@vmosedge/web-sdk 1.0.2 → 1.0.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.
@@ -1,3 +1,3 @@
1
1
  var VmosEdgeWebSdk=function(e){"use strict";function t(e,t){this.v=e,this.k=t}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function r(e,t,n){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:n;throw new TypeError("Private element is not present on this object")}function i(e,t,n,r,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function o(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function s(e){i(a,r,o,s,u,"next",e)}function u(e){i(a,r,o,s,u,"throw",e)}s(void 0)})}}function a(e){return new t(e,0)}function s(e,t,n){return t=g(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,E()?Reflect.construct(t,n||[],g(e).constructor):t.apply(e,n))}function u(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){return e.get(r(e,t))}function f(e,t,n){u(e,t),t.set(e,n)}function h(e,t,n){return e.set(r(e,t),n),n}function d(e,t){u(e,t),t.add(e)}function v(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,M(r.key),r)}}function p(e,t,n){return t&&v(e.prototype,t),n&&v(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function y(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=N(e))||t){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function m(e,t,n){return(t=M(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function w(){return w="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=g(e)););return e}(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},w.apply(null,arguments)}function g(e){return g=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},g(e)}function b(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&R(e,t)}function E(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(E=function(){return!!e})()}function k(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function C(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?k(Object(n),!0).forEach(function(t){m(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):k(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function S(){
2
2
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
3
- var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return O(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],f=!1,h={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function d(n,r){for(s=n,u=r,t=0;!f&&c&&!i&&t<l.length;t++){var i,o=l[t],d=h.p,v=o[2];n>3?(i=v===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=d&&((i=n<2&&d<o[1])?(s=0,h.v=r,h.n=o[1]):d<v&&(i=n<3||o[0]>r||r>v)&&(o[4]=n,o[5]=r,h.n=v,s=0))}if(i||n>1)return a;throw f=!0,r}return function(i,l,v){if(c>1)throw TypeError("Generator is already running");for(f&&1===l&&d(l,v),s=l,u=v;(t=s<2?e:u)||!f;){o||(s?s<3?(s>1&&(h.n=-1),d(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(f=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:f}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(O(t={},r,function(){return this}),t),f=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,O(e,i,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=c,O(f,"constructor",c),O(c,"constructor",u),u.displayName="GeneratorFunction",O(c,i,"GeneratorFunction"),O(f),O(f,i,"Generator"),O(f,r,function(){return this}),O(f,"toString",function(){return"[object Generator]"}),(S=function(){return{w:o,m:h}})()}function O(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}O=function(e,t,n,r){function o(t,n){O(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},O(e,t,n,r)}function x(e){if(null!=e){var t=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}throw new TypeError(typeof e+" is not iterable")}function R(e,t){return R=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},R(e,t)}function A(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],u=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);u=!0);}catch(e){c=!0,i=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(e,t)||N(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function T(e,t,n,r){var i=w(g(e.prototype),t,n);return"function"==typeof i?function(e){return i.apply(n,e)}:i}function _(e){return function(e){if(Array.isArray(e))return n(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||N(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function M(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function I(e){return I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},I(e)}function N(e,t){if(e){if("string"==typeof e)return n(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}}function D(e){var n,r;function i(n,r){try{var a=e[n](r),s=a.value,u=s instanceof t;Promise.resolve(u?s.v:s).then(function(t){if(u){var r="return"===n?"return":"next";if(!s.k||t.done)return i(r,t);t=e[r](t).value}o(a.done?"return":"normal",t)},function(e){i("throw",e)})}catch(e){o("throw",e)}}function o(e,t){switch(e){case"return":n.resolve({value:t,done:!0});break;case"throw":n.reject(t);break;default:n.resolve({value:t,done:!1})}(n=n.next)?i(n.key,n.arg):r=null}this._invoke=function(e,t){return new Promise(function(o,a){var s={key:e,arg:t,resolve:o,reject:a,next:null};r?r=r.next=s:(n=r=s,i(e,t))})},"function"!=typeof e.return&&(this.return=void 0)}function P(e){var t="function"==typeof Map?new Map:void 0;return P=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(E())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var i=new(e.bind.apply(e,r));return n&&R(i,n.prototype),i}(e,arguments,g(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),R(n,e)},P(e)}var W;D.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},D.prototype.next=function(e){return this._invoke("next",e)},D.prototype.throw=function(e){return this._invoke("throw",e)},D.prototype.return=function(e){return this._invoke("return",e)};var L=function(){return p(function e(t,n,r,i){c(this,e),m(this,"optionValue",void 0),m(this,"metadataValue",void 0),m(this,"mimeType",void 0),m(this,"webCodecId",void 0),this.optionValue=t,this.metadataValue=n,this.mimeType=r,this.webCodecId=i},[{key:"toOptionValue",value:function(){return this.optionValue}}])}();m(L,"Opus",new(W=L)("opus",1869641075,"audio/opus","opus")),m(L,"Aac",new W("aac",6381923,"audio/aac","mp4a.66")),m(L,"Flac",new W("flac",1718378851,"audio/flac","flac")),m(L,"Raw",new W("raw",7496055,"audio/raw",""));var V=0,U=1,B=2,j=3,F=4,G=5,z=6,H=7,K=8,q=9,X=10,Y=11,J=12,Q=13,Z=14,$=15,ee=16,te=17,ne=new WeakMap,re=new WeakSet,ie=function(){return p(function e(){c(this,e),d(this,re),f(this,ne,[])},[{key:"parsers",get:function(){return l(ne,this)}},{key:"add",value:function(e){if(Array.isArray(e.id)){var t,n=y(e.id);try{for(n.s();!(t=n.n()).done;){var i=t.value;r(re,this,oe).call(this,i,e)}}catch(e){n.e(e)}finally{n.f()}}else r(re,this,oe).call(this,e.id,e);return e}},{key:"parse",value:(e=o(S().m(function e(t,n){var r;return S().w(function(e){for(;;)switch(e.n){case 0:if(r=l(ne,this)[t]){e.n=1;break}throw new Error("Unknown device message id ".concat(t));case 1:return e.a(2,r.parse(t,n))}},e,this)})),function(t,n){return e.apply(this,arguments)})},{key:"close",value:function(){var e,t=y(l(ne,this));try{for(t.s();!(e=t.n()).done;){e.value.close()}}catch(e){t.e(e)}finally{t.f()}}},{key:"error",value:function(e){var t,n=y(l(ne,this));try{for(n.s();!(t=n.n()).done;){t.value.error(e)}}catch(e){n.e(e)}finally{n.f()}}}]);var e}();function oe(e,t){if(l(ne,this)[e])throw new Error("Duplicate parser for id ".concat(e));l(ne,this)[e]=t}function ae(e,t){if(function(e){return"object"===I(e)&&null!==e&&"toOptionValue"in e&&"function"==typeof e.toOptionValue}(e)&&(e=e.toOptionValue()),void 0===e)return t;if("string"!=typeof e&&"number"!=typeof e&&"boolean"!=typeof e)throw new TypeError("Invalid option value: ".concat(JSON.stringify(e)));return e.toString()}var se=1748121140,ue=1748121141,ce=6387249,le=new WeakMap,fe=new WeakMap,he=new WeakMap,de=new WeakMap,ve=function(){return p(function e(){var t=this;c(this,e),f(this,le,void 0),f(this,fe,void 0),f(this,he,void 0),f(this,de,"running"),m(this,"resolve",function(e){l(fe,t).call(t,e),h(de,t,"resolved")}),m(this,"reject",function(e){l(he,t).call(t,e),h(de,t,"rejected")}),h(le,this,new Promise(function(e,n){h(fe,t,e),h(he,t,n)}))},[{key:"promise",get:function(){return l(le,this)}},{key:"state",get:function(){return l(de,this)}}])}();function pe(e){return"object"===I(e)&&null!==e&&"then"in e}function ye(e,t){for(;;){var n=e.next(t),r=n.done,i=n.value;if(r)return i;if(pe(i))return i.then(function(t){return ye(e,{resolved:t})},function(t){return ye(e,{error:t})});t=i}}function me(e,t){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return ye(e.call.apply(e,[this,S().m(function e(t){var n;return S().w(function(e){for(;;)switch(e.n){case 0:if(!pe(t)){e.n=3;break}return e.n=1,t;case 1:if(!("resolved"in(n=e.v))){e.n=2;break}return e.a(2,n.resolved);case 2:throw n.error;case 3:return e.a(2,t)}},e)})].concat(n)),void 0)}}function we(e,t){return function(n,r){var i;if("buffer"in r)return null!==(i=r.index)&&void 0!==i||(r.index=0),t(n,r),e;var o=new Uint8Array(e);return t(n,{buffer:o,index:0,littleEndian:r.littleEndian}),o}}var ge=function(e,t,n,r,i){var o,a={size:e,type:t,serialize:"default"===t?(o=n,function(e,t){if("buffer"in t){var n=o(e,t);return t.buffer.set(n,t.index),n.length}return o(e,t)}):we(e,n),deserialize:me(r),omitInit:null==i?void 0:i.omitInit};return null!=i&&i.init&&(a.init=i.init),a},be=new Uint8Array(0);function Ee(e,t){var n,r,i,o,a,s,u,c,l;return"number"==typeof e?(0===e?(n=function(){},r=t?S().m(function e(){return S().w(function(e){for(;;)if(0===e.n)return e.a(2,t.convert(be))},e)}):S().m(function e(){return S().w(function(e){for(;;)if(0===e.n)return e.a(2,be)},e)})):(n=function(t,n){return function(e,t,n,r){t.length<r?(e.set(t,n),e.fill(0,n+t.length,n+r)):t.length===r?e.set(t,n):e.set(t.subarray(0,r),n)}(n.buffer,t,n.index,e)},t?(r=S().m(function n(r,i){var o,a;return S().w(function(n){for(;;)switch(n.n){case 0:return o=i.readExactly(e),a=t,n.d(x(r(o)),1);case 1:return n.a(2,a.convert.call(a,n.v))}},n)}),i=function(e){return t.back(e)}):r=S().m(function t(n,r){var i;return S().w(function(t){for(;;)if(0===t.n)return i=r.readExactly(e),t.a(2,i)},t)})),ge(e,"byob",n,r,{init:i})):"object"!==I(e)&&"function"!=typeof e||!("serialize"in e)?"string"==typeof e?(t?(s=function(n,r,i){var o=i.dependencies;return S().m(function i(){var a,s,u;return S().w(function(i){for(;;)switch(i.n){case 0:return a=o[e],s=0!==a?r.readExactly(a):be,u=t,i.d(x(n(s)),1);case 1:return i.a(2,u.convert.call(u,i.v))}},i)})()},u=function(n,r){var i=t.back(n);return r[e]=i.length,i}):(s=function(t,n,r){var i=r.dependencies;return S().m(function t(){var r,o;return S().w(function(t){for(;;)if(0===t.n)return r=i[e],o=0!==r?n.readExactly(r):be,t.a(2,o)},t)})()},u=function(t,n){var r=t;return n[e]=r.length,r}),ge(0,"default",function(e){return e},s,{init:u})):(t?(c=function(n,r,i){var o=i.dependencies;return S().m(function i(){var a,s,u,c;return S().w(function(i){for(;;)switch(i.n){case 0:return a=o[e.field],s=e.convert(a),u=0!==s?r.readExactly(s):be,c=t,i.d(x(n(u)),1);case 1:return i.a(2,c.convert.call(c,i.v))}},i)})()},l=function(n,r){var i=t.back(n);return r[e.field]=e.back(i.length),i}):(c=function(t,n,r){var i=r.dependencies;return S().m(function t(){var r,o,a;return S().w(function(t){for(;;)if(0===t.n)return r=i[e.field],o=e.convert(r),a=0!==o?n.readExactly(o):be,t.a(2,a)},t)})()},l=function(t,n){var r=t;return n[e.field]=e.back(r.length),r}),ge(0,"default",function(e){return e},c,{init:l})):(t?(o=S().m(function n(r,i,o){var a,s,u;return S().w(function(n){for(;;)switch(n.n){case 0:return n.d(x(r(e.deserialize(i,o))),1);case 1:return a=n.v,s=0!==a?i.readExactly(a):be,u=t,n.d(x(r(s)),2);case 2:return n.a(2,u.convert.call(u,n.v))}},n)}),a=function(e){return t.back(e)}):o=S().m(function t(n,r,i){var o,a;return S().w(function(t){for(;;)switch(t.n){case 0:return t.d(x(n(e.deserialize(r,i))),1);case 1:return o=t.v,a=0!==o?r.readExactly(o):be,t.a(2,a)}},t)}),ge(e.size,"default",function(t,n){var r=n.littleEndian;if("default"===e.type){var i=e.serialize(t.length,{littleEndian:r});if(0===t.length)return i;var o=new Uint8Array(i.length+t.length);return o.set(i,0),o.set(t,i.length),o}var a=new Uint8Array(e.size+t.length);return e.serialize(t.length,{buffer:a,index:0,littleEndian:r}),a.set(t,e.size),a},o,{init:a}))}var ke=function(e){function t(){return c(this,t),s(this,t,["ExactReadable ended"])}return b(t,e),p(t)}(P(Error)),Ce=function(e){function t(e){return c(this,t),s(this,t,[e])}return b(t,e),p(t)}(P(Error)),Se=function(e){function t(){return c(this,t),s(this,t,["The underlying readable was ended before the struct was fully deserialized"])}return b(t,e),p(t)}(Ce),Oe=function(e){function t(){return c(this,t),s(this,t,["The underlying readable doesn't contain any more struct"])}return b(t,e),p(t)}(Ce);function xe(e,t){for(var n=Object.entries(e),r=0,i=!0,o=0,a=n;o<a.length;o++){var s=A(a[o],2)[1];r+=s.size,i&&"byob"!==s.type&&(i=!1)}var u=t.littleEndian,c=t.extra?Object.getOwnPropertyDescriptors(t.extra):void 0;return{littleEndian:u,fields:e,extra:t.extra,type:i?"byob":"default",size:r,serialize:function(e,t){for(var r=C({},e),i=0,o=n;i<o.length;i++){var a=A(o[i],2),s=a[0],c=a[1];if(s in r&&"init"in c){var l,f=null===(l=c.init)||void 0===l?void 0:l.call(c,r[s],r);r[s]=f}}var h,d=new Array(n.length),v=new Array(n.length),p={littleEndian:u},m=y(n.entries());try{for(m.s();!(h=m.n()).done;){var w=A(h.value,2),g=w[0],b=A(w[1],2),E=b[0],k=b[1];"byob"===k.type?d[g]=k.size:(v[g]=k.serialize(r[E],p),d[g]=v[g].length)}}catch(e){m.e(e)}finally{m.f()}var S,O,x,R=d.reduce(function(e,t){return e+t},0);if(t instanceof Uint8Array){if(t.length<R)throw new Error("Buffer too small");S=!0,O=t,x=0}else if("object"===I(t)&&"buffer"in t){var T;if(S=!0,O=t.buffer,x=null!==(T=t.index)&&void 0!==T?T:0,O.length-x<R)throw new Error("Buffer too small")}else S=!1,O=new Uint8Array(R),x=0;var _,M={buffer:O,index:x,littleEndian:u},N=y(n.entries());try{for(N.s();!(_=N.n()).done;){var D=A(_.value,2),P=D[0],W=A(D[1],2),L=W[0],V=W[1];v[P]?O.set(v[P],M.index):V.serialize(r[L],M),M.index+=d[P]}}catch(e){N.e(e)}finally{N.f()}return S?R:O},deserialize:me(S().m(function e(r,i){var o,a,s,l,f,h,d,v,p;return S().w(function(e){for(;;)switch(e.p=e.n){case 0:o=i.position,s={dependencies:a={},littleEndian:u},e.p=1,l=0,f=n;case 2:if(!(l<f.length)){e.n=5;break}return h=A(f[l],2),d=h[0],v=h[1],e.d(x(r(v.deserialize(i,s))),3);case 3:a[d]=e.v;case 4:l++,e.n=2;break;case 5:e.n=9;break;case 6:if(e.p=6,(p=e.v)instanceof ke){e.n=7;break}throw p;case 7:if(i.position!==o){e.n=8;break}throw new Oe;case 8:throw new Se;case 9:if(c&&Object.defineProperties(a,c),!t.postDeserialize){e.n=10;break}return e.a(2,t.postDeserialize.call(a,a));case 10:return e.a(2,a);case 11:return e.a(2)}},e,null,[[1,6]])}))}}function Re(e,t,n){return n?(e[t]|e[t+1]<<8)<<16>>16:(e[t]<<8|e[t+1])<<16>>16}function Ae(e,t,n){return n?e[t]|e[t+1]<<8:e[t+1]|e[t]<<8}function Te(e,t,n,r){r?(e[t]=n,e[t+1]=n>>8):(e[t]=n>>8,e[t+1]=n)}function _e(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function Me(e,t,n){return n?(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0:(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function Ie(e,t,n){return n?BigInt(e[t])|BigInt(e[t+1])<<8n|BigInt(e[t+2])<<16n|BigInt(e[t+3])<<24n|BigInt(e[t+4])<<32n|BigInt(e[t+5])<<40n|BigInt(e[t+6])<<48n|BigInt(e[t+7])<<56n:BigInt(e[t])<<56n|BigInt(e[t+1])<<48n|BigInt(e[t+2])<<40n|BigInt(e[t+3])<<32n|BigInt(e[t+4])<<24n|BigInt(e[t+5])<<16n|BigInt(e[t+6])<<8n|BigInt(e[t+7])}function Ne(e,t,n){var r=function(){return r};return Object.assign(r,ge(e,"byob",t,n)),r}var De=Ne(1,function(e,t){t.buffer[t.index]=e},S().m(function e(t,n){var r;return S().w(function(e){for(;;)switch(e.n){case 0:return e.d(x(t(n.readExactly(1))),1);case 1:return r=e.v,e.a(2,r[0])}},e)})),Pe=Ne(2,function(e,t){Te(t.buffer,t.index,e,t.littleEndian)},function(e,t,n){var r=n.littleEndian;return S().m(function n(){var i;return S().w(function(n){for(;;)switch(n.n){case 0:return n.d(x(e(t.readExactly(2))),1);case 1:return i=n.v,n.a(2,Ae(i,0,r))}},n)})()}),We=Ne(4,function(e,t){!function(e,t,n,r){r?(e[t]=n,e[t+1]=n>>8,e[t+2]=n>>16,e[t+3]=n>>24):(e[t]=n>>24,e[t+1]=n>>16,e[t+2]=n>>8,e[t+3]=n)}(t.buffer,t.index,e,t.littleEndian)},function(e,t,n){var r=n.littleEndian;return S().m(function n(){var i;return S().w(function(n){for(;;)switch(n.n){case 0:return n.d(x(e(t.readExactly(4))),1);case 1:return i=n.v,n.a(2,Me(i,0,r))}},n)})()}),Le=Ne(8,function(e,t){!function(e,t,n,r){r?(e[t]=Number(0xffn&n),e[t+1]=Number(n>>8n&0xffn),e[t+2]=Number(n>>16n&0xffn),e[t+3]=Number(n>>24n&0xffn),e[t+4]=Number(n>>32n&0xffn),e[t+5]=Number(n>>40n&0xffn),e[t+6]=Number(n>>48n&0xffn),e[t+7]=Number(n>>56n&0xffn)):(e[t]=Number(n>>56n&0xffn),e[t+1]=Number(n>>48n&0xffn),e[t+2]=Number(n>>40n&0xffn),e[t+3]=Number(n>>32n&0xffn),e[t+4]=Number(n>>24n&0xffn),e[t+5]=Number(n>>16n&0xffn),e[t+6]=Number(n>>8n&0xffn),e[t+7]=Number(0xffn&n))}(t.buffer,t.index,e,t.littleEndian)},function(e,t,n){var r=n.littleEndian;return S().m(function n(){var i;return S().w(function(n){for(;;)switch(n.n){case 0:return n.d(x(e(t.readExactly(8))),1);case 1:return i=n.v,n.a(2,Ie(i,0,r))}},n)})()}),Ve=globalThis.TextEncoder,Ue=globalThis.TextDecoder,Be=new Ve,je=new Ue;function Fe(e){return Be.encode(e)}function Ge(e){return je.decode(e)}var ze=function(e){var t=Ee(e,{convert:Ge,back:Fe});return t.as=function(){return t},t},He=xe({type:De},{littleEndian:!1}),Ke=globalThis.AbortController,qe=function(){var e=globalThis.ReadableStream;return e.from||(e.from=function(t){var n=Symbol.asyncIterator in t?t[Symbol.asyncIterator]():t[Symbol.iterator]();return new e({pull:function(e){return o(S().m(function t(){var r;return S().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,n.next();case 1:if(!(r=t.v).done){t.n=2;break}return e.close(),t.a(2);case 2:e.enqueue(r.value);case 3:return t.a(2)}},t)}))()},cancel:function(e){return o(S().m(function t(){var r;return S().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,null===(r=n.return)||void 0===r?void 0:r.call(n,e);case 1:return t.a(2)}},t)}))()}})}),e.prototype[Symbol.asyncIterator]&&e.prototype.values||(e.prototype.values=function(){var e,t=(e=S().m(function e(t){var n,r,i,o;return S().w(function(e){for(;;)switch(e.p=e.n){case 0:n=this.getReader(),e.p=1;case 2:return e.n=3,a(n.read());case 3:if(r=e.v,i=r.done,o=r.value,!i){e.n=4;break}return e.a(2);case 4:return e.n=5,o;case 5:e.n=2;break;case 6:if(e.p=6,null!=t&&t.preventCancel){e.n=7;break}return e.n=7,a(n.cancel());case 7:return n.releaseLock(),e.f(6);case 8:return e.a(2)}},e,this,[[1,,6,8]])}),function(){return new D(e.apply(this,arguments))});return function(e){return t.apply(this,arguments)}}(),e.prototype[Symbol.asyncIterator]=e.prototype.values),e}(),Xe=globalThis.WritableStream,Ye=globalThis.TransformStream,Je=function(e){function t(e,n,r){var i;c(this,t);var a=!1,u=new Ke;return s(this,t,[{start:function(t){var n,s=e({abortSignal:u.signal,enqueue:(n=o(S().m(function e(n){return S().w(function(e){for(;;)switch(e.n){case 0:if(null==r||r({source:"producer",operation:"enqueue",value:n,phase:"start"}),!u.signal.aborted){e.n=1;break}return null==r||r({source:"producer",operation:"enqueue",value:n,phase:"ignored"}),e.a(2);case 1:if(null!==t.desiredSize){e.n=2;break}return t.enqueue(n),e.a(2);case 2:if(!a){e.n=3;break}return a=!1,t.enqueue(n),null==r||r({source:"producer",operation:"enqueue",value:n,phase:"complete"}),e.a(2);case 3:if(!(t.desiredSize<=0)){e.n=5;break}return null==r||r({source:"producer",operation:"enqueue",value:n,phase:"waiting"}),i=new ve,e.n=4,i.promise;case 4:if(!u.signal.aborted){e.n=5;break}return null==r||r({source:"producer",operation:"enqueue",value:n,phase:"ignored"}),e.a(2);case 5:t.enqueue(n),null==r||r({source:"producer",operation:"enqueue",value:n,phase:"complete"});case 6:return e.a(2)}},e)})),function(e){return n.apply(this,arguments)}),close:function(){null==r||r({source:"producer",operation:"close",explicit:!0,phase:"start"}),u.signal.aborted?null==r||r({source:"producer",operation:"close",explicit:!0,phase:"ignored"}):(t.close(),null==r||r({source:"producer",operation:"close",explicit:!0,phase:"complete"}))},error:function(e){null==r||r({source:"producer",operation:"error",explicit:!0,phase:"start"}),t.error(e),null==r||r({source:"producer",operation:"error",explicit:!0,phase:"complete"})}});s&&"then"in s&&s.then(function(){null==r||r({source:"producer",operation:"close",explicit:!1,phase:"start"});try{t.close(),null==r||r({source:"producer",operation:"close",explicit:!1,phase:"complete"})}catch(e){null==r||r({source:"producer",operation:"close",explicit:!1,phase:"ignored"})}},function(e){null==r||r({source:"producer",operation:"error",explicit:!1,phase:"start"}),t.error(e),null==r||r({source:"producer",operation:"error",explicit:!1,phase:"complete"})})},pull:function(){null==r||r({source:"consumer",operation:"pull",phase:"start"}),i?i.resolve():0===(null==n?void 0:n.highWaterMark)&&(a=!0),null==r||r({source:"consumer",operation:"pull",phase:"complete"})},cancel:function(e){var t;null==r||r({source:"consumer",operation:"cancel",phase:"start"}),u.abort(e),null===(t=i)||void 0===t||t.resolve(),null==r||r({source:"consumer",operation:"cancel",phase:"complete"})}},n])}return b(t,e),p(t)}(qe);function Qe(e){return Ze.apply(this,arguments)}function Ze(){return(Ze=o(S().m(function e(t){return S().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,t.cancel();case 1:return e.a(2,!0);case 2:return e.p=2,e.v,e.a(2,!1)}},e,null,[[0,2]])}))).apply(this,arguments)}var $e=new WeakMap,et=new WeakMap,tt=new WeakMap,nt=new WeakMap,rt=new WeakSet,it=function(){return p(function e(t){c(this,e),d(this,rt),f(this,$e,void 0),f(this,et,0),f(this,tt,0),f(this,nt,0),m(this,"stream",void 0),m(this,"reader",void 0),m(this,"readExactly",me(S().m(function e(t,n){var i,o,a,s;return S().w(function(e){for(;;)switch(e.n){case 0:if(o=0,!(a=r(rt,this,ot).call(this,n))){e.n=2;break}if(a.length!==n){e.n=1;break}return e.a(2,a);case 1:(i=new Uint8Array(n)).set(a,o),o+=a.length,n-=a.length,e.n=3;break;case 2:i=new Uint8Array(n);case 3:if(!(n>0)){e.n=5;break}return e.d(x(t(r(rt,this,at).call(this,n))),4);case 4:s=e.v,i.set(s,o),o+=s.length,n-=s.length,e.n=3;break;case 5:return e.a(2,i)}},e,this)}))),this.stream=t,this.reader=t.getReader()},[{key:"position",get:function(){return l(nt,this)}},{key:"iterateExactly",value:function(e){var t=this,n=l($e,this)?0:1;return{next:function(){switch(n){case 0:var i=r(rt,t,ot).call(t,e);return i.length===e?n=2:(e-=i.length,n=1),{done:!1,value:i};case 1:return n=3,{done:!1,value:r(rt,t,at).call(t,e).then(function(t){return t.length===e?n=2:(e-=t.length,n=1),t})};case 2:return{done:!0,value:void 0};case 3:throw new Error("Can't call `next` before previous Promise resolves");default:throw new Error("unreachable")}}}}},{key:"release",value:function(){var e=this;return l(tt,this)>0?new Je(function(){var t=o(S().m(function t(n){var r,i,o,a;return S().w(function(t){for(;;)switch(t.n){case 0:return r=l($e,e).subarray(l(et,e)),t.n=1,n.enqueue(r);case 1:n.abortSignal.addEventListener("abort",function(){Qe(e.reader)});case 2:return t.n=3,e.reader.read();case 3:if(i=t.v,o=i.done,a=i.value,!o){t.n=4;break}return t.a(2);case 4:return t.n=5,n.enqueue(a);case 5:t.n=2;break;case 6:return t.a(2)}},t)}));return function(e){return t.apply(this,arguments)}}()):(this.reader.releaseLock(),this.stream)}},{key:"cancel",value:(e=o(S().m(function e(t){return S().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,this.reader.cancel(t);case 1:return e.a(2)}},e,this)})),function(t){return e.apply(this,arguments)})}]);var e}();function ot(e){if(l($e,this)){var t=l($e,this).subarray(l(et,this),l(et,this)+e);return l(tt,this)>e?(h(nt,this,l(nt,this)+e),h(et,this,l(et,this)+e),h(tt,this,l(tt,this)-e),t):(h(nt,this,l(nt,this)+l(tt,this)),h($e,this,void 0),h(et,this,0),h(tt,this,0),t)}}function at(e){return st.apply(this,arguments)}function st(){return(st=o(S().m(function e(t){var n,r,i;return S().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,this.reader.read();case 1:if(n=e.v,r=n.done,i=n.value,!r){e.n=2;break}throw new ke;case 2:if(!(i.length>t)){e.n=3;break}return h($e,this,i),h(et,this,t),h(tt,this,i.length-t),h(nt,this,l(nt,this)+t),e.a(2,i.subarray(0,t));case 3:return h(nt,this,l(nt,this)+i.length),e.a(2,i)}},e,this)}))).apply(this,arguments)}var ut=new WeakMap,ct=new WeakMap,lt=function(e){function t(e){return c(this,t),s(this,t,[function(t){return e.deserialize(t)}])}return b(t,e),p(t)}(function(){return p(function e(t){var n,r;c(this,e),f(this,ut,void 0),f(this,ct,void 0);var i=new it(new Je(function(e){n=e}));h(ut,this,new qe({pull:function(e){return o(S().m(function n(){var r,o;return S().w(function(n){for(;;)switch(n.p=n.n){case 0:return n.p=0,n.n=1,t(i);case 1:r=n.v,e.enqueue(r),n.n=4;break;case 2:if(n.p=2,!((o=n.v)instanceof Oe)){n.n=3;break}return e.close(),n.a(2);case 3:throw o;case 4:return n.a(2)}},n,null,[[0,2]])}))()},cancel:function(e){return r.error(e)}})),h(ct,this,new Xe({start:function(e){r=e},write:function(e){return o(S().m(function t(){return S().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,n.enqueue(e);case 1:return t.a(2)}},t)}))()},abort:function(){n.close()},close:function(){n.close()}}))},[{key:"readable",get:function(){return l(ut,this)}},{key:"writable",get:function(){return l(ct,this)}}])}()),ft=He,ht=xe({content:ze(We)},{littleEndian:!1}),dt=new WeakMap,vt=function(e){function t(){var e,n;return c(this,t),f(e=s(this,t,[function(e){n=e}]),dt,void 0),m(e,"id",0),h(dt,e,n),e}return b(t,e),p(t,[{key:"parse",value:(n=o(S().m(function e(t,n){var r;return S().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,ht.deserialize(n);case 1:return r=e.v,e.n=2,l(dt,this).enqueue(r.content);case 2:return e.a(2)}},e,this)})),function(e,t){return n.apply(this,arguments)})},{key:"close",value:function(){l(dt,this).close()}},{key:"error",value:function(e){l(dt,this).error(e)}}]);var n}(Je),pt=function(){return[V,U,B,j,F,G,H,K,q,X,Y]}();var yt={repeatPreviousFrameAfter:"long",maxPtsGapToEncoder:"long"},mt=function(){return p(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};c(this,e),m(this,"options",void 0);for(var n=0,r=Object.entries(t);n<r.length;n++){var i=A(r[n],2),o=i[0],a=i[1];if(void 0!==a&&"number"!=typeof a)throw new Error("Invalid option value for ".concat(o,": ").concat(String(a)))}this.options=t},[{key:"toOptionValue",value:function(){var e=Object.entries(this.options).filter(function(e){return void 0!==A(e,2)[1]});if(0!==e.length)return e.map(function(e){var t=A(e,2),n=t[0],r=t[1],i=n.replace(/([A-Z])/g,"-$1").toLowerCase(),o=yt[n];return o&&(i+=":".concat(o)),i+="=".concat(r)}).join(",")}}])}();m(mt,"Empty",new mt);var wt={logLevel:"debug",maxSize:0,bitRate:8e6,maxFps:0,lockVideoOrientation:-1,tunnelForward:!1,crop:void 0,sendFrameMeta:!0,control:!0,displayId:0,showTouches:!1,stayAwake:!1,codecOptions:void 0};function gt(e,t,n){return e<t?t:e>n?n:e}function bt(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return Object.fromEntries(Object.entries(e).filter(function(e){var t=A(e,1)[0];return!n.includes(t)}))}var Et=ge(2,"byob",function(e,t){var n=t.buffer,r=t.index,i=t.littleEndian;Te(n,r,e=1===(e=gt(e,-1,1))?65535:65536*e,i)},function(e,t,n){var r=n.littleEndian;return S().m(function n(){var i,o;return S().w(function(n){for(;;)switch(n.n){case 0:return n.d(x(e(t.readExactly(2))),1);case 1:return i=n.v,o=Ae(i,0,r),n.a(2,65535===o?1:o/65536)}},n)})()}),kt=xe({pts:Le,data:Ee(We)},{littleEndian:!1}),Ct=1n<<63n;function St(e,t){return Ot.apply(this,arguments)}function Ot(){return Ot=o(S().m(function e(t,n){var r;return S().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,t.readExactly(n);case 1:return r=e.v,e.a(2,Ge(r.subarray(0,r.indexOf(0))))}},e)})),Ot.apply(this,arguments)}function xt(e){return Rt.apply(this,arguments)}function Rt(){return Rt=o(S().m(function e(t){var n;return S().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,t.readExactly(4);case 1:return n=e.v,e.a(2,_e(n,0))}},e)})),Rt.apply(this,arguments)}var At,Tt,_t=function(){return C(C({},wt),{},{encoderName:void 0})}(),Mt=(At=ft,Tt={action:De()},xe(Object.assign({},At.fields,Tt),{littleEndian:At.littleEndian,extra:At.extra,postDeserialize:void 0}));var It=function(){var e=pt.slice();return e.splice(6,0,z),e}(),Nt=-1,Dt=function(){return C(C({},_t),{},{logLevel:"debug",lockVideoOrientation:Nt,powerOffOnClose:!1})}(),Pt=function(){return C(C({},Dt),{},{clipboardAutosync:!0})}();function Wt(e){return e.replace(/([A-Z])/g,"_$1").toLowerCase()}var Lt=xe({sequence:Le},{littleEndian:!1}),Vt=xe({type:De,sequence:Le,paste:De(),content:ze(We)},{littleEndian:!1}),Ut=new WeakMap,Bt=new WeakMap,jt=function(){return p(function e(){c(this,e),f(this,Ut,new Map),f(this,Bt,!1),m(this,"id",1)},[{key:"parse",value:(e=o(S().m(function e(t,n){var r,i;return S().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,Lt.deserialize(n);case 1:r=e.v,(i=l(Ut,this).get(r.sequence))&&(i.resolve(),l(Ut,this).delete(r.sequence));case 2:return e.a(2)}},e,this)})),function(t,n){return e.apply(this,arguments)})},{key:"close",value:function(){var e,t=y(l(Ut,this).values());try{for(t.s();!(e=t.n()).done;){e.value.reject()}}catch(e){t.e(e)}finally{t.f()}l(Ut,this).clear(),h(Bt,this,!0)}},{key:"error",value:function(e){var t,n=y(l(Ut,this).values());try{for(n.s();!(t=n.n()).done;){t.value.reject(e)}}catch(e){n.e(e)}finally{n.f()}l(Ut,this).clear(),h(Bt,this,!0)}},{key:"serializeSetClipboardControlMessage",value:function(e){if(0n===e.sequence)return Vt.serialize(e);if(l(Bt,this))throw new Error;var t=new ve;return l(Ut,this).set(e.sequence,t),[Vt.serialize(e),t.promise]}}]);var e}(),Ft=function(){return C(C({},Pt),{},{downsizeOnError:!0,sendDeviceMeta:!0,sendDummyByte:!0})}(),Gt=function(){return C(C({},Ft),{},{cleanup:!0})}(),zt=1n<<62n;var Ht=function(){return C(C({},Gt),{},{powerOn:!0})}(),Kt=ge(2,"byob",function(e,t){var n=t.buffer,r=t.index,i=t.littleEndian;!function(e,t,n,r){r?(e[t]=n,e[t+1]=n>>8):(e[t]=n>>8,e[t+1]=n)}(n,r,e=1===(e=gt(e,-1,1))?32767:32768*e,i)},function(e,t,n){var r=n.littleEndian;return S().m(function n(){var i,o;return S().w(function(n){for(;;)switch(n.n){case 0:return n.d(x(e(t.readExactly(2))),1);case 1:return i=n.v,o=Re(i,0,r),n.a(2,32767===o?1:o/32768)}},n)})()}),qt=function(){return xe({type:De(j),pointerX:We,pointerY:We,videoWidth:Pe,videoHeight:Pe,scrollX:Kt,scrollY:Kt,buttons:We},{littleEndian:!1})}(),Xt=function(){return C(C({},bt(Ht,"bitRate","codecOptions","encoderName")),{},{scid:void 0,videoCodec:"h264",videoBitRate:8e6,videoCodecOptions:void 0,videoEncoder:void 0,audio:!0,audioCodec:"opus",audioBitRate:128e3,audioCodecOptions:void 0,audioEncoder:void 0,listEncoders:!1,listDisplays:!1,sendCodecMeta:!0})}(),Yt=function(){return xe({type:De(B),action:De(),pointerId:Le,pointerX:We,pointerY:We,videoWidth:Pe,videoHeight:Pe,pressure:Et,actionButton:We,buttons:We},{littleEndian:!1})}();function Jt(){return Jt=o(S().m(function e(t,n){var r,i,a,s,u,c,l,f;return S().w(function(e){for(;;)switch(e.n){case 0:return r=new it(t),e.n=1,r.readExactly(4);case 1:i=e.v,a=_e(i,0),c=a,e.n=0===c?2:1===c?3:4;break;case 2:return e.a(2,{type:"disabled"});case 3:return e.a(2,{type:"errored"});case 4:if(!n.sendCodecMeta){e.n=11;break}l=a,e.n=l===L.Raw.metadataValue?5:l===L.Opus.metadataValue?6:l===L.Aac.metadataValue?7:l===L.Flac.metadataValue?8:9;break;case 5:return s=L.Raw,e.a(3,10);case 6:return s=L.Opus,e.a(3,10);case 7:return s=L.Aac,e.a(3,10);case 8:return s=L.Flac,e.a(3,10);case 9:case 16:throw new Error("Unknown audio codec metadata value: ".concat(a));case 10:return e.a(2,{type:"success",codec:s,stream:r.release()});case 11:f=n.audioCodec,e.n="raw"===f?12:"opus"===f?13:"aac"===f?14:"flac"===f?15:16;break;case 12:return u=L.Raw,e.a(3,17);case 13:return u=L.Opus,e.a(3,17);case 14:return u=L.Aac,e.a(3,17);case 15:return u=L.Flac,e.a(3,17);case 17:return e.a(2,{type:"success",codec:u,stream:new Je(function(){var e=o(S().m(function e(t){var n,o,a,s,u;return S().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,t.enqueue(i);case 1:n=r.release(),o=n.getReader();case 2:return e.n=3,o.read();case 3:if(a=e.v,s=a.done,u=a.value,!s){e.n=4;break}return e.a(3,6);case 4:return e.n=5,t.enqueue(u);case 5:e.n=2;break;case 6:return e.a(2)}},e)}));return function(t){return e.apply(this,arguments)}}())})}},e)})),Jt.apply(this,arguments)}function Qt(e){switch(e){case"h264":return se;case"h265":return ue;case"av1":return ce;default:throw new Error("Unknown video codec: ".concat(e))}}function Zt(){return(Zt=o(S().m(function e(t,n){var r,i,o,a,s;return S().w(function(e){for(;;)switch(e.n){case 0:if(r=new it(n),!t.sendDeviceMeta){e.n=2;break}return e.n=1,St(r,64);case 1:i=e.v;case 2:if(!t.sendCodecMeta){e.n=6;break}return e.n=3,xt(r);case 3:return o=e.v,e.n=4,xt(r);case 4:return a=e.v,e.n=5,xt(r);case 5:s=e.v,e.n=7;break;case 6:o=Qt(t.videoCodec);case 7:return e.a(2,{stream:r.release(),metadata:{deviceName:i,codec:o,width:a,height:s}})}},e)}))).apply(this,arguments)}function $t(e,t){return e.sendDeviceMeta||e.sendCodecMeta?function(e,t){return Zt.apply(this,arguments)}(e,t):{stream:t,metadata:{codec:Qt(e.videoCodec)}}}var en=function(){return C(C({},Xt),{},{video:!0,audioSource:"output"})}(),tn=function(){return C(C({},en),{},{videoSource:"display",displayId:0,cameraId:void 0,cameraSize:void 0,cameraFacing:void 0,cameraAr:void 0,cameraFps:void 0,cameraHighSpeed:!1,listCameras:!1,listCameraSizes:!1})}();var nn=function(){return[].concat(_(It),[J,Q,$])}(),rn=xe({id:Pe,data:Ee(Pe)},{littleEndian:!1}),on=new WeakMap,an=function(e){function t(){var e,n;return c(this,t),f(e=s(this,t,[function(e){n=e}]),on,void 0),m(e,"id",2),h(on,e,n),e}return b(t,e),p(t,[{key:"parse",value:(n=o(S().m(function e(t,n){var r;return S().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,rn.deserialize(n);case 1:return r=e.v,e.n=2,l(on,this).enqueue(r);case 2:return e.a(2)}},e,this)})),function(e,t){return n.apply(this,arguments)})},{key:"close",value:function(){l(on,this).close()}},{key:"error",value:function(e){l(on,this).error(e)}}]);var n}(Je),sn=function(){return C(C({},tn),{},{audioDup:!1})}(),un=function(){var e=nn.slice();return e.splice(14,0,Z),e}(),cn=function(){return[].concat(_(un),[ee,te])}(),ln=function(){return C(C({},bt(sn,"lockVideoOrientation")),{},{captureOrientation:void 0,angle:0,screenOffTimeout:void 0,listApps:!1,newDisplay:void 0,vdSystemDecorations:!0})}(),fn=/^\s+--(video|audio)-codec=(\S+)\s+--\1-encoder=(\S+)(?:\s*\((sw|hw|hybrid)\))?(?:\s*\[vendor\])?(?:\s*\(alias for (\S+)\))?$/;function hn(e){switch(e){case"sw":return"software";case"hw":return"hardware";case"hybrid":return"hybrid";default:throw new Error("Unknown hardware type: ".concat(e))}}var dn=function(){return C(C({},ln),{},{vdDestroyContent:!1})}(),vn=xe({type:De,id:Pe,vendorId:Pe,productId:Pe,name:ze(De),data:Ee(Pe)},{littleEndian:!1});var pn=function(){return C(C({},dn),{},{displayImePolicy:void 0})}(),yn=function(){return p(function e(){c(this,e)},[{key:"serializeScrollMessage",value:function(e){return e=C(C({},e),{},{scrollX:e.scrollX/16,scrollY:e.scrollY/16}),qt.serialize(e)}}])}();var mn=new WeakMap,wn=new WeakMap,gn=new WeakMap,bn=new WeakMap,En=function(){return p(function e(t){c(this,e),m(this,"value",void 0),f(this,mn,void 0),f(this,wn,void 0),f(this,gn,void 0),f(this,bn,new ie),this.value=C(C({},pn),t),"camera"===this.value.videoSource&&(this.value.control=!1),this.value.audioDup&&(this.value.audioSource="playback"),this.value.control&&(this.value.clipboardAutosync&&(h(mn,this,l(bn,this).add(new vt)),h(wn,this,l(bn,this).add(new jt))),h(gn,this,l(bn,this).add(new an)))},[{key:"controlMessageTypes",get:function(){return cn}},{key:"clipboard",get:function(){return l(mn,this)}},{key:"uHidOutput",get:function(){return l(gn,this)}},{key:"deviceMessageParsers",get:function(){return l(bn,this)}},{key:"serialize",value:function(){return function(e,t){for(var n=[],r=0,i=Object.entries(e);r<i.length;r++){var o=A(i[r],2),a=o[0],s=ae(o[1],void 0);void 0!==s&&s!==ae(t[a],void 0)&&n.push("".concat(Wt(a),"=").concat(s))}return n}(this.value,pn)}},{key:"setListDisplays",value:function(){this.value.listDisplays=!0}},{key:"parseDisplay",value:function(e){return function(e){var t=e.match(/^\s+--display-id=(\d+)\s+\(([^)]+)\)$/);if(t){var n={id:Number.parseInt(t[1],10)};return"size unknown"!==t[2]&&(n.resolution=t[2]),n}}(e)}},{key:"setListEncoders",value:function(){this.value.listEncoders=!0}},{key:"parseEncoder",value:function(e){return function(e){var t=e.match(fn);return t?{type:t[1],name:t[3],codec:t[2],hardwareType:t[4]?hn(t[4]):void 0,vendor:!!t[5],aliasFor:t[6]}:void 0}(e)}},{key:"parseVideoStreamMetadata",value:function(e){return $t(this.value,e)}},{key:"parseAudioStreamMetadata",value:function(e){return function(e,t){return Jt.apply(this,arguments)}(e,this.value)}},{key:"createMediaStreamTransformer",value:function(){return function(e){if(!e.sendFrameMeta)return new Ye({transform:function(e,t){t.enqueue({type:"data",data:e})}});var t=new lt(kt);return{writable:t.writable,readable:t.readable.pipeThrough(new Ye({transform:function(e,t){e.pts!==Ct?e.pts&zt?t.enqueue({type:"data",keyframe:!0,pts:e.pts&~zt,data:e.data}):t.enqueue({type:"data",keyframe:!1,pts:e.pts,data:e.data}):t.enqueue({type:"configuration",data:e.data})}}))}}(this.value)}},{key:"serializeInjectTouchControlMessage",value:function(e){return function(e){return Yt.serialize(e)}(e)}},{key:"serializeBackOrScreenOnControlMessage",value:function(e){return function(e){return Mt.serialize(e)}(e)}},{key:"serializeSetClipboardControlMessage",value:function(e){return l(wn,this).serializeSetClipboardControlMessage(e)}},{key:"createScrollController",value:function(){return new yn}},{key:"serializeUHidCreateControlMessage",value:function(e){return function(e){return vn.serialize(e)}(e)}}])}();function kn(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}function Cn(e,t,n,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(e,n):i?i.value=n:t.set(e,n),n}function Sn(e){if(e%1!=0)throw new Error("Value must be an integer");if(e<0)throw new Error("Value must be positive");if(e>=256)throw new Error("Value must be less than 256");return e<16?"0"+e.toString(16).toUpperCase():e.toString(16).toUpperCase()}m(En,"Defaults",pn),"function"==typeof SuppressedError&&SuppressedError;var On,xn,Rn,An,Tn,_n,Mn,In,Nn,Dn,Pn,Wn,Ln=S().m(Vn);function Vn(e){var t,n,r,i,o,a,s;return S().w(function(u){for(;;)switch(u.n){case 0:t=-1,n=0,r=!1,i=0;case 1:if(!(i<e.length)){u.n=15;break}if(o=e[i],!r){u.n=3;break}if(!(o>3)){u.n=2;break}throw new Error("Invalid data");case 2:return r=!1,u.a(3,14);case 3:if(0!==o){u.n=4;break}return n+=1,u.a(3,14);case 4:if(a=n,n=0,-1!==t){u.n=6;break}if(!(a>=2&&1===o)){u.n=5;break}return t=i+1,u.a(3,14);case 5:throw new Error("Invalid data");case 6:if(!(a<2)){u.n=7;break}return u.a(3,14);case 7:if(1!==o){u.n=9;break}return u.n=8,e.subarray(t,i-a);case 8:return t=i+1,u.a(3,14);case 9:if(!(a>2)){u.n=10;break}throw new Error("Invalid data");case 10:s=o,u.n=2===s?11:3===s?12:13;break;case 11:throw new Error("Invalid data");case 12:return r=!0,u.a(3,14);case 13:return u.a(3,14);case 14:i+=1,u.n=1;break;case 15:if(!r){u.n=16;break}throw new Error("Invalid data");case 16:return u.n=17,e.subarray(t,e.length);case 17:return u.a(2)}},Ln)}var Un,Bn,jn,Fn,Gn=function(){return p(function e(t){c(this,e),On.add(this),xn.set(this,void 0),Rn.set(this,void 0),An.set(this,void 0),Tn.set(this,0),_n.set(this,0),Mn.set(this,7),In.set(this,0),Cn(this,xn,t,"f");for(var n=t.length-1;n>=0;n-=1)if(0!==kn(this,xn,"f")[n])for(var r=t[n],i=0;i<8;i+=1)if(1==(r>>i&1))return Cn(this,Rn,n,"f"),Cn(this,An,i,"f"),void kn(this,On,"m",Nn).call(this);throw new Error("Stop bit not found")},[{key:"byteLength",get:function(){return kn(this,Rn,"f")}},{key:"stopBitIndex",get:function(){return kn(this,An,"f")}},{key:"bytePosition",get:function(){return kn(this,_n,"f")}},{key:"bitPosition",get:function(){return kn(this,Mn,"f")}},{key:"ended",get:function(){return kn(this,_n,"f")>=kn(this,Rn,"f")&&kn(this,Mn,"f")<=kn(this,An,"f")}},{key:"next",value:function(){if(this.ended)throw new Error("Bit index out of bounds");var e=kn(this,In,"f")>>kn(this,Mn,"f")&1;return Cn(this,Mn,kn(this,Mn,"f")-1,"f"),kn(this,Mn,"f")<0&&(Cn(this,_n,kn(this,_n,"f")+1,"f"),Cn(this,Mn,7,"f"),kn(this,On,"m",Nn).call(this)),e}},{key:"read",value:function(e){if(e>32)throw new Error("Read length too large");for(var t=0,n=0;n<e;n+=1)t=t<<1|this.next();return t}},{key:"skip",value:function(e){if(e<=kn(this,Mn,"f")+1)return Cn(this,Mn,kn(this,Mn,"f")-e,"f"),void kn(this,On,"m",Dn).call(this);for(e-=kn(this,Mn,"f")+1,Cn(this,_n,kn(this,_n,"f")+1,"f"),Cn(this,Mn,7,"f"),kn(this,On,"m",Nn).call(this),kn(this,On,"m",Dn).call(this);e>=8;e-=8)Cn(this,_n,kn(this,_n,"f")+1,"f"),kn(this,On,"m",Nn).call(this),kn(this,On,"m",Dn).call(this);Cn(this,Mn,7-e,"f"),kn(this,On,"m",Dn).call(this)}},{key:"decodeExponentialGolombNumber",value:function(){for(var e=0;0===this.next();)e+=1;return 0===e?0:(1<<e|this.read(e))-1}},{key:"peek",value:function(e){var t=kn(this,On,"m",Pn).call(this),n=this.read(e);return kn(this,On,"m",Wn).call(this,t),n}},{key:"readBytes",value:function(e){for(var t=new Uint8Array(e),n=0;n<e;n+=1)t[n]=this.read(8);return t}},{key:"peekBytes",value:function(e){var t=kn(this,On,"m",Pn).call(this),n=this.readBytes(e);return kn(this,On,"m",Wn).call(this,t),n}}])}();function zn(e){var t=function(e){var t,n,r,i=y(Vn(e));try{for(i.s();!(r=i.n()).done;){var o=r.value;switch(31&o[0]){case 7:if(t=o,n)return{sequenceParameterSet:t,pictureParameterSet:n};break;case 8:if(n=o,t)return{sequenceParameterSet:t,pictureParameterSet:n}}}}catch(e){i.e(e)}finally{i.f()}throw new Error("Invalid data")}(e),n=t.sequenceParameterSet,r=t.pictureParameterSet,i=function(e){var t=new Gn(e);if(0!==t.next())throw new Error("Invalid data");var n=t.read(2);if(7!==t.read(5))throw new Error("Invalid data");if(0===n)throw new Error("Invalid data");var r=t.read(8),i=t.peek(8),o=!!t.next(),a=!!t.next(),s=!!t.next(),u=!!t.next(),c=!!t.next(),l=!!t.next();if(0!==t.read(2))throw new Error("Invalid data");var f=t.read(8),h=t.decodeExponentialGolombNumber();if(100===r||110===r||122===r||244===r||44===r||83===r||86===r||118===r||128===r||138===r||139===r||134===r){var d=t.decodeExponentialGolombNumber();if(3===d&&t.next(),t.decodeExponentialGolombNumber(),t.decodeExponentialGolombNumber(),t.next(),t.next())for(var v=[],p=0;p<(3!==d?8:12);p+=1)v[p]=!!t.next(),v[p]}t.decodeExponentialGolombNumber();var y=t.decodeExponentialGolombNumber();if(0===y)t.decodeExponentialGolombNumber();else if(1===y){t.next(),t.decodeExponentialGolombNumber(),t.decodeExponentialGolombNumber();for(var m=t.decodeExponentialGolombNumber(),w=[],g=0;g<m;g+=1)w[g]=t.decodeExponentialGolombNumber()}t.decodeExponentialGolombNumber(),t.next();var b=t.decodeExponentialGolombNumber(),E=t.decodeExponentialGolombNumber(),k=t.next();k||t.next(),t.next();var C,S,O,x,R=!!t.next();return R?(C=t.decodeExponentialGolombNumber(),S=t.decodeExponentialGolombNumber(),O=t.decodeExponentialGolombNumber(),x=t.decodeExponentialGolombNumber()):(C=0,S=0,O=0,x=0),t.next(),{profile_idc:r,constraint_set:i,constraint_set0_flag:o,constraint_set1_flag:a,constraint_set2_flag:s,constraint_set3_flag:u,constraint_set4_flag:c,constraint_set5_flag:l,level_idc:f,seq_parameter_set_id:h,pic_width_in_mbs_minus1:b,pic_height_in_map_units_minus1:E,frame_mbs_only_flag:k,frame_cropping_flag:R,frame_crop_left_offset:C,frame_crop_right_offset:S,frame_crop_top_offset:O,frame_crop_bottom_offset:x}}(n),o=i.profile_idc,a=i.constraint_set,s=i.level_idc,u=16*(i.pic_width_in_mbs_minus1+1),c=(i.pic_height_in_map_units_minus1+1)*(2-i.frame_mbs_only_flag)*16,l=2*i.frame_crop_left_offset,f=2*i.frame_crop_right_offset,h=2*i.frame_crop_top_offset,d=2*i.frame_crop_bottom_offset;return{pictureParameterSet:r,sequenceParameterSet:n,profileIndex:o,constraintSet:a,levelIndex:s,encodedWidth:u,encodedHeight:c,cropLeft:l,cropRight:f,cropTop:h,cropBottom:d,croppedWidth:u-l-f,croppedHeight:c-h-d}}function Hn(e){var t=e.profileIndex,n=e.constraintSet,r=e.levelIndex;return"avc1."+Sn(t)+Sn(n)+Sn(r)}xn=new WeakMap,Rn=new WeakMap,An=new WeakMap,Tn=new WeakMap,_n=new WeakMap,Mn=new WeakMap,In=new WeakMap,On=new WeakSet,Nn=function e(){if(Cn(this,In,kn(this,xn,"f")[kn(this,_n,"f")],"f"),2===kn(this,Tn,"f")&&3===kn(this,In,"f"))return Cn(this,Tn,0,"f"),Cn(this,_n,kn(this,_n,"f")+1,"f"),void kn(this,On,"m",e).call(this);0===kn(this,In,"f")?Cn(this,Tn,kn(this,Tn,"f")+1,"f"):Cn(this,Tn,0,"f")},Dn=function(){if(kn(this,_n,"f")>=kn(this,Rn,"f")&&kn(this,Mn,"f")<kn(this,An,"f"))throw new Error("Bit index out of bounds")},Pn=function(){return{zeroCount:kn(this,Tn,"f"),bytePosition:kn(this,_n,"f"),bitPosition:kn(this,Mn,"f"),byte:kn(this,In,"f")}},Wn=function(e){Cn(this,Tn,e.zeroCount,"f"),Cn(this,_n,e.bytePosition,"f"),Cn(this,Mn,e.bitPosition,"f"),Cn(this,In,e.byte,"f")};var Kn,qn,Xn,Yn=function(){return p(function e(t){c(this,e),Un.set(this,void 0),Bn.set(this,void 0),jn.set(this,!1),Fn.set(this,void 0),Cn(this,Fn,t,"f")},[{key:"decode",value:function(e){if("configuration"===e.type)return Cn(this,Un,e.data,"f"),Cn(this,Bn,this.configure(e.data),"f"),void Cn(this,jn,!0,"f");var t;e.keyframe&&kn(this,Bn,"f")&&(kn(this,Fn,"f").reset(),kn(this,Fn,"f").configure(kn(this,Bn,"f")),kn(this,Un,"f")&&Cn(this,jn,!0,"f")),kn(this,jn,"f")&&void 0!==kn(this,Un,"f")?((t=new Uint8Array(kn(this,Un,"f").length+e.data.length)).set(kn(this,Un,"f"),0),t.set(e.data,kn(this,Un,"f").length),Cn(this,jn,!1,"f")):t=e.data,kn(this,Fn,"f").decode(new EncodedVideoChunk({type:!1===e.keyframe?"delta":"key",timestamp:void 0!==e.pts?Number(e.pts):1,data:t}))}}])}();Un=new WeakMap,Bn=new WeakMap,jn=new WeakMap,Fn=new WeakMap;var Jn,Qn,Zn,$n,er,tr,nr=function(e){function t(e,n,r){var i;return c(this,t),i=s(this,t,[e]),Kn.set(i,void 0),qn.set(i,void 0),Xn.set(i,void 0),Cn(i,Kn,e,"f"),Cn(i,qn,n,"f"),Cn(i,Xn,r,"f"),i}return b(t,e),p(t,[{key:"configure",value:function(e){var t,n,r=zn(e);kn(this,qn,"f").call(this,r.croppedWidth,r.croppedHeight);var i={codec:Hn(r),hardwareAcceleration:null!==(t=null===(n=kn(this,Xn,"f"))||void 0===n?void 0:n.hardwareAcceleration)&&void 0!==t?t:"no-preference",optimizeForLatency:!0};return kn(this,Kn,"f").configure(i),i}}])}(Yn);Kn=new WeakMap,qn=new WeakMap,Xn=new WeakMap;var rr,ir,or=function(){return p(function e(t,n){var r=this;c(this,e),Jn.set(this,void 0),Qn.set(this,new ReadableStream({start:function(e){Cn(r,Jn,e,"f")},pull:function(e){e.enqueue(kn(r,$n,"f").call(r))}},{highWaterMark:0})),Zn.set(this,kn(this,Qn,"f").getReader()),$n.set(this,void 0),er.set(this,0),tr.set(this,void 0),Cn(this,$n,t,"f"),Cn(this,tr,n,"f")},[{key:"borrow",value:(e=o(S().m(function e(){var t;return S().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,kn(this,Zn,"f").read();case 1:return t=e.v,e.a(2,t.value)}},e,this)})),function(){return e.apply(this,arguments)})},{key:"return",value:function(e){kn(this,er,"f")<kn(this,tr,"f")&&(kn(this,Jn,"f").enqueue(e),Cn(this,er,kn(this,er,"f")+1,"f"))}}]);var e}();Jn=new WeakMap,Qn=new WeakMap,Zn=new WeakMap,$n=new WeakMap,er=new WeakMap,tr=new WeakMap;var ar,sr,ur,cr,lr,fr,hr,dr,vr,pr,yr,mr,wr=function(){return p(function e(){c(this,e),rr.set(this,void 0),ir.set(this,void 0),"undefined"!=typeof OffscreenCanvas?Cn(this,rr,new OffscreenCanvas(1,1),"f"):(Cn(this,rr,document.createElement("canvas"),"f"),kn(this,rr,"f").width=1,kn(this,rr,"f").height=1);var t=kn(this,rr,"f").getContext("bitmaprenderer",{alpha:!1});if(!t)throw new Error("ImageBitmapRenderingContext is not supported");Cn(this,ir,t,"f")},[{key:"capture",value:(e=o(S().m(function e(t){var n,r=this;return S().w(function(e){for(;;)switch(e.n){case 0:return kn(this,rr,"f").width=t.displayWidth,kn(this,rr,"f").height=t.displayHeight,e.n=1,createImageBitmap(t);case 1:if(n=e.v,kn(this,ir,"f").transferFromImageBitmap(n),!(kn(this,rr,"f")instanceof OffscreenCanvas)){e.n=3;break}return e.n=2,kn(this,rr,"f").convertToBlob({type:"image/png"});case 2:return e.a(2,e.v);case 3:return e.a(2,new Promise(function(e,t){kn(r,rr,"f").toBlob(function(n){n?e(n):t(new Error("Failed to convert canvas to blob"))},"image/png")}));case 4:return e.a(2)}},e,this)})),function(t){return e.apply(this,arguments)})}]);var e}();rr=new WeakMap,ir=new WeakMap;var gr,br,Er,kr,Cr,Sr=function(){return p(function e(t,n){var r=this;c(this,e),ar.add(this),sr.set(this,!1),ur.set(this,!1),cr.set(this,void 0),lr.set(this,void 0),fr.set(this,void 0),hr.set(this,[]),dr.set(this,void 0),vr.set(this,!1),this.write=function(){var e=o(S().m(function e(t){var n,i;return S().w(function(e){for(;;)switch(e.n){case 0:if(!kn(r,vr,"f")){e.n=1;break}throw new Error("Attempt to write to a closed decoder");case 1:if(!kn(r,sr,"f")){e.n=5;break}n=t.type,e.n="configuration"===n?2:"data"===n?3:4;break;case 2:return Cn(r,fr,t,"f"),kn(r,hr,"f").length=0,e.a(3,4);case 3:return t.keyframe&&(kn(r,hr,"f").length=0),kn(r,hr,"f").push(t),e.a(3,4);case 4:case 12:return e.a(2);case 5:return e.n=6,kn(r,dr,"f");case 6:if(!kn(r,vr,"f")){e.n=7;break}return e.a(2);case 7:i=t.type,e.n="configuration"===i?8:"data"===i?10:12;break;case 8:return e.n=9,kn(r,cr,"f").call(r,t);case 9:case 11:return e.a(3,12);case 10:return e.n=11,kn(r,lr,"f").call(r,t,!1)}},e)}));return function(t){return e.apply(this,arguments)}}(),mr.set(this,void 0),Cn(this,cr,t,"f"),Cn(this,lr,n,"f")},[{key:"paused",get:function(){return kn(this,sr,"f")}},{key:"pause",value:function(){kn(this,ar,"m",pr).call(this,!0)}},{key:"resume",value:function(){return kn(this,ar,"m",yr).call(this,!0)}},{key:"trackDocumentVisibility",value:function(e){var t,n=this;null===(t=kn(this,mr,"f"))||void 0===t||t.call(this);var r=function(){"hidden"===e.visibilityState?kn(n,ar,"m",pr).call(n,!1):kn(n,ar,"m",yr).call(n,!1)};r(),e.addEventListener("visibilitychange",r);var i=!1;return Cn(this,mr,function(){i||(i=!0,e.removeEventListener("visibilitychange",r),kn(n,vr,"f")||kn(n,ar,"m",yr).call(n,!1))},"f"),kn(this,mr,"f")}},{key:"dispose",value:function(){var e;kn(this,vr,"f")||(Cn(this,vr,!0,"f"),Cn(this,fr,void 0,"f"),kn(this,hr,"f").length=0,null===(e=kn(this,mr,"f"))||void 0===e||e.call(this))}}])}();sr=new WeakMap,ur=new WeakMap,cr=new WeakMap,lr=new WeakMap,fr=new WeakMap,hr=new WeakMap,dr=new WeakMap,vr=new WeakMap,mr=new WeakMap,ar=new WeakSet,pr=function(e){if(kn(this,vr,"f"))throw new Error("Attempt to pause a closed decoder");Cn(this,sr,!0,"f"),e&&Cn(this,ur,!0,"f")},yr=function(){var e=o(S().m(function e(t){var n,r,i,o;return S().w(function(e){for(;;)switch(e.n){case 0:if(!kn(this,vr,"f")){e.n=1;break}throw new Error("Attempt to resume a closed decoder");case 1:if(kn(this,sr,"f")){e.n=2;break}return e.a(2);case 2:if(!kn(this,ur,"f")||t){e.n=3;break}return e.a(2);case 3:if(n=new ve,Cn(this,dr,n.promise,"f"),Cn(this,sr,!1,"f"),Cn(this,ur,!1,"f"),!kn(this,fr,"f")){e.n=5;break}return e.n=4,kn(this,cr,"f").call(this,kn(this,fr,"f"));case 4:if(Cn(this,fr,void 0,"f"),!kn(this,vr,"f")){e.n=5;break}return e.a(2);case 5:r=0,i=kn(this,hr,"f").length;case 6:if(!(r<i)){e.n=9;break}return o=kn(this,hr,"f")[r],e.n=7,kn(this,lr,"f").call(this,o,r!==i-1);case 7:if(!kn(this,vr,"f")){e.n=8;break}return e.a(2);case 8:r+=1,e.n=6;break;case 9:kn(this,hr,"f").length=0,n.resolve(void 0),Cn(this,dr,void 0,"f");case 10:return e.a(2)}},e,this)}));return function(t){return e.apply(this,arguments)}}();var Or=function(){return p(function e(){var t=this;c(this,e),gr.set(this,0),br.set(this,0),Er.set(this,0),kr.set(this,void 0),Cr.set(this,function(){kn(t,gr,"f")>0&&(Cn(t,br,kn(t,br,"f")+1,"f"),Cn(t,gr,0,"f")),Cn(t,kr,requestAnimationFrame(kn(t,Cr,"f")),"f")});try{Cn(this,kr,requestAnimationFrame(kn(this,Cr,"f")),"f")}catch(e){}},[{key:"framesDrawn",get:function(){return kn(this,gr,"f")}},{key:"framesRendered",get:function(){return kn(this,gr,"f")}},{key:"framesPresented",get:function(){return kn(this,br,"f")}},{key:"framesSkipped",get:function(){return kn(this,Er,"f")}},{key:"increaseFramesSkipped",value:function(){Cn(this,Er,kn(this,Er,"f")+1,"f")}},{key:"increaseFramesDrawn",value:function(){Cn(this,gr,kn(this,gr,"f")+1,"f")}},{key:"dispose",value:function(){void 0!==kn(this,kr,"f")&&cancelAnimationFrame(kn(this,kr,"f"))}}])}();gr=new WeakMap,br=new WeakMap,Er=new WeakMap,kr=new WeakMap,Cr=new WeakMap;var xr,Rr,Ar,Tr=function(){return p(function e(){var t=this;c(this,e),m(this,"listeners",[]),m(this,"event",function(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),o=2;o<r;o++)i[o-2]=arguments[o];var a={listener:e,thisArg:n,args:i};return t.addEventListener(a)}),this.event=this.event.bind(this)},[{key:"addEventListener",value:function(e){var t=this;this.listeners.push(e);var n=function(){var n=t.listeners.indexOf(e);-1!==n&&t.listeners.splice(n,1)};return n.dispose=n,n}},{key:"fire",value:function(e){var t,n=y(this.listeners.slice());try{for(n.s();!(t=n.n()).done;){var r,i=t.value;(r=i.listener).call.apply(r,[i.thisArg,e].concat(_(i.args)))}}catch(e){n.e(e)}finally{n.f()}}},{key:"dispose",value:function(){this.listeners.length=0}}])}(),_r=Symbol("undefined"),Mr=new WeakMap,Ir=function(e){function t(){var e;c(this,t);for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return f(e=s(this,t,[].concat(r)),Mr,_r),e}return b(t,e),p(t,[{key:"addEventListener",value:function(e){var n;l(Mr,this)!==_r&&(n=e.listener).call.apply(n,[e.thisArg,l(Mr,this)].concat(_(e.args)));return T(t,"addEventListener",this)([e])}},{key:"fire",value:function(e){h(Mr,this,e),T(t,"fire",this)([e])}}])}(Tr),Nr=function(){return p(function e(){c(this,e),xr.set(this,0),Rr.set(this,0),Ar.set(this,new Ir)},[{key:"width",get:function(){return kn(this,xr,"f")}},{key:"height",get:function(){return kn(this,Rr,"f")}},{key:"sizeChanged",get:function(){return kn(this,Ar,"f").event}},{key:"setSize",value:function(e,t){kn(this,xr,"f")===e&&kn(this,Rr,"f")===t||(Cn(this,xr,e,"f"),Cn(this,Rr,t,"f"),kn(this,Ar,"f").fire({width:e,height:t}))}},{key:"dispose",value:function(){kn(this,Ar,"f").dispose()}}])}();xr=new WeakMap,Rr=new WeakMap,Ar=new WeakMap;var Dr,Pr,Wr,Lr,Vr,Ur,Br,jr,Fr,Gr,zr,Hr,Kr,qr,Xr,Yr,Jr,Qr,Zr,$r,ei,ti,ni,ri,ii,oi,ai,si,ui,ci,li,fi,hi,di=["codec","renderer","frameDropMode"],vi=new or(function(){return new wr},4);!function(e){e.RenderLatest="render-latest",e.DropWhenBusy="drop-when-busy",e.RenderAll="render-all"}(hi||(hi={}));var pi,yi=function(){return p(function e(t){var n=this,r=t.codec,i=t.renderer,o=t.frameDropMode,a=function(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}(t,di);if(c(this,e),Dr.add(this),Pr.set(this,void 0),Wr.set(this,void 0),Lr.set(this,void 0),Vr.set(this,void 0),Ur.set(this,hi.RenderLatest),Br.set(this,1),jr.set(this,[]),Fr.set(this,1),Gr.set(this,[]),zr.set(this,void 0),Hr.set(this,void 0),Kr.set(this,new Nr),qr.set(this,new Or),Xr.set(this,void 0),Yr.set(this,void 0),Jr.set(this,void 0),Qr.set(this,0),Zr.set(this,0),$r.set(this,!1),ei.set(this,void 0),ti.set(this,[]),ni.set(this,void 0),oi.set(this,function(e,t){kn(n,Wr,"f").setSize(e,t),kn(n,Kr,"f").setSize(e,t)}),Cn(this,Pr,r,"f"),Cn(this,Wr,i,"f"),Cn(this,Lr,a,"f"),Cn(this,Ur,null!=o?o:hi.RenderLatest,"f"),Cn(this,Yr,new VideoDecoder({output:function(e){var t;return kn(n,Ur,"f")!==hi.RenderLatest&&kn(n,Dr,"m",ui).call(n),kn(n,Vr,"f")||0===e.timestamp?(e.close(),void(kn(n,Ur,"f")===hi.RenderAll&&kn(n,Dr,"m",li).call(n))):(Cn(n,Qr,kn(n,Qr,"f")+1,"f"),Cn(n,Zr,kn(n,Zr,"f")+(performance.now()-e.timestamp/1e3),"f"),null===(t=kn(n,ni,"f"))||void 0===t||t.close(),Cn(n,ni,e.clone(),"f"),void kn(n,Dr,"m",ii).call(n,e))},error:function(e){kn(n,Ur,"f")!==hi.RenderLatest&&kn(n,Dr,"m",ui).call(n),kn(n,Ur,"f")===hi.RenderAll&&kn(n,Dr,"m",li).call(n),kn(n,Dr,"m",ri).call(n,e)}}),"f"),kn(this,Pr,"f")!==se)throw new Error("Unsupported codec: ".concat(kn(this,Pr,"f")));Cn(this,Jr,new nr(kn(this,Yr,"f"),kn(this,oi,"f"),kn(this,Lr,"f")),"f"),Cn(this,Xr,new Sr(function(e){return kn(n,Jr,"f").decode(e)},function(e,t){kn(n,Dr,"m",ai).call(n,e,t)}),"f"),Cn(this,zr,new Xe({start:function(e){kn(n,Vr,"f")?e.error(kn(n,Vr,"f")):Cn(n,Hr,e,"f")},write:kn(this,Xr,"f").write}),"f")},[{key:"codec",get:function(){return kn(this,Pr,"f")}},{key:"renderer",get:function(){return kn(this,Wr,"f")}},{key:"writable",get:function(){return kn(this,zr,"f")}},{key:"width",get:function(){return kn(this,Kr,"f").width}},{key:"height",get:function(){return kn(this,Kr,"f").height}},{key:"sizeChanged",get:function(){return kn(this,Kr,"f").sizeChanged}},{key:"framesDrawn",get:function(){return kn(this,qr,"f").framesDrawn}},{key:"framesRendered",get:function(){return kn(this,qr,"f").framesRendered}},{key:"framesPresented",get:function(){return kn(this,qr,"f").framesPresented}},{key:"framesSkipped",get:function(){return kn(this,qr,"f").framesSkipped}},{key:"paused",get:function(){return kn(this,Xr,"f").paused}},{key:"framesDecoded",get:function(){return kn(this,Qr,"f")}},{key:"decodeQueueSize",get:function(){return kn(this,Yr,"f").decodeQueueSize}},{key:"decodingTime",get:function(){return kn(this,Zr,"f")}},{key:"snapshot",value:(e=o(S().m(function e(){var t,n;return S().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t=kn(this,ni,"f")){e.n=1;break}return e.a(2,void 0);case 1:return e.n=2,vi.borrow();case 2:return n=e.v,e.p=3,e.n=4,n.capture(t);case 4:return e.a(2,e.v);case 5:return e.p=5,vi.return(n),e.f(5);case 6:return e.a(2)}},e,this,[[3,,5,6]])})),function(){return e.apply(this,arguments)})},{key:"pause",value:function(){kn(this,Xr,"f").pause()}},{key:"resume",value:function(){return kn(this,Xr,"f").resume()}},{key:"trackDocumentVisibility",value:function(e){return kn(this,Xr,"f").trackDocumentVisibility(e)}},{key:"dispose",value:function(){var e,t;null===(e=kn(this,ni,"f"))||void 0===e||e.close(),kn(this,qr,"f").dispose(),kn(this,Wr,"f").dispose(),kn(this,Kr,"f").dispose(),null===(t=kn(this,ei,"f"))||void 0===t||t.close();var n,r=y(kn(this,ti,"f"));try{for(r.s();!(n=r.n()).done;){n.value.close()}}catch(e){r.e(e)}finally{r.f()}kn(this,ti,"f").length=0,"closed"!==kn(this,Yr,"f").state&&kn(this,Yr,"f").close(),kn(this,Xr,"f").dispose()}}],[{key:"isSupported",get:function(){return void 0!==globalThis.VideoDecoder}}]);var e}();function mi(){if("undefined"!=typeof document)return document.createElement("canvas");if("undefined"!=typeof OffscreenCanvas)return new OffscreenCanvas(1,1);throw new Error("no canvas input found nor any canvas can be created")}function wi(e,t){try{var n=e.getContext("webgl2",t);if(n)return n}catch(e){}try{var r=e.getContext("webgl",t);if(r)return r}catch(e){}if(e instanceof HTMLCanvasElement){var i=e.getContext("experimental-webgl",t);if(i)return i}return null}function gi(e){try{var t;null===(t=e.getExtension("WEBGL_lose_context"))||void 0===t||t.loseContext()}catch(e){}}Pr=new WeakMap,Wr=new WeakMap,Lr=new WeakMap,Vr=new WeakMap,Ur=new WeakMap,Br=new WeakMap,jr=new WeakMap,Fr=new WeakMap,Gr=new WeakMap,zr=new WeakMap,Hr=new WeakMap,Kr=new WeakMap,qr=new WeakMap,Xr=new WeakMap,Yr=new WeakMap,Jr=new WeakMap,Qr=new WeakMap,Zr=new WeakMap,$r=new WeakMap,ei=new WeakMap,ti=new WeakMap,ni=new WeakMap,oi=new WeakMap,Dr=new WeakSet,ri=function(e){if(!kn(this,Vr,"f")){Cn(this,Vr,e,"f");try{var t;null===(t=kn(this,Hr,"f"))||void 0===t||t.error(e)}catch(e){}kn(this,Dr,"m",fi).call(this),this.dispose()}},ii=function(){var e=o(S().m(function e(t){var n,r;return S().w(function(e){for(;;)switch(e.p=e.n){case 0:if(e.p=0,!kn(this,$r,"f")){e.n=1;break}return kn(this,Ur,"f")===hi.RenderAll?kn(this,ti,"f").push(t):(kn(this,ei,"f")&&(kn(this,ei,"f").close(),kn(this,qr,"f").increaseFramesSkipped()),Cn(this,ei,t,"f")),e.a(2);case 1:Cn(this,$r,!0,"f");case 2:return kn(this,oi,"f").call(this,t.displayWidth,t.displayHeight),e.n=3,kn(this,Wr,"f").draw(t);case 3:if(t.close(),kn(this,qr,"f").increaseFramesDrawn(),kn(this,Ur,"f")!==hi.RenderAll){e.n=6;break}if(!(n=kn(this,ti,"f").shift())){e.n=4;break}t=n,e.n=5;break;case 4:return e.a(3,9);case 5:e.n=8;break;case 6:if(!kn(this,ei,"f")){e.n=7;break}t=kn(this,ei,"f"),Cn(this,ei,void 0,"f"),e.n=8;break;case 7:return e.a(3,9);case 8:e.n=2;break;case 9:Cn(this,$r,!1,"f"),kn(this,Ur,"f")===hi.RenderAll&&kn(this,Dr,"m",li).call(this),e.n=11;break;case 10:e.p=10,r=e.v,kn(this,Ur,"f")===hi.RenderAll&&kn(this,Dr,"m",li).call(this),kn(this,Dr,"m",ri).call(this,r);case 11:return e.a(2)}},e,this,[[0,10]])}));return function(t){return e.apply(this,arguments)}}(),ai=function(){var e=o(S().m(function e(t,n){var r,i,o,a,s,u;return S().w(function(e){for(;;)switch(e.n){case 0:if(kn(this,Ur,"f")!==hi.RenderAll){e.n=3;break}return e.n=1,kn(this,Dr,"m",ci).call(this);case 1:return e.n=2,kn(this,Dr,"m",si).call(this);case 2:e.n=4;break;case 3:if(kn(this,Ur,"f")!==hi.DropWhenBusy){e.n=4;break}return e.n=4,kn(this,Dr,"m",si).call(this);case 4:n?r=0n:(i=performance.now(),o=i.toString().split("."),a=A(o,2),s=a[0],u=a[1],r=BigInt(s+((void 0===u?"":u)+"000").slice(0,3)));try{kn(this,Jr,"f").decode(C(C({},t),{},{pts:r}))}catch(e){kn(this,Ur,"f")!==hi.RenderLatest&&kn(this,Dr,"m",ui).call(this),kn(this,Ur,"f")===hi.RenderAll&&kn(this,Dr,"m",li).call(this),kn(this,Dr,"m",ri).call(this,e)}case 5:return e.a(2)}},e,this)}));return function(t,n){return e.apply(this,arguments)}}(),si=function(){var e=o(S().m(function e(){var t=this;return S().w(function(e){for(;;)switch(e.n){case 0:if(!(kn(this,Br,"f")>0)){e.n=1;break}return Cn(this,Br,kn(this,Br,"f")-1,"f"),e.a(2);case 1:return e.n=2,new Promise(function(e){kn(t,jr,"f").push(e)});case 2:return e.a(2)}},e,this)}));return function(){return e.apply(this,arguments)}}(),ui=function(){kn(this,jr,"f").length>0?kn(this,jr,"f").shift()():kn(this,Br,"f")<1&&Cn(this,Br,kn(this,Br,"f")+1,"f")},ci=function(){var e=o(S().m(function e(){var t=this;return S().w(function(e){for(;;)switch(e.n){case 0:if(!(kn(this,Fr,"f")>0)){e.n=1;break}return Cn(this,Fr,kn(this,Fr,"f")-1,"f"),e.a(2);case 1:return e.n=2,new Promise(function(e){kn(t,Gr,"f").push(e)});case 2:return e.a(2)}},e,this)}));return function(){return e.apply(this,arguments)}}(),li=function(){kn(this,Gr,"f").length>0?kn(this,Gr,"f").shift()():kn(this,Fr,"f")<1&&Cn(this,Fr,kn(this,Fr,"f")+1,"f")},fi=function(){var e,t=y(kn(this,jr,"f"));try{for(t.s();!(e=t.n()).done;){(0,e.value)()}}catch(e){t.e(e)}finally{t.f()}kn(this,jr,"f").length=0,Cn(this,Br,1,"f");var n,r=y(kn(this,Gr,"f"));try{for(r.s();!(n=r.n()).done;){(0,n.value)()}}catch(e){r.e(e)}finally{r.f()}kn(this,Gr,"f").length=0,Cn(this,Fr,1,"f")},yi.capabilities={h264:{}};var bi,Ei=function(){return p(function e(t){c(this,e),pi.set(this,void 0),Cn(this,pi,t||mi(),"f")},[{key:"canvas",get:function(){return kn(this,pi,"f")}},{key:"setSize",value:function(e,t){kn(this,pi,"f").width===e&&kn(this,pi,"f").height===t||(kn(this,pi,"f").width=e,kn(this,pi,"f").height=t)}},{key:"dispose",value:function(){kn(this,pi,"f").width=0,kn(this,pi,"f").height=0}}])}();pi=new WeakMap;var ki=Promise.resolve(),Ci=function(e){function t(e,n){var r;c(this,t),r=s(this,t,[e]),bi.set(r,void 0);var i=wi(r.canvas,{powerPreference:"low-power",alpha:!1,failIfMajorPerformanceCaveat:!0,preserveDrawingBuffer:!!n,desynchronized:!n,antialias:!1,depth:!1,premultipliedAlpha:!0,stencil:!1});if(!i)throw new Error("WebGL not supported, check `isSupported` first");Cn(r,bi,i,"f");var o=i.createShader(i.VERTEX_SHADER);if(i.shaderSource(o,t.VertexShaderSource),i.compileShader(o),!i.getShaderParameter(o,i.COMPILE_STATUS))throw new Error(i.getShaderInfoLog(o));var a=i.createShader(i.FRAGMENT_SHADER);if(i.shaderSource(a,t.FragmentShaderSource),i.compileShader(a),!i.getShaderParameter(a,i.COMPILE_STATUS))throw new Error(i.getShaderInfoLog(a));var u=i.createProgram();if(i.attachShader(u,o),i.attachShader(u,a),i.linkProgram(u),!i.getProgramParameter(u,i.LINK_STATUS))throw new Error(i.getProgramInfoLog(u));i.useProgram(u);var l=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,l),i.bufferData(i.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),i.STATIC_DRAW);var f=i.getAttribLocation(u,"xy");i.vertexAttribPointer(f,2,i.FLOAT,!1,0,0),i.enableVertexAttribArray(f);var h=i.createTexture();return i.bindTexture(i.TEXTURE_2D,h),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i instanceof WebGL2RenderingContext?i.NEAREST_MIPMAP_LINEAR:i.NEAREST),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),r}return b(t,e),p(t,[{key:"draw",value:function(e){var t=kn(this,bi,"f");return t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),t instanceof WebGL2RenderingContext&&t.generateMipmap(t.TEXTURE_2D),t.viewport(0,0,t.drawingBufferWidth,t.drawingBufferHeight),t.drawArrays(t.TRIANGLE_FAN,0,4),ki}},{key:"dispose",value:function(){gi(kn(this,bi,"f"))}}],[{key:"isSupported",get:function(){return e={failIfMajorPerformanceCaveat:!0},(t=wi(mi(),e))&&gi(t),!!t;var e,t}}])}(Ei);bi=new WeakMap,Ci.VertexShaderSource="\n attribute vec2 xy;\n\n varying highp vec2 uv;\n\n void main(void) {\n gl_Position = vec4(xy, 0.0, 1.0);\n // Map vertex coordinates (-1 to +1) to UV coordinates (0 to 1).\n // UV coordinates are Y-flipped relative to vertex coordinates.\n uv = vec2((1.0 + xy.x) / 2.0, (1.0 - xy.y) / 2.0);\n }\n",Ci.FragmentShaderSource="\n precision mediump float;\n\n varying highp vec2 uv;\n uniform sampler2D texture;\n\n void main(void) {\n gl_FragColor = texture2D(texture, uv);\n }\n";var Si=function(){return p(function e(t,n){c(this,e),this.program=null,this.texture=null,this.vertexBuffer=null,this.canvas=t;var r={alpha:!1,depth:!1,stencil:!1,antialias:!1,preserveDrawingBuffer:!1,powerPreference:null!=n?n:"low-power",failIfMajorPerformanceCaveat:!0},i=t.getContext("webgl2",r)||t.getContext("webgl",r);if(!i)throw new Error("WebGL not supported");this.gl=i,this.initGL()},[{key:"initGL",value:function(){var e=this.gl,t=this.createShader(e.VERTEX_SHADER,"\n attribute vec2 a_pos;\n varying highp vec2 v_texCoord;\n void main() {\n gl_Position = vec4(a_pos, 0.0, 1.0);\n // Map [-1, 1] to [0, 1] and flip Y for texture\n v_texCoord = vec2((a_pos.x + 1.0) * 0.5, (1.0 - a_pos.y) * 0.5);\n }\n "),n=this.createShader(e.FRAGMENT_SHADER,"\n varying highp vec2 v_texCoord;\n uniform sampler2D u_sampler;\n void main() {\n gl_FragColor = texture2D(u_sampler, v_texCoord);\n }\n ");this.program=this.createProgram(t,n),e.useProgram(this.program);var r=new Float32Array([-1,-1,1,-1,-1,1,1,1]);this.vertexBuffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),e.bufferData(e.ARRAY_BUFFER,r,e.STATIC_DRAW);var i=e.getAttribLocation(this.program,"a_pos");e.enableVertexAttribArray(i),e.vertexAttribPointer(i,2,e.FLOAT,!1,0,0),this.texture=e.createTexture(),e.bindTexture(e.TEXTURE_2D,this.texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.clearColor(1,1,1,1),e.clear(e.COLOR_BUFFER_BIT)}},{key:"setSize",value:function(e,t){this.canvas.width===e&&this.canvas.height===t||(this.canvas.width=e,this.canvas.height=t)}},{key:"draw",value:function(e){var t=this.gl;t&&this.program&&(t.viewport(0,0,t.drawingBufferWidth,t.drawingBufferHeight),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,this.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),t.drawArrays(t.TRIANGLE_STRIP,0,4))}},{key:"createShader",value:function(e,t){var n=this.gl,r=n.createShader(e);if(n.shaderSource(r,t),n.compileShader(r),!n.getShaderParameter(r,n.COMPILE_STATUS)){var i=n.getShaderInfoLog(r);throw n.deleteShader(r),new Error("Shader compile error: "+i)}return r}},{key:"createProgram",value:function(e,t){var n=this.gl,r=n.createProgram();if(n.attachShader(r,e),n.attachShader(r,t),n.linkProgram(r),!n.getProgramParameter(r,n.LINK_STATUS)){var i=n.getProgramInfoLog(r);throw n.deleteProgram(r),new Error("Program link error: "+i)}return n.detachShader(r,e),n.detachShader(r,t),n.deleteShader(e),n.deleteShader(t),r}},{key:"dispose",value:function(){var e,t=this.gl;this.texture&&t.deleteTexture(this.texture),this.vertexBuffer&&t.deleteBuffer(this.vertexBuffer),this.program&&t.deleteProgram(this.program),null===(e=t.getExtension("WEBGL_lose_context"))||void 0===e||e.loseContext()}}],[{key:"isSupported",get:function(){try{var e=new OffscreenCanvas(1,1);return!(!e.getContext("webgl2")&&!e.getContext("webgl"))}catch(e){return!1}}}])}(),Oi=function(){return p(function e(t){if(c(this,e),this.canvas=t,this.ctx=null,this.ctx=t.getContext("2d",{alpha:!1,desynchronized:!0}),!this.ctx)throw new Error("Canvas 2D not supported")},[{key:"setSize",value:function(e,t){this.canvas.width===e&&this.canvas.height===t||(this.canvas.width=e,this.canvas.height=t)}},{key:"draw",value:function(e){this.ctx&&this.ctx.drawImage(e,0,0,this.canvas.width,this.canvas.height)}},{key:"dispose",value:function(){this.ctx=null,this.canvas.width=0,this.canvas.height=0}}])}(),xi=function(){return p(function e(){c(this,e),this.listeners=new Map},[{key:"on",value:function(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)}},{key:"once",value:function(e,t){var n=this,r=function(){t.apply(void 0,arguments),n.off(e,r)};this.on(e,r)}},{key:"off",value:function(e,t){var n;null===(n=this.listeners.get(e))||void 0===n||n.delete(t)}},{key:"emit",value:function(e){var t=this.listeners.get(e);if(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];var o,a=y(t);try{for(a.s();!(o=a.n()).done;){var s=o.value;try{s.apply(void 0,r)}catch(t){console.error("EventEmitter '".concat(e,"' listener error"),t)}}}catch(e){a.e(e)}finally{a.f()}}}},{key:"clear",value:function(e){e?this.listeners.delete(e):this.listeners.clear()}}])}(),Ri=function(e){function t(e){var n,r;return c(this,t),(r=s(this,t)).sockets={video:null,audio:null,touch:null},r.subscribers={video:new Set,audio:new Set,touch:new Set},r.deviceId=e.deviceId,r.ip=e.ip,r.ports=null!==(n=e.ports)&&void 0!==n?n:{},r}return b(t,e),p(t,[{key:"getUrl",value:function(e){var t=this.ports[e];return"ws://".concat(this.ip,":").concat(t)}},{key:"getChannelStatus",value:function(e){var t=this.sockets[e];if(!t)return"disconnected";switch(t.readyState){case WebSocket.CONNECTING:return"connecting";case WebSocket.OPEN:return"connected";case WebSocket.CLOSING:case WebSocket.CLOSED:default:return"disconnected"}}},{key:"getAllChannelsStatus",value:function(){return{video:this.getChannelStatus("video"),audio:this.getChannelStatus("audio"),touch:this.getChannelStatus("touch")}}},{key:"emitChannelStatus",value:function(e,t){var n=this.getAllChannelsStatus();this.emit(t,e,n)}},{key:"ensureChannel",value:function(e){var t=this;if(this.sockets[e]){var n=this.sockets[e].readyState;if(n===WebSocket.OPEN||n===WebSocket.CONNECTING)return;this.sockets[e]=null}var r=new WebSocket(this.getUrl(e));r.binaryType="arraybuffer",r.onopen=function(){console.log("[".concat(t.deviceId,":").concat(e,"] connected")),t.emitChannelStatus(e,"open")},r.onmessage=function(n){try{var r,i=y(t.subscribers[e]);try{for(i.s();!(r=i.n()).done;){(0,r.value)(n.data)}}catch(e){i.e(e)}finally{i.f()}}catch(n){console.error("[".concat(t.deviceId,":").concat(e,"] message error"),n)}},r.onerror=function(n){console.error("[".concat(t.deviceId,":").concat(e,"] error"),n),t.emit("error",e,n)},r.onclose=function(n){console.warn("[".concat(t.deviceId,":").concat(e,"] closed"),n),t.sockets[e]=null,t.emit("close",e,n)},this.sockets[e]=r}},{key:"subscribe",value:function(e,t){this.subscribers[e].add(t),this.sockets[e]||this.ensureChannel(e)}},{key:"unsubscribe",value:function(e,t){var n;(t?this.subscribers[e].delete(t):this.subscribers[e].clear(),0===this.subscribers[e].size)&&(console.log("[".concat(this.deviceId,":").concat(e,"] no subscribers, closing")),null===(n=this.sockets[e])||void 0===n||n.close(),this.sockets[e]=null)}},{key:"send",value:function(e,t){var n=this.sockets[e];if(n&&n.readyState===WebSocket.OPEN)try{t instanceof ArrayBuffer||t instanceof Uint8Array?n.send(t):n.send(JSON.stringify(t))}catch(t){console.error("[".concat(e,"] send error"),t)}}},{key:"sendTouch",value:function(e){this.send("touch",e)}},{key:"destroy",value:function(){var e=this;["video","audio","touch"].forEach(function(t){console.log("[".concat(e.deviceId,":").concat(t,"] destroying"));var n=e.sockets[t];n&&(n.onopen=null,n.onmessage=null,n.onerror=null,n.onclose=null,n.close(),e.sockets[t]=null),e.subscribers[t].clear()}),this.clear()}}])}(xi),Ai="focus",Ti="blur",_i="input",Mi="delete",Ii="enter",Ni="arrow-up",Di="arrow-down",Pi="arrow-left",Wi="arrow-right",Li=function(){return p(function e(t){c(this,e),this.emitter=new xi,this.isComposing=!1,this.el=document.createElement("textarea"),this.el.style.cssText="\n position:absolute;\n top:0;\n left:0;\n pointer-events:none;\n opacity:0.01;\n width:100%;\n max-width:95%;\n height: 40px;\n resize: none;\n overflow: hidden;\n ",this.el.autocomplete="off",t.appendChild(this.el),this.bindEvents()},[{key:"on",value:function(e,t){var n;null===(n=this.emitter)||void 0===n||n.on(e,t)}},{key:"off",value:function(e,t){var n;null===(n=this.emitter)||void 0===n||n.off(e,t)}},{key:"bindEvents",value:function(){var e=this;this.el.addEventListener("focus",function(){var t;return null===(t=e.emitter)||void 0===t?void 0:t.emit(Ai)}),this.el.addEventListener("blur",function(){var t;return null===(t=e.emitter)||void 0===t?void 0:t.emit(Ti)}),this.el.addEventListener("compositionstart",function(){e.isComposing=!0}),this.el.addEventListener("compositionend",function(t){var n;e.isComposing=!1;var r=t.target;null===(n=e.emitter)||void 0===n||n.emit(_i,r.value),e.el.value=""}),this.el.addEventListener("input",function(t){var n;if(!e.isComposing){var r=t.target;null===(n=e.emitter)||void 0===n||n.emit(_i,r.value),e.el.value=""}}),this.el.addEventListener("keydown",function(t){var n,r,i,o,a,s;switch(t.key){case"Backspace":case"Delete":null===(n=e.emitter)||void 0===n||n.emit(Mi);break;case"Enter":null===(r=e.emitter)||void 0===r||r.emit(Ii),e.el.blur();break;case"ArrowUp":null===(i=e.emitter)||void 0===i||i.emit(Ni);break;case"ArrowDown":null===(o=e.emitter)||void 0===o||o.emit(Di);break;case"ArrowLeft":null===(a=e.emitter)||void 0===a||a.emit(Pi);break;case"ArrowRight":null===(s=e.emitter)||void 0===s||s.emit(Wi)}})}},{key:"focus",value:function(){this.el.focus()}},{key:"blur",value:function(){this.el.blur()}},{key:"moveTo",value:function(e,t,n){this.el.style.left="".concat(e,"px"),this.el.style.top="".concat(t,"px"),n&&(this.el.style.width="".concat(n,"px"))}},{key:"destroy",value:function(){var e;null===(e=this.emitter)||void 0===e||e.clear(),this.emitter=null,this.el.remove()}}])}(),Vi={AndroidHome:3,AndroidBack:4,AndroidCall:5,AndroidEndCall:6,Digit0:7,Digit1:8,Digit2:9,Digit3:10,Digit4:11,Digit5:12,Digit6:13,Digit7:14,Digit8:15,Digit9:16,Star:17,Pound:18,ArrowUp:19,ArrowDown:20,ArrowLeft:21,ArrowRight:22,AndroidDPadCenter:23,VolumeUp:24,VolumeDown:25,Power:26,AndroidCamera:27,Clear:28,KeyA:29,KeyB:30,KeyC:31,KeyD:32,KeyE:33,KeyF:34,KeyG:35,KeyH:36,KeyI:37,KeyJ:38,KeyK:39,KeyL:40,KeyM:41,KeyN:42,KeyO:43,KeyP:44,KeyQ:45,KeyR:46,KeyS:47,KeyT:48,KeyU:49,KeyV:50,KeyW:51,KeyX:52,KeyY:53,KeyZ:54,Comma:55,Period:56,AltLeft:57,AltRight:58,ShiftLeft:59,ShiftRight:60,Tab:61,Space:62,AndroidSymbol:63,AndroidExplorer:64,AndroidEnvelope:65,Enter:66,Backspace:67,Backquote:68,Minus:69,Equal:70,BracketLeft:71,BracketRight:72,Backslash:73,Semicolon:74,Quote:75,Slash:76,At:77,AndroidNum:78,AndroidHeadsetHook:79,AndroidFocus:80,Plus:81,ContextMenu:82,AndroidNotification:83,AndroidSearch:84,PageUp:92,PageDown:93,Escape:111,Delete:112,ControlLeft:113,ControlRight:114,CapsLock:115,ScrollLock:116,MetaLeft:117,MetaRight:118,AndroidFunction:119,PrintScreen:120,Pause:121,Home:122,End:123,Insert:124,AndroidForward:125,F1:131,F2:132,F3:133,F4:134,F5:135,F6:136,F7:137,F8:138,F9:139,F10:140,F11:141,F12:142,NumLock:143,Numpad0:144,Numpad1:145,Numpad2:146,Numpad3:147,Numpad4:148,Numpad5:149,Numpad6:150,Numpad7:151,Numpad8:152,Numpad9:153,NumpadDivide:154,NumpadMultiply:155,NumpadSubtract:156,NumpadAdd:157,NumpadDecimal:158,NumpadComma:159,NumpadEnter:160,NumpadEquals:161,NumpadLeftParen:162,NumpadRightParen:163,VolumeMute:164,AndroidAppSwitch:187,AndroidCut:277,AndroidCopy:278,AndroidPaste:279};Object.fromEntries(Object.entries(Vi).map(function(e){var t=A(e,2),n=t[0];return[t[1],n]}));var Ui,Bi,ji={Down:0,Up:1},Fi={Down:0,Up:1,Move:2,Cancel:3,Outside:4,PointerDown:5,PointerUp:6,HoverMove:7,Scroll:8,HoverEnter:9,HoverExit:10,ButtonPress:11,ButtonRelease:12},Gi={None:0,Primary:1,Secondary:2,Tertiary:4,Back:8,Forward:16,StylusPrimary:32,StylusSecondary:64};function zi(e,t,n){return e.setUint16(t,n),t+2}function Hi(e,t,n){return e.setUint32(t,n),t+4}function Ki(e,t,n){return e.setInt32(t,n),t+4}function qi(e,t,n){var r=Math.round(n/16*32767);return e.setInt16(t,r),t+2}function Xi(e,t,n){return e.setUint8(t,n),t+1}function Yi(e,t,n){return e.setBigInt64(t,n),t+8}!function(e){e[e.injectKeyCode=0]="injectKeyCode",e[e.injectText=1]="injectText",e[e.injectTouchEvent=2]="injectTouchEvent",e[e.injectScrollEvent=3]="injectScrollEvent",e[e.backOrScreenOn=4]="backOrScreenOn",e[e.expandNotificationPanel=5]="expandNotificationPanel",e[e.expandSettingsPanel=6]="expandSettingsPanel",e[e.collapsePanels=7]="collapsePanels",e[e.getClipboard=8]="getClipboard",e[e.setClipboard=9]="setClipboard",e[e.setDisplayPower=10]="setDisplayPower",e[e.rotateDevice=11]="rotateDevice",e[e.uhidCreate=12]="uhidCreate",e[e.uhidInput=13]="uhidInput",e[e.uhidDestroy=14]="uhidDestroy",e[e.openHardKeyboardSettings=15]="openHardKeyboardSettings",e[e.startApp=16]="startApp",e[e.resetVideo=17]="resetVideo"}(Ui||(Ui={})),function(e){e[e.Clipboard=0]="Clipboard",e[e.AckClipboard=1]="AckClipboard",e[e.UhidOutput=2]="UhidOutput"}(Bi||(Bi={}));var Ji=function(){return p(function e(){c(this,e)},null,[{key:"injectKeyCode",value:function(e){var t=e.action,n=e.keyCode,r=e.repeat,i=void 0===r?0:r,o=e.metaState,a=void 0===o?0:o,s=new ArrayBuffer(14),u=new DataView(s),c=0;return c=Xi(u,c,Ui.injectKeyCode),c=Ki(u,c=Xi(u,c,t),n),c=Ki(u,c,i),c=Ki(u,c,a),new Uint8Array(s)}},{key:"injectText",value:function(e){var t=e.text,n=this.encoder.encode(t),r=new ArrayBuffer(5+n.length),i=new DataView(r),o=0;return o=Hi(i,o=Xi(i,o,Ui.injectText),n.length),new Uint8Array(r,o).set(n),new Uint8Array(r)}},{key:"injectTouch",value:function(e){var t=e.action,n=e.pointerId,r=e.pointerX,i=e.pointerY,o=e.screenWidth,a=e.screenHeight,s=e.pressure,u=e.actionButton,c=e.buttons,l=new ArrayBuffer(32),f=new DataView(l),h=0;return h=Xi(f,h,Ui.injectTouchEvent),h=Ki(f,h=Yi(f,h=Xi(f,h,t),BigInt(n)),r),h=zi(f,h=Ki(f,h,i),o),h=function(e,t,n){var r=65535*Math.max(0,Math.min(1,n));return e.setUint16(t,r),t+2}(f,h=zi(f,h,a),s),h=Ki(f,h,u),h=Ki(f,h,c),new Uint8Array(l)}},{key:"injectScroll",value:function(e){var t=e.pointerX,n=e.pointerY,r=e.screenWidth,i=e.screenHeight,o=e.scrollX,a=e.scrollY,s=e.buttons,u=new ArrayBuffer(21),c=new DataView(u),l=0;return l=Ki(c,l=Xi(c,l,Ui.injectScrollEvent),t),l=zi(c,l=Ki(c,l,n),r),l=qi(c,l=zi(c,l,i),o),l=Ki(c,l=qi(c,l,a),s),new Uint8Array(u)}},{key:"setClipboard",value:function(e){var t=e.sequence,n=e.text,r=e.paste,i=void 0!==r&&r,o=this.encoder.encode(n),a=new ArrayBuffer(14+o.length),s=new DataView(a),u=0;return u=Xi(s,u,Ui.setClipboard),u=Hi(s,u=Xi(s,u=Yi(s,u,BigInt(t)),i?1:0),o.length),new Uint8Array(a,u).set(o),new Uint8Array(a)}},{key:"resetVideo",value:function(){var e=new ArrayBuffer(1);return Xi(new DataView(e),0,Ui.resetVideo),new Uint8Array(e)}}])}();Ji.encoder=new TextEncoder;var Qi=function(){return p(function e(){c(this,e)},null,[{key:"parse",value:function(e){var t=new DataView(e instanceof Uint8Array?e.buffer:e,e instanceof Uint8Array?e.byteOffset:0,e.byteLength);if(t.byteLength<1)return null;var n=function(e,t){return e.getUint8(t)}(t,0);switch(n){case Bi.Clipboard:return this.parseClipboard(t);case Bi.AckClipboard:return this.parseAckClipboard(t);default:return null}}},{key:"parseClipboard",value:function(e){if(e.byteLength<5)return null;var t=function(e,t){return e.getUint32(t)}(e,1);if(e.byteLength<5+t)return null;var n=new Uint8Array(e.buffer,e.byteOffset+5,t),r=this.decoder.decode(n);return{type:Bi.Clipboard,content:r}}},{key:"parseAckClipboard",value:function(e){if(e.byteLength<9)return null;var t=function(e,t){return e.getBigInt64(t)}(e,1);return{type:Bi.AckClipboard,sequence:t}}}])}();function Zi(e,t,n){return Math.max(t,Math.min(n,e))}Qi.decoder=new TextDecoder;var $i,eo,to={SIZE_CHANGED:"size-changed",ERROR:"error",STARTED:"started",STOPPED:"stopped",CLIPBOARD_CHANGED:"clipboard-changed",CHANNEL_CONNECTED:"channel-connected",GROUP_CONTROL_JOINED:"group-control-joined",GROUP_CONTROL_LEAVE:"group-control-leave"};e.VmosEdgeErrorType=void 0,($i=e.VmosEdgeErrorType||(e.VmosEdgeErrorType={})).CONNECTION="connection",$i.VIDEO="video",$i.AUDIO="audio",$i.TOUCH="touch",$i.DECODER="decoder",$i.RENDERER="renderer",e.VmosEdgeErrorCode=void 0,(eo=e.VmosEdgeErrorCode||(e.VmosEdgeErrorCode={})).CONNECTION_FAILED="CONNECTION_FAILED",eo.CONNECTION_TIMEOUT="CONNECTION_TIMEOUT",eo.CONNECTION_LOST="CONNECTION_LOST",eo.VIDEO_CHANNEL_CONNECTION_FAILED="VIDEO_CHANNEL_CONNECTION_FAILED",eo.VIDEO_CHANNEL_CLOSED="VIDEO_CHANNEL_CLOSED",eo.VIDEO_STREAM_ERROR="VIDEO_STREAM_ERROR",eo.VIDEO_PIPELINE_ERROR="VIDEO_PIPELINE_ERROR",eo.AUDIO_CHANNEL_CONNECTION_FAILED="AUDIO_CHANNEL_CONNECTION_FAILED",eo.AUDIO_STREAM_ERROR="AUDIO_STREAM_ERROR",eo.TOUCH_CHANNEL_CONNECTION_FAILED="TOUCH_CHANNEL_CONNECTION_FAILED",eo.TOUCH_MESSAGE_PARSE_ERROR="TOUCH_MESSAGE_PARSE_ERROR",eo.DECODER_INIT_FAILED="DECODER_INIT_FAILED",eo.DECODER_ERROR="DECODER_ERROR",eo.RENDERER_INIT_FAILED="RENDERER_INIT_FAILED",eo.RENDERER_ERROR="RENDERER_ERROR",eo.UNKNOWN_ERROR="UNKNOWN_ERROR";function no(e,t){var n,r,i=!1,o=0,a=0;return new Ye({transform:function(s,u){var c=Date.now();if("configuration"===s.type)return r=s,void(i||u.enqueue(s));if(void 0!==s.pts)if(void 0===n)n=s.pts,o=c;else{var l=s.pts-n,f=c-(o+Number(l)/1e3),h=t();f<-1e3&&(n=s.pts,o=c),!i&&(f>5e3||h>14)&&(i=!0,console.warn("[PacketDropper] Entering drop mode: lag=".concat(f.toFixed(0),"ms, queue=").concat(h)))}if(i){if(c-a>1600&&(e(),a=c,console.log("[PacketDropper] Requested keyframe")),!s.keyframe)return;i=!1,n=s.pts,o=c,console.log("[PacketDropper] Recovered from drop mode: received keyframe"),r&&(u.enqueue(r),r=void 0)}u.enqueue(s)}})}var ro=function(t){function n(e){var t,r,i,o,a,u;return c(this,n),(u=s(this,n)).canvas=null,u.canvasContainer=null,u.device=null,u.isGroupControl=!1,u.deviceTouchGroupMap=new Map,u.config=null,u.renderer=null,u.videoCodecPreference="no-preference",u.renderPreference="default",u.decoder=null,u.textareaManager=null,u.videoWidth=0,u.videoHeight=0,u.isRunning=!1,u.rotation=0,u.manualRotation=!1,u.currentRotationAngle=0,u.resizeObserver=null,u.pointerMoveThrottleMap=new Map,u.touchMoveInterval=1e3/60,u.retryCount=0,u.maxRetries=0,u.retryInterval=1e3,u.stopVideoSubscription=null,u.container=e.container,u.config=e.config,u.device=new Ri(u.config),u.maxRetries=null!==(t=e.retryCount)&&void 0!==t?t:0,u.retryInterval=null!==(r=e.retryInterval)&&void 0!==r?r:1e3,u.isGroupControl=null!==(i=e.isGroupControl)&&void 0!==i&&i,u.videoCodecPreference=null!==(o=e.videoCodecPreference)&&void 0!==o?o:"no-preference",u.renderPreference=null!==(a=e.renderPreference)&&void 0!==a?a:"default",e.touchMoveFrequency&&(u.touchMoveInterval=1e3/e.touchMoveFrequency),u.initCanvas(),u.handlePointerEvent=u.handlePointerEvent.bind(u),u.handleWheelEvent=u.handleWheelEvent.bind(u),u.handleContextMenu=u.handleContextMenu.bind(u),u.initTextareaManager(),u.observeContainerResize(),u}return b(n,t),p(n,[{key:"setupChannelStatusListener",value:function(){var e,t,n=this;null===(e=this.device)||void 0===e||e.on("open",function(e,t){var r,i=null===(r=n.config)||void 0===r?void 0:r.ports[e];n.emit(to.CHANNEL_CONNECTED,{channel:e,port:i,allChannelsStatus:t}),"connected"===t.video&&"connected"===t.touch&&n.sendTouch(Ji.resetVideo())}),null===(t=this.device)||void 0===t||t.on("error",function(e,t){var r,i=n.extractErrorMessage(t);i||(i="WebSocket ".concat(e," channel connection failed"));var o=n.getErrorCodeForChannel(e,"connection_failed");n.emit(to.ERROR,{type:n.channelToErrorType(e),code:o,message:i,port:null===(r=n.config)||void 0===r?void 0:r.ports[e]})})}},{key:"extractErrorMessage",value:function(e){if(e instanceof Error)return e.message||e.toString();if(e instanceof Event)return"".concat(e.type||"unknown");if("string"==typeof e)return e;if(e&&"object"===I(e))return e.message||e.reason||String(e);var t=String(e);return"[object Object]"===t||"[object Event]"===t?"":t}},{key:"channelToErrorType",value:function(t){switch(t){case"video":return e.VmosEdgeErrorType.VIDEO;case"audio":return e.VmosEdgeErrorType.AUDIO;case"touch":return e.VmosEdgeErrorType.TOUCH;default:return e.VmosEdgeErrorType.CONNECTION}}},{key:"getErrorCodeForChannel",value:function(t,n){if("video"===t)switch(n){case"connection_failed":return e.VmosEdgeErrorCode.VIDEO_CHANNEL_CONNECTION_FAILED;case"connection_closed":return e.VmosEdgeErrorCode.VIDEO_CHANNEL_CLOSED;default:return e.VmosEdgeErrorCode.VIDEO_STREAM_ERROR}else{if("audio"===t)return"connection_failed"===n?e.VmosEdgeErrorCode.AUDIO_CHANNEL_CONNECTION_FAILED:e.VmosEdgeErrorCode.AUDIO_STREAM_ERROR;switch(n){case"connection_failed":default:return e.VmosEdgeErrorCode.TOUCH_CHANNEL_CONNECTION_FAILED;case"parse_error":return e.VmosEdgeErrorCode.TOUCH_MESSAGE_PARSE_ERROR}}}},{key:"initCanvas",value:function(){this.canvasContainer=document.createElement("div"),this.canvasContainer.className="vmos-canvas-container",this.container.appendChild(this.canvasContainer),this.canvas=document.createElement("canvas"),this.applyCanvasStyle(this.canvas),this.canvasContainer.appendChild(this.canvas),this.container.appendChild(this.canvasContainer)}},{key:"replaceCanvas",value:function(){var e;this.canvas&&this.canvasContainer&&this.canvasContainer.removeChild(this.canvas),this.canvas=document.createElement("canvas"),this.applyCanvasStyle(this.canvas),null===(e=this.canvasContainer)||void 0===e||e.appendChild(this.canvas)}},{key:"applyCanvasStyle",value:function(e){e.style.width="100%",e.style.height="100%",e.style.outline="none",e.style.userSelect="none",e.style.backgroundColor="transparent",e.style.touchAction="none"}},{key:"initTextareaManager",value:function(){var e=this;this.textareaManager=new Li(this.container),this.textareaManager.on(_i,function(t){e.sendText(t)}),this.textareaManager.on(Mi,function(){e.sendKeyCode(Vi.Backspace,ji.Down),e.sendKeyCode(Vi.Backspace,ji.Up)}),this.textareaManager.on(Ii,function(){e.sendKeyCode(Vi.Enter,ji.Down),e.sendKeyCode(Vi.Enter,ji.Up)}),this.textareaManager.on(Ni,function(){e.sendKeyCode(Vi.ArrowUp,ji.Down),e.sendKeyCode(Vi.ArrowUp,ji.Up)}),this.textareaManager.on(Di,function(){e.sendKeyCode(Vi.ArrowDown,ji.Down),e.sendKeyCode(Vi.ArrowDown,ji.Up)}),this.textareaManager.on(Pi,function(){e.sendKeyCode(Vi.ArrowLeft,ji.Down),e.sendKeyCode(Vi.ArrowLeft,ji.Up)}),this.textareaManager.on(Wi,function(){e.sendKeyCode(Vi.ArrowRight,ji.Down),e.sendKeyCode(Vi.ArrowRight,ji.Up)})}},{key:"observeContainerResize",value:function(){var e=this;"undefined"!=typeof ResizeObserver&&(this.resizeObserver=new ResizeObserver(function(){e.updateCanvasSize()}),this.resizeObserver.observe(this.container))}},{key:"on",value:function(e,t){return T(n,"on",this)([e,t]),this}},{key:"once",value:function(e,t){return T(n,"once",this)([e,t]),this}},{key:"off",value:function(e,t){return t?T(n,"off",this)([e,t]):T(n,"clear",this)([e]),this}},{key:"emit",value:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];T(n,"emit",this)([e].concat(r))}},{key:"start",value:(u=o(S().m(function e(){return S().w(function(e){for(;;)switch(e.p=e.n){case 0:if(!this.isRunning){e.n=1;break}return e.a(2);case 1:return this.isRunning=!0,this.retryCount=0,e.p=2,e.n=3,this.connectWithRetry();case 3:this.setupChannelStatusListener(),e.n=5;break;case 4:e.p=4,e.v;case 5:return e.a(2)}},e,this,[[2,4]])})),function(){return u.apply(this,arguments)})},{key:"connectWithRetry",value:(a=o(S().m(function t(){var n=this;return S().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t,r){var i=function(){var a=o(S().m(function o(){var a,s,u;return S().w(function(o){for(;;)switch(o.p=o.n){case 0:return o.p=0,o.n=1,n.internalStart();case 1:t(),o.n=4;break;case 2:if(o.p=2,u=o.v,n.isRunning){o.n=3;break}return console.log("[VmosEdgeClient] Connection stopped by user during handshake/start."),o.a(2);case 3:console.error("[VmosEdgeClient] Connection failed (Attempt ".concat(n.retryCount+1,"/").concat(n.maxRetries+1,"):"),u),n.retryCount<n.maxRetries&&n.isRunning?(n.retryCount++,a=Math.min(n.retryInterval*Math.pow(2,n.retryCount-1),1e4),console.log("[VmosEdgeClient] Retrying in ".concat(a,"ms...")),setTimeout(function(){n.isRunning?i():r(new Error("Stopped"))},a)):(s=n.extractErrorMessage(u)||"连接失败",n.emit(to.ERROR,{type:e.VmosEdgeErrorType.CONNECTION,code:e.VmosEdgeErrorCode.CONNECTION_FAILED,message:s}),n.stop(),r(u));case 4:return o.a(2)}},o,null,[[0,2]])}));return function(){return a.apply(this,arguments)}}();i()}))},t)})),function(){return a.apply(this,arguments)})},{key:"internalStart",value:(i=o(S().m(function t(){var n,r,i,o,a,s,u,c,l,f,h,d,v=this;return S().w(function(t){for(;;)switch(t.p=t.n){case 0:return this.canvas&&this.canvasContainer||this.initCanvas(),this.stopVideoSubscription&&(this.stopVideoSubscription(),this.stopVideoSubscription=null),n=new En({sendFrameMeta:!0,sendCodecMeta:!0,sendDeviceMeta:!0}),r=null,i=null,t.p=1,o=this.createVideoStream(),a=o.videoStream,s=o.stopVideoSubscription,r=s,t.n=2,this.performHandshake(n,a);case 2:u=t.v,c=u.metadata,l=u.stream,i=this.setupTouch(),this.createRenderer(),this.decoder=new yi({codec:c.codec,renderer:this.renderer,hardwareAcceleration:this.videoCodecPreference}),this.decoder.sizeChanged(function(e){var t=e.width,n=e.height,r=v.videoWidth,i=v.videoHeight;if(t!==r||n!==i){v.videoWidth=t,v.videoHeight=n;var o=t>n;0!==r&&0!==i&&r>i!==o&&(v.manualRotation=!1),v.manualRotation||(v.rotation=o?1:0),v.emitSizeChanged()}}),l.pipeThrough(n.createMediaStreamTransformer()).pipeThrough(no(function(){v.sendTouch(Ji.resetVideo())},function(){var e,t;return null!==(e=null===(t=v.decoder)||void 0===t?void 0:t.decodeQueueSize)&&void 0!==e?e:0})).pipeTo(this.decoder.writable).catch(function(t){var n,r;if(v.isRunning){console.error("[VmosEdgeClient] Video pipeline error:",t),null===(n=v.stopVideoSubscription)||void 0===n||n.call(v);var i=null===(r=v.config)||void 0===r?void 0:r.ports.video,o=v.extractErrorMessage(t)||"视频管道处理错误";v.emit(to.ERROR,{type:e.VmosEdgeErrorType.VIDEO,code:e.VmosEdgeErrorCode.VIDEO_PIPELINE_ERROR,message:o,port:i})}else console.log("[VmosEdgeClient] Video pipeline error: stopped by user during handshake/start.")}),this.bindInputEvents(),this.emit(to.STARTED),t.n=4;break;case 3:throw t.p=3,d=t.v,null===(f=r)||void 0===f||f(),null===(h=i)||void 0===h||h(),d;case 4:return t.a(2)}},t,this,[[1,3]])})),function(){return i.apply(this,arguments)})},{key:"createVideoStream",value:function(){var t,n,r=this,i=new ReadableStream({start:function(e){n=e},cancel:function(){var e;null===(e=r.stopVideoSubscription)||void 0===e||e.call(r)}}),o=function(t){var i;if(null!==n.desiredSize)try{var o=t instanceof Uint8Array?t:new Uint8Array(t);n.enqueue(o)}catch(t){var a;null===(a=r.stopVideoSubscription)||void 0===a||a.call(r);var s=r.extractErrorMessage(t)||"视频流数据处理错误";r.emit(to.ERROR,{type:e.VmosEdgeErrorType.VIDEO,code:e.VmosEdgeErrorCode.VIDEO_STREAM_ERROR,message:s})}else null===(i=r.stopVideoSubscription)||void 0===i||i.call(r)};return null===(t=this.device)||void 0===t||t.subscribe("video",o),this.stopVideoSubscription=function(){var e;null===(e=r.device)||void 0===e||e.unsubscribe("video",o),r.stopVideoSubscription=null;try{n&&null!==n.desiredSize&&n.close()}catch(e){if(e instanceof TypeError)return;console.error("[VmosEdgeClient] stopVideoSubscription error:",e)}},{videoStream:i,stopVideoSubscription:this.stopVideoSubscription}}},{key:"setupTouch",value:function(){var e,t=this,n=function(e){try{var n,r=Qi.parse(e);if((null==r?void 0:r.type)===Bi.Clipboard)t.emit(to.CLIPBOARD_CHANGED,null!==(n=null==r?void 0:r.content)&&void 0!==n?n:"")}catch(e){console.error("[VmosEdgeClient] Touch channel error:",e)}};return null===(e=this.device)||void 0===e||e.subscribe("touch",n),function(){var e;return null===(e=t.device)||void 0===e?void 0:e.unsubscribe("touch",n)}}},{key:"performHandshake",value:(r=o(S().m(function e(t,n){var r,i,o=this;return S().w(function(e){for(;;)switch(e.p=e.n){case 0:return r=null,i=new Promise(function(e,t){var n,i,a=!1,s=function(e){a||(a=!0,t(e))},u=function(e,t){console.error("[VmosEdgeClient] Handshake error on ".concat(e,":"),t),"video"===e&&s(new Error("Video channel connection failed"))},c=function(e){"video"===e&&s(new Error("Video channel closed unexpectedly during handshake"))};null===(n=o.device)||void 0===n||n.on("error",u),null===(i=o.device)||void 0===i||i.on("close",c),r=function(){var e,t;null===(e=o.device)||void 0===e||e.off("error",u),null===(t=o.device)||void 0===t||t.off("close",c)}}),e.p=1,e.n=2,Promise.race([t.parseVideoStreamMetadata(n),i]);case 2:return e.a(2,e.v);case 3:return e.p=3,r&&r(),e.f(3);case 4:return e.a(2)}},e,null,[[1,,3,4]])})),function(e,t){return r.apply(this,arguments)})},{key:"setGroupControlMode",value:function(e){if(this.isGroupControl=e,!e){var t,n=y(this.deviceTouchGroupMap.values());try{for(n.s();!(t=n.n()).done;){t.value.destroy()}}catch(e){n.e(e)}finally{n.f()}this.deviceTouchGroupMap.clear()}}},{key:"joinGroupControl",value:function(e){var t=this;if(this.isGroupControl){console.log("[VmosEdgeClient] joinGroupControl start",e);var n,r=y(e);try{var i=function(){var e=n.value;if(!e.deviceId)return 0;if(t.deviceTouchGroupMap.has(e.deviceId))return 0;var r=new Ri(e);r.subscribe("touch",function(){}),r.on("open",function(){t.emit(to.GROUP_CONTROL_JOINED,e)}),r.on("close",function(){r.destroy(),t.deviceTouchGroupMap.delete(e.deviceId),t.emit(to.GROUP_CONTROL_LEAVE,e)}),t.deviceTouchGroupMap.set(e.deviceId,r)};for(r.s();!(n=r.n()).done;)i()}catch(e){r.e(e)}finally{r.f()}}}},{key:"leaveGroupControl",value:function(e){if(this.isGroupControl){var t,n=y(e);try{for(n.s();!(t=n.n()).done;){var r,i=t.value;i.deviceId&&(this.deviceTouchGroupMap.has(i.deviceId)&&(null===(r=this.deviceTouchGroupMap.get(i.deviceId))||void 0===r||r.destroy(),this.deviceTouchGroupMap.delete(i.deviceId)))}}catch(e){n.e(e)}finally{n.f()}}}},{key:"stop",value:function(){var e,t;if(this.isRunning){if(this.isRunning=!1,null===(e=this.stopVideoSubscription)||void 0===e||e.call(this),this.unbindInputEvents(),this.emit(to.STOPPED),this.isGroupControl){var n,r=y(this.deviceTouchGroupMap.values());try{for(r.s();!(n=r.n()).done;){n.value.destroy()}}catch(e){r.e(e)}finally{r.f()}this.deviceTouchGroupMap.clear()}if(this.clear(),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.canvasContainer&&this.canvasContainer.parentNode&&(this.canvasContainer.parentNode.removeChild(this.canvasContainer),this.canvasContainer=null,this.canvas=null),null===(t=this.device)||void 0===t||t.destroy(),this.renderer){try{this.renderer.dispose()}catch(e){console.warn("[VmosEdgeClient] Renderer dispose error:",e)}this.renderer=null}if(this.decoder){try{var i,o;null===(i=this.decoder)||void 0===i||null===(o=i.dispose)||void 0===o||o.call(i)}catch(e){console.warn("[VmosEdgeClient] Decoder dispose error:",e)}this.decoder=null}}}},{key:"emitSizeChanged",value:function(){var e=this.updateCanvasSize(),t={idealWidth:e.idealWidth,idealHeight:e.idealHeight,videoWidth:e.videoWidth,videoHeight:e.videoHeight,rotation:this.rotation};this.emit(to.SIZE_CHANGED,t)}},{key:"mapCoordinates",value:function(e,t){var n,r;switch(this.currentRotationAngle){case 90:n=t*this.videoWidth,r=(1-e)*this.videoHeight;break;case 270:n=(1-t)*this.videoWidth,r=e*this.videoHeight;break;default:n=e*this.videoWidth,r=t*this.videoHeight}return{x:n,y:r}}},{key:"updateCanvasSize",value:function(){if(!this.canvasContainer||!this.videoWidth||!this.videoHeight)return{idealWidth:0,idealHeight:0,videoWidth:0,videoHeight:0};var e,t,n=this.container,r=n.clientWidth,i=n.clientHeight,o=this.videoWidth,a=this.videoHeight,s=this.rotation,u=r,c=i,l=Math.max(u,c),f=Math.min(u,c);1===s?(e=l,t=f):(e=f,t=l);var h=Math.min(r/e,i/t,1),d=e*h,v=t*h,p=o>a,y=0,m=90===(y=1===s?p?0:270:p?90:0)||270===y,w=m?a:o,g=m?o:a,b=Math.min(d/w,v/g),E=w*b,k=g*b,C=this.canvasContainer.style;C.width="".concat(Math.ceil(E),"px"),C.height="".concat(Math.ceil(k),"px"),C.display="block",C.position="relative",C.transform="none";var S=this.canvas,O=S.style;S.width!==o&&(S.width=o),S.height!==a&&(S.height=a);var x=m?k:E,R=m?E:k;O.width="".concat(Math.ceil(x),"px"),O.height="".concat(Math.ceil(R),"px"),O.position="absolute",O.top="50%",O.left="50%",O.transformOrigin="center center",O.transform="translate(-50%, -50%) rotate(".concat(y,"deg)"),this.currentRotationAngle=y;var A=Math.min(e/w,t/g);return{idealWidth:w*A,idealHeight:g*A,videoWidth:o,videoHeight:a}}},{key:"createRenderer",value:function(){try{if(!Si.isSupported)throw new Error("WebGL not supported check");console.log("[VmosEdgeClient] Using WebGLVideoFrameRenderer"),this.renderer=new Si(this.canvas,this.renderPreference)}catch(e){console.warn("[VmosEdgeClient] WebGL initialization failed, falling back to Canvas2DRenderer:",e),this.replaceCanvas(),this.renderer=new Oi(this.canvas)}}},{key:"bindInputEvents",value:function(){var e,t,n,r,i,o,a;null===(e=this.canvas)||void 0===e||e.addEventListener("pointerdown",this.handlePointerEvent),null===(t=this.canvas)||void 0===t||t.addEventListener("pointermove",this.handlePointerEvent),null===(n=this.canvas)||void 0===n||n.addEventListener("pointerup",this.handlePointerEvent),null===(r=this.canvas)||void 0===r||r.addEventListener("pointercancel",this.handlePointerEvent),null===(i=this.canvas)||void 0===i||i.addEventListener("pointerleave",this.handlePointerEvent),null===(o=this.canvas)||void 0===o||o.addEventListener("wheel",this.handleWheelEvent,{passive:!1}),null===(a=this.canvas)||void 0===a||a.addEventListener("contextmenu",this.handleContextMenu)}},{key:"unbindInputEvents",value:function(){var e,t,n,r,i,o,a;null===(e=this.canvas)||void 0===e||e.removeEventListener("pointerdown",this.handlePointerEvent),null===(t=this.canvas)||void 0===t||t.removeEventListener("pointermove",this.handlePointerEvent),null===(n=this.canvas)||void 0===n||n.removeEventListener("pointerup",this.handlePointerEvent),null===(r=this.canvas)||void 0===r||r.removeEventListener("pointercancel",this.handlePointerEvent),null===(i=this.canvas)||void 0===i||i.removeEventListener("pointerleave",this.handlePointerEvent),null===(o=this.canvas)||void 0===o||o.removeEventListener("wheel",this.handleWheelEvent),null===(a=this.canvas)||void 0===a||a.removeEventListener("contextmenu",this.handleContextMenu)}},{key:"handleContextMenu",value:function(e){e.preventDefault(),e.stopPropagation()}},{key:"handlePointerEvent",value:function(e){var t;if(this.videoWidth&&this.videoHeight){e.preventDefault(),e.stopPropagation();var r,i=this.canvas,o=e.type,a=e.clientX,s=e.clientY,u=e.button,c=e.buttons,l=e.pointerId;if("pointermove"===o){var f=Date.now();if(f-(this.pointerMoveThrottleMap.get(l)||0)<this.touchMoveInterval)return;this.pointerMoveThrottleMap.set(l,f)}if("pointerdown"===o){if(2===u)return void this.back();if(1===u)return void this.home()}else if("pointerup"===o){if(2===u||1===u)return}else if("pointermove"===o&&(2&c||4&c))return;switch(o){case"pointerdown":r=Fi.Down,i.setPointerCapture(l),null===(t=this.textareaManager)||void 0===t||t.focus();break;case"pointermove":if(0===c)return;r=Fi.Move;break;case"pointerup":case"pointercancel":case"pointerleave":r=Fi.Up,i.releasePointerCapture(l),this.pointerMoveThrottleMap.delete(l);break;default:return}var h=i.getBoundingClientRect(),d=Zi((a-h.x)/h.width,0,1),v=Zi((s-h.y)/h.height,0,1),p=this.mapCoordinates(d,v),y=p.x,m=p.y,w=Ji.injectTouch({action:r,pointerId:BigInt(l),pointerX:y,pointerY:m,screenWidth:this.videoWidth,screenHeight:this.videoHeight,pressure:0===c?0:1,actionButton:n.PointerEventButtonToAndroidButton[u]||Gi.Primary,buttons:c});this.sendTouch(w)}}},{key:"sendTouch",value:function(e){var t;if(null===(t=this.device)||void 0===t||t.sendTouch(e),this.isGroupControl){var n,r=y(this.deviceTouchGroupMap.values());try{for(r.s();!(n=r.n()).done;){n.value.sendTouch(e)}}catch(e){r.e(e)}finally{r.f()}}}},{key:"handleWheelEvent",value:function(e){if(this.videoWidth&&this.videoHeight&&this.device){e.preventDefault(),e.stopPropagation();var t=this.canvas.getBoundingClientRect(),n=Zi((e.clientX-t.x)/t.width,0,1),r=Zi((e.clientY-t.y)/t.height,0,1),i=this.mapCoordinates(n,r),o=i.x,a=i.y,s=Ji.injectScroll({pointerX:o,pointerY:a,screenWidth:this.videoWidth,screenHeight:this.videoHeight,scrollX:-e.deltaX,scrollY:-e.deltaY,buttons:0});this.sendTouch(s)}}},{key:"sendText",value:function(e){this.device&&this.sendTouch(Ji.injectText({text:e}))}},{key:"sendKeyCode",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this.device&&this.sendTouch(Ji.injectKeyCode({keyCode:e,action:t,repeat:0,metaState:n}))}},{key:"clickKey",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.sendKeyCode(e,ji.Down,t),this.sendKeyCode(e,ji.Up,t)}},{key:"volumeUp",value:function(){this.clickKey(Vi.VolumeUp)}},{key:"volumeDown",value:function(){this.clickKey(Vi.VolumeDown)}},{key:"home",value:function(){this.clickKey(Vi.AndroidHome)}},{key:"back",value:function(){this.clickKey(Vi.AndroidBack)}},{key:"menu",value:function(){this.clickKey(Vi.AndroidAppSwitch)}},{key:"setRotation",value:function(e){this.rotation!==e&&(this.manualRotation=!0,this.rotation=e,this.emitSizeChanged())}},{key:"getRotation",value:function(){return this.rotation}},{key:"getRunningState",value:function(){return this.isRunning}},{key:"getVideoSize",value:function(){return{width:this.videoWidth,height:this.videoHeight}}},{key:"getConfig",value:function(){return this.config?C({},this.config):null}},{key:"getScale",value:function(){return this.canvas&&this.videoWidth?this.canvas.getBoundingClientRect().width/this.videoWidth:1}}]);var r,i,a,u}(xi);return ro.PointerEventButtonToAndroidButton=[Gi.Primary,Gi.Tertiary,Gi.Secondary,Gi.Back,Gi.Forward],e.AndroidKeyCode=Vi,e.AndroidKeyEventAction=ji,e.AndroidMetaState={None:0,AltOn:2,AltLeftOn:16,AltRightOn:32,ShiftOn:1,ShiftLeftOn:64,ShiftRightOn:128,SymOn:4,FunctionOn:8,CtrlOn:4096,CtrlLeftOn:8192,CtrlRightOn:16384,MetaOn:65536,MetaLeftOn:131072,MetaRightOn:262144,CapsLockOn:1048576,NumLockOn:2097152,ScrollLockOn:4194304},e.AndroidMotionEventAction=Fi,e.AndroidMotionEventButton=Gi,e.VmosEdgeClient=ro,e.VmosEdgeClientEvents=to,e}({});
3
+ var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return x(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],f=!1,h={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function d(n,r){for(s=n,u=r,t=0;!f&&c&&!i&&t<l.length;t++){var i,o=l[t],d=h.p,v=o[2];n>3?(i=v===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=d&&((i=n<2&&d<o[1])?(s=0,h.v=r,h.n=o[1]):d<v&&(i=n<3||o[0]>r||r>v)&&(o[4]=n,o[5]=r,h.n=v,s=0))}if(i||n>1)return a;throw f=!0,r}return function(i,l,v){if(c>1)throw TypeError("Generator is already running");for(f&&1===l&&d(l,v),s=l,u=v;(t=s<2?e:u)||!f;){o||(s?s<3?(s>1&&(h.n=-1),d(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(f=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:f}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(x(t={},r,function(){return this}),t),f=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,x(e,i,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=c,x(f,"constructor",c),x(c,"constructor",u),u.displayName="GeneratorFunction",x(c,i,"GeneratorFunction"),x(f),x(f,i,"Generator"),x(f,r,function(){return this}),x(f,"toString",function(){return"[object Generator]"}),(S=function(){return{w:o,m:h}})()}function x(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}x=function(e,t,n,r){function o(t,n){x(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},x(e,t,n,r)}function O(e){if(null!=e){var t=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}throw new TypeError(typeof e+" is not iterable")}function R(e,t){return R=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},R(e,t)}function A(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],u=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);u=!0);}catch(e){c=!0,i=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(e,t)||N(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _(e,t,n,r){var i=w(g(e.prototype),t,n);return"function"==typeof i?function(e){return i.apply(n,e)}:i}function T(e){return function(e){if(Array.isArray(e))return n(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||N(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function M(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function I(e){return I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},I(e)}function N(e,t){if(e){if("string"==typeof e)return n(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}}function D(e){var n,r;function i(n,r){try{var a=e[n](r),s=a.value,u=s instanceof t;Promise.resolve(u?s.v:s).then(function(t){if(u){var r="return"===n?"return":"next";if(!s.k||t.done)return i(r,t);t=e[r](t).value}o(a.done?"return":"normal",t)},function(e){i("throw",e)})}catch(e){o("throw",e)}}function o(e,t){switch(e){case"return":n.resolve({value:t,done:!0});break;case"throw":n.reject(t);break;default:n.resolve({value:t,done:!1})}(n=n.next)?i(n.key,n.arg):r=null}this._invoke=function(e,t){return new Promise(function(o,a){var s={key:e,arg:t,resolve:o,reject:a,next:null};r?r=r.next=s:(n=r=s,i(e,t))})},"function"!=typeof e.return&&(this.return=void 0)}function P(e){var t="function"==typeof Map?new Map:void 0;return P=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(E())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var i=new(e.bind.apply(e,r));return n&&R(i,n.prototype),i}(e,arguments,g(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),R(n,e)},P(e)}var W;D.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},D.prototype.next=function(e){return this._invoke("next",e)},D.prototype.throw=function(e){return this._invoke("throw",e)},D.prototype.return=function(e){return this._invoke("return",e)};var L=function(){return p(function e(t,n,r,i){c(this,e),m(this,"optionValue",void 0),m(this,"metadataValue",void 0),m(this,"mimeType",void 0),m(this,"webCodecId",void 0),this.optionValue=t,this.metadataValue=n,this.mimeType=r,this.webCodecId=i},[{key:"toOptionValue",value:function(){return this.optionValue}}])}();m(L,"Opus",new(W=L)("opus",1869641075,"audio/opus","opus")),m(L,"Aac",new W("aac",6381923,"audio/aac","mp4a.66")),m(L,"Flac",new W("flac",1718378851,"audio/flac","flac")),m(L,"Raw",new W("raw",7496055,"audio/raw",""));var V=0,U=1,B=2,j=3,F=4,G=5,z=6,H=7,K=8,q=9,X=10,Y=11,J=12,Q=13,Z=14,$=15,ee=16,te=17,ne=new WeakMap,re=new WeakSet,ie=function(){return p(function e(){c(this,e),d(this,re),f(this,ne,[])},[{key:"parsers",get:function(){return l(ne,this)}},{key:"add",value:function(e){if(Array.isArray(e.id)){var t,n=y(e.id);try{for(n.s();!(t=n.n()).done;){var i=t.value;r(re,this,oe).call(this,i,e)}}catch(e){n.e(e)}finally{n.f()}}else r(re,this,oe).call(this,e.id,e);return e}},{key:"parse",value:(e=o(S().m(function e(t,n){var r;return S().w(function(e){for(;;)switch(e.n){case 0:if(r=l(ne,this)[t]){e.n=1;break}throw new Error("Unknown device message id ".concat(t));case 1:return e.a(2,r.parse(t,n))}},e,this)})),function(t,n){return e.apply(this,arguments)})},{key:"close",value:function(){var e,t=y(l(ne,this));try{for(t.s();!(e=t.n()).done;){e.value.close()}}catch(e){t.e(e)}finally{t.f()}}},{key:"error",value:function(e){var t,n=y(l(ne,this));try{for(n.s();!(t=n.n()).done;){t.value.error(e)}}catch(e){n.e(e)}finally{n.f()}}}]);var e}();function oe(e,t){if(l(ne,this)[e])throw new Error("Duplicate parser for id ".concat(e));l(ne,this)[e]=t}function ae(e,t){if(function(e){return"object"===I(e)&&null!==e&&"toOptionValue"in e&&"function"==typeof e.toOptionValue}(e)&&(e=e.toOptionValue()),void 0===e)return t;if("string"!=typeof e&&"number"!=typeof e&&"boolean"!=typeof e)throw new TypeError("Invalid option value: ".concat(JSON.stringify(e)));return e.toString()}var se=1748121140,ue=1748121141,ce=6387249,le=new WeakMap,fe=new WeakMap,he=new WeakMap,de=new WeakMap,ve=function(){return p(function e(){var t=this;c(this,e),f(this,le,void 0),f(this,fe,void 0),f(this,he,void 0),f(this,de,"running"),m(this,"resolve",function(e){l(fe,t).call(t,e),h(de,t,"resolved")}),m(this,"reject",function(e){l(he,t).call(t,e),h(de,t,"rejected")}),h(le,this,new Promise(function(e,n){h(fe,t,e),h(he,t,n)}))},[{key:"promise",get:function(){return l(le,this)}},{key:"state",get:function(){return l(de,this)}}])}();function pe(e){return"object"===I(e)&&null!==e&&"then"in e}function ye(e,t){for(;;){var n=e.next(t),r=n.done,i=n.value;if(r)return i;if(pe(i))return i.then(function(t){return ye(e,{resolved:t})},function(t){return ye(e,{error:t})});t=i}}function me(e,t){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return ye(e.call.apply(e,[this,S().m(function e(t){var n;return S().w(function(e){for(;;)switch(e.n){case 0:if(!pe(t)){e.n=3;break}return e.n=1,t;case 1:if(!("resolved"in(n=e.v))){e.n=2;break}return e.a(2,n.resolved);case 2:throw n.error;case 3:return e.a(2,t)}},e)})].concat(n)),void 0)}}function we(e,t){return function(n,r){var i;if("buffer"in r)return null!==(i=r.index)&&void 0!==i||(r.index=0),t(n,r),e;var o=new Uint8Array(e);return t(n,{buffer:o,index:0,littleEndian:r.littleEndian}),o}}var ge=function(e,t,n,r,i){var o,a={size:e,type:t,serialize:"default"===t?(o=n,function(e,t){if("buffer"in t){var n=o(e,t);return t.buffer.set(n,t.index),n.length}return o(e,t)}):we(e,n),deserialize:me(r),omitInit:null==i?void 0:i.omitInit};return null!=i&&i.init&&(a.init=i.init),a},be=new Uint8Array(0);function Ee(e,t){var n,r,i,o,a,s,u,c,l;return"number"==typeof e?(0===e?(n=function(){},r=t?S().m(function e(){return S().w(function(e){for(;;)if(0===e.n)return e.a(2,t.convert(be))},e)}):S().m(function e(){return S().w(function(e){for(;;)if(0===e.n)return e.a(2,be)},e)})):(n=function(t,n){return function(e,t,n,r){t.length<r?(e.set(t,n),e.fill(0,n+t.length,n+r)):t.length===r?e.set(t,n):e.set(t.subarray(0,r),n)}(n.buffer,t,n.index,e)},t?(r=S().m(function n(r,i){var o,a;return S().w(function(n){for(;;)switch(n.n){case 0:return o=i.readExactly(e),a=t,n.d(O(r(o)),1);case 1:return n.a(2,a.convert.call(a,n.v))}},n)}),i=function(e){return t.back(e)}):r=S().m(function t(n,r){var i;return S().w(function(t){for(;;)if(0===t.n)return i=r.readExactly(e),t.a(2,i)},t)})),ge(e,"byob",n,r,{init:i})):"object"!==I(e)&&"function"!=typeof e||!("serialize"in e)?"string"==typeof e?(t?(s=function(n,r,i){var o=i.dependencies;return S().m(function i(){var a,s,u;return S().w(function(i){for(;;)switch(i.n){case 0:return a=o[e],s=0!==a?r.readExactly(a):be,u=t,i.d(O(n(s)),1);case 1:return i.a(2,u.convert.call(u,i.v))}},i)})()},u=function(n,r){var i=t.back(n);return r[e]=i.length,i}):(s=function(t,n,r){var i=r.dependencies;return S().m(function t(){var r,o;return S().w(function(t){for(;;)if(0===t.n)return r=i[e],o=0!==r?n.readExactly(r):be,t.a(2,o)},t)})()},u=function(t,n){var r=t;return n[e]=r.length,r}),ge(0,"default",function(e){return e},s,{init:u})):(t?(c=function(n,r,i){var o=i.dependencies;return S().m(function i(){var a,s,u,c;return S().w(function(i){for(;;)switch(i.n){case 0:return a=o[e.field],s=e.convert(a),u=0!==s?r.readExactly(s):be,c=t,i.d(O(n(u)),1);case 1:return i.a(2,c.convert.call(c,i.v))}},i)})()},l=function(n,r){var i=t.back(n);return r[e.field]=e.back(i.length),i}):(c=function(t,n,r){var i=r.dependencies;return S().m(function t(){var r,o,a;return S().w(function(t){for(;;)if(0===t.n)return r=i[e.field],o=e.convert(r),a=0!==o?n.readExactly(o):be,t.a(2,a)},t)})()},l=function(t,n){var r=t;return n[e.field]=e.back(r.length),r}),ge(0,"default",function(e){return e},c,{init:l})):(t?(o=S().m(function n(r,i,o){var a,s,u;return S().w(function(n){for(;;)switch(n.n){case 0:return n.d(O(r(e.deserialize(i,o))),1);case 1:return a=n.v,s=0!==a?i.readExactly(a):be,u=t,n.d(O(r(s)),2);case 2:return n.a(2,u.convert.call(u,n.v))}},n)}),a=function(e){return t.back(e)}):o=S().m(function t(n,r,i){var o,a;return S().w(function(t){for(;;)switch(t.n){case 0:return t.d(O(n(e.deserialize(r,i))),1);case 1:return o=t.v,a=0!==o?r.readExactly(o):be,t.a(2,a)}},t)}),ge(e.size,"default",function(t,n){var r=n.littleEndian;if("default"===e.type){var i=e.serialize(t.length,{littleEndian:r});if(0===t.length)return i;var o=new Uint8Array(i.length+t.length);return o.set(i,0),o.set(t,i.length),o}var a=new Uint8Array(e.size+t.length);return e.serialize(t.length,{buffer:a,index:0,littleEndian:r}),a.set(t,e.size),a},o,{init:a}))}var ke=function(e){function t(){return c(this,t),s(this,t,["ExactReadable ended"])}return b(t,e),p(t)}(P(Error)),Ce=function(e){function t(e){return c(this,t),s(this,t,[e])}return b(t,e),p(t)}(P(Error)),Se=function(e){function t(){return c(this,t),s(this,t,["The underlying readable was ended before the struct was fully deserialized"])}return b(t,e),p(t)}(Ce),xe=function(e){function t(){return c(this,t),s(this,t,["The underlying readable doesn't contain any more struct"])}return b(t,e),p(t)}(Ce);function Oe(e,t){for(var n=Object.entries(e),r=0,i=!0,o=0,a=n;o<a.length;o++){var s=A(a[o],2)[1];r+=s.size,i&&"byob"!==s.type&&(i=!1)}var u=t.littleEndian,c=t.extra?Object.getOwnPropertyDescriptors(t.extra):void 0;return{littleEndian:u,fields:e,extra:t.extra,type:i?"byob":"default",size:r,serialize:function(e,t){for(var r=C({},e),i=0,o=n;i<o.length;i++){var a=A(o[i],2),s=a[0],c=a[1];if(s in r&&"init"in c){var l,f=null===(l=c.init)||void 0===l?void 0:l.call(c,r[s],r);r[s]=f}}var h,d=new Array(n.length),v=new Array(n.length),p={littleEndian:u},m=y(n.entries());try{for(m.s();!(h=m.n()).done;){var w=A(h.value,2),g=w[0],b=A(w[1],2),E=b[0],k=b[1];"byob"===k.type?d[g]=k.size:(v[g]=k.serialize(r[E],p),d[g]=v[g].length)}}catch(e){m.e(e)}finally{m.f()}var S,x,O,R=d.reduce(function(e,t){return e+t},0);if(t instanceof Uint8Array){if(t.length<R)throw new Error("Buffer too small");S=!0,x=t,O=0}else if("object"===I(t)&&"buffer"in t){var _;if(S=!0,x=t.buffer,O=null!==(_=t.index)&&void 0!==_?_:0,x.length-O<R)throw new Error("Buffer too small")}else S=!1,x=new Uint8Array(R),O=0;var T,M={buffer:x,index:O,littleEndian:u},N=y(n.entries());try{for(N.s();!(T=N.n()).done;){var D=A(T.value,2),P=D[0],W=A(D[1],2),L=W[0],V=W[1];v[P]?x.set(v[P],M.index):V.serialize(r[L],M),M.index+=d[P]}}catch(e){N.e(e)}finally{N.f()}return S?R:x},deserialize:me(S().m(function e(r,i){var o,a,s,l,f,h,d,v,p;return S().w(function(e){for(;;)switch(e.p=e.n){case 0:o=i.position,s={dependencies:a={},littleEndian:u},e.p=1,l=0,f=n;case 2:if(!(l<f.length)){e.n=5;break}return h=A(f[l],2),d=h[0],v=h[1],e.d(O(r(v.deserialize(i,s))),3);case 3:a[d]=e.v;case 4:l++,e.n=2;break;case 5:e.n=9;break;case 6:if(e.p=6,(p=e.v)instanceof ke){e.n=7;break}throw p;case 7:if(i.position!==o){e.n=8;break}throw new xe;case 8:throw new Se;case 9:if(c&&Object.defineProperties(a,c),!t.postDeserialize){e.n=10;break}return e.a(2,t.postDeserialize.call(a,a));case 10:return e.a(2,a);case 11:return e.a(2)}},e,null,[[1,6]])}))}}function Re(e,t,n){return n?(e[t]|e[t+1]<<8)<<16>>16:(e[t]<<8|e[t+1])<<16>>16}function Ae(e,t,n){return n?e[t]|e[t+1]<<8:e[t+1]|e[t]<<8}function _e(e,t,n,r){r?(e[t]=n,e[t+1]=n>>8):(e[t]=n>>8,e[t+1]=n)}function Te(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function Me(e,t,n){return n?(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0:(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function Ie(e,t,n){return n?BigInt(e[t])|BigInt(e[t+1])<<8n|BigInt(e[t+2])<<16n|BigInt(e[t+3])<<24n|BigInt(e[t+4])<<32n|BigInt(e[t+5])<<40n|BigInt(e[t+6])<<48n|BigInt(e[t+7])<<56n:BigInt(e[t])<<56n|BigInt(e[t+1])<<48n|BigInt(e[t+2])<<40n|BigInt(e[t+3])<<32n|BigInt(e[t+4])<<24n|BigInt(e[t+5])<<16n|BigInt(e[t+6])<<8n|BigInt(e[t+7])}function Ne(e,t,n){var r=function(){return r};return Object.assign(r,ge(e,"byob",t,n)),r}var De=Ne(1,function(e,t){t.buffer[t.index]=e},S().m(function e(t,n){var r;return S().w(function(e){for(;;)switch(e.n){case 0:return e.d(O(t(n.readExactly(1))),1);case 1:return r=e.v,e.a(2,r[0])}},e)})),Pe=Ne(2,function(e,t){_e(t.buffer,t.index,e,t.littleEndian)},function(e,t,n){var r=n.littleEndian;return S().m(function n(){var i;return S().w(function(n){for(;;)switch(n.n){case 0:return n.d(O(e(t.readExactly(2))),1);case 1:return i=n.v,n.a(2,Ae(i,0,r))}},n)})()}),We=Ne(4,function(e,t){!function(e,t,n,r){r?(e[t]=n,e[t+1]=n>>8,e[t+2]=n>>16,e[t+3]=n>>24):(e[t]=n>>24,e[t+1]=n>>16,e[t+2]=n>>8,e[t+3]=n)}(t.buffer,t.index,e,t.littleEndian)},function(e,t,n){var r=n.littleEndian;return S().m(function n(){var i;return S().w(function(n){for(;;)switch(n.n){case 0:return n.d(O(e(t.readExactly(4))),1);case 1:return i=n.v,n.a(2,Me(i,0,r))}},n)})()}),Le=Ne(8,function(e,t){!function(e,t,n,r){r?(e[t]=Number(0xffn&n),e[t+1]=Number(n>>8n&0xffn),e[t+2]=Number(n>>16n&0xffn),e[t+3]=Number(n>>24n&0xffn),e[t+4]=Number(n>>32n&0xffn),e[t+5]=Number(n>>40n&0xffn),e[t+6]=Number(n>>48n&0xffn),e[t+7]=Number(n>>56n&0xffn)):(e[t]=Number(n>>56n&0xffn),e[t+1]=Number(n>>48n&0xffn),e[t+2]=Number(n>>40n&0xffn),e[t+3]=Number(n>>32n&0xffn),e[t+4]=Number(n>>24n&0xffn),e[t+5]=Number(n>>16n&0xffn),e[t+6]=Number(n>>8n&0xffn),e[t+7]=Number(0xffn&n))}(t.buffer,t.index,e,t.littleEndian)},function(e,t,n){var r=n.littleEndian;return S().m(function n(){var i;return S().w(function(n){for(;;)switch(n.n){case 0:return n.d(O(e(t.readExactly(8))),1);case 1:return i=n.v,n.a(2,Ie(i,0,r))}},n)})()}),Ve=globalThis.TextEncoder,Ue=globalThis.TextDecoder,Be=new Ve,je=new Ue;function Fe(e){return Be.encode(e)}function Ge(e){return je.decode(e)}var ze=function(e){var t=Ee(e,{convert:Ge,back:Fe});return t.as=function(){return t},t},He=Oe({type:De},{littleEndian:!1}),Ke=globalThis.AbortController,qe=function(){var e=globalThis.ReadableStream;return e.from||(e.from=function(t){var n=Symbol.asyncIterator in t?t[Symbol.asyncIterator]():t[Symbol.iterator]();return new e({pull:function(e){return o(S().m(function t(){var r;return S().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,n.next();case 1:if(!(r=t.v).done){t.n=2;break}return e.close(),t.a(2);case 2:e.enqueue(r.value);case 3:return t.a(2)}},t)}))()},cancel:function(e){return o(S().m(function t(){var r;return S().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,null===(r=n.return)||void 0===r?void 0:r.call(n,e);case 1:return t.a(2)}},t)}))()}})}),e.prototype[Symbol.asyncIterator]&&e.prototype.values||(e.prototype.values=function(){var e,t=(e=S().m(function e(t){var n,r,i,o;return S().w(function(e){for(;;)switch(e.p=e.n){case 0:n=this.getReader(),e.p=1;case 2:return e.n=3,a(n.read());case 3:if(r=e.v,i=r.done,o=r.value,!i){e.n=4;break}return e.a(2);case 4:return e.n=5,o;case 5:e.n=2;break;case 6:if(e.p=6,null!=t&&t.preventCancel){e.n=7;break}return e.n=7,a(n.cancel());case 7:return n.releaseLock(),e.f(6);case 8:return e.a(2)}},e,this,[[1,,6,8]])}),function(){return new D(e.apply(this,arguments))});return function(e){return t.apply(this,arguments)}}(),e.prototype[Symbol.asyncIterator]=e.prototype.values),e}(),Xe=globalThis.WritableStream,Ye=globalThis.TransformStream,Je=function(e){function t(e,n,r){var i;c(this,t);var a=!1,u=new Ke;return s(this,t,[{start:function(t){var n,s=e({abortSignal:u.signal,enqueue:(n=o(S().m(function e(n){return S().w(function(e){for(;;)switch(e.n){case 0:if(null==r||r({source:"producer",operation:"enqueue",value:n,phase:"start"}),!u.signal.aborted){e.n=1;break}return null==r||r({source:"producer",operation:"enqueue",value:n,phase:"ignored"}),e.a(2);case 1:if(null!==t.desiredSize){e.n=2;break}return t.enqueue(n),e.a(2);case 2:if(!a){e.n=3;break}return a=!1,t.enqueue(n),null==r||r({source:"producer",operation:"enqueue",value:n,phase:"complete"}),e.a(2);case 3:if(!(t.desiredSize<=0)){e.n=5;break}return null==r||r({source:"producer",operation:"enqueue",value:n,phase:"waiting"}),i=new ve,e.n=4,i.promise;case 4:if(!u.signal.aborted){e.n=5;break}return null==r||r({source:"producer",operation:"enqueue",value:n,phase:"ignored"}),e.a(2);case 5:t.enqueue(n),null==r||r({source:"producer",operation:"enqueue",value:n,phase:"complete"});case 6:return e.a(2)}},e)})),function(e){return n.apply(this,arguments)}),close:function(){null==r||r({source:"producer",operation:"close",explicit:!0,phase:"start"}),u.signal.aborted?null==r||r({source:"producer",operation:"close",explicit:!0,phase:"ignored"}):(t.close(),null==r||r({source:"producer",operation:"close",explicit:!0,phase:"complete"}))},error:function(e){null==r||r({source:"producer",operation:"error",explicit:!0,phase:"start"}),t.error(e),null==r||r({source:"producer",operation:"error",explicit:!0,phase:"complete"})}});s&&"then"in s&&s.then(function(){null==r||r({source:"producer",operation:"close",explicit:!1,phase:"start"});try{t.close(),null==r||r({source:"producer",operation:"close",explicit:!1,phase:"complete"})}catch(e){null==r||r({source:"producer",operation:"close",explicit:!1,phase:"ignored"})}},function(e){null==r||r({source:"producer",operation:"error",explicit:!1,phase:"start"}),t.error(e),null==r||r({source:"producer",operation:"error",explicit:!1,phase:"complete"})})},pull:function(){null==r||r({source:"consumer",operation:"pull",phase:"start"}),i?i.resolve():0===(null==n?void 0:n.highWaterMark)&&(a=!0),null==r||r({source:"consumer",operation:"pull",phase:"complete"})},cancel:function(e){var t;null==r||r({source:"consumer",operation:"cancel",phase:"start"}),u.abort(e),null===(t=i)||void 0===t||t.resolve(),null==r||r({source:"consumer",operation:"cancel",phase:"complete"})}},n])}return b(t,e),p(t)}(qe);function Qe(e){return Ze.apply(this,arguments)}function Ze(){return(Ze=o(S().m(function e(t){return S().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,t.cancel();case 1:return e.a(2,!0);case 2:return e.p=2,e.v,e.a(2,!1)}},e,null,[[0,2]])}))).apply(this,arguments)}var $e=new WeakMap,et=new WeakMap,tt=new WeakMap,nt=new WeakMap,rt=new WeakSet,it=function(){return p(function e(t){c(this,e),d(this,rt),f(this,$e,void 0),f(this,et,0),f(this,tt,0),f(this,nt,0),m(this,"stream",void 0),m(this,"reader",void 0),m(this,"readExactly",me(S().m(function e(t,n){var i,o,a,s;return S().w(function(e){for(;;)switch(e.n){case 0:if(o=0,!(a=r(rt,this,ot).call(this,n))){e.n=2;break}if(a.length!==n){e.n=1;break}return e.a(2,a);case 1:(i=new Uint8Array(n)).set(a,o),o+=a.length,n-=a.length,e.n=3;break;case 2:i=new Uint8Array(n);case 3:if(!(n>0)){e.n=5;break}return e.d(O(t(r(rt,this,at).call(this,n))),4);case 4:s=e.v,i.set(s,o),o+=s.length,n-=s.length,e.n=3;break;case 5:return e.a(2,i)}},e,this)}))),this.stream=t,this.reader=t.getReader()},[{key:"position",get:function(){return l(nt,this)}},{key:"iterateExactly",value:function(e){var t=this,n=l($e,this)?0:1;return{next:function(){switch(n){case 0:var i=r(rt,t,ot).call(t,e);return i.length===e?n=2:(e-=i.length,n=1),{done:!1,value:i};case 1:return n=3,{done:!1,value:r(rt,t,at).call(t,e).then(function(t){return t.length===e?n=2:(e-=t.length,n=1),t})};case 2:return{done:!0,value:void 0};case 3:throw new Error("Can't call `next` before previous Promise resolves");default:throw new Error("unreachable")}}}}},{key:"release",value:function(){var e=this;return l(tt,this)>0?new Je(function(){var t=o(S().m(function t(n){var r,i,o,a;return S().w(function(t){for(;;)switch(t.n){case 0:return r=l($e,e).subarray(l(et,e)),t.n=1,n.enqueue(r);case 1:n.abortSignal.addEventListener("abort",function(){Qe(e.reader)});case 2:return t.n=3,e.reader.read();case 3:if(i=t.v,o=i.done,a=i.value,!o){t.n=4;break}return t.a(2);case 4:return t.n=5,n.enqueue(a);case 5:t.n=2;break;case 6:return t.a(2)}},t)}));return function(e){return t.apply(this,arguments)}}()):(this.reader.releaseLock(),this.stream)}},{key:"cancel",value:(e=o(S().m(function e(t){return S().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,this.reader.cancel(t);case 1:return e.a(2)}},e,this)})),function(t){return e.apply(this,arguments)})}]);var e}();function ot(e){if(l($e,this)){var t=l($e,this).subarray(l(et,this),l(et,this)+e);return l(tt,this)>e?(h(nt,this,l(nt,this)+e),h(et,this,l(et,this)+e),h(tt,this,l(tt,this)-e),t):(h(nt,this,l(nt,this)+l(tt,this)),h($e,this,void 0),h(et,this,0),h(tt,this,0),t)}}function at(e){return st.apply(this,arguments)}function st(){return(st=o(S().m(function e(t){var n,r,i;return S().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,this.reader.read();case 1:if(n=e.v,r=n.done,i=n.value,!r){e.n=2;break}throw new ke;case 2:if(!(i.length>t)){e.n=3;break}return h($e,this,i),h(et,this,t),h(tt,this,i.length-t),h(nt,this,l(nt,this)+t),e.a(2,i.subarray(0,t));case 3:return h(nt,this,l(nt,this)+i.length),e.a(2,i)}},e,this)}))).apply(this,arguments)}var ut=new WeakMap,ct=new WeakMap,lt=function(e){function t(e){return c(this,t),s(this,t,[function(t){return e.deserialize(t)}])}return b(t,e),p(t)}(function(){return p(function e(t){var n,r;c(this,e),f(this,ut,void 0),f(this,ct,void 0);var i=new it(new Je(function(e){n=e}));h(ut,this,new qe({pull:function(e){return o(S().m(function n(){var r,o;return S().w(function(n){for(;;)switch(n.p=n.n){case 0:return n.p=0,n.n=1,t(i);case 1:r=n.v,e.enqueue(r),n.n=4;break;case 2:if(n.p=2,!((o=n.v)instanceof xe)){n.n=3;break}return e.close(),n.a(2);case 3:throw o;case 4:return n.a(2)}},n,null,[[0,2]])}))()},cancel:function(e){return r.error(e)}})),h(ct,this,new Xe({start:function(e){r=e},write:function(e){return o(S().m(function t(){return S().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,n.enqueue(e);case 1:return t.a(2)}},t)}))()},abort:function(){n.close()},close:function(){n.close()}}))},[{key:"readable",get:function(){return l(ut,this)}},{key:"writable",get:function(){return l(ct,this)}}])}()),ft=He,ht=Oe({content:ze(We)},{littleEndian:!1}),dt=new WeakMap,vt=function(e){function t(){var e,n;return c(this,t),f(e=s(this,t,[function(e){n=e}]),dt,void 0),m(e,"id",0),h(dt,e,n),e}return b(t,e),p(t,[{key:"parse",value:(n=o(S().m(function e(t,n){var r;return S().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,ht.deserialize(n);case 1:return r=e.v,e.n=2,l(dt,this).enqueue(r.content);case 2:return e.a(2)}},e,this)})),function(e,t){return n.apply(this,arguments)})},{key:"close",value:function(){l(dt,this).close()}},{key:"error",value:function(e){l(dt,this).error(e)}}]);var n}(Je),pt=function(){return[V,U,B,j,F,G,H,K,q,X,Y]}();var yt={repeatPreviousFrameAfter:"long",maxPtsGapToEncoder:"long"},mt=function(){return p(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};c(this,e),m(this,"options",void 0);for(var n=0,r=Object.entries(t);n<r.length;n++){var i=A(r[n],2),o=i[0],a=i[1];if(void 0!==a&&"number"!=typeof a)throw new Error("Invalid option value for ".concat(o,": ").concat(String(a)))}this.options=t},[{key:"toOptionValue",value:function(){var e=Object.entries(this.options).filter(function(e){return void 0!==A(e,2)[1]});if(0!==e.length)return e.map(function(e){var t=A(e,2),n=t[0],r=t[1],i=n.replace(/([A-Z])/g,"-$1").toLowerCase(),o=yt[n];return o&&(i+=":".concat(o)),i+="=".concat(r)}).join(",")}}])}();m(mt,"Empty",new mt);var wt={logLevel:"debug",maxSize:0,bitRate:8e6,maxFps:0,lockVideoOrientation:-1,tunnelForward:!1,crop:void 0,sendFrameMeta:!0,control:!0,displayId:0,showTouches:!1,stayAwake:!1,codecOptions:void 0};function gt(e,t,n){return e<t?t:e>n?n:e}function bt(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return Object.fromEntries(Object.entries(e).filter(function(e){var t=A(e,1)[0];return!n.includes(t)}))}var Et=ge(2,"byob",function(e,t){var n=t.buffer,r=t.index,i=t.littleEndian;_e(n,r,e=1===(e=gt(e,-1,1))?65535:65536*e,i)},function(e,t,n){var r=n.littleEndian;return S().m(function n(){var i,o;return S().w(function(n){for(;;)switch(n.n){case 0:return n.d(O(e(t.readExactly(2))),1);case 1:return i=n.v,o=Ae(i,0,r),n.a(2,65535===o?1:o/65536)}},n)})()}),kt=Oe({pts:Le,data:Ee(We)},{littleEndian:!1}),Ct=1n<<63n;function St(e,t){return xt.apply(this,arguments)}function xt(){return xt=o(S().m(function e(t,n){var r;return S().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,t.readExactly(n);case 1:return r=e.v,e.a(2,Ge(r.subarray(0,r.indexOf(0))))}},e)})),xt.apply(this,arguments)}function Ot(e){return Rt.apply(this,arguments)}function Rt(){return Rt=o(S().m(function e(t){var n;return S().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,t.readExactly(4);case 1:return n=e.v,e.a(2,Te(n,0))}},e)})),Rt.apply(this,arguments)}var At,_t,Tt=function(){return C(C({},wt),{},{encoderName:void 0})}(),Mt=(At=ft,_t={action:De()},Oe(Object.assign({},At.fields,_t),{littleEndian:At.littleEndian,extra:At.extra,postDeserialize:void 0}));var It=function(){var e=pt.slice();return e.splice(6,0,z),e}(),Nt=-1,Dt=function(){return C(C({},Tt),{},{logLevel:"debug",lockVideoOrientation:Nt,powerOffOnClose:!1})}(),Pt=function(){return C(C({},Dt),{},{clipboardAutosync:!0})}();function Wt(e){return e.replace(/([A-Z])/g,"_$1").toLowerCase()}var Lt=Oe({sequence:Le},{littleEndian:!1}),Vt=Oe({type:De,sequence:Le,paste:De(),content:ze(We)},{littleEndian:!1}),Ut=new WeakMap,Bt=new WeakMap,jt=function(){return p(function e(){c(this,e),f(this,Ut,new Map),f(this,Bt,!1),m(this,"id",1)},[{key:"parse",value:(e=o(S().m(function e(t,n){var r,i;return S().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,Lt.deserialize(n);case 1:r=e.v,(i=l(Ut,this).get(r.sequence))&&(i.resolve(),l(Ut,this).delete(r.sequence));case 2:return e.a(2)}},e,this)})),function(t,n){return e.apply(this,arguments)})},{key:"close",value:function(){var e,t=y(l(Ut,this).values());try{for(t.s();!(e=t.n()).done;){e.value.reject()}}catch(e){t.e(e)}finally{t.f()}l(Ut,this).clear(),h(Bt,this,!0)}},{key:"error",value:function(e){var t,n=y(l(Ut,this).values());try{for(n.s();!(t=n.n()).done;){t.value.reject(e)}}catch(e){n.e(e)}finally{n.f()}l(Ut,this).clear(),h(Bt,this,!0)}},{key:"serializeSetClipboardControlMessage",value:function(e){if(0n===e.sequence)return Vt.serialize(e);if(l(Bt,this))throw new Error;var t=new ve;return l(Ut,this).set(e.sequence,t),[Vt.serialize(e),t.promise]}}]);var e}(),Ft=function(){return C(C({},Pt),{},{downsizeOnError:!0,sendDeviceMeta:!0,sendDummyByte:!0})}(),Gt=function(){return C(C({},Ft),{},{cleanup:!0})}(),zt=1n<<62n;var Ht=function(){return C(C({},Gt),{},{powerOn:!0})}(),Kt=ge(2,"byob",function(e,t){var n=t.buffer,r=t.index,i=t.littleEndian;!function(e,t,n,r){r?(e[t]=n,e[t+1]=n>>8):(e[t]=n>>8,e[t+1]=n)}(n,r,e=1===(e=gt(e,-1,1))?32767:32768*e,i)},function(e,t,n){var r=n.littleEndian;return S().m(function n(){var i,o;return S().w(function(n){for(;;)switch(n.n){case 0:return n.d(O(e(t.readExactly(2))),1);case 1:return i=n.v,o=Re(i,0,r),n.a(2,32767===o?1:o/32768)}},n)})()}),qt=function(){return Oe({type:De(j),pointerX:We,pointerY:We,videoWidth:Pe,videoHeight:Pe,scrollX:Kt,scrollY:Kt,buttons:We},{littleEndian:!1})}(),Xt=function(){return C(C({},bt(Ht,"bitRate","codecOptions","encoderName")),{},{scid:void 0,videoCodec:"h264",videoBitRate:8e6,videoCodecOptions:void 0,videoEncoder:void 0,audio:!0,audioCodec:"opus",audioBitRate:128e3,audioCodecOptions:void 0,audioEncoder:void 0,listEncoders:!1,listDisplays:!1,sendCodecMeta:!0})}(),Yt=function(){return Oe({type:De(B),action:De(),pointerId:Le,pointerX:We,pointerY:We,videoWidth:Pe,videoHeight:Pe,pressure:Et,actionButton:We,buttons:We},{littleEndian:!1})}();function Jt(){return Jt=o(S().m(function e(t,n){var r,i,a,s,u,c,l,f;return S().w(function(e){for(;;)switch(e.n){case 0:return r=new it(t),e.n=1,r.readExactly(4);case 1:i=e.v,a=Te(i,0),c=a,e.n=0===c?2:1===c?3:4;break;case 2:return e.a(2,{type:"disabled"});case 3:return e.a(2,{type:"errored"});case 4:if(!n.sendCodecMeta){e.n=11;break}l=a,e.n=l===L.Raw.metadataValue?5:l===L.Opus.metadataValue?6:l===L.Aac.metadataValue?7:l===L.Flac.metadataValue?8:9;break;case 5:return s=L.Raw,e.a(3,10);case 6:return s=L.Opus,e.a(3,10);case 7:return s=L.Aac,e.a(3,10);case 8:return s=L.Flac,e.a(3,10);case 9:case 16:throw new Error("Unknown audio codec metadata value: ".concat(a));case 10:return e.a(2,{type:"success",codec:s,stream:r.release()});case 11:f=n.audioCodec,e.n="raw"===f?12:"opus"===f?13:"aac"===f?14:"flac"===f?15:16;break;case 12:return u=L.Raw,e.a(3,17);case 13:return u=L.Opus,e.a(3,17);case 14:return u=L.Aac,e.a(3,17);case 15:return u=L.Flac,e.a(3,17);case 17:return e.a(2,{type:"success",codec:u,stream:new Je(function(){var e=o(S().m(function e(t){var n,o,a,s,u;return S().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,t.enqueue(i);case 1:n=r.release(),o=n.getReader();case 2:return e.n=3,o.read();case 3:if(a=e.v,s=a.done,u=a.value,!s){e.n=4;break}return e.a(3,6);case 4:return e.n=5,t.enqueue(u);case 5:e.n=2;break;case 6:return e.a(2)}},e)}));return function(t){return e.apply(this,arguments)}}())})}},e)})),Jt.apply(this,arguments)}function Qt(e){switch(e){case"h264":return se;case"h265":return ue;case"av1":return ce;default:throw new Error("Unknown video codec: ".concat(e))}}function Zt(){return(Zt=o(S().m(function e(t,n){var r,i,o,a,s;return S().w(function(e){for(;;)switch(e.n){case 0:if(r=new it(n),!t.sendDeviceMeta){e.n=2;break}return e.n=1,St(r,64);case 1:i=e.v;case 2:if(!t.sendCodecMeta){e.n=6;break}return e.n=3,Ot(r);case 3:return o=e.v,e.n=4,Ot(r);case 4:return a=e.v,e.n=5,Ot(r);case 5:s=e.v,e.n=7;break;case 6:o=Qt(t.videoCodec);case 7:return e.a(2,{stream:r.release(),metadata:{deviceName:i,codec:o,width:a,height:s}})}},e)}))).apply(this,arguments)}function $t(e,t){return e.sendDeviceMeta||e.sendCodecMeta?function(e,t){return Zt.apply(this,arguments)}(e,t):{stream:t,metadata:{codec:Qt(e.videoCodec)}}}var en=function(){return C(C({},Xt),{},{video:!0,audioSource:"output"})}(),tn=function(){return C(C({},en),{},{videoSource:"display",displayId:0,cameraId:void 0,cameraSize:void 0,cameraFacing:void 0,cameraAr:void 0,cameraFps:void 0,cameraHighSpeed:!1,listCameras:!1,listCameraSizes:!1})}();var nn=function(){return[].concat(T(It),[J,Q,$])}(),rn=Oe({id:Pe,data:Ee(Pe)},{littleEndian:!1}),on=new WeakMap,an=function(e){function t(){var e,n;return c(this,t),f(e=s(this,t,[function(e){n=e}]),on,void 0),m(e,"id",2),h(on,e,n),e}return b(t,e),p(t,[{key:"parse",value:(n=o(S().m(function e(t,n){var r;return S().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,rn.deserialize(n);case 1:return r=e.v,e.n=2,l(on,this).enqueue(r);case 2:return e.a(2)}},e,this)})),function(e,t){return n.apply(this,arguments)})},{key:"close",value:function(){l(on,this).close()}},{key:"error",value:function(e){l(on,this).error(e)}}]);var n}(Je),sn=function(){return C(C({},tn),{},{audioDup:!1})}(),un=function(){var e=nn.slice();return e.splice(14,0,Z),e}(),cn=function(){return[].concat(T(un),[ee,te])}(),ln=function(){return C(C({},bt(sn,"lockVideoOrientation")),{},{captureOrientation:void 0,angle:0,screenOffTimeout:void 0,listApps:!1,newDisplay:void 0,vdSystemDecorations:!0})}(),fn=/^\s+--(video|audio)-codec=(\S+)\s+--\1-encoder=(\S+)(?:\s*\((sw|hw|hybrid)\))?(?:\s*\[vendor\])?(?:\s*\(alias for (\S+)\))?$/;function hn(e){switch(e){case"sw":return"software";case"hw":return"hardware";case"hybrid":return"hybrid";default:throw new Error("Unknown hardware type: ".concat(e))}}var dn=function(){return C(C({},ln),{},{vdDestroyContent:!1})}(),vn=Oe({type:De,id:Pe,vendorId:Pe,productId:Pe,name:ze(De),data:Ee(Pe)},{littleEndian:!1});var pn=function(){return C(C({},dn),{},{displayImePolicy:void 0})}(),yn=function(){return p(function e(){c(this,e)},[{key:"serializeScrollMessage",value:function(e){return e=C(C({},e),{},{scrollX:e.scrollX/16,scrollY:e.scrollY/16}),qt.serialize(e)}}])}();var mn=new WeakMap,wn=new WeakMap,gn=new WeakMap,bn=new WeakMap,En=function(){return p(function e(t){c(this,e),m(this,"value",void 0),f(this,mn,void 0),f(this,wn,void 0),f(this,gn,void 0),f(this,bn,new ie),this.value=C(C({},pn),t),"camera"===this.value.videoSource&&(this.value.control=!1),this.value.audioDup&&(this.value.audioSource="playback"),this.value.control&&(this.value.clipboardAutosync&&(h(mn,this,l(bn,this).add(new vt)),h(wn,this,l(bn,this).add(new jt))),h(gn,this,l(bn,this).add(new an)))},[{key:"controlMessageTypes",get:function(){return cn}},{key:"clipboard",get:function(){return l(mn,this)}},{key:"uHidOutput",get:function(){return l(gn,this)}},{key:"deviceMessageParsers",get:function(){return l(bn,this)}},{key:"serialize",value:function(){return function(e,t){for(var n=[],r=0,i=Object.entries(e);r<i.length;r++){var o=A(i[r],2),a=o[0],s=ae(o[1],void 0);void 0!==s&&s!==ae(t[a],void 0)&&n.push("".concat(Wt(a),"=").concat(s))}return n}(this.value,pn)}},{key:"setListDisplays",value:function(){this.value.listDisplays=!0}},{key:"parseDisplay",value:function(e){return function(e){var t=e.match(/^\s+--display-id=(\d+)\s+\(([^)]+)\)$/);if(t){var n={id:Number.parseInt(t[1],10)};return"size unknown"!==t[2]&&(n.resolution=t[2]),n}}(e)}},{key:"setListEncoders",value:function(){this.value.listEncoders=!0}},{key:"parseEncoder",value:function(e){return function(e){var t=e.match(fn);return t?{type:t[1],name:t[3],codec:t[2],hardwareType:t[4]?hn(t[4]):void 0,vendor:!!t[5],aliasFor:t[6]}:void 0}(e)}},{key:"parseVideoStreamMetadata",value:function(e){return $t(this.value,e)}},{key:"parseAudioStreamMetadata",value:function(e){return function(e,t){return Jt.apply(this,arguments)}(e,this.value)}},{key:"createMediaStreamTransformer",value:function(){return function(e){if(!e.sendFrameMeta)return new Ye({transform:function(e,t){t.enqueue({type:"data",data:e})}});var t=new lt(kt);return{writable:t.writable,readable:t.readable.pipeThrough(new Ye({transform:function(e,t){e.pts!==Ct?e.pts&zt?t.enqueue({type:"data",keyframe:!0,pts:e.pts&~zt,data:e.data}):t.enqueue({type:"data",keyframe:!1,pts:e.pts,data:e.data}):t.enqueue({type:"configuration",data:e.data})}}))}}(this.value)}},{key:"serializeInjectTouchControlMessage",value:function(e){return function(e){return Yt.serialize(e)}(e)}},{key:"serializeBackOrScreenOnControlMessage",value:function(e){return function(e){return Mt.serialize(e)}(e)}},{key:"serializeSetClipboardControlMessage",value:function(e){return l(wn,this).serializeSetClipboardControlMessage(e)}},{key:"createScrollController",value:function(){return new yn}},{key:"serializeUHidCreateControlMessage",value:function(e){return function(e){return vn.serialize(e)}(e)}}])}();function kn(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}function Cn(e,t,n,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(e,n):i?i.value=n:t.set(e,n),n}function Sn(e){if(e%1!=0)throw new Error("Value must be an integer");if(e<0)throw new Error("Value must be positive");if(e>=256)throw new Error("Value must be less than 256");return e<16?"0"+e.toString(16).toUpperCase():e.toString(16).toUpperCase()}m(En,"Defaults",pn),"function"==typeof SuppressedError&&SuppressedError;var xn,On,Rn,An,_n,Tn,Mn,In,Nn,Dn,Pn,Wn,Ln=S().m(Vn);function Vn(e){var t,n,r,i,o,a,s;return S().w(function(u){for(;;)switch(u.n){case 0:t=-1,n=0,r=!1,i=0;case 1:if(!(i<e.length)){u.n=15;break}if(o=e[i],!r){u.n=3;break}if(!(o>3)){u.n=2;break}throw new Error("Invalid data");case 2:return r=!1,u.a(3,14);case 3:if(0!==o){u.n=4;break}return n+=1,u.a(3,14);case 4:if(a=n,n=0,-1!==t){u.n=6;break}if(!(a>=2&&1===o)){u.n=5;break}return t=i+1,u.a(3,14);case 5:throw new Error("Invalid data");case 6:if(!(a<2)){u.n=7;break}return u.a(3,14);case 7:if(1!==o){u.n=9;break}return u.n=8,e.subarray(t,i-a);case 8:return t=i+1,u.a(3,14);case 9:if(!(a>2)){u.n=10;break}throw new Error("Invalid data");case 10:s=o,u.n=2===s?11:3===s?12:13;break;case 11:throw new Error("Invalid data");case 12:return r=!0,u.a(3,14);case 13:return u.a(3,14);case 14:i+=1,u.n=1;break;case 15:if(!r){u.n=16;break}throw new Error("Invalid data");case 16:return u.n=17,e.subarray(t,e.length);case 17:return u.a(2)}},Ln)}var Un,Bn,jn,Fn,Gn=function(){return p(function e(t){c(this,e),xn.add(this),On.set(this,void 0),Rn.set(this,void 0),An.set(this,void 0),_n.set(this,0),Tn.set(this,0),Mn.set(this,7),In.set(this,0),Cn(this,On,t,"f");for(var n=t.length-1;n>=0;n-=1)if(0!==kn(this,On,"f")[n])for(var r=t[n],i=0;i<8;i+=1)if(1==(r>>i&1))return Cn(this,Rn,n,"f"),Cn(this,An,i,"f"),void kn(this,xn,"m",Nn).call(this);throw new Error("Stop bit not found")},[{key:"byteLength",get:function(){return kn(this,Rn,"f")}},{key:"stopBitIndex",get:function(){return kn(this,An,"f")}},{key:"bytePosition",get:function(){return kn(this,Tn,"f")}},{key:"bitPosition",get:function(){return kn(this,Mn,"f")}},{key:"ended",get:function(){return kn(this,Tn,"f")>=kn(this,Rn,"f")&&kn(this,Mn,"f")<=kn(this,An,"f")}},{key:"next",value:function(){if(this.ended)throw new Error("Bit index out of bounds");var e=kn(this,In,"f")>>kn(this,Mn,"f")&1;return Cn(this,Mn,kn(this,Mn,"f")-1,"f"),kn(this,Mn,"f")<0&&(Cn(this,Tn,kn(this,Tn,"f")+1,"f"),Cn(this,Mn,7,"f"),kn(this,xn,"m",Nn).call(this)),e}},{key:"read",value:function(e){if(e>32)throw new Error("Read length too large");for(var t=0,n=0;n<e;n+=1)t=t<<1|this.next();return t}},{key:"skip",value:function(e){if(e<=kn(this,Mn,"f")+1)return Cn(this,Mn,kn(this,Mn,"f")-e,"f"),void kn(this,xn,"m",Dn).call(this);for(e-=kn(this,Mn,"f")+1,Cn(this,Tn,kn(this,Tn,"f")+1,"f"),Cn(this,Mn,7,"f"),kn(this,xn,"m",Nn).call(this),kn(this,xn,"m",Dn).call(this);e>=8;e-=8)Cn(this,Tn,kn(this,Tn,"f")+1,"f"),kn(this,xn,"m",Nn).call(this),kn(this,xn,"m",Dn).call(this);Cn(this,Mn,7-e,"f"),kn(this,xn,"m",Dn).call(this)}},{key:"decodeExponentialGolombNumber",value:function(){for(var e=0;0===this.next();)e+=1;return 0===e?0:(1<<e|this.read(e))-1}},{key:"peek",value:function(e){var t=kn(this,xn,"m",Pn).call(this),n=this.read(e);return kn(this,xn,"m",Wn).call(this,t),n}},{key:"readBytes",value:function(e){for(var t=new Uint8Array(e),n=0;n<e;n+=1)t[n]=this.read(8);return t}},{key:"peekBytes",value:function(e){var t=kn(this,xn,"m",Pn).call(this),n=this.readBytes(e);return kn(this,xn,"m",Wn).call(this,t),n}}])}();function zn(e){var t=function(e){var t,n,r,i=y(Vn(e));try{for(i.s();!(r=i.n()).done;){var o=r.value;switch(31&o[0]){case 7:if(t=o,n)return{sequenceParameterSet:t,pictureParameterSet:n};break;case 8:if(n=o,t)return{sequenceParameterSet:t,pictureParameterSet:n}}}}catch(e){i.e(e)}finally{i.f()}throw new Error("Invalid data")}(e),n=t.sequenceParameterSet,r=t.pictureParameterSet,i=function(e){var t=new Gn(e);if(0!==t.next())throw new Error("Invalid data");var n=t.read(2);if(7!==t.read(5))throw new Error("Invalid data");if(0===n)throw new Error("Invalid data");var r=t.read(8),i=t.peek(8),o=!!t.next(),a=!!t.next(),s=!!t.next(),u=!!t.next(),c=!!t.next(),l=!!t.next();if(0!==t.read(2))throw new Error("Invalid data");var f=t.read(8),h=t.decodeExponentialGolombNumber();if(100===r||110===r||122===r||244===r||44===r||83===r||86===r||118===r||128===r||138===r||139===r||134===r){var d=t.decodeExponentialGolombNumber();if(3===d&&t.next(),t.decodeExponentialGolombNumber(),t.decodeExponentialGolombNumber(),t.next(),t.next())for(var v=[],p=0;p<(3!==d?8:12);p+=1)v[p]=!!t.next(),v[p]}t.decodeExponentialGolombNumber();var y=t.decodeExponentialGolombNumber();if(0===y)t.decodeExponentialGolombNumber();else if(1===y){t.next(),t.decodeExponentialGolombNumber(),t.decodeExponentialGolombNumber();for(var m=t.decodeExponentialGolombNumber(),w=[],g=0;g<m;g+=1)w[g]=t.decodeExponentialGolombNumber()}t.decodeExponentialGolombNumber(),t.next();var b=t.decodeExponentialGolombNumber(),E=t.decodeExponentialGolombNumber(),k=t.next();k||t.next(),t.next();var C,S,x,O,R=!!t.next();return R?(C=t.decodeExponentialGolombNumber(),S=t.decodeExponentialGolombNumber(),x=t.decodeExponentialGolombNumber(),O=t.decodeExponentialGolombNumber()):(C=0,S=0,x=0,O=0),t.next(),{profile_idc:r,constraint_set:i,constraint_set0_flag:o,constraint_set1_flag:a,constraint_set2_flag:s,constraint_set3_flag:u,constraint_set4_flag:c,constraint_set5_flag:l,level_idc:f,seq_parameter_set_id:h,pic_width_in_mbs_minus1:b,pic_height_in_map_units_minus1:E,frame_mbs_only_flag:k,frame_cropping_flag:R,frame_crop_left_offset:C,frame_crop_right_offset:S,frame_crop_top_offset:x,frame_crop_bottom_offset:O}}(n),o=i.profile_idc,a=i.constraint_set,s=i.level_idc,u=16*(i.pic_width_in_mbs_minus1+1),c=(i.pic_height_in_map_units_minus1+1)*(2-i.frame_mbs_only_flag)*16,l=2*i.frame_crop_left_offset,f=2*i.frame_crop_right_offset,h=2*i.frame_crop_top_offset,d=2*i.frame_crop_bottom_offset;return{pictureParameterSet:r,sequenceParameterSet:n,profileIndex:o,constraintSet:a,levelIndex:s,encodedWidth:u,encodedHeight:c,cropLeft:l,cropRight:f,cropTop:h,cropBottom:d,croppedWidth:u-l-f,croppedHeight:c-h-d}}function Hn(e){var t=e.profileIndex,n=e.constraintSet,r=e.levelIndex;return"avc1."+Sn(t)+Sn(n)+Sn(r)}On=new WeakMap,Rn=new WeakMap,An=new WeakMap,_n=new WeakMap,Tn=new WeakMap,Mn=new WeakMap,In=new WeakMap,xn=new WeakSet,Nn=function e(){if(Cn(this,In,kn(this,On,"f")[kn(this,Tn,"f")],"f"),2===kn(this,_n,"f")&&3===kn(this,In,"f"))return Cn(this,_n,0,"f"),Cn(this,Tn,kn(this,Tn,"f")+1,"f"),void kn(this,xn,"m",e).call(this);0===kn(this,In,"f")?Cn(this,_n,kn(this,_n,"f")+1,"f"):Cn(this,_n,0,"f")},Dn=function(){if(kn(this,Tn,"f")>=kn(this,Rn,"f")&&kn(this,Mn,"f")<kn(this,An,"f"))throw new Error("Bit index out of bounds")},Pn=function(){return{zeroCount:kn(this,_n,"f"),bytePosition:kn(this,Tn,"f"),bitPosition:kn(this,Mn,"f"),byte:kn(this,In,"f")}},Wn=function(e){Cn(this,_n,e.zeroCount,"f"),Cn(this,Tn,e.bytePosition,"f"),Cn(this,Mn,e.bitPosition,"f"),Cn(this,In,e.byte,"f")};var Kn,qn,Xn,Yn=function(){return p(function e(t){c(this,e),Un.set(this,void 0),Bn.set(this,void 0),jn.set(this,!1),Fn.set(this,void 0),Cn(this,Fn,t,"f")},[{key:"decode",value:function(e){if("configuration"===e.type)return Cn(this,Un,e.data,"f"),Cn(this,Bn,this.configure(e.data),"f"),void Cn(this,jn,!0,"f");var t;e.keyframe&&kn(this,Bn,"f")&&(kn(this,Fn,"f").reset(),kn(this,Fn,"f").configure(kn(this,Bn,"f")),kn(this,Un,"f")&&Cn(this,jn,!0,"f")),kn(this,jn,"f")&&void 0!==kn(this,Un,"f")?((t=new Uint8Array(kn(this,Un,"f").length+e.data.length)).set(kn(this,Un,"f"),0),t.set(e.data,kn(this,Un,"f").length),Cn(this,jn,!1,"f")):t=e.data,kn(this,Fn,"f").decode(new EncodedVideoChunk({type:!1===e.keyframe?"delta":"key",timestamp:void 0!==e.pts?Number(e.pts):1,data:t}))}}])}();Un=new WeakMap,Bn=new WeakMap,jn=new WeakMap,Fn=new WeakMap;var Jn,Qn,Zn,$n,er,tr,nr=function(e){function t(e,n,r){var i;return c(this,t),i=s(this,t,[e]),Kn.set(i,void 0),qn.set(i,void 0),Xn.set(i,void 0),Cn(i,Kn,e,"f"),Cn(i,qn,n,"f"),Cn(i,Xn,r,"f"),i}return b(t,e),p(t,[{key:"configure",value:function(e){var t,n,r=zn(e);kn(this,qn,"f").call(this,r.croppedWidth,r.croppedHeight);var i={codec:Hn(r),hardwareAcceleration:null!==(t=null===(n=kn(this,Xn,"f"))||void 0===n?void 0:n.hardwareAcceleration)&&void 0!==t?t:"no-preference",optimizeForLatency:!0};return kn(this,Kn,"f").configure(i),i}}])}(Yn);Kn=new WeakMap,qn=new WeakMap,Xn=new WeakMap;var rr,ir,or=function(){return p(function e(t,n){var r=this;c(this,e),Jn.set(this,void 0),Qn.set(this,new ReadableStream({start:function(e){Cn(r,Jn,e,"f")},pull:function(e){e.enqueue(kn(r,$n,"f").call(r))}},{highWaterMark:0})),Zn.set(this,kn(this,Qn,"f").getReader()),$n.set(this,void 0),er.set(this,0),tr.set(this,void 0),Cn(this,$n,t,"f"),Cn(this,tr,n,"f")},[{key:"borrow",value:(e=o(S().m(function e(){var t;return S().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,kn(this,Zn,"f").read();case 1:return t=e.v,e.a(2,t.value)}},e,this)})),function(){return e.apply(this,arguments)})},{key:"return",value:function(e){kn(this,er,"f")<kn(this,tr,"f")&&(kn(this,Jn,"f").enqueue(e),Cn(this,er,kn(this,er,"f")+1,"f"))}}]);var e}();Jn=new WeakMap,Qn=new WeakMap,Zn=new WeakMap,$n=new WeakMap,er=new WeakMap,tr=new WeakMap;var ar,sr,ur,cr,lr,fr,hr,dr,vr,pr,yr,mr,wr=function(){return p(function e(){c(this,e),rr.set(this,void 0),ir.set(this,void 0),"undefined"!=typeof OffscreenCanvas?Cn(this,rr,new OffscreenCanvas(1,1),"f"):(Cn(this,rr,document.createElement("canvas"),"f"),kn(this,rr,"f").width=1,kn(this,rr,"f").height=1);var t=kn(this,rr,"f").getContext("bitmaprenderer",{alpha:!1});if(!t)throw new Error("ImageBitmapRenderingContext is not supported");Cn(this,ir,t,"f")},[{key:"capture",value:(e=o(S().m(function e(t){var n,r=this;return S().w(function(e){for(;;)switch(e.n){case 0:return kn(this,rr,"f").width=t.displayWidth,kn(this,rr,"f").height=t.displayHeight,e.n=1,createImageBitmap(t);case 1:if(n=e.v,kn(this,ir,"f").transferFromImageBitmap(n),!(kn(this,rr,"f")instanceof OffscreenCanvas)){e.n=3;break}return e.n=2,kn(this,rr,"f").convertToBlob({type:"image/png"});case 2:return e.a(2,e.v);case 3:return e.a(2,new Promise(function(e,t){kn(r,rr,"f").toBlob(function(n){n?e(n):t(new Error("Failed to convert canvas to blob"))},"image/png")}));case 4:return e.a(2)}},e,this)})),function(t){return e.apply(this,arguments)})}]);var e}();rr=new WeakMap,ir=new WeakMap;var gr,br,Er,kr,Cr,Sr=function(){return p(function e(t,n){var r=this;c(this,e),ar.add(this),sr.set(this,!1),ur.set(this,!1),cr.set(this,void 0),lr.set(this,void 0),fr.set(this,void 0),hr.set(this,[]),dr.set(this,void 0),vr.set(this,!1),this.write=function(){var e=o(S().m(function e(t){var n,i;return S().w(function(e){for(;;)switch(e.n){case 0:if(!kn(r,vr,"f")){e.n=1;break}throw new Error("Attempt to write to a closed decoder");case 1:if(!kn(r,sr,"f")){e.n=5;break}n=t.type,e.n="configuration"===n?2:"data"===n?3:4;break;case 2:return Cn(r,fr,t,"f"),kn(r,hr,"f").length=0,e.a(3,4);case 3:return t.keyframe&&(kn(r,hr,"f").length=0),kn(r,hr,"f").push(t),e.a(3,4);case 4:case 12:return e.a(2);case 5:return e.n=6,kn(r,dr,"f");case 6:if(!kn(r,vr,"f")){e.n=7;break}return e.a(2);case 7:i=t.type,e.n="configuration"===i?8:"data"===i?10:12;break;case 8:return e.n=9,kn(r,cr,"f").call(r,t);case 9:case 11:return e.a(3,12);case 10:return e.n=11,kn(r,lr,"f").call(r,t,!1)}},e)}));return function(t){return e.apply(this,arguments)}}(),mr.set(this,void 0),Cn(this,cr,t,"f"),Cn(this,lr,n,"f")},[{key:"paused",get:function(){return kn(this,sr,"f")}},{key:"pause",value:function(){kn(this,ar,"m",pr).call(this,!0)}},{key:"resume",value:function(){return kn(this,ar,"m",yr).call(this,!0)}},{key:"trackDocumentVisibility",value:function(e){var t,n=this;null===(t=kn(this,mr,"f"))||void 0===t||t.call(this);var r=function(){"hidden"===e.visibilityState?kn(n,ar,"m",pr).call(n,!1):kn(n,ar,"m",yr).call(n,!1)};r(),e.addEventListener("visibilitychange",r);var i=!1;return Cn(this,mr,function(){i||(i=!0,e.removeEventListener("visibilitychange",r),kn(n,vr,"f")||kn(n,ar,"m",yr).call(n,!1))},"f"),kn(this,mr,"f")}},{key:"dispose",value:function(){var e;kn(this,vr,"f")||(Cn(this,vr,!0,"f"),Cn(this,fr,void 0,"f"),kn(this,hr,"f").length=0,null===(e=kn(this,mr,"f"))||void 0===e||e.call(this))}}])}();sr=new WeakMap,ur=new WeakMap,cr=new WeakMap,lr=new WeakMap,fr=new WeakMap,hr=new WeakMap,dr=new WeakMap,vr=new WeakMap,mr=new WeakMap,ar=new WeakSet,pr=function(e){if(kn(this,vr,"f"))throw new Error("Attempt to pause a closed decoder");Cn(this,sr,!0,"f"),e&&Cn(this,ur,!0,"f")},yr=function(){var e=o(S().m(function e(t){var n,r,i,o;return S().w(function(e){for(;;)switch(e.n){case 0:if(!kn(this,vr,"f")){e.n=1;break}throw new Error("Attempt to resume a closed decoder");case 1:if(kn(this,sr,"f")){e.n=2;break}return e.a(2);case 2:if(!kn(this,ur,"f")||t){e.n=3;break}return e.a(2);case 3:if(n=new ve,Cn(this,dr,n.promise,"f"),Cn(this,sr,!1,"f"),Cn(this,ur,!1,"f"),!kn(this,fr,"f")){e.n=5;break}return e.n=4,kn(this,cr,"f").call(this,kn(this,fr,"f"));case 4:if(Cn(this,fr,void 0,"f"),!kn(this,vr,"f")){e.n=5;break}return e.a(2);case 5:r=0,i=kn(this,hr,"f").length;case 6:if(!(r<i)){e.n=9;break}return o=kn(this,hr,"f")[r],e.n=7,kn(this,lr,"f").call(this,o,r!==i-1);case 7:if(!kn(this,vr,"f")){e.n=8;break}return e.a(2);case 8:r+=1,e.n=6;break;case 9:kn(this,hr,"f").length=0,n.resolve(void 0),Cn(this,dr,void 0,"f");case 10:return e.a(2)}},e,this)}));return function(t){return e.apply(this,arguments)}}();var xr=function(){return p(function e(){var t=this;c(this,e),gr.set(this,0),br.set(this,0),Er.set(this,0),kr.set(this,void 0),Cr.set(this,function(){kn(t,gr,"f")>0&&(Cn(t,br,kn(t,br,"f")+1,"f"),Cn(t,gr,0,"f")),Cn(t,kr,requestAnimationFrame(kn(t,Cr,"f")),"f")});try{Cn(this,kr,requestAnimationFrame(kn(this,Cr,"f")),"f")}catch(e){}},[{key:"framesDrawn",get:function(){return kn(this,gr,"f")}},{key:"framesRendered",get:function(){return kn(this,gr,"f")}},{key:"framesPresented",get:function(){return kn(this,br,"f")}},{key:"framesSkipped",get:function(){return kn(this,Er,"f")}},{key:"increaseFramesSkipped",value:function(){Cn(this,Er,kn(this,Er,"f")+1,"f")}},{key:"increaseFramesDrawn",value:function(){Cn(this,gr,kn(this,gr,"f")+1,"f")}},{key:"dispose",value:function(){void 0!==kn(this,kr,"f")&&cancelAnimationFrame(kn(this,kr,"f"))}}])}();gr=new WeakMap,br=new WeakMap,Er=new WeakMap,kr=new WeakMap,Cr=new WeakMap;var Or,Rr,Ar,_r=function(){return p(function e(){var t=this;c(this,e),m(this,"listeners",[]),m(this,"event",function(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),o=2;o<r;o++)i[o-2]=arguments[o];var a={listener:e,thisArg:n,args:i};return t.addEventListener(a)}),this.event=this.event.bind(this)},[{key:"addEventListener",value:function(e){var t=this;this.listeners.push(e);var n=function(){var n=t.listeners.indexOf(e);-1!==n&&t.listeners.splice(n,1)};return n.dispose=n,n}},{key:"fire",value:function(e){var t,n=y(this.listeners.slice());try{for(n.s();!(t=n.n()).done;){var r,i=t.value;(r=i.listener).call.apply(r,[i.thisArg,e].concat(T(i.args)))}}catch(e){n.e(e)}finally{n.f()}}},{key:"dispose",value:function(){this.listeners.length=0}}])}(),Tr=Symbol("undefined"),Mr=new WeakMap,Ir=function(e){function t(){var e;c(this,t);for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return f(e=s(this,t,[].concat(r)),Mr,Tr),e}return b(t,e),p(t,[{key:"addEventListener",value:function(e){var n;l(Mr,this)!==Tr&&(n=e.listener).call.apply(n,[e.thisArg,l(Mr,this)].concat(T(e.args)));return _(t,"addEventListener",this)([e])}},{key:"fire",value:function(e){h(Mr,this,e),_(t,"fire",this)([e])}}])}(_r),Nr=function(){return p(function e(){c(this,e),Or.set(this,0),Rr.set(this,0),Ar.set(this,new Ir)},[{key:"width",get:function(){return kn(this,Or,"f")}},{key:"height",get:function(){return kn(this,Rr,"f")}},{key:"sizeChanged",get:function(){return kn(this,Ar,"f").event}},{key:"setSize",value:function(e,t){kn(this,Or,"f")===e&&kn(this,Rr,"f")===t||(Cn(this,Or,e,"f"),Cn(this,Rr,t,"f"),kn(this,Ar,"f").fire({width:e,height:t}))}},{key:"dispose",value:function(){kn(this,Ar,"f").dispose()}}])}();Or=new WeakMap,Rr=new WeakMap,Ar=new WeakMap;var Dr,Pr,Wr,Lr,Vr,Ur,Br,jr,Fr,Gr,zr,Hr,Kr,qr,Xr,Yr,Jr,Qr,Zr,$r,ei,ti,ni,ri,ii,oi,ai,si,ui,ci,li,fi,hi,di=["codec","renderer","frameDropMode"],vi=new or(function(){return new wr},4);!function(e){e.RenderLatest="render-latest",e.DropWhenBusy="drop-when-busy",e.RenderAll="render-all"}(hi||(hi={}));var pi,yi=function(){return p(function e(t){var n=this,r=t.codec,i=t.renderer,o=t.frameDropMode,a=function(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}(t,di);if(c(this,e),Dr.add(this),Pr.set(this,void 0),Wr.set(this,void 0),Lr.set(this,void 0),Vr.set(this,void 0),Ur.set(this,hi.RenderLatest),Br.set(this,1),jr.set(this,[]),Fr.set(this,1),Gr.set(this,[]),zr.set(this,void 0),Hr.set(this,void 0),Kr.set(this,new Nr),qr.set(this,new xr),Xr.set(this,void 0),Yr.set(this,void 0),Jr.set(this,void 0),Qr.set(this,0),Zr.set(this,0),$r.set(this,!1),ei.set(this,void 0),ti.set(this,[]),ni.set(this,void 0),oi.set(this,function(e,t){kn(n,Wr,"f").setSize(e,t),kn(n,Kr,"f").setSize(e,t)}),Cn(this,Pr,r,"f"),Cn(this,Wr,i,"f"),Cn(this,Lr,a,"f"),Cn(this,Ur,null!=o?o:hi.RenderLatest,"f"),Cn(this,Yr,new VideoDecoder({output:function(e){var t;return kn(n,Ur,"f")!==hi.RenderLatest&&kn(n,Dr,"m",ui).call(n),kn(n,Vr,"f")||0===e.timestamp?(e.close(),void(kn(n,Ur,"f")===hi.RenderAll&&kn(n,Dr,"m",li).call(n))):(Cn(n,Qr,kn(n,Qr,"f")+1,"f"),Cn(n,Zr,kn(n,Zr,"f")+(performance.now()-e.timestamp/1e3),"f"),null===(t=kn(n,ni,"f"))||void 0===t||t.close(),Cn(n,ni,e.clone(),"f"),void kn(n,Dr,"m",ii).call(n,e))},error:function(e){kn(n,Ur,"f")!==hi.RenderLatest&&kn(n,Dr,"m",ui).call(n),kn(n,Ur,"f")===hi.RenderAll&&kn(n,Dr,"m",li).call(n),kn(n,Dr,"m",ri).call(n,e)}}),"f"),kn(this,Pr,"f")!==se)throw new Error("Unsupported codec: ".concat(kn(this,Pr,"f")));Cn(this,Jr,new nr(kn(this,Yr,"f"),kn(this,oi,"f"),kn(this,Lr,"f")),"f"),Cn(this,Xr,new Sr(function(e){return kn(n,Jr,"f").decode(e)},function(e,t){kn(n,Dr,"m",ai).call(n,e,t)}),"f"),Cn(this,zr,new Xe({start:function(e){kn(n,Vr,"f")?e.error(kn(n,Vr,"f")):Cn(n,Hr,e,"f")},write:kn(this,Xr,"f").write}),"f")},[{key:"codec",get:function(){return kn(this,Pr,"f")}},{key:"renderer",get:function(){return kn(this,Wr,"f")}},{key:"writable",get:function(){return kn(this,zr,"f")}},{key:"width",get:function(){return kn(this,Kr,"f").width}},{key:"height",get:function(){return kn(this,Kr,"f").height}},{key:"sizeChanged",get:function(){return kn(this,Kr,"f").sizeChanged}},{key:"framesDrawn",get:function(){return kn(this,qr,"f").framesDrawn}},{key:"framesRendered",get:function(){return kn(this,qr,"f").framesRendered}},{key:"framesPresented",get:function(){return kn(this,qr,"f").framesPresented}},{key:"framesSkipped",get:function(){return kn(this,qr,"f").framesSkipped}},{key:"paused",get:function(){return kn(this,Xr,"f").paused}},{key:"framesDecoded",get:function(){return kn(this,Qr,"f")}},{key:"decodeQueueSize",get:function(){return kn(this,Yr,"f").decodeQueueSize}},{key:"decodingTime",get:function(){return kn(this,Zr,"f")}},{key:"snapshot",value:(e=o(S().m(function e(){var t,n;return S().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t=kn(this,ni,"f")){e.n=1;break}return e.a(2,void 0);case 1:return e.n=2,vi.borrow();case 2:return n=e.v,e.p=3,e.n=4,n.capture(t);case 4:return e.a(2,e.v);case 5:return e.p=5,vi.return(n),e.f(5);case 6:return e.a(2)}},e,this,[[3,,5,6]])})),function(){return e.apply(this,arguments)})},{key:"pause",value:function(){kn(this,Xr,"f").pause()}},{key:"resume",value:function(){return kn(this,Xr,"f").resume()}},{key:"trackDocumentVisibility",value:function(e){return kn(this,Xr,"f").trackDocumentVisibility(e)}},{key:"dispose",value:function(){var e,t;null===(e=kn(this,ni,"f"))||void 0===e||e.close(),kn(this,qr,"f").dispose(),kn(this,Wr,"f").dispose(),kn(this,Kr,"f").dispose(),null===(t=kn(this,ei,"f"))||void 0===t||t.close();var n,r=y(kn(this,ti,"f"));try{for(r.s();!(n=r.n()).done;){n.value.close()}}catch(e){r.e(e)}finally{r.f()}kn(this,ti,"f").length=0,"closed"!==kn(this,Yr,"f").state&&kn(this,Yr,"f").close(),kn(this,Xr,"f").dispose()}}],[{key:"isSupported",get:function(){return void 0!==globalThis.VideoDecoder}}]);var e}();function mi(){if("undefined"!=typeof document)return document.createElement("canvas");if("undefined"!=typeof OffscreenCanvas)return new OffscreenCanvas(1,1);throw new Error("no canvas input found nor any canvas can be created")}function wi(e,t){try{var n=e.getContext("webgl2",t);if(n)return n}catch(e){}try{var r=e.getContext("webgl",t);if(r)return r}catch(e){}if(e instanceof HTMLCanvasElement){var i=e.getContext("experimental-webgl",t);if(i)return i}return null}function gi(e){try{var t;null===(t=e.getExtension("WEBGL_lose_context"))||void 0===t||t.loseContext()}catch(e){}}Pr=new WeakMap,Wr=new WeakMap,Lr=new WeakMap,Vr=new WeakMap,Ur=new WeakMap,Br=new WeakMap,jr=new WeakMap,Fr=new WeakMap,Gr=new WeakMap,zr=new WeakMap,Hr=new WeakMap,Kr=new WeakMap,qr=new WeakMap,Xr=new WeakMap,Yr=new WeakMap,Jr=new WeakMap,Qr=new WeakMap,Zr=new WeakMap,$r=new WeakMap,ei=new WeakMap,ti=new WeakMap,ni=new WeakMap,oi=new WeakMap,Dr=new WeakSet,ri=function(e){if(!kn(this,Vr,"f")){Cn(this,Vr,e,"f");try{var t;null===(t=kn(this,Hr,"f"))||void 0===t||t.error(e)}catch(e){}kn(this,Dr,"m",fi).call(this),this.dispose()}},ii=function(){var e=o(S().m(function e(t){var n,r;return S().w(function(e){for(;;)switch(e.p=e.n){case 0:if(e.p=0,!kn(this,$r,"f")){e.n=1;break}return kn(this,Ur,"f")===hi.RenderAll?kn(this,ti,"f").push(t):(kn(this,ei,"f")&&(kn(this,ei,"f").close(),kn(this,qr,"f").increaseFramesSkipped()),Cn(this,ei,t,"f")),e.a(2);case 1:Cn(this,$r,!0,"f");case 2:return kn(this,oi,"f").call(this,t.displayWidth,t.displayHeight),e.n=3,kn(this,Wr,"f").draw(t);case 3:if(t.close(),kn(this,qr,"f").increaseFramesDrawn(),kn(this,Ur,"f")!==hi.RenderAll){e.n=6;break}if(!(n=kn(this,ti,"f").shift())){e.n=4;break}t=n,e.n=5;break;case 4:return e.a(3,9);case 5:e.n=8;break;case 6:if(!kn(this,ei,"f")){e.n=7;break}t=kn(this,ei,"f"),Cn(this,ei,void 0,"f"),e.n=8;break;case 7:return e.a(3,9);case 8:e.n=2;break;case 9:Cn(this,$r,!1,"f"),kn(this,Ur,"f")===hi.RenderAll&&kn(this,Dr,"m",li).call(this),e.n=11;break;case 10:e.p=10,r=e.v,kn(this,Ur,"f")===hi.RenderAll&&kn(this,Dr,"m",li).call(this),kn(this,Dr,"m",ri).call(this,r);case 11:return e.a(2)}},e,this,[[0,10]])}));return function(t){return e.apply(this,arguments)}}(),ai=function(){var e=o(S().m(function e(t,n){var r,i,o,a,s,u;return S().w(function(e){for(;;)switch(e.n){case 0:if(kn(this,Ur,"f")!==hi.RenderAll){e.n=3;break}return e.n=1,kn(this,Dr,"m",ci).call(this);case 1:return e.n=2,kn(this,Dr,"m",si).call(this);case 2:e.n=4;break;case 3:if(kn(this,Ur,"f")!==hi.DropWhenBusy){e.n=4;break}return e.n=4,kn(this,Dr,"m",si).call(this);case 4:n?r=0n:(i=performance.now(),o=i.toString().split("."),a=A(o,2),s=a[0],u=a[1],r=BigInt(s+((void 0===u?"":u)+"000").slice(0,3)));try{kn(this,Jr,"f").decode(C(C({},t),{},{pts:r}))}catch(e){kn(this,Ur,"f")!==hi.RenderLatest&&kn(this,Dr,"m",ui).call(this),kn(this,Ur,"f")===hi.RenderAll&&kn(this,Dr,"m",li).call(this),kn(this,Dr,"m",ri).call(this,e)}case 5:return e.a(2)}},e,this)}));return function(t,n){return e.apply(this,arguments)}}(),si=function(){var e=o(S().m(function e(){var t=this;return S().w(function(e){for(;;)switch(e.n){case 0:if(!(kn(this,Br,"f")>0)){e.n=1;break}return Cn(this,Br,kn(this,Br,"f")-1,"f"),e.a(2);case 1:return e.n=2,new Promise(function(e){kn(t,jr,"f").push(e)});case 2:return e.a(2)}},e,this)}));return function(){return e.apply(this,arguments)}}(),ui=function(){kn(this,jr,"f").length>0?kn(this,jr,"f").shift()():kn(this,Br,"f")<1&&Cn(this,Br,kn(this,Br,"f")+1,"f")},ci=function(){var e=o(S().m(function e(){var t=this;return S().w(function(e){for(;;)switch(e.n){case 0:if(!(kn(this,Fr,"f")>0)){e.n=1;break}return Cn(this,Fr,kn(this,Fr,"f")-1,"f"),e.a(2);case 1:return e.n=2,new Promise(function(e){kn(t,Gr,"f").push(e)});case 2:return e.a(2)}},e,this)}));return function(){return e.apply(this,arguments)}}(),li=function(){kn(this,Gr,"f").length>0?kn(this,Gr,"f").shift()():kn(this,Fr,"f")<1&&Cn(this,Fr,kn(this,Fr,"f")+1,"f")},fi=function(){var e,t=y(kn(this,jr,"f"));try{for(t.s();!(e=t.n()).done;){(0,e.value)()}}catch(e){t.e(e)}finally{t.f()}kn(this,jr,"f").length=0,Cn(this,Br,1,"f");var n,r=y(kn(this,Gr,"f"));try{for(r.s();!(n=r.n()).done;){(0,n.value)()}}catch(e){r.e(e)}finally{r.f()}kn(this,Gr,"f").length=0,Cn(this,Fr,1,"f")},yi.capabilities={h264:{}};var bi,Ei=function(){return p(function e(t){c(this,e),pi.set(this,void 0),Cn(this,pi,t||mi(),"f")},[{key:"canvas",get:function(){return kn(this,pi,"f")}},{key:"setSize",value:function(e,t){kn(this,pi,"f").width===e&&kn(this,pi,"f").height===t||(kn(this,pi,"f").width=e,kn(this,pi,"f").height=t)}},{key:"dispose",value:function(){kn(this,pi,"f").width=0,kn(this,pi,"f").height=0}}])}();pi=new WeakMap;var ki=Promise.resolve(),Ci=function(e){function t(e,n){var r;c(this,t),r=s(this,t,[e]),bi.set(r,void 0);var i=wi(r.canvas,{powerPreference:"low-power",alpha:!1,failIfMajorPerformanceCaveat:!0,preserveDrawingBuffer:!!n,desynchronized:!n,antialias:!1,depth:!1,premultipliedAlpha:!0,stencil:!1});if(!i)throw new Error("WebGL not supported, check `isSupported` first");Cn(r,bi,i,"f");var o=i.createShader(i.VERTEX_SHADER);if(i.shaderSource(o,t.VertexShaderSource),i.compileShader(o),!i.getShaderParameter(o,i.COMPILE_STATUS))throw new Error(i.getShaderInfoLog(o));var a=i.createShader(i.FRAGMENT_SHADER);if(i.shaderSource(a,t.FragmentShaderSource),i.compileShader(a),!i.getShaderParameter(a,i.COMPILE_STATUS))throw new Error(i.getShaderInfoLog(a));var u=i.createProgram();if(i.attachShader(u,o),i.attachShader(u,a),i.linkProgram(u),!i.getProgramParameter(u,i.LINK_STATUS))throw new Error(i.getProgramInfoLog(u));i.useProgram(u);var l=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,l),i.bufferData(i.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),i.STATIC_DRAW);var f=i.getAttribLocation(u,"xy");i.vertexAttribPointer(f,2,i.FLOAT,!1,0,0),i.enableVertexAttribArray(f);var h=i.createTexture();return i.bindTexture(i.TEXTURE_2D,h),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i instanceof WebGL2RenderingContext?i.NEAREST_MIPMAP_LINEAR:i.NEAREST),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),r}return b(t,e),p(t,[{key:"draw",value:function(e){var t=kn(this,bi,"f");return t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),t instanceof WebGL2RenderingContext&&t.generateMipmap(t.TEXTURE_2D),t.viewport(0,0,t.drawingBufferWidth,t.drawingBufferHeight),t.drawArrays(t.TRIANGLE_FAN,0,4),ki}},{key:"dispose",value:function(){gi(kn(this,bi,"f"))}}],[{key:"isSupported",get:function(){return e={failIfMajorPerformanceCaveat:!0},(t=wi(mi(),e))&&gi(t),!!t;var e,t}}])}(Ei);bi=new WeakMap,Ci.VertexShaderSource="\n attribute vec2 xy;\n\n varying highp vec2 uv;\n\n void main(void) {\n gl_Position = vec4(xy, 0.0, 1.0);\n // Map vertex coordinates (-1 to +1) to UV coordinates (0 to 1).\n // UV coordinates are Y-flipped relative to vertex coordinates.\n uv = vec2((1.0 + xy.x) / 2.0, (1.0 - xy.y) / 2.0);\n }\n",Ci.FragmentShaderSource="\n precision mediump float;\n\n varying highp vec2 uv;\n uniform sampler2D texture;\n\n void main(void) {\n gl_FragColor = texture2D(texture, uv);\n }\n";var Si=function(){return p(function e(t,n){c(this,e),this.program=null,this.texture=null,this.vertexBuffer=null,this.canvas=t;var r={alpha:!1,depth:!1,stencil:!1,antialias:!1,preserveDrawingBuffer:!1,powerPreference:null!=n?n:"low-power",failIfMajorPerformanceCaveat:!0},i=t.getContext("webgl2",r)||t.getContext("webgl",r);if(!i)throw new Error("WebGL not supported");this.gl=i,this.initGL()},[{key:"initGL",value:function(){var e=this.gl,t=this.createShader(e.VERTEX_SHADER,"\n attribute vec2 a_pos;\n varying highp vec2 v_texCoord;\n void main() {\n gl_Position = vec4(a_pos, 0.0, 1.0);\n // Map [-1, 1] to [0, 1] and flip Y for texture\n v_texCoord = vec2((a_pos.x + 1.0) * 0.5, (1.0 - a_pos.y) * 0.5);\n }\n "),n=this.createShader(e.FRAGMENT_SHADER,"\n varying highp vec2 v_texCoord;\n uniform sampler2D u_sampler;\n void main() {\n gl_FragColor = texture2D(u_sampler, v_texCoord);\n }\n ");this.program=this.createProgram(t,n),e.useProgram(this.program);var r=new Float32Array([-1,-1,1,-1,-1,1,1,1]);this.vertexBuffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),e.bufferData(e.ARRAY_BUFFER,r,e.STATIC_DRAW);var i=e.getAttribLocation(this.program,"a_pos");e.enableVertexAttribArray(i),e.vertexAttribPointer(i,2,e.FLOAT,!1,0,0),this.texture=e.createTexture(),e.bindTexture(e.TEXTURE_2D,this.texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.clearColor(1,1,1,1),e.clear(e.COLOR_BUFFER_BIT)}},{key:"setSize",value:function(e,t){this.canvas.width===e&&this.canvas.height===t||(this.canvas.width=e,this.canvas.height=t)}},{key:"draw",value:function(e){var t=this.gl;t&&this.program&&(t.viewport(0,0,t.drawingBufferWidth,t.drawingBufferHeight),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,this.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),t.drawArrays(t.TRIANGLE_STRIP,0,4))}},{key:"createShader",value:function(e,t){var n=this.gl,r=n.createShader(e);if(n.shaderSource(r,t),n.compileShader(r),!n.getShaderParameter(r,n.COMPILE_STATUS)){var i=n.getShaderInfoLog(r);throw n.deleteShader(r),new Error("Shader compile error: "+i)}return r}},{key:"createProgram",value:function(e,t){var n=this.gl,r=n.createProgram();if(n.attachShader(r,e),n.attachShader(r,t),n.linkProgram(r),!n.getProgramParameter(r,n.LINK_STATUS)){var i=n.getProgramInfoLog(r);throw n.deleteProgram(r),new Error("Program link error: "+i)}return n.detachShader(r,e),n.detachShader(r,t),n.deleteShader(e),n.deleteShader(t),r}},{key:"dispose",value:function(){var e,t=this.gl;this.texture&&t.deleteTexture(this.texture),this.vertexBuffer&&t.deleteBuffer(this.vertexBuffer),this.program&&t.deleteProgram(this.program),null===(e=t.getExtension("WEBGL_lose_context"))||void 0===e||e.loseContext()}}],[{key:"isSupported",get:function(){try{var e=new OffscreenCanvas(1,1);return!(!e.getContext("webgl2")&&!e.getContext("webgl"))}catch(e){return!1}}}])}(),xi=function(){return p(function e(t){if(c(this,e),this.canvas=t,this.ctx=null,this.ctx=t.getContext("2d",{alpha:!1,desynchronized:!0}),!this.ctx)throw new Error("Canvas 2D not supported")},[{key:"setSize",value:function(e,t){this.canvas.width===e&&this.canvas.height===t||(this.canvas.width=e,this.canvas.height=t)}},{key:"draw",value:function(e){this.ctx&&this.ctx.drawImage(e,0,0,this.canvas.width,this.canvas.height)}},{key:"dispose",value:function(){this.ctx=null,this.canvas.width=0,this.canvas.height=0}}])}(),Oi=function(){return p(function e(){c(this,e),this.listeners=new Map},[{key:"on",value:function(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)}},{key:"once",value:function(e,t){var n=this,r=function(){t.apply(void 0,arguments),n.off(e,r)};this.on(e,r)}},{key:"off",value:function(e,t){var n;null===(n=this.listeners.get(e))||void 0===n||n.delete(t)}},{key:"emit",value:function(e){var t=this.listeners.get(e);if(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];var o,a=y(t);try{for(a.s();!(o=a.n()).done;){var s=o.value;try{s.apply(void 0,r)}catch(t){console.error("EventEmitter '".concat(e,"' listener error"),t)}}}catch(e){a.e(e)}finally{a.f()}}}},{key:"clear",value:function(e){e?this.listeners.delete(e):this.listeners.clear()}}])}(),Ri=function(e){function t(e){var n,r;return c(this,t),(r=s(this,t)).sockets={video:null,audio:null,touch:null},r.subscribers={video:new Set,audio:new Set,touch:new Set},r.deviceId=e.deviceId,r.ip=e.ip,r.ports=null!==(n=e.ports)&&void 0!==n?n:{},r}return b(t,e),p(t,[{key:"getUrl",value:function(e){var t=this.ports[e];return"ws://".concat(this.ip,":").concat(t)}},{key:"getChannelStatus",value:function(e){var t=this.sockets[e];if(!t)return"disconnected";switch(t.readyState){case WebSocket.CONNECTING:return"connecting";case WebSocket.OPEN:return"connected";case WebSocket.CLOSING:case WebSocket.CLOSED:default:return"disconnected"}}},{key:"getAllChannelsStatus",value:function(){return{video:this.getChannelStatus("video"),audio:this.getChannelStatus("audio"),touch:this.getChannelStatus("touch")}}},{key:"emitChannelStatus",value:function(e,t){var n=this.getAllChannelsStatus();this.emit(t,e,n)}},{key:"ensureChannel",value:function(e){var t=this;if(this.sockets[e]){var n=this.sockets[e].readyState;if(n===WebSocket.OPEN||n===WebSocket.CONNECTING)return;this.sockets[e]=null}var r=new WebSocket(this.getUrl(e));r.binaryType="arraybuffer",r.onopen=function(){console.log("[".concat(t.deviceId,":").concat(e,"] connected")),t.emitChannelStatus(e,"open")},r.onmessage=function(n){try{var r,i=y(t.subscribers[e]);try{for(i.s();!(r=i.n()).done;){(0,r.value)(n.data)}}catch(e){i.e(e)}finally{i.f()}}catch(n){console.error("[".concat(t.deviceId,":").concat(e,"] message error"),n)}},r.onerror=function(n){console.error("[".concat(t.deviceId,":").concat(e,"] error"),n),t.emit("error",e,n)},r.onclose=function(n){console.warn("[".concat(t.deviceId,":").concat(e,"] closed"),n),t.sockets[e]=null,t.emit("close",e,n)},this.sockets[e]=r}},{key:"subscribe",value:function(e,t){this.subscribers[e].add(t),this.sockets[e]||this.ensureChannel(e)}},{key:"unsubscribe",value:function(e,t){var n;(t?this.subscribers[e].delete(t):this.subscribers[e].clear(),0===this.subscribers[e].size)&&(console.log("[".concat(this.deviceId,":").concat(e,"] no subscribers, closing")),null===(n=this.sockets[e])||void 0===n||n.close(),this.sockets[e]=null)}},{key:"send",value:function(e,t){var n=this.sockets[e];if(n&&n.readyState===WebSocket.OPEN)try{t instanceof ArrayBuffer||t instanceof Uint8Array?n.send(t):n.send(JSON.stringify(t))}catch(t){console.error("[".concat(e,"] send error"),t)}}},{key:"sendTouch",value:function(e){this.send("touch",e)}},{key:"destroy",value:function(){var e=this;["video","audio","touch"].forEach(function(t){console.log("[".concat(e.deviceId,":").concat(t,"] destroying"));var n=e.sockets[t];n&&(n.onopen=null,n.onmessage=null,n.onerror=null,n.onclose=null,n.close(),e.sockets[t]=null),e.subscribers[t].clear()}),this.clear()}}])}(Oi),Ai="focus",_i="blur",Ti="input",Mi="delete",Ii="enter",Ni="arrow-up",Di="arrow-down",Pi="arrow-left",Wi="arrow-right",Li=function(){return p(function e(t){c(this,e),this.emitter=new Oi,this.isComposing=!1,this.el=document.createElement("textarea"),this.el.style.cssText="\n position:absolute;\n top:0;\n left:0;\n pointer-events:none;\n opacity:0.01;\n width:100%;\n max-width:95%;\n height: 40px;\n resize: none;\n overflow: hidden;\n ",this.el.autocomplete="off",t.appendChild(this.el),this.bindEvents()},[{key:"on",value:function(e,t){var n;null===(n=this.emitter)||void 0===n||n.on(e,t)}},{key:"off",value:function(e,t){var n;null===(n=this.emitter)||void 0===n||n.off(e,t)}},{key:"bindEvents",value:function(){var e=this;this.el.addEventListener("focus",function(){var t;return null===(t=e.emitter)||void 0===t?void 0:t.emit(Ai)}),this.el.addEventListener("blur",function(){var t;return null===(t=e.emitter)||void 0===t?void 0:t.emit(_i)}),this.el.addEventListener("compositionstart",function(){e.isComposing=!0}),this.el.addEventListener("compositionend",function(t){var n;e.isComposing=!1;var r=t.target;null===(n=e.emitter)||void 0===n||n.emit(Ti,r.value),e.el.value=""}),this.el.addEventListener("input",function(t){var n;if(!e.isComposing){var r=t.target;null===(n=e.emitter)||void 0===n||n.emit(Ti,r.value),e.el.value=""}}),this.el.addEventListener("keydown",function(t){var n,r,i,o,a,s;switch(t.key){case"Backspace":case"Delete":null===(n=e.emitter)||void 0===n||n.emit(Mi);break;case"Enter":null===(r=e.emitter)||void 0===r||r.emit(Ii),e.el.blur();break;case"ArrowUp":null===(i=e.emitter)||void 0===i||i.emit(Ni);break;case"ArrowDown":null===(o=e.emitter)||void 0===o||o.emit(Di);break;case"ArrowLeft":null===(a=e.emitter)||void 0===a||a.emit(Pi);break;case"ArrowRight":null===(s=e.emitter)||void 0===s||s.emit(Wi)}})}},{key:"focus",value:function(){this.el.focus()}},{key:"blur",value:function(){this.el.blur()}},{key:"moveTo",value:function(e,t,n){this.el.style.left="".concat(e,"px"),this.el.style.top="".concat(t,"px"),n&&(this.el.style.width="".concat(n,"px"))}},{key:"destroy",value:function(){var e;null===(e=this.emitter)||void 0===e||e.clear(),this.emitter=null,this.el.remove()}}])}(),Vi={AndroidHome:3,AndroidBack:4,AndroidCall:5,AndroidEndCall:6,Digit0:7,Digit1:8,Digit2:9,Digit3:10,Digit4:11,Digit5:12,Digit6:13,Digit7:14,Digit8:15,Digit9:16,Star:17,Pound:18,ArrowUp:19,ArrowDown:20,ArrowLeft:21,ArrowRight:22,AndroidDPadCenter:23,VolumeUp:24,VolumeDown:25,Power:26,AndroidCamera:27,Clear:28,KeyA:29,KeyB:30,KeyC:31,KeyD:32,KeyE:33,KeyF:34,KeyG:35,KeyH:36,KeyI:37,KeyJ:38,KeyK:39,KeyL:40,KeyM:41,KeyN:42,KeyO:43,KeyP:44,KeyQ:45,KeyR:46,KeyS:47,KeyT:48,KeyU:49,KeyV:50,KeyW:51,KeyX:52,KeyY:53,KeyZ:54,Comma:55,Period:56,AltLeft:57,AltRight:58,ShiftLeft:59,ShiftRight:60,Tab:61,Space:62,AndroidSymbol:63,AndroidExplorer:64,AndroidEnvelope:65,Enter:66,Backspace:67,Backquote:68,Minus:69,Equal:70,BracketLeft:71,BracketRight:72,Backslash:73,Semicolon:74,Quote:75,Slash:76,At:77,AndroidNum:78,AndroidHeadsetHook:79,AndroidFocus:80,Plus:81,ContextMenu:82,AndroidNotification:83,AndroidSearch:84,PageUp:92,PageDown:93,Escape:111,Delete:112,ControlLeft:113,ControlRight:114,CapsLock:115,ScrollLock:116,MetaLeft:117,MetaRight:118,AndroidFunction:119,PrintScreen:120,Pause:121,Home:122,End:123,Insert:124,AndroidForward:125,F1:131,F2:132,F3:133,F4:134,F5:135,F6:136,F7:137,F8:138,F9:139,F10:140,F11:141,F12:142,NumLock:143,Numpad0:144,Numpad1:145,Numpad2:146,Numpad3:147,Numpad4:148,Numpad5:149,Numpad6:150,Numpad7:151,Numpad8:152,Numpad9:153,NumpadDivide:154,NumpadMultiply:155,NumpadSubtract:156,NumpadAdd:157,NumpadDecimal:158,NumpadComma:159,NumpadEnter:160,NumpadEquals:161,NumpadLeftParen:162,NumpadRightParen:163,VolumeMute:164,AndroidAppSwitch:187,AndroidCut:277,AndroidCopy:278,AndroidPaste:279};Object.fromEntries(Object.entries(Vi).map(function(e){var t=A(e,2),n=t[0];return[t[1],n]}));var Ui,Bi,ji={Down:0,Up:1},Fi={Down:0,Up:1,Move:2,Cancel:3,Outside:4,PointerDown:5,PointerUp:6,HoverMove:7,Scroll:8,HoverEnter:9,HoverExit:10,ButtonPress:11,ButtonRelease:12},Gi={None:0,Primary:1,Secondary:2,Tertiary:4,Back:8,Forward:16,StylusPrimary:32,StylusSecondary:64};function zi(e,t,n){return e.setUint16(t,n),t+2}function Hi(e,t,n){return e.setUint32(t,n),t+4}function Ki(e,t,n){return e.setInt32(t,n),t+4}function qi(e,t,n){var r=Math.round(n/16*32767);return e.setInt16(t,r),t+2}function Xi(e,t,n){return e.setUint8(t,n),t+1}function Yi(e,t,n){return e.setBigInt64(t,n),t+8}!function(e){e[e.injectKeyCode=0]="injectKeyCode",e[e.injectText=1]="injectText",e[e.injectTouchEvent=2]="injectTouchEvent",e[e.injectScrollEvent=3]="injectScrollEvent",e[e.backOrScreenOn=4]="backOrScreenOn",e[e.expandNotificationPanel=5]="expandNotificationPanel",e[e.expandSettingsPanel=6]="expandSettingsPanel",e[e.collapsePanels=7]="collapsePanels",e[e.getClipboard=8]="getClipboard",e[e.setClipboard=9]="setClipboard",e[e.setDisplayPower=10]="setDisplayPower",e[e.rotateDevice=11]="rotateDevice",e[e.uhidCreate=12]="uhidCreate",e[e.uhidInput=13]="uhidInput",e[e.uhidDestroy=14]="uhidDestroy",e[e.openHardKeyboardSettings=15]="openHardKeyboardSettings",e[e.startApp=16]="startApp",e[e.resetVideo=17]="resetVideo"}(Ui||(Ui={})),function(e){e[e.Clipboard=0]="Clipboard",e[e.AckClipboard=1]="AckClipboard",e[e.UhidOutput=2]="UhidOutput"}(Bi||(Bi={}));var Ji=function(){return p(function e(){c(this,e)},null,[{key:"injectKeyCode",value:function(e){var t=e.action,n=e.keyCode,r=e.repeat,i=void 0===r?0:r,o=e.metaState,a=void 0===o?0:o,s=new ArrayBuffer(14),u=new DataView(s),c=0;return c=Xi(u,c,Ui.injectKeyCode),c=Ki(u,c=Xi(u,c,t),n),c=Ki(u,c,i),c=Ki(u,c,a),new Uint8Array(s)}},{key:"injectText",value:function(e){var t=e.text,n=this.encoder.encode(t),r=new ArrayBuffer(5+n.length),i=new DataView(r),o=0;return o=Hi(i,o=Xi(i,o,Ui.injectText),n.length),new Uint8Array(r,o).set(n),new Uint8Array(r)}},{key:"injectTouch",value:function(e){var t=e.action,n=e.pointerId,r=e.pointerX,i=e.pointerY,o=e.screenWidth,a=e.screenHeight,s=e.pressure,u=e.actionButton,c=e.buttons,l=new ArrayBuffer(32),f=new DataView(l),h=0;return h=Xi(f,h,Ui.injectTouchEvent),h=Ki(f,h=Yi(f,h=Xi(f,h,t),BigInt(n)),r),h=zi(f,h=Ki(f,h,i),o),h=function(e,t,n){var r=65535*Math.max(0,Math.min(1,n));return e.setUint16(t,r),t+2}(f,h=zi(f,h,a),s),h=Ki(f,h,u),h=Ki(f,h,c),new Uint8Array(l)}},{key:"injectScroll",value:function(e){var t=e.pointerX,n=e.pointerY,r=e.screenWidth,i=e.screenHeight,o=e.scrollX,a=e.scrollY,s=e.buttons,u=new ArrayBuffer(21),c=new DataView(u),l=0;return l=Ki(c,l=Xi(c,l,Ui.injectScrollEvent),t),l=zi(c,l=Ki(c,l,n),r),l=qi(c,l=zi(c,l,i),o),l=Ki(c,l=qi(c,l,a),s),new Uint8Array(u)}},{key:"setClipboard",value:function(e){var t=e.sequence,n=e.text,r=e.paste,i=void 0!==r&&r,o=this.encoder.encode(n),a=new ArrayBuffer(14+o.length),s=new DataView(a),u=0;return u=Xi(s,u,Ui.setClipboard),u=Hi(s,u=Xi(s,u=Yi(s,u,BigInt(t)),i?1:0),o.length),new Uint8Array(a,u).set(o),new Uint8Array(a)}},{key:"resetVideo",value:function(){var e=new ArrayBuffer(1);return Xi(new DataView(e),0,Ui.resetVideo),new Uint8Array(e)}}])}();Ji.encoder=new TextEncoder;var Qi=function(){return p(function e(){c(this,e)},null,[{key:"parse",value:function(e){var t=new DataView(e instanceof Uint8Array?e.buffer:e,e instanceof Uint8Array?e.byteOffset:0,e.byteLength);if(t.byteLength<1)return null;var n=function(e,t){return e.getUint8(t)}(t,0);switch(n){case Bi.Clipboard:return this.parseClipboard(t);case Bi.AckClipboard:return this.parseAckClipboard(t);default:return null}}},{key:"parseClipboard",value:function(e){if(e.byteLength<5)return null;var t=function(e,t){return e.getUint32(t)}(e,1);if(e.byteLength<5+t)return null;var n=new Uint8Array(e.buffer,e.byteOffset+5,t),r=this.decoder.decode(n);return{type:Bi.Clipboard,content:r}}},{key:"parseAckClipboard",value:function(e){if(e.byteLength<9)return null;var t=function(e,t){return e.getBigInt64(t)}(e,1);return{type:Bi.AckClipboard,sequence:t}}}])}();function Zi(e,t,n){return Math.max(t,Math.min(n,e))}Qi.decoder=new TextDecoder;var $i,eo,to={SIZE_CHANGED:"size-changed",ERROR:"error",STARTED:"started",STOPPED:"stopped",CLIPBOARD_CHANGED:"clipboard-changed",CHANNEL_CONNECTED:"channel-connected",GROUP_CONTROL_JOINED:"group-control-joined",GROUP_CONTROL_LEAVE:"group-control-leave"};e.VmosEdgeErrorType=void 0,($i=e.VmosEdgeErrorType||(e.VmosEdgeErrorType={})).CONNECTION="connection",$i.VIDEO="video",$i.AUDIO="audio",$i.TOUCH="touch",$i.DECODER="decoder",$i.RENDERER="renderer",e.VmosEdgeErrorCode=void 0,(eo=e.VmosEdgeErrorCode||(e.VmosEdgeErrorCode={})).CONNECTION_FAILED="CONNECTION_FAILED",eo.CONNECTION_TIMEOUT="CONNECTION_TIMEOUT",eo.CONNECTION_LOST="CONNECTION_LOST",eo.VIDEO_CHANNEL_CONNECTION_FAILED="VIDEO_CHANNEL_CONNECTION_FAILED",eo.VIDEO_CHANNEL_CLOSED="VIDEO_CHANNEL_CLOSED",eo.VIDEO_STREAM_ERROR="VIDEO_STREAM_ERROR",eo.VIDEO_PIPELINE_ERROR="VIDEO_PIPELINE_ERROR",eo.AUDIO_CHANNEL_CONNECTION_FAILED="AUDIO_CHANNEL_CONNECTION_FAILED",eo.AUDIO_STREAM_ERROR="AUDIO_STREAM_ERROR",eo.TOUCH_CHANNEL_CONNECTION_FAILED="TOUCH_CHANNEL_CONNECTION_FAILED",eo.TOUCH_MESSAGE_PARSE_ERROR="TOUCH_MESSAGE_PARSE_ERROR",eo.DECODER_INIT_FAILED="DECODER_INIT_FAILED",eo.DECODER_ERROR="DECODER_ERROR",eo.RENDERER_INIT_FAILED="RENDERER_INIT_FAILED",eo.RENDERER_ERROR="RENDERER_ERROR",eo.UNKNOWN_ERROR="UNKNOWN_ERROR";function no(e,t){var n,r,i=!1,o=0,a=0;return new Ye({transform:function(s,u){var c=Date.now();if("configuration"===s.type)return r=s,void(i||u.enqueue(s));if(void 0!==s.pts)if(void 0===n)n=s.pts,o=c;else{var l=s.pts-n,f=c-(o+Number(l)/1e3),h=t();f<-1e3&&(n=s.pts,o=c),!i&&(f>5e3||h>14)&&(i=!0,console.warn("[PacketDropper] Entering drop mode: lag=".concat(f.toFixed(0),"ms, queue=").concat(h)))}if(i){if(c-a>1600&&(e(),a=c,console.log("[PacketDropper] Requested keyframe")),!s.keyframe)return;i=!1,n=s.pts,o=c,console.log("[PacketDropper] Recovered from drop mode: received keyframe"),r&&(u.enqueue(r),r=void 0)}u.enqueue(s)}})}var ro=function(t){function n(e){var t,r,i,o,a,u;return c(this,n),(u=s(this,n)).canvas=null,u.canvasContainer=null,u.device=null,u.isGroupControl=!1,u.deviceTouchGroupMap=new Map,u.config=null,u.renderer=null,u.videoCodecPreference="no-preference",u.renderPreference="default",u.decoder=null,u.textareaManager=null,u.videoWidth=0,u.videoHeight=0,u.isRunning=!1,u.rotation=0,u.manualRotation=!1,u.currentRotationAngle=0,u.resizeObserver=null,u.pointerMoveThrottleMap=new Map,u.touchMoveInterval=1e3/60,u.retryCount=0,u.maxRetries=0,u.retryInterval=1e3,u.stopVideoSubscription=null,u.container=e.container,u.config=e.config,u.device=new Ri(u.config),u.maxRetries=null!==(t=e.retryCount)&&void 0!==t?t:0,u.retryInterval=null!==(r=e.retryInterval)&&void 0!==r?r:1e3,u.isGroupControl=null!==(i=e.isGroupControl)&&void 0!==i&&i,u.videoCodecPreference=null!==(o=e.videoCodecPreference)&&void 0!==o?o:"no-preference",u.renderPreference=null!==(a=e.renderPreference)&&void 0!==a?a:"default",e.touchMoveFrequency&&(u.touchMoveInterval=1e3/e.touchMoveFrequency),u.initCanvas(),u.handlePointerEvent=u.handlePointerEvent.bind(u),u.handleWheelEvent=u.handleWheelEvent.bind(u),u.handleContextMenu=u.handleContextMenu.bind(u),u.initTextareaManager(),u.observeContainerResize(),u}return b(n,t),p(n,[{key:"setupChannelStatusListener",value:function(){var e,t,n=this;null===(e=this.device)||void 0===e||e.on("open",function(e,t){var r,i=null===(r=n.config)||void 0===r?void 0:r.ports[e];n.emit(to.CHANNEL_CONNECTED,{channel:e,port:i,allChannelsStatus:t})}),null===(t=this.device)||void 0===t||t.on("error",function(e,t){var r,i=n.extractErrorMessage(t);i||(i="WebSocket ".concat(e," channel connection failed"));var o=n.getErrorCodeForChannel(e,"connection_failed");n.emit(to.ERROR,{type:n.channelToErrorType(e),code:o,message:i,port:null===(r=n.config)||void 0===r?void 0:r.ports[e]})})}},{key:"extractErrorMessage",value:function(e){if(e instanceof Error)return e.message||e.toString();if(e instanceof Event)return"".concat(e.type||"unknown");if("string"==typeof e)return e;if(e&&"object"===I(e))return e.message||e.reason||String(e);var t=String(e);return"[object Object]"===t||"[object Event]"===t?"":t}},{key:"channelToErrorType",value:function(t){switch(t){case"video":return e.VmosEdgeErrorType.VIDEO;case"audio":return e.VmosEdgeErrorType.AUDIO;case"touch":return e.VmosEdgeErrorType.TOUCH;default:return e.VmosEdgeErrorType.CONNECTION}}},{key:"getErrorCodeForChannel",value:function(t,n){if("video"===t)switch(n){case"connection_failed":return e.VmosEdgeErrorCode.VIDEO_CHANNEL_CONNECTION_FAILED;case"connection_closed":return e.VmosEdgeErrorCode.VIDEO_CHANNEL_CLOSED;default:return e.VmosEdgeErrorCode.VIDEO_STREAM_ERROR}else{if("audio"===t)return"connection_failed"===n?e.VmosEdgeErrorCode.AUDIO_CHANNEL_CONNECTION_FAILED:e.VmosEdgeErrorCode.AUDIO_STREAM_ERROR;switch(n){case"connection_failed":default:return e.VmosEdgeErrorCode.TOUCH_CHANNEL_CONNECTION_FAILED;case"parse_error":return e.VmosEdgeErrorCode.TOUCH_MESSAGE_PARSE_ERROR}}}},{key:"initCanvas",value:function(){this.canvasContainer=document.createElement("div"),this.canvasContainer.className="vmos-canvas-container",this.container.appendChild(this.canvasContainer),this.canvas=document.createElement("canvas"),this.applyCanvasStyle(this.canvas),this.canvasContainer.appendChild(this.canvas),this.container.appendChild(this.canvasContainer)}},{key:"replaceCanvas",value:function(){var e;this.canvas&&this.canvasContainer&&this.canvasContainer.removeChild(this.canvas),this.canvas=document.createElement("canvas"),this.applyCanvasStyle(this.canvas),null===(e=this.canvasContainer)||void 0===e||e.appendChild(this.canvas)}},{key:"applyCanvasStyle",value:function(e){e.style.width="100%",e.style.height="100%",e.style.outline="none",e.style.userSelect="none",e.style.backgroundColor="transparent",e.style.touchAction="none"}},{key:"initTextareaManager",value:function(){var e=this;this.textareaManager=new Li(this.container),this.textareaManager.on(Ti,function(t){e.sendText(t)}),this.textareaManager.on(Mi,function(){e.sendKeyCode(Vi.Backspace,ji.Down),e.sendKeyCode(Vi.Backspace,ji.Up)}),this.textareaManager.on(Ii,function(){e.sendKeyCode(Vi.Enter,ji.Down),e.sendKeyCode(Vi.Enter,ji.Up)}),this.textareaManager.on(Ni,function(){e.sendKeyCode(Vi.ArrowUp,ji.Down),e.sendKeyCode(Vi.ArrowUp,ji.Up)}),this.textareaManager.on(Di,function(){e.sendKeyCode(Vi.ArrowDown,ji.Down),e.sendKeyCode(Vi.ArrowDown,ji.Up)}),this.textareaManager.on(Pi,function(){e.sendKeyCode(Vi.ArrowLeft,ji.Down),e.sendKeyCode(Vi.ArrowLeft,ji.Up)}),this.textareaManager.on(Wi,function(){e.sendKeyCode(Vi.ArrowRight,ji.Down),e.sendKeyCode(Vi.ArrowRight,ji.Up)})}},{key:"observeContainerResize",value:function(){var e=this;"undefined"!=typeof ResizeObserver&&(this.resizeObserver=new ResizeObserver(function(){e.updateCanvasSize()}),this.resizeObserver.observe(this.container))}},{key:"on",value:function(e,t){return _(n,"on",this)([e,t]),this}},{key:"once",value:function(e,t){return _(n,"once",this)([e,t]),this}},{key:"off",value:function(e,t){return t?_(n,"off",this)([e,t]):_(n,"clear",this)([e]),this}},{key:"emit",value:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];_(n,"emit",this)([e].concat(r))}},{key:"start",value:(u=o(S().m(function e(){return S().w(function(e){for(;;)switch(e.p=e.n){case 0:if(!this.isRunning){e.n=1;break}return e.a(2);case 1:return this.isRunning=!0,this.retryCount=0,e.p=2,e.n=3,this.connectWithRetry();case 3:this.setupChannelStatusListener(),e.n=5;break;case 4:e.p=4,e.v;case 5:return e.a(2)}},e,this,[[2,4]])})),function(){return u.apply(this,arguments)})},{key:"connectWithRetry",value:(a=o(S().m(function t(){var n=this;return S().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t,r){var i=function(){var a=o(S().m(function o(){var a,s,u;return S().w(function(o){for(;;)switch(o.p=o.n){case 0:return o.p=0,o.n=1,n.internalStart();case 1:t(),o.n=4;break;case 2:if(o.p=2,u=o.v,n.isRunning){o.n=3;break}return console.log("[VmosEdgeClient] Connection stopped by user during handshake/start."),o.a(2);case 3:console.error("[VmosEdgeClient] Connection failed (Attempt ".concat(n.retryCount+1,"/").concat(n.maxRetries+1,"):"),u),n.retryCount<n.maxRetries&&n.isRunning?(n.retryCount++,a=Math.min(n.retryInterval*Math.pow(2,n.retryCount-1),1e4),console.log("[VmosEdgeClient] Retrying in ".concat(a,"ms...")),setTimeout(function(){n.isRunning?i():r(new Error("Stopped"))},a)):(s=n.extractErrorMessage(u)||"连接失败",n.emit(to.ERROR,{type:e.VmosEdgeErrorType.CONNECTION,code:e.VmosEdgeErrorCode.CONNECTION_FAILED,message:s}),n.stop(),r(u));case 4:return o.a(2)}},o,null,[[0,2]])}));return function(){return a.apply(this,arguments)}}();i()}))},t)})),function(){return a.apply(this,arguments)})},{key:"internalStart",value:(i=o(S().m(function t(){var n,r,i,o,a,s,u,c,l,f,h,d,v=this;return S().w(function(t){for(;;)switch(t.p=t.n){case 0:return this.canvas&&this.canvasContainer||this.initCanvas(),this.stopVideoSubscription&&(this.stopVideoSubscription(),this.stopVideoSubscription=null),n=new En({sendFrameMeta:!0,sendCodecMeta:!0,sendDeviceMeta:!0}),r=null,i=null,t.p=1,o=this.createVideoStream(),a=o.videoStream,s=o.stopVideoSubscription,r=s,t.n=2,this.performHandshake(n,a);case 2:u=t.v,c=u.metadata,l=u.stream,i=this.setupTouch(),this.createRenderer(),this.decoder=new yi({codec:c.codec,renderer:this.renderer,hardwareAcceleration:this.videoCodecPreference}),this.decoder.sizeChanged(function(e){var t=e.width,n=e.height,r=v.videoWidth,i=v.videoHeight;if(t!==r||n!==i){v.videoWidth=t,v.videoHeight=n;var o=t>n;0!==r&&0!==i&&r>i!==o&&(v.manualRotation=!1),v.manualRotation||(v.rotation=o?1:0),v.emitSizeChanged()}}),l.pipeThrough(n.createMediaStreamTransformer()).pipeThrough(no(function(){v.sendTouch(Ji.resetVideo())},function(){var e,t;return null!==(e=null===(t=v.decoder)||void 0===t?void 0:t.decodeQueueSize)&&void 0!==e?e:0})).pipeTo(this.decoder.writable).catch(function(t){var n,r;if(v.isRunning){console.error("[VmosEdgeClient] Video pipeline error:",t),null===(n=v.stopVideoSubscription)||void 0===n||n.call(v);var i=null===(r=v.config)||void 0===r?void 0:r.ports.video,o=v.extractErrorMessage(t)||"视频管道处理错误";v.emit(to.ERROR,{type:e.VmosEdgeErrorType.VIDEO,code:e.VmosEdgeErrorCode.VIDEO_PIPELINE_ERROR,message:o,port:i})}else console.log("[VmosEdgeClient] Video pipeline error: stopped by user during handshake/start.")}),this.bindInputEvents(),this.emit(to.STARTED),t.n=4;break;case 3:throw t.p=3,d=t.v,null===(f=r)||void 0===f||f(),null===(h=i)||void 0===h||h(),d;case 4:return t.a(2)}},t,this,[[1,3]])})),function(){return i.apply(this,arguments)})},{key:"createVideoStream",value:function(){var t,n,r=this,i=new ReadableStream({start:function(e){n=e},cancel:function(){var e;null===(e=r.stopVideoSubscription)||void 0===e||e.call(r)}}),o=function(t){var i;if(null!==n.desiredSize)try{var o=t instanceof Uint8Array?t:new Uint8Array(t);n.enqueue(o)}catch(t){var a;null===(a=r.stopVideoSubscription)||void 0===a||a.call(r);var s=r.extractErrorMessage(t)||"视频流数据处理错误";r.emit(to.ERROR,{type:e.VmosEdgeErrorType.VIDEO,code:e.VmosEdgeErrorCode.VIDEO_STREAM_ERROR,message:s})}else null===(i=r.stopVideoSubscription)||void 0===i||i.call(r)};return null===(t=this.device)||void 0===t||t.subscribe("video",o),this.stopVideoSubscription=function(){var e;null===(e=r.device)||void 0===e||e.unsubscribe("video",o),r.stopVideoSubscription=null;try{n&&null!==n.desiredSize&&n.close()}catch(e){if(e instanceof TypeError)return;console.error("[VmosEdgeClient] stopVideoSubscription error:",e)}},{videoStream:i,stopVideoSubscription:this.stopVideoSubscription}}},{key:"setupTouch",value:function(){var e,t=this,n=function(e){try{var n,r=Qi.parse(e);if((null==r?void 0:r.type)===Bi.Clipboard)t.emit(to.CLIPBOARD_CHANGED,null!==(n=null==r?void 0:r.content)&&void 0!==n?n:"")}catch(e){console.error("[VmosEdgeClient] Touch channel error:",e)}};return null===(e=this.device)||void 0===e||e.subscribe("touch",n),function(){var e;return null===(e=t.device)||void 0===e?void 0:e.unsubscribe("touch",n)}}},{key:"performHandshake",value:(r=o(S().m(function e(t,n){var r,i,o=this;return S().w(function(e){for(;;)switch(e.p=e.n){case 0:return r=null,i=new Promise(function(e,t){var n,i,a=!1,s=function(e){a||(a=!0,t(e))},u=function(e,t){console.error("[VmosEdgeClient] Handshake error on ".concat(e,":"),t),"video"===e&&s(new Error("Video channel connection failed"))},c=function(e){"video"===e&&s(new Error("Video channel closed unexpectedly during handshake"))};null===(n=o.device)||void 0===n||n.on("error",u),null===(i=o.device)||void 0===i||i.on("close",c),r=function(){var e,t;null===(e=o.device)||void 0===e||e.off("error",u),null===(t=o.device)||void 0===t||t.off("close",c)}}),e.p=1,e.n=2,Promise.race([t.parseVideoStreamMetadata(n),i]);case 2:return e.a(2,e.v);case 3:return e.p=3,r&&r(),e.f(3);case 4:return e.a(2)}},e,null,[[1,,3,4]])})),function(e,t){return r.apply(this,arguments)})},{key:"setGroupControlMode",value:function(e){if(this.isGroupControl=e,!e){var t,n=y(this.deviceTouchGroupMap.values());try{for(n.s();!(t=n.n()).done;){t.value.destroy()}}catch(e){n.e(e)}finally{n.f()}this.deviceTouchGroupMap.clear()}}},{key:"joinGroupControl",value:function(e){var t=this;if(this.isGroupControl){console.log("[VmosEdgeClient] joinGroupControl start",e);var n,r=y(e);try{var i=function(){var e=n.value;if(!e.deviceId)return 0;if(t.deviceTouchGroupMap.has(e.deviceId))return 0;var r=new Ri(e);r.subscribe("touch",function(){}),r.on("open",function(){t.emit(to.GROUP_CONTROL_JOINED,e)}),r.on("close",function(){r.destroy(),t.deviceTouchGroupMap.delete(e.deviceId),t.emit(to.GROUP_CONTROL_LEAVE,e)}),t.deviceTouchGroupMap.set(e.deviceId,r)};for(r.s();!(n=r.n()).done;)i()}catch(e){r.e(e)}finally{r.f()}}}},{key:"leaveGroupControl",value:function(e){if(this.isGroupControl){var t,n=y(e);try{for(n.s();!(t=n.n()).done;){var r,i=t.value;i.deviceId&&(this.deviceTouchGroupMap.has(i.deviceId)&&(null===(r=this.deviceTouchGroupMap.get(i.deviceId))||void 0===r||r.destroy(),this.deviceTouchGroupMap.delete(i.deviceId)))}}catch(e){n.e(e)}finally{n.f()}}}},{key:"stop",value:function(){var e,t,n;if(this.isRunning){if(this.isRunning=!1,null===(e=this.stopVideoSubscription)||void 0===e||e.call(this),this.unbindInputEvents(),null===(t=this.textareaManager)||void 0===t||t.destroy(),this.emit(to.STOPPED),this.isGroupControl){var r,i=y(this.deviceTouchGroupMap.values());try{for(i.s();!(r=i.n()).done;){r.value.destroy()}}catch(e){i.e(e)}finally{i.f()}this.deviceTouchGroupMap.clear()}if(this.clear(),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.canvasContainer&&this.canvasContainer.parentNode&&(this.canvasContainer.parentNode.removeChild(this.canvasContainer),this.canvasContainer=null,this.canvas=null),null===(n=this.device)||void 0===n||n.destroy(),this.renderer){try{this.renderer.dispose()}catch(e){console.warn("[VmosEdgeClient] Renderer dispose error:",e)}this.renderer=null}if(this.decoder){try{var o,a;null===(o=this.decoder)||void 0===o||null===(a=o.dispose)||void 0===a||a.call(o)}catch(e){console.warn("[VmosEdgeClient] Decoder dispose error:",e)}this.decoder=null}}}},{key:"emitSizeChanged",value:function(){var e=this.updateCanvasSize(),t={idealWidth:e.idealWidth,idealHeight:e.idealHeight,videoWidth:e.videoWidth,videoHeight:e.videoHeight,rotation:this.rotation};this.emit(to.SIZE_CHANGED,t)}},{key:"mapCoordinates",value:function(e,t){var n,r;switch(this.currentRotationAngle){case 90:n=t*this.videoWidth,r=(1-e)*this.videoHeight;break;case 270:n=(1-t)*this.videoWidth,r=e*this.videoHeight;break;default:n=e*this.videoWidth,r=t*this.videoHeight}return{x:n,y:r}}},{key:"updateCanvasSize",value:function(){if(!this.canvasContainer||!this.videoWidth||!this.videoHeight)return{idealWidth:0,idealHeight:0,videoWidth:0,videoHeight:0};var e,t,n=this.container,r=n.clientWidth,i=n.clientHeight,o=this.videoWidth,a=this.videoHeight,s=this.rotation,u=r,c=i,l=Math.max(u,c),f=Math.min(u,c);1===s?(e=l,t=f):(e=f,t=l);var h=Math.min(r/e,i/t,1),d=e*h,v=t*h,p=o>a,y=0,m=90===(y=1===s?p?0:270:p?90:0)||270===y,w=m?a:o,g=m?o:a,b=Math.min(d/w,v/g),E=w*b,k=g*b,C=this.canvasContainer.style;C.width="".concat(Math.ceil(E),"px"),C.height="".concat(Math.ceil(k),"px"),C.display="block",C.position="relative",C.transform="none";var S=this.canvas,x=S.style;S.width!==o&&(S.width=o),S.height!==a&&(S.height=a);var O=m?k:E,R=m?E:k;x.width="".concat(Math.ceil(O),"px"),x.height="".concat(Math.ceil(R),"px"),x.position="absolute",x.top="50%",x.left="50%",x.transformOrigin="center center",x.transform="translate(-50%, -50%) rotate(".concat(y,"deg)"),this.currentRotationAngle=y;var A=Math.min(e/w,t/g);return{idealWidth:w*A,idealHeight:g*A,videoWidth:o,videoHeight:a}}},{key:"createRenderer",value:function(){try{if(!Si.isSupported)throw new Error("WebGL not supported check");console.log("[VmosEdgeClient] Using WebGLVideoFrameRenderer"),this.renderer=new Si(this.canvas,this.renderPreference)}catch(e){console.warn("[VmosEdgeClient] WebGL initialization failed, falling back to Canvas2DRenderer:",e),this.replaceCanvas(),this.renderer=new xi(this.canvas)}}},{key:"bindInputEvents",value:function(){var e,t,n,r,i,o,a;null===(e=this.canvas)||void 0===e||e.addEventListener("pointerdown",this.handlePointerEvent),null===(t=this.canvas)||void 0===t||t.addEventListener("pointermove",this.handlePointerEvent),null===(n=this.canvas)||void 0===n||n.addEventListener("pointerup",this.handlePointerEvent),null===(r=this.canvas)||void 0===r||r.addEventListener("pointercancel",this.handlePointerEvent),null===(i=this.canvas)||void 0===i||i.addEventListener("pointerleave",this.handlePointerEvent),null===(o=this.canvas)||void 0===o||o.addEventListener("wheel",this.handleWheelEvent,{passive:!1}),null===(a=this.canvas)||void 0===a||a.addEventListener("contextmenu",this.handleContextMenu)}},{key:"unbindInputEvents",value:function(){var e,t,n,r,i,o,a;null===(e=this.canvas)||void 0===e||e.removeEventListener("pointerdown",this.handlePointerEvent),null===(t=this.canvas)||void 0===t||t.removeEventListener("pointermove",this.handlePointerEvent),null===(n=this.canvas)||void 0===n||n.removeEventListener("pointerup",this.handlePointerEvent),null===(r=this.canvas)||void 0===r||r.removeEventListener("pointercancel",this.handlePointerEvent),null===(i=this.canvas)||void 0===i||i.removeEventListener("pointerleave",this.handlePointerEvent),null===(o=this.canvas)||void 0===o||o.removeEventListener("wheel",this.handleWheelEvent),null===(a=this.canvas)||void 0===a||a.removeEventListener("contextmenu",this.handleContextMenu)}},{key:"handleContextMenu",value:function(e){e.preventDefault(),e.stopPropagation()}},{key:"handlePointerEvent",value:function(e){var t;if(this.videoWidth&&this.videoHeight){e.preventDefault(),e.stopPropagation();var r,i=this.canvas,o=e.type,a=e.clientX,s=e.clientY,u=e.button,c=e.buttons,l=e.pointerId;if("pointermove"===o){var f=Date.now();if(f-(this.pointerMoveThrottleMap.get(l)||0)<this.touchMoveInterval)return;this.pointerMoveThrottleMap.set(l,f)}if("pointerdown"===o){if(2===u)return void this.back();if(1===u)return void this.home()}else if("pointerup"===o){if(2===u||1===u)return}else if("pointermove"===o&&(2&c||4&c))return;switch(o){case"pointerdown":r=Fi.Down,i.setPointerCapture(l),null===(t=this.textareaManager)||void 0===t||t.focus();break;case"pointermove":if(0===c)return;r=Fi.Move;break;case"pointerup":case"pointercancel":case"pointerleave":r=Fi.Up,i.releasePointerCapture(l),this.pointerMoveThrottleMap.delete(l);break;default:return}var h=i.getBoundingClientRect(),d=Zi((a-h.x)/h.width,0,1),v=Zi((s-h.y)/h.height,0,1),p=this.mapCoordinates(d,v),y=p.x,m=p.y,w=Ji.injectTouch({action:r,pointerId:BigInt(l),pointerX:y,pointerY:m,screenWidth:this.videoWidth,screenHeight:this.videoHeight,pressure:0===c?0:1,actionButton:n.PointerEventButtonToAndroidButton[u]||Gi.Primary,buttons:c});this.sendTouch(w)}}},{key:"sendTouch",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(null===(t=this.device)||void 0===t||t.sendTouch(e),this.isGroupControl&&!n){var r,i=y(this.deviceTouchGroupMap.values());try{for(i.s();!(r=i.n()).done;){r.value.sendTouch(e)}}catch(e){i.e(e)}finally{i.f()}}}},{key:"handleWheelEvent",value:function(e){if(this.videoWidth&&this.videoHeight&&this.device){e.preventDefault(),e.stopPropagation();var t=this.canvas.getBoundingClientRect(),n=Zi((e.clientX-t.x)/t.width,0,1),r=Zi((e.clientY-t.y)/t.height,0,1),i=this.mapCoordinates(n,r),o=i.x,a=i.y,s=Ji.injectScroll({pointerX:o,pointerY:a,screenWidth:this.videoWidth,screenHeight:this.videoHeight,scrollX:-e.deltaX,scrollY:-e.deltaY,buttons:0});this.sendTouch(s)}}},{key:"sendText",value:function(e){this.device&&this.sendTouch(Ji.injectText({text:e}))}},{key:"sendKeyCode",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this.device&&this.sendTouch(Ji.injectKeyCode({keyCode:e,action:t,repeat:0,metaState:n}))}},{key:"clickKey",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.sendKeyCode(e,ji.Down,t),this.sendKeyCode(e,ji.Up,t)}},{key:"volumeUp",value:function(){this.clickKey(Vi.VolumeUp)}},{key:"volumeDown",value:function(){this.clickKey(Vi.VolumeDown)}},{key:"home",value:function(){this.clickKey(Vi.AndroidHome)}},{key:"back",value:function(){this.clickKey(Vi.AndroidBack)}},{key:"menu",value:function(){this.clickKey(Vi.AndroidAppSwitch)}},{key:"setRotation",value:function(e){this.rotation!==e&&(this.manualRotation=!0,this.rotation=e,this.emitSizeChanged())}},{key:"getRotation",value:function(){return this.rotation}},{key:"getRunningState",value:function(){return this.isRunning}},{key:"getVideoSize",value:function(){return{width:this.videoWidth,height:this.videoHeight}}},{key:"getConfig",value:function(){return this.config?C({},this.config):null}},{key:"getScale",value:function(){return this.canvas&&this.videoWidth?this.canvas.getBoundingClientRect().width/this.videoWidth:1}}]);var r,i,a,u}(Oi);return ro.PointerEventButtonToAndroidButton=[Gi.Primary,Gi.Tertiary,Gi.Secondary,Gi.Back,Gi.Forward],e.AndroidKeyCode=Vi,e.AndroidKeyEventAction=ji,e.AndroidMetaState={None:0,AltOn:2,AltLeftOn:16,AltRightOn:32,ShiftOn:1,ShiftLeftOn:64,ShiftRightOn:128,SymOn:4,FunctionOn:8,CtrlOn:4096,CtrlLeftOn:8192,CtrlRightOn:16384,MetaOn:65536,MetaLeftOn:131072,MetaRightOn:262144,CapsLockOn:1048576,NumLockOn:2097152,ScrollLockOn:4194304},e.AndroidMotionEventAction=Fi,e.AndroidMotionEventButton=Gi,e.VmosEdgeClient=ro,e.VmosEdgeClientEvents=to,e}({});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vmosedge/web-sdk",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "main": "./dist/index.cjs.js",
5
5
  "module": "./dist/index.es.js",
6
6
  "types": "./dist/types/index.d.ts",