@ikonai/sdk-ui 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ const e={None:0,SendBackToSender:1,Delayable:2,SendToUser:4,Compressed:8,Unreliable:16};function t(e){return e}function n(e){if(e.length<8)throw Error(`Protocol message too short`);return(e[4]|e[5]<<8|e[6]<<16|e[7]<<24)>>>0}function r(e){let t=S(e),n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(t.length<27)throw Error(`Protocol payload too short`);let r=n.getUint32(0,!0),i=n.getUint32(4,!0),a=n.getUint32(8,!0),o=n.getUint32(12,!0),s=n.getUint32(16,!0),c=n.getUint32(20,!0),l=n.getUint8(24),u=n.getUint8(25),d=n.getUint8(26);if(27+c*4>t.length)throw Error(`Protocol header exceeds payload length`);let f=[],p=27;for(let e=0;e<c;e++)f.push(n.getUint32(p,!0)),p+=4;return{length:r,opcode:i,senderId:a,trackId:o,sequenceId:s,targetIds:f,payloadVersion:l,payloadType:u,flags:d}}async function i(t,n,i){let o=S(t),s=r(o);if(n!==void 0&&s.opcode!==n)throw Error(`Unexpected opcode ${s.opcode}`);if(s.payloadType!==8)throw Error(`Unexpected payload type ${s.payloadType}`);let c=27+s.targetIds.length*4,l=o.subarray(c,s.length);return(s.flags&e.Compressed)!==0&&(l=await a(l)),l}async function a(e){if(typeof DecompressionStream>`u`)throw Error(`DecompressionStream not supported`);let t=new DecompressionStream(`gzip`),n=t.writable.getWriter(),r=new Uint8Array(e);n.write(r).then(()=>n.close()).catch(()=>void 0);let i=t.readable.getReader(),a=[],o=0;for(;;){let{done:e,value:t}=await i.read();if(e)break;a.push(t),o+=t.length}let s=new Uint8Array(o),c=0;for(let e=0;e<a.length;e++)s.set(a[e],c),c+=a[e].length;return s}let o=function(e){return e[e.Null=1]=`Null`,e[e.Bool=2]=`Bool`,e[e.Int32=3]=`Int32`,e[e.Int64=4]=`Int64`,e[e.UInt32=5]=`UInt32`,e[e.UInt64=6]=`UInt64`,e[e.Float32=7]=`Float32`,e[e.Float64=8]=`Float64`,e[e.Array=9]=`Array`,e[e.Dict=10]=`Dict`,e[e.Object=11]=`Object`,e[e.String=12]=`String`,e[e.Binary=13]=`Binary`,e[e.Guid=14]=`Guid`,e}({});new TextEncoder;const s=new TextDecoder(`utf-8`,{fatal:!0});var c=class e{buffer;version;offset;end;constructor(e,t,n){this.buffer=e,this.version=t,this.offset=n,this.end=e.length-1}static create(t){let n=S(t);if(n.length<2)throw Error(`Teleport payload too short`);if(n[0]!==161||n[n.length-1]!==162)throw Error(`Teleport object missing markers`);let r={offset:1},i=g(n,r,`InvalidLength`);return new e(n,i,r.offset)}next(){if(this.offset>=this.end)return null;if(this.offset+5>this.buffer.length)throw Error(`Teleport object truncated`);let e=ne(this.buffer,this.offset);this.offset+=4;let t=this.buffer[this.offset++],n=t>>4&15;if(t&15)throw Error(`Teleport field flags must be zero`);let r=_(n),i;if(r>=0)v(this.buffer,this.offset,r),i=this.buffer.subarray(this.offset,this.offset+r),this.offset+=r;else{let e={offset:this.offset},t=g(this.buffer,e,`InvalidLength`);v(this.buffer,e.offset,t),i=this.buffer.subarray(e.offset,e.offset+t),this.offset=e.offset+t}return new u(e,n,i)}},l=class{type;payload;constructor(e,t){this.type=e,this.payload=t}asInt32(){return this.ensureType(3),new DataView(this.payload.buffer,this.payload.byteOffset,4).getInt32(0,!0)}asUInt32(){return this.ensureType(5),new DataView(this.payload.buffer,this.payload.byteOffset,4).getUint32(0,!0)}asInt64(){return this.ensureType(4),new DataView(this.payload.buffer,this.payload.byteOffset,8).getBigInt64(0,!0)}asUInt64(){return this.ensureType(6),new DataView(this.payload.buffer,this.payload.byteOffset,8).getBigUint64(0,!0)}asFloat32(){return this.ensureType(7),new DataView(this.payload.buffer,this.payload.byteOffset,4).getFloat32(0,!0)}asFloat64(){return this.ensureType(8),new DataView(this.payload.buffer,this.payload.byteOffset,8).getFloat64(0,!0)}asBool(){return this.ensureType(2),this.payload.length>0&&this.payload[0]!==0}asBinary(){return this.ensureType(13),this.payload}asUtf8(){return this.ensureType(12),this.payload}asString(){return this.ensureType(12),s.decode(this.payload)}asGuid(){return this.ensureType(14),h.fromBytes(this.payload)}asObject(){return this.ensureType(11),c.create(this.payload)}asArray(){return this.ensureType(9),d.create(this.payload)}asDictionary(){return this.ensureType(10),p.create(this.payload)}ensureType(e){if(this.type!==e)throw Error(`Teleport value has type ${o[this.type]}, expected ${o[e]}`)}},u=class extends l{fieldId;constructor(e,t,n){super(t,n),this.fieldId=e}get isNull(){return this.type===1}},d=class e{payload;elementType;count;offset;index=0;constructor(e){if(this.payload=e,e.length===0)throw Error(`Array payload too short`);let t=e[0];if(this.elementType=t>>4&15,t&15)throw Error(`Array flags must be zero`);let n={offset:1};this.count=g(e,n,`ArrayMalformed`),this.offset=n.offset}static create(t){return new e(S(t))}next(){if(this.index>=this.count){if(this.offset!==this.payload.length)throw Error(`Array payload contains trailing data`);return null}let e=this.readValue();return this.index++,e}readValue(){switch(this.elementType){case 3:case 5:case 7:case 8:case 2:case 4:case 6:case 14:{let e=_(this.elementType);v(this.payload,this.offset,e);let t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new f(this.elementType,t)}case 12:case 13:{let e={offset:this.offset},t=g(this.payload,e,`ArrayMalformed`);v(this.payload,e.offset,t);let n=this.payload.subarray(e.offset,e.offset+t);return this.offset=e.offset+t,new f(this.elementType,n)}case 11:{let e={offset:this.offset},t=g(this.payload,e,`ArrayMalformed`);v(this.payload,e.offset,t);let n=this.payload.subarray(e.offset,e.offset+t);return this.offset=e.offset+t,new f(11,n)}case 9:{let e=y(this.payload,this.offset),t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new f(9,t)}case 10:{let e=b(this.payload,this.offset),t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new f(10,t)}default:throw Error(`Unsupported array element type ${o[this.elementType]}`)}}},f=class extends l{constructor(e,t){super(e,t)}},p=class e{payload;keyType;valueType;count;offset;index=0;constructor(e){if(this.payload=e,e.length<2)throw Error(`Dictionary payload too short`);if(this.keyType=e[0]>>4&15,this.valueType=e[1]>>4&15,e[0]&15||e[1]&15)throw Error(`Dictionary key/value flags must be zero`);te(this.keyType);let t={offset:2};this.count=g(e,t,`DictMalformed`),this.offset=t.offset}static create(t){return new e(S(t))}next(){if(this.index>=this.count){if(this.offset!==this.payload.length)throw Error(`Dictionary payload contains trailing data`);return null}let e=this.readKey(),t=this.readValue();return this.index++,new m(e,t)}readKey(){let e=_(this.keyType);if(e>=0){v(this.payload,this.offset,e);let t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new l(this.keyType,t)}if(this.keyType===12||this.keyType===13){let e={offset:this.offset},t=g(this.payload,e,`DictMalformed`);v(this.payload,e.offset,t);let n=this.payload.subarray(e.offset,e.offset+t);return this.offset=e.offset+t,new l(this.keyType,n)}throw Error(`Unsupported dictionary key type`)}readValue(){switch(this.valueType){case 12:case 13:{let e={offset:this.offset},t=g(this.payload,e,`DictMalformed`);v(this.payload,e.offset,t);let n=this.payload.subarray(e.offset,e.offset+t);return this.offset=e.offset+t,new l(this.valueType,n)}case 11:{let e={offset:this.offset},t=g(this.payload,e,`DictMalformed`);v(this.payload,e.offset,t);let n=this.payload.subarray(e.offset,e.offset+t);return this.offset=e.offset+t,new l(11,n)}case 9:{let e=y(this.payload,this.offset),t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new l(9,t)}case 10:{let e=b(this.payload,this.offset),t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new l(10,t)}case 3:case 5:case 7:case 8:case 2:case 4:case 6:case 14:case 1:{let e=_(this.valueType);v(this.payload,this.offset,e);let t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new l(this.valueType,t)}default:throw Error(`Unsupported dictionary value type ${o[this.valueType]}`)}}},m=class{key;value;constructor(e,t){this.key=e,this.value=t}},h=class e{bytes;constructor(e){this.bytes=e}static fromString(t){if(!t)throw Error(`Guid string is empty`);let n=t.replace(/-/g,``);if(n.length!==32)throw Error(`Guid string must be 32 hex characters`);let r=new Uint8Array(16),i=e.parseHexSlice(n,0,8),a=e.parseHexSlice(n,8,4),o=e.parseHexSlice(n,12,4);e.writeUInt32LE(r,0,i),e.writeUInt16LE(r,4,a),e.writeUInt16LE(r,6,o);for(let t=0;t<8;t++)r[8+t]=e.parseHexSlice(n,16+t*2,2);return new e(r)}static fromBytes(t){if(t.length!==16)throw Error(`Guid byte array must be 16 bytes`);return new e(Uint8Array.from(t))}static createZero(){return new e(new Uint8Array(16))}static createRandom(){let t=new Uint8Array(16),n=globalThis.crypto;if(n?.getRandomValues)n.getRandomValues(t);else for(let e=0;e<t.length;e++)t[e]=Math.floor(Math.random()*256);return t[6]=t[6]&15|64,t[8]=t[8]&63|128,new e(t)}toString(){let t=this.bytes;return[e.toHex(e.readUInt32LE(t,0),8),e.toHex(e.readUInt16LE(t,4),4),e.toHex(e.readUInt16LE(t,6),4),re(t.subarray(8,10)),re(t.subarray(10,16))].join(`-`)}asBytes(){return this.bytes.slice()}static parseHexSlice(e,t,n){let r=e.substr(t,n),i=Number.parseInt(r,16);if(Number.isNaN(i))throw Error(`Guid string contains invalid characters`);return i>>>0}static writeUInt32LE(e,t,n){let r=n>>>0;e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24&255}static writeUInt16LE(e,t,n){let r=n&65535;e[t]=r&255,e[t+1]=r>>>8&255}static readUInt32LE(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}static readUInt16LE(e,t){return(e[t]|e[t+1]<<8)&65535}static toHex(e,t){return(e>>>0).toString(16).padStart(t,`0`)}};function g(e,t,n){if(t.offset>=e.length)throw Error(n);let r=0,i=0,a=0;for(;t.offset<e.length;){let n=e[t.offset++];if(a++,r|=(n&127)<<i,!(n&128)){if(a!==ee(r))throw Error(`Teleport VarUInt is not canonical`);return r>>>0}if(i+=7,i>=35)throw Error(`Teleport VarUInt exceeds 32-bit range`)}throw Error(n)}function ee(e){return e<128?1:e<16384?2:e<2097152?3:e<268435456?4:5}function _(e){switch(e){case 3:case 5:case 7:return 4;case 4:case 6:case 8:return 8;case 14:return 16;case 2:return 1;case 1:return 0;default:return-1}}function te(e){if(e===9||e===11||e===10||e===1)throw Error(`Dictionary keys must be primitive Teleport types`)}function v(e,t,n){if(t<0||n<0||t+n>e.length)throw Error(`Teleport payload exceeds bounds`)}function ne(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function y(e,t){if(t>=e.length)throw Error(`Array payload exceeds bounds`);let n=e[t],r=n>>4&15;if(n&15)throw Error(`Array flags must be zero`);let i={offset:t+1},a=g(e,i,`ArrayMalformed`),o=_(r);if(o>=0){let n=o*a;return v(e,i.offset,n),i.offset+n-t}let s=i.offset;for(let t=0;t<a;t++)s=x(r,e,s,`ArrayMalformed`);return s-t}function b(e,t){if(t+2>e.length)throw Error(`Dictionary payload too short`);let n=e[t]>>4&15,r=e[t+1]>>4&15;if(e[t]&15||e[t+1]&15)throw Error(`Dictionary key/value flags must be zero`);te(n);let i={offset:t+2},a=g(e,i,`DictMalformed`),o=i.offset;for(let t=0;t<a;t++)o=x(n,e,o,`DictMalformed`),o=x(r,e,o,`DictMalformed`);return o-t}function x(e,t,n,r){let i=_(e);if(i>=0)return v(t,n,i),n+i;switch(e){case 12:case 13:{let e={offset:n},i=g(t,e,r);return v(t,e.offset,i),e.offset+i}case 11:{let e={offset:n},i=g(t,e,r);return v(t,e.offset,i),e.offset+i}case 9:return n+y(t,n);case 10:return n+b(t,n);default:throw Error(`Unsupported Teleport type ${o[e]}`)}}function re(e){return Array.from(e).map(e=>e.toString(16).padStart(2,`0`)).join(``)}function S(e){return e instanceof Uint8Array?e:new Uint8Array(e)}let ie=function(e){return e[e.Unknown=0]=`Unknown`,e[e.Opus=1]=`Opus`,e[e.Mp3=2]=`Mp3`,e[e.RawPcm16=3]=`RawPcm16`,e}({}),ae=function(e){return e[e.Unknown=0]=`Unknown`,e[e.MobileWeb=1]=`MobileWeb`,e[e.MobileApp=2]=`MobileApp`,e[e.DesktopWeb=3]=`DesktopWeb`,e[e.DesktopApp=4]=`DesktopApp`,e}({}),oe=function(e){return e[e.Unknown=0]=`Unknown`,e[e.Backend=2]=`Backend`,e[e.Server=4]=`Server`,e[e.Plugin=8]=`Plugin`,e[e.Browser=16]=`Browser`,e[e.Native=32]=`Native`,e}({}),se=function(e){return e[e.Unknown=0]=`Unknown`,e[e.MessagePack=1]=`MessagePack`,e[e.MemoryPack=2]=`MemoryPack`,e[e.Json=4]=`Json`,e[e.Teleport=8]=`Teleport`,e[e.All=15]=`All`,e}({}),ce=function(e){return e[e.Css=0]=`Css`,e[e.Flutter=1]=`Flutter`,e}({}),le=function(e){return e[e.Unknown=0]=`Unknown`,e[e.Machine=1]=`Machine`,e[e.Human=2]=`Human`,e}({}),ue=function(e){return e[e.Unknown=0]=`Unknown`,e[e.H264=1]=`H264`,e[e.Vp8=2]=`Vp8`,e[e.Vp9=3]=`Vp9`,e[e.Av1=4]=`Av1`,e}({}),de=function(e){return e[e.Unknown=0]=`Unknown`,e[e.DotNet=1]=`DotNet`,e[e.TypeScript=2]=`TypeScript`,e[e.Cpp=3]=`Cpp`,e[e.Dart=4]=`Dart`,e[e.Rust=5]=`Rust`,e}({}),fe=function(e){return e[e.Local=0]=`Local`,e[e.Cloud=1]=`Cloud`,e}({}),C=function(e){return e[e.NONE=0]=`NONE`,e[e.CONSTANT_GROUP_BITS=15]=`CONSTANT_GROUP_BITS`,e[e.CONSTANT_GROUP_OFFSET=16]=`CONSTANT_GROUP_OFFSET`,e[e.GROUP_CORE=65536]=`GROUP_CORE`,e[e.CORE_AUTH_RESPONSE=65537]=`CORE_AUTH_RESPONSE`,e[e.CORE_AUTH_TICKET=65538]=`CORE_AUTH_TICKET`,e[e.CORE_GLOBAL_STATE=65539]=`CORE_GLOBAL_STATE`,e[e.CORE_ON_SERVER_STATUS_PING=65540]=`CORE_ON_SERVER_STATUS_PING`,e[e.CORE_ON_USER_JOINED=65541]=`CORE_ON_USER_JOINED`,e[e.CORE_ON_USER_LEFT=65542]=`CORE_ON_USER_LEFT`,e[e.CORE_ON_CLIENT_JOINED=65543]=`CORE_ON_CLIENT_JOINED`,e[e.CORE_ON_CLIENT_LEFT=65544]=`CORE_ON_CLIENT_LEFT`,e[e.CORE_ON_SERVER_STARTED=65545]=`CORE_ON_SERVER_STARTED`,e[e.CORE_ON_SERVER_STOPPED=65546]=`CORE_ON_SERVER_STOPPED`,e[e.CORE_ON_SERVER_STOPPING=65547]=`CORE_ON_SERVER_STOPPING`,e[e.CORE_ON_CLIENT_READY=65548]=`CORE_ON_CLIENT_READY`,e[e.CORE_CLIENT_READY=65549]=`CORE_CLIENT_READY`,e[e.CORE_SERVER_INIT=65550]=`CORE_SERVER_INIT`,e[e.CORE_ON_PLUGIN_RELOADED=65551]=`CORE_ON_PLUGIN_RELOADED`,e[e.CORE_DYNAMIC_CONFIG=65555]=`CORE_DYNAMIC_CONFIG`,e[e.CORE_PROXY_RPC_AUTH_TICKET=65556]=`CORE_PROXY_RPC_AUTH_TICKET`,e[e.CORE_UPDATE_CLIENT_CONTEXT=65558]=`CORE_UPDATE_CLIENT_CONTEXT`,e[e.CORE_BACKGROUND_WORK_ACTIVE=65559]=`CORE_BACKGROUND_WORK_ACTIVE`,e[e.CORE_RESET_IDLE=65560]=`CORE_RESET_IDLE`,e[e.CORE_CLIENT_DISCONNECTING=65561]=`CORE_CLIENT_DISCONNECTING`,e[e.CORE_ON_APP_READY=65562]=`CORE_ON_APP_READY`,e[e.CORE_ON_FRONTEND_RELOADED=65563]=`CORE_ON_FRONTEND_RELOADED`,e[e.CORE_ON_USER_DATA_ERASED=65564]=`CORE_ON_USER_DATA_ERASED`,e[e.CORE_WEBRTC_OFFER=65566]=`CORE_WEBRTC_OFFER`,e[e.CORE_WEBRTC_ANSWER=65567]=`CORE_WEBRTC_ANSWER`,e[e.CORE_WEBRTC_ICE_CANDIDATE=65568]=`CORE_WEBRTC_ICE_CANDIDATE`,e[e.CORE_WEBRTC_READY=65569]=`CORE_WEBRTC_READY`,e[e.CORE_WEBRTC_AUDIO_SEGMENT=65570]=`CORE_WEBRTC_AUDIO_SEGMENT`,e[e.CORE_WEBRTC_TRACK_MAP=65571]=`CORE_WEBRTC_TRACK_MAP`,e[e.CORE_WEBRTC_VIDEO_CAPTURE=65572]=`CORE_WEBRTC_VIDEO_CAPTURE`,e[e.CORE_WEBRTC_ICE_SERVERS_REQUEST=65573]=`CORE_WEBRTC_ICE_SERVERS_REQUEST`,e[e.CORE_WEBRTC_ICE_SERVERS_RESPONSE=65574]=`CORE_WEBRTC_ICE_SERVERS_RESPONSE`,e[e.CORE_WEBRTC_CLOSE=65575]=`CORE_WEBRTC_CLOSE`,e[e.CORE_RELAY_AGENT_AUTH=65576]=`CORE_RELAY_AGENT_AUTH`,e[e.CORE_RELAY_AGENT_AUTH_RESULT=65577]=`CORE_RELAY_AGENT_AUTH_RESULT`,e[e.CORE_RELAY_HEARTBEAT=65578]=`CORE_RELAY_HEARTBEAT`,e[e.CORE_RELAY_TCP_CONNECTION_OPENED=65579]=`CORE_RELAY_TCP_CONNECTION_OPENED`,e[e.CORE_RELAY_TCP_CONNECTION_CLOSED=65580]=`CORE_RELAY_TCP_CONNECTION_CLOSED`,e[e.CORE_RELAY_TCP_DATA=65581]=`CORE_RELAY_TCP_DATA`,e[e.CORE_RELAY_UDP_DATA=65582]=`CORE_RELAY_UDP_DATA`,e[e.CORE_RELAY_ADD_TUNNEL=65583]=`CORE_RELAY_ADD_TUNNEL`,e[e.CORE_RELAY_TUNNEL_ADDED=65584]=`CORE_RELAY_TUNNEL_ADDED`,e[e.CORE_RELAY_REMOVE_TUNNEL=65585]=`CORE_RELAY_REMOVE_TUNNEL`,e[e.CORE_IKON_SERVER_ENDPOINT_HOST_INFO=65586]=`CORE_IKON_SERVER_ENDPOINT_HOST_INFO`,e[e.CORE_CLIENT_INITIALIZATION=65587]=`CORE_CLIENT_INITIALIZATION`,e[e.CORE_CLIENT_LIFECYCLE_BATCH=65588]=`CORE_CLIENT_LIFECYCLE_BATCH`,e[e.CORE_APP_CONFIG=65589]=`CORE_APP_CONFIG`,e[e.GROUP_KEEPALIVE=131072]=`GROUP_KEEPALIVE`,e[e.KEEPALIVE_REQUEST=131073]=`KEEPALIVE_REQUEST`,e[e.KEEPALIVE_RESPONSE=131074]=`KEEPALIVE_RESPONSE`,e[e.GROUP_EVENTS=262144]=`GROUP_EVENTS`,e[e.EVENTS_PROFILE_UPDATE=262145]=`EVENTS_PROFILE_UPDATE`,e[e.EVENTS_SPEECH_PLAYBACK_COMPLETE=262147]=`EVENTS_SPEECH_PLAYBACK_COMPLETE`,e[e.GROUP_ANALYTICS=524288]=`GROUP_ANALYTICS`,e[e.ANALYTICS_LOGS=524289]=`ANALYTICS_LOGS`,e[e.ANALYTICS_EVENTS=524290]=`ANALYTICS_EVENTS`,e[e.ANALYTICS_USAGES=524291]=`ANALYTICS_USAGES`,e[e.ANALYTICS_USAGE=524292]=`ANALYTICS_USAGE`,e[e.ANALYTICS_SPECIAL_LOG=524293]=`ANALYTICS_SPECIAL_LOG`,e[e.ANALYTICS_PROCESSING_UPDATE=524294]=`ANALYTICS_PROCESSING_UPDATE`,e[e.ANALYTICS_REACTIVE_PROCESSING_UPDATE=524295]=`ANALYTICS_REACTIVE_PROCESSING_UPDATE`,e[e.ANALYTICS_IKON_PROXY_SERVER_STATS=524296]=`ANALYTICS_IKON_PROXY_SERVER_STATS`,e[e.ANALYTICS_IKON_RELAY_SERVER_STATS=524297]=`ANALYTICS_IKON_RELAY_SERVER_STATS`,e[e.ANALYTICS_IKON_TURN_SERVER_STATS=524298]=`ANALYTICS_IKON_TURN_SERVER_STATS`,e[e.ANALYTICS_IKON_HOST_SERVER_STATS=524299]=`ANALYTICS_IKON_HOST_SERVER_STATS`,e[e.GROUP_ACTIONS=1048576]=`GROUP_ACTIONS`,e[e.ACTION_CALL=1048577]=`ACTION_CALL`,e[e.ACTION_ACTIVE=1048578]=`ACTION_ACTIVE`,e[e.ACTION_TEXT_OUTPUT=1048579]=`ACTION_TEXT_OUTPUT`,e[e.ACTION_TEXT_OUTPUT_DELTA=1048580]=`ACTION_TEXT_OUTPUT_DELTA`,e[e.ACTION_TEXT_OUTPUT_DELTA_FULL=1048581]=`ACTION_TEXT_OUTPUT_DELTA_FULL`,e[e.ACTION_SET_STATE=1048582]=`ACTION_SET_STATE`,e[e.ACTION_TAP=1048583]=`ACTION_TAP`,e[e.ACTION_PAN=1048584]=`ACTION_PAN`,e[e.ACTION_ZOOM=1048585]=`ACTION_ZOOM`,e[e.ACTION_FILE_UPLOAD_BEGIN=1048586]=`ACTION_FILE_UPLOAD_BEGIN`,e[e.ACTION_FILE_UPLOAD_DATA=1048587]=`ACTION_FILE_UPLOAD_DATA`,e[e.ACTION_FILE_UPLOAD_ACK=1048588]=`ACTION_FILE_UPLOAD_ACK`,e[e.ACTION_FILE_UPLOAD_END=1048589]=`ACTION_FILE_UPLOAD_END`,e[e.ACTION_FILE_UPLOAD_RESULT=1048590]=`ACTION_FILE_UPLOAD_RESULT`,e[e.ACTION_OPEN_EXTERNAL_URL=1048592]=`ACTION_OPEN_EXTERNAL_URL`,e[e.ACTION_FUNCTION_REGISTER=1048600]=`ACTION_FUNCTION_REGISTER`,e[e.ACTION_FUNCTION_CALL=1048601]=`ACTION_FUNCTION_CALL`,e[e.ACTION_FUNCTION_RESULT=1048602]=`ACTION_FUNCTION_RESULT`,e[e.ACTION_GENERATE_ANSWER=1048603]=`ACTION_GENERATE_ANSWER`,e[e.ACTION_REGENERATE_ANSWER=1048604]=`ACTION_REGENERATE_ANSWER`,e[e.ACTION_CLEAR_STATE=1048606]=`ACTION_CLEAR_STATE`,e[e.ACTION_CLASSIFICATION_RESULT=1048609]=`ACTION_CLASSIFICATION_RESULT`,e[e.ACTION_AUDIO_STOP=1048610]=`ACTION_AUDIO_STOP`,e[e.ACTION_CALL_TEXT=1048611]=`ACTION_CALL_TEXT`,e[e.ACTION_CANCEL_GENERATION=1048613]=`ACTION_CANCEL_GENERATION`,e[e.ACTION_SPEECH_RECOGNIZED=1048615]=`ACTION_SPEECH_RECOGNIZED`,e[e.ACTION_CALL_RESULT=1048616]=`ACTION_CALL_RESULT`,e[e.ACTION_DOWNLOAD=1048618]=`ACTION_DOWNLOAD`,e[e.ACTION_PLAY_SOUND=1048621]=`ACTION_PLAY_SOUND`,e[e.ACTION_STOP_SOUND=1048623]=`ACTION_STOP_SOUND`,e[e.ACTION_START_RECORDING=1048624]=`ACTION_START_RECORDING`,e[e.ACTION_STOP_RECORDING=1048625]=`ACTION_STOP_RECORDING`,e[e.ACTION_FUNCTION_ENUMERATION_ITEM=1048627]=`ACTION_FUNCTION_ENUMERATION_ITEM`,e[e.ACTION_FUNCTION_ENUMERATION_END=1048628]=`ACTION_FUNCTION_ENUMERATION_END`,e[e.ACTION_FUNCTION_CANCEL=1048629]=`ACTION_FUNCTION_CANCEL`,e[e.ACTION_FUNCTION_DISPOSE=1048630]=`ACTION_FUNCTION_DISPOSE`,e[e.ACTION_FUNCTION_ERROR=1048631]=`ACTION_FUNCTION_ERROR`,e[e.ACTION_FUNCTION_ACK=1048632]=`ACTION_FUNCTION_ACK`,e[e.ACTION_FUNCTION_AWAITING_APPROVAL=1048633]=`ACTION_FUNCTION_AWAITING_APPROVAL`,e[e.ACTION_FUNCTION_APPROVAL_REQUIRED=1048634]=`ACTION_FUNCTION_APPROVAL_REQUIRED`,e[e.ACTION_FUNCTION_APPROVAL_RESPONSE=1048635]=`ACTION_FUNCTION_APPROVAL_RESPONSE`,e[e.UI_UPDATE_ACK=1048636]=`UI_UPDATE_ACK`,e[e.ACTION_CALL2=1048637]=`ACTION_CALL2`,e[e.ACTION_FUNCTION_REGISTER_BATCH=1048638]=`ACTION_FUNCTION_REGISTER_BATCH`,e[e.ACTION_FILE_UPLOAD_CALLBACK=1048640]=`ACTION_FILE_UPLOAD_CALLBACK`,e[e.ACTION_CUSTOM_USER_MESSAGE=1048641]=`ACTION_CUSTOM_USER_MESSAGE`,e[e.ACTION_URL_CHANGED=1048642]=`ACTION_URL_CHANGED`,e[e.ACTION_FILE_UPLOAD_PRE_START2=1048643]=`ACTION_FILE_UPLOAD_PRE_START2`,e[e.ACTION_FILE_UPLOAD_PRE_START_RESPONSE2=1048644]=`ACTION_FILE_UPLOAD_PRE_START_RESPONSE2`,e[e.ACTION_FILE_UPLOAD_START2=1048645]=`ACTION_FILE_UPLOAD_START2`,e[e.ACTION_FILE_UPLOAD_START_RESPONSE2=1048646]=`ACTION_FILE_UPLOAD_START_RESPONSE2`,e[e.ACTION_FILE_UPLOAD_DATA2=1048647]=`ACTION_FILE_UPLOAD_DATA2`,e[e.ACTION_FILE_UPLOAD_ACK2=1048648]=`ACTION_FILE_UPLOAD_ACK2`,e[e.ACTION_FILE_UPLOAD_END2=1048649]=`ACTION_FILE_UPLOAD_END2`,e[e.ACTION_FILE_UPLOAD_COMPLETE2=1048650]=`ACTION_FILE_UPLOAD_COMPLETE2`,e[e.ACTION_FUNCTION_ENUMERATION_ITEM_BATCH=1048651]=`ACTION_FUNCTION_ENUMERATION_ITEM_BATCH`,e[e.ACTION_CALL_ACK=1048652]=`ACTION_CALL_ACK`,e[e.ACTION_TRIGGER_CRON=1048653]=`ACTION_TRIGGER_CRON`,e[e.ACTION_RESULT=1048654]=`ACTION_RESULT`,e[e.UI_RESYNC_REQUEST=1048655]=`UI_RESYNC_REQUEST`,e[e.ACTION_USER_DATA_ERASURE=1048656]=`ACTION_USER_DATA_ERASURE`,e[e.GROUP_UI=2097152]=`GROUP_UI`,e[e.UI_STREAM_BEGIN=2097153]=`UI_STREAM_BEGIN`,e[e.UI_STREAM_END=2097154]=`UI_STREAM_END`,e[e.UI_STYLES=2097188]=`UI_STYLES`,e[e.UI_UPDATE=2097190]=`UI_UPDATE`,e[e.UI_STYLES_BATCH=2097192]=`UI_STYLES_BATCH`,e[e.UI_STYLES_DELETE=2097193]=`UI_STYLES_DELETE`,e[e.GROUP_COMMON=4128768]=`GROUP_COMMON`,e[e.GROUP_AUDIO=4194304]=`GROUP_AUDIO`,e[e.AUDIO_STREAM_BEGIN=4194305]=`AUDIO_STREAM_BEGIN`,e[e.AUDIO_STREAM_END=4194306]=`AUDIO_STREAM_END`,e[e.AUDIO_FRAME=4194307]=`AUDIO_FRAME`,e[e.AUDIO_FRAME_VOLUME=4194308]=`AUDIO_FRAME_VOLUME`,e[e.AUDIO_FRAME2=4194309]=`AUDIO_FRAME2`,e[e.AUDIO_SHAPE_FRAME=4194310]=`AUDIO_SHAPE_FRAME`,e[e.AUDIO_PLAYBACK_REPORT=4194311]=`AUDIO_PLAYBACK_REPORT`,e[e.GROUP_VIDEO=8388608]=`GROUP_VIDEO`,e[e.VIDEO_STREAM_BEGIN=8388609]=`VIDEO_STREAM_BEGIN`,e[e.VIDEO_STREAM_END=8388610]=`VIDEO_STREAM_END`,e[e.VIDEO_FRAME=8388611]=`VIDEO_FRAME`,e[e.VIDEO_REQUEST_IDR_FRAME=8388612]=`VIDEO_REQUEST_IDR_FRAME`,e[e.VIDEO_INVALIDATE_FRAME=8388613]=`VIDEO_INVALIDATE_FRAME`,e[e.GROUP_ALL=16711680]=`GROUP_ALL`,e[e.GROUP_APP_LOCAL=1073741824]=`GROUP_APP_LOCAL`,e[e.CONSTANT_GROUP_MASK=2147418112]=`CONSTANT_GROUP_MASK`,e}({});function pe(e){let t={};return me(t),e&&Object.assign(t,e),t}function me(e){return e.StreamId=``,e.Description=``,e.SourceType=``,e.Codec=ie.Unknown,e.CodecDetails=``,e.SampleRate=0,e.Channels=0,e.ShapeSets=void 0,e.CorrelationId=void 0,e}function he(e,t){let n=t??pe();return me(n),ge(e,n),n}function ge(e,t){let n;for(;(n=e.next())!==null;)switch(n.fieldId){case 161083277:if(n.isNull)throw Error();t.StreamId=n.asString();break;case 265814330:if(n.isNull){t.ShapeSets=void 0;break}t.ShapeSets=_e(n.asArray());break;case 1368629611:if(n.isNull)throw Error();t.Description=n.asString();break;case 2431514951:if(n.isNull)throw Error();t.Channels=n.asInt32();break;case 2514959030:if(n.isNull){t.CorrelationId=void 0;break}t.CorrelationId=n.asString();break;case 2745379226:if(n.isNull)throw Error();t.CodecDetails=n.asString();break;case 3282782683:if(n.isNull)throw Error();t.SourceType=n.asString();break;case 3284746250:if(n.isNull)throw Error();t.Codec=n.asInt32();break;case 4101844078:if(n.isNull)throw Error();t.SampleRate=n.asInt32()}}function _e(e){let t=[],n;for(;(n=e.next())!==null;)t.push(be(n.asObject()));return t}function ve(e){let t={};return ye(t),e&&Object.assign(t,e),t}function ye(e){return e.SetId=0,e.Name=``,e.ShapeNames=[],e}function be(e,t){let n=t??ve();return ye(n),xe(e,n),n}function xe(e,t){let n;for(;(n=e.next())!==null;)switch(n.fieldId){case 1107713536:if(n.isNull)throw Error();t.Name=n.asString();break;case 1154362099:if(n.isNull)throw Error();t.SetId=n.asUInt32();break;case 1185721362:if(n.isNull)throw Error();t.ShapeNames=Se(n.asArray())}}function Se(e){let t=[],n;for(;(n=e.next())!==null;)t.push(n.asString());return t}function Ce(e){let t={};return we(t),e&&Object.assign(t,e),t}function we(e){return e.ContextType=oe.Unknown,e.UserType=le.Unknown,e.PayloadType=se.Unknown,e.Description=``,e.UserId=``,e.DeviceId=``,e.ProductId=``,e.VersionId=``,e.InstallId=``,e.Locale=``,e.SessionId=-1,e.IsInternal=!1,e.IsSnapshot=!1,e.SnapshotVariant=``,e.IsReady=!1,e.HasInput=!1,e.AuthSessionId=``,e.IsAnonymous=!1,e.IsGlobal=!1,e.ReceiveAllMessages=!1,e.PreciseJoinedAt=BigInt(0),e.UserAgent=``,e.ClientType=ae.Unknown,e.UniqueSessionId=``,e.Parameters=Object.create(null),e.SdkType=de.Unknown,e.SdkCapability=0,e.ViewportWidth=0,e.ViewportHeight=0,e.Theme=``,e.Timezone=``,e.IsTouchDevice=!1,e.InitialPath=``,e.StyleFormat=ce.Css,e.SupportsCompression=!0,e.IsSoftDisconnected=!1,e.SoftDisconnectAt=BigInt(0),e}function Te(e,t){let n=t??Ce();return we(n),Ee(e,n),n}function Ee(e,t){let n;for(;(n=e.next())!==null;)switch(n.fieldId){case 76337612:if(n.isNull)throw Error();t.DeviceId=n.asString();break;case 185396121:if(n.isNull)throw Error();t.InstallId=n.asString();break;case 250031587:if(n.isNull)throw Error();t.Theme=n.asString();break;case 388632637:if(n.isNull)throw Error();t.UserAgent=n.asString();break;case 417197284:if(n.isNull)throw Error();t.ContextType=n.asInt32();break;case 425972532:if(n.isNull)throw Error();t.SoftDisconnectAt=n.asUInt64();break;case 469070965:if(n.isNull)throw Error();t.HasInput=n.asBool();break;case 470595159:if(n.isNull)throw Error();t.UserType=n.asInt32();break;case 594855258:if(n.isNull)throw Error();t.InitialPath=n.asString();break;case 617065367:if(n.isNull)throw Error();t.IsSoftDisconnected=n.asBool();break;case 661691032:if(n.isNull)throw Error();t.SupportsCompression=n.asBool();break;case 781727218:if(n.isNull)throw Error();t.UserId=n.asString();break;case 834078886:if(n.isNull)throw Error();t.ProductId=n.asString();break;case 1043273762:if(n.isNull)throw Error();t.AuthSessionId=n.asString();break;case 1236999138:if(n.isNull)throw Error();t.ReceiveAllMessages=n.asBool();break;case 1286979607:if(n.isNull)throw Error();t.ViewportHeight=n.asInt32();break;case 1368629611:if(n.isNull)throw Error();t.Description=n.asString();break;case 1437068682:if(n.isNull)throw Error();t.SdkCapability=n.asInt32();break;case 1668375353:if(n.isNull)throw Error();t.IsSnapshot=n.asBool();break;case 1715899485:if(n.isNull)throw Error();t.Locale=n.asString();break;case 1719830747:if(n.isNull)throw Error();t.IsAnonymous=n.asBool();break;case 1942830531:if(n.isNull)throw Error();t.SdkType=n.asInt32();break;case 1999510636:if(n.isNull)throw Error();t.SessionId=n.asInt32();break;case 2033288346:if(n.isNull)throw Error();t.ViewportWidth=n.asInt32();break;case 2079864626:if(n.isNull)throw Error();t.PreciseJoinedAt=n.asUInt64();break;case 2142346422:if(n.isNull)throw Error();t.PayloadType=n.asInt32();break;case 2228539873:if(n.isNull)throw Error();t.StyleFormat=n.asInt32();break;case 2232517119:if(n.isNull)throw Error();t.IsTouchDevice=n.asBool();break;case 2388060749:if(n.isNull)throw Error();t.IsGlobal=n.asBool();break;case 2504065971:if(n.isNull)throw Error();t.SnapshotVariant=n.asString();break;case 2598291686:if(n.isNull)throw Error();t.VersionId=n.asString();break;case 2719718823:if(n.isNull)throw Error();t.UniqueSessionId=n.asString();break;case 2810953526:if(n.isNull)throw Error();t.ClientType=n.asInt32();break;case 2840065720:if(n.isNull)throw Error();t.IsReady=n.asBool();break;case 2885165957:if(n.isNull)throw Error();t.Parameters=De(n.asDictionary());break;case 3542818975:if(n.isNull)throw Error();t.Timezone=n.asString();break;case 3586157513:if(n.isNull)throw Error();t.IsInternal=n.asBool()}}function De(e){let t=Object.create(null),n;for(;(n=e.next())!==null;){let e=n.key.asString();t[e]=n.value.asString()}return t}function Oe(e){let t={};return ke(t),e&&Object.assign(t,e),t}function ke(e){return e.FunctionId=h.fromBytes(new Uint8Array(16)),e.FunctionName=``,e.Parameters=[],e.ResultTypeName=``,e.IsEnumerable=!1,e.EnumerableItemTypeName=``,e.IsCancellable=!1,e.Description=``,e.LlmInlineResult=!1,e.LlmCallOnlyOnce=!1,e.RequiresInstance=!1,e.Versions=[],e}function Ae(e,t){let n=t??Oe();return ke(n),je(e,n),n}function je(e,t){let n;for(;(n=e.next())!==null;)switch(n.fieldId){case 703025676:if(n.isNull)throw Error();t.ResultTypeName=n.asString();break;case 814454131:if(n.isNull)throw Error();t.FunctionName=n.asString();break;case 972460562:if(n.isNull)throw Error();t.EnumerableItemTypeName=n.asString();break;case 976255570:if(n.isNull)throw Error();t.FunctionId=n.asGuid();break;case 1368629611:if(n.isNull)throw Error();t.Description=n.asString();break;case 1479280922:if(n.isNull)throw Error();t.IsCancellable=n.asBool();break;case 1533537016:if(n.isNull)throw Error();t.RequiresInstance=n.asBool();break;case 1909301063:if(n.isNull)throw Error();t.Versions=Me(n.asArray());break;case 2274386296:if(n.isNull)throw Error();t.LlmInlineResult=n.asBool();break;case 2603556958:if(n.isNull)throw Error();t.IsEnumerable=n.asBool();break;case 2885165957:if(n.isNull)throw Error();t.Parameters=Ne(n.asArray());break;case 3568439632:if(n.isNull)throw Error();t.LlmCallOnlyOnce=n.asBool()}}function Me(e){let t=[],n;for(;(n=e.next())!==null;)t.push(n.asString());return t}function Ne(e){let t=[],n;for(;(n=e.next())!==null;)t.push(Ie(n.asObject()));return t}function Pe(e){let t={};return Fe(t),e&&Object.assign(t,e),t}function Fe(e){return e.ParameterIndex=0,e.ParameterName=``,e.TypeName=``,e.HasDefaultValue=!1,e.DefaultValueJson=``,e.DefaultValueData=new Uint8Array,e.IsEnumerable=!1,e.EnumerableItemTypeName=``,e.Description=``,e}function Ie(e,t){let n=t??Pe();return Fe(n),Le(e,n),n}function Le(e,t){let n;for(;(n=e.next())!==null;)switch(n.fieldId){case 607861992:if(n.isNull)throw Error();t.HasDefaultValue=n.asBool();break;case 894485888:if(n.isNull)throw Error();t.DefaultValueJson=n.asString();break;case 972460562:if(n.isNull)throw Error();t.EnumerableItemTypeName=n.asString();break;case 1368629611:if(n.isNull)throw Error();t.Description=n.asString();break;case 1883521406:if(n.isNull)throw Error();t.DefaultValueData=n.asBinary();break;case 2603556958:if(n.isNull)throw Error();t.IsEnumerable=n.asBool();break;case 3609695522:if(n.isNull)throw Error();t.TypeName=n.asString();break;case 4075263697:if(n.isNull)throw Error();t.ParameterName=n.asString();break;case 4257460908:if(n.isNull)throw Error();t.ParameterIndex=n.asInt32()}}function Re(e){let t={};return ze(t),e&&Object.assign(t,e),t}function ze(e){return e.MimeType=``,e.Value=new Uint8Array,e}function Be(e,t){let n=t??Re();return ze(n),Ve(e,n),n}function Ve(e,t){let n;for(;(n=e.next())!==null;)switch(n.fieldId){case 1405462580:if(n.isNull)throw Error();t.Value=n.asBinary();break;case 2968276160:if(n.isNull)throw Error();t.MimeType=n.asString()}}function He(e){let t={};return Ue(t),e&&Object.assign(t,e),t}function Ue(e){return e.Category=``,e}function We(e,t){let n=t??He();return Ue(n),Ge(e,n),n}function Ge(e,t){let n;for(;(n=e.next())!==null;)switch(n.fieldId){case 3612929027:if(n.isNull)throw Error();t.Category=n.asString()}}function Ke(e){let t={};return qe(t),e&&Object.assign(t,e),t}function qe(e){return e.StyleId=``,e.Style=Object.create(null),e}function Je(e,t){return Ye(c.create(e),t)}function Ye(e,t){let n=t??Ke();return qe(n),Xe(e,n),n}function Xe(e,t){let n;for(;(n=e.next())!==null;)switch(n.fieldId){case 979822885:if(n.isNull)throw Error();t.StyleId=n.asString();break;case 2374537704:if(n.isNull)throw Error();t.Style=Qe(n.asDictionary())}}async function Ze(e,t){return Je(await i(e,2097188,1),t)}function Qe(e){let t=Object.create(null),n;for(;(n=e.next())!==null;){let e=n.key.asString();t[e]=n.value.asString()}return t}function $e(e){let t={};return et(t),e&&Object.assign(t,e),t}function et(e){return e.Styles=[],e}function tt(e,t){return nt(c.create(e),t)}function nt(e,t){let n=t??$e();return et(n),rt(e,n),n}function rt(e,t){let n;for(;(n=e.next())!==null;)switch(n.fieldId){case 2136687806:if(n.isNull)throw Error();t.Styles=at(n.asArray())}}async function it(e,t){return tt(await i(e,2097192,1),t)}function at(e){let t=[],n;for(;(n=e.next())!==null;)t.push(ct(n.asObject()));return t}function ot(e){let t={};return st(t),e&&Object.assign(t,e),t}function st(e){return e.StyleId=``,e.Style=Object.create(null),e}function ct(e,t){let n=t??ot();return st(n),lt(e,n),n}function lt(e,t){let n;for(;(n=e.next())!==null;)switch(n.fieldId){case 979822885:if(n.isNull)throw Error();t.StyleId=n.asString();break;case 2374537704:if(n.isNull)throw Error();t.Style=ut(n.asDictionary())}}function ut(e){let t=Object.create(null),n;for(;(n=e.next())!==null;){let e=n.key.asString();t[e]=n.value.asString()}return t}function dt(e){let t={};return ft(t),e&&Object.assign(t,e),t}function ft(e){return e.StyleIds=[],e}function pt(e,t){return mt(c.create(e),t)}function mt(e,t){let n=t??dt();return ft(n),ht(e,n),n}function ht(e,t){let n;for(;(n=e.next())!==null;)switch(n.fieldId){case 1415642792:if(n.isNull)throw Error();t.StyleIds=_t(n.asArray())}}async function gt(e,t){return pt(await i(e,2097193,1),t)}function _t(e){let t=[],n;for(;(n=e.next())!==null;)t.push(n.asString());return t}function vt(e){let t={};return w(t),e&&Object.assign(t,e),t}function w(e){return e.Json=``,e.Payloads=Object.create(null),e}function yt(e,t){return bt(c.create(e),t)}function bt(e,t){let n=t??vt();return w(n),xt(e,n),n}function xt(e,t){let n;for(;(n=e.next())!==null;)switch(n.fieldId){case 425183262:if(n.isNull)throw Error();t.Json=n.asString();break;case 653781469:if(n.isNull)throw Error();t.Payloads=Ct(n.asDictionary())}}async function St(e,t){return yt(await i(e,2097190,1),t)}function Ct(e){let t=Object.create(null),n;for(;(n=e.next())!==null;){let e=n.key.asString();t[e]=Be(n.value.asObject())}return t}function T(e){let t={};return E(t),e&&Object.assign(t,e),t}function E(e){return e.StreamId=``,e.Description=``,e.SourceType=``,e.Codec=ue.H264,e.CodecDetails=``,e.Width=0,e.Height=0,e.Framerate=30,e.CorrelationId=void 0,e}function wt(e,t){let n=t??T();return E(n),Tt(e,n),n}function Tt(e,t){let n;for(;(n=e.next())!==null;)switch(n.fieldId){case 161083277:if(n.isNull)throw Error();t.StreamId=n.asString();break;case 164808083:if(n.isNull)throw Error();t.Framerate=n.asFloat64();break;case 1368629611:if(n.isNull)throw Error();t.Description=n.asString();break;case 2514959030:if(n.isNull){t.CorrelationId=void 0;break}t.CorrelationId=n.asString();break;case 2745379226:if(n.isNull)throw Error();t.CodecDetails=n.asString();break;case 2950031986:if(n.isNull)throw Error();t.Height=n.asInt32();break;case 3282782683:if(n.isNull)throw Error();t.SourceType=n.asString();break;case 3284746250:if(n.isNull)throw Error();t.Codec=n.asInt32();break;case 4065070594:if(n.isNull)throw Error();t.Width=n.asInt32()}}function Et(e){let t={};return Dt(t),e&&Object.assign(t,e),t}function Dt(e){return e.Clients=Object.create(null),e.Functions=Object.create(null),e.UIStreams=Object.create(null),e.AudioStreams=Object.create(null),e.VideoStreams=Object.create(null),e.SpaceId=``,e.IkonServerId=``,e.AppSessionId=``,e.SessionIdentityHash=``,e.SpaceUrl=``,e.SessionUrl=``,e.FirstUserId=``,e.PrimaryUserId=``,e.OrganisationName=``,e.SpaceName=``,e.ServerRunType=fe.Local,e.PublicAccess=!1,e.DebugMode=!1,e.retiredFields=void 0,e}function Ot(e,t){return kt(c.create(e),t)}function kt(e,t){let n=t??Et();return Dt(n),At(e,n),n}function At(e,t){let n;for(;(n=e.next())!==null;)switch(n.fieldId){case 620476198:if(n.isNull)throw Error();t.IkonServerId=n.asString();break;case 693643444:if(n.isNull)throw Error();t.FirstUserId=n.asString();break;case 1144553441:if(n.isNull)throw Error();t.Clients=Mt(n.asDictionary());break;case 1731742060:if(n.isNull)throw Error();t.AppSessionId=n.asString();break;case 1931178803:if(n.isNull)throw Error();t.SessionIdentityHash=n.asString();break;case 2191393509:if(n.isNull)throw Error();t.SessionUrl=n.asString();break;case 2563358196:if(n.isNull)throw Error();t.SpaceUrl=n.asString();break;case 3042922213:if(n.isNull)throw Error();t.PublicAccess=n.asBool();break;case 3064612128:if(n.isNull)throw Error();t.ServerRunType=n.asInt32();break;case 3219210453:if(n.isNull)throw Error();t.OrganisationName=n.asString();break;case 3504054055:if(n.isNull)throw Error();t.DebugMode=n.asBool();break;case 3678477544:if(n.isNull)throw Error();t.Functions=Nt(n.asDictionary());break;case 3696445035:if(n.isNull)throw Error();t.UIStreams=Pt(n.asDictionary());break;case 3707543140:if(n.isNull)throw Error();t.SpaceId=n.asString();break;case 3712281496:if(n.isNull)throw Error();t.PrimaryUserId=n.asString();break;case 3895362455:if(n.isNull)throw Error();t.AudioStreams=Ft(n.asDictionary());break;case 3897397815:if(n.isNull)throw Error();t.VideoStreams=It(n.asDictionary());break;case 4225107827:if(n.isNull)throw Error();t.SpaceName=n.asString();break;case 976837618:if(n.isNull)break;(t.retiredFields??={}).SessionHash=n.asString();break;case 2271236852:if(n.isNull)break;(t.retiredFields??={}).SessionChannelUrl=n.asString();break;case 2277643855:if(n.isNull)break;(t.retiredFields??={}).ChannelUrl=n.asString();break;case 3914217035:if(n.isNull)break;(t.retiredFields??={}).ServerSessionId=n.asString()}}async function jt(e,t){return Ot(await i(e,65539,11),t)}function Mt(e){let t=Object.create(null),n;for(;(n=e.next())!==null;){let e=n.key.asInt32();t[e]=Te(n.value.asObject())}return t}function Nt(e){let t=Object.create(null),n;for(;(n=e.next())!==null;){let e=n.key.asInt32();t[e]=Lt(n.value.asArray())}return t}function Pt(e){let t=Object.create(null),n;for(;(n=e.next())!==null;){let e=n.key.asString();t[e]=Bt(n.value.asObject())}return t}function Ft(e){let t=Object.create(null),n;for(;(n=e.next())!==null;){let e=n.key.asString();t[e]=Wt(n.value.asObject())}return t}function It(e){let t=Object.create(null),n;for(;(n=e.next())!==null;){let e=n.key.asString();t[e]=Jt(n.value.asObject())}return t}function Lt(e){let t=[],n;for(;(n=e.next())!==null;)t.push(Ae(n.asObject()));return t}function Rt(e){let t={};return zt(t),e&&Object.assign(t,e),t}function zt(e){return e.StreamId=``,e.ClientSessionId=0,e.TrackId=0,e.Info=He(),e}function Bt(e,t){let n=t??Rt();return zt(n),Vt(e,n),n}function Vt(e,t){let n;for(;(n=e.next())!==null;)switch(n.fieldId){case 161083277:if(n.isNull)throw Error();t.StreamId=n.asString();break;case 325678206:if(n.isNull)throw Error();t.ClientSessionId=n.asInt32();break;case 3469892363:if(n.isNull)throw Error();t.TrackId=n.asInt32();break;case 3645544153:if(n.isNull)throw Error();t.Info=We(n.asObject())}}function Ht(e){let t={};return Ut(t),e&&Object.assign(t,e),t}function Ut(e){return e.StreamId=``,e.ClientSessionId=0,e.TrackId=0,e.Info=pe(),e}function Wt(e,t){let n=t??Ht();return Ut(n),Gt(e,n),n}function Gt(e,t){let n;for(;(n=e.next())!==null;)switch(n.fieldId){case 161083277:if(n.isNull)throw Error();t.StreamId=n.asString();break;case 325678206:if(n.isNull)throw Error();t.ClientSessionId=n.asInt32();break;case 3469892363:if(n.isNull)throw Error();t.TrackId=n.asInt32();break;case 3645544153:if(n.isNull)throw Error();t.Info=he(n.asObject())}}function Kt(e){let t={};return qt(t),e&&Object.assign(t,e),t}function qt(e){return e.StreamId=``,e.ClientSessionId=0,e.TrackId=0,e.Info=T(),e}function Jt(e,t){let n=t??Kt();return qt(n),Yt(e,n),n}function Yt(e,t){let n;for(;(n=e.next())!==null;)switch(n.fieldId){case 161083277:if(n.isNull)throw Error();t.StreamId=n.asString();break;case 325678206:if(n.isNull)throw Error();t.ClientSessionId=n.asInt32();break;case 3469892363:if(n.isNull)throw Error();t.TrackId=n.asInt32();break;case 3645544153:if(n.isNull)throw Error();t.Info=wt(n.asObject())}}function D(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Xt(e){let t={},n=Object.keys(e);for(let r=0;r<n.length;r++){let i=n[r];t[i]=e[i]}return t}function Zt(e,t,n,r){if(!(e===void 0&&r)){if(Array.isArray(e)){let r=[];for(let i=0;i<e.length;i++){let a=e[i];if(typeof a!=`string`)throw Error(`Invalid styleIds entry at ${t}.styleIds[${i}] for element ${n}`);let o=a.trim();o.length!==0&&r.push(o)}return r}if(e!=null)throw Error(`Invalid styleIds for element ${n}`);return[]}}function O(e,t){if(!e||typeof e!=`object`)throw Error(`Invalid UI node at ${t}`);let n=e.Id,r=e.Type,i=e.Props,a=e.Children,o=e.StyleIds;if(typeof n!=`string`)throw Error(`Invalid or missing node id at ${t}`);if(typeof r!=`string`)throw Error(`Invalid or missing node type for ${n}`);let s={};if(i!=null){if(!D(i))throw Error(`Invalid props for node ${n}`);s=Xt(i)}let c=[];Array.isArray(a)&&(c=a.map((e,n)=>O(e??{},`${t}.children[${n}]`)));let l=Zt(o,t,n,!1),u=typeof e.SourceMarker==`string`?e.SourceMarker:void 0;return{id:n,type:r,props:s,children:c,styleIds:l??[],...u?{sourceMarker:u}:{}}}function Qt(e,t){if(!D(e))throw Error(`Invalid text delta at ${t}`);let n=e.NodeId,r=e.PropertyName,i=e.Start,a=e.End,o=e.InsertedText;if(typeof n!=`string`||n.length===0)throw Error(`Invalid text delta node id at ${t}`);if(typeof r!=`string`||r.length===0)throw Error(`Invalid text delta property name at ${t}`);if(typeof i!=`number`||!Number.isFinite(i))throw Error(`Invalid text delta start at ${t}`);if(typeof o!=`string`)throw Error(`Invalid text delta inserted text at ${t}`);let s;if(typeof a==`number`){if(!Number.isFinite(a))throw Error(`Invalid text delta end at ${t}`);s=a}else if(a!=null)throw Error(`Invalid text delta end at ${t}`);return{nodeId:n,propertyName:r,start:i,end:s,insertedText:o}}function $t(e,t){if(!D(e))throw Error(`Invalid child insert at ${t}`);let n=e.Index,r=e.Node;if(typeof n!=`number`||!Number.isFinite(n))throw Error(`Invalid child insert index at ${t}`);if(!D(r))throw Error(`Invalid child insert node at ${t}`);return{index:n,node:O(r,`${t}.node`)}}function en(e,t){if(!D(e))throw Error(`Invalid child move at ${t}`);let n=e.NodeId,r=e.FromIndex,i=e.ToIndex;if(typeof n!=`string`||n.length===0)throw Error(`Invalid child move nodeId at ${t}`);if(typeof r!=`number`||!Number.isFinite(r))throw Error(`Invalid child move fromIndex at ${t}`);if(typeof i!=`number`||!Number.isFinite(i))throw Error(`Invalid child move toIndex at ${t}`);return{nodeId:n,fromIndex:r,toIndex:i}}function tn(e,t){if(!D(e))throw Error(`Invalid child remove at ${t}`);let n=e.NodeId,r=e.Index;if(typeof n!=`string`||n.length===0)throw Error(`Invalid child remove nodeId at ${t}`);if(typeof r!=`number`||!Number.isFinite(r))throw Error(`Invalid child remove index at ${t}`);return{nodeId:n,index:r}}function nn(e,t){if(!D(e))throw Error(`Invalid node change at ${t}`);let n=e.nodeId;if(typeof n!=`string`||n.length===0)throw Error(`Invalid node change nodeId at ${t}`);let r=Array.isArray(e.inserts)?e.inserts.map((e,n)=>$t(e??{},`${t}.inserts[${n}]`)):void 0,i=Array.isArray(e.moves)?e.moves.map((e,n)=>en(e??{},`${t}.moves[${n}]`)):void 0,a=Array.isArray(e.removals)?e.removals.map((e,n)=>tn(e??{},`${t}.removals[${n}]`)):void 0,o;if(D(e.changedProps)){o=new Map;for(let[t,n]of Object.entries(e.changedProps)){if(!D(n))continue;let e=n.New;e==null?o.set(t,void 0):D(e)?o.set(t,Xt(e)):o.set(t,e)}}let s=Array.isArray(e.textUpdates)?e.textUpdates.map((e,n)=>Qt(e??{},`${t}.textUpdates[${n}]`)):void 0,c=e.styleIds,l=c===void 0?void 0:Zt(c,t,n,!0);return{nodeId:n,...r&&r.length>0?{inserts:r}:{},...i&&i.length>0?{moves:i}:{},...a&&a.length>0?{removals:a}:{},...o&&o.size>0?{changedProps:o}:{},...s&&s.length>0?{textUpdates:s}:{},...l===void 0?{}:{styleIds:l}}}function rn(e){let t=new Map;for(let[n,r]of Object.entries(e))t.set(n,r);return t}function an(e,t,n){if(!e||typeof e!=`object`)throw new k(`UI update graph is missing`);let r=O(e,`graph`);if(r.type!==`root`)throw new k(`UI update root element must have type "root"`);return{type:`full`,version:n,root:r,metadata:sn(r.props,t)}}function on(e,t,n){if(!Array.isArray(e))throw new k(`UI diff changes must be an array`);if(!D(t))throw new k(`UI diff metadata must be an object`);let r=t.viewId;if(typeof r!=`string`||r.length===0)throw new k(`UI diff metadata is missing viewId`);let i=e.map((e,t)=>nn(e??{},`changes[${t}]`)),a=typeof t.isUpdate==`boolean`?t.isUpdate:void 0;return{type:`diff`,version:n,changes:i,metadata:{viewId:r,...a===void 0?{}:{isUpdate:a}}}}function sn(e,t){let n=e.viewId;if(typeof n!=`string`||n.length===0)throw new k(`UI update root is missing viewId`);let r=n,i=typeof e.isUpdate==`boolean`?e.isUpdate:void 0;return D(t)&&(typeof t.viewId==`string`&&t.viewId.length>0&&(r=t.viewId),typeof t.isUpdate==`boolean`&&(i=t.isUpdate)),{viewId:r,...i===void 0?{}:{isUpdate:i}}}var k=class extends Error{causeError;constructor(e,t){super(e),this.causeError=t,this.name=`UiUpdateParseError`,t instanceof Error&&(this.stack=t.stack)}};function A(e){let t;try{t=JSON.parse(e.Json)}catch(e){throw new k(`Failed to parse UIUpdate.Json payload`,e)}if(!t||typeof t!=`object`)throw new k(`UI update snapshot must be an object`);let{type:n,version:r}=t;if(n!==`full`&&n!==`diff`)throw new k(`Unknown UI update type: ${String(n)}`);if(typeof r!=`number`)throw new k(`UI update version must be a number`);return{snapshot:n===`full`?an(t.graph,t.metadata,r):on(t.changes,t.metadata,r),payloads:e.Payloads?rn(e.Payloads):new Map}}const cn=new Map,ln={0:`DEBUG`,1:`INFO`,2:`WARN`,3:`ERROR`,4:`NONE`};function un(e,t){return`[${e}] ${t}`}function j(e,t,n,r){let i={timestamp:new Date().toISOString(),level:e,levelName:ln[e],component:t,message:n,args:r};for(let[t,n]of cn)if(e>=(n?.minLevel??2))try{t(i)}catch{}if(1<=e){let i=un(t,n);switch(e){case 0:console.debug(i,...r);break;case 1:console.info(i,...r);break;case 2:console.warn(i,...r);break;case 3:console.error(i,...r)}}}function dn(e){return{debug(t,...n){j(0,e,t,n)},info(t,...n){j(1,e,t,n)},warn(t,...n){j(2,e,t,n)},error(t,...n){j(3,e,t,n)}}}var fn=class{cache=new Map;getHandler(e,t,n){let r=`${e}:${t}`,i=this.cache.get(r);return i||(i=()=>n(t),this.cache.set(r,i)),i}getHandlerWithPayload(e,t,n){let r=`${e}:${t}:payload`,i=this.cache.get(r);return i||(i=e=>n(t,e),this.cache.set(r,i)),i}getBooleanHandler(e,t,n){return this.getHandlerWithPayload(e,t,n)}getStringHandler(e,t,n){return this.getHandlerWithPayload(e,t,n)}getNumberHandler(e,t,n){return this.getHandlerWithPayload(e,t,n)}getNumberArrayHandler(e,t,n){return this.getHandlerWithPayload(e,t,n)}getNullableBooleanHandler(e,t,n){let r=`${e}:${t}:nullable-bool`,i=this.cache.get(r);return i||(i=e=>n(t,e??null),this.cache.set(r,i)),i}invalidateNode(e){let t=`${e}:`;for(let e of this.cache.keys())e.startsWith(t)&&this.cache.delete(e)}invalidateHandler(e,t){this.cache.delete(`${e}:${t}`),this.cache.delete(`${e}:${t}:payload`),this.cache.delete(`${e}:${t}:nullable-bool`)}clear(){this.cache.clear()}get size(){return this.cache.size}};const pn=dn(`UiStreamStore`);var mn=class{views=new Map;listeners=new Set;payloads=new Map;snapshotMode=!1;snapshot={views:new Map,payloads:new Map,version:-1};rootViewId;nodeListeners=new Map;changedNodeIds=new Set;nodeVersions=new Map;structureChanged=!1;resyncNeeded=!1;viewsDirty=!0;payloadsDirty=!0;handlerCache=new fn;nodeIndex=new Map;indexedViews;apply(e){if(this.snapshotMode){if(e.snapshot.type!==`full`)return!1;this.snapshotMode=!1,this.views.clear(),this.payloads.clear(),this.rootViewId=void 0,this.viewsDirty=!0,this.payloadsDirty=!0,this.snapshot={views:new Map,payloads:new Map,version:-1}}let{snapshot:t,payloads:n}=e,{metadata:r}=t,{viewId:i}=r,a=this.views.get(i);a||(a={version:0},this.views.set(i,a));let o=t.type===`diff`&&r.isUpdate===!0;if(t.version<a.version||t.type===`diff`&&t.version>a.version+1)return this.resyncNeeded=!0,!1;if(t.version===a.version&&!o)return!1;let s=!1;this.rootViewId||(this.rootViewId=i,s=!0,this.structureChanged=!0);let c=a.root;if(t.type===`full`)a.root=t.root,a.version=t.version,s=!0,this.viewsDirty=!0,this.structureChanged=!0,t.root&&N(t.root,this.changedNodeIds);else{if(!c)return this.resyncNeeded=!0,!1;let e=gn(c,t.changes);e===c?a.root=e:(a.root=e,s=!0,this.viewsDirty=!0,I(c,e,this.changedNodeIds)),a.version=t.version}for(let[e,t]of n)this.payloads.get(e)!==t&&(this.payloads.set(e,t),s=!0,this.payloadsDirty=!0);return s?(this.commitSnapshot(),this.notify(),!0):(a.version=t.version,!1)}enterSnapshotMode(){this.snapshotMode=!0}consumeResyncNeeded(){let e=this.resyncNeeded;return this.resyncNeeded=!1,e}replaceFromWire(e){let t={rootViewId:e.rootViewId,views:new Map(e.views),payloads:new Map(e.payloads),version:e.version};return this.replaceSnapshot(t)}patchFromOp(e){this.snapshotMode=!0;let t=e.expectedBaseVersion;if(t!==void 0&&this.snapshot.version!==t)return!1;let n=!1,r=null,i=null,a=()=>(r||=new Map(this.snapshot.views),r),o=()=>(i||=new Map(this.snapshot.payloads),i);if(e.deleteViews&&e.deleteViews.length>0)for(let t of e.deleteViews)a().delete(t)&&(n=!0,this.structureChanged=!0);if(e.upsertViews&&e.upsertViews.length>0)for(let[t,r]of e.upsertViews){let e=a(),i=e.get(t);i!==r&&(e.set(t,r),n=!0,i?I(i,r,this.changedNodeIds):(N(r,this.changedNodeIds),this.structureChanged=!0))}if(e.deletePayloads&&e.deletePayloads.length>0)for(let t of e.deletePayloads)o().delete(t)&&(n=!0);if(e.upsertPayloads&&e.upsertPayloads.length>0)for(let[t,r]of e.upsertPayloads){let e=o();e.get(t)!==r&&(e.set(t,r),n=!0)}let s=e.rootViewId??this.snapshot.rootViewId;s!==this.snapshot.rootViewId&&(n=!0,this.structureChanged=!0);let c=e.nextVersion;if(c!==this.snapshot.version&&(n=!0),!n)return this.snapshot={...this.snapshot,version:c},!1;for(let e of this.changedNodeIds)this.nodeVersions.set(e,(this.nodeVersions.get(e)??0)+1);return this.snapshot={rootViewId:s,views:r??new Map(this.snapshot.views),payloads:i??new Map(this.snapshot.payloads),version:c},this.notify(),!0}replaceSnapshot(e){this.snapshotMode=!0;let t=this.snapshot,n=t.version!==e.version||t.rootViewId!==e.rootViewId||t.views.size!==e.views.size||t.payloads.size!==e.payloads.size;(t.rootViewId!==e.rootViewId||t.views.size!==e.views.size)&&(this.structureChanged=!0);for(let[n,r]of e.views){let e=t.views.get(n);e?I(e,r,this.changedNodeIds):(N(r,this.changedNodeIds),this.structureChanged=!0)}for(let e of this.changedNodeIds)this.nodeVersions.set(e,(this.nodeVersions.get(e)??0)+1);return this.snapshot=e,n&&this.notify(),n}clear(){(this.snapshot.rootViewId!==void 0&&this.snapshot.rootViewId.length!==0||this.snapshot.views.size!==0||this.snapshot.payloads.size!==0)&&(this.snapshotMode=!0,this.views.clear(),this.payloads.clear(),this.rootViewId=void 0,this.viewsDirty=!0,this.payloadsDirty=!0,this.snapshot={views:new Map,payloads:new Map,version:-1},this.structureChanged=!0,this.notify())}getSnapshot(){return this.snapshot}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}subscribeNode(e,t){let n=this.nodeListeners.get(e);return n||(n=new Set,this.nodeListeners.set(e,n)),n.add(t),()=>{n&&(n.delete(t),n.size===0&&this.nodeListeners.delete(e))}}getNode(e){let t=this.snapshot.views;return this.indexedViews!==t&&this.rebuildNodeIndex(t),this.nodeIndex.get(e)}rebuildNodeIndex(e){this.nodeIndex.clear();for(let t of e.values())P(t,this.nodeIndex);for(let[t,n]of e)this.nodeIndex.set(t,n);this.indexedViews=e}getNodeVersion(e){return this.nodeVersions.get(e)??0}notifyNodes(){if(this.changedNodeIds.size===0||this.nodeListeners.size===0){this.changedNodeIds.clear();return}for(let e of this.changedNodeIds){let t=this.nodeListeners.get(e);if(t)for(let e of t)e()}this.changedNodeIds.clear()}commitSnapshot(){let e,t;if(this.viewsDirty){let t=new Map;for(let[e,n]of this.views)n.root&&t.set(e,n.root);e=t,this.viewsDirty=!1}else e=this.snapshot.views;this.payloadsDirty?(t=new Map(this.payloads),this.payloadsDirty=!1):t=this.snapshot.payloads;let n=this.rootViewId&&this.views.has(this.rootViewId)?this.views.get(this.rootViewId)?.version:void 0;if(n===void 0)for(let e of this.views.values())n=n===void 0?e.version:Math.max(n,e.version);this.snapshot={rootViewId:this.rootViewId,views:e,payloads:t,version:n};for(let e of this.changedNodeIds)this.nodeVersions.set(e,(this.nodeVersions.get(e)??0)+1)}notify(){if(this.notifyNodes(),this.structureChanged){this.structureChanged=!1;for(let e of this.listeners)e()}}},hn=class{streams=new Map;listeners=new Set;apply(e,t){let n=this.getOrCreateStreamEntry(e).store.apply(t);return n&&this.notify(e),n}needsResync(e){let t=this.streams.get(e);return t?t.store.consumeResyncNeeded():!1}applyStoreOp(e){if(e.type===`ReplaceStreamSnapshot`){let t=this.getOrCreateStreamEntry(e.snapshot.streamId),n=t.category!==e.snapshot.category;return t.category=e.snapshot.category,t.store.replaceFromWire(e.snapshot)||n?(this.notify(e.snapshot.streamId),!0):!1}if(e.type===`PatchStreamSnapshot`){let t=this.getOrCreateStreamEntry(e.streamId),n=e.category!==void 0&&t.category!==e.category;return e.category!==void 0&&(t.category=e.category),t.store.patchFromOp(e)||n?(this.notify(e.streamId),!0):!1}if(e.type===`ClearStream`){let t=this.streams.get(e.streamId);return t?(t.store.clear(),this.notify(e.streamId),!0):!1}return e.type===`RemoveStream`?this.streams.delete(e.streamId)?(this.notify(e.streamId),!0):!1:e.type===`SetStreamCategory`&&(this.setCategory(e.streamId,e.category),!0)}applyStoreOps(e){for(let t of e)this.applyStoreOp(t)}clear(e){let t=this.streams.get(e);t&&(t.store.clear(),this.notify(e))}remove(e){this.streams.delete(e)&&this.notify(e)}enterSnapshotModeAll(){for(let e of this.streams.values())e.store.enterSnapshotMode()}setCategory(e,t){let n=this.getOrCreateStreamEntry(e);n.category!==t&&(n.category=t,this.notify(e))}getSnapshot(e){let t=this.streams.get(e);if(t)return{...t.store.getSnapshot(),streamId:e,category:t.category}}getSnapshots(){let e=[];for(let[t,n]of this.streams){let r=n.store.getSnapshot();e.push({...r,streamId:t,category:n.category})}return e}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}getOrCreateStreamEntry(e){let t=this.streams.get(e);return t||(t={store:new mn},this.streams.set(e,t)),t}notify(e){for(let t of this.listeners)t(e)}};function gn(e,t,n){if(t.length===0)return e;let r=new Map;for(let e of t)r.set(e.nodeId,e);return M(e,r,n)}function M(e,t,n){let r=t.get(e.id),i=e,a=!1;if(r?.textUpdates&&r.textUpdates.length>0){let t=xn(e,r.textUpdates,n);i=t.node,a=t.changed}let o=!1,s=i.props;if(r?.changedProps&&r.changedProps.size>0)for(let[e,t]of r.changedProps.entries()){let n=s[e];if(t===void 0)(n!==void 0||e in s)&&(o||=(s=R(s),!0),delete s[e]);else if(z(t)){let r=R(t);B(r,n)||(o||=(s=R(s),!0),s[e]=r)}else B(t,n)||(o||=(s=R(s),!0),s[e]=t)}let c=!1,l=i.styleIds;r?.styleIds!==void 0&&(L(i.styleIds,r.styleIds)||(l=r.styleIds,c=!0));let u=i.children??[],d=u,f=!1;if(r?.removals&&r.removals.length>0||r?.moves&&r.moves.length>0||r?.inserts&&r.inserts.length>0){let e=d.slice();if(r?.removals&&r.removals.length>0){let t=[...r.removals].sort((e,t)=>t.index-e.index);for(let n of t)if(n.index>=0&&n.index<e.length&&e[n.index].id===n.nodeId)e.splice(n.index,1);else{let t=e.findIndex(e=>e.id===n.nodeId);t>=0&&e.splice(t,1)}f=!0}let t=new Map;if(r?.moves&&r.moves.length>0){for(let n of r.moves){let r=e.findIndex(e=>e.id===n.nodeId);r>=0&&(t.set(n.nodeId,e[r]),e.splice(r,1))}f=!0}let i=[];if(r?.moves)for(let e of r.moves){let n=t.get(e.nodeId);n&&i.push({index:e.toIndex,node:n,isInsert:!1})}if(r?.inserts){for(let n of r.inserts)(e.some(e=>e.id===n.node.id)||t.has(n.node.id))&&pn.warn(`Duplicate node id '${n.node.id}' (type '${n.node.type}') inserted next to an existing sibling — UI tree diverged from the server`),i.push({index:n.index,node:n.node,isInsert:!0});f=!0}i.sort((e,t)=>e.index-t.index);for(let t of i){let r=Math.min(t.index,e.length);e.splice(r,0,t.node),t.isInsert&&n&&N(t.node,n)}d=e}let p;for(let e=0;e<d.length;e++){let r=d[e],i=M(r,t,n);i!==r&&(p||=d.slice(),p[e]=i)}p&&(d=p,f=!0);let m=a||o||c,h=m||f;return m&&n&&n.add(e.id),h?!o&&!f&&!c?i:{id:e.id,type:e.type,props:o?s:i.props,children:f?d:u,styleIds:c?l:i.styleIds,...e.sourceMarker?{sourceMarker:e.sourceMarker}:{}}:e}function N(e,t){if(t.add(e.id),e.children)for(let n of e.children)N(n,t)}function P(e,t){if(t.set(e.id,e),e.children)for(let n of e.children)P(n,t)}const F=[];function _n(e){for(;F.length<=e;)F.push(new Map);return F[e].clear(),F[e]}function I(e,t,n){vn(e,t,n,0)}function vn(e,t,n,r){if(e===t)return;(e.type!==t.type||!yn(e.props,t.props)||!L(e.styleIds,t.styleIds))&&n.add(t.id);let i=e.children??[],a=t.children??[];if(i!==a){let e=_n(r);for(let t of i)e.set(t.id,t);let o=!1;for(let t=0;t<a.length;t++){let s=a[t],c=e.get(s.id);c?(vn(c,s,n,r+1),!o&&t<i.length&&i[t].id!==s.id&&(o=!0)):(N(s,n),o=!0)}(i.length!==a.length||o)&&n.add(t.id)}}function yn(e,t){return B(e,t)}function L(e,t){return B(e,t)}function bn(e,t){if(t.length===0)return e;let n=[...t].sort((e,t)=>e.start-t.start),r=e,i=0;for(let e of n){let t=Cn(e.start+i,0,r.length);if(e.end==null){let n=r.slice(t),a=wn(n,e.insertedText);r=r.slice(0,t)+e.insertedText+n.slice(a),i+=e.insertedText.length-a;continue}let n=Cn(e.end+i,t,r.length),a=n-t;r=r.slice(0,t)+e.insertedText+r.slice(n),i+=e.insertedText.length-a}return r}function xn(e,t,n){if(t.length===0)return{node:e,changed:!1};let r=new Map;for(let e of t){let t=r.get(e.nodeId);t?t.push(e):r.set(e.nodeId,[e])}return Sn(e,r,n)}function Sn(e,t,n){let r=t.get(e.id)??[],i=!1,a=e.props;if(r.length>0){let e=new Map;for(let t of r){let n=e.get(t.propertyName);n?n.push(t):e.set(t.propertyName,[t])}for(let[t,n]of e.entries()){let e=a[t],r=bn(typeof e==`string`?e:``,n);i||=(a=R(a),!0),a[t]=r}}let o=!1,s=e.children??[],c=s;if(s.length>0){let e;for(let r=0;r<s.length;r++){let i=s[r],a=Sn(i,t,n);a.changed&&(e||=[...s],e[r]=a.node)}e&&(c=e,o=!0)}return!i&&!o?{node:e,changed:!1}:(i&&n&&n.add(e.id),{node:{id:e.id,type:e.type,props:i?a:e.props,children:o?c:s,styleIds:e.styleIds,...e.sourceMarker?{sourceMarker:e.sourceMarker}:{}},changed:!0})}function Cn(e,t,n){return Math.max(t,Math.min(n,e))}function wn(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e.charCodeAt(r)===t.charCodeAt(r);)r++;return r}function R(e){let t={},n=Object.keys(e);for(let r=0;r<n.length;r++){let i=n[r];t[i]=e[i]}return t}function z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function B(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!B(e[n],t[n]))return!1;return!0}if(z(e)&&z(t)){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!B(e[r],t[r]))return!1;return!0}return!1}const V=new hn,H=new Map,U=new Map,W=new Set;let Tn=16,En=50,G=[],K=null,q=null,J=0,Y=0;const X=new Map,Z=new Map;function Dn(){return typeof performance<`u`?performance.now():Date.now()}function On(){try{return crypto.randomUUID()}catch{return`${Date.now()}_${Math.random().toString(16).slice(2)}`}}function kn(e){let t=[];for(let n of e.views)t.push(n);let n=[];for(let t of e.payloads)n.push(t);return{streamId:e.streamId,category:e.category,version:e.version??-1,rootViewId:e.rootViewId,views:t,payloads:n}}function An(e,t,n){if(!n||n.version===-1)return{type:`ReplaceStreamSnapshot`,snapshot:kn(t)};let r,i;for(let[e,i]of t.views)n.views.get(e)!==i&&(r??=[]).push([e,i]);for(let e of n.views.keys())t.views.has(e)||(i??=[]).push(e);let a,o;for(let[e,r]of t.payloads)n.payloads.get(e)!==r&&(a??=[]).push([e,r]);for(let e of n.payloads.keys())t.payloads.has(e)||(o??=[]).push(e);return{type:`PatchStreamSnapshot`,streamId:e,category:t.category,nextVersion:t.version??-1,expectedBaseVersion:n.version??-1,rootViewId:t.rootViewId,upsertViews:r,deleteViews:i,upsertPayloads:a,deletePayloads:o}}function Q(){K||=setTimeout(jn,Tn),q||=setTimeout(jn,En)}function $(e){G.push(e),Q()}function jn(){if(K&&=(clearTimeout(K),null),q&&=(clearTimeout(q),null),G.length===0&&X.size===0&&Z.size===0){J=0,Y=0;return}let e=[];for(let[t,n]of X)e.push({trackId:t,version:n.version,senderId:n.senderId});let t=[];for(let[e,n]of Z)t.push({trackId:e,senderId:n});let n={batchId:On(),createdAtMs:Dn(),ops:G,...e.length>0?{acks:e}:{},...t.length>0?{resyncs:t}:{},stats:{uiMessagesConsumed:J,bytesConsumed:Y}};G=[],J=0,Y=0,X.clear(),Z.clear(),self.postMessage(n)}function Mn(e){return`${e.senderId}_${e.trackId}`}async function Nn(e){let t=await jt(e),n=new Set;for(let e of Object.values(t.UIStreams??{})){let t=e.StreamId;n.add(t);let r=e.Info?.Category;V.getSnapshot(t)?.category!==r&&(V.setCategory(t,r),$({type:`SetStreamCategory`,streamId:t,category:r}))}for(let e of V.getSnapshots())W.has(e.streamId)||n.has(e.streamId)||(V.remove(e.streamId),U.delete(e.streamId),$({type:`RemoveStream`,streamId:e.streamId}))}function Pn(e){if(W.size!==0){for(let t of W)t!==e&&(V.remove(t),U.delete(t),$({type:`RemoveStream`,streamId:t}));W.clear()}}async function Fn(e){let t=r(e),n=Mn(t),i=A(await St(e)),a=X.get(t.trackId);(a===void 0||i.snapshot.version>a.version)&&(X.set(t.trackId,{version:i.snapshot.version,senderId:t.senderId}),Q());let o=V.apply(n,i);if(V.needsResync(n)&&(Z.set(t.trackId,t.senderId),Q()),!o)return;let s=V.getSnapshot(n);if(!s)return;let c=U.get(n);U.set(n,s),$(An(n,s,c)),Pn(n)}async function In(e){let t=await Ze(e);if(!t.StyleId)return;let n={styleId:t.StyleId,css:t.Style?.css,common:t.Style?.common},r=H.get(n.styleId);r&&r.css===n.css&&r.common===n.common||(H.set(n.styleId,n),$({type:`UpsertUiStyle`,style:n}))}async function Ln(e){let t=await it(e);if(t.Styles)for(let e of t.Styles){if(!e.StyleId)continue;let t={styleId:e.StyleId,css:e.Style?.css,common:e.Style?.common},n=H.get(t.styleId);n&&n.css===t.css&&n.common===t.common||(H.set(t.styleId,t),$({type:`UpsertUiStyle`,style:t}))}}async function Rn(e){let t=await gt(e);if(!(!t.StyleIds||t.StyleIds.length===0))for(let e of t.StyleIds)H.delete(e)&&$({type:`RemoveUiStyle`,styleId:e})}function zn(e){if(!V.getSnapshots().some(e=>e.rootViewId)){for(let t of e.styles){let e=H.get(t.styleId);e&&e.css===t.css&&e.common===t.common||(H.set(t.styleId,t),$({type:`UpsertUiStyle`,style:t}))}if(e.bootJson&&e.bootStreamId){let t=A({Json:e.bootJson});if(V.apply(e.bootStreamId,t)){let t=V.getSnapshot(e.bootStreamId);t&&(U.set(e.bootStreamId,t),W.add(e.bootStreamId),$({type:`ReplaceStreamSnapshot`,snapshot:kn(t),fromSeed:!0}))}}for(let t of e.liveStreams??[])if(V.applyStoreOp({type:`ReplaceStreamSnapshot`,snapshot:t})){let e=V.getSnapshot(t.streamId);e&&U.set(t.streamId,e),$({type:`ReplaceStreamSnapshot`,snapshot:t,fromSeed:!0})}V.enterSnapshotModeAll()}}async function Bn(e){let r=new Uint8Array(e);Y+=r.byteLength;let i=t(r);switch(n(i)){case C.CORE_GLOBAL_STATE:await Nn(i),J++;return;case C.UI_UPDATE:try{await Fn(i)}catch(e){e instanceof k;return}finally{J++}return;case C.UI_STYLES:await In(i),J++;return;case C.UI_STYLES_BATCH:await Ln(i),J++;return;case C.UI_STYLES_DELETE:await Rn(i),J++;return;default:return}}self.addEventListener(`message`,e=>{let t=e.data;if(t.type===`configure`){typeof t.flushIntervalMs==`number`&&Number.isFinite(t.flushIntervalMs)&&t.flushIntervalMs>=0&&(Tn=t.flushIntervalMs),typeof t.maxLatencyMs==`number`&&Number.isFinite(t.maxLatencyMs)&&t.maxLatencyMs>=0&&(En=t.maxLatencyMs);return}if(t.type===`clear`){G=[],U.clear(),X.clear(),Z.clear(),H.clear();for(let e of V.getSnapshots())V.remove(e.streamId);return}if(t.type===`snapshotMode`){V.enterSnapshotModeAll();return}if(t.type===`seed`){zn(t);return}t.type===`protocol`&&Bn(t.message).catch(()=>{})});
@@ -1 +1 @@
1
- const e={None:0,SendBackToSender:1,Delayable:2,SendToUser:4,Compressed:8,Unreliable:16};function t(e){let t=w(e),n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(t.length<27)throw Error(`Protocol payload too short`);let r=n.getUint32(0,!0),i=n.getUint32(4,!0),a=n.getUint32(8,!0),o=n.getUint32(12,!0),s=n.getUint32(16,!0),c=n.getUint32(20,!0),l=n.getUint8(24),u=n.getUint8(25),d=n.getUint8(26);if(27+c*4>t.length)throw Error(`Protocol header exceeds payload length`);let f=[],p=27;for(let e=0;e<c;e++)f.push(n.getUint32(p,!0)),p+=4;return{length:r,opcode:i,senderId:a,trackId:o,sequenceId:s,targetIds:f,payloadVersion:l,payloadType:u,flags:d}}async function n(n,i,a){let o=w(n),s=t(o);if(i!==void 0&&s.opcode!==i)throw Error(`Unexpected opcode ${s.opcode}`);if(s.payloadType!==8)throw Error(`Unexpected payload type ${s.payloadType}`);let c=27+s.targetIds.length*4,l=o.subarray(c,s.length);return(s.flags&e.Compressed)!==0&&(l=await r(l)),l}async function r(e){if(typeof DecompressionStream>`u`)throw Error(`DecompressionStream not supported`);let t=new DecompressionStream(`gzip`),n=t.writable.getWriter(),r=new Uint8Array(e);n.write(r).then(()=>n.close()).catch(()=>void 0);let i=t.readable.getReader(),a=[],o=0;for(;;){let{done:e,value:t}=await i.read();if(e)break;a.push(t),o+=t.length}let s=new Uint8Array(o),c=0;for(let e=0;e<a.length;e++)s.set(a[e],c),c+=a[e].length;return s}let i=function(e){return e[e.Null=1]=`Null`,e[e.Bool=2]=`Bool`,e[e.Int32=3]=`Int32`,e[e.Int64=4]=`Int64`,e[e.UInt32=5]=`UInt32`,e[e.UInt64=6]=`UInt64`,e[e.Float32=7]=`Float32`,e[e.Float64=8]=`Float64`,e[e.Array=9]=`Array`,e[e.Dict=10]=`Dict`,e[e.Object=11]=`Object`,e[e.String=12]=`String`,e[e.Binary=13]=`Binary`,e[e.Guid=14]=`Guid`,e}({});new TextEncoder;const a=new TextDecoder(`utf-8`,{fatal:!0});var o=class e{buffer;version;offset;end;constructor(e,t,n){this.buffer=e,this.version=t,this.offset=n,this.end=e.length-1}static create(t){let n=w(t);if(n.length<2)throw Error(`Teleport payload too short`);if(n[0]!==161||n[n.length-1]!==162)throw Error(`Teleport object missing markers`);let r={offset:1},i=m(n,r,`InvalidLength`);return new e(n,i,r.offset)}next(){if(this.offset>=this.end)return null;if(this.offset+5>this.buffer.length)throw Error(`Teleport object truncated`);let e=y(this.buffer,this.offset);this.offset+=4;let t=this.buffer[this.offset++],n=t>>4&15;if(t&15)throw Error(`Teleport field flags must be zero`);let r=g(n),i;if(r>=0)v(this.buffer,this.offset,r),i=this.buffer.subarray(this.offset,this.offset+r),this.offset+=r;else{let e={offset:this.offset},t=m(this.buffer,e,`InvalidLength`);v(this.buffer,e.offset,t),i=this.buffer.subarray(e.offset,e.offset+t),this.offset=e.offset+t}return new c(e,n,i)}},s=class{type;payload;constructor(e,t){this.type=e,this.payload=t}asInt32(){return this.ensureType(3),new DataView(this.payload.buffer,this.payload.byteOffset,4).getInt32(0,!0)}asUInt32(){return this.ensureType(5),new DataView(this.payload.buffer,this.payload.byteOffset,4).getUint32(0,!0)}asInt64(){return this.ensureType(4),new DataView(this.payload.buffer,this.payload.byteOffset,8).getBigInt64(0,!0)}asUInt64(){return this.ensureType(6),new DataView(this.payload.buffer,this.payload.byteOffset,8).getBigUint64(0,!0)}asFloat32(){return this.ensureType(7),new DataView(this.payload.buffer,this.payload.byteOffset,4).getFloat32(0,!0)}asFloat64(){return this.ensureType(8),new DataView(this.payload.buffer,this.payload.byteOffset,8).getFloat64(0,!0)}asBool(){return this.ensureType(2),this.payload.length>0&&this.payload[0]!==0}asBinary(){return this.ensureType(13),this.payload}asUtf8(){return this.ensureType(12),this.payload}asString(){return this.ensureType(12),a.decode(this.payload)}asGuid(){return this.ensureType(14),p.fromBytes(this.payload)}asObject(){return this.ensureType(11),o.create(this.payload)}asArray(){return this.ensureType(9),l.create(this.payload)}asDictionary(){return this.ensureType(10),d.create(this.payload)}ensureType(e){if(this.type!==e)throw Error(`Teleport value has type ${i[this.type]}, expected ${i[e]}`)}},c=class extends s{fieldId;constructor(e,t,n){super(t,n),this.fieldId=e}get isNull(){return this.type===1}},l=class e{payload;elementType;count;offset;index=0;constructor(e){if(this.payload=e,e.length===0)throw Error(`Array payload too short`);let t=e[0];if(this.elementType=t>>4&15,t&15)throw Error(`Array flags must be zero`);let n={offset:1};this.count=m(e,n,`ArrayMalformed`),this.offset=n.offset}static create(t){return new e(w(t))}next(){if(this.index>=this.count){if(this.offset!==this.payload.length)throw Error(`Array payload contains trailing data`);return null}let e=this.readValue();return this.index++,e}readValue(){switch(this.elementType){case 3:case 5:case 7:case 8:case 2:case 4:case 6:case 14:{let e=g(this.elementType);v(this.payload,this.offset,e);let t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new u(this.elementType,t)}case 12:case 13:{let e={offset:this.offset},t=m(this.payload,e,`ArrayMalformed`);v(this.payload,e.offset,t);let n=this.payload.subarray(e.offset,e.offset+t);return this.offset=e.offset+t,new u(this.elementType,n)}case 11:{let e={offset:this.offset},t=m(this.payload,e,`ArrayMalformed`);v(this.payload,e.offset,t);let n=this.payload.subarray(e.offset,e.offset+t);return this.offset=e.offset+t,new u(11,n)}case 9:{let e=b(this.payload,this.offset),t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new u(9,t)}case 10:{let e=x(this.payload,this.offset),t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new u(10,t)}default:throw Error(`Unsupported array element type ${i[this.elementType]}`)}}},u=class extends s{constructor(e,t){super(e,t)}},d=class e{payload;keyType;valueType;count;offset;index=0;constructor(e){if(this.payload=e,e.length<2)throw Error(`Dictionary payload too short`);if(this.keyType=e[0]>>4&15,this.valueType=e[1]>>4&15,e[0]&15||e[1]&15)throw Error(`Dictionary key/value flags must be zero`);_(this.keyType);let t={offset:2};this.count=m(e,t,`DictMalformed`),this.offset=t.offset}static create(t){return new e(w(t))}next(){if(this.index>=this.count){if(this.offset!==this.payload.length)throw Error(`Dictionary payload contains trailing data`);return null}let e=this.readKey(),t=this.readValue();return this.index++,new f(e,t)}readKey(){let e=g(this.keyType);if(e>=0){v(this.payload,this.offset,e);let t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new s(this.keyType,t)}if(this.keyType===12||this.keyType===13){let e={offset:this.offset},t=m(this.payload,e,`DictMalformed`);v(this.payload,e.offset,t);let n=this.payload.subarray(e.offset,e.offset+t);return this.offset=e.offset+t,new s(this.keyType,n)}throw Error(`Unsupported dictionary key type`)}readValue(){switch(this.valueType){case 12:case 13:{let e={offset:this.offset},t=m(this.payload,e,`DictMalformed`);v(this.payload,e.offset,t);let n=this.payload.subarray(e.offset,e.offset+t);return this.offset=e.offset+t,new s(this.valueType,n)}case 11:{let e={offset:this.offset},t=m(this.payload,e,`DictMalformed`);v(this.payload,e.offset,t);let n=this.payload.subarray(e.offset,e.offset+t);return this.offset=e.offset+t,new s(11,n)}case 9:{let e=b(this.payload,this.offset),t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new s(9,t)}case 10:{let e=x(this.payload,this.offset),t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new s(10,t)}case 3:case 5:case 7:case 8:case 2:case 4:case 6:case 14:case 1:{let e=g(this.valueType);v(this.payload,this.offset,e);let t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new s(this.valueType,t)}default:throw Error(`Unsupported dictionary value type ${i[this.valueType]}`)}}},f=class{key;value;constructor(e,t){this.key=e,this.value=t}},p=class e{bytes;constructor(e){this.bytes=e}static fromString(t){if(!t)throw Error(`Guid string is empty`);let n=t.replace(/-/g,``);if(n.length!==32)throw Error(`Guid string must be 32 hex characters`);let r=new Uint8Array(16),i=e.parseHexSlice(n,0,8),a=e.parseHexSlice(n,8,4),o=e.parseHexSlice(n,12,4);e.writeUInt32LE(r,0,i),e.writeUInt16LE(r,4,a),e.writeUInt16LE(r,6,o);for(let t=0;t<8;t++)r[8+t]=e.parseHexSlice(n,16+t*2,2);return new e(r)}static fromBytes(t){if(t.length!==16)throw Error(`Guid byte array must be 16 bytes`);return new e(Uint8Array.from(t))}static createZero(){return new e(new Uint8Array(16))}static createRandom(){let t=new Uint8Array(16),n=globalThis.crypto;if(n?.getRandomValues)n.getRandomValues(t);else for(let e=0;e<t.length;e++)t[e]=Math.floor(Math.random()*256);return t[6]=t[6]&15|64,t[8]=t[8]&63|128,new e(t)}toString(){let t=this.bytes;return[e.toHex(e.readUInt32LE(t,0),8),e.toHex(e.readUInt16LE(t,4),4),e.toHex(e.readUInt16LE(t,6),4),C(t.subarray(8,10)),C(t.subarray(10,16))].join(`-`)}asBytes(){return this.bytes.slice()}static parseHexSlice(e,t,n){let r=e.substr(t,n),i=Number.parseInt(r,16);if(Number.isNaN(i))throw Error(`Guid string contains invalid characters`);return i>>>0}static writeUInt32LE(e,t,n){let r=n>>>0;e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24&255}static writeUInt16LE(e,t,n){let r=n&65535;e[t]=r&255,e[t+1]=r>>>8&255}static readUInt32LE(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}static readUInt16LE(e,t){return(e[t]|e[t+1]<<8)&65535}static toHex(e,t){return(e>>>0).toString(16).padStart(t,`0`)}};function m(e,t,n){if(t.offset>=e.length)throw Error(n);let r=0,i=0,a=0;for(;t.offset<e.length;){let n=e[t.offset++];if(a++,r|=(n&127)<<i,!(n&128)){if(a!==h(r))throw Error(`Teleport VarUInt is not canonical`);return r>>>0}if(i+=7,i>=35)throw Error(`Teleport VarUInt exceeds 32-bit range`)}throw Error(n)}function h(e){return e<128?1:e<16384?2:e<2097152?3:e<268435456?4:5}function g(e){switch(e){case 3:case 5:case 7:return 4;case 4:case 6:case 8:return 8;case 14:return 16;case 2:return 1;case 1:return 0;default:return-1}}function _(e){if(e===9||e===11||e===10||e===1)throw Error(`Dictionary keys must be primitive Teleport types`)}function v(e,t,n){if(t<0||n<0||t+n>e.length)throw Error(`Teleport payload exceeds bounds`)}function y(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function b(e,t){if(t>=e.length)throw Error(`Array payload exceeds bounds`);let n=e[t],r=n>>4&15;if(n&15)throw Error(`Array flags must be zero`);let i={offset:t+1},a=m(e,i,`ArrayMalformed`),o=g(r);if(o>=0){let n=o*a;return v(e,i.offset,n),i.offset+n-t}let s=i.offset;for(let t=0;t<a;t++)s=S(r,e,s,`ArrayMalformed`);return s-t}function x(e,t){if(t+2>e.length)throw Error(`Dictionary payload too short`);let n=e[t]>>4&15,r=e[t+1]>>4&15;if(e[t]&15||e[t+1]&15)throw Error(`Dictionary key/value flags must be zero`);_(n);let i={offset:t+2},a=m(e,i,`DictMalformed`),o=i.offset;for(let t=0;t<a;t++)o=S(n,e,o,`DictMalformed`),o=S(r,e,o,`DictMalformed`);return o-t}function S(e,t,n,r){let a=g(e);if(a>=0)return v(t,n,a),n+a;switch(e){case 12:case 13:{let e={offset:n},i=m(t,e,r);return v(t,e.offset,i),e.offset+i}case 11:{let e={offset:n},i=m(t,e,r);return v(t,e.offset,i),e.offset+i}case 9:return n+b(t,n);case 10:return n+x(t,n);default:throw Error(`Unsupported Teleport type ${i[e]}`)}}function C(e){return Array.from(e).map(e=>e.toString(16).padStart(2,`0`)).join(``)}function w(e){return e instanceof Uint8Array?e:new Uint8Array(e)}let T=function(e){return e[e.Unknown=0]=`Unknown`,e[e.H264=1]=`H264`,e[e.Vp8=2]=`Vp8`,e[e.Vp9=3]=`Vp9`,e[e.Av1=4]=`Av1`,e}({}),E=function(e){return e[e.NONE=0]=`NONE`,e[e.CONSTANT_GROUP_BITS=15]=`CONSTANT_GROUP_BITS`,e[e.CONSTANT_GROUP_OFFSET=16]=`CONSTANT_GROUP_OFFSET`,e[e.GROUP_CORE=65536]=`GROUP_CORE`,e[e.CORE_AUTH_RESPONSE=65537]=`CORE_AUTH_RESPONSE`,e[e.CORE_AUTH_TICKET=65538]=`CORE_AUTH_TICKET`,e[e.CORE_GLOBAL_STATE=65539]=`CORE_GLOBAL_STATE`,e[e.CORE_ON_SERVER_STATUS_PING=65540]=`CORE_ON_SERVER_STATUS_PING`,e[e.CORE_ON_USER_JOINED=65541]=`CORE_ON_USER_JOINED`,e[e.CORE_ON_USER_LEFT=65542]=`CORE_ON_USER_LEFT`,e[e.CORE_ON_CLIENT_JOINED=65543]=`CORE_ON_CLIENT_JOINED`,e[e.CORE_ON_CLIENT_LEFT=65544]=`CORE_ON_CLIENT_LEFT`,e[e.CORE_ON_SERVER_STARTED=65545]=`CORE_ON_SERVER_STARTED`,e[e.CORE_ON_SERVER_STOPPED=65546]=`CORE_ON_SERVER_STOPPED`,e[e.CORE_ON_SERVER_STOPPING=65547]=`CORE_ON_SERVER_STOPPING`,e[e.CORE_ON_CLIENT_READY=65548]=`CORE_ON_CLIENT_READY`,e[e.CORE_CLIENT_READY=65549]=`CORE_CLIENT_READY`,e[e.CORE_SERVER_INIT=65550]=`CORE_SERVER_INIT`,e[e.CORE_ON_PLUGIN_RELOADED=65551]=`CORE_ON_PLUGIN_RELOADED`,e[e.CORE_DYNAMIC_CONFIG=65555]=`CORE_DYNAMIC_CONFIG`,e[e.CORE_PROXY_RPC_AUTH_TICKET=65556]=`CORE_PROXY_RPC_AUTH_TICKET`,e[e.CORE_UPDATE_CLIENT_CONTEXT=65558]=`CORE_UPDATE_CLIENT_CONTEXT`,e[e.CORE_BACKGROUND_WORK_ACTIVE=65559]=`CORE_BACKGROUND_WORK_ACTIVE`,e[e.CORE_RESET_IDLE=65560]=`CORE_RESET_IDLE`,e[e.CORE_CLIENT_DISCONNECTING=65561]=`CORE_CLIENT_DISCONNECTING`,e[e.CORE_ON_APP_READY=65562]=`CORE_ON_APP_READY`,e[e.CORE_ON_FRONTEND_RELOADED=65563]=`CORE_ON_FRONTEND_RELOADED`,e[e.CORE_ON_USER_DATA_ERASED=65564]=`CORE_ON_USER_DATA_ERASED`,e[e.CORE_WEBRTC_OFFER=65566]=`CORE_WEBRTC_OFFER`,e[e.CORE_WEBRTC_ANSWER=65567]=`CORE_WEBRTC_ANSWER`,e[e.CORE_WEBRTC_ICE_CANDIDATE=65568]=`CORE_WEBRTC_ICE_CANDIDATE`,e[e.CORE_WEBRTC_READY=65569]=`CORE_WEBRTC_READY`,e[e.CORE_WEBRTC_AUDIO_SEGMENT=65570]=`CORE_WEBRTC_AUDIO_SEGMENT`,e[e.CORE_WEBRTC_TRACK_MAP=65571]=`CORE_WEBRTC_TRACK_MAP`,e[e.CORE_WEBRTC_VIDEO_CAPTURE=65572]=`CORE_WEBRTC_VIDEO_CAPTURE`,e[e.CORE_WEBRTC_ICE_SERVERS_REQUEST=65573]=`CORE_WEBRTC_ICE_SERVERS_REQUEST`,e[e.CORE_WEBRTC_ICE_SERVERS_RESPONSE=65574]=`CORE_WEBRTC_ICE_SERVERS_RESPONSE`,e[e.CORE_WEBRTC_CLOSE=65575]=`CORE_WEBRTC_CLOSE`,e[e.CORE_RELAY_AGENT_AUTH=65576]=`CORE_RELAY_AGENT_AUTH`,e[e.CORE_RELAY_AGENT_AUTH_RESULT=65577]=`CORE_RELAY_AGENT_AUTH_RESULT`,e[e.CORE_RELAY_HEARTBEAT=65578]=`CORE_RELAY_HEARTBEAT`,e[e.CORE_RELAY_TCP_CONNECTION_OPENED=65579]=`CORE_RELAY_TCP_CONNECTION_OPENED`,e[e.CORE_RELAY_TCP_CONNECTION_CLOSED=65580]=`CORE_RELAY_TCP_CONNECTION_CLOSED`,e[e.CORE_RELAY_TCP_DATA=65581]=`CORE_RELAY_TCP_DATA`,e[e.CORE_RELAY_UDP_DATA=65582]=`CORE_RELAY_UDP_DATA`,e[e.CORE_RELAY_ADD_TUNNEL=65583]=`CORE_RELAY_ADD_TUNNEL`,e[e.CORE_RELAY_TUNNEL_ADDED=65584]=`CORE_RELAY_TUNNEL_ADDED`,e[e.CORE_RELAY_REMOVE_TUNNEL=65585]=`CORE_RELAY_REMOVE_TUNNEL`,e[e.CORE_IKON_SERVER_ENDPOINT_HOST_INFO=65586]=`CORE_IKON_SERVER_ENDPOINT_HOST_INFO`,e[e.CORE_CLIENT_INITIALIZATION=65587]=`CORE_CLIENT_INITIALIZATION`,e[e.CORE_CLIENT_LIFECYCLE_BATCH=65588]=`CORE_CLIENT_LIFECYCLE_BATCH`,e[e.CORE_APP_CONFIG=65589]=`CORE_APP_CONFIG`,e[e.GROUP_KEEPALIVE=131072]=`GROUP_KEEPALIVE`,e[e.KEEPALIVE_REQUEST=131073]=`KEEPALIVE_REQUEST`,e[e.KEEPALIVE_RESPONSE=131074]=`KEEPALIVE_RESPONSE`,e[e.GROUP_EVENTS=262144]=`GROUP_EVENTS`,e[e.EVENTS_PROFILE_UPDATE=262145]=`EVENTS_PROFILE_UPDATE`,e[e.EVENTS_SPEECH_PLAYBACK_COMPLETE=262147]=`EVENTS_SPEECH_PLAYBACK_COMPLETE`,e[e.GROUP_ANALYTICS=524288]=`GROUP_ANALYTICS`,e[e.ANALYTICS_LOGS=524289]=`ANALYTICS_LOGS`,e[e.ANALYTICS_EVENTS=524290]=`ANALYTICS_EVENTS`,e[e.ANALYTICS_USAGES=524291]=`ANALYTICS_USAGES`,e[e.ANALYTICS_USAGE=524292]=`ANALYTICS_USAGE`,e[e.ANALYTICS_SPECIAL_LOG=524293]=`ANALYTICS_SPECIAL_LOG`,e[e.ANALYTICS_PROCESSING_UPDATE=524294]=`ANALYTICS_PROCESSING_UPDATE`,e[e.ANALYTICS_REACTIVE_PROCESSING_UPDATE=524295]=`ANALYTICS_REACTIVE_PROCESSING_UPDATE`,e[e.ANALYTICS_IKON_PROXY_SERVER_STATS=524296]=`ANALYTICS_IKON_PROXY_SERVER_STATS`,e[e.ANALYTICS_IKON_RELAY_SERVER_STATS=524297]=`ANALYTICS_IKON_RELAY_SERVER_STATS`,e[e.ANALYTICS_IKON_TURN_SERVER_STATS=524298]=`ANALYTICS_IKON_TURN_SERVER_STATS`,e[e.ANALYTICS_IKON_HOST_SERVER_STATS=524299]=`ANALYTICS_IKON_HOST_SERVER_STATS`,e[e.GROUP_ACTIONS=1048576]=`GROUP_ACTIONS`,e[e.ACTION_CALL=1048577]=`ACTION_CALL`,e[e.ACTION_ACTIVE=1048578]=`ACTION_ACTIVE`,e[e.ACTION_TEXT_OUTPUT=1048579]=`ACTION_TEXT_OUTPUT`,e[e.ACTION_TEXT_OUTPUT_DELTA=1048580]=`ACTION_TEXT_OUTPUT_DELTA`,e[e.ACTION_TEXT_OUTPUT_DELTA_FULL=1048581]=`ACTION_TEXT_OUTPUT_DELTA_FULL`,e[e.ACTION_SET_STATE=1048582]=`ACTION_SET_STATE`,e[e.ACTION_TAP=1048583]=`ACTION_TAP`,e[e.ACTION_PAN=1048584]=`ACTION_PAN`,e[e.ACTION_ZOOM=1048585]=`ACTION_ZOOM`,e[e.ACTION_FILE_UPLOAD_BEGIN=1048586]=`ACTION_FILE_UPLOAD_BEGIN`,e[e.ACTION_FILE_UPLOAD_DATA=1048587]=`ACTION_FILE_UPLOAD_DATA`,e[e.ACTION_FILE_UPLOAD_ACK=1048588]=`ACTION_FILE_UPLOAD_ACK`,e[e.ACTION_FILE_UPLOAD_END=1048589]=`ACTION_FILE_UPLOAD_END`,e[e.ACTION_FILE_UPLOAD_RESULT=1048590]=`ACTION_FILE_UPLOAD_RESULT`,e[e.ACTION_OPEN_EXTERNAL_URL=1048592]=`ACTION_OPEN_EXTERNAL_URL`,e[e.ACTION_FUNCTION_REGISTER=1048600]=`ACTION_FUNCTION_REGISTER`,e[e.ACTION_FUNCTION_CALL=1048601]=`ACTION_FUNCTION_CALL`,e[e.ACTION_FUNCTION_RESULT=1048602]=`ACTION_FUNCTION_RESULT`,e[e.ACTION_GENERATE_ANSWER=1048603]=`ACTION_GENERATE_ANSWER`,e[e.ACTION_REGENERATE_ANSWER=1048604]=`ACTION_REGENERATE_ANSWER`,e[e.ACTION_CLEAR_STATE=1048606]=`ACTION_CLEAR_STATE`,e[e.ACTION_CLASSIFICATION_RESULT=1048609]=`ACTION_CLASSIFICATION_RESULT`,e[e.ACTION_AUDIO_STOP=1048610]=`ACTION_AUDIO_STOP`,e[e.ACTION_CALL_TEXT=1048611]=`ACTION_CALL_TEXT`,e[e.ACTION_CANCEL_GENERATION=1048613]=`ACTION_CANCEL_GENERATION`,e[e.ACTION_SPEECH_RECOGNIZED=1048615]=`ACTION_SPEECH_RECOGNIZED`,e[e.ACTION_CALL_RESULT=1048616]=`ACTION_CALL_RESULT`,e[e.ACTION_DOWNLOAD=1048618]=`ACTION_DOWNLOAD`,e[e.ACTION_PLAY_SOUND=1048621]=`ACTION_PLAY_SOUND`,e[e.ACTION_STOP_SOUND=1048623]=`ACTION_STOP_SOUND`,e[e.ACTION_START_RECORDING=1048624]=`ACTION_START_RECORDING`,e[e.ACTION_STOP_RECORDING=1048625]=`ACTION_STOP_RECORDING`,e[e.ACTION_FUNCTION_ENUMERATION_ITEM=1048627]=`ACTION_FUNCTION_ENUMERATION_ITEM`,e[e.ACTION_FUNCTION_ENUMERATION_END=1048628]=`ACTION_FUNCTION_ENUMERATION_END`,e[e.ACTION_FUNCTION_CANCEL=1048629]=`ACTION_FUNCTION_CANCEL`,e[e.ACTION_FUNCTION_DISPOSE=1048630]=`ACTION_FUNCTION_DISPOSE`,e[e.ACTION_FUNCTION_ERROR=1048631]=`ACTION_FUNCTION_ERROR`,e[e.ACTION_FUNCTION_ACK=1048632]=`ACTION_FUNCTION_ACK`,e[e.ACTION_FUNCTION_AWAITING_APPROVAL=1048633]=`ACTION_FUNCTION_AWAITING_APPROVAL`,e[e.ACTION_FUNCTION_APPROVAL_REQUIRED=1048634]=`ACTION_FUNCTION_APPROVAL_REQUIRED`,e[e.ACTION_FUNCTION_APPROVAL_RESPONSE=1048635]=`ACTION_FUNCTION_APPROVAL_RESPONSE`,e[e.UI_UPDATE_ACK=1048636]=`UI_UPDATE_ACK`,e[e.ACTION_CALL2=1048637]=`ACTION_CALL2`,e[e.ACTION_FUNCTION_REGISTER_BATCH=1048638]=`ACTION_FUNCTION_REGISTER_BATCH`,e[e.ACTION_FILE_UPLOAD_CALLBACK=1048640]=`ACTION_FILE_UPLOAD_CALLBACK`,e[e.ACTION_CUSTOM_USER_MESSAGE=1048641]=`ACTION_CUSTOM_USER_MESSAGE`,e[e.ACTION_URL_CHANGED=1048642]=`ACTION_URL_CHANGED`,e[e.ACTION_FILE_UPLOAD_PRE_START2=1048643]=`ACTION_FILE_UPLOAD_PRE_START2`,e[e.ACTION_FILE_UPLOAD_PRE_START_RESPONSE2=1048644]=`ACTION_FILE_UPLOAD_PRE_START_RESPONSE2`,e[e.ACTION_FILE_UPLOAD_START2=1048645]=`ACTION_FILE_UPLOAD_START2`,e[e.ACTION_FILE_UPLOAD_START_RESPONSE2=1048646]=`ACTION_FILE_UPLOAD_START_RESPONSE2`,e[e.ACTION_FILE_UPLOAD_DATA2=1048647]=`ACTION_FILE_UPLOAD_DATA2`,e[e.ACTION_FILE_UPLOAD_ACK2=1048648]=`ACTION_FILE_UPLOAD_ACK2`,e[e.ACTION_FILE_UPLOAD_END2=1048649]=`ACTION_FILE_UPLOAD_END2`,e[e.ACTION_FILE_UPLOAD_COMPLETE2=1048650]=`ACTION_FILE_UPLOAD_COMPLETE2`,e[e.ACTION_FUNCTION_ENUMERATION_ITEM_BATCH=1048651]=`ACTION_FUNCTION_ENUMERATION_ITEM_BATCH`,e[e.ACTION_CALL_ACK=1048652]=`ACTION_CALL_ACK`,e[e.ACTION_TRIGGER_CRON=1048653]=`ACTION_TRIGGER_CRON`,e[e.ACTION_RESULT=1048654]=`ACTION_RESULT`,e[e.UI_RESYNC_REQUEST=1048655]=`UI_RESYNC_REQUEST`,e[e.ACTION_USER_DATA_ERASURE=1048656]=`ACTION_USER_DATA_ERASURE`,e[e.GROUP_UI=2097152]=`GROUP_UI`,e[e.UI_STREAM_BEGIN=2097153]=`UI_STREAM_BEGIN`,e[e.UI_STREAM_END=2097154]=`UI_STREAM_END`,e[e.UI_STYLES=2097188]=`UI_STYLES`,e[e.UI_UPDATE=2097190]=`UI_UPDATE`,e[e.UI_STYLES_BATCH=2097192]=`UI_STYLES_BATCH`,e[e.UI_STYLES_DELETE=2097193]=`UI_STYLES_DELETE`,e[e.GROUP_COMMON=4128768]=`GROUP_COMMON`,e[e.GROUP_AUDIO=4194304]=`GROUP_AUDIO`,e[e.AUDIO_STREAM_BEGIN=4194305]=`AUDIO_STREAM_BEGIN`,e[e.AUDIO_STREAM_END=4194306]=`AUDIO_STREAM_END`,e[e.AUDIO_FRAME=4194307]=`AUDIO_FRAME`,e[e.AUDIO_FRAME_VOLUME=4194308]=`AUDIO_FRAME_VOLUME`,e[e.AUDIO_FRAME2=4194309]=`AUDIO_FRAME2`,e[e.AUDIO_SHAPE_FRAME=4194310]=`AUDIO_SHAPE_FRAME`,e[e.AUDIO_PLAYBACK_REPORT=4194311]=`AUDIO_PLAYBACK_REPORT`,e[e.GROUP_VIDEO=8388608]=`GROUP_VIDEO`,e[e.VIDEO_STREAM_BEGIN=8388609]=`VIDEO_STREAM_BEGIN`,e[e.VIDEO_STREAM_END=8388610]=`VIDEO_STREAM_END`,e[e.VIDEO_FRAME=8388611]=`VIDEO_FRAME`,e[e.VIDEO_REQUEST_IDR_FRAME=8388612]=`VIDEO_REQUEST_IDR_FRAME`,e[e.VIDEO_INVALIDATE_FRAME=8388613]=`VIDEO_INVALIDATE_FRAME`,e[e.GROUP_ALL=16711680]=`GROUP_ALL`,e[e.GROUP_APP_LOCAL=1073741824]=`GROUP_APP_LOCAL`,e[e.CONSTANT_GROUP_MASK=2147418112]=`CONSTANT_GROUP_MASK`,e}({});function D(e){let t={};return O(t),e&&Object.assign(t,e),t}function O(e){return e.Data=new Uint8Array,e.FrameNumber=0,e.IsKey=!1,e.TimestampInUs=BigInt(0),e.DurationInUs=0,e}function k(e,t){return A(o.create(e),t)}function A(e,t){let n=t??D();return O(n),ee(e,n),n}function ee(e,t){let n;for(;(n=e.next())!==null;)switch(n.fieldId){case 271275304:if(n.isNull)throw Error();t.TimestampInUs=n.asUInt64();break;case 2541432218:if(n.isNull)throw Error();t.DurationInUs=n.asUInt32();break;case 2986785889:if(n.isNull)throw Error();t.Data=n.asBinary();break;case 3105403172:if(n.isNull)throw Error();t.IsKey=n.asBool();break;case 3456383222:if(n.isNull)throw Error();t.FrameNumber=n.asInt32();break;default:break}}async function te(e,t){return k(await n(e,8388611,1),t)}function ne(e){let t={};return j(t),e&&Object.assign(t,e),t}function j(e){return e.StreamId=``,e.Description=``,e.SourceType=``,e.Codec=T.H264,e.CodecDetails=``,e.Width=0,e.Height=0,e.Framerate=30,e.CorrelationId=void 0,e}function M(e,t){return N(o.create(e),t)}function N(e,t){let n=t??ne();return j(n),P(e,n),n}function P(e,t){let n;for(;(n=e.next())!==null;)switch(n.fieldId){case 161083277:if(n.isNull)throw Error();t.StreamId=n.asString();break;case 164808083:if(n.isNull)throw Error();t.Framerate=n.asFloat64();break;case 1368629611:if(n.isNull)throw Error();t.Description=n.asString();break;case 2514959030:if(n.isNull){t.CorrelationId=void 0;break}t.CorrelationId=n.asString();break;case 2745379226:if(n.isNull)throw Error();t.CodecDetails=n.asString();break;case 2950031986:if(n.isNull)throw Error();t.Height=n.asInt32();break;case 3282782683:if(n.isNull)throw Error();t.SourceType=n.asString();break;case 3284746250:if(n.isNull)throw Error();t.Codec=n.asInt32();break;case 4065070594:if(n.isNull)throw Error();t.Width=n.asInt32();break;default:break}}async function F(e,t){return M(await n(e,8388609,6),t)}const I=(e,t)=>self.postMessage(e,t??[]);let L=null,R=!0,z=!1;const B=new Map,V=new Map;function H(e){e.hasPainted||(e.hasPainted=!0,I({type:`log`,message:`first frame painted for ${e.streamId}`}))}function U(e){let t=e instanceof Error?e:Error(String(e));I({type:`error`,error:{name:t.name,message:t.message,stack:t.stack}})}function W(e,t){return e<<16|t&65535}function G(e){let t=B.get(e);if(t)return t;let n={streamId:e,numericKey:0,watched:!1,surface:null,ctx2d:null,codec:null,width:0,height:0,framerate:0,decoder:null,decoderCodec:null,decoderWidth:0,decoderHeight:0,isKeyFrameRequired:!0,isReconfiguring:!1,pendingDecodeCount:0,hasPainted:!1};return B.set(e,n),n}function K(e){if(e===T.H264)return`avc1.42E01E`;if(e===T.Vp8)return`vp8`;if(e===T.Vp9)return`vp09.00.10.08`;if(e===T.Av1)return`av01.0.04M.08`;throw Error(`Unknown codec: ${e}`)}function q(e){let t=B.get(e);if(!t||t.numericKey===0)return;let n=t.numericKey>>16&65535,r=t.numericKey&65535;I({type:`requestIdr`,streamId:e,senderId:n,trackId:r})}async function re(e,t){try{if(!R||!e.watched)return;if(typeof createImageBitmap==`function`){let n=await createImageBitmap(t);I({type:`frame`,streamId:e.streamId,width:e.width,height:e.height,bitmap:n},[n]),H(e)}}catch(e){U(e)}finally{e.pendingDecodeCount--;try{t.close()}catch{}}}async function ie(e,t,n){let r={codec:e,codedWidth:t>0?t:void 0,codedHeight:n>0?n:void 0,optimizeForLatency:!0};if(typeof VideoDecoder?.isConfigSupported!=`function`)return{config:{...r,hardwareAcceleration:`prefer-hardware`},isHardwareAccelerated:!0};let i={...r,hardwareAcceleration:`prefer-hardware`};try{let e=await VideoDecoder.isConfigSupported(i);if(e.supported)return{config:e.config??i,isHardwareAccelerated:!0}}catch{}try{let e=await VideoDecoder.isConfigSupported(r);if(e.supported)return{config:e.config??r,isHardwareAccelerated:!1}}catch{}return null}function J(e){return new VideoDecoder({output:t=>{if(e.pendingDecodeCount++,!R||!e.watched){e.pendingDecodeCount--;try{t.close()}catch{}return}if(e.pendingDecodeCount>8){e.pendingDecodeCount--;try{t.close()}catch{}return}let n=e.width,r=e.height;if(e.ctx2d&&e.surface){try{e.ctx2d.drawImage(t,0,0,n,r),H(e)}catch(e){U(e)}finally{e.pendingDecodeCount--;try{t.close()}catch{}}return}re(e,t)},error:t=>{if(U(t),e.isKeyFrameRequired=!0,e.decoder&&e.decoder.state!==`closed`)try{e.decoder.close()}catch{}e.decoder=null,e.decoderCodec=null,q(e.streamId)}})}async function Y(e){if(e.codec==null||z){e.isReconfiguring=!1;return}let t=K(e.codec);(!e.decoder||e.decoder.state===`closed`)&&(e.decoder&&(e.decoderCodec=null,e.decoderWidth=0,e.decoderHeight=0),e.decoder=J(e));let n=e.decoderCodec!==null&&e.decoderCodec!==t;if(!(e.decoderCodec!==t||e.decoderWidth!==e.width||e.decoderHeight!==e.height)){e.isReconfiguring=!1;return}if(e.isReconfiguring=!0,e.decoderCodec=null,n&&e.decoder){try{e.decoder.close()}catch{}e.decoder=J(e)}try{let n=await ie(t,e.width,e.height);if(K(e.codec)!==t){if(e.decoder&&e.decoder.state!==`closed`)try{e.decoder.close()}catch{}e.decoder=null,e.decoderCodec=null,e.decoderWidth=0,e.decoderHeight=0;return}if(!n){U(Error(`Decoder not supported for codec ${t}`));return}(!e.decoder||e.decoder.state===`closed`)&&(e.decoder=J(e)),e.decoderCodec=t,e.decoderWidth=e.width,e.decoderHeight=e.height;try{e.decoder.configure(n.config),e.isKeyFrameRequired=!0,q(e.streamId);let r=n.isHardwareAccelerated?`hardware`:`software`,i=e.framerate>0?`@${Math.round(e.framerate)}fps`:``;I({type:`debug`,message:`Decoder configured: codec=${t}, ${e.width}x${e.height}${i}, hw=${r}`})}catch(e){U(e)}e.surface&&e.ctx2d&&e.width>0&&e.height>0&&(e.surface.width!==e.width||e.surface.height!==e.height)&&(e.surface.width=e.width,e.surface.height=e.height)}finally{e.isReconfiguring=!1}}async function ae(e,t){let n=await F(e);X(W(t.senderId,t.trackId),n)}function X(e,t){let n=t.StreamId,r=G(n);r.numericKey=e,r.codec=t.Codec,r.width=t.Width,r.height=t.Height,r.framerate=t.Framerate,V.set(e,n),I({type:`streamBegin`,streamId:n,width:t.Width,height:t.Height,codec:t.Codec}),r.watched?(r.surface&&r.ctx2d&&t.Width>0&&t.Height>0&&(r.surface.width!==t.Width||r.surface.height!==t.Height)&&(r.surface.width=t.Width,r.surface.height=t.Height),Y(r)):r.isReconfiguring=!1}function oe(e){let t=W(e.senderId,e.trackId),n=V.get(t);if(!n)return;I({type:`streamEnd`,streamId:n});let r=B.get(n);if(!r){V.delete(t);return}if(r.decoder)try{r.decoder.close()}catch{}B.delete(n),V.delete(t)}function Z(e){let t=B.get(e);t&&(t.surface=null,t.ctx2d=null)}function Q(e){let t=B.get(e);if(t){if(t.watched=!1,t.isKeyFrameRequired=!0,Z(e),t.decoder){try{t.decoder.close()}catch{}t.decoder=null,t.decoderCodec=null,t.decoderWidth=0,t.decoderHeight=0}t.isReconfiguring=!1}}async function se(e,t){let n=W(t.senderId,t.trackId),r=V.get(n);if(!r)return;let i=B.get(r);if(!i||!R||!i.watched||i.isReconfiguring||((!i.decoder||!i.decoderCodec)&&Y(i),!i.decoder||!i.decoderCodec))return;let a=await te(e);if(!(i.isReconfiguring||!i.decoder||!i.decoderCodec)&&i.decoder.state!==`closed`){if(i.isKeyFrameRequired){if(!a.IsKey)return;i.isKeyFrameRequired=!1}try{if(i.decoder.state===`closed`)return;i.decoder.decode(new EncodedVideoChunk({type:a.IsKey?`key`:`delta`,timestamp:Number(a.TimestampInUs),duration:a.DurationInUs,data:a.Data}))}catch(e){if(e instanceof DOMException&&e.message.includes(`closed`))return;i.isKeyFrameRequired=!0,q(i.streamId),U(e)}}}function ce(e){let t=W(e.senderId,e.trackId),n=V.get(t);if(!n)return;let r=B.get(n);r&&(r.isKeyFrameRequired=!0,r.watched&&q(r.streamId))}function le(e,t){switch(t.opcode){case E.VIDEO_STREAM_BEGIN:{let n=W(t.senderId,t.trackId),r=V.get(n);if(r){let e=B.get(r);e&&(e.isReconfiguring=!0)}ae(e,t);return}case E.VIDEO_STREAM_END:oe(t);return;case E.VIDEO_FRAME:se(e,t);return;case E.VIDEO_INVALIDATE_FRAME:ce(t);return;default:return}}function $(){if(L){try{L.close()}catch{}L=null}}function ue(){$();for(let e of B.values())Q(e.streamId);B.clear(),V.clear()}self.addEventListener(`message`,e=>{let t=e.data;if(t.type===`configure`){z=t.webRtcEnabled??!1;return}if(t.type===`setWebRtcEnabled`){if(z=t.enabled,!z)for(let e of B.values())e.watched&&(e.isKeyFrameRequired=!0,Y(e),q(e.streamId));return}if(t.type===`syncStreams`){for(let e of t.streams){let t=W(e.senderId,e.trackId);V.has(t)||X(t,e.info)}return}if(t.type===`attachSurface`){let e=t.streamId,n=G(e);n.watched=!0,n.surface=t.canvas;try{n.ctx2d=n.surface.getContext(`2d`,{alpha:!1,desynchronized:!0})}catch(e){U(e),n.ctx2d=null}n.isKeyFrameRequired=!0,Y(n),q(e);return}if(t.type===`detachSurface`){Z(t.streamId);return}if(t.type===`attachProtocolPort`){$(),L=t.port,L.addEventListener(`message`,e=>{let t=e.data;t?.type===`protocol`&&t.message instanceof ArrayBuffer&&t.headers&&le(new Uint8Array(t.message),t.headers)}),L.start?.();return}if(t.type===`watchStream`){let e=G(t.streamId);e.watched=!0,e.isKeyFrameRequired=!0,Y(e),q(e.streamId);return}if(t.type===`unwatchStream`){Q(t.streamId);return}if(t.type===`setEnabled`){if(R=t.enabled,R)for(let e of B.values())e.watched&&(e.isKeyFrameRequired=!0,Y(e),q(e.streamId));return}t.type===`dispose`&&ue()});
1
+ const e={None:0,SendBackToSender:1,Delayable:2,SendToUser:4,Compressed:8,Unreliable:16};function t(e){let t=w(e),n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(t.length<27)throw Error(`Protocol payload too short`);let r=n.getUint32(0,!0),i=n.getUint32(4,!0),a=n.getUint32(8,!0),o=n.getUint32(12,!0),s=n.getUint32(16,!0),c=n.getUint32(20,!0),l=n.getUint8(24),u=n.getUint8(25),d=n.getUint8(26);if(27+c*4>t.length)throw Error(`Protocol header exceeds payload length`);let f=[],p=27;for(let e=0;e<c;e++)f.push(n.getUint32(p,!0)),p+=4;return{length:r,opcode:i,senderId:a,trackId:o,sequenceId:s,targetIds:f,payloadVersion:l,payloadType:u,flags:d}}async function n(n,i,a){let o=w(n),s=t(o);if(i!==void 0&&s.opcode!==i)throw Error(`Unexpected opcode ${s.opcode}`);if(s.payloadType!==8)throw Error(`Unexpected payload type ${s.payloadType}`);let c=27+s.targetIds.length*4,l=o.subarray(c,s.length);return(s.flags&e.Compressed)!==0&&(l=await r(l)),l}async function r(e){if(typeof DecompressionStream>`u`)throw Error(`DecompressionStream not supported`);let t=new DecompressionStream(`gzip`),n=t.writable.getWriter(),r=new Uint8Array(e);n.write(r).then(()=>n.close()).catch(()=>void 0);let i=t.readable.getReader(),a=[],o=0;for(;;){let{done:e,value:t}=await i.read();if(e)break;a.push(t),o+=t.length}let s=new Uint8Array(o),c=0;for(let e=0;e<a.length;e++)s.set(a[e],c),c+=a[e].length;return s}let i=function(e){return e[e.Null=1]=`Null`,e[e.Bool=2]=`Bool`,e[e.Int32=3]=`Int32`,e[e.Int64=4]=`Int64`,e[e.UInt32=5]=`UInt32`,e[e.UInt64=6]=`UInt64`,e[e.Float32=7]=`Float32`,e[e.Float64=8]=`Float64`,e[e.Array=9]=`Array`,e[e.Dict=10]=`Dict`,e[e.Object=11]=`Object`,e[e.String=12]=`String`,e[e.Binary=13]=`Binary`,e[e.Guid=14]=`Guid`,e}({});new TextEncoder;const a=new TextDecoder(`utf-8`,{fatal:!0});var o=class e{buffer;version;offset;end;constructor(e,t,n){this.buffer=e,this.version=t,this.offset=n,this.end=e.length-1}static create(t){let n=w(t);if(n.length<2)throw Error(`Teleport payload too short`);if(n[0]!==161||n[n.length-1]!==162)throw Error(`Teleport object missing markers`);let r={offset:1},i=m(n,r,`InvalidLength`);return new e(n,i,r.offset)}next(){if(this.offset>=this.end)return null;if(this.offset+5>this.buffer.length)throw Error(`Teleport object truncated`);let e=y(this.buffer,this.offset);this.offset+=4;let t=this.buffer[this.offset++],n=t>>4&15;if(t&15)throw Error(`Teleport field flags must be zero`);let r=g(n),i;if(r>=0)v(this.buffer,this.offset,r),i=this.buffer.subarray(this.offset,this.offset+r),this.offset+=r;else{let e={offset:this.offset},t=m(this.buffer,e,`InvalidLength`);v(this.buffer,e.offset,t),i=this.buffer.subarray(e.offset,e.offset+t),this.offset=e.offset+t}return new c(e,n,i)}},s=class{type;payload;constructor(e,t){this.type=e,this.payload=t}asInt32(){return this.ensureType(3),new DataView(this.payload.buffer,this.payload.byteOffset,4).getInt32(0,!0)}asUInt32(){return this.ensureType(5),new DataView(this.payload.buffer,this.payload.byteOffset,4).getUint32(0,!0)}asInt64(){return this.ensureType(4),new DataView(this.payload.buffer,this.payload.byteOffset,8).getBigInt64(0,!0)}asUInt64(){return this.ensureType(6),new DataView(this.payload.buffer,this.payload.byteOffset,8).getBigUint64(0,!0)}asFloat32(){return this.ensureType(7),new DataView(this.payload.buffer,this.payload.byteOffset,4).getFloat32(0,!0)}asFloat64(){return this.ensureType(8),new DataView(this.payload.buffer,this.payload.byteOffset,8).getFloat64(0,!0)}asBool(){return this.ensureType(2),this.payload.length>0&&this.payload[0]!==0}asBinary(){return this.ensureType(13),this.payload}asUtf8(){return this.ensureType(12),this.payload}asString(){return this.ensureType(12),a.decode(this.payload)}asGuid(){return this.ensureType(14),p.fromBytes(this.payload)}asObject(){return this.ensureType(11),o.create(this.payload)}asArray(){return this.ensureType(9),l.create(this.payload)}asDictionary(){return this.ensureType(10),d.create(this.payload)}ensureType(e){if(this.type!==e)throw Error(`Teleport value has type ${i[this.type]}, expected ${i[e]}`)}},c=class extends s{fieldId;constructor(e,t,n){super(t,n),this.fieldId=e}get isNull(){return this.type===1}},l=class e{payload;elementType;count;offset;index=0;constructor(e){if(this.payload=e,e.length===0)throw Error(`Array payload too short`);let t=e[0];if(this.elementType=t>>4&15,t&15)throw Error(`Array flags must be zero`);let n={offset:1};this.count=m(e,n,`ArrayMalformed`),this.offset=n.offset}static create(t){return new e(w(t))}next(){if(this.index>=this.count){if(this.offset!==this.payload.length)throw Error(`Array payload contains trailing data`);return null}let e=this.readValue();return this.index++,e}readValue(){switch(this.elementType){case 3:case 5:case 7:case 8:case 2:case 4:case 6:case 14:{let e=g(this.elementType);v(this.payload,this.offset,e);let t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new u(this.elementType,t)}case 12:case 13:{let e={offset:this.offset},t=m(this.payload,e,`ArrayMalformed`);v(this.payload,e.offset,t);let n=this.payload.subarray(e.offset,e.offset+t);return this.offset=e.offset+t,new u(this.elementType,n)}case 11:{let e={offset:this.offset},t=m(this.payload,e,`ArrayMalformed`);v(this.payload,e.offset,t);let n=this.payload.subarray(e.offset,e.offset+t);return this.offset=e.offset+t,new u(11,n)}case 9:{let e=b(this.payload,this.offset),t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new u(9,t)}case 10:{let e=x(this.payload,this.offset),t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new u(10,t)}default:throw Error(`Unsupported array element type ${i[this.elementType]}`)}}},u=class extends s{constructor(e,t){super(e,t)}},d=class e{payload;keyType;valueType;count;offset;index=0;constructor(e){if(this.payload=e,e.length<2)throw Error(`Dictionary payload too short`);if(this.keyType=e[0]>>4&15,this.valueType=e[1]>>4&15,e[0]&15||e[1]&15)throw Error(`Dictionary key/value flags must be zero`);_(this.keyType);let t={offset:2};this.count=m(e,t,`DictMalformed`),this.offset=t.offset}static create(t){return new e(w(t))}next(){if(this.index>=this.count){if(this.offset!==this.payload.length)throw Error(`Dictionary payload contains trailing data`);return null}let e=this.readKey(),t=this.readValue();return this.index++,new f(e,t)}readKey(){let e=g(this.keyType);if(e>=0){v(this.payload,this.offset,e);let t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new s(this.keyType,t)}if(this.keyType===12||this.keyType===13){let e={offset:this.offset},t=m(this.payload,e,`DictMalformed`);v(this.payload,e.offset,t);let n=this.payload.subarray(e.offset,e.offset+t);return this.offset=e.offset+t,new s(this.keyType,n)}throw Error(`Unsupported dictionary key type`)}readValue(){switch(this.valueType){case 12:case 13:{let e={offset:this.offset},t=m(this.payload,e,`DictMalformed`);v(this.payload,e.offset,t);let n=this.payload.subarray(e.offset,e.offset+t);return this.offset=e.offset+t,new s(this.valueType,n)}case 11:{let e={offset:this.offset},t=m(this.payload,e,`DictMalformed`);v(this.payload,e.offset,t);let n=this.payload.subarray(e.offset,e.offset+t);return this.offset=e.offset+t,new s(11,n)}case 9:{let e=b(this.payload,this.offset),t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new s(9,t)}case 10:{let e=x(this.payload,this.offset),t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new s(10,t)}case 3:case 5:case 7:case 8:case 2:case 4:case 6:case 14:case 1:{let e=g(this.valueType);v(this.payload,this.offset,e);let t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new s(this.valueType,t)}default:throw Error(`Unsupported dictionary value type ${i[this.valueType]}`)}}},f=class{key;value;constructor(e,t){this.key=e,this.value=t}},p=class e{bytes;constructor(e){this.bytes=e}static fromString(t){if(!t)throw Error(`Guid string is empty`);let n=t.replace(/-/g,``);if(n.length!==32)throw Error(`Guid string must be 32 hex characters`);let r=new Uint8Array(16),i=e.parseHexSlice(n,0,8),a=e.parseHexSlice(n,8,4),o=e.parseHexSlice(n,12,4);e.writeUInt32LE(r,0,i),e.writeUInt16LE(r,4,a),e.writeUInt16LE(r,6,o);for(let t=0;t<8;t++)r[8+t]=e.parseHexSlice(n,16+t*2,2);return new e(r)}static fromBytes(t){if(t.length!==16)throw Error(`Guid byte array must be 16 bytes`);return new e(Uint8Array.from(t))}static createZero(){return new e(new Uint8Array(16))}static createRandom(){let t=new Uint8Array(16),n=globalThis.crypto;if(n?.getRandomValues)n.getRandomValues(t);else for(let e=0;e<t.length;e++)t[e]=Math.floor(Math.random()*256);return t[6]=t[6]&15|64,t[8]=t[8]&63|128,new e(t)}toString(){let t=this.bytes;return[e.toHex(e.readUInt32LE(t,0),8),e.toHex(e.readUInt16LE(t,4),4),e.toHex(e.readUInt16LE(t,6),4),C(t.subarray(8,10)),C(t.subarray(10,16))].join(`-`)}asBytes(){return this.bytes.slice()}static parseHexSlice(e,t,n){let r=e.substr(t,n),i=Number.parseInt(r,16);if(Number.isNaN(i))throw Error(`Guid string contains invalid characters`);return i>>>0}static writeUInt32LE(e,t,n){let r=n>>>0;e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24&255}static writeUInt16LE(e,t,n){let r=n&65535;e[t]=r&255,e[t+1]=r>>>8&255}static readUInt32LE(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}static readUInt16LE(e,t){return(e[t]|e[t+1]<<8)&65535}static toHex(e,t){return(e>>>0).toString(16).padStart(t,`0`)}};function m(e,t,n){if(t.offset>=e.length)throw Error(n);let r=0,i=0,a=0;for(;t.offset<e.length;){let n=e[t.offset++];if(a++,r|=(n&127)<<i,!(n&128)){if(a!==h(r))throw Error(`Teleport VarUInt is not canonical`);return r>>>0}if(i+=7,i>=35)throw Error(`Teleport VarUInt exceeds 32-bit range`)}throw Error(n)}function h(e){return e<128?1:e<16384?2:e<2097152?3:e<268435456?4:5}function g(e){switch(e){case 3:case 5:case 7:return 4;case 4:case 6:case 8:return 8;case 14:return 16;case 2:return 1;case 1:return 0;default:return-1}}function _(e){if(e===9||e===11||e===10||e===1)throw Error(`Dictionary keys must be primitive Teleport types`)}function v(e,t,n){if(t<0||n<0||t+n>e.length)throw Error(`Teleport payload exceeds bounds`)}function y(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function b(e,t){if(t>=e.length)throw Error(`Array payload exceeds bounds`);let n=e[t],r=n>>4&15;if(n&15)throw Error(`Array flags must be zero`);let i={offset:t+1},a=m(e,i,`ArrayMalformed`),o=g(r);if(o>=0){let n=o*a;return v(e,i.offset,n),i.offset+n-t}let s=i.offset;for(let t=0;t<a;t++)s=S(r,e,s,`ArrayMalformed`);return s-t}function x(e,t){if(t+2>e.length)throw Error(`Dictionary payload too short`);let n=e[t]>>4&15,r=e[t+1]>>4&15;if(e[t]&15||e[t+1]&15)throw Error(`Dictionary key/value flags must be zero`);_(n);let i={offset:t+2},a=m(e,i,`DictMalformed`),o=i.offset;for(let t=0;t<a;t++)o=S(n,e,o,`DictMalformed`),o=S(r,e,o,`DictMalformed`);return o-t}function S(e,t,n,r){let a=g(e);if(a>=0)return v(t,n,a),n+a;switch(e){case 12:case 13:{let e={offset:n},i=m(t,e,r);return v(t,e.offset,i),e.offset+i}case 11:{let e={offset:n},i=m(t,e,r);return v(t,e.offset,i),e.offset+i}case 9:return n+b(t,n);case 10:return n+x(t,n);default:throw Error(`Unsupported Teleport type ${i[e]}`)}}function C(e){return Array.from(e).map(e=>e.toString(16).padStart(2,`0`)).join(``)}function w(e){return e instanceof Uint8Array?e:new Uint8Array(e)}let T=function(e){return e[e.Unknown=0]=`Unknown`,e[e.H264=1]=`H264`,e[e.Vp8=2]=`Vp8`,e[e.Vp9=3]=`Vp9`,e[e.Av1=4]=`Av1`,e}({}),E=function(e){return e[e.NONE=0]=`NONE`,e[e.CONSTANT_GROUP_BITS=15]=`CONSTANT_GROUP_BITS`,e[e.CONSTANT_GROUP_OFFSET=16]=`CONSTANT_GROUP_OFFSET`,e[e.GROUP_CORE=65536]=`GROUP_CORE`,e[e.CORE_AUTH_RESPONSE=65537]=`CORE_AUTH_RESPONSE`,e[e.CORE_AUTH_TICKET=65538]=`CORE_AUTH_TICKET`,e[e.CORE_GLOBAL_STATE=65539]=`CORE_GLOBAL_STATE`,e[e.CORE_ON_SERVER_STATUS_PING=65540]=`CORE_ON_SERVER_STATUS_PING`,e[e.CORE_ON_USER_JOINED=65541]=`CORE_ON_USER_JOINED`,e[e.CORE_ON_USER_LEFT=65542]=`CORE_ON_USER_LEFT`,e[e.CORE_ON_CLIENT_JOINED=65543]=`CORE_ON_CLIENT_JOINED`,e[e.CORE_ON_CLIENT_LEFT=65544]=`CORE_ON_CLIENT_LEFT`,e[e.CORE_ON_SERVER_STARTED=65545]=`CORE_ON_SERVER_STARTED`,e[e.CORE_ON_SERVER_STOPPED=65546]=`CORE_ON_SERVER_STOPPED`,e[e.CORE_ON_SERVER_STOPPING=65547]=`CORE_ON_SERVER_STOPPING`,e[e.CORE_ON_CLIENT_READY=65548]=`CORE_ON_CLIENT_READY`,e[e.CORE_CLIENT_READY=65549]=`CORE_CLIENT_READY`,e[e.CORE_SERVER_INIT=65550]=`CORE_SERVER_INIT`,e[e.CORE_ON_PLUGIN_RELOADED=65551]=`CORE_ON_PLUGIN_RELOADED`,e[e.CORE_DYNAMIC_CONFIG=65555]=`CORE_DYNAMIC_CONFIG`,e[e.CORE_PROXY_RPC_AUTH_TICKET=65556]=`CORE_PROXY_RPC_AUTH_TICKET`,e[e.CORE_UPDATE_CLIENT_CONTEXT=65558]=`CORE_UPDATE_CLIENT_CONTEXT`,e[e.CORE_BACKGROUND_WORK_ACTIVE=65559]=`CORE_BACKGROUND_WORK_ACTIVE`,e[e.CORE_RESET_IDLE=65560]=`CORE_RESET_IDLE`,e[e.CORE_CLIENT_DISCONNECTING=65561]=`CORE_CLIENT_DISCONNECTING`,e[e.CORE_ON_APP_READY=65562]=`CORE_ON_APP_READY`,e[e.CORE_ON_FRONTEND_RELOADED=65563]=`CORE_ON_FRONTEND_RELOADED`,e[e.CORE_ON_USER_DATA_ERASED=65564]=`CORE_ON_USER_DATA_ERASED`,e[e.CORE_WEBRTC_OFFER=65566]=`CORE_WEBRTC_OFFER`,e[e.CORE_WEBRTC_ANSWER=65567]=`CORE_WEBRTC_ANSWER`,e[e.CORE_WEBRTC_ICE_CANDIDATE=65568]=`CORE_WEBRTC_ICE_CANDIDATE`,e[e.CORE_WEBRTC_READY=65569]=`CORE_WEBRTC_READY`,e[e.CORE_WEBRTC_AUDIO_SEGMENT=65570]=`CORE_WEBRTC_AUDIO_SEGMENT`,e[e.CORE_WEBRTC_TRACK_MAP=65571]=`CORE_WEBRTC_TRACK_MAP`,e[e.CORE_WEBRTC_VIDEO_CAPTURE=65572]=`CORE_WEBRTC_VIDEO_CAPTURE`,e[e.CORE_WEBRTC_ICE_SERVERS_REQUEST=65573]=`CORE_WEBRTC_ICE_SERVERS_REQUEST`,e[e.CORE_WEBRTC_ICE_SERVERS_RESPONSE=65574]=`CORE_WEBRTC_ICE_SERVERS_RESPONSE`,e[e.CORE_WEBRTC_CLOSE=65575]=`CORE_WEBRTC_CLOSE`,e[e.CORE_RELAY_AGENT_AUTH=65576]=`CORE_RELAY_AGENT_AUTH`,e[e.CORE_RELAY_AGENT_AUTH_RESULT=65577]=`CORE_RELAY_AGENT_AUTH_RESULT`,e[e.CORE_RELAY_HEARTBEAT=65578]=`CORE_RELAY_HEARTBEAT`,e[e.CORE_RELAY_TCP_CONNECTION_OPENED=65579]=`CORE_RELAY_TCP_CONNECTION_OPENED`,e[e.CORE_RELAY_TCP_CONNECTION_CLOSED=65580]=`CORE_RELAY_TCP_CONNECTION_CLOSED`,e[e.CORE_RELAY_TCP_DATA=65581]=`CORE_RELAY_TCP_DATA`,e[e.CORE_RELAY_UDP_DATA=65582]=`CORE_RELAY_UDP_DATA`,e[e.CORE_RELAY_ADD_TUNNEL=65583]=`CORE_RELAY_ADD_TUNNEL`,e[e.CORE_RELAY_TUNNEL_ADDED=65584]=`CORE_RELAY_TUNNEL_ADDED`,e[e.CORE_RELAY_REMOVE_TUNNEL=65585]=`CORE_RELAY_REMOVE_TUNNEL`,e[e.CORE_IKON_SERVER_ENDPOINT_HOST_INFO=65586]=`CORE_IKON_SERVER_ENDPOINT_HOST_INFO`,e[e.CORE_CLIENT_INITIALIZATION=65587]=`CORE_CLIENT_INITIALIZATION`,e[e.CORE_CLIENT_LIFECYCLE_BATCH=65588]=`CORE_CLIENT_LIFECYCLE_BATCH`,e[e.CORE_APP_CONFIG=65589]=`CORE_APP_CONFIG`,e[e.GROUP_KEEPALIVE=131072]=`GROUP_KEEPALIVE`,e[e.KEEPALIVE_REQUEST=131073]=`KEEPALIVE_REQUEST`,e[e.KEEPALIVE_RESPONSE=131074]=`KEEPALIVE_RESPONSE`,e[e.GROUP_EVENTS=262144]=`GROUP_EVENTS`,e[e.EVENTS_PROFILE_UPDATE=262145]=`EVENTS_PROFILE_UPDATE`,e[e.EVENTS_SPEECH_PLAYBACK_COMPLETE=262147]=`EVENTS_SPEECH_PLAYBACK_COMPLETE`,e[e.GROUP_ANALYTICS=524288]=`GROUP_ANALYTICS`,e[e.ANALYTICS_LOGS=524289]=`ANALYTICS_LOGS`,e[e.ANALYTICS_EVENTS=524290]=`ANALYTICS_EVENTS`,e[e.ANALYTICS_USAGES=524291]=`ANALYTICS_USAGES`,e[e.ANALYTICS_USAGE=524292]=`ANALYTICS_USAGE`,e[e.ANALYTICS_SPECIAL_LOG=524293]=`ANALYTICS_SPECIAL_LOG`,e[e.ANALYTICS_PROCESSING_UPDATE=524294]=`ANALYTICS_PROCESSING_UPDATE`,e[e.ANALYTICS_REACTIVE_PROCESSING_UPDATE=524295]=`ANALYTICS_REACTIVE_PROCESSING_UPDATE`,e[e.ANALYTICS_IKON_PROXY_SERVER_STATS=524296]=`ANALYTICS_IKON_PROXY_SERVER_STATS`,e[e.ANALYTICS_IKON_RELAY_SERVER_STATS=524297]=`ANALYTICS_IKON_RELAY_SERVER_STATS`,e[e.ANALYTICS_IKON_TURN_SERVER_STATS=524298]=`ANALYTICS_IKON_TURN_SERVER_STATS`,e[e.ANALYTICS_IKON_HOST_SERVER_STATS=524299]=`ANALYTICS_IKON_HOST_SERVER_STATS`,e[e.GROUP_ACTIONS=1048576]=`GROUP_ACTIONS`,e[e.ACTION_CALL=1048577]=`ACTION_CALL`,e[e.ACTION_ACTIVE=1048578]=`ACTION_ACTIVE`,e[e.ACTION_TEXT_OUTPUT=1048579]=`ACTION_TEXT_OUTPUT`,e[e.ACTION_TEXT_OUTPUT_DELTA=1048580]=`ACTION_TEXT_OUTPUT_DELTA`,e[e.ACTION_TEXT_OUTPUT_DELTA_FULL=1048581]=`ACTION_TEXT_OUTPUT_DELTA_FULL`,e[e.ACTION_SET_STATE=1048582]=`ACTION_SET_STATE`,e[e.ACTION_TAP=1048583]=`ACTION_TAP`,e[e.ACTION_PAN=1048584]=`ACTION_PAN`,e[e.ACTION_ZOOM=1048585]=`ACTION_ZOOM`,e[e.ACTION_FILE_UPLOAD_BEGIN=1048586]=`ACTION_FILE_UPLOAD_BEGIN`,e[e.ACTION_FILE_UPLOAD_DATA=1048587]=`ACTION_FILE_UPLOAD_DATA`,e[e.ACTION_FILE_UPLOAD_ACK=1048588]=`ACTION_FILE_UPLOAD_ACK`,e[e.ACTION_FILE_UPLOAD_END=1048589]=`ACTION_FILE_UPLOAD_END`,e[e.ACTION_FILE_UPLOAD_RESULT=1048590]=`ACTION_FILE_UPLOAD_RESULT`,e[e.ACTION_OPEN_EXTERNAL_URL=1048592]=`ACTION_OPEN_EXTERNAL_URL`,e[e.ACTION_FUNCTION_REGISTER=1048600]=`ACTION_FUNCTION_REGISTER`,e[e.ACTION_FUNCTION_CALL=1048601]=`ACTION_FUNCTION_CALL`,e[e.ACTION_FUNCTION_RESULT=1048602]=`ACTION_FUNCTION_RESULT`,e[e.ACTION_GENERATE_ANSWER=1048603]=`ACTION_GENERATE_ANSWER`,e[e.ACTION_REGENERATE_ANSWER=1048604]=`ACTION_REGENERATE_ANSWER`,e[e.ACTION_CLEAR_STATE=1048606]=`ACTION_CLEAR_STATE`,e[e.ACTION_CLASSIFICATION_RESULT=1048609]=`ACTION_CLASSIFICATION_RESULT`,e[e.ACTION_AUDIO_STOP=1048610]=`ACTION_AUDIO_STOP`,e[e.ACTION_CALL_TEXT=1048611]=`ACTION_CALL_TEXT`,e[e.ACTION_CANCEL_GENERATION=1048613]=`ACTION_CANCEL_GENERATION`,e[e.ACTION_SPEECH_RECOGNIZED=1048615]=`ACTION_SPEECH_RECOGNIZED`,e[e.ACTION_CALL_RESULT=1048616]=`ACTION_CALL_RESULT`,e[e.ACTION_DOWNLOAD=1048618]=`ACTION_DOWNLOAD`,e[e.ACTION_PLAY_SOUND=1048621]=`ACTION_PLAY_SOUND`,e[e.ACTION_STOP_SOUND=1048623]=`ACTION_STOP_SOUND`,e[e.ACTION_START_RECORDING=1048624]=`ACTION_START_RECORDING`,e[e.ACTION_STOP_RECORDING=1048625]=`ACTION_STOP_RECORDING`,e[e.ACTION_FUNCTION_ENUMERATION_ITEM=1048627]=`ACTION_FUNCTION_ENUMERATION_ITEM`,e[e.ACTION_FUNCTION_ENUMERATION_END=1048628]=`ACTION_FUNCTION_ENUMERATION_END`,e[e.ACTION_FUNCTION_CANCEL=1048629]=`ACTION_FUNCTION_CANCEL`,e[e.ACTION_FUNCTION_DISPOSE=1048630]=`ACTION_FUNCTION_DISPOSE`,e[e.ACTION_FUNCTION_ERROR=1048631]=`ACTION_FUNCTION_ERROR`,e[e.ACTION_FUNCTION_ACK=1048632]=`ACTION_FUNCTION_ACK`,e[e.ACTION_FUNCTION_AWAITING_APPROVAL=1048633]=`ACTION_FUNCTION_AWAITING_APPROVAL`,e[e.ACTION_FUNCTION_APPROVAL_REQUIRED=1048634]=`ACTION_FUNCTION_APPROVAL_REQUIRED`,e[e.ACTION_FUNCTION_APPROVAL_RESPONSE=1048635]=`ACTION_FUNCTION_APPROVAL_RESPONSE`,e[e.UI_UPDATE_ACK=1048636]=`UI_UPDATE_ACK`,e[e.ACTION_CALL2=1048637]=`ACTION_CALL2`,e[e.ACTION_FUNCTION_REGISTER_BATCH=1048638]=`ACTION_FUNCTION_REGISTER_BATCH`,e[e.ACTION_FILE_UPLOAD_CALLBACK=1048640]=`ACTION_FILE_UPLOAD_CALLBACK`,e[e.ACTION_CUSTOM_USER_MESSAGE=1048641]=`ACTION_CUSTOM_USER_MESSAGE`,e[e.ACTION_URL_CHANGED=1048642]=`ACTION_URL_CHANGED`,e[e.ACTION_FILE_UPLOAD_PRE_START2=1048643]=`ACTION_FILE_UPLOAD_PRE_START2`,e[e.ACTION_FILE_UPLOAD_PRE_START_RESPONSE2=1048644]=`ACTION_FILE_UPLOAD_PRE_START_RESPONSE2`,e[e.ACTION_FILE_UPLOAD_START2=1048645]=`ACTION_FILE_UPLOAD_START2`,e[e.ACTION_FILE_UPLOAD_START_RESPONSE2=1048646]=`ACTION_FILE_UPLOAD_START_RESPONSE2`,e[e.ACTION_FILE_UPLOAD_DATA2=1048647]=`ACTION_FILE_UPLOAD_DATA2`,e[e.ACTION_FILE_UPLOAD_ACK2=1048648]=`ACTION_FILE_UPLOAD_ACK2`,e[e.ACTION_FILE_UPLOAD_END2=1048649]=`ACTION_FILE_UPLOAD_END2`,e[e.ACTION_FILE_UPLOAD_COMPLETE2=1048650]=`ACTION_FILE_UPLOAD_COMPLETE2`,e[e.ACTION_FUNCTION_ENUMERATION_ITEM_BATCH=1048651]=`ACTION_FUNCTION_ENUMERATION_ITEM_BATCH`,e[e.ACTION_CALL_ACK=1048652]=`ACTION_CALL_ACK`,e[e.ACTION_TRIGGER_CRON=1048653]=`ACTION_TRIGGER_CRON`,e[e.ACTION_RESULT=1048654]=`ACTION_RESULT`,e[e.UI_RESYNC_REQUEST=1048655]=`UI_RESYNC_REQUEST`,e[e.ACTION_USER_DATA_ERASURE=1048656]=`ACTION_USER_DATA_ERASURE`,e[e.GROUP_UI=2097152]=`GROUP_UI`,e[e.UI_STREAM_BEGIN=2097153]=`UI_STREAM_BEGIN`,e[e.UI_STREAM_END=2097154]=`UI_STREAM_END`,e[e.UI_STYLES=2097188]=`UI_STYLES`,e[e.UI_UPDATE=2097190]=`UI_UPDATE`,e[e.UI_STYLES_BATCH=2097192]=`UI_STYLES_BATCH`,e[e.UI_STYLES_DELETE=2097193]=`UI_STYLES_DELETE`,e[e.GROUP_COMMON=4128768]=`GROUP_COMMON`,e[e.GROUP_AUDIO=4194304]=`GROUP_AUDIO`,e[e.AUDIO_STREAM_BEGIN=4194305]=`AUDIO_STREAM_BEGIN`,e[e.AUDIO_STREAM_END=4194306]=`AUDIO_STREAM_END`,e[e.AUDIO_FRAME=4194307]=`AUDIO_FRAME`,e[e.AUDIO_FRAME_VOLUME=4194308]=`AUDIO_FRAME_VOLUME`,e[e.AUDIO_FRAME2=4194309]=`AUDIO_FRAME2`,e[e.AUDIO_SHAPE_FRAME=4194310]=`AUDIO_SHAPE_FRAME`,e[e.AUDIO_PLAYBACK_REPORT=4194311]=`AUDIO_PLAYBACK_REPORT`,e[e.GROUP_VIDEO=8388608]=`GROUP_VIDEO`,e[e.VIDEO_STREAM_BEGIN=8388609]=`VIDEO_STREAM_BEGIN`,e[e.VIDEO_STREAM_END=8388610]=`VIDEO_STREAM_END`,e[e.VIDEO_FRAME=8388611]=`VIDEO_FRAME`,e[e.VIDEO_REQUEST_IDR_FRAME=8388612]=`VIDEO_REQUEST_IDR_FRAME`,e[e.VIDEO_INVALIDATE_FRAME=8388613]=`VIDEO_INVALIDATE_FRAME`,e[e.GROUP_ALL=16711680]=`GROUP_ALL`,e[e.GROUP_APP_LOCAL=1073741824]=`GROUP_APP_LOCAL`,e[e.CONSTANT_GROUP_MASK=2147418112]=`CONSTANT_GROUP_MASK`,e}({});function D(e){let t={};return O(t),e&&Object.assign(t,e),t}function O(e){return e.Data=new Uint8Array,e.FrameNumber=0,e.IsKey=!1,e.TimestampInUs=BigInt(0),e.DurationInUs=0,e}function k(e,t){return A(o.create(e),t)}function A(e,t){let n=t??D();return O(n),ee(e,n),n}function ee(e,t){let n;for(;(n=e.next())!==null;)switch(n.fieldId){case 271275304:if(n.isNull)throw Error();t.TimestampInUs=n.asUInt64();break;case 2541432218:if(n.isNull)throw Error();t.DurationInUs=n.asUInt32();break;case 2986785889:if(n.isNull)throw Error();t.Data=n.asBinary();break;case 3105403172:if(n.isNull)throw Error();t.IsKey=n.asBool();break;case 3456383222:if(n.isNull)throw Error();t.FrameNumber=n.asInt32()}}async function te(e,t){return k(await n(e,8388611,1),t)}function ne(e){let t={};return j(t),e&&Object.assign(t,e),t}function j(e){return e.StreamId=``,e.Description=``,e.SourceType=``,e.Codec=T.H264,e.CodecDetails=``,e.Width=0,e.Height=0,e.Framerate=30,e.CorrelationId=void 0,e}function M(e,t){return N(o.create(e),t)}function N(e,t){let n=t??ne();return j(n),P(e,n),n}function P(e,t){let n;for(;(n=e.next())!==null;)switch(n.fieldId){case 161083277:if(n.isNull)throw Error();t.StreamId=n.asString();break;case 164808083:if(n.isNull)throw Error();t.Framerate=n.asFloat64();break;case 1368629611:if(n.isNull)throw Error();t.Description=n.asString();break;case 2514959030:if(n.isNull){t.CorrelationId=void 0;break}t.CorrelationId=n.asString();break;case 2745379226:if(n.isNull)throw Error();t.CodecDetails=n.asString();break;case 2950031986:if(n.isNull)throw Error();t.Height=n.asInt32();break;case 3282782683:if(n.isNull)throw Error();t.SourceType=n.asString();break;case 3284746250:if(n.isNull)throw Error();t.Codec=n.asInt32();break;case 4065070594:if(n.isNull)throw Error();t.Width=n.asInt32()}}async function F(e,t){return M(await n(e,8388609,6),t)}const I=(e,t)=>self.postMessage(e,t??[]);let L=null,R=!0,z=!1;const B=new Map,V=new Map;function H(e){e.hasPainted||(e.hasPainted=!0,I({type:`log`,message:`first frame painted for ${e.streamId}`}))}function U(e){let t=e instanceof Error?e:Error(String(e));I({type:`error`,error:{name:t.name,message:t.message,stack:t.stack}})}function W(e,t){return e<<16|t&65535}function G(e){let t=B.get(e);if(t)return t;let n={streamId:e,numericKey:0,watched:!1,surface:null,ctx2d:null,codec:null,width:0,height:0,framerate:0,decoder:null,decoderCodec:null,decoderWidth:0,decoderHeight:0,isKeyFrameRequired:!0,isReconfiguring:!1,pendingDecodeCount:0,hasPainted:!1};return B.set(e,n),n}function K(e){if(e===T.H264)return`avc1.42E01E`;if(e===T.Vp8)return`vp8`;if(e===T.Vp9)return`vp09.00.10.08`;if(e===T.Av1)return`av01.0.04M.08`;throw Error(`Unknown codec: ${e}`)}function q(e){let t=B.get(e);if(!t||t.numericKey===0)return;let n=t.numericKey>>16&65535,r=t.numericKey&65535;I({type:`requestIdr`,streamId:e,senderId:n,trackId:r})}async function re(e,t){try{if(!R||!e.watched)return;if(typeof createImageBitmap==`function`){let n=await createImageBitmap(t);I({type:`frame`,streamId:e.streamId,width:e.width,height:e.height,bitmap:n},[n]),H(e)}}catch(e){U(e)}finally{e.pendingDecodeCount--;try{t.close()}catch{}}}async function ie(e,t,n){let r={codec:e,codedWidth:t>0?t:void 0,codedHeight:n>0?n:void 0,optimizeForLatency:!0};if(typeof VideoDecoder?.isConfigSupported!=`function`)return{config:{...r,hardwareAcceleration:`prefer-hardware`},isHardwareAccelerated:!0};let i={...r,hardwareAcceleration:`prefer-hardware`};try{let e=await VideoDecoder.isConfigSupported(i);if(e.supported)return{config:e.config??i,isHardwareAccelerated:!0}}catch{}try{let e=await VideoDecoder.isConfigSupported(r);if(e.supported)return{config:e.config??r,isHardwareAccelerated:!1}}catch{}return null}function J(e){return new VideoDecoder({output:t=>{if(e.pendingDecodeCount++,!R||!e.watched){e.pendingDecodeCount--;try{t.close()}catch{}return}if(e.pendingDecodeCount>8){e.pendingDecodeCount--;try{t.close()}catch{}return}let n=e.width,r=e.height;if(e.ctx2d&&e.surface){try{e.ctx2d.drawImage(t,0,0,n,r),H(e)}catch(e){U(e)}finally{e.pendingDecodeCount--;try{t.close()}catch{}}return}re(e,t)},error:t=>{if(U(t),e.isKeyFrameRequired=!0,e.decoder&&e.decoder.state!==`closed`)try{e.decoder.close()}catch{}e.decoder=null,e.decoderCodec=null,q(e.streamId)}})}async function Y(e){if(e.codec==null||z){e.isReconfiguring=!1;return}let t=K(e.codec);(!e.decoder||e.decoder.state===`closed`)&&(e.decoder&&(e.decoderCodec=null,e.decoderWidth=0,e.decoderHeight=0),e.decoder=J(e));let n=e.decoderCodec!==null&&e.decoderCodec!==t;if(e.decoderCodec===t&&e.decoderWidth===e.width&&e.decoderHeight===e.height){e.isReconfiguring=!1;return}if(e.isReconfiguring=!0,e.decoderCodec=null,n&&e.decoder){try{e.decoder.close()}catch{}e.decoder=J(e)}try{let n=await ie(t,e.width,e.height);if(K(e.codec)!==t){if(e.decoder&&e.decoder.state!==`closed`)try{e.decoder.close()}catch{}e.decoder=null,e.decoderCodec=null,e.decoderWidth=0,e.decoderHeight=0;return}if(!n){U(Error(`Decoder not supported for codec ${t}`));return}(!e.decoder||e.decoder.state===`closed`)&&(e.decoder=J(e)),e.decoderCodec=t,e.decoderWidth=e.width,e.decoderHeight=e.height;try{e.decoder.configure(n.config),e.isKeyFrameRequired=!0,q(e.streamId);let r=n.isHardwareAccelerated?`hardware`:`software`,i=e.framerate>0?`@${Math.round(e.framerate)}fps`:``;I({type:`debug`,message:`Decoder configured: codec=${t}, ${e.width}x${e.height}${i}, hw=${r}`})}catch(e){U(e)}e.surface&&e.ctx2d&&e.width>0&&e.height>0&&(e.surface.width!==e.width||e.surface.height!==e.height)&&(e.surface.width=e.width,e.surface.height=e.height)}finally{e.isReconfiguring=!1}}async function ae(e,t){let n=await F(e);X(W(t.senderId,t.trackId),n)}function X(e,t){let n=t.StreamId,r=G(n);r.numericKey=e,r.codec=t.Codec,r.width=t.Width,r.height=t.Height,r.framerate=t.Framerate,V.set(e,n),I({type:`streamBegin`,streamId:n,width:t.Width,height:t.Height,codec:t.Codec}),r.watched?(r.surface&&r.ctx2d&&t.Width>0&&t.Height>0&&(r.surface.width!==t.Width||r.surface.height!==t.Height)&&(r.surface.width=t.Width,r.surface.height=t.Height),Y(r)):r.isReconfiguring=!1}function oe(e){let t=W(e.senderId,e.trackId),n=V.get(t);if(!n)return;I({type:`streamEnd`,streamId:n});let r=B.get(n);if(!r){V.delete(t);return}if(r.decoder)try{r.decoder.close()}catch{}B.delete(n),V.delete(t)}function Z(e){let t=B.get(e);t&&(t.surface=null,t.ctx2d=null)}function Q(e){let t=B.get(e);if(t){if(t.watched=!1,t.isKeyFrameRequired=!0,Z(e),t.decoder){try{t.decoder.close()}catch{}t.decoder=null,t.decoderCodec=null,t.decoderWidth=0,t.decoderHeight=0}t.isReconfiguring=!1}}async function se(e,t){let n=W(t.senderId,t.trackId),r=V.get(n);if(!r)return;let i=B.get(r);if(!i||!R||!i.watched||i.isReconfiguring||((!i.decoder||!i.decoderCodec)&&Y(i),!i.decoder||!i.decoderCodec))return;let a=await te(e);if(!(i.isReconfiguring||!i.decoder||!i.decoderCodec)&&i.decoder.state!==`closed`){if(i.isKeyFrameRequired){if(!a.IsKey)return;i.isKeyFrameRequired=!1}try{if(i.decoder.state===`closed`)return;i.decoder.decode(new EncodedVideoChunk({type:a.IsKey?`key`:`delta`,timestamp:Number(a.TimestampInUs),duration:a.DurationInUs,data:a.Data}))}catch(e){if(e instanceof DOMException&&e.message.includes(`closed`))return;i.isKeyFrameRequired=!0,q(i.streamId),U(e)}}}function ce(e){let t=W(e.senderId,e.trackId),n=V.get(t);if(!n)return;let r=B.get(n);r&&(r.isKeyFrameRequired=!0,r.watched&&q(r.streamId))}function le(e,t){switch(t.opcode){case E.VIDEO_STREAM_BEGIN:{let n=W(t.senderId,t.trackId),r=V.get(n);if(r){let e=B.get(r);e&&(e.isReconfiguring=!0)}ae(e,t);return}case E.VIDEO_STREAM_END:oe(t);return;case E.VIDEO_FRAME:se(e,t);return;case E.VIDEO_INVALIDATE_FRAME:ce(t);return;default:return}}function $(){if(L){try{L.close()}catch{}L=null}}function ue(){$();for(let e of B.values())Q(e.streamId);B.clear(),V.clear()}self.addEventListener(`message`,e=>{let t=e.data;if(t.type===`configure`){z=t.webRtcEnabled??!1;return}if(t.type===`setWebRtcEnabled`){if(z=t.enabled,!z)for(let e of B.values())e.watched&&(e.isKeyFrameRequired=!0,Y(e),q(e.streamId));return}if(t.type===`syncStreams`){for(let e of t.streams){let t=W(e.senderId,e.trackId);V.has(t)||X(t,e.info)}return}if(t.type===`attachSurface`){let e=t.streamId,n=G(e);n.watched=!0,n.surface=t.canvas;try{n.ctx2d=n.surface.getContext(`2d`,{alpha:!1,desynchronized:!0})}catch(e){U(e),n.ctx2d=null}n.isKeyFrameRequired=!0,Y(n),q(e);return}if(t.type===`detachSurface`){Z(t.streamId);return}if(t.type===`attachProtocolPort`){$(),L=t.port,L.addEventListener(`message`,e=>{let t=e.data;t?.type===`protocol`&&t.message instanceof ArrayBuffer&&t.headers&&le(new Uint8Array(t.message),t.headers)}),L.start?.();return}if(t.type===`watchStream`){let e=G(t.streamId);e.watched=!0,e.isKeyFrameRequired=!0,Y(e),q(e.streamId);return}if(t.type===`unwatchStream`){Q(t.streamId);return}if(t.type===`setEnabled`){if(R=t.enabled,R)for(let e of B.values())e.watched&&(e.isKeyFrameRequired=!0,Y(e),q(e.streamId));return}t.type===`dispose`&&ue()});
@@ -1 +1 @@
1
- const e={None:0,SendBackToSender:1,Delayable:2,SendToUser:4,Compressed:8,Unreliable:16};function t(e){return e}function n(e){if(e.length<8)throw Error(`Protocol message too short`);return(e[4]|e[5]<<8|e[6]<<16|e[7]<<24)>>>0}function r(e){let t=S(e),n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(t.length<27)throw Error(`Protocol payload too short`);let r=n.getUint32(0,!0),i=n.getUint32(4,!0),a=n.getUint32(8,!0),o=n.getUint32(12,!0),s=n.getUint32(16,!0),c=n.getUint32(20,!0),l=n.getUint8(24),u=n.getUint8(25),d=n.getUint8(26);if(27+c*4>t.length)throw Error(`Protocol header exceeds payload length`);let f=[],p=27;for(let e=0;e<c;e++)f.push(n.getUint32(p,!0)),p+=4;return{length:r,opcode:i,senderId:a,trackId:o,sequenceId:s,targetIds:f,payloadVersion:l,payloadType:u,flags:d}}async function i(t,n,i){let o=S(t),s=r(o);if(n!==void 0&&s.opcode!==n)throw Error(`Unexpected opcode ${s.opcode}`);if(s.payloadType!==8)throw Error(`Unexpected payload type ${s.payloadType}`);let c=27+s.targetIds.length*4,l=o.subarray(c,s.length);return(s.flags&e.Compressed)!==0&&(l=await a(l)),l}async function a(e){if(typeof DecompressionStream>`u`)throw Error(`DecompressionStream not supported`);let t=new DecompressionStream(`gzip`),n=t.writable.getWriter(),r=new Uint8Array(e);n.write(r).then(()=>n.close()).catch(()=>void 0);let i=t.readable.getReader(),a=[],o=0;for(;;){let{done:e,value:t}=await i.read();if(e)break;a.push(t),o+=t.length}let s=new Uint8Array(o),c=0;for(let e=0;e<a.length;e++)s.set(a[e],c),c+=a[e].length;return s}let o=function(e){return e[e.Null=1]=`Null`,e[e.Bool=2]=`Bool`,e[e.Int32=3]=`Int32`,e[e.Int64=4]=`Int64`,e[e.UInt32=5]=`UInt32`,e[e.UInt64=6]=`UInt64`,e[e.Float32=7]=`Float32`,e[e.Float64=8]=`Float64`,e[e.Array=9]=`Array`,e[e.Dict=10]=`Dict`,e[e.Object=11]=`Object`,e[e.String=12]=`String`,e[e.Binary=13]=`Binary`,e[e.Guid=14]=`Guid`,e}({});new TextEncoder;const s=new TextDecoder(`utf-8`,{fatal:!0});var c=class e{buffer;version;offset;end;constructor(e,t,n){this.buffer=e,this.version=t,this.offset=n,this.end=e.length-1}static create(t){let n=S(t);if(n.length<2)throw Error(`Teleport payload too short`);if(n[0]!==161||n[n.length-1]!==162)throw Error(`Teleport object missing markers`);let r={offset:1},i=m(n,r,`InvalidLength`);return new e(n,i,r.offset)}next(){if(this.offset>=this.end)return null;if(this.offset+5>this.buffer.length)throw Error(`Teleport object truncated`);let e=re(this.buffer,this.offset);this.offset+=4;let t=this.buffer[this.offset++],n=t>>4&15;if(t&15)throw Error(`Teleport field flags must be zero`);let r=h(n),i;if(r>=0)_(this.buffer,this.offset,r),i=this.buffer.subarray(this.offset,this.offset+r),this.offset+=r;else{let e={offset:this.offset},t=m(this.buffer,e,`InvalidLength`);_(this.buffer,e.offset,t),i=this.buffer.subarray(e.offset,e.offset+t),this.offset=e.offset+t}return new u(e,n,i)}},l=class{type;payload;constructor(e,t){this.type=e,this.payload=t}asInt32(){return this.ensureType(3),new DataView(this.payload.buffer,this.payload.byteOffset,4).getInt32(0,!0)}asUInt32(){return this.ensureType(5),new DataView(this.payload.buffer,this.payload.byteOffset,4).getUint32(0,!0)}asInt64(){return this.ensureType(4),new DataView(this.payload.buffer,this.payload.byteOffset,8).getBigInt64(0,!0)}asUInt64(){return this.ensureType(6),new DataView(this.payload.buffer,this.payload.byteOffset,8).getBigUint64(0,!0)}asFloat32(){return this.ensureType(7),new DataView(this.payload.buffer,this.payload.byteOffset,4).getFloat32(0,!0)}asFloat64(){return this.ensureType(8),new DataView(this.payload.buffer,this.payload.byteOffset,8).getFloat64(0,!0)}asBool(){return this.ensureType(2),this.payload.length>0&&this.payload[0]!==0}asBinary(){return this.ensureType(13),this.payload}asUtf8(){return this.ensureType(12),this.payload}asString(){return this.ensureType(12),s.decode(this.payload)}asGuid(){return this.ensureType(14),te.fromBytes(this.payload)}asObject(){return this.ensureType(11),c.create(this.payload)}asArray(){return this.ensureType(9),d.create(this.payload)}asDictionary(){return this.ensureType(10),p.create(this.payload)}ensureType(e){if(this.type!==e)throw Error(`Teleport value has type ${o[this.type]}, expected ${o[e]}`)}},u=class extends l{fieldId;constructor(e,t,n){super(t,n),this.fieldId=e}get isNull(){return this.type===1}},d=class e{payload;elementType;count;offset;index=0;constructor(e){if(this.payload=e,e.length===0)throw Error(`Array payload too short`);let t=e[0];if(this.elementType=t>>4&15,t&15)throw Error(`Array flags must be zero`);let n={offset:1};this.count=m(e,n,`ArrayMalformed`),this.offset=n.offset}static create(t){return new e(S(t))}next(){if(this.index>=this.count){if(this.offset!==this.payload.length)throw Error(`Array payload contains trailing data`);return null}let e=this.readValue();return this.index++,e}readValue(){switch(this.elementType){case 3:case 5:case 7:case 8:case 2:case 4:case 6:case 14:{let e=h(this.elementType);_(this.payload,this.offset,e);let t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new f(this.elementType,t)}case 12:case 13:{let e={offset:this.offset},t=m(this.payload,e,`ArrayMalformed`);_(this.payload,e.offset,t);let n=this.payload.subarray(e.offset,e.offset+t);return this.offset=e.offset+t,new f(this.elementType,n)}case 11:{let e={offset:this.offset},t=m(this.payload,e,`ArrayMalformed`);_(this.payload,e.offset,t);let n=this.payload.subarray(e.offset,e.offset+t);return this.offset=e.offset+t,new f(11,n)}case 9:{let e=v(this.payload,this.offset),t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new f(9,t)}case 10:{let e=y(this.payload,this.offset),t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new f(10,t)}default:throw Error(`Unsupported array element type ${o[this.elementType]}`)}}},f=class extends l{constructor(e,t){super(e,t)}},p=class e{payload;keyType;valueType;count;offset;index=0;constructor(e){if(this.payload=e,e.length<2)throw Error(`Dictionary payload too short`);if(this.keyType=e[0]>>4&15,this.valueType=e[1]>>4&15,e[0]&15||e[1]&15)throw Error(`Dictionary key/value flags must be zero`);g(this.keyType);let t={offset:2};this.count=m(e,t,`DictMalformed`),this.offset=t.offset}static create(t){return new e(S(t))}next(){if(this.index>=this.count){if(this.offset!==this.payload.length)throw Error(`Dictionary payload contains trailing data`);return null}let e=this.readKey(),t=this.readValue();return this.index++,new ee(e,t)}readKey(){let e=h(this.keyType);if(e>=0){_(this.payload,this.offset,e);let t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new l(this.keyType,t)}if(this.keyType===12||this.keyType===13){let e={offset:this.offset},t=m(this.payload,e,`DictMalformed`);_(this.payload,e.offset,t);let n=this.payload.subarray(e.offset,e.offset+t);return this.offset=e.offset+t,new l(this.keyType,n)}throw Error(`Unsupported dictionary key type`)}readValue(){switch(this.valueType){case 12:case 13:{let e={offset:this.offset},t=m(this.payload,e,`DictMalformed`);_(this.payload,e.offset,t);let n=this.payload.subarray(e.offset,e.offset+t);return this.offset=e.offset+t,new l(this.valueType,n)}case 11:{let e={offset:this.offset},t=m(this.payload,e,`DictMalformed`);_(this.payload,e.offset,t);let n=this.payload.subarray(e.offset,e.offset+t);return this.offset=e.offset+t,new l(11,n)}case 9:{let e=v(this.payload,this.offset),t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new l(9,t)}case 10:{let e=y(this.payload,this.offset),t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new l(10,t)}case 3:case 5:case 7:case 8:case 2:case 4:case 6:case 14:case 1:{let e=h(this.valueType);_(this.payload,this.offset,e);let t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new l(this.valueType,t)}default:throw Error(`Unsupported dictionary value type ${o[this.valueType]}`)}}},ee=class{key;value;constructor(e,t){this.key=e,this.value=t}},te=class e{bytes;constructor(e){this.bytes=e}static fromString(t){if(!t)throw Error(`Guid string is empty`);let n=t.replace(/-/g,``);if(n.length!==32)throw Error(`Guid string must be 32 hex characters`);let r=new Uint8Array(16),i=e.parseHexSlice(n,0,8),a=e.parseHexSlice(n,8,4),o=e.parseHexSlice(n,12,4);e.writeUInt32LE(r,0,i),e.writeUInt16LE(r,4,a),e.writeUInt16LE(r,6,o);for(let t=0;t<8;t++)r[8+t]=e.parseHexSlice(n,16+t*2,2);return new e(r)}static fromBytes(t){if(t.length!==16)throw Error(`Guid byte array must be 16 bytes`);return new e(Uint8Array.from(t))}static createZero(){return new e(new Uint8Array(16))}static createRandom(){let t=new Uint8Array(16),n=globalThis.crypto;if(n?.getRandomValues)n.getRandomValues(t);else for(let e=0;e<t.length;e++)t[e]=Math.floor(Math.random()*256);return t[6]=t[6]&15|64,t[8]=t[8]&63|128,new e(t)}toString(){let t=this.bytes;return[e.toHex(e.readUInt32LE(t,0),8),e.toHex(e.readUInt16LE(t,4),4),e.toHex(e.readUInt16LE(t,6),4),x(t.subarray(8,10)),x(t.subarray(10,16))].join(`-`)}asBytes(){return this.bytes.slice()}static parseHexSlice(e,t,n){let r=e.substr(t,n),i=Number.parseInt(r,16);if(Number.isNaN(i))throw Error(`Guid string contains invalid characters`);return i>>>0}static writeUInt32LE(e,t,n){let r=n>>>0;e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24&255}static writeUInt16LE(e,t,n){let r=n&65535;e[t]=r&255,e[t+1]=r>>>8&255}static readUInt32LE(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}static readUInt16LE(e,t){return(e[t]|e[t+1]<<8)&65535}static toHex(e,t){return(e>>>0).toString(16).padStart(t,`0`)}};function m(e,t,n){if(t.offset>=e.length)throw Error(n);let r=0,i=0,a=0;for(;t.offset<e.length;){let n=e[t.offset++];if(a++,r|=(n&127)<<i,!(n&128)){if(a!==ne(r))throw Error(`Teleport VarUInt is not canonical`);return r>>>0}if(i+=7,i>=35)throw Error(`Teleport VarUInt exceeds 32-bit range`)}throw Error(n)}function ne(e){return e<128?1:e<16384?2:e<2097152?3:e<268435456?4:5}function h(e){switch(e){case 3:case 5:case 7:return 4;case 4:case 6:case 8:return 8;case 14:return 16;case 2:return 1;case 1:return 0;default:return-1}}function g(e){if(e===9||e===11||e===10||e===1)throw Error(`Dictionary keys must be primitive Teleport types`)}function _(e,t,n){if(t<0||n<0||t+n>e.length)throw Error(`Teleport payload exceeds bounds`)}function re(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function v(e,t){if(t>=e.length)throw Error(`Array payload exceeds bounds`);let n=e[t],r=n>>4&15;if(n&15)throw Error(`Array flags must be zero`);let i={offset:t+1},a=m(e,i,`ArrayMalformed`),o=h(r);if(o>=0){let n=o*a;return _(e,i.offset,n),i.offset+n-t}let s=i.offset;for(let t=0;t<a;t++)s=b(r,e,s,`ArrayMalformed`);return s-t}function y(e,t){if(t+2>e.length)throw Error(`Dictionary payload too short`);let n=e[t]>>4&15,r=e[t+1]>>4&15;if(e[t]&15||e[t+1]&15)throw Error(`Dictionary key/value flags must be zero`);g(n);let i={offset:t+2},a=m(e,i,`DictMalformed`),o=i.offset;for(let t=0;t<a;t++)o=b(n,e,o,`DictMalformed`),o=b(r,e,o,`DictMalformed`);return o-t}function b(e,t,n,r){let i=h(e);if(i>=0)return _(t,n,i),n+i;switch(e){case 12:case 13:{let e={offset:n},i=m(t,e,r);return _(t,e.offset,i),e.offset+i}case 11:{let e={offset:n},i=m(t,e,r);return _(t,e.offset,i),e.offset+i}case 9:return n+v(t,n);case 10:return n+y(t,n);default:throw Error(`Unsupported Teleport type ${o[e]}`)}}function x(e){return Array.from(e).map(e=>e.toString(16).padStart(2,`0`)).join(``)}function S(e){return e instanceof Uint8Array?e:new Uint8Array(e)}let C=function(e){return e[e.Unknown=0]=`Unknown`,e[e.Opus=1]=`Opus`,e[e.Mp3=2]=`Mp3`,e[e.RawPcm16=3]=`RawPcm16`,e}({}),w=function(e){return e[e.NONE=0]=`NONE`,e[e.CONSTANT_GROUP_BITS=15]=`CONSTANT_GROUP_BITS`,e[e.CONSTANT_GROUP_OFFSET=16]=`CONSTANT_GROUP_OFFSET`,e[e.GROUP_CORE=65536]=`GROUP_CORE`,e[e.CORE_AUTH_RESPONSE=65537]=`CORE_AUTH_RESPONSE`,e[e.CORE_AUTH_TICKET=65538]=`CORE_AUTH_TICKET`,e[e.CORE_GLOBAL_STATE=65539]=`CORE_GLOBAL_STATE`,e[e.CORE_ON_SERVER_STATUS_PING=65540]=`CORE_ON_SERVER_STATUS_PING`,e[e.CORE_ON_USER_JOINED=65541]=`CORE_ON_USER_JOINED`,e[e.CORE_ON_USER_LEFT=65542]=`CORE_ON_USER_LEFT`,e[e.CORE_ON_CLIENT_JOINED=65543]=`CORE_ON_CLIENT_JOINED`,e[e.CORE_ON_CLIENT_LEFT=65544]=`CORE_ON_CLIENT_LEFT`,e[e.CORE_ON_SERVER_STARTED=65545]=`CORE_ON_SERVER_STARTED`,e[e.CORE_ON_SERVER_STOPPED=65546]=`CORE_ON_SERVER_STOPPED`,e[e.CORE_ON_SERVER_STOPPING=65547]=`CORE_ON_SERVER_STOPPING`,e[e.CORE_ON_CLIENT_READY=65548]=`CORE_ON_CLIENT_READY`,e[e.CORE_CLIENT_READY=65549]=`CORE_CLIENT_READY`,e[e.CORE_SERVER_INIT=65550]=`CORE_SERVER_INIT`,e[e.CORE_ON_PLUGIN_RELOADED=65551]=`CORE_ON_PLUGIN_RELOADED`,e[e.CORE_DYNAMIC_CONFIG=65555]=`CORE_DYNAMIC_CONFIG`,e[e.CORE_PROXY_RPC_AUTH_TICKET=65556]=`CORE_PROXY_RPC_AUTH_TICKET`,e[e.CORE_UPDATE_CLIENT_CONTEXT=65558]=`CORE_UPDATE_CLIENT_CONTEXT`,e[e.CORE_BACKGROUND_WORK_ACTIVE=65559]=`CORE_BACKGROUND_WORK_ACTIVE`,e[e.CORE_RESET_IDLE=65560]=`CORE_RESET_IDLE`,e[e.CORE_CLIENT_DISCONNECTING=65561]=`CORE_CLIENT_DISCONNECTING`,e[e.CORE_ON_APP_READY=65562]=`CORE_ON_APP_READY`,e[e.CORE_ON_FRONTEND_RELOADED=65563]=`CORE_ON_FRONTEND_RELOADED`,e[e.CORE_ON_USER_DATA_ERASED=65564]=`CORE_ON_USER_DATA_ERASED`,e[e.CORE_WEBRTC_OFFER=65566]=`CORE_WEBRTC_OFFER`,e[e.CORE_WEBRTC_ANSWER=65567]=`CORE_WEBRTC_ANSWER`,e[e.CORE_WEBRTC_ICE_CANDIDATE=65568]=`CORE_WEBRTC_ICE_CANDIDATE`,e[e.CORE_WEBRTC_READY=65569]=`CORE_WEBRTC_READY`,e[e.CORE_WEBRTC_AUDIO_SEGMENT=65570]=`CORE_WEBRTC_AUDIO_SEGMENT`,e[e.CORE_WEBRTC_TRACK_MAP=65571]=`CORE_WEBRTC_TRACK_MAP`,e[e.CORE_WEBRTC_VIDEO_CAPTURE=65572]=`CORE_WEBRTC_VIDEO_CAPTURE`,e[e.CORE_WEBRTC_ICE_SERVERS_REQUEST=65573]=`CORE_WEBRTC_ICE_SERVERS_REQUEST`,e[e.CORE_WEBRTC_ICE_SERVERS_RESPONSE=65574]=`CORE_WEBRTC_ICE_SERVERS_RESPONSE`,e[e.CORE_WEBRTC_CLOSE=65575]=`CORE_WEBRTC_CLOSE`,e[e.CORE_RELAY_AGENT_AUTH=65576]=`CORE_RELAY_AGENT_AUTH`,e[e.CORE_RELAY_AGENT_AUTH_RESULT=65577]=`CORE_RELAY_AGENT_AUTH_RESULT`,e[e.CORE_RELAY_HEARTBEAT=65578]=`CORE_RELAY_HEARTBEAT`,e[e.CORE_RELAY_TCP_CONNECTION_OPENED=65579]=`CORE_RELAY_TCP_CONNECTION_OPENED`,e[e.CORE_RELAY_TCP_CONNECTION_CLOSED=65580]=`CORE_RELAY_TCP_CONNECTION_CLOSED`,e[e.CORE_RELAY_TCP_DATA=65581]=`CORE_RELAY_TCP_DATA`,e[e.CORE_RELAY_UDP_DATA=65582]=`CORE_RELAY_UDP_DATA`,e[e.CORE_RELAY_ADD_TUNNEL=65583]=`CORE_RELAY_ADD_TUNNEL`,e[e.CORE_RELAY_TUNNEL_ADDED=65584]=`CORE_RELAY_TUNNEL_ADDED`,e[e.CORE_RELAY_REMOVE_TUNNEL=65585]=`CORE_RELAY_REMOVE_TUNNEL`,e[e.CORE_IKON_SERVER_ENDPOINT_HOST_INFO=65586]=`CORE_IKON_SERVER_ENDPOINT_HOST_INFO`,e[e.CORE_CLIENT_INITIALIZATION=65587]=`CORE_CLIENT_INITIALIZATION`,e[e.CORE_CLIENT_LIFECYCLE_BATCH=65588]=`CORE_CLIENT_LIFECYCLE_BATCH`,e[e.CORE_APP_CONFIG=65589]=`CORE_APP_CONFIG`,e[e.GROUP_KEEPALIVE=131072]=`GROUP_KEEPALIVE`,e[e.KEEPALIVE_REQUEST=131073]=`KEEPALIVE_REQUEST`,e[e.KEEPALIVE_RESPONSE=131074]=`KEEPALIVE_RESPONSE`,e[e.GROUP_EVENTS=262144]=`GROUP_EVENTS`,e[e.EVENTS_PROFILE_UPDATE=262145]=`EVENTS_PROFILE_UPDATE`,e[e.EVENTS_SPEECH_PLAYBACK_COMPLETE=262147]=`EVENTS_SPEECH_PLAYBACK_COMPLETE`,e[e.GROUP_ANALYTICS=524288]=`GROUP_ANALYTICS`,e[e.ANALYTICS_LOGS=524289]=`ANALYTICS_LOGS`,e[e.ANALYTICS_EVENTS=524290]=`ANALYTICS_EVENTS`,e[e.ANALYTICS_USAGES=524291]=`ANALYTICS_USAGES`,e[e.ANALYTICS_USAGE=524292]=`ANALYTICS_USAGE`,e[e.ANALYTICS_SPECIAL_LOG=524293]=`ANALYTICS_SPECIAL_LOG`,e[e.ANALYTICS_PROCESSING_UPDATE=524294]=`ANALYTICS_PROCESSING_UPDATE`,e[e.ANALYTICS_REACTIVE_PROCESSING_UPDATE=524295]=`ANALYTICS_REACTIVE_PROCESSING_UPDATE`,e[e.ANALYTICS_IKON_PROXY_SERVER_STATS=524296]=`ANALYTICS_IKON_PROXY_SERVER_STATS`,e[e.ANALYTICS_IKON_RELAY_SERVER_STATS=524297]=`ANALYTICS_IKON_RELAY_SERVER_STATS`,e[e.ANALYTICS_IKON_TURN_SERVER_STATS=524298]=`ANALYTICS_IKON_TURN_SERVER_STATS`,e[e.ANALYTICS_IKON_HOST_SERVER_STATS=524299]=`ANALYTICS_IKON_HOST_SERVER_STATS`,e[e.GROUP_ACTIONS=1048576]=`GROUP_ACTIONS`,e[e.ACTION_CALL=1048577]=`ACTION_CALL`,e[e.ACTION_ACTIVE=1048578]=`ACTION_ACTIVE`,e[e.ACTION_TEXT_OUTPUT=1048579]=`ACTION_TEXT_OUTPUT`,e[e.ACTION_TEXT_OUTPUT_DELTA=1048580]=`ACTION_TEXT_OUTPUT_DELTA`,e[e.ACTION_TEXT_OUTPUT_DELTA_FULL=1048581]=`ACTION_TEXT_OUTPUT_DELTA_FULL`,e[e.ACTION_SET_STATE=1048582]=`ACTION_SET_STATE`,e[e.ACTION_TAP=1048583]=`ACTION_TAP`,e[e.ACTION_PAN=1048584]=`ACTION_PAN`,e[e.ACTION_ZOOM=1048585]=`ACTION_ZOOM`,e[e.ACTION_FILE_UPLOAD_BEGIN=1048586]=`ACTION_FILE_UPLOAD_BEGIN`,e[e.ACTION_FILE_UPLOAD_DATA=1048587]=`ACTION_FILE_UPLOAD_DATA`,e[e.ACTION_FILE_UPLOAD_ACK=1048588]=`ACTION_FILE_UPLOAD_ACK`,e[e.ACTION_FILE_UPLOAD_END=1048589]=`ACTION_FILE_UPLOAD_END`,e[e.ACTION_FILE_UPLOAD_RESULT=1048590]=`ACTION_FILE_UPLOAD_RESULT`,e[e.ACTION_OPEN_EXTERNAL_URL=1048592]=`ACTION_OPEN_EXTERNAL_URL`,e[e.ACTION_FUNCTION_REGISTER=1048600]=`ACTION_FUNCTION_REGISTER`,e[e.ACTION_FUNCTION_CALL=1048601]=`ACTION_FUNCTION_CALL`,e[e.ACTION_FUNCTION_RESULT=1048602]=`ACTION_FUNCTION_RESULT`,e[e.ACTION_GENERATE_ANSWER=1048603]=`ACTION_GENERATE_ANSWER`,e[e.ACTION_REGENERATE_ANSWER=1048604]=`ACTION_REGENERATE_ANSWER`,e[e.ACTION_CLEAR_STATE=1048606]=`ACTION_CLEAR_STATE`,e[e.ACTION_CLASSIFICATION_RESULT=1048609]=`ACTION_CLASSIFICATION_RESULT`,e[e.ACTION_AUDIO_STOP=1048610]=`ACTION_AUDIO_STOP`,e[e.ACTION_CALL_TEXT=1048611]=`ACTION_CALL_TEXT`,e[e.ACTION_CANCEL_GENERATION=1048613]=`ACTION_CANCEL_GENERATION`,e[e.ACTION_SPEECH_RECOGNIZED=1048615]=`ACTION_SPEECH_RECOGNIZED`,e[e.ACTION_CALL_RESULT=1048616]=`ACTION_CALL_RESULT`,e[e.ACTION_DOWNLOAD=1048618]=`ACTION_DOWNLOAD`,e[e.ACTION_PLAY_SOUND=1048621]=`ACTION_PLAY_SOUND`,e[e.ACTION_STOP_SOUND=1048623]=`ACTION_STOP_SOUND`,e[e.ACTION_START_RECORDING=1048624]=`ACTION_START_RECORDING`,e[e.ACTION_STOP_RECORDING=1048625]=`ACTION_STOP_RECORDING`,e[e.ACTION_FUNCTION_ENUMERATION_ITEM=1048627]=`ACTION_FUNCTION_ENUMERATION_ITEM`,e[e.ACTION_FUNCTION_ENUMERATION_END=1048628]=`ACTION_FUNCTION_ENUMERATION_END`,e[e.ACTION_FUNCTION_CANCEL=1048629]=`ACTION_FUNCTION_CANCEL`,e[e.ACTION_FUNCTION_DISPOSE=1048630]=`ACTION_FUNCTION_DISPOSE`,e[e.ACTION_FUNCTION_ERROR=1048631]=`ACTION_FUNCTION_ERROR`,e[e.ACTION_FUNCTION_ACK=1048632]=`ACTION_FUNCTION_ACK`,e[e.ACTION_FUNCTION_AWAITING_APPROVAL=1048633]=`ACTION_FUNCTION_AWAITING_APPROVAL`,e[e.ACTION_FUNCTION_APPROVAL_REQUIRED=1048634]=`ACTION_FUNCTION_APPROVAL_REQUIRED`,e[e.ACTION_FUNCTION_APPROVAL_RESPONSE=1048635]=`ACTION_FUNCTION_APPROVAL_RESPONSE`,e[e.UI_UPDATE_ACK=1048636]=`UI_UPDATE_ACK`,e[e.ACTION_CALL2=1048637]=`ACTION_CALL2`,e[e.ACTION_FUNCTION_REGISTER_BATCH=1048638]=`ACTION_FUNCTION_REGISTER_BATCH`,e[e.ACTION_FILE_UPLOAD_CALLBACK=1048640]=`ACTION_FILE_UPLOAD_CALLBACK`,e[e.ACTION_CUSTOM_USER_MESSAGE=1048641]=`ACTION_CUSTOM_USER_MESSAGE`,e[e.ACTION_URL_CHANGED=1048642]=`ACTION_URL_CHANGED`,e[e.ACTION_FILE_UPLOAD_PRE_START2=1048643]=`ACTION_FILE_UPLOAD_PRE_START2`,e[e.ACTION_FILE_UPLOAD_PRE_START_RESPONSE2=1048644]=`ACTION_FILE_UPLOAD_PRE_START_RESPONSE2`,e[e.ACTION_FILE_UPLOAD_START2=1048645]=`ACTION_FILE_UPLOAD_START2`,e[e.ACTION_FILE_UPLOAD_START_RESPONSE2=1048646]=`ACTION_FILE_UPLOAD_START_RESPONSE2`,e[e.ACTION_FILE_UPLOAD_DATA2=1048647]=`ACTION_FILE_UPLOAD_DATA2`,e[e.ACTION_FILE_UPLOAD_ACK2=1048648]=`ACTION_FILE_UPLOAD_ACK2`,e[e.ACTION_FILE_UPLOAD_END2=1048649]=`ACTION_FILE_UPLOAD_END2`,e[e.ACTION_FILE_UPLOAD_COMPLETE2=1048650]=`ACTION_FILE_UPLOAD_COMPLETE2`,e[e.ACTION_FUNCTION_ENUMERATION_ITEM_BATCH=1048651]=`ACTION_FUNCTION_ENUMERATION_ITEM_BATCH`,e[e.ACTION_CALL_ACK=1048652]=`ACTION_CALL_ACK`,e[e.ACTION_TRIGGER_CRON=1048653]=`ACTION_TRIGGER_CRON`,e[e.ACTION_RESULT=1048654]=`ACTION_RESULT`,e[e.UI_RESYNC_REQUEST=1048655]=`UI_RESYNC_REQUEST`,e[e.ACTION_USER_DATA_ERASURE=1048656]=`ACTION_USER_DATA_ERASURE`,e[e.GROUP_UI=2097152]=`GROUP_UI`,e[e.UI_STREAM_BEGIN=2097153]=`UI_STREAM_BEGIN`,e[e.UI_STREAM_END=2097154]=`UI_STREAM_END`,e[e.UI_STYLES=2097188]=`UI_STYLES`,e[e.UI_UPDATE=2097190]=`UI_UPDATE`,e[e.UI_STYLES_BATCH=2097192]=`UI_STYLES_BATCH`,e[e.UI_STYLES_DELETE=2097193]=`UI_STYLES_DELETE`,e[e.GROUP_COMMON=4128768]=`GROUP_COMMON`,e[e.GROUP_AUDIO=4194304]=`GROUP_AUDIO`,e[e.AUDIO_STREAM_BEGIN=4194305]=`AUDIO_STREAM_BEGIN`,e[e.AUDIO_STREAM_END=4194306]=`AUDIO_STREAM_END`,e[e.AUDIO_FRAME=4194307]=`AUDIO_FRAME`,e[e.AUDIO_FRAME_VOLUME=4194308]=`AUDIO_FRAME_VOLUME`,e[e.AUDIO_FRAME2=4194309]=`AUDIO_FRAME2`,e[e.AUDIO_SHAPE_FRAME=4194310]=`AUDIO_SHAPE_FRAME`,e[e.AUDIO_PLAYBACK_REPORT=4194311]=`AUDIO_PLAYBACK_REPORT`,e[e.GROUP_VIDEO=8388608]=`GROUP_VIDEO`,e[e.VIDEO_STREAM_BEGIN=8388609]=`VIDEO_STREAM_BEGIN`,e[e.VIDEO_STREAM_END=8388610]=`VIDEO_STREAM_END`,e[e.VIDEO_FRAME=8388611]=`VIDEO_FRAME`,e[e.VIDEO_REQUEST_IDR_FRAME=8388612]=`VIDEO_REQUEST_IDR_FRAME`,e[e.VIDEO_INVALIDATE_FRAME=8388613]=`VIDEO_INVALIDATE_FRAME`,e[e.GROUP_ALL=16711680]=`GROUP_ALL`,e[e.GROUP_APP_LOCAL=1073741824]=`GROUP_APP_LOCAL`,e[e.CONSTANT_GROUP_MASK=2147418112]=`CONSTANT_GROUP_MASK`,e}({});function T(e){let t={};return E(t),e&&Object.assign(t,e),t}function E(e){return e.Epoch=0,e.Sequence=0,e.FrameSizeInInterleavedSamples=0,e.TimeStampInInterleavedSamples=BigInt(0),e.ShapeSetValues=[],e}function D(e,t){return O(c.create(e),t)}function O(e,t){let n=t??T();return E(n),ie(e,n),n}function ie(e,t){let n;for(;(n=e.next())!==null;)switch(n.fieldId){case 717315017:if(n.isNull)throw Error();t.ShapeSetValues=k(n.asArray());break;case 2026534360:if(n.isNull)throw Error();t.TimeStampInInterleavedSamples=n.asUInt64();break;case 4007456593:if(n.isNull)throw Error();t.FrameSizeInInterleavedSamples=n.asUInt32();break;case 4065417427:if(n.isNull)throw Error();t.Sequence=n.asUInt32();break;case 4086360332:if(n.isNull)throw Error();t.Epoch=n.asUInt32();break;default:break}}async function ae(e,t){return D(await i(e,4194310,1),t)}function k(e){let t=[],n;for(;(n=e.next())!==null;)t.push(M(n.asObject()));return t}function A(e){let t={};return j(t),e&&Object.assign(t,e),t}function j(e){return e.SetId=0,e.Values=[],e}function M(e,t){let n=t??A();return j(n),N(e,n),n}function N(e,t){let n;for(;(n=e.next())!==null;)switch(n.fieldId){case 1154362099:if(n.isNull)throw Error();t.SetId=n.asUInt32();break;case 3974819915:if(n.isNull)throw Error();t.Values=P(n.asArray());break;default:break}}function P(e){let t=[],n;for(;(n=e.next())!==null;)t.push(n.asFloat32());return t}function F(e){let t={};return I(t),e&&Object.assign(t,e),t}function I(e){return e.StreamId=``,e.Description=``,e.SourceType=``,e.Codec=C.Unknown,e.CodecDetails=``,e.SampleRate=0,e.Channels=0,e.ShapeSets=void 0,e.CorrelationId=void 0,e}function L(e,t){return R(c.create(e),t)}function R(e,t){let n=t??F();return I(n),z(e,n),n}function z(e,t){let n;for(;(n=e.next())!==null;)switch(n.fieldId){case 161083277:if(n.isNull)throw Error();t.StreamId=n.asString();break;case 265814330:if(n.isNull){t.ShapeSets=void 0;break}t.ShapeSets=V(n.asArray());break;case 1368629611:if(n.isNull)throw Error();t.Description=n.asString();break;case 2431514951:if(n.isNull)throw Error();t.Channels=n.asInt32();break;case 2514959030:if(n.isNull){t.CorrelationId=void 0;break}t.CorrelationId=n.asString();break;case 2745379226:if(n.isNull)throw Error();t.CodecDetails=n.asString();break;case 3282782683:if(n.isNull)throw Error();t.SourceType=n.asString();break;case 3284746250:if(n.isNull)throw Error();t.Codec=n.asInt32();break;case 4101844078:if(n.isNull)throw Error();t.SampleRate=n.asInt32();break;default:break}}async function B(e,t){return L(await i(e,4194305,6),t)}function V(e){let t=[],n;for(;(n=e.next())!==null;)t.push(W(n.asObject()));return t}function H(e){let t={};return U(t),e&&Object.assign(t,e),t}function U(e){return e.SetId=0,e.Name=``,e.ShapeNames=[],e}function W(e,t){let n=t??H();return U(n),G(e,n),n}function G(e,t){let n;for(;(n=e.next())!==null;)switch(n.fieldId){case 1107713536:if(n.isNull)throw Error();t.Name=n.asString();break;case 1154362099:if(n.isNull)throw Error();t.SetId=n.asUInt32();break;case 1185721362:if(n.isNull)throw Error();t.ShapeNames=K(n.asArray());break;default:break}}function K(e){let t=[],n;for(;(n=e.next())!==null;)t.push(n.asString());return t}const q=48e3*2,J=new Map;let Y=null;const X=e=>{self.postMessage(e)};function Z(e){let t=r(e);return`${t.senderId}_${t.trackId}`}async function oe(e){Q(Z(e),await B(e))}function Q(e,t){J.set(e,{inputSampleRate:t.SampleRate,inputChannels:t.Channels}),X({type:`streamBegin`,streamId:e,shapeSets:t.ShapeSets??[]})}function se(e){let t=Z(e);J.delete(t),X({type:`streamEnd`,streamId:t})}async function ce(e){let t=Z(e),n=J.get(t);if(!n)return;let r=await ae(e),i=n.inputSampleRate*n.inputChannels;X({type:`shapeFrame`,streamId:t,epoch:r.Epoch,timestampInterleavedSamples:Math.round(Number(r.TimeStampInInterleavedSamples)*q/i),frameSizeInterleavedSamples:Math.round(r.FrameSizeInInterleavedSamples*q/i),shapeSetValues:r.ShapeSetValues})}function le(e){switch(n(t(e))){case w.AUDIO_STREAM_BEGIN:oe(e);return;case w.AUDIO_STREAM_END:se(e);return;case w.AUDIO_SHAPE_FRAME:ce(e);return;default:return}}function $(){if(Y){try{Y.close()}catch{}Y=null}}self.addEventListener(`message`,e=>{let t=e.data;if(t.type===`attachProtocolPort`){$(),Y=t.port,Y.addEventListener(`message`,e=>{let t=e.data;t?.type===`protocol`&&t.message instanceof ArrayBuffer&&le(new Uint8Array(t.message))}),Y.start?.();return}if(t.type===`syncStreams`){for(let e of t.streams){let t=`${e.senderId}_${e.trackId}`;J.has(t)||Q(t,e.info)}return}if(t.type===`dispose`){$(),J.clear();return}});
1
+ const e={None:0,SendBackToSender:1,Delayable:2,SendToUser:4,Compressed:8,Unreliable:16};function t(e){return e}function n(e){if(e.length<8)throw Error(`Protocol message too short`);return(e[4]|e[5]<<8|e[6]<<16|e[7]<<24)>>>0}function r(e){let t=S(e),n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(t.length<27)throw Error(`Protocol payload too short`);let r=n.getUint32(0,!0),i=n.getUint32(4,!0),a=n.getUint32(8,!0),o=n.getUint32(12,!0),s=n.getUint32(16,!0),c=n.getUint32(20,!0),l=n.getUint8(24),u=n.getUint8(25),d=n.getUint8(26);if(27+c*4>t.length)throw Error(`Protocol header exceeds payload length`);let f=[],p=27;for(let e=0;e<c;e++)f.push(n.getUint32(p,!0)),p+=4;return{length:r,opcode:i,senderId:a,trackId:o,sequenceId:s,targetIds:f,payloadVersion:l,payloadType:u,flags:d}}async function i(t,n,i){let o=S(t),s=r(o);if(n!==void 0&&s.opcode!==n)throw Error(`Unexpected opcode ${s.opcode}`);if(s.payloadType!==8)throw Error(`Unexpected payload type ${s.payloadType}`);let c=27+s.targetIds.length*4,l=o.subarray(c,s.length);return(s.flags&e.Compressed)!==0&&(l=await a(l)),l}async function a(e){if(typeof DecompressionStream>`u`)throw Error(`DecompressionStream not supported`);let t=new DecompressionStream(`gzip`),n=t.writable.getWriter(),r=new Uint8Array(e);n.write(r).then(()=>n.close()).catch(()=>void 0);let i=t.readable.getReader(),a=[],o=0;for(;;){let{done:e,value:t}=await i.read();if(e)break;a.push(t),o+=t.length}let s=new Uint8Array(o),c=0;for(let e=0;e<a.length;e++)s.set(a[e],c),c+=a[e].length;return s}let o=function(e){return e[e.Null=1]=`Null`,e[e.Bool=2]=`Bool`,e[e.Int32=3]=`Int32`,e[e.Int64=4]=`Int64`,e[e.UInt32=5]=`UInt32`,e[e.UInt64=6]=`UInt64`,e[e.Float32=7]=`Float32`,e[e.Float64=8]=`Float64`,e[e.Array=9]=`Array`,e[e.Dict=10]=`Dict`,e[e.Object=11]=`Object`,e[e.String=12]=`String`,e[e.Binary=13]=`Binary`,e[e.Guid=14]=`Guid`,e}({});new TextEncoder;const s=new TextDecoder(`utf-8`,{fatal:!0});var c=class e{buffer;version;offset;end;constructor(e,t,n){this.buffer=e,this.version=t,this.offset=n,this.end=e.length-1}static create(t){let n=S(t);if(n.length<2)throw Error(`Teleport payload too short`);if(n[0]!==161||n[n.length-1]!==162)throw Error(`Teleport object missing markers`);let r={offset:1},i=m(n,r,`InvalidLength`);return new e(n,i,r.offset)}next(){if(this.offset>=this.end)return null;if(this.offset+5>this.buffer.length)throw Error(`Teleport object truncated`);let e=re(this.buffer,this.offset);this.offset+=4;let t=this.buffer[this.offset++],n=t>>4&15;if(t&15)throw Error(`Teleport field flags must be zero`);let r=h(n),i;if(r>=0)_(this.buffer,this.offset,r),i=this.buffer.subarray(this.offset,this.offset+r),this.offset+=r;else{let e={offset:this.offset},t=m(this.buffer,e,`InvalidLength`);_(this.buffer,e.offset,t),i=this.buffer.subarray(e.offset,e.offset+t),this.offset=e.offset+t}return new u(e,n,i)}},l=class{type;payload;constructor(e,t){this.type=e,this.payload=t}asInt32(){return this.ensureType(3),new DataView(this.payload.buffer,this.payload.byteOffset,4).getInt32(0,!0)}asUInt32(){return this.ensureType(5),new DataView(this.payload.buffer,this.payload.byteOffset,4).getUint32(0,!0)}asInt64(){return this.ensureType(4),new DataView(this.payload.buffer,this.payload.byteOffset,8).getBigInt64(0,!0)}asUInt64(){return this.ensureType(6),new DataView(this.payload.buffer,this.payload.byteOffset,8).getBigUint64(0,!0)}asFloat32(){return this.ensureType(7),new DataView(this.payload.buffer,this.payload.byteOffset,4).getFloat32(0,!0)}asFloat64(){return this.ensureType(8),new DataView(this.payload.buffer,this.payload.byteOffset,8).getFloat64(0,!0)}asBool(){return this.ensureType(2),this.payload.length>0&&this.payload[0]!==0}asBinary(){return this.ensureType(13),this.payload}asUtf8(){return this.ensureType(12),this.payload}asString(){return this.ensureType(12),s.decode(this.payload)}asGuid(){return this.ensureType(14),te.fromBytes(this.payload)}asObject(){return this.ensureType(11),c.create(this.payload)}asArray(){return this.ensureType(9),d.create(this.payload)}asDictionary(){return this.ensureType(10),p.create(this.payload)}ensureType(e){if(this.type!==e)throw Error(`Teleport value has type ${o[this.type]}, expected ${o[e]}`)}},u=class extends l{fieldId;constructor(e,t,n){super(t,n),this.fieldId=e}get isNull(){return this.type===1}},d=class e{payload;elementType;count;offset;index=0;constructor(e){if(this.payload=e,e.length===0)throw Error(`Array payload too short`);let t=e[0];if(this.elementType=t>>4&15,t&15)throw Error(`Array flags must be zero`);let n={offset:1};this.count=m(e,n,`ArrayMalformed`),this.offset=n.offset}static create(t){return new e(S(t))}next(){if(this.index>=this.count){if(this.offset!==this.payload.length)throw Error(`Array payload contains trailing data`);return null}let e=this.readValue();return this.index++,e}readValue(){switch(this.elementType){case 3:case 5:case 7:case 8:case 2:case 4:case 6:case 14:{let e=h(this.elementType);_(this.payload,this.offset,e);let t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new f(this.elementType,t)}case 12:case 13:{let e={offset:this.offset},t=m(this.payload,e,`ArrayMalformed`);_(this.payload,e.offset,t);let n=this.payload.subarray(e.offset,e.offset+t);return this.offset=e.offset+t,new f(this.elementType,n)}case 11:{let e={offset:this.offset},t=m(this.payload,e,`ArrayMalformed`);_(this.payload,e.offset,t);let n=this.payload.subarray(e.offset,e.offset+t);return this.offset=e.offset+t,new f(11,n)}case 9:{let e=v(this.payload,this.offset),t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new f(9,t)}case 10:{let e=y(this.payload,this.offset),t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new f(10,t)}default:throw Error(`Unsupported array element type ${o[this.elementType]}`)}}},f=class extends l{constructor(e,t){super(e,t)}},p=class e{payload;keyType;valueType;count;offset;index=0;constructor(e){if(this.payload=e,e.length<2)throw Error(`Dictionary payload too short`);if(this.keyType=e[0]>>4&15,this.valueType=e[1]>>4&15,e[0]&15||e[1]&15)throw Error(`Dictionary key/value flags must be zero`);g(this.keyType);let t={offset:2};this.count=m(e,t,`DictMalformed`),this.offset=t.offset}static create(t){return new e(S(t))}next(){if(this.index>=this.count){if(this.offset!==this.payload.length)throw Error(`Dictionary payload contains trailing data`);return null}let e=this.readKey(),t=this.readValue();return this.index++,new ee(e,t)}readKey(){let e=h(this.keyType);if(e>=0){_(this.payload,this.offset,e);let t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new l(this.keyType,t)}if(this.keyType===12||this.keyType===13){let e={offset:this.offset},t=m(this.payload,e,`DictMalformed`);_(this.payload,e.offset,t);let n=this.payload.subarray(e.offset,e.offset+t);return this.offset=e.offset+t,new l(this.keyType,n)}throw Error(`Unsupported dictionary key type`)}readValue(){switch(this.valueType){case 12:case 13:{let e={offset:this.offset},t=m(this.payload,e,`DictMalformed`);_(this.payload,e.offset,t);let n=this.payload.subarray(e.offset,e.offset+t);return this.offset=e.offset+t,new l(this.valueType,n)}case 11:{let e={offset:this.offset},t=m(this.payload,e,`DictMalformed`);_(this.payload,e.offset,t);let n=this.payload.subarray(e.offset,e.offset+t);return this.offset=e.offset+t,new l(11,n)}case 9:{let e=v(this.payload,this.offset),t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new l(9,t)}case 10:{let e=y(this.payload,this.offset),t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new l(10,t)}case 3:case 5:case 7:case 8:case 2:case 4:case 6:case 14:case 1:{let e=h(this.valueType);_(this.payload,this.offset,e);let t=this.payload.subarray(this.offset,this.offset+e);return this.offset+=e,new l(this.valueType,t)}default:throw Error(`Unsupported dictionary value type ${o[this.valueType]}`)}}},ee=class{key;value;constructor(e,t){this.key=e,this.value=t}},te=class e{bytes;constructor(e){this.bytes=e}static fromString(t){if(!t)throw Error(`Guid string is empty`);let n=t.replace(/-/g,``);if(n.length!==32)throw Error(`Guid string must be 32 hex characters`);let r=new Uint8Array(16),i=e.parseHexSlice(n,0,8),a=e.parseHexSlice(n,8,4),o=e.parseHexSlice(n,12,4);e.writeUInt32LE(r,0,i),e.writeUInt16LE(r,4,a),e.writeUInt16LE(r,6,o);for(let t=0;t<8;t++)r[8+t]=e.parseHexSlice(n,16+t*2,2);return new e(r)}static fromBytes(t){if(t.length!==16)throw Error(`Guid byte array must be 16 bytes`);return new e(Uint8Array.from(t))}static createZero(){return new e(new Uint8Array(16))}static createRandom(){let t=new Uint8Array(16),n=globalThis.crypto;if(n?.getRandomValues)n.getRandomValues(t);else for(let e=0;e<t.length;e++)t[e]=Math.floor(Math.random()*256);return t[6]=t[6]&15|64,t[8]=t[8]&63|128,new e(t)}toString(){let t=this.bytes;return[e.toHex(e.readUInt32LE(t,0),8),e.toHex(e.readUInt16LE(t,4),4),e.toHex(e.readUInt16LE(t,6),4),x(t.subarray(8,10)),x(t.subarray(10,16))].join(`-`)}asBytes(){return this.bytes.slice()}static parseHexSlice(e,t,n){let r=e.substr(t,n),i=Number.parseInt(r,16);if(Number.isNaN(i))throw Error(`Guid string contains invalid characters`);return i>>>0}static writeUInt32LE(e,t,n){let r=n>>>0;e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24&255}static writeUInt16LE(e,t,n){let r=n&65535;e[t]=r&255,e[t+1]=r>>>8&255}static readUInt32LE(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}static readUInt16LE(e,t){return(e[t]|e[t+1]<<8)&65535}static toHex(e,t){return(e>>>0).toString(16).padStart(t,`0`)}};function m(e,t,n){if(t.offset>=e.length)throw Error(n);let r=0,i=0,a=0;for(;t.offset<e.length;){let n=e[t.offset++];if(a++,r|=(n&127)<<i,!(n&128)){if(a!==ne(r))throw Error(`Teleport VarUInt is not canonical`);return r>>>0}if(i+=7,i>=35)throw Error(`Teleport VarUInt exceeds 32-bit range`)}throw Error(n)}function ne(e){return e<128?1:e<16384?2:e<2097152?3:e<268435456?4:5}function h(e){switch(e){case 3:case 5:case 7:return 4;case 4:case 6:case 8:return 8;case 14:return 16;case 2:return 1;case 1:return 0;default:return-1}}function g(e){if(e===9||e===11||e===10||e===1)throw Error(`Dictionary keys must be primitive Teleport types`)}function _(e,t,n){if(t<0||n<0||t+n>e.length)throw Error(`Teleport payload exceeds bounds`)}function re(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function v(e,t){if(t>=e.length)throw Error(`Array payload exceeds bounds`);let n=e[t],r=n>>4&15;if(n&15)throw Error(`Array flags must be zero`);let i={offset:t+1},a=m(e,i,`ArrayMalformed`),o=h(r);if(o>=0){let n=o*a;return _(e,i.offset,n),i.offset+n-t}let s=i.offset;for(let t=0;t<a;t++)s=b(r,e,s,`ArrayMalformed`);return s-t}function y(e,t){if(t+2>e.length)throw Error(`Dictionary payload too short`);let n=e[t]>>4&15,r=e[t+1]>>4&15;if(e[t]&15||e[t+1]&15)throw Error(`Dictionary key/value flags must be zero`);g(n);let i={offset:t+2},a=m(e,i,`DictMalformed`),o=i.offset;for(let t=0;t<a;t++)o=b(n,e,o,`DictMalformed`),o=b(r,e,o,`DictMalformed`);return o-t}function b(e,t,n,r){let i=h(e);if(i>=0)return _(t,n,i),n+i;switch(e){case 12:case 13:{let e={offset:n},i=m(t,e,r);return _(t,e.offset,i),e.offset+i}case 11:{let e={offset:n},i=m(t,e,r);return _(t,e.offset,i),e.offset+i}case 9:return n+v(t,n);case 10:return n+y(t,n);default:throw Error(`Unsupported Teleport type ${o[e]}`)}}function x(e){return Array.from(e).map(e=>e.toString(16).padStart(2,`0`)).join(``)}function S(e){return e instanceof Uint8Array?e:new Uint8Array(e)}let C=function(e){return e[e.Unknown=0]=`Unknown`,e[e.Opus=1]=`Opus`,e[e.Mp3=2]=`Mp3`,e[e.RawPcm16=3]=`RawPcm16`,e}({}),w=function(e){return e[e.NONE=0]=`NONE`,e[e.CONSTANT_GROUP_BITS=15]=`CONSTANT_GROUP_BITS`,e[e.CONSTANT_GROUP_OFFSET=16]=`CONSTANT_GROUP_OFFSET`,e[e.GROUP_CORE=65536]=`GROUP_CORE`,e[e.CORE_AUTH_RESPONSE=65537]=`CORE_AUTH_RESPONSE`,e[e.CORE_AUTH_TICKET=65538]=`CORE_AUTH_TICKET`,e[e.CORE_GLOBAL_STATE=65539]=`CORE_GLOBAL_STATE`,e[e.CORE_ON_SERVER_STATUS_PING=65540]=`CORE_ON_SERVER_STATUS_PING`,e[e.CORE_ON_USER_JOINED=65541]=`CORE_ON_USER_JOINED`,e[e.CORE_ON_USER_LEFT=65542]=`CORE_ON_USER_LEFT`,e[e.CORE_ON_CLIENT_JOINED=65543]=`CORE_ON_CLIENT_JOINED`,e[e.CORE_ON_CLIENT_LEFT=65544]=`CORE_ON_CLIENT_LEFT`,e[e.CORE_ON_SERVER_STARTED=65545]=`CORE_ON_SERVER_STARTED`,e[e.CORE_ON_SERVER_STOPPED=65546]=`CORE_ON_SERVER_STOPPED`,e[e.CORE_ON_SERVER_STOPPING=65547]=`CORE_ON_SERVER_STOPPING`,e[e.CORE_ON_CLIENT_READY=65548]=`CORE_ON_CLIENT_READY`,e[e.CORE_CLIENT_READY=65549]=`CORE_CLIENT_READY`,e[e.CORE_SERVER_INIT=65550]=`CORE_SERVER_INIT`,e[e.CORE_ON_PLUGIN_RELOADED=65551]=`CORE_ON_PLUGIN_RELOADED`,e[e.CORE_DYNAMIC_CONFIG=65555]=`CORE_DYNAMIC_CONFIG`,e[e.CORE_PROXY_RPC_AUTH_TICKET=65556]=`CORE_PROXY_RPC_AUTH_TICKET`,e[e.CORE_UPDATE_CLIENT_CONTEXT=65558]=`CORE_UPDATE_CLIENT_CONTEXT`,e[e.CORE_BACKGROUND_WORK_ACTIVE=65559]=`CORE_BACKGROUND_WORK_ACTIVE`,e[e.CORE_RESET_IDLE=65560]=`CORE_RESET_IDLE`,e[e.CORE_CLIENT_DISCONNECTING=65561]=`CORE_CLIENT_DISCONNECTING`,e[e.CORE_ON_APP_READY=65562]=`CORE_ON_APP_READY`,e[e.CORE_ON_FRONTEND_RELOADED=65563]=`CORE_ON_FRONTEND_RELOADED`,e[e.CORE_ON_USER_DATA_ERASED=65564]=`CORE_ON_USER_DATA_ERASED`,e[e.CORE_WEBRTC_OFFER=65566]=`CORE_WEBRTC_OFFER`,e[e.CORE_WEBRTC_ANSWER=65567]=`CORE_WEBRTC_ANSWER`,e[e.CORE_WEBRTC_ICE_CANDIDATE=65568]=`CORE_WEBRTC_ICE_CANDIDATE`,e[e.CORE_WEBRTC_READY=65569]=`CORE_WEBRTC_READY`,e[e.CORE_WEBRTC_AUDIO_SEGMENT=65570]=`CORE_WEBRTC_AUDIO_SEGMENT`,e[e.CORE_WEBRTC_TRACK_MAP=65571]=`CORE_WEBRTC_TRACK_MAP`,e[e.CORE_WEBRTC_VIDEO_CAPTURE=65572]=`CORE_WEBRTC_VIDEO_CAPTURE`,e[e.CORE_WEBRTC_ICE_SERVERS_REQUEST=65573]=`CORE_WEBRTC_ICE_SERVERS_REQUEST`,e[e.CORE_WEBRTC_ICE_SERVERS_RESPONSE=65574]=`CORE_WEBRTC_ICE_SERVERS_RESPONSE`,e[e.CORE_WEBRTC_CLOSE=65575]=`CORE_WEBRTC_CLOSE`,e[e.CORE_RELAY_AGENT_AUTH=65576]=`CORE_RELAY_AGENT_AUTH`,e[e.CORE_RELAY_AGENT_AUTH_RESULT=65577]=`CORE_RELAY_AGENT_AUTH_RESULT`,e[e.CORE_RELAY_HEARTBEAT=65578]=`CORE_RELAY_HEARTBEAT`,e[e.CORE_RELAY_TCP_CONNECTION_OPENED=65579]=`CORE_RELAY_TCP_CONNECTION_OPENED`,e[e.CORE_RELAY_TCP_CONNECTION_CLOSED=65580]=`CORE_RELAY_TCP_CONNECTION_CLOSED`,e[e.CORE_RELAY_TCP_DATA=65581]=`CORE_RELAY_TCP_DATA`,e[e.CORE_RELAY_UDP_DATA=65582]=`CORE_RELAY_UDP_DATA`,e[e.CORE_RELAY_ADD_TUNNEL=65583]=`CORE_RELAY_ADD_TUNNEL`,e[e.CORE_RELAY_TUNNEL_ADDED=65584]=`CORE_RELAY_TUNNEL_ADDED`,e[e.CORE_RELAY_REMOVE_TUNNEL=65585]=`CORE_RELAY_REMOVE_TUNNEL`,e[e.CORE_IKON_SERVER_ENDPOINT_HOST_INFO=65586]=`CORE_IKON_SERVER_ENDPOINT_HOST_INFO`,e[e.CORE_CLIENT_INITIALIZATION=65587]=`CORE_CLIENT_INITIALIZATION`,e[e.CORE_CLIENT_LIFECYCLE_BATCH=65588]=`CORE_CLIENT_LIFECYCLE_BATCH`,e[e.CORE_APP_CONFIG=65589]=`CORE_APP_CONFIG`,e[e.GROUP_KEEPALIVE=131072]=`GROUP_KEEPALIVE`,e[e.KEEPALIVE_REQUEST=131073]=`KEEPALIVE_REQUEST`,e[e.KEEPALIVE_RESPONSE=131074]=`KEEPALIVE_RESPONSE`,e[e.GROUP_EVENTS=262144]=`GROUP_EVENTS`,e[e.EVENTS_PROFILE_UPDATE=262145]=`EVENTS_PROFILE_UPDATE`,e[e.EVENTS_SPEECH_PLAYBACK_COMPLETE=262147]=`EVENTS_SPEECH_PLAYBACK_COMPLETE`,e[e.GROUP_ANALYTICS=524288]=`GROUP_ANALYTICS`,e[e.ANALYTICS_LOGS=524289]=`ANALYTICS_LOGS`,e[e.ANALYTICS_EVENTS=524290]=`ANALYTICS_EVENTS`,e[e.ANALYTICS_USAGES=524291]=`ANALYTICS_USAGES`,e[e.ANALYTICS_USAGE=524292]=`ANALYTICS_USAGE`,e[e.ANALYTICS_SPECIAL_LOG=524293]=`ANALYTICS_SPECIAL_LOG`,e[e.ANALYTICS_PROCESSING_UPDATE=524294]=`ANALYTICS_PROCESSING_UPDATE`,e[e.ANALYTICS_REACTIVE_PROCESSING_UPDATE=524295]=`ANALYTICS_REACTIVE_PROCESSING_UPDATE`,e[e.ANALYTICS_IKON_PROXY_SERVER_STATS=524296]=`ANALYTICS_IKON_PROXY_SERVER_STATS`,e[e.ANALYTICS_IKON_RELAY_SERVER_STATS=524297]=`ANALYTICS_IKON_RELAY_SERVER_STATS`,e[e.ANALYTICS_IKON_TURN_SERVER_STATS=524298]=`ANALYTICS_IKON_TURN_SERVER_STATS`,e[e.ANALYTICS_IKON_HOST_SERVER_STATS=524299]=`ANALYTICS_IKON_HOST_SERVER_STATS`,e[e.GROUP_ACTIONS=1048576]=`GROUP_ACTIONS`,e[e.ACTION_CALL=1048577]=`ACTION_CALL`,e[e.ACTION_ACTIVE=1048578]=`ACTION_ACTIVE`,e[e.ACTION_TEXT_OUTPUT=1048579]=`ACTION_TEXT_OUTPUT`,e[e.ACTION_TEXT_OUTPUT_DELTA=1048580]=`ACTION_TEXT_OUTPUT_DELTA`,e[e.ACTION_TEXT_OUTPUT_DELTA_FULL=1048581]=`ACTION_TEXT_OUTPUT_DELTA_FULL`,e[e.ACTION_SET_STATE=1048582]=`ACTION_SET_STATE`,e[e.ACTION_TAP=1048583]=`ACTION_TAP`,e[e.ACTION_PAN=1048584]=`ACTION_PAN`,e[e.ACTION_ZOOM=1048585]=`ACTION_ZOOM`,e[e.ACTION_FILE_UPLOAD_BEGIN=1048586]=`ACTION_FILE_UPLOAD_BEGIN`,e[e.ACTION_FILE_UPLOAD_DATA=1048587]=`ACTION_FILE_UPLOAD_DATA`,e[e.ACTION_FILE_UPLOAD_ACK=1048588]=`ACTION_FILE_UPLOAD_ACK`,e[e.ACTION_FILE_UPLOAD_END=1048589]=`ACTION_FILE_UPLOAD_END`,e[e.ACTION_FILE_UPLOAD_RESULT=1048590]=`ACTION_FILE_UPLOAD_RESULT`,e[e.ACTION_OPEN_EXTERNAL_URL=1048592]=`ACTION_OPEN_EXTERNAL_URL`,e[e.ACTION_FUNCTION_REGISTER=1048600]=`ACTION_FUNCTION_REGISTER`,e[e.ACTION_FUNCTION_CALL=1048601]=`ACTION_FUNCTION_CALL`,e[e.ACTION_FUNCTION_RESULT=1048602]=`ACTION_FUNCTION_RESULT`,e[e.ACTION_GENERATE_ANSWER=1048603]=`ACTION_GENERATE_ANSWER`,e[e.ACTION_REGENERATE_ANSWER=1048604]=`ACTION_REGENERATE_ANSWER`,e[e.ACTION_CLEAR_STATE=1048606]=`ACTION_CLEAR_STATE`,e[e.ACTION_CLASSIFICATION_RESULT=1048609]=`ACTION_CLASSIFICATION_RESULT`,e[e.ACTION_AUDIO_STOP=1048610]=`ACTION_AUDIO_STOP`,e[e.ACTION_CALL_TEXT=1048611]=`ACTION_CALL_TEXT`,e[e.ACTION_CANCEL_GENERATION=1048613]=`ACTION_CANCEL_GENERATION`,e[e.ACTION_SPEECH_RECOGNIZED=1048615]=`ACTION_SPEECH_RECOGNIZED`,e[e.ACTION_CALL_RESULT=1048616]=`ACTION_CALL_RESULT`,e[e.ACTION_DOWNLOAD=1048618]=`ACTION_DOWNLOAD`,e[e.ACTION_PLAY_SOUND=1048621]=`ACTION_PLAY_SOUND`,e[e.ACTION_STOP_SOUND=1048623]=`ACTION_STOP_SOUND`,e[e.ACTION_START_RECORDING=1048624]=`ACTION_START_RECORDING`,e[e.ACTION_STOP_RECORDING=1048625]=`ACTION_STOP_RECORDING`,e[e.ACTION_FUNCTION_ENUMERATION_ITEM=1048627]=`ACTION_FUNCTION_ENUMERATION_ITEM`,e[e.ACTION_FUNCTION_ENUMERATION_END=1048628]=`ACTION_FUNCTION_ENUMERATION_END`,e[e.ACTION_FUNCTION_CANCEL=1048629]=`ACTION_FUNCTION_CANCEL`,e[e.ACTION_FUNCTION_DISPOSE=1048630]=`ACTION_FUNCTION_DISPOSE`,e[e.ACTION_FUNCTION_ERROR=1048631]=`ACTION_FUNCTION_ERROR`,e[e.ACTION_FUNCTION_ACK=1048632]=`ACTION_FUNCTION_ACK`,e[e.ACTION_FUNCTION_AWAITING_APPROVAL=1048633]=`ACTION_FUNCTION_AWAITING_APPROVAL`,e[e.ACTION_FUNCTION_APPROVAL_REQUIRED=1048634]=`ACTION_FUNCTION_APPROVAL_REQUIRED`,e[e.ACTION_FUNCTION_APPROVAL_RESPONSE=1048635]=`ACTION_FUNCTION_APPROVAL_RESPONSE`,e[e.UI_UPDATE_ACK=1048636]=`UI_UPDATE_ACK`,e[e.ACTION_CALL2=1048637]=`ACTION_CALL2`,e[e.ACTION_FUNCTION_REGISTER_BATCH=1048638]=`ACTION_FUNCTION_REGISTER_BATCH`,e[e.ACTION_FILE_UPLOAD_CALLBACK=1048640]=`ACTION_FILE_UPLOAD_CALLBACK`,e[e.ACTION_CUSTOM_USER_MESSAGE=1048641]=`ACTION_CUSTOM_USER_MESSAGE`,e[e.ACTION_URL_CHANGED=1048642]=`ACTION_URL_CHANGED`,e[e.ACTION_FILE_UPLOAD_PRE_START2=1048643]=`ACTION_FILE_UPLOAD_PRE_START2`,e[e.ACTION_FILE_UPLOAD_PRE_START_RESPONSE2=1048644]=`ACTION_FILE_UPLOAD_PRE_START_RESPONSE2`,e[e.ACTION_FILE_UPLOAD_START2=1048645]=`ACTION_FILE_UPLOAD_START2`,e[e.ACTION_FILE_UPLOAD_START_RESPONSE2=1048646]=`ACTION_FILE_UPLOAD_START_RESPONSE2`,e[e.ACTION_FILE_UPLOAD_DATA2=1048647]=`ACTION_FILE_UPLOAD_DATA2`,e[e.ACTION_FILE_UPLOAD_ACK2=1048648]=`ACTION_FILE_UPLOAD_ACK2`,e[e.ACTION_FILE_UPLOAD_END2=1048649]=`ACTION_FILE_UPLOAD_END2`,e[e.ACTION_FILE_UPLOAD_COMPLETE2=1048650]=`ACTION_FILE_UPLOAD_COMPLETE2`,e[e.ACTION_FUNCTION_ENUMERATION_ITEM_BATCH=1048651]=`ACTION_FUNCTION_ENUMERATION_ITEM_BATCH`,e[e.ACTION_CALL_ACK=1048652]=`ACTION_CALL_ACK`,e[e.ACTION_TRIGGER_CRON=1048653]=`ACTION_TRIGGER_CRON`,e[e.ACTION_RESULT=1048654]=`ACTION_RESULT`,e[e.UI_RESYNC_REQUEST=1048655]=`UI_RESYNC_REQUEST`,e[e.ACTION_USER_DATA_ERASURE=1048656]=`ACTION_USER_DATA_ERASURE`,e[e.GROUP_UI=2097152]=`GROUP_UI`,e[e.UI_STREAM_BEGIN=2097153]=`UI_STREAM_BEGIN`,e[e.UI_STREAM_END=2097154]=`UI_STREAM_END`,e[e.UI_STYLES=2097188]=`UI_STYLES`,e[e.UI_UPDATE=2097190]=`UI_UPDATE`,e[e.UI_STYLES_BATCH=2097192]=`UI_STYLES_BATCH`,e[e.UI_STYLES_DELETE=2097193]=`UI_STYLES_DELETE`,e[e.GROUP_COMMON=4128768]=`GROUP_COMMON`,e[e.GROUP_AUDIO=4194304]=`GROUP_AUDIO`,e[e.AUDIO_STREAM_BEGIN=4194305]=`AUDIO_STREAM_BEGIN`,e[e.AUDIO_STREAM_END=4194306]=`AUDIO_STREAM_END`,e[e.AUDIO_FRAME=4194307]=`AUDIO_FRAME`,e[e.AUDIO_FRAME_VOLUME=4194308]=`AUDIO_FRAME_VOLUME`,e[e.AUDIO_FRAME2=4194309]=`AUDIO_FRAME2`,e[e.AUDIO_SHAPE_FRAME=4194310]=`AUDIO_SHAPE_FRAME`,e[e.AUDIO_PLAYBACK_REPORT=4194311]=`AUDIO_PLAYBACK_REPORT`,e[e.GROUP_VIDEO=8388608]=`GROUP_VIDEO`,e[e.VIDEO_STREAM_BEGIN=8388609]=`VIDEO_STREAM_BEGIN`,e[e.VIDEO_STREAM_END=8388610]=`VIDEO_STREAM_END`,e[e.VIDEO_FRAME=8388611]=`VIDEO_FRAME`,e[e.VIDEO_REQUEST_IDR_FRAME=8388612]=`VIDEO_REQUEST_IDR_FRAME`,e[e.VIDEO_INVALIDATE_FRAME=8388613]=`VIDEO_INVALIDATE_FRAME`,e[e.GROUP_ALL=16711680]=`GROUP_ALL`,e[e.GROUP_APP_LOCAL=1073741824]=`GROUP_APP_LOCAL`,e[e.CONSTANT_GROUP_MASK=2147418112]=`CONSTANT_GROUP_MASK`,e}({});function T(e){let t={};return E(t),e&&Object.assign(t,e),t}function E(e){return e.Epoch=0,e.Sequence=0,e.FrameSizeInInterleavedSamples=0,e.TimeStampInInterleavedSamples=BigInt(0),e.ShapeSetValues=[],e}function D(e,t){return O(c.create(e),t)}function O(e,t){let n=t??T();return E(n),ie(e,n),n}function ie(e,t){let n;for(;(n=e.next())!==null;)switch(n.fieldId){case 717315017:if(n.isNull)throw Error();t.ShapeSetValues=k(n.asArray());break;case 2026534360:if(n.isNull)throw Error();t.TimeStampInInterleavedSamples=n.asUInt64();break;case 4007456593:if(n.isNull)throw Error();t.FrameSizeInInterleavedSamples=n.asUInt32();break;case 4065417427:if(n.isNull)throw Error();t.Sequence=n.asUInt32();break;case 4086360332:if(n.isNull)throw Error();t.Epoch=n.asUInt32()}}async function ae(e,t){return D(await i(e,4194310,1),t)}function k(e){let t=[],n;for(;(n=e.next())!==null;)t.push(M(n.asObject()));return t}function A(e){let t={};return j(t),e&&Object.assign(t,e),t}function j(e){return e.SetId=0,e.Values=[],e}function M(e,t){let n=t??A();return j(n),N(e,n),n}function N(e,t){let n;for(;(n=e.next())!==null;)switch(n.fieldId){case 1154362099:if(n.isNull)throw Error();t.SetId=n.asUInt32();break;case 3974819915:if(n.isNull)throw Error();t.Values=P(n.asArray())}}function P(e){let t=[],n;for(;(n=e.next())!==null;)t.push(n.asFloat32());return t}function F(e){let t={};return I(t),e&&Object.assign(t,e),t}function I(e){return e.StreamId=``,e.Description=``,e.SourceType=``,e.Codec=C.Unknown,e.CodecDetails=``,e.SampleRate=0,e.Channels=0,e.ShapeSets=void 0,e.CorrelationId=void 0,e}function L(e,t){return R(c.create(e),t)}function R(e,t){let n=t??F();return I(n),z(e,n),n}function z(e,t){let n;for(;(n=e.next())!==null;)switch(n.fieldId){case 161083277:if(n.isNull)throw Error();t.StreamId=n.asString();break;case 265814330:if(n.isNull){t.ShapeSets=void 0;break}t.ShapeSets=V(n.asArray());break;case 1368629611:if(n.isNull)throw Error();t.Description=n.asString();break;case 2431514951:if(n.isNull)throw Error();t.Channels=n.asInt32();break;case 2514959030:if(n.isNull){t.CorrelationId=void 0;break}t.CorrelationId=n.asString();break;case 2745379226:if(n.isNull)throw Error();t.CodecDetails=n.asString();break;case 3282782683:if(n.isNull)throw Error();t.SourceType=n.asString();break;case 3284746250:if(n.isNull)throw Error();t.Codec=n.asInt32();break;case 4101844078:if(n.isNull)throw Error();t.SampleRate=n.asInt32()}}async function B(e,t){return L(await i(e,4194305,6),t)}function V(e){let t=[],n;for(;(n=e.next())!==null;)t.push(W(n.asObject()));return t}function H(e){let t={};return U(t),e&&Object.assign(t,e),t}function U(e){return e.SetId=0,e.Name=``,e.ShapeNames=[],e}function W(e,t){let n=t??H();return U(n),G(e,n),n}function G(e,t){let n;for(;(n=e.next())!==null;)switch(n.fieldId){case 1107713536:if(n.isNull)throw Error();t.Name=n.asString();break;case 1154362099:if(n.isNull)throw Error();t.SetId=n.asUInt32();break;case 1185721362:if(n.isNull)throw Error();t.ShapeNames=K(n.asArray())}}function K(e){let t=[],n;for(;(n=e.next())!==null;)t.push(n.asString());return t}const q=96e3,J=new Map;let Y=null;const X=e=>{self.postMessage(e)};function Z(e){let t=r(e);return`${t.senderId}_${t.trackId}`}async function oe(e){Q(Z(e),await B(e))}function Q(e,t){J.set(e,{inputSampleRate:t.SampleRate,inputChannels:t.Channels}),X({type:`streamBegin`,streamId:e,shapeSets:t.ShapeSets??[]})}function se(e){let t=Z(e);J.delete(t),X({type:`streamEnd`,streamId:t})}async function ce(e){let t=Z(e),n=J.get(t);if(!n)return;let r=await ae(e),i=n.inputSampleRate*n.inputChannels;X({type:`shapeFrame`,streamId:t,epoch:r.Epoch,timestampInterleavedSamples:Math.round(Number(r.TimeStampInInterleavedSamples)*q/i),frameSizeInterleavedSamples:Math.round(r.FrameSizeInInterleavedSamples*q/i),shapeSetValues:r.ShapeSetValues})}function le(e){switch(n(t(e))){case w.AUDIO_STREAM_BEGIN:oe(e);return;case w.AUDIO_STREAM_END:se(e);return;case w.AUDIO_SHAPE_FRAME:ce(e);return;default:return}}function $(){if(Y){try{Y.close()}catch{}Y=null}}self.addEventListener(`message`,e=>{let t=e.data;if(t.type===`attachProtocolPort`){$(),Y=t.port,Y.addEventListener(`message`,e=>{let t=e.data;t?.type===`protocol`&&t.message instanceof ArrayBuffer&&le(new Uint8Array(t.message))}),Y.start?.();return}if(t.type===`syncStreams`){for(let e of t.streams){let t=`${e.senderId}_${e.trackId}`;J.has(t)||Q(t,e.info)}return}if(t.type===`dispose`){$(),J.clear();return}});
package/index.js CHANGED
@@ -858,8 +858,6 @@ function Oe(e, t) {
858
858
  case Ee:
859
859
  if (n.isNull) throw Error();
860
860
  t.SampleRate = n.asInt32();
861
- break;
862
- default: break;
863
861
  }
864
862
  }
865
863
  function ke(e) {
@@ -893,8 +891,6 @@ function Fe(e, t) {
893
891
  case Me:
894
892
  if (n.isNull) throw Error();
895
893
  t.ShapeNames = Ie(n.asArray());
896
- break;
897
- default: break;
898
894
  }
899
895
  }
900
896
  function Ie(e) {
@@ -1066,8 +1062,6 @@ function St(e, t) {
1066
1062
  case yt:
1067
1063
  if (n.isNull) throw Error();
1068
1064
  t.IsInternal = n.asBool();
1069
- break;
1070
- default: break;
1071
1065
  }
1072
1066
  }
1073
1067
  function Ct(e) {
@@ -1142,8 +1136,6 @@ function Rt(e, t) {
1142
1136
  case Ft:
1143
1137
  if (n.isNull) throw Error();
1144
1138
  t.LlmCallOnlyOnce = n.asBool();
1145
- break;
1146
- default: break;
1147
1139
  }
1148
1140
  }
1149
1141
  function zt(e) {
@@ -1206,8 +1198,6 @@ function $t(e, t) {
1206
1198
  case Yt:
1207
1199
  if (n.isNull) throw Error();
1208
1200
  t.ParameterIndex = n.asInt32();
1209
- break;
1210
- default: break;
1211
1201
  }
1212
1202
  }
1213
1203
  //#endregion
@@ -1234,8 +1224,6 @@ function on(e, t) {
1234
1224
  case tn:
1235
1225
  if (n.isNull) throw Error();
1236
1226
  t.MimeType = n.asString();
1237
- break;
1238
- default: break;
1239
1227
  }
1240
1228
  }
1241
1229
  var sn = 1048655, cn = 3469892363;
@@ -1267,8 +1255,6 @@ function gn(e, t) {
1267
1255
  case fn:
1268
1256
  if (n.isNull) throw Error();
1269
1257
  t.Category = n.asString();
1270
- break;
1271
- default: break;
1272
1258
  }
1273
1259
  }
1274
1260
  var _n = 2097188, vn = 979822885, yn = 2374537704;
@@ -1296,8 +1282,6 @@ function wn(e, t) {
1296
1282
  case yn:
1297
1283
  if (n.isNull) throw Error();
1298
1284
  t.Style = En(n.asDictionary());
1299
- break;
1300
- default: break;
1301
1285
  }
1302
1286
  }
