hs-admin-ui 6.2.2 → 6.2.4

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.
Files changed (299) hide show
  1. package/dist/{401-BaFHDIol.mjs → 401-Bef_K-hx.mjs} +1 -1
  2. package/dist/{401-BDfTLdQm.js → 401-Du3L6F93.js} +1 -1
  3. package/dist/{404-BdT2Aypp.mjs → 404-C9wIn4yh.mjs} +1 -1
  4. package/dist/404-C9wIn4yh.mjs.gz +0 -0
  5. package/dist/{404-6NqKYrIg.js → 404-CChb_ibc.js} +1 -1
  6. package/dist/404-CChb_ibc.js.gz +0 -0
  7. package/dist/{account-C-akTMV6.mjs → account-BQZ3DLgm.mjs} +2 -2
  8. package/dist/account-BQZ3DLgm.mjs.gz +0 -0
  9. package/dist/{account-CpNGjqs0.js → account-Cy-kqWGK.js} +1 -1
  10. package/dist/account-Cy-kqWGK.js.gz +0 -0
  11. package/dist/{aside-Br6_c3a3.js → aside-D1unjpD5.js} +1 -1
  12. package/dist/{aside-YQcM3-ff.mjs → aside-D23yuhCh.mjs} +3 -3
  13. package/dist/{btnIndex-D1coJwQv.mjs → btnIndex-B3rlq6HK.mjs} +2 -2
  14. package/dist/btnIndex-B3rlq6HK.mjs.gz +0 -0
  15. package/dist/{btnIndex-D59oFt3n.js → btnIndex-CMLzfmGQ.js} +1 -1
  16. package/dist/{classic-BHVll-fD.mjs → classic-DoZOWPcG.mjs} +5 -5
  17. package/dist/{classic-CzWAsF3U.js → classic-rJ1cF8F9.js} +1 -1
  18. package/dist/{cloneConfigDialog-uMkYu28E.js → cloneConfigDialog-BK6sGZi8.js} +1 -1
  19. package/dist/{cloneConfigDialog-ABPlNVUl.mjs → cloneConfigDialog-Bnb0_FC_.mjs} +1 -1
  20. package/dist/cloneConfigDialog-Bnb0_FC_.mjs.gz +0 -0
  21. package/dist/{columns-DBoXNEtu.mjs → columns-B_qx6ORD.mjs} +5 -5
  22. package/dist/{columns-Bni3Ft_r.js → columns-OApPbL4W.js} +1 -1
  23. package/dist/{columnsAside-BRmzkJOf.js → columnsAside-CAzAyMUB.js} +1 -1
  24. package/dist/{columnsAside-B3wOgKGf.mjs → columnsAside-Cb3wGkLt.mjs} +1 -1
  25. package/dist/{contextmenu-D7tTOyO2.mjs → contextmenu-BVHpRsH0.mjs} +1 -1
  26. package/dist/{contextmenu-kothYDrF.mjs → contextmenu-BVJA_heU.mjs} +1 -1
  27. package/dist/{contextmenu-Bqkcp5ma.js → contextmenu-B_jb3bvP.js} +1 -1
  28. package/dist/{contextmenu-CMvJYAGk.js → contextmenu-CcXqbSYz.js} +1 -1
  29. package/dist/{contextmenu-Db1uMObU.js → contextmenu-Culjk0s9.js} +1 -1
  30. package/dist/{contextmenu-DC12Jepb.mjs → contextmenu-ovpTLQKm.mjs} +1 -1
  31. package/dist/{defaults-BH4PC0Ja.js → defaults-BFAFFOqe.js} +1 -1
  32. package/dist/{defaults-BvvK1lkg.mjs → defaults-C1fFvaho.mjs} +4 -4
  33. package/dist/{dialog-B0Ak8JfX.mjs → dialog-B0T3IztQ.mjs} +1 -1
  34. package/dist/{dialog-CGfI9cyT.js → dialog-B0fSJZHd.js} +1 -1
  35. package/dist/{dialog-D3W4YL6X.js → dialog-C9m4Q9le.js} +1 -1
  36. package/dist/{dialog-B-_6kZBx.js → dialog-CAh2arzy.js} +1 -1
  37. package/dist/{dialog-DylBMRnY.mjs → dialog-CBI_OWUW.mjs} +1 -1
  38. package/dist/{dialog-DphixweP.mjs → dialog-mEpJmJy2.mjs} +1 -1
  39. package/dist/{dialog.vue_vue_type_script_setup_true_name_dataAuthDialog_lang-B5hstOeV.js → dialog.vue_vue_type_script_setup_true_name_dataAuthDialog_lang-C_QGLXhZ.js} +1 -1
  40. package/dist/{dialog.vue_vue_type_script_setup_true_name_dataAuthDialog_lang-C5Q65Rl4.mjs → dialog.vue_vue_type_script_setup_true_name_dataAuthDialog_lang-D_dOwb-T.mjs} +2 -2
  41. package/dist/{dialog.vue_vue_type_script_setup_true_name_systemMenuDialog_lang-Ck72tLcE.mjs → dialog.vue_vue_type_script_setup_true_name_systemMenuDialog_lang-BUvGrhPb.mjs} +2 -2
  42. package/dist/dialog.vue_vue_type_script_setup_true_name_systemMenuDialog_lang-BUvGrhPb.mjs.gz +0 -0
  43. package/dist/{dialog.vue_vue_type_script_setup_true_name_systemMenuDialog_lang-C5L8cHDj.js → dialog.vue_vue_type_script_setup_true_name_systemMenuDialog_lang-BlCI0FmX.js} +1 -1
  44. package/dist/{dictDialog-DJ_F0ls1.js → dictDialog-C-0rXDgE.js} +1 -1
  45. package/dist/{dictDialog-uLyAPqpW.mjs → dictDialog-DuHH9WAj.mjs} +1 -1
  46. package/dist/{dictDialog.vue_vue_type_script_setup_true_name_dictDialog_lang-B-EjXh9w.js → dictDialog.vue_vue_type_script_setup_true_name_dictDialog_lang-C5foaCqr.js} +1 -1
  47. package/dist/{dictDialog.vue_vue_type_script_setup_true_name_dictDialog_lang-BCWKVYtk.mjs → dictDialog.vue_vue_type_script_setup_true_name_dictDialog_lang-DrBCjusp.mjs} +2 -2
  48. package/dist/{dictItemDialog-WVEH3HIS.mjs → dictItemDialog-CC5jRMiW.mjs} +1 -1
  49. package/dist/{dictItemDialog-BtDGLrcy.js → dictItemDialog-CMW_y2Up.js} +1 -1
  50. package/dist/{dictItemDialog.vue_vue_type_script_setup_true_lang-F-VV8USQ.js → dictItemDialog.vue_vue_type_script_setup_true_lang-Bwm85MO_.js} +1 -1
  51. package/dist/{dictItemDialog.vue_vue_type_script_setup_true_lang-VrGR-oCI.mjs → dictItemDialog.vue_vue_type_script_setup_true_lang-CZdfe4_p.mjs} +2 -2
  52. package/dist/{editDialog-DBZTUbYf.mjs → editDialog-Ch7A7xEJ.mjs} +1 -1
  53. package/dist/{editDialog-h-8uiduX.js → editDialog-Cuand05-.js} +1 -1
  54. package/dist/{formConfig-tFKDVa97.mjs → formConfig-BumORKxW.mjs} +4 -4
  55. package/dist/formConfig-BumORKxW.mjs.gz +0 -0
  56. package/dist/{formConfig-A5jQNaay.js → formConfig-Cs61eDY-.js} +1 -1
  57. package/dist/{header-yCN4SubB.js → header-CgkORQ5f.js} +1 -1
  58. package/dist/{header-pMAmLboA.mjs → header-PJkGB9vq.mjs} +2 -2
  59. package/dist/{horizontal-Ce1n7x-H.mjs → horizontal-Blhjb8sV.mjs} +2 -2
  60. package/dist/{horizontal-C6w3Skms.js → horizontal-CUendLGs.js} +1 -1
  61. package/dist/{hsAttrBtn-D8dxzUuw.mjs → hsAttrBtn-Dv9UfunN.mjs} +1 -1
  62. package/dist/{hsAttrBtn-DDBDfCjT.js → hsAttrBtn-Ef3WCIrG.js} +1 -1
  63. package/dist/{hsAttrBtn.vue_vue_type_script_setup_true_lang-DqsQQm4r.mjs → hsAttrBtn.vue_vue_type_script_setup_true_lang-BU0byVOP.mjs} +3 -3
  64. package/dist/{hsAttrBtn.vue_vue_type_script_setup_true_lang-CCRGcUpb.js → hsAttrBtn.vue_vue_type_script_setup_true_lang-Cj3TgcBo.js} +1 -1
  65. package/dist/{hsAttrForm-3ZxVQ7SC.js → hsAttrForm-B73JwuQc.js} +1 -1
  66. package/dist/{hsAttrForm-Be6gAbml.mjs → hsAttrForm-kmOHsHe2.mjs} +1 -1
  67. package/dist/{hsAttrForm.vue_vue_type_script_setup_true_lang-DpYbwuJV.mjs → hsAttrForm.vue_vue_type_script_setup_true_lang-C5Ib1-xG.mjs} +2 -2
  68. package/dist/hsAttrForm.vue_vue_type_script_setup_true_lang-C5Ib1-xG.mjs.gz +0 -0
  69. package/dist/{hsAttrForm.vue_vue_type_script_setup_true_lang-TD6haED1.js → hsAttrForm.vue_vue_type_script_setup_true_lang-CQBRufoq.js} +1 -1
  70. package/dist/{hsBtnConfigList-vdoQcwgc.mjs → hsBtnConfigList-BhwPIR7K.mjs} +1 -1
  71. package/dist/{hsBtnConfigList-Dg6yF15H.js → hsBtnConfigList-DJWibMab.js} +1 -1
  72. package/dist/{hsBtnItemConfig-CUVzj6oZ.js → hsBtnItemConfig-BPbQAsmX.js} +1 -1
  73. package/dist/{hsBtnItemConfig-BapYRz_F.mjs → hsBtnItemConfig-D2llIvGb.mjs} +1 -1
  74. package/dist/{hsBtnItemConfig.vue_vue_type_script_setup_true_lang-JksMLkR2.js → hsBtnItemConfig.vue_vue_type_script_setup_true_lang-C4-GoAX6.js} +1 -1
  75. package/dist/{hsBtnItemConfig.vue_vue_type_script_setup_true_lang-BdKKE4FS.mjs → hsBtnItemConfig.vue_vue_type_script_setup_true_lang-Fx0Ni-Oy.mjs} +1 -1
  76. package/dist/{hsBtnPanel-eAyep_EE.mjs → hsBtnPanel-4dTKgBqp.mjs} +1 -1
  77. package/dist/{hsBtnPanel-CLeokgZs.js → hsBtnPanel-kmhA_9i4.js} +1 -1
  78. package/dist/{hsBtnPanel.vue_vue_type_script_setup_true_name_formPanel_lang-DgypxhWV.js → hsBtnPanel.vue_vue_type_script_setup_true_name_formPanel_lang-BgSl5Fsb.js} +1 -1
  79. package/dist/{hsBtnPanel.vue_vue_type_script_setup_true_name_formPanel_lang-CQ37c4k5.mjs → hsBtnPanel.vue_vue_type_script_setup_true_name_formPanel_lang-D8eftfDe.mjs} +4 -4
  80. package/dist/{hsExpand-CCWEQwnB.mjs → hsExpand-C3Uqf8Ni.mjs} +1 -1
  81. package/dist/{hsExpand-CzODoJPJ.js → hsExpand-ElHHBoyb.js} +1 -1
  82. package/dist/{hsExpand.vue_vue_type_script_setup_true_lang-d8OZchdd.js → hsExpand.vue_vue_type_script_setup_true_lang-CtyddsSW.js} +1 -1
  83. package/dist/{hsExpand.vue_vue_type_script_setup_true_lang-DmIZP3Ws.mjs → hsExpand.vue_vue_type_script_setup_true_lang-DC-g-TvN.mjs} +1 -1
  84. package/dist/{hsFormConfig-BnsuHEU-.js → hsFormConfig-CUdXKLIh.js} +1 -1
  85. package/dist/{hsFormConfig-yPkaHdtV.mjs → hsFormConfig-CXNxDI_1.mjs} +1 -1
  86. package/dist/{hsFormConfigList-PWlWkgTd.js → hsFormConfigList-BV3ydHkw.js} +1 -1
  87. package/dist/{hsFormConfigList-uH63uHU8.mjs → hsFormConfigList-Ct3-6Chb.mjs} +2 -2
  88. package/dist/hsFormConfigList-Ct3-6Chb.mjs.gz +0 -0
  89. package/dist/{hsFormPanel-CD6-T9O7.js → hsFormPanel-BXEr121q.js} +1 -1
  90. package/dist/{hsFormPanel-CIktfzcJ.mjs → hsFormPanel-DrDvYOJf.mjs} +1 -1
  91. package/dist/{hsFormPanel.vue_vue_type_script_setup_true_name_formPanel_lang-VmVuSC0W.js → hsFormPanel.vue_vue_type_script_setup_true_name_formPanel_lang-BuFYihnB.js} +1 -1
  92. package/dist/{hsFormPanel.vue_vue_type_script_setup_true_name_formPanel_lang-DaSIxnpE.mjs → hsFormPanel.vue_vue_type_script_setup_true_name_formPanel_lang-DMlzsmHA.mjs} +5 -5
  93. package/dist/hsFormPanel.vue_vue_type_script_setup_true_name_formPanel_lang-DMlzsmHA.mjs.gz +0 -0
  94. package/dist/{hsFormParse-CJDVLgk0.js → hsFormParse-B6o42gLU.js} +1 -1
  95. package/dist/{hsFormParse-Cq0efPEk.mjs → hsFormParse-Dk7Q4FT2.mjs} +1 -1
  96. package/dist/{hsFormParse.vue_vue_type_script_setup_true_lang-CsxccxKE.js → hsFormParse.vue_vue_type_script_setup_true_lang-CpVwwG-0.js} +1 -1
  97. package/dist/{hsFormParse.vue_vue_type_script_setup_true_lang-DVKjawFK.mjs → hsFormParse.vue_vue_type_script_setup_true_lang-DppvOzsi.mjs} +1 -1
  98. package/dist/{hsPanelItem-BGXHM7jV.mjs → hsPanelItem-C5nHec5J.mjs} +1 -1
  99. package/dist/{hsPanelItem-CMomjPIQ.js → hsPanelItem-CwT51q_-.js} +1 -1
  100. package/dist/{hsPanelItem.vue_vue_type_script_setup_true_name_panelItem_lang-Bf8qRigU.js → hsPanelItem.vue_vue_type_script_setup_true_name_panelItem_lang-BfksL0sH.js} +1 -1
  101. package/dist/{hsPanelItem.vue_vue_type_script_setup_true_name_panelItem_lang-C30iv7OT.mjs → hsPanelItem.vue_vue_type_script_setup_true_name_panelItem_lang-yAml6Wil.mjs} +1 -1
  102. package/dist/{iframes-DW9C1fnA.js → iframes-5B-N3Cvt.js} +1 -1
  103. package/dist/{iframes-CwtjdJOg.mjs → iframes-DSH1iGqv.mjs} +1 -1
  104. package/dist/{index-FLihEM03.mjs → index-B1TEzs-m.mjs} +2 -2
  105. package/dist/{index-SCuf7Q4e.js → index-B2786SgB.js} +1 -1
  106. package/dist/{index-BKGCxBzy.js → index-B4bGdxNY.js} +1 -1
  107. package/dist/{index-DCBjWN0S.js → index-B7xVAK5P.js} +1 -1
  108. package/dist/{index-D_oFou_1.mjs → index-B8qF_6H3.mjs} +4 -4
  109. package/dist/{index-K7M-1od9.mjs → index-BDx5pPTm.mjs} +1 -1
  110. package/dist/{index-BS11O_Xq.mjs → index-BJx2YvYG.mjs} +2 -2
  111. package/dist/index-BJx2YvYG.mjs.gz +0 -0
  112. package/dist/{index-BAB-DG7v.mjs → index-BLJDZc3c.mjs} +56 -74
  113. package/dist/{index-BAB-DG7v.mjs.gz → index-BLJDZc3c.mjs.gz} +0 -0
  114. package/dist/{index-CrMBUDKT.mjs → index-BQ9sD47I.mjs} +3 -3
  115. package/dist/{index-C-_zZysC.mjs → index-BSghgEra.mjs} +1 -1
  116. package/dist/{index-oHQLbiOD.js → index-BW7rQDJY.js} +1 -1
  117. package/dist/{index-gtIzcox7.mjs → index-B_iaXX7d.mjs} +1 -1
  118. package/dist/{index-koHHrjcT.js → index-Bc5G_06G.js} +4 -4
  119. package/dist/{index-koHHrjcT.js.gz → index-Bc5G_06G.js.gz} +0 -0
  120. package/dist/{index-B7pFuECQ.js → index-BcVji-B9.js} +1 -1
  121. package/dist/index-BcVji-B9.js.gz +0 -0
  122. package/dist/{index-DVD690iz.js → index-BfTUtKlB.js} +1 -1
  123. package/dist/{index-Ccyx_wvR.mjs → index-BhygW8Hy.mjs} +1 -1
  124. package/dist/{index-DOPIYZ5g.js → index-BmXod-WD.js} +1 -1
  125. package/dist/{index-GRTXZhBL.js → index-BoJqRMDA.js} +1 -1
  126. package/dist/{index-ClMq3Klu.js → index-BtbgXUQj.js} +1 -1
  127. package/dist/{index-BRopzZGe.js → index-BwRIAice.js} +1 -1
  128. package/dist/{index-91XigVJA.mjs → index-BxDXMc_R.mjs} +2 -2
  129. package/dist/{index-CGJqoS7P.mjs → index-BxOYJXjv.mjs} +1 -1
  130. package/dist/{index-CVU5buvx.mjs → index-C26nBdZn.mjs} +1 -1
  131. package/dist/{index-CWW8e1cX.mjs → index-C35MbBFy.mjs} +1 -1
  132. package/dist/{index-BoYnDHV0.js → index-CCE9UQgn.js} +1 -1
  133. package/dist/{index-D3boZUxF.js → index-COOnCwD6.js} +1 -1
  134. package/dist/{index-DTKgZGnq.mjs → index-CUO_3h_E.mjs} +4 -4
  135. package/dist/{index-DuxY5-V8.mjs → index-CWUHQHLf.mjs} +1 -1
  136. package/dist/{index-ayF43nQn.mjs → index-CaYx6_Ml.mjs} +1 -1
  137. package/dist/index-CaYx6_Ml.mjs.gz +0 -0
  138. package/dist/{index-CzPF82RJ.mjs → index-CdjgsLLJ.mjs} +3 -3
  139. package/dist/{index-Blpe1ZXl.mjs → index-CfjmXxPt.mjs} +1 -1
  140. package/dist/{index-B6hm5q2r.mjs → index-Ch6R1wHF.mjs} +1 -1
  141. package/dist/{index-Vit0wRE-.mjs → index-ChAqh7Rt.mjs} +2 -2
  142. package/dist/{index-DB3OZwde.mjs → index-ClZzCwKX.mjs} +1 -1
  143. package/dist/{index-xm1WbA05.js → index-CldFHDLg.js} +1 -1
  144. package/dist/{index-D89vdQJF.js → index-CyLXdoVE.js} +1 -1
  145. package/dist/{index-BiI8qj7X.mjs → index-D-VOVGuI.mjs} +3 -3
  146. package/dist/{index-OvWYLnUi.mjs → index-D2tO9xG1.mjs} +1 -1
  147. package/dist/{index-u-qX3KoS.js → index-D4dZpxBy.js} +1 -1
  148. package/dist/{index-C2Y2XLCh.js → index-D512Tfhv.js} +1 -1
  149. package/dist/{index-BkCNff19.js → index-D7RzSbVS.js} +1 -1
  150. package/dist/index-D7RzSbVS.js.gz +0 -0
  151. package/dist/{index-CYKm4XNy.js → index-D80yiVZ0.js} +1 -1
  152. package/dist/{index-BeadDz3c.js → index-D8YIsqBq.js} +1 -1
  153. package/dist/{index-DTUXE4It.mjs → index-DCO6mkY2.mjs} +1 -1
  154. package/dist/{index-Dl1Nw2wP.mjs → index-DGh__iqp.mjs} +1 -1
  155. package/dist/{index-CrICGB1o.mjs → index-DM2nI_J2.mjs} +2 -2
  156. package/dist/{index-epL-JEfW.js → index-DMkQQb8B.js} +1 -1
  157. package/dist/{index-Cg_-snAI.mjs → index-DNXJlbEV.mjs} +1 -1
  158. package/dist/{index-Bf5JQwzv.js → index-DOpBkfv2.js} +1 -1
  159. package/dist/{index-BKeF6fg0.js → index-DPHph6eT.js} +1 -1
  160. package/dist/{index-alb36AdY.js → index-DSpkbu9h.js} +1 -1
  161. package/dist/{index-Bh9_D-mY.mjs → index-DVQizqhD.mjs} +3 -3
  162. package/dist/{index-CbF1yWZU.mjs → index-DWVu16e2.mjs} +1 -1
  163. package/dist/index-DWVu16e2.mjs.gz +0 -0
  164. package/dist/{index-CO7QTEV1.mjs → index-DWpF8wdu.mjs} +5 -5
  165. package/dist/{index-x01105pK.js → index-DYFe_Adv.js} +1 -1
  166. package/dist/{index-D9-dE38a.js → index-D_LIDONE.js} +1 -1
  167. package/dist/{index-DZWd3ID7.js → index-DnTRToQW.js} +1 -1
  168. package/dist/{index-DxXPulxx.js → index-Dq6UcMyz.js} +1 -1
  169. package/dist/{index-DT8zEnyG.mjs → index-Dw9dGTdq.mjs} +2 -2
  170. package/dist/{index-DT8zEnyG.mjs.gz → index-Dw9dGTdq.mjs.gz} +0 -0
  171. package/dist/{index-xsTrKcAD.js → index-Dy5Htf4F.js} +1 -1
  172. package/dist/{index-CT7viBCL.mjs → index-DzYEbqVL.mjs} +1 -1
  173. package/dist/{index-ze58sgNO.mjs → index-HBSdvJ7A.mjs} +1 -1
  174. package/dist/{index-DP6Pk3JT.js → index-aIPKtbgc.js} +1 -1
  175. package/dist/{index-CjLlh8h5.js → index-bvSE9Gh2.js} +1 -1
  176. package/dist/{index-T5vVcZnW.mjs → index-dJ-Nv6Op.mjs} +4 -4
  177. package/dist/index-dJ-Nv6Op.mjs.gz +0 -0
  178. package/dist/{index-CGnd9OVs.js → index-dtKsizWS.js} +1 -1
  179. package/dist/{index-CaYG_H1p.mjs → index-ejKx6lWQ.mjs} +1 -1
  180. package/dist/{index-BfGSHaIN.js → index-fNYeOLeK.js} +1 -1
  181. package/dist/{index-BSCvY0UU.js → index-jQ1aFKfD.js} +1 -1
  182. package/dist/index-jQ1aFKfD.js.gz +0 -0
  183. package/dist/{index-1TOysUYx.js → index-jS-zmqNo.js} +1 -1
  184. package/dist/index-n3QXyNNr.mjs +4 -0
  185. package/dist/{index-C8F3LANA.js → index-q9cb8xya.js} +1 -1
  186. package/dist/index.js +1 -1
  187. package/dist/index.mjs +1 -1
  188. package/dist/{index.vue_vue_type_script_setup_true_lang-D749UqtU.mjs → index.vue_vue_type_script_setup_true_lang-AWpxbTq8.mjs} +1 -1
  189. package/dist/index.vue_vue_type_script_setup_true_lang-AWpxbTq8.mjs.gz +0 -0
  190. package/dist/{index.vue_vue_type_script_setup_true_lang-CKZetK6c.mjs → index.vue_vue_type_script_setup_true_lang-BFAaL8v9.mjs} +1 -1
  191. package/dist/{index.vue_vue_type_script_setup_true_lang-B4klBSL1.mjs → index.vue_vue_type_script_setup_true_lang-BexDPw2a.mjs} +4 -4
  192. package/dist/{index.vue_vue_type_script_setup_true_lang-De7IKx5Z.js → index.vue_vue_type_script_setup_true_lang-BqFxdloS.js} +1 -1
  193. package/dist/{index.vue_vue_type_script_setup_true_lang-BerfpQSE.js → index.vue_vue_type_script_setup_true_lang-C79N0XbY.js} +1 -1
  194. package/dist/{index.vue_vue_type_script_setup_true_lang-Bh4Xf2iH.js → index.vue_vue_type_script_setup_true_lang-CEeQq_XE.js} +1 -1
  195. package/dist/{index.vue_vue_type_script_setup_true_lang-Ce-2tBgE.js → index.vue_vue_type_script_setup_true_lang-D4P__RfI.js} +1 -1
  196. package/dist/{index.vue_vue_type_script_setup_true_lang-DqdiAfRS.mjs → index.vue_vue_type_script_setup_true_lang-FnvgHQnL.mjs} +1 -1
  197. package/dist/index.vue_vue_type_script_setup_true_name_commodityClassify_lang-BNy1NXdG.js +1 -0
  198. package/dist/{index.vue_vue_type_script_setup_true_name_commodityClassify_lang-C06LmPLj.mjs → index.vue_vue_type_script_setup_true_name_commodityClassify_lang-BR2xIQdY.mjs} +2 -2
  199. package/dist/{link-Qdp1VB_9.mjs → link-DQG3lBmc.mjs} +1 -1
  200. package/dist/{link-CIB11l20.js → link-Vbkke20E.js} +1 -1
  201. package/dist/{list-CM1qzoA-.js → list-BYORrSPh.js} +1 -1
  202. package/dist/{list-WxQXwHZG.mjs → list-BaSQDDdy.mjs} +1 -1
  203. package/dist/{main-D6nWawKs.mjs → main-CazHn3mk.mjs} +3 -3
  204. package/dist/{main-UBBi_kjX.js → main-EnzMXa1Y.js} +1 -1
  205. package/dist/{mobile-CqaNS2Vf.mjs → mobile-BdJ5OjSX.mjs} +1 -1
  206. package/dist/{mobile-ByNpEEO_.js → mobile-CpGgLI5A.js} +1 -1
  207. package/dist/{parent-C7qmwrXx.mjs → parent-B1754FsK.mjs} +2 -2
  208. package/dist/{parent-M186Qoio.js → parent-BkJTNV-C.js} +1 -1
  209. package/dist/{popup-_lR9fjw9.js → popup-Dl0KpSkM.js} +1 -1
  210. package/dist/{popup-CZxhd1r4.mjs → popup-v7xAm6gN.mjs} +1 -1
  211. package/dist/{popup.vue_vue_type_script_setup_true_name_editorPopup_lang-CY0qqgdX.mjs → popup.vue_vue_type_script_setup_true_name_editorPopup_lang-BOHxsWOM.mjs} +1 -1
  212. package/dist/{popup.vue_vue_type_script_setup_true_name_editorPopup_lang-DWrfbSeK.js → popup.vue_vue_type_script_setup_true_name_editorPopup_lang-RwmN80R3.js} +1 -1
  213. package/dist/{replaceRules-B4uWLp-z.js → replaceRules-BXeLD2ll.js} +1 -1
  214. package/dist/{replaceRules-BS7iGZWN.mjs → replaceRules-Cx3qE-lz.mjs} +1 -1
  215. package/dist/{roleItem-C9_266Qz.js → roleItem-COfKStHR.js} +1 -1
  216. package/dist/{roleItem-CHTgT-Cf.mjs → roleItem-DEGVquWc.mjs} +1 -1
  217. package/dist/{saveForm-BBIlE4bA.js → saveForm-DLCIn7LY.js} +1 -1
  218. package/dist/{saveForm-DtRVePAY.mjs → saveForm-MEGCzHk6.mjs} +1 -1
  219. package/dist/{saveForm.vue_vue_type_script_setup_true_lang-Bzf3g_Gw.mjs → saveForm.vue_vue_type_script_setup_true_lang-C-Ay7T8t.mjs} +2 -2
  220. package/dist/saveForm.vue_vue_type_script_setup_true_lang-C-Ay7T8t.mjs.gz +0 -0
  221. package/dist/{saveForm.vue_vue_type_script_setup_true_lang-DZPfE6km.js → saveForm.vue_vue_type_script_setup_true_lang-DTCNDTNB.js} +1 -1
  222. package/dist/{scan-DN_eaZqO.js → scan-Cb6i-QuQ.js} +1 -1
  223. package/dist/scan-Cb6i-QuQ.js.gz +0 -0
  224. package/dist/{scan-CoPkaY0Z.mjs → scan-DaDQG8LI.mjs} +1 -1
  225. package/dist/scan-DaDQG8LI.mjs.gz +0 -0
  226. package/dist/{search-CSESmAHt.js → search-BsoGdl2p.js} +1 -1
  227. package/dist/{search-BNNjQ9gX.mjs → search-GS5eSo0a.mjs} +1 -1
  228. package/dist/{selectConfig-ntC6Pgi0.js → selectConfig---3mI_ac.js} +1 -1
  229. package/dist/{selectConfig-BlTqbP2_.mjs → selectConfig-C1cb3F_a.mjs} +1 -1
  230. package/dist/selectConfig-C1cb3F_a.mjs.gz +0 -0
  231. package/dist/style.css +1 -1
  232. package/dist/style.css.gz +0 -0
  233. package/dist/{subItem-4TY6fE8-.js → subItem-EEb0ZZIH.js} +1 -1
  234. package/dist/{subItem-DnfvuPd3.mjs → subItem-P2Y0JBsf.mjs} +1 -1
  235. package/dist/{tagsView-BfgCH6t5.js → tagsView-BY3P1SJU.js} +2 -2
  236. package/dist/tagsView-BY3P1SJU.js.gz +0 -0
  237. package/dist/{tagsView-DfBzWbw7.mjs → tagsView-w8wvOUNI.mjs} +2 -2
  238. package/dist/tagsView-w8wvOUNI.mjs.gz +0 -0
  239. package/dist/{transverse-DdkbKVgY.js → transverse-BF77TZz3.js} +1 -1
  240. package/dist/{transverse-CliO2yvR.mjs → transverse-DkOIZvrd.mjs} +3 -3
  241. package/dist/{trtcUI-Bg5hipmK.mjs → trtcUI-B-trDWSl.mjs} +1 -1
  242. package/dist/trtcUI-B-trDWSl.mjs.gz +0 -0
  243. package/dist/{trtcUI-BlyZB0XB.js → trtcUI-xXHsyAD6.js} +1 -1
  244. package/dist/trtcUI-xXHsyAD6.js.gz +0 -0
  245. package/dist/types/components/business/bcTable/bcFormTable.vue.d.ts +1 -1
  246. package/dist/types/components/business/bcTable/utils/onFormKey.d.ts +1 -2
  247. package/dist/types/components/business/bcTable/utils/onTableKey.d.ts +2 -2
  248. package/dist/types/components/business/bcTable/utils/type.d.ts +6 -2
  249. package/dist/types/components/business/bcTable/utils/useButon.d.ts +2 -3
  250. package/dist/types/components/business/bcTable/utils/useTable.d.ts +2 -2
  251. package/dist/types/utils/storage.d.ts +1 -1
  252. package/dist/{uploadAvatar-eOk1BvgN.mjs → uploadAvatar-BSjd_PgD.mjs} +1 -1
  253. package/dist/uploadAvatar-BSjd_PgD.mjs.gz +0 -0
  254. package/dist/{uploadAvatar-DymUvBP6.js → uploadAvatar-DwZlhWso.js} +1 -1
  255. package/dist/uploadAvatar-DwZlhWso.js.gz +0 -0
  256. package/dist/{user-B19RCz6r.js → user-B9d0M5uN.js} +1 -1
  257. package/dist/{user-mAo5l6T4.mjs → user-wRb4nLGr.mjs} +4 -4
  258. package/dist/user-wRb4nLGr.mjs.gz +0 -0
  259. package/dist/{userNews-BjUp0PKB.mjs → userNews-5utNAxvP.mjs} +1 -1
  260. package/dist/{userNews-Ctli7L8O.js → userNews-YC2sSppu.js} +1 -1
  261. package/dist/{userSelect-BX5Isd4o.mjs → userSelect-BEsU17WE.mjs} +1 -1
  262. package/dist/{userSelect-CKUVNYg0.js → userSelect-COow_xK8.js} +1 -1
  263. package/dist/{userSelect.vue_vue_type_script_setup_true_lang-DgXeV4Q8.mjs → userSelect.vue_vue_type_script_setup_true_lang-B4tyE2z6.mjs} +1 -1
  264. package/dist/{userSelect.vue_vue_type_script_setup_true_lang-Dh0UyfTC.js → userSelect.vue_vue_type_script_setup_true_lang-CffzNKzY.js} +1 -1
  265. package/dist/{vertical-vEVWWpwR.js → vertical-Bp8QJGTs.js} +1 -1
  266. package/dist/{vertical-BmpqfLjQ.mjs → vertical-D59sNdtX.mjs} +2 -2
  267. package/package.json +3 -3
  268. package/dist/404-6NqKYrIg.js.gz +0 -0
  269. package/dist/404-BdT2Aypp.mjs.gz +0 -0
  270. package/dist/account-C-akTMV6.mjs.gz +0 -0
  271. package/dist/account-CpNGjqs0.js.gz +0 -0
  272. package/dist/btnIndex-D1coJwQv.mjs.gz +0 -0
  273. package/dist/cloneConfigDialog-ABPlNVUl.mjs.gz +0 -0
  274. package/dist/dialog.vue_vue_type_script_setup_true_name_systemMenuDialog_lang-Ck72tLcE.mjs.gz +0 -0
  275. package/dist/formConfig-tFKDVa97.mjs.gz +0 -0
  276. package/dist/hsAttrForm.vue_vue_type_script_setup_true_lang-DpYbwuJV.mjs.gz +0 -0
  277. package/dist/hsFormConfigList-uH63uHU8.mjs.gz +0 -0
  278. package/dist/hsFormPanel.vue_vue_type_script_setup_true_name_formPanel_lang-DaSIxnpE.mjs.gz +0 -0
  279. package/dist/index-B7pFuECQ.js.gz +0 -0
  280. package/dist/index-BS11O_Xq.mjs.gz +0 -0
  281. package/dist/index-BSCvY0UU.js.gz +0 -0
  282. package/dist/index-BkCNff19.js.gz +0 -0
  283. package/dist/index-CbF1yWZU.mjs.gz +0 -0
  284. package/dist/index-CdEhy3Nm.mjs +0 -4
  285. package/dist/index-T5vVcZnW.mjs.gz +0 -0
  286. package/dist/index-ayF43nQn.mjs.gz +0 -0
  287. package/dist/index.vue_vue_type_script_setup_true_lang-D749UqtU.mjs.gz +0 -0
  288. package/dist/index.vue_vue_type_script_setup_true_name_commodityClassify_lang-BT_QbUrK.js +0 -1
  289. package/dist/saveForm.vue_vue_type_script_setup_true_lang-Bzf3g_Gw.mjs.gz +0 -0
  290. package/dist/scan-CoPkaY0Z.mjs.gz +0 -0
  291. package/dist/scan-DN_eaZqO.js.gz +0 -0
  292. package/dist/selectConfig-BlTqbP2_.mjs.gz +0 -0
  293. package/dist/tagsView-BfgCH6t5.js.gz +0 -0
  294. package/dist/tagsView-DfBzWbw7.mjs.gz +0 -0
  295. package/dist/trtcUI-Bg5hipmK.mjs.gz +0 -0
  296. package/dist/trtcUI-BlyZB0XB.js.gz +0 -0
  297. package/dist/uploadAvatar-DymUvBP6.js.gz +0 -0
  298. package/dist/uploadAvatar-eOk1BvgN.mjs.gz +0 -0
  299. package/dist/user-mAo5l6T4.mjs.gz +0 -0
@@ -1 +1 @@
1
- "use strict";const e=require("vue"),t=require("./index-koHHrjcT.js");var i,r={exports:{}};i=r,t.commonjsGlobal,i.exports=function(){function e(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(i){if("default"!==i&&!(i in e)){var r=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,r.get?r:{enumerable:!0,get:function(){return t[i]}})}}))})),Object.freeze(e)}var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==t.commonjsGlobal?t.commonjsGlobal:"undefined"!=typeof self?self:{},r=function(e){try{return!!e()}catch(Th){return!0}},n=!r((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),o=n,s=Function.prototype,a=s.call,c=o&&s.bind.bind(a,a),l=o?c:function(e){return function(){return a.apply(e,arguments)}},d=l,u=d({}.toString),h=d("".slice),p=function(e){return h(u(e),8,-1)},m=r,_=p,f=Object,g=l("".split),E=m((function(){return!f("z").propertyIsEnumerable(0)}))?function(e){return"String"==_(e)?g(e,""):f(e)}:f,v=function(e){return null==e},y=v,T=TypeError,S=function(e){if(y(e))throw T("Can't call method on "+e);return e},I=E,A=S,R=function(e){return I(A(e))},b=function(e){return e&&e.Math==Math&&e},C=b("object"==typeof globalThis&&globalThis)||b("object"==typeof window&&window)||b("object"==typeof self&&self)||b("object"==typeof i&&i)||function(){return this}()||Function("return this")(),k={},w={get exports(){return k},set exports(e){k=e}},N=C,D=Object.defineProperty,O=function(e,t){try{D(N,e,{value:t,configurable:!0,writable:!0})}catch(i){N[e]=t}return t},L=O,P="__core-js_shared__",M=C[P]||L(P,{}),x=M;(w.exports=function(e,t){return x[e]||(x[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.30.0",mode:"global",copyright:"© 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.30.0/LICENSE",source:"https://github.com/zloirock/core-js"});var V,U,B=S,F=Object,H=function(e){return F(B(e))},j=H,W=l({}.hasOwnProperty),z=Object.hasOwn||function(e,t){return W(j(e),t)},G=l,K=0,Y=Math.random(),J=G(1..toString),q=function(e){return"Symbol("+(void 0===e?"":e)+")_"+J(++K+Y,36)},X="undefined"!=typeof navigator&&String(navigator.userAgent)||"",Q=C,Z=X,$=Q.process,ee=Q.Deno,te=$&&$.versions||ee&&ee.version,ie=te&&te.v8;ie&&(U=(V=ie.split("."))[0]>0&&V[0]<4?1:+(V[0]+V[1])),!U&&Z&&(!(V=Z.match(/Edge\/(\d+)/))||V[1]>=74)&&(V=Z.match(/Chrome\/(\d+)/))&&(U=+V[1]);var re=U,ne=re,oe=r,se=!!Object.getOwnPropertySymbols&&!oe((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&ne&&ne<41})),ae=se&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,ce=k,le=z,de=q,ue=se,he=ae,pe=C.Symbol,me=ce("wks"),_e=he?pe.for||pe:pe&&pe.withoutSetter||de,fe=function(e){return le(me,e)||(me[e]=ue&&le(pe,e)?pe[e]:_e("Symbol."+e)),me[e]},ge="object"==typeof document&&document.all,Ee={all:ge,IS_HTMLDDA:void 0===ge&&void 0!==ge},ve=Ee.all,ye=Ee.IS_HTMLDDA?function(e){return"function"==typeof e||e===ve}:function(e){return"function"==typeof e},Te=ye,Se=Ee.all,Ie=Ee.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:Te(e)||e===Se}:function(e){return"object"==typeof e?null!==e:Te(e)},Ae=Ie,Re=String,be=TypeError,Ce=function(e){if(Ae(e))return e;throw be(Re(e)+" is not an object")},ke={},we=!r((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),Ne=we&&r((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),De={},Oe=Ie,Le=C.document,Pe=Oe(Le)&&Oe(Le.createElement),Me=function(e){return Pe?Le.createElement(e):{}},xe=Me,Ve=!we&&!r((function(){return 7!=Object.defineProperty(xe("div"),"a",{get:function(){return 7}}).a})),Ue=n,Be=Function.prototype.call,Fe=Ue?Be.bind(Be):function(){return Be.apply(Be,arguments)},He=C,je=ye,We=function(e,t){return arguments.length<2?(i=He[e],je(i)?i:void 0):He[e]&&He[e][t];var i},ze=l({}.isPrototypeOf),Ge=We,Ke=ye,Ye=ze,Je=Object,qe=ae?function(e){return"symbol"==typeof e}:function(e){var t=Ge("Symbol");return Ke(t)&&Ye(t.prototype,Je(e))},Xe=String,Qe=function(e){try{return Xe(e)}catch(Th){return"Object"}},Ze=ye,$e=Qe,et=TypeError,tt=function(e){if(Ze(e))return e;throw et($e(e)+" is not a function")},it=tt,rt=v,nt=function(e,t){var i=e[t];return rt(i)?void 0:it(i)},ot=Fe,st=ye,at=Ie,ct=TypeError,lt=Fe,dt=Ie,ut=qe,ht=nt,pt=function(e,t){var i,r;if("string"===t&&st(i=e.toString)&&!at(r=ot(i,e)))return r;if(st(i=e.valueOf)&&!at(r=ot(i,e)))return r;if("string"!==t&&st(i=e.toString)&&!at(r=ot(i,e)))return r;throw ct("Can't convert object to primitive value")},mt=TypeError,_t=fe("toPrimitive"),ft=function(e,t){if(!dt(e)||ut(e))return e;var i,r=ht(e,_t);if(r){if(void 0===t&&(t="default"),i=lt(r,e,t),!dt(i)||ut(i))return i;throw mt("Can't convert object to primitive value")}return void 0===t&&(t="number"),pt(e,t)},gt=ft,Et=qe,vt=function(e){var t=gt(e,"string");return Et(t)?t:t+""},yt=we,Tt=Ve,St=Ne,It=Ce,At=vt,Rt=TypeError,bt=Object.defineProperty,Ct=Object.getOwnPropertyDescriptor,kt="enumerable",wt="configurable",Nt="writable";De.f=yt?St?function(e,t,i){if(It(e),t=At(t),It(i),"function"==typeof e&&"prototype"===t&&"value"in i&&Nt in i&&!i[Nt]){var r=Ct(e,t);r&&r[Nt]&&(e[t]=i.value,i={configurable:wt in i?i[wt]:r[wt],enumerable:kt in i?i[kt]:r[kt],writable:!1})}return bt(e,t,i)}:bt:function(e,t,i){if(It(e),t=At(t),It(i),Tt)try{return bt(e,t,i)}catch(r){}if("get"in i||"set"in i)throw Rt("Accessors not supported");return"value"in i&&(e[t]=i.value),e};var Dt=Math.ceil,Ot=Math.floor,Lt=Math.trunc||function(e){var t=+e;return(t>0?Ot:Dt)(t)},Pt=function(e){var t=+e;return t!=t||0===t?0:Lt(t)},Mt=Pt,xt=Math.max,Vt=Math.min,Ut=function(e,t){var i=Mt(e);return i<0?xt(i+t,0):Vt(i,t)},Bt=Pt,Ft=Math.min,Ht=function(e){return e>0?Ft(Bt(e),9007199254740991):0},jt=Ht,Wt=function(e){return jt(e.length)},zt=R,Gt=Ut,Kt=Wt,Yt=function(e){return function(t,i,r){var n,o=zt(t),s=Kt(o),a=Gt(r,s);if(e&&i!=i){for(;s>a;)if((n=o[a++])!=n)return!0}else for(;s>a;a++)if((e||a in o)&&o[a]===i)return e||a||0;return!e&&-1}},Jt={includes:Yt(!0),indexOf:Yt(!1)},qt={},Xt=z,Qt=R,Zt=Jt.indexOf,$t=qt,ei=l([].push),ti=function(e,t){var i,r=Qt(e),n=0,o=[];for(i in r)!Xt($t,i)&&Xt(r,i)&&ei(o,i);for(;t.length>n;)Xt(r,i=t[n++])&&(~Zt(o,i)||ei(o,i));return o},ii=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],ri=ti,ni=ii,oi=Object.keys||function(e){return ri(e,ni)},si=we,ai=Ne,ci=De,li=Ce,di=R,ui=oi;ke.f=si&&!ai?Object.defineProperties:function(e,t){li(e);for(var i,r=di(t),n=ui(t),o=n.length,s=0;o>s;)ci.f(e,i=n[s++],r[i]);return e};var hi,pi=We("document","documentElement"),mi=q,_i=k("keys"),fi=function(e){return _i[e]||(_i[e]=mi(e))},gi=Ce,Ei=ke,vi=ii,yi=qt,Ti=pi,Si=Me,Ii="prototype",Ai="script",Ri=fi("IE_PROTO"),bi=function(){},Ci=function(e){return"<"+Ai+">"+e+"</"+Ai+">"},ki=function(e){e.write(Ci("")),e.close();var t=e.parentWindow.Object;return e=null,t},wi=function(){try{hi=new ActiveXObject("htmlfile")}catch(n){}var e,t,i;wi="undefined"!=typeof document?document.domain&&hi?ki(hi):(t=Si("iframe"),i="java"+Ai+":",t.style.display="none",Ti.appendChild(t),t.src=String(i),(e=t.contentWindow.document).open(),e.write(Ci("document.F=Object")),e.close(),e.F):ki(hi);for(var r=vi.length;r--;)delete wi[Ii][vi[r]];return wi()};yi[Ri]=!0;var Ni=Object.create||function(e,t){var i;return null!==e?(bi[Ii]=gi(e),i=new bi,bi[Ii]=null,i[Ri]=e):i=wi(),void 0===t?i:Ei.f(i,t)},Di=fe,Oi=Ni,Li=De.f,Pi=Di("unscopables"),Mi=Array.prototype;null==Mi[Pi]&&Li(Mi,Pi,{configurable:!0,value:Oi(null)});var xi,Vi,Ui,Bi=function(e){Mi[Pi][e]=!0},Fi={},Hi=ye,ji=C.WeakMap,Wi=Hi(ji)&&/native code/.test(String(ji)),zi=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},Gi=De,Ki=zi,Yi=we?function(e,t,i){return Gi.f(e,t,Ki(1,i))}:function(e,t,i){return e[t]=i,e},Ji=Wi,qi=C,Xi=Ie,Qi=Yi,Zi=z,$i=M,er=fi,tr=qt,ir="Object already initialized",rr=qi.TypeError,nr=qi.WeakMap;if(Ji||$i.state){var or=$i.state||($i.state=new nr);or.get=or.get,or.has=or.has,or.set=or.set,xi=function(e,t){if(or.has(e))throw rr(ir);return t.facade=e,or.set(e,t),t},Vi=function(e){return or.get(e)||{}},Ui=function(e){return or.has(e)}}else{var sr=er("state");tr[sr]=!0,xi=function(e,t){if(Zi(e,sr))throw rr(ir);return t.facade=e,Qi(e,sr,t),t},Vi=function(e){return Zi(e,sr)?e[sr]:{}},Ui=function(e){return Zi(e,sr)}}var ar={set:xi,get:Vi,has:Ui,enforce:function(e){return Ui(e)?Vi(e):xi(e,{})},getterFor:function(e){return function(t){var i;if(!Xi(t)||(i=Vi(t)).type!==e)throw rr("Incompatible receiver, "+e+" required");return i}}},cr={},lr={},dr={}.propertyIsEnumerable,ur=Object.getOwnPropertyDescriptor,hr=ur&&!dr.call({1:2},1);lr.f=hr?function(e){var t=ur(this,e);return!!t&&t.enumerable}:dr;var pr=we,mr=Fe,_r=lr,fr=zi,gr=R,Er=vt,vr=z,yr=Ve,Tr=Object.getOwnPropertyDescriptor;cr.f=pr?Tr:function(e,t){if(e=gr(e),t=Er(t),yr)try{return Tr(e,t)}catch(i){}if(vr(e,t))return fr(!mr(_r.f,e,t),e[t])};var Sr={},Ir={get exports(){return Sr},set exports(e){Sr=e}},Ar=we,Rr=z,br=Function.prototype,Cr=Ar&&Object.getOwnPropertyDescriptor,kr=Rr(br,"name"),wr={EXISTS:kr,PROPER:kr&&"something"===function(){}.name,CONFIGURABLE:kr&&(!Ar||Ar&&Cr(br,"name").configurable)},Nr=ye,Dr=M,Or=l(Function.toString);Nr(Dr.inspectSource)||(Dr.inspectSource=function(e){return Or(e)});var Lr=Dr.inspectSource,Pr=l,Mr=r,xr=ye,Vr=z,Ur=we,Br=wr.CONFIGURABLE,Fr=Lr,Hr=ar.enforce,jr=ar.get,Wr=String,zr=Object.defineProperty,Gr=Pr("".slice),Kr=Pr("".replace),Yr=Pr([].join),Jr=Ur&&!Mr((function(){return 8!==zr((function(){}),"length",{value:8}).length})),qr=String(String).split("String"),Xr=Ir.exports=function(e,t,i){"Symbol("===Gr(Wr(t),0,7)&&(t="["+Kr(Wr(t),/^Symbol\(([^)]*)\)/,"$1")+"]"),i&&i.getter&&(t="get "+t),i&&i.setter&&(t="set "+t),(!Vr(e,"name")||Br&&e.name!==t)&&(Ur?zr(e,"name",{value:t,configurable:!0}):e.name=t),Jr&&i&&Vr(i,"arity")&&e.length!==i.arity&&zr(e,"length",{value:i.arity});try{i&&Vr(i,"constructor")&&i.constructor?Ur&&zr(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(n){}var r=Hr(e);return Vr(r,"source")||(r.source=Yr(qr,"string"==typeof t?t:"")),e};Function.prototype.toString=Xr((function(){return xr(this)&&jr(this).source||Fr(this)}),"toString");var Qr=ye,Zr=De,$r=Sr,en=O,tn=function(e,t,i,r){r||(r={});var n=r.enumerable,o=void 0!==r.name?r.name:t;if(Qr(i)&&$r(i,o,r),r.global)n?e[t]=i:en(t,i);else{try{r.unsafe?e[t]&&(n=!0):delete e[t]}catch(s){}n?e[t]=i:Zr.f(e,t,{value:i,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return e},rn={},nn=ti,on=ii.concat("length","prototype");rn.f=Object.getOwnPropertyNames||function(e){return nn(e,on)};var sn={};sn.f=Object.getOwnPropertySymbols;var an,cn,ln,dn=We,un=rn,hn=sn,pn=Ce,mn=l([].concat),_n=dn("Reflect","ownKeys")||function(e){var t=un.f(pn(e)),i=hn.f;return i?mn(t,i(e)):t},fn=z,gn=_n,En=cr,vn=De,yn=function(e,t,i){for(var r=gn(t),n=vn.f,o=En.f,s=0;s<r.length;s++){var a=r[s];fn(e,a)||i&&fn(i,a)||n(e,a,o(t,a))}},Tn=r,Sn=ye,In=/#|\.prototype\./,An=function(e,t){var i=bn[Rn(e)];return i==kn||i!=Cn&&(Sn(t)?Tn(t):!!t)},Rn=An.normalize=function(e){return String(e).replace(In,".").toLowerCase()},bn=An.data={},Cn=An.NATIVE="N",kn=An.POLYFILL="P",wn=An,Nn=C,Dn=cr.f,On=Yi,Ln=tn,Pn=O,Mn=yn,xn=wn,Vn=function(e,t){var i,r,n,o,s,a=e.target,c=e.global,l=e.stat;if(i=c?Nn:l?Nn[a]||Pn(a,{}):(Nn[a]||{}).prototype)for(r in t){if(o=t[r],n=e.dontCallGetSet?(s=Dn(i,r))&&s.value:i[r],!xn(c?r:a+(l?".":"#")+r,e.forced)&&void 0!==n){if(typeof o==typeof n)continue;Mn(o,n)}(e.sham||n&&n.sham)&&On(o,"sham",!0),Ln(i,r,o,e)}},Un=!r((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),Bn=z,Fn=ye,Hn=H,jn=Un,Wn=fi("IE_PROTO"),zn=Object,Gn=zn.prototype,Kn=jn?zn.getPrototypeOf:function(e){var t=Hn(e);if(Bn(t,Wn))return t[Wn];var i=t.constructor;return Fn(i)&&t instanceof i?i.prototype:t instanceof zn?Gn:null},Yn=r,Jn=ye,qn=Ie,Xn=Kn,Qn=tn,Zn=fe("iterator"),$n=!1;[].keys&&("next"in(ln=[].keys())?(cn=Xn(Xn(ln)))!==Object.prototype&&(an=cn):$n=!0),(!qn(an)||Yn((function(){var e={};return an[Zn].call(e)!==e})))&&(an={}),Jn(an[Zn])||Qn(an,Zn,(function(){return this}));var eo={IteratorPrototype:an,BUGGY_SAFARI_ITERATORS:$n},to=De.f,io=z,ro=fe("toStringTag"),no=function(e,t,i){e&&!i&&(e=e.prototype),e&&!io(e,ro)&&to(e,ro,{configurable:!0,value:t})},oo=eo.IteratorPrototype,so=Ni,ao=zi,co=no,lo=Fi,uo=function(){return this},ho=function(e,t,i,r){var n=t+" Iterator";return e.prototype=so(oo,{next:ao(+!r,i)}),co(e,n,!1),lo[n]=uo,e},po=l,mo=tt,_o=ye,fo=String,go=TypeError,Eo=function(e,t,i){try{return po(mo(Object.getOwnPropertyDescriptor(e,t)[i]))}catch(r){}},vo=Ce,yo=function(e){if("object"==typeof e||_o(e))return e;throw go("Can't set "+fo(e)+" as a prototype")},To=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,i={};try{(e=Eo(Object.prototype,"__proto__","set"))(i,[]),t=i instanceof Array}catch(r){}return function(i,r){return vo(i),yo(r),t?e(i,r):i.__proto__=r,i}}():void 0),So=Vn,Io=Fe,Ao=ye,Ro=ho,bo=Kn,Co=To,ko=no,wo=Yi,No=tn,Do=Fi,Oo=wr.PROPER,Lo=wr.CONFIGURABLE,Po=eo.IteratorPrototype,Mo=eo.BUGGY_SAFARI_ITERATORS,xo=fe("iterator"),Vo="keys",Uo="values",Bo="entries",Fo=function(){return this},Ho=function(e,t,i,r,n,o,s){Ro(i,t,r);var a,c,l,d=function(e){if(e===n&&_)return _;if(!Mo&&e in p)return p[e];switch(e){case Vo:case Uo:case Bo:return function(){return new i(this,e)}}return function(){return new i(this)}},u=t+" Iterator",h=!1,p=e.prototype,m=p[xo]||p["@@iterator"]||n&&p[n],_=!Mo&&m||d(n),f="Array"==t&&p.entries||m;if(f&&(a=bo(f.call(new e)))!==Object.prototype&&a.next&&(bo(a)!==Po&&(Co?Co(a,Po):Ao(a[xo])||No(a,xo,Fo)),ko(a,u,!0)),Oo&&n==Uo&&m&&m.name!==Uo&&(Lo?wo(p,"name",Uo):(h=!0,_=function(){return Io(m,this)})),n)if(c={values:d(Uo),keys:o?_:d(Vo),entries:d(Bo)},s)for(l in c)(Mo||h||!(l in p))&&No(p,l,c[l]);else So({target:t,proto:!0,forced:Mo||h},c);return p[xo]!==_&&No(p,xo,_,{name:n}),Do[t]=_,c},jo=function(e,t){return{value:e,done:t}},Wo=R,zo=Bi,Go=Fi,Ko=ar,Yo=De.f,Jo=Ho,qo=jo,Xo=we,Qo="Array Iterator",Zo=Ko.set,$o=Ko.getterFor(Qo),es=Jo(Array,"Array",(function(e,t){Zo(this,{type:Qo,target:Wo(e),index:0,kind:t})}),(function(){var e=$o(this),t=e.target,i=e.kind,r=e.index++;return!t||r>=t.length?(e.target=void 0,qo(void 0,!0)):qo("keys"==i?r:"values"==i?t[r]:[r,t[r]],!1)}),"values"),ts=Go.Arguments=Go.Array;if(zo("keys"),zo("values"),zo("entries"),Xo&&"values"!==ts.name)try{Yo(ts,"name",{value:"values"})}catch(cB){}var is={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},rs=Me("span").classList,ns=rs&&rs.constructor&&rs.constructor.prototype,os=ns===Object.prototype?void 0:ns,ss=C,as=is,cs=os,ls=es,ds=Yi,us=fe,hs=us("iterator"),ps=us("toStringTag"),ms=ls.values,_s=function(e,t){if(e){if(e[hs]!==ms)try{ds(e,hs,ms)}catch(cB){e[hs]=ms}if(e[ps]||ds(e,ps,t),as[t])for(var i in ls)if(e[i]!==ls[i])try{ds(e,i,ls[i])}catch(cB){e[i]=ls[i]}}};for(var fs in as)_s(ss[fs]&&ss[fs].prototype,fs);_s(cs,"DOMTokenList");var gs="undefined"!=typeof process&&"process"==p(process),Es=Sr,vs=De,ys=function(e,t,i){return i.get&&Es(i.get,t,{getter:!0}),i.set&&Es(i.set,t,{setter:!0}),vs.f(e,t,i)},Ts=We,Ss=ys,Is=we,As=fe("species"),Rs=function(e){var t=Ts(e);Is&&t&&!t[As]&&Ss(t,As,{configurable:!0,get:function(){return this}})},bs=ze,Cs=TypeError,ks=function(e,t){if(bs(t,e))return e;throw Cs("Incorrect invocation")},ws={};ws[fe("toStringTag")]="z";var Ns="[object z]"===String(ws),Ds=ye,Os=p,Ls=fe("toStringTag"),Ps=Object,Ms="Arguments"==Os(function(){return arguments}()),xs=Ns?Os:function(e){var t,i,r;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(i=function(e,t){try{return e[t]}catch(cB){}}(t=Ps(e),Ls))?i:Ms?Os(t):"Object"==(r=Os(t))&&Ds(t.callee)?"Arguments":r},Vs=l,Us=r,Bs=ye,Fs=xs,Hs=Lr,js=function(){},Ws=[],zs=We("Reflect","construct"),Gs=/^\s*(?:class|function)\b/,Ks=Vs(Gs.exec),Ys=!Gs.exec(js),Js=function(e){if(!Bs(e))return!1;try{return zs(js,Ws,e),!0}catch(cB){return!1}},qs=function(e){if(!Bs(e))return!1;switch(Fs(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Ys||!!Ks(Gs,Hs(e))}catch(cB){return!0}};qs.sham=!0;var Xs,Qs,Zs,$s,ea=!zs||Us((function(){var e;return Js(Js.call)||!Js(Object)||!Js((function(){e=!0}))||e}))?qs:Js,ta=ea,ia=Qe,ra=TypeError,na=function(e){if(ta(e))return e;throw ra(ia(e)+" is not a constructor")},oa=Ce,sa=na,aa=v,ca=fe("species"),la=function(e,t){var i,r=oa(e).constructor;return void 0===r||aa(i=oa(r)[ca])?t:sa(i)},da=n,ua=Function.prototype,ha=ua.apply,pa=ua.call,ma="object"==typeof Reflect&&Reflect.apply||(da?pa.bind(ha):function(){return pa.apply(ha,arguments)}),_a=p,fa=l,ga=function(e){if("Function"===_a(e))return fa(e)},Ea=tt,va=n,ya=ga(ga.bind),Ta=function(e,t){return Ea(e),void 0===t?e:va?ya(e,t):function(){return e.apply(t,arguments)}},Sa=l([].slice),Ia=TypeError,Aa=function(e,t){if(e<t)throw Ia("Not enough arguments");return e},Ra=/(?:ipad|iphone|ipod).*applewebkit/i.test(X),ba=C,Ca=ma,ka=Ta,wa=ye,Na=z,Da=r,Oa=pi,La=Sa,Pa=Me,Ma=Aa,xa=Ra,Va=gs,Ua=ba.setImmediate,Ba=ba.clearImmediate,Fa=ba.process,Ha=ba.Dispatch,ja=ba.Function,Wa=ba.MessageChannel,za=ba.String,Ga=0,Ka={},Ya="onreadystatechange";Da((function(){Xs=ba.location}));var Ja=function(e){if(Na(Ka,e)){var t=Ka[e];delete Ka[e],t()}},qa=function(e){return function(){Ja(e)}},Xa=function(e){Ja(e.data)},Qa=function(e){ba.postMessage(za(e),Xs.protocol+"//"+Xs.host)};Ua&&Ba||(Ua=function(e){Ma(arguments.length,1);var t=wa(e)?e:ja(e),i=La(arguments,1);return Ka[++Ga]=function(){Ca(t,void 0,i)},Qs(Ga),Ga},Ba=function(e){delete Ka[e]},Va?Qs=function(e){Fa.nextTick(qa(e))}:Ha&&Ha.now?Qs=function(e){Ha.now(qa(e))}:Wa&&!xa?($s=(Zs=new Wa).port2,Zs.port1.onmessage=Xa,Qs=ka($s.postMessage,$s)):ba.addEventListener&&wa(ba.postMessage)&&!ba.importScripts&&Xs&&"file:"!==Xs.protocol&&!Da(Qa)?(Qs=Qa,ba.addEventListener("message",Xa,!1)):Qs=Ya in Pa("script")?function(e){Oa.appendChild(Pa("script"))[Ya]=function(){Oa.removeChild(this),Ja(e)}}:function(e){setTimeout(qa(e),0)});var Za={set:Ua,clear:Ba},$a=function(){this.head=null,this.tail=null};$a.prototype={add:function(e){var t={item:e,next:null},i=this.tail;i?i.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return null===(this.head=e.next)&&(this.tail=null),e.item}};var ec,tc,ic,rc,nc,oc=$a,sc=/ipad|iphone|ipod/i.test(X)&&"undefined"!=typeof Pebble,ac=/web0s(?!.*chrome)/i.test(X),cc=C,lc=Ta,dc=cr.f,uc=Za.set,hc=oc,pc=Ra,mc=sc,_c=ac,fc=gs,gc=cc.MutationObserver||cc.WebKitMutationObserver,Ec=cc.document,vc=cc.process,yc=cc.Promise,Tc=dc(cc,"queueMicrotask"),Sc=Tc&&Tc.value;if(!Sc){var Ic=new hc,Ac=function(){var e,t;for(fc&&(e=vc.domain)&&e.exit();t=Ic.get();)try{t()}catch(cB){throw Ic.head&&ec(),cB}e&&e.enter()};pc||fc||_c||!gc||!Ec?!mc&&yc&&yc.resolve?((rc=yc.resolve(void 0)).constructor=yc,nc=lc(rc.then,rc),ec=function(){nc(Ac)}):fc?ec=function(){vc.nextTick(Ac)}:(uc=lc(uc,cc),ec=function(){uc(Ac)}):(tc=!0,ic=Ec.createTextNode(""),new gc(Ac).observe(ic,{characterData:!0}),ec=function(){ic.data=tc=!tc}),Sc=function(e){Ic.head||ec(),Ic.add(e)}}var Rc=Sc,bc=function(e){try{return{error:!1,value:e()}}catch(cB){return{error:!0,value:cB}}},Cc=C.Promise,kc="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,wc=!kc&&!gs&&"object"==typeof window&&"object"==typeof document,Nc=C,Dc=Cc,Oc=ye,Lc=wn,Pc=Lr,Mc=fe,xc=wc,Vc=kc,Uc=re;Dc&&Dc.prototype;var Bc=Mc("species"),Fc=!1,Hc=Oc(Nc.PromiseRejectionEvent),jc={CONSTRUCTOR:Lc("Promise",(function(){var e=Pc(Dc),t=e!==String(Dc);if(!t&&66===Uc)return!0;if(!Uc||Uc<51||!/native code/.test(e)){var i=new Dc((function(e){e(1)})),r=function(e){e((function(){}),(function(){}))};if((i.constructor={})[Bc]=r,!(Fc=i.then((function(){}))instanceof r))return!0}return!t&&(xc||Vc)&&!Hc})),REJECTION_EVENT:Hc,SUBCLASSING:Fc},Wc={},zc=tt,Gc=TypeError,Kc=function(e){var t,i;this.promise=new e((function(e,r){if(void 0!==t||void 0!==i)throw Gc("Bad Promise constructor");t=e,i=r})),this.resolve=zc(t),this.reject=zc(i)};Wc.f=function(e){return new Kc(e)};var Yc,Jc,qc,Xc=Vn,Qc=gs,Zc=C,$c=Fe,el=tn,tl=To,il=no,rl=Rs,nl=tt,ol=ye,sl=Ie,al=ks,cl=la,ll=Za.set,dl=Rc,ul=function(e,t){try{1==arguments.length?console.error(e):console.error(e,t)}catch(cB){}},hl=bc,pl=oc,ml=ar,_l=Cc,fl=Wc,gl="Promise",El=jc.CONSTRUCTOR,vl=jc.REJECTION_EVENT,yl=jc.SUBCLASSING,Tl=ml.getterFor(gl),Sl=ml.set,Il=_l&&_l.prototype,Al=_l,Rl=Il,bl=Zc.TypeError,Cl=Zc.document,kl=Zc.process,wl=fl.f,Nl=wl,Dl=!!(Cl&&Cl.createEvent&&Zc.dispatchEvent),Ol="unhandledrejection",Ll=function(e){var t;return!(!sl(e)||!ol(t=e.then))&&t},Pl=function(e,t){var i,r,n,o=t.value,s=1==t.state,a=s?e.ok:e.fail,c=e.resolve,l=e.reject,d=e.domain;try{a?(s||(2===t.rejection&&Bl(t),t.rejection=1),!0===a?i=o:(d&&d.enter(),i=a(o),d&&(d.exit(),n=!0)),i===e.promise?l(bl("Promise-chain cycle")):(r=Ll(i))?$c(r,i,c,l):c(i)):l(o)}catch(cB){d&&!n&&d.exit(),l(cB)}},Ml=function(e,t){e.notified||(e.notified=!0,dl((function(){for(var i,r=e.reactions;i=r.get();)Pl(i,e);e.notified=!1,t&&!e.rejection&&Vl(e)})))},xl=function(e,t,i){var r,n;Dl?((r=Cl.createEvent("Event")).promise=t,r.reason=i,r.initEvent(e,!1,!0),Zc.dispatchEvent(r)):r={promise:t,reason:i},!vl&&(n=Zc["on"+e])?n(r):e===Ol&&ul("Unhandled promise rejection",i)},Vl=function(e){$c(ll,Zc,(function(){var t,i=e.facade,r=e.value;if(Ul(e)&&(t=hl((function(){Qc?kl.emit("unhandledRejection",r,i):xl(Ol,i,r)})),e.rejection=Qc||Ul(e)?2:1,t.error))throw t.value}))},Ul=function(e){return 1!==e.rejection&&!e.parent},Bl=function(e){$c(ll,Zc,(function(){var t=e.facade;Qc?kl.emit("rejectionHandled",t):xl("rejectionhandled",t,e.value)}))},Fl=function(e,t,i){return function(r){e(t,r,i)}},Hl=function(e,t,i){e.done||(e.done=!0,i&&(e=i),e.value=t,e.state=2,Ml(e,!0))},jl=function(e,t,i){if(!e.done){e.done=!0,i&&(e=i);try{if(e.facade===t)throw bl("Promise can't be resolved itself");var r=Ll(t);r?dl((function(){var i={done:!1};try{$c(r,t,Fl(jl,i,e),Fl(Hl,i,e))}catch(cB){Hl(i,cB,e)}})):(e.value=t,e.state=1,Ml(e,!1))}catch(cB){Hl({done:!1},cB,e)}}};if(El&&(Rl=(Al=function(e){al(this,Rl),nl(e),$c(Yc,this);var t=Tl(this);try{e(Fl(jl,t),Fl(Hl,t))}catch(cB){Hl(t,cB)}}).prototype,(Yc=function(e){Sl(this,{type:gl,done:!1,notified:!1,parent:!1,reactions:new pl,rejection:!1,state:0,value:void 0})}).prototype=el(Rl,"then",(function(e,t){var i=Tl(this),r=wl(cl(this,Al));return i.parent=!0,r.ok=!ol(e)||e,r.fail=ol(t)&&t,r.domain=Qc?kl.domain:void 0,0==i.state?i.reactions.add(r):dl((function(){Pl(r,i)})),r.promise})),Jc=function(){var e=new Yc,t=Tl(e);this.promise=e,this.resolve=Fl(jl,t),this.reject=Fl(Hl,t)},fl.f=wl=function(e){return e===Al||void 0===e?new Jc(e):Nl(e)},ol(_l)&&Il!==Object.prototype)){qc=Il.then,yl||el(Il,"then",(function(e,t){var i=this;return new Al((function(e,t){$c(qc,i,e,t)})).then(e,t)}),{unsafe:!0});try{delete Il.constructor}catch(cB){}tl&&tl(Il,Rl)}Xc({global:!0,constructor:!0,wrap:!0,forced:El},{Promise:Al}),il(Al,gl,!1),rl(gl);var Wl=Fi,zl=fe("iterator"),Gl=Array.prototype,Kl=function(e){return void 0!==e&&(Wl.Array===e||Gl[zl]===e)},Yl=xs,Jl=nt,ql=v,Xl=Fi,Ql=fe("iterator"),Zl=function(e){if(!ql(e))return Jl(e,Ql)||Jl(e,"@@iterator")||Xl[Yl(e)]},$l=Fe,ed=tt,td=Ce,id=Qe,rd=Zl,nd=TypeError,od=function(e,t){var i=arguments.length<2?rd(e):t;if(ed(i))return td($l(i,e));throw nd(id(e)+" is not iterable")},sd=Fe,ad=Ce,cd=nt,ld=function(e,t,i){var r,n;ad(e);try{if(!(r=cd(e,"return"))){if("throw"===t)throw i;return i}r=sd(r,e)}catch(cB){n=!0,r=cB}if("throw"===t)throw i;if(n)throw r;return ad(r),i},dd=Ta,ud=Fe,hd=Ce,pd=Qe,md=Kl,_d=Wt,fd=ze,gd=od,Ed=Zl,vd=ld,yd=TypeError,Td=function(e,t){this.stopped=e,this.result=t},Sd=Td.prototype,Id=function(e,t,i){var r,n,o,s,a,c,l,d=i&&i.that,u=!(!i||!i.AS_ENTRIES),h=!(!i||!i.IS_RECORD),p=!(!i||!i.IS_ITERATOR),m=!(!i||!i.INTERRUPTED),_=dd(t,d),f=function(e){return r&&vd(r,"normal",e),new Td(!0,e)},g=function(e){return u?(hd(e),m?_(e[0],e[1],f):_(e[0],e[1])):m?_(e,f):_(e)};if(h)r=e.iterator;else if(p)r=e;else{if(!(n=Ed(e)))throw yd(pd(e)+" is not iterable");if(md(n)){for(o=0,s=_d(e);s>o;o++)if((a=g(e[o]))&&fd(Sd,a))return a;return new Td(!1)}r=gd(e,n)}for(c=h?e.next:r.next;!(l=ud(c,r)).done;){try{a=g(l.value)}catch(cB){vd(r,"throw",cB)}if("object"==typeof a&&a&&fd(Sd,a))return a}return new Td(!1)},Ad=fe("iterator"),Rd=!1;try{var bd=0,Cd={next:function(){return{done:!!bd++}},return:function(){Rd=!0}};Cd[Ad]=function(){return this},Array.from(Cd,(function(){throw 2}))}catch(cB){}var kd=function(e,t){if(!t&&!Rd)return!1;var i=!1;try{var r={};r[Ad]=function(){return{next:function(){return{done:i=!0}}}},e(r)}catch(cB){}return i},wd=Cc,Nd=jc.CONSTRUCTOR||!kd((function(e){wd.all(e).then(void 0,(function(){}))})),Dd=Fe,Od=tt,Ld=Wc,Pd=bc,Md=Id;Vn({target:"Promise",stat:!0,forced:Nd},{all:function(e){var t=this,i=Ld.f(t),r=i.resolve,n=i.reject,o=Pd((function(){var i=Od(t.resolve),o=[],s=0,a=1;Md(e,(function(e){var c=s++,l=!1;a++,Dd(i,t,e).then((function(e){l||(l=!0,o[c]=e,--a||r(o))}),n)})),--a||r(o)}));return o.error&&n(o.value),i.promise}});var xd=Vn,Vd=jc.CONSTRUCTOR,Ud=Cc,Bd=We,Fd=ye,Hd=tn,jd=Ud&&Ud.prototype;if(xd({target:"Promise",proto:!0,forced:Vd,real:!0},{catch:function(e){return this.then(void 0,e)}}),Fd(Ud)){var Wd=Bd("Promise").prototype.catch;jd.catch!==Wd&&Hd(jd,"catch",Wd,{unsafe:!0})}var zd=Fe,Gd=tt,Kd=Wc,Yd=bc,Jd=Id;Vn({target:"Promise",stat:!0,forced:Nd},{race:function(e){var t=this,i=Kd.f(t),r=i.reject,n=Yd((function(){var n=Gd(t.resolve);Jd(e,(function(e){zd(n,t,e).then(i.resolve,r)}))}));return n.error&&r(n.value),i.promise}});var qd=Fe,Xd=Wc;Vn({target:"Promise",stat:!0,forced:jc.CONSTRUCTOR},{reject:function(e){var t=Xd.f(this);return qd(t.reject,void 0,e),t.promise}});var Qd=Ce,Zd=Ie,$d=Wc,eu=function(e,t){if(Qd(e),Zd(t)&&t.constructor===e)return t;var i=$d.f(e);return(0,i.resolve)(t),i.promise},tu=Vn,iu=jc.CONSTRUCTOR,ru=eu;We("Promise"),tu({target:"Promise",stat:!0,forced:iu},{resolve:function(e){return ru(this,e)}});var nu=ye,ou=Ie,su=To,au=function(e,t,i){var r,n;return su&&nu(r=t.constructor)&&r!==i&&ou(n=r.prototype)&&n!==i.prototype&&su(e,n),e},cu=Ie,lu=p,du=fe("match"),uu=function(e){var t;return cu(e)&&(void 0!==(t=e[du])?!!t:"RegExp"==lu(e))},hu=xs,pu=String,mu=function(e){if("Symbol"===hu(e))throw TypeError("Cannot convert a Symbol value to a string");return pu(e)},_u=Ce,fu=function(){var e=_u(this),t="";return e.hasIndices&&(t+="d"),e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.unicodeSets&&(t+="v"),e.sticky&&(t+="y"),t},gu=Fe,Eu=z,vu=ze,yu=fu,Tu=RegExp.prototype,Su=function(e){var t=e.flags;return void 0!==t||"flags"in Tu||Eu(e,"flags")||!vu(Tu,e)?t:gu(yu,e)},Iu=r,Au=C.RegExp,Ru=Iu((function(){var e=Au("a","y");return e.lastIndex=2,null!=e.exec("abcd")})),bu=Ru||Iu((function(){return!Au("a","y").sticky})),Cu={BROKEN_CARET:Ru||Iu((function(){var e=Au("^r","gy");return e.lastIndex=2,null!=e.exec("str")})),MISSED_STICKY:bu,UNSUPPORTED_Y:Ru},ku=De.f,wu=r,Nu=C.RegExp,Du=wu((function(){var e=Nu(".","s");return!(e.dotAll&&e.exec("\n")&&"s"===e.flags)})),Ou=r,Lu=C.RegExp,Pu=Ou((function(){var e=Lu("(?<a>b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$<a>c")})),Mu=we,xu=C,Vu=l,Uu=wn,Bu=au,Fu=Yi,Hu=rn.f,ju=ze,Wu=uu,zu=mu,Gu=Su,Ku=Cu,Yu=function(e,t,i){i in e||ku(e,i,{configurable:!0,get:function(){return t[i]},set:function(e){t[i]=e}})},Ju=tn,qu=r,Xu=z,Qu=ar.enforce,Zu=Rs,$u=Du,eh=Pu,th=fe("match"),ih=xu.RegExp,rh=ih.prototype,nh=xu.SyntaxError,oh=Vu(rh.exec),sh=Vu("".charAt),ah=Vu("".replace),ch=Vu("".indexOf),lh=Vu("".slice),dh=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,uh=/a/g,hh=/a/g,ph=new ih(uh)!==uh,mh=Ku.MISSED_STICKY,_h=Ku.UNSUPPORTED_Y,fh=Mu&&(!ph||mh||$u||eh||qu((function(){return hh[th]=!1,ih(uh)!=uh||ih(hh)==hh||"/a/i"!=ih(uh,"i")})));if(Uu("RegExp",fh)){for(var gh=function(e,t){var i,r,n,o,s,a,c=ju(rh,this),l=Wu(e),d=void 0===t,u=[],h=e;if(!c&&l&&d&&e.constructor===gh)return e;if((l||ju(rh,e))&&(e=e.source,d&&(t=Gu(h))),e=void 0===e?"":zu(e),t=void 0===t?"":zu(t),h=e,$u&&"dotAll"in uh&&(r=!!t&&ch(t,"s")>-1)&&(t=ah(t,/s/g,"")),i=t,mh&&"sticky"in uh&&(n=!!t&&ch(t,"y")>-1)&&_h&&(t=ah(t,/y/g,"")),eh&&(e=(o=function(e){for(var t,i=e.length,r=0,n="",o=[],s={},a=!1,c=!1,l=0,d="";r<=i;r++){if("\\"===(t=sh(e,r)))t+=sh(e,++r);else if("]"===t)a=!1;else if(!a)switch(!0){case"["===t:a=!0;break;case"("===t:oh(dh,lh(e,r+1))&&(r+=2,c=!0),n+=t,l++;continue;case">"===t&&c:if(""===d||Xu(s,d))throw new nh("Invalid capture group name");s[d]=!0,o[o.length]=[d,l],c=!1,d="";continue}c?d+=t:n+=t}return[n,o]}(e))[0],u=o[1]),s=Bu(ih(e,t),c?this:rh,gh),(r||n||u.length)&&(a=Qu(s),r&&(a.dotAll=!0,a.raw=gh(function(e){for(var t,i=e.length,r=0,n="",o=!1;r<=i;r++)"\\"!==(t=sh(e,r))?o||"."!==t?("["===t?o=!0:"]"===t&&(o=!1),n+=t):n+="[\\s\\S]":n+=t+sh(e,++r);return n}(e),i)),n&&(a.sticky=!0),u.length&&(a.groups=u)),e!==h)try{Fu(s,"source",""===h?"(?:)":h)}catch(cB){}return s},Eh=Hu(ih),vh=0;Eh.length>vh;)Yu(gh,ih,Eh[vh++]);rh.constructor=gh,gh.prototype=rh,Ju(xu,"RegExp",gh,{constructor:!0})}Zu("RegExp");var yh,Th,Sh=Fe,Ih=l,Ah=mu,Rh=fu,bh=Cu,Ch=Ni,kh=ar.get,wh=Du,Nh=Pu,Dh=k("native-string-replace",String.prototype.replace),Oh=RegExp.prototype.exec,Lh=Oh,Ph=Ih("".charAt),Mh=Ih("".indexOf),xh=Ih("".replace),Vh=Ih("".slice),Uh=(Th=/b*/g,Sh(Oh,yh=/a/,"a"),Sh(Oh,Th,"a"),0!==yh.lastIndex||0!==Th.lastIndex),Bh=bh.BROKEN_CARET,Fh=void 0!==/()??/.exec("")[1];(Uh||Fh||Bh||wh||Nh)&&(Lh=function(e){var t,i,r,n,o,s,a,c=this,l=kh(c),d=Ah(e),u=l.raw;if(u)return u.lastIndex=c.lastIndex,t=Sh(Lh,u,d),c.lastIndex=u.lastIndex,t;var h=l.groups,p=Bh&&c.sticky,m=Sh(Rh,c),_=c.source,f=0,g=d;if(p&&(m=xh(m,"y",""),-1===Mh(m,"g")&&(m+="g"),g=Vh(d,c.lastIndex),c.lastIndex>0&&(!c.multiline||c.multiline&&"\n"!==Ph(d,c.lastIndex-1))&&(_="(?: "+_+")",g=" "+g,f++),i=new RegExp("^(?:"+_+")",m)),Fh&&(i=new RegExp("^"+_+"$(?!\\s)",m)),Uh&&(r=c.lastIndex),n=Sh(Oh,p?i:c,g),p?n?(n.input=Vh(n.input,f),n[0]=Vh(n[0],f),n.index=c.lastIndex,c.lastIndex+=n[0].length):c.lastIndex=0:Uh&&n&&(c.lastIndex=c.global?n.index+n[0].length:r),Fh&&n&&n.length>1&&Sh(Dh,n[0],i,(function(){for(o=1;o<arguments.length-2;o++)void 0===arguments[o]&&(n[o]=void 0)})),n&&h)for(n.groups=s=Ch(null),o=0;o<h.length;o++)s[(a=h[o])[0]]=n[a[1]];return n});var Hh=Lh;Vn({target:"RegExp",proto:!0,forced:/./.exec!==Hh},{exec:Hh});var jh=p,Wh=Array.isArray||function(e){return"Array"==jh(e)},zh=Wh,Gh=ea,Kh=Ie,Yh=fe("species"),Jh=Array,qh=function(e){var t;return zh(e)&&(t=e.constructor,(Gh(t)&&(t===Jh||zh(t.prototype))||Kh(t)&&null===(t=t[Yh]))&&(t=void 0)),void 0===t?Jh:t},Xh=Ta,Qh=E,Zh=H,$h=Wt,ep=function(e,t){return new(qh(e))(0===t?0:t)},tp=l([].push),ip=function(e){var t=1==e,i=2==e,r=3==e,n=4==e,o=6==e,s=7==e,a=5==e||o;return function(c,l,d,u){for(var h,p,m=Zh(c),_=Qh(m),f=Xh(l,d),g=$h(_),E=0,v=u||ep,y=t?v(c,g):i||s?v(c,0):void 0;g>E;E++)if((a||E in _)&&(p=f(h=_[E],E,m),e))if(t)y[E]=p;else if(p)switch(e){case 3:return!0;case 5:return h;case 6:return E;case 2:tp(y,h)}else switch(e){case 4:return!1;case 7:tp(y,h)}return o?-1:r||n?n:y}},rp={forEach:ip(0),map:ip(1),filter:ip(2),some:ip(3),every:ip(4),find:ip(5),findIndex:ip(6),filterReject:ip(7)},np=r,op=function(e,t){var i=[][e];return!!i&&np((function(){i.call(null,t||function(){return 1},1)}))},sp=rp.forEach,ap=op("forEach")?[].forEach:function(e){return sp(this,e,arguments.length>1?arguments[1]:void 0)},cp=C,lp=is,dp=os,up=ap,hp=Yi,pp=function(e){if(e&&e.forEach!==up)try{hp(e,"forEach",up)}catch(cB){e.forEach=up}};for(var mp in lp)lp[mp]&&pp(cp[mp]&&cp[mp].prototype);pp(dp);var _p=tt,fp=H,gp=E,Ep=Wt,vp=TypeError,yp=function(e){return function(t,i,r,n){_p(i);var o=fp(t),s=gp(o),a=Ep(o),c=e?a-1:0,l=e?-1:1;if(r<2)for(;;){if(c in s){n=s[c],c+=l;break}if(c+=l,e?c<0:a<=c)throw vp("Reduce of empty array with no initial value")}for(;e?c>=0:a>c;c+=l)c in s&&(n=i(n,s[c],c,o));return n}},Tp=[yp(!1),yp(!0)][0];Vn({target:"Array",proto:!0,forced:!gs&&re>79&&re<83||!op("reduce")},{reduce:function(e){var t=arguments.length;return Tp(this,e,t,t>1?arguments[1]:void 0)}});var Sp=ga,Ip=tn,Ap=Hh,Rp=r,bp=fe,Cp=Yi,kp=bp("species"),wp=RegExp.prototype,Np=l,Dp=Pt,Op=mu,Lp=S,Pp=Np("".charAt),Mp=Np("".charCodeAt),xp=Np("".slice),Vp=function(e){return function(t,i){var r,n,o=Op(Lp(t)),s=Dp(i),a=o.length;return s<0||s>=a?e?"":void 0:(r=Mp(o,s))<55296||r>56319||s+1===a||(n=Mp(o,s+1))<56320||n>57343?e?Pp(o,s):r:e?xp(o,s,s+2):n-56320+(r-55296<<10)+65536}},Up={codeAt:Vp(!1),charAt:Vp(!0)},Bp=Up.charAt,Fp=l,Hp=H,jp=Math.floor,Wp=Fp("".charAt),zp=Fp("".replace),Gp=Fp("".slice),Kp=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,Yp=/\$([$&'`]|\d{1,2})/g,Jp=function(e,t,i,r,n,o){var s=i+e.length,a=r.length,c=Yp;return void 0!==n&&(n=Hp(n),c=Kp),zp(o,c,(function(o,c){var l;switch(Wp(c,0)){case"$":return"$";case"&":return e;case"`":return Gp(t,0,i);case"'":return Gp(t,s);case"<":l=n[Gp(c,1,-1)];break;default:var d=+c;if(0===d)return o;if(d>a){var u=jp(d/10);return 0===u?o:u<=a?void 0===r[u-1]?Wp(c,1):r[u-1]+Wp(c,1):o}l=r[d-1]}return void 0===l?"":l}))},qp=Fe,Xp=Ce,Qp=ye,Zp=p,$p=Hh,em=TypeError,tm=ma,im=Fe,rm=l,nm=function(e,t,i,r){var n=bp(e),o=!Rp((function(){var t={};return t[n]=function(){return 7},7!=""[e](t)})),s=o&&!Rp((function(){var t=!1,i=/a/;return"split"===e&&((i={}).constructor={},i.constructor[kp]=function(){return i},i.flags="",i[n]=/./[n]),i.exec=function(){return t=!0,null},i[n](""),!t}));if(!o||!s||i){var a=Sp(/./[n]),c=t(n,""[e],(function(e,t,i,r,n){var s=Sp(e),c=t.exec;return c===Ap||c===wp.exec?o&&!n?{done:!0,value:a(t,i,r)}:{done:!0,value:s(i,t,r)}:{done:!1}}));Ip(String.prototype,e,c[0]),Ip(wp,n,c[1])}r&&Cp(wp[n],"sham",!0)},om=r,sm=Ce,am=ye,cm=v,lm=Pt,dm=Ht,um=mu,hm=S,pm=function(e,t,i){return t+(i?Bp(e,t).length:1)},mm=nt,_m=Jp,fm=function(e,t){var i=e.exec;if(Qp(i)){var r=qp(i,e,t);return null!==r&&Xp(r),r}if("RegExp"===Zp(e))return qp($p,e,t);throw em("RegExp#exec called on incompatible receiver")},gm=fe("replace"),Em=Math.max,vm=Math.min,ym=rm([].concat),Tm=rm([].push),Sm=rm("".indexOf),Im=rm("".slice),Am=function(e){return void 0===e?e:String(e)},Rm="$0"==="a".replace(/./,"$0"),bm=!!/./[gm]&&""===/./[gm]("a","$0"),Cm=!om((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")}));nm("replace",(function(e,t,i){var r=bm?"$":"$0";return[function(e,i){var r=hm(this),n=cm(e)?void 0:mm(e,gm);return n?im(n,e,r,i):im(t,um(r),e,i)},function(e,n){var o=sm(this),s=um(e);if("string"==typeof n&&-1===Sm(n,r)&&-1===Sm(n,"$<")){var a=i(t,o,s,n);if(a.done)return a.value}var c=am(n);c||(n=um(n));var l=o.global;if(l){var d=o.unicode;o.lastIndex=0}for(var u=[];;){var h=fm(o,s);if(null===h)break;if(Tm(u,h),!l)break;""===um(h[0])&&(o.lastIndex=pm(s,dm(o.lastIndex),d))}for(var p="",m=0,_=0;_<u.length;_++){for(var f=um((h=u[_])[0]),g=Em(vm(lm(h.index),s.length),0),E=[],v=1;v<h.length;v++)Tm(E,Am(h[v]));var y=h.groups;if(c){var T=ym([f],E,g,s);void 0!==y&&Tm(T,y);var S=um(tm(n,void 0,T))}else S=_m(f,s,g,E,y,n);g>=m&&(p+=Im(s,m,g)+S,m=g+f.length)}return p+Im(s,m)}]}),!Cm||!Rm||bm);var km=Jt.includes,wm=Bi;Vn({target:"Array",proto:!0,forced:r((function(){return!Array(1).includes()}))},{includes:function(e){return km(this,e,arguments.length>1?arguments[1]:void 0)}}),wm("includes");var Nm=Pt,Dm=mu,Om=S,Lm=RangeError,Pm=l,Mm=Ht,xm=mu,Vm=S,Um=Pm((function(e){var t=Dm(Om(this)),i="",r=Nm(e);if(r<0||1/0==r)throw Lm("Wrong number of repetitions");for(;r>0;(r>>>=1)&&(t+=t))1&r&&(i+=t);return i})),Bm=Pm("".slice),Fm=Math.ceil,Hm=function(e){return function(t,i,r){var n,o,s=xm(Vm(t)),a=Mm(i),c=s.length,l=void 0===r?" ":xm(r);return a<=c||""==l?s:((o=Um(l,Fm((n=a-c)/l.length))).length>n&&(o=Bm(o,0,n)),e?s+o:o+s)}},jm={start:Hm(!1),end:Hm(!0)},Wm=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(X),zm=jm.start;Vn({target:"String",proto:!0,forced:Wm},{padStart:function(e){return zm(this,e,arguments.length>1?arguments[1]:void 0)}});var Gm=r,Km=we,Ym=fe("iterator"),Jm=!Gm((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,i="";return e.pathname="c%20d",t.forEach((function(e,r){t.delete("b"),i+=r+e})),!t.size&&!Km||!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[Ym]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://тест").host||"#%D0%B1"!==new URL("http://a#б").hash||"a1c3"!==i||"x"!==new URL("http://x",void 0).host})),qm=tn,Xm=function(e,t,i){for(var r in t)qm(e,r,t[r],i);return e},Qm=vt,Zm=De,$m=zi,e_=function(e,t,i){var r=Qm(t);r in e?Zm.f(e,r,$m(0,i)):e[r]=i},t_=Ut,i_=Wt,r_=e_,n_=Array,o_=Math.max,s_=function(e,t,i){for(var r=i_(e),n=t_(t,r),o=t_(void 0===i?r:i,r),s=n_(o_(o-n,0)),a=0;n<o;n++,a++)r_(s,a,e[n]);return s.length=a,s},a_=s_,c_=Math.floor,l_=function(e,t){var i=e.length,r=c_(i/2);return i<8?d_(e,t):u_(e,l_(a_(e,0,r),t),l_(a_(e,r),t),t)},d_=function(e,t){for(var i,r,n=e.length,o=1;o<n;){for(r=o,i=e[o];r&&t(e[r-1],i)>0;)e[r]=e[--r];r!==o++&&(e[r]=i)}return e},u_=function(e,t,i,r){for(var n=t.length,o=i.length,s=0,a=0;s<n||a<o;)e[s+a]=s<n&&a<o?r(t[s],i[a])<=0?t[s++]:i[a++]:s<n?t[s++]:i[a++];return e},h_=l_,p_=Vn,m_=C,__=Fe,f_=l,g_=we,E_=Jm,v_=tn,y_=ys,T_=Xm,S_=no,I_=ho,A_=ar,R_=ks,b_=ye,C_=z,k_=Ta,w_=xs,N_=Ce,D_=Ie,O_=mu,L_=Ni,P_=zi,M_=od,x_=Zl,V_=Aa,U_=h_,B_=fe("iterator"),F_="URLSearchParams",H_=F_+"Iterator",j_=A_.set,W_=A_.getterFor(F_),z_=A_.getterFor(H_),G_=Object.getOwnPropertyDescriptor,K_=function(e){if(!g_)return m_[e];var t=G_(m_,e);return t&&t.value},Y_=K_("fetch"),J_=K_("Request"),q_=K_("Headers"),X_=J_&&J_.prototype,Q_=q_&&q_.prototype,Z_=m_.RegExp,$_=m_.TypeError,ef=m_.decodeURIComponent,tf=m_.encodeURIComponent,rf=f_("".charAt),nf=f_([].join),of=f_([].push),sf=f_("".replace),af=f_([].shift),cf=f_([].splice),lf=f_("".split),df=f_("".slice),uf=/\+/g,hf=Array(4),pf=function(e){return hf[e-1]||(hf[e-1]=Z_("((?:%[\\da-f]{2}){"+e+"})","gi"))},mf=function(e){try{return ef(e)}catch(cB){return e}},_f=function(e){var t=sf(e,uf," "),i=4;try{return ef(t)}catch(cB){for(;i;)t=sf(t,pf(i--),mf);return t}},ff=/[!'()~]|%20/g,gf={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},Ef=function(e){return gf[e]},vf=function(e){return sf(tf(e),ff,Ef)},yf=I_((function(e,t){j_(this,{type:H_,iterator:M_(W_(e).entries),kind:t})}),"Iterator",(function(){var e=z_(this),t=e.kind,i=e.iterator.next(),r=i.value;return i.done||(i.value="keys"===t?r.key:"values"===t?r.value:[r.key,r.value]),i}),!0),Tf=function(e){this.entries=[],this.url=null,void 0!==e&&(D_(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===rf(e,0)?df(e,1):e:O_(e)))};Tf.prototype={type:F_,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,i,r,n,o,s,a,c=x_(e);if(c)for(i=(t=M_(e,c)).next;!(r=__(i,t)).done;){if(o=(n=M_(N_(r.value))).next,(s=__(o,n)).done||(a=__(o,n)).done||!__(o,n).done)throw $_("Expected sequence with length 2");of(this.entries,{key:O_(s.value),value:O_(a.value)})}else for(var l in e)C_(e,l)&&of(this.entries,{key:l,value:O_(e[l])})},parseQuery:function(e){if(e)for(var t,i,r=lf(e,"&"),n=0;n<r.length;)(t=r[n++]).length&&(i=lf(t,"="),of(this.entries,{key:_f(af(i)),value:_f(nf(i,"="))}))},serialize:function(){for(var e,t=this.entries,i=[],r=0;r<t.length;)e=t[r++],of(i,vf(e.key)+"="+vf(e.value));return nf(i,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var Sf=function(){R_(this,If);var e=j_(this,new Tf(arguments.length>0?arguments[0]:void 0));g_||(this.length=e.entries.length)},If=Sf.prototype;if(T_(If,{append:function(e,t){V_(arguments.length,2);var i=W_(this);of(i.entries,{key:O_(e),value:O_(t)}),g_||this.length++,i.updateURL()},delete:function(e){V_(arguments.length,1);for(var t=W_(this),i=t.entries,r=O_(e),n=0;n<i.length;)i[n].key===r?cf(i,n,1):n++;g_||(this.length=i.length),t.updateURL()},get:function(e){V_(arguments.length,1);for(var t=W_(this).entries,i=O_(e),r=0;r<t.length;r++)if(t[r].key===i)return t[r].value;return null},getAll:function(e){V_(arguments.length,1);for(var t=W_(this).entries,i=O_(e),r=[],n=0;n<t.length;n++)t[n].key===i&&of(r,t[n].value);return r},has:function(e){V_(arguments.length,1);for(var t=W_(this).entries,i=O_(e),r=0;r<t.length;)if(t[r++].key===i)return!0;return!1},set:function(e,t){V_(arguments.length,1);for(var i,r=W_(this),n=r.entries,o=!1,s=O_(e),a=O_(t),c=0;c<n.length;c++)(i=n[c]).key===s&&(o?cf(n,c--,1):(o=!0,i.value=a));o||of(n,{key:s,value:a}),g_||(this.length=n.length),r.updateURL()},sort:function(){var e=W_(this);U_(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,i=W_(this).entries,r=k_(e,arguments.length>1?arguments[1]:void 0),n=0;n<i.length;)r((t=i[n++]).value,t.key,this)},keys:function(){return new yf(this,"keys")},values:function(){return new yf(this,"values")},entries:function(){return new yf(this,"entries")}},{enumerable:!0}),v_(If,B_,If.entries,{name:"entries"}),v_(If,"toString",(function(){return W_(this).serialize()}),{enumerable:!0}),g_&&y_(If,"size",{get:function(){return W_(this).entries.length},configurable:!0,enumerable:!0}),S_(Sf,F_),p_({global:!0,constructor:!0,forced:!E_},{URLSearchParams:Sf}),!E_&&b_(q_)){var Af=f_(Q_.has),Rf=f_(Q_.set),bf=function(e){if(D_(e)){var t,i=e.body;if(w_(i)===F_)return t=e.headers?new q_(e.headers):new q_,Af(t,"content-type")||Rf(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),L_(e,{body:P_(0,O_(i)),headers:P_(0,t)})}return e};if(b_(Y_)&&p_({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return Y_(e,arguments.length>1?bf(arguments[1]):{})}}),b_(J_)){var Cf=function(e){return R_(this,X_),new J_(e,arguments.length>1?bf(arguments[1]):{})};X_.constructor=Cf,Cf.prototype=X_,p_({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:Cf})}}var kf={URLSearchParams:Sf,getState:W_},wf="\t\n\v\f\r                 \u2028\u2029\ufeff",Nf=S,Df=mu,Of=wf,Lf=l("".replace),Pf=RegExp("^["+Of+"]+"),Mf=RegExp("(^|[^"+Of+"])["+Of+"]+$"),xf=function(e){return function(t){var i=Df(Nf(t));return 1&e&&(i=Lf(i,Pf,"")),2&e&&(i=Lf(i,Mf,"$1")),i}},Vf={start:xf(1),end:xf(2),trim:xf(3)},Uf=wr.PROPER,Bf=r,Ff=wf,Hf=Vf.trim;Vn({target:"String",proto:!0,forced:function(e){return Bf((function(){return!!Ff[e]()||"​…᠎"!=="​…᠎"[e]()||Uf&&Ff[e].name!==e}))}("trim")},{trim:function(){return Hf(this)}});var jf=Vn,Wf=we,zf=l,Gf=z,Kf=ye,Yf=ze,Jf=mu,qf=ys,Xf=yn,Qf=C.Symbol,Zf=Qf&&Qf.prototype;if(Wf&&Kf(Qf)&&(!("description"in Zf)||void 0!==Qf().description)){var $f={},eg=function(){var e=arguments.length<1||void 0===arguments[0]?void 0:Jf(arguments[0]),t=Yf(Zf,this)?new Qf(e):void 0===e?Qf():Qf(e);return""===e&&($f[t]=!0),t};Xf(eg,Qf),eg.prototype=Zf,Zf.constructor=eg;var tg="Symbol(test)"==String(Qf("test")),ig=zf(Zf.valueOf),rg=zf(Zf.toString),ng=/^Symbol\((.*)\)[^)]+$/,og=zf("".replace),sg=zf("".slice);qf(Zf,"description",{configurable:!0,get:function(){var e=ig(this);if(Gf($f,e))return"";var t=rg(e),i=tg?sg(t,7,-1):og(t,ng,"$1");return""===i?void 0:i}}),jf({global:!0,constructor:!0,forced:!0},{Symbol:eg})}var ag=Up.charAt,cg=mu,lg=ar,dg=Ho,ug=jo,hg="String Iterator",pg=lg.set,mg=lg.getterFor(hg);dg(String,"String",(function(e){pg(this,{type:hg,string:cg(e),index:0})}),(function(){var e,t=mg(this),i=t.string,r=t.index;return r>=i.length?ug(void 0,!0):(e=ag(i,r),t.index+=e.length,ug(e,!1))}));var _g,fg=we,gg=l,Eg=Fe,vg=r,yg=oi,Tg=sn,Sg=lr,Ig=H,Ag=E,Rg=Object.assign,bg=Object.defineProperty,Cg=gg([].concat),kg=!Rg||vg((function(){if(fg&&1!==Rg({b:1},Rg(bg({},"a",{enumerable:!0,get:function(){bg(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},i=Symbol(),r="abcdefghijklmnopqrst";return e[i]=7,r.split("").forEach((function(e){t[e]=e})),7!=Rg({},e)[i]||yg(Rg({},t)).join("")!=r}))?function(e,t){for(var i=Ig(e),r=arguments.length,n=1,o=Tg.f,s=Sg.f;r>n;)for(var a,c=Ag(arguments[n++]),l=o?Cg(yg(c),o(c)):yg(c),d=l.length,u=0;d>u;)a=l[u++],fg&&!Eg(s,c,a)||(i[a]=c[a]);return i}:Rg,wg=Ce,Ng=ld,Dg=Ta,Og=Fe,Lg=H,Pg=function(e,t,i,r){try{return r?t(wg(i)[0],i[1]):t(i)}catch(cB){Ng(e,"throw",cB)}},Mg=Kl,xg=ea,Vg=Wt,Ug=e_,Bg=od,Fg=Zl,Hg=Array,jg=l,Wg=2147483647,zg=/[^\0-\u007E]/,Gg=/[.\u3002\uFF0E\uFF61]/g,Kg="Overflow: input needs wider integers to process",Yg=RangeError,Jg=jg(Gg.exec),qg=Math.floor,Xg=String.fromCharCode,Qg=jg("".charCodeAt),Zg=jg([].join),$g=jg([].push),eE=jg("".replace),tE=jg("".split),iE=jg("".toLowerCase),rE=function(e){return e+22+75*(e<26)},nE=function(e,t,i){var r=0;for(e=i?qg(e/700):e>>1,e+=qg(e/t);e>455;)e=qg(e/35),r+=36;return qg(r+36*e/(e+38))},oE=function(e){var t,i,r=[],n=(e=function(e){for(var t=[],i=0,r=e.length;i<r;){var n=Qg(e,i++);if(n>=55296&&n<=56319&&i<r){var o=Qg(e,i++);56320==(64512&o)?$g(t,((1023&n)<<10)+(1023&o)+65536):($g(t,n),i--)}else $g(t,n)}return t}(e)).length,o=128,s=0,a=72;for(t=0;t<e.length;t++)(i=e[t])<128&&$g(r,Xg(i));var c=r.length,l=c;for(c&&$g(r,"-");l<n;){var d=Wg;for(t=0;t<e.length;t++)(i=e[t])>=o&&i<d&&(d=i);var u=l+1;if(d-o>qg((Wg-s)/u))throw Yg(Kg);for(s+=(d-o)*u,o=d,t=0;t<e.length;t++){if((i=e[t])<o&&++s>Wg)throw Yg(Kg);if(i==o){for(var h=s,p=36;;){var m=p<=a?1:p>=a+26?26:p-a;if(h<m)break;var _=h-m,f=36-m;$g(r,Xg(rE(m+_%f))),h=qg(_/f),p+=36}$g(r,Xg(rE(h))),a=nE(s,u,l==c),s=0,l++}}s++,o++}return Zg(r,"")},sE=Vn,aE=we,cE=Jm,lE=C,dE=Ta,uE=l,hE=tn,pE=ys,mE=ks,_E=z,fE=kg,gE=function(e){var t=Lg(e),i=xg(this),r=arguments.length,n=r>1?arguments[1]:void 0,o=void 0!==n;o&&(n=Dg(n,r>2?arguments[2]:void 0));var s,a,c,l,d,u,h=Fg(t),p=0;if(!h||this===Hg&&Mg(h))for(s=Vg(t),a=i?new this(s):Hg(s);s>p;p++)u=o?n(t[p],p):t[p],Ug(a,p,u);else for(d=(l=Bg(t,h)).next,a=i?new this:[];!(c=Og(d,l)).done;p++)u=o?Pg(l,n,[c.value,p],!0):c.value,Ug(a,p,u);return a.length=p,a},EE=s_,vE=Up.codeAt,yE=function(e){var t,i,r=[],n=tE(eE(iE(e),Gg,"."),".");for(t=0;t<n.length;t++)i=n[t],$g(r,Jg(zg,i)?"xn--"+oE(i):i);return Zg(r,".")},TE=mu,SE=no,IE=Aa,AE=kf,RE=ar,bE=RE.set,CE=RE.getterFor("URL"),kE=AE.URLSearchParams,wE=AE.getState,NE=lE.URL,DE=lE.TypeError,OE=lE.parseInt,LE=Math.floor,PE=Math.pow,ME=uE("".charAt),xE=uE(/./.exec),VE=uE([].join),UE=uE(1..toString),BE=uE([].pop),FE=uE([].push),HE=uE("".replace),jE=uE([].shift),WE=uE("".split),zE=uE("".slice),GE=uE("".toLowerCase),KE=uE([].unshift),YE="Invalid scheme",JE="Invalid host",qE="Invalid port",XE=/[a-z]/i,QE=/[\d+-.a-z]/i,ZE=/\d/,$E=/^0x/i,ev=/^[0-7]+$/,tv=/^\d+$/,iv=/^[\da-f]+$/i,rv=/[\0\t\n\r #%/:<>?@[\\\]^|]/,nv=/[\0\t\n\r #/:<>?@[\\\]^|]/,ov=/^[\u0000-\u0020]+/,sv=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,av=/[\t\n\r]/g,cv=function(e){var t,i,r,n;if("number"==typeof e){for(t=[],i=0;i<4;i++)KE(t,e%256),e=LE(e/256);return VE(t,".")}if("object"==typeof e){for(t="",r=function(e){for(var t=null,i=1,r=null,n=0,o=0;o<8;o++)0!==e[o]?(n>i&&(t=r,i=n),r=null,n=0):(null===r&&(r=o),++n);return n>i&&(t=r,i=n),t}(e),i=0;i<8;i++)n&&0===e[i]||(n&&(n=!1),r===i?(t+=i?":":"::",n=!0):(t+=UE(e[i],16),i<7&&(t+=":")));return"["+t+"]"}return e},lv={},dv=fE({},lv,{" ":1,'"':1,"<":1,">":1,"`":1}),uv=fE({},dv,{"#":1,"?":1,"{":1,"}":1}),hv=fE({},uv,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),pv=function(e,t){var i=vE(e,0);return i>32&&i<127&&!_E(t,e)?e:encodeURIComponent(e)},mv={ftp:21,file:null,http:80,https:443,ws:80,wss:443},_v=function(e,t){var i;return 2==e.length&&xE(XE,ME(e,0))&&(":"==(i=ME(e,1))||!t&&"|"==i)},fv=function(e){var t;return e.length>1&&_v(zE(e,0,2))&&(2==e.length||"/"===(t=ME(e,2))||"\\"===t||"?"===t||"#"===t)},gv=function(e){return"."===e||"%2e"===GE(e)},Ev={},vv={},yv={},Tv={},Sv={},Iv={},Av={},Rv={},bv={},Cv={},kv={},wv={},Nv={},Dv={},Ov={},Lv={},Pv={},Mv={},xv={},Vv={},Uv={},Bv=function(e,t,i){var r,n,o,s=TE(e);if(t){if(n=this.parse(s))throw DE(n);this.searchParams=null}else{if(void 0!==i&&(r=new Bv(i,!0)),n=this.parse(s,null,r))throw DE(n);(o=wE(new kE)).bindURL(this),this.searchParams=o}};Bv.prototype={type:"URL",parse:function(e,t,i){var r,n,o,s,a,c=this,l=t||Ev,d=0,u="",h=!1,p=!1,m=!1;for(e=TE(e),t||(c.scheme="",c.username="",c.password="",c.host=null,c.port=null,c.path=[],c.query=null,c.fragment=null,c.cannotBeABaseURL=!1,e=HE(e,ov,""),e=HE(e,sv,"$1")),e=HE(e,av,""),r=gE(e);d<=r.length;){switch(n=r[d],l){case Ev:if(!n||!xE(XE,n)){if(t)return YE;l=yv;continue}u+=GE(n),l=vv;break;case vv:if(n&&(xE(QE,n)||"+"==n||"-"==n||"."==n))u+=GE(n);else{if(":"!=n){if(t)return YE;u="",l=yv,d=0;continue}if(t&&(c.isSpecial()!=_E(mv,u)||"file"==u&&(c.includesCredentials()||null!==c.port)||"file"==c.scheme&&!c.host))return;if(c.scheme=u,t)return void(c.isSpecial()&&mv[c.scheme]==c.port&&(c.port=null));u="","file"==c.scheme?l=Dv:c.isSpecial()&&i&&i.scheme==c.scheme?l=Tv:c.isSpecial()?l=Rv:"/"==r[d+1]?(l=Sv,d++):(c.cannotBeABaseURL=!0,FE(c.path,""),l=xv)}break;case yv:if(!i||i.cannotBeABaseURL&&"#"!=n)return YE;if(i.cannotBeABaseURL&&"#"==n){c.scheme=i.scheme,c.path=EE(i.path),c.query=i.query,c.fragment="",c.cannotBeABaseURL=!0,l=Uv;break}l="file"==i.scheme?Dv:Iv;continue;case Tv:if("/"!=n||"/"!=r[d+1]){l=Iv;continue}l=bv,d++;break;case Sv:if("/"==n){l=Cv;break}l=Mv;continue;case Iv:if(c.scheme=i.scheme,n==_g)c.username=i.username,c.password=i.password,c.host=i.host,c.port=i.port,c.path=EE(i.path),c.query=i.query;else if("/"==n||"\\"==n&&c.isSpecial())l=Av;else if("?"==n)c.username=i.username,c.password=i.password,c.host=i.host,c.port=i.port,c.path=EE(i.path),c.query="",l=Vv;else{if("#"!=n){c.username=i.username,c.password=i.password,c.host=i.host,c.port=i.port,c.path=EE(i.path),c.path.length--,l=Mv;continue}c.username=i.username,c.password=i.password,c.host=i.host,c.port=i.port,c.path=EE(i.path),c.query=i.query,c.fragment="",l=Uv}break;case Av:if(!c.isSpecial()||"/"!=n&&"\\"!=n){if("/"!=n){c.username=i.username,c.password=i.password,c.host=i.host,c.port=i.port,l=Mv;continue}l=Cv}else l=bv;break;case Rv:if(l=bv,"/"!=n||"/"!=ME(u,d+1))continue;d++;break;case bv:if("/"!=n&&"\\"!=n){l=Cv;continue}break;case Cv:if("@"==n){h&&(u="%40"+u),h=!0,o=gE(u);for(var _=0;_<o.length;_++){var f=o[_];if(":"!=f||m){var g=pv(f,hv);m?c.password+=g:c.username+=g}else m=!0}u=""}else if(n==_g||"/"==n||"?"==n||"#"==n||"\\"==n&&c.isSpecial()){if(h&&""==u)return"Invalid authority";d-=gE(u).length+1,u="",l=kv}else u+=n;break;case kv:case wv:if(t&&"file"==c.scheme){l=Lv;continue}if(":"!=n||p){if(n==_g||"/"==n||"?"==n||"#"==n||"\\"==n&&c.isSpecial()){if(c.isSpecial()&&""==u)return JE;if(t&&""==u&&(c.includesCredentials()||null!==c.port))return;if(s=c.parseHost(u))return s;if(u="",l=Pv,t)return;continue}"["==n?p=!0:"]"==n&&(p=!1),u+=n}else{if(""==u)return JE;if(s=c.parseHost(u))return s;if(u="",l=Nv,t==wv)return}break;case Nv:if(!xE(ZE,n)){if(n==_g||"/"==n||"?"==n||"#"==n||"\\"==n&&c.isSpecial()||t){if(""!=u){var E=OE(u,10);if(E>65535)return qE;c.port=c.isSpecial()&&E===mv[c.scheme]?null:E,u=""}if(t)return;l=Pv;continue}return qE}u+=n;break;case Dv:if(c.scheme="file","/"==n||"\\"==n)l=Ov;else{if(!i||"file"!=i.scheme){l=Mv;continue}if(n==_g)c.host=i.host,c.path=EE(i.path),c.query=i.query;else if("?"==n)c.host=i.host,c.path=EE(i.path),c.query="",l=Vv;else{if("#"!=n){fv(VE(EE(r,d),""))||(c.host=i.host,c.path=EE(i.path),c.shortenPath()),l=Mv;continue}c.host=i.host,c.path=EE(i.path),c.query=i.query,c.fragment="",l=Uv}}break;case Ov:if("/"==n||"\\"==n){l=Lv;break}i&&"file"==i.scheme&&!fv(VE(EE(r,d),""))&&(_v(i.path[0],!0)?FE(c.path,i.path[0]):c.host=i.host),l=Mv;continue;case Lv:if(n==_g||"/"==n||"\\"==n||"?"==n||"#"==n){if(!t&&_v(u))l=Mv;else if(""==u){if(c.host="",t)return;l=Pv}else{if(s=c.parseHost(u))return s;if("localhost"==c.host&&(c.host=""),t)return;u="",l=Pv}continue}u+=n;break;case Pv:if(c.isSpecial()){if(l=Mv,"/"!=n&&"\\"!=n)continue}else if(t||"?"!=n)if(t||"#"!=n){if(n!=_g&&(l=Mv,"/"!=n))continue}else c.fragment="",l=Uv;else c.query="",l=Vv;break;case Mv:if(n==_g||"/"==n||"\\"==n&&c.isSpecial()||!t&&("?"==n||"#"==n)){if(".."===(a=GE(a=u))||"%2e."===a||".%2e"===a||"%2e%2e"===a?(c.shortenPath(),"/"==n||"\\"==n&&c.isSpecial()||FE(c.path,"")):gv(u)?"/"==n||"\\"==n&&c.isSpecial()||FE(c.path,""):("file"==c.scheme&&!c.path.length&&_v(u)&&(c.host&&(c.host=""),u=ME(u,0)+":"),FE(c.path,u)),u="","file"==c.scheme&&(n==_g||"?"==n||"#"==n))for(;c.path.length>1&&""===c.path[0];)jE(c.path);"?"==n?(c.query="",l=Vv):"#"==n&&(c.fragment="",l=Uv)}else u+=pv(n,uv);break;case xv:"?"==n?(c.query="",l=Vv):"#"==n?(c.fragment="",l=Uv):n!=_g&&(c.path[0]+=pv(n,lv));break;case Vv:t||"#"!=n?n!=_g&&("'"==n&&c.isSpecial()?c.query+="%27":c.query+="#"==n?"%23":pv(n,lv)):(c.fragment="",l=Uv);break;case Uv:n!=_g&&(c.fragment+=pv(n,dv))}d++}},parseHost:function(e){var t,i,r;if("["==ME(e,0)){if("]"!=ME(e,e.length-1))return JE;if(!(t=function(e){var t,i,r,n,o,s,a,c=[0,0,0,0,0,0,0,0],l=0,d=null,u=0,h=function(){return ME(e,u)};if(":"==h()){if(":"!=ME(e,1))return;u+=2,d=++l}for(;h();){if(8==l)return;if(":"!=h()){for(t=i=0;i<4&&xE(iv,h());)t=16*t+OE(h(),16),u++,i++;if("."==h()){if(0==i)return;if(u-=i,l>6)return;for(r=0;h();){if(n=null,r>0){if(!("."==h()&&r<4))return;u++}if(!xE(ZE,h()))return;for(;xE(ZE,h());){if(o=OE(h(),10),null===n)n=o;else{if(0==n)return;n=10*n+o}if(n>255)return;u++}c[l]=256*c[l]+n,2!=++r&&4!=r||l++}if(4!=r)return;break}if(":"==h()){if(u++,!h())return}else if(h())return;c[l++]=t}else{if(null!==d)return;u++,d=++l}}if(null!==d)for(s=l-d,l=7;0!=l&&s>0;)a=c[l],c[l--]=c[d+s-1],c[d+--s]=a;else if(8!=l)return;return c}(zE(e,1,-1))))return JE;this.host=t}else if(this.isSpecial()){if(e=yE(e),xE(rv,e))return JE;if(null===(t=function(e){var t,i,r,n,o,s,a,c=WE(e,".");if(c.length&&""==c[c.length-1]&&c.length--,(t=c.length)>4)return e;for(i=[],r=0;r<t;r++){if(""==(n=c[r]))return e;if(o=10,n.length>1&&"0"==ME(n,0)&&(o=xE($E,n)?16:8,n=zE(n,8==o?1:2)),""===n)s=0;else{if(!xE(10==o?tv:8==o?ev:iv,n))return e;s=OE(n,o)}FE(i,s)}for(r=0;r<t;r++)if(s=i[r],r==t-1){if(s>=PE(256,5-t))return null}else if(s>255)return null;for(a=BE(i),r=0;r<i.length;r++)a+=i[r]*PE(256,3-r);return a}(e)))return JE;this.host=t}else{if(xE(nv,e))return JE;for(t="",i=gE(e),r=0;r<i.length;r++)t+=pv(i[r],lv);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"==this.scheme},includesCredentials:function(){return""!=this.username||""!=this.password},isSpecial:function(){return _E(mv,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"==this.scheme&&1==t&&_v(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,i=e.username,r=e.password,n=e.host,o=e.port,s=e.path,a=e.query,c=e.fragment,l=t+":";return null!==n?(l+="//",e.includesCredentials()&&(l+=i+(r?":"+r:"")+"@"),l+=cv(n),null!==o&&(l+=":"+o)):"file"==t&&(l+="//"),l+=e.cannotBeABaseURL?s[0]:s.length?"/"+VE(s,"/"):"",null!==a&&(l+="?"+a),null!==c&&(l+="#"+c),l},setHref:function(e){var t=this.parse(e);if(t)throw DE(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"==e)try{return new Fv(e.path[0]).origin}catch(cB){return"null"}return"file"!=e&&this.isSpecial()?e+"://"+cv(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(TE(e)+":",Ev)},getUsername:function(){return this.username},setUsername:function(e){var t=gE(TE(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var i=0;i<t.length;i++)this.username+=pv(t[i],hv)}},getPassword:function(){return this.password},setPassword:function(e){var t=gE(TE(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var i=0;i<t.length;i++)this.password+=pv(t[i],hv)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?cv(e):cv(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,kv)},getHostname:function(){var e=this.host;return null===e?"":cv(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,wv)},getPort:function(){var e=this.port;return null===e?"":TE(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""==(e=TE(e))?this.port=null:this.parse(e,Nv))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+VE(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,Pv))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""==(e=TE(e))?this.query=null:("?"==ME(e,0)&&(e=zE(e,1)),this.query="",this.parse(e,Vv)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!=(e=TE(e))?("#"==ME(e,0)&&(e=zE(e,1)),this.fragment="",this.parse(e,Uv)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var Fv=function(e){var t=mE(this,Hv),i=IE(arguments.length,1)>1?arguments[1]:void 0,r=bE(t,new Bv(e,!1,i));aE||(t.href=r.serialize(),t.origin=r.getOrigin(),t.protocol=r.getProtocol(),t.username=r.getUsername(),t.password=r.getPassword(),t.host=r.getHost(),t.hostname=r.getHostname(),t.port=r.getPort(),t.pathname=r.getPathname(),t.search=r.getSearch(),t.searchParams=r.getSearchParams(),t.hash=r.getHash())},Hv=Fv.prototype,jv=function(e,t){return{get:function(){return CE(this)[e]()},set:t&&function(e){return CE(this)[t](e)},configurable:!0,enumerable:!0}};if(aE&&(pE(Hv,"href",jv("serialize","setHref")),pE(Hv,"origin",jv("getOrigin")),pE(Hv,"protocol",jv("getProtocol","setProtocol")),pE(Hv,"username",jv("getUsername","setUsername")),pE(Hv,"password",jv("getPassword","setPassword")),pE(Hv,"host",jv("getHost","setHost")),pE(Hv,"hostname",jv("getHostname","setHostname")),pE(Hv,"port",jv("getPort","setPort")),pE(Hv,"pathname",jv("getPathname","setPathname")),pE(Hv,"search",jv("getSearch","setSearch")),pE(Hv,"searchParams",jv("getSearchParams")),pE(Hv,"hash",jv("getHash","setHash"))),hE(Hv,"toJSON",(function(){return CE(this).serialize()}),{enumerable:!0}),hE(Hv,"toString",(function(){return CE(this).serialize()}),{enumerable:!0}),NE){var Wv=NE.createObjectURL,zv=NE.revokeObjectURL;Wv&&hE(Fv,"createObjectURL",dE(Wv,NE)),zv&&hE(Fv,"revokeObjectURL",dE(zv,NE))}SE(Fv,"URL"),sE({global:!0,constructor:!0,forced:!cE,sham:!aE},{URL:Fv});var Gv="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,Kv=Pt,Yv=Ht,Jv=RangeError,qv=function(e){if(void 0===e)return 0;var t=Kv(e),i=Yv(t);if(t!==i)throw Jv("Wrong length or index");return i},Xv=Array,Qv=Math.abs,Zv=Math.pow,$v=Math.floor,ey=Math.log,ty=Math.LN2,iy=H,ry=Ut,ny=Wt,oy=function(e){for(var t=iy(this),i=ny(t),r=arguments.length,n=ry(r>1?arguments[1]:void 0,i),o=r>2?arguments[2]:void 0,s=void 0===o?i:ry(o,i);s>n;)t[n++]=e;return t},sy=C,ay=l,cy=we,ly=Gv,dy=wr,uy=Yi,hy=ys,py=Xm,my=r,_y=ks,fy=Pt,gy=Ht,Ey=qv,vy={pack:function(e,t,i){var r,n,o,s=Xv(i),a=8*i-t-1,c=(1<<a)-1,l=c>>1,d=23===t?Zv(2,-24)-Zv(2,-77):0,u=e<0||0===e&&1/e<0?1:0,h=0;for((e=Qv(e))!=e||1/0===e?(n=e!=e?1:0,r=c):(r=$v(ey(e)/ty),e*(o=Zv(2,-r))<1&&(r--,o*=2),(e+=r+l>=1?d/o:d*Zv(2,1-l))*o>=2&&(r++,o/=2),r+l>=c?(n=0,r=c):r+l>=1?(n=(e*o-1)*Zv(2,t),r+=l):(n=e*Zv(2,l-1)*Zv(2,t),r=0));t>=8;)s[h++]=255&n,n/=256,t-=8;for(r=r<<t|n,a+=t;a>0;)s[h++]=255&r,r/=256,a-=8;return s[--h]|=128*u,s},unpack:function(e,t){var i,r=e.length,n=8*r-t-1,o=(1<<n)-1,s=o>>1,a=n-7,c=r-1,l=e[c--],d=127&l;for(l>>=7;a>0;)d=256*d+e[c--],a-=8;for(i=d&(1<<-a)-1,d>>=-a,a+=t;a>0;)i=256*i+e[c--],a-=8;if(0===d)d=1-s;else{if(d===o)return i?NaN:l?-1/0:1/0;i+=Zv(2,t),d-=s}return(l?-1:1)*i*Zv(2,d-t)}},yy=Kn,Ty=To,Sy=rn.f,Iy=oy,Ay=s_,Ry=no,by=ar,Cy=dy.PROPER,ky=dy.CONFIGURABLE,wy="ArrayBuffer",Ny="DataView",Dy="prototype",Oy="Wrong index",Ly=by.getterFor(wy),Py=by.getterFor(Ny),My=by.set,xy=sy[wy],Vy=xy,Uy=Vy&&Vy[Dy],By=sy[Ny],Fy=By&&By[Dy],Hy=Object.prototype,jy=sy.Array,Wy=sy.RangeError,zy=ay(Iy),Gy=ay([].reverse),Ky=vy.pack,Yy=vy.unpack,Jy=function(e){return[255&e]},qy=function(e){return[255&e,e>>8&255]},Xy=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},Qy=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},Zy=function(e){return Ky(e,23,4)},$y=function(e){return Ky(e,52,8)},eT=function(e,t,i){hy(e[Dy],t,{configurable:!0,get:function(){return i(this)[t]}})},tT=function(e,t,i,r){var n=Ey(i),o=Py(e);if(n+t>o.byteLength)throw Wy(Oy);var s=o.bytes,a=n+o.byteOffset,c=Ay(s,a,a+t);return r?c:Gy(c)},iT=function(e,t,i,r,n,o){var s=Ey(i),a=Py(e);if(s+t>a.byteLength)throw Wy(Oy);for(var c=a.bytes,l=s+a.byteOffset,d=r(+n),u=0;u<t;u++)c[l+u]=d[o?u:t-u-1]};if(ly){var rT=Cy&&xy.name!==wy;if(my((function(){xy(1)}))&&my((function(){new xy(-1)}))&&!my((function(){return new xy,new xy(1.5),new xy(NaN),1!=xy.length||rT&&!ky})))rT&&ky&&uy(xy,"name",wy);else{(Vy=function(e){return _y(this,Uy),new xy(Ey(e))})[Dy]=Uy;for(var nT,oT=Sy(xy),sT=0;oT.length>sT;)(nT=oT[sT++])in Vy||uy(Vy,nT,xy[nT]);Uy.constructor=Vy}Ty&&yy(Fy)!==Hy&&Ty(Fy,Hy);var aT=new By(new Vy(2)),cT=ay(Fy.setInt8);aT.setInt8(0,2147483648),aT.setInt8(1,2147483649),!aT.getInt8(0)&&aT.getInt8(1)||py(Fy,{setInt8:function(e,t){cT(this,e,t<<24>>24)},setUint8:function(e,t){cT(this,e,t<<24>>24)}},{unsafe:!0})}else Uy=(Vy=function(e){_y(this,Uy);var t=Ey(e);My(this,{type:wy,bytes:zy(jy(t),0),byteLength:t}),cy||(this.byteLength=t,this.detached=!1)})[Dy],Fy=(By=function(e,t,i){_y(this,Fy),_y(e,Uy);var r=Ly(e),n=r.byteLength,o=fy(t);if(o<0||o>n)throw Wy("Wrong offset");if(o+(i=void 0===i?n-o:gy(i))>n)throw Wy("Wrong length");My(this,{type:Ny,buffer:e,byteLength:i,byteOffset:o,bytes:r.bytes}),cy||(this.buffer=e,this.byteLength=i,this.byteOffset=o)})[Dy],cy&&(eT(Vy,"byteLength",Ly),eT(By,"buffer",Py),eT(By,"byteLength",Py),eT(By,"byteOffset",Py)),py(Fy,{getInt8:function(e){return tT(this,1,e)[0]<<24>>24},getUint8:function(e){return tT(this,1,e)[0]},getInt16:function(e){var t=tT(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=tT(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return Qy(tT(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return Qy(tT(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return Yy(tT(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return Yy(tT(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){iT(this,1,e,Jy,t)},setUint8:function(e,t){iT(this,1,e,Jy,t)},setInt16:function(e,t){iT(this,2,e,qy,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){iT(this,2,e,qy,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){iT(this,4,e,Xy,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){iT(this,4,e,Xy,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){iT(this,4,e,Zy,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){iT(this,8,e,$y,t,arguments.length>2?arguments[2]:void 0)}});Ry(Vy,wy),Ry(By,Ny);var lT={ArrayBuffer:Vy,DataView:By},dT=Vn,uT=ga,hT=r,pT=Ce,mT=Ut,_T=Ht,fT=la,gT=lT.ArrayBuffer,ET=lT.DataView,vT=ET.prototype,yT=uT(gT.prototype.slice),TT=uT(vT.getUint8),ST=uT(vT.setUint8);dT({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:hT((function(){return!new gT(2).slice(1,void 0).byteLength}))},{slice:function(e,t){if(yT&&void 0===t)return yT(pT(this),e);for(var i=pT(this).byteLength,r=mT(e,i),n=mT(void 0===t?i:t,i),o=new(fT(this,gT))(_T(n-r)),s=new ET(this),a=new ET(o),c=0;r<n;)ST(a,c++,TT(s,r++));return o}});var IT,AT,RT,bT={},CT={get exports(){return bT},set exports(e){bT=e}},kT=Gv,wT=we,NT=C,DT=ye,OT=Ie,LT=z,PT=xs,MT=Qe,xT=Yi,VT=tn,UT=ys,BT=ze,FT=Kn,HT=To,jT=fe,WT=q,zT=ar.enforce,GT=ar.get,KT=NT.Int8Array,YT=KT&&KT.prototype,JT=NT.Uint8ClampedArray,qT=JT&&JT.prototype,XT=KT&&FT(KT),QT=YT&&FT(YT),ZT=Object.prototype,$T=NT.TypeError,eS=jT("toStringTag"),tS=WT("TYPED_ARRAY_TAG"),iS="TypedArrayConstructor",rS=kT&&!!HT&&"Opera"!==PT(NT.opera),nS=!1,oS={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},sS={BigInt64Array:8,BigUint64Array:8},aS=function(e){var t=FT(e);if(OT(t)){var i=GT(t);return i&&LT(i,iS)?i[iS]:aS(t)}},cS=function(e){if(!OT(e))return!1;var t=PT(e);return LT(oS,t)||LT(sS,t)};for(IT in oS)(RT=(AT=NT[IT])&&AT.prototype)?zT(RT)[iS]=AT:rS=!1;for(IT in sS)(RT=(AT=NT[IT])&&AT.prototype)&&(zT(RT)[iS]=AT);if((!rS||!DT(XT)||XT===Function.prototype)&&(XT=function(){throw $T("Incorrect invocation")},rS))for(IT in oS)NT[IT]&&HT(NT[IT],XT);if((!rS||!QT||QT===ZT)&&(QT=XT.prototype,rS))for(IT in oS)NT[IT]&&HT(NT[IT].prototype,QT);if(rS&&FT(qT)!==QT&&HT(qT,QT),wT&&!LT(QT,eS))for(IT in nS=!0,UT(QT,eS,{configurable:!0,get:function(){return OT(this)?this[tS]:void 0}}),oS)NT[IT]&&xT(NT[IT],tS,IT);var lS={NATIVE_ARRAY_BUFFER_VIEWS:rS,TYPED_ARRAY_TAG:nS&&tS,aTypedArray:function(e){if(cS(e))return e;throw $T("Target is not a typed array")},aTypedArrayConstructor:function(e){if(DT(e)&&(!HT||BT(XT,e)))return e;throw $T(MT(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,i,r){if(wT){if(i)for(var n in oS){var o=NT[n];if(o&&LT(o.prototype,e))try{delete o.prototype[e]}catch(cB){try{o.prototype[e]=t}catch(s){}}}QT[e]&&!i||VT(QT,e,i?t:rS&&YT[e]||t,r)}},exportTypedArrayStaticMethod:function(e,t,i){var r,n;if(wT){if(HT){if(i)for(r in oS)if((n=NT[r])&&LT(n,e))try{delete n[e]}catch(cB){}if(XT[e]&&!i)return;try{return VT(XT,e,i?t:rS&&XT[e]||t)}catch(cB){}}for(r in oS)!(n=NT[r])||n[e]&&!i||VT(n,e,t)}},getTypedArrayConstructor:aS,isView:function(e){if(!OT(e))return!1;var t=PT(e);return"DataView"===t||LT(oS,t)||LT(sS,t)},isTypedArray:cS,TypedArray:XT,TypedArrayPrototype:QT},dS=C,uS=r,hS=kd,pS=lS.NATIVE_ARRAY_BUFFER_VIEWS,mS=dS.ArrayBuffer,_S=dS.Int8Array,fS=!pS||!uS((function(){_S(1)}))||!uS((function(){new _S(-1)}))||!hS((function(e){new _S,new _S(null),new _S(1.5),new _S(e)}),!0)||uS((function(){return 1!==new _S(new mS(2),1,void 0).length})),gS=Ie,ES=Math.floor,vS=Number.isInteger||function(e){return!gS(e)&&isFinite(e)&&ES(e)===e},yS=Pt,TS=RangeError,SS=function(e){var t=yS(e);if(t<0)throw TS("The argument can't be less than 0");return t},IS=RangeError,AS=function(e,t){var i=SS(e);if(i%t)throw IS("Wrong offset");return i},RS=xs,bS=ft,CS=TypeError,kS=function(e){var t=bS(e,"number");if("number"==typeof t)throw CS("Can't convert number to bigint");return BigInt(t)},wS=Ta,NS=Fe,DS=na,OS=H,LS=Wt,PS=od,MS=Zl,xS=Kl,VS=function(e){var t=RS(e);return"BigInt64Array"==t||"BigUint64Array"==t},US=lS.aTypedArrayConstructor,BS=kS,FS=Vn,HS=C,jS=Fe,WS=we,zS=fS,GS=lS,KS=lT,YS=ks,JS=zi,qS=Yi,XS=vS,QS=Ht,ZS=qv,$S=AS,eI=vt,tI=z,iI=xs,rI=Ie,nI=qe,oI=Ni,sI=ze,aI=To,cI=rn.f,lI=function(e){var t,i,r,n,o,s,a,c,l=DS(this),d=OS(e),u=arguments.length,h=u>1?arguments[1]:void 0,p=void 0!==h,m=MS(d);if(m&&!xS(m))for(c=(a=PS(d,m)).next,d=[];!(s=NS(c,a)).done;)d.push(s.value);for(p&&u>2&&(h=wS(h,arguments[2])),i=LS(d),r=new(US(l))(i),n=VS(r),t=0;i>t;t++)o=p?h(d[t],t):d[t],r[t]=n?BS(o):+o;return r},dI=rp.forEach,uI=Rs,hI=ys,pI=De,mI=cr,_I=au,fI=ar.get,gI=ar.set,EI=ar.enforce,vI=pI.f,yI=mI.f,TI=Math.round,SI=HS.RangeError,II=KS.ArrayBuffer,AI=II.prototype,RI=KS.DataView,bI=GS.NATIVE_ARRAY_BUFFER_VIEWS,CI=GS.TYPED_ARRAY_TAG,kI=GS.TypedArray,wI=GS.TypedArrayPrototype,NI=GS.aTypedArrayConstructor,DI=GS.isTypedArray,OI="BYTES_PER_ELEMENT",LI="Wrong length",PI=function(e,t){NI(e);for(var i=0,r=t.length,n=new e(r);r>i;)n[i]=t[i++];return n},MI=function(e,t){hI(e,t,{configurable:!0,get:function(){return fI(this)[t]}})},xI=function(e){var t;return sI(AI,e)||"ArrayBuffer"==(t=iI(e))||"SharedArrayBuffer"==t},VI=function(e,t){return DI(e)&&!nI(t)&&t in e&&XS(+t)&&t>=0},UI=function(e,t){return t=eI(t),VI(e,t)?JS(2,e[t]):yI(e,t)},BI=function(e,t,i){return t=eI(t),!(VI(e,t)&&rI(i)&&tI(i,"value"))||tI(i,"get")||tI(i,"set")||i.configurable||tI(i,"writable")&&!i.writable||tI(i,"enumerable")&&!i.enumerable?vI(e,t,i):(e[t]=i.value,e)};WS?(bI||(mI.f=UI,pI.f=BI,MI(wI,"buffer"),MI(wI,"byteOffset"),MI(wI,"byteLength"),MI(wI,"length")),FS({target:"Object",stat:!0,forced:!bI},{getOwnPropertyDescriptor:UI,defineProperty:BI}),CT.exports=function(e,t,i){var r=e.match(/\d+/)[0]/8,n=e+(i?"Clamped":"")+"Array",o="get"+e,s="set"+e,a=HS[n],c=a,l=c&&c.prototype,d={},u=function(e,t){vI(e,t,{get:function(){return e=t,(i=fI(this)).view[o](e*r+i.byteOffset,!0);var e,i},set:function(e){return n=t,o=e,a=fI(this),i&&(o=(o=TI(o))<0?0:o>255?255:255&o),void a.view[s](n*r+a.byteOffset,o,!0);var n,o,a},enumerable:!0})};bI?zS&&(c=t((function(e,t,i,n){return YS(e,l),_I(rI(t)?xI(t)?void 0!==n?new a(t,$S(i,r),n):void 0!==i?new a(t,$S(i,r)):new a(t):DI(t)?PI(c,t):jS(lI,c,t):new a(ZS(t)),e,c)})),aI&&aI(c,kI),dI(cI(a),(function(e){e in c||qS(c,e,a[e])})),c.prototype=l):(c=t((function(e,t,i,n){YS(e,l);var o,s,a,d=0,h=0;if(rI(t)){if(!xI(t))return DI(t)?PI(c,t):jS(lI,c,t);o=t,h=$S(i,r);var p=t.byteLength;if(void 0===n){if(p%r)throw SI(LI);if((s=p-h)<0)throw SI(LI)}else if((s=QS(n)*r)+h>p)throw SI(LI);a=s/r}else a=ZS(t),o=new II(s=a*r);for(gI(e,{buffer:o,byteOffset:h,byteLength:s,length:a,view:new RI(o)});d<a;)u(e,d++)})),aI&&aI(c,kI),l=c.prototype=oI(wI)),l.constructor!==c&&qS(l,"constructor",c),EI(l).TypedArrayConstructor=c,CI&&qS(l,CI,n);var h=c!=a;d[n]=c,FS({global:!0,constructor:!0,forced:h,sham:!bI},d),OI in c||qS(c,OI,r),OI in l||qS(l,OI,r),uI(n)}):CT.exports=function(){},bT("Uint8",(function(e){return function(t,i,r){return e(this,t,i,r)}}));var FI=oy,HI=kS,jI=xs,WI=Fe,zI=r,GI=lS.aTypedArray,KI=lS.exportTypedArrayMethod,YI=l("".slice);KI("fill",(function(e){var t=arguments.length;GI(this);var i="Big"===YI(jI(this),0,3)?HI(e):+e;return WI(FI,this,i,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)}),zI((function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),1!==e})));var JI=C,qI=Fe,XI=lS,QI=Wt,ZI=AS,$I=H,eA=r,tA=JI.RangeError,iA=JI.Int8Array,rA=iA&&iA.prototype,nA=rA&&rA.set,oA=XI.aTypedArray,sA=XI.exportTypedArrayMethod,aA=!eA((function(){var e=new Uint8ClampedArray(2);return qI(nA,e,{length:1,0:3},1),3!==e[1]})),cA=aA&&XI.NATIVE_ARRAY_BUFFER_VIEWS&&eA((function(){var e=new iA(2);return e.set(1),e.set("2",1),0!==e[0]||2!==e[1]}));sA("set",(function(e){oA(this);var t=ZI(arguments.length>1?arguments[1]:void 0,1),i=$I(e);if(aA)return qI(nA,this,i,t);var r=this.length,n=QI(i),o=0;if(n+t>r)throw tA("Wrong length");for(;o<n;)this[t+o]=i[o++]}),!aA||cA);var lA=X.match(/firefox\/(\d+)/i),dA=!!lA&&+lA[1],uA=/MSIE|Trident/.test(X),hA=X.match(/AppleWebKit\/(\d+)\./),pA=!!hA&&+hA[1],mA=ga,_A=r,fA=tt,gA=h_,EA=dA,vA=uA,yA=re,TA=pA,SA=lS.aTypedArray,IA=lS.exportTypedArrayMethod,AA=C.Uint16Array,RA=AA&&mA(AA.prototype.sort),bA=!(!RA||_A((function(){RA(new AA(2),null)}))&&_A((function(){RA(new AA(2),{})}))),CA=!!RA&&!_A((function(){if(yA)return yA<74;if(EA)return EA<67;if(vA)return!0;if(TA)return TA<602;var e,t,i=new AA(516),r=Array(516);for(e=0;e<516;e++)t=e%4,i[e]=515-e,r[e]=e-2*t+3;for(RA(i,(function(e,t){return(e/4|0)-(t/4|0)})),e=0;e<516;e++)if(i[e]!==r[e])return!0}));IA("sort",(function(e){return void 0!==e&&fA(e),CA?RA(this,e):gA(SA(this),function(e){return function(t,i){return void 0!==e?+e(t,i)||0:i!=i?-1:t!=t?1:0===t&&0===i?1/t>0&&1/i<0?1:-1:t>i}}(e))}),!CA||bA);var kA=Vn,wA=Cc,NA=r,DA=We,OA=ye,LA=la,PA=eu,MA=tn,xA=wA&&wA.prototype;if(kA({target:"Promise",proto:!0,real:!0,forced:!!wA&&NA((function(){xA.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=LA(this,DA("Promise")),i=OA(e);return this.then(i?function(i){return PA(t,e()).then((function(){return i}))}:e,i?function(i){return PA(t,e()).then((function(){throw i}))}:e)}}),OA(wA)){var VA=DA("Promise").prototype.finally;xA.finally!==VA&&MA(xA,"finally",VA,{unsafe:!0})}var UA=Rs,BA="ArrayBuffer",FA=lT[BA];Vn({global:!0,constructor:!0,forced:C[BA]!==FA},{ArrayBuffer:FA}),UA(BA);var HA=Qe,jA=TypeError,WA=Vn,zA=l,GA=tt,KA=H,YA=Wt,JA=function(e,t){if(!delete e[t])throw jA("Cannot delete property "+HA(t)+" of "+HA(e))},qA=mu,XA=r,QA=h_,ZA=op,$A=dA,eR=uA,tR=re,iR=pA,rR=[],nR=zA(rR.sort),oR=zA(rR.push),sR=XA((function(){rR.sort(void 0)})),aR=XA((function(){rR.sort(null)})),cR=ZA("sort"),lR=!XA((function(){if(tR)return tR<70;if(!($A&&$A>3)){if(eR)return!0;if(iR)return iR<603;var e,t,i,r,n="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:i=3;break;case 68:case 71:i=4;break;default:i=2}for(r=0;r<47;r++)rR.push({k:t+r,v:i})}for(rR.sort((function(e,t){return t.v-e.v})),r=0;r<rR.length;r++)t=rR[r].k.charAt(0),n.charAt(n.length-1)!==t&&(n+=t);return"DGBEFHACIJK"!==n}}));WA({target:"Array",proto:!0,forced:sR||!aR||!cR||!lR},{sort:function(e){void 0!==e&&GA(e);var t=KA(this);if(lR)return void 0===e?nR(t):nR(t,e);var i,r,n=[],o=YA(t);for(r=0;r<o;r++)r in t&&oR(n,t[r]);for(QA(n,function(e){return function(t,i){return void 0===i?-1:void 0===t?1:void 0!==e?+e(t,i)||0:qA(t)>qA(i)?1:-1}}(e)),i=YA(n),r=0;r<i;)t[r]=n[r++];for(;r<o;)JA(t,r++);return t}}),bT("Float32",(function(e){return function(t,i,r){return e(this,t,i,r)}}));var dR=Vn,uR=Wh,hR=l([].reverse),pR=[1,2];dR({target:"Array",proto:!0,forced:String(pR)===String(pR.reverse())},{reverse:function(){return uR(this)&&(this.length=this.length),hR(this)}});var mR=Vn,_R=Fe,fR=l,gR=S,ER=ye,vR=v,yR=uu,TR=mu,SR=nt,IR=Su,AR=Jp,RR=fe("replace"),bR=TypeError,CR=fR("".indexOf);fR("".replace);var kR=fR("".slice),wR=Math.max,NR=function(e,t,i){return i>e.length?-1:""===t?i:CR(e,t,i)};mR({target:"String",proto:!0},{replaceAll:function(e,t){var i,r,n,o,s,a,c,l,d=gR(this),u=0,h=0,p="";if(!vR(e)){if(yR(e)&&(i=TR(gR(IR(e))),!~CR(i,"g")))throw bR("`.replaceAll` does not allow non-global regexes");if(r=SR(e,RR))return _R(r,e,d,t)}for(n=TR(d),o=TR(e),(s=ER(t))||(t=TR(t)),a=o.length,c=wR(1,a),u=NR(n,o,0);-1!==u;)l=s?TR(t(o,u,n)):AR(o,n,u,[],void 0,t),p+=kR(n,h,u)+l,h=u+a,u=NR(n,o,u+c);return h<n.length&&(p+=kR(n,h)),p}});let DR=!0,OR=!0;function LR(e,t,i){const r=e.match(t);return r&&r.length>=i&&parseInt(r[i],10)}function PR(e,t,i){if(!e.RTCPeerConnection)return;const r=e.RTCPeerConnection.prototype,n=r.addEventListener;r.addEventListener=function(e,r){if(e!==t)return n.apply(this,arguments);const o=e=>{const t=i(e);t&&(r.handleEvent?r.handleEvent(t):r(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(r,o),n.apply(this,[e,o])};const o=r.removeEventListener;r.removeEventListener=function(e,i){if(e!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(i))return o.apply(this,arguments);const r=this._eventMap[t].get(i);return this._eventMap[t].delete(i),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,r])},Object.defineProperty(r,"on"+t,{get(){return this["_on"+t]},set(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}function MR(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(DR=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function xR(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(OR=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function VR(){if("object"==typeof window){if(DR)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function UR(e,t){OR&&console.warn(e+" is deprecated, please use "+t+" instead.")}function BR(e){return"[object Object]"===Object.prototype.toString.call(e)}function FR(e){return BR(e)?Object.keys(e).reduce((function(t,i){const r=BR(e[i]),n=r?FR(e[i]):e[i],o=r&&!Object.keys(n).length;return void 0===n||o?t:Object.assign(t,{[i]:n})}),{}):e}function HR(e,t,i){t&&!i.has(t.id)&&(i.set(t.id,t),Object.keys(t).forEach((r=>{r.endsWith("Id")?HR(e,e.get(t[r]),i):r.endsWith("Ids")&&t[r].forEach((t=>{HR(e,e.get(t),i)}))})))}function jR(e,t,i){const r=i?"outbound-rtp":"inbound-rtp",n=new Map;if(null===t)return n;const o=[];return e.forEach((e=>{"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)})),o.forEach((t=>{e.forEach((i=>{i.type===r&&i.trackId===t.id&&HR(e,i,n)}))})),n}const WR=VR;function zR(e,t){const i=e&&e.navigator;if(!i.mediaDevices)return;const r=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;const t={};return Object.keys(e).forEach((i=>{if("require"===i||"advanced"===i||"mediaSource"===i)return;const r="object"==typeof e[i]?e[i]:{ideal:e[i]};void 0!==r.exact&&"number"==typeof r.exact&&(r.min=r.max=r.exact);const n=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==r.ideal){t.optional=t.optional||[];let e={};"number"==typeof r.ideal?(e[n("min",i)]=r.ideal,t.optional.push(e),e={},e[n("max",i)]=r.ideal,t.optional.push(e)):(e[n("",i)]=r.ideal,t.optional.push(e))}void 0!==r.exact&&"number"!=typeof r.exact?(t.mandatory=t.mandatory||{},t.mandatory[n("",i)]=r.exact):["min","max"].forEach((e=>{void 0!==r[e]&&(t.mandatory=t.mandatory||{},t.mandatory[n(e,i)]=r[e])}))})),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},n=function(e,n){if(t.version>=61)return n(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"==typeof e.audio){const t=function(e,t,i){t in e&&!(i in e)&&(e[i]=e[t],delete e[t])};t((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),t(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=r(e.audio)}if(e&&"object"==typeof e.video){let o=e.video.facingMode;o=o&&("object"==typeof o?o:{ideal:o});const s=t.version<66;if(o&&("user"===o.exact||"environment"===o.exact||"user"===o.ideal||"environment"===o.ideal)&&(!i.mediaDevices.getSupportedConstraints||!i.mediaDevices.getSupportedConstraints().facingMode||s)){let t;if(delete e.video.facingMode,"environment"===o.exact||"environment"===o.ideal?t=["back","rear"]:"user"!==o.exact&&"user"!==o.ideal||(t=["front"]),t)return i.mediaDevices.enumerateDevices().then((i=>{let s=(i=i.filter((e=>"videoinput"===e.kind))).find((e=>t.some((t=>e.label.toLowerCase().includes(t)))));return!s&&i.length&&t.includes("back")&&(s=i[i.length-1]),s&&(e.video.deviceId=o.exact?{exact:s.deviceId}:{ideal:s.deviceId}),e.video=r(e.video),WR("chrome: "+JSON.stringify(e)),n(e)}))}e.video=r(e.video)}return WR("chrome: "+JSON.stringify(e)),n(e)},o=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}};if(i.getUserMedia=function(e,t,r){n(e,(e=>{i.webkitGetUserMedia(e,t,(e=>{r&&r(o(e))}))}))}.bind(i),i.mediaDevices.getUserMedia){const e=i.mediaDevices.getUserMedia.bind(i.mediaDevices);i.mediaDevices.getUserMedia=function(t){return n(t,(t=>e(t).then((e=>{if(t.audio&&!e.getAudioTracks().length||t.video&&!e.getVideoTracks().length)throw e.getTracks().forEach((e=>{e.stop()})),new DOMException("","NotFoundError");return e}),(e=>Promise.reject(o(e))))))}}}function GR(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function KR(e){if("object"==typeof e&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener("addtrack",(i=>{let r;r=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===i.track.id)):{track:i.track};const n=new Event("track");n.track=i.track,n.receiver=r,n.transceiver={receiver:r},n.streams=[t.stream],this.dispatchEvent(n)})),t.stream.getTracks().forEach((i=>{let r;r=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===i.id)):{track:i};const n=new Event("track");n.track=i,n.receiver=r,n.transceiver={receiver:r},n.streams=[t.stream],this.dispatchEvent(n)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else PR(e,"track",(e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e)))}function YR(e){if("object"==typeof e&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){const t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const i=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){let n=i.apply(this,arguments);return n||(n=t(this,e),this._senders.push(n)),n};const r=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){r.apply(this,arguments);const t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}const i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._senders=this._senders||[],i.apply(this,[e]),e.getTracks().forEach((e=>{this._senders.push(t(this,e))}))};const r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._senders=this._senders||[],r.apply(this,[e]),e.getTracks().forEach((e=>{const t=this._senders.find((t=>t.track===e));t&&this._senders.splice(this._senders.indexOf(t),1)}))}}else if("object"==typeof e&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function JR(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,i,r]=arguments;if(arguments.length>0&&"function"==typeof e)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof e))return t.apply(this,[]);const n=function(e){const t={};return e.result().forEach((e=>{const i={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach((t=>{i[t]=e.stat(t)})),t[i.id]=i})),t},o=function(e){return new Map(Object.keys(e).map((t=>[t,e[t]])))};if(arguments.length>=2){const r=function(e){i(o(n(e)))};return t.apply(this,[r,e])}return new Promise(((e,i)=>{t.apply(this,[function(t){e(o(n(t)))},i])})).then(i,r)}}function qR(e){if(!("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e});const i=e.RTCPeerConnection.prototype.addTrack;i&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=i.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>jR(t,e.track,!0)))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e}),PR(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>jR(t,e.track,!1)))}}if(!("getStats"in e.RTCRtpSender.prototype)||!("getStats"in e.RTCRtpReceiver.prototype))return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){const e=arguments[0];let t,i,r;return this.getSenders().forEach((i=>{i.track===e&&(t?r=!0:t=i)})),this.getReceivers().forEach((t=>(t.track===e&&(i?r=!0:i=t),t.track===e))),r||t&&i?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():i?i.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function XR(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map((e=>this._shimmedLocalStreams[e][0]))};const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,i){if(!i)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const r=t.apply(this,arguments);return this._shimmedLocalStreams[i.id]?-1===this._shimmedLocalStreams[i.id].indexOf(r)&&this._shimmedLocalStreams[i.id].push(r):this._shimmedLocalStreams[i.id]=[i,r],r};const i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach((e=>{if(this.getSenders().find((t=>t.track===e)))throw new DOMException("Track already exists.","InvalidAccessError")}));const t=this.getSenders();i.apply(this,arguments);const r=this.getSenders().filter((e=>-1===t.indexOf(e)));this._shimmedLocalStreams[e.id]=[e].concat(r)};const r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],r.apply(this,arguments)};const n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach((t=>{const i=this._shimmedLocalStreams[t].indexOf(e);-1!==i&&this._shimmedLocalStreams[t].splice(i,1),1===this._shimmedLocalStreams[t].length&&delete this._shimmedLocalStreams[t]})),n.apply(this,arguments)}}function QR(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return XR(e);const i=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){const e=i.apply(this);return this._reverseStreams=this._reverseStreams||{},e.map((e=>this._reverseStreams[e.id]))};const r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach((e=>{if(this.getSenders().find((t=>t.track===e)))throw new DOMException("Track already exists.","InvalidAccessError")})),!this._reverseStreams[t.id]){const i=new e.MediaStream(t.getTracks());this._streams[t.id]=i,this._reverseStreams[i.id]=t,t=i}r.apply(this,[t])};const n=e.RTCPeerConnection.prototype.removeStream;function o(e,t){let i=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const r=e._reverseStreams[t],n=e._streams[r.id];i=i.replace(new RegExp(n.id,"g"),r.id)})),new RTCSessionDescription({type:t.type,sdp:i})}e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},n.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,i){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const r=[].slice.call(arguments,1);if(1!==r.length||!r[0].getTracks().find((e=>e===t)))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find((e=>e.track===t)))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const n=this._streams[i.id];if(n)n.addTrack(t),Promise.resolve().then((()=>{this.dispatchEvent(new Event("negotiationneeded"))}));else{const r=new e.MediaStream([t]);this._streams[i.id]=r,this._reverseStreams[r.id]=i,this.addStream(r)}return this.getSenders().find((e=>e.track===t))},["createOffer","createAnswer"].forEach((function(t){const i=e.RTCPeerConnection.prototype[t],r={[t](){const e=arguments;return arguments.length&&"function"==typeof arguments[0]?i.apply(this,[t=>{const i=o(this,t);e[0].apply(null,[i])},t=>{e[1]&&e[1].apply(null,t)},arguments[2]]):i.apply(this,arguments).then((e=>o(this,e)))}};e.RTCPeerConnection.prototype[t]=r[t]}));const s=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=function(e,t){let i=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const r=e._reverseStreams[t],n=e._streams[r.id];i=i.replace(new RegExp(r.id,"g"),n.id)})),new RTCSessionDescription({type:t.type,sdp:i})}(this,arguments[0]),s.apply(this,arguments)):s.apply(this,arguments)};const a=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get(){const e=a.get.apply(this);return""===e.type?e:o(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(e._pc!==this)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");let t;this._streams=this._streams||{},Object.keys(this._streams).forEach((i=>{this._streams[i].getTracks().find((t=>e.track===t))&&(t=this._streams[i])})),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function ZR(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const i=e.RTCPeerConnection.prototype[t],r={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),i.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=r[t]}))}function $R(e,t){PR(e,"negotiationneeded",(e=>{const i=e.target;if(!(t.version<72||i.getConfiguration&&"plan-b"===i.getConfiguration().sdpSemantics)||"stable"===i.signalingState)return e}))}var eb=Object.freeze({__proto__:null,shimMediaStream:GR,shimOnTrack:KR,shimGetSendersWithDtmf:YR,shimGetStats:JR,shimSenderReceiverGetStats:qR,shimAddTrackRemoveTrackWithNative:XR,shimAddTrackRemoveTrack:QR,shimPeerConnection:ZR,fixNegotiationNeeded:$R,shimGetUserMedia:zR,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(i){return t(i).then((t=>{const r=i.video&&i.video.width,n=i.video&&i.video.height,o=i.video&&i.video.frameRate;return i.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:o||3}},r&&(i.video.mandatory.maxWidth=r),n&&(i.video.mandatory.maxHeight=n),e.navigator.mediaDevices.getUserMedia(i)}))}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}});function tb(e,t){const i=e&&e.navigator,r=e&&e.MediaStreamTrack;if(i.getUserMedia=function(e,t,r){UR("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),i.mediaDevices.getUserMedia(e).then(t,r)},!(t.version>55&&"autoGainControl"in i.mediaDevices.getSupportedConstraints())){const e=function(e,t,i){t in e&&!(i in e)&&(e[i]=e[t],delete e[t])},t=i.mediaDevices.getUserMedia.bind(i.mediaDevices);if(i.mediaDevices.getUserMedia=function(i){return"object"==typeof i&&"object"==typeof i.audio&&(i=JSON.parse(JSON.stringify(i)),e(i.audio,"autoGainControl","mozAutoGainControl"),e(i.audio,"noiseSuppression","mozNoiseSuppression")),t(i)},r&&r.prototype.getSettings){const t=r.prototype.getSettings;r.prototype.getSettings=function(){const i=t.apply(this,arguments);return e(i,"mozAutoGainControl","autoGainControl"),e(i,"mozNoiseSuppression","noiseSuppression"),i}}if(r&&r.prototype.applyConstraints){const t=r.prototype.applyConstraints;r.prototype.applyConstraints=function(i){return"audio"===this.kind&&"object"==typeof i&&(i=JSON.parse(JSON.stringify(i)),e(i,"autoGainControl","mozAutoGainControl"),e(i,"noiseSuppression","mozNoiseSuppression")),t.apply(this,[i])}}}}function ib(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function rb(e,t){if("object"!=typeof e||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const i=e.RTCPeerConnection.prototype[t],r={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),i.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=r[t]}));const i={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},r=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,n,o]=arguments;return r.apply(this,[e||null]).then((e=>{if(t.version<53&&!n)try{e.forEach((e=>{e.type=i[e.type]||e.type}))}catch(r){if("TypeError"!==r.name)throw r;e.forEach(((t,r)=>{e.set(r,Object.assign({},t,{type:i[t.type]||t.type}))}))}return e})).then(n,o)}}function nb(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e});const i=e.RTCPeerConnection.prototype.addTrack;i&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=i.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function ob(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e}),PR(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function sb(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){UR("removeStream","removeTrack"),this.getSenders().forEach((t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t)}))})}function ab(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function cb(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];let e=arguments[1]&&arguments[1].sendEncodings;void 0===e&&(e=[]),e=[...e];const i=e.length>0;i&&e.forEach((e=>{if("rid"in e&&!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(parseFloat(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")}));const r=t.apply(this,arguments);if(i){const{sender:t}=r,i=t.getParameters();(!("encodings"in i)||1===i.encodings.length&&0===Object.keys(i.encodings[0]).length)&&(i.encodings=e,t.sendEncodings=e,this.setParametersPromises.push(t.setParameters(i).then((()=>{delete t.sendEncodings})).catch((()=>{delete t.sendEncodings}))))}return r})}function lb(e){if("object"!=typeof e||!e.RTCRtpSender)return;const t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){const e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})}function db(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((()=>t.apply(this,arguments))).finally((()=>{this.setParametersPromises=[]})):t.apply(this,arguments)}}function ub(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((()=>t.apply(this,arguments))).finally((()=>{this.setParametersPromises=[]})):t.apply(this,arguments)}}var hb=Object.freeze({__proto__:null,shimOnTrack:ib,shimPeerConnection:rb,shimSenderGetStats:nb,shimReceiverGetStats:ob,shimRemoveStream:sb,shimRTCDataChannel:ab,shimAddTransceiver:cb,shimGetParameters:lb,shimCreateOffer:db,shimCreateAnswer:ub,shimGetUserMedia:tb,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(i){if(!i||!i.video){const e=new DOMException("getDisplayMedia without video constraints is undefined");return e.name="NotFoundError",e.code=8,Promise.reject(e)}return!0===i.video?i.video={mediaSource:t}:i.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(i)})}});function pb(e){if("object"==typeof e&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach((i=>t.call(this,i,e))),e.getVideoTracks().forEach((i=>t.call(this,i,e)))},e.RTCPeerConnection.prototype.addTrack=function(e,...i){return i&&i.forEach((e=>{this._localStreams?this._localStreams.includes(e)||this._localStreams.push(e):this._localStreams=[e]})),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const t=this._localStreams.indexOf(e);if(-1===t)return;this._localStreams.splice(t,1);const i=e.getTracks();this.getSenders().forEach((e=>{i.includes(e.track)&&this.removeTrack(e)}))})}}function mb(e){if("object"==typeof e&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=e=>{e.streams.forEach((e=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(e))return;this._remoteStreams.push(e);const t=new Event("addstream");t.stream=e,this.dispatchEvent(t)}))})}});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){const e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach((t=>{if(e._remoteStreams||(e._remoteStreams=[]),e._remoteStreams.indexOf(t)>=0)return;e._remoteStreams.push(t);const i=new Event("addstream");i.stream=t,e.dispatchEvent(i)}))}),t.apply(e,arguments)}}}function _b(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype,i=t.createOffer,r=t.createAnswer,n=t.setLocalDescription,o=t.setRemoteDescription,s=t.addIceCandidate;t.createOffer=function(e,t){const r=arguments.length>=2?arguments[2]:arguments[0],n=i.apply(this,[r]);return t?(n.then(e,t),Promise.resolve()):n},t.createAnswer=function(e,t){const i=arguments.length>=2?arguments[2]:arguments[0],n=r.apply(this,[i]);return t?(n.then(e,t),Promise.resolve()):n};let a=function(e,t,i){const r=n.apply(this,[e]);return i?(r.then(t,i),Promise.resolve()):r};t.setLocalDescription=a,a=function(e,t,i){const r=o.apply(this,[e]);return i?(r.then(t,i),Promise.resolve()):r},t.setRemoteDescription=a,a=function(e,t,i){const r=s.apply(this,[e]);return i?(r.then(t,i),Promise.resolve()):r},t.addIceCandidate=a}function fb(e){const t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){const e=t.mediaDevices,i=e.getUserMedia.bind(e);t.mediaDevices.getUserMedia=e=>i(gb(e))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,i,r){t.mediaDevices.getUserMedia(e).then(i,r)}.bind(t))}function gb(e){return e&&void 0!==e.video?Object.assign({},e,{video:FR(e.video)}):e}function Eb(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,i){if(e&&e.iceServers){const t=[];for(let i=0;i<e.iceServers.length;i++){let r=e.iceServers[i];void 0===r.urls&&r.url?(UR("RTCIceServer.url","RTCIceServer.urls"),r=JSON.parse(JSON.stringify(r)),r.urls=r.url,delete r.url,t.push(r)):t.push(e.iceServers[i])}e.iceServers=t}return new t(e,i)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:()=>t.generateCertificate})}function vb(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function yb(e){const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);const t=this.getTransceivers().find((e=>"audio"===e.receiver.track.kind));!1===e.offerToReceiveAudio&&t?"sendrecv"===t.direction?t.setDirection?t.setDirection("sendonly"):t.direction="sendonly":"recvonly"===t.direction&&(t.setDirection?t.setDirection("inactive"):t.direction="inactive"):!0!==e.offerToReceiveAudio||t||this.addTransceiver("audio",{direction:"recvonly"}),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);const i=this.getTransceivers().find((e=>"video"===e.receiver.track.kind));!1===e.offerToReceiveVideo&&i?"sendrecv"===i.direction?i.setDirection?i.setDirection("sendonly"):i.direction="sendonly":"recvonly"===i.direction&&(i.setDirection?i.setDirection("inactive"):i.direction="inactive"):!0!==e.offerToReceiveVideo||i||this.addTransceiver("video",{direction:"recvonly"})}return t.apply(this,arguments)}}function Tb(e){"object"!=typeof e||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var Sb=Object.freeze({__proto__:null,shimLocalStreamsAPI:pb,shimRemoteStreamsAPI:mb,shimCallbacksAPI:_b,shimGetUserMedia:fb,shimConstraints:gb,shimRTCIceServerUrls:Eb,shimTrackEventTransceiver:vb,shimCreateOfferLegacy:yb,shimAudioContext:Tb}),Ib={};!function(e){const t={generateIdentifier:function(){return Math.random().toString(36).substring(2,12)}};t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split("\n").map((e=>e.trim()))},t.splitSections=function(e){return e.split("\nm=").map(((e,t)=>(t>0?"m="+e:e).trim()+"\r\n"))},t.getDescription=function(e){const i=t.splitSections(e);return i&&i[0]},t.getMediaSections=function(e){const i=t.splitSections(e);return i.shift(),i},t.matchPrefix=function(e,i){return t.splitLines(e).filter((e=>0===e.indexOf(i)))},t.parseCandidate=function(e){let t;t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" ");const i={foundation:t[0],component:{1:"rtp",2:"rtcp"}[t[1]]||t[1],protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]};for(let r=8;r<t.length;r+=2)switch(t[r]){case"raddr":i.relatedAddress=t[r+1];break;case"rport":i.relatedPort=parseInt(t[r+1],10);break;case"tcptype":i.tcpType=t[r+1];break;case"ufrag":i.ufrag=t[r+1],i.usernameFragment=t[r+1];break;default:void 0===i[t[r]]&&(i[t[r]]=t[r+1])}return i},t.writeCandidate=function(e){const t=[];t.push(e.foundation);const i=e.component;"rtp"===i?t.push(1):"rtcp"===i?t.push(2):t.push(i),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);const r=e.type;return t.push("typ"),t.push(r),"host"!==r&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(t.push("ufrag"),t.push(e.usernameFragment||e.ufrag)),"candidate:"+t.join(" ")},t.parseIceOptions=function(e){return e.substring(14).split(" ")},t.parseRtpMap=function(e){let t=e.substring(9).split(" ");const i={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),i.name=t[0],i.clockRate=parseInt(t[1],10),i.channels=3===t.length?parseInt(t[2],10):1,i.numChannels=i.channels,i},t.writeRtpMap=function(e){let t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);const i=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==i?"/"+i:"")+"\r\n"},t.parseExtmap=function(e){const t=e.substring(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1],attributes:t.slice(2).join(" ")}},t.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+(e.attributes?" "+e.attributes:"")+"\r\n"},t.parseFmtp=function(e){const t={};let i;const r=e.substring(e.indexOf(" ")+1).split(";");for(let n=0;n<r.length;n++)i=r[n].trim().split("="),t[i[0].trim()]=i[1];return t},t.writeFmtp=function(e){let t="",i=e.payloadType;if(void 0!==e.preferredPayloadType&&(i=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){const r=[];Object.keys(e.parameters).forEach((t=>{void 0!==e.parameters[t]?r.push(t+"="+e.parameters[t]):r.push(t)})),t+="a=fmtp:"+i+" "+r.join(";")+"\r\n"}return t},t.parseRtcpFb=function(e){const t=e.substring(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},t.writeRtcpFb=function(e){let t="",i=e.payloadType;return void 0!==e.preferredPayloadType&&(i=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach((e=>{t+="a=rtcp-fb:"+i+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"})),t},t.parseSsrcMedia=function(e){const t=e.indexOf(" "),i={ssrc:parseInt(e.substring(7,t),10)},r=e.indexOf(":",t);return r>-1?(i.attribute=e.substring(t+1,r),i.value=e.substring(r+1)):i.attribute=e.substring(t+1),i},t.parseSsrcGroup=function(e){const t=e.substring(13).split(" ");return{semantics:t.shift(),ssrcs:t.map((e=>parseInt(e,10)))}},t.getMid=function(e){const i=t.matchPrefix(e,"a=mid:")[0];if(i)return i.substring(6)},t.parseFingerprint=function(e){const t=e.substring(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},t.getDtlsParameters=function(e,i){return{role:"auto",fingerprints:t.matchPrefix(e+i,"a=fingerprint:").map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,t){let i="a=setup:"+t+"\r\n";return e.fingerprints.forEach((e=>{i+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),i},t.parseCryptoLine=function(e){const t=e.substring(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},t.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==typeof e.keyParams?t.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},t.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;const t=e.substring(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},t.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},t.getCryptoParameters=function(e,i){return t.matchPrefix(e+i,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(e,i){const r=t.matchPrefix(e+i,"a=ice-ufrag:")[0],n=t.matchPrefix(e+i,"a=ice-pwd:")[0];return r&&n?{usernameFragment:r.substring(12),password:n.substring(10)}:null},t.writeIceParameters=function(e){let t="a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n";return e.iceLite&&(t+="a=ice-lite\r\n"),t},t.parseRtpParameters=function(e){const i={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=t.splitLines(e)[0].split(" ");i.profile=r[2];for(let o=3;o<r.length;o++){const n=r[o],s=t.matchPrefix(e,"a=rtpmap:"+n+" ")[0];if(s){const r=t.parseRtpMap(s),o=t.matchPrefix(e,"a=fmtp:"+n+" ");switch(r.parameters=o.length?t.parseFmtp(o[0]):{},r.rtcpFeedback=t.matchPrefix(e,"a=rtcp-fb:"+n+" ").map(t.parseRtcpFb),i.codecs.push(r),r.name.toUpperCase()){case"RED":case"ULPFEC":i.fecMechanisms.push(r.name.toUpperCase())}}}t.matchPrefix(e,"a=extmap:").forEach((e=>{i.headerExtensions.push(t.parseExtmap(e))}));const n=t.matchPrefix(e,"a=rtcp-fb:* ").map(t.parseRtcpFb);return i.codecs.forEach((e=>{n.forEach((t=>{e.rtcpFeedback.find((e=>e.type===t.type&&e.parameter===t.parameter))||e.rtcpFeedback.push(t)}))})),i},t.writeRtpDescription=function(e,i){let r="";r+="m="+e+" ",r+=i.codecs.length>0?"9":"0",r+=" "+(i.profile||"UDP/TLS/RTP/SAVPF")+" ",r+=i.codecs.map((e=>void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType)).join(" ")+"\r\n",r+="c=IN IP4 0.0.0.0\r\n",r+="a=rtcp:9 IN IP4 0.0.0.0\r\n",i.codecs.forEach((e=>{r+=t.writeRtpMap(e),r+=t.writeFmtp(e),r+=t.writeRtcpFb(e)}));let n=0;return i.codecs.forEach((e=>{e.maxptime>n&&(n=e.maxptime)})),n>0&&(r+="a=maxptime:"+n+"\r\n"),i.headerExtensions&&i.headerExtensions.forEach((e=>{r+=t.writeExtmap(e)})),r},t.parseRtpEncodingParameters=function(e){const i=[],r=t.parseRtpParameters(e),n=-1!==r.fecMechanisms.indexOf("RED"),o=-1!==r.fecMechanisms.indexOf("ULPFEC"),s=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"cname"===e.attribute)),a=s.length>0&&s[0].ssrc;let c;const l=t.matchPrefix(e,"a=ssrc-group:FID").map((e=>e.substring(17).split(" ").map((e=>parseInt(e,10)))));l.length>0&&l[0].length>1&&l[0][0]===a&&(c=l[0][1]),r.codecs.forEach((e=>{if("RTX"===e.name.toUpperCase()&&e.parameters.apt){let t={ssrc:a,codecPayloadType:parseInt(e.parameters.apt,10)};a&&c&&(t.rtx={ssrc:c}),i.push(t),n&&(t=JSON.parse(JSON.stringify(t)),t.fec={ssrc:a,mechanism:o?"red+ulpfec":"red"},i.push(t))}})),0===i.length&&a&&i.push({ssrc:a});let d=t.matchPrefix(e,"b=");return d.length&&(d=0===d[0].indexOf("b=TIAS:")?parseInt(d[0].substring(7),10):0===d[0].indexOf("b=AS:")?1e3*parseInt(d[0].substring(5),10)*.95-16e3:void 0,i.forEach((e=>{e.maxBitrate=d}))),i},t.parseRtcpParameters=function(e){const i={},r=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"cname"===e.attribute))[0];r&&(i.cname=r.value,i.ssrc=r.ssrc);const n=t.matchPrefix(e,"a=rtcp-rsize");i.reducedSize=n.length>0,i.compound=0===n.length;const o=t.matchPrefix(e,"a=rtcp-mux");return i.mux=o.length>0,i},t.writeRtcpParameters=function(e){let t="";return e.reducedSize&&(t+="a=rtcp-rsize\r\n"),e.mux&&(t+="a=rtcp-mux\r\n"),void 0!==e.ssrc&&e.cname&&(t+="a=ssrc:"+e.ssrc+" cname:"+e.cname+"\r\n"),t},t.parseMsid=function(e){let i;const r=t.matchPrefix(e,"a=msid:");if(1===r.length)return i=r[0].substring(7).split(" "),{stream:i[0],track:i[1]};const n=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"msid"===e.attribute));return n.length>0?(i=n[0].value.split(" "),{stream:i[0],track:i[1]}):void 0},t.parseSctpDescription=function(e){const i=t.parseMLine(e),r=t.matchPrefix(e,"a=max-message-size:");let n;r.length>0&&(n=parseInt(r[0].substring(19),10)),isNaN(n)&&(n=65536);const o=t.matchPrefix(e,"a=sctp-port:");if(o.length>0)return{port:parseInt(o[0].substring(12),10),protocol:i.fmt,maxMessageSize:n};const s=t.matchPrefix(e,"a=sctpmap:");if(s.length>0){const e=s[0].substring(10).split(" ");return{port:parseInt(e[0],10),protocol:e[1],maxMessageSize:n}}},t.writeSctpDescription=function(e,t){let i=[];return i="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&i.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),i.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,22)},t.writeSessionBoilerplate=function(e,i,r){let n;const o=void 0!==i?i:2;return n=e||t.generateSessionId(),"v=0\r\no="+(r||"thisisadapterortc")+" "+n+" "+o+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},t.getDirection=function(e,i){const r=t.splitLines(e);for(let t=0;t<r.length;t++)switch(r[t]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return r[t].substring(2)}return i?t.getDirection(i):"sendrecv"},t.getKind=function(e){return t.splitLines(e)[0].split(" ")[0].substring(2)},t.isRejected=function(e){return"0"===e.split(" ",2)[1]},t.parseMLine=function(e){const i=t.splitLines(e)[0].substring(2).split(" ");return{kind:i[0],port:parseInt(i[1],10),protocol:i[2],fmt:i.slice(3).join(" ")}},t.parseOLine=function(e){const i=t.matchPrefix(e,"o=")[0].substring(2).split(" ");return{username:i[0],sessionId:i[1],sessionVersion:parseInt(i[2],10),netType:i[3],addressType:i[4],address:i[5]}},t.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;const i=t.splitLines(e);for(let t=0;t<i.length;t++)if(i[t].length<2||"="!==i[t].charAt(1))return!1;return!0},e.exports=t}({get exports(){return Ib},set exports(e){Ib=e}});var Ab=Ib,Rb=e({__proto__:null,default:Ab},[Ib]);function bb(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;const t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"==typeof e&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substring(2)),e.candidate&&e.candidate.length){const i=new t(e),r=Ab.parseCandidate(e.candidate);for(const e in r)e in i||Object.defineProperty(i,e,{value:r[e]});return i.toJSON=function(){return{candidate:i.candidate,sdpMid:i.sdpMid,sdpMLineIndex:i.sdpMLineIndex,usernameFragment:i.usernameFragment}},i}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,PR(e,"icecandidate",(t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t)))}function Cb(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||PR(e,"icecandidate",(e=>{if(e.candidate){const t=Ab.parseCandidate(e.candidate.candidate);"relay"===t.type&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e}))}function kb(e,t){if(!e.RTCPeerConnection)return;"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get(){return void 0===this._sctp?null:this._sctp}});const i=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){const{sdpSemantics:e}=this.getConfiguration();"plan-b"===e&&Object.defineProperty(this,"sctp",{get(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(function(e){if(!e||!e.sdp)return!1;const t=Ab.splitSections(e.sdp);return t.shift(),t.some((e=>{const t=Ab.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")}))}(arguments[0])){const e=function(e){const t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;const i=parseInt(t[1],10);return i!=i?-1:i}(arguments[0]),i=function(e){let i=65536;return"firefox"===t.browser&&(i=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),i}(e),r=function(e,i){let r=65536;"firefox"===t.browser&&57===t.version&&(r=65535);const n=Ab.matchPrefix(e.sdp,"a=max-message-size:");return n.length>0?r=parseInt(n[0].substring(19),10):"firefox"===t.browser&&-1!==i&&(r=2147483637),r}(arguments[0],e);let n;n=0===i&&0===r?Number.POSITIVE_INFINITY:0===i||0===r?Math.max(i,r):Math.min(i,r);const o={};Object.defineProperty(o,"maxMessageSize",{get:()=>n}),this._sctp=o}return i.apply(this,arguments)}}function wb(e){if(!e.RTCPeerConnection||!("createDataChannel"in e.RTCPeerConnection.prototype))return;function t(e,t){const i=e.send;e.send=function(){const r=arguments[0],n=r.length||r.size||r.byteLength;if("open"===e.readyState&&t.sctp&&n>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return i.apply(e,arguments)}}const i=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){const e=i.apply(this,arguments);return t(e,this),e},PR(e,"datachannel",(e=>(t(e.channel,e.target),e)))}function Nb(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;const t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach((e=>{const i=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=e=>{const t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;const i=new Event("connectionstatechange",e);t.dispatchEvent(i)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),i.apply(this,arguments)}}))}function Db(e,t){if(!e.RTCPeerConnection)return;if("chrome"===t.browser&&t.version>=71)return;if("safari"===t.browser&&t.version>=605)return;const i=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){const i=t.sdp.split("\n").filter((e=>"a=extmap-allow-mixed"!==e.trim())).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:i}):t.sdp=i}return i.apply(this,arguments)}}function Ob(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const i=e.RTCPeerConnection.prototype.addIceCandidate;i&&0!==i.length&&(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():i.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}function Lb(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const i=e.RTCPeerConnection.prototype.setLocalDescription;i&&0!==i.length&&(e.RTCPeerConnection.prototype.setLocalDescription=function(){let e=arguments[0]||{};if("object"!=typeof e||e.type&&e.sdp)return i.apply(this,arguments);if(e={type:e.type,sdp:e.sdp},!e.type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":e.type="offer";break;default:e.type="answer"}return e.sdp||"offer"!==e.type&&"answer"!==e.type?i.apply(this,[e]):("offer"===e.type?this.createOffer:this.createAnswer).apply(this).then((e=>i.apply(this,[e])))})}var Pb=Object.freeze({__proto__:null,shimRTCIceCandidate:bb,shimRTCIceCandidateRelayProtocol:Cb,shimMaxMessageSize:kb,shimSendThrowTypeError:wb,shimConnectionState:Nb,removeExtmapAllowMixed:Db,shimAddIceCandidateNullOrEmpty:Ob,shimParameterlessSetLocalDescription:Lb});!function({window:e}={},t={shimChrome:!0,shimFirefox:!0,shimSafari:!0}){const i=VR,r=function(e){const t={browser:null,version:null};if(void 0===e||!e.navigator||!e.navigator.userAgent)return t.browser="Not a browser.",t;const{navigator:i}=e;if(i.mozGetUserMedia)t.browser="firefox",t.version=LR(i.userAgent,/Firefox\/(\d+)\./,1);else if(i.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection)t.browser="chrome",t.version=LR(i.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!e.RTCPeerConnection||!i.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=LR(i.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}(e),n={browserDetails:r,commonShim:Pb,extractVersion:LR,disableLog:MR,disableWarnings:xR,sdp:Rb};switch(r.browser){case"chrome":if(!eb||!ZR||!t.shimChrome)return i("Chrome shim is not included in this adapter release."),n;if(null===r.version)return i("Chrome shim can not determine version, not shimming."),n;i("adapter.js shimming chrome."),n.browserShim=eb,Ob(e,r),Lb(e),zR(e,r),GR(e),ZR(e,r),KR(e),QR(e,r),YR(e),JR(e),qR(e),$R(e,r),bb(e),Cb(e),Nb(e),kb(e,r),wb(e),Db(e,r);break;case"firefox":if(!hb||!rb||!t.shimFirefox)return i("Firefox shim is not included in this adapter release."),n;i("adapter.js shimming firefox."),n.browserShim=hb,Ob(e,r),Lb(e),tb(e,r),rb(e,r),ib(e),sb(e),nb(e),ob(e),ab(e),cb(e),lb(e),db(e),ub(e),bb(e),Nb(e),kb(e,r),wb(e);break;case"safari":if(!Sb||!t.shimSafari)return i("Safari shim is not included in this adapter release."),n;i("adapter.js shimming safari."),n.browserShim=Sb,Ob(e,r),Lb(e),Eb(e),yb(e),_b(e),pb(e),mb(e),vb(e),fb(e),Tb(e),bb(e),Cb(e),kb(e,r),wb(e),Db(e,r);break;default:i("Unsupported browser!")}}({window:"undefined"==typeof window?void 0:window});var Mb,xb=Object.create,Vb=Object.defineProperty,Ub=Object.defineProperties,Bb=Object.getOwnPropertyDescriptor,Fb=Object.getOwnPropertyDescriptors,Hb=Object.getOwnPropertyNames,jb=Object.getOwnPropertySymbols,Wb=Object.getPrototypeOf,zb=Object.prototype.hasOwnProperty,Gb=Object.prototype.propertyIsEnumerable,Kb=Reflect.get,Yb=Math.pow,Jb=(e,t,i)=>t in e?Vb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,qb=(e,t)=>{for(var i in t||(t={}))zb.call(t,i)&&Jb(e,i,t[i]);if(jb)for(var i of jb(t))Gb.call(t,i)&&Jb(e,i,t[i]);return e},Xb=(e,t)=>Ub(e,Fb(t)),Qb=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Zb=(e,t)=>{for(var i in t)Vb(e,i,{get:t[i],enumerable:!0})},$b=(e,t,i)=>(i=null!=e?xb(Wb(e)):{},((e,t,i,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let n of Hb(t))!zb.call(e,n)&&n!==i&&Vb(e,n,{get:()=>t[n],enumerable:!(r=Bb(t,n))||r.enumerable});return e})(!t&&e&&e.__esModule?i:Vb(i,"default",{value:e,enumerable:!0}),e)),eC=(e,t,i,r)=>{for(var n,o=r>1?void 0:r?Bb(t,i):t,s=e.length-1;s>=0;s--)(n=e[s])&&(o=(r?n(t,i,o):n(o))||o);return r&&o&&Vb(t,i,o),o},tC=(e,t,i)=>(Jb(e,"symbol"!=typeof t?t+"":t,i),i),iC=(e,t,i)=>Kb(Wb(e),i,t),rC=(e,t,i)=>new Promise(((r,n)=>{var o=e=>{try{a(i.next(e))}catch(t){n(t)}},s=e=>{try{a(i.throw(e))}catch(t){n(t)}},a=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,s);a((i=i.apply(e,t)).next())})),nC=Qb(((e,t)=>{var i=Object.prototype.hasOwnProperty,r="~";function n(){}function o(e,t,i){this.fn=e,this.context=t,this.once=i||!1}function s(e,t,i,n,s){if("function"!=typeof i)throw new TypeError("The listener must be a function");var a=new o(i,n||e,s),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function a(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function c(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),c.prototype.eventNames=function(){var e,t,n=[];if(0===this._eventsCount)return n;for(t in e=this._events)i.call(e,t)&&n.push(r?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},c.prototype.listeners=function(e){var t=r?r+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,o=i.length,s=new Array(o);n<o;n++)s[n]=i[n].fn;return s},c.prototype.listenerCount=function(e){var t=r?r+e:e,i=this._events[t];return i?i.fn?1:i.length:0},c.prototype.emit=function(e,t,i,n,o,s){var a=r?r+e:e;if(!this._events[a])return!1;var c,l,d=this._events[a],u=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),u){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,i),!0;case 4:return d.fn.call(d.context,t,i,n),!0;case 5:return d.fn.call(d.context,t,i,n,o),!0;case 6:return d.fn.call(d.context,t,i,n,o,s),!0}for(l=1,c=new Array(u-1);l<u;l++)c[l-1]=arguments[l];d.fn.apply(d.context,c)}else{var h,p=d.length;for(l=0;l<p;l++)switch(d[l].once&&this.removeListener(e,d[l].fn,void 0,!0),u){case 1:d[l].fn.call(d[l].context);break;case 2:d[l].fn.call(d[l].context,t);break;case 3:d[l].fn.call(d[l].context,t,i);break;case 4:d[l].fn.call(d[l].context,t,i,n);break;default:if(!c)for(h=1,c=new Array(u-1);h<u;h++)c[h-1]=arguments[h];d[l].fn.apply(d[l].context,c)}}return!0},c.prototype.on=function(e,t,i){return s(this,e,t,i,!1)},c.prototype.once=function(e,t,i){return s(this,e,t,i,!0)},c.prototype.removeListener=function(e,t,i,n){var o=r?r+e:e;if(!this._events[o])return this;if(!t)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn===t&&(!n||s.once)&&(!i||s.context===i)&&a(this,o);else{for(var c=0,l=[],d=s.length;c<d;c++)(s[c].fn!==t||n&&!s[c].once||i&&s[c].context!==i)&&l.push(s[c]);l.length?this._events[o]=1===l.length?l[0]:l:a(this,o)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&a(this,t)):(this._events=new n,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,void 0!==t&&(t.exports=c)})),oC=Qb(((e,t)=>{var i=t.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),(t+=null!=e["network-id"]?" network-id %d":"%v")+(null!=e["network-cost"]?" network-cost %d":"%v")}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",(t+=null!=e.rateNumerator?" rate=%s":"")+(null!=e.rateDenominator?"/%s":"")}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(i).forEach((function(e){i[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))}))})),sC=Qb((e=>{var t=function(e){return String(Number(e))===e?Number(e):e},i=function(e,i,r){var n=e.name&&e.names;e.push&&!i[e.push]?i[e.push]=[]:n&&!i[e.name]&&(i[e.name]={});var o=e.push?{}:n?i[e.name]:i;(function(e,i,r,n){if(n&&!r)i[n]=t(e[1]);else for(var o=0;o<r.length;o+=1)null!=e[o+1]&&(i[r[o]]=t(e[o+1]))})(r.match(e.reg),o,e.names,e.name),e.push&&i[e.push].push(o)},r=oC(),n=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},o=[],s=t;return e.split(/(\r\n|\r|\n)/).filter(n).forEach((function(e){var t=e[0],n=e.slice(2);"m"===t&&(o.push({rtp:[],fmtp:[]}),s=o[o.length-1]);for(var a=0;a<(r[t]||[]).length;a+=1){var c=r[t][a];if(c.reg.test(n))return i(c,s,n)}})),t.media=o,t};var o=function(e,i){var r=i.split(/=(.+)/,2);return 2===r.length?e[r[0]]=t(r[1]):1===r.length&&i.length>1&&(e[r[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return e.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(e){for(var i=[],r=e.split(" ").map(t),n=0;n<r.length;n+=3)i.push({component:r[n],ip:r[n+1],port:r[n+2]});return i},e.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(o,{})}))},e.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var i,r=!1;return"~"!==e[0]?i=t(e):(i=t(e.substring(1,e.length)),r=!0),{scid:i,paused:r}}))}))}})),aC=Qb(((e,t)=>{var i=oC(),r=/%[sdv%]/g,n=function(e){var t=1,i=arguments,n=i.length;return e.replace(r,(function(e){if(t>=n)return e;var r=i[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(r);case"%d":return Number(r);case"%v":return""}}))},o=function(e,t,i){var r=[e+"="+(t.format instanceof Function?t.format(t.push?i:i[t.name]):t.format)];if(t.names)for(var o=0;o<t.names.length;o+=1){var s=t.names[o];t.name?r.push(i[t.name][s]):r.push(i[t.names[o]])}else r.push(i[t.name]);return n.apply(null,r)},s=["v","o","s","i","u","e","p","c","b","t","r","z","a"],a=["i","c","b","a"];t.exports=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach((function(e){null==e.payloads&&(e.payloads="")}));var r=t.outerOrder||s,n=t.innerOrder||a,c=[];return r.forEach((function(t){i[t].forEach((function(i){i.name in e&&null!=e[i.name]?c.push(o(t,i,e)):i.push in e&&null!=e[i.push]&&e[i.push].forEach((function(e){c.push(o(t,i,e))}))}))})),e.media.forEach((function(e){c.push(o("m",i.m[0],e)),n.forEach((function(t){i[t].forEach((function(i){i.name in e&&null!=e[i.name]?c.push(o(t,i,e)):i.push in e&&null!=e[i.push]&&e[i.push].forEach((function(e){c.push(o(t,i,e))}))}))}))})),c.join("\r\n")+"\r\n"}})),cC=Qb((e=>{var t=sC(),i=aC();e.write=i,e.parse=t.parse,e.parseParams=t.parseParams,e.parseFmtpConfig=t.parseFmtpConfig,e.parsePayloads=t.parsePayloads,e.parseRemoteCandidates=t.parseRemoteCandidates,e.parseImageAttributes=t.parseImageAttributes,e.parseSimulcastStreamList=t.parseSimulcastStreamList})),lC=Qb(((e,t)=>{var i=t.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),(t+=null!=e["network-id"]?" network-id %d":"%v")+(null!=e["network-cost"]?" network-cost %d":"%v")}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",(t+=null!=e.rateNumerator?" rate=%s":"")+(null!=e.rateDenominator?"/%s":"")}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(i).forEach((function(e){i[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))}))})),dC=Qb((e=>{var t=function(e){return String(Number(e))===e?Number(e):e},i=function(e,i,r){var n=e.name&&e.names;e.push&&!i[e.push]?i[e.push]=[]:n&&!i[e.name]&&(i[e.name]={});var o=e.push?{}:n?i[e.name]:i;(function(e,i,r,n){if(n&&!r)i[n]=t(e[1]);else for(var o=0;o<r.length;o+=1)null!=e[o+1]&&(i[r[o]]=t(e[o+1]))})(r.match(e.reg),o,e.names,e.name),e.push&&i[e.push].push(o)},r=lC(),n=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},o=[],s=t;return e.split(/(\r\n|\r|\n)/).filter(n).forEach((function(e){var t=e[0],n=e.slice(2);"m"===t&&(o.push({rtp:[],fmtp:[]}),s=o[o.length-1]);for(var a=0;a<(r[t]||[]).length;a+=1){var c=r[t][a];if(c.reg.test(n))return i(c,s,n)}})),t.media=o,t};var o=function(e,i){var r=i.split(/=(.+)/,2);return 2===r.length?e[r[0]]=t(r[1]):1===r.length&&i.length>1&&(e[r[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return e.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(e){for(var i=[],r=e.split(" ").map(t),n=0;n<r.length;n+=3)i.push({component:r[n],ip:r[n+1],port:r[n+2]});return i},e.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(o,{})}))},e.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var i,r=!1;return"~"!==e[0]?i=t(e):(i=t(e.substring(1,e.length)),r=!0),{scid:i,paused:r}}))}))}})),uC=Qb(((e,t)=>{var i=lC(),r=/%[sdv%]/g,n=function(e){var t=1,i=arguments,n=i.length;return e.replace(r,(function(e){if(t>=n)return e;var r=i[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(r);case"%d":return Number(r);case"%v":return""}}))},o=function(e,t,i){var r=[e+"="+(t.format instanceof Function?t.format(t.push?i:i[t.name]):t.format)];if(t.names)for(var o=0;o<t.names.length;o+=1){var s=t.names[o];t.name?r.push(i[t.name][s]):r.push(i[t.names[o]])}else r.push(i[t.name]);return n.apply(null,r)},s=["v","o","s","i","u","e","p","c","b","t","r","z","a"],a=["i","c","b","a"];t.exports=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach((function(e){null==e.payloads&&(e.payloads="")}));var r=t.outerOrder||s,n=t.innerOrder||a,c=[];return r.forEach((function(t){i[t].forEach((function(i){i.name in e&&null!=e[i.name]?c.push(o(t,i,e)):i.push in e&&null!=e[i.push]&&e[i.push].forEach((function(e){c.push(o(t,i,e))}))}))})),e.media.forEach((function(e){c.push(o("m",i.m[0],e)),n.forEach((function(t){i[t].forEach((function(i){i.name in e&&null!=e[i.name]?c.push(o(t,i,e)):i.push in e&&null!=e[i.push]&&e[i.push].forEach((function(e){c.push(o(t,i,e))}))}))}))})),c.join("\r\n")+"\r\n"}})),hC=Qb((e=>{var t=dC(),i=uC();e.write=i,e.parse=t.parse,e.parseParams=t.parseParams,e.parseFmtpConfig=t.parseFmtpConfig,e.parsePayloads=t.parsePayloads,e.parseRemoteCandidates=t.parseRemoteCandidates,e.parseImageAttributes=t.parseImageAttributes,e.parseSimulcastStreamList=t.parseSimulcastStreamList})),pC=$b(nC()),mC=((Mb=mC||{})[Mb.INVALID_PARAMETER=4096]="INVALID_PARAMETER",Mb[Mb.INVALID_OPERATION=4097]="INVALID_OPERATION",Mb[Mb.NOT_SUPPORTED=4098]="NOT_SUPPORTED",Mb[Mb.DEVICE_NOT_FOUND=4099]="DEVICE_NOT_FOUND",Mb[Mb.INITIALIZE_FAILED=4100]="INITIALIZE_FAILED",Mb[Mb.SIGNAL_CHANNEL_SETUP_FAILED=16385]="SIGNAL_CHANNEL_SETUP_FAILED",Mb[Mb.SIGNAL_CHANNEL_ERROR=16386]="SIGNAL_CHANNEL_ERROR",Mb[Mb.ICE_TRANSPORT_ERROR=16387]="ICE_TRANSPORT_ERROR",Mb[Mb.JOIN_ROOM_FAILED=16388]="JOIN_ROOM_FAILED",Mb[Mb.CREATE_OFFER_FAILED=16389]="CREATE_OFFER_FAILED",Mb[Mb.SIGNAL_CHANNEL_RECONNECTION_FAILED=16390]="SIGNAL_CHANNEL_RECONNECTION_FAILED",Mb[Mb.UPLINK_RECONNECTION_FAILED=16391]="UPLINK_RECONNECTION_FAILED",Mb[Mb.DOWNLINK_RECONNECTION_FAILED=16392]="DOWNLINK_RECONNECTION_FAILED",Mb[Mb.REMOTE_STREAM_NOT_EXIST=16400]="REMOTE_STREAM_NOT_EXIST",Mb[Mb.CLIENT_BANNED=16448]="CLIENT_BANNED",Mb[Mb.SERVER_TIMEOUT=16449]="SERVER_TIMEOUT",Mb[Mb.SUBSCRIPTION_TIMEOUT=16450]="SUBSCRIPTION_TIMEOUT",Mb[Mb.PLAY_NOT_ALLOWED=16451]="PLAY_NOT_ALLOWED",Mb[Mb.DEVICE_AUTO_RECOVER_FAILED=16452]="DEVICE_AUTO_RECOVER_FAILED",Mb[Mb.START_PUBLISH_CDN_FAILED=16453]="START_PUBLISH_CDN_FAILED",Mb[Mb.STOP_PUBLISH_CDN_FAILED=16454]="STOP_PUBLISH_CDN_FAILED",Mb[Mb.START_MIX_TRANSCODE_FAILED=16455]="START_MIX_TRANSCODE_FAILED",Mb[Mb.STOP_MIX_TRANSCODE_FAILED=16456]="STOP_MIX_TRANSCODE_FAILED",Mb[Mb.NOT_SUPPORTED_H264=16457]="NOT_SUPPORTED_H264",Mb[Mb.SWITCH_ROLE_FAILED=16458]="SWITCH_ROLE_FAILED",Mb[Mb.API_CALL_TIMEOUT=16459]="API_CALL_TIMEOUT",Mb[Mb.SCHEDULE_FAILED=16460]="SCHEDULE_FAILED",Mb[Mb.API_CALL_ABORTED=16461]="API_CALL_ABORTED",Mb[Mb.UNKNOWN=65535]="UNKNOWN",Mb),_C=mC,fC=class extends Error{constructor(e){let{name:t="RtcError",message:i,code:r=_C.UNKNOWN,extraCode:n=0,constraint:o}=e,s="<".concat(function(e){for(let t in _C)if(_C[t]===e)return t;return"UNKNOWN"}(r)," 0x").concat(r.toString(16),">"),a="".concat(i).concat(o?" constraint: ".concat(o):"").concat(null!=i&&i.includes(s)?"":" ".concat(s));super(a),tC(this,"code"),tC(this,"extraCode"),tC(this,"message"),tC(this,"originMessage"),tC(this,"name"),tC(this,"constraint"),this.code=r,this.extraCode=n,this.name=t,this.message=a,this.constraint=o,this.originMessage=i}getCode(){return this.code}getExtraCode(){return this.extraCode}toString(){return this.originMessage}},gC=((new Date).getTime(),0),EC=function(){return(new Date).getTime()+gC},vC=function(){let e=new Date;return e.setTime(EC()),e.toLocaleString()},yC={};Zb(yC,{bytes2ms:()=>yD,convertObjectNumberToInt:()=>hO,copyProperties:()=>vD,deepClone:()=>eO,deepMerge:()=>$D,env:()=>TC,fibonacci:()=>CD,formatedTime:()=>nO,getAbilityConfigUrl:()=>nD,getConstructorName:()=>HD,getContainerFromElement:()=>iO,getEnv:()=>cD,getInternalVersion:()=>KD,getLoggerUrl:()=>dD,getMuteStateFromFlag:()=>qD,getNetworkQuality:()=>XD,getNetworkType:()=>mD,getNumNetworkType:()=>gD,getOSType:()=>hD,getReconnectionTimeout:()=>kD,getStringByteLength:()=>aO,getSysInfo:()=>ED,getTerminalType:()=>uD,getTurnServer:()=>QD,getUint32Version:()=>uO,getValueType:()=>wD,getViewListFromView:()=>tO,glog:()=>AD,ipv4ToUint32:()=>ZD,isArray:()=>xD,isAudioWorkletSupported:()=>jD,isBoolean:()=>PD,isConstructor:()=>FD,isEmpty:()=>JD,isFunction:()=>ND,isLangChinese:()=>RD,isMediaStreamTrack:()=>VD,isNumber:()=>LD,isObject:()=>MD,isOverseaSdkAppId:()=>lD,isPlainObject:()=>bD,isPortrait:()=>lO,isPromise:()=>BD,isRemoteTrack:()=>UD,isString:()=>OD,isUndefined:()=>DD,loadImage:()=>dO,logVisibilityState:()=>cO,ms2bytes:()=>SD,ms2samples:()=>ID,performanceNow:()=>zD,promiseAny:()=>WD,samples2ms:()=>TD,setNetworkType:()=>fD,stringify:()=>oO,stringifyIncludeValue:()=>sO});var TC={};Zb(TC,{ANDROID_VERSION:()=>xC,CHROME_MAJOR_VERSION:()=>Vk,CHROME_VERSION:()=>Uk,EDGE_VERSION:()=>WC,EDG_MAJOR_VERSION:()=>KC,EDG_VERSION:()=>GC,FIREFOX_MAJOR_VERSION:()=>HC,FIREFOX_VERSION:()=>FC,HUAWEI_VERSION:()=>bk,IE_VERSION:()=>rk,IOS_MAIN_VERSION:()=>zk,IOS_VERSION:()=>Wk,IPADQQB_VERSION:()=>mk,IS_ANDROID:()=>MC,IS_ANDROID_WEBVIEW:()=>jk,IS_ANY_SAFARI:()=>Fk,IS_CHROME:()=>Mk,IS_CHROME_OS:()=>Ek,IS_CHROMIUM_BASE:()=>Pk,IS_EDG:()=>zC,IS_EDGE:()=>jC,IS_ELECTRON:()=>Tk,IS_FIREFOX:()=>BC,IS_HEADLESS_CHROME:()=>xk,IS_HUAWEI:()=>Rk,IS_HUAWEIBROWSER:()=>Ak,IS_IE:()=>ik,IS_IE8:()=>tk,IS_IOS:()=>PC,IS_IOS_13_OR_14:()=>Yk,IS_IOS_15_1:()=>Kk,IS_IPAD:()=>NC,IS_IPADQQB:()=>pk,IS_IPAD_PRO:()=>DC,IS_IPHONE:()=>OC,IS_IPOD:()=>LC,IS_LINUX:()=>gk,IS_LOCAL:()=>Jk,IS_MAC:()=>fk,IS_MACQQB:()=>uk,IS_MIBROWSER:()=>Sk,IS_MQQB:()=>ak,IS_NATIVE_ANDROID:()=>UC,IS_OLD_ANDROID:()=>VC,IS_OPPOBROWSER:()=>wk,IS_SAFARI:()=>Bk,IS_SAFARI_15_1:()=>Gk,IS_SAMSUNGBROWSER:()=>Ck,IS_SOGOU:()=>qC,IS_SOGOUM:()=>YC,IS_TBS:()=>QC,IS_UCBROWSER:()=>yk,IS_VIVOBROWSER:()=>Dk,IS_WECHAT:()=>nk,IS_WIN:()=>_k,IS_WQQB:()=>lk,IS_WX:()=>vk,IS_X5MQQB:()=>sk,IS_XWEB:()=>$C,MACQQB_VERSION:()=>hk,MI_VERSION:()=>Ik,MQQB_VERSION:()=>ck,OPPO_VERSION:()=>Nk,SAFARI_VERSION:()=>Hk,SAMSUNG_VERSION:()=>kk,SOGOUM_VERSION:()=>JC,SOGOU_VERSION:()=>XC,TBS_VERSION:()=>ZC,USER_AGENT:()=>AC,VIVO_VERSION:()=>Ok,WECHAT_VERSION:()=>ok,WQQB_VERSION:()=>dk,XWEB_VERSION:()=>ek,browserInfo:()=>Xk,getBrowserInfo:()=>Qk,getChromeMajorVersion:()=>Lk,getOSName:()=>tw,getOSString:()=>iw,getUserAgentData:()=>$k,isFunction:()=>SC,isLocalStorageEnabled:()=>qk,isUndefined:()=>IC});var SC=e=>"function"==typeof e,IC=e=>void 0===e,AC="undefined"==typeof navigator?"":navigator.userAgent,RC=e=>new RegExp(e,"i").test(AC),bC=e=>{if(RC(e)){let t=new RegExp("".concat(e,"\\/([\\d.]+)")),i=AC.match(t);if(i&&i[1])return i[1]}return""},CC=e=>{if(RC(e)){let t=new RegExp("".concat(e,"\\/(\\d+)")),i=AC.match(t);if(i&&i[1])return parseFloat(i[1])}return NaN},kC=/AppleWebKit\/([\d.]+)/i.exec(AC),wC=kC?parseFloat(kC[1]):NaN,NC=RC("iPad"),DC="undefined"!=typeof navigator&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&RC("Macintosh"),OC=RC("iPhone")&&!NC,LC=RC("iPod"),PC=OC||NC||LC||DC,MC=RC("Android"),xC=function(){if(MC){let e=AC.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(e){let t=e[1]&&parseFloat(e[1]),i=e[2]&&parseFloat(e[2]);if(t&&i)return parseFloat("".concat(e[1],".").concat(e[2]));if(t)return t}}return NaN}(),VC=MC&&RC("webkit")&&xC<2.3,UC=MC&&xC<5&&wC<537,BC=RC("Firefox"),FC=bC("Firefox"),HC=CC("Firefox"),jC=RC("Edge"),WC=bC("Edge"),zC=RC("Edg"),GC=bC("Edg"),KC=CC("Edg"),YC=RC("SogouMobileBrowser"),JC=bC("SogouMobileBrowser"),qC=RC("MetaSr\\s"),XC=bC("MetaSr\\s"),QC=RC("TBS"),ZC=bC("TBS"),$C=RC("XWEB"),ek=bC("XWEB"),tk=RC("MSIE\\s8\\.0"),ik=RC("MSIE\\/\\d+"),rk=function(){if(ik){let e=/MSIE\s(\d+)\.\d/.exec(AC),t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(AC)&&/rv:11.0/.test(AC)&&(t=11),t}return NaN}(),nk=RC("(micromessenger|webbrowser)"),ok=bC("MicroMessenger"),sk=!QC&&RC("MQQBrowser")&&RC("COVC"),ak=!QC&&RC("MQQBrowser")&&!RC("COVC"),ck=ak||sk?bC("MQQBrowser"):"",lk=!QC&&RC(" QQBrowser"),dk=bC(" QQBrowser"),uk=!QC&&RC("QQBrowserLite"),hk=bC("QQBrowserLite"),pk=!QC&&RC("MQBHD"),mk=bC("MQBHD"),_k=RC("Windows"),fk=!PC&&RC("MAC OS X"),gk=!MC&&RC("Linux"),Ek=RC("CrOS"),vk=RC("MicroMessenger"),yk=RC("UCBrowser"),Tk=RC("Electron"),Sk=RC("MiuiBrowser"),Ik=bC("MiuiBrowser"),Ak=RC("HuaweiBrowser"),Rk=RC("Huawei"),bk=bC("HuaweiBrowser"),Ck=RC("SamsungBrowser"),kk=bC("SamsungBrowser"),wk=RC("HeyTapBrowser"),Nk=bC("HeyTapBrowser"),Dk=RC("VivoBrowser"),Ok=bC("VivoBrowser"),Lk=()=>CC("Chrome"),Pk=RC("Chrome"),Mk=!jC&&!qC&&!YC&&!QC&&!$C&&!zC&&!lk&&!Sk&&!Ak&&!Ck&&!wk&&!Dk&&Pk,xk=RC("HeadlessChrome"),Vk=Lk(),Uk=bC("Chrome"),Bk=!Pk&&!ak&&!sk&&!uk&&!pk&&RC("Safari"),Fk=Bk||PC,Hk=bC("Version"),jk=/Android.*(wv|.0.0.0)/.test(AC),Wk=(()=>{if(DC)return Hk;if(PC){let e=AC.match(/OS (\d+)_(\d+)/i);if(e&&e[1]){let t=e[1];return e[2]&&(t+=".".concat(e[2])),t}}return""})(),zk=Number(Wk.split(".")[0]),Gk="15.1"===Hk,Kk="15.1"===Wk,Yk=(()=>{let e=Number(Wk.split(".")[0]);return 14===e||13===e})(),Jk="undefined"!=typeof location&&("file:"===location.protocol||"localhost"===location.hostname||"127.0.0.1"===location.hostname),qk=(()=>{let e;return()=>{if(IC(e))try{e=!!window.localStorage}catch(t){e=!1}return e}})(),Xk=Qk();function Qk(){let e=new Map([[BC,["Firefox",FC]],[zC,["Edg",GC]],[Mk,["Chrome",Uk]],[Bk,["Safari",Hk]],[QC,["TBS",ZC]],[$C,["XWEB",ek]],[nk&&OC,["WeChat",ok]],[lk,["QQ(Win)",dk]],[ak,["QQ(Mobile)",ck]],[sk,["QQ(Mobile X5)",ck]],[uk,["QQ(Mac)",hk]],[pk,["QQ(iPad)",mk]],[Sk,["MI",Ik]],[Ak,["HW",bk]],[Ck,["Samsung",kk]],[wk,["OPPO",Nk]],[Dk,["VIVO",Ok]],[jC,["EDGE",WC]],[YC,["SogouMobile",JC]],[qC,["Sogou",XC]]]),t="unknown",i="unknown";return e.has(!0)&&([t,i]=e.get(!0)),{name:t,version:i}}var Zk=null;function $k(){return rC(this,null,(function*(){if(Zk)return Zk;if(!navigator.userAgentData||!SC(navigator.userAgentData.getHighEntropyValues))return null;try{return Zk=yield navigator.userAgentData.getHighEntropyValues(["architecture","bitness","model","platformVersion","fullVersionList"])}catch(e){return null}}))}var ew=new Map([[MC,"Android"],[PC,"iOS"],[_k,"Windows"],[fk,"MacOS"],[gk,"Linux"],[Ek,"ChromeOS"]]),tw=function(){return ew.get(!0)?ew.get(!0):Zk?Zk.platform:"unknown"},iw=()=>{let e=tw();return e+="/".concat(Xk.name,"/").concat(Bk?Xk.version:Xk.version.split(".")[0]),null!=Zk&&Zk.platformVersion&&(e+="/".concat(Zk.platformVersion)),null!=Zk&&Zk.architecture&&(e+="/".concat(Zk.architecture)),e},rw={};Zb(rw,{AUDIO_MUTE_BIT:()=>Ww,AUDIO_STAT_BIT:()=>jw,AUX_STAT_BIT:()=>Hw,AUX_STREAM_MSID:()=>Kw,BACKEND_ENV:()=>Vw,BASE_DOC_URL:()=>vw,BASE_HOST:()=>_w,CAPABILITIES_KEYS:()=>VN,CLASS_NAME:()=>AN,CLOUD_CONSOLE_URL:()=>Ew,DATA_FREEZE_TIMING:()=>gN,DOC_URL:()=>yw,DTLS_STATE_UNKNOWN:()=>iN,ENV_NAME:()=>Rw,EXCHANGE_SDP_TIMEOUT:()=>hN,INTERVAL:()=>MN,IS_WORKER:()=>dw,IS_WORKLET:()=>uw,KIBANA_EVENT:()=>lN,LOCAL_STREAM_PUBLISH_STATE:()=>fN,LOGGER_CMD_TYPE:()=>Aw,LOGGER_DOMAIN:()=>Tw,LOGGER_DOMAIN_OVERSEA:()=>Sw,LOG_LEVEL:()=>bw,LOG_LEVEL_NAME:()=>wN,MAIN_STREAM_MSID:()=>Gw,MICROPHONE_COMMUNICATIONS:()=>kN,MICROPHONE_DEFAULT:()=>bN,NAME:()=>Mw,NETWORK_TYPE:()=>ww,NOT_SUPPORTED_H264:()=>_N,PAUSED_RETRY_COUNT:()=>RN,PEERCONNECTION_CONNECTING_TIMEOUT:()=>TN,PEER_CONNECTION_STATE:()=>rN,PEER_LEAVE_REASON:()=>NN,RAF:()=>PN,RECOVER_CAPTURE_INTERVAL:()=>ON,REMOTE_STREAM_TYPE_AUX:()=>Jw,REMOTE_STREAM_TYPE_MAIN:()=>Yw,RENDER_FREEZE_TIMING:()=>EN,RIC:()=>LN,SCHEDULE_DOMAIN:()=>SN,SCHEDULE_TIMEOUT:()=>IN,SDP_SEMANTICS_PLAN_B:()=>mN,SDP_SEMANTICS_UNIFIED_PLAN:()=>pN,SECOND_HOST:()=>fw,SIGNAL_PING_PONG_INTERVAL:()=>kw,SIGNAL_PING_TIMEOUT:()=>Cw,SIGNAL_RECONNECTION_COUNT:()=>cN,SMALL_STAT_BIT:()=>Fw,SPEAKER_DEFAULT:()=>CN,STORAGE_EXPIRES_TIME:()=>Nw,STREAM_TYPE_BIG:()=>vN,STREAM_TYPE_SMALL:()=>yN,SUBSCRIBE_SMALL_RETRY_COUNT:()=>DN,SYNC_USER_LIST_INTERVAL:()=>dN,Scene:()=>Uw,Switch:()=>Dw,THIRD_HOST:()=>gw,TIMEOUT:()=>xN,TRANSPORT_DIRECTION:()=>xw,TRTC_ERROR_ASSISTANCE:()=>Iw,TRTC_QUALITY_BAD:()=>$w,TRTC_QUALITY_DISCONNECTED:()=>tN,TRTC_QUALITY_EXCELLENT:()=>Xw,TRTC_QUALITY_GOOD:()=>Qw,TRTC_QUALITY_POOR:()=>Zw,TRTC_QUALITY_UNKNOWN:()=>qw,TRTC_QUALITY_VERY_BAD:()=>eN,UPDATE_OFFER_TIMEOUT:()=>uN,VIDEO_MUTE_BIT:()=>zw,VIDEO_STAT_BIT:()=>Bw,audioProfileMap:()=>Ow,getRetryCount:()=>sN,getScriptDir:()=>hw,innerVersion:()=>nw,loggerProxy:()=>pw,screenProfileMap:()=>Pw,setLoggerProxy:()=>mw,setRetryCount:()=>oN,setVersion:()=>sw,version:()=>ow,videoProfileMap:()=>Lw});var nw="4.15.00.1600",ow="5.0.0";function sw(e){ow=e;let[t,i,r]=e.split(".").map((e=>parseInt(e,10)));nw="".concat(t,".").concat(Math.min(15,i),".").concat(Math.min(15,r),".").concat(i.toString().padStart(2,"0")).concat(r.toString().padStart(2,"0"))}var aw,cw,lw,dw="undefined"!=typeof importScripts,uw="undefined"!=typeof registerProcessor,hw=()=>{let e=dw?self.location.href:document.currentScript.src;return e.substring(0,e.lastIndexOf("/")+1)},pw="",mw=e=>pw=e,_w="web.sdk.qcloud.com",fw="web.sdk.tencent.cn",gw="web.sdk.cloud.tencent.cn",Ew="https://console.cloud.tencent.com/trtc",vw="https://".concat(_w,"/trtc/webrtc/v5/doc"),yw="".concat(vw,"/zh-cn/"),Tw="https://yun.tim.qq.com",Sw="https://apisgp.my-imcloud.com",Iw="trtc_error_assistance",Aw={LOG:"jssdk_log",EVENT:"jssdk_event",KEY_POINT:"jssdk_new_endreport",KV_STAT:"jssdk_key_metrics_report"},Rw={QCLOUD:"qcloud",OLD_CLOUD_LADDER:"trtc",WEBRTC:"webrtc"},bw=((lw=bw||{})[lw.TRACE=0]="TRACE",lw[lw.DEBUG=1]="DEBUG",lw[lw.INFO=2]="INFO",lw[lw.WARN=3]="WARN",lw[lw.ERROR=4]="ERROR",lw[lw.NONE=5]="NONE",lw),Cw=18e3,kw=2e3,ww={unknown:0,wifi:1,"3g":2,"2g":3,"4g":4,wired:5,"5g":6},Nw=6048e5,Dw=((cw=Dw||{}).USEAINS="useAINS",cw.ENABLEDEBUG="enableDebug",cw.USEV2="useV2",cw.USEWT="useWt",cw),Ow={standard:{sampleRate:48e3,channelCount:1,bitrate:40},"standard-stereo":{sampleRate:48e3,channelCount:2,bitrate:64},high:{sampleRate:48e3,channelCount:1,bitrate:192},"high-stereo":{sampleRate:48e3,channelCount:2,bitrate:192}},Lw={"120p":{width:160,height:120,frameRate:15,bitrate:200},"120p_2":{width:160,height:120,frameRate:15,bitrate:100},"180p":{width:320,height:180,frameRate:15,bitrate:350},"180p_2":{width:320,height:180,frameRate:15,bitrate:150},"240p":{width:320,height:240,frameRate:15,bitrate:400},"240p_2":{width:320,height:240,frameRate:15,bitrate:200},"360p":{width:640,height:360,frameRate:15,bitrate:800},"360p_2":{width:640,height:360,frameRate:15,bitrate:400},"480p":{width:640,height:480,frameRate:15,bitrate:900},"480p_2":{width:640,height:480,frameRate:15,bitrate:500},"720p":{width:1280,height:720,frameRate:15,bitrate:1500},"1080p":{width:1920,height:1080,frameRate:15,bitrate:2e3},"1440p":{width:2560,height:1440,frameRate:30,bitrate:4860},"4K":{width:3840,height:2160,frameRate:30,bitrate:9e3}},Pw={"480p":{width:640,height:480,frameRate:5,bitrate:900},"480p_2":{width:640,height:480,frameRate:30,bitrate:1e3},"720p":{width:1280,height:720,frameRate:5,bitrate:1200},"720p_2":{width:1280,height:720,frameRate:30,bitrate:3e3},"1080p":{width:1920,height:1080,frameRate:5,bitrate:1600},"1080p_2":{width:1920,height:1080,frameRate:30,bitrate:4e3}},Mw={CANVAS:"canvas",AUDIO:"audio",VIDEO:"video",SCREEN:"screen",SMALL:"small",BIG:"big",AUXILIARY:"auxiliary",SMALL_VIDEO:"smallVideo",FACING_MODE_USER:"user",FACING_MODE_ENVIRONMENT:"environment",MUTE:"mute",UNMUTE:"unmute",ENDED:"ended",PLAYING:"playing",PAUSE:"pause",ERROR:"error",LOADEDDATA:"loadeddata",AUDIO_INPUT:"audioinput",VIDEO_INPUT:"videoinput",DETAIL:"detail",TEXT:"text",MAIN:"main",BACKUP:"backup",BANNED:"banned",KICK:"kick",USER_TIME_OUT:"user_time_out",ROOM_DISBAND:"room_disband",SEI_MESSAGE:"sei-message",ADD:"add",REMOVE:"remove",REPLACE:"replace",TRACK:"track",SUBSCRIBE:"subscribe",UNSUBSCRIBE:"unsubscribe",TRANSCEIVER_DIRECTION_SENDONLY:"sendonly",TRANSCEIVER_DIRECTION_RECVONLY:"recvonly",ENTER_PICTURE_IN_PICTURE:"enterpictureinpicture",LEAVE_PICTURE_IN_PICTURE:"leavepictureinpicture"},xw={INACTIVE:"inactive",SENDONLY:"sendonly",RECVONLY:"recvonly"},Vw={OLD_CLOUD_LADDER:"wss://trtc.rtc.qq.com",WEBRTC:"wss://webrtc.qq.com"},Uw=((aw=Uw||{}).LIVE="live",aw.RTC="rtc",aw),Bw=1,Fw=2,Hw=4,jw=8,Ww=64,zw=16,Gw="5Y2wZK8nANNAoVw6dSAHVjNxrD1ObBM2kBPV",Kw="224d130c-7b5c-415b-aaa2-79c2eb5a6df2",Yw=Mw.MAIN,Jw=Mw.AUXILIARY,qw=0,Xw=1,Qw=2,Zw=3,$w=4,eN=5,tN=6,iN="unknown",rN={NEW:"new",CONNECTING:"connecting",FAILED:"failed",CLOSED:"closed",DISCONNECTED:"disconnected",CONNECTED:"connected",COMPLETED:"completed"},nN=1/0;function oN(e){nN=e}function sN(){return nN}var aN,cN=30,lN={JOIN:"join",DELTA_JOIN:"delta-join",REJOIN:"rejoin",LEAVE:"leave",DELTA_LEAVE:"delta-leave",PUBLISH:"publish",DELTA_PUBLISH:"delta-publish",UNPUBLISH:"unpublish",SUBSCRIBE:"subscribe",UNSUBSCRIBE:"unsubscribe",UPLINK_CONNECTION:"uplink-connection",UPLINK_RECONNECTION:"uplink-reconnection",DOWNLINK_CONNECTION:"downlink-connection",DOWNLINK_RECONNECTION:"downlink-reconnection",ON_TRACK:"ontrack",ICE_CONNECTION_STATE:"iceConnectionState",LOCAL_STREAM_INITIALIZE:"stream-initialize",SIGNAL_CONNECTION:"websocketConnectionState",SIGNAL_RECONNECTION:"websocketReconnectionState",UPDATE_STREAM:"update-stream",RECOVER_LOCAL_AUDIO_TRACK:"recover-local-audio-track",RECOVER_LOCAL_VIDEO_TRACK:"recover-local-video-track",RECOVER_SUBSCRIPTION:"recover-subscription",START_MIX_TRANSCODE:"start-mix-transcode",STOP_MIX_TRANSCODE:"stop-mix-transcode",PLAYER_ERROR:"player-error",SCHEDULE:"schedule",LOAD_WORKLET:"load-worklet",VIDEO_FROZEN_COUNT:"videoFrozenCount",GET_USER_MEDIA_RETRY:"getUserMedia-retry"},dN=1e4,uN=1e4,hN=1e4,pN="unified-plan",mN="plan-b",_N=1028,fN=((aN=fN||{})[aN.UNPUBLISH=-1]="UNPUBLISH",aN[aN.PUBLISHING=0]="PUBLISHING",aN[aN.PUBLISHED=1]="PUBLISHED",aN),gN=500,EN=1e3,vN=Mw.BIG,yN=Mw.SMALL,TN=1e4,SN={MAIN:"schedule.cloud-rtc.com",BACKUP:"schedule.rtc.qcloud.com",MAIN_OVERSEA:"schedule.rtc-web.com",BACKUP_OVERSEA:"schedule.rtc-web.io",MAIN_OVERSEA_OLD:"schedule.rtc.tencentcloud.com",BACKUP_OVERSEA_OLD:"schedule-ecdn.rtc.tencentcloud.com"},IN=2e3,AN={TRTC:"TRTC",CLIENT:"Client",LOCAL_STREAM:"LocalStream",REMOTE_STREAM:"RemoteStream",STREAM:"Stream"},RN=5,bN="default",CN=bN,kN="communications",wN=Object.keys(bw),NN=["normal leave","timeout leave","kick","role change"],DN=10,ON=2e3,LN="ric",PN="raf",MN="interval",xN="timeout",VN=["width","height","frameRate","facingMode","sampleRate","sampleSize","channelCount","deviceId","min","max"],UN=1e8;function BN(e){let{url:t,body:i,method:r,timeout:n}=e,o=new XMLHttpRequest;return new Promise(((e,s)=>{o.onreadystatechange=()=>{if(4===o.readyState)if(o.status>=200&&o.status<300)try{let t=JSON.parse(o.response);e({data:t})}catch(t){e({data:o.response})}else s({status:o.status,statusText:o.statusText||"request failed!"})},o.timeout=n||5e3,o.open(r||"POST",t,!0),o.send(i)}))}function FN(e){return rC(this,null,(function*(){let t=zD(),i=JSON.stringify(e);try{if(!CompressionStream||i.length<=2800)return i;let e=new Blob([i],{type:"application/json"}).stream().pipeThrough(new CompressionStream("gzip")),r=yield(yield(yield new Response(e)).blob()).arrayBuffer();return EO.debug("compressJSON ".concat(i.length," -> ").concat(r.byteLength," ").concat(zD()-t,"ms")),r}catch(r){return i}}))}var HN={AVOID_REPEATED_CALL:"AVOID_REPEATED_CALL",INVALID_PARAMETER_REQUIRED:"INVALID_PARAMETER_REQUIRED",INVALID_PARAMETER_TYPE:"INVALID_PARAMETER_TYPE",INVALID_PARAMETER_EMPTY:"INVALID_PARAMETER_EMPTY",INVALID_PARAMETER_INSTANCE:"INVALID_PARAMETER_INSTANCE",INVALID_PARAMETER_RANGE:"INVALID_PARAMETER_RANGE",INVALID_PARAMETER_MIN:"INVALID_PARAMETER_MIN",INVALID_PARAMETER_MAX:"INVALID_PARAMETER_MAX",INVALID_PARAMETER_STREAMTYPE:"INVALID_PARAMETER_STREAMTYPE",API_CALL_TIMEOUT:"API_CALL_TIMEOUT",SIGNAL_CHANNEL_RECONNECTION_FAILED:"SIGNAL_CHANNEL_RECONNECTION_FAILED",SIGNAL_CHANNEL_SETUP_FAILED:"SIGNAL_CHANNEL_SETUP_FAILED",ERROR_MESSAGE:"ERROR_MESSAGE",EXCHANGE_SDP_TIMEOUT:"EXCHANGE_SDP_TIMEOUT",DOWNLINK_RECONNECTION_FAILED:"DOWNLINK_RECONNECTION_FAILED",EXCHANGE_SDP_FAILED:"EXCHANGE_SDP_FAILED",UPDATE_OFFER_TIMEOUT:"UPDATE_OFFER_TIMEOUT",UPLINK_RECONNECTION_FAILED:"UPLINK_RECONNECTION_FAILED",INVALID_RECORDID:"INVALID_RECORDID",INVALID_PURE_AUDIO:"INVALID_PURE_AUDIO",INVALID_STREAMID:"INVALID_STREAMID",INVALID_USER_DEFINE_RECORDID:"INVALID_USER_DEFINE_RECORDID",INVALID_USER_DEFINE_PUSH_ARGS:"INVALID_USER_DEFINE_PUSH_ARGS",INVALID_PROXY:"INVALID_PROXY",INVALID_JOIN:"INVALID_JOIN",INVALID_ROOMID_STRING:"INVALID_ROOMID_STRING",INVALID_ROOMID_INTEGER:"INVALID_ROOMID_INTEGER",INVALID_SIGNAL_CHANNEL:"INVALID_SIGNAL_CHANNEL",JOIN_ROOM_TIMEOUT:"JOIN_ROOM_TIMEOUT",JOIN_ROOM_FAILED:"JOIN_ROOM_FAILED",REJOIN_ROOM_FAILED:"REJOIN_ROOM_FAILED",INVALID_DESTROY:"INVALID_DESTROY",INVALID_PUBLISH:"INVALID_PUBLISH",INVALID_UNPUBLISH:"INVALID_UNPUBLISH",INVALID_AUDIENCE:"INVALID_AUDIENCE",INVALID_INITIALIZE:"INVALID_INITIALIZE",INVALID_DUPLICATE_PUBLISHING:"INVALID_DUPLICATE_PUBLISHING",INVALID_SUBSCRIBE_UNDEFINED:"INVALID_SUBSCRIBE_UNDEFINED",INVALID_SUBSCRIBE_LOCAL:"INVALID_SUBSCRIBE_LOCAL",INVALID_REMOTE_STREAM:"INVALID_REMOTE_STREAM",SUBSCRIBE_FAILED:"SUBSCRIBE_FAILED",INVALID_ROLE:"INVALID_ROLE",INVALID_PARAMETER_SWITCH_ROLE:"INVALID_PARAMETER_SWITCH_ROLE",INVALID_OPERATION_SWITCH_ROLE:"INVALID_OPERATION_SWITCH_ROLE",SWITCH_ROLE_TIMEOUT:"SWITCH_ROLE_TIMEOUT",SWITCH_ROLE_FAILED:"SWITCH_ROLE_FAILED",CLIENT_BANNED:"CLIENT_BANNED",INVALID_OPERATION_START_PUBLISH_CDN:"INVALID_OPERATION_START_PUBLISH_CDN",INVALID_OPERATION_STOP_PUBLISH_CDN:"INVALID_OPERATION_STOP_PUBLISH_CDN",INVALID_STREAM_ID:"INVALID_STREAM_ID",START_PUBLISH_CDN_FAILED:"START_PUBLISH_CDN_FAILED",STOP_PUBLISH_CDN_FAILED:"STOP_PUBLISH_CDN_FAILED",START_MIX_TRANSCODE:"START_MIX_TRANSCODE",STOP_MIX_TRANSCODE:"STOP_MIX_TRANSCODE",INVALID_AUDIO_VOLUME:"INVALID_AUDIO_VOLUME",ENABLE_SMALL_STREAM_PUBLISHED:"ENABLE_SMALL_STREAM_PUBLISHED",DISABLE_SMALL_STREAM_PUBLISHED:"DISABLE_SMALL_STREAM_PUBLISHED",NOT_SUPPORTED_SMALL_STREAM:"NOT_SUPPORTED_SMALL_STREAM",INVALID_SMALL_STREAM_PROFILE:"INVALID_SMALL_STREAM_PROFILE",INVALID_PARAMETER_REMOTE_STREAM:"INVALID_PARAMETER_REMOTE_STREAM",INVALID_OPERATION_CHANGE_SMALL:"INVALID_OPERATION_CHANGE_SMALL",REMOTE_NOT_PUBLISH_SMALL_STREAM:"REMOTE_NOT_PUBLISH_SMALL_STREAM",INVALID_SWITCH_DEVICE:"INVALID_SWITCH_DEVICE",INVALID_SWITCH_DEVICE_PUBLISHING:"INVALID_SWITCH_DEVICE_PUBLISHING",INVALID_REPLACE_TRACK:"INVALID_REPLACE_TRACK",INVALID_INITIALIZE_LOCAL_STREAM:"INVALID_INITIALIZE_LOCAL_STREAM",INVALID_ADD_TRACK_REPETITIVE:"INVALID_ADD_TRACK_REPETITIVE",INVALID_ADD_TRACK_REMOVING:"INVALID_ADD_TRACK_REMOVING",INVALID_ADD_TRACK_PUBLISHING:"INVALID_ADD_TRACK_PUBLISHING",INVALID_STREAM_INITIALIZED:"INVALID_STREAM_INITIALIZED",INVALID_ADD_TRACK_NUMBER:"INVALID_ADD_TRACK_NUMBER",INVALID_REMOVE_AUDIO_TRACK:"INVALID_REMOVE_AUDIO_TRACK",INVALID_REMOVE_AUDIO_ADDING:"INVALID_REMOVE_AUDIO_ADDING",INVALID_REMOVE_AUDIO_ON:"INVALID_REMOVE_AUDIO_ON",INVALID_REMOVE_TRACK_PUBLISHING:"INVALID_REMOVE_TRACK_PUBLISHING",INVALID_REMOVE_TRACK_NOT_TRACK:"INVALID_REMOVE_TRACK_NOT_TRACK",INVALID_REMOVE_TRACK_NUMBER:"INVALID_REMOVE_TRACK_NUMBER",INVALID_REPLACE_TRACK_NO_TRACK:"INVALID_REPLACE_TRACK_NO_TRACK",REPEAT_JOIN:"REPEAT_JOIN",CLIENT_DESTROYED:"CLIENT_DESTROYED",NOT_BUG_PACKAGE:"NOT_BUG_PACKAGE",START_MIX_TRANSCODE_FAILED:"START_MIX_TRANSCODE_FAILED",STOP_MIX_TRANSCODE_FAILED:"STOP_MIX_TRANSCODE_FAILED",MIX_TRANSCODE_NOT_STARTED:"MIX_TRANSCODE_NOT_STARTED",CANNOT_LESS_THAN_ZERO:"CANNOT_LESS_THAN_ZERO",MIX_PARAMS_VIDEO_FRAMERATE:"MIX_PARAMS_VIDEO_FRAMERATE",MIX_PARAMS_VIDEO_GOP:"MIX_PARAMS_VIDEO_GOP",MIX_PARAMS_AUDIO_BITRATE:"MIX_PARAMS_AUDIO_BITRATE",MIX_PARAMS_USER_Z_ORDER:"MIX_PARAMS_USER_Z_ORDER",MIX_PARAMS_NOT_SELF:"MIX_PARAMS_NOT_SELF",MIX_PARAMS_USER_STREAM:"MIX_PARAMS_USER_STREAM",INVALID_PLAY:"INVALID_PLAY",INVALID_ELEMENT_ID:"INVALID_ELEMENT_ID",INVALID_ELEMENT_ID_TYPE:"INVALID_ELEMENT_ID_TYPE",PLAY_FAILED:"PLAY_FAILED",INVALID_USERID:"INVALID_USERID",INVALID_CREATE_STREAM_SOURCE:"INVALID_CREATE_STREAM_SOURCE",INVALID_CREATE_STREAM_SCREEN:"INVALID_CREATE_STREAM_SCREEN",INVALID_CREATE_STREAM_AUDIO:"INVALID_CREATE_STREAM_AUDIO",INVALID_CREATE_STREAM_SCREEN_AUDIO:"INVALID_CREATE_STREAM_SCREEN_AUDIO",NOT_SUPPORTED_HTTP:"NOT_SUPPORTED_HTTP",NOT_SUPPORTED_WEBRTC:"NOT_SUPPORTED_WEBRTC",NOT_SUPPORTED_PROFILE:"NOT_SUPPORTED_PROFILE",NOT_SUPPORTED_MEDIA:"NOT_SUPPORTED_MEDIA",NOT_SUPPORTED_H264ENCODE:"NOT_SUPPORTED_H264ENCODE",NOT_SUPPORTED_H264DECODE:"NOT_SUPPORTED_H264DECODE",NOT_SUPPORTED_TRACK:"NOT_SUPPORTED_TRACK",NOT_SUPPORTED_SWITCH_DEVICE:"NOT_SUPPORTED_SWITCH_DEVICE",NOT_SUPPORTED_CAPTURE:"NOT_SUPPORTED_CAPTURE",NOT_SUPPORTED_AUX:"NOT_SUPPORTED_AUX",MICROPHONE_NOT_FOUND:"MICROPHONE_NOT_FOUND",CAMERA_NOT_FOUND:"CAMERA_NOT_FOUND",SIGNAL_RESPONSE_FAILED:"SIGNAL_RESPONSE_FAILED",CATCH_HANDLER_ERROR:"CATCH_HANDLER_ERROR",API_NOT_EXIST:"API_NOT_EXIST",CONNECTION_CLOSED:"CONNECTION_CLOSED",SUBSCRIBE_ALL_FALSE:"SUBSCRIBE_ALL_FALSE",SEI_NOT_SUPPORT:"SEI_NOT_SUPPORT",SEI_DISABLED:"SEI_DISABLED",SEI_EMPTY:"SEI_EMPTY",SEI_OVERSIZE:"SEI_OVERSIZE",SEI_BEFORE_PUBLISH:"SEI_BEFORE_PUBLISH",SEI_NOT_VIDEO:"SEI_NOT_VIDEO",CALL_FREQUENCY_LIMIT:"CALL_FREQUENCY_LIMIT",CONNECTION_ABORTED:"CONNECTION_ABORTED",API_CALL_ABORTED:"API_CALL_ABORTED",DUPLICATE_AUX:"DUPLICATE_AUX"},jN={AVOID_REPEATED_CALL:e=>"previous ".concat(e.name,"() is ongoing, please avoid repeated calls."),INVALID_PARAMETER_REQUIRED(e){let{key:t,rule:i,fnName:r,value:n}=e;return"'".concat(t||i.name,"' is a required param when calling ").concat(r,"(), received: ").concat(n,".")},INVALID_PARAMETER_TYPE(e){let{key:t,rule:i,fnName:r,value:n}=e,o="".concat(t||i.name),s="";return s=Array.isArray(i.type)?i.type.join("|"):i.type,"'".concat(o,"' must be type of ").concat(s," when calling ").concat(r,"(), received type: ").concat(wD(n),".")},INVALID_PARAMETER_EMPTY(e){let{key:t,rule:i,fnName:r,value:n}=e;return"'".concat(t||i.name,"' cannot be '").concat(n,"' when calling ").concat(r,"().")},INVALID_PARAMETER_INSTANCE(e){let{key:t,rule:i,fnName:r,value:n}=e,o="".concat(t||i.name),s="".concat(i.instanceOf.name||i.instanceOf);return"'".concat(o,"' must be instanceof ").concat(s," when calling ").concat(r,"(), received type: ").concat(wD(n),".")},INVALID_PARAMETER_RANGE(e){let{key:t,rule:i,fnName:r,value:n}=e;return"'".concat(t||i.name,"' must be one of ").concat(i.values.join("|")," when calling ").concat(r,"(), received: ").concat(n,".")},INVALID_PARAMETER_MIN(e){let{key:t,rule:i,fnName:r,value:n}=e;return"the min value of ".concat(t||i.name," is ").concat(i.min,", received: ").concat(n,".")},INVALID_PARAMETER_MAX(e){let{key:t,rule:i,fnName:r,value:n}=e;return"the max value of ".concat(t||i.name," is ").concat(i.max,", received: ").concat(n,".")},API_CALL_TIMEOUT:e=>"".concat(e.commandDesc||e.command," timeout observed."),SIGNAL_CHANNEL_RECONNECTION_FAILED:"signal channel reconnection failed, please check your network.",SIGNAL_CHANNEL_SETUP_FAILED:e=>"SignalChannel setup failure: (errorCode: ".concat(e.errorCode,", errorMsg: ").concat(e.errorMsg," })."),ERROR_MESSAGE(e){let t="".concat(e.type," failed");return e.message&&(t="".concat(t,": ").concat(e.message,".")),t},EXCHANGE_SDP_TIMEOUT:"exchange sdp timeout.",DOWNLINK_RECONNECTION_FAILED:"downlink reconnection failed, please check your network and re-join room.",EXCHANGE_SDP_FAILED:e=>"exchange sdp failed ".concat(e.errMsg,"."),UPDATE_OFFER_TIMEOUT:"update offer timeout observed.",UPLINK_RECONNECTION_FAILED:"uplink reconnection failed, please check your network and publish again.",INVALID_RECORDID:"recordId must be an integer number.",INVALID_PURE_AUDIO:"pureAudioPushMode must be 1 or 2.",INVALID_STREAMID:"streamId must be a sting literal within 64 bytes, and not be empty.",INVALID_USER_DEFINE_RECORDID:"userDefineRecordId must be a sting literal contains (a-zA-Z),(0-9), underline and hyphen, within 64 bytes, and not be empty.",INVALID_USER_DEFINE_PUSH_ARGS:"userDefinePushArgs must be a sting literal within 256 bytes, and not be empty.",INVALID_PROXY:'proxy server url must start with "wss://".',INVALID_JOIN:"duplicate join() called.",INVALID_ROOMID_STRING:e=>"'".concat(e,"' must be validate string when useStringRoomId is true."),INVALID_ROOMID_INTEGER:e=>"'".concat(e,"' must be an integer between [1, 4294967294] when useStringRoomId is false."),INVALID_SIGNAL_CHANNEL:"SignalChannel is not ready yet.",JOIN_ROOM_TIMEOUT:"join room timeout.",JOIN_ROOM_FAILED(e){let{error:t,code:i}=e;return"Failed to join room - ".concat(t," code: ").concat(i)},REJOIN_ROOM_FAILED:e=>"reJoin room: ".concat(e.roomId," failed, please check your network."),INVALID_DESTROY:"please call leave() before destroy().",INVALID_PUBLISH:"please call join() before publish().",INVALID_UNPUBLISH:"stream has not been published yet.",INVALID_AUDIENCE:"no permission to publish() under live/".concat("audience",', please call switchRole("',"anchor",'") firstly before publish().'),INVALID_INITIALIZE:"cannot publish stream because stream is not initialized, is switching device, or has been closed.",INVALID_DUPLICATE_PUBLISHING:e=>"duplicate ".concat(e," stream publishing, please unpublish your prev ").concat(e," stream and then re-publish."),INVALID_SUBSCRIBE_UNDEFINED:"stream is undefined or null.",INVALID_SUBSCRIBE_LOCAL:"stream cannot be LocalStream.",INVALID_REMOTE_STREAM:"remoteStream does not exist because it has been unpublished by remote peer.",SUBSCRIBE_FAILED(e){let{message:t,userId:i,streamType:r}=e;return"failed to subscribe ".concat(i," ").concat(r," stream, reason: ").concat(t,".")},INVALID_ROLE:"switchRole can only be called in live mode.",INVALID_PARAMETER_SWITCH_ROLE:"role could only be set to a value as ".concat("anchor"," or ","audience","."),INVALID_OPERATION_SWITCH_ROLE:"please call join() before switchRole().",SWITCH_ROLE_TIMEOUT:"switchRole timeout.",SWITCH_ROLE_FAILED:e=>"switchRole failed, errCode: ".concat(e.code," errMsg: ").concat(e.message,"."),CLIENT_BANNED:e=>"client was banned because of ".concat(e.message,"."),INVALID_OPERATION_START_PUBLISH_CDN:"please call startPublishCDNStream() after join room and publish the local stream.",INVALID_OPERATION_STOP_PUBLISH_CDN:"please call startPublishCDNStream() before stopPublishCDNStream().",START_PUBLISH_CDN_FAILED:e=>"startPublishCDNStream failed, errMsg: ".concat(e.message,"."),STOP_PUBLISH_CDN_FAILED:e=>"stopPublishCDNStream failed, errMsg: ".concat(e.message,"."),INVALID_STREAM_ID:e=>"'".concat(e,"' can only consist of uppercase and lowercase english letters (a-zA-Z), numbers (0-9), hyphens and underscores."),START_MIX_TRANSCODE:"please call startMixTranscode() after join().",STOP_MIX_TRANSCODE:"please call stopMixTranscode() after startMixTranscode().",INVALID_AUDIO_VOLUME:"interval must be a number.",ENABLE_SMALL_STREAM_PUBLISHED:"Cannot enable small stream after localStream published.",DISABLE_SMALL_STREAM_PUBLISHED:"Cannot disable small stream after localStream published.",NOT_SUPPORTED_SMALL_STREAM:"your browser does not support opening small stream.",INVALID_SMALL_STREAM_PROFILE:"small stream profile is invalid.",INVALID_PARAMETER_REMOTE_STREAM:"remoteStream is invalid.",INVALID_OPERATION_CHANGE_SMALL:"cannot switch to the small stream without subscribing to the video of remoteStream.",REMOTE_NOT_PUBLISH_SMALL_STREAM:"remote peer does not publish small stream.",INVALID_SWITCH_DEVICE:"cannot switch device on current stream.",INVALID_SWITCH_DEVICE_PUBLISHING:"cannot switch device when publishing localStream.",INVALID_REPLACE_TRACK:"cannot replace track when publishing localStream.",INVALID_INITIALIZE_LOCAL_STREAM:"local stream has not initialized yet.",INVALID_ADD_TRACK_REPETITIVE:"previous addTrack is ongoing, please avoid repetitive execution.",INVALID_ADD_TRACK_REMOVING:"cannot add track when a track is removing.",INVALID_ADD_TRACK_PUBLISHING:"cannot add track when publishing localStream.",INVALID_STREAM_INITIALIZED:"your local stream haven't been initialized yet.",INVALID_ADD_TRACK_NUMBER:"a Stream has at most one audio track and one video track.",INVALID_REMOVE_AUDIO_TRACK:"remove audio track is not supported on your browser.",INVALID_REMOVE_AUDIO_ADDING:"cannot remove track when a track is adding.",INVALID_REMOVE_AUDIO_ON:"previous removeTrack is ongoing, please avoid repetitive execution.",INVALID_REMOVE_TRACK_PUBLISHING:"cannot remove track when publishing localStream.",INVALID_REMOVE_TRACK_NOT_TRACK:"localStream has not this track.",INVALID_REMOVE_TRACK_NUMBER:"remove the only video track is not supported, please use replaceTrack or muteVideo.",INVALID_REPLACE_TRACK_NO_TRACK:e=>"cannot replace ".concat(e.kind," track because stream has not ").concat(e.kind," track"),NOT_BUG_PACKAGE:"You need to buy packages, refer to tencent console.",START_MIX_TRANSCODE_FAILED:e=>"startMixTranscode failed, errMsg: ".concat(e.message,"."),STOP_MIX_TRANSCODE_FAILED:e=>"stopMixTranscode failed, errMsg: ".concat(e.message,"."),MIX_TRANSCODE_NOT_STARTED:"mixTranscode has not been started.",CANNOT_LESS_THAN_ZERO(e){let{key:t,rule:i,fnName:r,value:n}=e;return"'".concat(t||i.name,"' cannot be less than 0 when calling ").concat(r,"().")},MIX_PARAMS_VIDEO_FRAMERATE:"'config.videoFramerate' should be an integer between 0 and 30, excluding 0.",MIX_PARAMS_VIDEO_GOP:"'config.videoGOP' should be an integer between 1 and 8.",MIX_PARAMS_AUDIO_BITRATE:"'config.audioBitrate' should be an integer between 32 and 192.",MIX_PARAMS_USER_Z_ORDER:e=>"'".concat(e,"' is required and must be between 1 and 15."),MIX_PARAMS_NOT_SELF:"'config.mixUsers' must contain self.",MIX_PARAMS_USER_STREAM:"'config.videoWidth' and 'config.videoHeight' of output stream should be contain all mix stream.",INVALID_PLAY:"duplicate play() call observed, please stop() firstly.",INVALID_ELEMENT_ID:e=>{let{key:t,fnName:i}=e;return"'".concat(t,"' is not found in the document object when calling ").concat(i,"().")},INVALID_ELEMENT_ID_TYPE:e=>{let{key:t,fnName:i,type:r}=e;return"the element corresponding to '".concat(t,"' must be instanceof HTMLElement when calling ").concat(i,"(), received: ").concat(r,".")},PLAY_FAILED:e=>"".concat(e.media," play failed,browser exception: ").concat(e.error.toString()),INVALID_USERID:"userId cannot be all spaces.",INVALID_CREATE_STREAM_SOURCE:"LocalStream must be created by createStream() with either audio/video or audioSource/videoSource, but can not be mixed with audio/video and audioSource/videoSource.",INVALID_CREATE_STREAM_SCREEN:"screen/video cannot be both true.",INVALID_CREATE_STREAM_AUDIO:"audio/screenAudio cannot be both true.",INVALID_CREATE_STREAM_SCREEN_AUDIO:"when screen is true, screenAudio can be configured.",NOT_SUPPORTED_HTTP:"http protocol does not support the ability to capture microphone, camera and screen. please use https to deploy your page.",NOT_SUPPORTED_WEBRTC:"your browser or environment does not support full WebRTC capabilities.",NOT_SUPPORTED_PROFILE:"your browser does not support setVideoProfile.",NOT_SUPPORTED_MEDIA:"your browser or environment does not support navigator.mediaDevices.",NOT_SUPPORTED_H264ENCODE:"your device does not support H.264 encoding.",NOT_SUPPORTED_H264DECODE:"your device does not support H.264 decoding.",NOT_SUPPORTED_TRACK:e=>"".concat(e,"Track is not supported on your browser."),NOT_SUPPORTED_SWITCH_DEVICE:"switchDevice is not supported on your browser.",NOT_SUPPORTED_CAPTURE:"Your browser or environment does not support screen sharing, please check whether the browser version.",MICROPHONE_NOT_FOUND:"no microphone detected, please check your microphone.",CAMERA_NOT_FOUND:"no camera detected, please check your camera.",SIGNAL_RESPONSE_FAILED:e=>"".concat(e.signalResponse," failed, response code is ").concat(e.code," , errMsg: ").concat(e.message,"."),CATCH_HANDLER_ERROR(e){let{name:t,event:i}=e;return"an error was caught on ".concat(t,".on('").concat(i,"', handler), please check your code on 'handler'.")},API_NOT_EXIST(e){let{name:t}=e;return"experimental api ".concat(t," does not exist.")},REPEAT_JOIN:e=>"[".concat(e,"] is calling client.join api or has already joined room, please avoid repeated join."),CONNECTION_CLOSED:"remoteStream has been unsubscribed or unpublished by remote user.",SUBSCRIBE_ALL_FALSE:"cannot subscribe when both audio & video are false, use client.unsubscribe() instead",CLIENT_DESTROYED(e){let{funName:t}=e;return"failed to call ".concat(t,"() because client was destroyed.")},SEI_NOT_SUPPORT:e=>"not support to sendSEIMessage".concat(!1===e?" without using h264 codec":""),SEI_DISABLED:"SEI is disabled",SEI_EMPTY:"buffer cannot be empty",SEI_OVERSIZE:e=>"buffer size(".concat(e,") is over 1000 Bytes"),SEI_BEFORE_PUBLISH:"please call sendSEIMessage() after publish() success",SEI_NOT_VIDEO:"cannot send sei when localStream has not video.",CALL_FREQUENCY_LIMIT:e=>{let{isSize:t,name:i,timesInSecond:r,maxSizeInSecond:n}=e;return"api ".concat(i," call ").concat(t?"size":"times"," is over ").concat(t?"".concat(n," bytes"):r," in a second.")},CONNECTION_ABORTED:e=>"connection aborted due to: ".concat(e),API_CALL_ABORTED(e){let t;return t=e.message.includes("REMOTE_STREAM_NOT_EXIST")?"Subscribe ".concat(e.userId," ").concat(e.streamType," stream aborted, reason: remote user ").concat(e.userId," unpublished stream."):"API aborted, reason: ".concat(e.message),t},DUPLICATE_AUX:"only one auxiliary stream can be published in a room.",NOT_SUPPORTED_AUX:"publish auxiliary stream is not supported on your browser.",INVALID_PARAMETER_STREAMTYPE:e=>"'streamType' is required when 'userId' is not '*', calling ".concat(e,"()")},WN=(e,t)=>t?"".concat(vw,"/").concat(e,"/").concat(t):"".concat(vw,"/").concat(e,"/index.html"),zN=()=>{if(window.TRTC_ERROR_INFO&&window.TRTC_ERROR_LINK)return{TRTC_ERROR_INFO:window.TRTC_ERROR_INFO,TRTC_ERROR_LINK:window.TRTC_ERROR_LINK};let e=localStorage.getItem(Iw);if(e){e=JSON.parse(e);let t=document.createElement("script");t.type="text/javascript",t.text=e.message,document.body.appendChild(t);let i=window.TRTC_ERROR_INFO,r=window.TRTC_ERROR_LINK;return document.body.removeChild(t),{TRTC_ERROR_INFO:i,TRTC_ERROR_LINK:r}}return{}};function GN(e){let{key:t,data:i,link:r,addDocLink:n=!0}=e,o="",s="",a="";ND(jN[t])?o=jN[t](i):OD(jN[t])&&(o=jN[t]);let{TRTC_ERROR_INFO:c,TRTC_ERROR_LINK:l}=zN();r?a="".concat(r.className,".html#").concat(r.fnName):l&&l[t]&&(ND(l[t])?a=l[t](i):OD(l[t])&&(a=l[t]));let d=o;return RD()&&(c&&c[t]&&(ND(c[t])?s=c[t](i):OD(c[t])&&(s=c[t])),s&&(d=n?"".concat(s,"\n请查看文档: ").concat(WN("zh-cn",a),"\n\n"):"".concat(s,"\n\n"),d+=o)),n&&(d+=" \nRefer to: ".concat(WN("en",a),"\n")),d}var KN,YN=function(e){let{retryFunction:t,settings:i,onError:r,onRetrying:n,onRetryFailed:o,onRetrySuccess:s,context:a}=e;return function(){for(var e=arguments.length,c=new Array(e),l=0;l<e;l++)c[l]=arguments[l];let{retries:d=5,timeout:u=1e3}=i,h=0,p=-1,m=0,_=(e,i)=>rC(this,null,(function*(){let l=a||this;try{let i=yield t.apply(l,c);h>0&&s&&s.call(this,h),h=0,e(i)}catch(f){let t=()=>{clearTimeout(p),h=0,m=2,i(f)},s=()=>{2!==m&&h<(ND(d)?d():d)?(h++,m=1,ND(n)&&n.call(this,h,t),p=window.setTimeout((()=>{p=-1,_(e,i)}),ND(u)?u(h):u)):(t(),ND(o)&&o.call(this,f))};ND(r)?r.call(this,{error:f,retry:s,reject:i,retryFuncArgs:c,retriedCount:h}):s()}}));return new Promise(_)}},JN=new($b(nC(),1).default),qN=((KN=qN||{}).ROOM_DESTROY="1",KN.JOIN_START="21",KN.JOIN_SCHEDULE_SUCCESS="22",KN.JOIN_SIGNAL_CONNECTION_START="23",KN.JOIN_SIGNAL_CONNECTION_END="24",KN.JOIN_SEND_CMD="25",KN.JOIN_RECEIVED_CMD_RES="26",KN.JOIN_SUCCESS="27",KN.JOIN_FAILED="28",KN.LEAVE_START="51",KN.LEAVE_SEND_CMD="52",KN.LEAVE_SUCCESS="53",KN.PUBLISH_START="61",KN.SEND_FIRST_VIDEO_FRAME="62",KN.PUBLISH_FAILED="63",KN.SUBSCRIBE_START="81",KN.SUBSCRIBE_SUCCESS="82",KN.SUBSCRIBE_FAILED="84",KN.UNSUBSCRIBE_SUCCESS="83",KN.LOCAL_TRACK_CAPTURE_START="101",KN.LOCAL_TRACK_CAPTURE_SUCCESS="102",KN.LOCAL_TRACK_CAPTURE_FAILED="103",KN.LOCAL_TRACK_PUBLISHED="104",KN.LOCAL_TRACK_UNPUBLISHED="105",KN.LOCAL_TRACK_REPLACED="106",KN.SWITCH_DEVICE_SUCCESS="107",KN.TRACK_MUTED="108",KN.TRACK_UNMUTED="109",KN.REMOTE_TRACK_SUBSCRIBED="110",KN.REMOTE_TRACK_UNSUBSCRIBED="111",KN.PLAY_TRACK_START="151",KN.PLAYER_STATE_CHANGED="152",KN.VIDEO_LOADED_DATA="153",KN.AUTOPLAY_DIALOG_CLICK_CONFIRM="154",KN.SIGNAL_CONNECTION_STATE_CHANGED="201",KN.PEER_CONNECTION_STATE_CHANGED="202",KN.SINGLE_CONNECTION_STAT="203",KN.SPC_RECONNECTED="204",KN.HEARTBEAT_REPORT="251",KN.RECEIVED_PUBLISHED_USER_LIST="252",KN.REMOTE_PUBLISH_STATE_CHANGED="253",KN.AUDIO_LEVEL_INTERVAL="260",KN.NETWORK_QUALITY="261",KN),XN=new class{constructor(){this._roomIdMap=new Map,"undefined"==typeof registerProcessor&&(this._configs={sdkAppId:"",userId:"",version:ow,env:Rw.QCLOUD,browserVersion:Xk.name+Xk.version,ua:navigator.userAgent})}setConfig(e){let{sdkAppId:t,env:i,userId:r,roomId:n}=e;t!==this._configs.sdkAppId&&(this._configs.sdkAppId=String(t)),this._configs.env=i,this._configs.userId=r,this._roomIdMap.set(r,String(n))}logSuccessEvent(e){Jk||!EO.isAbleToUpload||this._configs.env===Rw.QCLOUD&&this.uploadEventToKibana(Xb(qb({},e),{result:"success"}))}logFailedEvent(e){if(Jk||!EO.isAbleToUpload)return;let{eventType:t,code:i,error:r,userId:n}=e,o={roomId:this._roomIdMap.get(n||this._configs.userId),userId:n,eventType:t,result:"failed",code:i||(null==r?void 0:r.extraCode)||(null==r?void 0:r.code)||_C.UNKNOWN};this._configs.env===Rw.QCLOUD&&this.uploadEventToKibana(Xb(qb({},o),{error:r}))}uploadEventToKibana(e){let t="stat-".concat(e.eventType,"-").concat(e.result);("delta-join"===e.eventType||"delta-leave"===e.eventType||"delta-publish"===e.eventType)&&(t="".concat(e.eventType,":").concat(e.delta)),this.uploadEvent({log:t,userId:e.userId}),"failed"===e.result&&(t="stat-".concat(e.eventType,"-").concat(e.result,"-").concat(e.code),this.uploadEvent({log:t,userId:e.userId,error:e.error}))}uploadEvent(e){let{log:t,userId:i,error:r}=e,n={timestamp:vC(),sdkAppId:this._configs.sdkAppId,userId:i||this._configs.userId,version:ow,log:t};r&&(n.errorInfo=r.message),this.sendRequest(dD(this._configs.sdkAppId,Aw.LOG),n)}sendRequest(e,t){EO.isAbleToUpload?BN({url:e,body:JSON.stringify(t)}).catch((()=>{})):setTimeout((()=>{this.sendRequest(e,t)}),1e3)}},QN=null,ZN=!0;function $N(e){PD(e)&&e!==ZN&&(ZN=e,EO.info("setIsNeedToSchedule ".concat(e)))}function eD(e){return rC(this,arguments,(function(e){let{userId:t,sdkAppId:i,useStringRoomId:r,roomId:n,userSig:o,version:s,frameWorkType:a}=e;return function*(){if(!ZN&&QN)return{isCached:!0,result:QN};let e={delta:0,count:[1,1],msg:[],detail:[]};try{let u=new FormData;u.append("userId",String(t)),u.append("sdkAppId",String(i)),u.append("isStrGroupId",String(r)),u.append("groupId",String(n)),u.append("sdkVersion",s),u.append("userSig",String(o)),a&&u.append("frameWorkType",String(a));let h=zD(),p=yield(c=u,l=e,d=i,new Promise(((e,t)=>{let i=null;WD([aD((e=>l.count[0]=e+1),(e=>{let{error:t,retry:r,retriedCount:n,retryFuncArgs:o}=e;l.msg[0]=t.message,i||(n>=2&&(o[0]=rD(d,Mw.MAIN,!0)),r())}))(rD(d,Mw.MAIN),c,{get timeout(){return 1e3*CD(2+l.count[0])}}),aD((e=>l.count[1]=e+1),(e=>{let{error:t,retry:r,retriedCount:n,retryFuncArgs:o}=e;l.msg[1]=t.message,i||(n>=2&&(o[0]=rD(d,Mw.BACKUP,!0)),r())}))(rD(d,Mw.BACKUP),c,{get timeout(){return 1e3*CD(2+l.count[1])}})]).then((t=>{i=t,e(i)})).catch(t)})));p.config&&(p.config.loggerDomain&&mw(p.config.loggerDomain),PD(p.config.scheduleCache)&&$N(!p.config.scheduleCache)),e.delta=zD()-h;let m=function(e,t,i){let r=performance.getEntriesByType("resource"),n=rD(e,Mw.MAIN),o=rD(e,Mw.BACKUP),s={totalCost:0,local:0,dns:0,tcp:0,tls:0,request:0,response:0};for(let a of r)if(a.startTime>=i&&(a.name===n||a.name===o)&&a.transferSize>0){let e=a.name===n?Mw.MAIN:Mw.BACKUP,i=Math.round(a.duration),r=Math.round(a.domainLookupStart-a.startTime),o=Math.round(a.domainLookupEnd-a.domainLookupStart),c=Math.round(a.requestStart-a.secureConnectionStart),l=Math.round(a.secureConnectionStart-a.connectStart),d=Math.round(a.responseStart-a.requestStart),u=Math.round(a.responseEnd-a.responseStart),h=[r,o,c,l,d,u];XN.uploadEvent({log:"stat-schedule-net:".concat(i,"(").concat(h.join("->"),") ").concat(e),userId:t}),s=Xb(qb({},s),{totalCost:i,local:r,dns:o,tcp:l,tls:c,request:d,response:u});break}return s}(Number(i),t,h);return QN=p,{isCached:!1,result:p,detailCost:m}}catch(u){let e=xD(u)?u[0]:u,t=LD(e.code)?e.code:0,i="schedule failed".concat(e.message?": ".concat(e.message):""),r=new fC({code:_C.SCHEDULE_FAILED,extraCode:t,message:GN({key:HN.JOIN_ROOM_FAILED,data:{error:i,code:t}})});throw EO.error(i,t),r}var c,l,d}()}))}document&&document.head.insertAdjacentHTML("beforeend",Object.values(SN).map((e=>'<link rel="dns-prefetch" href="https://'.concat(e,'">'))).join("\r\n")),JN.on("28",(()=>$N(!0))),JN.on("63",(()=>$N(!0))),JN.on("84",(()=>$N(!0))),JN.on("201",(e=>{"RECONNECTING"===e.state&&$N(!0)})),JN.on("202",(e=>{"RECONNECTING"===e.state&&$N(!0)}));var tD={main:"",backup:""};function iD(e){xD(e)?(tD.main=e[0],tD.backup=e[1]):tD.main=e}function rD(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Mw.MAIN,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return"https://".concat(tD[t]||oD(e,t,i),"/api/v1/config")}function nD(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Mw.MAIN;return"https://".concat(tD[t]||oD(e,t),"/api/v1/trtcAutoConf")}function oD(e){let t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Mw.MAIN,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return lD(e)?i===Mw.MAIN?SN.MAIN_OVERSEA:SN.BACKUP_OVERSEA:(t=lD(e)?r?i===Mw.MAIN?SN.MAIN_OVERSEA_OLD:SN.BACKUP_OVERSEA_OLD:i===Mw.MAIN?SN.MAIN_OVERSEA:SN.BACKUP_OVERSEA:i===Mw.MAIN?SN.MAIN:SN.BACKUP,t)}function sD(e,t,i){return new Promise(((r,n)=>{BN({url:e,body:t,timeout:i.timeout}).then((e=>{0===e.data.code?r(e.data.data):n({code:e.data.code,message:e.data.msg})})).catch(n)}))}var aD=(e,t)=>YN({retryFunction:sD,settings:{retries:3,timeout:0},onError:t,onRetrying:e}),cD=function(){return new URLSearchParams(location.search).get("trtc_env")||""},lD=e=>Number(e)<14e8,dD=function(e,t){let i;i=pw||(lD(e)?Sw:Tw);let r=Math.floor(Math.random()*Yb(2,31));return"".concat(i,"/v5/AVQualityReportSvc/C2S?random=").concat(r,"&sdkappid=").concat(e,"&cmdtype=").concat(t)};function uD(){return MC?4:OC?2:NC?3:fk?12:_k?5:gk?13:1}function hD(){return MC?"Android":OC?"iPhone":NC?"iPad":fk?"Mac":_k?"Windows":gk?"Linux":"unknown"}var pD="unknown";function mD(){if("unknown"!==pD)return pD;let{userAgent:e,connection:t}=navigator,i=(e.match(/NetType\/\S+/)||[])[0]||"";i=i.toLowerCase().replace("nettype/",""),"3gnet"===i&&(i="3g");let r=t&&t.type&&t.type.toLowerCase(),n=t&&t.effectiveType&&t.effectiveType.toLowerCase();return"slow-2"===n&&(n="2g"),r&&(pD=_D(r,n)),pD}function _D(e,t){if(ww[e])return e;switch(e){case"cellular":case"wimax":return t||"unknown";case"ethernet":return"wired";default:return"unknown"}}function fD(e){pD=_D(e)}function gD(){return ww[mD()]}var ED=function(e){return{AbilityOption:{AVLimit:e,GeneralLimit:{CPULimit:{uint32_CPU_num:navigator.hardwareConcurrency||0,str_CPU_name:String(navigator.platform),uint32_CPU_maxfreq:0,model:"",uint32_total_memory:0},uint32_terminal_type:uD(),uint32_device_type:0,str_os_verion:hD(),uint32_link_type:1,str_client_version:nw,uint32_net_type:ww[mD()],ua:navigator.userAgent,version:""}}}};function vD(e,t){for(let i of Reflect.ownKeys(t))if("constructor"!==i&&"prototype"!==i&&"name"!==i){let r=Object.getOwnPropertyDescriptor(t,i)||"";Object.defineProperty(e,i,r)}return e}function yD(e){return TD(e/4,arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function TD(e){return 1e3*e/(arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function SD(e){return 4*ID(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function ID(e){return e*(arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)/1e3}var AD="undefined"!=typeof window&&"function"==typeof window.glog?window.glog:()=>{},RD=()=>{let e=navigator.language;return e=e.substring(0,2),"zh"===e},bD=function(e){if(!e||"object"!=typeof e||"[object Object]"!=Object.prototype.toString.call(e))return!1;let t=Object.getPrototypeOf(e);if(null===t)return!0;let i=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return"function"==typeof i&&i instanceof i&&Function.prototype.toString.call(i)===Function.prototype.toString.call(Object)};function CD(e){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return e<=1?t:CD(e-1,t,(arguments.length>1&&void 0!==arguments[1]?arguments[1]:1)+t)}function kD(e){return e>8?3e4:1e3*CD(e)}function wD(e){return Reflect.apply(Object.prototype.toString,e,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}var ND=e=>"function"==typeof e,DD=e=>void 0===e,OD=e=>"string"==typeof e,LD=e=>"number"==typeof e,PD=e=>"boolean"==typeof e,MD=e=>"object"===wD(e),xD=e=>"array"===wD(e),VD=e=>wD(e)==="MediaStreamTrack".toLowerCase(),UD=e=>e.isRemote,BD=e=>"promise"===wD(e),FD=e=>ND(e)&&e.prototype.constructor===e,HD=e=>FD(e)?e.prototype.constructor.name:"",jD="undefined"!=typeof AudioWorkletNode;function WD(e){return new Promise(((t,i)=>{let r=[];e.forEach((n=>{n.then(t).catch((t=>{r.push(t),r.length===e.length&&i(r)}))}))}))}function zD(){return performance&&performance.now?Math.floor(performance.now()):Date.now()}var GD=e=>+e<10?"0".concat(e):e,KD=e=>{let t=e.match(/^\d+\.\d+\.\d+/)[0];if(!t)return e;let i=t.split("."),r=GD(i[1])+GD(i[2]);return i[1]-15>0&&(i[1]="15"),i[2]-15>0&&(i[2]="15"),"".concat(i.join("."),".").concat(r)},YD=Object.prototype.hasOwnProperty;function JD(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e||"function"==typeof e||Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(bD(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(let t in e)if(YD.call(e,t))return!1;return!0}return!1}function qD(e,t){return{userId:t,hasAudio:!!(e&jw),hasVideo:!!(e&Bw),hasAuxiliary:!!(e&Hw),hasSmall:!!(e&Fw),audioMuted:!!(e&Ww),videoMuted:!!(e&zw),audioAvailable:!(!(e&jw)||e&Ww),videoAvailable:!(!(e&Bw)||e&zw)}}function XD(e,t){return e>50||t>500?5:e>30||t>350?4:e>20||t>200?3:e>10||t>100?2:e>=0||t>=0?1:0}function QD(e){let t={urls:"turn:".concat(e.url)};return!DD(e.username)&&!DD(e.credential)&&(t.username=e.username,t.credential=e.credential,t.credentialType="password",DD(e.credentialType)||(t.credentialType=e.credentialType)),t}function ZD(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!OD(e))return 0;let i=e.split(".");return t?(Number(i[0])<<24|Number(i[1])<<16|Number(i[2])<<8|Number(i[3]))>>>0:(Number(i[3])<<24|Number(i[2])<<16|Number(i[1])<<8|Number(i[0]))>>>0}var $D=function(e,t,i,r){if(!MD(e)||!MD(t))return 0;let n,o=0,s=Object.keys(t);for(let a=0,c=s.length;a<c;a++)if(n=s[a],!(DD(t[n])||i&&i.includes(n)))if(MD(e[n])&&MD(t[n]))o+=$D(e[n],t[n],i,r);else{if(r&&r.includes(t[n]))continue;e[n]!==t[n]&&(e[n]=eO(t[n]),o+=1)}return o};function eO(e){if(xD(e)){let t=[];return e.forEach(((e,i)=>{t[i]=eO(e)})),t}if(MD(e)){let t={};return Object.keys(e).forEach((i=>{t[i]=eO(e[i])})),t}return e}var tO=e=>{let t=[];if(xD(e))t=[...e];else if(OD(e)){let i=document.getElementById(e);i&&t.push(i)}else e&&t.push(e);return t},iO=e=>OD(e)?document.getElementById(e):e,rO=new Intl.DateTimeFormat("zh-CN",{dateStyle:"short",timeStyle:"medium"}),nO=()=>rO.format(new Date);function oO(e,t){let{keysToInclude:i,keysToExclude:r}=t;try{if(xD(e))return"[".concat(e.map((e=>oO(e,{keysToInclude:i,keysToExclude:r}))).join(","),"]");if(!bD(e)||!xD(i)&&!xD(r))return JSON.stringify(e);let t={},n=new Set(i),o=new Set(r);return Object.keys(e).forEach((s=>{(0===o.size&&n.has(s)||0===n.size&&!o.has(s))&&(t[s]=bD(e[s])||xD(e[s])?JSON.parse(oO(e[s],{keysToExclude:r,keysToInclude:i})):e[s])})),JSON.stringify(t)}catch(n){return"{}"}}function sO(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=[];return Object.keys(e).forEach((r=>{t===e[r]&&i.push(r)})),oO(e,{keysToInclude:i})}function aO(e){return e.replace(/[\u4e00-\u9fa5]/g,"aa").length}var cO=(()=>{let e=!1,t=document.visibilityState;return()=>{document.visibilityState!==t&&EO.info("visibility change: ".concat(document.visibilityState)),!e&&(document.addEventListener("visibilitychange",(()=>{EO.info("visibility change: ".concat(document.visibilityState)),t=document.visibilityState})),e=!0)}})(),lO=()=>{var e,t,i,r;return null!=(e=window.screen)&&e.orientation?!(null==(r=null==(i=null==(t=window.screen)?void 0:t.orientation)?void 0:i.type)||!r.includes("portrait")):0===window.orientation||180===window.orientation},dO=e=>rC(void 0,null,(function*(){return new Promise(((t,i)=>{let r;if(OD(e))r=new Image,r.crossOrigin="anonymous",r.src=e;else if(r=e,r.complete)return void t(r);r.onload=()=>t(r),r.onerror=i}))})),uO=e=>{let t=e.split(".");return+t[0]<<24|+t[1]<<16|+t[2]<<8|+t[3]},hO=e=>(Object.keys(e).forEach((t=>{LD(e[t])&&(t.startsWith("uint")||t.startsWith("int"))?e[t]=Math.floor(e[t]):(bD(e[t])||xD(e[t]))&&hO(e[t])})),e),pO=Object.prototype.hasOwnProperty;function mO(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e||"function"==typeof e||Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(function(e){if(!e||"object"!=typeof e||"[object Object]"!=Object.prototype.toString.call(e))return!1;let t=Object.getPrototypeOf(e);if(null===t)return!0;let i=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return"function"==typeof i&&i instanceof i&&Function.prototype.toString.call(i)===Function.prototype.toString.call(Object)}(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(let t in e)if(pO.call(e,t))return!1;return!0}return!1}var _O=class{constructor(e){tC(this,"userId"),tC(this,"remoteUserId"),tC(this,"id"),tC(this,"sdkAppId"),tC(this,"type"),tC(this,"isLocal"),this.id=e.id,this.userId=e.userId,this.sdkAppId=e.sdkAppId,this.remoteUserId=e.remoteUserId,this.isLocal="boolean"!=typeof e.isLocal||e.isLocal,this.type=this.isLocal?"":e.type}createChild(e){return Object.setPrototypeOf(e,this)}setUserId(e){this.userId=e}setSdkAppId(e){this.sdkAppId=e}log(e,t){let i=this.isLocal?this.userId:this.remoteUserId;t.unshift("[".concat(this.isLocal?"↑":"↓").concat(this.type&&"main"!==this.type?"*":"").concat(this.id).concat(i?"|".concat(i):"","]")),EO.log(e,t,void 0===this.userId||mO(this.userId),this.userId,this.sdkAppId)}info(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(2,t)}debug(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(1,t)}warn(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(3,t)}error(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(4,t)}},fO=qN,gO=!(PC||MC||xk),EO=new class{constructor(){tC(this,"_isEnableUploadLog",!0),tC(this,"_localJoinedUser",new Map),tC(this,"_queue",[]),tC(this,"_timeoutId",-1),tC(this,"_logLevel",1),tC(this,"_logLevelToUpload",2),!dw&&!uw&&(this.checkURLParam(),this.installEvents())}get isAbleToUpload(){return this._isEnableUploadLog&&-1!==this._timeoutId}installEvents(){JN.on(fO.JOIN_SCHEDULE_SUCCESS,(e=>{let{schedule:t}=e;var i;(null==(i=null==t?void 0:t.config)?void 0:i.logLevelToUpload)&&bw[t.config.logLevelToUpload]&&(this._logLevelToUpload=t.config.logLevelToUpload)})),JN.on(fO.JOIN_SUCCESS,(e=>{let{room:t}=e;this.addJoinedUser({userId:t.userId,sdkAppId:t.sdkAppId}),this.startUpload()})),JN.once(fO.JOIN_FAILED,(()=>{this.startUpload()})),JN.on(fO.LEAVE_SUCCESS,(e=>{let{room:t}=e;this.deleteJoinedUser(t.userId)}))}startUpload(){-1===this._timeoutId&&this.uploadInterval()}addJoinedUser(e){this._localJoinedUser.set(e.userId,e),this.startUpload()}deleteJoinedUser(e){this._localJoinedUser.delete(e)}uploadInterval(){this.upload().catch((()=>{})),this._timeoutId=window.setTimeout((()=>this.uploadInterval()),2e3)}getLogsToUpload(){let e={map:new Map,splicedQueue:[]};if(this._queue[0].forAllJoinedClients&&0===this._localJoinedUser.size)return e;let t=0;for(;t<this._queue.length&&50!==t;t++){let i=this._queue[t];if(i.forAllJoinedClients)this._localJoinedUser.forEach((t=>{let{userId:r,sdkAppId:n}=t;e.map.has(r)?e.map.get(r).logs.push(i):e.map.set(r,{userId:r,sdkAppId:n,logs:[i]})}));else if(OD(i.userId)&&LD(i.sdkAppId)){let{userId:t,sdkAppId:r}=i;e.map.has(t)?e.map.get(t).logs.push(i):e.map.set(t,{userId:t,sdkAppId:r,logs:[i]})}}return e.map.size>0&&(e.splicedQueue=this._queue.splice(0,t)),e}upload(){return rC(this,null,(function*(){if(0===this._queue.length||!this._isEnableUploadLog)return;let{map:e,splicedQueue:t}=this.getLogsToUpload();if(0===e.size)return;try{let t=[...e.values()];for(let e=0;e<t.length;e++){let{userId:i,sdkAppId:r,logs:n}=t[e];yield this.uploadLogWithRetry(JSON.stringify({timestamp:vC(),sdkAppId:String(r),userId:i,version:ow,log:n.map((e=>e.log)).join("\n")}),r),n.forEach((e=>e.uploaded=!0))}}catch(r){}let i=t.filter((e=>!e.uploaded));i.length>0&&(this._queue=i.concat(this._queue))}))}uploadLogWithRetry(e,t){return YN({retryFunction:()=>BN({url:dD(t,Aw.LOG),body:e,timeout:5e3}),settings:{retries:3,timeout:1e3},onError:e=>{let{retry:t}=e;t()}})()}getPrefix(e){let t=new Date;t.setTime(EC());let i=String(t.getMilliseconds());return"padStart"in String.prototype&&(i=i.toString().padStart(3,"0")),"[".concat(t.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(i,"] <").concat(bw[e],">")}getLogLevel(){return this._logLevel}setLogLevel(e){DD(bw[e])||(this._logLevel!==e&&this.info("setLogLevel",e),this._logLevel=e)}enableUploadLog(){this._isEnableUploadLog=!0}disableUploadLog(){this.warn("disableUploadLog"),this._isEnableUploadLog=!1}logChunkToString(e){if(OD(e))return e;try{return e instanceof Error?e.toString():JSON.stringify(e)}catch(t){return""}}log(e,t){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=arguments.length>3?arguments[3]:void 0,n=arguments.length>4?arguments[4]:void 0;var o;if(t.unshift(this.getPrefix(e)),this._isEnableUploadLog&&e>=this._logLevelToUpload&&this._queue.push({log:t.reduce(((e,t)=>"".concat(e," ").concat(this.logChunkToString(t)).trim()),""),level:e,userId:r,sdkAppId:n,forAllJoinedClients:i}),e<this._logLevel)return;let s=(null==(o=bw[e])?void 0:o.toLowerCase())||"info";gO?console[s]("%cTRTC%c%s","padding: 1px 4px;border-radius: 3px;color: #fff;background: #1E88E5;","display: inline",...t):console[s](...t)}debug(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(1,t)}info(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(2,t)}warn(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(3,t)}error(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(4,t)}createLogger(e){return new _O(e)}checkURLParam(){let e=new URLSearchParams(location.search).get("logLevelToUpload"),t=e?Number(e):-1;bw[t]&&(this._logLevelToUpload=t)}},vO=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{let t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))},yO=new class{constructor(){tC(this,"_prefix","TRTC"),tC(this,"_queue",new Map),this.checkStorage()}getRealKey(e){return"".concat(this._prefix,"_").concat(e)}checkStorage(){qk()&&(setInterval(this.doFlush.bind(this),2e4),Object.keys(localStorage).filter((e=>{if(e.startsWith(this._prefix)){let t=localStorage.getItem(e);if(!t)return!1;let i=JSON.parse(t);if(i&&i.expiresIn<Date.now())return!0}return!1})).forEach((e=>localStorage.removeItem(e))))}doFlush(){if(qk())try{for(let[e,t]of this._queue)localStorage.setItem(e,JSON.stringify(t))}catch(e){EO.warn(e)}}getItem(e){if(!qk())return null;try{let t=localStorage.getItem(this.getRealKey(e));if(!t)return null;let i=JSON.parse(t);return i&&i.expiresIn>=Date.now()?i.value:null}catch(t){EO.warn(t)}}setItem(e,t){if(qk())try{let i={expiresIn:Date.now()+Nw,value:t};this._queue.set(this.getRealKey(e),i)}catch(i){EO.warn(i)}}deleteItem(e){if(!qk())return!1;try{return e=this.getRealKey(e),this._queue.delete(e),localStorage.removeItem(e),!0}catch(t){return EO.warn(t),!1}}clear(){if(qk())try{localStorage.clear()}catch(e){EO.warn(e)}}},TO={};Zb(TO,{HTTPS_API:()=>VO,IS_GET_CAPABILITIES_SUPPORTED:()=>eL,IS_GET_SETTINGS_SUPPORTED:()=>$O,IS_SEI_SUPPORTED:()=>tL,IS_SPC_SUPPORTED:()=>qO,basis:()=>sL,checkSystemRequirementsInternal:()=>PO,decodeSupportStatus:()=>LO,encodeSupportStatus:()=>OO,getBrowserInfo:()=>RO,getDisplayResolution:()=>BO,isAddTransceiverSupported:()=>JO,isBrowserSupported:()=>bO,isGetReceiversSupported:()=>GO,isGetSendersSupported:()=>KO,isGetTransceiversSupported:()=>YO,isGetUserMediaSupported:()=>FO,isMediaDevicesSupported:()=>kO,isMediaSessionSupported:()=>nL,isMediaStreamTrackProcessorSupported:()=>DO,isReplaceTrackSupported:()=>QO,isScreenCaptureApiAvailable:()=>xO,isSelectedCandidatePair:()=>UO,isSetParametersSupported:()=>ZO,isSmallStreamAPISupported:()=>jO,isSmallStreamSupported:()=>WO,isStopTransceiverSupported:()=>XO,isTRTCSupported:()=>MO,isUnifiedPlanDefault:()=>zO,isUsedInHttpProtocol:()=>NO,isWebAudioSupported:()=>HO,isWebCodecSupported:()=>rL,isWebCodecsSupported:()=>CO,isWebRTCSupported:()=>iL,isWebTransportSupported:()=>oL});var SO=$b(cC(),1),IO={result:!1,detail:{isBrowserSupported:!1,isWebRTCSupported:!1,isWebCodecsSupported:!1,isMediaDevicesSupported:!1,isScreenShareSupported:!1,isSmallStreamSupported:!1,isH264EncodeSupported:!1,isVp8EncodeSupported:!1,isH264DecodeSupported:!1,isVp8DecodeSupported:!1}},AO=new Map([[BC,["Firefox",FC]],[zC,["Edg",GC]],[Mk,["Chrome",Uk]],[Bk,["Safari",Hk]],[QC,["TBS",ZC]],[$C,["XWEB",ek]],[nk&&OC,["WeChat",ok]],[lk,["QQ(Win)",dk]],[ak,["QQ(Mobile)",ck]],[sk,["QQ(Mobile X5)",ck]],[uk,["QQ(Mac)",hk]],[pk,["QQ(iPad)",mk]],[Sk,["MI",Ik]],[Ak,["HW",bk]],[Ck,["Samsung",kk]],[wk,["OPPO",Nk]],[Dk,["VIVO",Ok]],[jC,["EDGE",WC]],[YC,["SogouMobile",JC]],[qC,["Sogou",XC]]]);function RO(){let e=AO.get(!0);return{browserName:e?e[0]:"unknown",browserVersion:e?e[1]:"unknown"}}var bO=function(){return!(yk||jC||zC&&KC<80||BC&&HC<56)},CO=function(){return["VideoDecoder","VideoEncoder","AudioEncoder","AudioDecoder","MediaStreamTrackGenerator"].every((e=>e in window))},kO=function(){if(!navigator.mediaDevices)return NO()||EO.error(jN.NOT_SUPPORTED_MEDIA),!1;let e=["getUserMedia","enumerateDevices"];return e.filter((e=>e in navigator.mediaDevices)).length===e.length},wO=!1;function NO(){return"http:"===location.protocol&&!Jk&&(wO||EO.error(GN({key:HN.NOT_SUPPORTED_HTTP})),wO=!0,!0)}var DO=function(){return(null==window?void 0:window.OffscreenCanvas)&&(null==window?void 0:window.MediaStreamTrackProcessor)&&(null==window?void 0:window.MediaStreamTrackGenerator)},OO=function(){return rC(this,null,(function*(){if(IO.detail.isH264EncodeSupported||IO.detail.isVp8EncodeSupported)return{isH264EncodeSupported:IO.detail.isH264EncodeSupported,isVp8EncodeSupported:IO.detail.isVp8EncodeSupported};let e,t=!1,i=!1;try{let r=new RTCPeerConnection,n=document.createElement(Mw.CANVAS);n.getContext("2d");let o=n.captureStream(0);return r.addTrack(o.getVideoTracks()[0],o),e=yield r.createOffer(),-1!==e.sdp.toLowerCase().indexOf("h264")&&(t=!0),-1!==e.sdp.toLowerCase().indexOf("vp8")&&(i=!0),r.close(),IO.detail.isH264EncodeSupported=t,IO.detail.isVp8EncodeSupported=i,{isH264EncodeSupported:IO.detail.isH264EncodeSupported,isVp8EncodeSupported:IO.detail.isVp8EncodeSupported}}catch(r){return{isH264EncodeSupported:!1,isVp8EncodeSupported:!1}}}))},LO=function(){return rC(this,null,(function*(){if(IO.detail.isH264DecodeSupported&&IO.detail.isVp8DecodeSupported)return{isH264DecodeSupported:IO.detail.isH264DecodeSupported,isVp8DecodeSupported:IO.detail.isVp8DecodeSupported};let e,t=!1,i=!1;try{let r=new RTCPeerConnection;return e=yield r.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0}),-1!==e.sdp.toLowerCase().indexOf("h264")&&(t=!0),-1!==e.sdp.toLowerCase().indexOf("vp8")&&(i=!0),r.close(),{isH264DecodeSupported:t,isVp8DecodeSupported:i}}catch(r){return{isH264DecodeSupported:!1,isVp8DecodeSupported:!1}}}))},PO=function(){return rC(this,null,(function*(){if(IO.result)return IO;let e=bO(),t=iL(),i=CO(),r=kO(),{isH264EncodeSupported:n,isVp8EncodeSupported:o}=yield OO(),{isH264DecodeSupported:s,isVp8DecodeSupported:a}=yield LO();if(!n||!o){let e=yield OO();n=e.isH264EncodeSupported,o=e.isVp8EncodeSupported}if(n&&s&&(wk||Dk||jk)&&!QC&&Lk()<79){let{encode:e,decode:t}=yield function(){return rC(this,null,(function*(){return new Promise((e=>rC(this,null,(function*(){let t={encode:!1,decode:!1},i=()=>{};try{let r=document.createElement("canvas"),n=r.getContext("2d");r.width=640,r.height=480;let o=setInterval((()=>{n.fillText("test",Math.floor(640*Math.random()),Math.floor(480*Math.random()))}),33),s=-1,a=-1;i=()=>{clearInterval(s),clearInterval(o),clearTimeout(a),l.close(),d.close(),c.getTracks().forEach((e=>e.stop()))},a=setTimeout((()=>{i(),e(t)}),3e3);let c=r.captureStream(),l=new RTCPeerConnection({}),d=new RTCPeerConnection({offerToReceiveAudio:!0,offerToReceiveVideo:!0});l.addEventListener("icecandidate",(e=>d.addIceCandidate(e.candidate))),d.addEventListener("icecandidate",(e=>l.addIceCandidate(e.candidate))),l.addTrack(c.getVideoTracks()[0],c);let u=yield l.createOffer();yield l.setLocalDescription(u),yield d.setRemoteDescription(u);let h=yield d.createAnswer(),p=SO.default.parse(h.sdp),m=p.media[0].rtp.findIndex((e=>"H264"===e.codec));p.media[0].rtp=[p.media[0].rtp[m]],p.media[0].fmtp=p.media[0].fmtp.filter((e=>e.payload===p.media[0].rtp[0].payload)),p.media[0].rtcpFb&&(p.media[0].rtcpFb=p.media[0].rtcpFb.filter((e=>e.payload===p.media[0].rtp[0].payload))),h.sdp=SO.default.write(p),yield d.setLocalDescription(h),yield l.setRemoteDescription(h),s=setInterval((()=>rC(this,null,(function*(){t.encode&&t.decode&&(i(),e(t));let r=yield l.getStats(),n=yield d.getStats();t.encode||r.forEach((e=>{"outbound-rtp"===e.type&&e.mediaType===Mw.VIDEO&&e.framesEncoded>0&&(t.encode=!0)})),t.decode||n.forEach((e=>{"inbound-rtp"===e.type&&e.mediaType===Mw.VIDEO&&e.framesDecoded>0&&(t.decode=!0)}))}))),500)}catch(r){i(),EO.warn(r),e(t)}}))))}))}();n=e,s=t}return IO.result=e&&t&&r&&(n||o)&&(s||a),IO.detail.isBrowserSupported=e,IO.detail.isWebRTCSupported=t,IO.detail.isWebCodecsSupported=i,IO.detail.isMediaDevicesSupported=r,IO.detail.isScreenShareSupported=xO(),IO.detail.isSmallStreamSupported=WO(),IO.detail.isH264EncodeSupported=n,IO.detail.isVp8EncodeSupported=o,IO.detail.isH264DecodeSupported=s,IO.detail.isVp8DecodeSupported=a,IO.result||EO.error("".concat(navigator.userAgent," ").concat(sO(IO.detail,!1))),yO.setItem(aL,{ua:navigator.userAgent,checkResult:IO}),IO}))},MO=function(){return IO.result},xO=function(){return!(!navigator.mediaDevices||!navigator.mediaDevices.getDisplayMedia)},VO=(e,t,i)=>{"http:"===location.protocol&&!Jk&&(e[t]=()=>{throw new fC({code:_C.INVALID_OPERATION,message:jN.NOT_SUPPORTED_HTTP})})},UO=function(e){return!("candidate-pair"!==e.type||!e.nominated||"in-progress"!==e.state&&"succeeded"!==e.state||PD(e.selected)&&!e.selected)};function BO(){let e="";if(screen.width){let t=screen.width?screen.width*window.devicePixelRatio:"",i=screen.height?screen.height*window.devicePixelRatio:"";e+="".concat(t," * ").concat(i)}return e}function FO(){return navigator.getUserMedia||navigator.mediaDevices&&navigator.mediaDevices.getUserMedia}function HO(){let e={isSupported:!1},t=["AudioContext","webkitAudioContext","mozAudioContext","msAudioContext"];for(let i=0;i<t.length;i++)if(t[i]in window){e.isSupported=!0;break}return e.isSupported}function jO(){return"captureStream"in HTMLCanvasElement.prototype}function WO(){return!(nk||PC||Vk&&Vk<63||!bO()||!jO())}var zO=function(){if(DD(window.RTCRtpTransceiver)||!("currentDirection"in RTCRtpTransceiver.prototype))return!1;let e=null,t=!1;try{e=new RTCPeerConnection({sdpSemantics:pN}),e.addTransceiver(Mw.AUDIO),t=!0}catch(i){}return null==e||e.close(),t};function GO(){return"RTCPeerConnection"in window&&"getReceivers"in window.RTCPeerConnection.prototype}function KO(){return"RTCPeerConnection"in window&&"getSenders"in window.RTCPeerConnection.prototype}function YO(){return"RTCPeerConnection"in window&&"getTransceivers"in window.RTCPeerConnection.prototype}function JO(){return 11!==zk&&"RTCPeerConnection"in window&&"addTransceiver"in window.RTCPeerConnection.prototype}var qO=!(!JO()||Pk&&Vk<74);function XO(){return"RTCRtpTransceiver"in window&&"stop"in window.RTCRtpTransceiver.prototype}function QO(){return"RTCRtpSender"in window&&"replaceTrack"in window.RTCRtpSender.prototype}function ZO(){return"RTCRtpSender"in window&&"setParameters"in window.RTCRtpSender.prototype&&KO()}var $O=window.MediaStreamTrack&&"getSettings"in MediaStreamTrack.prototype,eL=window.MediaStreamTrack&&"getCapabilities"in MediaStreamTrack.prototype,tL="RTCRtpSender"in window&&"createEncodedStreams"in window.RTCRtpSender.prototype&&Lk()>=86,iL=function(){return["RTCPeerConnection","webkitRTCPeerConnection","RTCIceGatherer"].filter((e=>e in window)).length>0};function rL(){let e={AudioDecoder:!1,AudioEncoder:!1,VideoDecoder:!1,VideoEncoder:!1,ImageDecoder:!1};return DD(window.AudioDecoder)||(e.AudioDecoder=!0),DD(window.AudioEncoder)||(e.AudioEncoder=!0),DD(window.VideoDecoder)||(e.VideoDecoder=!0),DD(window.VideoEncoder)||(e.VideoEncoder=!0),DD(window.ImageDecoder)||(e.ImageDecoder=!0),e}function nL(){return"mediaSession"in navigator&&!DD(navigator.mediaSession.setActionHandler)}function oL(){return!DD(window.WebTransport)}function sL(){let e={browser:"".concat(Xk.name,"/").concat(Xk.version),os:tw(),displayResolution:BO(),isScreenShareSupported:xO(),isWebRTCSupported:iL(),isGetUserMediaSupported:FO(),isWebAudioSupported:HO(),isWebSocketsSupported:"WebSocket"in window&&2===window.WebSocket.CLOSING,isWebCodecSupported:rL(),isMediaSessionSupported:nL(),isWebTransportSupported:oL()};return navigator.userAgent.includes("miniProgram")&&(e.browser="mini/".concat(e.browser)),e}var aL="checkResult";!function(){NO();let e=yO.getItem(aL);e&&e.ua===navigator.userAgent&&(IO=e.checkResult),PO()}();var cL=$b(nC(),1),lL=Symbol("instance"),dL=Symbol("cacheResult"),uL=class{constructor(e,t,i){this.oldState=e,this.newState=t,this.action=i,this.aborted=!1}abort(e){this.aborted=!0,fL.call(e,this.oldState,new Error("action '".concat(this.action,"' aborted")))}toString(){return"".concat(this.action,"ing")}},hL=class extends Error{constructor(e,t,i){super(t),this.state=e,this.message=t,this.cause=i}},pL=new Map;function mL(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return(r,n,o)=>{let s=i.action||n;if(!i.context){let i=pL.get(r)||[];pL.has(r)||pL.set(r,i),i.push({from:e,to:t,action:s})}let a=o.value;o.value=function(){let r=this;for(var n=arguments.length,o=new Array(n),c=0;c<n;c++)o[c]=arguments[c];if(i.context&&(r=gL.get("function"==typeof i.context?i.context.call(this,...o):i.context)),r.state===t)return i.sync?r[dL]:Promise.resolve(r[dL]);r.state instanceof uL&&r.state.action==i.abortAction&&r.state.abort(r);let l=null;Array.isArray(e)?0==e.length?r.state instanceof uL&&r.state.abort(r):("string"!=typeof r.state||!e.includes(r.state))&&(l=new hL(r._state,"".concat(r.name," ").concat(s," to ").concat(t," failed: current state ").concat(r._state," not from ").concat(e.join("|")))):e!==r.state&&(l=new hL(r._state,"".concat(r.name," ").concat(s," to ").concat(t," failed: current state ").concat(r._state," not from ").concat(e)));let d=e=>{if(i.fail&&i.fail.call(this,e),i.sync){if(i.ignoreError)return e;throw e}return i.ignoreError?Promise.resolve(e):Promise.reject(e)};if(l)return d(l);let u=r.state,h=new uL(u,t,s);fL.call(r,h);let p=e=>{var n;return r[dL]=e,h.aborted||(fL.call(r,t),null===(n=i.success)||void 0===n||n.call(this,r[dL])),e},m=e=>{let t=e instanceof Error?e.message:String(e);return fL.call(r,u,e),d(new hL(r._state,"action '".concat(s,"' failed :").concat(t),e instanceof Error?e:new Error(t)))};try{let e=a.apply(this,o);return"object"==typeof(_=e)&&_&&"then"in _?e.then(p).catch(m):i.sync?p(e):Promise.resolve(p(e))}catch(f){return m(f)}var _}}}var _L="undefined"!=typeof window&&window.__AFSM__?(e,t)=>{window.dispatchEvent(new CustomEvent(e,{detail:t}))}:"undefined"!=typeof importScripts?(e,t)=>{postMessage({type:e,payload:t})}:()=>{};function fL(e,t){let i=this._state;this._state=e;let r=e.toString();e&&this.emit(r,i),this.emit(gL.STATECHANGED,e,i,t),this.updateDevTools({value:e,old:i,err:t instanceof Error?t.message:String(t)})}var gL=class extends cL.default{constructor(e,t,i){super(),this.name=e,this.groupName=t,this._state=gL.INIT,e||(e=Date.now().toString(36)),i?Object.setPrototypeOf(this,i):i=Object.getPrototypeOf(this),t||(this.groupName=this.constructor.name);let r=i[lL];r?this.name=r.name+"-"+r.count++:i[lL]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){let e=Object.getPrototypeOf(this),t=pL.get(e)||[],i=new Set,r=[],n=[],o=new Set,s=Object.getPrototypeOf(e);pL.has(s)&&(s.stateDiagram.forEach((e=>i.add(e))),s.allStates.forEach((e=>o.add(e)))),t.forEach((e=>{let{from:t,to:i,action:o}=e;"string"==typeof t?r.push({from:t,to:i,action:o}):t.length?t.forEach((e=>{r.push({from:e,to:i,action:o})})):n.push({to:i,action:o})})),r.forEach((e=>{let{from:t,to:r,action:n}=e;o.add(t),o.add(r),o.add(n+"ing"),i.add("".concat(t," --\x3e ").concat(n,"ing : ").concat(n)),i.add("".concat(n,"ing --\x3e ").concat(r," : ").concat(n," 🟢")),i.add("".concat(n,"ing --\x3e ").concat(t," : ").concat(n," 🔴"))})),n.forEach((e=>{let{to:t,action:r}=e;i.add("".concat(r,"ing --\x3e ").concat(t," : ").concat(r," 🟢")),o.forEach((e=>{e!==t&&i.add("".concat(e," --\x3e ").concat(r,"ing : ").concat(r))}))}));let a=[...i];return Object.defineProperties(e,{stateDiagram:{value:a},allStates:{value:o}}),a}static get(e){let t;return"string"==typeof e?(t=gL.instances.get(e),t||gL.instances.set(e,t=new gL(e,void 0,Object.create(gL.prototype)))):(t=gL.instances2.get(e),t||gL.instances2.set(e,t=new gL(e.constructor.name,void 0,Object.create(gL.prototype)))),t}static getState(e){var t;return null===(t=gL.get(e))||void 0===t?void 0:t.state}updateDevTools(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};_L(gL.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},e))}get state(){return this._state}set state(e){fL.call(this,e)}};gL.STATECHANGED="stateChanged",gL.UPDATEAFSM="updateAFSM",gL.INIT="[*]",gL.ON="on",gL.OFF="off",gL.instances=new Map,gL.instances2=new WeakMap;var EL=(null==window?void 0:window.requestIdleCallback)||function(e){let t=Date.now();return setTimeout((()=>{e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})}),1e3)},vL=(null==window?void 0:window.cancelIdleCallback)||function(e){clearTimeout(e)},yL=(null==window?void 0:window.cancelAnimationFrame)||(null==window?void 0:window.mozCancelAnimationFrame),TL=class{static generateTaskID(){return this.currentTaskID++}static run(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:xN,t=arguments.length>1?arguments[1]:void 0,i=arguments.length>2?arguments[2]:void 0;i=qb(e===MN?{delay:2e3,count:0,backgroundTask:!0}:e===LN?{delay:1e4,count:0}:e===PN?{fps:60,delay:16.6,count:0,backgroundTask:!0}:{delay:2e3,count:0,backgroundTask:!0},i),MD(t)&&(i=qb(qb({},i),t)),ND(e)&&(t=e,e=xN);let r=qb({taskID:this.generateTaskID(),loopCount:0,intervalID:null,timeoutID:null,rafID:null,ricID:null,taskName:e,callback:t},i);return this.taskMap.set(r.taskID,r),this[e](r),r.taskID}static interval(e){return e.intervalID=setInterval((()=>{e.callback(),e.loopCount+=1,this.isBreakLoop(e)}),e.delay)}static intervalInWorker(e){e.delay=(1e3/e.fps).toFixed(2);let t=new Worker(URL.createObjectURL(new Blob(["\n let timerID = null;\n self.onmessage = function (e) {\n if (e.data === 'start') {\n timerID = setInterval(() => {\n self.postMessage('tick');\n }, ".concat(e.delay,");\n } else if (e.data === 'stop') {\n clearInterval(timerID);\n }\n };\n ")])));t.onmessage=i=>{"tick"===i.data&&(e.callback(),e.loopCount+=1,this.isBreakLoop(e)&&t.postMessage("stop"))},e.worker=t,t.postMessage("start")}static timeout(e){let t=()=>{if(e.callback(),e.loopCount+=1,!this.isBreakLoop(e))return e.timeoutID=setTimeout(t,e.delay)};return e.timeoutID=setTimeout(t,e.delay)}static ric(e){let t,i=zD(),r=()=>{if(t=zD()-i,t>=e.delay&&(i=zD()-Math.floor(t%e.delay),e.callback(),e.loopCount+=1),!this.isBreakLoop(e))return e.ricID=EL(r,{timeout:e.delay})};return e.ricID=EL(r,{timeout:e.delay})}static raf(e){e.delay=(1e3/e.fps).toFixed(2);let t,i=zD(),r=()=>document.hidden&&e.backgroundTask?(t=zD()-i,i=zD(),e.callback(),e.loopCount+=1,this.isBreakLoop(e)?void 0:e.timeoutID=setTimeout(r,e.delay-Math.floor(t%e.delay))):(t=zD()-i,t>=e.delay&&(i=zD()-Math.floor(t%e.delay),e.callback(),e.loopCount+=1),this.isBreakLoop(e)?void 0:e.rafID=requestAnimationFrame(r));if(e.rafID=requestAnimationFrame(r),e.backgroundTask){let t=()=>{if(document.hidden){let t=zD()-i;t>=e.delay?r():e.timeoutID=setTimeout(r,e.delay-t)}};document.addEventListener("visibilitychange",t),e.onVisibilitychange=t,document.hidden&&t()}return e.taskID}static hasTask(e){return this.taskMap.has(e)}static clearTask(e){if(!this.taskMap.has(e))return!0;let{intervalID:t,timeoutID:i,rafID:r,ricID:n,onVisibilitychange:o,worker:s}=this.taskMap.get(e);return s&&s.terminate(),t&&clearInterval(t),i&&clearTimeout(i),r&&yL(r),n&&vL(n),o&&document.removeEventListener("visibilitychange",o),this.taskMap.delete(e),!0}static isBreakLoop(e){return!this.taskMap.has(e.taskID)||0!==e.count&&e.loopCount>=e.count&&(this.clearTask(e.taskID),!0)}};TL.taskMap=new Map,TL.currentTaskID=1;var SL=TL,IL={LOADED_DATA:Mw.LOADEDDATA,MEDIA_TRACK_CHANGED:"media-track-changed",PLAYER_STATE_CHANGED:"player-state-changed"},AL="trtc_autoplay",RL="".concat(AL,"_mask"),bL="".concat(AL,"_wrapper"),CL="".concat(AL,"_header"),kL="".concat(AL,"_content"),wL="".concat(AL,"_action_wrapper"),NL="".concat(AL,"_question"),DL="".concat(AL,"_collapse"),OL="".concat(AL,"_action_confirm"),LL="".concat(AL,"_detail"),PL="#2473E8",ML="dialog",xL="".concat(ML,"-show"),VL="".concat(ML,"-1"),UL="".concat(ML,"-2"),BL=!1,FL=()=>!!document.querySelector(".".concat(bL)),HL="".concat(vw,"/").concat(RD()?"zh-cn":"en","/tutorial-21-advanced-auto-play-policy.html"),jL="<br><a href='".concat(HL,"' target='_blank'>").concat(RD()?"其他方案?":"Any other solution?","</a>"),WL="".concat(RD()?"浏览器自动播放策略:在用户与页面产生交互(点击、触摸)之前,浏览器禁止播放有声媒体。该弹窗用于帮助用户恢复音视频播放。".concat(jL):"Autoplay Policy: Before user interacts with the web page (clicking, touching), page will not be allowed to play media with sound. This Dialog is used to help users resume playback. ".concat(jL)),zL=class{constructor(){if(tC(this,"content","音视频播放被浏览器拦截,请点击“恢复播放”。"),tC(this,"_dialogNode",null),tC(this,"_bodyPosition",""),tC(this,"_showDetail",!1),tC(this,"_isCollapseClicked",!1),tC(this,"_isQuestionClicked",!1),RD()||(this.content='Media playback failed. Click the "Resume" to resume playback.'),!BL){let e=document.createElement("style");e.innerHTML=".".concat(RL,"{position:fixed;top:0;left:0;right:0;bottom:0;width:100vw;height:100vh;display:flex;justify-content:center;align-items:center;background:rgba(0,0,0,0.5);z-index:1500;}.").concat(RL," div:not(.").concat(wL,"){display:block !important;}.").concat(bL,"{padding:14px;background:#fff;border-radius:3px;box-shadow:0px 3px 15px #434343;border:1px solid #d1cfcf;max-width:500px;}.").concat(bL," a{color:").concat(PL,";}.").concat(CL,"{overflow:hidden;text-overflow:ellipsis;font-size:16px;font-weight:600;}.").concat(kL,"{margin:8px 0;}.").concat(wL,"{width:100%;display:flex !important;align-items:center;justify-content:right;float:right;}.").concat(DL,"{margin-right:auto;cursor:pointer}.").concat(NL,"{height:100%;line-height:16px;cursor:pointer;}.").concat(OL,"{margin-left:8px;color:#fff;background:").concat(PL,";padding:4px 12px;outline:none;border:1px solid;border-radius:3px;font-weight:bold;}.").concat(OL,":hover{opacity:0.9;}.").concat(DL,",.").concat(OL,",.").concat(kL,",.").concat(NL,"{font-size:14px;}@media screen and (max-width:750px){.").concat(bL,"{width:80vw;}}"),document.head.appendChild(e),BL=!0}this.addDiaLog()}createDiaLog(){let e=document.createElement("template");e.innerHTML='<div class="'.concat(RL,"\"><div class='").concat(bL,"'><div class='").concat(CL,"'>").concat(location.host,"</div><div class='").concat(kL,"'>").concat(this.content,"</div><div class='").concat(LL,'\' style="visibility:hidden;width:100%;height:0;font-size:12px;color:gray;">').concat(WL,"</div><div class='").concat(wL,"'></div></div></div>").trim();let t=document.createElement("button");t.className=OL,t.innerText=RD()?"恢复播放":"Resume",t.onclick=this.onConfirm.bind(this);let i=document.createElement("div");i.className=NL,i.innerHTML='<?xml version="1.0" encoding="UTF-8"?>\n <svg class="icon" width="18" height="18" p-id="2030" t="1639646523624" version="1.1" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">\n <path d="m464 784.35c0 26.51 21.49 48 48 48s48-21.49 48-48-21.49-48-48-48-48 21.49-48 48z" p-id="2031"/>\n <path d="m512 960c-247.04 0-448-200.96-448-448s200.96-448 448-448 448 200.96 448 448-200.96 448-448 448zm0-831.71c-211.58 0-383.71 172.13-383.71 383.71 0 211.55 172.13 383.71 383.71 383.71 211.55 0 383.71-172.16 383.71-383.71 0-211.58-172.16-383.71-383.71-383.71z" p-id="2032"/>\n <path d="m512 673.7c-17.665 0-32.001-14.336-32.001-31.999v-54.112c0-52.353 40-92.352 75.328-127.65 25.887-25.92 52.672-52.672 52.672-74.017 0-53.343-43.072-96.735-95.999-96.735-53.823 0-95.999 41.536-95.999 94.559 0 17.665-14.336 31.999-32.001 31.999s-32.001-14.336-32.001-31.999c0-87.424 71.775-158.56 160-158.56s160 72.095 160 160.74c0 47.904-36.32 84.192-71.424 119.3-27.84 27.776-56.576 56.512-56.576 82.336v54.112c0 17.665-14.336 32.032-32.001 32.032z" p-id="2033"/>\n </svg>\n ',i.onclick=this.onQuestionClick.bind(this);let r=document.createElement("div");r.className=DL,r.innerText="".concat(RD()?"详情 >":"Detail >"),r.onclick=this.onCollapseClick.bind(this);let n=e.content.firstChild,o=n.querySelector(".".concat(wL));return o.appendChild(r),o.appendChild(i),o.appendChild(t),n}addDiaLog(){FL()||(this._dialogNode=this.createDiaLog(),document.body.appendChild(this._dialogNode),this._dialogNode.onclick=this.onConfirm.bind(this),this._dialogNode.querySelector(".".concat(bL)).onclick=e=>e.stopPropagation(),this._bodyPosition=document.body.style.position,document.body.style.position="fixed",EO.info("show autoplay dialog"),XN.uploadEvent({log:xL}))}deleteDiaLog(){this._dialogNode&&(document.body.removeChild(this._dialogNode),document.body.style.position=this._bodyPosition,this._dialogNode=null)}onConfirm(){EO.warn("confirm clicked, try resume stream"),JN.emit(fO.AUTOPLAY_DIALOG_CLICK_CONFIRM),this.deleteDiaLog()}onCollapseClick(){let e=this._dialogNode.querySelector(".".concat(LL));e.style.visibility="".concat(this._showDetail?"hidden":"visible"),e.style.height="".concat(this._showDetail?0:"fit-content"),this._showDetail=!this._showDetail,this._isCollapseClicked||XN.uploadEvent({log:VL}),this._isCollapseClicked=!0}onQuestionClick(){window.open(HL,"_blank"),this._isQuestionClicked||XN.uploadEvent({log:UL}),this._isQuestionClicked=!0}},GL={};Zb(GL,{create:()=>YL,remove:()=>JL});var KL=new WeakMap;function YL(e,t){KL.has(e)||KL.set(e,[]);let i=KL.get(e),r={add:(e,n)=>("addEventListener"in t?(i.push(t.removeEventListener.bind(t,e,n)),t.addEventListener(e,n)):(i.push(t.off.bind(t,e,n)),t.on(e,n)),r)};return r}function JL(e){let t=KL.get(e);t&&(t.forEach((e=>e())),KL.delete(e))}var qL=class extends gL{constructor(e,t){super(e.id,"".concat(t,"-player")),this.kind=t,tC(this,"id"),tC(this,"element",null),tC(this,"track"),tC(this,"url"),tC(this,"attr"),tC(this,"muted"),tC(this,"_log"),tC(this,"_pausedRetryCount"),tC(this,"_isElementPlayingFired",!1),tC(this,"_interval"),this.id=e.id,this._log=e.log,this.track=e.track,this.muted=e.muted,this._pausedRetryCount=RN,this._state="STOPPED",this.bindTrackEvents(),this._log.info("create ".concat(t,"-player ").concat(this.id))}get isPlaying(){return"PLAYING"===this._state}get isStopped(){return"STOPPED"===this._state}setAttr(e){this.attr=e}setUrl(e){this.track&&(this.unbindTrackEvents(),this.element&&(this.element.srcObject=null),this.track=null),e!==this.url&&(this.url=e,null!==e&&this.element&&(this.element.crossOrigin="anonymous",this.element.src=e))}play(){return rC(this,null,(function*(){if(!this.isPlaying)try{this.bindAutoPlayEvent(),yield this.element.play()}catch(e){let t=GN({key:HN.PLAY_FAILED,data:{media:this.kind,error:e}});if(this.track&&!this.track.muted&&this._log.warn(e),t.includes("NotAllowedError"))throw new fC({code:_C.PLAY_NOT_ALLOWED,message:t})}}))}stop(){this.unbindEvents(),this._isElementPlayingFired=!1,this.element&&(this.element.remove(),this.element.srcObject=null,this.element=null),this.handleStopped(Mw.ENDED),this._interval>0&&SL.clearTask(this._interval)}pause(){var e;this.isPlaying&&(null==(e=this.element)||e.pause())}resume(){return this.isPlaying?Promise.resolve():Kk?this.replay():this.play().catch((()=>{}))}setMuted(e){this.element&&(this.element.muted=e),this.muted=e}replay(){return this.stop(),this.play().catch((()=>{}))}bindElementEvents(){if(this.element){let e=this.handleElementEvent.bind(this);return YL(this.element,this.element).add(Mw.PLAYING,e).add(Mw.ENDED,e).add(Mw.PAUSE,e).add(Mw.ERROR,e).add(Mw.LOADEDDATA,e)}}bindTrackEvents(){if(this.track){let e=this.handleTrackEvent.bind(this);null==GL||GL.create(this.track,this.track).add(Mw.ENDED,e).add(Mw.MUTE,e).add(Mw.UNMUTE,e),this.track.readyState===Mw.ENDED&&this.handleTrackEvent({type:Mw.ENDED}),this.track.muted&&this.handleTrackEvent({type:Mw.MUTE})}}bindAutoPlayEvent(){JN.on(fO.AUTOPLAY_DIALOG_CLICK_CONFIRM,this.resume,this)}unbindTrackEvents(){this.track&&JL(this.track)}unbindEvents(){this.element&&JL(this.element),this.unbindTrackEvents(),JN.off(fO.AUTOPLAY_DIALOG_CLICK_CONFIRM,this.resume,this)}handleElementEvent(e){var t;switch(e.type){case Mw.PLAYING:this._isElementPlayingFired=!0,this._log.info("".concat(this.kind," player is playing")),this.handlePlaying(Mw.PLAYING),this._interval&&(SL.clearTask(this._interval),this._interval=-1);break;case Mw.ENDED:this._log.info("".concat(this.kind," player is ended")),this.handleStopped(Mw.ENDED);break;case Mw.PAUSE:this._log.info("".concat(this.kind," player is paused")),this.handlePaused(Mw.PAUSE);let e=this.container&&document.getElementById(this.container.id);e||this._log.warn("".concat(this.kind," player has been remove, element ID: ").concat(null==(t=this.container)?void 0:t.id));let i=Lk();this._pausedRetryCount>0&&(this.kind===Mw.VIDEO&&!FL()||this.kind===Mw.AUDIO&&(LD(i)&&i<=70||!e))&&(this._log.info("".concat(this.kind," player auto resume when paused")),this.resume(),this._pausedRetryCount--),PC&&(this._interval=SL.run(xN,(()=>{this.element&&"PAUSED"===this._state&&this.resume()}),{delay:3e3}));break;case Mw.ERROR:if(this.element&&this.element.error){let{code:e,message:t}=this.element.error;this._log.error("".concat(this.kind," player error observed. code: ").concat(e," message: ").concat(t," userAgent: ").concat(navigator.userAgent)),XN.uploadEvent({log:"stat-".concat(this.kind,"-").concat(lN.PLAYER_ERROR,"-").concat(e,"-").concat(navigator.userAgent),error:this.element.error})}break;case Mw.LOADEDDATA:this.kind===Mw.VIDEO&&this.emit(IL.LOADED_DATA)}}handleTrackEvent(e){switch(e.type){case Mw.ENDED:this._log.info("".concat(this.kind," track is ended")),this.handleStopped(Mw.ENDED);break;case Mw.MUTE:this._log.info("".concat(this.kind," track is unable to provide media output")),this.handlePaused(Mw.MUTE);break;case Mw.UNMUTE:this._log.info("".concat(this.kind," track is able to provide media output")),this._isElementPlayingFired&&this.handlePlaying(Mw.UNMUTE)}}handlePlaying(e){this.emit(IL.PLAYER_STATE_CHANGED,{type:this.kind,state:"PLAYING",reason:e})}handlePaused(e){this.emit(IL.PLAYER_STATE_CHANGED,{type:this.kind,state:"PAUSED",reason:e})}handleStopped(e){this.emit(IL.PLAYER_STATE_CHANGED,{type:this.kind,state:"STOPPED",reason:e})}getElement(){return this.element}};eC([mL([],"PLAYING",{sync:!0})],qL.prototype,"handlePlaying",1),eC([mL("PLAYING","PAUSED",{ignoreError:!0,sync:!0})],qL.prototype,"handlePaused",1),eC([mL([],"STOPPED",{sync:!0})],qL.prototype,"handleStopped",1);var XL=class extends qL{constructor(e){super(e,Mw.VIDEO),tC(this,"viewMirror",!1),tC(this,"objectFit"),tC(this,"container"),tC(this,"canvas"),this.container=e.container,this.canvas=e.canvas,DD(e.viewMirror)||(this.viewMirror=e.viewMirror),DD(e.objectFit)||(this.objectFit=e.objectFit),this.initializeElement()}initializeElement(){var e;let t=document.createElement(Mw.VIDEO);this.track&&(t.srcObject=new MediaStream([this.track])),t.muted=!0,t.setAttribute("id","video_".concat(this.id)),t.setAttribute("style",this.styleAttribute),this.canvas&&this.canvas.setAttribute("style",this.styleAttribute),t.setAttribute("autoplay","autoplay"),t.setAttribute("playsinline","playsinline"),this.element=t,null==(e=this.container)||e.appendChild(this.elementToRender),this.bindElementEvents()}get styleAttribute(){let e="width: 100%; height: 100%; object-fit: ".concat(this.objectFit,";background-color: black;");return this.viewMirror&&(e+="transform: scaleX(-1);"),e}setContainer(e){var t;this.container=e,this.track&&this.elementToRender&&(null==(t=this.container)||t.appendChild(this.elementToRender))}bindElementEvents(){let e=super.bindElementEvents();this.handleElementEvent=this.handleElementEvent.bind(this),e&&e.add(Mw.ENTER_PICTURE_IN_PICTURE,this.handleElementEvent).add(Mw.LEAVE_PICTURE_IN_PICTURE,this.handleElementEvent)}handleElementEvent(e){super.handleElementEvent(e);let t=e.type;if(this.viewMirror&&this.element){let e=this.element.style.transform;t===Mw.ENTER_PICTURE_IN_PICTURE?this.element.style.transform=e.replace("scaleX(-1)",""):t===Mw.LEAVE_PICTURE_IN_PICTURE&&!e.includes("scaleX")&&(this.element.style.transform="".concat(e," scaleX(-1)"))}}setCanvas(e){var t,i;this.canvas!==e&&(null==(t=this.canvas)||t.remove(),null==e||e.setAttribute("style",this.styleAttribute),this.canvas=e,e&&(null==(i=this.container)||i.appendChild(e)))}setAttr(e){let t=Object.assign({autoplay:"autoplay",playsinline:"playsinline",muted:!0},e);t.style=Object.assign({width:"100%",height:"100%"},t.style),super.setAttr(t)}get mirror(){return this.viewMirror}setRect(e,t){this.elementToRender&&(this.elementToRender.style.width="".concat(e,"px"),this.elementToRender.style.height="".concat(t,"px"))}setViewMirror(e){this.elementToRender&&(this.elementToRender.style.transform=e?"scaleX(-1)":""),this.viewMirror=e}setObjectFit(e){this.elementToRender&&(this.elementToRender.style.objectFit="".concat(e)),this.objectFit=e}stop(){var e;this.setContainer(null),super.stop(),null==(e=this.canvas)||e.remove()}play(){return this.element?this.elementToRender&&this.elementToRender.parentElement!==this.container&&this.container&&this.container.append(this.elementToRender):this.initializeElement(),super.play()}get elementToRender(){return this.canvas||this.element}setTrack(e){e!==this.track&&(this.unbindTrackEvents(),this.track=e,this.emit(IL.MEDIA_TRACK_CHANGED,e),null!==e&&(this.bindTrackEvents(),this.element&&(this.element.srcObject=new MediaStream([e]),this.element.remove()),this.elementToRender&&this.elementToRender.parentElement!==this.container&&this.container&&this.container.append(this.elementToRender)))}getVideoFrame(){if(this.canvas)return this.canvas.toDataURL("image/png");if(!this.element)return"";let e=document.createElement("canvas");return e.width=this.element.videoWidth,e.height=this.element.videoHeight,e.getContext("2d").drawImage(this.element,0,0),e.toDataURL("image/png")}getElement(){return this.element}};function QL(e,t){return rC(this,null,(function*(){if(!e.audioWorklet)return Promise.reject("audioWorklet is not supported");try{yield e.audioWorklet.addModule(t),EO.info("worklet addModule success")}catch(i){throw EO.info("worklet addModule catch error. ".concat(i.message)),i}}))}"undefined"!=typeof window&&(window.AudioContext=window.AudioContext||window.webkitAudioContext||window.mozAudioContext);var ZL=new window.AudioContext({sampleRate:48e3}),$L=()=>{"suspended"===ZL.state?(ZL.resume(),document.addEventListener("click",$L)):"interrupted"===ZL.state?ZL.resume():document.removeEventListener("click",$L)};document.addEventListener("click",$L),ZL.onstatechange=()=>{EO.info("context state: ".concat(ZL.state)),$L()};var eP,tP,iP,rP=e=>ZL,nP=class{constructor(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.countMap=new Map,this.distributionMap=new Map,this.log=EO.createLogger({id:"kv"}),e&&(JN.on("102",(e=>{let{track:t,cost:i}=e;this.addSuccessEvent({key:t.kind===Mw.AUDIO?lP.START_MICROPHONE:dP.START_CAMERA,cost:i})})),JN.on("103",(e=>{let{track:t,error:i}=e;this.addFailedEvent({key:t.kind===Mw.AUDIO?lP.START_MICROPHONE:dP.START_CAMERA,error:i})})))}getReportData(){let e={msg_sdk_basic_info:{uint32_sdk_version:uO(this.version||ow),uint32_terminal_type:15,bytes_device_name:"",bytes_os_version:"",uint32_framework:30,uint32_network_type:0},stats_count:[...this.countMap.entries()].map((e=>{let[t,i]=e;return{uint32_key:t,uint32_count:i}})),stats_distribution:[...this.distributionMap.entries()].map((e=>{let[t,i]=e;return{uint32_key:t,distribution_items:[...i.entries()].map((e=>{let[t,i]=e;return{uint32_item_key:t,uint32_item_value:i}}))}}))};return this.countMap.clear(),this.distributionMap.clear(),e}clear(){this.countMap.clear(),this.distributionMap.clear()}isEnumKey(e){let t=+String(e).slice(-3);return t>=700&&t<799}isErrorCodeKey(e){let t=+String(e).slice(-3);return t>=600&&t<699}isCountKey(e){let t=+String(e).slice(-3);return t>=0&&t<599}isNumberKey(e){let t=+String(e).slice(-3);return t>=800&&t<899}addCount(e){let{key:t,useUV:i=!1}=e;this.isCountKey(t)?i&&this.countMap.has(t)||this.countMap.set(t,(this.countMap.get(t)||0)+1):this.log.debug("".concat(t," is not count key, last 3 number should be 0~599"))}addEnum(e){let{key:t,value:i,useUV:r=!0}=e;var n;if(!this.isEnumKey(t))return this.log.debug("".concat(t," is not enum key, last 3 number should be 700~799"));if(r&&this.countMap.has(t))return;this.countMap.set(t,(this.countMap.get(t)||0)+1);let o=(null==(n=this.distributionMap)?void 0:n.get(t))||new Map;o.set(i,(o.get(i)||0)+1),this.distributionMap.set(t,o)}addNumber(e){let{key:t,value:i,split:r=100,useUV:n=!1}=e;var o;if(!this.isNumberKey(t))return this.log.debug("".concat(t," is not number key, last 3 number should be 800~899"));if(n&&this.countMap.has(t))return;this.countMap.set(t,(this.countMap.get(t)||0)+1);let s=(null==(o=this.distributionMap)?void 0:o.get(t))||new Map,a=0;if(LD(r))a=Math.floor(i/r);else for(let c=r.length-1;c>0;c--)if(i>r[c]){a=c;break}s.set(a,(s.get(a)||0)+1),this.distributionMap.set(t,s)}addSuccessEvent(e){let{key:t,cost:i,timeKey:r,split:n}=e;if(t&&(this.addEnum({key:t,value:1,useUV:!1}),i)){let e=+String(t).slice(-3);e<800&&e>=700?this.addNumber({key:r||t+100,value:i,split:n}):r||this.log.debug("time stat ignored, ".concat(t))}}addFailedEvent(e){let{key:t,error:i}=e;if(!t)return;let r=_C.UNKNOWN;LD(i)?r=i:(!DD(i.extraCode)||!DD(i.code))&&(r=i.extraCode||i.code),this.addEnum({key:t,value:0,useUV:!1}),this.addEnum({key:t,value:r,useUV:!1})}},oP=((tP=oP||{})[tP.enterRoom=500700]="enterRoom",tP[tP.exitRoom=500701]="exitRoom",tP[tP.switchRole=500702]="switchRole",tP[tP.destroy=500703]="destroy",tP[tP.startLocalAudio=500704]="startLocalAudio",tP[tP.updateLocalAudio=500705]="updateLocalAudio",tP[tP.stopLocalAudio=500706]="stopLocalAudio",tP[tP.startLocalVideo=500707]="startLocalVideo",tP[tP.updateLocalVideo=500708]="updateLocalVideo",tP[tP.stopLocalVideo=500709]="stopLocalVideo",tP[tP.startScreenShare=500710]="startScreenShare",tP[tP.updateScreenShare=500711]="updateScreenShare",tP[tP.stopScreenShare=500712]="stopScreenShare",tP[tP.startRemoteVideo=500713]="startRemoteVideo",tP[tP.updateRemoteVideo=500714]="updateRemoteVideo",tP[tP.stopRemoteVideo=500715]="stopRemoteVideo",tP[tP.muteRemoteAudio=500716]="muteRemoteAudio",tP[tP.setRemoteAudioVolume=500717]="setRemoteAudioVolume",tP),sP=((eP=sP||{})[eP.AudioMixer=550700]="AudioMixer",eP[eP.AIDenoiser=551700]="AIDenoiser",eP[eP.VirtualBackground=570700]="VirtualBackground",eP[eP.Beauty=571700]="Beauty",eP[eP.Watermark=572700]="Watermark",eP),aP=(e=>(e[e.AudioMixer=550701]="AudioMixer",e[e.AIDenoiser=551701]="AIDenoiser",e[e.VirtualBackground=570701]="VirtualBackground",e[e.Beauty=571701]="Beauty",e[e.Watermark=572701]="Watermark",e))(aP||{}),cP=(e=>(e[e.AudioMixer=550702]="AudioMixer",e[e.AIDenoiser=551702]="AIDenoiser",e[e.VirtualBackground=570702]="VirtualBackground",e[e.Beauty=571702]="Beauty",e[e.Watermark=572702]="Watermark",e))(cP||{}),lP=(e=>(e[e.START_MICROPHONE=501700]="START_MICROPHONE",e[e.MICROPHONE_CAHNNELS=501701]="MICROPHONE_CAHNNELS",e[e.MICROPHONE_SAMPLERATE=501702]="MICROPHONE_SAMPLERATE",e))(lP||{}),dP=((iP=dP||{})[iP.START_CAMERA=511700]="START_CAMERA",iP),uP=new nP(!0),hP=new nP(!1),pP=uP,mP=class{constructor(){this.pre=new Set,this.next=new Set,this.connectedNodes=new Set}setContext(e){this.context=e,this.node&&e.addMixWeight()}removeContext(){var e;this.node&&(null==(e=this.context)||e.reduceMixWeight()),delete this.context}setNode(e){var t;if(!this.node)try{null==(t=this.context)||t.addMixWeight(),this.node=e,this.preNodeReconnect(),this.reconnect(),pP.addSuccessEvent({key:502701})}catch(i){EO.error(i),pP.addFailedEvent({key:502701,error:i})}}deleteNode(){var e;if(this.node)try{this._disconnect(),delete this.node,null==(e=this.context)||e.reduceMixWeight(),this.preNodeReconnect(),pP.addSuccessEvent({key:502702})}catch(t){EO.error(t),pP.addFailedEvent({key:502702,error:t})}}preNodeReconnect(){this.pre.forEach((e=>{e.node?e.reconnect():e.preNodeReconnect()}))}connectNext(e){this.next.forEach((t=>e._connect(t.node)||t.connectNext(e)))}_connect(e){return!(!this.node||!e||(this.node.connect(e),this.connectedNodes.add(e),0))}_disconnect(){this.connectedNodes.forEach((e=>{var t;return null==(t=this.node)?void 0:t.disconnect(e)})),this.connectedNodes.clear()}reconnect(){this._disconnect(),this.connectNext(this)}pipeTo(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return t.forEach((e=>{this.next.add(e),e.pre.add(this)})),this}},_P=class extends mP{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:256;super(),this.fftSize=e,this.dataArray=new Uint8Array(0)}setNode(e){e.fftSize=this.fftSize,this.dataArray=new Uint8Array(e.frequencyBinCount),super.setNode(e)}getByteTimeDomainData(){var e;return null==(e=this.node)||e.getByteTimeDomainData(this.dataArray),this.dataArray}get level(){var e;return null==(e=this.node)||e.getByteTimeDomainData(this.dataArray),Math.max(...this.dataArray)/128-1}get timeDomainPathData(){let e=this.getByteTimeDomainData(),t=0,i=0,r="M".concat(t,",").concat(i);for(let n=0;n<e.length;n++)i=e[n]/128*100/2,r+="L".concat(t,",").concat(i),t+=1;return r}},fP=class{constructor(){this.source=new mP,this.gain=new mP,this.destination=new mP}get volume(){var e;return(null==(e=this.gain.node)?void 0:e.gain.value)||1}setVolume(e){1!==e?(this.gain.node||this.gain.setNode(this.source.node.context.createGain()),this.gain.node.gain.value=e):this.gain.node&&this.gain.deleteNode()}replaceSource(e){this.source.deleteNode(),this.source.setNode(function(e){let t=vP.get(e);if(t)return t;let i=rP();if(e instanceof HTMLAudioElement)t=i.createMediaElementSource(e);else{if(!(e instanceof MediaStreamTrack))return e;t=i.createMediaStreamSource(new MediaStream([e]))}return vP.set(e,t),t}(e))}get track(){var e;return null==(e=this.stream)?void 0:e.getAudioTracks()[0]}get stream(){var e;return null==(e=this.destination.node)?void 0:e.stream}},gP=class extends fP{constructor(e){super(),this.context=e,this.denoiser=new mP,this.source.pipeTo(this.denoiser.pipeTo(this.gain.pipeTo(this.destination)))}connect(){this.context.inputs.has(this)||(this.destination.setNode(this.context.destination),this.source.setContext(this.context),this.denoiser.setContext(this.context),this.gain.setContext(this.context),this.context.inputs.add(this))}disconnect(){!this.context.inputs.has(this)||(this.destination.deleteNode(),this.source.removeContext(),this.denoiser.removeContext(),this.gain.removeContext(),this.context.inputs.delete(this))}remove(){this.gain.deleteNode(),this.denoiser.deleteNode(),this.source.deleteNode(),this.disconnect()}setVolume(e){1!==e?(this.gain.node||this.gain.setNode(this.context.audioContext.createGain()),this.gain.node.gain.value=e):this.gain.node&&this.gain.deleteNode()}},EP=class{constructor(){this.audioContext=rP(),this.destination=this.audioContext.createMediaStreamDestination(),this.inputs=new Set,this.mixWeight=0,this.destination.channelCount=1}addMixWeight(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this.mixWeight+=e,this.mixWeight-1==e+1>>1&&this.mixOnChange()}reduceMixWeight(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this.addMixWeight(-e)}close(){this.inputs.forEach((e=>e.remove()))}get mixTrack(){return this.destination.stream.getAudioTracks()[0]}},vP=new WeakMap,yP=class{constructor(e){tC(this,"_volume",0),tC(this,"_log"),tC(this,"_scriptProcessorNode",null),tC(this,"_audioWorkletNode",null),tC(this,"_interval",200),tC(this,"ready",this.preload());let{log:t}=e;this._log=t,JN.on(fO.AUDIO_LEVEL_INTERVAL,this.handleAudioLevelInterval,this)}get node(){return this._audioWorkletNode||this._scriptProcessorNode}preload(){return yP.workletReady||(yP.workletReady=QL(yP.audioContext,URL.createObjectURL(new Blob(['class VolumeMeter extends AudioWorkletProcessor{constructor(){super(),this.volume=0,this.intervalTime=200,this.tick=this.intervalTime,this.isStop=!1,this.port.onmessage=t=>{let{data:e}=t;switch(e.name){case"setIntervalTime":this.intervalTime=e.intervalTime;break;case"stop":this.isStop=!0}}}process(t){let e=t[0];if(this.isStop)return!1;if(e.length>0){let i=e[0],s=0;for(let l=0;l<i.length;++l)s=Math.max(Math.abs(i[l]),s);this.volume=s,this.tick-=i.length,this.tick<0&&(this.tick+=this.intervalTime/1e3*sampleRate,this.port.postMessage({volume:this.volume}))}return!0}}registerProcessor("volume-meter",VolumeMeter);'],{type:"application/javascript"})))),yP.workletReady.then((()=>this.initAudioWorklet())).catch((()=>this.initScriptProcessor()))}initAudioWorklet(){if(!this._audioWorkletNode)try{this._audioWorkletNode=new AudioWorkletNode(yP.audioContext,"volume-meter"),this._audioWorkletNode.port.onmessage=e=>{this._volume=e.data.volume||0},this.handleAudioLevelInterval({interval:this._interval})}catch(e){XN.logFailedEvent({userId:this._log.userId,eventType:lN.LOAD_WORKLET,error:e}),this.initScriptProcessor()}}initScriptProcessor(){if(!this._scriptProcessorNode)try{this._scriptProcessorNode=rP().createScriptProcessor(2048,1,1),this._scriptProcessorNode.onaudioprocess=e=>{let t=e.inputBuffer.getChannelData(0),i=0;for(let r=0;r<t.length;++r)i+=t[r]*t[r];this._volume=Math.sqrt(i/t.length)||0}}catch(e){this._log.error("volumeMeter init script processor error: ".concat(e))}}destroy(){this._scriptProcessorNode&&(this._scriptProcessorNode.onaudioprocess=null),this._audioWorkletNode&&(this._audioWorkletNode.port.postMessage({name:"stop"}),this._audioWorkletNode.port.onmessage=null),this._audioWorkletNode=null,this._scriptProcessorNode=null,JN.off(fO.AUDIO_LEVEL_INTERVAL,this.handleAudioLevelInterval,this)}getInternalAudioLevel(){return this._volume}getCalculatedVolume(){return parseFloat(this._volume.toFixed(2))}handleAudioLevelInterval(e){var t;let{interval:i}=e;this._interval=i,null==(t=this._audioWorkletNode)||t.port.postMessage({name:"setIntervalTime",intervalTime:i})}},TP=yP;tC(TP,"audioContext",rP()),tC(TP,"workletReady");var SP=class extends mP{constructor(e){super(),tC(this,"_volumeMeter"),this._volumeMeter=new TP(e)}deleteNode(){this._volumeMeter.destroy(),super.deleteNode()}init(){return rC(this,null,(function*(){yield this._volumeMeter.preload(),this.setNode(this._volumeMeter.node)}))}getCalculatedVolume(){return this._volumeMeter.getCalculatedVolume()}getInternalAudioLevel(){return this._volumeMeter.getInternalAudioLevel()}},IP=class extends fP{constructor(e){super(),this.log=e,tC(this,"volumeMeter"),tC(this,"analyser",new _P),this.volumeMeter=new SP({log:this.log})}destory(){this.gain.deleteNode(),this.volumeMeter.deleteNode(),this.analyser.deleteNode(),this.source.deleteNode(),this.destination.deleteNode()}},AP=class extends qL{constructor(e){super(e,Mw.AUDIO),tC(this,"_outputDeviceId"),tC(this,"_volume",1),tC(this,"_destination",rP().createMediaStreamDestination()),tC(this,"pipeline"),tC(this,"volumeMeterMode","worklet"),this.pipeline=new IP(this._log)}getMediaStream(){return this.pipeline.stream||(this.track?new MediaStream([this.track]):null)}initializeElement(){if(("15.2"===Wk||"15.3"===Wk||"15.4"===Wk)&&this.muted)return void this._log.info("audioElement is muted.");let e=new Audio;e.setAttribute("autoplay","autoplay"),e.srcObject=this.getMediaStream(),e.muted=this.muted,this.element=e,this.bindElementEvents()}play(){return rC(this,null,(function*(){if(this.track)return this.pipeline.source.node||this.pipeline.replaceSource(this.track),this.element||this.initializeElement(),this._outputDeviceId&&(yield this.setSinkId(this._outputDeviceId)),"worklet"===this.volumeMeterMode?this.pipeline.volumeMeter.init():"analyser"===this.volumeMeterMode&&this.pipeline.analyser.setNode(rP().createAnalyser()),this.setVolume(this._volume),iC(AP.prototype,this,"play").call(this)}))}stop(){this.pipeline.destory(),super.stop()}setSinkId(e){return rC(this,null,(function*(){var t,i;this._outputDeviceId!==e&&(this._outputDeviceId=e),this.element&&this.element.sinkId!==e&&(yield null==(i=(t=this.element).setSinkId)?void 0:i.call(t,e))}))}get useDestination(){return!!this.pipeline.stream}setLoop(e){!this.element||(this.element.loop=e)}getAudioLevel(){return this.pipeline.volumeMeter.getCalculatedVolume()}getInternalAudioLevel(){return this.pipeline.volumeMeter.getInternalAudioLevel()}},RP=class extends AP{constructor(e){super(e),this.pipeline.source.pipeTo(this.pipeline.volumeMeter,this.pipeline.destination)}setTrack(e){this.track!==e&&(this.unbindTrackEvents(),this.track=e,this.emit(IL.MEDIA_TRACK_CHANGED,e),e?(this.bindTrackEvents(),this.pipeline.replaceSource(e),!this.useDestination&&this.element&&(this.element.srcObject=new MediaStream([e]))):this.pipeline.source.deleteNode())}setSourceNode(e){!e||this.pipeline.source.node===e||(this.pipeline.replaceSource(e),e instanceof MediaStreamAudioSourceNode?this.pipeline.destination.setNode(this._destination):this.pipeline.destination.deleteNode(),this.element&&(this.element.srcObject=this.getMediaStream(),this.element.play().catch((()=>{})),this.setVolume(this._volume)))}setVolume(e){this._volume=e,this.element&&(this.element.volume=e)}},bP=class extends AP{constructor(e){super(e),tC(this,"_sourceElement"),this.pipeline.source.pipeTo(this.pipeline.gain.pipeTo(this.pipeline.volumeMeter,this.pipeline.destination))}setTrack(e){this.track!==e&&(this.unbindTrackEvents(),this.track=e,this.emit(IL.MEDIA_TRACK_CHANGED,e),e?(this.bindTrackEvents(),this._sourceElement?this._sourceElement.srcObject=new MediaStream([e]):!this.useDestination&&this.element&&(this.element.srcObject=new MediaStream([e])),this.pipeline.replaceSource(e)):this.pipeline.source.deleteNode())}setVolume(e){this._volume=e,this.useDestination?(this.pipeline.setVolume(e),this._log.info("set pipeline volume: ".concat(e))):e<=1?(this.element?this._log.info("set element volume: ".concat(e)):this._log.info("set element volume: no element"),this.element&&(this.element.volume=e)):(this._log.info("start set pipeline volume: ".concat(e)),this.pipeline.setVolume(e),this.element&&!this._sourceElement&&(this.pipeline.destination.setNode(this._destination),JL(this.element),this._sourceElement=this.element,this._sourceElement.muted=!0,this.element=null,this.play()))}stop(){this.pipeline.destory(),this._sourceElement&&(this._sourceElement.srcObject=null,delete this._sourceElement),super.stop()}},CP=class extends gL{constructor(e){let{userId:t,sdkAppId:i,mediaType:r,room:n,PlayerClass:o=(1===r?bP:XL)}=e;var s;super(),tC(this,"id",vO()),tC(this,"userId",""),tC(this,"isRemote"),tC(this,"mediaType"),tC(this,"room"),tC(this,"user"),tC(this,"_log"),tC(this,"_inputTrack"),tC(this,"_outputTrack"),tC(this,"isPlayCalled"),tC(this,"container",null),tC(this,"player"),tC(this,"subVideoPlayerMap"),tC(this,"muted",!1),tC(this,"abortCtrl"),tC(this,"objectFit","cover"),tC(this,"mirror"),tC(this,"isScreen",!1),tC(this,"manager"),tC(this,"trackSettings"),this.userId=t||"",this.mediaType=r,this._log=EO.createLogger({id:"".concat(this.kind[0],"t"),userId:null==(s=n||this.room)?void 0:s.userId,remoteUserId:this instanceof eM?void 0:this.userId,sdkAppId:i,type:2===this.mediaType?"auxiliary":"main",isLocal:this instanceof eM}),this.player=new o({track:null,muted:!1,container:null,id:this.userId||this.id,log:this.log}),this.player.on(IL.PLAYER_STATE_CHANGED,(e=>{JN.emit(fO.PLAYER_STATE_CHANGED,qb({track:this},e)),this.emit("player-state-changed",e)})),this.kind===Mw.VIDEO&&(this.player.on(IL.LOADED_DATA,(()=>{JN.emit(fO.VIDEO_LOADED_DATA,{track:this})})),this.player.on(IL.MEDIA_TRACK_CHANGED,(e=>{var t;null==(t=this.subVideoPlayerMap)||t.forEach((t=>t.setTrack(e)))})))}get log(){return this._log||EO}get kind(){return 1===this.mediaType?Mw.AUDIO:Mw.VIDEO}get strMediaType(){return 4===this.mediaType?Mw.VIDEO:2===this.mediaType?Mw.SCREEN:Mw.AUDIO}get streamType(){return 2&this.mediaType?"auxiliary":"main"}play(e,t){return rC(this,null,(function*(){let i=xD(e)?e[0]:e;if(this.isPlayCalled)return this.log.info("play update options: ".concat(JSON.stringify(t))),t&&!DD(t.muted)&&this.setPlayerMute(t.muted),t&&!DD(t.objectFit)&&(this.objectFit=t.objectFit),void(this.player instanceof XL&&(this.player.setObjectFit(this.objectFit),this.container!==i&&i&&(this.container=i,this.player.setContainer(i)),xD(e)&&e.length>=1&&(yield this.playSubContainer(e.slice(1),t))));if(t&&!DD(t.muted)?this.setPlayerMute(t.muted):(!this.isRemote||this.kind===Mw.VIDEO)&&this.setPlayerMute(!0),t&&!DD(t.objectFit)&&(this.objectFit=t.objectFit),this.kind===Mw.VIDEO&&this.player.setObjectFit(this.objectFit),this.isPlayCalled=!0,i&&(this.container=i,this.player instanceof XL&&this.player.setContainer(i)),JN.emit(fO.PLAY_TRACK_START,{track:this}),this._outputTrack){this._log.info("play with options: ".concat(JSON.stringify(t)));try{this.player.setTrack(this.playerMediaTrack),yield this.player.play(),xD(e)&&e.length>1&&(yield this.playSubContainer(e.slice(1),t))}catch(r){throw this.handleAutoPlayFailed(),this.emit("error",r),r}}else this.log.info("play has not mediaTrack, abort")}))}setMirror(e,t){if(this.isScreen||this.kind!==Mw.VIDEO||DD(e)||e===this.mirror)return;this.mirror=e;let i=this.player;if(t&&(i=t),PD(this.mirror))return i.setViewMirror(this.mirror),void(this.room&&(this.room.videoManager.mirror=!1));switch(this.mirror){case"view":this.room&&(this.room.videoManager.mirror=!1),i.setViewMirror(!0);break;case"publish":this.room&&(this.room.videoManager.mirror=!0),i.setViewMirror(!0);break;case"both":this.room&&(this.room.videoManager.mirror=!0),i.setViewMirror(!1)}}playSubContainer(e,t){return rC(this,null,(function*(){if(!this._outputTrack||this.kind===Mw.AUDIO)return;this.subVideoPlayerMap||(this.subVideoPlayerMap=new Map),this.subVideoPlayerMap.forEach(((t,i)=>{var r;e.find((e=>i===e))||(t.stop(),null==(r=this.subVideoPlayerMap)||r.delete(i))}));for(let[r,n]of e.entries()){let e=this.subVideoPlayerMap.get(n);e?t&&(DD(t.objectFit)||e.setObjectFit(t.objectFit)):this.subVideoPlayerMap.set(n,new XL({id:this.userId||this.id,track:this.playerMediaTrack,container:n,muted:this.player.muted,objectFit:this.objectFit,log:this.log.createChild({id:"vp-sub".concat(r+1)})}))}let i=[...this.subVideoPlayerMap.values()];for(let e of i)e.setViewMirror(this.player.mirror),yield e.play()}))}setAudioOutput(e){return this.player.setSinkId(e)}setAudioVolume(e){this.player.setVolume(e)}getAudioLevel(){return this.player.getAudioLevel()||0}getInternalAudioLevel(){var e;return(null==(e=this.player)?void 0:e.getInternalAudioLevel())||0}stop(){!this.isPlayCalled||(this.isPlayCalled=!1,this.player&&(this.log.info("stop ".concat(this.kind," player")),this.player.stop()),this.subVideoPlayerMap&&this.subVideoPlayerMap.size>0&&this.subVideoPlayerMap.forEach((e=>{e.stop()})),this.container=null)}resume(){return rC(this,null,(function*(){var e;!this.isPlayCalled||(yield null==(e=this.player)?void 0:e.resume())}))}close(){this.log.info("close"),this.isPlayCalled&&this.stop()}setMute(e){this.muted=e,this._inputTrack&&(this._inputTrack.enabled=!e),this._outputTrack&&(this._outputTrack.enabled=!e),this.emit(e?"mute":"unmute",this),JN.emit(e?fO.TRACK_MUTED:fO.TRACK_UNMUTED,{track:this})}setPlayerMute(e){this.player.setMuted(e)}get mediaTrack(){return this._inputTrack||null}get outMediaTrack(){return this._outputTrack||null}get playerMediaTrack(){return this.outMediaTrack}setInputMediaStreamTrack(e){var t;let i=this._inputTrack;if(e!==i)return this._inputTrack=e,this.trackSettings=null==(t=e.getSettings)?void 0:t.call(e),e.enabled=!this.muted,this.emit("input-media-track-changed",e||null,i||null),this.manager?this.manager.changeInput(this):this.setOutputMediaStreamTrack(e)}setOutputMediaStreamTrack(e){var t;e!==this._outputTrack&&(this.isRemote?this.log.debug("setOutputMediaStreamTrack",e.label):this.log.info("setOutputMediaStreamTrack",null==(t=e.getSettings)?void 0:t.call(e).deviceId,e.label),this._outputTrack=e,this.updatePlayingState(!!e),this.emit("output-media-track-changed",e))}setMediaType(e){this.mediaType=e}updatePlayingState(e){if(this.isPlayCalled)if(e){if(this.player.setTrack(this.playerMediaTrack),this.player.isStopped)return this.player.play().catch((()=>this.handleAutoPlayFailed())),void this.log.info("playing state updated, play ".concat(this.kind))}else if(!this.player.isStopped)return this.player.stop(),void this.log.info("playing state updated, stop ".concat(this.kind));this.log.debug("updatePlayingState abort ".concat(this.isPlayCalled," ").concat(e," ").concat(this.player.isStopped))}handleAutoPlayFailed(){if(this.room&&this.room.enableAutoPlayDialog)new zL;else{let e=()=>{this.resume().then((()=>{document.removeEventListener("click",e,!0),document.removeEventListener("touchstart",e,!0)}))};document.addEventListener("click",e,!0),document.addEventListener("touchstart",e,!0)}}getVideoFrame(){return this.kind===Mw.VIDEO?this.player.getVideoFrame():""}};eC([mL([],gL.INIT,{sync:!0})],CP.prototype,"close",1);var kP=Object.prototype.hasOwnProperty,wP=function(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e||"function"==typeof e||Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(bD(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(let t in e)if(kP.call(e,t))return!1;return!0}return!1},NP=$b(nC(),1),DP=e=>t=>t.deviceId===e,OP=class{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Input";tC(this,"kind"),tC(this,"type"),tC(this,"devices",[]),this.kind=e,this.type=t}update(e,t){let i=e.filter((e=>e.kind==="".concat(this.kind).concat(this.type.toLocaleLowerCase())));1===this.devices.length&&MP(this.devices[0])||t&&(i.forEach((e=>{if(e.deviceId&&!this.devices.find(DP(e.deviceId))){let i="".concat(this.kind).concat(this.type,"Added");EO.warn("".concat(i,": ").concat(JSON.stringify(e))),t.emit(i,e)}})),this.devices.forEach((e=>{if(e.deviceId&&!i.find(DP(e.deviceId))){let i="".concat(this.kind).concat(this.type,"Removed");EO.warn("".concat(i,": ").concat(JSON.stringify(e))),t.emit(i,e)}}))),this.devices=i}hasDevice(e){return!!this.devices.find((t=>t.deviceId===e))}},LP=class extends NP.EventEmitter{constructor(){super(),tC(this,"audioInputs",new OP(Mw.AUDIO)),tC(this,"videoInputs",new OP(Mw.VIDEO)),tC(this,"audioOutputs",new OP(Mw.AUDIO,"Output")),this.init(),navigator.mediaDevices&&(navigator.mediaDevices.addEventListener&&navigator.mediaDevices.addEventListener("devicechange",(()=>this.update())),"ondevicechange"in navigator.mediaDevices||SL.run(MN,(()=>{this.update()}),{delay:1e4}))}init(){xP().then((e=>{this.audioInputs.update(e),this.videoInputs.update(e),this.audioOutputs.update(e)}))}update(){return rC(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return function*(){let i=yield xP(t);return e.audioInputs.update(i,e),e.videoInputs.update(i,e),e.audioOutputs.update(i,e),e}()}))}},PP=uw||dw?null:new LP;function MP(e){return e.deviceId===e.groupId&&""===e.groupId}function xP(){return rC(this,arguments,(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return function*(){if(NO()||!kO())return[];let t=yield navigator.mediaDevices.enumerateDevices();if(0!==e){let r={audio:!1,video:!1};if(t.forEach((e=>{MP(e)&&(e.kind===Mw.AUDIO_INPUT?r.audio=!0:e.kind===Mw.VIDEO_INPUT&&(r.video=!0))})),2===e&&(r.audio=!1),1===e&&(r.video=!1),r.audio||r.video){let e;try{e=yield navigator.mediaDevices.getUserMedia(r)}catch(i){EO.debug("capture before getDevices failed: ",i)}t=yield navigator.mediaDevices.enumerateDevices(),null==e||e.getTracks().forEach((e=>e.stop()))}}return t.map(((e,t)=>{let i={kind:e.kind,deviceId:e.deviceId,groupId:e.groupId,label:e.label||"".concat(e.kind,"_").concat(t)};return e.deviceId.length>0&&FP.add("".concat(e.deviceId,"_").concat(e.kind)),e.getCapabilities&&(i.getCapabilities=()=>e.getCapabilities()),i}))}()}))}function VP(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return PP.update(e?1:0).then((e=>e.audioInputs.devices))}function UP(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return PP.update(e?2:0).then((e=>e.videoInputs.devices))}function BP(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return rC(this,null,(function*(){return PP.update(e?1:0).then((e=>e.audioOutputs.devices))}))}var FP=new Set;function HP(e,t){return rC(this,null,(function*(){let i=(yield VP()).find((e=>e.deviceId===bN));return(null==i?void 0:i.groupId)===e&&i.label===t}))}function jP(e,t){return rC(this,null,(function*(){let i=(t?yield UP():yield VP()).find((t=>t.deviceId===e));i&&ND(i.getCapabilities)&&EO.warn(oO(i.getCapabilities(),{keysToInclude:VN}))}))}function WP(e){if(!e.audio)return!1;if(e.useTrueAsConstraint)return!0;let t={echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,sampleRate:e.sampleRate};return!wP(e.microphoneId)&&(t.deviceId=e.useExactDeviceId?{exact:e.microphoneId}:e.microphoneId,e.useDeviceIdOnly)?t:(LD(e.channelCount)&&(t.channelCount=e.channelCount),PD(e.echoCancellation)&&!e.echoCancellation&&(t.echoCancellation=!1),PD(e.noiseSuppression)&&!e.noiseSuppression&&(t.noiseSuppression=!1),PD(e.autoGainControl)&&!e.autoGainControl&&(t.autoGainControl=!1),!!wP(t)||t)}function zP(e){if(!e.video)return!1;if(e.useTrueAsConstraint)return!0;let{maxResolution:t=!0}=e,i={};return e.cameraId?i.deviceId=e.useExactDeviceId?{exact:e.cameraId}:e.cameraId:e.facingMode&&(i.facingMode=e.facingMode),e.useDeviceIdOnly&&!wP(i)?i:(e.width&&(i.width={ideal:e.width},t&&!BC&&(i.width.max=e.width)),e.height&&(i.height={ideal:e.height},t&&!BC&&(i.height.max=e.height)),BC&&fk&&e.width&&e.height&&e.width*e.height<101376&&(i.width=e.width,i.height=e.height),e.frameRate&&(i.frameRate=e.frameRate),!!wP(i)||i)}var GP=YN({retryFunction:function(e){return rC(this,null,(function*(){let t={audio:WP(i=e),video:zP(i)};var i;EO.info("getUserMedia with constraints: ".concat(JSON.stringify(t)));let r=[],n=[],o=["label","deviceId"];t.audio&&(r=yield VP(),EO.info("microphones: ".concat(oO(r,{keysToInclude:o})))),t.video&&(n=yield UP(),EO.info("cameras: ".concat(oO(n,{keysToInclude:o}))));try{let e=yield navigator.mediaDevices.getUserMedia(t);return eL&&e.getTracks().forEach((e=>{EO.info("".concat(e.kind," capabilities: ").concat(oO(e.getCapabilities(),{keysToInclude:VN})))})),e}catch(s){let{message:t}=s;throw"NotFoundError"===s.name&&(e.video&&n&&0===n.length&&(t=GN({key:HN.CAMERA_NOT_FOUND})),e.audio&&r&&0===r.length&&(t=GN({key:HN.MICROPHONE_NOT_FOUND}))),new fC({code:_C.INITIALIZE_FAILED,name:s.name,message:t,constraint:s.constraint})}}))},settings:{retries:3,timeout:500},onError:e=>{let{error:t,retry:i,reject:r,retryFuncArgs:n,retriedCount:o}=e,s=o+1;"NotReadableError"===t.name||"OverconstrainedError"===t.name?(1===s?n[0].video&&(n[0].maxResolution=!1,n[0].frameRate&&(n[0].frameRate=n[0].frameRate>10?10:5)):2===s?n[0].useDeviceIdOnly=!0:3===s&&!n[0].useExactDeviceId&&(n[0].useTrueAsConstraint=!0),i()):r(t),n[0].microphoneId&&jP(n[0].microphoneId,!1),n[0].cameraId&&jP(n[0].cameraId,!0)},onRetrying:e=>{EO.warn("getUserMedia NotReadableError observed, retrying [".concat(e,"/3]"))},onRetryFailed:e=>{XN.logFailedEvent({eventType:lN.GET_USER_MEDIA_RETRY,error:e})},onRetrySuccess:e=>{XN.logSuccessEvent({eventType:lN.GET_USER_MEDIA_RETRY}),XN.uploadEvent({log:"stat-".concat(lN.GET_USER_MEDIA_RETRY,"-success-").concat(e)})}});function KP(e){return JP(((t,i)=>function(){for(var i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return rC(this,null,(function*(){return yield e.apply(this,r),t.apply(this,r)}))}))}function YP(e){return JP(((t,i)=>function(){for(var i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return rC(this,null,(function*(){return e.call(this,t.apply(this,r))}))}))}function JP(e){return function(t,i,r){return r.value=e(r.value,i),r}}var qP=new WeakMap,XP=new WeakMap;function QP(){return function(e,t,i){let r=i.value,n=e=>{let{fn:t,args:i,context:r,resolve:n,reject:o}=e;t.apply(r,i).then(n,o)};return i.value=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return new Promise(((e,i)=>{if(qP.has(this)){let o=qP.get(this),{length:s}=o;o.push({fn:r,args:t,context:this,resolve:e,reject:i}),0===s&&n({fn:r,args:t,context:this,resolve:e,reject:i})}else qP.set(this,[{fn:r,args:t,context:this,resolve:e,reject:i}]),n({fn:r,args:t,context:this,resolve:e,reject:i})})).finally((()=>{let e=qP.get(this);e&&(e.shift(),e[0]&&n(qb({},e[0])))}))},i}}function ZP(e){return function(t,i,r){let n=r.value;return r.value=function(){var t,i;let r=[];for(var o=arguments.length,s=new Array(o),a=0;a<o;a++)s[a]=arguments[a];return null==(t=qP.get(this))||t.forEach((e=>r.push(e))),null==(i=XP.get(this))||i.forEach((e=>e.forEach((e=>r.push(e))))),r.forEach((t=>{t.reject(new fC({code:_C.API_CALL_ABORTED,message:e}))})),qP.delete(this),XP.delete(this),n.apply(this,s)},r}}function $P(e){return function(t,i,r){let n=r.value,o=t=>LD(e)?t[e]:e(...t),s=e=>{let{fn:t,args:i,context:r,resolve:n,reject:a}=e;t.apply(r,i).then(n,a).finally((()=>{if(XP.has(r)&&XP.get(r).has(o(i))){let e=XP.get(r).get(o(i));e&&(e.shift(),e[0]&&s(qb({},e[0])))}}))};return r.value=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return new Promise(((e,i)=>{if(XP.has(this))if(XP.get(this).has(o(t))){let r=XP.get(this).get(o(t));if(r){let{length:o}=r;r.push({fn:n,args:t,context:this,resolve:e,reject:i}),0===o&&s({fn:n,args:t,context:this,resolve:e,reject:i})}}else XP.get(this).set(o(t),[{fn:n,args:t,context:this,resolve:e,reject:i}]),s({fn:n,args:t,context:this,resolve:e,reject:i});else{let r=new Map;r.set(o(t),[{fn:n,args:t,context:this,resolve:e,reject:i}]),XP.set(this,r),s({fn:n,args:t,context:this,resolve:e,reject:i})}}))},r}}var eM=class extends CP{constructor(e,t){super({mediaType:e,PlayerClass:t}),tC(this,"isRemote",!1),tC(this,"deviceId"),tC(this,"groupId",""),tC(this,"label",""),tC(this,"_isRecapturing",!1),tC(this,"_lastRecaptureTime",0),tC(this,"_onMuteTimeoutId",-1),tC(this,"profile"),this.onTrackMuted=this.onTrackMuted.bind(this),this.onTrackUnmuted=this.onTrackUnmuted.bind(this),this.onTrackEnded=this.onTrackEnded.bind(this)}get isPublished(){return"publish"===this.state}installTrackEvent(e){YL(e,e).add(Mw.MUTE,this.onTrackMuted).add(Mw.UNMUTE,this.onTrackUnmuted).add(Mw.ENDED,this.onTrackEnded),e.muted&&this.onTrackMuted(),e.readyState===Mw.ENDED&&this.onTrackEnded()}uninstallTrackEvent(e){JL(e)}setStateToCapture(){}capture(e){return rC(this,null,(function*(){var t;try{let i,r=zD();JN.emit(fO.LOCAL_TRACK_CAPTURE_START,{track:this}),e.customSource?(i=new MediaStream,i.addTrack(e.customSource)):(null==(t=this.mediaTrack)||t.stop(),i=yield GP(e));let n=i.getTracks()[0];return yield this.setInputMediaStreamTrack(n),e.customSource||(this.updateDeviceIdInUse(),this.listenDeviceChange()),JN.emit(fO.LOCAL_TRACK_CAPTURE_SUCCESS,{track:this,cost:zD()-r}),i}catch(i){throw JN.emit(fO.LOCAL_TRACK_CAPTURE_FAILED,{track:this,error:i}),this.log.error("getUserMedia error observed ".concat(i)),i}}))}setInputMediaStreamTrack(e){this.state===gL.INIT&&this.setStateToCapture(),this._inputTrack&&this.uninstallTrackEvent(this._inputTrack);let t=super.setInputMediaStreamTrack(e);return this.installTrackEvent(e),t}setOutputMediaStreamTrack(e){var t;return super.setOutputMediaStreamTrack(e),null==(t=this.room)?void 0:t.replaceTrack(this)}publish(e,t){return this.room=e,this.emit("4",{mediaType:this.strMediaType,state:"starting",prevState:"stopped"}),this.userId=e.userId,this._log.setUserId(e.userId),this._log.setSdkAppId(e.sdkAppId),t}unpublish(){this.room&&this.room.localTracks.delete(this),JN.emit(fO.LOCAL_TRACK_UNPUBLISHED,{track:this})}updateDeviceIdInUse(){return rC(this,null,(function*(){if(this.mediaTrack&&$O){let{deviceId:e,groupId:t}=this.mediaTrack.getSettings(),{label:i}=this.mediaTrack;(yield function(e){return rC(this,arguments,(function(e){let{newDeviceId:t,oldDeviceId:i,oldGroupId:r,oldLabel:n,kind:o}=e;return function*(){return t===i&&(o!==Mw.AUDIO||t!==bN||(yield HP(r,n)))}()}))}({newDeviceId:e,oldDeviceId:this.deviceId,oldGroupId:this.groupId,oldLabel:this.label,kind:this.kind}))||(this.deviceId=e,this.label=i,t&&(this.groupId=t),xP().then((t=>{let i=t.find((t=>t.deviceId===e));i&&this.emit("2",i)})))}}))}setProfile(e){this.log.info("setProfile",e),Object.assign(this.profile,e)}isNeedToRecapture(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return!(!this.deviceId||!this.mediaTrack||this.kind===Mw.AUDIO&&!function(e){if(e instanceof CanvasCaptureMediaStreamTrack||!(e instanceof MediaStreamTrack))return!1;let t=e.label.toLocaleLowerCase();if(t.includes("mic")||t.includes("麦克风"))return!0;let i="".concat(((null==e?void 0:e.getSettings())||{}).deviceId,"_").concat(Mw.AUDIO_INPUT);return!!FP.has(i)}(this.mediaTrack)||this.kind===Mw.VIDEO&&!function(e){if(e instanceof CanvasCaptureMediaStreamTrack||!(e instanceof MediaStreamTrack))return!1;let t=e.label.toLocaleLowerCase();if(t.includes("camera")||t.includes("webcam"))return!0;let i="".concat(((null==e?void 0:e.getSettings())||{}).deviceId,"_").concat(Mw.VIDEO_INPUT);return!!FP.has(i)}(this.mediaTrack)||this._isRecapturing||e&&fk&&Bk)}onTrackMuted(){if(cO(),this.isNeedToRecapture(!0)){if(Date.now()-this._lastRecaptureTime<ON)return void setTimeout((()=>this.onTrackMuted()),ON);this._onMuteTimeoutId=setTimeout((()=>rC(this,null,(function*(){var e;if(null!=(e=this.mediaTrack)&&e.muted){if((PC||MC)&&"visible"!==document.visibilityState)return;this.recapture(yield this.getRecoverCaptureDeviceId())}}))),5e3)}}onTrackUnmuted(){this._onMuteTimeoutId>0&&clearTimeout(this._onMuteTimeoutId)}onTrackEnded(){return rC(this,null,(function*(){if(this.isNeedToRecapture()){if(Date.now()-this._lastRecaptureTime<ON)return void setTimeout((()=>this.onTrackEnded()),ON);this.recapture(yield this.getRecoverCaptureDeviceId())}}))}recapture(e){return rC(this,null,(function*(){var t;if(this._isRecapturing||!this._inputTrack)return;this.log.warn("recapture trying"),null==(t=this._inputTrack)||t.stop(),this._isRecapturing=!0,this._lastRecaptureTime=Date.now();let i={useExactDeviceId:!0};if("user"===e||"environment"===e)i.facingMode=e;else{let t;("audio"===this.kind?yield VP():yield UP()).find((t=>t.deviceId===e))&&(t=e),i.deviceId=t}return this.capture(i).then((()=>{this._isRecapturing=!1,this.log.warn("recapture success"),this.emit("1",{deviceId:this.deviceId})})).catch((e=>{this._isRecapturing=!1,this.log.warn("recapture failed ".concat(e.message)),this.emit("5",e)}))}))}getRecoverCaptureDeviceId(){return rC(this,null,(function*(){let e=this instanceof rM;if(e&&this.facingMode)return this.facingMode;let{deviceId:t}=this;if(t){let i=(tM.get(t)||0)+1;if(tM.set(t,i),i>=3){let r=e?(yield UP()).find((e=>!tM.has(e.deviceId))):(yield VP()).find((e=>!tM.has(e.deviceId)));r&&(this.log.warn("".concat(t," capture fail ").concat(i," times, change new ").concat(r.deviceId)),t=r.deviceId)}}return t}))}close(){var e;super.close(),this._inputTrack&&(this._inputTrack.stop(),this.uninstallTrackEvent(this._inputTrack)),null==(e=this.manager)||e.removeInput(this)}};eC([mL(gL.INIT,"capture",{ignoreError:!0,sync:!0})],eM.prototype,"setStateToCapture",1),eC([QP()],eM.prototype,"capture",1),eC([mL("capture","publish",{ignoreError:!0,success(){this.room.localTracks.add(this),JN.emit(fO.LOCAL_TRACK_PUBLISHED,{track:this}),this.emit("4",{mediaType:this.strMediaType,state:"started",prevState:"starting"})},fail(e){let t="error",i=e.cause;i.message.includes("timeout")?t="timeout":i.code===_C.API_CALL_ABORTED&&(t="api-call"),this.emit("4",{mediaType:this.strMediaType,state:"stopped",prevState:"starting",reason:t,error:i})}})],eM.prototype,"publish",1),eC([JP((e=>function(){return rC(this,null,(function*(){let t="publish"===this.state?"started":"starting";e.call(this),this.emit("4",{mediaType:this.strMediaType,state:"stopped",prevState:t,reason:"api-call"}),2===this.mediaType&&(this.mediaType=4)}))})),mL([],"capture",{sync:!0})],eM.prototype,"unpublish",1);var tM=new Map;JN.on(fO.SWITCH_DEVICE_SUCCESS,(e=>{e.track.deviceId&&tM.delete(e.track.deviceId)}));var iM=class extends eM{constructor(e){super(1,RP),tC(this,"mediaType",1),tC(this,"volume",0),tC(this,"profile",{echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0,sampleRate:48e3,channelCount:1,bitrate:40}),tC(this,"playerMuted",!0),tC(this,"pipeline"),this.manager=e,this.pipeline=new gP(e)}getAudioLevel(){let e=(this.volume||super.getAudioLevel())*this.captureVolume;return e>1?1:e}get playerMediaTrack(){return this.mediaTrack}setInputMediaStreamTrack(e){return rC(this,null,(function*(){yield iC(iM.prototype,this,"setInputMediaStreamTrack").call(this,e);let t=this.trackSettings||{};pP.addEnum({key:501701,value:t.channelCount||0,useUV:!1}),pP.addEnum({key:501702,value:t.sampleRate||0,useUV:!1}),pP.addEnum({key:502700,value:0});let{sampleRate:i,channelCount:r}=t;this._log.info("local audio track input ".concat(JSON.stringify({sampleRate:i,channelCount:r}))),this.pipeline.replaceSource(e),this.updatePlayingState(!!e)}))}capture(e){let{deviceId:t,customSource:i,useExactDeviceId:r=!1}=e;return super.capture({video:!1,audio:!0,microphoneId:t,echoCancellation:this.profile.echoCancellation,autoGainControl:this.profile.autoGainControl,noiseSuppression:this.profile.noiseSuppression,sampleRate:this.profile.sampleRate,channelCount:this.profile.channelCount,useExactDeviceId:r,customSource:i})}switchDevice(e){return rC(this,null,(function*(){if(this.mediaTrack){if(this.deviceId===e){if(e!==bN)return;if(yield HP(this.groupId,this.label))return}try{this.log.info("switchDevice audio to: ".concat(e)),this.mediaTrack&&this.mediaTrack.stop(),yield this.capture({deviceId:e,useExactDeviceId:!0}),this.room&&(yield this.room.replaceTrack(this)),JN.emit(fO.SWITCH_DEVICE_SUCCESS,{track:this}),this.log.info("switch microphone success")}catch(t){throw this.log.error("switch microphone failed ".concat(t)),this.deviceId&&this.recapture(this.deviceId),t}}}))}listenDeviceChange(){PP&&!PP.listeners("audioInputRemoved").includes(this.handleMicrophoneRemoved)&&PP.on("audioInputRemoved",this.handleMicrophoneRemoved,this)}handleMicrophoneRemoved(e){return rC(this,null,(function*(){if(e.deviceId===this.deviceId){this.log.warn("current microphone is lost: ".concat(JSON.stringify(e)));let t=yield VP();t[0]?this.recapture(t[0].deviceId):PP.on("audioInputAdded",this.handleMicrophoneAdded,this)}}))}handleMicrophoneAdded(e){this.log.warn("microphone added: ".concat(JSON.stringify(e))),this.recapture(e.deviceId)}update3A(e){return rC(this,arguments,(function(e){var t=this;let{echoCancellation:i,noiseSuppression:r,autoGainControl:n}=e;return function*(){let e=!1;!DD(i)&&i!==t.profile.echoCancellation&&(t.profile.echoCancellation=i,e=!0),!DD(r)&&r!==t.profile.noiseSuppression&&(t.profile.noiseSuppression=r,e=!0),!DD(n)&&n!==t.profile.autoGainControl&&(t.profile.autoGainControl=n,e=!0),e&&t.deviceId&&(yield t.recapture(t.deviceId))}()}))}get captureVolume(){return this.pipeline.volume}setCaptureVolume(e){this.pipeline.setVolume(e/100),this.pipeline.gain.node&&pP.addEnum({key:502700,value:2}),this.resetPlayerSource()}enableTrackANS(e){if(!this._inputTrack)return;let t=this._inputTrack.getConstraints();return t.noiseSuppression=e,this._inputTrack.applyConstraints(t).catch((t=>this._log.warn("".concat(e?"enable":"disable"," ANS failed "),t)))}addDenoiser(e){var t;Vk<=92&&48e3!==(null==(t=this.trackSettings)?void 0:t.sampleRate)?this._log.warn("denoiser only support sampleRate 48000 before chrome 93"):(pP.addEnum({key:502700,value:1}),this.pipeline.denoiser.setNode(e),this.resetPlayerSource(),this.enableTrackANS(!1))}removeDenoiser(e){this.pipeline.denoiser.node===e&&(this.pipeline.denoiser.deleteNode(),this.resetPlayerSource(),this.enableTrackANS(!0))}resetPlayerSource(){this.player.setSourceNode(this.pipeline.gain.node||this.pipeline.denoiser.node||this.pipeline.source.node)}close(){this.pipeline.remove(),PP.off("audioInputAdded",this.handleMicrophoneAdded,this),PP.off("audioInputRemoved",this.handleMicrophoneRemoved,this),super.close()}},rM=class extends eM{constructor(e){super(4,XL),tC(this,"mediaType",4),tC(this,"profile",{width:640,height:480,frameRate:15,bitrate:500}),tC(this,"states",{bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0}),tC(this,"small"),tC(this,"isNeedToSetBandwidth"),tC(this,"muteImage"),tC(this,"manager"),this.manager=e;let t=()=>{this.isAllowed2k4k(this.profile)?this.room&&this.settings.height>=1440&&"publish"===this.state&&this.room.sendAbilityStatus({"2k4k":1}):(this.log.warn("Resolution is reset to 1080p, need to upgrade ability here https://cloud.tencent.com/document/product/647/85386"),this.setProfile(Xb(qb({},this.profile),{width:1920,height:1080})),this.applyProfile())};this.on("input-media-track-changed",t),this.on("publish",t)}get facingMode(){if($O&&this.mediaTrack)return this.mediaTrack.getSettings().facingMode}setMute(e){return rC(this,null,(function*(){var t,i,r;if(OD(e)){if(this.muteImage===e)return;yield null==(t=this.manager)?void 0:t.deleteWatermark("mute"),yield null==(i=this.manager)?void 0:i.setWatermark({x:0,y:0,width:this.settings.width,height:this.settings.height,type:"mute",zIndex:999,imageUrl:e}),this.muteImage=e,iC(rM.prototype,this,"setMute").call(this,!1)}else yield null==(r=this.manager)?void 0:r.deleteWatermark("mute"),this.muteImage=void 0,iC(rM.prototype,this,"setMute").call(this,e)}))}capture(e){let{deviceId:t,facingMode:i,useExactDeviceId:r=!1,customSource:n}=e;return super.capture({audio:!1,video:!0,facingMode:i||this.facingMode,cameraId:t,width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate,useExactDeviceId:r,customSource:n})}setProfile(e){let t=qb({},e),i=t.width>t.height;t.width*t.height<=19200&&MC&&Pk&&(this.log.warn("resolution is ".concat(t.width,"*").concat(t.height,", fallback to 240*180")),t.width=i?240:180,t.height=i?180:240,t.bitrate=Math.max(t.bitrate,150)),t.width*t.height>921600&&Yk&&(t.width=i?1280:720,t.height=i?720:1280,this.log.warn("reset to 1280 * 720 on iOS 13~14")),t.bitrate&&(this.isNeedToSetBandwidth=t.bitrate!==this.profile.bitrate),this.isAllowed2k4k(this.profile)?super.setProfile(t):(this.log.warn("Resolution is reset to 1080p, need to upgrade ability here https://cloud.tencent.com/document/product/647/85386"),super.setProfile(Xb(qb({},this.profile),{width:1920,height:1080})))}applyProfile(){var e;if(!this.mediaTrack)return;let t=this.settings;return t.height!==this.profile.height||t.width!==this.profile.width||t.frameRate!==this.profile.frameRate?null==(e=this.mediaTrack)?void 0:e.applyConstraints({width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate}).then((()=>{if(this.manager&&this.manager.changeInput(this),this.room&&this.settings.height>=1440&&"publish"===this.state&&this.room.sendAbilityStatus({"2k4k":1}),this.isNeedToSetBandwidth&&this.room&&this.room.setBandWidth)return this.isNeedToSetBandwidth=!1,this.room.setBandWidth({bandwidth:this.profile.bitrate,type:Mw.VIDEO,videoType:Mw.BIG})})):void 0}get settings(){let e={width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate};return $O&&this.mediaTrack&&Object.assign(e,this.mediaTrack.getSettings()),e}get scaleResolutionDownBy(){let{settings:e}=this;return e.width===this.profile.width&&e.height===this.profile.height?1:lO()&&this.profile.width>this.profile.height&&e.height>e.width?Math.max(e.width/this.profile.height,e.height/this.profile.width,1):Math.max(e.width/this.profile.width,e.height/this.profile.height,1)}isAllowed2k4k(e){var t;return!(this.room&&this.room.scheduleResult&&!this.isScreen&&!(e.height*e.width<3686400))||1===(null==(t=this.room.scheduleResult.trtcAutoConf)?void 0:t["2k4k"])}isNeedToSwitchDevice(e){return!(!this.mediaTrack||this.deviceId===e||this.facingMode===e)}switchDevice(e){return rC(this,null,(function*(){try{if(!this.isNeedToSwitchDevice(e))return;let t={useExactDeviceId:!0};"user"===e||"environment"===e?t.facingMode=e:t.deviceId=e,this.mediaTrack.stop(),yield this.capture(t),JN.emit(fO.SWITCH_DEVICE_SUCCESS,{track:this}),this.log.info("switch camera success")}catch(t){throw this.log.error("switch camera failed ".concat(t)),this.deviceId&&this.recapture(this.deviceId),t}}))}listenDeviceChange(){PP&&!PP.listeners("videoInputRemoved").includes(this.handleCameraRemoved)&&PP.on("videoInputRemoved",this.handleCameraRemoved,this)}handleCameraRemoved(e){return rC(this,null,(function*(){if(e.deviceId===this.deviceId){this.log.warn("current camera is lost: ".concat(JSON.stringify(e)));let t=yield UP();t[0]?this.recapture(t[0].deviceId):PP.on("videoInputAdded",this.handleCameraAdded,this)}}))}handleCameraAdded(e){return rC(this,null,(function*(){this.log.warn("camera added: ".concat(JSON.stringify(e))),this.recapture(e.deviceId)}))}play(e,t){return rC(this,null,(function*(){return DD(this.mirror)&&!this.isScreen&&this.setMirror("view"),iC(rM.prototype,this,"play").call(this,e,t)}))}close(){PP.off("videoInputAdded",this.handleCameraAdded,this),PP.off("videoInputRemoved",this.handleCameraRemoved,this),super.close()}},nM=vO();if(navigator.mediaDevices&&"setCaptureHandleConfig"in navigator.mediaDevices)try{navigator.mediaDevices.setCaptureHandleConfig({handle:nM,exposeOrigin:!0,permittedOrigins:["*"]})}catch(lB){}var oM,sM=function(e){return rC(this,null,(function*(){let t=null,i=function(e){let t={preferCurrentTab:"current-tab"===e.preferDisplaySurface,systemAudio:"include",selfBrowserSurface:"include",surfaceSwitching:"include"},i={width:Bk?{max:e.width}:{ideal:e.width,max:e.width},height:Bk?{max:e.height}:{ideal:e.height,max:e.height},frameRate:e.frameRate,displaySurface:e.preferDisplaySurface||"monitor"};if(t.video=i,e.systemAudio){let{echoCancellation:i=!0,noiseSuppression:r=!1,autoGainControl:n=!1}=e;t.audio={echoCancellation:i,noiseSuppression:r,autoGainControl:n,sampleRate:48e3}}return t}(e);EO.info("getDisplayMedia with constraints: ".concat(JSON.stringify(i)));let r=yield navigator.mediaDevices.getDisplayMedia(i);e.systemAudio&&0===r.getAudioTracks().length&&(Mk&&Vk<74||Bk||BC)&&EO.warn("Your browser not support capture system audio");let n=r.getVideoTracks()[0];if(n){if(e.frameRate)try{yield n.applyConstraints({frameRate:{min:e.frameRate,ideal:e.frameRate},width:e.width,height:e.height})}catch(o){EO.warn("screen applyConstraints failed: ".concat(o))}e.captureElement&&(yield function(e,t){return rC(this,null,(function*(){var i;if("CropTarget"in window&&"fromElement"in CropTarget&&ND(e.cropTo))try{if((null==(i=e.getCaptureHandle())?void 0:i.handle)!==nM)return;let r=yield CropTarget.fromElement(t);yield e.cropTo(r)}catch(r){EO.warn("cropTo target failed ".concat(r))}}))}(n,e.captureElement))}if(e.audio){let i=function(e){let t={echoCancellation:e.echoCancellation,autoGainControl:e.autoGainControl,noiseSuppression:e.noiseSuppression,sampleRate:e.sampleRate,channelCount:e.channelCount};return DD(e.microphoneId)||(t.deviceId=e.microphoneId),{audio:t,video:!1}}(e);EO.info("getUserMedia with constraints: ".concat(JSON.stringify(i))),t=yield navigator.mediaDevices.getUserMedia(i),r.addTrack(t.getAudioTracks()[0])}return r}))},aM=class extends rM{constructor(e){super(e),tC(this,"profile",{width:1920,height:1080,frameRate:5,bitrate:1600}),tC(this,"objectFit","contain"),tC(this,"isScreen",!0),this._log.id="s-".concat(this._log.id)}capture(e){return rC(this,arguments,(function(e){var t=this;let{systemAudio:i=!1,autoGainControl:r,echoCancellation:n,noiseSuppression:o,audioTrack:s,videoTrack:a,captureElement:c,preferDisplaySurface:l}=e;return function*(){try{let e;return a||s?(e=new MediaStream,a&&e.addTrack(a),s&&e.addTrack(s)):e=yield sM({audio:!1,systemAudio:i,width:t.profile.width,height:t.profile.height,frameRate:t.profile.frameRate,autoGainControl:r,echoCancellation:n,noiseSuppression:o,captureElement:c,preferDisplaySurface:l}),yield t.setInputMediaStreamTrack(e.getVideoTracks()[0]),e}catch(e){throw t.log.error("getDisplayMedia error observed ".concat(e)),e instanceof fC?e:new fC({code:_C.INITIALIZE_FAILED,name:e.name,message:e.message})}}()}))}switchDevice(e){return rC(this,null,(function*(){throw new Error("Method not implemented.")}))}},cM=class extends iM{constructor(e){super(e),this._log.id="s-".concat(this._log.id)}},lM=class extends EP{constructor(e){super(),this.room=e,tC(this,"_localAudioTrack"),tC(this,"_localScreenAudioTrack"),tC(this,"log",EO.createLogger({id:"am"})),tC(this,"denoiser"),e&&(this.log.setUserId(e.userId),this.log.setSdkAppId(e.sdkAppId))}get _localAudioPipline(){var e;return null==(e=this._localAudioTrack)?void 0:e.pipeline}dump(e){var t,i;if(!this._localAudioTrack)return;let r=[],n=[];null!=(t=this._localAudioPipline)&&t.source.node&&(r.push(this._localAudioPipline.source.node),n.push("mic")),null!=(i=this._localAudioPipline)&&i.denoiser.node&&(r.push(this._localAudioPipline.denoiser.node),n.push("mic-processed")),this.mixWeight>1&&(r.push(this.audioContext.createMediaStreamSource(this._localAudioPipline.stream)),n.push("mix")),this.log.info("dump audio track ".concat(n,", duration: ").concat(e));let o=new AbortController,s=[],a=setTimeout((()=>{this.log.info('dump audio track complete please input "download()" to download.'),o.abort("timeout")}),1e3*e),c=()=>{for(let e=0;e<n.length;e++){let t=URL.createObjectURL(new Blob(s[e])),i=document.createElement("a");i.href=t,i.download="".concat(n[e],".pcm"),i.style.display="none",document.body.appendChild(i),i.click(),URL.revokeObjectURL(t),i.remove()}clearTimeout(a),o.abort("download")},l=function(e){return rC(this,null,(function*(){let t=rP();oM||(oM=QL(t,URL.createObjectURL(new Blob(["registerProcessor('dumper', class extends AudioWorkletProcessor {process(inputs) {this.port.postMessage(inputs);return true;}});"],{type:"application/javascript"})))),yield oM;let i=new AudioWorkletNode(t,"dumper",{numberOfInputs:e.length,numberOfOutputs:0});return e.forEach(((e,t)=>e.connect(i,0,t))),new ReadableStream({start(e){i.port.onmessage=t=>{e.enqueue(t.data)}},cancel(){e.forEach((e=>e.disconnect(i))),i.port.close()}})}))}(r).then((e=>e.pipeTo(new WritableStream({write(e){e.forEach(((e,t)=>s[t]=s[t]?s[t].concat(e[0]):[e[0]]))}}),o).catch((e=>c))));return{then:l.then.bind(l),download:c}}get hasScreenAudioTrack(){return null!==this._localScreenAudioTrack}get hasAudioTrack(){return null!==this._localAudioTrack}changeInput(e){var t;if(e instanceof cM)this._localScreenAudioTrack=e,e.pipeline.connect(),this.mixOnChange();else if(e instanceof iM)this._localAudioTrack=e,this.destination.channelCount=(null==(t=e.trackSettings)?void 0:t.channelCount)||1,this.denoiser&&e.addDenoiser(this.denoiser),e.pipeline.connect(),this.mixOnChange();else if(e instanceof hM)return e.setOutputMediaStreamTrack(e.mediaTrack)}mixOnChange(){var e,t;null==(e=this._localAudioTrack)||e.setOutputMediaStreamTrack(this.mixWeight>1?this.mixTrack:this._localAudioTrack.mediaTrack),null==(t=this._localScreenAudioTrack)||t.setOutputMediaStreamTrack(this.mixWeight>1?this.mixTrack:this._localScreenAudioTrack.mediaTrack)}removeInput(e){e instanceof cM?delete this._localScreenAudioTrack:e instanceof iM&&delete this._localAudioTrack}addDenoiser(e){var t;this.denoiser=e,null==(t=this._localAudioTrack)||t.addDenoiser(e)}removeDenoiser(e){var t;delete this.denoiser,null==(t=this._localAudioTrack)||t.removeDenoiser(e)}destroy(){this.close()}},dM=class extends CP{constructor(e,t,i){super({userId:t.userId,sdkAppId:e.sdkAppId,mediaType:i,room:e}),this.room=e,this.user=t,tC(this,"tinyId"),tC(this,"isRemote",!0),this.tinyId=t.tinyId}setMute(e){this.hasFlag&&super.setMute(e)}setInputMediaStreamTrack(e){super.setInputMediaStreamTrack(e),this.hasFlag&&this.isSubscribed&&this.player.setTrack(this.outMediaTrack)}waitHasMediaTrack(){return new Promise((e=>{this.mediaTrack?e():this.once("input-media-track-changed",e)}))}get isSubscribing(){return"subscribeing"===this.state.toString()}get isSubscribed(){return this.state===dM.STATE_SUBSCRIBE}subscribe(e){return e}unsubscribe(){this.player.setTrack(null),"main"===this.streamType&&"video"===this.kind&&this.room.changeType(!1,this.user)}updatePlayingState(e){if(this.isPlayCalled&&this.player.isStopped===e){if(e&&(!this.isSubscribed||!this.hasFlag||!this.outMediaTrack))return void this.log.info("abort play, isSubscribed:".concat(this.isSubscribed," hasFlag:").concat(this.hasFlag," hasTrack:").concat(!!this.outMediaTrack));super.updatePlayingState(e)}}onFlagChanged(){this.updatePlayingState(this.hasFlag)}},uM=dM;tC(uM,"STATE_SUBSCRIBE","subscribe"),eC([mL(gL.INIT,uM.STATE_SUBSCRIBE,{success(){this.log.info("subscribed"),JN.emit(fO.REMOTE_TRACK_SUBSCRIBED,{track:this}),this.updatePlayingState(!0)},ignoreError:!0})],uM.prototype,"subscribe",1),eC([mL(uM.STATE_SUBSCRIBE,gL.INIT,{sync:!0,success(){this.log.info("unsubscribed"),this.updatePlayingState(!1),JN.emit(fO.REMOTE_TRACK_UNSUBSCRIBED,{track:this})}})],uM.prototype,"unsubscribe",1);var hM=class extends uM{constructor(e,t){super(e,t,1),tC(this,"volume",0),tC(this,"mediaType",1),tC(this,"stat",{bytesReceived:0,packetsReceived:0,packetsLost:0,end2EndDelay:0,jitterBufferDelay:0}),this.manager=e.audioManager}getAudioLevel(){let e=this.volume||super.getAudioLevel();return e>1?1:e}get hasFlag(){return this.user.muteState.hasAudio&&!this.user.muteState.audioMuted}isFlagChanged(e){let t=e.hasAudio&&!e.audioMuted;return this.hasFlag||(this.volume=0),this.hasFlag!==t}},pM=class extends uM{constructor(e,t){super(e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:4),tC(this,"mediaType",4),tC(this,"stat",{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0,end2EndDelay:0,jitterBufferDelay:0}),this.manager=e.videoManager}get isBig(){return 4===this.mediaType}get isSmall(){return 8===this.mediaType}changeType(e){this.room.changeType(e,this.user)}get hasFlag(){return this.user.muteState.hasVideo&&!this.user.muteState.videoMuted}isFlagChanged(e){let t=e.hasVideo&&!e.videoMuted;return this.hasFlag!==t}setMirror(e){"publish"===e||"both"===e||super.setMirror(e)}},mM=class extends pM{constructor(e,t){super(e,t,2),tC(this,"mediaType",2),tC(this,"objectFit","contain")}get hasFlag(){return this.user.muteState.hasAuxiliary}isFlagChanged(e){let t=e.hasAuxiliary;return this.hasFlag!==t}};function _M(){}var fM=e=>e(),gM=()=>"undefined"!=typeof __FASTRX_DEVTOOLS__,EM=1,vM=class extends Function{toString(){return"".concat(this.name,"(").concat(this.args.length?[...this.args].join(", "):"",")")}subscribe(e){let t=new AM(e,this,this.streamId++);return RM.subscribe({id:this.id,end:!1},{nodeId:t.sourceId,streamId:t.id}),this(t),t}},yM=class{constructor(){this.defers=new Set,this.disposed=!1}next(e){}complete(){this.dispose()}error(e){this.dispose()}get bindDispose(){return()=>this.dispose()}dispose(){this.disposed=!0,this.complete=_M,this.error=_M,this.next=_M,this.dispose=_M,this.subscribe=_M,this.doDefer()}subscribe(e){return e instanceof vM?e.subscribe(this):e(this),this}get bindSubscribe(){return e=>this.subscribe(e)}doDefer(){this.defers.forEach(fM),this.defers.clear()}defer(e){this.defers.add(e)}removeDefer(e){this.defers.delete(e)}reset(){this.disposed=!1,delete this.complete,delete this.next,delete this.dispose,delete this.next,delete this.subscribe}resetNext(){delete this.next}resetComplete(){delete this.complete}resetError(){delete this.error}},TM=class extends yM{constructor(e){super(),this.sink=e,e.defer(this.bindDispose)}next(e){this.sink.next(e)}complete(){this.sink.complete()}error(e){this.sink.error(e)}};function SM(e,t,i){if(gM()){let r=Object.defineProperties(Object.setPrototypeOf(e,vM.prototype),{streamId:{value:0,writable:!0,configurable:!0},name:{value:t,writable:!0,configurable:!0},args:{value:i,writable:!0,configurable:!0},id:{value:0,writable:!0,configurable:!0}});RM.create(r);for(let e=0;e<i.length;e++){let t=i[e];"function"==typeof t&&t instanceof vM&&RM.addSource(r,t)}return r}return e}function IM(e,t){window.postMessage({source:"fastrx-devtools-backend",payload:{event:e,payload:t}})}var AM=class extends TM{constructor(e,t,i){super(e),this.source=t,this.id=i,this.sourceId=e.sourceId,this.defer((()=>{RM.defer(this.source,this.id)}))}next(e){RM.next(this.source,this.id,e),this.sink.next(e)}complete(){RM.complete(this.source,this.id),this.sink.complete()}error(e){RM.complete(this.source,this.id,e),this.sink.error(e)}},RM={addSource(e,t){IM("addSource",{id:e.id,name:e.toString(),source:{id:t.id,name:t.toString()}})},next(e,t,i){IM("next",{id:e.id,streamId:t,data:i&&i.toString()})},subscribe(e,t){let{id:i,end:r}=e;IM("subscribe",{id:i,end:r,sink:{nodeId:t&&t.nodeId,streamId:t&&t.streamId}})},complete(e,t,i){IM("complete",{id:e.id,streamId:t,err:i?i.toString():null})},defer(e,t){IM("defer",{id:e.id,streamId:t})},pipe(e){IM("pipe",{name:e.toString(),id:e.id,source:{id:e.source.id,name:e.source.toString()}})},update(e){IM("update",{id:e.id,name:e.toString()})},create(e){e.id||(e.id=EM++),IM("create",{name:e.toString(),id:e.id})}},bM=class extends yM{constructor(e){super(),this.source=e,this.sinks=new Set}add(e){e.defer((()=>this.remove(e))),1===this.sinks.add(e).size&&(this.reset(),this.subscribe(this.source))}remove(e){this.sinks.delete(e),0===this.sinks.size&&this.dispose()}next(e){this.sinks.forEach((t=>t.next(e)))}complete(){this.sinks.forEach((e=>e.complete())),this.sinks.clear()}error(e){this.sinks.forEach((t=>t.error(e))),this.sinks.clear()}},CM=function(e,t){return function(){for(var i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return i=>{if(i instanceof vM){let n=SM((t=>{let o=new e(t,...r);o.sourceId=n.id,o.subscribe(i)}),t,arguments);return n.source=i,RM.pipe(n),n}return t=>i(new e(t,...r))}}}(class extends TM{constructor(e,t,i){super(e),this.mapper=t,this.thisArg=i}next(e){super.next(this.mapper.call(this.thisArg,e))}},"map");!function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];i.reduce(((e,t)=>t(e)),e)}(function(e){return SM((t=>{let i=0,r=setInterval((()=>t.next(i++)),e);return t.defer((()=>{clearInterval(r)})),"interval"}),"interval",arguments)}(250),CM((()=>performance.now())),function(){return e=>{let t=new bM(e);if(e instanceof vM){let i=SM((e=>{t.add(e)}),"share",arguments);return t.sourceId=i.id,i.source=e,RM.pipe(i),i}return SM(t.add.bind(t),"share",arguments)}}());var kM=new Map;function wM(e,t){let i=Xb(qb({},t),{timestamp:EC()});kM.has(e)?kM.get(e).push(i):kM.set(e,[i])}JN.on(fO.JOIN_SUCCESS,(e=>{let{room:t}=e;wM(t.userId,{eventId:32788,eventDesc:"join room"})})),JN.on(fO.LEAVE_START,(e=>{let{room:t}=e;wM(t.userId,{eventId:32789,eventDesc:"leave room"})})),JN.on(fO.LOCAL_TRACK_PUBLISHED,(e=>{let{track:t}=e;if(t.room){let e=32769;4===t.mediaType?e=32768:2===t.mediaType&&(e=32805),wM(t.room.userId,{eventId:e,eventDesc:"publish ".concat(t.kind)})}})),JN.on(fO.LOCAL_TRACK_UNPUBLISHED,(e=>{let{track:t}=e;if(t.room){let e=32771;4===t.mediaType?e=32770:2===t.mediaType&&(e=32806),wM(t.room.userId,{eventId:e,eventDesc:"unpublish ".concat(t.kind)})}})),JN.on(fO.TRACK_MUTED,(e=>{let{track:t}=e;t.room&&(t.kind===Mw.AUDIO?wM(t.room.userId,{eventId:t.isRemote?32785:32772,eventDesc:"mute audio",remoteUserId:t.isRemote?t.userId:void 0}):wM(t.room.userId,{eventId:t.isRemote?32784:32773,eventDesc:"mute video",remoteUserId:t.isRemote?t.userId:void 0}))})),JN.on(fO.TRACK_UNMUTED,(e=>{let{track:t}=e;t.room&&(t.kind===Mw.AUDIO?wM(t.room.userId,{eventId:t.isRemote?32787:32774,eventDesc:"unmute audio",remoteUserId:t.isRemote?t.userId:void 0}):wM(t.room.userId,{eventId:t.isRemote?32786:32775,eventDesc:"unmute video",remoteUserId:t.isRemote?t.userId:void 0}))})),JN.on(fO.REMOTE_TRACK_SUBSCRIBED,(e=>{let{track:t}=e;!t.room||(1===t.mediaType&&wM(t.room.userId,{eventId:32777,eventDesc:"".concat(Mw.SUBSCRIBE," ").concat(t.kind),remoteUserId:t.userId}),4===t.mediaType&&wM(t.room.userId,{eventId:32776,eventDesc:"".concat(Mw.SUBSCRIBE," ").concat(t.kind),remoteUserId:t.userId}),8===t.mediaType&&wM(t.room.userId,{eventId:32803,eventDesc:"".concat(Mw.SUBSCRIBE," ").concat(Mw.SMALL_VIDEO),remoteUserId:t.userId}))})),JN.on(fO.REMOTE_TRACK_UNSUBSCRIBED,(e=>{let{track:t}=e;!t.room||(1===t.mediaType&&wM(t.room.userId,{eventId:32779,eventDesc:"".concat(Mw.UNSUBSCRIBE," ").concat(t.kind),remoteUserId:t.userId}),4===t.mediaType&&wM(t.room.userId,{eventId:32778,eventDesc:"".concat(Mw.UNSUBSCRIBE," ").concat(t.kind),remoteUserId:t.userId}),8===t.mediaType&&wM(t.room.userId,{eventId:32804,eventDesc:"".concat(Mw.UNSUBSCRIBE," ").concat(Mw.SMALL_VIDEO),remoteUserId:t.userId}))})),JN.on(fO.SWITCH_DEVICE_SUCCESS,(e=>{let{track:t}=e;t.room&&wM(t.room.userId,{eventId:t.kind===Mw.VIDEO?32780:32781,eventDesc:"switch ".concat(t.kind===Mw.VIDEO?"camera":"microphone")})})),JN.on(fO.LOCAL_TRACK_REPLACED,(e=>{let{track:t}=e;t.room&&wM(t.room.userId,{eventId:t.kind===Mw.VIDEO?32782:32783,eventDesc:"replace ".concat(t.kind)})})),JN.on(fO.SIGNAL_CONNECTION_STATE_CHANGED,(e=>{let t,i,{room:r,prevState:n,state:o}=e;switch(o){case"CONNECTED":"RECONNECTING"===n?(t=32795,i="signal reconnected"):(t=32791,i="signal connected");break;case"DISCONNECTED":"RECONNECTING"===n?(t=32796,i="signal reconnect fail"):(t=32790,i="signal disconnected");break;case"RECONNECTING":t=32794,i="signal reconnecting"}t&&i&&wM(r.userId,{eventId:t,eventDesc:i})})),JN.on(fO.PEER_CONNECTION_STATE_CHANGED,(e=>{let t,i,{room:r,prevState:n,state:o,remoteUserId:s}=e,a=!!s,c=a?"downlink":"uplink";switch(o){case"CONNECTED":"RECONNECTING"===n?(t=a?32801:32798,i="".concat(c," reconnected")):(t=a?32793:32792,i="".concat(c," connected"));break;case"DISCONNECTED":"RECONNECTING"===n&&(t=a?32802:32799,i="".concat(c," reconnect fail"));break;case"RECONNECTING":t=a?32800:32797,i="".concat(c," reconnecting")}t&&i&&wM(r.userId,{eventId:t,eventDesc:i,remoteUserId:s})}));var NM,DM=$b(nC(),1),OM=class extends DM.EventEmitter{constructor(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"userId";super(),this.mySelfId=e,this._log=t,this.key=i,tC(this,"userMap",new Map),tC(this,"remotePublishedUserMap",new Map)}getPublishedUser(e){return this.remotePublishedUserMap.get(e)}addUser(e){let t=e[this.key],{userId:i,tinyId:r,role:n}=e;if(this.userMap.has(t))return;let o={userId:i,tinyId:r,role:20===n?"anchor":"audience"};this.userMap.set(t,o),this.emit("1",o)}deleteUser(e,t){let i=this.userMap.get(e);if(!i)return;let r="peer leave [".concat(e,"]");DD(t)||(r+=":".concat(NN[t])),this._log.info(r);let n=this.remotePublishedUserMap.get(e);if(n){let t=n.muteState;n.flag=0,this.emit("5",n.userId),this.deleteRemotePublishedUser(e),this.emit("6",{prevMuteState:t,muteState:n.muteState,flag:0})}this.userMap.delete(e),this.emit("2",i.userId)}setUserList(e){this.userMap.forEach((t=>{e.findIndex((e=>e[this.key]===t[this.key]))<0&&this.deleteUser(t[this.key],0)})),e.forEach((e=>{!this.userMap.has(e[this.key])&&e[this.key]!==this.mySelfId&&this.addUser(e)}))}addRemotePublishedUser(e){this.remotePublishedUserMap.has(e[this.key])||this.remotePublishedUserMap.set(e[this.key],e)}deleteRemotePublishedUser(e){!this.remotePublishedUserMap.has(e)||this.remotePublishedUserMap.delete(e)}setRemotePublishedUserList(e){this.remotePublishedUserMap.forEach((t=>{let i=t[this.key];if(e.findIndex((e=>e[this.key]===t[this.key]))<0){this._log.info("remote [".concat(i,"] unpublish"));let e=t.muteState;t.flag=0,this.emit("5",t.userId),this.deleteRemotePublishedUser(i),this.emit("6",{prevMuteState:e,muteState:t.muteState,flag:0})}})),e.forEach((e=>{var t;let i=e[this.key];if(i===this.mySelfId)return;let{flag:r,userId:n,tinyId:o}=e,s=qD(r,n),a=null==(t=this.remotePublishedUserMap.get(i))?void 0:t.muteState;if(a){let e=this.remotePublishedUserMap.get(i);e&&e.flag!==r&&(e.flag=r,this._log.info("remote publish updated: ".concat(JSON.stringify(e.muteState))),this.emit("6",{prevMuteState:a,muteState:s,flag:r}))}else this._log.info("remote publish. state: ".concat(JSON.stringify(s))),this.addUser({userId:n,tinyId:o,role:20}),this.emit("3",e),this.emit("6",{prevMuteState:qD(0,n),muteState:s,flag:r})}))}clear(){this.userMap.clear(),this.remotePublishedUserMap.clear()}},LM=!0,PM={SCENE_LIVE:"live",SCENE_RTC:"rtc",ROLE_ANCHOR:"anchor",ROLE_AUDIENCE:"audience",STREAM_TYPE_MAIN:"main",STREAM_TYPE_SUB:"sub",AUDIO_PROFILE_STANDARD:"standard",AUDIO_PROFILE_STANDARD_STEREO:"standard-stereo",AUDIO_PROFILE_HIGH:"high",AUDIO_PROFILE_HIGH_STEREO:"high-stereo",QOS_PREFERENCE_SMOOTH:"smooth",QOS_PREFERENCE_CLEAR:"clear"},MM={INVALID_PARAMETER:5e3,INVALID_OPERATION:5100,ENV_NOT_SUPPORTED:5200,DEVICE_ERROR:5300,SERVER_ERROR:5400,OPERATION_FAILED:5500,OPERATION_ABORT:5998,UNKNOWN_ERROR:5999},xM=((NM=xM||{})[NM.INVALID_PARAMETER=5e3]="INVALID_PARAMETER",NM[NM.INVALID_PARAMETER_REQUIRED=5001]="INVALID_PARAMETER_REQUIRED",NM[NM.INVALID_PARAMETER_TYPE=5002]="INVALID_PARAMETER_TYPE",NM[NM.INVALID_PARAMETER_EMPTY=5003]="INVALID_PARAMETER_EMPTY",NM[NM.INVALID_PARAMETER_INSTANCE=5004]="INVALID_PARAMETER_INSTANCE",NM[NM.INVALID_PARAMETER_RANGE=5005]="INVALID_PARAMETER_RANGE",NM[NM.INVALID_PARAMETER_LESS_THAN_ZERO=5006]="INVALID_PARAMETER_LESS_THAN_ZERO",NM[NM.INVALID_PARAMETER_MIN=5007]="INVALID_PARAMETER_MIN",NM[NM.INVALID_PARAMETER_MAX=5008]="INVALID_PARAMETER_MAX",NM[NM.INVALID_ELEMENT_ID=5009]="INVALID_ELEMENT_ID",NM[NM.INVALID_ELEMENT_ID_TYPE=5010]="INVALID_ELEMENT_ID_TYPE",NM[NM.INVALID_STREAM_ID=5011]="INVALID_STREAM_ID",NM[NM.INVALID_ROOM_ID_STRING=5012]="INVALID_ROOM_ID_STRING",NM[NM.INVALID_ROOM_ID_INTEGER=5013]="INVALID_ROOM_ID_INTEGER",NM[NM.INVALID_STREAM_TYPE=5014]="INVALID_STREAM_TYPE",NM[NM.INVALID_ROOM_ID_REQUIED=5015]="INVALID_ROOM_ID_REQUIED",NM[NM.INVALID_ROOM_ID_INTEGER_STRING=5016]="INVALID_ROOM_ID_INTEGER_STRING",NM[NM.INVALID_OPERATION=5100]="INVALID_OPERATION",NM[NM.INVALID_OPERATION_NOT_JOINED=5101]="INVALID_OPERATION_NOT_JOINED",NM[NM.INVALID_OPERATION_REMOTE_USER_NOT_EXIST=5102]="INVALID_OPERATION_REMOTE_USER_NOT_EXIST",NM[NM.INVALID_OPERATION_STREAM_TYPE_NOT_EXIST=5103]="INVALID_OPERATION_STREAM_TYPE_NOT_EXIST",NM[NM.INVALID_OPERATION_REPEAT_CALL=5104]="INVALID_OPERATION_REPEAT_CALL",NM[NM.INVALID_OPERATION_NEED_VIDEO=5105]="INVALID_OPERATION_NEED_VIDEO",NM[NM.INVALID_OPERATION_NEED_AUDIO=5106]="INVALID_OPERATION_NEED_AUDIO",NM[NM.ENV_NOT_SUPPORTED=5200]="ENV_NOT_SUPPORTED",NM[NM.NOT_SUPPORTED_HTTP=5201]="NOT_SUPPORTED_HTTP",NM[NM.NOT_SUPPORTED_WEBRTC=5202]="NOT_SUPPORTED_WEBRTC",NM[NM.NOT_SUPPORTED_H264_ENCODE=5203]="NOT_SUPPORTED_H264_ENCODE",NM[NM.NOT_SUPPORTED_H264_DECODE=5204]="NOT_SUPPORTED_H264_DECODE",NM[NM.NOT_SUPPORTED_SCREEN_SHARE=5205]="NOT_SUPPORTED_SCREEN_SHARE",NM[NM.NOT_SUPPORTED_SMALL_VIDEO=5206]="NOT_SUPPORTED_SMALL_VIDEO",NM[NM.NOT_SUPPORTED_SEI=5207]="NOT_SUPPORTED_SEI",NM[NM.NOT_SUPPORTED_WEBGL=5208]="NOT_SUPPORTED_WEBGL",NM[NM.NOT_SUPPORTED_CHROME_VERSION=5209]="NOT_SUPPORTED_CHROME_VERSION",NM[NM.DEVICE_ERROR=5300]="DEVICE_ERROR",NM[NM.DEVICE_NOT_FOUND_ERROR=5301]="DEVICE_NOT_FOUND_ERROR",NM[NM.DEVICE_NOT_ALLOWED_ERROR=5302]="DEVICE_NOT_ALLOWED_ERROR",NM[NM.DEVICE_NOT_READABLE_ERROR=5303]="DEVICE_NOT_READABLE_ERROR",NM[NM.DEVICE_OVERCONSTRAINED_ERROR=5304]="DEVICE_OVERCONSTRAINED_ERROR",NM[NM.DEVICE_INVALID_STATE_ERROR=5305]="DEVICE_INVALID_STATE_ERROR",NM[NM.DEVICE_SECURITY_ERROR=5306]="DEVICE_SECURITY_ERROR",NM[NM.DEVICE_ABORT_ERROR=5307]="DEVICE_ABORT_ERROR",NM[NM.CAMERA_RECOVER_FAILED=5308]="CAMERA_RECOVER_FAILED",NM[NM.MICROPHONE_RECOVER_FAILED=5309]="MICROPHONE_RECOVER_FAILED",NM[NM.SERVER_ERROR=5400]="SERVER_ERROR",NM[NM.NEED_TO_BUY=5401]="NEED_TO_BUY",NM[NM.ACCOUNT_NO_MONEY=-100013]="ACCOUNT_NO_MONEY",NM[NM.OPERATION_FAILED=5500]="OPERATION_FAILED",NM[NM.FIREWALL_RESTRICTION=5501]="FIREWALL_RESTRICTION",NM[NM.REJOIN_FAILED=5502]="REJOIN_FAILED",NM[NM.EVENT_HANDLER_ERROR=5503]="EVENT_HANDLER_ERROR",NM[NM.VIDEO_CONTEXT_ERROR=5504]="VIDEO_CONTEXT_ERROR",NM[NM.OPERATION_ABORT=5998]="OPERATION_ABORT",NM[NM.UNKNOWN_ERROR=5999]="UNKNOWN_ERROR",NM),VM=Xb(qb({},jN),{INVALID_PARAMETER(e){let{fnName:t}=e;return"the parameters of the '".concat(t,"' you called does not meet the requirements, please check the API documentation.")},INVALID_PARAMETER_REQUIRED(e){let{key:t,rule:i,fnName:r,value:n}=e;return"'".concat(t||i.name,"' is a required param when calling ").concat(r,"(), received: ").concat(n,".")},INVALID_PARAMETER_TYPE(e){let{key:t,rule:i,fnName:r,value:n}=e,o="".concat(t||i.name),s="";return s=Array.isArray(i.type)?i.type.join("|"):i.type,"'".concat(o,"' must be type of ").concat(s," when calling ").concat(r,"(), received type: ").concat(wD(n),".")},INVALID_PARAMETER_EMPTY(e){let{key:t,rule:i,fnName:r,value:n}=e;return"'".concat(t||i.name,"' cannot be '").concat(n,"' when calling ").concat(r,"().")},INVALID_PARAMETER_INSTANCE(e){let{key:t,rule:i,fnName:r,value:n}=e,o="".concat(t||i.name),s="".concat(i.instanceOf.name||i.instanceOf);return"'".concat(o,"' must be instanceof ").concat(s," when calling ").concat(r,"(), received type: ").concat(wD(n),".")},INVALID_PARAMETER_RANGE(e){let{key:t,rule:i,fnName:r,value:n}=e;return"'".concat(t||i.name,"' must be one of ").concat(i.values.join("|")," when calling ").concat(r,"(), received: ").concat(n,".")},INVALID_PARAMETER_LESS_THAN_ZERO(e){let{key:t,rule:i,fnName:r}=e;return"'".concat(t||i.name,"' cannot be less than 0 when calling ").concat(r,"().")},INVALID_PARAMETER_MIN(e){let{key:t,rule:i,value:r}=e;return"the min value of ".concat(t||i.name," is ").concat(i.min,", received: ").concat(r,".")},INVALID_PARAMETER_MAX(e){let{key:t,rule:i,value:r}=e;return"the max value of ".concat(t||i.name," is ").concat(i.max,", received: ").concat(r,".")},INVALID_ELEMENT_ID(e){let{key:t,fnName:i}=e;return"'".concat(t,"' is not found in the document object when calling ").concat(i,"().")},INVALID_ELEMENT_ID_TYPE(e){let{key:t,fnName:i,type:r}=e;return"the element corresponding to '".concat(t,"' must be instanceof HTMLElement when calling ").concat(i,"(), received: ").concat(r,".")},INVALID_STREAM_ID(e){let{key:t}=e;return"'".concat(t,"' can only consist of uppercase and lowercase english letters (a-zA-Z), numbers (0-9), hyphens and underscores.")},INVALID_ROOM_ID_STRING(e){let{key:t}=e;return"'".concat(t,"' must be a valid string.")},INVALID_ROOM_ID_INTEGER(e){let{key:t}=e;return"'".concat(t,"' must be an integer between [1, 4294967294].")},INVALID_ROOM_ID_INTEGER_STRING(e){let{key:t}=e;return"'".concat(t,"' must be an integer but go a string, use 'parseInt' to convert it or use 'strRoomId' instead.")},INVALID_ROOM_ID_REQUIED:()=>"at least one of 'roomId'(between [1, 4294967294]) and 'strRoomId'(not empty) is required.",INVALID_STREAM_TYPE:e=>{let{fnName:t}=e;return"'streamType' is required when 'userId' is not '*', calling ".concat(t,"()")},INVALID_IMAGE_URL:"The 'src' param must be filled in when the background type is image.",INVALID_OPERATION(e){let{fnName:t}=e;return"the API '".concat(t,"' you called does not meet the requirements, please check the API documentation.")},INVALID_OPERATION_NOT_JOINED(e){let{fnName:t}=e;return"cannot ".concat(t," because you are not enter room yet.")},INVALID_OPERATION_REMOTE_USER_NOT_EXIST(e){let{fnName:t,value:i}=e;return"cannot ".concat(t," because remote user(userId: ").concat(i.userId,") does not publishing stream.")},INVALID_OPERATION_STREAM_TYPE_NOT_EXIST(e){let{fnName:t,value:i}=e;return"cannot ".concat(t," because remote user(userId: ").concat(i.userId,") does not publishing ").concat(i.streamType," video.")},INVALID_OPERATION_REPEAT_CALL(e){let{fnName:t}=e;return"you are already ".concat(t,"(), cannot repeated call '").concat(t,"'.")},INVALID_OPERATION_NEED_VIDEO(e){let{fnName:t}=e;return"cannot call '".concat(t,"' because the camera is not turned on.")},INVALID_OPERATION_NEED_AUDIO(e){let{fnName:t}=e;return"cannot call '".concat(t,"' because the microphone is not turned on.")},ENV_NOT_SUPPORTED(e){let{fnName:t}=e;return"the current browser does not support the capability of the function '".concat(t,"' you are calling, please check the API documentation.")},NOT_SUPPORTED_WEBRTC:"the current browser does not support WebRTC capability, please check the SDK documentation.",NOT_SUPPORTED_H264_ENCODE:"this browser does not support H264 encode.",NOT_SUPPORTED_H264_DECODE:"this browser does not support H264 decode.",NOT_SUPPORTED_SCREEN_SHARE:"this browser does not support screen share, please check the browser version.",NOT_SUPPORTED_SMALL_VIDEO:"this browser does not support small video, please check the browser version.",NOT_SUPPORTED_SEI:"this browser does not support SEI, please check the browser version.",NOT_SUPPORTED_WEBGL:"this browser does not support WebGL, please check the browser version.",NOT_SUPPORTED_CHROME_VERSION(e){let{fnName:t}=e;return"cannot call ".concat(t," because the browser version is too low, please upgrade to the latest version")},DEVICE_ERROR(e){let{fnName:t,error:i}=e;return"'".concat(t,"' got device exception").concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_NOT_FOUND_ERROR(e){let{fnName:t,deviceType:i=UM(t),error:r}=e;return"NotFoundError, no ".concat(i," detected, please check your device and the configuration on '").concat(t,"'").concat(r?", error: ".concat(r.toString(),"."):".")},DEVICE_NOT_ALLOWED_ERROR(e){let{fnName:t,deviceType:i=UM(t),error:r}=e;return"NotAllowedError, you have disabled ".concat(i," access, please allow the current application to use the ").concat(i).concat(r?", error: ".concat(r.toString(),"."):".")},DEVICE_NOT_READABLE_ERROR(e){let{fnName:t,deviceType:i=UM(t),error:r}=e;return"NotReadableError, the ".concat(i," maybe in use by another APP, please check if the device is pre-occupied by another APP.")},DEVICE_OVERCONSTRAINED_ERROR(e){let{fnName:t,deviceType:i=UM(t),error:r}=e;return"OverconstrainedError, the device ID is incorrect, please check whether the device ID passed in is correct".concat(r?", error: ".concat(r.toString(),"."):".")},DEVICE_INVALID_STATE_ERROR(e){let{fnName:t,deviceType:i=UM(t),error:r}=e;return"InvalidStateError, after the user clicks and interacts with the page, turn on the ".concat(i).concat(r?", error: ".concat(r.toString(),"."):".")},DEVICE_SECURITY_ERROR(e){let{fnName:t,deviceType:i=UM(t),error:r}=e;return"SecurityError, check whether the system security policy restricts the use of the ".concat(i,", and it is recommended to turn on the ").concat(i," after the user interacts with the page").concat(r?", error: ".concat(r.toString(),"."):".")},DEVICE_ABORT_ERROR(e){let{fnName:t,deviceType:i=UM(t),error:r}=e;return"AbortError, an unknown exception in the system makes the device unusable, recommended to change the device or browser and re-check whether the device is normal".concat(r?" error: ".concat(r.toString(),"."):".")},CAMERA_RECOVER_FAILED(e){let{error:t}=e;return"camera recover capture failed ".concat((null==t?void 0:t.name)||"",": ").concat((null==t?void 0:t.originMessage)||(null==t?void 0:t.message))},MICROPHONE_RECOVER_FAILED(e){let{error:t}=e;return"microphone recover capture failed ".concat((null==t?void 0:t.name)||"",": ").concat((null==t?void 0:t.originMessage)||(null==t?void 0:t.message))},OPERATION_FAILED(e){let{fnName:t,error:i}=e;return"'".concat(t,"' failed, reason: ").concat(null==i?void 0:i.toString())},FIREWALL_RESTRICTION:()=>"media connection failure due to firewall restrictions, please try to change your network.",EVENT_HANDLER_ERROR(e){let{eventName:t}=e;return"an error was caught on trtc.on('".concat(t,"', handler), please check your code on 'handler'.")},VIDEO_CONTEXT_ERROR(e){let{reason:t,error:i}=e;return"video context error ".concat(t," ").concat((null==i?void 0:i.name)||""," ").concat((null==i?void 0:i.message)||"")},SERVER_ERROR(e){let{fnName:t,error:i}=e;return"'".concat(t,"' got server error: ").concat(null==i?void 0:i.toString(),", please check the SDK documentation.")},NEED_TO_BUY(e){let{value:t,url:i}=e;return"You need to buy packages for ".concat(t,". Refer to: ").concat(i)},ACCOUNT_NO_MONEY:e=>{let{fnParams:t}=e;return"your TRTC account run out of credit, please recharge.".concat(t.sdkAppId?" SDKAppId: ".concat(t.sdkAppId):"")},OPERATION_ABORT(e){let{fnName:t}=e;return"'".concat(t,"' abort")},UNKNOWN_ERROR(e){let{fnName:t,error:i}=e;return"'".concat(t,"' throw unknown exception").concat(i?", error: ".concat(i.toString(),"."):".")}});function UM(e){if(!e)return"camera";let t=e.toLowerCase();return t.includes("screen")?"screen share":t.includes("audio")?"microphone":"camera"}var BM=class extends Error{constructor(e){let{code:t,extraCode:i,message:r="",messageParams:n,fnName:o="",originError:s}=e;var a;let c;c=r||function(e){let t,{code:i,params:r,enableDocLink:n=!1}=e,o="",s=xM[i];try{t=VM[s]}catch(a){t=VM.UNKNOWN_ERROR}return ND(t)?o=t(r):OD(t)&&(o=t),n&&(o+=" doc:"),o}({code:i||t,params:qb({fnName:o,error:s},n)}),super(c),tC(this,"name","RtcError"),tC(this,"code"),tC(this,"extraCode"),tC(this,"functionName"),tC(this,"message"),tC(this,"handler"),tC(this,"originError"),this.name=xM[t],this.code=t,this.extraCode=i,this.functionName=o,this.originError=s,this.message=c,5302===this.extraCode&&(null==(a=this.originError)?void 0:a.message.includes("system"))&&(this.handler=()=>{let e=document.createElement("a");_k?e.href="ms-settings:privacy-".concat({startLocalVideo:"webcam",startLocalAudio:"microphone"}[this.functionName]):fk&&(e.href="x-apple.systempreferences:com.apple.preference.security?Privacy_".concat({startLocalVideo:"Camera",startLocalAudio:"Microphone",startScreenShare:"ScreenCapture"}[this.functionName])),e.href.length>0&&e.click()})}static convertFrom(e,t,i){let r=e;if(e instanceof fC){let{stack:n}=e,o={code:MM.UNKNOWN_ERROR,fnName:t,originError:e};switch(e.getCode()){case _C.INVALID_PARAMETER:o.code=MM.INVALID_PARAMETER,o.message=e.message;break;case _C.INVALID_OPERATION:o.code=MM.INVALID_OPERATION;break;case _C.NOT_SUPPORTED:case _C.NOT_SUPPORTED_H264:o.code=MM.ENV_NOT_SUPPORTED,e.getCode()===_C.NOT_SUPPORTED_H264&&(o.extraCode=e.message.includes(jN.NOT_SUPPORTED_H264ENCODE)?5203:5204);break;case _C.JOIN_ROOM_FAILED:o.messageParams={fnParams:i};case _C.SERVER_TIMEOUT:case _C.SWITCH_ROLE_FAILED:o.code=MM.SERVER_ERROR,o.extraCode=e.getExtraCode();break;case _C.API_CALL_ABORTED:o.code=MM.OPERATION_ABORT;break;case _C.DEVICE_NOT_FOUND:case _C.DEVICE_AUTO_RECOVER_FAILED:case _C.INITIALIZE_FAILED:o.code=5300,e.name&&(o.extraCode=function(e){let t;switch(e){case"NotFoundError":t=5301;break;case"NotAllowedError":t=5302;break;case"NotReadableError":t=5303;break;case"OverconstrainedError":t=5304;break;case"InvalidStateError":t=5305;break;case"SecurityError":t=5306;break;case"AbortError":t=5307;break;default:t=5300}return t}(e.name));break;case _C.UNKNOWN:break;default:o.code=MM.OPERATION_FAILED}r=new BM(o),n&&(r.stack+=n.substr(n.indexOf("\n")))}else{if(e instanceof BM)return e;r=new BM({code:MM.UNKNOWN_ERROR,fnName:t,originError:e})}return r}},FM=BM,HM={type:"object",properties:{cameraId:{type:"string"},useFrontCamera:{type:"boolean"},fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:["string","boolean"],values:[!0,!1,"view","publish","both"]},small:{properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},videoTrack:{instanceOf:MediaStreamTrack}}},jM={type:"object",properties:{systemAudio:{type:"boolean"},fillMode:{type:"string",values:["contain","cover","fill"]},profile:{type:["string","object"],properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},videoTrack:{instanceOf:MediaStreamTrack},audioTrack:{instanceOf:MediaStreamTrack}}},WM={type:["string",HTMLElement,null,"array"],arrayItem:{instanceOf:HTMLElement},validate(e,t,i){if(OD(e)&&!document.getElementById(e))throw new FM({code:MM.INVALID_PARAMETER,extraCode:5009,fnName:i,messageParams:{key:t}})}},zM={name:"userId",required:!0,type:"string"},GM={type:"object",properties:{microphoneId:{type:"string"},audioTrack:{instanceOf:MediaStreamTrack},captureVolume:{type:"number",min:0},earMonitorVolume:{type:"number",min:0,max:100},profile:{values:[PM.AUDIO_PROFILE_STANDARD,PM.AUDIO_PROFILE_STANDARD_STEREO,PM.AUDIO_PROFILE_HIGH,PM.AUDIO_PROFILE_HIGH_STEREO]},echoCancellation:{type:"boolean"},autoGainControl:{type:"boolean"},noiseSuppression:{type:"boolean"}}};function KM(e,t){if(!e)throw new FM({code:MM.INVALID_OPERATION,extraCode:5101,fnName:t})}function YM(e,t,i){if(!e)throw new FM({code:MM.INVALID_OPERATION,extraCode:5102,fnName:t,messageParams:{value:i}})}var JM={TRTC:{create:[{name:"RoomConfig",instanceOf:Function},{name:"CreateConfig",type:"object",properties:{plugins:{type:"array",arrayItem:{instanceOf:Function}}}}],enterRoom:{name:"EnterRoomConfig",type:"object",required:!0,validate(e,t,i){if(this._room.isJoined)throw new FM({code:MM.INVALID_OPERATION,extraCode:5104,fnName:i});if(e.roomId){if(OD(e.roomId))throw new FM({code:MM.INVALID_PARAMETER,extraCode:5016,fnName:i,messageParams:{key:t}});if(!(/^[1-9]\d*$/.test(String(e.roomId))&&e.roomId<4294967295))throw new FM({code:MM.INVALID_PARAMETER,extraCode:5013,fnName:i,messageParams:{key:t}})}else{if(!e.strRoomId)throw new FM({code:MM.INVALID_PARAMETER,extraCode:5015,fnName:i});if(!/^[A-Za-z\d\s!#$%&()+\-:;<=.>?@[\]^_{}|~,]{1,64}$/.test(e.strRoomId))throw new FM({code:MM.INVALID_PARAMETER,extraCode:5012,fnName:i,messageParams:{key:t}})}},properties:{sdkAppId:{required:!0,type:"number",allowEmpty:!1},userId:{required:!0,type:"string",allowEmpty:!1},userSig:{required:!0,type:"string",allowEmpty:!1},scene:{type:"string",values:["live","rtc"]},role:{type:"string",values:["audience","anchor"]},roomId:{type:["string","number"]},strRoomId:{type:"string"},proxy:{type:["object","string"],properties:{websocketProxy:{type:"string"},turnServer:{type:["object","array"],properties:{url:{required:!0,type:"string"},username:{type:"string"},credential:{type:"string"},credentialType:{type:"string",values:["password"]}}},loggerProxy:{type:"string"},webtransportProxy:{type:"string"}}},enableAutoPlayDialog:{type:"boolean"},userDefineRecordId:{type:"string"}}},startLocalVideo:{name:"LocalVideoConfig",type:"object",properties:{view:WM,mute:{type:["boolean","string"]},publish:{type:"boolean"},option:HM},validate(e){var t;if((null==(t=null==e?void 0:e.option)||!t.videoTrack)&&NO())throw new FM({code:MM.ENV_NOT_SUPPORTED,extraCode:5201})}},updateLocalVideo:{name:"updateLocalVideoConfig",type:"object",required:!0,properties:{view:Xb(qb({},WM),{required:!1}),publish:{type:"boolean"},mute:{type:["boolean","string"]},option:HM}},startLocalAudio:{name:"LocalAudioConfig",type:"object",properties:{publish:{type:"boolean"},option:GM},validate(e){var t;if((null==(t=null==e?void 0:e.option)||!t.audioTrack)&&NO())throw new FM({code:MM.ENV_NOT_SUPPORTED,extraCode:5201})}},updateLocalAudio:{name:"updateLocalAudioConfig",type:"object",required:!0,properties:{publish:{type:"boolean"},mute:{type:"boolean"},option:GM}},startScreenShare:{name:"ScreenShareConfig",type:"object",properties:{view:WM,publish:{type:"boolean"},option:jM},validate(e,t,i,r,n){var o;if((null==(o=null==e?void 0:e.option)||!o.videoTrack)&&NO())throw new FM({code:MM.ENV_NOT_SUPPORTED,extraCode:5201});if(!xO())throw new FM({code:MM.ENV_NOT_SUPPORTED,fnName:i,extraCode:5205})}},updateScreenShare:{name:"updateScreenShareConfig",type:"object",required:!0,properties:{view:WM,publish:{type:"boolean"},option:jM}},muteRemoteAudio:[zM,{name:"mute",required:!0,type:"boolean"}],setRemoteAudioVolume:[zM,{name:"volume",required:!0,type:"number",min:0}],startRemoteVideo:{name:"startRemoteVideoConfig",type:"object",required:!0,properties:{view:WM,userId:{type:"string",required:!0},streamType:{values:["main","sub"],required:!0},option:{type:"object",properties:{fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:"boolean"}}}},validate(e,t,i){KM(this._room.isJoined,i);let r=this._room.remotePublishedUserMap.get(e.userId);if(YM(!!r,i,e),r&&("main"===e.streamType&&!r.muteState.videoAvailable||"sub"===e.streamType&&!r.muteState.hasAuxiliary))throw new FM({code:MM.INVALID_OPERATION,extraCode:5103,fnName:i,messageParams:{value:e}})}},updateRemoteVideo:{name:"updateRemoteVideoConfig",type:"object",required:!0,properties:{view:Xb(qb({},WM),{required:!1}),userId:{type:"string",required:!0},streamType:{values:["main","sub"],required:!0},option:{type:"object",properties:{fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:"boolean"}}}},validate(e,t,i){KM(this._room.isJoined,i);let r=this._room.remotePublishedUserMap.get(e.userId);if(YM(!!r,i,e),r&&("main"===e.streamType&&!r.muteState.videoAvailable||"sub"===e.streamType&&!r.muteState.hasAuxiliary))throw new FM({code:MM.INVALID_OPERATION,extraCode:5103,fnName:i,messageParams:{value:e}})}},stopRemoteVideo:{name:"stopRemoteVideoConfig",type:"object",required:!0,properties:{userId:{type:"string",required:!0},streamType:{values:["main","sub"]}},validate(e,t,i){if("*"!==e.userId&&DD(e.streamType))throw new FM({code:MM.INVALID_PARAMETER,extraCode:5014,fnName:i})}},switchRole:{name:"role",required:!0,values:["anchor","audience"],validate(e,t,i){KM(this._room.isJoining||this._room.isJoined,i)}},enableAudioVolumeEvaluation:[{name:"interval",type:"number"},{name:"enableInBackground",type:"boolean"}],sendSEIMessage:[{name:"buffer",required:!0,instanceOf:ArrayBuffer,validate(e,t,i,r){if(!tL)throw new FM({code:MM.ENV_NOT_SUPPORTED,fnName:i,extraCode:5207});if(!this._room.enableSEI)throw new FM({code:MM.INVALID_OPERATION,messageParams:{key:HN.SEI_DISABLED}});if(e.byteLength>1e3)throw new FM({code:MM.INVALID_PARAMETER,messageParams:{key:HN.SEI_OVERSIZE,data:e.byteLength}});if(0===e.byteLength)throw new FM({code:MM.INVALID_PARAMETER,messageParams:{key:HN.SEI_EMPTY}});if(KM(this._room.isJoined,i),!this._room.isMainStreamPublished)throw new FM({code:MM.INVALID_PARAMETER,messageParams:{key:HN.SEI_BEFORE_PUBLISH}})}},{name:"options",type:"object",properties:{seiPayloadType:{type:"number",values:[5,243]}}}]}},qM=class extends Error{};function XM(e,t){let i=eO(e);for(let r=0;r<t.length;r++)$D(i[r],t[r]);return i}function QM(e){this._resolve=Promise.resolve(e)}function ZM(e){this._reject=Promise.reject(e)}var $M=class{constructor(e,t){this.instance=e,this.group=t,this.started=!1,this.ops=[],this.startSame=()=>!0,this.mergeUpdate=XM;let i=$M.instances.get(e);i?i.set(t,this):$M.instances.set(e,new Map([[t,this]]))}static get(e,t){let i=$M.instances.get(e);return i&&i.get(t)||new $M(e,t)}action(e,t,i){let r=t=>{var i;return 0===e?this.started=!0:3===e&&(this.started=!1),this.ops.shift(),null==(i=this.currentOp)||i.action(),t},n=t=>{var i,r;throw this.ops.shift(),0===e&&2===(null==(i=this.currentOp)?void 0:i.type)&&this.ops.shift().reject(new qM("start failed")),null==(r=this.currentOp)||r.action(),t},o={type:e,action:()=>t(...o.args).then(r,n),args:i,resolve:QM,reject:ZM};try{switch(this.state){case 1:if(0===e)throw new qM("already started");break;case 4:if(2===e)throw new qM("not started");break;default:return this.cacheOp(o)}}catch(s){return Promise.reject(s)}return this.ops.push(o),o.promise=t(...o.args).then(r,n)}cacheOp(e){if(1===this.ops.length)switch(this.state){case 0:case 2:if(0===e.type)throw new qM("already start");break;case 3:switch(e.type){case 2:throw new qM("update not allowed when stopping");case 3:return this.currentOp.promise}break;default:throw new qM("unknown state")}else switch(e.type){case 3:if(3===this.lastOpType)return this.lastOp.promise;{let e=new qM("keep stop");if(this.ops.slice(1).forEach((t=>t.reject(e))),this.ops=this.ops.slice(0,1),3===this.state)return this.currentOp.promise}break;case 2:switch(this.lastOpType){case 2:return this.lastOp.args=this.mergeUpdate(this.lastOp.args,e.args),this.lastOp.promise;case 3:throw new qM("update not allowed after stop")}break;case 0:switch(this.lastOpType){case 2:throw new qM("start not allowed after update");case 0:throw new qM("duplicate start");case 3:if(this.startSame(this.currentOp.args,e.args))throw this.ops.pop().reject(new qM("keep start")),new qM("already start")}}e.promise=new Promise(((t,i)=>{e._resolve?e._resolve.then(t):e.resolve=t,e._reject?e._reject.catch(i):e.reject=i}));let{action:t}=e;return e.action=()=>t().then(e.resolve,e.reject),this.ops.push(e),e.promise}get lastOp(){return this.ops[this.ops.length-1]}get lastOpType(){return this.lastOp.type}get currentOp(){return this.ops[0]}get state(){return this.currentOp?this.currentOp.type:this.started?1:4}},ex=$M;ex.instances=new WeakMap;var tx=new WeakMap,ix=(e,t)=>{if(t instanceof qM){let{stack:i}=t;t=new FM({code:MM.OPERATION_ABORT,message:"".concat(e," abort: ").concat(t.message),fnName:e}),i&&(t.stack+=i.substr(i.indexOf("\n")))}throw t};function rx(e,t){return JP(((i,r)=>function(){for(var n=arguments.length,o=new Array(n),s=0;s<n;s++)o[s]=arguments[s];let a=ex.get(this,"string"==typeof e?e:e.call(this,...o));return t&&(a.startSame=t.bind(this)),a.action(0,i.bind(this),o).catch(ix.bind(null,r))}))}function nx(e,t){let{merge:i,debounce:r}=t||{};return JP(((t,n)=>function(){for(var o=arguments.length,s=new Array(o),a=0;a<o;a++)s[a]=arguments[a];let c=ex.get(this,"string"==typeof e?e:e.call(this,...s));if(i&&(c.mergeUpdate=i.bind(this)),r&&r.isNeedToDebounce.apply(this,s)){let{delay:e,getKey:i}=r;return new Promise(((r,o)=>{var a,l;let d=null==(a=tx.get(this))?void 0:a.get(i(...s));if(d){let{timeoutId:e,resolve:t}=d;clearTimeout(e),t()}let u=setTimeout((()=>{if(3===c.state||4===c.state)return r();c.action(2,t.bind(this),s).catch(ix.bind(null,n)).then(r,o)}),e);tx.has(this)?null==(l=tx.get(this))||l.set(i(...s),{timeoutId:u,resolve:r}):tx.set(this,new Map([[i(...s),{timeoutId:u,resolve:r}]]))}))}return c.action(2,t.bind(this),s).catch(ix.bind(null,n))}))}function ox(e){return JP(((t,i)=>function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return ex.get(this,"string"==typeof e?e:e.call(this,...n)).action(3,t.bind(this),n).catch(ix.bind(null,i))}))}var sx={ERROR:"error",AUTOPLAY_FAILED:"autoplay-failed",KICKED_OUT:"kicked-out",REMOTE_USER_ENTER:"remote-user-enter",REMOTE_USER_EXIT:"remote-user-exit",REMOTE_AUDIO_AVAILABLE:"remote-audio-available",REMOTE_AUDIO_UNAVAILABLE:"remote-audio-unavailable",REMOTE_VIDEO_AVAILABLE:"remote-video-available",REMOTE_VIDEO_UNAVAILABLE:"remote-video-unavailable",AUDIO_VOLUME:"audio-volume",NETWORK_QUALITY:"network-quality",CONNECTION_STATE_CHANGED:"connection-state-changed",AUDIO_PLAY_STATE_CHANGED:"audio-play-state-changed",VIDEO_PLAY_STATE_CHANGED:"video-play-state-changed",SCREEN_SHARE_STOPPED:"screen-share-stopped",DEVICE_CHANGED:"device-changed",PUBLISH_STATE_CHANGED:"publish-state-changed",STATISTICS:"statistics",SEI_MESSAGE:"sei-message",TRACK:"track"};function ax(e){return"sub"===e?"auxiliary":"auxiliary"===e?"sub":"main"}function cx(e){return e===PM.QOS_PREFERENCE_CLEAR?"detail":e===PM.QOS_PREFERENCE_SMOOTH?"motion":""}function lx(e,t,i){return{room:e,assetsPath:i,innerEmitter:JN,constants:rw,environment:TC,utils:yC,eventLogger:XN,log:e.getLogger(),errorModule:t,kvStatManager:pP,clearStarted(t,i){let r=t.getAlias(),n=ex.instances.get(e);if(n)if(i){let e=n.get(r+i);if(!e)return;e.started=!1}else n.forEach(((e,t)=>{t.startsWith(r)&&(e.started=!1)}))}}}var dx=new WeakMap;function ux(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return JP(((e,i)=>function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];try{px.call(this,t,n,i,this._name)}catch(s){return Promise.reject(s)}return e.apply(this,n)}))}function hx(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return JP(((e,i)=>function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];try{px.call(this,t,n,i,this._name)}catch(s){throw s}return e.apply(this,n)}))}function px(e,t,i,r){if(xD(e))for(let n=0;n<e.length;n++)mx.call(this,{rule:e[n],value:t[n],key:e[n].name,fnName:i,className:r});else mx.call(this,{rule:e,value:t[0],key:e.name,fnName:i,className:r})}function mx(e){let{rule:t,value:i,key:r,fnName:n,className:o}=e;function s(e){return{code:MM.INVALID_PARAMETER,extraCode:e,fnName:n,messageParams:{key:r,rule:t,value:i}}}if(DD(i)){if(t.required)throw new FM(s(5001));if(DD(t.defaultValue))return void(ND(t.validate)&&t.validate.call(this,i,r,n,o,this));i=t.defaultValue}if(Array.isArray(t.type)){let e=!1;for(let r=0;r<t.type.length;r++)null===t.type[r]&&null===i&&(e=!0),ND(t.type[r])&&i instanceof t.type[r]&&(e=!0),OD(t.type[r])&&wD(i)===t.type[r].toLowerCase()&&(e=!0);if(!e)throw new FM({code:MM.INVALID_PARAMETER,extraCode:5002,fnName:n,messageParams:{key:r,rule:{type:t.type.map((e=>FD(e)?HD(e):OD(e)?e:wD(e)))},value:i}})}else if(!DD(t.type)&&wD(i)!==t.type)throw new FM(s(5002));if(!1===t.allowEmpty){let e=LD(i)&&(0===i||Number.isNaN(i)),t=OD(i)&&""===i.trim();if(e||t)throw new FM(s(5003))}if(t.notLessThanZero&&LD(i)&&i<0)throw new FM(s(5006));if(!DD(t.min)&&LD(i)&&i<t.min)throw new FM(s(5007));if(!DD(t.max)&&LD(i)&&i>t.max)throw new FM(s(5008));if(OD(t.instanceOf)){if(!i||i._name!==t.instanceOf)throw new FM(s(5004))}else if(ND(t.instanceOf)&&!(i instanceof t.instanceOf))throw new FM(s(5004));if(Array.isArray(t.values)&&!t.values.includes(i))throw new FM(s(5005));let{properties:a}=t;bD(a)&&MD(i)&&Object.keys(a).forEach((e=>{mx.call(this,{rule:a[e],value:i&&i[e],key:"".concat(e),fnName:n,className:o})}));let{arrayItem:c}=t;bD(c)&&xD(i)&&i.forEach(((e,t)=>{mx.call(this,{rule:c,value:e,key:"".concat(r,"[").concat(t,"]"),fnName:n,className:o})})),ND(t.validate)&&t.validate.call(this,i,r,n,o,this)}function _x(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{getRemoteId:t=(()=>""),replaceArg:i,getKVReportKey:r}=e;return JP(((e,n)=>function(){for(var o=arguments.length,s=new Array(o),a=0;a<o;a++)s[a]=arguments[a];function c(e,t,r){if(r&&r.includes(e))return"hided";if(i){let e=i(...s);if(s[e.argIndex]===t)return e.value}if(t===s||e in s)return t;try{return t instanceof HTMLElement?"id: ".concat(t.id," type:").concat(wD(t)):(JSON.stringify(t),t)}catch(n){return"type:".concat(wD(t))}}let l=this._log||EO;s.length>0?l.info("".concat(n,"() ").concat(JSON.stringify(s,((e,t)=>c(e,t,["userSig","privateMapKey"]))))):l.info("".concat(n,"()"));let d=r?r(...s):oP[n];try{let i=e.apply(this,s),r=zD();return BD(i)?i.then((e=>(l.info("".concat(n,"() success ").concat(t.call(this,...s))),pP.addSuccessEvent({key:d,cost:zD()-r}),e))).catch((e=>{throw e=FM.convertFrom.call(this,e,n,1===s.length?s[0]:s),l.error("".concat(n,"() failed ").concat(t.call(this,...s)," ").concat(e," params: ").concat(JSON.stringify(s,c))),pP.addFailedEvent({key:d,error:e}),e})):(pP.addSuccessEvent({key:d}),i)}catch(u){throw u=FM.convertFrom.call(this,u,n),l.error("".concat(n,"() failed ").concat(u," params: ").concat(JSON.stringify(s,c))),pP.addFailedEvent({key:d,error:u}),u}}))}var fx=e=>JP(((t,i)=>function(r,n){return rC(this,null,(function*(){let o=this._plugins.get(r);if(o)return px.call(this,o.getValidateRule(e),[n],i,"TRTC"),t.call(this,o,n);this._log.warn("plugin ".concat(r," is not found"))}))})),gx=0,Ex=class{constructor(e,t){tC(this,"player"),tC(this,"publisher"),tC(this,"mixInput"),this.mixInput=new gP(t),e.url?(this.player=new Audio(e.url),this.player.crossOrigin="anonymous",this.publisher=new Audio(e.url),this.publisher.crossOrigin="anonymous",this.mixInput.replaceSource(this.publisher)):this.mixInput.replaceSource(e.track),this.mixInput.connect()}reset(){this.seek(0),this.mixInput.connect()}seek(e){!this.player||e<0&&e>this.player.duration||(this.player.currentTime=e,this.publisher.currentTime=e)}play(){var e,t;return null==(e=this.publisher)||e.play(),null==(t=this.player)?void 0:t.play()}pause(){var e,t;null==(e=this.player)||e.pause(),null==(t=this.publisher)||t.pause()}stop(){var e;null==(e=this.player)||e.pause(),this.mixInput.disconnect()}setOperation(e){"pause"===e&&this.pause(),"resume"===e&&(this.pause(),this.play()),"stop"===e&&(this.pause(),this.seek(0))}set volume(e){!this.player||!this.publisher||(this.player.volume=e,this.publisher.volume=e)}set loop(e){!this.player||!this.publisher||(this.player.loop=e,this.publisher.loop=e)}},vx=class{constructor(e){this.core=e,tC(this,"log"),tC(this,"mixedMusicMap",new Map),tC(this,"cacheMusicMap",new Map),gx+=1,this.log=e.log.createChild({id:"".concat(this.getAlias()).concat(gx)}),this.log.info("[audioMixer] created id=".concat(this.getAlias()).concat(gx)),this.core=e}getName(){return"AudioMixer"}getAlias(){return"ax"}getGroup(e){return null==e?void 0:e.id}getValidateRule(e){switch(e){case"start":return vx.startValidateRule;case"update":return vx.updateValidateRule;case"stop":return vx.stopValidateRule}}start(e){return rC(this,null,(function*(){let{room:t}=this.core;this.log.info("add music source, id: ".concat(e.id," url: ").concat(e.url,", track: ").concat(e.track));let{id:i,url:r}=e;if(this.mixedMusicMap.has(i))return;let n=this.cacheMusicMap.get(i);n?e.url?n.reset():(n.mixInput.replaceSource(e.track),n.mixInput.connect()):(n=new Ex(e,t.audioManager),this.cacheMusicMap.set(i,n)),yield n.play(),this.mixedMusicMap.set(i,n),this.log.info("start mix audio track ".concat(i," success.")),pP.addEnum({key:502700,value:3})}))}update(e){return rC(this,null,(function*(){let{id:t,volume:i,loop:r,operation:n,seekFrom:o}=e;this.log.info("update music source, ".concat(JSON.stringify(e)));let s=this.mixedMusicMap.get(t);s?(DD(i)||(s.volume=i),DD(r)||(s.loop=r),DD(n)||s.setOperation(n),DD(o)||s.seek(o)):this.log.warn("update music source failed, music id: ".concat(t," not found."))}))}stop(e){return rC(this,arguments,(function(e){var t=this;let{id:i}=e;return function*(){var e;t.mixedMusicMap.has(i)&&(t.log.info("remove music source, music id: ".concat(i)),null==(e=t.mixedMusicMap.get(i))||e.stop(),t.mixedMusicMap.delete(i)),"*"===i&&t.destroyAllMusic()}()}))}destroyAllMusic(){this.log.info("destroy all music source."),this.mixedMusicMap.forEach(((e,t)=>this.stop({id:t})))}destroyAllCache(){this.log.info("destroy all music cache."),this.cacheMusicMap.clear()}destroy(){this.log.info("destroy audio mixer plugin."),this.destroyAllMusic(),this.destroyAllCache()}},yx=vx;tC(yx,"startValidateRule",{name:"options",required:!0,type:"object",properties:{id:{type:"string",required:!0},url:{type:"string",required:!1},track:{required:!1},loop:{type:"boolean"},volume:{type:"number"}},validate(e,t,i){if(e.url&&"*"!==e.url){let t=e.url.split("?")[0],r=["mp3","ogg","wav","flac"],n=t.split(".").pop(),o=r.indexOf(n)>=0,s=t.startsWith("blob"),a=t.startsWith("data");if(!(o||s||a))throw new FM({code:MM.INVALID_PARAMETER,message:"start audioMixer plugin: music url is invalid, please check your file format.",fnName:i})}if(!e.url&&!e.track)throw new FM({code:MM.INVALID_PARAMETER,message:"start audioMixer plugin: param url or track is required.",fnName:i})}}),tC(yx,"updateValidateRule",{name:"options",required:!0,type:"object",properties:{id:{type:"string",required:!0},loop:{type:"boolean"},volume:{type:"number"},seekFrom:{type:"number"},operation:{type:"string",values:["pause","resume","stop"]}}}),tC(yx,"stopValidateRule",{name:"options",type:"object",required:!0,properties:{id:{type:"string",required:!0}}});var Tx=e=>(e=Number(e))>0&&e<14e8,Sx=0,Ix=class{constructor(e){this.core=e,tC(this,"log"),tC(this,"workletReady"),tC(this,"audioContext",rP()),tC(this,"workletNode"),Sx+=1,this.log=e.log.createChild({id:"".concat(this.getAlias()).concat(Sx)}),this.log.info("[audioDenoiser] created id=".concat(this.getAlias()).concat(Sx)),e.assetsPath&&(this.workletReady=QL(this.audioContext,"".concat(e.assetsPath,"/denoiser-wasm.js")),this.workletReady.catch((t=>{this.log.error("Init assets from ".concat(e.assetsPath," failed! Reason: ").concat(t))})))}static startValidateRule(e){return{name:"options",required:!0,type:"object",properties:{sdkAppId:{type:"number",required:!0},userId:{type:"string",required:!0},userSig:{type:"string",required:!0}},validate(t,i,r,n){if(!e.room.audioManager.hasAudioTrack)throw new FM({code:MM.INVALID_OPERATION,extraCode:5106,fnName:r})}}}getName(){return"AIDenoiser"}getAlias(){return"ad"}getGroup(){return"AIDenoiser_".concat(Date.now())}getValidateRule(e){switch(e){case"start":return Ix.startValidateRule(this.core);case"update":return Ix.updateValidateRule;case"stop":return Ix.stopValidateRule}}start(e){return rC(this,null,(function*(){let{room:t}=this.core;if(this.workletReady||(this.workletReady=QL(this.audioContext,"".concat(e.assetsPath,"/denoiser-wasm.js")),this.workletReady.catch((t=>{this.log.error("Init assets from ".concat(e.assetsPath," failed! Reason: ").concat(t))}))),!this.workletNode){let t=String(Date.now()).slice(0,-3),{auth:i,sign:r,status:n,message:o}=yield function(e){return rC(this,arguments,(function(e){let{sdkAppId:t,userId:i,userSig:r,timestamp:n}=e;return function*(){let e="https://".concat(function(e){let t;return t=Tx(e)?Rx.MAIN_OVERSEA:Rx.MAIN,t}(t),"/api/v1/audioAiAuth?sdkAppId=").concat(t,"&userId=").concat(i,"&userSig=").concat(r,"&timestamp=").concat(n),o=yield fetch(e),{data:{errCode:s,errMsg:a,sign:c,status:l}}=yield o.json();if("1"===l)return{auth:!0,sign:c,status:l,message:a};let d="Init RTCAIDenoiser failed.",u="";switch(s){case 1:u="Please check your params.";break;case 2:u="You need to buy packages. Refer to: https://cloud.tencent.com/document/product/647/44247";break;case 3:u="Server is invalid. Please contact our engineer. ";break;case 4:u="Your packages is not active. Refer to: https://cloud.tencent.com/document/product/647/44247";break;case 5:u="Your packages is expired. Refer to: https://cloud.tencent.com/document/product/647/44247";break;case 6:u="Your version is not supported."}return{auth:!1,status:l,message:a?"".concat(d," Reason: ").concat(a,". ").concat(u):"".concat(d,", ").concat(u)}}()}))}(Xb(qb({},e),{timestamp:t}));if(!i)throw this.log.info("RTCAIDenoiser: ".concat(e.userId," auth result: ").concat(i,". Message: ").concat(o)),new FM({code:MM.INVALID_PARAMETER,message:o});yield this.workletReady,this.workletNode=new AudioWorkletNode(this.audioContext,"trtc-denoiser-processor",{numberOfInputs:1,numberOfOutputs:1}),this.workletNode.port.postMessage({type:"init",data:{sdkAppId:String(e.sdkAppId),userId:e.userId,timestamp:t,sign:r,status:n}}),this.workletNode.port.onmessage=e=>{let{data:t}=e;"cost"===t.type&&this.log.debug("[RTCAIDenoiser] ".concat(t.value))}}this.workletNode.port.postMessage({type:"enable"}),t.audioManager.addDenoiser(this.workletNode),t.sendAbilityStatus({ai_denoise:1})}))}update(){return rC(this,null,(function*(){}))}stop(){return rC(this,null,(function*(){if(!this.workletNode)return;let{room:e}=this.core;this.workletNode.port.postMessage({type:"disable"}),yield e.audioManager.removeDenoiser(this.workletNode)}))}destroy(){}},Ax=Ix;tC(Ax,"updateValidateRule",{type:"object"}),tC(Ax,"stopValidateRule",{type:"object"});var Rx={MAIN:"schedule.cloud-rtc.com",MAIN_OVERSEA:"schedule.rtc.tencentcloud.com"},bx=0,Cx=new Set,kx=null;sw("5.5.0");var wx=class extends pC.EventEmitter{constructor(e,t){super(),tC(this,"_room"),tC(this,"_eventListened",new Set),tC(this,"_localVideoTrack",null),tC(this,"_localAudioTrack",null),tC(this,"_localScreenTrack",null),tC(this,"_localScreenAudioTrack",null),tC(this,"_localVideoConfig",null),tC(this,"_localScreenConfig",null),tC(this,"_localAudioConfig",null),tC(this,"_remoteVideoConfigMap",new Map),tC(this,"_remoteAudioConfigMap",new Map),tC(this,"_remoteAudioMuteMap",new Map),tC(this,"_mediaTrackMap",new WeakMap),tC(this,"_log",EO.createLogger({id:"t".concat(++bx)})),tC(this,"_plugins",new Map),tC(this,"_networkQuality",null),tC(this,"_speakerId"),this._room=new e(qb({logger:this._log,frameWorkType:wx.frameWorkType},t)),this._log.debug(JSON.stringify(t)),Object.defineProperties(this,{dumpAudio:{enumerable:!1,value(e){return this._room.audioManager.dump(e)}}});let i={RtcError:FM,ErrorCode:MM,ErrorCodeDictionary:xM};t.plugins&&t.plugins.forEach((e=>{let r=new e(lx(this._room,i,t.assetsPath));this._plugins.set(r.getName(),r)}));let r=new yx(lx(this._room,i,t.assetsPath));this._plugins.set(r.getName(),r);let n=new Ax(lx(this._room,i,t.assetsPath));this._plugins.set(n.getName(),n),this._room.on("audio-volume",(e=>{!e.find((e=>""===e.userId))&&this._localAudioTrack&&e.push({userId:"",volume:Math.floor(100*this._localAudioTrack.getAudioLevel())}),this.emit(sx.AUDIO_VOLUME,{result:e.sort(((e,t)=>t.volume-e.volume))})})),this._room.videoManager.on("error",(e=>{let{reason:t,error:i}=e;this._log.error(new FM({code:MM.OPERATION_FAILED,extraCode:5504,messageParams:{reason:t,error:i}}))})),this._listenEvents(),this._initActiveSpeaker(),((e,t)=>{let{emit:i}=e;e.emit=function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];try{return i.apply(e,n)}catch(s){let e=GN({key:HN.CATCH_HANDLER_ERROR,data:{name:t,event:n[0]},addDocLink:!1});return EO.warn("".concat(e,"\n\n").concat(s.stack)),!1}}})(this,"trtc")}static create(e){}static _create(e,t){var i;LM&&(LM=!1,5!==EO.getLogLevel()&&("* API Document: ".concat(vw,"/en/index.html"),"* Changelog: ".concat(vw,"/en/tutorial-01-info-changelog.html")),EO.info("TRTC Web SDK Version:",ow),EO.info("UA:",navigator.userAgent),EO.info("URL: ".concat(location.href).concat("IFRAME"===(null==(i=self.frameElement)?void 0:i.tagName)?" in iframe":"")),$k().then((e=>{if(e){let t="UAData: ".concat(e.platform,"/").concat(e.platformVersion);e.architecture&&e.bitness&&(t+=" ".concat(e.architecture,"/").concat(e.bitness)),e.mobile&&(t+=" mobile"),e.model&&(t+=" model: ".concat(e.model)),e.fullVersionList&&(t+=" ".concat(e.fullVersionList.filter((e=>"Not/A)Brand"!==e.brand)).map((e=>"".concat(e.brand,"/").concat(e.version))).join(","))),EO.info(t)}})));let r=new wx(e,t||{});return Cx.add(r),r}_listenEvents(){YL(this,this._room).add("peer-join",(e=>{let{userId:t}=e;this.emit(sx.REMOTE_USER_ENTER,{userId:t})})).add("peer-leave",(e=>{this.emit(sx.REMOTE_USER_EXIT,{userId:e})})).add("banned",(e=>{this._exitRoom().then((()=>{this.emit(sx.KICKED_OUT,{reason:e.reason})}))})).add("error",(e=>{this._exitRoom().then((()=>{this.emit(sx.ERROR,FM.convertFrom(e))}))})).add("signal-connection-state-changed",(e=>{this.emit(sx.CONNECTION_STATE_CHANGED,e)})).add("network-quality",(e=>{this._networkQuality=e,this.emit(sx.NETWORK_QUALITY,e)})).add("remote-published",(e=>{[e.remoteAudioTrack,e.remoteVideoTrack,e.remoteAuxiliaryTrack].forEach((t=>{YL(t,t).add("player-state-changed",(i=>{let r=Xb(qb({},i),{userId:e.userId});t.kind===Mw.VIDEO&&(r.streamType=ax(t.streamType)),this.emit(t.kind===Mw.AUDIO?sx.AUDIO_PLAY_STATE_CHANGED:sx.VIDEO_PLAY_STATE_CHANGED,r)})).add("error",(e=>{e.getCode()===_C.PLAY_NOT_ALLOWED&&this.emit(sx.AUTOPLAY_FAILED,{userId:t.userId})}))}))})).add("remote-unpublished",(e=>{[e.remoteAudioTrack,e.remoteVideoTrack,e.remoteAuxiliaryTrack].forEach((e=>{JL(e)}))})).add("remote-publish-state-changed",(e=>{let{prevMuteState:t,muteState:i}=e,{userId:r}=i,n=t.audioAvailable,o=t.videoAvailable,{audioAvailable:s,videoAvailable:a}=i;s||this._remoteAudioConfigMap.delete(r),a||this._remoteVideoConfigMap.delete("".concat(r,"_","main")),i.hasAuxiliary||this._remoteVideoConfigMap.delete("".concat(r,"_","sub")),n!==s&&(this.emit(s?sx.REMOTE_AUDIO_AVAILABLE:sx.REMOTE_AUDIO_UNAVAILABLE,{userId:r}),s?this._onAudioAvailable({userId:r}):this._onAudioUnavailable({userId:r,muteState:i})),o!==a&&(this.emit(a?sx.REMOTE_VIDEO_AVAILABLE:sx.REMOTE_VIDEO_UNAVAILABLE,{userId:r,streamType:"main"}),a?this._onVideoAvailable({userId:r,streamType:"main"}):this._onVideoUnavailable({userId:r,streamType:"main"})),t.hasAuxiliary!==i.hasAuxiliary&&(this.emit(i.hasAuxiliary?sx.REMOTE_VIDEO_AVAILABLE:sx.REMOTE_VIDEO_UNAVAILABLE,{userId:r,streamType:"sub"}),i.hasAuxiliary?this._onVideoAvailable({userId:r,streamType:"sub"}):this._onVideoUnavailable({userId:r,streamType:"sub"}))})).add("firewall-restriction",(()=>{this.emit(sx.ERROR,new FM({code:MM.OPERATION_FAILED,extraCode:5501}))})).add("sei-message",(e=>{this.emit(sx.SEI_MESSAGE,Xb(qb({},e),{streamType:ax(e.streamType)}))})).add("heartbeat-report",(e=>{var t,i,r,n,o,s,a;let c={2:"big",3:"small",7:"sub"},l={rtt:e.msg_up_stream_info.msg_network_status.uint32_rtt||(null==(t=e.msg_down_stream_info[0])?void 0:t.msg_network_status.uint32_rtt)||(null==(i=this._networkQuality)?void 0:i.uplinkRTT)||(null==(r=this._networkQuality)?void 0:r.downlinkRTT)||0,upLoss:(null==(n=this._networkQuality)?void 0:n.uplinkLoss)||0,downLoss:(null==(o=this._networkQuality)?void 0:o.downlinkLoss)||0,bytesSent:e.bytes_sent||0,bytesReceived:e.bytes_received||0,localStatistics:{audio:{bitrate:((null==(s=e.msg_up_stream_info.msg_audio_status)?void 0:s.uint32_audio_codec_bitrate)||0)/1e3,audioLevel:((null==(a=e.msg_up_stream_info.msg_audio_status)?void 0:a.uint32_audio_level)||0)/UN},video:e.msg_up_stream_info.msg_video_status.filter((e=>c[e.uint32_video_stream_type])).map((e=>({bitrate:(e.uint32_video_codec_bitrate||0)/1e3,width:e.uint32_video_width,height:e.uint32_video_height,frameRate:e.uint32_video_enc_fps,videoType:c[e.uint32_video_stream_type]})))},remoteStatistics:e.msg_down_stream_info.map((e=>({userId:e.msg_user_info.str_identifier,audio:{bitrate:(e.msg_audio_status.uint32_audio_codec_bitrate||0)/1e3,audioLevel:(e.msg_audio_status.uint32_audio_level||0)/UN},video:e.msg_video_status.map((e=>({bitrate:(e.uint32_video_codec_bitrate||0)/1e3,width:e.uint32_video_width,height:e.uint32_video_height,frameRate:e.uint32_video_dec_fps,videoType:c[e.uint32_video_stream_type]})))})))};this.emit(sx.STATISTICS,l)})),YL(this,PP).add("audioInputAdded",(e=>{this.emit(sx.DEVICE_CHANGED,{type:"microphone",action:"add",device:e})})).add("audioInputRemoved",(e=>{this.emit(sx.DEVICE_CHANGED,{type:"microphone",action:"remove",device:e})})).add("videoInputAdded",(e=>{this.emit(sx.DEVICE_CHANGED,{type:"camera",action:"add",device:e})})).add("videoInputRemoved",(e=>{this.emit(sx.DEVICE_CHANGED,{type:"camera",action:"remove",device:e})})).add("audioOutputAdded",(e=>rC(this,null,(function*(){if(this.emit(sx.DEVICE_CHANGED,{type:"speaker",action:"add",device:e}),kx&&kx.deviceId===CN){let e=(yield BP()).find((e=>e.deviceId===CN));e&&kx.groupId!==e.groupId&&(kx=e,this.emit(sx.DEVICE_CHANGED,{type:"speaker",action:"active",device:e}))}})))).add("audioOutputRemoved",(e=>rC(this,null,(function*(){this.emit(sx.DEVICE_CHANGED,{type:"speaker",action:"remove",device:e});let t=(yield BP())[0];t&&kx&&(kx.deviceId===e.deviceId||kx.deviceId===CN&&kx.groupId!==t.groupId)&&(kx=t,this.emit(sx.DEVICE_CHANGED,{type:"speaker",action:"active",device:t}))}))))}enterRoom(e){return rC(this,null,(function*(){var t,i;let{scene:r="rtc",enableAutoPlayDialog:n=!0,autoReceiveAudio:o=!0,autoReceiveVideo:s=!0}=e;e.proxy&&(this._room.setProxyServer(e.proxy),!OD(e.proxy)&&e.proxy.turnServer&&(null==(i=(t=this._room).setTurnServer)||i.call(t,e.proxy.turnServer,e.proxy.iceTransportPolicy))),this._room.enableAutoPlayDialog=n,this._room.autoReceiveAudio=o,this._room.autoReceiveVideo=s,PD(e.enableHWEncoder)&&(this._room.enableHWEncoder=e.enableHWEncoder);let a={sdkAppId:e.sdkAppId,userId:e.userId,userSig:e.userSig,privateMapKey:e.privateMapKey||null,role:"audience"===e.role?21:20,roomId:e.roomId||0,strRoomId:e.strRoomId||"",businessInfo:e.businessInfo||null,streamId:null,userDefineRecordId:e.userDefineRecordId||null,frameWorkType:e.frameWorkType,component:e.component,language:e.language};e.strRoomId&&!e.roomId&&(this._room.useStringRoomId=!0),yield this._room.join(a,r,wx.frameWorkType),this._checkTrackToPublish()}))}exitRoom(){return rC(this,null,(function*(){return yield this._exitRoom()}))}switchRole(e,t){return rC(this,null,(function*(){null!=t&&t.privateMapKey&&(this._room.privateMapKey=t.privateMapKey),yield this._room.switchRole(e),"anchor"===e&&this._checkTrackToPublish()}))}destroy(){JL(this),this.removeAllListeners(),this._room.destroy(),Cx.delete(this),this._localAudioTrack&&this.stopLocalAudio(),this._localVideoTrack&&this.stopLocalVideo(),this._localScreenTrack&&this.stopScreenShare(),this._plugins.forEach((e=>e.destroy()))}startLocalAudio(){return rC(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0};return function*(){if(e._localAudioTrack)return void e._log.warn("local audio is already started");let{publish:i=!0,mute:r,option:n}=t,o=new iM(e._room.audioManager),s={},a={muted:!0};n&&(DD(n.microphoneId)?DD(n.audioTrack)||(s.customSource=n.audioTrack):s.deviceId=n.microphoneId,n&&LD(n.captureVolume)&&o.setCaptureVolume(n.captureVolume),DD(n.profile)||(OD(n.profile)?Ow[n.profile]&&o.setProfile(Ow[n.profile]):o.setProfile(n.profile)),LD(n.earMonitorVolume)&&(a.muted=!(n.earMonitorVolume>0),a.volume=n.earMonitorVolume),DD(n.echoCancellation)||(o.profile.echoCancellation=n.echoCancellation),DD(n.noiseSuppression)||(o.profile.noiseSuppression=n.noiseSuppression),DD(n.autoGainControl)||(o.profile.autoGainControl=n.autoGainControl)),o.on("5",(t=>{e.emit(sx.ERROR,new FM({code:MM.DEVICE_ERROR,extraCode:5309,messageParams:{error:t}}))})),o.on("2",(t=>{e.emit(sx.DEVICE_CHANGED,{type:"microphone",action:"active",device:t})})),o.on("4",(t=>{let i;t.error&&(i=FM.convertFrom(t.error)),e.emit(sx.PUBLISH_STATE_CHANGED,Xb(qb({},t),{error:i}))})),e._listenOutputTrackChanged(o),e._speakerId&&o.setAudioOutput(e._speakerId),yield o.capture(s),DD(r)||o.setMute(r),YL(o,o).add("player-state-changed",(t=>{e.emit(sx.AUDIO_PLAY_STATE_CHANGED,Xb(qb({},t),{userId:""}))})),i&&e._room.isJoined&&e._room.publish(o).catch((()=>{})),e._localAudioTrack=o,e._localAudioConfig=Xb(qb({},t),{publish:i}),yield e._updateAudioPlayOption({playOption:a,track:o})}()}))}updateLocalAudio(e){return rC(this,null,(function*(){if(!this._localAudioTrack||!this._localAudioConfig)return;let{publish:t,mute:i,option:r}=e,n={};r&&(r.microphoneId?yield this._localAudioTrack.switchDevice(r.microphoneId):DD(r.audioTrack)||(yield this._localAudioTrack.setInputMediaStreamTrack(r.audioTrack)),DD(r.captureVolume)||this._localAudioTrack.setCaptureVolume(r.captureVolume),DD(r.earMonitorVolume)||(n.muted=!(r.earMonitorVolume>0),n.volume=r.earMonitorVolume),yield this._localAudioTrack.update3A(r)),this._room.isJoined&&!DD(t)&&(t&&!this._localAudioConfig.publish&&this._room.publish(this._localAudioTrack).catch((()=>{})),this._localAudioConfig.publish&&!t&&this._room.unpublish(this._localAudioTrack).catch((()=>{}))),DD(i)||this._localAudioTrack.setMute(i),yield this._updateAudioPlayOption({playOption:n,track:this._localAudioTrack,prevConfig:this._localAudioConfig}),$D(this._localAudioConfig,e)}))}stopLocalAudio(){return rC(this,null,(function*(){!this._localAudioTrack||(this._room.isJoined&&(yield this._room.unpublish(this._localAudioTrack).catch((()=>{}))),this._localAudioTrack.stop(),this._localAudioTrack.close(),this._room.audioManager.removeInput(this._localAudioTrack),JL(this._localAudioTrack),this._localAudioTrack=null,this._localAudioConfig=null)}))}startLocalVideo(){return rC(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0,view:null};return function*(){if(e._localVideoTrack)return void e._log.warn("local video is already started");let{view:i,publish:r=!0,mute:n,option:o}=t,s=new rM(e._room.videoManager),a={},c={};if(o&&(o.cameraId?a.deviceId=o.cameraId:DD(o.useFrontCamera)?DD(o.videoTrack)||(a.customSource=o.videoTrack):a.facingMode=o.useFrontCamera?Mw.FACING_MODE_USER:Mw.FACING_MODE_ENVIRONMENT,DD(o.profile)||(OD(o.profile)?Lw[o.profile]&&s.setProfile(Lw[o.profile]):s.setProfile(o.profile)),DD(o.fillMode)||(c.objectFit=o.fillMode),DD(o.mirror)||(c.mirror=o.mirror),DD(o.small)||(WO()?OD(o.small)?s.small=Lw[o.small]:!0===o.small?s.small=Lw["120p"]:s.small=o.small:e._log.warn("small stream is not supported"))),s.on("5",(t=>{e.emit(sx.ERROR,new FM({code:MM.DEVICE_ERROR,extraCode:5308,messageParams:{error:t}}))})),s.on("2",(t=>{e.emit(sx.DEVICE_CHANGED,{type:"camera",action:"active",device:t})})),s.on("4",(t=>{let i;t.error&&(i=FM.convertFrom(t.error)),e.emit(sx.PUBLISH_STATE_CHANGED,Xb(qb({},t),{error:i}))})),e._listenOutputTrackChanged(s),yield s.capture(a),DD(n)||(yield s.setMute(n)),(null==o?void 0:o.qosPreference)&&s.mediaTrack){let e=cx(o.qosPreference);s.mediaTrack.contentHint=e}YL(s,s).add("player-state-changed",(t=>{e.emit(sx.VIDEO_PLAY_STATE_CHANGED,Xb(qb({},t),{userId:"",streamType:"main"}))})),r&&e._room.isJoined&&e._room.publish(s).catch((()=>{})),e._localVideoTrack=s,e._localVideoConfig=Xb(qb({},t),{view:i,publish:r}),yield e._updateVideoPlayOption({view:i,playOption:c,track:s})}()}))}updateLocalVideo(e){return rC(this,null,(function*(){if(!this._localVideoTrack||!this._localVideoConfig)return;let{view:t,publish:i,mute:r,option:n}=e,o={};if(n){if(DD(n.profile)||(OD(n.profile)?Lw[n.profile]&&this._localVideoTrack.setProfile(Lw[n.profile]):this._localVideoTrack.setProfile(n.profile),(!n.cameraId||!this._localVideoTrack.isNeedToSwitchDevice(n.cameraId))&&DD(n.useFrontCamera)&&this._localVideoTrack.applyProfile()),n.cameraId?yield this._localVideoTrack.switchDevice(n.cameraId):DD(n.useFrontCamera)?DD(n.videoTrack)||(yield this._localVideoTrack.setInputMediaStreamTrack(n.videoTrack)):yield this._localVideoTrack.switchDevice(n.useFrontCamera?Mw.FACING_MODE_USER:Mw.FACING_MODE_ENVIRONMENT),DD(n.fillMode)||(o.objectFit=n.fillMode),DD(n.mirror)||(o.mirror=n.mirror),n.qosPreference&&this._localVideoTrack.mediaTrack){let e=cx(n.qosPreference);this._localVideoTrack.mediaTrack.contentHint=e}if(n.small){let e=!this._localVideoTrack.small;WO()?(!0===n.small?this._localVideoTrack.small=Lw["120p"]:OD(n.small)?this._localVideoTrack.small=Lw[n.small]:this._localVideoTrack.small=n.small,this._room.videoManager.update(),e&&this._room.enableSmall(!0)):this._log.warn("small stream is not supported")}else!1===n.small&&this._localVideoTrack.small&&(delete this._localVideoTrack.small,this._room.videoManager.update(),this._room.enableSmall(!1))}this._room.isJoined&&!DD(i)&&(i&&!this._localVideoConfig.publish&&this._room.publish(this._localVideoTrack).catch((()=>{})),this._localVideoConfig.publish&&!i&&this._room.unpublish(this._localVideoTrack).catch((()=>{}))),DD(r)||(yield this._localVideoTrack.setMute(r)),yield this._updateVideoPlayOption({view:t,playOption:o,track:this._localVideoTrack,prevConfig:this._localVideoConfig}),$D(this._localVideoConfig,e)}))}stopLocalVideo(){return rC(this,null,(function*(){!this._localVideoTrack||(this._room.isJoined&&(yield this._room.unpublish(this._localVideoTrack).catch((()=>{}))),this._localVideoTrack.stop(),this._localVideoTrack.close(),JL(this._localVideoTrack),this._localVideoTrack=null,this._localVideoConfig=null)}))}startScreenShare(){return rC(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0,view:null};return function*(){if(e._localScreenTrack)return void e._log.warn("screen share is already started");let{view:i=null,publish:r=!0,option:n}=t,o=new aM(e._room.videoManager);o.on("4",(t=>{let i;t.error&&(i=FM.convertFrom(t.error)),e.emit(sx.PUBLISH_STATE_CHANGED,Xb(qb({},t),{error:i}))})),e._listenOutputTrackChanged(o);let s=null;o.setMediaType(2);let a={},c={};n&&(DD(n.profile)||(OD(n.profile)?Pw[n.profile]&&o.setProfile(Pw[n.profile]):o.setProfile(n.profile)),n.systemAudio&&(a.systemAudio=!0,a.echoCancellation=n.echoCancellation,a.noiseSuppression=n.noiseSuppression,a.autoGainControl=n.autoGainControl),DD(n.fillMode)||(c.objectFit=n.fillMode),n.videoTrack&&(a.videoTrack=n.videoTrack),n.audioTrack&&(a.audioTrack=n.audioTrack),n.captureElement&&(a.captureElement=n.captureElement),n.preferDisplaySurface&&(a.preferDisplaySurface=n.preferDisplaySurface));let l=yield o.capture(a);if(null!=n&&n.qosPreference){let e=cx(n.qosPreference);o.mediaTrack.contentHint=e}if(o.mediaTrack.addEventListener(Mw.ENDED,(()=>{e._stopScreenShare(),e.emit(sx.SCREEN_SHARE_STOPPED)})),l.getAudioTracks()[0]&&(s=new cM(e._room.audioManager),s.setInputMediaStreamTrack(l.getAudioTracks()[0]),e._speakerId&&s.setAudioOutput(e._speakerId)),YL(o,o).add("player-state-changed",(t=>{e.emit(sx.VIDEO_PLAY_STATE_CHANGED,Xb(qb({},t),{userId:"",streamType:"sub"}))})),r&&e._room.isJoined){let t=[o];s&&t.push(s),e._room.publish(...t).catch((()=>{}))}e._localScreenTrack=o,e._localScreenAudioTrack=s,e._localScreenConfig=Xb(qb({},t),{view:i,publish:r}),yield e._updateVideoPlayOption({view:i,playOption:c,track:o})}()}))}updateScreenShare(e){return rC(this,null,(function*(){if(!this._localScreenTrack||!this._localScreenConfig)return;let{view:t,publish:i,option:r}=e,n={};if(r&&(DD(r.fillMode)||(n.objectFit=r.fillMode),r.qosPreference)){let e=cx(r.qosPreference);this._localScreenTrack.mediaTrack.contentHint=e}this._room.isJoined&&!DD(i)&&(i&&!this._localScreenConfig.publish&&(this._room.publish(this._localScreenTrack).catch((()=>{})),this._localScreenAudioTrack&&this._room.publish(this._localScreenAudioTrack).catch((()=>{}))),this._localScreenConfig.publish&&!i&&(this._room.unpublish(this._localScreenTrack).catch((()=>{})),this._localScreenAudioTrack&&this._room.unpublish(this._localScreenAudioTrack).catch((()=>{})))),yield this._updateVideoPlayOption({view:t,playOption:n,track:this._localScreenTrack,prevConfig:this._localScreenConfig}),$D(this._localScreenConfig,e)}))}stopScreenShare(){return rC(this,null,(function*(){return yield this._stopScreenShare()}))}startRemoteVideo(e){return rC(this,null,(function*(){let{view:t,userId:i,streamType:r,option:n}=e,o="".concat(i,"_").concat(r);if(this._remoteVideoConfigMap.has(o))return void this._log.warn("remote video has already started. userId:".concat(i,", streamType:").concat(r));let s=this._room.remotePublishedUserMap.get(i);if(!s)return;let a={},c="main"===r?s.remoteVideoTrack:s.remoteAuxiliaryTrack;this._listenOutputTrackChanged(c),n&&(DD(n.fillMode)||(a.objectFit=n.fillMode),DD(n.mirror)||(a.mirror=n.mirror),"main"===r&&!DD(n.small)&&this._room.changeType(n.small,c.user)),yield this._room.subscribe(c),yield this._updateVideoPlayOption({view:t,playOption:a,track:c}),this._emitTrackEvent(c),this._remoteVideoConfigMap.set(o,{config:e}),n&&!DD(n.receiveWhenViewVisible)&&this._observeView({remoteTrack:c,view:t,receiveWhenViewVisible:n.receiveWhenViewVisible,viewRoot:null==n?void 0:n.viewRoot})}))}updateRemoteVideo(e){return rC(this,null,(function*(){var t,i;let{view:r,userId:n,streamType:o,option:s}=e,a="".concat(n,"_").concat(o),c=this._remoteVideoConfigMap.get(a);if(!c||!this._room.remotePublishedUserMap.has(n))return;let l={};s&&(DD(s.fillMode)||(l.objectFit=s.fillMode),DD(s.mirror)||(l.mirror=s.mirror));let d=null,u=this._room.remotePublishedUserMap.get(n);if("main"===o&&(null==u?void 0:u.muteState.hasVideo)&&(d=u.remoteVideoTrack),"sub"===o&&(null==u?void 0:u.muteState.hasAuxiliary)&&(d=u.remoteAuxiliaryTrack),!d)return;let{config:h}=c;"main"===o&&s&&!DD(s.small)&&this._room.changeType(s.small,d.user),yield this._updateVideoPlayOption({view:r,playOption:l,track:d,prevConfig:h}),$D(h,e);let p=DD(null==s?void 0:s.receiveWhenViewVisible)?null==(t=h.option)?void 0:t.receiveWhenViewVisible:s.receiveWhenViewVisible,m=DD(r)?h.view:r,_=DD(null==s?void 0:s.viewRoot)?null==(i=h.option)?void 0:i.viewRoot:s.viewRoot;this._observeView({remoteTrack:d,view:m,receiveWhenViewVisible:p,viewRoot:_})}))}stopRemoteVideo(e){return rC(this,null,(function*(){return this._stopRemoteVideo(e)}))}_stopRemoteVideo(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return rC(this,null,(function*(){let i=[],r=this._room.remotePublishedUserMap.get(e.userId);if(r){let{muteState:t,remoteVideoTrack:n,remoteAuxiliaryTrack:o}=r;"main"===e.streamType&&(n.stop(),t.hasVideo&&i.push(n)),"sub"===e.streamType&&(o.stop(),t.hasAuxiliary&&i.push(o))}for(let e of i)t&&(yield this._room.unsubscribe(e),this._mediaTrackMap.get(e.outMediaTrack)===e.userId&&this._mediaTrackMap.delete(e.outMediaTrack));let n=this._remoteVideoConfigMap.get("".concat(e.userId,"_").concat(e.streamType));n&&n.observer&&n.observer.disconnect(),this._remoteVideoConfigMap.delete("".concat(e.userId,"_").concat(e.streamType))}))}muteRemoteAudio(e,t){return rC(this,null,(function*(){if("*"===e)if(t)yield this._stopRemoteAudio({userId:e});else{let e=[...this._room.remotePublishedUserMap.values()];for(let t of e)t.muteState.hasAudio&&(yield this._startRemoteAudio({userId:t.userId}))}else t?yield this._stopRemoteAudio({userId:e}):yield this._startRemoteAudio({userId:e});this._remoteAudioMuteMap.set(e,t)}))}setRemoteAudioVolume(e,t){if("*"===e){let e=[...this._room.remotePublishedUserMap.values()];for(let i of e)this._updateAudioPlayOption({playOption:{volume:t},track:i.remoteAudioTrack})}else if(e){let i=this._room.remotePublishedUserMap.get(e);i&&this._updateAudioPlayOption({playOption:{volume:t},track:i.remoteAudioTrack})}}startPlugin(e,t){return rC(this,null,(function*(){return e.start(t)}))}updatePlugin(e,t){return rC(this,null,(function*(){return e.update(t)}))}stopPlugin(e,t){return rC(this,null,(function*(){return e.stop(t)}))}enableAudioVolumeEvaluation(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._room.enableAudioVolumeEvaluation(e,t)}on(e,t,i){return this.listeners(e).includes(t)||(super.on(e,t,i),this._eventListened.add(e)),this}off(e,t,i){return"*"===e?(this._eventListened.clear(),this.removeAllListeners()):super.off(e,t,i),this}getVideoTrack(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{userId:"",streamType:"main"},{userId:t="",streamType:i="main"}=e;if(""===t){if("main"===i&&this._localVideoTrack)return this._localVideoTrack.mediaTrack;if("sub"===i&&this._localScreenTrack)return this._localScreenTrack.mediaTrack}else{let e=this._room.remotePublishedUserMap.get(t);if(e)return"main"===i?e.remoteVideoTrack.mediaTrack:e.remoteAuxiliaryTrack.mediaTrack}return null}getAudioTrack(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{userId:"",streamType:"main"};var t,i;let r,n="main";if(OD(e)?r=e:(r=e.userId,e.streamType&&(n=e.streamType)),!r)return"sub"===n?(null==(t=this._localScreenAudioTrack)?void 0:t.mediaTrack)||null:(null==(i=this._localAudioTrack)?void 0:i.mediaTrack)||null;{let e=this._room.remotePublishedUserMap.get(r);if(e)return e.remoteAudioTrack.mediaTrack}return null}setCurrentSpeaker(e){var t,i;this._speakerId=e,null==(t=this._localAudioTrack)||t.setAudioOutput(e),null==(i=this._localScreenAudioTrack)||i.setAudioOutput(e),this._room.remotePublishedUserMap.forEach((t=>t.remoteAudioTrack.setAudioOutput(e)))}_startRemoteAudio(e){return this._doStartRemoteAudio(e)}_doStartRemoteAudio(e){return rC(this,null,(function*(){let{userId:t,option:i}=e;if(this._remoteAudioConfigMap.has(t))return void this._log.warn("remote audio has already started. userId:".concat(t));let r=this._room.remotePublishedUserMap.get(t);if(!r)return;let n={};i&&(DD(i.volume)||(n.volume=i.volume));let o=r.remoteAudioTrack;this._listenOutputTrackChanged(o),this._speakerId&&o.setAudioOutput(this._speakerId);try{this._remoteAudioConfigMap.set(t,e),yield this._room.subscribe(o),yield this._updateAudioPlayOption({playOption:n,track:o})}catch(s){throw this._remoteAudioConfigMap.delete(t),s}this._emitTrackEvent(o)}))}_stopRemoteAudio(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return rC(this,null,(function*(){let i=this._room.remotePublishedUserMap.get(e.userId);i&&(i.remoteAudioTrack.stop(),i.muteState.hasAudio&&t&&(yield this._room.unsubscribe(i.remoteAudioTrack)),this._mediaTrackMap.get(i.remoteAudioTrack.outMediaTrack)===e.userId&&this._mediaTrackMap.delete(i.remoteAudioTrack.outMediaTrack)),this._remoteAudioConfigMap.delete("".concat(e.userId))}))}_updateVideoPlayOption(e){return rC(this,arguments,(function(e){let{view:t,playOption:i,track:r,prevConfig:n}=e;return function*(){if(r.setMirror(i.mirror),DD(t)&&n&&n.view&&!JD(i)){let e=tO(n.view);e.length>0&&(yield r.play(e,i))}if(!DD(t)){let e=tO(t);e.length>0?yield r.play(e,i):r.stop()}}()}))}_updateAudioPlayOption(e){return rC(this,arguments,(function(e){let{playOption:t={},track:i,prevConfig:r}=e;return function*(){if(!i.isPlayCalled)try{yield i.play(null,t)}catch(e){}DD(t.muted)||i.setPlayerMute(t.muted),DD(t.volume)||i.setAudioVolume(t.volume/100)}()}))}_listenOutputTrackChanged(e){0===e.listeners("output-media-track-changed").length&&e.on("output-media-track-changed",(()=>this._emitTrackEvent(e)))}_emitTrackEvent(e){let t=e.isRemote?e.userId:"";e.outMediaTrack&&this._mediaTrackMap.get(e.outMediaTrack)!==t&&(this._mediaTrackMap.set(e.outMediaTrack,t),this.emit(sx.TRACK,{userId:t,streamType:ax(e.streamType),track:e.outMediaTrack}))}_checkTrackToPublish(){var e,t,i;let r=[];if((null==(e=this._localAudioConfig)?void 0:e.publish)&&this._localAudioTrack&&r.push(this._localAudioTrack),(null==(t=this._localVideoConfig)?void 0:t.publish)&&this._localVideoTrack&&r.push(this._localVideoTrack),null!=(i=this._localScreenConfig)&&i.publish&&(this._localScreenTrack&&r.push(this._localScreenTrack),this._localScreenAudioTrack&&r.push(this._localScreenAudioTrack)),0!==r.length)return this._room.publish(...r).catch((()=>{}))}_observeView(e){let{remoteTrack:t,view:i,receiveWhenViewVisible:r=!1,viewRoot:n}=e;if(DD(i))return;let o=this._remoteVideoConfigMap.get("".concat(t.userId,"_").concat(ax(t.streamType)));if(!o)return;let s=o.observer||void 0;if(null===i||xD(i)&&0===i.length||!r)return null==s||s.disconnect(),void(t.isSubscribed||this._room.subscribe(t).catch((()=>{})));let a=o.visibleViewMap||new Map,c=-1;(!s||s.root!==n)&&(null==s||s.disconnect(),a.clear(),s=new IntersectionObserver((e=>{e.forEach((e=>{a.set(e.target,e.isIntersecting)})),clearTimeout(c),c=window.setTimeout((()=>{[...a.values()].find((e=>e))?t.isSubscribed||this._room.subscribe(t).catch((()=>{})):t.isSubscribed&&this._room.unsubscribe(t).catch((()=>{}))}),200)}),{root:n}));let l=new Set(tO(i));a.forEach(((e,t)=>{l.has(t)||(s.unobserve(t),a.delete(t))})),l.forEach((e=>{a.set(e,!0),s.observe(e)})),s.takeRecords().forEach((e=>{a.set(e.target,e.isIntersecting)})),o.visibleViewMap=a,o.observer=s}_exitRoom(){return rC(this,null,(function*(){this._room.isJoined&&(yield this._room.leave()),[...this._remoteAudioConfigMap.keys()].forEach((e=>{this._stopRemoteAudio({userId:e}).catch()})),[...this._remoteVideoConfigMap.keys()].forEach((e=>{let t=e.includes("main")?"main":"sub",i=e.split("_".concat(t))[0];i&&this._stopRemoteVideo({userId:i,streamType:t}).catch()})),this._remoteVideoConfigMap.clear(),this._remoteAudioConfigMap.clear(),this._remoteAudioMuteMap.clear(),this._room.remotePublishedUserMap.forEach((e=>{JL(e.remoteAudioTrack),JL(e.remoteVideoTrack),JL(e.remoteAuxiliaryTrack)}))}))}_stopScreenShare(){return rC(this,null,(function*(){var e;if(this._localScreenTrack){if(this._room.isJoined){let t=[this._localScreenTrack];this._localScreenAudioTrack&&t.push(this._localScreenAudioTrack),yield null==(e=this._room)?void 0:e.unpublish(...t).catch((()=>{}))}this._localScreenTrack.stop(),this._localScreenTrack.close(),this._localScreenAudioTrack&&(this._localScreenAudioTrack.stop(),this._localScreenAudioTrack.close(),this._room.audioManager.removeInput(this._localScreenAudioTrack),this._localScreenAudioTrack=null),JL(this._localScreenTrack),this._localScreenTrack=null,this._localScreenConfig=null}}))}_initActiveSpeaker(){return rC(this,null,(function*(){if(kx&&!MP(kx))this.emit(sx.DEVICE_CHANGED,{type:"speaker",action:"active",device:kx});else{let e=yield BP();if(e[0]&&!MP(e[0]))kx=e[0],this.emit(sx.DEVICE_CHANGED,{type:"speaker",action:"active",device:e[0]});else{let e=e=>{let{track:t}=e;"audio"===t.kind&&(!kx||MP(kx))&&(this._initActiveSpeaker(),JN.off("102",this._initActiveSpeaker))};JN.on("102",e)}}}))}_onAudioAvailable(e){let{userId:t}=e;!this._room.autoReceiveAudio||this._remoteAudioMuteMap.get("*")||this._remoteAudioMuteMap.get(t)||this._doStartRemoteAudio({userId:t}).catch((()=>{}))}_onVideoAvailable(e){let{userId:t,streamType:i}=e;if(!this._room.autoReceiveVideo)return;let r=this._room.remotePublishedUserMap.get(t);if(r){let e="main"===i?r.remoteVideoTrack:r.remoteAuxiliaryTrack;this._room.subscribe(e).then((()=>{this._emitTrackEvent(e)})).catch((()=>{}))}}_onAudioUnavailable(e){let{userId:t,muteState:i}=e;i.hasAudio&&i.audioMuted||this._stopRemoteAudio({userId:t},!1).catch((()=>{}))}_onVideoUnavailable(e){let{userId:t,streamType:i}=e;this._stopRemoteVideo({userId:t,streamType:i},!1).catch((()=>{}))}sendSEIMessage(e,t){this._room.sendSEI(e,t||{seiPayloadType:243})}getVideoSnapshot(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{userId:t,streamType:i="main"}=e;if(t){let e=this._room.remotePublishedUserMap.get(t);if("main"===i&&(null==e?void 0:e.muteState.hasVideo))return e.remoteVideoTrack.getVideoFrame();if("sub"===i&&(null==e?void 0:e.muteState.hasAuxiliary))return e.remoteAuxiliaryTrack.getVideoFrame()}else{if("main"===i&&this._localVideoTrack)return this._localVideoTrack.getVideoFrame();if("sub"===i&&this._localScreenTrack)return this._localScreenTrack.getVideoFrame()}return""}static setLogLevel(e,t){EO.setLogLevel(e),DD(t)||(t?EO.enableUploadLog():EO.disableUploadLog())}static isSupported(){return PO()}static getCameraList(){return UP(!0)}static getMicrophoneList(){return VP(!0)}static getSpeakerList(){return BP(!0)}static setCurrentSpeaker(e){return rC(this,null,(function*(){(yield BP()).forEach((t=>{t.deviceId===e&&(Cx.forEach((i=>{i.setCurrentSpeaker(e),i.emit(sx.DEVICE_CHANGED,{type:"speaker",action:"active",device:t})})),kx=t)}))}))}static _addKVStat(e){let{type:t,key:i,value:r,base:n,useUV:o,version:s}=e;switch(s&&(hP.version=s),t){case"count":hP.addCount({key:i,useUV:o});break;case"enum":hP.addEnum({key:i,value:r,useUV:o});break;case"number":hP.addNumber({key:i,value:r,split:n})}}},Nx=wx;tC(Nx,"_loggerManager",EO),tC(Nx,"EVENT",sx),tC(Nx,"ERROR_CODE",MM),tC(Nx,"TYPE",PM),tC(Nx,"frameWorkType",30),eC([ux(JM.TRTC.enterRoom),rx("room",((e,t)=>{let[i]=e,[r]=t;return(i.roomId||i.strRoomId)===(r.roomId||r.strRoomId)&&i.userId===r.userId&&i.sdkAppId===r.sdkAppId})),JP((e=>function(t){return this._log.setUserId(t.userId),this._log.setSdkAppId(t.sdkAppId),e.call(this,t)})),_x()],Nx.prototype,"enterRoom",1),eC([_x()],Nx.prototype,"exitRoom",1),eC([ux(JM.TRTC.switchRole),nx("room",{merge:(e,t)=>t}),_x()],Nx.prototype,"switchRole",1),eC([_x()],Nx.prototype,"destroy",1),eC([ux(JM.TRTC.startLocalAudio),rx("audio",((e,t)=>{let[i]=e,[r]=t;var n,o;return(null==(n=null==i?void 0:i.option)?void 0:n.microphoneId)===(null==(o=null==r?void 0:r.option)?void 0:o.microphoneId)})),_x()],Nx.prototype,"startLocalAudio",1),eC([ux(JM.TRTC.updateLocalAudio),nx("audio",{debounce:{delay:200,getKey:()=>"".concat(bx,"-localAudio"),isNeedToDebounce:e=>{var t;return!DD(null==(t=e.option)?void 0:t.captureVolume)}}}),_x()],Nx.prototype,"updateLocalAudio",1),eC([ox("audio"),_x()],Nx.prototype,"stopLocalAudio",1),eC([ux(JM.TRTC.startLocalVideo),rx("video",((e,t)=>{let[i]=e,[r]=t;var n,o;return(null==(n=null==i?void 0:i.option)?void 0:n.cameraId)===(null==(o=null==r?void 0:r.option)?void 0:o.cameraId)})),_x()],Nx.prototype,"startLocalVideo",1),eC([ux(JM.TRTC.updateLocalVideo),nx("video"),_x()],Nx.prototype,"updateLocalVideo",1),eC([ox("video"),_x()],Nx.prototype,"stopLocalVideo",1),eC([ux(JM.TRTC.startScreenShare),rx("screen",(()=>!0)),_x()],Nx.prototype,"startScreenShare",1),eC([ux(JM.TRTC.updateScreenShare),nx("screen"),_x()],Nx.prototype,"updateScreenShare",1),eC([_x()],Nx.prototype,"stopScreenShare",1),eC([ux(JM.TRTC.startRemoteVideo),rx((e=>"v".concat(e.userId).concat(e.streamType)),(()=>!0)),_x({getRemoteId:e=>"".concat(e.userId,"_").concat(e.streamType)})],Nx.prototype,"startRemoteVideo",1),eC([ux(JM.TRTC.updateRemoteVideo),nx((e=>"v".concat(e.userId).concat(e.streamType))),_x({getRemoteId:e=>"".concat(e.userId,"_").concat(e.streamType)})],Nx.prototype,"updateRemoteVideo",1),eC([ux(JM.TRTC.stopRemoteVideo),JP((e=>function(t){return rC(this,null,(function*(){if("*"===t.userId){let e=[];return this._room.remotePublishedUserMap.forEach((t=>{this._remoteVideoConfigMap.has("".concat(t.userId,"_","main"))&&e.push(this.stopRemoteVideo({streamType:"main",userId:t.userId}).catch((()=>{}))),this._remoteVideoConfigMap.has("".concat(t.userId,"_","sub"))&&e.push(this.stopRemoteVideo({streamType:"sub",userId:t.userId}).catch((()=>{})))})),Promise.all(e)}return e.call(this,t)}))})),_x({getRemoteId:e=>"".concat(e.userId,"_").concat(e.streamType)})],Nx.prototype,"stopRemoteVideo",1),eC([ox((e=>"v".concat(e.userId).concat(e.streamType)))],Nx.prototype,"_stopRemoteVideo",1),eC([ux(...JM.TRTC.muteRemoteAudio),_x({getRemoteId:e=>e})],Nx.prototype,"muteRemoteAudio",1),eC([hx(...JM.TRTC.setRemoteAudioVolume),function(e,t){return JP(((i,r)=>function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];var s,a;let c=null==(s=dx.get(this))?void 0:s.get(t(...n));c&&c>0&&clearTimeout(c);let l=window.setTimeout((()=>{i.apply(this,n)}),e);dx.has(this)?null==(a=dx.get(this))||a.set(t(...n),l):dx.set(this,new Map([[t(...n),l]]))}))}(200,(e=>e)),_x({getRemoteId:e=>e})],Nx.prototype,"setRemoteAudioVolume",1),eC([fx("start"),rx(((e,t)=>e.getAlias()+e.getGroup(t))),_x({replaceArg:e=>({argIndex:0,value:e.getName()}),getKVReportKey:e=>sP[e.getName()]})],Nx.prototype,"startPlugin",1),eC([fx("update"),nx(((e,t)=>e.getAlias()+e.getGroup(t))),_x({replaceArg:e=>({argIndex:0,value:e.getName()}),getKVReportKey:e=>aP[e.getName()]})],Nx.prototype,"updatePlugin",1),eC([fx("stop"),ox(((e,t)=>e.getAlias()+e.getGroup(t))),_x({replaceArg:e=>({argIndex:0,value:e.getName()}),getKVReportKey:e=>cP[e.getName()]})],Nx.prototype,"stopPlugin",1),eC([hx(...JM.TRTC.enableAudioVolumeEvaluation)],Nx.prototype,"enableAudioVolumeEvaluation",1),eC([_x()],Nx.prototype,"setCurrentSpeaker",1),eC([rx((e=>"a".concat(e.userId)),(()=>!0))],Nx.prototype,"_startRemoteAudio",1),eC([JP((e=>function(t){return rC(this,null,(function*(){return"*"===t.userId?Promise.all([...this._room.remotePublishedUserMap.values()].map((e=>this._stopRemoteAudio(Xb(qb({},t),{userId:e.userId})).catch((()=>{}))))):e.call(this,t)}))})),ox((e=>"a".concat(e.userId)))],Nx.prototype,"_stopRemoteAudio",1),eC([ox("room")],Nx.prototype,"_exitRoom",1),eC([ox("screen")],Nx.prototype,"_stopScreenShare",1),eC([ux(JM.TRTC.sendSEIMessage),function(e){let{timesInSecond:t,maxSizeInSecond:i,getSize:r}=e;return JP(((e,n)=>{let o=new Map;return JN.on(fO.ROOM_DESTROY,(e=>{let{room:t}=e;return o.delete(t)})),function(){let s=o.get(this);for(var a=arguments.length,c=new Array(a),l=0;l<a;l++)c[l]=arguments[l];if(s||(s={callCountInSecond:0,timestamp:0,totalSizeInSecond:0},o.set(this,s)),0===s.timestamp?s.timestamp=Date.now():Date.now()-s.timestamp>1e3&&(s.timestamp=Date.now(),s.callCountInSecond=0,s.totalSizeInSecond=0),r&&(s.totalSizeInSecond+=r(...c)),0!==s.timestamp&&Date.now()-s.timestamp<1e3&&(s.callCountInSecond>=t||s.totalSizeInSecond>i))throw new fC({code:_C.INVALID_OPERATION,message:GN({key:HN.CALL_FREQUENCY_LIMIT,data:{isTimes:s.callCountInSecond>=t,isSize:s.totalSizeInSecond>i,name:n,timesInSecond:t,maxSizeInSecond:i}})});s.callCountInSecond++,e.call(this,...c)}}))}({timesInSecond:30,maxSizeInSecond:8e3,getSize:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return t[0].byteLength}})],Nx.prototype,"sendSEIMessage",1),eC([_x()],Nx.prototype,"getVideoSnapshot",1),eC([ux(JM.TRTC.create)],Nx,"_create",1);var Dx=Nx,Ox=class{constructor(){this._set=new Set,JN.on(fO.LEAVE_SUCCESS,this.delete,this)}add(e){let{room:t,roomId:i}=e;if("rtc"===t.scene)return;let r=this.getKey(t.userId,i||t.roomId,t.sdkAppId,t.useStringRoomId);this._set.add(r)}delete(e){let{room:t,roomId:i}=e;if("rtc"===t.scene)return;let r=this.getKey(t.userId,t.roomId||i,t.sdkAppId,t.useStringRoomId);this._set.delete(r)}getKey(e,t,i,r){return"".concat(i,"_").concat(t,"_").concat(e,"_").concat(r)}isJoined(e){let{userId:t,roomId:i,sdkAppId:r,room:n}=e;return"rtc"!==n.scene&&this._set.has(this.getKey(t,i,r,n.useStringRoomId))}};function Lx(){return rC(this,null,(function*(){let e,t;try{let t=yield VP();e=t&&t.length}catch(u){}try{let e=yield UP();t=e&&e.length}catch(u){}let i={microphone:e,camera:t},{isH264EncodeSupported:r,isVp8EncodeSupported:n,isH264DecodeSupported:o,isVp8DecodeSupported:s}=this.checkSystemResult.detail,a=TO.basis(),c={webRTC:a.isWebRTCSupported,getUserMedia:a.isGetUserMediaSupported,webSocket:a.isWebSocketsSupported,screenShare:a.isScreenShareSupported,webAudio:a.isWebAudioSupported,h264Encode:r,h264Decode:o,vp8Encode:n,vp8Decode:s},l={browser:a.browser,os:a.os,trtc:c,devices:i},d={isWebCodecSupported:a.isWebCodecSupported,isMediaSessionSupported:a.isMediaSessionSupported,isWebTransportSupported:a.isWebTransportSupported};XN.uploadEvent({log:"trtcstats-".concat(JSON.stringify(l)),userId:this.userId}),this._log.info("TrtcStats-".concat(JSON.stringify(l))),XN.uploadEvent({log:"trtcadvancedstats-".concat(JSON.stringify(d)),userId:this.userId})}))}var Px=$b(nC(),1),Mx=Symbol("instance"),xx=Symbol("cacheResult"),Vx=class{constructor(e,t,i){this.oldState=e,this.newState=t,this.action=i,this.aborted=!1}abort(e){this.aborted=!0,jx.call(e,this.oldState,new Error("action '".concat(this.action,"' aborted")))}toString(){return"".concat(this.action,"ing")}},Ux=class extends Error{constructor(e,t,i){super(t),this.state=e,this.message=t,this.cause=i}},Bx=new Map;function Fx(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return(r,n,o)=>{let s=i.action||n;if(!i.context){let i=Bx.get(r)||[];Bx.has(r)||Bx.set(r,i),i.push({from:e,to:t,action:s})}let a=o.value;o.value=function(){let r=this;for(var n=arguments.length,o=new Array(n),c=0;c<n;c++)o[c]=arguments[c];if(i.context&&(r=Wx.get("function"==typeof i.context?i.context.call(this,...o):i.context)),r.state===t)return r[xx];r.state instanceof Vx&&r.state.action==i.abortAction&&r.state.abort(r);let l=null;if(Array.isArray(e)?0==e.length?r.state instanceof Vx&&r.state.abort(r):("string"!=typeof r.state||!e.includes(r.state))&&(l=new Ux(r._state,"".concat(r.name," ").concat(s," to ").concat(t," failed: current state ").concat(r._state," not in from config"))):e!==r.state&&(l=new Ux(r._state,"".concat(r.name," ").concat(s," to ").concat(t," failed: current state ").concat(r._state," not from ").concat(e))),l){if(!i.fail){if(i.ignoreError)return l;throw l}i.fail.call(this,l)}let d=r.state,u=new Vx(d,t,s);jx.call(r,u);let h=e=>{var n;return r[xx]=e,u.aborted||(jx.call(r,t),null===(n=i.success)||void 0===n||n.call(this,r[xx])),e},p=e=>{let t=e instanceof Error?e.message:String(e);if(jx.call(r,d,e),!i.fail){if(i.ignoreError)return e;throw e}i.fail.call(this,new Ux(r._state,"action '".concat(s,"' failed :").concat(t),e instanceof Error?e:new Error(t)))};try{let e=a.apply(this,o);return"object"==typeof(m=e)&&m&&"then"in m?e.then(h).catch(p):h(e)}catch(_){p(_)}var m}}}var Hx="undefined"!=typeof window&&window.__AFSM__?(e,t)=>{window.dispatchEvent(new CustomEvent(e,{detail:t}))}:"undefined"!=typeof importScripts?(e,t)=>{postMessage({type:e,payload:t})}:()=>{};function jx(e,t){let i=this._state;this._state=e;let r=e.toString();e&&this.emit(r,i),this.emit(Wx.STATECHANGED,e,i,t),this.updateDevTools({value:e,old:i,err:t instanceof Error?t.message:String(t)})}var Wx=class extends Px.default{constructor(e,t,i){super(),this.name=e,this.groupName=t,this._state=Wx.INIT,e||(e=Date.now().toString(36)),i?Object.setPrototypeOf(this,i):i=Object.getPrototypeOf(this),t||(this.groupName=this.constructor.name);let r=i[Mx];r?this.name=r.name+"-"+r.count++:i[Mx]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){let e=Object.getPrototypeOf(this),t=Bx.get(e)||[],i=new Set,r=[],n=[],o=new Set,s=Object.getPrototypeOf(e);Bx.has(s)&&(s.stateDiagram.forEach((e=>i.add(e))),s.allStates.forEach((e=>o.add(e)))),t.forEach((e=>{let{from:t,to:i,action:o}=e;"string"==typeof t?r.push({from:t,to:i,action:o}):t.length?t.forEach((e=>{r.push({from:e,to:i,action:o})})):n.push({to:i,action:o})})),r.forEach((e=>{let{from:t,to:r,action:n}=e;o.add(t),o.add(r),o.add(n+"ing"),i.add("".concat(t," --\x3e ").concat(n,"ing : ").concat(n)),i.add("".concat(n,"ing --\x3e ").concat(r," : ").concat(n," 🟢")),i.add("".concat(n,"ing --\x3e ").concat(t," : ").concat(n," 🔴"))})),n.forEach((e=>{let{to:t,action:r}=e;i.add("".concat(r,"ing --\x3e ").concat(t," : ").concat(r," 🟢")),o.forEach((e=>{e!==t&&i.add("".concat(e," --\x3e ").concat(r,"ing : ").concat(r))}))}));let a=[...i];return Object.defineProperties(e,{stateDiagram:{value:a},allStates:{value:o}}),a}static get(e){let t;return"string"==typeof e?(t=Wx.instances.get(e),t||Wx.instances.set(e,t=new Wx(e,void 0,Object.create(Wx.prototype)))):(t=Wx.instances2.get(e),t||Wx.instances2.set(e,t=new Wx(e.constructor.name,void 0,Object.create(Wx.prototype)))),t}static getState(e){var t;return null===(t=Wx.get(e))||void 0===t?void 0:t.state}updateDevTools(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Hx(Wx.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},e))}get state(){return this._state}set state(e){jx.call(this,e)}};Wx.STATECHANGED="stateChanged",Wx.UPDATEAFSM="updateAFSM",Wx.INIT="[*]",Wx.ON="on",Wx.OFF="off",Wx.instances=new Map,Wx.instances2=new WeakMap;var zx=$b(nC()),Gx="1",Kx="5",Yx="2",Jx="3",qx="4",Xx={CLIENT_BANNED:9,CHANNEL_SETUP_RESULT:19,CHANNEL_RECONNECT_RESULT:514,JOIN_ROOM_RESULT:20,PEER_JOIN:4134,PEER_LEAVE:4135,STREAM_ADDED:16,STREAM_REMOVED:18,UPLINK_NETWORK_STATS:22,UPDATE_REMOTE_MUTE_STAT:23,PUBLISH_RESULT:4098,PUBLISH_STATE_CHANGE_RESULT:4112,UNPUBLISH_RESULT:4100,SUBSCRIBE_RESULT:4102,UNSUBSCRIBE_RESULT:4104,SUBSCRIBE_CHANGE_RESULT:4106,MUTE_RESULT:4108,UPDATE_OFFER_RESULT:4128,START_PUBLISH_TENCENT_CDN_RES:1286,STOP_PUBLISH_TENCENT_CDN_RES:1288,START_PUBLISH_GIVEN_CDN_RES:777,STOP_PUBLISH_GIVEN_CDN_RES:779,START_MIX_TRANSCODE_RES:781,STOP_MIX_TRANSCODE_RES:783,USER_LIST_RES:4137,SWITCH_ROLE_RES:4110,UPDATE_CONSTRAINT_CONFIG_RES:772,REBUILD_PEER_CONNECTION_RES:4150,SPC_PUBLISH_RESULT:4146,SPC_SUBSCRIBE_RESULT:4156,ABILITY_STATUS_REPORT_RESULT:4158,SERVER_PUBLISH_RESULT:5e3},Qx=[Xx.UPDATE_REMOTE_MUTE_STAT,Xx.UPLINK_NETWORK_STATS,Xx.USER_LIST_RES,Xx.MUTE_RESULT,Xx.SERVER_PUBLISH_RESULT],Zx={CLIENT_BANNED:"client-banned",CHANNEL_SETUP_RESULT:"channel-setup-result",CHANNEL_RECONNECT_RESULT:"channel-reconnect-result",JOIN_ROOM_RESULT:"join-room-result",PEER_JOIN:"peer-join",PEER_LEAVE:"peer-leave",STREAM_ADDED:"stream-added",STREAM_REMOVED:"stream-removed",UPLINK_NETWORK_STATS:"uplink-network-stats",UPDATE_REMOTE_MUTE_STAT:"update-remote-mute-stat",PUBLISH_RESULT:"publish-result",PUBLISH_STATE_CHANGE_RESULT:"publish-state-change-result",UNPUBLISH_RESULT:"unpublish-result",SUBSCRIBE_RESULT:"subscribe-result",SUBSCRIBE_CHANGE_RESULT:"subscribe-change-result",UNSUBSCRIBE_RESULT:"unsubscribe-result",UPDATE_OFFER_RESULT:"update-offer-result",START_PUBLISH_TENCENT_CDN_RES:"start-publish-tencent-cdn-res",STOP_PUBLISH_TENCENT_CDN_RES:"stop-publish-tencent-cdn-res",START_PUBLISH_GIVEN_CDN_RES:"start-publish-given-cdn-res",STOP_PUBLISH_GIVEN_CDN_RES:"stop-publish-given-cdn-res",START_MIX_TRANSCODE_RES:"start-mix-transcode-res",STOP_MIX_TRANSCODE_RES:"stop-mix-transcode-res",USER_LIST_RES:"user-list-res",SWITCH_ROLE_RES:"switch_role_res",MUTE_RESULT:"mute-result",UPDATE_CONSTRAINT_CONFIG_RES:"update-contraint-config-res",REBUILD_PEER_CONNECTION_RES:"rebuild-pc-res",SPC_PUBLISH_RESULT:"spc-publish-result",SPC_SUBSCRIBE_RESULT:"spc-subscribe-result",ABILITY_STATUS_REPORT_RESULT:"ability-status-report",SERVER_PUBLISH_RESULT:"server-publish-result"},$x="publish_change",eV="join",tV="leave",iV="quality_report",rV="mute_uplink",nV="publish",oV="publish_state_change",sV="unpublish",aV="subscribe",cV="unsubscribe",lV="subscribe_change",dV="start_publishing",uV="stop_publishing",hV="start_push_user_cdn",pV="stop_push_user_cdn",mV="start_mcu_mix",_V="stop_mcu_mix",fV="get_user_list",gV="change_role",EV="update_constraint_config",vV="rebuild_pc",yV="join/v2",TV="publish/v2",SV="subscribe/v3",IV="ability_status_report",AV="reconnect",RV=new WeakMap;function bV(e){let{settings:t={retries:5,timeout:2e3},onError:i,onRetrying:r,onRetryFailed:n}=e;return function(e,o,s){let a=YN({retryFunction:s.value,settings:t,onError(t){let{error:r,retry:n,reject:s,retryFuncArgs:a}=t;i&&i.call(this,r,(()=>{var t;null!=(t=RV.get(e))&&t.has(o)?n():s(r)}),s,a)},onRetrying(t,i){var n;ND(r)&&r.call(this,t,i),null!=(n=RV.get(e))&&n.has(o)&&(RV.get(e).get(o).stopRetry=i)},onRetryFailed:n});return s.value=function(){let t=RV.get(e);for(var i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return t?t.set(o,{args:r}):RV.set(e,new Map([[o,{args:r}]])),a.apply(this,r).finally((()=>{var t;return null==(t=RV.get(e))?void 0:t.delete(o)}))},s}}function CV(e){let{fnName:t,callback:i,validateArgs:r=!0}=e;return function(e,n,o){let s=o.value;return o.value=function(){for(var n,o,a=arguments.length,c=new Array(a),l=0;l<a;l++)c[l]=arguments[l];if(null!=(n=RV.get(e))&&n.has(t)){let{stopRetry:n,args:s}=RV.get(e).get(t),a=!0;if(r)for(let e of s)if(!c.find((t=>t===e))){a=!1;break}a&&(i&&i.apply(this,c),n&&n(),null==(o=RV.get(e))||o.delete(t))}return s.apply(this,c)},o}}var kV=new Set,wV=class extends zx.default{constructor(e){var t,i;super(),tC(this,"room"),tC(this,"url"),tC(this,"backupUrl"),tC(this,"race"),tC(this,"_socketInUse"),tC(this,"_socket"),tC(this,"_backupSocket"),tC(this,"_signalInfo",{tinyId:void 0,clientIp:"",signalIp:"",relayIp:"",relayInnerIp:"",relayPort:0}),tC(this,"_currentState","DISCONNECTED"),tC(this,"_isReconnecting",!1),tC(this,"_seq",0),tC(this,"_log"),tC(this,"_lastMessageTime",-1),tC(this,"_connnectStartTime",-1),tC(this,"_stopConnectRetry"),tC(this,"bytesSent",0),tC(this,"bytesReceived",0),tC(this,"keepAlive",!1),this.room=e.room,this.race=!!DD(e.race)||e.race,((null==(i=null==(t=this.room.scheduleResult)?void 0:t.config)?void 0:i.keepAliveClient)||0)-kV.size>0&&this.room.enableSPC&&(this.keepAlive=!0,kV.add(this)),this.url=e.url,this.backupUrl=e.backupUrl,this._seq=0,this._log=EO.createLogger({id:"ws",userId:this.userId,sdkAppId:this.sdkAppId}),this.onmessage=this.onmessage.bind(this),this.onerror=this.onerror.bind(this),this.onclose=this.onclose.bind(this)}get urlParam(){let e="?sdkAppId=".concat(encodeURIComponent(this.sdkAppId),"&userId=").concat(encodeURIComponent(this.userId),"&userSig=").concat(encodeURIComponent(this.userSig),"&keepAlive=").concat(encodeURIComponent(Number(this.keepAlive)));return this.race?"".concat(e,"&race=1"):e}get _urlWithParam(){return"".concat(this.url).concat(this.race?"/v2/ws":"").concat(this.urlParam)}get _backupUrlWithParam(){return"".concat(this.backupUrl).concat(this.race?"/v2/ws":"").concat(this.urlParam)}get isConnected(){return"CONNECTED"===this._currentState}get isConnecting(){return"CONNECTING"===this._currentState}get sdkAppId(){return this.room.sdkAppId}get userId(){return this.room.userId}get userSig(){return this.room.userSig}get isOnline(){return"CONNECTED"===this._currentState&&Date.now()-this._lastMessageTime<12e3}connect(){return rC(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e4;return function*(){if(e.isConnected)return Promise.resolve();e._log.info("connect to [".concat(e.url,", ").concat(e.backupUrl,"]").concat(t?" timeout: ".concat(t):""," keepAlive: ").concat(Number(e.keepAlive))),e.emitConnectionStateChanged("CONNECTING"),e._connnectStartTime=zD();let i=[e.connectWS({url:e._urlWithParam,isMain:!0,timeout:t})];e.race&&e._backupUrlWithParam!==e._urlWithParam&&i.push(e.connectWS({url:e._backupUrlWithParam,isMain:!1,timeout:t})),e._socketInUse=yield WD(i),e.unbindAndCloseSocket(e._socketInUse===e._socket?Mw.BACKUP:Mw.MAIN),e.emitConnectionStateChanged("CONNECTED")}()}))}connectWS(e){let{url:t,timeout:i,isMain:r}=e,n=new WebSocket(t);this.bindSocket(n),r?this._socket=n:this._backupSocket=n;let o=-1;return new Promise(((e,t)=>{n.onclose=t,n.onerror=t,n.onopen=()=>e(n),i&&(o=setTimeout((()=>{this.unbindAndCloseSocket(r?Mw.MAIN:Mw.BACKUP),t(new fC({code:_C.SIGNAL_CHANNEL_SETUP_FAILED,message:"ws connect timeout"}))}),i))})).finally((()=>{n.onclose=null,n.onerror=null,n.onopen=null,clearTimeout(o)}))}bindSocket(e){e.addEventListener("close",this.onclose),e.addEventListener("error",this.onerror),e.addEventListener("message",this.onmessage)}unbindSocket(e){e.removeEventListener("close",this.onclose),e.removeEventListener("error",this.onerror),e.removeEventListener("message",this.onmessage)}unbindAndCloseSocket(e){if(e===Mw.MAIN){if(this._socket){this.unbindSocket(this._socket);try{this._socket.close(1e3)}catch(t){}this._socket=null}}else if(this._backupSocket){this.unbindSocket(this._backupSocket);try{this._backupSocket.close(1e3)}catch(t){}this._backupSocket=null}}onclose(e){if(e.target===this._socketInUse&&(this._log.warn("".concat(e.target===this._socket?"main":"backup"," is closed code:").concat(e.code," ").concat(e.reason)),this.emitConnectionStateChanged("DISCONNECTED"),!e.wasClean||1e3!==e.code)){this._socketInUse.onclose=null,this._socketInUse.close(4011);let e=this._socketInUse===this._socket;this.unbindAndCloseSocket(e?Mw.MAIN:Mw.BACKUP),this._socketInUse=null,this.reconnect()}}onerror(e){this._log.error("".concat(e.target===this._socket?"main":"backup"," error observed")),e.target===this._socketInUse&&(this.unbindAndCloseSocket(Mw.MAIN),this.unbindAndCloseSocket(Mw.BACKUP),this._socketInUse=null,this.reconnect())}onmessage(e){if(!this.isConnected)return;this._lastMessageTime=Date.now(),this.bytesReceived+=aO(e.data);let t=JSON.parse(e.data),{cmd:i,data:r}=t,n=Object.values(Xx),o=Object.keys(Xx)[n.indexOf(i)],s=Zx[o];switch(Qx.includes(i)||(this._log.debug("received ".concat(i," msg: ").concat(e.data)),s&&this._log.info("Received event: [ ".concat(s," ]"))),i){case Xx.CHANNEL_SETUP_RESULT:if(0===t.code)this._signalInfo.clientIp=r.clientIp,this._signalInfo.signalIp=r.signalInnerIp,r.svrTime&&function(e){gC=e-(new Date).getTime();let t=new Date;t.setTime(e),EO.info("baseTime from server: ".concat(t," offset: ").concat(gC))}(r.svrTime),this._log.info("ChannelSetup Success"),pP.addSuccessEvent({key:521701,cost:zD()-this._connnectStartTime}),this._connnectStartTime=-1,this.emit(Gx,{signalInfo:this._signalInfo});else{let e=new fC({code:_C.SIGNAL_CHANNEL_SETUP_FAILED,extraCode:t.code,message:GN({key:HN.SIGNAL_CHANNEL_SETUP_FAILED,data:{errorCode:t.code,errorMsg:t.message}})});this._log.error("".concat(t.code,", ").concat(t.message)),this.close(),pP.addFailedEvent({key:521701,error:e}),this.emit(Kx,e)}break;case Xx.JOIN_ROOM_RESULT:0===t.code&&(this._signalInfo.relayIp=r.relayOuterIp,this._signalInfo.relayInnerIp=r.relayInnerIp,this._signalInfo.relayPort=r.relayPort,this._signalInfo.tinyId=t.tinyId,this._log.info("signalIp:".concat(this._signalInfo.signalIp," clientIp:").concat(this._signalInfo.clientIp," relayIp: ").concat(this._signalInfo.relayIp))),this.emit(s,{data:t});break;default:this.emit(s,{data:t})}}reGetSignalChannelUrl(){return rC(this,null,(function*(){try{$N(!0),yield this.room.schedule(this.room.roomId);let{mainUrl:e,backupUrl:t}=this.room.getSignalChannelUrl();this.url=e,this.backupUrl=t}catch(e){}}))}reconnect(){return rC(this,null,(function*(){if(!this._isReconnecting){if(!this.room.isJoined&&this.keepAlive)return void this.close();this._isReconnecting=!0;try{this._log.warn("reconnect"),yield this.connect();let{roomId:e,useStringRoomId:t}=this.room,{relayIp:i,relayInnerIp:r,relayPort:n}=this._signalInfo,{data:o}=yield this.sendWaitForResponse({command:AV,data:{roomId:e,useStringRoomId:t,relayInnerIp:r,relayOuterIp:i,relayPort:n},responseCommand:Zx.CHANNEL_RECONNECT_RESULT});0===o.code?(this._log.warn("reconnect success"),this.stopReconnection(),pP.addSuccessEvent({key:521702,cost:zD()-this._connnectStartTime}),this._connnectStartTime=-1,this.room.syncUserList(),this.room.checkConnectionsToReconnect()):(pP.addFailedEvent({key:521702,error:o.code}),this._log.warn("reconnect failed, ".concat(o.code," ").concat(o.message)),this.room.reJoin())}catch(e){this._log.error(e),this.room.reJoin()}}}))}send(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.isConnected&&!this.room.isLeft){let i={cmd:e,data:t,userId:this.userId,tinyId:this._signalInfo.tinyId,seq:++this._seq},r=JSON.stringify(i);return this._socketInUse.send(r),this.bytesSent+=aO(r),i.seq}}sendWaitForResponse(e){let{command:t,data:i,timeout:r=5e3,responseCommand:n,commandDesc:o,enableLog:s=!0}=e;return new Promise(((e,a)=>{let c=setTimeout((()=>{this.off(n,l);let e=new fC({code:_C.API_CALL_TIMEOUT,message:GN({key:HN.API_CALL_TIMEOUT,data:{commandDesc:o,command:t}})});s&&this._log.warn(e),a(e)}),r),l=t=>{t.data.seq===d&&(clearTimeout(c),this.off(n,l),e(t))};this.on(n,l);let d=this.send(t,i)}))}sendWaitForResponseWithRetry(e){let{commandDesc:t,command:i,retries:r=0,retryTimeout:n=0}=e;return YN({retryFunction:this.sendWaitForResponse,onRetrying:e=>{this._log.warn("".concat(t||i," timeout observed, retrying [").concat(e,"/").concat(r,"]"))},settings:{retries:r,timeout:n},context:this})(e)}getCurrentState(){return this._currentState}getSignalInfo(){return this._signalInfo}stopReconnection(){this._isReconnecting=!1,this._stopConnectRetry&&this._stopConnectRetry()}close(){this._log.info("closed"),kV.delete(this),this.stopReconnection(),this._signalInfo={tinyId:void 0,clientIp:"",signalIp:"",relayIp:"",relayInnerIp:"",relayPort:0},this._socketInUse=null,this.bytesSent=0,this.bytesReceived=0,this._stopConnectRetry&&this._stopConnectRetry(),this.unbindAndCloseSocket(Mw.MAIN),this.unbindAndCloseSocket(Mw.BACKUP),this.emitConnectionStateChanged("DISCONNECTED")}stopKeepAliveIn(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:3600;if(this.keepAlive){this._log.info("stopKeepAlive in ".concat(e,"s"));let t=setTimeout((()=>{this.keepAlive=!1,this._log.info("close due to not used ".concat(e,"s")),this.close()}),1e3*e),i=e=>{e instanceof Vx&&"join"===e.action&&(this._log.info("stopKeepAlive clear timeout"),clearTimeout(t),this.room.off(Wx.STATECHANGED,i))};this.room.on(Wx.STATECHANGED,i)}}emitConnectionStateChanged(e){e!==this._currentState&&(this._log.info("".concat(this._currentState," -> ").concat(e)),this.emit(Yx,{prevState:this._currentState,state:e}),this._currentState=e,"CONNECTED"===e&&this.emit(Jx))}};eC([bV({settings:{retries:1/0,timeout:2e3},onError(e,t){this.room.isDestroyed||t()},onRetrying(e,t){this._log.warn("retrying to connect ".concat(e)),e>=3&&e%3==0&&this.reGetSignalChannelUrl(),t&&(this._stopConnectRetry=t,this.room.isDestroyed&&t())}})],wV.prototype,"connect",1);var NV=$b(nC()),DV=0,OV=!1,LV=new Set,PV=!1,MV=class{constructor(e){tC(this,"userId"),tC(this,"tinyId"),tC(this,"_sdpSemantics"),tC(this,"_isUplink"),tC(this,"_room"),tC(this,"_log"),tC(this,"_signalChannel"),tC(this,"_isErrorObserved",!1),tC(this,"_waitForPeerConnectionConnectedPromise"),tC(this,"_waitForPeerConnectionConnectedPromiseReject",null),tC(this,"_peerConnection",null),tC(this,"_emitter",new NV.default),tC(this,"_currentState","DISCONNECTED"),tC(this,"_isReconnecting",!1),tC(this,"_reconnectionCount",0),tC(this,"_reconnectionTimer",-1),tC(this,"_isFirstConnection",!0),tC(this,"_prevTime",-1),tC(this,"_enableSEI"),tC(this,"_sei"),tC(this,"_localAddress"),tC(this,"_remoteAddress"),this.userId=e.userId,this.tinyId=e.tinyId,this._room=e.room,this._sdpSemantics=e.room.sdpSemantics,this._isUplink=e.isUplink,this._log=EO.createLogger({id:"n-mpc",userId:this._room.userId,remoteUserId:this.userId,sdkAppId:this._room.sdkAppId,isLocal:this._isUplink}),this._signalChannel=e.signalChannel,this._enableSEI=e.enableSEI}beforeConnect(){this._prevTime<0&&(this._prevTime=zD())}afterConnect(e){return rC(this,null,(function*(){try{yield e,this._isFirstConnection?(this._isFirstConnection=!1,pP.addSuccessEvent({key:521705,cost:Math.min(zD()-this._prevTime,3e4)})):this._isReconnecting&&pP.addSuccessEvent({key:521706,cost:zD()-this._prevTime}),this._prevTime=-1}catch(t){throw this._isFirstConnection?(this._isFirstConnection=!1,pP.addFailedEvent({key:521705,error:t})):this._isReconnecting&&this._reconnectionCount>=3&&pP.addFailedEvent({key:521706,error:t}),t}}))}initialize(){let e={encodedInsertableStreams:this._enableSEI&&tL,iceServers:this._room.getIceServers(),iceTransportPolicy:this._room.getIceTransportPolicy(),sdpSemantics:this._sdpSemantics,bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",tcpCandidatePolicy:"disable",IceTransportsType:"nohost"};this._peerConnection=new RTCPeerConnection(e),this._peerConnection.onconnectionstatechange=this.onConnectionStateChange.bind(this)}close(e){this._log.info("close connection"),this._emitter.emit("closed",e),this._isReconnecting&&this.stopReconnection(),this.closePeerConnection(),this._sei&&(this._sei.destroy(),this._sei=null),LV.delete(this)}closePeerConnection(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._peerConnection&&(this._log.info("close pc"),this._peerConnection.onconnectionstatechange=null,this._peerConnection.close(),this._peerConnection=null,e&&this.emitConnectionStateChangedEvent("DISCONNECTED")),this._waitForPeerConnectionConnectedPromiseReject&&this._waitForPeerConnectionConnectedPromiseReject(new fC({code:_C.API_CALL_ABORTED,message:"connection closed"}))}getDTLSTransportState(){if(!this._peerConnection)return iN;let e=null;if(this._isUplink){if(!KO()||0===this._peerConnection.getSenders().length)return iN;e=this._peerConnection.getSenders()[0].transport}else{if(!GO()||0===this._peerConnection.getReceivers().length)return iN;e=this._peerConnection.getReceivers()[0].transport}return e?e.state:iN}onConnectionStateChange(e){let t=this._peerConnection.iceConnectionState,i=this.getDTLSTransportState();if(this._log.info("connectionState: ".concat(e.target.connectionState,", ICE: ").concat(t,", DTLS: ").concat(i)),e.target.connectionState===rN.CONNECTING&&this.emitConnectionStateChangedEvent("CONNECTING"),e.target.connectionState===rN.FAILED||e.target.connectionState===rN.CLOSED){let r="connection ".concat(e.target.connectionState,". ICE Transport state: ").concat(t,", DTLS Transport state: ").concat(i),n=new fC({message:r,code:_C.ICE_TRANSPORT_ERROR});this.emitConnectionStateChangedEvent("DISCONNECTED"),this.startReconnection(),this._isErrorObserved||this._emitter.emit("error",n)}(e.target.connectionState===rN.CONNECTED||e.target.connectionState===rN.COMPLETED)&&(this.logSelectedCandidate(),XN.logSuccessEvent({userId:this._room.userId,eventType:lN.ICE_CONNECTION_STATE}),this.emitConnectionStateChangedEvent("CONNECTED"))}emitConnectionStateChangedEvent(e){return e!==this._currentState&&("CONNECTED"===e?(DV=0,OV=!1,PV=!0,LV.add(this)):LV.delete(this),JN.emit(fO.PEER_CONNECTION_STATE_CHANGED,{room:this._room,prevState:this._currentState,state:e,remoteUserId:this._isUplink?void 0:this.userId}),this._emitter.emit("connection-state-changed",{prevState:this._currentState,state:e}),this._currentState=e,!0)}getPeerConnection(){return this._peerConnection}getRoom(){return this._room}getUserId(){return this.userId}getTinyId(){return this.tinyId}logSelectedCandidate(){return rC(this,null,(function*(){if(!this._peerConnection)return;let e=yield this._peerConnection.getStats();for(let[,t]of e)if(UO(t)){let i=e.get(t.localCandidateId),r=e.get(t.remoteCandidateId);i&&(this._log.info("local candidate: ".concat(i.candidateType," ").concat(i.protocol,":").concat(i.ip||i.address,":").concat(i.port," ").concat(i.networkType||""," ").concat("relay"===i.candidateType?"relayProtocol:".concat(i.relayProtocol):"")),this._localAddress="".concat(i.ip||i.address,":").concat(i.port)),r&&(this._log.info("remote candidate: ".concat(r.candidateType," ").concat(r.protocol,":").concat(r.ip||r.address,":").concat(r.port)),this._remoteAddress="".concat(r.protocol,":").concat(r.ip||r.address));break}}))}getCurrentState(){return this._currentState}waitForPeerConnectionConnected(){return this._waitForPeerConnectionConnectedPromise||(this._waitForPeerConnectionConnectedPromise=new Promise(((e,t)=>{if("CONNECTED"===this._currentState)return e();this._waitForPeerConnectionConnectedPromiseReject=t;let i=t=>{"CONNECTED"===t.state&&(clearTimeout(o),n(),e())},r=e=>{let{room:i}=e;i===this._room&&(clearTimeout(o),n(),t(new fC({code:_C.API_CALL_ABORTED,message:GN({key:HN.CONNECTION_ABORTED,data:"leave room"})})))},n=()=>{JN.off(fO.LEAVE_SUCCESS,r,this),this._emitter.off("connection-state-changed",i,this)},o=setTimeout((()=>{n();let e=new fC({code:_C.API_CALL_TIMEOUT,message:"connection timeout"});var i;DV+=1,i=this._signalChannel.isConnected,DV>2&&!OV&&0===LV.size&&i&&(this._log.warn("firewall restrition"),OV=!0,this._emitter.emit("firewall-restriction")),t(e)}),TN);JN.on(fO.LEAVE_SUCCESS,r,this),this._emitter.on("connection-state-changed",i,this)})),this._waitForPeerConnectionConnectedPromise=this._waitForPeerConnectionConnectedPromise.finally((()=>{this._waitForPeerConnectionConnectedPromise=null,this._waitForPeerConnectionConnectedPromiseReject=null}))),this._waitForPeerConnectionConnectedPromise}getReconnectionCount(){return this._reconnectionCount}startReconnection(){this._isReconnecting=!0,this.reconnect()}clearReconnectionTimer(){-1!==this._reconnectionTimer&&(clearTimeout(this._reconnectionTimer),this._reconnectionTimer=-1)}stopReconnection(){this._log.info("stop reconnection"),this._isReconnecting=!1,this._reconnectionCount=0,this.clearReconnectionTimer(),this._signalChannel.off(Jx,this.reconnect,this)}beforeReconnect(){if(-1!==this._reconnectionTimer)return this._log.warn("reconnect() is reconnecting, ignore"),-1;if(this._reconnectionCount>=sN()){this._log.warn("SDK has tried reconnect for ".concat(this._reconnectionCount," times, but all failed, please check your network")),this.stopReconnection();let e=new fC({code:this._isUplink?_C.UPLINK_RECONNECTION_FAILED:_C.DOWNLINK_RECONNECTION_FAILED,message:GN({key:this._isUplink?HN.UPLINK_RECONNECTION_FAILED:HN.DOWNLINK_RECONNECTION_FAILED})});return this.emitConnectionStateChangedEvent("DISCONNECTED"),this._emitter.emit("error",e),-1}return this._signalChannel.isConnected?(this._reconnectionCount+=1,this._log.warn("reconnect() trying [".concat(this._reconnectionCount,"]")),1):(this._log.warn("reconnect() signal channel is not connected, suspend reconnection until signal is connected"),this._signalChannel.once(Jx,this.reconnect,this),-1)}on(e,t,i){this._emitter.on(e,t,i)}off(e,t,i){this._emitter.off(e,t,i)}getIsReconnecting(){return this._isReconnecting}get isH264(){var e,t;return!(null==(t=null==(e=this._peerConnection)?void 0:e.remoteDescription)||!t.sdp.includes("H264"))}},xV=$b(hC()),VV=function(e){return xV.default.parse(e)},UV=function(e){return xV.default.write(e)};function BV(e){return Object.keys(e).filter((t=>e[t]))}var FV=class extends MV{constructor(e){super(Xb(qb({},e),{isUplink:!1})),tC(this,"_flag",0),tC(this,"role","anchor"),tC(this,"remoteAudioTrack"),tC(this,"remoteVideoTrack"),tC(this,"remoteAuxiliaryTrack"),tC(this,"ssrc",{audio:0,video:0,auxiliary:0}),tC(this,"_isSDPExchanging",!1),this.flag=e.flag,this.remoteAudioTrack=e.remoteAudioTrack||new hM(this._room,this),this.remoteVideoTrack=e.remoteVideoTrack||new pM(this._room,this),this.remoteAuxiliaryTrack=e.remoteAuxiliaryTrack||new mM(this._room,this)}get subscribeState(){let e={audio:!1,video:!1,auxiliary:!1,smallVideo:!1};return this.remoteVideoTrack.isSubscribed&&(8&this.remoteVideoTrack.mediaType?e.smallVideo=!0:e.video=!0),this.remoteAudioTrack.isSubscribed&&(e.audio=!0),this.remoteAuxiliaryTrack.isSubscribed&&(e.auxiliary=!0),e}get muteState(){return qD(this.flag,this.userId)}get flag(){return this._flag}set flag(e){var t,i,r;e!==this._flag&&(this._flag=e,null==(t=this.remoteAudioTrack)||t.onFlagChanged(),null==(i=this.remoteVideoTrack)||i.onFlagChanged(),null==(r=this.remoteAuxiliaryTrack)||r.onFlagChanged())}get hasMainStream(){return this.muteState.hasAudio||this.muteState.hasVideo||this.muteState.hasSmall}get hasAuxStream(){return this.muteState.hasAuxiliary}get isMainStreamSubscribed(){return(this.subscribeState.audio||this.subscribeState.video||this.subscribeState.smallVideo)&&(this.muteState.hasAudio||this.muteState.hasVideo||this.muteState.hasSmall)}get isAuxStreamSubscribed(){return this.subscribeState.auxiliary&&this.muteState.hasAuxiliary}get isSmallStreamSubscribed(){return this.subscribeState.smallVideo&&this.muteState.hasSmall}get isBigStreamSubscribed(){return this.subscribeState.video&&this.muteState.hasVideo}isStreamUnpublished(e){return e===Mw.MAIN?!this.muteState.hasAudio&&!this.muteState.hasVideo:!this.muteState.hasAuxiliary}initialize(){super.initialize(),this.installEvents(),this._peerConnection.ontrack=this.onTrack.bind(this)}close(e){super.close(e),this.emitConnectionStateChangedEvent("DISCONNECTED"),this.remoteAudioTrack.close(),this.remoteVideoTrack.close(),this.remoteAuxiliaryTrack.close(),this.uninstallEvents()}installEvents(){}uninstallEvents(){this._emitter.removeAllListeners()}emitConnectionStateChangedEvent(e){var t,i;let r=this._currentState,n=super.emitConnectionStateChangedEvent(e);return n&&r!==e&&(null==(t=this.remoteVideoTrack)||t.emit("connection-state-changed",{prevState:r,state:e}),null==(i=this.remoteAuxiliaryTrack)||i.emit("connection-state-changed",{prevState:r,state:e})),n}onTrack(e){let t=e.streams[0],{track:i}=e,r=t.id===Gw?Mw.MAIN:Mw.AUXILIARY;this._log.debug("ontrack ".concat(r," ").concat(i.kind));let n=Mw.AUDIO;i.kind===Mw.VIDEO&&(n=r===Mw.MAIN?Mw.VIDEO:Mw.AUXILIARY);let o=this.remoteAudioTrack;n===Mw.VIDEO?o=this.remoteVideoTrack:n===Mw.AUXILIARY&&(o=this.remoteAuxiliaryTrack),o.setInputMediaStreamTrack(i)}addRRTRLine(e){let t=e.split("\r\n"),i=new Map;t.forEach(((e,r)=>{/^a=rtcp-fb:/.test(e)&&t[r+1]&&!/^a=rtcp-fb:/.test(t[r+1])&&i.set(r+1,"".concat(e.match(/^a=rtcp-fb:\d+/)[0]," rrtr"))}));let r=[...i];for(let n=0;n<r.length;n++){let[e,i]=r[n];t.splice(e+n,0,i)}return t.join("\r\n")}addSPSDescription(e){let t=VV(e);return t.media.forEach((e=>{e.type===Mw.VIDEO&&e.fmtp.forEach((e=>{e.config+=";sps-pps-idr-in-keyframe=1"}))})),UV(t)}removeSDESDescription(e){let t=["urn:ietf:params:rtp-hdrext:sdes:mid","urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id","urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"],i=VV(e);return i.media.forEach((e=>{!e.ext||(e.ext=e.ext.filter((e=>!t.includes(e.uri))))})),UV(i)}isSubscriptionStateNotChanged(e){return JSON.stringify(e)===JSON.stringify(this.subscribeState)}subscribe(e,t){return rC(this,null,(function*(){var i,r;try{if(((null==(i=this._peerConnection)?void 0:i.connectionState)===rN.NEW||(null==(r=this._peerConnection)?void 0:r.connectionState)===rN.CONNECTING)&&(yield this.waitForPeerConnectionConnected()),this.isSubscriptionStateNotChanged(e))return void(this._peerConnection||(this.initialize(),yield this.connect(e)));if(this._log.info("subscribe ".concat(t," ").concat(JSON.stringify(e))),this._peerConnection||this._isSDPExchanging){let t="subscribe_change";Object.values(e).find((e=>!0===e))||(t="unsubscribe"),yield this.sendSubscription(t,e)}else this.initialize(),yield this.connect(e)}catch(n){throw this._room.isJoined&&this.isStreamUnpublished(t)?(this._log.warn("".concat(n.message," ").concat(JSON.stringify(this.muteState))),new fC({code:_C.REMOTE_STREAM_NOT_EXIST,message:"remote user ".concat(this.userId," unpublished stream")})):n}}))}unsubscribe(e){return rC(this,arguments,(function(e){var t=this;let{remoteTracks:i,streamType:r}=e;return function*(){if("CONNECTED"===t._currentState&&("main"===r&&!t.isMainStreamSubscribed||"auxiliary"===r&&!t.isAuxStreamSubscribed))return void t._log.info("".concat(r," stream already unsubscribed"));let e=qb({},t.subscribeState);i.forEach((t=>{switch(t.mediaType){case 1:e.audio=!1;break;case 4:e.video=!1;break;case 8:e.smallVideo=!1;break;case 2:e.auxiliary=!1}}));let n="subscribe_change";Object.values(e).find((e=>!0===e))||(n="unsubscribe"),t._log.info("".concat("unsubscribe"===n?n:"subscribe"," ").concat(r," [").concat(BV(e),"]")),yield t.sendSubscription(n,e),"unsubscribe"===n&&(t.closePeerConnection(),t.emitConnectionStateChangedEvent("DISCONNECTED"))}()}))}sendSubscription(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.subscribeState,i={srcTinyId:this.tinyId,srcUserId:this.userId},r=cV,n=Zx.UNSUBSCRIBE_RESULT;return"subscribe_change"===e&&(i={audio:t.audio,bigVideo:t.video,auxVideo:t.auxiliary,smallVideo:t.smallVideo,srcTinyId:this.tinyId},r=lV,n=Zx.SUBSCRIBE_CHANGE_RESULT),this._signalChannel.sendWaitForResponse({command:r,data:i,responseCommand:n,timeout:1e4}).then((t=>{let{data:i}=t;if(0!==i.code){let t=new fC({code:i.code,message:GN({key:HN.ERROR_MESSAGE,data:{type:e,message:i.message}})});throw this._log.error(t),t}}))}connect(){return rC(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.subscribeState;return function*(){try{yield e.exchangeSDP(t),yield e.waitForPeerConnectionConnected()}catch(i){throw e.closePeerConnection(!0),i}}()}))}exchangeSDP(e){return rC(this,null,(function*(){try{this._isSDPExchanging=!0,yield this.createOffer(),this._log.info("createOffer success, sending offer");let{type:t,sdp:i}=this._peerConnection.localDescription,r={type:t,sdp:i,srcUserId:this.userId,srcTinyId:this.tinyId,audio:e.audio,bigVideo:e.video,auxVideo:e.auxiliary,smallVideo:e.smallVideo},n=yield this._signalChannel.sendWaitForResponse({command:aV,commandDesc:"exchange sdp",data:r,responseCommand:Zx.SUBSCRIBE_RESULT,timeout:hN});if(!this._peerConnection){let e=new fC({code:_C.INVALID_OPERATION,message:GN({key:HN.CONNECTION_CLOSED})});throw this._log.warn(e),e}yield this.onSubscribeResult(n),this._isSDPExchanging=!1}catch(t){throw this._isSDPExchanging=!1,t}}))}createOffer(){return rC(this,null,(function*(){let e={voiceActivityDetection:!1};JO()&&this._sdpSemantics===pN?(this._peerConnection.addTransceiver(Mw.AUDIO,{direction:xw.RECVONLY}),this._peerConnection.addTransceiver(Mw.VIDEO,{direction:xw.RECVONLY}),this._peerConnection.addTransceiver(Mw.VIDEO,{direction:xw.RECVONLY})):(e.offerToReceiveAudio=!0,e.offerToReceiveVideo=!0);let t=yield this._peerConnection.createOffer(e);if(t.sdp){let{isH264DecodeSupported:e}=yield LO();e||(this._log.warn("remove h264 desc from sdp"),t.sdp=function(e){let t=VV(e);return t.media.forEach((e=>{var t,i;if(e.type===Mw.VIDEO){let r=new Set;e.rtp.forEach((e=>{let{payload:t,codec:i}=e;return"H264"===i&&r.add(t)})),e.fmtp.forEach((e=>{let{payload:t,config:i}=e,n=i.match(/apt=(\d+)/);n&&n[1]&&r.has(Number(n[1]))&&r.add(t)}));let n=e=>{let{payload:t}=e;return!r.has(t)};e.rtp=e.rtp.filter(n),e.rtcpFb=null==(t=e.rtcpFb)?void 0:t.filter(n),e.fmtp=e.fmtp.filter(n),e.payloads=null==(i=e.payloads)?void 0:i.split(" ").filter((e=>!r.has(Number(e)))).join(" ")}})),UV(t)}(t.sdp)),t.sdp=this.addRRTRLine(t.sdp),t.sdp=this.addSPSDescription(t.sdp),t.sdp=function(e){let t=VV(e);return t.media.forEach((e=>{e.type===Mw.AUDIO&&e.fmtp.forEach((e=>{e.config+=";sprop-stereo=1;stereo=1"}))})),UV(t)}(t.sdp),this._sdpSemantics===pN&&(t.sdp=this.removeSDESDescription(t.sdp))}yield this._peerConnection.setLocalDescription(t)}))}onSubscribeResult(e){return rC(this,null,(function*(){let{code:t,message:i=""}=e&&e.data||{},{type:r,sdp:n}=e&&e.data&&e.data.data||{};if(t===_N)throw new fC({code:_C.NOT_SUPPORTED_H264,message:GN({key:HN.NOT_SUPPORTED_H264DECODE})});try{if(0!==t)throw new fC({code:t,message:GN({key:HN.EXCHANGE_SDP_FAILED,data:{errMsg:i}})});this._log.debug("accept remote answer: ".concat(n)),yield this._peerConnection.setRemoteDescription({type:r,sdp:n}),this._sei&&(this._sei.handleEncodedStreams(),this._sei.onSEIMessage=e=>{this._emitter.emit("sei-message",Xb(qb({},e),{userId:this.userId}))}),this.updateSSRC(n)}catch(o){throw this._log.error(o),o}}))}updateSSRC(e){try{VV(e).media.forEach((e=>{if(e.ssrcs)if(e.type===Mw.AUDIO){let t=e.ssrcs.find((e=>{var t;return null==(t=e.value)?void 0:t.includes(Gw)}));t&&(this.ssrc.audio=Number(t.id))}else{let t=e.ssrcs.find((e=>{var t;return null==(t=e.value)?void 0:t.includes(Gw)})),i=e.ssrcs.find((e=>{var t;return null==(t=e.value)?void 0:t.includes(Kw)}));t&&(this.ssrc.video=Number(t.id)),i&&(this.ssrc.auxiliary=Number(i.id))}}))}catch(t){}}getMainStreamVideoTrackId(){return this.remoteVideoTrack&&this.remoteVideoTrack.mediaTrack?this.remoteVideoTrack.mediaTrack.id:""}getAuxStreamVideoTrackId(){return this.remoteAuxiliaryTrack&&this.remoteAuxiliaryTrack.mediaTrack?this.remoteAuxiliaryTrack.mediaTrack.id:""}reconnect(){return rC(this,null,(function*(){if(!(iC(FV.prototype,this,"beforeReconnect").call(this)<0))try{this.closePeerConnection(),this.initialize(),yield this.connect(),this.stopReconnection(),this._log.warn("reconnect() success")}catch(e){let t=kD(this._reconnectionCount);this._log.warn("reconnect() timeout, try again after ".concat(t/1e3,"s")),this._reconnectionTimer=setTimeout((()=>{this.clearReconnectionTimer(),this.reconnect()}),t)}}))}getIsReconnecting(){return this._isReconnecting}clearReconnectionTimer(){-1!==this._reconnectionTimer&&(clearTimeout(this._reconnectionTimer),this._reconnectionTimer=-1)}getCurrentState(){return this._currentState}setDelay(e){let{audioDelay:t,videoDelay:i}=e;this.remoteAudioTrack.stat.end2EndDelay=t,this.remoteVideoTrack.stat.end2EndDelay=i}},HV=FV;eC([JP((e=>function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];return new Promise(((t,r)=>{let n=e=>{this._emitter.off("closed",n),r(new fC({code:_C.API_CALL_ABORTED,message:GN({key:HN.CONNECTION_ABORTED,data:e})}))};this._emitter.on("closed",n),e.apply(this,i).then(t,r).finally((()=>{this._emitter.off("closed",n)}))}))}))],HV.prototype,"subscribe",1),eC([YP(MV.prototype.afterConnect),KP(MV.prototype.beforeConnect)],HV.prototype,"connect",1);var jV=HV,WV={voiceActivityDetection:!1},zV=class extends MV{constructor(e){super(Xb(qb({},e),{isUplink:!0})),tC(this,"localMainAudioTrack",null),tC(this,"localMainVideoTrack",null),tC(this,"localAuxAudioTrack",null),tC(this,"localAuxVideoTrack",null),tC(this,"ssrc",{audio:0,video:0,small:0,auxiliary:0}),tC(this,"_isPublishingAux",!1),tC(this,"_publishingLocalAudioTrack"),tC(this,"_publishingLocalVideoTrack"),tC(this,"_mediaSettings",{videoCodec:"",videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioCodec:"opus",audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0,auxVideoWidth:0,auxVideoHeight:0,auxVideoFps:0,auxVideoBps:0}),tC(this,"_audioManager"),this._audioManager=e.audioManager}get isMainStreamPublished(){return!(!this.localMainAudioTrack&&!this.localMainVideoTrack)}get isAuxStreamPublished(){return!(!this.localAuxVideoTrack&&!this.localAuxAudioTrack)}get publishState(){var e,t,i,r;let n={audio:!1,bigVideo:!1,smallVideo:!1,auxVideo:!1};if(this._peerConnection){let o=this._peerConnection.getSenders();o&&(YO()?(n.audio=!(null==(e=o[0])||!e.track),n.bigVideo=!(null==(t=o[1])||!t.track),n.smallVideo=!(null==(i=o[2])||!i.track),n.auxVideo=!(null==(r=o[3])||!r.track)):o.forEach((e=>{e.track&&(e.track.kind===Mw.AUDIO?n.audio=!0:(n.bigVideo=!0,this._room.videoManager.hasSmall&&(n.smallVideo=!0)))})))}return n}initialize(){super.initialize(),this.installEvents()}reset(){this._isReconnecting&&this.stopReconnection(),this.closePeerConnection(),this.uninstallEvents()}close(e){super.close(e),this.reset(),this.emitConnectionStateChangedEvent("DISCONNECTED")}installEvents(){this._emitter.listeners("connection-state-changed").includes(this.handleConnectionStateChange)||this._emitter.on("connection-state-changed",this.handleConnectionStateChange,this)}uninstallEvents(){this._emitter.off("connection-state-changed",this.handleConnectionStateChange,this)}emitConnectionStateChangedEvent(e,t){var i,r,n;let o=this._currentState,s=super.emitConnectionStateChangedEvent(e);return s&&o!==e&&(t?t.emit("connection-state-changed",{prevState:o,state:e}):(null==(i=this.localMainVideoTrack)||i.emit("connection-state-changed",{prevState:o,state:e}),null==(r=this.localAuxVideoTrack)||r.emit("connection-state-changed",{prevState:o,state:e}),null==(n=this._publishingLocalVideoTrack)||n.emit("connection-state-changed",{prevState:o,state:e}))),s}publish(e){return rC(this,arguments,(function(e){var t=this;let{localAudioTrack:i,localVideoTrack:r,isAuxiliary:n}=e;return function*(){var e;let o;t._peerConnection||t.initialize(),i&&(t._publishingLocalAudioTrack=i),r&&(t._publishingLocalVideoTrack=r),t._isPublishingAux=n,r&&!n&&r.small&&(o=t._room.videoManager.smallTrack),t.sendMediaSettings(),JO()?yield t.publishByTransceiver({localAudioTrack:i,localVideoTrack:r,smallTrack:o,isAuxiliary:n}):yield t.publishByAddTrack({localAudioTrack:i,localVideoTrack:r,smallTrack:o}),t._publishingLocalAudioTrack=null,t._publishingLocalVideoTrack=null,t._isPublishingAux=!1,n?(r&&(t.localAuxVideoTrack=r),i&&(t.localAuxAudioTrack=i)):(r&&(t.localMainVideoTrack=r),i&&(t.localMainAudioTrack=i)),null==(e=t._sei)||e.handleEncodedStreams(),t.installTrackMuteEvents(i,r),t.sendMutedFlag()}()}))}publishByTransceiver(e){return rC(this,arguments,(function(e){var t=this;let{localAudioTrack:i,localVideoTrack:r,smallTrack:n,isAuxiliary:o}=e;return function*(){t._log.info("publish by transceiver");let e=new MediaStream,s=null==r?void 0:r.outMediaTrack,a=null==i?void 0:i.outMediaTrack;a&&e.addTrack(a),s&&e.addTrack(s);let c=t._peerConnection.getTransceivers();if(0===c.length)t._peerConnection.addTransceiver(a||Mw.AUDIO,{direction:xw.SENDONLY,streams:[e]}),t._peerConnection.addTransceiver(o?Mw.VIDEO:s||Mw.VIDEO,{direction:xw.SENDONLY,streams:[e]}),t._peerConnection.addTransceiver(n||Mw.VIDEO,{direction:xw.SENDONLY,streams:[e]}),t._peerConnection.addTransceiver(o&&s||Mw.VIDEO,{direction:xw.SENDONLY,streams:[e]}),yield t.connect();else{let e=[];if(a&&(c[0].sender.track||e.push(0),yield c[0].sender.replaceTrack(a),yield t.setBandwidth({bandwidth:(null==i?void 0:i.profile.bitrate)||40,type:Mw.AUDIO})),s){let i=o?3:1;yield c[i].sender.replaceTrack(s),yield t.setBandwidth({bandwidth:r.profile.bitrate,type:Mw.VIDEO,videoType:o?Mw.AUXILIARY:Mw.BIG}),e.push(i),n&&(yield c[2].sender.replaceTrack(n),yield t.setBandwidth({bandwidth:r.small.bitrate,type:Mw.VIDEO,videoType:Mw.SMALL}),e.push(2))}yield t.setTransceiverDirection(xw.SENDONLY,e),yield t.doPublishChange(),null==r||r.emit("connection-state-changed",{prevState:"DISCONNECTED",state:"CONNECTING"}),null==r||r.emit("connection-state-changed",{prevState:"CONNECTING",state:"CONNECTED"})}}()}))}publishByAddTrack(e){return rC(this,arguments,(function(e){var t=this;let{localAudioTrack:i,localVideoTrack:r,smallTrack:n}=e;return function*(){t._log.info("publish by addtrack");let e=null==r?void 0:r.outMediaTrack,o=null==i?void 0:i.outMediaTrack;if(t._peerConnection&&"new"!==t._peerConnection.connectionState)return i&&o&&(yield t.addTrack(i)),void(e&&(yield t.addTrack(r)));let s=new MediaStream;if(o&&s.addTrack(o),e&&s.addTrack(e),o&&t._peerConnection.addTrack(o,s),e&&(t._peerConnection.addTrack(e,s),n)){let e=new MediaStream;e.addTrack(n),t._peerConnection.addTrack(n,e)}yield t.connect()}()}))}enableSmall(e){return rC(this,null,(function*(){let t=this._peerConnection.getTransceivers();e?this._room.videoManager.smallTrack&&(yield t[2].sender.replaceTrack(this._room.videoManager.smallTrack),yield this.setTransceiverDirection(xw.SENDONLY,[2])):(yield t[2].sender.replaceTrack(null),yield this.setTransceiverDirection(xw.INACTIVE,[2])),this.updateMediaSettings(),yield this.doPublishChange()}))}installTrackMuteEvents(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];t.forEach((e=>{e&&(null==e||e.on("mute",this.sendMutedFlag,this),null==e||e.on("unmute",this.sendMutedFlag,this))}))}uninstallTrackMuteEvents(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];t.forEach((e=>{e&&(null==e||e.off("mute",this.sendMutedFlag,this),null==e||e.off("unmute",this.sendMutedFlag,this))}))}unpublish(e){return rC(this,arguments,(function(e){var t=this;let{localAudioTrack:i,localVideoTrack:r}=e;return function*(){if(!YO())return i&&i.outMediaTrack&&!r&&t.localMainVideoTrack?(yield t.removeTrack(i),void(t.localMainAudioTrack=null)):r&&r.outMediaTrack&&!i&&t.localMainAudioTrack?(yield t.removeTrack(r),void(t.localMainVideoTrack=null)):(yield t.doUnpublish(),t.uninstallTrackMuteEvents(i,r),void t.emitConnectionStateChangedEvent("DISCONNECTED",r));let e=r&&r===t.localAuxVideoTrack,n=null==r?void 0:r.outMediaTrack,o=t._peerConnection.getSenders(),s=[];i&&(yield o[0].replaceTrack(null),s.push(0),e?t.localAuxAudioTrack=null:t.localMainAudioTrack=null),n&&(e?(yield o[3].replaceTrack(null),t.localAuxVideoTrack=null,t._mediaSettings=Xb(qb({},t._mediaSettings),{auxVideoBps:0,auxVideoFps:0,auxVideoWidth:0,auxVideoHeight:0}),s.push(3)):(yield o[1].replaceTrack(null),yield o[2].replaceTrack(null),t.localMainVideoTrack=null,t._mediaSettings=Xb(qb({},t._mediaSettings),{videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0}),s.push(1,2))),t.isMainStreamPublished||t.isAuxStreamPublished?(yield t.setTransceiverDirection(xw.INACTIVE,s),yield t.doPublishChange(!1)):yield t.doUnpublish(),t.uninstallTrackMuteEvents(i,r),null==r||r.emit("connection-state-changed",{prevState:t._currentState,state:"DISCONNECTED"})}()}))}doPublishChange(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return rC(this,null,(function*(){let t={state:this.publishState,constraintConfig:this._mediaSettings},i=yield this._signalChannel.sendWaitForResponse({command:oV,data:t,responseCommand:Zx.PUBLISH_STATE_CHANGE_RESULT,enableLog:e});this.checkPublishResultCode(i.data.code,i.data.message)}))}doUnpublish(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this._signalChannel.sendWaitForResponse({command:sV,commandDesc:"unpublish",responseCommand:Zx.UNPUBLISH_RESULT,enableLog:e}).catch((e=>{if(e.getCode()===_C.API_CALL_TIMEOUT)return Promise.resolve();throw e}))}updateMediaSettings(){let{detail:{isH264EncodeSupported:e,isVp8EncodeSupported:t}}=this._room.checkSystemResult;e?this._mediaSettings.videoCodec="H264":t&&(this._mediaSettings.videoCodec="VP8");let i=this._publishingLocalAudioTrack||this.localMainAudioTrack||this.localAuxAudioTrack,{localMainVideoTrack:r,localAuxVideoTrack:n}=this;if(this._publishingLocalVideoTrack&&(this._isPublishingAux?n=this._publishingLocalVideoTrack:r=this._publishingLocalVideoTrack),$O){if(i&&i.outMediaTrack){let e=i.outMediaTrack.getSettings();this._mediaSettings.audioChannel=e.channelCount||1,this._mediaSettings.audioBps=1e3*i.profile.bitrate,this._mediaSettings.audioFs=e.sampleRate||0}if(r&&r.outMediaTrack){let e=r.outMediaTrack.getSettings();this._mediaSettings.videoWidth=e.width||0,this._mediaSettings.videoHeight=e.height||0,this._mediaSettings.videoFps=e.frameRate||0,this._mediaSettings.videoBps=1e3*r.profile.bitrate,r.small&&(this._mediaSettings.smallVideoWidth=r.small.width,this._mediaSettings.smallVideoHeight=r.small.height,this._mediaSettings.smallVideoFps=r.small.frameRate,this._mediaSettings.smallVideoBps=1e3*r.small.bitrate)}if(n&&n.outMediaTrack){let e=n.outMediaTrack.getSettings();this._mediaSettings.auxVideoWidth=e.width||0,this._mediaSettings.auxVideoHeight=e.height||0,this._mediaSettings.auxVideoFps=e.frameRate||0,this._mediaSettings.auxVideoBps=1e3*n.profile.bitrate}}else i&&i.outMediaTrack&&(this._mediaSettings.audioChannel=i.profile.channelCount,this._mediaSettings.audioBps=1e3*i.profile.bitrate,this._mediaSettings.audioFs=i.profile.sampleRate),r&&r.outMediaTrack&&(this._mediaSettings.videoWidth=r.profile.width,this._mediaSettings.videoHeight=r.profile.height,this._mediaSettings.videoFps=r.profile.frameRate,this._mediaSettings.videoBps=1e3*r.profile.bitrate);this._log.info("updateMediaSettings: ".concat(JSON.stringify(this._mediaSettings)))}sendMediaSettings(){this.updateMediaSettings(),this._signalChannel.sendWaitForResponse({command:EV,data:this._mediaSettings,responseCommand:Zx.UPDATE_CONSTRAINT_CONFIG_RES}).then((e=>{0!==e.data.code&&this._log.warn(e.data.message)})).catch((()=>{}))}addTrack(e){return rC(this,null,(function*(){var t;if(!this._peerConnection)return;let i=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack;this._log.info("is adding ".concat(e.kind," track to current published local ").concat(i?Mw.AUXILIARY:Mw.MAIN," stream")),null==(t=this._sei)||t.handleEncodedStreams(),JO()?yield this.addTrackByTransceiver(e,i):yield this.addTrackBySender(e)}))}addTrackByTransceiver(e,t){return rC(this,null,(function*(){var i;if(!e.mediaTrack)return;let r=this._peerConnection.getTransceivers();if(e.kind===Mw.AUDIO)yield r[0].sender.replaceTrack(e.outMediaTrack);else{let n=t?3:1;yield r[n].sender.replaceTrack(e.outMediaTrack),1===n&&(null==(i=this.localMainVideoTrack)?void 0:i.small)&&(yield r[2].sender.replaceTrack(this._room.videoManager.smallTrack)),r[n].direction===xw.INACTIVE&&(yield this.setTransceiverDirection(xw.SENDONLY,[n]))}this.updateMediaSettings(),yield this.doPublishChange()}))}addTrackBySender(e){return rC(this,null,(function*(){if(!e.outMediaTrack)return;let t=e.outMediaTrack;YO()&&this._peerConnection.getTransceivers().findIndex((e=>"stopped"===e.direction))>=0&&(this._log.warn("transceiver is stopping, negotiate sdp first"),yield this.updateOffer("remove",t));let i=this._peerConnection.getSenders().find((e=>e.track&&e.track.kind===t.kind));if(i&&i.track){this._log.warn("sender already exists, remove sender first");let e=i.track;this.removeSender(i),yield this.updateOffer("remove",e)}if(t&&this._peerConnection.addTrack(t,new MediaStream([t])),t.kind===Mw.VIDEO&&e instanceof rM&&e.small){let e=new MediaStream,{smallTrack:t}=this._room.videoManager;e.addTrack(t),this._peerConnection.addTrack(t,e)}yield this.updateOffer("add",t)}))}isNeedToResetOfferOrder(){if(this._sdpSemantics===mN||!this._peerConnection||!this._peerConnection.localDescription)return!1;let{sdp:e}=this._peerConnection.localDescription,t=VV(e);for(let i=0;i<t.media.length;i++)if(0===Number(t.media[i].mid)&&t.media[i].type===Mw.VIDEO)return!0;return!1}removeSender(e){let t=null;YO()&&(t=this._peerConnection.getTransceivers().find((t=>t.sender&&t.sender.track===e.track))),this._peerConnection.removeTrack(e),t&&ND(t.stop)&&(this._log.info("stop transceiver"),t.stop())}removeTrack(e){return rC(this,null,(function*(){if(!this._peerConnection)return;let t=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack;this._log.info("is removing ".concat(e.kind," track from current published local ").concat(t?Mw.AUXILIARY:Mw.MAIN," stream")),JO()?yield this.removeTrackByTransceiver(e,t):yield this.removeTrackBySender(e)}))}removeTrackByTransceiver(e,t){return rC(this,null,(function*(){if(!e.outMediaTrack)return;let i=this._peerConnection.getTransceivers();if(e.kind===Mw.AUDIO)yield i[0].sender.replaceTrack(null);else{let r=t?3:1;yield i[r].sender.replaceTrack(null),1===r&&e.small&&(yield i[2].sender.replaceTrack(null)),yield this.setTransceiverDirection(xw.INACTIVE,[r])}this.updateMediaSettings(),yield this.doPublishChange()}))}setTransceiverDirection(e,t){return rC(this,null,(function*(){if(!BC)return;let i=!1,r=!1;this._log.info("setting transceiver ".concat(t.join(",")," direction to ").concat(e));let n=this._peerConnection.getTransceivers();if(t.forEach((t=>{n[t].direction!==e&&(n[t].direction=e,i=!0)})),i){this._log.info("updating offer");let e=yield this._peerConnection.createOffer();yield this._peerConnection.setLocalDescription(e)}let o=-1,s=this._peerConnection.remoteDescription.sdp.split("\r\n").map((i=>{if(i.match(new RegExp("a=(".concat(xw.INACTIVE,"|").concat(xw.RECVONLY,"|").concat(xw.SENDONLY,")")))&&o++,t.includes(o)){if(e===xw.INACTIVE&&i.includes("a=".concat(xw.RECVONLY)))return r=!0,"a=".concat(e);if(e===xw.SENDONLY&&i.includes("a=".concat(xw.INACTIVE)))return r=!0,"a=".concat(xw.RECVONLY)}return i})).join("\r\n");r&&(this._log.info("updating answer"),yield this._peerConnection.setRemoteDescription({type:"answer",sdp:s}))}))}removeTrackBySender(e){return rC(this,null,(function*(){if(!e.outMediaTrack)return;if(e.kind===Mw.VIDEO&&this.isNeedToResetOfferOrder()&&this.localMainAudioTrack)return this.reset(),this.initialize(),void(yield this.publish({localAudioTrack:this.localMainAudioTrack,isAuxiliary:!1}));let t=this._peerConnection.getSenders().find((t=>t.track===e.outMediaTrack));t&&(this.removeSender(t),e.kind===Mw.VIDEO&&e.small&&this._peerConnection.getSenders().forEach((e=>{e.track&&e.track.kind===Mw.VIDEO&&this.removeSender(e)}))),yield this.updateOffer("remove",e.outMediaTrack)}))}replaceTrack(e){return rC(this,null,(function*(){var t;let i,r=null==(t=this._peerConnection)?void 0:t.getSenders();if(!r||0===r.length||!e.mediaTrack)return;if(i=JO()?e.kind===Mw.AUDIO?r[0]:r[1]:r.find((t=>t.track&&t.track.kind===e.kind)),!i)return;let n=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack;this._log.info("is replacing ".concat(e.kind," track on ").concat(n?Mw.AUXILIARY:Mw.MAIN," stream")),e.kind===Mw.AUDIO?yield i.replaceTrack(e.outMediaTrack):e.kind===Mw.VIDEO&&(n?r[3]&&(yield r[3].replaceTrack(e.outMediaTrack)):yield i.replaceTrack(e.outMediaTrack))}))}updateOffer(e,t){return rC(this,null,(function*(){try{let i=yield this._peerConnection.createOffer(WV);BC&&i.sdp&&(i.sdp=this.setSDPDirection(i.sdp,"sendrecv")),yield this._peerConnection.setLocalDescription(i);let r=this.updateMediaSettings(),n={action:e,trackId:t.id,kind:t.kind===Mw.VIDEO?"bigVideo":t.kind,type:"offer",sdp:this._peerConnection.localDescription.sdp,constraintConfig:r,state:this.publishState};this._log.info("createOffer success, sending updated offer to remote server"),this._log.debug("updatedOffer: ".concat(n.sdp));let o=yield this._signalChannel.sendWaitForResponse({command:$x,data:n,responseCommand:Zx.UPDATE_OFFER_RESULT,timeout:uN,commandDesc:"update offer"}),{code:s,message:a}=o.data;0!==s&&this.checkPublishResultCode(s,a),yield this.acceptAnswer(o.data.data),i.sdp&&this.updateSSRC(i.sdp)}catch(i){throw this._log.error(i),i}}))}setBandwidth(e){return rC(this,arguments,(function(e){var t=this;let{bandwidth:i,type:r,videoType:n,sdp:o}=e;return function*(){if(!ZO())return o?r===Mw.VIDEO?t.updateVideoBandwidthRestriction(o,i,n):t.updateAudioBandwidthRestriction(o,i):void 0;let e,s=t._peerConnection.getSenders();if(JO()){let t=0;r===Mw.VIDEO&&(t=n===Mw.SMALL?2:n===Mw.AUXILIARY?3:1),e=s[t]}else e=s.find((e=>e.track&&e.track.kind===r));if(e){let s=e.getParameters();(!s.encodings||0===s.encodings.length)&&(s.encodings=[{}]),s.encodings[0].maxBitrate=1e3*i;try{return yield e.setParameters(s),t._log.info("".concat(n||"").concat(r," bandwidth ").concat(i," kbps")),o}catch(a){if(t._log.info("failed to set bandwidth by setting maxBitrate: ".concat(a)),o)return r===Mw.VIDEO?t.updateVideoBandwidthRestriction(o,i,n):t.updateAudioBandwidthRestriction(o,i)}}return o}()}))}updateVideoBandwidthRestriction(e,t,i){let r="AS";BC&&(r="TIAS",t*=1e3);let n=0,o=-1;return i===Mw.SMALL?n=1:i===Mw.AUXILIARY&&(n=2),e.replace(/m=video (.*)\r\nc=IN (.*)\r\n/g,(e=>(o+=1,o===n?"".concat(e,"b=").concat(r,":").concat(t,"\r\n"):e)))}updateAudioBandwidthRestriction(e,t){let i="AS";return BC&&(i="TIAS",t*=1e3),e.replace(/m=audio (.*)\r\nc=IN (.*)\r\n/,"m=audio $1\r\nc=IN $2\r\nb=".concat(i,":").concat(t,"\r\n"))}removeBandwidthRestriction(e){return e.replace(/b=AS:.*\r\n/,"").replace(/b=TIAS:.*\r\n/,"")}removeVideoOrientation(e){return e.replace(/urn:3gpp:video-orientation/,"")}connect(){return rC(this,null,(function*(){try{yield this.exchangeSDP(),yield this.waitForPeerConnectionConnected()}catch(e){throw this.closePeerConnection(!0),this.uninstallEvents(),e}}))}exchangeSDP(){return rC(this,null,(function*(){try{yield this.createOffer(),this._log.info("createOffer success, sending offer to remote server"),yield this.doExchangeSDP()}catch(e){throw e}}))}createOffer(){return rC(this,null,(function*(){try{let e=yield this._peerConnection.createOffer(WV);yield this._peerConnection.setLocalDescription(e),e.sdp&&this.updateSSRC(e.sdp)}catch(e){throw e}}))}doExchangeSDP(){let e={command:nV,responseCommand:Zx.PUBLISH_RESULT,data:{type:this._peerConnection.localDescription.type,sdp:this.removeVideoOrientation(this._peerConnection.localDescription.sdp),screen:this.localMainVideoTrack instanceof aM||this.localAuxVideoTrack instanceof aM,state:this.publishState,constraintConfig:this._mediaSettings},enableLog:!1};return this._log.debug("sending sdp offer: ".concat(e.data.sdp)),this._signalChannel.sendWaitForResponse(e).then((e=>{let{code:t,message:i,data:r}=e.data;return 0===t?this.acceptAnswer(r):this.checkPublishResultCode(t,i)}))}setSDPDirection(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"all",r=VV(e);return r.media.forEach((e=>{("all"===i||e.type===i)&&(e.direction=t)})),UV(r)}acceptAnswer(e){return rC(this,null,(function*(){var t,i,r,n,o;try{let s;if(this._publishingLocalAudioTrack||this._publishingLocalVideoTrack||this.isMainStreamPublished){let e=(null==(t=this._publishingLocalVideoTrack)?void 0:t.profile.bitrate)||(null==(i=this.localMainVideoTrack)?void 0:i.profile.bitrate),o=(null==(r=this._publishingLocalAudioTrack)?void 0:r.profile.bitrate)||(null==(n=this.localMainAudioTrack)?void 0:n.profile.bitrate);if(e){let t=this._isPublishingAux?Mw.AUXILIARY:Mw.BIG;s=yield this.setBandwidth({bandwidth:e,type:Mw.VIDEO,sdp:s,videoType:t})}o&&(s=yield this.setBandwidth({bandwidth:o,type:Mw.AUDIO,sdp:s}))}if(s=this.removeVideoOrientation(e.sdp),null!=(o=this._publishingLocalVideoTrack)&&o.small){let{smallStreamConfig:e}=this._room;s=yield this.setBandwidth({bandwidth:this._publishingLocalVideoTrack.small.bitrate||e.bitrate,type:Mw.VIDEO,videoType:Mw.SMALL,sdp:s})}let a={type:e.type,sdp:s};yield this._peerConnection.setRemoteDescription(a),this._log.debug("accepted answer: ".concat(s))}catch(s){throw this._log.error("failed to accept remote answer ".concat(s)),s}}))}sendMutedFlag(e){var t,i,r;if(e===this.localAuxAudioTrack||e===this.localAuxVideoTrack)return;let n={audio:!(null==(t=this.localMainAudioTrack)||!t.muted),bigVideo:!(null==(i=this.localMainVideoTrack)||!i.muted),auxVideo:!(null==(r=this.localAuxVideoTrack)||!r.muted)};this._log.info("send muted state: ".concat(JSON.stringify(n))),this._signalChannel.send(rV,n)}getIsReconnecting(){return this._isReconnecting}reconnect(){return rC(this,null,(function*(){if(!(iC(zV.prototype,this,"beforeReconnect").call(this)<0))try{yield this._signalChannel.sendWaitForResponse({command:sV,responseCommand:Zx.UNPUBLISH_RESULT,enableLog:!1}),this.closePeerConnection(),this.initialize(),this.isMainStreamPublished&&(yield this.publish({localAudioTrack:this.localMainAudioTrack,localVideoTrack:this.localMainVideoTrack,isAuxiliary:!1})),this.isAuxStreamPublished&&(yield this.publish({localAudioTrack:this.localAuxAudioTrack,localVideoTrack:this.localAuxVideoTrack,isAuxiliary:!0})),this._log.warn("reconnect() uplink reconnect successfully"),this.stopReconnection()}catch(e){let t=kD(this._reconnectionCount);this._log.warn("reconnect() timeout, try again after ".concat(t/1e3,"s")),this._reconnectionTimer=setTimeout((()=>{this.clearReconnectionTimer(),this.reconnect()}),t)}}))}handleConnectionStateChange(e){"CONNECTED"===e.state&&(this.localMainVideoTrack||this._publishingLocalVideoTrack&&!this._isPublishingAux)&&JN.emit(fO.SEND_FIRST_VIDEO_FRAME,{room:this._room})}updateSSRC(e){try{VV(e).media.forEach(((e,t)=>{if(e.type===Mw.AUDIO){let t=e.ssrcs&&e.ssrcs[0];t&&(this.ssrc.audio=Number(t.id))}else{if(this._sdpSemantics===mN&&e.ssrcGroups)return void e.ssrcGroups.forEach(((e,t)=>{let i=Number(e.ssrcs.split(" ")[0]);0===t?this.ssrc.video=i:1===t&&(this.ssrc.small=i)}));let i=e.ssrcs&&e.ssrcs[0];if(!i)return;switch(t){case 1:this.ssrc.video=Number(i.id);break;case 2:this.ssrc.small=Number(i.id);break;case 3:this.ssrc.auxiliary=Number(i.id)}}}))}catch(t){}}getVideoTrackId(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Mw.VIDEO;if(this._peerConnection){let t=this._peerConnection.getSenders();if(e===Mw.AUXILIARY&&t[3]&&t[3].track)return t[3].track.id;if(e===Mw.VIDEO&&t[1]&&t[1].track)return t[1].track.id}if(this.localMainVideoTrack&&e===Mw.VIDEO){let e=this.localMainVideoTrack.mediaTrack;if(e)return e.id}if(this.localAuxVideoTrack&&e===Mw.AUXILIARY){let e=this.localAuxVideoTrack.mediaTrack;if(e)return e.id}return""}getSSRC(){return this.ssrc}checkPublishResultCode(e,t){if(0!==e)throw e===_N?(this._log.error(jN.NOT_SUPPORTED_H264ENCODE),new fC({code:_C.NOT_SUPPORTED_H264,message:GN({key:HN.NOT_SUPPORTED_H264ENCODE})})):new fC({code:_C.UNKNOWN,message:GN({key:HN.SIGNAL_RESPONSE_FAILED,data:{signalResponse:Zx.PUBLISH_RESULT,code:e,message:t}})})}sendSEI(e,t){var i;null==(i=this._sei)||i.push(e,t)}},GV=zV;eC([JP((e=>function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];return new Promise(((t,r)=>{let n=e=>{this._emitter.off("closed",n),r(new fC({code:_C.API_CALL_ABORTED,message:GN({key:HN.CONNECTION_ABORTED,data:e})}))};this._emitter.on("closed",n),e.apply(this,i).then(t,r).finally((()=>{this._emitter.off("closed",n)}))}))}))],GV.prototype,"publish",1),eC([YP(MV.prototype.afterConnect),KP(MV.prototype.beforeConnect)],GV.prototype,"connect",1);var KV=GV,YV=class{constructor(e,t){this.room=e,tC(this,"_log"),tC(this,"_prevReportTime"),tC(this,"_prevReport",{}),tC(this,"_prevEncoderImplementation"),tC(this,"_prevQualityLimitationReason"),tC(this,"_prevAuxQualityLimitationReason"),tC(this,"_prevDecoderImplementationMap",new Map),tC(this,"totalBytesSent",0),tC(this,"totalBytesReceived",0),tC(this,"_spcStats",null),this._log=t,this._prevReportTime=0,this._prevEncoderImplementation="",this._prevQualityLimitationReason="",this._prevAuxQualityLimitationReason=""}get statInterval(){return 0===this._prevReportTime?2:(Date.now()-this._prevReportTime)/1e3}getSenderStats(e){return rC(this,null,(function*(){let t={audio:{bytesSent:0,packetsSent:0,audioLevel:0,totalAudioEnergy:0},video:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},small:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},auxiliary:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},rtt:0},i=e.getPeerConnection(),r=e.getSSRC();if(i)try{if((this._spcStats||(yield i.getStats())).forEach((i=>{var n;if("outbound-rtp"===i.type)if((i.mediaType||i.kind)===Mw.VIDEO){let n,o;if(i.ssrc===r.video?(n=Mw.VIDEO,o=e.localMainVideoTrack):i.ssrc===r.small?n=Mw.SMALL:i.ssrc===r.auxiliary&&(o=e.localAuxVideoTrack,n=Mw.AUXILIARY),!n)return;t[n].bytesSent=i.bytesSent,t[n].packetsSent=i.packetsSent,t[n].framesEncoded=i.framesEncoded,DD(i.keyFramesEncoded)||(t[n].keyFramesEncoded=i.keyFramesEncoded),DD(i.nackCount)||(t[n].nackCount=i.nackCount),DD(i.pliCount)||(t[n].pliCount=i.pliCount),DD(i.retransmittedPacketsSent)||(t[n].retransmittedPacketsSent=i.retransmittedPacketsSent),DD(i.totalEncodeTime)||(t[n].totalEncodeTime=i.totalEncodeTime),DD(i.totalPacketSendDelay)||(t[n].totalPacketSendDelay=i.totalPacketSendDelay),i.ssrc===r.video?(!DD(i.encoderImplementation)&&this._prevEncoderImplementation!==i.encoderImplementation&&(this._log.info("encoderImplementation change to ".concat(i.encoderImplementation)),this._prevEncoderImplementation=i.encoderImplementation),!DD(i.qualityLimitationReason)&&0!==i.bytesSent&&this._prevQualityLimitationReason!==i.qualityLimitationReason&&(this._log.info("qualityLimitationReason change to ".concat(i.qualityLimitationReason)),this._prevQualityLimitationReason=i.qualityLimitationReason)):i.ssrc===r.auxiliary&&!DD(i.qualityLimitationReason)&&0!==i.bytesSent&&this._prevAuxQualityLimitationReason!==i.qualityLimitationReason&&(this._log.info("aux qualityLimitationReason change to ".concat(i.qualityLimitationReason)),this._prevAuxQualityLimitationReason=i.qualityLimitationReason)}else t.audio.bytesSent=i.bytesSent,t.audio.packetsSent=i.packetsSent;else"candidate-pair"===i.type?UO(i)&&LD(i.currentRoundTripTime)&&(t.rtt=Math.floor(1e3*i.currentRoundTripTime),this.totalBytesSent=i.bytesSent):"media-source"===i.type&&(i.kind===Mw.AUDIO?(t.audio.audioLevel=i.audioLevel||0,t.audio.totalAudioEnergy=i.totalAudioEnergy||0):i.kind===Mw.VIDEO&&(i.trackIdentifier===e.getVideoTrackId(Mw.VIDEO)?t.video.fpsCapture=i.framesPerSecond:i.trackIdentifier===e.getVideoTrackId(Mw.AUXILIARY)?t.auxiliary.fpsCapture=i.framesPerSecond:t.small.fpsCapture=i.framesPerSecond));if(!DD(i.audioLevel)&&(null==(n=e.localMainAudioTrack)?void 0:n.mediaTrack)&&i.trackIdentifier===e.localMainAudioTrack.mediaTrack.id&&(t.audio.audioLevel=i.audioLevel||0),!DD(i.frameWidth)){let n=Mw.SMALL;i.trackIdentifier===e.getVideoTrackId(Mw.VIDEO)||i.ssrc===r.video?n=Mw.VIDEO:(i.trackIdentifier===e.getVideoTrackId(Mw.AUXILIARY)||i.ssrc===r.auxiliary)&&(n=Mw.AUXILIARY),t[n].frameWidth=i.frameWidth,t[n].frameHeight=i.frameHeight,t[n].framesSent=i.framesSent}})),e.localMainAudioTrack){let i=e.localMainAudioTrack.getInternalAudioLevel();t.audio.micAudioLevel=i,0===t.audio.audioLevel&&(t.audio.audioLevel=i)}this.totalBytesSent||(this.totalBytesSent+=t.audio.bytesSent+t.video.bytesSent+t.auxiliary.bytesSent)}catch(n){this._log.warn("failed to getStats on sender connection ".concat(n))}return t}))}getReceiverStats(e){return rC(this,null,(function*(){let t={tinyId:e.tinyId,userId:e.userId,rtt:0,hasAudio:!1,hasVideo:!1,hasAuxiliary:!1,isSmallSubscribed:!1,audio:{bytesReceived:0,packetsReceived:0,packetsLost:0,p2pDelay:0,totalJitter:0,totalJitterCount:0,audioLevel:0,totalAudioEnergy:0,insertedSamplesForDeceleration:0,removedSamplesForAcceleration:0},video:{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0,fpsDecoded:0},auxiliary:{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0,fpsDecoded:0}},i=e.getPeerConnection();if(i)try{let{ssrc:r}=e,{muteState:n,subscribeState:o}=e;(this._spcStats||(yield i.getStats())).forEach((i=>{if("inbound-rtp"===i.type)if((i.mediaType||i.kind)===Mw.AUDIO){if(i.ssrc!==r.audio||!n.hasAudio)return;t.audio.packetsReceived=i.packetsReceived,t.audio.bytesReceived=i.bytesReceived,t.audio.packetsLost=i.packetsLost,i.insertedSamplesForDeceleration&&(t.audio.insertedSamplesForDeceleration=i.insertedSamplesForDeceleration),i.removedSamplesForAcceleration&&(t.audio.removedSamplesForAcceleration=i.removedSamplesForAcceleration);let{remoteAudioTrack:o}=e;o.stat.packetsReceived=i.packetsReceived,o.stat.bytesReceived=i.bytesReceived,o.stat.packetsLost=i.packetsLost,t.audio.p2pDelay=o.stat.end2EndDelay,i.jitterBufferDelay&&(t.audio.totalJitter=i.jitterBufferDelay,t.audio.totalJitterCount=i.jitterBufferEmittedCount),t.hasAudio=!0}else{if(BC&&0===i.bytesReceived)return;let s;i.ssrc===r.video&&n.hasVideo&&(t.video.packetsReceived=i.packetsReceived,t.video.bytesReceived=i.bytesReceived,t.video.packetsLost=i.packetsLost,t.video.framesReceived=i.framesReceived,t.video.framesDecoded=i.framesDecoded,t.video.fpsDecoded=i.framesPerSecond,t.hasVideo=!0,s=e.remoteVideoTrack,n.hasSmall&&o.smallVideo&&(t.isSmallSubscribed=!0),i.decoderImplementation&&(!this._prevDecoderImplementationMap.has(t.userId)||this._prevDecoderImplementationMap.get(t.userId)!==i.decoderImplementation)&&(this._log.info("".concat(t.userId," decoderImplementation change to ").concat(i.decoderImplementation)),this._prevDecoderImplementationMap.set(t.userId,i.decoderImplementation))),i.ssrc===r.auxiliary&&n.hasAuxiliary&&(t.auxiliary.packetsReceived=i.packetsReceived,t.auxiliary.bytesReceived=i.bytesReceived,t.auxiliary.packetsLost=i.packetsLost,t.auxiliary.framesReceived=i.framesReceived,t.auxiliary.framesDecoded=i.framesDecoded,t.auxiliary.fpsDecoded=i.framesPerSecond,s=e.remoteAuxiliaryTrack,t.hasAuxiliary=!0),s&&(s.stat.packetsReceived=i.packetsReceived,s.stat.bytesReceived=i.bytesReceived,s.stat.packetsLost=i.packetsLost,s.stat.framesReceived=i.framesReceived,s.stat.framesDecoded=i.framesDecoded,i.jitterBufferDelay&&(s.stat.jitterBufferDelay=Math.floor(i.jitterBufferDelay/i.jitterBufferEmittedCount*1e3)))}else"candidate-pair"===i.type&&UO(i)&&LD(i.currentRoundTripTime)&&(t.rtt=Math.floor(1e3*i.currentRoundTripTime),this.totalBytesReceived=i.bytesReceived);DD(i.frameWidth)||((i.trackIdentifier===e.getMainStreamVideoTrackId()||i.ssrc===r.video)&&(t.video.frameWidth=i.frameWidth,t.video.frameHeight=i.frameHeight,e.remoteVideoTrack.stat.frameWidth=i.frameWidth,e.remoteVideoTrack.stat.frameHeight=i.frameHeight),(i.trackIdentifier===e.getAuxStreamVideoTrackId()||i.ssrc===r.auxiliary)&&(t.auxiliary.frameWidth=i.frameWidth,t.auxiliary.frameHeight=i.frameHeight,e.remoteAuxiliaryTrack.stat.frameWidth=i.frameWidth,e.remoteAuxiliaryTrack.stat.frameHeight=i.frameHeight)),!DD(i.audioLevel)&&e.muteState.audioAvailable&&e.remoteAudioTrack.mediaTrack&&i.trackIdentifier===e.remoteAudioTrack.mediaTrack.id&&(t.audio.audioLevel=i.audioLevel||0,t.audio.totalAudioEnergy=i.totalAudioEnergy||0)})),0===t.audio.audioLevel&&e.muteState.audioAvailable&&(t.audio.audioLevel=e.remoteAudioTrack.getInternalAudioLevel()||0),this.totalBytesReceived||(this.totalBytesReceived+=t.audio.bytesReceived+t.video.bytesReceived+t.auxiliary.bytesReceived)}catch(r){this._log.warn("failed to getStats on receiver connection ".concat(r))}return t}))}getStats(e,t){return rC(this,null,(function*(){let i={},r=[];if(this.room.singlePC){let e=this.room.singlePC.getPeerConnection();if(!e)return{senderStats:i,receiverStats:r};let t=yield e.getStats(),n=[],o=new Set(["inbound-rtp","outbound-rtp","track","candidate-pair","media-source"]);t.forEach((e=>o.has(e.type)&&n.push(e))),this._spcStats=n}e&&(i=yield this.getSenderStats(e));for(let[e,n]of t){let e=yield this.getReceiverStats(n);r.push(e)}return{senderStats:i,receiverStats:r}}))}getDifferenceValue(e,t){if(wP(e))return t;let i=t-e;return i<0?0:i}prepareReport(e){let{stats:t,report:i,freezeMap:r}=e;if(!wP(t.senderStats)){let e={uint32_audio_level:t.senderStats.audio.audioLevel*UN,uint32_audio_energy:1e6*t.senderStats.audio.totalAudioEnergy,uint32_audio_codec_bitrate:t.senderStats.audio.bytesSent};t.senderStats.audio.micAudioLevel&&(e.uint32_mic_audio_level=t.senderStats.audio.micAudioLevel*UN);let r=[];if(t.senderStats.video.bytesSent){let e={uint32_video_stream_type:2,uint32_video_codec_fps:t.senderStats.video.framesSent,uint32_video_capture_fps:t.senderStats.video.fpsCapture,uint32_video_width:t.senderStats.video.frameWidth,uint32_video_height:t.senderStats.video.frameHeight,uint32_video_codec_bitrate:t.senderStats.video.bytesSent,uint32_video_enc_fps:t.senderStats.video.framesEncoded,uint32_key_frame_count:t.senderStats.video.keyFramesEncoded,uint32_nack_count:t.senderStats.video.nackCount,uint32_pli_count:t.senderStats.video.pliCount,uint32_encode_cost:1e3*(t.senderStats.video.totalEncodeTime||0),uint32_send_packet_cost:1e3*(t.senderStats.video.totalPacketSendDelay||0),uint32_video_arq_packets:t.senderStats.video.retransmittedPacketsSent};r.push(e)}if(t.senderStats.small.bytesSent){let e={uint32_video_stream_type:3,uint32_video_codec_fps:t.senderStats.small.framesSent||0,uint32_video_capture_fps:t.senderStats.small.fpsCapture||0,uint32_video_width:t.senderStats.small.frameWidth||0,uint32_video_height:t.senderStats.small.frameHeight||0,uint32_video_codec_bitrate:t.senderStats.small.bytesSent,uint32_video_enc_fps:t.senderStats.small.framesEncoded||0,uint32_key_frame_count:t.senderStats.small.keyFramesEncoded,uint32_nack_count:t.senderStats.small.nackCount,uint32_pli_count:t.senderStats.small.pliCount,uint32_encode_cost:1e3*(t.senderStats.small.totalEncodeTime||0),uint32_send_packet_cost:1e3*(t.senderStats.small.totalPacketSendDelay||0),uint32_video_arq_packets:t.senderStats.small.retransmittedPacketsSent};r.push(e)}if(t.senderStats.auxiliary.bytesSent){let e={uint32_video_stream_type:7,uint32_video_codec_fps:t.senderStats.auxiliary.framesSent||0,uint32_video_capture_fps:t.senderStats.auxiliary.fpsCapture||0,uint32_video_width:t.senderStats.auxiliary.frameWidth||0,uint32_video_height:t.senderStats.auxiliary.frameHeight||0,uint32_video_codec_bitrate:t.senderStats.auxiliary.bytesSent,uint32_video_enc_fps:t.senderStats.auxiliary.framesEncoded||0,uint32_key_frame_count:t.senderStats.auxiliary.keyFramesEncoded,uint32_nack_count:t.senderStats.auxiliary.nackCount,uint32_pli_count:t.senderStats.auxiliary.pliCount,uint32_encode_cost:1e3*(t.senderStats.auxiliary.totalEncodeTime||0),uint32_send_packet_cost:1e3*(t.senderStats.auxiliary.totalPacketSendDelay||0),uint32_video_arq_packets:t.senderStats.auxiliary.retransmittedPacketsSent};r.push(e)}let n={uint32_bitrate:0,uint32_lost:0,uint32_rtt:t.senderStats.rtt};i.msg_up_stream_info={msg_audio_status:e,msg_video_status:r,msg_network_status:n}}let{statInterval:n}=this;i.msg_down_stream_info=[],t.receiverStats.forEach((e=>{let t={msg_user_info:{str_identifier:e.userId,uint64_tinyid:e.tinyId},msg_network_status:{uint32_rtt:e.rtt,uint32_bitrate:0,uint32_lost:0},msg_audio_status:{},msg_video_status:[]};if(e.hasAudio){let i={uint32_audio_p2p_delay:e.audio.p2pDelay,uint32_audio_cache_ms:e.audio.totalJitter,uint32_audio_cache_ms_count:e.audio.totalJitterCount,uint32_audio_codec_bitrate:e.audio.bytesReceived,uint32_audio_total_bitrate:e.audio.bytesReceived,uint32_audio_level:1e8*e.audio.audioLevel,uint32_audio_energy:1e6*e.audio.totalAudioEnergy,uint32_audio_receive:e.audio.packetsReceived,uint32_audio_origin_lost:e.audio.packetsLost};t.msg_audio_status=i}if(e.hasVideo){let i=r.get("".concat(e.userId,"_").concat(Yw)),n=i?i.duration:0,o={uint32_video_stream_type:e.isSmallSubscribed?3:2,uint32_video_receive_fps:e.video.framesReceived,uint32_video_width:e.video.frameWidth,uint32_video_height:e.video.frameHeight,uint32_video_codec_bitrate:e.video.bytesReceived,uint32_video_receive:e.video.packetsReceived,uint32_video_origin_lost:e.video.packetsLost,uint32_video_block_time:n,uint32_video_dec_fps:e.video.framesDecoded};t.msg_video_status.push(o)}if(e.hasAuxiliary){let i=r.get("".concat(e.userId,"_").concat(Jw)),n=i?i.duration:0,o={uint32_video_stream_type:7,uint32_video_receive_fps:e.auxiliary.framesReceived,uint32_video_width:e.auxiliary.frameWidth,uint32_video_height:e.auxiliary.frameHeight,uint32_video_codec_bitrate:e.auxiliary.bytesReceived,uint32_video_receive:e.auxiliary.packetsReceived+e.auxiliary.packetsLost,uint32_video_origin_lost:e.auxiliary.packetsLost,uint32_video_block_time:n,uint32_video_dec_fps:e.auxiliary.framesDecoded};t.msg_video_status.push(o)}i.msg_down_stream_info.push(t)}));let o=this._prevReport;if(this._prevReport=JSON.parse(JSON.stringify(i)),i.msg_up_stream_info.msg_audio_status&&o.msg_up_stream_info.msg_audio_status){let e=o.msg_up_stream_info.msg_audio_status,t=i.msg_up_stream_info.msg_audio_status;if(0===e.uint32_audio_codec_bitrate)t.uint32_audio_codec_bitrate=0;else{let r=this.getDifferenceValue(e.uint32_audio_codec_bitrate,t.uint32_audio_codec_bitrate);t.uint32_audio_codec_bitrate=Math.round(8*r/n),i.msg_up_stream_info.msg_network_status.uint32_bitrate+=t.uint32_audio_codec_bitrate}}let s=o.msg_up_stream_info.msg_video_status;i.msg_up_stream_info.msg_video_status.forEach((e=>{let t=s.find((t=>t.uint32_video_stream_type===e.uint32_video_stream_type));if(!t||0===t.uint32_video_codec_bitrate)return e.uint32_video_codec_bitrate=0,e.uint32_video_enc_fps=0,void(e.uint32_video_codec_fps=0);let r=0,o=0,a=0;t&&e.uint32_video_codec_bitrate>=t.uint32_video_codec_bitrate&&(r=t.uint32_video_codec_bitrate,o=t.uint32_video_enc_fps,a=t.uint32_video_codec_fps);let c=this.getDifferenceValue(r,e.uint32_video_codec_bitrate);e.uint32_video_codec_bitrate=Math.round(8*c/n),i.msg_up_stream_info.msg_network_status.uint32_bitrate+=e.uint32_video_codec_bitrate,e.uint32_video_enc_fps=Math.round(this.getDifferenceValue(o,e.uint32_video_enc_fps)/n),e.uint32_video_codec_fps=Math.round(this.getDifferenceValue(a,e.uint32_video_codec_fps)/n),_k&&115===Lk()&&0===t.uint32_video_width&&0===t.uint32_video_height&&0===t.uint32_video_codec_fps&&(e.uint32_video_codec_fps=e.uint32_video_enc_fps),DD(t.uint32_key_frame_count)||(e.uint32_key_frame_count=Math.round(this.getDifferenceValue(t.uint32_key_frame_count,e.uint32_key_frame_count))),DD(t.uint32_nack_count)||(e.uint32_nack_count=Math.round(this.getDifferenceValue(t.uint32_nack_count,e.uint32_nack_count))),DD(t.uint32_pli_count)||(e.uint32_pli_count=Math.round(this.getDifferenceValue(t.uint32_pli_count,e.uint32_pli_count))),DD(t.uint32_video_arq_packets)||(e.uint32_video_arq_packets=Math.round(this.getDifferenceValue(t.uint32_video_arq_packets,e.uint32_video_arq_packets))),DD(t.uint32_encode_cost)||(e.uint32_encode_cost=Math.round(this.getDifferenceValue(t.uint32_encode_cost,e.uint32_encode_cost)/n)),DD(t.uint32_send_packet_cost)||(e.uint32_send_packet_cost=Math.round(this.getDifferenceValue(t.uint32_send_packet_cost,e.uint32_send_packet_cost)/n))}));let a=o.msg_down_stream_info;return i.msg_down_stream_info=i.msg_down_stream_info.filter((e=>a.find((t=>t.msg_user_info.uint64_tinyid===e.msg_user_info.uint64_tinyid)))),i.msg_down_stream_info.forEach((e=>{let t=a.find((t=>t.msg_user_info.uint64_tinyid===e.msg_user_info.uint64_tinyid));if(wP(e.msg_audio_status)||wP(t.msg_audio_status))e.msg_audio_status={};else{let i=e.msg_audio_status,r=t.msg_audio_status,o=this.getDifferenceValue(r.uint32_audio_cache_ms_count,i.uint32_audio_cache_ms_count);delete i.uint32_audio_cache_ms_count,i.uint32_audio_cache_ms=Math.floor(1e3*this.getDifferenceValue(r.uint32_audio_cache_ms,i.uint32_audio_cache_ms)/o)||0;let s=this.room.remotePublishedUserMap.get(e.msg_user_info.str_identifier);s&&(s.remoteAudioTrack.stat.jitterBufferDelay=i.uint32_audio_cache_ms),i.uint32_audio_origin_lost=this.getDifferenceValue(r.uint32_audio_origin_lost,i.uint32_audio_origin_lost),i.uint32_audio_receive=this.getDifferenceValue(r.uint32_audio_receive,i.uint32_audio_receive),i.uint32_audio_receive+=i.uint32_audio_origin_lost;let a=this.getDifferenceValue(r.uint32_audio_codec_bitrate,i.uint32_audio_codec_bitrate);i.uint32_audio_codec_bitrate=Math.round(8*a/n),i.uint32_audio_total_bitrate=Math.round(8*a/n)}if(e.msg_video_status&&t.msg_video_status){let i=t.msg_video_status;e.msg_video_status=e.msg_video_status.filter((e=>i.find((t=>t.uint32_video_stream_type===e.uint32_video_stream_type)))),e.msg_video_status.forEach((e=>{let t=i.find((t=>t.uint32_video_stream_type===e.uint32_video_stream_type)),r=t.uint32_video_receive,o=t.uint32_video_origin_lost,s=t.uint32_video_codec_bitrate,a=t.uint32_video_receive_fps,c=t.uint32_video_dec_fps;e.uint32_video_origin_lost=this.getDifferenceValue(o,e.uint32_video_origin_lost),e.uint32_video_receive=this.getDifferenceValue(r,e.uint32_video_receive)+e.uint32_video_origin_lost;let l=this.getDifferenceValue(s,e.uint32_video_codec_bitrate);e.uint32_video_codec_bitrate=Math.round(8*l/n);let d=this.getDifferenceValue(a,e.uint32_video_receive_fps);e.uint32_video_receive_fps=Math.round(d/n),e.uint32_video_dec_fps=Math.round(this.getDifferenceValue(c,e.uint32_video_dec_fps)/n)}))}})),i}getStatsReport(e){return rC(this,arguments,(function(e){var t=this;let{uplinkConnection:i,downlinkConnections:r,freezeMap:n}=e;return function*(){let e={msg_up_stream_info:{msg_audio_status:{uint32_audio_format:11,uint32_audio_sample_rate:0,uint32_audio_codec_bitrate:0,uint32_audio_receive:0,uint32_audio_origin_lost:0,uint32_audio_level:0,uint32_audio_energy:0},msg_video_status:[],msg_network_status:{uint32_bitrate:0,uint32_rtt:0,uint32_lost:0}},msg_down_stream_info:[{msg_user_info:{str_identifier:"",uint64_tinyid:0},msg_audio_status:{uint32_audio_cache_ms:0,uint32_audio_format:11,uint32_audio_sample_rate:0,uint32_audio_codec_bitrate:0,uint32_audio_total_bitrate:0,uint32_audio_level:0,uint32_audio_energy:0,uint32_audio_receive:0,uint32_audio_origin_lost:0,uint32_audio_final_lost:0},msg_video_status:[{uint32_video_stream_type:0,uint32_video_receive_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_codec_bitrate:0,uint32_video_receive:0,uint32_video_origin_lost:0,uint32_video_block_time:0,uint32_video_dec_fps:0}],msg_network_status:{uint32_bitrate:0,uint32_rtt:0,uint32_lost:0}}]},o=yield t.getStats(i,r);return"{}"===JSON.stringify(t._prevReport)&&(t._prevReport=JSON.parse(JSON.stringify(e))),t.prepareReport({stats:o,report:e,freezeMap:n}),t._prevReportTime=Date.now(),e}()}))}reset(){this._prevReportTime=0,this._prevReport={},this._prevEncoderImplementation="",this._prevQualityLimitationReason="",this._prevDecoderImplementationMap=new Map}},JV=$b(nC()),qV=class extends JV.default{constructor(e){let{signalChannel:t,room:i}=e;super(),tC(this,"_room"),tC(this,"_signalChannel"),tC(this,"_log"),tC(this,"_uplinkRTT",0),tC(this,"_uplinkLoss",0),tC(this,"_downlinkRTT",0),tC(this,"_downlinkLoss",0),tC(this,"_downlinkPrevStatMap",new Map),tC(this,"_downlinkLossAndRTTMap",new Map),tC(this,"_interval",-1),tC(this,"_uplinkNetworkQuality",0),tC(this,"_downlinkNetworkQuality",0),this._room=i,this._signalChannel=t,this._log=EO.createLogger({id:"q",userId:this._room.userId,sdkAppId:this._room.sdkAppId}),this.initialize()}get uplinkNetworkQuality(){return this._uplinkNetworkQuality}set uplinkNetworkQuality(e){e!==this._uplinkNetworkQuality&&this._log.info("uplink ".concat(this.uplinkNetworkQuality," -> ").concat(e,", rtt: ").concat(this._uplinkRTT,", loss: ").concat(this._uplinkLoss)),this._uplinkNetworkQuality=e}get downlinkNetworkQuality(){return this._downlinkNetworkQuality}set downlinkNetworkQuality(e){if(e!==this._downlinkNetworkQuality){let{rtt:t,loss:i}=this.getAverageLossAndRTT([...this._downlinkLossAndRTTMap.values()]);this._log.info("downlink ".concat(this.downlinkNetworkQuality," -> ").concat(e,", rtt: ").concat(t,", loss: ").concat(i))}this._downlinkNetworkQuality=e}initialize(){this._signalChannel.on(Zx.UPLINK_NETWORK_STATS,(e=>{this.handleUplinkNetworkQuality(e)})),this._signalChannel.on(Yx,this.handleSignalConnectionStateChange.bind(this)),this.start()}handleUplinkNetworkQuality(e){var t,i;if(0!==e.data.code)return;let r=e.data.data;if(r.delay&&this.updateDelay(r.delay),!this._room.uplinkConnection)return this.uplinkNetworkQuality=0,this._uplinkLoss=0,void(this._uplinkRTT=0);let n=null==(i=null==(t=this._room)?void 0:t.uplinkConnection)?void 0:i.getPeerConnection();if(n&&this.isPeerConnectionDisconnected(n))return this.uplinkNetworkQuality=6,this._uplinkLoss=0,void(this._uplinkRTT=0);let o=r.expectAudPkg+r.expectVidPkg,s=r.recvAudPkg+r.recvVidPkg,a=o-s;0===o&&0===s||(this._uplinkLoss=a<=0?0:Math.round(a/o*100),this._uplinkRTT=r.rtt,this.uplinkNetworkQuality=this.getNetworkQuality(this._uplinkLoss,this._uplinkRTT))}handleDownlinkNetworkQuality(){return rC(this,null,(function*(){if(0===this._room.remotePublishedUserMap.size)return void(this.downlinkNetworkQuality=0);let e=[...this._room.remotePublishedUserMap.values()],t=e.filter((e=>{var t;return(null==(t=e.getPeerConnection())?void 0:t.connectionState)===rN.CONNECTED}));if(e.filter((e=>this.isPeerConnectionDisconnected(e.getPeerConnection()))).length===e.length)return void(this.downlinkNetworkQuality=6);for(let n=0;n<t.length;n++){let e=t[n].getPeerConnection();if(!e)return;let{rtt:i,totalPacketsLost:r,totalPacketsReceived:o}=yield this.getStat(e);if(!this._downlinkPrevStatMap.has(e)){this._downlinkPrevStatMap.set(e,{totalPacketsLost:r,totalPacketsReceived:o});continue}let s=0,a=this._downlinkPrevStatMap.get(e),c=r-a.totalPacketsLost,l=o-a.totalPacketsReceived;s=c<=0||l<0?0:Math.round(c/(c+l)*100),this._downlinkPrevStatMap.set(e,{totalPacketsLost:r,totalPacketsReceived:o}),this._downlinkLossAndRTTMap.set(e,{rtt:i,loss:s,userId:t[n].getUserId(),audioDelay:t[n].remoteAudioTrack.stat.end2EndDelay,videoDelay:t[n].remoteVideoTrack.stat.end2EndDelay})}if([...this._downlinkPrevStatMap.keys()].forEach((e=>{this.isPeerConnectionDisconnected(e)&&(this._downlinkPrevStatMap.delete(e),this._downlinkLossAndRTTMap.delete(e))})),0===this._downlinkLossAndRTTMap.size)return;let{rtt:i,loss:r}=this.getAverageLossAndRTT([...this._downlinkLossAndRTTMap.values()]);this._downlinkRTT=i,this._downlinkLoss=r,this.downlinkNetworkQuality=this.getNetworkQuality(r,i)}))}getStat(e){return rC(this,null,(function*(){let t={rtt:0,totalPacketsLost:0,totalPacketsReceived:0};if(!e||!GO())return t;let i=e.getReceivers();try{for(let e=0;e<i.length;e++)(yield i[e].getStats()).forEach((e=>{"candidate-pair"===e.type&&LD(e.currentRoundTripTime)&&(t.rtt=Math.round(1e3*e.currentRoundTripTime)),"inbound-rtp"===e.type&&(e.mediaType===Mw.AUDIO||e.mediaType===Mw.VIDEO)&&(t.totalPacketsLost+=e.packetsLost,t.totalPacketsReceived+=e.packetsReceived)}));return t}catch(r){return t}}))}getAverageLossAndRTT(e){let t={rtt:0,loss:0};return Array.isArray(e)&&e.length>0&&(e.forEach((e=>{t.rtt+=e.rtt,t.loss+=e.loss})),Object.keys(t).forEach((i=>{t[i]=Math.round(t[i]/e.length)}))),t}getNetworkQuality(e,t){return e>50||t>500?5:e>30||t>350?4:e>20||t>200?3:e>10||t>100?2:e>=0||t>=0?1:0}handleSignalConnectionStateChange(e){"DISCONNECTED"===e.state?(this._uplinkRTT=0,this._uplinkLoss=0,this.uplinkNetworkQuality=6):"CONNECTED"===e.state&&6===this.uplinkNetworkQuality&&(this.uplinkNetworkQuality=5)}handleUplinkConnectionStateChange(e){let{state:t}=e;"DISCONNECTED"===t?(this._uplinkLoss=0,this._uplinkRTT=0,this.uplinkNetworkQuality=6):"CONNECTED"===t&&6===this.uplinkNetworkQuality&&(this.uplinkNetworkQuality=5)}isPeerConnectionDisconnected(e){return!(!e||e.connectionState!==rN.DISCONNECTED&&e.connectionState!==rN.FAILED&&e.connectionState!==rN.CLOSED)}setUplinkConnection(e){this._room.uplinkConnection=e,this._room.uplinkConnection?this._room.uplinkConnection.on("connection-state-changed",this.handleUplinkConnectionStateChange.bind(this)):(this.uplinkNetworkQuality=0,this._uplinkRTT=0,this._uplinkLoss=0)}start(){-1===this._interval?(this._log.debug("start network quality calculating"),this._interval=SL.run(LN,(()=>{this.handleDownlinkNetworkQuality();let e=[...this._downlinkLossAndRTTMap.values()];JN.emit(fO.NETWORK_QUALITY,{room:this._room,uplink:{rtt:this._uplinkRTT,loss:this._uplinkLoss},downlinks:e}),this.emit(qV.EVENT_NETWORK_QUALITY,{uplinkNetworkQuality:this.uplinkNetworkQuality,downlinkNetworkQuality:this.downlinkNetworkQuality,uplinkRTT:this._uplinkRTT,uplinkLoss:this._uplinkLoss,downlinkRTT:this._downlinkRTT,downlinkLoss:this._downlinkLoss,downlinkInfo:e})}),{delay:2e3})):this._log.info("network quality calculating is already started")}stop(){this._log.debug("stopped"),-1!==this._interval&&(SL.clearTask(this._interval),this._interval=-1),this._downlinkLossAndRTTMap.clear(),this._downlinkPrevStatMap.clear()}updateDelay(e){let{tinyIdToUserIdMap:t}=this._room;e.forEach((e=>{let{srcTinyId:i,videoDelay:r,audioDelay:n}=e,o=t.get(i);if(o){let e=this._room.remotePublishedUserMap.get(o);null==e||e.setDelay({videoDelay:r,audioDelay:n})}}))}},XV=qV;tC(XV,"EVENT_NETWORK_QUALITY","0");var QV=class{constructor(e){this._signalInfo={tinyId:void 0,clientIp:"",signalIp:"",relayIp:"",relayInnerIp:"",relayPort:0},this._eventMap=new Map,this._frameWorkType=e.frameWorkType||30,this._component=e.component||0,this.connectionType=e.connectionType||1,this._language=e.language||0,this._room=e.room,this._keyPrefix="key_point",this._log=EO.createLogger({id:"kpm",userId:this._room.userId,sdkAppId:this._room.sdkAppId}),Object.getOwnPropertyNames(this.__proto__).forEach((e=>{e.startsWith("handle")&&ND(this[e])&&(this[e]=function(e){let{fn:t,context:i}=e;return function(){try{for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];let o=t.apply(i,r);return BD(o)?o.catch((e=>EO.error("".concat(t.name,"() error observed ").concat(e)))):o}catch(o){EO.error("".concat(t.name,"() error observed ").concat(o))}}}({fn:this[e],context:this}))})),this.initData(),this.installEvents(),this._intervalId=SL.run(LN,this.setStorage.bind(this),{delay:2e4})}get _storageKey(){return"".concat(this._keyPrefix,"_").concat(this._room.userId)}initData(){this._firstPublishedUserList=[],this._networkQuality={totalUplinkRTT:0,totalUplinkLoss:0,count:0,totalDownlinkRTTAndLossMap:new Map},this._basicInfo={string_sdk_version:ow,uint32_os_type:15,string_device_name:"",string_http_user_agent:navigator.userAgent,string_os_version:"",uint32_avg_rtt:0,uint32_avg_up_loss:0,uint32_scene:"live"===this._room.scene?1:0,uint32_joining_duration:0,uint32_networkType:0,uint32_framework:this._frameWorkType,uint32_component:this._component,uint32_connection_type:this.connectionType,uint32_caller_coding_language:this._language,string_domain:location.hostname},this._pathJoinRoom={uint64_start_time:0,uint64_send_request_acc_ip_cmd_start_time:0,uint64_send_request_acc_ip_cmd_end_time:0,uint64_send_request_enter_room_cmd_start_time:0,uint64_send_request_enter_room_cmd_end_time:0,uint64_send_first_video_frame_time:0,uint64_recv_userlist_time:0,uint64_end_time:0,int32_send_request_acc_ip_cmd_ret:0,int32_send_request_enter_room_cmd_ret:0,int32_end_ret:0},this._pathLeaveRoom={uint64_start_time:0,uint64_send_request_exit_room_cmd_start_time:0,uint64_send_request_exit_room_cmd_end_time:0,uint64_end_time:0,int32_send_request_exit_room_cmd_ret:0,int32_end_ret:0},this._localStreamStat={totalVideoBitrate:0,totalVideoFPS:0,totalVideoHeight:0,totalVideoWidth:0,totalAudioLevel:0,videoCount:0,audioLevelCount:0,publishStartTime:0,statsToReport:{uint32_audio_capture_db:0,uint32_video_big_capture_fps:0,uint32_video_big_bitrate:0,uint32_video_big_resolution:0}},this._pathMainVideoMap=new Map,this._pathMainAudioMap=new Map,this._pathAuxiliaryMap=new Map,this._remoteStreamStatMap=new Map,$k().then((e=>{this._basicInfo.string_os_version=iw(),this._basicInfo.string_device_name=e&&e.mobile?e.model:this._basicInfo.string_os_version}))}addEvent(e,t){return this._eventMap.set(e,t),JN.on(e,t),this}installEvents(){this.handleUnload=this.handleUnload.bind(this),window.addEventListener("unload",this.handleUnload),this._room.once("banned",(()=>this.handleLeaveSuccess({room:this._room,roomId:this._room.roomId}))),this.addEvent(fO.JOIN_START,this.handleJoinStart).addEvent(fO.JOIN_SCHEDULE_SUCCESS,this.handleJoinScheduleSuccess).addEvent(fO.JOIN_SIGNAL_CONNECTION_START,this.handleSignalConnectionStart).addEvent(fO.JOIN_SIGNAL_CONNECTION_END,this.handleSignalConnectionEnd).addEvent(fO.JOIN_SEND_CMD,this.handleJoinSendCMD).addEvent(fO.JOIN_RECEIVED_CMD_RES,this.handleJoinReceivedCMDResponce).addEvent(fO.JOIN_SUCCESS,this.handleJoinSuccess).addEvent(fO.JOIN_FAILED,this.handleJoinFailed).addEvent(fO.LEAVE_START,this.handleLeaveStart).addEvent(fO.LEAVE_SUCCESS,this.handleLeaveSuccess).addEvent(fO.LEAVE_SEND_CMD,this.handleLeaveSendCMD).addEvent(fO.LOCAL_TRACK_CAPTURE_START,this.handleTrackCaptureStart).addEvent(fO.LOCAL_TRACK_CAPTURE_SUCCESS,this.handleTrackCaptureSuccess).addEvent(fO.LOCAL_TRACK_CAPTURE_FAILED,this.handleTrackCaptureFailed).addEvent(fO.PUBLISH_START,this.handlePublishStart).addEvent(fO.SEND_FIRST_VIDEO_FRAME,this.handleSendFirstVideoFrame).addEvent(fO.SUBSCRIBE_START,this.handleSubscribeStart).addEvent(fO.SUBSCRIBE_SUCCESS,this.handleSubscribed).addEvent(fO.PLAY_TRACK_START,this.handlePlayStart).addEvent(fO.VIDEO_LOADED_DATA,this.handleVideoLoadedData).addEvent(fO.PLAYER_STATE_CHANGED,(e=>{let{track:t,state:i,type:r}=e;!UD(t)||!this.hitTest(t.room)||"PLAYING"===i&&(r===Mw.AUDIO?this.handleAudioPlaying(t):this.handleVideoPlaying(t))})).addEvent(fO.NETWORK_QUALITY,this.handleNetworkQuality).addEvent(fO.HEARTBEAT_REPORT,this.handleHeartbeatStats).addEvent(fO.RECEIVED_PUBLISHED_USER_LIST,this.handleReceivedPublishUserList).addEvent(fO.REMOTE_PUBLISH_STATE_CHANGED,(e=>{let{room:t,prevMuteState:i,muteState:r}=e;if(!this.hitTest(t))return;let n=i.hasAudio||i.hasVideo||i.hasSmall,o=i.hasAuxiliary,s=r.hasAudio||r.hasVideo||r.hasSmall,a=r.hasAuxiliary;!n&&s&&this.handleRemoteStreamAdded(r.userId,"main"),!o&&a&&this.handleRemoteStreamAdded(r.userId,"auxiliary")})).addEvent(fO.SINGLE_CONNECTION_STAT,(e=>{let{room:t,stat:i}=e;this.hitTest(t)&&(this._pathJoinRoom.int32_ice_cost=i.ice,this._pathJoinRoom.int32_dtls_cost=i.dtls,this._pathJoinRoom.int32_peer_connection_cost=i.peerConnection)}))}uninstallEvents(){window.removeEventListener("unload",this.handleUnload),this._eventMap.forEach(((e,t)=>JN.off(t,e))),this._eventMap.clear()}destroy(){this.uninstallEvents(),SL.clearTask(this._intervalId)}handleUnload(){this._room.isJoined&&this.handleLeaveSuccess({room:this._room,roomId:this._room.roomId})}handleJoinStart(e){this.hitTest(e.room)&&(0===this._pathJoinRoom.uint64_start_time&&(this._pathJoinRoom.uint64_start_time=Date.now(),this.checkStorage()),e.params&&(DD(e.params.frameWorkType)||(this._frameWorkType=e.params.frameWorkType,this._basicInfo.uint32_framework=this._frameWorkType),DD(e.params.component)||(this._component=e.params.component,this._basicInfo.uint32_component=this._component),DD(e.params.language)||(this._language=e.params.language,this._basicInfo.uint32_caller_coding_language=this._language)))}handleJoinScheduleSuccess(e){let{room:t,detailCost:i}=e;if(this.hitTest(t)&&i){let{totalCost:e,local:t,dns:r,tcp:n,tls:o,request:s,response:a}=i;this._pathJoinRoom.int32_schedule_cost=e,this._pathJoinRoom.int32_schedule_local=t,this._pathJoinRoom.int32_schedule_dns=r,this._pathJoinRoom.int32_schedule_tcp=n,this._pathJoinRoom.int32_schedule_tls=o,this._pathJoinRoom.int32_schedule_request=s,this._pathJoinRoom.int32_schedule_response=a}}handleSignalConnectionStart(e){let{room:t}=e;this.hitTest(t)&&0===this._pathJoinRoom.uint64_send_request_acc_ip_cmd_start_time&&(this._pathJoinRoom.uint64_send_request_acc_ip_cmd_start_time=Date.now())}handleSignalConnectionEnd(e){let{room:t,error:i}=e;this.hitTest(t)&&0===this._pathJoinRoom.uint64_send_request_acc_ip_cmd_end_time&&(this._pathJoinRoom.uint64_send_request_acc_ip_cmd_end_time=Date.now(),i&&(this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret=i instanceof fC?Number(i.getExtraCode()||i.getCode()):_C.UNKNOWN,this._pathJoinRoom.int32_end_ret=this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret))}handleJoinSendCMD(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_send_request_enter_room_cmd_start_time&&(this._pathJoinRoom.uint64_send_request_enter_room_cmd_start_time=Date.now())}handleJoinReceivedCMDResponce(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_send_request_enter_room_cmd_end_time&&(this._pathJoinRoom.uint64_send_request_enter_room_cmd_end_time=Date.now(),this._pathJoinRoom.int32_send_request_enter_room_cmd_ret=e.code,0!==e.code&&(this._pathJoinRoom.int32_end_ret=this._pathJoinRoom.int32_send_request_enter_room_cmd_ret))}handleJoinSuccess(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_end_time&&(this._pathJoinRoom.uint64_end_time=Date.now(),this._pathJoinRoom.int32_end_ret=0,this._signalInfo=e.room.getSignalInfo())}handleJoinFailed(e){let{room:t,error:i}=e;this.hitTest(t)&&(this._pathJoinRoom.uint64_end_time=Date.now(),0===this._pathJoinRoom.int32_end_ret&&(this._pathJoinRoom.int32_end_ret=i.code||this._pathJoinRoom.int32_send_request_enter_room_cmd_ret||this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret),setTimeout((()=>{this.report()})))}handleReceivedPublishUserList(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_recv_userlist_time&&(this._pathJoinRoom.uint64_recv_userlist_time=Date.now(),this._firstPublishedUserList=e.publishedUserList||[])}handleSendFirstVideoFrame(e){let{room:t}=e;!this.hitTest(t)||0===this._pathJoinRoom.uint64_send_first_video_frame_time&&0!==this._pathJoinRoom.uint64_start_time&&(this._pathJoinRoom.uint64_send_first_video_frame_time=Date.now())}handleLeaveStart(e){this.hitTest(e.room)&&(this._pathLeaveRoom.uint64_start_time=Date.now())}handleLeaveSuccess(e){this.hitTest(e.room)&&0===this._pathLeaveRoom.uint64_end_time&&(this._pathLeaveRoom.uint64_end_time=Date.now(),0!==this._pathJoinRoom.uint64_end_time?this._basicInfo.uint32_joining_duration=this._pathLeaveRoom.uint64_end_time-this._pathJoinRoom.uint64_end_time:this._log.warn("pathJoinRoom endTime is 0"),this.report())}handleLeaveSendCMD(e){this.hitTest(e.room)&&(this._pathLeaveRoom.uint64_send_request_exit_room_cmd_start_time=Date.now(),this._pathLeaveRoom.uint64_send_request_exit_room_cmd_end_time=Date.now())}handleRemoteStreamAdded(e,t){var i;let r="".concat(e,"_").concat(t);if(!this._remoteStreamStatMap.has(r)){let n={userId:e,totalVideoFPS:0,totalVideoBitrate:0,totalAudioLevel:0,totalAudioBitrate:0,totalLoss:0,audioCount:0,audioLevelCount:0,videoCount:0,networkQualityCount:0,streamAddedTime:Date.now(),subscribeStartTime:0,subscribedTime:0,playStreamTime:0,statsToReport:Xb(qb({},$V),{msg_user_info:new eU({userId:e,tinyId:null==(i=this._room.remotePublishedUserMap.get(e))?void 0:i.tinyId,role:20})})};n.statsToReport.uint32_stream_type="main"===t?2:7,this._remoteStreamStatMap.set(r,n)}}handleSubscribeStart(e){let{room:t,remotePublishedUser:i,streamType:r,subscribeState:n}=e;if(!this.hitTest(t))return;let{userId:o,tinyId:s,role:a}=i,c=new eU({userId:o,tinyId:s,role:"anchor"===a?20:21}),l=Date.now(),d="".concat(o,"_").concat(r),u=this._remoteStreamStatMap.get(d);u&&0===u.subscribeStartTime&&(u.subscribeStartTime=l),"main"===r?(i.muteState.hasVideo&&(n.video||n.smallVideo)&&!this._pathMainVideoMap.has(d)&&this._pathMainVideoMap.set(d,{statsToReport:{msg_user_info:c,uint64_start_enter_time:this._pathJoinRoom.uint64_start_time,uint64_render_first_frame_time:0,uint64_combine_first_frame_time:0},userId:o,sendSubscribeCMDTime:l}),i.muteState.hasAudio&&n.audio&&!this._pathMainAudioMap.has(d)&&this._pathMainAudioMap.set(d,{statsToReport:{msg_user_info:c,uint64_start_enter_time:this._pathJoinRoom.uint64_start_time,uint64_play_first_frame_time:0},userId:o,sendSubscribeCMDTime:l})):i.muteState.hasAuxiliary&&n.auxiliary&&!this._pathAuxiliaryMap.has(d)&&this._pathAuxiliaryMap.set(d,{sendSubscribeCMDTime:l})}handleSubscribed(e){let{room:t,remotePublishedUser:i,streamType:r}=e;if(this.hitTest(t)){let e="".concat(i.userId,"_").concat(r),t=this._remoteStreamStatMap.get(e);t&&0===t.subscribedTime&&(t.subscribedTime=Date.now())}}handlePlayStart(e){let{track:t}=e;if(!UD(t)||!this.hitTest(t.room))return;let i="".concat(t.userId,"_").concat(t.streamType),r=this._remoteStreamStatMap.get(i);0===(null==r?void 0:r.playStreamTime)&&(r.playStreamTime=Date.now())}handleVideoLoadedData(e){let{track:t}=e;if(!UD(t)||!this.hitTest(t.room))return;let i="".concat(t.userId,"_").concat(t.streamType),r=this._pathMainVideoMap.get(i);r&&0===r.statsToReport.uint64_combine_first_frame_time&&(r.statsToReport.uint64_combine_first_frame_time=Date.now())}handleVideoPlaying(e){let t="".concat(e.userId,"_").concat(e.streamType),i=Date.now(),r=this._pathMainVideoMap.get(t),n=this._remoteStreamStatMap.get(t);if(r&&(0===r.statsToReport.uint64_render_first_frame_time&&(r.statsToReport.uint64_render_first_frame_time=i),n)){let{statsToReport:e,playStreamTime:t,subscribedTime:o}=n;0===e.uint32_video_render_first&&t-o<=100&&(e.uint32_video_render_first=i-r.sendSubscribeCMDTime)}let o=this._pathAuxiliaryMap.get(t);if(o&&n){let{statsToReport:e,playStreamTime:t,subscribedTime:r}=n;0===e.uint32_video_render_first&&t-r<=100&&(e.uint32_video_render_first=i-o.sendSubscribeCMDTime)}}handleAudioPlaying(e){let t="".concat(e.userId,"_").concat(e.streamType),i=this._pathMainAudioMap.get(t);i&&0===i.statsToReport.uint64_play_first_frame_time&&(i.statsToReport.uint64_play_first_frame_time=Date.now())}handleNetworkQuality(e){this.hitTest(e.room)&&(this._networkQuality.totalUplinkLoss+=e.uplink.loss,this._networkQuality.totalUplinkRTT+=e.uplink.rtt,this._networkQuality.count++,e.downlinks.forEach((e=>{let{rtt:t,loss:i,userId:r,videoDelay:n,audioDelay:o}=e,s=this._networkQuality.totalDownlinkRTTAndLossMap.get(r);if(s)s.totalRTT+=t,s.totalLoss+=i,n&&(s.totalVideoDelay=(s.totalVideoDelay||0)+n,s.videoDelayCount=(s.videoDelayCount||0)+1),o&&(s.totalAudioDelay=(s.totalAudioDelay||0)+o,s.audioDelayCount=(s.audioDelayCount||0)+1),s.count++;else{let e,s,a,c;n&&(s=n,a=1),o&&(e=o,c=1),this._networkQuality.totalDownlinkRTTAndLossMap.set(r,{totalRTT:t,totalLoss:i,count:1,totalAudioDelay:e,totalVideoDelay:s,audioDelayCount:c,videoDelayCount:a})}})))}handleHeartbeatStats(e){if(this.hitTest(e.room)){let{msg_up_stream_info:t,msg_down_stream_info:i}=e.report;if(t.msg_video_status[0]){let{uint32_video_codec_bitrate:e,uint32_video_enc_fps:i,uint32_video_width:r,uint32_video_height:n}=t.msg_video_status[0];this._localStreamStat.totalVideoBitrate+=e,this._localStreamStat.totalVideoFPS+=i,this._localStreamStat.totalVideoWidth+=r,this._localStreamStat.totalVideoHeight+=n,this._localStreamStat.videoCount++}if(t.msg_audio_status){let{uint32_audio_level:e}=t.msg_audio_status;Math.floor(e/UN*100)>0&&(this._localStreamStat.totalAudioLevel+=e/UN,this._localStreamStat.audioLevelCount++)}i.forEach((e=>{let{msg_user_info:t,msg_audio_status:i,msg_video_status:r}=e,n=t.str_identifier,o=this._room.remotePublishedUserMap.get(n);if(r.forEach((e=>{let t=2===e.uint32_video_stream_type,i=7===e.uint32_video_stream_type,r="".concat(n,"_").concat(t?"main":"auxiliary"),s=this._remoteStreamStatMap.get(r);if(s&&(t&&(null==o?void 0:o.remoteVideoTrack.isSubscribed)||i&&(null==o?void 0:o.remoteAuxiliaryTrack))){s.totalVideoFPS+=e.uint32_video_receive_fps,s.totalVideoBitrate+=e.uint32_video_codec_bitrate,s.videoCount++,0===s.statsToReport.uint32_video_width&&(s.statsToReport.uint32_video_width=e.uint32_video_width),0===s.statsToReport.uint32_video_height&&(s.statsToReport.uint32_video_height=e.uint32_video_height);let i=t?o.remoteVideoTrack:o.remoteAuxiliaryTrack;i.stat.jitterBufferDelay&&(s.videoJitterBufferDelay=i.stat.jitterBufferDelay),i.stat.framesReceived&&(s.statsToReport.uint32_video_consume_render_rate=Math.floor(i.stat.framesDecoded/i.stat.framesReceived*Yb(10,6)))}})),i){let e="".concat(n,"_","main"),t=this._remoteStreamStatMap.get(e);this._remoteStreamStatMap.has(e)&&t&&(null==o?void 0:o.remoteAudioTrack.isSubscribed)&&(t.totalAudioBitrate+=i.uint32_audio_codec_bitrate,t.audioCount++,o.remoteAudioTrack.stat.jitterBufferDelay&&(t.audioJitterBufferDelay=o.remoteAudioTrack.stat.jitterBufferDelay),Math.floor(i.uint32_audio_level/UN*100)>0&&(t.totalAudioLevel+=i.uint32_audio_level/UN,t.audioLevelCount++))}}))}}handlePublishStart(e){let{room:t}=e;this.hitTest(t)&&0===this._localStreamStat.publishStartTime&&(this._localStreamStat.publishStartTime=Date.now())}handleTrackCaptureStart(e){let{track:t}=e;1===t.mediaType&&!this._pathJoinRoom.uint64_init_audio_start_time&&(this._pathJoinRoom.uint64_init_audio_start_time=Date.now()),4===t.mediaType&&!this._pathJoinRoom.uint64_init_camera_start_time&&(this._pathJoinRoom.uint64_init_camera_start_time=Date.now())}handleTrackCaptureSuccess(e){let{track:t}=e;1===t.mediaType&&!this._pathJoinRoom.uint64_init_audio_end_time&&(this._pathJoinRoom.int32_init_audio_ret=0,this._pathJoinRoom.uint64_init_audio_end_time=Date.now()),4===t.mediaType&&!this._pathJoinRoom.uint64_init_camera_end_time&&(this._pathJoinRoom.int32_init_camera_ret=0,this._pathJoinRoom.uint64_init_camera_end_time=Date.now())}handleTrackCaptureFailed(e){let{track:t,error:i}=e,r={NotFoundError:1,NotAllowedError:2,NotReadableError:3,OverConstrainedError:4,AbortError:5,InvalidStateError:6,SecurityError:7,TypeError:8}[i.name]||(i instanceof fC?i.getExtraCode()||i.getCode():_C.UNKNOWN);1===t.mediaType&&!this._pathJoinRoom.uint64_init_audio_end_time&&(this._pathJoinRoom.int32_init_audio_ret=r,this._pathJoinRoom.uint64_init_audio_end_time=Date.now()),4===t.mediaType&&!this._pathJoinRoom.uint64_init_camera_end_time&&(this._pathJoinRoom.int32_init_camera_ret=r,this._pathJoinRoom.uint64_init_camera_end_time=Date.now())}hasVideoFlag(e){return this._firstPublishedUserList.findIndex((t=>t.userId===e&&t.flag&Bw))>=0}hasAudioFlag(e){return this._firstPublishedUserList.findIndex((t=>t.userId===e&&t.flag&jw))>=0}hasAuxFlag(e){return this._firstPublishedUserList.findIndex((t=>t.userId===e&&t.flag&Hw))>=0}hitTest(e){return e===this._room}checkStorage(){return rC(this,null,(function*(){try{let e=yO.getItem(this._storageKey);e&&(yield this.upload(e),yO.deleteItem(this._storageKey))}catch(e){this._log.warn(e)}}))}setStorage(){this.prepareReport();let e=this.getReportData();0!==e.msg_path_enter_room.uint64_start_time&&yO.setItem(this._storageKey,e)}prepareReport(){if(this._networkQuality.count>0&&(this._basicInfo.uint32_avg_rtt=Math.floor(this._networkQuality.totalUplinkRTT/this._networkQuality.count),this._basicInfo.uint32_avg_up_loss=Math.floor(this._networkQuality.totalUplinkLoss/this._networkQuality.count)),this._localStreamStat.videoCount>0){this._localStreamStat.statsToReport.uint32_video_big_capture_fps=Math.floor(this._localStreamStat.totalVideoFPS/this._localStreamStat.videoCount),this._localStreamStat.statsToReport.uint32_video_big_bitrate=Math.floor(this._localStreamStat.totalVideoBitrate/this._localStreamStat.videoCount);let e=Math.floor(this._localStreamStat.totalVideoWidth/this._localStreamStat.videoCount),t=Math.floor(this._localStreamStat.totalVideoHeight/this._localStreamStat.videoCount);this._localStreamStat.statsToReport.uint32_video_big_resolution=e<<16|t}this._localStreamStat.audioLevelCount>0&&(this._localStreamStat.statsToReport.uint32_audio_capture_db=Math.floor(this._localStreamStat.totalAudioLevel/this._localStreamStat.audioLevelCount*100)),this._remoteStreamStatMap.forEach(((e,t)=>{let{userId:i}=e,r=this._networkQuality.totalDownlinkRTTAndLossMap.get(i);if(r){let{totalLoss:t,count:i,audioDelayCount:n,videoDelayCount:o,totalAudioDelay:s,totalVideoDelay:a}=r;e.statsToReport.uint32_avg_down_loss=Math.floor(t/i),n&&s&&(e.statsToReport.uint32_audio_network_p2p_delay=Math.floor(s/n),e.audioJitterBufferDelay&&(e.statsToReport.uint32_p2p_delay=Math.floor(e.statsToReport.uint32_audio_network_p2p_delay+e.audioJitterBufferDelay))),o&&a&&(e.statsToReport.uint32_video_network_p2p_delay=Math.floor(a/o))}e.videoCount>0&&(e.statsToReport.uint32_video_avg_fps=Math.floor(e.totalVideoFPS/e.videoCount),e.statsToReport.uint32_video_avg_bitrate=Math.floor(e.totalVideoBitrate/e.videoCount)),e.audioCount>0&&(e.statsToReport.uint32_audio_recv_bitrate=e.statsToReport.uint32_audio_bitrate=Math.floor(e.totalAudioBitrate/e.audioCount)),e.audioLevelCount>0&&(e.statsToReport.uint32_audio_play_db=Math.floor(e.totalAudioLevel/e.audioLevelCount*100));let{callDurationCalculator:n}=this._room;n&&(e.statsToReport.uint32_audio_play_time=n.getDuration(t,Mw.AUDIO),e.statsToReport.uint32_video_play_time=n.getDuration(t,Mw.VIDEO)),e.statsToReport.uint32_video_render_first=Math.min(e.statsToReport.uint32_video_render_first,ZV);let{badCaseDetector:o}=this._room,{dataFreeze:s,count:a}=o.getDataFreezeDuration(t),{renderFreeze:c}=o.getRenderFreezeDuration(t);e.statsToReport.uint32_video_block_count=a,e.statsToReport.uint32_video_block_time=Math.min(s,e.statsToReport.uint32_video_play_time),e.statsToReport.uint32_video_external_block_time=Math.min(c,e.statsToReport.uint32_video_play_time),o.isBlackStream(t)&&0===e.statsToReport.uint32_video_avg_fps?e.statsToReport.uint32_video_black_screen_subjective=1:e.statsToReport.uint32_video_black_screen_subjective=0,(0===e.subscribeStartTime||e.subscribeStartTime-e.streamAddedTime>100||0===e.playStreamTime)&&(this._pathMainAudioMap.delete(t),this._pathMainVideoMap.delete(t),e.statsToReport.uint32_video_render_first=0)})),this._pathMainAudioMap.forEach(((e,t)=>{this.hasAudioFlag(e.userId)?e.statsToReport.uint64_play_first_frame_time-e.statsToReport.uint64_start_enter_time>ZV&&(e.statsToReport.uint64_play_first_frame_time=e.statsToReport.uint64_start_enter_time+ZV):this._pathMainAudioMap.delete(t)})),this._pathMainVideoMap.forEach(((e,t)=>{this.hasVideoFlag(e.userId)?e.statsToReport.uint64_render_first_frame_time-e.statsToReport.uint64_start_enter_time>ZV&&(e.statsToReport.uint64_render_first_frame_time=e.statsToReport.uint64_start_enter_time+ZV):this._pathMainVideoMap.delete(t)})),this._pathJoinRoom.uint64_end_time-this._pathJoinRoom.uint64_start_time>ZV&&(this._pathJoinRoom.uint64_end_time=this._pathJoinRoom.uint64_start_time+ZV)}getReportData(){this._basicInfo.uint32_networkType=gD();let e={uint32_sdk_app_id:Number(this._room.sdkAppId),msg_user_info:new eU({userId:this._room.userId,tinyId:this._room.tinyId,role:"anchor"===this._room.role?20:21}),msg_basic_info:this._basicInfo,uint32_acc_ip:ZD(this._signalInfo.relayIp),uint32_client_ip:ZD(this._signalInfo.clientIp,!1),uint32_acc_port:this._signalInfo.relayPort||0,uint64_timestamp:Date.now(),uint32_seq:Math.floor(Math.random()*Yb(2,31)),msg_path_enter_room:this._pathJoinRoom,msg_path_exit_room:this._pathLeaveRoom,msg_path_recv_video:[...this._pathMainVideoMap.values()].map((e=>e.statsToReport)),msg_quality_statistics:[...this._remoteStreamStatMap.values()].map((e=>e.statsToReport)),str_room_name:String(this._room.roomId||0),msg_path_recv_audio:[...this._pathMainAudioMap.values()].map((e=>e.statsToReport)),uint32_info_client_ip:ZD(this._signalInfo.clientIp,!1),error_code:[],msg_local_statistics:this._localStreamStat.statsToReport};return hO(e),e}report(){return rC(this,null,(function*(){try{this.prepareReport();let e=this.getReportData();yield this.upload(e),yO.deleteItem(this._storageKey),this.initData()}catch(e){this._log.warn(e)}}))}upload(e){return rC(this,null,(function*(){if(Jk&&!Tk||0===e.msg_path_enter_room.uint64_start_time||[_w,fw,gw].findIndex((e=>e===location.host))>=0)return;let t=Number(this._room.sdkAppId),i=yield FN(e),r=i instanceof ArrayBuffer,n="".concat(dD(t,Aw.KEY_POINT),"&gzip=").concat(+r),o=!1;navigator.sendBeacon&&(o=navigator.sendBeacon(n,i)),o||BN({url:n,body:i}),this.uploadKVStat(pP),this.uploadKVStat(hP)}))}setConnectionType(e){this.connectionType=e,this._basicInfo.uint32_connection_type=e}uploadKVStat(e){return rC(this,null,(function*(){let t=e.getReportData();if(0===t.stats_count.length&&0===t.stats_distribution.length)return;t.msg_sdk_basic_info=Xb(qb({},t.msg_sdk_basic_info),{bytes_device_name:this._basicInfo.string_device_name||"",bytes_os_version:this._basicInfo.string_os_version||"",uint32_framework:this._frameWorkType,uint32_network_type:this._basicInfo.uint32_networkType||0}),this._log.debug(t);let i=yield FN(t),r="".concat(dD(+this._room.sdkAppId,Aw.KV_STAT),"&gzip=").concat(+(i instanceof ArrayBuffer)),n=!1;navigator.sendBeacon&&(n=navigator.sendBeacon(r,i)),n||BN({url:r,body:i})}))}};eC([bV({settings:{timeout:500,retries:3}})],QV.prototype,"upload",1);var ZV=5e3,$V={msg_user_info:null,uint32_video_avg_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_avg_bitrate:0,uint32_video_block_time:0,uint32_video_play_time:0,uint32_audio_block_time:0,uint32_audio_play_time:0,uint32_audio_play_db:0,uint32_avg_down_loss:0,uint32_stream_type:0,uint32_video_render_first:0,uint32_video_block_count:0,uint32_audio_block_count:0,uint32_audio_bitrate:0,uint32_video_black_screen_subjective:0,uint32_audio_recv_bitrate:0,uint32_video_external_block_time:0,uint32_video_consume_render_rate:0},eU=class{constructor(e){this.str_identifier=String(e.userId),this.str_tinyid=String(e.tinyId||0),this.uint32_role=e.role}},tU=QV,iU=class{constructor(){tC(this,"_startTime"),tC(this,"_endTime"),this._startTime=0,this._endTime=0,this.start()}start(){0===this._startTime&&(this._startTime=zD())}stop(){0===this._endTime&&(this._endTime=zD())}getDuration(){return 0===this._endTime?zD()-this._startTime:this._endTime-this._startTime}get endTime(){return this._endTime}},rU=class{constructor(e){tC(this,"_room",null),tC(this,"_durationMap"),tC(this,"_eventMap",new Map),this._room=e.room,this._durationMap=new Map,this.installEvents()}installEvents(){this._eventMap.set(fO.SUBSCRIBE_SUCCESS,this.handleSubscribed).set(fO.UNSUBSCRIBE_SUCCESS,this.handleStreamStopped).set(fO.REMOTE_PUBLISH_STATE_CHANGED,(e=>{let{room:t,prevMuteState:i,muteState:r}=e;var n;let{userId:o}=r;if(!this.hitTest(t))return;i.hasAudio&&!r.hasAudio&&this.stopDurationItem("".concat(o,"_","main"),Mw.AUDIO),i.hasVideo&&!r.hasVideo&&this.stopDurationItem("".concat(o,"_","main"),Mw.VIDEO),i.hasAuxiliary&&!r.hasAuxiliary&&this.stopDurationItem("".concat(o,"_","auxiliary"),Mw.VIDEO);let s=null==(n=this._room)?void 0:n.remotePublishedUserMap.get(o);!s||(!i.hasAudio&&r.hasAudio&&s.remoteAudioTrack.isSubscribed&&this.addDuractionItem(o,Mw.AUDIO,"main"),!i.hasVideo&&r.hasVideo&&s.remoteVideoTrack.isSubscribed&&this.addDuractionItem(o,Mw.VIDEO,"main"),!i.hasAuxiliary&&r.hasAuxiliary&&s.remoteAuxiliaryTrack.isSubscribed&&this.addDuractionItem(o,Mw.VIDEO,"auxiliary"))})),this._eventMap.forEach(((e,t)=>JN.on(t,e,this)))}uninstallEvents(){this._eventMap.forEach(((e,t)=>JN.off(t,e,this))),this._eventMap.clear()}handleSubscribed(e){let{room:t,streamType:i,remotePublishedUser:r}=e;if(!this.hitTest(t))return;let{userId:n}=r,o="".concat(n,"_").concat(i);if(r.muteState.hasAudio&&"main"===i)if(r.remoteAudioTrack.isSubscribed){let e=new iU,t=this._durationMap.get(o);t?this.isRecording(t.audio)||t.audio.push(e):this._durationMap.set(o,{userId:n,type:i,audio:[e],video:[]})}else this.stopDurationItem(o,Mw.AUDIO);if(r.muteState.hasVideo||r.muteState.hasAuxiliary)if(r.remoteVideoTrack.isSubscribed||r.remoteAuxiliaryTrack.isSubscribed){let e=new iU,t=this._durationMap.get(o);t?this.isRecording(t.video)||t.video.push(e):this._durationMap.set(o,{userId:n,type:i,audio:[],video:[e]})}else this.stopDurationItem(o,Mw.VIDEO)}handleStreamStopped(e){let{room:t,streamType:i,remotePublishedUser:r}=e;if(!this.hitTest(t))return;let{userId:n}=r,o="".concat(n,"_").concat(i);this.stopDurationItem(o,Mw.AUDIO),this.stopDurationItem(o,Mw.VIDEO)}isRecording(e){return e.findIndex((e=>0===e.endTime))>=0}addDuractionItem(e,t,i){let r="".concat(e,"_").concat(i),n=new iU,o=this._durationMap.get(r);o?this.isRecording(o[t])||o[t].push(n):this._durationMap.set(r,{userId:e,type:i,audio:t===Mw.AUDIO?[n]:[],video:t===Mw.AUDIO?[]:[n]})}stopDurationItem(e,t){if(this._durationMap.has(e)){let i=this._durationMap.get(e)[t].find((e=>0===e.endTime));i&&i.stop()}}hitTest(e){return this._room===e}getDuration(e,t){return this._durationMap.has(e)?this._durationMap.get(e)[t].reduce(((e,t)=>e+t.getDuration()),0):0}getDurationMap(){return this._durationMap}reset(){this._durationMap.clear()}destroy(){this._room=null,this.uninstallEvents()}},nU=class{constructor(e){tC(this,"_room"),tC(this,"_renderFreezeMap",new Map),tC(this,"_isVideoPlayingEventFiredMap",new Map),tC(this,"_dataFreezeMap",new Map),tC(this,"_monitorFreezeData",new Map),tC(this,"_eventMap",new Map),this._room=e.room,this.installEvents()}installEvents(){this._eventMap.set(fO.LEAVE_SUCCESS,(e=>{let{room:t}=e;this.hitTest(t)&&this.stop()})).set(fO.PLAY_TRACK_START,this.onPlayTrackStart).set(fO.UNSUBSCRIBE_SUCCESS,(e=>{let{room:t,streamType:i,remotePublishedUser:r}=e;if(!this.hitTest(t))return;let{userId:n}=r,o="".concat(n,"_").concat(i);this.stopDataFreeze({key:o,userId:n,type:i})})).set(fO.REMOTE_PUBLISH_STATE_CHANGED,(e=>{let{room:t,prevMuteState:i,muteState:r}=e;if(!this.hitTest(t))return;let{userId:n}=r;if(i.hasVideo&&!r.hasVideo){let e="main",t="".concat(r.userId,"_").concat(e);this.stopDataFreeze({key:t,userId:n,type:e})}if(i.hasAuxiliary&&!r.hasAuxiliary){let e="auxiliary",t="".concat(r.userId,"_").concat(e);this.stopDataFreeze({key:t,userId:n,type:e})}})).set(fO.PLAYER_STATE_CHANGED,(e=>{let{track:t,state:i,reason:r,type:n}=e;if(UD(t)&&this.hitTest(t.room)&&n===Mw.VIDEO){if("PLAYING"===i){let e="".concat(t.userId,"_").concat(t.streamType);this._isVideoPlayingEventFiredMap.set(e,!0)}r===Mw.MUTE?this.onVideoTrackMuted(t):r===Mw.UNMUTE&&this.onVideoTrackUnmuted(t)}})).set(fO.HEARTBEAT_REPORT,this.onHearBeatReport),this._eventMap.forEach(((e,t)=>JN.on(t,e,this)))}uninstallEvents(){this._eventMap.forEach(((e,t)=>JN.off(t,e,this))),this._eventMap.clear()}stop(){this._renderFreezeMap.clear(),this._dataFreezeMap.clear(),this._isVideoPlayingEventFiredMap.clear()}onVideoTrackMuted(e){if(!e.isSubscribed)return;let{userId:t,streamType:i}=e,r="".concat(t,"_").concat(i),n=this._dataFreezeMap.get(r),o=new iU;n?n.durationItemList.push(o):this._dataFreezeMap.set(r,{userId:t,type:i,durationItemList:[o],isFreezing(){let e=this.durationItemList[this.durationItemList.length-1];return e&&0===e.endTime}})}onVideoTrackUnmuted(e){if(!e.isSubscribed)return;let{userId:t,streamType:i}=e,r="".concat(t,"_").concat(i);this.stopDataFreeze({key:r,userId:t,type:i})}onHearBeatReport(e){let{room:t,report:i}=e;!this.hitTest(t)||i.msg_down_stream_info.forEach((e=>{let t=this._room.remotePublishedUserMap.get(e.msg_user_info.str_identifier);if(!t)return;let{userId:i,muteState:r}=t;e.msg_video_status.forEach((e=>{2===e.uint32_video_stream_type&&r.hasVideo&&!r.videoMuted&&t.remoteVideoTrack.isSubscribed&&this.handleRenderFreeze({userId:i,fps:e.uint32_video_dec_fps,type:"main"}),7===e.uint32_video_stream_type&&r.hasAuxiliary&&t.remoteAuxiliaryTrack.isSubscribed&&this.handleRenderFreeze({userId:i,fps:e.uint32_video_dec_fps,type:"auxiliary"})}))}))}stopDataFreeze(e){let{key:t,userId:i,type:r}=e,n=this._dataFreezeMap.get(t);if(!n||!n.isFreezing())return;let o=n.durationItemList[n.durationItemList.length-1];o.stop();let s=o.getDuration();s>gN?this._monitorFreezeData.set(t,{userId:i,type:r,duration:s}):n.durationItemList.pop()}getTotalDuration(e){return e.reduce(((e,t)=>{let i=t.getDuration();return e+Math.min(i,5e3)}),0)}handleRenderFreeze(e){return rC(this,arguments,(function(e){var t=this;let{userId:i,fps:r,type:n}=e;return function*(){let e="".concat(i,"_").concat(n),o=t._renderFreezeMap.get(e);if(r<=2){let r=zD();o&&!o.isFreeze&&(o.freezeTimeline.push({startTime:r,endTime:0}),o.isFreeze=!0),o||t._renderFreezeMap.set(e,{userId:i,type:n,isFreeze:!0,freezeTimeline:[{startTime:r,endTime:0}],renderFreezeTotal:0})}else if(o&&o.isFreeze){o.isFreeze=!1;let e=o.freezeTimeline.pop();if(e){e.endTime=zD();let t=e.endTime-e.startTime;o.freezeTimeline.push(e),o.renderFreezeTotal+=Math.min(5e3,t)}}}()}))}onPlayTrackStart(e){let{track:t}=e;if(!UD(t)||!this.hitTest(t.room)||t.kind!==Mw.VIDEO||t.hasFlag)return;let i="".concat(t.userId,"_").concat(t.streamType);this._isVideoPlayingEventFiredMap.has(i)||this._isVideoPlayingEventFiredMap.set(i,!1)}getDataFreezeDuration(e){let t={dataFreeze:0,count:0},i=this._dataFreezeMap.get(e);if(i){if(i.isFreezing()){let e=i.durationItemList[i.durationItemList.length-1];e.stop(),e.getDuration()<gN&&i.durationItemList.pop()}t.dataFreeze=this.getTotalDuration(i.durationItemList),t.count=i.durationItemList.length}return t}getRenderFreezeDuration(e){let t=this._renderFreezeMap.get(e),i=0,r=0;if(t)if(t.isFreeze){let e=zD()-t.freezeTimeline[t.freezeTimeline.length-1].startTime;i=t.renderFreezeTotal+Math.min(e,5e3),r=t.freezeTimeline.length}else i=t.renderFreezeTotal;return{renderFreeze:i,count:r}}getMonitorFreeze(){return this._monitorFreezeData}isBlackStream(e){return!!this._isVideoPlayingEventFiredMap.has(e)&&!this._isVideoPlayingEventFiredMap.get(e)}resetMonitor(){this._monitorFreezeData.clear()}hitTest(e){return e===this._room}destroy(){this.uninstallEvents()}},oU=$b(nC(),1),sU=[-1,-1,1,-1,-1,1,1,1],aU=[0,0,1,0,0,1,1,1],cU=class extends gL{constructor(e,t){if(super(),this.context=e,tC(this,"name"),tC(this,"input"),tC(this,"output"),tC(this,"texture"),tC(this,"image"),tC(this,"ctx2d",null),tC(this,"fbo"),tC(this,"width",0),tC(this,"height",0),tC(this,"x",0),tC(this,"y",0),tC(this,"program"),tC(this,"vertexShader"),tC(this,"fragmentShader"),tC(this,"totalFrames",0),tC(this,"dropFrames",0),tC(this,"matchInputSize",!0),tC(this,"texCoordBuffer"),tC(this,"positionBuffer"),tC(this,"lastInfo",{name:"",timestamp:0,totalFrames:0,x:0,y:0,width:0,height:0,fps:0}),tC(this,"cost",0),tC(this,"_canvas",null),this.context.on("disconnect",this.close,this),this.name=t.name,this.matchInputSize=!1!==t.matchInputSize,this.width=t.width||e.width,this.height=t.height||e.height,e instanceof vU){if(e.ctx&&t.create2d){let e=document.createElement("canvas"),t="function"==typeof e.transferControlToOffscreen?e.transferControlToOffscreen():e;t.width=this.width,t.height=this.height,this.ctx2d=t.getContext("2d"),this.image=t,this._canvas=t}}else try{let i=e.ctx;this.texCoordBuffer=this.createBuffer(aU),this.positionBuffer=this.createBuffer(sU),!1!==t.createTexture&&(this.texture=i.createTexture(),this.useTexture(),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.pixelStorei(i.PACK_ALIGNMENT,1),i.pixelStorei(i.UNPACK_ALIGNMENT,1)),t.useFbo&&(this.fbo=i.createFramebuffer(),this.useBufferFrame(),this.useTexture(),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,this.width,this.height,0,i.RGBA,i.UNSIGNED_BYTE,null),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,this.texture,0)),t.useDefaultProgram?this.program=e.defaultProgam:(t.vertexShaderSource||t.fragmentShaderSource)&&(this.vertexShader=t.vertexShaderSource?e.createShader(i.VERTEX_SHADER,t.vertexShaderSource):e.defaultVShader,this.fragmentShader=t.fragmentShaderSource?e.createShader(i.FRAGMENT_SHADER,t.fragmentShaderSource):e.defaultFShader,this.program=e.createProgram(this.vertexShader,this.fragmentShader))}catch(i){this.context.destroy(i)}}connect(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return e.addInput(this,...i),this.output=e,e}addInput(e){this.input=e,this.matchInputSize&&e.width&&e.height&&this.resize(e.width,e.height)}requestFrame(e){let t=Date.now();return!!(this.context instanceof EU&&this.render(e)||this.context instanceof vU&&this.render2d(e))&&(this.totalFrames++,this.cost=Date.now()-t,!0)}render2d(e){var t;return!(null==(t=this.input)||!t.requestFrame(e))&&this.draw2d(this.input.image,0,0,this.width,this.height)}disconnect(){for(var e,t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];null==(e=this.output)||e.removeInput(this,...i),delete this.output}removeInput(e){delete this.input}close(){var e,t;if(this.context.off("disconnect",this.close,this),null==(e=this.output)||e.removeInput(this),delete this.output,null==(t=this.input)||t.disconnect(),this.context instanceof EU){let e=this.context.ctx;e.deleteBuffer(this.texCoordBuffer),e.deleteBuffer(this.positionBuffer),this.fbo&&e.deleteFramebuffer(this.fbo),this.texture&&e.deleteTexture(this.texture),this.vertexShader&&this.vertexShader!==this.context.defaultVShader&&e.deleteShader(this.vertexShader),this.fragmentShader&&this.fragmentShader!==this.context.defaultFShader&&e.deleteShader(this.fragmentShader),this.program&&this.program!==this.context.defaultProgam&&e.deleteProgram(this.program)}this._canvas&&(this._canvas.width=0,this._canvas.height=0,this.ctx2d=null),this.removeAllListeners()}useTexture(){this.useTextures(this.texture)}useInputTexture(){var e;this.useTextures(null==(e=this.input)?void 0:e.texture)}useTextures(){let e=this.context.ctx;for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];i.forEach(((t,i)=>{t&&(e.activeTexture(e.TEXTURE0+i),e.bindTexture(e.TEXTURE_2D,t))}))}useProgram(){this.context.ctx.useProgram(this.program)}useBufferFrame(){let e=this.context.ctx;e.bindFramebuffer(e.FRAMEBUFFER,this.fbo||null)}createBuffer(e){let t=this.context.ctx,i=t.createBuffer();return t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e),t.STATIC_DRAW),i}setTexBuffer(e){let t=this.context.ctx;t.bindBuffer(t.ARRAY_BUFFER,this.texCoordBuffer),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e),t.STATIC_DRAW)}setPosBuffer(e){let t=this.context.ctx;t.bindBuffer(t.ARRAY_BUFFER,this.positionBuffer),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e),t.STATIC_DRAW)}changeBufferData(e,t){let i=this.context.ctx;i.bindBuffer(i.ARRAY_BUFFER,e),i.bufferData(i.ARRAY_BUFFER,new Float32Array(t),i.STATIC_DRAW)}setAttributes(){let e=this.context.ctx;for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];i.forEach(((t,i)=>{e.enableVertexAttribArray(i),e.bindBuffer(e.ARRAY_BUFFER,t),e.vertexAttribPointer(i,2,e.FLOAT,!1,0,0)}))}getVertexPoint(e,t){return[e/this.width*2-1,t/this.height*2-1]}layout2texCoords(e){return[...this.getVertexPoint(e.x,e.y),...this.getVertexPoint(e.x+e.width,e.y),...this.getVertexPoint(e.x,e.y+e.height),...this.getVertexPoint(e.x+e.width,e.y+e.height)]}resize(e,t){if(this.width!==e||this.height!==t){if(this.width=e,this.height=t,this._canvas&&(this._canvas.width=e,this._canvas.height=t),this.texture&&this.fbo){this.useTexture();let i=this.context.ctx;i.texImage2D(i.TEXTURE_2D,0,i.RGBA,e,t,0,i.RGBA,i.UNSIGNED_BYTE,null)}this.output&&this.output.matchInputSize&&this.output.resize(e,t)}}draw(e,t){this.setAttributes(e||this.positionBuffer,t||this.texCoordBuffer);let i=this.context.ctx;i.drawArrays(i.TRIANGLE_STRIP,0,4)}draw2d(e,t,i,r,n){return!(!this.ctx2d||!e||(e instanceof ImageData?this.ctx2d.putImageData(e,t,i):this.ctx2d.drawImage(e,t,i,r,n),0))}getInfo(){var e;let{totalFrames:t,x:i,y:r,width:n,height:o,name:s,cost:a}=this,c=Date.now(),l=(t-this.lastInfo.totalFrames)/((c-this.lastInfo.timestamp)/1e3)|0;return this.lastInfo={totalFrames:t,x:i,y:r,width:n,height:o,timestamp:c,fps:l,name:s,cost:a},qb({parent:null==(e=this.input)?void 0:e.getInfo()},this.lastInfo)}createTexture(e){let t=this.context.ctx,i=t.createTexture();return this.useTextures(i),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.pixelStorei(t.PACK_ALIGNMENT,1),t.pixelStorei(t.UNPACK_ALIGNMENT,1),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),i}};eC([mL(gL.INIT,"connected",{sync:!0})],cU.prototype,"connect",1),eC([mL("connected",gL.INIT,{ignoreError:!0,sync:!0})],cU.prototype,"disconnect",1),eC([mL([],"closed",{sync:!0})],cU.prototype,"close",1);var lU=[0,1,1,1,0,0,1,0],dU=class extends cU{constructor(e,t){super(e,Object.assign({useDefaultProgram:!0,createTexture:!1,name:"destination"},t)),tC(this,"_intervalId",0),tC(this,"_sequence",0),tC(this,"checkGLError",!1),e instanceof vU?this.ctx2d=e.ctx:e.available&&(null==t?void 0:t.mirrorUpAndDown)&&this.setTexBuffer(lU)}start(e){this._intervalId=SL.run("intervalInWorker",(()=>{if(e!==this.context.frameRate&&(SL.clearTask(this._intervalId),this.start(this.context.frameRate)),this.requestFrame(this._sequence++),this.checkGLError&&this.context instanceof EU){let e=this.context.ctx.getError();e&&this.context.destroy(new Error("".concat(this.name," req ").concat(this._sequence," render ").concat(this.totalFrames," faild ").concat(e)))}}),{fps:this.context.frameRate})}render(e){var t;return!(null==(t=this.input)||!t.requestFrame(e)||(this.useProgram(),this.useBufferFrame(),this.useInputTexture(),this.draw(),0))}addInput(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];super.addInput(e,...i),this.start(this.context.frameRate)}removeInput(e){super.removeInput(e),SL.clearTask(this._intervalId)}},uU=class extends dU{constructor(e,t){super(e,t),tC(this,"_videoTrack"),[this._videoTrack]=e._canvas.captureStream(e.frameRate).getVideoTracks();let i=e=>{var t;let i=()=>{var t;return null==(t=this._videoTrack)?void 0:t.removeEventListener(e,r)},r=()=>{i(),this.context.destroy(new Error("video track ".concat(e)))};this.once("closed",i),null==(t=this._videoTrack)||t.addEventListener(e,r)};e instanceof EU&&i("mute"),i("ended")}get videoTrack(){return this._videoTrack}close(){var e;super.close(),null==(e=this._videoTrack)||e.stop(),delete this._videoTrack}resize(e,t){super.resize(e,t),this.context.setSize(e,t)}},hU=class extends uU{render(e){var t;return!(null==(t=this.input)||!t.requestFrame(e))}},pU=class extends uU{constructor(e,t){super(e,{name:"smallDestination"}),this.resolution=t}resize(e,t){let i,r=e*t,n=this.resolution.width*this.resolution.height;EO.info("big res: ".concat(e,"*").concat(t," small res: ").concat(this.resolution.width,"*").concat(this.resolution.height," ")),r>n?i=r/n:(EO.warn("Small stream resolution is not smaller than big stream, which is invalid. big: ".concat(e," * ").concat(t," small: ").concat(this.resolution.width," * ").concat(this.resolution.height)),i=r/19200),super.resize(e/Math.sqrt(i),t/Math.sqrt(i))}},mU=class extends cU{constructor(e,t,i){super(e,qb({name:"imageSource"},i)),this.image=t,tC(this,"_image"),tC(this,"_totalFrames",0),tC(this,"_autoResize",!1),this._autoResize=!1!==(null==i?void 0:i.autoResize)}_render(e,t){let{width:i,height:r}=this;if(this.image instanceof HTMLVideoElement){if(ND(this.image.getVideoPlaybackQuality)&&!Fk){let e=this.image.getVideoPlaybackQuality().totalVideoFrames;if(this._totalFrames===e)return!1;this._totalFrames=e,this.dropFrames=this._totalFrames-this.totalFrames}({videoWidth:i,videoHeight:r}=this.image),this.image.width=i,this.image.height=r}else if(this.image instanceof HTMLImageElement||this.image instanceof ImageData||this.image instanceof ImageBitmap){if(({width:i,height:r}=this.image),this.image!==this._image)this._image=this.image;else if(i===this.width&&r===this.height)return!1}else(this.image instanceof HTMLCanvasElement||this.image instanceof OffscreenCanvas)&&(({width:i,height:r}=this.image),this._image=this.image);if(!this._autoResize)return!0;if(this.width===i&&this.height===r&&this.totalFrames){if(t){this.useTexture();let e=this.context.ctx;e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,this.image)}}else{if(t){this.useTexture();let e=this.context.ctx;e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this.image)}this.resize(i,r)}return!0}render(e){return this._render(e,!0)}render2d(e){return this._render(e,!1)}},_U=class extends mU{constructor(e,t,i){let r=document.createElement("video");r.setAttribute("playsinline","playsinline"),r.setAttribute("muted",""),super(e,r,i),this._videoTrack=t,tC(this,"_mediaStream"),this.name="videoTrackSource",this._mediaStream=new MediaStream([t]),this.image.srcObject=this._mediaStream,this.image.play()}replaceTrack(e){var t,i;this._videoTrack!==e&&(null==(t=this._mediaStream)||t.removeTrack(this._videoTrack),this._videoTrack=e,null==(i=this._mediaStream)||i.addTrack(this._videoTrack),this.image.play())}close(){var e;super.close(),null==(e=this._mediaStream)||e.removeTrack(this._videoTrack),delete this._mediaStream,this.image.srcObject=null}},fU=class extends gL{constructor(e){super(),tC(this,"frameRate"),tC(this,"_canvas"),tC(this,"log"),tC(this,"hasAlpha",!1),tC(this,"name"),this.name=e.name,this.log=e.logger.createChild({id:"vc-".concat(this.name)}),this.frameRate=e.frameRate}set width(e){this._canvas&&(this._canvas.width=e)}get width(){var e;return(null==(e=this._canvas)?void 0:e.width)||0}set height(e){this._canvas&&(this._canvas.height=e)}get height(){var e;return(null==(e=this._canvas)?void 0:e.height)||0}setSize(e,t){this._canvas&&(this._canvas.width=e,this._canvas.height=t)}createVideoTrackSource(e){return new _U(this,e)}createVideoTrackDestination(e){return new uU(this,e)}createVideoImageSource(e,t){return new mU(this,e,t)}get available(){return"created"===this.state}disconnect(){this.emit("disconnect")}},gU={alpha:!0,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0,powerPreference:"low-power"},EU=class extends fU{constructor(){super(...arguments),tC(this,"defaultProgam"),tC(this,"defaultVShader"),tC(this,"defaultFShader"),tC(this,"ctx")}create(){if(this._canvas||(this._canvas=document.createElement("canvas")),this.ctx=this._canvas.getContext("webgl2",gU),!this.ctx)throw new Error("webgl2 not supported");this.defaultVShader=this.createShader(this.ctx.VERTEX_SHADER,"\n// 顶点着色器\nattribute vec4 a_position;\nattribute vec2 a_texCoord;\nvarying vec2 v_texCoord;\n\nvoid main() {\n gl_Position = a_position;\n v_texCoord = a_texCoord;\n}\n"),this.defaultFShader=this.createShader(this.ctx.FRAGMENT_SHADER,"\n// 片元着色器\nprecision mediump float;\nvarying vec2 v_texCoord;\nuniform sampler2D u_texture;\n\nvoid main() {\n gl_FragColor = texture2D(u_texture, v_texCoord);\n} "),this.defaultProgam=this.createProgram(this.defaultVShader,this.defaultFShader),this._canvas.addEventListener("webglcontextlost",(()=>{this.destroy(new Error("webgl context lost"))})),this.log.info("video context created use webgl")}destroy(e){return this.disconnect(),this.log.info("video context destroy ".concat(e?": ".concat(e):"")),this.ctx&&(this.ctx.deleteShader(this.defaultVShader),this.ctx.deleteShader(this.defaultFShader),this.ctx.deleteProgram(this.defaultProgam),delete this.ctx),e}set width(e){var t;null==(t=this.ctx)||t.viewport(0,0,e,this.height),super.width=e}set height(e){var t;null==(t=this.ctx)||t.viewport(0,0,this.width,e),super.height=e}setSize(e,t){var i;null==(i=this.ctx)||i.viewport(0,0,e,t),super.setSize(e,t)}createShader(e,t){let i=this.ctx,r=i.createShader(e);return i.shaderSource(r,t),i.compileShader(r),r}createProgram(e,t){let i=this.ctx,r=i.createProgram();return i.attachShader(r,e),i.attachShader(r,t),i.linkProgram(r),i.getProgramParameter(r,i.LINK_STATUS)||this.log.error(i.getProgramInfoLog(r)),r}};eC([mL(gL.INIT,"created",{sync:!0})],EU.prototype,"create",1),eC([mL("created",gL.INIT,{ignoreError:!0,sync:!0,success(e){e&&this.emit("unavailable",e),this.removeAllListeners()}})],EU.prototype,"destroy",1);var vU=class extends fU{constructor(){super(...arguments),tC(this,"ctx")}create(e){if(this.hasAlpha=e.alpha,this._canvas=document.createElement("canvas"),this.ctx=this._canvas.getContext("2d",{alpha:e.alpha}),!this.ctx)throw new Error("2d context not supported");this.log.info("video context created use 2d")}destroy(e){this.disconnect(),this.log.info("video context destroy ".concat(e?": ".concat(e):"")),delete this.ctx,this._canvas&&(this._canvas.remove(),this._canvas.width=0,this._canvas.height=0,delete this._canvas),this.removeAllListeners()}};eC([mL(gL.INIT,"created",{sync:!0})],vU.prototype,"create",1),eC([mL("created",gL.INIT,{ignoreError:!0,sync:!0})],vU.prototype,"destroy",1);var yU,TU=[1,0,0,0,1,1,0,1],SU=class extends cU{constructor(e){if(super(e,{useDefaultProgram:!0,useFbo:!0,create2d:!0,name:"mirror"}),e instanceof EU)try{this.setTexBuffer(TU)}catch(t){e.destroy(t)}else this.ctx2d&&setTimeout((e=>{e.scale(-1,1),e.translate(-this.width,0)}),0,this.ctx2d)}render(e){var t;return!(null==(t=this.input)||!t.requestFrame(e)||(this.useProgram(),this.useBufferFrame(),this.useInputTexture(),this.draw(),0))}},IU=class{constructor(e,t){this.node=e,this.layout=t,tC(this,"positionBuffer")}get x(){return this.layout.x||this.node.x}get y(){return this.layout.y||this.node.y}get width(){return this.layout.width||this.node.width}get height(){return this.layout.height||this.node.height}get right(){return this.x+this.width}get bottom(){return this.y+this.height}},AU=class extends cU{constructor(e){super(e,{useDefaultProgram:!0,useFbo:!0,name:"mix",create2d:!0}),tC(this,"inputs",[])}addInput(e,t){if(this.inputs[t.zIndex])throw new Error("input already exists");let i=new IU(e,t);this.inputs[t.zIndex]=i}resize(e,t){let i=this.inputs.reduce(((e,t)=>t?Object.assign(e,{width:Math.max(e.width,t.right),height:Math.max(e.height,t.bottom)}):e),{width:0,height:0});super.resize(i.width,i.height),this.context instanceof EU&&this.inputs.forEach((e=>{if(e){let t=this.layout2texCoords(e);e.positionBuffer?this.changeBufferData(e.positionBuffer,t):e.positionBuffer=this.createBuffer(t)}}))}connect(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return super.connect(e,...i),this.resize(0,0),e}removeInput(e){this.inputs[this.inputs.findIndex((t=>(null==t?void 0:t.node)===e))]=void 0}render(e){let t=this.context.ctx;if(t.clearColor(0,0,0,0),!this.inputs.reduce(((t,i)=>(!i||!i.node.requestFrame(e))&&t),!0)&&t){this.useProgram(),t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA),this.useBufferFrame();for(let e=0;e<this.inputs.length;e++){let t=this.inputs[e];t&&(t.node.useTexture(),this.draw(t.positionBuffer))}return!0}return!1}render2d(e){if(!this.inputs.reduce(((t,i)=>(!i||!i.node.requestFrame(e))&&t),!0)&&this.ctx2d){this.ctx2d.clearRect(0,0,this.width,this.height);for(let e=0;e<this.inputs.length;e++){let t=this.inputs[e];t&&this.draw2d(t.node.image,t.x,t.y,t.width,t.height)}return!0}return!1}getInfo(){let{totalFrames:e,x:t,y:i,width:r,height:n,name:o}=this,s=Date.now(),a=(e-this.lastInfo.totalFrames)/((s-this.lastInfo.timestamp)/1e3)|0;return this.lastInfo={totalFrames:e,x:t,y:i,width:r,height:n,timestamp:s,fps:a,name:o},qb({parent:this.inputs.filter((e=>e)).map((e=>e.node.getInfo()))},this.lastInfo)}close(){super.close(),this.inputs.forEach((e=>{var t,i;if(e&&(null==(t=e.node)||t.disconnect(),e.positionBuffer&&this.context instanceof EU))try{null==(i=this.context.ctx)||i.deleteBuffer(e.positionBuffer)}catch(r){}}))}},RU=class{constructor(e,t){this.createMediapipeSolutionsWasm=t,tC(this,"canvas"),tC(this,"locateFile"),tC(this,"_glName"),tC(this,"_solutionWasm"),tC(this,"ctx"),tC(this,"pl",{onResults:e=>this.onResults(e.get(0).glName)}),this.locateFile=t=>"".concat(e,"/").concat(t)}bindTexture(){var e;null==(e=this.ctx)||e.activeTexture(this.ctx.TEXTURE0),this.bindTexture2d(this._glName)}initialize(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"selfie_segmentation_landscape.tflite";return rC(this,null,(function*(){yield this.createMediapipeSolutionsWasm(this),this.canvas=e,this.createContext(e,!0,!0,{}),this._glName=this.createTexture(),this._solutionWasm=new this.SolutionWasm;let i=new this.StringList;i.push_back("segmentation_mask");let r=this.PacketListener.implement(this.pl);this._solutionWasm.attachMultiListener(i,r),i.delete(),this._solutionWasm.loadGraph(yield fetch(this.locateFile("selfie_segmentation.binarypb")).then((e=>e.arrayBuffer()))),this._solutionWasm.overrideFile("third_party/mediapipe/modules/selfie_segmentation/selfie_segmentation_landscape.tflite",yield fetch(this.locateFile(t)).then((e=>e.arrayBuffer())));let n=new this.GraphOptionChangeRequestList;return n.push_back({calculatorIndex:1,calculatorName:"",calculatorType:"GlScalerCalculator",fieldName:"flip_horizontal",valueBoolean:!1,valueNumber:0,valueString:""}),n.push_back({calculatorIndex:0,calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculatorModelSelection",fieldName:"int_value",valueBoolean:!1,valueNumber:1,valueString:""}),n.push_back({calculatorIndex:0,calculatorType:"InferenceCalculator",calculatorName:"",fieldName:"use_cpu_inference",valueBoolean:!1,valueNumber:0,valueString:""}),this._solutionWasm.changeOptions(n),this}))}send(e,t){let i=new this.PacketDataList;i.pushTexture2d({stream:"input_frames_gpu",timestamp:1e3*performance.now(),glName:this._glName,width:e,height:t}),this._solutionWasm.send(i),i.delete()}close(){var e,t,i;null==(e=this.canvas)||delete e.getContext,delete this.readyPromiseResolve,delete this.readyPromiseReject,this.pl.onResults=null,delete this.onResults,null==(t=this.deleteTexture)||t.call(this,this._glName),null==(i=this._solutionWasm)||i.delete();for(let r of Object.keys(this))delete this[r]}},bU=class extends _U{constructor(e,t){super(e,t.input,{name:"vb",create2d:!1,useDefaultProgram:!1,useFbo:!1,createTexture:!0}),tC(this,"ready",!1),tC(this,"_bgTexture"),tC(this,"_waterMarkTexture"),tC(this,"_lastMaskTexture"),tC(this,"_textureValid",!1),tC(this,"_selfieTextureValid",!1),tC(this,"_selfieSegmentation"),tC(this,"wasm"),this.init(t).catch((()=>this.context.destroy(new Error("selfie_segmentation init faild"))))}init(e){return rC(this,null,(function*(){let t=yield e.Wasm(),i=this.context.ctx;if(this.wasm=new t.AllIn1(i),this.wasm.blurRadius=e.blurRadius||3,this.wasm.mirror=!!e.mirror,this.wasm.vbMode="blur"===e.bg?1:e.bg instanceof HTMLImageElement?2:"green"===e.bg?3:0,e.waterMark){let{x:t,y:i,width:r,height:n}=e.waterMark;this.wasm.setWaterMark(t,i,r,n)}this.program=this.wasm.init(),this.useProgram(),this.setAttributes(this.positionBuffer,this.texCoordBuffer),i.uniform1i(i.getUniformLocation(this.program,"mask"),1),e.bg instanceof HTMLImageElement&&(i.uniform1i(i.getUniformLocation(this.program,"bg"),2),this._bgTexture=this.createTexture(e.bg)),e.waterMark&&(i.uniform1i(i.getUniformLocation(this.program,"waterMark"),3),this._waterMarkTexture=this.createTexture(e.waterMark.image)),i.uniform1i(i.getUniformLocation(this.program,"lastMask"),4),this._selfieSegmentation=yield e.selfieSegmentation,this._selfieSegmentation.onResults=this.onPredict.bind(this),this.ready=!0}))}onPredict(e){let t=this.context.ctx;this._lastMaskTexture||(this._lastMaskTexture=this.createTexture(this.image)),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,1&this.totalFrames?this.texture:this._lastMaskTexture),t.copyTexSubImage2D(t.TEXTURE_2D,0,0,0,0,0,this.width,this.height),this.useProgram(),this._selfieSegmentation.bindTexture(),t.activeTexture(t.TEXTURE1),this._selfieSegmentation.bindTexture2d(e),t.activeTexture(t.TEXTURE2),t.bindTexture(t.TEXTURE_2D,this._bgTexture||null),t.activeTexture(t.TEXTURE3),t.bindTexture(t.TEXTURE_2D,this._waterMarkTexture||null),t.activeTexture(t.TEXTURE4),t.bindTexture(t.TEXTURE_2D,1&this.totalFrames?this._lastMaskTexture:this.texture),this.useBufferFrame(),t.drawArrays(t.TRIANGLE_STRIP,0,4),this.totalFrames++}render(e){let t=this.context.ctx;if("function"==typeof this.image.getVideoPlaybackQuality&&!Fk){let e=this.image.getVideoPlaybackQuality().totalVideoFrames;if(this._totalFrames===e)return!1;this._totalFrames=e,this.dropFrames=this._totalFrames-this.totalFrames}let{videoWidth:i,videoHeight:r}=this.image;this.image.width=i,this.image.height=r;let n=!1;if(this.totalFrames)this._selfieSegmentation.bindTexture(),n=this._selfieTextureValid,this._selfieTextureValid=!0;else{if(!this.program)return!1;this.useTexture(),n=this._textureValid,this._textureValid=!0}return this.width===i&&this.height===r&&n?t.texSubImage2D(t.TEXTURE_2D,0,0,0,t.RGBA,t.UNSIGNED_BYTE,this.image):(this.resize(i,r),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,this.image)),this.ready&&this._selfieSegmentation.send(i,r),this.totalFrames||(t.activeTexture(t.TEXTURE2),t.bindTexture(t.TEXTURE_2D,this._bgTexture||null),t.activeTexture(t.TEXTURE3),t.bindTexture(t.TEXTURE_2D,this._waterMarkTexture||null),t.drawArrays(t.TRIANGLE_STRIP,0,4)),!1}close(){var e;super.close();let t=this.context.ctx;this._bgTexture&&t.deleteTexture(this._bgTexture),this._waterMarkTexture&&t.deleteTexture(this._waterMarkTexture),this._lastMaskTexture&&t.deleteTexture(this._lastMaskTexture),null==(e=this.wasm)||e.close()}},CU=class extends oU.EventEmitter{constructor(e){super(),this.room=e,tC(this,"videoContext"),tC(this,"_glVideoContext"),tC(this,"_2dVideoContext"),tC(this,"destination"),tC(this,"smallVideoContext"),tC(this,"smallDestination"),tC(this,"smallTrackSource"),tC(this,"smallImageSource"),tC(this,"_isMirror",!1),tC(this,"cameraTrack"),tC(this,"cameraNode"),tC(this,"mirrorNode"),tC(this,"mixNode"),tC(this,"screenTrack"),tC(this,"screenNode"),tC(this,"selfModel",!1),tC(this,"blurRadius",3),tC(this,"arTrack"),tC(this,"Wasm"),tC(this,"waterMarkNode"),tC(this,"_waterMarkOption"),tC(this,"watermarkImageList",[]),tC(this,"_isMixScreen",!1),tC(this,"_virtualBackground"),tC(this,"virtualBackgroundInstance"),tC(this,"isUsingArTrack",!1),tC(this,"_bgAssetPath"),tC(this,"log",EO.createLogger({id:"vm"})),tC(this,"_checkId",0),tC(this,"_use2d",!1),tC(this,"_autoSwitchRenderMode",!0),tC(this,"_selfieSegmentation"),e&&(this.log.setUserId(e.userId),this.log.setSdkAppId(e.sdkAppId)),this.smallVideoContext=new vU({frameRate:15,logger:this.log,name:"s"}),this.enablePrintDetail()}get _hasVirtualBg(){return!!this._virtualBackground}get _hasWaterMark(){return this.watermarkImageList.length>0}get renderMode(){return this._autoSwitchRenderMode?"auto":this._use2d?"2d":"webgl"}set renderMode(e){if(this._autoSwitchRenderMode="auto"===e,this._autoSwitchRenderMode)return;let t="2d"===e;this._use2d!==t&&(this._use2d=t,this.clear(),this.videoContext=this._use2d?this.get2dVideoContext():this.getGlVideoContext(),this.update())}get2dVideoContext(){return this._2dVideoContext?this._2dVideoContext.destroy():this._2dVideoContext=new vU({frameRate:15,logger:this.log,name:"m"}),this._2dVideoContext.create({alpha:this._hasWaterMark||this._hasVirtualBg}),this.sendCreateResult("videoCtx2d",this._2dVideoContext.ctx?void 0:new Error("create 2d context failed")),this._2dVideoContext}getGlVideoContext(){if(this._glVideoContext){if(this._glVideoContext.available)return this._glVideoContext}else this._glVideoContext=new EU({frameRate:15,logger:this.log,name:"m"});try{this._glVideoContext.create(),this.sendCreateResult(),this._glVideoContext.on("unavailable",((e,t)=>{this.emit("error",{reason:e,error:t}),this.log.warn("video context unavailable",e,t),this.sendCreateResult("videoCtxGl",t||new Error(e)),this.update()}))}catch(e){this.emit("error",{reason:"create",error:e}),this.sendCreateResult("videoCtxGl",e)}return this._glVideoContext}enablePrintDetail(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3;this._checkId=SL.run(MN,(()=>{this.destination&&this.log.debug(this.destination.getInfo())}),{delay:e})}destroy(){var e,t;null==(e=this._2dVideoContext)||e.destroy(),null==(t=this._glVideoContext)||t.destroy(),this.smallVideoContext.destroy(),SL.clearTask(this._checkId)}get needAlpha(){return this._hasWaterMark||this._hasVirtualBg}get active(){return(Fk||this._isMixScreen||this._isMirror||this._hasWaterMark||this._hasVirtualBg)&&this.checkOrCreateVideoContext()}sendCreateResult(){let e=arguments.length>1?arguments[1]:void 0,t="videoCtxGl"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"videoCtxGl")?512700:512701;e?pP.addFailedEvent({key:t,error:e}):pP.addSuccessEvent({key:t})}checkOrCreateVideoContext(){let e=this._use2d;if(this._autoSwitchRenderMode&&(this._use2d=!this._hasVirtualBg),this.videoContext)if(this.videoContext.available){let t=!this.videoContext.hasAlpha&&this.needAlpha;if(this._autoSwitchRenderMode&&e===this._hasVirtualBg)this.clear();else{if(!t)return!0;if(!this._use2d)return!0;this.clear()}}else this.clear(),this._use2d=!0;return this.videoContext=this._use2d?this.get2dVideoContext():this.getGlVideoContext(),this.videoContext.available}get smallTrack(){var e;return null==(e=this.smallDestination)?void 0:e.videoTrack}get hasSmall(){return!!this.smallTrack}get initialTrack(){var e;return null==(e=this.cameraTrack)?void 0:e.mediaTrack}initVirtualBackground(e){if(!this._selfieSegmentation){let t=new RU(e.assetPath||"./selfie_segmentation",e.createMediapipeSolutionsWasm),i=this.getGlVideoContext();return i.available?this._selfieSegmentation=t.initialize(i._canvas,"selfie_segmentation_landscape.tflite"):Promise.reject(new Error("init virtual background failed, reason: video context unavailable"))}return this._selfieSegmentation}_setMainOutput(e){var t;let i=this.cameraTrack,{small:r,settings:n,player:o}=i;r?(this.smallVideoContext.available||(this.smallVideoContext.create({alpha:!1}),this.smallDestination=new pU(this.smallVideoContext,r)),this.smallVideoContext.frameRate=r.frameRate,this.smallDestination.resolution=r,e?(this.smallTrackSource&&(this.smallTrackSource.close(),delete this.smallTrackSource),this.smallImageSource?this.smallImageSource.image=e:(this.smallImageSource=this.smallVideoContext.createVideoImageSource(e),this.smallImageSource.connect(this.smallDestination))):(this.smallImageSource&&(this.smallImageSource.close(),delete this.smallImageSource),this.smallTrackSource?this.smallTrackSource.replaceTrack(this.initialTrack):(this.smallTrackSource=this.smallVideoContext.createVideoTrackSource(this.initialTrack),this.smallTrackSource.width=n.width,this.smallTrackSource.height=n.height,this.smallTrackSource.connect(this.smallDestination)))):this.smallVideoContext.available&&(this.smallVideoContext.destroy(),delete this.smallDestination,delete this.smallTrackSource,delete this.smallImageSource),Fk&&o.setCanvas(e);let s=e&&(null==(t=this.destination)?void 0:t.videoTrack)||this.initialTrack;return this.isUsingArTrack&&this.arTrack&&(this.emit("output-track-changed"),s=this.arTrack),i.setOutputMediaStreamTrack(s)}update(){return rC(this,null,(function*(){var e,t;if(!this.cameraTrack||!this.cameraTrack.mediaTrack)return;if(!this.active)return this.cameraNode&&this.clear(),this._setMainOutput();let{settings:i,profile:r}=this.cameraTrack;if(this._use2d||!this._selfieSegmentation?(this.destination||(this.destination=this.videoContext.createVideoTrackDestination({name:"mainDestination"})),this.cameraNode?this.cameraNode.replaceTrack(this.initialTrack):(this.cameraNode=this.videoContext.createVideoTrackSource(this.initialTrack),this.cameraNode.resize(i.width,i.height))):(this.cameraNode&&this.cameraNode.close(),this.destination||(this.destination=new hU(this.videoContext,{name:"mainDestination"})),this.cameraNode=new bU(this.videoContext,{input:this.cameraTrack.mediaTrack,mirror:this._isMirror,bg:this._virtualBackground,selfModel:this.selfModel,waterMark:this._waterMarkOption,useTflite:!0,blurRadius:this.blurRadius,assetPath:this._bgAssetPath,selfieSegmentation:this._selfieSegmentation,Wasm:this.Wasm}),this.cameraNode.connect(this.destination)),this.videoContext.frameRate=r.frameRate,this._use2d){let i=this.cameraNode;i.disconnect(),this._isMirror&&(this.mirrorNode||(this.mirrorNode=new SU(this.videoContext)),i=i.connect(this.mirrorNode),i.disconnect(),this.log.info("start mirror")),this.mixNode&&this.mixNode.close(),delete this.mixNode,(this._isMixScreen||this._hasWaterMark)&&(this.mixNode=new AU(this.videoContext),i.connect(this.mixNode,{zIndex:1}),this._hasWaterMark&&!this.waterMarkNode&&this._waterMarkOption&&(this.waterMarkNode=this.videoContext.createVideoImageSource(this._waterMarkOption.image,{autoResize:!1}),this.waterMarkNode.resize(this._waterMarkOption.width,this._waterMarkOption.height),this.waterMarkNode.x=this._waterMarkOption.x,this.waterMarkNode.y=this._waterMarkOption.y),null==(e=this.waterMarkNode)||e.connect(this.mixNode,{zIndex:2}),this._isMixScreen&&this.screenTrack&&!this.screenNode&&(this.screenNode=this.videoContext.createVideoTrackSource(this.screenTrack.mediaTrack)),null==(t=this.screenNode)||t.connect(this.mixNode,{zIndex:0}),i=this.mixNode,this.log.info("start mix","".concat(this.mixNode.width,"x").concat(this.mixNode.height))),i.connect(this.destination)}return this._setMainOutput(this.videoContext._canvas)}))}changeInput(e){return this.log.info("change input"),e instanceof aM?this.setScreenTrack(e):e instanceof rM?this.setCameraTrack(e):e instanceof pM?e.setOutputMediaStreamTrack(e.mediaTrack):void 0}removeInput(e){var t;e instanceof aM?(null==(t=this.screenNode)||t.close(),delete this.screenNode,delete this.screenTrack,this.update()):e instanceof rM&&(this.clear(),delete this.cameraTrack,this.smallImageSource&&(this.smallImageSource.close(),delete this.smallImageSource),this.smallTrackSource&&(this.smallTrackSource.close(),delete this.smallTrackSource))}setCameraTrack(e){return rC(this,null,(function*(){this.cameraTrack=e,this.update()}))}setScreenTrack(e){return this.screenTrack=e,this._isMixScreen&&(this.screenNode?this.screenNode.replaceTrack(e.mediaTrack):this.update()),e.setOutputMediaStreamTrack(e.mediaTrack)}getWatermarkImage(e,t){return rC(this,null,(function*(){let i=document.createElement("canvas");t&&e&&(i.height=t,i.width=e);let r=i.getContext("2d");if(!r)throw new fC({code:_C.NOT_SUPPORTED,message:"Make image failed because of canvas context is null"});return this.watermarkImageList.sort(((e,t)=>e.zIndex-t.zIndex)),this.watermarkImageList.forEach((e=>{let{image:t,x:i,y:n,width:o,height:s}=e;r.drawImage(t,i,n,o,s)})),dO(i.toDataURL())}))}pushWaterMarkImageList(e){let{type:t}=e;this.watermarkImageList.some((t=>t.imageUrl===e.imageUrl&&t.height===e.height&&t.width===e.width&&t.x===e.x&&t.y===e.y&&t.type===e.type&&t.zIndex===e.zIndex))||(("mute"===t||"watermark"===t)&&(this.watermarkImageList=this.watermarkImageList.filter((e=>e.type!==t))),this.watermarkImageList.push(e))}setWatermark(e){return rC(this,null,(function*(){let t;try{t=yield dO((null==e?void 0:e.imageElement)||e.imageUrl)}catch(c){throw new fC({code:_C.INVALID_PARAMETER,message:"load image failed, url: ".concat(e.imageUrl)})}let{x:i=0,y:r=0,width:n=t.width,height:o=t.height,type:s="watermark",zIndex:a=2}=e;this.pushWaterMarkImageList({x:i,y:r,width:n,height:o,image:t,zIndex:a,type:s,imageUrl:e.imageUrl}),yield this.freshWatermark(),this.log.info("set watermark",JSON.stringify(this.watermarkImageList))}))}deleteWatermark(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"watermark";return rC(this,null,(function*(){this.watermarkImageList=this.watermarkImageList.filter((t=>t.type!==e)),this.log.info("delete watermark",e,JSON.stringify(this.watermarkImageList)),yield this.freshWatermark()}))}freshWatermark(){return rC(this,null,(function*(){var e,t,i;null==(e=this.waterMarkNode)||e.close(),delete this.waterMarkNode,delete this._waterMarkOption;let r=yield this.getWatermarkImage(null==(t=this.cameraTrack)?void 0:t.settings.width,null==(i=this.cameraTrack)?void 0:i.settings.height);this._waterMarkOption={x:0,y:0,width:r.width,height:r.height,image:r},this.update()}))}setVirtualBackground(e){return rC(this,null,(function*(){if(e){if(this._use2d&&!this._autoSwitchRenderMode)return Promise.reject(new Error("not support virtual background in 2d mode"));this._bgAssetPath=e.assetPath,"image"===e.type?this._virtualBackground=yield dO(e.imageUrl):(this.blurRadius=e.blurRadius||3,this._virtualBackground=e.type)}else this._virtualBackground=void 0;this.log.info("".concat(this._virtualBackground?"start":"stop"," visual background, ").concat((null==e?void 0:e.type)||"")),this.update()}))}get mixScreen(){return this._isMixScreen}set mixScreen(e){var t;this._isMixScreen=e,this._isMixScreen||(null==(t=this.screenNode)||t.close(),delete this.screenNode),this.update()}set mirror(e){var t;this._isMirror!==e&&(this._isMirror=e,this._isMirror||(null==(t=this.mirrorNode)||t.close(),delete this.mirrorNode),this.update())}get mirror(){return this._isMirror}enableAr(e){this.arTrack=e,this.isUsingArTrack=!0,this.update()}updateAr(){return rC(this,null,(function*(){var e;null==(e=this.cameraTrack)||!e.mediaTrack||(yield this.virtualBackgroundInstance.ar.updateInputTrack(this.cameraTrack.mediaTrack.clone()))}))}disableAr(){var e;this.isUsingArTrack=!1,null==(e=this.arTrack)||e.stop(),this.arTrack=void 0,this.update()}clear(){var e;null==(e=this.videoContext)||e.disconnect(),delete this.destination,delete this.cameraNode,delete this.mirrorNode,delete this.screenNode,delete this.waterMarkNode}},kU=0,wU=class extends gL{constructor(e){super("room"),this.seq=++kU,this.role="anchor",this.localTracks=new Set,this.enableAutoPlayDialog=!0,this.autoReceiveAudio=!0,this.autoReceiveVideo=!0,this.scheduleResult={domains:null,iceServers:null,iceTransportPolicy:null,trtcAutoConf:null},this._isUsingCachedSchedule=!1,this._log=EO.createLogger({id:"r".concat(this.seq)}),this._joinedTimestamp=0,this.isDestroyed=!1,this.useStringRoomId=!!e.useStringRoomId,PD(e.autoReceiveAudio)&&(this.autoReceiveAudio=e.autoReceiveAudio),PD(e.autoReceiveVideo)&&(this.autoReceiveVideo=e.autoReceiveVideo),PD(e.enableAutoPlayDialog)&&(this.enableAutoPlayDialog=e.enableAutoPlayDialog),this._sdkType=e.sdkType,this.keyPointManager=new tU({room:this,frameWorkType:e.frameWorkType,component:e.component,language:e.language}),this.callDurationCalculator=new rU({room:this}),this.badCaseDetector=new nU({room:this}),this.audioManager=new lM(this),this.videoManager=new CU(this)}get isMainStreamPublished(){for(let e of this.localTracks)if(4&e.mediaType)return!0;return!1}get isAuxStreamPublished(){for(let e of this.localTracks)if(2&e.mediaType)return!0;return!1}get hasAuxStream(){for(let e of this.remotePublishedUserMap.values())if(e.muteState.hasAuxiliary)return!0;return this.isAuxStreamPublished}getLogger(){return this._log}get isJoining(){return"joining"===this.state.toString()}get isJoined(){return"joined"===this.state}get isLeft(){return"left"===this.state}addTrack(e){return rC(this,null,(function*(){return this.publish(e)}))}removeTrack(e){return rC(this,null,(function*(){return this.unpublish(e)}))}replaceTrack(e){return rC(this,null,(function*(){}))}setEncodedDataProcessingListener(e){throw new Error("Method not implemented.")}enableAIVoice(e){throw new Error("Method not implemented.")}setProxyServer(e){if(OD(e))e.startsWith("wss://")?this.proxy_ws=e:e.startsWith("https://")&&(this.proxy_wt=e);else if(bD(e)){let{websocketProxy:t,webtransportProxy:i,loggerProxy:r,scheduleProxy:n,unifiedProxy:o}=e;this.proxy_ws=t,this.proxy_wt=i,this.proxy_unified=o,o?(iD([o,o]),mw("https://".concat(o))):(r&&mw(r),n&&iD(n))}JN.once(fO.JOIN_RECEIVED_CMD_RES,(()=>this.sendAbilityStatus({sched_domain:tD.main,sched_back_domain:tD.backup,signal_domain:this.proxy_ws||this.proxy_wt||""})))}getRemoteAudioStats(){return rC(this,null,(function*(){let e={};return this.remotePublishedUserMap.forEach((t=>{e[t.userId]=t.remoteAudioTrack.stat})),e}))}getTransportStats(){return rC(this,null,(function*(){var e;let t={rtt:(null==(e=this.quality)?void 0:e.uplinkRTT)||0,downlinksRTT:{}};if(this.quality)for(let i of this.quality.downlinkInfo)t.downlinksRTT[i.userId]=i.rtt;return t}))}getRemoteVideoStats(){return rC(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"main";return function*(){let i={};return e.remotePublishedUserMap.forEach((e=>{let r="auxiliary"===t?e.remoteAuxiliaryTrack:e.remoteVideoTrack;i[e.userId]=r.stat})),i}()}))}checkDestroy(){if(this.isDestroyed)throw new fC({code:_C.INVALID_OPERATION,message:GN({key:HN.CLIENT_DESTROYED,data:{funName:"join"}})})}destroy(){if(this.isJoined)throw this._log.warn(jN.INVALID_DESTROY),new fC({code:_C.INVALID_OPERATION,message:GN({key:HN.INVALID_DESTROY})});this._log.info("destroy room"),this.audioManager.destroy(),this.videoManager.destroy(),this.keyPointManager.destroy(),this.callDurationCalculator.destroy(),this.badCaseDetector.destroy(),this.isDestroyed=!0,JN.emit(fO.ROOM_DESTROY,{room:this})}schedule(e,t){return rC(this,null,(function*(){var i,r;let n=zD();try{let{isCached:o,result:s,detailCost:a}=yield eD({userId:this.userId,sdkAppId:this.sdkAppId,roomId:e,useStringRoomId:this.useStringRoomId,version:ow,userSig:this.userSig,frameWorkType:t});this._isUsingCachedSchedule=o,this._log.info("schedule cache:".concat(+o," ").concat(oO(s,{keysToExclude:["username","credential"]}))),o&&JN.once(fO.JOIN_RECEIVED_CMD_RES,(()=>this.sendAbilityStatus({scheduleCache:1}))),this.scheduleResult=qb(qb({},this.scheduleResult),s),LD(null==(i=s.config)?void 0:i.retryCount)&&oN(s.config.retryCount),OD(null==(r=s.config)?void 0:r.loggerDomain)&&mw(s.config.loggerDomain),JN.emit(fO.JOIN_SCHEDULE_SUCCESS,{room:this,schedule:this.scheduleResult,detailCost:a}),pP.addSuccessEvent({key:521700,cost:zD()-n,split:50})}catch(o){throw pP.addFailedEvent({key:521700,error:o}),o}}))}},NU=$b(nC()),DU=$b(hC()),OU=e=>{let{serverAbility:t,clientAbility:i,offerSDP:r,enableCustomMessage:n}=e,o=VV(r),s={extmapAllowMixed:"extmap-allow-mixed",groups:o.groups,icelite:"ice-lite",media:[],msidSemantic:{semantic:"",token:"WMS"},name:"-",origin:{address:"127.0.0.1",username:"-",sessionId:String(Date.now()),sessionVersion:1,netType:"IN",ipVer:4},timing:{start:0,stop:0},version:0},a={candidates:t.candidates.map((e=>({component:1,foundation:"1",generation:0,ip:e.ip,port:e.port,priority:e.priority,transport:e.foundation,type:e.type}))),connection:{version:4,ip:"0.0.0.0"},direction:Mw.TRANSCEIVER_DIRECTION_RECVONLY,ext:t.audio.extensions.map((e=>({value:e.id,uri:e.uri}))),fingerprint:{type:t.dtls.hash,hash:t.dtls.fingerprint},fmtp:[{payload:t.audio.codecs[0].payload,config:t.audio.codecs[0].fmtp}],icePwd:t.ice.password,iceUfrag:t.ice.ufrag,mid:"0",payloads:String(t.audio.codecs[0].payload),port:o.media[0].port,protocol:o.media[0].protocol,type:Mw.AUDIO,setup:t.dtls.setup,rtcpFb:t.audio.codecs[0].rtcpfb.map((e=>({payload:t.audio.codecs[0].payload,type:e.id,subtype:e.params[0]}))),rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",rtp:[{payload:t.audio.codecs[0].payload,codec:t.audio.codecs[0].codec,rate:t.audio.codecs[0].rate,encoding:t.audio.codecs[0].channels}]};return s.media.push(a),[1,2,3].forEach((e=>{s.media.push(LU({mid:e,serverAbility:t,clientAbility:i,parsedOffer:o}))})),n&&s.media.push(o.media.find((e=>"dc"===e.mid))),UV(s)},LU=e=>{let{mid:t,serverAbility:i,clientAbility:r,parsedOffer:n,useAllCodec:o=!1}=e,s={candidates:i.candidates.map((e=>({component:1,foundation:"1",generation:0,ip:e.ip,port:e.port,priority:e.priority,transport:e.foundation,type:e.type}))),connection:{version:4,ip:"0.0.0.0"},direction:Mw.TRANSCEIVER_DIRECTION_RECVONLY,ext:i.video.extensions.map((e=>({value:e.id,uri:e.uri}))),fingerprint:{type:i.dtls.hash,hash:i.dtls.fingerprint},fmtp:[],icePwd:i.ice.password,iceUfrag:i.ice.ufrag,mid:String(t),payloads:"",port:n.media[0].port,protocol:n.media[0].protocol,type:Mw.VIDEO,setup:i.dtls.setup,rtcpFb:[],rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",rtp:[]};if(i.video.codecs.length>0)if(o)for(let a=0;a<i.video.codecs.length;a++)PU(s,i.video.codecs[a]);else{let e=i.video.codecs.findIndex((e=>e.codec.toLowerCase()===(i.useVp8?"vp8":"h264")));PU(s,i.video.codecs[e])}else if(o)for(let a=0;a<r.video.codecs.length;a++)PU(s,r.video.codecs[a]);else PU(s,r.video.codecs[0]);return s.payloads=s.payloads.trim(),s},PU=(e,t)=>{e.payloads="".concat(e.payloads," ").concat(t.payload),e.fmtp.push({payload:t.payload,config:t.fmtp}),e.rtcpFb=[...e.rtcpFb||[],...(t.rtcpfb||t.rtcpFb).map((e=>({payload:t.payload,type:e.id,subtype:e.params[0]})))],e.rtp.push({payload:t.payload,codec:t.codec.toUpperCase(),rate:t.rate}),t.rtx&&(e.payloads="".concat(e.payloads," ").concat(t.rtx),e.fmtp.push({payload:t.rtx,config:"apt=".concat(t.payload)}),e.rtp.push({payload:t.rtx,codec:"rtx",rate:t.rate}))},MU=e=>{let t=DU.default.parse(e);return t.media.forEach((e=>{var i,r;(e.type===Mw.AUDIO||e.type===Mw.VIDEO)&&(function(e){if(!e.rtcpFb)return;let t=[];e.rtcpFb.forEach(((i,r)=>{var n;t.push(i),e.rtcpFb&&(null==(n=e.rtcpFb[r+1])?void 0:n.payload)!==i.payload&&"rrtr"!==i.type&&t.push({payload:i.payload,type:"rrtr"})})),e.rtcpFb=t}(e),(r=e).type===Mw.VIDEO&&r.fmtp&&r.fmtp.forEach((e=>{e.config.includes("apt")||(e.config+=";sps-pps-idr-in-keyframe=1")})),function(e){e.type===Mw.AUDIO&&e.fmtp&&e.fmtp.forEach((e=>{e.config+=";sprop-stereo=1;stereo=1"}))}(e),function(e){let t=new Set(["urn:ietf:params:rtp-hdrext:sdes:mid","urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id","urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"]);e.ext&&(e.ext=e.ext.filter((e=>!t.has(e.uri))))}(e)),(null==(i=e.payloads)?void 0:i.includes("datachannel"))&&t.groups&&e.mid&&(t.groups[0].mids=t.groups[0].mids.replace(e.mid,"dc"),e.mid="dc")})),DU.default.write(t)},xU=class{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.dataView=e,this.isSEI&&(t?this.addPreventionByte():this.removePreventionByte())}addPreventionByte(){let e=this.seiPayloadStartIndex,t=this.dataView.byteLength-2,i=[],r=0;for(let o=e;o<=t;o++){let e=this.dataView.getInt8(o);switch(e){case 0:case 1:case 2:case 3:2===r&&(i.push(3),r=0),0==e?r++:r=0,i.push(e);break;default:r=0,i.push(e)}}i.push(this.dataView.getInt8(this.dataView.byteLength-1));let n=new DataView(new Uint8Array([...new Uint8Array(this.dataView.buffer).slice(0,e),...i]).buffer);this.dataView=n}removePreventionByte(){let e=this.seiPayloadStartIndex,t=this.dataView.byteLength-1,i=[],r=0;for(let o=e;o<=t;o++)switch(this.dataView.getInt8(o)){case 0:r++,i.push(this.dataView.getInt8(o));break;case 3:2!==r&&i.push(this.dataView.getInt8(o)),r=0;break;default:i.push(this.dataView.getInt8(o)),r=0}let n=new DataView(new Uint8Array([...new Uint8Array(this.dataView.buffer).slice(0,e),...i]).buffer);this.dataView=n}get isSEI(){return 6===this.dataView.getUint8(4)}get seiPayloadStartIndex(){let e=6;for(let t=6;t<this.dataView.buffer.byteLength&&(e++,255===this.dataView.getUint8(t));t++);return e}get seiPayloadType(){return this.isSEI?this.dataView.getUint8(5):null}get seiPayload(){if(!this.isSEI)return null;let e=0,t=6;for(let n=6;n<this.dataView.buffer.byteLength;n++){let i=this.dataView.getUint8(n);if(t++,255!==i){e+=i;break}e+=255}let i=new ArrayBuffer(e),r=new DataView(i);for(let n=0;n<i.byteLength;n++,t++)r.setInt8(n,this.dataView.getInt8(t));return r}},VU=class{constructor(e,t){this._singlePC=e,this._log=t,tC(this,"_seiMessageList",[]),tC(this,"_smallSeiMessageList",[]),tC(this,"_seiPayloadType",243),tC(this,"_seiAbortMap",new Map),tC(this,"_nonSeiAbortMap",new Map),tC(this,"onSEIMessage",null)}isRunning(e){return this._seiAbortMap.has(e)}start(e){let t=e.direction===Mw.TRANSCEIVER_DIRECTION_SENDONLY,i=(t?e.sender:e.receiver).createEncodedStreams(),r=i.readable,n=i.writable,o=new TransformStream({transform:t?(t,i)=>this.encodeVideoFrame(t,i,e):(t,i)=>this.decodeVideoFrame(t,i,e)}),s=new AbortController;r.pipeThrough(o).pipeTo(n,s).catch((e=>{this._log.warn(e)})),this._seiAbortMap.set(e,s)}restart(e){this.stop(e),this.start(e)}stop(e){var t;null==(t=this._seiAbortMap.get(e))||t.abort(),this._seiAbortMap.delete(e)}destroy(){this._seiAbortMap.forEach((e=>e.abort())),this._seiAbortMap.clear(),this._nonSeiAbortMap.forEach((e=>e.abort())),this._nonSeiAbortMap.clear(),this.onSEIMessage=null}handleEncodedStreams(){try{this._singlePC.getPeerConnection().getTransceivers().forEach(((e,t)=>{var i,r;if("inactive"!==e.direction&&e.mid)if(t<4)1===t||2===t?this.isRunning(e)||this.start(e):this._nonSeiAbortMap.has(e)||this.pipeSenderOrReceiver(e);else{let n=(t-4)%3==1,o=(t-4)%3==2;(null==(r=null==(i=e.receiver)?void 0:i.track)?void 0:r.kind)===Mw.VIDEO&&(n||o)?this.isRunning(e)||this.start(e):this._nonSeiAbortMap.has(e)||this.pipeSenderOrReceiver(e)}}))}catch(e){this._log.warn(e)}}pipeSenderOrReceiver(e){let t=e.direction===Mw.TRANSCEIVER_DIRECTION_SENDONLY?e.sender:e.receiver,{readable:i,writable:r}=t.createEncodedStreams(),n=new AbortController;this._nonSeiAbortMap.set(e,n),i.pipeTo(r,n).catch((()=>{}))}push(e,t){var i,r;t&&t.seiPayloadType&&(this._seiPayloadType=t.seiPayloadType),this._seiMessageList.push(e),(null==(r=null==(i=this._singlePC.getPeerConnection())?void 0:i.getSenders()[2])?void 0:r.track)&&this._smallSeiMessageList.push(e)}hasSEI(e){let t=new DataView(e);return 1===t.getInt32(0)&&6===t.getInt8(4)}isEmptyFrame(e){return"empty"===e.type||0===e.data.byteLength}getNaluCount(e){let t=0,i=0,r=new DataView(e);for(let n=0;n<e.byteLength;n++)switch(r.getUint8(n)){case 0:t++;break;case 1:(2===t||3===t)&&i++,t=0;break;default:t=0}return i}encodeVideoFrame(e,t,i){try{let t=2===Number(i.mid)?this._smallSeiMessageList:this._seiMessageList;if(this._singlePC.isUsingH264&&t.length>0&&!this.isEmptyFrame(e)){let i=9-this.getNaluCount(e.data);if(i<=0)return;let r=t.splice(0,i).reverse().map(this.encodeSEINalu.bind(this)),n=r.reduce(((e,t)=>e+t.dataView.byteLength),0),o=new ArrayBuffer(n+e.data.byteLength),s=new DataView(o),a=new DataView(e.data),c=0;for(let e=0;e<r.length;e++)for(let t=0;t<r[e].dataView.byteLength;t++)s.setInt8(c++,r[e].dataView.getInt8(t));for(let t=0;t<e.data.byteLength;t++)s.setInt8(c++,a.getInt8(t));e.data=o,this._log.debug("".concat(r.length," sei sent"))}}catch(r){this._log.warn(r)}t.enqueue(e)}decodeVideoFrame(e,t,i){try{if(this._singlePC.isUsingH264&&!this.isEmptyFrame(e)&&this.hasSEI(e.data)){let t=[],r=new DataView(e.data),n=0,o=-1,s=-1;for(let i=0;i<e.data.byteLength;i++){let a=r.getUint8(i);if(0===a)n++;else if(1===a){if(2===n||3===n){let a=i-n;if(-1===o?o=a:-1===s&&(s=a,t.push(new xU(new DataView(r.buffer.slice(o,s)))),o=a,s=-1),6!==r.getUint8(i+1)){e.data=new DataView(r.buffer.slice(a)).buffer;break}}n=0}else n=0}this._log.debug("".concat(t.length," sei received")),ND(this.onSEIMessage)&&t.reverse().forEach((e=>{let t=Number(i.mid);this.onSEIMessage({seiPayloadType:e.seiPayloadType,data:e.seiPayload.buffer,mid:t,streamType:(t-4)%3==2?"auxiliary":"main"})}))}}catch(r){this._log.warn(r)}t.enqueue(e)}encodeSEINalu(e){let t=e.byteLength,i=parseInt(String(t/255),10),r=t%255,n=[];n.push(0,0,0,1,6,this._seiPayloadType);for(let s=0;s<i;s++)n.push(255);n.push(r);let o=new DataView(e);return n.push(...new Uint8Array(o.buffer)),n.push(128),new xU(new DataView(new Uint8Array(n).buffer),!0)}},UU=((yU=UU||{}).TRACK="track",yU.DATA_CHANNEL_MESSAGE="data_channel_msg",yU[yU.CONNECTION_STATE_CHANGED="connection-state-changed"]="CONNECTION_STATE_CHANGED",yU[yU.FIREWALL_RESTRICTION="firewall-restriction"]="FIREWALL_RESTRICTION",yU.RECONNECTED="spc-reconnected",yU.RECONNECT_FAILED="spc-reconnect-failed",yU.ERROR="error",yU.SEI_MESSAGE="sei-message",yU),BU=0,FU=!1,HU=new Set,jU=1,WU=class extends NU.default{constructor(e){let{signalChannel:t,room:i,enableCustomMessage:r}=e;super(),tC(this,"stat",{iceStartTime:0,iceEndTime:0,dtlsStartTime:0,dtlsEndTime:0,peerConnectionStartTime:0,peerConnectionEndTime:0}),tC(this,"currentState","DISCONNECTED"),tC(this,"_room"),tC(this,"_signalChannel"),tC(this,"_peerConnection",null),tC(this,"_datachannel",null),tC(this,"_enableCustomMessage"),tC(this,"_log"),tC(this,"_downlinkMIDMap",new Map),tC(this,"_downlinkMIDUserIDMap",new Map),tC(this,"_reconnectionTimer",-1),tC(this,"reconnectionCount",0),tC(this,"_clientAbility",null),tC(this,"_serverAbility",null),tC(this,"addDownlinkQueue",new Set),tC(this,"removeDownlinkQueue",new Set),tC(this,"_parsedAnswer",null),tC(this,"_updateSDPPromise",null),tC(this,"_waitForPCConnectedPromise"),tC(this,"_waitForPCConnectedPromiseReject",null),tC(this,"_isSDPLogged",!1),tC(this,"seiCodec",null),this._room=i,this._enableCustomMessage=r,this._signalChannel=t,this._log=EO.createLogger({id:"spc".concat(jU++),userId:this._room.userId,sdkAppId:this._room.sdkAppId}),this._room.enableSEI&&tL&&(this._log.info("create sei codec"),this.seiCodec=new VU(this,this._log),this.seiCodec.onSEIMessage=e=>{this.emit("sei-message",{userId:this._downlinkMIDUserIDMap.get(e.mid),data:e.data,seiPayloadType:e.seiPayloadType,streamType:e.streamType})})}get isH264EncodeSupported(){let e=this._room.checkSystemResult.detail.isH264EncodeSupported;return this._serverAbility&&(e=e&&!!this._serverAbility.video.codecs.find((e=>"h264"===e.codec.toLowerCase()))),e}get isVP8EncodeSupported(){let e=this._room.checkSystemResult.detail.isVp8EncodeSupported;return this._serverAbility&&(e=e&&this._serverAbility.useVp8),e}get videoCodec(){var e;return null!=(e=this._serverAbility)&&e.useVp8?"vp8":"h264"}get isUsingH264(){return"h264"===this.videoCodec}get uplinkSSRC(){return this._peerConnection&&this._peerConnection.localDescription?(e=>{let t=VV(e),i={audioSsrc:0,audioRtxSsrc:0,bigVideoSsrc:0,bigVideoRtxSsrc:0,smallVideoSsrc:0,smallVideoRtxSsrc:0,auxVideoSsrc:0,auxVideoRtxSsrc:0};return t.media.forEach(((e,t)=>{var r;if(e.ssrcs&&!DD(e.ssrcs[0].id)){let n=Number(e.ssrcs[0].id),o=Number(null==(r=e.ssrcs.filter((e=>"cname"===e.attribute))[1])?void 0:r.id);switch(t){case 0:i.audioSsrc=n;break;case 1:i.bigVideoSsrc=n,i.bigVideoRtxSsrc=o;break;case 2:i.smallVideoSsrc=n,i.smallVideoRtxSsrc=o;break;case 3:i.auxVideoSsrc=n,i.auxVideoRtxSsrc=o}}})),i})(this._peerConnection.localDescription.sdp):{audioSsrc:0,audioRtxSsrc:0,bigVideoSsrc:0,bigVideoRtxSsrc:0,smallVideoSsrc:0,smallVideoRtxSsrc:0,auxVideoSsrc:0,auxVideoRtxSsrc:0}}get isReconnecting(){return"RECONNECTING"===this.currentState||this._reconnectionTimer>0||this.reconnectionCount>0}get dtlsTransport(){if(!this._peerConnection)return null;let e=this._peerConnection.getSenders();return 0===e.length?null:e[0].transport}initialize(){return rC(this,null,(function*(){try{this._peerConnection=new RTCPeerConnection({encodedInsertableStreams:this._room.enableSEI&&tL,offerExtmapAllowMixed:!0,iceServers:this._room.getIceServers(),iceTransportPolicy:this._room.getIceTransportPolicy(),sdpSemantics:this._room.sdpSemantics,bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",tcpCandidatePolicy:"disable",IceTransportsType:"nohost"}),this._peerConnection.oniceconnectionstatechange=()=>{if(!this._peerConnection)return;let e=this._peerConnection.iceConnectionState;this._log.debug("ice state: ".concat(e)),"checking"===e&&0===this.stat.iceStartTime?this.stat.iceStartTime=Date.now():"connected"===e&&0===this.stat.iceEndTime&&(this.stat.iceEndTime=Date.now())},this._peerConnection.onconnectionstatechange=this.onConnectionStateChange.bind(this),this._peerConnection.ontrack=e=>this.emit("track",e),this._enableCustomMessage&&(this._datachannel=this._peerConnection.createDataChannel("".concat(this._room.userId,"dc")),this._datachannel.binaryType="arraybuffer",this._datachannel.onopen=()=>{this._log.info("datachannel open")},this._datachannel.onclose=()=>{this._log.warn("datachannel close")},this._datachannel.onmessage=e=>{let t=new GU(e.data);this.emit("data_channel_msg",{data:t})},this._datachannel.onerror=e=>{this._log.warn("datachannel error",e)}),this._peerConnection.addTransceiver(Mw.AUDIO,{direction:Mw.TRANSCEIVER_DIRECTION_SENDONLY}),this._peerConnection.addTransceiver(Mw.VIDEO,{direction:Mw.TRANSCEIVER_DIRECTION_SENDONLY}),this._peerConnection.addTransceiver(Mw.VIDEO,{direction:Mw.TRANSCEIVER_DIRECTION_SENDONLY}),this._peerConnection.addTransceiver(Mw.VIDEO,{direction:Mw.TRANSCEIVER_DIRECTION_SENDONLY});let e=yield this._peerConnection.createOffer();return yield this.setOffer(e),this.dtlsTransport&&(this.dtlsTransport.onstatechange=()=>{let{dtlsTransport:e}=this;!e||(this._log.debug("dtls state: ".concat(e.state)),"connecting"===e.state&&0===this.stat.dtlsStartTime?this.stat.dtlsStartTime=Date.now():"connected"===e.state&&0===this.stat.dtlsEndTime&&(this.stat.dtlsEndTime=Date.now()))}),this._clientAbility=((e,t)=>{var i,r;let n=VV(e),o={ice:{ufrag:"",password:""},dtls:{hash:"",fingerprint:"",setup:""},audio:{codecs:[],extensions:[]},video:{codecs:[],extensions:[]},useDataChannel:t};o.ice.ufrag=String(n.media[0].iceUfrag),o.ice.password=n.media[0].icePwd||"",n.fingerprint&&(o.dtls.hash=n.fingerprint.type,o.dtls.fingerprint=n.fingerprint.hash,o.dtls.setup=n.setup||""),n.media[0].fingerprint&&(o.dtls.hash=n.media[0].fingerprint.type,o.dtls.fingerprint=n.media[0].fingerprint.hash),o.dtls.setup=n.media[0].setup||"";let s=n.media[0],a=n.media[1];s.ext&&(o.audio.extensions=s.ext.map((e=>({id:e.value,uri:e.uri})))),a.ext&&(o.video.extensions=a.ext.map((e=>({id:e.value,uri:e.uri}))));let c={codec:s.rtp[0].codec,fmtp:s.fmtp[0].config,payload:s.fmtp[0].payload,rate:s.rtp[0].rate,channel:s.rtp[0].encoding,rtcpFb:[],rtx:0};null==(i=s.rtcpFb)||i.forEach((e=>{let{payload:t,type:i,subtype:r}=e;if(t===c.payload){let e={id:i,params:[]};r&&e.params.push(r),c.rtcpFb.push(e)}})),o.audio.codecs.push(c);for(let l=0;l<a.rtp.length;l++){if(["rtx","red","ulpfec"].includes(a.rtp[l].codec))continue;let e=a.fmtp.filter((e=>e.payload===a.rtp[l].payload))[0];o.video.codecs.push({payload:a.rtp[l].payload,codec:a.rtp[l].codec,fmtp:e?e.config:"",rate:a.rtp[l].rate,rtx:"rtx"===(null==(r=a.rtp[l+1])?void 0:r.codec)?a.rtp[l+1].payload:0,rtcpFb:((null==a?void 0:a.rtcpFb)||[]).filter((e=>e.payload===a.rtp[l].payload)).map((e=>{let{type:t,subtype:i}=e;return{id:t,params:i?[i]:[]}}))})}return o})(e.sdp,this._enableCustomMessage),this._clientAbility}catch(e){throw this._log.error("initialize failed ".concat(e)),e}}))}connect(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return rC(this,null,(function*(){var i;try{if("CONNECTED"===this.currentState)return;let r=zD(),n={type:"answer",sdp:OU({serverAbility:e,clientAbility:this._clientAbility,offerSDP:this._peerConnection.localDescription.sdp,enableCustomMessage:this._enableCustomMessage})};this._serverAbility=e,yield this.setAnswer(n),yield this.waitForPeerConnectionConnected(),t||pP.addSuccessEvent({key:521703,cost:zD()-r}),null==(i=this.seiCodec)||i.handleEncodedStreams()}catch(r){let t=r instanceof fC&&r.code===_C.API_CALL_ABORTED;throw t||this._log.error("connect failed: ".concat(r),e),this.reset(),!t&&!this.isReconnecting&&(pP.addFailedEvent({key:521703,error:r}),this.emitConnectionStateChangedEvent("DISCONNECTED"),this.startReconnection()),r}}))}reconnect(){return rC(this,null,(function*(){if(-1===this._reconnectionTimer){if(!this._signalChannel.isConnected)return this._log.warn("reconnect() wait signal channel is connected"),void this._signalChannel.once(Jx,this.reconnect,this);try{this.reconnectionCount++,this._log.warn("reconnect() trying [".concat(this.reconnectionCount,"]")),this.reset();let e=yield this.initialize(),t=yield this._signalChannel.sendWaitForResponse({command:vV,responseCommand:Zx.REBUILD_PEER_CONNECTION_RES,data:{ability:e},enableLog:!1});if(0!==t.data.code)throw new fC({code:t.data.code,message:t.data.message});yield this.connect(t.data.data.ability,!0),pP.addSuccessEvent({key:521704}),this._log.warn("reconnect() success"),this.stopReconnection(),JN.emit(fO.SPC_RECONNECTED,{room:this._room}),this.emit("spc-reconnected")}catch(e){if(!this.isReconnecting)return;if(null!=e&&e.message.includes("timeout")){let e=kD(this.reconnectionCount);this._log.warn("reconnect() timeout, try again after ".concat(e/1e3,"s")),this._reconnectionTimer=window.setTimeout((()=>{this.clearReconnectionTimer(),this.reconnect()}),e)}else this._log.error("reconnect() failed ".concat(null==e?void 0:e.code," ").concat(e)),pP.addFailedEvent({key:521704,error:e}),this.reconnectionCount>=sN()&&this._log.warn("SDK has tried reconnect for ".concat(sN()," times, but all failed, please check your network")),this.stopReconnection(),this.emitConnectionStateChangedEvent("DISCONNECTED"),this.emit("error")}}else this._log.warn("reconnect() is reconnecting, ignore current reconnection")}))}getPeerConnection(){return this._peerConnection}startReconnection(){return rC(this,null,(function*(){this._log.warn("start reconnect"),this.emitConnectionStateChangedEvent("RECONNECTING"),yield this.reconnect()}))}stopReconnection(){this.isReconnecting&&(this._log.info("stop reconnect"),this.reconnectionCount=0,this.clearReconnectionTimer(),this._signalChannel.off(Jx,this.reconnect,this))}checkPeerConnectionToReconnect(){var e;!this.isReconnecting&&(null==(e=this._peerConnection)?void 0:e.connectionState)===rN.CLOSED&&this.startReconnection()}clearReconnectionTimer(){-1!==this._reconnectionTimer&&(clearTimeout(this._reconnectionTimer),this._reconnectionTimer=-1)}onConnectionStateChange(e){let t=this._peerConnection.iceConnectionState,i=this.getDTLSTransportState();this._log.info("connectionState: ".concat(e.target.connectionState," ICE: ").concat(t," DTLS: ").concat(i)),e.target.connectionState===rN.CONNECTING&&(0===this.stat.peerConnectionStartTime&&(this.stat.peerConnectionStartTime=Date.now()),this.emitConnectionStateChangedEvent("CONNECTING")),(e.target.connectionState===rN.FAILED||e.target.connectionState===rN.CLOSED)&&(this.emitConnectionStateChangedEvent("DISCONNECTED"),this.startReconnection()),(e.target.connectionState===rN.CONNECTED||e.target.connectionState===rN.COMPLETED)&&(0===this.stat.peerConnectionEndTime&&(this.stat.peerConnectionEndTime=Date.now()),JN.emit(fO.SINGLE_CONNECTION_STAT,{room:this._room,stat:{ice:this.stat.iceEndTime-this.stat.iceStartTime,dtls:this.stat.dtlsEndTime-this.stat.dtlsStartTime,peerConnection:this.stat.peerConnectionEndTime-this.stat.peerConnectionStartTime}}),this.logSelectedCandidate(),this.emitConnectionStateChangedEvent("CONNECTED"))}getDTLSTransportState(){if(!this._peerConnection)return iN;let e=null;return KO()&&0!==this._peerConnection.getSenders().length?(e=this._peerConnection.getSenders()[0].transport,GO()&&0!==this._peerConnection.getReceivers().length&&e?e.state:iN):iN}emitConnectionStateChangedEvent(e){e!==this.currentState&&("RECONNECTING"===this.currentState&&"CONNECTING"===e||(this.emit(UU.CONNECTION_STATE_CHANGED,{prevState:this.currentState,state:e}),this.currentState=e))}logSelectedCandidate(){return rC(this,null,(function*(){if(!this._peerConnection)return;let e=yield this._peerConnection.getStats();for(let[t,i]of e)if(UO(i)){let t=e.get(i.localCandidateId),r=e.get(i.remoteCandidateId);t&&(this._log.info("local candidate: ".concat(t.candidateType," ").concat(t.protocol,":").concat(t.ip||t.address,":").concat(t.port," ").concat(t.networkType||""," ").concat("relay"===t.candidateType?"relayProtocol:".concat(t.relayProtocol):"")),t.networkType&&fD(t.networkType)),r&&this._log.info("remote candidate: ".concat(r.candidateType," ").concat(r.protocol,":").concat(r.ip||r.address,":").concat(r.port));break}}))}waitForPeerConnectionConnected(){return this._waitForPCConnectedPromise||(this._waitForPCConnectedPromise=new Promise(((e,t)=>{if("CONNECTED"===this.currentState)return e();this._waitForPCConnectedPromiseReject=t;let i=t=>{"CONNECTED"===t.state&&(clearTimeout(o),n(),e())},r=e=>{let{room:i}=e;i===this._room&&(clearTimeout(o),n(),t(new fC({code:_C.API_CALL_ABORTED,message:GN({key:HN.CONNECTION_ABORTED,data:"leave room"})})))},n=()=>{JN.off(fO.LEAVE_SUCCESS,r,this),this.off(UU.CONNECTION_STATE_CHANGED,i,this)},o=setTimeout((()=>{n();let e=new fC({code:_C.API_CALL_TIMEOUT,message:"connection timeout"});var i;BU+=1,i=this._signalChannel.isConnected,BU>2&&!FU&&0===HU.size&&i&&(this._log.warn("firewall restrition"),FU=!0,this.emit(UU.FIREWALL_RESTRICTION)),t(e)}),TN);JN.on(fO.LEAVE_SUCCESS,r,this),this.on(UU.CONNECTION_STATE_CHANGED,i,this)})),this._waitForPCConnectedPromise=this._waitForPCConnectedPromise.finally((()=>{this._waitForPCConnectedPromise=null,this._waitForPCConnectedPromiseReject=null}))),this._waitForPCConnectedPromise}waitForReconnected(){return this.isReconnecting?new Promise(((e,t)=>{this.once("spc-reconnected",e),this.once("error",t)})):Promise.resolve()}addDownlink(e){return rC(this,null,(function*(){var t;if(this._log.info("addDownlink(".concat(e.userId,") trying")),this.isReconnecting&&(yield this.waitForReconnected()),this._updateSDPPromise&&(yield this._updateSDPPromise),this.updateLocalAndRemoteSDPConfig(e),0===this.addDownlinkQueue.size)try{yield this.updateSDP(),null==(t=this.seiCodec)||t.handleEncodedStreams(),this._log.info("addDownlink(".concat(e.userId,") done"))}catch(i){this._log.info("addDownlink(".concat(e.userId,") failed")),yield this.startReconnection()}}))}updateLocalAndRemoteSDPConfig(e){let{ssrc:t,userId:i,tinyId:r}=e;if(!this._peerConnection)return;this._log.info("updateLocalAndRemoteSDPConfig ".concat(i," ").concat(JSON.stringify(t)));let n,o,s,a=this._peerConnection.getTransceivers().filter((e=>"inactive"===e.direction)).slice(0,3).map((e=>(e.direction=Mw.TRANSCEIVER_DIRECTION_RECVONLY,Number(e.mid))));if(0===a.length&&(this._peerConnection.addTransceiver(Mw.AUDIO,{direction:Mw.TRANSCEIVER_DIRECTION_RECVONLY}),this._peerConnection.addTransceiver(Mw.VIDEO,{direction:Mw.TRANSCEIVER_DIRECTION_RECVONLY}),this._peerConnection.addTransceiver(Mw.VIDEO,{direction:Mw.TRANSCEIVER_DIRECTION_RECVONLY})),this._parsedAnswer||(this._parsedAnswer=VV(this._peerConnection.remoteDescription.sdp)),3===a.length)n=this._parsedAnswer.media.find((e=>Number(e.mid)===Number(a[0]))),o=this._parsedAnswer.media.find((e=>Number(e.mid)===Number(a[1]))),s=this._parsedAnswer.media.find((e=>Number(e.mid)===Number(a[2])));else{n=JSON.parse(JSON.stringify(this._parsedAnswer.media[0]));let e=LU({mid:1,serverAbility:this._serverAbility,clientAbility:this._clientAbility,parsedOffer:VV(this._peerConnection.localDescription.sdp),useAllCodec:!0});o=JSON.parse(JSON.stringify(e)),s=JSON.parse(JSON.stringify(e)),n.mid=this._parsedAnswer.media.length,this._parsedAnswer.media.push(n),o.mid=this._parsedAnswer.media.length,this._parsedAnswer.media.push(o),s.mid=this._parsedAnswer.media.length,this._parsedAnswer.media.push(s)}n.direction=Mw.TRANSCEIVER_DIRECTION_SENDONLY,n.ssrcs=[{id:t.audio,attribute:"cname",value:"".concat(r)},{id:t.audio,attribute:"msid",value:"".concat(r,"-").concat(Mw.MAIN," ").concat(r,"-audio")}],o.direction=Mw.TRANSCEIVER_DIRECTION_SENDONLY,o.ssrcs=[{id:t.video,attribute:"cname",value:"".concat(r)},{id:t.video,attribute:"msid",value:"".concat(r,"-").concat(Mw.MAIN," ").concat(r,"-bigvideo")},{id:t.videoRtx,attribute:"cname",value:"".concat(r)},{id:t.videoRtx,attribute:"msid",value:"".concat(r,"-").concat(Mw.MAIN," ").concat(r,"-bigvideo")}],o.ssrcGroups=[{semantics:"FID",ssrcs:"".concat(t.video," ").concat(t.videoRtx)}],s.direction=Mw.TRANSCEIVER_DIRECTION_SENDONLY;let c="".concat(r,"-aux");s.ssrcs=[{id:t.auxiliary,attribute:"cname",value:c},{id:t.auxiliary,attribute:"msid",value:"".concat(c," ").concat(r,"-aux").concat(Mw.VIDEO)},{id:t.auxiliaryRtx,attribute:"cname",value:"".concat(c," ").concat(r,"-aux").concat(Mw.VIDEO)},{id:t.auxiliaryRtx,attribute:"msid",value:"".concat(c," ").concat(r,"-aux").concat(Mw.VIDEO)}],s.ssrcGroups=[{semantics:"FID",ssrcs:"".concat(t.auxiliary," ").concat(t.auxiliaryRtx)}],this._parsedAnswer.groups&&(this._parsedAnswer.groups[0].mids=this._parsedAnswer.media.map((e=>e.mid)).join(" ")),this._downlinkMIDMap.set(i,[n.mid,o.mid,s.mid]),this._downlinkMIDUserIDMap.set(n.mid,i),this._downlinkMIDUserIDMap.set(o.mid,i),this._downlinkMIDUserIDMap.set(s.mid,i)}removeDownlink(e,t){return rC(this,null,(function*(){if(!this._downlinkMIDMap.has(t)||!this._peerConnection)return;this._log.info("removeDownlink(".concat(t,") trying")),this.isReconnecting&&(yield this.waitForReconnected()),this._updateSDPPromise&&(yield this._updateSDPPromise);let e=this._downlinkMIDMap.get(t),i=!1;this._peerConnection.getTransceivers().forEach((t=>{null!=e&&e.includes(Number(t.mid))&&(i=!0,t.direction="inactive")})),this._parsedAnswer||(this._parsedAnswer=VV(this._peerConnection.remoteDescription.sdp)),this._parsedAnswer.media.forEach((t=>{null!=e&&e.includes(Number(t.mid))&&(i=!0,t.direction="inactive",t.ssrcs=[],t.ssrcGroups=[])})),0===this.removeDownlinkQueue.size&&i&&(yield this.updateSDP()),this._downlinkMIDMap.delete(t),null==e||e.forEach((e=>this._downlinkMIDUserIDMap.delete(e))),this._log.info("removeDownlink(".concat(t,") done"))}))}setBandwidth(e){return rC(this,null,(function*(){if(!this._peerConnection)return;let{audio:t,bigVideo:i,smallVideo:r,auxVideo:n}=e;try{if(ZO()){let e=this._peerConnection.getSenders().slice(0,4);for(let s=0;s<e.length;s++){let o,a=e[s];0===s&&t?o=t:1===s&&i?o=i:2===s&&r?o=r:3===s&&n&&(o=n),o&&(yield this.setSenderMaxBitrate(a,o))}let o=!1;i&&e[1].track&&(o=this.setStartBitrate(1,i)),n&&e[3].track&&(o=this.setStartBitrate(3,n)||o),o&&(yield this.updateSDP())}else yield this.setBandwidthBySDP(e);this._log.info("setBandwidth ".concat(JSON.stringify(e)))}catch(o){this._log.error("failed to set bandwidth".concat(o))}}))}setStartBitrate(e,t){var i,r;return!(null==(i=this._peerConnection)||!i.remoteDescription||(this._parsedAnswer||(this._parsedAnswer=VV(this._peerConnection.remoteDescription.sdp)),null==(r=this._parsedAnswer.media[e])||!r.fmtp[0])||(this._parsedAnswer.media[e].fmtp[0].config+=";x-google-start-bitrate=".concat(t>5e3?5e3:t),0))}setSenderMaxBitrate(e,t){let i=e.getParameters();return(!i.encodings||0===i.encodings.length)&&(i.encodings=[{}]),"unlimited"===t?delete i.encodings[0].maxBitrate:i.encodings[0].maxBitrate=1e3*t,e.setParameters(i)}setBandwidthBySDP(e){let{audio:t,bigVideo:i,smallVideo:r,auxVideo:n}=e;if(!this._peerConnection||!this._peerConnection.localDescription)return;let o=VV(this._peerConnection.localDescription.sdp);this._parsedAnswer||(this._parsedAnswer=VV(this._peerConnection.remoteDescription.sdp));let s=BC?"TIAS":"AS";t&&(o.media[0].bandwidth=[{type:s,limit:BC?1e3*t:t}],this._parsedAnswer.media[0].bandwidth=[{type:s,limit:BC?1e3*t:t}]),i&&(o.media[1].bandwidth=[{type:s,limit:BC?1e3*i:i}],this._parsedAnswer.media[1].bandwidth=[{type:s,limit:BC?1e3*i:i}]),r&&(o.media[2].bandwidth=[{type:s,limit:BC?1e3*r:r}],this._parsedAnswer.media[2].bandwidth=[{type:s,limit:BC?1e3*r:r}]),n&&(o.media[3].bandwidth=[{type:s,limit:BC?1e3*n:n}],this._parsedAnswer.media[3].bandwidth=[{type:s,limit:BC?1e3*n:n}]);let a={type:"offer",sdp:UV(o)};return this.updateSDP({localDescription:a})}setScaleResolutionDownBy(e,t){if(1===t)return;let i=e.getParameters();return(!i.encodings||0===i.encodings.length)&&(i.encodings=[{}]),i.encodings[0].scaleResolutionDownBy=t,e.setParameters(i)}updateSDP(){let{localDescription:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this._parsedAnswer)return Promise.resolve();let t=UV(this._parsedAnswer);return this._updateSDPPromise=new Promise(((i,r)=>rC(this,null,(function*(){var n,o;try{!e&&this._peerConnection&&(this._log.info("creating offer"),e=yield this._peerConnection.createOffer()),e&&(yield this.setOffer(e)),yield this.setAnswer({type:"answer",sdp:t}),this._updateSDPPromise=null,i()}catch(s){this._log.error(s),!this._isSDPLogged&&this._peerConnection&&(this._log.warn("current offer: ".concat(this.filterSDPDirection(null==(n=this._peerConnection.localDescription)?void 0:n.sdp)," \nnext offer: ").concat(this.filterSDPDirection(null==e?void 0:e.sdp))),this._log.warn("current answer: ".concat(this.filterSDPDirection(null==(o=this._peerConnection.remoteDescription)?void 0:o.sdp)," \nnext answer: ").concat(this.filterSDPDirection(t))),this._log.warn("transceivers: ".concat(JSON.stringify(this._peerConnection.getTransceivers().map((e=>{let{mid:t,currentDirection:i,direction:r,stopped:n}=e;return{mid:t,currentDirection:i,direction:r,stopped:n}}))))),this._log.warn("parsedAnswer: ".concat(JSON.stringify(this._parsedAnswer))),this._isSDPLogged=!0),this._updateSDPPromise=null,r(s)}})))),this._updateSDPPromise}filterSDPDirection(){return VV(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").media.map((e=>e.direction))}setOffer(e){return this._log.info("setting offer"),this._peerConnection.setLocalDescription({type:"offer",sdp:MU(e.sdp)})}setAnswer(e){return this._log.info("setting answer"),this._room.enableHWEncoder&&e.sdp&&(e.sdp=e.sdp.replaceAll("42e01f","42001f")),this._peerConnection.setRemoteDescription(e)}sendDataChannelMessage(e){var t;null==(t=this._datachannel)||t.send(e)}reset(){var e;null==(e=this._peerConnection)||e.close(),this._waitForPCConnectedPromise=null,this._parsedAnswer=null}close(){this._log.info("close pc"),this.reset(),this.emitConnectionStateChangedEvent("DISCONNECTED"),this._downlinkMIDMap.clear(),this.stopReconnection(),this.removeAllListeners()}sendSEI(e,t){var i;null==(i=this.seiCodec)||i.push(e,t)}};eC([ZP("reconnect")],WU.prototype,"startReconnection",1),eC([QP()],WU.prototype,"updateSDP",1);var zU=class{constructor(e){tC(this,"tag"),tC(this,"len"),tC(this,"data");let t=new DataView(e);this.tag=t.getUint16(),this.len=t.getUint16(2),this.data=new Uint8Array(e).slice(4,4+this.len).buffer}},GU=class{constructor(e){tC(this,"tinyId"),tC(this,"data");let t=new DataView(e),i=0,r=[];for(;i<t.byteLength;){let n=t.getUint16(i+2),o=new zU(new Uint8Array(e).slice(i,i+2+2+n).buffer);r.push(o),i+=4+n}r.forEach((e=>{1===e.tag?this.tinyId=(new TextDecoder).decode(e.data):2===e.tag&&(this.data=e.data)}))}},KU=new Set;function YU(){let e=Math.floor(4294967296*Math.random());return KU.has(e)?YU():(KU.add(e),e)}var JU=$b(nC()),qU=class extends JU.default{constructor(e){super(),tC(this,"userId"),tC(this,"tinyId"),tC(this,"_sdpSemantics"),tC(this,"_isUplink"),tC(this,"_room"),tC(this,"_log"),tC(this,"_signalChannel"),tC(this,"_currentState","DISCONNECTED"),tC(this,"_prevTime",-1),tC(this,"_enableSEI"),tC(this,"_sei"),this.userId=e.userId,this.tinyId=e.tinyId,this._room=e.room,this._sdpSemantics=e.room.sdpSemantics,this._isUplink=e.isUplink,this._log=EO.createLogger({id:"n",userId:this._room.userId,remoteUserId:this._isUplink?void 0:this.userId,sdkAppId:this._room.sdkAppId,isLocal:this._isUplink}),this._signalChannel=e.signalChannel,this._enableSEI=e.enableSEI,this._enableSEI&&tL&&(this._sei=new VU(this,this._log,this._isUplink))}get _peerConnection(){var e;return(null==(e=this.singlePC)?void 0:e.getPeerConnection())||null}get singlePC(){return this._room.singlePC}close(e){this._log.info("close connection"),this.emit("closed",e),this._sei&&(this._sei.destroy(),this._sei=null)}emitConnectionStateChangedEvent(e){return e!==this._currentState&&(JN.emit(fO.PEER_CONNECTION_STATE_CHANGED,{room:this._room,prevState:this._currentState,state:e,remoteUserId:this._isUplink?void 0:this.userId}),this.emit("connection-state-changed",{prevState:this._currentState,state:e}),this._currentState=e,!0)}getPeerConnection(){return this._peerConnection}getRoom(){return this._room}getUserId(){return this.userId}getTinyId(){return this.tinyId}getCurrentState(){return this._currentState}get isH264(){var e,t;return!(null==(t=null==(e=this._peerConnection)?void 0:e.remoteDescription)||!t.sdp.includes("H264"))}},XU=class extends qU{constructor(e){super(Xb(qb({},e),{isUplink:!0})),tC(this,"localMainAudioTrack",null),tC(this,"localMainVideoTrack",null),tC(this,"localAuxAudioTrack",null),tC(this,"localAuxVideoTrack",null),tC(this,"_isPublishingAux",!1),tC(this,"_publishingLocalAudioTrack"),tC(this,"_publishingLocalVideoTrack"),tC(this,"_mediaSettings",{videoCodec:"",videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioCodec:"opus",audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0,auxVideoWidth:0,auxVideoHeight:0,auxVideoFps:0,auxVideoBps:0}),tC(this,"_audioManager"),this._audioManager=e.audioManager,this.initialize()}get ssrc(){if(!this.singlePC)return{audio:0,video:0,videoRtx:0,small:0,smallRtx:0,auxiliary:0,auxiliaryRtx:0};let{audioSsrc:e,bigVideoSsrc:t,bigVideoRtxSsrc:i,smallVideoSsrc:r,smallVideoRtxSsrc:n,auxVideoSsrc:o,auxVideoRtxSsrc:s}=this.singlePC.uplinkSSRC;return{audio:e||0,video:t||0,videoRtx:i||0,small:r||0,smallRtx:n||0,auxiliary:o||0,auxiliaryRtx:s||0}}get isMainStreamPublished(){return!(!this.localMainAudioTrack&&!this.localMainVideoTrack)}get isAuxStreamPublished(){return!(!this.localAuxVideoTrack&&!this.localAuxAudioTrack)}get publishState(){var e,t,i,r;let n={audio:!1,bigVideo:!1,smallVideo:!1,auxVideo:!1};if(this._peerConnection){let o=this._peerConnection.getSenders();o&&(YO()?(n.audio=!(null==(e=o[0])||!e.track),n.bigVideo=!(null==(t=o[1])||!t.track),n.smallVideo=!(null==(i=o[2])||!i.track),n.auxVideo=!(null==(r=o[3])||!r.track)):o.forEach((e=>{e.track&&(e.track.kind===Mw.AUDIO?n.audio=!0:(n.bigVideo=!0,this._room.videoManager.hasSmall&&(n.smallVideo=!0)))})))}return n}get muteState(){var e,t,i;return{audio:!(null==(e=this.localMainAudioTrack)||!e.muted),bigVideo:!(null==(t=this.localMainVideoTrack)||!t.muted),auxVideo:!(null==(i=this.localAuxVideoTrack)||!i.muted)}}initialize(){this.installEvents()}reset(){this.uninstallEvents(),this.uninstallTrackMuteEvents(this.localMainAudioTrack,this.localMainVideoTrack,this.localAuxVideoTrack)}close(e){super.close(e),this.reset(),this.emitConnectionStateChangedEvent("DISCONNECTED")}installEvents(){var e;this.listeners("connection-state-changed").includes(this.handleConnectionStateChange)||this.on("connection-state-changed",this.handleConnectionStateChange,this),this.listeners("spc-reconnected").includes(this.onSinglePCReconnected)||null==(e=this.singlePC)||e.on("spc-reconnected",this.onSinglePCReconnected,this)}uninstallEvents(){var e;this.off("connection-state-changed",this.handleConnectionStateChange,this),null==(e=this.singlePC)||e.off("spc-reconnected",this.onSinglePCReconnected,this)}emitConnectionStateChangedEvent(e,t){var i,r,n;let o=this._currentState,s=super.emitConnectionStateChangedEvent(e);return s&&o!==e&&(t?t.emit("connection-state-changed",{prevState:o,state:e}):(null==(i=this.localMainVideoTrack)||i.emit("connection-state-changed",{prevState:o,state:e}),null==(r=this.localAuxVideoTrack)||r.emit("connection-state-changed",{prevState:o,state:e}),null==(n=this._publishingLocalVideoTrack)||n.emit("connection-state-changed",{prevState:o,state:e}))),s}publish(e){return rC(this,arguments,(function(e){var t=this;let{localAudioTrack:i,localVideoTrack:r,isAuxiliary:n}=e;return function*(){var e,o,s,a,c,l,d;if(!t.singlePC)return;yield t.singlePC.waitForPeerConnectionConnected();let u,{publishState:h,muteState:p}=t;if(i&&(t._publishingLocalAudioTrack=i,h.audio=!0,p.audio=i.muted),r){if(!t.singlePC.isH264EncodeSupported&&!t.singlePC.isVP8EncodeSupported)throw new fC({code:_C.NOT_SUPPORTED_H264,message:GN({key:HN.NOT_SUPPORTED_H264ENCODE})});MC&&115===Lk()&&r.profile.width*r.profile.height<=230400&&(t._log.warn("fallback video to 480p"),r.setProfile(Lw["480p_2"]),yield r.applyProfile()),t._publishingLocalVideoTrack=r,n?(h.auxVideo=!0,p.auxVideo=r.muted):(h.bigVideo=!0,p.bigVideo=r.muted)}if(t._isPublishingAux=n,r&&!n&&r.small&&(u=t._room.videoManager.smallTrack,h.smallVideo=!0),t._signalChannel.once(Zx.SERVER_PUBLISH_RESULT,(e=>{let o={audio:!(null==i||!i.mediaTrack),bigVideo:!1,smallVideo:!!u,auxVideo:!1};o[n?"auxVideo":"bigVideo"]=!(null==r||!r.mediaTrack);let s=Object.keys(o).find((t=>o[t]!==e.data.data[t]));s&&(t._log.warn("publish state not matched, ".concat(s," local:").concat(o[s]," server:").concat(e.data.data[s]," ").concat(iw())),pP.addCount({key:521e3}))})),yield t._signalChannel.sendWaitForResponse({command:TV,responseCommand:Zx.SPC_PUBLISH_RESULT,data:Xb(qb({},t.singlePC.uplinkSSRC),{state:h,muteState:p})}),yield t.publishByTransceiver({localAudioTrack:i,localVideoTrack:r,smallTrack:u,isAuxiliary:n}),null==(e=t.singlePC.seiCodec)||e.handleEncodedStreams(),t._publishingLocalAudioTrack=null,t._publishingLocalVideoTrack=null,t._isPublishingAux=!1,n)r&&(t.localAuxVideoTrack=r),i&&(t.localAuxAudioTrack=i);else{if(r){t.localMainVideoTrack=r;let{scaleResolutionDownBy:e}=r;e>1&&(t._log.warn("setScaleResolutionDownBy main ".concat(e)),yield t.singlePC.setScaleResolutionDownBy(t._peerConnection.getSenders()[1],e))}i&&(t.localMainAudioTrack=i)}yield t.singlePC.setBandwidth({audio:(null==(o=t.localMainAudioTrack)?void 0:o.profile.bitrate)||(null==(s=t.localAuxAudioTrack)?void 0:s.profile.bitrate),bigVideo:null==(a=t.localMainVideoTrack)?void 0:a.profile.bitrate,smallVideo:null==(l=null==(c=t.localMainVideoTrack)?void 0:c.small)?void 0:l.bitrate,auxVideo:null==(d=t.localAuxVideoTrack)?void 0:d.profile.bitrate}),t.sendMediaSettings(),t.installTrackMuteEvents(i,r)}()}))}publishByTransceiver(e){let{localAudioTrack:t,localVideoTrack:i,smallTrack:r,isAuxiliary:n}=e;if(!JO())return;this._log.info("publish by transceiver");let o=null==i?void 0:i.outMediaTrack,s=null==t?void 0:t.outMediaTrack,a=this._peerConnection.getTransceivers(),c=[],l=[];if(s){let e=a[0].sender.replaceTrack(s);l.push(0),c.push(e)}if(o)if(n){let e=a[3].sender.replaceTrack(o);l.push(3),c.push(e)}else{let e=a[1].sender.replaceTrack(o);l.push(1),c.push(e)}if(r){let e=a[2].sender.replaceTrack(r);l.push(2),c.push(e)}let d=this.setTransceiverDirection(xw.SENDONLY,l);return c.push(d),Promise.all(c)}enableSmall(e){return rC(this,null,(function*(){if(!this.singlePC)return;let t=this._peerConnection.getTransceivers();e?this._room.videoManager.smallTrack&&(yield t[2].sender.replaceTrack(this._room.videoManager.smallTrack),yield this.setTransceiverDirection(xw.SENDONLY,[2])):(yield t[2].sender.replaceTrack(null),yield this.setTransceiverDirection(xw.INACTIVE,[2])),this.updateMediaSettings(),yield this.doPublishChange()}))}installTrackMuteEvents(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];t.forEach((e=>{e&&(null==e||e.on("mute",this.sendMutedFlag,this),null==e||e.on("unmute",this.sendMutedFlag,this))}))}uninstallTrackMuteEvents(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];t.forEach((e=>{e&&(null==e||e.off("mute",this.sendMutedFlag,this),null==e||e.off("unmute",this.sendMutedFlag,this))}))}unpublish(e){return rC(this,arguments,(function(e){var t=this;let{localAudioTrack:i,localVideoTrack:r}=e;return function*(){let e=r&&r===t.localAuxVideoTrack,n=null==r?void 0:r.outMediaTrack,o=t._peerConnection.getSenders(),s=[];i&&(yield o[0].replaceTrack(null),s.push(0),e?t.localAuxAudioTrack=null:t.localMainAudioTrack=null),n&&(e?(yield o[3].replaceTrack(null),t.localAuxVideoTrack=null,t._mediaSettings=Xb(qb({},t._mediaSettings),{auxVideoBps:0,auxVideoFps:0,auxVideoWidth:0,auxVideoHeight:0}),s.push(3)):(yield o[1].replaceTrack(null),yield o[2].replaceTrack(null),t.localMainVideoTrack=null,t._mediaSettings=Xb(qb({},t._mediaSettings),{videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0}),s.push(1,2))),t.isMainStreamPublished||t.isAuxStreamPublished?(yield t.setTransceiverDirection(xw.INACTIVE,s),yield t.doPublishChange(!1)):yield t.doUnpublish(),t.uninstallTrackMuteEvents(i,r),null==r||r.emit("connection-state-changed",{prevState:t._currentState,state:"DISCONNECTED"})}()}))}doPublishChange(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return rC(this,null,(function*(){let t={state:this.publishState,constraintConfig:this._mediaSettings},i=yield this._signalChannel.sendWaitForResponse({command:oV,data:t,responseCommand:Zx.PUBLISH_STATE_CHANGE_RESULT,enableLog:e});this.checkPublishResultCode(i.data.code,i.data.message)}))}doUnpublish(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this._signalChannel.sendWaitForResponse({command:sV,commandDesc:"unpublish",responseCommand:Zx.UNPUBLISH_RESULT,enableLog:e}).catch((e=>{if(e.getCode()===_C.API_CALL_TIMEOUT)return Promise.resolve();throw e}))}updateMediaSettings(){let{detail:{isH264EncodeSupported:e,isVp8EncodeSupported:t}}=this._room.checkSystemResult;e?this._mediaSettings.videoCodec="H264":t&&(this._mediaSettings.videoCodec="VP8");let i=this._publishingLocalAudioTrack||this.localMainAudioTrack||this.localAuxAudioTrack,{localMainVideoTrack:r,localAuxVideoTrack:n}=this;if(this._publishingLocalVideoTrack&&(this._isPublishingAux?n=this._publishingLocalVideoTrack:r=this._publishingLocalVideoTrack),$O){if(i&&i.outMediaTrack){let e=i.outMediaTrack.getSettings();this._mediaSettings.audioChannel=e.channelCount||1,this._mediaSettings.audioBps=1e3*i.profile.bitrate,this._mediaSettings.audioFs=e.sampleRate||0}if(r&&r.outMediaTrack){let e=r.outMediaTrack.getSettings();this._mediaSettings.videoWidth=e.width||0,this._mediaSettings.videoHeight=e.height||0,this._mediaSettings.videoFps=e.frameRate||0,this._mediaSettings.videoBps=1e3*r.profile.bitrate,r.small&&(this._mediaSettings.smallVideoWidth=r.small.width,this._mediaSettings.smallVideoHeight=r.small.height,this._mediaSettings.smallVideoFps=r.small.frameRate,this._mediaSettings.smallVideoBps=1e3*r.small.bitrate)}if(n&&n.outMediaTrack){let e=n.outMediaTrack.getSettings();this._mediaSettings.auxVideoWidth=e.width||0,this._mediaSettings.auxVideoHeight=e.height||0,this._mediaSettings.auxVideoFps=e.frameRate||0,this._mediaSettings.auxVideoBps=1e3*n.profile.bitrate}}else i&&i.outMediaTrack&&(this._mediaSettings.audioChannel=i.profile.channelCount,this._mediaSettings.audioBps=1e3*i.profile.bitrate,this._mediaSettings.audioFs=i.profile.sampleRate),r&&r.outMediaTrack&&(this._mediaSettings.videoWidth=r.profile.width,this._mediaSettings.videoHeight=r.profile.height,this._mediaSettings.videoFps=r.profile.frameRate,this._mediaSettings.videoBps=1e3*r.profile.bitrate);this._log.info("updateMediaSettings: ".concat(JSON.stringify(this._mediaSettings)))}sendMediaSettings(){this.updateMediaSettings(),this._signalChannel.sendWaitForResponse({command:EV,data:this._mediaSettings,responseCommand:Zx.UPDATE_CONSTRAINT_CONFIG_RES}).then((e=>{0!==e.data.code&&this._log.warn(e.data.message)})).catch((()=>{}))}addTrack(e){return rC(this,null,(function*(){var t;if(!this._peerConnection)return;let i=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack;this._log.info("is adding ".concat(e.kind," track to current published local ").concat(i?Mw.AUXILIARY:Mw.MAIN," stream")),null==(t=this._sei)||t.handleEncodedStreams(),YO()&&(yield this.addTrackByTransceiver(e,i))}))}addTrackByTransceiver(e,t){return rC(this,null,(function*(){var i;if(!e.mediaTrack)return;let r=this._peerConnection.getTransceivers();if(e.kind===Mw.AUDIO)yield r[0].sender.replaceTrack(e.outMediaTrack);else{let n=t?3:1;yield r[n].sender.replaceTrack(e.outMediaTrack),1===n&&(null==(i=this.localMainVideoTrack)?void 0:i.small)&&(yield r[2].sender.replaceTrack(this._room.videoManager.smallTrack)),r[n].direction===xw.INACTIVE&&(yield this.setTransceiverDirection(xw.SENDONLY,[n]))}this.updateMediaSettings(),yield this.doPublishChange()}))}removeTrack(e){return rC(this,null,(function*(){if(!this._peerConnection)return;let t=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack;this._log.info("is removing ".concat(e.kind," track from current published local ").concat(t?Mw.AUXILIARY:Mw.MAIN," stream")),YO()&&(yield this.removeTrackByTransceiver(e,t))}))}removeTrackByTransceiver(e,t){return rC(this,null,(function*(){if(!e.mediaTrack)return;let i=this._peerConnection.getTransceivers();if(e.kind===Mw.AUDIO)yield i[0].sender.replaceTrack(null);else{let e=t?3:1;yield i[e].sender.replaceTrack(null),1===e&&this._room.videoManager.hasSmall&&(yield i[2].sender.replaceTrack(null)),yield this.setTransceiverDirection(xw.INACTIVE,[e])}this.updateMediaSettings(),yield this.doPublishChange()}))}setTransceiverDirection(e,t){return rC(this,null,(function*(){if(!BC)return;let i=!1,r=!1;this._log.info("setting transceiver ".concat(t.join(",")," direction to ").concat(e));let n=this._peerConnection.getTransceivers();if(t.forEach((t=>{n[t].direction!==e&&(n[t].direction=e,i=!0)})),i){this._log.info("updating offer");let e=yield this._peerConnection.createOffer();yield this._peerConnection.setLocalDescription(e)}let o=-1,s=this._peerConnection.remoteDescription.sdp.split("\r\n").map((i=>{if(i.match(new RegExp("a=(".concat(xw.INACTIVE,"|").concat(xw.RECVONLY,"|").concat(xw.SENDONLY,")")))&&o++,t.includes(o)){if(e===xw.INACTIVE&&i.includes("a=".concat(xw.RECVONLY)))return r=!0,"a=".concat(e);if(e===xw.SENDONLY&&i.includes("a=".concat(xw.INACTIVE)))return r=!0,"a=".concat(xw.RECVONLY)}return i})).join("\r\n");r&&(this._log.info("updating answer"),yield this._peerConnection.setRemoteDescription({type:"answer",sdp:s}))}))}replaceTrack(e){return rC(this,null,(function*(){var t;let i=null==(t=this._peerConnection)?void 0:t.getSenders(),r=e.outMediaTrack||e.mediaTrack;if(!i||0===i.length||!r||i.find((e=>e.track===r)))return;let n=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack;this._log.info("is replacing ".concat(r.kind," track on ").concat(n?Mw.AUXILIARY:Mw.MAIN," stream")),r.kind===Mw.AUDIO&&i[0]&&(yield i[0].replaceTrack(r)),r.kind===Mw.VIDEO&&(!n&&i[1]&&(yield i[1].replaceTrack(r)),n&&i[3]&&(yield i[3].replaceTrack(r)))}))}setBandwidth(e){return rC(this,arguments,(function(e){var t=this;let{bandwidth:i,type:r,videoType:n}=e;return function*(){if(t.singlePC){let e={};r===Mw.AUDIO?e.audio=i:"big"===n?e.bigVideo=i:"small"===n?e.smallVideo=i:e.auxVideo=i,yield t.singlePC.setBandwidth(e)}}()}))}sendMutedFlag(e){e===this.localAuxAudioTrack||e===this.localAuxVideoTrack||(this._log.info("send muted state: ".concat(JSON.stringify(this.muteState))),this._signalChannel.sendWaitForResponseWithRetry({command:rV,responseCommand:Zx.MUTE_RESULT,data:this.muteState,retries:3}).catch((()=>{})))}handleConnectionStateChange(e){"CONNECTED"===e.state&&(this.localMainVideoTrack||this._publishingLocalVideoTrack&&!this._isPublishingAux)&&JN.emit(fO.SEND_FIRST_VIDEO_FRAME,{room:this._room})}getVideoTrackId(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Mw.VIDEO;if(this._peerConnection){let t=this._peerConnection.getSenders();if(e===Mw.AUXILIARY&&t[3]&&t[3].track)return t[3].track.id;if(e===Mw.VIDEO&&t[1]&&t[1].track)return t[1].track.id}if(this.localMainVideoTrack&&e===Mw.VIDEO){let e=this.localMainVideoTrack.mediaTrack;if(e)return e.id}if(this.localAuxVideoTrack&&e===Mw.AUXILIARY){let e=this.localAuxVideoTrack.mediaTrack;if(e)return e.id}return""}getSSRC(){return this.ssrc}checkPublishResultCode(e,t){if(0!==e)throw e===_N?(this._log.error(jN.NOT_SUPPORTED_H264ENCODE),new fC({code:_C.NOT_SUPPORTED_H264,message:GN({key:HN.NOT_SUPPORTED_H264ENCODE})})):new fC({code:_C.UNKNOWN,message:GN({key:HN.SIGNAL_RESPONSE_FAILED,data:{signalResponse:Zx.PUBLISH_RESULT,code:e,message:t}})})}sendSEI(e,t){var i;null==(i=this._sei)||i.push(e,t)}onSinglePCReconnected(){return rC(this,null,(function*(){this.isMainStreamPublished&&(this._log.warn("republish main stream"),yield this.publish({localAudioTrack:this.localMainAudioTrack,localVideoTrack:this.localMainVideoTrack,isAuxiliary:!1})),this.isAuxStreamPublished&&(this._log.warn("republish aux stream"),yield this.publish({localAudioTrack:this.localAuxAudioTrack,localVideoTrack:this.localAuxVideoTrack,isAuxiliary:!0}))}))}};function QU(e){return Object.keys(e).filter((t=>e[t]))}var ZU=class extends qU{constructor(e){super(Xb(qb({},e),{isUplink:!1})),tC(this,"_flag",0),tC(this,"role","anchor"),tC(this,"remoteAudioTrack"),tC(this,"remoteVideoTrack"),tC(this,"remoteAuxiliaryTrack"),tC(this,"ssrc",{audio:0,video:0,videoRtx:0,auxiliary:0,auxiliaryRtx:0}),this.flag=e.flag,this.remoteAudioTrack=new hM(this._room,this),this.remoteVideoTrack=new pM(this._room,this),this.remoteAuxiliaryTrack=new mM(this._room,this),this.initialize()}get subscribeState(){return{audio:this.remoteAudioTrack.isSubscribed||this.remoteAudioTrack.isSubscribing,video:this.remoteVideoTrack.isBig&&(this.remoteVideoTrack.isSubscribed||this.remoteVideoTrack.isSubscribing),smallVideo:this.remoteVideoTrack.isSmall&&(this.remoteVideoTrack.isSubscribed||this.remoteVideoTrack.isSubscribing),auxiliary:this.remoteAuxiliaryTrack.isSubscribed||this.remoteAuxiliaryTrack.isSubscribing}}get muteState(){return qD(this.flag,this.userId)}get flag(){return this._flag}set flag(e){var t,i,r;e!==this._flag&&(this._flag=e,null==(t=this.remoteAudioTrack)||t.onFlagChanged(),null==(i=this.remoteVideoTrack)||i.onFlagChanged(),null==(r=this.remoteAuxiliaryTrack)||r.onFlagChanged())}get hasMainStream(){return this.muteState.hasAudio||this.muteState.hasVideo||this.muteState.hasSmall}get hasAuxStream(){return this.muteState.hasAuxiliary}get isMainStreamSubscribed(){return(this.subscribeState.audio||this.subscribeState.video||this.subscribeState.smallVideo)&&(this.muteState.hasAudio||this.muteState.hasVideo||this.muteState.hasSmall)}get isAuxStreamSubscribed(){return this.subscribeState.auxiliary&&this.muteState.hasAuxiliary}get isSmallStreamSubscribed(){return this.subscribeState.smallVideo&&this.muteState.hasSmall}get isBigStreamSubscribed(){return this.subscribeState.video&&this.muteState.hasVideo}isStreamUnpublished(e){return e===Mw.MAIN?!this.muteState.hasAudio&&!this.muteState.hasVideo:!this.muteState.hasAuxiliary}initialize(){this.installEvents()}close(e){super.close(e),this.emitConnectionStateChangedEvent("DISCONNECTED"),this.remoteAudioTrack.close(),this.remoteVideoTrack.close(),this.remoteAuxiliaryTrack.close(),this.uninstallEvents(),this.removeDownlink()}installEvents(){!this.singlePC||(this.listeners("track").includes(this.onTrack)||this.singlePC.on("track",this.onTrack,this),this.listeners("spc-reconnected").includes(this.onSinglePCReconnected)||this.singlePC.on("spc-reconnected",this.onSinglePCReconnected,this))}uninstallEvents(){!this.singlePC||(this.singlePC.off("track",this.onTrack,this),this.singlePC.off("spc-reconnected",this.onSinglePCReconnected,this))}emitConnectionStateChangedEvent(e){var t,i;let r=this._currentState,n=super.emitConnectionStateChangedEvent(e);return n&&r!==e&&(null==(t=this.remoteVideoTrack)||t.emit("connection-state-changed",{prevState:r,state:e}),null==(i=this.remoteAuxiliaryTrack)||i.emit("connection-state-changed",{prevState:r,state:e})),n}onTrack(e){let t=e.streams[0],{track:i}=e;if(t.id.split("-")[0]!==this.tinyId)return;let r=t.id.includes("aux")?"auxiliary":"main";this._log.debug("ontrack ".concat(r," ").concat(i.kind));let n=Mw.AUDIO;i.kind===Mw.VIDEO&&(n=r===Mw.MAIN?Mw.VIDEO:Mw.AUXILIARY);let o=this.remoteAudioTrack;n===Mw.VIDEO?o=this.remoteVideoTrack:n===Mw.AUXILIARY&&(o=this.remoteAuxiliaryTrack),o.setInputMediaStreamTrack(i)}isSubscriptionStateNotChanged(e){return JSON.stringify(e)===JSON.stringify(this.subscribeState)}subscribe(e,t){return rC(this,null,(function*(){var i,r,n;try{if(this.isSubscriptionStateNotChanged(e))return;if(this._log.info("subscribe ".concat(t," ").concat(QU(e))),this.hasSSRC){let t="subscribe_change";Object.values(e).find((e=>!0===e))||(t="unsubscribe"),yield this.sendSubscription(t,e)}else yield this.doSubscribe(e);(e.audio&&"ended"===(null==(i=this.remoteAudioTrack.mediaTrack)?void 0:i.readyState)||e.video&&"ended"===(null==(r=this.remoteVideoTrack.mediaTrack)?void 0:r.readyState)||e.auxiliary&&"ended"===(null==(n=this.remoteAuxiliaryTrack.mediaTrack)?void 0:n.readState))&&this.singlePC&&!this.singlePC.isReconnecting&&(this._log.warn("remote track ended start spc reconnect"),this.singlePC.startReconnection())}catch(o){throw this._room.isJoined&&this.isStreamUnpublished(t)?(this._log.warn("".concat(o.message," ").concat(JSON.stringify(this.muteState))),new fC({code:_C.REMOTE_STREAM_NOT_EXIST,message:"remote user ".concat(this.userId," unpublished stream")})):o}}))}unsubscribe(e){return rC(this,arguments,(function(e){var t=this;let{remoteTracks:i,streamType:r}=e;return function*(){var e;if("main"===r&&!t.isMainStreamSubscribed||"auxiliary"===r&&!t.isAuxStreamSubscribed)return void t._log.info("".concat(r," stream already unsubscribed"));let n=qb({},t.subscribeState);i.forEach((e=>{switch(e.mediaType){case 1:n.audio=!1;break;case 4:n.video=!1;break;case 8:n.smallVideo=!1;break;case 2:n.auxiliary=!1}}));let o="subscribe_change";Object.values(n).find((e=>!0===e))||(o="unsubscribe"),t._log.info("".concat("unsubscribe"===o?o:"subscribe"," ").concat(r," [").concat(QU(n),"]")),"unsubscribe"===o&&(null==(e=t.singlePC)||e.removeDownlinkQueue.add(t.tinyId)),yield t.sendSubscription(o,n),"unsubscribe"===o&&(yield t.removeDownlink())}()}))}sendSubscription(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.subscribeState,i={srcTinyId:this.tinyId,srcUserId:this.userId},r=cV,n=Zx.UNSUBSCRIBE_RESULT;return"subscribe_change"===e&&(i={audio:t.audio,bigVideo:t.video,auxVideo:t.auxiliary,smallVideo:t.smallVideo,srcTinyId:this.tinyId},r=lV,n=Zx.SUBSCRIBE_CHANGE_RESULT),this._signalChannel.sendWaitForResponse({command:r,data:i,responseCommand:n,timeout:1e4}).then((t=>{let{data:i}=t;if(0!==i.code){let t=new fC({code:i.code,message:GN({key:HN.ERROR_MESSAGE,data:{type:e,message:i.message}})});throw this._log.error(t),t}}))}getMainStreamVideoTrackId(){return this.remoteVideoTrack&&this.remoteVideoTrack.mediaTrack?this.remoteVideoTrack.mediaTrack.id:""}getAuxStreamVideoTrackId(){return this.remoteAuxiliaryTrack&&this.remoteAuxiliaryTrack.mediaTrack?this.remoteAuxiliaryTrack.mediaTrack.id:""}setDelay(e){let{audioDelay:t,videoDelay:i}=e;this.remoteAudioTrack.stat.end2EndDelay=t,this.remoteVideoTrack.stat.end2EndDelay=i}onSinglePCReconnected(){(this.ssrc.audio||this.ssrc.video||this.ssrc.auxiliary)&&(this._log.warn("resubscribe ".concat(JSON.stringify(this.subscribeState))),this.doSubscribe(this.subscribeState))}get hasSSRC(){return this.ssrc.audio&&this.ssrc.video&&this.ssrc.auxiliary}doSubscribe(){return rC(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.subscribeState,i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return function*(){if(e.singlePC){if(e.singlePC.addDownlinkQueue.add(e.tinyId),yield e.singlePC.waitForPeerConnectionConnected(),i||!e.hasSSRC){let i={audioSsrc:YU(),bigVideoSsrc:YU(),bigVideoRtxSsrc:YU(),auxVideoSsrc:YU(),auxVideoRtxSsrc:YU()},{audioSsrc:n,bigVideoSsrc:o,bigVideoRtxSsrc:s,auxVideoSsrc:a,auxVideoRtxSsrc:c}=i;e.ssrc={audio:n,video:o,videoRtx:s,auxiliary:a,auxiliaryRtx:c},e.singlePC.addDownlinkQueue.delete(e.tinyId),yield e.singlePC.addDownlink({userId:e.userId,tinyId:e.tinyId,ssrc:e.ssrc});try{let r=yield e._signalChannel.sendWaitForResponseWithRetry({command:SV,responseCommand:Zx.SPC_SUBSCRIBE_RESULT,data:{srcUserId:e.userId,srcTinyId:e.tinyId,audio:t.audio,bigVideo:t.video,auxVideo:t.auxiliary,smallVideo:t.smallVideo,customData:!1,ssrc:i},retries:3,retryTimeout:0});if(0!==r.data.code)throw new fC({code:r.data.code,message:r.data.message})}catch(r){throw yield e.removeDownlink(),r}return}e.singlePC.addDownlinkQueue.delete(e.tinyId),yield e.singlePC.addDownlink({userId:e.userId,tinyId:e.tinyId,ssrc:e.ssrc})}}()}))}removeDownlink(){return rC(this,null,(function*(){!this.singlePC||(this.ssrc={audio:0,video:0,videoRtx:0,auxiliary:0,auxiliaryRtx:0},this.singlePC.removeDownlinkQueue.delete(this.tinyId),yield this.singlePC.removeDownlink(this.tinyId,this.userId))}))}};eC([JP((e=>function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];return new Promise(((t,r)=>{let n=e=>{this.off("closed",n),r(new fC({code:_C.API_CALL_ABORTED,message:GN({key:HN.CONNECTION_ABORTED,data:e})}))};this.on("closed",n),e.apply(this,i).then(t,r).finally((()=>{this.off("closed",n)}))}))}))],ZU.prototype,"subscribe",1);var $U,eB=ZU,{isString:tB,isPlainObject:iB,isUndefined:rB,getNetworkType:nB,getTerminalType:oB,isEmpty:sB}=yC,aB=class extends wU{constructor(e){super(e),this._heartbeat=-1,this._lastHeartBeatTime=-1,this._joinTimeout=-1,this._firstPublishedList=null,this._joinReject=null,this._isRelayChanged=!1,this._signalChannel=null,this.uplinkConnection=null,this.singlePC=null,this.enableSPC=qO,this._changeBigSmallRecords=new Map,this._networkQuality=null,this._turnServers=[],this._syncUserListInterval=-1,this._smallStreamConfig={bitrate:100,frameRate:15,height:120,width:160},this.enableSEI=!1,this._enableAudioVolumeEvaluation=!1,this._audioVolumeIntervalId=0,this._enableMultiAuxStream=!1,this._pureAudioPushMode=!1,this.enableHWEncoder=!1,this._stats=new YV(this,this._log),this.userManager=new OM(this.userId,this._log),this._version=ow,this.sdpSemantics=mN,rB(e.sdpSemantics)?TO.isUnifiedPlanDefault()&&(this.sdpSemantics=pN):this.sdpSemantics=e.sdpSemantics,this._log.info("sdpSemantics: ".concat(this.sdpSemantics,", netType: ").concat(nB())),e.iceTransportPolicy&&(this._iceTransportPolicy=e.iceTransportPolicy),this._enableMultiAuxStream=!rB(e.enableMultiAuxStream)&&e.enableMultiAuxStream,this.enableSEI=e.enableSEI,!rB(e.enableSPC)&&qO&&(this.enableSPC=e.enableSPC),this.enableHWEncoder=e.enableHWEncoder||!1,this._initBusinessInfo(e)}get isMainStreamPublished(){var e;return!(null==(e=this.uplinkConnection)||!e.isMainStreamPublished)}get isMainAudioPublished(){var e;return!(null==(e=this.uplinkConnection)||!e.localMainAudioTrack)}get isAuxStreamPublished(){var e;return!(null==(e=this.uplinkConnection)||!e.isAuxStreamPublished)}get hasAuxStream(){return[...this.remotePublishedUserMap.values()].findIndex((e=>e.muteState.hasAuxiliary))>=0}get userMap(){return this.userManager.userMap}get remotePublishedUserMap(){return this.userManager.remotePublishedUserMap}get tinyIdToUserIdMap(){return new Map([...this.remotePublishedUserMap.values()].map((e=>[e.tinyId,e.userId])))}join(e,t,i){return rC(this,null,(function*(){return this.userManager.mySelfId=this.userId,this.userManager.on("1",(e=>{this.emit("peer-join",e)})),this.userManager.on("2",(e=>{this.closeDownLinkConnection(e,"remote user exitRoom"),this.emit("peer-leave",e)})),this.userManager.on("3",this.createDownlinkConnection,this),this.userManager.on("5",this.closeDownLinkConnection,this),this.userManager.on("6",(e=>{var t=((e,t)=>{var i={};for(var r in e)zb.call(e,r)&&t.indexOf(r)<0&&(i[r]=e[r]);if(null!=e&&jb)for(var r of jb(e))t.indexOf(r)<0&&Gb.call(e,r)&&(i[r]=e[r]);return i})(e,[]);JN.emit(fO.REMOTE_PUBLISH_STATE_CHANGED,qb({room:this},t)),this.emit("remote-publish-state-changed",qb({},t))})),this._joinOptions=e,new Promise(((t,i)=>rC(this,null,(function*(){this._joinReject=i;try{this.checkDestroy();let[,i]=yield Promise.all([this.initialize(),this.initSinglePC()]);yield this.doJoin(e,i),t(),this._firstPublishedList&&this.onPublishedUserList({data:{userList:this._firstPublishedList}})}catch(r){i(r)}this._joinReject=null}))))}))}initSinglePC(){return rC(this,null,(function*(){if(this.enableSPC&&!this.singlePC){this.singlePC=new WU({signalChannel:this._signalChannel,room:this,enableCustomMessage:!1}),this.singlePC.on("sei-message",(e=>this.emit("sei-message",e))),this.singlePC.once("error",(()=>this.fallbackToMPC()));try{return yield this.singlePC.initialize()}catch(e){this.singlePC.close(),this.singlePC=null}}}))}doJoin(e,t){return new Promise(((i,r)=>rC(this,null,(function*(){var n,o,s;e.privateMapKey&&(this.privateMapKey=e.privateMapKey),this._signalChannel.once(Kx,(e=>{this.clearJoinTimeout(),JN.emit(fO.JOIN_SIGNAL_CONNECTION_END,{room:this,error:e}),r(e)})),PD(null==(o=null==(n=this.scheduleResult)?void 0:n.config)?void 0:o.singlePC)&&qO&&(this.enableSPC=this.scheduleResult.config.singlePC),this.keyPointManager.setConnectionType(this.singlePC?1:2);let a={roomId:String(e.roomId||e.strRoomId),useStringRoomId:this.useStringRoomId,privateMapKey:this.privateMapKey,trtcRole:e.role,trtcScene:"live"===this.scene?2:1,sdpSemantics:this.sdpSemantics,version:this._version,ua:navigator&&navigator.userAgent||"",terminalType:oB(),netType:gD(),bussinessInfo:this._businessInfo,ability:t,sdkType:this._sdkType,userSig:this.userSig};this._log.debug("join room signal data: ".concat(JSON.stringify(a)));let c=5e3;(null==(s=this.scheduleResult.config)?void 0:s.enterRoomTimeout)&&this.scheduleResult.config.enterRoomTimeout>=1&&(c=1e3*this.scheduleResult.config.enterRoomTimeout),this._joinTimeout=window.setTimeout((()=>{r(new fC({code:_C.JOIN_ROOM_FAILED,message:GN({key:HN.JOIN_ROOM_TIMEOUT})}))}),c),JN.emit(fO.JOIN_SEND_CMD,{room:this}),this._signalChannel.send(this.singlePC?yV:eV,a),this._signalChannel.once(Zx.JOIN_ROOM_RESULT,(e=>{this.clearJoinTimeout();let{code:t,message:n,data:o,tinyId:s}=e.data;JN.emit(fO.JOIN_RECEIVED_CMD_RES,{room:this,code:t}),0===t?(this._log.info("Join room success, start heartbeat"),s&&(this.tinyId=s),this.startHeartbeat(),this.syncUserList(),this.startSyncUserListInterval(),this._firstPublishedList=o.publishers,this.singlePC&&this.singlePC.connect(o.ability).catch((()=>{})),i()):(this._log.error("Join room failed result: ".concat(t," error: ").concat(n)),r(new fC({code:_C.JOIN_ROOM_FAILED,extraCode:t,message:GN({key:HN.JOIN_ROOM_FAILED,data:{error:n,code:t}})})))}))}))))}reJoin(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return rC(this,null,(function*(){if(this.isJoined)try{this._log.warn("reJoin pending: ".concat(this._joinOptions.roomId));let t,i=[];if(this.singlePC&&(this.singlePC.close(),this.singlePC=null,i.push(this.initSinglePC().then((e=>(t=e,e))))),this._signalChannel&&(this._signalChannel.race=e,this._signalChannel.close(),i.push(this._signalChannel.connect())),yield Promise.all(i),yield this.doJoin(Xb(qb({},this._joinOptions),{role:"anchor"===this.role?20:21,privateMapKey:this.privateMapKey}),t),this._log.warn("reJoin success"),XN.logSuccessEvent({userId:this.userId,eventType:lN.REJOIN}),this.singlePC){let e=t=>{var i;"CONNECTED"===t.state&&(null==(i=this.singlePC)||i.off(UU.CONNECTION_STATE_CHANGED,e),this.uplinkConnection instanceof XU&&this.uplinkConnection.onSinglePCReconnected(),this.remotePublishedUserMap.forEach((e=>{e.installEvents(),e.onSinglePCReconnected()})))};this.singlePC.on(UU.CONNECTION_STATE_CHANGED,e),this.checkConnectionsToReconnect(),this.uplinkConnection instanceof KV&&!this.uplinkConnection.getIsReconnecting()&&this.uplinkConnection.startReconnection()}}catch(t){this._log.warn("reJoin fail ".concat(t)),this.reset(),XN.logFailedEvent({userId:this.userId,eventType:lN.REJOIN,error:t}),this.emit("error",new fC({code:_C.JOIN_ROOM_FAILED,message:GN({key:HN.REJOIN_ROOM_FAILED,data:{roomId:this._joinOptions.roomId}})}))}else this._log.warn("reJoin abort")}))}initialize(){return rC(this,null,(function*(){let{mainUrl:e,backupUrl:t}=this.getSignalChannelUrl(),i=this._signalChannel||(n=this.userId,[...kV.values()].find((e=>e.room.userId===n&&!e.room.isJoined))||null),r=!!(i&&i.isConnected&&i.keepAlive);var n;return this._log.info("".concat(r?"reuse":"setup"," signal channel")),r?(i.url=e,i.backupUrl=t,i.room=this,this._signalChannel=i):this._signalChannel=new wV({sdkAppId:this.sdkAppId,userId:this.userId,userSig:this.userSig,url:e,backupUrl:t,race:this.enableSPC&&!this.proxy_ws,room:this}),this._networkQuality||(this._networkQuality=new XV({signalChannel:this._signalChannel,room:this}),this._networkQuality.on(XV.EVENT_NETWORK_QUALITY,(e=>{this.emit("network-quality",e)}))),YL(this,this._signalChannel).add(Yx,(e=>{JN.emit(fO.SIGNAL_CONNECTION_STATE_CHANGED,qb({room:this},e)),this.emit("signal-connection-state-changed",e)})).add(qx,(e=>{this.reset(),this.emit("error",e)})).add(Zx.PEER_JOIN,(e=>{let{srcTinyId:t,userId:i,role:r}=e.data.data;this.userManager.addUser({userId:i,tinyId:t,role:r})})).add(Zx.PEER_LEAVE,(e=>{let{userId:t,reason:i=0}=e.data.data;this.userManager.deleteUser(t,i)})).add(Zx.UPDATE_REMOTE_MUTE_STAT,(e=>{this._lastHeartBeatTime>0&&Date.now()-this._lastHeartBeatTime>=1e4&&this.doHeartbeat(),this.onPublishedUserList(e.data)})).add(Zx.CLIENT_BANNED,(e=>{let t=e.data.data,{reason:i}=t;if(XN.uploadEvent({log:"stat-banned:".concat(i),userId:this.userId}),"user_time_out"===i)return this._log.warn("".concat(i," last heart beat time: ").concat(this._lastHeartBeatTime," interval: ").concat(Date.now()-this._lastHeartBeatTime,", visibility: ").concat(document.visibilityState)),void this.reJoin();this._log["kick"===i?"error":"info"]("user was banned because of [".concat(i,"]")),this.reset(),this.emit("banned",{reason:i})})),this._signalChannel.once(Gx,(e=>{this.tinyId=e.signalInfo.tinyId,JN.emit(fO.JOIN_SIGNAL_CONNECTION_END,{room:this})})),JN.emit(fO.JOIN_SIGNAL_CONNECTION_START,{room:this}),yield this._signalChannel.connect(),r&&JN.emit(fO.JOIN_SIGNAL_CONNECTION_END,{room:this}),r}))}setSignalChannel(e){this._signalChannel=e,e||JL(this)}leave(){return rC(this,null,(function*(){var e;try{yield this.doHeartbeat()}catch(t){}this._log.info("leave() => leaving room"),JN.emit(fO.LEAVE_SEND_CMD,{room:this}),null==(e=this._signalChannel)||e.send(tV)}))}clearNetworkQuality(){this._networkQuality&&(this._networkQuality.stop(),this._networkQuality=null)}closeConnections(){this.remotePublishedUserMap.forEach((e=>{this.closeDownLinkConnection(e.userId,"you exitRoom")}))}clearJoinTimeout(){clearTimeout(this._joinTimeout),this._joinTimeout=-1}startHeartbeat(){-1===this._heartbeat&&(this._heartbeat=SL.run(LN,this.doHeartbeat.bind(this),{delay:2e3}))}stopHeartbeat(){-1!==this._heartbeat&&(this._log.info("stopHeartbeat"),SL.clearTask(this._heartbeat),this._heartbeat=-1,this._lastHeartBeatTime=-1)}doHeartbeat(){return rC(this,null,(function*(){var e;let t=this.badCaseDetector.getMonitorFreeze(),i=yield this._stats.getStatsReport({uplinkConnection:this.uplinkConnection,downlinkConnections:this.remotePublishedUserMap,freezeMap:t});if(this.badCaseDetector.resetMonitor(),null==(e=this._signalChannel)||!e.isConnected)return;let r=this._signalChannel.isConnected?function(e){if(kM.has(e)){let t=kM.get(e).map((e=>({uint32_event_id:e.eventId,uint64_date:e.timestamp,str_userid:e.remoteUserId,str_event_json:e.eventDesc})));return kM.delete(e),t}return[]}(this.userId):[],n=qb({str_sdk_version:nw,uint64_datetime:(new Date).getTime(),msg_user_info:{str_identifier:this.userId,uint64_tinyid:this.tinyId},msg_device_info:{uint32_terminal_type:15,str_device_name:navigator.platform,str_os_version:"",uint32_net_type:gD()},msg_event_msg:r,str_acc_ip:this.getSignalInfo().relayIp,str_client_ip:this.getSignalInfo().clientIp},i);JN.emit(fO.HEARTBEAT_REPORT,{room:this,report:n}),this._signalChannel.send(iV,n),this.emit("heartbeat-report",Xb(qb({},n),{bytes_sent:this._stats.totalBytesSent+this._signalChannel.bytesSent,bytes_received:this._stats.totalBytesReceived+this._signalChannel.bytesReceived}));let o=Date.now();this._lastHeartBeatTime>0&&o-this._lastHeartBeatTime>1e4&&this._log.warn("heartbeat took ".concat(o-this._lastHeartBeatTime)),this._signalChannel.isConnected&&(this._lastHeartBeatTime=o),!this._isRelayChanged&&this.isRelayMaybeFailed()&&(this.reJoin(),this._isRelayChanged=!0)}))}onPublishedUserList(e){if(!this.isJoined)return;let t=e.data.userList.map((e=>{let{userId:t,srcTinyId:i,flag:r}=e,n=this.remotePublishedUserMap.get(t);return n&&this.checkSubscribeBigSmallVideo(n),{userId:t,tinyId:i,flag:r}}));JN.emit(fO.RECEIVED_PUBLISHED_USER_LIST,{room:this,publishedUserList:t}),this.userManager.setRemotePublishedUserList(t)}closeUplink(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"you unpublished";this.uplinkConnection&&(this.localTracks.size>0&&this.uplinkConnection.doUnpublish(),this.uplinkConnection.close(e),this.uplinkConnection=null),this.localTracks.forEach((e=>e.unpublish())),this.localTracks.clear()}createDownlinkConnection(e){let{userId:t,tinyId:i,flag:r}=e,n=new(this.singlePC?eB:jV)({userId:t,tinyId:i,room:this,signalChannel:this._signalChannel,enableSEI:this.enableSEI,flag:r});this.userManager.addRemotePublishedUser(n),this.installDownlinkEvents(n,t),this.emit("remote-published",n)}closeDownLinkConnection(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"remote user unpublished",i=this.remotePublishedUserMap.get(e);i&&(i.close(t),this.emit("remote-unpublished",i))}installDownlinkEvents(e,t){e.on("error",(e=>{let i=e.getCode();i!==_C.ICE_TRANSPORT_ERROR&&(i===_C.DOWNLINK_RECONNECTION_FAILED&&this.closeDownLinkConnection(t),this.emit("error",e))})),e.on("connection-state-changed",(t=>{this.emit("media-connection-state-changed",Xb(qb({},t),{userId:e.userId}))})),e.on("firewall-restriction",(()=>{this.emit("firewall-restriction")}))}startSyncUserListInterval(){-1===this._syncUserListInterval&&(this._syncUserListInterval=SL.run(LN,this.syncUserList.bind(this)))}stopSyncUserListInterval(){SL.clearTask(this._syncUserListInterval),this._syncUserListInterval=-1}syncUserList(){return this.getUserList().then((e=>{this.userManager.setUserList(e)})).catch((e=>{this._log.debug("sync user list failed: ".concat(e))}))}getUserList(){var e;return null!=(e=this._signalChannel)&&e.isConnected?this._signalChannel.sendWaitForResponse({command:fV,responseCommand:Zx.USER_LIST_RES,enableLog:!1,timeout:2e3}).then((e=>{let{data:t}=e,{code:i,message:r}=t;if(0===i)return(t.data&&t.data.userList||[]).map((e=>{let{userId:t,srcTinyId:i,role:r}=e;return{userId:t,tinyId:i,role:r}}));throw GN({key:HN.SIGNAL_RESPONSE_FAILED,data:{signalResponse:Zx.USER_LIST_RES,code:i,message:r}})})):Promise.reject("not connected")}getAllConnections(){let e=[...this.remotePublishedUserMap.values()];return this.uplinkConnection&&e.push(this.uplinkConnection),e}isRelayMaybeFailed(){if(this._signalChannel&&!this._signalChannel.isOnline||!PV)return!1;if(this.singlePC)return this.singlePC.reconnectionCount>6;let e=this.getAllConnections();if(0===e.length)return!1;for(let t=0;t<e.length;t++)if(e[t].getReconnectionCount()<6)return!1;return!0}checkConnectionsToReconnect(){var e;this.singlePC?(null==(e=this.singlePC.getPeerConnection())?void 0:e.connectionState)===rN.CLOSED&&!this.singlePC.isReconnecting&&(this._log.warn("spc pc is closed but not reconnect"),this.singlePC.startReconnection()):this.getAllConnections().forEach((e=>{if(e instanceof MV&&!e.getIsReconnecting()){let t=e.getPeerConnection();t&&t.connectionState===rN.CLOSED&&(this._log.warn("[".concat(e.getUserId(),"] pc is closed but not reconnect")),e.startReconnection())}}))}fallbackToMPC(){return rC(this,null,(function*(){var e;if(this._log.warn("fallback to multi pc"),XN.uploadEvent({log:"stat-fallback",userId:this.userId}),this.enableSPC=!1,null==(e=this.singlePC)||e.close(),this.singlePC=null,yield this.reJoin(!1),this.uplinkConnection){let e=this.uplinkConnection;this.uplinkConnection=new KV({userId:this.userId,tinyId:this.tinyId,room:this,signalChannel:this._signalChannel,enableSEI:this.enableSEI,audioManager:this.audioManager}),e.isMainStreamPublished&&(yield this.uplinkConnection.publish({localAudioTrack:e.localMainAudioTrack,localVideoTrack:e.localMainVideoTrack,isAuxiliary:!1})),e.isAuxStreamPublished&&(yield this.uplinkConnection.publish({localAudioTrack:e.localAuxAudioTrack,localVideoTrack:e.localAuxVideoTrack,isAuxiliary:!0})),e.close()}this.remotePublishedUserMap.forEach((e=>{let t=new jV({userId:e.userId,tinyId:e.tinyId,room:this,signalChannel:this._signalChannel,enableSEI:this.enableSEI,flag:e.flag,remoteAudioTrack:e.remoteAudioTrack,remoteVideoTrack:e.remoteVideoTrack,remoteAuxiliaryTrack:e.remoteAuxiliaryTrack});this.installDownlinkEvents(t,e.userId),this.remotePublishedUserMap.set(e.userId,t),e.isMainStreamSubscribed&&t.subscribe(e.subscribeState,"main"),e.isAuxStreamSubscribed&&t.subscribe(e.subscribeState,"auxiliary")}))}))}destroy(){this.isDestroyed||(this._signalChannel&&(this._log.info("destroying SignalChannel"),this._signalChannel.close(),this._signalChannel=null),super.destroy(),this._joinReject&&(this._joinReject(new fC({code:_C.INVALID_OPERATION,message:GN({key:HN.CLIENT_DESTROYED,data:{funName:"join"}})})),this.clearJoinTimeout(),this.reset()),this.removeAllListeners())}switchRole(e){return rC(this,null,(function*(){this.role!==e&&("audience"===e&&this.uplinkConnection&&this.closeUplink("you switch role to audience"),yield this.doSwitchRole(e))}))}doSwitchRole(e){let t={command:gV,data:{role:"anchor"===e?20:21,privateMapKey:this.privateMapKey},responseCommand:Zx.SWITCH_ROLE_RES,retries:1};return this._log.info("switchRole signal data: ".concat(JSON.stringify(t.data))),this._signalChannel.sendWaitForResponseWithRetry(t).then((t=>{let{code:i,message:r}=t.data;if(0!==i)throw new fC({code:_C.SWITCH_ROLE_FAILED,message:GN({key:HN.SWITCH_ROLE_FAILED,data:{message:r,code:i}})});this.role=e})).catch((e=>{throw e instanceof fC&&e.getCode()===_C.API_CALL_TIMEOUT&&(e=new fC({code:_C.SWITCH_ROLE_FAILED,message:GN({key:HN.SWITCH_ROLE_TIMEOUT})})),this._log.error(e),e}))}publish(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return rC(this,null,(function*(){let e={},i={};t.forEach((t=>{t instanceof iM&&(t instanceof cM?i.audio=t:e.audio=t),t instanceof rM&&(t instanceof aM&&2===t.mediaType?i.video=t:e.video=t)}));let r=sB(e),n=sB(i);(!r||!n)&&!this.uplinkConnection&&(this.singlePC?this.uplinkConnection=new XU({userId:this.userId,tinyId:this.tinyId,room:this,signalChannel:this._signalChannel,enableSEI:this.enableSEI,audioManager:this.audioManager}):this.uplinkConnection=new KV({userId:this.userId,tinyId:this.tinyId,room:this,signalChannel:this._signalChannel,enableSEI:this.enableSEI,audioManager:this.audioManager}),this.uplinkConnection.on("connection-state-changed",(e=>{this.emit("media-connection-state-changed",Xb(qb({},e),{userId:this.userId}))})),this.uplinkConnection.on("firewall-restriction",(()=>{this.emit("firewall-restriction")})),this.uplinkConnection.on("error",(e=>{let t=e.getCode();t!==_C.ICE_TRANSPORT_ERROR&&(t===_C.UPLINK_RECONNECTION_FAILED&&this.closeUplink(),this.emit("error",e))})));let o=t.map((e=>e.kind)).join(",");r||(this._log.info("publish() => main ".concat(o)),yield this.uplinkConnection.publish({localAudioTrack:e.audio,localVideoTrack:e.video,isAuxiliary:!1}),this._log.info("main is published")),n||(this._log.info("publish() => aux ".concat(o)),yield this.uplinkConnection.publish({localAudioTrack:i.audio,localVideoTrack:i.video,isAuxiliary:!0}),this._log.info("aux is published"))}))}unpublish(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return rC(this,null,(function*(){if("live"===this.scene&&"anchor"!==this.role||!this.isMainStreamPublished&&!this.isAuxStreamPublished||!this.uplinkConnection)return;let e={},i={};t.forEach((t=>{!t.mediaTrack||!t.isPublished||(t instanceof iM&&(t instanceof cM?i.audio=t:e.audio=t),t instanceof rM&&(t instanceof aM&&2===t.mediaType?i.video=t:e.video=t))}));try{let r=t.map((e=>e.kind)).join(",");sB(e)||(this._log.info("unpublish() => main ".concat(r)),yield this.uplinkConnection.unpublish({localAudioTrack:e.audio,localVideoTrack:e.video})),sB(i)||(this._log.info("unpublish() => aux ".concat(r)),yield this.uplinkConnection.unpublish({localAudioTrack:i.audio,localVideoTrack:i.video}))}catch(r){}0===this.localTracks.size&&this.closeUplink("you unpublished")}))}addTrack(e){if(!this.uplinkConnection||!e.mediaTrack)return Promise.resolve();let t=this.uplinkConnection.addTrack(e);return e.publish(this,t),t}removeTrack(e){return this.uplinkConnection&&e.mediaTrack?this.uplinkConnection.removeTrack(e).then((t=>(e.unpublish(),t))):Promise.resolve()}replaceTrack(e){return this.uplinkConnection&&e.mediaTrack&&QO()?this.uplinkConnection.replaceTrack(e).then((t=>{JN.emit(fO.LOCAL_TRACK_REPLACED,{track:e})})):Promise.resolve()}setBandWidth(e){return rC(this,null,(function*(){!this.uplinkConnection||(yield this.uplinkConnection.setBandwidth(e),yield this.uplinkConnection.sendMediaSettings())}))}enableSmall(e){return rC(this,null,(function*(){if(!this.uplinkConnection||!this.uplinkConnection.localMainVideoTrack)return Promise.resolve();e&&this.uplinkConnection.localMainVideoTrack.small&&(yield this.setBandWidth({type:Mw.VIDEO,videoType:Mw.SMALL,bandwidth:this.uplinkConnection.localMainVideoTrack.small.bitrate})),yield this.uplinkConnection.enableSmall(e)}))}subscribe(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return rC(this,null,(function*(){if(0===(t=t.filter((e=>!e.isSubscribed))).length)return;let{userId:e}=t[0],i=this.remotePublishedUserMap.get(e);if(!i)return;let r=t.find((e=>2===e.mediaType))?"auxiliary":"main";try{let n=qb({},i.subscribeState);t.forEach((e=>{switch(e.mediaType){case 1:n.audio=!0;break;case 4:n.video=!0;break;case 2:n.auxiliary=!0}}));let o=this._changeBigSmallRecords.get(e);o&&o.options.smallVideo&&i.muteState.hasSmall&&n.video&&(n.video=!1,n.smallVideo=!0),JN.emit(fO.SUBSCRIBE_START,{room:this,streamType:r,remotePublishedUser:i,subscribeState:n}),this._log.info("subscribe() => ".concat(e," ").concat(r," [").concat(BV(n),"] prev: [").concat(BV(i.subscribeState),"]")),yield i.subscribe(n,r);for(let e of t)e.mediaTrack||(yield e.waitHasMediaTrack());i.remoteVideoTrack.setMediaType(n.smallVideo?8:4),JN.emit(fO.SUBSCRIBE_SUCCESS,{room:this,streamType:r,remotePublishedUser:i})}catch(n){let t=n instanceof fC?n.getCode():_C.UNKNOWN,i=n;throw n instanceof fC?t===_C.REMOTE_STREAM_NOT_EXIST&&(i=new fC({code:_C.API_CALL_ABORTED,message:GN({key:HN.API_CALL_ABORTED,data:{message:n.message,userId:e,streamType:r}})}),this._log.warn(i)):(i=new fC({code:t,message:GN({key:HN.SUBSCRIBE_FAILED,data:{message:n.message,userId:e,streamType:r}})}),this._log.error(i)),i}}))}unsubscribe(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return rC(this,null,(function*(){let{userId:e}=t[0],i=this.remotePublishedUserMap.get(e);if(!i)return;let r=t.find((e=>2===e.mediaType))?"auxiliary":"main";this._log.info("unsubscribe() => ".concat(e," ").concat(r));try{yield i.unsubscribe({remoteTracks:t,streamType:r})}catch(n){this._log.warn("unsubscribe() => failed ".concat(n))}t.forEach((e=>{e.unsubscribe(),8===e.mediaType&&e.setMediaType(4)})),JN.emit(fO.UNSUBSCRIBE_SUCCESS,{room:this,streamType:r,remotePublishedUser:i})}))}setEncodedDataProcessingListener(e){throw new Error("Method not implemented.")}enableAudioVolumeEvaluation(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,t=arguments.length>1?arguments[1]:void 0;if(e<=0)return this._enableAudioVolumeEvaluation=!1,void SL.clearTask(this._audioVolumeIntervalId);e=Math.floor(Math.max(e,100)),JN.emit(fO.AUDIO_LEVEL_INTERVAL,{interval:e}),this._audioVolumeIntervalId&&SL.clearTask(this._audioVolumeIntervalId),this._enableAudioVolumeEvaluation=!0,this._audioVolumeIntervalId=SL.run(PN,(()=>{var e;let t=[];null==(e=this.remotePublishedUserMap)||e.forEach((e=>{if(e.muteState.hasAudio){let i=Math.floor(100*e.remoteAudioTrack.getAudioLevel());t.push({userId:e.userId,volume:i})}})),this.emit("audio-volume",t)}),{fps:1e3/e,backgroundTask:t})}getLocalAudioStats(){return rC(this,null,(function*(){let e={};if(e[this.userId]={bytesSent:0,packetsSent:0},this.uplinkConnection){let t=yield this._stats.getSenderStats(this.uplinkConnection);e[this.userId]={bytesSent:t.audio.bytesSent,packetsSent:t.audio.packetsSent}}return e}))}getLocalVideoStats(){return rC(this,null,(function*(){let e={};if(e[this.userId]={bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0},this.uplinkConnection){let{video:{bytesSent:t,packetsSent:i,framesEncoded:r,framesSent:n,frameWidth:o,frameHeight:s}}=yield this._stats.getSenderStats(this.uplinkConnection);e[this.userId]={bytesSent:t,packetsSent:i,framesEncoded:r,framesSent:n,frameWidth:o,frameHeight:s}}return e}))}getTransportStats(){return rC(this,null,(function*(){let e={rtt:0,downlinksRTT:{}};if(this.uplinkConnection){let t=yield this._stats.getSenderStats(this.uplinkConnection);e.rtt=t.rtt}for(let[,t]of this.remotePublishedUserMap){let i=yield this._stats.getReceiverStats(t);e.downlinksRTT[i.userId]=i.rtt}return e}))}getRemoteVideoStats(e){return rC(this,null,(function*(){let t={};for(let[i,r]of this.remotePublishedUserMap)"main"===e&&r.muteState.hasVideo&&(t[i]=r.remoteVideoTrack.stat),"auxiliary"===e&&r.muteState.hasAuxiliary&&(t[i]=r.remoteAuxiliaryTrack.stat);return t}))}getRemoteAudioStats(){return rC(this,null,(function*(){let e={};for(let[t,i]of this.remotePublishedUserMap)i.muteState.hasAudio&&(e[t]=i.remoteAudioTrack.stat);return e}))}setTurnServer(e,t){this._log.info("set turn server: ".concat(JSON.stringify(e)," ").concat(t||""));let i=[];Array.isArray(e)?e.forEach((e=>i.push(yC.getTurnServer(e)))):yC.isPlainObject(e)&&i.push(yC.getTurnServer(e)),this._turnServers=i,t&&(this._iceTransportPolicy=t)}sendStartMixTranscode(e){return this._signalChannel.sendWaitForResponse({command:mV,data:e,timeout:5e3,responseCommand:Zx.START_MIX_TRANSCODE_RES,commandDesc:"startMixTranscode"})}sendStopMixTranscode(e){return this._signalChannel.sendWaitForResponse({command:_V,data:e,timeout:5e3,responseCommand:Zx.STOP_MIX_TRANSCODE_RES,commandDesc:"stopMixTranscode"})}sendStartPublishCDN(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return this._signalChannel.sendWaitForResponse({command:t?dV:hV,data:e,timeout:5e3,responseCommand:t?Zx.START_PUBLISH_TENCENT_CDN_RES:Zx.START_PUBLISH_GIVEN_CDN_RES,commandDesc:"startPublishCDN"})}sendStopPublishCDN(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return this._signalChannel.sendWaitForResponse({command:t?uV:pV,data:e,timeout:5e3,responseCommand:t?Zx.STOP_PUBLISH_TENCENT_CDN_RES:Zx.STOP_PUBLISH_GIVEN_CDN_RES,commandDesc:"stopPublishCDN"})}sendAbilityStatus(e){var t;null==(t=this._signalChannel)||t.sendWaitForResponse({command:IV,data:e,timeout:5e3,responseCommand:Zx.ABILITY_STATUS_REPORT_RESULT,commandDesc:"ability status report"}).catch((e=>{}))}getIceServers(){return 0===this._turnServers.length&&this.scheduleResult.iceServers?this.scheduleResult.iceServers:this._turnServers}getIceTransportPolicy(){return this._iceTransportPolicy||this.scheduleResult.iceTransportPolicy||"all"}getLogger(){return this._log}enableAIVoice(){throw new Error("Method not implemented.")}getSignalChannelUrl(){let e={mainUrl:"",backupUrl:""},t=yC.getEnv();return t?(e.mainUrl="wss://".concat(t,".rtc.qq.com"),e.backupUrl=e.mainUrl):this.proxy_ws?(e.mainUrl=this.proxy_ws,e.backupUrl=e.mainUrl):Array.isArray(this.scheduleResult.domains)&&this.scheduleResult.domains.length>0&&(e.mainUrl="wss://".concat(this.scheduleResult.domains[0]),e.backupUrl=e.mainUrl,this.scheduleResult.domains[1]&&(e.backupUrl="wss://".concat(this.scheduleResult.domains[1]))),e}getSignalInfo(){var e;return(null==(e=this._signalChannel)?void 0:e.getSignalInfo())||{clientIp:"",relayIp:""}}reset(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.stopSyncUserListInterval(),this.stopHeartbeat(),this.closeConnections(),this.clearNetworkQuality(),this.closeUplink("you exitRoom"),this._signalChannel&&(e&&this._signalChannel.keepAlive&&this._signalChannel.isConnected?this._signalChannel.stopKeepAliveIn(3600):this._signalChannel.close(),this.setSignalChannel(null)),this._stats.reset(),this.userManager.clear(),this.userManager.removeAllListeners(),this.singlePC&&(this.singlePC.close(),this.singlePC=null),this.scheduleResult={domains:null,iceServers:null,iceTransportPolicy:null,trtcAutoConf:null}}checkSubscribeBigSmallVideo(e){return rC(this,null,(function*(){let{subscribeState:t,userId:i,muteState:{hasSmall:r,hasVideo:n}}=e;if(!r&&!n||!t.video&&!t.smallVideo)return;let o=this._changeBigSmallRecords.get(i);if(!o||o.isSubscribing||o.reSubscribeCount<=0)return;let{options:s,reSubscribeCount:a}=o;if(s.video&&t.video||s.smallVideo&&t.smallVideo&&r)return;let c={audio:e.remoteAudioTrack.isSubscribed||e.remoteAudioTrack.isSubscribing,auxiliary:e.remoteAuxiliaryTrack.isSubscribed||e.remoteAuxiliaryTrack.isSubscribing,video:s.video,smallVideo:s.smallVideo};try{if(!r&&c.smallVideo&&(c.video=!0,c.smallVideo=!1),c.smallVideo===t.smallVideo&&c.video===t.video)return;o.isSubscribing=!0,o.reSubscribeCount=a-1,yield e.subscribe(c,"main"),e.remoteVideoTrack.setMediaType(c.smallVideo?8:4),this._log.info("change [".concat(i,"] to ").concat(c.smallVideo?"small":"big"," video successfully. count ").concat(DN-o.reSubscribeCount,".")),o.isSubscribing=!1,o.reSubscribeCount=DN}catch(l){this._log.info("change [".concat(i,"] to ").concat(c.smallVideo?"small":"big"," video failed. count ").concat(DN-o.reSubscribeCount,".")),o.isSubscribing=!1,0===o.reSubscribeCount&&this._changeBigSmallRecords.delete(i)}}))}changeType(e,t){let i={options:{video:!e,smallVideo:e},isSubscribing:!1,reSubscribeCount:DN};this._changeBigSmallRecords.set(t.userId,i),this._log.info("set [".concat(t.userId,"] video prefer type: ").concat(e?"small":"big"))}get smallStreamConfig(){return this._smallStreamConfig}_initBusinessInfo(e){this._businessInfo=e.businessInfo;let t={};if(tB(e.businessInfo)&&(t=JSON.parse(e.businessInfo)),!rB(e.pureAudioPushMode)){if(!Number.isInteger(Number(e.pureAudioPushMode)))throw new fC({code:_C.INVALID_PARAMETER,message:GN({key:HN.INVALID_PURE_AUDIO})});this._pureAudioPushMode=e.pureAudioPushMode,t.Str_uc_params||(t.Str_uc_params={}),t.Str_uc_params.pure_audio_push_mod=this._pureAudioPushMode}if(!rB(e.userDefineRecordId)){let i=/^[A-Za-z0-9_-]{1,64}$/gi;if(null===e.userDefineRecordId.match(i))throw new fC({code:_C.INVALID_PARAMETER,message:GN({key:HN.INVALID_USER_DEFINE_RECORDID})});t.Str_uc_params||(t.Str_uc_params={}),t.Str_uc_params.userdefine_record_id=e.userDefineRecordId}if(!rB(e.userDefinePushArgs)){if(!(tB(e.userDefinePushArgs)&&String(e.userDefinePushArgs)&&String(e.userDefinePushArgs).length<=256))throw new fC({code:_C.INVALID_PARAMETER,message:GN({key:HN.INVALID_USER_DEFINE_PUSH_ARGS})});t.Str_uc_params||(t.Str_uc_params={}),t.Str_uc_params.userdefine_push_args=e.userDefinePushArgs}sB(t)||(this._businessInfo=JSON.stringify(t))}sendSEI(e,t){this.singlePC&&this.singlePC.sendSEI(e,t)}};return eC([Fx(["left",Wx.INIT],"joined"),bV({settings:{retries:1,timeout:0},onError(e,t,i){this._isUsingCachedSchedule&&!this.isDestroyed?(this._log.warn("is using cached schedule, retry join"),$N(!0),this.reset(),t()):this._signalChannel&&this._signalChannel.isConnected&&this._signalChannel.keepAlive?(this._log.warn("is using keepAlive ws, retry join"),this._signalChannel.close(),this.reset(),t()):(this.reset(),this._log.error(e),i(e))}}),JP((e=>{let t=new Ox;return function(i,r,n){return rC(this,null,(function*(){let o=String(i.roomId||i.strRoomId);if(this.userId=i.userId,this.sdkAppId=i.sdkAppId,this.userSig=i.userSig,this._log.setSdkAppId(this.sdkAppId),this._log.setUserId(this.userId),this.scene=r,i.privateMapKey=i.privateMapKey||"",this.isJoined)throw new fC({code:_C.INVALID_OPERATION,message:GN({key:HN.INVALID_JOIN})});if(this.checkDestroy(),t.isJoined({userId:this.userId,roomId:o,sdkAppId:this.sdkAppId,room:this}))throw new fC({code:_C.INVALID_OPERATION,message:GN({key:HN.REPEAT_JOIN,data:this.userId})});t.add({room:this,roomId:o}),this.role=21===i.role?"audience":"anchor",this._log.info("Join() => joining room: ".concat(o," useStringRoomId: ").concat(this.useStringRoomId," scene: ").concat(this.scene," role: ").concat(this.role)),JN.emit(fO.JOIN_START,{room:this,roomId:o,params:i}),this.checkSystemResult=yield TO.checkSystemRequirementsInternal(),this.checkDestroy();let s=yC.getEnv();s||(s=Rw.QCLOUD,this.proxy_ws&&(this.proxy_ws.startsWith(Vw.OLD_CLOUD_LADDER)?s=Rw.OLD_CLOUD_LADDER:this.proxy_ws.startsWith(Vw.WEBRTC)&&(s=Rw.WEBRTC))),XN.setConfig({env:s,sdkAppId:String(this.sdkAppId),userId:this.userId,roomId:o}),Lx.call(this);let{isH264EncodeSupported:a,isVp8EncodeSupported:c}=this.checkSystemResult.detail;if(!TO.isWebRTCSupported()||!a&&!c)throw new fC({code:_C.NOT_SUPPORTED,message:GN({key:HN.NOT_SUPPORTED_WEBRTC})});try{!this.proxy_ws&&!this.proxy_wt&&!this.scheduleResult.domains&&!yC.getEnv()&&(yield this.schedule(o,n));let t=yield e.call(this,i,r,n);return this.roomId=o,this._joinedTimestamp=yC.performanceNow(),JN.emit(fO.JOIN_SUCCESS,{room:this}),XN.uploadEvent({log:"stat-conv-".concat(Number(Jk),"-").concat(location.hostname),userId:this.userId}),t}catch(l){throw t.delete({room:this,roomId:o}),JN.emit(fO.JOIN_FAILED,{room:this,error:l}),l}}))}}))],aB.prototype,"join",1),eC([Fx("joined","left",{ignoreError:!0,success(){this.reset(!0)}}),JP((e=>function(){return rC(this,null,(function*(){JN.emit(fO.LEAVE_START,{room:this}),yield e.call(this),JN.emit(fO.LEAVE_SUCCESS,{room:this,roomId:this.roomId})}))})),ZP("leave room"),CV({fnName:"publish",validateArgs:!1}),CV({fnName:"unsubscribe",validateArgs:!1})],aB.prototype,"leave",1),eC([QP(),JP((e=>function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];return rC(this,null,(function*(){if("live"===this.scene&&"anchor"!==this.role||!(i=i.filter((e=>e.outMediaTrack&&"capture"===e.state))).length)return;JN.emit("61",{room:this});let t=e.apply(this,i);return i.forEach((e=>e.publish(this,t))),t}))})),bV({settings:{retries:sN,timeout:e=>kD(e)},onError(e,t,i){var r;null!=(r=e.message)&&r.includes("timeout")?(this._log.warn("publish timeout"),t()):(this._log.error("publish failed: ".concat(e)),i(e),JN.emit(fO.PUBLISH_FAILED,{room:this}))}})],aB.prototype,"publish",1),eC([CV({fnName:"publish"}),($U="api-call",function(e,t,i){let r=i.value;return i.value=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];let n=qP.get(this);if(n){let e=n.filter(((e,i)=>{if(0===i)return!0;let r=!0;return e.args.forEach((e=>{t.find((t=>t===e))||(r=!1)})),!r||(e.reject(new fC({code:_C.API_CALL_ABORTED,message:$U})),!1)}));qP.set(this,e)}return r.apply(this,t)},i}),QP(),JP((e=>function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];let n=e.apply(this,i);return i.forEach((e=>e.unpublish())),n}))],aB.prototype,"unpublish",1),eC([$P((function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return t[0].userId})),JP((e=>function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];let n=e.apply(this,i);return i.forEach((e=>!e.isSubscribed&&e.subscribe(n))),n})),bV({settings:{retries:sN,timeout:e=>kD(e)},onError(e,t,i,r){e.message.includes("timeout")?(this._log.warn("subscribe timeout"),t()):(this._log.error("subscribe failed: ".concat(e)),i(e),JN.emit(fO.SUBSCRIBE_FAILED,{room:this,remoteTracks:r}))}})],aB.prototype,"subscribe",1),eC([CV({fnName:"subscribe",callback(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.singlePC||t.forEach((e=>{let t=this.remotePublishedUserMap.get(e.userId);t&&!t.isMainStreamSubscribed&&!t.isAuxStreamSubscribed&&t.close("you unsubscribed")}))}}),$P((function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return t[0].userId}))],aB.prototype,"unsubscribe",1),Dx.create=Dx._create.bind(Dx,aB),Dx}();var n=r.exports;const o=t.getDefaultExportFromCjs(n);var s="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a=[],c=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,d=!1;function u(){d=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)a[t]=e[t],c[e.charCodeAt(t)]=t;c["-".charCodeAt(0)]=62,c["_".charCodeAt(0)]=63}function h(e,t,i){for(var r,n,o=[],s=t;s<i;s+=3)r=(e[s]<<16)+(e[s+1]<<8)+e[s+2],o.push(a[(n=r)>>18&63]+a[n>>12&63]+a[n>>6&63]+a[63&n]);return o.join("")}function p(e){var t;d||u();for(var i=e.length,r=i%3,n="",o=[],s=0,c=i-r;s<c;s+=16383)o.push(h(e,s,s+16383>c?c:s+16383));return 1===r?(t=e[i-1],n+=a[t>>2],n+=a[t<<4&63],n+="=="):2===r&&(t=(e[i-2]<<8)+e[i-1],n+=a[t>>10],n+=a[t>>4&63],n+=a[t<<2&63],n+="="),o.push(n),o.join("")}function m(e,t,i,r,n){var o,s,a=8*n-r-1,c=(1<<a)-1,l=c>>1,d=-7,u=i?n-1:0,h=i?-1:1,p=e[t+u];for(u+=h,o=p&(1<<-d)-1,p>>=-d,d+=a;d>0;o=256*o+e[t+u],u+=h,d-=8);for(s=o&(1<<-d)-1,o>>=-d,d+=r;d>0;s=256*s+e[t+u],u+=h,d-=8);if(0===o)o=1-l;else{if(o===c)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),o-=l}return(p?-1:1)*s*Math.pow(2,o-r)}function _(e,t,i,r,n,o){var s,a,c,l=8*o-n-1,d=(1<<l)-1,u=d>>1,h=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,m=r?1:-1,_=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=d):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+u>=1?h/c:h*Math.pow(2,1-u))*c>=2&&(s++,c/=2),s+u>=d?(a=0,s=d):s+u>=1?(a=(t*c-1)*Math.pow(2,n),s+=u):(a=t*Math.pow(2,u-1)*Math.pow(2,n),s=0));n>=8;e[i+p]=255&a,p+=m,a/=256,n-=8);for(s=s<<n|a,l+=n;l>0;e[i+p]=255&s,p+=m,s/=256,l-=8);e[i+p-m]|=128*_}var f={}.toString,g=Array.isArray||function(e){return"[object Array]"==f.call(e)};function E(){return y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function v(e,t){if(E()<t)throw new RangeError("Invalid typed array length");return y.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=y.prototype:(null===e&&(e=new y(t)),e.length=t),e}function y(e,t,i){if(!(y.TYPED_ARRAY_SUPPORT||this instanceof y))return new y(e,t,i);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return I(this,e)}return T(this,e,t,i)}function T(e,t,i,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,i,r){if(t.byteLength,i<0||t.byteLength<i)throw new RangeError("'offset' is out of bounds");if(t.byteLength<i+(r||0))throw new RangeError("'length' is out of bounds");return t=void 0===i&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,i):new Uint8Array(t,i,r),y.TYPED_ARRAY_SUPPORT?(e=t).__proto__=y.prototype:e=A(e,t),e}(e,t,i,r):"string"==typeof t?function(e,t,i){if("string"==typeof i&&""!==i||(i="utf8"),!y.isEncoding(i))throw new TypeError('"encoding" must be a valid string encoding');var r=0|C(t,i),n=(e=v(e,r)).write(t,i);return n!==r&&(e=e.slice(0,n)),e}(e,t,i):function(e,t){if(b(t)){var i=0|R(t.length);return 0===(e=v(e,i)).length||t.copy(e,0,0,i),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?v(e,0):A(e,t);if("Buffer"===t.type&&g(t.data))return A(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function S(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function I(e,t){if(S(t),e=v(e,t<0?0:0|R(t)),!y.TYPED_ARRAY_SUPPORT)for(var i=0;i<t;++i)e[i]=0;return e}function A(e,t){var i=t.length<0?0:0|R(t.length);e=v(e,i);for(var r=0;r<i;r+=1)e[r]=255&t[r];return e}function R(e){if(e>=E())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+E().toString(16)+" bytes");return 0|e}function b(e){return!(null==e||!e._isBuffer)}function C(e,t){if(b(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var i=e.length;if(0===i)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return ee(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return te(e).length;default:if(r)return ee(e).length;t=(""+t).toLowerCase(),r=!0}}function k(e,t,i){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return W(this,t,i);case"utf8":case"utf-8":return B(this,t,i);case"ascii":return H(this,t,i);case"latin1":case"binary":return j(this,t,i);case"base64":return U(this,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return z(this,t,i);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function w(e,t,i){var r=e[t];e[t]=e[i],e[i]=r}function N(e,t,i,r,n){if(0===e.length)return-1;if("string"==typeof i?(r=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=n?0:e.length-1),i<0&&(i=e.length+i),i>=e.length){if(n)return-1;i=e.length-1}else if(i<0){if(!n)return-1;i=0}if("string"==typeof t&&(t=y.from(t,r)),b(t))return 0===t.length?-1:D(e,t,i,r,n);if("number"==typeof t)return t&=255,y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(e,t,i):Uint8Array.prototype.lastIndexOf.call(e,t,i):D(e,[t],i,r,n);throw new TypeError("val must be string, number or Buffer")}function D(e,t,i,r,n){var o,s=1,a=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,i/=2}function l(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(n){var d=-1;for(o=i;o<a;o++)if(l(e,o)===l(t,-1===d?0:o-d)){if(-1===d&&(d=o),o-d+1===c)return d*s}else-1!==d&&(o-=o-d),d=-1}else for(i+c>a&&(i=a-c),o=i;o>=0;o--){for(var u=!0,h=0;h<c;h++)if(l(e,o+h)!==l(t,h)){u=!1;break}if(u)return o}return-1}function O(e,t,i,r){i=Number(i)||0;var n=e.length-i;r?(r=Number(r))>n&&(r=n):r=n;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;s<r;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[i+s]=a}return s}function L(e,t,i,r){return ie(ee(t,e.length-i),e,i,r)}function P(e,t,i,r){return ie(function(e){for(var t=[],i=0;i<e.length;++i)t.push(255&e.charCodeAt(i));return t}(t),e,i,r)}function M(e,t,i,r){return P(e,t,i,r)}function x(e,t,i,r){return ie(te(t),e,i,r)}function V(e,t,i,r){return ie(function(e,t){for(var i,r,n,o=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(i=e.charCodeAt(s))>>8,n=i%256,o.push(n),o.push(r);return o}(t,e.length-i),e,i,r)}function U(e,t,i){return 0===t&&i===e.length?p(e):p(e.slice(t,i))}function B(e,t,i){i=Math.min(e.length,i);for(var r=[],n=t;n<i;){var o,s,a,c,l=e[n],d=null,u=l>239?4:l>223?3:l>191?2:1;if(n+u<=i)switch(u){case 1:l<128&&(d=l);break;case 2:128==(192&(o=e[n+1]))&&(c=(31&l)<<6|63&o)>127&&(d=c);break;case 3:o=e[n+1],s=e[n+2],128==(192&o)&&128==(192&s)&&(c=(15&l)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(d=c);break;case 4:o=e[n+1],s=e[n+2],a=e[n+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&l)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(d=c)}null===d?(d=65533,u=1):d>65535&&(d-=65536,r.push(d>>>10&1023|55296),d=56320|1023&d),r.push(d),n+=u}return function(e){var t=e.length;if(t<=F)return String.fromCharCode.apply(String,e);for(var i="",r=0;r<t;)i+=String.fromCharCode.apply(String,e.slice(r,r+=F));return i}(r)}y.TYPED_ARRAY_SUPPORT=void 0===s.TYPED_ARRAY_SUPPORT||s.TYPED_ARRAY_SUPPORT,y.poolSize=8192,y._augment=function(e){return e.__proto__=y.prototype,e},y.from=function(e,t,i){return T(null,e,t,i)},y.TYPED_ARRAY_SUPPORT&&(y.prototype.__proto__=Uint8Array.prototype,y.__proto__=Uint8Array),y.alloc=function(e,t,i){return r=null,o=t,s=i,S(n=e),n<=0?v(r,n):void 0!==o?"string"==typeof s?v(r,n).fill(o,s):v(r,n).fill(o):v(r,n);var r,n,o,s},y.allocUnsafe=function(e){return I(null,e)},y.allocUnsafeSlow=function(e){return I(null,e)},y.isBuffer=re,y.compare=function(e,t){if(!b(e)||!b(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var i=e.length,r=t.length,n=0,o=Math.min(i,r);n<o;++n)if(e[n]!==t[n]){i=e[n],r=t[n];break}return i<r?-1:r<i?1:0},y.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},y.concat=function(e,t){if(!g(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return y.alloc(0);var i;if(void 0===t)for(t=0,i=0;i<e.length;++i)t+=e[i].length;var r=y.allocUnsafe(t),n=0;for(i=0;i<e.length;++i){var o=e[i];if(!b(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(r,n),n+=o.length}return r},y.byteLength=C,y.prototype._isBuffer=!0,y.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)w(this,t,t+1);return this},y.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)w(this,t,t+3),w(this,t+1,t+2);return this},y.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)w(this,t,t+7),w(this,t+1,t+6),w(this,t+2,t+5),w(this,t+3,t+4);return this},y.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?B(this,0,e):k.apply(this,arguments)},y.prototype.equals=function(e){if(!b(e))throw new TypeError("Argument must be a Buffer");return this===e||0===y.compare(this,e)},y.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},y.prototype.compare=function(e,t,i,r,n){if(!b(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===i&&(i=e?e.length:0),void 0===r&&(r=0),void 0===n&&(n=this.length),t<0||i>e.length||r<0||n>this.length)throw new RangeError("out of range index");if(r>=n&&t>=i)return 0;if(r>=n)return-1;if(t>=i)return 1;if(this===e)return 0;for(var o=(n>>>=0)-(r>>>=0),s=(i>>>=0)-(t>>>=0),a=Math.min(o,s),c=this.slice(r,n),l=e.slice(t,i),d=0;d<a;++d)if(c[d]!==l[d]){o=c[d],s=l[d];break}return o<s?-1:s<o?1:0},y.prototype.includes=function(e,t,i){return-1!==this.indexOf(e,t,i)},y.prototype.indexOf=function(e,t,i){return N(this,e,t,i,!0)},y.prototype.lastIndexOf=function(e,t,i){return N(this,e,t,i,!1)},y.prototype.write=function(e,t,i,r){if(void 0===t)r="utf8",i=this.length,t=0;else if(void 0===i&&"string"==typeof t)r=t,i=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(i)?(i|=0,void 0===r&&(r="utf8")):(r=i,i=void 0)}var n=this.length-t;if((void 0===i||i>n)&&(i=n),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return O(this,e,t,i);case"utf8":case"utf-8":return L(this,e,t,i);case"ascii":return P(this,e,t,i);case"latin1":case"binary":return M(this,e,t,i);case"base64":return x(this,e,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return V(this,e,t,i);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var F=4096;function H(e,t,i){var r="";i=Math.min(e.length,i);for(var n=t;n<i;++n)r+=String.fromCharCode(127&e[n]);return r}function j(e,t,i){var r="";i=Math.min(e.length,i);for(var n=t;n<i;++n)r+=String.fromCharCode(e[n]);return r}function W(e,t,i){var r=e.length;(!t||t<0)&&(t=0),(!i||i<0||i>r)&&(i=r);for(var n="",o=t;o<i;++o)n+=$(e[o]);return n}function z(e,t,i){for(var r=e.slice(t,i),n="",o=0;o<r.length;o+=2)n+=String.fromCharCode(r[o]+256*r[o+1]);return n}function G(e,t,i){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>i)throw new RangeError("Trying to access beyond buffer length")}function K(e,t,i,r,n,o){if(!b(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||t<o)throw new RangeError('"value" argument is out of bounds');if(i+r>e.length)throw new RangeError("Index out of range")}function Y(e,t,i,r){t<0&&(t=65535+t+1);for(var n=0,o=Math.min(e.length-i,2);n<o;++n)e[i+n]=(t&255<<8*(r?n:1-n))>>>8*(r?n:1-n)}function J(e,t,i,r){t<0&&(t=4294967295+t+1);for(var n=0,o=Math.min(e.length-i,4);n<o;++n)e[i+n]=t>>>8*(r?n:3-n)&255}function q(e,t,i,r,n,o){if(i+r>e.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function X(e,t,i,r,n){return n||q(e,0,i,4),_(e,t,i,r,23,4),i+4}function Q(e,t,i,r,n){return n||q(e,0,i,8),_(e,t,i,r,52,8),i+8}y.prototype.slice=function(e,t){var i,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),y.TYPED_ARRAY_SUPPORT)(i=this.subarray(e,t)).__proto__=y.prototype;else{var n=t-e;i=new y(n,void 0);for(var o=0;o<n;++o)i[o]=this[o+e]}return i},y.prototype.readUIntLE=function(e,t,i){e|=0,t|=0,i||G(e,t,this.length);for(var r=this[e],n=1,o=0;++o<t&&(n*=256);)r+=this[e+o]*n;return r},y.prototype.readUIntBE=function(e,t,i){e|=0,t|=0,i||G(e,t,this.length);for(var r=this[e+--t],n=1;t>0&&(n*=256);)r+=this[e+--t]*n;return r},y.prototype.readUInt8=function(e,t){return t||G(e,1,this.length),this[e]},y.prototype.readUInt16LE=function(e,t){return t||G(e,2,this.length),this[e]|this[e+1]<<8},y.prototype.readUInt16BE=function(e,t){return t||G(e,2,this.length),this[e]<<8|this[e+1]},y.prototype.readUInt32LE=function(e,t){return t||G(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},y.prototype.readUInt32BE=function(e,t){return t||G(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},y.prototype.readIntLE=function(e,t,i){e|=0,t|=0,i||G(e,t,this.length);for(var r=this[e],n=1,o=0;++o<t&&(n*=256);)r+=this[e+o]*n;return r>=(n*=128)&&(r-=Math.pow(2,8*t)),r},y.prototype.readIntBE=function(e,t,i){e|=0,t|=0,i||G(e,t,this.length);for(var r=t,n=1,o=this[e+--r];r>0&&(n*=256);)o+=this[e+--r]*n;return o>=(n*=128)&&(o-=Math.pow(2,8*t)),o},y.prototype.readInt8=function(e,t){return t||G(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},y.prototype.readInt16LE=function(e,t){t||G(e,2,this.length);var i=this[e]|this[e+1]<<8;return 32768&i?4294901760|i:i},y.prototype.readInt16BE=function(e,t){t||G(e,2,this.length);var i=this[e+1]|this[e]<<8;return 32768&i?4294901760|i:i},y.prototype.readInt32LE=function(e,t){return t||G(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},y.prototype.readInt32BE=function(e,t){return t||G(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},y.prototype.readFloatLE=function(e,t){return t||G(e,4,this.length),m(this,e,!0,23,4)},y.prototype.readFloatBE=function(e,t){return t||G(e,4,this.length),m(this,e,!1,23,4)},y.prototype.readDoubleLE=function(e,t){return t||G(e,8,this.length),m(this,e,!0,52,8)},y.prototype.readDoubleBE=function(e,t){return t||G(e,8,this.length),m(this,e,!1,52,8)},y.prototype.writeUIntLE=function(e,t,i,r){e=+e,t|=0,i|=0,r||K(this,e,t,i,Math.pow(2,8*i)-1,0);var n=1,o=0;for(this[t]=255&e;++o<i&&(n*=256);)this[t+o]=e/n&255;return t+i},y.prototype.writeUIntBE=function(e,t,i,r){e=+e,t|=0,i|=0,r||K(this,e,t,i,Math.pow(2,8*i)-1,0);var n=i-1,o=1;for(this[t+n]=255&e;--n>=0&&(o*=256);)this[t+n]=e/o&255;return t+i},y.prototype.writeUInt8=function(e,t,i){return e=+e,t|=0,i||K(this,e,t,1,255,0),y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},y.prototype.writeUInt16LE=function(e,t,i){return e=+e,t|=0,i||K(this,e,t,2,65535,0),y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Y(this,e,t,!0),t+2},y.prototype.writeUInt16BE=function(e,t,i){return e=+e,t|=0,i||K(this,e,t,2,65535,0),y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Y(this,e,t,!1),t+2},y.prototype.writeUInt32LE=function(e,t,i){return e=+e,t|=0,i||K(this,e,t,4,4294967295,0),y.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):J(this,e,t,!0),t+4},y.prototype.writeUInt32BE=function(e,t,i){return e=+e,t|=0,i||K(this,e,t,4,4294967295,0),y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):J(this,e,t,!1),t+4},y.prototype.writeIntLE=function(e,t,i,r){if(e=+e,t|=0,!r){var n=Math.pow(2,8*i-1);K(this,e,t,i,n-1,-n)}var o=0,s=1,a=0;for(this[t]=255&e;++o<i&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s|0)-a&255;return t+i},y.prototype.writeIntBE=function(e,t,i,r){if(e=+e,t|=0,!r){var n=Math.pow(2,8*i-1);K(this,e,t,i,n-1,-n)}var o=i-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s|0)-a&255;return t+i},y.prototype.writeInt8=function(e,t,i){return e=+e,t|=0,i||K(this,e,t,1,127,-128),y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},y.prototype.writeInt16LE=function(e,t,i){return e=+e,t|=0,i||K(this,e,t,2,32767,-32768),y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Y(this,e,t,!0),t+2},y.prototype.writeInt16BE=function(e,t,i){return e=+e,t|=0,i||K(this,e,t,2,32767,-32768),y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Y(this,e,t,!1),t+2},y.prototype.writeInt32LE=function(e,t,i){return e=+e,t|=0,i||K(this,e,t,4,2147483647,-2147483648),y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):J(this,e,t,!0),t+4},y.prototype.writeInt32BE=function(e,t,i){return e=+e,t|=0,i||K(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):J(this,e,t,!1),t+4},y.prototype.writeFloatLE=function(e,t,i){return X(this,e,t,!0,i)},y.prototype.writeFloatBE=function(e,t,i){return X(this,e,t,!1,i)},y.prototype.writeDoubleLE=function(e,t,i){return Q(this,e,t,!0,i)},y.prototype.writeDoubleBE=function(e,t,i){return Q(this,e,t,!1,i)},y.prototype.copy=function(e,t,i,r){if(i||(i=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<i&&(r=i),r===i)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-i&&(r=e.length-t+i);var n,o=r-i;if(this===e&&i<t&&t<r)for(n=o-1;n>=0;--n)e[n+t]=this[n+i];else if(o<1e3||!y.TYPED_ARRAY_SUPPORT)for(n=0;n<o;++n)e[n+t]=this[n+i];else Uint8Array.prototype.set.call(e,this.subarray(i,i+o),t);return o},y.prototype.fill=function(e,t,i,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,i=this.length):"string"==typeof i&&(r=i,i=this.length),1===e.length){var n=e.charCodeAt(0);n<256&&(e=n)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!y.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<i)throw new RangeError("Out of range index");if(i<=t)return this;var o;if(t>>>=0,i=void 0===i?this.length:i>>>0,e||(e=0),"number"==typeof e)for(o=t;o<i;++o)this[o]=e;else{var s=b(e)?e:ee(new y(e,r).toString()),a=s.length;for(o=0;o<i-t;++o)this[o+t]=s[o%a]}return this};var Z=/[^+\/0-9A-Za-z-_]/g;function $(e){return e<16?"0"+e.toString(16):e.toString(16)}function ee(e,t){var i;t=t||1/0;for(var r=e.length,n=null,o=[],s=0;s<r;++s){if((i=e.charCodeAt(s))>55295&&i<57344){if(!n){if(i>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}n=i;continue}if(i<56320){(t-=3)>-1&&o.push(239,191,189),n=i;continue}i=65536+(n-55296<<10|i-56320)}else n&&(t-=3)>-1&&o.push(239,191,189);if(n=null,i<128){if((t-=1)<0)break;o.push(i)}else if(i<2048){if((t-=2)<0)break;o.push(i>>6|192,63&i|128)}else if(i<65536){if((t-=3)<0)break;o.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return o}function te(e){return function(e){var t,i,r,n,o,s;d||u();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new l(3*a/4-o),r=o>0?a-4:a;var h=0;for(t=0,i=0;t<r;t+=4,i+=3)n=c[e.charCodeAt(t)]<<18|c[e.charCodeAt(t+1)]<<12|c[e.charCodeAt(t+2)]<<6|c[e.charCodeAt(t+3)],s[h++]=n>>16&255,s[h++]=n>>8&255,s[h++]=255&n;return 2===o?(n=c[e.charCodeAt(t)]<<2|c[e.charCodeAt(t+1)]>>4,s[h++]=255&n):1===o&&(n=c[e.charCodeAt(t)]<<10|c[e.charCodeAt(t+1)]<<4|c[e.charCodeAt(t+2)]>>2,s[h++]=n>>8&255,s[h++]=255&n),s}(function(e){if((e=(t=e,t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")).replace(Z,"")).length<2)return"";for(var t;e.length%4!=0;)e+="=";return e}(e))}function ie(e,t,i,r){for(var n=0;n<r&&!(n+i>=t.length||n>=e.length);++n)t[n+i]=e[n];return n}function re(e){return null!=e&&(!!e._isBuffer||ne(e)||"function"==typeof(t=e).readFloatLE&&"function"==typeof t.slice&&ne(t.slice(0,0)));var t}function ne(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function oe(e,t){return e(t={exports:{}},t.exports),t.exports}var se=oe((function(e,t){var i,r,n,o,s,a,c,l,d,u,h,p,m;e.exports=(i=i||(r=Math,n=Object.create||function(){function e(){}return function(t){var i;return e.prototype=t,i=new e,e.prototype=null,i}}(),s=(o={}).lib={},a=s.Base={extend:function(e){var t=n(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},c=s.WordArray=a.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||d).stringify(this)},concat:function(e){var t=this.words,i=e.words,r=this.sigBytes,n=e.sigBytes;if(this.clamp(),r%4)for(var o=0;o<n;o++){var s=i[o>>>2]>>>24-o%4*8&255;t[r+o>>>2]|=s<<24-(r+o)%4*8}else for(o=0;o<n;o+=4)t[r+o>>>2]=i[o>>>2];return this.sigBytes+=n,this},clamp:function(){var e=this.words,t=this.sigBytes;e[t>>>2]&=4294967295<<32-t%4*8,e.length=r.ceil(t/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t,i=[],n=function(e){var t=987654321,i=4294967295;return function(){var n=((t=36969*(65535&t)+(t>>16)&i)<<16)+(e=18e3*(65535&e)+(e>>16)&i)&i;return n/=4294967296,(n+=.5)*(r.random()>.5?1:-1)}},o=0;o<e;o+=4){var s=n(4294967296*(t||r.random()));t=987654071*s(),i.push(4294967296*s()|0)}return new c.init(i,e)}}),l=o.enc={},d=l.Hex={stringify:function(e){for(var t=e.words,i=e.sigBytes,r=[],n=0;n<i;n++){var o=t[n>>>2]>>>24-n%4*8&255;r.push((o>>>4).toString(16)),r.push((15&o).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,i=[],r=0;r<t;r+=2)i[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new c.init(i,t/2)}},u=l.Latin1={stringify:function(e){for(var t=e.words,i=e.sigBytes,r=[],n=0;n<i;n++){var o=t[n>>>2]>>>24-n%4*8&255;r.push(String.fromCharCode(o))}return r.join("")},parse:function(e){for(var t=e.length,i=[],r=0;r<t;r++)i[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new c.init(i,t)}},h=l.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},p=s.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=h.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(e){var t=this._data,i=t.words,n=t.sigBytes,o=this.blockSize,s=n/(4*o),a=(s=e?r.ceil(s):r.max((0|s)-this._minBufferSize,0))*o,l=r.min(4*a,n);if(a){for(var d=0;d<a;d+=o)this._doProcessBlock(i,d);var u=i.splice(0,a);t.sigBytes-=l}return new c.init(u,l)},clone:function(){var e=a.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),s.Hasher=p.extend({cfg:a.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){p.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,i){return new e.init(i).finalize(t)}},_createHmacHelper:function(e){return function(t,i){return new m.HMAC.init(e,i).finalize(t)}}}),m=o.algo={},o),i)})),ae=(oe((function(e,t){var i,r,n,o,s,a;e.exports=(n=(r=i=se).lib,o=n.Base,s=n.WordArray,(a=r.x64={}).Word=o.extend({init:function(e,t){this.high=e,this.low=t}}),a.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:8*e.length},toX32:function(){for(var e=this.words,t=e.length,i=[],r=0;r<t;r++){var n=e[r];i.push(n.high),i.push(n.low)}return s.create(i,this.sigBytes)},clone:function(){for(var e=o.clone.call(this),t=e.words=this.words.slice(0),i=t.length,r=0;r<i;r++)t[r]=t[r].clone();return e}}),i)})),oe((function(e,t){var i;e.exports=(i=se,function(){if("function"==typeof ArrayBuffer){var e=i.lib.WordArray,t=e.init;(e.init=function(e){if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),(e instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)&&(e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),e instanceof Uint8Array){for(var i=e.byteLength,r=[],n=0;n<i;n++)r[n>>>2]|=e[n]<<24-n%4*8;t.call(this,r,i)}else t.apply(this,arguments)}).prototype=e}}(),i.lib.WordArray)})),oe((function(e,t){var i;e.exports=(i=se,function(){var e=i,t=e.lib.WordArray,r=e.enc;function n(e){return e<<8&4278255360|e>>>8&16711935}r.Utf16=r.Utf16BE={stringify:function(e){for(var t=e.words,i=e.sigBytes,r=[],n=0;n<i;n+=2){var o=t[n>>>2]>>>16-n%4*8&65535;r.push(String.fromCharCode(o))}return r.join("")},parse:function(e){for(var i=e.length,r=[],n=0;n<i;n++)r[n>>>1]|=e.charCodeAt(n)<<16-n%2*16;return t.create(r,2*i)}},r.Utf16LE={stringify:function(e){for(var t=e.words,i=e.sigBytes,r=[],o=0;o<i;o+=2){var s=n(t[o>>>2]>>>16-o%4*8&65535);r.push(String.fromCharCode(s))}return r.join("")},parse:function(e){for(var i=e.length,r=[],o=0;o<i;o++)r[o>>>1]|=n(e.charCodeAt(o)<<16-o%2*16);return t.create(r,2*i)}}}(),i.enc.Utf16)})),oe((function(e,t){var i,r,n;e.exports=(n=(r=i=se).lib.WordArray,r.enc.Base64={stringify:function(e){var t=e.words,i=e.sigBytes,r=this._map;e.clamp();for(var n=[],o=0;o<i;o+=3)for(var s=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;a<4&&o+.75*a<i;a++)n.push(r.charAt(s>>>6*(3-a)&63));var c=r.charAt(64);if(c)for(;n.length%4;)n.push(c);return n.join("")},parse:function(e){var t=e.length,i=this._map,r=this._reverseMap;if(!r){r=this._reverseMap=[];for(var o=0;o<i.length;o++)r[i.charCodeAt(o)]=o}var s=i.charAt(64);if(s){var a=e.indexOf(s);-1!==a&&(t=a)}return function(e,t,i){for(var r=[],o=0,s=0;s<t;s++)if(s%4){var a=i[e.charCodeAt(s-1)]<<s%4*2,c=i[e.charCodeAt(s)]>>>6-s%4*2;r[o>>>2]|=(a|c)<<24-o%4*8,o++}return n.create(r,o)}(e,t,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},i.enc.Base64)})),oe((function(e,t){var i;e.exports=(i=se,function(e){var t=i,r=t.lib,n=r.WordArray,o=r.Hasher,s=t.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=s.MD5=o.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var i=0;i<16;i++){var r=t+i,n=e[r];e[r]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var o=this._hash.words,s=e[t+0],c=e[t+1],p=e[t+2],m=e[t+3],_=e[t+4],f=e[t+5],g=e[t+6],E=e[t+7],v=e[t+8],y=e[t+9],T=e[t+10],S=e[t+11],I=e[t+12],A=e[t+13],R=e[t+14],b=e[t+15],C=o[0],k=o[1],w=o[2],N=o[3];C=l(C,k,w,N,s,7,a[0]),N=l(N,C,k,w,c,12,a[1]),w=l(w,N,C,k,p,17,a[2]),k=l(k,w,N,C,m,22,a[3]),C=l(C,k,w,N,_,7,a[4]),N=l(N,C,k,w,f,12,a[5]),w=l(w,N,C,k,g,17,a[6]),k=l(k,w,N,C,E,22,a[7]),C=l(C,k,w,N,v,7,a[8]),N=l(N,C,k,w,y,12,a[9]),w=l(w,N,C,k,T,17,a[10]),k=l(k,w,N,C,S,22,a[11]),C=l(C,k,w,N,I,7,a[12]),N=l(N,C,k,w,A,12,a[13]),w=l(w,N,C,k,R,17,a[14]),C=d(C,k=l(k,w,N,C,b,22,a[15]),w,N,c,5,a[16]),N=d(N,C,k,w,g,9,a[17]),w=d(w,N,C,k,S,14,a[18]),k=d(k,w,N,C,s,20,a[19]),C=d(C,k,w,N,f,5,a[20]),N=d(N,C,k,w,T,9,a[21]),w=d(w,N,C,k,b,14,a[22]),k=d(k,w,N,C,_,20,a[23]),C=d(C,k,w,N,y,5,a[24]),N=d(N,C,k,w,R,9,a[25]),w=d(w,N,C,k,m,14,a[26]),k=d(k,w,N,C,v,20,a[27]),C=d(C,k,w,N,A,5,a[28]),N=d(N,C,k,w,p,9,a[29]),w=d(w,N,C,k,E,14,a[30]),C=u(C,k=d(k,w,N,C,I,20,a[31]),w,N,f,4,a[32]),N=u(N,C,k,w,v,11,a[33]),w=u(w,N,C,k,S,16,a[34]),k=u(k,w,N,C,R,23,a[35]),C=u(C,k,w,N,c,4,a[36]),N=u(N,C,k,w,_,11,a[37]),w=u(w,N,C,k,E,16,a[38]),k=u(k,w,N,C,T,23,a[39]),C=u(C,k,w,N,A,4,a[40]),N=u(N,C,k,w,s,11,a[41]),w=u(w,N,C,k,m,16,a[42]),k=u(k,w,N,C,g,23,a[43]),C=u(C,k,w,N,y,4,a[44]),N=u(N,C,k,w,I,11,a[45]),w=u(w,N,C,k,b,16,a[46]),C=h(C,k=u(k,w,N,C,p,23,a[47]),w,N,s,6,a[48]),N=h(N,C,k,w,E,10,a[49]),w=h(w,N,C,k,R,15,a[50]),k=h(k,w,N,C,f,21,a[51]),C=h(C,k,w,N,I,6,a[52]),N=h(N,C,k,w,m,10,a[53]),w=h(w,N,C,k,T,15,a[54]),k=h(k,w,N,C,c,21,a[55]),C=h(C,k,w,N,v,6,a[56]),N=h(N,C,k,w,b,10,a[57]),w=h(w,N,C,k,g,15,a[58]),k=h(k,w,N,C,A,21,a[59]),C=h(C,k,w,N,_,6,a[60]),N=h(N,C,k,w,S,10,a[61]),w=h(w,N,C,k,p,15,a[62]),k=h(k,w,N,C,y,21,a[63]),o[0]=o[0]+C|0,o[1]=o[1]+k|0,o[2]=o[2]+w|0,o[3]=o[3]+N|0},_doFinalize:function(){var t=this._data,i=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;i[n>>>5]|=128<<24-n%32;var o=e.floor(r/4294967296),s=r;i[15+(n+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),i[14+(n+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),t.sigBytes=4*(i.length+1),this._process();for(var a=this._hash,c=a.words,l=0;l<4;l++){var d=c[l];c[l]=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8)}return a},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function l(e,t,i,r,n,o,s){var a=e+(t&i|~t&r)+n+s;return(a<<o|a>>>32-o)+t}function d(e,t,i,r,n,o,s){var a=e+(t&r|i&~r)+n+s;return(a<<o|a>>>32-o)+t}function u(e,t,i,r,n,o,s){var a=e+(t^i^r)+n+s;return(a<<o|a>>>32-o)+t}function h(e,t,i,r,n,o,s){var a=e+(i^(t|~r))+n+s;return(a<<o|a>>>32-o)+t}t.MD5=o._createHelper(c),t.HmacMD5=o._createHmacHelper(c)}(Math),i.MD5)})),oe((function(e,t){var i,r,n,o,s,a,c,l;e.exports=(n=(r=i=se).lib,o=n.WordArray,s=n.Hasher,a=r.algo,c=[],l=a.SHA1=s.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var i=this._hash.words,r=i[0],n=i[1],o=i[2],s=i[3],a=i[4],l=0;l<80;l++){if(l<16)c[l]=0|e[t+l];else{var d=c[l-3]^c[l-8]^c[l-14]^c[l-16];c[l]=d<<1|d>>>31}var u=(r<<5|r>>>27)+a+c[l];u+=l<20?1518500249+(n&o|~n&s):l<40?1859775393+(n^o^s):l<60?(n&o|n&s|o&s)-1894007588:(n^o^s)-899497514,a=s,s=o,o=n<<30|n>>>2,n=r,r=u}i[0]=i[0]+r|0,i[1]=i[1]+n|0,i[2]=i[2]+o|0,i[3]=i[3]+s|0,i[4]=i[4]+a|0},_doFinalize:function(){var e=this._data,t=e.words,i=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(r+64>>>9<<4)]=Math.floor(i/4294967296),t[15+(r+64>>>9<<4)]=i,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}}),r.SHA1=s._createHelper(l),r.HmacSHA1=s._createHmacHelper(l),i.SHA1)})),oe((function(e,t){var i;e.exports=(i=se,function(e){var t=i,r=t.lib,n=r.WordArray,o=r.Hasher,s=t.algo,a=[],c=[];!function(){function t(t){for(var i=e.sqrt(t),r=2;r<=i;r++)if(!(t%r))return!1;return!0}function i(e){return 4294967296*(e-(0|e))|0}for(var r=2,n=0;n<64;)t(r)&&(n<8&&(a[n]=i(e.pow(r,.5))),c[n]=i(e.pow(r,1/3)),n++),r++}();var l=[],d=s.SHA256=o.extend({_doReset:function(){this._hash=new n.init(a.slice(0))},_doProcessBlock:function(e,t){for(var i=this._hash.words,r=i[0],n=i[1],o=i[2],s=i[3],a=i[4],d=i[5],u=i[6],h=i[7],p=0;p<64;p++){if(p<16)l[p]=0|e[t+p];else{var m=l[p-15],_=(m<<25|m>>>7)^(m<<14|m>>>18)^m>>>3,f=l[p-2],g=(f<<15|f>>>17)^(f<<13|f>>>19)^f>>>10;l[p]=_+l[p-7]+g+l[p-16]}var E=r&n^r&o^n&o,v=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),y=h+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&d^~a&u)+c[p]+l[p];h=u,u=d,d=a,a=s+y|0,s=o,o=n,n=r,r=y+(v+E)|0}i[0]=i[0]+r|0,i[1]=i[1]+n|0,i[2]=i[2]+o|0,i[3]=i[3]+s|0,i[4]=i[4]+a|0,i[5]=i[5]+d|0,i[6]=i[6]+u|0,i[7]=i[7]+h|0},_doFinalize:function(){var t=this._data,i=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;return i[n>>>5]|=128<<24-n%32,i[14+(n+64>>>9<<4)]=e.floor(r/4294967296),i[15+(n+64>>>9<<4)]=r,t.sigBytes=4*i.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=o._createHelper(d),t.HmacSHA256=o._createHmacHelper(d)}(Math),i.SHA256)})),oe((function(e,t){var i,r,n,o,s,a;e.exports=(n=(r=i=se).lib.WordArray,o=r.algo,s=o.SHA256,a=o.SHA224=s.extend({_doReset:function(){this._hash=new n.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var e=s._doFinalize.call(this);return e.sigBytes-=4,e}}),r.SHA224=s._createHelper(a),r.HmacSHA224=s._createHmacHelper(a),i.SHA224)})),oe((function(e,t){var i;e.exports=(i=se,function(){var e=i,t=e.lib.Hasher,r=e.x64,n=r.Word,o=r.WordArray,s=e.algo;function a(){return n.create.apply(n,arguments)}var c=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],l=[];!function(){for(var e=0;e<80;e++)l[e]=a()}();var d=s.SHA512=t.extend({_doReset:function(){this._hash=new o.init([new n.init(1779033703,4089235720),new n.init(3144134277,2227873595),new n.init(1013904242,4271175723),new n.init(2773480762,1595750129),new n.init(1359893119,2917565137),new n.init(2600822924,725511199),new n.init(528734635,4215389547),new n.init(1541459225,327033209)])},_doProcessBlock:function(e,t){for(var i=this._hash.words,r=i[0],n=i[1],o=i[2],s=i[3],a=i[4],d=i[5],u=i[6],h=i[7],p=r.high,m=r.low,_=n.high,f=n.low,g=o.high,E=o.low,v=s.high,y=s.low,T=a.high,S=a.low,I=d.high,A=d.low,R=u.high,b=u.low,C=h.high,k=h.low,w=p,N=m,D=_,O=f,L=g,P=E,M=v,x=y,V=T,U=S,B=I,F=A,H=R,j=b,W=C,z=k,G=0;G<80;G++){var K=l[G];if(G<16)var Y=K.high=0|e[t+2*G],J=K.low=0|e[t+2*G+1];else{var q=l[G-15],X=q.high,Q=q.low,Z=(X>>>1|Q<<31)^(X>>>8|Q<<24)^X>>>7,$=(Q>>>1|X<<31)^(Q>>>8|X<<24)^(Q>>>7|X<<25),ee=l[G-2],te=ee.high,ie=ee.low,re=(te>>>19|ie<<13)^(te<<3|ie>>>29)^te>>>6,ne=(ie>>>19|te<<13)^(ie<<3|te>>>29)^(ie>>>6|te<<26),oe=l[G-7],se=oe.high,ae=oe.low,ce=l[G-16],le=ce.high,de=ce.low;Y=(Y=(Y=Z+se+((J=$+ae)>>>0<$>>>0?1:0))+re+((J+=ne)>>>0<ne>>>0?1:0))+le+((J+=de)>>>0<de>>>0?1:0),K.high=Y,K.low=J}var ue,he=V&B^~V&H,pe=U&F^~U&j,me=w&D^w&L^D&L,_e=N&O^N&P^O&P,fe=(w>>>28|N<<4)^(w<<30|N>>>2)^(w<<25|N>>>7),ge=(N>>>28|w<<4)^(N<<30|w>>>2)^(N<<25|w>>>7),Ee=(V>>>14|U<<18)^(V>>>18|U<<14)^(V<<23|U>>>9),ve=(U>>>14|V<<18)^(U>>>18|V<<14)^(U<<23|V>>>9),ye=c[G],Te=ye.high,Se=ye.low,Ie=W+Ee+((ue=z+ve)>>>0<z>>>0?1:0),Ae=ge+_e;W=H,z=j,H=B,j=F,B=V,F=U,V=M+(Ie=(Ie=(Ie=Ie+he+((ue+=pe)>>>0<pe>>>0?1:0))+Te+((ue+=Se)>>>0<Se>>>0?1:0))+Y+((ue+=J)>>>0<J>>>0?1:0))+((U=x+ue|0)>>>0<x>>>0?1:0)|0,M=L,x=P,L=D,P=O,D=w,O=N,w=Ie+(fe+me+(Ae>>>0<ge>>>0?1:0))+((N=ue+Ae|0)>>>0<ue>>>0?1:0)|0}m=r.low=m+N,r.high=p+w+(m>>>0<N>>>0?1:0),f=n.low=f+O,n.high=_+D+(f>>>0<O>>>0?1:0),E=o.low=E+P,o.high=g+L+(E>>>0<P>>>0?1:0),y=s.low=y+x,s.high=v+M+(y>>>0<x>>>0?1:0),S=a.low=S+U,a.high=T+V+(S>>>0<U>>>0?1:0),A=d.low=A+F,d.high=I+B+(A>>>0<F>>>0?1:0),b=u.low=b+j,u.high=R+H+(b>>>0<j>>>0?1:0),k=h.low=k+z,h.high=C+W+(k>>>0<z>>>0?1:0)},_doFinalize:function(){var e=this._data,t=e.words,i=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[30+(r+128>>>10<<5)]=Math.floor(i/4294967296),t[31+(r+128>>>10<<5)]=i,e.sigBytes=4*t.length,this._process(),this._hash.toX32()},clone:function(){var e=t.clone.call(this);return e._hash=this._hash.clone(),e},blockSize:32});e.SHA512=t._createHelper(d),e.HmacSHA512=t._createHmacHelper(d)}(),i.SHA512)})),oe((function(e,t){var i,r,n,o,s,a,c,l;e.exports=(n=(r=i=se).x64,o=n.Word,s=n.WordArray,a=r.algo,c=a.SHA512,l=a.SHA384=c.extend({_doReset:function(){this._hash=new s.init([new o.init(3418070365,3238371032),new o.init(1654270250,914150663),new o.init(2438529370,812702999),new o.init(355462360,4144912697),new o.init(1731405415,4290775857),new o.init(2394180231,1750603025),new o.init(3675008525,1694076839),new o.init(1203062813,3204075428)])},_doFinalize:function(){var e=c._doFinalize.call(this);return e.sigBytes-=16,e}}),r.SHA384=c._createHelper(l),r.HmacSHA384=c._createHmacHelper(l),i.SHA384)})),oe((function(e,t){var i;e.exports=(i=se,function(e){var t=i,r=t.lib,n=r.WordArray,o=r.Hasher,s=t.x64.Word,a=t.algo,c=[],l=[],d=[];!function(){for(var e=1,t=0,i=0;i<24;i++){c[e+5*t]=(i+1)*(i+2)/2%64;var r=(2*e+3*t)%5;e=t%5,t=r}for(e=0;e<5;e++)for(t=0;t<5;t++)l[e+5*t]=t+(2*e+3*t)%5*5;for(var n=1,o=0;o<24;o++){for(var a=0,u=0,h=0;h<7;h++){if(1&n){var p=(1<<h)-1;p<32?u^=1<<p:a^=1<<p-32}128&n?n=n<<1^113:n<<=1}d[o]=s.create(a,u)}}();var u=[];!function(){for(var e=0;e<25;e++)u[e]=s.create()}();var h=a.SHA3=o.extend({cfg:o.cfg.extend({outputLength:512}),_doReset:function(){for(var e=this._state=[],t=0;t<25;t++)e[t]=new s.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(e,t){for(var i=this._state,r=this.blockSize/2,n=0;n<r;n++){var o=e[t+2*n],s=e[t+2*n+1];o=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),s=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),(k=i[n]).high^=s,k.low^=o}for(var a=0;a<24;a++){for(var h=0;h<5;h++){for(var p=0,m=0,_=0;_<5;_++)p^=(k=i[h+5*_]).high,m^=k.low;var f=u[h];f.high=p,f.low=m}for(h=0;h<5;h++){var g=u[(h+4)%5],E=u[(h+1)%5],v=E.high,y=E.low;for(p=g.high^(v<<1|y>>>31),m=g.low^(y<<1|v>>>31),_=0;_<5;_++)(k=i[h+5*_]).high^=p,k.low^=m}for(var T=1;T<25;T++){var S=(k=i[T]).high,I=k.low,A=c[T];A<32?(p=S<<A|I>>>32-A,m=I<<A|S>>>32-A):(p=I<<A-32|S>>>64-A,m=S<<A-32|I>>>64-A);var R=u[l[T]];R.high=p,R.low=m}var b=u[0],C=i[0];for(b.high=C.high,b.low=C.low,h=0;h<5;h++)for(_=0;_<5;_++){var k=i[T=h+5*_],w=u[T],N=u[(h+1)%5+5*_],D=u[(h+2)%5+5*_];k.high=w.high^~N.high&D.high,k.low=w.low^~N.low&D.low}k=i[0];var O=d[a];k.high^=O.high,k.low^=O.low}},_doFinalize:function(){var t=this._data,i=t.words,r=(this._nDataBytes,8*t.sigBytes),o=32*this.blockSize;i[r>>>5]|=1<<24-r%32,i[(e.ceil((r+1)/o)*o>>>5)-1]|=128,t.sigBytes=4*i.length,this._process();for(var s=this._state,a=this.cfg.outputLength/8,c=a/8,l=[],d=0;d<c;d++){var u=s[d],h=u.high,p=u.low;h=16711935&(h<<8|h>>>24)|4278255360&(h<<24|h>>>8),p=16711935&(p<<8|p>>>24)|4278255360&(p<<24|p>>>8),l.push(p),l.push(h)}return new n.init(l,a)},clone:function(){for(var e=o.clone.call(this),t=e._state=this._state.slice(0),i=0;i<25;i++)t[i]=t[i].clone();return e}});t.SHA3=o._createHelper(h),t.HmacSHA3=o._createHmacHelper(h)}(Math),i.SHA3)})),oe((function(e,t){var i;e.exports=(i=se,function(e){var t=i,r=t.lib,n=r.WordArray,o=r.Hasher,s=t.algo,a=n.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),c=n.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),l=n.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),d=n.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),u=n.create([0,1518500249,1859775393,2400959708,2840853838]),h=n.create([1352829926,1548603684,1836072691,2053994217,0]),p=s.RIPEMD160=o.extend({_doReset:function(){this._hash=n.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var i=0;i<16;i++){var r=t+i,n=e[r];e[r]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var o,s,p,y,T,S,I,A,R,b,C,k=this._hash.words,w=u.words,N=h.words,D=a.words,O=c.words,L=l.words,P=d.words;for(S=o=k[0],I=s=k[1],A=p=k[2],R=y=k[3],b=T=k[4],i=0;i<80;i+=1)C=o+e[t+D[i]]|0,C+=i<16?m(s,p,y)+w[0]:i<32?_(s,p,y)+w[1]:i<48?f(s,p,y)+w[2]:i<64?g(s,p,y)+w[3]:E(s,p,y)+w[4],C=(C=v(C|=0,L[i]))+T|0,o=T,T=y,y=v(p,10),p=s,s=C,C=S+e[t+O[i]]|0,C+=i<16?E(I,A,R)+N[0]:i<32?g(I,A,R)+N[1]:i<48?f(I,A,R)+N[2]:i<64?_(I,A,R)+N[3]:m(I,A,R)+N[4],C=(C=v(C|=0,P[i]))+b|0,S=b,b=R,R=v(A,10),A=I,I=C;C=k[1]+p+R|0,k[1]=k[2]+y+b|0,k[2]=k[3]+T+S|0,k[3]=k[4]+o+I|0,k[4]=k[0]+s+A|0,k[0]=C},_doFinalize:function(){var e=this._data,t=e.words,i=8*this._nDataBytes,r=8*e.sigBytes;t[r>>>5]|=128<<24-r%32,t[14+(r+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),e.sigBytes=4*(t.length+1),this._process();for(var n=this._hash,o=n.words,s=0;s<5;s++){var a=o[s];o[s]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}return n},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function m(e,t,i){return e^t^i}function _(e,t,i){return e&t|~e&i}function f(e,t,i){return(e|~t)^i}function g(e,t,i){return e&i|t&~i}function E(e,t,i){return e^(t|~i)}function v(e,t){return e<<t|e>>>32-t}t.RIPEMD160=o._createHelper(p),t.HmacRIPEMD160=o._createHmacHelper(p)}(),i.RIPEMD160)})),oe((function(e,t){var i,r,n,o;e.exports=(r=(i=se).lib.Base,n=i.enc,o=n.Utf8,void(i.algo.HMAC=r.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=o.parse(t));var i=e.blockSize,r=4*i;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var n=this._oKey=t.clone(),s=this._iKey=t.clone(),a=n.words,c=s.words,l=0;l<i;l++)a[l]^=1549556828,c[l]^=909522486;n.sigBytes=s.sigBytes=r,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,i=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(i))}})))})),oe((function(e,t){var i,r,n,o,s,a,c,l,d;e.exports=(o=(n=(r=i=se).lib).Base,s=n.WordArray,c=(a=r.algo).SHA1,l=a.HMAC,d=a.PBKDF2=o.extend({cfg:o.extend({keySize:4,hasher:c,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var i=this.cfg,r=l.create(i.hasher,e),n=s.create(),o=s.create([1]),a=n.words,c=o.words,d=i.keySize,u=i.iterations;a.length<d;){var h=r.update(t).finalize(o);r.reset();for(var p=h.words,m=p.length,_=h,f=1;f<u;f++){_=r.finalize(_),r.reset();for(var g=_.words,E=0;E<m;E++)p[E]^=g[E]}n.concat(h),c[0]++}return n.sigBytes=4*d,n}}),r.PBKDF2=function(e,t,i){return d.create(i).compute(e,t)},i.PBKDF2)})),oe((function(e,t){var i,r,n,o,s,a,c,l;e.exports=(o=(n=(r=i=se).lib).Base,s=n.WordArray,c=(a=r.algo).MD5,l=a.EvpKDF=o.extend({cfg:o.extend({keySize:4,hasher:c,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var i=this.cfg,r=i.hasher.create(),n=s.create(),o=n.words,a=i.keySize,c=i.iterations;o.length<a;){l&&r.update(l);var l=r.update(e).finalize(t);r.reset();for(var d=1;d<c;d++)l=r.finalize(l),r.reset();n.concat(l)}return n.sigBytes=4*a,n}}),r.EvpKDF=function(e,t,i){return l.create(i).compute(e,t)},i.EvpKDF)})),oe((function(e,t){var i,r,n,o,s,a,c,l,d,u,h,p,m,_,f,g,E,v,y,T,S,I,A;e.exports=void((i=se).lib.Cipher||(r=i,n=r.lib,o=n.Base,s=n.WordArray,a=n.BufferedBlockAlgorithm,c=r.enc,c.Utf8,l=c.Base64,d=r.algo,u=d.EvpKDF,h=n.Cipher=a.extend({cfg:o.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,i){this.cfg=this.cfg.extend(i),this._xformMode=e,this._key=t,this.reset()},reset:function(){a.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?A:T}return function(t){return{encrypt:function(i,r,n){return e(r).encrypt(t,i,r,n)},decrypt:function(i,r,n){return e(r).decrypt(t,i,r,n)}}}}()}),n.StreamCipher=h.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),p=r.mode={},m=n.BlockCipherMode=o.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),_=p.CBC=function(){var e=m.extend();function t(e,t,i){var r=this._iv;if(r){var n=r;this._iv=undefined}else n=this._prevBlock;for(var o=0;o<i;o++)e[t+o]^=n[o]}return e.Encryptor=e.extend({processBlock:function(e,i){var r=this._cipher,n=r.blockSize;t.call(this,e,i,n),r.encryptBlock(e,i),this._prevBlock=e.slice(i,i+n)}}),e.Decryptor=e.extend({processBlock:function(e,i){var r=this._cipher,n=r.blockSize,o=e.slice(i,i+n);r.decryptBlock(e,i),t.call(this,e,i,n),this._prevBlock=o}}),e}(),f=r.pad={},g=f.Pkcs7={pad:function(e,t){for(var i=4*t,r=i-e.sigBytes%i,n=r<<24|r<<16|r<<8|r,o=[],a=0;a<r;a+=4)o.push(n);var c=s.create(o,r);e.concat(c)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},n.BlockCipher=h.extend({cfg:h.cfg.extend({mode:_,padding:g}),reset:function(){h.reset.call(this);var e=this.cfg,t=e.iv,i=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var r=i.createEncryptor;else{r=i.createDecryptor;this._minBufferSize=1}this._mode&&this._mode.__creator==r?this._mode.init(this,t&&t.words):(this._mode=r.call(i,this,t&&t.words),this._mode.__creator=r)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){e.pad(this._data,this.blockSize);var t=this._process(!0)}else{t=this._process(!0);e.unpad(t)}return t},blockSize:4}),E=n.CipherParams=o.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),v=r.format={},y=v.OpenSSL={stringify:function(e){var t=e.ciphertext,i=e.salt;if(i)var r=s.create([1398893684,1701076831]).concat(i).concat(t);else r=t;return r.toString(l)},parse:function(e){var t=l.parse(e),i=t.words;if(1398893684==i[0]&&1701076831==i[1]){var r=s.create(i.slice(2,4));i.splice(0,4),t.sigBytes-=16}return E.create({ciphertext:t,salt:r})}},T=n.SerializableCipher=o.extend({cfg:o.extend({format:y}),encrypt:function(e,t,i,r){r=this.cfg.extend(r);var n=e.createEncryptor(i,r),o=n.finalize(t),s=n.cfg;return E.create({ciphertext:o,key:i,iv:s.iv,algorithm:e,mode:s.mode,padding:s.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,i,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(i,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),S=r.kdf={},I=S.OpenSSL={execute:function(e,t,i,r){r||(r=s.random(8));var n=u.create({keySize:t+i}).compute(e,r),o=s.create(n.words.slice(t),4*i);return n.sigBytes=4*t,E.create({key:n,iv:o,salt:r})}},A=n.PasswordBasedCipher=T.extend({cfg:T.cfg.extend({kdf:I}),encrypt:function(e,t,i,r){var n=(r=this.cfg.extend(r)).kdf.execute(i,e.keySize,e.ivSize);r.iv=n.iv;var o=T.encrypt.call(this,e,t,n.key,r);return o.mixIn(n),o},decrypt:function(e,t,i,r){r=this.cfg.extend(r),t=this._parse(t,r.format);var n=r.kdf.execute(i,e.keySize,e.ivSize,t.salt);return r.iv=n.iv,T.decrypt.call(this,e,t,n.key,r)}})))})),oe((function(e,t){var i;e.exports=((i=se).mode.CFB=function(){var e=i.lib.BlockCipherMode.extend();function t(e,t,i,r){var n=this._iv;if(n){var o=n.slice(0);this._iv=void 0}else o=this._prevBlock;r.encryptBlock(o,0);for(var s=0;s<i;s++)e[t+s]^=o[s]}return e.Encryptor=e.extend({processBlock:function(e,i){var r=this._cipher,n=r.blockSize;t.call(this,e,i,n,r),this._prevBlock=e.slice(i,i+n)}}),e.Decryptor=e.extend({processBlock:function(e,i){var r=this._cipher,n=r.blockSize,o=e.slice(i,i+n);t.call(this,e,i,n,r),this._prevBlock=o}}),e}(),i.mode.CFB)})),oe((function(e,t){var i,r,n;e.exports=((i=se).mode.CTR=(n=(r=i.lib.BlockCipherMode.extend()).Encryptor=r.extend({processBlock:function(e,t){var i=this._cipher,r=i.blockSize,n=this._iv,o=this._counter;n&&(o=this._counter=n.slice(0),this._iv=void 0);var s=o.slice(0);i.encryptBlock(s,0),o[r-1]=o[r-1]+1|0;for(var a=0;a<r;a++)e[t+a]^=s[a]}}),r.Decryptor=n,r),i.mode.CTR)})),oe((function(e,t){var i;e.exports=((i=se).mode.CTRGladman=function(){var e=i.lib.BlockCipherMode.extend();function t(e){if(255&~(e>>24))e+=1<<24;else{var t=e>>16&255,i=e>>8&255,r=255&e;255===t?(t=0,255===i?(i=0,255===r?r=0:++r):++i):++t,e=0,e+=t<<16,e+=i<<8,e+=r}return e}var r=e.Encryptor=e.extend({processBlock:function(e,i){var r,n=this._cipher,o=n.blockSize,s=this._iv,a=this._counter;s&&(a=this._counter=s.slice(0),this._iv=void 0),0===((r=a)[0]=t(r[0]))&&(r[1]=t(r[1]));var c=a.slice(0);n.encryptBlock(c,0);for(var l=0;l<o;l++)e[i+l]^=c[l]}});return e.Decryptor=r,e}(),i.mode.CTRGladman)})),oe((function(e,t){var i,r,n;e.exports=((i=se).mode.OFB=(n=(r=i.lib.BlockCipherMode.extend()).Encryptor=r.extend({processBlock:function(e,t){var i=this._cipher,r=i.blockSize,n=this._iv,o=this._keystream;n&&(o=this._keystream=n.slice(0),this._iv=void 0),i.encryptBlock(o,0);for(var s=0;s<r;s++)e[t+s]^=o[s]}}),r.Decryptor=n,r),i.mode.OFB)})),oe((function(e,t){var i,r;e.exports=((i=se).mode.ECB=((r=i.lib.BlockCipherMode.extend()).Encryptor=r.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),r.Decryptor=r.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),r),i.mode.ECB)})),oe((function(e,t){var i;e.exports=((i=se).pad.AnsiX923={pad:function(e,t){var i=e.sigBytes,r=4*t,n=r-i%r,o=i+n-1;e.clamp(),e.words[o>>>2]|=n<<24-o%4*8,e.sigBytes+=n},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},i.pad.Ansix923)})),oe((function(e,t){var i;e.exports=((i=se).pad.Iso10126={pad:function(e,t){var r=4*t,n=r-e.sigBytes%r;e.concat(i.lib.WordArray.random(n-1)).concat(i.lib.WordArray.create([n<<24],1))},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},i.pad.Iso10126)})),oe((function(e,t){var i;e.exports=((i=se).pad.Iso97971={pad:function(e,t){e.concat(i.lib.WordArray.create([2147483648],1)),i.pad.ZeroPadding.pad(e,t)},unpad:function(e){i.pad.ZeroPadding.unpad(e),e.sigBytes--}},i.pad.Iso97971)})),oe((function(e,t){var i;e.exports=((i=se).pad.ZeroPadding={pad:function(e,t){var i=4*t;e.clamp(),e.sigBytes+=i-(e.sigBytes%i||i)},unpad:function(e){for(var t=e.words,i=e.sigBytes-1;!(t[i>>>2]>>>24-i%4*8&255);)i--;e.sigBytes=i+1}},i.pad.ZeroPadding)})),oe((function(e,t){var i;e.exports=((i=se).pad.NoPadding={pad:function(){},unpad:function(){}},i.pad.NoPadding)})),oe((function(e,t){var i,r,n,o;e.exports=(n=(r=i=se).lib.CipherParams,o=r.enc.Hex,r.format.Hex={stringify:function(e){return e.ciphertext.toString(o)},parse:function(e){var t=o.parse(e);return n.create({ciphertext:t})}},i.format.Hex)})),oe((function(e,t){var i;e.exports=(i=se,function(){var e=i,t=e.lib.BlockCipher,r=e.algo,n=[],o=[],s=[],a=[],c=[],l=[],d=[],u=[],h=[],p=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;var i=0,r=0;for(t=0;t<256;t++){var m=r^r<<1^r<<2^r<<3^r<<4;m=m>>>8^255&m^99,n[i]=m,o[m]=i;var _=e[i],f=e[_],g=e[f],E=257*e[m]^16843008*m;s[i]=E<<24|E>>>8,a[i]=E<<16|E>>>16,c[i]=E<<8|E>>>24,l[i]=E,E=16843009*g^65537*f^257*_^16843008*i,d[m]=E<<24|E>>>8,u[m]=E<<16|E>>>16,h[m]=E<<8|E>>>24,p[m]=E,i?(i=_^e[e[e[g^_]]],r^=e[e[r]]):i=r=1}}();var m=[0,1,2,4,8,16,32,64,128,27,54],_=r.AES=t.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,i=e.sigBytes/4,r=4*((this._nRounds=i+6)+1),o=this._keySchedule=[],s=0;s<r;s++)if(s<i)o[s]=t[s];else{var a=o[s-1];s%i?i>6&&s%i==4&&(a=n[a>>>24]<<24|n[a>>>16&255]<<16|n[a>>>8&255]<<8|n[255&a]):(a=n[(a=a<<8|a>>>24)>>>24]<<24|n[a>>>16&255]<<16|n[a>>>8&255]<<8|n[255&a],a^=m[s/i|0]<<24),o[s]=o[s-i]^a}for(var c=this._invKeySchedule=[],l=0;l<r;l++)s=r-l,a=l%4?o[s]:o[s-4],c[l]=l<4||s<=4?a:d[n[a>>>24]]^u[n[a>>>16&255]]^h[n[a>>>8&255]]^p[n[255&a]]}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,s,a,c,l,n)},decryptBlock:function(e,t){var i=e[t+1];e[t+1]=e[t+3],e[t+3]=i,this._doCryptBlock(e,t,this._invKeySchedule,d,u,h,p,o),i=e[t+1],e[t+1]=e[t+3],e[t+3]=i},_doCryptBlock:function(e,t,i,r,n,o,s,a){for(var c=this._nRounds,l=e[t]^i[0],d=e[t+1]^i[1],u=e[t+2]^i[2],h=e[t+3]^i[3],p=4,m=1;m<c;m++){var _=r[l>>>24]^n[d>>>16&255]^o[u>>>8&255]^s[255&h]^i[p++],f=r[d>>>24]^n[u>>>16&255]^o[h>>>8&255]^s[255&l]^i[p++],g=r[u>>>24]^n[h>>>16&255]^o[l>>>8&255]^s[255&d]^i[p++],E=r[h>>>24]^n[l>>>16&255]^o[d>>>8&255]^s[255&u]^i[p++];l=_,d=f,u=g,h=E}_=(a[l>>>24]<<24|a[d>>>16&255]<<16|a[u>>>8&255]<<8|a[255&h])^i[p++],f=(a[d>>>24]<<24|a[u>>>16&255]<<16|a[h>>>8&255]<<8|a[255&l])^i[p++],g=(a[u>>>24]<<24|a[h>>>16&255]<<16|a[l>>>8&255]<<8|a[255&d])^i[p++],E=(a[h>>>24]<<24|a[l>>>16&255]<<16|a[d>>>8&255]<<8|a[255&u])^i[p++],e[t]=_,e[t+1]=f,e[t+2]=g,e[t+3]=E},keySize:8});e.AES=t._createHelper(_)}(),i.AES)})),oe((function(e,t){var i;e.exports=(i=se,function(){var e=i,t=e.lib,r=t.WordArray,n=t.BlockCipher,o=e.algo,s=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],a=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],c=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],l=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],d=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],u=o.DES=n.extend({_doReset:function(){for(var e=this._key.words,t=[],i=0;i<56;i++){var r=s[i]-1;t[i]=e[r>>>5]>>>31-r%32&1}for(var n=this._subKeys=[],o=0;o<16;o++){var l=n[o]=[],d=c[o];for(i=0;i<24;i++)l[i/6|0]|=t[(a[i]-1+d)%28]<<31-i%6,l[4+(i/6|0)]|=t[28+(a[i+24]-1+d)%28]<<31-i%6;for(l[0]=l[0]<<1|l[0]>>>31,i=1;i<7;i++)l[i]=l[i]>>>4*(i-1)+3;l[7]=l[7]<<5|l[7]>>>27}var u=this._invSubKeys=[];for(i=0;i<16;i++)u[i]=n[15-i]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._subKeys)},decryptBlock:function(e,t){this._doCryptBlock(e,t,this._invSubKeys)},_doCryptBlock:function(e,t,i){this._lBlock=e[t],this._rBlock=e[t+1],h.call(this,4,252645135),h.call(this,16,65535),p.call(this,2,858993459),p.call(this,8,16711935),h.call(this,1,1431655765);for(var r=0;r<16;r++){for(var n=i[r],o=this._lBlock,s=this._rBlock,a=0,c=0;c<8;c++)a|=l[c][((s^n[c])&d[c])>>>0];this._lBlock=s,this._rBlock=o^a}var u=this._lBlock;this._lBlock=this._rBlock,this._rBlock=u,h.call(this,1,1431655765),p.call(this,8,16711935),p.call(this,2,858993459),h.call(this,16,65535),h.call(this,4,252645135),e[t]=this._lBlock,e[t+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function h(e,t){var i=(this._lBlock>>>e^this._rBlock)&t;this._rBlock^=i,this._lBlock^=i<<e}function p(e,t){var i=(this._rBlock>>>e^this._lBlock)&t;this._lBlock^=i,this._rBlock^=i<<e}e.DES=n._createHelper(u);var m=o.TripleDES=n.extend({_doReset:function(){var e=this._key.words;this._des1=u.createEncryptor(r.create(e.slice(0,2))),this._des2=u.createEncryptor(r.create(e.slice(2,4))),this._des3=u.createEncryptor(r.create(e.slice(4,6)))},encryptBlock:function(e,t){this._des1.encryptBlock(e,t),this._des2.decryptBlock(e,t),this._des3.encryptBlock(e,t)},decryptBlock:function(e,t){this._des3.decryptBlock(e,t),this._des2.encryptBlock(e,t),this._des1.decryptBlock(e,t)},keySize:6,ivSize:2,blockSize:2});e.TripleDES=n._createHelper(m)}(),i.TripleDES)})),oe((function(e,t){var i;e.exports=(i=se,function(){var e=i,t=e.lib.StreamCipher,r=e.algo,n=r.RC4=t.extend({_doReset:function(){for(var e=this._key,t=e.words,i=e.sigBytes,r=this._S=[],n=0;n<256;n++)r[n]=n;n=0;for(var o=0;n<256;n++){var s=n%i,a=t[s>>>2]>>>24-s%4*8&255;o=(o+r[n]+a)%256;var c=r[n];r[n]=r[o],r[o]=c}this._i=this._j=0},_doProcessBlock:function(e,t){e[t]^=o.call(this)},keySize:8,ivSize:0});function o(){for(var e=this._S,t=this._i,i=this._j,r=0,n=0;n<4;n++){i=(i+e[t=(t+1)%256])%256;var o=e[t];e[t]=e[i],e[i]=o,r|=e[(e[t]+e[i])%256]<<24-8*n}return this._i=t,this._j=i,r}e.RC4=t._createHelper(n);var s=r.RC4Drop=n.extend({cfg:n.cfg.extend({drop:192}),_doReset:function(){n._doReset.call(this);for(var e=this.cfg.drop;e>0;e--)o.call(this)}});e.RC4Drop=t._createHelper(s)}(),i.RC4)})),oe((function(e,t){var i;e.exports=(i=se,function(){var e=i,t=e.lib.StreamCipher,r=e.algo,n=[],o=[],s=[],a=r.Rabbit=t.extend({_doReset:function(){for(var e=this._key.words,t=this.cfg.iv,i=0;i<4;i++)e[i]=16711935&(e[i]<<8|e[i]>>>24)|4278255360&(e[i]<<24|e[i]>>>8);var r=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],n=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];for(this._b=0,i=0;i<4;i++)c.call(this);for(i=0;i<8;i++)n[i]^=r[i+4&7];if(t){var o=t.words,s=o[0],a=o[1],l=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),d=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),u=l>>>16|4294901760&d,h=d<<16|65535&l;for(n[0]^=l,n[1]^=u,n[2]^=d,n[3]^=h,n[4]^=l,n[5]^=u,n[6]^=d,n[7]^=h,i=0;i<4;i++)c.call(this)}},_doProcessBlock:function(e,t){var i=this._X;c.call(this),n[0]=i[0]^i[5]>>>16^i[3]<<16,n[1]=i[2]^i[7]>>>16^i[5]<<16,n[2]=i[4]^i[1]>>>16^i[7]<<16,n[3]=i[6]^i[3]>>>16^i[1]<<16;for(var r=0;r<4;r++)n[r]=16711935&(n[r]<<8|n[r]>>>24)|4278255360&(n[r]<<24|n[r]>>>8),e[t+r]^=n[r]},blockSize:4,ivSize:2});function c(){for(var e=this._X,t=this._C,i=0;i<8;i++)o[i]=t[i];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<o[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<o[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<o[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<o[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<o[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<o[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<o[6]>>>0?1:0)|0,this._b=t[7]>>>0<o[7]>>>0?1:0,i=0;i<8;i++){var r=e[i]+t[i],n=65535&r,a=r>>>16,c=((n*n>>>17)+n*a>>>15)+a*a,l=((4294901760&r)*r|0)+((65535&r)*r|0);s[i]=c^l}e[0]=s[0]+(s[7]<<16|s[7]>>>16)+(s[6]<<16|s[6]>>>16)|0,e[1]=s[1]+(s[0]<<8|s[0]>>>24)+s[7]|0,e[2]=s[2]+(s[1]<<16|s[1]>>>16)+(s[0]<<16|s[0]>>>16)|0,e[3]=s[3]+(s[2]<<8|s[2]>>>24)+s[1]|0,e[4]=s[4]+(s[3]<<16|s[3]>>>16)+(s[2]<<16|s[2]>>>16)|0,e[5]=s[5]+(s[4]<<8|s[4]>>>24)+s[3]|0,e[6]=s[6]+(s[5]<<16|s[5]>>>16)+(s[4]<<16|s[4]>>>16)|0,e[7]=s[7]+(s[6]<<8|s[6]>>>24)+s[5]|0}e.Rabbit=t._createHelper(a)}(),i.Rabbit)})),oe((function(e,t){var i;e.exports=(i=se,function(){var e=i,t=e.lib.StreamCipher,r=e.algo,n=[],o=[],s=[],a=r.RabbitLegacy=t.extend({_doReset:function(){var e=this._key.words,t=this.cfg.iv,i=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],r=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];this._b=0;for(var n=0;n<4;n++)c.call(this);for(n=0;n<8;n++)r[n]^=i[n+4&7];if(t){var o=t.words,s=o[0],a=o[1],l=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),d=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),u=l>>>16|4294901760&d,h=d<<16|65535&l;for(r[0]^=l,r[1]^=u,r[2]^=d,r[3]^=h,r[4]^=l,r[5]^=u,r[6]^=d,r[7]^=h,n=0;n<4;n++)c.call(this)}},_doProcessBlock:function(e,t){var i=this._X;c.call(this),n[0]=i[0]^i[5]>>>16^i[3]<<16,n[1]=i[2]^i[7]>>>16^i[5]<<16,n[2]=i[4]^i[1]>>>16^i[7]<<16,n[3]=i[6]^i[3]>>>16^i[1]<<16;for(var r=0;r<4;r++)n[r]=16711935&(n[r]<<8|n[r]>>>24)|4278255360&(n[r]<<24|n[r]>>>8),e[t+r]^=n[r]},blockSize:4,ivSize:2});function c(){for(var e=this._X,t=this._C,i=0;i<8;i++)o[i]=t[i];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<o[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<o[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<o[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<o[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<o[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<o[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<o[6]>>>0?1:0)|0,this._b=t[7]>>>0<o[7]>>>0?1:0,i=0;i<8;i++){var r=e[i]+t[i],n=65535&r,a=r>>>16,c=((n*n>>>17)+n*a>>>15)+a*a,l=((4294901760&r)*r|0)+((65535&r)*r|0);s[i]=c^l}e[0]=s[0]+(s[7]<<16|s[7]>>>16)+(s[6]<<16|s[6]>>>16)|0,e[1]=s[1]+(s[0]<<8|s[0]>>>24)+s[7]|0,e[2]=s[2]+(s[1]<<16|s[1]>>>16)+(s[0]<<16|s[0]>>>16)|0,e[3]=s[3]+(s[2]<<8|s[2]>>>24)+s[1]|0,e[4]=s[4]+(s[3]<<16|s[3]>>>16)+(s[2]<<16|s[2]>>>16)|0,e[5]=s[5]+(s[4]<<8|s[4]>>>24)+s[3]|0,e[6]=s[6]+(s[5]<<16|s[5]>>>16)+(s[4]<<16|s[4]>>>16)|0,e[7]=s[7]+(s[6]<<8|s[6]>>>24)+s[5]|0}e.RabbitLegacy=t._createHelper(a)}(),i.RabbitLegacy)})),oe((function(e,t){e.exports=se})));function ce(){throw new Error("setTimeout has not been defined")}function le(){throw new Error("clearTimeout has not been defined")}var de=ce,ue=le;function he(e){if(de===setTimeout)return setTimeout(e,0);if((de===ce||!de)&&setTimeout)return de=setTimeout,setTimeout(e,0);try{return de(e,0)}catch(t){try{return de.call(null,e,0)}catch(i){return de.call(this,e,0)}}}"function"==typeof s.setTimeout&&(de=setTimeout),"function"==typeof s.clearTimeout&&(ue=clearTimeout);var pe,me=[],_e=!1,fe=-1;function ge(){_e&&pe&&(_e=!1,pe.length?me=pe.concat(me):fe=-1,me.length&&Ee())}function Ee(){if(!_e){var e=he(ge);_e=!0;for(var t=me.length;t;){for(pe=me,me=[];++fe<t;)pe&&pe[fe].run();fe=-1,t=me.length}pe=null,_e=!1,function(e){if(ue===clearTimeout)return clearTimeout(e);if((ue===le||!ue)&&clearTimeout)return ue=clearTimeout,clearTimeout(e);try{ue(e)}catch(t){try{return ue.call(null,e)}catch(i){return ue.call(this,e)}}}(e)}}function ve(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)t[i-1]=arguments[i];me.push(new ye(e,t)),1!==me.length||_e||he(Ee)}function ye(e,t){this.fun=e,this.array=t}ye.prototype.run=function(){this.fun.apply(null,this.array)};var Te=s.performance||{};function Se(){}function Ie(){Ie.init.call(this)}function Ae(e){return void 0===e._maxListeners?Ie.defaultMaxListeners:e._maxListeners}function Re(e,t,i,r){var n,o,s,a;if("function"!=typeof i)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,i.listener?i.listener:i),o=e._events),s=o[t]):(o=e._events=new Se,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=r?[i,s]:[s,i]:r?s.unshift(i):s.push(i),!s.warned&&(n=Ae(e))&&n>0&&s.length>n){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,a=c,"function"==typeof console.warn&&console.warn(a)}}else s=o[t]=i,++e._eventsCount;return e}function be(e,t,i){var r=!1;function n(){e.removeListener(t,n),r||(r=!0,i.apply(e,arguments))}return n.listener=i,n}function Ce(e){var t=this._events;if(t){var i=t[e];if("function"==typeof i)return 1;if(i)return i.length}return 0}function ke(e,t){for(var i=new Array(t);t--;)i[t]=e[t];return i}Te.now||Te.mozNow||Te.msNow||Te.oNow||Te.webkitNow,Se.prototype=Object.create(null),Ie.EventEmitter=Ie,Ie.usingDomains=!1,Ie.prototype.domain=void 0,Ie.prototype._events=void 0,Ie.prototype._maxListeners=void 0,Ie.defaultMaxListeners=10,Ie.init=function(){this.domain=null,Ie.usingDomains&&(void 0).active&&(void 0).Domain,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new Se,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Ie.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},Ie.prototype.getMaxListeners=function(){return Ae(this)},Ie.prototype.emit=function(e){var t,i,r,n,o,s,a,c="error"===e;if(s=this._events)c=c&&null==s.error;else if(!c)return!1;if(a=this.domain,c){if(t=arguments[1],!a){if(t instanceof Error)throw t;var l=new Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(i=s[e]))return!1;var d="function"==typeof i;switch(r=arguments.length){case 1:!function(e,t,i){if(t)e.call(i);else for(var r=e.length,n=ke(e,r),o=0;o<r;++o)n[o].call(i)}(i,d,this);break;case 2:!function(e,t,i,r){if(t)e.call(i,r);else for(var n=e.length,o=ke(e,n),s=0;s<n;++s)o[s].call(i,r)}(i,d,this,arguments[1]);break;case 3:!function(e,t,i,r,n){if(t)e.call(i,r,n);else for(var o=e.length,s=ke(e,o),a=0;a<o;++a)s[a].call(i,r,n)}(i,d,this,arguments[1],arguments[2]);break;case 4:!function(e,t,i,r,n,o){if(t)e.call(i,r,n,o);else for(var s=e.length,a=ke(e,s),c=0;c<s;++c)a[c].call(i,r,n,o)}(i,d,this,arguments[1],arguments[2],arguments[3]);break;default:for(n=new Array(r-1),o=1;o<r;o++)n[o-1]=arguments[o];!function(e,t,i,r){if(t)e.apply(i,r);else for(var n=e.length,o=ke(e,n),s=0;s<n;++s)o[s].apply(i,r)}(i,d,this,n)}return!0},Ie.prototype.addListener=function(e,t){return Re(this,e,t,!1)},Ie.prototype.on=Ie.prototype.addListener,Ie.prototype.prependListener=function(e,t){return Re(this,e,t,!0)},Ie.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,be(this,e,t)),this},Ie.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,be(this,e,t)),this},Ie.prototype.removeListener=function(e,t){var i,r,n,o,s;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(i=r[e]))return this;if(i===t||i.listener&&i.listener===t)0==--this._eventsCount?this._events=new Se:(delete r[e],r.removeListener&&this.emit("removeListener",e,i.listener||t));else if("function"!=typeof i){for(n=-1,o=i.length;o-- >0;)if(i[o]===t||i[o].listener&&i[o].listener===t){s=i[o].listener,n=o;break}if(n<0)return this;if(1===i.length){if(i[0]=void 0,0==--this._eventsCount)return this._events=new Se,this;delete r[e]}else!function(e,t){for(var i=t,r=i+1,n=e.length;r<n;i+=1,r+=1)e[i]=e[r];e.pop()}(i,n);r.removeListener&&this.emit("removeListener",e,s||t)}return this},Ie.prototype.removeAllListeners=function(e){var t,i;if(!(i=this._events))return this;if(!i.removeListener)return 0===arguments.length?(this._events=new Se,this._eventsCount=0):i[e]&&(0==--this._eventsCount?this._events=new Se:delete i[e]),this;if(0===arguments.length){for(var r,n=Object.keys(i),o=0;o<n.length;++o)"removeListener"!==(r=n[o])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=new Se,this._eventsCount=0,this}if("function"==typeof(t=i[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},Ie.prototype.listeners=function(e){var t,i=this._events;return i&&(t=i[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),i=0;i<t.length;++i)t[i]=e[i].listener||e[i];return t}(t):[]},Ie.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Ce.call(e,t)},Ie.prototype.listenerCount=Ce,Ie.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var we="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e},Ne=/%[sdj%]/g;function De(e){if(!We(e)){for(var t=[],i=0;i<arguments.length;i++)t.push(Me(arguments[i]));return t.join(" ")}i=1;for(var r=arguments,n=r.length,o=String(e).replace(Ne,(function(e){if("%%"===e)return"%";if(i>=n)return e;switch(e){case"%s":return String(r[i++]);case"%d":return Number(r[i++]);case"%j":try{return JSON.stringify(r[i++])}catch(t){return"[Circular]"}default:return e}})),s=r[i];i<n;s=r[++i])je(s)||!Ke(s)?o+=" "+s:o+=" "+Me(s);return o}function Oe(e,t){if(ze(s.process))return function(){return Oe(e,t).apply(this,arguments)};var i=!1;return function(){return i||(console.error(t),i=!0),e.apply(this,arguments)}}var Le,Pe={};function Me(e,t){var i={seen:[],stylize:Ve};return arguments.length>=3&&(i.depth=arguments[2]),arguments.length>=4&&(i.colors=arguments[3]),He(t)?i.showHidden=t:t&&function(e,t){if(!t||!Ke(t))return e;for(var i=Object.keys(t),r=i.length;r--;)e[i[r]]=t[i[r]]}(i,t),ze(i.showHidden)&&(i.showHidden=!1),ze(i.depth)&&(i.depth=2),ze(i.colors)&&(i.colors=!1),ze(i.customInspect)&&(i.customInspect=!0),i.colors&&(i.stylize=xe),Ue(i,e,i.depth)}function xe(e,t){var i=Me.styles[t];return i?"["+Me.colors[i][0]+"m"+e+"["+Me.colors[i][1]+"m":e}function Ve(e,t){return e}function Ue(e,t,i){if(e.customInspect&&t&&qe(t.inspect)&&t.inspect!==Me&&(!t.constructor||t.constructor.prototype!==t)){var r=t.inspect(i,e);return We(r)||(r=Ue(e,r,i)),r}var n=function(e,t){if(ze(t))return e.stylize("undefined","undefined");if(We(t)){var i="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(i,"string")}return"number"==typeof t?e.stylize(""+t,"number"):He(t)?e.stylize(""+t,"boolean"):je(t)?e.stylize("null","null"):void 0}(e,t);if(n)return n;var o,s=Object.keys(t),a=(o={},s.forEach((function(e,t){o[e]=!0})),o);if(e.showHidden&&(s=Object.getOwnPropertyNames(t)),Je(t)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return Be(t);if(0===s.length){if(qe(t)){var c=t.name?": "+t.name:"";return e.stylize("[Function"+c+"]","special")}if(Ge(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(Ye(t))return e.stylize(Date.prototype.toString.call(t),"date");if(Je(t))return Be(t)}var l,d,u="",h=!1,p=["{","}"];return l=t,Array.isArray(l)&&(h=!0,p=["[","]"]),qe(t)&&(u=" [Function"+(t.name?": "+t.name:"")+"]"),Ge(t)&&(u=" "+RegExp.prototype.toString.call(t)),Ye(t)&&(u=" "+Date.prototype.toUTCString.call(t)),Je(t)&&(u=" "+Be(t)),0!==s.length||h&&0!=t.length?i<0?Ge(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),d=h?function(e,t,i,r,n){for(var o=[],s=0,a=t.length;s<a;++s)Qe(t,String(s))?o.push(Fe(e,t,i,r,String(s),!0)):o.push("");return n.forEach((function(n){n.match(/^\d+$/)||o.push(Fe(e,t,i,r,n,!0))})),o}(e,t,i,a,s):s.map((function(r){return Fe(e,t,i,a,r,h)})),e.seen.pop(),function(e,t,i){return e.reduce((function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60?i[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+i[1]:i[0]+t+" "+e.join(", ")+" "+i[1]}(d,u,p)):p[0]+u+p[1]}function Be(e){return"["+Error.prototype.toString.call(e)+"]"}function Fe(e,t,i,r,n,o){var s,a,c;if((c=Object.getOwnPropertyDescriptor(t,n)||{value:t[n]}).get?a=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),Qe(r,n)||(s="["+n+"]"),a||(e.seen.indexOf(c.value)<0?(a=je(i)?Ue(e,c.value,null):Ue(e,c.value,i-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),ze(s)){if(o&&n.match(/^\d+$/))return a;(s=JSON.stringify(""+n)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function He(e){return"boolean"==typeof e}function je(e){return null===e}function We(e){return"string"==typeof e}function ze(e){return void 0===e}function Ge(e){return Ke(e)&&"[object RegExp]"===Xe(e)}function Ke(e){return"object"==typeof e&&null!==e}function Ye(e){return Ke(e)&&"[object Date]"===Xe(e)}function Je(e){return Ke(e)&&("[object Error]"===Xe(e)||e instanceof Error)}function qe(e){return"function"==typeof e}function Xe(e){return Object.prototype.toString.call(e)}function Qe(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Ze(){this.head=null,this.tail=null,this.length=0}Me.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},Me.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Ze.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},Ze.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Ze.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},Ze.prototype.clear=function(){this.head=this.tail=null,this.length=0},Ze.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,i=""+t.data;t=t.next;)i+=e+t.data;return i},Ze.prototype.concat=function(e){if(0===this.length)return y.alloc(0);if(1===this.length)return this.head.data;for(var t=y.allocUnsafe(e>>>0),i=this.head,r=0;i;)i.data.copy(t,r),r+=i.data.length,i=i.next;return t};var $e=y.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function et(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!$e(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=it;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=rt;break;default:return void(this.write=tt)}this.charBuffer=new y(6),this.charReceived=0,this.charLength=0}function tt(e){return e.toString(this.encoding)}function it(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function rt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}et.prototype.write=function(e){for(var t="";this.charLength;){var i=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,i),this.charReceived+=i,this.charReceived<this.charLength)return"";if(e=e.slice(i,e.length),!((r=(t=this.charBuffer.slice(0,this.charLength).toString(this.encoding)).charCodeAt(t.length-1))>=55296&&r<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var r,n=e.length;if(this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived),n=(t+=e.toString(this.encoding,0,n)).length-1,(r=t.charCodeAt(n))>=55296&&r<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},et.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var i=e[e.length-t];if(1==t&&i>>5==6){this.charLength=2;break}if(t<=2&&i>>4==14){this.charLength=3;break}if(t<=3&&i>>3==30){this.charLength=4;break}}this.charReceived=t},et.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var i=this.charReceived,r=this.charBuffer,n=this.encoding;t+=r.slice(0,i).toString(n)}return t},at.ReadableState=st;var nt,ot=(nt="stream",ze(Le)&&(Le=""),nt=nt.toUpperCase(),Pe[nt]||(new RegExp("\\b"+nt+"\\b","i").test(Le)?Pe[nt]=function(){var e=De.apply(null,arguments);console.error("%s %d: %s",nt,0,e)}:Pe[nt]=function(){}),Pe[nt]);function st(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof Mt&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var i=e.highWaterMark,r=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r,this.highWaterMark=~~this.highWaterMark,this.buffer=new Ze,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new et(e.encoding),this.encoding=e.encoding)}function at(e){if(!(this instanceof at))return new at(e);this._readableState=new st(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),Ie.call(this)}function ct(e,t,i,r,n){var o,s,a,c=(o=t,a=null,re(s=i)||"string"==typeof s||null==s||o.objectMode||(a=new TypeError("Invalid non-string/buffer chunk")),a);if(c)e.emit("error",c);else if(null===i)t.reading=!1,function(e,t){if(!t.ended){if(t.decoder){var i=t.decoder.end();i&&i.length&&(t.buffer.push(i),t.length+=t.objectMode?1:i.length)}t.ended=!0,ut(e)}}(e,t);else if(t.objectMode||i&&i.length>0)if(t.ended&&!n){var l=new Error("stream.push() after EOF");e.emit("error",l)}else if(t.endEmitted&&n){var d=new Error("stream.unshift() after end event");e.emit("error",d)}else{var u;!t.decoder||n||r||(i=t.decoder.write(i),u=!t.objectMode&&0===i.length),n||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",i),e.read(0)):(t.length+=t.objectMode?1:i.length,n?t.buffer.unshift(i):t.buffer.push(i),t.needReadable&&ut(e))),function(e,t){t.readingMore||(t.readingMore=!0,ve(pt,e,t))}(e,t)}else n||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||0===e.length)}(t)}we(at,Ie),at.prototype.push=function(e,t){var i=this._readableState;return i.objectMode||"string"!=typeof e||(t=t||i.defaultEncoding)!==i.encoding&&(e=y.from(e,t),t=""),ct(this,i,e,t,!1)},at.prototype.unshift=function(e){return ct(this,this._readableState,e,"",!0)},at.prototype.isPaused=function(){return!1===this._readableState.flowing},at.prototype.setEncoding=function(e){return this._readableState.decoder=new et(e),this._readableState.encoding=e,this};var lt=8388608;function dt(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=((i=e)>=lt?i=lt:(i--,i|=i>>>1,i|=i>>>2,i|=i>>>4,i|=i>>>8,i|=i>>>16,i++),i)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0));var i}function ut(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(ot("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?ve(ht,e):ht(e))}function ht(e){ot("emit readable"),e.emit("readable"),ft(e)}function pt(e,t){for(var i=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(ot("maybeReadMore read 0"),e.read(0),i!==t.length);)i=t.length;t.readingMore=!1}function mt(e){ot("readable nexttick read 0"),e.read(0)}function _t(e,t){t.reading||(ot("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),ft(e),t.flowing&&!t.reading&&e.read(0)}function ft(e){var t=e._readableState;for(ot("flow",t.flowing);t.flowing&&null!==e.read(););}function gt(e,t){return 0===t.length?null:(t.objectMode?s=t.buffer.shift():!e||e>=t.length?(s=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):(i=e,r=t.buffer,n=t.decoder,i<r.head.data.length?(o=r.head.data.slice(0,i),r.head.data=r.head.data.slice(i)):o=i===r.head.data.length?r.shift():n?function(e,t){var i=t.head,r=1,n=i.data;for(e-=n.length;i=i.next;){var o=i.data,s=e>o.length?o.length:e;if(s===o.length?n+=o:n+=o.slice(0,e),0==(e-=s)){s===o.length?(++r,i.next?t.head=i.next:t.head=t.tail=null):(t.head=i,i.data=o.slice(s));break}++r}return t.length-=r,n}(i,r):function(e,t){var i=y.allocUnsafe(e),r=t.head,n=1;for(r.data.copy(i),e-=r.data.length;r=r.next;){var o=r.data,s=e>o.length?o.length:e;if(o.copy(i,i.length-e,0,s),0==(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(i,r),s=o),s);var i,r,n,o,s}function Et(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,ve(vt,t,e))}function vt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function yt(e,t){for(var i=0,r=e.length;i<r;i++)if(e[i]===t)return i;return-1}function Tt(){}function St(e,t,i){this.chunk=e,this.encoding=t,this.callback=i,this.next=null}function It(e,t){Object.defineProperty(this,"buffer",{get:Oe((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")}),e=e||{},this.objectMode=!!e.objectMode,t instanceof Mt&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,r=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var n=!1===e.decodeStrings;this.decodeStrings=!n,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var i,r=e._writableState,n=r.sync,o=r.writecb;if((i=r).writing=!1,i.writecb=null,i.length-=i.writelen,i.writelen=0,t)!function(e,t,i,r,n){--t.pendingcb,i?ve(n,r):n(r),e._writableState.errorEmitted=!0,e.emit("error",r)}(e,r,n,t,o);else{var s=kt(r);s||r.corked||r.bufferProcessing||!r.bufferedRequest||Ct(e,r),n?ve(bt,e,r,s,o):bt(e,r,s,o)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new Dt(this)}function At(e){if(!(this instanceof At||this instanceof Mt))return new At(e);this._writableState=new It(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev)),Ie.call(this)}function Rt(e,t,i,r,n,o,s){t.writelen=r,t.writecb=s,t.writing=!0,t.sync=!0,i?e._writev(n,t.onwrite):e._write(n,o,t.onwrite),t.sync=!1}function bt(e,t,i,r){var n,o;i||(n=e,0===(o=t).length&&o.needDrain&&(o.needDrain=!1,n.emit("drain"))),t.pendingcb--,r(),Nt(e,t)}function Ct(e,t){t.bufferProcessing=!0;var i=t.bufferedRequest;if(e._writev&&i&&i.next){var r=t.bufferedRequestCount,n=new Array(r),o=t.corkedRequestsFree;o.entry=i;for(var s=0;i;)n[s]=i,i=i.next,s+=1;Rt(e,t,!0,t.length,n,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new Dt(t)}else{for(;i;){var a=i.chunk,c=i.encoding,l=i.callback;if(Rt(e,t,!1,t.objectMode?1:a.length,a,c,l),i=i.next,t.writing)break}null===i&&(t.lastBufferedRequest=null)}t.bufferedRequestCount=0,t.bufferedRequest=i,t.bufferProcessing=!1}function kt(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function wt(e,t){t.prefinished||(t.prefinished=!0,e.emit("prefinish"))}function Nt(e,t){var i=kt(t);return i&&(0===t.pendingcb?(wt(e,t),t.finished=!0,e.emit("finish")):wt(e,t)),i}function Dt(e){var t=this;this.next=null,this.entry=null,this.finish=function(i){var r=t.entry;for(t.entry=null;r;){var n=r.callback;e.pendingcb--,n(i),r=r.next}e.corkedRequestsFree?e.corkedRequestsFree.next=t:e.corkedRequestsFree=t}}at.prototype.read=function(e){ot("read",e),e=parseInt(e,10);var t=this._readableState,i=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return ot("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Et(this):ut(this),null;if(0===(e=dt(e,t))&&t.ended)return 0===t.length&&Et(this),null;var r,n=t.needReadable;return ot("need readable",n),(0===t.length||t.length-e<t.highWaterMark)&&ot("length less than watermark",n=!0),t.ended||t.reading?ot("reading or ended",n=!1):n&&(ot("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=dt(i,t))),null===(r=e>0?gt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),i!==e&&t.ended&&Et(this)),null!==r&&this.emit("data",r),r},at.prototype._read=function(e){this.emit("error",new Error("not implemented"))},at.prototype.pipe=function(e,t){var i=this,r=this._readableState;switch(r.pipesCount){case 0:r.pipes=e;break;case 1:r.pipes=[r.pipes,e];break;default:r.pipes.push(e)}r.pipesCount+=1,ot("pipe count=%d opts=%j",r.pipesCount,t);var n=t&&!1===t.end?l:s;function o(e){ot("onunpipe"),e===i&&l()}function s(){ot("onend"),e.end()}r.endEmitted?ve(n):i.once("end",n),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;ot("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,ft(e))}}(i);e.on("drain",a);var c=!1;function l(){ot("cleanup"),e.removeListener("close",p),e.removeListener("finish",m),e.removeListener("drain",a),e.removeListener("error",h),e.removeListener("unpipe",o),i.removeListener("end",s),i.removeListener("end",l),i.removeListener("data",u),c=!0,!r.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var d=!1;function u(t){ot("ondata"),d=!1,!1!==e.write(t)||d||((1===r.pipesCount&&r.pipes===e||r.pipesCount>1&&-1!==yt(r.pipes,e))&&!c&&(ot("false write response, pause",i._readableState.awaitDrain),i._readableState.awaitDrain++,d=!0),i.pause())}function h(t){ot("onerror",t),_(),e.removeListener("error",h),0===("error",e.listeners("error").length)&&e.emit("error",t)}function p(){e.removeListener("finish",m),_()}function m(){ot("onfinish"),e.removeListener("close",p),_()}function _(){ot("unpipe"),i.unpipe(e)}return i.on("data",u),function(e,t,i){if("function"==typeof e.prependListener)return e.prependListener(t,i);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(i):e._events[t]=[i,e._events[t]]:e.on(t,i)}(e,"error",h),e.once("close",p),e.once("finish",m),e.emit("pipe",i),r.flowing||(ot("pipe resume"),i.resume()),e},at.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var i=t.pipes,r=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var n=0;n<r;n++)i[n].emit("unpipe",this);return this}var o=yt(t.pipes,e);return-1===o||(t.pipes.splice(o,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this)),this},at.prototype.on=function(e,t){var i=Ie.prototype.on.call(this,e,t);if("data"===e)!1!==this._readableState.flowing&&this.resume();else if("readable"===e){var r=this._readableState;r.endEmitted||r.readableListening||(r.readableListening=r.needReadable=!0,r.emittedReadable=!1,r.reading?r.length&&ut(this):ve(mt,this))}return i},at.prototype.addListener=at.prototype.on,at.prototype.resume=function(){var e,t,i=this._readableState;return i.flowing||(ot("resume"),i.flowing=!0,e=this,(t=i).resumeScheduled||(t.resumeScheduled=!0,ve(_t,e,t))),this},at.prototype.pause=function(){return ot("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(ot("pause"),this._readableState.flowing=!1,this.emit("pause")),this},at.prototype.wrap=function(e){var t=this._readableState,i=!1,r=this;for(var n in e.on("end",(function(){if(ot("wrapped end"),t.decoder&&!t.ended){var e=t.decoder.end();e&&e.length&&r.push(e)}r.push(null)})),e.on("data",(function(n){ot("wrapped data"),t.decoder&&(n=t.decoder.write(n)),t.objectMode&&null==n||(t.objectMode||n&&n.length)&&(r.push(n)||(i=!0,e.pause()))})),e)void 0===this[n]&&"function"==typeof e[n]&&(this[n]=function(t){return function(){return e[t].apply(e,arguments)}}(n));return function(e,t){for(var i=0,r=e.length;i<r;i++)t(e[i])}(["error","close","destroy","pause","resume"],(function(t){e.on(t,r.emit.bind(r,t))})),r._read=function(t){ot("wrapped _read",t),i&&(i=!1,e.resume())},r},at._fromList=gt,At.WritableState=It,we(At,Ie),It.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},At.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},At.prototype.write=function(e,t,i){var r,n,o,s=this._writableState,a=!1;return"function"==typeof t&&(i=t,t=null),y.isBuffer(e)?t="buffer":t||(t=s.defaultEncoding),"function"!=typeof i&&(i=Tt),s.ended?(r=this,n=i,o=new Error("write after end"),r.emit("error",o),ve(n,o)):function(e,t,i,r){var n=!0,o=!1;return null===i?o=new TypeError("May not write null values to stream"):y.isBuffer(i)||"string"==typeof i||void 0===i||t.objectMode||(o=new TypeError("Invalid non-string/buffer chunk")),o&&(e.emit("error",o),ve(r,o),n=!1),n}(this,s,e,i)&&(s.pendingcb++,a=function(e,t,i,r,n){var o,s,a;s=i,a=r,(o=t).objectMode||!1===o.decodeStrings||"string"!=typeof s||(s=y.from(s,a)),i=s,y.isBuffer(i)&&(r="buffer");var c=t.objectMode?1:i.length;t.length+=c;var l=t.length<t.highWaterMark;if(l||(t.needDrain=!0),t.writing||t.corked){var d=t.lastBufferedRequest;t.lastBufferedRequest=new St(i,r,n),d?d.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else Rt(e,t,!1,c,i,r,n);return l}(this,s,e,t,i)),a},At.prototype.cork=function(){this._writableState.corked++},At.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||Ct(this,e))},At.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},At.prototype._write=function(e,t,i){i(new Error("not implemented"))},At.prototype._writev=null,At.prototype.end=function(e,t,i){var r,n,o,s=this._writableState;"function"==typeof e?(i=e,e=null,t=null):"function"==typeof t&&(i=t,t=null),null!=e&&this.write(e,t),s.corked&&(s.corked=1,this.uncork()),s.ending||s.finished||(r=this,o=i,(n=s).ending=!0,Nt(r,n),o&&(n.finished?ve(o):r.once("finish",o)),n.ended=!0,r.writable=!1)},we(Mt,at);for(var Ot=Object.keys(At.prototype),Lt=0;Lt<Ot.length;Lt++){var Pt=Ot[Lt];Mt.prototype[Pt]||(Mt.prototype[Pt]=At.prototype[Pt])}function Mt(e){if(!(this instanceof Mt))return new Mt(e);at.call(this,e),At.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",xt)}function xt(){this.allowHalfOpen||this._writableState.ended||ve(Vt,this)}function Vt(e){e.end()}function Ut(e){this.afterTransform=function(t,i){return function(e,t,i){var r=e._transformState;r.transforming=!1;var n=r.writecb;if(!n)return e.emit("error",new Error("no writecb in Transform class"));r.writechunk=null,r.writecb=null,null!=i&&e.push(i),n(t);var o=e._readableState;o.reading=!1,(o.needReadable||o.length<o.highWaterMark)&&e._read(o.highWaterMark)}(e,t,i)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null,this.writeencoding=null}function Bt(e){if(!(this instanceof Bt))return new Bt(e);Mt.call(this,e),this._transformState=new Ut(this);var t=this;this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.once("prefinish",(function(){"function"==typeof this._flush?this._flush((function(e){Ft(t,e)})):Ft(t)}))}function Ft(e,t){if(t)return e.emit("error",t);var i=e._writableState,r=e._transformState;if(i.length)throw new Error("Calling transform done when ws.length != 0");if(r.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}function Ht(e){if(!(this instanceof Ht))return new Ht(e);Bt.call(this,e)}function jt(){Ie.call(this)}we(Bt,Mt),Bt.prototype.push=function(e,t){return this._transformState.needTransform=!1,Mt.prototype.push.call(this,e,t)},Bt.prototype._transform=function(e,t,i){throw new Error("Not implemented")},Bt.prototype._write=function(e,t,i){var r=this._transformState;if(r.writecb=i,r.writechunk=e,r.writeencoding=t,!r.transforming){var n=this._readableState;(r.needTransform||n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}},Bt.prototype._read=function(e){var t=this._transformState;null!==t.writechunk&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0},we(Ht,Bt),Ht.prototype._transform=function(e,t,i){i(null,e)},we(jt,Ie),jt.Readable=at,jt.Writable=At,jt.Duplex=Mt,jt.Transform=Bt,jt.PassThrough=Ht,jt.Stream=jt,jt.prototype.pipe=function(e,t){var i=this;function r(t){e.writable&&!1===e.write(t)&&i.pause&&i.pause()}function n(){i.readable&&i.resume&&i.resume()}i.on("data",r),e.on("drain",n),e._isStdio||t&&!1===t.end||(i.on("end",s),i.on("close",a));var o=!1;function s(){o||(o=!0,e.end())}function a(){o||(o=!0,"function"==typeof e.destroy&&e.destroy())}function c(e){if(l(),0===Ie.listenerCount(this,"error"))throw e}function l(){i.removeListener("data",r),e.removeListener("drain",n),i.removeListener("end",s),i.removeListener("close",a),i.removeListener("error",c),e.removeListener("error",c),i.removeListener("end",l),i.removeListener("close",l),e.removeListener("close",l)}return i.on("error",c),e.on("error",c),i.on("end",l),i.on("close",l),e.on("close",l),e.emit("pipe",i),e};var Wt={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};function zt(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}function Gt(e,t,i,r,n){if(t.subarray&&e.subarray)e.set(t.subarray(i,i+r),n);else for(var o=0;o<r;o++)e[n+o]=t[i+o]}var Kt=Uint8Array,Yt=Uint16Array,Jt=Int32Array,qt=4,Xt=0,Qt=1,Zt=2;function $t(e){for(var t=e.length;--t>=0;)e[t]=0}var ei=0,ti=1,ii=2,ri=29,ni=256,oi=ni+1+ri,si=30,ai=19,ci=2*oi+1,li=15,di=16,ui=7,hi=256,pi=16,mi=17,_i=18,fi=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],gi=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Ei=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],vi=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],yi=new Array(2*(oi+2));$t(yi);var Ti=new Array(2*si);$t(Ti);var Si=new Array(512);$t(Si);var Ii=new Array(256);$t(Ii);var Ai=new Array(ri);$t(Ai);var Ri,bi,Ci,ki=new Array(si);function wi(e,t,i,r,n){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=r,this.max_length=n,this.has_stree=e&&e.length}function Ni(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function Di(e){return e<256?Si[e]:Si[256+(e>>>7)]}function Oi(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function Li(e,t,i){e.bi_valid>di-i?(e.bi_buf|=t<<e.bi_valid&65535,Oi(e,e.bi_buf),e.bi_buf=t>>di-e.bi_valid,e.bi_valid+=i-di):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=i)}function Pi(e,t,i){Li(e,i[2*t],i[2*t+1])}function Mi(e,t){var i=0;do{i|=1&e,e>>>=1,i<<=1}while(--t>0);return i>>>1}function xi(e,t,i){var r,n,o=new Array(li+1),s=0;for(r=1;r<=li;r++)o[r]=s=s+i[r-1]<<1;for(n=0;n<=t;n++){var a=e[2*n+1];0!==a&&(e[2*n]=Mi(o[a]++,a))}}function Vi(e){var t;for(t=0;t<oi;t++)e.dyn_ltree[2*t]=0;for(t=0;t<si;t++)e.dyn_dtree[2*t]=0;for(t=0;t<ai;t++)e.bl_tree[2*t]=0;e.dyn_ltree[2*hi]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function Ui(e){e.bi_valid>8?Oi(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function Bi(e,t,i,r){var n=2*t,o=2*i;return e[n]<e[o]||e[n]===e[o]&&r[t]<=r[i]}function Fi(e,t,i){for(var r=e.heap[i],n=i<<1;n<=e.heap_len&&(n<e.heap_len&&Bi(t,e.heap[n+1],e.heap[n],e.depth)&&n++,!Bi(t,r,e.heap[n],e.depth));)e.heap[i]=e.heap[n],i=n,n<<=1;e.heap[i]=r}function Hi(e,t,i){var r,n,o,s,a=0;if(0!==e.last_lit)do{r=e.pending_buf[e.d_buf+2*a]<<8|e.pending_buf[e.d_buf+2*a+1],n=e.pending_buf[e.l_buf+a],a++,0===r?Pi(e,n,t):(Pi(e,(o=Ii[n])+ni+1,t),0!==(s=fi[o])&&Li(e,n-=Ai[o],s),Pi(e,o=Di(--r),i),0!==(s=gi[o])&&Li(e,r-=ki[o],s))}while(a<e.last_lit);Pi(e,hi,t)}function ji(e,t){var i,r,n,o=t.dyn_tree,s=t.stat_desc.static_tree,a=t.stat_desc.has_stree,c=t.stat_desc.elems,l=-1;for(e.heap_len=0,e.heap_max=ci,i=0;i<c;i++)0!==o[2*i]?(e.heap[++e.heap_len]=l=i,e.depth[i]=0):o[2*i+1]=0;for(;e.heap_len<2;)o[2*(n=e.heap[++e.heap_len]=l<2?++l:0)]=1,e.depth[n]=0,e.opt_len--,a&&(e.static_len-=s[2*n+1]);for(t.max_code=l,i=e.heap_len>>1;i>=1;i--)Fi(e,o,i);n=c;do{i=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Fi(e,o,1),r=e.heap[1],e.heap[--e.heap_max]=i,e.heap[--e.heap_max]=r,o[2*n]=o[2*i]+o[2*r],e.depth[n]=(e.depth[i]>=e.depth[r]?e.depth[i]:e.depth[r])+1,o[2*i+1]=o[2*r+1]=n,e.heap[1]=n++,Fi(e,o,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var i,r,n,o,s,a,c=t.dyn_tree,l=t.max_code,d=t.stat_desc.static_tree,u=t.stat_desc.has_stree,h=t.stat_desc.extra_bits,p=t.stat_desc.extra_base,m=t.stat_desc.max_length,_=0;for(o=0;o<=li;o++)e.bl_count[o]=0;for(c[2*e.heap[e.heap_max]+1]=0,i=e.heap_max+1;i<ci;i++)(o=c[2*c[2*(r=e.heap[i])+1]+1]+1)>m&&(o=m,_++),c[2*r+1]=o,r>l||(e.bl_count[o]++,s=0,r>=p&&(s=h[r-p]),a=c[2*r],e.opt_len+=a*(o+s),u&&(e.static_len+=a*(d[2*r+1]+s)));if(0!==_){do{for(o=m-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[m]--,_-=2}while(_>0);for(o=m;0!==o;o--)for(r=e.bl_count[o];0!==r;)(n=e.heap[--i])>l||(c[2*n+1]!==o&&(e.opt_len+=(o-c[2*n+1])*c[2*n],c[2*n+1]=o),r--)}}(e,t),xi(o,l,e.bl_count)}function Wi(e,t,i){var r,n,o=-1,s=t[1],a=0,c=7,l=4;for(0===s&&(c=138,l=3),t[2*(i+1)+1]=65535,r=0;r<=i;r++)n=s,s=t[2*(r+1)+1],++a<c&&n===s||(a<l?e.bl_tree[2*n]+=a:0!==n?(n!==o&&e.bl_tree[2*n]++,e.bl_tree[2*pi]++):a<=10?e.bl_tree[2*mi]++:e.bl_tree[2*_i]++,a=0,o=n,0===s?(c=138,l=3):n===s?(c=6,l=3):(c=7,l=4))}function zi(e,t,i){var r,n,o=-1,s=t[1],a=0,c=7,l=4;for(0===s&&(c=138,l=3),r=0;r<=i;r++)if(n=s,s=t[2*(r+1)+1],!(++a<c&&n===s)){if(a<l)do{Pi(e,n,e.bl_tree)}while(0!=--a);else 0!==n?(n!==o&&(Pi(e,n,e.bl_tree),a--),Pi(e,pi,e.bl_tree),Li(e,a-3,2)):a<=10?(Pi(e,mi,e.bl_tree),Li(e,a-3,3)):(Pi(e,_i,e.bl_tree),Li(e,a-11,7));a=0,o=n,0===s?(c=138,l=3):n===s?(c=6,l=3):(c=7,l=4)}}$t(ki);var Gi=!1;function Ki(e,t,i,r){var n,o,s;Li(e,(ei<<1)+(r?1:0),3),o=t,s=i,Ui(n=e),Oi(n,s),Oi(n,~s),Gt(n.pending_buf,n.window,o,s,n.pending),n.pending+=s}function Yi(e,t,i){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&i,e.last_lit++,0===t?e.dyn_ltree[2*i]++:(e.matches++,t--,e.dyn_ltree[2*(Ii[i]+ni+1)]++,e.dyn_dtree[2*Di(t)]++),e.last_lit===e.lit_bufsize-1}function Ji(e,t,i,r){for(var n=65535&e,o=e>>>16&65535,s=0;0!==i;){i-=s=i>2e3?2e3:i;do{o=o+(n=n+t[r++]|0)|0}while(--s);n%=65521,o%=65521}return n|o<<16}var qi=function(){for(var e,t=[],i=0;i<256;i++){e=i;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t}();function Xi(e,t,i,r){var n=qi,o=r+i;e^=-1;for(var s=r;s<o;s++)e=e>>>8^n[255&(e^t[s])];return~e}var Qi,Zi=-2,$i=3,er=258,tr=er+$i+1,ir=103,rr=113,nr=666;function or(e,t){return e.msg=Wt[t],t}function sr(e){return(e<<1)-(e>4?9:0)}function ar(e){for(var t=e.length;--t>=0;)e[t]=0}function cr(e){var t=e.state,i=t.pending;i>e.avail_out&&(i=e.avail_out),0!==i&&(Gt(e.output,t.pending_buf,t.pending_out,i,e.next_out),e.next_out+=i,t.pending_out+=i,e.total_out+=i,e.avail_out-=i,t.pending-=i,0===t.pending&&(t.pending_out=0))}function lr(e,t){(function(e,t,i,r){var n,o,s=0;e.level>0?(e.strm.data_type===Zt&&(e.strm.data_type=function(e){var t,i=4093624447;for(t=0;t<=31;t++,i>>>=1)if(1&i&&0!==e.dyn_ltree[2*t])return Xt;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return Qt;for(t=32;t<ni;t++)if(0!==e.dyn_ltree[2*t])return Qt;return Xt}(e)),ji(e,e.l_desc),ji(e,e.d_desc),s=function(e){var t;for(Wi(e,e.dyn_ltree,e.l_desc.max_code),Wi(e,e.dyn_dtree,e.d_desc.max_code),ji(e,e.bl_desc),t=ai-1;t>=3&&0===e.bl_tree[2*vi[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),n=e.opt_len+3+7>>>3,(o=e.static_len+3+7>>>3)<=n&&(n=o)):n=o=i+5,i+4<=n&&-1!==t?Ki(e,t,i,r):e.strategy===qt||o===n?(Li(e,(ti<<1)+(r?1:0),3),Hi(e,yi,Ti)):(Li(e,(ii<<1)+(r?1:0),3),function(e,t,i,r){var n;for(Li(e,t-257,5),Li(e,i-1,5),Li(e,r-4,4),n=0;n<r;n++)Li(e,e.bl_tree[2*vi[n]+1],3);zi(e,e.dyn_ltree,t-1),zi(e,e.dyn_dtree,i-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),Hi(e,e.dyn_ltree,e.dyn_dtree)),Vi(e),r&&Ui(e)})(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,cr(e.strm)}function dr(e,t){e.pending_buf[e.pending++]=t}function ur(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function hr(e,t){var i,r,n=e.max_chain_length,o=e.strstart,s=e.prev_length,a=e.nice_match,c=e.strstart>e.w_size-tr?e.strstart-(e.w_size-tr):0,l=e.window,d=e.w_mask,u=e.prev,h=e.strstart+er,p=l[o+s-1],m=l[o+s];e.prev_length>=e.good_match&&(n>>=2),a>e.lookahead&&(a=e.lookahead);do{if(l[(i=t)+s]===m&&l[i+s-1]===p&&l[i]===l[o]&&l[++i]===l[o+1]){o+=2,i++;do{}while(l[++o]===l[++i]&&l[++o]===l[++i]&&l[++o]===l[++i]&&l[++o]===l[++i]&&l[++o]===l[++i]&&l[++o]===l[++i]&&l[++o]===l[++i]&&l[++o]===l[++i]&&o<h);if(r=er-(h-o),o=h-er,r>s){if(e.match_start=t,s=r,r>=a)break;p=l[o+s-1],m=l[o+s]}}}while((t=u[t&d])>c&&0!=--n);return s<=e.lookahead?s:e.lookahead}function pr(e){var t,i,r,n,o,s,a,c,l,d,u=e.w_size;do{if(n=e.window_size-e.lookahead-e.strstart,e.strstart>=u+(u-tr)){Gt(e.window,e.window,u,u,0),e.match_start-=u,e.strstart-=u,e.block_start-=u,t=i=e.hash_size;do{r=e.head[--t],e.head[t]=r>=u?r-u:0}while(--i);t=i=u;do{r=e.prev[--t],e.prev[t]=r>=u?r-u:0}while(--i);n+=u}if(0===e.strm.avail_in)break;if(s=e.strm,a=e.window,c=e.strstart+e.lookahead,l=n,d=void 0,(d=s.avail_in)>l&&(d=l),i=0===d?0:(s.avail_in-=d,Gt(a,s.input,s.next_in,d,c),1===s.state.wrap?s.adler=Ji(s.adler,a,d,c):2===s.state.wrap&&(s.adler=Xi(s.adler,a,d,c)),s.next_in+=d,s.total_in+=d,d),e.lookahead+=i,e.lookahead+e.insert>=$i)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+$i-1])&e.hash_mask,e.prev[o&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=o,o++,e.insert--,!(e.lookahead+e.insert<$i)););}while(e.lookahead<tr&&0!==e.strm.avail_in)}function mr(e,t){for(var i,r;;){if(e.lookahead<tr){if(pr(e),e.lookahead<tr&&0===t)return 1;if(0===e.lookahead)break}if(i=0,e.lookahead>=$i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+$i-1])&e.hash_mask,i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==i&&e.strstart-i<=e.w_size-tr&&(e.match_length=hr(e,i)),e.match_length>=$i)if(r=Yi(e,e.strstart-e.match_start,e.match_length-$i),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=$i){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+$i-1])&e.hash_mask,i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else r=Yi(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(lr(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<$i-1?e.strstart:$i-1,4===t?(lr(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(lr(e,!1),0===e.strm.avail_out)?1:2}function _r(e,t){for(var i,r,n;;){if(e.lookahead<tr){if(pr(e),e.lookahead<tr&&0===t)return 1;if(0===e.lookahead)break}if(i=0,e.lookahead>=$i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+$i-1])&e.hash_mask,i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=$i-1,0!==i&&e.prev_length<e.max_lazy_match&&e.strstart-i<=e.w_size-tr&&(e.match_length=hr(e,i),e.match_length<=5&&(1===e.strategy||e.match_length===$i&&e.strstart-e.match_start>4096)&&(e.match_length=$i-1)),e.prev_length>=$i&&e.match_length<=e.prev_length){n=e.strstart+e.lookahead-$i,r=Yi(e,e.strstart-1-e.prev_match,e.prev_length-$i),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=n&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+$i-1])&e.hash_mask,i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=$i-1,e.strstart++,r&&(lr(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((r=Yi(e,0,e.window[e.strstart-1]))&&lr(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=Yi(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<$i-1?e.strstart:$i-1,4===t?(lr(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(lr(e,!1),0===e.strm.avail_out)?1:2}function fr(e,t,i,r,n){this.good_length=e,this.max_lazy=t,this.nice_length=i,this.max_chain=r,this.func=n}function gr(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Yt(1146),this.dyn_dtree=new Yt(122),this.bl_tree=new Yt(78),ar(this.dyn_ltree),ar(this.dyn_dtree),ar(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Yt(16),this.heap=new Yt(573),ar(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Yt(573),ar(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function Er(e){var t,i,r,n=(i=e)&&i.state?(i.total_in=i.total_out=0,i.data_type=2,(r=i.state).pending=0,r.pending_out=0,r.wrap<0&&(r.wrap=-r.wrap),r.status=r.wrap?42:rr,i.adler=2===r.wrap?0:1,r.last_flush=0,function(e){Gi||(function(){var e,t,i,r,n,o=new Array(li+1);for(i=0,r=0;r<ri-1;r++)for(Ai[r]=i,e=0;e<1<<fi[r];e++)Ii[i++]=r;for(Ii[i-1]=r,n=0,r=0;r<16;r++)for(ki[r]=n,e=0;e<1<<gi[r];e++)Si[n++]=r;for(n>>=7;r<si;r++)for(ki[r]=n<<7,e=0;e<1<<gi[r]-7;e++)Si[256+n++]=r;for(t=0;t<=li;t++)o[t]=0;for(e=0;e<=143;)yi[2*e+1]=8,e++,o[8]++;for(;e<=255;)yi[2*e+1]=9,e++,o[9]++;for(;e<=279;)yi[2*e+1]=7,e++,o[7]++;for(;e<=287;)yi[2*e+1]=8,e++,o[8]++;for(xi(yi,oi+1,o),e=0;e<si;e++)Ti[2*e+1]=5,Ti[2*e]=Mi(e,5);Ri=new wi(yi,fi,ni+1,oi,li),bi=new wi(Ti,gi,0,si,li),Ci=new wi(new Array(0),Ei,0,ai,ui)}(),Gi=!0),e.l_desc=new Ni(e.dyn_ltree,Ri),e.d_desc=new Ni(e.dyn_dtree,bi),e.bl_desc=new Ni(e.bl_tree,Ci),e.bi_buf=0,e.bi_valid=0,Vi(e)}(r),0):or(i,Zi);return 0===n&&((t=e.state).window_size=2*t.w_size,ar(t.head),t.max_lazy_match=Qi[t.level].max_lazy,t.good_match=Qi[t.level].good_length,t.nice_match=Qi[t.level].nice_length,t.max_chain_length=Qi[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=$i-1,t.match_available=0,t.ins_h=0),n}function vr(e,t){var i,r,n,o;if(!e||!e.state||t>5||t<0)return e?or(e,Zi):Zi;if(r=e.state,!e.output||!e.input&&0!==e.avail_in||r.status===nr&&4!==t)return or(e,0===e.avail_out?-5:Zi);if(r.strm=e,i=r.last_flush,r.last_flush=t,42===r.status)if(2===r.wrap)e.adler=0,dr(r,31),dr(r,139),dr(r,8),r.gzhead?(dr(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),dr(r,255&r.gzhead.time),dr(r,r.gzhead.time>>8&255),dr(r,r.gzhead.time>>16&255),dr(r,r.gzhead.time>>24&255),dr(r,9===r.level?2:r.strategy>=2||r.level<2?4:0),dr(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(dr(r,255&r.gzhead.extra.length),dr(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=Xi(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69):(dr(r,0),dr(r,0),dr(r,0),dr(r,0),dr(r,0),dr(r,9===r.level?2:r.strategy>=2||r.level<2?4:0),dr(r,3),r.status=rr);else{var s=8+(r.w_bits-8<<4)<<8;s|=(r.strategy>=2||r.level<2?0:r.level<6?1:6===r.level?2:3)<<6,0!==r.strstart&&(s|=32),s+=31-s%31,r.status=rr,ur(r,s),0!==r.strstart&&(ur(r,e.adler>>>16),ur(r,65535&e.adler)),e.adler=1}if(69===r.status)if(r.gzhead.extra){for(n=r.pending;r.gzindex<(65535&r.gzhead.extra.length)&&(r.pending!==r.pending_buf_size||(r.gzhead.hcrc&&r.pending>n&&(e.adler=Xi(e.adler,r.pending_buf,r.pending-n,n)),cr(e),n=r.pending,r.pending!==r.pending_buf_size));)dr(r,255&r.gzhead.extra[r.gzindex]),r.gzindex++;r.gzhead.hcrc&&r.pending>n&&(e.adler=Xi(e.adler,r.pending_buf,r.pending-n,n)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=73)}else r.status=73;if(73===r.status)if(r.gzhead.name){n=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>n&&(e.adler=Xi(e.adler,r.pending_buf,r.pending-n,n)),cr(e),n=r.pending,r.pending===r.pending_buf_size)){o=1;break}o=r.gzindex<r.gzhead.name.length?255&r.gzhead.name.charCodeAt(r.gzindex++):0,dr(r,o)}while(0!==o);r.gzhead.hcrc&&r.pending>n&&(e.adler=Xi(e.adler,r.pending_buf,r.pending-n,n)),0===o&&(r.gzindex=0,r.status=91)}else r.status=91;if(91===r.status)if(r.gzhead.comment){n=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>n&&(e.adler=Xi(e.adler,r.pending_buf,r.pending-n,n)),cr(e),n=r.pending,r.pending===r.pending_buf_size)){o=1;break}o=r.gzindex<r.gzhead.comment.length?255&r.gzhead.comment.charCodeAt(r.gzindex++):0,dr(r,o)}while(0!==o);r.gzhead.hcrc&&r.pending>n&&(e.adler=Xi(e.adler,r.pending_buf,r.pending-n,n)),0===o&&(r.status=ir)}else r.status=ir;if(r.status===ir&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&cr(e),r.pending+2<=r.pending_buf_size&&(dr(r,255&e.adler),dr(r,e.adler>>8&255),e.adler=0,r.status=rr)):r.status=rr),0!==r.pending){if(cr(e),0===e.avail_out)return r.last_flush=-1,0}else if(0===e.avail_in&&sr(t)<=sr(i)&&4!==t)return or(e,-5);if(r.status===nr&&0!==e.avail_in)return or(e,-5);if(0!==e.avail_in||0!==r.lookahead||0!==t&&r.status!==nr){var a=2===r.strategy?function(e,t){for(var i;;){if(0===e.lookahead&&(pr(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,i=Yi(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(lr(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(lr(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(lr(e,!1),0===e.strm.avail_out)?1:2}(r,t):3===r.strategy?function(e,t){for(var i,r,n,o,s=e.window;;){if(e.lookahead<=er){if(pr(e),e.lookahead<=er&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=$i&&e.strstart>0&&(r=s[n=e.strstart-1])===s[++n]&&r===s[++n]&&r===s[++n]){o=e.strstart+er;do{}while(r===s[++n]&&r===s[++n]&&r===s[++n]&&r===s[++n]&&r===s[++n]&&r===s[++n]&&r===s[++n]&&r===s[++n]&&n<o);e.match_length=er-(o-n),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=$i?(i=Yi(e,1,e.match_length-$i),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=Yi(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(lr(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(lr(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(lr(e,!1),0===e.strm.avail_out)?1:2}(r,t):Qi[r.level].func(r,t);if(3!==a&&4!==a||(r.status=nr),1===a||3===a)return 0===e.avail_out&&(r.last_flush=-1),0;if(2===a&&(1===t?function(e){var t;Li(e,ti<<1,3),Pi(e,hi,yi),16===(t=e).bi_valid?(Oi(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(r):5!==t&&(Ki(r,0,0,!1),3===t&&(ar(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),cr(e),0===e.avail_out))return r.last_flush=-1,0}return 4!==t?0:r.wrap<=0?1:(2===r.wrap?(dr(r,255&e.adler),dr(r,e.adler>>8&255),dr(r,e.adler>>16&255),dr(r,e.adler>>24&255),dr(r,255&e.total_in),dr(r,e.total_in>>8&255),dr(r,e.total_in>>16&255),dr(r,e.total_in>>24&255)):(ur(r,e.adler>>>16),ur(r,65535&e.adler)),cr(e),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?0:1)}Qi=[new fr(0,0,0,0,(function(e,t){var i=65535;for(i>e.pending_buf_size-5&&(i=e.pending_buf_size-5);;){if(e.lookahead<=1){if(pr(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+i;if((0===e.strstart||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,lr(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-tr&&(lr(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(lr(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(lr(e,!1),e.strm.avail_out),1)})),new fr(4,4,8,4,mr),new fr(4,5,16,8,mr),new fr(4,6,32,32,mr),new fr(4,4,16,16,_r),new fr(8,16,32,32,_r),new fr(8,16,128,128,_r),new fr(8,32,128,256,_r),new fr(32,128,258,1024,_r),new fr(32,258,258,4096,_r)];var yr=30,Tr=12;function Sr(e,t){var i,r,n,o,s,a,c,l,d,u,h,p,m,_,f,g,E,v,y,T,S,I,A,R,b;i=e.state,r=e.next_in,R=e.input,n=r+(e.avail_in-5),o=e.next_out,b=e.output,s=o-(t-e.avail_out),a=o+(e.avail_out-257),c=i.dmax,l=i.wsize,d=i.whave,u=i.wnext,h=i.window,p=i.hold,m=i.bits,_=i.lencode,f=i.distcode,g=(1<<i.lenbits)-1,E=(1<<i.distbits)-1;e:do{m<15&&(p+=R[r++]<<m,m+=8,p+=R[r++]<<m,m+=8),v=_[p&g];t:for(;;){if(p>>>=y=v>>>24,m-=y,0==(y=v>>>16&255))b[o++]=65535&v;else{if(!(16&y)){if(!(64&y)){v=_[(65535&v)+(p&(1<<y)-1)];continue t}if(32&y){i.mode=Tr;break e}e.msg="invalid literal/length code",i.mode=yr;break e}T=65535&v,(y&=15)&&(m<y&&(p+=R[r++]<<m,m+=8),T+=p&(1<<y)-1,p>>>=y,m-=y),m<15&&(p+=R[r++]<<m,m+=8,p+=R[r++]<<m,m+=8),v=f[p&E];i:for(;;){if(p>>>=y=v>>>24,m-=y,!(16&(y=v>>>16&255))){if(!(64&y)){v=f[(65535&v)+(p&(1<<y)-1)];continue i}e.msg="invalid distance code",i.mode=yr;break e}if(S=65535&v,m<(y&=15)&&(p+=R[r++]<<m,(m+=8)<y&&(p+=R[r++]<<m,m+=8)),(S+=p&(1<<y)-1)>c){e.msg="invalid distance too far back",i.mode=yr;break e}if(p>>>=y,m-=y,S>(y=o-s)){if((y=S-y)>d&&i.sane){e.msg="invalid distance too far back",i.mode=yr;break e}if(I=0,A=h,0===u){if(I+=l-y,y<T){T-=y;do{b[o++]=h[I++]}while(--y);I=o-S,A=b}}else if(u<y){if(I+=l+u-y,(y-=u)<T){T-=y;do{b[o++]=h[I++]}while(--y);if(I=0,u<T){T-=y=u;do{b[o++]=h[I++]}while(--y);I=o-S,A=b}}}else if(I+=u-y,y<T){T-=y;do{b[o++]=h[I++]}while(--y);I=o-S,A=b}for(;T>2;)b[o++]=A[I++],b[o++]=A[I++],b[o++]=A[I++],T-=3;T&&(b[o++]=A[I++],T>1&&(b[o++]=A[I++]))}else{I=o-S;do{b[o++]=b[I++],b[o++]=b[I++],b[o++]=b[I++],T-=3}while(T>2);T&&(b[o++]=b[I++],T>1&&(b[o++]=b[I++]))}break}}break}}while(r<n&&o<a);r-=T=m>>3,p&=(1<<(m-=T<<3))-1,e.next_in=r,e.next_out=o,e.avail_in=r<n?n-r+5:5-(r-n),e.avail_out=o<a?a-o+257:257-(o-a),i.hold=p,i.bits=m}var Ir=15,Ar=852,Rr=592,br=0,Cr=1,kr=2,wr=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],Nr=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],Dr=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],Or=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];function Lr(e,t,i,r,n,o,s,a){var c,l,d,u,h,p,m,_,f,g=a.bits,E=0,v=0,y=0,T=0,S=0,I=0,A=0,R=0,b=0,C=0,k=null,w=0,N=new Yt(Ir+1),D=new Yt(Ir+1),O=null,L=0;for(E=0;E<=Ir;E++)N[E]=0;for(v=0;v<r;v++)N[t[i+v]]++;for(S=g,T=Ir;T>=1&&0===N[T];T--);if(S>T&&(S=T),0===T)return n[o++]=20971520,n[o++]=20971520,a.bits=1,0;for(y=1;y<T&&0===N[y];y++);for(S<y&&(S=y),R=1,E=1;E<=Ir;E++)if(R<<=1,(R-=N[E])<0)return-1;if(R>0&&(e===br||1!==T))return-1;for(D[1]=0,E=1;E<Ir;E++)D[E+1]=D[E]+N[E];for(v=0;v<r;v++)0!==t[i+v]&&(s[D[t[i+v]]++]=v);if(e===br?(k=O=s,p=19):e===Cr?(k=wr,w-=257,O=Nr,L-=257,p=256):(k=Dr,O=Or,p=-1),C=0,v=0,E=y,h=o,I=S,A=0,d=-1,u=(b=1<<S)-1,e===Cr&&b>Ar||e===kr&&b>Rr)return 1;for(;;){m=E-A,s[v]<p?(_=0,f=s[v]):s[v]>p?(_=O[L+s[v]],f=k[w+s[v]]):(_=96,f=0),c=1<<E-A,y=l=1<<I;do{n[h+(C>>A)+(l-=c)]=m<<24|_<<16|f}while(0!==l);for(c=1<<E-1;C&c;)c>>=1;if(0!==c?(C&=c-1,C+=c):C=0,v++,0==--N[E]){if(E===T)break;E=t[i+s[v]]}if(E>S&&(C&u)!==d){for(0===A&&(A=S),h+=y,R=1<<(I=E-A);I+A<T&&!((R-=N[I+A])<=0);)I++,R<<=1;if(b+=1<<I,e===Cr&&b>Ar||e===kr&&b>Rr)return 1;n[d=C&u]=S<<24|I<<16|h-o}}return 0!==C&&(n[h+C]=E-A<<24|64<<16),a.bits=S,0}var Pr=1,Mr=2,xr=0,Vr=-2,Ur=1,Br=12,Fr=30,Hr=852,jr=592;function Wr(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function zr(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Yt(320),this.work=new Yt(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function Gr(e){var t,i,r;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,(i=e)&&i.state?(r=i.state,i.total_in=i.total_out=r.total=0,i.msg="",r.wrap&&(i.adler=1&r.wrap),r.mode=Ur,r.last=0,r.havedict=0,r.dmax=32768,r.head=null,r.hold=0,r.bits=0,r.lencode=r.lendyn=new Jt(Hr),r.distcode=r.distdyn=new Jt(jr),r.sane=1,r.back=-1,xr):Vr):Vr}var Kr,Yr,Jr=!0;function qr(e){if(Jr){var t;for(Kr=new Jt(512),Yr=new Jt(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Lr(Pr,e.lens,0,288,Kr,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Lr(Mr,e.lens,0,32,Yr,0,e.work,{bits:5}),Jr=!1}e.lencode=Kr,e.lenbits=9,e.distcode=Yr,e.distbits=5}var Xr;function Qr(e){if(e<1||e>7)throw new TypeError("Bad argument");this.mode=e,this.init_done=!1,this.write_in_progress=!1,this.pending_close=!1,this.windowBits=0,this.level=0,this.memLevel=0,this.strategy=0,this.dictionary=null}function Zr(e,t){for(var i=0;i<e.length;i++)this[t+i]=e[i]}Qr.prototype.init=function(e,t,i,r,n){var o;switch(this.windowBits=e,this.level=t,this.memLevel=i,this.strategy=r,3!==this.mode&&4!==this.mode||(this.windowBits+=16),7===this.mode&&(this.windowBits+=32),5!==this.mode&&6!==this.mode||(this.windowBits=-this.windowBits),this.strm=new zt,this.mode){case 1:case 3:case 5:o=function(e,t,i,r,n,o){if(!e)return Zi;var s=1;if(-1===t&&(t=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),n<1||n>9||r<8||r>15||t<0||t>9||o<0||o>4)return or(e,Zi);8===r&&(r=9);var a=new gr;return e.state=a,a.strm=e,a.wrap=s,a.gzhead=null,a.w_bits=r,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=n+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+$i-1)/$i),a.window=new Kt(2*a.w_size),a.head=new Yt(a.hash_size),a.prev=new Yt(a.w_size),a.lit_bufsize=1<<n+6,a.pending_buf_size=4*a.lit_bufsize,a.pending_buf=new Kt(a.pending_buf_size),a.d_buf=1*a.lit_bufsize,a.l_buf=3*a.lit_bufsize,a.level=t,a.strategy=o,a.method=8,Er(e)}(this.strm,this.level,0,this.windowBits,this.memLevel,this.strategy);break;case 2:case 4:case 6:case 7:o=function(e,t){var i,r,n,o,s,a;return e?(r=new zr,e.state=r,r.window=null,o=t,(i=(n=e)&&n.state?(a=n.state,o<0?(s=0,o=-o):(s=1+(o>>4),o<48&&(o&=15)),o&&(o<8||o>15)?Vr:(null!==a.window&&a.wbits!==o&&(a.window=null),a.wrap=s,a.wbits=o,Gr(n))):Vr)!==xr&&(e.state=null),i):Vr}(this.strm,this.windowBits);break;default:throw new Error("Unknown mode "+this.mode)}0===o?(this.write_in_progress=!1,this.init_done=!0):this._error(o)},Qr.prototype.params=function(){throw new Error("deflateParams Not supported")},Qr.prototype._writeCheck=function(){if(!this.init_done)throw new Error("write before init");if(0===this.mode)throw new Error("already finalized");if(this.write_in_progress)throw new Error("write already in progress");if(this.pending_close)throw new Error("close is pending")},Qr.prototype.write=function(e,t,i,r,n,o,s){this._writeCheck(),this.write_in_progress=!0;var a=this;return ve((function(){a.write_in_progress=!1;var c=a._write(e,t,i,r,n,o,s);a.callback(c[0],c[1]),a.pending_close&&a.close()})),this},Qr.prototype.writeSync=function(e,t,i,r,n,o,s){return this._writeCheck(),this._write(e,t,i,r,n,o,s)},Qr.prototype._write=function(e,t,i,r,n,o,s){if(this.write_in_progress=!0,0!==e&&1!==e&&2!==e&&3!==e&&4!==e&&5!==e)throw new Error("Invalid flush value");null==t&&(t=new y(0),r=0,i=0),n._set?n.set=n._set:n.set=Zr;var a,c=this.strm;switch(c.avail_in=r,c.input=t,c.next_in=i,c.avail_out=s,c.output=n,c.next_out=o,this.mode){case 1:case 3:case 5:a=vr(c,e);break;case 7:case 2:case 4:case 6:a=function(e,t){var i,r,n,o,s,a,c,l,d,u,h,p,m,_,f,g,E,v,y,T,S,I,A,R,b,C,k,w,N,D,O=0,L=new Kt(4),P=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return Vr;(i=e.state).mode===Br&&(i.mode=13),s=e.next_out,n=e.output,c=e.avail_out,o=e.next_in,r=e.input,a=e.avail_in,l=i.hold,d=i.bits,u=a,h=c,I=xr;e:for(;;)switch(i.mode){case Ur:if(0===i.wrap){i.mode=13;break}for(;d<16;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}if(2&i.wrap&&35615===l){i.check=0,L[0]=255&l,L[1]=l>>>8&255,i.check=Xi(i.check,L,2,0),l=0,d=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&l)<<8)+(l>>8))%31){e.msg="incorrect header check",i.mode=Fr;break}if(8!=(15&l)){e.msg="unknown compression method",i.mode=Fr;break}if(d-=4,S=8+(15&(l>>>=4)),0===i.wbits)i.wbits=S;else if(S>i.wbits){e.msg="invalid window size",i.mode=Fr;break}i.dmax=1<<S,e.adler=i.check=1,i.mode=512&l?10:Br,l=0,d=0;break;case 2:for(;d<16;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}if(i.flags=l,8!=(255&i.flags)){e.msg="unknown compression method",i.mode=Fr;break}if(57344&i.flags){e.msg="unknown header flags set",i.mode=Fr;break}i.head&&(i.head.text=l>>8&1),512&i.flags&&(L[0]=255&l,L[1]=l>>>8&255,i.check=Xi(i.check,L,2,0)),l=0,d=0,i.mode=3;case 3:for(;d<32;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}i.head&&(i.head.time=l),512&i.flags&&(L[0]=255&l,L[1]=l>>>8&255,L[2]=l>>>16&255,L[3]=l>>>24&255,i.check=Xi(i.check,L,4,0)),l=0,d=0,i.mode=4;case 4:for(;d<16;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}i.head&&(i.head.xflags=255&l,i.head.os=l>>8),512&i.flags&&(L[0]=255&l,L[1]=l>>>8&255,i.check=Xi(i.check,L,2,0)),l=0,d=0,i.mode=5;case 5:if(1024&i.flags){for(;d<16;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}i.length=l,i.head&&(i.head.extra_len=l),512&i.flags&&(L[0]=255&l,L[1]=l>>>8&255,i.check=Xi(i.check,L,2,0)),l=0,d=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&((p=i.length)>a&&(p=a),p&&(i.head&&(S=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),Gt(i.head.extra,r,o,p,S)),512&i.flags&&(i.check=Xi(i.check,r,p,o)),a-=p,o+=p,i.length-=p),i.length))break e;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===a)break e;p=0;do{S=r[o+p++],i.head&&S&&i.length<65536&&(i.head.name+=String.fromCharCode(S))}while(S&&p<a);if(512&i.flags&&(i.check=Xi(i.check,r,p,o)),a-=p,o+=p,S)break e}else i.head&&(i.head.name=null);i.length=0,i.mode=8;case 8:if(4096&i.flags){if(0===a)break e;p=0;do{S=r[o+p++],i.head&&S&&i.length<65536&&(i.head.comment+=String.fromCharCode(S))}while(S&&p<a);if(512&i.flags&&(i.check=Xi(i.check,r,p,o)),a-=p,o+=p,S)break e}else i.head&&(i.head.comment=null);i.mode=9;case 9:if(512&i.flags){for(;d<16;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}if(l!==(65535&i.check)){e.msg="header crc mismatch",i.mode=Fr;break}l=0,d=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=Br;break;case 10:for(;d<32;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}e.adler=i.check=Wr(l),l=0,d=0,i.mode=11;case 11:if(0===i.havedict)return e.next_out=s,e.avail_out=c,e.next_in=o,e.avail_in=a,i.hold=l,i.bits=d,2;e.adler=i.check=1,i.mode=Br;case Br:if(5===t||6===t)break e;case 13:if(i.last){l>>>=7&d,d-=7&d,i.mode=27;break}for(;d<3;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}switch(i.last=1&l,d-=1,3&(l>>>=1)){case 0:i.mode=14;break;case 1:if(qr(i),i.mode=20,6===t){l>>>=2,d-=2;break e}break;case 2:i.mode=17;break;case 3:e.msg="invalid block type",i.mode=Fr}l>>>=2,d-=2;break;case 14:for(l>>>=7&d,d-=7&d;d<32;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}if((65535&l)!=(l>>>16^65535)){e.msg="invalid stored block lengths",i.mode=Fr;break}if(i.length=65535&l,l=0,d=0,i.mode=15,6===t)break e;case 15:i.mode=16;case 16:if(p=i.length){if(p>a&&(p=a),p>c&&(p=c),0===p)break e;Gt(n,r,o,p,s),a-=p,o+=p,c-=p,s+=p,i.length-=p;break}i.mode=Br;break;case 17:for(;d<14;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}if(i.nlen=257+(31&l),l>>>=5,d-=5,i.ndist=1+(31&l),l>>>=5,d-=5,i.ncode=4+(15&l),l>>>=4,d-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=Fr;break}i.have=0,i.mode=18;case 18:for(;i.have<i.ncode;){for(;d<3;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}i.lens[P[i.have++]]=7&l,l>>>=3,d-=3}for(;i.have<19;)i.lens[P[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,A={bits:i.lenbits},I=Lr(0,i.lens,0,19,i.lencode,0,i.work,A),i.lenbits=A.bits,I){e.msg="invalid code lengths set",i.mode=Fr;break}i.have=0,i.mode=19;case 19:for(;i.have<i.nlen+i.ndist;){for(;g=(O=i.lencode[l&(1<<i.lenbits)-1])>>>16&255,E=65535&O,!((f=O>>>24)<=d);){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}if(E<16)l>>>=f,d-=f,i.lens[i.have++]=E;else{if(16===E){for(R=f+2;d<R;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}if(l>>>=f,d-=f,0===i.have){e.msg="invalid bit length repeat",i.mode=Fr;break}S=i.lens[i.have-1],p=3+(3&l),l>>>=2,d-=2}else if(17===E){for(R=f+3;d<R;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}d-=f,S=0,p=3+(7&(l>>>=f)),l>>>=3,d-=3}else{for(R=f+7;d<R;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}d-=f,S=0,p=11+(127&(l>>>=f)),l>>>=7,d-=7}if(i.have+p>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=Fr;break}for(;p--;)i.lens[i.have++]=S}}if(i.mode===Fr)break;if(0===i.lens[256]){e.msg="invalid code -- missing end-of-block",i.mode=Fr;break}if(i.lenbits=9,A={bits:i.lenbits},I=Lr(Pr,i.lens,0,i.nlen,i.lencode,0,i.work,A),i.lenbits=A.bits,I){e.msg="invalid literal/lengths set",i.mode=Fr;break}if(i.distbits=6,i.distcode=i.distdyn,A={bits:i.distbits},I=Lr(Mr,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,A),i.distbits=A.bits,I){e.msg="invalid distances set",i.mode=Fr;break}if(i.mode=20,6===t)break e;case 20:i.mode=21;case 21:if(a>=6&&c>=258){e.next_out=s,e.avail_out=c,e.next_in=o,e.avail_in=a,i.hold=l,i.bits=d,Sr(e,h),s=e.next_out,n=e.output,c=e.avail_out,o=e.next_in,r=e.input,a=e.avail_in,l=i.hold,d=i.bits,i.mode===Br&&(i.back=-1);break}for(i.back=0;g=(O=i.lencode[l&(1<<i.lenbits)-1])>>>16&255,E=65535&O,!((f=O>>>24)<=d);){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}if(g&&!(240&g)){for(v=f,y=g,T=E;g=(O=i.lencode[T+((l&(1<<v+y)-1)>>v)])>>>16&255,E=65535&O,!(v+(f=O>>>24)<=d);){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}l>>>=v,d-=v,i.back+=v}if(l>>>=f,d-=f,i.back+=f,i.length=E,0===g){i.mode=26;break}if(32&g){i.back=-1,i.mode=Br;break}if(64&g){e.msg="invalid literal/length code",i.mode=Fr;break}i.extra=15&g,i.mode=22;case 22:if(i.extra){for(R=i.extra;d<R;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}i.length+=l&(1<<i.extra)-1,l>>>=i.extra,d-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;g=(O=i.distcode[l&(1<<i.distbits)-1])>>>16&255,E=65535&O,!((f=O>>>24)<=d);){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}if(!(240&g)){for(v=f,y=g,T=E;g=(O=i.distcode[T+((l&(1<<v+y)-1)>>v)])>>>16&255,E=65535&O,!(v+(f=O>>>24)<=d);){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}l>>>=v,d-=v,i.back+=v}if(l>>>=f,d-=f,i.back+=f,64&g){e.msg="invalid distance code",i.mode=Fr;break}i.offset=E,i.extra=15&g,i.mode=24;case 24:if(i.extra){for(R=i.extra;d<R;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}i.offset+=l&(1<<i.extra)-1,l>>>=i.extra,d-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=Fr;break}i.mode=25;case 25:if(0===c)break e;if(p=h-c,i.offset>p){if((p=i.offset-p)>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=Fr;break}p>i.wnext?(p-=i.wnext,m=i.wsize-p):m=i.wnext-p,p>i.length&&(p=i.length),_=i.window}else _=n,m=s-i.offset,p=i.length;p>c&&(p=c),c-=p,i.length-=p;do{n[s++]=_[m++]}while(--p);0===i.length&&(i.mode=21);break;case 26:if(0===c)break e;n[s++]=i.length,c--,i.mode=21;break;case 27:if(i.wrap){for(;d<32;){if(0===a)break e;a--,l|=r[o++]<<d,d+=8}if(h-=c,e.total_out+=h,i.total+=h,h&&(e.adler=i.check=i.flags?Xi(i.check,n,h,s-h):Ji(i.check,n,h,s-h)),h=c,(i.flags?l:Wr(l))!==i.check){e.msg="incorrect data check",i.mode=Fr;break}l=0,d=0}i.mode=28;case 28:if(i.wrap&&i.flags){for(;d<32;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}if(l!==(4294967295&i.total)){e.msg="incorrect length check",i.mode=Fr;break}l=0,d=0}i.mode=29;case 29:I=1;break e;case Fr:I=-3;break e;case 31:return-4;default:return Vr}return e.next_out=s,e.avail_out=c,e.next_in=o,e.avail_in=a,i.hold=l,i.bits=d,(i.wsize||h!==e.avail_out&&i.mode<Fr&&(i.mode<27||4!==t))&&(b=e,C=e.output,k=e.next_out,w=h-e.avail_out,null===(D=b.state).window&&(D.wsize=1<<D.wbits,D.wnext=0,D.whave=0,D.window=new Kt(D.wsize)),w>=D.wsize?(Gt(D.window,C,k-D.wsize,D.wsize,0),D.wnext=0,D.whave=D.wsize):((N=D.wsize-D.wnext)>w&&(N=w),Gt(D.window,C,k-w,N,D.wnext),(w-=N)?(Gt(D.window,C,k-w,w,0),D.wnext=w,D.whave=D.wsize):(D.wnext+=N,D.wnext===D.wsize&&(D.wnext=0),D.whave<D.wsize&&(D.whave+=N)))),u-=e.avail_in,h-=e.avail_out,e.total_in+=u,e.total_out+=h,i.total+=h,i.wrap&&h&&(e.adler=i.check=i.flags?Xi(i.check,n,h,e.next_out-h):Ji(i.check,n,h,e.next_out-h)),e.data_type=i.bits+(i.last?64:0)+(i.mode===Br?128:0)+(20===i.mode||15===i.mode?256:0),(0===u&&0===h||4===t)&&I===xr&&(I=-5),I}(c,e);break;default:throw new Error("Unknown mode "+this.mode)}return 1!==a&&0!==a&&this._error(a),this.write_in_progress=!1,[c.avail_in,c.avail_out]},Qr.prototype.close=function(){this.write_in_progress?this.pending_close=!0:(this.pending_close=!1,1===this.mode||3===this.mode||5===this.mode?function(e){var t;e&&e.state&&(42!==(t=e.state.status)&&69!==t&&73!==t&&91!==t&&t!==ir&&t!==rr&&t!==nr?or(e,Zi):(e.state=null,t===rr&&or(e,-3)))}(this.strm):function(e){if(!e||!e.state)return Vr;var t=e.state;t.window&&(t.window=null),e.state=null}(this.strm),this.mode=0)},Qr.prototype.reset=function(){switch(this.mode){case 1:case 5:Xr=Er(this.strm);break;case 2:case 6:Xr=Gr(this.strm)}0!==Xr&&this._error(Xr)},Qr.prototype._error=function(e){this.onerror(Wt[e]+": "+this.strm.msg,e),this.write_in_progress=!1,this.pending_close&&this.close()};var $r=Object.freeze({NONE:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8,Zlib:Qr}),en={};Object.keys($r).forEach((function(e){en[e]=$r[e]})),en.Z_MIN_WINDOWBITS=8,en.Z_MAX_WINDOWBITS=15,en.Z_DEFAULT_WINDOWBITS=15,en.Z_MIN_CHUNK=64,en.Z_MAX_CHUNK=1/0,en.Z_DEFAULT_CHUNK=16384,en.Z_MIN_MEMLEVEL=1,en.Z_MAX_MEMLEVEL=9,en.Z_DEFAULT_MEMLEVEL=8,en.Z_MIN_LEVEL=-1,en.Z_MAX_LEVEL=9,en.Z_DEFAULT_LEVEL=en.Z_DEFAULT_COMPRESSION;var tn={Z_OK:en.Z_OK,Z_STREAM_END:en.Z_STREAM_END,Z_NEED_DICT:en.Z_NEED_DICT,Z_ERRNO:en.Z_ERRNO,Z_STREAM_ERROR:en.Z_STREAM_ERROR,Z_DATA_ERROR:en.Z_DATA_ERROR,Z_MEM_ERROR:en.Z_MEM_ERROR,Z_BUF_ERROR:en.Z_BUF_ERROR,Z_VERSION_ERROR:en.Z_VERSION_ERROR};function rn(e,t){if("string"==typeof t&&(t=new y(t)),!re(t))throw new TypeError("Not a string or buffer");var i=en.Z_FINISH;return e._processChunk(t,i)}function nn(e){if(!(this instanceof nn))return new nn(e);un.call(this,e,en.DEFLATE)}function on(e){if(!(this instanceof on))return new on(e);un.call(this,e,en.INFLATE)}function sn(e){if(!(this instanceof sn))return new sn(e);un.call(this,e,en.GZIP)}function an(e){if(!(this instanceof an))return new an(e);un.call(this,e,en.GUNZIP)}function cn(e){if(!(this instanceof cn))return new cn(e);un.call(this,e,en.DEFLATERAW)}function ln(e){if(!(this instanceof ln))return new ln(e);un.call(this,e,en.INFLATERAW)}function dn(e){if(!(this instanceof dn))return new dn(e);un.call(this,e,en.UNZIP)}function un(e,t){if(this._opts=e=e||{},this._chunkSize=e.chunkSize||en.Z_DEFAULT_CHUNK,Bt.call(this,e),e.flush&&e.flush!==en.Z_NO_FLUSH&&e.flush!==en.Z_PARTIAL_FLUSH&&e.flush!==en.Z_SYNC_FLUSH&&e.flush!==en.Z_FULL_FLUSH&&e.flush!==en.Z_FINISH&&e.flush!==en.Z_BLOCK)throw new Error("Invalid flush flag: "+e.flush);if(this._flushFlag=e.flush||en.Z_NO_FLUSH,e.chunkSize&&(e.chunkSize<en.Z_MIN_CHUNK||e.chunkSize>en.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+e.chunkSize);if(e.windowBits&&(e.windowBits<en.Z_MIN_WINDOWBITS||e.windowBits>en.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+e.windowBits);if(e.level&&(e.level<en.Z_MIN_LEVEL||e.level>en.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+e.level);if(e.memLevel&&(e.memLevel<en.Z_MIN_MEMLEVEL||e.memLevel>en.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+e.memLevel);if(e.strategy&&e.strategy!=en.Z_FILTERED&&e.strategy!=en.Z_HUFFMAN_ONLY&&e.strategy!=en.Z_RLE&&e.strategy!=en.Z_FIXED&&e.strategy!=en.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+e.strategy);if(e.dictionary&&!re(e.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._binding=new en.Zlib(t);var i=this;this._hadError=!1,this._binding.onerror=function(e,t){i._binding=null,i._hadError=!0;var r=new Error(e);r.errno=t,r.code=en.codes[t],i.emit("error",r)};var r=en.Z_DEFAULT_COMPRESSION;"number"==typeof e.level&&(r=e.level);var n=en.Z_DEFAULT_STRATEGY;"number"==typeof e.strategy&&(n=e.strategy),this._binding.init(e.windowBits||en.Z_DEFAULT_WINDOWBITS,r,e.memLevel||en.Z_DEFAULT_MEMLEVEL,n,e.dictionary),this._buffer=new y(this._chunkSize),this._offset=0,this._closed=!1,this._level=r,this._strategy=n,this.once("end",this.close)}Object.keys(tn).forEach((function(e){tn[tn[e]]=e})),we(un,Bt),un.prototype.params=function(e,t,i){if(e<en.Z_MIN_LEVEL||e>en.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+e);if(t!=en.Z_FILTERED&&t!=en.Z_HUFFMAN_ONLY&&t!=en.Z_RLE&&t!=en.Z_FIXED&&t!=en.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+t);if(this._level!==e||this._strategy!==t){var r=this;this.flush(en.Z_SYNC_FLUSH,(function(){r._binding.params(e,t),r._hadError||(r._level=e,r._strategy=t,i&&i())}))}else ve(i)},un.prototype.reset=function(){return this._binding.reset()},un.prototype._flush=function(e){this._transform(new y(0),"",e)},un.prototype.flush=function(e,t){var i=this._writableState;if(("function"==typeof e||void 0===e&&!t)&&(t=e,e=en.Z_FULL_FLUSH),i.ended)t&&ve(t);else if(i.ending)t&&this.once("end",t);else if(i.needDrain){var r=this;this.once("drain",(function(){r.flush(t)}))}else this._flushFlag=e,this.write(new y(0),"",t)},un.prototype.close=function(e){if(e&&ve(e),!this._closed){this._closed=!0,this._binding.close();var t=this;ve((function(){t.emit("close")}))}},un.prototype._transform=function(e,t,i){var r,n=this._writableState,o=(n.ending||n.ended)&&(!e||n.length===e.length);if(null===!e&&!re(e))return i(new Error("invalid input"));o?r=en.Z_FINISH:(r=this._flushFlag,e.length>=n.length&&(this._flushFlag=this._opts.flush||en.Z_NO_FLUSH)),this._processChunk(e,r,i)},un.prototype._processChunk=function(e,t,i){var r=e&&e.length,n=this._chunkSize-this._offset,o=0,s=this,a="function"==typeof i;if(!a){var c,l=[],d=0;this.on("error",(function(e){c=e}));do{var u=this._binding.writeSync(t,e,o,r,this._buffer,this._offset,n)}while(!this._hadError&&m(u[0],u[1]));if(this._hadError)throw c;var h=y.concat(l,d);return this.close(),h}var p=this._binding.write(t,e,o,r,this._buffer,this._offset,n);function m(c,u){if(!s._hadError){var h=n-u;if(function(e,t){if(!e)throw new Error("have should not go down")}(h>=0),h>0){var p=s._buffer.slice(s._offset,s._offset+h);s._offset+=h,a?s.push(p):(l.push(p),d+=p.length)}if((0===u||s._offset>=s._chunkSize)&&(n=s._chunkSize,s._offset=0,s._buffer=new y(s._chunkSize)),0===u){if(o+=r-c,r=c,!a)return!0;var _=s._binding.write(t,e,o,r,s._buffer,s._offset,s._chunkSize);return _.callback=m,void(_.buffer=e)}if(!a)return!1;i()}}p.buffer=e,p.callback=m},we(nn,un),we(on,un),we(sn,un),we(an,un),we(cn,un),we(ln,un),we(dn,un);var hn=function(e,t){return rn(new nn(t),e)},pn=function(e,t){return rn(new on(t),e)};class mn{constructor(e,t,i){this.SDKAPPID=e,this.EXPIRETIME=i,this.PRIVATEKEY=t}genTestUserSig(e){return this._isNumber(this.SDKAPPID)?this._isString(this.PRIVATEKEY)?this._isString(e)?this._isNumber(this.EXPIRETIME)?(this.SDKAPPID,this.PRIVATEKEY,this.EXPIRETIME,this.genSigWithUserbuf(e,this.EXPIRETIME,null)):(console.error("expireTime must be a number"),""):(console.error("userID must be a string"),""):(console.error("privateKey must be a string"),""):(console.error("sdkAppID must be a number"),"")}newBuffer(e,t){return y.from?y.from(e,t):new y(e,t)}unescape(e){return e.replace(/_/g,"=").replace(/\-/g,"/").replace(/\*/g,"+")}escape(e){return e.replace(/\+/g,"*").replace(/\//g,"-").replace(/=/g,"_")}encode(e){return this.escape(this.newBuffer(e).toString("base64"))}decode(e){return this.newBuffer(this.unescape(e),"base64")}base64encode(e){return this.newBuffer(e).toString("base64")}base64decode(e){return this.newBuffer(e,"base64").toString()}_hmacsha256(e,t,i,r){let n="TLS.identifier:"+e+"\n";n+="TLS.sdkappid:"+this.SDKAPPID+"\n",n+="TLS.time:"+t+"\n",n+="TLS.expire:"+i+"\n",null!=r&&(n+="TLS.userbuf:"+r+"\n");let o=ae.HmacSHA256(n,this.PRIVATEKEY);return ae.enc.Base64.stringify(o)}_utc(){return Math.round(Date.now()/1e3)}_isNumber(e){return null!==e&&("number"==typeof e&&!isNaN(e-0)||"object"==typeof e&&e.constructor===Number)}_isString(e){return"string"==typeof e}genSigWithUserbuf(e,t,i){let r=this._utc(),n={"TLS.ver":"2.0","TLS.identifier":e,"TLS.sdkappid":this.SDKAPPID,"TLS.time":r,"TLS.expire":t},o="";if(null!=i){let s=this.base64encode(i);n["TLS.userbuf"]=s,o=this._hmacsha256(e,r,t,s)}else o=this._hmacsha256(e,r,t,null);n["TLS.sig"]=o;let s=JSON.stringify(n),a=hn(this.newBuffer(s)).toString("base64"),c=this.escape(a);return c}validate(e){let t=this.decode(e);pn(t)}}const _n=20008434,fn=604800,gn="aa4c2a6f23c55f8826fa3a1fd6023c82ee161d78d32124dabd704f068dac420b";function En(e){const t=new mn(_n,gn,fn).genTestUserSig(e);return{SDKAppID:_n,userSig:t}}function vn(e){return{addSuccessLog:function(t){e.value.push({type:"success",content:t})},addFailedLog:function(t){e.value.push({type:"failed",content:t}),e.value},handleClearLog:()=>{e.value=[]}}}const yn=e.ref(!1),Tn=e.ref(!1),Sn=e.ref("stopped"),In=e.ref("stopped"),An=e.ref("stopped"),Rn=e.markRaw(o.create()),bn=e.ref([]),{addSuccessLog:Cn,addFailedLog:kn}=vn(bn);function wn(i,r,n){async function s(){An.value="starting";try{await Rn.startLocalAudio({option:{microphoneId:n.audioDeviceId}}),An.value="started",Cn("Local audio started successfully")}catch(e){An.value="stopped",kn(`Local audio is failed to started. Error: ${e.message}`)}}async function a(){if("started"===An.value){An.value="stopping";try{await Rn.stopLocalAudio(),An.value="stopped",Cn("Local audio stopped successfully")}catch(e){An.value="started",kn(`Local audio is failed to stopped. Error: ${e.message}`)}}else kn("The audio has not been started")}async function c(){In.value="starting";try{await Rn.startLocalVideo({view:"local",option:{cameraId:n.videoDeviceId,profile:"1080p"}}),In.value="started",Cn("Local audio stopped successfully")}catch(e){In.value="stopped",kn(`Local audio is failed to stopped. Error: ${e.message}`)}}async function l(){if("started"===In.value){In.value="stopping";try{await Rn.stopLocalVideo(),In.value="stopped",Cn("Local audio stopped successfully")}catch(e){In.value="started",kn(`Local audio is failed to stopped. Error: ${e.message}`)}}else kn("The audio has not been started")}const{handleError:d,handleKickedOut:u,handleRemoteUserEnter:h,handleRemoteUserExit:p,handleRemoteVideoAvailable:m,handleRemoteVideoUnavailable:_,handleRemoteAudioUnavailable:f,handleRemoteAudioAvailable:g,handleScreenShareStopped:E,handleVolumeValue:v,handleNetworkQuality:y,handleAutoplayFailed:T,handleConnectStateChanged:S,handleAudioPlayStateChanged:I,handleVideoPlayStateChanged:A,handleDeviceChanged:R,handlePublishStateChanged:b,handleStatistics:C,handleSEIMessage:k,handleTrack:w}=function(i,r,n,s){const{addFailedLog:a,addSuccessLog:c}=vn(s);return{handleError:function(e){t.ElMessage({message:`Local error: ${e.message}`,type:"error"}),a(`Local error: ${e.message}`),r(o.EVENT.ERROR,e)},handleKickedOut:function(e){t.ElMessage({message:`User has been kicked out for ${e.reason}`,type:"warning"}),a(`User has been kicked out for ${e.reason}`),r(o.EVENT.KICKED_OUT,e)},handleRemoteUserEnter:function(e){const{userId:t}=e;n.remoteUsersViews.push({userId:t,streamType:"main"}),c(`Remote User [${t}] entered`),r(o.EVENT.REMOTE_USER_ENTER,e)},handleRemoteUserExit:function(e){let t=n.remoteUsersViews.findIndex((t=>t.userId==e.userId));n.remoteUsersViews.splice(t,1),c(`远端用户: [${e.userId}] 退房事件`),r(o.EVENT.REMOTE_USER_EXIT,e)},handleRemoteVideoAvailable:async function(t){const{userId:n,streamType:s}=t;try{await e.nextTick(),i.startRemoteVideo({userId:n,streamType:s,view:n}),c(`Play remote video success: [${n}]`),r(o.EVENT.REMOTE_VIDEO_AVAILABLE,t)}catch(l){a(`Play remote video failed: [${n}], error: ${l.message}`)}},handleRemoteVideoUnavailable:function(e){const{streamType:t,userId:n}=e;c(`[${n}] [${t}] video unavailable`),i.stopRemoteVideo({userId:n,streamType:t}),r(o.EVENT.REMOTE_VIDEO_UNAVAILABLE,e)},handleRemoteAudioUnavailable:function(e){c(`[${e.userId}] audio unavailable`),r(o.EVENT.REMOTE_AUDIO_UNAVAILABLE,e)},handleRemoteAudioAvailable:function(e){c(`[${e.userId}] audio available`),r(o.EVENT.REMOTE_AUDIO_AVAILABLE,e)},handleScreenShareStopped:function(){c("本地屏幕分享停止事件"),r(o.EVENT.SCREEN_SHARE_STOPPED)},handleVolumeValue:function(e){const{userId:t,volume:i}=e;r(o.EVENT.AUDIO_VOLUME,e)},handleNetworkQuality:function(e){r(o.EVENT.NETWORK_QUALITY,e)},handleAutoplayFailed:function(e){r(o.EVENT.AUTOPLAY_FAILED,e)},handleConnectStateChanged:function(e){r(o.EVENT.CONNECTION_STATE_CHANGED,e)},handleAudioPlayStateChanged:function(e){e.userId,e.state,e.reason,r(o.EVENT.AUDIO_PLAY_STATE_CHANGED,e)},handleVideoPlayStateChanged:function(e){e.userId,e.streamType,e.state,e.reason,r(o.EVENT.VIDEO_PLAY_STATE_CHANGED,e)},handleDeviceChanged:function(e){e.type,e.device.label,e.action,r(o.EVENT.DEVICE_CHANGED,e)},handlePublishStateChanged:function(e){e.mediaType,e.state,e.reason,r(o.EVENT.PUBLISH_STATE_CHANGED,e)},handleStatistics:function(e){r(o.EVENT.STATISTICS,e)},handleSEIMessage:function(e){r(o.EVENT.SEI_MESSAGE,e)},handleTrack:function(e){r(o.EVENT.TRACK,e)}}}(Rn,r,n,bn);e.watch((()=>Sn.value),(e=>{r("changeRoomState",e)}),{deep:!0,immediate:!0}),e.watch((()=>bn.value),(e=>{r("updateLog",e)}),{deep:!0,immediate:!0});return{trtc:Rn,logs:bn,roomStatus:Sn,audioMuted:yn,videoMuted:Tn,camStatus:In,micStatus:An,handleEnter:async function(){if(i.sdkAppId&&i.sdkSecretKey&&i.roomId&&i.userId){Sn.value="entering";try{let e={roomId:Number(i.roomId),sdkAppId:Number(i.sdkAppId),userId:i.userId,userSig:i.userSig};await Rn.enterRoom(e),Sn.value="entered",Rn.on(o.EVENT.ERROR,d),Rn.on(o.EVENT.KICKED_OUT,u),Rn.on(o.EVENT.REMOTE_USER_ENTER,h),Rn.on(o.EVENT.REMOTE_USER_EXIT,p),Rn.on(o.EVENT.REMOTE_VIDEO_AVAILABLE,m),Rn.on(o.EVENT.REMOTE_VIDEO_UNAVAILABLE,_),Rn.on(o.EVENT.REMOTE_AUDIO_UNAVAILABLE,f),Rn.on(o.EVENT.REMOTE_AUDIO_AVAILABLE,g),Rn.on(o.EVENT.SCREEN_SHARE_STOPPED,E),Rn.on(o.EVENT.AUDIO_VOLUME,v),Rn.on(o.EVENT.NETWORK_QUALITY,y),Rn.on(o.EVENT.AUTOPLAY_FAILED,T),Rn.on(o.EVENT.CONNECTION_STATE_CHANGED,S),Rn.on(o.EVENT.AUDIO_PLAY_STATE_CHANGED,I),Rn.on(o.EVENT.VIDEO_PLAY_STATE_CHANGED,A),Rn.on(o.EVENT.DEVICE_CHANGED,R),Rn.on(o.EVENT.PUBLISH_STATE_CHANGED,b),Rn.on(o.EVENT.STATISTICS,C),Rn.on(o.EVENT.SEI_MESSAGE,k),Rn.on(o.EVENT.TRACK,w),await s(),await c(),Cn(`[${i.userId}] enter room [${i.roomId}] success`)}catch(e){Sn.value="stopped",kn(`Enter room ${i.roomId} failed. Error: ${e.message}`)}}else t.ElMessage({message:"请检查参数 SDKAppId, SDKSecretKey, userId, roomId 是否输入正确!",type:"error"})},handleExit:async function(){if("entered"===Sn.value){Sn.value="exiting";try{Rn.off(o.EVENT.ERROR,d),Rn.off(o.EVENT.KICKED_OUT,u),Rn.off(o.EVENT.REMOTE_USER_ENTER,h),Rn.off(o.EVENT.REMOTE_USER_EXIT,p),Rn.off(o.EVENT.REMOTE_VIDEO_AVAILABLE,m),Rn.off(o.EVENT.REMOTE_VIDEO_UNAVAILABLE,_),Rn.off(o.EVENT.REMOTE_AUDIO_UNAVAILABLE,f),Rn.off(o.EVENT.REMOTE_AUDIO_AVAILABLE,g),Rn.off(o.EVENT.SCREEN_SHARE_STOPPED,E),Rn.off(o.EVENT.AUDIO_VOLUME,v),Rn.off(o.EVENT.NETWORK_QUALITY,y),Rn.off(o.EVENT.AUTOPLAY_FAILED,T),Rn.off(o.EVENT.CONNECTION_STATE_CHANGED,S),Rn.off(o.EVENT.AUDIO_PLAY_STATE_CHANGED,I),Rn.off(o.EVENT.VIDEO_PLAY_STATE_CHANGED,A),Rn.off(o.EVENT.DEVICE_CHANGED,R),Rn.off(o.EVENT.PUBLISH_STATE_CHANGED,b),Rn.off(o.EVENT.STATISTICS,C),Rn.off(o.EVENT.SEI_MESSAGE,k),Rn.off(o.EVENT.TRACK,w),await Rn.exitRoom(),await Rn.stopLocalVideo(),await Rn.stopLocalAudio(),Sn.value="exited",n.remoteUsersViews=[],Cn("Exit room success")}catch(e){Sn.value="entered",kn(`Exit room failed. Error: ${e.message}`)}"started"===An.value&&a(),"started"===In.value&&l(),n.remoteUsersViews=[]}else kn("The room has not been entered")},destroy:()=>{Rn.destroy()},handleStartLocalAudio:s,handleStopLocalAudio:a,handleStartLocalVideo:c,handleStopLocalVideo:l,toggleAudio:async()=>{try{yn.value?(await Rn.updateLocalAudio({mute:!1}),yn.value=!1):(await Rn.updateLocalAudio({mute:!0}),yn.value=!0),Cn(`Audio Muted: ${yn.value}`)}catch(e){kn(`Mute audio error: ${e.message}`)}},toggleVideo:async()=>{try{Tn.value?(await Rn.updateLocalVideo({mute:!1}),Tn.value=!1):(await Rn.updateLocalVideo({mute:!0}),Tn.value=!0),Cn(`Video Muted: ${Tn.value}`)}catch(e){kn(`Mute video error: ${e.message}`)}},getUserSig:function(){let e=i.userSig||En({sdkAppId:Number(i.sdkAppId),userId:i.userId,sdkSecretKey:i.sdkSecretKey}).userSig;return e}}}const Nn=t=>(e.pushScopeId("data-v-4d910502"),t=t(),e.popScopeId(),t),Dn={class:"pusher"},On={key:0,class:"group"},Ln={class:"remote grid",style:{"grid-template-rows":"repeat(99, minmax(10em, auto))"}},Pn=["id"],Mn=Nn((()=>e.createElementVNode("div",{class:"local-user",id:"local"},null,-1))),xn={key:1,class:"single"},Vn=Nn((()=>e.createElementVNode("div",{class:"local-user",id:"local"},null,-1))),Un={class:"remote flex flex-wrap"},Bn=["id"],Fn={key:2,class:"btns flex justify-center"},Hn={class:"btn-box flex flex-nowrap justify-between items-center"},jn=e.defineComponent({__name:"trtcUI",props:{sdkAppId:{type:String,default:""},userId:{type:String,default:""},roomId:{type:String,default:""},sdkSecretKey:{type:String,default:""},userSig:{type:String,default:""}},emits:[o.EVENT.ERROR,o.EVENT.KICKED_OUT,o.EVENT.REMOTE_USER_ENTER,o.EVENT.REMOTE_USER_EXIT,o.EVENT.REMOTE_VIDEO_AVAILABLE,o.EVENT.REMOTE_VIDEO_UNAVAILABLE,o.EVENT.REMOTE_AUDIO_UNAVAILABLE,o.EVENT.REMOTE_AUDIO_AVAILABLE,o.EVENT.SCREEN_SHARE_STOPPED,o.EVENT.AUDIO_VOLUME,o.EVENT.NETWORK_QUALITY,o.EVENT.AUTOPLAY_FAILED,o.EVENT.CONNECTION_STATE_CHANGED,o.EVENT.AUDIO_PLAY_STATE_CHANGED,o.EVENT.VIDEO_PLAY_STATE_CHANGED,o.EVENT.DEVICE_CHANGED,o.EVENT.PUBLISH_STATE_CHANGED,o.EVENT.STATISTICS,o.EVENT.SEI_MESSAGE,o.EVENT.TRACK,"changeRoomState","updateLog"],setup(t,{expose:i,emit:r}){const n=t,o=r,s=e.reactive({audioDeviceId:"",videoDeviceId:"",remoteUsersViews:[]}),{audioMuted:a,videoMuted:c,roomStatus:l,trtc:d,logs:u,handleEnter:h,handleExit:p,destroy:m,handleStartLocalAudio:_,handleStopLocalAudio:f,handleStartLocalVideo:g,handleStopLocalVideo:E,toggleAudio:v,toggleVideo:y}=wn(n,o,s),T=()=>{v()},S=()=>{y()},I=()=>{p()};return i({trtc:d,logs:u,handleEnter:h,handleExit:p,destroy:m,handleStartLocalAudio:_,handleStopLocalAudio:f,handleStartLocalVideo:g,handleStopLocalVideo:E,toggleAudio:v,toggleVideo:y}),(t,i)=>{const r=e.resolveComponent("bc-icon");return e.openBlock(),e.createElementBlock("div",Dn,[s.remoteUsersViews.length>=2?(e.openBlock(),e.createElementBlock("div",On,[e.createElementVNode("div",Ln,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.remoteUsersViews,(t=>(e.openBlock(),e.createElementBlock("div",{id:t.userId,key:t.userId,class:"remote-user"},e.toDisplayString(t),9,Pn)))),128))]),Mn])):(e.openBlock(),e.createElementBlock("div",xn,[Vn,e.createElementVNode("div",Un,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.remoteUsersViews,(t=>(e.openBlock(),e.createElementBlock("div",{id:t.userId,key:t.userId,class:"remote-user"},e.toDisplayString(t.userId),9,Bn)))),128))])])),"entered"==e.unref(l)?(e.openBlock(),e.createElementBlock("div",Fn,[e.createElementVNode("div",Hn,[e.createElementVNode("div",{class:e.normalizeClass("flex-items-center justify-center rounded-full p-3 "+(e.unref(a)?" bg-zinc-400/80":" bg-stone-50")),onClick:T},[e.createVNode(r,{name:e.unref(a)?"ele-Mute":"ele-Microphone",color:e.unref(a)?"#fff":"#333",size:"20"},null,8,["name","color"])],2),e.createElementVNode("div",{class:"icon-bg flex-items-center justify-center bg-red-500",onClick:I},[e.createVNode(r,{name:"ele-PhoneFilled",color:"#fff",size:"20"})]),e.createElementVNode("div",{class:e.normalizeClass("flex-items-center justify-center rounded-full p-3 "+(e.unref(c)?" bg-zinc-400/80":" bg-stone-50")),onClick:S},[e.createVNode(r,{name:e.unref(c)?"ele-VideoPlay":"ele-VideoCamera",color:e.unref(c)?"#fff":"#333",size:"20"},null,8,["name","color"])],2)])])):e.createCommentVNode("",!0)])}}}),Wn=t._export_sfc(jn,[["__scopeId","data-v-4d910502"]]),zn=Object.freeze(Object.defineProperty({__proto__:null,default:Wn},Symbol.toStringTag,{value:"Module"}));exports.TRTC=o,exports.genTestUserSig=En,exports.trtcUI=Wn,exports.trtcUI$1=zn;
1
+ "use strict";const e=require("vue"),t=require("./index-Bc5G_06G.js");var i,r={exports:{}};i=r,t.commonjsGlobal,i.exports=function(){function e(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(i){if("default"!==i&&!(i in e)){var r=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,r.get?r:{enumerable:!0,get:function(){return t[i]}})}}))})),Object.freeze(e)}var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==t.commonjsGlobal?t.commonjsGlobal:"undefined"!=typeof self?self:{},r=function(e){try{return!!e()}catch(Th){return!0}},n=!r((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),o=n,s=Function.prototype,a=s.call,c=o&&s.bind.bind(a,a),l=o?c:function(e){return function(){return a.apply(e,arguments)}},d=l,u=d({}.toString),h=d("".slice),p=function(e){return h(u(e),8,-1)},m=r,_=p,f=Object,g=l("".split),E=m((function(){return!f("z").propertyIsEnumerable(0)}))?function(e){return"String"==_(e)?g(e,""):f(e)}:f,v=function(e){return null==e},y=v,T=TypeError,S=function(e){if(y(e))throw T("Can't call method on "+e);return e},I=E,A=S,R=function(e){return I(A(e))},b=function(e){return e&&e.Math==Math&&e},C=b("object"==typeof globalThis&&globalThis)||b("object"==typeof window&&window)||b("object"==typeof self&&self)||b("object"==typeof i&&i)||function(){return this}()||Function("return this")(),k={},w={get exports(){return k},set exports(e){k=e}},N=C,D=Object.defineProperty,O=function(e,t){try{D(N,e,{value:t,configurable:!0,writable:!0})}catch(i){N[e]=t}return t},L=O,P="__core-js_shared__",M=C[P]||L(P,{}),x=M;(w.exports=function(e,t){return x[e]||(x[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.30.0",mode:"global",copyright:"© 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.30.0/LICENSE",source:"https://github.com/zloirock/core-js"});var V,U,B=S,F=Object,H=function(e){return F(B(e))},j=H,W=l({}.hasOwnProperty),z=Object.hasOwn||function(e,t){return W(j(e),t)},G=l,K=0,Y=Math.random(),J=G(1..toString),q=function(e){return"Symbol("+(void 0===e?"":e)+")_"+J(++K+Y,36)},X="undefined"!=typeof navigator&&String(navigator.userAgent)||"",Q=C,Z=X,$=Q.process,ee=Q.Deno,te=$&&$.versions||ee&&ee.version,ie=te&&te.v8;ie&&(U=(V=ie.split("."))[0]>0&&V[0]<4?1:+(V[0]+V[1])),!U&&Z&&(!(V=Z.match(/Edge\/(\d+)/))||V[1]>=74)&&(V=Z.match(/Chrome\/(\d+)/))&&(U=+V[1]);var re=U,ne=re,oe=r,se=!!Object.getOwnPropertySymbols&&!oe((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&ne&&ne<41})),ae=se&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,ce=k,le=z,de=q,ue=se,he=ae,pe=C.Symbol,me=ce("wks"),_e=he?pe.for||pe:pe&&pe.withoutSetter||de,fe=function(e){return le(me,e)||(me[e]=ue&&le(pe,e)?pe[e]:_e("Symbol."+e)),me[e]},ge="object"==typeof document&&document.all,Ee={all:ge,IS_HTMLDDA:void 0===ge&&void 0!==ge},ve=Ee.all,ye=Ee.IS_HTMLDDA?function(e){return"function"==typeof e||e===ve}:function(e){return"function"==typeof e},Te=ye,Se=Ee.all,Ie=Ee.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:Te(e)||e===Se}:function(e){return"object"==typeof e?null!==e:Te(e)},Ae=Ie,Re=String,be=TypeError,Ce=function(e){if(Ae(e))return e;throw be(Re(e)+" is not an object")},ke={},we=!r((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),Ne=we&&r((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),De={},Oe=Ie,Le=C.document,Pe=Oe(Le)&&Oe(Le.createElement),Me=function(e){return Pe?Le.createElement(e):{}},xe=Me,Ve=!we&&!r((function(){return 7!=Object.defineProperty(xe("div"),"a",{get:function(){return 7}}).a})),Ue=n,Be=Function.prototype.call,Fe=Ue?Be.bind(Be):function(){return Be.apply(Be,arguments)},He=C,je=ye,We=function(e,t){return arguments.length<2?(i=He[e],je(i)?i:void 0):He[e]&&He[e][t];var i},ze=l({}.isPrototypeOf),Ge=We,Ke=ye,Ye=ze,Je=Object,qe=ae?function(e){return"symbol"==typeof e}:function(e){var t=Ge("Symbol");return Ke(t)&&Ye(t.prototype,Je(e))},Xe=String,Qe=function(e){try{return Xe(e)}catch(Th){return"Object"}},Ze=ye,$e=Qe,et=TypeError,tt=function(e){if(Ze(e))return e;throw et($e(e)+" is not a function")},it=tt,rt=v,nt=function(e,t){var i=e[t];return rt(i)?void 0:it(i)},ot=Fe,st=ye,at=Ie,ct=TypeError,lt=Fe,dt=Ie,ut=qe,ht=nt,pt=function(e,t){var i,r;if("string"===t&&st(i=e.toString)&&!at(r=ot(i,e)))return r;if(st(i=e.valueOf)&&!at(r=ot(i,e)))return r;if("string"!==t&&st(i=e.toString)&&!at(r=ot(i,e)))return r;throw ct("Can't convert object to primitive value")},mt=TypeError,_t=fe("toPrimitive"),ft=function(e,t){if(!dt(e)||ut(e))return e;var i,r=ht(e,_t);if(r){if(void 0===t&&(t="default"),i=lt(r,e,t),!dt(i)||ut(i))return i;throw mt("Can't convert object to primitive value")}return void 0===t&&(t="number"),pt(e,t)},gt=ft,Et=qe,vt=function(e){var t=gt(e,"string");return Et(t)?t:t+""},yt=we,Tt=Ve,St=Ne,It=Ce,At=vt,Rt=TypeError,bt=Object.defineProperty,Ct=Object.getOwnPropertyDescriptor,kt="enumerable",wt="configurable",Nt="writable";De.f=yt?St?function(e,t,i){if(It(e),t=At(t),It(i),"function"==typeof e&&"prototype"===t&&"value"in i&&Nt in i&&!i[Nt]){var r=Ct(e,t);r&&r[Nt]&&(e[t]=i.value,i={configurable:wt in i?i[wt]:r[wt],enumerable:kt in i?i[kt]:r[kt],writable:!1})}return bt(e,t,i)}:bt:function(e,t,i){if(It(e),t=At(t),It(i),Tt)try{return bt(e,t,i)}catch(r){}if("get"in i||"set"in i)throw Rt("Accessors not supported");return"value"in i&&(e[t]=i.value),e};var Dt=Math.ceil,Ot=Math.floor,Lt=Math.trunc||function(e){var t=+e;return(t>0?Ot:Dt)(t)},Pt=function(e){var t=+e;return t!=t||0===t?0:Lt(t)},Mt=Pt,xt=Math.max,Vt=Math.min,Ut=function(e,t){var i=Mt(e);return i<0?xt(i+t,0):Vt(i,t)},Bt=Pt,Ft=Math.min,Ht=function(e){return e>0?Ft(Bt(e),9007199254740991):0},jt=Ht,Wt=function(e){return jt(e.length)},zt=R,Gt=Ut,Kt=Wt,Yt=function(e){return function(t,i,r){var n,o=zt(t),s=Kt(o),a=Gt(r,s);if(e&&i!=i){for(;s>a;)if((n=o[a++])!=n)return!0}else for(;s>a;a++)if((e||a in o)&&o[a]===i)return e||a||0;return!e&&-1}},Jt={includes:Yt(!0),indexOf:Yt(!1)},qt={},Xt=z,Qt=R,Zt=Jt.indexOf,$t=qt,ei=l([].push),ti=function(e,t){var i,r=Qt(e),n=0,o=[];for(i in r)!Xt($t,i)&&Xt(r,i)&&ei(o,i);for(;t.length>n;)Xt(r,i=t[n++])&&(~Zt(o,i)||ei(o,i));return o},ii=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],ri=ti,ni=ii,oi=Object.keys||function(e){return ri(e,ni)},si=we,ai=Ne,ci=De,li=Ce,di=R,ui=oi;ke.f=si&&!ai?Object.defineProperties:function(e,t){li(e);for(var i,r=di(t),n=ui(t),o=n.length,s=0;o>s;)ci.f(e,i=n[s++],r[i]);return e};var hi,pi=We("document","documentElement"),mi=q,_i=k("keys"),fi=function(e){return _i[e]||(_i[e]=mi(e))},gi=Ce,Ei=ke,vi=ii,yi=qt,Ti=pi,Si=Me,Ii="prototype",Ai="script",Ri=fi("IE_PROTO"),bi=function(){},Ci=function(e){return"<"+Ai+">"+e+"</"+Ai+">"},ki=function(e){e.write(Ci("")),e.close();var t=e.parentWindow.Object;return e=null,t},wi=function(){try{hi=new ActiveXObject("htmlfile")}catch(n){}var e,t,i;wi="undefined"!=typeof document?document.domain&&hi?ki(hi):(t=Si("iframe"),i="java"+Ai+":",t.style.display="none",Ti.appendChild(t),t.src=String(i),(e=t.contentWindow.document).open(),e.write(Ci("document.F=Object")),e.close(),e.F):ki(hi);for(var r=vi.length;r--;)delete wi[Ii][vi[r]];return wi()};yi[Ri]=!0;var Ni=Object.create||function(e,t){var i;return null!==e?(bi[Ii]=gi(e),i=new bi,bi[Ii]=null,i[Ri]=e):i=wi(),void 0===t?i:Ei.f(i,t)},Di=fe,Oi=Ni,Li=De.f,Pi=Di("unscopables"),Mi=Array.prototype;null==Mi[Pi]&&Li(Mi,Pi,{configurable:!0,value:Oi(null)});var xi,Vi,Ui,Bi=function(e){Mi[Pi][e]=!0},Fi={},Hi=ye,ji=C.WeakMap,Wi=Hi(ji)&&/native code/.test(String(ji)),zi=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},Gi=De,Ki=zi,Yi=we?function(e,t,i){return Gi.f(e,t,Ki(1,i))}:function(e,t,i){return e[t]=i,e},Ji=Wi,qi=C,Xi=Ie,Qi=Yi,Zi=z,$i=M,er=fi,tr=qt,ir="Object already initialized",rr=qi.TypeError,nr=qi.WeakMap;if(Ji||$i.state){var or=$i.state||($i.state=new nr);or.get=or.get,or.has=or.has,or.set=or.set,xi=function(e,t){if(or.has(e))throw rr(ir);return t.facade=e,or.set(e,t),t},Vi=function(e){return or.get(e)||{}},Ui=function(e){return or.has(e)}}else{var sr=er("state");tr[sr]=!0,xi=function(e,t){if(Zi(e,sr))throw rr(ir);return t.facade=e,Qi(e,sr,t),t},Vi=function(e){return Zi(e,sr)?e[sr]:{}},Ui=function(e){return Zi(e,sr)}}var ar={set:xi,get:Vi,has:Ui,enforce:function(e){return Ui(e)?Vi(e):xi(e,{})},getterFor:function(e){return function(t){var i;if(!Xi(t)||(i=Vi(t)).type!==e)throw rr("Incompatible receiver, "+e+" required");return i}}},cr={},lr={},dr={}.propertyIsEnumerable,ur=Object.getOwnPropertyDescriptor,hr=ur&&!dr.call({1:2},1);lr.f=hr?function(e){var t=ur(this,e);return!!t&&t.enumerable}:dr;var pr=we,mr=Fe,_r=lr,fr=zi,gr=R,Er=vt,vr=z,yr=Ve,Tr=Object.getOwnPropertyDescriptor;cr.f=pr?Tr:function(e,t){if(e=gr(e),t=Er(t),yr)try{return Tr(e,t)}catch(i){}if(vr(e,t))return fr(!mr(_r.f,e,t),e[t])};var Sr={},Ir={get exports(){return Sr},set exports(e){Sr=e}},Ar=we,Rr=z,br=Function.prototype,Cr=Ar&&Object.getOwnPropertyDescriptor,kr=Rr(br,"name"),wr={EXISTS:kr,PROPER:kr&&"something"===function(){}.name,CONFIGURABLE:kr&&(!Ar||Ar&&Cr(br,"name").configurable)},Nr=ye,Dr=M,Or=l(Function.toString);Nr(Dr.inspectSource)||(Dr.inspectSource=function(e){return Or(e)});var Lr=Dr.inspectSource,Pr=l,Mr=r,xr=ye,Vr=z,Ur=we,Br=wr.CONFIGURABLE,Fr=Lr,Hr=ar.enforce,jr=ar.get,Wr=String,zr=Object.defineProperty,Gr=Pr("".slice),Kr=Pr("".replace),Yr=Pr([].join),Jr=Ur&&!Mr((function(){return 8!==zr((function(){}),"length",{value:8}).length})),qr=String(String).split("String"),Xr=Ir.exports=function(e,t,i){"Symbol("===Gr(Wr(t),0,7)&&(t="["+Kr(Wr(t),/^Symbol\(([^)]*)\)/,"$1")+"]"),i&&i.getter&&(t="get "+t),i&&i.setter&&(t="set "+t),(!Vr(e,"name")||Br&&e.name!==t)&&(Ur?zr(e,"name",{value:t,configurable:!0}):e.name=t),Jr&&i&&Vr(i,"arity")&&e.length!==i.arity&&zr(e,"length",{value:i.arity});try{i&&Vr(i,"constructor")&&i.constructor?Ur&&zr(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(n){}var r=Hr(e);return Vr(r,"source")||(r.source=Yr(qr,"string"==typeof t?t:"")),e};Function.prototype.toString=Xr((function(){return xr(this)&&jr(this).source||Fr(this)}),"toString");var Qr=ye,Zr=De,$r=Sr,en=O,tn=function(e,t,i,r){r||(r={});var n=r.enumerable,o=void 0!==r.name?r.name:t;if(Qr(i)&&$r(i,o,r),r.global)n?e[t]=i:en(t,i);else{try{r.unsafe?e[t]&&(n=!0):delete e[t]}catch(s){}n?e[t]=i:Zr.f(e,t,{value:i,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return e},rn={},nn=ti,on=ii.concat("length","prototype");rn.f=Object.getOwnPropertyNames||function(e){return nn(e,on)};var sn={};sn.f=Object.getOwnPropertySymbols;var an,cn,ln,dn=We,un=rn,hn=sn,pn=Ce,mn=l([].concat),_n=dn("Reflect","ownKeys")||function(e){var t=un.f(pn(e)),i=hn.f;return i?mn(t,i(e)):t},fn=z,gn=_n,En=cr,vn=De,yn=function(e,t,i){for(var r=gn(t),n=vn.f,o=En.f,s=0;s<r.length;s++){var a=r[s];fn(e,a)||i&&fn(i,a)||n(e,a,o(t,a))}},Tn=r,Sn=ye,In=/#|\.prototype\./,An=function(e,t){var i=bn[Rn(e)];return i==kn||i!=Cn&&(Sn(t)?Tn(t):!!t)},Rn=An.normalize=function(e){return String(e).replace(In,".").toLowerCase()},bn=An.data={},Cn=An.NATIVE="N",kn=An.POLYFILL="P",wn=An,Nn=C,Dn=cr.f,On=Yi,Ln=tn,Pn=O,Mn=yn,xn=wn,Vn=function(e,t){var i,r,n,o,s,a=e.target,c=e.global,l=e.stat;if(i=c?Nn:l?Nn[a]||Pn(a,{}):(Nn[a]||{}).prototype)for(r in t){if(o=t[r],n=e.dontCallGetSet?(s=Dn(i,r))&&s.value:i[r],!xn(c?r:a+(l?".":"#")+r,e.forced)&&void 0!==n){if(typeof o==typeof n)continue;Mn(o,n)}(e.sham||n&&n.sham)&&On(o,"sham",!0),Ln(i,r,o,e)}},Un=!r((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),Bn=z,Fn=ye,Hn=H,jn=Un,Wn=fi("IE_PROTO"),zn=Object,Gn=zn.prototype,Kn=jn?zn.getPrototypeOf:function(e){var t=Hn(e);if(Bn(t,Wn))return t[Wn];var i=t.constructor;return Fn(i)&&t instanceof i?i.prototype:t instanceof zn?Gn:null},Yn=r,Jn=ye,qn=Ie,Xn=Kn,Qn=tn,Zn=fe("iterator"),$n=!1;[].keys&&("next"in(ln=[].keys())?(cn=Xn(Xn(ln)))!==Object.prototype&&(an=cn):$n=!0),(!qn(an)||Yn((function(){var e={};return an[Zn].call(e)!==e})))&&(an={}),Jn(an[Zn])||Qn(an,Zn,(function(){return this}));var eo={IteratorPrototype:an,BUGGY_SAFARI_ITERATORS:$n},to=De.f,io=z,ro=fe("toStringTag"),no=function(e,t,i){e&&!i&&(e=e.prototype),e&&!io(e,ro)&&to(e,ro,{configurable:!0,value:t})},oo=eo.IteratorPrototype,so=Ni,ao=zi,co=no,lo=Fi,uo=function(){return this},ho=function(e,t,i,r){var n=t+" Iterator";return e.prototype=so(oo,{next:ao(+!r,i)}),co(e,n,!1),lo[n]=uo,e},po=l,mo=tt,_o=ye,fo=String,go=TypeError,Eo=function(e,t,i){try{return po(mo(Object.getOwnPropertyDescriptor(e,t)[i]))}catch(r){}},vo=Ce,yo=function(e){if("object"==typeof e||_o(e))return e;throw go("Can't set "+fo(e)+" as a prototype")},To=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,i={};try{(e=Eo(Object.prototype,"__proto__","set"))(i,[]),t=i instanceof Array}catch(r){}return function(i,r){return vo(i),yo(r),t?e(i,r):i.__proto__=r,i}}():void 0),So=Vn,Io=Fe,Ao=ye,Ro=ho,bo=Kn,Co=To,ko=no,wo=Yi,No=tn,Do=Fi,Oo=wr.PROPER,Lo=wr.CONFIGURABLE,Po=eo.IteratorPrototype,Mo=eo.BUGGY_SAFARI_ITERATORS,xo=fe("iterator"),Vo="keys",Uo="values",Bo="entries",Fo=function(){return this},Ho=function(e,t,i,r,n,o,s){Ro(i,t,r);var a,c,l,d=function(e){if(e===n&&_)return _;if(!Mo&&e in p)return p[e];switch(e){case Vo:case Uo:case Bo:return function(){return new i(this,e)}}return function(){return new i(this)}},u=t+" Iterator",h=!1,p=e.prototype,m=p[xo]||p["@@iterator"]||n&&p[n],_=!Mo&&m||d(n),f="Array"==t&&p.entries||m;if(f&&(a=bo(f.call(new e)))!==Object.prototype&&a.next&&(bo(a)!==Po&&(Co?Co(a,Po):Ao(a[xo])||No(a,xo,Fo)),ko(a,u,!0)),Oo&&n==Uo&&m&&m.name!==Uo&&(Lo?wo(p,"name",Uo):(h=!0,_=function(){return Io(m,this)})),n)if(c={values:d(Uo),keys:o?_:d(Vo),entries:d(Bo)},s)for(l in c)(Mo||h||!(l in p))&&No(p,l,c[l]);else So({target:t,proto:!0,forced:Mo||h},c);return p[xo]!==_&&No(p,xo,_,{name:n}),Do[t]=_,c},jo=function(e,t){return{value:e,done:t}},Wo=R,zo=Bi,Go=Fi,Ko=ar,Yo=De.f,Jo=Ho,qo=jo,Xo=we,Qo="Array Iterator",Zo=Ko.set,$o=Ko.getterFor(Qo),es=Jo(Array,"Array",(function(e,t){Zo(this,{type:Qo,target:Wo(e),index:0,kind:t})}),(function(){var e=$o(this),t=e.target,i=e.kind,r=e.index++;return!t||r>=t.length?(e.target=void 0,qo(void 0,!0)):qo("keys"==i?r:"values"==i?t[r]:[r,t[r]],!1)}),"values"),ts=Go.Arguments=Go.Array;if(zo("keys"),zo("values"),zo("entries"),Xo&&"values"!==ts.name)try{Yo(ts,"name",{value:"values"})}catch(cB){}var is={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},rs=Me("span").classList,ns=rs&&rs.constructor&&rs.constructor.prototype,os=ns===Object.prototype?void 0:ns,ss=C,as=is,cs=os,ls=es,ds=Yi,us=fe,hs=us("iterator"),ps=us("toStringTag"),ms=ls.values,_s=function(e,t){if(e){if(e[hs]!==ms)try{ds(e,hs,ms)}catch(cB){e[hs]=ms}if(e[ps]||ds(e,ps,t),as[t])for(var i in ls)if(e[i]!==ls[i])try{ds(e,i,ls[i])}catch(cB){e[i]=ls[i]}}};for(var fs in as)_s(ss[fs]&&ss[fs].prototype,fs);_s(cs,"DOMTokenList");var gs="undefined"!=typeof process&&"process"==p(process),Es=Sr,vs=De,ys=function(e,t,i){return i.get&&Es(i.get,t,{getter:!0}),i.set&&Es(i.set,t,{setter:!0}),vs.f(e,t,i)},Ts=We,Ss=ys,Is=we,As=fe("species"),Rs=function(e){var t=Ts(e);Is&&t&&!t[As]&&Ss(t,As,{configurable:!0,get:function(){return this}})},bs=ze,Cs=TypeError,ks=function(e,t){if(bs(t,e))return e;throw Cs("Incorrect invocation")},ws={};ws[fe("toStringTag")]="z";var Ns="[object z]"===String(ws),Ds=ye,Os=p,Ls=fe("toStringTag"),Ps=Object,Ms="Arguments"==Os(function(){return arguments}()),xs=Ns?Os:function(e){var t,i,r;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(i=function(e,t){try{return e[t]}catch(cB){}}(t=Ps(e),Ls))?i:Ms?Os(t):"Object"==(r=Os(t))&&Ds(t.callee)?"Arguments":r},Vs=l,Us=r,Bs=ye,Fs=xs,Hs=Lr,js=function(){},Ws=[],zs=We("Reflect","construct"),Gs=/^\s*(?:class|function)\b/,Ks=Vs(Gs.exec),Ys=!Gs.exec(js),Js=function(e){if(!Bs(e))return!1;try{return zs(js,Ws,e),!0}catch(cB){return!1}},qs=function(e){if(!Bs(e))return!1;switch(Fs(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Ys||!!Ks(Gs,Hs(e))}catch(cB){return!0}};qs.sham=!0;var Xs,Qs,Zs,$s,ea=!zs||Us((function(){var e;return Js(Js.call)||!Js(Object)||!Js((function(){e=!0}))||e}))?qs:Js,ta=ea,ia=Qe,ra=TypeError,na=function(e){if(ta(e))return e;throw ra(ia(e)+" is not a constructor")},oa=Ce,sa=na,aa=v,ca=fe("species"),la=function(e,t){var i,r=oa(e).constructor;return void 0===r||aa(i=oa(r)[ca])?t:sa(i)},da=n,ua=Function.prototype,ha=ua.apply,pa=ua.call,ma="object"==typeof Reflect&&Reflect.apply||(da?pa.bind(ha):function(){return pa.apply(ha,arguments)}),_a=p,fa=l,ga=function(e){if("Function"===_a(e))return fa(e)},Ea=tt,va=n,ya=ga(ga.bind),Ta=function(e,t){return Ea(e),void 0===t?e:va?ya(e,t):function(){return e.apply(t,arguments)}},Sa=l([].slice),Ia=TypeError,Aa=function(e,t){if(e<t)throw Ia("Not enough arguments");return e},Ra=/(?:ipad|iphone|ipod).*applewebkit/i.test(X),ba=C,Ca=ma,ka=Ta,wa=ye,Na=z,Da=r,Oa=pi,La=Sa,Pa=Me,Ma=Aa,xa=Ra,Va=gs,Ua=ba.setImmediate,Ba=ba.clearImmediate,Fa=ba.process,Ha=ba.Dispatch,ja=ba.Function,Wa=ba.MessageChannel,za=ba.String,Ga=0,Ka={},Ya="onreadystatechange";Da((function(){Xs=ba.location}));var Ja=function(e){if(Na(Ka,e)){var t=Ka[e];delete Ka[e],t()}},qa=function(e){return function(){Ja(e)}},Xa=function(e){Ja(e.data)},Qa=function(e){ba.postMessage(za(e),Xs.protocol+"//"+Xs.host)};Ua&&Ba||(Ua=function(e){Ma(arguments.length,1);var t=wa(e)?e:ja(e),i=La(arguments,1);return Ka[++Ga]=function(){Ca(t,void 0,i)},Qs(Ga),Ga},Ba=function(e){delete Ka[e]},Va?Qs=function(e){Fa.nextTick(qa(e))}:Ha&&Ha.now?Qs=function(e){Ha.now(qa(e))}:Wa&&!xa?($s=(Zs=new Wa).port2,Zs.port1.onmessage=Xa,Qs=ka($s.postMessage,$s)):ba.addEventListener&&wa(ba.postMessage)&&!ba.importScripts&&Xs&&"file:"!==Xs.protocol&&!Da(Qa)?(Qs=Qa,ba.addEventListener("message",Xa,!1)):Qs=Ya in Pa("script")?function(e){Oa.appendChild(Pa("script"))[Ya]=function(){Oa.removeChild(this),Ja(e)}}:function(e){setTimeout(qa(e),0)});var Za={set:Ua,clear:Ba},$a=function(){this.head=null,this.tail=null};$a.prototype={add:function(e){var t={item:e,next:null},i=this.tail;i?i.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return null===(this.head=e.next)&&(this.tail=null),e.item}};var ec,tc,ic,rc,nc,oc=$a,sc=/ipad|iphone|ipod/i.test(X)&&"undefined"!=typeof Pebble,ac=/web0s(?!.*chrome)/i.test(X),cc=C,lc=Ta,dc=cr.f,uc=Za.set,hc=oc,pc=Ra,mc=sc,_c=ac,fc=gs,gc=cc.MutationObserver||cc.WebKitMutationObserver,Ec=cc.document,vc=cc.process,yc=cc.Promise,Tc=dc(cc,"queueMicrotask"),Sc=Tc&&Tc.value;if(!Sc){var Ic=new hc,Ac=function(){var e,t;for(fc&&(e=vc.domain)&&e.exit();t=Ic.get();)try{t()}catch(cB){throw Ic.head&&ec(),cB}e&&e.enter()};pc||fc||_c||!gc||!Ec?!mc&&yc&&yc.resolve?((rc=yc.resolve(void 0)).constructor=yc,nc=lc(rc.then,rc),ec=function(){nc(Ac)}):fc?ec=function(){vc.nextTick(Ac)}:(uc=lc(uc,cc),ec=function(){uc(Ac)}):(tc=!0,ic=Ec.createTextNode(""),new gc(Ac).observe(ic,{characterData:!0}),ec=function(){ic.data=tc=!tc}),Sc=function(e){Ic.head||ec(),Ic.add(e)}}var Rc=Sc,bc=function(e){try{return{error:!1,value:e()}}catch(cB){return{error:!0,value:cB}}},Cc=C.Promise,kc="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,wc=!kc&&!gs&&"object"==typeof window&&"object"==typeof document,Nc=C,Dc=Cc,Oc=ye,Lc=wn,Pc=Lr,Mc=fe,xc=wc,Vc=kc,Uc=re;Dc&&Dc.prototype;var Bc=Mc("species"),Fc=!1,Hc=Oc(Nc.PromiseRejectionEvent),jc={CONSTRUCTOR:Lc("Promise",(function(){var e=Pc(Dc),t=e!==String(Dc);if(!t&&66===Uc)return!0;if(!Uc||Uc<51||!/native code/.test(e)){var i=new Dc((function(e){e(1)})),r=function(e){e((function(){}),(function(){}))};if((i.constructor={})[Bc]=r,!(Fc=i.then((function(){}))instanceof r))return!0}return!t&&(xc||Vc)&&!Hc})),REJECTION_EVENT:Hc,SUBCLASSING:Fc},Wc={},zc=tt,Gc=TypeError,Kc=function(e){var t,i;this.promise=new e((function(e,r){if(void 0!==t||void 0!==i)throw Gc("Bad Promise constructor");t=e,i=r})),this.resolve=zc(t),this.reject=zc(i)};Wc.f=function(e){return new Kc(e)};var Yc,Jc,qc,Xc=Vn,Qc=gs,Zc=C,$c=Fe,el=tn,tl=To,il=no,rl=Rs,nl=tt,ol=ye,sl=Ie,al=ks,cl=la,ll=Za.set,dl=Rc,ul=function(e,t){try{1==arguments.length?console.error(e):console.error(e,t)}catch(cB){}},hl=bc,pl=oc,ml=ar,_l=Cc,fl=Wc,gl="Promise",El=jc.CONSTRUCTOR,vl=jc.REJECTION_EVENT,yl=jc.SUBCLASSING,Tl=ml.getterFor(gl),Sl=ml.set,Il=_l&&_l.prototype,Al=_l,Rl=Il,bl=Zc.TypeError,Cl=Zc.document,kl=Zc.process,wl=fl.f,Nl=wl,Dl=!!(Cl&&Cl.createEvent&&Zc.dispatchEvent),Ol="unhandledrejection",Ll=function(e){var t;return!(!sl(e)||!ol(t=e.then))&&t},Pl=function(e,t){var i,r,n,o=t.value,s=1==t.state,a=s?e.ok:e.fail,c=e.resolve,l=e.reject,d=e.domain;try{a?(s||(2===t.rejection&&Bl(t),t.rejection=1),!0===a?i=o:(d&&d.enter(),i=a(o),d&&(d.exit(),n=!0)),i===e.promise?l(bl("Promise-chain cycle")):(r=Ll(i))?$c(r,i,c,l):c(i)):l(o)}catch(cB){d&&!n&&d.exit(),l(cB)}},Ml=function(e,t){e.notified||(e.notified=!0,dl((function(){for(var i,r=e.reactions;i=r.get();)Pl(i,e);e.notified=!1,t&&!e.rejection&&Vl(e)})))},xl=function(e,t,i){var r,n;Dl?((r=Cl.createEvent("Event")).promise=t,r.reason=i,r.initEvent(e,!1,!0),Zc.dispatchEvent(r)):r={promise:t,reason:i},!vl&&(n=Zc["on"+e])?n(r):e===Ol&&ul("Unhandled promise rejection",i)},Vl=function(e){$c(ll,Zc,(function(){var t,i=e.facade,r=e.value;if(Ul(e)&&(t=hl((function(){Qc?kl.emit("unhandledRejection",r,i):xl(Ol,i,r)})),e.rejection=Qc||Ul(e)?2:1,t.error))throw t.value}))},Ul=function(e){return 1!==e.rejection&&!e.parent},Bl=function(e){$c(ll,Zc,(function(){var t=e.facade;Qc?kl.emit("rejectionHandled",t):xl("rejectionhandled",t,e.value)}))},Fl=function(e,t,i){return function(r){e(t,r,i)}},Hl=function(e,t,i){e.done||(e.done=!0,i&&(e=i),e.value=t,e.state=2,Ml(e,!0))},jl=function(e,t,i){if(!e.done){e.done=!0,i&&(e=i);try{if(e.facade===t)throw bl("Promise can't be resolved itself");var r=Ll(t);r?dl((function(){var i={done:!1};try{$c(r,t,Fl(jl,i,e),Fl(Hl,i,e))}catch(cB){Hl(i,cB,e)}})):(e.value=t,e.state=1,Ml(e,!1))}catch(cB){Hl({done:!1},cB,e)}}};if(El&&(Rl=(Al=function(e){al(this,Rl),nl(e),$c(Yc,this);var t=Tl(this);try{e(Fl(jl,t),Fl(Hl,t))}catch(cB){Hl(t,cB)}}).prototype,(Yc=function(e){Sl(this,{type:gl,done:!1,notified:!1,parent:!1,reactions:new pl,rejection:!1,state:0,value:void 0})}).prototype=el(Rl,"then",(function(e,t){var i=Tl(this),r=wl(cl(this,Al));return i.parent=!0,r.ok=!ol(e)||e,r.fail=ol(t)&&t,r.domain=Qc?kl.domain:void 0,0==i.state?i.reactions.add(r):dl((function(){Pl(r,i)})),r.promise})),Jc=function(){var e=new Yc,t=Tl(e);this.promise=e,this.resolve=Fl(jl,t),this.reject=Fl(Hl,t)},fl.f=wl=function(e){return e===Al||void 0===e?new Jc(e):Nl(e)},ol(_l)&&Il!==Object.prototype)){qc=Il.then,yl||el(Il,"then",(function(e,t){var i=this;return new Al((function(e,t){$c(qc,i,e,t)})).then(e,t)}),{unsafe:!0});try{delete Il.constructor}catch(cB){}tl&&tl(Il,Rl)}Xc({global:!0,constructor:!0,wrap:!0,forced:El},{Promise:Al}),il(Al,gl,!1),rl(gl);var Wl=Fi,zl=fe("iterator"),Gl=Array.prototype,Kl=function(e){return void 0!==e&&(Wl.Array===e||Gl[zl]===e)},Yl=xs,Jl=nt,ql=v,Xl=Fi,Ql=fe("iterator"),Zl=function(e){if(!ql(e))return Jl(e,Ql)||Jl(e,"@@iterator")||Xl[Yl(e)]},$l=Fe,ed=tt,td=Ce,id=Qe,rd=Zl,nd=TypeError,od=function(e,t){var i=arguments.length<2?rd(e):t;if(ed(i))return td($l(i,e));throw nd(id(e)+" is not iterable")},sd=Fe,ad=Ce,cd=nt,ld=function(e,t,i){var r,n;ad(e);try{if(!(r=cd(e,"return"))){if("throw"===t)throw i;return i}r=sd(r,e)}catch(cB){n=!0,r=cB}if("throw"===t)throw i;if(n)throw r;return ad(r),i},dd=Ta,ud=Fe,hd=Ce,pd=Qe,md=Kl,_d=Wt,fd=ze,gd=od,Ed=Zl,vd=ld,yd=TypeError,Td=function(e,t){this.stopped=e,this.result=t},Sd=Td.prototype,Id=function(e,t,i){var r,n,o,s,a,c,l,d=i&&i.that,u=!(!i||!i.AS_ENTRIES),h=!(!i||!i.IS_RECORD),p=!(!i||!i.IS_ITERATOR),m=!(!i||!i.INTERRUPTED),_=dd(t,d),f=function(e){return r&&vd(r,"normal",e),new Td(!0,e)},g=function(e){return u?(hd(e),m?_(e[0],e[1],f):_(e[0],e[1])):m?_(e,f):_(e)};if(h)r=e.iterator;else if(p)r=e;else{if(!(n=Ed(e)))throw yd(pd(e)+" is not iterable");if(md(n)){for(o=0,s=_d(e);s>o;o++)if((a=g(e[o]))&&fd(Sd,a))return a;return new Td(!1)}r=gd(e,n)}for(c=h?e.next:r.next;!(l=ud(c,r)).done;){try{a=g(l.value)}catch(cB){vd(r,"throw",cB)}if("object"==typeof a&&a&&fd(Sd,a))return a}return new Td(!1)},Ad=fe("iterator"),Rd=!1;try{var bd=0,Cd={next:function(){return{done:!!bd++}},return:function(){Rd=!0}};Cd[Ad]=function(){return this},Array.from(Cd,(function(){throw 2}))}catch(cB){}var kd=function(e,t){if(!t&&!Rd)return!1;var i=!1;try{var r={};r[Ad]=function(){return{next:function(){return{done:i=!0}}}},e(r)}catch(cB){}return i},wd=Cc,Nd=jc.CONSTRUCTOR||!kd((function(e){wd.all(e).then(void 0,(function(){}))})),Dd=Fe,Od=tt,Ld=Wc,Pd=bc,Md=Id;Vn({target:"Promise",stat:!0,forced:Nd},{all:function(e){var t=this,i=Ld.f(t),r=i.resolve,n=i.reject,o=Pd((function(){var i=Od(t.resolve),o=[],s=0,a=1;Md(e,(function(e){var c=s++,l=!1;a++,Dd(i,t,e).then((function(e){l||(l=!0,o[c]=e,--a||r(o))}),n)})),--a||r(o)}));return o.error&&n(o.value),i.promise}});var xd=Vn,Vd=jc.CONSTRUCTOR,Ud=Cc,Bd=We,Fd=ye,Hd=tn,jd=Ud&&Ud.prototype;if(xd({target:"Promise",proto:!0,forced:Vd,real:!0},{catch:function(e){return this.then(void 0,e)}}),Fd(Ud)){var Wd=Bd("Promise").prototype.catch;jd.catch!==Wd&&Hd(jd,"catch",Wd,{unsafe:!0})}var zd=Fe,Gd=tt,Kd=Wc,Yd=bc,Jd=Id;Vn({target:"Promise",stat:!0,forced:Nd},{race:function(e){var t=this,i=Kd.f(t),r=i.reject,n=Yd((function(){var n=Gd(t.resolve);Jd(e,(function(e){zd(n,t,e).then(i.resolve,r)}))}));return n.error&&r(n.value),i.promise}});var qd=Fe,Xd=Wc;Vn({target:"Promise",stat:!0,forced:jc.CONSTRUCTOR},{reject:function(e){var t=Xd.f(this);return qd(t.reject,void 0,e),t.promise}});var Qd=Ce,Zd=Ie,$d=Wc,eu=function(e,t){if(Qd(e),Zd(t)&&t.constructor===e)return t;var i=$d.f(e);return(0,i.resolve)(t),i.promise},tu=Vn,iu=jc.CONSTRUCTOR,ru=eu;We("Promise"),tu({target:"Promise",stat:!0,forced:iu},{resolve:function(e){return ru(this,e)}});var nu=ye,ou=Ie,su=To,au=function(e,t,i){var r,n;return su&&nu(r=t.constructor)&&r!==i&&ou(n=r.prototype)&&n!==i.prototype&&su(e,n),e},cu=Ie,lu=p,du=fe("match"),uu=function(e){var t;return cu(e)&&(void 0!==(t=e[du])?!!t:"RegExp"==lu(e))},hu=xs,pu=String,mu=function(e){if("Symbol"===hu(e))throw TypeError("Cannot convert a Symbol value to a string");return pu(e)},_u=Ce,fu=function(){var e=_u(this),t="";return e.hasIndices&&(t+="d"),e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.unicodeSets&&(t+="v"),e.sticky&&(t+="y"),t},gu=Fe,Eu=z,vu=ze,yu=fu,Tu=RegExp.prototype,Su=function(e){var t=e.flags;return void 0!==t||"flags"in Tu||Eu(e,"flags")||!vu(Tu,e)?t:gu(yu,e)},Iu=r,Au=C.RegExp,Ru=Iu((function(){var e=Au("a","y");return e.lastIndex=2,null!=e.exec("abcd")})),bu=Ru||Iu((function(){return!Au("a","y").sticky})),Cu={BROKEN_CARET:Ru||Iu((function(){var e=Au("^r","gy");return e.lastIndex=2,null!=e.exec("str")})),MISSED_STICKY:bu,UNSUPPORTED_Y:Ru},ku=De.f,wu=r,Nu=C.RegExp,Du=wu((function(){var e=Nu(".","s");return!(e.dotAll&&e.exec("\n")&&"s"===e.flags)})),Ou=r,Lu=C.RegExp,Pu=Ou((function(){var e=Lu("(?<a>b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$<a>c")})),Mu=we,xu=C,Vu=l,Uu=wn,Bu=au,Fu=Yi,Hu=rn.f,ju=ze,Wu=uu,zu=mu,Gu=Su,Ku=Cu,Yu=function(e,t,i){i in e||ku(e,i,{configurable:!0,get:function(){return t[i]},set:function(e){t[i]=e}})},Ju=tn,qu=r,Xu=z,Qu=ar.enforce,Zu=Rs,$u=Du,eh=Pu,th=fe("match"),ih=xu.RegExp,rh=ih.prototype,nh=xu.SyntaxError,oh=Vu(rh.exec),sh=Vu("".charAt),ah=Vu("".replace),ch=Vu("".indexOf),lh=Vu("".slice),dh=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,uh=/a/g,hh=/a/g,ph=new ih(uh)!==uh,mh=Ku.MISSED_STICKY,_h=Ku.UNSUPPORTED_Y,fh=Mu&&(!ph||mh||$u||eh||qu((function(){return hh[th]=!1,ih(uh)!=uh||ih(hh)==hh||"/a/i"!=ih(uh,"i")})));if(Uu("RegExp",fh)){for(var gh=function(e,t){var i,r,n,o,s,a,c=ju(rh,this),l=Wu(e),d=void 0===t,u=[],h=e;if(!c&&l&&d&&e.constructor===gh)return e;if((l||ju(rh,e))&&(e=e.source,d&&(t=Gu(h))),e=void 0===e?"":zu(e),t=void 0===t?"":zu(t),h=e,$u&&"dotAll"in uh&&(r=!!t&&ch(t,"s")>-1)&&(t=ah(t,/s/g,"")),i=t,mh&&"sticky"in uh&&(n=!!t&&ch(t,"y")>-1)&&_h&&(t=ah(t,/y/g,"")),eh&&(e=(o=function(e){for(var t,i=e.length,r=0,n="",o=[],s={},a=!1,c=!1,l=0,d="";r<=i;r++){if("\\"===(t=sh(e,r)))t+=sh(e,++r);else if("]"===t)a=!1;else if(!a)switch(!0){case"["===t:a=!0;break;case"("===t:oh(dh,lh(e,r+1))&&(r+=2,c=!0),n+=t,l++;continue;case">"===t&&c:if(""===d||Xu(s,d))throw new nh("Invalid capture group name");s[d]=!0,o[o.length]=[d,l],c=!1,d="";continue}c?d+=t:n+=t}return[n,o]}(e))[0],u=o[1]),s=Bu(ih(e,t),c?this:rh,gh),(r||n||u.length)&&(a=Qu(s),r&&(a.dotAll=!0,a.raw=gh(function(e){for(var t,i=e.length,r=0,n="",o=!1;r<=i;r++)"\\"!==(t=sh(e,r))?o||"."!==t?("["===t?o=!0:"]"===t&&(o=!1),n+=t):n+="[\\s\\S]":n+=t+sh(e,++r);return n}(e),i)),n&&(a.sticky=!0),u.length&&(a.groups=u)),e!==h)try{Fu(s,"source",""===h?"(?:)":h)}catch(cB){}return s},Eh=Hu(ih),vh=0;Eh.length>vh;)Yu(gh,ih,Eh[vh++]);rh.constructor=gh,gh.prototype=rh,Ju(xu,"RegExp",gh,{constructor:!0})}Zu("RegExp");var yh,Th,Sh=Fe,Ih=l,Ah=mu,Rh=fu,bh=Cu,Ch=Ni,kh=ar.get,wh=Du,Nh=Pu,Dh=k("native-string-replace",String.prototype.replace),Oh=RegExp.prototype.exec,Lh=Oh,Ph=Ih("".charAt),Mh=Ih("".indexOf),xh=Ih("".replace),Vh=Ih("".slice),Uh=(Th=/b*/g,Sh(Oh,yh=/a/,"a"),Sh(Oh,Th,"a"),0!==yh.lastIndex||0!==Th.lastIndex),Bh=bh.BROKEN_CARET,Fh=void 0!==/()??/.exec("")[1];(Uh||Fh||Bh||wh||Nh)&&(Lh=function(e){var t,i,r,n,o,s,a,c=this,l=kh(c),d=Ah(e),u=l.raw;if(u)return u.lastIndex=c.lastIndex,t=Sh(Lh,u,d),c.lastIndex=u.lastIndex,t;var h=l.groups,p=Bh&&c.sticky,m=Sh(Rh,c),_=c.source,f=0,g=d;if(p&&(m=xh(m,"y",""),-1===Mh(m,"g")&&(m+="g"),g=Vh(d,c.lastIndex),c.lastIndex>0&&(!c.multiline||c.multiline&&"\n"!==Ph(d,c.lastIndex-1))&&(_="(?: "+_+")",g=" "+g,f++),i=new RegExp("^(?:"+_+")",m)),Fh&&(i=new RegExp("^"+_+"$(?!\\s)",m)),Uh&&(r=c.lastIndex),n=Sh(Oh,p?i:c,g),p?n?(n.input=Vh(n.input,f),n[0]=Vh(n[0],f),n.index=c.lastIndex,c.lastIndex+=n[0].length):c.lastIndex=0:Uh&&n&&(c.lastIndex=c.global?n.index+n[0].length:r),Fh&&n&&n.length>1&&Sh(Dh,n[0],i,(function(){for(o=1;o<arguments.length-2;o++)void 0===arguments[o]&&(n[o]=void 0)})),n&&h)for(n.groups=s=Ch(null),o=0;o<h.length;o++)s[(a=h[o])[0]]=n[a[1]];return n});var Hh=Lh;Vn({target:"RegExp",proto:!0,forced:/./.exec!==Hh},{exec:Hh});var jh=p,Wh=Array.isArray||function(e){return"Array"==jh(e)},zh=Wh,Gh=ea,Kh=Ie,Yh=fe("species"),Jh=Array,qh=function(e){var t;return zh(e)&&(t=e.constructor,(Gh(t)&&(t===Jh||zh(t.prototype))||Kh(t)&&null===(t=t[Yh]))&&(t=void 0)),void 0===t?Jh:t},Xh=Ta,Qh=E,Zh=H,$h=Wt,ep=function(e,t){return new(qh(e))(0===t?0:t)},tp=l([].push),ip=function(e){var t=1==e,i=2==e,r=3==e,n=4==e,o=6==e,s=7==e,a=5==e||o;return function(c,l,d,u){for(var h,p,m=Zh(c),_=Qh(m),f=Xh(l,d),g=$h(_),E=0,v=u||ep,y=t?v(c,g):i||s?v(c,0):void 0;g>E;E++)if((a||E in _)&&(p=f(h=_[E],E,m),e))if(t)y[E]=p;else if(p)switch(e){case 3:return!0;case 5:return h;case 6:return E;case 2:tp(y,h)}else switch(e){case 4:return!1;case 7:tp(y,h)}return o?-1:r||n?n:y}},rp={forEach:ip(0),map:ip(1),filter:ip(2),some:ip(3),every:ip(4),find:ip(5),findIndex:ip(6),filterReject:ip(7)},np=r,op=function(e,t){var i=[][e];return!!i&&np((function(){i.call(null,t||function(){return 1},1)}))},sp=rp.forEach,ap=op("forEach")?[].forEach:function(e){return sp(this,e,arguments.length>1?arguments[1]:void 0)},cp=C,lp=is,dp=os,up=ap,hp=Yi,pp=function(e){if(e&&e.forEach!==up)try{hp(e,"forEach",up)}catch(cB){e.forEach=up}};for(var mp in lp)lp[mp]&&pp(cp[mp]&&cp[mp].prototype);pp(dp);var _p=tt,fp=H,gp=E,Ep=Wt,vp=TypeError,yp=function(e){return function(t,i,r,n){_p(i);var o=fp(t),s=gp(o),a=Ep(o),c=e?a-1:0,l=e?-1:1;if(r<2)for(;;){if(c in s){n=s[c],c+=l;break}if(c+=l,e?c<0:a<=c)throw vp("Reduce of empty array with no initial value")}for(;e?c>=0:a>c;c+=l)c in s&&(n=i(n,s[c],c,o));return n}},Tp=[yp(!1),yp(!0)][0];Vn({target:"Array",proto:!0,forced:!gs&&re>79&&re<83||!op("reduce")},{reduce:function(e){var t=arguments.length;return Tp(this,e,t,t>1?arguments[1]:void 0)}});var Sp=ga,Ip=tn,Ap=Hh,Rp=r,bp=fe,Cp=Yi,kp=bp("species"),wp=RegExp.prototype,Np=l,Dp=Pt,Op=mu,Lp=S,Pp=Np("".charAt),Mp=Np("".charCodeAt),xp=Np("".slice),Vp=function(e){return function(t,i){var r,n,o=Op(Lp(t)),s=Dp(i),a=o.length;return s<0||s>=a?e?"":void 0:(r=Mp(o,s))<55296||r>56319||s+1===a||(n=Mp(o,s+1))<56320||n>57343?e?Pp(o,s):r:e?xp(o,s,s+2):n-56320+(r-55296<<10)+65536}},Up={codeAt:Vp(!1),charAt:Vp(!0)},Bp=Up.charAt,Fp=l,Hp=H,jp=Math.floor,Wp=Fp("".charAt),zp=Fp("".replace),Gp=Fp("".slice),Kp=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,Yp=/\$([$&'`]|\d{1,2})/g,Jp=function(e,t,i,r,n,o){var s=i+e.length,a=r.length,c=Yp;return void 0!==n&&(n=Hp(n),c=Kp),zp(o,c,(function(o,c){var l;switch(Wp(c,0)){case"$":return"$";case"&":return e;case"`":return Gp(t,0,i);case"'":return Gp(t,s);case"<":l=n[Gp(c,1,-1)];break;default:var d=+c;if(0===d)return o;if(d>a){var u=jp(d/10);return 0===u?o:u<=a?void 0===r[u-1]?Wp(c,1):r[u-1]+Wp(c,1):o}l=r[d-1]}return void 0===l?"":l}))},qp=Fe,Xp=Ce,Qp=ye,Zp=p,$p=Hh,em=TypeError,tm=ma,im=Fe,rm=l,nm=function(e,t,i,r){var n=bp(e),o=!Rp((function(){var t={};return t[n]=function(){return 7},7!=""[e](t)})),s=o&&!Rp((function(){var t=!1,i=/a/;return"split"===e&&((i={}).constructor={},i.constructor[kp]=function(){return i},i.flags="",i[n]=/./[n]),i.exec=function(){return t=!0,null},i[n](""),!t}));if(!o||!s||i){var a=Sp(/./[n]),c=t(n,""[e],(function(e,t,i,r,n){var s=Sp(e),c=t.exec;return c===Ap||c===wp.exec?o&&!n?{done:!0,value:a(t,i,r)}:{done:!0,value:s(i,t,r)}:{done:!1}}));Ip(String.prototype,e,c[0]),Ip(wp,n,c[1])}r&&Cp(wp[n],"sham",!0)},om=r,sm=Ce,am=ye,cm=v,lm=Pt,dm=Ht,um=mu,hm=S,pm=function(e,t,i){return t+(i?Bp(e,t).length:1)},mm=nt,_m=Jp,fm=function(e,t){var i=e.exec;if(Qp(i)){var r=qp(i,e,t);return null!==r&&Xp(r),r}if("RegExp"===Zp(e))return qp($p,e,t);throw em("RegExp#exec called on incompatible receiver")},gm=fe("replace"),Em=Math.max,vm=Math.min,ym=rm([].concat),Tm=rm([].push),Sm=rm("".indexOf),Im=rm("".slice),Am=function(e){return void 0===e?e:String(e)},Rm="$0"==="a".replace(/./,"$0"),bm=!!/./[gm]&&""===/./[gm]("a","$0"),Cm=!om((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")}));nm("replace",(function(e,t,i){var r=bm?"$":"$0";return[function(e,i){var r=hm(this),n=cm(e)?void 0:mm(e,gm);return n?im(n,e,r,i):im(t,um(r),e,i)},function(e,n){var o=sm(this),s=um(e);if("string"==typeof n&&-1===Sm(n,r)&&-1===Sm(n,"$<")){var a=i(t,o,s,n);if(a.done)return a.value}var c=am(n);c||(n=um(n));var l=o.global;if(l){var d=o.unicode;o.lastIndex=0}for(var u=[];;){var h=fm(o,s);if(null===h)break;if(Tm(u,h),!l)break;""===um(h[0])&&(o.lastIndex=pm(s,dm(o.lastIndex),d))}for(var p="",m=0,_=0;_<u.length;_++){for(var f=um((h=u[_])[0]),g=Em(vm(lm(h.index),s.length),0),E=[],v=1;v<h.length;v++)Tm(E,Am(h[v]));var y=h.groups;if(c){var T=ym([f],E,g,s);void 0!==y&&Tm(T,y);var S=um(tm(n,void 0,T))}else S=_m(f,s,g,E,y,n);g>=m&&(p+=Im(s,m,g)+S,m=g+f.length)}return p+Im(s,m)}]}),!Cm||!Rm||bm);var km=Jt.includes,wm=Bi;Vn({target:"Array",proto:!0,forced:r((function(){return!Array(1).includes()}))},{includes:function(e){return km(this,e,arguments.length>1?arguments[1]:void 0)}}),wm("includes");var Nm=Pt,Dm=mu,Om=S,Lm=RangeError,Pm=l,Mm=Ht,xm=mu,Vm=S,Um=Pm((function(e){var t=Dm(Om(this)),i="",r=Nm(e);if(r<0||1/0==r)throw Lm("Wrong number of repetitions");for(;r>0;(r>>>=1)&&(t+=t))1&r&&(i+=t);return i})),Bm=Pm("".slice),Fm=Math.ceil,Hm=function(e){return function(t,i,r){var n,o,s=xm(Vm(t)),a=Mm(i),c=s.length,l=void 0===r?" ":xm(r);return a<=c||""==l?s:((o=Um(l,Fm((n=a-c)/l.length))).length>n&&(o=Bm(o,0,n)),e?s+o:o+s)}},jm={start:Hm(!1),end:Hm(!0)},Wm=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(X),zm=jm.start;Vn({target:"String",proto:!0,forced:Wm},{padStart:function(e){return zm(this,e,arguments.length>1?arguments[1]:void 0)}});var Gm=r,Km=we,Ym=fe("iterator"),Jm=!Gm((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,i="";return e.pathname="c%20d",t.forEach((function(e,r){t.delete("b"),i+=r+e})),!t.size&&!Km||!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[Ym]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://тест").host||"#%D0%B1"!==new URL("http://a#б").hash||"a1c3"!==i||"x"!==new URL("http://x",void 0).host})),qm=tn,Xm=function(e,t,i){for(var r in t)qm(e,r,t[r],i);return e},Qm=vt,Zm=De,$m=zi,e_=function(e,t,i){var r=Qm(t);r in e?Zm.f(e,r,$m(0,i)):e[r]=i},t_=Ut,i_=Wt,r_=e_,n_=Array,o_=Math.max,s_=function(e,t,i){for(var r=i_(e),n=t_(t,r),o=t_(void 0===i?r:i,r),s=n_(o_(o-n,0)),a=0;n<o;n++,a++)r_(s,a,e[n]);return s.length=a,s},a_=s_,c_=Math.floor,l_=function(e,t){var i=e.length,r=c_(i/2);return i<8?d_(e,t):u_(e,l_(a_(e,0,r),t),l_(a_(e,r),t),t)},d_=function(e,t){for(var i,r,n=e.length,o=1;o<n;){for(r=o,i=e[o];r&&t(e[r-1],i)>0;)e[r]=e[--r];r!==o++&&(e[r]=i)}return e},u_=function(e,t,i,r){for(var n=t.length,o=i.length,s=0,a=0;s<n||a<o;)e[s+a]=s<n&&a<o?r(t[s],i[a])<=0?t[s++]:i[a++]:s<n?t[s++]:i[a++];return e},h_=l_,p_=Vn,m_=C,__=Fe,f_=l,g_=we,E_=Jm,v_=tn,y_=ys,T_=Xm,S_=no,I_=ho,A_=ar,R_=ks,b_=ye,C_=z,k_=Ta,w_=xs,N_=Ce,D_=Ie,O_=mu,L_=Ni,P_=zi,M_=od,x_=Zl,V_=Aa,U_=h_,B_=fe("iterator"),F_="URLSearchParams",H_=F_+"Iterator",j_=A_.set,W_=A_.getterFor(F_),z_=A_.getterFor(H_),G_=Object.getOwnPropertyDescriptor,K_=function(e){if(!g_)return m_[e];var t=G_(m_,e);return t&&t.value},Y_=K_("fetch"),J_=K_("Request"),q_=K_("Headers"),X_=J_&&J_.prototype,Q_=q_&&q_.prototype,Z_=m_.RegExp,$_=m_.TypeError,ef=m_.decodeURIComponent,tf=m_.encodeURIComponent,rf=f_("".charAt),nf=f_([].join),of=f_([].push),sf=f_("".replace),af=f_([].shift),cf=f_([].splice),lf=f_("".split),df=f_("".slice),uf=/\+/g,hf=Array(4),pf=function(e){return hf[e-1]||(hf[e-1]=Z_("((?:%[\\da-f]{2}){"+e+"})","gi"))},mf=function(e){try{return ef(e)}catch(cB){return e}},_f=function(e){var t=sf(e,uf," "),i=4;try{return ef(t)}catch(cB){for(;i;)t=sf(t,pf(i--),mf);return t}},ff=/[!'()~]|%20/g,gf={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},Ef=function(e){return gf[e]},vf=function(e){return sf(tf(e),ff,Ef)},yf=I_((function(e,t){j_(this,{type:H_,iterator:M_(W_(e).entries),kind:t})}),"Iterator",(function(){var e=z_(this),t=e.kind,i=e.iterator.next(),r=i.value;return i.done||(i.value="keys"===t?r.key:"values"===t?r.value:[r.key,r.value]),i}),!0),Tf=function(e){this.entries=[],this.url=null,void 0!==e&&(D_(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===rf(e,0)?df(e,1):e:O_(e)))};Tf.prototype={type:F_,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,i,r,n,o,s,a,c=x_(e);if(c)for(i=(t=M_(e,c)).next;!(r=__(i,t)).done;){if(o=(n=M_(N_(r.value))).next,(s=__(o,n)).done||(a=__(o,n)).done||!__(o,n).done)throw $_("Expected sequence with length 2");of(this.entries,{key:O_(s.value),value:O_(a.value)})}else for(var l in e)C_(e,l)&&of(this.entries,{key:l,value:O_(e[l])})},parseQuery:function(e){if(e)for(var t,i,r=lf(e,"&"),n=0;n<r.length;)(t=r[n++]).length&&(i=lf(t,"="),of(this.entries,{key:_f(af(i)),value:_f(nf(i,"="))}))},serialize:function(){for(var e,t=this.entries,i=[],r=0;r<t.length;)e=t[r++],of(i,vf(e.key)+"="+vf(e.value));return nf(i,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var Sf=function(){R_(this,If);var e=j_(this,new Tf(arguments.length>0?arguments[0]:void 0));g_||(this.length=e.entries.length)},If=Sf.prototype;if(T_(If,{append:function(e,t){V_(arguments.length,2);var i=W_(this);of(i.entries,{key:O_(e),value:O_(t)}),g_||this.length++,i.updateURL()},delete:function(e){V_(arguments.length,1);for(var t=W_(this),i=t.entries,r=O_(e),n=0;n<i.length;)i[n].key===r?cf(i,n,1):n++;g_||(this.length=i.length),t.updateURL()},get:function(e){V_(arguments.length,1);for(var t=W_(this).entries,i=O_(e),r=0;r<t.length;r++)if(t[r].key===i)return t[r].value;return null},getAll:function(e){V_(arguments.length,1);for(var t=W_(this).entries,i=O_(e),r=[],n=0;n<t.length;n++)t[n].key===i&&of(r,t[n].value);return r},has:function(e){V_(arguments.length,1);for(var t=W_(this).entries,i=O_(e),r=0;r<t.length;)if(t[r++].key===i)return!0;return!1},set:function(e,t){V_(arguments.length,1);for(var i,r=W_(this),n=r.entries,o=!1,s=O_(e),a=O_(t),c=0;c<n.length;c++)(i=n[c]).key===s&&(o?cf(n,c--,1):(o=!0,i.value=a));o||of(n,{key:s,value:a}),g_||(this.length=n.length),r.updateURL()},sort:function(){var e=W_(this);U_(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,i=W_(this).entries,r=k_(e,arguments.length>1?arguments[1]:void 0),n=0;n<i.length;)r((t=i[n++]).value,t.key,this)},keys:function(){return new yf(this,"keys")},values:function(){return new yf(this,"values")},entries:function(){return new yf(this,"entries")}},{enumerable:!0}),v_(If,B_,If.entries,{name:"entries"}),v_(If,"toString",(function(){return W_(this).serialize()}),{enumerable:!0}),g_&&y_(If,"size",{get:function(){return W_(this).entries.length},configurable:!0,enumerable:!0}),S_(Sf,F_),p_({global:!0,constructor:!0,forced:!E_},{URLSearchParams:Sf}),!E_&&b_(q_)){var Af=f_(Q_.has),Rf=f_(Q_.set),bf=function(e){if(D_(e)){var t,i=e.body;if(w_(i)===F_)return t=e.headers?new q_(e.headers):new q_,Af(t,"content-type")||Rf(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),L_(e,{body:P_(0,O_(i)),headers:P_(0,t)})}return e};if(b_(Y_)&&p_({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return Y_(e,arguments.length>1?bf(arguments[1]):{})}}),b_(J_)){var Cf=function(e){return R_(this,X_),new J_(e,arguments.length>1?bf(arguments[1]):{})};X_.constructor=Cf,Cf.prototype=X_,p_({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:Cf})}}var kf={URLSearchParams:Sf,getState:W_},wf="\t\n\v\f\r                 \u2028\u2029\ufeff",Nf=S,Df=mu,Of=wf,Lf=l("".replace),Pf=RegExp("^["+Of+"]+"),Mf=RegExp("(^|[^"+Of+"])["+Of+"]+$"),xf=function(e){return function(t){var i=Df(Nf(t));return 1&e&&(i=Lf(i,Pf,"")),2&e&&(i=Lf(i,Mf,"$1")),i}},Vf={start:xf(1),end:xf(2),trim:xf(3)},Uf=wr.PROPER,Bf=r,Ff=wf,Hf=Vf.trim;Vn({target:"String",proto:!0,forced:function(e){return Bf((function(){return!!Ff[e]()||"​…᠎"!=="​…᠎"[e]()||Uf&&Ff[e].name!==e}))}("trim")},{trim:function(){return Hf(this)}});var jf=Vn,Wf=we,zf=l,Gf=z,Kf=ye,Yf=ze,Jf=mu,qf=ys,Xf=yn,Qf=C.Symbol,Zf=Qf&&Qf.prototype;if(Wf&&Kf(Qf)&&(!("description"in Zf)||void 0!==Qf().description)){var $f={},eg=function(){var e=arguments.length<1||void 0===arguments[0]?void 0:Jf(arguments[0]),t=Yf(Zf,this)?new Qf(e):void 0===e?Qf():Qf(e);return""===e&&($f[t]=!0),t};Xf(eg,Qf),eg.prototype=Zf,Zf.constructor=eg;var tg="Symbol(test)"==String(Qf("test")),ig=zf(Zf.valueOf),rg=zf(Zf.toString),ng=/^Symbol\((.*)\)[^)]+$/,og=zf("".replace),sg=zf("".slice);qf(Zf,"description",{configurable:!0,get:function(){var e=ig(this);if(Gf($f,e))return"";var t=rg(e),i=tg?sg(t,7,-1):og(t,ng,"$1");return""===i?void 0:i}}),jf({global:!0,constructor:!0,forced:!0},{Symbol:eg})}var ag=Up.charAt,cg=mu,lg=ar,dg=Ho,ug=jo,hg="String Iterator",pg=lg.set,mg=lg.getterFor(hg);dg(String,"String",(function(e){pg(this,{type:hg,string:cg(e),index:0})}),(function(){var e,t=mg(this),i=t.string,r=t.index;return r>=i.length?ug(void 0,!0):(e=ag(i,r),t.index+=e.length,ug(e,!1))}));var _g,fg=we,gg=l,Eg=Fe,vg=r,yg=oi,Tg=sn,Sg=lr,Ig=H,Ag=E,Rg=Object.assign,bg=Object.defineProperty,Cg=gg([].concat),kg=!Rg||vg((function(){if(fg&&1!==Rg({b:1},Rg(bg({},"a",{enumerable:!0,get:function(){bg(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},i=Symbol(),r="abcdefghijklmnopqrst";return e[i]=7,r.split("").forEach((function(e){t[e]=e})),7!=Rg({},e)[i]||yg(Rg({},t)).join("")!=r}))?function(e,t){for(var i=Ig(e),r=arguments.length,n=1,o=Tg.f,s=Sg.f;r>n;)for(var a,c=Ag(arguments[n++]),l=o?Cg(yg(c),o(c)):yg(c),d=l.length,u=0;d>u;)a=l[u++],fg&&!Eg(s,c,a)||(i[a]=c[a]);return i}:Rg,wg=Ce,Ng=ld,Dg=Ta,Og=Fe,Lg=H,Pg=function(e,t,i,r){try{return r?t(wg(i)[0],i[1]):t(i)}catch(cB){Ng(e,"throw",cB)}},Mg=Kl,xg=ea,Vg=Wt,Ug=e_,Bg=od,Fg=Zl,Hg=Array,jg=l,Wg=2147483647,zg=/[^\0-\u007E]/,Gg=/[.\u3002\uFF0E\uFF61]/g,Kg="Overflow: input needs wider integers to process",Yg=RangeError,Jg=jg(Gg.exec),qg=Math.floor,Xg=String.fromCharCode,Qg=jg("".charCodeAt),Zg=jg([].join),$g=jg([].push),eE=jg("".replace),tE=jg("".split),iE=jg("".toLowerCase),rE=function(e){return e+22+75*(e<26)},nE=function(e,t,i){var r=0;for(e=i?qg(e/700):e>>1,e+=qg(e/t);e>455;)e=qg(e/35),r+=36;return qg(r+36*e/(e+38))},oE=function(e){var t,i,r=[],n=(e=function(e){for(var t=[],i=0,r=e.length;i<r;){var n=Qg(e,i++);if(n>=55296&&n<=56319&&i<r){var o=Qg(e,i++);56320==(64512&o)?$g(t,((1023&n)<<10)+(1023&o)+65536):($g(t,n),i--)}else $g(t,n)}return t}(e)).length,o=128,s=0,a=72;for(t=0;t<e.length;t++)(i=e[t])<128&&$g(r,Xg(i));var c=r.length,l=c;for(c&&$g(r,"-");l<n;){var d=Wg;for(t=0;t<e.length;t++)(i=e[t])>=o&&i<d&&(d=i);var u=l+1;if(d-o>qg((Wg-s)/u))throw Yg(Kg);for(s+=(d-o)*u,o=d,t=0;t<e.length;t++){if((i=e[t])<o&&++s>Wg)throw Yg(Kg);if(i==o){for(var h=s,p=36;;){var m=p<=a?1:p>=a+26?26:p-a;if(h<m)break;var _=h-m,f=36-m;$g(r,Xg(rE(m+_%f))),h=qg(_/f),p+=36}$g(r,Xg(rE(h))),a=nE(s,u,l==c),s=0,l++}}s++,o++}return Zg(r,"")},sE=Vn,aE=we,cE=Jm,lE=C,dE=Ta,uE=l,hE=tn,pE=ys,mE=ks,_E=z,fE=kg,gE=function(e){var t=Lg(e),i=xg(this),r=arguments.length,n=r>1?arguments[1]:void 0,o=void 0!==n;o&&(n=Dg(n,r>2?arguments[2]:void 0));var s,a,c,l,d,u,h=Fg(t),p=0;if(!h||this===Hg&&Mg(h))for(s=Vg(t),a=i?new this(s):Hg(s);s>p;p++)u=o?n(t[p],p):t[p],Ug(a,p,u);else for(d=(l=Bg(t,h)).next,a=i?new this:[];!(c=Og(d,l)).done;p++)u=o?Pg(l,n,[c.value,p],!0):c.value,Ug(a,p,u);return a.length=p,a},EE=s_,vE=Up.codeAt,yE=function(e){var t,i,r=[],n=tE(eE(iE(e),Gg,"."),".");for(t=0;t<n.length;t++)i=n[t],$g(r,Jg(zg,i)?"xn--"+oE(i):i);return Zg(r,".")},TE=mu,SE=no,IE=Aa,AE=kf,RE=ar,bE=RE.set,CE=RE.getterFor("URL"),kE=AE.URLSearchParams,wE=AE.getState,NE=lE.URL,DE=lE.TypeError,OE=lE.parseInt,LE=Math.floor,PE=Math.pow,ME=uE("".charAt),xE=uE(/./.exec),VE=uE([].join),UE=uE(1..toString),BE=uE([].pop),FE=uE([].push),HE=uE("".replace),jE=uE([].shift),WE=uE("".split),zE=uE("".slice),GE=uE("".toLowerCase),KE=uE([].unshift),YE="Invalid scheme",JE="Invalid host",qE="Invalid port",XE=/[a-z]/i,QE=/[\d+-.a-z]/i,ZE=/\d/,$E=/^0x/i,ev=/^[0-7]+$/,tv=/^\d+$/,iv=/^[\da-f]+$/i,rv=/[\0\t\n\r #%/:<>?@[\\\]^|]/,nv=/[\0\t\n\r #/:<>?@[\\\]^|]/,ov=/^[\u0000-\u0020]+/,sv=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,av=/[\t\n\r]/g,cv=function(e){var t,i,r,n;if("number"==typeof e){for(t=[],i=0;i<4;i++)KE(t,e%256),e=LE(e/256);return VE(t,".")}if("object"==typeof e){for(t="",r=function(e){for(var t=null,i=1,r=null,n=0,o=0;o<8;o++)0!==e[o]?(n>i&&(t=r,i=n),r=null,n=0):(null===r&&(r=o),++n);return n>i&&(t=r,i=n),t}(e),i=0;i<8;i++)n&&0===e[i]||(n&&(n=!1),r===i?(t+=i?":":"::",n=!0):(t+=UE(e[i],16),i<7&&(t+=":")));return"["+t+"]"}return e},lv={},dv=fE({},lv,{" ":1,'"':1,"<":1,">":1,"`":1}),uv=fE({},dv,{"#":1,"?":1,"{":1,"}":1}),hv=fE({},uv,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),pv=function(e,t){var i=vE(e,0);return i>32&&i<127&&!_E(t,e)?e:encodeURIComponent(e)},mv={ftp:21,file:null,http:80,https:443,ws:80,wss:443},_v=function(e,t){var i;return 2==e.length&&xE(XE,ME(e,0))&&(":"==(i=ME(e,1))||!t&&"|"==i)},fv=function(e){var t;return e.length>1&&_v(zE(e,0,2))&&(2==e.length||"/"===(t=ME(e,2))||"\\"===t||"?"===t||"#"===t)},gv=function(e){return"."===e||"%2e"===GE(e)},Ev={},vv={},yv={},Tv={},Sv={},Iv={},Av={},Rv={},bv={},Cv={},kv={},wv={},Nv={},Dv={},Ov={},Lv={},Pv={},Mv={},xv={},Vv={},Uv={},Bv=function(e,t,i){var r,n,o,s=TE(e);if(t){if(n=this.parse(s))throw DE(n);this.searchParams=null}else{if(void 0!==i&&(r=new Bv(i,!0)),n=this.parse(s,null,r))throw DE(n);(o=wE(new kE)).bindURL(this),this.searchParams=o}};Bv.prototype={type:"URL",parse:function(e,t,i){var r,n,o,s,a,c=this,l=t||Ev,d=0,u="",h=!1,p=!1,m=!1;for(e=TE(e),t||(c.scheme="",c.username="",c.password="",c.host=null,c.port=null,c.path=[],c.query=null,c.fragment=null,c.cannotBeABaseURL=!1,e=HE(e,ov,""),e=HE(e,sv,"$1")),e=HE(e,av,""),r=gE(e);d<=r.length;){switch(n=r[d],l){case Ev:if(!n||!xE(XE,n)){if(t)return YE;l=yv;continue}u+=GE(n),l=vv;break;case vv:if(n&&(xE(QE,n)||"+"==n||"-"==n||"."==n))u+=GE(n);else{if(":"!=n){if(t)return YE;u="",l=yv,d=0;continue}if(t&&(c.isSpecial()!=_E(mv,u)||"file"==u&&(c.includesCredentials()||null!==c.port)||"file"==c.scheme&&!c.host))return;if(c.scheme=u,t)return void(c.isSpecial()&&mv[c.scheme]==c.port&&(c.port=null));u="","file"==c.scheme?l=Dv:c.isSpecial()&&i&&i.scheme==c.scheme?l=Tv:c.isSpecial()?l=Rv:"/"==r[d+1]?(l=Sv,d++):(c.cannotBeABaseURL=!0,FE(c.path,""),l=xv)}break;case yv:if(!i||i.cannotBeABaseURL&&"#"!=n)return YE;if(i.cannotBeABaseURL&&"#"==n){c.scheme=i.scheme,c.path=EE(i.path),c.query=i.query,c.fragment="",c.cannotBeABaseURL=!0,l=Uv;break}l="file"==i.scheme?Dv:Iv;continue;case Tv:if("/"!=n||"/"!=r[d+1]){l=Iv;continue}l=bv,d++;break;case Sv:if("/"==n){l=Cv;break}l=Mv;continue;case Iv:if(c.scheme=i.scheme,n==_g)c.username=i.username,c.password=i.password,c.host=i.host,c.port=i.port,c.path=EE(i.path),c.query=i.query;else if("/"==n||"\\"==n&&c.isSpecial())l=Av;else if("?"==n)c.username=i.username,c.password=i.password,c.host=i.host,c.port=i.port,c.path=EE(i.path),c.query="",l=Vv;else{if("#"!=n){c.username=i.username,c.password=i.password,c.host=i.host,c.port=i.port,c.path=EE(i.path),c.path.length--,l=Mv;continue}c.username=i.username,c.password=i.password,c.host=i.host,c.port=i.port,c.path=EE(i.path),c.query=i.query,c.fragment="",l=Uv}break;case Av:if(!c.isSpecial()||"/"!=n&&"\\"!=n){if("/"!=n){c.username=i.username,c.password=i.password,c.host=i.host,c.port=i.port,l=Mv;continue}l=Cv}else l=bv;break;case Rv:if(l=bv,"/"!=n||"/"!=ME(u,d+1))continue;d++;break;case bv:if("/"!=n&&"\\"!=n){l=Cv;continue}break;case Cv:if("@"==n){h&&(u="%40"+u),h=!0,o=gE(u);for(var _=0;_<o.length;_++){var f=o[_];if(":"!=f||m){var g=pv(f,hv);m?c.password+=g:c.username+=g}else m=!0}u=""}else if(n==_g||"/"==n||"?"==n||"#"==n||"\\"==n&&c.isSpecial()){if(h&&""==u)return"Invalid authority";d-=gE(u).length+1,u="",l=kv}else u+=n;break;case kv:case wv:if(t&&"file"==c.scheme){l=Lv;continue}if(":"!=n||p){if(n==_g||"/"==n||"?"==n||"#"==n||"\\"==n&&c.isSpecial()){if(c.isSpecial()&&""==u)return JE;if(t&&""==u&&(c.includesCredentials()||null!==c.port))return;if(s=c.parseHost(u))return s;if(u="",l=Pv,t)return;continue}"["==n?p=!0:"]"==n&&(p=!1),u+=n}else{if(""==u)return JE;if(s=c.parseHost(u))return s;if(u="",l=Nv,t==wv)return}break;case Nv:if(!xE(ZE,n)){if(n==_g||"/"==n||"?"==n||"#"==n||"\\"==n&&c.isSpecial()||t){if(""!=u){var E=OE(u,10);if(E>65535)return qE;c.port=c.isSpecial()&&E===mv[c.scheme]?null:E,u=""}if(t)return;l=Pv;continue}return qE}u+=n;break;case Dv:if(c.scheme="file","/"==n||"\\"==n)l=Ov;else{if(!i||"file"!=i.scheme){l=Mv;continue}if(n==_g)c.host=i.host,c.path=EE(i.path),c.query=i.query;else if("?"==n)c.host=i.host,c.path=EE(i.path),c.query="",l=Vv;else{if("#"!=n){fv(VE(EE(r,d),""))||(c.host=i.host,c.path=EE(i.path),c.shortenPath()),l=Mv;continue}c.host=i.host,c.path=EE(i.path),c.query=i.query,c.fragment="",l=Uv}}break;case Ov:if("/"==n||"\\"==n){l=Lv;break}i&&"file"==i.scheme&&!fv(VE(EE(r,d),""))&&(_v(i.path[0],!0)?FE(c.path,i.path[0]):c.host=i.host),l=Mv;continue;case Lv:if(n==_g||"/"==n||"\\"==n||"?"==n||"#"==n){if(!t&&_v(u))l=Mv;else if(""==u){if(c.host="",t)return;l=Pv}else{if(s=c.parseHost(u))return s;if("localhost"==c.host&&(c.host=""),t)return;u="",l=Pv}continue}u+=n;break;case Pv:if(c.isSpecial()){if(l=Mv,"/"!=n&&"\\"!=n)continue}else if(t||"?"!=n)if(t||"#"!=n){if(n!=_g&&(l=Mv,"/"!=n))continue}else c.fragment="",l=Uv;else c.query="",l=Vv;break;case Mv:if(n==_g||"/"==n||"\\"==n&&c.isSpecial()||!t&&("?"==n||"#"==n)){if(".."===(a=GE(a=u))||"%2e."===a||".%2e"===a||"%2e%2e"===a?(c.shortenPath(),"/"==n||"\\"==n&&c.isSpecial()||FE(c.path,"")):gv(u)?"/"==n||"\\"==n&&c.isSpecial()||FE(c.path,""):("file"==c.scheme&&!c.path.length&&_v(u)&&(c.host&&(c.host=""),u=ME(u,0)+":"),FE(c.path,u)),u="","file"==c.scheme&&(n==_g||"?"==n||"#"==n))for(;c.path.length>1&&""===c.path[0];)jE(c.path);"?"==n?(c.query="",l=Vv):"#"==n&&(c.fragment="",l=Uv)}else u+=pv(n,uv);break;case xv:"?"==n?(c.query="",l=Vv):"#"==n?(c.fragment="",l=Uv):n!=_g&&(c.path[0]+=pv(n,lv));break;case Vv:t||"#"!=n?n!=_g&&("'"==n&&c.isSpecial()?c.query+="%27":c.query+="#"==n?"%23":pv(n,lv)):(c.fragment="",l=Uv);break;case Uv:n!=_g&&(c.fragment+=pv(n,dv))}d++}},parseHost:function(e){var t,i,r;if("["==ME(e,0)){if("]"!=ME(e,e.length-1))return JE;if(!(t=function(e){var t,i,r,n,o,s,a,c=[0,0,0,0,0,0,0,0],l=0,d=null,u=0,h=function(){return ME(e,u)};if(":"==h()){if(":"!=ME(e,1))return;u+=2,d=++l}for(;h();){if(8==l)return;if(":"!=h()){for(t=i=0;i<4&&xE(iv,h());)t=16*t+OE(h(),16),u++,i++;if("."==h()){if(0==i)return;if(u-=i,l>6)return;for(r=0;h();){if(n=null,r>0){if(!("."==h()&&r<4))return;u++}if(!xE(ZE,h()))return;for(;xE(ZE,h());){if(o=OE(h(),10),null===n)n=o;else{if(0==n)return;n=10*n+o}if(n>255)return;u++}c[l]=256*c[l]+n,2!=++r&&4!=r||l++}if(4!=r)return;break}if(":"==h()){if(u++,!h())return}else if(h())return;c[l++]=t}else{if(null!==d)return;u++,d=++l}}if(null!==d)for(s=l-d,l=7;0!=l&&s>0;)a=c[l],c[l--]=c[d+s-1],c[d+--s]=a;else if(8!=l)return;return c}(zE(e,1,-1))))return JE;this.host=t}else if(this.isSpecial()){if(e=yE(e),xE(rv,e))return JE;if(null===(t=function(e){var t,i,r,n,o,s,a,c=WE(e,".");if(c.length&&""==c[c.length-1]&&c.length--,(t=c.length)>4)return e;for(i=[],r=0;r<t;r++){if(""==(n=c[r]))return e;if(o=10,n.length>1&&"0"==ME(n,0)&&(o=xE($E,n)?16:8,n=zE(n,8==o?1:2)),""===n)s=0;else{if(!xE(10==o?tv:8==o?ev:iv,n))return e;s=OE(n,o)}FE(i,s)}for(r=0;r<t;r++)if(s=i[r],r==t-1){if(s>=PE(256,5-t))return null}else if(s>255)return null;for(a=BE(i),r=0;r<i.length;r++)a+=i[r]*PE(256,3-r);return a}(e)))return JE;this.host=t}else{if(xE(nv,e))return JE;for(t="",i=gE(e),r=0;r<i.length;r++)t+=pv(i[r],lv);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"==this.scheme},includesCredentials:function(){return""!=this.username||""!=this.password},isSpecial:function(){return _E(mv,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"==this.scheme&&1==t&&_v(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,i=e.username,r=e.password,n=e.host,o=e.port,s=e.path,a=e.query,c=e.fragment,l=t+":";return null!==n?(l+="//",e.includesCredentials()&&(l+=i+(r?":"+r:"")+"@"),l+=cv(n),null!==o&&(l+=":"+o)):"file"==t&&(l+="//"),l+=e.cannotBeABaseURL?s[0]:s.length?"/"+VE(s,"/"):"",null!==a&&(l+="?"+a),null!==c&&(l+="#"+c),l},setHref:function(e){var t=this.parse(e);if(t)throw DE(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"==e)try{return new Fv(e.path[0]).origin}catch(cB){return"null"}return"file"!=e&&this.isSpecial()?e+"://"+cv(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(TE(e)+":",Ev)},getUsername:function(){return this.username},setUsername:function(e){var t=gE(TE(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var i=0;i<t.length;i++)this.username+=pv(t[i],hv)}},getPassword:function(){return this.password},setPassword:function(e){var t=gE(TE(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var i=0;i<t.length;i++)this.password+=pv(t[i],hv)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?cv(e):cv(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,kv)},getHostname:function(){var e=this.host;return null===e?"":cv(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,wv)},getPort:function(){var e=this.port;return null===e?"":TE(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""==(e=TE(e))?this.port=null:this.parse(e,Nv))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+VE(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,Pv))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""==(e=TE(e))?this.query=null:("?"==ME(e,0)&&(e=zE(e,1)),this.query="",this.parse(e,Vv)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!=(e=TE(e))?("#"==ME(e,0)&&(e=zE(e,1)),this.fragment="",this.parse(e,Uv)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var Fv=function(e){var t=mE(this,Hv),i=IE(arguments.length,1)>1?arguments[1]:void 0,r=bE(t,new Bv(e,!1,i));aE||(t.href=r.serialize(),t.origin=r.getOrigin(),t.protocol=r.getProtocol(),t.username=r.getUsername(),t.password=r.getPassword(),t.host=r.getHost(),t.hostname=r.getHostname(),t.port=r.getPort(),t.pathname=r.getPathname(),t.search=r.getSearch(),t.searchParams=r.getSearchParams(),t.hash=r.getHash())},Hv=Fv.prototype,jv=function(e,t){return{get:function(){return CE(this)[e]()},set:t&&function(e){return CE(this)[t](e)},configurable:!0,enumerable:!0}};if(aE&&(pE(Hv,"href",jv("serialize","setHref")),pE(Hv,"origin",jv("getOrigin")),pE(Hv,"protocol",jv("getProtocol","setProtocol")),pE(Hv,"username",jv("getUsername","setUsername")),pE(Hv,"password",jv("getPassword","setPassword")),pE(Hv,"host",jv("getHost","setHost")),pE(Hv,"hostname",jv("getHostname","setHostname")),pE(Hv,"port",jv("getPort","setPort")),pE(Hv,"pathname",jv("getPathname","setPathname")),pE(Hv,"search",jv("getSearch","setSearch")),pE(Hv,"searchParams",jv("getSearchParams")),pE(Hv,"hash",jv("getHash","setHash"))),hE(Hv,"toJSON",(function(){return CE(this).serialize()}),{enumerable:!0}),hE(Hv,"toString",(function(){return CE(this).serialize()}),{enumerable:!0}),NE){var Wv=NE.createObjectURL,zv=NE.revokeObjectURL;Wv&&hE(Fv,"createObjectURL",dE(Wv,NE)),zv&&hE(Fv,"revokeObjectURL",dE(zv,NE))}SE(Fv,"URL"),sE({global:!0,constructor:!0,forced:!cE,sham:!aE},{URL:Fv});var Gv="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,Kv=Pt,Yv=Ht,Jv=RangeError,qv=function(e){if(void 0===e)return 0;var t=Kv(e),i=Yv(t);if(t!==i)throw Jv("Wrong length or index");return i},Xv=Array,Qv=Math.abs,Zv=Math.pow,$v=Math.floor,ey=Math.log,ty=Math.LN2,iy=H,ry=Ut,ny=Wt,oy=function(e){for(var t=iy(this),i=ny(t),r=arguments.length,n=ry(r>1?arguments[1]:void 0,i),o=r>2?arguments[2]:void 0,s=void 0===o?i:ry(o,i);s>n;)t[n++]=e;return t},sy=C,ay=l,cy=we,ly=Gv,dy=wr,uy=Yi,hy=ys,py=Xm,my=r,_y=ks,fy=Pt,gy=Ht,Ey=qv,vy={pack:function(e,t,i){var r,n,o,s=Xv(i),a=8*i-t-1,c=(1<<a)-1,l=c>>1,d=23===t?Zv(2,-24)-Zv(2,-77):0,u=e<0||0===e&&1/e<0?1:0,h=0;for((e=Qv(e))!=e||1/0===e?(n=e!=e?1:0,r=c):(r=$v(ey(e)/ty),e*(o=Zv(2,-r))<1&&(r--,o*=2),(e+=r+l>=1?d/o:d*Zv(2,1-l))*o>=2&&(r++,o/=2),r+l>=c?(n=0,r=c):r+l>=1?(n=(e*o-1)*Zv(2,t),r+=l):(n=e*Zv(2,l-1)*Zv(2,t),r=0));t>=8;)s[h++]=255&n,n/=256,t-=8;for(r=r<<t|n,a+=t;a>0;)s[h++]=255&r,r/=256,a-=8;return s[--h]|=128*u,s},unpack:function(e,t){var i,r=e.length,n=8*r-t-1,o=(1<<n)-1,s=o>>1,a=n-7,c=r-1,l=e[c--],d=127&l;for(l>>=7;a>0;)d=256*d+e[c--],a-=8;for(i=d&(1<<-a)-1,d>>=-a,a+=t;a>0;)i=256*i+e[c--],a-=8;if(0===d)d=1-s;else{if(d===o)return i?NaN:l?-1/0:1/0;i+=Zv(2,t),d-=s}return(l?-1:1)*i*Zv(2,d-t)}},yy=Kn,Ty=To,Sy=rn.f,Iy=oy,Ay=s_,Ry=no,by=ar,Cy=dy.PROPER,ky=dy.CONFIGURABLE,wy="ArrayBuffer",Ny="DataView",Dy="prototype",Oy="Wrong index",Ly=by.getterFor(wy),Py=by.getterFor(Ny),My=by.set,xy=sy[wy],Vy=xy,Uy=Vy&&Vy[Dy],By=sy[Ny],Fy=By&&By[Dy],Hy=Object.prototype,jy=sy.Array,Wy=sy.RangeError,zy=ay(Iy),Gy=ay([].reverse),Ky=vy.pack,Yy=vy.unpack,Jy=function(e){return[255&e]},qy=function(e){return[255&e,e>>8&255]},Xy=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},Qy=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},Zy=function(e){return Ky(e,23,4)},$y=function(e){return Ky(e,52,8)},eT=function(e,t,i){hy(e[Dy],t,{configurable:!0,get:function(){return i(this)[t]}})},tT=function(e,t,i,r){var n=Ey(i),o=Py(e);if(n+t>o.byteLength)throw Wy(Oy);var s=o.bytes,a=n+o.byteOffset,c=Ay(s,a,a+t);return r?c:Gy(c)},iT=function(e,t,i,r,n,o){var s=Ey(i),a=Py(e);if(s+t>a.byteLength)throw Wy(Oy);for(var c=a.bytes,l=s+a.byteOffset,d=r(+n),u=0;u<t;u++)c[l+u]=d[o?u:t-u-1]};if(ly){var rT=Cy&&xy.name!==wy;if(my((function(){xy(1)}))&&my((function(){new xy(-1)}))&&!my((function(){return new xy,new xy(1.5),new xy(NaN),1!=xy.length||rT&&!ky})))rT&&ky&&uy(xy,"name",wy);else{(Vy=function(e){return _y(this,Uy),new xy(Ey(e))})[Dy]=Uy;for(var nT,oT=Sy(xy),sT=0;oT.length>sT;)(nT=oT[sT++])in Vy||uy(Vy,nT,xy[nT]);Uy.constructor=Vy}Ty&&yy(Fy)!==Hy&&Ty(Fy,Hy);var aT=new By(new Vy(2)),cT=ay(Fy.setInt8);aT.setInt8(0,2147483648),aT.setInt8(1,2147483649),!aT.getInt8(0)&&aT.getInt8(1)||py(Fy,{setInt8:function(e,t){cT(this,e,t<<24>>24)},setUint8:function(e,t){cT(this,e,t<<24>>24)}},{unsafe:!0})}else Uy=(Vy=function(e){_y(this,Uy);var t=Ey(e);My(this,{type:wy,bytes:zy(jy(t),0),byteLength:t}),cy||(this.byteLength=t,this.detached=!1)})[Dy],Fy=(By=function(e,t,i){_y(this,Fy),_y(e,Uy);var r=Ly(e),n=r.byteLength,o=fy(t);if(o<0||o>n)throw Wy("Wrong offset");if(o+(i=void 0===i?n-o:gy(i))>n)throw Wy("Wrong length");My(this,{type:Ny,buffer:e,byteLength:i,byteOffset:o,bytes:r.bytes}),cy||(this.buffer=e,this.byteLength=i,this.byteOffset=o)})[Dy],cy&&(eT(Vy,"byteLength",Ly),eT(By,"buffer",Py),eT(By,"byteLength",Py),eT(By,"byteOffset",Py)),py(Fy,{getInt8:function(e){return tT(this,1,e)[0]<<24>>24},getUint8:function(e){return tT(this,1,e)[0]},getInt16:function(e){var t=tT(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=tT(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return Qy(tT(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return Qy(tT(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return Yy(tT(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return Yy(tT(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){iT(this,1,e,Jy,t)},setUint8:function(e,t){iT(this,1,e,Jy,t)},setInt16:function(e,t){iT(this,2,e,qy,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){iT(this,2,e,qy,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){iT(this,4,e,Xy,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){iT(this,4,e,Xy,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){iT(this,4,e,Zy,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){iT(this,8,e,$y,t,arguments.length>2?arguments[2]:void 0)}});Ry(Vy,wy),Ry(By,Ny);var lT={ArrayBuffer:Vy,DataView:By},dT=Vn,uT=ga,hT=r,pT=Ce,mT=Ut,_T=Ht,fT=la,gT=lT.ArrayBuffer,ET=lT.DataView,vT=ET.prototype,yT=uT(gT.prototype.slice),TT=uT(vT.getUint8),ST=uT(vT.setUint8);dT({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:hT((function(){return!new gT(2).slice(1,void 0).byteLength}))},{slice:function(e,t){if(yT&&void 0===t)return yT(pT(this),e);for(var i=pT(this).byteLength,r=mT(e,i),n=mT(void 0===t?i:t,i),o=new(fT(this,gT))(_T(n-r)),s=new ET(this),a=new ET(o),c=0;r<n;)ST(a,c++,TT(s,r++));return o}});var IT,AT,RT,bT={},CT={get exports(){return bT},set exports(e){bT=e}},kT=Gv,wT=we,NT=C,DT=ye,OT=Ie,LT=z,PT=xs,MT=Qe,xT=Yi,VT=tn,UT=ys,BT=ze,FT=Kn,HT=To,jT=fe,WT=q,zT=ar.enforce,GT=ar.get,KT=NT.Int8Array,YT=KT&&KT.prototype,JT=NT.Uint8ClampedArray,qT=JT&&JT.prototype,XT=KT&&FT(KT),QT=YT&&FT(YT),ZT=Object.prototype,$T=NT.TypeError,eS=jT("toStringTag"),tS=WT("TYPED_ARRAY_TAG"),iS="TypedArrayConstructor",rS=kT&&!!HT&&"Opera"!==PT(NT.opera),nS=!1,oS={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},sS={BigInt64Array:8,BigUint64Array:8},aS=function(e){var t=FT(e);if(OT(t)){var i=GT(t);return i&&LT(i,iS)?i[iS]:aS(t)}},cS=function(e){if(!OT(e))return!1;var t=PT(e);return LT(oS,t)||LT(sS,t)};for(IT in oS)(RT=(AT=NT[IT])&&AT.prototype)?zT(RT)[iS]=AT:rS=!1;for(IT in sS)(RT=(AT=NT[IT])&&AT.prototype)&&(zT(RT)[iS]=AT);if((!rS||!DT(XT)||XT===Function.prototype)&&(XT=function(){throw $T("Incorrect invocation")},rS))for(IT in oS)NT[IT]&&HT(NT[IT],XT);if((!rS||!QT||QT===ZT)&&(QT=XT.prototype,rS))for(IT in oS)NT[IT]&&HT(NT[IT].prototype,QT);if(rS&&FT(qT)!==QT&&HT(qT,QT),wT&&!LT(QT,eS))for(IT in nS=!0,UT(QT,eS,{configurable:!0,get:function(){return OT(this)?this[tS]:void 0}}),oS)NT[IT]&&xT(NT[IT],tS,IT);var lS={NATIVE_ARRAY_BUFFER_VIEWS:rS,TYPED_ARRAY_TAG:nS&&tS,aTypedArray:function(e){if(cS(e))return e;throw $T("Target is not a typed array")},aTypedArrayConstructor:function(e){if(DT(e)&&(!HT||BT(XT,e)))return e;throw $T(MT(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,i,r){if(wT){if(i)for(var n in oS){var o=NT[n];if(o&&LT(o.prototype,e))try{delete o.prototype[e]}catch(cB){try{o.prototype[e]=t}catch(s){}}}QT[e]&&!i||VT(QT,e,i?t:rS&&YT[e]||t,r)}},exportTypedArrayStaticMethod:function(e,t,i){var r,n;if(wT){if(HT){if(i)for(r in oS)if((n=NT[r])&&LT(n,e))try{delete n[e]}catch(cB){}if(XT[e]&&!i)return;try{return VT(XT,e,i?t:rS&&XT[e]||t)}catch(cB){}}for(r in oS)!(n=NT[r])||n[e]&&!i||VT(n,e,t)}},getTypedArrayConstructor:aS,isView:function(e){if(!OT(e))return!1;var t=PT(e);return"DataView"===t||LT(oS,t)||LT(sS,t)},isTypedArray:cS,TypedArray:XT,TypedArrayPrototype:QT},dS=C,uS=r,hS=kd,pS=lS.NATIVE_ARRAY_BUFFER_VIEWS,mS=dS.ArrayBuffer,_S=dS.Int8Array,fS=!pS||!uS((function(){_S(1)}))||!uS((function(){new _S(-1)}))||!hS((function(e){new _S,new _S(null),new _S(1.5),new _S(e)}),!0)||uS((function(){return 1!==new _S(new mS(2),1,void 0).length})),gS=Ie,ES=Math.floor,vS=Number.isInteger||function(e){return!gS(e)&&isFinite(e)&&ES(e)===e},yS=Pt,TS=RangeError,SS=function(e){var t=yS(e);if(t<0)throw TS("The argument can't be less than 0");return t},IS=RangeError,AS=function(e,t){var i=SS(e);if(i%t)throw IS("Wrong offset");return i},RS=xs,bS=ft,CS=TypeError,kS=function(e){var t=bS(e,"number");if("number"==typeof t)throw CS("Can't convert number to bigint");return BigInt(t)},wS=Ta,NS=Fe,DS=na,OS=H,LS=Wt,PS=od,MS=Zl,xS=Kl,VS=function(e){var t=RS(e);return"BigInt64Array"==t||"BigUint64Array"==t},US=lS.aTypedArrayConstructor,BS=kS,FS=Vn,HS=C,jS=Fe,WS=we,zS=fS,GS=lS,KS=lT,YS=ks,JS=zi,qS=Yi,XS=vS,QS=Ht,ZS=qv,$S=AS,eI=vt,tI=z,iI=xs,rI=Ie,nI=qe,oI=Ni,sI=ze,aI=To,cI=rn.f,lI=function(e){var t,i,r,n,o,s,a,c,l=DS(this),d=OS(e),u=arguments.length,h=u>1?arguments[1]:void 0,p=void 0!==h,m=MS(d);if(m&&!xS(m))for(c=(a=PS(d,m)).next,d=[];!(s=NS(c,a)).done;)d.push(s.value);for(p&&u>2&&(h=wS(h,arguments[2])),i=LS(d),r=new(US(l))(i),n=VS(r),t=0;i>t;t++)o=p?h(d[t],t):d[t],r[t]=n?BS(o):+o;return r},dI=rp.forEach,uI=Rs,hI=ys,pI=De,mI=cr,_I=au,fI=ar.get,gI=ar.set,EI=ar.enforce,vI=pI.f,yI=mI.f,TI=Math.round,SI=HS.RangeError,II=KS.ArrayBuffer,AI=II.prototype,RI=KS.DataView,bI=GS.NATIVE_ARRAY_BUFFER_VIEWS,CI=GS.TYPED_ARRAY_TAG,kI=GS.TypedArray,wI=GS.TypedArrayPrototype,NI=GS.aTypedArrayConstructor,DI=GS.isTypedArray,OI="BYTES_PER_ELEMENT",LI="Wrong length",PI=function(e,t){NI(e);for(var i=0,r=t.length,n=new e(r);r>i;)n[i]=t[i++];return n},MI=function(e,t){hI(e,t,{configurable:!0,get:function(){return fI(this)[t]}})},xI=function(e){var t;return sI(AI,e)||"ArrayBuffer"==(t=iI(e))||"SharedArrayBuffer"==t},VI=function(e,t){return DI(e)&&!nI(t)&&t in e&&XS(+t)&&t>=0},UI=function(e,t){return t=eI(t),VI(e,t)?JS(2,e[t]):yI(e,t)},BI=function(e,t,i){return t=eI(t),!(VI(e,t)&&rI(i)&&tI(i,"value"))||tI(i,"get")||tI(i,"set")||i.configurable||tI(i,"writable")&&!i.writable||tI(i,"enumerable")&&!i.enumerable?vI(e,t,i):(e[t]=i.value,e)};WS?(bI||(mI.f=UI,pI.f=BI,MI(wI,"buffer"),MI(wI,"byteOffset"),MI(wI,"byteLength"),MI(wI,"length")),FS({target:"Object",stat:!0,forced:!bI},{getOwnPropertyDescriptor:UI,defineProperty:BI}),CT.exports=function(e,t,i){var r=e.match(/\d+/)[0]/8,n=e+(i?"Clamped":"")+"Array",o="get"+e,s="set"+e,a=HS[n],c=a,l=c&&c.prototype,d={},u=function(e,t){vI(e,t,{get:function(){return e=t,(i=fI(this)).view[o](e*r+i.byteOffset,!0);var e,i},set:function(e){return n=t,o=e,a=fI(this),i&&(o=(o=TI(o))<0?0:o>255?255:255&o),void a.view[s](n*r+a.byteOffset,o,!0);var n,o,a},enumerable:!0})};bI?zS&&(c=t((function(e,t,i,n){return YS(e,l),_I(rI(t)?xI(t)?void 0!==n?new a(t,$S(i,r),n):void 0!==i?new a(t,$S(i,r)):new a(t):DI(t)?PI(c,t):jS(lI,c,t):new a(ZS(t)),e,c)})),aI&&aI(c,kI),dI(cI(a),(function(e){e in c||qS(c,e,a[e])})),c.prototype=l):(c=t((function(e,t,i,n){YS(e,l);var o,s,a,d=0,h=0;if(rI(t)){if(!xI(t))return DI(t)?PI(c,t):jS(lI,c,t);o=t,h=$S(i,r);var p=t.byteLength;if(void 0===n){if(p%r)throw SI(LI);if((s=p-h)<0)throw SI(LI)}else if((s=QS(n)*r)+h>p)throw SI(LI);a=s/r}else a=ZS(t),o=new II(s=a*r);for(gI(e,{buffer:o,byteOffset:h,byteLength:s,length:a,view:new RI(o)});d<a;)u(e,d++)})),aI&&aI(c,kI),l=c.prototype=oI(wI)),l.constructor!==c&&qS(l,"constructor",c),EI(l).TypedArrayConstructor=c,CI&&qS(l,CI,n);var h=c!=a;d[n]=c,FS({global:!0,constructor:!0,forced:h,sham:!bI},d),OI in c||qS(c,OI,r),OI in l||qS(l,OI,r),uI(n)}):CT.exports=function(){},bT("Uint8",(function(e){return function(t,i,r){return e(this,t,i,r)}}));var FI=oy,HI=kS,jI=xs,WI=Fe,zI=r,GI=lS.aTypedArray,KI=lS.exportTypedArrayMethod,YI=l("".slice);KI("fill",(function(e){var t=arguments.length;GI(this);var i="Big"===YI(jI(this),0,3)?HI(e):+e;return WI(FI,this,i,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)}),zI((function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),1!==e})));var JI=C,qI=Fe,XI=lS,QI=Wt,ZI=AS,$I=H,eA=r,tA=JI.RangeError,iA=JI.Int8Array,rA=iA&&iA.prototype,nA=rA&&rA.set,oA=XI.aTypedArray,sA=XI.exportTypedArrayMethod,aA=!eA((function(){var e=new Uint8ClampedArray(2);return qI(nA,e,{length:1,0:3},1),3!==e[1]})),cA=aA&&XI.NATIVE_ARRAY_BUFFER_VIEWS&&eA((function(){var e=new iA(2);return e.set(1),e.set("2",1),0!==e[0]||2!==e[1]}));sA("set",(function(e){oA(this);var t=ZI(arguments.length>1?arguments[1]:void 0,1),i=$I(e);if(aA)return qI(nA,this,i,t);var r=this.length,n=QI(i),o=0;if(n+t>r)throw tA("Wrong length");for(;o<n;)this[t+o]=i[o++]}),!aA||cA);var lA=X.match(/firefox\/(\d+)/i),dA=!!lA&&+lA[1],uA=/MSIE|Trident/.test(X),hA=X.match(/AppleWebKit\/(\d+)\./),pA=!!hA&&+hA[1],mA=ga,_A=r,fA=tt,gA=h_,EA=dA,vA=uA,yA=re,TA=pA,SA=lS.aTypedArray,IA=lS.exportTypedArrayMethod,AA=C.Uint16Array,RA=AA&&mA(AA.prototype.sort),bA=!(!RA||_A((function(){RA(new AA(2),null)}))&&_A((function(){RA(new AA(2),{})}))),CA=!!RA&&!_A((function(){if(yA)return yA<74;if(EA)return EA<67;if(vA)return!0;if(TA)return TA<602;var e,t,i=new AA(516),r=Array(516);for(e=0;e<516;e++)t=e%4,i[e]=515-e,r[e]=e-2*t+3;for(RA(i,(function(e,t){return(e/4|0)-(t/4|0)})),e=0;e<516;e++)if(i[e]!==r[e])return!0}));IA("sort",(function(e){return void 0!==e&&fA(e),CA?RA(this,e):gA(SA(this),function(e){return function(t,i){return void 0!==e?+e(t,i)||0:i!=i?-1:t!=t?1:0===t&&0===i?1/t>0&&1/i<0?1:-1:t>i}}(e))}),!CA||bA);var kA=Vn,wA=Cc,NA=r,DA=We,OA=ye,LA=la,PA=eu,MA=tn,xA=wA&&wA.prototype;if(kA({target:"Promise",proto:!0,real:!0,forced:!!wA&&NA((function(){xA.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=LA(this,DA("Promise")),i=OA(e);return this.then(i?function(i){return PA(t,e()).then((function(){return i}))}:e,i?function(i){return PA(t,e()).then((function(){throw i}))}:e)}}),OA(wA)){var VA=DA("Promise").prototype.finally;xA.finally!==VA&&MA(xA,"finally",VA,{unsafe:!0})}var UA=Rs,BA="ArrayBuffer",FA=lT[BA];Vn({global:!0,constructor:!0,forced:C[BA]!==FA},{ArrayBuffer:FA}),UA(BA);var HA=Qe,jA=TypeError,WA=Vn,zA=l,GA=tt,KA=H,YA=Wt,JA=function(e,t){if(!delete e[t])throw jA("Cannot delete property "+HA(t)+" of "+HA(e))},qA=mu,XA=r,QA=h_,ZA=op,$A=dA,eR=uA,tR=re,iR=pA,rR=[],nR=zA(rR.sort),oR=zA(rR.push),sR=XA((function(){rR.sort(void 0)})),aR=XA((function(){rR.sort(null)})),cR=ZA("sort"),lR=!XA((function(){if(tR)return tR<70;if(!($A&&$A>3)){if(eR)return!0;if(iR)return iR<603;var e,t,i,r,n="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:i=3;break;case 68:case 71:i=4;break;default:i=2}for(r=0;r<47;r++)rR.push({k:t+r,v:i})}for(rR.sort((function(e,t){return t.v-e.v})),r=0;r<rR.length;r++)t=rR[r].k.charAt(0),n.charAt(n.length-1)!==t&&(n+=t);return"DGBEFHACIJK"!==n}}));WA({target:"Array",proto:!0,forced:sR||!aR||!cR||!lR},{sort:function(e){void 0!==e&&GA(e);var t=KA(this);if(lR)return void 0===e?nR(t):nR(t,e);var i,r,n=[],o=YA(t);for(r=0;r<o;r++)r in t&&oR(n,t[r]);for(QA(n,function(e){return function(t,i){return void 0===i?-1:void 0===t?1:void 0!==e?+e(t,i)||0:qA(t)>qA(i)?1:-1}}(e)),i=YA(n),r=0;r<i;)t[r]=n[r++];for(;r<o;)JA(t,r++);return t}}),bT("Float32",(function(e){return function(t,i,r){return e(this,t,i,r)}}));var dR=Vn,uR=Wh,hR=l([].reverse),pR=[1,2];dR({target:"Array",proto:!0,forced:String(pR)===String(pR.reverse())},{reverse:function(){return uR(this)&&(this.length=this.length),hR(this)}});var mR=Vn,_R=Fe,fR=l,gR=S,ER=ye,vR=v,yR=uu,TR=mu,SR=nt,IR=Su,AR=Jp,RR=fe("replace"),bR=TypeError,CR=fR("".indexOf);fR("".replace);var kR=fR("".slice),wR=Math.max,NR=function(e,t,i){return i>e.length?-1:""===t?i:CR(e,t,i)};mR({target:"String",proto:!0},{replaceAll:function(e,t){var i,r,n,o,s,a,c,l,d=gR(this),u=0,h=0,p="";if(!vR(e)){if(yR(e)&&(i=TR(gR(IR(e))),!~CR(i,"g")))throw bR("`.replaceAll` does not allow non-global regexes");if(r=SR(e,RR))return _R(r,e,d,t)}for(n=TR(d),o=TR(e),(s=ER(t))||(t=TR(t)),a=o.length,c=wR(1,a),u=NR(n,o,0);-1!==u;)l=s?TR(t(o,u,n)):AR(o,n,u,[],void 0,t),p+=kR(n,h,u)+l,h=u+a,u=NR(n,o,u+c);return h<n.length&&(p+=kR(n,h)),p}});let DR=!0,OR=!0;function LR(e,t,i){const r=e.match(t);return r&&r.length>=i&&parseInt(r[i],10)}function PR(e,t,i){if(!e.RTCPeerConnection)return;const r=e.RTCPeerConnection.prototype,n=r.addEventListener;r.addEventListener=function(e,r){if(e!==t)return n.apply(this,arguments);const o=e=>{const t=i(e);t&&(r.handleEvent?r.handleEvent(t):r(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(r,o),n.apply(this,[e,o])};const o=r.removeEventListener;r.removeEventListener=function(e,i){if(e!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(i))return o.apply(this,arguments);const r=this._eventMap[t].get(i);return this._eventMap[t].delete(i),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,r])},Object.defineProperty(r,"on"+t,{get(){return this["_on"+t]},set(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}function MR(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(DR=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function xR(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(OR=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function VR(){if("object"==typeof window){if(DR)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function UR(e,t){OR&&console.warn(e+" is deprecated, please use "+t+" instead.")}function BR(e){return"[object Object]"===Object.prototype.toString.call(e)}function FR(e){return BR(e)?Object.keys(e).reduce((function(t,i){const r=BR(e[i]),n=r?FR(e[i]):e[i],o=r&&!Object.keys(n).length;return void 0===n||o?t:Object.assign(t,{[i]:n})}),{}):e}function HR(e,t,i){t&&!i.has(t.id)&&(i.set(t.id,t),Object.keys(t).forEach((r=>{r.endsWith("Id")?HR(e,e.get(t[r]),i):r.endsWith("Ids")&&t[r].forEach((t=>{HR(e,e.get(t),i)}))})))}function jR(e,t,i){const r=i?"outbound-rtp":"inbound-rtp",n=new Map;if(null===t)return n;const o=[];return e.forEach((e=>{"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)})),o.forEach((t=>{e.forEach((i=>{i.type===r&&i.trackId===t.id&&HR(e,i,n)}))})),n}const WR=VR;function zR(e,t){const i=e&&e.navigator;if(!i.mediaDevices)return;const r=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;const t={};return Object.keys(e).forEach((i=>{if("require"===i||"advanced"===i||"mediaSource"===i)return;const r="object"==typeof e[i]?e[i]:{ideal:e[i]};void 0!==r.exact&&"number"==typeof r.exact&&(r.min=r.max=r.exact);const n=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==r.ideal){t.optional=t.optional||[];let e={};"number"==typeof r.ideal?(e[n("min",i)]=r.ideal,t.optional.push(e),e={},e[n("max",i)]=r.ideal,t.optional.push(e)):(e[n("",i)]=r.ideal,t.optional.push(e))}void 0!==r.exact&&"number"!=typeof r.exact?(t.mandatory=t.mandatory||{},t.mandatory[n("",i)]=r.exact):["min","max"].forEach((e=>{void 0!==r[e]&&(t.mandatory=t.mandatory||{},t.mandatory[n(e,i)]=r[e])}))})),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},n=function(e,n){if(t.version>=61)return n(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"==typeof e.audio){const t=function(e,t,i){t in e&&!(i in e)&&(e[i]=e[t],delete e[t])};t((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),t(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=r(e.audio)}if(e&&"object"==typeof e.video){let o=e.video.facingMode;o=o&&("object"==typeof o?o:{ideal:o});const s=t.version<66;if(o&&("user"===o.exact||"environment"===o.exact||"user"===o.ideal||"environment"===o.ideal)&&(!i.mediaDevices.getSupportedConstraints||!i.mediaDevices.getSupportedConstraints().facingMode||s)){let t;if(delete e.video.facingMode,"environment"===o.exact||"environment"===o.ideal?t=["back","rear"]:"user"!==o.exact&&"user"!==o.ideal||(t=["front"]),t)return i.mediaDevices.enumerateDevices().then((i=>{let s=(i=i.filter((e=>"videoinput"===e.kind))).find((e=>t.some((t=>e.label.toLowerCase().includes(t)))));return!s&&i.length&&t.includes("back")&&(s=i[i.length-1]),s&&(e.video.deviceId=o.exact?{exact:s.deviceId}:{ideal:s.deviceId}),e.video=r(e.video),WR("chrome: "+JSON.stringify(e)),n(e)}))}e.video=r(e.video)}return WR("chrome: "+JSON.stringify(e)),n(e)},o=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}};if(i.getUserMedia=function(e,t,r){n(e,(e=>{i.webkitGetUserMedia(e,t,(e=>{r&&r(o(e))}))}))}.bind(i),i.mediaDevices.getUserMedia){const e=i.mediaDevices.getUserMedia.bind(i.mediaDevices);i.mediaDevices.getUserMedia=function(t){return n(t,(t=>e(t).then((e=>{if(t.audio&&!e.getAudioTracks().length||t.video&&!e.getVideoTracks().length)throw e.getTracks().forEach((e=>{e.stop()})),new DOMException("","NotFoundError");return e}),(e=>Promise.reject(o(e))))))}}}function GR(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function KR(e){if("object"==typeof e&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener("addtrack",(i=>{let r;r=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===i.track.id)):{track:i.track};const n=new Event("track");n.track=i.track,n.receiver=r,n.transceiver={receiver:r},n.streams=[t.stream],this.dispatchEvent(n)})),t.stream.getTracks().forEach((i=>{let r;r=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===i.id)):{track:i};const n=new Event("track");n.track=i,n.receiver=r,n.transceiver={receiver:r},n.streams=[t.stream],this.dispatchEvent(n)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else PR(e,"track",(e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e)))}function YR(e){if("object"==typeof e&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){const t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const i=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){let n=i.apply(this,arguments);return n||(n=t(this,e),this._senders.push(n)),n};const r=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){r.apply(this,arguments);const t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}const i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._senders=this._senders||[],i.apply(this,[e]),e.getTracks().forEach((e=>{this._senders.push(t(this,e))}))};const r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._senders=this._senders||[],r.apply(this,[e]),e.getTracks().forEach((e=>{const t=this._senders.find((t=>t.track===e));t&&this._senders.splice(this._senders.indexOf(t),1)}))}}else if("object"==typeof e&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function JR(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,i,r]=arguments;if(arguments.length>0&&"function"==typeof e)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof e))return t.apply(this,[]);const n=function(e){const t={};return e.result().forEach((e=>{const i={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach((t=>{i[t]=e.stat(t)})),t[i.id]=i})),t},o=function(e){return new Map(Object.keys(e).map((t=>[t,e[t]])))};if(arguments.length>=2){const r=function(e){i(o(n(e)))};return t.apply(this,[r,e])}return new Promise(((e,i)=>{t.apply(this,[function(t){e(o(n(t)))},i])})).then(i,r)}}function qR(e){if(!("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e});const i=e.RTCPeerConnection.prototype.addTrack;i&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=i.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>jR(t,e.track,!0)))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e}),PR(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>jR(t,e.track,!1)))}}if(!("getStats"in e.RTCRtpSender.prototype)||!("getStats"in e.RTCRtpReceiver.prototype))return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){const e=arguments[0];let t,i,r;return this.getSenders().forEach((i=>{i.track===e&&(t?r=!0:t=i)})),this.getReceivers().forEach((t=>(t.track===e&&(i?r=!0:i=t),t.track===e))),r||t&&i?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():i?i.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function XR(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map((e=>this._shimmedLocalStreams[e][0]))};const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,i){if(!i)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const r=t.apply(this,arguments);return this._shimmedLocalStreams[i.id]?-1===this._shimmedLocalStreams[i.id].indexOf(r)&&this._shimmedLocalStreams[i.id].push(r):this._shimmedLocalStreams[i.id]=[i,r],r};const i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach((e=>{if(this.getSenders().find((t=>t.track===e)))throw new DOMException("Track already exists.","InvalidAccessError")}));const t=this.getSenders();i.apply(this,arguments);const r=this.getSenders().filter((e=>-1===t.indexOf(e)));this._shimmedLocalStreams[e.id]=[e].concat(r)};const r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],r.apply(this,arguments)};const n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach((t=>{const i=this._shimmedLocalStreams[t].indexOf(e);-1!==i&&this._shimmedLocalStreams[t].splice(i,1),1===this._shimmedLocalStreams[t].length&&delete this._shimmedLocalStreams[t]})),n.apply(this,arguments)}}function QR(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return XR(e);const i=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){const e=i.apply(this);return this._reverseStreams=this._reverseStreams||{},e.map((e=>this._reverseStreams[e.id]))};const r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach((e=>{if(this.getSenders().find((t=>t.track===e)))throw new DOMException("Track already exists.","InvalidAccessError")})),!this._reverseStreams[t.id]){const i=new e.MediaStream(t.getTracks());this._streams[t.id]=i,this._reverseStreams[i.id]=t,t=i}r.apply(this,[t])};const n=e.RTCPeerConnection.prototype.removeStream;function o(e,t){let i=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const r=e._reverseStreams[t],n=e._streams[r.id];i=i.replace(new RegExp(n.id,"g"),r.id)})),new RTCSessionDescription({type:t.type,sdp:i})}e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},n.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,i){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const r=[].slice.call(arguments,1);if(1!==r.length||!r[0].getTracks().find((e=>e===t)))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find((e=>e.track===t)))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const n=this._streams[i.id];if(n)n.addTrack(t),Promise.resolve().then((()=>{this.dispatchEvent(new Event("negotiationneeded"))}));else{const r=new e.MediaStream([t]);this._streams[i.id]=r,this._reverseStreams[r.id]=i,this.addStream(r)}return this.getSenders().find((e=>e.track===t))},["createOffer","createAnswer"].forEach((function(t){const i=e.RTCPeerConnection.prototype[t],r={[t](){const e=arguments;return arguments.length&&"function"==typeof arguments[0]?i.apply(this,[t=>{const i=o(this,t);e[0].apply(null,[i])},t=>{e[1]&&e[1].apply(null,t)},arguments[2]]):i.apply(this,arguments).then((e=>o(this,e)))}};e.RTCPeerConnection.prototype[t]=r[t]}));const s=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=function(e,t){let i=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const r=e._reverseStreams[t],n=e._streams[r.id];i=i.replace(new RegExp(r.id,"g"),n.id)})),new RTCSessionDescription({type:t.type,sdp:i})}(this,arguments[0]),s.apply(this,arguments)):s.apply(this,arguments)};const a=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get(){const e=a.get.apply(this);return""===e.type?e:o(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(e._pc!==this)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");let t;this._streams=this._streams||{},Object.keys(this._streams).forEach((i=>{this._streams[i].getTracks().find((t=>e.track===t))&&(t=this._streams[i])})),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function ZR(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const i=e.RTCPeerConnection.prototype[t],r={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),i.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=r[t]}))}function $R(e,t){PR(e,"negotiationneeded",(e=>{const i=e.target;if(!(t.version<72||i.getConfiguration&&"plan-b"===i.getConfiguration().sdpSemantics)||"stable"===i.signalingState)return e}))}var eb=Object.freeze({__proto__:null,shimMediaStream:GR,shimOnTrack:KR,shimGetSendersWithDtmf:YR,shimGetStats:JR,shimSenderReceiverGetStats:qR,shimAddTrackRemoveTrackWithNative:XR,shimAddTrackRemoveTrack:QR,shimPeerConnection:ZR,fixNegotiationNeeded:$R,shimGetUserMedia:zR,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(i){return t(i).then((t=>{const r=i.video&&i.video.width,n=i.video&&i.video.height,o=i.video&&i.video.frameRate;return i.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:o||3}},r&&(i.video.mandatory.maxWidth=r),n&&(i.video.mandatory.maxHeight=n),e.navigator.mediaDevices.getUserMedia(i)}))}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}});function tb(e,t){const i=e&&e.navigator,r=e&&e.MediaStreamTrack;if(i.getUserMedia=function(e,t,r){UR("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),i.mediaDevices.getUserMedia(e).then(t,r)},!(t.version>55&&"autoGainControl"in i.mediaDevices.getSupportedConstraints())){const e=function(e,t,i){t in e&&!(i in e)&&(e[i]=e[t],delete e[t])},t=i.mediaDevices.getUserMedia.bind(i.mediaDevices);if(i.mediaDevices.getUserMedia=function(i){return"object"==typeof i&&"object"==typeof i.audio&&(i=JSON.parse(JSON.stringify(i)),e(i.audio,"autoGainControl","mozAutoGainControl"),e(i.audio,"noiseSuppression","mozNoiseSuppression")),t(i)},r&&r.prototype.getSettings){const t=r.prototype.getSettings;r.prototype.getSettings=function(){const i=t.apply(this,arguments);return e(i,"mozAutoGainControl","autoGainControl"),e(i,"mozNoiseSuppression","noiseSuppression"),i}}if(r&&r.prototype.applyConstraints){const t=r.prototype.applyConstraints;r.prototype.applyConstraints=function(i){return"audio"===this.kind&&"object"==typeof i&&(i=JSON.parse(JSON.stringify(i)),e(i,"autoGainControl","mozAutoGainControl"),e(i,"noiseSuppression","mozNoiseSuppression")),t.apply(this,[i])}}}}function ib(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function rb(e,t){if("object"!=typeof e||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const i=e.RTCPeerConnection.prototype[t],r={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),i.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=r[t]}));const i={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},r=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,n,o]=arguments;return r.apply(this,[e||null]).then((e=>{if(t.version<53&&!n)try{e.forEach((e=>{e.type=i[e.type]||e.type}))}catch(r){if("TypeError"!==r.name)throw r;e.forEach(((t,r)=>{e.set(r,Object.assign({},t,{type:i[t.type]||t.type}))}))}return e})).then(n,o)}}function nb(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e});const i=e.RTCPeerConnection.prototype.addTrack;i&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=i.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function ob(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e}),PR(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function sb(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){UR("removeStream","removeTrack"),this.getSenders().forEach((t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t)}))})}function ab(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function cb(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];let e=arguments[1]&&arguments[1].sendEncodings;void 0===e&&(e=[]),e=[...e];const i=e.length>0;i&&e.forEach((e=>{if("rid"in e&&!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(parseFloat(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")}));const r=t.apply(this,arguments);if(i){const{sender:t}=r,i=t.getParameters();(!("encodings"in i)||1===i.encodings.length&&0===Object.keys(i.encodings[0]).length)&&(i.encodings=e,t.sendEncodings=e,this.setParametersPromises.push(t.setParameters(i).then((()=>{delete t.sendEncodings})).catch((()=>{delete t.sendEncodings}))))}return r})}function lb(e){if("object"!=typeof e||!e.RTCRtpSender)return;const t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){const e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})}function db(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((()=>t.apply(this,arguments))).finally((()=>{this.setParametersPromises=[]})):t.apply(this,arguments)}}function ub(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((()=>t.apply(this,arguments))).finally((()=>{this.setParametersPromises=[]})):t.apply(this,arguments)}}var hb=Object.freeze({__proto__:null,shimOnTrack:ib,shimPeerConnection:rb,shimSenderGetStats:nb,shimReceiverGetStats:ob,shimRemoveStream:sb,shimRTCDataChannel:ab,shimAddTransceiver:cb,shimGetParameters:lb,shimCreateOffer:db,shimCreateAnswer:ub,shimGetUserMedia:tb,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(i){if(!i||!i.video){const e=new DOMException("getDisplayMedia without video constraints is undefined");return e.name="NotFoundError",e.code=8,Promise.reject(e)}return!0===i.video?i.video={mediaSource:t}:i.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(i)})}});function pb(e){if("object"==typeof e&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach((i=>t.call(this,i,e))),e.getVideoTracks().forEach((i=>t.call(this,i,e)))},e.RTCPeerConnection.prototype.addTrack=function(e,...i){return i&&i.forEach((e=>{this._localStreams?this._localStreams.includes(e)||this._localStreams.push(e):this._localStreams=[e]})),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const t=this._localStreams.indexOf(e);if(-1===t)return;this._localStreams.splice(t,1);const i=e.getTracks();this.getSenders().forEach((e=>{i.includes(e.track)&&this.removeTrack(e)}))})}}function mb(e){if("object"==typeof e&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=e=>{e.streams.forEach((e=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(e))return;this._remoteStreams.push(e);const t=new Event("addstream");t.stream=e,this.dispatchEvent(t)}))})}});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){const e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach((t=>{if(e._remoteStreams||(e._remoteStreams=[]),e._remoteStreams.indexOf(t)>=0)return;e._remoteStreams.push(t);const i=new Event("addstream");i.stream=t,e.dispatchEvent(i)}))}),t.apply(e,arguments)}}}function _b(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype,i=t.createOffer,r=t.createAnswer,n=t.setLocalDescription,o=t.setRemoteDescription,s=t.addIceCandidate;t.createOffer=function(e,t){const r=arguments.length>=2?arguments[2]:arguments[0],n=i.apply(this,[r]);return t?(n.then(e,t),Promise.resolve()):n},t.createAnswer=function(e,t){const i=arguments.length>=2?arguments[2]:arguments[0],n=r.apply(this,[i]);return t?(n.then(e,t),Promise.resolve()):n};let a=function(e,t,i){const r=n.apply(this,[e]);return i?(r.then(t,i),Promise.resolve()):r};t.setLocalDescription=a,a=function(e,t,i){const r=o.apply(this,[e]);return i?(r.then(t,i),Promise.resolve()):r},t.setRemoteDescription=a,a=function(e,t,i){const r=s.apply(this,[e]);return i?(r.then(t,i),Promise.resolve()):r},t.addIceCandidate=a}function fb(e){const t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){const e=t.mediaDevices,i=e.getUserMedia.bind(e);t.mediaDevices.getUserMedia=e=>i(gb(e))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,i,r){t.mediaDevices.getUserMedia(e).then(i,r)}.bind(t))}function gb(e){return e&&void 0!==e.video?Object.assign({},e,{video:FR(e.video)}):e}function Eb(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,i){if(e&&e.iceServers){const t=[];for(let i=0;i<e.iceServers.length;i++){let r=e.iceServers[i];void 0===r.urls&&r.url?(UR("RTCIceServer.url","RTCIceServer.urls"),r=JSON.parse(JSON.stringify(r)),r.urls=r.url,delete r.url,t.push(r)):t.push(e.iceServers[i])}e.iceServers=t}return new t(e,i)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:()=>t.generateCertificate})}function vb(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function yb(e){const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);const t=this.getTransceivers().find((e=>"audio"===e.receiver.track.kind));!1===e.offerToReceiveAudio&&t?"sendrecv"===t.direction?t.setDirection?t.setDirection("sendonly"):t.direction="sendonly":"recvonly"===t.direction&&(t.setDirection?t.setDirection("inactive"):t.direction="inactive"):!0!==e.offerToReceiveAudio||t||this.addTransceiver("audio",{direction:"recvonly"}),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);const i=this.getTransceivers().find((e=>"video"===e.receiver.track.kind));!1===e.offerToReceiveVideo&&i?"sendrecv"===i.direction?i.setDirection?i.setDirection("sendonly"):i.direction="sendonly":"recvonly"===i.direction&&(i.setDirection?i.setDirection("inactive"):i.direction="inactive"):!0!==e.offerToReceiveVideo||i||this.addTransceiver("video",{direction:"recvonly"})}return t.apply(this,arguments)}}function Tb(e){"object"!=typeof e||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var Sb=Object.freeze({__proto__:null,shimLocalStreamsAPI:pb,shimRemoteStreamsAPI:mb,shimCallbacksAPI:_b,shimGetUserMedia:fb,shimConstraints:gb,shimRTCIceServerUrls:Eb,shimTrackEventTransceiver:vb,shimCreateOfferLegacy:yb,shimAudioContext:Tb}),Ib={};!function(e){const t={generateIdentifier:function(){return Math.random().toString(36).substring(2,12)}};t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split("\n").map((e=>e.trim()))},t.splitSections=function(e){return e.split("\nm=").map(((e,t)=>(t>0?"m="+e:e).trim()+"\r\n"))},t.getDescription=function(e){const i=t.splitSections(e);return i&&i[0]},t.getMediaSections=function(e){const i=t.splitSections(e);return i.shift(),i},t.matchPrefix=function(e,i){return t.splitLines(e).filter((e=>0===e.indexOf(i)))},t.parseCandidate=function(e){let t;t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" ");const i={foundation:t[0],component:{1:"rtp",2:"rtcp"}[t[1]]||t[1],protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]};for(let r=8;r<t.length;r+=2)switch(t[r]){case"raddr":i.relatedAddress=t[r+1];break;case"rport":i.relatedPort=parseInt(t[r+1],10);break;case"tcptype":i.tcpType=t[r+1];break;case"ufrag":i.ufrag=t[r+1],i.usernameFragment=t[r+1];break;default:void 0===i[t[r]]&&(i[t[r]]=t[r+1])}return i},t.writeCandidate=function(e){const t=[];t.push(e.foundation);const i=e.component;"rtp"===i?t.push(1):"rtcp"===i?t.push(2):t.push(i),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);const r=e.type;return t.push("typ"),t.push(r),"host"!==r&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(t.push("ufrag"),t.push(e.usernameFragment||e.ufrag)),"candidate:"+t.join(" ")},t.parseIceOptions=function(e){return e.substring(14).split(" ")},t.parseRtpMap=function(e){let t=e.substring(9).split(" ");const i={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),i.name=t[0],i.clockRate=parseInt(t[1],10),i.channels=3===t.length?parseInt(t[2],10):1,i.numChannels=i.channels,i},t.writeRtpMap=function(e){let t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);const i=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==i?"/"+i:"")+"\r\n"},t.parseExtmap=function(e){const t=e.substring(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1],attributes:t.slice(2).join(" ")}},t.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+(e.attributes?" "+e.attributes:"")+"\r\n"},t.parseFmtp=function(e){const t={};let i;const r=e.substring(e.indexOf(" ")+1).split(";");for(let n=0;n<r.length;n++)i=r[n].trim().split("="),t[i[0].trim()]=i[1];return t},t.writeFmtp=function(e){let t="",i=e.payloadType;if(void 0!==e.preferredPayloadType&&(i=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){const r=[];Object.keys(e.parameters).forEach((t=>{void 0!==e.parameters[t]?r.push(t+"="+e.parameters[t]):r.push(t)})),t+="a=fmtp:"+i+" "+r.join(";")+"\r\n"}return t},t.parseRtcpFb=function(e){const t=e.substring(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},t.writeRtcpFb=function(e){let t="",i=e.payloadType;return void 0!==e.preferredPayloadType&&(i=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach((e=>{t+="a=rtcp-fb:"+i+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"})),t},t.parseSsrcMedia=function(e){const t=e.indexOf(" "),i={ssrc:parseInt(e.substring(7,t),10)},r=e.indexOf(":",t);return r>-1?(i.attribute=e.substring(t+1,r),i.value=e.substring(r+1)):i.attribute=e.substring(t+1),i},t.parseSsrcGroup=function(e){const t=e.substring(13).split(" ");return{semantics:t.shift(),ssrcs:t.map((e=>parseInt(e,10)))}},t.getMid=function(e){const i=t.matchPrefix(e,"a=mid:")[0];if(i)return i.substring(6)},t.parseFingerprint=function(e){const t=e.substring(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},t.getDtlsParameters=function(e,i){return{role:"auto",fingerprints:t.matchPrefix(e+i,"a=fingerprint:").map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,t){let i="a=setup:"+t+"\r\n";return e.fingerprints.forEach((e=>{i+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),i},t.parseCryptoLine=function(e){const t=e.substring(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},t.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==typeof e.keyParams?t.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},t.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;const t=e.substring(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},t.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},t.getCryptoParameters=function(e,i){return t.matchPrefix(e+i,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(e,i){const r=t.matchPrefix(e+i,"a=ice-ufrag:")[0],n=t.matchPrefix(e+i,"a=ice-pwd:")[0];return r&&n?{usernameFragment:r.substring(12),password:n.substring(10)}:null},t.writeIceParameters=function(e){let t="a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n";return e.iceLite&&(t+="a=ice-lite\r\n"),t},t.parseRtpParameters=function(e){const i={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=t.splitLines(e)[0].split(" ");i.profile=r[2];for(let o=3;o<r.length;o++){const n=r[o],s=t.matchPrefix(e,"a=rtpmap:"+n+" ")[0];if(s){const r=t.parseRtpMap(s),o=t.matchPrefix(e,"a=fmtp:"+n+" ");switch(r.parameters=o.length?t.parseFmtp(o[0]):{},r.rtcpFeedback=t.matchPrefix(e,"a=rtcp-fb:"+n+" ").map(t.parseRtcpFb),i.codecs.push(r),r.name.toUpperCase()){case"RED":case"ULPFEC":i.fecMechanisms.push(r.name.toUpperCase())}}}t.matchPrefix(e,"a=extmap:").forEach((e=>{i.headerExtensions.push(t.parseExtmap(e))}));const n=t.matchPrefix(e,"a=rtcp-fb:* ").map(t.parseRtcpFb);return i.codecs.forEach((e=>{n.forEach((t=>{e.rtcpFeedback.find((e=>e.type===t.type&&e.parameter===t.parameter))||e.rtcpFeedback.push(t)}))})),i},t.writeRtpDescription=function(e,i){let r="";r+="m="+e+" ",r+=i.codecs.length>0?"9":"0",r+=" "+(i.profile||"UDP/TLS/RTP/SAVPF")+" ",r+=i.codecs.map((e=>void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType)).join(" ")+"\r\n",r+="c=IN IP4 0.0.0.0\r\n",r+="a=rtcp:9 IN IP4 0.0.0.0\r\n",i.codecs.forEach((e=>{r+=t.writeRtpMap(e),r+=t.writeFmtp(e),r+=t.writeRtcpFb(e)}));let n=0;return i.codecs.forEach((e=>{e.maxptime>n&&(n=e.maxptime)})),n>0&&(r+="a=maxptime:"+n+"\r\n"),i.headerExtensions&&i.headerExtensions.forEach((e=>{r+=t.writeExtmap(e)})),r},t.parseRtpEncodingParameters=function(e){const i=[],r=t.parseRtpParameters(e),n=-1!==r.fecMechanisms.indexOf("RED"),o=-1!==r.fecMechanisms.indexOf("ULPFEC"),s=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"cname"===e.attribute)),a=s.length>0&&s[0].ssrc;let c;const l=t.matchPrefix(e,"a=ssrc-group:FID").map((e=>e.substring(17).split(" ").map((e=>parseInt(e,10)))));l.length>0&&l[0].length>1&&l[0][0]===a&&(c=l[0][1]),r.codecs.forEach((e=>{if("RTX"===e.name.toUpperCase()&&e.parameters.apt){let t={ssrc:a,codecPayloadType:parseInt(e.parameters.apt,10)};a&&c&&(t.rtx={ssrc:c}),i.push(t),n&&(t=JSON.parse(JSON.stringify(t)),t.fec={ssrc:a,mechanism:o?"red+ulpfec":"red"},i.push(t))}})),0===i.length&&a&&i.push({ssrc:a});let d=t.matchPrefix(e,"b=");return d.length&&(d=0===d[0].indexOf("b=TIAS:")?parseInt(d[0].substring(7),10):0===d[0].indexOf("b=AS:")?1e3*parseInt(d[0].substring(5),10)*.95-16e3:void 0,i.forEach((e=>{e.maxBitrate=d}))),i},t.parseRtcpParameters=function(e){const i={},r=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"cname"===e.attribute))[0];r&&(i.cname=r.value,i.ssrc=r.ssrc);const n=t.matchPrefix(e,"a=rtcp-rsize");i.reducedSize=n.length>0,i.compound=0===n.length;const o=t.matchPrefix(e,"a=rtcp-mux");return i.mux=o.length>0,i},t.writeRtcpParameters=function(e){let t="";return e.reducedSize&&(t+="a=rtcp-rsize\r\n"),e.mux&&(t+="a=rtcp-mux\r\n"),void 0!==e.ssrc&&e.cname&&(t+="a=ssrc:"+e.ssrc+" cname:"+e.cname+"\r\n"),t},t.parseMsid=function(e){let i;const r=t.matchPrefix(e,"a=msid:");if(1===r.length)return i=r[0].substring(7).split(" "),{stream:i[0],track:i[1]};const n=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"msid"===e.attribute));return n.length>0?(i=n[0].value.split(" "),{stream:i[0],track:i[1]}):void 0},t.parseSctpDescription=function(e){const i=t.parseMLine(e),r=t.matchPrefix(e,"a=max-message-size:");let n;r.length>0&&(n=parseInt(r[0].substring(19),10)),isNaN(n)&&(n=65536);const o=t.matchPrefix(e,"a=sctp-port:");if(o.length>0)return{port:parseInt(o[0].substring(12),10),protocol:i.fmt,maxMessageSize:n};const s=t.matchPrefix(e,"a=sctpmap:");if(s.length>0){const e=s[0].substring(10).split(" ");return{port:parseInt(e[0],10),protocol:e[1],maxMessageSize:n}}},t.writeSctpDescription=function(e,t){let i=[];return i="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&i.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),i.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,22)},t.writeSessionBoilerplate=function(e,i,r){let n;const o=void 0!==i?i:2;return n=e||t.generateSessionId(),"v=0\r\no="+(r||"thisisadapterortc")+" "+n+" "+o+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},t.getDirection=function(e,i){const r=t.splitLines(e);for(let t=0;t<r.length;t++)switch(r[t]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return r[t].substring(2)}return i?t.getDirection(i):"sendrecv"},t.getKind=function(e){return t.splitLines(e)[0].split(" ")[0].substring(2)},t.isRejected=function(e){return"0"===e.split(" ",2)[1]},t.parseMLine=function(e){const i=t.splitLines(e)[0].substring(2).split(" ");return{kind:i[0],port:parseInt(i[1],10),protocol:i[2],fmt:i.slice(3).join(" ")}},t.parseOLine=function(e){const i=t.matchPrefix(e,"o=")[0].substring(2).split(" ");return{username:i[0],sessionId:i[1],sessionVersion:parseInt(i[2],10),netType:i[3],addressType:i[4],address:i[5]}},t.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;const i=t.splitLines(e);for(let t=0;t<i.length;t++)if(i[t].length<2||"="!==i[t].charAt(1))return!1;return!0},e.exports=t}({get exports(){return Ib},set exports(e){Ib=e}});var Ab=Ib,Rb=e({__proto__:null,default:Ab},[Ib]);function bb(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;const t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"==typeof e&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substring(2)),e.candidate&&e.candidate.length){const i=new t(e),r=Ab.parseCandidate(e.candidate);for(const e in r)e in i||Object.defineProperty(i,e,{value:r[e]});return i.toJSON=function(){return{candidate:i.candidate,sdpMid:i.sdpMid,sdpMLineIndex:i.sdpMLineIndex,usernameFragment:i.usernameFragment}},i}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,PR(e,"icecandidate",(t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t)))}function Cb(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||PR(e,"icecandidate",(e=>{if(e.candidate){const t=Ab.parseCandidate(e.candidate.candidate);"relay"===t.type&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e}))}function kb(e,t){if(!e.RTCPeerConnection)return;"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get(){return void 0===this._sctp?null:this._sctp}});const i=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){const{sdpSemantics:e}=this.getConfiguration();"plan-b"===e&&Object.defineProperty(this,"sctp",{get(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(function(e){if(!e||!e.sdp)return!1;const t=Ab.splitSections(e.sdp);return t.shift(),t.some((e=>{const t=Ab.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")}))}(arguments[0])){const e=function(e){const t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;const i=parseInt(t[1],10);return i!=i?-1:i}(arguments[0]),i=function(e){let i=65536;return"firefox"===t.browser&&(i=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),i}(e),r=function(e,i){let r=65536;"firefox"===t.browser&&57===t.version&&(r=65535);const n=Ab.matchPrefix(e.sdp,"a=max-message-size:");return n.length>0?r=parseInt(n[0].substring(19),10):"firefox"===t.browser&&-1!==i&&(r=2147483637),r}(arguments[0],e);let n;n=0===i&&0===r?Number.POSITIVE_INFINITY:0===i||0===r?Math.max(i,r):Math.min(i,r);const o={};Object.defineProperty(o,"maxMessageSize",{get:()=>n}),this._sctp=o}return i.apply(this,arguments)}}function wb(e){if(!e.RTCPeerConnection||!("createDataChannel"in e.RTCPeerConnection.prototype))return;function t(e,t){const i=e.send;e.send=function(){const r=arguments[0],n=r.length||r.size||r.byteLength;if("open"===e.readyState&&t.sctp&&n>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return i.apply(e,arguments)}}const i=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){const e=i.apply(this,arguments);return t(e,this),e},PR(e,"datachannel",(e=>(t(e.channel,e.target),e)))}function Nb(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;const t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach((e=>{const i=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=e=>{const t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;const i=new Event("connectionstatechange",e);t.dispatchEvent(i)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),i.apply(this,arguments)}}))}function Db(e,t){if(!e.RTCPeerConnection)return;if("chrome"===t.browser&&t.version>=71)return;if("safari"===t.browser&&t.version>=605)return;const i=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){const i=t.sdp.split("\n").filter((e=>"a=extmap-allow-mixed"!==e.trim())).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:i}):t.sdp=i}return i.apply(this,arguments)}}function Ob(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const i=e.RTCPeerConnection.prototype.addIceCandidate;i&&0!==i.length&&(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():i.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}function Lb(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const i=e.RTCPeerConnection.prototype.setLocalDescription;i&&0!==i.length&&(e.RTCPeerConnection.prototype.setLocalDescription=function(){let e=arguments[0]||{};if("object"!=typeof e||e.type&&e.sdp)return i.apply(this,arguments);if(e={type:e.type,sdp:e.sdp},!e.type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":e.type="offer";break;default:e.type="answer"}return e.sdp||"offer"!==e.type&&"answer"!==e.type?i.apply(this,[e]):("offer"===e.type?this.createOffer:this.createAnswer).apply(this).then((e=>i.apply(this,[e])))})}var Pb=Object.freeze({__proto__:null,shimRTCIceCandidate:bb,shimRTCIceCandidateRelayProtocol:Cb,shimMaxMessageSize:kb,shimSendThrowTypeError:wb,shimConnectionState:Nb,removeExtmapAllowMixed:Db,shimAddIceCandidateNullOrEmpty:Ob,shimParameterlessSetLocalDescription:Lb});!function({window:e}={},t={shimChrome:!0,shimFirefox:!0,shimSafari:!0}){const i=VR,r=function(e){const t={browser:null,version:null};if(void 0===e||!e.navigator||!e.navigator.userAgent)return t.browser="Not a browser.",t;const{navigator:i}=e;if(i.mozGetUserMedia)t.browser="firefox",t.version=LR(i.userAgent,/Firefox\/(\d+)\./,1);else if(i.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection)t.browser="chrome",t.version=LR(i.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!e.RTCPeerConnection||!i.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=LR(i.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}(e),n={browserDetails:r,commonShim:Pb,extractVersion:LR,disableLog:MR,disableWarnings:xR,sdp:Rb};switch(r.browser){case"chrome":if(!eb||!ZR||!t.shimChrome)return i("Chrome shim is not included in this adapter release."),n;if(null===r.version)return i("Chrome shim can not determine version, not shimming."),n;i("adapter.js shimming chrome."),n.browserShim=eb,Ob(e,r),Lb(e),zR(e,r),GR(e),ZR(e,r),KR(e),QR(e,r),YR(e),JR(e),qR(e),$R(e,r),bb(e),Cb(e),Nb(e),kb(e,r),wb(e),Db(e,r);break;case"firefox":if(!hb||!rb||!t.shimFirefox)return i("Firefox shim is not included in this adapter release."),n;i("adapter.js shimming firefox."),n.browserShim=hb,Ob(e,r),Lb(e),tb(e,r),rb(e,r),ib(e),sb(e),nb(e),ob(e),ab(e),cb(e),lb(e),db(e),ub(e),bb(e),Nb(e),kb(e,r),wb(e);break;case"safari":if(!Sb||!t.shimSafari)return i("Safari shim is not included in this adapter release."),n;i("adapter.js shimming safari."),n.browserShim=Sb,Ob(e,r),Lb(e),Eb(e),yb(e),_b(e),pb(e),mb(e),vb(e),fb(e),Tb(e),bb(e),Cb(e),kb(e,r),wb(e),Db(e,r);break;default:i("Unsupported browser!")}}({window:"undefined"==typeof window?void 0:window});var Mb,xb=Object.create,Vb=Object.defineProperty,Ub=Object.defineProperties,Bb=Object.getOwnPropertyDescriptor,Fb=Object.getOwnPropertyDescriptors,Hb=Object.getOwnPropertyNames,jb=Object.getOwnPropertySymbols,Wb=Object.getPrototypeOf,zb=Object.prototype.hasOwnProperty,Gb=Object.prototype.propertyIsEnumerable,Kb=Reflect.get,Yb=Math.pow,Jb=(e,t,i)=>t in e?Vb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,qb=(e,t)=>{for(var i in t||(t={}))zb.call(t,i)&&Jb(e,i,t[i]);if(jb)for(var i of jb(t))Gb.call(t,i)&&Jb(e,i,t[i]);return e},Xb=(e,t)=>Ub(e,Fb(t)),Qb=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Zb=(e,t)=>{for(var i in t)Vb(e,i,{get:t[i],enumerable:!0})},$b=(e,t,i)=>(i=null!=e?xb(Wb(e)):{},((e,t,i,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let n of Hb(t))!zb.call(e,n)&&n!==i&&Vb(e,n,{get:()=>t[n],enumerable:!(r=Bb(t,n))||r.enumerable});return e})(!t&&e&&e.__esModule?i:Vb(i,"default",{value:e,enumerable:!0}),e)),eC=(e,t,i,r)=>{for(var n,o=r>1?void 0:r?Bb(t,i):t,s=e.length-1;s>=0;s--)(n=e[s])&&(o=(r?n(t,i,o):n(o))||o);return r&&o&&Vb(t,i,o),o},tC=(e,t,i)=>(Jb(e,"symbol"!=typeof t?t+"":t,i),i),iC=(e,t,i)=>Kb(Wb(e),i,t),rC=(e,t,i)=>new Promise(((r,n)=>{var o=e=>{try{a(i.next(e))}catch(t){n(t)}},s=e=>{try{a(i.throw(e))}catch(t){n(t)}},a=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,s);a((i=i.apply(e,t)).next())})),nC=Qb(((e,t)=>{var i=Object.prototype.hasOwnProperty,r="~";function n(){}function o(e,t,i){this.fn=e,this.context=t,this.once=i||!1}function s(e,t,i,n,s){if("function"!=typeof i)throw new TypeError("The listener must be a function");var a=new o(i,n||e,s),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function a(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function c(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),c.prototype.eventNames=function(){var e,t,n=[];if(0===this._eventsCount)return n;for(t in e=this._events)i.call(e,t)&&n.push(r?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},c.prototype.listeners=function(e){var t=r?r+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,o=i.length,s=new Array(o);n<o;n++)s[n]=i[n].fn;return s},c.prototype.listenerCount=function(e){var t=r?r+e:e,i=this._events[t];return i?i.fn?1:i.length:0},c.prototype.emit=function(e,t,i,n,o,s){var a=r?r+e:e;if(!this._events[a])return!1;var c,l,d=this._events[a],u=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),u){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,i),!0;case 4:return d.fn.call(d.context,t,i,n),!0;case 5:return d.fn.call(d.context,t,i,n,o),!0;case 6:return d.fn.call(d.context,t,i,n,o,s),!0}for(l=1,c=new Array(u-1);l<u;l++)c[l-1]=arguments[l];d.fn.apply(d.context,c)}else{var h,p=d.length;for(l=0;l<p;l++)switch(d[l].once&&this.removeListener(e,d[l].fn,void 0,!0),u){case 1:d[l].fn.call(d[l].context);break;case 2:d[l].fn.call(d[l].context,t);break;case 3:d[l].fn.call(d[l].context,t,i);break;case 4:d[l].fn.call(d[l].context,t,i,n);break;default:if(!c)for(h=1,c=new Array(u-1);h<u;h++)c[h-1]=arguments[h];d[l].fn.apply(d[l].context,c)}}return!0},c.prototype.on=function(e,t,i){return s(this,e,t,i,!1)},c.prototype.once=function(e,t,i){return s(this,e,t,i,!0)},c.prototype.removeListener=function(e,t,i,n){var o=r?r+e:e;if(!this._events[o])return this;if(!t)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn===t&&(!n||s.once)&&(!i||s.context===i)&&a(this,o);else{for(var c=0,l=[],d=s.length;c<d;c++)(s[c].fn!==t||n&&!s[c].once||i&&s[c].context!==i)&&l.push(s[c]);l.length?this._events[o]=1===l.length?l[0]:l:a(this,o)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&a(this,t)):(this._events=new n,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,void 0!==t&&(t.exports=c)})),oC=Qb(((e,t)=>{var i=t.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),(t+=null!=e["network-id"]?" network-id %d":"%v")+(null!=e["network-cost"]?" network-cost %d":"%v")}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",(t+=null!=e.rateNumerator?" rate=%s":"")+(null!=e.rateDenominator?"/%s":"")}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(i).forEach((function(e){i[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))}))})),sC=Qb((e=>{var t=function(e){return String(Number(e))===e?Number(e):e},i=function(e,i,r){var n=e.name&&e.names;e.push&&!i[e.push]?i[e.push]=[]:n&&!i[e.name]&&(i[e.name]={});var o=e.push?{}:n?i[e.name]:i;(function(e,i,r,n){if(n&&!r)i[n]=t(e[1]);else for(var o=0;o<r.length;o+=1)null!=e[o+1]&&(i[r[o]]=t(e[o+1]))})(r.match(e.reg),o,e.names,e.name),e.push&&i[e.push].push(o)},r=oC(),n=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},o=[],s=t;return e.split(/(\r\n|\r|\n)/).filter(n).forEach((function(e){var t=e[0],n=e.slice(2);"m"===t&&(o.push({rtp:[],fmtp:[]}),s=o[o.length-1]);for(var a=0;a<(r[t]||[]).length;a+=1){var c=r[t][a];if(c.reg.test(n))return i(c,s,n)}})),t.media=o,t};var o=function(e,i){var r=i.split(/=(.+)/,2);return 2===r.length?e[r[0]]=t(r[1]):1===r.length&&i.length>1&&(e[r[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return e.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(e){for(var i=[],r=e.split(" ").map(t),n=0;n<r.length;n+=3)i.push({component:r[n],ip:r[n+1],port:r[n+2]});return i},e.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(o,{})}))},e.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var i,r=!1;return"~"!==e[0]?i=t(e):(i=t(e.substring(1,e.length)),r=!0),{scid:i,paused:r}}))}))}})),aC=Qb(((e,t)=>{var i=oC(),r=/%[sdv%]/g,n=function(e){var t=1,i=arguments,n=i.length;return e.replace(r,(function(e){if(t>=n)return e;var r=i[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(r);case"%d":return Number(r);case"%v":return""}}))},o=function(e,t,i){var r=[e+"="+(t.format instanceof Function?t.format(t.push?i:i[t.name]):t.format)];if(t.names)for(var o=0;o<t.names.length;o+=1){var s=t.names[o];t.name?r.push(i[t.name][s]):r.push(i[t.names[o]])}else r.push(i[t.name]);return n.apply(null,r)},s=["v","o","s","i","u","e","p","c","b","t","r","z","a"],a=["i","c","b","a"];t.exports=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach((function(e){null==e.payloads&&(e.payloads="")}));var r=t.outerOrder||s,n=t.innerOrder||a,c=[];return r.forEach((function(t){i[t].forEach((function(i){i.name in e&&null!=e[i.name]?c.push(o(t,i,e)):i.push in e&&null!=e[i.push]&&e[i.push].forEach((function(e){c.push(o(t,i,e))}))}))})),e.media.forEach((function(e){c.push(o("m",i.m[0],e)),n.forEach((function(t){i[t].forEach((function(i){i.name in e&&null!=e[i.name]?c.push(o(t,i,e)):i.push in e&&null!=e[i.push]&&e[i.push].forEach((function(e){c.push(o(t,i,e))}))}))}))})),c.join("\r\n")+"\r\n"}})),cC=Qb((e=>{var t=sC(),i=aC();e.write=i,e.parse=t.parse,e.parseParams=t.parseParams,e.parseFmtpConfig=t.parseFmtpConfig,e.parsePayloads=t.parsePayloads,e.parseRemoteCandidates=t.parseRemoteCandidates,e.parseImageAttributes=t.parseImageAttributes,e.parseSimulcastStreamList=t.parseSimulcastStreamList})),lC=Qb(((e,t)=>{var i=t.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),(t+=null!=e["network-id"]?" network-id %d":"%v")+(null!=e["network-cost"]?" network-cost %d":"%v")}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",(t+=null!=e.rateNumerator?" rate=%s":"")+(null!=e.rateDenominator?"/%s":"")}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(i).forEach((function(e){i[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))}))})),dC=Qb((e=>{var t=function(e){return String(Number(e))===e?Number(e):e},i=function(e,i,r){var n=e.name&&e.names;e.push&&!i[e.push]?i[e.push]=[]:n&&!i[e.name]&&(i[e.name]={});var o=e.push?{}:n?i[e.name]:i;(function(e,i,r,n){if(n&&!r)i[n]=t(e[1]);else for(var o=0;o<r.length;o+=1)null!=e[o+1]&&(i[r[o]]=t(e[o+1]))})(r.match(e.reg),o,e.names,e.name),e.push&&i[e.push].push(o)},r=lC(),n=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},o=[],s=t;return e.split(/(\r\n|\r|\n)/).filter(n).forEach((function(e){var t=e[0],n=e.slice(2);"m"===t&&(o.push({rtp:[],fmtp:[]}),s=o[o.length-1]);for(var a=0;a<(r[t]||[]).length;a+=1){var c=r[t][a];if(c.reg.test(n))return i(c,s,n)}})),t.media=o,t};var o=function(e,i){var r=i.split(/=(.+)/,2);return 2===r.length?e[r[0]]=t(r[1]):1===r.length&&i.length>1&&(e[r[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return e.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(e){for(var i=[],r=e.split(" ").map(t),n=0;n<r.length;n+=3)i.push({component:r[n],ip:r[n+1],port:r[n+2]});return i},e.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(o,{})}))},e.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var i,r=!1;return"~"!==e[0]?i=t(e):(i=t(e.substring(1,e.length)),r=!0),{scid:i,paused:r}}))}))}})),uC=Qb(((e,t)=>{var i=lC(),r=/%[sdv%]/g,n=function(e){var t=1,i=arguments,n=i.length;return e.replace(r,(function(e){if(t>=n)return e;var r=i[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(r);case"%d":return Number(r);case"%v":return""}}))},o=function(e,t,i){var r=[e+"="+(t.format instanceof Function?t.format(t.push?i:i[t.name]):t.format)];if(t.names)for(var o=0;o<t.names.length;o+=1){var s=t.names[o];t.name?r.push(i[t.name][s]):r.push(i[t.names[o]])}else r.push(i[t.name]);return n.apply(null,r)},s=["v","o","s","i","u","e","p","c","b","t","r","z","a"],a=["i","c","b","a"];t.exports=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach((function(e){null==e.payloads&&(e.payloads="")}));var r=t.outerOrder||s,n=t.innerOrder||a,c=[];return r.forEach((function(t){i[t].forEach((function(i){i.name in e&&null!=e[i.name]?c.push(o(t,i,e)):i.push in e&&null!=e[i.push]&&e[i.push].forEach((function(e){c.push(o(t,i,e))}))}))})),e.media.forEach((function(e){c.push(o("m",i.m[0],e)),n.forEach((function(t){i[t].forEach((function(i){i.name in e&&null!=e[i.name]?c.push(o(t,i,e)):i.push in e&&null!=e[i.push]&&e[i.push].forEach((function(e){c.push(o(t,i,e))}))}))}))})),c.join("\r\n")+"\r\n"}})),hC=Qb((e=>{var t=dC(),i=uC();e.write=i,e.parse=t.parse,e.parseParams=t.parseParams,e.parseFmtpConfig=t.parseFmtpConfig,e.parsePayloads=t.parsePayloads,e.parseRemoteCandidates=t.parseRemoteCandidates,e.parseImageAttributes=t.parseImageAttributes,e.parseSimulcastStreamList=t.parseSimulcastStreamList})),pC=$b(nC()),mC=((Mb=mC||{})[Mb.INVALID_PARAMETER=4096]="INVALID_PARAMETER",Mb[Mb.INVALID_OPERATION=4097]="INVALID_OPERATION",Mb[Mb.NOT_SUPPORTED=4098]="NOT_SUPPORTED",Mb[Mb.DEVICE_NOT_FOUND=4099]="DEVICE_NOT_FOUND",Mb[Mb.INITIALIZE_FAILED=4100]="INITIALIZE_FAILED",Mb[Mb.SIGNAL_CHANNEL_SETUP_FAILED=16385]="SIGNAL_CHANNEL_SETUP_FAILED",Mb[Mb.SIGNAL_CHANNEL_ERROR=16386]="SIGNAL_CHANNEL_ERROR",Mb[Mb.ICE_TRANSPORT_ERROR=16387]="ICE_TRANSPORT_ERROR",Mb[Mb.JOIN_ROOM_FAILED=16388]="JOIN_ROOM_FAILED",Mb[Mb.CREATE_OFFER_FAILED=16389]="CREATE_OFFER_FAILED",Mb[Mb.SIGNAL_CHANNEL_RECONNECTION_FAILED=16390]="SIGNAL_CHANNEL_RECONNECTION_FAILED",Mb[Mb.UPLINK_RECONNECTION_FAILED=16391]="UPLINK_RECONNECTION_FAILED",Mb[Mb.DOWNLINK_RECONNECTION_FAILED=16392]="DOWNLINK_RECONNECTION_FAILED",Mb[Mb.REMOTE_STREAM_NOT_EXIST=16400]="REMOTE_STREAM_NOT_EXIST",Mb[Mb.CLIENT_BANNED=16448]="CLIENT_BANNED",Mb[Mb.SERVER_TIMEOUT=16449]="SERVER_TIMEOUT",Mb[Mb.SUBSCRIPTION_TIMEOUT=16450]="SUBSCRIPTION_TIMEOUT",Mb[Mb.PLAY_NOT_ALLOWED=16451]="PLAY_NOT_ALLOWED",Mb[Mb.DEVICE_AUTO_RECOVER_FAILED=16452]="DEVICE_AUTO_RECOVER_FAILED",Mb[Mb.START_PUBLISH_CDN_FAILED=16453]="START_PUBLISH_CDN_FAILED",Mb[Mb.STOP_PUBLISH_CDN_FAILED=16454]="STOP_PUBLISH_CDN_FAILED",Mb[Mb.START_MIX_TRANSCODE_FAILED=16455]="START_MIX_TRANSCODE_FAILED",Mb[Mb.STOP_MIX_TRANSCODE_FAILED=16456]="STOP_MIX_TRANSCODE_FAILED",Mb[Mb.NOT_SUPPORTED_H264=16457]="NOT_SUPPORTED_H264",Mb[Mb.SWITCH_ROLE_FAILED=16458]="SWITCH_ROLE_FAILED",Mb[Mb.API_CALL_TIMEOUT=16459]="API_CALL_TIMEOUT",Mb[Mb.SCHEDULE_FAILED=16460]="SCHEDULE_FAILED",Mb[Mb.API_CALL_ABORTED=16461]="API_CALL_ABORTED",Mb[Mb.UNKNOWN=65535]="UNKNOWN",Mb),_C=mC,fC=class extends Error{constructor(e){let{name:t="RtcError",message:i,code:r=_C.UNKNOWN,extraCode:n=0,constraint:o}=e,s="<".concat(function(e){for(let t in _C)if(_C[t]===e)return t;return"UNKNOWN"}(r)," 0x").concat(r.toString(16),">"),a="".concat(i).concat(o?" constraint: ".concat(o):"").concat(null!=i&&i.includes(s)?"":" ".concat(s));super(a),tC(this,"code"),tC(this,"extraCode"),tC(this,"message"),tC(this,"originMessage"),tC(this,"name"),tC(this,"constraint"),this.code=r,this.extraCode=n,this.name=t,this.message=a,this.constraint=o,this.originMessage=i}getCode(){return this.code}getExtraCode(){return this.extraCode}toString(){return this.originMessage}},gC=((new Date).getTime(),0),EC=function(){return(new Date).getTime()+gC},vC=function(){let e=new Date;return e.setTime(EC()),e.toLocaleString()},yC={};Zb(yC,{bytes2ms:()=>yD,convertObjectNumberToInt:()=>hO,copyProperties:()=>vD,deepClone:()=>eO,deepMerge:()=>$D,env:()=>TC,fibonacci:()=>CD,formatedTime:()=>nO,getAbilityConfigUrl:()=>nD,getConstructorName:()=>HD,getContainerFromElement:()=>iO,getEnv:()=>cD,getInternalVersion:()=>KD,getLoggerUrl:()=>dD,getMuteStateFromFlag:()=>qD,getNetworkQuality:()=>XD,getNetworkType:()=>mD,getNumNetworkType:()=>gD,getOSType:()=>hD,getReconnectionTimeout:()=>kD,getStringByteLength:()=>aO,getSysInfo:()=>ED,getTerminalType:()=>uD,getTurnServer:()=>QD,getUint32Version:()=>uO,getValueType:()=>wD,getViewListFromView:()=>tO,glog:()=>AD,ipv4ToUint32:()=>ZD,isArray:()=>xD,isAudioWorkletSupported:()=>jD,isBoolean:()=>PD,isConstructor:()=>FD,isEmpty:()=>JD,isFunction:()=>ND,isLangChinese:()=>RD,isMediaStreamTrack:()=>VD,isNumber:()=>LD,isObject:()=>MD,isOverseaSdkAppId:()=>lD,isPlainObject:()=>bD,isPortrait:()=>lO,isPromise:()=>BD,isRemoteTrack:()=>UD,isString:()=>OD,isUndefined:()=>DD,loadImage:()=>dO,logVisibilityState:()=>cO,ms2bytes:()=>SD,ms2samples:()=>ID,performanceNow:()=>zD,promiseAny:()=>WD,samples2ms:()=>TD,setNetworkType:()=>fD,stringify:()=>oO,stringifyIncludeValue:()=>sO});var TC={};Zb(TC,{ANDROID_VERSION:()=>xC,CHROME_MAJOR_VERSION:()=>Vk,CHROME_VERSION:()=>Uk,EDGE_VERSION:()=>WC,EDG_MAJOR_VERSION:()=>KC,EDG_VERSION:()=>GC,FIREFOX_MAJOR_VERSION:()=>HC,FIREFOX_VERSION:()=>FC,HUAWEI_VERSION:()=>bk,IE_VERSION:()=>rk,IOS_MAIN_VERSION:()=>zk,IOS_VERSION:()=>Wk,IPADQQB_VERSION:()=>mk,IS_ANDROID:()=>MC,IS_ANDROID_WEBVIEW:()=>jk,IS_ANY_SAFARI:()=>Fk,IS_CHROME:()=>Mk,IS_CHROME_OS:()=>Ek,IS_CHROMIUM_BASE:()=>Pk,IS_EDG:()=>zC,IS_EDGE:()=>jC,IS_ELECTRON:()=>Tk,IS_FIREFOX:()=>BC,IS_HEADLESS_CHROME:()=>xk,IS_HUAWEI:()=>Rk,IS_HUAWEIBROWSER:()=>Ak,IS_IE:()=>ik,IS_IE8:()=>tk,IS_IOS:()=>PC,IS_IOS_13_OR_14:()=>Yk,IS_IOS_15_1:()=>Kk,IS_IPAD:()=>NC,IS_IPADQQB:()=>pk,IS_IPAD_PRO:()=>DC,IS_IPHONE:()=>OC,IS_IPOD:()=>LC,IS_LINUX:()=>gk,IS_LOCAL:()=>Jk,IS_MAC:()=>fk,IS_MACQQB:()=>uk,IS_MIBROWSER:()=>Sk,IS_MQQB:()=>ak,IS_NATIVE_ANDROID:()=>UC,IS_OLD_ANDROID:()=>VC,IS_OPPOBROWSER:()=>wk,IS_SAFARI:()=>Bk,IS_SAFARI_15_1:()=>Gk,IS_SAMSUNGBROWSER:()=>Ck,IS_SOGOU:()=>qC,IS_SOGOUM:()=>YC,IS_TBS:()=>QC,IS_UCBROWSER:()=>yk,IS_VIVOBROWSER:()=>Dk,IS_WECHAT:()=>nk,IS_WIN:()=>_k,IS_WQQB:()=>lk,IS_WX:()=>vk,IS_X5MQQB:()=>sk,IS_XWEB:()=>$C,MACQQB_VERSION:()=>hk,MI_VERSION:()=>Ik,MQQB_VERSION:()=>ck,OPPO_VERSION:()=>Nk,SAFARI_VERSION:()=>Hk,SAMSUNG_VERSION:()=>kk,SOGOUM_VERSION:()=>JC,SOGOU_VERSION:()=>XC,TBS_VERSION:()=>ZC,USER_AGENT:()=>AC,VIVO_VERSION:()=>Ok,WECHAT_VERSION:()=>ok,WQQB_VERSION:()=>dk,XWEB_VERSION:()=>ek,browserInfo:()=>Xk,getBrowserInfo:()=>Qk,getChromeMajorVersion:()=>Lk,getOSName:()=>tw,getOSString:()=>iw,getUserAgentData:()=>$k,isFunction:()=>SC,isLocalStorageEnabled:()=>qk,isUndefined:()=>IC});var SC=e=>"function"==typeof e,IC=e=>void 0===e,AC="undefined"==typeof navigator?"":navigator.userAgent,RC=e=>new RegExp(e,"i").test(AC),bC=e=>{if(RC(e)){let t=new RegExp("".concat(e,"\\/([\\d.]+)")),i=AC.match(t);if(i&&i[1])return i[1]}return""},CC=e=>{if(RC(e)){let t=new RegExp("".concat(e,"\\/(\\d+)")),i=AC.match(t);if(i&&i[1])return parseFloat(i[1])}return NaN},kC=/AppleWebKit\/([\d.]+)/i.exec(AC),wC=kC?parseFloat(kC[1]):NaN,NC=RC("iPad"),DC="undefined"!=typeof navigator&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&RC("Macintosh"),OC=RC("iPhone")&&!NC,LC=RC("iPod"),PC=OC||NC||LC||DC,MC=RC("Android"),xC=function(){if(MC){let e=AC.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(e){let t=e[1]&&parseFloat(e[1]),i=e[2]&&parseFloat(e[2]);if(t&&i)return parseFloat("".concat(e[1],".").concat(e[2]));if(t)return t}}return NaN}(),VC=MC&&RC("webkit")&&xC<2.3,UC=MC&&xC<5&&wC<537,BC=RC("Firefox"),FC=bC("Firefox"),HC=CC("Firefox"),jC=RC("Edge"),WC=bC("Edge"),zC=RC("Edg"),GC=bC("Edg"),KC=CC("Edg"),YC=RC("SogouMobileBrowser"),JC=bC("SogouMobileBrowser"),qC=RC("MetaSr\\s"),XC=bC("MetaSr\\s"),QC=RC("TBS"),ZC=bC("TBS"),$C=RC("XWEB"),ek=bC("XWEB"),tk=RC("MSIE\\s8\\.0"),ik=RC("MSIE\\/\\d+"),rk=function(){if(ik){let e=/MSIE\s(\d+)\.\d/.exec(AC),t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(AC)&&/rv:11.0/.test(AC)&&(t=11),t}return NaN}(),nk=RC("(micromessenger|webbrowser)"),ok=bC("MicroMessenger"),sk=!QC&&RC("MQQBrowser")&&RC("COVC"),ak=!QC&&RC("MQQBrowser")&&!RC("COVC"),ck=ak||sk?bC("MQQBrowser"):"",lk=!QC&&RC(" QQBrowser"),dk=bC(" QQBrowser"),uk=!QC&&RC("QQBrowserLite"),hk=bC("QQBrowserLite"),pk=!QC&&RC("MQBHD"),mk=bC("MQBHD"),_k=RC("Windows"),fk=!PC&&RC("MAC OS X"),gk=!MC&&RC("Linux"),Ek=RC("CrOS"),vk=RC("MicroMessenger"),yk=RC("UCBrowser"),Tk=RC("Electron"),Sk=RC("MiuiBrowser"),Ik=bC("MiuiBrowser"),Ak=RC("HuaweiBrowser"),Rk=RC("Huawei"),bk=bC("HuaweiBrowser"),Ck=RC("SamsungBrowser"),kk=bC("SamsungBrowser"),wk=RC("HeyTapBrowser"),Nk=bC("HeyTapBrowser"),Dk=RC("VivoBrowser"),Ok=bC("VivoBrowser"),Lk=()=>CC("Chrome"),Pk=RC("Chrome"),Mk=!jC&&!qC&&!YC&&!QC&&!$C&&!zC&&!lk&&!Sk&&!Ak&&!Ck&&!wk&&!Dk&&Pk,xk=RC("HeadlessChrome"),Vk=Lk(),Uk=bC("Chrome"),Bk=!Pk&&!ak&&!sk&&!uk&&!pk&&RC("Safari"),Fk=Bk||PC,Hk=bC("Version"),jk=/Android.*(wv|.0.0.0)/.test(AC),Wk=(()=>{if(DC)return Hk;if(PC){let e=AC.match(/OS (\d+)_(\d+)/i);if(e&&e[1]){let t=e[1];return e[2]&&(t+=".".concat(e[2])),t}}return""})(),zk=Number(Wk.split(".")[0]),Gk="15.1"===Hk,Kk="15.1"===Wk,Yk=(()=>{let e=Number(Wk.split(".")[0]);return 14===e||13===e})(),Jk="undefined"!=typeof location&&("file:"===location.protocol||"localhost"===location.hostname||"127.0.0.1"===location.hostname),qk=(()=>{let e;return()=>{if(IC(e))try{e=!!window.localStorage}catch(t){e=!1}return e}})(),Xk=Qk();function Qk(){let e=new Map([[BC,["Firefox",FC]],[zC,["Edg",GC]],[Mk,["Chrome",Uk]],[Bk,["Safari",Hk]],[QC,["TBS",ZC]],[$C,["XWEB",ek]],[nk&&OC,["WeChat",ok]],[lk,["QQ(Win)",dk]],[ak,["QQ(Mobile)",ck]],[sk,["QQ(Mobile X5)",ck]],[uk,["QQ(Mac)",hk]],[pk,["QQ(iPad)",mk]],[Sk,["MI",Ik]],[Ak,["HW",bk]],[Ck,["Samsung",kk]],[wk,["OPPO",Nk]],[Dk,["VIVO",Ok]],[jC,["EDGE",WC]],[YC,["SogouMobile",JC]],[qC,["Sogou",XC]]]),t="unknown",i="unknown";return e.has(!0)&&([t,i]=e.get(!0)),{name:t,version:i}}var Zk=null;function $k(){return rC(this,null,(function*(){if(Zk)return Zk;if(!navigator.userAgentData||!SC(navigator.userAgentData.getHighEntropyValues))return null;try{return Zk=yield navigator.userAgentData.getHighEntropyValues(["architecture","bitness","model","platformVersion","fullVersionList"])}catch(e){return null}}))}var ew=new Map([[MC,"Android"],[PC,"iOS"],[_k,"Windows"],[fk,"MacOS"],[gk,"Linux"],[Ek,"ChromeOS"]]),tw=function(){return ew.get(!0)?ew.get(!0):Zk?Zk.platform:"unknown"},iw=()=>{let e=tw();return e+="/".concat(Xk.name,"/").concat(Bk?Xk.version:Xk.version.split(".")[0]),null!=Zk&&Zk.platformVersion&&(e+="/".concat(Zk.platformVersion)),null!=Zk&&Zk.architecture&&(e+="/".concat(Zk.architecture)),e},rw={};Zb(rw,{AUDIO_MUTE_BIT:()=>Ww,AUDIO_STAT_BIT:()=>jw,AUX_STAT_BIT:()=>Hw,AUX_STREAM_MSID:()=>Kw,BACKEND_ENV:()=>Vw,BASE_DOC_URL:()=>vw,BASE_HOST:()=>_w,CAPABILITIES_KEYS:()=>VN,CLASS_NAME:()=>AN,CLOUD_CONSOLE_URL:()=>Ew,DATA_FREEZE_TIMING:()=>gN,DOC_URL:()=>yw,DTLS_STATE_UNKNOWN:()=>iN,ENV_NAME:()=>Rw,EXCHANGE_SDP_TIMEOUT:()=>hN,INTERVAL:()=>MN,IS_WORKER:()=>dw,IS_WORKLET:()=>uw,KIBANA_EVENT:()=>lN,LOCAL_STREAM_PUBLISH_STATE:()=>fN,LOGGER_CMD_TYPE:()=>Aw,LOGGER_DOMAIN:()=>Tw,LOGGER_DOMAIN_OVERSEA:()=>Sw,LOG_LEVEL:()=>bw,LOG_LEVEL_NAME:()=>wN,MAIN_STREAM_MSID:()=>Gw,MICROPHONE_COMMUNICATIONS:()=>kN,MICROPHONE_DEFAULT:()=>bN,NAME:()=>Mw,NETWORK_TYPE:()=>ww,NOT_SUPPORTED_H264:()=>_N,PAUSED_RETRY_COUNT:()=>RN,PEERCONNECTION_CONNECTING_TIMEOUT:()=>TN,PEER_CONNECTION_STATE:()=>rN,PEER_LEAVE_REASON:()=>NN,RAF:()=>PN,RECOVER_CAPTURE_INTERVAL:()=>ON,REMOTE_STREAM_TYPE_AUX:()=>Jw,REMOTE_STREAM_TYPE_MAIN:()=>Yw,RENDER_FREEZE_TIMING:()=>EN,RIC:()=>LN,SCHEDULE_DOMAIN:()=>SN,SCHEDULE_TIMEOUT:()=>IN,SDP_SEMANTICS_PLAN_B:()=>mN,SDP_SEMANTICS_UNIFIED_PLAN:()=>pN,SECOND_HOST:()=>fw,SIGNAL_PING_PONG_INTERVAL:()=>kw,SIGNAL_PING_TIMEOUT:()=>Cw,SIGNAL_RECONNECTION_COUNT:()=>cN,SMALL_STAT_BIT:()=>Fw,SPEAKER_DEFAULT:()=>CN,STORAGE_EXPIRES_TIME:()=>Nw,STREAM_TYPE_BIG:()=>vN,STREAM_TYPE_SMALL:()=>yN,SUBSCRIBE_SMALL_RETRY_COUNT:()=>DN,SYNC_USER_LIST_INTERVAL:()=>dN,Scene:()=>Uw,Switch:()=>Dw,THIRD_HOST:()=>gw,TIMEOUT:()=>xN,TRANSPORT_DIRECTION:()=>xw,TRTC_ERROR_ASSISTANCE:()=>Iw,TRTC_QUALITY_BAD:()=>$w,TRTC_QUALITY_DISCONNECTED:()=>tN,TRTC_QUALITY_EXCELLENT:()=>Xw,TRTC_QUALITY_GOOD:()=>Qw,TRTC_QUALITY_POOR:()=>Zw,TRTC_QUALITY_UNKNOWN:()=>qw,TRTC_QUALITY_VERY_BAD:()=>eN,UPDATE_OFFER_TIMEOUT:()=>uN,VIDEO_MUTE_BIT:()=>zw,VIDEO_STAT_BIT:()=>Bw,audioProfileMap:()=>Ow,getRetryCount:()=>sN,getScriptDir:()=>hw,innerVersion:()=>nw,loggerProxy:()=>pw,screenProfileMap:()=>Pw,setLoggerProxy:()=>mw,setRetryCount:()=>oN,setVersion:()=>sw,version:()=>ow,videoProfileMap:()=>Lw});var nw="4.15.00.1600",ow="5.0.0";function sw(e){ow=e;let[t,i,r]=e.split(".").map((e=>parseInt(e,10)));nw="".concat(t,".").concat(Math.min(15,i),".").concat(Math.min(15,r),".").concat(i.toString().padStart(2,"0")).concat(r.toString().padStart(2,"0"))}var aw,cw,lw,dw="undefined"!=typeof importScripts,uw="undefined"!=typeof registerProcessor,hw=()=>{let e=dw?self.location.href:document.currentScript.src;return e.substring(0,e.lastIndexOf("/")+1)},pw="",mw=e=>pw=e,_w="web.sdk.qcloud.com",fw="web.sdk.tencent.cn",gw="web.sdk.cloud.tencent.cn",Ew="https://console.cloud.tencent.com/trtc",vw="https://".concat(_w,"/trtc/webrtc/v5/doc"),yw="".concat(vw,"/zh-cn/"),Tw="https://yun.tim.qq.com",Sw="https://apisgp.my-imcloud.com",Iw="trtc_error_assistance",Aw={LOG:"jssdk_log",EVENT:"jssdk_event",KEY_POINT:"jssdk_new_endreport",KV_STAT:"jssdk_key_metrics_report"},Rw={QCLOUD:"qcloud",OLD_CLOUD_LADDER:"trtc",WEBRTC:"webrtc"},bw=((lw=bw||{})[lw.TRACE=0]="TRACE",lw[lw.DEBUG=1]="DEBUG",lw[lw.INFO=2]="INFO",lw[lw.WARN=3]="WARN",lw[lw.ERROR=4]="ERROR",lw[lw.NONE=5]="NONE",lw),Cw=18e3,kw=2e3,ww={unknown:0,wifi:1,"3g":2,"2g":3,"4g":4,wired:5,"5g":6},Nw=6048e5,Dw=((cw=Dw||{}).USEAINS="useAINS",cw.ENABLEDEBUG="enableDebug",cw.USEV2="useV2",cw.USEWT="useWt",cw),Ow={standard:{sampleRate:48e3,channelCount:1,bitrate:40},"standard-stereo":{sampleRate:48e3,channelCount:2,bitrate:64},high:{sampleRate:48e3,channelCount:1,bitrate:192},"high-stereo":{sampleRate:48e3,channelCount:2,bitrate:192}},Lw={"120p":{width:160,height:120,frameRate:15,bitrate:200},"120p_2":{width:160,height:120,frameRate:15,bitrate:100},"180p":{width:320,height:180,frameRate:15,bitrate:350},"180p_2":{width:320,height:180,frameRate:15,bitrate:150},"240p":{width:320,height:240,frameRate:15,bitrate:400},"240p_2":{width:320,height:240,frameRate:15,bitrate:200},"360p":{width:640,height:360,frameRate:15,bitrate:800},"360p_2":{width:640,height:360,frameRate:15,bitrate:400},"480p":{width:640,height:480,frameRate:15,bitrate:900},"480p_2":{width:640,height:480,frameRate:15,bitrate:500},"720p":{width:1280,height:720,frameRate:15,bitrate:1500},"1080p":{width:1920,height:1080,frameRate:15,bitrate:2e3},"1440p":{width:2560,height:1440,frameRate:30,bitrate:4860},"4K":{width:3840,height:2160,frameRate:30,bitrate:9e3}},Pw={"480p":{width:640,height:480,frameRate:5,bitrate:900},"480p_2":{width:640,height:480,frameRate:30,bitrate:1e3},"720p":{width:1280,height:720,frameRate:5,bitrate:1200},"720p_2":{width:1280,height:720,frameRate:30,bitrate:3e3},"1080p":{width:1920,height:1080,frameRate:5,bitrate:1600},"1080p_2":{width:1920,height:1080,frameRate:30,bitrate:4e3}},Mw={CANVAS:"canvas",AUDIO:"audio",VIDEO:"video",SCREEN:"screen",SMALL:"small",BIG:"big",AUXILIARY:"auxiliary",SMALL_VIDEO:"smallVideo",FACING_MODE_USER:"user",FACING_MODE_ENVIRONMENT:"environment",MUTE:"mute",UNMUTE:"unmute",ENDED:"ended",PLAYING:"playing",PAUSE:"pause",ERROR:"error",LOADEDDATA:"loadeddata",AUDIO_INPUT:"audioinput",VIDEO_INPUT:"videoinput",DETAIL:"detail",TEXT:"text",MAIN:"main",BACKUP:"backup",BANNED:"banned",KICK:"kick",USER_TIME_OUT:"user_time_out",ROOM_DISBAND:"room_disband",SEI_MESSAGE:"sei-message",ADD:"add",REMOVE:"remove",REPLACE:"replace",TRACK:"track",SUBSCRIBE:"subscribe",UNSUBSCRIBE:"unsubscribe",TRANSCEIVER_DIRECTION_SENDONLY:"sendonly",TRANSCEIVER_DIRECTION_RECVONLY:"recvonly",ENTER_PICTURE_IN_PICTURE:"enterpictureinpicture",LEAVE_PICTURE_IN_PICTURE:"leavepictureinpicture"},xw={INACTIVE:"inactive",SENDONLY:"sendonly",RECVONLY:"recvonly"},Vw={OLD_CLOUD_LADDER:"wss://trtc.rtc.qq.com",WEBRTC:"wss://webrtc.qq.com"},Uw=((aw=Uw||{}).LIVE="live",aw.RTC="rtc",aw),Bw=1,Fw=2,Hw=4,jw=8,Ww=64,zw=16,Gw="5Y2wZK8nANNAoVw6dSAHVjNxrD1ObBM2kBPV",Kw="224d130c-7b5c-415b-aaa2-79c2eb5a6df2",Yw=Mw.MAIN,Jw=Mw.AUXILIARY,qw=0,Xw=1,Qw=2,Zw=3,$w=4,eN=5,tN=6,iN="unknown",rN={NEW:"new",CONNECTING:"connecting",FAILED:"failed",CLOSED:"closed",DISCONNECTED:"disconnected",CONNECTED:"connected",COMPLETED:"completed"},nN=1/0;function oN(e){nN=e}function sN(){return nN}var aN,cN=30,lN={JOIN:"join",DELTA_JOIN:"delta-join",REJOIN:"rejoin",LEAVE:"leave",DELTA_LEAVE:"delta-leave",PUBLISH:"publish",DELTA_PUBLISH:"delta-publish",UNPUBLISH:"unpublish",SUBSCRIBE:"subscribe",UNSUBSCRIBE:"unsubscribe",UPLINK_CONNECTION:"uplink-connection",UPLINK_RECONNECTION:"uplink-reconnection",DOWNLINK_CONNECTION:"downlink-connection",DOWNLINK_RECONNECTION:"downlink-reconnection",ON_TRACK:"ontrack",ICE_CONNECTION_STATE:"iceConnectionState",LOCAL_STREAM_INITIALIZE:"stream-initialize",SIGNAL_CONNECTION:"websocketConnectionState",SIGNAL_RECONNECTION:"websocketReconnectionState",UPDATE_STREAM:"update-stream",RECOVER_LOCAL_AUDIO_TRACK:"recover-local-audio-track",RECOVER_LOCAL_VIDEO_TRACK:"recover-local-video-track",RECOVER_SUBSCRIPTION:"recover-subscription",START_MIX_TRANSCODE:"start-mix-transcode",STOP_MIX_TRANSCODE:"stop-mix-transcode",PLAYER_ERROR:"player-error",SCHEDULE:"schedule",LOAD_WORKLET:"load-worklet",VIDEO_FROZEN_COUNT:"videoFrozenCount",GET_USER_MEDIA_RETRY:"getUserMedia-retry"},dN=1e4,uN=1e4,hN=1e4,pN="unified-plan",mN="plan-b",_N=1028,fN=((aN=fN||{})[aN.UNPUBLISH=-1]="UNPUBLISH",aN[aN.PUBLISHING=0]="PUBLISHING",aN[aN.PUBLISHED=1]="PUBLISHED",aN),gN=500,EN=1e3,vN=Mw.BIG,yN=Mw.SMALL,TN=1e4,SN={MAIN:"schedule.cloud-rtc.com",BACKUP:"schedule.rtc.qcloud.com",MAIN_OVERSEA:"schedule.rtc-web.com",BACKUP_OVERSEA:"schedule.rtc-web.io",MAIN_OVERSEA_OLD:"schedule.rtc.tencentcloud.com",BACKUP_OVERSEA_OLD:"schedule-ecdn.rtc.tencentcloud.com"},IN=2e3,AN={TRTC:"TRTC",CLIENT:"Client",LOCAL_STREAM:"LocalStream",REMOTE_STREAM:"RemoteStream",STREAM:"Stream"},RN=5,bN="default",CN=bN,kN="communications",wN=Object.keys(bw),NN=["normal leave","timeout leave","kick","role change"],DN=10,ON=2e3,LN="ric",PN="raf",MN="interval",xN="timeout",VN=["width","height","frameRate","facingMode","sampleRate","sampleSize","channelCount","deviceId","min","max"],UN=1e8;function BN(e){let{url:t,body:i,method:r,timeout:n}=e,o=new XMLHttpRequest;return new Promise(((e,s)=>{o.onreadystatechange=()=>{if(4===o.readyState)if(o.status>=200&&o.status<300)try{let t=JSON.parse(o.response);e({data:t})}catch(t){e({data:o.response})}else s({status:o.status,statusText:o.statusText||"request failed!"})},o.timeout=n||5e3,o.open(r||"POST",t,!0),o.send(i)}))}function FN(e){return rC(this,null,(function*(){let t=zD(),i=JSON.stringify(e);try{if(!CompressionStream||i.length<=2800)return i;let e=new Blob([i],{type:"application/json"}).stream().pipeThrough(new CompressionStream("gzip")),r=yield(yield(yield new Response(e)).blob()).arrayBuffer();return EO.debug("compressJSON ".concat(i.length," -> ").concat(r.byteLength," ").concat(zD()-t,"ms")),r}catch(r){return i}}))}var HN={AVOID_REPEATED_CALL:"AVOID_REPEATED_CALL",INVALID_PARAMETER_REQUIRED:"INVALID_PARAMETER_REQUIRED",INVALID_PARAMETER_TYPE:"INVALID_PARAMETER_TYPE",INVALID_PARAMETER_EMPTY:"INVALID_PARAMETER_EMPTY",INVALID_PARAMETER_INSTANCE:"INVALID_PARAMETER_INSTANCE",INVALID_PARAMETER_RANGE:"INVALID_PARAMETER_RANGE",INVALID_PARAMETER_MIN:"INVALID_PARAMETER_MIN",INVALID_PARAMETER_MAX:"INVALID_PARAMETER_MAX",INVALID_PARAMETER_STREAMTYPE:"INVALID_PARAMETER_STREAMTYPE",API_CALL_TIMEOUT:"API_CALL_TIMEOUT",SIGNAL_CHANNEL_RECONNECTION_FAILED:"SIGNAL_CHANNEL_RECONNECTION_FAILED",SIGNAL_CHANNEL_SETUP_FAILED:"SIGNAL_CHANNEL_SETUP_FAILED",ERROR_MESSAGE:"ERROR_MESSAGE",EXCHANGE_SDP_TIMEOUT:"EXCHANGE_SDP_TIMEOUT",DOWNLINK_RECONNECTION_FAILED:"DOWNLINK_RECONNECTION_FAILED",EXCHANGE_SDP_FAILED:"EXCHANGE_SDP_FAILED",UPDATE_OFFER_TIMEOUT:"UPDATE_OFFER_TIMEOUT",UPLINK_RECONNECTION_FAILED:"UPLINK_RECONNECTION_FAILED",INVALID_RECORDID:"INVALID_RECORDID",INVALID_PURE_AUDIO:"INVALID_PURE_AUDIO",INVALID_STREAMID:"INVALID_STREAMID",INVALID_USER_DEFINE_RECORDID:"INVALID_USER_DEFINE_RECORDID",INVALID_USER_DEFINE_PUSH_ARGS:"INVALID_USER_DEFINE_PUSH_ARGS",INVALID_PROXY:"INVALID_PROXY",INVALID_JOIN:"INVALID_JOIN",INVALID_ROOMID_STRING:"INVALID_ROOMID_STRING",INVALID_ROOMID_INTEGER:"INVALID_ROOMID_INTEGER",INVALID_SIGNAL_CHANNEL:"INVALID_SIGNAL_CHANNEL",JOIN_ROOM_TIMEOUT:"JOIN_ROOM_TIMEOUT",JOIN_ROOM_FAILED:"JOIN_ROOM_FAILED",REJOIN_ROOM_FAILED:"REJOIN_ROOM_FAILED",INVALID_DESTROY:"INVALID_DESTROY",INVALID_PUBLISH:"INVALID_PUBLISH",INVALID_UNPUBLISH:"INVALID_UNPUBLISH",INVALID_AUDIENCE:"INVALID_AUDIENCE",INVALID_INITIALIZE:"INVALID_INITIALIZE",INVALID_DUPLICATE_PUBLISHING:"INVALID_DUPLICATE_PUBLISHING",INVALID_SUBSCRIBE_UNDEFINED:"INVALID_SUBSCRIBE_UNDEFINED",INVALID_SUBSCRIBE_LOCAL:"INVALID_SUBSCRIBE_LOCAL",INVALID_REMOTE_STREAM:"INVALID_REMOTE_STREAM",SUBSCRIBE_FAILED:"SUBSCRIBE_FAILED",INVALID_ROLE:"INVALID_ROLE",INVALID_PARAMETER_SWITCH_ROLE:"INVALID_PARAMETER_SWITCH_ROLE",INVALID_OPERATION_SWITCH_ROLE:"INVALID_OPERATION_SWITCH_ROLE",SWITCH_ROLE_TIMEOUT:"SWITCH_ROLE_TIMEOUT",SWITCH_ROLE_FAILED:"SWITCH_ROLE_FAILED",CLIENT_BANNED:"CLIENT_BANNED",INVALID_OPERATION_START_PUBLISH_CDN:"INVALID_OPERATION_START_PUBLISH_CDN",INVALID_OPERATION_STOP_PUBLISH_CDN:"INVALID_OPERATION_STOP_PUBLISH_CDN",INVALID_STREAM_ID:"INVALID_STREAM_ID",START_PUBLISH_CDN_FAILED:"START_PUBLISH_CDN_FAILED",STOP_PUBLISH_CDN_FAILED:"STOP_PUBLISH_CDN_FAILED",START_MIX_TRANSCODE:"START_MIX_TRANSCODE",STOP_MIX_TRANSCODE:"STOP_MIX_TRANSCODE",INVALID_AUDIO_VOLUME:"INVALID_AUDIO_VOLUME",ENABLE_SMALL_STREAM_PUBLISHED:"ENABLE_SMALL_STREAM_PUBLISHED",DISABLE_SMALL_STREAM_PUBLISHED:"DISABLE_SMALL_STREAM_PUBLISHED",NOT_SUPPORTED_SMALL_STREAM:"NOT_SUPPORTED_SMALL_STREAM",INVALID_SMALL_STREAM_PROFILE:"INVALID_SMALL_STREAM_PROFILE",INVALID_PARAMETER_REMOTE_STREAM:"INVALID_PARAMETER_REMOTE_STREAM",INVALID_OPERATION_CHANGE_SMALL:"INVALID_OPERATION_CHANGE_SMALL",REMOTE_NOT_PUBLISH_SMALL_STREAM:"REMOTE_NOT_PUBLISH_SMALL_STREAM",INVALID_SWITCH_DEVICE:"INVALID_SWITCH_DEVICE",INVALID_SWITCH_DEVICE_PUBLISHING:"INVALID_SWITCH_DEVICE_PUBLISHING",INVALID_REPLACE_TRACK:"INVALID_REPLACE_TRACK",INVALID_INITIALIZE_LOCAL_STREAM:"INVALID_INITIALIZE_LOCAL_STREAM",INVALID_ADD_TRACK_REPETITIVE:"INVALID_ADD_TRACK_REPETITIVE",INVALID_ADD_TRACK_REMOVING:"INVALID_ADD_TRACK_REMOVING",INVALID_ADD_TRACK_PUBLISHING:"INVALID_ADD_TRACK_PUBLISHING",INVALID_STREAM_INITIALIZED:"INVALID_STREAM_INITIALIZED",INVALID_ADD_TRACK_NUMBER:"INVALID_ADD_TRACK_NUMBER",INVALID_REMOVE_AUDIO_TRACK:"INVALID_REMOVE_AUDIO_TRACK",INVALID_REMOVE_AUDIO_ADDING:"INVALID_REMOVE_AUDIO_ADDING",INVALID_REMOVE_AUDIO_ON:"INVALID_REMOVE_AUDIO_ON",INVALID_REMOVE_TRACK_PUBLISHING:"INVALID_REMOVE_TRACK_PUBLISHING",INVALID_REMOVE_TRACK_NOT_TRACK:"INVALID_REMOVE_TRACK_NOT_TRACK",INVALID_REMOVE_TRACK_NUMBER:"INVALID_REMOVE_TRACK_NUMBER",INVALID_REPLACE_TRACK_NO_TRACK:"INVALID_REPLACE_TRACK_NO_TRACK",REPEAT_JOIN:"REPEAT_JOIN",CLIENT_DESTROYED:"CLIENT_DESTROYED",NOT_BUG_PACKAGE:"NOT_BUG_PACKAGE",START_MIX_TRANSCODE_FAILED:"START_MIX_TRANSCODE_FAILED",STOP_MIX_TRANSCODE_FAILED:"STOP_MIX_TRANSCODE_FAILED",MIX_TRANSCODE_NOT_STARTED:"MIX_TRANSCODE_NOT_STARTED",CANNOT_LESS_THAN_ZERO:"CANNOT_LESS_THAN_ZERO",MIX_PARAMS_VIDEO_FRAMERATE:"MIX_PARAMS_VIDEO_FRAMERATE",MIX_PARAMS_VIDEO_GOP:"MIX_PARAMS_VIDEO_GOP",MIX_PARAMS_AUDIO_BITRATE:"MIX_PARAMS_AUDIO_BITRATE",MIX_PARAMS_USER_Z_ORDER:"MIX_PARAMS_USER_Z_ORDER",MIX_PARAMS_NOT_SELF:"MIX_PARAMS_NOT_SELF",MIX_PARAMS_USER_STREAM:"MIX_PARAMS_USER_STREAM",INVALID_PLAY:"INVALID_PLAY",INVALID_ELEMENT_ID:"INVALID_ELEMENT_ID",INVALID_ELEMENT_ID_TYPE:"INVALID_ELEMENT_ID_TYPE",PLAY_FAILED:"PLAY_FAILED",INVALID_USERID:"INVALID_USERID",INVALID_CREATE_STREAM_SOURCE:"INVALID_CREATE_STREAM_SOURCE",INVALID_CREATE_STREAM_SCREEN:"INVALID_CREATE_STREAM_SCREEN",INVALID_CREATE_STREAM_AUDIO:"INVALID_CREATE_STREAM_AUDIO",INVALID_CREATE_STREAM_SCREEN_AUDIO:"INVALID_CREATE_STREAM_SCREEN_AUDIO",NOT_SUPPORTED_HTTP:"NOT_SUPPORTED_HTTP",NOT_SUPPORTED_WEBRTC:"NOT_SUPPORTED_WEBRTC",NOT_SUPPORTED_PROFILE:"NOT_SUPPORTED_PROFILE",NOT_SUPPORTED_MEDIA:"NOT_SUPPORTED_MEDIA",NOT_SUPPORTED_H264ENCODE:"NOT_SUPPORTED_H264ENCODE",NOT_SUPPORTED_H264DECODE:"NOT_SUPPORTED_H264DECODE",NOT_SUPPORTED_TRACK:"NOT_SUPPORTED_TRACK",NOT_SUPPORTED_SWITCH_DEVICE:"NOT_SUPPORTED_SWITCH_DEVICE",NOT_SUPPORTED_CAPTURE:"NOT_SUPPORTED_CAPTURE",NOT_SUPPORTED_AUX:"NOT_SUPPORTED_AUX",MICROPHONE_NOT_FOUND:"MICROPHONE_NOT_FOUND",CAMERA_NOT_FOUND:"CAMERA_NOT_FOUND",SIGNAL_RESPONSE_FAILED:"SIGNAL_RESPONSE_FAILED",CATCH_HANDLER_ERROR:"CATCH_HANDLER_ERROR",API_NOT_EXIST:"API_NOT_EXIST",CONNECTION_CLOSED:"CONNECTION_CLOSED",SUBSCRIBE_ALL_FALSE:"SUBSCRIBE_ALL_FALSE",SEI_NOT_SUPPORT:"SEI_NOT_SUPPORT",SEI_DISABLED:"SEI_DISABLED",SEI_EMPTY:"SEI_EMPTY",SEI_OVERSIZE:"SEI_OVERSIZE",SEI_BEFORE_PUBLISH:"SEI_BEFORE_PUBLISH",SEI_NOT_VIDEO:"SEI_NOT_VIDEO",CALL_FREQUENCY_LIMIT:"CALL_FREQUENCY_LIMIT",CONNECTION_ABORTED:"CONNECTION_ABORTED",API_CALL_ABORTED:"API_CALL_ABORTED",DUPLICATE_AUX:"DUPLICATE_AUX"},jN={AVOID_REPEATED_CALL:e=>"previous ".concat(e.name,"() is ongoing, please avoid repeated calls."),INVALID_PARAMETER_REQUIRED(e){let{key:t,rule:i,fnName:r,value:n}=e;return"'".concat(t||i.name,"' is a required param when calling ").concat(r,"(), received: ").concat(n,".")},INVALID_PARAMETER_TYPE(e){let{key:t,rule:i,fnName:r,value:n}=e,o="".concat(t||i.name),s="";return s=Array.isArray(i.type)?i.type.join("|"):i.type,"'".concat(o,"' must be type of ").concat(s," when calling ").concat(r,"(), received type: ").concat(wD(n),".")},INVALID_PARAMETER_EMPTY(e){let{key:t,rule:i,fnName:r,value:n}=e;return"'".concat(t||i.name,"' cannot be '").concat(n,"' when calling ").concat(r,"().")},INVALID_PARAMETER_INSTANCE(e){let{key:t,rule:i,fnName:r,value:n}=e,o="".concat(t||i.name),s="".concat(i.instanceOf.name||i.instanceOf);return"'".concat(o,"' must be instanceof ").concat(s," when calling ").concat(r,"(), received type: ").concat(wD(n),".")},INVALID_PARAMETER_RANGE(e){let{key:t,rule:i,fnName:r,value:n}=e;return"'".concat(t||i.name,"' must be one of ").concat(i.values.join("|")," when calling ").concat(r,"(), received: ").concat(n,".")},INVALID_PARAMETER_MIN(e){let{key:t,rule:i,fnName:r,value:n}=e;return"the min value of ".concat(t||i.name," is ").concat(i.min,", received: ").concat(n,".")},INVALID_PARAMETER_MAX(e){let{key:t,rule:i,fnName:r,value:n}=e;return"the max value of ".concat(t||i.name," is ").concat(i.max,", received: ").concat(n,".")},API_CALL_TIMEOUT:e=>"".concat(e.commandDesc||e.command," timeout observed."),SIGNAL_CHANNEL_RECONNECTION_FAILED:"signal channel reconnection failed, please check your network.",SIGNAL_CHANNEL_SETUP_FAILED:e=>"SignalChannel setup failure: (errorCode: ".concat(e.errorCode,", errorMsg: ").concat(e.errorMsg," })."),ERROR_MESSAGE(e){let t="".concat(e.type," failed");return e.message&&(t="".concat(t,": ").concat(e.message,".")),t},EXCHANGE_SDP_TIMEOUT:"exchange sdp timeout.",DOWNLINK_RECONNECTION_FAILED:"downlink reconnection failed, please check your network and re-join room.",EXCHANGE_SDP_FAILED:e=>"exchange sdp failed ".concat(e.errMsg,"."),UPDATE_OFFER_TIMEOUT:"update offer timeout observed.",UPLINK_RECONNECTION_FAILED:"uplink reconnection failed, please check your network and publish again.",INVALID_RECORDID:"recordId must be an integer number.",INVALID_PURE_AUDIO:"pureAudioPushMode must be 1 or 2.",INVALID_STREAMID:"streamId must be a sting literal within 64 bytes, and not be empty.",INVALID_USER_DEFINE_RECORDID:"userDefineRecordId must be a sting literal contains (a-zA-Z),(0-9), underline and hyphen, within 64 bytes, and not be empty.",INVALID_USER_DEFINE_PUSH_ARGS:"userDefinePushArgs must be a sting literal within 256 bytes, and not be empty.",INVALID_PROXY:'proxy server url must start with "wss://".',INVALID_JOIN:"duplicate join() called.",INVALID_ROOMID_STRING:e=>"'".concat(e,"' must be validate string when useStringRoomId is true."),INVALID_ROOMID_INTEGER:e=>"'".concat(e,"' must be an integer between [1, 4294967294] when useStringRoomId is false."),INVALID_SIGNAL_CHANNEL:"SignalChannel is not ready yet.",JOIN_ROOM_TIMEOUT:"join room timeout.",JOIN_ROOM_FAILED(e){let{error:t,code:i}=e;return"Failed to join room - ".concat(t," code: ").concat(i)},REJOIN_ROOM_FAILED:e=>"reJoin room: ".concat(e.roomId," failed, please check your network."),INVALID_DESTROY:"please call leave() before destroy().",INVALID_PUBLISH:"please call join() before publish().",INVALID_UNPUBLISH:"stream has not been published yet.",INVALID_AUDIENCE:"no permission to publish() under live/".concat("audience",', please call switchRole("',"anchor",'") firstly before publish().'),INVALID_INITIALIZE:"cannot publish stream because stream is not initialized, is switching device, or has been closed.",INVALID_DUPLICATE_PUBLISHING:e=>"duplicate ".concat(e," stream publishing, please unpublish your prev ").concat(e," stream and then re-publish."),INVALID_SUBSCRIBE_UNDEFINED:"stream is undefined or null.",INVALID_SUBSCRIBE_LOCAL:"stream cannot be LocalStream.",INVALID_REMOTE_STREAM:"remoteStream does not exist because it has been unpublished by remote peer.",SUBSCRIBE_FAILED(e){let{message:t,userId:i,streamType:r}=e;return"failed to subscribe ".concat(i," ").concat(r," stream, reason: ").concat(t,".")},INVALID_ROLE:"switchRole can only be called in live mode.",INVALID_PARAMETER_SWITCH_ROLE:"role could only be set to a value as ".concat("anchor"," or ","audience","."),INVALID_OPERATION_SWITCH_ROLE:"please call join() before switchRole().",SWITCH_ROLE_TIMEOUT:"switchRole timeout.",SWITCH_ROLE_FAILED:e=>"switchRole failed, errCode: ".concat(e.code," errMsg: ").concat(e.message,"."),CLIENT_BANNED:e=>"client was banned because of ".concat(e.message,"."),INVALID_OPERATION_START_PUBLISH_CDN:"please call startPublishCDNStream() after join room and publish the local stream.",INVALID_OPERATION_STOP_PUBLISH_CDN:"please call startPublishCDNStream() before stopPublishCDNStream().",START_PUBLISH_CDN_FAILED:e=>"startPublishCDNStream failed, errMsg: ".concat(e.message,"."),STOP_PUBLISH_CDN_FAILED:e=>"stopPublishCDNStream failed, errMsg: ".concat(e.message,"."),INVALID_STREAM_ID:e=>"'".concat(e,"' can only consist of uppercase and lowercase english letters (a-zA-Z), numbers (0-9), hyphens and underscores."),START_MIX_TRANSCODE:"please call startMixTranscode() after join().",STOP_MIX_TRANSCODE:"please call stopMixTranscode() after startMixTranscode().",INVALID_AUDIO_VOLUME:"interval must be a number.",ENABLE_SMALL_STREAM_PUBLISHED:"Cannot enable small stream after localStream published.",DISABLE_SMALL_STREAM_PUBLISHED:"Cannot disable small stream after localStream published.",NOT_SUPPORTED_SMALL_STREAM:"your browser does not support opening small stream.",INVALID_SMALL_STREAM_PROFILE:"small stream profile is invalid.",INVALID_PARAMETER_REMOTE_STREAM:"remoteStream is invalid.",INVALID_OPERATION_CHANGE_SMALL:"cannot switch to the small stream without subscribing to the video of remoteStream.",REMOTE_NOT_PUBLISH_SMALL_STREAM:"remote peer does not publish small stream.",INVALID_SWITCH_DEVICE:"cannot switch device on current stream.",INVALID_SWITCH_DEVICE_PUBLISHING:"cannot switch device when publishing localStream.",INVALID_REPLACE_TRACK:"cannot replace track when publishing localStream.",INVALID_INITIALIZE_LOCAL_STREAM:"local stream has not initialized yet.",INVALID_ADD_TRACK_REPETITIVE:"previous addTrack is ongoing, please avoid repetitive execution.",INVALID_ADD_TRACK_REMOVING:"cannot add track when a track is removing.",INVALID_ADD_TRACK_PUBLISHING:"cannot add track when publishing localStream.",INVALID_STREAM_INITIALIZED:"your local stream haven't been initialized yet.",INVALID_ADD_TRACK_NUMBER:"a Stream has at most one audio track and one video track.",INVALID_REMOVE_AUDIO_TRACK:"remove audio track is not supported on your browser.",INVALID_REMOVE_AUDIO_ADDING:"cannot remove track when a track is adding.",INVALID_REMOVE_AUDIO_ON:"previous removeTrack is ongoing, please avoid repetitive execution.",INVALID_REMOVE_TRACK_PUBLISHING:"cannot remove track when publishing localStream.",INVALID_REMOVE_TRACK_NOT_TRACK:"localStream has not this track.",INVALID_REMOVE_TRACK_NUMBER:"remove the only video track is not supported, please use replaceTrack or muteVideo.",INVALID_REPLACE_TRACK_NO_TRACK:e=>"cannot replace ".concat(e.kind," track because stream has not ").concat(e.kind," track"),NOT_BUG_PACKAGE:"You need to buy packages, refer to tencent console.",START_MIX_TRANSCODE_FAILED:e=>"startMixTranscode failed, errMsg: ".concat(e.message,"."),STOP_MIX_TRANSCODE_FAILED:e=>"stopMixTranscode failed, errMsg: ".concat(e.message,"."),MIX_TRANSCODE_NOT_STARTED:"mixTranscode has not been started.",CANNOT_LESS_THAN_ZERO(e){let{key:t,rule:i,fnName:r,value:n}=e;return"'".concat(t||i.name,"' cannot be less than 0 when calling ").concat(r,"().")},MIX_PARAMS_VIDEO_FRAMERATE:"'config.videoFramerate' should be an integer between 0 and 30, excluding 0.",MIX_PARAMS_VIDEO_GOP:"'config.videoGOP' should be an integer between 1 and 8.",MIX_PARAMS_AUDIO_BITRATE:"'config.audioBitrate' should be an integer between 32 and 192.",MIX_PARAMS_USER_Z_ORDER:e=>"'".concat(e,"' is required and must be between 1 and 15."),MIX_PARAMS_NOT_SELF:"'config.mixUsers' must contain self.",MIX_PARAMS_USER_STREAM:"'config.videoWidth' and 'config.videoHeight' of output stream should be contain all mix stream.",INVALID_PLAY:"duplicate play() call observed, please stop() firstly.",INVALID_ELEMENT_ID:e=>{let{key:t,fnName:i}=e;return"'".concat(t,"' is not found in the document object when calling ").concat(i,"().")},INVALID_ELEMENT_ID_TYPE:e=>{let{key:t,fnName:i,type:r}=e;return"the element corresponding to '".concat(t,"' must be instanceof HTMLElement when calling ").concat(i,"(), received: ").concat(r,".")},PLAY_FAILED:e=>"".concat(e.media," play failed,browser exception: ").concat(e.error.toString()),INVALID_USERID:"userId cannot be all spaces.",INVALID_CREATE_STREAM_SOURCE:"LocalStream must be created by createStream() with either audio/video or audioSource/videoSource, but can not be mixed with audio/video and audioSource/videoSource.",INVALID_CREATE_STREAM_SCREEN:"screen/video cannot be both true.",INVALID_CREATE_STREAM_AUDIO:"audio/screenAudio cannot be both true.",INVALID_CREATE_STREAM_SCREEN_AUDIO:"when screen is true, screenAudio can be configured.",NOT_SUPPORTED_HTTP:"http protocol does not support the ability to capture microphone, camera and screen. please use https to deploy your page.",NOT_SUPPORTED_WEBRTC:"your browser or environment does not support full WebRTC capabilities.",NOT_SUPPORTED_PROFILE:"your browser does not support setVideoProfile.",NOT_SUPPORTED_MEDIA:"your browser or environment does not support navigator.mediaDevices.",NOT_SUPPORTED_H264ENCODE:"your device does not support H.264 encoding.",NOT_SUPPORTED_H264DECODE:"your device does not support H.264 decoding.",NOT_SUPPORTED_TRACK:e=>"".concat(e,"Track is not supported on your browser."),NOT_SUPPORTED_SWITCH_DEVICE:"switchDevice is not supported on your browser.",NOT_SUPPORTED_CAPTURE:"Your browser or environment does not support screen sharing, please check whether the browser version.",MICROPHONE_NOT_FOUND:"no microphone detected, please check your microphone.",CAMERA_NOT_FOUND:"no camera detected, please check your camera.",SIGNAL_RESPONSE_FAILED:e=>"".concat(e.signalResponse," failed, response code is ").concat(e.code," , errMsg: ").concat(e.message,"."),CATCH_HANDLER_ERROR(e){let{name:t,event:i}=e;return"an error was caught on ".concat(t,".on('").concat(i,"', handler), please check your code on 'handler'.")},API_NOT_EXIST(e){let{name:t}=e;return"experimental api ".concat(t," does not exist.")},REPEAT_JOIN:e=>"[".concat(e,"] is calling client.join api or has already joined room, please avoid repeated join."),CONNECTION_CLOSED:"remoteStream has been unsubscribed or unpublished by remote user.",SUBSCRIBE_ALL_FALSE:"cannot subscribe when both audio & video are false, use client.unsubscribe() instead",CLIENT_DESTROYED(e){let{funName:t}=e;return"failed to call ".concat(t,"() because client was destroyed.")},SEI_NOT_SUPPORT:e=>"not support to sendSEIMessage".concat(!1===e?" without using h264 codec":""),SEI_DISABLED:"SEI is disabled",SEI_EMPTY:"buffer cannot be empty",SEI_OVERSIZE:e=>"buffer size(".concat(e,") is over 1000 Bytes"),SEI_BEFORE_PUBLISH:"please call sendSEIMessage() after publish() success",SEI_NOT_VIDEO:"cannot send sei when localStream has not video.",CALL_FREQUENCY_LIMIT:e=>{let{isSize:t,name:i,timesInSecond:r,maxSizeInSecond:n}=e;return"api ".concat(i," call ").concat(t?"size":"times"," is over ").concat(t?"".concat(n," bytes"):r," in a second.")},CONNECTION_ABORTED:e=>"connection aborted due to: ".concat(e),API_CALL_ABORTED(e){let t;return t=e.message.includes("REMOTE_STREAM_NOT_EXIST")?"Subscribe ".concat(e.userId," ").concat(e.streamType," stream aborted, reason: remote user ").concat(e.userId," unpublished stream."):"API aborted, reason: ".concat(e.message),t},DUPLICATE_AUX:"only one auxiliary stream can be published in a room.",NOT_SUPPORTED_AUX:"publish auxiliary stream is not supported on your browser.",INVALID_PARAMETER_STREAMTYPE:e=>"'streamType' is required when 'userId' is not '*', calling ".concat(e,"()")},WN=(e,t)=>t?"".concat(vw,"/").concat(e,"/").concat(t):"".concat(vw,"/").concat(e,"/index.html"),zN=()=>{if(window.TRTC_ERROR_INFO&&window.TRTC_ERROR_LINK)return{TRTC_ERROR_INFO:window.TRTC_ERROR_INFO,TRTC_ERROR_LINK:window.TRTC_ERROR_LINK};let e=localStorage.getItem(Iw);if(e){e=JSON.parse(e);let t=document.createElement("script");t.type="text/javascript",t.text=e.message,document.body.appendChild(t);let i=window.TRTC_ERROR_INFO,r=window.TRTC_ERROR_LINK;return document.body.removeChild(t),{TRTC_ERROR_INFO:i,TRTC_ERROR_LINK:r}}return{}};function GN(e){let{key:t,data:i,link:r,addDocLink:n=!0}=e,o="",s="",a="";ND(jN[t])?o=jN[t](i):OD(jN[t])&&(o=jN[t]);let{TRTC_ERROR_INFO:c,TRTC_ERROR_LINK:l}=zN();r?a="".concat(r.className,".html#").concat(r.fnName):l&&l[t]&&(ND(l[t])?a=l[t](i):OD(l[t])&&(a=l[t]));let d=o;return RD()&&(c&&c[t]&&(ND(c[t])?s=c[t](i):OD(c[t])&&(s=c[t])),s&&(d=n?"".concat(s,"\n请查看文档: ").concat(WN("zh-cn",a),"\n\n"):"".concat(s,"\n\n"),d+=o)),n&&(d+=" \nRefer to: ".concat(WN("en",a),"\n")),d}var KN,YN=function(e){let{retryFunction:t,settings:i,onError:r,onRetrying:n,onRetryFailed:o,onRetrySuccess:s,context:a}=e;return function(){for(var e=arguments.length,c=new Array(e),l=0;l<e;l++)c[l]=arguments[l];let{retries:d=5,timeout:u=1e3}=i,h=0,p=-1,m=0,_=(e,i)=>rC(this,null,(function*(){let l=a||this;try{let i=yield t.apply(l,c);h>0&&s&&s.call(this,h),h=0,e(i)}catch(f){let t=()=>{clearTimeout(p),h=0,m=2,i(f)},s=()=>{2!==m&&h<(ND(d)?d():d)?(h++,m=1,ND(n)&&n.call(this,h,t),p=window.setTimeout((()=>{p=-1,_(e,i)}),ND(u)?u(h):u)):(t(),ND(o)&&o.call(this,f))};ND(r)?r.call(this,{error:f,retry:s,reject:i,retryFuncArgs:c,retriedCount:h}):s()}}));return new Promise(_)}},JN=new($b(nC(),1).default),qN=((KN=qN||{}).ROOM_DESTROY="1",KN.JOIN_START="21",KN.JOIN_SCHEDULE_SUCCESS="22",KN.JOIN_SIGNAL_CONNECTION_START="23",KN.JOIN_SIGNAL_CONNECTION_END="24",KN.JOIN_SEND_CMD="25",KN.JOIN_RECEIVED_CMD_RES="26",KN.JOIN_SUCCESS="27",KN.JOIN_FAILED="28",KN.LEAVE_START="51",KN.LEAVE_SEND_CMD="52",KN.LEAVE_SUCCESS="53",KN.PUBLISH_START="61",KN.SEND_FIRST_VIDEO_FRAME="62",KN.PUBLISH_FAILED="63",KN.SUBSCRIBE_START="81",KN.SUBSCRIBE_SUCCESS="82",KN.SUBSCRIBE_FAILED="84",KN.UNSUBSCRIBE_SUCCESS="83",KN.LOCAL_TRACK_CAPTURE_START="101",KN.LOCAL_TRACK_CAPTURE_SUCCESS="102",KN.LOCAL_TRACK_CAPTURE_FAILED="103",KN.LOCAL_TRACK_PUBLISHED="104",KN.LOCAL_TRACK_UNPUBLISHED="105",KN.LOCAL_TRACK_REPLACED="106",KN.SWITCH_DEVICE_SUCCESS="107",KN.TRACK_MUTED="108",KN.TRACK_UNMUTED="109",KN.REMOTE_TRACK_SUBSCRIBED="110",KN.REMOTE_TRACK_UNSUBSCRIBED="111",KN.PLAY_TRACK_START="151",KN.PLAYER_STATE_CHANGED="152",KN.VIDEO_LOADED_DATA="153",KN.AUTOPLAY_DIALOG_CLICK_CONFIRM="154",KN.SIGNAL_CONNECTION_STATE_CHANGED="201",KN.PEER_CONNECTION_STATE_CHANGED="202",KN.SINGLE_CONNECTION_STAT="203",KN.SPC_RECONNECTED="204",KN.HEARTBEAT_REPORT="251",KN.RECEIVED_PUBLISHED_USER_LIST="252",KN.REMOTE_PUBLISH_STATE_CHANGED="253",KN.AUDIO_LEVEL_INTERVAL="260",KN.NETWORK_QUALITY="261",KN),XN=new class{constructor(){this._roomIdMap=new Map,"undefined"==typeof registerProcessor&&(this._configs={sdkAppId:"",userId:"",version:ow,env:Rw.QCLOUD,browserVersion:Xk.name+Xk.version,ua:navigator.userAgent})}setConfig(e){let{sdkAppId:t,env:i,userId:r,roomId:n}=e;t!==this._configs.sdkAppId&&(this._configs.sdkAppId=String(t)),this._configs.env=i,this._configs.userId=r,this._roomIdMap.set(r,String(n))}logSuccessEvent(e){Jk||!EO.isAbleToUpload||this._configs.env===Rw.QCLOUD&&this.uploadEventToKibana(Xb(qb({},e),{result:"success"}))}logFailedEvent(e){if(Jk||!EO.isAbleToUpload)return;let{eventType:t,code:i,error:r,userId:n}=e,o={roomId:this._roomIdMap.get(n||this._configs.userId),userId:n,eventType:t,result:"failed",code:i||(null==r?void 0:r.extraCode)||(null==r?void 0:r.code)||_C.UNKNOWN};this._configs.env===Rw.QCLOUD&&this.uploadEventToKibana(Xb(qb({},o),{error:r}))}uploadEventToKibana(e){let t="stat-".concat(e.eventType,"-").concat(e.result);("delta-join"===e.eventType||"delta-leave"===e.eventType||"delta-publish"===e.eventType)&&(t="".concat(e.eventType,":").concat(e.delta)),this.uploadEvent({log:t,userId:e.userId}),"failed"===e.result&&(t="stat-".concat(e.eventType,"-").concat(e.result,"-").concat(e.code),this.uploadEvent({log:t,userId:e.userId,error:e.error}))}uploadEvent(e){let{log:t,userId:i,error:r}=e,n={timestamp:vC(),sdkAppId:this._configs.sdkAppId,userId:i||this._configs.userId,version:ow,log:t};r&&(n.errorInfo=r.message),this.sendRequest(dD(this._configs.sdkAppId,Aw.LOG),n)}sendRequest(e,t){EO.isAbleToUpload?BN({url:e,body:JSON.stringify(t)}).catch((()=>{})):setTimeout((()=>{this.sendRequest(e,t)}),1e3)}},QN=null,ZN=!0;function $N(e){PD(e)&&e!==ZN&&(ZN=e,EO.info("setIsNeedToSchedule ".concat(e)))}function eD(e){return rC(this,arguments,(function(e){let{userId:t,sdkAppId:i,useStringRoomId:r,roomId:n,userSig:o,version:s,frameWorkType:a}=e;return function*(){if(!ZN&&QN)return{isCached:!0,result:QN};let e={delta:0,count:[1,1],msg:[],detail:[]};try{let u=new FormData;u.append("userId",String(t)),u.append("sdkAppId",String(i)),u.append("isStrGroupId",String(r)),u.append("groupId",String(n)),u.append("sdkVersion",s),u.append("userSig",String(o)),a&&u.append("frameWorkType",String(a));let h=zD(),p=yield(c=u,l=e,d=i,new Promise(((e,t)=>{let i=null;WD([aD((e=>l.count[0]=e+1),(e=>{let{error:t,retry:r,retriedCount:n,retryFuncArgs:o}=e;l.msg[0]=t.message,i||(n>=2&&(o[0]=rD(d,Mw.MAIN,!0)),r())}))(rD(d,Mw.MAIN),c,{get timeout(){return 1e3*CD(2+l.count[0])}}),aD((e=>l.count[1]=e+1),(e=>{let{error:t,retry:r,retriedCount:n,retryFuncArgs:o}=e;l.msg[1]=t.message,i||(n>=2&&(o[0]=rD(d,Mw.BACKUP,!0)),r())}))(rD(d,Mw.BACKUP),c,{get timeout(){return 1e3*CD(2+l.count[1])}})]).then((t=>{i=t,e(i)})).catch(t)})));p.config&&(p.config.loggerDomain&&mw(p.config.loggerDomain),PD(p.config.scheduleCache)&&$N(!p.config.scheduleCache)),e.delta=zD()-h;let m=function(e,t,i){let r=performance.getEntriesByType("resource"),n=rD(e,Mw.MAIN),o=rD(e,Mw.BACKUP),s={totalCost:0,local:0,dns:0,tcp:0,tls:0,request:0,response:0};for(let a of r)if(a.startTime>=i&&(a.name===n||a.name===o)&&a.transferSize>0){let e=a.name===n?Mw.MAIN:Mw.BACKUP,i=Math.round(a.duration),r=Math.round(a.domainLookupStart-a.startTime),o=Math.round(a.domainLookupEnd-a.domainLookupStart),c=Math.round(a.requestStart-a.secureConnectionStart),l=Math.round(a.secureConnectionStart-a.connectStart),d=Math.round(a.responseStart-a.requestStart),u=Math.round(a.responseEnd-a.responseStart),h=[r,o,c,l,d,u];XN.uploadEvent({log:"stat-schedule-net:".concat(i,"(").concat(h.join("->"),") ").concat(e),userId:t}),s=Xb(qb({},s),{totalCost:i,local:r,dns:o,tcp:l,tls:c,request:d,response:u});break}return s}(Number(i),t,h);return QN=p,{isCached:!1,result:p,detailCost:m}}catch(u){let e=xD(u)?u[0]:u,t=LD(e.code)?e.code:0,i="schedule failed".concat(e.message?": ".concat(e.message):""),r=new fC({code:_C.SCHEDULE_FAILED,extraCode:t,message:GN({key:HN.JOIN_ROOM_FAILED,data:{error:i,code:t}})});throw EO.error(i,t),r}var c,l,d}()}))}document&&document.head.insertAdjacentHTML("beforeend",Object.values(SN).map((e=>'<link rel="dns-prefetch" href="https://'.concat(e,'">'))).join("\r\n")),JN.on("28",(()=>$N(!0))),JN.on("63",(()=>$N(!0))),JN.on("84",(()=>$N(!0))),JN.on("201",(e=>{"RECONNECTING"===e.state&&$N(!0)})),JN.on("202",(e=>{"RECONNECTING"===e.state&&$N(!0)}));var tD={main:"",backup:""};function iD(e){xD(e)?(tD.main=e[0],tD.backup=e[1]):tD.main=e}function rD(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Mw.MAIN,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return"https://".concat(tD[t]||oD(e,t,i),"/api/v1/config")}function nD(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Mw.MAIN;return"https://".concat(tD[t]||oD(e,t),"/api/v1/trtcAutoConf")}function oD(e){let t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Mw.MAIN,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return lD(e)?i===Mw.MAIN?SN.MAIN_OVERSEA:SN.BACKUP_OVERSEA:(t=lD(e)?r?i===Mw.MAIN?SN.MAIN_OVERSEA_OLD:SN.BACKUP_OVERSEA_OLD:i===Mw.MAIN?SN.MAIN_OVERSEA:SN.BACKUP_OVERSEA:i===Mw.MAIN?SN.MAIN:SN.BACKUP,t)}function sD(e,t,i){return new Promise(((r,n)=>{BN({url:e,body:t,timeout:i.timeout}).then((e=>{0===e.data.code?r(e.data.data):n({code:e.data.code,message:e.data.msg})})).catch(n)}))}var aD=(e,t)=>YN({retryFunction:sD,settings:{retries:3,timeout:0},onError:t,onRetrying:e}),cD=function(){return new URLSearchParams(location.search).get("trtc_env")||""},lD=e=>Number(e)<14e8,dD=function(e,t){let i;i=pw||(lD(e)?Sw:Tw);let r=Math.floor(Math.random()*Yb(2,31));return"".concat(i,"/v5/AVQualityReportSvc/C2S?random=").concat(r,"&sdkappid=").concat(e,"&cmdtype=").concat(t)};function uD(){return MC?4:OC?2:NC?3:fk?12:_k?5:gk?13:1}function hD(){return MC?"Android":OC?"iPhone":NC?"iPad":fk?"Mac":_k?"Windows":gk?"Linux":"unknown"}var pD="unknown";function mD(){if("unknown"!==pD)return pD;let{userAgent:e,connection:t}=navigator,i=(e.match(/NetType\/\S+/)||[])[0]||"";i=i.toLowerCase().replace("nettype/",""),"3gnet"===i&&(i="3g");let r=t&&t.type&&t.type.toLowerCase(),n=t&&t.effectiveType&&t.effectiveType.toLowerCase();return"slow-2"===n&&(n="2g"),r&&(pD=_D(r,n)),pD}function _D(e,t){if(ww[e])return e;switch(e){case"cellular":case"wimax":return t||"unknown";case"ethernet":return"wired";default:return"unknown"}}function fD(e){pD=_D(e)}function gD(){return ww[mD()]}var ED=function(e){return{AbilityOption:{AVLimit:e,GeneralLimit:{CPULimit:{uint32_CPU_num:navigator.hardwareConcurrency||0,str_CPU_name:String(navigator.platform),uint32_CPU_maxfreq:0,model:"",uint32_total_memory:0},uint32_terminal_type:uD(),uint32_device_type:0,str_os_verion:hD(),uint32_link_type:1,str_client_version:nw,uint32_net_type:ww[mD()],ua:navigator.userAgent,version:""}}}};function vD(e,t){for(let i of Reflect.ownKeys(t))if("constructor"!==i&&"prototype"!==i&&"name"!==i){let r=Object.getOwnPropertyDescriptor(t,i)||"";Object.defineProperty(e,i,r)}return e}function yD(e){return TD(e/4,arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function TD(e){return 1e3*e/(arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function SD(e){return 4*ID(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function ID(e){return e*(arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)/1e3}var AD="undefined"!=typeof window&&"function"==typeof window.glog?window.glog:()=>{},RD=()=>{let e=navigator.language;return e=e.substring(0,2),"zh"===e},bD=function(e){if(!e||"object"!=typeof e||"[object Object]"!=Object.prototype.toString.call(e))return!1;let t=Object.getPrototypeOf(e);if(null===t)return!0;let i=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return"function"==typeof i&&i instanceof i&&Function.prototype.toString.call(i)===Function.prototype.toString.call(Object)};function CD(e){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return e<=1?t:CD(e-1,t,(arguments.length>1&&void 0!==arguments[1]?arguments[1]:1)+t)}function kD(e){return e>8?3e4:1e3*CD(e)}function wD(e){return Reflect.apply(Object.prototype.toString,e,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}var ND=e=>"function"==typeof e,DD=e=>void 0===e,OD=e=>"string"==typeof e,LD=e=>"number"==typeof e,PD=e=>"boolean"==typeof e,MD=e=>"object"===wD(e),xD=e=>"array"===wD(e),VD=e=>wD(e)==="MediaStreamTrack".toLowerCase(),UD=e=>e.isRemote,BD=e=>"promise"===wD(e),FD=e=>ND(e)&&e.prototype.constructor===e,HD=e=>FD(e)?e.prototype.constructor.name:"",jD="undefined"!=typeof AudioWorkletNode;function WD(e){return new Promise(((t,i)=>{let r=[];e.forEach((n=>{n.then(t).catch((t=>{r.push(t),r.length===e.length&&i(r)}))}))}))}function zD(){return performance&&performance.now?Math.floor(performance.now()):Date.now()}var GD=e=>+e<10?"0".concat(e):e,KD=e=>{let t=e.match(/^\d+\.\d+\.\d+/)[0];if(!t)return e;let i=t.split("."),r=GD(i[1])+GD(i[2]);return i[1]-15>0&&(i[1]="15"),i[2]-15>0&&(i[2]="15"),"".concat(i.join("."),".").concat(r)},YD=Object.prototype.hasOwnProperty;function JD(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e||"function"==typeof e||Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(bD(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(let t in e)if(YD.call(e,t))return!1;return!0}return!1}function qD(e,t){return{userId:t,hasAudio:!!(e&jw),hasVideo:!!(e&Bw),hasAuxiliary:!!(e&Hw),hasSmall:!!(e&Fw),audioMuted:!!(e&Ww),videoMuted:!!(e&zw),audioAvailable:!(!(e&jw)||e&Ww),videoAvailable:!(!(e&Bw)||e&zw)}}function XD(e,t){return e>50||t>500?5:e>30||t>350?4:e>20||t>200?3:e>10||t>100?2:e>=0||t>=0?1:0}function QD(e){let t={urls:"turn:".concat(e.url)};return!DD(e.username)&&!DD(e.credential)&&(t.username=e.username,t.credential=e.credential,t.credentialType="password",DD(e.credentialType)||(t.credentialType=e.credentialType)),t}function ZD(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!OD(e))return 0;let i=e.split(".");return t?(Number(i[0])<<24|Number(i[1])<<16|Number(i[2])<<8|Number(i[3]))>>>0:(Number(i[3])<<24|Number(i[2])<<16|Number(i[1])<<8|Number(i[0]))>>>0}var $D=function(e,t,i,r){if(!MD(e)||!MD(t))return 0;let n,o=0,s=Object.keys(t);for(let a=0,c=s.length;a<c;a++)if(n=s[a],!(DD(t[n])||i&&i.includes(n)))if(MD(e[n])&&MD(t[n]))o+=$D(e[n],t[n],i,r);else{if(r&&r.includes(t[n]))continue;e[n]!==t[n]&&(e[n]=eO(t[n]),o+=1)}return o};function eO(e){if(xD(e)){let t=[];return e.forEach(((e,i)=>{t[i]=eO(e)})),t}if(MD(e)){let t={};return Object.keys(e).forEach((i=>{t[i]=eO(e[i])})),t}return e}var tO=e=>{let t=[];if(xD(e))t=[...e];else if(OD(e)){let i=document.getElementById(e);i&&t.push(i)}else e&&t.push(e);return t},iO=e=>OD(e)?document.getElementById(e):e,rO=new Intl.DateTimeFormat("zh-CN",{dateStyle:"short",timeStyle:"medium"}),nO=()=>rO.format(new Date);function oO(e,t){let{keysToInclude:i,keysToExclude:r}=t;try{if(xD(e))return"[".concat(e.map((e=>oO(e,{keysToInclude:i,keysToExclude:r}))).join(","),"]");if(!bD(e)||!xD(i)&&!xD(r))return JSON.stringify(e);let t={},n=new Set(i),o=new Set(r);return Object.keys(e).forEach((s=>{(0===o.size&&n.has(s)||0===n.size&&!o.has(s))&&(t[s]=bD(e[s])||xD(e[s])?JSON.parse(oO(e[s],{keysToExclude:r,keysToInclude:i})):e[s])})),JSON.stringify(t)}catch(n){return"{}"}}function sO(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=[];return Object.keys(e).forEach((r=>{t===e[r]&&i.push(r)})),oO(e,{keysToInclude:i})}function aO(e){return e.replace(/[\u4e00-\u9fa5]/g,"aa").length}var cO=(()=>{let e=!1,t=document.visibilityState;return()=>{document.visibilityState!==t&&EO.info("visibility change: ".concat(document.visibilityState)),!e&&(document.addEventListener("visibilitychange",(()=>{EO.info("visibility change: ".concat(document.visibilityState)),t=document.visibilityState})),e=!0)}})(),lO=()=>{var e,t,i,r;return null!=(e=window.screen)&&e.orientation?!(null==(r=null==(i=null==(t=window.screen)?void 0:t.orientation)?void 0:i.type)||!r.includes("portrait")):0===window.orientation||180===window.orientation},dO=e=>rC(void 0,null,(function*(){return new Promise(((t,i)=>{let r;if(OD(e))r=new Image,r.crossOrigin="anonymous",r.src=e;else if(r=e,r.complete)return void t(r);r.onload=()=>t(r),r.onerror=i}))})),uO=e=>{let t=e.split(".");return+t[0]<<24|+t[1]<<16|+t[2]<<8|+t[3]},hO=e=>(Object.keys(e).forEach((t=>{LD(e[t])&&(t.startsWith("uint")||t.startsWith("int"))?e[t]=Math.floor(e[t]):(bD(e[t])||xD(e[t]))&&hO(e[t])})),e),pO=Object.prototype.hasOwnProperty;function mO(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e||"function"==typeof e||Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(function(e){if(!e||"object"!=typeof e||"[object Object]"!=Object.prototype.toString.call(e))return!1;let t=Object.getPrototypeOf(e);if(null===t)return!0;let i=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return"function"==typeof i&&i instanceof i&&Function.prototype.toString.call(i)===Function.prototype.toString.call(Object)}(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(let t in e)if(pO.call(e,t))return!1;return!0}return!1}var _O=class{constructor(e){tC(this,"userId"),tC(this,"remoteUserId"),tC(this,"id"),tC(this,"sdkAppId"),tC(this,"type"),tC(this,"isLocal"),this.id=e.id,this.userId=e.userId,this.sdkAppId=e.sdkAppId,this.remoteUserId=e.remoteUserId,this.isLocal="boolean"!=typeof e.isLocal||e.isLocal,this.type=this.isLocal?"":e.type}createChild(e){return Object.setPrototypeOf(e,this)}setUserId(e){this.userId=e}setSdkAppId(e){this.sdkAppId=e}log(e,t){let i=this.isLocal?this.userId:this.remoteUserId;t.unshift("[".concat(this.isLocal?"↑":"↓").concat(this.type&&"main"!==this.type?"*":"").concat(this.id).concat(i?"|".concat(i):"","]")),EO.log(e,t,void 0===this.userId||mO(this.userId),this.userId,this.sdkAppId)}info(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(2,t)}debug(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(1,t)}warn(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(3,t)}error(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(4,t)}},fO=qN,gO=!(PC||MC||xk),EO=new class{constructor(){tC(this,"_isEnableUploadLog",!0),tC(this,"_localJoinedUser",new Map),tC(this,"_queue",[]),tC(this,"_timeoutId",-1),tC(this,"_logLevel",1),tC(this,"_logLevelToUpload",2),!dw&&!uw&&(this.checkURLParam(),this.installEvents())}get isAbleToUpload(){return this._isEnableUploadLog&&-1!==this._timeoutId}installEvents(){JN.on(fO.JOIN_SCHEDULE_SUCCESS,(e=>{let{schedule:t}=e;var i;(null==(i=null==t?void 0:t.config)?void 0:i.logLevelToUpload)&&bw[t.config.logLevelToUpload]&&(this._logLevelToUpload=t.config.logLevelToUpload)})),JN.on(fO.JOIN_SUCCESS,(e=>{let{room:t}=e;this.addJoinedUser({userId:t.userId,sdkAppId:t.sdkAppId}),this.startUpload()})),JN.once(fO.JOIN_FAILED,(()=>{this.startUpload()})),JN.on(fO.LEAVE_SUCCESS,(e=>{let{room:t}=e;this.deleteJoinedUser(t.userId)}))}startUpload(){-1===this._timeoutId&&this.uploadInterval()}addJoinedUser(e){this._localJoinedUser.set(e.userId,e),this.startUpload()}deleteJoinedUser(e){this._localJoinedUser.delete(e)}uploadInterval(){this.upload().catch((()=>{})),this._timeoutId=window.setTimeout((()=>this.uploadInterval()),2e3)}getLogsToUpload(){let e={map:new Map,splicedQueue:[]};if(this._queue[0].forAllJoinedClients&&0===this._localJoinedUser.size)return e;let t=0;for(;t<this._queue.length&&50!==t;t++){let i=this._queue[t];if(i.forAllJoinedClients)this._localJoinedUser.forEach((t=>{let{userId:r,sdkAppId:n}=t;e.map.has(r)?e.map.get(r).logs.push(i):e.map.set(r,{userId:r,sdkAppId:n,logs:[i]})}));else if(OD(i.userId)&&LD(i.sdkAppId)){let{userId:t,sdkAppId:r}=i;e.map.has(t)?e.map.get(t).logs.push(i):e.map.set(t,{userId:t,sdkAppId:r,logs:[i]})}}return e.map.size>0&&(e.splicedQueue=this._queue.splice(0,t)),e}upload(){return rC(this,null,(function*(){if(0===this._queue.length||!this._isEnableUploadLog)return;let{map:e,splicedQueue:t}=this.getLogsToUpload();if(0===e.size)return;try{let t=[...e.values()];for(let e=0;e<t.length;e++){let{userId:i,sdkAppId:r,logs:n}=t[e];yield this.uploadLogWithRetry(JSON.stringify({timestamp:vC(),sdkAppId:String(r),userId:i,version:ow,log:n.map((e=>e.log)).join("\n")}),r),n.forEach((e=>e.uploaded=!0))}}catch(r){}let i=t.filter((e=>!e.uploaded));i.length>0&&(this._queue=i.concat(this._queue))}))}uploadLogWithRetry(e,t){return YN({retryFunction:()=>BN({url:dD(t,Aw.LOG),body:e,timeout:5e3}),settings:{retries:3,timeout:1e3},onError:e=>{let{retry:t}=e;t()}})()}getPrefix(e){let t=new Date;t.setTime(EC());let i=String(t.getMilliseconds());return"padStart"in String.prototype&&(i=i.toString().padStart(3,"0")),"[".concat(t.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(i,"] <").concat(bw[e],">")}getLogLevel(){return this._logLevel}setLogLevel(e){DD(bw[e])||(this._logLevel!==e&&this.info("setLogLevel",e),this._logLevel=e)}enableUploadLog(){this._isEnableUploadLog=!0}disableUploadLog(){this.warn("disableUploadLog"),this._isEnableUploadLog=!1}logChunkToString(e){if(OD(e))return e;try{return e instanceof Error?e.toString():JSON.stringify(e)}catch(t){return""}}log(e,t){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=arguments.length>3?arguments[3]:void 0,n=arguments.length>4?arguments[4]:void 0;var o;if(t.unshift(this.getPrefix(e)),this._isEnableUploadLog&&e>=this._logLevelToUpload&&this._queue.push({log:t.reduce(((e,t)=>"".concat(e," ").concat(this.logChunkToString(t)).trim()),""),level:e,userId:r,sdkAppId:n,forAllJoinedClients:i}),e<this._logLevel)return;let s=(null==(o=bw[e])?void 0:o.toLowerCase())||"info";gO?console[s]("%cTRTC%c%s","padding: 1px 4px;border-radius: 3px;color: #fff;background: #1E88E5;","display: inline",...t):console[s](...t)}debug(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(1,t)}info(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(2,t)}warn(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(3,t)}error(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(4,t)}createLogger(e){return new _O(e)}checkURLParam(){let e=new URLSearchParams(location.search).get("logLevelToUpload"),t=e?Number(e):-1;bw[t]&&(this._logLevelToUpload=t)}},vO=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{let t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))},yO=new class{constructor(){tC(this,"_prefix","TRTC"),tC(this,"_queue",new Map),this.checkStorage()}getRealKey(e){return"".concat(this._prefix,"_").concat(e)}checkStorage(){qk()&&(setInterval(this.doFlush.bind(this),2e4),Object.keys(localStorage).filter((e=>{if(e.startsWith(this._prefix)){let t=localStorage.getItem(e);if(!t)return!1;let i=JSON.parse(t);if(i&&i.expiresIn<Date.now())return!0}return!1})).forEach((e=>localStorage.removeItem(e))))}doFlush(){if(qk())try{for(let[e,t]of this._queue)localStorage.setItem(e,JSON.stringify(t))}catch(e){EO.warn(e)}}getItem(e){if(!qk())return null;try{let t=localStorage.getItem(this.getRealKey(e));if(!t)return null;let i=JSON.parse(t);return i&&i.expiresIn>=Date.now()?i.value:null}catch(t){EO.warn(t)}}setItem(e,t){if(qk())try{let i={expiresIn:Date.now()+Nw,value:t};this._queue.set(this.getRealKey(e),i)}catch(i){EO.warn(i)}}deleteItem(e){if(!qk())return!1;try{return e=this.getRealKey(e),this._queue.delete(e),localStorage.removeItem(e),!0}catch(t){return EO.warn(t),!1}}clear(){if(qk())try{localStorage.clear()}catch(e){EO.warn(e)}}},TO={};Zb(TO,{HTTPS_API:()=>VO,IS_GET_CAPABILITIES_SUPPORTED:()=>eL,IS_GET_SETTINGS_SUPPORTED:()=>$O,IS_SEI_SUPPORTED:()=>tL,IS_SPC_SUPPORTED:()=>qO,basis:()=>sL,checkSystemRequirementsInternal:()=>PO,decodeSupportStatus:()=>LO,encodeSupportStatus:()=>OO,getBrowserInfo:()=>RO,getDisplayResolution:()=>BO,isAddTransceiverSupported:()=>JO,isBrowserSupported:()=>bO,isGetReceiversSupported:()=>GO,isGetSendersSupported:()=>KO,isGetTransceiversSupported:()=>YO,isGetUserMediaSupported:()=>FO,isMediaDevicesSupported:()=>kO,isMediaSessionSupported:()=>nL,isMediaStreamTrackProcessorSupported:()=>DO,isReplaceTrackSupported:()=>QO,isScreenCaptureApiAvailable:()=>xO,isSelectedCandidatePair:()=>UO,isSetParametersSupported:()=>ZO,isSmallStreamAPISupported:()=>jO,isSmallStreamSupported:()=>WO,isStopTransceiverSupported:()=>XO,isTRTCSupported:()=>MO,isUnifiedPlanDefault:()=>zO,isUsedInHttpProtocol:()=>NO,isWebAudioSupported:()=>HO,isWebCodecSupported:()=>rL,isWebCodecsSupported:()=>CO,isWebRTCSupported:()=>iL,isWebTransportSupported:()=>oL});var SO=$b(cC(),1),IO={result:!1,detail:{isBrowserSupported:!1,isWebRTCSupported:!1,isWebCodecsSupported:!1,isMediaDevicesSupported:!1,isScreenShareSupported:!1,isSmallStreamSupported:!1,isH264EncodeSupported:!1,isVp8EncodeSupported:!1,isH264DecodeSupported:!1,isVp8DecodeSupported:!1}},AO=new Map([[BC,["Firefox",FC]],[zC,["Edg",GC]],[Mk,["Chrome",Uk]],[Bk,["Safari",Hk]],[QC,["TBS",ZC]],[$C,["XWEB",ek]],[nk&&OC,["WeChat",ok]],[lk,["QQ(Win)",dk]],[ak,["QQ(Mobile)",ck]],[sk,["QQ(Mobile X5)",ck]],[uk,["QQ(Mac)",hk]],[pk,["QQ(iPad)",mk]],[Sk,["MI",Ik]],[Ak,["HW",bk]],[Ck,["Samsung",kk]],[wk,["OPPO",Nk]],[Dk,["VIVO",Ok]],[jC,["EDGE",WC]],[YC,["SogouMobile",JC]],[qC,["Sogou",XC]]]);function RO(){let e=AO.get(!0);return{browserName:e?e[0]:"unknown",browserVersion:e?e[1]:"unknown"}}var bO=function(){return!(yk||jC||zC&&KC<80||BC&&HC<56)},CO=function(){return["VideoDecoder","VideoEncoder","AudioEncoder","AudioDecoder","MediaStreamTrackGenerator"].every((e=>e in window))},kO=function(){if(!navigator.mediaDevices)return NO()||EO.error(jN.NOT_SUPPORTED_MEDIA),!1;let e=["getUserMedia","enumerateDevices"];return e.filter((e=>e in navigator.mediaDevices)).length===e.length},wO=!1;function NO(){return"http:"===location.protocol&&!Jk&&(wO||EO.error(GN({key:HN.NOT_SUPPORTED_HTTP})),wO=!0,!0)}var DO=function(){return(null==window?void 0:window.OffscreenCanvas)&&(null==window?void 0:window.MediaStreamTrackProcessor)&&(null==window?void 0:window.MediaStreamTrackGenerator)},OO=function(){return rC(this,null,(function*(){if(IO.detail.isH264EncodeSupported||IO.detail.isVp8EncodeSupported)return{isH264EncodeSupported:IO.detail.isH264EncodeSupported,isVp8EncodeSupported:IO.detail.isVp8EncodeSupported};let e,t=!1,i=!1;try{let r=new RTCPeerConnection,n=document.createElement(Mw.CANVAS);n.getContext("2d");let o=n.captureStream(0);return r.addTrack(o.getVideoTracks()[0],o),e=yield r.createOffer(),-1!==e.sdp.toLowerCase().indexOf("h264")&&(t=!0),-1!==e.sdp.toLowerCase().indexOf("vp8")&&(i=!0),r.close(),IO.detail.isH264EncodeSupported=t,IO.detail.isVp8EncodeSupported=i,{isH264EncodeSupported:IO.detail.isH264EncodeSupported,isVp8EncodeSupported:IO.detail.isVp8EncodeSupported}}catch(r){return{isH264EncodeSupported:!1,isVp8EncodeSupported:!1}}}))},LO=function(){return rC(this,null,(function*(){if(IO.detail.isH264DecodeSupported&&IO.detail.isVp8DecodeSupported)return{isH264DecodeSupported:IO.detail.isH264DecodeSupported,isVp8DecodeSupported:IO.detail.isVp8DecodeSupported};let e,t=!1,i=!1;try{let r=new RTCPeerConnection;return e=yield r.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0}),-1!==e.sdp.toLowerCase().indexOf("h264")&&(t=!0),-1!==e.sdp.toLowerCase().indexOf("vp8")&&(i=!0),r.close(),{isH264DecodeSupported:t,isVp8DecodeSupported:i}}catch(r){return{isH264DecodeSupported:!1,isVp8DecodeSupported:!1}}}))},PO=function(){return rC(this,null,(function*(){if(IO.result)return IO;let e=bO(),t=iL(),i=CO(),r=kO(),{isH264EncodeSupported:n,isVp8EncodeSupported:o}=yield OO(),{isH264DecodeSupported:s,isVp8DecodeSupported:a}=yield LO();if(!n||!o){let e=yield OO();n=e.isH264EncodeSupported,o=e.isVp8EncodeSupported}if(n&&s&&(wk||Dk||jk)&&!QC&&Lk()<79){let{encode:e,decode:t}=yield function(){return rC(this,null,(function*(){return new Promise((e=>rC(this,null,(function*(){let t={encode:!1,decode:!1},i=()=>{};try{let r=document.createElement("canvas"),n=r.getContext("2d");r.width=640,r.height=480;let o=setInterval((()=>{n.fillText("test",Math.floor(640*Math.random()),Math.floor(480*Math.random()))}),33),s=-1,a=-1;i=()=>{clearInterval(s),clearInterval(o),clearTimeout(a),l.close(),d.close(),c.getTracks().forEach((e=>e.stop()))},a=setTimeout((()=>{i(),e(t)}),3e3);let c=r.captureStream(),l=new RTCPeerConnection({}),d=new RTCPeerConnection({offerToReceiveAudio:!0,offerToReceiveVideo:!0});l.addEventListener("icecandidate",(e=>d.addIceCandidate(e.candidate))),d.addEventListener("icecandidate",(e=>l.addIceCandidate(e.candidate))),l.addTrack(c.getVideoTracks()[0],c);let u=yield l.createOffer();yield l.setLocalDescription(u),yield d.setRemoteDescription(u);let h=yield d.createAnswer(),p=SO.default.parse(h.sdp),m=p.media[0].rtp.findIndex((e=>"H264"===e.codec));p.media[0].rtp=[p.media[0].rtp[m]],p.media[0].fmtp=p.media[0].fmtp.filter((e=>e.payload===p.media[0].rtp[0].payload)),p.media[0].rtcpFb&&(p.media[0].rtcpFb=p.media[0].rtcpFb.filter((e=>e.payload===p.media[0].rtp[0].payload))),h.sdp=SO.default.write(p),yield d.setLocalDescription(h),yield l.setRemoteDescription(h),s=setInterval((()=>rC(this,null,(function*(){t.encode&&t.decode&&(i(),e(t));let r=yield l.getStats(),n=yield d.getStats();t.encode||r.forEach((e=>{"outbound-rtp"===e.type&&e.mediaType===Mw.VIDEO&&e.framesEncoded>0&&(t.encode=!0)})),t.decode||n.forEach((e=>{"inbound-rtp"===e.type&&e.mediaType===Mw.VIDEO&&e.framesDecoded>0&&(t.decode=!0)}))}))),500)}catch(r){i(),EO.warn(r),e(t)}}))))}))}();n=e,s=t}return IO.result=e&&t&&r&&(n||o)&&(s||a),IO.detail.isBrowserSupported=e,IO.detail.isWebRTCSupported=t,IO.detail.isWebCodecsSupported=i,IO.detail.isMediaDevicesSupported=r,IO.detail.isScreenShareSupported=xO(),IO.detail.isSmallStreamSupported=WO(),IO.detail.isH264EncodeSupported=n,IO.detail.isVp8EncodeSupported=o,IO.detail.isH264DecodeSupported=s,IO.detail.isVp8DecodeSupported=a,IO.result||EO.error("".concat(navigator.userAgent," ").concat(sO(IO.detail,!1))),yO.setItem(aL,{ua:navigator.userAgent,checkResult:IO}),IO}))},MO=function(){return IO.result},xO=function(){return!(!navigator.mediaDevices||!navigator.mediaDevices.getDisplayMedia)},VO=(e,t,i)=>{"http:"===location.protocol&&!Jk&&(e[t]=()=>{throw new fC({code:_C.INVALID_OPERATION,message:jN.NOT_SUPPORTED_HTTP})})},UO=function(e){return!("candidate-pair"!==e.type||!e.nominated||"in-progress"!==e.state&&"succeeded"!==e.state||PD(e.selected)&&!e.selected)};function BO(){let e="";if(screen.width){let t=screen.width?screen.width*window.devicePixelRatio:"",i=screen.height?screen.height*window.devicePixelRatio:"";e+="".concat(t," * ").concat(i)}return e}function FO(){return navigator.getUserMedia||navigator.mediaDevices&&navigator.mediaDevices.getUserMedia}function HO(){let e={isSupported:!1},t=["AudioContext","webkitAudioContext","mozAudioContext","msAudioContext"];for(let i=0;i<t.length;i++)if(t[i]in window){e.isSupported=!0;break}return e.isSupported}function jO(){return"captureStream"in HTMLCanvasElement.prototype}function WO(){return!(nk||PC||Vk&&Vk<63||!bO()||!jO())}var zO=function(){if(DD(window.RTCRtpTransceiver)||!("currentDirection"in RTCRtpTransceiver.prototype))return!1;let e=null,t=!1;try{e=new RTCPeerConnection({sdpSemantics:pN}),e.addTransceiver(Mw.AUDIO),t=!0}catch(i){}return null==e||e.close(),t};function GO(){return"RTCPeerConnection"in window&&"getReceivers"in window.RTCPeerConnection.prototype}function KO(){return"RTCPeerConnection"in window&&"getSenders"in window.RTCPeerConnection.prototype}function YO(){return"RTCPeerConnection"in window&&"getTransceivers"in window.RTCPeerConnection.prototype}function JO(){return 11!==zk&&"RTCPeerConnection"in window&&"addTransceiver"in window.RTCPeerConnection.prototype}var qO=!(!JO()||Pk&&Vk<74);function XO(){return"RTCRtpTransceiver"in window&&"stop"in window.RTCRtpTransceiver.prototype}function QO(){return"RTCRtpSender"in window&&"replaceTrack"in window.RTCRtpSender.prototype}function ZO(){return"RTCRtpSender"in window&&"setParameters"in window.RTCRtpSender.prototype&&KO()}var $O=window.MediaStreamTrack&&"getSettings"in MediaStreamTrack.prototype,eL=window.MediaStreamTrack&&"getCapabilities"in MediaStreamTrack.prototype,tL="RTCRtpSender"in window&&"createEncodedStreams"in window.RTCRtpSender.prototype&&Lk()>=86,iL=function(){return["RTCPeerConnection","webkitRTCPeerConnection","RTCIceGatherer"].filter((e=>e in window)).length>0};function rL(){let e={AudioDecoder:!1,AudioEncoder:!1,VideoDecoder:!1,VideoEncoder:!1,ImageDecoder:!1};return DD(window.AudioDecoder)||(e.AudioDecoder=!0),DD(window.AudioEncoder)||(e.AudioEncoder=!0),DD(window.VideoDecoder)||(e.VideoDecoder=!0),DD(window.VideoEncoder)||(e.VideoEncoder=!0),DD(window.ImageDecoder)||(e.ImageDecoder=!0),e}function nL(){return"mediaSession"in navigator&&!DD(navigator.mediaSession.setActionHandler)}function oL(){return!DD(window.WebTransport)}function sL(){let e={browser:"".concat(Xk.name,"/").concat(Xk.version),os:tw(),displayResolution:BO(),isScreenShareSupported:xO(),isWebRTCSupported:iL(),isGetUserMediaSupported:FO(),isWebAudioSupported:HO(),isWebSocketsSupported:"WebSocket"in window&&2===window.WebSocket.CLOSING,isWebCodecSupported:rL(),isMediaSessionSupported:nL(),isWebTransportSupported:oL()};return navigator.userAgent.includes("miniProgram")&&(e.browser="mini/".concat(e.browser)),e}var aL="checkResult";!function(){NO();let e=yO.getItem(aL);e&&e.ua===navigator.userAgent&&(IO=e.checkResult),PO()}();var cL=$b(nC(),1),lL=Symbol("instance"),dL=Symbol("cacheResult"),uL=class{constructor(e,t,i){this.oldState=e,this.newState=t,this.action=i,this.aborted=!1}abort(e){this.aborted=!0,fL.call(e,this.oldState,new Error("action '".concat(this.action,"' aborted")))}toString(){return"".concat(this.action,"ing")}},hL=class extends Error{constructor(e,t,i){super(t),this.state=e,this.message=t,this.cause=i}},pL=new Map;function mL(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return(r,n,o)=>{let s=i.action||n;if(!i.context){let i=pL.get(r)||[];pL.has(r)||pL.set(r,i),i.push({from:e,to:t,action:s})}let a=o.value;o.value=function(){let r=this;for(var n=arguments.length,o=new Array(n),c=0;c<n;c++)o[c]=arguments[c];if(i.context&&(r=gL.get("function"==typeof i.context?i.context.call(this,...o):i.context)),r.state===t)return i.sync?r[dL]:Promise.resolve(r[dL]);r.state instanceof uL&&r.state.action==i.abortAction&&r.state.abort(r);let l=null;Array.isArray(e)?0==e.length?r.state instanceof uL&&r.state.abort(r):("string"!=typeof r.state||!e.includes(r.state))&&(l=new hL(r._state,"".concat(r.name," ").concat(s," to ").concat(t," failed: current state ").concat(r._state," not from ").concat(e.join("|")))):e!==r.state&&(l=new hL(r._state,"".concat(r.name," ").concat(s," to ").concat(t," failed: current state ").concat(r._state," not from ").concat(e)));let d=e=>{if(i.fail&&i.fail.call(this,e),i.sync){if(i.ignoreError)return e;throw e}return i.ignoreError?Promise.resolve(e):Promise.reject(e)};if(l)return d(l);let u=r.state,h=new uL(u,t,s);fL.call(r,h);let p=e=>{var n;return r[dL]=e,h.aborted||(fL.call(r,t),null===(n=i.success)||void 0===n||n.call(this,r[dL])),e},m=e=>{let t=e instanceof Error?e.message:String(e);return fL.call(r,u,e),d(new hL(r._state,"action '".concat(s,"' failed :").concat(t),e instanceof Error?e:new Error(t)))};try{let e=a.apply(this,o);return"object"==typeof(_=e)&&_&&"then"in _?e.then(p).catch(m):i.sync?p(e):Promise.resolve(p(e))}catch(f){return m(f)}var _}}}var _L="undefined"!=typeof window&&window.__AFSM__?(e,t)=>{window.dispatchEvent(new CustomEvent(e,{detail:t}))}:"undefined"!=typeof importScripts?(e,t)=>{postMessage({type:e,payload:t})}:()=>{};function fL(e,t){let i=this._state;this._state=e;let r=e.toString();e&&this.emit(r,i),this.emit(gL.STATECHANGED,e,i,t),this.updateDevTools({value:e,old:i,err:t instanceof Error?t.message:String(t)})}var gL=class extends cL.default{constructor(e,t,i){super(),this.name=e,this.groupName=t,this._state=gL.INIT,e||(e=Date.now().toString(36)),i?Object.setPrototypeOf(this,i):i=Object.getPrototypeOf(this),t||(this.groupName=this.constructor.name);let r=i[lL];r?this.name=r.name+"-"+r.count++:i[lL]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){let e=Object.getPrototypeOf(this),t=pL.get(e)||[],i=new Set,r=[],n=[],o=new Set,s=Object.getPrototypeOf(e);pL.has(s)&&(s.stateDiagram.forEach((e=>i.add(e))),s.allStates.forEach((e=>o.add(e)))),t.forEach((e=>{let{from:t,to:i,action:o}=e;"string"==typeof t?r.push({from:t,to:i,action:o}):t.length?t.forEach((e=>{r.push({from:e,to:i,action:o})})):n.push({to:i,action:o})})),r.forEach((e=>{let{from:t,to:r,action:n}=e;o.add(t),o.add(r),o.add(n+"ing"),i.add("".concat(t," --\x3e ").concat(n,"ing : ").concat(n)),i.add("".concat(n,"ing --\x3e ").concat(r," : ").concat(n," 🟢")),i.add("".concat(n,"ing --\x3e ").concat(t," : ").concat(n," 🔴"))})),n.forEach((e=>{let{to:t,action:r}=e;i.add("".concat(r,"ing --\x3e ").concat(t," : ").concat(r," 🟢")),o.forEach((e=>{e!==t&&i.add("".concat(e," --\x3e ").concat(r,"ing : ").concat(r))}))}));let a=[...i];return Object.defineProperties(e,{stateDiagram:{value:a},allStates:{value:o}}),a}static get(e){let t;return"string"==typeof e?(t=gL.instances.get(e),t||gL.instances.set(e,t=new gL(e,void 0,Object.create(gL.prototype)))):(t=gL.instances2.get(e),t||gL.instances2.set(e,t=new gL(e.constructor.name,void 0,Object.create(gL.prototype)))),t}static getState(e){var t;return null===(t=gL.get(e))||void 0===t?void 0:t.state}updateDevTools(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};_L(gL.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},e))}get state(){return this._state}set state(e){fL.call(this,e)}};gL.STATECHANGED="stateChanged",gL.UPDATEAFSM="updateAFSM",gL.INIT="[*]",gL.ON="on",gL.OFF="off",gL.instances=new Map,gL.instances2=new WeakMap;var EL=(null==window?void 0:window.requestIdleCallback)||function(e){let t=Date.now();return setTimeout((()=>{e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})}),1e3)},vL=(null==window?void 0:window.cancelIdleCallback)||function(e){clearTimeout(e)},yL=(null==window?void 0:window.cancelAnimationFrame)||(null==window?void 0:window.mozCancelAnimationFrame),TL=class{static generateTaskID(){return this.currentTaskID++}static run(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:xN,t=arguments.length>1?arguments[1]:void 0,i=arguments.length>2?arguments[2]:void 0;i=qb(e===MN?{delay:2e3,count:0,backgroundTask:!0}:e===LN?{delay:1e4,count:0}:e===PN?{fps:60,delay:16.6,count:0,backgroundTask:!0}:{delay:2e3,count:0,backgroundTask:!0},i),MD(t)&&(i=qb(qb({},i),t)),ND(e)&&(t=e,e=xN);let r=qb({taskID:this.generateTaskID(),loopCount:0,intervalID:null,timeoutID:null,rafID:null,ricID:null,taskName:e,callback:t},i);return this.taskMap.set(r.taskID,r),this[e](r),r.taskID}static interval(e){return e.intervalID=setInterval((()=>{e.callback(),e.loopCount+=1,this.isBreakLoop(e)}),e.delay)}static intervalInWorker(e){e.delay=(1e3/e.fps).toFixed(2);let t=new Worker(URL.createObjectURL(new Blob(["\n let timerID = null;\n self.onmessage = function (e) {\n if (e.data === 'start') {\n timerID = setInterval(() => {\n self.postMessage('tick');\n }, ".concat(e.delay,");\n } else if (e.data === 'stop') {\n clearInterval(timerID);\n }\n };\n ")])));t.onmessage=i=>{"tick"===i.data&&(e.callback(),e.loopCount+=1,this.isBreakLoop(e)&&t.postMessage("stop"))},e.worker=t,t.postMessage("start")}static timeout(e){let t=()=>{if(e.callback(),e.loopCount+=1,!this.isBreakLoop(e))return e.timeoutID=setTimeout(t,e.delay)};return e.timeoutID=setTimeout(t,e.delay)}static ric(e){let t,i=zD(),r=()=>{if(t=zD()-i,t>=e.delay&&(i=zD()-Math.floor(t%e.delay),e.callback(),e.loopCount+=1),!this.isBreakLoop(e))return e.ricID=EL(r,{timeout:e.delay})};return e.ricID=EL(r,{timeout:e.delay})}static raf(e){e.delay=(1e3/e.fps).toFixed(2);let t,i=zD(),r=()=>document.hidden&&e.backgroundTask?(t=zD()-i,i=zD(),e.callback(),e.loopCount+=1,this.isBreakLoop(e)?void 0:e.timeoutID=setTimeout(r,e.delay-Math.floor(t%e.delay))):(t=zD()-i,t>=e.delay&&(i=zD()-Math.floor(t%e.delay),e.callback(),e.loopCount+=1),this.isBreakLoop(e)?void 0:e.rafID=requestAnimationFrame(r));if(e.rafID=requestAnimationFrame(r),e.backgroundTask){let t=()=>{if(document.hidden){let t=zD()-i;t>=e.delay?r():e.timeoutID=setTimeout(r,e.delay-t)}};document.addEventListener("visibilitychange",t),e.onVisibilitychange=t,document.hidden&&t()}return e.taskID}static hasTask(e){return this.taskMap.has(e)}static clearTask(e){if(!this.taskMap.has(e))return!0;let{intervalID:t,timeoutID:i,rafID:r,ricID:n,onVisibilitychange:o,worker:s}=this.taskMap.get(e);return s&&s.terminate(),t&&clearInterval(t),i&&clearTimeout(i),r&&yL(r),n&&vL(n),o&&document.removeEventListener("visibilitychange",o),this.taskMap.delete(e),!0}static isBreakLoop(e){return!this.taskMap.has(e.taskID)||0!==e.count&&e.loopCount>=e.count&&(this.clearTask(e.taskID),!0)}};TL.taskMap=new Map,TL.currentTaskID=1;var SL=TL,IL={LOADED_DATA:Mw.LOADEDDATA,MEDIA_TRACK_CHANGED:"media-track-changed",PLAYER_STATE_CHANGED:"player-state-changed"},AL="trtc_autoplay",RL="".concat(AL,"_mask"),bL="".concat(AL,"_wrapper"),CL="".concat(AL,"_header"),kL="".concat(AL,"_content"),wL="".concat(AL,"_action_wrapper"),NL="".concat(AL,"_question"),DL="".concat(AL,"_collapse"),OL="".concat(AL,"_action_confirm"),LL="".concat(AL,"_detail"),PL="#2473E8",ML="dialog",xL="".concat(ML,"-show"),VL="".concat(ML,"-1"),UL="".concat(ML,"-2"),BL=!1,FL=()=>!!document.querySelector(".".concat(bL)),HL="".concat(vw,"/").concat(RD()?"zh-cn":"en","/tutorial-21-advanced-auto-play-policy.html"),jL="<br><a href='".concat(HL,"' target='_blank'>").concat(RD()?"其他方案?":"Any other solution?","</a>"),WL="".concat(RD()?"浏览器自动播放策略:在用户与页面产生交互(点击、触摸)之前,浏览器禁止播放有声媒体。该弹窗用于帮助用户恢复音视频播放。".concat(jL):"Autoplay Policy: Before user interacts with the web page (clicking, touching), page will not be allowed to play media with sound. This Dialog is used to help users resume playback. ".concat(jL)),zL=class{constructor(){if(tC(this,"content","音视频播放被浏览器拦截,请点击“恢复播放”。"),tC(this,"_dialogNode",null),tC(this,"_bodyPosition",""),tC(this,"_showDetail",!1),tC(this,"_isCollapseClicked",!1),tC(this,"_isQuestionClicked",!1),RD()||(this.content='Media playback failed. Click the "Resume" to resume playback.'),!BL){let e=document.createElement("style");e.innerHTML=".".concat(RL,"{position:fixed;top:0;left:0;right:0;bottom:0;width:100vw;height:100vh;display:flex;justify-content:center;align-items:center;background:rgba(0,0,0,0.5);z-index:1500;}.").concat(RL," div:not(.").concat(wL,"){display:block !important;}.").concat(bL,"{padding:14px;background:#fff;border-radius:3px;box-shadow:0px 3px 15px #434343;border:1px solid #d1cfcf;max-width:500px;}.").concat(bL," a{color:").concat(PL,";}.").concat(CL,"{overflow:hidden;text-overflow:ellipsis;font-size:16px;font-weight:600;}.").concat(kL,"{margin:8px 0;}.").concat(wL,"{width:100%;display:flex !important;align-items:center;justify-content:right;float:right;}.").concat(DL,"{margin-right:auto;cursor:pointer}.").concat(NL,"{height:100%;line-height:16px;cursor:pointer;}.").concat(OL,"{margin-left:8px;color:#fff;background:").concat(PL,";padding:4px 12px;outline:none;border:1px solid;border-radius:3px;font-weight:bold;}.").concat(OL,":hover{opacity:0.9;}.").concat(DL,",.").concat(OL,",.").concat(kL,",.").concat(NL,"{font-size:14px;}@media screen and (max-width:750px){.").concat(bL,"{width:80vw;}}"),document.head.appendChild(e),BL=!0}this.addDiaLog()}createDiaLog(){let e=document.createElement("template");e.innerHTML='<div class="'.concat(RL,"\"><div class='").concat(bL,"'><div class='").concat(CL,"'>").concat(location.host,"</div><div class='").concat(kL,"'>").concat(this.content,"</div><div class='").concat(LL,'\' style="visibility:hidden;width:100%;height:0;font-size:12px;color:gray;">').concat(WL,"</div><div class='").concat(wL,"'></div></div></div>").trim();let t=document.createElement("button");t.className=OL,t.innerText=RD()?"恢复播放":"Resume",t.onclick=this.onConfirm.bind(this);let i=document.createElement("div");i.className=NL,i.innerHTML='<?xml version="1.0" encoding="UTF-8"?>\n <svg class="icon" width="18" height="18" p-id="2030" t="1639646523624" version="1.1" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">\n <path d="m464 784.35c0 26.51 21.49 48 48 48s48-21.49 48-48-21.49-48-48-48-48 21.49-48 48z" p-id="2031"/>\n <path d="m512 960c-247.04 0-448-200.96-448-448s200.96-448 448-448 448 200.96 448 448-200.96 448-448 448zm0-831.71c-211.58 0-383.71 172.13-383.71 383.71 0 211.55 172.13 383.71 383.71 383.71 211.55 0 383.71-172.16 383.71-383.71 0-211.58-172.16-383.71-383.71-383.71z" p-id="2032"/>\n <path d="m512 673.7c-17.665 0-32.001-14.336-32.001-31.999v-54.112c0-52.353 40-92.352 75.328-127.65 25.887-25.92 52.672-52.672 52.672-74.017 0-53.343-43.072-96.735-95.999-96.735-53.823 0-95.999 41.536-95.999 94.559 0 17.665-14.336 31.999-32.001 31.999s-32.001-14.336-32.001-31.999c0-87.424 71.775-158.56 160-158.56s160 72.095 160 160.74c0 47.904-36.32 84.192-71.424 119.3-27.84 27.776-56.576 56.512-56.576 82.336v54.112c0 17.665-14.336 32.032-32.001 32.032z" p-id="2033"/>\n </svg>\n ',i.onclick=this.onQuestionClick.bind(this);let r=document.createElement("div");r.className=DL,r.innerText="".concat(RD()?"详情 >":"Detail >"),r.onclick=this.onCollapseClick.bind(this);let n=e.content.firstChild,o=n.querySelector(".".concat(wL));return o.appendChild(r),o.appendChild(i),o.appendChild(t),n}addDiaLog(){FL()||(this._dialogNode=this.createDiaLog(),document.body.appendChild(this._dialogNode),this._dialogNode.onclick=this.onConfirm.bind(this),this._dialogNode.querySelector(".".concat(bL)).onclick=e=>e.stopPropagation(),this._bodyPosition=document.body.style.position,document.body.style.position="fixed",EO.info("show autoplay dialog"),XN.uploadEvent({log:xL}))}deleteDiaLog(){this._dialogNode&&(document.body.removeChild(this._dialogNode),document.body.style.position=this._bodyPosition,this._dialogNode=null)}onConfirm(){EO.warn("confirm clicked, try resume stream"),JN.emit(fO.AUTOPLAY_DIALOG_CLICK_CONFIRM),this.deleteDiaLog()}onCollapseClick(){let e=this._dialogNode.querySelector(".".concat(LL));e.style.visibility="".concat(this._showDetail?"hidden":"visible"),e.style.height="".concat(this._showDetail?0:"fit-content"),this._showDetail=!this._showDetail,this._isCollapseClicked||XN.uploadEvent({log:VL}),this._isCollapseClicked=!0}onQuestionClick(){window.open(HL,"_blank"),this._isQuestionClicked||XN.uploadEvent({log:UL}),this._isQuestionClicked=!0}},GL={};Zb(GL,{create:()=>YL,remove:()=>JL});var KL=new WeakMap;function YL(e,t){KL.has(e)||KL.set(e,[]);let i=KL.get(e),r={add:(e,n)=>("addEventListener"in t?(i.push(t.removeEventListener.bind(t,e,n)),t.addEventListener(e,n)):(i.push(t.off.bind(t,e,n)),t.on(e,n)),r)};return r}function JL(e){let t=KL.get(e);t&&(t.forEach((e=>e())),KL.delete(e))}var qL=class extends gL{constructor(e,t){super(e.id,"".concat(t,"-player")),this.kind=t,tC(this,"id"),tC(this,"element",null),tC(this,"track"),tC(this,"url"),tC(this,"attr"),tC(this,"muted"),tC(this,"_log"),tC(this,"_pausedRetryCount"),tC(this,"_isElementPlayingFired",!1),tC(this,"_interval"),this.id=e.id,this._log=e.log,this.track=e.track,this.muted=e.muted,this._pausedRetryCount=RN,this._state="STOPPED",this.bindTrackEvents(),this._log.info("create ".concat(t,"-player ").concat(this.id))}get isPlaying(){return"PLAYING"===this._state}get isStopped(){return"STOPPED"===this._state}setAttr(e){this.attr=e}setUrl(e){this.track&&(this.unbindTrackEvents(),this.element&&(this.element.srcObject=null),this.track=null),e!==this.url&&(this.url=e,null!==e&&this.element&&(this.element.crossOrigin="anonymous",this.element.src=e))}play(){return rC(this,null,(function*(){if(!this.isPlaying)try{this.bindAutoPlayEvent(),yield this.element.play()}catch(e){let t=GN({key:HN.PLAY_FAILED,data:{media:this.kind,error:e}});if(this.track&&!this.track.muted&&this._log.warn(e),t.includes("NotAllowedError"))throw new fC({code:_C.PLAY_NOT_ALLOWED,message:t})}}))}stop(){this.unbindEvents(),this._isElementPlayingFired=!1,this.element&&(this.element.remove(),this.element.srcObject=null,this.element=null),this.handleStopped(Mw.ENDED),this._interval>0&&SL.clearTask(this._interval)}pause(){var e;this.isPlaying&&(null==(e=this.element)||e.pause())}resume(){return this.isPlaying?Promise.resolve():Kk?this.replay():this.play().catch((()=>{}))}setMuted(e){this.element&&(this.element.muted=e),this.muted=e}replay(){return this.stop(),this.play().catch((()=>{}))}bindElementEvents(){if(this.element){let e=this.handleElementEvent.bind(this);return YL(this.element,this.element).add(Mw.PLAYING,e).add(Mw.ENDED,e).add(Mw.PAUSE,e).add(Mw.ERROR,e).add(Mw.LOADEDDATA,e)}}bindTrackEvents(){if(this.track){let e=this.handleTrackEvent.bind(this);null==GL||GL.create(this.track,this.track).add(Mw.ENDED,e).add(Mw.MUTE,e).add(Mw.UNMUTE,e),this.track.readyState===Mw.ENDED&&this.handleTrackEvent({type:Mw.ENDED}),this.track.muted&&this.handleTrackEvent({type:Mw.MUTE})}}bindAutoPlayEvent(){JN.on(fO.AUTOPLAY_DIALOG_CLICK_CONFIRM,this.resume,this)}unbindTrackEvents(){this.track&&JL(this.track)}unbindEvents(){this.element&&JL(this.element),this.unbindTrackEvents(),JN.off(fO.AUTOPLAY_DIALOG_CLICK_CONFIRM,this.resume,this)}handleElementEvent(e){var t;switch(e.type){case Mw.PLAYING:this._isElementPlayingFired=!0,this._log.info("".concat(this.kind," player is playing")),this.handlePlaying(Mw.PLAYING),this._interval&&(SL.clearTask(this._interval),this._interval=-1);break;case Mw.ENDED:this._log.info("".concat(this.kind," player is ended")),this.handleStopped(Mw.ENDED);break;case Mw.PAUSE:this._log.info("".concat(this.kind," player is paused")),this.handlePaused(Mw.PAUSE);let e=this.container&&document.getElementById(this.container.id);e||this._log.warn("".concat(this.kind," player has been remove, element ID: ").concat(null==(t=this.container)?void 0:t.id));let i=Lk();this._pausedRetryCount>0&&(this.kind===Mw.VIDEO&&!FL()||this.kind===Mw.AUDIO&&(LD(i)&&i<=70||!e))&&(this._log.info("".concat(this.kind," player auto resume when paused")),this.resume(),this._pausedRetryCount--),PC&&(this._interval=SL.run(xN,(()=>{this.element&&"PAUSED"===this._state&&this.resume()}),{delay:3e3}));break;case Mw.ERROR:if(this.element&&this.element.error){let{code:e,message:t}=this.element.error;this._log.error("".concat(this.kind," player error observed. code: ").concat(e," message: ").concat(t," userAgent: ").concat(navigator.userAgent)),XN.uploadEvent({log:"stat-".concat(this.kind,"-").concat(lN.PLAYER_ERROR,"-").concat(e,"-").concat(navigator.userAgent),error:this.element.error})}break;case Mw.LOADEDDATA:this.kind===Mw.VIDEO&&this.emit(IL.LOADED_DATA)}}handleTrackEvent(e){switch(e.type){case Mw.ENDED:this._log.info("".concat(this.kind," track is ended")),this.handleStopped(Mw.ENDED);break;case Mw.MUTE:this._log.info("".concat(this.kind," track is unable to provide media output")),this.handlePaused(Mw.MUTE);break;case Mw.UNMUTE:this._log.info("".concat(this.kind," track is able to provide media output")),this._isElementPlayingFired&&this.handlePlaying(Mw.UNMUTE)}}handlePlaying(e){this.emit(IL.PLAYER_STATE_CHANGED,{type:this.kind,state:"PLAYING",reason:e})}handlePaused(e){this.emit(IL.PLAYER_STATE_CHANGED,{type:this.kind,state:"PAUSED",reason:e})}handleStopped(e){this.emit(IL.PLAYER_STATE_CHANGED,{type:this.kind,state:"STOPPED",reason:e})}getElement(){return this.element}};eC([mL([],"PLAYING",{sync:!0})],qL.prototype,"handlePlaying",1),eC([mL("PLAYING","PAUSED",{ignoreError:!0,sync:!0})],qL.prototype,"handlePaused",1),eC([mL([],"STOPPED",{sync:!0})],qL.prototype,"handleStopped",1);var XL=class extends qL{constructor(e){super(e,Mw.VIDEO),tC(this,"viewMirror",!1),tC(this,"objectFit"),tC(this,"container"),tC(this,"canvas"),this.container=e.container,this.canvas=e.canvas,DD(e.viewMirror)||(this.viewMirror=e.viewMirror),DD(e.objectFit)||(this.objectFit=e.objectFit),this.initializeElement()}initializeElement(){var e;let t=document.createElement(Mw.VIDEO);this.track&&(t.srcObject=new MediaStream([this.track])),t.muted=!0,t.setAttribute("id","video_".concat(this.id)),t.setAttribute("style",this.styleAttribute),this.canvas&&this.canvas.setAttribute("style",this.styleAttribute),t.setAttribute("autoplay","autoplay"),t.setAttribute("playsinline","playsinline"),this.element=t,null==(e=this.container)||e.appendChild(this.elementToRender),this.bindElementEvents()}get styleAttribute(){let e="width: 100%; height: 100%; object-fit: ".concat(this.objectFit,";background-color: black;");return this.viewMirror&&(e+="transform: scaleX(-1);"),e}setContainer(e){var t;this.container=e,this.track&&this.elementToRender&&(null==(t=this.container)||t.appendChild(this.elementToRender))}bindElementEvents(){let e=super.bindElementEvents();this.handleElementEvent=this.handleElementEvent.bind(this),e&&e.add(Mw.ENTER_PICTURE_IN_PICTURE,this.handleElementEvent).add(Mw.LEAVE_PICTURE_IN_PICTURE,this.handleElementEvent)}handleElementEvent(e){super.handleElementEvent(e);let t=e.type;if(this.viewMirror&&this.element){let e=this.element.style.transform;t===Mw.ENTER_PICTURE_IN_PICTURE?this.element.style.transform=e.replace("scaleX(-1)",""):t===Mw.LEAVE_PICTURE_IN_PICTURE&&!e.includes("scaleX")&&(this.element.style.transform="".concat(e," scaleX(-1)"))}}setCanvas(e){var t,i;this.canvas!==e&&(null==(t=this.canvas)||t.remove(),null==e||e.setAttribute("style",this.styleAttribute),this.canvas=e,e&&(null==(i=this.container)||i.appendChild(e)))}setAttr(e){let t=Object.assign({autoplay:"autoplay",playsinline:"playsinline",muted:!0},e);t.style=Object.assign({width:"100%",height:"100%"},t.style),super.setAttr(t)}get mirror(){return this.viewMirror}setRect(e,t){this.elementToRender&&(this.elementToRender.style.width="".concat(e,"px"),this.elementToRender.style.height="".concat(t,"px"))}setViewMirror(e){this.elementToRender&&(this.elementToRender.style.transform=e?"scaleX(-1)":""),this.viewMirror=e}setObjectFit(e){this.elementToRender&&(this.elementToRender.style.objectFit="".concat(e)),this.objectFit=e}stop(){var e;this.setContainer(null),super.stop(),null==(e=this.canvas)||e.remove()}play(){return this.element?this.elementToRender&&this.elementToRender.parentElement!==this.container&&this.container&&this.container.append(this.elementToRender):this.initializeElement(),super.play()}get elementToRender(){return this.canvas||this.element}setTrack(e){e!==this.track&&(this.unbindTrackEvents(),this.track=e,this.emit(IL.MEDIA_TRACK_CHANGED,e),null!==e&&(this.bindTrackEvents(),this.element&&(this.element.srcObject=new MediaStream([e]),this.element.remove()),this.elementToRender&&this.elementToRender.parentElement!==this.container&&this.container&&this.container.append(this.elementToRender)))}getVideoFrame(){if(this.canvas)return this.canvas.toDataURL("image/png");if(!this.element)return"";let e=document.createElement("canvas");return e.width=this.element.videoWidth,e.height=this.element.videoHeight,e.getContext("2d").drawImage(this.element,0,0),e.toDataURL("image/png")}getElement(){return this.element}};function QL(e,t){return rC(this,null,(function*(){if(!e.audioWorklet)return Promise.reject("audioWorklet is not supported");try{yield e.audioWorklet.addModule(t),EO.info("worklet addModule success")}catch(i){throw EO.info("worklet addModule catch error. ".concat(i.message)),i}}))}"undefined"!=typeof window&&(window.AudioContext=window.AudioContext||window.webkitAudioContext||window.mozAudioContext);var ZL=new window.AudioContext({sampleRate:48e3}),$L=()=>{"suspended"===ZL.state?(ZL.resume(),document.addEventListener("click",$L)):"interrupted"===ZL.state?ZL.resume():document.removeEventListener("click",$L)};document.addEventListener("click",$L),ZL.onstatechange=()=>{EO.info("context state: ".concat(ZL.state)),$L()};var eP,tP,iP,rP=e=>ZL,nP=class{constructor(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.countMap=new Map,this.distributionMap=new Map,this.log=EO.createLogger({id:"kv"}),e&&(JN.on("102",(e=>{let{track:t,cost:i}=e;this.addSuccessEvent({key:t.kind===Mw.AUDIO?lP.START_MICROPHONE:dP.START_CAMERA,cost:i})})),JN.on("103",(e=>{let{track:t,error:i}=e;this.addFailedEvent({key:t.kind===Mw.AUDIO?lP.START_MICROPHONE:dP.START_CAMERA,error:i})})))}getReportData(){let e={msg_sdk_basic_info:{uint32_sdk_version:uO(this.version||ow),uint32_terminal_type:15,bytes_device_name:"",bytes_os_version:"",uint32_framework:30,uint32_network_type:0},stats_count:[...this.countMap.entries()].map((e=>{let[t,i]=e;return{uint32_key:t,uint32_count:i}})),stats_distribution:[...this.distributionMap.entries()].map((e=>{let[t,i]=e;return{uint32_key:t,distribution_items:[...i.entries()].map((e=>{let[t,i]=e;return{uint32_item_key:t,uint32_item_value:i}}))}}))};return this.countMap.clear(),this.distributionMap.clear(),e}clear(){this.countMap.clear(),this.distributionMap.clear()}isEnumKey(e){let t=+String(e).slice(-3);return t>=700&&t<799}isErrorCodeKey(e){let t=+String(e).slice(-3);return t>=600&&t<699}isCountKey(e){let t=+String(e).slice(-3);return t>=0&&t<599}isNumberKey(e){let t=+String(e).slice(-3);return t>=800&&t<899}addCount(e){let{key:t,useUV:i=!1}=e;this.isCountKey(t)?i&&this.countMap.has(t)||this.countMap.set(t,(this.countMap.get(t)||0)+1):this.log.debug("".concat(t," is not count key, last 3 number should be 0~599"))}addEnum(e){let{key:t,value:i,useUV:r=!0}=e;var n;if(!this.isEnumKey(t))return this.log.debug("".concat(t," is not enum key, last 3 number should be 700~799"));if(r&&this.countMap.has(t))return;this.countMap.set(t,(this.countMap.get(t)||0)+1);let o=(null==(n=this.distributionMap)?void 0:n.get(t))||new Map;o.set(i,(o.get(i)||0)+1),this.distributionMap.set(t,o)}addNumber(e){let{key:t,value:i,split:r=100,useUV:n=!1}=e;var o;if(!this.isNumberKey(t))return this.log.debug("".concat(t," is not number key, last 3 number should be 800~899"));if(n&&this.countMap.has(t))return;this.countMap.set(t,(this.countMap.get(t)||0)+1);let s=(null==(o=this.distributionMap)?void 0:o.get(t))||new Map,a=0;if(LD(r))a=Math.floor(i/r);else for(let c=r.length-1;c>0;c--)if(i>r[c]){a=c;break}s.set(a,(s.get(a)||0)+1),this.distributionMap.set(t,s)}addSuccessEvent(e){let{key:t,cost:i,timeKey:r,split:n}=e;if(t&&(this.addEnum({key:t,value:1,useUV:!1}),i)){let e=+String(t).slice(-3);e<800&&e>=700?this.addNumber({key:r||t+100,value:i,split:n}):r||this.log.debug("time stat ignored, ".concat(t))}}addFailedEvent(e){let{key:t,error:i}=e;if(!t)return;let r=_C.UNKNOWN;LD(i)?r=i:(!DD(i.extraCode)||!DD(i.code))&&(r=i.extraCode||i.code),this.addEnum({key:t,value:0,useUV:!1}),this.addEnum({key:t,value:r,useUV:!1})}},oP=((tP=oP||{})[tP.enterRoom=500700]="enterRoom",tP[tP.exitRoom=500701]="exitRoom",tP[tP.switchRole=500702]="switchRole",tP[tP.destroy=500703]="destroy",tP[tP.startLocalAudio=500704]="startLocalAudio",tP[tP.updateLocalAudio=500705]="updateLocalAudio",tP[tP.stopLocalAudio=500706]="stopLocalAudio",tP[tP.startLocalVideo=500707]="startLocalVideo",tP[tP.updateLocalVideo=500708]="updateLocalVideo",tP[tP.stopLocalVideo=500709]="stopLocalVideo",tP[tP.startScreenShare=500710]="startScreenShare",tP[tP.updateScreenShare=500711]="updateScreenShare",tP[tP.stopScreenShare=500712]="stopScreenShare",tP[tP.startRemoteVideo=500713]="startRemoteVideo",tP[tP.updateRemoteVideo=500714]="updateRemoteVideo",tP[tP.stopRemoteVideo=500715]="stopRemoteVideo",tP[tP.muteRemoteAudio=500716]="muteRemoteAudio",tP[tP.setRemoteAudioVolume=500717]="setRemoteAudioVolume",tP),sP=((eP=sP||{})[eP.AudioMixer=550700]="AudioMixer",eP[eP.AIDenoiser=551700]="AIDenoiser",eP[eP.VirtualBackground=570700]="VirtualBackground",eP[eP.Beauty=571700]="Beauty",eP[eP.Watermark=572700]="Watermark",eP),aP=(e=>(e[e.AudioMixer=550701]="AudioMixer",e[e.AIDenoiser=551701]="AIDenoiser",e[e.VirtualBackground=570701]="VirtualBackground",e[e.Beauty=571701]="Beauty",e[e.Watermark=572701]="Watermark",e))(aP||{}),cP=(e=>(e[e.AudioMixer=550702]="AudioMixer",e[e.AIDenoiser=551702]="AIDenoiser",e[e.VirtualBackground=570702]="VirtualBackground",e[e.Beauty=571702]="Beauty",e[e.Watermark=572702]="Watermark",e))(cP||{}),lP=(e=>(e[e.START_MICROPHONE=501700]="START_MICROPHONE",e[e.MICROPHONE_CAHNNELS=501701]="MICROPHONE_CAHNNELS",e[e.MICROPHONE_SAMPLERATE=501702]="MICROPHONE_SAMPLERATE",e))(lP||{}),dP=((iP=dP||{})[iP.START_CAMERA=511700]="START_CAMERA",iP),uP=new nP(!0),hP=new nP(!1),pP=uP,mP=class{constructor(){this.pre=new Set,this.next=new Set,this.connectedNodes=new Set}setContext(e){this.context=e,this.node&&e.addMixWeight()}removeContext(){var e;this.node&&(null==(e=this.context)||e.reduceMixWeight()),delete this.context}setNode(e){var t;if(!this.node)try{null==(t=this.context)||t.addMixWeight(),this.node=e,this.preNodeReconnect(),this.reconnect(),pP.addSuccessEvent({key:502701})}catch(i){EO.error(i),pP.addFailedEvent({key:502701,error:i})}}deleteNode(){var e;if(this.node)try{this._disconnect(),delete this.node,null==(e=this.context)||e.reduceMixWeight(),this.preNodeReconnect(),pP.addSuccessEvent({key:502702})}catch(t){EO.error(t),pP.addFailedEvent({key:502702,error:t})}}preNodeReconnect(){this.pre.forEach((e=>{e.node?e.reconnect():e.preNodeReconnect()}))}connectNext(e){this.next.forEach((t=>e._connect(t.node)||t.connectNext(e)))}_connect(e){return!(!this.node||!e||(this.node.connect(e),this.connectedNodes.add(e),0))}_disconnect(){this.connectedNodes.forEach((e=>{var t;return null==(t=this.node)?void 0:t.disconnect(e)})),this.connectedNodes.clear()}reconnect(){this._disconnect(),this.connectNext(this)}pipeTo(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return t.forEach((e=>{this.next.add(e),e.pre.add(this)})),this}},_P=class extends mP{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:256;super(),this.fftSize=e,this.dataArray=new Uint8Array(0)}setNode(e){e.fftSize=this.fftSize,this.dataArray=new Uint8Array(e.frequencyBinCount),super.setNode(e)}getByteTimeDomainData(){var e;return null==(e=this.node)||e.getByteTimeDomainData(this.dataArray),this.dataArray}get level(){var e;return null==(e=this.node)||e.getByteTimeDomainData(this.dataArray),Math.max(...this.dataArray)/128-1}get timeDomainPathData(){let e=this.getByteTimeDomainData(),t=0,i=0,r="M".concat(t,",").concat(i);for(let n=0;n<e.length;n++)i=e[n]/128*100/2,r+="L".concat(t,",").concat(i),t+=1;return r}},fP=class{constructor(){this.source=new mP,this.gain=new mP,this.destination=new mP}get volume(){var e;return(null==(e=this.gain.node)?void 0:e.gain.value)||1}setVolume(e){1!==e?(this.gain.node||this.gain.setNode(this.source.node.context.createGain()),this.gain.node.gain.value=e):this.gain.node&&this.gain.deleteNode()}replaceSource(e){this.source.deleteNode(),this.source.setNode(function(e){let t=vP.get(e);if(t)return t;let i=rP();if(e instanceof HTMLAudioElement)t=i.createMediaElementSource(e);else{if(!(e instanceof MediaStreamTrack))return e;t=i.createMediaStreamSource(new MediaStream([e]))}return vP.set(e,t),t}(e))}get track(){var e;return null==(e=this.stream)?void 0:e.getAudioTracks()[0]}get stream(){var e;return null==(e=this.destination.node)?void 0:e.stream}},gP=class extends fP{constructor(e){super(),this.context=e,this.denoiser=new mP,this.source.pipeTo(this.denoiser.pipeTo(this.gain.pipeTo(this.destination)))}connect(){this.context.inputs.has(this)||(this.destination.setNode(this.context.destination),this.source.setContext(this.context),this.denoiser.setContext(this.context),this.gain.setContext(this.context),this.context.inputs.add(this))}disconnect(){!this.context.inputs.has(this)||(this.destination.deleteNode(),this.source.removeContext(),this.denoiser.removeContext(),this.gain.removeContext(),this.context.inputs.delete(this))}remove(){this.gain.deleteNode(),this.denoiser.deleteNode(),this.source.deleteNode(),this.disconnect()}setVolume(e){1!==e?(this.gain.node||this.gain.setNode(this.context.audioContext.createGain()),this.gain.node.gain.value=e):this.gain.node&&this.gain.deleteNode()}},EP=class{constructor(){this.audioContext=rP(),this.destination=this.audioContext.createMediaStreamDestination(),this.inputs=new Set,this.mixWeight=0,this.destination.channelCount=1}addMixWeight(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this.mixWeight+=e,this.mixWeight-1==e+1>>1&&this.mixOnChange()}reduceMixWeight(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this.addMixWeight(-e)}close(){this.inputs.forEach((e=>e.remove()))}get mixTrack(){return this.destination.stream.getAudioTracks()[0]}},vP=new WeakMap,yP=class{constructor(e){tC(this,"_volume",0),tC(this,"_log"),tC(this,"_scriptProcessorNode",null),tC(this,"_audioWorkletNode",null),tC(this,"_interval",200),tC(this,"ready",this.preload());let{log:t}=e;this._log=t,JN.on(fO.AUDIO_LEVEL_INTERVAL,this.handleAudioLevelInterval,this)}get node(){return this._audioWorkletNode||this._scriptProcessorNode}preload(){return yP.workletReady||(yP.workletReady=QL(yP.audioContext,URL.createObjectURL(new Blob(['class VolumeMeter extends AudioWorkletProcessor{constructor(){super(),this.volume=0,this.intervalTime=200,this.tick=this.intervalTime,this.isStop=!1,this.port.onmessage=t=>{let{data:e}=t;switch(e.name){case"setIntervalTime":this.intervalTime=e.intervalTime;break;case"stop":this.isStop=!0}}}process(t){let e=t[0];if(this.isStop)return!1;if(e.length>0){let i=e[0],s=0;for(let l=0;l<i.length;++l)s=Math.max(Math.abs(i[l]),s);this.volume=s,this.tick-=i.length,this.tick<0&&(this.tick+=this.intervalTime/1e3*sampleRate,this.port.postMessage({volume:this.volume}))}return!0}}registerProcessor("volume-meter",VolumeMeter);'],{type:"application/javascript"})))),yP.workletReady.then((()=>this.initAudioWorklet())).catch((()=>this.initScriptProcessor()))}initAudioWorklet(){if(!this._audioWorkletNode)try{this._audioWorkletNode=new AudioWorkletNode(yP.audioContext,"volume-meter"),this._audioWorkletNode.port.onmessage=e=>{this._volume=e.data.volume||0},this.handleAudioLevelInterval({interval:this._interval})}catch(e){XN.logFailedEvent({userId:this._log.userId,eventType:lN.LOAD_WORKLET,error:e}),this.initScriptProcessor()}}initScriptProcessor(){if(!this._scriptProcessorNode)try{this._scriptProcessorNode=rP().createScriptProcessor(2048,1,1),this._scriptProcessorNode.onaudioprocess=e=>{let t=e.inputBuffer.getChannelData(0),i=0;for(let r=0;r<t.length;++r)i+=t[r]*t[r];this._volume=Math.sqrt(i/t.length)||0}}catch(e){this._log.error("volumeMeter init script processor error: ".concat(e))}}destroy(){this._scriptProcessorNode&&(this._scriptProcessorNode.onaudioprocess=null),this._audioWorkletNode&&(this._audioWorkletNode.port.postMessage({name:"stop"}),this._audioWorkletNode.port.onmessage=null),this._audioWorkletNode=null,this._scriptProcessorNode=null,JN.off(fO.AUDIO_LEVEL_INTERVAL,this.handleAudioLevelInterval,this)}getInternalAudioLevel(){return this._volume}getCalculatedVolume(){return parseFloat(this._volume.toFixed(2))}handleAudioLevelInterval(e){var t;let{interval:i}=e;this._interval=i,null==(t=this._audioWorkletNode)||t.port.postMessage({name:"setIntervalTime",intervalTime:i})}},TP=yP;tC(TP,"audioContext",rP()),tC(TP,"workletReady");var SP=class extends mP{constructor(e){super(),tC(this,"_volumeMeter"),this._volumeMeter=new TP(e)}deleteNode(){this._volumeMeter.destroy(),super.deleteNode()}init(){return rC(this,null,(function*(){yield this._volumeMeter.preload(),this.setNode(this._volumeMeter.node)}))}getCalculatedVolume(){return this._volumeMeter.getCalculatedVolume()}getInternalAudioLevel(){return this._volumeMeter.getInternalAudioLevel()}},IP=class extends fP{constructor(e){super(),this.log=e,tC(this,"volumeMeter"),tC(this,"analyser",new _P),this.volumeMeter=new SP({log:this.log})}destory(){this.gain.deleteNode(),this.volumeMeter.deleteNode(),this.analyser.deleteNode(),this.source.deleteNode(),this.destination.deleteNode()}},AP=class extends qL{constructor(e){super(e,Mw.AUDIO),tC(this,"_outputDeviceId"),tC(this,"_volume",1),tC(this,"_destination",rP().createMediaStreamDestination()),tC(this,"pipeline"),tC(this,"volumeMeterMode","worklet"),this.pipeline=new IP(this._log)}getMediaStream(){return this.pipeline.stream||(this.track?new MediaStream([this.track]):null)}initializeElement(){if(("15.2"===Wk||"15.3"===Wk||"15.4"===Wk)&&this.muted)return void this._log.info("audioElement is muted.");let e=new Audio;e.setAttribute("autoplay","autoplay"),e.srcObject=this.getMediaStream(),e.muted=this.muted,this.element=e,this.bindElementEvents()}play(){return rC(this,null,(function*(){if(this.track)return this.pipeline.source.node||this.pipeline.replaceSource(this.track),this.element||this.initializeElement(),this._outputDeviceId&&(yield this.setSinkId(this._outputDeviceId)),"worklet"===this.volumeMeterMode?this.pipeline.volumeMeter.init():"analyser"===this.volumeMeterMode&&this.pipeline.analyser.setNode(rP().createAnalyser()),this.setVolume(this._volume),iC(AP.prototype,this,"play").call(this)}))}stop(){this.pipeline.destory(),super.stop()}setSinkId(e){return rC(this,null,(function*(){var t,i;this._outputDeviceId!==e&&(this._outputDeviceId=e),this.element&&this.element.sinkId!==e&&(yield null==(i=(t=this.element).setSinkId)?void 0:i.call(t,e))}))}get useDestination(){return!!this.pipeline.stream}setLoop(e){!this.element||(this.element.loop=e)}getAudioLevel(){return this.pipeline.volumeMeter.getCalculatedVolume()}getInternalAudioLevel(){return this.pipeline.volumeMeter.getInternalAudioLevel()}},RP=class extends AP{constructor(e){super(e),this.pipeline.source.pipeTo(this.pipeline.volumeMeter,this.pipeline.destination)}setTrack(e){this.track!==e&&(this.unbindTrackEvents(),this.track=e,this.emit(IL.MEDIA_TRACK_CHANGED,e),e?(this.bindTrackEvents(),this.pipeline.replaceSource(e),!this.useDestination&&this.element&&(this.element.srcObject=new MediaStream([e]))):this.pipeline.source.deleteNode())}setSourceNode(e){!e||this.pipeline.source.node===e||(this.pipeline.replaceSource(e),e instanceof MediaStreamAudioSourceNode?this.pipeline.destination.setNode(this._destination):this.pipeline.destination.deleteNode(),this.element&&(this.element.srcObject=this.getMediaStream(),this.element.play().catch((()=>{})),this.setVolume(this._volume)))}setVolume(e){this._volume=e,this.element&&(this.element.volume=e)}},bP=class extends AP{constructor(e){super(e),tC(this,"_sourceElement"),this.pipeline.source.pipeTo(this.pipeline.gain.pipeTo(this.pipeline.volumeMeter,this.pipeline.destination))}setTrack(e){this.track!==e&&(this.unbindTrackEvents(),this.track=e,this.emit(IL.MEDIA_TRACK_CHANGED,e),e?(this.bindTrackEvents(),this._sourceElement?this._sourceElement.srcObject=new MediaStream([e]):!this.useDestination&&this.element&&(this.element.srcObject=new MediaStream([e])),this.pipeline.replaceSource(e)):this.pipeline.source.deleteNode())}setVolume(e){this._volume=e,this.useDestination?(this.pipeline.setVolume(e),this._log.info("set pipeline volume: ".concat(e))):e<=1?(this.element?this._log.info("set element volume: ".concat(e)):this._log.info("set element volume: no element"),this.element&&(this.element.volume=e)):(this._log.info("start set pipeline volume: ".concat(e)),this.pipeline.setVolume(e),this.element&&!this._sourceElement&&(this.pipeline.destination.setNode(this._destination),JL(this.element),this._sourceElement=this.element,this._sourceElement.muted=!0,this.element=null,this.play()))}stop(){this.pipeline.destory(),this._sourceElement&&(this._sourceElement.srcObject=null,delete this._sourceElement),super.stop()}},CP=class extends gL{constructor(e){let{userId:t,sdkAppId:i,mediaType:r,room:n,PlayerClass:o=(1===r?bP:XL)}=e;var s;super(),tC(this,"id",vO()),tC(this,"userId",""),tC(this,"isRemote"),tC(this,"mediaType"),tC(this,"room"),tC(this,"user"),tC(this,"_log"),tC(this,"_inputTrack"),tC(this,"_outputTrack"),tC(this,"isPlayCalled"),tC(this,"container",null),tC(this,"player"),tC(this,"subVideoPlayerMap"),tC(this,"muted",!1),tC(this,"abortCtrl"),tC(this,"objectFit","cover"),tC(this,"mirror"),tC(this,"isScreen",!1),tC(this,"manager"),tC(this,"trackSettings"),this.userId=t||"",this.mediaType=r,this._log=EO.createLogger({id:"".concat(this.kind[0],"t"),userId:null==(s=n||this.room)?void 0:s.userId,remoteUserId:this instanceof eM?void 0:this.userId,sdkAppId:i,type:2===this.mediaType?"auxiliary":"main",isLocal:this instanceof eM}),this.player=new o({track:null,muted:!1,container:null,id:this.userId||this.id,log:this.log}),this.player.on(IL.PLAYER_STATE_CHANGED,(e=>{JN.emit(fO.PLAYER_STATE_CHANGED,qb({track:this},e)),this.emit("player-state-changed",e)})),this.kind===Mw.VIDEO&&(this.player.on(IL.LOADED_DATA,(()=>{JN.emit(fO.VIDEO_LOADED_DATA,{track:this})})),this.player.on(IL.MEDIA_TRACK_CHANGED,(e=>{var t;null==(t=this.subVideoPlayerMap)||t.forEach((t=>t.setTrack(e)))})))}get log(){return this._log||EO}get kind(){return 1===this.mediaType?Mw.AUDIO:Mw.VIDEO}get strMediaType(){return 4===this.mediaType?Mw.VIDEO:2===this.mediaType?Mw.SCREEN:Mw.AUDIO}get streamType(){return 2&this.mediaType?"auxiliary":"main"}play(e,t){return rC(this,null,(function*(){let i=xD(e)?e[0]:e;if(this.isPlayCalled)return this.log.info("play update options: ".concat(JSON.stringify(t))),t&&!DD(t.muted)&&this.setPlayerMute(t.muted),t&&!DD(t.objectFit)&&(this.objectFit=t.objectFit),void(this.player instanceof XL&&(this.player.setObjectFit(this.objectFit),this.container!==i&&i&&(this.container=i,this.player.setContainer(i)),xD(e)&&e.length>=1&&(yield this.playSubContainer(e.slice(1),t))));if(t&&!DD(t.muted)?this.setPlayerMute(t.muted):(!this.isRemote||this.kind===Mw.VIDEO)&&this.setPlayerMute(!0),t&&!DD(t.objectFit)&&(this.objectFit=t.objectFit),this.kind===Mw.VIDEO&&this.player.setObjectFit(this.objectFit),this.isPlayCalled=!0,i&&(this.container=i,this.player instanceof XL&&this.player.setContainer(i)),JN.emit(fO.PLAY_TRACK_START,{track:this}),this._outputTrack){this._log.info("play with options: ".concat(JSON.stringify(t)));try{this.player.setTrack(this.playerMediaTrack),yield this.player.play(),xD(e)&&e.length>1&&(yield this.playSubContainer(e.slice(1),t))}catch(r){throw this.handleAutoPlayFailed(),this.emit("error",r),r}}else this.log.info("play has not mediaTrack, abort")}))}setMirror(e,t){if(this.isScreen||this.kind!==Mw.VIDEO||DD(e)||e===this.mirror)return;this.mirror=e;let i=this.player;if(t&&(i=t),PD(this.mirror))return i.setViewMirror(this.mirror),void(this.room&&(this.room.videoManager.mirror=!1));switch(this.mirror){case"view":this.room&&(this.room.videoManager.mirror=!1),i.setViewMirror(!0);break;case"publish":this.room&&(this.room.videoManager.mirror=!0),i.setViewMirror(!0);break;case"both":this.room&&(this.room.videoManager.mirror=!0),i.setViewMirror(!1)}}playSubContainer(e,t){return rC(this,null,(function*(){if(!this._outputTrack||this.kind===Mw.AUDIO)return;this.subVideoPlayerMap||(this.subVideoPlayerMap=new Map),this.subVideoPlayerMap.forEach(((t,i)=>{var r;e.find((e=>i===e))||(t.stop(),null==(r=this.subVideoPlayerMap)||r.delete(i))}));for(let[r,n]of e.entries()){let e=this.subVideoPlayerMap.get(n);e?t&&(DD(t.objectFit)||e.setObjectFit(t.objectFit)):this.subVideoPlayerMap.set(n,new XL({id:this.userId||this.id,track:this.playerMediaTrack,container:n,muted:this.player.muted,objectFit:this.objectFit,log:this.log.createChild({id:"vp-sub".concat(r+1)})}))}let i=[...this.subVideoPlayerMap.values()];for(let e of i)e.setViewMirror(this.player.mirror),yield e.play()}))}setAudioOutput(e){return this.player.setSinkId(e)}setAudioVolume(e){this.player.setVolume(e)}getAudioLevel(){return this.player.getAudioLevel()||0}getInternalAudioLevel(){var e;return(null==(e=this.player)?void 0:e.getInternalAudioLevel())||0}stop(){!this.isPlayCalled||(this.isPlayCalled=!1,this.player&&(this.log.info("stop ".concat(this.kind," player")),this.player.stop()),this.subVideoPlayerMap&&this.subVideoPlayerMap.size>0&&this.subVideoPlayerMap.forEach((e=>{e.stop()})),this.container=null)}resume(){return rC(this,null,(function*(){var e;!this.isPlayCalled||(yield null==(e=this.player)?void 0:e.resume())}))}close(){this.log.info("close"),this.isPlayCalled&&this.stop()}setMute(e){this.muted=e,this._inputTrack&&(this._inputTrack.enabled=!e),this._outputTrack&&(this._outputTrack.enabled=!e),this.emit(e?"mute":"unmute",this),JN.emit(e?fO.TRACK_MUTED:fO.TRACK_UNMUTED,{track:this})}setPlayerMute(e){this.player.setMuted(e)}get mediaTrack(){return this._inputTrack||null}get outMediaTrack(){return this._outputTrack||null}get playerMediaTrack(){return this.outMediaTrack}setInputMediaStreamTrack(e){var t;let i=this._inputTrack;if(e!==i)return this._inputTrack=e,this.trackSettings=null==(t=e.getSettings)?void 0:t.call(e),e.enabled=!this.muted,this.emit("input-media-track-changed",e||null,i||null),this.manager?this.manager.changeInput(this):this.setOutputMediaStreamTrack(e)}setOutputMediaStreamTrack(e){var t;e!==this._outputTrack&&(this.isRemote?this.log.debug("setOutputMediaStreamTrack",e.label):this.log.info("setOutputMediaStreamTrack",null==(t=e.getSettings)?void 0:t.call(e).deviceId,e.label),this._outputTrack=e,this.updatePlayingState(!!e),this.emit("output-media-track-changed",e))}setMediaType(e){this.mediaType=e}updatePlayingState(e){if(this.isPlayCalled)if(e){if(this.player.setTrack(this.playerMediaTrack),this.player.isStopped)return this.player.play().catch((()=>this.handleAutoPlayFailed())),void this.log.info("playing state updated, play ".concat(this.kind))}else if(!this.player.isStopped)return this.player.stop(),void this.log.info("playing state updated, stop ".concat(this.kind));this.log.debug("updatePlayingState abort ".concat(this.isPlayCalled," ").concat(e," ").concat(this.player.isStopped))}handleAutoPlayFailed(){if(this.room&&this.room.enableAutoPlayDialog)new zL;else{let e=()=>{this.resume().then((()=>{document.removeEventListener("click",e,!0),document.removeEventListener("touchstart",e,!0)}))};document.addEventListener("click",e,!0),document.addEventListener("touchstart",e,!0)}}getVideoFrame(){return this.kind===Mw.VIDEO?this.player.getVideoFrame():""}};eC([mL([],gL.INIT,{sync:!0})],CP.prototype,"close",1);var kP=Object.prototype.hasOwnProperty,wP=function(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e||"function"==typeof e||Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(bD(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(let t in e)if(kP.call(e,t))return!1;return!0}return!1},NP=$b(nC(),1),DP=e=>t=>t.deviceId===e,OP=class{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Input";tC(this,"kind"),tC(this,"type"),tC(this,"devices",[]),this.kind=e,this.type=t}update(e,t){let i=e.filter((e=>e.kind==="".concat(this.kind).concat(this.type.toLocaleLowerCase())));1===this.devices.length&&MP(this.devices[0])||t&&(i.forEach((e=>{if(e.deviceId&&!this.devices.find(DP(e.deviceId))){let i="".concat(this.kind).concat(this.type,"Added");EO.warn("".concat(i,": ").concat(JSON.stringify(e))),t.emit(i,e)}})),this.devices.forEach((e=>{if(e.deviceId&&!i.find(DP(e.deviceId))){let i="".concat(this.kind).concat(this.type,"Removed");EO.warn("".concat(i,": ").concat(JSON.stringify(e))),t.emit(i,e)}}))),this.devices=i}hasDevice(e){return!!this.devices.find((t=>t.deviceId===e))}},LP=class extends NP.EventEmitter{constructor(){super(),tC(this,"audioInputs",new OP(Mw.AUDIO)),tC(this,"videoInputs",new OP(Mw.VIDEO)),tC(this,"audioOutputs",new OP(Mw.AUDIO,"Output")),this.init(),navigator.mediaDevices&&(navigator.mediaDevices.addEventListener&&navigator.mediaDevices.addEventListener("devicechange",(()=>this.update())),"ondevicechange"in navigator.mediaDevices||SL.run(MN,(()=>{this.update()}),{delay:1e4}))}init(){xP().then((e=>{this.audioInputs.update(e),this.videoInputs.update(e),this.audioOutputs.update(e)}))}update(){return rC(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return function*(){let i=yield xP(t);return e.audioInputs.update(i,e),e.videoInputs.update(i,e),e.audioOutputs.update(i,e),e}()}))}},PP=uw||dw?null:new LP;function MP(e){return e.deviceId===e.groupId&&""===e.groupId}function xP(){return rC(this,arguments,(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return function*(){if(NO()||!kO())return[];let t=yield navigator.mediaDevices.enumerateDevices();if(0!==e){let r={audio:!1,video:!1};if(t.forEach((e=>{MP(e)&&(e.kind===Mw.AUDIO_INPUT?r.audio=!0:e.kind===Mw.VIDEO_INPUT&&(r.video=!0))})),2===e&&(r.audio=!1),1===e&&(r.video=!1),r.audio||r.video){let e;try{e=yield navigator.mediaDevices.getUserMedia(r)}catch(i){EO.debug("capture before getDevices failed: ",i)}t=yield navigator.mediaDevices.enumerateDevices(),null==e||e.getTracks().forEach((e=>e.stop()))}}return t.map(((e,t)=>{let i={kind:e.kind,deviceId:e.deviceId,groupId:e.groupId,label:e.label||"".concat(e.kind,"_").concat(t)};return e.deviceId.length>0&&FP.add("".concat(e.deviceId,"_").concat(e.kind)),e.getCapabilities&&(i.getCapabilities=()=>e.getCapabilities()),i}))}()}))}function VP(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return PP.update(e?1:0).then((e=>e.audioInputs.devices))}function UP(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return PP.update(e?2:0).then((e=>e.videoInputs.devices))}function BP(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return rC(this,null,(function*(){return PP.update(e?1:0).then((e=>e.audioOutputs.devices))}))}var FP=new Set;function HP(e,t){return rC(this,null,(function*(){let i=(yield VP()).find((e=>e.deviceId===bN));return(null==i?void 0:i.groupId)===e&&i.label===t}))}function jP(e,t){return rC(this,null,(function*(){let i=(t?yield UP():yield VP()).find((t=>t.deviceId===e));i&&ND(i.getCapabilities)&&EO.warn(oO(i.getCapabilities(),{keysToInclude:VN}))}))}function WP(e){if(!e.audio)return!1;if(e.useTrueAsConstraint)return!0;let t={echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,sampleRate:e.sampleRate};return!wP(e.microphoneId)&&(t.deviceId=e.useExactDeviceId?{exact:e.microphoneId}:e.microphoneId,e.useDeviceIdOnly)?t:(LD(e.channelCount)&&(t.channelCount=e.channelCount),PD(e.echoCancellation)&&!e.echoCancellation&&(t.echoCancellation=!1),PD(e.noiseSuppression)&&!e.noiseSuppression&&(t.noiseSuppression=!1),PD(e.autoGainControl)&&!e.autoGainControl&&(t.autoGainControl=!1),!!wP(t)||t)}function zP(e){if(!e.video)return!1;if(e.useTrueAsConstraint)return!0;let{maxResolution:t=!0}=e,i={};return e.cameraId?i.deviceId=e.useExactDeviceId?{exact:e.cameraId}:e.cameraId:e.facingMode&&(i.facingMode=e.facingMode),e.useDeviceIdOnly&&!wP(i)?i:(e.width&&(i.width={ideal:e.width},t&&!BC&&(i.width.max=e.width)),e.height&&(i.height={ideal:e.height},t&&!BC&&(i.height.max=e.height)),BC&&fk&&e.width&&e.height&&e.width*e.height<101376&&(i.width=e.width,i.height=e.height),e.frameRate&&(i.frameRate=e.frameRate),!!wP(i)||i)}var GP=YN({retryFunction:function(e){return rC(this,null,(function*(){let t={audio:WP(i=e),video:zP(i)};var i;EO.info("getUserMedia with constraints: ".concat(JSON.stringify(t)));let r=[],n=[],o=["label","deviceId"];t.audio&&(r=yield VP(),EO.info("microphones: ".concat(oO(r,{keysToInclude:o})))),t.video&&(n=yield UP(),EO.info("cameras: ".concat(oO(n,{keysToInclude:o}))));try{let e=yield navigator.mediaDevices.getUserMedia(t);return eL&&e.getTracks().forEach((e=>{EO.info("".concat(e.kind," capabilities: ").concat(oO(e.getCapabilities(),{keysToInclude:VN})))})),e}catch(s){let{message:t}=s;throw"NotFoundError"===s.name&&(e.video&&n&&0===n.length&&(t=GN({key:HN.CAMERA_NOT_FOUND})),e.audio&&r&&0===r.length&&(t=GN({key:HN.MICROPHONE_NOT_FOUND}))),new fC({code:_C.INITIALIZE_FAILED,name:s.name,message:t,constraint:s.constraint})}}))},settings:{retries:3,timeout:500},onError:e=>{let{error:t,retry:i,reject:r,retryFuncArgs:n,retriedCount:o}=e,s=o+1;"NotReadableError"===t.name||"OverconstrainedError"===t.name?(1===s?n[0].video&&(n[0].maxResolution=!1,n[0].frameRate&&(n[0].frameRate=n[0].frameRate>10?10:5)):2===s?n[0].useDeviceIdOnly=!0:3===s&&!n[0].useExactDeviceId&&(n[0].useTrueAsConstraint=!0),i()):r(t),n[0].microphoneId&&jP(n[0].microphoneId,!1),n[0].cameraId&&jP(n[0].cameraId,!0)},onRetrying:e=>{EO.warn("getUserMedia NotReadableError observed, retrying [".concat(e,"/3]"))},onRetryFailed:e=>{XN.logFailedEvent({eventType:lN.GET_USER_MEDIA_RETRY,error:e})},onRetrySuccess:e=>{XN.logSuccessEvent({eventType:lN.GET_USER_MEDIA_RETRY}),XN.uploadEvent({log:"stat-".concat(lN.GET_USER_MEDIA_RETRY,"-success-").concat(e)})}});function KP(e){return JP(((t,i)=>function(){for(var i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return rC(this,null,(function*(){return yield e.apply(this,r),t.apply(this,r)}))}))}function YP(e){return JP(((t,i)=>function(){for(var i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return rC(this,null,(function*(){return e.call(this,t.apply(this,r))}))}))}function JP(e){return function(t,i,r){return r.value=e(r.value,i),r}}var qP=new WeakMap,XP=new WeakMap;function QP(){return function(e,t,i){let r=i.value,n=e=>{let{fn:t,args:i,context:r,resolve:n,reject:o}=e;t.apply(r,i).then(n,o)};return i.value=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return new Promise(((e,i)=>{if(qP.has(this)){let o=qP.get(this),{length:s}=o;o.push({fn:r,args:t,context:this,resolve:e,reject:i}),0===s&&n({fn:r,args:t,context:this,resolve:e,reject:i})}else qP.set(this,[{fn:r,args:t,context:this,resolve:e,reject:i}]),n({fn:r,args:t,context:this,resolve:e,reject:i})})).finally((()=>{let e=qP.get(this);e&&(e.shift(),e[0]&&n(qb({},e[0])))}))},i}}function ZP(e){return function(t,i,r){let n=r.value;return r.value=function(){var t,i;let r=[];for(var o=arguments.length,s=new Array(o),a=0;a<o;a++)s[a]=arguments[a];return null==(t=qP.get(this))||t.forEach((e=>r.push(e))),null==(i=XP.get(this))||i.forEach((e=>e.forEach((e=>r.push(e))))),r.forEach((t=>{t.reject(new fC({code:_C.API_CALL_ABORTED,message:e}))})),qP.delete(this),XP.delete(this),n.apply(this,s)},r}}function $P(e){return function(t,i,r){let n=r.value,o=t=>LD(e)?t[e]:e(...t),s=e=>{let{fn:t,args:i,context:r,resolve:n,reject:a}=e;t.apply(r,i).then(n,a).finally((()=>{if(XP.has(r)&&XP.get(r).has(o(i))){let e=XP.get(r).get(o(i));e&&(e.shift(),e[0]&&s(qb({},e[0])))}}))};return r.value=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return new Promise(((e,i)=>{if(XP.has(this))if(XP.get(this).has(o(t))){let r=XP.get(this).get(o(t));if(r){let{length:o}=r;r.push({fn:n,args:t,context:this,resolve:e,reject:i}),0===o&&s({fn:n,args:t,context:this,resolve:e,reject:i})}}else XP.get(this).set(o(t),[{fn:n,args:t,context:this,resolve:e,reject:i}]),s({fn:n,args:t,context:this,resolve:e,reject:i});else{let r=new Map;r.set(o(t),[{fn:n,args:t,context:this,resolve:e,reject:i}]),XP.set(this,r),s({fn:n,args:t,context:this,resolve:e,reject:i})}}))},r}}var eM=class extends CP{constructor(e,t){super({mediaType:e,PlayerClass:t}),tC(this,"isRemote",!1),tC(this,"deviceId"),tC(this,"groupId",""),tC(this,"label",""),tC(this,"_isRecapturing",!1),tC(this,"_lastRecaptureTime",0),tC(this,"_onMuteTimeoutId",-1),tC(this,"profile"),this.onTrackMuted=this.onTrackMuted.bind(this),this.onTrackUnmuted=this.onTrackUnmuted.bind(this),this.onTrackEnded=this.onTrackEnded.bind(this)}get isPublished(){return"publish"===this.state}installTrackEvent(e){YL(e,e).add(Mw.MUTE,this.onTrackMuted).add(Mw.UNMUTE,this.onTrackUnmuted).add(Mw.ENDED,this.onTrackEnded),e.muted&&this.onTrackMuted(),e.readyState===Mw.ENDED&&this.onTrackEnded()}uninstallTrackEvent(e){JL(e)}setStateToCapture(){}capture(e){return rC(this,null,(function*(){var t;try{let i,r=zD();JN.emit(fO.LOCAL_TRACK_CAPTURE_START,{track:this}),e.customSource?(i=new MediaStream,i.addTrack(e.customSource)):(null==(t=this.mediaTrack)||t.stop(),i=yield GP(e));let n=i.getTracks()[0];return yield this.setInputMediaStreamTrack(n),e.customSource||(this.updateDeviceIdInUse(),this.listenDeviceChange()),JN.emit(fO.LOCAL_TRACK_CAPTURE_SUCCESS,{track:this,cost:zD()-r}),i}catch(i){throw JN.emit(fO.LOCAL_TRACK_CAPTURE_FAILED,{track:this,error:i}),this.log.error("getUserMedia error observed ".concat(i)),i}}))}setInputMediaStreamTrack(e){this.state===gL.INIT&&this.setStateToCapture(),this._inputTrack&&this.uninstallTrackEvent(this._inputTrack);let t=super.setInputMediaStreamTrack(e);return this.installTrackEvent(e),t}setOutputMediaStreamTrack(e){var t;return super.setOutputMediaStreamTrack(e),null==(t=this.room)?void 0:t.replaceTrack(this)}publish(e,t){return this.room=e,this.emit("4",{mediaType:this.strMediaType,state:"starting",prevState:"stopped"}),this.userId=e.userId,this._log.setUserId(e.userId),this._log.setSdkAppId(e.sdkAppId),t}unpublish(){this.room&&this.room.localTracks.delete(this),JN.emit(fO.LOCAL_TRACK_UNPUBLISHED,{track:this})}updateDeviceIdInUse(){return rC(this,null,(function*(){if(this.mediaTrack&&$O){let{deviceId:e,groupId:t}=this.mediaTrack.getSettings(),{label:i}=this.mediaTrack;(yield function(e){return rC(this,arguments,(function(e){let{newDeviceId:t,oldDeviceId:i,oldGroupId:r,oldLabel:n,kind:o}=e;return function*(){return t===i&&(o!==Mw.AUDIO||t!==bN||(yield HP(r,n)))}()}))}({newDeviceId:e,oldDeviceId:this.deviceId,oldGroupId:this.groupId,oldLabel:this.label,kind:this.kind}))||(this.deviceId=e,this.label=i,t&&(this.groupId=t),xP().then((t=>{let i=t.find((t=>t.deviceId===e));i&&this.emit("2",i)})))}}))}setProfile(e){this.log.info("setProfile",e),Object.assign(this.profile,e)}isNeedToRecapture(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return!(!this.deviceId||!this.mediaTrack||this.kind===Mw.AUDIO&&!function(e){if(e instanceof CanvasCaptureMediaStreamTrack||!(e instanceof MediaStreamTrack))return!1;let t=e.label.toLocaleLowerCase();if(t.includes("mic")||t.includes("麦克风"))return!0;let i="".concat(((null==e?void 0:e.getSettings())||{}).deviceId,"_").concat(Mw.AUDIO_INPUT);return!!FP.has(i)}(this.mediaTrack)||this.kind===Mw.VIDEO&&!function(e){if(e instanceof CanvasCaptureMediaStreamTrack||!(e instanceof MediaStreamTrack))return!1;let t=e.label.toLocaleLowerCase();if(t.includes("camera")||t.includes("webcam"))return!0;let i="".concat(((null==e?void 0:e.getSettings())||{}).deviceId,"_").concat(Mw.VIDEO_INPUT);return!!FP.has(i)}(this.mediaTrack)||this._isRecapturing||e&&fk&&Bk)}onTrackMuted(){if(cO(),this.isNeedToRecapture(!0)){if(Date.now()-this._lastRecaptureTime<ON)return void setTimeout((()=>this.onTrackMuted()),ON);this._onMuteTimeoutId=setTimeout((()=>rC(this,null,(function*(){var e;if(null!=(e=this.mediaTrack)&&e.muted){if((PC||MC)&&"visible"!==document.visibilityState)return;this.recapture(yield this.getRecoverCaptureDeviceId())}}))),5e3)}}onTrackUnmuted(){this._onMuteTimeoutId>0&&clearTimeout(this._onMuteTimeoutId)}onTrackEnded(){return rC(this,null,(function*(){if(this.isNeedToRecapture()){if(Date.now()-this._lastRecaptureTime<ON)return void setTimeout((()=>this.onTrackEnded()),ON);this.recapture(yield this.getRecoverCaptureDeviceId())}}))}recapture(e){return rC(this,null,(function*(){var t;if(this._isRecapturing||!this._inputTrack)return;this.log.warn("recapture trying"),null==(t=this._inputTrack)||t.stop(),this._isRecapturing=!0,this._lastRecaptureTime=Date.now();let i={useExactDeviceId:!0};if("user"===e||"environment"===e)i.facingMode=e;else{let t;("audio"===this.kind?yield VP():yield UP()).find((t=>t.deviceId===e))&&(t=e),i.deviceId=t}return this.capture(i).then((()=>{this._isRecapturing=!1,this.log.warn("recapture success"),this.emit("1",{deviceId:this.deviceId})})).catch((e=>{this._isRecapturing=!1,this.log.warn("recapture failed ".concat(e.message)),this.emit("5",e)}))}))}getRecoverCaptureDeviceId(){return rC(this,null,(function*(){let e=this instanceof rM;if(e&&this.facingMode)return this.facingMode;let{deviceId:t}=this;if(t){let i=(tM.get(t)||0)+1;if(tM.set(t,i),i>=3){let r=e?(yield UP()).find((e=>!tM.has(e.deviceId))):(yield VP()).find((e=>!tM.has(e.deviceId)));r&&(this.log.warn("".concat(t," capture fail ").concat(i," times, change new ").concat(r.deviceId)),t=r.deviceId)}}return t}))}close(){var e;super.close(),this._inputTrack&&(this._inputTrack.stop(),this.uninstallTrackEvent(this._inputTrack)),null==(e=this.manager)||e.removeInput(this)}};eC([mL(gL.INIT,"capture",{ignoreError:!0,sync:!0})],eM.prototype,"setStateToCapture",1),eC([QP()],eM.prototype,"capture",1),eC([mL("capture","publish",{ignoreError:!0,success(){this.room.localTracks.add(this),JN.emit(fO.LOCAL_TRACK_PUBLISHED,{track:this}),this.emit("4",{mediaType:this.strMediaType,state:"started",prevState:"starting"})},fail(e){let t="error",i=e.cause;i.message.includes("timeout")?t="timeout":i.code===_C.API_CALL_ABORTED&&(t="api-call"),this.emit("4",{mediaType:this.strMediaType,state:"stopped",prevState:"starting",reason:t,error:i})}})],eM.prototype,"publish",1),eC([JP((e=>function(){return rC(this,null,(function*(){let t="publish"===this.state?"started":"starting";e.call(this),this.emit("4",{mediaType:this.strMediaType,state:"stopped",prevState:t,reason:"api-call"}),2===this.mediaType&&(this.mediaType=4)}))})),mL([],"capture",{sync:!0})],eM.prototype,"unpublish",1);var tM=new Map;JN.on(fO.SWITCH_DEVICE_SUCCESS,(e=>{e.track.deviceId&&tM.delete(e.track.deviceId)}));var iM=class extends eM{constructor(e){super(1,RP),tC(this,"mediaType",1),tC(this,"volume",0),tC(this,"profile",{echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0,sampleRate:48e3,channelCount:1,bitrate:40}),tC(this,"playerMuted",!0),tC(this,"pipeline"),this.manager=e,this.pipeline=new gP(e)}getAudioLevel(){let e=(this.volume||super.getAudioLevel())*this.captureVolume;return e>1?1:e}get playerMediaTrack(){return this.mediaTrack}setInputMediaStreamTrack(e){return rC(this,null,(function*(){yield iC(iM.prototype,this,"setInputMediaStreamTrack").call(this,e);let t=this.trackSettings||{};pP.addEnum({key:501701,value:t.channelCount||0,useUV:!1}),pP.addEnum({key:501702,value:t.sampleRate||0,useUV:!1}),pP.addEnum({key:502700,value:0});let{sampleRate:i,channelCount:r}=t;this._log.info("local audio track input ".concat(JSON.stringify({sampleRate:i,channelCount:r}))),this.pipeline.replaceSource(e),this.updatePlayingState(!!e)}))}capture(e){let{deviceId:t,customSource:i,useExactDeviceId:r=!1}=e;return super.capture({video:!1,audio:!0,microphoneId:t,echoCancellation:this.profile.echoCancellation,autoGainControl:this.profile.autoGainControl,noiseSuppression:this.profile.noiseSuppression,sampleRate:this.profile.sampleRate,channelCount:this.profile.channelCount,useExactDeviceId:r,customSource:i})}switchDevice(e){return rC(this,null,(function*(){if(this.mediaTrack){if(this.deviceId===e){if(e!==bN)return;if(yield HP(this.groupId,this.label))return}try{this.log.info("switchDevice audio to: ".concat(e)),this.mediaTrack&&this.mediaTrack.stop(),yield this.capture({deviceId:e,useExactDeviceId:!0}),this.room&&(yield this.room.replaceTrack(this)),JN.emit(fO.SWITCH_DEVICE_SUCCESS,{track:this}),this.log.info("switch microphone success")}catch(t){throw this.log.error("switch microphone failed ".concat(t)),this.deviceId&&this.recapture(this.deviceId),t}}}))}listenDeviceChange(){PP&&!PP.listeners("audioInputRemoved").includes(this.handleMicrophoneRemoved)&&PP.on("audioInputRemoved",this.handleMicrophoneRemoved,this)}handleMicrophoneRemoved(e){return rC(this,null,(function*(){if(e.deviceId===this.deviceId){this.log.warn("current microphone is lost: ".concat(JSON.stringify(e)));let t=yield VP();t[0]?this.recapture(t[0].deviceId):PP.on("audioInputAdded",this.handleMicrophoneAdded,this)}}))}handleMicrophoneAdded(e){this.log.warn("microphone added: ".concat(JSON.stringify(e))),this.recapture(e.deviceId)}update3A(e){return rC(this,arguments,(function(e){var t=this;let{echoCancellation:i,noiseSuppression:r,autoGainControl:n}=e;return function*(){let e=!1;!DD(i)&&i!==t.profile.echoCancellation&&(t.profile.echoCancellation=i,e=!0),!DD(r)&&r!==t.profile.noiseSuppression&&(t.profile.noiseSuppression=r,e=!0),!DD(n)&&n!==t.profile.autoGainControl&&(t.profile.autoGainControl=n,e=!0),e&&t.deviceId&&(yield t.recapture(t.deviceId))}()}))}get captureVolume(){return this.pipeline.volume}setCaptureVolume(e){this.pipeline.setVolume(e/100),this.pipeline.gain.node&&pP.addEnum({key:502700,value:2}),this.resetPlayerSource()}enableTrackANS(e){if(!this._inputTrack)return;let t=this._inputTrack.getConstraints();return t.noiseSuppression=e,this._inputTrack.applyConstraints(t).catch((t=>this._log.warn("".concat(e?"enable":"disable"," ANS failed "),t)))}addDenoiser(e){var t;Vk<=92&&48e3!==(null==(t=this.trackSettings)?void 0:t.sampleRate)?this._log.warn("denoiser only support sampleRate 48000 before chrome 93"):(pP.addEnum({key:502700,value:1}),this.pipeline.denoiser.setNode(e),this.resetPlayerSource(),this.enableTrackANS(!1))}removeDenoiser(e){this.pipeline.denoiser.node===e&&(this.pipeline.denoiser.deleteNode(),this.resetPlayerSource(),this.enableTrackANS(!0))}resetPlayerSource(){this.player.setSourceNode(this.pipeline.gain.node||this.pipeline.denoiser.node||this.pipeline.source.node)}close(){this.pipeline.remove(),PP.off("audioInputAdded",this.handleMicrophoneAdded,this),PP.off("audioInputRemoved",this.handleMicrophoneRemoved,this),super.close()}},rM=class extends eM{constructor(e){super(4,XL),tC(this,"mediaType",4),tC(this,"profile",{width:640,height:480,frameRate:15,bitrate:500}),tC(this,"states",{bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0}),tC(this,"small"),tC(this,"isNeedToSetBandwidth"),tC(this,"muteImage"),tC(this,"manager"),this.manager=e;let t=()=>{this.isAllowed2k4k(this.profile)?this.room&&this.settings.height>=1440&&"publish"===this.state&&this.room.sendAbilityStatus({"2k4k":1}):(this.log.warn("Resolution is reset to 1080p, need to upgrade ability here https://cloud.tencent.com/document/product/647/85386"),this.setProfile(Xb(qb({},this.profile),{width:1920,height:1080})),this.applyProfile())};this.on("input-media-track-changed",t),this.on("publish",t)}get facingMode(){if($O&&this.mediaTrack)return this.mediaTrack.getSettings().facingMode}setMute(e){return rC(this,null,(function*(){var t,i,r;if(OD(e)){if(this.muteImage===e)return;yield null==(t=this.manager)?void 0:t.deleteWatermark("mute"),yield null==(i=this.manager)?void 0:i.setWatermark({x:0,y:0,width:this.settings.width,height:this.settings.height,type:"mute",zIndex:999,imageUrl:e}),this.muteImage=e,iC(rM.prototype,this,"setMute").call(this,!1)}else yield null==(r=this.manager)?void 0:r.deleteWatermark("mute"),this.muteImage=void 0,iC(rM.prototype,this,"setMute").call(this,e)}))}capture(e){let{deviceId:t,facingMode:i,useExactDeviceId:r=!1,customSource:n}=e;return super.capture({audio:!1,video:!0,facingMode:i||this.facingMode,cameraId:t,width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate,useExactDeviceId:r,customSource:n})}setProfile(e){let t=qb({},e),i=t.width>t.height;t.width*t.height<=19200&&MC&&Pk&&(this.log.warn("resolution is ".concat(t.width,"*").concat(t.height,", fallback to 240*180")),t.width=i?240:180,t.height=i?180:240,t.bitrate=Math.max(t.bitrate,150)),t.width*t.height>921600&&Yk&&(t.width=i?1280:720,t.height=i?720:1280,this.log.warn("reset to 1280 * 720 on iOS 13~14")),t.bitrate&&(this.isNeedToSetBandwidth=t.bitrate!==this.profile.bitrate),this.isAllowed2k4k(this.profile)?super.setProfile(t):(this.log.warn("Resolution is reset to 1080p, need to upgrade ability here https://cloud.tencent.com/document/product/647/85386"),super.setProfile(Xb(qb({},this.profile),{width:1920,height:1080})))}applyProfile(){var e;if(!this.mediaTrack)return;let t=this.settings;return t.height!==this.profile.height||t.width!==this.profile.width||t.frameRate!==this.profile.frameRate?null==(e=this.mediaTrack)?void 0:e.applyConstraints({width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate}).then((()=>{if(this.manager&&this.manager.changeInput(this),this.room&&this.settings.height>=1440&&"publish"===this.state&&this.room.sendAbilityStatus({"2k4k":1}),this.isNeedToSetBandwidth&&this.room&&this.room.setBandWidth)return this.isNeedToSetBandwidth=!1,this.room.setBandWidth({bandwidth:this.profile.bitrate,type:Mw.VIDEO,videoType:Mw.BIG})})):void 0}get settings(){let e={width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate};return $O&&this.mediaTrack&&Object.assign(e,this.mediaTrack.getSettings()),e}get scaleResolutionDownBy(){let{settings:e}=this;return e.width===this.profile.width&&e.height===this.profile.height?1:lO()&&this.profile.width>this.profile.height&&e.height>e.width?Math.max(e.width/this.profile.height,e.height/this.profile.width,1):Math.max(e.width/this.profile.width,e.height/this.profile.height,1)}isAllowed2k4k(e){var t;return!(this.room&&this.room.scheduleResult&&!this.isScreen&&!(e.height*e.width<3686400))||1===(null==(t=this.room.scheduleResult.trtcAutoConf)?void 0:t["2k4k"])}isNeedToSwitchDevice(e){return!(!this.mediaTrack||this.deviceId===e||this.facingMode===e)}switchDevice(e){return rC(this,null,(function*(){try{if(!this.isNeedToSwitchDevice(e))return;let t={useExactDeviceId:!0};"user"===e||"environment"===e?t.facingMode=e:t.deviceId=e,this.mediaTrack.stop(),yield this.capture(t),JN.emit(fO.SWITCH_DEVICE_SUCCESS,{track:this}),this.log.info("switch camera success")}catch(t){throw this.log.error("switch camera failed ".concat(t)),this.deviceId&&this.recapture(this.deviceId),t}}))}listenDeviceChange(){PP&&!PP.listeners("videoInputRemoved").includes(this.handleCameraRemoved)&&PP.on("videoInputRemoved",this.handleCameraRemoved,this)}handleCameraRemoved(e){return rC(this,null,(function*(){if(e.deviceId===this.deviceId){this.log.warn("current camera is lost: ".concat(JSON.stringify(e)));let t=yield UP();t[0]?this.recapture(t[0].deviceId):PP.on("videoInputAdded",this.handleCameraAdded,this)}}))}handleCameraAdded(e){return rC(this,null,(function*(){this.log.warn("camera added: ".concat(JSON.stringify(e))),this.recapture(e.deviceId)}))}play(e,t){return rC(this,null,(function*(){return DD(this.mirror)&&!this.isScreen&&this.setMirror("view"),iC(rM.prototype,this,"play").call(this,e,t)}))}close(){PP.off("videoInputAdded",this.handleCameraAdded,this),PP.off("videoInputRemoved",this.handleCameraRemoved,this),super.close()}},nM=vO();if(navigator.mediaDevices&&"setCaptureHandleConfig"in navigator.mediaDevices)try{navigator.mediaDevices.setCaptureHandleConfig({handle:nM,exposeOrigin:!0,permittedOrigins:["*"]})}catch(lB){}var oM,sM=function(e){return rC(this,null,(function*(){let t=null,i=function(e){let t={preferCurrentTab:"current-tab"===e.preferDisplaySurface,systemAudio:"include",selfBrowserSurface:"include",surfaceSwitching:"include"},i={width:Bk?{max:e.width}:{ideal:e.width,max:e.width},height:Bk?{max:e.height}:{ideal:e.height,max:e.height},frameRate:e.frameRate,displaySurface:e.preferDisplaySurface||"monitor"};if(t.video=i,e.systemAudio){let{echoCancellation:i=!0,noiseSuppression:r=!1,autoGainControl:n=!1}=e;t.audio={echoCancellation:i,noiseSuppression:r,autoGainControl:n,sampleRate:48e3}}return t}(e);EO.info("getDisplayMedia with constraints: ".concat(JSON.stringify(i)));let r=yield navigator.mediaDevices.getDisplayMedia(i);e.systemAudio&&0===r.getAudioTracks().length&&(Mk&&Vk<74||Bk||BC)&&EO.warn("Your browser not support capture system audio");let n=r.getVideoTracks()[0];if(n){if(e.frameRate)try{yield n.applyConstraints({frameRate:{min:e.frameRate,ideal:e.frameRate},width:e.width,height:e.height})}catch(o){EO.warn("screen applyConstraints failed: ".concat(o))}e.captureElement&&(yield function(e,t){return rC(this,null,(function*(){var i;if("CropTarget"in window&&"fromElement"in CropTarget&&ND(e.cropTo))try{if((null==(i=e.getCaptureHandle())?void 0:i.handle)!==nM)return;let r=yield CropTarget.fromElement(t);yield e.cropTo(r)}catch(r){EO.warn("cropTo target failed ".concat(r))}}))}(n,e.captureElement))}if(e.audio){let i=function(e){let t={echoCancellation:e.echoCancellation,autoGainControl:e.autoGainControl,noiseSuppression:e.noiseSuppression,sampleRate:e.sampleRate,channelCount:e.channelCount};return DD(e.microphoneId)||(t.deviceId=e.microphoneId),{audio:t,video:!1}}(e);EO.info("getUserMedia with constraints: ".concat(JSON.stringify(i))),t=yield navigator.mediaDevices.getUserMedia(i),r.addTrack(t.getAudioTracks()[0])}return r}))},aM=class extends rM{constructor(e){super(e),tC(this,"profile",{width:1920,height:1080,frameRate:5,bitrate:1600}),tC(this,"objectFit","contain"),tC(this,"isScreen",!0),this._log.id="s-".concat(this._log.id)}capture(e){return rC(this,arguments,(function(e){var t=this;let{systemAudio:i=!1,autoGainControl:r,echoCancellation:n,noiseSuppression:o,audioTrack:s,videoTrack:a,captureElement:c,preferDisplaySurface:l}=e;return function*(){try{let e;return a||s?(e=new MediaStream,a&&e.addTrack(a),s&&e.addTrack(s)):e=yield sM({audio:!1,systemAudio:i,width:t.profile.width,height:t.profile.height,frameRate:t.profile.frameRate,autoGainControl:r,echoCancellation:n,noiseSuppression:o,captureElement:c,preferDisplaySurface:l}),yield t.setInputMediaStreamTrack(e.getVideoTracks()[0]),e}catch(e){throw t.log.error("getDisplayMedia error observed ".concat(e)),e instanceof fC?e:new fC({code:_C.INITIALIZE_FAILED,name:e.name,message:e.message})}}()}))}switchDevice(e){return rC(this,null,(function*(){throw new Error("Method not implemented.")}))}},cM=class extends iM{constructor(e){super(e),this._log.id="s-".concat(this._log.id)}},lM=class extends EP{constructor(e){super(),this.room=e,tC(this,"_localAudioTrack"),tC(this,"_localScreenAudioTrack"),tC(this,"log",EO.createLogger({id:"am"})),tC(this,"denoiser"),e&&(this.log.setUserId(e.userId),this.log.setSdkAppId(e.sdkAppId))}get _localAudioPipline(){var e;return null==(e=this._localAudioTrack)?void 0:e.pipeline}dump(e){var t,i;if(!this._localAudioTrack)return;let r=[],n=[];null!=(t=this._localAudioPipline)&&t.source.node&&(r.push(this._localAudioPipline.source.node),n.push("mic")),null!=(i=this._localAudioPipline)&&i.denoiser.node&&(r.push(this._localAudioPipline.denoiser.node),n.push("mic-processed")),this.mixWeight>1&&(r.push(this.audioContext.createMediaStreamSource(this._localAudioPipline.stream)),n.push("mix")),this.log.info("dump audio track ".concat(n,", duration: ").concat(e));let o=new AbortController,s=[],a=setTimeout((()=>{this.log.info('dump audio track complete please input "download()" to download.'),o.abort("timeout")}),1e3*e),c=()=>{for(let e=0;e<n.length;e++){let t=URL.createObjectURL(new Blob(s[e])),i=document.createElement("a");i.href=t,i.download="".concat(n[e],".pcm"),i.style.display="none",document.body.appendChild(i),i.click(),URL.revokeObjectURL(t),i.remove()}clearTimeout(a),o.abort("download")},l=function(e){return rC(this,null,(function*(){let t=rP();oM||(oM=QL(t,URL.createObjectURL(new Blob(["registerProcessor('dumper', class extends AudioWorkletProcessor {process(inputs) {this.port.postMessage(inputs);return true;}});"],{type:"application/javascript"})))),yield oM;let i=new AudioWorkletNode(t,"dumper",{numberOfInputs:e.length,numberOfOutputs:0});return e.forEach(((e,t)=>e.connect(i,0,t))),new ReadableStream({start(e){i.port.onmessage=t=>{e.enqueue(t.data)}},cancel(){e.forEach((e=>e.disconnect(i))),i.port.close()}})}))}(r).then((e=>e.pipeTo(new WritableStream({write(e){e.forEach(((e,t)=>s[t]=s[t]?s[t].concat(e[0]):[e[0]]))}}),o).catch((e=>c))));return{then:l.then.bind(l),download:c}}get hasScreenAudioTrack(){return null!==this._localScreenAudioTrack}get hasAudioTrack(){return null!==this._localAudioTrack}changeInput(e){var t;if(e instanceof cM)this._localScreenAudioTrack=e,e.pipeline.connect(),this.mixOnChange();else if(e instanceof iM)this._localAudioTrack=e,this.destination.channelCount=(null==(t=e.trackSettings)?void 0:t.channelCount)||1,this.denoiser&&e.addDenoiser(this.denoiser),e.pipeline.connect(),this.mixOnChange();else if(e instanceof hM)return e.setOutputMediaStreamTrack(e.mediaTrack)}mixOnChange(){var e,t;null==(e=this._localAudioTrack)||e.setOutputMediaStreamTrack(this.mixWeight>1?this.mixTrack:this._localAudioTrack.mediaTrack),null==(t=this._localScreenAudioTrack)||t.setOutputMediaStreamTrack(this.mixWeight>1?this.mixTrack:this._localScreenAudioTrack.mediaTrack)}removeInput(e){e instanceof cM?delete this._localScreenAudioTrack:e instanceof iM&&delete this._localAudioTrack}addDenoiser(e){var t;this.denoiser=e,null==(t=this._localAudioTrack)||t.addDenoiser(e)}removeDenoiser(e){var t;delete this.denoiser,null==(t=this._localAudioTrack)||t.removeDenoiser(e)}destroy(){this.close()}},dM=class extends CP{constructor(e,t,i){super({userId:t.userId,sdkAppId:e.sdkAppId,mediaType:i,room:e}),this.room=e,this.user=t,tC(this,"tinyId"),tC(this,"isRemote",!0),this.tinyId=t.tinyId}setMute(e){this.hasFlag&&super.setMute(e)}setInputMediaStreamTrack(e){super.setInputMediaStreamTrack(e),this.hasFlag&&this.isSubscribed&&this.player.setTrack(this.outMediaTrack)}waitHasMediaTrack(){return new Promise((e=>{this.mediaTrack?e():this.once("input-media-track-changed",e)}))}get isSubscribing(){return"subscribeing"===this.state.toString()}get isSubscribed(){return this.state===dM.STATE_SUBSCRIBE}subscribe(e){return e}unsubscribe(){this.player.setTrack(null),"main"===this.streamType&&"video"===this.kind&&this.room.changeType(!1,this.user)}updatePlayingState(e){if(this.isPlayCalled&&this.player.isStopped===e){if(e&&(!this.isSubscribed||!this.hasFlag||!this.outMediaTrack))return void this.log.info("abort play, isSubscribed:".concat(this.isSubscribed," hasFlag:").concat(this.hasFlag," hasTrack:").concat(!!this.outMediaTrack));super.updatePlayingState(e)}}onFlagChanged(){this.updatePlayingState(this.hasFlag)}},uM=dM;tC(uM,"STATE_SUBSCRIBE","subscribe"),eC([mL(gL.INIT,uM.STATE_SUBSCRIBE,{success(){this.log.info("subscribed"),JN.emit(fO.REMOTE_TRACK_SUBSCRIBED,{track:this}),this.updatePlayingState(!0)},ignoreError:!0})],uM.prototype,"subscribe",1),eC([mL(uM.STATE_SUBSCRIBE,gL.INIT,{sync:!0,success(){this.log.info("unsubscribed"),this.updatePlayingState(!1),JN.emit(fO.REMOTE_TRACK_UNSUBSCRIBED,{track:this})}})],uM.prototype,"unsubscribe",1);var hM=class extends uM{constructor(e,t){super(e,t,1),tC(this,"volume",0),tC(this,"mediaType",1),tC(this,"stat",{bytesReceived:0,packetsReceived:0,packetsLost:0,end2EndDelay:0,jitterBufferDelay:0}),this.manager=e.audioManager}getAudioLevel(){let e=this.volume||super.getAudioLevel();return e>1?1:e}get hasFlag(){return this.user.muteState.hasAudio&&!this.user.muteState.audioMuted}isFlagChanged(e){let t=e.hasAudio&&!e.audioMuted;return this.hasFlag||(this.volume=0),this.hasFlag!==t}},pM=class extends uM{constructor(e,t){super(e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:4),tC(this,"mediaType",4),tC(this,"stat",{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0,end2EndDelay:0,jitterBufferDelay:0}),this.manager=e.videoManager}get isBig(){return 4===this.mediaType}get isSmall(){return 8===this.mediaType}changeType(e){this.room.changeType(e,this.user)}get hasFlag(){return this.user.muteState.hasVideo&&!this.user.muteState.videoMuted}isFlagChanged(e){let t=e.hasVideo&&!e.videoMuted;return this.hasFlag!==t}setMirror(e){"publish"===e||"both"===e||super.setMirror(e)}},mM=class extends pM{constructor(e,t){super(e,t,2),tC(this,"mediaType",2),tC(this,"objectFit","contain")}get hasFlag(){return this.user.muteState.hasAuxiliary}isFlagChanged(e){let t=e.hasAuxiliary;return this.hasFlag!==t}};function _M(){}var fM=e=>e(),gM=()=>"undefined"!=typeof __FASTRX_DEVTOOLS__,EM=1,vM=class extends Function{toString(){return"".concat(this.name,"(").concat(this.args.length?[...this.args].join(", "):"",")")}subscribe(e){let t=new AM(e,this,this.streamId++);return RM.subscribe({id:this.id,end:!1},{nodeId:t.sourceId,streamId:t.id}),this(t),t}},yM=class{constructor(){this.defers=new Set,this.disposed=!1}next(e){}complete(){this.dispose()}error(e){this.dispose()}get bindDispose(){return()=>this.dispose()}dispose(){this.disposed=!0,this.complete=_M,this.error=_M,this.next=_M,this.dispose=_M,this.subscribe=_M,this.doDefer()}subscribe(e){return e instanceof vM?e.subscribe(this):e(this),this}get bindSubscribe(){return e=>this.subscribe(e)}doDefer(){this.defers.forEach(fM),this.defers.clear()}defer(e){this.defers.add(e)}removeDefer(e){this.defers.delete(e)}reset(){this.disposed=!1,delete this.complete,delete this.next,delete this.dispose,delete this.next,delete this.subscribe}resetNext(){delete this.next}resetComplete(){delete this.complete}resetError(){delete this.error}},TM=class extends yM{constructor(e){super(),this.sink=e,e.defer(this.bindDispose)}next(e){this.sink.next(e)}complete(){this.sink.complete()}error(e){this.sink.error(e)}};function SM(e,t,i){if(gM()){let r=Object.defineProperties(Object.setPrototypeOf(e,vM.prototype),{streamId:{value:0,writable:!0,configurable:!0},name:{value:t,writable:!0,configurable:!0},args:{value:i,writable:!0,configurable:!0},id:{value:0,writable:!0,configurable:!0}});RM.create(r);for(let e=0;e<i.length;e++){let t=i[e];"function"==typeof t&&t instanceof vM&&RM.addSource(r,t)}return r}return e}function IM(e,t){window.postMessage({source:"fastrx-devtools-backend",payload:{event:e,payload:t}})}var AM=class extends TM{constructor(e,t,i){super(e),this.source=t,this.id=i,this.sourceId=e.sourceId,this.defer((()=>{RM.defer(this.source,this.id)}))}next(e){RM.next(this.source,this.id,e),this.sink.next(e)}complete(){RM.complete(this.source,this.id),this.sink.complete()}error(e){RM.complete(this.source,this.id,e),this.sink.error(e)}},RM={addSource(e,t){IM("addSource",{id:e.id,name:e.toString(),source:{id:t.id,name:t.toString()}})},next(e,t,i){IM("next",{id:e.id,streamId:t,data:i&&i.toString()})},subscribe(e,t){let{id:i,end:r}=e;IM("subscribe",{id:i,end:r,sink:{nodeId:t&&t.nodeId,streamId:t&&t.streamId}})},complete(e,t,i){IM("complete",{id:e.id,streamId:t,err:i?i.toString():null})},defer(e,t){IM("defer",{id:e.id,streamId:t})},pipe(e){IM("pipe",{name:e.toString(),id:e.id,source:{id:e.source.id,name:e.source.toString()}})},update(e){IM("update",{id:e.id,name:e.toString()})},create(e){e.id||(e.id=EM++),IM("create",{name:e.toString(),id:e.id})}},bM=class extends yM{constructor(e){super(),this.source=e,this.sinks=new Set}add(e){e.defer((()=>this.remove(e))),1===this.sinks.add(e).size&&(this.reset(),this.subscribe(this.source))}remove(e){this.sinks.delete(e),0===this.sinks.size&&this.dispose()}next(e){this.sinks.forEach((t=>t.next(e)))}complete(){this.sinks.forEach((e=>e.complete())),this.sinks.clear()}error(e){this.sinks.forEach((t=>t.error(e))),this.sinks.clear()}},CM=function(e,t){return function(){for(var i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return i=>{if(i instanceof vM){let n=SM((t=>{let o=new e(t,...r);o.sourceId=n.id,o.subscribe(i)}),t,arguments);return n.source=i,RM.pipe(n),n}return t=>i(new e(t,...r))}}}(class extends TM{constructor(e,t,i){super(e),this.mapper=t,this.thisArg=i}next(e){super.next(this.mapper.call(this.thisArg,e))}},"map");!function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];i.reduce(((e,t)=>t(e)),e)}(function(e){return SM((t=>{let i=0,r=setInterval((()=>t.next(i++)),e);return t.defer((()=>{clearInterval(r)})),"interval"}),"interval",arguments)}(250),CM((()=>performance.now())),function(){return e=>{let t=new bM(e);if(e instanceof vM){let i=SM((e=>{t.add(e)}),"share",arguments);return t.sourceId=i.id,i.source=e,RM.pipe(i),i}return SM(t.add.bind(t),"share",arguments)}}());var kM=new Map;function wM(e,t){let i=Xb(qb({},t),{timestamp:EC()});kM.has(e)?kM.get(e).push(i):kM.set(e,[i])}JN.on(fO.JOIN_SUCCESS,(e=>{let{room:t}=e;wM(t.userId,{eventId:32788,eventDesc:"join room"})})),JN.on(fO.LEAVE_START,(e=>{let{room:t}=e;wM(t.userId,{eventId:32789,eventDesc:"leave room"})})),JN.on(fO.LOCAL_TRACK_PUBLISHED,(e=>{let{track:t}=e;if(t.room){let e=32769;4===t.mediaType?e=32768:2===t.mediaType&&(e=32805),wM(t.room.userId,{eventId:e,eventDesc:"publish ".concat(t.kind)})}})),JN.on(fO.LOCAL_TRACK_UNPUBLISHED,(e=>{let{track:t}=e;if(t.room){let e=32771;4===t.mediaType?e=32770:2===t.mediaType&&(e=32806),wM(t.room.userId,{eventId:e,eventDesc:"unpublish ".concat(t.kind)})}})),JN.on(fO.TRACK_MUTED,(e=>{let{track:t}=e;t.room&&(t.kind===Mw.AUDIO?wM(t.room.userId,{eventId:t.isRemote?32785:32772,eventDesc:"mute audio",remoteUserId:t.isRemote?t.userId:void 0}):wM(t.room.userId,{eventId:t.isRemote?32784:32773,eventDesc:"mute video",remoteUserId:t.isRemote?t.userId:void 0}))})),JN.on(fO.TRACK_UNMUTED,(e=>{let{track:t}=e;t.room&&(t.kind===Mw.AUDIO?wM(t.room.userId,{eventId:t.isRemote?32787:32774,eventDesc:"unmute audio",remoteUserId:t.isRemote?t.userId:void 0}):wM(t.room.userId,{eventId:t.isRemote?32786:32775,eventDesc:"unmute video",remoteUserId:t.isRemote?t.userId:void 0}))})),JN.on(fO.REMOTE_TRACK_SUBSCRIBED,(e=>{let{track:t}=e;!t.room||(1===t.mediaType&&wM(t.room.userId,{eventId:32777,eventDesc:"".concat(Mw.SUBSCRIBE," ").concat(t.kind),remoteUserId:t.userId}),4===t.mediaType&&wM(t.room.userId,{eventId:32776,eventDesc:"".concat(Mw.SUBSCRIBE," ").concat(t.kind),remoteUserId:t.userId}),8===t.mediaType&&wM(t.room.userId,{eventId:32803,eventDesc:"".concat(Mw.SUBSCRIBE," ").concat(Mw.SMALL_VIDEO),remoteUserId:t.userId}))})),JN.on(fO.REMOTE_TRACK_UNSUBSCRIBED,(e=>{let{track:t}=e;!t.room||(1===t.mediaType&&wM(t.room.userId,{eventId:32779,eventDesc:"".concat(Mw.UNSUBSCRIBE," ").concat(t.kind),remoteUserId:t.userId}),4===t.mediaType&&wM(t.room.userId,{eventId:32778,eventDesc:"".concat(Mw.UNSUBSCRIBE," ").concat(t.kind),remoteUserId:t.userId}),8===t.mediaType&&wM(t.room.userId,{eventId:32804,eventDesc:"".concat(Mw.UNSUBSCRIBE," ").concat(Mw.SMALL_VIDEO),remoteUserId:t.userId}))})),JN.on(fO.SWITCH_DEVICE_SUCCESS,(e=>{let{track:t}=e;t.room&&wM(t.room.userId,{eventId:t.kind===Mw.VIDEO?32780:32781,eventDesc:"switch ".concat(t.kind===Mw.VIDEO?"camera":"microphone")})})),JN.on(fO.LOCAL_TRACK_REPLACED,(e=>{let{track:t}=e;t.room&&wM(t.room.userId,{eventId:t.kind===Mw.VIDEO?32782:32783,eventDesc:"replace ".concat(t.kind)})})),JN.on(fO.SIGNAL_CONNECTION_STATE_CHANGED,(e=>{let t,i,{room:r,prevState:n,state:o}=e;switch(o){case"CONNECTED":"RECONNECTING"===n?(t=32795,i="signal reconnected"):(t=32791,i="signal connected");break;case"DISCONNECTED":"RECONNECTING"===n?(t=32796,i="signal reconnect fail"):(t=32790,i="signal disconnected");break;case"RECONNECTING":t=32794,i="signal reconnecting"}t&&i&&wM(r.userId,{eventId:t,eventDesc:i})})),JN.on(fO.PEER_CONNECTION_STATE_CHANGED,(e=>{let t,i,{room:r,prevState:n,state:o,remoteUserId:s}=e,a=!!s,c=a?"downlink":"uplink";switch(o){case"CONNECTED":"RECONNECTING"===n?(t=a?32801:32798,i="".concat(c," reconnected")):(t=a?32793:32792,i="".concat(c," connected"));break;case"DISCONNECTED":"RECONNECTING"===n&&(t=a?32802:32799,i="".concat(c," reconnect fail"));break;case"RECONNECTING":t=a?32800:32797,i="".concat(c," reconnecting")}t&&i&&wM(r.userId,{eventId:t,eventDesc:i,remoteUserId:s})}));var NM,DM=$b(nC(),1),OM=class extends DM.EventEmitter{constructor(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"userId";super(),this.mySelfId=e,this._log=t,this.key=i,tC(this,"userMap",new Map),tC(this,"remotePublishedUserMap",new Map)}getPublishedUser(e){return this.remotePublishedUserMap.get(e)}addUser(e){let t=e[this.key],{userId:i,tinyId:r,role:n}=e;if(this.userMap.has(t))return;let o={userId:i,tinyId:r,role:20===n?"anchor":"audience"};this.userMap.set(t,o),this.emit("1",o)}deleteUser(e,t){let i=this.userMap.get(e);if(!i)return;let r="peer leave [".concat(e,"]");DD(t)||(r+=":".concat(NN[t])),this._log.info(r);let n=this.remotePublishedUserMap.get(e);if(n){let t=n.muteState;n.flag=0,this.emit("5",n.userId),this.deleteRemotePublishedUser(e),this.emit("6",{prevMuteState:t,muteState:n.muteState,flag:0})}this.userMap.delete(e),this.emit("2",i.userId)}setUserList(e){this.userMap.forEach((t=>{e.findIndex((e=>e[this.key]===t[this.key]))<0&&this.deleteUser(t[this.key],0)})),e.forEach((e=>{!this.userMap.has(e[this.key])&&e[this.key]!==this.mySelfId&&this.addUser(e)}))}addRemotePublishedUser(e){this.remotePublishedUserMap.has(e[this.key])||this.remotePublishedUserMap.set(e[this.key],e)}deleteRemotePublishedUser(e){!this.remotePublishedUserMap.has(e)||this.remotePublishedUserMap.delete(e)}setRemotePublishedUserList(e){this.remotePublishedUserMap.forEach((t=>{let i=t[this.key];if(e.findIndex((e=>e[this.key]===t[this.key]))<0){this._log.info("remote [".concat(i,"] unpublish"));let e=t.muteState;t.flag=0,this.emit("5",t.userId),this.deleteRemotePublishedUser(i),this.emit("6",{prevMuteState:e,muteState:t.muteState,flag:0})}})),e.forEach((e=>{var t;let i=e[this.key];if(i===this.mySelfId)return;let{flag:r,userId:n,tinyId:o}=e,s=qD(r,n),a=null==(t=this.remotePublishedUserMap.get(i))?void 0:t.muteState;if(a){let e=this.remotePublishedUserMap.get(i);e&&e.flag!==r&&(e.flag=r,this._log.info("remote publish updated: ".concat(JSON.stringify(e.muteState))),this.emit("6",{prevMuteState:a,muteState:s,flag:r}))}else this._log.info("remote publish. state: ".concat(JSON.stringify(s))),this.addUser({userId:n,tinyId:o,role:20}),this.emit("3",e),this.emit("6",{prevMuteState:qD(0,n),muteState:s,flag:r})}))}clear(){this.userMap.clear(),this.remotePublishedUserMap.clear()}},LM=!0,PM={SCENE_LIVE:"live",SCENE_RTC:"rtc",ROLE_ANCHOR:"anchor",ROLE_AUDIENCE:"audience",STREAM_TYPE_MAIN:"main",STREAM_TYPE_SUB:"sub",AUDIO_PROFILE_STANDARD:"standard",AUDIO_PROFILE_STANDARD_STEREO:"standard-stereo",AUDIO_PROFILE_HIGH:"high",AUDIO_PROFILE_HIGH_STEREO:"high-stereo",QOS_PREFERENCE_SMOOTH:"smooth",QOS_PREFERENCE_CLEAR:"clear"},MM={INVALID_PARAMETER:5e3,INVALID_OPERATION:5100,ENV_NOT_SUPPORTED:5200,DEVICE_ERROR:5300,SERVER_ERROR:5400,OPERATION_FAILED:5500,OPERATION_ABORT:5998,UNKNOWN_ERROR:5999},xM=((NM=xM||{})[NM.INVALID_PARAMETER=5e3]="INVALID_PARAMETER",NM[NM.INVALID_PARAMETER_REQUIRED=5001]="INVALID_PARAMETER_REQUIRED",NM[NM.INVALID_PARAMETER_TYPE=5002]="INVALID_PARAMETER_TYPE",NM[NM.INVALID_PARAMETER_EMPTY=5003]="INVALID_PARAMETER_EMPTY",NM[NM.INVALID_PARAMETER_INSTANCE=5004]="INVALID_PARAMETER_INSTANCE",NM[NM.INVALID_PARAMETER_RANGE=5005]="INVALID_PARAMETER_RANGE",NM[NM.INVALID_PARAMETER_LESS_THAN_ZERO=5006]="INVALID_PARAMETER_LESS_THAN_ZERO",NM[NM.INVALID_PARAMETER_MIN=5007]="INVALID_PARAMETER_MIN",NM[NM.INVALID_PARAMETER_MAX=5008]="INVALID_PARAMETER_MAX",NM[NM.INVALID_ELEMENT_ID=5009]="INVALID_ELEMENT_ID",NM[NM.INVALID_ELEMENT_ID_TYPE=5010]="INVALID_ELEMENT_ID_TYPE",NM[NM.INVALID_STREAM_ID=5011]="INVALID_STREAM_ID",NM[NM.INVALID_ROOM_ID_STRING=5012]="INVALID_ROOM_ID_STRING",NM[NM.INVALID_ROOM_ID_INTEGER=5013]="INVALID_ROOM_ID_INTEGER",NM[NM.INVALID_STREAM_TYPE=5014]="INVALID_STREAM_TYPE",NM[NM.INVALID_ROOM_ID_REQUIED=5015]="INVALID_ROOM_ID_REQUIED",NM[NM.INVALID_ROOM_ID_INTEGER_STRING=5016]="INVALID_ROOM_ID_INTEGER_STRING",NM[NM.INVALID_OPERATION=5100]="INVALID_OPERATION",NM[NM.INVALID_OPERATION_NOT_JOINED=5101]="INVALID_OPERATION_NOT_JOINED",NM[NM.INVALID_OPERATION_REMOTE_USER_NOT_EXIST=5102]="INVALID_OPERATION_REMOTE_USER_NOT_EXIST",NM[NM.INVALID_OPERATION_STREAM_TYPE_NOT_EXIST=5103]="INVALID_OPERATION_STREAM_TYPE_NOT_EXIST",NM[NM.INVALID_OPERATION_REPEAT_CALL=5104]="INVALID_OPERATION_REPEAT_CALL",NM[NM.INVALID_OPERATION_NEED_VIDEO=5105]="INVALID_OPERATION_NEED_VIDEO",NM[NM.INVALID_OPERATION_NEED_AUDIO=5106]="INVALID_OPERATION_NEED_AUDIO",NM[NM.ENV_NOT_SUPPORTED=5200]="ENV_NOT_SUPPORTED",NM[NM.NOT_SUPPORTED_HTTP=5201]="NOT_SUPPORTED_HTTP",NM[NM.NOT_SUPPORTED_WEBRTC=5202]="NOT_SUPPORTED_WEBRTC",NM[NM.NOT_SUPPORTED_H264_ENCODE=5203]="NOT_SUPPORTED_H264_ENCODE",NM[NM.NOT_SUPPORTED_H264_DECODE=5204]="NOT_SUPPORTED_H264_DECODE",NM[NM.NOT_SUPPORTED_SCREEN_SHARE=5205]="NOT_SUPPORTED_SCREEN_SHARE",NM[NM.NOT_SUPPORTED_SMALL_VIDEO=5206]="NOT_SUPPORTED_SMALL_VIDEO",NM[NM.NOT_SUPPORTED_SEI=5207]="NOT_SUPPORTED_SEI",NM[NM.NOT_SUPPORTED_WEBGL=5208]="NOT_SUPPORTED_WEBGL",NM[NM.NOT_SUPPORTED_CHROME_VERSION=5209]="NOT_SUPPORTED_CHROME_VERSION",NM[NM.DEVICE_ERROR=5300]="DEVICE_ERROR",NM[NM.DEVICE_NOT_FOUND_ERROR=5301]="DEVICE_NOT_FOUND_ERROR",NM[NM.DEVICE_NOT_ALLOWED_ERROR=5302]="DEVICE_NOT_ALLOWED_ERROR",NM[NM.DEVICE_NOT_READABLE_ERROR=5303]="DEVICE_NOT_READABLE_ERROR",NM[NM.DEVICE_OVERCONSTRAINED_ERROR=5304]="DEVICE_OVERCONSTRAINED_ERROR",NM[NM.DEVICE_INVALID_STATE_ERROR=5305]="DEVICE_INVALID_STATE_ERROR",NM[NM.DEVICE_SECURITY_ERROR=5306]="DEVICE_SECURITY_ERROR",NM[NM.DEVICE_ABORT_ERROR=5307]="DEVICE_ABORT_ERROR",NM[NM.CAMERA_RECOVER_FAILED=5308]="CAMERA_RECOVER_FAILED",NM[NM.MICROPHONE_RECOVER_FAILED=5309]="MICROPHONE_RECOVER_FAILED",NM[NM.SERVER_ERROR=5400]="SERVER_ERROR",NM[NM.NEED_TO_BUY=5401]="NEED_TO_BUY",NM[NM.ACCOUNT_NO_MONEY=-100013]="ACCOUNT_NO_MONEY",NM[NM.OPERATION_FAILED=5500]="OPERATION_FAILED",NM[NM.FIREWALL_RESTRICTION=5501]="FIREWALL_RESTRICTION",NM[NM.REJOIN_FAILED=5502]="REJOIN_FAILED",NM[NM.EVENT_HANDLER_ERROR=5503]="EVENT_HANDLER_ERROR",NM[NM.VIDEO_CONTEXT_ERROR=5504]="VIDEO_CONTEXT_ERROR",NM[NM.OPERATION_ABORT=5998]="OPERATION_ABORT",NM[NM.UNKNOWN_ERROR=5999]="UNKNOWN_ERROR",NM),VM=Xb(qb({},jN),{INVALID_PARAMETER(e){let{fnName:t}=e;return"the parameters of the '".concat(t,"' you called does not meet the requirements, please check the API documentation.")},INVALID_PARAMETER_REQUIRED(e){let{key:t,rule:i,fnName:r,value:n}=e;return"'".concat(t||i.name,"' is a required param when calling ").concat(r,"(), received: ").concat(n,".")},INVALID_PARAMETER_TYPE(e){let{key:t,rule:i,fnName:r,value:n}=e,o="".concat(t||i.name),s="";return s=Array.isArray(i.type)?i.type.join("|"):i.type,"'".concat(o,"' must be type of ").concat(s," when calling ").concat(r,"(), received type: ").concat(wD(n),".")},INVALID_PARAMETER_EMPTY(e){let{key:t,rule:i,fnName:r,value:n}=e;return"'".concat(t||i.name,"' cannot be '").concat(n,"' when calling ").concat(r,"().")},INVALID_PARAMETER_INSTANCE(e){let{key:t,rule:i,fnName:r,value:n}=e,o="".concat(t||i.name),s="".concat(i.instanceOf.name||i.instanceOf);return"'".concat(o,"' must be instanceof ").concat(s," when calling ").concat(r,"(), received type: ").concat(wD(n),".")},INVALID_PARAMETER_RANGE(e){let{key:t,rule:i,fnName:r,value:n}=e;return"'".concat(t||i.name,"' must be one of ").concat(i.values.join("|")," when calling ").concat(r,"(), received: ").concat(n,".")},INVALID_PARAMETER_LESS_THAN_ZERO(e){let{key:t,rule:i,fnName:r}=e;return"'".concat(t||i.name,"' cannot be less than 0 when calling ").concat(r,"().")},INVALID_PARAMETER_MIN(e){let{key:t,rule:i,value:r}=e;return"the min value of ".concat(t||i.name," is ").concat(i.min,", received: ").concat(r,".")},INVALID_PARAMETER_MAX(e){let{key:t,rule:i,value:r}=e;return"the max value of ".concat(t||i.name," is ").concat(i.max,", received: ").concat(r,".")},INVALID_ELEMENT_ID(e){let{key:t,fnName:i}=e;return"'".concat(t,"' is not found in the document object when calling ").concat(i,"().")},INVALID_ELEMENT_ID_TYPE(e){let{key:t,fnName:i,type:r}=e;return"the element corresponding to '".concat(t,"' must be instanceof HTMLElement when calling ").concat(i,"(), received: ").concat(r,".")},INVALID_STREAM_ID(e){let{key:t}=e;return"'".concat(t,"' can only consist of uppercase and lowercase english letters (a-zA-Z), numbers (0-9), hyphens and underscores.")},INVALID_ROOM_ID_STRING(e){let{key:t}=e;return"'".concat(t,"' must be a valid string.")},INVALID_ROOM_ID_INTEGER(e){let{key:t}=e;return"'".concat(t,"' must be an integer between [1, 4294967294].")},INVALID_ROOM_ID_INTEGER_STRING(e){let{key:t}=e;return"'".concat(t,"' must be an integer but go a string, use 'parseInt' to convert it or use 'strRoomId' instead.")},INVALID_ROOM_ID_REQUIED:()=>"at least one of 'roomId'(between [1, 4294967294]) and 'strRoomId'(not empty) is required.",INVALID_STREAM_TYPE:e=>{let{fnName:t}=e;return"'streamType' is required when 'userId' is not '*', calling ".concat(t,"()")},INVALID_IMAGE_URL:"The 'src' param must be filled in when the background type is image.",INVALID_OPERATION(e){let{fnName:t}=e;return"the API '".concat(t,"' you called does not meet the requirements, please check the API documentation.")},INVALID_OPERATION_NOT_JOINED(e){let{fnName:t}=e;return"cannot ".concat(t," because you are not enter room yet.")},INVALID_OPERATION_REMOTE_USER_NOT_EXIST(e){let{fnName:t,value:i}=e;return"cannot ".concat(t," because remote user(userId: ").concat(i.userId,") does not publishing stream.")},INVALID_OPERATION_STREAM_TYPE_NOT_EXIST(e){let{fnName:t,value:i}=e;return"cannot ".concat(t," because remote user(userId: ").concat(i.userId,") does not publishing ").concat(i.streamType," video.")},INVALID_OPERATION_REPEAT_CALL(e){let{fnName:t}=e;return"you are already ".concat(t,"(), cannot repeated call '").concat(t,"'.")},INVALID_OPERATION_NEED_VIDEO(e){let{fnName:t}=e;return"cannot call '".concat(t,"' because the camera is not turned on.")},INVALID_OPERATION_NEED_AUDIO(e){let{fnName:t}=e;return"cannot call '".concat(t,"' because the microphone is not turned on.")},ENV_NOT_SUPPORTED(e){let{fnName:t}=e;return"the current browser does not support the capability of the function '".concat(t,"' you are calling, please check the API documentation.")},NOT_SUPPORTED_WEBRTC:"the current browser does not support WebRTC capability, please check the SDK documentation.",NOT_SUPPORTED_H264_ENCODE:"this browser does not support H264 encode.",NOT_SUPPORTED_H264_DECODE:"this browser does not support H264 decode.",NOT_SUPPORTED_SCREEN_SHARE:"this browser does not support screen share, please check the browser version.",NOT_SUPPORTED_SMALL_VIDEO:"this browser does not support small video, please check the browser version.",NOT_SUPPORTED_SEI:"this browser does not support SEI, please check the browser version.",NOT_SUPPORTED_WEBGL:"this browser does not support WebGL, please check the browser version.",NOT_SUPPORTED_CHROME_VERSION(e){let{fnName:t}=e;return"cannot call ".concat(t," because the browser version is too low, please upgrade to the latest version")},DEVICE_ERROR(e){let{fnName:t,error:i}=e;return"'".concat(t,"' got device exception").concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_NOT_FOUND_ERROR(e){let{fnName:t,deviceType:i=UM(t),error:r}=e;return"NotFoundError, no ".concat(i," detected, please check your device and the configuration on '").concat(t,"'").concat(r?", error: ".concat(r.toString(),"."):".")},DEVICE_NOT_ALLOWED_ERROR(e){let{fnName:t,deviceType:i=UM(t),error:r}=e;return"NotAllowedError, you have disabled ".concat(i," access, please allow the current application to use the ").concat(i).concat(r?", error: ".concat(r.toString(),"."):".")},DEVICE_NOT_READABLE_ERROR(e){let{fnName:t,deviceType:i=UM(t),error:r}=e;return"NotReadableError, the ".concat(i," maybe in use by another APP, please check if the device is pre-occupied by another APP.")},DEVICE_OVERCONSTRAINED_ERROR(e){let{fnName:t,deviceType:i=UM(t),error:r}=e;return"OverconstrainedError, the device ID is incorrect, please check whether the device ID passed in is correct".concat(r?", error: ".concat(r.toString(),"."):".")},DEVICE_INVALID_STATE_ERROR(e){let{fnName:t,deviceType:i=UM(t),error:r}=e;return"InvalidStateError, after the user clicks and interacts with the page, turn on the ".concat(i).concat(r?", error: ".concat(r.toString(),"."):".")},DEVICE_SECURITY_ERROR(e){let{fnName:t,deviceType:i=UM(t),error:r}=e;return"SecurityError, check whether the system security policy restricts the use of the ".concat(i,", and it is recommended to turn on the ").concat(i," after the user interacts with the page").concat(r?", error: ".concat(r.toString(),"."):".")},DEVICE_ABORT_ERROR(e){let{fnName:t,deviceType:i=UM(t),error:r}=e;return"AbortError, an unknown exception in the system makes the device unusable, recommended to change the device or browser and re-check whether the device is normal".concat(r?" error: ".concat(r.toString(),"."):".")},CAMERA_RECOVER_FAILED(e){let{error:t}=e;return"camera recover capture failed ".concat((null==t?void 0:t.name)||"",": ").concat((null==t?void 0:t.originMessage)||(null==t?void 0:t.message))},MICROPHONE_RECOVER_FAILED(e){let{error:t}=e;return"microphone recover capture failed ".concat((null==t?void 0:t.name)||"",": ").concat((null==t?void 0:t.originMessage)||(null==t?void 0:t.message))},OPERATION_FAILED(e){let{fnName:t,error:i}=e;return"'".concat(t,"' failed, reason: ").concat(null==i?void 0:i.toString())},FIREWALL_RESTRICTION:()=>"media connection failure due to firewall restrictions, please try to change your network.",EVENT_HANDLER_ERROR(e){let{eventName:t}=e;return"an error was caught on trtc.on('".concat(t,"', handler), please check your code on 'handler'.")},VIDEO_CONTEXT_ERROR(e){let{reason:t,error:i}=e;return"video context error ".concat(t," ").concat((null==i?void 0:i.name)||""," ").concat((null==i?void 0:i.message)||"")},SERVER_ERROR(e){let{fnName:t,error:i}=e;return"'".concat(t,"' got server error: ").concat(null==i?void 0:i.toString(),", please check the SDK documentation.")},NEED_TO_BUY(e){let{value:t,url:i}=e;return"You need to buy packages for ".concat(t,". Refer to: ").concat(i)},ACCOUNT_NO_MONEY:e=>{let{fnParams:t}=e;return"your TRTC account run out of credit, please recharge.".concat(t.sdkAppId?" SDKAppId: ".concat(t.sdkAppId):"")},OPERATION_ABORT(e){let{fnName:t}=e;return"'".concat(t,"' abort")},UNKNOWN_ERROR(e){let{fnName:t,error:i}=e;return"'".concat(t,"' throw unknown exception").concat(i?", error: ".concat(i.toString(),"."):".")}});function UM(e){if(!e)return"camera";let t=e.toLowerCase();return t.includes("screen")?"screen share":t.includes("audio")?"microphone":"camera"}var BM=class extends Error{constructor(e){let{code:t,extraCode:i,message:r="",messageParams:n,fnName:o="",originError:s}=e;var a;let c;c=r||function(e){let t,{code:i,params:r,enableDocLink:n=!1}=e,o="",s=xM[i];try{t=VM[s]}catch(a){t=VM.UNKNOWN_ERROR}return ND(t)?o=t(r):OD(t)&&(o=t),n&&(o+=" doc:"),o}({code:i||t,params:qb({fnName:o,error:s},n)}),super(c),tC(this,"name","RtcError"),tC(this,"code"),tC(this,"extraCode"),tC(this,"functionName"),tC(this,"message"),tC(this,"handler"),tC(this,"originError"),this.name=xM[t],this.code=t,this.extraCode=i,this.functionName=o,this.originError=s,this.message=c,5302===this.extraCode&&(null==(a=this.originError)?void 0:a.message.includes("system"))&&(this.handler=()=>{let e=document.createElement("a");_k?e.href="ms-settings:privacy-".concat({startLocalVideo:"webcam",startLocalAudio:"microphone"}[this.functionName]):fk&&(e.href="x-apple.systempreferences:com.apple.preference.security?Privacy_".concat({startLocalVideo:"Camera",startLocalAudio:"Microphone",startScreenShare:"ScreenCapture"}[this.functionName])),e.href.length>0&&e.click()})}static convertFrom(e,t,i){let r=e;if(e instanceof fC){let{stack:n}=e,o={code:MM.UNKNOWN_ERROR,fnName:t,originError:e};switch(e.getCode()){case _C.INVALID_PARAMETER:o.code=MM.INVALID_PARAMETER,o.message=e.message;break;case _C.INVALID_OPERATION:o.code=MM.INVALID_OPERATION;break;case _C.NOT_SUPPORTED:case _C.NOT_SUPPORTED_H264:o.code=MM.ENV_NOT_SUPPORTED,e.getCode()===_C.NOT_SUPPORTED_H264&&(o.extraCode=e.message.includes(jN.NOT_SUPPORTED_H264ENCODE)?5203:5204);break;case _C.JOIN_ROOM_FAILED:o.messageParams={fnParams:i};case _C.SERVER_TIMEOUT:case _C.SWITCH_ROLE_FAILED:o.code=MM.SERVER_ERROR,o.extraCode=e.getExtraCode();break;case _C.API_CALL_ABORTED:o.code=MM.OPERATION_ABORT;break;case _C.DEVICE_NOT_FOUND:case _C.DEVICE_AUTO_RECOVER_FAILED:case _C.INITIALIZE_FAILED:o.code=5300,e.name&&(o.extraCode=function(e){let t;switch(e){case"NotFoundError":t=5301;break;case"NotAllowedError":t=5302;break;case"NotReadableError":t=5303;break;case"OverconstrainedError":t=5304;break;case"InvalidStateError":t=5305;break;case"SecurityError":t=5306;break;case"AbortError":t=5307;break;default:t=5300}return t}(e.name));break;case _C.UNKNOWN:break;default:o.code=MM.OPERATION_FAILED}r=new BM(o),n&&(r.stack+=n.substr(n.indexOf("\n")))}else{if(e instanceof BM)return e;r=new BM({code:MM.UNKNOWN_ERROR,fnName:t,originError:e})}return r}},FM=BM,HM={type:"object",properties:{cameraId:{type:"string"},useFrontCamera:{type:"boolean"},fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:["string","boolean"],values:[!0,!1,"view","publish","both"]},small:{properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},videoTrack:{instanceOf:MediaStreamTrack}}},jM={type:"object",properties:{systemAudio:{type:"boolean"},fillMode:{type:"string",values:["contain","cover","fill"]},profile:{type:["string","object"],properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},videoTrack:{instanceOf:MediaStreamTrack},audioTrack:{instanceOf:MediaStreamTrack}}},WM={type:["string",HTMLElement,null,"array"],arrayItem:{instanceOf:HTMLElement},validate(e,t,i){if(OD(e)&&!document.getElementById(e))throw new FM({code:MM.INVALID_PARAMETER,extraCode:5009,fnName:i,messageParams:{key:t}})}},zM={name:"userId",required:!0,type:"string"},GM={type:"object",properties:{microphoneId:{type:"string"},audioTrack:{instanceOf:MediaStreamTrack},captureVolume:{type:"number",min:0},earMonitorVolume:{type:"number",min:0,max:100},profile:{values:[PM.AUDIO_PROFILE_STANDARD,PM.AUDIO_PROFILE_STANDARD_STEREO,PM.AUDIO_PROFILE_HIGH,PM.AUDIO_PROFILE_HIGH_STEREO]},echoCancellation:{type:"boolean"},autoGainControl:{type:"boolean"},noiseSuppression:{type:"boolean"}}};function KM(e,t){if(!e)throw new FM({code:MM.INVALID_OPERATION,extraCode:5101,fnName:t})}function YM(e,t,i){if(!e)throw new FM({code:MM.INVALID_OPERATION,extraCode:5102,fnName:t,messageParams:{value:i}})}var JM={TRTC:{create:[{name:"RoomConfig",instanceOf:Function},{name:"CreateConfig",type:"object",properties:{plugins:{type:"array",arrayItem:{instanceOf:Function}}}}],enterRoom:{name:"EnterRoomConfig",type:"object",required:!0,validate(e,t,i){if(this._room.isJoined)throw new FM({code:MM.INVALID_OPERATION,extraCode:5104,fnName:i});if(e.roomId){if(OD(e.roomId))throw new FM({code:MM.INVALID_PARAMETER,extraCode:5016,fnName:i,messageParams:{key:t}});if(!(/^[1-9]\d*$/.test(String(e.roomId))&&e.roomId<4294967295))throw new FM({code:MM.INVALID_PARAMETER,extraCode:5013,fnName:i,messageParams:{key:t}})}else{if(!e.strRoomId)throw new FM({code:MM.INVALID_PARAMETER,extraCode:5015,fnName:i});if(!/^[A-Za-z\d\s!#$%&()+\-:;<=.>?@[\]^_{}|~,]{1,64}$/.test(e.strRoomId))throw new FM({code:MM.INVALID_PARAMETER,extraCode:5012,fnName:i,messageParams:{key:t}})}},properties:{sdkAppId:{required:!0,type:"number",allowEmpty:!1},userId:{required:!0,type:"string",allowEmpty:!1},userSig:{required:!0,type:"string",allowEmpty:!1},scene:{type:"string",values:["live","rtc"]},role:{type:"string",values:["audience","anchor"]},roomId:{type:["string","number"]},strRoomId:{type:"string"},proxy:{type:["object","string"],properties:{websocketProxy:{type:"string"},turnServer:{type:["object","array"],properties:{url:{required:!0,type:"string"},username:{type:"string"},credential:{type:"string"},credentialType:{type:"string",values:["password"]}}},loggerProxy:{type:"string"},webtransportProxy:{type:"string"}}},enableAutoPlayDialog:{type:"boolean"},userDefineRecordId:{type:"string"}}},startLocalVideo:{name:"LocalVideoConfig",type:"object",properties:{view:WM,mute:{type:["boolean","string"]},publish:{type:"boolean"},option:HM},validate(e){var t;if((null==(t=null==e?void 0:e.option)||!t.videoTrack)&&NO())throw new FM({code:MM.ENV_NOT_SUPPORTED,extraCode:5201})}},updateLocalVideo:{name:"updateLocalVideoConfig",type:"object",required:!0,properties:{view:Xb(qb({},WM),{required:!1}),publish:{type:"boolean"},mute:{type:["boolean","string"]},option:HM}},startLocalAudio:{name:"LocalAudioConfig",type:"object",properties:{publish:{type:"boolean"},option:GM},validate(e){var t;if((null==(t=null==e?void 0:e.option)||!t.audioTrack)&&NO())throw new FM({code:MM.ENV_NOT_SUPPORTED,extraCode:5201})}},updateLocalAudio:{name:"updateLocalAudioConfig",type:"object",required:!0,properties:{publish:{type:"boolean"},mute:{type:"boolean"},option:GM}},startScreenShare:{name:"ScreenShareConfig",type:"object",properties:{view:WM,publish:{type:"boolean"},option:jM},validate(e,t,i,r,n){var o;if((null==(o=null==e?void 0:e.option)||!o.videoTrack)&&NO())throw new FM({code:MM.ENV_NOT_SUPPORTED,extraCode:5201});if(!xO())throw new FM({code:MM.ENV_NOT_SUPPORTED,fnName:i,extraCode:5205})}},updateScreenShare:{name:"updateScreenShareConfig",type:"object",required:!0,properties:{view:WM,publish:{type:"boolean"},option:jM}},muteRemoteAudio:[zM,{name:"mute",required:!0,type:"boolean"}],setRemoteAudioVolume:[zM,{name:"volume",required:!0,type:"number",min:0}],startRemoteVideo:{name:"startRemoteVideoConfig",type:"object",required:!0,properties:{view:WM,userId:{type:"string",required:!0},streamType:{values:["main","sub"],required:!0},option:{type:"object",properties:{fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:"boolean"}}}},validate(e,t,i){KM(this._room.isJoined,i);let r=this._room.remotePublishedUserMap.get(e.userId);if(YM(!!r,i,e),r&&("main"===e.streamType&&!r.muteState.videoAvailable||"sub"===e.streamType&&!r.muteState.hasAuxiliary))throw new FM({code:MM.INVALID_OPERATION,extraCode:5103,fnName:i,messageParams:{value:e}})}},updateRemoteVideo:{name:"updateRemoteVideoConfig",type:"object",required:!0,properties:{view:Xb(qb({},WM),{required:!1}),userId:{type:"string",required:!0},streamType:{values:["main","sub"],required:!0},option:{type:"object",properties:{fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:"boolean"}}}},validate(e,t,i){KM(this._room.isJoined,i);let r=this._room.remotePublishedUserMap.get(e.userId);if(YM(!!r,i,e),r&&("main"===e.streamType&&!r.muteState.videoAvailable||"sub"===e.streamType&&!r.muteState.hasAuxiliary))throw new FM({code:MM.INVALID_OPERATION,extraCode:5103,fnName:i,messageParams:{value:e}})}},stopRemoteVideo:{name:"stopRemoteVideoConfig",type:"object",required:!0,properties:{userId:{type:"string",required:!0},streamType:{values:["main","sub"]}},validate(e,t,i){if("*"!==e.userId&&DD(e.streamType))throw new FM({code:MM.INVALID_PARAMETER,extraCode:5014,fnName:i})}},switchRole:{name:"role",required:!0,values:["anchor","audience"],validate(e,t,i){KM(this._room.isJoining||this._room.isJoined,i)}},enableAudioVolumeEvaluation:[{name:"interval",type:"number"},{name:"enableInBackground",type:"boolean"}],sendSEIMessage:[{name:"buffer",required:!0,instanceOf:ArrayBuffer,validate(e,t,i,r){if(!tL)throw new FM({code:MM.ENV_NOT_SUPPORTED,fnName:i,extraCode:5207});if(!this._room.enableSEI)throw new FM({code:MM.INVALID_OPERATION,messageParams:{key:HN.SEI_DISABLED}});if(e.byteLength>1e3)throw new FM({code:MM.INVALID_PARAMETER,messageParams:{key:HN.SEI_OVERSIZE,data:e.byteLength}});if(0===e.byteLength)throw new FM({code:MM.INVALID_PARAMETER,messageParams:{key:HN.SEI_EMPTY}});if(KM(this._room.isJoined,i),!this._room.isMainStreamPublished)throw new FM({code:MM.INVALID_PARAMETER,messageParams:{key:HN.SEI_BEFORE_PUBLISH}})}},{name:"options",type:"object",properties:{seiPayloadType:{type:"number",values:[5,243]}}}]}},qM=class extends Error{};function XM(e,t){let i=eO(e);for(let r=0;r<t.length;r++)$D(i[r],t[r]);return i}function QM(e){this._resolve=Promise.resolve(e)}function ZM(e){this._reject=Promise.reject(e)}var $M=class{constructor(e,t){this.instance=e,this.group=t,this.started=!1,this.ops=[],this.startSame=()=>!0,this.mergeUpdate=XM;let i=$M.instances.get(e);i?i.set(t,this):$M.instances.set(e,new Map([[t,this]]))}static get(e,t){let i=$M.instances.get(e);return i&&i.get(t)||new $M(e,t)}action(e,t,i){let r=t=>{var i;return 0===e?this.started=!0:3===e&&(this.started=!1),this.ops.shift(),null==(i=this.currentOp)||i.action(),t},n=t=>{var i,r;throw this.ops.shift(),0===e&&2===(null==(i=this.currentOp)?void 0:i.type)&&this.ops.shift().reject(new qM("start failed")),null==(r=this.currentOp)||r.action(),t},o={type:e,action:()=>t(...o.args).then(r,n),args:i,resolve:QM,reject:ZM};try{switch(this.state){case 1:if(0===e)throw new qM("already started");break;case 4:if(2===e)throw new qM("not started");break;default:return this.cacheOp(o)}}catch(s){return Promise.reject(s)}return this.ops.push(o),o.promise=t(...o.args).then(r,n)}cacheOp(e){if(1===this.ops.length)switch(this.state){case 0:case 2:if(0===e.type)throw new qM("already start");break;case 3:switch(e.type){case 2:throw new qM("update not allowed when stopping");case 3:return this.currentOp.promise}break;default:throw new qM("unknown state")}else switch(e.type){case 3:if(3===this.lastOpType)return this.lastOp.promise;{let e=new qM("keep stop");if(this.ops.slice(1).forEach((t=>t.reject(e))),this.ops=this.ops.slice(0,1),3===this.state)return this.currentOp.promise}break;case 2:switch(this.lastOpType){case 2:return this.lastOp.args=this.mergeUpdate(this.lastOp.args,e.args),this.lastOp.promise;case 3:throw new qM("update not allowed after stop")}break;case 0:switch(this.lastOpType){case 2:throw new qM("start not allowed after update");case 0:throw new qM("duplicate start");case 3:if(this.startSame(this.currentOp.args,e.args))throw this.ops.pop().reject(new qM("keep start")),new qM("already start")}}e.promise=new Promise(((t,i)=>{e._resolve?e._resolve.then(t):e.resolve=t,e._reject?e._reject.catch(i):e.reject=i}));let{action:t}=e;return e.action=()=>t().then(e.resolve,e.reject),this.ops.push(e),e.promise}get lastOp(){return this.ops[this.ops.length-1]}get lastOpType(){return this.lastOp.type}get currentOp(){return this.ops[0]}get state(){return this.currentOp?this.currentOp.type:this.started?1:4}},ex=$M;ex.instances=new WeakMap;var tx=new WeakMap,ix=(e,t)=>{if(t instanceof qM){let{stack:i}=t;t=new FM({code:MM.OPERATION_ABORT,message:"".concat(e," abort: ").concat(t.message),fnName:e}),i&&(t.stack+=i.substr(i.indexOf("\n")))}throw t};function rx(e,t){return JP(((i,r)=>function(){for(var n=arguments.length,o=new Array(n),s=0;s<n;s++)o[s]=arguments[s];let a=ex.get(this,"string"==typeof e?e:e.call(this,...o));return t&&(a.startSame=t.bind(this)),a.action(0,i.bind(this),o).catch(ix.bind(null,r))}))}function nx(e,t){let{merge:i,debounce:r}=t||{};return JP(((t,n)=>function(){for(var o=arguments.length,s=new Array(o),a=0;a<o;a++)s[a]=arguments[a];let c=ex.get(this,"string"==typeof e?e:e.call(this,...s));if(i&&(c.mergeUpdate=i.bind(this)),r&&r.isNeedToDebounce.apply(this,s)){let{delay:e,getKey:i}=r;return new Promise(((r,o)=>{var a,l;let d=null==(a=tx.get(this))?void 0:a.get(i(...s));if(d){let{timeoutId:e,resolve:t}=d;clearTimeout(e),t()}let u=setTimeout((()=>{if(3===c.state||4===c.state)return r();c.action(2,t.bind(this),s).catch(ix.bind(null,n)).then(r,o)}),e);tx.has(this)?null==(l=tx.get(this))||l.set(i(...s),{timeoutId:u,resolve:r}):tx.set(this,new Map([[i(...s),{timeoutId:u,resolve:r}]]))}))}return c.action(2,t.bind(this),s).catch(ix.bind(null,n))}))}function ox(e){return JP(((t,i)=>function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return ex.get(this,"string"==typeof e?e:e.call(this,...n)).action(3,t.bind(this),n).catch(ix.bind(null,i))}))}var sx={ERROR:"error",AUTOPLAY_FAILED:"autoplay-failed",KICKED_OUT:"kicked-out",REMOTE_USER_ENTER:"remote-user-enter",REMOTE_USER_EXIT:"remote-user-exit",REMOTE_AUDIO_AVAILABLE:"remote-audio-available",REMOTE_AUDIO_UNAVAILABLE:"remote-audio-unavailable",REMOTE_VIDEO_AVAILABLE:"remote-video-available",REMOTE_VIDEO_UNAVAILABLE:"remote-video-unavailable",AUDIO_VOLUME:"audio-volume",NETWORK_QUALITY:"network-quality",CONNECTION_STATE_CHANGED:"connection-state-changed",AUDIO_PLAY_STATE_CHANGED:"audio-play-state-changed",VIDEO_PLAY_STATE_CHANGED:"video-play-state-changed",SCREEN_SHARE_STOPPED:"screen-share-stopped",DEVICE_CHANGED:"device-changed",PUBLISH_STATE_CHANGED:"publish-state-changed",STATISTICS:"statistics",SEI_MESSAGE:"sei-message",TRACK:"track"};function ax(e){return"sub"===e?"auxiliary":"auxiliary"===e?"sub":"main"}function cx(e){return e===PM.QOS_PREFERENCE_CLEAR?"detail":e===PM.QOS_PREFERENCE_SMOOTH?"motion":""}function lx(e,t,i){return{room:e,assetsPath:i,innerEmitter:JN,constants:rw,environment:TC,utils:yC,eventLogger:XN,log:e.getLogger(),errorModule:t,kvStatManager:pP,clearStarted(t,i){let r=t.getAlias(),n=ex.instances.get(e);if(n)if(i){let e=n.get(r+i);if(!e)return;e.started=!1}else n.forEach(((e,t)=>{t.startsWith(r)&&(e.started=!1)}))}}}var dx=new WeakMap;function ux(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return JP(((e,i)=>function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];try{px.call(this,t,n,i,this._name)}catch(s){return Promise.reject(s)}return e.apply(this,n)}))}function hx(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return JP(((e,i)=>function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];try{px.call(this,t,n,i,this._name)}catch(s){throw s}return e.apply(this,n)}))}function px(e,t,i,r){if(xD(e))for(let n=0;n<e.length;n++)mx.call(this,{rule:e[n],value:t[n],key:e[n].name,fnName:i,className:r});else mx.call(this,{rule:e,value:t[0],key:e.name,fnName:i,className:r})}function mx(e){let{rule:t,value:i,key:r,fnName:n,className:o}=e;function s(e){return{code:MM.INVALID_PARAMETER,extraCode:e,fnName:n,messageParams:{key:r,rule:t,value:i}}}if(DD(i)){if(t.required)throw new FM(s(5001));if(DD(t.defaultValue))return void(ND(t.validate)&&t.validate.call(this,i,r,n,o,this));i=t.defaultValue}if(Array.isArray(t.type)){let e=!1;for(let r=0;r<t.type.length;r++)null===t.type[r]&&null===i&&(e=!0),ND(t.type[r])&&i instanceof t.type[r]&&(e=!0),OD(t.type[r])&&wD(i)===t.type[r].toLowerCase()&&(e=!0);if(!e)throw new FM({code:MM.INVALID_PARAMETER,extraCode:5002,fnName:n,messageParams:{key:r,rule:{type:t.type.map((e=>FD(e)?HD(e):OD(e)?e:wD(e)))},value:i}})}else if(!DD(t.type)&&wD(i)!==t.type)throw new FM(s(5002));if(!1===t.allowEmpty){let e=LD(i)&&(0===i||Number.isNaN(i)),t=OD(i)&&""===i.trim();if(e||t)throw new FM(s(5003))}if(t.notLessThanZero&&LD(i)&&i<0)throw new FM(s(5006));if(!DD(t.min)&&LD(i)&&i<t.min)throw new FM(s(5007));if(!DD(t.max)&&LD(i)&&i>t.max)throw new FM(s(5008));if(OD(t.instanceOf)){if(!i||i._name!==t.instanceOf)throw new FM(s(5004))}else if(ND(t.instanceOf)&&!(i instanceof t.instanceOf))throw new FM(s(5004));if(Array.isArray(t.values)&&!t.values.includes(i))throw new FM(s(5005));let{properties:a}=t;bD(a)&&MD(i)&&Object.keys(a).forEach((e=>{mx.call(this,{rule:a[e],value:i&&i[e],key:"".concat(e),fnName:n,className:o})}));let{arrayItem:c}=t;bD(c)&&xD(i)&&i.forEach(((e,t)=>{mx.call(this,{rule:c,value:e,key:"".concat(r,"[").concat(t,"]"),fnName:n,className:o})})),ND(t.validate)&&t.validate.call(this,i,r,n,o,this)}function _x(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{getRemoteId:t=(()=>""),replaceArg:i,getKVReportKey:r}=e;return JP(((e,n)=>function(){for(var o=arguments.length,s=new Array(o),a=0;a<o;a++)s[a]=arguments[a];function c(e,t,r){if(r&&r.includes(e))return"hided";if(i){let e=i(...s);if(s[e.argIndex]===t)return e.value}if(t===s||e in s)return t;try{return t instanceof HTMLElement?"id: ".concat(t.id," type:").concat(wD(t)):(JSON.stringify(t),t)}catch(n){return"type:".concat(wD(t))}}let l=this._log||EO;s.length>0?l.info("".concat(n,"() ").concat(JSON.stringify(s,((e,t)=>c(e,t,["userSig","privateMapKey"]))))):l.info("".concat(n,"()"));let d=r?r(...s):oP[n];try{let i=e.apply(this,s),r=zD();return BD(i)?i.then((e=>(l.info("".concat(n,"() success ").concat(t.call(this,...s))),pP.addSuccessEvent({key:d,cost:zD()-r}),e))).catch((e=>{throw e=FM.convertFrom.call(this,e,n,1===s.length?s[0]:s),l.error("".concat(n,"() failed ").concat(t.call(this,...s)," ").concat(e," params: ").concat(JSON.stringify(s,c))),pP.addFailedEvent({key:d,error:e}),e})):(pP.addSuccessEvent({key:d}),i)}catch(u){throw u=FM.convertFrom.call(this,u,n),l.error("".concat(n,"() failed ").concat(u," params: ").concat(JSON.stringify(s,c))),pP.addFailedEvent({key:d,error:u}),u}}))}var fx=e=>JP(((t,i)=>function(r,n){return rC(this,null,(function*(){let o=this._plugins.get(r);if(o)return px.call(this,o.getValidateRule(e),[n],i,"TRTC"),t.call(this,o,n);this._log.warn("plugin ".concat(r," is not found"))}))})),gx=0,Ex=class{constructor(e,t){tC(this,"player"),tC(this,"publisher"),tC(this,"mixInput"),this.mixInput=new gP(t),e.url?(this.player=new Audio(e.url),this.player.crossOrigin="anonymous",this.publisher=new Audio(e.url),this.publisher.crossOrigin="anonymous",this.mixInput.replaceSource(this.publisher)):this.mixInput.replaceSource(e.track),this.mixInput.connect()}reset(){this.seek(0),this.mixInput.connect()}seek(e){!this.player||e<0&&e>this.player.duration||(this.player.currentTime=e,this.publisher.currentTime=e)}play(){var e,t;return null==(e=this.publisher)||e.play(),null==(t=this.player)?void 0:t.play()}pause(){var e,t;null==(e=this.player)||e.pause(),null==(t=this.publisher)||t.pause()}stop(){var e;null==(e=this.player)||e.pause(),this.mixInput.disconnect()}setOperation(e){"pause"===e&&this.pause(),"resume"===e&&(this.pause(),this.play()),"stop"===e&&(this.pause(),this.seek(0))}set volume(e){!this.player||!this.publisher||(this.player.volume=e,this.publisher.volume=e)}set loop(e){!this.player||!this.publisher||(this.player.loop=e,this.publisher.loop=e)}},vx=class{constructor(e){this.core=e,tC(this,"log"),tC(this,"mixedMusicMap",new Map),tC(this,"cacheMusicMap",new Map),gx+=1,this.log=e.log.createChild({id:"".concat(this.getAlias()).concat(gx)}),this.log.info("[audioMixer] created id=".concat(this.getAlias()).concat(gx)),this.core=e}getName(){return"AudioMixer"}getAlias(){return"ax"}getGroup(e){return null==e?void 0:e.id}getValidateRule(e){switch(e){case"start":return vx.startValidateRule;case"update":return vx.updateValidateRule;case"stop":return vx.stopValidateRule}}start(e){return rC(this,null,(function*(){let{room:t}=this.core;this.log.info("add music source, id: ".concat(e.id," url: ").concat(e.url,", track: ").concat(e.track));let{id:i,url:r}=e;if(this.mixedMusicMap.has(i))return;let n=this.cacheMusicMap.get(i);n?e.url?n.reset():(n.mixInput.replaceSource(e.track),n.mixInput.connect()):(n=new Ex(e,t.audioManager),this.cacheMusicMap.set(i,n)),yield n.play(),this.mixedMusicMap.set(i,n),this.log.info("start mix audio track ".concat(i," success.")),pP.addEnum({key:502700,value:3})}))}update(e){return rC(this,null,(function*(){let{id:t,volume:i,loop:r,operation:n,seekFrom:o}=e;this.log.info("update music source, ".concat(JSON.stringify(e)));let s=this.mixedMusicMap.get(t);s?(DD(i)||(s.volume=i),DD(r)||(s.loop=r),DD(n)||s.setOperation(n),DD(o)||s.seek(o)):this.log.warn("update music source failed, music id: ".concat(t," not found."))}))}stop(e){return rC(this,arguments,(function(e){var t=this;let{id:i}=e;return function*(){var e;t.mixedMusicMap.has(i)&&(t.log.info("remove music source, music id: ".concat(i)),null==(e=t.mixedMusicMap.get(i))||e.stop(),t.mixedMusicMap.delete(i)),"*"===i&&t.destroyAllMusic()}()}))}destroyAllMusic(){this.log.info("destroy all music source."),this.mixedMusicMap.forEach(((e,t)=>this.stop({id:t})))}destroyAllCache(){this.log.info("destroy all music cache."),this.cacheMusicMap.clear()}destroy(){this.log.info("destroy audio mixer plugin."),this.destroyAllMusic(),this.destroyAllCache()}},yx=vx;tC(yx,"startValidateRule",{name:"options",required:!0,type:"object",properties:{id:{type:"string",required:!0},url:{type:"string",required:!1},track:{required:!1},loop:{type:"boolean"},volume:{type:"number"}},validate(e,t,i){if(e.url&&"*"!==e.url){let t=e.url.split("?")[0],r=["mp3","ogg","wav","flac"],n=t.split(".").pop(),o=r.indexOf(n)>=0,s=t.startsWith("blob"),a=t.startsWith("data");if(!(o||s||a))throw new FM({code:MM.INVALID_PARAMETER,message:"start audioMixer plugin: music url is invalid, please check your file format.",fnName:i})}if(!e.url&&!e.track)throw new FM({code:MM.INVALID_PARAMETER,message:"start audioMixer plugin: param url or track is required.",fnName:i})}}),tC(yx,"updateValidateRule",{name:"options",required:!0,type:"object",properties:{id:{type:"string",required:!0},loop:{type:"boolean"},volume:{type:"number"},seekFrom:{type:"number"},operation:{type:"string",values:["pause","resume","stop"]}}}),tC(yx,"stopValidateRule",{name:"options",type:"object",required:!0,properties:{id:{type:"string",required:!0}}});var Tx=e=>(e=Number(e))>0&&e<14e8,Sx=0,Ix=class{constructor(e){this.core=e,tC(this,"log"),tC(this,"workletReady"),tC(this,"audioContext",rP()),tC(this,"workletNode"),Sx+=1,this.log=e.log.createChild({id:"".concat(this.getAlias()).concat(Sx)}),this.log.info("[audioDenoiser] created id=".concat(this.getAlias()).concat(Sx)),e.assetsPath&&(this.workletReady=QL(this.audioContext,"".concat(e.assetsPath,"/denoiser-wasm.js")),this.workletReady.catch((t=>{this.log.error("Init assets from ".concat(e.assetsPath," failed! Reason: ").concat(t))})))}static startValidateRule(e){return{name:"options",required:!0,type:"object",properties:{sdkAppId:{type:"number",required:!0},userId:{type:"string",required:!0},userSig:{type:"string",required:!0}},validate(t,i,r,n){if(!e.room.audioManager.hasAudioTrack)throw new FM({code:MM.INVALID_OPERATION,extraCode:5106,fnName:r})}}}getName(){return"AIDenoiser"}getAlias(){return"ad"}getGroup(){return"AIDenoiser_".concat(Date.now())}getValidateRule(e){switch(e){case"start":return Ix.startValidateRule(this.core);case"update":return Ix.updateValidateRule;case"stop":return Ix.stopValidateRule}}start(e){return rC(this,null,(function*(){let{room:t}=this.core;if(this.workletReady||(this.workletReady=QL(this.audioContext,"".concat(e.assetsPath,"/denoiser-wasm.js")),this.workletReady.catch((t=>{this.log.error("Init assets from ".concat(e.assetsPath," failed! Reason: ").concat(t))}))),!this.workletNode){let t=String(Date.now()).slice(0,-3),{auth:i,sign:r,status:n,message:o}=yield function(e){return rC(this,arguments,(function(e){let{sdkAppId:t,userId:i,userSig:r,timestamp:n}=e;return function*(){let e="https://".concat(function(e){let t;return t=Tx(e)?Rx.MAIN_OVERSEA:Rx.MAIN,t}(t),"/api/v1/audioAiAuth?sdkAppId=").concat(t,"&userId=").concat(i,"&userSig=").concat(r,"&timestamp=").concat(n),o=yield fetch(e),{data:{errCode:s,errMsg:a,sign:c,status:l}}=yield o.json();if("1"===l)return{auth:!0,sign:c,status:l,message:a};let d="Init RTCAIDenoiser failed.",u="";switch(s){case 1:u="Please check your params.";break;case 2:u="You need to buy packages. Refer to: https://cloud.tencent.com/document/product/647/44247";break;case 3:u="Server is invalid. Please contact our engineer. ";break;case 4:u="Your packages is not active. Refer to: https://cloud.tencent.com/document/product/647/44247";break;case 5:u="Your packages is expired. Refer to: https://cloud.tencent.com/document/product/647/44247";break;case 6:u="Your version is not supported."}return{auth:!1,status:l,message:a?"".concat(d," Reason: ").concat(a,". ").concat(u):"".concat(d,", ").concat(u)}}()}))}(Xb(qb({},e),{timestamp:t}));if(!i)throw this.log.info("RTCAIDenoiser: ".concat(e.userId," auth result: ").concat(i,". Message: ").concat(o)),new FM({code:MM.INVALID_PARAMETER,message:o});yield this.workletReady,this.workletNode=new AudioWorkletNode(this.audioContext,"trtc-denoiser-processor",{numberOfInputs:1,numberOfOutputs:1}),this.workletNode.port.postMessage({type:"init",data:{sdkAppId:String(e.sdkAppId),userId:e.userId,timestamp:t,sign:r,status:n}}),this.workletNode.port.onmessage=e=>{let{data:t}=e;"cost"===t.type&&this.log.debug("[RTCAIDenoiser] ".concat(t.value))}}this.workletNode.port.postMessage({type:"enable"}),t.audioManager.addDenoiser(this.workletNode),t.sendAbilityStatus({ai_denoise:1})}))}update(){return rC(this,null,(function*(){}))}stop(){return rC(this,null,(function*(){if(!this.workletNode)return;let{room:e}=this.core;this.workletNode.port.postMessage({type:"disable"}),yield e.audioManager.removeDenoiser(this.workletNode)}))}destroy(){}},Ax=Ix;tC(Ax,"updateValidateRule",{type:"object"}),tC(Ax,"stopValidateRule",{type:"object"});var Rx={MAIN:"schedule.cloud-rtc.com",MAIN_OVERSEA:"schedule.rtc.tencentcloud.com"},bx=0,Cx=new Set,kx=null;sw("5.5.0");var wx=class extends pC.EventEmitter{constructor(e,t){super(),tC(this,"_room"),tC(this,"_eventListened",new Set),tC(this,"_localVideoTrack",null),tC(this,"_localAudioTrack",null),tC(this,"_localScreenTrack",null),tC(this,"_localScreenAudioTrack",null),tC(this,"_localVideoConfig",null),tC(this,"_localScreenConfig",null),tC(this,"_localAudioConfig",null),tC(this,"_remoteVideoConfigMap",new Map),tC(this,"_remoteAudioConfigMap",new Map),tC(this,"_remoteAudioMuteMap",new Map),tC(this,"_mediaTrackMap",new WeakMap),tC(this,"_log",EO.createLogger({id:"t".concat(++bx)})),tC(this,"_plugins",new Map),tC(this,"_networkQuality",null),tC(this,"_speakerId"),this._room=new e(qb({logger:this._log,frameWorkType:wx.frameWorkType},t)),this._log.debug(JSON.stringify(t)),Object.defineProperties(this,{dumpAudio:{enumerable:!1,value(e){return this._room.audioManager.dump(e)}}});let i={RtcError:FM,ErrorCode:MM,ErrorCodeDictionary:xM};t.plugins&&t.plugins.forEach((e=>{let r=new e(lx(this._room,i,t.assetsPath));this._plugins.set(r.getName(),r)}));let r=new yx(lx(this._room,i,t.assetsPath));this._plugins.set(r.getName(),r);let n=new Ax(lx(this._room,i,t.assetsPath));this._plugins.set(n.getName(),n),this._room.on("audio-volume",(e=>{!e.find((e=>""===e.userId))&&this._localAudioTrack&&e.push({userId:"",volume:Math.floor(100*this._localAudioTrack.getAudioLevel())}),this.emit(sx.AUDIO_VOLUME,{result:e.sort(((e,t)=>t.volume-e.volume))})})),this._room.videoManager.on("error",(e=>{let{reason:t,error:i}=e;this._log.error(new FM({code:MM.OPERATION_FAILED,extraCode:5504,messageParams:{reason:t,error:i}}))})),this._listenEvents(),this._initActiveSpeaker(),((e,t)=>{let{emit:i}=e;e.emit=function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];try{return i.apply(e,n)}catch(s){let e=GN({key:HN.CATCH_HANDLER_ERROR,data:{name:t,event:n[0]},addDocLink:!1});return EO.warn("".concat(e,"\n\n").concat(s.stack)),!1}}})(this,"trtc")}static create(e){}static _create(e,t){var i;LM&&(LM=!1,5!==EO.getLogLevel()&&("* API Document: ".concat(vw,"/en/index.html"),"* Changelog: ".concat(vw,"/en/tutorial-01-info-changelog.html")),EO.info("TRTC Web SDK Version:",ow),EO.info("UA:",navigator.userAgent),EO.info("URL: ".concat(location.href).concat("IFRAME"===(null==(i=self.frameElement)?void 0:i.tagName)?" in iframe":"")),$k().then((e=>{if(e){let t="UAData: ".concat(e.platform,"/").concat(e.platformVersion);e.architecture&&e.bitness&&(t+=" ".concat(e.architecture,"/").concat(e.bitness)),e.mobile&&(t+=" mobile"),e.model&&(t+=" model: ".concat(e.model)),e.fullVersionList&&(t+=" ".concat(e.fullVersionList.filter((e=>"Not/A)Brand"!==e.brand)).map((e=>"".concat(e.brand,"/").concat(e.version))).join(","))),EO.info(t)}})));let r=new wx(e,t||{});return Cx.add(r),r}_listenEvents(){YL(this,this._room).add("peer-join",(e=>{let{userId:t}=e;this.emit(sx.REMOTE_USER_ENTER,{userId:t})})).add("peer-leave",(e=>{this.emit(sx.REMOTE_USER_EXIT,{userId:e})})).add("banned",(e=>{this._exitRoom().then((()=>{this.emit(sx.KICKED_OUT,{reason:e.reason})}))})).add("error",(e=>{this._exitRoom().then((()=>{this.emit(sx.ERROR,FM.convertFrom(e))}))})).add("signal-connection-state-changed",(e=>{this.emit(sx.CONNECTION_STATE_CHANGED,e)})).add("network-quality",(e=>{this._networkQuality=e,this.emit(sx.NETWORK_QUALITY,e)})).add("remote-published",(e=>{[e.remoteAudioTrack,e.remoteVideoTrack,e.remoteAuxiliaryTrack].forEach((t=>{YL(t,t).add("player-state-changed",(i=>{let r=Xb(qb({},i),{userId:e.userId});t.kind===Mw.VIDEO&&(r.streamType=ax(t.streamType)),this.emit(t.kind===Mw.AUDIO?sx.AUDIO_PLAY_STATE_CHANGED:sx.VIDEO_PLAY_STATE_CHANGED,r)})).add("error",(e=>{e.getCode()===_C.PLAY_NOT_ALLOWED&&this.emit(sx.AUTOPLAY_FAILED,{userId:t.userId})}))}))})).add("remote-unpublished",(e=>{[e.remoteAudioTrack,e.remoteVideoTrack,e.remoteAuxiliaryTrack].forEach((e=>{JL(e)}))})).add("remote-publish-state-changed",(e=>{let{prevMuteState:t,muteState:i}=e,{userId:r}=i,n=t.audioAvailable,o=t.videoAvailable,{audioAvailable:s,videoAvailable:a}=i;s||this._remoteAudioConfigMap.delete(r),a||this._remoteVideoConfigMap.delete("".concat(r,"_","main")),i.hasAuxiliary||this._remoteVideoConfigMap.delete("".concat(r,"_","sub")),n!==s&&(this.emit(s?sx.REMOTE_AUDIO_AVAILABLE:sx.REMOTE_AUDIO_UNAVAILABLE,{userId:r}),s?this._onAudioAvailable({userId:r}):this._onAudioUnavailable({userId:r,muteState:i})),o!==a&&(this.emit(a?sx.REMOTE_VIDEO_AVAILABLE:sx.REMOTE_VIDEO_UNAVAILABLE,{userId:r,streamType:"main"}),a?this._onVideoAvailable({userId:r,streamType:"main"}):this._onVideoUnavailable({userId:r,streamType:"main"})),t.hasAuxiliary!==i.hasAuxiliary&&(this.emit(i.hasAuxiliary?sx.REMOTE_VIDEO_AVAILABLE:sx.REMOTE_VIDEO_UNAVAILABLE,{userId:r,streamType:"sub"}),i.hasAuxiliary?this._onVideoAvailable({userId:r,streamType:"sub"}):this._onVideoUnavailable({userId:r,streamType:"sub"}))})).add("firewall-restriction",(()=>{this.emit(sx.ERROR,new FM({code:MM.OPERATION_FAILED,extraCode:5501}))})).add("sei-message",(e=>{this.emit(sx.SEI_MESSAGE,Xb(qb({},e),{streamType:ax(e.streamType)}))})).add("heartbeat-report",(e=>{var t,i,r,n,o,s,a;let c={2:"big",3:"small",7:"sub"},l={rtt:e.msg_up_stream_info.msg_network_status.uint32_rtt||(null==(t=e.msg_down_stream_info[0])?void 0:t.msg_network_status.uint32_rtt)||(null==(i=this._networkQuality)?void 0:i.uplinkRTT)||(null==(r=this._networkQuality)?void 0:r.downlinkRTT)||0,upLoss:(null==(n=this._networkQuality)?void 0:n.uplinkLoss)||0,downLoss:(null==(o=this._networkQuality)?void 0:o.downlinkLoss)||0,bytesSent:e.bytes_sent||0,bytesReceived:e.bytes_received||0,localStatistics:{audio:{bitrate:((null==(s=e.msg_up_stream_info.msg_audio_status)?void 0:s.uint32_audio_codec_bitrate)||0)/1e3,audioLevel:((null==(a=e.msg_up_stream_info.msg_audio_status)?void 0:a.uint32_audio_level)||0)/UN},video:e.msg_up_stream_info.msg_video_status.filter((e=>c[e.uint32_video_stream_type])).map((e=>({bitrate:(e.uint32_video_codec_bitrate||0)/1e3,width:e.uint32_video_width,height:e.uint32_video_height,frameRate:e.uint32_video_enc_fps,videoType:c[e.uint32_video_stream_type]})))},remoteStatistics:e.msg_down_stream_info.map((e=>({userId:e.msg_user_info.str_identifier,audio:{bitrate:(e.msg_audio_status.uint32_audio_codec_bitrate||0)/1e3,audioLevel:(e.msg_audio_status.uint32_audio_level||0)/UN},video:e.msg_video_status.map((e=>({bitrate:(e.uint32_video_codec_bitrate||0)/1e3,width:e.uint32_video_width,height:e.uint32_video_height,frameRate:e.uint32_video_dec_fps,videoType:c[e.uint32_video_stream_type]})))})))};this.emit(sx.STATISTICS,l)})),YL(this,PP).add("audioInputAdded",(e=>{this.emit(sx.DEVICE_CHANGED,{type:"microphone",action:"add",device:e})})).add("audioInputRemoved",(e=>{this.emit(sx.DEVICE_CHANGED,{type:"microphone",action:"remove",device:e})})).add("videoInputAdded",(e=>{this.emit(sx.DEVICE_CHANGED,{type:"camera",action:"add",device:e})})).add("videoInputRemoved",(e=>{this.emit(sx.DEVICE_CHANGED,{type:"camera",action:"remove",device:e})})).add("audioOutputAdded",(e=>rC(this,null,(function*(){if(this.emit(sx.DEVICE_CHANGED,{type:"speaker",action:"add",device:e}),kx&&kx.deviceId===CN){let e=(yield BP()).find((e=>e.deviceId===CN));e&&kx.groupId!==e.groupId&&(kx=e,this.emit(sx.DEVICE_CHANGED,{type:"speaker",action:"active",device:e}))}})))).add("audioOutputRemoved",(e=>rC(this,null,(function*(){this.emit(sx.DEVICE_CHANGED,{type:"speaker",action:"remove",device:e});let t=(yield BP())[0];t&&kx&&(kx.deviceId===e.deviceId||kx.deviceId===CN&&kx.groupId!==t.groupId)&&(kx=t,this.emit(sx.DEVICE_CHANGED,{type:"speaker",action:"active",device:t}))}))))}enterRoom(e){return rC(this,null,(function*(){var t,i;let{scene:r="rtc",enableAutoPlayDialog:n=!0,autoReceiveAudio:o=!0,autoReceiveVideo:s=!0}=e;e.proxy&&(this._room.setProxyServer(e.proxy),!OD(e.proxy)&&e.proxy.turnServer&&(null==(i=(t=this._room).setTurnServer)||i.call(t,e.proxy.turnServer,e.proxy.iceTransportPolicy))),this._room.enableAutoPlayDialog=n,this._room.autoReceiveAudio=o,this._room.autoReceiveVideo=s,PD(e.enableHWEncoder)&&(this._room.enableHWEncoder=e.enableHWEncoder);let a={sdkAppId:e.sdkAppId,userId:e.userId,userSig:e.userSig,privateMapKey:e.privateMapKey||null,role:"audience"===e.role?21:20,roomId:e.roomId||0,strRoomId:e.strRoomId||"",businessInfo:e.businessInfo||null,streamId:null,userDefineRecordId:e.userDefineRecordId||null,frameWorkType:e.frameWorkType,component:e.component,language:e.language};e.strRoomId&&!e.roomId&&(this._room.useStringRoomId=!0),yield this._room.join(a,r,wx.frameWorkType),this._checkTrackToPublish()}))}exitRoom(){return rC(this,null,(function*(){return yield this._exitRoom()}))}switchRole(e,t){return rC(this,null,(function*(){null!=t&&t.privateMapKey&&(this._room.privateMapKey=t.privateMapKey),yield this._room.switchRole(e),"anchor"===e&&this._checkTrackToPublish()}))}destroy(){JL(this),this.removeAllListeners(),this._room.destroy(),Cx.delete(this),this._localAudioTrack&&this.stopLocalAudio(),this._localVideoTrack&&this.stopLocalVideo(),this._localScreenTrack&&this.stopScreenShare(),this._plugins.forEach((e=>e.destroy()))}startLocalAudio(){return rC(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0};return function*(){if(e._localAudioTrack)return void e._log.warn("local audio is already started");let{publish:i=!0,mute:r,option:n}=t,o=new iM(e._room.audioManager),s={},a={muted:!0};n&&(DD(n.microphoneId)?DD(n.audioTrack)||(s.customSource=n.audioTrack):s.deviceId=n.microphoneId,n&&LD(n.captureVolume)&&o.setCaptureVolume(n.captureVolume),DD(n.profile)||(OD(n.profile)?Ow[n.profile]&&o.setProfile(Ow[n.profile]):o.setProfile(n.profile)),LD(n.earMonitorVolume)&&(a.muted=!(n.earMonitorVolume>0),a.volume=n.earMonitorVolume),DD(n.echoCancellation)||(o.profile.echoCancellation=n.echoCancellation),DD(n.noiseSuppression)||(o.profile.noiseSuppression=n.noiseSuppression),DD(n.autoGainControl)||(o.profile.autoGainControl=n.autoGainControl)),o.on("5",(t=>{e.emit(sx.ERROR,new FM({code:MM.DEVICE_ERROR,extraCode:5309,messageParams:{error:t}}))})),o.on("2",(t=>{e.emit(sx.DEVICE_CHANGED,{type:"microphone",action:"active",device:t})})),o.on("4",(t=>{let i;t.error&&(i=FM.convertFrom(t.error)),e.emit(sx.PUBLISH_STATE_CHANGED,Xb(qb({},t),{error:i}))})),e._listenOutputTrackChanged(o),e._speakerId&&o.setAudioOutput(e._speakerId),yield o.capture(s),DD(r)||o.setMute(r),YL(o,o).add("player-state-changed",(t=>{e.emit(sx.AUDIO_PLAY_STATE_CHANGED,Xb(qb({},t),{userId:""}))})),i&&e._room.isJoined&&e._room.publish(o).catch((()=>{})),e._localAudioTrack=o,e._localAudioConfig=Xb(qb({},t),{publish:i}),yield e._updateAudioPlayOption({playOption:a,track:o})}()}))}updateLocalAudio(e){return rC(this,null,(function*(){if(!this._localAudioTrack||!this._localAudioConfig)return;let{publish:t,mute:i,option:r}=e,n={};r&&(r.microphoneId?yield this._localAudioTrack.switchDevice(r.microphoneId):DD(r.audioTrack)||(yield this._localAudioTrack.setInputMediaStreamTrack(r.audioTrack)),DD(r.captureVolume)||this._localAudioTrack.setCaptureVolume(r.captureVolume),DD(r.earMonitorVolume)||(n.muted=!(r.earMonitorVolume>0),n.volume=r.earMonitorVolume),yield this._localAudioTrack.update3A(r)),this._room.isJoined&&!DD(t)&&(t&&!this._localAudioConfig.publish&&this._room.publish(this._localAudioTrack).catch((()=>{})),this._localAudioConfig.publish&&!t&&this._room.unpublish(this._localAudioTrack).catch((()=>{}))),DD(i)||this._localAudioTrack.setMute(i),yield this._updateAudioPlayOption({playOption:n,track:this._localAudioTrack,prevConfig:this._localAudioConfig}),$D(this._localAudioConfig,e)}))}stopLocalAudio(){return rC(this,null,(function*(){!this._localAudioTrack||(this._room.isJoined&&(yield this._room.unpublish(this._localAudioTrack).catch((()=>{}))),this._localAudioTrack.stop(),this._localAudioTrack.close(),this._room.audioManager.removeInput(this._localAudioTrack),JL(this._localAudioTrack),this._localAudioTrack=null,this._localAudioConfig=null)}))}startLocalVideo(){return rC(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0,view:null};return function*(){if(e._localVideoTrack)return void e._log.warn("local video is already started");let{view:i,publish:r=!0,mute:n,option:o}=t,s=new rM(e._room.videoManager),a={},c={};if(o&&(o.cameraId?a.deviceId=o.cameraId:DD(o.useFrontCamera)?DD(o.videoTrack)||(a.customSource=o.videoTrack):a.facingMode=o.useFrontCamera?Mw.FACING_MODE_USER:Mw.FACING_MODE_ENVIRONMENT,DD(o.profile)||(OD(o.profile)?Lw[o.profile]&&s.setProfile(Lw[o.profile]):s.setProfile(o.profile)),DD(o.fillMode)||(c.objectFit=o.fillMode),DD(o.mirror)||(c.mirror=o.mirror),DD(o.small)||(WO()?OD(o.small)?s.small=Lw[o.small]:!0===o.small?s.small=Lw["120p"]:s.small=o.small:e._log.warn("small stream is not supported"))),s.on("5",(t=>{e.emit(sx.ERROR,new FM({code:MM.DEVICE_ERROR,extraCode:5308,messageParams:{error:t}}))})),s.on("2",(t=>{e.emit(sx.DEVICE_CHANGED,{type:"camera",action:"active",device:t})})),s.on("4",(t=>{let i;t.error&&(i=FM.convertFrom(t.error)),e.emit(sx.PUBLISH_STATE_CHANGED,Xb(qb({},t),{error:i}))})),e._listenOutputTrackChanged(s),yield s.capture(a),DD(n)||(yield s.setMute(n)),(null==o?void 0:o.qosPreference)&&s.mediaTrack){let e=cx(o.qosPreference);s.mediaTrack.contentHint=e}YL(s,s).add("player-state-changed",(t=>{e.emit(sx.VIDEO_PLAY_STATE_CHANGED,Xb(qb({},t),{userId:"",streamType:"main"}))})),r&&e._room.isJoined&&e._room.publish(s).catch((()=>{})),e._localVideoTrack=s,e._localVideoConfig=Xb(qb({},t),{view:i,publish:r}),yield e._updateVideoPlayOption({view:i,playOption:c,track:s})}()}))}updateLocalVideo(e){return rC(this,null,(function*(){if(!this._localVideoTrack||!this._localVideoConfig)return;let{view:t,publish:i,mute:r,option:n}=e,o={};if(n){if(DD(n.profile)||(OD(n.profile)?Lw[n.profile]&&this._localVideoTrack.setProfile(Lw[n.profile]):this._localVideoTrack.setProfile(n.profile),(!n.cameraId||!this._localVideoTrack.isNeedToSwitchDevice(n.cameraId))&&DD(n.useFrontCamera)&&this._localVideoTrack.applyProfile()),n.cameraId?yield this._localVideoTrack.switchDevice(n.cameraId):DD(n.useFrontCamera)?DD(n.videoTrack)||(yield this._localVideoTrack.setInputMediaStreamTrack(n.videoTrack)):yield this._localVideoTrack.switchDevice(n.useFrontCamera?Mw.FACING_MODE_USER:Mw.FACING_MODE_ENVIRONMENT),DD(n.fillMode)||(o.objectFit=n.fillMode),DD(n.mirror)||(o.mirror=n.mirror),n.qosPreference&&this._localVideoTrack.mediaTrack){let e=cx(n.qosPreference);this._localVideoTrack.mediaTrack.contentHint=e}if(n.small){let e=!this._localVideoTrack.small;WO()?(!0===n.small?this._localVideoTrack.small=Lw["120p"]:OD(n.small)?this._localVideoTrack.small=Lw[n.small]:this._localVideoTrack.small=n.small,this._room.videoManager.update(),e&&this._room.enableSmall(!0)):this._log.warn("small stream is not supported")}else!1===n.small&&this._localVideoTrack.small&&(delete this._localVideoTrack.small,this._room.videoManager.update(),this._room.enableSmall(!1))}this._room.isJoined&&!DD(i)&&(i&&!this._localVideoConfig.publish&&this._room.publish(this._localVideoTrack).catch((()=>{})),this._localVideoConfig.publish&&!i&&this._room.unpublish(this._localVideoTrack).catch((()=>{}))),DD(r)||(yield this._localVideoTrack.setMute(r)),yield this._updateVideoPlayOption({view:t,playOption:o,track:this._localVideoTrack,prevConfig:this._localVideoConfig}),$D(this._localVideoConfig,e)}))}stopLocalVideo(){return rC(this,null,(function*(){!this._localVideoTrack||(this._room.isJoined&&(yield this._room.unpublish(this._localVideoTrack).catch((()=>{}))),this._localVideoTrack.stop(),this._localVideoTrack.close(),JL(this._localVideoTrack),this._localVideoTrack=null,this._localVideoConfig=null)}))}startScreenShare(){return rC(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0,view:null};return function*(){if(e._localScreenTrack)return void e._log.warn("screen share is already started");let{view:i=null,publish:r=!0,option:n}=t,o=new aM(e._room.videoManager);o.on("4",(t=>{let i;t.error&&(i=FM.convertFrom(t.error)),e.emit(sx.PUBLISH_STATE_CHANGED,Xb(qb({},t),{error:i}))})),e._listenOutputTrackChanged(o);let s=null;o.setMediaType(2);let a={},c={};n&&(DD(n.profile)||(OD(n.profile)?Pw[n.profile]&&o.setProfile(Pw[n.profile]):o.setProfile(n.profile)),n.systemAudio&&(a.systemAudio=!0,a.echoCancellation=n.echoCancellation,a.noiseSuppression=n.noiseSuppression,a.autoGainControl=n.autoGainControl),DD(n.fillMode)||(c.objectFit=n.fillMode),n.videoTrack&&(a.videoTrack=n.videoTrack),n.audioTrack&&(a.audioTrack=n.audioTrack),n.captureElement&&(a.captureElement=n.captureElement),n.preferDisplaySurface&&(a.preferDisplaySurface=n.preferDisplaySurface));let l=yield o.capture(a);if(null!=n&&n.qosPreference){let e=cx(n.qosPreference);o.mediaTrack.contentHint=e}if(o.mediaTrack.addEventListener(Mw.ENDED,(()=>{e._stopScreenShare(),e.emit(sx.SCREEN_SHARE_STOPPED)})),l.getAudioTracks()[0]&&(s=new cM(e._room.audioManager),s.setInputMediaStreamTrack(l.getAudioTracks()[0]),e._speakerId&&s.setAudioOutput(e._speakerId)),YL(o,o).add("player-state-changed",(t=>{e.emit(sx.VIDEO_PLAY_STATE_CHANGED,Xb(qb({},t),{userId:"",streamType:"sub"}))})),r&&e._room.isJoined){let t=[o];s&&t.push(s),e._room.publish(...t).catch((()=>{}))}e._localScreenTrack=o,e._localScreenAudioTrack=s,e._localScreenConfig=Xb(qb({},t),{view:i,publish:r}),yield e._updateVideoPlayOption({view:i,playOption:c,track:o})}()}))}updateScreenShare(e){return rC(this,null,(function*(){if(!this._localScreenTrack||!this._localScreenConfig)return;let{view:t,publish:i,option:r}=e,n={};if(r&&(DD(r.fillMode)||(n.objectFit=r.fillMode),r.qosPreference)){let e=cx(r.qosPreference);this._localScreenTrack.mediaTrack.contentHint=e}this._room.isJoined&&!DD(i)&&(i&&!this._localScreenConfig.publish&&(this._room.publish(this._localScreenTrack).catch((()=>{})),this._localScreenAudioTrack&&this._room.publish(this._localScreenAudioTrack).catch((()=>{}))),this._localScreenConfig.publish&&!i&&(this._room.unpublish(this._localScreenTrack).catch((()=>{})),this._localScreenAudioTrack&&this._room.unpublish(this._localScreenAudioTrack).catch((()=>{})))),yield this._updateVideoPlayOption({view:t,playOption:n,track:this._localScreenTrack,prevConfig:this._localScreenConfig}),$D(this._localScreenConfig,e)}))}stopScreenShare(){return rC(this,null,(function*(){return yield this._stopScreenShare()}))}startRemoteVideo(e){return rC(this,null,(function*(){let{view:t,userId:i,streamType:r,option:n}=e,o="".concat(i,"_").concat(r);if(this._remoteVideoConfigMap.has(o))return void this._log.warn("remote video has already started. userId:".concat(i,", streamType:").concat(r));let s=this._room.remotePublishedUserMap.get(i);if(!s)return;let a={},c="main"===r?s.remoteVideoTrack:s.remoteAuxiliaryTrack;this._listenOutputTrackChanged(c),n&&(DD(n.fillMode)||(a.objectFit=n.fillMode),DD(n.mirror)||(a.mirror=n.mirror),"main"===r&&!DD(n.small)&&this._room.changeType(n.small,c.user)),yield this._room.subscribe(c),yield this._updateVideoPlayOption({view:t,playOption:a,track:c}),this._emitTrackEvent(c),this._remoteVideoConfigMap.set(o,{config:e}),n&&!DD(n.receiveWhenViewVisible)&&this._observeView({remoteTrack:c,view:t,receiveWhenViewVisible:n.receiveWhenViewVisible,viewRoot:null==n?void 0:n.viewRoot})}))}updateRemoteVideo(e){return rC(this,null,(function*(){var t,i;let{view:r,userId:n,streamType:o,option:s}=e,a="".concat(n,"_").concat(o),c=this._remoteVideoConfigMap.get(a);if(!c||!this._room.remotePublishedUserMap.has(n))return;let l={};s&&(DD(s.fillMode)||(l.objectFit=s.fillMode),DD(s.mirror)||(l.mirror=s.mirror));let d=null,u=this._room.remotePublishedUserMap.get(n);if("main"===o&&(null==u?void 0:u.muteState.hasVideo)&&(d=u.remoteVideoTrack),"sub"===o&&(null==u?void 0:u.muteState.hasAuxiliary)&&(d=u.remoteAuxiliaryTrack),!d)return;let{config:h}=c;"main"===o&&s&&!DD(s.small)&&this._room.changeType(s.small,d.user),yield this._updateVideoPlayOption({view:r,playOption:l,track:d,prevConfig:h}),$D(h,e);let p=DD(null==s?void 0:s.receiveWhenViewVisible)?null==(t=h.option)?void 0:t.receiveWhenViewVisible:s.receiveWhenViewVisible,m=DD(r)?h.view:r,_=DD(null==s?void 0:s.viewRoot)?null==(i=h.option)?void 0:i.viewRoot:s.viewRoot;this._observeView({remoteTrack:d,view:m,receiveWhenViewVisible:p,viewRoot:_})}))}stopRemoteVideo(e){return rC(this,null,(function*(){return this._stopRemoteVideo(e)}))}_stopRemoteVideo(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return rC(this,null,(function*(){let i=[],r=this._room.remotePublishedUserMap.get(e.userId);if(r){let{muteState:t,remoteVideoTrack:n,remoteAuxiliaryTrack:o}=r;"main"===e.streamType&&(n.stop(),t.hasVideo&&i.push(n)),"sub"===e.streamType&&(o.stop(),t.hasAuxiliary&&i.push(o))}for(let e of i)t&&(yield this._room.unsubscribe(e),this._mediaTrackMap.get(e.outMediaTrack)===e.userId&&this._mediaTrackMap.delete(e.outMediaTrack));let n=this._remoteVideoConfigMap.get("".concat(e.userId,"_").concat(e.streamType));n&&n.observer&&n.observer.disconnect(),this._remoteVideoConfigMap.delete("".concat(e.userId,"_").concat(e.streamType))}))}muteRemoteAudio(e,t){return rC(this,null,(function*(){if("*"===e)if(t)yield this._stopRemoteAudio({userId:e});else{let e=[...this._room.remotePublishedUserMap.values()];for(let t of e)t.muteState.hasAudio&&(yield this._startRemoteAudio({userId:t.userId}))}else t?yield this._stopRemoteAudio({userId:e}):yield this._startRemoteAudio({userId:e});this._remoteAudioMuteMap.set(e,t)}))}setRemoteAudioVolume(e,t){if("*"===e){let e=[...this._room.remotePublishedUserMap.values()];for(let i of e)this._updateAudioPlayOption({playOption:{volume:t},track:i.remoteAudioTrack})}else if(e){let i=this._room.remotePublishedUserMap.get(e);i&&this._updateAudioPlayOption({playOption:{volume:t},track:i.remoteAudioTrack})}}startPlugin(e,t){return rC(this,null,(function*(){return e.start(t)}))}updatePlugin(e,t){return rC(this,null,(function*(){return e.update(t)}))}stopPlugin(e,t){return rC(this,null,(function*(){return e.stop(t)}))}enableAudioVolumeEvaluation(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._room.enableAudioVolumeEvaluation(e,t)}on(e,t,i){return this.listeners(e).includes(t)||(super.on(e,t,i),this._eventListened.add(e)),this}off(e,t,i){return"*"===e?(this._eventListened.clear(),this.removeAllListeners()):super.off(e,t,i),this}getVideoTrack(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{userId:"",streamType:"main"},{userId:t="",streamType:i="main"}=e;if(""===t){if("main"===i&&this._localVideoTrack)return this._localVideoTrack.mediaTrack;if("sub"===i&&this._localScreenTrack)return this._localScreenTrack.mediaTrack}else{let e=this._room.remotePublishedUserMap.get(t);if(e)return"main"===i?e.remoteVideoTrack.mediaTrack:e.remoteAuxiliaryTrack.mediaTrack}return null}getAudioTrack(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{userId:"",streamType:"main"};var t,i;let r,n="main";if(OD(e)?r=e:(r=e.userId,e.streamType&&(n=e.streamType)),!r)return"sub"===n?(null==(t=this._localScreenAudioTrack)?void 0:t.mediaTrack)||null:(null==(i=this._localAudioTrack)?void 0:i.mediaTrack)||null;{let e=this._room.remotePublishedUserMap.get(r);if(e)return e.remoteAudioTrack.mediaTrack}return null}setCurrentSpeaker(e){var t,i;this._speakerId=e,null==(t=this._localAudioTrack)||t.setAudioOutput(e),null==(i=this._localScreenAudioTrack)||i.setAudioOutput(e),this._room.remotePublishedUserMap.forEach((t=>t.remoteAudioTrack.setAudioOutput(e)))}_startRemoteAudio(e){return this._doStartRemoteAudio(e)}_doStartRemoteAudio(e){return rC(this,null,(function*(){let{userId:t,option:i}=e;if(this._remoteAudioConfigMap.has(t))return void this._log.warn("remote audio has already started. userId:".concat(t));let r=this._room.remotePublishedUserMap.get(t);if(!r)return;let n={};i&&(DD(i.volume)||(n.volume=i.volume));let o=r.remoteAudioTrack;this._listenOutputTrackChanged(o),this._speakerId&&o.setAudioOutput(this._speakerId);try{this._remoteAudioConfigMap.set(t,e),yield this._room.subscribe(o),yield this._updateAudioPlayOption({playOption:n,track:o})}catch(s){throw this._remoteAudioConfigMap.delete(t),s}this._emitTrackEvent(o)}))}_stopRemoteAudio(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return rC(this,null,(function*(){let i=this._room.remotePublishedUserMap.get(e.userId);i&&(i.remoteAudioTrack.stop(),i.muteState.hasAudio&&t&&(yield this._room.unsubscribe(i.remoteAudioTrack)),this._mediaTrackMap.get(i.remoteAudioTrack.outMediaTrack)===e.userId&&this._mediaTrackMap.delete(i.remoteAudioTrack.outMediaTrack)),this._remoteAudioConfigMap.delete("".concat(e.userId))}))}_updateVideoPlayOption(e){return rC(this,arguments,(function(e){let{view:t,playOption:i,track:r,prevConfig:n}=e;return function*(){if(r.setMirror(i.mirror),DD(t)&&n&&n.view&&!JD(i)){let e=tO(n.view);e.length>0&&(yield r.play(e,i))}if(!DD(t)){let e=tO(t);e.length>0?yield r.play(e,i):r.stop()}}()}))}_updateAudioPlayOption(e){return rC(this,arguments,(function(e){let{playOption:t={},track:i,prevConfig:r}=e;return function*(){if(!i.isPlayCalled)try{yield i.play(null,t)}catch(e){}DD(t.muted)||i.setPlayerMute(t.muted),DD(t.volume)||i.setAudioVolume(t.volume/100)}()}))}_listenOutputTrackChanged(e){0===e.listeners("output-media-track-changed").length&&e.on("output-media-track-changed",(()=>this._emitTrackEvent(e)))}_emitTrackEvent(e){let t=e.isRemote?e.userId:"";e.outMediaTrack&&this._mediaTrackMap.get(e.outMediaTrack)!==t&&(this._mediaTrackMap.set(e.outMediaTrack,t),this.emit(sx.TRACK,{userId:t,streamType:ax(e.streamType),track:e.outMediaTrack}))}_checkTrackToPublish(){var e,t,i;let r=[];if((null==(e=this._localAudioConfig)?void 0:e.publish)&&this._localAudioTrack&&r.push(this._localAudioTrack),(null==(t=this._localVideoConfig)?void 0:t.publish)&&this._localVideoTrack&&r.push(this._localVideoTrack),null!=(i=this._localScreenConfig)&&i.publish&&(this._localScreenTrack&&r.push(this._localScreenTrack),this._localScreenAudioTrack&&r.push(this._localScreenAudioTrack)),0!==r.length)return this._room.publish(...r).catch((()=>{}))}_observeView(e){let{remoteTrack:t,view:i,receiveWhenViewVisible:r=!1,viewRoot:n}=e;if(DD(i))return;let o=this._remoteVideoConfigMap.get("".concat(t.userId,"_").concat(ax(t.streamType)));if(!o)return;let s=o.observer||void 0;if(null===i||xD(i)&&0===i.length||!r)return null==s||s.disconnect(),void(t.isSubscribed||this._room.subscribe(t).catch((()=>{})));let a=o.visibleViewMap||new Map,c=-1;(!s||s.root!==n)&&(null==s||s.disconnect(),a.clear(),s=new IntersectionObserver((e=>{e.forEach((e=>{a.set(e.target,e.isIntersecting)})),clearTimeout(c),c=window.setTimeout((()=>{[...a.values()].find((e=>e))?t.isSubscribed||this._room.subscribe(t).catch((()=>{})):t.isSubscribed&&this._room.unsubscribe(t).catch((()=>{}))}),200)}),{root:n}));let l=new Set(tO(i));a.forEach(((e,t)=>{l.has(t)||(s.unobserve(t),a.delete(t))})),l.forEach((e=>{a.set(e,!0),s.observe(e)})),s.takeRecords().forEach((e=>{a.set(e.target,e.isIntersecting)})),o.visibleViewMap=a,o.observer=s}_exitRoom(){return rC(this,null,(function*(){this._room.isJoined&&(yield this._room.leave()),[...this._remoteAudioConfigMap.keys()].forEach((e=>{this._stopRemoteAudio({userId:e}).catch()})),[...this._remoteVideoConfigMap.keys()].forEach((e=>{let t=e.includes("main")?"main":"sub",i=e.split("_".concat(t))[0];i&&this._stopRemoteVideo({userId:i,streamType:t}).catch()})),this._remoteVideoConfigMap.clear(),this._remoteAudioConfigMap.clear(),this._remoteAudioMuteMap.clear(),this._room.remotePublishedUserMap.forEach((e=>{JL(e.remoteAudioTrack),JL(e.remoteVideoTrack),JL(e.remoteAuxiliaryTrack)}))}))}_stopScreenShare(){return rC(this,null,(function*(){var e;if(this._localScreenTrack){if(this._room.isJoined){let t=[this._localScreenTrack];this._localScreenAudioTrack&&t.push(this._localScreenAudioTrack),yield null==(e=this._room)?void 0:e.unpublish(...t).catch((()=>{}))}this._localScreenTrack.stop(),this._localScreenTrack.close(),this._localScreenAudioTrack&&(this._localScreenAudioTrack.stop(),this._localScreenAudioTrack.close(),this._room.audioManager.removeInput(this._localScreenAudioTrack),this._localScreenAudioTrack=null),JL(this._localScreenTrack),this._localScreenTrack=null,this._localScreenConfig=null}}))}_initActiveSpeaker(){return rC(this,null,(function*(){if(kx&&!MP(kx))this.emit(sx.DEVICE_CHANGED,{type:"speaker",action:"active",device:kx});else{let e=yield BP();if(e[0]&&!MP(e[0]))kx=e[0],this.emit(sx.DEVICE_CHANGED,{type:"speaker",action:"active",device:e[0]});else{let e=e=>{let{track:t}=e;"audio"===t.kind&&(!kx||MP(kx))&&(this._initActiveSpeaker(),JN.off("102",this._initActiveSpeaker))};JN.on("102",e)}}}))}_onAudioAvailable(e){let{userId:t}=e;!this._room.autoReceiveAudio||this._remoteAudioMuteMap.get("*")||this._remoteAudioMuteMap.get(t)||this._doStartRemoteAudio({userId:t}).catch((()=>{}))}_onVideoAvailable(e){let{userId:t,streamType:i}=e;if(!this._room.autoReceiveVideo)return;let r=this._room.remotePublishedUserMap.get(t);if(r){let e="main"===i?r.remoteVideoTrack:r.remoteAuxiliaryTrack;this._room.subscribe(e).then((()=>{this._emitTrackEvent(e)})).catch((()=>{}))}}_onAudioUnavailable(e){let{userId:t,muteState:i}=e;i.hasAudio&&i.audioMuted||this._stopRemoteAudio({userId:t},!1).catch((()=>{}))}_onVideoUnavailable(e){let{userId:t,streamType:i}=e;this._stopRemoteVideo({userId:t,streamType:i},!1).catch((()=>{}))}sendSEIMessage(e,t){this._room.sendSEI(e,t||{seiPayloadType:243})}getVideoSnapshot(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{userId:t,streamType:i="main"}=e;if(t){let e=this._room.remotePublishedUserMap.get(t);if("main"===i&&(null==e?void 0:e.muteState.hasVideo))return e.remoteVideoTrack.getVideoFrame();if("sub"===i&&(null==e?void 0:e.muteState.hasAuxiliary))return e.remoteAuxiliaryTrack.getVideoFrame()}else{if("main"===i&&this._localVideoTrack)return this._localVideoTrack.getVideoFrame();if("sub"===i&&this._localScreenTrack)return this._localScreenTrack.getVideoFrame()}return""}static setLogLevel(e,t){EO.setLogLevel(e),DD(t)||(t?EO.enableUploadLog():EO.disableUploadLog())}static isSupported(){return PO()}static getCameraList(){return UP(!0)}static getMicrophoneList(){return VP(!0)}static getSpeakerList(){return BP(!0)}static setCurrentSpeaker(e){return rC(this,null,(function*(){(yield BP()).forEach((t=>{t.deviceId===e&&(Cx.forEach((i=>{i.setCurrentSpeaker(e),i.emit(sx.DEVICE_CHANGED,{type:"speaker",action:"active",device:t})})),kx=t)}))}))}static _addKVStat(e){let{type:t,key:i,value:r,base:n,useUV:o,version:s}=e;switch(s&&(hP.version=s),t){case"count":hP.addCount({key:i,useUV:o});break;case"enum":hP.addEnum({key:i,value:r,useUV:o});break;case"number":hP.addNumber({key:i,value:r,split:n})}}},Nx=wx;tC(Nx,"_loggerManager",EO),tC(Nx,"EVENT",sx),tC(Nx,"ERROR_CODE",MM),tC(Nx,"TYPE",PM),tC(Nx,"frameWorkType",30),eC([ux(JM.TRTC.enterRoom),rx("room",((e,t)=>{let[i]=e,[r]=t;return(i.roomId||i.strRoomId)===(r.roomId||r.strRoomId)&&i.userId===r.userId&&i.sdkAppId===r.sdkAppId})),JP((e=>function(t){return this._log.setUserId(t.userId),this._log.setSdkAppId(t.sdkAppId),e.call(this,t)})),_x()],Nx.prototype,"enterRoom",1),eC([_x()],Nx.prototype,"exitRoom",1),eC([ux(JM.TRTC.switchRole),nx("room",{merge:(e,t)=>t}),_x()],Nx.prototype,"switchRole",1),eC([_x()],Nx.prototype,"destroy",1),eC([ux(JM.TRTC.startLocalAudio),rx("audio",((e,t)=>{let[i]=e,[r]=t;var n,o;return(null==(n=null==i?void 0:i.option)?void 0:n.microphoneId)===(null==(o=null==r?void 0:r.option)?void 0:o.microphoneId)})),_x()],Nx.prototype,"startLocalAudio",1),eC([ux(JM.TRTC.updateLocalAudio),nx("audio",{debounce:{delay:200,getKey:()=>"".concat(bx,"-localAudio"),isNeedToDebounce:e=>{var t;return!DD(null==(t=e.option)?void 0:t.captureVolume)}}}),_x()],Nx.prototype,"updateLocalAudio",1),eC([ox("audio"),_x()],Nx.prototype,"stopLocalAudio",1),eC([ux(JM.TRTC.startLocalVideo),rx("video",((e,t)=>{let[i]=e,[r]=t;var n,o;return(null==(n=null==i?void 0:i.option)?void 0:n.cameraId)===(null==(o=null==r?void 0:r.option)?void 0:o.cameraId)})),_x()],Nx.prototype,"startLocalVideo",1),eC([ux(JM.TRTC.updateLocalVideo),nx("video"),_x()],Nx.prototype,"updateLocalVideo",1),eC([ox("video"),_x()],Nx.prototype,"stopLocalVideo",1),eC([ux(JM.TRTC.startScreenShare),rx("screen",(()=>!0)),_x()],Nx.prototype,"startScreenShare",1),eC([ux(JM.TRTC.updateScreenShare),nx("screen"),_x()],Nx.prototype,"updateScreenShare",1),eC([_x()],Nx.prototype,"stopScreenShare",1),eC([ux(JM.TRTC.startRemoteVideo),rx((e=>"v".concat(e.userId).concat(e.streamType)),(()=>!0)),_x({getRemoteId:e=>"".concat(e.userId,"_").concat(e.streamType)})],Nx.prototype,"startRemoteVideo",1),eC([ux(JM.TRTC.updateRemoteVideo),nx((e=>"v".concat(e.userId).concat(e.streamType))),_x({getRemoteId:e=>"".concat(e.userId,"_").concat(e.streamType)})],Nx.prototype,"updateRemoteVideo",1),eC([ux(JM.TRTC.stopRemoteVideo),JP((e=>function(t){return rC(this,null,(function*(){if("*"===t.userId){let e=[];return this._room.remotePublishedUserMap.forEach((t=>{this._remoteVideoConfigMap.has("".concat(t.userId,"_","main"))&&e.push(this.stopRemoteVideo({streamType:"main",userId:t.userId}).catch((()=>{}))),this._remoteVideoConfigMap.has("".concat(t.userId,"_","sub"))&&e.push(this.stopRemoteVideo({streamType:"sub",userId:t.userId}).catch((()=>{})))})),Promise.all(e)}return e.call(this,t)}))})),_x({getRemoteId:e=>"".concat(e.userId,"_").concat(e.streamType)})],Nx.prototype,"stopRemoteVideo",1),eC([ox((e=>"v".concat(e.userId).concat(e.streamType)))],Nx.prototype,"_stopRemoteVideo",1),eC([ux(...JM.TRTC.muteRemoteAudio),_x({getRemoteId:e=>e})],Nx.prototype,"muteRemoteAudio",1),eC([hx(...JM.TRTC.setRemoteAudioVolume),function(e,t){return JP(((i,r)=>function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];var s,a;let c=null==(s=dx.get(this))?void 0:s.get(t(...n));c&&c>0&&clearTimeout(c);let l=window.setTimeout((()=>{i.apply(this,n)}),e);dx.has(this)?null==(a=dx.get(this))||a.set(t(...n),l):dx.set(this,new Map([[t(...n),l]]))}))}(200,(e=>e)),_x({getRemoteId:e=>e})],Nx.prototype,"setRemoteAudioVolume",1),eC([fx("start"),rx(((e,t)=>e.getAlias()+e.getGroup(t))),_x({replaceArg:e=>({argIndex:0,value:e.getName()}),getKVReportKey:e=>sP[e.getName()]})],Nx.prototype,"startPlugin",1),eC([fx("update"),nx(((e,t)=>e.getAlias()+e.getGroup(t))),_x({replaceArg:e=>({argIndex:0,value:e.getName()}),getKVReportKey:e=>aP[e.getName()]})],Nx.prototype,"updatePlugin",1),eC([fx("stop"),ox(((e,t)=>e.getAlias()+e.getGroup(t))),_x({replaceArg:e=>({argIndex:0,value:e.getName()}),getKVReportKey:e=>cP[e.getName()]})],Nx.prototype,"stopPlugin",1),eC([hx(...JM.TRTC.enableAudioVolumeEvaluation)],Nx.prototype,"enableAudioVolumeEvaluation",1),eC([_x()],Nx.prototype,"setCurrentSpeaker",1),eC([rx((e=>"a".concat(e.userId)),(()=>!0))],Nx.prototype,"_startRemoteAudio",1),eC([JP((e=>function(t){return rC(this,null,(function*(){return"*"===t.userId?Promise.all([...this._room.remotePublishedUserMap.values()].map((e=>this._stopRemoteAudio(Xb(qb({},t),{userId:e.userId})).catch((()=>{}))))):e.call(this,t)}))})),ox((e=>"a".concat(e.userId)))],Nx.prototype,"_stopRemoteAudio",1),eC([ox("room")],Nx.prototype,"_exitRoom",1),eC([ox("screen")],Nx.prototype,"_stopScreenShare",1),eC([ux(JM.TRTC.sendSEIMessage),function(e){let{timesInSecond:t,maxSizeInSecond:i,getSize:r}=e;return JP(((e,n)=>{let o=new Map;return JN.on(fO.ROOM_DESTROY,(e=>{let{room:t}=e;return o.delete(t)})),function(){let s=o.get(this);for(var a=arguments.length,c=new Array(a),l=0;l<a;l++)c[l]=arguments[l];if(s||(s={callCountInSecond:0,timestamp:0,totalSizeInSecond:0},o.set(this,s)),0===s.timestamp?s.timestamp=Date.now():Date.now()-s.timestamp>1e3&&(s.timestamp=Date.now(),s.callCountInSecond=0,s.totalSizeInSecond=0),r&&(s.totalSizeInSecond+=r(...c)),0!==s.timestamp&&Date.now()-s.timestamp<1e3&&(s.callCountInSecond>=t||s.totalSizeInSecond>i))throw new fC({code:_C.INVALID_OPERATION,message:GN({key:HN.CALL_FREQUENCY_LIMIT,data:{isTimes:s.callCountInSecond>=t,isSize:s.totalSizeInSecond>i,name:n,timesInSecond:t,maxSizeInSecond:i}})});s.callCountInSecond++,e.call(this,...c)}}))}({timesInSecond:30,maxSizeInSecond:8e3,getSize:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return t[0].byteLength}})],Nx.prototype,"sendSEIMessage",1),eC([_x()],Nx.prototype,"getVideoSnapshot",1),eC([ux(JM.TRTC.create)],Nx,"_create",1);var Dx=Nx,Ox=class{constructor(){this._set=new Set,JN.on(fO.LEAVE_SUCCESS,this.delete,this)}add(e){let{room:t,roomId:i}=e;if("rtc"===t.scene)return;let r=this.getKey(t.userId,i||t.roomId,t.sdkAppId,t.useStringRoomId);this._set.add(r)}delete(e){let{room:t,roomId:i}=e;if("rtc"===t.scene)return;let r=this.getKey(t.userId,t.roomId||i,t.sdkAppId,t.useStringRoomId);this._set.delete(r)}getKey(e,t,i,r){return"".concat(i,"_").concat(t,"_").concat(e,"_").concat(r)}isJoined(e){let{userId:t,roomId:i,sdkAppId:r,room:n}=e;return"rtc"!==n.scene&&this._set.has(this.getKey(t,i,r,n.useStringRoomId))}};function Lx(){return rC(this,null,(function*(){let e,t;try{let t=yield VP();e=t&&t.length}catch(u){}try{let e=yield UP();t=e&&e.length}catch(u){}let i={microphone:e,camera:t},{isH264EncodeSupported:r,isVp8EncodeSupported:n,isH264DecodeSupported:o,isVp8DecodeSupported:s}=this.checkSystemResult.detail,a=TO.basis(),c={webRTC:a.isWebRTCSupported,getUserMedia:a.isGetUserMediaSupported,webSocket:a.isWebSocketsSupported,screenShare:a.isScreenShareSupported,webAudio:a.isWebAudioSupported,h264Encode:r,h264Decode:o,vp8Encode:n,vp8Decode:s},l={browser:a.browser,os:a.os,trtc:c,devices:i},d={isWebCodecSupported:a.isWebCodecSupported,isMediaSessionSupported:a.isMediaSessionSupported,isWebTransportSupported:a.isWebTransportSupported};XN.uploadEvent({log:"trtcstats-".concat(JSON.stringify(l)),userId:this.userId}),this._log.info("TrtcStats-".concat(JSON.stringify(l))),XN.uploadEvent({log:"trtcadvancedstats-".concat(JSON.stringify(d)),userId:this.userId})}))}var Px=$b(nC(),1),Mx=Symbol("instance"),xx=Symbol("cacheResult"),Vx=class{constructor(e,t,i){this.oldState=e,this.newState=t,this.action=i,this.aborted=!1}abort(e){this.aborted=!0,jx.call(e,this.oldState,new Error("action '".concat(this.action,"' aborted")))}toString(){return"".concat(this.action,"ing")}},Ux=class extends Error{constructor(e,t,i){super(t),this.state=e,this.message=t,this.cause=i}},Bx=new Map;function Fx(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return(r,n,o)=>{let s=i.action||n;if(!i.context){let i=Bx.get(r)||[];Bx.has(r)||Bx.set(r,i),i.push({from:e,to:t,action:s})}let a=o.value;o.value=function(){let r=this;for(var n=arguments.length,o=new Array(n),c=0;c<n;c++)o[c]=arguments[c];if(i.context&&(r=Wx.get("function"==typeof i.context?i.context.call(this,...o):i.context)),r.state===t)return r[xx];r.state instanceof Vx&&r.state.action==i.abortAction&&r.state.abort(r);let l=null;if(Array.isArray(e)?0==e.length?r.state instanceof Vx&&r.state.abort(r):("string"!=typeof r.state||!e.includes(r.state))&&(l=new Ux(r._state,"".concat(r.name," ").concat(s," to ").concat(t," failed: current state ").concat(r._state," not in from config"))):e!==r.state&&(l=new Ux(r._state,"".concat(r.name," ").concat(s," to ").concat(t," failed: current state ").concat(r._state," not from ").concat(e))),l){if(!i.fail){if(i.ignoreError)return l;throw l}i.fail.call(this,l)}let d=r.state,u=new Vx(d,t,s);jx.call(r,u);let h=e=>{var n;return r[xx]=e,u.aborted||(jx.call(r,t),null===(n=i.success)||void 0===n||n.call(this,r[xx])),e},p=e=>{let t=e instanceof Error?e.message:String(e);if(jx.call(r,d,e),!i.fail){if(i.ignoreError)return e;throw e}i.fail.call(this,new Ux(r._state,"action '".concat(s,"' failed :").concat(t),e instanceof Error?e:new Error(t)))};try{let e=a.apply(this,o);return"object"==typeof(m=e)&&m&&"then"in m?e.then(h).catch(p):h(e)}catch(_){p(_)}var m}}}var Hx="undefined"!=typeof window&&window.__AFSM__?(e,t)=>{window.dispatchEvent(new CustomEvent(e,{detail:t}))}:"undefined"!=typeof importScripts?(e,t)=>{postMessage({type:e,payload:t})}:()=>{};function jx(e,t){let i=this._state;this._state=e;let r=e.toString();e&&this.emit(r,i),this.emit(Wx.STATECHANGED,e,i,t),this.updateDevTools({value:e,old:i,err:t instanceof Error?t.message:String(t)})}var Wx=class extends Px.default{constructor(e,t,i){super(),this.name=e,this.groupName=t,this._state=Wx.INIT,e||(e=Date.now().toString(36)),i?Object.setPrototypeOf(this,i):i=Object.getPrototypeOf(this),t||(this.groupName=this.constructor.name);let r=i[Mx];r?this.name=r.name+"-"+r.count++:i[Mx]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){let e=Object.getPrototypeOf(this),t=Bx.get(e)||[],i=new Set,r=[],n=[],o=new Set,s=Object.getPrototypeOf(e);Bx.has(s)&&(s.stateDiagram.forEach((e=>i.add(e))),s.allStates.forEach((e=>o.add(e)))),t.forEach((e=>{let{from:t,to:i,action:o}=e;"string"==typeof t?r.push({from:t,to:i,action:o}):t.length?t.forEach((e=>{r.push({from:e,to:i,action:o})})):n.push({to:i,action:o})})),r.forEach((e=>{let{from:t,to:r,action:n}=e;o.add(t),o.add(r),o.add(n+"ing"),i.add("".concat(t," --\x3e ").concat(n,"ing : ").concat(n)),i.add("".concat(n,"ing --\x3e ").concat(r," : ").concat(n," 🟢")),i.add("".concat(n,"ing --\x3e ").concat(t," : ").concat(n," 🔴"))})),n.forEach((e=>{let{to:t,action:r}=e;i.add("".concat(r,"ing --\x3e ").concat(t," : ").concat(r," 🟢")),o.forEach((e=>{e!==t&&i.add("".concat(e," --\x3e ").concat(r,"ing : ").concat(r))}))}));let a=[...i];return Object.defineProperties(e,{stateDiagram:{value:a},allStates:{value:o}}),a}static get(e){let t;return"string"==typeof e?(t=Wx.instances.get(e),t||Wx.instances.set(e,t=new Wx(e,void 0,Object.create(Wx.prototype)))):(t=Wx.instances2.get(e),t||Wx.instances2.set(e,t=new Wx(e.constructor.name,void 0,Object.create(Wx.prototype)))),t}static getState(e){var t;return null===(t=Wx.get(e))||void 0===t?void 0:t.state}updateDevTools(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Hx(Wx.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},e))}get state(){return this._state}set state(e){jx.call(this,e)}};Wx.STATECHANGED="stateChanged",Wx.UPDATEAFSM="updateAFSM",Wx.INIT="[*]",Wx.ON="on",Wx.OFF="off",Wx.instances=new Map,Wx.instances2=new WeakMap;var zx=$b(nC()),Gx="1",Kx="5",Yx="2",Jx="3",qx="4",Xx={CLIENT_BANNED:9,CHANNEL_SETUP_RESULT:19,CHANNEL_RECONNECT_RESULT:514,JOIN_ROOM_RESULT:20,PEER_JOIN:4134,PEER_LEAVE:4135,STREAM_ADDED:16,STREAM_REMOVED:18,UPLINK_NETWORK_STATS:22,UPDATE_REMOTE_MUTE_STAT:23,PUBLISH_RESULT:4098,PUBLISH_STATE_CHANGE_RESULT:4112,UNPUBLISH_RESULT:4100,SUBSCRIBE_RESULT:4102,UNSUBSCRIBE_RESULT:4104,SUBSCRIBE_CHANGE_RESULT:4106,MUTE_RESULT:4108,UPDATE_OFFER_RESULT:4128,START_PUBLISH_TENCENT_CDN_RES:1286,STOP_PUBLISH_TENCENT_CDN_RES:1288,START_PUBLISH_GIVEN_CDN_RES:777,STOP_PUBLISH_GIVEN_CDN_RES:779,START_MIX_TRANSCODE_RES:781,STOP_MIX_TRANSCODE_RES:783,USER_LIST_RES:4137,SWITCH_ROLE_RES:4110,UPDATE_CONSTRAINT_CONFIG_RES:772,REBUILD_PEER_CONNECTION_RES:4150,SPC_PUBLISH_RESULT:4146,SPC_SUBSCRIBE_RESULT:4156,ABILITY_STATUS_REPORT_RESULT:4158,SERVER_PUBLISH_RESULT:5e3},Qx=[Xx.UPDATE_REMOTE_MUTE_STAT,Xx.UPLINK_NETWORK_STATS,Xx.USER_LIST_RES,Xx.MUTE_RESULT,Xx.SERVER_PUBLISH_RESULT],Zx={CLIENT_BANNED:"client-banned",CHANNEL_SETUP_RESULT:"channel-setup-result",CHANNEL_RECONNECT_RESULT:"channel-reconnect-result",JOIN_ROOM_RESULT:"join-room-result",PEER_JOIN:"peer-join",PEER_LEAVE:"peer-leave",STREAM_ADDED:"stream-added",STREAM_REMOVED:"stream-removed",UPLINK_NETWORK_STATS:"uplink-network-stats",UPDATE_REMOTE_MUTE_STAT:"update-remote-mute-stat",PUBLISH_RESULT:"publish-result",PUBLISH_STATE_CHANGE_RESULT:"publish-state-change-result",UNPUBLISH_RESULT:"unpublish-result",SUBSCRIBE_RESULT:"subscribe-result",SUBSCRIBE_CHANGE_RESULT:"subscribe-change-result",UNSUBSCRIBE_RESULT:"unsubscribe-result",UPDATE_OFFER_RESULT:"update-offer-result",START_PUBLISH_TENCENT_CDN_RES:"start-publish-tencent-cdn-res",STOP_PUBLISH_TENCENT_CDN_RES:"stop-publish-tencent-cdn-res",START_PUBLISH_GIVEN_CDN_RES:"start-publish-given-cdn-res",STOP_PUBLISH_GIVEN_CDN_RES:"stop-publish-given-cdn-res",START_MIX_TRANSCODE_RES:"start-mix-transcode-res",STOP_MIX_TRANSCODE_RES:"stop-mix-transcode-res",USER_LIST_RES:"user-list-res",SWITCH_ROLE_RES:"switch_role_res",MUTE_RESULT:"mute-result",UPDATE_CONSTRAINT_CONFIG_RES:"update-contraint-config-res",REBUILD_PEER_CONNECTION_RES:"rebuild-pc-res",SPC_PUBLISH_RESULT:"spc-publish-result",SPC_SUBSCRIBE_RESULT:"spc-subscribe-result",ABILITY_STATUS_REPORT_RESULT:"ability-status-report",SERVER_PUBLISH_RESULT:"server-publish-result"},$x="publish_change",eV="join",tV="leave",iV="quality_report",rV="mute_uplink",nV="publish",oV="publish_state_change",sV="unpublish",aV="subscribe",cV="unsubscribe",lV="subscribe_change",dV="start_publishing",uV="stop_publishing",hV="start_push_user_cdn",pV="stop_push_user_cdn",mV="start_mcu_mix",_V="stop_mcu_mix",fV="get_user_list",gV="change_role",EV="update_constraint_config",vV="rebuild_pc",yV="join/v2",TV="publish/v2",SV="subscribe/v3",IV="ability_status_report",AV="reconnect",RV=new WeakMap;function bV(e){let{settings:t={retries:5,timeout:2e3},onError:i,onRetrying:r,onRetryFailed:n}=e;return function(e,o,s){let a=YN({retryFunction:s.value,settings:t,onError(t){let{error:r,retry:n,reject:s,retryFuncArgs:a}=t;i&&i.call(this,r,(()=>{var t;null!=(t=RV.get(e))&&t.has(o)?n():s(r)}),s,a)},onRetrying(t,i){var n;ND(r)&&r.call(this,t,i),null!=(n=RV.get(e))&&n.has(o)&&(RV.get(e).get(o).stopRetry=i)},onRetryFailed:n});return s.value=function(){let t=RV.get(e);for(var i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return t?t.set(o,{args:r}):RV.set(e,new Map([[o,{args:r}]])),a.apply(this,r).finally((()=>{var t;return null==(t=RV.get(e))?void 0:t.delete(o)}))},s}}function CV(e){let{fnName:t,callback:i,validateArgs:r=!0}=e;return function(e,n,o){let s=o.value;return o.value=function(){for(var n,o,a=arguments.length,c=new Array(a),l=0;l<a;l++)c[l]=arguments[l];if(null!=(n=RV.get(e))&&n.has(t)){let{stopRetry:n,args:s}=RV.get(e).get(t),a=!0;if(r)for(let e of s)if(!c.find((t=>t===e))){a=!1;break}a&&(i&&i.apply(this,c),n&&n(),null==(o=RV.get(e))||o.delete(t))}return s.apply(this,c)},o}}var kV=new Set,wV=class extends zx.default{constructor(e){var t,i;super(),tC(this,"room"),tC(this,"url"),tC(this,"backupUrl"),tC(this,"race"),tC(this,"_socketInUse"),tC(this,"_socket"),tC(this,"_backupSocket"),tC(this,"_signalInfo",{tinyId:void 0,clientIp:"",signalIp:"",relayIp:"",relayInnerIp:"",relayPort:0}),tC(this,"_currentState","DISCONNECTED"),tC(this,"_isReconnecting",!1),tC(this,"_seq",0),tC(this,"_log"),tC(this,"_lastMessageTime",-1),tC(this,"_connnectStartTime",-1),tC(this,"_stopConnectRetry"),tC(this,"bytesSent",0),tC(this,"bytesReceived",0),tC(this,"keepAlive",!1),this.room=e.room,this.race=!!DD(e.race)||e.race,((null==(i=null==(t=this.room.scheduleResult)?void 0:t.config)?void 0:i.keepAliveClient)||0)-kV.size>0&&this.room.enableSPC&&(this.keepAlive=!0,kV.add(this)),this.url=e.url,this.backupUrl=e.backupUrl,this._seq=0,this._log=EO.createLogger({id:"ws",userId:this.userId,sdkAppId:this.sdkAppId}),this.onmessage=this.onmessage.bind(this),this.onerror=this.onerror.bind(this),this.onclose=this.onclose.bind(this)}get urlParam(){let e="?sdkAppId=".concat(encodeURIComponent(this.sdkAppId),"&userId=").concat(encodeURIComponent(this.userId),"&userSig=").concat(encodeURIComponent(this.userSig),"&keepAlive=").concat(encodeURIComponent(Number(this.keepAlive)));return this.race?"".concat(e,"&race=1"):e}get _urlWithParam(){return"".concat(this.url).concat(this.race?"/v2/ws":"").concat(this.urlParam)}get _backupUrlWithParam(){return"".concat(this.backupUrl).concat(this.race?"/v2/ws":"").concat(this.urlParam)}get isConnected(){return"CONNECTED"===this._currentState}get isConnecting(){return"CONNECTING"===this._currentState}get sdkAppId(){return this.room.sdkAppId}get userId(){return this.room.userId}get userSig(){return this.room.userSig}get isOnline(){return"CONNECTED"===this._currentState&&Date.now()-this._lastMessageTime<12e3}connect(){return rC(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e4;return function*(){if(e.isConnected)return Promise.resolve();e._log.info("connect to [".concat(e.url,", ").concat(e.backupUrl,"]").concat(t?" timeout: ".concat(t):""," keepAlive: ").concat(Number(e.keepAlive))),e.emitConnectionStateChanged("CONNECTING"),e._connnectStartTime=zD();let i=[e.connectWS({url:e._urlWithParam,isMain:!0,timeout:t})];e.race&&e._backupUrlWithParam!==e._urlWithParam&&i.push(e.connectWS({url:e._backupUrlWithParam,isMain:!1,timeout:t})),e._socketInUse=yield WD(i),e.unbindAndCloseSocket(e._socketInUse===e._socket?Mw.BACKUP:Mw.MAIN),e.emitConnectionStateChanged("CONNECTED")}()}))}connectWS(e){let{url:t,timeout:i,isMain:r}=e,n=new WebSocket(t);this.bindSocket(n),r?this._socket=n:this._backupSocket=n;let o=-1;return new Promise(((e,t)=>{n.onclose=t,n.onerror=t,n.onopen=()=>e(n),i&&(o=setTimeout((()=>{this.unbindAndCloseSocket(r?Mw.MAIN:Mw.BACKUP),t(new fC({code:_C.SIGNAL_CHANNEL_SETUP_FAILED,message:"ws connect timeout"}))}),i))})).finally((()=>{n.onclose=null,n.onerror=null,n.onopen=null,clearTimeout(o)}))}bindSocket(e){e.addEventListener("close",this.onclose),e.addEventListener("error",this.onerror),e.addEventListener("message",this.onmessage)}unbindSocket(e){e.removeEventListener("close",this.onclose),e.removeEventListener("error",this.onerror),e.removeEventListener("message",this.onmessage)}unbindAndCloseSocket(e){if(e===Mw.MAIN){if(this._socket){this.unbindSocket(this._socket);try{this._socket.close(1e3)}catch(t){}this._socket=null}}else if(this._backupSocket){this.unbindSocket(this._backupSocket);try{this._backupSocket.close(1e3)}catch(t){}this._backupSocket=null}}onclose(e){if(e.target===this._socketInUse&&(this._log.warn("".concat(e.target===this._socket?"main":"backup"," is closed code:").concat(e.code," ").concat(e.reason)),this.emitConnectionStateChanged("DISCONNECTED"),!e.wasClean||1e3!==e.code)){this._socketInUse.onclose=null,this._socketInUse.close(4011);let e=this._socketInUse===this._socket;this.unbindAndCloseSocket(e?Mw.MAIN:Mw.BACKUP),this._socketInUse=null,this.reconnect()}}onerror(e){this._log.error("".concat(e.target===this._socket?"main":"backup"," error observed")),e.target===this._socketInUse&&(this.unbindAndCloseSocket(Mw.MAIN),this.unbindAndCloseSocket(Mw.BACKUP),this._socketInUse=null,this.reconnect())}onmessage(e){if(!this.isConnected)return;this._lastMessageTime=Date.now(),this.bytesReceived+=aO(e.data);let t=JSON.parse(e.data),{cmd:i,data:r}=t,n=Object.values(Xx),o=Object.keys(Xx)[n.indexOf(i)],s=Zx[o];switch(Qx.includes(i)||(this._log.debug("received ".concat(i," msg: ").concat(e.data)),s&&this._log.info("Received event: [ ".concat(s," ]"))),i){case Xx.CHANNEL_SETUP_RESULT:if(0===t.code)this._signalInfo.clientIp=r.clientIp,this._signalInfo.signalIp=r.signalInnerIp,r.svrTime&&function(e){gC=e-(new Date).getTime();let t=new Date;t.setTime(e),EO.info("baseTime from server: ".concat(t," offset: ").concat(gC))}(r.svrTime),this._log.info("ChannelSetup Success"),pP.addSuccessEvent({key:521701,cost:zD()-this._connnectStartTime}),this._connnectStartTime=-1,this.emit(Gx,{signalInfo:this._signalInfo});else{let e=new fC({code:_C.SIGNAL_CHANNEL_SETUP_FAILED,extraCode:t.code,message:GN({key:HN.SIGNAL_CHANNEL_SETUP_FAILED,data:{errorCode:t.code,errorMsg:t.message}})});this._log.error("".concat(t.code,", ").concat(t.message)),this.close(),pP.addFailedEvent({key:521701,error:e}),this.emit(Kx,e)}break;case Xx.JOIN_ROOM_RESULT:0===t.code&&(this._signalInfo.relayIp=r.relayOuterIp,this._signalInfo.relayInnerIp=r.relayInnerIp,this._signalInfo.relayPort=r.relayPort,this._signalInfo.tinyId=t.tinyId,this._log.info("signalIp:".concat(this._signalInfo.signalIp," clientIp:").concat(this._signalInfo.clientIp," relayIp: ").concat(this._signalInfo.relayIp))),this.emit(s,{data:t});break;default:this.emit(s,{data:t})}}reGetSignalChannelUrl(){return rC(this,null,(function*(){try{$N(!0),yield this.room.schedule(this.room.roomId);let{mainUrl:e,backupUrl:t}=this.room.getSignalChannelUrl();this.url=e,this.backupUrl=t}catch(e){}}))}reconnect(){return rC(this,null,(function*(){if(!this._isReconnecting){if(!this.room.isJoined&&this.keepAlive)return void this.close();this._isReconnecting=!0;try{this._log.warn("reconnect"),yield this.connect();let{roomId:e,useStringRoomId:t}=this.room,{relayIp:i,relayInnerIp:r,relayPort:n}=this._signalInfo,{data:o}=yield this.sendWaitForResponse({command:AV,data:{roomId:e,useStringRoomId:t,relayInnerIp:r,relayOuterIp:i,relayPort:n},responseCommand:Zx.CHANNEL_RECONNECT_RESULT});0===o.code?(this._log.warn("reconnect success"),this.stopReconnection(),pP.addSuccessEvent({key:521702,cost:zD()-this._connnectStartTime}),this._connnectStartTime=-1,this.room.syncUserList(),this.room.checkConnectionsToReconnect()):(pP.addFailedEvent({key:521702,error:o.code}),this._log.warn("reconnect failed, ".concat(o.code," ").concat(o.message)),this.room.reJoin())}catch(e){this._log.error(e),this.room.reJoin()}}}))}send(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.isConnected&&!this.room.isLeft){let i={cmd:e,data:t,userId:this.userId,tinyId:this._signalInfo.tinyId,seq:++this._seq},r=JSON.stringify(i);return this._socketInUse.send(r),this.bytesSent+=aO(r),i.seq}}sendWaitForResponse(e){let{command:t,data:i,timeout:r=5e3,responseCommand:n,commandDesc:o,enableLog:s=!0}=e;return new Promise(((e,a)=>{let c=setTimeout((()=>{this.off(n,l);let e=new fC({code:_C.API_CALL_TIMEOUT,message:GN({key:HN.API_CALL_TIMEOUT,data:{commandDesc:o,command:t}})});s&&this._log.warn(e),a(e)}),r),l=t=>{t.data.seq===d&&(clearTimeout(c),this.off(n,l),e(t))};this.on(n,l);let d=this.send(t,i)}))}sendWaitForResponseWithRetry(e){let{commandDesc:t,command:i,retries:r=0,retryTimeout:n=0}=e;return YN({retryFunction:this.sendWaitForResponse,onRetrying:e=>{this._log.warn("".concat(t||i," timeout observed, retrying [").concat(e,"/").concat(r,"]"))},settings:{retries:r,timeout:n},context:this})(e)}getCurrentState(){return this._currentState}getSignalInfo(){return this._signalInfo}stopReconnection(){this._isReconnecting=!1,this._stopConnectRetry&&this._stopConnectRetry()}close(){this._log.info("closed"),kV.delete(this),this.stopReconnection(),this._signalInfo={tinyId:void 0,clientIp:"",signalIp:"",relayIp:"",relayInnerIp:"",relayPort:0},this._socketInUse=null,this.bytesSent=0,this.bytesReceived=0,this._stopConnectRetry&&this._stopConnectRetry(),this.unbindAndCloseSocket(Mw.MAIN),this.unbindAndCloseSocket(Mw.BACKUP),this.emitConnectionStateChanged("DISCONNECTED")}stopKeepAliveIn(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:3600;if(this.keepAlive){this._log.info("stopKeepAlive in ".concat(e,"s"));let t=setTimeout((()=>{this.keepAlive=!1,this._log.info("close due to not used ".concat(e,"s")),this.close()}),1e3*e),i=e=>{e instanceof Vx&&"join"===e.action&&(this._log.info("stopKeepAlive clear timeout"),clearTimeout(t),this.room.off(Wx.STATECHANGED,i))};this.room.on(Wx.STATECHANGED,i)}}emitConnectionStateChanged(e){e!==this._currentState&&(this._log.info("".concat(this._currentState," -> ").concat(e)),this.emit(Yx,{prevState:this._currentState,state:e}),this._currentState=e,"CONNECTED"===e&&this.emit(Jx))}};eC([bV({settings:{retries:1/0,timeout:2e3},onError(e,t){this.room.isDestroyed||t()},onRetrying(e,t){this._log.warn("retrying to connect ".concat(e)),e>=3&&e%3==0&&this.reGetSignalChannelUrl(),t&&(this._stopConnectRetry=t,this.room.isDestroyed&&t())}})],wV.prototype,"connect",1);var NV=$b(nC()),DV=0,OV=!1,LV=new Set,PV=!1,MV=class{constructor(e){tC(this,"userId"),tC(this,"tinyId"),tC(this,"_sdpSemantics"),tC(this,"_isUplink"),tC(this,"_room"),tC(this,"_log"),tC(this,"_signalChannel"),tC(this,"_isErrorObserved",!1),tC(this,"_waitForPeerConnectionConnectedPromise"),tC(this,"_waitForPeerConnectionConnectedPromiseReject",null),tC(this,"_peerConnection",null),tC(this,"_emitter",new NV.default),tC(this,"_currentState","DISCONNECTED"),tC(this,"_isReconnecting",!1),tC(this,"_reconnectionCount",0),tC(this,"_reconnectionTimer",-1),tC(this,"_isFirstConnection",!0),tC(this,"_prevTime",-1),tC(this,"_enableSEI"),tC(this,"_sei"),tC(this,"_localAddress"),tC(this,"_remoteAddress"),this.userId=e.userId,this.tinyId=e.tinyId,this._room=e.room,this._sdpSemantics=e.room.sdpSemantics,this._isUplink=e.isUplink,this._log=EO.createLogger({id:"n-mpc",userId:this._room.userId,remoteUserId:this.userId,sdkAppId:this._room.sdkAppId,isLocal:this._isUplink}),this._signalChannel=e.signalChannel,this._enableSEI=e.enableSEI}beforeConnect(){this._prevTime<0&&(this._prevTime=zD())}afterConnect(e){return rC(this,null,(function*(){try{yield e,this._isFirstConnection?(this._isFirstConnection=!1,pP.addSuccessEvent({key:521705,cost:Math.min(zD()-this._prevTime,3e4)})):this._isReconnecting&&pP.addSuccessEvent({key:521706,cost:zD()-this._prevTime}),this._prevTime=-1}catch(t){throw this._isFirstConnection?(this._isFirstConnection=!1,pP.addFailedEvent({key:521705,error:t})):this._isReconnecting&&this._reconnectionCount>=3&&pP.addFailedEvent({key:521706,error:t}),t}}))}initialize(){let e={encodedInsertableStreams:this._enableSEI&&tL,iceServers:this._room.getIceServers(),iceTransportPolicy:this._room.getIceTransportPolicy(),sdpSemantics:this._sdpSemantics,bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",tcpCandidatePolicy:"disable",IceTransportsType:"nohost"};this._peerConnection=new RTCPeerConnection(e),this._peerConnection.onconnectionstatechange=this.onConnectionStateChange.bind(this)}close(e){this._log.info("close connection"),this._emitter.emit("closed",e),this._isReconnecting&&this.stopReconnection(),this.closePeerConnection(),this._sei&&(this._sei.destroy(),this._sei=null),LV.delete(this)}closePeerConnection(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._peerConnection&&(this._log.info("close pc"),this._peerConnection.onconnectionstatechange=null,this._peerConnection.close(),this._peerConnection=null,e&&this.emitConnectionStateChangedEvent("DISCONNECTED")),this._waitForPeerConnectionConnectedPromiseReject&&this._waitForPeerConnectionConnectedPromiseReject(new fC({code:_C.API_CALL_ABORTED,message:"connection closed"}))}getDTLSTransportState(){if(!this._peerConnection)return iN;let e=null;if(this._isUplink){if(!KO()||0===this._peerConnection.getSenders().length)return iN;e=this._peerConnection.getSenders()[0].transport}else{if(!GO()||0===this._peerConnection.getReceivers().length)return iN;e=this._peerConnection.getReceivers()[0].transport}return e?e.state:iN}onConnectionStateChange(e){let t=this._peerConnection.iceConnectionState,i=this.getDTLSTransportState();if(this._log.info("connectionState: ".concat(e.target.connectionState,", ICE: ").concat(t,", DTLS: ").concat(i)),e.target.connectionState===rN.CONNECTING&&this.emitConnectionStateChangedEvent("CONNECTING"),e.target.connectionState===rN.FAILED||e.target.connectionState===rN.CLOSED){let r="connection ".concat(e.target.connectionState,". ICE Transport state: ").concat(t,", DTLS Transport state: ").concat(i),n=new fC({message:r,code:_C.ICE_TRANSPORT_ERROR});this.emitConnectionStateChangedEvent("DISCONNECTED"),this.startReconnection(),this._isErrorObserved||this._emitter.emit("error",n)}(e.target.connectionState===rN.CONNECTED||e.target.connectionState===rN.COMPLETED)&&(this.logSelectedCandidate(),XN.logSuccessEvent({userId:this._room.userId,eventType:lN.ICE_CONNECTION_STATE}),this.emitConnectionStateChangedEvent("CONNECTED"))}emitConnectionStateChangedEvent(e){return e!==this._currentState&&("CONNECTED"===e?(DV=0,OV=!1,PV=!0,LV.add(this)):LV.delete(this),JN.emit(fO.PEER_CONNECTION_STATE_CHANGED,{room:this._room,prevState:this._currentState,state:e,remoteUserId:this._isUplink?void 0:this.userId}),this._emitter.emit("connection-state-changed",{prevState:this._currentState,state:e}),this._currentState=e,!0)}getPeerConnection(){return this._peerConnection}getRoom(){return this._room}getUserId(){return this.userId}getTinyId(){return this.tinyId}logSelectedCandidate(){return rC(this,null,(function*(){if(!this._peerConnection)return;let e=yield this._peerConnection.getStats();for(let[,t]of e)if(UO(t)){let i=e.get(t.localCandidateId),r=e.get(t.remoteCandidateId);i&&(this._log.info("local candidate: ".concat(i.candidateType," ").concat(i.protocol,":").concat(i.ip||i.address,":").concat(i.port," ").concat(i.networkType||""," ").concat("relay"===i.candidateType?"relayProtocol:".concat(i.relayProtocol):"")),this._localAddress="".concat(i.ip||i.address,":").concat(i.port)),r&&(this._log.info("remote candidate: ".concat(r.candidateType," ").concat(r.protocol,":").concat(r.ip||r.address,":").concat(r.port)),this._remoteAddress="".concat(r.protocol,":").concat(r.ip||r.address));break}}))}getCurrentState(){return this._currentState}waitForPeerConnectionConnected(){return this._waitForPeerConnectionConnectedPromise||(this._waitForPeerConnectionConnectedPromise=new Promise(((e,t)=>{if("CONNECTED"===this._currentState)return e();this._waitForPeerConnectionConnectedPromiseReject=t;let i=t=>{"CONNECTED"===t.state&&(clearTimeout(o),n(),e())},r=e=>{let{room:i}=e;i===this._room&&(clearTimeout(o),n(),t(new fC({code:_C.API_CALL_ABORTED,message:GN({key:HN.CONNECTION_ABORTED,data:"leave room"})})))},n=()=>{JN.off(fO.LEAVE_SUCCESS,r,this),this._emitter.off("connection-state-changed",i,this)},o=setTimeout((()=>{n();let e=new fC({code:_C.API_CALL_TIMEOUT,message:"connection timeout"});var i;DV+=1,i=this._signalChannel.isConnected,DV>2&&!OV&&0===LV.size&&i&&(this._log.warn("firewall restrition"),OV=!0,this._emitter.emit("firewall-restriction")),t(e)}),TN);JN.on(fO.LEAVE_SUCCESS,r,this),this._emitter.on("connection-state-changed",i,this)})),this._waitForPeerConnectionConnectedPromise=this._waitForPeerConnectionConnectedPromise.finally((()=>{this._waitForPeerConnectionConnectedPromise=null,this._waitForPeerConnectionConnectedPromiseReject=null}))),this._waitForPeerConnectionConnectedPromise}getReconnectionCount(){return this._reconnectionCount}startReconnection(){this._isReconnecting=!0,this.reconnect()}clearReconnectionTimer(){-1!==this._reconnectionTimer&&(clearTimeout(this._reconnectionTimer),this._reconnectionTimer=-1)}stopReconnection(){this._log.info("stop reconnection"),this._isReconnecting=!1,this._reconnectionCount=0,this.clearReconnectionTimer(),this._signalChannel.off(Jx,this.reconnect,this)}beforeReconnect(){if(-1!==this._reconnectionTimer)return this._log.warn("reconnect() is reconnecting, ignore"),-1;if(this._reconnectionCount>=sN()){this._log.warn("SDK has tried reconnect for ".concat(this._reconnectionCount," times, but all failed, please check your network")),this.stopReconnection();let e=new fC({code:this._isUplink?_C.UPLINK_RECONNECTION_FAILED:_C.DOWNLINK_RECONNECTION_FAILED,message:GN({key:this._isUplink?HN.UPLINK_RECONNECTION_FAILED:HN.DOWNLINK_RECONNECTION_FAILED})});return this.emitConnectionStateChangedEvent("DISCONNECTED"),this._emitter.emit("error",e),-1}return this._signalChannel.isConnected?(this._reconnectionCount+=1,this._log.warn("reconnect() trying [".concat(this._reconnectionCount,"]")),1):(this._log.warn("reconnect() signal channel is not connected, suspend reconnection until signal is connected"),this._signalChannel.once(Jx,this.reconnect,this),-1)}on(e,t,i){this._emitter.on(e,t,i)}off(e,t,i){this._emitter.off(e,t,i)}getIsReconnecting(){return this._isReconnecting}get isH264(){var e,t;return!(null==(t=null==(e=this._peerConnection)?void 0:e.remoteDescription)||!t.sdp.includes("H264"))}},xV=$b(hC()),VV=function(e){return xV.default.parse(e)},UV=function(e){return xV.default.write(e)};function BV(e){return Object.keys(e).filter((t=>e[t]))}var FV=class extends MV{constructor(e){super(Xb(qb({},e),{isUplink:!1})),tC(this,"_flag",0),tC(this,"role","anchor"),tC(this,"remoteAudioTrack"),tC(this,"remoteVideoTrack"),tC(this,"remoteAuxiliaryTrack"),tC(this,"ssrc",{audio:0,video:0,auxiliary:0}),tC(this,"_isSDPExchanging",!1),this.flag=e.flag,this.remoteAudioTrack=e.remoteAudioTrack||new hM(this._room,this),this.remoteVideoTrack=e.remoteVideoTrack||new pM(this._room,this),this.remoteAuxiliaryTrack=e.remoteAuxiliaryTrack||new mM(this._room,this)}get subscribeState(){let e={audio:!1,video:!1,auxiliary:!1,smallVideo:!1};return this.remoteVideoTrack.isSubscribed&&(8&this.remoteVideoTrack.mediaType?e.smallVideo=!0:e.video=!0),this.remoteAudioTrack.isSubscribed&&(e.audio=!0),this.remoteAuxiliaryTrack.isSubscribed&&(e.auxiliary=!0),e}get muteState(){return qD(this.flag,this.userId)}get flag(){return this._flag}set flag(e){var t,i,r;e!==this._flag&&(this._flag=e,null==(t=this.remoteAudioTrack)||t.onFlagChanged(),null==(i=this.remoteVideoTrack)||i.onFlagChanged(),null==(r=this.remoteAuxiliaryTrack)||r.onFlagChanged())}get hasMainStream(){return this.muteState.hasAudio||this.muteState.hasVideo||this.muteState.hasSmall}get hasAuxStream(){return this.muteState.hasAuxiliary}get isMainStreamSubscribed(){return(this.subscribeState.audio||this.subscribeState.video||this.subscribeState.smallVideo)&&(this.muteState.hasAudio||this.muteState.hasVideo||this.muteState.hasSmall)}get isAuxStreamSubscribed(){return this.subscribeState.auxiliary&&this.muteState.hasAuxiliary}get isSmallStreamSubscribed(){return this.subscribeState.smallVideo&&this.muteState.hasSmall}get isBigStreamSubscribed(){return this.subscribeState.video&&this.muteState.hasVideo}isStreamUnpublished(e){return e===Mw.MAIN?!this.muteState.hasAudio&&!this.muteState.hasVideo:!this.muteState.hasAuxiliary}initialize(){super.initialize(),this.installEvents(),this._peerConnection.ontrack=this.onTrack.bind(this)}close(e){super.close(e),this.emitConnectionStateChangedEvent("DISCONNECTED"),this.remoteAudioTrack.close(),this.remoteVideoTrack.close(),this.remoteAuxiliaryTrack.close(),this.uninstallEvents()}installEvents(){}uninstallEvents(){this._emitter.removeAllListeners()}emitConnectionStateChangedEvent(e){var t,i;let r=this._currentState,n=super.emitConnectionStateChangedEvent(e);return n&&r!==e&&(null==(t=this.remoteVideoTrack)||t.emit("connection-state-changed",{prevState:r,state:e}),null==(i=this.remoteAuxiliaryTrack)||i.emit("connection-state-changed",{prevState:r,state:e})),n}onTrack(e){let t=e.streams[0],{track:i}=e,r=t.id===Gw?Mw.MAIN:Mw.AUXILIARY;this._log.debug("ontrack ".concat(r," ").concat(i.kind));let n=Mw.AUDIO;i.kind===Mw.VIDEO&&(n=r===Mw.MAIN?Mw.VIDEO:Mw.AUXILIARY);let o=this.remoteAudioTrack;n===Mw.VIDEO?o=this.remoteVideoTrack:n===Mw.AUXILIARY&&(o=this.remoteAuxiliaryTrack),o.setInputMediaStreamTrack(i)}addRRTRLine(e){let t=e.split("\r\n"),i=new Map;t.forEach(((e,r)=>{/^a=rtcp-fb:/.test(e)&&t[r+1]&&!/^a=rtcp-fb:/.test(t[r+1])&&i.set(r+1,"".concat(e.match(/^a=rtcp-fb:\d+/)[0]," rrtr"))}));let r=[...i];for(let n=0;n<r.length;n++){let[e,i]=r[n];t.splice(e+n,0,i)}return t.join("\r\n")}addSPSDescription(e){let t=VV(e);return t.media.forEach((e=>{e.type===Mw.VIDEO&&e.fmtp.forEach((e=>{e.config+=";sps-pps-idr-in-keyframe=1"}))})),UV(t)}removeSDESDescription(e){let t=["urn:ietf:params:rtp-hdrext:sdes:mid","urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id","urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"],i=VV(e);return i.media.forEach((e=>{!e.ext||(e.ext=e.ext.filter((e=>!t.includes(e.uri))))})),UV(i)}isSubscriptionStateNotChanged(e){return JSON.stringify(e)===JSON.stringify(this.subscribeState)}subscribe(e,t){return rC(this,null,(function*(){var i,r;try{if(((null==(i=this._peerConnection)?void 0:i.connectionState)===rN.NEW||(null==(r=this._peerConnection)?void 0:r.connectionState)===rN.CONNECTING)&&(yield this.waitForPeerConnectionConnected()),this.isSubscriptionStateNotChanged(e))return void(this._peerConnection||(this.initialize(),yield this.connect(e)));if(this._log.info("subscribe ".concat(t," ").concat(JSON.stringify(e))),this._peerConnection||this._isSDPExchanging){let t="subscribe_change";Object.values(e).find((e=>!0===e))||(t="unsubscribe"),yield this.sendSubscription(t,e)}else this.initialize(),yield this.connect(e)}catch(n){throw this._room.isJoined&&this.isStreamUnpublished(t)?(this._log.warn("".concat(n.message," ").concat(JSON.stringify(this.muteState))),new fC({code:_C.REMOTE_STREAM_NOT_EXIST,message:"remote user ".concat(this.userId," unpublished stream")})):n}}))}unsubscribe(e){return rC(this,arguments,(function(e){var t=this;let{remoteTracks:i,streamType:r}=e;return function*(){if("CONNECTED"===t._currentState&&("main"===r&&!t.isMainStreamSubscribed||"auxiliary"===r&&!t.isAuxStreamSubscribed))return void t._log.info("".concat(r," stream already unsubscribed"));let e=qb({},t.subscribeState);i.forEach((t=>{switch(t.mediaType){case 1:e.audio=!1;break;case 4:e.video=!1;break;case 8:e.smallVideo=!1;break;case 2:e.auxiliary=!1}}));let n="subscribe_change";Object.values(e).find((e=>!0===e))||(n="unsubscribe"),t._log.info("".concat("unsubscribe"===n?n:"subscribe"," ").concat(r," [").concat(BV(e),"]")),yield t.sendSubscription(n,e),"unsubscribe"===n&&(t.closePeerConnection(),t.emitConnectionStateChangedEvent("DISCONNECTED"))}()}))}sendSubscription(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.subscribeState,i={srcTinyId:this.tinyId,srcUserId:this.userId},r=cV,n=Zx.UNSUBSCRIBE_RESULT;return"subscribe_change"===e&&(i={audio:t.audio,bigVideo:t.video,auxVideo:t.auxiliary,smallVideo:t.smallVideo,srcTinyId:this.tinyId},r=lV,n=Zx.SUBSCRIBE_CHANGE_RESULT),this._signalChannel.sendWaitForResponse({command:r,data:i,responseCommand:n,timeout:1e4}).then((t=>{let{data:i}=t;if(0!==i.code){let t=new fC({code:i.code,message:GN({key:HN.ERROR_MESSAGE,data:{type:e,message:i.message}})});throw this._log.error(t),t}}))}connect(){return rC(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.subscribeState;return function*(){try{yield e.exchangeSDP(t),yield e.waitForPeerConnectionConnected()}catch(i){throw e.closePeerConnection(!0),i}}()}))}exchangeSDP(e){return rC(this,null,(function*(){try{this._isSDPExchanging=!0,yield this.createOffer(),this._log.info("createOffer success, sending offer");let{type:t,sdp:i}=this._peerConnection.localDescription,r={type:t,sdp:i,srcUserId:this.userId,srcTinyId:this.tinyId,audio:e.audio,bigVideo:e.video,auxVideo:e.auxiliary,smallVideo:e.smallVideo},n=yield this._signalChannel.sendWaitForResponse({command:aV,commandDesc:"exchange sdp",data:r,responseCommand:Zx.SUBSCRIBE_RESULT,timeout:hN});if(!this._peerConnection){let e=new fC({code:_C.INVALID_OPERATION,message:GN({key:HN.CONNECTION_CLOSED})});throw this._log.warn(e),e}yield this.onSubscribeResult(n),this._isSDPExchanging=!1}catch(t){throw this._isSDPExchanging=!1,t}}))}createOffer(){return rC(this,null,(function*(){let e={voiceActivityDetection:!1};JO()&&this._sdpSemantics===pN?(this._peerConnection.addTransceiver(Mw.AUDIO,{direction:xw.RECVONLY}),this._peerConnection.addTransceiver(Mw.VIDEO,{direction:xw.RECVONLY}),this._peerConnection.addTransceiver(Mw.VIDEO,{direction:xw.RECVONLY})):(e.offerToReceiveAudio=!0,e.offerToReceiveVideo=!0);let t=yield this._peerConnection.createOffer(e);if(t.sdp){let{isH264DecodeSupported:e}=yield LO();e||(this._log.warn("remove h264 desc from sdp"),t.sdp=function(e){let t=VV(e);return t.media.forEach((e=>{var t,i;if(e.type===Mw.VIDEO){let r=new Set;e.rtp.forEach((e=>{let{payload:t,codec:i}=e;return"H264"===i&&r.add(t)})),e.fmtp.forEach((e=>{let{payload:t,config:i}=e,n=i.match(/apt=(\d+)/);n&&n[1]&&r.has(Number(n[1]))&&r.add(t)}));let n=e=>{let{payload:t}=e;return!r.has(t)};e.rtp=e.rtp.filter(n),e.rtcpFb=null==(t=e.rtcpFb)?void 0:t.filter(n),e.fmtp=e.fmtp.filter(n),e.payloads=null==(i=e.payloads)?void 0:i.split(" ").filter((e=>!r.has(Number(e)))).join(" ")}})),UV(t)}(t.sdp)),t.sdp=this.addRRTRLine(t.sdp),t.sdp=this.addSPSDescription(t.sdp),t.sdp=function(e){let t=VV(e);return t.media.forEach((e=>{e.type===Mw.AUDIO&&e.fmtp.forEach((e=>{e.config+=";sprop-stereo=1;stereo=1"}))})),UV(t)}(t.sdp),this._sdpSemantics===pN&&(t.sdp=this.removeSDESDescription(t.sdp))}yield this._peerConnection.setLocalDescription(t)}))}onSubscribeResult(e){return rC(this,null,(function*(){let{code:t,message:i=""}=e&&e.data||{},{type:r,sdp:n}=e&&e.data&&e.data.data||{};if(t===_N)throw new fC({code:_C.NOT_SUPPORTED_H264,message:GN({key:HN.NOT_SUPPORTED_H264DECODE})});try{if(0!==t)throw new fC({code:t,message:GN({key:HN.EXCHANGE_SDP_FAILED,data:{errMsg:i}})});this._log.debug("accept remote answer: ".concat(n)),yield this._peerConnection.setRemoteDescription({type:r,sdp:n}),this._sei&&(this._sei.handleEncodedStreams(),this._sei.onSEIMessage=e=>{this._emitter.emit("sei-message",Xb(qb({},e),{userId:this.userId}))}),this.updateSSRC(n)}catch(o){throw this._log.error(o),o}}))}updateSSRC(e){try{VV(e).media.forEach((e=>{if(e.ssrcs)if(e.type===Mw.AUDIO){let t=e.ssrcs.find((e=>{var t;return null==(t=e.value)?void 0:t.includes(Gw)}));t&&(this.ssrc.audio=Number(t.id))}else{let t=e.ssrcs.find((e=>{var t;return null==(t=e.value)?void 0:t.includes(Gw)})),i=e.ssrcs.find((e=>{var t;return null==(t=e.value)?void 0:t.includes(Kw)}));t&&(this.ssrc.video=Number(t.id)),i&&(this.ssrc.auxiliary=Number(i.id))}}))}catch(t){}}getMainStreamVideoTrackId(){return this.remoteVideoTrack&&this.remoteVideoTrack.mediaTrack?this.remoteVideoTrack.mediaTrack.id:""}getAuxStreamVideoTrackId(){return this.remoteAuxiliaryTrack&&this.remoteAuxiliaryTrack.mediaTrack?this.remoteAuxiliaryTrack.mediaTrack.id:""}reconnect(){return rC(this,null,(function*(){if(!(iC(FV.prototype,this,"beforeReconnect").call(this)<0))try{this.closePeerConnection(),this.initialize(),yield this.connect(),this.stopReconnection(),this._log.warn("reconnect() success")}catch(e){let t=kD(this._reconnectionCount);this._log.warn("reconnect() timeout, try again after ".concat(t/1e3,"s")),this._reconnectionTimer=setTimeout((()=>{this.clearReconnectionTimer(),this.reconnect()}),t)}}))}getIsReconnecting(){return this._isReconnecting}clearReconnectionTimer(){-1!==this._reconnectionTimer&&(clearTimeout(this._reconnectionTimer),this._reconnectionTimer=-1)}getCurrentState(){return this._currentState}setDelay(e){let{audioDelay:t,videoDelay:i}=e;this.remoteAudioTrack.stat.end2EndDelay=t,this.remoteVideoTrack.stat.end2EndDelay=i}},HV=FV;eC([JP((e=>function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];return new Promise(((t,r)=>{let n=e=>{this._emitter.off("closed",n),r(new fC({code:_C.API_CALL_ABORTED,message:GN({key:HN.CONNECTION_ABORTED,data:e})}))};this._emitter.on("closed",n),e.apply(this,i).then(t,r).finally((()=>{this._emitter.off("closed",n)}))}))}))],HV.prototype,"subscribe",1),eC([YP(MV.prototype.afterConnect),KP(MV.prototype.beforeConnect)],HV.prototype,"connect",1);var jV=HV,WV={voiceActivityDetection:!1},zV=class extends MV{constructor(e){super(Xb(qb({},e),{isUplink:!0})),tC(this,"localMainAudioTrack",null),tC(this,"localMainVideoTrack",null),tC(this,"localAuxAudioTrack",null),tC(this,"localAuxVideoTrack",null),tC(this,"ssrc",{audio:0,video:0,small:0,auxiliary:0}),tC(this,"_isPublishingAux",!1),tC(this,"_publishingLocalAudioTrack"),tC(this,"_publishingLocalVideoTrack"),tC(this,"_mediaSettings",{videoCodec:"",videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioCodec:"opus",audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0,auxVideoWidth:0,auxVideoHeight:0,auxVideoFps:0,auxVideoBps:0}),tC(this,"_audioManager"),this._audioManager=e.audioManager}get isMainStreamPublished(){return!(!this.localMainAudioTrack&&!this.localMainVideoTrack)}get isAuxStreamPublished(){return!(!this.localAuxVideoTrack&&!this.localAuxAudioTrack)}get publishState(){var e,t,i,r;let n={audio:!1,bigVideo:!1,smallVideo:!1,auxVideo:!1};if(this._peerConnection){let o=this._peerConnection.getSenders();o&&(YO()?(n.audio=!(null==(e=o[0])||!e.track),n.bigVideo=!(null==(t=o[1])||!t.track),n.smallVideo=!(null==(i=o[2])||!i.track),n.auxVideo=!(null==(r=o[3])||!r.track)):o.forEach((e=>{e.track&&(e.track.kind===Mw.AUDIO?n.audio=!0:(n.bigVideo=!0,this._room.videoManager.hasSmall&&(n.smallVideo=!0)))})))}return n}initialize(){super.initialize(),this.installEvents()}reset(){this._isReconnecting&&this.stopReconnection(),this.closePeerConnection(),this.uninstallEvents()}close(e){super.close(e),this.reset(),this.emitConnectionStateChangedEvent("DISCONNECTED")}installEvents(){this._emitter.listeners("connection-state-changed").includes(this.handleConnectionStateChange)||this._emitter.on("connection-state-changed",this.handleConnectionStateChange,this)}uninstallEvents(){this._emitter.off("connection-state-changed",this.handleConnectionStateChange,this)}emitConnectionStateChangedEvent(e,t){var i,r,n;let o=this._currentState,s=super.emitConnectionStateChangedEvent(e);return s&&o!==e&&(t?t.emit("connection-state-changed",{prevState:o,state:e}):(null==(i=this.localMainVideoTrack)||i.emit("connection-state-changed",{prevState:o,state:e}),null==(r=this.localAuxVideoTrack)||r.emit("connection-state-changed",{prevState:o,state:e}),null==(n=this._publishingLocalVideoTrack)||n.emit("connection-state-changed",{prevState:o,state:e}))),s}publish(e){return rC(this,arguments,(function(e){var t=this;let{localAudioTrack:i,localVideoTrack:r,isAuxiliary:n}=e;return function*(){var e;let o;t._peerConnection||t.initialize(),i&&(t._publishingLocalAudioTrack=i),r&&(t._publishingLocalVideoTrack=r),t._isPublishingAux=n,r&&!n&&r.small&&(o=t._room.videoManager.smallTrack),t.sendMediaSettings(),JO()?yield t.publishByTransceiver({localAudioTrack:i,localVideoTrack:r,smallTrack:o,isAuxiliary:n}):yield t.publishByAddTrack({localAudioTrack:i,localVideoTrack:r,smallTrack:o}),t._publishingLocalAudioTrack=null,t._publishingLocalVideoTrack=null,t._isPublishingAux=!1,n?(r&&(t.localAuxVideoTrack=r),i&&(t.localAuxAudioTrack=i)):(r&&(t.localMainVideoTrack=r),i&&(t.localMainAudioTrack=i)),null==(e=t._sei)||e.handleEncodedStreams(),t.installTrackMuteEvents(i,r),t.sendMutedFlag()}()}))}publishByTransceiver(e){return rC(this,arguments,(function(e){var t=this;let{localAudioTrack:i,localVideoTrack:r,smallTrack:n,isAuxiliary:o}=e;return function*(){t._log.info("publish by transceiver");let e=new MediaStream,s=null==r?void 0:r.outMediaTrack,a=null==i?void 0:i.outMediaTrack;a&&e.addTrack(a),s&&e.addTrack(s);let c=t._peerConnection.getTransceivers();if(0===c.length)t._peerConnection.addTransceiver(a||Mw.AUDIO,{direction:xw.SENDONLY,streams:[e]}),t._peerConnection.addTransceiver(o?Mw.VIDEO:s||Mw.VIDEO,{direction:xw.SENDONLY,streams:[e]}),t._peerConnection.addTransceiver(n||Mw.VIDEO,{direction:xw.SENDONLY,streams:[e]}),t._peerConnection.addTransceiver(o&&s||Mw.VIDEO,{direction:xw.SENDONLY,streams:[e]}),yield t.connect();else{let e=[];if(a&&(c[0].sender.track||e.push(0),yield c[0].sender.replaceTrack(a),yield t.setBandwidth({bandwidth:(null==i?void 0:i.profile.bitrate)||40,type:Mw.AUDIO})),s){let i=o?3:1;yield c[i].sender.replaceTrack(s),yield t.setBandwidth({bandwidth:r.profile.bitrate,type:Mw.VIDEO,videoType:o?Mw.AUXILIARY:Mw.BIG}),e.push(i),n&&(yield c[2].sender.replaceTrack(n),yield t.setBandwidth({bandwidth:r.small.bitrate,type:Mw.VIDEO,videoType:Mw.SMALL}),e.push(2))}yield t.setTransceiverDirection(xw.SENDONLY,e),yield t.doPublishChange(),null==r||r.emit("connection-state-changed",{prevState:"DISCONNECTED",state:"CONNECTING"}),null==r||r.emit("connection-state-changed",{prevState:"CONNECTING",state:"CONNECTED"})}}()}))}publishByAddTrack(e){return rC(this,arguments,(function(e){var t=this;let{localAudioTrack:i,localVideoTrack:r,smallTrack:n}=e;return function*(){t._log.info("publish by addtrack");let e=null==r?void 0:r.outMediaTrack,o=null==i?void 0:i.outMediaTrack;if(t._peerConnection&&"new"!==t._peerConnection.connectionState)return i&&o&&(yield t.addTrack(i)),void(e&&(yield t.addTrack(r)));let s=new MediaStream;if(o&&s.addTrack(o),e&&s.addTrack(e),o&&t._peerConnection.addTrack(o,s),e&&(t._peerConnection.addTrack(e,s),n)){let e=new MediaStream;e.addTrack(n),t._peerConnection.addTrack(n,e)}yield t.connect()}()}))}enableSmall(e){return rC(this,null,(function*(){let t=this._peerConnection.getTransceivers();e?this._room.videoManager.smallTrack&&(yield t[2].sender.replaceTrack(this._room.videoManager.smallTrack),yield this.setTransceiverDirection(xw.SENDONLY,[2])):(yield t[2].sender.replaceTrack(null),yield this.setTransceiverDirection(xw.INACTIVE,[2])),this.updateMediaSettings(),yield this.doPublishChange()}))}installTrackMuteEvents(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];t.forEach((e=>{e&&(null==e||e.on("mute",this.sendMutedFlag,this),null==e||e.on("unmute",this.sendMutedFlag,this))}))}uninstallTrackMuteEvents(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];t.forEach((e=>{e&&(null==e||e.off("mute",this.sendMutedFlag,this),null==e||e.off("unmute",this.sendMutedFlag,this))}))}unpublish(e){return rC(this,arguments,(function(e){var t=this;let{localAudioTrack:i,localVideoTrack:r}=e;return function*(){if(!YO())return i&&i.outMediaTrack&&!r&&t.localMainVideoTrack?(yield t.removeTrack(i),void(t.localMainAudioTrack=null)):r&&r.outMediaTrack&&!i&&t.localMainAudioTrack?(yield t.removeTrack(r),void(t.localMainVideoTrack=null)):(yield t.doUnpublish(),t.uninstallTrackMuteEvents(i,r),void t.emitConnectionStateChangedEvent("DISCONNECTED",r));let e=r&&r===t.localAuxVideoTrack,n=null==r?void 0:r.outMediaTrack,o=t._peerConnection.getSenders(),s=[];i&&(yield o[0].replaceTrack(null),s.push(0),e?t.localAuxAudioTrack=null:t.localMainAudioTrack=null),n&&(e?(yield o[3].replaceTrack(null),t.localAuxVideoTrack=null,t._mediaSettings=Xb(qb({},t._mediaSettings),{auxVideoBps:0,auxVideoFps:0,auxVideoWidth:0,auxVideoHeight:0}),s.push(3)):(yield o[1].replaceTrack(null),yield o[2].replaceTrack(null),t.localMainVideoTrack=null,t._mediaSettings=Xb(qb({},t._mediaSettings),{videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0}),s.push(1,2))),t.isMainStreamPublished||t.isAuxStreamPublished?(yield t.setTransceiverDirection(xw.INACTIVE,s),yield t.doPublishChange(!1)):yield t.doUnpublish(),t.uninstallTrackMuteEvents(i,r),null==r||r.emit("connection-state-changed",{prevState:t._currentState,state:"DISCONNECTED"})}()}))}doPublishChange(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return rC(this,null,(function*(){let t={state:this.publishState,constraintConfig:this._mediaSettings},i=yield this._signalChannel.sendWaitForResponse({command:oV,data:t,responseCommand:Zx.PUBLISH_STATE_CHANGE_RESULT,enableLog:e});this.checkPublishResultCode(i.data.code,i.data.message)}))}doUnpublish(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this._signalChannel.sendWaitForResponse({command:sV,commandDesc:"unpublish",responseCommand:Zx.UNPUBLISH_RESULT,enableLog:e}).catch((e=>{if(e.getCode()===_C.API_CALL_TIMEOUT)return Promise.resolve();throw e}))}updateMediaSettings(){let{detail:{isH264EncodeSupported:e,isVp8EncodeSupported:t}}=this._room.checkSystemResult;e?this._mediaSettings.videoCodec="H264":t&&(this._mediaSettings.videoCodec="VP8");let i=this._publishingLocalAudioTrack||this.localMainAudioTrack||this.localAuxAudioTrack,{localMainVideoTrack:r,localAuxVideoTrack:n}=this;if(this._publishingLocalVideoTrack&&(this._isPublishingAux?n=this._publishingLocalVideoTrack:r=this._publishingLocalVideoTrack),$O){if(i&&i.outMediaTrack){let e=i.outMediaTrack.getSettings();this._mediaSettings.audioChannel=e.channelCount||1,this._mediaSettings.audioBps=1e3*i.profile.bitrate,this._mediaSettings.audioFs=e.sampleRate||0}if(r&&r.outMediaTrack){let e=r.outMediaTrack.getSettings();this._mediaSettings.videoWidth=e.width||0,this._mediaSettings.videoHeight=e.height||0,this._mediaSettings.videoFps=e.frameRate||0,this._mediaSettings.videoBps=1e3*r.profile.bitrate,r.small&&(this._mediaSettings.smallVideoWidth=r.small.width,this._mediaSettings.smallVideoHeight=r.small.height,this._mediaSettings.smallVideoFps=r.small.frameRate,this._mediaSettings.smallVideoBps=1e3*r.small.bitrate)}if(n&&n.outMediaTrack){let e=n.outMediaTrack.getSettings();this._mediaSettings.auxVideoWidth=e.width||0,this._mediaSettings.auxVideoHeight=e.height||0,this._mediaSettings.auxVideoFps=e.frameRate||0,this._mediaSettings.auxVideoBps=1e3*n.profile.bitrate}}else i&&i.outMediaTrack&&(this._mediaSettings.audioChannel=i.profile.channelCount,this._mediaSettings.audioBps=1e3*i.profile.bitrate,this._mediaSettings.audioFs=i.profile.sampleRate),r&&r.outMediaTrack&&(this._mediaSettings.videoWidth=r.profile.width,this._mediaSettings.videoHeight=r.profile.height,this._mediaSettings.videoFps=r.profile.frameRate,this._mediaSettings.videoBps=1e3*r.profile.bitrate);this._log.info("updateMediaSettings: ".concat(JSON.stringify(this._mediaSettings)))}sendMediaSettings(){this.updateMediaSettings(),this._signalChannel.sendWaitForResponse({command:EV,data:this._mediaSettings,responseCommand:Zx.UPDATE_CONSTRAINT_CONFIG_RES}).then((e=>{0!==e.data.code&&this._log.warn(e.data.message)})).catch((()=>{}))}addTrack(e){return rC(this,null,(function*(){var t;if(!this._peerConnection)return;let i=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack;this._log.info("is adding ".concat(e.kind," track to current published local ").concat(i?Mw.AUXILIARY:Mw.MAIN," stream")),null==(t=this._sei)||t.handleEncodedStreams(),JO()?yield this.addTrackByTransceiver(e,i):yield this.addTrackBySender(e)}))}addTrackByTransceiver(e,t){return rC(this,null,(function*(){var i;if(!e.mediaTrack)return;let r=this._peerConnection.getTransceivers();if(e.kind===Mw.AUDIO)yield r[0].sender.replaceTrack(e.outMediaTrack);else{let n=t?3:1;yield r[n].sender.replaceTrack(e.outMediaTrack),1===n&&(null==(i=this.localMainVideoTrack)?void 0:i.small)&&(yield r[2].sender.replaceTrack(this._room.videoManager.smallTrack)),r[n].direction===xw.INACTIVE&&(yield this.setTransceiverDirection(xw.SENDONLY,[n]))}this.updateMediaSettings(),yield this.doPublishChange()}))}addTrackBySender(e){return rC(this,null,(function*(){if(!e.outMediaTrack)return;let t=e.outMediaTrack;YO()&&this._peerConnection.getTransceivers().findIndex((e=>"stopped"===e.direction))>=0&&(this._log.warn("transceiver is stopping, negotiate sdp first"),yield this.updateOffer("remove",t));let i=this._peerConnection.getSenders().find((e=>e.track&&e.track.kind===t.kind));if(i&&i.track){this._log.warn("sender already exists, remove sender first");let e=i.track;this.removeSender(i),yield this.updateOffer("remove",e)}if(t&&this._peerConnection.addTrack(t,new MediaStream([t])),t.kind===Mw.VIDEO&&e instanceof rM&&e.small){let e=new MediaStream,{smallTrack:t}=this._room.videoManager;e.addTrack(t),this._peerConnection.addTrack(t,e)}yield this.updateOffer("add",t)}))}isNeedToResetOfferOrder(){if(this._sdpSemantics===mN||!this._peerConnection||!this._peerConnection.localDescription)return!1;let{sdp:e}=this._peerConnection.localDescription,t=VV(e);for(let i=0;i<t.media.length;i++)if(0===Number(t.media[i].mid)&&t.media[i].type===Mw.VIDEO)return!0;return!1}removeSender(e){let t=null;YO()&&(t=this._peerConnection.getTransceivers().find((t=>t.sender&&t.sender.track===e.track))),this._peerConnection.removeTrack(e),t&&ND(t.stop)&&(this._log.info("stop transceiver"),t.stop())}removeTrack(e){return rC(this,null,(function*(){if(!this._peerConnection)return;let t=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack;this._log.info("is removing ".concat(e.kind," track from current published local ").concat(t?Mw.AUXILIARY:Mw.MAIN," stream")),JO()?yield this.removeTrackByTransceiver(e,t):yield this.removeTrackBySender(e)}))}removeTrackByTransceiver(e,t){return rC(this,null,(function*(){if(!e.outMediaTrack)return;let i=this._peerConnection.getTransceivers();if(e.kind===Mw.AUDIO)yield i[0].sender.replaceTrack(null);else{let r=t?3:1;yield i[r].sender.replaceTrack(null),1===r&&e.small&&(yield i[2].sender.replaceTrack(null)),yield this.setTransceiverDirection(xw.INACTIVE,[r])}this.updateMediaSettings(),yield this.doPublishChange()}))}setTransceiverDirection(e,t){return rC(this,null,(function*(){if(!BC)return;let i=!1,r=!1;this._log.info("setting transceiver ".concat(t.join(",")," direction to ").concat(e));let n=this._peerConnection.getTransceivers();if(t.forEach((t=>{n[t].direction!==e&&(n[t].direction=e,i=!0)})),i){this._log.info("updating offer");let e=yield this._peerConnection.createOffer();yield this._peerConnection.setLocalDescription(e)}let o=-1,s=this._peerConnection.remoteDescription.sdp.split("\r\n").map((i=>{if(i.match(new RegExp("a=(".concat(xw.INACTIVE,"|").concat(xw.RECVONLY,"|").concat(xw.SENDONLY,")")))&&o++,t.includes(o)){if(e===xw.INACTIVE&&i.includes("a=".concat(xw.RECVONLY)))return r=!0,"a=".concat(e);if(e===xw.SENDONLY&&i.includes("a=".concat(xw.INACTIVE)))return r=!0,"a=".concat(xw.RECVONLY)}return i})).join("\r\n");r&&(this._log.info("updating answer"),yield this._peerConnection.setRemoteDescription({type:"answer",sdp:s}))}))}removeTrackBySender(e){return rC(this,null,(function*(){if(!e.outMediaTrack)return;if(e.kind===Mw.VIDEO&&this.isNeedToResetOfferOrder()&&this.localMainAudioTrack)return this.reset(),this.initialize(),void(yield this.publish({localAudioTrack:this.localMainAudioTrack,isAuxiliary:!1}));let t=this._peerConnection.getSenders().find((t=>t.track===e.outMediaTrack));t&&(this.removeSender(t),e.kind===Mw.VIDEO&&e.small&&this._peerConnection.getSenders().forEach((e=>{e.track&&e.track.kind===Mw.VIDEO&&this.removeSender(e)}))),yield this.updateOffer("remove",e.outMediaTrack)}))}replaceTrack(e){return rC(this,null,(function*(){var t;let i,r=null==(t=this._peerConnection)?void 0:t.getSenders();if(!r||0===r.length||!e.mediaTrack)return;if(i=JO()?e.kind===Mw.AUDIO?r[0]:r[1]:r.find((t=>t.track&&t.track.kind===e.kind)),!i)return;let n=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack;this._log.info("is replacing ".concat(e.kind," track on ").concat(n?Mw.AUXILIARY:Mw.MAIN," stream")),e.kind===Mw.AUDIO?yield i.replaceTrack(e.outMediaTrack):e.kind===Mw.VIDEO&&(n?r[3]&&(yield r[3].replaceTrack(e.outMediaTrack)):yield i.replaceTrack(e.outMediaTrack))}))}updateOffer(e,t){return rC(this,null,(function*(){try{let i=yield this._peerConnection.createOffer(WV);BC&&i.sdp&&(i.sdp=this.setSDPDirection(i.sdp,"sendrecv")),yield this._peerConnection.setLocalDescription(i);let r=this.updateMediaSettings(),n={action:e,trackId:t.id,kind:t.kind===Mw.VIDEO?"bigVideo":t.kind,type:"offer",sdp:this._peerConnection.localDescription.sdp,constraintConfig:r,state:this.publishState};this._log.info("createOffer success, sending updated offer to remote server"),this._log.debug("updatedOffer: ".concat(n.sdp));let o=yield this._signalChannel.sendWaitForResponse({command:$x,data:n,responseCommand:Zx.UPDATE_OFFER_RESULT,timeout:uN,commandDesc:"update offer"}),{code:s,message:a}=o.data;0!==s&&this.checkPublishResultCode(s,a),yield this.acceptAnswer(o.data.data),i.sdp&&this.updateSSRC(i.sdp)}catch(i){throw this._log.error(i),i}}))}setBandwidth(e){return rC(this,arguments,(function(e){var t=this;let{bandwidth:i,type:r,videoType:n,sdp:o}=e;return function*(){if(!ZO())return o?r===Mw.VIDEO?t.updateVideoBandwidthRestriction(o,i,n):t.updateAudioBandwidthRestriction(o,i):void 0;let e,s=t._peerConnection.getSenders();if(JO()){let t=0;r===Mw.VIDEO&&(t=n===Mw.SMALL?2:n===Mw.AUXILIARY?3:1),e=s[t]}else e=s.find((e=>e.track&&e.track.kind===r));if(e){let s=e.getParameters();(!s.encodings||0===s.encodings.length)&&(s.encodings=[{}]),s.encodings[0].maxBitrate=1e3*i;try{return yield e.setParameters(s),t._log.info("".concat(n||"").concat(r," bandwidth ").concat(i," kbps")),o}catch(a){if(t._log.info("failed to set bandwidth by setting maxBitrate: ".concat(a)),o)return r===Mw.VIDEO?t.updateVideoBandwidthRestriction(o,i,n):t.updateAudioBandwidthRestriction(o,i)}}return o}()}))}updateVideoBandwidthRestriction(e,t,i){let r="AS";BC&&(r="TIAS",t*=1e3);let n=0,o=-1;return i===Mw.SMALL?n=1:i===Mw.AUXILIARY&&(n=2),e.replace(/m=video (.*)\r\nc=IN (.*)\r\n/g,(e=>(o+=1,o===n?"".concat(e,"b=").concat(r,":").concat(t,"\r\n"):e)))}updateAudioBandwidthRestriction(e,t){let i="AS";return BC&&(i="TIAS",t*=1e3),e.replace(/m=audio (.*)\r\nc=IN (.*)\r\n/,"m=audio $1\r\nc=IN $2\r\nb=".concat(i,":").concat(t,"\r\n"))}removeBandwidthRestriction(e){return e.replace(/b=AS:.*\r\n/,"").replace(/b=TIAS:.*\r\n/,"")}removeVideoOrientation(e){return e.replace(/urn:3gpp:video-orientation/,"")}connect(){return rC(this,null,(function*(){try{yield this.exchangeSDP(),yield this.waitForPeerConnectionConnected()}catch(e){throw this.closePeerConnection(!0),this.uninstallEvents(),e}}))}exchangeSDP(){return rC(this,null,(function*(){try{yield this.createOffer(),this._log.info("createOffer success, sending offer to remote server"),yield this.doExchangeSDP()}catch(e){throw e}}))}createOffer(){return rC(this,null,(function*(){try{let e=yield this._peerConnection.createOffer(WV);yield this._peerConnection.setLocalDescription(e),e.sdp&&this.updateSSRC(e.sdp)}catch(e){throw e}}))}doExchangeSDP(){let e={command:nV,responseCommand:Zx.PUBLISH_RESULT,data:{type:this._peerConnection.localDescription.type,sdp:this.removeVideoOrientation(this._peerConnection.localDescription.sdp),screen:this.localMainVideoTrack instanceof aM||this.localAuxVideoTrack instanceof aM,state:this.publishState,constraintConfig:this._mediaSettings},enableLog:!1};return this._log.debug("sending sdp offer: ".concat(e.data.sdp)),this._signalChannel.sendWaitForResponse(e).then((e=>{let{code:t,message:i,data:r}=e.data;return 0===t?this.acceptAnswer(r):this.checkPublishResultCode(t,i)}))}setSDPDirection(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"all",r=VV(e);return r.media.forEach((e=>{("all"===i||e.type===i)&&(e.direction=t)})),UV(r)}acceptAnswer(e){return rC(this,null,(function*(){var t,i,r,n,o;try{let s;if(this._publishingLocalAudioTrack||this._publishingLocalVideoTrack||this.isMainStreamPublished){let e=(null==(t=this._publishingLocalVideoTrack)?void 0:t.profile.bitrate)||(null==(i=this.localMainVideoTrack)?void 0:i.profile.bitrate),o=(null==(r=this._publishingLocalAudioTrack)?void 0:r.profile.bitrate)||(null==(n=this.localMainAudioTrack)?void 0:n.profile.bitrate);if(e){let t=this._isPublishingAux?Mw.AUXILIARY:Mw.BIG;s=yield this.setBandwidth({bandwidth:e,type:Mw.VIDEO,sdp:s,videoType:t})}o&&(s=yield this.setBandwidth({bandwidth:o,type:Mw.AUDIO,sdp:s}))}if(s=this.removeVideoOrientation(e.sdp),null!=(o=this._publishingLocalVideoTrack)&&o.small){let{smallStreamConfig:e}=this._room;s=yield this.setBandwidth({bandwidth:this._publishingLocalVideoTrack.small.bitrate||e.bitrate,type:Mw.VIDEO,videoType:Mw.SMALL,sdp:s})}let a={type:e.type,sdp:s};yield this._peerConnection.setRemoteDescription(a),this._log.debug("accepted answer: ".concat(s))}catch(s){throw this._log.error("failed to accept remote answer ".concat(s)),s}}))}sendMutedFlag(e){var t,i,r;if(e===this.localAuxAudioTrack||e===this.localAuxVideoTrack)return;let n={audio:!(null==(t=this.localMainAudioTrack)||!t.muted),bigVideo:!(null==(i=this.localMainVideoTrack)||!i.muted),auxVideo:!(null==(r=this.localAuxVideoTrack)||!r.muted)};this._log.info("send muted state: ".concat(JSON.stringify(n))),this._signalChannel.send(rV,n)}getIsReconnecting(){return this._isReconnecting}reconnect(){return rC(this,null,(function*(){if(!(iC(zV.prototype,this,"beforeReconnect").call(this)<0))try{yield this._signalChannel.sendWaitForResponse({command:sV,responseCommand:Zx.UNPUBLISH_RESULT,enableLog:!1}),this.closePeerConnection(),this.initialize(),this.isMainStreamPublished&&(yield this.publish({localAudioTrack:this.localMainAudioTrack,localVideoTrack:this.localMainVideoTrack,isAuxiliary:!1})),this.isAuxStreamPublished&&(yield this.publish({localAudioTrack:this.localAuxAudioTrack,localVideoTrack:this.localAuxVideoTrack,isAuxiliary:!0})),this._log.warn("reconnect() uplink reconnect successfully"),this.stopReconnection()}catch(e){let t=kD(this._reconnectionCount);this._log.warn("reconnect() timeout, try again after ".concat(t/1e3,"s")),this._reconnectionTimer=setTimeout((()=>{this.clearReconnectionTimer(),this.reconnect()}),t)}}))}handleConnectionStateChange(e){"CONNECTED"===e.state&&(this.localMainVideoTrack||this._publishingLocalVideoTrack&&!this._isPublishingAux)&&JN.emit(fO.SEND_FIRST_VIDEO_FRAME,{room:this._room})}updateSSRC(e){try{VV(e).media.forEach(((e,t)=>{if(e.type===Mw.AUDIO){let t=e.ssrcs&&e.ssrcs[0];t&&(this.ssrc.audio=Number(t.id))}else{if(this._sdpSemantics===mN&&e.ssrcGroups)return void e.ssrcGroups.forEach(((e,t)=>{let i=Number(e.ssrcs.split(" ")[0]);0===t?this.ssrc.video=i:1===t&&(this.ssrc.small=i)}));let i=e.ssrcs&&e.ssrcs[0];if(!i)return;switch(t){case 1:this.ssrc.video=Number(i.id);break;case 2:this.ssrc.small=Number(i.id);break;case 3:this.ssrc.auxiliary=Number(i.id)}}}))}catch(t){}}getVideoTrackId(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Mw.VIDEO;if(this._peerConnection){let t=this._peerConnection.getSenders();if(e===Mw.AUXILIARY&&t[3]&&t[3].track)return t[3].track.id;if(e===Mw.VIDEO&&t[1]&&t[1].track)return t[1].track.id}if(this.localMainVideoTrack&&e===Mw.VIDEO){let e=this.localMainVideoTrack.mediaTrack;if(e)return e.id}if(this.localAuxVideoTrack&&e===Mw.AUXILIARY){let e=this.localAuxVideoTrack.mediaTrack;if(e)return e.id}return""}getSSRC(){return this.ssrc}checkPublishResultCode(e,t){if(0!==e)throw e===_N?(this._log.error(jN.NOT_SUPPORTED_H264ENCODE),new fC({code:_C.NOT_SUPPORTED_H264,message:GN({key:HN.NOT_SUPPORTED_H264ENCODE})})):new fC({code:_C.UNKNOWN,message:GN({key:HN.SIGNAL_RESPONSE_FAILED,data:{signalResponse:Zx.PUBLISH_RESULT,code:e,message:t}})})}sendSEI(e,t){var i;null==(i=this._sei)||i.push(e,t)}},GV=zV;eC([JP((e=>function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];return new Promise(((t,r)=>{let n=e=>{this._emitter.off("closed",n),r(new fC({code:_C.API_CALL_ABORTED,message:GN({key:HN.CONNECTION_ABORTED,data:e})}))};this._emitter.on("closed",n),e.apply(this,i).then(t,r).finally((()=>{this._emitter.off("closed",n)}))}))}))],GV.prototype,"publish",1),eC([YP(MV.prototype.afterConnect),KP(MV.prototype.beforeConnect)],GV.prototype,"connect",1);var KV=GV,YV=class{constructor(e,t){this.room=e,tC(this,"_log"),tC(this,"_prevReportTime"),tC(this,"_prevReport",{}),tC(this,"_prevEncoderImplementation"),tC(this,"_prevQualityLimitationReason"),tC(this,"_prevAuxQualityLimitationReason"),tC(this,"_prevDecoderImplementationMap",new Map),tC(this,"totalBytesSent",0),tC(this,"totalBytesReceived",0),tC(this,"_spcStats",null),this._log=t,this._prevReportTime=0,this._prevEncoderImplementation="",this._prevQualityLimitationReason="",this._prevAuxQualityLimitationReason=""}get statInterval(){return 0===this._prevReportTime?2:(Date.now()-this._prevReportTime)/1e3}getSenderStats(e){return rC(this,null,(function*(){let t={audio:{bytesSent:0,packetsSent:0,audioLevel:0,totalAudioEnergy:0},video:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},small:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},auxiliary:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},rtt:0},i=e.getPeerConnection(),r=e.getSSRC();if(i)try{if((this._spcStats||(yield i.getStats())).forEach((i=>{var n;if("outbound-rtp"===i.type)if((i.mediaType||i.kind)===Mw.VIDEO){let n,o;if(i.ssrc===r.video?(n=Mw.VIDEO,o=e.localMainVideoTrack):i.ssrc===r.small?n=Mw.SMALL:i.ssrc===r.auxiliary&&(o=e.localAuxVideoTrack,n=Mw.AUXILIARY),!n)return;t[n].bytesSent=i.bytesSent,t[n].packetsSent=i.packetsSent,t[n].framesEncoded=i.framesEncoded,DD(i.keyFramesEncoded)||(t[n].keyFramesEncoded=i.keyFramesEncoded),DD(i.nackCount)||(t[n].nackCount=i.nackCount),DD(i.pliCount)||(t[n].pliCount=i.pliCount),DD(i.retransmittedPacketsSent)||(t[n].retransmittedPacketsSent=i.retransmittedPacketsSent),DD(i.totalEncodeTime)||(t[n].totalEncodeTime=i.totalEncodeTime),DD(i.totalPacketSendDelay)||(t[n].totalPacketSendDelay=i.totalPacketSendDelay),i.ssrc===r.video?(!DD(i.encoderImplementation)&&this._prevEncoderImplementation!==i.encoderImplementation&&(this._log.info("encoderImplementation change to ".concat(i.encoderImplementation)),this._prevEncoderImplementation=i.encoderImplementation),!DD(i.qualityLimitationReason)&&0!==i.bytesSent&&this._prevQualityLimitationReason!==i.qualityLimitationReason&&(this._log.info("qualityLimitationReason change to ".concat(i.qualityLimitationReason)),this._prevQualityLimitationReason=i.qualityLimitationReason)):i.ssrc===r.auxiliary&&!DD(i.qualityLimitationReason)&&0!==i.bytesSent&&this._prevAuxQualityLimitationReason!==i.qualityLimitationReason&&(this._log.info("aux qualityLimitationReason change to ".concat(i.qualityLimitationReason)),this._prevAuxQualityLimitationReason=i.qualityLimitationReason)}else t.audio.bytesSent=i.bytesSent,t.audio.packetsSent=i.packetsSent;else"candidate-pair"===i.type?UO(i)&&LD(i.currentRoundTripTime)&&(t.rtt=Math.floor(1e3*i.currentRoundTripTime),this.totalBytesSent=i.bytesSent):"media-source"===i.type&&(i.kind===Mw.AUDIO?(t.audio.audioLevel=i.audioLevel||0,t.audio.totalAudioEnergy=i.totalAudioEnergy||0):i.kind===Mw.VIDEO&&(i.trackIdentifier===e.getVideoTrackId(Mw.VIDEO)?t.video.fpsCapture=i.framesPerSecond:i.trackIdentifier===e.getVideoTrackId(Mw.AUXILIARY)?t.auxiliary.fpsCapture=i.framesPerSecond:t.small.fpsCapture=i.framesPerSecond));if(!DD(i.audioLevel)&&(null==(n=e.localMainAudioTrack)?void 0:n.mediaTrack)&&i.trackIdentifier===e.localMainAudioTrack.mediaTrack.id&&(t.audio.audioLevel=i.audioLevel||0),!DD(i.frameWidth)){let n=Mw.SMALL;i.trackIdentifier===e.getVideoTrackId(Mw.VIDEO)||i.ssrc===r.video?n=Mw.VIDEO:(i.trackIdentifier===e.getVideoTrackId(Mw.AUXILIARY)||i.ssrc===r.auxiliary)&&(n=Mw.AUXILIARY),t[n].frameWidth=i.frameWidth,t[n].frameHeight=i.frameHeight,t[n].framesSent=i.framesSent}})),e.localMainAudioTrack){let i=e.localMainAudioTrack.getInternalAudioLevel();t.audio.micAudioLevel=i,0===t.audio.audioLevel&&(t.audio.audioLevel=i)}this.totalBytesSent||(this.totalBytesSent+=t.audio.bytesSent+t.video.bytesSent+t.auxiliary.bytesSent)}catch(n){this._log.warn("failed to getStats on sender connection ".concat(n))}return t}))}getReceiverStats(e){return rC(this,null,(function*(){let t={tinyId:e.tinyId,userId:e.userId,rtt:0,hasAudio:!1,hasVideo:!1,hasAuxiliary:!1,isSmallSubscribed:!1,audio:{bytesReceived:0,packetsReceived:0,packetsLost:0,p2pDelay:0,totalJitter:0,totalJitterCount:0,audioLevel:0,totalAudioEnergy:0,insertedSamplesForDeceleration:0,removedSamplesForAcceleration:0},video:{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0,fpsDecoded:0},auxiliary:{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0,fpsDecoded:0}},i=e.getPeerConnection();if(i)try{let{ssrc:r}=e,{muteState:n,subscribeState:o}=e;(this._spcStats||(yield i.getStats())).forEach((i=>{if("inbound-rtp"===i.type)if((i.mediaType||i.kind)===Mw.AUDIO){if(i.ssrc!==r.audio||!n.hasAudio)return;t.audio.packetsReceived=i.packetsReceived,t.audio.bytesReceived=i.bytesReceived,t.audio.packetsLost=i.packetsLost,i.insertedSamplesForDeceleration&&(t.audio.insertedSamplesForDeceleration=i.insertedSamplesForDeceleration),i.removedSamplesForAcceleration&&(t.audio.removedSamplesForAcceleration=i.removedSamplesForAcceleration);let{remoteAudioTrack:o}=e;o.stat.packetsReceived=i.packetsReceived,o.stat.bytesReceived=i.bytesReceived,o.stat.packetsLost=i.packetsLost,t.audio.p2pDelay=o.stat.end2EndDelay,i.jitterBufferDelay&&(t.audio.totalJitter=i.jitterBufferDelay,t.audio.totalJitterCount=i.jitterBufferEmittedCount),t.hasAudio=!0}else{if(BC&&0===i.bytesReceived)return;let s;i.ssrc===r.video&&n.hasVideo&&(t.video.packetsReceived=i.packetsReceived,t.video.bytesReceived=i.bytesReceived,t.video.packetsLost=i.packetsLost,t.video.framesReceived=i.framesReceived,t.video.framesDecoded=i.framesDecoded,t.video.fpsDecoded=i.framesPerSecond,t.hasVideo=!0,s=e.remoteVideoTrack,n.hasSmall&&o.smallVideo&&(t.isSmallSubscribed=!0),i.decoderImplementation&&(!this._prevDecoderImplementationMap.has(t.userId)||this._prevDecoderImplementationMap.get(t.userId)!==i.decoderImplementation)&&(this._log.info("".concat(t.userId," decoderImplementation change to ").concat(i.decoderImplementation)),this._prevDecoderImplementationMap.set(t.userId,i.decoderImplementation))),i.ssrc===r.auxiliary&&n.hasAuxiliary&&(t.auxiliary.packetsReceived=i.packetsReceived,t.auxiliary.bytesReceived=i.bytesReceived,t.auxiliary.packetsLost=i.packetsLost,t.auxiliary.framesReceived=i.framesReceived,t.auxiliary.framesDecoded=i.framesDecoded,t.auxiliary.fpsDecoded=i.framesPerSecond,s=e.remoteAuxiliaryTrack,t.hasAuxiliary=!0),s&&(s.stat.packetsReceived=i.packetsReceived,s.stat.bytesReceived=i.bytesReceived,s.stat.packetsLost=i.packetsLost,s.stat.framesReceived=i.framesReceived,s.stat.framesDecoded=i.framesDecoded,i.jitterBufferDelay&&(s.stat.jitterBufferDelay=Math.floor(i.jitterBufferDelay/i.jitterBufferEmittedCount*1e3)))}else"candidate-pair"===i.type&&UO(i)&&LD(i.currentRoundTripTime)&&(t.rtt=Math.floor(1e3*i.currentRoundTripTime),this.totalBytesReceived=i.bytesReceived);DD(i.frameWidth)||((i.trackIdentifier===e.getMainStreamVideoTrackId()||i.ssrc===r.video)&&(t.video.frameWidth=i.frameWidth,t.video.frameHeight=i.frameHeight,e.remoteVideoTrack.stat.frameWidth=i.frameWidth,e.remoteVideoTrack.stat.frameHeight=i.frameHeight),(i.trackIdentifier===e.getAuxStreamVideoTrackId()||i.ssrc===r.auxiliary)&&(t.auxiliary.frameWidth=i.frameWidth,t.auxiliary.frameHeight=i.frameHeight,e.remoteAuxiliaryTrack.stat.frameWidth=i.frameWidth,e.remoteAuxiliaryTrack.stat.frameHeight=i.frameHeight)),!DD(i.audioLevel)&&e.muteState.audioAvailable&&e.remoteAudioTrack.mediaTrack&&i.trackIdentifier===e.remoteAudioTrack.mediaTrack.id&&(t.audio.audioLevel=i.audioLevel||0,t.audio.totalAudioEnergy=i.totalAudioEnergy||0)})),0===t.audio.audioLevel&&e.muteState.audioAvailable&&(t.audio.audioLevel=e.remoteAudioTrack.getInternalAudioLevel()||0),this.totalBytesReceived||(this.totalBytesReceived+=t.audio.bytesReceived+t.video.bytesReceived+t.auxiliary.bytesReceived)}catch(r){this._log.warn("failed to getStats on receiver connection ".concat(r))}return t}))}getStats(e,t){return rC(this,null,(function*(){let i={},r=[];if(this.room.singlePC){let e=this.room.singlePC.getPeerConnection();if(!e)return{senderStats:i,receiverStats:r};let t=yield e.getStats(),n=[],o=new Set(["inbound-rtp","outbound-rtp","track","candidate-pair","media-source"]);t.forEach((e=>o.has(e.type)&&n.push(e))),this._spcStats=n}e&&(i=yield this.getSenderStats(e));for(let[e,n]of t){let e=yield this.getReceiverStats(n);r.push(e)}return{senderStats:i,receiverStats:r}}))}getDifferenceValue(e,t){if(wP(e))return t;let i=t-e;return i<0?0:i}prepareReport(e){let{stats:t,report:i,freezeMap:r}=e;if(!wP(t.senderStats)){let e={uint32_audio_level:t.senderStats.audio.audioLevel*UN,uint32_audio_energy:1e6*t.senderStats.audio.totalAudioEnergy,uint32_audio_codec_bitrate:t.senderStats.audio.bytesSent};t.senderStats.audio.micAudioLevel&&(e.uint32_mic_audio_level=t.senderStats.audio.micAudioLevel*UN);let r=[];if(t.senderStats.video.bytesSent){let e={uint32_video_stream_type:2,uint32_video_codec_fps:t.senderStats.video.framesSent,uint32_video_capture_fps:t.senderStats.video.fpsCapture,uint32_video_width:t.senderStats.video.frameWidth,uint32_video_height:t.senderStats.video.frameHeight,uint32_video_codec_bitrate:t.senderStats.video.bytesSent,uint32_video_enc_fps:t.senderStats.video.framesEncoded,uint32_key_frame_count:t.senderStats.video.keyFramesEncoded,uint32_nack_count:t.senderStats.video.nackCount,uint32_pli_count:t.senderStats.video.pliCount,uint32_encode_cost:1e3*(t.senderStats.video.totalEncodeTime||0),uint32_send_packet_cost:1e3*(t.senderStats.video.totalPacketSendDelay||0),uint32_video_arq_packets:t.senderStats.video.retransmittedPacketsSent};r.push(e)}if(t.senderStats.small.bytesSent){let e={uint32_video_stream_type:3,uint32_video_codec_fps:t.senderStats.small.framesSent||0,uint32_video_capture_fps:t.senderStats.small.fpsCapture||0,uint32_video_width:t.senderStats.small.frameWidth||0,uint32_video_height:t.senderStats.small.frameHeight||0,uint32_video_codec_bitrate:t.senderStats.small.bytesSent,uint32_video_enc_fps:t.senderStats.small.framesEncoded||0,uint32_key_frame_count:t.senderStats.small.keyFramesEncoded,uint32_nack_count:t.senderStats.small.nackCount,uint32_pli_count:t.senderStats.small.pliCount,uint32_encode_cost:1e3*(t.senderStats.small.totalEncodeTime||0),uint32_send_packet_cost:1e3*(t.senderStats.small.totalPacketSendDelay||0),uint32_video_arq_packets:t.senderStats.small.retransmittedPacketsSent};r.push(e)}if(t.senderStats.auxiliary.bytesSent){let e={uint32_video_stream_type:7,uint32_video_codec_fps:t.senderStats.auxiliary.framesSent||0,uint32_video_capture_fps:t.senderStats.auxiliary.fpsCapture||0,uint32_video_width:t.senderStats.auxiliary.frameWidth||0,uint32_video_height:t.senderStats.auxiliary.frameHeight||0,uint32_video_codec_bitrate:t.senderStats.auxiliary.bytesSent,uint32_video_enc_fps:t.senderStats.auxiliary.framesEncoded||0,uint32_key_frame_count:t.senderStats.auxiliary.keyFramesEncoded,uint32_nack_count:t.senderStats.auxiliary.nackCount,uint32_pli_count:t.senderStats.auxiliary.pliCount,uint32_encode_cost:1e3*(t.senderStats.auxiliary.totalEncodeTime||0),uint32_send_packet_cost:1e3*(t.senderStats.auxiliary.totalPacketSendDelay||0),uint32_video_arq_packets:t.senderStats.auxiliary.retransmittedPacketsSent};r.push(e)}let n={uint32_bitrate:0,uint32_lost:0,uint32_rtt:t.senderStats.rtt};i.msg_up_stream_info={msg_audio_status:e,msg_video_status:r,msg_network_status:n}}let{statInterval:n}=this;i.msg_down_stream_info=[],t.receiverStats.forEach((e=>{let t={msg_user_info:{str_identifier:e.userId,uint64_tinyid:e.tinyId},msg_network_status:{uint32_rtt:e.rtt,uint32_bitrate:0,uint32_lost:0},msg_audio_status:{},msg_video_status:[]};if(e.hasAudio){let i={uint32_audio_p2p_delay:e.audio.p2pDelay,uint32_audio_cache_ms:e.audio.totalJitter,uint32_audio_cache_ms_count:e.audio.totalJitterCount,uint32_audio_codec_bitrate:e.audio.bytesReceived,uint32_audio_total_bitrate:e.audio.bytesReceived,uint32_audio_level:1e8*e.audio.audioLevel,uint32_audio_energy:1e6*e.audio.totalAudioEnergy,uint32_audio_receive:e.audio.packetsReceived,uint32_audio_origin_lost:e.audio.packetsLost};t.msg_audio_status=i}if(e.hasVideo){let i=r.get("".concat(e.userId,"_").concat(Yw)),n=i?i.duration:0,o={uint32_video_stream_type:e.isSmallSubscribed?3:2,uint32_video_receive_fps:e.video.framesReceived,uint32_video_width:e.video.frameWidth,uint32_video_height:e.video.frameHeight,uint32_video_codec_bitrate:e.video.bytesReceived,uint32_video_receive:e.video.packetsReceived,uint32_video_origin_lost:e.video.packetsLost,uint32_video_block_time:n,uint32_video_dec_fps:e.video.framesDecoded};t.msg_video_status.push(o)}if(e.hasAuxiliary){let i=r.get("".concat(e.userId,"_").concat(Jw)),n=i?i.duration:0,o={uint32_video_stream_type:7,uint32_video_receive_fps:e.auxiliary.framesReceived,uint32_video_width:e.auxiliary.frameWidth,uint32_video_height:e.auxiliary.frameHeight,uint32_video_codec_bitrate:e.auxiliary.bytesReceived,uint32_video_receive:e.auxiliary.packetsReceived+e.auxiliary.packetsLost,uint32_video_origin_lost:e.auxiliary.packetsLost,uint32_video_block_time:n,uint32_video_dec_fps:e.auxiliary.framesDecoded};t.msg_video_status.push(o)}i.msg_down_stream_info.push(t)}));let o=this._prevReport;if(this._prevReport=JSON.parse(JSON.stringify(i)),i.msg_up_stream_info.msg_audio_status&&o.msg_up_stream_info.msg_audio_status){let e=o.msg_up_stream_info.msg_audio_status,t=i.msg_up_stream_info.msg_audio_status;if(0===e.uint32_audio_codec_bitrate)t.uint32_audio_codec_bitrate=0;else{let r=this.getDifferenceValue(e.uint32_audio_codec_bitrate,t.uint32_audio_codec_bitrate);t.uint32_audio_codec_bitrate=Math.round(8*r/n),i.msg_up_stream_info.msg_network_status.uint32_bitrate+=t.uint32_audio_codec_bitrate}}let s=o.msg_up_stream_info.msg_video_status;i.msg_up_stream_info.msg_video_status.forEach((e=>{let t=s.find((t=>t.uint32_video_stream_type===e.uint32_video_stream_type));if(!t||0===t.uint32_video_codec_bitrate)return e.uint32_video_codec_bitrate=0,e.uint32_video_enc_fps=0,void(e.uint32_video_codec_fps=0);let r=0,o=0,a=0;t&&e.uint32_video_codec_bitrate>=t.uint32_video_codec_bitrate&&(r=t.uint32_video_codec_bitrate,o=t.uint32_video_enc_fps,a=t.uint32_video_codec_fps);let c=this.getDifferenceValue(r,e.uint32_video_codec_bitrate);e.uint32_video_codec_bitrate=Math.round(8*c/n),i.msg_up_stream_info.msg_network_status.uint32_bitrate+=e.uint32_video_codec_bitrate,e.uint32_video_enc_fps=Math.round(this.getDifferenceValue(o,e.uint32_video_enc_fps)/n),e.uint32_video_codec_fps=Math.round(this.getDifferenceValue(a,e.uint32_video_codec_fps)/n),_k&&115===Lk()&&0===t.uint32_video_width&&0===t.uint32_video_height&&0===t.uint32_video_codec_fps&&(e.uint32_video_codec_fps=e.uint32_video_enc_fps),DD(t.uint32_key_frame_count)||(e.uint32_key_frame_count=Math.round(this.getDifferenceValue(t.uint32_key_frame_count,e.uint32_key_frame_count))),DD(t.uint32_nack_count)||(e.uint32_nack_count=Math.round(this.getDifferenceValue(t.uint32_nack_count,e.uint32_nack_count))),DD(t.uint32_pli_count)||(e.uint32_pli_count=Math.round(this.getDifferenceValue(t.uint32_pli_count,e.uint32_pli_count))),DD(t.uint32_video_arq_packets)||(e.uint32_video_arq_packets=Math.round(this.getDifferenceValue(t.uint32_video_arq_packets,e.uint32_video_arq_packets))),DD(t.uint32_encode_cost)||(e.uint32_encode_cost=Math.round(this.getDifferenceValue(t.uint32_encode_cost,e.uint32_encode_cost)/n)),DD(t.uint32_send_packet_cost)||(e.uint32_send_packet_cost=Math.round(this.getDifferenceValue(t.uint32_send_packet_cost,e.uint32_send_packet_cost)/n))}));let a=o.msg_down_stream_info;return i.msg_down_stream_info=i.msg_down_stream_info.filter((e=>a.find((t=>t.msg_user_info.uint64_tinyid===e.msg_user_info.uint64_tinyid)))),i.msg_down_stream_info.forEach((e=>{let t=a.find((t=>t.msg_user_info.uint64_tinyid===e.msg_user_info.uint64_tinyid));if(wP(e.msg_audio_status)||wP(t.msg_audio_status))e.msg_audio_status={};else{let i=e.msg_audio_status,r=t.msg_audio_status,o=this.getDifferenceValue(r.uint32_audio_cache_ms_count,i.uint32_audio_cache_ms_count);delete i.uint32_audio_cache_ms_count,i.uint32_audio_cache_ms=Math.floor(1e3*this.getDifferenceValue(r.uint32_audio_cache_ms,i.uint32_audio_cache_ms)/o)||0;let s=this.room.remotePublishedUserMap.get(e.msg_user_info.str_identifier);s&&(s.remoteAudioTrack.stat.jitterBufferDelay=i.uint32_audio_cache_ms),i.uint32_audio_origin_lost=this.getDifferenceValue(r.uint32_audio_origin_lost,i.uint32_audio_origin_lost),i.uint32_audio_receive=this.getDifferenceValue(r.uint32_audio_receive,i.uint32_audio_receive),i.uint32_audio_receive+=i.uint32_audio_origin_lost;let a=this.getDifferenceValue(r.uint32_audio_codec_bitrate,i.uint32_audio_codec_bitrate);i.uint32_audio_codec_bitrate=Math.round(8*a/n),i.uint32_audio_total_bitrate=Math.round(8*a/n)}if(e.msg_video_status&&t.msg_video_status){let i=t.msg_video_status;e.msg_video_status=e.msg_video_status.filter((e=>i.find((t=>t.uint32_video_stream_type===e.uint32_video_stream_type)))),e.msg_video_status.forEach((e=>{let t=i.find((t=>t.uint32_video_stream_type===e.uint32_video_stream_type)),r=t.uint32_video_receive,o=t.uint32_video_origin_lost,s=t.uint32_video_codec_bitrate,a=t.uint32_video_receive_fps,c=t.uint32_video_dec_fps;e.uint32_video_origin_lost=this.getDifferenceValue(o,e.uint32_video_origin_lost),e.uint32_video_receive=this.getDifferenceValue(r,e.uint32_video_receive)+e.uint32_video_origin_lost;let l=this.getDifferenceValue(s,e.uint32_video_codec_bitrate);e.uint32_video_codec_bitrate=Math.round(8*l/n);let d=this.getDifferenceValue(a,e.uint32_video_receive_fps);e.uint32_video_receive_fps=Math.round(d/n),e.uint32_video_dec_fps=Math.round(this.getDifferenceValue(c,e.uint32_video_dec_fps)/n)}))}})),i}getStatsReport(e){return rC(this,arguments,(function(e){var t=this;let{uplinkConnection:i,downlinkConnections:r,freezeMap:n}=e;return function*(){let e={msg_up_stream_info:{msg_audio_status:{uint32_audio_format:11,uint32_audio_sample_rate:0,uint32_audio_codec_bitrate:0,uint32_audio_receive:0,uint32_audio_origin_lost:0,uint32_audio_level:0,uint32_audio_energy:0},msg_video_status:[],msg_network_status:{uint32_bitrate:0,uint32_rtt:0,uint32_lost:0}},msg_down_stream_info:[{msg_user_info:{str_identifier:"",uint64_tinyid:0},msg_audio_status:{uint32_audio_cache_ms:0,uint32_audio_format:11,uint32_audio_sample_rate:0,uint32_audio_codec_bitrate:0,uint32_audio_total_bitrate:0,uint32_audio_level:0,uint32_audio_energy:0,uint32_audio_receive:0,uint32_audio_origin_lost:0,uint32_audio_final_lost:0},msg_video_status:[{uint32_video_stream_type:0,uint32_video_receive_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_codec_bitrate:0,uint32_video_receive:0,uint32_video_origin_lost:0,uint32_video_block_time:0,uint32_video_dec_fps:0}],msg_network_status:{uint32_bitrate:0,uint32_rtt:0,uint32_lost:0}}]},o=yield t.getStats(i,r);return"{}"===JSON.stringify(t._prevReport)&&(t._prevReport=JSON.parse(JSON.stringify(e))),t.prepareReport({stats:o,report:e,freezeMap:n}),t._prevReportTime=Date.now(),e}()}))}reset(){this._prevReportTime=0,this._prevReport={},this._prevEncoderImplementation="",this._prevQualityLimitationReason="",this._prevDecoderImplementationMap=new Map}},JV=$b(nC()),qV=class extends JV.default{constructor(e){let{signalChannel:t,room:i}=e;super(),tC(this,"_room"),tC(this,"_signalChannel"),tC(this,"_log"),tC(this,"_uplinkRTT",0),tC(this,"_uplinkLoss",0),tC(this,"_downlinkRTT",0),tC(this,"_downlinkLoss",0),tC(this,"_downlinkPrevStatMap",new Map),tC(this,"_downlinkLossAndRTTMap",new Map),tC(this,"_interval",-1),tC(this,"_uplinkNetworkQuality",0),tC(this,"_downlinkNetworkQuality",0),this._room=i,this._signalChannel=t,this._log=EO.createLogger({id:"q",userId:this._room.userId,sdkAppId:this._room.sdkAppId}),this.initialize()}get uplinkNetworkQuality(){return this._uplinkNetworkQuality}set uplinkNetworkQuality(e){e!==this._uplinkNetworkQuality&&this._log.info("uplink ".concat(this.uplinkNetworkQuality," -> ").concat(e,", rtt: ").concat(this._uplinkRTT,", loss: ").concat(this._uplinkLoss)),this._uplinkNetworkQuality=e}get downlinkNetworkQuality(){return this._downlinkNetworkQuality}set downlinkNetworkQuality(e){if(e!==this._downlinkNetworkQuality){let{rtt:t,loss:i}=this.getAverageLossAndRTT([...this._downlinkLossAndRTTMap.values()]);this._log.info("downlink ".concat(this.downlinkNetworkQuality," -> ").concat(e,", rtt: ").concat(t,", loss: ").concat(i))}this._downlinkNetworkQuality=e}initialize(){this._signalChannel.on(Zx.UPLINK_NETWORK_STATS,(e=>{this.handleUplinkNetworkQuality(e)})),this._signalChannel.on(Yx,this.handleSignalConnectionStateChange.bind(this)),this.start()}handleUplinkNetworkQuality(e){var t,i;if(0!==e.data.code)return;let r=e.data.data;if(r.delay&&this.updateDelay(r.delay),!this._room.uplinkConnection)return this.uplinkNetworkQuality=0,this._uplinkLoss=0,void(this._uplinkRTT=0);let n=null==(i=null==(t=this._room)?void 0:t.uplinkConnection)?void 0:i.getPeerConnection();if(n&&this.isPeerConnectionDisconnected(n))return this.uplinkNetworkQuality=6,this._uplinkLoss=0,void(this._uplinkRTT=0);let o=r.expectAudPkg+r.expectVidPkg,s=r.recvAudPkg+r.recvVidPkg,a=o-s;0===o&&0===s||(this._uplinkLoss=a<=0?0:Math.round(a/o*100),this._uplinkRTT=r.rtt,this.uplinkNetworkQuality=this.getNetworkQuality(this._uplinkLoss,this._uplinkRTT))}handleDownlinkNetworkQuality(){return rC(this,null,(function*(){if(0===this._room.remotePublishedUserMap.size)return void(this.downlinkNetworkQuality=0);let e=[...this._room.remotePublishedUserMap.values()],t=e.filter((e=>{var t;return(null==(t=e.getPeerConnection())?void 0:t.connectionState)===rN.CONNECTED}));if(e.filter((e=>this.isPeerConnectionDisconnected(e.getPeerConnection()))).length===e.length)return void(this.downlinkNetworkQuality=6);for(let n=0;n<t.length;n++){let e=t[n].getPeerConnection();if(!e)return;let{rtt:i,totalPacketsLost:r,totalPacketsReceived:o}=yield this.getStat(e);if(!this._downlinkPrevStatMap.has(e)){this._downlinkPrevStatMap.set(e,{totalPacketsLost:r,totalPacketsReceived:o});continue}let s=0,a=this._downlinkPrevStatMap.get(e),c=r-a.totalPacketsLost,l=o-a.totalPacketsReceived;s=c<=0||l<0?0:Math.round(c/(c+l)*100),this._downlinkPrevStatMap.set(e,{totalPacketsLost:r,totalPacketsReceived:o}),this._downlinkLossAndRTTMap.set(e,{rtt:i,loss:s,userId:t[n].getUserId(),audioDelay:t[n].remoteAudioTrack.stat.end2EndDelay,videoDelay:t[n].remoteVideoTrack.stat.end2EndDelay})}if([...this._downlinkPrevStatMap.keys()].forEach((e=>{this.isPeerConnectionDisconnected(e)&&(this._downlinkPrevStatMap.delete(e),this._downlinkLossAndRTTMap.delete(e))})),0===this._downlinkLossAndRTTMap.size)return;let{rtt:i,loss:r}=this.getAverageLossAndRTT([...this._downlinkLossAndRTTMap.values()]);this._downlinkRTT=i,this._downlinkLoss=r,this.downlinkNetworkQuality=this.getNetworkQuality(r,i)}))}getStat(e){return rC(this,null,(function*(){let t={rtt:0,totalPacketsLost:0,totalPacketsReceived:0};if(!e||!GO())return t;let i=e.getReceivers();try{for(let e=0;e<i.length;e++)(yield i[e].getStats()).forEach((e=>{"candidate-pair"===e.type&&LD(e.currentRoundTripTime)&&(t.rtt=Math.round(1e3*e.currentRoundTripTime)),"inbound-rtp"===e.type&&(e.mediaType===Mw.AUDIO||e.mediaType===Mw.VIDEO)&&(t.totalPacketsLost+=e.packetsLost,t.totalPacketsReceived+=e.packetsReceived)}));return t}catch(r){return t}}))}getAverageLossAndRTT(e){let t={rtt:0,loss:0};return Array.isArray(e)&&e.length>0&&(e.forEach((e=>{t.rtt+=e.rtt,t.loss+=e.loss})),Object.keys(t).forEach((i=>{t[i]=Math.round(t[i]/e.length)}))),t}getNetworkQuality(e,t){return e>50||t>500?5:e>30||t>350?4:e>20||t>200?3:e>10||t>100?2:e>=0||t>=0?1:0}handleSignalConnectionStateChange(e){"DISCONNECTED"===e.state?(this._uplinkRTT=0,this._uplinkLoss=0,this.uplinkNetworkQuality=6):"CONNECTED"===e.state&&6===this.uplinkNetworkQuality&&(this.uplinkNetworkQuality=5)}handleUplinkConnectionStateChange(e){let{state:t}=e;"DISCONNECTED"===t?(this._uplinkLoss=0,this._uplinkRTT=0,this.uplinkNetworkQuality=6):"CONNECTED"===t&&6===this.uplinkNetworkQuality&&(this.uplinkNetworkQuality=5)}isPeerConnectionDisconnected(e){return!(!e||e.connectionState!==rN.DISCONNECTED&&e.connectionState!==rN.FAILED&&e.connectionState!==rN.CLOSED)}setUplinkConnection(e){this._room.uplinkConnection=e,this._room.uplinkConnection?this._room.uplinkConnection.on("connection-state-changed",this.handleUplinkConnectionStateChange.bind(this)):(this.uplinkNetworkQuality=0,this._uplinkRTT=0,this._uplinkLoss=0)}start(){-1===this._interval?(this._log.debug("start network quality calculating"),this._interval=SL.run(LN,(()=>{this.handleDownlinkNetworkQuality();let e=[...this._downlinkLossAndRTTMap.values()];JN.emit(fO.NETWORK_QUALITY,{room:this._room,uplink:{rtt:this._uplinkRTT,loss:this._uplinkLoss},downlinks:e}),this.emit(qV.EVENT_NETWORK_QUALITY,{uplinkNetworkQuality:this.uplinkNetworkQuality,downlinkNetworkQuality:this.downlinkNetworkQuality,uplinkRTT:this._uplinkRTT,uplinkLoss:this._uplinkLoss,downlinkRTT:this._downlinkRTT,downlinkLoss:this._downlinkLoss,downlinkInfo:e})}),{delay:2e3})):this._log.info("network quality calculating is already started")}stop(){this._log.debug("stopped"),-1!==this._interval&&(SL.clearTask(this._interval),this._interval=-1),this._downlinkLossAndRTTMap.clear(),this._downlinkPrevStatMap.clear()}updateDelay(e){let{tinyIdToUserIdMap:t}=this._room;e.forEach((e=>{let{srcTinyId:i,videoDelay:r,audioDelay:n}=e,o=t.get(i);if(o){let e=this._room.remotePublishedUserMap.get(o);null==e||e.setDelay({videoDelay:r,audioDelay:n})}}))}},XV=qV;tC(XV,"EVENT_NETWORK_QUALITY","0");var QV=class{constructor(e){this._signalInfo={tinyId:void 0,clientIp:"",signalIp:"",relayIp:"",relayInnerIp:"",relayPort:0},this._eventMap=new Map,this._frameWorkType=e.frameWorkType||30,this._component=e.component||0,this.connectionType=e.connectionType||1,this._language=e.language||0,this._room=e.room,this._keyPrefix="key_point",this._log=EO.createLogger({id:"kpm",userId:this._room.userId,sdkAppId:this._room.sdkAppId}),Object.getOwnPropertyNames(this.__proto__).forEach((e=>{e.startsWith("handle")&&ND(this[e])&&(this[e]=function(e){let{fn:t,context:i}=e;return function(){try{for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];let o=t.apply(i,r);return BD(o)?o.catch((e=>EO.error("".concat(t.name,"() error observed ").concat(e)))):o}catch(o){EO.error("".concat(t.name,"() error observed ").concat(o))}}}({fn:this[e],context:this}))})),this.initData(),this.installEvents(),this._intervalId=SL.run(LN,this.setStorage.bind(this),{delay:2e4})}get _storageKey(){return"".concat(this._keyPrefix,"_").concat(this._room.userId)}initData(){this._firstPublishedUserList=[],this._networkQuality={totalUplinkRTT:0,totalUplinkLoss:0,count:0,totalDownlinkRTTAndLossMap:new Map},this._basicInfo={string_sdk_version:ow,uint32_os_type:15,string_device_name:"",string_http_user_agent:navigator.userAgent,string_os_version:"",uint32_avg_rtt:0,uint32_avg_up_loss:0,uint32_scene:"live"===this._room.scene?1:0,uint32_joining_duration:0,uint32_networkType:0,uint32_framework:this._frameWorkType,uint32_component:this._component,uint32_connection_type:this.connectionType,uint32_caller_coding_language:this._language,string_domain:location.hostname},this._pathJoinRoom={uint64_start_time:0,uint64_send_request_acc_ip_cmd_start_time:0,uint64_send_request_acc_ip_cmd_end_time:0,uint64_send_request_enter_room_cmd_start_time:0,uint64_send_request_enter_room_cmd_end_time:0,uint64_send_first_video_frame_time:0,uint64_recv_userlist_time:0,uint64_end_time:0,int32_send_request_acc_ip_cmd_ret:0,int32_send_request_enter_room_cmd_ret:0,int32_end_ret:0},this._pathLeaveRoom={uint64_start_time:0,uint64_send_request_exit_room_cmd_start_time:0,uint64_send_request_exit_room_cmd_end_time:0,uint64_end_time:0,int32_send_request_exit_room_cmd_ret:0,int32_end_ret:0},this._localStreamStat={totalVideoBitrate:0,totalVideoFPS:0,totalVideoHeight:0,totalVideoWidth:0,totalAudioLevel:0,videoCount:0,audioLevelCount:0,publishStartTime:0,statsToReport:{uint32_audio_capture_db:0,uint32_video_big_capture_fps:0,uint32_video_big_bitrate:0,uint32_video_big_resolution:0}},this._pathMainVideoMap=new Map,this._pathMainAudioMap=new Map,this._pathAuxiliaryMap=new Map,this._remoteStreamStatMap=new Map,$k().then((e=>{this._basicInfo.string_os_version=iw(),this._basicInfo.string_device_name=e&&e.mobile?e.model:this._basicInfo.string_os_version}))}addEvent(e,t){return this._eventMap.set(e,t),JN.on(e,t),this}installEvents(){this.handleUnload=this.handleUnload.bind(this),window.addEventListener("unload",this.handleUnload),this._room.once("banned",(()=>this.handleLeaveSuccess({room:this._room,roomId:this._room.roomId}))),this.addEvent(fO.JOIN_START,this.handleJoinStart).addEvent(fO.JOIN_SCHEDULE_SUCCESS,this.handleJoinScheduleSuccess).addEvent(fO.JOIN_SIGNAL_CONNECTION_START,this.handleSignalConnectionStart).addEvent(fO.JOIN_SIGNAL_CONNECTION_END,this.handleSignalConnectionEnd).addEvent(fO.JOIN_SEND_CMD,this.handleJoinSendCMD).addEvent(fO.JOIN_RECEIVED_CMD_RES,this.handleJoinReceivedCMDResponce).addEvent(fO.JOIN_SUCCESS,this.handleJoinSuccess).addEvent(fO.JOIN_FAILED,this.handleJoinFailed).addEvent(fO.LEAVE_START,this.handleLeaveStart).addEvent(fO.LEAVE_SUCCESS,this.handleLeaveSuccess).addEvent(fO.LEAVE_SEND_CMD,this.handleLeaveSendCMD).addEvent(fO.LOCAL_TRACK_CAPTURE_START,this.handleTrackCaptureStart).addEvent(fO.LOCAL_TRACK_CAPTURE_SUCCESS,this.handleTrackCaptureSuccess).addEvent(fO.LOCAL_TRACK_CAPTURE_FAILED,this.handleTrackCaptureFailed).addEvent(fO.PUBLISH_START,this.handlePublishStart).addEvent(fO.SEND_FIRST_VIDEO_FRAME,this.handleSendFirstVideoFrame).addEvent(fO.SUBSCRIBE_START,this.handleSubscribeStart).addEvent(fO.SUBSCRIBE_SUCCESS,this.handleSubscribed).addEvent(fO.PLAY_TRACK_START,this.handlePlayStart).addEvent(fO.VIDEO_LOADED_DATA,this.handleVideoLoadedData).addEvent(fO.PLAYER_STATE_CHANGED,(e=>{let{track:t,state:i,type:r}=e;!UD(t)||!this.hitTest(t.room)||"PLAYING"===i&&(r===Mw.AUDIO?this.handleAudioPlaying(t):this.handleVideoPlaying(t))})).addEvent(fO.NETWORK_QUALITY,this.handleNetworkQuality).addEvent(fO.HEARTBEAT_REPORT,this.handleHeartbeatStats).addEvent(fO.RECEIVED_PUBLISHED_USER_LIST,this.handleReceivedPublishUserList).addEvent(fO.REMOTE_PUBLISH_STATE_CHANGED,(e=>{let{room:t,prevMuteState:i,muteState:r}=e;if(!this.hitTest(t))return;let n=i.hasAudio||i.hasVideo||i.hasSmall,o=i.hasAuxiliary,s=r.hasAudio||r.hasVideo||r.hasSmall,a=r.hasAuxiliary;!n&&s&&this.handleRemoteStreamAdded(r.userId,"main"),!o&&a&&this.handleRemoteStreamAdded(r.userId,"auxiliary")})).addEvent(fO.SINGLE_CONNECTION_STAT,(e=>{let{room:t,stat:i}=e;this.hitTest(t)&&(this._pathJoinRoom.int32_ice_cost=i.ice,this._pathJoinRoom.int32_dtls_cost=i.dtls,this._pathJoinRoom.int32_peer_connection_cost=i.peerConnection)}))}uninstallEvents(){window.removeEventListener("unload",this.handleUnload),this._eventMap.forEach(((e,t)=>JN.off(t,e))),this._eventMap.clear()}destroy(){this.uninstallEvents(),SL.clearTask(this._intervalId)}handleUnload(){this._room.isJoined&&this.handleLeaveSuccess({room:this._room,roomId:this._room.roomId})}handleJoinStart(e){this.hitTest(e.room)&&(0===this._pathJoinRoom.uint64_start_time&&(this._pathJoinRoom.uint64_start_time=Date.now(),this.checkStorage()),e.params&&(DD(e.params.frameWorkType)||(this._frameWorkType=e.params.frameWorkType,this._basicInfo.uint32_framework=this._frameWorkType),DD(e.params.component)||(this._component=e.params.component,this._basicInfo.uint32_component=this._component),DD(e.params.language)||(this._language=e.params.language,this._basicInfo.uint32_caller_coding_language=this._language)))}handleJoinScheduleSuccess(e){let{room:t,detailCost:i}=e;if(this.hitTest(t)&&i){let{totalCost:e,local:t,dns:r,tcp:n,tls:o,request:s,response:a}=i;this._pathJoinRoom.int32_schedule_cost=e,this._pathJoinRoom.int32_schedule_local=t,this._pathJoinRoom.int32_schedule_dns=r,this._pathJoinRoom.int32_schedule_tcp=n,this._pathJoinRoom.int32_schedule_tls=o,this._pathJoinRoom.int32_schedule_request=s,this._pathJoinRoom.int32_schedule_response=a}}handleSignalConnectionStart(e){let{room:t}=e;this.hitTest(t)&&0===this._pathJoinRoom.uint64_send_request_acc_ip_cmd_start_time&&(this._pathJoinRoom.uint64_send_request_acc_ip_cmd_start_time=Date.now())}handleSignalConnectionEnd(e){let{room:t,error:i}=e;this.hitTest(t)&&0===this._pathJoinRoom.uint64_send_request_acc_ip_cmd_end_time&&(this._pathJoinRoom.uint64_send_request_acc_ip_cmd_end_time=Date.now(),i&&(this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret=i instanceof fC?Number(i.getExtraCode()||i.getCode()):_C.UNKNOWN,this._pathJoinRoom.int32_end_ret=this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret))}handleJoinSendCMD(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_send_request_enter_room_cmd_start_time&&(this._pathJoinRoom.uint64_send_request_enter_room_cmd_start_time=Date.now())}handleJoinReceivedCMDResponce(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_send_request_enter_room_cmd_end_time&&(this._pathJoinRoom.uint64_send_request_enter_room_cmd_end_time=Date.now(),this._pathJoinRoom.int32_send_request_enter_room_cmd_ret=e.code,0!==e.code&&(this._pathJoinRoom.int32_end_ret=this._pathJoinRoom.int32_send_request_enter_room_cmd_ret))}handleJoinSuccess(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_end_time&&(this._pathJoinRoom.uint64_end_time=Date.now(),this._pathJoinRoom.int32_end_ret=0,this._signalInfo=e.room.getSignalInfo())}handleJoinFailed(e){let{room:t,error:i}=e;this.hitTest(t)&&(this._pathJoinRoom.uint64_end_time=Date.now(),0===this._pathJoinRoom.int32_end_ret&&(this._pathJoinRoom.int32_end_ret=i.code||this._pathJoinRoom.int32_send_request_enter_room_cmd_ret||this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret),setTimeout((()=>{this.report()})))}handleReceivedPublishUserList(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_recv_userlist_time&&(this._pathJoinRoom.uint64_recv_userlist_time=Date.now(),this._firstPublishedUserList=e.publishedUserList||[])}handleSendFirstVideoFrame(e){let{room:t}=e;!this.hitTest(t)||0===this._pathJoinRoom.uint64_send_first_video_frame_time&&0!==this._pathJoinRoom.uint64_start_time&&(this._pathJoinRoom.uint64_send_first_video_frame_time=Date.now())}handleLeaveStart(e){this.hitTest(e.room)&&(this._pathLeaveRoom.uint64_start_time=Date.now())}handleLeaveSuccess(e){this.hitTest(e.room)&&0===this._pathLeaveRoom.uint64_end_time&&(this._pathLeaveRoom.uint64_end_time=Date.now(),0!==this._pathJoinRoom.uint64_end_time?this._basicInfo.uint32_joining_duration=this._pathLeaveRoom.uint64_end_time-this._pathJoinRoom.uint64_end_time:this._log.warn("pathJoinRoom endTime is 0"),this.report())}handleLeaveSendCMD(e){this.hitTest(e.room)&&(this._pathLeaveRoom.uint64_send_request_exit_room_cmd_start_time=Date.now(),this._pathLeaveRoom.uint64_send_request_exit_room_cmd_end_time=Date.now())}handleRemoteStreamAdded(e,t){var i;let r="".concat(e,"_").concat(t);if(!this._remoteStreamStatMap.has(r)){let n={userId:e,totalVideoFPS:0,totalVideoBitrate:0,totalAudioLevel:0,totalAudioBitrate:0,totalLoss:0,audioCount:0,audioLevelCount:0,videoCount:0,networkQualityCount:0,streamAddedTime:Date.now(),subscribeStartTime:0,subscribedTime:0,playStreamTime:0,statsToReport:Xb(qb({},$V),{msg_user_info:new eU({userId:e,tinyId:null==(i=this._room.remotePublishedUserMap.get(e))?void 0:i.tinyId,role:20})})};n.statsToReport.uint32_stream_type="main"===t?2:7,this._remoteStreamStatMap.set(r,n)}}handleSubscribeStart(e){let{room:t,remotePublishedUser:i,streamType:r,subscribeState:n}=e;if(!this.hitTest(t))return;let{userId:o,tinyId:s,role:a}=i,c=new eU({userId:o,tinyId:s,role:"anchor"===a?20:21}),l=Date.now(),d="".concat(o,"_").concat(r),u=this._remoteStreamStatMap.get(d);u&&0===u.subscribeStartTime&&(u.subscribeStartTime=l),"main"===r?(i.muteState.hasVideo&&(n.video||n.smallVideo)&&!this._pathMainVideoMap.has(d)&&this._pathMainVideoMap.set(d,{statsToReport:{msg_user_info:c,uint64_start_enter_time:this._pathJoinRoom.uint64_start_time,uint64_render_first_frame_time:0,uint64_combine_first_frame_time:0},userId:o,sendSubscribeCMDTime:l}),i.muteState.hasAudio&&n.audio&&!this._pathMainAudioMap.has(d)&&this._pathMainAudioMap.set(d,{statsToReport:{msg_user_info:c,uint64_start_enter_time:this._pathJoinRoom.uint64_start_time,uint64_play_first_frame_time:0},userId:o,sendSubscribeCMDTime:l})):i.muteState.hasAuxiliary&&n.auxiliary&&!this._pathAuxiliaryMap.has(d)&&this._pathAuxiliaryMap.set(d,{sendSubscribeCMDTime:l})}handleSubscribed(e){let{room:t,remotePublishedUser:i,streamType:r}=e;if(this.hitTest(t)){let e="".concat(i.userId,"_").concat(r),t=this._remoteStreamStatMap.get(e);t&&0===t.subscribedTime&&(t.subscribedTime=Date.now())}}handlePlayStart(e){let{track:t}=e;if(!UD(t)||!this.hitTest(t.room))return;let i="".concat(t.userId,"_").concat(t.streamType),r=this._remoteStreamStatMap.get(i);0===(null==r?void 0:r.playStreamTime)&&(r.playStreamTime=Date.now())}handleVideoLoadedData(e){let{track:t}=e;if(!UD(t)||!this.hitTest(t.room))return;let i="".concat(t.userId,"_").concat(t.streamType),r=this._pathMainVideoMap.get(i);r&&0===r.statsToReport.uint64_combine_first_frame_time&&(r.statsToReport.uint64_combine_first_frame_time=Date.now())}handleVideoPlaying(e){let t="".concat(e.userId,"_").concat(e.streamType),i=Date.now(),r=this._pathMainVideoMap.get(t),n=this._remoteStreamStatMap.get(t);if(r&&(0===r.statsToReport.uint64_render_first_frame_time&&(r.statsToReport.uint64_render_first_frame_time=i),n)){let{statsToReport:e,playStreamTime:t,subscribedTime:o}=n;0===e.uint32_video_render_first&&t-o<=100&&(e.uint32_video_render_first=i-r.sendSubscribeCMDTime)}let o=this._pathAuxiliaryMap.get(t);if(o&&n){let{statsToReport:e,playStreamTime:t,subscribedTime:r}=n;0===e.uint32_video_render_first&&t-r<=100&&(e.uint32_video_render_first=i-o.sendSubscribeCMDTime)}}handleAudioPlaying(e){let t="".concat(e.userId,"_").concat(e.streamType),i=this._pathMainAudioMap.get(t);i&&0===i.statsToReport.uint64_play_first_frame_time&&(i.statsToReport.uint64_play_first_frame_time=Date.now())}handleNetworkQuality(e){this.hitTest(e.room)&&(this._networkQuality.totalUplinkLoss+=e.uplink.loss,this._networkQuality.totalUplinkRTT+=e.uplink.rtt,this._networkQuality.count++,e.downlinks.forEach((e=>{let{rtt:t,loss:i,userId:r,videoDelay:n,audioDelay:o}=e,s=this._networkQuality.totalDownlinkRTTAndLossMap.get(r);if(s)s.totalRTT+=t,s.totalLoss+=i,n&&(s.totalVideoDelay=(s.totalVideoDelay||0)+n,s.videoDelayCount=(s.videoDelayCount||0)+1),o&&(s.totalAudioDelay=(s.totalAudioDelay||0)+o,s.audioDelayCount=(s.audioDelayCount||0)+1),s.count++;else{let e,s,a,c;n&&(s=n,a=1),o&&(e=o,c=1),this._networkQuality.totalDownlinkRTTAndLossMap.set(r,{totalRTT:t,totalLoss:i,count:1,totalAudioDelay:e,totalVideoDelay:s,audioDelayCount:c,videoDelayCount:a})}})))}handleHeartbeatStats(e){if(this.hitTest(e.room)){let{msg_up_stream_info:t,msg_down_stream_info:i}=e.report;if(t.msg_video_status[0]){let{uint32_video_codec_bitrate:e,uint32_video_enc_fps:i,uint32_video_width:r,uint32_video_height:n}=t.msg_video_status[0];this._localStreamStat.totalVideoBitrate+=e,this._localStreamStat.totalVideoFPS+=i,this._localStreamStat.totalVideoWidth+=r,this._localStreamStat.totalVideoHeight+=n,this._localStreamStat.videoCount++}if(t.msg_audio_status){let{uint32_audio_level:e}=t.msg_audio_status;Math.floor(e/UN*100)>0&&(this._localStreamStat.totalAudioLevel+=e/UN,this._localStreamStat.audioLevelCount++)}i.forEach((e=>{let{msg_user_info:t,msg_audio_status:i,msg_video_status:r}=e,n=t.str_identifier,o=this._room.remotePublishedUserMap.get(n);if(r.forEach((e=>{let t=2===e.uint32_video_stream_type,i=7===e.uint32_video_stream_type,r="".concat(n,"_").concat(t?"main":"auxiliary"),s=this._remoteStreamStatMap.get(r);if(s&&(t&&(null==o?void 0:o.remoteVideoTrack.isSubscribed)||i&&(null==o?void 0:o.remoteAuxiliaryTrack))){s.totalVideoFPS+=e.uint32_video_receive_fps,s.totalVideoBitrate+=e.uint32_video_codec_bitrate,s.videoCount++,0===s.statsToReport.uint32_video_width&&(s.statsToReport.uint32_video_width=e.uint32_video_width),0===s.statsToReport.uint32_video_height&&(s.statsToReport.uint32_video_height=e.uint32_video_height);let i=t?o.remoteVideoTrack:o.remoteAuxiliaryTrack;i.stat.jitterBufferDelay&&(s.videoJitterBufferDelay=i.stat.jitterBufferDelay),i.stat.framesReceived&&(s.statsToReport.uint32_video_consume_render_rate=Math.floor(i.stat.framesDecoded/i.stat.framesReceived*Yb(10,6)))}})),i){let e="".concat(n,"_","main"),t=this._remoteStreamStatMap.get(e);this._remoteStreamStatMap.has(e)&&t&&(null==o?void 0:o.remoteAudioTrack.isSubscribed)&&(t.totalAudioBitrate+=i.uint32_audio_codec_bitrate,t.audioCount++,o.remoteAudioTrack.stat.jitterBufferDelay&&(t.audioJitterBufferDelay=o.remoteAudioTrack.stat.jitterBufferDelay),Math.floor(i.uint32_audio_level/UN*100)>0&&(t.totalAudioLevel+=i.uint32_audio_level/UN,t.audioLevelCount++))}}))}}handlePublishStart(e){let{room:t}=e;this.hitTest(t)&&0===this._localStreamStat.publishStartTime&&(this._localStreamStat.publishStartTime=Date.now())}handleTrackCaptureStart(e){let{track:t}=e;1===t.mediaType&&!this._pathJoinRoom.uint64_init_audio_start_time&&(this._pathJoinRoom.uint64_init_audio_start_time=Date.now()),4===t.mediaType&&!this._pathJoinRoom.uint64_init_camera_start_time&&(this._pathJoinRoom.uint64_init_camera_start_time=Date.now())}handleTrackCaptureSuccess(e){let{track:t}=e;1===t.mediaType&&!this._pathJoinRoom.uint64_init_audio_end_time&&(this._pathJoinRoom.int32_init_audio_ret=0,this._pathJoinRoom.uint64_init_audio_end_time=Date.now()),4===t.mediaType&&!this._pathJoinRoom.uint64_init_camera_end_time&&(this._pathJoinRoom.int32_init_camera_ret=0,this._pathJoinRoom.uint64_init_camera_end_time=Date.now())}handleTrackCaptureFailed(e){let{track:t,error:i}=e,r={NotFoundError:1,NotAllowedError:2,NotReadableError:3,OverConstrainedError:4,AbortError:5,InvalidStateError:6,SecurityError:7,TypeError:8}[i.name]||(i instanceof fC?i.getExtraCode()||i.getCode():_C.UNKNOWN);1===t.mediaType&&!this._pathJoinRoom.uint64_init_audio_end_time&&(this._pathJoinRoom.int32_init_audio_ret=r,this._pathJoinRoom.uint64_init_audio_end_time=Date.now()),4===t.mediaType&&!this._pathJoinRoom.uint64_init_camera_end_time&&(this._pathJoinRoom.int32_init_camera_ret=r,this._pathJoinRoom.uint64_init_camera_end_time=Date.now())}hasVideoFlag(e){return this._firstPublishedUserList.findIndex((t=>t.userId===e&&t.flag&Bw))>=0}hasAudioFlag(e){return this._firstPublishedUserList.findIndex((t=>t.userId===e&&t.flag&jw))>=0}hasAuxFlag(e){return this._firstPublishedUserList.findIndex((t=>t.userId===e&&t.flag&Hw))>=0}hitTest(e){return e===this._room}checkStorage(){return rC(this,null,(function*(){try{let e=yO.getItem(this._storageKey);e&&(yield this.upload(e),yO.deleteItem(this._storageKey))}catch(e){this._log.warn(e)}}))}setStorage(){this.prepareReport();let e=this.getReportData();0!==e.msg_path_enter_room.uint64_start_time&&yO.setItem(this._storageKey,e)}prepareReport(){if(this._networkQuality.count>0&&(this._basicInfo.uint32_avg_rtt=Math.floor(this._networkQuality.totalUplinkRTT/this._networkQuality.count),this._basicInfo.uint32_avg_up_loss=Math.floor(this._networkQuality.totalUplinkLoss/this._networkQuality.count)),this._localStreamStat.videoCount>0){this._localStreamStat.statsToReport.uint32_video_big_capture_fps=Math.floor(this._localStreamStat.totalVideoFPS/this._localStreamStat.videoCount),this._localStreamStat.statsToReport.uint32_video_big_bitrate=Math.floor(this._localStreamStat.totalVideoBitrate/this._localStreamStat.videoCount);let e=Math.floor(this._localStreamStat.totalVideoWidth/this._localStreamStat.videoCount),t=Math.floor(this._localStreamStat.totalVideoHeight/this._localStreamStat.videoCount);this._localStreamStat.statsToReport.uint32_video_big_resolution=e<<16|t}this._localStreamStat.audioLevelCount>0&&(this._localStreamStat.statsToReport.uint32_audio_capture_db=Math.floor(this._localStreamStat.totalAudioLevel/this._localStreamStat.audioLevelCount*100)),this._remoteStreamStatMap.forEach(((e,t)=>{let{userId:i}=e,r=this._networkQuality.totalDownlinkRTTAndLossMap.get(i);if(r){let{totalLoss:t,count:i,audioDelayCount:n,videoDelayCount:o,totalAudioDelay:s,totalVideoDelay:a}=r;e.statsToReport.uint32_avg_down_loss=Math.floor(t/i),n&&s&&(e.statsToReport.uint32_audio_network_p2p_delay=Math.floor(s/n),e.audioJitterBufferDelay&&(e.statsToReport.uint32_p2p_delay=Math.floor(e.statsToReport.uint32_audio_network_p2p_delay+e.audioJitterBufferDelay))),o&&a&&(e.statsToReport.uint32_video_network_p2p_delay=Math.floor(a/o))}e.videoCount>0&&(e.statsToReport.uint32_video_avg_fps=Math.floor(e.totalVideoFPS/e.videoCount),e.statsToReport.uint32_video_avg_bitrate=Math.floor(e.totalVideoBitrate/e.videoCount)),e.audioCount>0&&(e.statsToReport.uint32_audio_recv_bitrate=e.statsToReport.uint32_audio_bitrate=Math.floor(e.totalAudioBitrate/e.audioCount)),e.audioLevelCount>0&&(e.statsToReport.uint32_audio_play_db=Math.floor(e.totalAudioLevel/e.audioLevelCount*100));let{callDurationCalculator:n}=this._room;n&&(e.statsToReport.uint32_audio_play_time=n.getDuration(t,Mw.AUDIO),e.statsToReport.uint32_video_play_time=n.getDuration(t,Mw.VIDEO)),e.statsToReport.uint32_video_render_first=Math.min(e.statsToReport.uint32_video_render_first,ZV);let{badCaseDetector:o}=this._room,{dataFreeze:s,count:a}=o.getDataFreezeDuration(t),{renderFreeze:c}=o.getRenderFreezeDuration(t);e.statsToReport.uint32_video_block_count=a,e.statsToReport.uint32_video_block_time=Math.min(s,e.statsToReport.uint32_video_play_time),e.statsToReport.uint32_video_external_block_time=Math.min(c,e.statsToReport.uint32_video_play_time),o.isBlackStream(t)&&0===e.statsToReport.uint32_video_avg_fps?e.statsToReport.uint32_video_black_screen_subjective=1:e.statsToReport.uint32_video_black_screen_subjective=0,(0===e.subscribeStartTime||e.subscribeStartTime-e.streamAddedTime>100||0===e.playStreamTime)&&(this._pathMainAudioMap.delete(t),this._pathMainVideoMap.delete(t),e.statsToReport.uint32_video_render_first=0)})),this._pathMainAudioMap.forEach(((e,t)=>{this.hasAudioFlag(e.userId)?e.statsToReport.uint64_play_first_frame_time-e.statsToReport.uint64_start_enter_time>ZV&&(e.statsToReport.uint64_play_first_frame_time=e.statsToReport.uint64_start_enter_time+ZV):this._pathMainAudioMap.delete(t)})),this._pathMainVideoMap.forEach(((e,t)=>{this.hasVideoFlag(e.userId)?e.statsToReport.uint64_render_first_frame_time-e.statsToReport.uint64_start_enter_time>ZV&&(e.statsToReport.uint64_render_first_frame_time=e.statsToReport.uint64_start_enter_time+ZV):this._pathMainVideoMap.delete(t)})),this._pathJoinRoom.uint64_end_time-this._pathJoinRoom.uint64_start_time>ZV&&(this._pathJoinRoom.uint64_end_time=this._pathJoinRoom.uint64_start_time+ZV)}getReportData(){this._basicInfo.uint32_networkType=gD();let e={uint32_sdk_app_id:Number(this._room.sdkAppId),msg_user_info:new eU({userId:this._room.userId,tinyId:this._room.tinyId,role:"anchor"===this._room.role?20:21}),msg_basic_info:this._basicInfo,uint32_acc_ip:ZD(this._signalInfo.relayIp),uint32_client_ip:ZD(this._signalInfo.clientIp,!1),uint32_acc_port:this._signalInfo.relayPort||0,uint64_timestamp:Date.now(),uint32_seq:Math.floor(Math.random()*Yb(2,31)),msg_path_enter_room:this._pathJoinRoom,msg_path_exit_room:this._pathLeaveRoom,msg_path_recv_video:[...this._pathMainVideoMap.values()].map((e=>e.statsToReport)),msg_quality_statistics:[...this._remoteStreamStatMap.values()].map((e=>e.statsToReport)),str_room_name:String(this._room.roomId||0),msg_path_recv_audio:[...this._pathMainAudioMap.values()].map((e=>e.statsToReport)),uint32_info_client_ip:ZD(this._signalInfo.clientIp,!1),error_code:[],msg_local_statistics:this._localStreamStat.statsToReport};return hO(e),e}report(){return rC(this,null,(function*(){try{this.prepareReport();let e=this.getReportData();yield this.upload(e),yO.deleteItem(this._storageKey),this.initData()}catch(e){this._log.warn(e)}}))}upload(e){return rC(this,null,(function*(){if(Jk&&!Tk||0===e.msg_path_enter_room.uint64_start_time||[_w,fw,gw].findIndex((e=>e===location.host))>=0)return;let t=Number(this._room.sdkAppId),i=yield FN(e),r=i instanceof ArrayBuffer,n="".concat(dD(t,Aw.KEY_POINT),"&gzip=").concat(+r),o=!1;navigator.sendBeacon&&(o=navigator.sendBeacon(n,i)),o||BN({url:n,body:i}),this.uploadKVStat(pP),this.uploadKVStat(hP)}))}setConnectionType(e){this.connectionType=e,this._basicInfo.uint32_connection_type=e}uploadKVStat(e){return rC(this,null,(function*(){let t=e.getReportData();if(0===t.stats_count.length&&0===t.stats_distribution.length)return;t.msg_sdk_basic_info=Xb(qb({},t.msg_sdk_basic_info),{bytes_device_name:this._basicInfo.string_device_name||"",bytes_os_version:this._basicInfo.string_os_version||"",uint32_framework:this._frameWorkType,uint32_network_type:this._basicInfo.uint32_networkType||0}),this._log.debug(t);let i=yield FN(t),r="".concat(dD(+this._room.sdkAppId,Aw.KV_STAT),"&gzip=").concat(+(i instanceof ArrayBuffer)),n=!1;navigator.sendBeacon&&(n=navigator.sendBeacon(r,i)),n||BN({url:r,body:i})}))}};eC([bV({settings:{timeout:500,retries:3}})],QV.prototype,"upload",1);var ZV=5e3,$V={msg_user_info:null,uint32_video_avg_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_avg_bitrate:0,uint32_video_block_time:0,uint32_video_play_time:0,uint32_audio_block_time:0,uint32_audio_play_time:0,uint32_audio_play_db:0,uint32_avg_down_loss:0,uint32_stream_type:0,uint32_video_render_first:0,uint32_video_block_count:0,uint32_audio_block_count:0,uint32_audio_bitrate:0,uint32_video_black_screen_subjective:0,uint32_audio_recv_bitrate:0,uint32_video_external_block_time:0,uint32_video_consume_render_rate:0},eU=class{constructor(e){this.str_identifier=String(e.userId),this.str_tinyid=String(e.tinyId||0),this.uint32_role=e.role}},tU=QV,iU=class{constructor(){tC(this,"_startTime"),tC(this,"_endTime"),this._startTime=0,this._endTime=0,this.start()}start(){0===this._startTime&&(this._startTime=zD())}stop(){0===this._endTime&&(this._endTime=zD())}getDuration(){return 0===this._endTime?zD()-this._startTime:this._endTime-this._startTime}get endTime(){return this._endTime}},rU=class{constructor(e){tC(this,"_room",null),tC(this,"_durationMap"),tC(this,"_eventMap",new Map),this._room=e.room,this._durationMap=new Map,this.installEvents()}installEvents(){this._eventMap.set(fO.SUBSCRIBE_SUCCESS,this.handleSubscribed).set(fO.UNSUBSCRIBE_SUCCESS,this.handleStreamStopped).set(fO.REMOTE_PUBLISH_STATE_CHANGED,(e=>{let{room:t,prevMuteState:i,muteState:r}=e;var n;let{userId:o}=r;if(!this.hitTest(t))return;i.hasAudio&&!r.hasAudio&&this.stopDurationItem("".concat(o,"_","main"),Mw.AUDIO),i.hasVideo&&!r.hasVideo&&this.stopDurationItem("".concat(o,"_","main"),Mw.VIDEO),i.hasAuxiliary&&!r.hasAuxiliary&&this.stopDurationItem("".concat(o,"_","auxiliary"),Mw.VIDEO);let s=null==(n=this._room)?void 0:n.remotePublishedUserMap.get(o);!s||(!i.hasAudio&&r.hasAudio&&s.remoteAudioTrack.isSubscribed&&this.addDuractionItem(o,Mw.AUDIO,"main"),!i.hasVideo&&r.hasVideo&&s.remoteVideoTrack.isSubscribed&&this.addDuractionItem(o,Mw.VIDEO,"main"),!i.hasAuxiliary&&r.hasAuxiliary&&s.remoteAuxiliaryTrack.isSubscribed&&this.addDuractionItem(o,Mw.VIDEO,"auxiliary"))})),this._eventMap.forEach(((e,t)=>JN.on(t,e,this)))}uninstallEvents(){this._eventMap.forEach(((e,t)=>JN.off(t,e,this))),this._eventMap.clear()}handleSubscribed(e){let{room:t,streamType:i,remotePublishedUser:r}=e;if(!this.hitTest(t))return;let{userId:n}=r,o="".concat(n,"_").concat(i);if(r.muteState.hasAudio&&"main"===i)if(r.remoteAudioTrack.isSubscribed){let e=new iU,t=this._durationMap.get(o);t?this.isRecording(t.audio)||t.audio.push(e):this._durationMap.set(o,{userId:n,type:i,audio:[e],video:[]})}else this.stopDurationItem(o,Mw.AUDIO);if(r.muteState.hasVideo||r.muteState.hasAuxiliary)if(r.remoteVideoTrack.isSubscribed||r.remoteAuxiliaryTrack.isSubscribed){let e=new iU,t=this._durationMap.get(o);t?this.isRecording(t.video)||t.video.push(e):this._durationMap.set(o,{userId:n,type:i,audio:[],video:[e]})}else this.stopDurationItem(o,Mw.VIDEO)}handleStreamStopped(e){let{room:t,streamType:i,remotePublishedUser:r}=e;if(!this.hitTest(t))return;let{userId:n}=r,o="".concat(n,"_").concat(i);this.stopDurationItem(o,Mw.AUDIO),this.stopDurationItem(o,Mw.VIDEO)}isRecording(e){return e.findIndex((e=>0===e.endTime))>=0}addDuractionItem(e,t,i){let r="".concat(e,"_").concat(i),n=new iU,o=this._durationMap.get(r);o?this.isRecording(o[t])||o[t].push(n):this._durationMap.set(r,{userId:e,type:i,audio:t===Mw.AUDIO?[n]:[],video:t===Mw.AUDIO?[]:[n]})}stopDurationItem(e,t){if(this._durationMap.has(e)){let i=this._durationMap.get(e)[t].find((e=>0===e.endTime));i&&i.stop()}}hitTest(e){return this._room===e}getDuration(e,t){return this._durationMap.has(e)?this._durationMap.get(e)[t].reduce(((e,t)=>e+t.getDuration()),0):0}getDurationMap(){return this._durationMap}reset(){this._durationMap.clear()}destroy(){this._room=null,this.uninstallEvents()}},nU=class{constructor(e){tC(this,"_room"),tC(this,"_renderFreezeMap",new Map),tC(this,"_isVideoPlayingEventFiredMap",new Map),tC(this,"_dataFreezeMap",new Map),tC(this,"_monitorFreezeData",new Map),tC(this,"_eventMap",new Map),this._room=e.room,this.installEvents()}installEvents(){this._eventMap.set(fO.LEAVE_SUCCESS,(e=>{let{room:t}=e;this.hitTest(t)&&this.stop()})).set(fO.PLAY_TRACK_START,this.onPlayTrackStart).set(fO.UNSUBSCRIBE_SUCCESS,(e=>{let{room:t,streamType:i,remotePublishedUser:r}=e;if(!this.hitTest(t))return;let{userId:n}=r,o="".concat(n,"_").concat(i);this.stopDataFreeze({key:o,userId:n,type:i})})).set(fO.REMOTE_PUBLISH_STATE_CHANGED,(e=>{let{room:t,prevMuteState:i,muteState:r}=e;if(!this.hitTest(t))return;let{userId:n}=r;if(i.hasVideo&&!r.hasVideo){let e="main",t="".concat(r.userId,"_").concat(e);this.stopDataFreeze({key:t,userId:n,type:e})}if(i.hasAuxiliary&&!r.hasAuxiliary){let e="auxiliary",t="".concat(r.userId,"_").concat(e);this.stopDataFreeze({key:t,userId:n,type:e})}})).set(fO.PLAYER_STATE_CHANGED,(e=>{let{track:t,state:i,reason:r,type:n}=e;if(UD(t)&&this.hitTest(t.room)&&n===Mw.VIDEO){if("PLAYING"===i){let e="".concat(t.userId,"_").concat(t.streamType);this._isVideoPlayingEventFiredMap.set(e,!0)}r===Mw.MUTE?this.onVideoTrackMuted(t):r===Mw.UNMUTE&&this.onVideoTrackUnmuted(t)}})).set(fO.HEARTBEAT_REPORT,this.onHearBeatReport),this._eventMap.forEach(((e,t)=>JN.on(t,e,this)))}uninstallEvents(){this._eventMap.forEach(((e,t)=>JN.off(t,e,this))),this._eventMap.clear()}stop(){this._renderFreezeMap.clear(),this._dataFreezeMap.clear(),this._isVideoPlayingEventFiredMap.clear()}onVideoTrackMuted(e){if(!e.isSubscribed)return;let{userId:t,streamType:i}=e,r="".concat(t,"_").concat(i),n=this._dataFreezeMap.get(r),o=new iU;n?n.durationItemList.push(o):this._dataFreezeMap.set(r,{userId:t,type:i,durationItemList:[o],isFreezing(){let e=this.durationItemList[this.durationItemList.length-1];return e&&0===e.endTime}})}onVideoTrackUnmuted(e){if(!e.isSubscribed)return;let{userId:t,streamType:i}=e,r="".concat(t,"_").concat(i);this.stopDataFreeze({key:r,userId:t,type:i})}onHearBeatReport(e){let{room:t,report:i}=e;!this.hitTest(t)||i.msg_down_stream_info.forEach((e=>{let t=this._room.remotePublishedUserMap.get(e.msg_user_info.str_identifier);if(!t)return;let{userId:i,muteState:r}=t;e.msg_video_status.forEach((e=>{2===e.uint32_video_stream_type&&r.hasVideo&&!r.videoMuted&&t.remoteVideoTrack.isSubscribed&&this.handleRenderFreeze({userId:i,fps:e.uint32_video_dec_fps,type:"main"}),7===e.uint32_video_stream_type&&r.hasAuxiliary&&t.remoteAuxiliaryTrack.isSubscribed&&this.handleRenderFreeze({userId:i,fps:e.uint32_video_dec_fps,type:"auxiliary"})}))}))}stopDataFreeze(e){let{key:t,userId:i,type:r}=e,n=this._dataFreezeMap.get(t);if(!n||!n.isFreezing())return;let o=n.durationItemList[n.durationItemList.length-1];o.stop();let s=o.getDuration();s>gN?this._monitorFreezeData.set(t,{userId:i,type:r,duration:s}):n.durationItemList.pop()}getTotalDuration(e){return e.reduce(((e,t)=>{let i=t.getDuration();return e+Math.min(i,5e3)}),0)}handleRenderFreeze(e){return rC(this,arguments,(function(e){var t=this;let{userId:i,fps:r,type:n}=e;return function*(){let e="".concat(i,"_").concat(n),o=t._renderFreezeMap.get(e);if(r<=2){let r=zD();o&&!o.isFreeze&&(o.freezeTimeline.push({startTime:r,endTime:0}),o.isFreeze=!0),o||t._renderFreezeMap.set(e,{userId:i,type:n,isFreeze:!0,freezeTimeline:[{startTime:r,endTime:0}],renderFreezeTotal:0})}else if(o&&o.isFreeze){o.isFreeze=!1;let e=o.freezeTimeline.pop();if(e){e.endTime=zD();let t=e.endTime-e.startTime;o.freezeTimeline.push(e),o.renderFreezeTotal+=Math.min(5e3,t)}}}()}))}onPlayTrackStart(e){let{track:t}=e;if(!UD(t)||!this.hitTest(t.room)||t.kind!==Mw.VIDEO||t.hasFlag)return;let i="".concat(t.userId,"_").concat(t.streamType);this._isVideoPlayingEventFiredMap.has(i)||this._isVideoPlayingEventFiredMap.set(i,!1)}getDataFreezeDuration(e){let t={dataFreeze:0,count:0},i=this._dataFreezeMap.get(e);if(i){if(i.isFreezing()){let e=i.durationItemList[i.durationItemList.length-1];e.stop(),e.getDuration()<gN&&i.durationItemList.pop()}t.dataFreeze=this.getTotalDuration(i.durationItemList),t.count=i.durationItemList.length}return t}getRenderFreezeDuration(e){let t=this._renderFreezeMap.get(e),i=0,r=0;if(t)if(t.isFreeze){let e=zD()-t.freezeTimeline[t.freezeTimeline.length-1].startTime;i=t.renderFreezeTotal+Math.min(e,5e3),r=t.freezeTimeline.length}else i=t.renderFreezeTotal;return{renderFreeze:i,count:r}}getMonitorFreeze(){return this._monitorFreezeData}isBlackStream(e){return!!this._isVideoPlayingEventFiredMap.has(e)&&!this._isVideoPlayingEventFiredMap.get(e)}resetMonitor(){this._monitorFreezeData.clear()}hitTest(e){return e===this._room}destroy(){this.uninstallEvents()}},oU=$b(nC(),1),sU=[-1,-1,1,-1,-1,1,1,1],aU=[0,0,1,0,0,1,1,1],cU=class extends gL{constructor(e,t){if(super(),this.context=e,tC(this,"name"),tC(this,"input"),tC(this,"output"),tC(this,"texture"),tC(this,"image"),tC(this,"ctx2d",null),tC(this,"fbo"),tC(this,"width",0),tC(this,"height",0),tC(this,"x",0),tC(this,"y",0),tC(this,"program"),tC(this,"vertexShader"),tC(this,"fragmentShader"),tC(this,"totalFrames",0),tC(this,"dropFrames",0),tC(this,"matchInputSize",!0),tC(this,"texCoordBuffer"),tC(this,"positionBuffer"),tC(this,"lastInfo",{name:"",timestamp:0,totalFrames:0,x:0,y:0,width:0,height:0,fps:0}),tC(this,"cost",0),tC(this,"_canvas",null),this.context.on("disconnect",this.close,this),this.name=t.name,this.matchInputSize=!1!==t.matchInputSize,this.width=t.width||e.width,this.height=t.height||e.height,e instanceof vU){if(e.ctx&&t.create2d){let e=document.createElement("canvas"),t="function"==typeof e.transferControlToOffscreen?e.transferControlToOffscreen():e;t.width=this.width,t.height=this.height,this.ctx2d=t.getContext("2d"),this.image=t,this._canvas=t}}else try{let i=e.ctx;this.texCoordBuffer=this.createBuffer(aU),this.positionBuffer=this.createBuffer(sU),!1!==t.createTexture&&(this.texture=i.createTexture(),this.useTexture(),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.pixelStorei(i.PACK_ALIGNMENT,1),i.pixelStorei(i.UNPACK_ALIGNMENT,1)),t.useFbo&&(this.fbo=i.createFramebuffer(),this.useBufferFrame(),this.useTexture(),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,this.width,this.height,0,i.RGBA,i.UNSIGNED_BYTE,null),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,this.texture,0)),t.useDefaultProgram?this.program=e.defaultProgam:(t.vertexShaderSource||t.fragmentShaderSource)&&(this.vertexShader=t.vertexShaderSource?e.createShader(i.VERTEX_SHADER,t.vertexShaderSource):e.defaultVShader,this.fragmentShader=t.fragmentShaderSource?e.createShader(i.FRAGMENT_SHADER,t.fragmentShaderSource):e.defaultFShader,this.program=e.createProgram(this.vertexShader,this.fragmentShader))}catch(i){this.context.destroy(i)}}connect(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return e.addInput(this,...i),this.output=e,e}addInput(e){this.input=e,this.matchInputSize&&e.width&&e.height&&this.resize(e.width,e.height)}requestFrame(e){let t=Date.now();return!!(this.context instanceof EU&&this.render(e)||this.context instanceof vU&&this.render2d(e))&&(this.totalFrames++,this.cost=Date.now()-t,!0)}render2d(e){var t;return!(null==(t=this.input)||!t.requestFrame(e))&&this.draw2d(this.input.image,0,0,this.width,this.height)}disconnect(){for(var e,t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];null==(e=this.output)||e.removeInput(this,...i),delete this.output}removeInput(e){delete this.input}close(){var e,t;if(this.context.off("disconnect",this.close,this),null==(e=this.output)||e.removeInput(this),delete this.output,null==(t=this.input)||t.disconnect(),this.context instanceof EU){let e=this.context.ctx;e.deleteBuffer(this.texCoordBuffer),e.deleteBuffer(this.positionBuffer),this.fbo&&e.deleteFramebuffer(this.fbo),this.texture&&e.deleteTexture(this.texture),this.vertexShader&&this.vertexShader!==this.context.defaultVShader&&e.deleteShader(this.vertexShader),this.fragmentShader&&this.fragmentShader!==this.context.defaultFShader&&e.deleteShader(this.fragmentShader),this.program&&this.program!==this.context.defaultProgam&&e.deleteProgram(this.program)}this._canvas&&(this._canvas.width=0,this._canvas.height=0,this.ctx2d=null),this.removeAllListeners()}useTexture(){this.useTextures(this.texture)}useInputTexture(){var e;this.useTextures(null==(e=this.input)?void 0:e.texture)}useTextures(){let e=this.context.ctx;for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];i.forEach(((t,i)=>{t&&(e.activeTexture(e.TEXTURE0+i),e.bindTexture(e.TEXTURE_2D,t))}))}useProgram(){this.context.ctx.useProgram(this.program)}useBufferFrame(){let e=this.context.ctx;e.bindFramebuffer(e.FRAMEBUFFER,this.fbo||null)}createBuffer(e){let t=this.context.ctx,i=t.createBuffer();return t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e),t.STATIC_DRAW),i}setTexBuffer(e){let t=this.context.ctx;t.bindBuffer(t.ARRAY_BUFFER,this.texCoordBuffer),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e),t.STATIC_DRAW)}setPosBuffer(e){let t=this.context.ctx;t.bindBuffer(t.ARRAY_BUFFER,this.positionBuffer),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e),t.STATIC_DRAW)}changeBufferData(e,t){let i=this.context.ctx;i.bindBuffer(i.ARRAY_BUFFER,e),i.bufferData(i.ARRAY_BUFFER,new Float32Array(t),i.STATIC_DRAW)}setAttributes(){let e=this.context.ctx;for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];i.forEach(((t,i)=>{e.enableVertexAttribArray(i),e.bindBuffer(e.ARRAY_BUFFER,t),e.vertexAttribPointer(i,2,e.FLOAT,!1,0,0)}))}getVertexPoint(e,t){return[e/this.width*2-1,t/this.height*2-1]}layout2texCoords(e){return[...this.getVertexPoint(e.x,e.y),...this.getVertexPoint(e.x+e.width,e.y),...this.getVertexPoint(e.x,e.y+e.height),...this.getVertexPoint(e.x+e.width,e.y+e.height)]}resize(e,t){if(this.width!==e||this.height!==t){if(this.width=e,this.height=t,this._canvas&&(this._canvas.width=e,this._canvas.height=t),this.texture&&this.fbo){this.useTexture();let i=this.context.ctx;i.texImage2D(i.TEXTURE_2D,0,i.RGBA,e,t,0,i.RGBA,i.UNSIGNED_BYTE,null)}this.output&&this.output.matchInputSize&&this.output.resize(e,t)}}draw(e,t){this.setAttributes(e||this.positionBuffer,t||this.texCoordBuffer);let i=this.context.ctx;i.drawArrays(i.TRIANGLE_STRIP,0,4)}draw2d(e,t,i,r,n){return!(!this.ctx2d||!e||(e instanceof ImageData?this.ctx2d.putImageData(e,t,i):this.ctx2d.drawImage(e,t,i,r,n),0))}getInfo(){var e;let{totalFrames:t,x:i,y:r,width:n,height:o,name:s,cost:a}=this,c=Date.now(),l=(t-this.lastInfo.totalFrames)/((c-this.lastInfo.timestamp)/1e3)|0;return this.lastInfo={totalFrames:t,x:i,y:r,width:n,height:o,timestamp:c,fps:l,name:s,cost:a},qb({parent:null==(e=this.input)?void 0:e.getInfo()},this.lastInfo)}createTexture(e){let t=this.context.ctx,i=t.createTexture();return this.useTextures(i),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.pixelStorei(t.PACK_ALIGNMENT,1),t.pixelStorei(t.UNPACK_ALIGNMENT,1),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),i}};eC([mL(gL.INIT,"connected",{sync:!0})],cU.prototype,"connect",1),eC([mL("connected",gL.INIT,{ignoreError:!0,sync:!0})],cU.prototype,"disconnect",1),eC([mL([],"closed",{sync:!0})],cU.prototype,"close",1);var lU=[0,1,1,1,0,0,1,0],dU=class extends cU{constructor(e,t){super(e,Object.assign({useDefaultProgram:!0,createTexture:!1,name:"destination"},t)),tC(this,"_intervalId",0),tC(this,"_sequence",0),tC(this,"checkGLError",!1),e instanceof vU?this.ctx2d=e.ctx:e.available&&(null==t?void 0:t.mirrorUpAndDown)&&this.setTexBuffer(lU)}start(e){this._intervalId=SL.run("intervalInWorker",(()=>{if(e!==this.context.frameRate&&(SL.clearTask(this._intervalId),this.start(this.context.frameRate)),this.requestFrame(this._sequence++),this.checkGLError&&this.context instanceof EU){let e=this.context.ctx.getError();e&&this.context.destroy(new Error("".concat(this.name," req ").concat(this._sequence," render ").concat(this.totalFrames," faild ").concat(e)))}}),{fps:this.context.frameRate})}render(e){var t;return!(null==(t=this.input)||!t.requestFrame(e)||(this.useProgram(),this.useBufferFrame(),this.useInputTexture(),this.draw(),0))}addInput(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];super.addInput(e,...i),this.start(this.context.frameRate)}removeInput(e){super.removeInput(e),SL.clearTask(this._intervalId)}},uU=class extends dU{constructor(e,t){super(e,t),tC(this,"_videoTrack"),[this._videoTrack]=e._canvas.captureStream(e.frameRate).getVideoTracks();let i=e=>{var t;let i=()=>{var t;return null==(t=this._videoTrack)?void 0:t.removeEventListener(e,r)},r=()=>{i(),this.context.destroy(new Error("video track ".concat(e)))};this.once("closed",i),null==(t=this._videoTrack)||t.addEventListener(e,r)};e instanceof EU&&i("mute"),i("ended")}get videoTrack(){return this._videoTrack}close(){var e;super.close(),null==(e=this._videoTrack)||e.stop(),delete this._videoTrack}resize(e,t){super.resize(e,t),this.context.setSize(e,t)}},hU=class extends uU{render(e){var t;return!(null==(t=this.input)||!t.requestFrame(e))}},pU=class extends uU{constructor(e,t){super(e,{name:"smallDestination"}),this.resolution=t}resize(e,t){let i,r=e*t,n=this.resolution.width*this.resolution.height;EO.info("big res: ".concat(e,"*").concat(t," small res: ").concat(this.resolution.width,"*").concat(this.resolution.height," ")),r>n?i=r/n:(EO.warn("Small stream resolution is not smaller than big stream, which is invalid. big: ".concat(e," * ").concat(t," small: ").concat(this.resolution.width," * ").concat(this.resolution.height)),i=r/19200),super.resize(e/Math.sqrt(i),t/Math.sqrt(i))}},mU=class extends cU{constructor(e,t,i){super(e,qb({name:"imageSource"},i)),this.image=t,tC(this,"_image"),tC(this,"_totalFrames",0),tC(this,"_autoResize",!1),this._autoResize=!1!==(null==i?void 0:i.autoResize)}_render(e,t){let{width:i,height:r}=this;if(this.image instanceof HTMLVideoElement){if(ND(this.image.getVideoPlaybackQuality)&&!Fk){let e=this.image.getVideoPlaybackQuality().totalVideoFrames;if(this._totalFrames===e)return!1;this._totalFrames=e,this.dropFrames=this._totalFrames-this.totalFrames}({videoWidth:i,videoHeight:r}=this.image),this.image.width=i,this.image.height=r}else if(this.image instanceof HTMLImageElement||this.image instanceof ImageData||this.image instanceof ImageBitmap){if(({width:i,height:r}=this.image),this.image!==this._image)this._image=this.image;else if(i===this.width&&r===this.height)return!1}else(this.image instanceof HTMLCanvasElement||this.image instanceof OffscreenCanvas)&&(({width:i,height:r}=this.image),this._image=this.image);if(!this._autoResize)return!0;if(this.width===i&&this.height===r&&this.totalFrames){if(t){this.useTexture();let e=this.context.ctx;e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,this.image)}}else{if(t){this.useTexture();let e=this.context.ctx;e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this.image)}this.resize(i,r)}return!0}render(e){return this._render(e,!0)}render2d(e){return this._render(e,!1)}},_U=class extends mU{constructor(e,t,i){let r=document.createElement("video");r.setAttribute("playsinline","playsinline"),r.setAttribute("muted",""),super(e,r,i),this._videoTrack=t,tC(this,"_mediaStream"),this.name="videoTrackSource",this._mediaStream=new MediaStream([t]),this.image.srcObject=this._mediaStream,this.image.play()}replaceTrack(e){var t,i;this._videoTrack!==e&&(null==(t=this._mediaStream)||t.removeTrack(this._videoTrack),this._videoTrack=e,null==(i=this._mediaStream)||i.addTrack(this._videoTrack),this.image.play())}close(){var e;super.close(),null==(e=this._mediaStream)||e.removeTrack(this._videoTrack),delete this._mediaStream,this.image.srcObject=null}},fU=class extends gL{constructor(e){super(),tC(this,"frameRate"),tC(this,"_canvas"),tC(this,"log"),tC(this,"hasAlpha",!1),tC(this,"name"),this.name=e.name,this.log=e.logger.createChild({id:"vc-".concat(this.name)}),this.frameRate=e.frameRate}set width(e){this._canvas&&(this._canvas.width=e)}get width(){var e;return(null==(e=this._canvas)?void 0:e.width)||0}set height(e){this._canvas&&(this._canvas.height=e)}get height(){var e;return(null==(e=this._canvas)?void 0:e.height)||0}setSize(e,t){this._canvas&&(this._canvas.width=e,this._canvas.height=t)}createVideoTrackSource(e){return new _U(this,e)}createVideoTrackDestination(e){return new uU(this,e)}createVideoImageSource(e,t){return new mU(this,e,t)}get available(){return"created"===this.state}disconnect(){this.emit("disconnect")}},gU={alpha:!0,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0,powerPreference:"low-power"},EU=class extends fU{constructor(){super(...arguments),tC(this,"defaultProgam"),tC(this,"defaultVShader"),tC(this,"defaultFShader"),tC(this,"ctx")}create(){if(this._canvas||(this._canvas=document.createElement("canvas")),this.ctx=this._canvas.getContext("webgl2",gU),!this.ctx)throw new Error("webgl2 not supported");this.defaultVShader=this.createShader(this.ctx.VERTEX_SHADER,"\n// 顶点着色器\nattribute vec4 a_position;\nattribute vec2 a_texCoord;\nvarying vec2 v_texCoord;\n\nvoid main() {\n gl_Position = a_position;\n v_texCoord = a_texCoord;\n}\n"),this.defaultFShader=this.createShader(this.ctx.FRAGMENT_SHADER,"\n// 片元着色器\nprecision mediump float;\nvarying vec2 v_texCoord;\nuniform sampler2D u_texture;\n\nvoid main() {\n gl_FragColor = texture2D(u_texture, v_texCoord);\n} "),this.defaultProgam=this.createProgram(this.defaultVShader,this.defaultFShader),this._canvas.addEventListener("webglcontextlost",(()=>{this.destroy(new Error("webgl context lost"))})),this.log.info("video context created use webgl")}destroy(e){return this.disconnect(),this.log.info("video context destroy ".concat(e?": ".concat(e):"")),this.ctx&&(this.ctx.deleteShader(this.defaultVShader),this.ctx.deleteShader(this.defaultFShader),this.ctx.deleteProgram(this.defaultProgam),delete this.ctx),e}set width(e){var t;null==(t=this.ctx)||t.viewport(0,0,e,this.height),super.width=e}set height(e){var t;null==(t=this.ctx)||t.viewport(0,0,this.width,e),super.height=e}setSize(e,t){var i;null==(i=this.ctx)||i.viewport(0,0,e,t),super.setSize(e,t)}createShader(e,t){let i=this.ctx,r=i.createShader(e);return i.shaderSource(r,t),i.compileShader(r),r}createProgram(e,t){let i=this.ctx,r=i.createProgram();return i.attachShader(r,e),i.attachShader(r,t),i.linkProgram(r),i.getProgramParameter(r,i.LINK_STATUS)||this.log.error(i.getProgramInfoLog(r)),r}};eC([mL(gL.INIT,"created",{sync:!0})],EU.prototype,"create",1),eC([mL("created",gL.INIT,{ignoreError:!0,sync:!0,success(e){e&&this.emit("unavailable",e),this.removeAllListeners()}})],EU.prototype,"destroy",1);var vU=class extends fU{constructor(){super(...arguments),tC(this,"ctx")}create(e){if(this.hasAlpha=e.alpha,this._canvas=document.createElement("canvas"),this.ctx=this._canvas.getContext("2d",{alpha:e.alpha}),!this.ctx)throw new Error("2d context not supported");this.log.info("video context created use 2d")}destroy(e){this.disconnect(),this.log.info("video context destroy ".concat(e?": ".concat(e):"")),delete this.ctx,this._canvas&&(this._canvas.remove(),this._canvas.width=0,this._canvas.height=0,delete this._canvas),this.removeAllListeners()}};eC([mL(gL.INIT,"created",{sync:!0})],vU.prototype,"create",1),eC([mL("created",gL.INIT,{ignoreError:!0,sync:!0})],vU.prototype,"destroy",1);var yU,TU=[1,0,0,0,1,1,0,1],SU=class extends cU{constructor(e){if(super(e,{useDefaultProgram:!0,useFbo:!0,create2d:!0,name:"mirror"}),e instanceof EU)try{this.setTexBuffer(TU)}catch(t){e.destroy(t)}else this.ctx2d&&setTimeout((e=>{e.scale(-1,1),e.translate(-this.width,0)}),0,this.ctx2d)}render(e){var t;return!(null==(t=this.input)||!t.requestFrame(e)||(this.useProgram(),this.useBufferFrame(),this.useInputTexture(),this.draw(),0))}},IU=class{constructor(e,t){this.node=e,this.layout=t,tC(this,"positionBuffer")}get x(){return this.layout.x||this.node.x}get y(){return this.layout.y||this.node.y}get width(){return this.layout.width||this.node.width}get height(){return this.layout.height||this.node.height}get right(){return this.x+this.width}get bottom(){return this.y+this.height}},AU=class extends cU{constructor(e){super(e,{useDefaultProgram:!0,useFbo:!0,name:"mix",create2d:!0}),tC(this,"inputs",[])}addInput(e,t){if(this.inputs[t.zIndex])throw new Error("input already exists");let i=new IU(e,t);this.inputs[t.zIndex]=i}resize(e,t){let i=this.inputs.reduce(((e,t)=>t?Object.assign(e,{width:Math.max(e.width,t.right),height:Math.max(e.height,t.bottom)}):e),{width:0,height:0});super.resize(i.width,i.height),this.context instanceof EU&&this.inputs.forEach((e=>{if(e){let t=this.layout2texCoords(e);e.positionBuffer?this.changeBufferData(e.positionBuffer,t):e.positionBuffer=this.createBuffer(t)}}))}connect(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return super.connect(e,...i),this.resize(0,0),e}removeInput(e){this.inputs[this.inputs.findIndex((t=>(null==t?void 0:t.node)===e))]=void 0}render(e){let t=this.context.ctx;if(t.clearColor(0,0,0,0),!this.inputs.reduce(((t,i)=>(!i||!i.node.requestFrame(e))&&t),!0)&&t){this.useProgram(),t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA),this.useBufferFrame();for(let e=0;e<this.inputs.length;e++){let t=this.inputs[e];t&&(t.node.useTexture(),this.draw(t.positionBuffer))}return!0}return!1}render2d(e){if(!this.inputs.reduce(((t,i)=>(!i||!i.node.requestFrame(e))&&t),!0)&&this.ctx2d){this.ctx2d.clearRect(0,0,this.width,this.height);for(let e=0;e<this.inputs.length;e++){let t=this.inputs[e];t&&this.draw2d(t.node.image,t.x,t.y,t.width,t.height)}return!0}return!1}getInfo(){let{totalFrames:e,x:t,y:i,width:r,height:n,name:o}=this,s=Date.now(),a=(e-this.lastInfo.totalFrames)/((s-this.lastInfo.timestamp)/1e3)|0;return this.lastInfo={totalFrames:e,x:t,y:i,width:r,height:n,timestamp:s,fps:a,name:o},qb({parent:this.inputs.filter((e=>e)).map((e=>e.node.getInfo()))},this.lastInfo)}close(){super.close(),this.inputs.forEach((e=>{var t,i;if(e&&(null==(t=e.node)||t.disconnect(),e.positionBuffer&&this.context instanceof EU))try{null==(i=this.context.ctx)||i.deleteBuffer(e.positionBuffer)}catch(r){}}))}},RU=class{constructor(e,t){this.createMediapipeSolutionsWasm=t,tC(this,"canvas"),tC(this,"locateFile"),tC(this,"_glName"),tC(this,"_solutionWasm"),tC(this,"ctx"),tC(this,"pl",{onResults:e=>this.onResults(e.get(0).glName)}),this.locateFile=t=>"".concat(e,"/").concat(t)}bindTexture(){var e;null==(e=this.ctx)||e.activeTexture(this.ctx.TEXTURE0),this.bindTexture2d(this._glName)}initialize(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"selfie_segmentation_landscape.tflite";return rC(this,null,(function*(){yield this.createMediapipeSolutionsWasm(this),this.canvas=e,this.createContext(e,!0,!0,{}),this._glName=this.createTexture(),this._solutionWasm=new this.SolutionWasm;let i=new this.StringList;i.push_back("segmentation_mask");let r=this.PacketListener.implement(this.pl);this._solutionWasm.attachMultiListener(i,r),i.delete(),this._solutionWasm.loadGraph(yield fetch(this.locateFile("selfie_segmentation.binarypb")).then((e=>e.arrayBuffer()))),this._solutionWasm.overrideFile("third_party/mediapipe/modules/selfie_segmentation/selfie_segmentation_landscape.tflite",yield fetch(this.locateFile(t)).then((e=>e.arrayBuffer())));let n=new this.GraphOptionChangeRequestList;return n.push_back({calculatorIndex:1,calculatorName:"",calculatorType:"GlScalerCalculator",fieldName:"flip_horizontal",valueBoolean:!1,valueNumber:0,valueString:""}),n.push_back({calculatorIndex:0,calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculatorModelSelection",fieldName:"int_value",valueBoolean:!1,valueNumber:1,valueString:""}),n.push_back({calculatorIndex:0,calculatorType:"InferenceCalculator",calculatorName:"",fieldName:"use_cpu_inference",valueBoolean:!1,valueNumber:0,valueString:""}),this._solutionWasm.changeOptions(n),this}))}send(e,t){let i=new this.PacketDataList;i.pushTexture2d({stream:"input_frames_gpu",timestamp:1e3*performance.now(),glName:this._glName,width:e,height:t}),this._solutionWasm.send(i),i.delete()}close(){var e,t,i;null==(e=this.canvas)||delete e.getContext,delete this.readyPromiseResolve,delete this.readyPromiseReject,this.pl.onResults=null,delete this.onResults,null==(t=this.deleteTexture)||t.call(this,this._glName),null==(i=this._solutionWasm)||i.delete();for(let r of Object.keys(this))delete this[r]}},bU=class extends _U{constructor(e,t){super(e,t.input,{name:"vb",create2d:!1,useDefaultProgram:!1,useFbo:!1,createTexture:!0}),tC(this,"ready",!1),tC(this,"_bgTexture"),tC(this,"_waterMarkTexture"),tC(this,"_lastMaskTexture"),tC(this,"_textureValid",!1),tC(this,"_selfieTextureValid",!1),tC(this,"_selfieSegmentation"),tC(this,"wasm"),this.init(t).catch((()=>this.context.destroy(new Error("selfie_segmentation init faild"))))}init(e){return rC(this,null,(function*(){let t=yield e.Wasm(),i=this.context.ctx;if(this.wasm=new t.AllIn1(i),this.wasm.blurRadius=e.blurRadius||3,this.wasm.mirror=!!e.mirror,this.wasm.vbMode="blur"===e.bg?1:e.bg instanceof HTMLImageElement?2:"green"===e.bg?3:0,e.waterMark){let{x:t,y:i,width:r,height:n}=e.waterMark;this.wasm.setWaterMark(t,i,r,n)}this.program=this.wasm.init(),this.useProgram(),this.setAttributes(this.positionBuffer,this.texCoordBuffer),i.uniform1i(i.getUniformLocation(this.program,"mask"),1),e.bg instanceof HTMLImageElement&&(i.uniform1i(i.getUniformLocation(this.program,"bg"),2),this._bgTexture=this.createTexture(e.bg)),e.waterMark&&(i.uniform1i(i.getUniformLocation(this.program,"waterMark"),3),this._waterMarkTexture=this.createTexture(e.waterMark.image)),i.uniform1i(i.getUniformLocation(this.program,"lastMask"),4),this._selfieSegmentation=yield e.selfieSegmentation,this._selfieSegmentation.onResults=this.onPredict.bind(this),this.ready=!0}))}onPredict(e){let t=this.context.ctx;this._lastMaskTexture||(this._lastMaskTexture=this.createTexture(this.image)),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,1&this.totalFrames?this.texture:this._lastMaskTexture),t.copyTexSubImage2D(t.TEXTURE_2D,0,0,0,0,0,this.width,this.height),this.useProgram(),this._selfieSegmentation.bindTexture(),t.activeTexture(t.TEXTURE1),this._selfieSegmentation.bindTexture2d(e),t.activeTexture(t.TEXTURE2),t.bindTexture(t.TEXTURE_2D,this._bgTexture||null),t.activeTexture(t.TEXTURE3),t.bindTexture(t.TEXTURE_2D,this._waterMarkTexture||null),t.activeTexture(t.TEXTURE4),t.bindTexture(t.TEXTURE_2D,1&this.totalFrames?this._lastMaskTexture:this.texture),this.useBufferFrame(),t.drawArrays(t.TRIANGLE_STRIP,0,4),this.totalFrames++}render(e){let t=this.context.ctx;if("function"==typeof this.image.getVideoPlaybackQuality&&!Fk){let e=this.image.getVideoPlaybackQuality().totalVideoFrames;if(this._totalFrames===e)return!1;this._totalFrames=e,this.dropFrames=this._totalFrames-this.totalFrames}let{videoWidth:i,videoHeight:r}=this.image;this.image.width=i,this.image.height=r;let n=!1;if(this.totalFrames)this._selfieSegmentation.bindTexture(),n=this._selfieTextureValid,this._selfieTextureValid=!0;else{if(!this.program)return!1;this.useTexture(),n=this._textureValid,this._textureValid=!0}return this.width===i&&this.height===r&&n?t.texSubImage2D(t.TEXTURE_2D,0,0,0,t.RGBA,t.UNSIGNED_BYTE,this.image):(this.resize(i,r),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,this.image)),this.ready&&this._selfieSegmentation.send(i,r),this.totalFrames||(t.activeTexture(t.TEXTURE2),t.bindTexture(t.TEXTURE_2D,this._bgTexture||null),t.activeTexture(t.TEXTURE3),t.bindTexture(t.TEXTURE_2D,this._waterMarkTexture||null),t.drawArrays(t.TRIANGLE_STRIP,0,4)),!1}close(){var e;super.close();let t=this.context.ctx;this._bgTexture&&t.deleteTexture(this._bgTexture),this._waterMarkTexture&&t.deleteTexture(this._waterMarkTexture),this._lastMaskTexture&&t.deleteTexture(this._lastMaskTexture),null==(e=this.wasm)||e.close()}},CU=class extends oU.EventEmitter{constructor(e){super(),this.room=e,tC(this,"videoContext"),tC(this,"_glVideoContext"),tC(this,"_2dVideoContext"),tC(this,"destination"),tC(this,"smallVideoContext"),tC(this,"smallDestination"),tC(this,"smallTrackSource"),tC(this,"smallImageSource"),tC(this,"_isMirror",!1),tC(this,"cameraTrack"),tC(this,"cameraNode"),tC(this,"mirrorNode"),tC(this,"mixNode"),tC(this,"screenTrack"),tC(this,"screenNode"),tC(this,"selfModel",!1),tC(this,"blurRadius",3),tC(this,"arTrack"),tC(this,"Wasm"),tC(this,"waterMarkNode"),tC(this,"_waterMarkOption"),tC(this,"watermarkImageList",[]),tC(this,"_isMixScreen",!1),tC(this,"_virtualBackground"),tC(this,"virtualBackgroundInstance"),tC(this,"isUsingArTrack",!1),tC(this,"_bgAssetPath"),tC(this,"log",EO.createLogger({id:"vm"})),tC(this,"_checkId",0),tC(this,"_use2d",!1),tC(this,"_autoSwitchRenderMode",!0),tC(this,"_selfieSegmentation"),e&&(this.log.setUserId(e.userId),this.log.setSdkAppId(e.sdkAppId)),this.smallVideoContext=new vU({frameRate:15,logger:this.log,name:"s"}),this.enablePrintDetail()}get _hasVirtualBg(){return!!this._virtualBackground}get _hasWaterMark(){return this.watermarkImageList.length>0}get renderMode(){return this._autoSwitchRenderMode?"auto":this._use2d?"2d":"webgl"}set renderMode(e){if(this._autoSwitchRenderMode="auto"===e,this._autoSwitchRenderMode)return;let t="2d"===e;this._use2d!==t&&(this._use2d=t,this.clear(),this.videoContext=this._use2d?this.get2dVideoContext():this.getGlVideoContext(),this.update())}get2dVideoContext(){return this._2dVideoContext?this._2dVideoContext.destroy():this._2dVideoContext=new vU({frameRate:15,logger:this.log,name:"m"}),this._2dVideoContext.create({alpha:this._hasWaterMark||this._hasVirtualBg}),this.sendCreateResult("videoCtx2d",this._2dVideoContext.ctx?void 0:new Error("create 2d context failed")),this._2dVideoContext}getGlVideoContext(){if(this._glVideoContext){if(this._glVideoContext.available)return this._glVideoContext}else this._glVideoContext=new EU({frameRate:15,logger:this.log,name:"m"});try{this._glVideoContext.create(),this.sendCreateResult(),this._glVideoContext.on("unavailable",((e,t)=>{this.emit("error",{reason:e,error:t}),this.log.warn("video context unavailable",e,t),this.sendCreateResult("videoCtxGl",t||new Error(e)),this.update()}))}catch(e){this.emit("error",{reason:"create",error:e}),this.sendCreateResult("videoCtxGl",e)}return this._glVideoContext}enablePrintDetail(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3;this._checkId=SL.run(MN,(()=>{this.destination&&this.log.debug(this.destination.getInfo())}),{delay:e})}destroy(){var e,t;null==(e=this._2dVideoContext)||e.destroy(),null==(t=this._glVideoContext)||t.destroy(),this.smallVideoContext.destroy(),SL.clearTask(this._checkId)}get needAlpha(){return this._hasWaterMark||this._hasVirtualBg}get active(){return(Fk||this._isMixScreen||this._isMirror||this._hasWaterMark||this._hasVirtualBg)&&this.checkOrCreateVideoContext()}sendCreateResult(){let e=arguments.length>1?arguments[1]:void 0,t="videoCtxGl"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"videoCtxGl")?512700:512701;e?pP.addFailedEvent({key:t,error:e}):pP.addSuccessEvent({key:t})}checkOrCreateVideoContext(){let e=this._use2d;if(this._autoSwitchRenderMode&&(this._use2d=!this._hasVirtualBg),this.videoContext)if(this.videoContext.available){let t=!this.videoContext.hasAlpha&&this.needAlpha;if(this._autoSwitchRenderMode&&e===this._hasVirtualBg)this.clear();else{if(!t)return!0;if(!this._use2d)return!0;this.clear()}}else this.clear(),this._use2d=!0;return this.videoContext=this._use2d?this.get2dVideoContext():this.getGlVideoContext(),this.videoContext.available}get smallTrack(){var e;return null==(e=this.smallDestination)?void 0:e.videoTrack}get hasSmall(){return!!this.smallTrack}get initialTrack(){var e;return null==(e=this.cameraTrack)?void 0:e.mediaTrack}initVirtualBackground(e){if(!this._selfieSegmentation){let t=new RU(e.assetPath||"./selfie_segmentation",e.createMediapipeSolutionsWasm),i=this.getGlVideoContext();return i.available?this._selfieSegmentation=t.initialize(i._canvas,"selfie_segmentation_landscape.tflite"):Promise.reject(new Error("init virtual background failed, reason: video context unavailable"))}return this._selfieSegmentation}_setMainOutput(e){var t;let i=this.cameraTrack,{small:r,settings:n,player:o}=i;r?(this.smallVideoContext.available||(this.smallVideoContext.create({alpha:!1}),this.smallDestination=new pU(this.smallVideoContext,r)),this.smallVideoContext.frameRate=r.frameRate,this.smallDestination.resolution=r,e?(this.smallTrackSource&&(this.smallTrackSource.close(),delete this.smallTrackSource),this.smallImageSource?this.smallImageSource.image=e:(this.smallImageSource=this.smallVideoContext.createVideoImageSource(e),this.smallImageSource.connect(this.smallDestination))):(this.smallImageSource&&(this.smallImageSource.close(),delete this.smallImageSource),this.smallTrackSource?this.smallTrackSource.replaceTrack(this.initialTrack):(this.smallTrackSource=this.smallVideoContext.createVideoTrackSource(this.initialTrack),this.smallTrackSource.width=n.width,this.smallTrackSource.height=n.height,this.smallTrackSource.connect(this.smallDestination)))):this.smallVideoContext.available&&(this.smallVideoContext.destroy(),delete this.smallDestination,delete this.smallTrackSource,delete this.smallImageSource),Fk&&o.setCanvas(e);let s=e&&(null==(t=this.destination)?void 0:t.videoTrack)||this.initialTrack;return this.isUsingArTrack&&this.arTrack&&(this.emit("output-track-changed"),s=this.arTrack),i.setOutputMediaStreamTrack(s)}update(){return rC(this,null,(function*(){var e,t;if(!this.cameraTrack||!this.cameraTrack.mediaTrack)return;if(!this.active)return this.cameraNode&&this.clear(),this._setMainOutput();let{settings:i,profile:r}=this.cameraTrack;if(this._use2d||!this._selfieSegmentation?(this.destination||(this.destination=this.videoContext.createVideoTrackDestination({name:"mainDestination"})),this.cameraNode?this.cameraNode.replaceTrack(this.initialTrack):(this.cameraNode=this.videoContext.createVideoTrackSource(this.initialTrack),this.cameraNode.resize(i.width,i.height))):(this.cameraNode&&this.cameraNode.close(),this.destination||(this.destination=new hU(this.videoContext,{name:"mainDestination"})),this.cameraNode=new bU(this.videoContext,{input:this.cameraTrack.mediaTrack,mirror:this._isMirror,bg:this._virtualBackground,selfModel:this.selfModel,waterMark:this._waterMarkOption,useTflite:!0,blurRadius:this.blurRadius,assetPath:this._bgAssetPath,selfieSegmentation:this._selfieSegmentation,Wasm:this.Wasm}),this.cameraNode.connect(this.destination)),this.videoContext.frameRate=r.frameRate,this._use2d){let i=this.cameraNode;i.disconnect(),this._isMirror&&(this.mirrorNode||(this.mirrorNode=new SU(this.videoContext)),i=i.connect(this.mirrorNode),i.disconnect(),this.log.info("start mirror")),this.mixNode&&this.mixNode.close(),delete this.mixNode,(this._isMixScreen||this._hasWaterMark)&&(this.mixNode=new AU(this.videoContext),i.connect(this.mixNode,{zIndex:1}),this._hasWaterMark&&!this.waterMarkNode&&this._waterMarkOption&&(this.waterMarkNode=this.videoContext.createVideoImageSource(this._waterMarkOption.image,{autoResize:!1}),this.waterMarkNode.resize(this._waterMarkOption.width,this._waterMarkOption.height),this.waterMarkNode.x=this._waterMarkOption.x,this.waterMarkNode.y=this._waterMarkOption.y),null==(e=this.waterMarkNode)||e.connect(this.mixNode,{zIndex:2}),this._isMixScreen&&this.screenTrack&&!this.screenNode&&(this.screenNode=this.videoContext.createVideoTrackSource(this.screenTrack.mediaTrack)),null==(t=this.screenNode)||t.connect(this.mixNode,{zIndex:0}),i=this.mixNode,this.log.info("start mix","".concat(this.mixNode.width,"x").concat(this.mixNode.height))),i.connect(this.destination)}return this._setMainOutput(this.videoContext._canvas)}))}changeInput(e){return this.log.info("change input"),e instanceof aM?this.setScreenTrack(e):e instanceof rM?this.setCameraTrack(e):e instanceof pM?e.setOutputMediaStreamTrack(e.mediaTrack):void 0}removeInput(e){var t;e instanceof aM?(null==(t=this.screenNode)||t.close(),delete this.screenNode,delete this.screenTrack,this.update()):e instanceof rM&&(this.clear(),delete this.cameraTrack,this.smallImageSource&&(this.smallImageSource.close(),delete this.smallImageSource),this.smallTrackSource&&(this.smallTrackSource.close(),delete this.smallTrackSource))}setCameraTrack(e){return rC(this,null,(function*(){this.cameraTrack=e,this.update()}))}setScreenTrack(e){return this.screenTrack=e,this._isMixScreen&&(this.screenNode?this.screenNode.replaceTrack(e.mediaTrack):this.update()),e.setOutputMediaStreamTrack(e.mediaTrack)}getWatermarkImage(e,t){return rC(this,null,(function*(){let i=document.createElement("canvas");t&&e&&(i.height=t,i.width=e);let r=i.getContext("2d");if(!r)throw new fC({code:_C.NOT_SUPPORTED,message:"Make image failed because of canvas context is null"});return this.watermarkImageList.sort(((e,t)=>e.zIndex-t.zIndex)),this.watermarkImageList.forEach((e=>{let{image:t,x:i,y:n,width:o,height:s}=e;r.drawImage(t,i,n,o,s)})),dO(i.toDataURL())}))}pushWaterMarkImageList(e){let{type:t}=e;this.watermarkImageList.some((t=>t.imageUrl===e.imageUrl&&t.height===e.height&&t.width===e.width&&t.x===e.x&&t.y===e.y&&t.type===e.type&&t.zIndex===e.zIndex))||(("mute"===t||"watermark"===t)&&(this.watermarkImageList=this.watermarkImageList.filter((e=>e.type!==t))),this.watermarkImageList.push(e))}setWatermark(e){return rC(this,null,(function*(){let t;try{t=yield dO((null==e?void 0:e.imageElement)||e.imageUrl)}catch(c){throw new fC({code:_C.INVALID_PARAMETER,message:"load image failed, url: ".concat(e.imageUrl)})}let{x:i=0,y:r=0,width:n=t.width,height:o=t.height,type:s="watermark",zIndex:a=2}=e;this.pushWaterMarkImageList({x:i,y:r,width:n,height:o,image:t,zIndex:a,type:s,imageUrl:e.imageUrl}),yield this.freshWatermark(),this.log.info("set watermark",JSON.stringify(this.watermarkImageList))}))}deleteWatermark(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"watermark";return rC(this,null,(function*(){this.watermarkImageList=this.watermarkImageList.filter((t=>t.type!==e)),this.log.info("delete watermark",e,JSON.stringify(this.watermarkImageList)),yield this.freshWatermark()}))}freshWatermark(){return rC(this,null,(function*(){var e,t,i;null==(e=this.waterMarkNode)||e.close(),delete this.waterMarkNode,delete this._waterMarkOption;let r=yield this.getWatermarkImage(null==(t=this.cameraTrack)?void 0:t.settings.width,null==(i=this.cameraTrack)?void 0:i.settings.height);this._waterMarkOption={x:0,y:0,width:r.width,height:r.height,image:r},this.update()}))}setVirtualBackground(e){return rC(this,null,(function*(){if(e){if(this._use2d&&!this._autoSwitchRenderMode)return Promise.reject(new Error("not support virtual background in 2d mode"));this._bgAssetPath=e.assetPath,"image"===e.type?this._virtualBackground=yield dO(e.imageUrl):(this.blurRadius=e.blurRadius||3,this._virtualBackground=e.type)}else this._virtualBackground=void 0;this.log.info("".concat(this._virtualBackground?"start":"stop"," visual background, ").concat((null==e?void 0:e.type)||"")),this.update()}))}get mixScreen(){return this._isMixScreen}set mixScreen(e){var t;this._isMixScreen=e,this._isMixScreen||(null==(t=this.screenNode)||t.close(),delete this.screenNode),this.update()}set mirror(e){var t;this._isMirror!==e&&(this._isMirror=e,this._isMirror||(null==(t=this.mirrorNode)||t.close(),delete this.mirrorNode),this.update())}get mirror(){return this._isMirror}enableAr(e){this.arTrack=e,this.isUsingArTrack=!0,this.update()}updateAr(){return rC(this,null,(function*(){var e;null==(e=this.cameraTrack)||!e.mediaTrack||(yield this.virtualBackgroundInstance.ar.updateInputTrack(this.cameraTrack.mediaTrack.clone()))}))}disableAr(){var e;this.isUsingArTrack=!1,null==(e=this.arTrack)||e.stop(),this.arTrack=void 0,this.update()}clear(){var e;null==(e=this.videoContext)||e.disconnect(),delete this.destination,delete this.cameraNode,delete this.mirrorNode,delete this.screenNode,delete this.waterMarkNode}},kU=0,wU=class extends gL{constructor(e){super("room"),this.seq=++kU,this.role="anchor",this.localTracks=new Set,this.enableAutoPlayDialog=!0,this.autoReceiveAudio=!0,this.autoReceiveVideo=!0,this.scheduleResult={domains:null,iceServers:null,iceTransportPolicy:null,trtcAutoConf:null},this._isUsingCachedSchedule=!1,this._log=EO.createLogger({id:"r".concat(this.seq)}),this._joinedTimestamp=0,this.isDestroyed=!1,this.useStringRoomId=!!e.useStringRoomId,PD(e.autoReceiveAudio)&&(this.autoReceiveAudio=e.autoReceiveAudio),PD(e.autoReceiveVideo)&&(this.autoReceiveVideo=e.autoReceiveVideo),PD(e.enableAutoPlayDialog)&&(this.enableAutoPlayDialog=e.enableAutoPlayDialog),this._sdkType=e.sdkType,this.keyPointManager=new tU({room:this,frameWorkType:e.frameWorkType,component:e.component,language:e.language}),this.callDurationCalculator=new rU({room:this}),this.badCaseDetector=new nU({room:this}),this.audioManager=new lM(this),this.videoManager=new CU(this)}get isMainStreamPublished(){for(let e of this.localTracks)if(4&e.mediaType)return!0;return!1}get isAuxStreamPublished(){for(let e of this.localTracks)if(2&e.mediaType)return!0;return!1}get hasAuxStream(){for(let e of this.remotePublishedUserMap.values())if(e.muteState.hasAuxiliary)return!0;return this.isAuxStreamPublished}getLogger(){return this._log}get isJoining(){return"joining"===this.state.toString()}get isJoined(){return"joined"===this.state}get isLeft(){return"left"===this.state}addTrack(e){return rC(this,null,(function*(){return this.publish(e)}))}removeTrack(e){return rC(this,null,(function*(){return this.unpublish(e)}))}replaceTrack(e){return rC(this,null,(function*(){}))}setEncodedDataProcessingListener(e){throw new Error("Method not implemented.")}enableAIVoice(e){throw new Error("Method not implemented.")}setProxyServer(e){if(OD(e))e.startsWith("wss://")?this.proxy_ws=e:e.startsWith("https://")&&(this.proxy_wt=e);else if(bD(e)){let{websocketProxy:t,webtransportProxy:i,loggerProxy:r,scheduleProxy:n,unifiedProxy:o}=e;this.proxy_ws=t,this.proxy_wt=i,this.proxy_unified=o,o?(iD([o,o]),mw("https://".concat(o))):(r&&mw(r),n&&iD(n))}JN.once(fO.JOIN_RECEIVED_CMD_RES,(()=>this.sendAbilityStatus({sched_domain:tD.main,sched_back_domain:tD.backup,signal_domain:this.proxy_ws||this.proxy_wt||""})))}getRemoteAudioStats(){return rC(this,null,(function*(){let e={};return this.remotePublishedUserMap.forEach((t=>{e[t.userId]=t.remoteAudioTrack.stat})),e}))}getTransportStats(){return rC(this,null,(function*(){var e;let t={rtt:(null==(e=this.quality)?void 0:e.uplinkRTT)||0,downlinksRTT:{}};if(this.quality)for(let i of this.quality.downlinkInfo)t.downlinksRTT[i.userId]=i.rtt;return t}))}getRemoteVideoStats(){return rC(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"main";return function*(){let i={};return e.remotePublishedUserMap.forEach((e=>{let r="auxiliary"===t?e.remoteAuxiliaryTrack:e.remoteVideoTrack;i[e.userId]=r.stat})),i}()}))}checkDestroy(){if(this.isDestroyed)throw new fC({code:_C.INVALID_OPERATION,message:GN({key:HN.CLIENT_DESTROYED,data:{funName:"join"}})})}destroy(){if(this.isJoined)throw this._log.warn(jN.INVALID_DESTROY),new fC({code:_C.INVALID_OPERATION,message:GN({key:HN.INVALID_DESTROY})});this._log.info("destroy room"),this.audioManager.destroy(),this.videoManager.destroy(),this.keyPointManager.destroy(),this.callDurationCalculator.destroy(),this.badCaseDetector.destroy(),this.isDestroyed=!0,JN.emit(fO.ROOM_DESTROY,{room:this})}schedule(e,t){return rC(this,null,(function*(){var i,r;let n=zD();try{let{isCached:o,result:s,detailCost:a}=yield eD({userId:this.userId,sdkAppId:this.sdkAppId,roomId:e,useStringRoomId:this.useStringRoomId,version:ow,userSig:this.userSig,frameWorkType:t});this._isUsingCachedSchedule=o,this._log.info("schedule cache:".concat(+o," ").concat(oO(s,{keysToExclude:["username","credential"]}))),o&&JN.once(fO.JOIN_RECEIVED_CMD_RES,(()=>this.sendAbilityStatus({scheduleCache:1}))),this.scheduleResult=qb(qb({},this.scheduleResult),s),LD(null==(i=s.config)?void 0:i.retryCount)&&oN(s.config.retryCount),OD(null==(r=s.config)?void 0:r.loggerDomain)&&mw(s.config.loggerDomain),JN.emit(fO.JOIN_SCHEDULE_SUCCESS,{room:this,schedule:this.scheduleResult,detailCost:a}),pP.addSuccessEvent({key:521700,cost:zD()-n,split:50})}catch(o){throw pP.addFailedEvent({key:521700,error:o}),o}}))}},NU=$b(nC()),DU=$b(hC()),OU=e=>{let{serverAbility:t,clientAbility:i,offerSDP:r,enableCustomMessage:n}=e,o=VV(r),s={extmapAllowMixed:"extmap-allow-mixed",groups:o.groups,icelite:"ice-lite",media:[],msidSemantic:{semantic:"",token:"WMS"},name:"-",origin:{address:"127.0.0.1",username:"-",sessionId:String(Date.now()),sessionVersion:1,netType:"IN",ipVer:4},timing:{start:0,stop:0},version:0},a={candidates:t.candidates.map((e=>({component:1,foundation:"1",generation:0,ip:e.ip,port:e.port,priority:e.priority,transport:e.foundation,type:e.type}))),connection:{version:4,ip:"0.0.0.0"},direction:Mw.TRANSCEIVER_DIRECTION_RECVONLY,ext:t.audio.extensions.map((e=>({value:e.id,uri:e.uri}))),fingerprint:{type:t.dtls.hash,hash:t.dtls.fingerprint},fmtp:[{payload:t.audio.codecs[0].payload,config:t.audio.codecs[0].fmtp}],icePwd:t.ice.password,iceUfrag:t.ice.ufrag,mid:"0",payloads:String(t.audio.codecs[0].payload),port:o.media[0].port,protocol:o.media[0].protocol,type:Mw.AUDIO,setup:t.dtls.setup,rtcpFb:t.audio.codecs[0].rtcpfb.map((e=>({payload:t.audio.codecs[0].payload,type:e.id,subtype:e.params[0]}))),rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",rtp:[{payload:t.audio.codecs[0].payload,codec:t.audio.codecs[0].codec,rate:t.audio.codecs[0].rate,encoding:t.audio.codecs[0].channels}]};return s.media.push(a),[1,2,3].forEach((e=>{s.media.push(LU({mid:e,serverAbility:t,clientAbility:i,parsedOffer:o}))})),n&&s.media.push(o.media.find((e=>"dc"===e.mid))),UV(s)},LU=e=>{let{mid:t,serverAbility:i,clientAbility:r,parsedOffer:n,useAllCodec:o=!1}=e,s={candidates:i.candidates.map((e=>({component:1,foundation:"1",generation:0,ip:e.ip,port:e.port,priority:e.priority,transport:e.foundation,type:e.type}))),connection:{version:4,ip:"0.0.0.0"},direction:Mw.TRANSCEIVER_DIRECTION_RECVONLY,ext:i.video.extensions.map((e=>({value:e.id,uri:e.uri}))),fingerprint:{type:i.dtls.hash,hash:i.dtls.fingerprint},fmtp:[],icePwd:i.ice.password,iceUfrag:i.ice.ufrag,mid:String(t),payloads:"",port:n.media[0].port,protocol:n.media[0].protocol,type:Mw.VIDEO,setup:i.dtls.setup,rtcpFb:[],rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",rtp:[]};if(i.video.codecs.length>0)if(o)for(let a=0;a<i.video.codecs.length;a++)PU(s,i.video.codecs[a]);else{let e=i.video.codecs.findIndex((e=>e.codec.toLowerCase()===(i.useVp8?"vp8":"h264")));PU(s,i.video.codecs[e])}else if(o)for(let a=0;a<r.video.codecs.length;a++)PU(s,r.video.codecs[a]);else PU(s,r.video.codecs[0]);return s.payloads=s.payloads.trim(),s},PU=(e,t)=>{e.payloads="".concat(e.payloads," ").concat(t.payload),e.fmtp.push({payload:t.payload,config:t.fmtp}),e.rtcpFb=[...e.rtcpFb||[],...(t.rtcpfb||t.rtcpFb).map((e=>({payload:t.payload,type:e.id,subtype:e.params[0]})))],e.rtp.push({payload:t.payload,codec:t.codec.toUpperCase(),rate:t.rate}),t.rtx&&(e.payloads="".concat(e.payloads," ").concat(t.rtx),e.fmtp.push({payload:t.rtx,config:"apt=".concat(t.payload)}),e.rtp.push({payload:t.rtx,codec:"rtx",rate:t.rate}))},MU=e=>{let t=DU.default.parse(e);return t.media.forEach((e=>{var i,r;(e.type===Mw.AUDIO||e.type===Mw.VIDEO)&&(function(e){if(!e.rtcpFb)return;let t=[];e.rtcpFb.forEach(((i,r)=>{var n;t.push(i),e.rtcpFb&&(null==(n=e.rtcpFb[r+1])?void 0:n.payload)!==i.payload&&"rrtr"!==i.type&&t.push({payload:i.payload,type:"rrtr"})})),e.rtcpFb=t}(e),(r=e).type===Mw.VIDEO&&r.fmtp&&r.fmtp.forEach((e=>{e.config.includes("apt")||(e.config+=";sps-pps-idr-in-keyframe=1")})),function(e){e.type===Mw.AUDIO&&e.fmtp&&e.fmtp.forEach((e=>{e.config+=";sprop-stereo=1;stereo=1"}))}(e),function(e){let t=new Set(["urn:ietf:params:rtp-hdrext:sdes:mid","urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id","urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"]);e.ext&&(e.ext=e.ext.filter((e=>!t.has(e.uri))))}(e)),(null==(i=e.payloads)?void 0:i.includes("datachannel"))&&t.groups&&e.mid&&(t.groups[0].mids=t.groups[0].mids.replace(e.mid,"dc"),e.mid="dc")})),DU.default.write(t)},xU=class{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.dataView=e,this.isSEI&&(t?this.addPreventionByte():this.removePreventionByte())}addPreventionByte(){let e=this.seiPayloadStartIndex,t=this.dataView.byteLength-2,i=[],r=0;for(let o=e;o<=t;o++){let e=this.dataView.getInt8(o);switch(e){case 0:case 1:case 2:case 3:2===r&&(i.push(3),r=0),0==e?r++:r=0,i.push(e);break;default:r=0,i.push(e)}}i.push(this.dataView.getInt8(this.dataView.byteLength-1));let n=new DataView(new Uint8Array([...new Uint8Array(this.dataView.buffer).slice(0,e),...i]).buffer);this.dataView=n}removePreventionByte(){let e=this.seiPayloadStartIndex,t=this.dataView.byteLength-1,i=[],r=0;for(let o=e;o<=t;o++)switch(this.dataView.getInt8(o)){case 0:r++,i.push(this.dataView.getInt8(o));break;case 3:2!==r&&i.push(this.dataView.getInt8(o)),r=0;break;default:i.push(this.dataView.getInt8(o)),r=0}let n=new DataView(new Uint8Array([...new Uint8Array(this.dataView.buffer).slice(0,e),...i]).buffer);this.dataView=n}get isSEI(){return 6===this.dataView.getUint8(4)}get seiPayloadStartIndex(){let e=6;for(let t=6;t<this.dataView.buffer.byteLength&&(e++,255===this.dataView.getUint8(t));t++);return e}get seiPayloadType(){return this.isSEI?this.dataView.getUint8(5):null}get seiPayload(){if(!this.isSEI)return null;let e=0,t=6;for(let n=6;n<this.dataView.buffer.byteLength;n++){let i=this.dataView.getUint8(n);if(t++,255!==i){e+=i;break}e+=255}let i=new ArrayBuffer(e),r=new DataView(i);for(let n=0;n<i.byteLength;n++,t++)r.setInt8(n,this.dataView.getInt8(t));return r}},VU=class{constructor(e,t){this._singlePC=e,this._log=t,tC(this,"_seiMessageList",[]),tC(this,"_smallSeiMessageList",[]),tC(this,"_seiPayloadType",243),tC(this,"_seiAbortMap",new Map),tC(this,"_nonSeiAbortMap",new Map),tC(this,"onSEIMessage",null)}isRunning(e){return this._seiAbortMap.has(e)}start(e){let t=e.direction===Mw.TRANSCEIVER_DIRECTION_SENDONLY,i=(t?e.sender:e.receiver).createEncodedStreams(),r=i.readable,n=i.writable,o=new TransformStream({transform:t?(t,i)=>this.encodeVideoFrame(t,i,e):(t,i)=>this.decodeVideoFrame(t,i,e)}),s=new AbortController;r.pipeThrough(o).pipeTo(n,s).catch((e=>{this._log.warn(e)})),this._seiAbortMap.set(e,s)}restart(e){this.stop(e),this.start(e)}stop(e){var t;null==(t=this._seiAbortMap.get(e))||t.abort(),this._seiAbortMap.delete(e)}destroy(){this._seiAbortMap.forEach((e=>e.abort())),this._seiAbortMap.clear(),this._nonSeiAbortMap.forEach((e=>e.abort())),this._nonSeiAbortMap.clear(),this.onSEIMessage=null}handleEncodedStreams(){try{this._singlePC.getPeerConnection().getTransceivers().forEach(((e,t)=>{var i,r;if("inactive"!==e.direction&&e.mid)if(t<4)1===t||2===t?this.isRunning(e)||this.start(e):this._nonSeiAbortMap.has(e)||this.pipeSenderOrReceiver(e);else{let n=(t-4)%3==1,o=(t-4)%3==2;(null==(r=null==(i=e.receiver)?void 0:i.track)?void 0:r.kind)===Mw.VIDEO&&(n||o)?this.isRunning(e)||this.start(e):this._nonSeiAbortMap.has(e)||this.pipeSenderOrReceiver(e)}}))}catch(e){this._log.warn(e)}}pipeSenderOrReceiver(e){let t=e.direction===Mw.TRANSCEIVER_DIRECTION_SENDONLY?e.sender:e.receiver,{readable:i,writable:r}=t.createEncodedStreams(),n=new AbortController;this._nonSeiAbortMap.set(e,n),i.pipeTo(r,n).catch((()=>{}))}push(e,t){var i,r;t&&t.seiPayloadType&&(this._seiPayloadType=t.seiPayloadType),this._seiMessageList.push(e),(null==(r=null==(i=this._singlePC.getPeerConnection())?void 0:i.getSenders()[2])?void 0:r.track)&&this._smallSeiMessageList.push(e)}hasSEI(e){let t=new DataView(e);return 1===t.getInt32(0)&&6===t.getInt8(4)}isEmptyFrame(e){return"empty"===e.type||0===e.data.byteLength}getNaluCount(e){let t=0,i=0,r=new DataView(e);for(let n=0;n<e.byteLength;n++)switch(r.getUint8(n)){case 0:t++;break;case 1:(2===t||3===t)&&i++,t=0;break;default:t=0}return i}encodeVideoFrame(e,t,i){try{let t=2===Number(i.mid)?this._smallSeiMessageList:this._seiMessageList;if(this._singlePC.isUsingH264&&t.length>0&&!this.isEmptyFrame(e)){let i=9-this.getNaluCount(e.data);if(i<=0)return;let r=t.splice(0,i).reverse().map(this.encodeSEINalu.bind(this)),n=r.reduce(((e,t)=>e+t.dataView.byteLength),0),o=new ArrayBuffer(n+e.data.byteLength),s=new DataView(o),a=new DataView(e.data),c=0;for(let e=0;e<r.length;e++)for(let t=0;t<r[e].dataView.byteLength;t++)s.setInt8(c++,r[e].dataView.getInt8(t));for(let t=0;t<e.data.byteLength;t++)s.setInt8(c++,a.getInt8(t));e.data=o,this._log.debug("".concat(r.length," sei sent"))}}catch(r){this._log.warn(r)}t.enqueue(e)}decodeVideoFrame(e,t,i){try{if(this._singlePC.isUsingH264&&!this.isEmptyFrame(e)&&this.hasSEI(e.data)){let t=[],r=new DataView(e.data),n=0,o=-1,s=-1;for(let i=0;i<e.data.byteLength;i++){let a=r.getUint8(i);if(0===a)n++;else if(1===a){if(2===n||3===n){let a=i-n;if(-1===o?o=a:-1===s&&(s=a,t.push(new xU(new DataView(r.buffer.slice(o,s)))),o=a,s=-1),6!==r.getUint8(i+1)){e.data=new DataView(r.buffer.slice(a)).buffer;break}}n=0}else n=0}this._log.debug("".concat(t.length," sei received")),ND(this.onSEIMessage)&&t.reverse().forEach((e=>{let t=Number(i.mid);this.onSEIMessage({seiPayloadType:e.seiPayloadType,data:e.seiPayload.buffer,mid:t,streamType:(t-4)%3==2?"auxiliary":"main"})}))}}catch(r){this._log.warn(r)}t.enqueue(e)}encodeSEINalu(e){let t=e.byteLength,i=parseInt(String(t/255),10),r=t%255,n=[];n.push(0,0,0,1,6,this._seiPayloadType);for(let s=0;s<i;s++)n.push(255);n.push(r);let o=new DataView(e);return n.push(...new Uint8Array(o.buffer)),n.push(128),new xU(new DataView(new Uint8Array(n).buffer),!0)}},UU=((yU=UU||{}).TRACK="track",yU.DATA_CHANNEL_MESSAGE="data_channel_msg",yU[yU.CONNECTION_STATE_CHANGED="connection-state-changed"]="CONNECTION_STATE_CHANGED",yU[yU.FIREWALL_RESTRICTION="firewall-restriction"]="FIREWALL_RESTRICTION",yU.RECONNECTED="spc-reconnected",yU.RECONNECT_FAILED="spc-reconnect-failed",yU.ERROR="error",yU.SEI_MESSAGE="sei-message",yU),BU=0,FU=!1,HU=new Set,jU=1,WU=class extends NU.default{constructor(e){let{signalChannel:t,room:i,enableCustomMessage:r}=e;super(),tC(this,"stat",{iceStartTime:0,iceEndTime:0,dtlsStartTime:0,dtlsEndTime:0,peerConnectionStartTime:0,peerConnectionEndTime:0}),tC(this,"currentState","DISCONNECTED"),tC(this,"_room"),tC(this,"_signalChannel"),tC(this,"_peerConnection",null),tC(this,"_datachannel",null),tC(this,"_enableCustomMessage"),tC(this,"_log"),tC(this,"_downlinkMIDMap",new Map),tC(this,"_downlinkMIDUserIDMap",new Map),tC(this,"_reconnectionTimer",-1),tC(this,"reconnectionCount",0),tC(this,"_clientAbility",null),tC(this,"_serverAbility",null),tC(this,"addDownlinkQueue",new Set),tC(this,"removeDownlinkQueue",new Set),tC(this,"_parsedAnswer",null),tC(this,"_updateSDPPromise",null),tC(this,"_waitForPCConnectedPromise"),tC(this,"_waitForPCConnectedPromiseReject",null),tC(this,"_isSDPLogged",!1),tC(this,"seiCodec",null),this._room=i,this._enableCustomMessage=r,this._signalChannel=t,this._log=EO.createLogger({id:"spc".concat(jU++),userId:this._room.userId,sdkAppId:this._room.sdkAppId}),this._room.enableSEI&&tL&&(this._log.info("create sei codec"),this.seiCodec=new VU(this,this._log),this.seiCodec.onSEIMessage=e=>{this.emit("sei-message",{userId:this._downlinkMIDUserIDMap.get(e.mid),data:e.data,seiPayloadType:e.seiPayloadType,streamType:e.streamType})})}get isH264EncodeSupported(){let e=this._room.checkSystemResult.detail.isH264EncodeSupported;return this._serverAbility&&(e=e&&!!this._serverAbility.video.codecs.find((e=>"h264"===e.codec.toLowerCase()))),e}get isVP8EncodeSupported(){let e=this._room.checkSystemResult.detail.isVp8EncodeSupported;return this._serverAbility&&(e=e&&this._serverAbility.useVp8),e}get videoCodec(){var e;return null!=(e=this._serverAbility)&&e.useVp8?"vp8":"h264"}get isUsingH264(){return"h264"===this.videoCodec}get uplinkSSRC(){return this._peerConnection&&this._peerConnection.localDescription?(e=>{let t=VV(e),i={audioSsrc:0,audioRtxSsrc:0,bigVideoSsrc:0,bigVideoRtxSsrc:0,smallVideoSsrc:0,smallVideoRtxSsrc:0,auxVideoSsrc:0,auxVideoRtxSsrc:0};return t.media.forEach(((e,t)=>{var r;if(e.ssrcs&&!DD(e.ssrcs[0].id)){let n=Number(e.ssrcs[0].id),o=Number(null==(r=e.ssrcs.filter((e=>"cname"===e.attribute))[1])?void 0:r.id);switch(t){case 0:i.audioSsrc=n;break;case 1:i.bigVideoSsrc=n,i.bigVideoRtxSsrc=o;break;case 2:i.smallVideoSsrc=n,i.smallVideoRtxSsrc=o;break;case 3:i.auxVideoSsrc=n,i.auxVideoRtxSsrc=o}}})),i})(this._peerConnection.localDescription.sdp):{audioSsrc:0,audioRtxSsrc:0,bigVideoSsrc:0,bigVideoRtxSsrc:0,smallVideoSsrc:0,smallVideoRtxSsrc:0,auxVideoSsrc:0,auxVideoRtxSsrc:0}}get isReconnecting(){return"RECONNECTING"===this.currentState||this._reconnectionTimer>0||this.reconnectionCount>0}get dtlsTransport(){if(!this._peerConnection)return null;let e=this._peerConnection.getSenders();return 0===e.length?null:e[0].transport}initialize(){return rC(this,null,(function*(){try{this._peerConnection=new RTCPeerConnection({encodedInsertableStreams:this._room.enableSEI&&tL,offerExtmapAllowMixed:!0,iceServers:this._room.getIceServers(),iceTransportPolicy:this._room.getIceTransportPolicy(),sdpSemantics:this._room.sdpSemantics,bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",tcpCandidatePolicy:"disable",IceTransportsType:"nohost"}),this._peerConnection.oniceconnectionstatechange=()=>{if(!this._peerConnection)return;let e=this._peerConnection.iceConnectionState;this._log.debug("ice state: ".concat(e)),"checking"===e&&0===this.stat.iceStartTime?this.stat.iceStartTime=Date.now():"connected"===e&&0===this.stat.iceEndTime&&(this.stat.iceEndTime=Date.now())},this._peerConnection.onconnectionstatechange=this.onConnectionStateChange.bind(this),this._peerConnection.ontrack=e=>this.emit("track",e),this._enableCustomMessage&&(this._datachannel=this._peerConnection.createDataChannel("".concat(this._room.userId,"dc")),this._datachannel.binaryType="arraybuffer",this._datachannel.onopen=()=>{this._log.info("datachannel open")},this._datachannel.onclose=()=>{this._log.warn("datachannel close")},this._datachannel.onmessage=e=>{let t=new GU(e.data);this.emit("data_channel_msg",{data:t})},this._datachannel.onerror=e=>{this._log.warn("datachannel error",e)}),this._peerConnection.addTransceiver(Mw.AUDIO,{direction:Mw.TRANSCEIVER_DIRECTION_SENDONLY}),this._peerConnection.addTransceiver(Mw.VIDEO,{direction:Mw.TRANSCEIVER_DIRECTION_SENDONLY}),this._peerConnection.addTransceiver(Mw.VIDEO,{direction:Mw.TRANSCEIVER_DIRECTION_SENDONLY}),this._peerConnection.addTransceiver(Mw.VIDEO,{direction:Mw.TRANSCEIVER_DIRECTION_SENDONLY});let e=yield this._peerConnection.createOffer();return yield this.setOffer(e),this.dtlsTransport&&(this.dtlsTransport.onstatechange=()=>{let{dtlsTransport:e}=this;!e||(this._log.debug("dtls state: ".concat(e.state)),"connecting"===e.state&&0===this.stat.dtlsStartTime?this.stat.dtlsStartTime=Date.now():"connected"===e.state&&0===this.stat.dtlsEndTime&&(this.stat.dtlsEndTime=Date.now()))}),this._clientAbility=((e,t)=>{var i,r;let n=VV(e),o={ice:{ufrag:"",password:""},dtls:{hash:"",fingerprint:"",setup:""},audio:{codecs:[],extensions:[]},video:{codecs:[],extensions:[]},useDataChannel:t};o.ice.ufrag=String(n.media[0].iceUfrag),o.ice.password=n.media[0].icePwd||"",n.fingerprint&&(o.dtls.hash=n.fingerprint.type,o.dtls.fingerprint=n.fingerprint.hash,o.dtls.setup=n.setup||""),n.media[0].fingerprint&&(o.dtls.hash=n.media[0].fingerprint.type,o.dtls.fingerprint=n.media[0].fingerprint.hash),o.dtls.setup=n.media[0].setup||"";let s=n.media[0],a=n.media[1];s.ext&&(o.audio.extensions=s.ext.map((e=>({id:e.value,uri:e.uri})))),a.ext&&(o.video.extensions=a.ext.map((e=>({id:e.value,uri:e.uri}))));let c={codec:s.rtp[0].codec,fmtp:s.fmtp[0].config,payload:s.fmtp[0].payload,rate:s.rtp[0].rate,channel:s.rtp[0].encoding,rtcpFb:[],rtx:0};null==(i=s.rtcpFb)||i.forEach((e=>{let{payload:t,type:i,subtype:r}=e;if(t===c.payload){let e={id:i,params:[]};r&&e.params.push(r),c.rtcpFb.push(e)}})),o.audio.codecs.push(c);for(let l=0;l<a.rtp.length;l++){if(["rtx","red","ulpfec"].includes(a.rtp[l].codec))continue;let e=a.fmtp.filter((e=>e.payload===a.rtp[l].payload))[0];o.video.codecs.push({payload:a.rtp[l].payload,codec:a.rtp[l].codec,fmtp:e?e.config:"",rate:a.rtp[l].rate,rtx:"rtx"===(null==(r=a.rtp[l+1])?void 0:r.codec)?a.rtp[l+1].payload:0,rtcpFb:((null==a?void 0:a.rtcpFb)||[]).filter((e=>e.payload===a.rtp[l].payload)).map((e=>{let{type:t,subtype:i}=e;return{id:t,params:i?[i]:[]}}))})}return o})(e.sdp,this._enableCustomMessage),this._clientAbility}catch(e){throw this._log.error("initialize failed ".concat(e)),e}}))}connect(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return rC(this,null,(function*(){var i;try{if("CONNECTED"===this.currentState)return;let r=zD(),n={type:"answer",sdp:OU({serverAbility:e,clientAbility:this._clientAbility,offerSDP:this._peerConnection.localDescription.sdp,enableCustomMessage:this._enableCustomMessage})};this._serverAbility=e,yield this.setAnswer(n),yield this.waitForPeerConnectionConnected(),t||pP.addSuccessEvent({key:521703,cost:zD()-r}),null==(i=this.seiCodec)||i.handleEncodedStreams()}catch(r){let t=r instanceof fC&&r.code===_C.API_CALL_ABORTED;throw t||this._log.error("connect failed: ".concat(r),e),this.reset(),!t&&!this.isReconnecting&&(pP.addFailedEvent({key:521703,error:r}),this.emitConnectionStateChangedEvent("DISCONNECTED"),this.startReconnection()),r}}))}reconnect(){return rC(this,null,(function*(){if(-1===this._reconnectionTimer){if(!this._signalChannel.isConnected)return this._log.warn("reconnect() wait signal channel is connected"),void this._signalChannel.once(Jx,this.reconnect,this);try{this.reconnectionCount++,this._log.warn("reconnect() trying [".concat(this.reconnectionCount,"]")),this.reset();let e=yield this.initialize(),t=yield this._signalChannel.sendWaitForResponse({command:vV,responseCommand:Zx.REBUILD_PEER_CONNECTION_RES,data:{ability:e},enableLog:!1});if(0!==t.data.code)throw new fC({code:t.data.code,message:t.data.message});yield this.connect(t.data.data.ability,!0),pP.addSuccessEvent({key:521704}),this._log.warn("reconnect() success"),this.stopReconnection(),JN.emit(fO.SPC_RECONNECTED,{room:this._room}),this.emit("spc-reconnected")}catch(e){if(!this.isReconnecting)return;if(null!=e&&e.message.includes("timeout")){let e=kD(this.reconnectionCount);this._log.warn("reconnect() timeout, try again after ".concat(e/1e3,"s")),this._reconnectionTimer=window.setTimeout((()=>{this.clearReconnectionTimer(),this.reconnect()}),e)}else this._log.error("reconnect() failed ".concat(null==e?void 0:e.code," ").concat(e)),pP.addFailedEvent({key:521704,error:e}),this.reconnectionCount>=sN()&&this._log.warn("SDK has tried reconnect for ".concat(sN()," times, but all failed, please check your network")),this.stopReconnection(),this.emitConnectionStateChangedEvent("DISCONNECTED"),this.emit("error")}}else this._log.warn("reconnect() is reconnecting, ignore current reconnection")}))}getPeerConnection(){return this._peerConnection}startReconnection(){return rC(this,null,(function*(){this._log.warn("start reconnect"),this.emitConnectionStateChangedEvent("RECONNECTING"),yield this.reconnect()}))}stopReconnection(){this.isReconnecting&&(this._log.info("stop reconnect"),this.reconnectionCount=0,this.clearReconnectionTimer(),this._signalChannel.off(Jx,this.reconnect,this))}checkPeerConnectionToReconnect(){var e;!this.isReconnecting&&(null==(e=this._peerConnection)?void 0:e.connectionState)===rN.CLOSED&&this.startReconnection()}clearReconnectionTimer(){-1!==this._reconnectionTimer&&(clearTimeout(this._reconnectionTimer),this._reconnectionTimer=-1)}onConnectionStateChange(e){let t=this._peerConnection.iceConnectionState,i=this.getDTLSTransportState();this._log.info("connectionState: ".concat(e.target.connectionState," ICE: ").concat(t," DTLS: ").concat(i)),e.target.connectionState===rN.CONNECTING&&(0===this.stat.peerConnectionStartTime&&(this.stat.peerConnectionStartTime=Date.now()),this.emitConnectionStateChangedEvent("CONNECTING")),(e.target.connectionState===rN.FAILED||e.target.connectionState===rN.CLOSED)&&(this.emitConnectionStateChangedEvent("DISCONNECTED"),this.startReconnection()),(e.target.connectionState===rN.CONNECTED||e.target.connectionState===rN.COMPLETED)&&(0===this.stat.peerConnectionEndTime&&(this.stat.peerConnectionEndTime=Date.now()),JN.emit(fO.SINGLE_CONNECTION_STAT,{room:this._room,stat:{ice:this.stat.iceEndTime-this.stat.iceStartTime,dtls:this.stat.dtlsEndTime-this.stat.dtlsStartTime,peerConnection:this.stat.peerConnectionEndTime-this.stat.peerConnectionStartTime}}),this.logSelectedCandidate(),this.emitConnectionStateChangedEvent("CONNECTED"))}getDTLSTransportState(){if(!this._peerConnection)return iN;let e=null;return KO()&&0!==this._peerConnection.getSenders().length?(e=this._peerConnection.getSenders()[0].transport,GO()&&0!==this._peerConnection.getReceivers().length&&e?e.state:iN):iN}emitConnectionStateChangedEvent(e){e!==this.currentState&&("RECONNECTING"===this.currentState&&"CONNECTING"===e||(this.emit(UU.CONNECTION_STATE_CHANGED,{prevState:this.currentState,state:e}),this.currentState=e))}logSelectedCandidate(){return rC(this,null,(function*(){if(!this._peerConnection)return;let e=yield this._peerConnection.getStats();for(let[t,i]of e)if(UO(i)){let t=e.get(i.localCandidateId),r=e.get(i.remoteCandidateId);t&&(this._log.info("local candidate: ".concat(t.candidateType," ").concat(t.protocol,":").concat(t.ip||t.address,":").concat(t.port," ").concat(t.networkType||""," ").concat("relay"===t.candidateType?"relayProtocol:".concat(t.relayProtocol):"")),t.networkType&&fD(t.networkType)),r&&this._log.info("remote candidate: ".concat(r.candidateType," ").concat(r.protocol,":").concat(r.ip||r.address,":").concat(r.port));break}}))}waitForPeerConnectionConnected(){return this._waitForPCConnectedPromise||(this._waitForPCConnectedPromise=new Promise(((e,t)=>{if("CONNECTED"===this.currentState)return e();this._waitForPCConnectedPromiseReject=t;let i=t=>{"CONNECTED"===t.state&&(clearTimeout(o),n(),e())},r=e=>{let{room:i}=e;i===this._room&&(clearTimeout(o),n(),t(new fC({code:_C.API_CALL_ABORTED,message:GN({key:HN.CONNECTION_ABORTED,data:"leave room"})})))},n=()=>{JN.off(fO.LEAVE_SUCCESS,r,this),this.off(UU.CONNECTION_STATE_CHANGED,i,this)},o=setTimeout((()=>{n();let e=new fC({code:_C.API_CALL_TIMEOUT,message:"connection timeout"});var i;BU+=1,i=this._signalChannel.isConnected,BU>2&&!FU&&0===HU.size&&i&&(this._log.warn("firewall restrition"),FU=!0,this.emit(UU.FIREWALL_RESTRICTION)),t(e)}),TN);JN.on(fO.LEAVE_SUCCESS,r,this),this.on(UU.CONNECTION_STATE_CHANGED,i,this)})),this._waitForPCConnectedPromise=this._waitForPCConnectedPromise.finally((()=>{this._waitForPCConnectedPromise=null,this._waitForPCConnectedPromiseReject=null}))),this._waitForPCConnectedPromise}waitForReconnected(){return this.isReconnecting?new Promise(((e,t)=>{this.once("spc-reconnected",e),this.once("error",t)})):Promise.resolve()}addDownlink(e){return rC(this,null,(function*(){var t;if(this._log.info("addDownlink(".concat(e.userId,") trying")),this.isReconnecting&&(yield this.waitForReconnected()),this._updateSDPPromise&&(yield this._updateSDPPromise),this.updateLocalAndRemoteSDPConfig(e),0===this.addDownlinkQueue.size)try{yield this.updateSDP(),null==(t=this.seiCodec)||t.handleEncodedStreams(),this._log.info("addDownlink(".concat(e.userId,") done"))}catch(i){this._log.info("addDownlink(".concat(e.userId,") failed")),yield this.startReconnection()}}))}updateLocalAndRemoteSDPConfig(e){let{ssrc:t,userId:i,tinyId:r}=e;if(!this._peerConnection)return;this._log.info("updateLocalAndRemoteSDPConfig ".concat(i," ").concat(JSON.stringify(t)));let n,o,s,a=this._peerConnection.getTransceivers().filter((e=>"inactive"===e.direction)).slice(0,3).map((e=>(e.direction=Mw.TRANSCEIVER_DIRECTION_RECVONLY,Number(e.mid))));if(0===a.length&&(this._peerConnection.addTransceiver(Mw.AUDIO,{direction:Mw.TRANSCEIVER_DIRECTION_RECVONLY}),this._peerConnection.addTransceiver(Mw.VIDEO,{direction:Mw.TRANSCEIVER_DIRECTION_RECVONLY}),this._peerConnection.addTransceiver(Mw.VIDEO,{direction:Mw.TRANSCEIVER_DIRECTION_RECVONLY})),this._parsedAnswer||(this._parsedAnswer=VV(this._peerConnection.remoteDescription.sdp)),3===a.length)n=this._parsedAnswer.media.find((e=>Number(e.mid)===Number(a[0]))),o=this._parsedAnswer.media.find((e=>Number(e.mid)===Number(a[1]))),s=this._parsedAnswer.media.find((e=>Number(e.mid)===Number(a[2])));else{n=JSON.parse(JSON.stringify(this._parsedAnswer.media[0]));let e=LU({mid:1,serverAbility:this._serverAbility,clientAbility:this._clientAbility,parsedOffer:VV(this._peerConnection.localDescription.sdp),useAllCodec:!0});o=JSON.parse(JSON.stringify(e)),s=JSON.parse(JSON.stringify(e)),n.mid=this._parsedAnswer.media.length,this._parsedAnswer.media.push(n),o.mid=this._parsedAnswer.media.length,this._parsedAnswer.media.push(o),s.mid=this._parsedAnswer.media.length,this._parsedAnswer.media.push(s)}n.direction=Mw.TRANSCEIVER_DIRECTION_SENDONLY,n.ssrcs=[{id:t.audio,attribute:"cname",value:"".concat(r)},{id:t.audio,attribute:"msid",value:"".concat(r,"-").concat(Mw.MAIN," ").concat(r,"-audio")}],o.direction=Mw.TRANSCEIVER_DIRECTION_SENDONLY,o.ssrcs=[{id:t.video,attribute:"cname",value:"".concat(r)},{id:t.video,attribute:"msid",value:"".concat(r,"-").concat(Mw.MAIN," ").concat(r,"-bigvideo")},{id:t.videoRtx,attribute:"cname",value:"".concat(r)},{id:t.videoRtx,attribute:"msid",value:"".concat(r,"-").concat(Mw.MAIN," ").concat(r,"-bigvideo")}],o.ssrcGroups=[{semantics:"FID",ssrcs:"".concat(t.video," ").concat(t.videoRtx)}],s.direction=Mw.TRANSCEIVER_DIRECTION_SENDONLY;let c="".concat(r,"-aux");s.ssrcs=[{id:t.auxiliary,attribute:"cname",value:c},{id:t.auxiliary,attribute:"msid",value:"".concat(c," ").concat(r,"-aux").concat(Mw.VIDEO)},{id:t.auxiliaryRtx,attribute:"cname",value:"".concat(c," ").concat(r,"-aux").concat(Mw.VIDEO)},{id:t.auxiliaryRtx,attribute:"msid",value:"".concat(c," ").concat(r,"-aux").concat(Mw.VIDEO)}],s.ssrcGroups=[{semantics:"FID",ssrcs:"".concat(t.auxiliary," ").concat(t.auxiliaryRtx)}],this._parsedAnswer.groups&&(this._parsedAnswer.groups[0].mids=this._parsedAnswer.media.map((e=>e.mid)).join(" ")),this._downlinkMIDMap.set(i,[n.mid,o.mid,s.mid]),this._downlinkMIDUserIDMap.set(n.mid,i),this._downlinkMIDUserIDMap.set(o.mid,i),this._downlinkMIDUserIDMap.set(s.mid,i)}removeDownlink(e,t){return rC(this,null,(function*(){if(!this._downlinkMIDMap.has(t)||!this._peerConnection)return;this._log.info("removeDownlink(".concat(t,") trying")),this.isReconnecting&&(yield this.waitForReconnected()),this._updateSDPPromise&&(yield this._updateSDPPromise);let e=this._downlinkMIDMap.get(t),i=!1;this._peerConnection.getTransceivers().forEach((t=>{null!=e&&e.includes(Number(t.mid))&&(i=!0,t.direction="inactive")})),this._parsedAnswer||(this._parsedAnswer=VV(this._peerConnection.remoteDescription.sdp)),this._parsedAnswer.media.forEach((t=>{null!=e&&e.includes(Number(t.mid))&&(i=!0,t.direction="inactive",t.ssrcs=[],t.ssrcGroups=[])})),0===this.removeDownlinkQueue.size&&i&&(yield this.updateSDP()),this._downlinkMIDMap.delete(t),null==e||e.forEach((e=>this._downlinkMIDUserIDMap.delete(e))),this._log.info("removeDownlink(".concat(t,") done"))}))}setBandwidth(e){return rC(this,null,(function*(){if(!this._peerConnection)return;let{audio:t,bigVideo:i,smallVideo:r,auxVideo:n}=e;try{if(ZO()){let e=this._peerConnection.getSenders().slice(0,4);for(let s=0;s<e.length;s++){let o,a=e[s];0===s&&t?o=t:1===s&&i?o=i:2===s&&r?o=r:3===s&&n&&(o=n),o&&(yield this.setSenderMaxBitrate(a,o))}let o=!1;i&&e[1].track&&(o=this.setStartBitrate(1,i)),n&&e[3].track&&(o=this.setStartBitrate(3,n)||o),o&&(yield this.updateSDP())}else yield this.setBandwidthBySDP(e);this._log.info("setBandwidth ".concat(JSON.stringify(e)))}catch(o){this._log.error("failed to set bandwidth".concat(o))}}))}setStartBitrate(e,t){var i,r;return!(null==(i=this._peerConnection)||!i.remoteDescription||(this._parsedAnswer||(this._parsedAnswer=VV(this._peerConnection.remoteDescription.sdp)),null==(r=this._parsedAnswer.media[e])||!r.fmtp[0])||(this._parsedAnswer.media[e].fmtp[0].config+=";x-google-start-bitrate=".concat(t>5e3?5e3:t),0))}setSenderMaxBitrate(e,t){let i=e.getParameters();return(!i.encodings||0===i.encodings.length)&&(i.encodings=[{}]),"unlimited"===t?delete i.encodings[0].maxBitrate:i.encodings[0].maxBitrate=1e3*t,e.setParameters(i)}setBandwidthBySDP(e){let{audio:t,bigVideo:i,smallVideo:r,auxVideo:n}=e;if(!this._peerConnection||!this._peerConnection.localDescription)return;let o=VV(this._peerConnection.localDescription.sdp);this._parsedAnswer||(this._parsedAnswer=VV(this._peerConnection.remoteDescription.sdp));let s=BC?"TIAS":"AS";t&&(o.media[0].bandwidth=[{type:s,limit:BC?1e3*t:t}],this._parsedAnswer.media[0].bandwidth=[{type:s,limit:BC?1e3*t:t}]),i&&(o.media[1].bandwidth=[{type:s,limit:BC?1e3*i:i}],this._parsedAnswer.media[1].bandwidth=[{type:s,limit:BC?1e3*i:i}]),r&&(o.media[2].bandwidth=[{type:s,limit:BC?1e3*r:r}],this._parsedAnswer.media[2].bandwidth=[{type:s,limit:BC?1e3*r:r}]),n&&(o.media[3].bandwidth=[{type:s,limit:BC?1e3*n:n}],this._parsedAnswer.media[3].bandwidth=[{type:s,limit:BC?1e3*n:n}]);let a={type:"offer",sdp:UV(o)};return this.updateSDP({localDescription:a})}setScaleResolutionDownBy(e,t){if(1===t)return;let i=e.getParameters();return(!i.encodings||0===i.encodings.length)&&(i.encodings=[{}]),i.encodings[0].scaleResolutionDownBy=t,e.setParameters(i)}updateSDP(){let{localDescription:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this._parsedAnswer)return Promise.resolve();let t=UV(this._parsedAnswer);return this._updateSDPPromise=new Promise(((i,r)=>rC(this,null,(function*(){var n,o;try{!e&&this._peerConnection&&(this._log.info("creating offer"),e=yield this._peerConnection.createOffer()),e&&(yield this.setOffer(e)),yield this.setAnswer({type:"answer",sdp:t}),this._updateSDPPromise=null,i()}catch(s){this._log.error(s),!this._isSDPLogged&&this._peerConnection&&(this._log.warn("current offer: ".concat(this.filterSDPDirection(null==(n=this._peerConnection.localDescription)?void 0:n.sdp)," \nnext offer: ").concat(this.filterSDPDirection(null==e?void 0:e.sdp))),this._log.warn("current answer: ".concat(this.filterSDPDirection(null==(o=this._peerConnection.remoteDescription)?void 0:o.sdp)," \nnext answer: ").concat(this.filterSDPDirection(t))),this._log.warn("transceivers: ".concat(JSON.stringify(this._peerConnection.getTransceivers().map((e=>{let{mid:t,currentDirection:i,direction:r,stopped:n}=e;return{mid:t,currentDirection:i,direction:r,stopped:n}}))))),this._log.warn("parsedAnswer: ".concat(JSON.stringify(this._parsedAnswer))),this._isSDPLogged=!0),this._updateSDPPromise=null,r(s)}})))),this._updateSDPPromise}filterSDPDirection(){return VV(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").media.map((e=>e.direction))}setOffer(e){return this._log.info("setting offer"),this._peerConnection.setLocalDescription({type:"offer",sdp:MU(e.sdp)})}setAnswer(e){return this._log.info("setting answer"),this._room.enableHWEncoder&&e.sdp&&(e.sdp=e.sdp.replaceAll("42e01f","42001f")),this._peerConnection.setRemoteDescription(e)}sendDataChannelMessage(e){var t;null==(t=this._datachannel)||t.send(e)}reset(){var e;null==(e=this._peerConnection)||e.close(),this._waitForPCConnectedPromise=null,this._parsedAnswer=null}close(){this._log.info("close pc"),this.reset(),this.emitConnectionStateChangedEvent("DISCONNECTED"),this._downlinkMIDMap.clear(),this.stopReconnection(),this.removeAllListeners()}sendSEI(e,t){var i;null==(i=this.seiCodec)||i.push(e,t)}};eC([ZP("reconnect")],WU.prototype,"startReconnection",1),eC([QP()],WU.prototype,"updateSDP",1);var zU=class{constructor(e){tC(this,"tag"),tC(this,"len"),tC(this,"data");let t=new DataView(e);this.tag=t.getUint16(),this.len=t.getUint16(2),this.data=new Uint8Array(e).slice(4,4+this.len).buffer}},GU=class{constructor(e){tC(this,"tinyId"),tC(this,"data");let t=new DataView(e),i=0,r=[];for(;i<t.byteLength;){let n=t.getUint16(i+2),o=new zU(new Uint8Array(e).slice(i,i+2+2+n).buffer);r.push(o),i+=4+n}r.forEach((e=>{1===e.tag?this.tinyId=(new TextDecoder).decode(e.data):2===e.tag&&(this.data=e.data)}))}},KU=new Set;function YU(){let e=Math.floor(4294967296*Math.random());return KU.has(e)?YU():(KU.add(e),e)}var JU=$b(nC()),qU=class extends JU.default{constructor(e){super(),tC(this,"userId"),tC(this,"tinyId"),tC(this,"_sdpSemantics"),tC(this,"_isUplink"),tC(this,"_room"),tC(this,"_log"),tC(this,"_signalChannel"),tC(this,"_currentState","DISCONNECTED"),tC(this,"_prevTime",-1),tC(this,"_enableSEI"),tC(this,"_sei"),this.userId=e.userId,this.tinyId=e.tinyId,this._room=e.room,this._sdpSemantics=e.room.sdpSemantics,this._isUplink=e.isUplink,this._log=EO.createLogger({id:"n",userId:this._room.userId,remoteUserId:this._isUplink?void 0:this.userId,sdkAppId:this._room.sdkAppId,isLocal:this._isUplink}),this._signalChannel=e.signalChannel,this._enableSEI=e.enableSEI,this._enableSEI&&tL&&(this._sei=new VU(this,this._log,this._isUplink))}get _peerConnection(){var e;return(null==(e=this.singlePC)?void 0:e.getPeerConnection())||null}get singlePC(){return this._room.singlePC}close(e){this._log.info("close connection"),this.emit("closed",e),this._sei&&(this._sei.destroy(),this._sei=null)}emitConnectionStateChangedEvent(e){return e!==this._currentState&&(JN.emit(fO.PEER_CONNECTION_STATE_CHANGED,{room:this._room,prevState:this._currentState,state:e,remoteUserId:this._isUplink?void 0:this.userId}),this.emit("connection-state-changed",{prevState:this._currentState,state:e}),this._currentState=e,!0)}getPeerConnection(){return this._peerConnection}getRoom(){return this._room}getUserId(){return this.userId}getTinyId(){return this.tinyId}getCurrentState(){return this._currentState}get isH264(){var e,t;return!(null==(t=null==(e=this._peerConnection)?void 0:e.remoteDescription)||!t.sdp.includes("H264"))}},XU=class extends qU{constructor(e){super(Xb(qb({},e),{isUplink:!0})),tC(this,"localMainAudioTrack",null),tC(this,"localMainVideoTrack",null),tC(this,"localAuxAudioTrack",null),tC(this,"localAuxVideoTrack",null),tC(this,"_isPublishingAux",!1),tC(this,"_publishingLocalAudioTrack"),tC(this,"_publishingLocalVideoTrack"),tC(this,"_mediaSettings",{videoCodec:"",videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioCodec:"opus",audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0,auxVideoWidth:0,auxVideoHeight:0,auxVideoFps:0,auxVideoBps:0}),tC(this,"_audioManager"),this._audioManager=e.audioManager,this.initialize()}get ssrc(){if(!this.singlePC)return{audio:0,video:0,videoRtx:0,small:0,smallRtx:0,auxiliary:0,auxiliaryRtx:0};let{audioSsrc:e,bigVideoSsrc:t,bigVideoRtxSsrc:i,smallVideoSsrc:r,smallVideoRtxSsrc:n,auxVideoSsrc:o,auxVideoRtxSsrc:s}=this.singlePC.uplinkSSRC;return{audio:e||0,video:t||0,videoRtx:i||0,small:r||0,smallRtx:n||0,auxiliary:o||0,auxiliaryRtx:s||0}}get isMainStreamPublished(){return!(!this.localMainAudioTrack&&!this.localMainVideoTrack)}get isAuxStreamPublished(){return!(!this.localAuxVideoTrack&&!this.localAuxAudioTrack)}get publishState(){var e,t,i,r;let n={audio:!1,bigVideo:!1,smallVideo:!1,auxVideo:!1};if(this._peerConnection){let o=this._peerConnection.getSenders();o&&(YO()?(n.audio=!(null==(e=o[0])||!e.track),n.bigVideo=!(null==(t=o[1])||!t.track),n.smallVideo=!(null==(i=o[2])||!i.track),n.auxVideo=!(null==(r=o[3])||!r.track)):o.forEach((e=>{e.track&&(e.track.kind===Mw.AUDIO?n.audio=!0:(n.bigVideo=!0,this._room.videoManager.hasSmall&&(n.smallVideo=!0)))})))}return n}get muteState(){var e,t,i;return{audio:!(null==(e=this.localMainAudioTrack)||!e.muted),bigVideo:!(null==(t=this.localMainVideoTrack)||!t.muted),auxVideo:!(null==(i=this.localAuxVideoTrack)||!i.muted)}}initialize(){this.installEvents()}reset(){this.uninstallEvents(),this.uninstallTrackMuteEvents(this.localMainAudioTrack,this.localMainVideoTrack,this.localAuxVideoTrack)}close(e){super.close(e),this.reset(),this.emitConnectionStateChangedEvent("DISCONNECTED")}installEvents(){var e;this.listeners("connection-state-changed").includes(this.handleConnectionStateChange)||this.on("connection-state-changed",this.handleConnectionStateChange,this),this.listeners("spc-reconnected").includes(this.onSinglePCReconnected)||null==(e=this.singlePC)||e.on("spc-reconnected",this.onSinglePCReconnected,this)}uninstallEvents(){var e;this.off("connection-state-changed",this.handleConnectionStateChange,this),null==(e=this.singlePC)||e.off("spc-reconnected",this.onSinglePCReconnected,this)}emitConnectionStateChangedEvent(e,t){var i,r,n;let o=this._currentState,s=super.emitConnectionStateChangedEvent(e);return s&&o!==e&&(t?t.emit("connection-state-changed",{prevState:o,state:e}):(null==(i=this.localMainVideoTrack)||i.emit("connection-state-changed",{prevState:o,state:e}),null==(r=this.localAuxVideoTrack)||r.emit("connection-state-changed",{prevState:o,state:e}),null==(n=this._publishingLocalVideoTrack)||n.emit("connection-state-changed",{prevState:o,state:e}))),s}publish(e){return rC(this,arguments,(function(e){var t=this;let{localAudioTrack:i,localVideoTrack:r,isAuxiliary:n}=e;return function*(){var e,o,s,a,c,l,d;if(!t.singlePC)return;yield t.singlePC.waitForPeerConnectionConnected();let u,{publishState:h,muteState:p}=t;if(i&&(t._publishingLocalAudioTrack=i,h.audio=!0,p.audio=i.muted),r){if(!t.singlePC.isH264EncodeSupported&&!t.singlePC.isVP8EncodeSupported)throw new fC({code:_C.NOT_SUPPORTED_H264,message:GN({key:HN.NOT_SUPPORTED_H264ENCODE})});MC&&115===Lk()&&r.profile.width*r.profile.height<=230400&&(t._log.warn("fallback video to 480p"),r.setProfile(Lw["480p_2"]),yield r.applyProfile()),t._publishingLocalVideoTrack=r,n?(h.auxVideo=!0,p.auxVideo=r.muted):(h.bigVideo=!0,p.bigVideo=r.muted)}if(t._isPublishingAux=n,r&&!n&&r.small&&(u=t._room.videoManager.smallTrack,h.smallVideo=!0),t._signalChannel.once(Zx.SERVER_PUBLISH_RESULT,(e=>{let o={audio:!(null==i||!i.mediaTrack),bigVideo:!1,smallVideo:!!u,auxVideo:!1};o[n?"auxVideo":"bigVideo"]=!(null==r||!r.mediaTrack);let s=Object.keys(o).find((t=>o[t]!==e.data.data[t]));s&&(t._log.warn("publish state not matched, ".concat(s," local:").concat(o[s]," server:").concat(e.data.data[s]," ").concat(iw())),pP.addCount({key:521e3}))})),yield t._signalChannel.sendWaitForResponse({command:TV,responseCommand:Zx.SPC_PUBLISH_RESULT,data:Xb(qb({},t.singlePC.uplinkSSRC),{state:h,muteState:p})}),yield t.publishByTransceiver({localAudioTrack:i,localVideoTrack:r,smallTrack:u,isAuxiliary:n}),null==(e=t.singlePC.seiCodec)||e.handleEncodedStreams(),t._publishingLocalAudioTrack=null,t._publishingLocalVideoTrack=null,t._isPublishingAux=!1,n)r&&(t.localAuxVideoTrack=r),i&&(t.localAuxAudioTrack=i);else{if(r){t.localMainVideoTrack=r;let{scaleResolutionDownBy:e}=r;e>1&&(t._log.warn("setScaleResolutionDownBy main ".concat(e)),yield t.singlePC.setScaleResolutionDownBy(t._peerConnection.getSenders()[1],e))}i&&(t.localMainAudioTrack=i)}yield t.singlePC.setBandwidth({audio:(null==(o=t.localMainAudioTrack)?void 0:o.profile.bitrate)||(null==(s=t.localAuxAudioTrack)?void 0:s.profile.bitrate),bigVideo:null==(a=t.localMainVideoTrack)?void 0:a.profile.bitrate,smallVideo:null==(l=null==(c=t.localMainVideoTrack)?void 0:c.small)?void 0:l.bitrate,auxVideo:null==(d=t.localAuxVideoTrack)?void 0:d.profile.bitrate}),t.sendMediaSettings(),t.installTrackMuteEvents(i,r)}()}))}publishByTransceiver(e){let{localAudioTrack:t,localVideoTrack:i,smallTrack:r,isAuxiliary:n}=e;if(!JO())return;this._log.info("publish by transceiver");let o=null==i?void 0:i.outMediaTrack,s=null==t?void 0:t.outMediaTrack,a=this._peerConnection.getTransceivers(),c=[],l=[];if(s){let e=a[0].sender.replaceTrack(s);l.push(0),c.push(e)}if(o)if(n){let e=a[3].sender.replaceTrack(o);l.push(3),c.push(e)}else{let e=a[1].sender.replaceTrack(o);l.push(1),c.push(e)}if(r){let e=a[2].sender.replaceTrack(r);l.push(2),c.push(e)}let d=this.setTransceiverDirection(xw.SENDONLY,l);return c.push(d),Promise.all(c)}enableSmall(e){return rC(this,null,(function*(){if(!this.singlePC)return;let t=this._peerConnection.getTransceivers();e?this._room.videoManager.smallTrack&&(yield t[2].sender.replaceTrack(this._room.videoManager.smallTrack),yield this.setTransceiverDirection(xw.SENDONLY,[2])):(yield t[2].sender.replaceTrack(null),yield this.setTransceiverDirection(xw.INACTIVE,[2])),this.updateMediaSettings(),yield this.doPublishChange()}))}installTrackMuteEvents(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];t.forEach((e=>{e&&(null==e||e.on("mute",this.sendMutedFlag,this),null==e||e.on("unmute",this.sendMutedFlag,this))}))}uninstallTrackMuteEvents(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];t.forEach((e=>{e&&(null==e||e.off("mute",this.sendMutedFlag,this),null==e||e.off("unmute",this.sendMutedFlag,this))}))}unpublish(e){return rC(this,arguments,(function(e){var t=this;let{localAudioTrack:i,localVideoTrack:r}=e;return function*(){let e=r&&r===t.localAuxVideoTrack,n=null==r?void 0:r.outMediaTrack,o=t._peerConnection.getSenders(),s=[];i&&(yield o[0].replaceTrack(null),s.push(0),e?t.localAuxAudioTrack=null:t.localMainAudioTrack=null),n&&(e?(yield o[3].replaceTrack(null),t.localAuxVideoTrack=null,t._mediaSettings=Xb(qb({},t._mediaSettings),{auxVideoBps:0,auxVideoFps:0,auxVideoWidth:0,auxVideoHeight:0}),s.push(3)):(yield o[1].replaceTrack(null),yield o[2].replaceTrack(null),t.localMainVideoTrack=null,t._mediaSettings=Xb(qb({},t._mediaSettings),{videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0}),s.push(1,2))),t.isMainStreamPublished||t.isAuxStreamPublished?(yield t.setTransceiverDirection(xw.INACTIVE,s),yield t.doPublishChange(!1)):yield t.doUnpublish(),t.uninstallTrackMuteEvents(i,r),null==r||r.emit("connection-state-changed",{prevState:t._currentState,state:"DISCONNECTED"})}()}))}doPublishChange(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return rC(this,null,(function*(){let t={state:this.publishState,constraintConfig:this._mediaSettings},i=yield this._signalChannel.sendWaitForResponse({command:oV,data:t,responseCommand:Zx.PUBLISH_STATE_CHANGE_RESULT,enableLog:e});this.checkPublishResultCode(i.data.code,i.data.message)}))}doUnpublish(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this._signalChannel.sendWaitForResponse({command:sV,commandDesc:"unpublish",responseCommand:Zx.UNPUBLISH_RESULT,enableLog:e}).catch((e=>{if(e.getCode()===_C.API_CALL_TIMEOUT)return Promise.resolve();throw e}))}updateMediaSettings(){let{detail:{isH264EncodeSupported:e,isVp8EncodeSupported:t}}=this._room.checkSystemResult;e?this._mediaSettings.videoCodec="H264":t&&(this._mediaSettings.videoCodec="VP8");let i=this._publishingLocalAudioTrack||this.localMainAudioTrack||this.localAuxAudioTrack,{localMainVideoTrack:r,localAuxVideoTrack:n}=this;if(this._publishingLocalVideoTrack&&(this._isPublishingAux?n=this._publishingLocalVideoTrack:r=this._publishingLocalVideoTrack),$O){if(i&&i.outMediaTrack){let e=i.outMediaTrack.getSettings();this._mediaSettings.audioChannel=e.channelCount||1,this._mediaSettings.audioBps=1e3*i.profile.bitrate,this._mediaSettings.audioFs=e.sampleRate||0}if(r&&r.outMediaTrack){let e=r.outMediaTrack.getSettings();this._mediaSettings.videoWidth=e.width||0,this._mediaSettings.videoHeight=e.height||0,this._mediaSettings.videoFps=e.frameRate||0,this._mediaSettings.videoBps=1e3*r.profile.bitrate,r.small&&(this._mediaSettings.smallVideoWidth=r.small.width,this._mediaSettings.smallVideoHeight=r.small.height,this._mediaSettings.smallVideoFps=r.small.frameRate,this._mediaSettings.smallVideoBps=1e3*r.small.bitrate)}if(n&&n.outMediaTrack){let e=n.outMediaTrack.getSettings();this._mediaSettings.auxVideoWidth=e.width||0,this._mediaSettings.auxVideoHeight=e.height||0,this._mediaSettings.auxVideoFps=e.frameRate||0,this._mediaSettings.auxVideoBps=1e3*n.profile.bitrate}}else i&&i.outMediaTrack&&(this._mediaSettings.audioChannel=i.profile.channelCount,this._mediaSettings.audioBps=1e3*i.profile.bitrate,this._mediaSettings.audioFs=i.profile.sampleRate),r&&r.outMediaTrack&&(this._mediaSettings.videoWidth=r.profile.width,this._mediaSettings.videoHeight=r.profile.height,this._mediaSettings.videoFps=r.profile.frameRate,this._mediaSettings.videoBps=1e3*r.profile.bitrate);this._log.info("updateMediaSettings: ".concat(JSON.stringify(this._mediaSettings)))}sendMediaSettings(){this.updateMediaSettings(),this._signalChannel.sendWaitForResponse({command:EV,data:this._mediaSettings,responseCommand:Zx.UPDATE_CONSTRAINT_CONFIG_RES}).then((e=>{0!==e.data.code&&this._log.warn(e.data.message)})).catch((()=>{}))}addTrack(e){return rC(this,null,(function*(){var t;if(!this._peerConnection)return;let i=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack;this._log.info("is adding ".concat(e.kind," track to current published local ").concat(i?Mw.AUXILIARY:Mw.MAIN," stream")),null==(t=this._sei)||t.handleEncodedStreams(),YO()&&(yield this.addTrackByTransceiver(e,i))}))}addTrackByTransceiver(e,t){return rC(this,null,(function*(){var i;if(!e.mediaTrack)return;let r=this._peerConnection.getTransceivers();if(e.kind===Mw.AUDIO)yield r[0].sender.replaceTrack(e.outMediaTrack);else{let n=t?3:1;yield r[n].sender.replaceTrack(e.outMediaTrack),1===n&&(null==(i=this.localMainVideoTrack)?void 0:i.small)&&(yield r[2].sender.replaceTrack(this._room.videoManager.smallTrack)),r[n].direction===xw.INACTIVE&&(yield this.setTransceiverDirection(xw.SENDONLY,[n]))}this.updateMediaSettings(),yield this.doPublishChange()}))}removeTrack(e){return rC(this,null,(function*(){if(!this._peerConnection)return;let t=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack;this._log.info("is removing ".concat(e.kind," track from current published local ").concat(t?Mw.AUXILIARY:Mw.MAIN," stream")),YO()&&(yield this.removeTrackByTransceiver(e,t))}))}removeTrackByTransceiver(e,t){return rC(this,null,(function*(){if(!e.mediaTrack)return;let i=this._peerConnection.getTransceivers();if(e.kind===Mw.AUDIO)yield i[0].sender.replaceTrack(null);else{let e=t?3:1;yield i[e].sender.replaceTrack(null),1===e&&this._room.videoManager.hasSmall&&(yield i[2].sender.replaceTrack(null)),yield this.setTransceiverDirection(xw.INACTIVE,[e])}this.updateMediaSettings(),yield this.doPublishChange()}))}setTransceiverDirection(e,t){return rC(this,null,(function*(){if(!BC)return;let i=!1,r=!1;this._log.info("setting transceiver ".concat(t.join(",")," direction to ").concat(e));let n=this._peerConnection.getTransceivers();if(t.forEach((t=>{n[t].direction!==e&&(n[t].direction=e,i=!0)})),i){this._log.info("updating offer");let e=yield this._peerConnection.createOffer();yield this._peerConnection.setLocalDescription(e)}let o=-1,s=this._peerConnection.remoteDescription.sdp.split("\r\n").map((i=>{if(i.match(new RegExp("a=(".concat(xw.INACTIVE,"|").concat(xw.RECVONLY,"|").concat(xw.SENDONLY,")")))&&o++,t.includes(o)){if(e===xw.INACTIVE&&i.includes("a=".concat(xw.RECVONLY)))return r=!0,"a=".concat(e);if(e===xw.SENDONLY&&i.includes("a=".concat(xw.INACTIVE)))return r=!0,"a=".concat(xw.RECVONLY)}return i})).join("\r\n");r&&(this._log.info("updating answer"),yield this._peerConnection.setRemoteDescription({type:"answer",sdp:s}))}))}replaceTrack(e){return rC(this,null,(function*(){var t;let i=null==(t=this._peerConnection)?void 0:t.getSenders(),r=e.outMediaTrack||e.mediaTrack;if(!i||0===i.length||!r||i.find((e=>e.track===r)))return;let n=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack;this._log.info("is replacing ".concat(r.kind," track on ").concat(n?Mw.AUXILIARY:Mw.MAIN," stream")),r.kind===Mw.AUDIO&&i[0]&&(yield i[0].replaceTrack(r)),r.kind===Mw.VIDEO&&(!n&&i[1]&&(yield i[1].replaceTrack(r)),n&&i[3]&&(yield i[3].replaceTrack(r)))}))}setBandwidth(e){return rC(this,arguments,(function(e){var t=this;let{bandwidth:i,type:r,videoType:n}=e;return function*(){if(t.singlePC){let e={};r===Mw.AUDIO?e.audio=i:"big"===n?e.bigVideo=i:"small"===n?e.smallVideo=i:e.auxVideo=i,yield t.singlePC.setBandwidth(e)}}()}))}sendMutedFlag(e){e===this.localAuxAudioTrack||e===this.localAuxVideoTrack||(this._log.info("send muted state: ".concat(JSON.stringify(this.muteState))),this._signalChannel.sendWaitForResponseWithRetry({command:rV,responseCommand:Zx.MUTE_RESULT,data:this.muteState,retries:3}).catch((()=>{})))}handleConnectionStateChange(e){"CONNECTED"===e.state&&(this.localMainVideoTrack||this._publishingLocalVideoTrack&&!this._isPublishingAux)&&JN.emit(fO.SEND_FIRST_VIDEO_FRAME,{room:this._room})}getVideoTrackId(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Mw.VIDEO;if(this._peerConnection){let t=this._peerConnection.getSenders();if(e===Mw.AUXILIARY&&t[3]&&t[3].track)return t[3].track.id;if(e===Mw.VIDEO&&t[1]&&t[1].track)return t[1].track.id}if(this.localMainVideoTrack&&e===Mw.VIDEO){let e=this.localMainVideoTrack.mediaTrack;if(e)return e.id}if(this.localAuxVideoTrack&&e===Mw.AUXILIARY){let e=this.localAuxVideoTrack.mediaTrack;if(e)return e.id}return""}getSSRC(){return this.ssrc}checkPublishResultCode(e,t){if(0!==e)throw e===_N?(this._log.error(jN.NOT_SUPPORTED_H264ENCODE),new fC({code:_C.NOT_SUPPORTED_H264,message:GN({key:HN.NOT_SUPPORTED_H264ENCODE})})):new fC({code:_C.UNKNOWN,message:GN({key:HN.SIGNAL_RESPONSE_FAILED,data:{signalResponse:Zx.PUBLISH_RESULT,code:e,message:t}})})}sendSEI(e,t){var i;null==(i=this._sei)||i.push(e,t)}onSinglePCReconnected(){return rC(this,null,(function*(){this.isMainStreamPublished&&(this._log.warn("republish main stream"),yield this.publish({localAudioTrack:this.localMainAudioTrack,localVideoTrack:this.localMainVideoTrack,isAuxiliary:!1})),this.isAuxStreamPublished&&(this._log.warn("republish aux stream"),yield this.publish({localAudioTrack:this.localAuxAudioTrack,localVideoTrack:this.localAuxVideoTrack,isAuxiliary:!0}))}))}};function QU(e){return Object.keys(e).filter((t=>e[t]))}var ZU=class extends qU{constructor(e){super(Xb(qb({},e),{isUplink:!1})),tC(this,"_flag",0),tC(this,"role","anchor"),tC(this,"remoteAudioTrack"),tC(this,"remoteVideoTrack"),tC(this,"remoteAuxiliaryTrack"),tC(this,"ssrc",{audio:0,video:0,videoRtx:0,auxiliary:0,auxiliaryRtx:0}),this.flag=e.flag,this.remoteAudioTrack=new hM(this._room,this),this.remoteVideoTrack=new pM(this._room,this),this.remoteAuxiliaryTrack=new mM(this._room,this),this.initialize()}get subscribeState(){return{audio:this.remoteAudioTrack.isSubscribed||this.remoteAudioTrack.isSubscribing,video:this.remoteVideoTrack.isBig&&(this.remoteVideoTrack.isSubscribed||this.remoteVideoTrack.isSubscribing),smallVideo:this.remoteVideoTrack.isSmall&&(this.remoteVideoTrack.isSubscribed||this.remoteVideoTrack.isSubscribing),auxiliary:this.remoteAuxiliaryTrack.isSubscribed||this.remoteAuxiliaryTrack.isSubscribing}}get muteState(){return qD(this.flag,this.userId)}get flag(){return this._flag}set flag(e){var t,i,r;e!==this._flag&&(this._flag=e,null==(t=this.remoteAudioTrack)||t.onFlagChanged(),null==(i=this.remoteVideoTrack)||i.onFlagChanged(),null==(r=this.remoteAuxiliaryTrack)||r.onFlagChanged())}get hasMainStream(){return this.muteState.hasAudio||this.muteState.hasVideo||this.muteState.hasSmall}get hasAuxStream(){return this.muteState.hasAuxiliary}get isMainStreamSubscribed(){return(this.subscribeState.audio||this.subscribeState.video||this.subscribeState.smallVideo)&&(this.muteState.hasAudio||this.muteState.hasVideo||this.muteState.hasSmall)}get isAuxStreamSubscribed(){return this.subscribeState.auxiliary&&this.muteState.hasAuxiliary}get isSmallStreamSubscribed(){return this.subscribeState.smallVideo&&this.muteState.hasSmall}get isBigStreamSubscribed(){return this.subscribeState.video&&this.muteState.hasVideo}isStreamUnpublished(e){return e===Mw.MAIN?!this.muteState.hasAudio&&!this.muteState.hasVideo:!this.muteState.hasAuxiliary}initialize(){this.installEvents()}close(e){super.close(e),this.emitConnectionStateChangedEvent("DISCONNECTED"),this.remoteAudioTrack.close(),this.remoteVideoTrack.close(),this.remoteAuxiliaryTrack.close(),this.uninstallEvents(),this.removeDownlink()}installEvents(){!this.singlePC||(this.listeners("track").includes(this.onTrack)||this.singlePC.on("track",this.onTrack,this),this.listeners("spc-reconnected").includes(this.onSinglePCReconnected)||this.singlePC.on("spc-reconnected",this.onSinglePCReconnected,this))}uninstallEvents(){!this.singlePC||(this.singlePC.off("track",this.onTrack,this),this.singlePC.off("spc-reconnected",this.onSinglePCReconnected,this))}emitConnectionStateChangedEvent(e){var t,i;let r=this._currentState,n=super.emitConnectionStateChangedEvent(e);return n&&r!==e&&(null==(t=this.remoteVideoTrack)||t.emit("connection-state-changed",{prevState:r,state:e}),null==(i=this.remoteAuxiliaryTrack)||i.emit("connection-state-changed",{prevState:r,state:e})),n}onTrack(e){let t=e.streams[0],{track:i}=e;if(t.id.split("-")[0]!==this.tinyId)return;let r=t.id.includes("aux")?"auxiliary":"main";this._log.debug("ontrack ".concat(r," ").concat(i.kind));let n=Mw.AUDIO;i.kind===Mw.VIDEO&&(n=r===Mw.MAIN?Mw.VIDEO:Mw.AUXILIARY);let o=this.remoteAudioTrack;n===Mw.VIDEO?o=this.remoteVideoTrack:n===Mw.AUXILIARY&&(o=this.remoteAuxiliaryTrack),o.setInputMediaStreamTrack(i)}isSubscriptionStateNotChanged(e){return JSON.stringify(e)===JSON.stringify(this.subscribeState)}subscribe(e,t){return rC(this,null,(function*(){var i,r,n;try{if(this.isSubscriptionStateNotChanged(e))return;if(this._log.info("subscribe ".concat(t," ").concat(QU(e))),this.hasSSRC){let t="subscribe_change";Object.values(e).find((e=>!0===e))||(t="unsubscribe"),yield this.sendSubscription(t,e)}else yield this.doSubscribe(e);(e.audio&&"ended"===(null==(i=this.remoteAudioTrack.mediaTrack)?void 0:i.readyState)||e.video&&"ended"===(null==(r=this.remoteVideoTrack.mediaTrack)?void 0:r.readyState)||e.auxiliary&&"ended"===(null==(n=this.remoteAuxiliaryTrack.mediaTrack)?void 0:n.readState))&&this.singlePC&&!this.singlePC.isReconnecting&&(this._log.warn("remote track ended start spc reconnect"),this.singlePC.startReconnection())}catch(o){throw this._room.isJoined&&this.isStreamUnpublished(t)?(this._log.warn("".concat(o.message," ").concat(JSON.stringify(this.muteState))),new fC({code:_C.REMOTE_STREAM_NOT_EXIST,message:"remote user ".concat(this.userId," unpublished stream")})):o}}))}unsubscribe(e){return rC(this,arguments,(function(e){var t=this;let{remoteTracks:i,streamType:r}=e;return function*(){var e;if("main"===r&&!t.isMainStreamSubscribed||"auxiliary"===r&&!t.isAuxStreamSubscribed)return void t._log.info("".concat(r," stream already unsubscribed"));let n=qb({},t.subscribeState);i.forEach((e=>{switch(e.mediaType){case 1:n.audio=!1;break;case 4:n.video=!1;break;case 8:n.smallVideo=!1;break;case 2:n.auxiliary=!1}}));let o="subscribe_change";Object.values(n).find((e=>!0===e))||(o="unsubscribe"),t._log.info("".concat("unsubscribe"===o?o:"subscribe"," ").concat(r," [").concat(QU(n),"]")),"unsubscribe"===o&&(null==(e=t.singlePC)||e.removeDownlinkQueue.add(t.tinyId)),yield t.sendSubscription(o,n),"unsubscribe"===o&&(yield t.removeDownlink())}()}))}sendSubscription(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.subscribeState,i={srcTinyId:this.tinyId,srcUserId:this.userId},r=cV,n=Zx.UNSUBSCRIBE_RESULT;return"subscribe_change"===e&&(i={audio:t.audio,bigVideo:t.video,auxVideo:t.auxiliary,smallVideo:t.smallVideo,srcTinyId:this.tinyId},r=lV,n=Zx.SUBSCRIBE_CHANGE_RESULT),this._signalChannel.sendWaitForResponse({command:r,data:i,responseCommand:n,timeout:1e4}).then((t=>{let{data:i}=t;if(0!==i.code){let t=new fC({code:i.code,message:GN({key:HN.ERROR_MESSAGE,data:{type:e,message:i.message}})});throw this._log.error(t),t}}))}getMainStreamVideoTrackId(){return this.remoteVideoTrack&&this.remoteVideoTrack.mediaTrack?this.remoteVideoTrack.mediaTrack.id:""}getAuxStreamVideoTrackId(){return this.remoteAuxiliaryTrack&&this.remoteAuxiliaryTrack.mediaTrack?this.remoteAuxiliaryTrack.mediaTrack.id:""}setDelay(e){let{audioDelay:t,videoDelay:i}=e;this.remoteAudioTrack.stat.end2EndDelay=t,this.remoteVideoTrack.stat.end2EndDelay=i}onSinglePCReconnected(){(this.ssrc.audio||this.ssrc.video||this.ssrc.auxiliary)&&(this._log.warn("resubscribe ".concat(JSON.stringify(this.subscribeState))),this.doSubscribe(this.subscribeState))}get hasSSRC(){return this.ssrc.audio&&this.ssrc.video&&this.ssrc.auxiliary}doSubscribe(){return rC(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.subscribeState,i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return function*(){if(e.singlePC){if(e.singlePC.addDownlinkQueue.add(e.tinyId),yield e.singlePC.waitForPeerConnectionConnected(),i||!e.hasSSRC){let i={audioSsrc:YU(),bigVideoSsrc:YU(),bigVideoRtxSsrc:YU(),auxVideoSsrc:YU(),auxVideoRtxSsrc:YU()},{audioSsrc:n,bigVideoSsrc:o,bigVideoRtxSsrc:s,auxVideoSsrc:a,auxVideoRtxSsrc:c}=i;e.ssrc={audio:n,video:o,videoRtx:s,auxiliary:a,auxiliaryRtx:c},e.singlePC.addDownlinkQueue.delete(e.tinyId),yield e.singlePC.addDownlink({userId:e.userId,tinyId:e.tinyId,ssrc:e.ssrc});try{let r=yield e._signalChannel.sendWaitForResponseWithRetry({command:SV,responseCommand:Zx.SPC_SUBSCRIBE_RESULT,data:{srcUserId:e.userId,srcTinyId:e.tinyId,audio:t.audio,bigVideo:t.video,auxVideo:t.auxiliary,smallVideo:t.smallVideo,customData:!1,ssrc:i},retries:3,retryTimeout:0});if(0!==r.data.code)throw new fC({code:r.data.code,message:r.data.message})}catch(r){throw yield e.removeDownlink(),r}return}e.singlePC.addDownlinkQueue.delete(e.tinyId),yield e.singlePC.addDownlink({userId:e.userId,tinyId:e.tinyId,ssrc:e.ssrc})}}()}))}removeDownlink(){return rC(this,null,(function*(){!this.singlePC||(this.ssrc={audio:0,video:0,videoRtx:0,auxiliary:0,auxiliaryRtx:0},this.singlePC.removeDownlinkQueue.delete(this.tinyId),yield this.singlePC.removeDownlink(this.tinyId,this.userId))}))}};eC([JP((e=>function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];return new Promise(((t,r)=>{let n=e=>{this.off("closed",n),r(new fC({code:_C.API_CALL_ABORTED,message:GN({key:HN.CONNECTION_ABORTED,data:e})}))};this.on("closed",n),e.apply(this,i).then(t,r).finally((()=>{this.off("closed",n)}))}))}))],ZU.prototype,"subscribe",1);var $U,eB=ZU,{isString:tB,isPlainObject:iB,isUndefined:rB,getNetworkType:nB,getTerminalType:oB,isEmpty:sB}=yC,aB=class extends wU{constructor(e){super(e),this._heartbeat=-1,this._lastHeartBeatTime=-1,this._joinTimeout=-1,this._firstPublishedList=null,this._joinReject=null,this._isRelayChanged=!1,this._signalChannel=null,this.uplinkConnection=null,this.singlePC=null,this.enableSPC=qO,this._changeBigSmallRecords=new Map,this._networkQuality=null,this._turnServers=[],this._syncUserListInterval=-1,this._smallStreamConfig={bitrate:100,frameRate:15,height:120,width:160},this.enableSEI=!1,this._enableAudioVolumeEvaluation=!1,this._audioVolumeIntervalId=0,this._enableMultiAuxStream=!1,this._pureAudioPushMode=!1,this.enableHWEncoder=!1,this._stats=new YV(this,this._log),this.userManager=new OM(this.userId,this._log),this._version=ow,this.sdpSemantics=mN,rB(e.sdpSemantics)?TO.isUnifiedPlanDefault()&&(this.sdpSemantics=pN):this.sdpSemantics=e.sdpSemantics,this._log.info("sdpSemantics: ".concat(this.sdpSemantics,", netType: ").concat(nB())),e.iceTransportPolicy&&(this._iceTransportPolicy=e.iceTransportPolicy),this._enableMultiAuxStream=!rB(e.enableMultiAuxStream)&&e.enableMultiAuxStream,this.enableSEI=e.enableSEI,!rB(e.enableSPC)&&qO&&(this.enableSPC=e.enableSPC),this.enableHWEncoder=e.enableHWEncoder||!1,this._initBusinessInfo(e)}get isMainStreamPublished(){var e;return!(null==(e=this.uplinkConnection)||!e.isMainStreamPublished)}get isMainAudioPublished(){var e;return!(null==(e=this.uplinkConnection)||!e.localMainAudioTrack)}get isAuxStreamPublished(){var e;return!(null==(e=this.uplinkConnection)||!e.isAuxStreamPublished)}get hasAuxStream(){return[...this.remotePublishedUserMap.values()].findIndex((e=>e.muteState.hasAuxiliary))>=0}get userMap(){return this.userManager.userMap}get remotePublishedUserMap(){return this.userManager.remotePublishedUserMap}get tinyIdToUserIdMap(){return new Map([...this.remotePublishedUserMap.values()].map((e=>[e.tinyId,e.userId])))}join(e,t,i){return rC(this,null,(function*(){return this.userManager.mySelfId=this.userId,this.userManager.on("1",(e=>{this.emit("peer-join",e)})),this.userManager.on("2",(e=>{this.closeDownLinkConnection(e,"remote user exitRoom"),this.emit("peer-leave",e)})),this.userManager.on("3",this.createDownlinkConnection,this),this.userManager.on("5",this.closeDownLinkConnection,this),this.userManager.on("6",(e=>{var t=((e,t)=>{var i={};for(var r in e)zb.call(e,r)&&t.indexOf(r)<0&&(i[r]=e[r]);if(null!=e&&jb)for(var r of jb(e))t.indexOf(r)<0&&Gb.call(e,r)&&(i[r]=e[r]);return i})(e,[]);JN.emit(fO.REMOTE_PUBLISH_STATE_CHANGED,qb({room:this},t)),this.emit("remote-publish-state-changed",qb({},t))})),this._joinOptions=e,new Promise(((t,i)=>rC(this,null,(function*(){this._joinReject=i;try{this.checkDestroy();let[,i]=yield Promise.all([this.initialize(),this.initSinglePC()]);yield this.doJoin(e,i),t(),this._firstPublishedList&&this.onPublishedUserList({data:{userList:this._firstPublishedList}})}catch(r){i(r)}this._joinReject=null}))))}))}initSinglePC(){return rC(this,null,(function*(){if(this.enableSPC&&!this.singlePC){this.singlePC=new WU({signalChannel:this._signalChannel,room:this,enableCustomMessage:!1}),this.singlePC.on("sei-message",(e=>this.emit("sei-message",e))),this.singlePC.once("error",(()=>this.fallbackToMPC()));try{return yield this.singlePC.initialize()}catch(e){this.singlePC.close(),this.singlePC=null}}}))}doJoin(e,t){return new Promise(((i,r)=>rC(this,null,(function*(){var n,o,s;e.privateMapKey&&(this.privateMapKey=e.privateMapKey),this._signalChannel.once(Kx,(e=>{this.clearJoinTimeout(),JN.emit(fO.JOIN_SIGNAL_CONNECTION_END,{room:this,error:e}),r(e)})),PD(null==(o=null==(n=this.scheduleResult)?void 0:n.config)?void 0:o.singlePC)&&qO&&(this.enableSPC=this.scheduleResult.config.singlePC),this.keyPointManager.setConnectionType(this.singlePC?1:2);let a={roomId:String(e.roomId||e.strRoomId),useStringRoomId:this.useStringRoomId,privateMapKey:this.privateMapKey,trtcRole:e.role,trtcScene:"live"===this.scene?2:1,sdpSemantics:this.sdpSemantics,version:this._version,ua:navigator&&navigator.userAgent||"",terminalType:oB(),netType:gD(),bussinessInfo:this._businessInfo,ability:t,sdkType:this._sdkType,userSig:this.userSig};this._log.debug("join room signal data: ".concat(JSON.stringify(a)));let c=5e3;(null==(s=this.scheduleResult.config)?void 0:s.enterRoomTimeout)&&this.scheduleResult.config.enterRoomTimeout>=1&&(c=1e3*this.scheduleResult.config.enterRoomTimeout),this._joinTimeout=window.setTimeout((()=>{r(new fC({code:_C.JOIN_ROOM_FAILED,message:GN({key:HN.JOIN_ROOM_TIMEOUT})}))}),c),JN.emit(fO.JOIN_SEND_CMD,{room:this}),this._signalChannel.send(this.singlePC?yV:eV,a),this._signalChannel.once(Zx.JOIN_ROOM_RESULT,(e=>{this.clearJoinTimeout();let{code:t,message:n,data:o,tinyId:s}=e.data;JN.emit(fO.JOIN_RECEIVED_CMD_RES,{room:this,code:t}),0===t?(this._log.info("Join room success, start heartbeat"),s&&(this.tinyId=s),this.startHeartbeat(),this.syncUserList(),this.startSyncUserListInterval(),this._firstPublishedList=o.publishers,this.singlePC&&this.singlePC.connect(o.ability).catch((()=>{})),i()):(this._log.error("Join room failed result: ".concat(t," error: ").concat(n)),r(new fC({code:_C.JOIN_ROOM_FAILED,extraCode:t,message:GN({key:HN.JOIN_ROOM_FAILED,data:{error:n,code:t}})})))}))}))))}reJoin(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return rC(this,null,(function*(){if(this.isJoined)try{this._log.warn("reJoin pending: ".concat(this._joinOptions.roomId));let t,i=[];if(this.singlePC&&(this.singlePC.close(),this.singlePC=null,i.push(this.initSinglePC().then((e=>(t=e,e))))),this._signalChannel&&(this._signalChannel.race=e,this._signalChannel.close(),i.push(this._signalChannel.connect())),yield Promise.all(i),yield this.doJoin(Xb(qb({},this._joinOptions),{role:"anchor"===this.role?20:21,privateMapKey:this.privateMapKey}),t),this._log.warn("reJoin success"),XN.logSuccessEvent({userId:this.userId,eventType:lN.REJOIN}),this.singlePC){let e=t=>{var i;"CONNECTED"===t.state&&(null==(i=this.singlePC)||i.off(UU.CONNECTION_STATE_CHANGED,e),this.uplinkConnection instanceof XU&&this.uplinkConnection.onSinglePCReconnected(),this.remotePublishedUserMap.forEach((e=>{e.installEvents(),e.onSinglePCReconnected()})))};this.singlePC.on(UU.CONNECTION_STATE_CHANGED,e),this.checkConnectionsToReconnect(),this.uplinkConnection instanceof KV&&!this.uplinkConnection.getIsReconnecting()&&this.uplinkConnection.startReconnection()}}catch(t){this._log.warn("reJoin fail ".concat(t)),this.reset(),XN.logFailedEvent({userId:this.userId,eventType:lN.REJOIN,error:t}),this.emit("error",new fC({code:_C.JOIN_ROOM_FAILED,message:GN({key:HN.REJOIN_ROOM_FAILED,data:{roomId:this._joinOptions.roomId}})}))}else this._log.warn("reJoin abort")}))}initialize(){return rC(this,null,(function*(){let{mainUrl:e,backupUrl:t}=this.getSignalChannelUrl(),i=this._signalChannel||(n=this.userId,[...kV.values()].find((e=>e.room.userId===n&&!e.room.isJoined))||null),r=!!(i&&i.isConnected&&i.keepAlive);var n;return this._log.info("".concat(r?"reuse":"setup"," signal channel")),r?(i.url=e,i.backupUrl=t,i.room=this,this._signalChannel=i):this._signalChannel=new wV({sdkAppId:this.sdkAppId,userId:this.userId,userSig:this.userSig,url:e,backupUrl:t,race:this.enableSPC&&!this.proxy_ws,room:this}),this._networkQuality||(this._networkQuality=new XV({signalChannel:this._signalChannel,room:this}),this._networkQuality.on(XV.EVENT_NETWORK_QUALITY,(e=>{this.emit("network-quality",e)}))),YL(this,this._signalChannel).add(Yx,(e=>{JN.emit(fO.SIGNAL_CONNECTION_STATE_CHANGED,qb({room:this},e)),this.emit("signal-connection-state-changed",e)})).add(qx,(e=>{this.reset(),this.emit("error",e)})).add(Zx.PEER_JOIN,(e=>{let{srcTinyId:t,userId:i,role:r}=e.data.data;this.userManager.addUser({userId:i,tinyId:t,role:r})})).add(Zx.PEER_LEAVE,(e=>{let{userId:t,reason:i=0}=e.data.data;this.userManager.deleteUser(t,i)})).add(Zx.UPDATE_REMOTE_MUTE_STAT,(e=>{this._lastHeartBeatTime>0&&Date.now()-this._lastHeartBeatTime>=1e4&&this.doHeartbeat(),this.onPublishedUserList(e.data)})).add(Zx.CLIENT_BANNED,(e=>{let t=e.data.data,{reason:i}=t;if(XN.uploadEvent({log:"stat-banned:".concat(i),userId:this.userId}),"user_time_out"===i)return this._log.warn("".concat(i," last heart beat time: ").concat(this._lastHeartBeatTime," interval: ").concat(Date.now()-this._lastHeartBeatTime,", visibility: ").concat(document.visibilityState)),void this.reJoin();this._log["kick"===i?"error":"info"]("user was banned because of [".concat(i,"]")),this.reset(),this.emit("banned",{reason:i})})),this._signalChannel.once(Gx,(e=>{this.tinyId=e.signalInfo.tinyId,JN.emit(fO.JOIN_SIGNAL_CONNECTION_END,{room:this})})),JN.emit(fO.JOIN_SIGNAL_CONNECTION_START,{room:this}),yield this._signalChannel.connect(),r&&JN.emit(fO.JOIN_SIGNAL_CONNECTION_END,{room:this}),r}))}setSignalChannel(e){this._signalChannel=e,e||JL(this)}leave(){return rC(this,null,(function*(){var e;try{yield this.doHeartbeat()}catch(t){}this._log.info("leave() => leaving room"),JN.emit(fO.LEAVE_SEND_CMD,{room:this}),null==(e=this._signalChannel)||e.send(tV)}))}clearNetworkQuality(){this._networkQuality&&(this._networkQuality.stop(),this._networkQuality=null)}closeConnections(){this.remotePublishedUserMap.forEach((e=>{this.closeDownLinkConnection(e.userId,"you exitRoom")}))}clearJoinTimeout(){clearTimeout(this._joinTimeout),this._joinTimeout=-1}startHeartbeat(){-1===this._heartbeat&&(this._heartbeat=SL.run(LN,this.doHeartbeat.bind(this),{delay:2e3}))}stopHeartbeat(){-1!==this._heartbeat&&(this._log.info("stopHeartbeat"),SL.clearTask(this._heartbeat),this._heartbeat=-1,this._lastHeartBeatTime=-1)}doHeartbeat(){return rC(this,null,(function*(){var e;let t=this.badCaseDetector.getMonitorFreeze(),i=yield this._stats.getStatsReport({uplinkConnection:this.uplinkConnection,downlinkConnections:this.remotePublishedUserMap,freezeMap:t});if(this.badCaseDetector.resetMonitor(),null==(e=this._signalChannel)||!e.isConnected)return;let r=this._signalChannel.isConnected?function(e){if(kM.has(e)){let t=kM.get(e).map((e=>({uint32_event_id:e.eventId,uint64_date:e.timestamp,str_userid:e.remoteUserId,str_event_json:e.eventDesc})));return kM.delete(e),t}return[]}(this.userId):[],n=qb({str_sdk_version:nw,uint64_datetime:(new Date).getTime(),msg_user_info:{str_identifier:this.userId,uint64_tinyid:this.tinyId},msg_device_info:{uint32_terminal_type:15,str_device_name:navigator.platform,str_os_version:"",uint32_net_type:gD()},msg_event_msg:r,str_acc_ip:this.getSignalInfo().relayIp,str_client_ip:this.getSignalInfo().clientIp},i);JN.emit(fO.HEARTBEAT_REPORT,{room:this,report:n}),this._signalChannel.send(iV,n),this.emit("heartbeat-report",Xb(qb({},n),{bytes_sent:this._stats.totalBytesSent+this._signalChannel.bytesSent,bytes_received:this._stats.totalBytesReceived+this._signalChannel.bytesReceived}));let o=Date.now();this._lastHeartBeatTime>0&&o-this._lastHeartBeatTime>1e4&&this._log.warn("heartbeat took ".concat(o-this._lastHeartBeatTime)),this._signalChannel.isConnected&&(this._lastHeartBeatTime=o),!this._isRelayChanged&&this.isRelayMaybeFailed()&&(this.reJoin(),this._isRelayChanged=!0)}))}onPublishedUserList(e){if(!this.isJoined)return;let t=e.data.userList.map((e=>{let{userId:t,srcTinyId:i,flag:r}=e,n=this.remotePublishedUserMap.get(t);return n&&this.checkSubscribeBigSmallVideo(n),{userId:t,tinyId:i,flag:r}}));JN.emit(fO.RECEIVED_PUBLISHED_USER_LIST,{room:this,publishedUserList:t}),this.userManager.setRemotePublishedUserList(t)}closeUplink(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"you unpublished";this.uplinkConnection&&(this.localTracks.size>0&&this.uplinkConnection.doUnpublish(),this.uplinkConnection.close(e),this.uplinkConnection=null),this.localTracks.forEach((e=>e.unpublish())),this.localTracks.clear()}createDownlinkConnection(e){let{userId:t,tinyId:i,flag:r}=e,n=new(this.singlePC?eB:jV)({userId:t,tinyId:i,room:this,signalChannel:this._signalChannel,enableSEI:this.enableSEI,flag:r});this.userManager.addRemotePublishedUser(n),this.installDownlinkEvents(n,t),this.emit("remote-published",n)}closeDownLinkConnection(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"remote user unpublished",i=this.remotePublishedUserMap.get(e);i&&(i.close(t),this.emit("remote-unpublished",i))}installDownlinkEvents(e,t){e.on("error",(e=>{let i=e.getCode();i!==_C.ICE_TRANSPORT_ERROR&&(i===_C.DOWNLINK_RECONNECTION_FAILED&&this.closeDownLinkConnection(t),this.emit("error",e))})),e.on("connection-state-changed",(t=>{this.emit("media-connection-state-changed",Xb(qb({},t),{userId:e.userId}))})),e.on("firewall-restriction",(()=>{this.emit("firewall-restriction")}))}startSyncUserListInterval(){-1===this._syncUserListInterval&&(this._syncUserListInterval=SL.run(LN,this.syncUserList.bind(this)))}stopSyncUserListInterval(){SL.clearTask(this._syncUserListInterval),this._syncUserListInterval=-1}syncUserList(){return this.getUserList().then((e=>{this.userManager.setUserList(e)})).catch((e=>{this._log.debug("sync user list failed: ".concat(e))}))}getUserList(){var e;return null!=(e=this._signalChannel)&&e.isConnected?this._signalChannel.sendWaitForResponse({command:fV,responseCommand:Zx.USER_LIST_RES,enableLog:!1,timeout:2e3}).then((e=>{let{data:t}=e,{code:i,message:r}=t;if(0===i)return(t.data&&t.data.userList||[]).map((e=>{let{userId:t,srcTinyId:i,role:r}=e;return{userId:t,tinyId:i,role:r}}));throw GN({key:HN.SIGNAL_RESPONSE_FAILED,data:{signalResponse:Zx.USER_LIST_RES,code:i,message:r}})})):Promise.reject("not connected")}getAllConnections(){let e=[...this.remotePublishedUserMap.values()];return this.uplinkConnection&&e.push(this.uplinkConnection),e}isRelayMaybeFailed(){if(this._signalChannel&&!this._signalChannel.isOnline||!PV)return!1;if(this.singlePC)return this.singlePC.reconnectionCount>6;let e=this.getAllConnections();if(0===e.length)return!1;for(let t=0;t<e.length;t++)if(e[t].getReconnectionCount()<6)return!1;return!0}checkConnectionsToReconnect(){var e;this.singlePC?(null==(e=this.singlePC.getPeerConnection())?void 0:e.connectionState)===rN.CLOSED&&!this.singlePC.isReconnecting&&(this._log.warn("spc pc is closed but not reconnect"),this.singlePC.startReconnection()):this.getAllConnections().forEach((e=>{if(e instanceof MV&&!e.getIsReconnecting()){let t=e.getPeerConnection();t&&t.connectionState===rN.CLOSED&&(this._log.warn("[".concat(e.getUserId(),"] pc is closed but not reconnect")),e.startReconnection())}}))}fallbackToMPC(){return rC(this,null,(function*(){var e;if(this._log.warn("fallback to multi pc"),XN.uploadEvent({log:"stat-fallback",userId:this.userId}),this.enableSPC=!1,null==(e=this.singlePC)||e.close(),this.singlePC=null,yield this.reJoin(!1),this.uplinkConnection){let e=this.uplinkConnection;this.uplinkConnection=new KV({userId:this.userId,tinyId:this.tinyId,room:this,signalChannel:this._signalChannel,enableSEI:this.enableSEI,audioManager:this.audioManager}),e.isMainStreamPublished&&(yield this.uplinkConnection.publish({localAudioTrack:e.localMainAudioTrack,localVideoTrack:e.localMainVideoTrack,isAuxiliary:!1})),e.isAuxStreamPublished&&(yield this.uplinkConnection.publish({localAudioTrack:e.localAuxAudioTrack,localVideoTrack:e.localAuxVideoTrack,isAuxiliary:!0})),e.close()}this.remotePublishedUserMap.forEach((e=>{let t=new jV({userId:e.userId,tinyId:e.tinyId,room:this,signalChannel:this._signalChannel,enableSEI:this.enableSEI,flag:e.flag,remoteAudioTrack:e.remoteAudioTrack,remoteVideoTrack:e.remoteVideoTrack,remoteAuxiliaryTrack:e.remoteAuxiliaryTrack});this.installDownlinkEvents(t,e.userId),this.remotePublishedUserMap.set(e.userId,t),e.isMainStreamSubscribed&&t.subscribe(e.subscribeState,"main"),e.isAuxStreamSubscribed&&t.subscribe(e.subscribeState,"auxiliary")}))}))}destroy(){this.isDestroyed||(this._signalChannel&&(this._log.info("destroying SignalChannel"),this._signalChannel.close(),this._signalChannel=null),super.destroy(),this._joinReject&&(this._joinReject(new fC({code:_C.INVALID_OPERATION,message:GN({key:HN.CLIENT_DESTROYED,data:{funName:"join"}})})),this.clearJoinTimeout(),this.reset()),this.removeAllListeners())}switchRole(e){return rC(this,null,(function*(){this.role!==e&&("audience"===e&&this.uplinkConnection&&this.closeUplink("you switch role to audience"),yield this.doSwitchRole(e))}))}doSwitchRole(e){let t={command:gV,data:{role:"anchor"===e?20:21,privateMapKey:this.privateMapKey},responseCommand:Zx.SWITCH_ROLE_RES,retries:1};return this._log.info("switchRole signal data: ".concat(JSON.stringify(t.data))),this._signalChannel.sendWaitForResponseWithRetry(t).then((t=>{let{code:i,message:r}=t.data;if(0!==i)throw new fC({code:_C.SWITCH_ROLE_FAILED,message:GN({key:HN.SWITCH_ROLE_FAILED,data:{message:r,code:i}})});this.role=e})).catch((e=>{throw e instanceof fC&&e.getCode()===_C.API_CALL_TIMEOUT&&(e=new fC({code:_C.SWITCH_ROLE_FAILED,message:GN({key:HN.SWITCH_ROLE_TIMEOUT})})),this._log.error(e),e}))}publish(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return rC(this,null,(function*(){let e={},i={};t.forEach((t=>{t instanceof iM&&(t instanceof cM?i.audio=t:e.audio=t),t instanceof rM&&(t instanceof aM&&2===t.mediaType?i.video=t:e.video=t)}));let r=sB(e),n=sB(i);(!r||!n)&&!this.uplinkConnection&&(this.singlePC?this.uplinkConnection=new XU({userId:this.userId,tinyId:this.tinyId,room:this,signalChannel:this._signalChannel,enableSEI:this.enableSEI,audioManager:this.audioManager}):this.uplinkConnection=new KV({userId:this.userId,tinyId:this.tinyId,room:this,signalChannel:this._signalChannel,enableSEI:this.enableSEI,audioManager:this.audioManager}),this.uplinkConnection.on("connection-state-changed",(e=>{this.emit("media-connection-state-changed",Xb(qb({},e),{userId:this.userId}))})),this.uplinkConnection.on("firewall-restriction",(()=>{this.emit("firewall-restriction")})),this.uplinkConnection.on("error",(e=>{let t=e.getCode();t!==_C.ICE_TRANSPORT_ERROR&&(t===_C.UPLINK_RECONNECTION_FAILED&&this.closeUplink(),this.emit("error",e))})));let o=t.map((e=>e.kind)).join(",");r||(this._log.info("publish() => main ".concat(o)),yield this.uplinkConnection.publish({localAudioTrack:e.audio,localVideoTrack:e.video,isAuxiliary:!1}),this._log.info("main is published")),n||(this._log.info("publish() => aux ".concat(o)),yield this.uplinkConnection.publish({localAudioTrack:i.audio,localVideoTrack:i.video,isAuxiliary:!0}),this._log.info("aux is published"))}))}unpublish(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return rC(this,null,(function*(){if("live"===this.scene&&"anchor"!==this.role||!this.isMainStreamPublished&&!this.isAuxStreamPublished||!this.uplinkConnection)return;let e={},i={};t.forEach((t=>{!t.mediaTrack||!t.isPublished||(t instanceof iM&&(t instanceof cM?i.audio=t:e.audio=t),t instanceof rM&&(t instanceof aM&&2===t.mediaType?i.video=t:e.video=t))}));try{let r=t.map((e=>e.kind)).join(",");sB(e)||(this._log.info("unpublish() => main ".concat(r)),yield this.uplinkConnection.unpublish({localAudioTrack:e.audio,localVideoTrack:e.video})),sB(i)||(this._log.info("unpublish() => aux ".concat(r)),yield this.uplinkConnection.unpublish({localAudioTrack:i.audio,localVideoTrack:i.video}))}catch(r){}0===this.localTracks.size&&this.closeUplink("you unpublished")}))}addTrack(e){if(!this.uplinkConnection||!e.mediaTrack)return Promise.resolve();let t=this.uplinkConnection.addTrack(e);return e.publish(this,t),t}removeTrack(e){return this.uplinkConnection&&e.mediaTrack?this.uplinkConnection.removeTrack(e).then((t=>(e.unpublish(),t))):Promise.resolve()}replaceTrack(e){return this.uplinkConnection&&e.mediaTrack&&QO()?this.uplinkConnection.replaceTrack(e).then((t=>{JN.emit(fO.LOCAL_TRACK_REPLACED,{track:e})})):Promise.resolve()}setBandWidth(e){return rC(this,null,(function*(){!this.uplinkConnection||(yield this.uplinkConnection.setBandwidth(e),yield this.uplinkConnection.sendMediaSettings())}))}enableSmall(e){return rC(this,null,(function*(){if(!this.uplinkConnection||!this.uplinkConnection.localMainVideoTrack)return Promise.resolve();e&&this.uplinkConnection.localMainVideoTrack.small&&(yield this.setBandWidth({type:Mw.VIDEO,videoType:Mw.SMALL,bandwidth:this.uplinkConnection.localMainVideoTrack.small.bitrate})),yield this.uplinkConnection.enableSmall(e)}))}subscribe(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return rC(this,null,(function*(){if(0===(t=t.filter((e=>!e.isSubscribed))).length)return;let{userId:e}=t[0],i=this.remotePublishedUserMap.get(e);if(!i)return;let r=t.find((e=>2===e.mediaType))?"auxiliary":"main";try{let n=qb({},i.subscribeState);t.forEach((e=>{switch(e.mediaType){case 1:n.audio=!0;break;case 4:n.video=!0;break;case 2:n.auxiliary=!0}}));let o=this._changeBigSmallRecords.get(e);o&&o.options.smallVideo&&i.muteState.hasSmall&&n.video&&(n.video=!1,n.smallVideo=!0),JN.emit(fO.SUBSCRIBE_START,{room:this,streamType:r,remotePublishedUser:i,subscribeState:n}),this._log.info("subscribe() => ".concat(e," ").concat(r," [").concat(BV(n),"] prev: [").concat(BV(i.subscribeState),"]")),yield i.subscribe(n,r);for(let e of t)e.mediaTrack||(yield e.waitHasMediaTrack());i.remoteVideoTrack.setMediaType(n.smallVideo?8:4),JN.emit(fO.SUBSCRIBE_SUCCESS,{room:this,streamType:r,remotePublishedUser:i})}catch(n){let t=n instanceof fC?n.getCode():_C.UNKNOWN,i=n;throw n instanceof fC?t===_C.REMOTE_STREAM_NOT_EXIST&&(i=new fC({code:_C.API_CALL_ABORTED,message:GN({key:HN.API_CALL_ABORTED,data:{message:n.message,userId:e,streamType:r}})}),this._log.warn(i)):(i=new fC({code:t,message:GN({key:HN.SUBSCRIBE_FAILED,data:{message:n.message,userId:e,streamType:r}})}),this._log.error(i)),i}}))}unsubscribe(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return rC(this,null,(function*(){let{userId:e}=t[0],i=this.remotePublishedUserMap.get(e);if(!i)return;let r=t.find((e=>2===e.mediaType))?"auxiliary":"main";this._log.info("unsubscribe() => ".concat(e," ").concat(r));try{yield i.unsubscribe({remoteTracks:t,streamType:r})}catch(n){this._log.warn("unsubscribe() => failed ".concat(n))}t.forEach((e=>{e.unsubscribe(),8===e.mediaType&&e.setMediaType(4)})),JN.emit(fO.UNSUBSCRIBE_SUCCESS,{room:this,streamType:r,remotePublishedUser:i})}))}setEncodedDataProcessingListener(e){throw new Error("Method not implemented.")}enableAudioVolumeEvaluation(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,t=arguments.length>1?arguments[1]:void 0;if(e<=0)return this._enableAudioVolumeEvaluation=!1,void SL.clearTask(this._audioVolumeIntervalId);e=Math.floor(Math.max(e,100)),JN.emit(fO.AUDIO_LEVEL_INTERVAL,{interval:e}),this._audioVolumeIntervalId&&SL.clearTask(this._audioVolumeIntervalId),this._enableAudioVolumeEvaluation=!0,this._audioVolumeIntervalId=SL.run(PN,(()=>{var e;let t=[];null==(e=this.remotePublishedUserMap)||e.forEach((e=>{if(e.muteState.hasAudio){let i=Math.floor(100*e.remoteAudioTrack.getAudioLevel());t.push({userId:e.userId,volume:i})}})),this.emit("audio-volume",t)}),{fps:1e3/e,backgroundTask:t})}getLocalAudioStats(){return rC(this,null,(function*(){let e={};if(e[this.userId]={bytesSent:0,packetsSent:0},this.uplinkConnection){let t=yield this._stats.getSenderStats(this.uplinkConnection);e[this.userId]={bytesSent:t.audio.bytesSent,packetsSent:t.audio.packetsSent}}return e}))}getLocalVideoStats(){return rC(this,null,(function*(){let e={};if(e[this.userId]={bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0},this.uplinkConnection){let{video:{bytesSent:t,packetsSent:i,framesEncoded:r,framesSent:n,frameWidth:o,frameHeight:s}}=yield this._stats.getSenderStats(this.uplinkConnection);e[this.userId]={bytesSent:t,packetsSent:i,framesEncoded:r,framesSent:n,frameWidth:o,frameHeight:s}}return e}))}getTransportStats(){return rC(this,null,(function*(){let e={rtt:0,downlinksRTT:{}};if(this.uplinkConnection){let t=yield this._stats.getSenderStats(this.uplinkConnection);e.rtt=t.rtt}for(let[,t]of this.remotePublishedUserMap){let i=yield this._stats.getReceiverStats(t);e.downlinksRTT[i.userId]=i.rtt}return e}))}getRemoteVideoStats(e){return rC(this,null,(function*(){let t={};for(let[i,r]of this.remotePublishedUserMap)"main"===e&&r.muteState.hasVideo&&(t[i]=r.remoteVideoTrack.stat),"auxiliary"===e&&r.muteState.hasAuxiliary&&(t[i]=r.remoteAuxiliaryTrack.stat);return t}))}getRemoteAudioStats(){return rC(this,null,(function*(){let e={};for(let[t,i]of this.remotePublishedUserMap)i.muteState.hasAudio&&(e[t]=i.remoteAudioTrack.stat);return e}))}setTurnServer(e,t){this._log.info("set turn server: ".concat(JSON.stringify(e)," ").concat(t||""));let i=[];Array.isArray(e)?e.forEach((e=>i.push(yC.getTurnServer(e)))):yC.isPlainObject(e)&&i.push(yC.getTurnServer(e)),this._turnServers=i,t&&(this._iceTransportPolicy=t)}sendStartMixTranscode(e){return this._signalChannel.sendWaitForResponse({command:mV,data:e,timeout:5e3,responseCommand:Zx.START_MIX_TRANSCODE_RES,commandDesc:"startMixTranscode"})}sendStopMixTranscode(e){return this._signalChannel.sendWaitForResponse({command:_V,data:e,timeout:5e3,responseCommand:Zx.STOP_MIX_TRANSCODE_RES,commandDesc:"stopMixTranscode"})}sendStartPublishCDN(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return this._signalChannel.sendWaitForResponse({command:t?dV:hV,data:e,timeout:5e3,responseCommand:t?Zx.START_PUBLISH_TENCENT_CDN_RES:Zx.START_PUBLISH_GIVEN_CDN_RES,commandDesc:"startPublishCDN"})}sendStopPublishCDN(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return this._signalChannel.sendWaitForResponse({command:t?uV:pV,data:e,timeout:5e3,responseCommand:t?Zx.STOP_PUBLISH_TENCENT_CDN_RES:Zx.STOP_PUBLISH_GIVEN_CDN_RES,commandDesc:"stopPublishCDN"})}sendAbilityStatus(e){var t;null==(t=this._signalChannel)||t.sendWaitForResponse({command:IV,data:e,timeout:5e3,responseCommand:Zx.ABILITY_STATUS_REPORT_RESULT,commandDesc:"ability status report"}).catch((e=>{}))}getIceServers(){return 0===this._turnServers.length&&this.scheduleResult.iceServers?this.scheduleResult.iceServers:this._turnServers}getIceTransportPolicy(){return this._iceTransportPolicy||this.scheduleResult.iceTransportPolicy||"all"}getLogger(){return this._log}enableAIVoice(){throw new Error("Method not implemented.")}getSignalChannelUrl(){let e={mainUrl:"",backupUrl:""},t=yC.getEnv();return t?(e.mainUrl="wss://".concat(t,".rtc.qq.com"),e.backupUrl=e.mainUrl):this.proxy_ws?(e.mainUrl=this.proxy_ws,e.backupUrl=e.mainUrl):Array.isArray(this.scheduleResult.domains)&&this.scheduleResult.domains.length>0&&(e.mainUrl="wss://".concat(this.scheduleResult.domains[0]),e.backupUrl=e.mainUrl,this.scheduleResult.domains[1]&&(e.backupUrl="wss://".concat(this.scheduleResult.domains[1]))),e}getSignalInfo(){var e;return(null==(e=this._signalChannel)?void 0:e.getSignalInfo())||{clientIp:"",relayIp:""}}reset(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.stopSyncUserListInterval(),this.stopHeartbeat(),this.closeConnections(),this.clearNetworkQuality(),this.closeUplink("you exitRoom"),this._signalChannel&&(e&&this._signalChannel.keepAlive&&this._signalChannel.isConnected?this._signalChannel.stopKeepAliveIn(3600):this._signalChannel.close(),this.setSignalChannel(null)),this._stats.reset(),this.userManager.clear(),this.userManager.removeAllListeners(),this.singlePC&&(this.singlePC.close(),this.singlePC=null),this.scheduleResult={domains:null,iceServers:null,iceTransportPolicy:null,trtcAutoConf:null}}checkSubscribeBigSmallVideo(e){return rC(this,null,(function*(){let{subscribeState:t,userId:i,muteState:{hasSmall:r,hasVideo:n}}=e;if(!r&&!n||!t.video&&!t.smallVideo)return;let o=this._changeBigSmallRecords.get(i);if(!o||o.isSubscribing||o.reSubscribeCount<=0)return;let{options:s,reSubscribeCount:a}=o;if(s.video&&t.video||s.smallVideo&&t.smallVideo&&r)return;let c={audio:e.remoteAudioTrack.isSubscribed||e.remoteAudioTrack.isSubscribing,auxiliary:e.remoteAuxiliaryTrack.isSubscribed||e.remoteAuxiliaryTrack.isSubscribing,video:s.video,smallVideo:s.smallVideo};try{if(!r&&c.smallVideo&&(c.video=!0,c.smallVideo=!1),c.smallVideo===t.smallVideo&&c.video===t.video)return;o.isSubscribing=!0,o.reSubscribeCount=a-1,yield e.subscribe(c,"main"),e.remoteVideoTrack.setMediaType(c.smallVideo?8:4),this._log.info("change [".concat(i,"] to ").concat(c.smallVideo?"small":"big"," video successfully. count ").concat(DN-o.reSubscribeCount,".")),o.isSubscribing=!1,o.reSubscribeCount=DN}catch(l){this._log.info("change [".concat(i,"] to ").concat(c.smallVideo?"small":"big"," video failed. count ").concat(DN-o.reSubscribeCount,".")),o.isSubscribing=!1,0===o.reSubscribeCount&&this._changeBigSmallRecords.delete(i)}}))}changeType(e,t){let i={options:{video:!e,smallVideo:e},isSubscribing:!1,reSubscribeCount:DN};this._changeBigSmallRecords.set(t.userId,i),this._log.info("set [".concat(t.userId,"] video prefer type: ").concat(e?"small":"big"))}get smallStreamConfig(){return this._smallStreamConfig}_initBusinessInfo(e){this._businessInfo=e.businessInfo;let t={};if(tB(e.businessInfo)&&(t=JSON.parse(e.businessInfo)),!rB(e.pureAudioPushMode)){if(!Number.isInteger(Number(e.pureAudioPushMode)))throw new fC({code:_C.INVALID_PARAMETER,message:GN({key:HN.INVALID_PURE_AUDIO})});this._pureAudioPushMode=e.pureAudioPushMode,t.Str_uc_params||(t.Str_uc_params={}),t.Str_uc_params.pure_audio_push_mod=this._pureAudioPushMode}if(!rB(e.userDefineRecordId)){let i=/^[A-Za-z0-9_-]{1,64}$/gi;if(null===e.userDefineRecordId.match(i))throw new fC({code:_C.INVALID_PARAMETER,message:GN({key:HN.INVALID_USER_DEFINE_RECORDID})});t.Str_uc_params||(t.Str_uc_params={}),t.Str_uc_params.userdefine_record_id=e.userDefineRecordId}if(!rB(e.userDefinePushArgs)){if(!(tB(e.userDefinePushArgs)&&String(e.userDefinePushArgs)&&String(e.userDefinePushArgs).length<=256))throw new fC({code:_C.INVALID_PARAMETER,message:GN({key:HN.INVALID_USER_DEFINE_PUSH_ARGS})});t.Str_uc_params||(t.Str_uc_params={}),t.Str_uc_params.userdefine_push_args=e.userDefinePushArgs}sB(t)||(this._businessInfo=JSON.stringify(t))}sendSEI(e,t){this.singlePC&&this.singlePC.sendSEI(e,t)}};return eC([Fx(["left",Wx.INIT],"joined"),bV({settings:{retries:1,timeout:0},onError(e,t,i){this._isUsingCachedSchedule&&!this.isDestroyed?(this._log.warn("is using cached schedule, retry join"),$N(!0),this.reset(),t()):this._signalChannel&&this._signalChannel.isConnected&&this._signalChannel.keepAlive?(this._log.warn("is using keepAlive ws, retry join"),this._signalChannel.close(),this.reset(),t()):(this.reset(),this._log.error(e),i(e))}}),JP((e=>{let t=new Ox;return function(i,r,n){return rC(this,null,(function*(){let o=String(i.roomId||i.strRoomId);if(this.userId=i.userId,this.sdkAppId=i.sdkAppId,this.userSig=i.userSig,this._log.setSdkAppId(this.sdkAppId),this._log.setUserId(this.userId),this.scene=r,i.privateMapKey=i.privateMapKey||"",this.isJoined)throw new fC({code:_C.INVALID_OPERATION,message:GN({key:HN.INVALID_JOIN})});if(this.checkDestroy(),t.isJoined({userId:this.userId,roomId:o,sdkAppId:this.sdkAppId,room:this}))throw new fC({code:_C.INVALID_OPERATION,message:GN({key:HN.REPEAT_JOIN,data:this.userId})});t.add({room:this,roomId:o}),this.role=21===i.role?"audience":"anchor",this._log.info("Join() => joining room: ".concat(o," useStringRoomId: ").concat(this.useStringRoomId," scene: ").concat(this.scene," role: ").concat(this.role)),JN.emit(fO.JOIN_START,{room:this,roomId:o,params:i}),this.checkSystemResult=yield TO.checkSystemRequirementsInternal(),this.checkDestroy();let s=yC.getEnv();s||(s=Rw.QCLOUD,this.proxy_ws&&(this.proxy_ws.startsWith(Vw.OLD_CLOUD_LADDER)?s=Rw.OLD_CLOUD_LADDER:this.proxy_ws.startsWith(Vw.WEBRTC)&&(s=Rw.WEBRTC))),XN.setConfig({env:s,sdkAppId:String(this.sdkAppId),userId:this.userId,roomId:o}),Lx.call(this);let{isH264EncodeSupported:a,isVp8EncodeSupported:c}=this.checkSystemResult.detail;if(!TO.isWebRTCSupported()||!a&&!c)throw new fC({code:_C.NOT_SUPPORTED,message:GN({key:HN.NOT_SUPPORTED_WEBRTC})});try{!this.proxy_ws&&!this.proxy_wt&&!this.scheduleResult.domains&&!yC.getEnv()&&(yield this.schedule(o,n));let t=yield e.call(this,i,r,n);return this.roomId=o,this._joinedTimestamp=yC.performanceNow(),JN.emit(fO.JOIN_SUCCESS,{room:this}),XN.uploadEvent({log:"stat-conv-".concat(Number(Jk),"-").concat(location.hostname),userId:this.userId}),t}catch(l){throw t.delete({room:this,roomId:o}),JN.emit(fO.JOIN_FAILED,{room:this,error:l}),l}}))}}))],aB.prototype,"join",1),eC([Fx("joined","left",{ignoreError:!0,success(){this.reset(!0)}}),JP((e=>function(){return rC(this,null,(function*(){JN.emit(fO.LEAVE_START,{room:this}),yield e.call(this),JN.emit(fO.LEAVE_SUCCESS,{room:this,roomId:this.roomId})}))})),ZP("leave room"),CV({fnName:"publish",validateArgs:!1}),CV({fnName:"unsubscribe",validateArgs:!1})],aB.prototype,"leave",1),eC([QP(),JP((e=>function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];return rC(this,null,(function*(){if("live"===this.scene&&"anchor"!==this.role||!(i=i.filter((e=>e.outMediaTrack&&"capture"===e.state))).length)return;JN.emit("61",{room:this});let t=e.apply(this,i);return i.forEach((e=>e.publish(this,t))),t}))})),bV({settings:{retries:sN,timeout:e=>kD(e)},onError(e,t,i){var r;null!=(r=e.message)&&r.includes("timeout")?(this._log.warn("publish timeout"),t()):(this._log.error("publish failed: ".concat(e)),i(e),JN.emit(fO.PUBLISH_FAILED,{room:this}))}})],aB.prototype,"publish",1),eC([CV({fnName:"publish"}),($U="api-call",function(e,t,i){let r=i.value;return i.value=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];let n=qP.get(this);if(n){let e=n.filter(((e,i)=>{if(0===i)return!0;let r=!0;return e.args.forEach((e=>{t.find((t=>t===e))||(r=!1)})),!r||(e.reject(new fC({code:_C.API_CALL_ABORTED,message:$U})),!1)}));qP.set(this,e)}return r.apply(this,t)},i}),QP(),JP((e=>function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];let n=e.apply(this,i);return i.forEach((e=>e.unpublish())),n}))],aB.prototype,"unpublish",1),eC([$P((function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return t[0].userId})),JP((e=>function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];let n=e.apply(this,i);return i.forEach((e=>!e.isSubscribed&&e.subscribe(n))),n})),bV({settings:{retries:sN,timeout:e=>kD(e)},onError(e,t,i,r){e.message.includes("timeout")?(this._log.warn("subscribe timeout"),t()):(this._log.error("subscribe failed: ".concat(e)),i(e),JN.emit(fO.SUBSCRIBE_FAILED,{room:this,remoteTracks:r}))}})],aB.prototype,"subscribe",1),eC([CV({fnName:"subscribe",callback(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.singlePC||t.forEach((e=>{let t=this.remotePublishedUserMap.get(e.userId);t&&!t.isMainStreamSubscribed&&!t.isAuxStreamSubscribed&&t.close("you unsubscribed")}))}}),$P((function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return t[0].userId}))],aB.prototype,"unsubscribe",1),Dx.create=Dx._create.bind(Dx,aB),Dx}();var n=r.exports;const o=t.getDefaultExportFromCjs(n);var s="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a=[],c=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,d=!1;function u(){d=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)a[t]=e[t],c[e.charCodeAt(t)]=t;c["-".charCodeAt(0)]=62,c["_".charCodeAt(0)]=63}function h(e,t,i){for(var r,n,o=[],s=t;s<i;s+=3)r=(e[s]<<16)+(e[s+1]<<8)+e[s+2],o.push(a[(n=r)>>18&63]+a[n>>12&63]+a[n>>6&63]+a[63&n]);return o.join("")}function p(e){var t;d||u();for(var i=e.length,r=i%3,n="",o=[],s=0,c=i-r;s<c;s+=16383)o.push(h(e,s,s+16383>c?c:s+16383));return 1===r?(t=e[i-1],n+=a[t>>2],n+=a[t<<4&63],n+="=="):2===r&&(t=(e[i-2]<<8)+e[i-1],n+=a[t>>10],n+=a[t>>4&63],n+=a[t<<2&63],n+="="),o.push(n),o.join("")}function m(e,t,i,r,n){var o,s,a=8*n-r-1,c=(1<<a)-1,l=c>>1,d=-7,u=i?n-1:0,h=i?-1:1,p=e[t+u];for(u+=h,o=p&(1<<-d)-1,p>>=-d,d+=a;d>0;o=256*o+e[t+u],u+=h,d-=8);for(s=o&(1<<-d)-1,o>>=-d,d+=r;d>0;s=256*s+e[t+u],u+=h,d-=8);if(0===o)o=1-l;else{if(o===c)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),o-=l}return(p?-1:1)*s*Math.pow(2,o-r)}function _(e,t,i,r,n,o){var s,a,c,l=8*o-n-1,d=(1<<l)-1,u=d>>1,h=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,m=r?1:-1,_=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=d):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+u>=1?h/c:h*Math.pow(2,1-u))*c>=2&&(s++,c/=2),s+u>=d?(a=0,s=d):s+u>=1?(a=(t*c-1)*Math.pow(2,n),s+=u):(a=t*Math.pow(2,u-1)*Math.pow(2,n),s=0));n>=8;e[i+p]=255&a,p+=m,a/=256,n-=8);for(s=s<<n|a,l+=n;l>0;e[i+p]=255&s,p+=m,s/=256,l-=8);e[i+p-m]|=128*_}var f={}.toString,g=Array.isArray||function(e){return"[object Array]"==f.call(e)};function E(){return y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function v(e,t){if(E()<t)throw new RangeError("Invalid typed array length");return y.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=y.prototype:(null===e&&(e=new y(t)),e.length=t),e}function y(e,t,i){if(!(y.TYPED_ARRAY_SUPPORT||this instanceof y))return new y(e,t,i);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return I(this,e)}return T(this,e,t,i)}function T(e,t,i,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,i,r){if(t.byteLength,i<0||t.byteLength<i)throw new RangeError("'offset' is out of bounds");if(t.byteLength<i+(r||0))throw new RangeError("'length' is out of bounds");return t=void 0===i&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,i):new Uint8Array(t,i,r),y.TYPED_ARRAY_SUPPORT?(e=t).__proto__=y.prototype:e=A(e,t),e}(e,t,i,r):"string"==typeof t?function(e,t,i){if("string"==typeof i&&""!==i||(i="utf8"),!y.isEncoding(i))throw new TypeError('"encoding" must be a valid string encoding');var r=0|C(t,i),n=(e=v(e,r)).write(t,i);return n!==r&&(e=e.slice(0,n)),e}(e,t,i):function(e,t){if(b(t)){var i=0|R(t.length);return 0===(e=v(e,i)).length||t.copy(e,0,0,i),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?v(e,0):A(e,t);if("Buffer"===t.type&&g(t.data))return A(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function S(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function I(e,t){if(S(t),e=v(e,t<0?0:0|R(t)),!y.TYPED_ARRAY_SUPPORT)for(var i=0;i<t;++i)e[i]=0;return e}function A(e,t){var i=t.length<0?0:0|R(t.length);e=v(e,i);for(var r=0;r<i;r+=1)e[r]=255&t[r];return e}function R(e){if(e>=E())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+E().toString(16)+" bytes");return 0|e}function b(e){return!(null==e||!e._isBuffer)}function C(e,t){if(b(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var i=e.length;if(0===i)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return ee(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return te(e).length;default:if(r)return ee(e).length;t=(""+t).toLowerCase(),r=!0}}function k(e,t,i){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return W(this,t,i);case"utf8":case"utf-8":return B(this,t,i);case"ascii":return H(this,t,i);case"latin1":case"binary":return j(this,t,i);case"base64":return U(this,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return z(this,t,i);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function w(e,t,i){var r=e[t];e[t]=e[i],e[i]=r}function N(e,t,i,r,n){if(0===e.length)return-1;if("string"==typeof i?(r=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=n?0:e.length-1),i<0&&(i=e.length+i),i>=e.length){if(n)return-1;i=e.length-1}else if(i<0){if(!n)return-1;i=0}if("string"==typeof t&&(t=y.from(t,r)),b(t))return 0===t.length?-1:D(e,t,i,r,n);if("number"==typeof t)return t&=255,y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(e,t,i):Uint8Array.prototype.lastIndexOf.call(e,t,i):D(e,[t],i,r,n);throw new TypeError("val must be string, number or Buffer")}function D(e,t,i,r,n){var o,s=1,a=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,i/=2}function l(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(n){var d=-1;for(o=i;o<a;o++)if(l(e,o)===l(t,-1===d?0:o-d)){if(-1===d&&(d=o),o-d+1===c)return d*s}else-1!==d&&(o-=o-d),d=-1}else for(i+c>a&&(i=a-c),o=i;o>=0;o--){for(var u=!0,h=0;h<c;h++)if(l(e,o+h)!==l(t,h)){u=!1;break}if(u)return o}return-1}function O(e,t,i,r){i=Number(i)||0;var n=e.length-i;r?(r=Number(r))>n&&(r=n):r=n;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;s<r;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[i+s]=a}return s}function L(e,t,i,r){return ie(ee(t,e.length-i),e,i,r)}function P(e,t,i,r){return ie(function(e){for(var t=[],i=0;i<e.length;++i)t.push(255&e.charCodeAt(i));return t}(t),e,i,r)}function M(e,t,i,r){return P(e,t,i,r)}function x(e,t,i,r){return ie(te(t),e,i,r)}function V(e,t,i,r){return ie(function(e,t){for(var i,r,n,o=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(i=e.charCodeAt(s))>>8,n=i%256,o.push(n),o.push(r);return o}(t,e.length-i),e,i,r)}function U(e,t,i){return 0===t&&i===e.length?p(e):p(e.slice(t,i))}function B(e,t,i){i=Math.min(e.length,i);for(var r=[],n=t;n<i;){var o,s,a,c,l=e[n],d=null,u=l>239?4:l>223?3:l>191?2:1;if(n+u<=i)switch(u){case 1:l<128&&(d=l);break;case 2:128==(192&(o=e[n+1]))&&(c=(31&l)<<6|63&o)>127&&(d=c);break;case 3:o=e[n+1],s=e[n+2],128==(192&o)&&128==(192&s)&&(c=(15&l)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(d=c);break;case 4:o=e[n+1],s=e[n+2],a=e[n+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&l)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(d=c)}null===d?(d=65533,u=1):d>65535&&(d-=65536,r.push(d>>>10&1023|55296),d=56320|1023&d),r.push(d),n+=u}return function(e){var t=e.length;if(t<=F)return String.fromCharCode.apply(String,e);for(var i="",r=0;r<t;)i+=String.fromCharCode.apply(String,e.slice(r,r+=F));return i}(r)}y.TYPED_ARRAY_SUPPORT=void 0===s.TYPED_ARRAY_SUPPORT||s.TYPED_ARRAY_SUPPORT,y.poolSize=8192,y._augment=function(e){return e.__proto__=y.prototype,e},y.from=function(e,t,i){return T(null,e,t,i)},y.TYPED_ARRAY_SUPPORT&&(y.prototype.__proto__=Uint8Array.prototype,y.__proto__=Uint8Array),y.alloc=function(e,t,i){return r=null,o=t,s=i,S(n=e),n<=0?v(r,n):void 0!==o?"string"==typeof s?v(r,n).fill(o,s):v(r,n).fill(o):v(r,n);var r,n,o,s},y.allocUnsafe=function(e){return I(null,e)},y.allocUnsafeSlow=function(e){return I(null,e)},y.isBuffer=re,y.compare=function(e,t){if(!b(e)||!b(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var i=e.length,r=t.length,n=0,o=Math.min(i,r);n<o;++n)if(e[n]!==t[n]){i=e[n],r=t[n];break}return i<r?-1:r<i?1:0},y.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},y.concat=function(e,t){if(!g(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return y.alloc(0);var i;if(void 0===t)for(t=0,i=0;i<e.length;++i)t+=e[i].length;var r=y.allocUnsafe(t),n=0;for(i=0;i<e.length;++i){var o=e[i];if(!b(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(r,n),n+=o.length}return r},y.byteLength=C,y.prototype._isBuffer=!0,y.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)w(this,t,t+1);return this},y.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)w(this,t,t+3),w(this,t+1,t+2);return this},y.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)w(this,t,t+7),w(this,t+1,t+6),w(this,t+2,t+5),w(this,t+3,t+4);return this},y.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?B(this,0,e):k.apply(this,arguments)},y.prototype.equals=function(e){if(!b(e))throw new TypeError("Argument must be a Buffer");return this===e||0===y.compare(this,e)},y.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},y.prototype.compare=function(e,t,i,r,n){if(!b(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===i&&(i=e?e.length:0),void 0===r&&(r=0),void 0===n&&(n=this.length),t<0||i>e.length||r<0||n>this.length)throw new RangeError("out of range index");if(r>=n&&t>=i)return 0;if(r>=n)return-1;if(t>=i)return 1;if(this===e)return 0;for(var o=(n>>>=0)-(r>>>=0),s=(i>>>=0)-(t>>>=0),a=Math.min(o,s),c=this.slice(r,n),l=e.slice(t,i),d=0;d<a;++d)if(c[d]!==l[d]){o=c[d],s=l[d];break}return o<s?-1:s<o?1:0},y.prototype.includes=function(e,t,i){return-1!==this.indexOf(e,t,i)},y.prototype.indexOf=function(e,t,i){return N(this,e,t,i,!0)},y.prototype.lastIndexOf=function(e,t,i){return N(this,e,t,i,!1)},y.prototype.write=function(e,t,i,r){if(void 0===t)r="utf8",i=this.length,t=0;else if(void 0===i&&"string"==typeof t)r=t,i=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(i)?(i|=0,void 0===r&&(r="utf8")):(r=i,i=void 0)}var n=this.length-t;if((void 0===i||i>n)&&(i=n),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return O(this,e,t,i);case"utf8":case"utf-8":return L(this,e,t,i);case"ascii":return P(this,e,t,i);case"latin1":case"binary":return M(this,e,t,i);case"base64":return x(this,e,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return V(this,e,t,i);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var F=4096;function H(e,t,i){var r="";i=Math.min(e.length,i);for(var n=t;n<i;++n)r+=String.fromCharCode(127&e[n]);return r}function j(e,t,i){var r="";i=Math.min(e.length,i);for(var n=t;n<i;++n)r+=String.fromCharCode(e[n]);return r}function W(e,t,i){var r=e.length;(!t||t<0)&&(t=0),(!i||i<0||i>r)&&(i=r);for(var n="",o=t;o<i;++o)n+=$(e[o]);return n}function z(e,t,i){for(var r=e.slice(t,i),n="",o=0;o<r.length;o+=2)n+=String.fromCharCode(r[o]+256*r[o+1]);return n}function G(e,t,i){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>i)throw new RangeError("Trying to access beyond buffer length")}function K(e,t,i,r,n,o){if(!b(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||t<o)throw new RangeError('"value" argument is out of bounds');if(i+r>e.length)throw new RangeError("Index out of range")}function Y(e,t,i,r){t<0&&(t=65535+t+1);for(var n=0,o=Math.min(e.length-i,2);n<o;++n)e[i+n]=(t&255<<8*(r?n:1-n))>>>8*(r?n:1-n)}function J(e,t,i,r){t<0&&(t=4294967295+t+1);for(var n=0,o=Math.min(e.length-i,4);n<o;++n)e[i+n]=t>>>8*(r?n:3-n)&255}function q(e,t,i,r,n,o){if(i+r>e.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function X(e,t,i,r,n){return n||q(e,0,i,4),_(e,t,i,r,23,4),i+4}function Q(e,t,i,r,n){return n||q(e,0,i,8),_(e,t,i,r,52,8),i+8}y.prototype.slice=function(e,t){var i,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),y.TYPED_ARRAY_SUPPORT)(i=this.subarray(e,t)).__proto__=y.prototype;else{var n=t-e;i=new y(n,void 0);for(var o=0;o<n;++o)i[o]=this[o+e]}return i},y.prototype.readUIntLE=function(e,t,i){e|=0,t|=0,i||G(e,t,this.length);for(var r=this[e],n=1,o=0;++o<t&&(n*=256);)r+=this[e+o]*n;return r},y.prototype.readUIntBE=function(e,t,i){e|=0,t|=0,i||G(e,t,this.length);for(var r=this[e+--t],n=1;t>0&&(n*=256);)r+=this[e+--t]*n;return r},y.prototype.readUInt8=function(e,t){return t||G(e,1,this.length),this[e]},y.prototype.readUInt16LE=function(e,t){return t||G(e,2,this.length),this[e]|this[e+1]<<8},y.prototype.readUInt16BE=function(e,t){return t||G(e,2,this.length),this[e]<<8|this[e+1]},y.prototype.readUInt32LE=function(e,t){return t||G(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},y.prototype.readUInt32BE=function(e,t){return t||G(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},y.prototype.readIntLE=function(e,t,i){e|=0,t|=0,i||G(e,t,this.length);for(var r=this[e],n=1,o=0;++o<t&&(n*=256);)r+=this[e+o]*n;return r>=(n*=128)&&(r-=Math.pow(2,8*t)),r},y.prototype.readIntBE=function(e,t,i){e|=0,t|=0,i||G(e,t,this.length);for(var r=t,n=1,o=this[e+--r];r>0&&(n*=256);)o+=this[e+--r]*n;return o>=(n*=128)&&(o-=Math.pow(2,8*t)),o},y.prototype.readInt8=function(e,t){return t||G(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},y.prototype.readInt16LE=function(e,t){t||G(e,2,this.length);var i=this[e]|this[e+1]<<8;return 32768&i?4294901760|i:i},y.prototype.readInt16BE=function(e,t){t||G(e,2,this.length);var i=this[e+1]|this[e]<<8;return 32768&i?4294901760|i:i},y.prototype.readInt32LE=function(e,t){return t||G(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},y.prototype.readInt32BE=function(e,t){return t||G(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},y.prototype.readFloatLE=function(e,t){return t||G(e,4,this.length),m(this,e,!0,23,4)},y.prototype.readFloatBE=function(e,t){return t||G(e,4,this.length),m(this,e,!1,23,4)},y.prototype.readDoubleLE=function(e,t){return t||G(e,8,this.length),m(this,e,!0,52,8)},y.prototype.readDoubleBE=function(e,t){return t||G(e,8,this.length),m(this,e,!1,52,8)},y.prototype.writeUIntLE=function(e,t,i,r){e=+e,t|=0,i|=0,r||K(this,e,t,i,Math.pow(2,8*i)-1,0);var n=1,o=0;for(this[t]=255&e;++o<i&&(n*=256);)this[t+o]=e/n&255;return t+i},y.prototype.writeUIntBE=function(e,t,i,r){e=+e,t|=0,i|=0,r||K(this,e,t,i,Math.pow(2,8*i)-1,0);var n=i-1,o=1;for(this[t+n]=255&e;--n>=0&&(o*=256);)this[t+n]=e/o&255;return t+i},y.prototype.writeUInt8=function(e,t,i){return e=+e,t|=0,i||K(this,e,t,1,255,0),y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},y.prototype.writeUInt16LE=function(e,t,i){return e=+e,t|=0,i||K(this,e,t,2,65535,0),y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Y(this,e,t,!0),t+2},y.prototype.writeUInt16BE=function(e,t,i){return e=+e,t|=0,i||K(this,e,t,2,65535,0),y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Y(this,e,t,!1),t+2},y.prototype.writeUInt32LE=function(e,t,i){return e=+e,t|=0,i||K(this,e,t,4,4294967295,0),y.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):J(this,e,t,!0),t+4},y.prototype.writeUInt32BE=function(e,t,i){return e=+e,t|=0,i||K(this,e,t,4,4294967295,0),y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):J(this,e,t,!1),t+4},y.prototype.writeIntLE=function(e,t,i,r){if(e=+e,t|=0,!r){var n=Math.pow(2,8*i-1);K(this,e,t,i,n-1,-n)}var o=0,s=1,a=0;for(this[t]=255&e;++o<i&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s|0)-a&255;return t+i},y.prototype.writeIntBE=function(e,t,i,r){if(e=+e,t|=0,!r){var n=Math.pow(2,8*i-1);K(this,e,t,i,n-1,-n)}var o=i-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s|0)-a&255;return t+i},y.prototype.writeInt8=function(e,t,i){return e=+e,t|=0,i||K(this,e,t,1,127,-128),y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},y.prototype.writeInt16LE=function(e,t,i){return e=+e,t|=0,i||K(this,e,t,2,32767,-32768),y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Y(this,e,t,!0),t+2},y.prototype.writeInt16BE=function(e,t,i){return e=+e,t|=0,i||K(this,e,t,2,32767,-32768),y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Y(this,e,t,!1),t+2},y.prototype.writeInt32LE=function(e,t,i){return e=+e,t|=0,i||K(this,e,t,4,2147483647,-2147483648),y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):J(this,e,t,!0),t+4},y.prototype.writeInt32BE=function(e,t,i){return e=+e,t|=0,i||K(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):J(this,e,t,!1),t+4},y.prototype.writeFloatLE=function(e,t,i){return X(this,e,t,!0,i)},y.prototype.writeFloatBE=function(e,t,i){return X(this,e,t,!1,i)},y.prototype.writeDoubleLE=function(e,t,i){return Q(this,e,t,!0,i)},y.prototype.writeDoubleBE=function(e,t,i){return Q(this,e,t,!1,i)},y.prototype.copy=function(e,t,i,r){if(i||(i=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<i&&(r=i),r===i)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-i&&(r=e.length-t+i);var n,o=r-i;if(this===e&&i<t&&t<r)for(n=o-1;n>=0;--n)e[n+t]=this[n+i];else if(o<1e3||!y.TYPED_ARRAY_SUPPORT)for(n=0;n<o;++n)e[n+t]=this[n+i];else Uint8Array.prototype.set.call(e,this.subarray(i,i+o),t);return o},y.prototype.fill=function(e,t,i,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,i=this.length):"string"==typeof i&&(r=i,i=this.length),1===e.length){var n=e.charCodeAt(0);n<256&&(e=n)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!y.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<i)throw new RangeError("Out of range index");if(i<=t)return this;var o;if(t>>>=0,i=void 0===i?this.length:i>>>0,e||(e=0),"number"==typeof e)for(o=t;o<i;++o)this[o]=e;else{var s=b(e)?e:ee(new y(e,r).toString()),a=s.length;for(o=0;o<i-t;++o)this[o+t]=s[o%a]}return this};var Z=/[^+\/0-9A-Za-z-_]/g;function $(e){return e<16?"0"+e.toString(16):e.toString(16)}function ee(e,t){var i;t=t||1/0;for(var r=e.length,n=null,o=[],s=0;s<r;++s){if((i=e.charCodeAt(s))>55295&&i<57344){if(!n){if(i>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}n=i;continue}if(i<56320){(t-=3)>-1&&o.push(239,191,189),n=i;continue}i=65536+(n-55296<<10|i-56320)}else n&&(t-=3)>-1&&o.push(239,191,189);if(n=null,i<128){if((t-=1)<0)break;o.push(i)}else if(i<2048){if((t-=2)<0)break;o.push(i>>6|192,63&i|128)}else if(i<65536){if((t-=3)<0)break;o.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return o}function te(e){return function(e){var t,i,r,n,o,s;d||u();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new l(3*a/4-o),r=o>0?a-4:a;var h=0;for(t=0,i=0;t<r;t+=4,i+=3)n=c[e.charCodeAt(t)]<<18|c[e.charCodeAt(t+1)]<<12|c[e.charCodeAt(t+2)]<<6|c[e.charCodeAt(t+3)],s[h++]=n>>16&255,s[h++]=n>>8&255,s[h++]=255&n;return 2===o?(n=c[e.charCodeAt(t)]<<2|c[e.charCodeAt(t+1)]>>4,s[h++]=255&n):1===o&&(n=c[e.charCodeAt(t)]<<10|c[e.charCodeAt(t+1)]<<4|c[e.charCodeAt(t+2)]>>2,s[h++]=n>>8&255,s[h++]=255&n),s}(function(e){if((e=(t=e,t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")).replace(Z,"")).length<2)return"";for(var t;e.length%4!=0;)e+="=";return e}(e))}function ie(e,t,i,r){for(var n=0;n<r&&!(n+i>=t.length||n>=e.length);++n)t[n+i]=e[n];return n}function re(e){return null!=e&&(!!e._isBuffer||ne(e)||"function"==typeof(t=e).readFloatLE&&"function"==typeof t.slice&&ne(t.slice(0,0)));var t}function ne(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function oe(e,t){return e(t={exports:{}},t.exports),t.exports}var se=oe((function(e,t){var i,r,n,o,s,a,c,l,d,u,h,p,m;e.exports=(i=i||(r=Math,n=Object.create||function(){function e(){}return function(t){var i;return e.prototype=t,i=new e,e.prototype=null,i}}(),s=(o={}).lib={},a=s.Base={extend:function(e){var t=n(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},c=s.WordArray=a.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||d).stringify(this)},concat:function(e){var t=this.words,i=e.words,r=this.sigBytes,n=e.sigBytes;if(this.clamp(),r%4)for(var o=0;o<n;o++){var s=i[o>>>2]>>>24-o%4*8&255;t[r+o>>>2]|=s<<24-(r+o)%4*8}else for(o=0;o<n;o+=4)t[r+o>>>2]=i[o>>>2];return this.sigBytes+=n,this},clamp:function(){var e=this.words,t=this.sigBytes;e[t>>>2]&=4294967295<<32-t%4*8,e.length=r.ceil(t/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t,i=[],n=function(e){var t=987654321,i=4294967295;return function(){var n=((t=36969*(65535&t)+(t>>16)&i)<<16)+(e=18e3*(65535&e)+(e>>16)&i)&i;return n/=4294967296,(n+=.5)*(r.random()>.5?1:-1)}},o=0;o<e;o+=4){var s=n(4294967296*(t||r.random()));t=987654071*s(),i.push(4294967296*s()|0)}return new c.init(i,e)}}),l=o.enc={},d=l.Hex={stringify:function(e){for(var t=e.words,i=e.sigBytes,r=[],n=0;n<i;n++){var o=t[n>>>2]>>>24-n%4*8&255;r.push((o>>>4).toString(16)),r.push((15&o).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,i=[],r=0;r<t;r+=2)i[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new c.init(i,t/2)}},u=l.Latin1={stringify:function(e){for(var t=e.words,i=e.sigBytes,r=[],n=0;n<i;n++){var o=t[n>>>2]>>>24-n%4*8&255;r.push(String.fromCharCode(o))}return r.join("")},parse:function(e){for(var t=e.length,i=[],r=0;r<t;r++)i[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new c.init(i,t)}},h=l.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},p=s.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=h.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(e){var t=this._data,i=t.words,n=t.sigBytes,o=this.blockSize,s=n/(4*o),a=(s=e?r.ceil(s):r.max((0|s)-this._minBufferSize,0))*o,l=r.min(4*a,n);if(a){for(var d=0;d<a;d+=o)this._doProcessBlock(i,d);var u=i.splice(0,a);t.sigBytes-=l}return new c.init(u,l)},clone:function(){var e=a.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),s.Hasher=p.extend({cfg:a.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){p.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,i){return new e.init(i).finalize(t)}},_createHmacHelper:function(e){return function(t,i){return new m.HMAC.init(e,i).finalize(t)}}}),m=o.algo={},o),i)})),ae=(oe((function(e,t){var i,r,n,o,s,a;e.exports=(n=(r=i=se).lib,o=n.Base,s=n.WordArray,(a=r.x64={}).Word=o.extend({init:function(e,t){this.high=e,this.low=t}}),a.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:8*e.length},toX32:function(){for(var e=this.words,t=e.length,i=[],r=0;r<t;r++){var n=e[r];i.push(n.high),i.push(n.low)}return s.create(i,this.sigBytes)},clone:function(){for(var e=o.clone.call(this),t=e.words=this.words.slice(0),i=t.length,r=0;r<i;r++)t[r]=t[r].clone();return e}}),i)})),oe((function(e,t){var i;e.exports=(i=se,function(){if("function"==typeof ArrayBuffer){var e=i.lib.WordArray,t=e.init;(e.init=function(e){if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),(e instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)&&(e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),e instanceof Uint8Array){for(var i=e.byteLength,r=[],n=0;n<i;n++)r[n>>>2]|=e[n]<<24-n%4*8;t.call(this,r,i)}else t.apply(this,arguments)}).prototype=e}}(),i.lib.WordArray)})),oe((function(e,t){var i;e.exports=(i=se,function(){var e=i,t=e.lib.WordArray,r=e.enc;function n(e){return e<<8&4278255360|e>>>8&16711935}r.Utf16=r.Utf16BE={stringify:function(e){for(var t=e.words,i=e.sigBytes,r=[],n=0;n<i;n+=2){var o=t[n>>>2]>>>16-n%4*8&65535;r.push(String.fromCharCode(o))}return r.join("")},parse:function(e){for(var i=e.length,r=[],n=0;n<i;n++)r[n>>>1]|=e.charCodeAt(n)<<16-n%2*16;return t.create(r,2*i)}},r.Utf16LE={stringify:function(e){for(var t=e.words,i=e.sigBytes,r=[],o=0;o<i;o+=2){var s=n(t[o>>>2]>>>16-o%4*8&65535);r.push(String.fromCharCode(s))}return r.join("")},parse:function(e){for(var i=e.length,r=[],o=0;o<i;o++)r[o>>>1]|=n(e.charCodeAt(o)<<16-o%2*16);return t.create(r,2*i)}}}(),i.enc.Utf16)})),oe((function(e,t){var i,r,n;e.exports=(n=(r=i=se).lib.WordArray,r.enc.Base64={stringify:function(e){var t=e.words,i=e.sigBytes,r=this._map;e.clamp();for(var n=[],o=0;o<i;o+=3)for(var s=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;a<4&&o+.75*a<i;a++)n.push(r.charAt(s>>>6*(3-a)&63));var c=r.charAt(64);if(c)for(;n.length%4;)n.push(c);return n.join("")},parse:function(e){var t=e.length,i=this._map,r=this._reverseMap;if(!r){r=this._reverseMap=[];for(var o=0;o<i.length;o++)r[i.charCodeAt(o)]=o}var s=i.charAt(64);if(s){var a=e.indexOf(s);-1!==a&&(t=a)}return function(e,t,i){for(var r=[],o=0,s=0;s<t;s++)if(s%4){var a=i[e.charCodeAt(s-1)]<<s%4*2,c=i[e.charCodeAt(s)]>>>6-s%4*2;r[o>>>2]|=(a|c)<<24-o%4*8,o++}return n.create(r,o)}(e,t,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},i.enc.Base64)})),oe((function(e,t){var i;e.exports=(i=se,function(e){var t=i,r=t.lib,n=r.WordArray,o=r.Hasher,s=t.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=s.MD5=o.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var i=0;i<16;i++){var r=t+i,n=e[r];e[r]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var o=this._hash.words,s=e[t+0],c=e[t+1],p=e[t+2],m=e[t+3],_=e[t+4],f=e[t+5],g=e[t+6],E=e[t+7],v=e[t+8],y=e[t+9],T=e[t+10],S=e[t+11],I=e[t+12],A=e[t+13],R=e[t+14],b=e[t+15],C=o[0],k=o[1],w=o[2],N=o[3];C=l(C,k,w,N,s,7,a[0]),N=l(N,C,k,w,c,12,a[1]),w=l(w,N,C,k,p,17,a[2]),k=l(k,w,N,C,m,22,a[3]),C=l(C,k,w,N,_,7,a[4]),N=l(N,C,k,w,f,12,a[5]),w=l(w,N,C,k,g,17,a[6]),k=l(k,w,N,C,E,22,a[7]),C=l(C,k,w,N,v,7,a[8]),N=l(N,C,k,w,y,12,a[9]),w=l(w,N,C,k,T,17,a[10]),k=l(k,w,N,C,S,22,a[11]),C=l(C,k,w,N,I,7,a[12]),N=l(N,C,k,w,A,12,a[13]),w=l(w,N,C,k,R,17,a[14]),C=d(C,k=l(k,w,N,C,b,22,a[15]),w,N,c,5,a[16]),N=d(N,C,k,w,g,9,a[17]),w=d(w,N,C,k,S,14,a[18]),k=d(k,w,N,C,s,20,a[19]),C=d(C,k,w,N,f,5,a[20]),N=d(N,C,k,w,T,9,a[21]),w=d(w,N,C,k,b,14,a[22]),k=d(k,w,N,C,_,20,a[23]),C=d(C,k,w,N,y,5,a[24]),N=d(N,C,k,w,R,9,a[25]),w=d(w,N,C,k,m,14,a[26]),k=d(k,w,N,C,v,20,a[27]),C=d(C,k,w,N,A,5,a[28]),N=d(N,C,k,w,p,9,a[29]),w=d(w,N,C,k,E,14,a[30]),C=u(C,k=d(k,w,N,C,I,20,a[31]),w,N,f,4,a[32]),N=u(N,C,k,w,v,11,a[33]),w=u(w,N,C,k,S,16,a[34]),k=u(k,w,N,C,R,23,a[35]),C=u(C,k,w,N,c,4,a[36]),N=u(N,C,k,w,_,11,a[37]),w=u(w,N,C,k,E,16,a[38]),k=u(k,w,N,C,T,23,a[39]),C=u(C,k,w,N,A,4,a[40]),N=u(N,C,k,w,s,11,a[41]),w=u(w,N,C,k,m,16,a[42]),k=u(k,w,N,C,g,23,a[43]),C=u(C,k,w,N,y,4,a[44]),N=u(N,C,k,w,I,11,a[45]),w=u(w,N,C,k,b,16,a[46]),C=h(C,k=u(k,w,N,C,p,23,a[47]),w,N,s,6,a[48]),N=h(N,C,k,w,E,10,a[49]),w=h(w,N,C,k,R,15,a[50]),k=h(k,w,N,C,f,21,a[51]),C=h(C,k,w,N,I,6,a[52]),N=h(N,C,k,w,m,10,a[53]),w=h(w,N,C,k,T,15,a[54]),k=h(k,w,N,C,c,21,a[55]),C=h(C,k,w,N,v,6,a[56]),N=h(N,C,k,w,b,10,a[57]),w=h(w,N,C,k,g,15,a[58]),k=h(k,w,N,C,A,21,a[59]),C=h(C,k,w,N,_,6,a[60]),N=h(N,C,k,w,S,10,a[61]),w=h(w,N,C,k,p,15,a[62]),k=h(k,w,N,C,y,21,a[63]),o[0]=o[0]+C|0,o[1]=o[1]+k|0,o[2]=o[2]+w|0,o[3]=o[3]+N|0},_doFinalize:function(){var t=this._data,i=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;i[n>>>5]|=128<<24-n%32;var o=e.floor(r/4294967296),s=r;i[15+(n+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),i[14+(n+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),t.sigBytes=4*(i.length+1),this._process();for(var a=this._hash,c=a.words,l=0;l<4;l++){var d=c[l];c[l]=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8)}return a},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function l(e,t,i,r,n,o,s){var a=e+(t&i|~t&r)+n+s;return(a<<o|a>>>32-o)+t}function d(e,t,i,r,n,o,s){var a=e+(t&r|i&~r)+n+s;return(a<<o|a>>>32-o)+t}function u(e,t,i,r,n,o,s){var a=e+(t^i^r)+n+s;return(a<<o|a>>>32-o)+t}function h(e,t,i,r,n,o,s){var a=e+(i^(t|~r))+n+s;return(a<<o|a>>>32-o)+t}t.MD5=o._createHelper(c),t.HmacMD5=o._createHmacHelper(c)}(Math),i.MD5)})),oe((function(e,t){var i,r,n,o,s,a,c,l;e.exports=(n=(r=i=se).lib,o=n.WordArray,s=n.Hasher,a=r.algo,c=[],l=a.SHA1=s.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var i=this._hash.words,r=i[0],n=i[1],o=i[2],s=i[3],a=i[4],l=0;l<80;l++){if(l<16)c[l]=0|e[t+l];else{var d=c[l-3]^c[l-8]^c[l-14]^c[l-16];c[l]=d<<1|d>>>31}var u=(r<<5|r>>>27)+a+c[l];u+=l<20?1518500249+(n&o|~n&s):l<40?1859775393+(n^o^s):l<60?(n&o|n&s|o&s)-1894007588:(n^o^s)-899497514,a=s,s=o,o=n<<30|n>>>2,n=r,r=u}i[0]=i[0]+r|0,i[1]=i[1]+n|0,i[2]=i[2]+o|0,i[3]=i[3]+s|0,i[4]=i[4]+a|0},_doFinalize:function(){var e=this._data,t=e.words,i=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(r+64>>>9<<4)]=Math.floor(i/4294967296),t[15+(r+64>>>9<<4)]=i,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}}),r.SHA1=s._createHelper(l),r.HmacSHA1=s._createHmacHelper(l),i.SHA1)})),oe((function(e,t){var i;e.exports=(i=se,function(e){var t=i,r=t.lib,n=r.WordArray,o=r.Hasher,s=t.algo,a=[],c=[];!function(){function t(t){for(var i=e.sqrt(t),r=2;r<=i;r++)if(!(t%r))return!1;return!0}function i(e){return 4294967296*(e-(0|e))|0}for(var r=2,n=0;n<64;)t(r)&&(n<8&&(a[n]=i(e.pow(r,.5))),c[n]=i(e.pow(r,1/3)),n++),r++}();var l=[],d=s.SHA256=o.extend({_doReset:function(){this._hash=new n.init(a.slice(0))},_doProcessBlock:function(e,t){for(var i=this._hash.words,r=i[0],n=i[1],o=i[2],s=i[3],a=i[4],d=i[5],u=i[6],h=i[7],p=0;p<64;p++){if(p<16)l[p]=0|e[t+p];else{var m=l[p-15],_=(m<<25|m>>>7)^(m<<14|m>>>18)^m>>>3,f=l[p-2],g=(f<<15|f>>>17)^(f<<13|f>>>19)^f>>>10;l[p]=_+l[p-7]+g+l[p-16]}var E=r&n^r&o^n&o,v=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),y=h+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&d^~a&u)+c[p]+l[p];h=u,u=d,d=a,a=s+y|0,s=o,o=n,n=r,r=y+(v+E)|0}i[0]=i[0]+r|0,i[1]=i[1]+n|0,i[2]=i[2]+o|0,i[3]=i[3]+s|0,i[4]=i[4]+a|0,i[5]=i[5]+d|0,i[6]=i[6]+u|0,i[7]=i[7]+h|0},_doFinalize:function(){var t=this._data,i=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;return i[n>>>5]|=128<<24-n%32,i[14+(n+64>>>9<<4)]=e.floor(r/4294967296),i[15+(n+64>>>9<<4)]=r,t.sigBytes=4*i.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=o._createHelper(d),t.HmacSHA256=o._createHmacHelper(d)}(Math),i.SHA256)})),oe((function(e,t){var i,r,n,o,s,a;e.exports=(n=(r=i=se).lib.WordArray,o=r.algo,s=o.SHA256,a=o.SHA224=s.extend({_doReset:function(){this._hash=new n.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var e=s._doFinalize.call(this);return e.sigBytes-=4,e}}),r.SHA224=s._createHelper(a),r.HmacSHA224=s._createHmacHelper(a),i.SHA224)})),oe((function(e,t){var i;e.exports=(i=se,function(){var e=i,t=e.lib.Hasher,r=e.x64,n=r.Word,o=r.WordArray,s=e.algo;function a(){return n.create.apply(n,arguments)}var c=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],l=[];!function(){for(var e=0;e<80;e++)l[e]=a()}();var d=s.SHA512=t.extend({_doReset:function(){this._hash=new o.init([new n.init(1779033703,4089235720),new n.init(3144134277,2227873595),new n.init(1013904242,4271175723),new n.init(2773480762,1595750129),new n.init(1359893119,2917565137),new n.init(2600822924,725511199),new n.init(528734635,4215389547),new n.init(1541459225,327033209)])},_doProcessBlock:function(e,t){for(var i=this._hash.words,r=i[0],n=i[1],o=i[2],s=i[3],a=i[4],d=i[5],u=i[6],h=i[7],p=r.high,m=r.low,_=n.high,f=n.low,g=o.high,E=o.low,v=s.high,y=s.low,T=a.high,S=a.low,I=d.high,A=d.low,R=u.high,b=u.low,C=h.high,k=h.low,w=p,N=m,D=_,O=f,L=g,P=E,M=v,x=y,V=T,U=S,B=I,F=A,H=R,j=b,W=C,z=k,G=0;G<80;G++){var K=l[G];if(G<16)var Y=K.high=0|e[t+2*G],J=K.low=0|e[t+2*G+1];else{var q=l[G-15],X=q.high,Q=q.low,Z=(X>>>1|Q<<31)^(X>>>8|Q<<24)^X>>>7,$=(Q>>>1|X<<31)^(Q>>>8|X<<24)^(Q>>>7|X<<25),ee=l[G-2],te=ee.high,ie=ee.low,re=(te>>>19|ie<<13)^(te<<3|ie>>>29)^te>>>6,ne=(ie>>>19|te<<13)^(ie<<3|te>>>29)^(ie>>>6|te<<26),oe=l[G-7],se=oe.high,ae=oe.low,ce=l[G-16],le=ce.high,de=ce.low;Y=(Y=(Y=Z+se+((J=$+ae)>>>0<$>>>0?1:0))+re+((J+=ne)>>>0<ne>>>0?1:0))+le+((J+=de)>>>0<de>>>0?1:0),K.high=Y,K.low=J}var ue,he=V&B^~V&H,pe=U&F^~U&j,me=w&D^w&L^D&L,_e=N&O^N&P^O&P,fe=(w>>>28|N<<4)^(w<<30|N>>>2)^(w<<25|N>>>7),ge=(N>>>28|w<<4)^(N<<30|w>>>2)^(N<<25|w>>>7),Ee=(V>>>14|U<<18)^(V>>>18|U<<14)^(V<<23|U>>>9),ve=(U>>>14|V<<18)^(U>>>18|V<<14)^(U<<23|V>>>9),ye=c[G],Te=ye.high,Se=ye.low,Ie=W+Ee+((ue=z+ve)>>>0<z>>>0?1:0),Ae=ge+_e;W=H,z=j,H=B,j=F,B=V,F=U,V=M+(Ie=(Ie=(Ie=Ie+he+((ue+=pe)>>>0<pe>>>0?1:0))+Te+((ue+=Se)>>>0<Se>>>0?1:0))+Y+((ue+=J)>>>0<J>>>0?1:0))+((U=x+ue|0)>>>0<x>>>0?1:0)|0,M=L,x=P,L=D,P=O,D=w,O=N,w=Ie+(fe+me+(Ae>>>0<ge>>>0?1:0))+((N=ue+Ae|0)>>>0<ue>>>0?1:0)|0}m=r.low=m+N,r.high=p+w+(m>>>0<N>>>0?1:0),f=n.low=f+O,n.high=_+D+(f>>>0<O>>>0?1:0),E=o.low=E+P,o.high=g+L+(E>>>0<P>>>0?1:0),y=s.low=y+x,s.high=v+M+(y>>>0<x>>>0?1:0),S=a.low=S+U,a.high=T+V+(S>>>0<U>>>0?1:0),A=d.low=A+F,d.high=I+B+(A>>>0<F>>>0?1:0),b=u.low=b+j,u.high=R+H+(b>>>0<j>>>0?1:0),k=h.low=k+z,h.high=C+W+(k>>>0<z>>>0?1:0)},_doFinalize:function(){var e=this._data,t=e.words,i=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[30+(r+128>>>10<<5)]=Math.floor(i/4294967296),t[31+(r+128>>>10<<5)]=i,e.sigBytes=4*t.length,this._process(),this._hash.toX32()},clone:function(){var e=t.clone.call(this);return e._hash=this._hash.clone(),e},blockSize:32});e.SHA512=t._createHelper(d),e.HmacSHA512=t._createHmacHelper(d)}(),i.SHA512)})),oe((function(e,t){var i,r,n,o,s,a,c,l;e.exports=(n=(r=i=se).x64,o=n.Word,s=n.WordArray,a=r.algo,c=a.SHA512,l=a.SHA384=c.extend({_doReset:function(){this._hash=new s.init([new o.init(3418070365,3238371032),new o.init(1654270250,914150663),new o.init(2438529370,812702999),new o.init(355462360,4144912697),new o.init(1731405415,4290775857),new o.init(2394180231,1750603025),new o.init(3675008525,1694076839),new o.init(1203062813,3204075428)])},_doFinalize:function(){var e=c._doFinalize.call(this);return e.sigBytes-=16,e}}),r.SHA384=c._createHelper(l),r.HmacSHA384=c._createHmacHelper(l),i.SHA384)})),oe((function(e,t){var i;e.exports=(i=se,function(e){var t=i,r=t.lib,n=r.WordArray,o=r.Hasher,s=t.x64.Word,a=t.algo,c=[],l=[],d=[];!function(){for(var e=1,t=0,i=0;i<24;i++){c[e+5*t]=(i+1)*(i+2)/2%64;var r=(2*e+3*t)%5;e=t%5,t=r}for(e=0;e<5;e++)for(t=0;t<5;t++)l[e+5*t]=t+(2*e+3*t)%5*5;for(var n=1,o=0;o<24;o++){for(var a=0,u=0,h=0;h<7;h++){if(1&n){var p=(1<<h)-1;p<32?u^=1<<p:a^=1<<p-32}128&n?n=n<<1^113:n<<=1}d[o]=s.create(a,u)}}();var u=[];!function(){for(var e=0;e<25;e++)u[e]=s.create()}();var h=a.SHA3=o.extend({cfg:o.cfg.extend({outputLength:512}),_doReset:function(){for(var e=this._state=[],t=0;t<25;t++)e[t]=new s.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(e,t){for(var i=this._state,r=this.blockSize/2,n=0;n<r;n++){var o=e[t+2*n],s=e[t+2*n+1];o=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),s=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),(k=i[n]).high^=s,k.low^=o}for(var a=0;a<24;a++){for(var h=0;h<5;h++){for(var p=0,m=0,_=0;_<5;_++)p^=(k=i[h+5*_]).high,m^=k.low;var f=u[h];f.high=p,f.low=m}for(h=0;h<5;h++){var g=u[(h+4)%5],E=u[(h+1)%5],v=E.high,y=E.low;for(p=g.high^(v<<1|y>>>31),m=g.low^(y<<1|v>>>31),_=0;_<5;_++)(k=i[h+5*_]).high^=p,k.low^=m}for(var T=1;T<25;T++){var S=(k=i[T]).high,I=k.low,A=c[T];A<32?(p=S<<A|I>>>32-A,m=I<<A|S>>>32-A):(p=I<<A-32|S>>>64-A,m=S<<A-32|I>>>64-A);var R=u[l[T]];R.high=p,R.low=m}var b=u[0],C=i[0];for(b.high=C.high,b.low=C.low,h=0;h<5;h++)for(_=0;_<5;_++){var k=i[T=h+5*_],w=u[T],N=u[(h+1)%5+5*_],D=u[(h+2)%5+5*_];k.high=w.high^~N.high&D.high,k.low=w.low^~N.low&D.low}k=i[0];var O=d[a];k.high^=O.high,k.low^=O.low}},_doFinalize:function(){var t=this._data,i=t.words,r=(this._nDataBytes,8*t.sigBytes),o=32*this.blockSize;i[r>>>5]|=1<<24-r%32,i[(e.ceil((r+1)/o)*o>>>5)-1]|=128,t.sigBytes=4*i.length,this._process();for(var s=this._state,a=this.cfg.outputLength/8,c=a/8,l=[],d=0;d<c;d++){var u=s[d],h=u.high,p=u.low;h=16711935&(h<<8|h>>>24)|4278255360&(h<<24|h>>>8),p=16711935&(p<<8|p>>>24)|4278255360&(p<<24|p>>>8),l.push(p),l.push(h)}return new n.init(l,a)},clone:function(){for(var e=o.clone.call(this),t=e._state=this._state.slice(0),i=0;i<25;i++)t[i]=t[i].clone();return e}});t.SHA3=o._createHelper(h),t.HmacSHA3=o._createHmacHelper(h)}(Math),i.SHA3)})),oe((function(e,t){var i;e.exports=(i=se,function(e){var t=i,r=t.lib,n=r.WordArray,o=r.Hasher,s=t.algo,a=n.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),c=n.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),l=n.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),d=n.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),u=n.create([0,1518500249,1859775393,2400959708,2840853838]),h=n.create([1352829926,1548603684,1836072691,2053994217,0]),p=s.RIPEMD160=o.extend({_doReset:function(){this._hash=n.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var i=0;i<16;i++){var r=t+i,n=e[r];e[r]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var o,s,p,y,T,S,I,A,R,b,C,k=this._hash.words,w=u.words,N=h.words,D=a.words,O=c.words,L=l.words,P=d.words;for(S=o=k[0],I=s=k[1],A=p=k[2],R=y=k[3],b=T=k[4],i=0;i<80;i+=1)C=o+e[t+D[i]]|0,C+=i<16?m(s,p,y)+w[0]:i<32?_(s,p,y)+w[1]:i<48?f(s,p,y)+w[2]:i<64?g(s,p,y)+w[3]:E(s,p,y)+w[4],C=(C=v(C|=0,L[i]))+T|0,o=T,T=y,y=v(p,10),p=s,s=C,C=S+e[t+O[i]]|0,C+=i<16?E(I,A,R)+N[0]:i<32?g(I,A,R)+N[1]:i<48?f(I,A,R)+N[2]:i<64?_(I,A,R)+N[3]:m(I,A,R)+N[4],C=(C=v(C|=0,P[i]))+b|0,S=b,b=R,R=v(A,10),A=I,I=C;C=k[1]+p+R|0,k[1]=k[2]+y+b|0,k[2]=k[3]+T+S|0,k[3]=k[4]+o+I|0,k[4]=k[0]+s+A|0,k[0]=C},_doFinalize:function(){var e=this._data,t=e.words,i=8*this._nDataBytes,r=8*e.sigBytes;t[r>>>5]|=128<<24-r%32,t[14+(r+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),e.sigBytes=4*(t.length+1),this._process();for(var n=this._hash,o=n.words,s=0;s<5;s++){var a=o[s];o[s]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}return n},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function m(e,t,i){return e^t^i}function _(e,t,i){return e&t|~e&i}function f(e,t,i){return(e|~t)^i}function g(e,t,i){return e&i|t&~i}function E(e,t,i){return e^(t|~i)}function v(e,t){return e<<t|e>>>32-t}t.RIPEMD160=o._createHelper(p),t.HmacRIPEMD160=o._createHmacHelper(p)}(),i.RIPEMD160)})),oe((function(e,t){var i,r,n,o;e.exports=(r=(i=se).lib.Base,n=i.enc,o=n.Utf8,void(i.algo.HMAC=r.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=o.parse(t));var i=e.blockSize,r=4*i;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var n=this._oKey=t.clone(),s=this._iKey=t.clone(),a=n.words,c=s.words,l=0;l<i;l++)a[l]^=1549556828,c[l]^=909522486;n.sigBytes=s.sigBytes=r,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,i=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(i))}})))})),oe((function(e,t){var i,r,n,o,s,a,c,l,d;e.exports=(o=(n=(r=i=se).lib).Base,s=n.WordArray,c=(a=r.algo).SHA1,l=a.HMAC,d=a.PBKDF2=o.extend({cfg:o.extend({keySize:4,hasher:c,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var i=this.cfg,r=l.create(i.hasher,e),n=s.create(),o=s.create([1]),a=n.words,c=o.words,d=i.keySize,u=i.iterations;a.length<d;){var h=r.update(t).finalize(o);r.reset();for(var p=h.words,m=p.length,_=h,f=1;f<u;f++){_=r.finalize(_),r.reset();for(var g=_.words,E=0;E<m;E++)p[E]^=g[E]}n.concat(h),c[0]++}return n.sigBytes=4*d,n}}),r.PBKDF2=function(e,t,i){return d.create(i).compute(e,t)},i.PBKDF2)})),oe((function(e,t){var i,r,n,o,s,a,c,l;e.exports=(o=(n=(r=i=se).lib).Base,s=n.WordArray,c=(a=r.algo).MD5,l=a.EvpKDF=o.extend({cfg:o.extend({keySize:4,hasher:c,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var i=this.cfg,r=i.hasher.create(),n=s.create(),o=n.words,a=i.keySize,c=i.iterations;o.length<a;){l&&r.update(l);var l=r.update(e).finalize(t);r.reset();for(var d=1;d<c;d++)l=r.finalize(l),r.reset();n.concat(l)}return n.sigBytes=4*a,n}}),r.EvpKDF=function(e,t,i){return l.create(i).compute(e,t)},i.EvpKDF)})),oe((function(e,t){var i,r,n,o,s,a,c,l,d,u,h,p,m,_,f,g,E,v,y,T,S,I,A;e.exports=void((i=se).lib.Cipher||(r=i,n=r.lib,o=n.Base,s=n.WordArray,a=n.BufferedBlockAlgorithm,c=r.enc,c.Utf8,l=c.Base64,d=r.algo,u=d.EvpKDF,h=n.Cipher=a.extend({cfg:o.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,i){this.cfg=this.cfg.extend(i),this._xformMode=e,this._key=t,this.reset()},reset:function(){a.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?A:T}return function(t){return{encrypt:function(i,r,n){return e(r).encrypt(t,i,r,n)},decrypt:function(i,r,n){return e(r).decrypt(t,i,r,n)}}}}()}),n.StreamCipher=h.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),p=r.mode={},m=n.BlockCipherMode=o.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),_=p.CBC=function(){var e=m.extend();function t(e,t,i){var r=this._iv;if(r){var n=r;this._iv=undefined}else n=this._prevBlock;for(var o=0;o<i;o++)e[t+o]^=n[o]}return e.Encryptor=e.extend({processBlock:function(e,i){var r=this._cipher,n=r.blockSize;t.call(this,e,i,n),r.encryptBlock(e,i),this._prevBlock=e.slice(i,i+n)}}),e.Decryptor=e.extend({processBlock:function(e,i){var r=this._cipher,n=r.blockSize,o=e.slice(i,i+n);r.decryptBlock(e,i),t.call(this,e,i,n),this._prevBlock=o}}),e}(),f=r.pad={},g=f.Pkcs7={pad:function(e,t){for(var i=4*t,r=i-e.sigBytes%i,n=r<<24|r<<16|r<<8|r,o=[],a=0;a<r;a+=4)o.push(n);var c=s.create(o,r);e.concat(c)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},n.BlockCipher=h.extend({cfg:h.cfg.extend({mode:_,padding:g}),reset:function(){h.reset.call(this);var e=this.cfg,t=e.iv,i=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var r=i.createEncryptor;else{r=i.createDecryptor;this._minBufferSize=1}this._mode&&this._mode.__creator==r?this._mode.init(this,t&&t.words):(this._mode=r.call(i,this,t&&t.words),this._mode.__creator=r)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){e.pad(this._data,this.blockSize);var t=this._process(!0)}else{t=this._process(!0);e.unpad(t)}return t},blockSize:4}),E=n.CipherParams=o.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),v=r.format={},y=v.OpenSSL={stringify:function(e){var t=e.ciphertext,i=e.salt;if(i)var r=s.create([1398893684,1701076831]).concat(i).concat(t);else r=t;return r.toString(l)},parse:function(e){var t=l.parse(e),i=t.words;if(1398893684==i[0]&&1701076831==i[1]){var r=s.create(i.slice(2,4));i.splice(0,4),t.sigBytes-=16}return E.create({ciphertext:t,salt:r})}},T=n.SerializableCipher=o.extend({cfg:o.extend({format:y}),encrypt:function(e,t,i,r){r=this.cfg.extend(r);var n=e.createEncryptor(i,r),o=n.finalize(t),s=n.cfg;return E.create({ciphertext:o,key:i,iv:s.iv,algorithm:e,mode:s.mode,padding:s.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,i,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(i,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),S=r.kdf={},I=S.OpenSSL={execute:function(e,t,i,r){r||(r=s.random(8));var n=u.create({keySize:t+i}).compute(e,r),o=s.create(n.words.slice(t),4*i);return n.sigBytes=4*t,E.create({key:n,iv:o,salt:r})}},A=n.PasswordBasedCipher=T.extend({cfg:T.cfg.extend({kdf:I}),encrypt:function(e,t,i,r){var n=(r=this.cfg.extend(r)).kdf.execute(i,e.keySize,e.ivSize);r.iv=n.iv;var o=T.encrypt.call(this,e,t,n.key,r);return o.mixIn(n),o},decrypt:function(e,t,i,r){r=this.cfg.extend(r),t=this._parse(t,r.format);var n=r.kdf.execute(i,e.keySize,e.ivSize,t.salt);return r.iv=n.iv,T.decrypt.call(this,e,t,n.key,r)}})))})),oe((function(e,t){var i;e.exports=((i=se).mode.CFB=function(){var e=i.lib.BlockCipherMode.extend();function t(e,t,i,r){var n=this._iv;if(n){var o=n.slice(0);this._iv=void 0}else o=this._prevBlock;r.encryptBlock(o,0);for(var s=0;s<i;s++)e[t+s]^=o[s]}return e.Encryptor=e.extend({processBlock:function(e,i){var r=this._cipher,n=r.blockSize;t.call(this,e,i,n,r),this._prevBlock=e.slice(i,i+n)}}),e.Decryptor=e.extend({processBlock:function(e,i){var r=this._cipher,n=r.blockSize,o=e.slice(i,i+n);t.call(this,e,i,n,r),this._prevBlock=o}}),e}(),i.mode.CFB)})),oe((function(e,t){var i,r,n;e.exports=((i=se).mode.CTR=(n=(r=i.lib.BlockCipherMode.extend()).Encryptor=r.extend({processBlock:function(e,t){var i=this._cipher,r=i.blockSize,n=this._iv,o=this._counter;n&&(o=this._counter=n.slice(0),this._iv=void 0);var s=o.slice(0);i.encryptBlock(s,0),o[r-1]=o[r-1]+1|0;for(var a=0;a<r;a++)e[t+a]^=s[a]}}),r.Decryptor=n,r),i.mode.CTR)})),oe((function(e,t){var i;e.exports=((i=se).mode.CTRGladman=function(){var e=i.lib.BlockCipherMode.extend();function t(e){if(255&~(e>>24))e+=1<<24;else{var t=e>>16&255,i=e>>8&255,r=255&e;255===t?(t=0,255===i?(i=0,255===r?r=0:++r):++i):++t,e=0,e+=t<<16,e+=i<<8,e+=r}return e}var r=e.Encryptor=e.extend({processBlock:function(e,i){var r,n=this._cipher,o=n.blockSize,s=this._iv,a=this._counter;s&&(a=this._counter=s.slice(0),this._iv=void 0),0===((r=a)[0]=t(r[0]))&&(r[1]=t(r[1]));var c=a.slice(0);n.encryptBlock(c,0);for(var l=0;l<o;l++)e[i+l]^=c[l]}});return e.Decryptor=r,e}(),i.mode.CTRGladman)})),oe((function(e,t){var i,r,n;e.exports=((i=se).mode.OFB=(n=(r=i.lib.BlockCipherMode.extend()).Encryptor=r.extend({processBlock:function(e,t){var i=this._cipher,r=i.blockSize,n=this._iv,o=this._keystream;n&&(o=this._keystream=n.slice(0),this._iv=void 0),i.encryptBlock(o,0);for(var s=0;s<r;s++)e[t+s]^=o[s]}}),r.Decryptor=n,r),i.mode.OFB)})),oe((function(e,t){var i,r;e.exports=((i=se).mode.ECB=((r=i.lib.BlockCipherMode.extend()).Encryptor=r.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),r.Decryptor=r.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),r),i.mode.ECB)})),oe((function(e,t){var i;e.exports=((i=se).pad.AnsiX923={pad:function(e,t){var i=e.sigBytes,r=4*t,n=r-i%r,o=i+n-1;e.clamp(),e.words[o>>>2]|=n<<24-o%4*8,e.sigBytes+=n},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},i.pad.Ansix923)})),oe((function(e,t){var i;e.exports=((i=se).pad.Iso10126={pad:function(e,t){var r=4*t,n=r-e.sigBytes%r;e.concat(i.lib.WordArray.random(n-1)).concat(i.lib.WordArray.create([n<<24],1))},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},i.pad.Iso10126)})),oe((function(e,t){var i;e.exports=((i=se).pad.Iso97971={pad:function(e,t){e.concat(i.lib.WordArray.create([2147483648],1)),i.pad.ZeroPadding.pad(e,t)},unpad:function(e){i.pad.ZeroPadding.unpad(e),e.sigBytes--}},i.pad.Iso97971)})),oe((function(e,t){var i;e.exports=((i=se).pad.ZeroPadding={pad:function(e,t){var i=4*t;e.clamp(),e.sigBytes+=i-(e.sigBytes%i||i)},unpad:function(e){for(var t=e.words,i=e.sigBytes-1;!(t[i>>>2]>>>24-i%4*8&255);)i--;e.sigBytes=i+1}},i.pad.ZeroPadding)})),oe((function(e,t){var i;e.exports=((i=se).pad.NoPadding={pad:function(){},unpad:function(){}},i.pad.NoPadding)})),oe((function(e,t){var i,r,n,o;e.exports=(n=(r=i=se).lib.CipherParams,o=r.enc.Hex,r.format.Hex={stringify:function(e){return e.ciphertext.toString(o)},parse:function(e){var t=o.parse(e);return n.create({ciphertext:t})}},i.format.Hex)})),oe((function(e,t){var i;e.exports=(i=se,function(){var e=i,t=e.lib.BlockCipher,r=e.algo,n=[],o=[],s=[],a=[],c=[],l=[],d=[],u=[],h=[],p=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;var i=0,r=0;for(t=0;t<256;t++){var m=r^r<<1^r<<2^r<<3^r<<4;m=m>>>8^255&m^99,n[i]=m,o[m]=i;var _=e[i],f=e[_],g=e[f],E=257*e[m]^16843008*m;s[i]=E<<24|E>>>8,a[i]=E<<16|E>>>16,c[i]=E<<8|E>>>24,l[i]=E,E=16843009*g^65537*f^257*_^16843008*i,d[m]=E<<24|E>>>8,u[m]=E<<16|E>>>16,h[m]=E<<8|E>>>24,p[m]=E,i?(i=_^e[e[e[g^_]]],r^=e[e[r]]):i=r=1}}();var m=[0,1,2,4,8,16,32,64,128,27,54],_=r.AES=t.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,i=e.sigBytes/4,r=4*((this._nRounds=i+6)+1),o=this._keySchedule=[],s=0;s<r;s++)if(s<i)o[s]=t[s];else{var a=o[s-1];s%i?i>6&&s%i==4&&(a=n[a>>>24]<<24|n[a>>>16&255]<<16|n[a>>>8&255]<<8|n[255&a]):(a=n[(a=a<<8|a>>>24)>>>24]<<24|n[a>>>16&255]<<16|n[a>>>8&255]<<8|n[255&a],a^=m[s/i|0]<<24),o[s]=o[s-i]^a}for(var c=this._invKeySchedule=[],l=0;l<r;l++)s=r-l,a=l%4?o[s]:o[s-4],c[l]=l<4||s<=4?a:d[n[a>>>24]]^u[n[a>>>16&255]]^h[n[a>>>8&255]]^p[n[255&a]]}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,s,a,c,l,n)},decryptBlock:function(e,t){var i=e[t+1];e[t+1]=e[t+3],e[t+3]=i,this._doCryptBlock(e,t,this._invKeySchedule,d,u,h,p,o),i=e[t+1],e[t+1]=e[t+3],e[t+3]=i},_doCryptBlock:function(e,t,i,r,n,o,s,a){for(var c=this._nRounds,l=e[t]^i[0],d=e[t+1]^i[1],u=e[t+2]^i[2],h=e[t+3]^i[3],p=4,m=1;m<c;m++){var _=r[l>>>24]^n[d>>>16&255]^o[u>>>8&255]^s[255&h]^i[p++],f=r[d>>>24]^n[u>>>16&255]^o[h>>>8&255]^s[255&l]^i[p++],g=r[u>>>24]^n[h>>>16&255]^o[l>>>8&255]^s[255&d]^i[p++],E=r[h>>>24]^n[l>>>16&255]^o[d>>>8&255]^s[255&u]^i[p++];l=_,d=f,u=g,h=E}_=(a[l>>>24]<<24|a[d>>>16&255]<<16|a[u>>>8&255]<<8|a[255&h])^i[p++],f=(a[d>>>24]<<24|a[u>>>16&255]<<16|a[h>>>8&255]<<8|a[255&l])^i[p++],g=(a[u>>>24]<<24|a[h>>>16&255]<<16|a[l>>>8&255]<<8|a[255&d])^i[p++],E=(a[h>>>24]<<24|a[l>>>16&255]<<16|a[d>>>8&255]<<8|a[255&u])^i[p++],e[t]=_,e[t+1]=f,e[t+2]=g,e[t+3]=E},keySize:8});e.AES=t._createHelper(_)}(),i.AES)})),oe((function(e,t){var i;e.exports=(i=se,function(){var e=i,t=e.lib,r=t.WordArray,n=t.BlockCipher,o=e.algo,s=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],a=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],c=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],l=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],d=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],u=o.DES=n.extend({_doReset:function(){for(var e=this._key.words,t=[],i=0;i<56;i++){var r=s[i]-1;t[i]=e[r>>>5]>>>31-r%32&1}for(var n=this._subKeys=[],o=0;o<16;o++){var l=n[o]=[],d=c[o];for(i=0;i<24;i++)l[i/6|0]|=t[(a[i]-1+d)%28]<<31-i%6,l[4+(i/6|0)]|=t[28+(a[i+24]-1+d)%28]<<31-i%6;for(l[0]=l[0]<<1|l[0]>>>31,i=1;i<7;i++)l[i]=l[i]>>>4*(i-1)+3;l[7]=l[7]<<5|l[7]>>>27}var u=this._invSubKeys=[];for(i=0;i<16;i++)u[i]=n[15-i]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._subKeys)},decryptBlock:function(e,t){this._doCryptBlock(e,t,this._invSubKeys)},_doCryptBlock:function(e,t,i){this._lBlock=e[t],this._rBlock=e[t+1],h.call(this,4,252645135),h.call(this,16,65535),p.call(this,2,858993459),p.call(this,8,16711935),h.call(this,1,1431655765);for(var r=0;r<16;r++){for(var n=i[r],o=this._lBlock,s=this._rBlock,a=0,c=0;c<8;c++)a|=l[c][((s^n[c])&d[c])>>>0];this._lBlock=s,this._rBlock=o^a}var u=this._lBlock;this._lBlock=this._rBlock,this._rBlock=u,h.call(this,1,1431655765),p.call(this,8,16711935),p.call(this,2,858993459),h.call(this,16,65535),h.call(this,4,252645135),e[t]=this._lBlock,e[t+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function h(e,t){var i=(this._lBlock>>>e^this._rBlock)&t;this._rBlock^=i,this._lBlock^=i<<e}function p(e,t){var i=(this._rBlock>>>e^this._lBlock)&t;this._lBlock^=i,this._rBlock^=i<<e}e.DES=n._createHelper(u);var m=o.TripleDES=n.extend({_doReset:function(){var e=this._key.words;this._des1=u.createEncryptor(r.create(e.slice(0,2))),this._des2=u.createEncryptor(r.create(e.slice(2,4))),this._des3=u.createEncryptor(r.create(e.slice(4,6)))},encryptBlock:function(e,t){this._des1.encryptBlock(e,t),this._des2.decryptBlock(e,t),this._des3.encryptBlock(e,t)},decryptBlock:function(e,t){this._des3.decryptBlock(e,t),this._des2.encryptBlock(e,t),this._des1.decryptBlock(e,t)},keySize:6,ivSize:2,blockSize:2});e.TripleDES=n._createHelper(m)}(),i.TripleDES)})),oe((function(e,t){var i;e.exports=(i=se,function(){var e=i,t=e.lib.StreamCipher,r=e.algo,n=r.RC4=t.extend({_doReset:function(){for(var e=this._key,t=e.words,i=e.sigBytes,r=this._S=[],n=0;n<256;n++)r[n]=n;n=0;for(var o=0;n<256;n++){var s=n%i,a=t[s>>>2]>>>24-s%4*8&255;o=(o+r[n]+a)%256;var c=r[n];r[n]=r[o],r[o]=c}this._i=this._j=0},_doProcessBlock:function(e,t){e[t]^=o.call(this)},keySize:8,ivSize:0});function o(){for(var e=this._S,t=this._i,i=this._j,r=0,n=0;n<4;n++){i=(i+e[t=(t+1)%256])%256;var o=e[t];e[t]=e[i],e[i]=o,r|=e[(e[t]+e[i])%256]<<24-8*n}return this._i=t,this._j=i,r}e.RC4=t._createHelper(n);var s=r.RC4Drop=n.extend({cfg:n.cfg.extend({drop:192}),_doReset:function(){n._doReset.call(this);for(var e=this.cfg.drop;e>0;e--)o.call(this)}});e.RC4Drop=t._createHelper(s)}(),i.RC4)})),oe((function(e,t){var i;e.exports=(i=se,function(){var e=i,t=e.lib.StreamCipher,r=e.algo,n=[],o=[],s=[],a=r.Rabbit=t.extend({_doReset:function(){for(var e=this._key.words,t=this.cfg.iv,i=0;i<4;i++)e[i]=16711935&(e[i]<<8|e[i]>>>24)|4278255360&(e[i]<<24|e[i]>>>8);var r=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],n=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];for(this._b=0,i=0;i<4;i++)c.call(this);for(i=0;i<8;i++)n[i]^=r[i+4&7];if(t){var o=t.words,s=o[0],a=o[1],l=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),d=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),u=l>>>16|4294901760&d,h=d<<16|65535&l;for(n[0]^=l,n[1]^=u,n[2]^=d,n[3]^=h,n[4]^=l,n[5]^=u,n[6]^=d,n[7]^=h,i=0;i<4;i++)c.call(this)}},_doProcessBlock:function(e,t){var i=this._X;c.call(this),n[0]=i[0]^i[5]>>>16^i[3]<<16,n[1]=i[2]^i[7]>>>16^i[5]<<16,n[2]=i[4]^i[1]>>>16^i[7]<<16,n[3]=i[6]^i[3]>>>16^i[1]<<16;for(var r=0;r<4;r++)n[r]=16711935&(n[r]<<8|n[r]>>>24)|4278255360&(n[r]<<24|n[r]>>>8),e[t+r]^=n[r]},blockSize:4,ivSize:2});function c(){for(var e=this._X,t=this._C,i=0;i<8;i++)o[i]=t[i];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<o[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<o[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<o[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<o[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<o[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<o[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<o[6]>>>0?1:0)|0,this._b=t[7]>>>0<o[7]>>>0?1:0,i=0;i<8;i++){var r=e[i]+t[i],n=65535&r,a=r>>>16,c=((n*n>>>17)+n*a>>>15)+a*a,l=((4294901760&r)*r|0)+((65535&r)*r|0);s[i]=c^l}e[0]=s[0]+(s[7]<<16|s[7]>>>16)+(s[6]<<16|s[6]>>>16)|0,e[1]=s[1]+(s[0]<<8|s[0]>>>24)+s[7]|0,e[2]=s[2]+(s[1]<<16|s[1]>>>16)+(s[0]<<16|s[0]>>>16)|0,e[3]=s[3]+(s[2]<<8|s[2]>>>24)+s[1]|0,e[4]=s[4]+(s[3]<<16|s[3]>>>16)+(s[2]<<16|s[2]>>>16)|0,e[5]=s[5]+(s[4]<<8|s[4]>>>24)+s[3]|0,e[6]=s[6]+(s[5]<<16|s[5]>>>16)+(s[4]<<16|s[4]>>>16)|0,e[7]=s[7]+(s[6]<<8|s[6]>>>24)+s[5]|0}e.Rabbit=t._createHelper(a)}(),i.Rabbit)})),oe((function(e,t){var i;e.exports=(i=se,function(){var e=i,t=e.lib.StreamCipher,r=e.algo,n=[],o=[],s=[],a=r.RabbitLegacy=t.extend({_doReset:function(){var e=this._key.words,t=this.cfg.iv,i=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],r=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];this._b=0;for(var n=0;n<4;n++)c.call(this);for(n=0;n<8;n++)r[n]^=i[n+4&7];if(t){var o=t.words,s=o[0],a=o[1],l=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),d=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),u=l>>>16|4294901760&d,h=d<<16|65535&l;for(r[0]^=l,r[1]^=u,r[2]^=d,r[3]^=h,r[4]^=l,r[5]^=u,r[6]^=d,r[7]^=h,n=0;n<4;n++)c.call(this)}},_doProcessBlock:function(e,t){var i=this._X;c.call(this),n[0]=i[0]^i[5]>>>16^i[3]<<16,n[1]=i[2]^i[7]>>>16^i[5]<<16,n[2]=i[4]^i[1]>>>16^i[7]<<16,n[3]=i[6]^i[3]>>>16^i[1]<<16;for(var r=0;r<4;r++)n[r]=16711935&(n[r]<<8|n[r]>>>24)|4278255360&(n[r]<<24|n[r]>>>8),e[t+r]^=n[r]},blockSize:4,ivSize:2});function c(){for(var e=this._X,t=this._C,i=0;i<8;i++)o[i]=t[i];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<o[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<o[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<o[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<o[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<o[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<o[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<o[6]>>>0?1:0)|0,this._b=t[7]>>>0<o[7]>>>0?1:0,i=0;i<8;i++){var r=e[i]+t[i],n=65535&r,a=r>>>16,c=((n*n>>>17)+n*a>>>15)+a*a,l=((4294901760&r)*r|0)+((65535&r)*r|0);s[i]=c^l}e[0]=s[0]+(s[7]<<16|s[7]>>>16)+(s[6]<<16|s[6]>>>16)|0,e[1]=s[1]+(s[0]<<8|s[0]>>>24)+s[7]|0,e[2]=s[2]+(s[1]<<16|s[1]>>>16)+(s[0]<<16|s[0]>>>16)|0,e[3]=s[3]+(s[2]<<8|s[2]>>>24)+s[1]|0,e[4]=s[4]+(s[3]<<16|s[3]>>>16)+(s[2]<<16|s[2]>>>16)|0,e[5]=s[5]+(s[4]<<8|s[4]>>>24)+s[3]|0,e[6]=s[6]+(s[5]<<16|s[5]>>>16)+(s[4]<<16|s[4]>>>16)|0,e[7]=s[7]+(s[6]<<8|s[6]>>>24)+s[5]|0}e.RabbitLegacy=t._createHelper(a)}(),i.RabbitLegacy)})),oe((function(e,t){e.exports=se})));function ce(){throw new Error("setTimeout has not been defined")}function le(){throw new Error("clearTimeout has not been defined")}var de=ce,ue=le;function he(e){if(de===setTimeout)return setTimeout(e,0);if((de===ce||!de)&&setTimeout)return de=setTimeout,setTimeout(e,0);try{return de(e,0)}catch(t){try{return de.call(null,e,0)}catch(i){return de.call(this,e,0)}}}"function"==typeof s.setTimeout&&(de=setTimeout),"function"==typeof s.clearTimeout&&(ue=clearTimeout);var pe,me=[],_e=!1,fe=-1;function ge(){_e&&pe&&(_e=!1,pe.length?me=pe.concat(me):fe=-1,me.length&&Ee())}function Ee(){if(!_e){var e=he(ge);_e=!0;for(var t=me.length;t;){for(pe=me,me=[];++fe<t;)pe&&pe[fe].run();fe=-1,t=me.length}pe=null,_e=!1,function(e){if(ue===clearTimeout)return clearTimeout(e);if((ue===le||!ue)&&clearTimeout)return ue=clearTimeout,clearTimeout(e);try{ue(e)}catch(t){try{return ue.call(null,e)}catch(i){return ue.call(this,e)}}}(e)}}function ve(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)t[i-1]=arguments[i];me.push(new ye(e,t)),1!==me.length||_e||he(Ee)}function ye(e,t){this.fun=e,this.array=t}ye.prototype.run=function(){this.fun.apply(null,this.array)};var Te=s.performance||{};function Se(){}function Ie(){Ie.init.call(this)}function Ae(e){return void 0===e._maxListeners?Ie.defaultMaxListeners:e._maxListeners}function Re(e,t,i,r){var n,o,s,a;if("function"!=typeof i)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,i.listener?i.listener:i),o=e._events),s=o[t]):(o=e._events=new Se,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=r?[i,s]:[s,i]:r?s.unshift(i):s.push(i),!s.warned&&(n=Ae(e))&&n>0&&s.length>n){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,a=c,"function"==typeof console.warn&&console.warn(a)}}else s=o[t]=i,++e._eventsCount;return e}function be(e,t,i){var r=!1;function n(){e.removeListener(t,n),r||(r=!0,i.apply(e,arguments))}return n.listener=i,n}function Ce(e){var t=this._events;if(t){var i=t[e];if("function"==typeof i)return 1;if(i)return i.length}return 0}function ke(e,t){for(var i=new Array(t);t--;)i[t]=e[t];return i}Te.now||Te.mozNow||Te.msNow||Te.oNow||Te.webkitNow,Se.prototype=Object.create(null),Ie.EventEmitter=Ie,Ie.usingDomains=!1,Ie.prototype.domain=void 0,Ie.prototype._events=void 0,Ie.prototype._maxListeners=void 0,Ie.defaultMaxListeners=10,Ie.init=function(){this.domain=null,Ie.usingDomains&&(void 0).active&&(void 0).Domain,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new Se,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Ie.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},Ie.prototype.getMaxListeners=function(){return Ae(this)},Ie.prototype.emit=function(e){var t,i,r,n,o,s,a,c="error"===e;if(s=this._events)c=c&&null==s.error;else if(!c)return!1;if(a=this.domain,c){if(t=arguments[1],!a){if(t instanceof Error)throw t;var l=new Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(i=s[e]))return!1;var d="function"==typeof i;switch(r=arguments.length){case 1:!function(e,t,i){if(t)e.call(i);else for(var r=e.length,n=ke(e,r),o=0;o<r;++o)n[o].call(i)}(i,d,this);break;case 2:!function(e,t,i,r){if(t)e.call(i,r);else for(var n=e.length,o=ke(e,n),s=0;s<n;++s)o[s].call(i,r)}(i,d,this,arguments[1]);break;case 3:!function(e,t,i,r,n){if(t)e.call(i,r,n);else for(var o=e.length,s=ke(e,o),a=0;a<o;++a)s[a].call(i,r,n)}(i,d,this,arguments[1],arguments[2]);break;case 4:!function(e,t,i,r,n,o){if(t)e.call(i,r,n,o);else for(var s=e.length,a=ke(e,s),c=0;c<s;++c)a[c].call(i,r,n,o)}(i,d,this,arguments[1],arguments[2],arguments[3]);break;default:for(n=new Array(r-1),o=1;o<r;o++)n[o-1]=arguments[o];!function(e,t,i,r){if(t)e.apply(i,r);else for(var n=e.length,o=ke(e,n),s=0;s<n;++s)o[s].apply(i,r)}(i,d,this,n)}return!0},Ie.prototype.addListener=function(e,t){return Re(this,e,t,!1)},Ie.prototype.on=Ie.prototype.addListener,Ie.prototype.prependListener=function(e,t){return Re(this,e,t,!0)},Ie.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,be(this,e,t)),this},Ie.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,be(this,e,t)),this},Ie.prototype.removeListener=function(e,t){var i,r,n,o,s;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(i=r[e]))return this;if(i===t||i.listener&&i.listener===t)0==--this._eventsCount?this._events=new Se:(delete r[e],r.removeListener&&this.emit("removeListener",e,i.listener||t));else if("function"!=typeof i){for(n=-1,o=i.length;o-- >0;)if(i[o]===t||i[o].listener&&i[o].listener===t){s=i[o].listener,n=o;break}if(n<0)return this;if(1===i.length){if(i[0]=void 0,0==--this._eventsCount)return this._events=new Se,this;delete r[e]}else!function(e,t){for(var i=t,r=i+1,n=e.length;r<n;i+=1,r+=1)e[i]=e[r];e.pop()}(i,n);r.removeListener&&this.emit("removeListener",e,s||t)}return this},Ie.prototype.removeAllListeners=function(e){var t,i;if(!(i=this._events))return this;if(!i.removeListener)return 0===arguments.length?(this._events=new Se,this._eventsCount=0):i[e]&&(0==--this._eventsCount?this._events=new Se:delete i[e]),this;if(0===arguments.length){for(var r,n=Object.keys(i),o=0;o<n.length;++o)"removeListener"!==(r=n[o])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=new Se,this._eventsCount=0,this}if("function"==typeof(t=i[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},Ie.prototype.listeners=function(e){var t,i=this._events;return i&&(t=i[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),i=0;i<t.length;++i)t[i]=e[i].listener||e[i];return t}(t):[]},Ie.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Ce.call(e,t)},Ie.prototype.listenerCount=Ce,Ie.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var we="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e},Ne=/%[sdj%]/g;function De(e){if(!We(e)){for(var t=[],i=0;i<arguments.length;i++)t.push(Me(arguments[i]));return t.join(" ")}i=1;for(var r=arguments,n=r.length,o=String(e).replace(Ne,(function(e){if("%%"===e)return"%";if(i>=n)return e;switch(e){case"%s":return String(r[i++]);case"%d":return Number(r[i++]);case"%j":try{return JSON.stringify(r[i++])}catch(t){return"[Circular]"}default:return e}})),s=r[i];i<n;s=r[++i])je(s)||!Ke(s)?o+=" "+s:o+=" "+Me(s);return o}function Oe(e,t){if(ze(s.process))return function(){return Oe(e,t).apply(this,arguments)};var i=!1;return function(){return i||(console.error(t),i=!0),e.apply(this,arguments)}}var Le,Pe={};function Me(e,t){var i={seen:[],stylize:Ve};return arguments.length>=3&&(i.depth=arguments[2]),arguments.length>=4&&(i.colors=arguments[3]),He(t)?i.showHidden=t:t&&function(e,t){if(!t||!Ke(t))return e;for(var i=Object.keys(t),r=i.length;r--;)e[i[r]]=t[i[r]]}(i,t),ze(i.showHidden)&&(i.showHidden=!1),ze(i.depth)&&(i.depth=2),ze(i.colors)&&(i.colors=!1),ze(i.customInspect)&&(i.customInspect=!0),i.colors&&(i.stylize=xe),Ue(i,e,i.depth)}function xe(e,t){var i=Me.styles[t];return i?"["+Me.colors[i][0]+"m"+e+"["+Me.colors[i][1]+"m":e}function Ve(e,t){return e}function Ue(e,t,i){if(e.customInspect&&t&&qe(t.inspect)&&t.inspect!==Me&&(!t.constructor||t.constructor.prototype!==t)){var r=t.inspect(i,e);return We(r)||(r=Ue(e,r,i)),r}var n=function(e,t){if(ze(t))return e.stylize("undefined","undefined");if(We(t)){var i="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(i,"string")}return"number"==typeof t?e.stylize(""+t,"number"):He(t)?e.stylize(""+t,"boolean"):je(t)?e.stylize("null","null"):void 0}(e,t);if(n)return n;var o,s=Object.keys(t),a=(o={},s.forEach((function(e,t){o[e]=!0})),o);if(e.showHidden&&(s=Object.getOwnPropertyNames(t)),Je(t)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return Be(t);if(0===s.length){if(qe(t)){var c=t.name?": "+t.name:"";return e.stylize("[Function"+c+"]","special")}if(Ge(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(Ye(t))return e.stylize(Date.prototype.toString.call(t),"date");if(Je(t))return Be(t)}var l,d,u="",h=!1,p=["{","}"];return l=t,Array.isArray(l)&&(h=!0,p=["[","]"]),qe(t)&&(u=" [Function"+(t.name?": "+t.name:"")+"]"),Ge(t)&&(u=" "+RegExp.prototype.toString.call(t)),Ye(t)&&(u=" "+Date.prototype.toUTCString.call(t)),Je(t)&&(u=" "+Be(t)),0!==s.length||h&&0!=t.length?i<0?Ge(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),d=h?function(e,t,i,r,n){for(var o=[],s=0,a=t.length;s<a;++s)Qe(t,String(s))?o.push(Fe(e,t,i,r,String(s),!0)):o.push("");return n.forEach((function(n){n.match(/^\d+$/)||o.push(Fe(e,t,i,r,n,!0))})),o}(e,t,i,a,s):s.map((function(r){return Fe(e,t,i,a,r,h)})),e.seen.pop(),function(e,t,i){return e.reduce((function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60?i[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+i[1]:i[0]+t+" "+e.join(", ")+" "+i[1]}(d,u,p)):p[0]+u+p[1]}function Be(e){return"["+Error.prototype.toString.call(e)+"]"}function Fe(e,t,i,r,n,o){var s,a,c;if((c=Object.getOwnPropertyDescriptor(t,n)||{value:t[n]}).get?a=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),Qe(r,n)||(s="["+n+"]"),a||(e.seen.indexOf(c.value)<0?(a=je(i)?Ue(e,c.value,null):Ue(e,c.value,i-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),ze(s)){if(o&&n.match(/^\d+$/))return a;(s=JSON.stringify(""+n)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function He(e){return"boolean"==typeof e}function je(e){return null===e}function We(e){return"string"==typeof e}function ze(e){return void 0===e}function Ge(e){return Ke(e)&&"[object RegExp]"===Xe(e)}function Ke(e){return"object"==typeof e&&null!==e}function Ye(e){return Ke(e)&&"[object Date]"===Xe(e)}function Je(e){return Ke(e)&&("[object Error]"===Xe(e)||e instanceof Error)}function qe(e){return"function"==typeof e}function Xe(e){return Object.prototype.toString.call(e)}function Qe(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Ze(){this.head=null,this.tail=null,this.length=0}Me.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},Me.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Ze.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},Ze.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Ze.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},Ze.prototype.clear=function(){this.head=this.tail=null,this.length=0},Ze.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,i=""+t.data;t=t.next;)i+=e+t.data;return i},Ze.prototype.concat=function(e){if(0===this.length)return y.alloc(0);if(1===this.length)return this.head.data;for(var t=y.allocUnsafe(e>>>0),i=this.head,r=0;i;)i.data.copy(t,r),r+=i.data.length,i=i.next;return t};var $e=y.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function et(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!$e(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=it;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=rt;break;default:return void(this.write=tt)}this.charBuffer=new y(6),this.charReceived=0,this.charLength=0}function tt(e){return e.toString(this.encoding)}function it(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function rt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}et.prototype.write=function(e){for(var t="";this.charLength;){var i=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,i),this.charReceived+=i,this.charReceived<this.charLength)return"";if(e=e.slice(i,e.length),!((r=(t=this.charBuffer.slice(0,this.charLength).toString(this.encoding)).charCodeAt(t.length-1))>=55296&&r<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var r,n=e.length;if(this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived),n=(t+=e.toString(this.encoding,0,n)).length-1,(r=t.charCodeAt(n))>=55296&&r<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,n)}return t},et.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var i=e[e.length-t];if(1==t&&i>>5==6){this.charLength=2;break}if(t<=2&&i>>4==14){this.charLength=3;break}if(t<=3&&i>>3==30){this.charLength=4;break}}this.charReceived=t},et.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var i=this.charReceived,r=this.charBuffer,n=this.encoding;t+=r.slice(0,i).toString(n)}return t},at.ReadableState=st;var nt,ot=(nt="stream",ze(Le)&&(Le=""),nt=nt.toUpperCase(),Pe[nt]||(new RegExp("\\b"+nt+"\\b","i").test(Le)?Pe[nt]=function(){var e=De.apply(null,arguments);console.error("%s %d: %s",nt,0,e)}:Pe[nt]=function(){}),Pe[nt]);function st(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof Mt&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var i=e.highWaterMark,r=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r,this.highWaterMark=~~this.highWaterMark,this.buffer=new Ze,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new et(e.encoding),this.encoding=e.encoding)}function at(e){if(!(this instanceof at))return new at(e);this._readableState=new st(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),Ie.call(this)}function ct(e,t,i,r,n){var o,s,a,c=(o=t,a=null,re(s=i)||"string"==typeof s||null==s||o.objectMode||(a=new TypeError("Invalid non-string/buffer chunk")),a);if(c)e.emit("error",c);else if(null===i)t.reading=!1,function(e,t){if(!t.ended){if(t.decoder){var i=t.decoder.end();i&&i.length&&(t.buffer.push(i),t.length+=t.objectMode?1:i.length)}t.ended=!0,ut(e)}}(e,t);else if(t.objectMode||i&&i.length>0)if(t.ended&&!n){var l=new Error("stream.push() after EOF");e.emit("error",l)}else if(t.endEmitted&&n){var d=new Error("stream.unshift() after end event");e.emit("error",d)}else{var u;!t.decoder||n||r||(i=t.decoder.write(i),u=!t.objectMode&&0===i.length),n||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",i),e.read(0)):(t.length+=t.objectMode?1:i.length,n?t.buffer.unshift(i):t.buffer.push(i),t.needReadable&&ut(e))),function(e,t){t.readingMore||(t.readingMore=!0,ve(pt,e,t))}(e,t)}else n||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||0===e.length)}(t)}we(at,Ie),at.prototype.push=function(e,t){var i=this._readableState;return i.objectMode||"string"!=typeof e||(t=t||i.defaultEncoding)!==i.encoding&&(e=y.from(e,t),t=""),ct(this,i,e,t,!1)},at.prototype.unshift=function(e){return ct(this,this._readableState,e,"",!0)},at.prototype.isPaused=function(){return!1===this._readableState.flowing},at.prototype.setEncoding=function(e){return this._readableState.decoder=new et(e),this._readableState.encoding=e,this};var lt=8388608;function dt(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=((i=e)>=lt?i=lt:(i--,i|=i>>>1,i|=i>>>2,i|=i>>>4,i|=i>>>8,i|=i>>>16,i++),i)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0));var i}function ut(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(ot("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?ve(ht,e):ht(e))}function ht(e){ot("emit readable"),e.emit("readable"),ft(e)}function pt(e,t){for(var i=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(ot("maybeReadMore read 0"),e.read(0),i!==t.length);)i=t.length;t.readingMore=!1}function mt(e){ot("readable nexttick read 0"),e.read(0)}function _t(e,t){t.reading||(ot("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),ft(e),t.flowing&&!t.reading&&e.read(0)}function ft(e){var t=e._readableState;for(ot("flow",t.flowing);t.flowing&&null!==e.read(););}function gt(e,t){return 0===t.length?null:(t.objectMode?s=t.buffer.shift():!e||e>=t.length?(s=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):(i=e,r=t.buffer,n=t.decoder,i<r.head.data.length?(o=r.head.data.slice(0,i),r.head.data=r.head.data.slice(i)):o=i===r.head.data.length?r.shift():n?function(e,t){var i=t.head,r=1,n=i.data;for(e-=n.length;i=i.next;){var o=i.data,s=e>o.length?o.length:e;if(s===o.length?n+=o:n+=o.slice(0,e),0==(e-=s)){s===o.length?(++r,i.next?t.head=i.next:t.head=t.tail=null):(t.head=i,i.data=o.slice(s));break}++r}return t.length-=r,n}(i,r):function(e,t){var i=y.allocUnsafe(e),r=t.head,n=1;for(r.data.copy(i),e-=r.data.length;r=r.next;){var o=r.data,s=e>o.length?o.length:e;if(o.copy(i,i.length-e,0,s),0==(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(i,r),s=o),s);var i,r,n,o,s}function Et(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,ve(vt,t,e))}function vt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function yt(e,t){for(var i=0,r=e.length;i<r;i++)if(e[i]===t)return i;return-1}function Tt(){}function St(e,t,i){this.chunk=e,this.encoding=t,this.callback=i,this.next=null}function It(e,t){Object.defineProperty(this,"buffer",{get:Oe((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")}),e=e||{},this.objectMode=!!e.objectMode,t instanceof Mt&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,r=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var n=!1===e.decodeStrings;this.decodeStrings=!n,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var i,r=e._writableState,n=r.sync,o=r.writecb;if((i=r).writing=!1,i.writecb=null,i.length-=i.writelen,i.writelen=0,t)!function(e,t,i,r,n){--t.pendingcb,i?ve(n,r):n(r),e._writableState.errorEmitted=!0,e.emit("error",r)}(e,r,n,t,o);else{var s=kt(r);s||r.corked||r.bufferProcessing||!r.bufferedRequest||Ct(e,r),n?ve(bt,e,r,s,o):bt(e,r,s,o)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new Dt(this)}function At(e){if(!(this instanceof At||this instanceof Mt))return new At(e);this._writableState=new It(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev)),Ie.call(this)}function Rt(e,t,i,r,n,o,s){t.writelen=r,t.writecb=s,t.writing=!0,t.sync=!0,i?e._writev(n,t.onwrite):e._write(n,o,t.onwrite),t.sync=!1}function bt(e,t,i,r){var n,o;i||(n=e,0===(o=t).length&&o.needDrain&&(o.needDrain=!1,n.emit("drain"))),t.pendingcb--,r(),Nt(e,t)}function Ct(e,t){t.bufferProcessing=!0;var i=t.bufferedRequest;if(e._writev&&i&&i.next){var r=t.bufferedRequestCount,n=new Array(r),o=t.corkedRequestsFree;o.entry=i;for(var s=0;i;)n[s]=i,i=i.next,s+=1;Rt(e,t,!0,t.length,n,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new Dt(t)}else{for(;i;){var a=i.chunk,c=i.encoding,l=i.callback;if(Rt(e,t,!1,t.objectMode?1:a.length,a,c,l),i=i.next,t.writing)break}null===i&&(t.lastBufferedRequest=null)}t.bufferedRequestCount=0,t.bufferedRequest=i,t.bufferProcessing=!1}function kt(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function wt(e,t){t.prefinished||(t.prefinished=!0,e.emit("prefinish"))}function Nt(e,t){var i=kt(t);return i&&(0===t.pendingcb?(wt(e,t),t.finished=!0,e.emit("finish")):wt(e,t)),i}function Dt(e){var t=this;this.next=null,this.entry=null,this.finish=function(i){var r=t.entry;for(t.entry=null;r;){var n=r.callback;e.pendingcb--,n(i),r=r.next}e.corkedRequestsFree?e.corkedRequestsFree.next=t:e.corkedRequestsFree=t}}at.prototype.read=function(e){ot("read",e),e=parseInt(e,10);var t=this._readableState,i=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return ot("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Et(this):ut(this),null;if(0===(e=dt(e,t))&&t.ended)return 0===t.length&&Et(this),null;var r,n=t.needReadable;return ot("need readable",n),(0===t.length||t.length-e<t.highWaterMark)&&ot("length less than watermark",n=!0),t.ended||t.reading?ot("reading or ended",n=!1):n&&(ot("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=dt(i,t))),null===(r=e>0?gt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),i!==e&&t.ended&&Et(this)),null!==r&&this.emit("data",r),r},at.prototype._read=function(e){this.emit("error",new Error("not implemented"))},at.prototype.pipe=function(e,t){var i=this,r=this._readableState;switch(r.pipesCount){case 0:r.pipes=e;break;case 1:r.pipes=[r.pipes,e];break;default:r.pipes.push(e)}r.pipesCount+=1,ot("pipe count=%d opts=%j",r.pipesCount,t);var n=t&&!1===t.end?l:s;function o(e){ot("onunpipe"),e===i&&l()}function s(){ot("onend"),e.end()}r.endEmitted?ve(n):i.once("end",n),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;ot("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,ft(e))}}(i);e.on("drain",a);var c=!1;function l(){ot("cleanup"),e.removeListener("close",p),e.removeListener("finish",m),e.removeListener("drain",a),e.removeListener("error",h),e.removeListener("unpipe",o),i.removeListener("end",s),i.removeListener("end",l),i.removeListener("data",u),c=!0,!r.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var d=!1;function u(t){ot("ondata"),d=!1,!1!==e.write(t)||d||((1===r.pipesCount&&r.pipes===e||r.pipesCount>1&&-1!==yt(r.pipes,e))&&!c&&(ot("false write response, pause",i._readableState.awaitDrain),i._readableState.awaitDrain++,d=!0),i.pause())}function h(t){ot("onerror",t),_(),e.removeListener("error",h),0===("error",e.listeners("error").length)&&e.emit("error",t)}function p(){e.removeListener("finish",m),_()}function m(){ot("onfinish"),e.removeListener("close",p),_()}function _(){ot("unpipe"),i.unpipe(e)}return i.on("data",u),function(e,t,i){if("function"==typeof e.prependListener)return e.prependListener(t,i);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(i):e._events[t]=[i,e._events[t]]:e.on(t,i)}(e,"error",h),e.once("close",p),e.once("finish",m),e.emit("pipe",i),r.flowing||(ot("pipe resume"),i.resume()),e},at.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var i=t.pipes,r=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var n=0;n<r;n++)i[n].emit("unpipe",this);return this}var o=yt(t.pipes,e);return-1===o||(t.pipes.splice(o,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this)),this},at.prototype.on=function(e,t){var i=Ie.prototype.on.call(this,e,t);if("data"===e)!1!==this._readableState.flowing&&this.resume();else if("readable"===e){var r=this._readableState;r.endEmitted||r.readableListening||(r.readableListening=r.needReadable=!0,r.emittedReadable=!1,r.reading?r.length&&ut(this):ve(mt,this))}return i},at.prototype.addListener=at.prototype.on,at.prototype.resume=function(){var e,t,i=this._readableState;return i.flowing||(ot("resume"),i.flowing=!0,e=this,(t=i).resumeScheduled||(t.resumeScheduled=!0,ve(_t,e,t))),this},at.prototype.pause=function(){return ot("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(ot("pause"),this._readableState.flowing=!1,this.emit("pause")),this},at.prototype.wrap=function(e){var t=this._readableState,i=!1,r=this;for(var n in e.on("end",(function(){if(ot("wrapped end"),t.decoder&&!t.ended){var e=t.decoder.end();e&&e.length&&r.push(e)}r.push(null)})),e.on("data",(function(n){ot("wrapped data"),t.decoder&&(n=t.decoder.write(n)),t.objectMode&&null==n||(t.objectMode||n&&n.length)&&(r.push(n)||(i=!0,e.pause()))})),e)void 0===this[n]&&"function"==typeof e[n]&&(this[n]=function(t){return function(){return e[t].apply(e,arguments)}}(n));return function(e,t){for(var i=0,r=e.length;i<r;i++)t(e[i])}(["error","close","destroy","pause","resume"],(function(t){e.on(t,r.emit.bind(r,t))})),r._read=function(t){ot("wrapped _read",t),i&&(i=!1,e.resume())},r},at._fromList=gt,At.WritableState=It,we(At,Ie),It.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},At.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},At.prototype.write=function(e,t,i){var r,n,o,s=this._writableState,a=!1;return"function"==typeof t&&(i=t,t=null),y.isBuffer(e)?t="buffer":t||(t=s.defaultEncoding),"function"!=typeof i&&(i=Tt),s.ended?(r=this,n=i,o=new Error("write after end"),r.emit("error",o),ve(n,o)):function(e,t,i,r){var n=!0,o=!1;return null===i?o=new TypeError("May not write null values to stream"):y.isBuffer(i)||"string"==typeof i||void 0===i||t.objectMode||(o=new TypeError("Invalid non-string/buffer chunk")),o&&(e.emit("error",o),ve(r,o),n=!1),n}(this,s,e,i)&&(s.pendingcb++,a=function(e,t,i,r,n){var o,s,a;s=i,a=r,(o=t).objectMode||!1===o.decodeStrings||"string"!=typeof s||(s=y.from(s,a)),i=s,y.isBuffer(i)&&(r="buffer");var c=t.objectMode?1:i.length;t.length+=c;var l=t.length<t.highWaterMark;if(l||(t.needDrain=!0),t.writing||t.corked){var d=t.lastBufferedRequest;t.lastBufferedRequest=new St(i,r,n),d?d.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else Rt(e,t,!1,c,i,r,n);return l}(this,s,e,t,i)),a},At.prototype.cork=function(){this._writableState.corked++},At.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||Ct(this,e))},At.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},At.prototype._write=function(e,t,i){i(new Error("not implemented"))},At.prototype._writev=null,At.prototype.end=function(e,t,i){var r,n,o,s=this._writableState;"function"==typeof e?(i=e,e=null,t=null):"function"==typeof t&&(i=t,t=null),null!=e&&this.write(e,t),s.corked&&(s.corked=1,this.uncork()),s.ending||s.finished||(r=this,o=i,(n=s).ending=!0,Nt(r,n),o&&(n.finished?ve(o):r.once("finish",o)),n.ended=!0,r.writable=!1)},we(Mt,at);for(var Ot=Object.keys(At.prototype),Lt=0;Lt<Ot.length;Lt++){var Pt=Ot[Lt];Mt.prototype[Pt]||(Mt.prototype[Pt]=At.prototype[Pt])}function Mt(e){if(!(this instanceof Mt))return new Mt(e);at.call(this,e),At.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",xt)}function xt(){this.allowHalfOpen||this._writableState.ended||ve(Vt,this)}function Vt(e){e.end()}function Ut(e){this.afterTransform=function(t,i){return function(e,t,i){var r=e._transformState;r.transforming=!1;var n=r.writecb;if(!n)return e.emit("error",new Error("no writecb in Transform class"));r.writechunk=null,r.writecb=null,null!=i&&e.push(i),n(t);var o=e._readableState;o.reading=!1,(o.needReadable||o.length<o.highWaterMark)&&e._read(o.highWaterMark)}(e,t,i)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null,this.writeencoding=null}function Bt(e){if(!(this instanceof Bt))return new Bt(e);Mt.call(this,e),this._transformState=new Ut(this);var t=this;this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.once("prefinish",(function(){"function"==typeof this._flush?this._flush((function(e){Ft(t,e)})):Ft(t)}))}function Ft(e,t){if(t)return e.emit("error",t);var i=e._writableState,r=e._transformState;if(i.length)throw new Error("Calling transform done when ws.length != 0");if(r.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}function Ht(e){if(!(this instanceof Ht))return new Ht(e);Bt.call(this,e)}function jt(){Ie.call(this)}we(Bt,Mt),Bt.prototype.push=function(e,t){return this._transformState.needTransform=!1,Mt.prototype.push.call(this,e,t)},Bt.prototype._transform=function(e,t,i){throw new Error("Not implemented")},Bt.prototype._write=function(e,t,i){var r=this._transformState;if(r.writecb=i,r.writechunk=e,r.writeencoding=t,!r.transforming){var n=this._readableState;(r.needTransform||n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}},Bt.prototype._read=function(e){var t=this._transformState;null!==t.writechunk&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0},we(Ht,Bt),Ht.prototype._transform=function(e,t,i){i(null,e)},we(jt,Ie),jt.Readable=at,jt.Writable=At,jt.Duplex=Mt,jt.Transform=Bt,jt.PassThrough=Ht,jt.Stream=jt,jt.prototype.pipe=function(e,t){var i=this;function r(t){e.writable&&!1===e.write(t)&&i.pause&&i.pause()}function n(){i.readable&&i.resume&&i.resume()}i.on("data",r),e.on("drain",n),e._isStdio||t&&!1===t.end||(i.on("end",s),i.on("close",a));var o=!1;function s(){o||(o=!0,e.end())}function a(){o||(o=!0,"function"==typeof e.destroy&&e.destroy())}function c(e){if(l(),0===Ie.listenerCount(this,"error"))throw e}function l(){i.removeListener("data",r),e.removeListener("drain",n),i.removeListener("end",s),i.removeListener("close",a),i.removeListener("error",c),e.removeListener("error",c),i.removeListener("end",l),i.removeListener("close",l),e.removeListener("close",l)}return i.on("error",c),e.on("error",c),i.on("end",l),i.on("close",l),e.on("close",l),e.emit("pipe",i),e};var Wt={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};function zt(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}function Gt(e,t,i,r,n){if(t.subarray&&e.subarray)e.set(t.subarray(i,i+r),n);else for(var o=0;o<r;o++)e[n+o]=t[i+o]}var Kt=Uint8Array,Yt=Uint16Array,Jt=Int32Array,qt=4,Xt=0,Qt=1,Zt=2;function $t(e){for(var t=e.length;--t>=0;)e[t]=0}var ei=0,ti=1,ii=2,ri=29,ni=256,oi=ni+1+ri,si=30,ai=19,ci=2*oi+1,li=15,di=16,ui=7,hi=256,pi=16,mi=17,_i=18,fi=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],gi=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Ei=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],vi=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],yi=new Array(2*(oi+2));$t(yi);var Ti=new Array(2*si);$t(Ti);var Si=new Array(512);$t(Si);var Ii=new Array(256);$t(Ii);var Ai=new Array(ri);$t(Ai);var Ri,bi,Ci,ki=new Array(si);function wi(e,t,i,r,n){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=r,this.max_length=n,this.has_stree=e&&e.length}function Ni(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function Di(e){return e<256?Si[e]:Si[256+(e>>>7)]}function Oi(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function Li(e,t,i){e.bi_valid>di-i?(e.bi_buf|=t<<e.bi_valid&65535,Oi(e,e.bi_buf),e.bi_buf=t>>di-e.bi_valid,e.bi_valid+=i-di):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=i)}function Pi(e,t,i){Li(e,i[2*t],i[2*t+1])}function Mi(e,t){var i=0;do{i|=1&e,e>>>=1,i<<=1}while(--t>0);return i>>>1}function xi(e,t,i){var r,n,o=new Array(li+1),s=0;for(r=1;r<=li;r++)o[r]=s=s+i[r-1]<<1;for(n=0;n<=t;n++){var a=e[2*n+1];0!==a&&(e[2*n]=Mi(o[a]++,a))}}function Vi(e){var t;for(t=0;t<oi;t++)e.dyn_ltree[2*t]=0;for(t=0;t<si;t++)e.dyn_dtree[2*t]=0;for(t=0;t<ai;t++)e.bl_tree[2*t]=0;e.dyn_ltree[2*hi]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function Ui(e){e.bi_valid>8?Oi(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function Bi(e,t,i,r){var n=2*t,o=2*i;return e[n]<e[o]||e[n]===e[o]&&r[t]<=r[i]}function Fi(e,t,i){for(var r=e.heap[i],n=i<<1;n<=e.heap_len&&(n<e.heap_len&&Bi(t,e.heap[n+1],e.heap[n],e.depth)&&n++,!Bi(t,r,e.heap[n],e.depth));)e.heap[i]=e.heap[n],i=n,n<<=1;e.heap[i]=r}function Hi(e,t,i){var r,n,o,s,a=0;if(0!==e.last_lit)do{r=e.pending_buf[e.d_buf+2*a]<<8|e.pending_buf[e.d_buf+2*a+1],n=e.pending_buf[e.l_buf+a],a++,0===r?Pi(e,n,t):(Pi(e,(o=Ii[n])+ni+1,t),0!==(s=fi[o])&&Li(e,n-=Ai[o],s),Pi(e,o=Di(--r),i),0!==(s=gi[o])&&Li(e,r-=ki[o],s))}while(a<e.last_lit);Pi(e,hi,t)}function ji(e,t){var i,r,n,o=t.dyn_tree,s=t.stat_desc.static_tree,a=t.stat_desc.has_stree,c=t.stat_desc.elems,l=-1;for(e.heap_len=0,e.heap_max=ci,i=0;i<c;i++)0!==o[2*i]?(e.heap[++e.heap_len]=l=i,e.depth[i]=0):o[2*i+1]=0;for(;e.heap_len<2;)o[2*(n=e.heap[++e.heap_len]=l<2?++l:0)]=1,e.depth[n]=0,e.opt_len--,a&&(e.static_len-=s[2*n+1]);for(t.max_code=l,i=e.heap_len>>1;i>=1;i--)Fi(e,o,i);n=c;do{i=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Fi(e,o,1),r=e.heap[1],e.heap[--e.heap_max]=i,e.heap[--e.heap_max]=r,o[2*n]=o[2*i]+o[2*r],e.depth[n]=(e.depth[i]>=e.depth[r]?e.depth[i]:e.depth[r])+1,o[2*i+1]=o[2*r+1]=n,e.heap[1]=n++,Fi(e,o,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var i,r,n,o,s,a,c=t.dyn_tree,l=t.max_code,d=t.stat_desc.static_tree,u=t.stat_desc.has_stree,h=t.stat_desc.extra_bits,p=t.stat_desc.extra_base,m=t.stat_desc.max_length,_=0;for(o=0;o<=li;o++)e.bl_count[o]=0;for(c[2*e.heap[e.heap_max]+1]=0,i=e.heap_max+1;i<ci;i++)(o=c[2*c[2*(r=e.heap[i])+1]+1]+1)>m&&(o=m,_++),c[2*r+1]=o,r>l||(e.bl_count[o]++,s=0,r>=p&&(s=h[r-p]),a=c[2*r],e.opt_len+=a*(o+s),u&&(e.static_len+=a*(d[2*r+1]+s)));if(0!==_){do{for(o=m-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[m]--,_-=2}while(_>0);for(o=m;0!==o;o--)for(r=e.bl_count[o];0!==r;)(n=e.heap[--i])>l||(c[2*n+1]!==o&&(e.opt_len+=(o-c[2*n+1])*c[2*n],c[2*n+1]=o),r--)}}(e,t),xi(o,l,e.bl_count)}function Wi(e,t,i){var r,n,o=-1,s=t[1],a=0,c=7,l=4;for(0===s&&(c=138,l=3),t[2*(i+1)+1]=65535,r=0;r<=i;r++)n=s,s=t[2*(r+1)+1],++a<c&&n===s||(a<l?e.bl_tree[2*n]+=a:0!==n?(n!==o&&e.bl_tree[2*n]++,e.bl_tree[2*pi]++):a<=10?e.bl_tree[2*mi]++:e.bl_tree[2*_i]++,a=0,o=n,0===s?(c=138,l=3):n===s?(c=6,l=3):(c=7,l=4))}function zi(e,t,i){var r,n,o=-1,s=t[1],a=0,c=7,l=4;for(0===s&&(c=138,l=3),r=0;r<=i;r++)if(n=s,s=t[2*(r+1)+1],!(++a<c&&n===s)){if(a<l)do{Pi(e,n,e.bl_tree)}while(0!=--a);else 0!==n?(n!==o&&(Pi(e,n,e.bl_tree),a--),Pi(e,pi,e.bl_tree),Li(e,a-3,2)):a<=10?(Pi(e,mi,e.bl_tree),Li(e,a-3,3)):(Pi(e,_i,e.bl_tree),Li(e,a-11,7));a=0,o=n,0===s?(c=138,l=3):n===s?(c=6,l=3):(c=7,l=4)}}$t(ki);var Gi=!1;function Ki(e,t,i,r){var n,o,s;Li(e,(ei<<1)+(r?1:0),3),o=t,s=i,Ui(n=e),Oi(n,s),Oi(n,~s),Gt(n.pending_buf,n.window,o,s,n.pending),n.pending+=s}function Yi(e,t,i){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&i,e.last_lit++,0===t?e.dyn_ltree[2*i]++:(e.matches++,t--,e.dyn_ltree[2*(Ii[i]+ni+1)]++,e.dyn_dtree[2*Di(t)]++),e.last_lit===e.lit_bufsize-1}function Ji(e,t,i,r){for(var n=65535&e,o=e>>>16&65535,s=0;0!==i;){i-=s=i>2e3?2e3:i;do{o=o+(n=n+t[r++]|0)|0}while(--s);n%=65521,o%=65521}return n|o<<16}var qi=function(){for(var e,t=[],i=0;i<256;i++){e=i;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t}();function Xi(e,t,i,r){var n=qi,o=r+i;e^=-1;for(var s=r;s<o;s++)e=e>>>8^n[255&(e^t[s])];return~e}var Qi,Zi=-2,$i=3,er=258,tr=er+$i+1,ir=103,rr=113,nr=666;function or(e,t){return e.msg=Wt[t],t}function sr(e){return(e<<1)-(e>4?9:0)}function ar(e){for(var t=e.length;--t>=0;)e[t]=0}function cr(e){var t=e.state,i=t.pending;i>e.avail_out&&(i=e.avail_out),0!==i&&(Gt(e.output,t.pending_buf,t.pending_out,i,e.next_out),e.next_out+=i,t.pending_out+=i,e.total_out+=i,e.avail_out-=i,t.pending-=i,0===t.pending&&(t.pending_out=0))}function lr(e,t){(function(e,t,i,r){var n,o,s=0;e.level>0?(e.strm.data_type===Zt&&(e.strm.data_type=function(e){var t,i=4093624447;for(t=0;t<=31;t++,i>>>=1)if(1&i&&0!==e.dyn_ltree[2*t])return Xt;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return Qt;for(t=32;t<ni;t++)if(0!==e.dyn_ltree[2*t])return Qt;return Xt}(e)),ji(e,e.l_desc),ji(e,e.d_desc),s=function(e){var t;for(Wi(e,e.dyn_ltree,e.l_desc.max_code),Wi(e,e.dyn_dtree,e.d_desc.max_code),ji(e,e.bl_desc),t=ai-1;t>=3&&0===e.bl_tree[2*vi[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),n=e.opt_len+3+7>>>3,(o=e.static_len+3+7>>>3)<=n&&(n=o)):n=o=i+5,i+4<=n&&-1!==t?Ki(e,t,i,r):e.strategy===qt||o===n?(Li(e,(ti<<1)+(r?1:0),3),Hi(e,yi,Ti)):(Li(e,(ii<<1)+(r?1:0),3),function(e,t,i,r){var n;for(Li(e,t-257,5),Li(e,i-1,5),Li(e,r-4,4),n=0;n<r;n++)Li(e,e.bl_tree[2*vi[n]+1],3);zi(e,e.dyn_ltree,t-1),zi(e,e.dyn_dtree,i-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),Hi(e,e.dyn_ltree,e.dyn_dtree)),Vi(e),r&&Ui(e)})(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,cr(e.strm)}function dr(e,t){e.pending_buf[e.pending++]=t}function ur(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function hr(e,t){var i,r,n=e.max_chain_length,o=e.strstart,s=e.prev_length,a=e.nice_match,c=e.strstart>e.w_size-tr?e.strstart-(e.w_size-tr):0,l=e.window,d=e.w_mask,u=e.prev,h=e.strstart+er,p=l[o+s-1],m=l[o+s];e.prev_length>=e.good_match&&(n>>=2),a>e.lookahead&&(a=e.lookahead);do{if(l[(i=t)+s]===m&&l[i+s-1]===p&&l[i]===l[o]&&l[++i]===l[o+1]){o+=2,i++;do{}while(l[++o]===l[++i]&&l[++o]===l[++i]&&l[++o]===l[++i]&&l[++o]===l[++i]&&l[++o]===l[++i]&&l[++o]===l[++i]&&l[++o]===l[++i]&&l[++o]===l[++i]&&o<h);if(r=er-(h-o),o=h-er,r>s){if(e.match_start=t,s=r,r>=a)break;p=l[o+s-1],m=l[o+s]}}}while((t=u[t&d])>c&&0!=--n);return s<=e.lookahead?s:e.lookahead}function pr(e){var t,i,r,n,o,s,a,c,l,d,u=e.w_size;do{if(n=e.window_size-e.lookahead-e.strstart,e.strstart>=u+(u-tr)){Gt(e.window,e.window,u,u,0),e.match_start-=u,e.strstart-=u,e.block_start-=u,t=i=e.hash_size;do{r=e.head[--t],e.head[t]=r>=u?r-u:0}while(--i);t=i=u;do{r=e.prev[--t],e.prev[t]=r>=u?r-u:0}while(--i);n+=u}if(0===e.strm.avail_in)break;if(s=e.strm,a=e.window,c=e.strstart+e.lookahead,l=n,d=void 0,(d=s.avail_in)>l&&(d=l),i=0===d?0:(s.avail_in-=d,Gt(a,s.input,s.next_in,d,c),1===s.state.wrap?s.adler=Ji(s.adler,a,d,c):2===s.state.wrap&&(s.adler=Xi(s.adler,a,d,c)),s.next_in+=d,s.total_in+=d,d),e.lookahead+=i,e.lookahead+e.insert>=$i)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+$i-1])&e.hash_mask,e.prev[o&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=o,o++,e.insert--,!(e.lookahead+e.insert<$i)););}while(e.lookahead<tr&&0!==e.strm.avail_in)}function mr(e,t){for(var i,r;;){if(e.lookahead<tr){if(pr(e),e.lookahead<tr&&0===t)return 1;if(0===e.lookahead)break}if(i=0,e.lookahead>=$i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+$i-1])&e.hash_mask,i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==i&&e.strstart-i<=e.w_size-tr&&(e.match_length=hr(e,i)),e.match_length>=$i)if(r=Yi(e,e.strstart-e.match_start,e.match_length-$i),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=$i){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+$i-1])&e.hash_mask,i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else r=Yi(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(lr(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<$i-1?e.strstart:$i-1,4===t?(lr(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(lr(e,!1),0===e.strm.avail_out)?1:2}function _r(e,t){for(var i,r,n;;){if(e.lookahead<tr){if(pr(e),e.lookahead<tr&&0===t)return 1;if(0===e.lookahead)break}if(i=0,e.lookahead>=$i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+$i-1])&e.hash_mask,i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=$i-1,0!==i&&e.prev_length<e.max_lazy_match&&e.strstart-i<=e.w_size-tr&&(e.match_length=hr(e,i),e.match_length<=5&&(1===e.strategy||e.match_length===$i&&e.strstart-e.match_start>4096)&&(e.match_length=$i-1)),e.prev_length>=$i&&e.match_length<=e.prev_length){n=e.strstart+e.lookahead-$i,r=Yi(e,e.strstart-1-e.prev_match,e.prev_length-$i),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=n&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+$i-1])&e.hash_mask,i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=$i-1,e.strstart++,r&&(lr(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((r=Yi(e,0,e.window[e.strstart-1]))&&lr(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=Yi(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<$i-1?e.strstart:$i-1,4===t?(lr(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(lr(e,!1),0===e.strm.avail_out)?1:2}function fr(e,t,i,r,n){this.good_length=e,this.max_lazy=t,this.nice_length=i,this.max_chain=r,this.func=n}function gr(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Yt(1146),this.dyn_dtree=new Yt(122),this.bl_tree=new Yt(78),ar(this.dyn_ltree),ar(this.dyn_dtree),ar(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Yt(16),this.heap=new Yt(573),ar(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Yt(573),ar(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function Er(e){var t,i,r,n=(i=e)&&i.state?(i.total_in=i.total_out=0,i.data_type=2,(r=i.state).pending=0,r.pending_out=0,r.wrap<0&&(r.wrap=-r.wrap),r.status=r.wrap?42:rr,i.adler=2===r.wrap?0:1,r.last_flush=0,function(e){Gi||(function(){var e,t,i,r,n,o=new Array(li+1);for(i=0,r=0;r<ri-1;r++)for(Ai[r]=i,e=0;e<1<<fi[r];e++)Ii[i++]=r;for(Ii[i-1]=r,n=0,r=0;r<16;r++)for(ki[r]=n,e=0;e<1<<gi[r];e++)Si[n++]=r;for(n>>=7;r<si;r++)for(ki[r]=n<<7,e=0;e<1<<gi[r]-7;e++)Si[256+n++]=r;for(t=0;t<=li;t++)o[t]=0;for(e=0;e<=143;)yi[2*e+1]=8,e++,o[8]++;for(;e<=255;)yi[2*e+1]=9,e++,o[9]++;for(;e<=279;)yi[2*e+1]=7,e++,o[7]++;for(;e<=287;)yi[2*e+1]=8,e++,o[8]++;for(xi(yi,oi+1,o),e=0;e<si;e++)Ti[2*e+1]=5,Ti[2*e]=Mi(e,5);Ri=new wi(yi,fi,ni+1,oi,li),bi=new wi(Ti,gi,0,si,li),Ci=new wi(new Array(0),Ei,0,ai,ui)}(),Gi=!0),e.l_desc=new Ni(e.dyn_ltree,Ri),e.d_desc=new Ni(e.dyn_dtree,bi),e.bl_desc=new Ni(e.bl_tree,Ci),e.bi_buf=0,e.bi_valid=0,Vi(e)}(r),0):or(i,Zi);return 0===n&&((t=e.state).window_size=2*t.w_size,ar(t.head),t.max_lazy_match=Qi[t.level].max_lazy,t.good_match=Qi[t.level].good_length,t.nice_match=Qi[t.level].nice_length,t.max_chain_length=Qi[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=$i-1,t.match_available=0,t.ins_h=0),n}function vr(e,t){var i,r,n,o;if(!e||!e.state||t>5||t<0)return e?or(e,Zi):Zi;if(r=e.state,!e.output||!e.input&&0!==e.avail_in||r.status===nr&&4!==t)return or(e,0===e.avail_out?-5:Zi);if(r.strm=e,i=r.last_flush,r.last_flush=t,42===r.status)if(2===r.wrap)e.adler=0,dr(r,31),dr(r,139),dr(r,8),r.gzhead?(dr(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),dr(r,255&r.gzhead.time),dr(r,r.gzhead.time>>8&255),dr(r,r.gzhead.time>>16&255),dr(r,r.gzhead.time>>24&255),dr(r,9===r.level?2:r.strategy>=2||r.level<2?4:0),dr(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(dr(r,255&r.gzhead.extra.length),dr(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=Xi(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69):(dr(r,0),dr(r,0),dr(r,0),dr(r,0),dr(r,0),dr(r,9===r.level?2:r.strategy>=2||r.level<2?4:0),dr(r,3),r.status=rr);else{var s=8+(r.w_bits-8<<4)<<8;s|=(r.strategy>=2||r.level<2?0:r.level<6?1:6===r.level?2:3)<<6,0!==r.strstart&&(s|=32),s+=31-s%31,r.status=rr,ur(r,s),0!==r.strstart&&(ur(r,e.adler>>>16),ur(r,65535&e.adler)),e.adler=1}if(69===r.status)if(r.gzhead.extra){for(n=r.pending;r.gzindex<(65535&r.gzhead.extra.length)&&(r.pending!==r.pending_buf_size||(r.gzhead.hcrc&&r.pending>n&&(e.adler=Xi(e.adler,r.pending_buf,r.pending-n,n)),cr(e),n=r.pending,r.pending!==r.pending_buf_size));)dr(r,255&r.gzhead.extra[r.gzindex]),r.gzindex++;r.gzhead.hcrc&&r.pending>n&&(e.adler=Xi(e.adler,r.pending_buf,r.pending-n,n)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=73)}else r.status=73;if(73===r.status)if(r.gzhead.name){n=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>n&&(e.adler=Xi(e.adler,r.pending_buf,r.pending-n,n)),cr(e),n=r.pending,r.pending===r.pending_buf_size)){o=1;break}o=r.gzindex<r.gzhead.name.length?255&r.gzhead.name.charCodeAt(r.gzindex++):0,dr(r,o)}while(0!==o);r.gzhead.hcrc&&r.pending>n&&(e.adler=Xi(e.adler,r.pending_buf,r.pending-n,n)),0===o&&(r.gzindex=0,r.status=91)}else r.status=91;if(91===r.status)if(r.gzhead.comment){n=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>n&&(e.adler=Xi(e.adler,r.pending_buf,r.pending-n,n)),cr(e),n=r.pending,r.pending===r.pending_buf_size)){o=1;break}o=r.gzindex<r.gzhead.comment.length?255&r.gzhead.comment.charCodeAt(r.gzindex++):0,dr(r,o)}while(0!==o);r.gzhead.hcrc&&r.pending>n&&(e.adler=Xi(e.adler,r.pending_buf,r.pending-n,n)),0===o&&(r.status=ir)}else r.status=ir;if(r.status===ir&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&cr(e),r.pending+2<=r.pending_buf_size&&(dr(r,255&e.adler),dr(r,e.adler>>8&255),e.adler=0,r.status=rr)):r.status=rr),0!==r.pending){if(cr(e),0===e.avail_out)return r.last_flush=-1,0}else if(0===e.avail_in&&sr(t)<=sr(i)&&4!==t)return or(e,-5);if(r.status===nr&&0!==e.avail_in)return or(e,-5);if(0!==e.avail_in||0!==r.lookahead||0!==t&&r.status!==nr){var a=2===r.strategy?function(e,t){for(var i;;){if(0===e.lookahead&&(pr(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,i=Yi(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(lr(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(lr(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(lr(e,!1),0===e.strm.avail_out)?1:2}(r,t):3===r.strategy?function(e,t){for(var i,r,n,o,s=e.window;;){if(e.lookahead<=er){if(pr(e),e.lookahead<=er&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=$i&&e.strstart>0&&(r=s[n=e.strstart-1])===s[++n]&&r===s[++n]&&r===s[++n]){o=e.strstart+er;do{}while(r===s[++n]&&r===s[++n]&&r===s[++n]&&r===s[++n]&&r===s[++n]&&r===s[++n]&&r===s[++n]&&r===s[++n]&&n<o);e.match_length=er-(o-n),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=$i?(i=Yi(e,1,e.match_length-$i),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=Yi(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(lr(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(lr(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(lr(e,!1),0===e.strm.avail_out)?1:2}(r,t):Qi[r.level].func(r,t);if(3!==a&&4!==a||(r.status=nr),1===a||3===a)return 0===e.avail_out&&(r.last_flush=-1),0;if(2===a&&(1===t?function(e){var t;Li(e,ti<<1,3),Pi(e,hi,yi),16===(t=e).bi_valid?(Oi(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(r):5!==t&&(Ki(r,0,0,!1),3===t&&(ar(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),cr(e),0===e.avail_out))return r.last_flush=-1,0}return 4!==t?0:r.wrap<=0?1:(2===r.wrap?(dr(r,255&e.adler),dr(r,e.adler>>8&255),dr(r,e.adler>>16&255),dr(r,e.adler>>24&255),dr(r,255&e.total_in),dr(r,e.total_in>>8&255),dr(r,e.total_in>>16&255),dr(r,e.total_in>>24&255)):(ur(r,e.adler>>>16),ur(r,65535&e.adler)),cr(e),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?0:1)}Qi=[new fr(0,0,0,0,(function(e,t){var i=65535;for(i>e.pending_buf_size-5&&(i=e.pending_buf_size-5);;){if(e.lookahead<=1){if(pr(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+i;if((0===e.strstart||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,lr(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-tr&&(lr(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(lr(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(lr(e,!1),e.strm.avail_out),1)})),new fr(4,4,8,4,mr),new fr(4,5,16,8,mr),new fr(4,6,32,32,mr),new fr(4,4,16,16,_r),new fr(8,16,32,32,_r),new fr(8,16,128,128,_r),new fr(8,32,128,256,_r),new fr(32,128,258,1024,_r),new fr(32,258,258,4096,_r)];var yr=30,Tr=12;function Sr(e,t){var i,r,n,o,s,a,c,l,d,u,h,p,m,_,f,g,E,v,y,T,S,I,A,R,b;i=e.state,r=e.next_in,R=e.input,n=r+(e.avail_in-5),o=e.next_out,b=e.output,s=o-(t-e.avail_out),a=o+(e.avail_out-257),c=i.dmax,l=i.wsize,d=i.whave,u=i.wnext,h=i.window,p=i.hold,m=i.bits,_=i.lencode,f=i.distcode,g=(1<<i.lenbits)-1,E=(1<<i.distbits)-1;e:do{m<15&&(p+=R[r++]<<m,m+=8,p+=R[r++]<<m,m+=8),v=_[p&g];t:for(;;){if(p>>>=y=v>>>24,m-=y,0==(y=v>>>16&255))b[o++]=65535&v;else{if(!(16&y)){if(!(64&y)){v=_[(65535&v)+(p&(1<<y)-1)];continue t}if(32&y){i.mode=Tr;break e}e.msg="invalid literal/length code",i.mode=yr;break e}T=65535&v,(y&=15)&&(m<y&&(p+=R[r++]<<m,m+=8),T+=p&(1<<y)-1,p>>>=y,m-=y),m<15&&(p+=R[r++]<<m,m+=8,p+=R[r++]<<m,m+=8),v=f[p&E];i:for(;;){if(p>>>=y=v>>>24,m-=y,!(16&(y=v>>>16&255))){if(!(64&y)){v=f[(65535&v)+(p&(1<<y)-1)];continue i}e.msg="invalid distance code",i.mode=yr;break e}if(S=65535&v,m<(y&=15)&&(p+=R[r++]<<m,(m+=8)<y&&(p+=R[r++]<<m,m+=8)),(S+=p&(1<<y)-1)>c){e.msg="invalid distance too far back",i.mode=yr;break e}if(p>>>=y,m-=y,S>(y=o-s)){if((y=S-y)>d&&i.sane){e.msg="invalid distance too far back",i.mode=yr;break e}if(I=0,A=h,0===u){if(I+=l-y,y<T){T-=y;do{b[o++]=h[I++]}while(--y);I=o-S,A=b}}else if(u<y){if(I+=l+u-y,(y-=u)<T){T-=y;do{b[o++]=h[I++]}while(--y);if(I=0,u<T){T-=y=u;do{b[o++]=h[I++]}while(--y);I=o-S,A=b}}}else if(I+=u-y,y<T){T-=y;do{b[o++]=h[I++]}while(--y);I=o-S,A=b}for(;T>2;)b[o++]=A[I++],b[o++]=A[I++],b[o++]=A[I++],T-=3;T&&(b[o++]=A[I++],T>1&&(b[o++]=A[I++]))}else{I=o-S;do{b[o++]=b[I++],b[o++]=b[I++],b[o++]=b[I++],T-=3}while(T>2);T&&(b[o++]=b[I++],T>1&&(b[o++]=b[I++]))}break}}break}}while(r<n&&o<a);r-=T=m>>3,p&=(1<<(m-=T<<3))-1,e.next_in=r,e.next_out=o,e.avail_in=r<n?n-r+5:5-(r-n),e.avail_out=o<a?a-o+257:257-(o-a),i.hold=p,i.bits=m}var Ir=15,Ar=852,Rr=592,br=0,Cr=1,kr=2,wr=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],Nr=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],Dr=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],Or=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];function Lr(e,t,i,r,n,o,s,a){var c,l,d,u,h,p,m,_,f,g=a.bits,E=0,v=0,y=0,T=0,S=0,I=0,A=0,R=0,b=0,C=0,k=null,w=0,N=new Yt(Ir+1),D=new Yt(Ir+1),O=null,L=0;for(E=0;E<=Ir;E++)N[E]=0;for(v=0;v<r;v++)N[t[i+v]]++;for(S=g,T=Ir;T>=1&&0===N[T];T--);if(S>T&&(S=T),0===T)return n[o++]=20971520,n[o++]=20971520,a.bits=1,0;for(y=1;y<T&&0===N[y];y++);for(S<y&&(S=y),R=1,E=1;E<=Ir;E++)if(R<<=1,(R-=N[E])<0)return-1;if(R>0&&(e===br||1!==T))return-1;for(D[1]=0,E=1;E<Ir;E++)D[E+1]=D[E]+N[E];for(v=0;v<r;v++)0!==t[i+v]&&(s[D[t[i+v]]++]=v);if(e===br?(k=O=s,p=19):e===Cr?(k=wr,w-=257,O=Nr,L-=257,p=256):(k=Dr,O=Or,p=-1),C=0,v=0,E=y,h=o,I=S,A=0,d=-1,u=(b=1<<S)-1,e===Cr&&b>Ar||e===kr&&b>Rr)return 1;for(;;){m=E-A,s[v]<p?(_=0,f=s[v]):s[v]>p?(_=O[L+s[v]],f=k[w+s[v]]):(_=96,f=0),c=1<<E-A,y=l=1<<I;do{n[h+(C>>A)+(l-=c)]=m<<24|_<<16|f}while(0!==l);for(c=1<<E-1;C&c;)c>>=1;if(0!==c?(C&=c-1,C+=c):C=0,v++,0==--N[E]){if(E===T)break;E=t[i+s[v]]}if(E>S&&(C&u)!==d){for(0===A&&(A=S),h+=y,R=1<<(I=E-A);I+A<T&&!((R-=N[I+A])<=0);)I++,R<<=1;if(b+=1<<I,e===Cr&&b>Ar||e===kr&&b>Rr)return 1;n[d=C&u]=S<<24|I<<16|h-o}}return 0!==C&&(n[h+C]=E-A<<24|64<<16),a.bits=S,0}var Pr=1,Mr=2,xr=0,Vr=-2,Ur=1,Br=12,Fr=30,Hr=852,jr=592;function Wr(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function zr(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Yt(320),this.work=new Yt(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function Gr(e){var t,i,r;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,(i=e)&&i.state?(r=i.state,i.total_in=i.total_out=r.total=0,i.msg="",r.wrap&&(i.adler=1&r.wrap),r.mode=Ur,r.last=0,r.havedict=0,r.dmax=32768,r.head=null,r.hold=0,r.bits=0,r.lencode=r.lendyn=new Jt(Hr),r.distcode=r.distdyn=new Jt(jr),r.sane=1,r.back=-1,xr):Vr):Vr}var Kr,Yr,Jr=!0;function qr(e){if(Jr){var t;for(Kr=new Jt(512),Yr=new Jt(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Lr(Pr,e.lens,0,288,Kr,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Lr(Mr,e.lens,0,32,Yr,0,e.work,{bits:5}),Jr=!1}e.lencode=Kr,e.lenbits=9,e.distcode=Yr,e.distbits=5}var Xr;function Qr(e){if(e<1||e>7)throw new TypeError("Bad argument");this.mode=e,this.init_done=!1,this.write_in_progress=!1,this.pending_close=!1,this.windowBits=0,this.level=0,this.memLevel=0,this.strategy=0,this.dictionary=null}function Zr(e,t){for(var i=0;i<e.length;i++)this[t+i]=e[i]}Qr.prototype.init=function(e,t,i,r,n){var o;switch(this.windowBits=e,this.level=t,this.memLevel=i,this.strategy=r,3!==this.mode&&4!==this.mode||(this.windowBits+=16),7===this.mode&&(this.windowBits+=32),5!==this.mode&&6!==this.mode||(this.windowBits=-this.windowBits),this.strm=new zt,this.mode){case 1:case 3:case 5:o=function(e,t,i,r,n,o){if(!e)return Zi;var s=1;if(-1===t&&(t=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),n<1||n>9||r<8||r>15||t<0||t>9||o<0||o>4)return or(e,Zi);8===r&&(r=9);var a=new gr;return e.state=a,a.strm=e,a.wrap=s,a.gzhead=null,a.w_bits=r,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=n+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+$i-1)/$i),a.window=new Kt(2*a.w_size),a.head=new Yt(a.hash_size),a.prev=new Yt(a.w_size),a.lit_bufsize=1<<n+6,a.pending_buf_size=4*a.lit_bufsize,a.pending_buf=new Kt(a.pending_buf_size),a.d_buf=1*a.lit_bufsize,a.l_buf=3*a.lit_bufsize,a.level=t,a.strategy=o,a.method=8,Er(e)}(this.strm,this.level,0,this.windowBits,this.memLevel,this.strategy);break;case 2:case 4:case 6:case 7:o=function(e,t){var i,r,n,o,s,a;return e?(r=new zr,e.state=r,r.window=null,o=t,(i=(n=e)&&n.state?(a=n.state,o<0?(s=0,o=-o):(s=1+(o>>4),o<48&&(o&=15)),o&&(o<8||o>15)?Vr:(null!==a.window&&a.wbits!==o&&(a.window=null),a.wrap=s,a.wbits=o,Gr(n))):Vr)!==xr&&(e.state=null),i):Vr}(this.strm,this.windowBits);break;default:throw new Error("Unknown mode "+this.mode)}0===o?(this.write_in_progress=!1,this.init_done=!0):this._error(o)},Qr.prototype.params=function(){throw new Error("deflateParams Not supported")},Qr.prototype._writeCheck=function(){if(!this.init_done)throw new Error("write before init");if(0===this.mode)throw new Error("already finalized");if(this.write_in_progress)throw new Error("write already in progress");if(this.pending_close)throw new Error("close is pending")},Qr.prototype.write=function(e,t,i,r,n,o,s){this._writeCheck(),this.write_in_progress=!0;var a=this;return ve((function(){a.write_in_progress=!1;var c=a._write(e,t,i,r,n,o,s);a.callback(c[0],c[1]),a.pending_close&&a.close()})),this},Qr.prototype.writeSync=function(e,t,i,r,n,o,s){return this._writeCheck(),this._write(e,t,i,r,n,o,s)},Qr.prototype._write=function(e,t,i,r,n,o,s){if(this.write_in_progress=!0,0!==e&&1!==e&&2!==e&&3!==e&&4!==e&&5!==e)throw new Error("Invalid flush value");null==t&&(t=new y(0),r=0,i=0),n._set?n.set=n._set:n.set=Zr;var a,c=this.strm;switch(c.avail_in=r,c.input=t,c.next_in=i,c.avail_out=s,c.output=n,c.next_out=o,this.mode){case 1:case 3:case 5:a=vr(c,e);break;case 7:case 2:case 4:case 6:a=function(e,t){var i,r,n,o,s,a,c,l,d,u,h,p,m,_,f,g,E,v,y,T,S,I,A,R,b,C,k,w,N,D,O=0,L=new Kt(4),P=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return Vr;(i=e.state).mode===Br&&(i.mode=13),s=e.next_out,n=e.output,c=e.avail_out,o=e.next_in,r=e.input,a=e.avail_in,l=i.hold,d=i.bits,u=a,h=c,I=xr;e:for(;;)switch(i.mode){case Ur:if(0===i.wrap){i.mode=13;break}for(;d<16;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}if(2&i.wrap&&35615===l){i.check=0,L[0]=255&l,L[1]=l>>>8&255,i.check=Xi(i.check,L,2,0),l=0,d=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&l)<<8)+(l>>8))%31){e.msg="incorrect header check",i.mode=Fr;break}if(8!=(15&l)){e.msg="unknown compression method",i.mode=Fr;break}if(d-=4,S=8+(15&(l>>>=4)),0===i.wbits)i.wbits=S;else if(S>i.wbits){e.msg="invalid window size",i.mode=Fr;break}i.dmax=1<<S,e.adler=i.check=1,i.mode=512&l?10:Br,l=0,d=0;break;case 2:for(;d<16;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}if(i.flags=l,8!=(255&i.flags)){e.msg="unknown compression method",i.mode=Fr;break}if(57344&i.flags){e.msg="unknown header flags set",i.mode=Fr;break}i.head&&(i.head.text=l>>8&1),512&i.flags&&(L[0]=255&l,L[1]=l>>>8&255,i.check=Xi(i.check,L,2,0)),l=0,d=0,i.mode=3;case 3:for(;d<32;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}i.head&&(i.head.time=l),512&i.flags&&(L[0]=255&l,L[1]=l>>>8&255,L[2]=l>>>16&255,L[3]=l>>>24&255,i.check=Xi(i.check,L,4,0)),l=0,d=0,i.mode=4;case 4:for(;d<16;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}i.head&&(i.head.xflags=255&l,i.head.os=l>>8),512&i.flags&&(L[0]=255&l,L[1]=l>>>8&255,i.check=Xi(i.check,L,2,0)),l=0,d=0,i.mode=5;case 5:if(1024&i.flags){for(;d<16;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}i.length=l,i.head&&(i.head.extra_len=l),512&i.flags&&(L[0]=255&l,L[1]=l>>>8&255,i.check=Xi(i.check,L,2,0)),l=0,d=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&((p=i.length)>a&&(p=a),p&&(i.head&&(S=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),Gt(i.head.extra,r,o,p,S)),512&i.flags&&(i.check=Xi(i.check,r,p,o)),a-=p,o+=p,i.length-=p),i.length))break e;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===a)break e;p=0;do{S=r[o+p++],i.head&&S&&i.length<65536&&(i.head.name+=String.fromCharCode(S))}while(S&&p<a);if(512&i.flags&&(i.check=Xi(i.check,r,p,o)),a-=p,o+=p,S)break e}else i.head&&(i.head.name=null);i.length=0,i.mode=8;case 8:if(4096&i.flags){if(0===a)break e;p=0;do{S=r[o+p++],i.head&&S&&i.length<65536&&(i.head.comment+=String.fromCharCode(S))}while(S&&p<a);if(512&i.flags&&(i.check=Xi(i.check,r,p,o)),a-=p,o+=p,S)break e}else i.head&&(i.head.comment=null);i.mode=9;case 9:if(512&i.flags){for(;d<16;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}if(l!==(65535&i.check)){e.msg="header crc mismatch",i.mode=Fr;break}l=0,d=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=Br;break;case 10:for(;d<32;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}e.adler=i.check=Wr(l),l=0,d=0,i.mode=11;case 11:if(0===i.havedict)return e.next_out=s,e.avail_out=c,e.next_in=o,e.avail_in=a,i.hold=l,i.bits=d,2;e.adler=i.check=1,i.mode=Br;case Br:if(5===t||6===t)break e;case 13:if(i.last){l>>>=7&d,d-=7&d,i.mode=27;break}for(;d<3;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}switch(i.last=1&l,d-=1,3&(l>>>=1)){case 0:i.mode=14;break;case 1:if(qr(i),i.mode=20,6===t){l>>>=2,d-=2;break e}break;case 2:i.mode=17;break;case 3:e.msg="invalid block type",i.mode=Fr}l>>>=2,d-=2;break;case 14:for(l>>>=7&d,d-=7&d;d<32;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}if((65535&l)!=(l>>>16^65535)){e.msg="invalid stored block lengths",i.mode=Fr;break}if(i.length=65535&l,l=0,d=0,i.mode=15,6===t)break e;case 15:i.mode=16;case 16:if(p=i.length){if(p>a&&(p=a),p>c&&(p=c),0===p)break e;Gt(n,r,o,p,s),a-=p,o+=p,c-=p,s+=p,i.length-=p;break}i.mode=Br;break;case 17:for(;d<14;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}if(i.nlen=257+(31&l),l>>>=5,d-=5,i.ndist=1+(31&l),l>>>=5,d-=5,i.ncode=4+(15&l),l>>>=4,d-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=Fr;break}i.have=0,i.mode=18;case 18:for(;i.have<i.ncode;){for(;d<3;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}i.lens[P[i.have++]]=7&l,l>>>=3,d-=3}for(;i.have<19;)i.lens[P[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,A={bits:i.lenbits},I=Lr(0,i.lens,0,19,i.lencode,0,i.work,A),i.lenbits=A.bits,I){e.msg="invalid code lengths set",i.mode=Fr;break}i.have=0,i.mode=19;case 19:for(;i.have<i.nlen+i.ndist;){for(;g=(O=i.lencode[l&(1<<i.lenbits)-1])>>>16&255,E=65535&O,!((f=O>>>24)<=d);){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}if(E<16)l>>>=f,d-=f,i.lens[i.have++]=E;else{if(16===E){for(R=f+2;d<R;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}if(l>>>=f,d-=f,0===i.have){e.msg="invalid bit length repeat",i.mode=Fr;break}S=i.lens[i.have-1],p=3+(3&l),l>>>=2,d-=2}else if(17===E){for(R=f+3;d<R;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}d-=f,S=0,p=3+(7&(l>>>=f)),l>>>=3,d-=3}else{for(R=f+7;d<R;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}d-=f,S=0,p=11+(127&(l>>>=f)),l>>>=7,d-=7}if(i.have+p>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=Fr;break}for(;p--;)i.lens[i.have++]=S}}if(i.mode===Fr)break;if(0===i.lens[256]){e.msg="invalid code -- missing end-of-block",i.mode=Fr;break}if(i.lenbits=9,A={bits:i.lenbits},I=Lr(Pr,i.lens,0,i.nlen,i.lencode,0,i.work,A),i.lenbits=A.bits,I){e.msg="invalid literal/lengths set",i.mode=Fr;break}if(i.distbits=6,i.distcode=i.distdyn,A={bits:i.distbits},I=Lr(Mr,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,A),i.distbits=A.bits,I){e.msg="invalid distances set",i.mode=Fr;break}if(i.mode=20,6===t)break e;case 20:i.mode=21;case 21:if(a>=6&&c>=258){e.next_out=s,e.avail_out=c,e.next_in=o,e.avail_in=a,i.hold=l,i.bits=d,Sr(e,h),s=e.next_out,n=e.output,c=e.avail_out,o=e.next_in,r=e.input,a=e.avail_in,l=i.hold,d=i.bits,i.mode===Br&&(i.back=-1);break}for(i.back=0;g=(O=i.lencode[l&(1<<i.lenbits)-1])>>>16&255,E=65535&O,!((f=O>>>24)<=d);){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}if(g&&!(240&g)){for(v=f,y=g,T=E;g=(O=i.lencode[T+((l&(1<<v+y)-1)>>v)])>>>16&255,E=65535&O,!(v+(f=O>>>24)<=d);){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}l>>>=v,d-=v,i.back+=v}if(l>>>=f,d-=f,i.back+=f,i.length=E,0===g){i.mode=26;break}if(32&g){i.back=-1,i.mode=Br;break}if(64&g){e.msg="invalid literal/length code",i.mode=Fr;break}i.extra=15&g,i.mode=22;case 22:if(i.extra){for(R=i.extra;d<R;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}i.length+=l&(1<<i.extra)-1,l>>>=i.extra,d-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;g=(O=i.distcode[l&(1<<i.distbits)-1])>>>16&255,E=65535&O,!((f=O>>>24)<=d);){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}if(!(240&g)){for(v=f,y=g,T=E;g=(O=i.distcode[T+((l&(1<<v+y)-1)>>v)])>>>16&255,E=65535&O,!(v+(f=O>>>24)<=d);){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}l>>>=v,d-=v,i.back+=v}if(l>>>=f,d-=f,i.back+=f,64&g){e.msg="invalid distance code",i.mode=Fr;break}i.offset=E,i.extra=15&g,i.mode=24;case 24:if(i.extra){for(R=i.extra;d<R;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}i.offset+=l&(1<<i.extra)-1,l>>>=i.extra,d-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=Fr;break}i.mode=25;case 25:if(0===c)break e;if(p=h-c,i.offset>p){if((p=i.offset-p)>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=Fr;break}p>i.wnext?(p-=i.wnext,m=i.wsize-p):m=i.wnext-p,p>i.length&&(p=i.length),_=i.window}else _=n,m=s-i.offset,p=i.length;p>c&&(p=c),c-=p,i.length-=p;do{n[s++]=_[m++]}while(--p);0===i.length&&(i.mode=21);break;case 26:if(0===c)break e;n[s++]=i.length,c--,i.mode=21;break;case 27:if(i.wrap){for(;d<32;){if(0===a)break e;a--,l|=r[o++]<<d,d+=8}if(h-=c,e.total_out+=h,i.total+=h,h&&(e.adler=i.check=i.flags?Xi(i.check,n,h,s-h):Ji(i.check,n,h,s-h)),h=c,(i.flags?l:Wr(l))!==i.check){e.msg="incorrect data check",i.mode=Fr;break}l=0,d=0}i.mode=28;case 28:if(i.wrap&&i.flags){for(;d<32;){if(0===a)break e;a--,l+=r[o++]<<d,d+=8}if(l!==(4294967295&i.total)){e.msg="incorrect length check",i.mode=Fr;break}l=0,d=0}i.mode=29;case 29:I=1;break e;case Fr:I=-3;break e;case 31:return-4;default:return Vr}return e.next_out=s,e.avail_out=c,e.next_in=o,e.avail_in=a,i.hold=l,i.bits=d,(i.wsize||h!==e.avail_out&&i.mode<Fr&&(i.mode<27||4!==t))&&(b=e,C=e.output,k=e.next_out,w=h-e.avail_out,null===(D=b.state).window&&(D.wsize=1<<D.wbits,D.wnext=0,D.whave=0,D.window=new Kt(D.wsize)),w>=D.wsize?(Gt(D.window,C,k-D.wsize,D.wsize,0),D.wnext=0,D.whave=D.wsize):((N=D.wsize-D.wnext)>w&&(N=w),Gt(D.window,C,k-w,N,D.wnext),(w-=N)?(Gt(D.window,C,k-w,w,0),D.wnext=w,D.whave=D.wsize):(D.wnext+=N,D.wnext===D.wsize&&(D.wnext=0),D.whave<D.wsize&&(D.whave+=N)))),u-=e.avail_in,h-=e.avail_out,e.total_in+=u,e.total_out+=h,i.total+=h,i.wrap&&h&&(e.adler=i.check=i.flags?Xi(i.check,n,h,e.next_out-h):Ji(i.check,n,h,e.next_out-h)),e.data_type=i.bits+(i.last?64:0)+(i.mode===Br?128:0)+(20===i.mode||15===i.mode?256:0),(0===u&&0===h||4===t)&&I===xr&&(I=-5),I}(c,e);break;default:throw new Error("Unknown mode "+this.mode)}return 1!==a&&0!==a&&this._error(a),this.write_in_progress=!1,[c.avail_in,c.avail_out]},Qr.prototype.close=function(){this.write_in_progress?this.pending_close=!0:(this.pending_close=!1,1===this.mode||3===this.mode||5===this.mode?function(e){var t;e&&e.state&&(42!==(t=e.state.status)&&69!==t&&73!==t&&91!==t&&t!==ir&&t!==rr&&t!==nr?or(e,Zi):(e.state=null,t===rr&&or(e,-3)))}(this.strm):function(e){if(!e||!e.state)return Vr;var t=e.state;t.window&&(t.window=null),e.state=null}(this.strm),this.mode=0)},Qr.prototype.reset=function(){switch(this.mode){case 1:case 5:Xr=Er(this.strm);break;case 2:case 6:Xr=Gr(this.strm)}0!==Xr&&this._error(Xr)},Qr.prototype._error=function(e){this.onerror(Wt[e]+": "+this.strm.msg,e),this.write_in_progress=!1,this.pending_close&&this.close()};var $r=Object.freeze({NONE:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8,Zlib:Qr}),en={};Object.keys($r).forEach((function(e){en[e]=$r[e]})),en.Z_MIN_WINDOWBITS=8,en.Z_MAX_WINDOWBITS=15,en.Z_DEFAULT_WINDOWBITS=15,en.Z_MIN_CHUNK=64,en.Z_MAX_CHUNK=1/0,en.Z_DEFAULT_CHUNK=16384,en.Z_MIN_MEMLEVEL=1,en.Z_MAX_MEMLEVEL=9,en.Z_DEFAULT_MEMLEVEL=8,en.Z_MIN_LEVEL=-1,en.Z_MAX_LEVEL=9,en.Z_DEFAULT_LEVEL=en.Z_DEFAULT_COMPRESSION;var tn={Z_OK:en.Z_OK,Z_STREAM_END:en.Z_STREAM_END,Z_NEED_DICT:en.Z_NEED_DICT,Z_ERRNO:en.Z_ERRNO,Z_STREAM_ERROR:en.Z_STREAM_ERROR,Z_DATA_ERROR:en.Z_DATA_ERROR,Z_MEM_ERROR:en.Z_MEM_ERROR,Z_BUF_ERROR:en.Z_BUF_ERROR,Z_VERSION_ERROR:en.Z_VERSION_ERROR};function rn(e,t){if("string"==typeof t&&(t=new y(t)),!re(t))throw new TypeError("Not a string or buffer");var i=en.Z_FINISH;return e._processChunk(t,i)}function nn(e){if(!(this instanceof nn))return new nn(e);un.call(this,e,en.DEFLATE)}function on(e){if(!(this instanceof on))return new on(e);un.call(this,e,en.INFLATE)}function sn(e){if(!(this instanceof sn))return new sn(e);un.call(this,e,en.GZIP)}function an(e){if(!(this instanceof an))return new an(e);un.call(this,e,en.GUNZIP)}function cn(e){if(!(this instanceof cn))return new cn(e);un.call(this,e,en.DEFLATERAW)}function ln(e){if(!(this instanceof ln))return new ln(e);un.call(this,e,en.INFLATERAW)}function dn(e){if(!(this instanceof dn))return new dn(e);un.call(this,e,en.UNZIP)}function un(e,t){if(this._opts=e=e||{},this._chunkSize=e.chunkSize||en.Z_DEFAULT_CHUNK,Bt.call(this,e),e.flush&&e.flush!==en.Z_NO_FLUSH&&e.flush!==en.Z_PARTIAL_FLUSH&&e.flush!==en.Z_SYNC_FLUSH&&e.flush!==en.Z_FULL_FLUSH&&e.flush!==en.Z_FINISH&&e.flush!==en.Z_BLOCK)throw new Error("Invalid flush flag: "+e.flush);if(this._flushFlag=e.flush||en.Z_NO_FLUSH,e.chunkSize&&(e.chunkSize<en.Z_MIN_CHUNK||e.chunkSize>en.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+e.chunkSize);if(e.windowBits&&(e.windowBits<en.Z_MIN_WINDOWBITS||e.windowBits>en.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+e.windowBits);if(e.level&&(e.level<en.Z_MIN_LEVEL||e.level>en.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+e.level);if(e.memLevel&&(e.memLevel<en.Z_MIN_MEMLEVEL||e.memLevel>en.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+e.memLevel);if(e.strategy&&e.strategy!=en.Z_FILTERED&&e.strategy!=en.Z_HUFFMAN_ONLY&&e.strategy!=en.Z_RLE&&e.strategy!=en.Z_FIXED&&e.strategy!=en.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+e.strategy);if(e.dictionary&&!re(e.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._binding=new en.Zlib(t);var i=this;this._hadError=!1,this._binding.onerror=function(e,t){i._binding=null,i._hadError=!0;var r=new Error(e);r.errno=t,r.code=en.codes[t],i.emit("error",r)};var r=en.Z_DEFAULT_COMPRESSION;"number"==typeof e.level&&(r=e.level);var n=en.Z_DEFAULT_STRATEGY;"number"==typeof e.strategy&&(n=e.strategy),this._binding.init(e.windowBits||en.Z_DEFAULT_WINDOWBITS,r,e.memLevel||en.Z_DEFAULT_MEMLEVEL,n,e.dictionary),this._buffer=new y(this._chunkSize),this._offset=0,this._closed=!1,this._level=r,this._strategy=n,this.once("end",this.close)}Object.keys(tn).forEach((function(e){tn[tn[e]]=e})),we(un,Bt),un.prototype.params=function(e,t,i){if(e<en.Z_MIN_LEVEL||e>en.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+e);if(t!=en.Z_FILTERED&&t!=en.Z_HUFFMAN_ONLY&&t!=en.Z_RLE&&t!=en.Z_FIXED&&t!=en.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+t);if(this._level!==e||this._strategy!==t){var r=this;this.flush(en.Z_SYNC_FLUSH,(function(){r._binding.params(e,t),r._hadError||(r._level=e,r._strategy=t,i&&i())}))}else ve(i)},un.prototype.reset=function(){return this._binding.reset()},un.prototype._flush=function(e){this._transform(new y(0),"",e)},un.prototype.flush=function(e,t){var i=this._writableState;if(("function"==typeof e||void 0===e&&!t)&&(t=e,e=en.Z_FULL_FLUSH),i.ended)t&&ve(t);else if(i.ending)t&&this.once("end",t);else if(i.needDrain){var r=this;this.once("drain",(function(){r.flush(t)}))}else this._flushFlag=e,this.write(new y(0),"",t)},un.prototype.close=function(e){if(e&&ve(e),!this._closed){this._closed=!0,this._binding.close();var t=this;ve((function(){t.emit("close")}))}},un.prototype._transform=function(e,t,i){var r,n=this._writableState,o=(n.ending||n.ended)&&(!e||n.length===e.length);if(null===!e&&!re(e))return i(new Error("invalid input"));o?r=en.Z_FINISH:(r=this._flushFlag,e.length>=n.length&&(this._flushFlag=this._opts.flush||en.Z_NO_FLUSH)),this._processChunk(e,r,i)},un.prototype._processChunk=function(e,t,i){var r=e&&e.length,n=this._chunkSize-this._offset,o=0,s=this,a="function"==typeof i;if(!a){var c,l=[],d=0;this.on("error",(function(e){c=e}));do{var u=this._binding.writeSync(t,e,o,r,this._buffer,this._offset,n)}while(!this._hadError&&m(u[0],u[1]));if(this._hadError)throw c;var h=y.concat(l,d);return this.close(),h}var p=this._binding.write(t,e,o,r,this._buffer,this._offset,n);function m(c,u){if(!s._hadError){var h=n-u;if(function(e,t){if(!e)throw new Error("have should not go down")}(h>=0),h>0){var p=s._buffer.slice(s._offset,s._offset+h);s._offset+=h,a?s.push(p):(l.push(p),d+=p.length)}if((0===u||s._offset>=s._chunkSize)&&(n=s._chunkSize,s._offset=0,s._buffer=new y(s._chunkSize)),0===u){if(o+=r-c,r=c,!a)return!0;var _=s._binding.write(t,e,o,r,s._buffer,s._offset,s._chunkSize);return _.callback=m,void(_.buffer=e)}if(!a)return!1;i()}}p.buffer=e,p.callback=m},we(nn,un),we(on,un),we(sn,un),we(an,un),we(cn,un),we(ln,un),we(dn,un);var hn=function(e,t){return rn(new nn(t),e)},pn=function(e,t){return rn(new on(t),e)};class mn{constructor(e,t,i){this.SDKAPPID=e,this.EXPIRETIME=i,this.PRIVATEKEY=t}genTestUserSig(e){return this._isNumber(this.SDKAPPID)?this._isString(this.PRIVATEKEY)?this._isString(e)?this._isNumber(this.EXPIRETIME)?(this.SDKAPPID,this.PRIVATEKEY,this.EXPIRETIME,this.genSigWithUserbuf(e,this.EXPIRETIME,null)):(console.error("expireTime must be a number"),""):(console.error("userID must be a string"),""):(console.error("privateKey must be a string"),""):(console.error("sdkAppID must be a number"),"")}newBuffer(e,t){return y.from?y.from(e,t):new y(e,t)}unescape(e){return e.replace(/_/g,"=").replace(/\-/g,"/").replace(/\*/g,"+")}escape(e){return e.replace(/\+/g,"*").replace(/\//g,"-").replace(/=/g,"_")}encode(e){return this.escape(this.newBuffer(e).toString("base64"))}decode(e){return this.newBuffer(this.unescape(e),"base64")}base64encode(e){return this.newBuffer(e).toString("base64")}base64decode(e){return this.newBuffer(e,"base64").toString()}_hmacsha256(e,t,i,r){let n="TLS.identifier:"+e+"\n";n+="TLS.sdkappid:"+this.SDKAPPID+"\n",n+="TLS.time:"+t+"\n",n+="TLS.expire:"+i+"\n",null!=r&&(n+="TLS.userbuf:"+r+"\n");let o=ae.HmacSHA256(n,this.PRIVATEKEY);return ae.enc.Base64.stringify(o)}_utc(){return Math.round(Date.now()/1e3)}_isNumber(e){return null!==e&&("number"==typeof e&&!isNaN(e-0)||"object"==typeof e&&e.constructor===Number)}_isString(e){return"string"==typeof e}genSigWithUserbuf(e,t,i){let r=this._utc(),n={"TLS.ver":"2.0","TLS.identifier":e,"TLS.sdkappid":this.SDKAPPID,"TLS.time":r,"TLS.expire":t},o="";if(null!=i){let s=this.base64encode(i);n["TLS.userbuf"]=s,o=this._hmacsha256(e,r,t,s)}else o=this._hmacsha256(e,r,t,null);n["TLS.sig"]=o;let s=JSON.stringify(n),a=hn(this.newBuffer(s)).toString("base64"),c=this.escape(a);return c}validate(e){let t=this.decode(e);pn(t)}}const _n=20008434,fn=604800,gn="aa4c2a6f23c55f8826fa3a1fd6023c82ee161d78d32124dabd704f068dac420b";function En(e){const t=new mn(_n,gn,fn).genTestUserSig(e);return{SDKAppID:_n,userSig:t}}function vn(e){return{addSuccessLog:function(t){e.value.push({type:"success",content:t})},addFailedLog:function(t){e.value.push({type:"failed",content:t}),e.value},handleClearLog:()=>{e.value=[]}}}const yn=e.ref(!1),Tn=e.ref(!1),Sn=e.ref("stopped"),In=e.ref("stopped"),An=e.ref("stopped"),Rn=e.markRaw(o.create()),bn=e.ref([]),{addSuccessLog:Cn,addFailedLog:kn}=vn(bn);function wn(i,r,n){async function s(){An.value="starting";try{await Rn.startLocalAudio({option:{microphoneId:n.audioDeviceId}}),An.value="started",Cn("Local audio started successfully")}catch(e){An.value="stopped",kn(`Local audio is failed to started. Error: ${e.message}`)}}async function a(){if("started"===An.value){An.value="stopping";try{await Rn.stopLocalAudio(),An.value="stopped",Cn("Local audio stopped successfully")}catch(e){An.value="started",kn(`Local audio is failed to stopped. Error: ${e.message}`)}}else kn("The audio has not been started")}async function c(){In.value="starting";try{await Rn.startLocalVideo({view:"local",option:{cameraId:n.videoDeviceId,profile:"1080p"}}),In.value="started",Cn("Local audio stopped successfully")}catch(e){In.value="stopped",kn(`Local audio is failed to stopped. Error: ${e.message}`)}}async function l(){if("started"===In.value){In.value="stopping";try{await Rn.stopLocalVideo(),In.value="stopped",Cn("Local audio stopped successfully")}catch(e){In.value="started",kn(`Local audio is failed to stopped. Error: ${e.message}`)}}else kn("The audio has not been started")}const{handleError:d,handleKickedOut:u,handleRemoteUserEnter:h,handleRemoteUserExit:p,handleRemoteVideoAvailable:m,handleRemoteVideoUnavailable:_,handleRemoteAudioUnavailable:f,handleRemoteAudioAvailable:g,handleScreenShareStopped:E,handleVolumeValue:v,handleNetworkQuality:y,handleAutoplayFailed:T,handleConnectStateChanged:S,handleAudioPlayStateChanged:I,handleVideoPlayStateChanged:A,handleDeviceChanged:R,handlePublishStateChanged:b,handleStatistics:C,handleSEIMessage:k,handleTrack:w}=function(i,r,n,s){const{addFailedLog:a,addSuccessLog:c}=vn(s);return{handleError:function(e){t.ElMessage({message:`Local error: ${e.message}`,type:"error"}),a(`Local error: ${e.message}`),r(o.EVENT.ERROR,e)},handleKickedOut:function(e){t.ElMessage({message:`User has been kicked out for ${e.reason}`,type:"warning"}),a(`User has been kicked out for ${e.reason}`),r(o.EVENT.KICKED_OUT,e)},handleRemoteUserEnter:function(e){const{userId:t}=e;n.remoteUsersViews.push({userId:t,streamType:"main"}),c(`Remote User [${t}] entered`),r(o.EVENT.REMOTE_USER_ENTER,e)},handleRemoteUserExit:function(e){let t=n.remoteUsersViews.findIndex((t=>t.userId==e.userId));n.remoteUsersViews.splice(t,1),c(`远端用户: [${e.userId}] 退房事件`),r(o.EVENT.REMOTE_USER_EXIT,e)},handleRemoteVideoAvailable:async function(t){const{userId:n,streamType:s}=t;try{await e.nextTick(),i.startRemoteVideo({userId:n,streamType:s,view:n}),c(`Play remote video success: [${n}]`),r(o.EVENT.REMOTE_VIDEO_AVAILABLE,t)}catch(l){a(`Play remote video failed: [${n}], error: ${l.message}`)}},handleRemoteVideoUnavailable:function(e){const{streamType:t,userId:n}=e;c(`[${n}] [${t}] video unavailable`),i.stopRemoteVideo({userId:n,streamType:t}),r(o.EVENT.REMOTE_VIDEO_UNAVAILABLE,e)},handleRemoteAudioUnavailable:function(e){c(`[${e.userId}] audio unavailable`),r(o.EVENT.REMOTE_AUDIO_UNAVAILABLE,e)},handleRemoteAudioAvailable:function(e){c(`[${e.userId}] audio available`),r(o.EVENT.REMOTE_AUDIO_AVAILABLE,e)},handleScreenShareStopped:function(){c("本地屏幕分享停止事件"),r(o.EVENT.SCREEN_SHARE_STOPPED)},handleVolumeValue:function(e){const{userId:t,volume:i}=e;r(o.EVENT.AUDIO_VOLUME,e)},handleNetworkQuality:function(e){r(o.EVENT.NETWORK_QUALITY,e)},handleAutoplayFailed:function(e){r(o.EVENT.AUTOPLAY_FAILED,e)},handleConnectStateChanged:function(e){r(o.EVENT.CONNECTION_STATE_CHANGED,e)},handleAudioPlayStateChanged:function(e){e.userId,e.state,e.reason,r(o.EVENT.AUDIO_PLAY_STATE_CHANGED,e)},handleVideoPlayStateChanged:function(e){e.userId,e.streamType,e.state,e.reason,r(o.EVENT.VIDEO_PLAY_STATE_CHANGED,e)},handleDeviceChanged:function(e){e.type,e.device.label,e.action,r(o.EVENT.DEVICE_CHANGED,e)},handlePublishStateChanged:function(e){e.mediaType,e.state,e.reason,r(o.EVENT.PUBLISH_STATE_CHANGED,e)},handleStatistics:function(e){r(o.EVENT.STATISTICS,e)},handleSEIMessage:function(e){r(o.EVENT.SEI_MESSAGE,e)},handleTrack:function(e){r(o.EVENT.TRACK,e)}}}(Rn,r,n,bn);e.watch((()=>Sn.value),(e=>{r("changeRoomState",e)}),{deep:!0,immediate:!0}),e.watch((()=>bn.value),(e=>{r("updateLog",e)}),{deep:!0,immediate:!0});return{trtc:Rn,logs:bn,roomStatus:Sn,audioMuted:yn,videoMuted:Tn,camStatus:In,micStatus:An,handleEnter:async function(){if(i.sdkAppId&&i.sdkSecretKey&&i.roomId&&i.userId){Sn.value="entering";try{let e={roomId:Number(i.roomId),sdkAppId:Number(i.sdkAppId),userId:i.userId,userSig:i.userSig};await Rn.enterRoom(e),Sn.value="entered",Rn.on(o.EVENT.ERROR,d),Rn.on(o.EVENT.KICKED_OUT,u),Rn.on(o.EVENT.REMOTE_USER_ENTER,h),Rn.on(o.EVENT.REMOTE_USER_EXIT,p),Rn.on(o.EVENT.REMOTE_VIDEO_AVAILABLE,m),Rn.on(o.EVENT.REMOTE_VIDEO_UNAVAILABLE,_),Rn.on(o.EVENT.REMOTE_AUDIO_UNAVAILABLE,f),Rn.on(o.EVENT.REMOTE_AUDIO_AVAILABLE,g),Rn.on(o.EVENT.SCREEN_SHARE_STOPPED,E),Rn.on(o.EVENT.AUDIO_VOLUME,v),Rn.on(o.EVENT.NETWORK_QUALITY,y),Rn.on(o.EVENT.AUTOPLAY_FAILED,T),Rn.on(o.EVENT.CONNECTION_STATE_CHANGED,S),Rn.on(o.EVENT.AUDIO_PLAY_STATE_CHANGED,I),Rn.on(o.EVENT.VIDEO_PLAY_STATE_CHANGED,A),Rn.on(o.EVENT.DEVICE_CHANGED,R),Rn.on(o.EVENT.PUBLISH_STATE_CHANGED,b),Rn.on(o.EVENT.STATISTICS,C),Rn.on(o.EVENT.SEI_MESSAGE,k),Rn.on(o.EVENT.TRACK,w),await s(),await c(),Cn(`[${i.userId}] enter room [${i.roomId}] success`)}catch(e){Sn.value="stopped",kn(`Enter room ${i.roomId} failed. Error: ${e.message}`)}}else t.ElMessage({message:"请检查参数 SDKAppId, SDKSecretKey, userId, roomId 是否输入正确!",type:"error"})},handleExit:async function(){if("entered"===Sn.value){Sn.value="exiting";try{Rn.off(o.EVENT.ERROR,d),Rn.off(o.EVENT.KICKED_OUT,u),Rn.off(o.EVENT.REMOTE_USER_ENTER,h),Rn.off(o.EVENT.REMOTE_USER_EXIT,p),Rn.off(o.EVENT.REMOTE_VIDEO_AVAILABLE,m),Rn.off(o.EVENT.REMOTE_VIDEO_UNAVAILABLE,_),Rn.off(o.EVENT.REMOTE_AUDIO_UNAVAILABLE,f),Rn.off(o.EVENT.REMOTE_AUDIO_AVAILABLE,g),Rn.off(o.EVENT.SCREEN_SHARE_STOPPED,E),Rn.off(o.EVENT.AUDIO_VOLUME,v),Rn.off(o.EVENT.NETWORK_QUALITY,y),Rn.off(o.EVENT.AUTOPLAY_FAILED,T),Rn.off(o.EVENT.CONNECTION_STATE_CHANGED,S),Rn.off(o.EVENT.AUDIO_PLAY_STATE_CHANGED,I),Rn.off(o.EVENT.VIDEO_PLAY_STATE_CHANGED,A),Rn.off(o.EVENT.DEVICE_CHANGED,R),Rn.off(o.EVENT.PUBLISH_STATE_CHANGED,b),Rn.off(o.EVENT.STATISTICS,C),Rn.off(o.EVENT.SEI_MESSAGE,k),Rn.off(o.EVENT.TRACK,w),await Rn.exitRoom(),await Rn.stopLocalVideo(),await Rn.stopLocalAudio(),Sn.value="exited",n.remoteUsersViews=[],Cn("Exit room success")}catch(e){Sn.value="entered",kn(`Exit room failed. Error: ${e.message}`)}"started"===An.value&&a(),"started"===In.value&&l(),n.remoteUsersViews=[]}else kn("The room has not been entered")},destroy:()=>{Rn.destroy()},handleStartLocalAudio:s,handleStopLocalAudio:a,handleStartLocalVideo:c,handleStopLocalVideo:l,toggleAudio:async()=>{try{yn.value?(await Rn.updateLocalAudio({mute:!1}),yn.value=!1):(await Rn.updateLocalAudio({mute:!0}),yn.value=!0),Cn(`Audio Muted: ${yn.value}`)}catch(e){kn(`Mute audio error: ${e.message}`)}},toggleVideo:async()=>{try{Tn.value?(await Rn.updateLocalVideo({mute:!1}),Tn.value=!1):(await Rn.updateLocalVideo({mute:!0}),Tn.value=!0),Cn(`Video Muted: ${Tn.value}`)}catch(e){kn(`Mute video error: ${e.message}`)}},getUserSig:function(){let e=i.userSig||En({sdkAppId:Number(i.sdkAppId),userId:i.userId,sdkSecretKey:i.sdkSecretKey}).userSig;return e}}}const Nn=t=>(e.pushScopeId("data-v-4d910502"),t=t(),e.popScopeId(),t),Dn={class:"pusher"},On={key:0,class:"group"},Ln={class:"remote grid",style:{"grid-template-rows":"repeat(99, minmax(10em, auto))"}},Pn=["id"],Mn=Nn((()=>e.createElementVNode("div",{class:"local-user",id:"local"},null,-1))),xn={key:1,class:"single"},Vn=Nn((()=>e.createElementVNode("div",{class:"local-user",id:"local"},null,-1))),Un={class:"remote flex flex-wrap"},Bn=["id"],Fn={key:2,class:"btns flex justify-center"},Hn={class:"btn-box flex flex-nowrap justify-between items-center"},jn=e.defineComponent({__name:"trtcUI",props:{sdkAppId:{type:String,default:""},userId:{type:String,default:""},roomId:{type:String,default:""},sdkSecretKey:{type:String,default:""},userSig:{type:String,default:""}},emits:[o.EVENT.ERROR,o.EVENT.KICKED_OUT,o.EVENT.REMOTE_USER_ENTER,o.EVENT.REMOTE_USER_EXIT,o.EVENT.REMOTE_VIDEO_AVAILABLE,o.EVENT.REMOTE_VIDEO_UNAVAILABLE,o.EVENT.REMOTE_AUDIO_UNAVAILABLE,o.EVENT.REMOTE_AUDIO_AVAILABLE,o.EVENT.SCREEN_SHARE_STOPPED,o.EVENT.AUDIO_VOLUME,o.EVENT.NETWORK_QUALITY,o.EVENT.AUTOPLAY_FAILED,o.EVENT.CONNECTION_STATE_CHANGED,o.EVENT.AUDIO_PLAY_STATE_CHANGED,o.EVENT.VIDEO_PLAY_STATE_CHANGED,o.EVENT.DEVICE_CHANGED,o.EVENT.PUBLISH_STATE_CHANGED,o.EVENT.STATISTICS,o.EVENT.SEI_MESSAGE,o.EVENT.TRACK,"changeRoomState","updateLog"],setup(t,{expose:i,emit:r}){const n=t,o=r,s=e.reactive({audioDeviceId:"",videoDeviceId:"",remoteUsersViews:[]}),{audioMuted:a,videoMuted:c,roomStatus:l,trtc:d,logs:u,handleEnter:h,handleExit:p,destroy:m,handleStartLocalAudio:_,handleStopLocalAudio:f,handleStartLocalVideo:g,handleStopLocalVideo:E,toggleAudio:v,toggleVideo:y}=wn(n,o,s),T=()=>{v()},S=()=>{y()},I=()=>{p()};return i({trtc:d,logs:u,handleEnter:h,handleExit:p,destroy:m,handleStartLocalAudio:_,handleStopLocalAudio:f,handleStartLocalVideo:g,handleStopLocalVideo:E,toggleAudio:v,toggleVideo:y}),(t,i)=>{const r=e.resolveComponent("bc-icon");return e.openBlock(),e.createElementBlock("div",Dn,[s.remoteUsersViews.length>=2?(e.openBlock(),e.createElementBlock("div",On,[e.createElementVNode("div",Ln,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.remoteUsersViews,(t=>(e.openBlock(),e.createElementBlock("div",{id:t.userId,key:t.userId,class:"remote-user"},e.toDisplayString(t),9,Pn)))),128))]),Mn])):(e.openBlock(),e.createElementBlock("div",xn,[Vn,e.createElementVNode("div",Un,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.remoteUsersViews,(t=>(e.openBlock(),e.createElementBlock("div",{id:t.userId,key:t.userId,class:"remote-user"},e.toDisplayString(t.userId),9,Bn)))),128))])])),"entered"==e.unref(l)?(e.openBlock(),e.createElementBlock("div",Fn,[e.createElementVNode("div",Hn,[e.createElementVNode("div",{class:e.normalizeClass("flex-items-center justify-center rounded-full p-3 "+(e.unref(a)?" bg-zinc-400/80":" bg-stone-50")),onClick:T},[e.createVNode(r,{name:e.unref(a)?"ele-Mute":"ele-Microphone",color:e.unref(a)?"#fff":"#333",size:"20"},null,8,["name","color"])],2),e.createElementVNode("div",{class:"icon-bg flex-items-center justify-center bg-red-500",onClick:I},[e.createVNode(r,{name:"ele-PhoneFilled",color:"#fff",size:"20"})]),e.createElementVNode("div",{class:e.normalizeClass("flex-items-center justify-center rounded-full p-3 "+(e.unref(c)?" bg-zinc-400/80":" bg-stone-50")),onClick:S},[e.createVNode(r,{name:e.unref(c)?"ele-VideoPlay":"ele-VideoCamera",color:e.unref(c)?"#fff":"#333",size:"20"},null,8,["name","color"])],2)])])):e.createCommentVNode("",!0)])}}}),Wn=t._export_sfc(jn,[["__scopeId","data-v-4d910502"]]),zn=Object.freeze(Object.defineProperty({__proto__:null,default:Wn},Symbol.toStringTag,{value:"Module"}));exports.TRTC=o,exports.genTestUserSig=En,exports.trtcUI=Wn,exports.trtcUI$1=zn;