@ikonai/sdk 1.0.79 → 1.1.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.
Files changed (55) hide show
  1. package/app-messaging.d.ts +1 -1
  2. package/assets/audio-capture-worker-D-0X2Dy8.js +1 -0
  3. package/assets/audio-playback-worker-DivBZPfS.js +1 -0
  4. package/assets/libopus-CnBCihDi.js +1 -0
  5. package/assets/protocol-worker-BH93CVck.js +1 -0
  6. package/assets/src-BKYD07QQ.js +1 -0
  7. package/assets/src-DOUWsCWT.js +1 -0
  8. package/assets/video-capture-worker-BQGOFbZt.js +1 -0
  9. package/assets/video-playback-worker-tC5nUVnw.js +1 -0
  10. package/assets/viseme-worker-Cd-JqTVM.js +1 -0
  11. package/capabilities-BtJblfdG.js +108 -0
  12. package/channel/channel-manager.d.ts +1 -1
  13. package/channel/channel.d.ts +1 -1
  14. package/client/endpoint-selector.d.ts +1 -1
  15. package/client/ikon-client-config.d.ts +13 -11
  16. package/client/ikon-client.d.ts +98 -4
  17. package/connection/authenticator.d.ts +3 -3
  18. package/connection/urls.d.ts +7 -18
  19. package/errors/index.d.ts +22 -13
  20. package/functions/browser-functions.d.ts +1 -1
  21. package/functions/function-registry.d.ts +1 -1
  22. package/functions/types.d.ts +2 -2
  23. package/ikon-media-zqob_QeE.js +3160 -0
  24. package/index.d.ts +8 -8
  25. package/index.js +8119 -12502
  26. package/media/ikon-audio-capture.d.ts +15 -3
  27. package/media/ikon-audio-playback.d.ts +37 -0
  28. package/media/ikon-video-playback.d.ts +24 -0
  29. package/media/media-session-helper.d.ts +8 -0
  30. package/media/video-constants.d.ts +11 -1
  31. package/media/viseme-tracker.d.ts +10 -1
  32. package/package.json +1 -1
  33. package/storage.d.ts +13 -0
  34. package/transport/transport.d.ts +1 -1
  35. package/transport/web-socket-transport.d.ts +1 -1
  36. package/transport/web-transport-transport.d.ts +1 -1
  37. package/utils/inspect-mode.d.ts +4 -0
  38. package/utils/log-sender.d.ts +1 -1
  39. package/utils/platform.d.ts +4 -0
  40. package/utils/query-params.d.ts +8 -4
  41. package/vite.config.d.ts +2 -0
  42. package/webrtc/webrtc-signaling.d.ts +11 -2
  43. package/worker/audio-playback-worker.d.ts +14 -1
  44. package/worker/video-capture-worker.d.ts +2 -2
  45. package/worker/video-playback-worker.d.ts +14 -2
  46. package/worker/viseme-worker.d.ts +10 -2
  47. package/assets/audio-capture-worker-Brmt2Z7a.js +0 -1279
  48. package/assets/audio-playback-worker-DDtsnLoq.js +0 -1473
  49. package/assets/index-Ca9sTcGt.js +0 -119
  50. package/assets/index-D_vz6N3U.js +0 -267
  51. package/assets/libopus-ChbDZJKA.js +0 -139
  52. package/assets/protocol-worker-BoZcMF0x.js +0 -1674
  53. package/assets/video-capture-worker-DxgvFTcw.js +0 -1126
  54. package/assets/video-playback-worker-Ca4XVGqt.js +0 -1005
  55. package/assets/viseme-worker-DVWM4pRh.js +0 -831