1303
1287
  async function Tn(e, t) {
@@ -1332,8 +1316,6 @@ function Nn(e, t) {
1332
1316
  case On:
1333
1317
  if (n.isNull) throw Error();
1334
1318
  t.Styles = Fn(n.asArray());
1335
- break;
1336
- default: break;
1337
1319
  }
1338
1320
  }
1339
1321
  async function Pn(e, t) {
@@ -1366,8 +1348,6 @@ function Vn(e, t) {
1366
1348
  case Ln:
1367
1349
  if (n.isNull) throw Error();
1368
1350
  t.Style = Hn(n.asDictionary());
1369
- break;
1370
- default: break;
1371
1351
  }
1372
1352
  }
1373
1353
  function Hn(e) {
@@ -1399,8 +1379,6 @@ function Yn(e, t) {
1399
1379
  case Wn:
1400
1380
  if (n.isNull) throw Error();
1401
1381
  t.StyleIds = Zn(n.asArray());
1402
- break;
1403
- default: break;
1404
1382
  }
1405
1383
  }
1406
1384
  async function Xn(e, t) {
@@ -1436,8 +1414,6 @@ function ar(e, t) {
1436
1414
  case er:
1437
1415
  if (n.isNull) throw Error();
1438
1416
  t.Payloads = sr(n.asDictionary());
1439
- break;
1440
- default: break;
1441
1417
  }
1442
1418
  }
