UNPKG

@needle-tools/engine

Version:

Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in

1,407 lines • 848 kB
import { PlaneGeometry as Or, ShaderChunk as fc, Triangle as wt, Vector3 as M, Layers as _s, MeshBasicMaterial as En, DoubleSide as jn, AdditiveBlending as _r, Object3D as Lo, InstancedBufferAttribute as Me, DynamicDrawUsage as ft, InstancedBufferGeometry as Vc, Uniform$1 as Qt, ShaderMaterial as On, BufferGeometry as oi, BufferAttribute as Gt, Mesh as mn, MeshStandardMaterial as Rc, MeshPhysicalMaterial as xc, Vector2 as qt, Plane as Dr, Line3 as he, Sphere as Ar, Matrix4 as kt, Box3 as Ct, REVISION as qr, BackSide as Lc, FrontSide as Jo, Group as Sc, LineBasicMaterial as Wc, BatchedMesh as Cc, Ray as gc, DataTexture as _n, NearestFilter as ii, UnsignedIntType as Ni, IntType as Ds, FloatType as Ii, UnsignedByteType as Uo, UnsignedShortType as zc, ByteType as Po, ShortType as vc, RGBAFormat as nn, RGBAIntegerFormat as Dn, RGFormat as Kc, RedFormat as Tc, RGIntegerFormat as $r, RedIntegerFormat as Mc, Matrix3 as Yc, Vector4 as So } from "./three.js"; const rt = { Handedness: Object.freeze({ NONE: "none", LEFT: "left", RIGHT: "right" }), ComponentState: Object.freeze({ DEFAULT: "default", TOUCHED: "touched", PRESSED: "pressed" }), ComponentProperty: Object.freeze({ BUTTON: "button", X_AXIS: "xAxis", Y_AXIS: "yAxis", STATE: "state" }), ComponentType: Object.freeze({ TRIGGER: "trigger", SQUEEZE: "squeeze", TOUCHPAD: "touchpad", THUMBSTICK: "thumbstick", BUTTON: "button" }), ButtonTouchThreshold: 0.05, AxisTouchThreshold: 0.1, VisualResponseProperty: Object.freeze({ TRANSFORM: "transform", VISIBILITY: "visibility" }) }; async function tl(s) { const t = await fetch(s); if (t.ok) return t.json(); throw new Error(t.statusText); } async function kc(s) { if (!s) throw new Error("No basePath supplied"); return await tl(`${s}/profilesList.json`); } async function Yu(s, t, e = null, i = !0) { if (!s) throw new Error("No xrInputSource supplied"); if (!t) throw new Error("No basePath supplied"); const n = await kc(t); let o; if (s.profiles.some((l) => { const a = n[l]; return a && (o = { profileId: l, profilePath: `${t}/${a.path}`, deprecated: !!a.deprecated }), !!o; }), !o) { if (!e) throw new Error("No matching profile name found"); const l = n[e]; if (!l) throw new Error(`No matching profile name found and default profile "${e}" missing.`); o = { profileId: e, profilePath: `${t}/${l.path}`, deprecated: !!l.deprecated }; } const r = await tl(o.profilePath); let c; if (i) { let l; if (s.handedness === "any" ? l = r.layouts[Object.keys(r.layouts)[0]] : l = r.layouts[s.handedness], !l) throw new Error( `No matching handedness, ${s.handedness}, in profile ${o.profileId}` ); l.assetPath && (c = o.profilePath.replace("profile.json", l.assetPath)); } return { profile: r, assetPath: c }; } const Hc = { xAxis: 0, yAxis: 0, button: 0, state: rt.ComponentState.DEFAULT }; function Nc(s = 0, t = 0) { let e = s, i = t; if (Math.sqrt(s * s + t * t) > 1) { const r = Math.atan2(t, s); e = Math.cos(r), i = Math.sin(r); } return { normalizedXAxis: e * 0.5 + 0.5, normalizedYAxis: i * 0.5 + 0.5 }; } class Ic { constructor(t) { this.componentProperty = t.componentProperty, this.states = t.states, this.valueNodeName = t.valueNodeName, this.valueNodeProperty = t.valueNodeProperty, this.valueNodeProperty === rt.VisualResponseProperty.TRANSFORM && (this.minNodeName = t.minNodeName, this.maxNodeName = t.maxNodeName), this.value = 0, this.updateFromComponent(Hc); } /** * Computes the visual response's interpolation weight based on component state * @param {Object} componentValues - The component from which to update * @param {number} xAxis - The reported X axis value of the component * @param {number} yAxis - The reported Y axis value of the component * @param {number} button - The reported value of the component's button * @param {string} state - The component's active state */ updateFromComponent({ xAxis: t, yAxis: e, button: i, state: n }) { const { normalizedXAxis: o, normalizedYAxis: r } = Nc(t, e); switch (this.componentProperty) { case rt.ComponentProperty.X_AXIS: this.value = this.states.includes(n) ? o : 0.5; break; case rt.ComponentProperty.Y_AXIS: this.value = this.states.includes(n) ? r : 0.5; break; case rt.ComponentProperty.BUTTON: this.value = this.states.includes(n) ? i : 0; break; case rt.ComponentProperty.STATE: this.valueNodeProperty === rt.VisualResponseProperty.VISIBILITY ? this.value = this.states.includes(n) : this.value = this.states.includes(n) ? 1 : 0; break; default: throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`); } } } class Jc { /** * @param {Object} componentId - Id of the component * @param {Object} componentDescription - Description of the component to be created */ constructor(t, e) { if (!t || !e || !e.visualResponses || !e.gamepadIndices || Object.keys(e.gamepadIndices).length === 0) throw new Error("Invalid arguments supplied"); this.id = t, this.type = e.type, this.rootNodeName = e.rootNodeName, this.touchPointNodeName = e.touchPointNodeName, this.visualResponses = {}, Object.keys(e.visualResponses).forEach((i) => { const n = new Ic(e.visualResponses[i]); this.visualResponses[i] = n; }), this.gamepadIndices = Object.assign({}, e.gamepadIndices), this.values = { state: rt.ComponentState.DEFAULT, button: this.gamepadIndices.button !== void 0 ? 0 : void 0, xAxis: this.gamepadIndices.xAxis !== void 0 ? 0 : void 0, yAxis: this.gamepadIndices.yAxis !== void 0 ? 0 : void 0 }; } get data() { return { id: this.id, ...this.values }; } /** * @description Poll for updated data based on current gamepad state * @param {Object} gamepad - The gamepad object from which the component data should be polled */ updateFromGamepad(t) { if (this.values.state = rt.ComponentState.DEFAULT, this.gamepadIndices.button !== void 0 && t.buttons.length > this.gamepadIndices.button) { const e = t.buttons[this.gamepadIndices.button]; this.values.button = e.value, this.values.button = this.values.button < 0 ? 0 : this.values.button, this.values.button = this.values.button > 1 ? 1 : this.values.button, e.pressed || this.values.button === 1 ? this.values.state = rt.ComponentState.PRESSED : (e.touched || this.values.button > rt.ButtonTouchThreshold) && (this.values.state = rt.ComponentState.TOUCHED); } this.gamepadIndices.xAxis !== void 0 && t.axes.length > this.gamepadIndices.xAxis && (this.values.xAxis = t.axes[this.gamepadIndices.xAxis], this.values.xAxis = this.values.xAxis < -1 ? -1 : this.values.xAxis, this.values.xAxis = this.values.xAxis > 1 ? 1 : this.values.xAxis, this.values.state === rt.ComponentState.DEFAULT && Math.abs(this.values.xAxis) > rt.AxisTouchThreshold && (this.values.state = rt.ComponentState.TOUCHED)), this.gamepadIndices.yAxis !== void 0 && t.axes.length > this.gamepadIndices.yAxis && (this.values.yAxis = t.axes[this.gamepadIndices.yAxis], this.values.yAxis = this.values.yAxis < -1 ? -1 : this.values.yAxis, this.values.yAxis = this.values.yAxis > 1 ? 1 : this.values.yAxis, this.values.state === rt.ComponentState.DEFAULT && Math.abs(this.values.yAxis) > rt.AxisTouchThreshold && (this.values.state = rt.ComponentState.TOUCHED)), Object.values(this.visualResponses).forEach((e) => { e.updateFromComponent(this.values); }); } } class ku { /** * @param {Object} xrInputSource - The XRInputSource to build the MotionController around * @param {Object} profile - The best matched profile description for the supplied xrInputSource * @param {Object} assetUrl */ constructor(t, e, i) { if (!t) throw new Error("No xrInputSource supplied"); if (!e) throw new Error("No profile supplied"); this.xrInputSource = t, this.assetUrl = i, this.id = e.profileId, this.layoutDescription = e.layouts[t.handedness], this.components = {}, Object.keys(this.layoutDescription.components).forEach((n) => { const o = this.layoutDescription.components[n]; this.components[n] = new Jc(n, o); }), this.updateFromGamepad(); } get gripSpace() { return this.xrInputSource.gripSpace; } get targetRaySpace() { return this.xrInputSource.targetRaySpace; } /** * @description Returns a subset of component data for simplified debugging */ get data() { const t = []; return Object.values(this.components).forEach((e) => { t.push(e.data); }), t; } /** * @description Poll for updated data based on current gamepad state */ updateFromGamepad() { Object.values(this.components).forEach((t) => { t.updateFromGamepad(this.xrInputSource.gamepad); }); } } const Rn = 2, Dt = 4, ae = 4, Uc = 4, Ze = new Int32Array(2), Fo = new Float32Array(Ze.buffer), Qo = new Float64Array(Ze.buffer), Rs = new Uint16Array(new Uint8Array([1, 0]).buffer)[0] === 1; class ue { constructor(t, e) { this.low = t | 0, this.high = e | 0; } static create(t, e) { return t == 0 && e == 0 ? ue.ZERO : new ue(t, e); } toFloat64() { return (this.low >>> 0) + this.high * 4294967296; } equals(t) { return this.low == t.low && this.high == t.high; } } ue.ZERO = new ue(0, 0); var An; (function(s) { s[s.UTF8_BYTES = 1] = "UTF8_BYTES", s[s.UTF16_STRING = 2] = "UTF16_STRING"; })(An || (An = {})); class on { /** * Create a new ByteBuffer with a given array of bytes (`Uint8Array`) */ constructor(t) { this.bytes_ = t, this.position_ = 0; } /** * Create and allocate a new ByteBuffer with a given size. */ static allocate(t) { return new on(new Uint8Array(t)); } clear() { this.position_ = 0; } /** * Get the underlying `Uint8Array`. */ bytes() { return this.bytes_; } /** * Get the buffer's position. */ position() { return this.position_; } /** * Set the buffer's position. */ setPosition(t) { this.position_ = t; } /** * Get the buffer's capacity. */ capacity() { return this.bytes_.length; } readInt8(t) { return this.readUint8(t) << 24 >> 24; } readUint8(t) { return this.bytes_[t]; } readInt16(t) { return this.readUint16(t) << 16 >> 16; } readUint16(t) { return this.bytes_[t] | this.bytes_[t + 1] << 8; } readInt32(t) { return this.bytes_[t] | this.bytes_[t + 1] << 8 | this.bytes_[t + 2] << 16 | this.bytes_[t + 3] << 24; } readUint32(t) { return this.readInt32(t) >>> 0; } readInt64(t) { return new ue(this.readInt32(t), this.readInt32(t + 4)); } readUint64(t) { return new ue(this.readUint32(t), this.readUint32(t + 4)); } readFloat32(t) { return Ze[0] = this.readInt32(t), Fo[0]; } readFloat64(t) { return Ze[Rs ? 0 : 1] = this.readInt32(t), Ze[Rs ? 1 : 0] = this.readInt32(t + 4), Qo[0]; } writeInt8(t, e) { this.bytes_[t] = e; } writeUint8(t, e) { this.bytes_[t] = e; } writeInt16(t, e) { this.bytes_[t] = e, this.bytes_[t + 1] = e >> 8; } writeUint16(t, e) { this.bytes_[t] = e, this.bytes_[t + 1] = e >> 8; } writeInt32(t, e) { this.bytes_[t] = e, this.bytes_[t + 1] = e >> 8, this.bytes_[t + 2] = e >> 16, this.bytes_[t + 3] = e >> 24; } writeUint32(t, e) { this.bytes_[t] = e, this.bytes_[t + 1] = e >> 8, this.bytes_[t + 2] = e >> 16, this.bytes_[t + 3] = e >> 24; } writeInt64(t, e) { this.writeInt32(t, e.low), this.writeInt32(t + 4, e.high); } writeUint64(t, e) { this.writeUint32(t, e.low), this.writeUint32(t + 4, e.high); } writeFloat32(t, e) { Fo[0] = e, this.writeInt32(t, Ze[0]); } writeFloat64(t, e) { Qo[0] = e, this.writeInt32(t, Ze[Rs ? 0 : 1]), this.writeInt32(t + 4, Ze[Rs ? 1 : 0]); } /** * Return the file identifier. Behavior is undefined for FlatBuffers whose * schema does not include a file_identifier (likely points at padding or the * start of a the root vtable). */ getBufferIdentifier() { if (this.bytes_.length < this.position_ + Dt + ae) throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier."); let t = ""; for (let e = 0; e < ae; e++) t += String.fromCharCode(this.readInt8(this.position_ + Dt + e)); return t; } /** * Look up a field in the vtable, return an offset into the object, or 0 if the * field is not present. */ __offset(t, e) { const i = t - this.readInt32(t); return e < this.readInt16(i) ? this.readInt16(i + e) : 0; } /** * Initialize any Table-derived type to point to the union at the given offset. */ __union(t, e) { return t.bb_pos = e + this.readInt32(e), t.bb = this, t; } /** * Create a JavaScript string from UTF-8 data stored inside the FlatBuffer. * This allocates a new string and converts to wide chars upon each access. * * To avoid the conversion to UTF-16, pass Encoding.UTF8_BYTES as * the "optionalEncoding" argument. This is useful for avoiding conversion to * and from UTF-16 when the data will just be packaged back up in another * FlatBuffer later on. * * @param offset * @param opt_encoding Defaults to UTF16_STRING */ __string(t, e) { t += this.readInt32(t); const i = this.readInt32(t); let n = "", o = 0; if (t += Dt, e === An.UTF8_BYTES) return this.bytes_.subarray(t, t + i); for (; o < i; ) { let r; const c = this.readUint8(t + o++); if (c < 192) r = c; else { const l = this.readUint8(t + o++); if (c < 224) r = (c & 31) << 6 | l & 63; else { const a = this.readUint8(t + o++); if (c < 240) r = (c & 15) << 12 | (l & 63) << 6 | a & 63; else { const d = this.readUint8(t + o++); r = (c & 7) << 18 | (l & 63) << 12 | (a & 63) << 6 | d & 63; } } } r < 65536 ? n += String.fromCharCode(r) : (r -= 65536, n += String.fromCharCode((r >> 10) + 55296, (r & 1024 - 1) + 56320)); } return n; } /** * Handle unions that can contain string as its member, if a Table-derived type then initialize it, * if a string then return a new one * * WARNING: strings are immutable in JS so we can't change the string that the user gave us, this * makes the behaviour of __union_with_string different compared to __union */ __union_with_string(t, e) { return typeof t == "string" ? this.__string(e) : this.__union(t, e); } /** * Retrieve the relative offset stored at "offset" */ __indirect(t) { return t + this.readInt32(t); } /** * Get the start of data of a vector whose offset is stored at "offset" in this object. */ __vector(t) { return t + this.readInt32(t) + Dt; } /** * Get the length of a vector whose offset is stored at "offset" in this object. */ __vector_len(t) { return this.readInt32(t + this.readInt32(t)); } __has_identifier(t) { if (t.length != ae) throw new Error("FlatBuffers: file identifier must be length " + ae); for (let e = 0; e < ae; e++) if (t.charCodeAt(e) != this.readInt8(this.position() + Dt + e)) return !1; return !0; } /** * A helper function to avoid generated code depending on this file directly. */ createLong(t, e) { return ue.create(t, e); } /** * A helper function for generating list for obj api */ createScalarList(t, e) { const i = []; for (let n = 0; n < e; ++n) t(n) !== null && i.push(t(n)); return i; } /** * A helper function for generating list for obj api * @param listAccessor function that accepts an index and return data at that index * @param listLength listLength * @param res result list */ createObjList(t, e) { const i = []; for (let n = 0; n < e; ++n) { const o = t(n); o !== null && i.push(o.unpack()); } return i; } } class el { /** * Create a FlatBufferBuilder. */ constructor(t) { this.minalign = 1, this.vtable = null, this.vtable_in_use = 0, this.isNested = !1, this.object_start = 0, this.vtables = [], this.vector_num_elems = 0, this.force_defaults = !1, this.string_maps = null; let e; t ? e = t : e = 1024, this.bb = on.allocate(e), this.space = e; } clear() { this.bb.clear(), this.space = this.bb.capacity(), this.minalign = 1, this.vtable = null, this.vtable_in_use = 0, this.isNested = !1, this.object_start = 0, this.vtables = [], this.vector_num_elems = 0, this.force_defaults = !1, this.string_maps = null; } /** * In order to save space, fields that are set to their default value * don't get serialized into the buffer. Forcing defaults provides a * way to manually disable this optimization. * * @param forceDefaults true always serializes default values */ forceDefaults(t) { this.force_defaults = t; } /** * Get the ByteBuffer representing the FlatBuffer. Only call this after you've * called finish(). The actual data starts at the ByteBuffer's current position, * not necessarily at 0. */ dataBuffer() { return this.bb; } /** * Get the bytes representing the FlatBuffer. Only call this after you've * called finish(). */ asUint8Array() { return this.bb.bytes().subarray(this.bb.position(), this.bb.position() + this.offset()); } /** * Prepare to write an element of `size` after `additional_bytes` have been * written, e.g. if you write a string, you need to align such the int length * field is aligned to 4 bytes, and the string data follows it directly. If all * you need to do is alignment, `additional_bytes` will be 0. * * @param size This is the of the new element to write * @param additional_bytes The padding size */ prep(t, e) { t > this.minalign && (this.minalign = t); const i = ~(this.bb.capacity() - this.space + e) + 1 & t - 1; for (; this.space < i + t + e; ) { const n = this.bb.capacity(); this.bb = el.growByteBuffer(this.bb), this.space += this.bb.capacity() - n; } this.pad(i); } pad(t) { for (let e = 0; e < t; e++) this.bb.writeInt8(--this.space, 0); } writeInt8(t) { this.bb.writeInt8(this.space -= 1, t); } writeInt16(t) { this.bb.writeInt16(this.space -= 2, t); } writeInt32(t) { this.bb.writeInt32(this.space -= 4, t); } writeInt64(t) { this.bb.writeInt64(this.space -= 8, t); } writeFloat32(t) { this.bb.writeFloat32(this.space -= 4, t); } writeFloat64(t) { this.bb.writeFloat64(this.space -= 8, t); } /** * Add an `int8` to the buffer, properly aligned, and grows the buffer (if necessary). * @param value The `int8` to add the the buffer. */ addInt8(t) { this.prep(1, 0), this.writeInt8(t); } /** * Add an `int16` to the buffer, properly aligned, and grows the buffer (if necessary). * @param value The `int16` to add the the buffer. */ addInt16(t) { this.prep(2, 0), this.writeInt16(t); } /** * Add an `int32` to the buffer, properly aligned, and grows the buffer (if necessary). * @param value The `int32` to add the the buffer. */ addInt32(t) { this.prep(4, 0), this.writeInt32(t); } /** * Add an `int64` to the buffer, properly aligned, and grows the buffer (if necessary). * @param value The `int64` to add the the buffer. */ addInt64(t) { this.prep(8, 0), this.writeInt64(t); } /** * Add a `float32` to the buffer, properly aligned, and grows the buffer (if necessary). * @param value The `float32` to add the the buffer. */ addFloat32(t) { this.prep(4, 0), this.writeFloat32(t); } /** * Add a `float64` to the buffer, properly aligned, and grows the buffer (if necessary). * @param value The `float64` to add the the buffer. */ addFloat64(t) { this.prep(8, 0), this.writeFloat64(t); } addFieldInt8(t, e, i) { (this.force_defaults || e != i) && (this.addInt8(e), this.slot(t)); } addFieldInt16(t, e, i) { (this.force_defaults || e != i) && (this.addInt16(e), this.slot(t)); } addFieldInt32(t, e, i) { (this.force_defaults || e != i) && (this.addInt32(e), this.slot(t)); } addFieldInt64(t, e, i) { (this.force_defaults || !e.equals(i)) && (this.addInt64(e), this.slot(t)); } addFieldFloat32(t, e, i) { (this.force_defaults || e != i) && (this.addFloat32(e), this.slot(t)); } addFieldFloat64(t, e, i) { (this.force_defaults || e != i) && (this.addFloat64(e), this.slot(t)); } addFieldOffset(t, e, i) { (this.force_defaults || e != i) && (this.addOffset(e), this.slot(t)); } /** * Structs are stored inline, so nothing additional is being added. `d` is always 0. */ addFieldStruct(t, e, i) { e != i && (this.nested(e), this.slot(t)); } /** * Structures are always stored inline, they need to be created right * where they're used. You'll get this assertion failure if you * created it elsewhere. */ nested(t) { if (t != this.offset()) throw new Error("FlatBuffers: struct must be serialized inline."); } /** * Should not be creating any other object, string or vector * while an object is being constructed */ notNested() { if (this.isNested) throw new Error("FlatBuffers: object serialization must not be nested."); } /** * Set the current vtable at `voffset` to the current location in the buffer. */ slot(t) { this.vtable !== null && (this.vtable[t] = this.offset()); } /** * @returns Offset relative to the end of the buffer. */ offset() { return this.bb.capacity() - this.space; } /** * Doubles the size of the backing ByteBuffer and copies the old data towards * the end of the new buffer (since we build the buffer backwards). * * @param bb The current buffer with the existing data * @returns A new byte buffer with the old data copied * to it. The data is located at the end of the buffer. * * uint8Array.set() formally takes {Array<number>|ArrayBufferView}, so to pass * it a uint8Array we need to suppress the type check: * @suppress {checkTypes} */ static growByteBuffer(t) { const e = t.capacity(); if (e & 3221225472) throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes."); const i = e << 1, n = on.allocate(i); return n.setPosition(i - e), n.bytes().set(t.bytes(), i - e), n; } /** * Adds on offset, relative to where it will be written. * * @param offset The offset to add. */ addOffset(t) { this.prep(Dt, 0), this.writeInt32(this.offset() - t + Dt); } /** * Start encoding a new object in the buffer. Users will not usually need to * call this directly. The FlatBuffers compiler will generate helper methods * that call this method internally. */ startObject(t) { this.notNested(), this.vtable == null && (this.vtable = []), this.vtable_in_use = t; for (let e = 0; e < t; e++) this.vtable[e] = 0; this.isNested = !0, this.object_start = this.offset(); } /** * Finish off writing the object that is under construction. * * @returns The offset to the object inside `dataBuffer` */ endObject() { if (this.vtable == null || !this.isNested) throw new Error("FlatBuffers: endObject called without startObject"); this.addInt32(0); const t = this.offset(); let e = this.vtable_in_use - 1; for (; e >= 0 && this.vtable[e] == 0; e--) ; const i = e + 1; for (; e >= 0; e--) this.addInt16(this.vtable[e] != 0 ? t - this.vtable[e] : 0); const n = 2; this.addInt16(t - this.object_start); const o = (i + n) * Rn; this.addInt16(o); let r = 0; const c = this.space; t: for (e = 0; e < this.vtables.length; e++) { const l = this.bb.capacity() - this.vtables[e]; if (o == this.bb.readInt16(l)) { for (let a = Rn; a < o; a += Rn) if (this.bb.readInt16(c + a) != this.bb.readInt16(l + a)) continue t; r = this.vtables[e]; break; } } return r ? (this.space = this.bb.capacity() - t, this.bb.writeInt32(this.space, r - t)) : (this.vtables.push(this.offset()), this.bb.writeInt32(this.bb.capacity() - t, this.offset() - t)), this.isNested = !1, t; } /** * Finalize a buffer, poiting to the given `root_table`. */ finish(t, e, i) { const n = i ? Uc : 0; if (e) { const o = e; if (this.prep(this.minalign, Dt + ae + n), o.length != ae) throw new Error("FlatBuffers: file identifier must be length " + ae); for (let r = ae - 1; r >= 0; r--) this.writeInt8(o.charCodeAt(r)); } this.prep(this.minalign, Dt + n), this.addOffset(t), n && this.addInt32(this.bb.capacity() - this.space), this.bb.setPosition(this.space); } /** * Finalize a size prefixed buffer, pointing to the given `root_table`. */ finishSizePrefixed(t, e) { this.finish(t, e, !0); } /** * This checks a required field has been set in a given table that has * just been constructed. */ requiredField(t, e) { const i = this.bb.capacity() - t, n = i - this.bb.readInt32(i); if (!(this.bb.readInt16(n + e) != 0)) throw new Error("FlatBuffers: field " + e + " must be set"); } /** * Start a new array/vector of objects. Users usually will not call * this directly. The FlatBuffers compiler will create a start/end * method for vector types in generated code. * * @param elem_size The size of each element in the array * @param num_elems The number of elements in the array * @param alignment The alignment of the array */ startVector(t, e, i) { this.notNested(), this.vector_num_elems = e, this.prep(Dt, t * e), this.prep(i, t * e); } /** * Finish off the creation of an array and all its elements. The array must be * created with `startVector`. * * @returns The offset at which the newly created array * starts. */ endVector() { return this.writeInt32(this.vector_num_elems), this.offset(); } /** * Encode the string `s` in the buffer using UTF-8. If the string passed has * already been seen, we return the offset of the already written string * * @param s The string to encode * @return The offset in the buffer where the encoded string starts */ createSharedString(t) { if (!t) return 0; if (this.string_maps || (this.string_maps = /* @__PURE__ */ new Map()), this.string_maps.has(t)) return this.string_maps.get(t); const e = this.createString(t); return this.string_maps.set(t, e), e; } /** * Encode the string `s` in the buffer using UTF-8. If a Uint8Array is passed * instead of a string, it is assumed to contain valid UTF-8 encoded data. * * @param s The string to encode * @return The offset in the buffer where the encoded string starts */ createString(t) { if (!t) return 0; let e; if (t instanceof Uint8Array) e = t; else { e = []; let i = 0; for (; i < t.length; ) { let n; const o = t.charCodeAt(i++); if (o < 55296 || o >= 56320) n = o; else { const r = t.charCodeAt(i++); n = (o << 10) + r + (65536 - 56623104 - 56320); } n < 128 ? e.push(n) : (n < 2048 ? e.push(n >> 6 & 31 | 192) : (n < 65536 ? e.push(n >> 12 & 15 | 224) : e.push(n >> 18 & 7 | 240, n >> 12 & 63 | 128), e.push(n >> 6 & 63 | 128)), e.push(n & 63 | 128)); } } this.addInt8(0), this.startVector(1, e.length, 1), this.bb.setPosition(this.space -= e.length); for (let i = 0, n = this.space, o = this.bb.bytes(); i < e.length; i++) o[n++] = e[i]; return this.endVector(); } /** * A helper function to avoid generated code depending on this file directly. */ createLong(t, e) { return ue.create(t, e); } /** * A helper function to pack an object * * @returns offset of obj */ createObjectOffset(t) { return t === null ? 0 : typeof t == "string" ? this.createString(t) : t.pack(this); } /** * A helper function to pack a list of object * * @returns list of offsets of each non null object */ createObjectOffsetList(t) { const e = []; for (let i = 0; i < t.length; ++i) { const n = t[i]; if (n !== null) e.push(this.createObjectOffset(n)); else throw new Error("FlatBuffers: Argument for createObjectOffsetList cannot contain null."); } return e; } createStructOffsetList(t, e) { return e(this, t.length), this.createObjectOffsetList(t), this.endVector(); } } function bn(s) { return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s; } var il = { exports: {} }; (function(s) { var t = {}; t.useBlobBuilder = function() { try { return new Blob([]), !1; } catch { return !0; } }(), t.useArrayBufferView = !t.useBlobBuilder && function() { try { return new Blob([new Uint8Array([])]).size === 0; } catch { return !0; } }(), s.exports.binaryFeatures = t; var e = s.exports.BlobBuilder; typeof window < "u" && (e = s.exports.BlobBuilder = window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder || window.BlobBuilder); function i() { this._pieces = [], this._parts = []; } i.prototype.append = function(n) { typeof n == "number" ? this._pieces.push(n) : (this.flush(), this._parts.push(n)); }, i.prototype.flush = function() { if (this._pieces.length > 0) { var n = new Uint8Array(this._pieces); t.useArrayBufferView || (n = n.buffer), this._parts.push(n), this._pieces = []; } }, i.prototype.getBuffer = function() { if (this.flush(), t.useBlobBuilder) { for (var n = new e(), o = 0, r = this._parts.length; o < r; o++) n.append(this._parts[o]); return n.getBlob(); } else return new Blob(this._parts); }, s.exports.BufferBuilder = i; })(il); var sl = il.exports, Pc = sl.BufferBuilder, wo = sl.binaryFeatures, Fc = { unpack: function(s) { var t = new ut(s); return t.unpack(); }, pack: function(s) { var t = new pt(); t.pack(s); var e = t.getBuffer(); return e; } }, Qc = Fc; function ut(s) { this.index = 0, this.dataBuffer = s, this.dataView = new Uint8Array(this.dataBuffer), this.length = this.dataBuffer.byteLength; } ut.prototype.unpack = function() { var s = this.unpack_uint8(); if (s < 128) return s; if ((s ^ 224) < 32) return (s ^ 224) - 32; var t; if ((t = s ^ 160) <= 15) return this.unpack_raw(t); if ((t = s ^ 176) <= 15) return this.unpack_string(t); if ((t = s ^ 144) <= 15) return this.unpack_array(t); if ((t = s ^ 128) <= 15) return this.unpack_map(t); switch (s) { case 192: return null; case 193: return; case 194: return !1; case 195: return !0; case 202: return this.unpack_float(); case 203: return this.unpack_double(); case 204: return this.unpack_uint8(); case 205: return this.unpack_uint16(); case 206: return this.unpack_uint32(); case 207: return this.unpack_uint64(); case 208: return this.unpack_int8(); case 209: return this.unpack_int16(); case 210: return this.unpack_int32(); case 211: return this.unpack_int64(); case 212: return; case 213: return; case 214: return; case 215: return; case 216: return t = this.unpack_uint16(), this.unpack_string(t); case 217: return t = this.unpack_uint32(), this.unpack_string(t); case 218: return t = this.unpack_uint16(), this.unpack_raw(t); case 219: return t = this.unpack_uint32(), this.unpack_raw(t); case 220: return t = this.unpack_uint16(), this.unpack_array(t); case 221: return t = this.unpack_uint32(), this.unpack_array(t); case 222: return t = this.unpack_uint16(), this.unpack_map(t); case 223: return t = this.unpack_uint32(), this.unpack_map(t); } }; ut.prototype.unpack_uint8 = function() { var s = this.dataView[this.index] & 255; return this.index++, s; }; ut.prototype.unpack_uint16 = function() { var s = this.read(2), t = (s[0] & 255) * 256 + (s[1] & 255); return this.index += 2, t; }; ut.prototype.unpack_uint32 = function() { var s = this.read(4), t = ((s[0] * 256 + s[1]) * 256 + s[2]) * 256 + s[3]; return this.index += 4, t; }; ut.prototype.unpack_uint64 = function() { var s = this.read(8), t = ((((((s[0] * 256 + s[1]) * 256 + s[2]) * 256 + s[3]) * 256 + s[4]) * 256 + s[5]) * 256 + s[6]) * 256 + s[7]; return this.index += 8, t; }; ut.prototype.unpack_int8 = function() { var s = this.unpack_uint8(); return s < 128 ? s : s - 256; }; ut.prototype.unpack_int16 = function() { var s = this.unpack_uint16(); return s < 32768 ? s : s - 65536; }; ut.prototype.unpack_int32 = function() { var s = this.unpack_uint32(); return s < Math.pow(2, 31) ? s : s - Math.pow(2, 32); }; ut.prototype.unpack_int64 = function() { var s = this.unpack_uint64(); return s < Math.pow(2, 63) ? s : s - Math.pow(2, 64); }; ut.prototype.unpack_raw = function(s) { if (this.length < this.index + s) throw new Error("BinaryPackFailure: index is out of range " + this.index + " " + s + " " + this.length); var t = this.dataBuffer.slice(this.index, this.index + s); return this.index += s, t; }; ut.prototype.unpack_string = function(s) { for (var t = this.read(s), e = 0, i = "", n, o; e < s; ) n = t[e], n < 128 ? (i += String.fromCharCode(n), e++) : (n ^ 192) < 32 ? (o = (n ^ 192) << 6 | t[e + 1] & 63, i += String.fromCharCode(o), e += 2) : (o = (n & 15) << 12 | (t[e + 1] & 63) << 6 | t[e + 2] & 63, i += String.fromCharCode(o), e += 3); return this.index += s, i; }; ut.prototype.unpack_array = function(s) { for (var t = new Array(s), e = 0; e < s; e++) t[e] = this.unpack(); return t; }; ut.prototype.unpack_map = function(s) { for (var t = {}, e = 0; e < s; e++) { var i = this.unpack(), n = this.unpack(); t[i] = n; } return t; }; ut.prototype.unpack_float = function() { var s = this.unpack_uint32(), t = s >> 31, e = (s >> 23 & 255) - 127, i = s & 8388607 | 8388608; return (t === 0 ? 1 : -1) * i * Math.pow(2, e - 23); }; ut.prototype.unpack_double = function() { var s = this.unpack_uint32(), t = this.unpack_uint32(), e = s >> 31, i = (s >> 20 & 2047) - 1023, n = s & 1048575 | 1048576, o = n * Math.pow(2, i - 20) + t * Math.pow(2, i - 52); return (e === 0 ? 1 : -1) * o; }; ut.prototype.read = function(s) { var t = this.index; if (t + s <= this.length) return this.dataView.subarray(t, t + s); throw new Error("BinaryPackFailure: read index out of range"); }; function pt() { this.bufferBuilder = new Pc(); } pt.prototype.getBuffer = function() { return this.bufferBuilder.getBuffer(); }; pt.prototype.pack = function(s) { var t = typeof s; if (t === "string") this.pack_string(s); else if (t === "number") Math.floor(s) === s ? this.pack_integer(s) : this.pack_double(s); else if (t === "boolean") s === !0 ? this.bufferBuilder.append(195) : s === !1 && this.bufferBuilder.append(194); else if (t === "undefined") this.bufferBuilder.append(192); else if (t === "object") if (s === null) this.bufferBuilder.append(192); else { var e = s.constructor; if (e == Array) this.pack_array(s); else if (e == Blob || e == File || s instanceof Blob || s instanceof File) this.pack_bin(s); else if (e == ArrayBuffer) wo.useArrayBufferView ? this.pack_bin(new Uint8Array(s)) : this.pack_bin(s); else if ("BYTES_PER_ELEMENT" in s) wo.useArrayBufferView ? this.pack_bin(new Uint8Array(s.buffer)) : this.pack_bin(s.buffer); else if (e == Object || e.toString().startsWith("class")) this.pack_object(s); else if (e == Date) this.pack_string(s.toString()); else if (typeof s.toBinaryPack == "function") this.bufferBuilder.append(s.toBinaryPack()); else throw new Error('Type "' + e.toString() + '" not yet supported'); } else throw new Error('Type "' + t + '" not yet supported'); this.bufferBuilder.flush(); }; pt.prototype.pack_bin = function(s) { var t = s.length || s.byteLength || s.size; if (t <= 15) this.pack_uint8(160 + t); else if (t <= 65535) this.bufferBuilder.append(218), this.pack_uint16(t); else if (t <= 4294967295) this.bufferBuilder.append(219), this.pack_uint32(t); else throw new Error("Invalid length"); this.bufferBuilder.append(s); }; pt.prototype.pack_string = function(s) { var t = Bc(s); if (t <= 15) this.pack_uint8(176 + t); else if (t <= 65535) this.bufferBuilder.append(216), this.pack_uint16(t); else if (t <= 4294967295) this.bufferBuilder.append(217), this.pack_uint32(t); else throw new Error("Invalid length"); this.bufferBuilder.append(s); }; pt.prototype.pack_array = function(s) { var t = s.length; if (t <= 15) this.pack_uint8(144 + t); else if (t <= 65535) this.bufferBuilder.append(220), this.pack_uint16(t); else if (t <= 4294967295) this.bufferBuilder.append(221), this.pack_uint32(t); else throw new Error("Invalid length"); for (var e = 0; e < t; e++) this.pack(s[e]); }; pt.prototype.pack_integer = function(s) { if (s >= -32 && s <= 127) this.bufferBuilder.append(s & 255); else if (s >= 0 && s <= 255) this.bufferBuilder.append(204), this.pack_uint8(s); else if (s >= -128 && s <= 127) this.bufferBuilder.append(208), this.pack_int8(s); else if (s >= 0 && s <= 65535) this.bufferBuilder.append(205), this.pack_uint16(s); else if (s >= -32768 && s <= 32767) this.bufferBuilder.append(209), this.pack_int16(s); else if (s >= 0 && s <= 4294967295) this.bufferBuilder.append(206), this.pack_uint32(s); else if (s >= -2147483648 && s <= 2147483647) this.bufferBuilder.append(210), this.pack_int32(s); else if (s >= -9223372036854776e3 && s <= 9223372036854776e3) this.bufferBuilder.append(211), this.pack_int64(s); else if (s >= 0 && s <= 18446744073709552e3) this.bufferBuilder.append(207), this.pack_uint64(s); else throw new Error("Invalid integer"); }; pt.prototype.pack_double = function(s) { var t = 0; s < 0 && (t = 1, s = -s); var e = Math.floor(Math.log(s) / Math.LN2), i = s / Math.pow(2, e) - 1, n = Math.floor(i * Math.pow(2, 52)), o = Math.pow(2, 32), r = t << 31 | e + 1023 << 20 | n / o & 1048575, c = n % o; this.bufferBuilder.append(203), this.pack_int32(r), this.pack_int32(c); }; pt.prototype.pack_object = function(s) { var t = Object.keys(s), e = t.length; if (e <= 15) this.pack_uint8(128 + e); else if (e <= 65535) this.bufferBuilder.append(222), this.pack_uint16(e); else if (e <= 4294967295) this.bufferBuilder.append(223), this.pack_uint32(e); else throw new Error("Invalid length"); for (var i in s) s.hasOwnProperty(i) && (this.pack(i), this.pack(s[i])); }; pt.prototype.pack_uint8 = function(s) { this.bufferBuilder.append(s); }; pt.prototype.pack_uint16 = function(s) { this.bufferBuilder.append(s >> 8), this.bufferBuilder.append(s & 255); }; pt.prototype.pack_uint32 = function(s) { var t = s & 4294967295; this.bufferBuilder.append((t & 4278190080) >>> 24), this.bufferBuilder.append((t & 16711680) >>> 16), this.bufferBuilder.append((t & 65280) >>> 8), this.bufferBuilder.append(t & 255); }; pt.prototype.pack_uint64 = function(s) { var t = s / Math.pow(2, 32), e = s % Math.pow(2, 32); this.bufferBuilder.append((t & 4278190080) >>> 24), this.bufferBuilder.append((t & 16711680) >>> 16), this.bufferBuilder.append((t & 65280) >>> 8), this.bufferBuilder.append(t & 255), this.bufferBuilder.append((e & 4278190080) >>> 24), this.bufferBuilder.append((e & 16711680) >>> 16), this.bufferBuilder.append((e & 65280) >>> 8), this.bufferBuilder.append(e & 255); }; pt.prototype.pack_int8 = function(s) { this.bufferBuilder.append(s & 255); }; pt.prototype.pack_int16 = function(s) { this.bufferBuilder.append((s & 65280) >> 8), this.bufferBuilder.append(s & 255); }; pt.prototype.pack_int32 = function(s) { this.bufferBuilder.append(s >>> 24 & 255), this.bufferBuilder.append((s & 16711680) >>> 16), this.bufferBuilder.append((s & 65280) >>> 8), this.bufferBuilder.append(s & 255); }; pt.prototype.pack_int64 = function(s) { var t = Math.floor(s / Math.pow(2, 32)), e = s % Math.pow(2, 32); this.bufferBuilder.append((t & 4278190080) >>> 24), this.bufferBuilder.append((t & 16711680) >>> 16), this.bufferBuilder.append((t & 65280) >>> 8), this.bufferBuilder.append(t & 255), this.bufferBuilder.append((e & 4278190080) >>> 24), this.bufferBuilder.append((e & 16711680) >>> 16), this.bufferBuilder.append((e & 65280) >>> 8), this.bufferBuilder.append(e & 255); }; function wc(s) { var t = s.charCodeAt(0); return t <= 2047 ? "00" : t <= 65535 ? "000" : t <= 2097151 ? "0000" : t <= 67108863 ? "00000" : "000000"; } function Bc(s) { return s.length > 600 ? new Blob([s]).size : s.replace(/[^\u0000-\u007F]/g, wc).length; } const Bo = /* @__PURE__ */ bn(Qc); let nl = !0, ol = !0; function Ti(s, t, e) { const i = s.match(t); return i && i.length >= e && parseInt(i[e], 10); } function di(s, t, e) { if (!s.RTCPeerConnection) return; const i = s.RTCPeerConnection.prototype, n = i.addEventListener; i.addEventListener = function(r, c) { if (r !== t) return n.apply(this, arguments); const l = (a) => { const d = e(a); d && (c.handleEvent ? c.handleEvent(d) : c(d)); }; return this._eventMap = this._eventMap || {}, this._eventMap[t] || (this._eventMap[t] = /* @__PURE__ */ new Map()), this._eventMap[t].set(c, l), n.apply(this, [ r, l ]); }; const o = i.removeEventListener; i.removeEventListener = function(r, c) { if (r !== t || !this._eventMap || !this._eventMap[t]) return o.apply(this, arguments); if (!this._eventMap[t].has(c)) return o.apply(this, arguments); const l = this._eventMap[t].get(c); return this._eventMap[t].delete(c), this._eventMap[t].size === 0 && delete this._eventMap[t], Object.keys(this._eventMap).length === 0 && delete this._eventMap, o.apply(this, [ r, l ]); }, Object.defineProperty(i, "on" + t, { get() { return this["_on" + t]; }, set(r) { this["_on" + t] && (this.removeEventListener( t, this["_on" + t] ), delete this["_on" + t]), r && this.addEventListener( t, this["_on" + t] = r ); }, enumerable: !0, configurable: !0 }); } function Ec(s) { return typeof s != "boolean" ? new Error("Argument type: " + typeof s + ". Please use a boolean.") : (nl = s, s ? "adapter.js logging disabled" : "adapter.js logging enabled"); } function jc(s) { return typeof s != "boolean" ? new Error("Argument type: " + typeof s + ". Please use a boolean.") : (ol = !s, "adapter.js deprecation warnings " + (s ? "disabled" : "enabled")); } function Wo() { if (typeof window == "object") { if (nl) return; typeof console < "u" && typeof console.log == "function" && console.log.apply(console, arguments); } } function yn(s, t) { ol && console.warn(s + " is deprecated, please use " + t + " instead."); } function Oc(s) { const t = { browser: null, version: null }; if (typeof s > "u" || !s.navigator) return t.browser = "Not a browser.", t; const { navigator: e } = s; if (e.mozGetUserMedia) t.browser = "firefox", t.version = Ti( e.userAgent, /Firefox\/(\d+)\./, 1 ); else if (e.webkitGetUserMedia || s.isSecureContext === !1 && s.webkitRTCPeerConnection && !s.RTCIceGatherer) t.browser = "chrome", t.version = Ti( e.userAgent, /Chrom(e|ium)\/(\d+)\./, 2 ); else if (e.mediaDevices && e.userAgent.match(/Edge\/(\d+).(\d+)$/)) t.browser = "edge", t.version = Ti( e.userAgent, /Edge\/(\d+).(\d+)$/, 2 ); else if (s.RTCPeerConnection && e.userAgent.match(/AppleWebKit\/(\d+)\./)) t.browser = "safari", t.version = Ti( e.userAgent, /AppleWebKit\/(\d+)\./, 1 ), t.supportsUnifiedPlan = s.RTCRtpTransceiver && "currentDirection" in s.RTCRtpTransceiver.prototype; else return t.browser = "Not a supported browser.", t; return t; } function Eo(s) { return Object.prototype.toString.call(s) === "[object Object]"; } function rl(s) { return Eo(s) ? Object.keys(s).reduce(function(t, e) { const i = Eo(s[e]), n = i ? rl(s[e]) : s[e], o = i && !Object.keys(n).length; return n === void 0 || o ? t : Object.assign(t, { [e]: n }); }, {}) : s; } function qn(s, t, e) { !t || e.has(t.id) || (e.set(t.id, t), Object.keys(t).forEach((i) => { i.endsWith("Id") ? qn(s, s.get(t[i]), e) : i.endsWith("Ids") && t[i].forEach((n) => { qn(s, s.get(n), e); }); })); } function jo(s, t, e) { const i = e ? "outbound-rtp" : "inbound-rtp", n = /* @__PURE__ */ new Map(); if (t === null) return n; const o = []; return s.forEach((r) => { r.type === "track" && r.trackIdentifier === t.id && o.push(r); }), o.forEach((r) => { s.forEach((c) => { c.type === i && c.trackId === r.id && qn(s, c, n); }); }), n; } const Oo = Wo; function ll(s, t) { const e = s && s.navigator; if (!e.mediaDevices) return; const i = function(c) { if (typeof c != "object" || c.mandatory || c.optional) return c; const l = {}; return Object.keys(c).forEach((a) => { if (a === "require" || a === "advanced" || a === "mediaSource") return; const d = typeof c[a] == "object" ? c[a] : { ideal: c[a] }; d.exact !== void 0 && typeof d.exact == "number" && (d.min = d.max = d.exact); const h = function(u, p) { return u ? u + p.charAt(0).toUpperCase() + p.slice(1) : p === "deviceId" ? "sourceId" : p; }; if (d.ideal !== void 0) { l.optional = l.optional || []; let u = {}; typeof d.ideal == "number" ? (u[h("min", a)] = d.ideal, l.optional.push(u), u = {}, u[h("max", a)] = d.ideal, l.optional.push(u)) : (u[h("", a)] = d.ideal, l.optional.push(u)); } d.exact !== void 0 && typeof d.exact != "number" ? (l.mandatory = l.mandatory || {}, l.mandatory[h("", a)] = d.exact) : ["min", "max"].forEach((u) => { d[u] !== void 0 && (l.mandatory = l.mandatory || {}, l.mandatory[h(u, a)] = d[u]); }); }), c.advanced && (l.optional = (l.optional || []).concat(c.advanced)), l; }, n = function(c, l) { if (t.version >= 61) return l(c); if (c = JSON.parse(JSON.stringify(c)), c && typeof c.audio == "object") { const a = function(d, h, u) { h in d && !(u in d) && (d[u] = d[h], delete d[h]); }; c = JSON.parse(JSON.stringify(c)), a(c.audio, "autoGainControl", "googAutoGainControl"), a(c.audio, "noiseSuppression", "googNoiseSuppression"), c.audio = i(c.audio); } if (c && typeof c.video == "object") { let a = c.video.facingMode; a = a && (typeof a == "object" ? a : { ideal: a }); const d = t.version < 66; if (a && (a.exact === "user" || a.exact === "environment" || a.ideal === "user" || a.ideal === "environment") && !(e.mediaDevices.getSupportedConstraints && e.mediaDevices.getSupportedConstraints().facingMode && !d)) { delete c.video.facingMode; let h; if (a.exact === "environment" || a.ideal === "environment" ? h = ["back", "rear"] : (a.exact === "user" || a.ideal === "user") && (h = ["front"]), h) return e.mediaDevices.enumerateDevices().then((u) => { u = u.filter((m) => m.kind === "videoinput"); let p = u.find((m) => h.some((b) => m.label.toLowerCase().includes(b))); return !p && u.length && h.includes("back") && (p = u[u.length - 1]), p && (c.video.deviceId = a.exact ? { exact: p.deviceId } : { ideal: p.deviceId }), c.video = i(c.video), Oo("chrome: " + JSON.stringify(c)), l(c); }); } c.video = i(c.video); } return Oo("chrome: " + JSON.stringify(c)), l(c); }, o = function(c) { return t.version >= 64 ? c : { name: { PermissionDeniedError: "NotAllowedError", PermissionDismissedError: "NotAllowedError", InvalidStateError: "NotAllowedError", DevicesNotFoundError: "NotFoundError", ConstraintNotSatisfiedError: "OverconstrainedError", TrackStartError: "NotReadableError", MediaDeviceFailedDueToShutdown: "NotAllowedError", MediaDeviceKillSwitchOn: "NotAllowedError", TabCaptureError: "AbortError", ScreenCaptureError: "AbortError", DeviceCaptureError: "AbortError" }[c.name] || c.name, message: c.message, constraint: c.constraint || c.constraintName, toString() { return this.name + (this.message && ": ") + this.message; } }; }, r = function(c, l, a) { n(c, (d) => { e.webkitGetUserMedia(d, l, (h) => { a && a(o(h)); }); }); }; if (e.getUserMedia = r.bind(e), e.mediaDevices.getUserMedia) { const c = e.mediaDevices.getUserMedia.bind(e.mediaDevices); e.mediaDevices.getUserMedia = function(l) { return n(l, (a) => c(a).then((d) => { if (a.audio && !d.getAudioTracks().length || a.video && !d.getVideoTracks().length) throw d.getTracks().forE