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

11 lines • 406 kB
"use strict";const x=require("./three.umd.cjs"),st={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:.05,AxisTouchThreshold:.1,VisualResponseProperty:Object.freeze({TRANSFORM:"transform",VISIBILITY:"visibility"})};async function _o(r){const t=await fetch(r);if(t.ok)return t.json();throw new Error(t.statusText)}async function La(r){if(!r)throw new Error("No basePath supplied");return await _o(`${r}/profilesList.json`)}async function Va(r,t,e=null,i=!0){if(!r)throw new Error("No xrInputSource supplied");if(!t)throw new Error("No basePath supplied");const n=await La(t);let s;if(r.profiles.some(a=>{const l=n[a];return l&&(s={profileId:a,profilePath:`${t}/${l.path}`,deprecated:!!l.deprecated}),!!s}),!s){if(!e)throw new Error("No matching profile name found");const a=n[e];if(!a)throw new Error(`No matching profile name found and default profile "${e}" missing.`);s={profileId:e,profilePath:`${t}/${a.path}`,deprecated:!!a.deprecated}}const o=await _o(s.profilePath);let c;if(i){let a;if(r.handedness==="any"?a=o.layouts[Object.keys(o.layouts)[0]]:a=o.layouts[r.handedness],!a)throw new Error(`No matching handedness, ${r.handedness}, in profile ${s.profileId}`);a.assetPath&&(c=s.profilePath.replace("profile.json",a.assetPath))}return{profile:o,assetPath:c}}const Ja={xAxis:0,yAxis:0,button:0,state:st.ComponentState.DEFAULT};function Ga(r=0,t=0){let e=r,i=t;if(Math.sqrt(r*r+t*t)>1){const o=Math.atan2(t,r);e=Math.cos(o),i=Math.sin(o)}return{normalizedXAxis:e*.5+.5,normalizedYAxis:i*.5+.5}}class ja{constructor(t){this.componentProperty=t.componentProperty,this.states=t.states,this.valueNodeName=t.valueNodeName,this.valueNodeProperty=t.valueNodeProperty,this.valueNodeProperty===st.VisualResponseProperty.TRANSFORM&&(this.minNodeName=t.minNodeName,this.maxNodeName=t.maxNodeName),this.value=0,this.updateFromComponent(Ja)}updateFromComponent({xAxis:t,yAxis:e,button:i,state:n}){const{normalizedXAxis:s,normalizedYAxis:o}=Ga(t,e);switch(this.componentProperty){case st.ComponentProperty.X_AXIS:this.value=this.states.includes(n)?s:.5;break;case st.ComponentProperty.Y_AXIS:this.value=this.states.includes(n)?o:.5;break;case st.ComponentProperty.BUTTON:this.value=this.states.includes(n)?i:0;break;case st.ComponentProperty.STATE:this.valueNodeProperty===st.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 $a{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 ja(e.visualResponses[i]);this.visualResponses[i]=n}),this.gamepadIndices=Object.assign({},e.gamepadIndices),this.values={state:st.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}}updateFromGamepad(t){if(this.values.state=st.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=st.ComponentState.PRESSED:(e.touched||this.values.button>st.ButtonTouchThreshold)&&(this.values.state=st.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===st.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>st.AxisTouchThreshold&&(this.values.state=st.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===st.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>st.AxisTouchThreshold&&(this.values.state=st.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(e=>{e.updateFromComponent(this.values)})}}class Ha{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 s=this.layoutDescription.components[n];this.components[n]=new $a(n,s)}),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const t=[];return Object.values(this.components).forEach(e=>{t.push(e.data)}),t}updateFromGamepad(){Object.values(this.components).forEach(t=>{t.updateFromGamepad(this.xrInputSource.gamepad)})}}const on=2,jt=4,ee=4,bo=4,le=new Int32Array(2),ps=new Float32Array(le.buffer),ms=new Float64Array(le.buffer),lr=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;class re{constructor(t,e){this.low=t|0,this.high=e|0}static create(t,e){return t==0&&e==0?re.ZERO:new re(t,e)}toFloat64(){return(this.low>>>0)+this.high*4294967296}equals(t){return this.low==t.low&&this.high==t.high}}re.ZERO=new re(0,0);var Rn;(function(r){r[r.UTF8_BYTES=1]="UTF8_BYTES",r[r.UTF16_STRING=2]="UTF16_STRING"})(Rn||(Rn={}));class Pi{constructor(t){this.bytes_=t,this.position_=0}static allocate(t){return new Pi(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}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 re(this.readInt32(t),this.readInt32(t+4))}readUint64(t){return new re(this.readUint32(t),this.readUint32(t+4))}readFloat32(t){return le[0]=this.readInt32(t),ps[0]}readFloat64(t){return le[lr?0:1]=this.readInt32(t),le[lr?1:0]=this.readInt32(t+4),ms[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){ps[0]=e,this.writeInt32(t,le[0])}writeFloat64(t,e){ms[0]=e,this.writeInt32(t,le[lr?0:1]),this.writeInt32(t+4,le[lr?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+jt+ee)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let e=0;e<ee;e++)t+=String.fromCharCode(this.readInt8(this.position_+jt+e));return t}__offset(t,e){const i=t-this.readInt32(t);return e<this.readInt16(i)?this.readInt16(i+e):0}__union(t,e){return t.bb_pos=e+this.readInt32(e),t.bb=this,t}__string(t,e){t+=this.readInt32(t);const i=this.readInt32(t);let n="",s=0;if(t+=jt,e===Rn.UTF8_BYTES)return this.bytes_.subarray(t,t+i);for(;s<i;){let o;const c=this.readUint8(t+s++);if(c<192)o=c;else{const a=this.readUint8(t+s++);if(c<224)o=(c&31)<<6|a&63;else{const l=this.readUint8(t+s++);if(c<240)o=(c&15)<<12|(a&63)<<6|l&63;else{const u=this.readUint8(t+s++);o=(c&7)<<18|(a&63)<<12|(l&63)<<6|u&63}}}o<65536?n+=String.fromCharCode(o):(o-=65536,n+=String.fromCharCode((o>>10)+55296,(o&1024-1)+56320))}return n}__union_with_string(t,e){return typeof t=="string"?this.__string(e):this.__union(t,e)}__indirect(t){return t+this.readInt32(t)}__vector(t){return t+this.readInt32(t)+jt}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(t.length!=ee)throw new Error("FlatBuffers: file identifier must be length "+ee);for(let e=0;e<ee;e++)if(t.charCodeAt(e)!=this.readInt8(this.position()+jt+e))return!1;return!0}createLong(t,e){return re.create(t,e)}createScalarList(t,e){const i=[];for(let n=0;n<e;++n)t(n)!==null&&i.push(t(n));return i}createObjList(t,e){const i=[];for(let n=0;n<e;++n){const s=t(n);s!==null&&i.push(s.unpack())}return i}}class ts{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=Pi.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}forceDefaults(t){this.force_defaults=t}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}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=ts.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)}addInt8(t){this.prep(1,0),this.writeInt8(t)}addInt16(t){this.prep(2,0),this.writeInt16(t)}addInt32(t){this.prep(4,0),this.writeInt32(t)}addInt64(t){this.prep(8,0),this.writeInt64(t)}addFloat32(t){this.prep(4,0),this.writeFloat32(t)}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))}addFieldStruct(t,e,i){e!=i&&(this.nested(e),this.slot(t))}nested(t){if(t!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")}slot(t){this.vtable!==null&&(this.vtable[t]=this.offset())}offset(){return this.bb.capacity()-this.space}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=Pi.allocate(i);return n.setPosition(i-e),n.bytes().set(t.bytes(),i-e),n}addOffset(t){this.prep(jt,0),this.writeInt32(this.offset()-t+jt)}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()}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 s=(i+n)*on;this.addInt16(s);let o=0;const c=this.space;t:for(e=0;e<this.vtables.length;e++){const a=this.bb.capacity()-this.vtables[e];if(s==this.bb.readInt16(a)){for(let l=on;l<s;l+=on)if(this.bb.readInt16(c+l)!=this.bb.readInt16(a+l))continue t;o=this.vtables[e];break}}return o?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,o-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,e,i){const n=i?bo:0;if(e){const s=e;if(this.prep(this.minalign,jt+ee+n),s.length!=ee)throw new Error("FlatBuffers: file identifier must be length "+ee);for(let o=ee-1;o>=0;o--)this.writeInt8(s.charCodeAt(o))}this.prep(this.minalign,jt+n),this.addOffset(t),n&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}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")}startVector(t,e,i){this.notNested(),this.vector_num_elems=e,this.prep(jt,t*e),this.prep(i,t*e)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=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}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 s=t.charCodeAt(i++);if(s<55296||s>=56320)n=s;else{const o=t.charCodeAt(i++);n=(s<<10)+o+(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,s=this.bb.bytes();i<e.length;i++)s[n++]=e[i];return this.endVector()}createLong(t,e){return re.create(t,e)}createObjectOffset(t){return t===null?0:typeof t=="string"?this.createString(t):t.pack(this)}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 Qr(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var So={exports:{}};(function(r){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}}(),r.exports.binaryFeatures=t;var e=r.exports.BlobBuilder;typeof window<"u"&&(e=r.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,s=0,o=this._parts.length;s<o;s++)n.append(this._parts[s]);return n.getBlob()}else return new Blob(this._parts)},r.exports.BufferBuilder=i})(So);var To=So.exports,qa=To.BufferBuilder,ys=To.binaryFeatures,Xa={unpack:function(r){var t=new ht(r);return t.unpack()},pack:function(r){var t=new ft;t.pack(r);var e=t.getBuffer();return e}},Wa=Xa;function ht(r){this.index=0,this.dataBuffer=r,this.dataView=new Uint8Array(this.dataBuffer),this.length=this.dataBuffer.byteLength}ht.prototype.unpack=function(){var r=this.unpack_uint8();if(r<128)return r;if((r^224)<32)return(r^224)-32;var t;if((t=r^160)<=15)return this.unpack_raw(t);if((t=r^176)<=15)return this.unpack_string(t);if((t=r^144)<=15)return this.unpack_array(t);if((t=r^128)<=15)return this.unpack_map(t);switch(r){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)}};ht.prototype.unpack_uint8=function(){var r=this.dataView[this.index]&255;return this.index++,r};ht.prototype.unpack_uint16=function(){var r=this.read(2),t=(r[0]&255)*256+(r[1]&255);return this.index+=2,t};ht.prototype.unpack_uint32=function(){var r=this.read(4),t=((r[0]*256+r[1])*256+r[2])*256+r[3];return this.index+=4,t};ht.prototype.unpack_uint64=function(){var r=this.read(8),t=((((((r[0]*256+r[1])*256+r[2])*256+r[3])*256+r[4])*256+r[5])*256+r[6])*256+r[7];return this.index+=8,t};ht.prototype.unpack_int8=function(){var r=this.unpack_uint8();return r<128?r:r-256};ht.prototype.unpack_int16=function(){var r=this.unpack_uint16();return r<32768?r:r-65536};ht.prototype.unpack_int32=function(){var r=this.unpack_uint32();return r<Math.pow(2,31)?r:r-Math.pow(2,32)};ht.prototype.unpack_int64=function(){var r=this.unpack_uint64();return r<Math.pow(2,63)?r:r-Math.pow(2,64)};ht.prototype.unpack_raw=function(r){if(this.length<this.index+r)throw new Error("BinaryPackFailure: index is out of range "+this.index+" "+r+" "+this.length);var t=this.dataBuffer.slice(this.index,this.index+r);return this.index+=r,t};ht.prototype.unpack_string=function(r){for(var t=this.read(r),e=0,i="",n,s;e<r;)n=t[e],n<128?(i+=String.fromCharCode(n),e++):(n^192)<32?(s=(n^192)<<6|t[e+1]&63,i+=String.fromCharCode(s),e+=2):(s=(n&15)<<12|(t[e+1]&63)<<6|t[e+2]&63,i+=String.fromCharCode(s),e+=3);return this.index+=r,i};ht.prototype.unpack_array=function(r){for(var t=new Array(r),e=0;e<r;e++)t[e]=this.unpack();return t};ht.prototype.unpack_map=function(r){for(var t={},e=0;e<r;e++){var i=this.unpack(),n=this.unpack();t[i]=n}return t};ht.prototype.unpack_float=function(){var r=this.unpack_uint32(),t=r>>31,e=(r>>23&255)-127,i=r&8388607|8388608;return(t===0?1:-1)*i*Math.pow(2,e-23)};ht.prototype.unpack_double=function(){var r=this.unpack_uint32(),t=this.unpack_uint32(),e=r>>31,i=(r>>20&2047)-1023,n=r&1048575|1048576,s=n*Math.pow(2,i-20)+t*Math.pow(2,i-52);return(e===0?1:-1)*s};ht.prototype.read=function(r){var t=this.index;if(t+r<=this.length)return this.dataView.subarray(t,t+r);throw new Error("BinaryPackFailure: read index out of range")};function ft(){this.bufferBuilder=new qa}ft.prototype.getBuffer=function(){return this.bufferBuilder.getBuffer()};ft.prototype.pack=function(r){var t=typeof r;if(t==="string")this.pack_string(r);else if(t==="number")Math.floor(r)===r?this.pack_integer(r):this.pack_double(r);else if(t==="boolean")r===!0?this.bufferBuilder.append(195):r===!1&&this.bufferBuilder.append(194);else if(t==="undefined")this.bufferBuilder.append(192);else if(t==="object")if(r===null)this.bufferBuilder.append(192);else{var e=r.constructor;if(e==Array)this.pack_array(r);else if(e==Blob||e==File||r instanceof Blob||r instanceof File)this.pack_bin(r);else if(e==ArrayBuffer)ys.useArrayBufferView?this.pack_bin(new Uint8Array(r)):this.pack_bin(r);else if("BYTES_PER_ELEMENT"in r)ys.useArrayBufferView?this.pack_bin(new Uint8Array(r.buffer)):this.pack_bin(r.buffer);else if(e==Object||e.toString().startsWith("class"))this.pack_object(r);else if(e==Date)this.pack_string(r.toString());else if(typeof r.toBinaryPack=="function")this.bufferBuilder.append(r.toBinaryPack());else throw new Error('Type "'+e.toString()+'" not yet supported')}else throw new Error('Type "'+t+'" not yet supported');this.bufferBuilder.flush()};ft.prototype.pack_bin=function(r){var t=r.length||r.byteLength||r.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(r)};ft.prototype.pack_string=function(r){var t=Za(r);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(r)};ft.prototype.pack_array=function(r){var t=r.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(r[e])};ft.prototype.pack_integer=function(r){if(r>=-32&&r<=127)this.bufferBuilder.append(r&255);else if(r>=0&&r<=255)this.bufferBuilder.append(204),this.pack_uint8(r);else if(r>=-128&&r<=127)this.bufferBuilder.append(208),this.pack_int8(r);else if(r>=0&&r<=65535)this.bufferBuilder.append(205),this.pack_uint16(r);else if(r>=-32768&&r<=32767)this.bufferBuilder.append(209),this.pack_int16(r);else if(r>=0&&r<=4294967295)this.bufferBuilder.append(206),this.pack_uint32(r);else if(r>=-2147483648&&r<=2147483647)this.bufferBuilder.append(210),this.pack_int32(r);else if(r>=-9223372036854776e3&&r<=9223372036854776e3)this.bufferBuilder.append(211),this.pack_int64(r);else if(r>=0&&r<=18446744073709552e3)this.bufferBuilder.append(207),this.pack_uint64(r);else throw new Error("Invalid integer")};ft.prototype.pack_double=function(r){var t=0;r<0&&(t=1,r=-r);var e=Math.floor(Math.log(r)/Math.LN2),i=r/Math.pow(2,e)-1,n=Math.floor(i*Math.pow(2,52)),s=Math.pow(2,32),o=t<<31|e+1023<<20|n/s&1048575,c=n%s;this.bufferBuilder.append(203),this.pack_int32(o),this.pack_int32(c)};ft.prototype.pack_object=function(r){var t=Object.keys(r),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 r)r.hasOwnProperty(i)&&(this.pack(i),this.pack(r[i]))};ft.prototype.pack_uint8=function(r){this.bufferBuilder.append(r)};ft.prototype.pack_uint16=function(r){this.bufferBuilder.append(r>>8),this.bufferBuilder.append(r&255)};ft.prototype.pack_uint32=function(r){var t=r&4294967295;this.bufferBuilder.append((t&4278190080)>>>24),this.bufferBuilder.append((t&16711680)>>>16),this.bufferBuilder.append((t&65280)>>>8),this.bufferBuilder.append(t&255)};ft.prototype.pack_uint64=function(r){var t=r/Math.pow(2,32),e=r%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)};ft.prototype.pack_int8=function(r){this.bufferBuilder.append(r&255)};ft.prototype.pack_int16=function(r){this.bufferBuilder.append((r&65280)>>8),this.bufferBuilder.append(r&255)};ft.prototype.pack_int32=function(r){this.bufferBuilder.append(r>>>24&255),this.bufferBuilder.append((r&16711680)>>>16),this.bufferBuilder.append((r&65280)>>>8),this.bufferBuilder.append(r&255)};ft.prototype.pack_int64=function(r){var t=Math.floor(r/Math.pow(2,32)),e=r%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 Ya(r){var t=r.charCodeAt(0);return t<=2047?"00":t<=65535?"000":t<=2097151?"0000":t<=67108863?"00000":"000000"}function Za(r){return r.length>600?new Blob([r]).size:r.replace(/[^\u0000-\u007F]/g,Ya).length}const gs=Qr(Wa);let Mo=!0,Co=!0;function _i(r,t,e){const i=r.match(t);return i&&i.length>=e&&parseInt(i[e],10)}function Qe(r,t,e){if(!r.RTCPeerConnection)return;const i=r.RTCPeerConnection.prototype,n=i.addEventListener;i.addEventListener=function(o,c){if(o!==t)return n.apply(this,arguments);const a=l=>{const u=e(l);u&&(c.handleEvent?c.handleEvent(u):c(u))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(c,a),n.apply(this,[o,a])};const s=i.removeEventListener;i.removeEventListener=function(o,c){if(o!==t||!this._eventMap||!this._eventMap[t])return s.apply(this,arguments);if(!this._eventMap[t].has(c))return s.apply(this,arguments);const a=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,s.apply(this,[o,a])},Object.defineProperty(i,"on"+t,{get(){return this["_on"+t]},set(o){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),o&&this.addEventListener(t,this["_on"+t]=o)},enumerable:!0,configurable:!0})}function Qa(r){return typeof r!="boolean"?new Error("Argument type: "+typeof r+". Please use a boolean."):(Mo=r,r?"adapter.js logging disabled":"adapter.js logging enabled")}function Ka(r){return typeof r!="boolean"?new Error("Argument type: "+typeof r+". Please use a boolean."):(Co=!r,"adapter.js deprecation warnings "+(r?"disabled":"enabled"))}function es(){if(typeof window=="object"){if(Mo)return;typeof console<"u"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function Kr(r,t){Co&&console.warn(r+" is deprecated, please use "+t+" instead.")}function tc(r){const t={browser:null,version:null};if(typeof r>"u"||!r.navigator)return t.browser="Not a browser.",t;const{navigator:e}=r;if(e.mozGetUserMedia)t.browser="firefox",t.version=_i(e.userAgent,/Firefox\/(\d+)\./,1);else if(e.webkitGetUserMedia||r.isSecureContext===!1&&r.webkitRTCPeerConnection&&!r.RTCIceGatherer)t.browser="chrome",t.version=_i(e.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(e.mediaDevices&&e.userAgent.match(/Edge\/(\d+).(\d+)$/))t.browser="edge",t.version=_i(e.userAgent,/Edge\/(\d+).(\d+)$/,2);else if(r.RTCPeerConnection&&e.userAgent.match(/AppleWebKit\/(\d+)\./))t.browser="safari",t.version=_i(e.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=r.RTCRtpTransceiver&&"currentDirection"in r.RTCRtpTransceiver.prototype;else return t.browser="Not a supported browser.",t;return t}function vs(r){return Object.prototype.toString.call(r)==="[object Object]"}function wo(r){return vs(r)?Object.keys(r).reduce(function(t,e){const i=vs(r[e]),n=i?wo(r[e]):r[e],s=i&&!Object.keys(n).length;return n===void 0||s?t:Object.assign(t,{[e]:n})},{}):r}function kn(r,t,e){!t||e.has(t.id)||(e.set(t.id,t),Object.keys(t).forEach(i=>{i.endsWith("Id")?kn(r,r.get(t[i]),e):i.endsWith("Ids")&&t[i].forEach(n=>{kn(r,r.get(n),e)})}))}function xs(r,t,e){const i=e?"outbound-rtp":"inbound-rtp",n=new Map;if(t===null)return n;const s=[];return r.forEach(o=>{o.type==="track"&&o.trackIdentifier===t.id&&s.push(o)}),s.forEach(o=>{r.forEach(c=>{c.type===i&&c.trackId===o.id&&kn(r,c,n)})}),n}const _s=es;function Po(r,t){const e=r&&r.navigator;if(!e.mediaDevices)return;const i=function(c){if(typeof c!="object"||c.mandatory||c.optional)return c;const a={};return Object.keys(c).forEach(l=>{if(l==="require"||l==="advanced"||l==="mediaSource")return;const u=typeof c[l]=="object"?c[l]:{ideal:c[l]};u.exact!==void 0&&typeof u.exact=="number"&&(u.min=u.max=u.exact);const h=function(f,d){return f?f+d.charAt(0).toUpperCase()+d.slice(1):d==="deviceId"?"sourceId":d};if(u.ideal!==void 0){a.optional=a.optional||[];let f={};typeof u.ideal=="number"?(f[h("min",l)]=u.ideal,a.optional.push(f),f={},f[h("max",l)]=u.ideal,a.optional.push(f)):(f[h("",l)]=u.ideal,a.optional.push(f))}u.exact!==void 0&&typeof u.exact!="number"?(a.mandatory=a.mandatory||{},a.mandatory[h("",l)]=u.exact):["min","max"].forEach(f=>{u[f]!==void 0&&(a.mandatory=a.mandatory||{},a.mandatory[h(f,l)]=u[f])})}),c.advanced&&(a.optional=(a.optional||[]).concat(c.advanced)),a},n=function(c,a){if(t.version>=61)return a(c);if(c=JSON.parse(JSON.stringify(c)),c&&typeof c.audio=="object"){const l=function(u,h,f){h in u&&!(f in u)&&(u[f]=u[h],delete u[h])};c=JSON.parse(JSON.stringify(c)),l(c.audio,"autoGainControl","googAutoGainControl"),l(c.audio,"noiseSuppression","googNoiseSuppression"),c.audio=i(c.audio)}if(c&&typeof c.video=="object"){let l=c.video.facingMode;l=l&&(typeof l=="object"?l:{ideal:l});const u=t.version<66;if(l&&(l.exact==="user"||l.exact==="environment"||l.ideal==="user"||l.ideal==="environment")&&!(e.mediaDevices.getSupportedConstraints&&e.mediaDevices.getSupportedConstraints().facingMode&&!u)){delete c.video.facingMode;let h;if(l.exact==="environment"||l.ideal==="environment"?h=["back","rear"]:(l.exact==="user"||l.ideal==="user")&&(h=["front"]),h)return e.mediaDevices.enumerateDevices().then(f=>{f=f.filter(p=>p.kind==="videoinput");let d=f.find(p=>h.some(m=>p.label.toLowerCase().includes(m)));return!d&&f.length&&h.includes("back")&&(d=f[f.length-1]),d&&(c.video.deviceId=l.exact?{exact:d.deviceId}:{ideal:d.deviceId}),c.video=i(c.video),_s("chrome: "+JSON.stringify(c)),a(c)})}c.video=i(c.video)}return _s("chrome: "+JSON.stringify(c)),a(c)},s=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}}},o=function(c,a,l){n(c,u=>{e.webkitGetUserMedia(u,a,h=>{l&&l(s(h))})})};if(e.getUserMedia=o.bind(e),e.mediaDevices.getUserMedia){const c=e.mediaDevices.getUserMedia.bind(e.mediaDevices);e.mediaDevices.getUserMedia=function(a){return n(a,l=>c(l).then(u=>{if(l.audio&&!u.getAudioTracks().length||l.video&&!u.getVideoTracks().length)throw u.getTracks().forEach(h=>{h.stop()}),new DOMException("","NotFoundError");return u},u=>Promise.reject(s(u))))}}}function ec(r,t){if(!(r.navigator.mediaDevices&&"getDisplayMedia"in r.navigator.mediaDevices)&&r.navigator.mediaDevices){if(typeof t!="function"){console.error("shimGetDisplayMedia: getSourceId argument is not a function");return}r.navigator.mediaDevices.getDisplayMedia=function(i){return t(i).then(n=>{const s=i.video&&i.video.width,o=i.video&&i.video.height,c=i.video&&i.video.frameRate;return i.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:n,maxFrameRate:c||3}},s&&(i.video.mandatory.maxWidth=s),o&&(i.video.mandatory.maxHeight=o),r.navigator.mediaDevices.getUserMedia(i)})}}}function Eo(r){r.MediaStream=r.MediaStream||r.webkitMediaStream}function Ao(r){if(typeof r=="object"&&r.RTCPeerConnection&&!("ontrack"in r.RTCPeerConnection.prototype)){Object.defineProperty(r.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});const t=r.RTCPeerConnection.prototype.setRemoteDescription;r.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=i=>{i.stream.addEventListener("addtrack",n=>{let s;r.RTCPeerConnection.prototype.getReceivers?s=this.getReceivers().find(c=>c.track&&c.track.id===n.track.id):s={track:n.track};const o=new Event("track");o.track=n.track,o.receiver=s,o.transceiver={receiver:s},o.streams=[i.stream],this.dispatchEvent(o)}),i.stream.getTracks().forEach(n=>{let s;r.RTCPeerConnection.prototype.getReceivers?s=this.getReceivers().find(c=>c.track&&c.track.id===n.id):s={track:n};const o=new Event("track");o.track=n,o.receiver=s,o.transceiver={receiver:s},o.streams=[i.stream],this.dispatchEvent(o)})},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else Qe(r,"track",t=>(t.transceiver||Object.defineProperty(t,"transceiver",{value:{receiver:t.receiver}}),t))}function Ro(r){if(typeof r=="object"&&r.RTCPeerConnection&&!("getSenders"in r.RTCPeerConnection.prototype)&&"createDTMFSender"in r.RTCPeerConnection.prototype){const t=function(n,s){return{track:s,get dtmf(){return this._dtmf===void 0&&(s.kind==="audio"?this._dtmf=n.createDTMFSender(s):this._dtmf=null),this._dtmf},_pc:n}};if(!r.RTCPeerConnection.prototype.getSenders){r.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const n=r.RTCPeerConnection.prototype.addTrack;r.RTCPeerConnection.prototype.addTrack=function(c,a){let l=n.apply(this,arguments);return l||(l=t(this,c),this._senders.push(l)),l};const s=r.RTCPeerConnection.prototype.removeTrack;r.RTCPeerConnection.prototype.removeTrack=function(c){s.apply(this,arguments);const a=this._senders.indexOf(c);a!==-1&&this._senders.splice(a,1)}}const e=r.RTCPeerConnection.prototype.addStream;r.RTCPeerConnection.prototype.addStream=function(s){this._senders=this._senders||[],e.apply(this,[s]),s.getTracks().forEach(o=>{this._senders.push(t(this,o))})};const i=r.RTCPeerConnection.prototype.removeStream;r.RTCPeerConnection.prototype.removeStream=function(s){this._senders=this._senders||[],i.apply(this,[s]),s.getTracks().forEach(o=>{const c=this._senders.find(a=>a.track===o);c&&this._senders.splice(this._senders.indexOf(c),1)})}}else if(typeof r=="object"&&r.RTCPeerConnection&&"getSenders"in r.RTCPeerConnection.prototype&&"createDTMFSender"in r.RTCPeerConnection.prototype&&r.RTCRtpSender&&!("dtmf"in r.RTCRtpSender.prototype)){const t=r.RTCPeerConnection.prototype.getSenders;r.RTCPeerConnection.prototype.getSenders=function(){const i=t.apply(this,[]);return i.forEach(n=>n._pc=this),i},Object.defineProperty(r.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function ko(r){if(!r.RTCPeerConnection)return;const t=r.RTCPeerConnection.prototype.getStats;r.RTCPeerConnection.prototype.getStats=function(){const[i,n,s]=arguments;if(arguments.length>0&&typeof i=="function")return t.apply(this,arguments);if(t.length===0&&(arguments.length===0||typeof i!="function"))return t.apply(this,[]);const o=function(a){const l={};return a.result().forEach(h=>{const f={id:h.id,timestamp:h.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[h.type]||h.type};h.names().forEach(d=>{f[d]=h.stat(d)}),l[f.id]=f}),l},c=function(a){return new Map(Object.keys(a).map(l=>[l,a[l]]))};if(arguments.length>=2){const a=function(l){n(c(o(l)))};return t.apply(this,[a,i])}return new Promise((a,l)=>{t.apply(this,[function(u){a(c(o(u)))},l])}).then(n,s)}}function Bo(r){if(!(typeof r=="object"&&r.RTCPeerConnection&&r.RTCRtpSender&&r.RTCRtpReceiver))return;if(!("getStats"in r.RTCRtpSender.prototype)){const e=r.RTCPeerConnection.prototype.getSenders;e&&(r.RTCPeerConnection.prototype.getSenders=function(){const s=e.apply(this,[]);return s.forEach(o=>o._pc=this),s});const i=r.RTCPeerConnection.prototype.addTrack;i&&(r.RTCPeerConnection.prototype.addTrack=function(){const s=i.apply(this,arguments);return s._pc=this,s}),r.RTCRtpSender.prototype.getStats=function(){const s=this;return this._pc.getStats().then(o=>xs(o,s.track,!0))}}if(!("getStats"in r.RTCRtpReceiver.prototype)){const e=r.RTCPeerConnection.prototype.getReceivers;e&&(r.RTCPeerConnection.prototype.getReceivers=function(){const n=e.apply(this,[]);return n.forEach(s=>s._pc=this),n}),Qe(r,"track",i=>(i.receiver._pc=i.srcElement,i)),r.RTCRtpReceiver.prototype.getStats=function(){const n=this;return this._pc.getStats().then(s=>xs(s,n.track,!1))}}if(!("getStats"in r.RTCRtpSender.prototype&&"getStats"in r.RTCRtpReceiver.prototype))return;const t=r.RTCPeerConnection.prototype.getStats;r.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof r.MediaStreamTrack){const i=arguments[0];let n,s,o;return this.getSenders().forEach(c=>{c.track===i&&(n?o=!0:n=c)}),this.getReceivers().forEach(c=>(c.track===i&&(s?o=!0:s=c),c.track===i)),o||n&&s?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):n?n.getStats():s?s.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function zo(r){r.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(o=>this._shimmedLocalStreams[o][0])};const t=r.RTCPeerConnection.prototype.addTrack;r.RTCPeerConnection.prototype.addTrack=function(o,c){if(!c)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const a=t.apply(this,arguments);return this._shimmedLocalStreams[c.id]?this._shimmedLocalStreams[c.id].indexOf(a)===-1&&this._shimmedLocalStreams[c.id].push(a):this._shimmedLocalStreams[c.id]=[c,a],a};const e=r.RTCPeerConnection.prototype.addStream;r.RTCPeerConnection.prototype.addStream=function(o){this._shimmedLocalStreams=this._shimmedLocalStreams||{},o.getTracks().forEach(l=>{if(this.getSenders().find(h=>h.track===l))throw new DOMException("Track already exists.","InvalidAccessError")});const c=this.getSenders();e.apply(this,arguments);const a=this.getSenders().filter(l=>c.indexOf(l)===-1);this._shimmedLocalStreams[o.id]=[o].concat(a)};const i=r.RTCPeerConnection.prototype.removeStream;r.RTCPeerConnection.prototype.removeStream=function(o){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[o.id],i.apply(this,arguments)};const n=r.RTCPeerConnection.prototype.removeTrack;r.RTCPeerConnection.prototype.removeTrack=function(o){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},o&&Object.keys(this._shimmedLocalStreams).forEach(c=>{const a=this._shimmedLocalStreams[c].indexOf(o);a!==-1&&this._shimmedLocalStreams[c].splice(a,1),this._shimmedLocalStreams[c].length===1&&delete this._shimmedLocalStreams[c]}),n.apply(this,arguments)}}function Oo(r,t){if(!r.RTCPeerConnection)return;if(r.RTCPeerConnection.prototype.addTrack&&t.version>=65)return zo(r);const e=r.RTCPeerConnection.prototype.getLocalStreams;r.RTCPeerConnection.prototype.getLocalStreams=function(){const u=e.apply(this);return this._reverseStreams=this._reverseStreams||{},u.map(h=>this._reverseStreams[h.id])};const i=r.RTCPeerConnection.prototype.addStream;r.RTCPeerConnection.prototype.addStream=function(u){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},u.getTracks().forEach(h=>{if(this.getSenders().find(d=>d.track===h))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[u.id]){const h=new r.MediaStream(u.getTracks());this._streams[u.id]=h,this._reverseStreams[h.id]=u,u=h}i.apply(this,[u])};const n=r.RTCPeerConnection.prototype.removeStream;r.RTCPeerConnection.prototype.removeStream=function(u){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},n.apply(this,[this._streams[u.id]||u]),delete this._reverseStreams[this._streams[u.id]?this._streams[u.id].id:u.id],delete this._streams[u.id]},r.RTCPeerConnection.prototype.addTrack=function(u,h){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const f=[].slice.call(arguments,1);if(f.length!==1||!f[0].getTracks().find(m=>m===u))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find(m=>m.track===u))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const p=this._streams[h.id];if(p)p.addTrack(u),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const m=new r.MediaStream([u]);this._streams[h.id]=m,this._reverseStreams[m.id]=h,this.addStream(m)}return this.getSenders().find(m=>m.track===u)};function s(l,u){let h=u.sdp;return Object.keys(l._reverseStreams||[]).forEach(f=>{const d=l._reverseStreams[f],p=l._streams[d.id];h=h.replace(new RegExp(p.id,"g"),d.id)}),new RTCSessionDescription({type:u.type,sdp:h})}function o(l,u){let h=u.sdp;return Object.keys(l._reverseStreams||[]).forEach(f=>{const d=l._reverseStreams[f],p=l._streams[d.id];h=h.replace(new RegExp(d.id,"g"),p.id)}),new RTCSessionDescription({type:u.type,sdp:h})}["createOffer","createAnswer"].forEach(function(l){const u=r.RTCPeerConnection.prototype[l],h={[l](){const f=arguments;return arguments.length&&typeof arguments[0]=="function"?u.apply(this,[p=>{const m=s(this,p);f[0].apply(null,[m])},p=>{f[1]&&f[1].apply(null,p)},arguments[2]]):u.apply(this,arguments).then(p=>s(this,p))}};r.RTCPeerConnection.prototype[l]=h[l]});const c=r.RTCPeerConnection.prototype.setLocalDescription;r.RTCPeerConnection.prototype.setLocalDescription=function(){return!arguments.length||!arguments[0].type?c.apply(this,arguments):(arguments[0]=o(this,arguments[0]),c.apply(this,arguments))};const a=Object.getOwnPropertyDescriptor(r.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(r.RTCPeerConnection.prototype,"localDescription",{get(){const l=a.get.apply(this);return l.type===""?l:s(this,l)}}),r.RTCPeerConnection.prototype.removeTrack=function(u){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!u._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(u._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};let f;Object.keys(this._streams).forEach(d=>{this._streams[d].getTracks().find(m=>u.track===m)&&(f=this._streams[d])}),f&&(f.getTracks().length===1?this.removeStream(this._reverseStreams[f.id]):f.removeTrack(u.track),this.dispatchEvent(new Event("negotiationneeded")))}}function Bn(r,t){!r.RTCPeerConnection&&r.webkitRTCPeerConnection&&(r.RTCPeerConnection=r.webkitRTCPeerConnection),r.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(e){const i=r.RTCPeerConnection.prototype[e],n={[e](){return arguments[0]=new(e==="addIceCandidate"?r.RTCIceCandidate:r.RTCSessionDescription)(arguments[0]),i.apply(this,arguments)}};r.RTCPeerConnection.prototype[e]=n[e]})}function Io(r,t){Qe(r,"negotiationneeded",e=>{const i=e.target;if(!((t.version<72||i.getConfiguration&&i.getConfiguration().sdpSemantics==="plan-b")&&i.signalingState!=="stable"))return e})}const bs=Object.freeze(Object.defineProperty({__proto__:null,fixNegotiationNeeded:Io,shimAddTrackRemoveTrack:Oo,shimAddTrackRemoveTrackWithNative:zo,shimGetDisplayMedia:ec,shimGetSendersWithDtmf:Ro,shimGetStats:ko,shimGetUserMedia:Po,shimMediaStream:Eo,shimOnTrack:Ao,shimPeerConnection:Bn,shimSenderReceiverGetStats:Bo},Symbol.toStringTag,{value:"Module"}));function ic(r,t){let e=!1;return r=JSON.parse(JSON.stringify(r)),r.filter(i=>{if(i&&(i.urls||i.url)){let n=i.urls||i.url;i.url&&!i.urls&&Kr("RTCIceServer.url","RTCIceServer.urls");const s=typeof n=="string";return s&&(n=[n]),n=n.filter(o=>{if(o.indexOf("stun:")===0)return!1;const c=o.startsWith("turn")&&!o.startsWith("turn:[")&&o.includes("transport=udp");return c&&!e?(e=!0,!0):c&&!e}),delete i.url,i.urls=s?n[0]:n,!!n.length}})}var No={exports:{}};(function(r){var t={};t.generateIdentifier=function(){return Math.random().toString(36).substr(2,10)},t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split(` `).map(function(i){return i.trim()})},t.splitSections=function(e){var i=e.split(` m=`);return i.map(function(n,s){return(s>0?"m="+n:n).trim()+`\r `})},t.getDescription=function(e){var i=t.splitSections(e);return i&&i[0]},t.getMediaSections=function(e){var i=t.splitSections(e);return i.shift(),i},t.matchPrefix=function(e,i){return t.splitLines(e).filter(function(n){return n.indexOf(i)===0})},t.parseCandidate=function(e){var i;e.indexOf("a=candidate:")===0?i=e.substring(12).split(" "):i=e.substring(10).split(" ");for(var n={foundation:i[0],component:parseInt(i[1],10),protocol:i[2].toLowerCase(),priority:parseInt(i[3],10),ip:i[4],address:i[4],port:parseInt(i[5],10),type:i[7]},s=8;s<i.length;s+=2)switch(i[s]){case"raddr":n.relatedAddress=i[s+1];break;case"rport":n.relatedPort=parseInt(i[s+1],10);break;case"tcptype":n.tcpType=i[s+1];break;case"ufrag":n.ufrag=i[s+1],n.usernameFragment=i[s+1];break;default:n[i[s]]=i[s+1];break}return n},t.writeCandidate=function(e){var i=[];i.push(e.foundation),i.push(e.component),i.push(e.protocol.toUpperCase()),i.push(e.priority),i.push(e.address||e.ip),i.push(e.port);var n=e.type;return i.push("typ"),i.push(n),n!=="host"&&e.relatedAddress&&e.relatedPort&&(i.push("raddr"),i.push(e.relatedAddress),i.push("rport"),i.push(e.relatedPort)),e.tcpType&&e.protocol.toLowerCase()==="tcp"&&(i.push("tcptype"),i.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(i.push("ufrag"),i.push(e.usernameFragment||e.ufrag)),"candidate:"+i.join(" ")},t.parseIceOptions=function(e){return e.substr(14).split(" ")},t.parseRtpMap=function(e){var i=e.substr(9).split(" "),n={payloadType:parseInt(i.shift(),10)};return i=i[0].split("/"),n.name=i[0],n.clockRate=parseInt(i[1],10),n.channels=i.length===3?parseInt(i[2],10):1,n.numChannels=n.channels,n},t.writeRtpMap=function(e){var i=e.payloadType;e.preferredPayloadType!==void 0&&(i=e.preferredPayloadType);var n=e.channels||e.numChannels||1;return"a=rtpmap:"+i+" "+e.name+"/"+e.clockRate+(n!==1?"/"+n:"")+`\r `},t.parseExtmap=function(e){var i=e.substr(9).split(" ");return{id:parseInt(i[0],10),direction:i[0].indexOf("/")>0?i[0].split("/")[1]:"sendrecv",uri:i[1]}},t.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&e.direction!=="sendrecv"?"/"+e.direction:"")+" "+e.uri+`\r `},t.parseFmtp=function(e){for(var i={},n,s=e.substr(e.indexOf(" ")+1).split(";"),o=0;o<s.length;o++)n=s[o].trim().split("="),i[n[0].trim()]=n[1];return i},t.writeFmtp=function(e){var i="",n=e.payloadType;if(e.preferredPayloadType!==void 0&&(n=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){var s=[];Object.keys(e.parameters).forEach(function(o){e.parameters[o]?s.push(o+"="+e.parameters[o]):s.push(o)}),i+="a=fmtp:"+n+" "+s.join(";")+`\r `}return i},t.parseRtcpFb=function(e){var i=e.substr(e.indexOf(" ")+1).split(" ");return{type:i.shift(),parameter:i.join(" ")}},t.writeRtcpFb=function(e){var i="",n=e.payloadType;return e.preferredPayloadType!==void 0&&(n=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach(function(s){i+="a=rtcp-fb:"+n+" "+s.type+(s.parameter&&s.parameter.length?" "+s.parameter:"")+`\r `}),i},t.parseSsrcMedia=function(e){var i=e.indexOf(" "),n={ssrc:parseInt(e.substr(7,i-7),10)},s=e.indexOf(":",i);return s>-1?(n.attribute=e.substr(i+1,s-i-1),n.value=e.substr(s+1)):n.attribute=e.substr(i+1),n},t.parseSsrcGroup=function(e){var i=e.substr(13).split(" ");return{semantics:i.shift(),ssrcs:i.map(function(n){return parseInt(n,10)})}},t.getMid=function(e){var i=t.matchPrefix(e,"a=mid:")[0];if(i)return i.substr(6)},t.parseFingerprint=function(e){var i=e.substr(14).split(" ");return{algorithm:i[0].toLowerCase(),value:i[1]}},t.getDtlsParameters=function(e,i){var n=t.matchPrefix(e+i,"a=fingerprint:");return{role:"auto",fingerprints:n.map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,i){var n="a=setup:"+i+`\r `;return e.fingerprints.forEach(function(s){n+="a=fingerprint:"+s.algorithm+" "+s.value+`\r `}),n},t.parseCryptoLine=function(e){var i=e.substr(9).split(" ");return{tag:parseInt(i[0],10),cryptoSuite:i[1],keyParams:i[2],sessionParams:i.slice(3)}},t.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+(typeof e.keyParams=="object"?t.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+`\r `},t.parseCryptoKeyParams=function(e){if(e.indexOf("inline:")!==0)return null;var i=e.substr(7).split("|");return{keyMethod:"inline",keySalt:i[0],lifeTime:i[1],mkiValue:i[2]?i[2].split(":")[0]:void 0,mkiLength:i[2]?i[2].split(":")[1]:void 0}},t.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},t.getCryptoParameters=function(e,i){var n=t.matchPrefix(e+i,"a=crypto:");return n.map(t.parseCryptoL