1443
1419
  async function or(e, t) {
@@ -1517,8 +1493,6 @@ function Tr(e, t) {
1517
1493
  case xr:
1518
1494
  if (n.isNull) throw Error();
1519
1495
  t.Width = n.asInt32();
1520
- break;
1521
- default: break;
1522
1496
  }
1523
1497
  }
1524
1498
  var Er = 65539, Dr = 620476198, Or = 693643444, kr = 1144553441, Ar = 1731742060, jr = 1931178803, Mr = 2191393509, Nr = 2563358196, Pr = 3042922213, Fr = 3064612128, Ir = 3219210453, Lr = 3504054055, Rr = 3678477544, zr = 3696445035, Br = 3707543140, Vr = 3712281496, Hr = 3895362455, Ur = 3897397815, Wr = 4225107827, Gr = 976837618, Kr = 2271236852, qr = 2277643855, Jr = 3914217035;
@@ -1626,8 +1600,6 @@ function $r(e, t) {
1626
1600
  case Jr:
1627
1601
  if (n.isNull) break;
1628
1602
  (t.retiredFields ??= {}).ServerSessionId = n.asString();
1629
- break;
1630
- default: break;
1631
1603
  }
1632
1604
  }
1633
1605
  async function ei(e, t) {
@@ -1708,8 +1680,6 @@ function mi(e, t) {
1708
1680
  case ui:
1709
1681
  if (n.isNull) throw Error();
1710
1682
  t.Info = hn(n.asObject());
1711
- break;
1712
- default: break;
1713
1683
  }
1714
1684
  }
