spice-html5-react 0.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.
- package/README.md +262 -0
- package/dist/components/SpiceDisplay.d.ts +109 -0
- package/dist/components/SpiceDisplay.d.ts.map +1 -0
- package/dist/hooks/useSpice.d.ts +107 -0
- package/dist/hooks/useSpice.d.ts.map +1 -0
- package/dist/index.cjs +14 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +6745 -0
- package/dist/index.mjs.map +1 -0
- package/dist/protocol/bitmap.d.ts +20 -0
- package/dist/protocol/bitmap.d.ts.map +1 -0
- package/dist/protocol/cursor.d.ts +16 -0
- package/dist/protocol/cursor.d.ts.map +1 -0
- package/dist/protocol/display.d.ts +311 -0
- package/dist/protocol/display.d.ts.map +1 -0
- package/dist/protocol/enums.d.ts +677 -0
- package/dist/protocol/enums.d.ts.map +1 -0
- package/dist/protocol/filexfer.d.ts +61 -0
- package/dist/protocol/filexfer.d.ts.map +1 -0
- package/dist/protocol/index.d.ts +34 -0
- package/dist/protocol/index.d.ts.map +1 -0
- package/dist/protocol/inputs.d.ts +95 -0
- package/dist/protocol/inputs.d.ts.map +1 -0
- package/dist/protocol/lz.d.ts +24 -0
- package/dist/protocol/lz.d.ts.map +1 -0
- package/dist/protocol/main.d.ts +205 -0
- package/dist/protocol/main.d.ts.map +1 -0
- package/dist/protocol/playback.d.ts +51 -0
- package/dist/protocol/playback.d.ts.map +1 -0
- package/dist/protocol/png.d.ts +14 -0
- package/dist/protocol/png.d.ts.map +1 -0
- package/dist/protocol/port.d.ts +46 -0
- package/dist/protocol/port.d.ts.map +1 -0
- package/dist/protocol/quic.d.ts +105 -0
- package/dist/protocol/quic.d.ts.map +1 -0
- package/dist/protocol/resize.d.ts +61 -0
- package/dist/protocol/resize.d.ts.map +1 -0
- package/dist/protocol/simulatecursor.d.ts +49 -0
- package/dist/protocol/simulatecursor.d.ts.map +1 -0
- package/dist/protocol/spicearraybuffer.d.ts +44 -0
- package/dist/protocol/spicearraybuffer.d.ts.map +1 -0
- package/dist/protocol/spiceconn.d.ts +118 -0
- package/dist/protocol/spiceconn.d.ts.map +1 -0
- package/dist/protocol/spicedataview.d.ts +144 -0
- package/dist/protocol/spicedataview.d.ts.map +1 -0
- package/dist/protocol/spicemsg.d.ts +435 -0
- package/dist/protocol/spicemsg.d.ts.map +1 -0
- package/dist/protocol/spicetype.d.ts +166 -0
- package/dist/protocol/spicetype.d.ts.map +1 -0
- package/dist/protocol/ticket.d.ts +14 -0
- package/dist/protocol/ticket.d.ts.map +1 -0
- package/dist/protocol/webm.d.ts +118 -0
- package/dist/protocol/webm.d.ts.map +1 -0
- package/dist/protocol/wire.d.ts +81 -0
- package/dist/protocol/wire.d.ts.map +1 -0
- package/dist/utils/atKeynames.d.ts +96 -0
- package/dist/utils/atKeynames.d.ts.map +1 -0
- package/dist/utils/codeToScancode.d.ts +2 -0
- package/dist/utils/codeToScancode.d.ts.map +1 -0
- package/dist/utils/debug.d.ts +84 -0
- package/dist/utils/debug.d.ts.map +1 -0
- package/package.json +60 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ls=require("react/jsx-runtime"),P=require("react"),Nt="REDQ",$t=2,es=2,ts=3e4,Be={PROTOCOL_AUTH_SELECTION:0,AUTH_SPICE:1,AUTH_SASL:2,MINI_HEADER:3},dt=1024,ft=162,ue={OK:0,ERROR:1,INVALID_MAGIC:2,INVALID_DATA:3,VERSION_MISMATCH:4,NEED_SECURED:5,NEED_UNSECURED:6,PERMISSION_DENIED:7,BAD_CONNECTION_ID:8,CHANNEL_NOT_AVAILABLE:9},pe={MIGRATE:1,MIGRATE_DATA:2,SET_ACK:3,PING:4,WAIT_FOR_CHANNELS:5,DISCONNECTING:6,NOTIFY:7,LIST:8},I={MIGRATE_BEGIN:101,MIGRATE_CANCEL:102,INIT:103,CHANNELS_LIST:104,MOUSE_MODE:105,MULTI_MEDIA_TIME:106,AGENT_CONNECTED:107,AGENT_DISCONNECTED:108,AGENT_DATA:109,AGENT_TOKEN:110,MIGRATE_SWITCH_HOST:111,MIGRATE_END:112,NAME:113,UUID:114,AGENT_CONNECTED_TOKENS:115,MIGRATE_BEGIN_SEAMLESS:116,MIGRATE_DST_SEAMLESS_ACK:117,MIGRATE_DST_SEAMLESS_NACK:118,END:119},Te={ACK_SYNC:1,ACK:2,PONG:3,MIGRATE_FLUSH_MARK:4,MIGRATE_DATA:5,DISCONNECTING:6},re={CLIENT_INFO:101,MIGRATE_CONNECTED:102,MIGRATE_CONNECT_ERROR:103,ATTACH_CHANNELS:104,MOUSE_MODE_REQUEST:105,AGENT_START:106,AGENT_DATA:107,AGENT_TOKEN:108,MIGRATE_END:109,END:110},f={MODE:101,MARK:102,RESET:103,COPY_BITS:104,INVAL_LIST:105,INVAL_ALL_PIXMAPS:106,INVAL_PALETTE:107,INVAL_ALL_PALETTES:108,STREAM_CREATE:122,STREAM_DATA:123,STREAM_CLIP:124,STREAM_DESTROY:125,STREAM_DESTROY_ALL:126,DRAW_FILL:302,DRAW_OPAQUE:303,DRAW_COPY:304,DRAW_BLEND:305,DRAW_BLACKNESS:306,DRAW_WHITENESS:307,DRAW_INVERS:308,DRAW_ROP3:309,DRAW_STROKE:310,DRAW_TEXT:311,DRAW_TRANSPARENT:312,DRAW_ALPHA_BLEND:313,SURFACE_CREATE:314,SURFACE_DESTROY:315,STREAM_DATA_SIZED:316,MONITORS_CONFIG:317,DRAW_COMPOSITE:318,STREAM_ACTIVATE_REPORT:319},et={INIT:101,STREAM_REPORT:102},Ye={INIT:101,KEY_MODIFIERS:102,MOUSE_MOTION_ACK:111},K={KEY_DOWN:101,KEY_UP:102,KEY_MODIFIERS:103,MOUSE_MOTION:111,MOUSE_POSITION:112,MOUSE_PRESS:113,MOUSE_RELEASE:114},ee={INIT:101,RESET:102,SET:103,MOVE:104,HIDE:105,TRAIL:106,INVAL_ONE:107,INVAL_ALL:108},oe={DATA:101,MODE:102,START:103,STOP:104,VOLUME:105,MUTE:106,LATENCY:107},Ge={SPICEVMC_DATA:101,INIT:201,EVENT:202,END:203},Qe={SPICEVMC_DATA:101,EVENT:201,END:202},He={CELT_0_5_1:0,VOLUME:1,LATENCY:2,OPUS:3},ze={SEMI_SEAMLESS_MIGRATE:0,NAME_AND_UUID:1,AGENT_CONNECTED_TOKENS:2,SEAMLESS_MIGRATE:3},$={SIZED_STREAM:0,MONITORS_CONFIG:1,COMPOSITE:2,A8_SURFACE:3,STREAM_REPORT:4,LZ4_COMPRESSION:5,PREF_COMPRESSION:6,GL_SCANOUT:7,MULTI_CODEC:8,CODEC_MJPEG:9,CODEC_VP8:10},Xe={INVALID:0,RAW:1,CELT_0_5_1:2,OPUS:3},Et={INVALID:0,S16:1},p={MAIN:1,DISPLAY:2,INPUTS:3,CURSOR:4,PLAYBACK:5,RECORD:6,TUNNEL:7,SMARTCARD:8,USBREDIR:9,PORT:10,WEBDAV:11},ss=1,Ze={INFO:0,WARN:1,ERROR:2},be={SERVER:1,CLIENT:2,MASK:3},tt={NONE:0,RECTS:1},O={BITMAP:0,QUIC:1,RESERVED:2,LZ_PLT:100,LZ_RGB:101,GLZ_RGB:102,FROM_CACHE:103,SURFACE:104,JPEG:105,FROM_CACHE_LOSSLESS:106,ZLIB_GLZ_RGB:107,JPEG_ALPHA:108},Pe={CACHE_ME:1,HIGH_BITS_SET:2,CACHE_REPLACE_ME:4},Fe={PAL_CACHE_ME:1,PAL_FROM_CACHE:2,TOP_DOWN:4,MASK:7},ne={INVALID:0,_1BIT_LE:1,_1BIT_BE:2,_4BIT_LE:3,_4BIT_BE:4,_8BIT:5,_16BIT:6,_24BIT:7,_32BIT:8,RGBA:9},ve={NONE:1,CACHE_ME:2,FROM_CACHE:4,MASK:7},Re={LEFT:1,MIDDLE:2,RIGHT:4,MASK:7},ae={INVALID:0,LEFT:1,MIDDLE:2,RIGHT:3,UP:4,DOWN:5},ye={NONE:0,SOLID:1,PATTERN:2},le={INVALID:0,_1_A:1,_8_A:8,_16_555:16,_32_xRGB:32,_16_565:80,_32_ARGB:96},ie={INVERS_SRC:1,INVERS_BRUSH:2,INVERS_DEST:4,OP_PUT:8,OP_OR:16,OP_AND:32,OP_XOR:64,OP_BLACKNESS:128,OP_WHITENESS:256,OP_INVERS:512,INVERS_RES:1024,MASK:2047},B={INVALID:0,PLT1_LE:1,PLT1_BE:2,PLT4_LE:3,PLT4_BE:4,PLT8:5,RGB16:6,RGB24:7,RGB32:8,RGBA:9,XXXA:10},_t=4,we={ALPHA:0,MONO:1,COLOR4:2,COLOR8:3,COLOR16:4,COLOR24:5,COLOR32:6},Ue={MJPEG:1,VP8:2},is=1,St=2048,b={MOUSE_STATE:1,MONITORS_CONFIG:2,REPLY:3,CLIPBOARD:4,DISPLAY_CONFIG:5,ANNOUNCE_CAPABILITIES:6,CLIPBOARD_GRAB:7,CLIPBOARD_REQUEST:8,CLIPBOARD_RELEASE:9,FILE_XFER_START:10,FILE_XFER_STATUS:11,FILE_XFER_DATA:12,CLIENT_DISCONNECTED:13,MAX_CLIPBOARD:14},Q={MOUSE_STATE:0,MONITORS_CONFIG:1,REPLY:2,CLIPBOARD:3,DISPLAY_CONFIG:4,CLIPBOARD_BY_DEMAND:5,CLIPBOARD_SELECTION:6,SPARSE_MONITORS_CONFIG:7,GUEST_LINEEND_LF:8,GUEST_LINEEND_CRLF:9,MAX_CLIPBOARD:10,END:11},Me={CAN_SEND_DATA:0,CANCELLED:1,ERROR:2,SUCCESS:3},me={NONE:0,UTF8_TEXT:1,IMAGE_PNG:2,IMAGE_BMP:3,IMAGE_TIFF:4,IMAGE_JPG:5},lr={SPICE_MAGIC:Nt,SPICE_VERSION_MAJOR:$t,SPICE_VERSION_MINOR:es,SPICE_CONNECT_TIMEOUT:ts,SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION:Be.PROTOCOL_AUTH_SELECTION,SPICE_COMMON_CAP_AUTH_SPICE:Be.AUTH_SPICE,SPICE_COMMON_CAP_AUTH_SASL:Be.AUTH_SASL,SPICE_COMMON_CAP_MINI_HEADER:Be.MINI_HEADER,SPICE_TICKET_KEY_PAIR_LENGTH:dt,SPICE_TICKET_PUBKEY_BYTES:ft,SPICE_LINK_ERR_OK:ue.OK,SPICE_LINK_ERR_ERROR:ue.ERROR,SPICE_LINK_ERR_INVALID_MAGIC:ue.INVALID_MAGIC,SPICE_LINK_ERR_INVALID_DATA:ue.INVALID_DATA,SPICE_LINK_ERR_VERSION_MISMATCH:ue.VERSION_MISMATCH,SPICE_LINK_ERR_NEED_SECURED:ue.NEED_SECURED,SPICE_LINK_ERR_NEED_UNSECURED:ue.NEED_UNSECURED,SPICE_LINK_ERR_PERMISSION_DENIED:ue.PERMISSION_DENIED,SPICE_LINK_ERR_BAD_CONNECTION_ID:ue.BAD_CONNECTION_ID,SPICE_LINK_ERR_CHANNEL_NOT_AVAILABLE:ue.CHANNEL_NOT_AVAILABLE,SPICE_MSG_MIGRATE:pe.MIGRATE,SPICE_MSG_MIGRATE_DATA:pe.MIGRATE_DATA,SPICE_MSG_SET_ACK:pe.SET_ACK,SPICE_MSG_PING:pe.PING,SPICE_MSG_WAIT_FOR_CHANNELS:pe.WAIT_FOR_CHANNELS,SPICE_MSG_DISCONNECTING:pe.DISCONNECTING,SPICE_MSG_NOTIFY:pe.NOTIFY,SPICE_MSG_LIST:pe.LIST,SPICE_MSG_MAIN_MIGRATE_BEGIN:I.MIGRATE_BEGIN,SPICE_MSG_MAIN_MIGRATE_CANCEL:I.MIGRATE_CANCEL,SPICE_MSG_MAIN_INIT:I.INIT,SPICE_MSG_MAIN_CHANNELS_LIST:I.CHANNELS_LIST,SPICE_MSG_MAIN_MOUSE_MODE:I.MOUSE_MODE,SPICE_MSG_MAIN_MULTI_MEDIA_TIME:I.MULTI_MEDIA_TIME,SPICE_MSG_MAIN_AGENT_CONNECTED:I.AGENT_CONNECTED,SPICE_MSG_MAIN_AGENT_DISCONNECTED:I.AGENT_DISCONNECTED,SPICE_MSG_MAIN_AGENT_DATA:I.AGENT_DATA,SPICE_MSG_MAIN_AGENT_TOKEN:I.AGENT_TOKEN,SPICE_MSG_MAIN_MIGRATE_SWITCH_HOST:I.MIGRATE_SWITCH_HOST,SPICE_MSG_MAIN_MIGRATE_END:I.MIGRATE_END,SPICE_MSG_MAIN_NAME:I.NAME,SPICE_MSG_MAIN_UUID:I.UUID,SPICE_MSG_MAIN_AGENT_CONNECTED_TOKENS:I.AGENT_CONNECTED_TOKENS,SPICE_MSG_MAIN_MIGRATE_BEGIN_SEAMLESS:I.MIGRATE_BEGIN_SEAMLESS,SPICE_MSG_MAIN_MIGRATE_DST_SEAMLESS_ACK:I.MIGRATE_DST_SEAMLESS_ACK,SPICE_MSG_MAIN_MIGRATE_DST_SEAMLESS_NACK:I.MIGRATE_DST_SEAMLESS_NACK,SPICE_MSG_END_MAIN:I.END,SPICE_MSGC_ACK_SYNC:Te.ACK_SYNC,SPICE_MSGC_ACK:Te.ACK,SPICE_MSGC_PONG:Te.PONG,SPICE_MSGC_MIGRATE_FLUSH_MARK:Te.MIGRATE_FLUSH_MARK,SPICE_MSGC_MIGRATE_DATA:Te.MIGRATE_DATA,SPICE_MSGC_DISCONNECTING:Te.DISCONNECTING,SPICE_MSGC_MAIN_CLIENT_INFO:re.CLIENT_INFO,SPICE_MSGC_MAIN_MIGRATE_CONNECTED:re.MIGRATE_CONNECTED,SPICE_MSGC_MAIN_MIGRATE_CONNECT_ERROR:re.MIGRATE_CONNECT_ERROR,SPICE_MSGC_MAIN_ATTACH_CHANNELS:re.ATTACH_CHANNELS,SPICE_MSGC_MAIN_MOUSE_MODE_REQUEST:re.MOUSE_MODE_REQUEST,SPICE_MSGC_MAIN_AGENT_START:re.AGENT_START,SPICE_MSGC_MAIN_AGENT_DATA:re.AGENT_DATA,SPICE_MSGC_MAIN_AGENT_TOKEN:re.AGENT_TOKEN,SPICE_MSGC_MAIN_MIGRATE_END:re.MIGRATE_END,SPICE_MSGC_END_MAIN:re.END,SPICE_MSG_DISPLAY_MODE:f.MODE,SPICE_MSG_DISPLAY_MARK:f.MARK,SPICE_MSG_DISPLAY_RESET:f.RESET,SPICE_MSG_DISPLAY_COPY_BITS:f.COPY_BITS,SPICE_MSG_DISPLAY_INVAL_LIST:f.INVAL_LIST,SPICE_MSG_DISPLAY_INVAL_ALL_PIXMAPS:f.INVAL_ALL_PIXMAPS,SPICE_MSG_DISPLAY_INVAL_PALETTE:f.INVAL_PALETTE,SPICE_MSG_DISPLAY_INVAL_ALL_PALETTES:f.INVAL_ALL_PALETTES,SPICE_MSG_DISPLAY_STREAM_CREATE:f.STREAM_CREATE,SPICE_MSG_DISPLAY_STREAM_DATA:f.STREAM_DATA,SPICE_MSG_DISPLAY_STREAM_CLIP:f.STREAM_CLIP,SPICE_MSG_DISPLAY_STREAM_DESTROY:f.STREAM_DESTROY,SPICE_MSG_DISPLAY_STREAM_DESTROY_ALL:f.STREAM_DESTROY_ALL,SPICE_MSG_DISPLAY_DRAW_FILL:f.DRAW_FILL,SPICE_MSG_DISPLAY_DRAW_OPAQUE:f.DRAW_OPAQUE,SPICE_MSG_DISPLAY_DRAW_COPY:f.DRAW_COPY,SPICE_MSG_DISPLAY_DRAW_BLEND:f.DRAW_BLEND,SPICE_MSG_DISPLAY_DRAW_BLACKNESS:f.DRAW_BLACKNESS,SPICE_MSG_DISPLAY_DRAW_WHITENESS:f.DRAW_WHITENESS,SPICE_MSG_DISPLAY_DRAW_INVERS:f.DRAW_INVERS,SPICE_MSG_DISPLAY_DRAW_ROP3:f.DRAW_ROP3,SPICE_MSG_DISPLAY_DRAW_STROKE:f.DRAW_STROKE,SPICE_MSG_DISPLAY_DRAW_TEXT:f.DRAW_TEXT,SPICE_MSG_DISPLAY_DRAW_TRANSPARENT:f.DRAW_TRANSPARENT,SPICE_MSG_DISPLAY_DRAW_ALPHA_BLEND:f.DRAW_ALPHA_BLEND,SPICE_MSG_DISPLAY_SURFACE_CREATE:f.SURFACE_CREATE,SPICE_MSG_DISPLAY_SURFACE_DESTROY:f.SURFACE_DESTROY,SPICE_MSG_DISPLAY_STREAM_DATA_SIZED:f.STREAM_DATA_SIZED,SPICE_MSG_DISPLAY_MONITORS_CONFIG:f.MONITORS_CONFIG,SPICE_MSG_DISPLAY_DRAW_COMPOSITE:f.DRAW_COMPOSITE,SPICE_MSG_DISPLAY_STREAM_ACTIVATE_REPORT:f.STREAM_ACTIVATE_REPORT,SPICE_MSGC_DISPLAY_INIT:et.INIT,SPICE_MSGC_DISPLAY_STREAM_REPORT:et.STREAM_REPORT,SPICE_MSG_INPUTS_INIT:Ye.INIT,SPICE_MSG_INPUTS_KEY_MODIFIERS:Ye.KEY_MODIFIERS,SPICE_MSG_INPUTS_MOUSE_MOTION_ACK:Ye.MOUSE_MOTION_ACK,SPICE_MSGC_INPUTS_KEY_DOWN:K.KEY_DOWN,SPICE_MSGC_INPUTS_KEY_UP:K.KEY_UP,SPICE_MSGC_INPUTS_KEY_MODIFIERS:K.KEY_MODIFIERS,SPICE_MSGC_INPUTS_MOUSE_MOTION:K.MOUSE_MOTION,SPICE_MSGC_INPUTS_MOUSE_POSITION:K.MOUSE_POSITION,SPICE_MSGC_INPUTS_MOUSE_PRESS:K.MOUSE_PRESS,SPICE_MSGC_INPUTS_MOUSE_RELEASE:K.MOUSE_RELEASE,SPICE_MSG_CURSOR_INIT:ee.INIT,SPICE_MSG_CURSOR_RESET:ee.RESET,SPICE_MSG_CURSOR_SET:ee.SET,SPICE_MSG_CURSOR_MOVE:ee.MOVE,SPICE_MSG_CURSOR_HIDE:ee.HIDE,SPICE_MSG_CURSOR_TRAIL:ee.TRAIL,SPICE_MSG_CURSOR_INVAL_ONE:ee.INVAL_ONE,SPICE_MSG_CURSOR_INVAL_ALL:ee.INVAL_ALL,SPICE_MSG_PLAYBACK_DATA:oe.DATA,SPICE_MSG_PLAYBACK_MODE:oe.MODE,SPICE_MSG_PLAYBACK_START:oe.START,SPICE_MSG_PLAYBACK_STOP:oe.STOP,SPICE_MSG_PLAYBACK_VOLUME:oe.VOLUME,SPICE_MSG_PLAYBACK_MUTE:oe.MUTE,SPICE_MSG_PLAYBACK_LATENCY:oe.LATENCY,SPICE_MSG_SPICEVMC_DATA:Ge.SPICEVMC_DATA,SPICE_MSG_PORT_INIT:Ge.INIT,SPICE_MSG_PORT_EVENT:Ge.EVENT,SPICE_MSG_END_PORT:Ge.END,SPICE_MSGC_SPICEVMC_DATA:Qe.SPICEVMC_DATA,SPICE_MSGC_PORT_EVENT:Qe.EVENT,SPICE_MSGC_END_PORT:Qe.END,SPICE_PLAYBACK_CAP_CELT_0_5_1:He.CELT_0_5_1,SPICE_PLAYBACK_CAP_VOLUME:He.VOLUME,SPICE_PLAYBACK_CAP_LATENCY:He.LATENCY,SPICE_PLAYBACK_CAP_OPUS:He.OPUS,SPICE_MAIN_CAP_SEMI_SEAMLESS_MIGRATE:ze.SEMI_SEAMLESS_MIGRATE,SPICE_MAIN_CAP_NAME_AND_UUID:ze.NAME_AND_UUID,SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS:ze.AGENT_CONNECTED_TOKENS,SPICE_MAIN_CAP_SEAMLESS_MIGRATE:ze.SEAMLESS_MIGRATE,SPICE_DISPLAY_CAP_SIZED_STREAM:$.SIZED_STREAM,SPICE_DISPLAY_CAP_MONITORS_CONFIG:$.MONITORS_CONFIG,SPICE_DISPLAY_CAP_COMPOSITE:$.COMPOSITE,SPICE_DISPLAY_CAP_A8_SURFACE:$.A8_SURFACE,SPICE_DISPLAY_CAP_STREAM_REPORT:$.STREAM_REPORT,SPICE_DISPLAY_CAP_LZ4_COMPRESSION:$.LZ4_COMPRESSION,SPICE_DISPLAY_CAP_PREF_COMPRESSION:$.PREF_COMPRESSION,SPICE_DISPLAY_CAP_GL_SCANOUT:$.GL_SCANOUT,SPICE_DISPLAY_CAP_MULTI_CODEC:$.MULTI_CODEC,SPICE_DISPLAY_CAP_CODEC_MJPEG:$.CODEC_MJPEG,SPICE_DISPLAY_CAP_CODEC_VP8:$.CODEC_VP8,SPICE_AUDIO_DATA_MODE_INVALID:Xe.INVALID,SPICE_AUDIO_DATA_MODE_RAW:Xe.RAW,SPICE_AUDIO_DATA_MODE_CELT_0_5_1:Xe.CELT_0_5_1,SPICE_AUDIO_DATA_MODE_OPUS:Xe.OPUS,SPICE_AUDIO_FMT_INVALID:Et.INVALID,SPICE_AUDIO_FMT_S16:Et.S16,SPICE_CHANNEL_MAIN:p.MAIN,SPICE_CHANNEL_DISPLAY:p.DISPLAY,SPICE_CHANNEL_INPUTS:p.INPUTS,SPICE_CHANNEL_CURSOR:p.CURSOR,SPICE_CHANNEL_PLAYBACK:p.PLAYBACK,SPICE_CHANNEL_RECORD:p.RECORD,SPICE_CHANNEL_TUNNEL:p.TUNNEL,SPICE_CHANNEL_SMARTCARD:p.SMARTCARD,SPICE_CHANNEL_USBREDIR:p.USBREDIR,SPICE_CHANNEL_PORT:p.PORT,SPICE_CHANNEL_WEBDAV:p.WEBDAV,SPICE_SURFACE_FLAGS_PRIMARY:ss,SPICE_NOTIFY_SEVERITY_INFO:Ze.INFO,SPICE_NOTIFY_SEVERITY_WARN:Ze.WARN,SPICE_NOTIFY_SEVERITY_ERROR:Ze.ERROR,SPICE_MOUSE_MODE_SERVER:be.SERVER,SPICE_MOUSE_MODE_CLIENT:be.CLIENT,SPICE_MOUSE_MODE_MASK:be.MASK,SPICE_CLIP_TYPE_NONE:tt.NONE,SPICE_CLIP_TYPE_RECTS:tt.RECTS,SPICE_IMAGE_TYPE_BITMAP:O.BITMAP,SPICE_IMAGE_TYPE_QUIC:O.QUIC,SPICE_IMAGE_TYPE_RESERVED:O.RESERVED,SPICE_IMAGE_TYPE_LZ_PLT:O.LZ_PLT,SPICE_IMAGE_TYPE_LZ_RGB:O.LZ_RGB,SPICE_IMAGE_TYPE_GLZ_RGB:O.GLZ_RGB,SPICE_IMAGE_TYPE_FROM_CACHE:O.FROM_CACHE,SPICE_IMAGE_TYPE_SURFACE:O.SURFACE,SPICE_IMAGE_TYPE_JPEG:O.JPEG,SPICE_IMAGE_TYPE_FROM_CACHE_LOSSLESS:O.FROM_CACHE_LOSSLESS,SPICE_IMAGE_TYPE_ZLIB_GLZ_RGB:O.ZLIB_GLZ_RGB,SPICE_IMAGE_TYPE_JPEG_ALPHA:O.JPEG_ALPHA,SPICE_IMAGE_FLAGS_CACHE_ME:Pe.CACHE_ME,SPICE_IMAGE_FLAGS_HIGH_BITS_SET:Pe.HIGH_BITS_SET,SPICE_IMAGE_FLAGS_CACHE_REPLACE_ME:Pe.CACHE_REPLACE_ME,SPICE_BITMAP_FLAGS_PAL_CACHE_ME:Fe.PAL_CACHE_ME,SPICE_BITMAP_FLAGS_PAL_FROM_CACHE:Fe.PAL_FROM_CACHE,SPICE_BITMAP_FLAGS_TOP_DOWN:Fe.TOP_DOWN,SPICE_BITMAP_FLAGS_MASK:Fe.MASK,SPICE_BITMAP_FMT_INVALID:ne.INVALID,SPICE_BITMAP_FMT_1BIT_LE:ne._1BIT_LE,SPICE_BITMAP_FMT_1BIT_BE:ne._1BIT_BE,SPICE_BITMAP_FMT_4BIT_LE:ne._4BIT_LE,SPICE_BITMAP_FMT_4BIT_BE:ne._4BIT_BE,SPICE_BITMAP_FMT_8BIT:ne._8BIT,SPICE_BITMAP_FMT_16BIT:ne._16BIT,SPICE_BITMAP_FMT_24BIT:ne._24BIT,SPICE_BITMAP_FMT_32BIT:ne._32BIT,SPICE_BITMAP_FMT_RGBA:ne.RGBA,SPICE_CURSOR_FLAGS_NONE:ve.NONE,SPICE_CURSOR_FLAGS_CACHE_ME:ve.CACHE_ME,SPICE_CURSOR_FLAGS_FROM_CACHE:ve.FROM_CACHE,SPICE_CURSOR_FLAGS_MASK:ve.MASK,SPICE_MOUSE_BUTTON_MASK_LEFT:Re.LEFT,SPICE_MOUSE_BUTTON_MASK_MIDDLE:Re.MIDDLE,SPICE_MOUSE_BUTTON_MASK_RIGHT:Re.RIGHT,SPICE_MOUSE_BUTTON_MASK_MASK:Re.MASK,SPICE_MOUSE_BUTTON_INVALID:ae.INVALID,SPICE_MOUSE_BUTTON_LEFT:ae.LEFT,SPICE_MOUSE_BUTTON_MIDDLE:ae.MIDDLE,SPICE_MOUSE_BUTTON_RIGHT:ae.RIGHT,SPICE_MOUSE_BUTTON_UP:ae.UP,SPICE_MOUSE_BUTTON_DOWN:ae.DOWN,SPICE_BRUSH_TYPE_NONE:ye.NONE,SPICE_BRUSH_TYPE_SOLID:ye.SOLID,SPICE_BRUSH_TYPE_PATTERN:ye.PATTERN,SPICE_SURFACE_FMT_INVALID:le.INVALID,SPICE_SURFACE_FMT_1_A:le._1_A,SPICE_SURFACE_FMT_8_A:le._8_A,SPICE_SURFACE_FMT_16_555:le._16_555,SPICE_SURFACE_FMT_32_xRGB:le._32_xRGB,SPICE_SURFACE_FMT_16_565:le._16_565,SPICE_SURFACE_FMT_32_ARGB:le._32_ARGB,SPICE_ROPD_INVERS_SRC:ie.INVERS_SRC,SPICE_ROPD_INVERS_BRUSH:ie.INVERS_BRUSH,SPICE_ROPD_INVERS_DEST:ie.INVERS_DEST,SPICE_ROPD_OP_PUT:ie.OP_PUT,SPICE_ROPD_OP_OR:ie.OP_OR,SPICE_ROPD_OP_AND:ie.OP_AND,SPICE_ROPD_OP_XOR:ie.OP_XOR,SPICE_ROPD_OP_BLACKNESS:ie.OP_BLACKNESS,SPICE_ROPD_OP_WHITENESS:ie.OP_WHITENESS,SPICE_ROPD_OP_INVERS:ie.OP_INVERS,SPICE_ROPD_INVERS_RES:ie.INVERS_RES,SPICE_ROPD_MASK:ie.MASK,LZ_IMAGE_TYPE_INVALID:B.INVALID,LZ_IMAGE_TYPE_PLT1_LE:B.PLT1_LE,LZ_IMAGE_TYPE_PLT1_BE:B.PLT1_BE,LZ_IMAGE_TYPE_PLT4_LE:B.PLT4_LE,LZ_IMAGE_TYPE_PLT4_BE:B.PLT4_BE,LZ_IMAGE_TYPE_PLT8:B.PLT8,LZ_IMAGE_TYPE_RGB16:B.RGB16,LZ_IMAGE_TYPE_RGB24:B.RGB24,LZ_IMAGE_TYPE_RGB32:B.RGB32,LZ_IMAGE_TYPE_RGBA:B.RGBA,LZ_IMAGE_TYPE_XXXA:B.XXXA,SPICE_INPUT_MOTION_ACK_BUNCH:_t,SPICE_CURSOR_TYPE_ALPHA:we.ALPHA,SPICE_CURSOR_TYPE_MONO:we.MONO,SPICE_CURSOR_TYPE_COLOR4:we.COLOR4,SPICE_CURSOR_TYPE_COLOR8:we.COLOR8,SPICE_CURSOR_TYPE_COLOR16:we.COLOR16,SPICE_CURSOR_TYPE_COLOR24:we.COLOR24,SPICE_CURSOR_TYPE_COLOR32:we.COLOR32,SPICE_VIDEO_CODEC_TYPE_MJPEG:Ue.MJPEG,SPICE_VIDEO_CODEC_TYPE_VP8:Ue.VP8,VD_AGENT_PROTOCOL:is,VD_AGENT_MAX_DATA_SIZE:St,VD_AGENT_MOUSE_STATE:b.MOUSE_STATE,VD_AGENT_MONITORS_CONFIG:b.MONITORS_CONFIG,VD_AGENT_REPLY:b.REPLY,VD_AGENT_CLIPBOARD:b.CLIPBOARD,VD_AGENT_DISPLAY_CONFIG:b.DISPLAY_CONFIG,VD_AGENT_ANNOUNCE_CAPABILITIES:b.ANNOUNCE_CAPABILITIES,VD_AGENT_CLIPBOARD_GRAB:b.CLIPBOARD_GRAB,VD_AGENT_CLIPBOARD_REQUEST:b.CLIPBOARD_REQUEST,VD_AGENT_CLIPBOARD_RELEASE:b.CLIPBOARD_RELEASE,VD_AGENT_FILE_XFER_START:b.FILE_XFER_START,VD_AGENT_FILE_XFER_STATUS:b.FILE_XFER_STATUS,VD_AGENT_FILE_XFER_DATA:b.FILE_XFER_DATA,VD_AGENT_CLIENT_DISCONNECTED:b.CLIENT_DISCONNECTED,VD_AGENT_MAX_CLIPBOARD:b.MAX_CLIPBOARD,VD_AGENT_CAP_MOUSE_STATE:Q.MOUSE_STATE,VD_AGENT_CAP_MONITORS_CONFIG:Q.MONITORS_CONFIG,VD_AGENT_CAP_REPLY:Q.REPLY,VD_AGENT_CAP_CLIPBOARD:Q.CLIPBOARD,VD_AGENT_CAP_DISPLAY_CONFIG:Q.DISPLAY_CONFIG,VD_AGENT_CAP_CLIPBOARD_BY_DEMAND:Q.CLIPBOARD_BY_DEMAND,VD_AGENT_CAP_CLIPBOARD_SELECTION:Q.CLIPBOARD_SELECTION,VD_AGENT_CAP_SPARSE_MONITORS_CONFIG:Q.SPARSE_MONITORS_CONFIG,VD_AGENT_CAP_GUEST_LINEEND_LF:Q.GUEST_LINEEND_LF,VD_AGENT_CAP_GUEST_LINEEND_CRLF:Q.GUEST_LINEEND_CRLF,VD_AGENT_CAP_MAX_CLIPBOARD:Q.MAX_CLIPBOARD,VD_AGENT_END_CAP:Q.END,VD_AGENT_FILE_XFER_STATUS_CAN_SEND_DATA:Me.CAN_SEND_DATA,VD_AGENT_FILE_XFER_STATUS_CANCELLED:Me.CANCELLED,VD_AGENT_FILE_XFER_STATUS_ERROR:Me.ERROR,VD_AGENT_FILE_XFER_STATUS_SUCCESS:Me.SUCCESS,VD_AGENT_CLIPBOARD_NONE:me.NONE,VD_AGENT_CLIPBOARD_UTF8_TEXT:me.UTF8_TEXT,VD_AGENT_CLIPBOARD_IMAGE_PNG:me.IMAGE_PNG,VD_AGENT_CLIPBOARD_IMAGE_BMP:me.IMAGE_BMP,VD_AGENT_CLIPBOARD_IMAGE_TIFF:me.IMAGE_TIFF,VD_AGENT_CLIPBOARD_IMAGE_JPG:me.IMAGE_JPG};let Ft=null;function dr(r){Ft=r}class Fs{constructor(){this.type=0,this.id=0}fromDataView(t,e,s){return this.type=t.getUint8(e),e++,this.id=t.getUint8(e),e++,e}}class Ce{constructor(){this.top=0,this.left=0,this.bottom=0,this.right=0}fromDataView(t,e,s){return this.top=t.getUint32(e,!0),e+=4,this.left=t.getUint32(e,!0),e+=4,this.bottom=t.getUint32(e,!0),e+=4,this.right=t.getUint32(e,!0),e+=4,e}isSameSize(t){return this.bottom-this.top===t.bottom-t.top&&this.right-this.left===t.right-t.left}}class vs{constructor(){this.numRects=0,this.rects=[]}fromDataView(t,e,s){this.numRects=t.getUint32(e,!0),e+=4,this.rects=[];for(let i=0;i<this.numRects;i++){const n=new Ce;e=n.fromDataView(t,e,s),this.rects.push(n)}return e}}class Ve{constructor(){this.type=0,this.rects=null}fromDataView(t,e,s){return this.type=t.getUint8(e),e++,this.type===tt.RECTS&&(this.rects=new vs,e=this.rects.fromDataView(t,e,s)),e}}class vt{constructor(){this.id=0n,this.type=0,this.flags=0,this.width=0,this.height=0}fromDataView(t,e,s){return this.id=t.getBigUint64(e,!0),e+=8,this.type=t.getUint8(e),e++,this.flags=t.getUint8(e),e++,this.width=t.getUint32(e,!0),e+=4,this.height=t.getUint32(e,!0),e+=4,e}}class Ys{constructor(){this.unique=0n,this.numEnts=0,this.ents=[]}fromDataView(t,e,s){this.unique=t.getBigUint64(e,!0),e+=8,this.numEnts=t.getUint16(e,!0),e+=2,this.ents=[];for(let i=0;i<this.numEnts;i++)this.ents[i]=t.getUint32(e,!0),e+=4;return e}}class Vs{constructor(){this.format=0,this.flags=0,this.x=0,this.y=0,this.stride=0,this.paletteId=0n,this.palette=null,this.data=new ArrayBuffer(0)}fromDataView(t,e,s){if(this.format=t.getUint8(e),e++,this.flags=t.getUint8(e),e++,this.x=t.getUint32(e,!0),e+=4,this.y=t.getUint32(e,!0),e+=4,this.stride=t.getUint32(e,!0),e+=4,this.flags&Fe.PAL_FROM_CACHE)this.paletteId=t.getBigUint64(e,!0),e+=8;else{const i=t.getUint32(e,!0);e+=4,i===0?this.palette=null:(this.palette=new Ys,this.palette.fromDataView(t,i,s))}return this.data=s.slice(e),e+=this.data.byteLength,e}}class ke{constructor(){this.x=0,this.y=0}fromDataView(t,e,s){return this.x=t.getUint32(e,!0),e+=4,this.y=t.getUint32(e,!0),e+=4,e}}class st{constructor(){this.x=0,this.y=0}fromDataView(t,e,s){return this.x=t.getUint16(e,!0),e+=2,this.y=t.getUint16(e,!0),e+=2,e}}class Lt{constructor(){this.descriptor=new vt,this.lzRgb=null,this.bitmap=null,this.surfaceId=null,this.jpeg=null,this.jpegAlpha=null,this.quic=null}fromDataView(t,e,s){if(this.descriptor=new vt,e=this.descriptor.fromDataView(t,e,s),this.descriptor.type===O.LZ_RGB&&(e=this.parseLzRgb(t,e,s)),this.descriptor.type===O.BITMAP&&(this.bitmap=new Vs,e=this.bitmap.fromDataView(t,e,s)),this.descriptor.type===O.SURFACE&&(this.surfaceId=t.getUint32(e,!0),e+=4),this.descriptor.type===O.JPEG){const i=t.getUint32(e,!0);e+=4;const n=s.slice(e);this.jpeg={data_size:i,data:n},e+=n.byteLength}if(this.descriptor.type===O.JPEG_ALPHA&&(e=this.parseJpegAlpha(t,e,s)),this.descriptor.type===O.QUIC){if(!Ft)throw new Error("SpiceQuic factory not registered. Call registerSpiceQuicFactory() before decoding QUIC images.");this.quic=Ft(),e=this.quic.fromDataView(t,e,s)}return e}parseLzRgb(t,e,s){const i=t.getUint32(e,!0);e+=4;const n=e;let o="";for(let g=3;g>=0;g--)o+=String.fromCharCode(t.getUint8(e+g));e+=4;const h=t.getUint32(e);e+=4;const u=t.getUint32(e);e+=4;const a=t.getUint32(e);e+=4;const l=t.getUint32(e);e+=4;const E=t.getUint32(e);e+=4;const _=t.getUint32(e);e+=4;const d=e-n,S=s.slice(e,i+e-d);return e+=S.byteLength,this.lzRgb={length:i,magic:o,version:h,type:u,width:a,height:l,stride:E,top_down:_,data:S},e}parseJpegAlpha(t,e,s){const i=t.getUint8(e);e+=1;const n=t.getUint32(e,!0);e+=4;const o=t.getUint32(e,!0);e+=4;const h=s.slice(e,n+e);e+=h.byteLength;const u=o-n,a=e;let l="";for(let R=3;R>=0;R--)l+=String.fromCharCode(t.getUint8(e+R));e+=4;const E=t.getUint32(e);e+=4;const _=t.getUint32(e);e+=4;const d=t.getUint32(e);e+=4;const S=t.getUint32(e);e+=4;const g=t.getUint32(e);e+=4;const D=t.getUint32(e);e+=4;const k=e-a,F=s.slice(e,u+e-k);return e+=F.byteLength,this.jpegAlpha={flags:i,jpeg_size:n,data_size:o,data:h,alpha:{length:u,magic:l,version:E,type:_,width:d,height:S,stride:g,top_down:D,data:F}},e}}class it{constructor(){this.flags=0,this.pos=new ke,this.bitmap=null}fromDataView(t,e,s){this.flags=t.getUint8(e),e++,this.pos=new ke,e=this.pos.fromDataView(t,e,s);const i=t.getUint32(e,!0);return e+=4,i===0?(this.bitmap=null,e):(this.bitmap=new Lt,this.bitmap.fromDataView(t,i,s))}}class ks{constructor(){this.pat=null,this.pos=new ke}fromDataView(t,e,s){const i=t.getUint32(e,!0);return e+=4,i===0?this.pat=null:(this.pat=new Lt,this.pat.fromDataView(t,i,s)),this.pos=new ke,this.pos.fromDataView(t,e,s)}}class Yt{constructor(){this.type=0,this.color=0,this.pattern=null}fromDataView(t,e,s){return this.type=t.getUint8(e),e++,this.type===ye.SOLID?(this.color=t.getUint32(e,!0),e+=4):this.type===ye.PATTERN&&(this.pattern=new ks,e=this.pattern.fromDataView(t,e,s)),e}}class Vt{constructor(){this.brush=new Yt,this.ropDescriptor=0,this.mask=new it}fromDataView(t,e,s){return this.brush=new Yt,e=this.brush.fromDataView(t,e,s),this.ropDescriptor=t.getUint16(e,!0),e+=2,this.mask=new it,this.mask.fromDataView(t,e,s)}}class kt{constructor(){this.srcBitmap=null,this.srcArea=new Ce,this.ropDescriptor=0,this.scaleMode=0,this.mask=new it}fromDataView(t,e,s){const i=t.getUint32(e,!0);return e+=4,i===0?this.srcBitmap=null:(this.srcBitmap=new Lt,this.srcBitmap.fromDataView(t,i,s)),this.srcArea=new Ce,e=this.srcArea.fromDataView(t,e,s),this.ropDescriptor=t.getUint16(e,!0),e+=2,this.scaleMode=t.getUint8(e),e++,this.mask=new it,this.mask.fromDataView(t,e,s)}}class xs{constructor(){this.unique=0n,this.type=0,this.width=0,this.height=0,this.hotSpotX=0,this.hotSpotY=0}fromDataView(t,e,s){return this.unique=t.getBigUint64(e,!0),e+=8,this.type=t.getUint8(e),e++,this.width=t.getUint16(e,!0),e+=2,this.height=t.getUint16(e,!0),e+=2,this.hotSpotX=t.getUint16(e,!0),e+=2,this.hotSpotY=t.getUint16(e,!0),e+=2,e}}class rt{constructor(){this.flags=0,this.header=null,this.data=new ArrayBuffer(0)}fromDataView(t,e,s){return this.flags=t.getUint16(e,!0),e+=2,this.flags&ve.NONE?this.header=null:(this.header=new xs,e=this.header.fromDataView(t,e,s),this.data=s.slice(e),e+=this.data.byteLength),e}}class xt{constructor(){this.surfaceId=0,this.width=0,this.height=0,this.format=0,this.flags=0}fromDataView(t,e,s){return this.surfaceId=t.getUint32(e,!0),e+=4,this.width=t.getUint32(e,!0),e+=4,this.height=t.getUint32(e,!0),e+=4,this.format=t.getUint32(e,!0),e+=4,this.flags=t.getUint32(e,!0),e+=4,e}}class ut{constructor(t,e){this.magic=Nt,this.majorVersion=$t,this.minorVersion=es,this.size=0,t!==void 0&&this.fromBuffer(t,e)}fromBuffer(t,e=0){const s=new DataView(t);this.magic="";for(let i=0;i<4;i++)this.magic+=String.fromCharCode(s.getUint8(e+i));e+=4,this.majorVersion=s.getUint32(e,!0),e+=4,this.minorVersion=s.getUint32(e,!0),e+=4,this.size=s.getUint32(e,!0),e+=4}toBuffer(t,e=0){const s=new DataView(t);for(let i=0;i<4;i++)s.setUint8(e+i,this.magic.charCodeAt(i));e+=4,s.setUint32(e,this.majorVersion,!0),e+=4,s.setUint32(e,this.minorVersion,!0),e+=4,s.setUint32(e,this.size,!0),e+=4}bufferSize(){return 16}}class Ws{constructor(t,e){this.connectionId=0,this.channelType=0,this.channelId=0,this.commonCaps=[],this.channelCaps=[],t!==void 0&&this.fromBuffer(t,e)}fromBuffer(t,e=0){const s=e,i=new DataView(t);this.connectionId=i.getUint32(e,!0),e+=4,this.channelType=i.getUint8(e),e++,this.channelId=i.getUint8(e),e++;const n=i.getUint32(e,!0);e+=4;const o=i.getUint32(e,!0);e+=4;const h=i.getUint32(e,!0);e+=4,e=s+h,this.commonCaps=[];for(let u=0;u<n;u++)this.commonCaps.unshift(i.getUint32(e,!0)),e+=4;this.channelCaps=[];for(let u=0;u<o;u++)this.channelCaps.unshift(i.getUint32(e,!0)),e+=4}toBuffer(t,e=0){const s=e,i=new DataView(t);i.setUint32(e,this.connectionId,!0),e+=4,i.setUint8(e,this.channelType),e++,i.setUint8(e,this.channelId),e++,i.setUint32(e,this.commonCaps.length,!0),e+=4,i.setUint32(e,this.channelCaps.length,!0),e+=4,i.setUint32(e,e-s+4,!0),e+=4;for(let n=0;n<this.commonCaps.length;n++)i.setUint32(e,this.commonCaps[n]??0,!0),e+=4;for(let n=0;n<this.channelCaps.length;n++)i.setUint32(e,this.channelCaps[n]??0,!0),e+=4}bufferSize(){return 18+4*this.commonCaps.length+4*this.channelCaps.length}}class Hs{constructor(t,e){this.error=0,this.pubKeyDer=null,this.commonCaps=[],this.channelCaps=[],t!==void 0&&this.fromBuffer(t,e)}fromBuffer(t,e=0){const s=e,i=new DataView(t);this.error=i.getUint32(e,!0),e+=4,this.pubKeyDer=t.slice(e,e+ft),e+=ft;const n=i.getUint32(e,!0);e+=4;const o=i.getUint32(e,!0);e+=4;const h=i.getUint32(e,!0);e+=4,e=s+h,this.commonCaps=[];for(let u=0;u<n;u++)this.commonCaps.unshift(i.getUint32(e,!0)),e+=4;this.channelCaps=[];for(let u=0;u<o;u++)this.channelCaps.unshift(i.getUint32(e,!0)),e+=4}}class zs{constructor(){this.authMechanism=0,this.encryptedData=null}toBuffer(t,e=0){const s=new DataView(t);s.setUint32(e,this.authMechanism,!0),e+=4;const i=dt/8;for(let n=0;n<i;n++)this.encryptedData&&n<this.encryptedData.length?s.setUint8(e,this.encryptedData[n]??0):s.setUint8(e,0),e++}bufferSize(){return 4+dt/8}}class Wt{constructor(t,e){this.authCode=0,t!==void 0&&this.fromBuffer(t,e)}fromBuffer(t,e=0){const s=new DataView(t);this.authCode=s.getUint32(e,!0),e+=4}bufferSize(){return 4}}class z{constructor(t,e){this.type=0,this.size=0,this.data=void 0,t!==void 0&&this.fromBuffer(t,e)}fromBuffer(t,e=0){const s=new DataView(t);this.type=s.getUint16(e,!0),e+=2,this.size=s.getUint32(e,!0),e+=4,t.byteLength>e&&(this.data=t.slice(e))}toBuffer(t,e=0){const s=new DataView(t);if(s.setUint16(e,this.type,!0),e+=2,s.setUint32(e,this.data?this.data.byteLength:0,!0),e+=4,this.data&&this.data.byteLength>0){const i=new Uint8Array(this.data),n=new Uint8Array(t);for(let o=0;o<i.length;o++,e++)n[e]=i[o]??0}}buildMsg(t,e){this.type=t,this.size=e.bufferSize(),this.data=new ArrayBuffer(this.size),e.toBuffer(this.data)}bufferSize(){return this.data?6+this.data.byteLength:6}}class Xs{constructor(t,e){this.numOfChannels=0,this.channels=[],t!==void 0&&this.fromBuffer(t,e)}fromBuffer(t,e=0){const s=new DataView(t);this.numOfChannels=s.getUint32(e,!0),e+=4,this.channels=[];for(let i=0;i<this.numOfChannels;i++){const n=new Fs;e=n.fromDataView(s,e,t),this.channels.push(n)}}}function Ot(r){const t=r[0];return t===void 0?!1:(t>>Q.CLIPBOARD_SELECTION&1)!==0}class qs{constructor(t,e){this.hasClipboardSelection=Ot(e),this.type=t}toBuffer(t,e=0){const s=new DataView(t);this.hasClipboardSelection&&(s.setUint32(e,0,!0),e+=4),s.setUint32(e,this.type,!0),e+=4}bufferSize(){return this.hasClipboardSelection?8:4}}class Qs{constructor(t,e){this.hasClipboardSelection=Ot(e);const s=new DataView(t.data);let i=this.hasClipboardSelection?4:0;this.type=s.getUint32(i,!0),i+=4,this.payload=t.data.slice(i)}getText(){return new TextDecoder("utf-8").decode(this.payload)}}class Zs{constructor(t,e){this.hasClipboardSelection=Ot(e),this.type=t}toBuffer(t,e=0){const s=new DataView(t);this.hasClipboardSelection&&(s.setUint32(e,0,!0),e+=4),s.setUint32(e,this.type,!0),e+=4}bufferSize(){return this.hasClipboardSelection?8:4}}class js{constructor(t,e,s){this.hasClipboardSelection=Ot(s),this.type=t,this.text=e}toBuffer(t,e=0){const s=new DataView(t);this.hasClipboardSelection&&(s.setUint32(e,0,!0),e+=4),s.setUint32(e,this.type,!0),e+=4;const i=new TextEncoder().encode(this.text);new Uint8Array(t,e,i.byteLength).set(i),e+=i.byteLength}bufferSize(){const t=new TextEncoder().encode(this.text).byteLength;return(this.hasClipboardSelection?8:4)+t}}class Js{constructor(t,e){this.sessionId=0,this.displayChannelsHint=0,this.supportedMouseModes=0,this.currentMouseMode=0,this.agentConnected=0,this.agentTokens=0,this.multiMediaTime=0,this.ramHint=0,this.fromBuffer(t,e)}fromBuffer(t,e=0){const s=new DataView(t);this.sessionId=s.getUint32(e,!0),e+=4,this.displayChannelsHint=s.getUint32(e,!0),e+=4,this.supportedMouseModes=s.getUint32(e,!0),e+=4,this.currentMouseMode=s.getUint32(e,!0),e+=4,this.agentConnected=s.getUint32(e,!0),e+=4,this.agentTokens=s.getUint32(e,!0),e+=4,this.multiMediaTime=s.getUint32(e,!0),e+=4,this.ramHint=s.getUint32(e,!0),e+=4}}class $s{constructor(t,e){this.supportedModes=0,this.currentMode=0,this.fromBuffer(t,e)}fromBuffer(t,e=0){const s=new DataView(t);this.supportedModes=s.getUint16(e,!0),e+=2,this.currentMode=s.getUint16(e,!0),e+=2}}class ei{constructor(t,e){this.protocol=0,this.type=0,this.opaque=0n,this.size=0,this.data=void 0,this.fromBuffer(t,e)}fromBuffer(t,e=0){const s=new DataView(t);this.protocol=s.getUint32(e,!0),e+=4,this.type=s.getUint32(e,!0),e+=4,this.opaque=s.getBigUint64(e,!0),e+=8,this.size=s.getUint32(e,!0),e+=4,t.byteLength>e&&(this.data=t.slice(e))}}class Ht{constructor(t,e){this.numTokens=0,this.fromBuffer(t,e)}fromBuffer(t,e=0){const s=new DataView(t);this.numTokens=s.getUint32(e,!0),e+=4}}class ti{constructor(t,e){this.generation=0,this.window=0,this.fromBuffer(t,e)}fromBuffer(t,e=0){const s=new DataView(t);this.generation=s.getUint32(e,!0),e+=4,this.window=s.getUint32(e,!0),e+=4}}class si{constructor(t){this.generation=t.generation}toBuffer(t,e=0){new DataView(t).setUint32(e,this.generation,!0),e+=4}bufferSize(){return 4}}class ii{constructor(t){this.mode=t}toBuffer(t,e=0){new DataView(t).setUint16(e,this.mode,!0),e+=2}bufferSize(){return 2}}class ri{constructor(t){this.numTokens=t}toBuffer(t,e=0){new DataView(t).setUint32(e,this.numTokens,!0),e+=4}bufferSize(){return 4}}class ni{constructor(t,e){this.opaque=0n,this.protocol=is,this.type=t,this.size=e.bufferSize(),this.data=e}toBuffer(t,e=0){const s=new DataView(t);s.setUint32(e,this.protocol,!0),e+=4,s.setUint32(e,this.type,!0),e+=4,s.setBigUint64(e,this.opaque,!0),e+=8,s.setUint32(e,this.size,!0),e+=4,this.data.toBuffer(t,e)}bufferSize(){return 20+this.data.bufferSize()}}class zt{constructor(t,e){this.request=0,this.caps=0,typeof t=="number"&&e!==void 0?(this.request=t,this.caps=e):t instanceof ArrayBuffer&&this.fromBuffer(t)}toBuffer(t,e=0){const s=new DataView(t);s.setUint32(e,this.request,!0),e+=4,s.setUint32(e,this.caps,!0),e+=4}fromBuffer(t,e=0){const s=new DataView(t);return this.request=s.getUint32(e,!0),e+=4,this.caps=s.getUint32(e,!0),e+=4,e}bufferSize(){return 8}}class oi{constructor(t,e,s,i,n,o){this.numMon=1,this.flags=t,this.width=e,this.height=s,this.depth=i,this.x=n,this.y=o}toBuffer(t,e=0){const s=new DataView(t);s.setUint32(e,this.numMon,!0),e+=4,s.setUint32(e,this.flags,!0),e+=4,s.setUint32(e,this.height,!0),e+=4,s.setUint32(e,this.width,!0),e+=4,s.setUint32(e,this.depth,!0),e+=4,s.setUint32(e,this.x,!0),e+=4,s.setUint32(e,this.y,!0),e+=4}bufferSize(){return 28}}class Xt{constructor(t,e){this.id=0,this.result=0,typeof t=="number"&&e!==void 0?(this.id=t,this.result=e):t instanceof ArrayBuffer&&this.fromBuffer(t)}toBuffer(t,e=0){const s=new DataView(t);s.setUint32(e,this.id,!0),e+=4,s.setUint32(e,this.result,!0),e+=4}fromBuffer(t,e=0){const s=new DataView(t);return this.id=s.getUint32(e,!0),e+=4,this.result=s.getUint32(e,!0),e+=4,e}bufferSize(){return 8}}class ai{constructor(t,e,s){this.id=t,this.string=`[vdagent-file-xfer]
|
|
2
|
+
name=`+e+`
|
|
3
|
+
size=`+s+`
|
|
4
|
+
`}toBuffer(t,e=0){const s=new DataView(t);s.setUint32(e,this.id,!0),e+=4;for(let i=0;i<this.string.length;i++,e++)s.setUint8(e,this.string.charCodeAt(i))}bufferSize(){return 4+this.string.length+1}}class ci{constructor(t,e,s){this.id=t,this.size=e,this.data=s}toBuffer(t,e=0){const s=new DataView(t);if(s.setUint32(e,this.id,!0),e+=4,s.setBigUint64(e,BigInt(this.size),!0),e+=8,this.data&&this.data.byteLength>0){const i=new Uint8Array(this.data),n=new Uint8Array(t);for(let o=0;o<i.length;o++,e++)n[e]=i[o]??0}}bufferSize(){return 12+this.size}}class hi{constructor(t,e){this.timeStamp=0n,this.severity=0,this.visibility=0,this.what=0,this.messageLen=0,this.message="",this.fromBuffer(t,e)}fromBuffer(t,e=0){const s=new DataView(t);this.timeStamp=s.getBigUint64(e,!0),e+=8,this.severity=s.getUint32(e,!0),e+=4,this.visibility=s.getUint32(e,!0),e+=4,this.what=s.getUint32(e,!0),e+=4,this.messageLen=s.getUint32(e,!0),e+=4,this.message="";for(let i=0;i<this.messageLen;i++){const n=s.getUint8(e);e++,this.message+=String.fromCharCode(n)}}}class ui{constructor(){this.pixmapCacheId=1,this.glzDictionaryId=0,this.pixmapCacheSize=10*1024*1024,this.glzDictionaryWindowSize=0}toBuffer(t,e=0){const s=new DataView(t);s.setUint8(e,this.pixmapCacheId),e++,s.setBigUint64(e,BigInt(this.pixmapCacheSize),!0),e+=8,s.setUint8(e,this.glzDictionaryId),e++,s.setUint32(e,this.glzDictionaryWindowSize,!0),e+=4}bufferSize(){return 14}}class Ke{constructor(){this.surfaceId=0,this.box=new Ce,this.clip=new Ve}fromDataView(t,e,s){return this.surfaceId=t.getUint32(e,!0),e+=4,this.box=new Ce,e=this.box.fromDataView(t,e,s),this.clip=new Ve,this.clip.fromDataView(t,e,s)}}class li{constructor(t,e){this.base=new Ke,this.data=new kt,this.fromBuffer(t,e)}fromBuffer(t,e=0){const s=new DataView(t);this.base=new Ke,e=this.base.fromDataView(s,e,t),this.data=new kt,this.data.fromDataView(s,e,t)}}class di{constructor(t,e){this.base=new Ke,this.data=new Vt,this.fromBuffer(t,e)}fromBuffer(t,e=0){const s=new DataView(t);this.base=new Ke,e=this.base.fromDataView(s,e,t),this.data=new Vt,this.data.fromDataView(s,e,t)}}class fi{constructor(t,e){this.base=new Ke,this.srcPos=new ke,this.fromBuffer(t,e)}fromBuffer(t,e=0){const s=new DataView(t);this.base=new Ke,e=this.base.fromDataView(s,e,t),this.srcPos=new ke,this.srcPos.fromDataView(s,e,t)}}class Ei{constructor(t,e){this.surface=new xt,this.fromBuffer(t,e)}fromBuffer(t,e=0){const s=new DataView(t);this.surface=new xt,this.surface.fromDataView(s,e,t)}}class _i{constructor(t,e){this.surfaceId=0,this.fromBuffer(t,e)}fromBuffer(t,e=0){const s=new DataView(t);this.surfaceId=s.getUint32(e,!0),e+=4}}class Si{constructor(t,e){this.keyboardModifiers=0,this.fromBuffer(t,e)}fromBuffer(t,e=0){const s=new DataView(t);return this.keyboardModifiers=s.getUint16(e,!0),e+=2,e}}class pi{constructor(t,e){this.keyboardModifiers=0,this.fromBuffer(t,e)}fromBuffer(t,e=0){const s=new DataView(t);return this.keyboardModifiers=s.getUint16(e,!0),e+=2,e}}class Ai{constructor(t,e){this.position=new st,this.trailLength=0,this.trailFrequency=0,this.visible=0,this.cursor=new rt,this.fromBuffer(t,e)}fromBuffer(t,e=0){const s=new DataView(t);this.position=new st,e=this.position.fromDataView(s,e,t),this.trailLength=s.getUint16(e,!0),e+=2,this.trailFrequency=s.getUint16(e,!0),e+=2,this.visible=s.getUint8(e),e++,this.cursor=new rt,this.cursor.fromDataView(s,e,t)}}class Ci{constructor(t,e){this.time=0,this.data=void 0,this.fromBuffer(t,e)}fromBuffer(t,e=0){const s=new DataView(t);return this.time=s.getUint32(e,!0),e+=4,t.byteLength>e&&(this.data=t.slice(e),e+=this.data.byteLength),e}}class Ii{constructor(t,e){this.time=0,this.mode=0,this.data=void 0,this.fromBuffer(t,e)}fromBuffer(t,e=0){const s=new DataView(t);return this.time=s.getUint32(e,!0),e+=4,this.mode=s.getUint16(e,!0),e+=2,t.byteLength>e&&(this.data=t.slice(e),e+=this.data.byteLength),e}}class gi{constructor(t,e){this.channels=0,this.format=0,this.frequency=0,this.time=0,this.fromBuffer(t,e)}fromBuffer(t,e=0){const s=new DataView(t);return this.channels=s.getUint32(e,!0),e+=4,this.format=s.getUint16(e,!0),e+=2,this.frequency=s.getUint32(e,!0),e+=4,this.time=s.getUint32(e,!0),e+=4,e}}class mi{constructor(t,e){this.position=new st,this.visible=0,this.cursor=new rt,this.fromBuffer(t,e)}fromBuffer(t,e=0){const s=new DataView(t);this.position=new st,e=this.position.fromDataView(s,e,t),this.visible=s.getUint8(e),e++,this.cursor=new rt,this.cursor.fromDataView(s,e,t)}}class rs{constructor(t=0,e=0,s=0,i=0){this.x=t,this.y=e,this.buttonsState=s,this.displayId=i}toBuffer(t,e=0){const s=new DataView(t);s.setUint32(e,this.x,!0),e+=4,s.setUint32(e,this.y,!0),e+=4,s.setUint16(e,this.buttonsState,!0),e+=2,s.setUint8(e,this.displayId),e+=1}bufferSize(){return 11}}class Ti{constructor(t=0,e=0,s=0,i=0){this.x=t,this.y=e,this.buttonsState=s,this.displayId=i}toBuffer(t,e=0){const s=new DataView(t);s.setUint32(e,this.x,!0),e+=4,s.setUint32(e,this.y,!0),e+=4,s.setUint16(e,this.buttonsState,!0),e+=2,s.setUint8(e,this.displayId),e+=1}bufferSize(){return 11}}class pt{constructor(t=ae.LEFT,e=Re.LEFT){this.button=t,this.buttonsState=e}toBuffer(t,e=0){const s=new DataView(t);s.setUint8(e,this.button),e++,s.setUint16(e,this.buttonsState,!0),e+=2}bufferSize(){return 3}}class At{constructor(t=ae.LEFT,e=0){this.button=t,this.buttonsState=e}toBuffer(t,e=0){const s=new DataView(t);s.setUint8(e,this.button),e++,s.setUint16(e,this.buttonsState,!0),e+=2}bufferSize(){return 3}}class Je{constructor(t=0){this.code=t}toBuffer(t,e=0){new DataView(t).setUint32(e,this.code,!0),e+=4}bufferSize(){return 4}}class $e{constructor(t=0){this.code=t}toBuffer(t,e=0){new DataView(t).setUint32(e,this.code,!0),e+=4}bufferSize(){return 4}}class Mi{constructor(t,e){this.surfaceId=0,this.id=0,this.flags=0,this.codecType=0,this.stamp=0n,this.streamWidth=0,this.streamHeight=0,this.srcWidth=0,this.srcHeight=0,this.dest=new Ce,this.clip=new Ve,this.fromBuffer(t,e)}fromBuffer(t,e=0){const s=new DataView(t);this.surfaceId=s.getUint32(e,!0),e+=4,this.id=s.getUint32(e,!0),e+=4,this.flags=s.getUint8(e),e+=1,this.codecType=s.getUint8(e),e+=1,this.stamp=s.getBigUint64(e,!0),e+=8,this.streamWidth=s.getUint32(e,!0),e+=4,this.streamHeight=s.getUint32(e,!0),e+=4,this.srcWidth=s.getUint32(e,!0),e+=4,this.srcHeight=s.getUint32(e,!0),e+=4,this.dest=new Ce,e=this.dest.fromDataView(s,e,t),this.clip=new Ve,this.clip.fromDataView(s,e,t)}}class nt{constructor(){this.id=0,this.multiMediaTime=0}fromDataView(t,e,s){return this.id=t.getUint32(e,!0),e+=4,this.multiMediaTime=t.getUint32(e,!0),e+=4,e}}class Di{constructor(t,e){this.base=new nt,this.dataSize=0,this.data=new Uint8Array(0),this.fromBuffer(t,e)}fromBuffer(t,e=0){const s=new DataView(t),i=new Uint8Array(t);this.base=new nt,e=this.base.fromDataView(s,e,t),this.dataSize=s.getUint32(e,!0),e+=4,this.data=i.subarray(e,e+this.dataSize)}}class qt{constructor(t,e){this.base=new nt,this.width=0,this.height=0,this.dest=new Ce,this.dataSize=0,this.data=new Uint8Array(0),this.fromBuffer(t,e)}fromBuffer(t,e=0){const s=new DataView(t),i=new Uint8Array(t);this.base=new nt,e=this.base.fromDataView(s,e,t),this.width=s.getUint32(e,!0),e+=4,this.height=s.getUint32(e,!0),e+=4,this.dest=new Ce,e=this.dest.fromDataView(s,e,t),this.dataSize=s.getUint32(e,!0),e+=4,this.data=i.subarray(e,e+this.dataSize)}}class wi{constructor(t,e){this.id=0,this.clip=new Ve,this.fromBuffer(t,e)}fromBuffer(t,e=0){const s=new DataView(t);this.id=s.getUint32(e,!0),e+=4,this.clip=new Ve,this.clip.fromDataView(s,e,t)}}class Pi{constructor(t,e){this.id=0,this.fromBuffer(t,e)}fromBuffer(t,e=0){const s=new DataView(t);this.id=s.getUint32(e,!0),e+=4}}class Ri{constructor(t,e){this.streamId=0,this.uniqueId=0,this.maxWindowSize=0,this.timeoutMs=0,this.fromBuffer(t,e)}fromBuffer(t,e=0){const s=new DataView(t);this.streamId=s.getUint32(e,!0),e+=4,this.uniqueId=s.getUint32(e,!0),e+=4,this.maxWindowSize=s.getUint32(e,!0),e+=4,this.timeoutMs=s.getUint32(e,!0),e+=4}}class bi{constructor(t,e){this.startFrameMmTime=0,this.endFrameMmTime=0,this.numFrames=0,this.numDrops=0,this.lastFrameDelay=0,this.audioDelay=-1,this.streamId=t,this.uniqueId=e}toBuffer(t,e=0){const s=new DataView(t);s.setUint32(e,this.streamId,!0),e+=4,s.setUint32(e,this.uniqueId,!0),e+=4,s.setUint32(e,this.startFrameMmTime,!0),e+=4,s.setUint32(e,this.endFrameMmTime,!0),e+=4,s.setUint32(e,this.numFrames,!0),e+=4,s.setUint32(e,this.numDrops,!0),e+=4,s.setUint32(e,this.lastFrameDelay,!0),e+=4,s.setInt32(e,this.audioDelay,!0),e+=4}bufferSize(){return 8*4}}class yi{constructor(t,e){this.count=0,this.resources=[],this.fromBuffer(t,e)}fromBuffer(t,e=0){const s=new DataView(t);this.count=s.getUint16(e,!0),e+=2,this.resources=[];for(let i=0;i<this.count;i++){const n=s.getUint8(e);e++;const o=s.getBigUint64(e,!0);e+=8,this.resources.push({type:n,id:o})}}}class Ni{constructor(t,e){this.opened=0,this.name=new ArrayBuffer(0),this.fromBuffer(t,e)}fromBuffer(t,e=0){const s=new DataView(t),i=s.getUint32(e,!0);e+=4;const n=s.getUint32(e,!0);e+=4,this.opened=s.getUint8(e),e+=1,this.name=t.slice(n,n+i-1)}}const c={KEY_Escape:1,KEY_1:2,KEY_2:3,KEY_3:4,KEY_4:5,KEY_5:6,KEY_6:7,KEY_7:8,KEY_8:9,KEY_9:10,KEY_0:11,KEY_Minus:12,KEY_Equal:13,KEY_BackSpace:14,KEY_Tab:15,KEY_Q:16,KEY_W:17,KEY_E:18,KEY_R:19,KEY_T:20,KEY_Y:21,KEY_U:22,KEY_I:23,KEY_O:24,KEY_P:25,KEY_LBrace:26,KEY_RBrace:27,KEY_Enter:28,KEY_LCtrl:29,KEY_A:30,KEY_S:31,KEY_D:32,KEY_F:33,KEY_G:34,KEY_H:35,KEY_J:36,KEY_K:37,KEY_L:38,KEY_SemiColon:39,KEY_Quote:40,KEY_Tilde:41,KEY_ShiftL:42,KEY_BSlash:43,KEY_Z:44,KEY_X:45,KEY_C:46,KEY_V:47,KEY_B:48,KEY_N:49,KEY_M:50,KEY_Comma:51,KEY_Period:52,KEY_Slash:53,KEY_KP_Multiply:55,KEY_Alt:56,KEY_Space:57,KEY_CapsLock:58,KEY_F1:59,KEY_F2:60,KEY_F3:61,KEY_F4:62,KEY_F5:63,KEY_F6:64,KEY_F7:65,KEY_F8:66,KEY_F9:67,KEY_F10:68,KEY_NumLock:69,KEY_ScrollLock:70,KEY_KP_7:71,KEY_KP_8:72,KEY_KP_9:73,KEY_KP_4:75,KEY_KP_5:76,KEY_KP_6:77,KEY_KP_Plus:78,KEY_KP_1:79,KEY_KP_2:80,KEY_KP_3:81,KEY_KP_0:82,KEY_KP_Decimal:83,KEY_SysReqest:84,KEY_F11:87,KEY_F12:88},fr={Escape:1,Digit1:2,Digit2:3,Digit3:4,Digit4:5,Digit5:6,Digit6:7,Digit7:8,Digit8:9,Digit9:10,Digit0:11,Minus:12,Equal:13,Backspace:14,Tab:15,KeyQ:16,KeyW:17,KeyE:18,KeyR:19,KeyT:20,KeyY:21,KeyU:22,KeyI:23,KeyO:24,KeyP:25,BracketLeft:26,BracketRight:27,Enter:28,ControlLeft:29,KeyA:30,KeyS:31,KeyD:32,KeyF:33,KeyG:34,KeyH:35,KeyJ:36,KeyK:37,KeyL:38,Semicolon:39,Quote:40,Backquote:41,ShiftLeft:42,Backslash:43,KeyZ:44,KeyX:45,KeyC:46,KeyV:47,KeyB:48,KeyN:49,KeyM:50,Comma:51,Period:52,Slash:53,ShiftRight:54,NumpadMultiply:55,AltLeft:56,Space:57,CapsLock:58,F1:59,F2:60,F3:61,F4:62,F5:63,F6:64,F7:65,F8:66,F9:67,F10:68,Pause:69,ScrollLock:70,Numpad7:71,Numpad8:72,Numpad9:73,NumpadSubtract:74,Numpad4:75,Numpad5:76,Numpad6:77,NumpadAdd:78,Numpad1:79,Numpad2:80,Numpad3:81,Numpad0:82,NumpadDecimal:83,PrintScreen:84,IntlBackslash:86,F11:87,F12:88,NumpadEqual:89,F13:100,F14:101,F15:102,F16:103,F17:104,F18:105,F19:106,F20:107,F21:108,F22:109,F23:110,KanaMode:112,IntlRo:115,F24:118,Convert:121,NonConvert:123,IntlYen:125,NumpadComma:126,MediaTrackPrevious:4320,MediaTrackNext:6624,NumpadEnter:7392,ControlRight:7648,AudioVolumeMute:8416,LaunchApp2:8672,MediaPlayPause:8928,MediaStop:9440,VolumeDown:12e3,VolumeUp:12512,BrowserHome:13024,NumpadDivide:13792,AltRight:14560,NumLock:17888,Home:18400,ArrowUp:18656,PageUp:18912,ArrowLeft:19424,ArrowRight:19936,End:20448,ArrowDown:20704,PageDown:20960,Insert:21216,Delete:21472,MetaLeft:23520,MetaRight:23776,ContextMenu:24032,Power:24288,BrowserSearch:26080,BrowserFavorites:26336,BrowserRefresh:26592,BrowserStop:26848,BrowserForward:27104,BrowserBack:27360,LaunchApp1:27616,LaunchMail:27872,MediaSelect:28128};let Er=0;const ds="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=",_r={49:c.KEY_1,50:c.KEY_2,51:c.KEY_3,52:c.KEY_4,53:c.KEY_5,54:c.KEY_6,55:c.KEY_7,56:c.KEY_8,57:c.KEY_9,48:c.KEY_0,145:c.KEY_ScrollLock,103:c.KEY_KP_7,104:c.KEY_KP_8,105:c.KEY_KP_9,100:c.KEY_KP_4,101:c.KEY_KP_5,102:c.KEY_KP_6,107:c.KEY_KP_Plus,97:c.KEY_KP_1,98:c.KEY_KP_2,99:c.KEY_KP_3,96:c.KEY_KP_0,109:c.KEY_Minus,110:c.KEY_KP_Decimal,191:c.KEY_Slash,190:c.KEY_Period,188:c.KEY_Comma,220:c.KEY_BSlash,192:c.KEY_Tilde,222:c.KEY_Quote,219:c.KEY_LBrace,221:c.KEY_RBrace,81:c.KEY_Q,87:c.KEY_W,69:c.KEY_E,82:c.KEY_R,84:c.KEY_T,89:c.KEY_Y,85:c.KEY_U,73:c.KEY_I,79:c.KEY_O,80:c.KEY_P,65:c.KEY_A,83:c.KEY_S,68:c.KEY_D,70:c.KEY_F,71:c.KEY_G,72:c.KEY_H,74:c.KEY_J,75:c.KEY_K,76:c.KEY_L,90:c.KEY_Z,88:c.KEY_X,67:c.KEY_C,86:c.KEY_V,66:c.KEY_B,78:c.KEY_N,77:c.KEY_M,32:c.KEY_Space,13:c.KEY_Enter,27:c.KEY_Escape,8:c.KEY_BackSpace,9:c.KEY_Tab,16:c.KEY_ShiftL,17:c.KEY_LCtrl,18:c.KEY_Alt,20:c.KEY_CapsLock,44:c.KEY_SysReqest,144:c.KEY_NumLock,112:c.KEY_F1,113:c.KEY_F2,114:c.KEY_F3,115:c.KEY_F4,116:c.KEY_F5,117:c.KEY_F6,118:c.KEY_F7,119:c.KEY_F8,120:c.KEY_F9,121:c.KEY_F10,122:c.KEY_F11,123:c.KEY_F12,42:99,19:101,111:224|c.KEY_Slash<<8,106:224|c.KEY_KP_Multiply<<8,36:224|c.KEY_KP_7<<8,38:224|c.KEY_KP_8<<8,33:224|c.KEY_KP_9<<8,37:224|c.KEY_KP_4<<8,39:224|c.KEY_KP_6<<8,35:224|c.KEY_KP_1<<8,40:224|c.KEY_KP_2<<8,34:224|c.KEY_KP_3<<8,45:224|c.KEY_KP_0<<8,46:224|c.KEY_KP_Decimal<<8,91:23520,92:23776,93:24032},Sr={173:c.KEY_Minus,61:c.KEY_Equal,59:c.KEY_SemiColon},pr={189:c.KEY_Minus,187:c.KEY_Equal,186:c.KEY_SemiColon};function Li(r,t){const e=fr[t];if(e!==void 0)return e;const s=_r[r];return s!==void 0?s:typeof navigator<"u"&&navigator.userAgent.indexOf("Firefox")!==-1?Sr[r]:pr[r]}function Ar(r,t){const e=Li(r,t);return e===void 0?(typeof alert<"u"&&alert("no map for "+r),0):e}function Cr(r,t){const e=Li(r,t);return e===void 0?0:e<256?e|128:e|32768}function Ir(r){return"[networkState "+r.networkState+"|readyState "+r.readyState+"|error "+r.error+"|seeking "+r.seeking+"|duration "+r.duration+"|paused "+r.paused+"|ended "+r.ended+"|buffered "+gr(r.buffered)+"]"}function gr(r){if(r){const t=r.length;let e="{len "+t;return t>0&&(e+="; start "+r.start(0)+"; end "+r.end(t-1)),e+="}",e}else return"N/A"}class Oi{constructor(t,e){this.needed=0,this.size=0,this.buffers=[],this.savedMsgHeader=void 0,this.owner=t,this.callback=e,this.boundOnMessage=this.onMessage.bind(this),this.owner.ws.binaryType="arraybuffer",this.owner.ws.addEventListener("message",this.boundOnMessage)}request(t){this.needed=t}saveHeader(t){this.savedMsgHeader=t}clearHeader(){this.savedMsgHeader=void 0}cleanup(){this.owner.ws.removeEventListener("message",this.boundOnMessage),this.buffers=[],this.size=0,this.needed=0,this.savedMsgHeader=void 0}onMessage(t){this.inbound(t.data)}inbound(t){if(this.needed===0){this.buffers.push(t),this.size+=t.byteLength;return}for(this.buffers.length===0&&t.byteLength>=this.needed?(t.byteLength>this.needed&&(this.size=t.byteLength-this.needed,this.buffers.push(t.slice(this.needed)),t=t.slice(0,this.needed)),this.callback.call(this.owner,t,this.savedMsgHeader??void 0)):(this.buffers.push(t),this.size+=t.byteLength);this.size>=this.needed&&this.needed>0;){let e=0;const s=new ArrayBuffer(this.needed),i=new Uint8Array(s);for(;e<s.byteLength&&this.buffers.length>0;){const n=this.buffers.shift();if(!n)return;const o=new Uint8Array(n),h=s.byteLength-e;if(o.length<=h)i.set(o,e),e+=o.length,this.size-=o.length;else{const u=o.slice(0,h);i.set(u,e),e+=u.length,this.size-=u.length,this.buffers.unshift(o.slice(h).buffer)}}this.callback.call(this.owner,s,this.savedMsgHeader??void 0)}}}const mr=[26,69,223,163],Tr=[66,134],Mr=[66,247],Dr=[66,242],wr=[66,243],Pr=[66,130],Rr=[66,135],br=[66,133],yr=[24,83,128,103],Ui=[21,73,169,102],fs=[42,215,177],Es=[77,128],_s=[87,65],Nr=[17,77,155,116],Lr=[77,187],Ss=[83,171],ps=[83,172],Bi=[22,84,174,107],Gi=[174],Ct=[215],It=[115,197],gt=[131],mt=[185],Tt=[136],Mt=[85,170],Dt=[156],wt=[109,231],Pt=[85,238],Rt=[170],bt=[86,187],As=[86,170],Cs=[99,162],yt=[134],Or=[224],Is=[154],gs=[176],ms=[186],Ur=[225],Ts=[181],Ms=[159],Ds=[31,67,182,117],ws=[231],Ps=[163],X={CLUSTER_SIMPLEBLOCK_FLAG_KEYFRAME:128,OPUS_FREQUENCY:48e3,OPUS_CHANNELS:2,SPICE_PLAYBACK_CODEC:'audio/webm; codecs="opus"',MAX_CLUSTER_TIME:1e3,EXPECTED_PACKET_DURATION:10,GAP_DETECTION_THRESHOLD:50,SPICE_VP8_CODEC:'video/webm; codecs="vp8"'};function We(r,t,e){const s=128|r;return t.setUint8(e,s),e+1}function N(r,t,e,s){return s=J(r,e,s),s=We(1,e,s),e.setUint8(s,t),s+1}function ot(r,t,e,s){return s=J(r,e,s),s=We(4,e,s),e.setUint32(s,t),s+4}function Qt(r,t,e,s){return s=J(r,e,s),s=We(2,e,s),e.setUint16(s,t),s+2}function Br(r,t,e,s){return s=J(r,e,s),s=We(4,e,s),e.setFloat32(s,t),s+4}function De(r,t,e){t.setUint8(e++,1),t.setUint8(e++,0),t.setUint8(e++,0),t.setUint8(e++,0);const s=r&4294967295;for(let i=24;i>=0;i-=8)t.setUint8(e++,s>>i);return e}function J(r,t,e){for(let s=0;s<r.length;s++)t.setUint8(e+s,r[s]);return e+r.length}function Gr(r,t,e){for(let s=0;s<r.length;s++)t.setUint8(e+s,r.charCodeAt(s));return e+r.length}function xe(r,t,e,s){return s=J(r,e,s),t.length<127?s=We(t.length,e,s):s=De(t.length,e,s),typeof t=="string"?s=Gr(t,e,s):s=J(t,e,s),s}class Kr{constructor(){this.id=mr,this.version=1,this.readVersion=1,this.maxIdLength=4,this.maxSizeLength=8,this.docType="webm",this.docTypeVersion=2,this.docTypeReadVersion=2}toBuffer(t,e=0){const s=new DataView(t);return e=J(this.id,s,e),e=De(31,s,e),e=N(Tr,this.version,s,e),e=N(Mr,this.readVersion,s,e),e=N(Dr,this.maxIdLength,s,e),e=N(wr,this.maxSizeLength,s,e),e=xe(Pr,this.docType,s,e),e=N(Rr,this.docTypeVersion,s,e),e=N(br,this.docTypeReadVersion,s,e),e}bufferSize(){return 39+this.id.length}}class Fr{constructor(){this.id=yr}toBuffer(t,e=0){const s=new DataView(t);return e=J(this.id,s,e),s.setUint8(e++,255),e}bufferSize(){return this.id.length+1}}class vr{constructor(){this.id=Ui,this.timecodeScale=1e6,this.muxingApp="spice",this.writingApp="spice-html5"}toBuffer(t,e=0){const s=new DataView(t);return e=J(this.id,s,e),e=De(this.bufferSize()-8-this.id.length,s,e),e=ot(fs,this.timecodeScale,s,e),e=xe(Es,this.muxingApp,s,e),e=xe(_s,this.writingApp,s,e),e}bufferSize(){return this.id.length+8+fs.length+1+4+Es.length+1+this.muxingApp.length+_s.length+1+this.writingApp.length}}class Ki{constructor(t){this.id=Ur,this.channels=X.OPUS_CHANNELS,this.samplingFrequency=t}toBuffer(t,e=0){const s=new DataView(t);return e=J(this.id,s,e),e=De(this.bufferSize()-8-this.id.length,s,e),e=N(Ms,this.channels,s,e),e=Br(Ts,this.samplingFrequency,s,e),e}bufferSize(){return this.id.length+8+Ts.length+1+4+Ms.length+1+1}}class Fi{constructor(t,e){this.id=Or,this.flagInterlaced=0,this.width=t,this.height=e}toBuffer(t,e=0){const s=new DataView(t);return e=J(this.id,s,e),e=De(this.bufferSize()-8-this.id.length,s,e),e=N(Is,this.flagInterlaced,s,e),e=Qt(gs,this.width,s,e),e=Qt(ms,this.height,s,e),e}bufferSize(){return this.id.length+8+Is.length+1+1+gs.length+1+2+ms.length+1+2}}class Rs{constructor(t,e){this.id=Lr,this.seekid=t,this.pos=e}toBuffer(t,e=0){const s=new DataView(t);return e=J(this.id,s,e),e=We(this.bufferSize()-1-this.id.length,s,e),e=xe(Ss,this.seekid,s,e),e=Qt(ps,this.pos,s,e),e}bufferSize(){return this.id.length+1+Ss.length+1+this.seekid.length+ps.length+1+2}}class Yr{constructor(t,e){this.id=Nr,this.info=new Rs(Ui,t),this.track=new Rs(Bi,e)}toBuffer(t,e=0){const s=new DataView(t);return e=J(this.id,s,e),e=De(this.bufferSize()-8-this.id.length,s,e),e=this.info.toBuffer(t,e),e=this.track.toBuffer(t,e),e}bufferSize(){return this.id.length+8+this.info.bufferSize()+this.track.bufferSize()}}class vi{constructor(){this.id=Gi,this.number=1,this.uid=2,this.type=2,this.flagEnabled=1,this.flagDefault=1,this.flagForced=1,this.flagLacing=0,this.minCache=0,this.maxBlockAdditionId=0,this.codecDecodeAll=0,this.seekPreRoll=0,this.codecDelay=8e7,this.codecId="A_OPUS",this.codecPrivate=[79,112,117,115,72,101,97,100,1,X.OPUS_CHANNELS,0,15,128,187,0,0,0,0,0],this.audio=new Ki(X.OPUS_FREQUENCY)}toBuffer(t,e=0){const s=new DataView(t);return e=J(this.id,s,e),e=De(this.bufferSize()-8-this.id.length,s,e),e=N(Ct,this.number,s,e),e=N(It,this.uid,s,e),e=N(mt,this.flagEnabled,s,e),e=N(Tt,this.flagDefault,s,e),e=N(Mt,this.flagForced,s,e),e=N(Dt,this.flagLacing,s,e),e=xe(yt,this.codecId,s,e),e=N(wt,this.minCache,s,e),e=N(Pt,this.maxBlockAdditionId,s,e),e=N(Rt,this.codecDecodeAll,s,e),e=ot(As,this.codecDelay,s,e),e=ot(bt,this.seekPreRoll,s,e),e=N(gt,this.type,s,e),e=xe(Cs,this.codecPrivate,s,e),e=this.audio.toBuffer(t,e),e}bufferSize(){return this.id.length+8+Ct.length+1+1+It.length+1+1+gt.length+1+1+mt.length+1+1+Tt.length+1+1+Mt.length+1+1+Dt.length+1+1+wt.length+1+1+Pt.length+1+1+Rt.length+1+1+bt.length+1+4+As.length+1+4+yt.length+this.codecId.length+1+Cs.length+1+this.codecPrivate.length+this.audio.bufferSize()}}class Yi{constructor(t,e){this.id=Gi,this.number=1,this.uid=1,this.type=1,this.flagEnabled=1,this.flagDefault=1,this.flagForced=1,this.flagLacing=1,this.minCache=0,this.maxBlockAdditionId=0,this.codecId="V_VP8",this.codecDecodeAll=1,this.seekPreRoll=0,this.video=new Fi(t,e)}toBuffer(t,e=0){const s=new DataView(t);return e=J(this.id,s,e),e=De(this.bufferSize()-8-this.id.length,s,e),e=N(Ct,this.number,s,e),e=N(It,this.uid,s,e),e=N(mt,this.flagEnabled,s,e),e=N(Tt,this.flagDefault,s,e),e=N(Mt,this.flagForced,s,e),e=N(Dt,this.flagLacing,s,e),e=xe(yt,this.codecId,s,e),e=N(wt,this.minCache,s,e),e=N(Pt,this.maxBlockAdditionId,s,e),e=N(Rt,this.codecDecodeAll,s,e),e=ot(bt,this.seekPreRoll,s,e),e=N(gt,this.type,s,e),e=this.video.toBuffer(t,e),e}bufferSize(){return this.id.length+8+Ct.length+1+1+It.length+1+1+mt.length+1+1+Tt.length+1+1+Mt.length+1+1+Dt.length+1+1+yt.length+this.codecId.length+1+wt.length+1+1+Pt.length+1+1+Rt.length+1+1+bt.length+1+4+gt.length+1+1+this.video.bufferSize()}}class ns{constructor(t){this.id=Bi,this.trackEntry=t}toBuffer(t,e=0){const s=new DataView(t);return e=J(this.id,s,e),e=De(this.bufferSize()-8-this.id.length,s,e),e=this.trackEntry.toBuffer(t,e),e}bufferSize(){return this.id.length+8+this.trackEntry.bufferSize()}}class os{constructor(t){this.timecode=t}toBuffer(t,e=0){const s=new DataView(t);return e=J(Ds,s,e),s.setUint8(e++,255),e=ot(ws,this.timecode,s,e),e}bufferSize(){return Ds.length+1+ws.length+1+4}}class as{constructor(t,e,s){this.timecode=t,this.data=e,this.keyframe=s}toBuffer(t,e=0){const s=new DataView(t);e=J(Ps,s,e),e=De(this.data.byteLength+4,s,e),e=We(1,s,e),s.setUint16(e,this.timecode),e+=2,s.setUint8(e,this.keyframe?X.CLUSTER_SIMPLEBLOCK_FLAG_KEYFRAME:0),e+=1;const i=new Uint8Array(this.data);return new Uint8Array(t,e,this.data.byteLength).set(i),e+=this.data.byteLength,e}bufferSize(){return Ps.length+8+1+2+1+this.data.byteLength}}class cs{constructor(){this.ebml=new Kr,this.segment=new Fr,this.seekHead=new Yr(0,0),this.seekHead.info.pos=this.segment.bufferSize()+this.seekHead.bufferSize(),this.info=new vr,this.seekHead.track.pos=this.seekHead.info.pos+this.info.bufferSize()}toBuffer(t,e=0){return e=this.ebml.toBuffer(t,e),e=this.segment.toBuffer(t,e),e=this.info.toBuffer(t,e),e}bufferSize(){return this.ebml.bufferSize()+this.segment.bufferSize()+this.info.bufferSize()}}async function Vi(r,t){const e=await crypto.subtle.importKey("spki",r,{name:"RSA-OAEP",hash:"SHA-1"},!1,["encrypt"]),s=new Uint8Array(t.length+1);for(let h=0;h<t.length;h++)s[h]=t.charCodeAt(h)&255;s[t.length]=0;const i=await crypto.subtle.encrypt({name:"RSA-OAEP"},e,s),n=new Uint8Array(i),o=new Array(n.length);for(let h=0;h<n.length;h++)o[h]=n[h];return o}const x={CONNECTING:"connecting",START:"start",LINK:"link",TICKET:"ticket",READY:"ready",CLOSING:"closing",ERROR:"error"};class Ne{constructor(t){if(this.state=x.CONNECTING,this.messagesSent=0,this.ackWindow=0,this.warnings={},!t.uri)throw new Error("You must specify a uri");if(this.connectionId=t.connectionId??0,this.type=t.type??p.MAIN,this.chanId=t.chanId??0,t.parent!==void 0?(this.parent=t.parent,this.messageId=t.parent.messageId,this.password=t.parent.password):this.password=t.password??"",t.screenId!==void 0&&(this.screenId=t.screenId),t.dumpId!==void 0&&(this.dumpId=t.dumpId),t.messageId!==void 0&&(this.messageId=t.messageId),t.password!==void 0&&(this.password=t.password),t.onerror!==void 0&&(this.onerror=t.onerror),t.onsuccess!==void 0&&(this.onsuccess=t.onsuccess),t.onagent!==void 0&&(this.onagent=t.onagent),this.ws=new WebSocket(t.uri,"binary"),!this.ws.binaryType)throw new Error("WebSocket doesn't support binaryType. Try a different browser.");if(this.wireReader=new Oi(this,this.processInbound.bind(this)),this.ws.addEventListener("open",()=>{this.sendHdr(),this.wireReader.request(new ut().bufferSize()),this.state=x.START}),this.ws.addEventListener("error",e=>{const s=e.target;s&&"url"in s&&this.logErr("WebSocket error: Can't connect to websocket on URL: "+s.url),this.reportError(new Error("WebSocket error"))}),this.ws.addEventListener("close",()=>{if(this.state!==x.CLOSING&&this.state!==x.ERROR&&this.onerror!==void 0){let e;this.state===x.CONNECTING?e=new Error("Connection refused."):this.state===x.START||this.state===x.LINK?e=new Error("Unexpected protocol mismatch."):this.state===x.TICKET?e=new Error("Bad password."):e=new Error("Unexpected close while "+this.state),this.onerror(e),this.logErr(e.toString())}}),this.ws.readyState===2||this.ws.readyState===3)throw new Error("Unable to connect to "+t.uri);this.timeout=setTimeout(()=>this.handleTimeout(),ts)}sendHdr(){const t=new ut,e=new Ws;if(e.connectionId=this.connectionId,e.channelType=this.type,e.channelId=this.chanId,e.commonCaps.push(1<<Be.PROTOCOL_AUTH_SELECTION|1<<Be.MINI_HEADER),e.channelType===p.PLAYBACK){let i=0;typeof MediaSource<"u"&&MediaSource.isTypeSupported(X.SPICE_PLAYBACK_CODEC)&&(i|=1<<He.OPUS),e.channelCaps.push(i)}else if(e.channelType===p.MAIN)e.channelCaps.push(1<<ze.AGENT_CONNECTED_TOKENS);else if(e.channelType===p.DISPLAY){let i=1<<$.SIZED_STREAM|1<<$.STREAM_REPORT|1<<$.MULTI_CODEC|1<<$.CODEC_MJPEG;typeof MediaSource<"u"&&MediaSource.isTypeSupported(X.SPICE_VP8_CODEC)&&(i|=1<<$.CODEC_VP8),e.channelCaps.push(i)}t.size=e.bufferSize();const s=new ArrayBuffer(t.bufferSize()+e.bufferSize());t.toBuffer(s),e.toBuffer(s,t.bufferSize()),this.ws.send(s)}sendTicket(t){const e=new zs;e.authMechanism=Be.AUTH_SPICE,e.encryptedData=t;const s=new ArrayBuffer(e.bufferSize());e.toBuffer(s),this.ws.send(s)}sendMsg(t){const e=new ArrayBuffer(t.bufferSize());t.toBuffer(e),this.messagesSent++,this.ws.send(e)}processInbound(t,e){if(this.state===x.READY)if(e===void 0){const s=new z(t);s.type>500,s.size===0?(this.processMessage(s),this.wireReader.request(new z().bufferSize())):(this.wireReader.request(s.size),this.wireReader.saveHeader(s))}else e.data=t,this.processMessage(e),this.wireReader.request(new z().bufferSize()),this.wireReader.clearHeader();else if(this.state===x.START)if(this.replyHdr=new ut(t),this.replyHdr.magic!==Nt){this.state=x.ERROR;const s=new Error("Error: magic mismatch: "+this.replyHdr.magic);this.reportError(s)}else this.wireReader.request(this.replyHdr.size),this.state=x.LINK;else if(this.state===x.LINK)if(this.replyLink=new Hs(t),this.replyLink.error){this.state=x.ERROR;const s=new Error("Error: reply link error "+this.replyLink.error);this.reportError(s)}else{if(!this.replyLink.pubKeyDer){this.state=x.ERROR,this.reportError(new Error("Error: no public key in server reply"));return}Vi(this.replyLink.pubKeyDer,this.password).then(s=>{this.sendTicket(s),this.state=x.TICKET,this.wireReader.request(new Wt().bufferSize())}).catch(s=>{this.state=x.ERROR;const i=s instanceof Error?s.message:String(s);this.reportError(new Error("RSA encryption failed: "+i))})}else if(this.state===x.TICKET)if(this.authReply=new Wt(t),this.authReply.authCode===ue.OK){if(this.type===p.DISPLAY){const s=new ui,i=new z;i.buildMsg(et.INIT,s),this.sendMsg(i)}this.state=x.READY,this.wireReader.request(new z().bufferSize()),this.timeout!==void 0&&(clearTimeout(this.timeout),this.timeout=void 0)}else this.state=x.ERROR,this.authReply.authCode===ue.PERMISSION_DENIED?this.reportError(new Error("Permission denied.")):this.reportError(new Error("Unexpected link error "+this.authReply.authCode))}processCommonMessages(t){if(t.type===pe.SET_ACK){if(!t.data)return this.logWarn("SET_ACK message with no data"),!0;const e=new ti(t.data);this.ackWindow=e.window,this.msgsUntilAck=this.ackWindow;const s=new si(e),i=new z;return i.buildMsg(Te.ACK_SYNC,s),this.sendMsg(i),!0}if(t.type===pe.PING){const e=new z;return e.type=Te.PONG,t.data&&(e.data=t.data.slice(0,12)),e.size=e.bufferSize(),this.sendMsg(e),!0}if(t.type===pe.NOTIFY){if(!t.data)return this.logWarn("NOTIFY message with no data"),!0;const e=new hi(t.data);return e.severity===Ze.ERROR?this.logErr(e.message):e.severity===Ze.WARN?this.logWarn(e.message):this.logInfo(e.message),!0}return!1}processMessage(t){const e=Date.now();let s=this.processCommonMessages(t);if(s||(s=this.processChannelMessage(t),s||this.logWarn(this.channelType()+": Unknown message type "+t.type+"!")),this.msgsUntilAck!==void 0&&this.ackWindow&&(this.msgsUntilAck--,this.msgsUntilAck<=0)){this.msgsUntilAck=this.ackWindow;const n=new z;n.type=Te.ACK,this.sendMsg(n)}const i=Date.now()-e;return i>X.GAP_DETECTION_THRESHOLD&&console.log("delta "+this.channelType()+":"+t.type+" "+i),s}processChannelMessage(t){return this.logErr(this.channelType()+": No message handlers for this channel; message "+t.type),!1}channelType(){switch(this.type){case p.MAIN:return"main";case p.DISPLAY:return"display";case p.INPUTS:return"inputs";case p.CURSOR:return"cursor";case p.PLAYBACK:return"playback";case p.RECORD:return"record";case p.TUNNEL:return"tunnel";case p.SMARTCARD:return"smartcard";case p.USBREDIR:return"usbredir";case p.PORT:return"port";case p.WEBDAV:return"webdav";default:return"unknown-"+this.type}}logInfo(...t){const e=t.join(" ");if(console.log(e),this.messageId&&typeof document<"u"){const s=document.getElementById(this.messageId);if(s){const i=document.createElement("p");i.appendChild(document.createTextNode(e)),i.className+="spice-message-info",s.appendChild(i)}}}logWarn(...t){const e=t.join(" ");if(console.log("WARNING: "+e),this.messageId&&typeof document<"u"){const s=document.getElementById(this.messageId);if(s){const i=document.createElement("p");i.appendChild(document.createTextNode(e)),i.className+="spice-message-warning",s.appendChild(i)}}}logErr(...t){const e=t.join(" ");if(console.log("ERROR: "+e),this.messageId&&typeof document<"u"){const s=document.getElementById(this.messageId);if(s){const i=document.createElement("p");i.appendChild(document.createTextNode(e)),i.className+="spice-message-error",s.appendChild(i)}}}knownUnimplemented(t,e){if(!this.warnings[t]||Er>1){let s="";s=" [ further notices suppressed ]",this.logWarn("Unimplemented function "+t+"("+e+")"+s),this.warnings[t]=!0}}reportError(t){if(this.logErr(t.toString()),this.onerror!==void 0)this.onerror(t);else throw t}reportSuccess(t){this.onsuccess!==void 0&&this.onsuccess(t)}cleanup(){this.timeout!==void 0&&(clearTimeout(this.timeout),this.timeout=void 0),this.wireReader&&this.wireReader.cleanup(),this.ws&&(this.state=x.CLOSING,this.ws.close())}handleTimeout(){const t=new Error("Connection timed out.");this.reportError(t)}}const ge={PENDING:"pending",TRANSFERRING:"transferring",COMPLETED:"completed",FAILED:"failed",CANCELLED:"cancelled"},ki=new Map;function je(r,t){ki.set(r,t)}class hs extends Ne{constructor(t){if(typeof WebSocket>"u")throw new Error("WebSocket unavailable. You need to use a different browser.");super(t),this.mouseMode=0,this.ourMmTime=0,this.mmTime=0,this.channels={display:void 0,inputs:void 0,cursor:void 0,playback:void 0,ports:[],extra:[]},this.agentConnected=!1,this.agentTokens=0,this.agentMsgQueue=[],this.agentCaps=[0],this.fileXferTasks={},this.fileXferTaskId=0,this.fileXferReadQueue=[]}processChannelMessage(t){if(t.type===I.MIGRATE_BEGIN)return this.knownUnimplemented(t.type,"Main Migrate Begin"),!0;if(t.type===I.MIGRATE_CANCEL)return this.knownUnimplemented(t.type,"Main Migrate Cancel"),!0;if(t.type===I.INIT)return this.handleInit(t);if(t.type===I.MOUSE_MODE)return this.handleMouseModeMsg(t);if(t.type===I.MULTI_MEDIA_TIME)return this.knownUnimplemented(t.type,"Main Multi Media Time"),!0;if(t.type===I.CHANNELS_LIST)return this.handleChannelsList(t);if(t.type===I.AGENT_CONNECTED)return this.connectAgent(),!0;if(t.type===I.AGENT_CONNECTED_TOKENS){if(t.data){const e=new Ht(t.data);this.agentTokens=e.numTokens}return this.connectAgent(),!0}return t.type===I.AGENT_TOKEN?this.handleAgentToken(t):t.type===I.AGENT_DISCONNECTED?(this.agentConnected=!1,!0):t.type===I.AGENT_DATA?this.handleAgentData(t):t.type===I.MIGRATE_SWITCH_HOST?(this.knownUnimplemented(t.type,"Main Migrate Switch Host"),!0):t.type===I.MIGRATE_END?(this.knownUnimplemented(t.type,"Main Migrate End"),!0):t.type===I.NAME?(this.knownUnimplemented(t.type,"Main Name"),!0):t.type===I.UUID?(this.knownUnimplemented(t.type,"Main UUID"),!0):t.type===I.MIGRATE_BEGIN_SEAMLESS?(this.knownUnimplemented(t.type,"Main Migrate Begin Seamless"),!0):t.type===I.MIGRATE_DST_SEAMLESS_ACK?(this.knownUnimplemented(t.type,"Main Migrate Dst Seamless ACK"),!0):t.type===I.MIGRATE_DST_SEAMLESS_NACK?(this.knownUnimplemented(t.type,"Main Migrate Dst Seamless NACK"),!0):!1}handleInit(t){if(!t.data)return this.logWarn("INIT message with no data"),!0;this.logInfo("Connected to "+this.ws.url),this.reportSuccess("Connected"),this.mainInit=new Js(t.data),this.connectionId=this.mainInit.sessionId,this.agentTokens=this.mainInit.agentTokens,this.ourMmTime=Date.now(),this.mmTime=this.mainInit.multiMediaTime,this.handleMouseMode(this.mainInit.currentMouseMode,this.mainInit.supportedMouseModes),this.mainInit.agentConnected&&this.connectAgent();const e=new z;return e.type=re.ATTACH_CHANNELS,e.size=e.bufferSize(),this.sendMsg(e),!0}handleChannelsList(t){if(!t.data)return this.logWarn("CHANNELS_LIST message with no data"),!0;const e=new Xs(t.data);for(let s=0;s<e.channels.length;s++){const i=e.channels[s],n={uri:this.ws.url,parent:this,connectionId:this.connectionId,type:i.type,chanId:i.id};if(i.type===p.DISPLAY)i.id===0?this.channels.display=this.createChannel(p.DISPLAY,n):this.logWarn("The spice-html5 client does not handle multiple heads.");else if(i.type===p.INPUTS){const o=this.createChannel(p.INPUTS,n);o&&"mouseMode"in o?(this.channels.inputs=o,this.channels.inputs.mouseMode=this.mouseMode):o&&(this.channels.inputs=o)}else if(i.type===p.CURSOR)this.channels.cursor=this.createChannel(p.CURSOR,n);else if(i.type===p.PLAYBACK)this.channels.playback=this.createChannel(p.PLAYBACK,n);else if(i.type===p.PORT){const o=this.createChannel(p.PORT,n);o&&this.channels.ports.push(o)}else{const o=new Ne(n);this.channels.extra.push(o),this.logErr("Channel type "+o.channelType()+" not implemented")}}return!0}createChannel(t,e){const s=ki.get(t);return s?new s(e):(this.logWarn("No factory registered for channel type "+t+"; creating generic SpiceConn"),new Ne(e))}handleMouseModeMsg(t){if(!t.data)return this.logWarn("MOUSE_MODE message with no data"),!0;const e=new $s(t.data);return this.handleMouseMode(e.currentMode,e.supportedModes),!0}handleMouseMode(t,e){if(this.mouseMode=t,t!==be.CLIENT&&e&be.CLIENT){const s=new ii(be.CLIENT),i=new z;i.buildMsg(re.MOUSE_MODE_REQUEST,s),this.sendMsg(i)}this.channels.inputs&&(this.channels.inputs.mouseMode=t)}connectAgent(){this.agentConnected=!0;const t=new ri(-1>>>0),e=new z;e.buildMsg(re.AGENT_START,t),this.sendMsg(e),this.announceAgentCapabilities(1),this.onagent!==void 0&&this.onagent()}announceAgentCapabilities(t){const e=new zt(t,1<<Q.MOUSE_STATE|1<<Q.MONITORS_CONFIG|1<<Q.REPLY|1<<Q.CLIPBOARD_SELECTION|1<<Q.CLIPBOARD_BY_DEMAND);this.sendAgentMessage(b.ANNOUNCE_CAPABILITIES,e)}sendAgentMessageQueue(t){if(this.agentConnected)for(t&&this.agentMsgQueue.push(t);this.agentTokens>0&&this.agentMsgQueue.length>0;){const e=this.agentMsgQueue.shift();e&&(this.sendMsg(e),this.agentTokens--)}}sendAgentMessage(t,e){const s=new ni(t,e),i=St-new z().bufferSize(),n=new ArrayBuffer(s.bufferSize());s.toBuffer(n);let o=0;for(;o<s.bufferSize();){const h=Math.min(o+i,s.bufferSize()),u=new z;u.type=re.AGENT_DATA,u.size=h-o,u.data=n.slice(o,h),this.sendAgentMessageQueue(u),o=h}}handleAgentToken(t){if(!t.data)return this.logWarn("AGENT_TOKEN message with no data"),!0;const e=new Ht(t.data);this.agentTokens+=e.numTokens,this.sendAgentMessageQueue();let s=this.agentTokens;for(;s>0&&this.fileXferReadQueue.length>0;){const i=this.fileXferReadQueue.shift();i&&(this.fileXferRead(i,i.readBytes),s--)}return!0}handleAgentData(t){if(!t.data)return this.logWarn("AGENT_DATA message with no data"),!0;const e=new ei(t.data);if(e.type===b.ANNOUNCE_CAPABILITIES){if(e.data){const s=new zt(e.data);this.agentCaps=[s.caps],s.request&&this.announceAgentCapabilities(0)}return!0}return e.type===b.FILE_XFER_STATUS?(e.data&&this.handleFileXferStatus(new Xt(e.data)),!0):e.type===b.CLIPBOARD_GRAB?(this.handleClipboardGrab(),!0):e.type===b.CLIPBOARD?(this.handleClipboardReceive(e),!0):e.type===b.CLIPBOARD_REQUEST?(this.handleClipboardSend(),!0):e.type===b.CLIPBOARD_RELEASE}fileXferStart(t){const e=this.fileXferTaskId++,s={id:e,file:t,state:ge.PENDING,cancelled:!1,readBytes:0};this.fileXferTasks[e]=s;const i=new ai(e,t.name,t.size);this.sendAgentMessage(b.FILE_XFER_START,i)}handleFileXferStatus(t){const e=this.fileXferTasks[t.id];if(!e)return;let s;switch(t.result){case Me.CAN_SEND_DATA:e.state=ge.TRANSFERRING,this.fileXferRead(e);return;case Me.CANCELLED:s="transfer is cancelled by spice agent",e.state=ge.CANCELLED;break;case Me.ERROR:s="some errors occurred in the spice agent",e.state=ge.FAILED;break;case Me.SUCCESS:e.state=ge.COMPLETED;break;default:s="unhandled status type: "+t.result,e.state=ge.FAILED;break}this.fileXferCompleted(e,s)}fileXferRead(t,e){const s=32*St;if(!t||!this.fileXferTasks[t.id]||e!==void 0&&e>0&&e===t.file.size)return;if(t.cancelled){const u=new Xt(t.id,Me.CANCELLED);this.sendAgentMessage(b.FILE_XFER_STATUS,u),t.state=ge.CANCELLED,delete this.fileXferTasks[t.id];return}const i=e??0,n=Math.min(i+s,t.file.size);if(!this.agentTokens){t.readBytes=i,this.fileXferReadQueue.push(t);return}const o=new FileReader;o.onload=u=>{var E;const a=(E=u.target)==null?void 0:E.result;if(!(a instanceof ArrayBuffer))return;const l=new ci(t.id,a.byteLength,a);this.sendAgentMessage(b.FILE_XFER_DATA,l),this.fileXferRead(t,n),this.onFileXferProgress&&this.onFileXferProgress(t.id,n,t.file.size,t.file.name)};const h=t.file.slice(i,n);o.readAsArrayBuffer(h)}fileXferCompleted(t,e){e?(this.logErr(e),t.state=ge.FAILED):(this.logInfo("transfer of '"+t.file.name+"' was successful"),t.state=ge.COMPLETED),this.onFileXferComplete&&this.onFileXferComplete(t.id,t.file.name,e),delete this.fileXferTasks[t.id]}cancelFileXfer(t){const e=this.fileXferTasks[t];e&&(e.cancelled=!0,e.state=ge.CANCELLED)}handleClipboardGrab(){const t=me.UTF8_TEXT,e=new Zs(t,this.agentCaps);this.sendAgentMessage(b.CLIPBOARD_REQUEST,e)}handleClipboardReceive(t){if(!t.data)return;const e=new Qs({data:t.data},this.agentCaps);if(e.type===me.UTF8_TEXT){const s=e.getText();this.onClipboard&&this.onClipboard(s),typeof navigator<"u"&&navigator.clipboard&&navigator.clipboard.writeText&&navigator.clipboard.writeText(s).catch(i=>{console.warn("Failed to write to navigator clipboard:",i)})}else console.log("Unsupported clipboard type:",e.type)}handleClipboardSend(){typeof navigator<"u"&&navigator.clipboard&&navigator.clipboard.readText&&navigator.clipboard.readText().then(t=>{const e=me.UTF8_TEXT,s=new js(e,t,this.agentCaps);this.sendAgentMessage(b.CLIPBOARD,s)}).catch(t=>{console.log("Failed to read clipboard:",t)})}sendClipboardGrab(){const t=me.UTF8_TEXT,e=new qs(t,this.agentCaps);this.sendAgentMessage(b.CLIPBOARD_GRAB,e)}resizeWindow(t,e,s,i,n,o){const h=new oi(t,e,s,i,n,o);this.sendAgentMessage(b.MONITORS_CONFIG,h)}relativeNow(){return Date.now()-this.ourMmTime+this.mmTime}stop(){this.state=x.CLOSING,this.channels.inputs&&(this.channels.inputs.cleanup(),this.channels.inputs=void 0),this.channels.cursor&&(this.channels.cursor.cleanup(),this.channels.cursor=void 0),this.channels.display&&(this.channels.display.cleanup(),this.channels.display=void 0),this.channels.playback&&(this.channels.playback.cleanup(),this.channels.playback=void 0);for(const t of this.channels.ports)t.cleanup();this.channels.ports=[],this.cleanup();for(const t of this.channels.extra)t.cleanup();this.channels.extra=[]}}const Vr="spice-xfer-area";class kr{constructor(t,e){this.cancelled=!1,this.progressbarContainer=void 0,this.progressbar=void 0,this.id=t,this.file=e}createProgressbar(t=Vr){if(typeof document>"u")return;const e=document.getElementById(t);if(!e)return;const s=document.createElement("input");this.progressbarContainer=document.createElement("div"),this.progressbar=document.createElement("progress"),s.type="button",s.value="Cancel",s.style.cssFloat="right",s.onclick=()=>{this.cancelled=!0,this.removeProgressbar()},this.progressbar.setAttribute("max",String(this.file.size)),this.progressbar.setAttribute("value","0"),this.progressbar.style.width="100%",this.progressbar.style.margin="4px auto",this.progressbar.style.display="inline-block",this.progressbarContainer.style.width="90%",this.progressbarContainer.style.margin="auto",this.progressbarContainer.style.padding="4px",this.progressbarContainer.textContent=this.file.name,this.progressbarContainer.appendChild(s),this.progressbarContainer.appendChild(this.progressbar),e.appendChild(this.progressbarContainer)}updateProgressbar(t){this.progressbar&&this.progressbar.setAttribute("value",String(t))}removeProgressbar(){this.progressbarContainer&&this.progressbarContainer.parentNode&&this.progressbarContainer.parentNode.removeChild(this.progressbarContainer),this.progressbarContainer=void 0,this.progressbar=void 0}}function xi(r){r.stopPropagation(),r.preventDefault(),r.dataTransfer&&(r.dataTransfer.dropEffect="copy")}function Wi(r,t){if(r.stopPropagation(),r.preventDefault(),!r.dataTransfer)return;const e=r.dataTransfer.files;for(let s=e.length-1;s>=0;s--){const i=e[s];i&&i.type&&t.fileXferStart(i)}}const Hi=200,ct=8,xr=20;function us(r){if(typeof document>"u"||typeof window>"u"||!r.screenId)return;const t=document.getElementById(r.screenId);if(!t)return;let e=t.clientWidth,s=window.innerHeight-xr;if(r.messageId){const i=document.getElementById(r.messageId);if(i!==null)if(window.getComputedStyle(i).getPropertyValue("display")==="none"){const n=parseInt(window.getComputedStyle(i).getPropertyValue("height"),10);isNaN(n)||(s=s-n)}else s=s-i.offsetHeight-i.clientHeight}s%ct>0&&(s-=s%ct),e%ct>0&&(e-=e%ct),r.resizeWindow(0,e,s,32,0,0)}class zi{constructor(t,e=Hi){this.resizeTimer=void 0,this.handleResize=()=>{this.resizeTimer!==void 0&&(clearTimeout(this.resizeTimer),this.resizeTimer=void 0),this.resizeTimer=setTimeout(()=>{us(this.connection),this.resizeTimer=void 0},this.debounceMs)},this.connection=t,this.debounceMs=e}cleanup(){this.resizeTimer!==void 0&&(clearTimeout(this.resizeTimer),this.resizeTimer=void 0)}}function Xi(r,t,e=Hi){if(typeof ResizeObserver>"u")return;const s=new zi(t,e),i=new ResizeObserver(()=>{s.handleResize()});return i.observe(r),()=>{i.disconnect(),s.cleanup()}}function Wr(r){let e=`${r.scheme??"ws"}://${r.host}:${r.port}`;return r.path&&(e+=r.path.startsWith("/")?r.path:`/${r.path}`),e}function Hr(r){if(typeof document>"u")return;const t=new Date;t.setTime(t.getTime()+24*60*60*1e3),document.cookie=`token=${r}; expires=${t.toUTCString()}; path=/`}const qi=P.forwardRef(function(t,e){const{connection:s,display:i,features:n,audio:o,className:h,style:u,onConnect:a,onDisconnect:l,onError:E,onResize:_,onClipboard:d,onFileTransferProgress:S,onFileTransferComplete:g,onPortData:D}=t,k=P.useRef(null),F=P.useRef(null),R=P.useRef(null),Ie=P.useRef(null),ce=P.useRef({onConnect:a,onDisconnect:l,onError:E,onResize:_,onClipboard:d,onFileTransferProgress:S,onFileTransferComplete:g,onPortData:D});ce.current={onConnect:a,onDisconnect:l,onError:E,onResize:_,onClipboard:d,onFileTransferProgress:S,onFileTransferComplete:g,onPortData:D};const at=(n==null?void 0:n.enableKeyboard)??!0,Bt=(n==null?void 0:n.enableMouse)??!0,M=(n==null?void 0:n.enableClipboard)??!0,v=(n==null?void 0:n.enableFileTransfer)??!0,W=(i==null?void 0:i.fitContainer)??!1,[q]=P.useState(()=>`spice-screen-${Math.random().toString(36).slice(2,9)}`),te=P.useCallback(()=>{var y,Y;Ie.current&&(Ie.current(),Ie.current=null),R.current&&(R.current.stop(),R.current=null),(Y=(y=ce.current).onDisconnect)==null||Y.call(y)},[]),H=P.useCallback(()=>{var V;if(typeof document>"u")return;te(),s.token&&Hr(s.token);const y=Wr(s),Y=ce.current,he={uri:y,screenId:q,password:s.password??"",onerror:m=>{var G,C;(C=(G=ce.current).onError)==null||C.call(G,m)},onsuccess:()=>{var m,G;(G=(m=ce.current).onConnect)==null||G.call(m)},onagent:()=>{const m=R.current;if(!m)return;ce.current.onClipboard&&(m.onClipboard=C=>{var L,U;return(U=(L=ce.current).onClipboard)==null?void 0:U.call(L,C)}),m.onFileXferProgress=(C,L,U,A)=>{var se,Le;return(Le=(se=ce.current).onFileTransferProgress)==null?void 0:Le.call(se,C,L,U,A)},m.onFileXferComplete=(C,L,U)=>{var A,se;return(se=(A=ce.current).onFileTransferComplete)==null?void 0:se.call(A,C,L,U)};const G=m.channels.display;if(G&&(G.onSurface=(C,L,U,A)=>{var se,Le;A&&((Le=(se=ce.current).onResize)==null||Le.call(se,L,U))}),W&&k.current){us(m);const C=Xi(k.current,m);if(C){const L=Ie.current;Ie.current=()=>{C(),L==null||L()}}}if(v&&k.current){const C=k.current,L=se=>xi(se),U=se=>Wi(se,m);C.addEventListener("dragover",L,!1),C.addEventListener("drop",U,!1);const A=Ie.current;Ie.current=()=>{C.removeEventListener("dragover",L,!1),C.removeEventListener("drop",U,!1),A==null||A()}}if(ce.current.onPortData)for(const C of m.channels.ports){const L=C;L.onPortData=(U,A)=>{var se,Le;return(Le=(se=ce.current).onPortData)==null?void 0:Le.call(se,U,A)}}}};try{R.current=new hs(he)}catch(m){const G=m instanceof Error?m:new Error(String(m));(V=Y.onError)==null||V.call(Y,G)}},[s.host,s.port,s.password,s.token,s.scheme,s.path,q,te,v,W,M]);return P.useImperativeHandle(e,()=>({sendCtrlAltDel:()=>{const y=R.current;if(!y)return;const Y=y.channels.inputs;Y==null||Y.sendCtrlAltDel()},disconnect:te,reconnect:H,getConnection:()=>R.current}),[te,H]),P.useEffect(()=>{const y=F.current;if(!y)return;const Y=()=>{const V=R.current;if(V)return V.channels.inputs},he=[];if(at){const V=G=>{const C=Y();C==null||C.handleKeyDown(G)},m=G=>{const C=Y();C==null||C.handleKeyUp(G)};he.push(["keydown",V],["keyup",m])}if(Bt){const V=U=>{const A=Y();A==null||A.handleMouseMove(U)},m=U=>{const A=Y();A==null||A.handleMouseDown(U)},G=U=>{const A=Y();A==null||A.handleMouseUp(U)},C=U=>{const A=Y();A==null||A.handleMouseWheel(U)},L=U=>{const A=Y();A==null||A.handleContextMenu(U)};he.push(["mousemove",V],["mousedown",m],["mouseup",G],["wheel",C],["contextmenu",L])}for(const[V,m]of he)y.addEventListener(V,m);return()=>{for(const[V,m]of he)y.removeEventListener(V,m)}},[at,Bt]),P.useEffect(()=>(H(),()=>{te()}),[H,te]),ls.jsx("div",{ref:k,className:h,style:{position:"relative",overflow:"hidden",...u},children:ls.jsx("div",{ref:F,id:q,tabIndex:0,style:{outline:"none",width:"100%",height:"100%"}})})});qi.displayName="SpiceDisplay";const zr=typeof document>"u";function Xr(r){const[t,e]=P.useState("disconnected"),[s,i]=P.useState(null),[n,o]=P.useState(null),[h,u]=P.useState(0),a=P.useRef(null),l=P.useRef(r==null?void 0:r.callbacks);l.current=r==null?void 0:r.callbacks;const E=r==null?void 0:r.canvasRef,_=P.useCallback(()=>{var M,v;a.current&&(a.current.stop(),a.current=null),e("disconnected"),o(null),u(0),(v=(M=l.current)==null?void 0:M.onDisconnect)==null||v.call(M)},[]),d=P.useCallback(M=>{var q,te;if(zr)return;_(),e("connecting"),i(null);let v=M.screenId;!v&&(E!=null&&E.current)&&(E.current.id||(E.current.id=`spice-screen-${Math.random().toString(36).slice(2,9)}`),v=E.current.id);const W={uri:M.uri,screenId:v,dumpId:M.dumpId,messageId:M.messageId,password:M.password??"",onerror:H=>{var y,Y;e("error"),i(H),(Y=(y=l.current)==null?void 0:y.onError)==null||Y.call(y,H)},onsuccess:()=>{var H,y;e("connected"),(y=(H=l.current)==null?void 0:H.onConnect)==null||y.call(H)},onagent:()=>{var Y;const H=a.current;if(!H)return;(Y=l.current)!=null&&Y.onClipboard&&(H.onClipboard=he=>{var V,m;return(m=(V=l.current)==null?void 0:V.onClipboard)==null?void 0:m.call(V,he)}),H.onFileXferProgress=(he,V,m,G)=>{var C,L;return(L=(C=l.current)==null?void 0:C.onFileTransferProgress)==null?void 0:L.call(C,he,V,m,G)},H.onFileXferComplete=(he,V,m)=>{var G,C;return(C=(G=l.current)==null?void 0:G.onFileTransferComplete)==null?void 0:C.call(G,he,V,m)};const y=H.channels.display;y&&(y.onSurface=(he,V,m,G)=>{var L,U;const C=Object.keys(y.surfaces).length;if(u(C),G){const A=y.getPrimarySurface();A&&o({width:A.width,height:A.height}),(U=(L=l.current)==null?void 0:L.onResize)==null||U.call(L,V,m)}else{const A=y.getPrimarySurface();o(A?{width:A.width,height:A.height}:null)}})}};try{a.current=new hs(W)}catch(H){const y=H instanceof Error?H:new Error(String(H));e("error"),i(y),(te=(q=l.current)==null?void 0:q.onError)==null||te.call(q,y)}},[_,E]),S=P.useCallback(()=>{const M=a.current;if(M)return M.channels.inputs},[]),g=P.useCallback(M=>{const v=S();if(!v)return;const W=new z,q=new Je(M);W.buildMsg(K.KEY_DOWN,q),v.sendMsg(W)},[S]),D=P.useCallback(M=>{const v=S();if(!v)return;const W=new z,q=new $e(M);W.buildMsg(K.KEY_UP,q),v.sendMsg(W)},[S]),k=P.useCallback((M,v)=>{const W=S();if(!W)return;const q=new z,te=new rs(M,v,W.buttonState,0);q.buildMsg(K.MOUSE_POSITION,te),W.sendMsg(q)},[S]),F=P.useCallback((M,v)=>{const W=S();if(!W)return;const q=new z;if(v){const te=new pt(M,W.buttonState);q.buildMsg(K.MOUSE_PRESS,te)}else{const te=new At(M,W.buttonState);q.buildMsg(K.MOUSE_RELEASE,te)}W.sendMsg(q)},[S]),R=P.useCallback(M=>{const v=a.current;v&&v.sendClipboardGrab()},[]),Ie=P.useCallback((M,v)=>{const W=a.current;W&&W.resizeWindow(0,M,v,32,0,0)},[]),ce=P.useCallback(()=>{const M=S();M==null||M.sendCtrlAltDel()},[S]),at=P.useCallback(()=>a.current,[]);return P.useEffect(()=>()=>{a.current&&(a.current.stop(),a.current=null)},[]),{status:t,error:s,resolution:n,surfaces:h,controls:{connect:d,disconnect:_,sendKeyDown:g,sendKeyUp:D,sendMouseMove:k,sendMouseButton:F,sendClipboard:R,setResolution:Ie,sendCtrlAltDel:ce,getConnection:at}}}const j={INVALID:0,GRAY:1,RGB16:2,RGB24:3,RGB32:4,RGBA:5},qr=3,Qr=6,Zr=2048,Qi=26,Zi=qr,Oe=Qr,qe=Zr,T=3,de=2,fe=1,Ee=0,w=4;function ji(){return{nGRcodewords:[0,0,0,0,0,0,0,0],notGRcwlen:[0,0,0,0,0,0,0,0],notGRprefixmask:[0,0,0,0,0,0,0,0],notGRsuffixlen:[0,0,0,0,0,0,0,0],xlatU2L:[],xlatL2U:[]}}const jr=ji(),Z=ji(),Ae=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535,131071,262143,524287,1048575,2097151,4194303,8388607,16777215,33554431,67108863,134217727,268435455,536870911,1073741823,2147483647,4294967295],Ji=[],Jr=[[550,900,800,700,500,350,300,200,180,180,160],[110,550,900,800,550,400,350,250,140,160,140],[100,120,550,900,700,500,400,300,220,250,160]],Zt=[0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,5,5,6,6,7,7,8,9,10,11,12,13,14,15],ht=[8,7,6,6,5,5,5,5,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],$r=[46495042,893548311,794435923,2453991765,2077388039,894197842,1462934312,697534094,1826128012,343623392,2581292719,3811265708,459739748,2638427270,1654964626,101227083,2654850628,3668700691,572794346,2758751005,3445133904,2344099199,3367450297,898927923,3618406352,1606297603,754696453,20823118,2050458127,972590750,3990194068,3305596553,4239238564,1690498157,3015324227,2306127097,1510321853,548392192,971157512,2292288069,1611390505,4086766286,4084927083,1883326811,1891043243,113180603,1107690783,3778825955,3248980775,2443839100,2190866218,1932072870,495393613,1078522166,4051963518,1784694977,1768732442,2146763203,264646923,1474361405,2361552500,296035746,2489922759,2094565616,2409465348,1334241083,72483606,3740181004,4057920662,1734898312,4114662834,574624900,880305546,3258472262,26713132,1571648456,52557195,4043234286,2458021343,676064371,1528437109,64953873,546717185,2709319979,1947039598,2812723004,28691684,286829174,4235176970,3465707163,12526951,2154766700,3165032534,2036061161,3386656087,2301212354,2023576300,1061142336,3105452904,2743866805,3283373992,3397596080,3085489552,3196092395,3210707808,3651022684,925444321,2088074316,230011220,3223248386,533229176,523863486,3028311159,13140218,2538347282,900399636,3000796173,1526771255,3541282854,2992674461,2135722105,389334227,1225164337,3119947809,1803959919,3471171263,704170491,1407019136,1924534819,526887421,168782227,333811993,298623278,4268451686,381087740,2542899140,3266880867,2498950977,200969370,3511909096,3252303004,2268881098,2499828613,2606499854,3163208665,3790254546,1840025712,1319758833,3771674836,519421307,3512796222,1563402978,4284300462,2263719815,715250337,3178437172,2660191010,2982332026,3256309961,2709659997,3434092872,2367065591,69438718,915160508,183164069,3134331940,175242981,2680543346,1421955782,4231173251,1736652874,3990568476,1710820912,2286604440,3464587098,1261907837,1757387321,1128554270,1090050251,2429922486,1288729218,882830086,211637042,1376462063,2147615815,1737974929,798170275,4271572277,4241687072,1638524620,2760366295,1065115089,2097227717,1224023317,1625204849,3383303351,1488272307,2640186157,1649047732,819719707,2615091943,502645401,760628135,4108137983,63606742,1404337880,1865161130,4272996852,1239761976,790984678,3213322601,1917062825,4195069880,1962259360,2111002573,2311983960,1861406170,511141875,2797510619,1331661048,3130608186,147483493,3767089176,2650841450,4096523407,2574446300,1956416337,851468126,3607527519,1811658703,3642821136,832691095,2453312857,933732854,94341217,3393797730,1695907457,2405722077,2877685663,2469507058,2249636341,3988608661,4001245617,825934927,3103985967,1127151177,3691656896,1640967098,2168932645,2830550957,3998822878,3002602893,1509651465,775813869,2599574079,3791574229];function bs(r){if(r===1)return 0;let t=1;for(r-=1;r=r>>>1;)t++;return t}function $i(r,t,e){for(let n=0;n<t;n++){let o=e-t;const h=Ae[t-n];o>h&&(o=h);const u=Ae[t]+1-(o<<n);r.nGRcodewords[n]=o<<n,r.notGRcwlen[n]=o+bs(u),r.notGRprefixmask[n]=Ae[32-o]>>>0,r.notGRsuffixlen[n]=bs(u)}const s=Ae[t],i=s>>>1;for(let n=0;n<=s;n++)n<=i?r.xlatU2L[n]=n<<1:r.xlatU2L[n]=(s-n<<1)+1;for(let n=0;n<=s;n++)n&1?r.xlatL2U[n]=s-(n>>>1):r.xlatL2U[n]=n>>>1}function en(r){switch(r){case j.GRAY:return 8;case j.RGB16:return 5;case j.RGB24:return 8;case j.RGB32:return 8;case j.RGBA:return 8;case j.INVALID:default:return console.log(`quic: bad image type
|
|
5
|
+
`),0}}function tn(r){return r&4286578688?ht[r>>>24]:r&4294934528?8+ht[r>>>16&255]:r&4294967168?16+ht[r>>>8&255]:24+ht[r&255]}function _e(r,t){let e,s;if(t<0||t>Z.notGRprefixmask[r]){const i=tn(t);s=i+1+r,e=i<<r|t>>32-s&Ae[r]}else s=Z.notGRcwlen[r],e=Z.nGRcodewords[r]+(t>>32-s&Ae[Z.notGRsuffixlen[r]]);return{codewordlen:s,rc:e}}function ys(r,t){return r<Z.nGRcodewords[t]?(r>>>t)+1+t:Z.notGRcwlen[t]}class Ns{constructor(t){this.nBuckets=0,this.nBucketsPtrs=0,this.repfirst=0,this.firstsize=0,this.repnext=0,this.mulsize=0;let e=0;switch(this.levels=1<<t,Zi){case 1:this.repfirst=3,this.firstsize=1,this.repnext=2,this.mulsize=2;break;case 3:this.repfirst=1,this.firstsize=1,this.repnext=1,this.mulsize=2;break;case 5:this.repfirst=1,this.firstsize=1,this.repnext=1,this.mulsize=4;break;case 0:case 2:case 4:console.log(`quic: findmodelparams(): evol value obsolete!!!
|
|
6
|
+
`);break;default:console.log(`quic: findmodelparams(): evol out of range!!!
|
|
7
|
+
`)}let s=this.repfirst+1,i=this.firstsize;do{let n;this.nBuckets?n=e+1:n=0,--s||(s=this.repnext,i*=this.mulsize),e=n+i-1,e+i>=this.levels&&(e=this.levels-1),this.nBucketsPtrs||(this.nBucketsPtrs=this.levels),this.nBuckets++}while(e<this.levels-1)}}class sn{constructor(){this.bestcode=0,this.counters=[0,0,0,0,0,0,0,0]}reste(t){this.bestcode=t,this.counters=[0,0,0,0,0,0,0,0]}updateModel8bpc(t,e,s){let i=s-1,n=this.counters[i]=(this.counters[i]??0)+ys(e,i);for(let o=s-2;o>=0;o--){const h=this.counters[o]=(this.counters[o]??0)+ys(e,o);h<n&&(i=o,n=h)}if(this.bestcode=i,n>t.wmTrigger)for(let o=0;o<s;o++)this.counters[o]=(this.counters[o]??0)>>>1}}class Ls{constructor(){this.bucketsPtrs=[],this.bucketsBuf=[]}fillModelStructures(t){let e=0,s=0,i=t.repfirst+1,n=t.firstsize;do{let o;s?o=e+1:o=0,--i||(i=t.repnext,n*=t.mulsize),e=o+n-1,e+n>=t.levels&&(e=t.levels-1);const h=new sn;this.bucketsBuf[s]=h;for(let u=o;u<=e;u++)this.bucketsPtrs[u]=h;s++}while(e<t.levels-1);return!0}}class rn{constructor(t,e){this.bucketsPtrs=[],this.state=new er,this.familyStat8bpc=new Ls,this.familyStat5bpc=new Ls,this.correlateRow={zero:0,row:[]},this.model8bpc=t,this.model5bpc=e,this.familyStat8bpc.fillModelStructures(this.model8bpc),this.familyStat5bpc.fillModelStructures(this.model5bpc)}reste(t){if(this.correlateRow={zero:0,row:[]},t===8){for(let e=0;e<this.model8bpc.nBuckets;e++)this.familyStat8bpc.bucketsBuf[e].reste(7);this.bucketsPtrs=this.familyStat8bpc.bucketsPtrs}else if(t===5){for(let e=0;e<this.model5bpc.nBuckets;e++)this.familyStat8bpc.bucketsBuf[e].reste(4);this.bucketsPtrs=this.familyStat5bpc.bucketsPtrs}else return console.log("quic: bad bpc "+t+`
|
|
8
|
+
`),!1;return this.state.reste(),!0}}class er{constructor(){this.waitcnt=0,this.tabrandSeed=255,this.wmTrigger=0,this.wmidx=0,this.wmileft=qe,this.melcstate=0,this.melclen=0,this.melcorder=0}setWmTrigger(){let t=this.wmidx;t>10&&(t=10),this.wmTrigger=Jr[Math.floor(Zi/2)][t]}reste(){this.waitcnt=0,this.tabrandSeed=255,this.wmidx=0,this.wmileft=qe,this.setWmTrigger(),this.melcstate=0,this.melclen=Zt[0],this.melcorder=1<<this.melclen}tabrand(){return this.tabrandSeed++,$r[this.tabrandSeed&255]}}class tr{constructor(){this.type=0,this.width=0,this.height=0,this.ioIdx=0,this.ioAvailableBits=0,this.ioWord=0,this.ioNextWord=0,this.ioNow=new Uint8Array(0),this.ioEnd=0,this.rowsCompleted=0,this.rgbState=new er,this.model8bpc=new Ns(8),this.model5bpc=new Ns(5),this.channels=[];for(let t=0;t<4;t++)this.channels.push(new rn(this.model8bpc,this.model5bpc))}reste(t){return this.rgbState.reste(),this.ioNow=t,this.ioEnd=this.ioNow.length,this.ioIdx=0,this.rowsCompleted=0,!0}readIoWord(){if(this.ioIdx>=this.ioEnd)throw new Error("quic: out of data");this.ioNextWord=this.ioNow[this.ioIdx++]|this.ioNow[this.ioIdx++]<<8|this.ioNow[this.ioIdx++]<<16|this.ioNow[this.ioIdx++]<<24}decodeEatbits(t){this.ioWord=this.ioWord<<t;const e=this.ioAvailableBits-t;if(e>=0)this.ioAvailableBits=e,this.ioWord|=this.ioNextWord>>>this.ioAvailableBits;else{const s=-1*e;this.ioWord|=this.ioNextWord<<s,this.readIoWord(),this.ioAvailableBits=32-s,this.ioWord|=this.ioNextWord>>>this.ioAvailableBits}}decodeEat32bits(){this.decodeEatbits(16),this.decodeEatbits(16)}resteChannels(t){for(let e=0;e<4;e++)if(!this.channels[e].reste(t))return!1;return!0}quicDecodeBegin(t){if(!this.reste(t))return!1;this.ioIdx=0,this.ioNextWord=this.ioNow[this.ioIdx++]|this.ioNow[this.ioIdx++]<<8|this.ioNow[this.ioIdx++]<<16|this.ioNow[this.ioIdx++]<<24,this.ioWord=this.ioNextWord,this.ioAvailableBits=0;const e=this.ioWord;if(this.decodeEat32bits(),e!==1128879441)return console.log("quic: bad magic "+e.toString(16)),!1;const s=this.ioWord;if(this.decodeEat32bits(),s!==0)return console.log("quic: bad version "+s.toString(16)),!1;this.type=this.ioWord,this.decodeEat32bits(),this.width=this.ioWord,this.decodeEat32bits(),this.height=this.ioWord,this.decodeEat32bits();const i=en(this.type);return!!this.resteChannels(i)}quicRgb32UncompressRow0Seg(t,e,s,i,n,o){let u,a,l;if(t)u=t+this.rgbState.waitcnt;else{e[T]=0,a=0;do l=_e(this.channels[a].bucketsPtrs[this.channels[a].correlateRow.zero].bestcode,this.ioWord),this.channels[a].correlateRow.row[0]=l.rc,e[2-a]=Z.xlatL2U[l.rc]&255,this.decodeEatbits(l.codewordlen);while(++a<3);if(this.rgbState.waitcnt)--this.rgbState.waitcnt;else{this.rgbState.waitcnt=this.rgbState.tabrand()&i,a=0;do this.channels[a].bucketsPtrs[this.channels[a].correlateRow.zero].updateModel8bpc(this.rgbState,this.channels[a].correlateRow.row[0],n);while(++a<3)}u=++t+this.rgbState.waitcnt}for(;u<s;){for(;t<=u;t++){e[t*w+T]=0,a=0;do l=_e(this.channels[a].bucketsPtrs[this.channels[a].correlateRow.row[t-1]].bestcode,this.ioWord),this.channels[a].correlateRow.row[t]=l.rc,e[t*w+(2-a)]=Z.xlatL2U[l.rc]+e[(t-1)*w+(2-a)]&o,this.decodeEatbits(l.codewordlen);while(++a<3)}a=0;do this.channels[a].bucketsPtrs[this.channels[a].correlateRow.row[u-1]].updateModel8bpc(this.rgbState,this.channels[a].correlateRow.row[u],n);while(++a<3);u=t+(this.rgbState.tabrand()&i)}for(;t<s;t++){e[t*w+T]=0,a=0;do l=_e(this.channels[a].bucketsPtrs[this.channels[a].correlateRow.row[t-1]].bestcode,this.ioWord),this.channels[a].correlateRow.row[t]=l.rc,e[t*w+(2-a)]=Z.xlatL2U[l.rc]+e[(t-1)*w+(2-a)]&o,this.decodeEatbits(l.codewordlen);while(++a<3)}this.rgbState.waitcnt=u-s}quicRgb32UncompressRow0(t){let i=0,n=this.width;for(;Oe>this.rgbState.wmidx&&this.rgbState.wmileft<=n;)this.rgbState.wmileft&&(this.quicRgb32UncompressRow0Seg(i,t,i+this.rgbState.wmileft,Ae[this.rgbState.wmidx],8,255),i+=this.rgbState.wmileft,n-=this.rgbState.wmileft),this.rgbState.wmidx++,this.rgbState.setWmTrigger(),this.rgbState.wmileft=qe;n&&(this.quicRgb32UncompressRow0Seg(i,t,i+n,Ae[this.rgbState.wmidx],8,255),Oe>this.rgbState.wmidx&&(this.rgbState.wmileft-=n))}quicRgb32UncompressRowSeg(t,e,s,i,n,o){const u=Ae[this.rgbState.wmidx];let a,l=0,E=0,_=0,d;if(s)_=s+this.rgbState.waitcnt;else{e[T]=0,d=0;do a=_e(this.channels[d].bucketsPtrs[this.channels[d].correlateRow.zero].bestcode,this.ioWord),this.channels[d].correlateRow.row[0]=a.rc,e[2-d]=Z.xlatL2U[this.channels[d].correlateRow.row[0]]+t[2-d]&o,this.decodeEatbits(a.codewordlen);while(++d<3);if(this.rgbState.waitcnt)--this.rgbState.waitcnt;else{this.rgbState.waitcnt=this.rgbState.tabrand()&u,d=0;do this.channels[d].bucketsPtrs[this.channels[d].correlateRow.zero].updateModel8bpc(this.rgbState,this.channels[d].correlateRow.row[0],n);while(++d<3)}_=++s+this.rgbState.waitcnt}for(;;){let S=0;for(;_<i&&!S;){for(;s<=_&&!S;s++){const g=s*w,D=(s-1)*w,k=(s-2)*w;if(t[D+de]===t[g+de]&&t[D+fe]===t[g+fe]&&t[D+Ee]===t[g+Ee]&&l!==s&&s>2&&e[D+de]===e[k+de]&&e[D+fe]===e[k+fe]&&e[D+Ee]===e[k+Ee]){for(this.rgbState.waitcnt=_-s,l=s,E=s+this.decodeRun(this.rgbState);s<E;s++){const F=s*w,R=(s-1)*w;e[F+T]=0,e[F+de]=e[R+de],e[F+fe]=e[R+fe],e[F+Ee]=e[R+Ee]}if(s===i)return;_=s+this.rgbState.waitcnt,S=1;break}d=0,e[g+T]=0;do{const F=this.channels[d],R=F.correlateRow;a=_e(F.bucketsPtrs[R.row[s-1]].bestcode,this.ioWord),R.row[s]=a.rc,e[g+(2-d)]=Z.xlatL2U[a.rc]+(e[D+(2-d)]+t[g+(2-d)]>>1)&o,this.decodeEatbits(a.codewordlen)}while(++d<3)}if(S)break;d=0;do this.channels[d].bucketsPtrs[this.channels[d].correlateRow.row[_-1]].updateModel8bpc(this.rgbState,this.channels[d].correlateRow.row[_],n);while(++d<3);_=s+(this.rgbState.tabrand()&u)}for(;s<i&&!S;s++){const g=s*w,D=(s-1)*w,k=(s-2)*w;if(t[D+de]===t[g+de]&&t[D+fe]===t[g+fe]&&t[D+Ee]===t[g+Ee]&&l!==s&&s>2&&e[D+de]===e[k+de]&&e[D+fe]===e[k+fe]&&e[D+Ee]===e[k+Ee]){for(this.rgbState.waitcnt=_-s,l=s,E=s+this.decodeRun(this.rgbState);s<E;s++){const F=s*w,R=(s-1)*w;e[F+T]=0,e[F+de]=e[R+de],e[F+fe]=e[R+fe],e[F+Ee]=e[R+Ee]}if(s===i)return;_=s+this.rgbState.waitcnt,S=1;break}e[g+T]=0,d=0;do a=_e(this.channels[d].bucketsPtrs[this.channels[d].correlateRow.row[s-1]].bestcode,this.ioWord),this.channels[d].correlateRow.row[s]=a.rc,e[g+(2-d)]=Z.xlatL2U[a.rc]+(e[D+(2-d)]+t[g+(2-d)]>>1)&o,this.decodeEatbits(a.codewordlen);while(++d<3)}if(!S){this.rgbState.waitcnt=_-i;return}}}decodeRun(t){let e=0;do{const s=~(this.ioWord>>>24)>>>0&255,i=Ji[s];for(let n=1;n<=i;n++)e+=t.melcorder,t.melcstate<32&&(t.melclen=Zt[++t.melcstate],t.melcorder=1<<t.melclen);if(i!==8){this.decodeEatbits(i+1);break}this.decodeEatbits(8)}while(!0);return t.melclen&&(e+=this.ioWord>>>32-t.melclen,this.decodeEatbits(t.melclen)),t.melcstate&&(t.melclen=Zt[--t.melcstate],t.melcorder=1<<t.melclen),e}quicRgb32UncompressRow(t,e){let n=0,o=this.width;for(;Oe>this.rgbState.wmidx&&this.rgbState.wmileft<=o;)this.rgbState.wmileft&&(this.quicRgb32UncompressRowSeg(t,e,n,n+this.rgbState.wmileft,8,255),n+=this.rgbState.wmileft,o-=this.rgbState.wmileft),this.rgbState.wmidx++,this.rgbState.setWmTrigger(),this.rgbState.wmileft=qe;o&&(this.quicRgb32UncompressRowSeg(t,e,n,n+o,8,255),Oe>this.rgbState.wmidx&&(this.rgbState.wmileft-=o))}quicFourUncompressRow0Seg(t,e,s,i,n,o,h,u){let a,l;for(e===0?(l=_e(t.bucketsPtrs[s.zero].bestcode,this.ioWord),s.row[0]=l.rc,i[T]=Z.xlatL2U[l.rc],this.decodeEatbits(l.codewordlen),t.state.waitcnt?--t.state.waitcnt:(t.state.waitcnt=t.state.tabrand()&o,t.bucketsPtrs[s.zero].updateModel8bpc(t.state,s.row[0],h)),a=++e+t.state.waitcnt):a=e+t.state.waitcnt;a<n;){let E;for(;e<=a;e++)E=t.bucketsPtrs[s.row[e-1]],l=_e(E.bestcode,this.ioWord),s.row[e]=l.rc,i[e*w+T]=Z.xlatL2U[l.rc]+i[(e-1)*w+T]&u,this.decodeEatbits(l.codewordlen);E.updateModel8bpc(t.state,s.row[a],h),a=e+(t.state.tabrand()&o)}for(;e<n;e++)l=_e(t.bucketsPtrs[s.row[e-1]].bestcode,this.ioWord),s.row[e]=l.rc,i[e*w+T]=Z.xlatL2U[l.rc]+i[(e-1)*w+T]&u,this.decodeEatbits(l.codewordlen);t.state.waitcnt=a-n}quicFourUncompressRow0(t,e){const n=t.correlateRow;let o=0,h=this.width;for(;Oe>t.state.wmidx&&t.state.wmileft<=h;)t.state.wmileft&&(this.quicFourUncompressRow0Seg(t,o,n,e,o+t.state.wmileft,Ae[t.state.wmidx],8,255),o+=t.state.wmileft,h-=t.state.wmileft),t.state.wmidx++,t.state.setWmTrigger(),t.state.wmileft=qe;h&&(this.quicFourUncompressRow0Seg(t,o,n,e,o+h,Ae[t.state.wmidx],8,255),Oe>t.state.wmidx&&(t.state.wmileft-=h))}quicFourUncompressRowSeg(t,e,s,i,n,o,h,u){const a=Ae[t.state.wmidx];let l,E=0,_,d;for(n===0?(d=_e(t.bucketsPtrs[e.zero].bestcode,this.ioWord),e.row[0]=d.rc,i[T]=Z.xlatL2U[d.rc]+s[T]&u,this.decodeEatbits(d.codewordlen),t.state.waitcnt?--t.state.waitcnt:(t.state.waitcnt=t.state.tabrand()&a,t.bucketsPtrs[e.zero].updateModel8bpc(t.state,e.row[0],h)),l=++n+t.state.waitcnt):l=n+t.state.waitcnt;;){let S=0;for(;l<o&&!S;){let g;for(;n<=l&&!S;n++){const D=n*w,k=(n-1)*w,F=(n-2)*w;if(s[k+T]===s[D+T]&&E!==n&&n>2&&i[k+T]===i[F+T]){for(t.state.waitcnt=l-n,E=n,_=n+this.decodeRun(t.state);n<_;n++){const R=n*w,Ie=(n-1)*w;i[R+T]=i[Ie+T]}if(n===o)return;l=n+t.state.waitcnt,S=1;break}g=t.bucketsPtrs[e.row[n-1]],d=_e(g.bestcode,this.ioWord),e.row[n]=d.rc,i[D+T]=Z.xlatL2U[d.rc]+(i[k+T]+s[D+T]>>1)&u,this.decodeEatbits(d.codewordlen)}if(S)break;g.updateModel8bpc(t.state,e.row[l],h),l=n+(t.state.tabrand()&a)}for(;n<o&&!S;n++){const g=n*w,D=(n-1)*w,k=(n-2)*w;if(s[D+T]===s[g+T]&&E!==n&&n>2&&i[D+T]===i[k+T]){for(t.state.waitcnt=l-n,E=n,_=n+this.decodeRun(t.state);n<_;n++){const F=n*w,R=(n-1)*w;i[F+T]=i[R+T]}if(n===o)return;l=n+t.state.waitcnt,S=1;break}d=_e(t.bucketsPtrs[e.row[n-1]].bestcode,this.ioWord),e.row[n]=d.rc,i[g+T]=Z.xlatL2U[d.rc]+(i[D+T]+s[g+T]>>1)&u,this.decodeEatbits(d.codewordlen)}if(!S){t.state.waitcnt=l-o;return}}}quicFourUncompressRow(t,e,s){const o=t.correlateRow;let h=0,u=this.width;for(;Oe>t.state.wmidx&&t.state.wmileft<=u;)t.state.wmileft&&(this.quicFourUncompressRowSeg(t,o,e,s,h,h+t.state.wmileft,8,255),h+=t.state.wmileft,u-=t.state.wmileft),t.state.wmidx++,t.state.setWmTrigger(),t.state.wmileft=qe;u&&(this.quicFourUncompressRowSeg(t,o,e,s,h,h+u,8,255),Oe>t.state.wmidx&&(t.state.wmileft-=u))}quicDecode(t,e){switch(this.type){case j.RGB32:case j.RGB24:this.channels[0].correlateRow.zero=0,this.channels[1].correlateRow.zero=0,this.channels[2].correlateRow.zero=0,this.quicRgb32UncompressRow0(t),this.rowsCompleted++;for(let s=1;s<this.height;s++){const i=t;t=i.subarray(e),this.channels[0].correlateRow.zero=this.channels[0].correlateRow.row[0],this.channels[1].correlateRow.zero=this.channels[1].correlateRow.row[0],this.channels[2].correlateRow.zero=this.channels[2].correlateRow.row[0],this.quicRgb32UncompressRow(i,t),this.rowsCompleted++}break;case j.RGB16:return console.log(`quic: unsupported output format
|
|
9
|
+
`),!1;case j.RGBA:this.channels[0].correlateRow.zero=0,this.channels[1].correlateRow.zero=0,this.channels[2].correlateRow.zero=0,this.quicRgb32UncompressRow0(t),this.channels[3].correlateRow.zero=0,this.quicFourUncompressRow0(this.channels[3],t),this.rowsCompleted++;for(let s=1;s<this.height;s++){const i=t;t=i.subarray(e),this.channels[0].correlateRow.zero=this.channels[0].correlateRow.row[0],this.channels[1].correlateRow.zero=this.channels[1].correlateRow.row[0],this.channels[2].correlateRow.zero=this.channels[2].correlateRow.row[0],this.quicRgb32UncompressRow(i,t),this.channels[3].correlateRow.zero=this.channels[3].correlateRow.row[0],this.quicFourUncompressRow(this.channels[3],i,t),this.rowsCompleted++}break;case j.GRAY:return console.log(`quic: unsupported output format
|
|
10
|
+
`),!1;case j.INVALID:default:return console.log(`quic: bad image type
|
|
11
|
+
`),!1}return!0}simpleQuicDecode(t){if(!this.quicDecodeBegin(t)||this.type!==j.RGB32&&this.type!==j.RGB24&&this.type!==j.RGBA)return null;const s=new Uint8Array(this.width*this.height*4);return s[0]=69,this.quicDecode(s,this.width*4)?s:null}}let lt=null;function nn(){return lt||(lt=new tr),lt}class on{constructor(){this.data_size=0,this.outptr=null,this.type=0,this.width=0,this.height=0}fromDataView(t,e,s){const i=nn();this.data_size=t.getUint32(e,!0),e+=4;const n=new Uint8Array(s.slice(e)),o=i.simpleQuicDecode(n);return this.outptr=o,o&&(this.type=i.type,this.width=i.width,this.height=i.height),e+=n.length,e}}function sr(r,t){if(!t.outptr)return;const e=r.createImageData(t.width,t.height),s=e.width*e.height*4;for(let i=0;i<s;i+=4)e.data[i+0]=t.outptr[i+2],e.data[i+1]=t.outptr[i+1],e.data[i+2]=t.outptr[i+0],t.type!==j.RGBA?e.data[i+3]=255:e.data[i+3]=255-t.outptr[i+3];return e}$i(Z,8,Qi);$i(jr,5,Qi);{let r=1,t=1,e=8;for(let s=0;s<256;++s)Ji[s]=e,--t,t===0&&(t=r,--e,r*=2)}lt=new tr;function Gt(r,t,e,s,i){let n=t,o=0;for(let h=r[n++];o*4<e.length;h=r[n++]){let u=o,a=h>>5,E=(h&31)<<8;if(h>=32){let _;if(a--,a===6)do _=r[n++],a+=_;while(_===255);if(_=r[n++],E+=_,_===255&&E-_===7936&&(E=r[n++]<<8,E+=r[n++],E+=8191),a+=1,s===B.RGBA&&(a+=2),E+=1,u-=E,u===o-1){const d=u;for(;a;--a){if(s===B.RGBA)e[o*4+3]=e[d*4+3];else for(let S=0;S<4;S++)e[o*4+S]=e[d*4+S];o++}}else for(;a;--a){if(s===B.RGBA)e[o*4+3]=e[u*4+3];else for(let d=0;d<4;d++)e[o*4+d]=e[u*4+d];o++,u++}}else for(h++,s===B.RGBA?e[o*4+3]=r[n++]:(e[o*4+0]=r[n+2],e[o*4+1]=r[n+1],e[o*4+2]=r[n+0],i&&(e[o*4+3]=255),n+=3),o++,--h;h;h--)s===B.RGBA?e[o*4+3]=r[n++]:(e[o*4+0]=r[n+2],e[o*4+1]=r[n+1],e[o*4+2]=r[n+0],i&&(e[o*4+3]=255),n+=3),o++}return n-1}function an(r){const t=r.width*4,e=r.height;let s=e;const i=new Uint8Array(r.width*r.height*4);for(;s--;)i.set(r.data.subarray(s*t,(s+1)*t),(e-s-1)*t);r.data.set(i)}function jt(r,t){if(t.type===B.RGB32||t.type===B.RGBA){const e=new Uint8Array(t.data),s=r.createImageData(t.width,t.height),i=Gt(e,0,s.data,B.RGB32,t.type!==B.RGBA);return t.top_down||an(s),t.type===B.RGBA&&Gt(e,i,s.data,B.RGBA,!1),s}else if(t.type===B.XXXA){const e=new Uint8Array(t.data),s=r.createImageData(t.width,t.height);return Gt(e,0,s.data,B.RGBA,!1),s}}function ir(r,t){if(t.format!==ne._32BIT&&t.format!==ne.RGBA)return;const e=new Uint8Array(t.data),s=t.x,i=t.y,n=t.stride;let o=0,h=0;t.flags&Fe.TOP_DOWN||(o=(i-1)*n,h=2*n);const u=r.createImageData(s,i),a=u.data;for(let l=0;l<i*n;o-=h)for(let E=0;E<s;E++,l+=4,o+=4)a[l+0]=e[o+2],a[l+1]=e[o+1],a[l+2]=e[o+0],t.format===ne._32BIT?a[l+3]=255:a[l+3]=e[o];return u}class rr extends Ne{constructor(t){super(t),this.surfaces={},this.cache={},this.streams={}}processChannelMessage(t){if(t.type===f.MODE)return this.knownUnimplemented(t.type,"Display Mode"),!0;if(t.type===f.MARK)return this.knownUnimplemented(t.type,"Display Mark"),!0;if(t.type===f.RESET){const e=this.surfaces[this.primarySurface];return e&&e.canvas.context.restore(),!0}return t.type===f.DRAW_COPY?this.handleDrawCopy(t):t.type===f.DRAW_FILL?this.handleDrawFill(t):t.type===f.DRAW_OPAQUE?(this.knownUnimplemented(t.type,"Display Draw Opaque"),!0):t.type===f.DRAW_BLEND?(this.knownUnimplemented(t.type,"Display Draw Blend"),!0):t.type===f.DRAW_BLACKNESS?(this.knownUnimplemented(t.type,"Display Draw Blackness"),!0):t.type===f.DRAW_WHITENESS?(this.knownUnimplemented(t.type,"Display Draw Whiteness"),!0):t.type===f.DRAW_INVERS?(this.knownUnimplemented(t.type,"Display Draw Invers"),!0):t.type===f.DRAW_ROP3?(this.knownUnimplemented(t.type,"Display Draw ROP3"),!0):t.type===f.DRAW_STROKE?(this.knownUnimplemented(t.type,"Display Draw Stroke"),!0):t.type===f.DRAW_TRANSPARENT?(this.knownUnimplemented(t.type,"Display Draw Transparent"),!0):t.type===f.DRAW_ALPHA_BLEND?(this.knownUnimplemented(t.type,"Display Draw Alpha Blend"),!0):t.type===f.DRAW_COMPOSITE?(this.knownUnimplemented(t.type,"Display Draw Composite"),!0):t.type===f.COPY_BITS?this.handleCopyBits(t):t.type===f.SURFACE_CREATE?this.handleSurfaceCreate(t):t.type===f.SURFACE_DESTROY?this.handleSurfaceDestroy(t):t.type===f.STREAM_CREATE?this.handleStreamCreate(t):t.type===f.STREAM_DATA||t.type===f.STREAM_DATA_SIZED?this.handleStreamData(t):t.type===f.STREAM_ACTIVATE_REPORT?this.handleStreamActivateReport(t):t.type===f.STREAM_CLIP?this.handleStreamClip(t):t.type===f.STREAM_DESTROY?this.handleStreamDestroy(t):t.type===f.STREAM_DESTROY_ALL?(this.knownUnimplemented(t.type,"Display Stream Destroy All"),!0):t.type===f.INVAL_LIST?this.handleInvalList(t):t.type===f.INVAL_ALL_PIXMAPS?(this.knownUnimplemented(t.type,"Display Inval All Pixmaps"),!0):t.type===f.INVAL_PALETTE?(this.knownUnimplemented(t.type,"Display Inval Palette"),!0):t.type===f.INVAL_ALL_PALETTES?(this.knownUnimplemented(t.type,"Inval All Palettes"),!0):t.type===f.MONITORS_CONFIG?(this.knownUnimplemented(t.type,"Display Monitors Config"),!0):!1}handleDrawCopy(t){if(!t.data)return this.logErr("DrawCopy with no data"),!1;const e=new li(t.data);if(e.base.box.isSameSize(e.data.srcArea)||this.logWarn("FIXME: DrawCopy src_area is a different size than base.box; we do not handle that yet."),e.base.clip.type!==tt.NONE&&this.logWarn("FIXME: DrawCopy we don't handle clipping yet"),e.data.ropDescriptor!==ie.OP_PUT&&this.logWarn("FIXME: DrawCopy we don't handle ropd type: "+e.data.ropDescriptor),e.data.mask.flags&&this.logWarn("FIXME: DrawCopy we don't handle mask flag: "+e.data.mask.flags),e.data.mask.bitmap&&this.logWarn("FIXME: DrawCopy we don't handle mask"),e.data&&e.data.srcBitmap){const s=e.data.srcBitmap,i=s.descriptor;if(i.flags&&i.flags!==Pe.CACHE_ME&&i.flags!==Pe.HIGH_BITS_SET&&(this.logWarn("FIXME: DrawCopy unhandled image flags: "+i.flags),this.logDraw("DrawCopy",e)),i.type===O.QUIC){const n=this.surfaces[e.base.surfaceId];if(!n)return this.logWarn("DrawCopy QUIC: no surface "+e.base.surfaceId),!1;if(!s.quic)return this.logWarn("FIXME: DrawCopy could not handle this QUIC file."),!1;const o=sr(n.canvas.context,s.quic);return o?this.drawCopyHelper({base:e.base,srcArea:e.data.srcArea,imageData:o,tag:"copyquic."+s.quic.type,hasAlpha:s.quic.type===j.RGBA,descriptor:i}):(this.logWarn("FIXME: DrawCopy QUIC decompression failed."),!1)}if(i.type===O.FROM_CACHE||i.type===O.FROM_CACHE_LOSSLESS){const n=this.cache[String(i.id)];return n?this.drawCopyHelper({base:e.base,srcArea:e.data.srcArea,imageData:n,tag:"copycache."+i.id,hasAlpha:!0,descriptor:i}):(this.logWarn("FIXME: DrawCopy did not find image id "+i.id+" in cache."),!1)}if(i.type===O.SURFACE){if(s.surfaceId===null)return this.logWarn("DrawCopy SURFACE: no surfaceId on srcBitmap"),!1;const n=this.surfaces[s.surfaceId];if(!n)return this.logWarn("DrawCopy SURFACE: source surface "+s.surfaceId+" not found"),!1;const o=n.canvas.context,h=e.data.srcArea,u=o.getImageData(h.left,h.top,h.right-h.left,h.bottom-h.top),a=new Ce;return a.top=0,a.left=0,a.right=u.width,a.bottom=u.height,this.drawCopyHelper({base:e.base,srcArea:a,imageData:u,tag:"copysurf."+s.surfaceId,hasAlpha:n.format!==le._32_xRGB,descriptor:i})}if(i.type===O.JPEG)return s.jpeg?(this.handleDrawJpeg(e.base,i,s.jpeg.data,null,e.base.surfaceId),!0):(this.logWarn("FIXME: DrawCopy could not handle this JPEG file."),!1);if(i.type===O.JPEG_ALPHA){if(!s.jpegAlpha)return this.logWarn("FIXME: DrawCopy could not handle this JPEG ALPHA file."),!1;let n;const o=this.surfaces[e.base.surfaceId];return o&&o.format===le._32_ARGB&&(n=jt(o.canvas.context,s.jpegAlpha.alpha)??void 0),this.handleDrawJpeg(e.base,i,s.jpegAlpha.data,n??null,e.base.surfaceId),!0}if(i.type===O.BITMAP){const n=this.surfaces[e.base.surfaceId];if(!n)return this.logWarn("DrawCopy BITMAP: no surface "+e.base.surfaceId),!1;if(!s.bitmap)return this.logErr("null bitmap"),!1;const o=ir(n.canvas.context,s.bitmap);return o?this.drawCopyHelper({base:e.base,srcArea:e.data.srcArea,imageData:o,tag:"bitmap."+s.bitmap.format,hasAlpha:s.bitmap.format!==ne._32BIT,descriptor:i}):(this.logWarn("FIXME: Unable to interpret bitmap of format: "+s.bitmap.format),!1)}if(i.type===O.LZ_RGB){const n=this.surfaces[e.base.surfaceId];if(!n)return this.logWarn("DrawCopy LZ_RGB: no surface "+e.base.surfaceId),!1;if(!s.lzRgb)return this.logErr("null lz_rgb"),!1;const o=jt(n.canvas.context,s.lzRgb);return o?this.drawCopyHelper({base:e.base,srcArea:e.data.srcArea,imageData:o,tag:"lz_rgb."+s.lzRgb.type,hasAlpha:s.lzRgb.type===B.RGBA,descriptor:i}):(this.logWarn("FIXME: Unable to interpret bitmap of type: "+s.lzRgb.type),!1)}return this.logWarn("FIXME: DrawCopy unhandled image type: "+i.type),this.logDraw("DrawCopy",e),!1}return this.logWarn("FIXME: DrawCopy no src_bitmap."),!1}handleDrawFill(t){if(!t.data)return this.logErr("DrawFill with no data"),!1;const e=new di(t.data);if(e.data.ropDescriptor!==ie.OP_PUT&&this.logWarn("FIXME: DrawFill we don't handle ropd type: "+e.data.ropDescriptor),e.data.mask.flags&&this.logWarn("FIXME: DrawFill we don't handle mask flag: "+e.data.mask.flags),e.data.mask.bitmap&&this.logWarn("FIXME: DrawFill we don't handle mask"),e.data.brush.type===ye.SOLID){const s=e.data.brush.color&16777215,i="rgb("+(s>>16)+", "+(s>>8&255)+", "+(s&255)+")",n=this.surfaces[e.base.surfaceId];if(!n)return this.logWarn("DrawFill: no surface "+e.base.surfaceId),!1;n.canvas.context.fillStyle=i,n.canvas.context.fillRect(e.base.box.left,e.base.box.top,e.base.box.right-e.base.box.left,e.base.box.bottom-e.base.box.top),n.drawCount++}else this.logWarn("FIXME: DrawFill can't handle brush type: "+e.data.brush.type);return!0}handleCopyBits(t){if(!t.data)return this.logErr("CopyBits with no data"),!1;const e=new fi(t.data),s=this.surfaces[e.base.surfaceId];if(!s)return this.logWarn("CopyBits: no surface "+e.base.surfaceId),!1;const i=s.canvas.context;let n=s.canvas.canvas.width-e.srcPos.x,o=s.canvas.canvas.height-e.srcPos.y;n>e.base.box.right-e.base.box.left&&(n=e.base.box.right-e.base.box.left),o>e.base.box.bottom-e.base.box.top&&(o=e.base.box.bottom-e.base.box.top);const h=i.getImageData(e.srcPos.x,e.srcPos.y,n,o);return Os(i,h,e.base.box.left,e.base.box.top),s.drawCount++,!0}drawCopyHelper(t){const e=this.surfaces[t.base.surfaceId];if(!e)return this.logWarn("drawCopyHelper: no surface "+t.base.surfaceId),!1;const s=e.canvas;return t.hasAlpha?e.format===le._32_xRGB?(cn(t.imageData),s.context.putImageData(t.imageData,t.base.box.left,t.base.box.top)):Os(s.context,t.imageData,t.base.box.left,t.base.box.top):s.context.putImageData(t.imageData,t.base.box.left,t.base.box.top),(t.srcArea.left>0||t.srcArea.top>0)&&this.logWarn("FIXME: DrawCopy not shifting draw copies just yet..."),t.descriptor&&t.descriptor.flags&Pe.CACHE_ME&&(this.cache[String(t.descriptor.id)]=t.imageData),e.drawCount++,!0}handleDrawJpeg(t,e,s,i,n){if(typeof document>"u"){this.logWarn("Cannot handle JPEG draw: no document (SSR).");return}let o="data:image/jpeg,";const h=new Uint8Array(s);for(let a=0;a<h.length;a++)o+="%",h[a]<16&&(o+="0"),o+=h[a].toString(16);const u=new Image;u.onload=()=>{let a,l=!1;const E=this.surfaces[n];if(E)a=E.canvas.context;else{const _=document.createElement("canvas");_.setAttribute("width",String(t.box.right)),_.setAttribute("height",String(t.box.bottom));const d=_.getContext("2d");if(!d)return;a=d,l=!0}if(i){const _=document.createElement("canvas"),d=_.getContext("2d");if(!d)return;_.setAttribute("width",String(i.width)),_.setAttribute("height",String(i.height)),d.putImageData(i,0,0),d.globalCompositeOperation="source-in",d.drawImage(u,0,0),a.drawImage(_,t.box.left,t.box.top),e.flags&Pe.CACHE_ME&&(this.cache[String(e.id)]=d.getImageData(0,0,i.width,i.height))}else a.drawImage(u,t.box.left,t.box.top),u.onload=null,u.src=ds,e.flags&Pe.CACHE_ME&&(this.cache[String(e.id)]=a.getImageData(t.box.left,t.box.top,t.box.right-t.box.left,t.box.bottom-t.box.top));!l&&E&&E.drawCount++},u.src=o}logDraw(t,e){const s=this.surfaces[e.base.surfaceId];if(!s)return;let i=t+"."+e.base.surfaceId+"."+s.drawCount+": ";i+="base.box "+e.base.box.left+", "+e.base.box.top+" to "+e.base.box.right+", "+e.base.box.bottom,i+="; clip.type "+e.base.clip.type;const n=e.data;if(n){if("srcArea"in n){const o=n.srcArea;i+="; src_area "+o.left+", "+o.top+" to "+o.right+", "+o.bottom}if("srcBitmap"in n&&n.srcBitmap){const o=n.srcBitmap;i+="; src_bitmap id: "+o.descriptor.id,i+="; src_bitmap width "+o.descriptor.width+", height "+o.descriptor.height,i+="; src_bitmap type "+o.descriptor.type+", flags "+o.descriptor.flags,o.surfaceId!==null&&(i+="; src_bitmap surface_id "+o.surfaceId),o.bitmap&&(i+="; BITMAP format "+o.bitmap.format+"; flags "+o.bitmap.flags+"; x "+o.bitmap.x+"; y "+o.bitmap.y+"; stride "+o.bitmap.stride),o.quic&&(i+="; QUIC type "+o.quic.type+"; width "+o.quic.width+"; height "+o.quic.height),o.lzRgb&&(i+="; LZ_RGB length "+o.lzRgb.length+"; magic "+o.lzRgb.magic+"; version 0x"+o.lzRgb.version.toString(16)+"; type "+o.lzRgb.type+"; width "+o.lzRgb.width+"; height "+o.lzRgb.height+"; stride "+o.lzRgb.stride+"; top down "+o.lzRgb.top_down)}else"srcBitmap"in n&&(i+="; src_bitmap is null");if("brush"in n){const o=n.brush;o.type===ye.SOLID&&(i+="; brush.color 0x"+o.color.toString(16)),o.type===ye.PATTERN&&o.pattern&&(i+="; brush.pat ",o.pattern.pat!==null?i+="[SpiceImage]":i+="[null]",i+=" at "+o.pattern.pos.x+", "+o.pattern.pos.y)}if("ropDescriptor"in n&&(i+="; rop_descriptor "+n.ropDescriptor),"scaleMode"in n&&(i+="; scale_mode "+n.scaleMode),"mask"in n){const o=n.mask;i+="; mask.flags "+o.flags,i+="; mask.pos "+o.pos.x+", "+o.pos.y,o.bitmap!==null?(i+="; mask.bitmap width "+o.bitmap.descriptor.width+", height "+o.bitmap.descriptor.height,i+="; mask.bitmap type "+o.bitmap.descriptor.type+", flags "+o.bitmap.descriptor.flags):i+="; mask.bitmap is null"}}console.log(i)}handleStreamCreate(t){if(!t.data)return this.logErr("StreamCreate with no data"),!1;const e=new Mi(t.data);this.streams[e.id]&&console.log("Stream "+e.id+" already exists");const s={id:e.id,surfaceId:e.surfaceId,codecType:e.codecType,streamWidth:e.streamWidth,streamHeight:e.streamHeight,dest:{left:e.dest.left,top:e.dest.top,right:e.dest.right,bottom:e.dest.bottom},clip:void 0,framesLoading:0,video:void 0,media:void 0,sourceBuffer:void 0,queue:[],startTime:0,clusterTime:0,appendOkay:!1,currentFrame:void 0,report:void 0,maxWindowSize:0,timeoutMs:0};if(this.streams[e.id]=s,e.codecType===Ue.VP8){if(typeof MediaSource>"u"||typeof document>"u")return this.logWarn("VP8 streaming requires MediaSource API — not available."),!0;const i=new MediaSource,n=document.createElement("video");n.src=URL.createObjectURL(i),n.setAttribute("muted","true"),n.setAttribute("autoplay","true"),n.setAttribute("width",String(e.streamWidth)),n.setAttribute("height",String(e.streamHeight));let o=e.dest.left,h=e.dest.top;const u=this.surfaces[e.surfaceId];if(u&&(o+=u.canvas.canvas.offsetLeft,h+=u.canvas.canvas.offsetTop),this.parent&&this.parent.screenId){const a=document.getElementById(this.parent.screenId);a&&a.appendChild(n)}n.setAttribute("style","pointer-events:none; position: absolute; top:"+h+"px; left:"+o+"px;"),s.video=n,s.media=i,i.addEventListener("sourceopen",()=>{this.handleVideoSourceOpen(s)},!1),i.addEventListener("sourceended",()=>{this.logErr("Video source unexpectedly ended.")},!1),i.addEventListener("sourceclosed",()=>{this.logErr("Video source unexpectedly closed.")},!1)}else e.codecType===Ue.MJPEG?s.framesLoading=0:console.log("Unhandled stream codec: "+e.codecType);return!0}handleStreamData(t){if(!t.data)return this.logErr("StreamData with no data"),!1;const s=t.type===f.STREAM_DATA_SIZED?new qt(t.data):new Di(t.data),i=this.streams[s.base.id];if(!i)return console.log("no stream for data"),!1;const n=this.parent,o=n&&typeof n.relativeNow=="function"?n.relativeNow():0,h=s.base.multiMediaTime-o;return i.codecType===Ue.MJPEG&&this.processMjpegStreamData(i,s,h),i.codecType===Ue.VP8&&this.processVideoStreamData(i,s),!0}handleStreamActivateReport(t){if(!t.data)return this.logErr("StreamActivateReport with no data"),!1;const e=new Ri(t.data),s=new bi(e.streamId,e.uniqueId),i=this.streams[e.streamId];return i&&(i.report=s,i.maxWindowSize=e.maxWindowSize,i.timeoutMs=e.timeoutMs),!0}handleStreamClip(t){if(!t.data)return this.logErr("StreamClip with no data"),!1;const e=new wi(t.data),s=this.streams[e.id];return s&&(s.clip=e.clip),!0}handleStreamDestroy(t){if(!t.data)return this.logErr("StreamDestroy with no data"),!1;const e=new Pi(t.data),s=this.streams[e.id];if(s){if(s.codecType===Ue.VP8&&s.video){if(typeof document<"u"&&this.parent&&this.parent.screenId){const i=document.getElementById(this.parent.screenId);i&&s.video.parentNode===i&&i.removeChild(s.video)}s.sourceBuffer=void 0,s.media=void 0,s.video=void 0}delete this.streams[e.id]}return!0}handleVideoSourceOpen(t){if(t.sourceBuffer)return;if(!t.media){this.logErr("handleVideoSourceOpen: no MediaSource on stream "+t.id);return}let e;try{e=t.media.addSourceBuffer(X.SPICE_VP8_CODEC)}catch{this.logErr("Codec "+X.SPICE_VP8_CODEC+" not available.");return}t.sourceBuffer=e,this.listenForVideoEvents(t);const s=new cs,i=new Yi(t.streamWidth,t.streamHeight),n=new ns(i),o=new ArrayBuffer(s.bufferSize()+n.bufferSize());let h=s.toBuffer(o);n.toBuffer(o,h),e.addEventListener("error",()=>{this.logErr("source_buffer error")},!1),e.addEventListener("updateend",()=>{this.handleAppendVideoBufferDone(t)},!1),this.appendVideoBuffer(t,o)}appendVideoBuffer(t,e){if(t.sourceBuffer)try{t.appendOkay=!1,t.sourceBuffer.appendBuffer(e)}catch(s){const i=s instanceof Error?s.message:String(s);this.logErr("Error invoking appendBuffer: "+i)}}handleAppendVideoBufferDone(t){if(t.currentFrame&&t.report){const e=this.parent,s=e&&typeof e.relativeNow=="function"?e.relativeNow():0;this.processStreamDataReport(t,t.currentFrame.msgMmtime,t.currentFrame.msgMmtime-s)}if(t.queue.length>0){const e=t.queue.shift();t.currentFrame={msgMmtime:e.msgMmtime},e.mb&&this.appendVideoBuffer(t,e.mb)}else t.appendOkay=!0;if(t.video){if(t.video.buffered.length>0){const e=t.video.buffered.start(t.video.buffered.length-1);t.video.currentTime<e&&(console.log("Video appears to have fallen behind; advancing to "+e),t.video.currentTime=e)}t.video.paused&&t.video.readyState>=2&&t.video.play().catch(()=>{})}}pushOrQueue(t,e,s){t.appendOkay?(t.currentFrame={msgMmtime:e},this.appendVideoBuffer(t,s)):t.queue.push({msgMmtime:e,mb:s})}videoSimpleBlock(t,e,s){const i=new as(e.base.multiMediaTime-t.clusterTime,e.data.slice().buffer,s),n=new ArrayBuffer(i.bufferSize());i.toBuffer(n),this.pushOrQueue(t,e.base.multiMediaTime,n)}newVideoCluster(t,e){t.clusterTime=e.base.multiMediaTime;const s=new os(t.clusterTime-t.startTime),i=new ArrayBuffer(s.bufferSize());s.toBuffer(i),this.pushOrQueue(t,e.base.multiMediaTime,i),this.videoSimpleBlock(t,e,!0)}processVideoStreamData(t,e){t.startTime===0?(t.startTime=e.base.multiMediaTime,this.newVideoCluster(t,e)):e.base.multiMediaTime-t.clusterTime>=X.MAX_CLUSTER_TIME?this.newVideoCluster(t,e):this.videoSimpleBlock(t,e,!1)}processMjpegStreamData(t,e,s){if(s<0&&t.framesLoading>0){t.report&&t.report.numDrops++;return}if(typeof document>"u")return;let i="data:image/jpeg,";for(let l=0;l<e.data.length;l++)i+="%",e.data[l]<16&&(i+="0"),i+=e.data[l].toString(16);const n=new Ke;n.surfaceId=t.surfaceId;const o="dest"in e&&e instanceof qt?e.dest:t.dest;n.box=new Ce,n.box.left=o.left,n.box.top=o.top,n.box.right=o.right,n.box.bottom=o.bottom;const h=new Image,u=t.id,a=e.base.multiMediaTime;h.onload=()=>{const l=this.streams[u];l&&l.framesLoading--;let E,_=!1;const d=this.surfaces[n.surfaceId];if(d)E=d.canvas.context;else{const S=document.createElement("canvas");S.setAttribute("width",String(n.box.right)),S.setAttribute("height",String(n.box.bottom));const g=S.getContext("2d");if(!g)return;E=g,_=!0}if(E.drawImage(h,n.box.left,n.box.top),h.onload=null,h.src=ds,!_&&d&&d.drawCount++,l&&l.report){const S=this.parent,g=S&&typeof S.relativeNow=="function"?S.relativeNow():0;this.processStreamDataReport(l,a,a-g)}},h.src=i,t.framesLoading++}processStreamDataReport(t,e,s){if(t.report&&(t.report.numFrames++,t.report.startFrameMmTime===0&&(t.report.startFrameMmTime=e),t.report.numFrames>t.maxWindowSize||e-t.report.startFrameMmTime>t.timeoutMs)){t.report.endFrameMmTime=e,t.report.lastFrameDelay=s;const i=new z;i.buildMsg(et.STREAM_REPORT,t.report),this.sendMsg(i),t.report.startFrameMmTime=0,t.report.numFrames=0,t.report.numDrops=0}}listenForVideoEvents(t){if(!t.video)return;const e=t.video,s=n=>{t.video&&t.video.buffered.length>1&&console.log(t.video.currentTime+":id "+t.id+" event "+n.type+Ir(t.video)),t.queue.length>1&&console.log(" queue len "+t.queue.length+"; append_okay: "+t.appendOkay)};["abort","error"].forEach(n=>e.addEventListener(n,s))}handleSurfaceCreate(t){if(!t.data)return this.logErr("SurfaceCreate with no data"),!1;const e=new Ei(t.data);if(e.surface.format!==le._32_xRGB&&e.surface.format!==le._32_ARGB)return this.logWarn("FIXME: cannot handle surface format "+e.surface.format+" yet."),!1;if(typeof document>"u")return this.logWarn("Cannot create surface canvas: no document (SSR)."),!1;const s=document.createElement("canvas");s.setAttribute("width",String(e.surface.width)),s.setAttribute("height",String(e.surface.height)),s.setAttribute("id","spice_surface_"+e.surface.surfaceId),s.setAttribute("tabindex",String(e.surface.surfaceId));const i=s.getContext("2d");if(!i)return this.logErr("Failed to get 2D context for surface "+e.surface.surfaceId),!1;const n={canvas:s,context:i},o={surfaceId:e.surface.surfaceId,width:e.surface.width,height:e.surface.height,format:e.surface.format,flags:e.surface.flags,canvas:n,drawCount:0};if(this.surfaces[e.surface.surfaceId]=o,e.surface.flags&ss){if(this.primarySurface=e.surface.surfaceId,i.save(),this.parent&&this.parent.screenId){const h=document.getElementById(this.parent.screenId);h&&(h.appendChild(s),h.style.height=e.surface.height+"px")}this.hookEvents()}return this.onSurface&&this.onSurface(e.surface.surfaceId,e.surface.width,e.surface.height,!0),!0}handleSurfaceDestroy(t){if(!t.data)return this.logErr("SurfaceDestroy with no data"),!1;const e=new _i(t.data);return this.deleteSurface(e.surfaceId),!0}deleteSurface(t){const e=this.surfaces[t];if(e){if(typeof document<"u"){const s=e.canvas.canvas;if(this.primarySurface===t&&(this.unhookEvents(),this.primarySurface=void 0,this.parent&&this.parent.screenId)){const i=document.getElementById(this.parent.screenId);i&&s.parentNode===i&&i.removeChild(s)}}this.onSurface&&this.onSurface(t,e.width,e.height,!1),delete this.surfaces[t]}}destroySurfaces(){const t=Object.keys(this.surfaces).map(Number);for(const e of t)this.deleteSurface(e)}handleInvalList(t){if(!t.data)return this.logErr("InvalList with no data"),!1;const e=new yi(t.data);for(let s=0;s<e.count;s++){const i=e.resources[s];if(i){const n=String(i.id);this.cache[n]!==void 0&&delete this.cache[n]}}return!0}cacheImage(t,e){this.cache[String(t)]=e}getCachedImage(t){return this.cache[String(t)]}hasImageInCache(t){return this.cache[String(t)]!==void 0}getSurface(t){return this.surfaces[t]}getPrimarySurface(){if(this.primarySurface!==void 0)return this.surfaces[this.primarySurface]}hookEvents(){if(this.primarySurface===void 0)return;const t=this.surfaces[this.primarySurface];if(!t)return;const e=t.canvas.canvas;if(this.parent){const s=this.parent;typeof s.sendClipboardGrab=="function"&&(this.focusListener=()=>s.sendClipboardGrab(),this.focusListener(),e.addEventListener("focus",this.focusListener))}e.focus()}unhookEvents(){if(this.primarySurface===void 0)return;const t=this.surfaces[this.primarySurface];if(!t)return;const e=t.canvas.canvas;this.focusListener&&(e.removeEventListener("focus",this.focusListener),this.focusListener=void 0)}cleanup(){this.destroySurfaces(),this.cache={},this.streams={},super.cleanup()}}function Os(r,t,e,s){if(typeof document>"u")return;const i=document.createElement("canvas"),n=i.getContext("2d");n&&(i.setAttribute("width",String(t.width)),i.setAttribute("height",String(t.height)),n.putImageData(t,0,0),r.drawImage(i,e,s,t.width,t.height))}function cn(r){for(let t=0;t<r.width*r.height*4;t+=4)r.data[t+3]=255}je(p.DISPLAY,rr);function Se(r,t){const e=new z;return e.buildMsg(r,t),e}function Us(r){switch(r){case 0:return ae.LEFT;case 1:return ae.MIDDLE;case 2:return ae.RIGHT;default:return ae.INVALID}}function Bs(r){let t=0;return r&1&&(t|=Re.LEFT),r&4&&(t|=Re.MIDDLE),r&2&&(t|=Re.RIGHT),t}const Kt=23520;class nr extends Ne{constructor(t){super(t),this.mouseX=void 0,this.mouseY=void 0,this.buttonState=0,this.waitingForAck=0,this.mouseMode=0,this.keyboardModifiers=0,this.modifiers={shift:-1,ctrl:-1,alt:-1,meta:-1}}processChannelMessage(t){if(t.type===Ye.INIT){if(!t.data)return!0;const e=new Si(t.data);return this.keyboardModifiers=e.keyboardModifiers,!0}if(t.type===Ye.KEY_MODIFIERS){if(!t.data)return!0;const e=new pi(t.data);return this.keyboardModifiers=e.keyboardModifiers,!0}return t.type===Ye.MOUSE_MOTION_ACK?(this.waitingForAck-=_t,!0):!1}handleKeyDown(t){const e=Ar(t.keyCode,t.code);if(e===0)return;this.checkAndUpdateModifiers(t,e);const s=new Je(e),i=Se(K.KEY_DOWN,s);this.state==="ready"&&this.sendMsg(i),t.preventDefault()}handleKeyUp(t){const e=Cr(t.keyCode,t.code);if(e===0)return;this.checkAndUpdateModifiers(t,e);const s=new $e(e),i=Se(K.KEY_UP,s);this.state==="ready"&&this.sendMsg(i),t.preventDefault()}sendCtrlAltDel(){if(this.state!=="ready")return;this.updateModifier(!0,c.KEY_LCtrl),this.updateModifier(!0,c.KEY_Alt);const t=c.KEY_KP_Decimal,e=new Je(t),s=Se(K.KEY_DOWN,e);this.sendMsg(s);const i=new $e(t|128),n=Se(K.KEY_UP,i);this.sendMsg(n),this.modifiers.ctrl===0&&this.updateModifier(!1,c.KEY_LCtrl),this.modifiers.alt===0&&this.updateModifier(!1,c.KEY_Alt)}updateModifier(t,e){const s=t?Se(K.KEY_DOWN,new Je(e)):Se(K.KEY_UP,new $e(e|128));this.sendMsg(s)}checkAndUpdateModifiers(t,e){this.modifiers.shift===-1&&(this.modifiers.shift=t.shiftKey?1:0,this.modifiers.ctrl=t.ctrlKey?1:0,this.modifiers.alt=t.altKey?1:0,this.modifiers.meta=t.metaKey?1:0),e===c.KEY_ShiftL?this.modifiers.shift=1:e===c.KEY_Alt?this.modifiers.alt=1:e===c.KEY_LCtrl?this.modifiers.ctrl=1:e===Kt?this.modifiers.meta=1:e===(128|c.KEY_ShiftL)?this.modifiers.shift=0:e===(128|c.KEY_Alt)?this.modifiers.alt=0:e===(128|c.KEY_LCtrl)?this.modifiers.ctrl=0:e===(32768|Kt)&&(this.modifiers.meta=0),this.state==="ready"&&(this.modifiers.shift!==(t.shiftKey?1:0)&&(console.log("Shift state out of sync"),this.updateModifier(t.shiftKey,c.KEY_ShiftL),this.modifiers.shift=t.shiftKey?1:0),this.modifiers.alt!==(t.altKey?1:0)&&(console.log("Alt state out of sync"),this.updateModifier(t.altKey,c.KEY_Alt),this.modifiers.alt=t.altKey?1:0),this.modifiers.ctrl!==(t.ctrlKey?1:0)&&(console.log("Ctrl state out of sync"),this.updateModifier(t.ctrlKey,c.KEY_LCtrl),this.modifiers.ctrl=t.ctrlKey?1:0),this.modifiers.meta!==(t.metaKey?1:0)&&(console.log("Meta state out of sync"),this.updateModifier(t.metaKey,Kt),this.modifiers.meta=t.metaKey?1:0))}handleMouseMove(t,e=0){if(this.state==="ready"&&!(this.waitingForAck>=2*_t)){if(this.mouseMode===be.CLIENT){const s=new rs(t.offsetX,t.offsetY,this.buttonState,e),i=Se(K.MOUSE_POSITION,s);this.sendMsg(i)}else{const s=new Ti(t.movementX,t.movementY,this.buttonState,e),i=Se(K.MOUSE_MOTION,s);this.sendMsg(i)}this.waitingForAck++}}handleMouseDown(t){if(this.state!=="ready")return;const e=Us(t.button);this.buttonState=Bs(t.buttons);const s=new pt(e,this.buttonState),i=Se(K.MOUSE_PRESS,s);this.sendMsg(i),t.preventDefault()}handleMouseUp(t){if(this.state!=="ready")return;const e=Us(t.button);this.buttonState=Bs(t.buttons);const s=new At(e,this.buttonState),i=Se(K.MOUSE_RELEASE,s);this.sendMsg(i),t.preventDefault()}handleMouseWheel(t){if(this.state!=="ready")return;const e=t.deltaY<0?ae.UP:ae.DOWN,s=new pt(e,0),i=Se(K.MOUSE_PRESS,s);this.sendMsg(i);const n=new At(e,0),o=Se(K.MOUSE_RELEASE,n);this.sendMsg(o),t.preventDefault()}handleContextMenu(t){t.preventDefault()}}je(p.INPUTS,nr);function or(r,t,e){if(typeof document>"u")throw new Error("No document available for canvas-based PNG creation");const s=new Uint8Array(e),i=new Uint8ClampedArray(s.buffer,s.byteOffset,s.byteLength),n=new ImageData(i,r,t),o=document.createElement("canvas");o.width=r,o.height=t;const h=o.getContext("2d");if(!h)throw new Error("Failed to get 2d context from canvas");return h.putImageData(n,0,0),o.toDataURL("image/png")}async function hn(r){const t=new TextEncoder().encode(r),e=await crypto.subtle.digest("SHA-1",t),s=new Uint8Array(e);return Array.from(s,i=>i.toString(16).padStart(2,"0")).join("")}function un(r,t){const e=r;return e.spiceScreen=t,e.spiceHotX=0,e.spiceHotY=0,e}const ar={},Gs={};let Ks=!1;function ln(r,t){ar[r]=t}function dn(r,t){Ks||(Ks=!0,typeof window<"u"&&typeof window.alert=="function"&&window.alert(`This browser does not support dynamic cursors. This page will now simulate cursors with images, which will be imperfect. We recommend using Chrome or Firefox instead.
|
|
12
|
+
|
|
13
|
+
If you need to use this browser, you can create a static cursor file for each cursor your application uses. View the console log for more information on creating static cursors for your environment.`)),Gs[r]||(Gs[r]=t,console.log("Unknown cursor. Simulation required. To avoid simulation for this cursor, create and include a custom javascript file, and add the following line:"),console.log('SpiceSimulateCursor.addCursor("'+r+'", "<your cursor url here>");'))}function fn(r,t){const e=new MouseEvent(r.type,{bubbles:!0,cancelable:!0,view:r.view,detail:r.detail,screenX:r.screenX,screenY:r.screenY,clientX:r.clientX,clientY:r.clientY,ctrlKey:r.ctrlKey,altKey:r.altKey,shiftKey:r.shiftKey,metaKey:r.metaKey,button:r.button,relatedTarget:r.relatedTarget});return t.dispatchEvent(e)}async function En(r,t,e,s){if(typeof document>"u")return;const i=await hn(s+" "+t.header.hotSpotX+" "+t.header.hotSpotY),n=ar[i];if(n!==void 0){const o="url("+n+"), default";e.style.cursor=o}if(typeof window<"u"&&window.getComputedStyle(e,null).cursor==="auto"){if(dn(i,s),e.style.cursor="none",!r.simulatedCursor){const o=un(document.createElement("img"),e);o.style.position="absolute",o.style.display="none",o.style.overflow="hidden",o.spiceScreen=e;const h=u=>{fn(u,e)};o.addEventListener("mousemove",h),r.simulatedCursorHandler=h,e.appendChild(o),r.simulatedCursor=o}r.simulatedCursor.src=s,r.simulatedCursor.spiceHotX=t.header.hotSpotX,r.simulatedCursor.spiceHotY=t.header.hotSpotY,r.simulatedCursor.style.pointerEvents="none"}else r.simulatedCursor&&(r.simulatedCursor.spiceScreen.removeChild(r.simulatedCursor),r.simulatedCursor=void 0)}function _n(r){r.simulatedCursor&&(r.simulatedCursorHandler&&(r.simulatedCursor.removeEventListener("mousemove",r.simulatedCursorHandler),r.simulatedCursorHandler=void 0),r.simulatedCursor.parentNode&&r.simulatedCursor.parentNode.removeChild(r.simulatedCursor),r.simulatedCursor=void 0)}const Jt={addCursor:ln,simulateCursor:En,cleanupSimulatedCursor:_n};class cr extends Ne{constructor(t){super(t),this.simulatedCursor=void 0,this.simulatedCursorHandler=void 0}processChannelMessage(t){if(!t.data)return!0;if(t.type===ee.INIT){const e=new Ai(t.data),s=this.parent;return s&&s.inputs&&s.inputs.mouseMode===be.SERVER&&(s.inputs.mousex=e.position.x,s.inputs.mousey=e.position.y),!0}if(t.type===ee.SET){const e=new mi(t.data);if(e.cursor.flags&ve.NONE){const s=this.getScreen();return s&&(s.style.cursor="none"),!0}return e.cursor.flags>0&&this.logWarn("FIXME: No support for cursor flags "+e.cursor.flags),e.cursor.header&&e.cursor.header.type!==we.ALPHA?(this.logWarn("FIXME: No support for cursor type "+e.cursor.header.type),!1):(e.cursor.header&&this.setCursor({header:e.cursor.header,data:e.cursor.data}),!0)}if(t.type===ee.MOVE)return this.knownUnimplemented(t.type,"Cursor Move"),!0;if(t.type===ee.HIDE){const e=this.getScreen();return e&&(e.style.cursor="none"),!0}if(t.type===ee.TRAIL)return this.knownUnimplemented(t.type,"Cursor Trail"),!0;if(t.type===ee.RESET){const e=this.getScreen();return e&&(e.style.cursor="auto"),!0}return t.type===ee.INVAL_ONE?(this.knownUnimplemented(t.type,"Cursor Inval One"),!0):t.type===ee.INVAL_ALL}setCursor(t){const e=or(t.header.width,t.header.height,t.data),s="url("+e+") "+t.header.hotSpotX+" "+t.header.hotSpotY+", default",i=this.getScreen();i&&(i.style.cursor="auto",i.style.cursor=s,typeof window<"u"&&window.getComputedStyle(i,null).cursor==="auto"&&Jt.simulateCursor(this,t,i,e))}getScreen(){if(typeof document>"u")return null;const t=this.parent,e=t?t.screenId:this.screenId;return e?document.getElementById(e):null}cleanup(){Jt.cleanupSimulatedCursor(this),super.cleanup()}}je(p.CURSOR,cr);function Sn(r){if(r.length===1)return r.shift();let t=0;for(let n=0;n<r.length;n++)t+=r[n].byteLength;const e=new ArrayBuffer(t),s=new Uint8Array(e);let i=0;for(let n=0;n<r.length;n++)s.set(new Uint8Array(r[n]),i),i+=r[n].byteLength;return r.length=0,e}class hr extends Ne{constructor(t){super(t),this.queue=[],this.appendOkay=!1,this.startTime=0,this.clusterTime=0,this.lastDataTime=0,this.bytesWritten=0,this.mediaSource=void 0,this.sourceBuffer=void 0,this.audioElement=void 0,this.onSourceOpen=()=>{this.handleSourceOpen()},this.onSourceEnded=()=>{this.handleSourceEnded()},this.onSourceClosed=()=>{this.handleSourceClosed()},this.onSourceBufferError=e=>{this.handleSourceBufferError(e)},this.onAppendBufferDone=()=>{this.handleAppendBufferDone()}}processChannelMessage(t){if(!t.data)return!0;if(typeof MediaSource>"u")return this.logErr("MediaSource API is not available"),!1;if(t.type===oe.START){const e=new gi(t.data);if(e.frequency!==X.OPUS_FREQUENCY)return this.logErr("This player cannot handle frequency "+e.frequency),!1;if(e.channels!==X.OPUS_CHANNELS)return this.logErr("This player cannot handle "+e.channels+" channels"),!1;if(e.format!==Et.S16)return this.logErr("This player cannot handle format "+e.format),!1;if(!this.sourceBuffer){this.mediaSource=new MediaSource,this.audioElement=document.createElement("audio"),this.audioElement.setAttribute("autoplay","true"),this.audioElement.src=URL.createObjectURL(this.mediaSource);const s=this.parent?this.parent.screenId:this.screenId;if(s){const i=document.getElementById(s);i&&i.appendChild(this.audioElement)}return this.mediaSource.addEventListener("sourceopen",this.onSourceOpen,!1),this.mediaSource.addEventListener("sourceended",this.onSourceEnded,!1),this.mediaSource.addEventListener("sourceclosed",this.onSourceClosed,!1),this.bytesWritten=0,!0}}if(t.type===oe.DATA){const e=new Ci(t.data);if(!this.sourceBuffer)return!0;if(this.audioElement&&this.audioElement.readyState>=3&&this.audioElement.buffered.length>1&&this.audioElement.currentTime===this.audioElement.buffered.end(0)&&this.audioElement.currentTime<this.audioElement.buffered.start(this.audioElement.buffered.length-1)){const s=this.audioElement.buffered.start(this.audioElement.buffered.length-1);console.log("Audio underrun: we appear to have fallen behind; advancing to "+s),this.audioElement.currentTime=s}return this.startTime!==0&&e.time!==this.lastDataTime+X.EXPECTED_PACKET_DURATION&&Math.abs(e.time-(X.EXPECTED_PACKET_DURATION+this.lastDataTime))<X.MAX_CLUSTER_TIME&&(e.time=this.lastDataTime+X.EXPECTED_PACKET_DURATION),this.lastDataTime=e.time,this.startTime===0?this.startPlayback(e):e.time-this.clusterTime>=X.MAX_CLUSTER_TIME?this.newCluster(e):this.simpleBlock(e,!1),!0}if(t.type===oe.MODE){const e=new Ii(t.data);return e.mode!==Xe.OPUS&&(this.logErr("This player cannot handle mode "+e.mode),this.sourceBuffer=void 0),!0}return t.type===oe.STOP&&this.sourceBuffer?(this.stopPlayback(),!0):t.type===oe.VOLUME?(this.knownUnimplemented(t.type,"Playback Volume"),!0):t.type===oe.MUTE?(this.knownUnimplemented(t.type,"Playback Mute"),!0):t.type===oe.LATENCY?(this.knownUnimplemented(t.type,"Playback Latency"),!0):!1}startPlayback(t){if(!this.sourceBuffer)return;this.startTime=t.time;const e=new cs,s=new vi,i=new ns(s),n=new ArrayBuffer(e.bufferSize()+i.bufferSize());this.bytesWritten=e.toBuffer(n,0),this.bytesWritten=i.toBuffer(n,this.bytesWritten),this.sourceBuffer.addEventListener("error",this.onSourceBufferError,!1),this.sourceBuffer.addEventListener("updateend",this.onAppendBufferDone,!1),this.appendBuffer(n),this.newCluster(t)}newCluster(t){this.clusterTime=t.time;const e=new os(t.time-this.startTime),s=new ArrayBuffer(e.bufferSize());this.bytesWritten+=e.toBuffer(s,0),this.appendOkay?this.appendBuffer(s):this.queue.push(s),this.simpleBlock(t,!0)}simpleBlock(t,e){if(!t.data)return;const s=new as(t.time-this.clusterTime,t.data.slice(0),e),i=new ArrayBuffer(s.bufferSize());this.bytesWritten+=s.toBuffer(i,0),this.appendOkay?this.appendBuffer(i):this.queue.push(i)}appendBuffer(t){if(this.sourceBuffer)try{this.sourceBuffer.appendBuffer(t),this.appendOkay=!1}catch(e){const s=e instanceof Error?e.message:String(e);this.logErr("Error invoking appendBuffer: "+s)}}stopPlayback(){if(this.audioElement){const t=this.parent?this.parent.screenId:this.screenId;if(t&&typeof document<"u"){const e=document.getElementById(t);e&&this.audioElement.parentNode===e&&e.removeChild(this.audioElement)}URL.revokeObjectURL(this.audioElement.src)}this.removeMediaSourceListeners(),this.sourceBuffer&&(this.sourceBuffer.removeEventListener("error",this.onSourceBufferError,!1),this.sourceBuffer.removeEventListener("updateend",this.onAppendBufferDone,!1)),this.sourceBuffer=void 0,this.mediaSource=void 0,this.audioElement=void 0,this.appendOkay=!1,this.queue=[],this.startTime=0}handleSourceOpen(){if(!(!this.mediaSource||this.sourceBuffer)){if(this.sourceBuffer=this.mediaSource.addSourceBuffer(X.SPICE_PLAYBACK_CODEC),!this.sourceBuffer){this.logErr("Codec "+X.SPICE_PLAYBACK_CODEC+" not available.");return}this.listenForAudioEvents(),this.sourceBuffer.mode="segments"}}handleSourceEnded(){this.logErr("Audio source unexpectedly ended.")}handleSourceClosed(){this.logErr("Audio source unexpectedly closed.")}handleSourceBufferError(t){this.logErr("source_buffer error "+(t instanceof ErrorEvent?t.message:"unknown"))}handleAppendBufferDone(){if(this.logPlaybackDebugEvent("updateend"),this.queue.length>0){const t=Sn(this.queue);this.appendBuffer(t)}else this.appendOkay=!0}logPlaybackDebugEvent(t){this.queue.length>1&&console.log(" queue len "+this.queue.length+"; append_okay: "+this.appendOkay)}listenForAudioEvents(){if(!this.audioElement)return;const t=this.audioElement,e=["abort","error"],s=i=>{this.logPlaybackDebugEvent(i.type)};for(const i of e)t.addEventListener(i,s)}removeMediaSourceListeners(){this.mediaSource&&(this.mediaSource.removeEventListener("sourceopen",this.onSourceOpen,!1),this.mediaSource.removeEventListener("sourceended",this.onSourceEnded,!1),this.mediaSource.removeEventListener("sourceclosed",this.onSourceClosed,!1))}cleanup(){this.sourceBuffer&&this.stopPlayback(),super.cleanup()}}je(p.PLAYBACK,hr);class ur extends Ne{constructor(t){super(t),this.portName=null,this.portOpened=!1;const e=t;this.onPortInit=e.onPortInit,this.onPortEvent=e.onPortEvent,this.onPortData=e.onPortData}processChannelMessage(t){if(t.type===Ge.INIT){if(this.portName===null){if(!t.data)return this.logWarn("SPICE port: INIT message with no data"),!1;const e=new Ni(t.data);return this.portName=new TextDecoder().decode(e.name),this.portOpened=e.opened!==0,this.onPortInit&&this.onPortInit(this.portName,this.portOpened),!0}return!0}return t.type===Ge.EVENT?t.data?(this.onPortEvent&&this.portName!==null&&this.onPortEvent(this.portName,new Uint8Array(t.data)),!0):(this.logWarn("SPICE port: EVENT message with no data"),!1):t.type===Ge.SPICEVMC_DATA?t.data?(this.onPortData&&this.portName!==null&&this.onPortData(this.portName,t.data),!0):(this.logWarn("SPICE port: DATA message with no data"),!1):!1}sendPortData(t){const e=new z,s={toBuffer(i,n=0){new Uint8Array(i,n).set(new Uint8Array(t))},bufferSize(){return t.byteLength}};e.buildMsg(Qe.SPICEVMC_DATA,s),this.sendMsg(e)}sendPortEvent(t){const e=new z,s={toBuffer(i,n=0){new Uint8Array(i,n).set(new Uint8Array(t))},bufferSize(){return t.byteLength}};e.buildMsg(Qe.EVENT,s),this.sendMsg(e)}cleanup(){super.cleanup(),this.onPortInit=void 0,this.onPortEvent=void 0,this.onPortData=void 0}}je(p.PORT,ur);function pn(r,t,e){let s=t??0,i=e??r.byteLength;return i<0&&(i=r.byteLength+i),s<0&&(s=r.byteLength+s),s<0&&(s=0),i<0&&(i=0),i>r.byteLength&&(i=r.byteLength),s>i&&(s=i),r.slice(s,i)}function An(...r){let t=0;for(const n of r)t+=n.byteLength;const e=new ArrayBuffer(t),s=new Uint8Array(e);let i=0;for(const n of r)s.set(new Uint8Array(n),i),i+=n.byteLength;return e}function Cn(r){const t=new ArrayBuffer(r.byteLength);return new Uint8Array(t).set(r),t}function In(r,t){if(r.byteLength!==t.byteLength)return!1;const e=new Uint8Array(r),s=new Uint8Array(t);for(let i=0;i<e.byteLength;i++)if(e[i]!==s[i])return!1;return!0}class Ut{constructor(t,e,s){e!==void 0&&s!==void 0?(this.dv=new DataView(t,e,s),this.u8=new Uint8Array(t,e,s)):e!==void 0?(this.dv=new DataView(t,e),this.u8=new Uint8Array(t,e)):(this.dv=new DataView(t),this.u8=new Uint8Array(t))}get buffer(){return this.dv.buffer}get byteOffset(){return this.dv.byteOffset}get byteLength(){return this.dv.byteLength}getUint8(t){return this.dv.getUint8(t)}getInt8(t){return this.dv.getInt8(t)}getUint16(t,e){return this.dv.getUint16(t,e)}getInt16(t,e){return this.dv.getInt16(t,e)}getUint32(t,e){return this.dv.getUint32(t,e)}getInt32(t,e){return this.dv.getInt32(t,e)}getFloat32(t,e){return this.dv.getFloat32(t,e)}getFloat64(t,e){return this.dv.getFloat64(t,e)}getBigUint64(t,e){return this.dv.getBigUint64(t,e)}getBigInt64(t,e){return this.dv.getBigInt64(t,e)}setUint8(t,e){this.dv.setUint8(t,e)}setInt8(t,e){this.dv.setInt8(t,e)}setUint16(t,e,s){this.dv.setUint16(t,e,s)}setInt16(t,e,s){this.dv.setInt16(t,e,s)}setUint32(t,e,s){this.dv.setUint32(t,e,s)}setInt32(t,e,s){this.dv.setInt32(t,e,s)}setFloat32(t,e,s){this.dv.setFloat32(t,e,s)}setFloat64(t,e,s){this.dv.setFloat64(t,e,s)}setBigUint64(t,e,s){this.dv.setBigUint64(t,e,s)}setBigInt64(t,e,s){this.dv.setBigInt64(t,e,s)}subview(t,e){const s=this.dv.byteOffset+t;return new Ut(this.dv.buffer,s,e)}remaining(t){return this.dv.byteLength-t}getBytes(t,e){const s=e??this.dv.byteLength-t;return new Uint8Array(this.dv.buffer.slice(this.dv.byteOffset+t,this.dv.byteOffset+t+s))}setBytes(t,e){this.u8.set(e,t)}}function gn(r,t,e){return new Ut(r,t,e)}function mn(r,t,e){return t!==void 0&&e!==void 0?new DataView(r,t,e):t!==void 0?new DataView(r,t):new DataView(r)}const Tn="0.1.0";exports.ConnectionState=x;exports.Constants=lr;exports.FileXferState=ge;exports.LzImageType=B;exports.QuicImageType=j;exports.SPICE_CONNECT_TIMEOUT=ts;exports.SPICE_INPUT_MOTION_ACK_BUNCH=_t;exports.SPICE_MAGIC=Nt;exports.SPICE_SURFACE_FLAGS_PRIMARY=ss;exports.SPICE_TICKET_KEY_PAIR_LENGTH=dt;exports.SPICE_TICKET_PUBKEY_BYTES=ft;exports.SPICE_VERSION_MAJOR=$t;exports.SPICE_VERSION_MINOR=es;exports.SpiceAudioDataMode=Xe;exports.SpiceAudioFmt=Et;exports.SpiceBitmap=Vs;exports.SpiceBitmapFlags=Fe;exports.SpiceBitmapFmt=ne;exports.SpiceBrush=Yt;exports.SpiceBrushType=ye;exports.SpiceChannel=p;exports.SpiceChannelId=Fs;exports.SpiceClip=Ve;exports.SpiceClipRects=vs;exports.SpiceClipType=tt;exports.SpiceCommonCap=Be;exports.SpiceConn=Ne;exports.SpiceCopy=kt;exports.SpiceCursor=rt;exports.SpiceCursorConn=cr;exports.SpiceCursorFlags=ve;exports.SpiceCursorHeader=xs;exports.SpiceCursorType=we;exports.SpiceDataView=Ut;exports.SpiceDisplay=qi;exports.SpiceDisplayCap=$;exports.SpiceDisplayConn=rr;exports.SpiceFileXferTask=kr;exports.SpiceFill=Vt;exports.SpiceImage=Lt;exports.SpiceImageDescriptor=vt;exports.SpiceImageFlags=Pe;exports.SpiceImageType=O;exports.SpiceInputsConn=nr;exports.SpiceLinkAuthReply=Wt;exports.SpiceLinkAuthTicket=zs;exports.SpiceLinkErr=ue;exports.SpiceLinkHeader=ut;exports.SpiceLinkMess=Ws;exports.SpiceLinkReply=Hs;exports.SpiceMainCap=ze;exports.SpiceMainConn=hs;exports.SpiceMiniData=z;exports.SpiceMouseButton=ae;exports.SpiceMouseButtonMask=Re;exports.SpiceMouseMode=be;exports.SpiceMsg=pe;exports.SpiceMsgChannels=Xs;exports.SpiceMsgClipboardGrab=qs;exports.SpiceMsgClipboardReceive=Qs;exports.SpiceMsgClipboardRequest=Zs;exports.SpiceMsgClipboardSend=js;exports.SpiceMsgCursor=ee;exports.SpiceMsgCursorInit=Ai;exports.SpiceMsgCursorSet=mi;exports.SpiceMsgDisplay=f;exports.SpiceMsgDisplayBase=Ke;exports.SpiceMsgDisplayCopyBits=fi;exports.SpiceMsgDisplayDrawCopy=li;exports.SpiceMsgDisplayDrawFill=di;exports.SpiceMsgDisplayInvalList=yi;exports.SpiceMsgDisplayStreamActivateReport=Ri;exports.SpiceMsgDisplayStreamClip=wi;exports.SpiceMsgDisplayStreamCreate=Mi;exports.SpiceMsgDisplayStreamData=Di;exports.SpiceMsgDisplayStreamDataSized=qt;exports.SpiceMsgDisplayStreamDestroy=Pi;exports.SpiceMsgInputs=Ye;exports.SpiceMsgInputsInit=Si;exports.SpiceMsgInputsKeyModifiers=pi;exports.SpiceMsgMain=I;exports.SpiceMsgMainAgentData=ei;exports.SpiceMsgMainAgentTokens=Ht;exports.SpiceMsgMainInit=Js;exports.SpiceMsgMainMouseMode=$s;exports.SpiceMsgNotify=hi;exports.SpiceMsgPlayback=oe;exports.SpiceMsgPlaybackData=Ci;exports.SpiceMsgPlaybackMode=Ii;exports.SpiceMsgPlaybackStart=gi;exports.SpiceMsgPort=Ge;exports.SpiceMsgPortInit=Ni;exports.SpiceMsgSetAck=ti;exports.SpiceMsgSurfaceCreate=Ei;exports.SpiceMsgSurfaceDestroy=_i;exports.SpiceMsgc=Te;exports.SpiceMsgcAckSync=si;exports.SpiceMsgcDisplay=et;exports.SpiceMsgcDisplayInit=ui;exports.SpiceMsgcDisplayStreamReport=bi;exports.SpiceMsgcInputs=K;exports.SpiceMsgcKeyDown=Je;exports.SpiceMsgcKeyUp=$e;exports.SpiceMsgcMain=re;exports.SpiceMsgcMainAgentData=ni;exports.SpiceMsgcMainAgentStart=ri;exports.SpiceMsgcMainMouseModeRequest=ii;exports.SpiceMsgcMouseMotion=Ti;exports.SpiceMsgcMousePosition=rs;exports.SpiceMsgcMousePress=pt;exports.SpiceMsgcMouseRelease=At;exports.SpiceMsgcPort=Qe;exports.SpiceNotifySeverity=Ze;exports.SpicePalette=Ys;exports.SpicePattern=ks;exports.SpicePlaybackCap=He;exports.SpicePlaybackConn=hr;exports.SpicePoint=ke;exports.SpicePoint16=st;exports.SpicePortConn=ur;exports.SpiceQMask=it;exports.SpiceQuic=on;exports.SpiceRect=Ce;exports.SpiceResizeHandler=zi;exports.SpiceRopd=ie;exports.SpiceSimulateCursor=Jt;exports.SpiceStreamDataHeader=nt;exports.SpiceSurface=xt;exports.SpiceSurfaceFmt=le;exports.SpiceVideoCodecType=Ue;exports.SpiceWireReader=Oi;exports.VDAgentAnnounceCapabilities=zt;exports.VDAgentFileXferDataMessage=ci;exports.VDAgentFileXferStartMessage=ai;exports.VDAgentFileXferStatusMessage=Xt;exports.VDAgentMonitorsConfig=oi;exports.VD_AGENT_MAX_DATA_SIZE=St;exports.VD_AGENT_PROTOCOL=is;exports.VERSION=Tn;exports.VdAgentCap=Q;exports.VdAgentClipboard=me;exports.VdAgentFileXferStatus=Me;exports.VdAgentMsg=b;exports.WebmAudio=Ki;exports.WebmAudioTrackEntry=vi;exports.WebmCluster=os;exports.WebmConstants=X;exports.WebmHeader=cs;exports.WebmSimpleBlock=as;exports.WebmTracks=ns;exports.WebmVideo=Fi;exports.WebmVideoTrackEntry=Yi;exports.arrayBufferFromUint8Array=Cn;exports.arrayBufferSlice=pn;exports.arrayBuffersEqual=In;exports.concatArrayBuffers=An;exports.convertSpiceBitmapToWeb=ir;exports.convertSpiceLzToWeb=jt;exports.convertSpiceQuicToWeb=sr;exports.createDataView=mn;exports.createRgbaPng=or;exports.createSpiceDataView=gn;exports.handleFileDragover=xi;exports.handleFileDrop=Wi;exports.observeContainerResize=Xi;exports.registerChannelFactory=je;exports.registerSpiceQuicFactory=dr;exports.resizeHelper=us;exports.rsaEncrypt=Vi;exports.useSpice=Xr;
|
|
14
|
+
//# sourceMappingURL=index.cjs.map
|