/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/videomail-client@13.8.17/dist/esm/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
import{deserializeError,serializeError}from"serialize-error";import superagent from"superagent";import defined from"defined";import{UAParser}from"ua-parser-js";import get_form_data from"get-form-data";import{createNanoEvents}from"nanoevents";import deepmerge from"deepmerge";import document_visibility from"document-visibility";import contains from"contains";import animitter from"animitter";import canvas_to_buffer from"canvas-to-buffer";import websocket_stream from"websocket-stream";import audio_sample from"audio-sample";import is_power_of_two from"is-power-of-two";var __webpack_modules__={},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var i=__webpack_module_cache__[e]={id:e,exports:{}};return __webpack_modules__[e](i,i.exports,__webpack_require__),i.exports}__webpack_require__.m=__webpack_modules__,__webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var i in t)__webpack_require__.o(t,i)&&!__webpack_require__.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},__webpack_require__.add=function(e){Object.assign(__webpack_require__.m,e)},(()=>{__webpack_require__.g=(()=>{if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}})()})(),__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.nc=void 0,__webpack_require__.add({"./node_modules/@rsbuild/core/compiled/css-loader/index.js??ruleSet[1].rules[10].oneOf[2].use[1]!builtin:lightningcss-loader??ruleSet[1].rules[10].oneOf[2].use[2]!./node_modules/stylus-loader/dist/cjs.js??ruleSet[1].rules[10].oneOf[2].use[3]!./src/styles/main.styl"(e,t,i){i.d(t,{A:()=>a});var r=i("./node_modules/@rsbuild/core/compiled/css-loader/noSourceMaps.js"),o=i.n(r),n=i("./node_modules/@rsbuild/core/compiled/css-loader/api.js"),s=i.n(n)()(o());s.push([e.id,'@keyframes blink {\n  0% {\n    opacity: .9;\n  }\n\n  35% {\n    opacity: .9;\n  }\n\n  50% {\n    opacity: .1;\n  }\n\n  85% {\n    opacity: .1;\n  }\n\n  100% {\n    opacity: .9;\n  }\n}\n\n.videomail .visuals {\n  position: relative;\n}\n\n.videomail .visuals video.replay {\n  width: 100%;\n  height: 100%;\n}\n\n.videomail .countdown, .videomail .recordTimer, .videomail .recordNote, .videomail .pausedHeader, .videomail .pausedHint {\n  height: auto;\n  margin: 0;\n}\n\n.videomail .countdown, .videomail .recordTimer, .videomail .recordNote, .videomail .paused, .videomail .facingMode, .videomail noscript {\n  z-index: 100;\n  position: absolute;\n}\n\n.videomail .countdown, .videomail .recordTimer, .videomail .recordNote, .videomail .pausedHeader, .videomail .pausedHint, .videomail noscript {\n  font-weight: bold;\n}\n\n.videomail .countdown, .videomail .paused, .videomail noscript {\n  width: 100%;\n  top: 50%;\n  transform: translateY(-50%);\n}\n\n.videomail .pausedHeader, .videomail .pausedHint, .videomail .countdown {\n  text-align: center;\n  letter-spacing: 4px;\n  text-shadow: -2px 0 #fff, 0 2px #fff, 2px 0 #fff, 0 -2px #fff;\n}\n\n.videomail .pausedHeader, .videomail .countdown {\n  opacity: .9;\n  font-size: 460%;\n}\n\n.videomail .pausedHint {\n  font-size: 150%;\n}\n\n.videomail .facingMode {\n  color: #f5f5f5e6;\n  z-index: 10;\n  background: #1e1e1e80;\n  border: none;\n  outline: none;\n  padding: .1em .3em;\n  font-family: monospace;\n  font-size: 1.2em;\n  transition: all .2s;\n  bottom: .6em;\n  right: .7em;\n}\n\n.videomail .facingMode:hover {\n  cursor: pointer;\n  background: #323232b3;\n}\n\n.videomail .recordTimer, .videomail .recordNote {\n  color: #00d814;\n  opacity: .9;\n  background: #0a0a0acc;\n  padding: .3em .4em;\n  font-family: monospace;\n  transition: all 1s;\n  right: .7em;\n}\n\n.videomail .recordTimer.near, .videomail .recordNote.near {\n  color: #eb9369;\n}\n\n.videomail .recordTimer.nigh, .videomail .recordNote.nigh {\n  color: #ea4b2a;\n}\n\n.videomail .recordTimer {\n  top: .7em;\n}\n\n.videomail .recordNote {\n  top: 3.6em;\n}\n\n.videomail .recordNote:before {\n  content: "REC";\n  animation: 1s infinite blink;\n}\n\n.videomail .notifier {\n  box-sizing: border-box;\n  overflow: hidden;\n}\n\n.videomail .radioGroup {\n  display: block;\n}\n\n.videomail .radioGroup label {\n  cursor: pointer;\n}\n\n.videomail video {\n  margin-bottom: 0;\n}\n\n.videomail video.userMedia {\n  background-color: #3232321a;\n}\n',""]);const a=s},"./node_modules/base64-js/index.js"(e,t){t.byteLength=function(e){var t=a(e),i=t[0],r=t[1];return 3*(i+r)/4-r},t.toByteArray=function(e){var t,i,n=a(e),s=n[0],l=n[1],d=new o(function(e,t,i){return 3*(t+i)/4-i}(0,s,l)),u=0,h=l>0?s-4:s;for(i=0;i<h;i+=4)t=r[e.charCodeAt(i)]<<18|r[e.charCodeAt(i+1)]<<12|r[e.charCodeAt(i+2)]<<6|r[e.charCodeAt(i+3)],d[u++]=t>>16&255,d[u++]=t>>8&255,d[u++]=255&t;2===l&&(t=r[e.charCodeAt(i)]<<2|r[e.charCodeAt(i+1)]>>4,d[u++]=255&t);1===l&&(t=r[e.charCodeAt(i)]<<10|r[e.charCodeAt(i+1)]<<4|r[e.charCodeAt(i+2)]>>2,d[u++]=t>>8&255,d[u++]=255&t);return d},t.fromByteArray=function(e){for(var t,r=e.length,o=r%3,n=[],s=16383,a=0,d=r-o;a<d;a+=s)n.push(l(e,a,a+s>d?d:a+s));1===o?(t=e[r-1],n.push(i[t>>2]+i[t<<4&63]+"==")):2===o&&(t=(e[r-2]<<8)+e[r-1],n.push(i[t>>10]+i[t>>4&63]+i[t<<2&63]+"="));return n.join("")};for(var i=[],r=[],o="u">typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)i[s]=n[s],r[n.charCodeAt(s)]=s;function a(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var i=e.indexOf("=");return-1===i&&(i=t),[i,i===t?0:4-i%4]}function l(e,t,r){for(var o,n,s=[],a=t;a<r;a+=3)o=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(i[(n=o)>>18&63]+i[n>>12&63]+i[n>>6&63]+i[63&n]);return s.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},"./node_modules/buffer/index.js"(e,t,i){
/*!
 * The buffer module from node.js, for the browser.
 *
 * @author   Feross Aboukhadijeh <https://feross.org>
 * @license  MIT
 */
var r=i("./node_modules/base64-js/index.js"),o=i("./node_modules/ieee754/index.js"),n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=l,t.SlowBuffer=function(e){+e!=e&&(e=0);return l.alloc(+e)},t.INSPECT_MAX_BYTES=50;var s=2147483647;function a(e){if(e>s)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,l.prototype),t}function l(e,t,i){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return h(e)}return d(e,t,i)}function d(e,t,i){if("string"==typeof e)return function(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!l.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var i=0|f(e,t),r=a(i),o=r.write(e,t);o!==i&&(r=r.slice(0,o));return r}(e,t);if(ArrayBuffer.isView(e))return function(e){if(F(e,Uint8Array)){var t=new Uint8Array(e);return p(t.buffer,t.byteOffset,t.byteLength)}return c(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(F(e,ArrayBuffer)||e&&F(e.buffer,ArrayBuffer))return p(e,t,i);if("u">typeof SharedArrayBuffer&&(F(e,SharedArrayBuffer)||e&&F(e.buffer,SharedArrayBuffer)))return p(e,t,i);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var r=e.valueOf&&e.valueOf();if(null!=r&&r!==e)return l.from(r,t,i);var o=function(e){if(l.isBuffer(e)){var t=0|m(e.length),i=a(t);return 0===i.length||e.copy(i,0,0,t),i}if(void 0!==e.length)return"number"!=typeof e.length||W(e.length)?a(0):c(e);if("Buffer"===e.type&&Array.isArray(e.data))return c(e.data)}(e);if(o)return o;if("u">typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return l.from(e[Symbol.toPrimitive]("string"),t,i);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function u(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function h(e){return u(e),a(e<0?0:0|m(e))}function c(e){for(var t=e.length<0?0:0|m(e.length),i=a(t),r=0;r<t;r+=1)i[r]=255&e[r];return i}function p(e,t,i){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(i||0))throw new RangeError('"length" is outside of buffer bounds');var r;return r=void 0===t&&void 0===i?new Uint8Array(e):void 0===i?new Uint8Array(e,t):new Uint8Array(e,t,i),Object.setPrototypeOf(r,l.prototype),r}function m(e){if(e>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|e}function f(e,t){if(l.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||F(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var i=e.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===i)return 0;for(var o=!1;;)switch(t){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":return L(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return U(e).length;default:if(o)return r?-1:L(e).length;t=(""+t).toLowerCase(),o=!0}}function g(e,t,i){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return I(this,t,i);case"utf8":case"utf-8":return M(this,t,i);case"ascii":return T(this,t,i);case"latin1":case"binary":return B(this,t,i);case"base64":return S(this,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,t,i);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function y(e,t,i){var r=e[t];e[t]=e[i],e[i]=r}function b(e,t,i,r,o){if(0===e.length)return-1;if("string"==typeof i?(r=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),W(i*=1)&&(i=o?0:e.length-1),i<0&&(i=e.length+i),i>=e.length){if(o)return-1;i=e.length-1}else if(i<0){if(!o)return-1;i=0}if("string"==typeof t&&(t=l.from(t,r)),l.isBuffer(t))return 0===t.length?-1:E(e,t,i,r,o);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,i):Uint8Array.prototype.lastIndexOf.call(e,t,i):E(e,[t],i,r,o);throw new TypeError("val must be string, number or Buffer")}function E(e,t,i,r,o){var n,s=1,a=e.length,l=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,l/=2,i/=2}function d(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){var u=-1;for(n=i;n<a;n++)if(d(e,n)===d(t,-1===u?0:n-u)){if(-1===u&&(u=n),n-u+1===l)return u*s}else-1!==u&&(n-=n-u),u=-1}else for(i+l>a&&(i=a-l),n=i;n>=0;n--){for(var h=!0,c=0;c<l;c++)if(d(e,n+c)!==d(t,c)){h=!1;break}if(h)return n}return-1}function _(e,t,i,r){i=Number(i)||0;var o=e.length-i;r?(r=Number(r))>o&&(r=o):r=o;var n=t.length;r>n/2&&(r=n/2);for(var s=0;s<r;++s){var a=parseInt(t.substr(2*s,2),16);if(W(a))break;e[i+s]=a}return s}function v(e,t,i,r){return V(L(t,e.length-i),e,i,r)}function w(e,t,i,r){return V(function(e){for(var t=[],i=0;i<e.length;++i)t.push(255&e.charCodeAt(i));return t}(t),e,i,r)}function R(e,t,i,r){return V(U(t),e,i,r)}function A(e,t,i,r){return V(function(e,t){for(var i,r,o,n=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(i=e.charCodeAt(s))>>8,o=i%256,n.push(o),n.push(r);return n}(t,e.length-i),e,i,r)}function S(e,t,i){return 0===t&&i===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,i))}function M(e,t,i){i=Math.min(e.length,i);for(var r=[],o=t;o<i;){var n,s,a,l,d=e[o],u=null,h=d>239?4:d>223?3:d>191?2:1;if(o+h<=i)switch(h){case 1:d<128&&(u=d);break;case 2:128==(192&(n=e[o+1]))&&(l=(31&d)<<6|63&n)>127&&(u=l);break;case 3:n=e[o+1],s=e[o+2],128==(192&n)&&128==(192&s)&&(l=(15&d)<<12|(63&n)<<6|63&s)>2047&&(l<55296||l>57343)&&(u=l);break;case 4:n=e[o+1],s=e[o+2],a=e[o+3],128==(192&n)&&128==(192&s)&&128==(192&a)&&(l=(15&d)<<18|(63&n)<<12|(63&s)<<6|63&a)>65535&&l<1114112&&(u=l)}null===u?(u=65533,h=1):u>65535&&(u-=65536,r.push(u>>>10&1023|55296),u=56320|1023&u),r.push(u),o+=h}return function(e){var t=e.length;if(t<=O)return String.fromCharCode.apply(String,e);var i="",r=0;for(;r<t;)i+=String.fromCharCode.apply(String,e.slice(r,r+=O));return i}(r)}t.kMaxLength=s,l.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),!l.TYPED_ARRAY_SUPPORT&&"u">typeof console&&"function"==typeof console.error&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(l.prototype,"parent",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.buffer}}),Object.defineProperty(l.prototype,"offset",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.byteOffset}}),l.poolSize=8192,l.from=function(e,t,i){return d(e,t,i)},Object.setPrototypeOf(l.prototype,Uint8Array.prototype),Object.setPrototypeOf(l,Uint8Array),l.alloc=function(e,t,i){return function(e,t,i){return u(e),e<=0?a(e):void 0!==t?"string"==typeof i?a(e).fill(t,i):a(e).fill(t):a(e)}(e,t,i)},l.allocUnsafe=function(e){return h(e)},l.allocUnsafeSlow=function(e){return h(e)},l.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==l.prototype},l.compare=function(e,t){if(F(e,Uint8Array)&&(e=l.from(e,e.offset,e.byteLength)),F(t,Uint8Array)&&(t=l.from(t,t.offset,t.byteLength)),!l.isBuffer(e)||!l.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var i=e.length,r=t.length,o=0,n=Math.min(i,r);o<n;++o)if(e[o]!==t[o]){i=e[o],r=t[o];break}return i<r?-1:r<i?1:0},l.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},l.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return l.alloc(0);var i;if(void 0===t)for(t=0,i=0;i<e.length;++i)t+=e[i].length;var r=l.allocUnsafe(t),o=0;for(i=0;i<e.length;++i){var n=e[i];if(F(n,Uint8Array))o+n.length>r.length?l.from(n).copy(r,o):Uint8Array.prototype.set.call(r,n,o);else{if(!l.isBuffer(n))throw new TypeError('"list" argument must be an Array of Buffers');n.copy(r,o)}o+=n.length}return r},l.byteLength=f,l.prototype._isBuffer=!0,l.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)y(this,t,t+1);return this},l.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)y(this,t,t+3),y(this,t+1,t+2);return this},l.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)y(this,t,t+7),y(this,t+1,t+6),y(this,t+2,t+5),y(this,t+3,t+4);return this},l.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?M(this,0,e):g.apply(this,arguments)},l.prototype.toLocaleString=l.prototype.toString,l.prototype.equals=function(e){if(!l.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===l.compare(this,e)},l.prototype.inspect=function(){var e="",i=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,i).replace(/(.{2})/g,"$1 ").trim(),this.length>i&&(e+=" ... "),"<Buffer "+e+">"},n&&(l.prototype[n]=l.prototype.inspect),l.prototype.compare=function(e,t,i,r,o){if(F(e,Uint8Array)&&(e=l.from(e,e.offset,e.byteLength)),!l.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===i&&(i=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||i>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=i)return 0;if(r>=o)return-1;if(t>=i)return 1;if(this===e)return 0;for(var n=(o>>>=0)-(r>>>=0),s=(i>>>=0)-(t>>>=0),a=Math.min(n,s),d=this.slice(r,o),u=e.slice(t,i),h=0;h<a;++h)if(d[h]!==u[h]){n=d[h],s=u[h];break}return n<s?-1:s<n?1:0},l.prototype.includes=function(e,t,i){return-1!==this.indexOf(e,t,i)},l.prototype.indexOf=function(e,t,i){return b(this,e,t,i,!0)},l.prototype.lastIndexOf=function(e,t,i){return b(this,e,t,i,!1)},l.prototype.write=function(e,t,i,r){if(void 0===t)r="utf8",i=this.length,t=0;else if(void 0===i&&"string"==typeof t)r=t,i=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(i)?(i>>>=0,void 0===r&&(r="utf8")):(r=i,i=void 0)}var o=this.length-t;if((void 0===i||i>o)&&(i=o),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var n=!1;;)switch(r){case"hex":return _(this,e,t,i);case"utf8":case"utf-8":return v(this,e,t,i);case"ascii":case"latin1":case"binary":return w(this,e,t,i);case"base64":return R(this,e,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,t,i);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),n=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var O=4096;function T(e,t,i){var r="";i=Math.min(e.length,i);for(var o=t;o<i;++o)r+=String.fromCharCode(127&e[o]);return r}function B(e,t,i){var r="";i=Math.min(e.length,i);for(var o=t;o<i;++o)r+=String.fromCharCode(e[o]);return r}function I(e,t,i){var r=e.length;(!t||t<0)&&(t=0),(!i||i<0||i>r)&&(i=r);for(var o="",n=t;n<i;++n)o+=$[e[n]];return o}function P(e,t,i){for(var r=e.slice(t,i),o="",n=0;n<r.length-1;n+=2)o+=String.fromCharCode(r[n]+256*r[n+1]);return o}function j(e,t,i){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>i)throw new RangeError("Trying to access beyond buffer length")}function x(e,t,i,r,o,n){if(!l.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<n)throw new RangeError('"value" argument is out of bounds');if(i+r>e.length)throw new RangeError("Index out of range")}function N(e,t,i,r,o,n){if(i+r>e.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function C(e,t,i,r,n){return t*=1,i>>>=0,n||N(e,0,i,4),o.write(e,t,i,r,23,4),i+4}function k(e,t,i,r,n){return t*=1,i>>>=0,n||N(e,0,i,8),o.write(e,t,i,r,52,8),i+8}l.prototype.slice=function(e,t){var i=this.length;(e=~~e)<0?(e+=i)<0&&(e=0):e>i&&(e=i),(t=void 0===t?i:~~t)<0?(t+=i)<0&&(t=0):t>i&&(t=i),t<e&&(t=e);var r=this.subarray(e,t);return Object.setPrototypeOf(r,l.prototype),r},l.prototype.readUintLE=l.prototype.readUIntLE=function(e,t,i){e>>>=0,t>>>=0,i||j(e,t,this.length);for(var r=this[e],o=1,n=0;++n<t&&(o*=256);)r+=this[e+n]*o;return r},l.prototype.readUintBE=l.prototype.readUIntBE=function(e,t,i){e>>>=0,t>>>=0,i||j(e,t,this.length);for(var r=this[e+--t],o=1;t>0&&(o*=256);)r+=this[e+--t]*o;return r},l.prototype.readUint8=l.prototype.readUInt8=function(e,t){return e>>>=0,t||j(e,1,this.length),this[e]},l.prototype.readUint16LE=l.prototype.readUInt16LE=function(e,t){return e>>>=0,t||j(e,2,this.length),this[e]|this[e+1]<<8},l.prototype.readUint16BE=l.prototype.readUInt16BE=function(e,t){return e>>>=0,t||j(e,2,this.length),this[e]<<8|this[e+1]},l.prototype.readUint32LE=l.prototype.readUInt32LE=function(e,t){return e>>>=0,t||j(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},l.prototype.readUint32BE=l.prototype.readUInt32BE=function(e,t){return e>>>=0,t||j(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},l.prototype.readIntLE=function(e,t,i){e>>>=0,t>>>=0,i||j(e,t,this.length);for(var r=this[e],o=1,n=0;++n<t&&(o*=256);)r+=this[e+n]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*t)),r},l.prototype.readIntBE=function(e,t,i){e>>>=0,t>>>=0,i||j(e,t,this.length);for(var r=t,o=1,n=this[e+--r];r>0&&(o*=256);)n+=this[e+--r]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*t)),n},l.prototype.readInt8=function(e,t){return e>>>=0,t||j(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},l.prototype.readInt16LE=function(e,t){e>>>=0,t||j(e,2,this.length);var i=this[e]|this[e+1]<<8;return 32768&i?4294901760|i:i},l.prototype.readInt16BE=function(e,t){e>>>=0,t||j(e,2,this.length);var i=this[e+1]|this[e]<<8;return 32768&i?4294901760|i:i},l.prototype.readInt32LE=function(e,t){return e>>>=0,t||j(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},l.prototype.readInt32BE=function(e,t){return e>>>=0,t||j(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},l.prototype.readFloatLE=function(e,t){return e>>>=0,t||j(e,4,this.length),o.read(this,e,!0,23,4)},l.prototype.readFloatBE=function(e,t){return e>>>=0,t||j(e,4,this.length),o.read(this,e,!1,23,4)},l.prototype.readDoubleLE=function(e,t){return e>>>=0,t||j(e,8,this.length),o.read(this,e,!0,52,8)},l.prototype.readDoubleBE=function(e,t){return e>>>=0,t||j(e,8,this.length),o.read(this,e,!1,52,8)},l.prototype.writeUintLE=l.prototype.writeUIntLE=function(e,t,i,r){(e*=1,t>>>=0,i>>>=0,r)||x(this,e,t,i,Math.pow(2,8*i)-1,0);var o=1,n=0;for(this[t]=255&e;++n<i&&(o*=256);)this[t+n]=e/o&255;return t+i},l.prototype.writeUintBE=l.prototype.writeUIntBE=function(e,t,i,r){(e*=1,t>>>=0,i>>>=0,r)||x(this,e,t,i,Math.pow(2,8*i)-1,0);var o=i-1,n=1;for(this[t+o]=255&e;--o>=0&&(n*=256);)this[t+o]=e/n&255;return t+i},l.prototype.writeUint8=l.prototype.writeUInt8=function(e,t,i){return e*=1,t>>>=0,i||x(this,e,t,1,255,0),this[t]=255&e,t+1},l.prototype.writeUint16LE=l.prototype.writeUInt16LE=function(e,t,i){return e*=1,t>>>=0,i||x(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},l.prototype.writeUint16BE=l.prototype.writeUInt16BE=function(e,t,i){return e*=1,t>>>=0,i||x(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},l.prototype.writeUint32LE=l.prototype.writeUInt32LE=function(e,t,i){return e*=1,t>>>=0,i||x(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},l.prototype.writeUint32BE=l.prototype.writeUInt32BE=function(e,t,i){return e*=1,t>>>=0,i||x(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},l.prototype.writeIntLE=function(e,t,i,r){if(e*=1,t>>>=0,!r){var o=Math.pow(2,8*i-1);x(this,e,t,i,o-1,-o)}var n=0,s=1,a=0;for(this[t]=255&e;++n<i&&(s*=256);)e<0&&0===a&&0!==this[t+n-1]&&(a=1),this[t+n]=(e/s|0)-a&255;return t+i},l.prototype.writeIntBE=function(e,t,i,r){if(e*=1,t>>>=0,!r){var o=Math.pow(2,8*i-1);x(this,e,t,i,o-1,-o)}var n=i-1,s=1,a=0;for(this[t+n]=255&e;--n>=0&&(s*=256);)e<0&&0===a&&0!==this[t+n+1]&&(a=1),this[t+n]=(e/s|0)-a&255;return t+i},l.prototype.writeInt8=function(e,t,i){return e*=1,t>>>=0,i||x(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},l.prototype.writeInt16LE=function(e,t,i){return e*=1,t>>>=0,i||x(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},l.prototype.writeInt16BE=function(e,t,i){return e*=1,t>>>=0,i||x(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},l.prototype.writeInt32LE=function(e,t,i){return e*=1,t>>>=0,i||x(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},l.prototype.writeInt32BE=function(e,t,i){return e*=1,t>>>=0,i||x(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},l.prototype.writeFloatLE=function(e,t,i){return C(this,e,t,!0,i)},l.prototype.writeFloatBE=function(e,t,i){return C(this,e,t,!1,i)},l.prototype.writeDoubleLE=function(e,t,i){return k(this,e,t,!0,i)},l.prototype.writeDoubleBE=function(e,t,i){return k(this,e,t,!1,i)},l.prototype.copy=function(e,t,i,r){if(!l.isBuffer(e))throw new TypeError("argument should be a Buffer");if(i||(i=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<i&&(r=i),r===i)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-i&&(r=e.length-t+i);var o=r-i;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,i,r):Uint8Array.prototype.set.call(e,this.subarray(i,r),t),o},l.prototype.fill=function(e,t,i,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,i=this.length):"string"==typeof i&&(r=i,i=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!l.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===e.length){var o=e.charCodeAt(0);("utf8"===r&&o<128||"latin1"===r)&&(e=o)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<i)throw new RangeError("Out of range index");if(i<=t)return this;var n;if(t>>>=0,i=void 0===i?this.length:i>>>0,e||(e=0),"number"==typeof e)for(n=t;n<i;++n)this[n]=e;else{var s=l.isBuffer(e)?e:l.from(e,r),a=s.length;if(0===a)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(n=0;n<i-t;++n)this[n+t]=s[n%a]}return this};var D=/[^+/0-9A-Za-z-_]/g;function L(e,t){var i;t=t||1/0;for(var r=e.length,o=null,n=[],s=0;s<r;++s){if((i=e.charCodeAt(s))>55295&&i<57344){if(!o){if(i>56319){(t-=3)>-1&&n.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&n.push(239,191,189);continue}o=i;continue}if(i<56320){(t-=3)>-1&&n.push(239,191,189),o=i;continue}i=65536+(o-55296<<10|i-56320)}else o&&(t-=3)>-1&&n.push(239,191,189);if(o=null,i<128){if((t-=1)<0)break;n.push(i)}else if(i<2048){if((t-=2)<0)break;n.push(i>>6|192,63&i|128)}else if(i<65536){if((t-=3)<0)break;n.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;n.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return n}function U(e){return r.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(D,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function V(e,t,i,r){for(var o=0;o<r&&!(o+i>=t.length||o>=e.length);++o)t[o+i]=e[o];return o}function F(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function W(e){return e!=e}var $=function(){for(var e="0123456789abcdef",t=new Array(256),i=0;i<16;++i)for(var r=16*i,o=0;o<16;++o)t[r+o]=e[i]+e[o];return t}()},"./node_modules/call-bind-apply-helpers/actualApply.js"(e,t,i){var r=i("./node_modules/function-bind/index.js"),o=i("./node_modules/call-bind-apply-helpers/functionApply.js"),n=i("./node_modules/call-bind-apply-helpers/functionCall.js"),s=i("./node_modules/call-bind-apply-helpers/reflectApply.js");e.exports=s||r.call(n,o)},"./node_modules/call-bind-apply-helpers/applyBind.js"(e,t,i){var r=i("./node_modules/function-bind/index.js"),o=i("./node_modules/call-bind-apply-helpers/functionApply.js"),n=i("./node_modules/call-bind-apply-helpers/actualApply.js");e.exports=function(){return n(r,o,arguments)}},"./node_modules/call-bind-apply-helpers/functionApply.js"(e){e.exports=Function.prototype.apply},"./node_modules/call-bind-apply-helpers/functionCall.js"(e){e.exports=Function.prototype.call},"./node_modules/call-bind-apply-helpers/index.js"(e,t,i){var r=i("./node_modules/function-bind/index.js"),o=i("./node_modules/es-errors/type.js"),n=i("./node_modules/call-bind-apply-helpers/functionCall.js"),s=i("./node_modules/call-bind-apply-helpers/actualApply.js");e.exports=function(e){if(e.length<1||"function"!=typeof e[0])throw new o("a function is required");return s(r,n,e)}},"./node_modules/call-bind-apply-helpers/reflectApply.js"(e){e.exports="u">typeof Reflect&&Reflect&&Reflect.apply},"./node_modules/call-bind/index.js"(e,t,i){var r=i("./node_modules/set-function-length/index.js"),o=i("./node_modules/es-define-property/index.js"),n=i("./node_modules/call-bind-apply-helpers/index.js"),s=i("./node_modules/call-bind-apply-helpers/applyBind.js");e.exports=function(e){var t=n(arguments),i=e.length-(arguments.length-1);return r(t,1+(i>0?i:0),!0)},o?o(e.exports,"apply",{value:s}):e.exports.apply=s},"./node_modules/call-bound/index.js"(e,t,i){var r=i("./node_modules/get-intrinsic/index.js"),o=i("./node_modules/call-bind-apply-helpers/index.js"),n=o([r("%String.prototype.indexOf%")]);e.exports=function(e,t){var i=r(e,!!t);return"function"==typeof i&&n(e,".prototype.")>-1?o([i]):i}},"./node_modules/define-data-property/index.js"(e,t,i){var r=i("./node_modules/es-define-property/index.js"),o=i("./node_modules/es-errors/syntax.js"),n=i("./node_modules/es-errors/type.js"),s=i("./node_modules/gopd/index.js");e.exports=function(e,t,i){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new n("`obj` must be an object or a function`");if("string"!=typeof t&&"symbol"!=typeof t)throw new n("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new n("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new n("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new n("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new n("`loose`, if provided, must be a boolean");var a=arguments.length>3?arguments[3]:null,l=arguments.length>4?arguments[4]:null,d=arguments.length>5?arguments[5]:null,u=arguments.length>6&&arguments[6],h=!!s&&s(e,t);if(r)r(e,t,{configurable:null===d&&h?h.configurable:!d,enumerable:null===a&&h?h.enumerable:!a,value:i,writable:null===l&&h?h.writable:!l});else{if(!u&&(a||l||d))throw new o("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");e[t]=i}}},"./node_modules/dunder-proto/get.js"(e,t,i){var r,o=i("./node_modules/call-bind-apply-helpers/index.js"),n=i("./node_modules/gopd/index.js");try{r=[].__proto__===Array.prototype}catch(e){if(!e||"object"!=typeof e||!("code"in e)||"ERR_PROTO_ACCESS"!==e.code)throw e}var s=!!r&&n&&n(Object.prototype,"__proto__"),a=Object,l=a.getPrototypeOf;e.exports=s&&"function"==typeof s.get?o([s.get]):"function"==typeof l&&function(e){return l(null==e?e:a(e))}},"./node_modules/es-define-property/index.js"(e){var t=Object.defineProperty||!1;if(t)try{t({},"a",{value:1})}catch(e){t=!1}e.exports=t},"./node_modules/es-errors/eval.js"(e){e.exports=EvalError},"./node_modules/es-errors/index.js"(e){e.exports=Error},"./node_modules/es-errors/range.js"(e){e.exports=RangeError},"./node_modules/es-errors/ref.js"(e){e.exports=ReferenceError},"./node_modules/es-errors/syntax.js"(e){e.exports=SyntaxError},"./node_modules/es-errors/type.js"(e){e.exports=TypeError},"./node_modules/es-errors/uri.js"(e){e.exports=URIError},"./node_modules/es-object-atoms/index.js"(e){e.exports=Object},"./node_modules/for-each/index.js"(e,t,i){var r=i("./node_modules/is-callable/index.js"),o=Object.prototype.toString,n=Object.prototype.hasOwnProperty;e.exports=function(e,t,i){if(!r(t))throw new TypeError("iterator must be a function");var s,a;arguments.length>=3&&(s=i),a=e,"[object Array]"===o.call(a)?function(e,t,i){for(var r=0,o=e.length;r<o;r++)n.call(e,r)&&(null==i?t(e[r],r,e):t.call(i,e[r],r,e))}(e,t,s):"string"==typeof e?function(e,t,i){for(var r=0,o=e.length;r<o;r++)null==i?t(e.charAt(r),r,e):t.call(i,e.charAt(r),r,e)}(e,t,s):function(e,t,i){for(var r in e)n.call(e,r)&&(null==i?t(e[r],r,e):t.call(i,e[r],r,e))}(e,t,s)}},"./node_modules/function-bind/implementation.js"(e){var t=Object.prototype.toString,i=Math.max,r=function(e,t){for(var i=[],r=0;r<e.length;r+=1)i[r]=e[r];for(var o=0;o<t.length;o+=1)i[o+e.length]=t[o];return i};e.exports=function(e){var o=this;if("function"!=typeof o||"[object Function]"!==t.apply(o))throw new TypeError("Function.prototype.bind called on incompatible "+o);for(var n,s=function(e,t){for(var i=[],r=t||0,o=0;r<e.length;r+=1,o+=1)i[o]=e[r];return i}(arguments,1),a=i(0,o.length-s.length),l=[],d=0;d<a;d++)l[d]="$"+d;if(n=Function("binder","return function ("+function(e,t){for(var i="",r=0;r<e.length;r+=1)i+=e[r],r+1<e.length&&(i+=t);return i}(l,",")+"){ return binder.apply(this,arguments); }")((function(){if(this instanceof n){var t=o.apply(this,r(s,arguments));return Object(t)===t?t:this}return o.apply(e,r(s,arguments))})),o.prototype){var u=function(){};u.prototype=o.prototype,n.prototype=new u,u.prototype=null}return n}},"./node_modules/function-bind/index.js"(e,t,i){var r=i("./node_modules/function-bind/implementation.js");e.exports=Function.prototype.bind||r},"./node_modules/generator-function/index.js"(e){const t=function*(){}.constructor;e.exports=()=>t},"./node_modules/get-intrinsic/index.js"(e,t,i){var r,o=i("./node_modules/es-object-atoms/index.js"),n=i("./node_modules/es-errors/index.js"),s=i("./node_modules/es-errors/eval.js"),a=i("./node_modules/es-errors/range.js"),l=i("./node_modules/es-errors/ref.js"),d=i("./node_modules/es-errors/syntax.js"),u=i("./node_modules/es-errors/type.js"),h=i("./node_modules/es-errors/uri.js"),c=i("./node_modules/math-intrinsics/abs.js"),p=i("./node_modules/math-intrinsics/floor.js"),m=i("./node_modules/math-intrinsics/max.js"),f=i("./node_modules/math-intrinsics/min.js"),g=i("./node_modules/math-intrinsics/pow.js"),y=i("./node_modules/math-intrinsics/round.js"),b=i("./node_modules/math-intrinsics/sign.js"),E=Function,_=function(e){try{return E('"use strict"; return ('+e+").constructor;")()}catch(e){}},v=i("./node_modules/gopd/index.js"),w=i("./node_modules/es-define-property/index.js"),R=function(){throw new u},A=v?function(){try{return R}catch(e){try{return v(arguments,"callee").get}catch(e){return R}}}():R,S=i("./node_modules/has-symbols/index.js")(),M=i("./node_modules/get-proto/index.js"),O=i("./node_modules/get-proto/Object.getPrototypeOf.js"),T=i("./node_modules/get-proto/Reflect.getPrototypeOf.js"),B=i("./node_modules/call-bind-apply-helpers/functionApply.js"),I=i("./node_modules/call-bind-apply-helpers/functionCall.js"),P={},j="u">typeof Uint8Array&&M?M(Uint8Array):r,x={__proto__:null,"%AggregateError%":"u"<typeof AggregateError?r:AggregateError,"%Array%":Array,"%ArrayBuffer%":"u"<typeof ArrayBuffer?r:ArrayBuffer,"%ArrayIteratorPrototype%":S&&M?M([][Symbol.iterator]()):r,"%AsyncFromSyncIteratorPrototype%":r,"%AsyncFunction%":P,"%AsyncGenerator%":P,"%AsyncGeneratorFunction%":P,"%AsyncIteratorPrototype%":P,"%Atomics%":"u"<typeof Atomics?r:Atomics,"%BigInt%":"u"<typeof BigInt?r:BigInt,"%BigInt64Array%":"u"<typeof BigInt64Array?r:BigInt64Array,"%BigUint64Array%":"u"<typeof BigUint64Array?r:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"u"<typeof DataView?r:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":n,"%eval%":eval,"%EvalError%":s,"%Float16Array%":"u"<typeof Float16Array?r:Float16Array,"%Float32Array%":"u"<typeof Float32Array?r:Float32Array,"%Float64Array%":"u"<typeof Float64Array?r:Float64Array,"%FinalizationRegistry%":"u"<typeof FinalizationRegistry?r:FinalizationRegistry,"%Function%":E,"%GeneratorFunction%":P,"%Int8Array%":"u"<typeof Int8Array?r:Int8Array,"%Int16Array%":"u"<typeof Int16Array?r:Int16Array,"%Int32Array%":"u"<typeof Int32Array?r:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":S&&M?M(M([][Symbol.iterator]())):r,"%JSON%":"object"==typeof JSON?JSON:r,"%Map%":"u"<typeof Map?r:Map,"%MapIteratorPrototype%":"u">typeof Map&&S&&M?M((new Map)[Symbol.iterator]()):r,"%Math%":Math,"%Number%":Number,"%Object%":o,"%Object.getOwnPropertyDescriptor%":v,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"u"<typeof Promise?r:Promise,"%Proxy%":"u"<typeof Proxy?r:Proxy,"%RangeError%":a,"%ReferenceError%":l,"%Reflect%":"u"<typeof Reflect?r:Reflect,"%RegExp%":RegExp,"%Set%":"u"<typeof Set?r:Set,"%SetIteratorPrototype%":"u">typeof Set&&S&&M?M((new Set)[Symbol.iterator]()):r,"%SharedArrayBuffer%":"u"<typeof SharedArrayBuffer?r:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":S&&M?M(""[Symbol.iterator]()):r,"%Symbol%":S?Symbol:r,"%SyntaxError%":d,"%ThrowTypeError%":A,"%TypedArray%":j,"%TypeError%":u,"%Uint8Array%":"u"<typeof Uint8Array?r:Uint8Array,"%Uint8ClampedArray%":"u"<typeof Uint8ClampedArray?r:Uint8ClampedArray,"%Uint16Array%":"u"<typeof Uint16Array?r:Uint16Array,"%Uint32Array%":"u"<typeof Uint32Array?r:Uint32Array,"%URIError%":h,"%WeakMap%":"u"<typeof WeakMap?r:WeakMap,"%WeakRef%":"u"<typeof WeakRef?r:WeakRef,"%WeakSet%":"u"<typeof WeakSet?r:WeakSet,"%Function.prototype.call%":I,"%Function.prototype.apply%":B,"%Object.defineProperty%":w,"%Object.getPrototypeOf%":O,"%Math.abs%":c,"%Math.floor%":p,"%Math.max%":m,"%Math.min%":f,"%Math.pow%":g,"%Math.round%":y,"%Math.sign%":b,"%Reflect.getPrototypeOf%":T};if(M)try{null.error}catch(e){var N=M(M(e));x["%Error.prototype%"]=N}var C=function e(t){var i;if("%AsyncFunction%"===t)i=_("async function () {}");else if("%GeneratorFunction%"===t)i=_("function* () {}");else if("%AsyncGeneratorFunction%"===t)i=_("async function* () {}");else if("%AsyncGenerator%"===t){var r=e("%AsyncGeneratorFunction%");r&&(i=r.prototype)}else if("%AsyncIteratorPrototype%"===t){var o=e("%AsyncGenerator%");o&&M&&(i=M(o.prototype))}return x[t]=i,i},k={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},D=i("./node_modules/function-bind/index.js"),L=i("./node_modules/hasown/index.js"),U=D.call(I,Array.prototype.concat),V=D.call(B,Array.prototype.splice),F=D.call(I,String.prototype.replace),W=D.call(I,String.prototype.slice),$=D.call(I,RegExp.prototype.exec),H=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,G=/\\(\\)?/g,q=function(e,t){var i,r=e;if(L(k,r)&&(r="%"+(i=k[r])[0]+"%"),L(x,r)){var o=x[r];if(o===P&&(o=C(r)),void 0===o&&!t)throw new u("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:r,value:o}}throw new d("intrinsic "+e+" does not exist!")};e.exports=function(e,t){if("string"!=typeof e||0===e.length)throw new u("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new u('"allowMissing" argument must be a boolean');if(null===$(/^%?[^%]*%?$/,e))throw new d("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=function(e){var t=W(e,0,1),i=W(e,-1);if("%"===t&&"%"!==i)throw new d("invalid intrinsic syntax, expected closing `%`");if("%"===i&&"%"!==t)throw new d("invalid intrinsic syntax, expected opening `%`");var r=[];return F(e,H,(function(e,t,i,o){r[r.length]=i?F(o,G,"$1"):t||e})),r}(e),r=i.length>0?i[0]:"",o=q("%"+r+"%",t),n=o.name,s=o.value,a=!1,l=o.alias;l&&(r=l[0],V(i,U([0,1],l)));for(var h=1,c=!0;h<i.length;h+=1){var p=i[h],m=W(p,0,1),f=W(p,-1);if(('"'===m||"'"===m||"`"===m||'"'===f||"'"===f||"`"===f)&&m!==f)throw new d("property names with quotes must have matching quotes");if("constructor"!==p&&c||(a=!0),L(x,n="%"+(r+="."+p)+"%"))s=x[n];else if(null!=s){if(!(p in s)){if(!t)throw new u("base intrinsic for "+e+" exists, but the property is not available.");return}if(v&&h+1>=i.length){var g=v(s,p);s=(c=!!g)&&"get"in g&&!("originalValue"in g.get)?g.get:s[p]}else c=L(s,p),s=s[p];c&&!a&&(x[n]=s)}}return s}},"./node_modules/get-proto/Object.getPrototypeOf.js"(e,t,i){var r=i("./node_modules/es-object-atoms/index.js");e.exports=r.getPrototypeOf||null},"./node_modules/get-proto/Reflect.getPrototypeOf.js"(e){e.exports="u">typeof Reflect&&Reflect.getPrototypeOf||null},"./node_modules/get-proto/index.js"(e,t,i){var r=i("./node_modules/get-proto/Reflect.getPrototypeOf.js"),o=i("./node_modules/get-proto/Object.getPrototypeOf.js"),n=i("./node_modules/dunder-proto/get.js");e.exports=r?function(e){return r(e)}:o?function(e){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new TypeError("getProto: not an object");return o(e)}:n?function(e){return n(e)}:null},"./node_modules/gopd/gOPD.js"(e){e.exports=Object.getOwnPropertyDescriptor},"./node_modules/gopd/index.js"(e,t,i){var r=i("./node_modules/gopd/gOPD.js");if(r)try{r([],"length")}catch(e){r=null}e.exports=r},"./node_modules/has-property-descriptors/index.js"(e,t,i){var r=i("./node_modules/es-define-property/index.js"),o=function(){return!!r};o.hasArrayLengthDefineBug=function(){if(!r)return null;try{return 1!==r([],"length",{value:1}).length}catch(e){return!0}},e.exports=o},"./node_modules/has-symbols/index.js"(e,t,i){var r="u">typeof Symbol&&Symbol,o=i("./node_modules/has-symbols/shams.js");e.exports=function(){return"function"==typeof r&&("function"==typeof Symbol&&("symbol"==typeof r("foo")&&("symbol"==typeof Symbol("bar")&&o())))}},"./node_modules/has-symbols/shams.js"(e){e.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),i=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(i))return!1;for(var r in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var o=Object.getOwnPropertySymbols(e);if(1!==o.length||o[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var n=Object.getOwnPropertyDescriptor(e,t);if(42!==n.value||!0!==n.enumerable)return!1}return!0}},"./node_modules/has-tostringtag/shams.js"(e,t,i){var r=i("./node_modules/has-symbols/shams.js");e.exports=function(){return r()&&!!Symbol.toStringTag}},"./node_modules/hasown/index.js"(e,t,i){var r=Function.prototype.call,o=Object.prototype.hasOwnProperty,n=i("./node_modules/function-bind/index.js");e.exports=n.call(r,o)},"./node_modules/ieee754/index.js"(e,t){
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */t.read=function(e,t,i,r,o){var n,s,a=8*o-r-1,l=(1<<a)-1,d=l>>1,u=-7,h=i?o-1:0,c=i?-1:1,p=e[t+h];for(h+=c,n=p&(1<<-u)-1,p>>=-u,u+=a;u>0;n=256*n+e[t+h],h+=c,u-=8);for(s=n&(1<<-u)-1,n>>=-u,u+=r;u>0;s=256*s+e[t+h],h+=c,u-=8);if(0===n)n=1-d;else{if(n===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),n-=d}return(p?-1:1)*s*Math.pow(2,n-r)},t.write=function(e,t,i,r,o,n){var s,a,l,d=8*n-o-1,u=(1<<d)-1,h=u>>1,c=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:n-1,m=r?1:-1,f=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=u):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),(t+=s+h>=1?c/l:c*Math.pow(2,1-h))*l>=2&&(s++,l/=2),s+h>=u?(a=0,s=u):s+h>=1?(a=(t*l-1)*Math.pow(2,o),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,o),s=0));o>=8;e[i+p]=255&a,p+=m,a/=256,o-=8);for(s=s<<o|a,d+=o;d>0;e[i+p]=255&s,p+=m,s/=256,d-=8);e[i+p-m]|=128*f}},"./node_modules/inherits/inherits_browser.js"(e){"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e}}},"./node_modules/is-arguments/index.js"(e,t,i){var r=i("./node_modules/has-tostringtag/shams.js")(),o=i("./node_modules/call-bound/index.js")("Object.prototype.toString"),n=function(e){return!(r&&e&&"object"==typeof e&&Symbol.toStringTag in e)&&"[object Arguments]"===o(e)},s=function(e){return!!n(e)||null!==e&&"object"==typeof e&&"length"in e&&"number"==typeof e.length&&e.length>=0&&"[object Array]"!==o(e)&&"callee"in e&&"[object Function]"===o(e.callee)},a=function(){return n(arguments)}();n.isLegacyArguments=s,e.exports=a?n:s},"./node_modules/is-callable/index.js"(e){var t,i,r=Function.prototype.toString,o="object"==typeof Reflect&&null!==Reflect&&Reflect.apply;if("function"==typeof o&&"function"==typeof Object.defineProperty)try{t=Object.defineProperty({},"length",{get:function(){throw i}}),i={},o((function(){throw 42}),null,t)}catch(e){e!==i&&(o=null)}else o=null;var n=/^\s*class\b/,s=function(e){try{var t=r.call(e);return n.test(t)}catch(e){return!1}},a=function(e){try{return!s(e)&&(r.call(e),!0)}catch(e){return!1}},l=Object.prototype.toString,d="function"==typeof Symbol&&!!Symbol.toStringTag,u=!(0 in[,]),h=function(){return!1};if("object"==typeof document){var c=document.all;l.call(c)===l.call(document.all)&&(h=function(e){if((u||!e)&&(void 0===e||"object"==typeof e))try{var t=l.call(e);return("[object HTMLAllCollection]"===t||"[object HTML document.all class]"===t||"[object HTMLCollection]"===t||"[object Object]"===t)&&null==e("")}catch(e){}return!1})}e.exports=o?function(e){if(h(e))return!0;if(!e)return!1;if("function"!=typeof e&&"object"!=typeof e)return!1;try{o(e,null,t)}catch(e){if(e!==i)return!1}return!s(e)&&a(e)}:function(e){if(h(e))return!0;if(!e)return!1;if("function"!=typeof e&&"object"!=typeof e)return!1;if(d)return a(e);if(s(e))return!1;var t=l.call(e);return!("[object Function]"!==t&&"[object GeneratorFunction]"!==t&&!/^\[object HTML/.test(t))&&a(e)}},"./node_modules/is-generator-function/index.js"(e,t,i){var r=i("./node_modules/call-bound/index.js"),o=i("./node_modules/safe-regex-test/index.js")(/^\s*(?:function)?\*/),n=i("./node_modules/has-tostringtag/shams.js")(),s=i("./node_modules/get-proto/index.js"),a=r("Object.prototype.toString"),l=r("Function.prototype.toString"),d=i("./node_modules/generator-function/index.js");e.exports=function(e){if("function"!=typeof e)return!1;if(o(l(e)))return!0;if(!n)return"[object GeneratorFunction]"===a(e);if(!s)return!1;var t=d();return t&&s(e)===t.prototype}},"./node_modules/is-regex/index.js"(e,t,i){var r,o=i("./node_modules/call-bound/index.js"),n=i("./node_modules/has-tostringtag/shams.js")(),s=i("./node_modules/hasown/index.js"),a=i("./node_modules/gopd/index.js");if(n){var l=o("RegExp.prototype.exec"),d={},u=function(){throw d},h={toString:u,valueOf:u};"symbol"==typeof Symbol.toPrimitive&&(h[Symbol.toPrimitive]=u),r=function(e){if(!e||"object"!=typeof e)return!1;var t=a(e,"lastIndex");if(!(t&&s(t,"value")))return!1;try{l(e,h)}catch(e){return e===d}}}else{var c=o("Object.prototype.toString");r=function(e){return!(!e||"object"!=typeof e&&"function"!=typeof e)&&"[object RegExp]"===c(e)}}e.exports=r},"./node_modules/is-typed-array/index.js"(e,t,i){var r=i("./node_modules/which-typed-array/index.js");e.exports=function(e){return!!r(e)}},"./node_modules/math-intrinsics/abs.js"(e){e.exports=Math.abs},"./node_modules/math-intrinsics/floor.js"(e){e.exports=Math.floor},"./node_modules/math-intrinsics/isNaN.js"(e){e.exports=Number.isNaN||function(e){return e!=e}},"./node_modules/math-intrinsics/max.js"(e){e.exports=Math.max},"./node_modules/math-intrinsics/min.js"(e){e.exports=Math.min},"./node_modules/math-intrinsics/pow.js"(e){e.exports=Math.pow},"./node_modules/math-intrinsics/round.js"(e){e.exports=Math.round},"./node_modules/math-intrinsics/sign.js"(e,t,i){var r=i("./node_modules/math-intrinsics/isNaN.js");e.exports=function(e){return r(e)||0===e?e:e<0?-1:1}},"./node_modules/possible-typed-array-names/index.js"(e){e.exports=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]},"./node_modules/process/browser.js"(e){var t,i,r=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function n(){throw new Error("clearTimeout has not been defined")}function s(e){if(t===setTimeout)return setTimeout(e,0);if((t===o||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(i){try{return t.call(null,e,0)}catch(i){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:o}catch(e){t=o}try{i="function"==typeof clearTimeout?clearTimeout:n}catch(e){i=n}}();var a,l=[],d=!1,u=-1;function h(){d&&a&&(d=!1,a.length?l=a.concat(l):u=-1,l.length&&c())}function c(){if(!d){var e=s(h);d=!0;for(var t=l.length;t;){for(a=l,l=[];++u<t;)a&&a[u].run();u=-1,t=l.length}a=null,d=!1,function(e){if(i===clearTimeout)return clearTimeout(e);if((i===n||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(e);try{return i(e)}catch(t){try{return i.call(null,e)}catch(t){return i.call(this,e)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function m(){}r.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)t[i-1]=arguments[i];l.push(new p(e,t)),1!==l.length||d||s(c)},p.prototype.run=function(){this.fun.apply(null,this.array)},r.title="browser",r.browser=!0,r.env={},r.argv=[],r.version="",r.versions={},r.on=m,r.addListener=m,r.once=m,r.off=m,r.removeListener=m,r.removeAllListeners=m,r.emit=m,r.prependListener=m,r.prependOnceListener=m,r.listeners=function(e){return[]},r.binding=function(e){throw new Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(e){throw new Error("process.chdir is not supported")},r.umask=function(){return 0}},"./node_modules/safe-regex-test/index.js"(e,t,i){var r=i("./node_modules/call-bound/index.js"),o=i("./node_modules/is-regex/index.js"),n=r("RegExp.prototype.exec"),s=i("./node_modules/es-errors/type.js");e.exports=function(e){if(!o(e))throw new s("`regex` must be a RegExp");return function(t){return null!==n(e,t)}}},"./node_modules/set-function-length/index.js"(e,t,i){var r=i("./node_modules/get-intrinsic/index.js"),o=i("./node_modules/define-data-property/index.js"),n=i("./node_modules/has-property-descriptors/index.js")(),s=i("./node_modules/gopd/index.js"),a=i("./node_modules/es-errors/type.js"),l=r("%Math.floor%");e.exports=function(e,t){if("function"!=typeof e)throw new a("`fn` is not a function");if("number"!=typeof t||t<0||t>4294967295||l(t)!==t)throw new a("`length` must be a positive 32-bit integer");var i=arguments.length>2&&!!arguments[2],r=!0,d=!0;if("length"in e&&s){var u=s(e,"length");u&&!u.configurable&&(r=!1),u&&!u.writable&&(d=!1)}return(r||d||!i)&&(n?o(e,"length",t,!0,!0):o(e,"length",t)),e}},"./node_modules/util/support/isBufferBrowser.js"(e){e.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},"./node_modules/util/support/types.js"(e,t,i){var r=i("./node_modules/is-arguments/index.js"),o=i("./node_modules/is-generator-function/index.js"),n=i("./node_modules/which-typed-array/index.js"),s=i("./node_modules/is-typed-array/index.js");function a(e){return e.call.bind(e)}var l="u">typeof BigInt,d="u">typeof Symbol,u=a(Object.prototype.toString),h=a(Number.prototype.valueOf),c=a(String.prototype.valueOf),p=a(Boolean.prototype.valueOf);if(l)var m=a(BigInt.prototype.valueOf);if(d)var f=a(Symbol.prototype.valueOf);function g(e,t){if("object"!=typeof e)return!1;try{return t(e),!0}catch(e){return!1}}function y(e){return"[object Map]"===u(e)}function b(e){return"[object Set]"===u(e)}function E(e){return"[object WeakMap]"===u(e)}function _(e){return"[object WeakSet]"===u(e)}function v(e){return"[object ArrayBuffer]"===u(e)}function w(e){return!("u"<typeof ArrayBuffer)&&(v.working?v(e):e instanceof ArrayBuffer)}function R(e){return"[object DataView]"===u(e)}function A(e){return!("u"<typeof DataView)&&(R.working?R(e):e instanceof DataView)}t.isArgumentsObject=r,t.isGeneratorFunction=o,t.isTypedArray=s,t.isPromise=function(e){return"u">typeof Promise&&e instanceof Promise||null!==e&&"object"==typeof e&&"function"==typeof e.then&&"function"==typeof e.catch},t.isArrayBufferView=function(e){return"u">typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):s(e)||A(e)},t.isUint8Array=function(e){return"Uint8Array"===n(e)},t.isUint8ClampedArray=function(e){return"Uint8ClampedArray"===n(e)},t.isUint16Array=function(e){return"Uint16Array"===n(e)},t.isUint32Array=function(e){return"Uint32Array"===n(e)},t.isInt8Array=function(e){return"Int8Array"===n(e)},t.isInt16Array=function(e){return"Int16Array"===n(e)},t.isInt32Array=function(e){return"Int32Array"===n(e)},t.isFloat32Array=function(e){return"Float32Array"===n(e)},t.isFloat64Array=function(e){return"Float64Array"===n(e)},t.isBigInt64Array=function(e){return"BigInt64Array"===n(e)},t.isBigUint64Array=function(e){return"BigUint64Array"===n(e)},y.working="u">typeof Map&&y(new Map),t.isMap=function(e){return!("u"<typeof Map)&&(y.working?y(e):e instanceof Map)},b.working="u">typeof Set&&b(new Set),t.isSet=function(e){return!("u"<typeof Set)&&(b.working?b(e):e instanceof Set)},E.working="u">typeof WeakMap&&E(new WeakMap),t.isWeakMap=function(e){return!("u"<typeof WeakMap)&&(E.working?E(e):e instanceof WeakMap)},_.working="u">typeof WeakSet&&_(new WeakSet),t.isWeakSet=function(e){return _(e)},v.working="u">typeof ArrayBuffer&&v(new ArrayBuffer),t.isArrayBuffer=w,R.working="u">typeof ArrayBuffer&&"u">typeof DataView&&R(new DataView(new ArrayBuffer(1),0,1)),t.isDataView=A;var S="u">typeof SharedArrayBuffer?SharedArrayBuffer:void 0;function M(e){return"[object SharedArrayBuffer]"===u(e)}function O(e){return void 0!==S&&(void 0===M.working&&(M.working=M(new S)),M.working?M(e):e instanceof S)}function T(e){return g(e,h)}function B(e){return g(e,c)}function I(e){return g(e,p)}function P(e){return l&&g(e,m)}function j(e){return d&&g(e,f)}t.isSharedArrayBuffer=O,t.isAsyncFunction=function(e){return"[object AsyncFunction]"===u(e)},t.isMapIterator=function(e){return"[object Map Iterator]"===u(e)},t.isSetIterator=function(e){return"[object Set Iterator]"===u(e)},t.isGeneratorObject=function(e){return"[object Generator]"===u(e)},t.isWebAssemblyCompiledModule=function(e){return"[object WebAssembly.Module]"===u(e)},t.isNumberObject=T,t.isStringObject=B,t.isBooleanObject=I,t.isBigIntObject=P,t.isSymbolObject=j,t.isBoxedPrimitive=function(e){return T(e)||B(e)||I(e)||P(e)||j(e)},t.isAnyArrayBuffer=function(e){return"u">typeof Uint8Array&&(w(e)||O(e))},["isProxy","isExternal","isModuleNamespaceObject"].forEach((function(e){Object.defineProperty(t,e,{enumerable:!1,value:function(){throw new Error(e+" is not supported in userland")}})}))},"./node_modules/util/util.js"(e,t,i){var r=i("./node_modules/process/browser.js"),o=Object.getOwnPropertyDescriptors||function(e){for(var t=Object.keys(e),i={},r=0;r<t.length;r++)i[t[r]]=Object.getOwnPropertyDescriptor(e,t[r]);return i},n=/%[sdj%]/g;t.format=function(e){if(!E(e)){for(var t=[],i=0;i<arguments.length;i++)t.push(d(arguments[i]));return t.join(" ")}i=1;for(var r=arguments,o=r.length,s=String(e).replace(n,(function(e){if("%%"===e)return"%";if(i>=o)return e;switch(e){case"%s":return String(r[i++]);case"%d":return Number(r[i++]);case"%j":try{return JSON.stringify(r[i++])}catch(e){return"[Circular]"}default:return e}})),a=r[i];i<o;a=r[++i])y(a)||!w(a)?s+=" "+a:s+=" "+d(a);return s},t.deprecate=function(e,i){if(void 0!==r&&!0===r.noDeprecation)return e;if(void 0===r)return function(){return t.deprecate(e,i).apply(this,arguments)};var o=!1;return function(){if(!o){if(r.throwDeprecation)throw new Error(i);r.traceDeprecation?console.trace(i):console.error(i),o=!0}return e.apply(this,arguments)}};var s={},a=/^$/;if(r.env.NODE_DEBUG){var l=r.env.NODE_DEBUG;l=l.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),a=new RegExp("^"+l+"$","i")}function d(e,i){var r={seen:[],stylize:h};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),g(i)?r.showHidden=i:i&&t._extend(r,i),_(r.showHidden)&&(r.showHidden=!1),_(r.depth)&&(r.depth=2),_(r.colors)&&(r.colors=!1),_(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=u),c(r,e,r.depth)}function u(e,t){var i=d.styles[t];return i?"["+d.colors[i][0]+"m"+e+"["+d.colors[i][1]+"m":e}function h(e,t){return e}function c(e,i,r){if(e.customInspect&&i&&S(i.inspect)&&i.inspect!==t.inspect&&(!i.constructor||i.constructor.prototype!==i)){var o=i.inspect(r,e);return E(o)||(o=c(e,o,r)),o}var n=function(e,t){if(_(t))return e.stylize("undefined","undefined");if(E(t)){var i="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(i,"string")}if(b(t))return e.stylize(""+t,"number");if(g(t))return e.stylize(""+t,"boolean");if(y(t))return e.stylize("null","null")}(e,i);if(n)return n;var s=Object.keys(i),a=function(e){var t={};return e.forEach((function(e,i){t[e]=!0})),t}(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(i)),A(i)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return p(i);if(0===s.length){if(S(i)){var l=i.name?": "+i.name:"";return e.stylize("[Function"+l+"]","special")}if(v(i))return e.stylize(RegExp.prototype.toString.call(i),"regexp");if(R(i))return e.stylize(Date.prototype.toString.call(i),"date");if(A(i))return p(i)}var d,u="",h=!1,w=["{","}"];(f(i)&&(h=!0,w=["[","]"]),S(i))&&(u=" [Function"+(i.name?": "+i.name:"")+"]");return v(i)&&(u=" "+RegExp.prototype.toString.call(i)),R(i)&&(u=" "+Date.prototype.toUTCString.call(i)),A(i)&&(u=" "+p(i)),0!==s.length||h&&0!=i.length?r<0?v(i)?e.stylize(RegExp.prototype.toString.call(i),"regexp"):e.stylize("[Object]","special"):(e.seen.push(i),d=h?function(e,t,i,r,o){for(var n=[],s=0,a=t.length;s<a;++s)B(t,String(s))?n.push(m(e,t,i,r,String(s),!0)):n.push("");return o.forEach((function(o){o.match(/^\d+$/)||n.push(m(e,t,i,r,o,!0))})),n}(e,i,r,a,s):s.map((function(t){return m(e,i,r,a,t,h)})),e.seen.pop(),function(e,t,i){var r=e.reduce((function(e,t){return t.indexOf("\n")>=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0);return r>60?i[0]+(""===t?"":t+"\n ")+" "+e.join(",\n  ")+" "+i[1]:i[0]+t+" "+e.join(", ")+" "+i[1]}(d,u,w)):w[0]+u+w[1]}function p(e){return"["+Error.prototype.toString.call(e)+"]"}function m(e,t,i,r,o,n){var s,a,l;if((l=Object.getOwnPropertyDescriptor(t,o)||{value:t[o]}).get?a=l.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):l.set&&(a=e.stylize("[Setter]","special")),B(r,o)||(s="["+o+"]"),a||(e.seen.indexOf(l.value)<0?(a=y(i)?c(e,l.value,null):c(e,l.value,i-1)).indexOf("\n")>-1&&(a=n?a.split("\n").map((function(e){return"  "+e})).join("\n").slice(2):"\n"+a.split("\n").map((function(e){return"   "+e})).join("\n")):a=e.stylize("[Circular]","special")),_(s)){if(n&&o.match(/^\d+$/))return a;(s=JSON.stringify(""+o)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.slice(1,-1),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function f(e){return Array.isArray(e)}function g(e){return"boolean"==typeof e}function y(e){return null===e}function b(e){return"number"==typeof e}function E(e){return"string"==typeof e}function _(e){return void 0===e}function v(e){return w(e)&&"[object RegExp]"===M(e)}function w(e){return"object"==typeof e&&null!==e}function R(e){return w(e)&&"[object Date]"===M(e)}function A(e){return w(e)&&("[object Error]"===M(e)||e instanceof Error)}function S(e){return"function"==typeof e}function M(e){return Object.prototype.toString.call(e)}function O(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(e){if(e=e.toUpperCase(),!s[e])if(a.test(e)){var i=r.pid;s[e]=function(){var r=t.format.apply(t,arguments);console.error("%s %d: %s",e,i,r)}}else s[e]=function(){};return s[e]},t.inspect=d,d.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},d.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.types=i("./node_modules/util/support/types.js"),t.isArray=f,t.isBoolean=g,t.isNull=y,t.isNullOrUndefined=function(e){return null==e},t.isNumber=b,t.isString=E,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=_,t.isRegExp=v,t.types.isRegExp=v,t.isObject=w,t.isDate=R,t.types.isDate=R,t.isError=A,t.types.isNativeError=A,t.isFunction=S,t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=i("./node_modules/util/support/isBufferBrowser.js");var T=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function B(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){var e,i;console.log("%s - %s",(e=new Date,i=[O(e.getHours()),O(e.getMinutes()),O(e.getSeconds())].join(":"),[e.getDate(),T[e.getMonth()],i].join(" ")),t.format.apply(t,arguments))},t.inherits=i("./node_modules/inherits/inherits_browser.js"),t._extend=function(e,t){if(!t||!w(t))return e;for(var i=Object.keys(t),r=i.length;r--;)e[i[r]]=t[i[r]];return e};var I="u">typeof Symbol?Symbol("util.promisify.custom"):void 0;function P(e,t){if(!e){var i=new Error("Promise was rejected with a falsy value");i.reason=e,e=i}return t(e)}t.promisify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(I&&e[I]){var t;if("function"!=typeof(t=e[I]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,I,{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(){for(var t,i,r=new Promise((function(e,r){t=e,i=r})),o=[],n=0;n<arguments.length;n++)o.push(arguments[n]);o.push((function(e,r){e?i(e):t(r)}));try{e.apply(this,o)}catch(e){i(e)}return r}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),I&&Object.defineProperty(t,I,{value:t,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(t,o(e))},t.promisify.custom=I,t.callbackify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');function t(){for(var t=[],i=0;i<arguments.length;i++)t.push(arguments[i]);var o=t.pop();if("function"!=typeof o)throw new TypeError("The last argument must be of type Function");var n=this,s=function(){return o.apply(n,arguments)};e.apply(this,t).then((function(e){r.nextTick(s.bind(null,null,e))}),(function(e){r.nextTick(P.bind(null,e,s))}))}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),Object.defineProperties(t,o(e)),t}},"./node_modules/which-typed-array/index.js"(e,t,i){var r=i("./node_modules/for-each/index.js"),o=i("./node_modules/available-typed-arrays/index.js"),n=i("./node_modules/call-bind/index.js"),s=i("./node_modules/call-bound/index.js"),a=i("./node_modules/gopd/index.js"),l=i("./node_modules/get-proto/index.js"),d=s("Object.prototype.toString"),u=i("./node_modules/has-tostringtag/shams.js")(),h="u"<typeof globalThis?i.g:globalThis,c=o(),p=s("String.prototype.slice"),m=s("Array.prototype.indexOf",!0)||function(e,t){for(var i=0;i<e.length;i+=1)if(e[i]===t)return i;return-1},f={__proto__:null};r(c,u&&a&&l?function(e){var t=new h[e];if(Symbol.toStringTag in t&&l){var i=l(t),r=a(i,Symbol.toStringTag);if(!r&&i){var o=l(i);r=a(o,Symbol.toStringTag)}if(r&&r.get){var s=n(r.get);f["$"+e]=s}}}:function(e){var t=new h[e],i=t.slice||t.set;if(i){var r=n(i);f["$"+e]=r}});e.exports=function(e){if(!e||"object"!=typeof e)return!1;if(!u){var t=p(d(e),8,-1);return m(c,t)>-1?t:"Object"===t&&function(e){var t=!1;return r(f,(function(i,r){if(!t)try{i(e),t=p(r,1)}catch(e){}})),t}(e)}return a?function(e){var t=!1;return r(f,(function(i,r){if(!t)try{"$"+i(e)===r&&(t=p(r,1))}catch(e){}})),t}(e):null}},"./node_modules/@rsbuild/core/compiled/css-loader/api.js"(e){e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var i="",r=void 0!==t[5];return t[4]&&(i+="@supports (".concat(t[4],") {")),t[2]&&(i+="@media ".concat(t[2]," {")),r&&(i+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),i+=e(t),r&&(i+="}"),t[2]&&(i+="}"),t[4]&&(i+="}"),i})).join("")},t.i=function(e,i,r,o,n){"string"==typeof e&&(e=[[null,e,void 0]]);var s={};if(r)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(s[l]=!0)}for(var d=0;d<e.length;d++){var u=[].concat(e[d]);r&&s[u[0]]||(void 0!==n&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=n),i&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=i):u[2]=i),o&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=o):u[4]="".concat(o)),t.push(u))}},t}},"./node_modules/@rsbuild/core/compiled/css-loader/noSourceMaps.js"(e){e.exports=function(e){return e[1]}},"./node_modules/@rsbuild/core/compiled/style-loader/runtime/injectStylesIntoStyleTag.js"(e){var t=[];function i(e){for(var i=-1,r=0;r<t.length;r++)if(t[r].identifier===e){i=r;break}return i}function r(e,r){for(var n={},s=[],a=0;a<e.length;a++){var l=e[a],d=r.base?l[0]+r.base:l[0],u=n[d]||0,h="".concat(d," ").concat(u);n[d]=u+1;var c=i(h),p={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==c)t[c].references++,t[c].updater(p);else{var m=o(p,r);r.byIndex=a,t.splice(a,0,{identifier:h,updater:m,references:1})}s.push(h)}return s}function o(e,t){var i=t.domAPI(t);i.update(e);return function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap&&t.supports===e.supports&&t.layer===e.layer)return;i.update(e=t)}else i.remove()}}e.exports=function(e,o){var n=r(e=e||[],o=o||{});return function(e){e=e||[];for(var s=0;s<n.length;s++){var a=i(n[s]);t[a].references--}for(var l=r(e,o),d=0;d<n.length;d++){var u=i(n[d]);0===t[u].references&&(t[u].updater(),t.splice(u,1))}n=l}}},"./node_modules/@rsbuild/core/compiled/style-loader/runtime/insertBySelector.js"(e){var t={};e.exports=function(e,i){var r=function(e){if(void 0===t[e]){var i=document.querySelector(e);if(window.HTMLIFrameElement&&i instanceof window.HTMLIFrameElement)try{i=i.contentDocument.head}catch(e){i=null}t[e]=i}return t[e]}(e);if(!r)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");r.appendChild(i)}},"./node_modules/@rsbuild/core/compiled/style-loader/runtime/insertStyleElement.js"(e){e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},"./node_modules/@rsbuild/core/compiled/style-loader/runtime/setAttributesWithoutAttributes.js"(e,t,i){e.exports=function(e){var t=i.nc;t&&e.setAttribute("nonce",t)}},"./node_modules/@rsbuild/core/compiled/style-loader/runtime/styleDomAPI.js"(e){e.exports=function(e){if("u"<typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(i){!function(e,t,i){var r="";i.supports&&(r+="@supports (".concat(i.supports,") {")),i.media&&(r+="@media ".concat(i.media," {"));var o=void 0!==i.layer;o&&(r+="@layer".concat(i.layer.length>0?" ".concat(i.layer):""," {")),r+=i.css,o&&(r+="}"),i.media&&(r+="}"),i.supports&&(r+="}");var n=i.sourceMap;n&&"u">typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(n))))," */")),t.styleTagTransform(r,e,t.options)}(t,e,i)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},"./node_modules/@rsbuild/core/compiled/style-loader/runtime/styleTagTransform.js"(e){e.exports=function(e,t){if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}},"./node_modules/available-typed-arrays/index.js"(e,t,i){var r=i("./node_modules/possible-typed-array-names/index.js"),o="u"<typeof globalThis?i.g:globalThis;e.exports=function(){for(var e=[],t=0;t<r.length;t++)"function"==typeof o[r[t]]&&(e[e.length]=r[t]);return e}}});const VideoType={WebM:"webm",MP4:"mp4"},constants={WHITELIST_KEY_LABEL:"x-videomail-whitelist-key",VERSION_LABEL:"videomailClientVersion",public:{ENC_TYPE_APP_JSON:"application/json",ENC_TYPE_FORM:"application/x-www-form-urlencoded"}};var package_namespaceObject={rE:"13.8.17"};function isAudioEnabled(e){return Boolean(e.audio.enabled)}function setAudioEnabled(e,t){return t.audio.enabled=e,t}function isAutoPauseEnabled(e){return e.enableAutoPause&&e.enablePause}const util=__webpack_require__("./node_modules/util/util.js");var util_default=__webpack_require__.n(util);function inspect(e){return util_default().inspect(e,{colors:!1,compact:!0,depth:4,breakLength:1/0}).replace(/\s+/gu," ").replace(/\r?\n/gu,"")}function pretty(e){return e instanceof HTMLElement?e.id?`#${e.id}`:e.className?`.${e.className}`:"(No HTML identifier available)":inspect(e)}const util_pretty=pretty;function canPlayType_canPlayType(e,t){const i=e.canPlayType(`video/${t}`);return""!==i&&i}const media_canPlayType=canPlayType_canPlayType;function _define_property(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const FALLBACK_VIDEO_TYPE=VideoType.MP4;class Browser{isIOS(){return"iOS"===this.result.os.name}getBrowserVersion(){return this.result.browser.version}isChrome(){return"Chrome"===this.result.browser.name}isChromium(){return"Chromium"===this.result.browser.name}isFirefox(){return"Firefox"===this.result.browser.name}isSafari(){return!!this.result.browser.name&&this.result.browser.name.includes("Safari")}isAndroid(){return!!this.result.os.name&&this.result.os.name.includes("Android")}isChromeBased(){return this.isChrome()||this.isChromium()}isMobile(){return this.isIOS()||this.isAndroid()}isOkSafari(){const e=this.getBrowserVersion();return!!e&&(this.isSafari()&&Number.parseFloat(e)>=11)}getVideoType(e){return this.videoType||(media_canPlayType(e,VideoType.MP4)?this.videoType=VideoType.MP4:media_canPlayType(e,VideoType.WebM)&&(this.videoType=VideoType.WebM)),this.videoType!==VideoType.WebM&&this.videoType!==VideoType.MP4&&(this.videoType=FALLBACK_VIDEO_TYPE),""===this.videoType.trim()&&(this.videoType=FALLBACK_VIDEO_TYPE),this.videoType}getNoAccessIssue(){let e;return e=this.isChromeBased()?"Click on the allow button to grant access to your webcam":this.isFirefox()?"Please grant Firefox access to your webcam":"Your system does not let your browser access your webcam",error_createError({message:"Unable to access webcam",explanation:e,options:this.options})}getUsefulData(){return{ua:this.result.ua,browser:this.result.browser,cpu:this.result.cpu,device:this.result.device,engine:this.result.engine,os:this.result.os}}constructor(e){_define_property(this,"options",void 0),_define_property(this,"result",void 0),_define_property(this,"videoType",void 0),this.options=e;const t=defined(e.fakeUaString,window.navigator.userAgent,""),i=new UAParser(t);this.result=i.getResult()}}const util_Browser=Browser;let getBrowser_browser;function getBrowser(e){return getBrowser_browser||(getBrowser_browser=new util_Browser(e)),getBrowser_browser}const util_getBrowser=getBrowser;function HTTPVideomailError_define_property(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class HTTPVideomailError extends Error{constructor(...e){super(...e),HTTPVideomailError_define_property(this,"code",void 0),HTTPVideomailError_define_property(this,"status",void 0),HTTPVideomailError_define_property(this,"explanation",void 0)}}const error_HTTPVideomailError=HTTPVideomailError;function VideomailError_define_property(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class VideomailError extends error_HTTPVideomailError{hasClass(e){return this.classList?.includes(e)}isBrowserProblem(){return this.hasClass(VideomailError.BROWSER_PROBLEM)}getClassList(){return this.classList}constructor(e,t,i,r){super(e,r),VideomailError_define_property(this,"title","Error from videomail-client npm package"),VideomailError_define_property(this,"location",window.location.href),VideomailError_define_property(this,"logLines",void 0),VideomailError_define_property(this,"whitelistKey",void 0),VideomailError_define_property(this,"cookie",void 0),VideomailError_define_property(this,"err",void 0),VideomailError_define_property(this,"promise",void 0),VideomailError_define_property(this,"reason",void 0),VideomailError_define_property(this,"browser",void 0),VideomailError_define_property(this,"cpu",void 0),VideomailError_define_property(this,"device",void 0),VideomailError_define_property(this,"engine",void 0),VideomailError_define_property(this,"os",void 0),VideomailError_define_property(this,"screen",void 0),VideomailError_define_property(this,"orientation",void 0),VideomailError_define_property(this,"classList",void 0),this.explanation=r?.explanation,this.logLines=r?.logLines,this.whitelistKey=t.whitelistKey,this.classList=i;const o=util_getBrowser(t).getUsefulData();let n;this.browser=o.browser,o.cpu.architecture&&(this.cpu=o.cpu),this.device=o.device.type?o.device:void 0,this.engine=o.engine,this.os=o.os,__webpack_require__.g.document.cookie.length>0&&(n=__webpack_require__.g.document.cookie.split(",").map((e=>e.trim()))),this.cookie=n&&n.length>0?n:void 0,this.screen=[screen.width,screen.height,screen.colorDepth].join("×"),screen.orientation&&(this.orientation=screen.orientation.type),this.err=r?.err;const s=r?.cause??r?.err;s&&"captureStackTrace"in Error&&Error.captureStackTrace(s,VideomailError)}}VideomailError_define_property(VideomailError,"PERMISSION_DENIED","PERMISSION_DENIED"),VideomailError_define_property(VideomailError,"NOT_ALLOWED_ERROR","NotAllowedError"),VideomailError_define_property(VideomailError,"DOM_EXCEPTION","DOMException"),VideomailError_define_property(VideomailError,"STARTING_FAILED","Starting video failed"),VideomailError_define_property(VideomailError,"MEDIA_DEVICE_NOT_SUPPORTED","MediaDeviceNotSupported"),VideomailError_define_property(VideomailError,"BROWSER_PROBLEM","browser-problem"),VideomailError_define_property(VideomailError,"WEBCAM_PROBLEM","webcam-problem"),VideomailError_define_property(VideomailError,"OVERCONSTRAINED","OverconstrainedError"),VideomailError_define_property(VideomailError,"NOT_READABLE_ERROR","NotReadableError"),VideomailError_define_property(VideomailError,"SECURITY_ERROR","SecurityError"),VideomailError_define_property(VideomailError,"TRACK_START_ERROR","TrackStartError"),VideomailError_define_property(VideomailError,"INVALID_STATE_ERROR","InvalidStateError");const error_VideomailError=VideomailError;function createError(e){const{exc:t,options:i}=e;let r=e.err;if(!r&&t instanceof Error&&(r=t),r instanceof error_VideomailError)return r;let o=e.message,n=e.explanation;const s=e.classList??[],a=isAudioEnabled(i),l=r?.name??r?.constructor.name;switch(l){case error_VideomailError.SECURITY_ERROR:o="The operation was insecure",n="Probably you have disallowed Cookies for this page?",s.push(error_VideomailError.BROWSER_PROBLEM);break;case error_VideomailError.OVERCONSTRAINED:if(o="Invalid webcam constraints",r&&"constraint"in r){const e=r.constraint;n="width"===e?"Your webcam does not meet the width requirement.":e?`Unmet constraint: ${e}`:r.message}else n=r?.message;break;case"MediaDeviceFailedDueToShutdown":o="Webcam is shutting down",n="This happens your webcam is already switching off and not giving you permission to use it.";break;case"SourceUnavailableError":o="Source of your webcam cannot be accessed",n="Probably it is locked from another process or has a hardware error.";break;case"NO_DEVICES_FOUND":a?(o="No webcam nor microphone found",n="Your browser cannot find a webcam with microphone attached to your machine."):(o="No webcam found",n="Your browser cannot find a webcam attached to your machine."),s.push(error_VideomailError.WEBCAM_PROBLEM);break;case"PermissionDismissedError":o="Ooops, you didn't give me any permissions?",n="Looks like you skipped the webcam permission dialogue.<br/>Please grant access next time the dialogue appears.",s.push(error_VideomailError.WEBCAM_PROBLEM);break;case error_VideomailError.NOT_ALLOWED_ERROR:case error_VideomailError.PERMISSION_DENIED:case"PermissionDeniedError":o="Permission denied",n="Cannot access your webcam. This can have two reasons:<br/>a) you blocked access to webcam; or<br/>b) your webcam is already in use.",s.push(error_VideomailError.WEBCAM_PROBLEM);break;case"HARDWARE_UNAVAILABLE":case"AbortError":o="Webcam is unavailable",n="Maybe it is already busy in another window?",s.push(error_VideomailError.WEBCAM_PROBLEM);break;case"NO_VIDEO_FEED":o="No video feed found!",n="Your webcam is already used in another browser.",s.push(error_VideomailError.WEBCAM_PROBLEM);break;case error_VideomailError.STARTING_FAILED:o="Starting video failed",n="Most likely this happens when the webcam is already active in another browser",s.push(error_VideomailError.WEBCAM_PROBLEM);break;case"DevicesNotFoundError":o="No available webcam could be found",n="Looks like you do not have any webcam attached to your machine; or the one you plugged in is already used.",s.push(error_VideomailError.WEBCAM_PROBLEM);break;case error_VideomailError.NOT_READABLE_ERROR:case error_VideomailError.TRACK_START_ERROR:o="No access to webcam",n="Perhaps you are already using it in another browser?",s.push(error_VideomailError.WEBCAM_PROBLEM);break;case error_VideomailError.INVALID_STATE_ERROR:o="Invalid state",n="Video recording stream from your webcam already has finished",s.push(error_VideomailError.WEBCAM_PROBLEM);break;case error_VideomailError.DOM_EXCEPTION:o="DOM Exception",n=util_pretty(r);break;case error_VideomailError.MEDIA_DEVICE_NOT_SUPPORTED:o="Media device not supported",n=util_pretty(r);break;default:{const e=n;n&&"object"==typeof n&&(n=util_pretty(n)),!n&&e&&(n=`Inspected: ${e}`),!n&&r?.explanation&&(n=r.explanation),!o&&r?.message&&(o=r.message),o||(l&&(o=`${l} (weird)`),n||(n=util_pretty(r)),util_pretty(o)===n&&(n=void 0));break}}let d;i.logger.getLines&&(d=i.logger.getLines());const u=[o,n].filter(Boolean).join(", ");i.logger.debug(`VideomailError: create(${u})`);const h=new error_VideomailError(o??"(undefined message)",i,s,{explanation:n,logLines:d,err:r});if(r&&(h.status=r.status,h.code=r.code),i.reportErrors){new src_resource(i).reportError(h).catch((e=>{console.error(e)}))}return h}const error_createError=createError;function Despot_define_property(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class Despot{emit(e,...t){const i=t[0];i&&("object"!=typeof i||"object"==typeof i&&Object.keys(i).filter(Boolean).length>0)?this.options.logger.debug(`${this.name} emits ${e} with ${util_pretty(t)}`):this.options.logger.debug(`${this.name} emits ${e}`);try{Despot.EMITTER.emit(e,...t)}catch(e){e instanceof error_VideomailError?Despot.EMITTER.emit("ERROR",{err:e}):Despot.EMITTER.emit("ERROR",{exc:e})}}on(e,t){return Despot.EMITTER.on(e,t)}once(e,t){const i=this.on(e,((...e)=>{i(),e.length>0?t(...e):t()}));return i}static getListeners(e){return Despot.EMITTER.events[e]}static removeListener(e){delete Despot.EMITTER.events[e]}static removeAllListeners(){Despot.EMITTER.events={}}constructor(e,t){Despot_define_property(this,"name",void 0),Despot_define_property(this,"options",void 0),this.name=e,this.options=t}}Despot_define_property(Despot,"EMITTER",createNanoEvents());const util_Despot=Despot;function getValidity(e){return"validity"in e?e.validity:void 0}const util_getValidity=getValidity;function hideElement(e){e&&e.style.setProperty("display","none","important")}const html_hideElement=hideElement;function isNotButton(e){return"BUTTON"!==e.tagName&&"submit"!==e.getAttribute("type")}const html_isNotButton=isNotButton;function showElement(e){e&&e.style.removeProperty("display")}const html_showElement=showElement,REGEX=/[ ,]+/u;function trimEmail(e){return e.replace(REGEX,"")}function trimEmails(e){return e.split(REGEX).map((e=>e.trim())).filter(Boolean)}function form_define_property(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const FormMethod={POST:"post",PUT:"put",GET:"get"};class Form extends util_Despot{getData(){return get_form_data(this.formElement,{includeDisabled:!0})}transformFormData(e){const t={};return Object.keys(this.FORM_FIELDS).forEach((i=>{const r=this.FORM_FIELDS[i];if(r in e){const o=e[r];if(void 0!==o)switch(i){case"from":t[i]=trimEmail(o);break;case"to":case"cc":case"bcc":t[i]=trimEmails(o);break;default:t[i]=o}}})),t}getRecipients(){const e=this.getData(),t=this.transformFormData(e),i={};return t.to&&(i.to=t.to),t.cc&&(i.cc=t.cc),t.bcc&&(i.bcc=t.bcc),i}loadVideomail(e){this.options.logger.debug("Form: loadVideomail()");for(const t of this.formElement.elements){const i=t.getAttribute("name");if(i){let r=e[i];const o=t.tagName;switch(this.options.callbacks.adjustFormValueBeforePopulating&&(r=this.options.callbacks.adjustFormValueBeforePopulating(i,r,e)),o){case"INPUT":{const e=t;Array.isArray(r)?e.value=r.join(", "):e.value=r;break}case"TEXTAREA":t.value=r;break;default:throw error_createError({message:`Unsupported form control tag name $${o} found`,options:this.options})}i!==this.options.selectors.toInputName&&i!==this.options.selectors.subjectInputName&&i!==this.options.selectors.bodyInputName||t.setAttribute("disabled","disabled")}}this.formElement.setAttribute("method",FormMethod.PUT)}setDisabled(e,t){for(const i of this.formElement.elements)(t||html_isNotButton(i))&&(e?i.setAttribute("disabled","disabled"):i.removeAttribute("disabled"))}hideAll(){for(const e of this.formElement.elements)html_hideElement(e);this.formElement.classList.contains(this.options.selectors.containerClass)||html_hideElement(this.formElement)}isRegisteredFormField(e){const t=e.getAttribute("name");return Object.values(this.FORM_FIELDS).includes(t)}getRegisteredFormElements(){const e=this.formElement.querySelectorAll("input, textarea, select"),t=[];for(const i of e)this.isRegisteredFormField(i)&&t.push(i);return t}disable(e){this.setDisabled(!0,e)}enable(e){this.setDisabled(!1,e)}build(){if(this.options.logger.debug("Form: build()"),this.keyInput=this.formElement.querySelector(`input[name="${this.options.selectors.keyInputName}"]`),this.keyInput||(this.keyInput=document.createElement("input"),this.keyInput.type="hidden",this.keyInput.name=this.options.selectors.keyInputName,this.formElement.appendChild(this.keyInput)),this.options.enableAutoValidation){const e=this.getRegisteredFormElements();for(let t=0,i=e.length;t<i;t++){const i=e[t],r=i?.getAttribute("type");i?.addEventListener("radio"===r||"select"===r?"change":"input",this.container.validate.bind(this.container))}}this.on("PREVIEW",(e=>{if(e?.key||this.keyInput?.value)e?.key&&this.keyInput&&(this.keyInput.value=e.key,this.keyInput.dispatchEvent(new InputEvent("input",{bubbles:!0})));else{const e=error_createError({message:"Videomail key and its value for previewing is missing",options:this.options});this.emit("ERROR",{err:e})}})),this.on("STARTING_OVER",(()=>{this.resetForm()})),this.on("INVALID",(()=>{this.formElement.classList.add("invalid")})),this.on("VALID",(()=>{this.formElement.classList.remove("invalid")})),this.on("ERROR",(e=>{const t=e.err?.isBrowserProblem();t&&this.options.adjustFormOnBrowserError&&this.hideAll(),t&&this.hideSubmitButton()})),this.on("BUILT",(()=>{this.startListeningToSubmitEvents()}))}removeAllInputListeners(){const e=this.getRegisteredFormElements();for(const t of e){const e=t.getAttribute("type");"radio"===e||"select"===e?t.removeEventListener("change",this.container.validate.bind(this.container)):t.removeEventListener("input",this.container.validate.bind(this.container))}}hideSubmitButton(){const e=this.findSubmitButton();html_hideElement(e)}unload(){this.options.logger.debug("Form: unload()"),this.removeAllInputListeners(),util_Despot.removeAllListeners(),this.stopListeningToSubmitEvents(),this.resetForm()}resetForm(){this.formElement.setAttribute("method",""),this.formElement.reset();const e=this.getRegisteredFormElements();for(const t of e){const e=t.getAttribute("type");"hidden"===e?.toLowerCase()&&t.setAttribute("value","")}}startListeningToSubmitEvents(){const e=this.container.getSubmitButton();e&&(e.onclick=this.doTheSubmit.bind(this))}stopListeningToSubmitEvents(){const e=this.container.getSubmitButton();e&&(e.onclick=null)}async doTheSubmit(e){e?(this.options.logger.debug(`Form: doTheSubmit(${util_pretty(e)})`),e.preventDefault()):this.options.logger.debug("Form: doTheSubmit()");const t=this.formElement.getAttribute("action")??this.options.apiUrl;let i;switch(this.formElement.getAttribute("method")){case FormMethod.POST:i=FormMethod.POST;break;case FormMethod.PUT:i=FormMethod.PUT;break;default:i=FormMethod.POST}return this.container.hasElement()&&await this.container.submitAll(this.getData(),i,t),!1}getInvalidElement(){const e=this.getRegisteredFormElements();for(const t of e){const e=util_getValidity(t);if(!e?.valid)return t}return null}findSubmitButton(){return this.formElement.querySelector("[type='submit']")}hide(){html_hideElement(this.formElement)}show(){html_showElement(this.formElement)}constructor(e,t,i){super("Form",i),form_define_property(this,"container",void 0),form_define_property(this,"formElement",void 0),form_define_property(this,"keyInput",void 0),form_define_property(this,"FORM_FIELDS",{}),this.container=e,this.formElement=t,this.FORM_FIELDS={subject:i.selectors.subjectInputName,from:i.selectors.fromInputName,to:i.selectors.toInputName,cc:i.selectors.ccInputName,bcc:i.selectors.bccInputName,body:i.selectors.bodyInputName,key:i.selectors.keyInputName,parentKey:i.selectors.parentKeyInputName,sendCopy:i.selectors.sendCopyInputName}}}const wrappers_form=Form;function resource_define_property(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function findOriginalExc(e){if(e instanceof Error&&"response"in e){const t=e.response.body;if("error"in t){const e=t.error.message,i=t.error.cause,r=new error_HTTPVideomailError(e,{cause:i});return t.error.name&&(r.name=t.error.name),t.error.explanation&&(r.explanation=t.error.explanation),t.error.stack&&(r.stack=t.error.stack),t.error.status&&(r.status=t.error.status),t.error.code&&(r.code=t.error.code),r}}return e}class Resource{applyDefaultValue(e,t){return this.options.defaults[t]&&!e[t]&&(e[t]=this.options.defaults[t]),e}applyDefaultValues(e){let t={...e};return t=this.applyDefaultValue(t,"from"),t=this.applyDefaultValue(t,"to"),t=this.applyDefaultValue(t,"cc"),t=this.applyDefaultValue(t,"bcc"),t=this.applyDefaultValue(t,"subject"),t=this.applyDefaultValue(t,"body"),t}async get(e,t){const i=`${this.options.apiUrl}/videomail/${e}/${t}/snapshot`;try{const e=await superagent("get",i).type("json").set("Accept","application/json").withCredentials().set("Timezone-Id",this.timezoneId).set(constants.WHITELIST_KEY_LABEL,this.options.whitelistKey).timeout(this.options.timeouts.connection);return e.body}catch(e){throw error_createError({exc:findOriginalExc(e),options:this.options})}}async write(e,t){const i={[constants.WHITELIST_KEY_LABEL]:this.options.whitelistKey},r=t.public?"wall":"videomail";let o=`${this.options.apiUrl}/${r}/`;e===FormMethod.PUT&&t.key&&(o+=t.key);try{return await superagent(e,o).query(i).set("Timezone-Id",this.timezoneId).withCredentials().send(t).timeout(this.options.timeouts.connection)}catch(e){throw error_createError({exc:findOriginalExc(e),options:this.options})}}async getByAlias(e){return await this.get("alias",e)}async getByKey(e){return await this.get("key",e)}async reportError(e){const t={[constants.WHITELIST_KEY_LABEL]:this.options.whitelistKey},i=`${this.options.apiUrl}/client-error/`;try{const r={browser:e.browser,code:e.code,cookie:e.cookie,cpu:e.cpu,device:e.device,engine:e.engine,err:serializeError(e.err),explanation:e.explanation,location:e.location,logLines:e.logLines,orientation:e.orientation,os:e.os,screen:e.screen,whitelistKey:e.whitelistKey,status:e.status,title:e.title,message:e.message,stack:e.stack,versions:{videomailClient:package_namespaceObject.rE,videomailNinjaFormPlugin:this.options.versions?.videomailNinjaFormPlugin}};await superagent(FormMethod.POST,i).query(t).set("Timezone-Id",this.timezoneId).withCredentials().send(r).timeout(this.options.timeouts.connection)}catch(e){console.error(e)}}async post(e){const t=this.applyDefaultValues(e);t.versions||(t.versions={}),t.versions.videomailClient=package_namespaceObject.rE,t.recordLocation=window.location.href;const i=util_getBrowser(this.options);t.browserStats=i.getUsefulData();try{let e;if(this.options.callbacks.adjustFormDataBeforePosting){const i=this.options.callbacks.adjustFormDataBeforePosting(t);e=await this.write(FormMethod.POST,i)}else e=await this.write(FormMethod.POST,t);return e}catch(e){throw error_createError({exc:findOriginalExc(e),options:this.options})}}async put(e){return await this.write(FormMethod.PUT,e)}async form(e,t){let i;switch(this.options.enctype){case constants.public.ENC_TYPE_APP_JSON:i="json";break;case constants.public.ENC_TYPE_FORM:i="form";break;default:throw error_createError({err:new Error(`Invalid enctype given: ${this.options.enctype}`),options:this.options})}try{return await superagent.post(t).type(i).set("Timezone-Id",this.timezoneId).send(e).timeout(this.options.timeouts.connection)}catch(e){throw error_createError({exc:findOriginalExc(e),options:this.options})}}constructor(e){resource_define_property(this,"options",void 0),resource_define_property(this,"timezoneId",void 0),this.options=e,this.timezoneId=window.Intl.DateTimeFormat().resolvedOptions().timeZone}}const src_resource=Resource,NodeEnvType={DEVELOPMENT:"development",PRODUCTION:"production"};var process=__webpack_require__("./node_modules/process/browser.js");function getNodeEnv(){return process.env.NODE_ENV?process.env.NODE_ENV:NodeEnvType.DEVELOPMENT}const util_getNodeEnv=getNodeEnv;function isProductionMode(){return util_getNodeEnv()===NodeEnvType.PRODUCTION}const util_isProductionMode=isProductionMode,PRODUCTION=util_isProductionMode(),options_options={logger:console,logStackSize:30,verbose:!PRODUCTION,apiUrl:"https://videomail.io/api",socketUrl:"wss://videomail.io",whitelistKey:"videomail-client-demo",enablePause:!0,enableAutoPause:!0,enableSpace:!0,submitWithVideomail:!1,disableSubmit:!1,enableAutoValidation:!0,enableAutoUnload:!0,enableAutoSubmission:!0,enctype:"application/json",selectors:{containerId:void 0,containerClass:"videomail",replayClass:"replay",userMediaClass:"userMedia",visualsClass:"visuals",buttonClass:void 0,buttonsClass:"buttons",recordButtonClass:"record",pauseButtonClass:"pause",resumeButtonClass:"resume",previewButtonClass:"preview",recordAgainButtonClass:"recordAgain",submitButtonClass:"submit",subjectInputName:"subject",fromInputName:"from",toInputName:"to",ccInputName:"cc",bccInputName:"bcc",bodyInputName:"body",sendCopyInputName:"sendCopy",keyInputName:"videomail_key",parentKeyInputName:"videomail_parent_key",formId:void 0,submitButtonId:void 0,submitButtonSelector:void 0},audio:{enabled:!1,switch:!1,volume:.2,bufferSize:"auto"},video:{fps:15,limitSeconds:30,countdown:3,width:void 0,height:void 0,facingMode:"user",facingModeButton:!1,stretch:!1,mobileBreakPoint:void 0,autoPlay:void 0},image:{quality:.42,types:["webp","jpeg"]},text:{pausedHeader:"Paused",pausedHint:void 0,sending:"Teleporting",encoding:"Encoding",limitReached:"Limit reached",audioOff:"Audio off",audioOn:"Audio on",buttons:{record:"Record video",recordAgain:"Record again",resume:"Resume",pause:"Pause",preview:"Preview"}},notifier:{entertain:!1,entertainClass:"bg",entertainLimit:6,entertainInterval:9e3},timeouts:{userMedia:2e4,connection:1e4,pingInterval:3e4},loadUserMediaOnRecord:!1,callbacks:{adjustFormDataBeforePosting:void 0,adjustFormValueBeforePopulating:void 0},defaults:{from:void 0,to:void 0,cc:void 0,bcc:void 0,subject:void 0,body:void 0},displayErrors:!0,adjustFormOnBrowserError:!0,reportErrors:!0,disableFormWhenSubmitting:!0,fakeUaString:void 0,recalculateDimensionsOnWindowResize:!1,versions:{videomailNinjaFormPlugin:void 0}},src_options=options_options;function CollectLogger_define_property(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class CollectLogger{lifo(e,t){const i=t.join();return this.stack.length>this.options.logStackSize&&this.stack.pop(),this.stack.push(`[${e}] ${i}`),i}debug(...e){const t=this.lifo("debug",e);this.options.verbose&&(this.browser.isFirefox()?this.logger.debug(t):this.logger.groupCollapsed?(this.logger.groupCollapsed(t),this.logger.trace("Trace"),this.logger.groupEnd()):this.logger.debug?this.logger.debug(t):console.log(t))}error(...e){this.logger.error(this.lifo("error",e))}warn(...e){this.logger.warn(this.lifo("warn",e))}info(...e){this.logger.info(this.lifo("info",e))}getLines(){return this.stack}constructor(e){CollectLogger_define_property(this,"browser",void 0),CollectLogger_define_property(this,"logger",void 0),CollectLogger_define_property(this,"stack",[]),CollectLogger_define_property(this,"options",void 0),this.options=e,this.browser=util_getBrowser(e),this.logger=e.logger}}const util_CollectLogger=CollectLogger;var isTest_process=__webpack_require__("./node_modules/process/browser.js");function isTest(){return"test"===isTest_process.env.ENVIRON}const util_isTest=isTest;function mergeWithDefaultOptions(e={}){const t=deepmerge(src_options,e,{arrayMerge:(e,t)=>t}),i=new util_CollectLogger(t);return t.logger=i,util_isTest()&&(t.verbose=!1),t}const options_mergeWithDefaultOptions=mergeWithDefaultOptions,injectStylesIntoStyleTag=__webpack_require__("./node_modules/@rsbuild/core/compiled/style-loader/runtime/injectStylesIntoStyleTag.js");var injectStylesIntoStyleTag_default=__webpack_require__.n(injectStylesIntoStyleTag);const styleDomAPI=__webpack_require__("./node_modules/@rsbuild/core/compiled/style-loader/runtime/styleDomAPI.js");var styleDomAPI_default=__webpack_require__.n(styleDomAPI);const insertBySelector=__webpack_require__("./node_modules/@rsbuild/core/compiled/style-loader/runtime/insertBySelector.js");var insertBySelector_default=__webpack_require__.n(insertBySelector);const setAttributesWithoutAttributes=__webpack_require__("./node_modules/@rsbuild/core/compiled/style-loader/runtime/setAttributesWithoutAttributes.js");var setAttributesWithoutAttributes_default=__webpack_require__.n(setAttributesWithoutAttributes);const insertStyleElement=__webpack_require__("./node_modules/@rsbuild/core/compiled/style-loader/runtime/insertStyleElement.js");var insertStyleElement_default=__webpack_require__.n(insertStyleElement);const styleTagTransform=__webpack_require__("./node_modules/@rsbuild/core/compiled/style-loader/runtime/styleTagTransform.js");var styleTagTransform_default=__webpack_require__.n(styleTagTransform);const main_0=__webpack_require__("./node_modules/@rsbuild/core/compiled/css-loader/index.js??ruleSet[1].rules[10].oneOf[2].use[1]!builtin:lightningcss-loader??ruleSet[1].rules[10].oneOf[2].use[2]!./node_modules/stylus-loader/dist/cjs.js??ruleSet[1].rules[10].oneOf[2].use[3]!./src/styles/main.styl");var main_options={};function limitHeight(e,t,i){const r={unit:"px"};let o=document.documentElement.clientHeight;if(e&&(o=Math.min(e,o)),o<1)throw error_createError({message:`Limited height ${o} cannot be less than 1! (Called from ${i})`,options:t});return r.value=o,r}main_options.styleTagTransform=styleTagTransform_default(),main_options.setAttributes=setAttributesWithoutAttributes_default(),main_options.insert=insertBySelector_default().bind(null,"head"),main_options.domAPI=styleDomAPI_default(),main_options.insertStyleElement=insertStyleElement_default(),injectStylesIntoStyleTag_default()(main_0.A,main_options),main_0.A&&main_0.A.locals&&main_0.A.locals;const dimensions_limitHeight=limitHeight;function getOuterWidth(e){let t=e.getBoundingClientRect(),i=t.right-t.left;return i<1&&(t=document.body.getBoundingClientRect(),i=t.right-t.left),i}const dimensions_getOuterWidth=getOuterWidth;function limitWidth(e,t,i){const r={unit:"px"};let o;const n=dimensions_getOuterWidth(e);if(o=i&&"number"==typeof i?n>0&&n<i?n:i:n,Number.isInteger(o)&&o<1)throw error_createError({message:"Limited width cannot be less than 1!",options:t});return r.value=o,r}const dimensions_limitWidth=limitWidth;function useFullWidth(e){if(void 0===e)return;if(window.innerWidth<e){return{unit:"%",value:100}}}const dimensions_useFullWidth=useFullWidth;function disableElement(e){e&&("INPUT"===e.tagName||"BUTTON"===e.tagName?e.setAttribute("disabled","true"):e.classList.add("disabled"))}const html_disableElement=disableElement;function adjustButton(e,t,i,r){return r&&html_disableElement(e),i&&(e.type=i),t||html_hideElement(e),e}const html_adjustButton=adjustButton;function enableElement(e){e&&("INPUT"===e.tagName||"BUTTON"===e.tagName?e.removeAttribute("disabled"):e.classList.remove("disabled"))}const html_enableElement=enableElement;function isShown(e){if(!e)return!1;return!e.style.getPropertyValue("display").includes("none")}const html_isShown=isShown;function buttons_define_property(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class Buttons extends util_Despot{replaceClickHandler(e,t){e.onclick=e=>{e.preventDefault();try{t({event:e})}catch(e){this.emit("ERROR",{exc:e})}}}makeRadioButtonPair(e){let t,i;if(e.id&&(t=document.querySelector(`#${e.id}`)),!t){t=document.createElement("input"),t.id=e.id,t.type="radio",t.name=e.name,t.value=e.value,t.checked=e.checked,i=document.createElement("span"),i.classList.add("radioGroup"),i.appendChild(t);const r=document.createElement("label");r.htmlFor=e.id,r.textContent=e.label,i.appendChild(r),this.submitButton&&contains(this.buttonsElement,this.submitButton)?this.buttonsElement?.insertBefore(i,this.submitButton):this.buttonsElement?.appendChild(i)}return t.onchange=e.changeHandler,html_disableElement(t),t}makeButton(e,t,i,r,o,n,s,a=!0){let l;return l=o?document.querySelector(`#${o}`):s?document.querySelector(s):this.buttonsElement?.querySelector(`.${e}`),l?l=html_adjustButton(l,r,n,a):(l=document.createElement("button"),l.classList.add(e),this.options.selectors.buttonClass&&l.classList.add(this.options.selectors.buttonClass),l=html_adjustButton(l,r,n,a),l.innerHTML=t,this.submitButton&&contains(this.buttonsElement,this.submitButton)?this.buttonsElement?.insertBefore(l,this.submitButton):this.buttonsElement?.appendChild(l)),i&&this.replaceClickHandler(l,i),l}buildButtons(){this.options.disableSubmit||(this.submitButton?html_disableElement(this.submitButton):this.submitButton=this.makeButton(this.options.selectors.submitButtonClass,"Submit",void 0,!0,this.options.selectors.submitButtonId,"submit",this.options.selectors.submitButtonSelector,this.options.enableAutoValidation),this.container.hasForm()||this.replaceClickHandler(this.submitButton,this.submit.bind(this))),this.recordButton=this.makeButton(this.options.selectors.recordButtonClass,this.options.text.buttons.record,this.record.bind(this),!1),this.options.enablePause&&(this.pauseButton=this.makeButton(this.options.selectors.pauseButtonClass,this.options.text.buttons.pause,this.container.pause.bind(this.container),!1)),this.options.enablePause&&(this.resumeButton=this.makeButton(this.options.selectors.resumeButtonClass,this.options.text.buttons.resume,this.container.resume.bind(this.container),!1)),this.previewButton=this.makeButton(this.options.selectors.previewButtonClass,this.options.text.buttons.preview,this.container.stop.bind(this.container),!1),this.recordAgainButton=this.makeButton(this.options.selectors.recordAgainButtonClass,this.options.text.buttons.recordAgain,this.recordAgain.bind(this),!1),this.options.audio.switch&&(this.audioOffRadioPair=this.makeRadioButtonPair({id:"audioOffOption",name:"audio",value:"off",label:this.options.text.audioOff,checked:!isAudioEnabled(this.options),changeHandler:()=>{this.container.disableAudio()}}),this.audioOnRadioPair=this.makeRadioButtonPair({id:"audioOnOption",name:"audio",value:"on",label:this.options.text.audioOn,checked:isAudioEnabled(this.options),changeHandler:()=>{this.container.enableAudio()}}))}onFormReady(e){html_isShown(this.recordAgainButton)||e?.paused||html_showElement(this.recordButton),e?.paused||(html_disableElement(this.previewButton),html_hideElement(this.previewButton)),this.options.enableAutoValidation||html_enableElement(this.submitButton)}onGoingBack(){html_hideElement(this.recordAgainButton),html_showElement(this.recordButton),html_showElement(this.submitButton)}onReplayShown(){this.hide()}onUserMediaReady(e){this.onFormReady(),html_showElement(this.buttonsElement),html_showElement(this.audioOnRadioPair),html_showElement(this.audioOffRadioPair),html_isShown(this.recordButton)&&!e.recordWhenReady?html_enableElement(this.recordButton):html_isShown(this.recordAgainButton)&&!e.recordWhenReady&&html_enableElement(this.recordAgainButton),this.options.enableAutoValidation&&html_disableElement(this.submitButton),e.recordWhenReady||(html_isShown(this.audioOnRadioPair)&&html_enableElement(this.audioOnRadioPair),html_isShown(this.audioOffRadioPair)&&html_enableElement(this.audioOffRadioPair))}onResetting(){html_disableElement(this.submitButton),this.reset()}onPreview(){html_hideElement(this.recordButton),html_hideElement(this.previewButton),html_disableElement(this.audioOnRadioPair),html_disableElement(this.audioOffRadioPair),html_showElement(this.recordAgainButton),html_enableElement(this.recordAgainButton),this.options.enableAutoValidation||html_enableElement(this.submitButton)}enableSubmit(){html_enableElement(this.submitButton)}adjustButtonsForPause(){this.isCountingDown()||(this.pauseButton&&html_hideElement(this.pauseButton),html_showElement(this.resumeButton),html_enableElement(this.resumeButton),html_hideElement(this.recordButton),html_showElement(this.previewButton),html_enableElement(this.previewButton))}onFirstFrameSent(){html_hideElement(this.recordButton),html_hideElement(this.recordAgainButton),this.pauseButton&&(html_showElement(this.pauseButton),html_enableElement(this.pauseButton)),html_enableElement(this.previewButton),html_showElement(this.previewButton)}onRecording(e){e.framesCount>1?this.onFirstFrameSent():(html_disableElement(this.audioOffRadioPair),html_disableElement(this.audioOnRadioPair),html_disableElement(this.recordAgainButton),html_disableElement(this.recordButton))}onResuming(){html_hideElement(this.resumeButton),html_hideElement(this.recordButton),this.pauseButton&&(html_enableElement(this.pauseButton),html_showElement(this.pauseButton))}onStopping(){html_disableElement(this.previewButton),html_disableElement(this.recordButton),html_hideElement(this.pauseButton),html_hideElement(this.resumeButton)}onCountdown(){html_disableElement(this.recordButton),html_disableElement(this.audioOffRadioPair),html_disableElement(this.audioOnRadioPair)}onSubmitting(){this.options.logger.debug("Buttons: onSubmitting()"),html_disableElement(this.submitButton),html_disableElement(this.recordAgainButton)}onSubmitted(){html_disableElement(this.previewButton),html_disableElement(this.recordAgainButton),html_disableElement(this.recordButton),html_disableElement(this.submitButton)}onInvalid(){this.options.enableAutoValidation&&html_disableElement(this.submitButton)}onValid(){this.options.enableAutoValidation&&html_enableElement(this.submitButton)}onHidden(){html_hideElement(this.recordButton),html_hideElement(this.previewButton),html_hideElement(this.recordAgainButton),html_hideElement(this.resumeButton),html_hideElement(this.audioOnRadioPair),html_hideElement(this.audioOffRadioPair)}onEnablingAudio(){this.options.logger.debug("Buttons: onEnablingAudio()"),html_disableElement(this.recordButton),html_disableElement(this.audioOnRadioPair),html_disableElement(this.audioOffRadioPair)}onDisablingAudio(){this.options.logger.debug("Buttons: onDisablingAudio()"),html_disableElement(this.recordButton),html_disableElement(this.audioOnRadioPair),html_disableElement(this.audioOffRadioPair)}recordAgain(){html_disableElement(this.recordAgainButton),this.container.beginWaiting(),this.container.recordAgain()}onStartingOver(){html_showElement(this.submitButton)}submit(){this.container.submit()}record(){html_disableElement(this.recordButton),this.container.record()}initEvents(){this.options.logger.debug("Buttons: initEvents()"),this.on("USER_MEDIA_READY",(e=>{e.switchingFacingMode||this.onUserMediaReady(e)})),this.on("PREVIEW",(()=>{this.onPreview()})),this.on("PAUSED",(()=>{this.adjustButtonsForPause()})),this.on("RECORDING",(e=>{this.onRecording(e)})),this.on("FIRST_FRAME_SENT",(()=>{this.onFirstFrameSent()})),this.on("RESUMING",(()=>{this.onResuming()})),this.on("STOPPING",(()=>{this.onStopping()})),this.on("COUNTDOWN",(()=>{this.onCountdown()})),this.on("SUBMITTING",(()=>{this.onSubmitting()})),this.on("RESETTING",(()=>{this.onResetting()})),this.on("INVALID",(()=>{this.onInvalid()})),this.on("VALID",(()=>{this.onValid()})),this.on("SUBMITTED",(()=>{this.onSubmitted()})),this.on("HIDE",(()=>{this.onHidden()})),this.on("FORM_READY",(e=>{this.onFormReady(e)})),this.on("REPLAY_SHOWN",(()=>{this.onReplayShown()})),this.on("GOING_BACK",(()=>{this.onGoingBack()})),this.on("ENABLING_AUDIO",(()=>{this.onEnablingAudio()})),this.on("DISABLING_AUDIO",(()=>{this.onDisablingAudio()})),this.on("STARTING_OVER",(()=>{this.onStartingOver()})),this.on("CONNECTED",(()=>{this.options.loadUserMediaOnRecord&&html_isShown(this.recordButton)&&html_enableElement(this.recordButton)})),this.on("DISCONNECTED",(()=>{html_disableElement(this.recordButton),html_disableElement(this.audioOnRadioPair),html_disableElement(this.audioOffRadioPair)})),this.on("ERROR",(e=>{e.err?.isBrowserProblem()&&this.options.adjustFormOnBrowserError&&this.hide()}))}reset(){this.options.logger.debug("Buttons: reset()"),html_disableElement(this.pauseButton),html_disableElement(this.resumeButton),html_disableElement(this.recordButton),html_disableElement(this.previewButton),html_disableElement(this.recordAgainButton),html_disableElement(this.audioOnRadioPair),html_disableElement(this.audioOffRadioPair)}isRecordAgainButtonEnabled(){return!this.recordAgainButton?.disabled}isReady(){return!!this.recordButton&&this.isRecordButtonEnabled()}isRecordButtonEnabled(){return!this.recordButton?.disabled}setSubmitButton(e){this.submitButton=e}getSubmitButton(){return this.submitButton}build(){this.buttonsElement=this.container.querySelector(`.${this.options.selectors.buttonsClass}`),this.buttonsElement||(this.buttonsElement=document.createElement("div"),this.buttonsElement.classList.add(this.options.selectors.buttonsClass),this.container.appendChild(this.buttonsElement)),html_hideElement(this.buttonsElement),this.buildButtons(),this.built||this.initEvents(),this.built=!0}unload(){this.built&&(this.reset(),this.options.logger.debug("Buttons: unload()"),util_Despot.removeAllListeners(),this.hide(),this.built=!1)}hide(e=!1){html_hideElement(this.buttonsElement),e&&(html_hideElement(this.recordButton),html_hideElement(this.pauseButton),html_hideElement(this.resumeButton),html_hideElement(this.previewButton),html_hideElement(this.recordAgainButton),html_hideElement(this.submitButton),html_hideElement(this.audioOnRadioPair),html_hideElement(this.audioOffRadioPair))}show(){html_showElement(this.buttonsElement)}isCountingDown(){return this.container.isCountingDown()}constructor(e,t){super("Buttons",t),buttons_define_property(this,"container",void 0),buttons_define_property(this,"buttonsElement",void 0),buttons_define_property(this,"recordButton",void 0),buttons_define_property(this,"pauseButton",void 0),buttons_define_property(this,"resumeButton",void 0),buttons_define_property(this,"previewButton",void 0),buttons_define_property(this,"recordAgainButton",void 0),buttons_define_property(this,"submitButton",void 0),buttons_define_property(this,"audioOnRadioPair",void 0),buttons_define_property(this,"audioOffRadioPair",void 0),buttons_define_property(this,"built",!1),this.container=e}}const buttons=Buttons;function isHidden(e){if(!e)return!0;return e.style.getPropertyValue("display").includes("none")}const html_isHidden=isHidden;function countdown_define_property(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class Countdown{fire(e){this.unload(),this.hide(),setTimeout((function(){e()}),0)}countBackward(e){this.paused||(this.options.logger.debug(`Countdown ${this.countdown}`),void 0!==this.countdown&&(this.countdown--,this.countdown<1?this.fire(e):this.countdownElement&&(this.countdownElement.innerHTML=this.countdown.toString())))}start(e){if(!this.countdownElement)throw new Error("Unable to start countdown without an element");if("number"!=typeof this.options.video.countdown)throw new TypeError(`The defined countdown is not a valid number: ${this.options.video.countdown}`);this.countdown=this.options.video.countdown,this.countdownElement.innerHTML=this.countdown.toString(),this.show(),this.intervalId=window.setInterval(this.countBackward.bind(this,e),950)}pause(){this.paused=!0}resume(){this.paused=!1}build(){this.countdownElement=this.visuals.getElement()?.querySelector(".countdown"),this.countdownElement?this.hide():(this.countdownElement=document.createElement("p"),this.countdownElement.className="countdown",this.hide(),this.visuals.appendChild(this.countdownElement))}show(){html_showElement(this.countdownElement)}isCountingDown(){return Boolean(this.intervalId)}unload(){clearInterval(this.intervalId),this.paused=!1,this.intervalId=void 0}hide(){html_hideElement(this.countdownElement),this.unload()}constructor(e,t){countdown_define_property(this,"visuals",void 0),countdown_define_property(this,"options",void 0),countdown_define_property(this,"countdownElement",void 0),countdown_define_property(this,"intervalId",void 0),countdown_define_property(this,"countdown",void 0),countdown_define_property(this,"paused",!1),this.visuals=e,this.options=t}}const countdown=Countdown;function facingMode_define_property(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class FacingMode extends util_Despot{initEvents(){this.on("ERROR",(()=>{this.hide()}))}build(){this.facingModeElement=this.visuals.getElement()?.querySelector(".facingMode"),this.facingModeElement?this.hide():(this.facingModeElement=document.createElement("button"),this.facingModeElement.classList.add("facingMode"),this.facingModeElement.innerHTML="⤾",this.facingModeElement.onclick=e=>{e?.preventDefault();try{this.emit("SWITCH_FACING_MODE")}catch(e){this.emit("ERROR",{exc:e})}},this.hide(),this.visuals.appendChild(this.facingModeElement)),this.initEvents()}hide(){html_hideElement(this.facingModeElement)}show(){html_showElement(this.facingModeElement)}constructor(e,t){super("Facing Mode",t),facingMode_define_property(this,"visuals",void 0),facingMode_define_property(this,"facingModeElement",void 0),this.visuals=e}}const facingMode=FacingMode;function pausedNote_define_property(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class PausedNote{hasPausedHintText(){return this.options.text.pausedHint}build(){this.pausedBlockElement=this.visuals.getElement()?.querySelector(".paused"),this.pausedHeaderElement=this.visuals.getElement()?.querySelector(".pausedHeader"),this.pausedHeaderElement?(this.hide(),this.pausedHeaderElement.innerHTML=this.options.text.pausedHeader,this.options.text.pausedHint&&this.pausedHintElement&&(this.pausedHintElement.innerHTML=this.options.text.pausedHint)):(this.pausedBlockElement=document.createElement("div"),this.pausedBlockElement.classList.add("paused"),this.pausedHeaderElement=document.createElement("p"),this.pausedHeaderElement.classList.add("pausedHeader"),this.hide(),this.pausedHeaderElement.innerHTML=this.options.text.pausedHeader,this.pausedBlockElement.appendChild(this.pausedHeaderElement),this.hasPausedHintText()&&(this.pausedHintElement=this.visuals.getElement()?.querySelector(".pausedHint"),this.pausedHintElement||(this.pausedHintElement=document.createElement("p"),this.pausedHintElement.classList.add("pausedHint"),this.pausedBlockElement.appendChild(this.pausedHintElement)),this.options.text.pausedHint&&(this.pausedHintElement.innerHTML=this.options.text.pausedHint)),this.visuals.appendChild(this.pausedBlockElement))}hide(){html_hideElement(this.pausedBlockElement)}show(){html_showElement(this.pausedBlockElement)}constructor(e,t){pausedNote_define_property(this,"visuals",void 0),pausedNote_define_property(this,"options",void 0),pausedNote_define_property(this,"pausedBlockElement",void 0),pausedNote_define_property(this,"pausedHeaderElement",void 0),pausedNote_define_property(this,"pausedHintElement",void 0),this.visuals=e,this.options=t}}const pausedNote=PausedNote;function recordNote_define_property(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class RecordNote{build(){this.recordNoteElement=this.visuals.getElement()?.querySelector(".recordNote"),this.recordNoteElement?this.hide():(this.recordNoteElement=document.createElement("p"),this.recordNoteElement.classList.add("recordNote"),this.hide(),this.visuals.appendChild(this.recordNoteElement))}stop(){this.hide(),this.recordNoteElement?.classList.remove("near"),this.recordNoteElement?.classList.remove("nigh")}setNear(){this.recordNoteElement?.classList.add("near")}setNigh(){this.recordNoteElement?.classList.add("nigh")}hide(){html_hideElement(this.recordNoteElement)}show(){html_showElement(this.recordNoteElement)}constructor(e){recordNote_define_property(this,"visuals",void 0),recordNote_define_property(this,"recordNoteElement",void 0),this.visuals=e}}const recorder_recordNote=RecordNote;function pad(e){const t=Math.abs(e);return t<10?e<0?`-0${t}`:`0${t}`:String(e)}const util_pad=pad;function recordTimer_define_property(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class RecordTimer{thresholdReached(e,t){return e>=this.options.video.limitSeconds*t}isNear(e){return!(this.nearComputed||!this.thresholdReached(e,.6))&&(this.nearComputed=!0,!0)}endIsNigh(e){return!(this.endNighComputed||!this.thresholdReached(e,.8))&&(this.endNighComputed=!0,!0)}setNear(){this.recordTimerElement?.classList.add("near")}setNigh(){this.recordTimerElement?.classList.add("nigh")}check(e){const t=this.getStartSeconds()-Math.floor(e/1e3);t!==this.countdown&&(this.countdown=t,this.update(),this.countdown<1&&this.visuals.stop())}update(){if(void 0===this.countdown)throw new Error("Countdown is set to undefined, unable to update timer");const e=Math.floor(this.countdown/60),t=this.countdown-60*e;if(!this.nearComputed||!this.endNighComputed){const e=this.options.video.limitSeconds-this.countdown;this.isNear(e)?(this.recordNote.setNear(),this.setNear(),this.options.logger.debug(`End is near, ${this.countdown} seconds to go`)):this.endIsNigh(e)&&(this.recordNote.setNigh(),this.setNigh(),this.options.logger.debug(`End is nigh, ${this.countdown} seconds to go`))}this.recordTimerElement&&(this.recordTimerElement.innerHTML=`${e}:${util_pad(t)}`)}hide(){html_hideElement(this.recordTimerElement)}show(){this.recordTimerElement?.classList.remove("near"),this.recordTimerElement?.classList.remove("nigh"),html_showElement(this.recordTimerElement)}getSecondsRecorded(){return void 0===this.countdown?this.getSecondsRecorded():this.getStartSeconds()-this.countdown}getStartSeconds(){return this.options.video.limitSeconds}setLimitSeconds(e){this.options.video.limitSeconds=e}start(){this.countdown=this.getStartSeconds(),this.nearComputed=this.endNighComputed=!1,this.started=!0,this.update(),this.show()}pause(){this.recordNote.hide()}resume(){this.recordNote.show()}isStopped(){return void 0===this.countdown}stop(){!this.isStopped()&&this.started&&(this.options.logger.debug(`Stopping record timer. Was recording for about ~${this.getSecondsRecorded()} seconds.`),this.hide(),this.recordNote.stop(),this.countdown=void 0,this.started=!1)}build(){this.recordTimerElement=this.visuals.getElement()?.querySelector(".recordTimer"),this.recordTimerElement?this.hide():(this.recordTimerElement=document.createElement("p"),this.recordTimerElement.classList.add("recordTimer"),this.hide(),this.visuals.appendChild(this.recordTimerElement))}constructor(e,t,i){recordTimer_define_property(this,"visuals",void 0),recordTimer_define_property(this,"recordNote",void 0),recordTimer_define_property(this,"options",void 0),recordTimer_define_property(this,"recordTimerElement",void 0),recordTimer_define_property(this,"nearComputed",!1),recordTimer_define_property(this,"endNighComputed",!1),recordTimer_define_property(this,"started",!1),recordTimer_define_property(this,"countdown",void 0),this.visuals=e,this.recordNote=t,this.options=i}}const recordTimer=RecordTimer;function recorderInsides_define_property(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class RecorderInsides extends util_Despot{startRecording(){this.recordTimer.start()}resumeRecording(){this.recordTimer.resume()}stopRecording(){this.recordTimer.stop()}pauseRecording(){this.isCountingDown()?this.countdown?.pause():this.recordTimer.pause()}onResetting(){this.hidePause(),this.hideCountdown(),this.recordTimer.stop(),this.facingMode?.hide()}initEvents(){this.options.logger.debug("RecorderInsides: initEvents()"),this.on("USER_MEDIA_READY",(()=>{this.facingMode?.show()})),this.on("RECORDING",(()=>{this.startRecording()})),this.on("RESUMING",(()=>{this.resumeRecording()})),this.on("STOPPING",(()=>{this.stopRecording()})),this.on("PAUSED",(()=>{this.pauseRecording()})),this.on("ERROR",(()=>{this.onResetting()})),this.on("RESETTING",(()=>{this.onResetting()})),this.on("HIDE",(()=>{this.hideCountdown()}))}build(){this.options.logger.debug("RecorderInsides: build()"),this.countdown?.build(),this.pausedNote?.build(),this.facingMode?.build(),this.recordNote.build(),this.recordTimer.build(),this.built||this.initEvents(),this.built=!0}unload(){this.countdown?.unload(),this.built=!1}showPause(){this.pausedNote?.show()}hidePause(){this.pausedNote?.hide()}hideCountdown(){this.countdown?.hide()}startCountdown(e){this.countdown?.start(e)}resumeCountdown(){this.countdown?.resume()}isCountingDown(){return this.countdown?.isCountingDown()}checkTimer(e){this.recordTimer.check(e)}setLimitSeconds(e){this.options.video.limitSeconds=e,this.recordTimer.setLimitSeconds(e)}constructor(e,t){super("RecorderInsides",t),recorderInsides_define_property(this,"recordNote",void 0),recorderInsides_define_property(this,"recordTimer",void 0),recorderInsides_define_property(this,"countdown",void 0),recorderInsides_define_property(this,"facingMode",void 0),recorderInsides_define_property(this,"pausedNote",void 0),recorderInsides_define_property(this,"built",!1),this.recordNote=new recorder_recordNote(e),this.recordTimer=new recordTimer(e,this.recordNote,t);const i=util_getBrowser(t);t.video.countdown&&(this.countdown=new countdown(e,t)),t.video.facingModeButton&&i.isMobile()&&(this.facingMode=new facingMode(e,t)),t.enablePause&&(this.pausedNote=new pausedNote(e,t))}}const recorderInsides=RecorderInsides;function notifier_define_property(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const NOTIFIER_MESSAGE_ID="notifierMessage";class Notifier extends util_Despot{onStopping(e=!1){let t="";this.visuals.beginWaiting(),e&&(this.options.logger.debug("Limit reached"),t+=`${this.options.text.limitReached}.<br/>`),t+=`${this.options.text.sending} …`,this.notify(t,void 0,{stillWait:!0,entertain:this.options.notifier.entertain})}onConnecting(){this.notify("Connecting …")}onLoadingUserMedia(){this.notify("Loading webcam …")}onProgress(e,t){let i;isAudioEnabled(this.options)?(i=`Video: ${e}`,t&&(i+=`, Audio: ${t}`)):i=e,this.setExplanation(i)}onBeginVideoEncoding(){this.visuals.beginWaiting();const e=`${this.options.text.encoding} …`;this.notify(e,void 0,{stillWait:!0,entertain:this.options.notifier.entertain}),this.hideExplanation()}initEvents(){this.options.logger.debug("Notifier: initEvents()"),this.on("CONNECTING",(()=>{this.onConnecting()})),this.on("LOADING_USER_MEDIA",(()=>{this.onLoadingUserMedia()})),this.on("USER_MEDIA_READY",(e=>{this.correctNotifierDimensions(),this.hide()})),this.on("PREVIEW",(()=>{this.hide()})),this.on("STOPPING",(e=>{this.onStopping(e.limitReached)})),this.on("PROGRESS",(e=>{this.onProgress(e.frameProgress,e.sampleProgress)})),this.on("BEGIN_VIDEO_ENCODING",(()=>{this.onBeginVideoEncoding()})),this.on("UNLOADING",(()=>{this.notify("Unloading …")})),this.on("DISCONNECTED",(()=>{this.notify("Disconnected")})),this.on("CONNECTED",(()=>{this.notify("Connected"),this.options.loadUserMediaOnRecord&&this.hide()})),this.on("WINDOW_RESIZE",(()=>{this.correctNotifierDimensions()}))}correctNotifierDimensions(){if(this.notifyElement)if(this.options.video.stretch){const e=this.visuals.getRecorderHeight(!0,!0);this.notifyElement.style.width="auto",e&&(this.notifyElement.style.height=`${e.value}${e.unit}`)}else{let e,t=dimensions_useFullWidth(this.options.video.mobileBreakPoint);t||(t=this.visuals.getRecorderWidth(!0),e=this.visuals.getRecorderHeight(!0)),t?this.notifyElement.style.width=`${t.value}${t.unit}`:this.notifyElement.style.removeProperty("width"),e?this.notifyElement.style.height=`${e.value}${e.unit}`:this.notifyElement.style.removeProperty("height")}}show(){html_showElement(this.notifyElement)}runEntertainment(){if(this.options.notifier.entertain){if(!this.entertaining){const e=Math.floor(Math.random()*this.options.notifier.entertainLimit+1);this.notifyElement&&(this.notifyElement.className=`notifier entertain ${this.options.notifier.entertainClass}${e}`),this.entertainTimeoutId=window.setTimeout(this.runEntertainment.bind(this),this.options.notifier.entertainInterval),this.entertaining=!0}}else this.cancelEntertainment()}cancelEntertainment(){this.notifyElement&&this.notifyElement.classList.remove("entertain"),clearTimeout(this.entertainTimeoutId),this.entertainTimeoutId=void 0,this.entertaining=!1}error(e){const t=e.message,i=e.explanation;t||this.options.logger.debug(`Weird empty error message generated for error ${util_pretty(e)}`),this.notify(t,i,{blocking:!0,problem:!0,classList:e.getClassList(),removeDimensions:util_getBrowser(this.options).isMobile()})}getMessageElement(){return this.messageElement||(this.messageElement=document.querySelector("#notifierMessage")),this.messageElement}setMessage(e,t){if(this.options.logger.debug(`Notifier: setMessage(${e})`),this.getMessageElement()||(this.messageElement=document.createElement("h2"),this.messageElement.id="notifierMessage",this.notifyElement?this.explanationElement?this.notifyElement.insertBefore(this.messageElement,this.explanationElement):this.notifyElement.appendChild(this.messageElement):this.options.logger.warn(`Unable to show message ${e} because notifyElement is empty`)),e.length>0)if(this.messageElement){const i=t?.problem;this.messageElement.innerHTML=(i?"&#x2639; ":"")+e}else this.options.logger.warn("There is no message element for displaying a message");else this.options.logger.warn("Not going to update notifierMessage element because message is empty");html_showElement(this.messageElement)}setExplanation(e){this.options.logger.debug(`Notifier: setExplanation(${e})`),this.explanationElement||(this.explanationElement=document.createElement("p"),this.explanationElement.classList.add("explanation"),this.notifyElement?this.notifyElement.appendChild(this.explanationElement):this.options.logger.warn(`Unable to show explanation because notifyElement is empty: ${e}`)),this.explanationElement.innerHTML=e,html_showElement(this.explanationElement)}build(){this.options.logger.debug("Notifier: build()"),this.notifyElement=this.visuals.getElement()?.querySelector(".notifier"),this.notifyElement?this.hide():(this.notifyElement=document.createElement("div"),this.hide(),this.visuals.appendChild(this.notifyElement)),this.built||this.initEvents(),this.built=!0}hideMessage(){html_hideElement(this.getMessageElement())}hideExplanation(){html_hideElement(this.explanationElement)}hide(){this.cancelEntertainment(),this.notifyElement&&(html_hideElement(this.notifyElement),this.notifyElement.classList.remove("blocking")),this.hideMessage(),this.hideExplanation()}isVisible(){return!!this.built&&(this.notifyElement&&!html_isHidden(this.notifyElement))}isBuilt(){return this.built}notify(e,t,i={}){const r=[e,t].filter(Boolean);this.options.logger.debug(`Notifier: notify(${r.join(", ")})`);const o=i.stillWait??!1,n=i.entertain??!1,s=i.blocking??!1,a=i.classList??!1,l=i.removeDimensions??!1;this.notifyElement&&(n||(this.notifyElement.className="notifier"),a&&a.forEach((e=>{this.notifyElement?.classList.add(e)})),l&&(this.notifyElement.style.width="auto",this.notifyElement.style.height="auto")),s?(this.notifyElement?.classList.add("blocking"),this.emit("BLOCKING")):this.emit("NOTIFYING"),this.visuals.hideReplay(),this.visuals.hideRecorder(),this.setMessage(e,i),t&&t.length>0&&this.setExplanation(t),n?this.runEntertainment():this.cancelEntertainment(),this.visuals.showVisuals(),this.show(),o||this.visuals.endWaiting()}constructor(e,t){super("Notifier",t),notifier_define_property(this,"visuals",void 0),notifier_define_property(this,"notifyElement",void 0),notifier_define_property(this,"messageElement",void 0),notifier_define_property(this,"explanationElement",void 0),notifier_define_property(this,"entertainTimeoutId",void 0),notifier_define_property(this,"entertaining",!1),notifier_define_property(this,"built",!1),this.visuals=e}}const notifier=Notifier;function figureMinHeight(e,t){let i;if(t.video.height){if(i=e?Math.min(t.video.height,e):t.video.height,i<1)throw error_createError({message:`Got a min height less than 1 (${i})!`,options:t})}else i=e;return i}const dimensions_figureMinHeight=figureMinHeight;function getRatio(e,t,i){let r=1;const o=t&&i,n=e.video.height,s=e.video.width;return n&&s?r=o&&(t<n||i<s)?t/i:n/s:o&&(r=t/i),r}const dimensions_getRatio=getRatio;function calculateHeight(e,t,i,r,o){const n={unit:"px"};let s=t;if(e&&o){s=dimensions_limitWidth(o,i,s).value}const a=r??dimensions_getRatio(i,void 0,t),l=s?Math.round(s*a):void 0;if(l&&Number.isInteger(l)&&l<1)throw error_createError({message:"Just calculated a height less than 1 which is wrong.",options:i});const d=dimensions_figureMinHeight(l,i);return n.value=d,n}const dimensions_calculateHeight=calculateHeight;function calculateWidth(e,t,i,r){const o={unit:"px"};let n=dimensions_figureMinHeight(i,t);if(e){n=dimensions_limitHeight(n,t,"calculateWidth").value}if(!n||n<1)throw error_createError({message:`Height ${n} cannot be smaller than 1 when calculating width.`,options:t});const s=r??dimensions_getRatio(t,i),a=Math.round(n/s);if(a<1)throw error_createError({message:"Calculated width cannot be smaller than 1!",options:t});return o.value=a,o}const dimensions_calculateWidth=calculateWidth;function AudioRecorder_define_property(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const CHANNELS=1;function getAudioContextClass(){return window.AudioContext}class AudioRecorder{hasAudioContext(){return Boolean(getAudioContextClass())&&Boolean(this.getAudioContext())}getAudioContext(){if(!this.vcAudioContext){const e=getAudioContextClass();this.vcAudioContext=new e}return this.vcAudioContext}onAudioProcess(e,t){if(!this.userMedia.isRecording()||this.userMedia.isPaused())return;const i=e.inputBuffer.getChannelData(0);t(new audio_sample(i))}init(e){this.options.logger.debug("AudioRecorder: init()");const t=this.getAudioContext().createGain();try{this.audioInput=this.getAudioContext().createMediaStreamSource(e)}catch(e){throw error_createError({message:"Webcam has no audio",exc:e,options:this.options})}let{bufferSize:i}=this.options.audio;if("auto"===i&&(i=util_getBrowser(this.options).isFirefox()?512:2048),!is_power_of_two(i))throw error_createError({message:"Audio buffer size must be a power of two.",options:this.options});if(!this.options.audio.volume||src_options.audio.volume>1)throw error_createError({message:"Audio volume must be between zero and one.",options:this.options});t.gain.value=this.options.audio.volume,this.scriptProcessor=this.getAudioContext().createScriptProcessor(i,1,1),this.audioInput.connect(this.scriptProcessor),this.scriptProcessor.connect(this.getAudioContext().destination),this.audioInput.connect(t),t.connect(this.scriptProcessor)}record(e){this.options.logger.debug("AudioRecorder: record()"),this.scriptProcessor&&(this.scriptProcessor.onaudioprocess=t=>{this.onAudioProcess(t,e)})}stop(){this.options.logger.debug("AudioRecorder: stop()"),this.scriptProcessor&&(this.scriptProcessor.onaudioprocess=null),this.audioInput&&this.audioInput.disconnect(),this.hasAudioContext()&&this.getAudioContext().close().then((()=>{this.options.logger.debug("AudioRecorder: audio context is closed"),this.vcAudioContext=void 0})).catch((function(e){if(e instanceof Error)throw error_createError({err:e,options:src_options});throw e}))}getSampleRate(){return this.hasAudioContext()?this.getAudioContext().sampleRate:-1}constructor(e,t){AudioRecorder_define_property(this,"scriptProcessor",void 0),AudioRecorder_define_property(this,"audioInput",void 0),AudioRecorder_define_property(this,"vcAudioContext",void 0),AudioRecorder_define_property(this,"userMedia",void 0),AudioRecorder_define_property(this,"options",void 0),this.options=t,this.userMedia=e}}const media_AudioRecorder=AudioRecorder;function getFirstVideoTrack(e){const t=e.getVideoTracks();let i;return t[0]&&(i=t[0]),i}const media_getFirstVideoTrack=getFirstVideoTrack,MEDIA_EVENTS=["loadstart","suspend","progress","abort","emptied","stalled","pause","loadeddata","waiting","playing","canplay","canplaythrough","seeking","seeked","ended","ratechange","durationchange","volumechange"],mediaEvents=MEDIA_EVENTS;function userMedia_define_property(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const EVENT_ASCII="|—O—|";class UserMedia extends util_Despot{attachMediaStream(e){if(this.currentVisualStream=e,!this.rawVisualUserMedia)throw error_createError({message:"Error attaching stream to element.",explanation:"Contact the developer about this",options:this.options});this.rawVisualUserMedia.srcObject=e}setVisualStream(e){e?this.attachMediaStream(e):(this.rawVisualUserMedia?.removeAttribute("srcObject"),this.rawVisualUserMedia?.removeAttribute("src"),this.currentVisualStream=void 0)}hasEnded(){return this.rawVisualUserMedia?.ended?this.rawVisualUserMedia.ended:!this.currentVisualStream?.active}hasInvalidDimensions(){return!!(this.rawVisualUserMedia?.videoWidth&&this.rawVisualUserMedia.videoWidth<3||this.rawVisualUserMedia?.height&&this.rawVisualUserMedia.height<3)}logEvent(e,t){this.options.logger.debug(`UserMedia: ... |—O—| event ${e}: ${util_pretty(t)}`)}outputEvent(e){this.logEvent(e.type,{readyState:this.rawVisualUserMedia?.readyState}),this.rawVisualUserMedia?.removeEventListener(e.type,this.outputEvent.bind(this))}unloadRemainingEventListeners(){this.options.logger.debug("UserMedia: unloadRemainingEventListeners()"),mediaEvents.forEach((e=>{this.rawVisualUserMedia?.removeEventListener(e,this.outputEvent.bind(this))}))}audioRecord(e){util_Despot.removeListener("SENDING_FIRST_FRAME"),this.audioRecorder?.record(e)}init(e,t,i,r,o){this.stop(e,{aboutToInitialize:!0,switchingFacingMode:o}),this.onPlayReached=!1,this.onLoadedMetaDataReached=!1,this.playingPromiseReached=!1,isAudioEnabled(this.options)&&(this.audioRecorder??=new media_AudioRecorder(this,this.options));const n=()=>{this.options.logger.debug("UserMedia: unloadAllEventListeners()"),this.unloadRemainingEventListeners(),util_Despot.removeListener("SENDING_FIRST_FRAME"),this.rawVisualUserMedia?.removeEventListener("play",l),this.rawVisualUserMedia?.removeEventListener("loadedmetadata",d)},s=()=>{try{this.rawVisualUserMedia?.load(),this.rawVisualUserMedia?.paused&&(this.options.logger.debug(`UserMedia: play(): media.readyState=${this.rawVisualUserMedia.readyState}, media.paused=${this.rawVisualUserMedia.paused}, media.ended=${this.rawVisualUserMedia.ended}, media.played=${util_pretty(this.rawVisualUserMedia.played)}`),this.rawVisualUserMedia.play().then((()=>{this.playingPromiseReached||(this.options.logger.debug("UserMedia: play promise successful. Playing now."),this.playingPromiseReached=!0)})).catch((e=>{if(!(e instanceof Error))throw error_createError({message:"Failed to play user media upon play event.",exc:e,options:this.options});this.options.logger.warn(`Caught pending user media promise exception: ${e.toString()}`)})))}catch(e){n(),r(e)}},a=()=>{const o=this.rawVisualUserMedia?.readyState;if(this.options.logger.debug(`UserMedia: fireCallbacks(readyState=${o}, onPlayReached=${this.onPlayReached}, onLoadedMetaDataReached=${this.onLoadedMetaDataReached})`),this.onPlayReached&&this.onLoadedMetaDataReached&&(t(),this.audioRecorder))try{this.audioRecorder.init(e),this.on("SENDING_FIRST_FRAME",(()=>{this.audioRecord(i)}))}catch(e){n(),r(e)}},l=()=>{try{this.logEvent("play",{readyState:this.rawVisualUserMedia?.readyState,audio:isAudioEnabled(this.options),width:this.rawVisualUserMedia?.width,height:this.rawVisualUserMedia?.height,videoWidth:this.rawVisualUserMedia?.videoWidth,videoHeight:this.rawVisualUserMedia?.videoHeight}),this.rawVisualUserMedia?.removeEventListener("play",l),this.hasEnded()||this.hasInvalidDimensions()?r(error_createError({message:"Already busy",explanation:"Probably another browser window is using your webcam?",options:this.options})):(this.onPlayReached=!0,a())}catch(e){n(),r(e)}},d=()=>{this.logEvent("loadedmetadata",{readyState:this.rawVisualUserMedia?.readyState,paused:this.rawVisualUserMedia?.paused,width:this.rawVisualUserMedia?.width,height:this.rawVisualUserMedia?.height,videoWidth:this.rawVisualUserMedia?.videoWidth,videoHeight:this.rawVisualUserMedia?.videoHeight}),this.rawVisualUserMedia?.removeEventListener("loadedmetadata",d),this.hasEnded()||this.hasInvalidDimensions()||(this.emit("LOADED_META_DATA"),this.onLoadedMetaDataReached=!0,a())};try{const t=media_getFirstVideoTrack(e);if(t){if(!t.enabled)throw error_createError({message:"Webcam is disabled",explanation:"The video track seems to be disabled. Enable it in your system.",options:this.options});{let e="";t.label&&t.label.length>0&&(e=e.concat(t.label)),e=e.concat(` with enabled=${t.enabled}, muted=${t.muted}, readyState=${t.readyState}`),this.options.logger.debug(`UserMedia: ${t.kind} detected. ${e}`)}}else this.options.logger.debug("UserMedia: detected (but no video tracks exist");this.rawVisualUserMedia?.addEventListener("loadedmetadata",d),this.rawVisualUserMedia?.addEventListener("play",l),this.rawVisualUserMedia?.addEventListener("error",(e=>{this.options.logger.warn(`Caught video element error event: ${util_pretty(e)}`)})),this.setVisualStream(e),s()}catch(e){this.emit("ERROR",{exc:e})}}isReady(){return Boolean(this.rawVisualUserMedia?.src)}stop(e,t){try{let i=e;if(!t?.aboutToInitialize){i??=this.currentVisualStream;const e=i?.getTracks();e&&e.forEach((e=>{e.stop()})),this.setVisualStream(),this.audioRecorder?.stop(),this.audioRecorder=void 0}t?.switchingFacingMode||(this.paused=this.recording=!1)}catch(e){this.emit("ERROR",{exc:e})}}createCanvas(){const e=document.createElement("canvas"),t=this.getRawWidth(!0);t.value&&(e.width=t.value);const i=this.getRawHeight(!0);return i&&(e.height=i),e}getVideoHeight(){if(this.rawVisualUserMedia)return this.rawVisualUserMedia.videoHeight||this.rawVisualUserMedia.height}getVideoWidth(){if(this.rawVisualUserMedia)return this.rawVisualUserMedia.videoWidth||this.rawVisualUserMedia.width}hasVideoWidth(){const e=this.getVideoWidth();return e&&e>0}getRawWidth(e){let t;const i={unit:"px"};if(t=e?this.getVideoWidth():this.options.video.width?this.options.video.width:this.getVideoWidth(),e){const e=this.recorder.limitWidth(t);t=e?.value}return i.value=t,i}getRawHeight(e){let t;if(e){t=this.options.video.height||this.getVideoHeight();const i=this.recorder.getRatio(),r=this.getRawWidth(e);void 0!==i&&r.value&&(t=r.value*i)}else t=this.options.video.height?this.options.video.height:this.getVideoHeight();if(e){t=this.recorder.limitHeight(t).value}return t}getRawVisuals(){return this.rawVisualUserMedia}pause(){this.paused=!0}isPaused(){return this.paused}resume(){this.paused=!1}record(){this.recording=!0}isRecording(){return this.recording}getAudioSampleRate(){return this.audioRecorder?this.audioRecorder.getSampleRate():-1}getCharacteristics(){return{audioSampleRate:this.getAudioSampleRate(),muted:this.rawVisualUserMedia?.muted,width:this.rawVisualUserMedia?.width,height:this.rawVisualUserMedia?.height,videoWidth:this.rawVisualUserMedia?.videoWidth,videoHeight:this.rawVisualUserMedia?.videoHeight}}constructor(e,t){super("UserMedia",t),userMedia_define_property(this,"recorder",void 0),userMedia_define_property(this,"rawVisualUserMedia",void 0),userMedia_define_property(this,"paused",!1),userMedia_define_property(this,"recording",!1),userMedia_define_property(this,"audioRecorder",void 0),userMedia_define_property(this,"currentVisualStream",void 0),userMedia_define_property(this,"onPlayReached",!1),userMedia_define_property(this,"onLoadedMetaDataReached",!1),userMedia_define_property(this,"playingPromiseReached",!1),this.recorder=e,this.rawVisualUserMedia=e.getRawVisualUserMedia(),mediaEvents.forEach((e=>{this.rawVisualUserMedia?.addEventListener(e,this.outputEvent.bind(this),!1)}))}}const visuals_userMedia=UserMedia;var Buffer=__webpack_require__("./node_modules/buffer/index.js").Buffer;function recorder_define_property(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const PIPE_SYMBOL="°º¤ø,¸¸,ø¤º°`°º¤ø,¸,ø¤°º¤ø,¸¸,ø¤º°`°º¤ø,¸ ";class Recorder extends util_Despot{writeStream(e,t){if(this.stream)if(this.stream.destroyed){this.stopPings();const e=error_createError({message:"Already disconnected",explanation:"Sorry, connection to the server has been destroyed. Please reload.",options:this.options});this.emit("ERROR",{err:e})}else{const i=t?.onFlushedCallback;try{this.stream.write(e,(()=>{if(i)try{i(t)}catch(e){const t=error_createError({message:"Failed to write stream buffer",explanation:`stream.write() failed because of ${util_pretty(e)}`,options:this.options,exc:e});this.emit("ERROR",{err:t})}}))}catch(e){const t=error_createError({message:"Failed writing to server",explanation:`stream.write() failed because of ${util_pretty(e)}`,options:this.options,exc:e});this.emit("ERROR",{err:t})}}}sendPings(){this.pingInterval=window.setInterval((()=>{this.options.logger.debug("Recorder: pinging..."),this.writeStream(Buffer.from(""))}),this.options.timeouts.pingInterval)}stopPings(){clearInterval(this.pingInterval)}onAudioSample(e){this.samplesCount++;const t=e.toBuffer();this.writeStream(t)}show(){html_showElement(this.recorderElement)}onUserMediaReady(e){try{this.options.logger.debug(`Recorder: onUserMediaReady(${e?util_pretty(e):""})`);const t=e?.switchingFacingMode;this.userMediaLoading=this.blocking=this.unloaded=this.submitting=!1,this.userMediaLoaded=!0,t||(this.loop=this.createLoop()),this.show(),e?.recordWhenReady&&this.record(),this.emit("USER_MEDIA_READY",{switchingFacingMode:e?.switchingFacingMode,paused:this.isPaused(),recordWhenReady:e?.recordWhenReady})}catch(e){this.emit("ERROR",{exc:e})}}clearRetryTimeout(){this.retryTimeout&&(this.options.logger.debug("Recorder: clearRetryTimeout()"),window.clearTimeout(this.retryTimeout),this.retryTimeout=void 0)}calculateFrameProgress(){return`${(this.confirmedFrameNumber/(this.framesCount||1)*100).toFixed(2)}%`}calculateSampleProgress(){return`${(this.confirmedSampleNumber/(this.samplesCount||1)*100).toFixed(2)}%`}updateOverallProgress(){this.frameProgress=this.calculateFrameProgress(),isAudioEnabled(this.options)&&(this.sampleProgress=this.calculateSampleProgress()),this.emit("PROGRESS",{frameProgress:this.frameProgress,sampleProgress:this.sampleProgress})}updateFrameProgress(e){if(!e)throw error_createError({message:"Arguments are missing for updating the frame progress",options:this.options});if(!e.frame)throw error_createError({message:"The frame number is missing",options:this.options});this.confirmedFrameNumber=e.frame,this.frameProgress=this.calculateFrameProgress(),this.updateOverallProgress()}updateSampleProgress(e){if(!e)throw error_createError({message:"Arguments are missing for updating the audio sample progress",options:this.options});if(!e.sample)throw error_createError({message:"The audio sample number is missing",options:this.options});this.confirmedSampleNumber=e.sample,this.sampleProgress=this.calculateSampleProgress(),this.updateOverallProgress()}preview(e){if(!e)throw error_createError({message:"Preview arguments are missing.",options:this.options});const t=this.samplesCount>0;this.confirmedFrameNumber=this.confirmedSampleNumber=this.samplesCount=this.framesCount=0,this.sampleProgress=this.frameProgress=void 0,this.key=e.key,e.mp4&&this.replay.setMp4Source(`${e.mp4+constants.WHITELIST_KEY_LABEL}/${this.options.whitelistKey}/videomail.mp4`,!0),e.webm&&this.replay.setWebMSource(`${e.webm+constants.WHITELIST_KEY_LABEL}/${this.options.whitelistKey}/videomail.webm`,!0),this.hide();const i=this.getRecorderWidth(!0),r=this.getRecorderHeight(!0),o=e.duration??-1;this.emit("PREVIEW",{key:this.key,width:i?.value,height:r?.value,hasAudio:t,duration:o}),this.stopTime&&(this.waitingTime=Date.now()-this.stopTime),this.recordingStats??={},this.recordingStats.waitingTime=this.waitingTime}initSocket(e){if(!this.connected){this.connecting=!0,this.emit("CONNECTING");const t=`${this.options.socketUrl}?${encodeURIComponent(constants.WHITELIST_KEY_LABEL)}=${encodeURIComponent(this.options.whitelistKey)}`;this.options.logger.debug(`Recorder: initializing web socket to ${t}`);try{this.stream=websocket_stream(t,{perMessageDeflate:!1})}catch(e){this.connecting=this.connected=!1;const i=error_createError({message:"Failed to connect to server",explanation:`Unable to build websocket to ${t}. Please check your connection and try again. If the problem persists, contact us.`,options:this.options,exc:e});this.emit("ERROR",{err:i})}this.stream&&(this.stream.on("close",(e=>{this.options.logger.debug(`${PIPE_SYMBOL}Stream has closed`),this.connecting=this.connected=!1,e?this.emit("ERROR",{err:e}):this.userMediaLoaded&&this.initSocket()})),this.stream.on("connect",(()=>{this.options.logger.debug(`${PIPE_SYMBOL}Stream *connect* event emitted`);const t=this.stream?.socket.readyState===WebSocket.CLOSING;this.connected||t||this.unloaded||(this.connected=!0,this.connecting=this.unloaded=!1,this.emit("CONNECTED"),e?.())})),this.stream.on("data",(e=>{this.options.logger.debug(`${PIPE_SYMBOL}Stream *data* event emitted`);try{const t=JSON.parse(e.toString());this.executeCommand(t)}catch(t){this.options.logger.debug(`Failed to parse command: ${t}`);const i=error_createError({message:"Invalid server command",explanation:`Contact us asap. Bad command was ${e.toString()}. `,options:this.options,exc:t});this.emit("ERROR",{err:i})}})),this.stream.on("error",(e=>{this.options.logger.debug(`${PIPE_SYMBOL}Stream *error* event emitted: ${util_pretty(e)}`)})),this.stream.on("drain",(()=>{this.options.logger.debug(`${PIPE_SYMBOL}Stream *drain* event emitted (should not happen!)`)})),this.stream.on("preend",(()=>{this.options.logger.debug(`${PIPE_SYMBOL}Stream *preend* event emitted`)})),this.stream.on("end",(()=>{this.options.logger.debug(`${PIPE_SYMBOL}Stream *end* event emitted`)})),this.stream.on("drain",(()=>{this.options.logger.debug(`${PIPE_SYMBOL}Stream *drain* event emitted`)})),this.stream.on("pipe",(()=>{this.options.logger.debug(`${PIPE_SYMBOL}Stream *pipe* event emitted`)})),this.stream.on("unpipe",(()=>{this.options.logger.debug(`${PIPE_SYMBOL}Stream *unpipe* event emitted`)})),this.stream.on("resume",(()=>{this.options.logger.debug(`${PIPE_SYMBOL}Stream *resume* event emitted`)})),this.stream.on("uncork",(()=>{this.options.logger.debug(`${PIPE_SYMBOL}Stream *uncork* event emitted`)})),this.stream.on("readable",(()=>{this.options.logger.debug(`${PIPE_SYMBOL}Stream *preend* event emitted`)})),this.stream.on("prefinish",(()=>{this.options.logger.debug(`${PIPE_SYMBOL}Stream *preend* event emitted`)})),this.stream.on("finish",(()=>{this.options.logger.debug(`${PIPE_SYMBOL}Stream *preend* event emitted`)})))}}showUserMedia(){if(!this.connected)return!1;if(!this.isHidden())return!0;return!!this.isNotifying()||this.blocking}userMediaErrorCallback(e){this.userMediaLoading=!1,this.clearUserMediaTimeout();const t=this.userMedia?.getCharacteristics();this.options.logger.debug(`Recorder: userMediaErrorCallback(), name: ${e.name}, message: ${e.message} and Webcam characteristics: ${t?util_pretty(t):"none"}`);const i=util_Despot.getListeners("ERROR");if(i?.length){if(e.name!==error_VideomailError.MEDIA_DEVICE_NOT_SUPPORTED){const t=error_createError({err:e,options:this.options});this.emit("ERROR",{err:t})}else this.options.logger.debug(`Recorder: ignore user media error ${util_pretty(e)}`);this.retryTimeout=window.setTimeout(this.initSocket.bind(this),this.options.timeouts.userMedia)}else{if(!this.unloaded)throw this.options.logger.debug(`Recorder: no error listeners attached but throwing error ${util_pretty(e)}`),error_createError({err:e,message:"Unable to process this error since there are no error listeners anymore.",options:this.options});this.options.logger.debug(`Recorder: already unloaded. Not going to throw error ${util_pretty(e)}`)}}getUserMediaCallback(e,t){if(!this.userMedia)throw new Error("No user media is defined");if(this.options.logger.debug(`Recorder: getUserMediaCallback(${t?util_pretty(t):""})`),this.showUserMedia())try{this.clearUserMediaTimeout(),this.userMedia.init(e,(()=>{this.onUserMediaReady(t)}),this.onAudioSample.bind(this),(e=>{this.emit("ERROR",{err:e})}),t?.switchingFacingMode)}catch(e){this.emit("ERROR",{exc:e})}}loadGenuineUserMedia(e){this.options.logger.debug(`Recorder: loadGenuineUserMedia(${e?util_pretty(e):""})`),this.emit("ASKING_WEBCAM_PERMISSION");const t={video:{frameRate:{ideal:this.options.video.fps}},audio:isAudioEnabled(this.options)};if(e?.switchingFacingMode&&t.video&&!0!==t.video&&(t.video.facingMode=e.switchingFacingMode),this.options.video.width&&t.video&&!0!==t.video){const e=this.options.video.width;e&&(t.video.width={ideal:e})}else if(t.video&&!0!==t.video){const e=this.limitWidth();e?.value&&(t.video.width={ideal:e.value})}if(this.options.video.height&&t.video&&!0!==t.video){const e=this.options.video.height;e&&(t.video.height={ideal:e})}this.options.logger.debug(`Recorder: our webcam constraints are: ${util_pretty(t)}`),this.options.logger.debug(`Recorder: available webcam constraints are: ${util_pretty(navigator.mediaDevices.getSupportedConstraints())}`);navigator.mediaDevices.getUserMedia(t).then((t=>{this.getUserMediaCallback(t,e)})).catch((e=>{this.userMediaErrorCallback(e)}))}loadUserMedia(e){if(this.userMediaLoaded)return this.options.logger.debug("Recorder: skipping loadUserMedia() because it is already loaded"),void this.onUserMediaReady(e);if(this.userMediaLoading)this.options.logger.debug("Recorder: skipping loadUserMedia() because it is already asking for permission");else{this.options.logger.debug(`Recorder: loadUserMedia(${e?util_pretty(e):""})`),this.emit("LOADING_USER_MEDIA");try{if(!navigator.mediaDevices)throw new Error("No media devices are available.");this.userMediaTimeout=window.setTimeout((()=>{if(!this.isReady()){const e=util_getBrowser(this.options).getNoAccessIssue();this.emit("ERROR",{err:e})}}),this.options.timeouts.userMedia),this.userMediaLoading=!0,this.loadGenuineUserMedia(e)}catch(e){this.clearUserMediaTimeout(),this.options.logger.debug("Recorder: failed to load genuine user media"),this.userMediaLoading=!1;const t=util_Despot.getListeners("ERROR");if(!t?.length)throw this.options.logger.debug("Recorder: no error listeners attached but throwing exception further"),e;this.emit("ERROR",{exc:e})}}}executeCommand(e){if(!this.unloaded)try{switch(e.args?this.options.logger.debug(`Server commanded: ${e.command} with ${util_pretty(e.args)}`):this.options.logger.debug(`Server commanded: ${e.command}`),e.command){case"ready":this.emit("SERVER_READY"),this.userMediaTimeout||(this.options.loadUserMediaOnRecord?this.show():this.loadUserMedia());break;case"preview":this.preview(e.args);break;case"error":{let t="(No explanation given)";e.args?.err?.message&&(t=e.args.err.message);const i=error_createError({message:"Websocket error from Videomail server",explanation:t,err:deserializeError(e.args?.err),options:this.options});this.emit("ERROR",{err:i});break}case"confirmFrame":this.updateFrameProgress(e.args);break;case"confirmSample":this.updateSampleProgress(e.args);break;case"beginAudioEncoding":this.emit("BEGIN_AUDIO_ENCODING");break;case"beginVideoEncoding":this.emit("BEGIN_VIDEO_ENCODING");break;default:{const t=error_createError({message:`Unknown server command: ${e.command}`,options:this.options});this.emit("ERROR",{err:t});break}}}catch(e){this.emit("ERROR",{exc:e})}}isNotifying(){return this.visuals.isNotifying()}isHidden(){return!this.recorderElement||html_isHidden(this.recorderElement)}writeCommand(e,t,i){if(this.connected){if(this.stream){t?this.options.logger.debug(`$ ${e} with ${util_pretty(t)}`):this.options.logger.debug(`$ ${e}`);const r={command:e,args:t};this.writeStream(Buffer.from(JSON.stringify(r))),i&&setTimeout((function(){i()}),0)}}else this.options.logger.debug(`Reconnecting for the command ${e} …`),this.initSocket((()=>{this.writeCommand(e,t),i?.()}))}cancelAnimationFrame(){this.loop?.dispose()}getIntervalSum(){if(this.loop)return this.loop.getElapsedTime()}getAvgInterval(){const e=this.getIntervalSum();if(e)return e/this.framesCount}getAvgFps(){const e=this.getIntervalSum();if(e)return this.framesCount/e*1e3}getRecordingStats(){return this.recordingStats}getAudioSampleRate(){return this.userMedia?.getAudioSampleRate()}stop(e){if(!this.userMedia)throw new Error("No user media defined, unable to stop");this.options.logger.debug(`Recorder: stop(${e?util_pretty(e):""})`);const t=e?.limitReached;this.emit("STOPPING",{limitReached:t}),this.loop?.complete(),setTimeout((()=>{this.stopTime=Date.now();const e=this.replay.getVideoType();if(!e)throw new Error("Unable to video record when no video type is defined.");this.recordingStats={avgFps:this.getAvgFps(),wantedFps:this.options.video.fps,avgInterval:this.getAvgInterval(),wantedInterval:1e3/this.options.video.fps,intervalSum:this.getIntervalSum(),framesCount:this.framesCount,videoType:e},isAudioEnabled(this.options)&&this.userMedia&&(this.recordingStats.samplesCount=this.samplesCount,this.recordingStats.sampleRate=this.userMedia.getAudioSampleRate()),this.writeCommand("stop",this.recordingStats,(()=>{this.emit("STOPPED",{recordingStats:this.recordingStats})})),this.reset()}),60)}back(e){this.emit("GOING_BACK"),this.unloaded=!1,this.show(),this.writeCommand("back",void 0,e)}reInitializeAudio(){this.options.logger.debug("Recorder: reInitializeAudio()"),this.clearUserMediaTimeout(),this.userMedia?.stop(),this.userMediaLoaded=this.key=this.canvas=this.ctx=void 0,this.loadUserMedia()}unload(e){if(this.unloaded||!this.built)return;const t=e?.e;let i;t&&(i=t.type);const r=i?`, cause: ${i}`:"";this.options.logger.debug(`Recorder: unload()${r}`),this.reset(),this.clearUserMediaTimeout(),this.userMedia&&this.userMedia.unloadRemainingEventListeners(),this.submitting||this.stream&&(this.options.logger.debug("Recorder: destroying stream ..."),this.stream.destroy(),this.stream=void 0),this.unloaded=!0,this.built=this.connecting=this.connected=!1}reset(){this.unloaded||(this.options.logger.debug("Recorder: reset()"),this.emit("RESETTING"),this.cancelAnimationFrame(),this.userMedia?.stop(),this.replay.reset(),this.userMediaLoaded=this.key=this.canvas=this.ctx=this.recordingBuffer=void 0)}clearUserMediaTimeout(){this.userMediaTimeout&&(this.options.logger.debug("Recorder: clearUserMediaTimeout()"),window.clearTimeout(this.userMediaTimeout),this.userMediaTimeout=void 0)}validate(){return this.connected&&void 0===this.canvas}isReady(){return this.userMedia?.isReady()}pause(e){e?this.options.logger.debug(`pause() at frame ${this.framesCount} with ${util_pretty(e)}`):this.options.logger.debug(`pause() at frame ${this.framesCount}`),this.userMedia?.pause(),this.loop.stop(),this.emit("PAUSED"),this.sendPings()}resume(){this.options.logger.debug(`Recorder: resume() with frame ${this.framesCount}`),this.stopPings(),this.emit("RESUMING"),this.userMedia?.resume(),this.loop.start()}onFlushed(e){1===e.frameNumber&&this.emit("FIRST_FRAME_SENT")}draw(e,t){if(!this.userMedia)throw new Error("No user media defined, unable to draw on canvas");try{if(!this.isPaused()&&this.stream&&this.ctx){0===this.framesCount&&this.emit("SENDING_FIRST_FRAME"),this.framesCount++;const e=this.userMedia.getRawVisuals();if(!this.canvas||!e)throw new Error("Unable to draw an image without a defined canvas");this.ctx.drawImage(e,0,0,this.canvas.width,this.canvas.height),this.recordingBuffer=this.frame?.toBuffer();const i=this.recordingBuffer?.length;if(!i)throw error_createError({message:"Failed to extract webcam data.",options:this.options});if(this.recordingBuffer){const e=Buffer.from(JSON.stringify({frameNumber:this.framesCount})),i=Buffer.concat([this.recordingBuffer,e]);this.writeStream(i,{frameNumber:this.framesCount,onFlushedCallback:this.onFlushed.bind(this)}),this.visuals.checkTimer(t)}}}catch(e){this.emit("ERROR",{exc:e})}}createLoop(){const e=animitter({fps:this.options.video.fps},this.draw.bind(this));return this.originalAnimationFrameObject=e.getRequestAnimationFrameObject(),e}record(){if(!this.unloaded){if(!this.connected)return this.options.logger.debug("Recorder: reconnecting before recording ..."),void this.initSocket((()=>{this.once("USER_MEDIA_READY",this.record.bind(this))}));if(this.userMediaLoaded){try{if(!this.userMedia)throw new Error("No user media defined, unable to create canvas");this.canvas=this.userMedia.createCanvas()}catch(e){const t=error_createError({exc:e,options:this.options});return void this.emit("ERROR",{err:t})}if(this.ctx=this.canvas.getContext("2d"),this.canvas.width)if(this.canvas.height)this.frame=new canvas_to_buffer(this.canvas,this.options.image.types,this.options.image.quality),this.options.logger.debug("Recorder: record()"),this.userMedia.record(),this.emit("RECORDING",{framesCount:this.framesCount}),this.loop.on("update",((e,t)=>{let i;i=0!==t?Math.round(this.framesCount/t*1e3):void 0,this.options.logger.debug(`Recorder updates avgFps = ${i} at frame ${this.framesCount}`)})),this.loop.start();else{const e=error_createError({message:"Canvas has an invalid height.",options:this.options});this.emit("ERROR",{err:e})}else{const e=error_createError({message:"Canvas has an invalid width.",options:this.options});this.emit("ERROR",{err:e})}}else if(this.options.loadUserMediaOnRecord)this.loadUserMedia({recordWhenReady:!0});else{const e=error_createError({message:"Load and enable your camera first",options:this.options});this.emit("ERROR",{err:e})}}}setAnimationFrameObject(e){if(this.loop){const t=this.isRecording();this.loop.stop(),this.loop.setRequestAnimationFrameObject(e),t&&this.loop.start()}}restoreAnimationFrameObject(){this.options.logger.debug("Recorder: restoreAnimationFrameObject()"),this.setAnimationFrameObject(this.originalAnimationFrameObject)}loopWithTimeouts(){this.options.logger.debug("Recorder: loopWithTimeouts()");const e=1e3/this.options.video.fps;let t,i=0;this.setAnimationFrameObject({requestAnimationFrame:r=>setTimeout((()=>{t=Date.now(),r(),i=Date.now()-t}),e-i),cancelAnimationFrame:e=>{window.clearTimeout(e)}})}correctDimensions(){if(!this.recorderElement)return;const e=dimensions_useFullWidth(this.options.video.mobileBreakPoint);if(this.options.video.stretch||e)this.recorderElement.style.width="100%",this.recorderElement.style.removeProperty("height");else{if(this.options.video.width){const e=this.getRecorderWidth(!0);e?.value?this.recorderElement.width=e.value:this.recorderElement.style.removeProperty("width")}if(this.options.video.height){const e=this.getRecorderHeight(!0);e?.value?this.recorderElement.height=e.value:this.recorderElement.style.removeProperty("height")}}}switchFacingMode(){util_getBrowser(this.options).isMobile()&&("user"===this.facingMode?this.facingMode="environment":"environment"===this.facingMode?this.facingMode="user":this.options.logger.warn(`Recorder: unsupported facing mode ${util_pretty(this.facingMode)}`),this.loadGenuineUserMedia({switchingFacingMode:this.facingMode}))}initEvents(){this.options.logger.debug("Recorder: initEvents()"),this.on("SUBMITTING",(()=>{this.submitting=!0})),this.on("SUBMITTED",(()=>{this.submitting=!1})),this.on("BLOCKING",(()=>{this.blocking=!0,this.clearUserMediaTimeout()})),this.on("PREVIEW",(()=>{this.hide()})),this.on("HIDE",(()=>{this.hide()})),this.on("LOADED_META_DATA",(()=>{this.correctDimensions()})),this.on("DISABLING_AUDIO",(()=>{this.reInitializeAudio()})),this.on("ENABLING_AUDIO",(()=>{this.reInitializeAudio()})),this.on("INVISIBLE",(()=>{this.loopWithTimeouts()})),this.on("VISIBLE",(()=>{this.restoreAnimationFrameObject()})),this.on("SWITCH_FACING_MODE",(()=>{this.switchFacingMode()})),this.on("WINDOW_RESIZE",(()=>{this.correctDimensions()}))}buildElement(){this.recorderElement=document.createElement("video"),this.recorderElement.classList.add(this.options.selectors.userMediaClass),this.visuals.appendChild(this.recorderElement)}build(){if(this.recorderElement=this.visuals.getElement()?.querySelector(`video.${this.options.selectors.userMediaClass}`),this.recorderElement||this.buildElement(),!this.recorderElement)throw new Error(`There is still no video element with class ${this.options.selectors.userMediaClass}`);this.correctDimensions(),this.recorderElement.muted=!0,this.recorderElement.setAttribute("playsinline","true"),this.recorderElement.setAttribute("webkit-playsinline","webkit-playsinline"),this.recorderElement.style.transform="rotateY(180deg)",this.recorderElement.style["-webkit-transform"]="rotateY(180deg)",this.recorderElement.style["-moz-transform"]="rotateY(180deg)",this.userMedia??=new visuals_userMedia(this,this.options),this.show(),this.built?this.options.loadUserMediaOnRecord&&this.loadUserMedia():(this.initEvents(),this.connected?this.options.loadUserMediaOnRecord||this.loadUserMedia():this.initSocket()),this.built=!0}isPaused(){return this.userMedia?.isPaused()&&!this.loop.isRunning()}isRecording(){return Boolean(this.loop?.isRunning()&&!this.isPaused()&&!this.isNotifying()&&this.stream&&!this.stream.destroyed)}hide(){this.isHidden()||(this.recorderElement&&html_hideElement(this.recorderElement),this.clearUserMediaTimeout(),this.clearRetryTimeout())}isUnloaded(){return this.unloaded}getRecorderWidth(e){if(this.userMedia?.hasVideoWidth())return this.userMedia.getRawWidth(e);if(e&&this.options.video.width)return this.limitWidth(this.options.video.width);return{unit:"px",value:this.options.video.width}}getRecorderHeight(e,t){let i;if(this.recorderElement&&t){i={unit:"px",value:this.recorderElement.getBoundingClientRect().height}}else if(this.userMedia){let t=this.userMedia.getRawHeight(e);if(void 0!==t&&this.options.video.width){const e=this.getRatio();if(void 0!==e){const i=this.options.video.width*e;t=Math.min(i,t)}}i={unit:"px",value:t}}else if(e&&this.options.video.height)i=this.calculateHeight(e);else if(this.options.video.height){i={unit:"px",value:this.options.video.height}}return i}getRatio(){let e;if(this.userMedia){const t=this.userMedia.getVideoWidth(),i=this.userMedia.getVideoHeight();!t||t<1?e=this.visuals.getRatio():i&&(e=i/t)}else e=dimensions_getRatio(this.options);return e}calculateWidth(e){let t;this.userMedia?t=this.userMedia.getVideoHeight():this.recorderElement&&(t=this.recorderElement.videoHeight||this.recorderElement.height);const i=this.getRatio();return dimensions_calculateWidth(e,this.options,t,i)}calculateHeight(e){let t;if(this.userMedia){t={value:this.userMedia.getVideoHeight(),unit:"px"}}else if(this.recorderElement){t={value:this.recorderElement.videoHeight||this.recorderElement.height,unit:"px"}}else t=dimensions_calculateHeight(e,void 0,this.options,this.getRatio(),this.recorderElement);return t}getRawVisualUserMedia(){return this.recorderElement}isConnected(){return this.connected}isConnecting(){return this.connecting}limitWidth(e){return this.visuals.limitWidth(e)}limitHeight(e){return this.visuals.limitHeight(e)}isUserMediaLoaded(){return this.userMediaLoaded}constructor(e,t,i){super("Recorder",i),recorder_define_property(this,"visuals",void 0),recorder_define_property(this,"replay",void 0),recorder_define_property(this,"loop",void 0),recorder_define_property(this,"originalAnimationFrameObject",void 0),recorder_define_property(this,"samplesCount",0),recorder_define_property(this,"framesCount",0),recorder_define_property(this,"recordingStats",void 0),recorder_define_property(this,"confirmedFrameNumber",0),recorder_define_property(this,"confirmedSampleNumber",0),recorder_define_property(this,"recorderElement",void 0),recorder_define_property(this,"userMedia",void 0),recorder_define_property(this,"userMediaTimeout",void 0),recorder_define_property(this,"retryTimeout",void 0),recorder_define_property(this,"frameProgress",void 0),recorder_define_property(this,"sampleProgress",void 0),recorder_define_property(this,"canvas",void 0),recorder_define_property(this,"ctx",void 0),recorder_define_property(this,"userMediaLoaded",void 0),recorder_define_property(this,"userMediaLoading",!1),recorder_define_property(this,"submitting",!1),recorder_define_property(this,"unloaded",void 0),recorder_define_property(this,"stopTime",void 0),recorder_define_property(this,"stream",void 0),recorder_define_property(this,"connecting",!1),recorder_define_property(this,"connected",!1),recorder_define_property(this,"blocking",!1),recorder_define_property(this,"built",!1),recorder_define_property(this,"key",void 0),recorder_define_property(this,"waitingTime",void 0),recorder_define_property(this,"pingInterval",void 0),recorder_define_property(this,"frame",void 0),recorder_define_property(this,"recordingBuffer",void 0),recorder_define_property(this,"facingMode",void 0),this.visuals=e,this.replay=t,this.facingMode=i.video.facingMode}}const visuals_recorder=Recorder;function replay_define_property(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class Replay extends util_Despot{buildElement(e){const t=`video.${this.options.selectors.replayClass}`;this.replayElement=e.querySelector(t),this.replayElement||(this.replayElement=document.createElement("video"),this.replayElement.classList.add(this.options.selectors.replayClass),e.appendChild(this.replayElement))}isStandalone(){return"HTMLDivElement"===this.visuals.constructor.name}copyAttributes(e){let t;Object.keys(e).forEach((i=>{if(t=this.replayElement?.parentNode?.querySelector(`.${i}`),t){(!t.innerHTML||t.innerHTML.length<1)&&(t.innerHTML=e[i])}}))}correctDimensions(e,t,i){if(!this.replayElement)throw new Error("There is no replay element to correct dimensions for.");let r,o,n;if(this.videomail&&(o=this.videomail.width,r=this.videomail.height,o&&(n=r/o)),o||(o=dimensions_calculateWidth(e,this.options,i,n)),!r){let i=this.visuals.getElement();i||(i=document.body),r=dimensions_calculateHeight(e,t,this.options,n,i)}this.replayElement.style.width=o>0?`${o}px`:"auto",this.replayElement.style.height=r>0?`${r}px`:"auto"}setVideomail(e,t=!1){this.videomail=e,this.videomail.mp4&&this.setMp4Source(this.videomail.mp4),this.videomail.webm&&this.setWebMSource(this.videomail.webm),this.videomail.vtt&&this.setTrackSource(this.videomail.vtt),this.videomail.poster&&this.replayElement?.setAttribute("poster",this.videomail.poster),this.copyAttributes(this.videomail);const i=this.videomail.recordingStats?.sampleRate,r=this.videomail.width,o=this.videomail.height,n=void 0!==i&&i>0;this.show(r,o,n,t)}show(e,t,i,r=!1){if(!this.replayElement)return;if(this.isShown())return;this.options.logger.debug(`Replay: show(playerOnly=${r})`);const o=Boolean(this.videomail?.webm)||Boolean(this.videomail?.mp4)||Boolean(this.videomail?.poster);o&&this.correctDimensions(!0,e??this.replayElement.videoWidth,t??this.replayElement.videoHeight),r?o&&html_showElement(this.replayElement):html_showElement(this.replayElement),r?html_showElement(this.replayElement.parentElement):this.visuals.show(),i?this.replayElement.setAttribute("volume","1"):isAudioEnabled(this.options)||this.replayElement.setAttribute("muted","true"),this.replayElement.load(),this.videomail?this.replayElement.addEventListener("canplaythrough",(()=>{this.emit("REPLAY_SHOWN")}),{once:!0}):this.replayElement.addEventListener("canplaythrough",(()=>{this.emit("PREVIEW_SHOWN")}),{once:!0})}build(e){if(this.options.logger.debug(`Replay: build (replayParentElement="${util_pretty(e)}")`),this.replayElement=this.visuals.getElement()?.querySelector(`video.${this.options.selectors.replayClass}`),this.replayElement||this.buildElement(e),!this.replayElement)throw new Error("There is no replayElement to build on");this.hide(),this.options.video.autoPlay&&this.replayElement.setAttribute("autoplay",this.options.video.autoPlay.toString()),this.replayElement.setAttribute("autostart","true"),this.replayElement.setAttribute("autobuffer","true"),this.replayElement.setAttribute("playsinline","true"),this.replayElement.setAttribute("webkit-playsinline","webkit-playsinline"),this.replayElement.setAttribute("controls","controls"),this.replayElement.setAttribute("preload","auto"),this.built||(this.isStandalone()||this.on("PREVIEW",(e=>{this.show(e?.width,e?.height,e?.hasAudio)})),this.replayElement.addEventListener("touchstart",(e=>{e.preventDefault(),this.replayElement?.paused?this.replayElement.play().catch((e=>{throw error_createError({message:"Failed to play replay video while paused upon touchstart event.",exc:e,options:this.options})})):this.replayElement?.pause()}),{passive:!0}),this.replayElement.addEventListener("click",(e=>{e.preventDefault(),this.replayElement?.paused?this.replayElement.play().catch((e=>{throw error_createError({message:"Failed to play replay video while paused upon click event.",exc:e,options:this.options})})):this.replayElement?.pause()}))),this.built=!0,this.options.logger.debug("Replay: built.")}unload(e){this.options.logger.debug("Replay: unload()"),util_Despot.removeAllListeners(),e?.startingOver?this.hide():(this.replayElement?.remove(),this.replayElement=void 0),this.videomail=void 0,this.built=!1}getVideoSource(e){if(!this.replayElement)return;const t=this.replayElement.getElementsByTagName("source"),i=t.length,r=`video/${e}`;let o;if(i){let e;for(e=0;e<i&&!o;e++)t[e]?.getAttribute("type")===r&&(o=t[e])}return o}setTrackSource(e){if(!this.replayElement)return;const t=this.replayElement.getElementsByTagName("track")[0];if(t)e?t.setAttribute("src",e):t.remove();else{const t=document.createElement("track");t.setAttribute("src",e),t.src=e,t.kind="captions",t.default=!0,this.replayElement.appendChild(t),this.replayElement.setAttribute("crossorigin","anonymous")}}setVideoSource(e,t,i){if(!this.replayElement)throw new Error("There is no replay element for appending a video source");let r=this.getVideoSource(e),o=t;if(o&&i&&(o+=`?${Date.now()}`),r)t?r.setAttribute("src",t):r.remove();else if(t){const{fps:t}=this.options.video,i=1/t*2;r=document.createElement("source"),r.src=`${o}#t=${i}`,r.type=`video/${e}`,this.replayElement.appendChild(r)}}setMp4Source(e,t){this.setVideoSource(VideoType.MP4,e,t)}setWebMSource(e,t){this.setVideoSource(VideoType.WebM,e,t)}getVideoType(){if(this.replayElement)return util_getBrowser(this.options).getVideoType(this.replayElement)}pause(e){window.setTimeout((()=>{try{this.replayElement&&this.replayElement.pause()}catch(e){this.options.logger.warn(e)}e()}),15)}reset(e){this.pause((()=>{this.replayElement&&(this.setMp4Source(void 0),this.setWebMSource(void 0)),this.videomail=void 0,e?.()}))}hide(){this.isStandalone()?this.visuals.hide():this.replayElement&&(html_hideElement(this.replayElement),html_hideElement(this.replayElement.parentElement))}isShown(){return!!this.replayElement&&(!html_isHidden(this.replayElement)&&!this.visuals.isHidden())}getVisuals(){return this.visuals}getElement(){return this.replayElement}constructor(e,t){super("Replay",t),replay_define_property(this,"visuals",void 0),replay_define_property(this,"built",!1),replay_define_property(this,"replayElement",void 0),replay_define_property(this,"videomail",void 0),this.visuals=e}}const visuals_replay=Replay;function visuals_define_property(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class Visuals extends util_Despot{buildNoScriptTag(){let e=this.container.querySelector("noscript");e&&(e=document.createElement("noscript"),e.innerHTML="Please enable Javascript",this.visualsElement?.appendChild(e))}buildChildren(e=!1,t){if(!t)throw new Error("Unable to build children without a visuals element");this.options.logger.debug(`Visuals: buildChildren (playerOnly = ${e}, visualsElement="${util_pretty(t)}"})`),this.buildNoScriptTag(),e||(this.notifier.build(),this.recorderInsides.build()),this.replay.build(t)}initEvents(e=!1){e||(this.options.logger.debug(`Visuals: initEvents (playerOnly = ${e})`),this.on("USER_MEDIA_READY",(()=>{this.built=!0,this.endWaiting(),this.container.enableForm(!1)})),this.on("PREVIEW",(()=>{this.endWaiting()})),this.on("BLOCKING",(()=>{this.options.adjustFormOnBrowserError&&this.container.disableForm(!0)})),this.on("PREVIEW_SHOWN",(()=>{this.container.validate(void 0,!0)})),this.on("LOADED_META_DATA",(()=>{this.correctDimensions()})),this.on("ERROR",(()=>{util_getBrowser(this.options).isMobile()&&this.removeDimensions()})),this.on("WINDOW_RESIZE",(()=>{this.correctDimensions()})))}correctDimensions(){if(this.options.video.stretch)this.removeDimensions();else if(this.visualsElement){let e,t=dimensions_useFullWidth(this.options.video.mobileBreakPoint);if(t||(t=this.getRecorderWidth(!0),e=this.getRecorderHeight(!0)),t?.value?this.visualsElement.style.width=`${t.value}${t.unit}`:this.visualsElement.style.removeProperty("width"),e?.value){const t=`${e.value}${e.unit}`;this.visualsElement.style.height=t}else this.visualsElement.style.removeProperty("height")}}removeDimensions(){this.visualsElement&&(this.visualsElement.style.width="auto",this.visualsElement.style.height="auto")}getRatio(){return this.visualsElement?.clientWidth?this.visualsElement.clientHeight/this.visualsElement.clientWidth:0}isRecordable(){return!this.isNotifying()&&!this.replay.isShown()&&!this.isCountingDown()}isCountingDown(){return this.recorderInsides.isCountingDown()}build(e=!1,t){const i=t?`, parentElement="${util_pretty(t)}"`:"";if(this.options.logger.debug(`Visuals: build (playerOnly = ${e}${i})`),this.visualsElement=t?t.querySelector(`.${this.options.selectors.visualsClass}`):this.container.querySelector(`.${this.options.selectors.visualsClass}`),!this.visualsElement)if(e&&t)this.visualsElement=t;else{this.visualsElement=document.createElement("div"),this.visualsElement.classList.add(this.options.selectors.visualsClass);const e=this.container.querySelector(`.${this.options.selectors.buttonsClass}`);e&&!this.container.isOutsideElementOf(e)?this.container.insertBefore(this.visualsElement,e):this.container.appendChild(this.visualsElement)}this.visualsElement.classList.add("visuals"),this.correctDimensions(),this.built||this.initEvents(e),this.buildChildren(e,this.visualsElement),this.built=!0}appendChild(e){this.visualsElement?.appendChild(e)}removeChild(e){e.remove()}reset(){this.endWaiting(),this.recorder.reset()}beginWaiting(){this.container.beginWaiting()}endWaiting(){this.container.endWaiting()}stop(e){this.recorder.stop(e),this.recorderInsides.hidePause()}back(e=!1,t){this.options.logger.debug(`Visuals: back(keepHidden = ${e})`),this.replay.hide(),this.notifier.hide(),e?(this.recorder.hide(),t?.()):this.recorder.back(t)}recordAgain(){this.back(!1,(()=>{this.options.loadUserMediaOnRecord?this.once("SERVER_READY",(()=>{this.recorder.record()})):this.once("USER_MEDIA_READY",(()=>{this.recorder.record()}))}))}unload(e){if(!this.built)return;const t=e?.e;this.options.logger.debug(`Visuals: unload(${t?util_pretty(t):""})`),this.recorder.unload(e),this.recorderInsides.unload(),this.replay.unload(e),t instanceof Error||this.hide(),this.built=!1}isNotifying(){return this.notifier.isVisible()}pause(e){this.recorder.pause(e),this.recorderInsides.showPause()}resume(){this.recorderInsides.isCountingDown()?this.recorderInsides.resumeCountdown():this.recorder.resume(),this.recorderInsides.hidePause()}pauseOrResume(){this.isRecordable()&&(this.isRecording()?this.pause():this.recorder.isPaused()?this.resume():this.recorder.isReady()&&this.recorder.record())}recordOrStop(){this.isRecordable()&&(this.isRecording()?this.stop():this.recorder.isReady()&&this.recorder.record())}getRecorder(){return this.recorder}validate(){return!!this.isReplayShown()||this.recorder.validate()}getRecordingStats(){return this.recorder.getRecordingStats()}getAudioSampleRate(){return this.recorder.getAudioSampleRate()}isPaused(){return this.recorder.isPaused()}error(e){this.notifier.error(e)}hide(){this.visualsElement&&(html_hideElement(this.visualsElement),this.emit("HIDE"))}isHidden(){return!this.built||html_isHidden(this.visualsElement)}showVisuals(){html_showElement(this.visualsElement)}show(e){e?.playerOnly||(this.isReplayShown()?e?.goBack&&this.recorder.show():this.recorder.build()),this.showVisuals()}showReplayOnly(){this.show({playerOnly:!0}),this.recorder.hide(),this.notifier.hide()}isRecorderUnloaded(){return this.recorder.isUnloaded()}isConnecting(){return this.recorder.isConnecting()}getRecorderWidth(e){return this.recorder.getRecorderWidth(e)}getRecorderHeight(e,t=!1){return this.recorder.getRecorderHeight(e,t)}limitWidth(e){return this.container.limitWidth(e)}limitHeight(e){return this.container.limitHeight(e)}getReplay(){return this.replay}getBoundingClientRect(){return this.visualsElement?.getBoundingClientRect()}checkTimer(e){this.recorderInsides.checkTimer(e)}isNotifierBuilt(){return this.notifier.isBuilt()}isReplayShown(){return this.replay.isShown()}hideReplay(){this.replay.hide()}hideRecorder(){this.recorder.hide()}isRecording(){return this.recorder.isRecording()}isUserMediaLoaded(){return this.recorder.isUserMediaLoaded()}isConnected(){return this.recorder.isConnected()}record(){this.options.video.countdown?(this.emit("COUNTDOWN"),this.recorderInsides.startCountdown(this.recorder.record.bind(this.recorder))):this.recorder.record()}setLimitSeconds(e){this.options.video.limitSeconds=e,this.recorderInsides.setLimitSeconds(e)}getElement(){return this.visualsElement}constructor(e,t){super("Visuals",t),visuals_define_property(this,"container",void 0),visuals_define_property(this,"replay",void 0),visuals_define_property(this,"recorder",void 0),visuals_define_property(this,"recorderInsides",void 0),visuals_define_property(this,"notifier",void 0),visuals_define_property(this,"visualsElement",void 0),visuals_define_property(this,"built",!1),this.container=e,this.replay=new visuals_replay(this,t),this.recorder=new visuals_recorder(this,this.replay,t),this.recorderInsides=new recorderInsides(this,t),this.notifier=new notifier(this,t)}}const wrappers_visuals=Visuals;function container_define_property(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class Container extends util_Despot{buildChildren(e=!1,t){const i=t?`, parentElement="${util_pretty(t)}"`:"";this.options.logger.debug(`Container: buildChildren (playerOnly = ${e}${i})`),this.containerElement&&this.containerElement.classList.add(this.options.selectors.containerClass),e||this.buttons.build(),this.visuals.build(e,t)}build(e){this.options.logger.debug(`Container: build (${e?util_pretty(e):""})`);try{const t=this.options.selectors.containerId;this.containerElement=t?document.getElementById(t):document.createElement("div"),this.containerElement?.classList.add(this.options.selectors.containerClass);let i,r=null;e?.replayParentElement?r=e.replayParentElement:e?.replayParentElementId&&(r=document.getElementById(e.replayParentElementId)),!this.containerElement&&r&&r.classList.contains(this.options.selectors.containerClass)&&(this.containerElement=r),this.built||this.initEvents(e?.playerOnly),e?.playerOnly||this.correctDimensions(),this.buildForm(),i=e?.playerOnly?r??this.containerElement:this.containerElement,this.buildChildren(e?.playerOnly,i),this.hasError?this.options.logger.debug("Container: building failed due to an error."):(this.options.logger.debug("Container: built."),this.built=!0,this.emit("BUILT"))}catch(e){this.emit("ERROR",{exc:e})}return this.containerElement}findParentFormElement(){if(this.containerElement)return this.containerElement.closest("form")}getFormElement(){let e;if("FORM"===this.containerElement?.tagName)e=this.containerElement;else if(this.options.selectors.formId){if(e=document.querySelector(`#${this.options.selectors.formId}`),e&&"FORM"!==e.tagName)throw new Error(`HTML element with ID ${this.options.selectors.formId} is not a form.`)}else e=this.findParentFormElement();return e}buildForm(){if(this.form)return;const e=this.getFormElement();if(e){this.form=new wrappers_form(this,e,this.options);const t=this.form.findSubmitButton();t&&this.buttons.setSubmitButton(t),this.form.build()}}processError(e){this.hasError=!0,e.err?.stack?this.options.logger.error(e.err.stack):e.err?.message?this.options.logger.error(e.err.message):e.exc&&(e.exc instanceof Error?e.exc.stack?this.options.logger.error(e.exc.stack):e.exc.message&&this.options.logger.error(e.exc.message):this.options.logger.error(e.exc)),this.options.displayErrors&&e.err?this.visuals.error(e.err):this.visuals.reset()}initEvents(e=!1){this.options.logger.debug(`Container: initEvents (playerOnly = ${e})`),this.options.recalculateDimensionsOnWindowResize&&window.addEventListener("resize",(()=>{this.built&&this.emit("WINDOW_RESIZE","container")})),this.options.enableAutoUnload&&window.addEventListener("beforeunload",(e=>{this.unload({e:e})}),{once:!0}),e||this.visibility.onChange((e=>{this.built&&(e?(isAutoPauseEnabled(this.options)&&this.isCountingDown()&&this.resume(),this.emit("VISIBLE")):(isAutoPauseEnabled(this.options)&&(this.isCountingDown()||this.isRecording())&&this.pause(),this.emit("INVISIBLE")))})),this.options.enableSpace&&(e||window.addEventListener("keydown",(e=>{const t=e.target,i=t.tagName;if(!(t.isContentEditable||"true"===t.contentEditable)&&i&&"INPUT"!==i.toUpperCase()&&"TEXTAREA"!==i.toUpperCase()){"Space"===e.code&&(e.preventDefault(),this.options.enablePause?this.visuals.pauseOrResume():this.visuals.recordOrStop())}}))),this.on("ERROR",(e=>{this.processError(e),this.endWaiting();util_getBrowser(this.options).isMobile()&&this.removeDimensions()})),this.on("WINDOW_RESIZE",(()=>{this.correctDimensions()})),e||this.on("LOADED_META_DATA",(()=>{this.correctDimensions()}))}correctDimensions(){if(this.options.video.stretch)this.removeDimensions();else if(this.containerElement){let e=dimensions_useFullWidth(this.options.video.mobileBreakPoint);e||(e=this.visuals.getRecorderWidth(!0)),e?.value?this.containerElement.style.width=`${e.value}${e.unit}`:this.containerElement.style.removeProperty("width")}}removeDimensions(){this.containerElement&&(this.containerElement.style.width="auto")}unloadChildren(e){this.visuals.unload(e),this.buttons.unload(),this.form&&(this.form.unload(),this.form=void 0),this.endWaiting()}hideMySelf(){html_hideElement(this.containerElement)}async submitVideomail(e,t){const i=this.form?.transformFormData(e);if(!i)throw new Error("No videomail form data defined");if(t===FormMethod.POST){i.recordingStats=this.visuals.getRecordingStats();const e=this.visuals.getRecorderWidth(!0),t=this.visuals.getRecorderHeight(!0);return i.width=e?.value,i.height=t?.value,await this.resource.post(i)}if(t===FormMethod.PUT)return await this.resource.put(i);throw error_createError({message:`Unsupported form method ${t}, unable to submit videomail.`,options:this.options})}limitWidth(e){if(this.containerElement)return dimensions_limitWidth(this.containerElement,this.options,e)}limitHeight(e){return dimensions_limitHeight(e,this.options,"containers limitHeight fn")}areVisualsHidden(){return this.visuals.isHidden()}hasElement(){return Boolean(this.containerElement)}getSubmitButton(){return this.buttons.getSubmitButton()}querySelector(e){if(this.containerElement)return this.containerElement.querySelector(e)}beginWaiting(){this.htmlElement?.classList.add("wait")}endWaiting(){this.htmlElement?.classList.remove("wait")}appendChild(e){this.containerElement&&this.containerElement!==e&&this.containerElement.appendChild(e)}insertBefore(e,t){this.containerElement&&this.containerElement.insertBefore(e,t)}unload(e){try{if(!this.built)return;const t=e?.e;this.options.logger.debug(`Container: unload(${t?util_pretty(t):""})`),this.emit("UNLOADING"),this.unloadChildren(e),this.hide()}catch(e){this.emit("ERROR",{exc:e})}finally{util_Despot.removeAllListeners(),this.built=this.submitted=!1}}show(e){if(!this.containerElement)throw error_createError({message:"No container element exists.",options:this.options});if(html_showElement(this.containerElement),this.visuals.show(e),!this.hasError){const e=this.isPaused();e&&this.buttons.adjustButtonsForPause(),this.buttons.show(),this.isReplayShown()?this.emit("PREVIEW"):this.emit("FORM_READY",{paused:e})}return this.containerElement}hide(){this.options.logger.debug("Container: hide()"),this.hasError=!1,this.isRecording()&&this.pause(),this.visuals.hide(),this.submitted&&(this.buttons.hide(),this.hideMySelf())}startOver(e){try{const t=e?.keepHidden;this.options.logger.debug(`Container: startOver(keepHidden = ${t})`),this.submitted=!1;const i=this.getReplay();i.hide(),i.reset(),this.build(),this.emit("STARTING_OVER"),this.visuals.back(t,(()=>{this.enableForm(!0),t||this.show()}))}catch(e){this.emit("ERROR",{exc:e})}}showReplayOnly(){this.hasError=!1,this.isRecording()&&this.pause(),this.visuals.showReplayOnly(),this.submitted&&this.buttons.hide()}isNotifying(){return this.visuals.isNotifying()}isPaused(){return this.visuals.isPaused()}pause(e){this.visuals.pause(e)}validate(e,t=!1){let i=!0,r=!0;if(this.built?this.options.enableAutoValidation?t?i=t:this.isNotifying()?i=!1:this.visuals.isConnected()?i=this.visuals.isUserMediaLoaded()??this.visuals.isReplayShown():this.visuals.isConnecting()&&(i=!1):(i=!1,this.lastValidation=!0):i=!1,i){const t=e?.target?.name;let i;t?this.emit("VALIDATING",{targetName:t}):e?this.emit("VALIDATING",{event:e}):this.emit("VALIDATING");const o=this.buttons.isRecordAgainButtonEnabled(),n=this.visuals.validate()&&o;let s;if(this.form){const e=this.form.getInvalidElement();if(e){const t=e.getAttribute("name"),o=util_getValidity(e);r=!1,t&&(o?.valueMissing?i=`Please fill out field "${t}" ⚠️`:(i=`Input "${t}" seems wrong 🤔`,s={[t]:e.getAttribute("value")}))}else this.areVisualsHidden()||n||(this.buttonsAreReady()||this.isRecording()||this.isPaused()||this.isCountingDown())&&(r=!1,i="Don't forget to record a video 😉",s={key:void 0});if(r){const e=this.form.getRecipients(),t="to"in e,o="cc"in e,n="bcc"in e,s=e.to&&e.to.length>0,a=e.cc&&e.cc.length>0,l=e.bcc&&e.bcc.length>0;t?s||(o&&n?a||l||(r=!1):o?a||(r=!1):n&&l||(r=!1)):o&&(a||n&&!l&&(r=!1)),r||(i="At least one recipient is required")}}else r=n,i="Because visuals aren't valid";r?this.emit("VALID"):s?this.emit("INVALID",{whyInvalid:i,invalidData:s}):this.emit("INVALID",{whyInvalid:i}),this.lastValidation=r}return r}disableForm(e){this.form?.disable(e)}enableForm(e){this.form?.enable(e)}hasForm(){return Boolean(this.form)}buttonsAreReady(){return this.buttons.isReady()}async submitAll(e,t,i){let r;try{const o=Boolean(e[this.options.selectors.keyInputName]);if(!o&&!this.options.enableAutoSubmission)return;const n=[t,i].filter(Boolean).join(": ");this.options.logger.debug(`Container: submitAll(${n})`),this.beginWaiting(),this.options.disableFormWhenSubmitting&&this.disableForm(!0),this.emit("SUBMITTING"),o?(r=await this.submitVideomail(e,t),this.submitted=!0,this.emit("SUBMITTED",{videomail:r.body.videomail,response:r})):(r=await this.resource.form(e,i),this.submitted=!0,this.emit("SUBMITTED",{videomail:r.body,response:r}))}catch(e){const t=error_createError({exc:e,options:this.options});this.emit("ERROR",{err:t})}finally{r?.text&&"text/html"===r.type&&(document.body.innerHTML=r.text),this.endWaiting()}}isBuilt(){return this.built}isReplayShown(){return this.visuals.isReplayShown()}isDirty(){let e=!1;return this.form&&(this.visuals.isRecorderUnloaded()||this.submitted?e=!1:(this.isReplayShown()||this.isPaused())&&(e=!0)),e}getReplay(){return this.visuals.getReplay()}isOutsideElementOf(e){return e.parentNode!==this.containerElement&&e!==this.containerElement}loadForm(e){this.form&&(this.form.loadVideomail(e),this.validate())}enableAudio(){this.options=setAudioEnabled(!0,this.options),this.emit("ENABLING_AUDIO")}disableAudio(){this.options=setAudioEnabled(!1,this.options),this.emit("DISABLING_AUDIO")}async submit(){return this.options.logger.debug("Container: submit()"),!!this.lastValidation&&await(this.form?.doTheSubmit())}isCountingDown(){return this.visuals.isCountingDown()}isRecording(){return this.visuals.isRecording()}record(){this.visuals.record()}resume(){this.visuals.resume()}stop(){this.visuals.stop()}recordAgain(){this.visuals.recordAgain()}setLimitSeconds(e){this.options.video.limitSeconds=e,this.visuals.setLimitSeconds(e)}constructor(e){super("Container",e),container_define_property(this,"visibility",document_visibility()),container_define_property(this,"htmlElement",document.querySelector("html")),container_define_property(this,"visuals",void 0),container_define_property(this,"buttons",void 0),container_define_property(this,"resource",void 0),container_define_property(this,"form",void 0),container_define_property(this,"hasError",!1),container_define_property(this,"submitted",!1),container_define_property(this,"lastValidation",!1),container_define_property(this,"containerElement",void 0),container_define_property(this,"built",!1),this.visuals=new wrappers_visuals(this,e),this.buttons=new buttons(this,e),this.resource=new src_resource(e)}}const wrappers_container=Container;function client_define_property(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class VideomailClient extends util_Despot{validateOptions(){const e=this.options.video.width;if(void 0!==e&&e%2!=0)throw error_createError({message:"Width must be divisible by two.",options:this.options});const t=this.options.video.height;if(void 0!==t&&t%2!=0)throw error_createError({message:"Height must be divisible by two.",options:this.options})}build(){if(!this.container.isBuilt())return this.options.logger.debug("Client: build()"),this.container.build()}show(e){return this.build(),this.container.show(e)}startOver(e){this.unload(!0),this.container.startOver(e)}setLimitSeconds(e){this.options.video.limitSeconds!==e?(this.options.video.limitSeconds=e,this.options.logger.debug(`Client: setLimitSeconds (limitSeconds = ${e})`),this.container.setLimitSeconds(e)):this.options.logger.debug(`Client: setLimitSeconds called but limitSeconds is already ${e}, doing nothing.`)}unload(e=!1){this.container.unload({startingOver:e})}replay(e,t){this.container.isBuilt()&&this.container.unload(),this.container.build({playerOnly:!0,replayParentElementId:t}),this.container.buildForm(),this.once("REPLAY_SHOWN",(()=>{this.container.showReplayOnly(),this.container.loadForm(e)}));const i=this.container.getReplay();i.setVideomail(e,!0);const r=i.getElement();if(!r)throw new Error("Failed to build a player element");return r}hide(){this.container.hide()}async getByAlias(e){const t=new src_resource(this.options);return await t.getByAlias(e)}async getByKey(e){const t=new src_resource(this.options);return await t.getByKey(e)}isDirty(){return this.container.isDirty()}isBuilt(){return this.container.isBuilt()}isRecording(){return this.container.isRecording()}submit(){this.container.submit()}record(){this.container.record()}getLogLines(){if(this.options.logger.getLines)return this.options.logger.getLines()}constructor(e={}){super("VideomailClient",options_mergeWithDefaultOptions(e)),client_define_property(this,"container",void 0),this.validateOptions(),util_Despot.removeAllListeners(),this.container=new wrappers_container(this.options)}}client_define_property(VideomailClient,"ENC_TYPE_APP_JSON",constants.public.ENC_TYPE_APP_JSON),client_define_property(VideomailClient,"ENC_TYPE_FORM",constants.public.ENC_TYPE_FORM);const Reactions={LOVE:{key:"love",label:"Love"},APPLAUSE:{key:"applause",label:"Applause"},FOLDED_HANDS:{key:"foldedHands",label:"Pray / Beg"},GRINNING_SWEAT:{key:"grinningSweat",label:"Smile / Grinning Sweat"},ANGER:{key:"anger",label:"Angry"}};export{Reactions,VideoType,VideomailClient};
//# sourceMappingURL=/sm/15b552fd6308791b17e1062b0345a126d42f3600590887bcf40144d5c15c3f41.map