1715
1685
  var hi = 161083277, gi = 325678206, _i = 3469892363, vi = 3645544153;
@@ -1742,8 +1712,6 @@ function Si(e, t) {
1742
1712
  case vi:
1743
1713
  if (n.isNull) throw Error();
1744
1714
  t.Info = De(n.asObject());
1745
- break;
1746
- default: break;
1747
1715
  }
1748
1716
  }
1749
1717
  var Ci = 161083277, wi = 325678206, Ti = 3469892363, Ei = 3645544153;
@@ -1776,8 +1744,6 @@ function Ai(e, t) {
1776
1744
  case Ei:
1777
1745
  if (n.isNull) throw Error();
1778
1746
  t.Info = wr(n.asObject());
1779
- break;
1780
- default: break;
1781
1747
  }
1782
1748
  }
1783
1749
  //#endregion
@@ -2116,7 +2082,7 @@ var Hi = class {
2116
2082
  return this.snapshot = e, n && this.notify(), n;
2117
2083
  }
2118
2084
  clear() {
2119
- (this.snapshot.rootViewId === void 0 || this.snapshot.rootViewId.length === 0) && this.snapshot.views.size === 0 && this.snapshot.payloads.size === 0 || (this.snapshotMode = !0, this.views.clear(), this.payloads.clear(), this.rootViewId = void 0, this.viewsDirty = !0, this.payloadsDirty = !0, this.snapshot = {
2085
+ (this.snapshot.rootViewId !== void 0 && this.snapshot.rootViewId.length !== 0 || this.snapshot.views.size !== 0 || this.snapshot.payloads.size !== 0) && (this.snapshotMode = !0, this.views.clear(), this.payloads.clear(), this.rootViewId = void 0, this.viewsDirty = !0, this.payloadsDirty = !0, this.snapshot = {
2120
2086
  views: /* @__PURE__ */ new Map(),
2121
2087
  payloads: /* @__PURE__ */ new Map(),
2122
2088
  version: -1
@@ -2208,7 +2174,7 @@ var Hi = class {
2208
2174
  let t = this.streams.get(e.streamId);
2209
2175
  return t ? (t.store.clear(), this.notify(e.streamId), !0) : !1;
2210
2176
  }
2211
- return e.type === "RemoveStream" ? this.streams.delete(e.streamId) ? (this.notify(e.streamId), !0) : !1 : e.type === "SetStreamCategory" ? (this.setCategory(e.streamId, e.category), !0) : !1;
2177
+ return e.type === "RemoveStream" ? this.streams.delete(e.streamId) ? (this.notify(e.streamId), !0) : !1 : e.type === "SetStreamCategory" && (this.setCategory(e.streamId, e.category), !0);
2212
2178
  }
2213
2179
  applyStoreOps(e) {
2214
2180
  for (let t of e) this.applyStoreOp(t);
@@ -2505,7 +2471,7 @@ function ia(e, t, n, r) {
2505
2471
  }
2506
2472
  //#endregion
2507
2473
  //#region src/live-snapshot.ts
2508
- var Y = e("LiveSnapshot"), aa = 3, X = "ikon-live-snapshot", oa = 300 * 1e3, sa = 5e6, ca = 1e3;
2474
+ var Y = e("LiveSnapshot"), aa = 3, X = "ikon-live-snapshot", oa = 3e5, sa = 5e6, ca = 1e3;
2509
2475
  function la() {
2510
2476
  return typeof location < "u" ? J(location.pathname) : "/";
2511
2477
  }
@@ -2684,7 +2650,7 @@ function pa(e) {
2684
2650
  //#endregion
2685
2651
  //#region src/ui-worker.ts?worker
2686
2652
  function ma(e) {
2687
- return new Worker("" + new URL("assets/ui-worker-Rn19H0bB.js", import.meta.url).href, {
2653
+ return new Worker("" + new URL("assets/ui-worker-CejqUEoP.js", import.meta.url).href, {
2688
2654
  type: "module",
2689
2655
  name: e?.name
2690
2656
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikonai/sdk-ui",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",