@@ -0,0 +1 @@
1
+ function e(e){return e}function t(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 n(e){let t=g(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}}function r(t,n,r,i,a){let o=a?.trackId??0,s=a?.sequenceId??0,c=a?.flags??0,l=a?.targetIds??[],u=a?.payloadType??8,d=27+l.length*4,f=d+n.length,p=new Uint8Array(f),m=new DataView(p.buffer);m.setUint32(0,f,!0),m.setUint32(4,t>>>0,!0),m.setUint32(8,i>>>0,!0),m.setUint32(12,o>>>0,!0),m.setUint32(16,s>>>0,!0),m.setUint32(20,l.length>>>0,!0),m.setUint8(24,r&255),m.setUint8(25,u&255),m.setUint8(26,c&255);let h=27;for(let e=0;e<l.length;e++)m.setUint32(h,l[e]>>>0,!0),h+=4;return p.set(n,d),e(p)}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}({});const a=new TextEncoder;new TextDecoder(`utf-8`,{fatal:!0});var o=class e{buffer=new d;cached;constructor(e=1){this.buffer.writeByte(161),this.buffer.writeVarUInt(e>>>0)}writeInt32Field(e,t){this.writeFixedField(e,3,()=>this.buffer.writeInt32(t|0))}writeUInt32Field(e,t){this.writeFixedField(e,5,()=>this.buffer.writeUInt32(t>>>0))}writeInt64Field(e,t){this.writeFixedField(e,4,()=>this.buffer.writeBigInt64(t))}writeUInt64Field(e,t){this.writeFixedField(e,6,()=>this.buffer.writeBigUInt64(t))}writeFloat32Field(e,t){this.writeFixedField(e,7,()=>this.buffer.writeFloat32(t))}writeFloat64Field(e,t){this.writeFixedField(e,8,()=>this.buffer.writeFloat64(t))}writeBoolField(e,t){this.writeFixedField(e,2,()=>this.buffer.writeByte(+!!t))}writeGuidField(e,t){let n=t instanceof u?t.asBytes():t;if(n.length!==16)throw Error(`Guid payload must be 16 bytes`);this.writeFixedField(e,14,()=>this.buffer.writeBytes(n))}writeStringField(e,t){let n=a.encode(t??``);this.writeVariableField(e,12,n)}writeBinaryField(e,t){this.writeVariableField(e,13,t)}writeObjectField(t,n,r){let i=new e(n);r(i);let a=i.finish();this.writeVariableField(t,11,a)}writeArrayField(e,t,n){let r=new s(t);n(r);let i=r.finish();this.writeVariableField(e,9,i)}writeDictionaryField(e,t,n,r){let i=new c(t,n);r(i);let a=i.finish();this.writeVariableField(e,10,a)}finish(){return this.cached||=(this.buffer.writeByte(162),this.buffer.toUint8Array()),this.cached}writeFixedField(e,t,n){this.writeFieldHeader(e,t,0),n()}writeVariableField(e,t,n){this.writeFieldHeader(e,t,n.length),this.buffer.writeBytes(n)}writeFieldHeader(e,t,n){this.buffer.writeUInt32(e>>>0),this.buffer.writeByte(f(t)),p(t)&&this.buffer.writeVarUInt(n>>>0)}},s=class e{elementType;payload=new d;count=0;constructor(e){this.elementType=e}writeInt32(e){this.ensureElementType(3),this.count++,this.payload.writeInt32(e|0)}writeUInt32(e){this.ensureElementType(5),this.count++,this.payload.writeUInt32(e>>>0)}writeInt64(e){this.ensureElementType(4),this.count++,this.payload.writeBigInt64(e)}writeUInt64(e){this.ensureElementType(6),this.count++,this.payload.writeBigUInt64(e)}writeFloat32(e){this.ensureElementType(7),this.count++,this.payload.writeFloat32(e)}writeFloat64(e){this.ensureElementType(8),this.count++,this.payload.writeFloat64(e)}writeBool(e){this.ensureElementType(2),this.count++,this.payload.writeByte(+!!e)}writeGuid(e){this.ensureElementType(14),this.count++;let t=e instanceof u?e.asBytes():e;if(t.length!==16)throw Error(`Guid payload must be 16 bytes`);this.payload.writeBytes(t)}writeString(e){this.ensureElementType(12),this.count++;let t=a.encode(e??``);this.payload.writeVarUInt(t.length),this.payload.writeBytes(t)}writeBinary(e){this.ensureElementType(13),this.count++,this.payload.writeVarUInt(e.length),this.payload.writeBytes(e)}writeObject(e,t){this.ensureElementType(11),this.count++;let n=new o(e);t(n);let r=n.finish();this.payload.writeVarUInt(r.length),this.payload.writeBytes(r)}writeArray(t,n){this.ensureElementType(9),this.count++;let r=new e(t);n(r);let i=r.finish();this.payload.writeBytes(i)}writeDictionary(e,t,n){this.ensureElementType(10),this.count++;let r=new c(e,t);n(r);let i=r.finish();this.payload.writeBytes(i)}finish(){let e=new d;return e.writeByte(f(this.elementType)),e.writeVarUInt(this.count),e.writeBytes(this.payload.toUint8Array()),e.toUint8Array()}ensureElementType(e){if(this.elementType!==e)throw Error(`Array element type is ${i[this.elementType]}, expected ${i[e]}`)}},c=class{keyType;valueType;payload=new d;count=0;entryOpen=!1;constructor(e,t){this.keyType=e,this.valueType=t,m(e)}beginEntry(){if(this.entryOpen)throw Error(`Previous dictionary entry not completed`);return this.count++,this.entryOpen=!0,new l(this.keyType,this.valueType,this.payload,()=>{this.entryOpen=!1})}finish(){if(this.entryOpen)throw Error(`Dictionary entry not completed`);let e=new d;return e.writeByte(f(this.keyType)),e.writeByte(f(this.valueType)),e.writeVarUInt(this.count),e.writeBytes(this.payload.toUint8Array()),e.toUint8Array()}},l=class{keyType;valueType;payload;onComplete;keyWritten=!1;valueWritten=!1;completed=!1;constructor(e,t,n,r){this.keyType=e,this.valueType=t,this.payload=n,this.onComplete=r}writeKeyInt32(e){this.ensureKeyType(3),this.payload.writeInt32(e|0),this.keyWritten=!0}writeKeyUInt32(e){this.ensureKeyType(5),this.payload.writeUInt32(e>>>0),this.keyWritten=!0}writeKeyInt64(e){this.ensureKeyType(4),this.payload.writeBigInt64(e),this.keyWritten=!0}writeKeyUInt64(e){this.ensureKeyType(6),this.payload.writeBigUInt64(e),this.keyWritten=!0}writeKeyFloat32(e){this.ensureKeyType(7),this.payload.writeFloat32(e),this.keyWritten=!0}writeKeyFloat64(e){this.ensureKeyType(8),this.payload.writeFloat64(e),this.keyWritten=!0}writeKeyBool(e){this.ensureKeyType(2),this.payload.writeByte(+!!e),this.keyWritten=!0}writeKeyGuid(e){this.ensureKeyType(14);let t=e instanceof u?e.asBytes():e;if(t.length!==16)throw Error(`Guid payload must be 16 bytes`);this.payload.writeBytes(t),this.keyWritten=!0}writeKeyString(e){this.ensureKeyType(12);let t=a.encode(e??``);this.payload.writeVarUInt(t.length),this.payload.writeBytes(t),this.keyWritten=!0}writeKeyBinary(e){this.ensureKeyType(13),this.payload.writeVarUInt(e.length),this.payload.writeBytes(e),this.keyWritten=!0}writeValueInt32(e){this.ensureValueType(3),this.payload.writeInt32(e|0),this.valueWritten=!0}writeValueUInt32(e){this.ensureValueType(5),this.payload.writeUInt32(e>>>0),this.valueWritten=!0}writeValueInt64(e){this.ensureValueType(4),this.payload.writeBigInt64(e),this.valueWritten=!0}writeValueUInt64(e){this.ensureValueType(6),this.payload.writeBigUInt64(e),this.valueWritten=!0}writeValueFloat32(e){this.ensureValueType(7),this.payload.writeFloat32(e),this.valueWritten=!0}writeValueFloat64(e){this.ensureValueType(8),this.payload.writeFloat64(e),this.valueWritten=!0}writeValueBool(e){this.ensureValueType(2),this.payload.writeByte(+!!e),this.valueWritten=!0}writeValueGuid(e){this.ensureValueType(14);let t=e instanceof u?e.asBytes():e;if(t.length!==16)throw Error(`Guid payload must be 16 bytes`);this.payload.writeBytes(t),this.valueWritten=!0}writeNullValue(){this.ensureValueType(1),this.valueWritten=!0}writeValueBinary(e){this.ensureValueType(13),this.payload.writeVarUInt(e.length),this.payload.writeBytes(e),this.valueWritten=!0}writeValueString(e){this.ensureValueType(12);let t=a.encode(e??``);this.payload.writeVarUInt(t.length),this.payload.writeBytes(t),this.valueWritten=!0}writeValueObject(e,t){this.ensureValueType(11);let n=new o(e);t(n);let r=n.finish();this.payload.writeVarUInt(r.length),this.payload.writeBytes(r),this.valueWritten=!0}writeValueArray(e,t){this.ensureValueType(9);let n=new s(e);t(n);let r=n.finish();this.payload.writeBytes(r),this.valueWritten=!0}writeValueDictionary(e,t,n){this.ensureValueType(10);let r=new c(e,t);n(r);let i=r.finish();this.payload.writeBytes(i),this.valueWritten=!0}complete(){if(!this.completed){if(!this.keyWritten||!this.valueWritten)throw Error(`Dictionary entry must write both key and value`);this.completed=!0,this.onComplete()}}ensureKeyType(e){if(this.keyType!==e)throw Error(`Dictionary key type is ${i[this.keyType]}, expected ${i[e]}`)}ensureValueType(e){if(this.valueType!==e)throw Error(`Dictionary value type is ${i[this.valueType]}, expected ${i[e]}`)}},u=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),h(t.subarray(8,10)),h(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`)}},d=class e{static INITIAL_CAPACITY=256;buffer;dataView;length=0;constructor(){this.buffer=new Uint8Array(e.INITIAL_CAPACITY),this.dataView=new DataView(this.buffer.buffer)}ensureCapacity(e){let t=this.length+e;if(t<=this.buffer.length)return;let n=this.buffer.length;for(;n<t;)n*=2;let r=new Uint8Array(n);r.set(this.buffer.subarray(0,this.length)),this.buffer=r,this.dataView=new DataView(this.buffer.buffer)}writeByte(e){this.ensureCapacity(1),this.buffer[this.length++]=e&255}writeBytes(e){this.ensureCapacity(e.length),this.buffer.set(e,this.length),this.length+=e.length}writeUInt32(e){this.ensureCapacity(4),this.dataView.setUint32(this.length,e>>>0,!0),this.length+=4}writeInt32(e){this.ensureCapacity(4),this.dataView.setInt32(this.length,e|0,!0),this.length+=4}writeFloat32(e){this.ensureCapacity(4),this.dataView.setFloat32(this.length,e,!0),this.length+=4}writeFloat64(e){this.ensureCapacity(8),this.dataView.setFloat64(this.length,e,!0),this.length+=8}writeBigInt64(e){this.ensureCapacity(8),this.dataView.setBigInt64(this.length,e,!0),this.length+=8}writeBigUInt64(e){this.ensureCapacity(8),this.dataView.setBigUint64(this.length,e,!0),this.length+=8}writeVarUInt(e){let t=e>>>0;for(;t>=128;)this.ensureCapacity(1),this.buffer[this.length++]=t&127|128,t>>>=7;this.ensureCapacity(1),this.buffer[this.length++]=t&127}toUint8Array(){return this.buffer.slice(0,this.length)}};function f(e,t=0){if(t&240)throw Error(`Teleport flags must fit into 4 bits`);return(e&15)<<4|t&15}function p(e){return e===12||e===13||e===9||e===11||e===10}function m(e){if(e===9||e===11||e===10||e===1)throw Error(`Dictionary keys must be primitive Teleport types`)}function h(e){return Array.from(e).map(e=>e.toString(16).padStart(2,`0`)).join(``)}function g(e){return e instanceof Uint8Array?e:new Uint8Array(e)}let _=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}({}),v=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 y(e){let t={};return ee(t),e&&Object.assign(t,e),t}function ee(e){return e.Data=new Uint8Array,e.FrameNumber=0,e.IsKey=!1,e.TimestampInUs=BigInt(0),e.DurationInUs=0,e}function b(e){let t=new o(1);return x(e,t),t.finish()}function x(e,t){t.writeUInt64Field(271275304,e.TimestampInUs),t.writeUInt32Field(2541432218,e.DurationInUs>>>0),t.writeBinaryField(2986785889,e.Data),t.writeBoolField(3105403172,e.IsKey),t.writeInt32Field(3456383222,e.FrameNumber|0)}function S(e,t,n){return r(8388611,b(e),1,t,n)}function C(e){let t={};return te(t),e&&Object.assign(t,e),t}function te(e){return e.StreamId=``,e.Description=``,e.SourceType=``,e.Codec=_.H264,e.CodecDetails=``,e.Width=0,e.Height=0,e.Framerate=30,e.CorrelationId=void 0,e}function w(e){let t=new o(6);return T(e,t),t.finish()}function T(e,t){t.writeStringField(161083277,e.StreamId),t.writeFloat64Field(164808083,e.Framerate),t.writeStringField(1368629611,e.Description);let n=e.CorrelationId;n!=null&&t.writeStringField(2514959030,n),t.writeStringField(2745379226,e.CodecDetails),t.writeInt32Field(2950031986,e.Height|0),t.writeStringField(3282782683,e.SourceType),t.writeInt32Field(3284746250,e.Codec),t.writeInt32Field(4065070594,e.Width|0)}function E(e,t,n){return r(8388609,w(e),6,t,n)}function D(e){let t={};return e&&Object.assign(t,e),t}function O(e){return new o(1).finish()}function k(e,t,n){return r(8388610,O(e),1,t,n)}const A=[`avc1.42001f`,`avc1.4d001f`,`avc1.42001e`,`avc1.4d001e`,`avc1.640028`,`avc1.4d0028`];A[0];const j=[`vp09.00.10.08`,`vp09.00.20.08`,`vp09.00.30.08`,`vp09.00.40.08`];j[0];const M=[`av01.0.04M.08`,`av01.0.05M.08`,`av01.0.08M.08`,`av01.0.01M.08`];M[0];const N=[`h264`,`vp8`,`vp9`,`av1`];function P(e){let t=N.slice();if(!Array.isArray(e)||e.length===0)return t;let n=[];for(let t of e)N.includes(t)&&!n.includes(t)&&n.push(t);if(n.length===0)return t;for(let e of t)n.includes(e)||n.push(e);return n}const F=[{width:1920,height:1080},{width:1280,height:720},{width:960,height:540},{width:640,height:480},{width:640,height:360}],I=e=>self.postMessage(e);let L=null,R=null;function z(e,t){let n=e instanceof Error?e:Error(String(e));I({type:`error`,captureId:t,error:{name:n.name,message:n.message,stack:n.stack}})}function ne(e){return e===`h264`?_.H264:e===`vp8`?_.Vp8:e===`vp9`?_.Vp9:e===`av1`?_.Av1:_.Unknown}const B={[_.Unknown]:[],[_.H264]:A,[_.Vp8]:[`vp8`],[_.Vp9]:j,[_.Av1]:M};function V(e,t,n,r){let i=e*t,a=n/30*.1,o=Math.floor(i*a);return Math.max(5e4,Math.floor(r??Math.max(5e5,Math.min(o,8e6))))}function H(e,t){let n=[{width:e,height:t}];for(let r of F)(r.width<e||r.height<t)&&(n.some(e=>e.width===r.width&&e.height===r.height)||n.push(r));return n}async function U(e,t,n,r,i,a,o){let s={codec:t,width:n,height:r,bitrate:i,framerate:a,latencyMode:`realtime`,...e===_.H264?{avc:{format:`annexb`}}:{}};if(typeof VideoEncoder?.isConfigSupported!=`function`)return null;if(o){let e={...s,hardwareAcceleration:o};try{let t=await VideoEncoder.isConfigSupported(e);if(t.supported){let n=t.config??e;return{config:n,isHardwareAccelerated:n.hardwareAcceleration===`prefer-hardware`}}}catch{}}try{let e=await VideoEncoder.isConfigSupported(s);if(e.supported)return{config:e.config??s,isHardwareAccelerated:!1}}catch{}return null}async function W(e,t,n,r){let i=Math.max(1,Math.floor(n?.framerate??30)),a=P(n?.preferredCodecs),o=n?.hardwareAcceleration===`preferSoftware`?[`prefer-software`,`prefer-hardware`,void 0]:[`prefer-hardware`,`prefer-software`,void 0],s=H(e,t),c=a;if(r){let e={[_.H264]:`h264`,[_.Vp8]:`vp8`,[_.Vp9]:`vp9`,[_.Av1]:`av1`}[r];e&&!a.includes(e)?c=[e,...a]:e&&(c=[e,...a.filter(t=>t!==e)])}for(let e of s){let t=V(e.width,e.height,i,n?.bitrate);for(let n of o)for(let r of c){let a=ne(r),o=B[a]??[];for(let r of o){let o=await U(a,r,e.width,e.height,t,i,n);if(o)return{codec:a,config:o.config,isHardwareAccelerated:o.isHardwareAccelerated}}}}throw Error(`No supported video encoder configuration`)}function G(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:e.slice().buffer}function K(e){if(!L)return;let t=G(e);L.postMessage({type:`send`,message:t},[t])}const q=new Map,J=new Map,Y=[];function X(e){for(let t=0;t<Y.length;t++)if(Y[t].length>=e){let n=Y[t];return Y.splice(t,1),n.length===e?n:new Uint8Array(n.buffer,0,e)}return new Uint8Array(e)}function Z(e){Y.length<8&&e.buffer.byteLength>0&&Y.push(new Uint8Array(e.buffer))}function Q(e){try{e.encoder.close()}catch{}}function re(e,t){try{if(e.stopped||e.isReconfiguring)return;if(e.kind===`screen`&&e.minFrameIntervalUs>0){let n=t.timestamp??0,r=n-e.lastEncodedTimestamp;if(e.lastEncodedTimestamp>0&&r<e.minFrameIntervalUs)return;e.lastEncodedTimestamp=n}if(e.encoder.encodeQueueSize>3)return;e.frameCounter+=1;let n=e.forceKeyframe||e.frameCounter>0&&e.frameCounter%e.keyFrameIntervalFrames===0;e.forceKeyframe=!1,e.encoder.encode(t,{keyFrame:n})}catch(t){z(t,e.captureId),e.forceKeyframe=!0}finally{try{t.close()}catch{}}}async function ie(e){try{for(;!e.stopped;){let t=await e.reader.read();if(t.done)break;let n=t.value;n&&re(e,n)}}catch(t){e.stopped||z(t,e.captureId)}}async function ae(e){if(!L)throw Error(`Video capture worker missing send port`);if(q.has(e.captureId))return;let t=Math.max(1,Math.floor(e.width)),n=Math.max(1,Math.floor(e.height)),r=await W(t,n,e.options),i=Math.max(1,Math.floor(e.options?.keyFrameIntervalFrames??90)),a=r.config.width??t,o=r.config.height??n,s=r.config.framerate??30,c=r.config.bitrate??0,l=e.trackSettings?.frameRate,u=l??s,d=e.options?.framerate??30,f=e.kind===`screen`?Math.floor(1e6/d):0,p=new VideoEncoder({output:t=>{let n=q.get(e.captureId);if(!n||n.stopped)return;let r=X(t.byteLength);t.copyTo(r);let i=S(y({Data:r,FrameNumber:n.frameCounter,IsKey:t.type===`key`,TimestampInUs:BigInt(Math.max(0,Math.round(t.timestamp??0))),DurationInUs:Math.max(0,Math.round(t.duration??0))}),n.senderId,{trackId:n.trackId});Z(r),K(i)},error:t=>{z(t,e.captureId)}});p.configure(r.config);let m=r.isHardwareAccelerated?`hardware`:`software`,h=e.kind===`screen`?`${Math.round(d)}fps (throttled from ${l===void 0?`?`:Math.round(l)}fps)`:l===void 0?`${Math.round(s)}fps (configured)`:`${Math.round(u)}fps (track)`;I({type:`debug`,message:`Encoder configured: codec=${r.config.codec}, ${a}x${o}@${h}, bitrate=${c}bps, hw=${m}`});let g=e.readable.getReader(),_={captureId:e.captureId,streamId:e.streamId,sourceType:e.sourceType,kind:e.kind,senderId:e.senderId,trackId:e.trackId,width:a,height:o,framerate:u,codec:r.codec,encoder:p,encoderConfig:r.config,options:e.options,correlationId:e.correlationId,reader:g,frameCounter:0,keyFrameIntervalFrames:i,forceKeyframe:!0,stopped:!1,isReconfiguring:!1,isHardwareAccelerated:r.isHardwareAccelerated,targetFramerate:d,lastEncodedTimestamp:0,minFrameIntervalUs:f};q.set(e.captureId,_),J.set(e.trackId,e.captureId);let v=e.kind===`screen`?d:u;K(E(C({StreamId:e.streamId,Description:`${e.kind}:${e.streamId}`,SourceType:e.sourceType,Codec:_.codec,CodecDetails:r.config.codec,Width:a,Height:o,Framerate:v,CorrelationId:e.correlationId}),e.senderId,{trackId:e.trackId})),I({type:`started`,captureId:e.captureId,codec:_.codec,width:a,height:o}),ie(_)}async function $(e){let t=q.get(e);if(t){t.stopped=!0,q.delete(e),J.delete(t.trackId);try{await t.reader.cancel()}catch{}try{await t.encoder.flush()}catch{}Q(t),K(k(D({}),t.senderId,{trackId:t.trackId})),I({type:`stopped`,captureId:t.captureId})}}async function oe(e,t,n){let r=q.get(e);if(!r||r.stopped||r.width===t&&r.height===n)return;r.isReconfiguring=!0,I({type:`debug`,message:`Window resize detected: ${r.width}x${r.height} -> ${t}x${n}`});try{await r.encoder.flush()}catch{}r.width=t,r.height=n;let i=await W(t,n,r.options,r.codec);Q(r),r.codec=i.codec,r.encoderConfig=i.config,r.isHardwareAccelerated=i.isHardwareAccelerated,r.encoder=new VideoEncoder({output:t=>{let n=q.get(e);if(!n||n.stopped)return;let r=X(t.byteLength);t.copyTo(r);let i=S(y({Data:r,FrameNumber:n.frameCounter,IsKey:t.type===`key`,TimestampInUs:BigInt(Math.max(0,Math.round(t.timestamp??0))),DurationInUs:Math.max(0,Math.round(t.duration??0))}),n.senderId,{trackId:n.trackId});Z(r),K(i)},error:t=>{z(t,e)}}),r.encoder.configure(i.config),r.forceKeyframe=!0;let a=i.config.width??t,o=i.config.height??n,s=r.kind===`screen`?r.targetFramerate:r.framerate;K(E(C({StreamId:r.streamId,Description:`${r.kind}:${r.streamId}`,SourceType:r.sourceType,Codec:r.codec,CodecDetails:i.config.codec,Width:a,Height:o,Framerate:s,CorrelationId:r.correlationId}),r.senderId,{trackId:r.trackId})),r.isReconfiguring=!1;let c=i.isHardwareAccelerated?`hardware`:`software`,l=r.kind===`screen`?`${Math.round(r.targetFramerate)}fps (throttled)`:`${Math.round(r.framerate)}fps`;I({type:`debug`,message:`Encoder reconfigured: codec=${i.config.codec}, ${a}x${o}@${l}, bitrate=${i.config.bitrate??0}bps, hw=${c}`})}async function se(e,t){let n=q.get(e);if(!n||n.stopped)return;let r=P(n.options?.preferredCodecs),i=P(t.preferredCodecs),a=JSON.stringify(r)!==JSON.stringify(i),o=n.options?.bitrate!==t.bitrate,s=n.options?.framerate!==t.framerate,c=t.width!==void 0&&n.options?.width!==t.width,l=t.height!==void 0&&n.options?.height!==t.height;if(!a&&!o&&!s&&!c&&!l)return;n.isReconfiguring=!0,I({type:`debug`,message:`Options update: codec=${a}, bitrate=${o}, framerate=${s}, width=${c}, height=${l}`}),n.options=t,n.kind===`camera`&&(c&&t.width!==void 0&&(n.width=t.width),l&&t.height!==void 0&&(n.height=t.height));try{await n.encoder.flush()}catch{}let u=await W(n.width,n.height,t);Q(n),n.codec=u.codec,n.encoderConfig=u.config,n.isHardwareAccelerated=u.isHardwareAccelerated,n.framerate=u.config.framerate??n.framerate,n.encoder=new VideoEncoder({output:t=>{let n=q.get(e);if(!n||n.stopped)return;let r=X(t.byteLength);t.copyTo(r);let i=S(y({Data:r,FrameNumber:n.frameCounter,IsKey:t.type===`key`,TimestampInUs:BigInt(Math.max(0,Math.round(t.timestamp??0))),DurationInUs:Math.max(0,Math.round(t.duration??0))}),n.senderId,{trackId:n.trackId});Z(r),K(i)},error:t=>{z(t,e)}}),n.encoder.configure(u.config),n.forceKeyframe=!0,n.kind===`screen`&&s&&t.framerate!==void 0&&(n.targetFramerate=t.framerate,n.minFrameIntervalUs=Math.floor(1e6/t.framerate),n.lastEncodedTimestamp=0);let d=u.config.width??n.width,f=u.config.height??n.height;K(E(C({StreamId:n.streamId,Description:`${n.kind}:${n.streamId}`,SourceType:n.sourceType,Codec:n.codec,CodecDetails:u.config.codec,Width:d,Height:f,Framerate:n.kind===`screen`?n.targetFramerate:n.framerate,CorrelationId:n.correlationId}),n.senderId,{trackId:n.trackId})),n.isReconfiguring=!1;let p=u.isHardwareAccelerated?`hardware`:`software`,m=n.kind===`screen`?`${Math.round(n.targetFramerate)}fps (throttled)`:`${Math.round(n.framerate)}fps`;I({type:`debug`,message:`Encoder reconfigured (options): codec=${u.config.codec}, ${d}x${f}@${m}, bitrate=${u.config.bitrate??0}bps, hw=${p}`})}function ce(r){let i=e(new Uint8Array(r));if(t(i)!==v.VIDEO_REQUEST_IDR_FRAME)return;let a=n(i),o=J.get(a.trackId);if(!o)return;let s=q.get(o);s&&(s.forceKeyframe=!0)}async function le(){let e=Array.from(q.keys()).map(e=>$(e).catch(()=>{}));if(await Promise.all(e),R){try{R.close()}catch{}R=null}if(L){try{L.close()}catch{}L=null}}self.addEventListener(`message`,e=>{let t=e.data;if(t.type===`attachSendPort`){if(L)try{L.close()}catch{}L=t.port;try{L.start?.()}catch{}return}if(t.type===`attachProtocolPort`){if(R)try{R.close()}catch{}R=t.port,R.addEventListener(`message`,e=>{let t=e.data;t?.type===`protocol`&&t.message instanceof ArrayBuffer&&ce(t.message)});try{R.start?.()}catch{}return}if(t.type===`start`){ae(t).catch(e=>z(e,t.captureId));return}if(t.type===`stop`){$(t.captureId).catch(e=>z(e,t.captureId));return}if(t.type===`updateDimensions`){oe(t.captureId,t.width,t.height).catch(e=>z(e,t.captureId));return}if(t.type===`updateOptions`){se(t.captureId,t.options).catch(e=>z(e,t.captureId));return}t.type===`dispose`&&le().catch(()=>{})});
@@ -0,0 +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()});
@@ -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=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}});
@@ -0,0 +1,108 @@
1
+ //#region ../../shared/protocol/src/enums/opcode.ts
2
+ var e = /* @__PURE__ */ function(e) {
3
+ 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;
4
+ }({}), t = /* @__PURE__ */ function(e) {
5
+ return e[e.DEBUG = 0] = "DEBUG", e[e.INFO = 1] = "INFO", e[e.WARN = 2] = "WARN", e[e.ERROR = 3] = "ERROR", e[e.NONE = 4] = "NONE", e;
6
+ }({}), n = 1, r = null, i = /* @__PURE__ */ new Map();
7
+ function a(e) {
8
+ n = e;
9
+ }
10
+ function o() {
11
+ return n;
12
+ }
13
+ function s(e) {
14
+ r = e;
15
+ }
16
+ function c() {
17
+ return r;
18
+ }
19
+ function l(e, t) {
20
+ return i.set(e, t ?? { minLevel: 2 }), () => {
21
+ i.delete(e);
22
+ };
23
+ }
24
+ var u = {
25
+ 0: "DEBUG",
26
+ 1: "INFO",
27
+ 2: "WARN",
28
+ 3: "ERROR",
29
+ 4: "NONE"
30
+ };
31
+ function d(e, t) {
32
+ return `[${e}] ${t}`;
33
+ }
34
+ function f(e, t, a, o) {
35
+ let s = {
36
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
37
+ level: e,
38
+ levelName: u[e],
39
+ component: t,
40
+ message: a,
41
+ args: o
42
+ };
43
+ r && r(s);
44
+ for (let [t, n] of i) if (e >= (n?.minLevel ?? 2)) try {
45
+ t(s);
46
+ } catch {}
47
+ if (n <= e) {
48
+ let n = d(t, a);
49
+ switch (e) {
50
+ case 0:
51
+ console.debug(n, ...o);
52
+ break;
53
+ case 1:
54
+ console.info(n, ...o);
55
+ break;
56
+ case 2:
57
+ console.warn(n, ...o);
58
+ break;
59
+ case 3:
60
+ console.error(n, ...o);
61
+ break;
62
+ case 4: break;
63
+ }
64
+ }
65
+ }
66
+ function p(e) {
67
+ return {
68
+ debug(t, ...n) {
69
+ f(0, e, t, n);
70
+ },
71
+ info(t, ...n) {
72
+ f(1, e, t, n);
73
+ },
74
+ warn(t, ...n) {
75
+ f(2, e, t, n);
76
+ },
77
+ error(t, ...n) {
78
+ f(3, e, t, n);
79
+ }
80
+ };
81
+ }
82
+ //#endregion
83
+ //#region src/utils/platform.ts
84
+ var m = () => {
85
+ if (typeof navigator > "u") return !1;
86
+ let e = navigator.userAgent, t = /iPad|iPhone|iPod/.test(e), n = e.includes("Macintosh") && typeof navigator.maxTouchPoints == "number" && navigator.maxTouchPoints > 1;
87
+ return t || n;
88
+ }, h = () => {
89
+ if (typeof navigator > "u" || typeof window > "u") return !1;
90
+ let e = navigator.userAgent;
91
+ return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(e) || m();
92
+ }, g = 48e3, _ = 1500, v = "playback", y = 8e3, b = 1500, x = -100, S = p("Capabilities"), C = globalThis;
93
+ function w() {
94
+ if (typeof SharedArrayBuffer > "u") return S.debug("SharedArrayBuffer not supported: SharedArrayBuffer is undefined"), !1;
95
+ if (typeof Atomics > "u") return S.debug("SharedArrayBuffer not supported: Atomics is undefined"), !1;
96
+ if (C.crossOriginIsolated === !1) return S.debug("SharedArrayBuffer not supported: crossOriginIsolated is false (missing COOP/COEP headers)"), !1;
97
+ try {
98
+ new SharedArrayBuffer(1);
99
+ } catch (e) {
100
+ return S.debug(`SharedArrayBuffer not supported: construction failed - ${e instanceof Error ? e.message : String(e)}`), !1;
101
+ }
102
+ return !0;
103
+ }
104
+ function T(e) {
105
+ return typeof AudioWorkletNode == "function" && typeof e.audioWorklet?.addModule == "function";
106
+ }
107
+ //#endregion
108
+ export { l as _, g as a, b as c, t as d, p as f, s as g, a as h, v as i, m as l, c as m, w as n, y as o, o as p, _ as r, x as s, T as t, h as u, e as v };
@@ -1,5 +1,5 @@
1
1
  import { EndpointSelector } from '../client/endpoint-selector';
2
- import { Entrypoint, EntrypointType, ProtocolMessage } from '../../../../shared/protocol/src/index.ts';
2
+ import { Entrypoint, EntrypointType, ProtocolMessage } from '../../shared/protocol/src/index.ts';
3
3
  /**
4
4
  * ChannelManager state.
5
5
  */
@@ -1,4 +1,4 @@
1
- import { Entrypoint, EntrypointType, ProtocolMessage } from '../../../../shared/protocol/src/index.ts';
1
+ import { Entrypoint, EntrypointType, ProtocolMessage } from '../../shared/protocol/src/index.ts';
2
2
  /**
3
3
  * Channel state.
4
4
  */
@@ -1,4 +1,4 @@
1
- import { Entrypoint, EntrypointType } from '../../../../shared/protocol/src/index.ts';
1
+ import { Entrypoint, EntrypointType } from '../../shared/protocol/src/index.ts';
2
2
  import { LocalConfig } from './ikon-client-config';
3
3
  /**
4
4
  * Proxy connection mode.
@@ -1,4 +1,4 @@
1
- import { ProtocolMessage } from '../../../../shared/protocol/src/index.ts';
1
+ import { ProtocolMessage } from '../../shared/protocol/src/index.ts';
2
2
  import { BackendType } from '../connection/urls';
3
3
  import { ConnectionState } from './connection-state';
4
4
  import { IkonAudioPlaybackConfig } from '../media/ikon-audio-playback';
@@ -80,6 +80,13 @@ export interface LocalConfig extends CommonConnectionConfig {
80
80
  * get-or-create the user's profile before connecting.
81
81
  */
82
82
  token?: string;
83
+ /**
84
+ * Identity-only backend JWT (e.g. an anonymous-auth token) whose claims
85
+ * (`authSession`, `role`) fill the connect token's AuthSessionId and IsAnonymous
86
+ * when no {@link token} is provided. Unlike {@link token} it does not mark the
87
+ * connection as authenticated.
88
+ */
89
+ identityToken?: string;
83
90
  /**
84
91
  * Backend API URL for profile operations. If not provided, derived from environment.
85
92
  */
@@ -94,15 +101,10 @@ export interface LocalConfig extends CommonConnectionConfig {
94
101
  */
95
102
  export interface CloudConnectionConfig extends CommonConnectionConfig {
96
103
  /**
97
- * Optional channel key (slug) for spaces with multiple channels.
98
- * If not provided, connects to the first available channel.
99
- * Example: 'lobby' or 'main'
100
- */
101
- channelKey?: string;
102
- /**
103
- * Optional session ID for targeting precomputed sessions.
104
+ * Join the live app session that owns this sessionIdentityHash, bypassing identity resolution.
105
+ * The connect fails when no live session has it — a hash never starts a fresh instance.
104
106
  */
105
- sessionId?: string;
107
+ sessionIdentityHash?: string;
106
108
  /**
107
109
  * Timeout for provisioning in milliseconds.
108
110
  * Default: 60000 (60 seconds)
@@ -111,7 +113,7 @@ export interface CloudConnectionConfig extends CommonConnectionConfig {
111
113
  }
112
114
  /**
113
115
  * Configuration for API key authentication mode.
114
- * Use this for programmatic/library access to cloud channels.
116
+ * Use this for programmatic/library access to cloud apps.
115
117
  */
116
118
  export interface ApiKeyConfig extends CloudConnectionConfig {
117
119
  /**
@@ -274,7 +276,7 @@ export interface IkonClientConfig {
274
276
  local?: LocalConfig;
275
277
  /**
276
278
  * API key authentication for programmatic access.
277
- * Use this for libraries, scripts, plugins that need to connect to cloud channels.
279
+ * Use this for libraries, scripts, plugins that need to connect to cloud apps.
278
280
  */
279
281
  apiKey?: ApiKeyConfig;
280
282
  /**
@@ -1,4 +1,4 @@
1
- import { GlobalState, ProtocolMessage } from '../../../../shared/protocol/src/index.ts';
1
+ import { GlobalState, ProtocolMessage } from '../../shared/protocol/src/index.ts';
2
2
  import { WebRTCSignaling } from '../webrtc';
3
3
  import { FunctionRegistry } from '../functions/function-registry';
4
4
  import { ReactiveRegistry } from '../reactive/reactive-registry';
@@ -62,6 +62,11 @@ export interface ProtocolMessageSubscriptionOptions {
62
62
  * State handler callback type for state subscribers.
63
63
  */
64
64
  export type StateHandler = (state: ConnectionState) => void;
65
+ /** The server-side outcome of a dispatched UI action (see {@link IkonClient.sendActionCallWithResult}). */
66
+ export interface ActionOutcome {
67
+ success: boolean;
68
+ errorMessage: string;
69
+ }
65
70
  /**
66
71
  * IkonClient is the main entry point for connecting to an Ikon server.
67
72
  *
@@ -119,6 +124,7 @@ export declare class IkonClient {
119
124
  private readonly actionAckTimeoutMs;
120
125
  private readonly _pendingActionAcks;
121
126
  private readonly _actionIdByCallId;
127
+ private readonly _pendingActionResults;
122
128
  private readonly endpointSelector;
123
129
  private _isUnloading;
124
130
  private boundBeforeUnload;
@@ -153,6 +159,8 @@ export declare class IkonClient {
153
159
  private _webRtcSignaling;
154
160
  private _webRtcConnectWatchdog;
155
161
  private _webRtcFallbackActive;
162
+ private _webRtcRetryCount;
163
+ private _webRtcRetryTimer;
156
164
  private _webRtcAudioElements;
157
165
  private _webRtcAudioStreams;
158
166
  private _webRtcVideoStreams;
@@ -177,6 +185,16 @@ export declare class IkonClient {
177
185
  * when WebRTC is disabled/unavailable. Callers must null-guard.
178
186
  */
179
187
  get media(): IkonMedia | null;
188
+ /**
189
+ * Recover audio output after an external disruption — most importantly iOS, where
190
+ * stopping microphone capture tears down the shared audio session and leaves playback
191
+ * silent. Covers both playback paths: the custom Web Audio pipeline (when active) and
192
+ * WebRTC audio elements.
193
+ *
194
+ * IMPORTANT: On iOS this must be called synchronously from a user gesture handler
195
+ * (e.g. a push-to-talk button release).
196
+ */
197
+ requestAudioRecovery(): void;
180
198
  /**
181
199
  * Lip-sync / shape-set receiver, available whenever audio is in use.
182
200
  *
@@ -215,11 +233,19 @@ export declare class IkonClient {
215
233
  * Returns false if both audio and video are disabled, even if webRtc.enabled is true.
216
234
  */
217
235
  get isWebRtcEnabled(): boolean;
236
+ /**
237
+ * Whether WebRTC currently carries the audio/video media. False when WebRTC is disabled
238
+ * by config, and also once playback has fallen back to the protocol channel after a
239
+ * WebRTC failure — the decode pipelines must then process protocol frames themselves.
240
+ */
241
+ get isWebRtcMediaActive(): boolean;
218
242
  /**
219
243
  * Whether media capture can use the WebRTC transport right now. False when WebRTC is
220
- * disabled by config, or when the WebRTC session is gone (e.g. connection failure tore
221
- * down signaling and playback fell back to the protocol channel) — capture must then
222
- * use the protocol-channel path instead.
244
+ * disabled by config, when the session is gone, and — critically — while a session exists
245
+ * but has not connected: a retry after a failure recreates signaling and clears the fallback
246
+ * flag immediately, so anything that only asked whether signaling exists would hand capture
247
+ * to a peer connection that is still trying to connect, and may never. Frames written there
248
+ * reach nobody and no fallback ever fires, because capture believed it had a transport.
223
249
  */
224
250
  get isWebRtcCaptureAvailable(): boolean;
225
251
  /**
@@ -259,6 +285,24 @@ export declare class IkonClient {
259
285
  * Returns undefined if not connected.
260
286
  */
261
287
  get sessionId(): number | undefined;
288
+ /**
289
+ * The Ikon server instance serving this connection. Stable across soft reconnects (cached
290
+ * entrypoints, same instance); changes when a full re-authentication lands on a different
291
+ * instance. This is the id that appears as `senderId` in server logs. Returns undefined before
292
+ * the first successful authentication.
293
+ */
294
+ get ikonServerId(): string | undefined;
295
+ /**
296
+ * The app session this connection joined — the session's business identity, stable across the
297
+ * Ikon servers that run it, and what the Portal addresses a session by. Returns undefined before
298
+ * the first successful authentication, and on a local run, which has no app session.
299
+ */
300
+ get appSessionId(): string | undefined;
301
+ /**
302
+ * True once the server has signaled it is shutting down (CORE_ON_SERVER_STOPPING).
303
+ * The client stays offline afterwards; only disconnect() resets this.
304
+ */
305
+ get serverStopped(): boolean;
262
306
  /**
263
307
  * Whether the backend connect handshake asked the client to display the platform
264
308
  * branding banner (set for low-tier app creators). Defaults to false.
@@ -290,6 +334,21 @@ export declare class IkonClient {
290
334
  * function-call wire as <see cref="functionRegistry" />.
291
335
  */
292
336
  get reactiveRegistry(): ReactiveRegistry;
337
+ /**
338
+ * Build a config for a sibling connection to the same deployment — same auth and
339
+ * transport settings as this client, with the given connection parameters replacing
340
+ * this client's. This is how a page opens an additional session next to its app
341
+ * connection, e.g. a media connection to a cell room (`ikon-cell-type` + the cell's
342
+ * identity fields). The returned config is a fresh object safe to extend before
343
+ * passing to `new IkonClient(...)`.
344
+ *
345
+ * Observer callbacks (`onConnectionStateChange`, `onError`, `onProtocolMessage`,
346
+ * `onVisibilityChange`, `onJoined`) are NOT inherited — they were registered to watch
347
+ * THIS client's connection, and a sibling reporting through them corrupts the owner's
348
+ * state (a closed media leg would paint the app's offline overlay). Pass them in
349
+ * `overrides` to observe the sibling.
350
+ */
351
+ deriveConfig(parameters: Record<string, string>, overrides?: Partial<IkonClientConfig>): IkonClientConfig;
293
352
  /**
294
353
  * Connect to the Ikon server.
295
354
  * Returns when connected or throws if connection fails.
@@ -304,6 +363,18 @@ export declare class IkonClient {
304
363
  */
305
364
  disconnect(): void;
306
365
  sendActionCall(actionId: string, payload?: string): void;
366
+ /**
367
+ * Dispatch a UI action and resolve with the server handler's actual outcome — the
368
+ * ActionResult the server emits when the handler finishes (the ActionCallAck is only a
369
+ * transport receipt). This is the primitive for optimistic UI with rollback: apply the
370
+ * optimistic change, await the outcome, revert when `success` is false.
371
+ *
372
+ * Rejects after `timeoutMs` — servers older than the ActionResult message never emit
373
+ * one, and a handler can genuinely hang; treat a rejection as "outcome unknown", not
374
+ * as failure.
375
+ */
376
+ sendActionCallWithResult(actionId: string, payload?: string, timeoutMs?: number): Promise<ActionOutcome>;
377
+ private sendActionCallCore;
307
378
  /**
308
379
  * Register an outstanding action call and start its ack-timeout timer. If the
309
380
  * server does not echo back an ActionCallAck for this CallId within
@@ -410,6 +481,16 @@ export declare class IkonClient {
410
481
  private enableCustomPlayback;
411
482
  private setupWebRtcSignaling;
412
483
  private clearWebRtcConnectWatchdog;
484
+ private clearWebRtcRetry;
485
+ /**
486
+ * A WebRTC-only failure (protocol channel still healthy) used to latch the session onto
487
+ * custom playback forever, even when the network recovered seconds later. Retry a bounded
488
+ * number of times so a transient blip doesn't permanently downgrade a long-lived session.
489
+ * Playback keeps running on the protocol channel in the meantime; once the new WebRTC
490
+ * session connects, the server routes media back over RTP and capture re-routes on the
491
+ * next segment via isWebRtcCaptureAvailable.
492
+ */
493
+ private scheduleWebRtcRetry;
413
494
  /**
414
495
  * Tear down a failed/never-connected WebRTC session and switch to the
415
496
  * non-WebRTC (protocol-channel) playback path. The server is told to drop the
@@ -417,10 +498,23 @@ export declare class IkonClient {
417
498
  * waiting for its liveness timeout. Idempotent.
418
499
  */
419
500
  private fallbackToCustomPlayback;
501
+ /**
502
+ * Tear down the WebRTC playback session and its DOM/stream bookkeeping.
503
+ * Closing the peer connection here also silences its later state callbacks,
504
+ * so a dead server does not surface as a spurious 'failed' transition.
505
+ */
506
+ private teardownWebRtcPlayback;
420
507
  private _webRtcAudioUnlockHandler;
421
508
  private readonly _webRtcMediaSession;
422
509
  private createWebRtcAudioElement;
423
510
  private destroyWebRtcAudioElement;
511
+ private scheduleWebRtcAudioPlaybackVerification;
512
+ /**
513
+ * Audibility-only playback report for a WebRTC audio track. RTP playback exposes no
514
+ * playout position, so PlayedSeconds is -1 (unknown); the report still tells the
515
+ * sender whether the user can hear the stream (e.g. blocked on a missing gesture).
516
+ */
517
+ private sendWebRtcAudioPlaybackReport;
424
518
  private ensureWebRtcAudioUnlockHandler;
425
519
  private setupWebRtcMediaSession;
426
520
  private removeWebRtcAudioUnlockHandler;
@@ -1,4 +1,4 @@
1
- import { AuthResponse } from '../../../../shared/protocol/src/index.ts';
1
+ import { AuthResponse } from '../../shared/protocol/src/index.ts';
2
2
  import { ApiKeyConfig, LocalConfig, SessionTokenConfig } from '../client/ikon-client-config';
3
3
  import { ProxyMode } from '../client/endpoint-selector';
4
4
  /**
@@ -34,7 +34,7 @@ export declare function authenticateLocal(config: LocalConfig, signal?: AbortSig
34
34
  *
35
35
  * Flow:
36
36
  * 1. POST /auth/api-key with { space, apiKey, user } → get JWT token
37
- * 2. POST /init to create profile, allocate channel, and wait for running
37
+ * 2. POST /init to create profile, resolve the app session, and wait for running
38
38
  * 3. Connect to the returned Ikon server URL
39
39
  */
40
40
  export declare function authenticateApiKey(config: ApiKeyConfig, signal?: AbortSignal, proxyMode?: ProxyMode, proxyPreferred?: boolean): Promise<AuthResult>;
@@ -44,7 +44,7 @@ export declare function authenticateApiKey(config: ApiKeyConfig, signal?: AbortS
44
44
  *
45
45
  * Flow:
46
46
  * 1. Use provided token as Bearer auth
47
- * 2. POST /init to create profile, allocate channel, and wait for running
47
+ * 2. POST /init to create profile, resolve the app session, and wait for running
48
48
  * 3. Connect to the returned Ikon server URL
49
49
  */
50
50
  export declare function authenticateSessionToken(config: SessionTokenConfig, signal?: AbortSignal, proxyMode?: ProxyMode, proxyPreferred?: boolean): Promise<AuthResult>;