react-vnc
Version:
A React Component to connect to a websockified VNC client using noVNC.
1,285 lines • 483 kB
JavaScript
import { jsx as En } from "react/jsx-runtime";
import { forwardRef as Xn, useRef as mt, useState as Fn, useImperativeHandle as Cn, useEffect as An } from "react";
function Rn(P) {
return P && P.__esModule && Object.prototype.hasOwnProperty.call(P, "default") ? P.default : P;
}
var Mt = {}, wt = {}, vr;
function dn() {
if (vr) return wt;
vr = 1, Object.defineProperty(wt, "__esModule", {
value: !0
}), wt.toSigned32bit = h, wt.toUnsigned32bit = P;
function P(Y) {
return Y >>> 0;
}
function h(Y) {
return Y | 0;
}
return wt;
}
var Je = {}, yr;
function ht() {
if (yr) return Je;
yr = 1, Object.defineProperty(Je, "__esModule", {
value: !0
}), Je.Warn = Je.Info = Je.Error = Je.Debug = void 0, Je.getLogging = Y, Je.initLogging = h;
var P = "warn";
Je.Debug = function() {
}, Je.Info = function() {
}, Je.Warn = function() {
}, Je.Error = function() {
};
function h(A) {
if (typeof A > "u" ? A = P : P = A, Je.Debug = Je.Info = Je.Warn = Je.Error = function() {
}, typeof window.console < "u")
switch (A) {
case "debug":
Je.Debug = console.debug.bind(window.console);
case "info":
Je.Info = console.info.bind(window.console);
case "warn":
Je.Warn = console.warn.bind(window.console);
case "error":
Je.Error = console.error.bind(window.console);
case "none":
break;
default:
throw new window.Error("invalid logging type '" + A + "'");
}
}
function Y() {
return P;
}
return h(), Je;
}
var kt = {}, xr;
function _n() {
if (xr) return kt;
xr = 1, Object.defineProperty(kt, "__esModule", {
value: !0
}), kt.decodeUTF8 = P, kt.encodeUTF8 = h;
function P(Y) {
var A = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1;
try {
return decodeURIComponent(escape(Y));
} catch (K) {
if (K instanceof URIError && A)
return Y;
throw K;
}
}
function h(Y) {
return unescape(encodeURIComponent(Y));
}
return kt;
}
var Ve = {}, gr;
function Ct() {
if (gr) return Ve;
gr = 1;
function P(S) {
"@babel/helpers - typeof";
return P = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(X) {
return typeof X;
} : function(X) {
return X && typeof Symbol == "function" && X.constructor === Symbol && X !== Symbol.prototype ? "symbol" : typeof X;
}, P(S);
}
Object.defineProperty(Ve, "__esModule", {
value: !0
}), Ve.hasScrollbarGutter = Ve.dragThreshold = void 0, Ve.isAndroid = r, Ve.isBlink = g, Ve.isChrome = n, Ve.isChromeOS = i, Ve.isChromium = c, Ve.isEdge = v, Ve.isFirefox = a, Ve.isGecko = b, Ve.isIOS = f, Ve.isMac = s, Ve.isOpera = x, Ve.isSafari = l, Ve.isTouchDevice = void 0, Ve.isWebKit = y, Ve.isWindows = p, Ve.supportsCursorURIs = void 0;
var h = A(ht());
function Y(S) {
if (typeof WeakMap != "function") return null;
var X = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakMap();
return (Y = function(Q) {
return Q ? F : X;
})(S);
}
function A(S, X) {
if (S && S.__esModule) return S;
if (S === null || P(S) != "object" && typeof S != "function") return { default: S };
var F = Y(X);
if (F && F.has(S)) return F.get(S);
var T = { __proto__: null }, Q = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var D in S) if (D !== "default" && {}.hasOwnProperty.call(S, D)) {
var j = Q ? Object.getOwnPropertyDescriptor(S, D) : null;
j && (j.get || j.set) ? Object.defineProperty(T, D, j) : T[D] = S[D];
}
return T.default = S, F && F.set(S, T), T;
}
Ve.isTouchDevice = "ontouchstart" in document.documentElement || // requried for Chrome debugger
document.ontouchstart !== void 0 || // required for MS Surface
navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0, window.addEventListener("touchstart", function S() {
Ve.isTouchDevice = !0, window.removeEventListener("touchstart", S, !1);
}, !1), Ve.dragThreshold = 10 * (window.devicePixelRatio || 1);
var K = !1;
try {
var I = document.createElement("canvas");
I.style.cursor = 'url("data:image/x-icon;base64,AAACAAEACAgAAAIAAgA4AQAAFgAAACgAAAAIAAAAEAAAAAEAIAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAA==") 2 2, default', I.style.cursor.indexOf("url") === 0 ? (h.Info("Data URI scheme cursor supported"), K = !0) : h.Warn("Data URI scheme cursor not supported");
} catch (S) {
h.Error("Data URI scheme cursor test exception: " + S);
}
Ve.supportsCursorURIs = K;
var L = !0;
try {
var C = document.createElement("div");
C.style.visibility = "hidden", C.style.overflow = "scroll", document.body.appendChild(C);
var u = document.createElement("div");
C.appendChild(u);
var _ = C.offsetWidth - u.offsetWidth;
C.parentNode.removeChild(C), L = _ != 0;
} catch (S) {
h.Error("Scrollbar test exception: " + S);
}
Ve.hasScrollbarGutter = L;
function s() {
return !!/mac/i.exec(navigator.platform);
}
function p() {
return !!/win/i.exec(navigator.platform);
}
function f() {
return !!/ipad/i.exec(navigator.platform) || !!/iphone/i.exec(navigator.platform) || !!/ipod/i.exec(navigator.platform);
}
function r() {
return !!navigator.userAgent.match("Android ");
}
function i() {
return !!navigator.userAgent.match(" CrOS ");
}
function l() {
return !!navigator.userAgent.match("Safari/...") && !navigator.userAgent.match("Chrome/...") && !navigator.userAgent.match("Chromium/...") && !navigator.userAgent.match("Epiphany/...");
}
function a() {
return !!navigator.userAgent.match("Firefox/...") && !navigator.userAgent.match("Seamonkey/...");
}
function n() {
return !!navigator.userAgent.match("Chrome/...") && !navigator.userAgent.match("Chromium/...") && !navigator.userAgent.match("Edg/...") && !navigator.userAgent.match("OPR/...");
}
function c() {
return !!navigator.userAgent.match("Chromium/...");
}
function x() {
return !!navigator.userAgent.match("OPR/...");
}
function v() {
return !!navigator.userAgent.match("Edg/...");
}
function b() {
return !!navigator.userAgent.match("Gecko/...");
}
function y() {
return !!navigator.userAgent.match("AppleWebKit/...") && !navigator.userAgent.match("Chrome/...");
}
function g() {
return !!navigator.userAgent.match("Chrome/...");
}
return Ve;
}
var Xt = {}, br;
function Tn() {
if (br) return Xt;
br = 1, Object.defineProperty(Xt, "__esModule", {
value: !0
}), Xt.clientToElement = P;
function P(h, Y, A) {
var K = A.getBoundingClientRect(), I = {
x: 0,
y: 0
};
return h < K.left ? I.x = 0 : h >= K.right ? I.x = K.width - 1 : I.x = h - K.left, Y < K.top ? I.y = 0 : Y >= K.bottom ? I.y = K.height - 1 : I.y = Y - K.top, I;
}
return Xt;
}
var pt = {}, mr;
function pn() {
if (mr) return pt;
mr = 1, Object.defineProperty(pt, "__esModule", {
value: !0
}), pt.getPointerEvent = P, pt.releaseCapture = u, pt.setCapture = C, pt.stopEvent = h;
function P(_) {
return _.changedTouches ? _.changedTouches[0] : _.touches ? _.touches[0] : _;
}
function h(_) {
_.stopPropagation(), _.preventDefault();
}
var Y = !1, A = null;
document.captureElement = null;
function K(_) {
if (!Y) {
var s = new _.constructor(_.type, _);
Y = !0, document.captureElement ? document.captureElement.dispatchEvent(s) : A.dispatchEvent(s), Y = !1, _.stopPropagation(), s.defaultPrevented && _.preventDefault(), _.type === "mouseup" && u();
}
}
function I() {
var _ = document.getElementById("noVNC_mouse_capture_elem");
_.style.cursor = window.getComputedStyle(document.captureElement).cursor;
}
var L = new MutationObserver(I);
function C(_) {
if (_.setCapture)
_.setCapture(), document.captureElement = _;
else {
u();
var s = document.getElementById("noVNC_mouse_capture_elem");
s === null && (s = document.createElement("div"), s.id = "noVNC_mouse_capture_elem", s.style.position = "fixed", s.style.top = "0px", s.style.left = "0px", s.style.width = "100%", s.style.height = "100%", s.style.zIndex = 1e4, s.style.display = "none", document.body.appendChild(s), s.addEventListener("contextmenu", K), s.addEventListener("mousemove", K), s.addEventListener("mouseup", K)), document.captureElement = _, L.observe(_, {
attributes: !0
}), I(), s.style.display = "", window.addEventListener("mousemove", K), window.addEventListener("mouseup", K);
}
}
function u() {
if (document.releaseCapture)
document.releaseCapture(), document.captureElement = null;
else {
if (!document.captureElement)
return;
A = document.captureElement, document.captureElement = null, L.disconnect();
var _ = document.getElementById("noVNC_mouse_capture_elem");
_.style.display = "none", window.removeEventListener("mousemove", K), window.removeEventListener("mouseup", K);
}
}
return pt;
}
var Dt = {}, wr;
function vn() {
return wr || (wr = 1, function(P) {
Object.defineProperty(P, "__esModule", {
value: !0
}), P.default = void 0;
function h(C) {
"@babel/helpers - typeof";
return h = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(u) {
return typeof u;
} : function(u) {
return u && typeof Symbol == "function" && u.constructor === Symbol && u !== Symbol.prototype ? "symbol" : typeof u;
}, h(C);
}
function Y(C, u) {
if (!(C instanceof u)) throw new TypeError("Cannot call a class as a function");
}
function A(C, u) {
for (var _ = 0; _ < u.length; _++) {
var s = u[_];
s.enumerable = s.enumerable || !1, s.configurable = !0, "value" in s && (s.writable = !0), Object.defineProperty(C, I(s.key), s);
}
}
function K(C, u, _) {
return u && A(C.prototype, u), Object.defineProperty(C, "prototype", { writable: !1 }), C;
}
function I(C) {
var u = L(C, "string");
return h(u) == "symbol" ? u : u + "";
}
function L(C, u) {
if (h(C) != "object" || !C) return C;
var _ = C[Symbol.toPrimitive];
if (_ !== void 0) {
var s = _.call(C, u);
if (h(s) != "object") return s;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return String(C);
}
P.default = /* @__PURE__ */ function() {
function C() {
Y(this, C), this._listeners = /* @__PURE__ */ new Map();
}
return K(C, [{
key: "addEventListener",
value: function(_, s) {
this._listeners.has(_) || this._listeners.set(_, /* @__PURE__ */ new Set()), this._listeners.get(_).add(s);
}
}, {
key: "removeEventListener",
value: function(_, s) {
this._listeners.has(_) && this._listeners.get(_).delete(s);
}
}, {
key: "dispatchEvent",
value: function(_) {
var s = this;
return this._listeners.has(_.type) ? (this._listeners.get(_.type).forEach(function(p) {
return p.call(s, _);
}), !_.defaultPrevented) : !0;
}
}]);
}();
}(Dt)), Dt;
}
var Ot = {}, Bt = {}, kr;
function yn() {
return kr || (kr = 1, function(P) {
function h(I) {
"@babel/helpers - typeof";
return h = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(L) {
return typeof L;
} : function(L) {
return L && typeof Symbol == "function" && L.constructor === Symbol && L !== Symbol.prototype ? "symbol" : typeof L;
}, h(I);
}
Object.defineProperty(P, "__esModule", {
value: !0
}), P.default = void 0;
var Y = K(ht());
function A(I) {
if (typeof WeakMap != "function") return null;
var L = /* @__PURE__ */ new WeakMap(), C = /* @__PURE__ */ new WeakMap();
return (A = function(_) {
return _ ? C : L;
})(I);
}
function K(I, L) {
if (I && I.__esModule) return I;
if (I === null || h(I) != "object" && typeof I != "function") return { default: I };
var C = A(L);
if (C && C.has(I)) return C.get(I);
var u = { __proto__: null }, _ = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var s in I) if (s !== "default" && {}.hasOwnProperty.call(I, s)) {
var p = _ ? Object.getOwnPropertyDescriptor(I, s) : null;
p && (p.get || p.set) ? Object.defineProperty(u, s, p) : u[s] = I[s];
}
return u.default = I, C && C.set(I, u), u;
}
P.default = {
/* Convert data (an array of integers) to a Base64 string. */
toBase64Table: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split(""),
base64Pad: "=",
encode: function(L) {
for (var C = "", u = L.length, _ = u % 3, s = 0; s < u - 2; s += 3)
C += this.toBase64Table[L[s] >> 2], C += this.toBase64Table[((L[s] & 3) << 4) + (L[s + 1] >> 4)], C += this.toBase64Table[((L[s + 1] & 15) << 2) + (L[s + 2] >> 6)], C += this.toBase64Table[L[s + 2] & 63];
var p = u - _;
return _ === 2 ? (C += this.toBase64Table[L[p] >> 2], C += this.toBase64Table[((L[p] & 3) << 4) + (L[p + 1] >> 4)], C += this.toBase64Table[(L[p + 1] & 15) << 2], C += this.toBase64Table[64]) : _ === 1 && (C += this.toBase64Table[L[p] >> 2], C += this.toBase64Table[(L[p] & 3) << 4], C += this.toBase64Table[64], C += this.toBase64Table[64]), C;
},
/* Convert Base64 data to a string */
/* eslint-disable comma-spacing */
toBinaryTable: [-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, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, 0, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1],
/* eslint-enable comma-spacing */
decode: function(L) {
var C = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, u = L.indexOf("=") - C;
u < 0 && (u = L.length - C);
for (var _ = (u >> 2) * 3 + Math.floor(u % 4 / 1.5), s = new Array(_), p = 0, f = 0, r = 0, i = C; i < L.length; i++) {
var l = this.toBinaryTable[L.charCodeAt(i) & 127], a = L.charAt(i) === this.base64Pad;
if (l === -1) {
Y.Error("Illegal character code " + L.charCodeAt(i) + " at position " + i);
continue;
}
f = f << 6 | l, p += 6, p >= 8 && (p -= 8, a || (s[r++] = f >> p & 255), f &= (1 << p) - 1);
}
if (p) {
var n = new Error("Corrupted base64 string");
throw n.name = "Base64-Error", n;
}
return s;
}
};
}(Bt)), Bt;
}
var Sr;
function Pn() {
return Sr || (Sr = 1, function(P) {
Object.defineProperty(P, "__esModule", {
value: !0
}), P.default = void 0;
var h = L(ht()), Y = K(yn()), A = dn();
function K(r) {
return r && r.__esModule ? r : { default: r };
}
function I(r) {
if (typeof WeakMap != "function") return null;
var i = /* @__PURE__ */ new WeakMap(), l = /* @__PURE__ */ new WeakMap();
return (I = function(n) {
return n ? l : i;
})(r);
}
function L(r, i) {
if (r && r.__esModule) return r;
if (r === null || C(r) != "object" && typeof r != "function") return { default: r };
var l = I(i);
if (l && l.has(r)) return l.get(r);
var a = { __proto__: null }, n = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var c in r) if (c !== "default" && {}.hasOwnProperty.call(r, c)) {
var x = n ? Object.getOwnPropertyDescriptor(r, c) : null;
x && (x.get || x.set) ? Object.defineProperty(a, c, x) : a[c] = r[c];
}
return a.default = r, l && l.set(r, a), a;
}
function C(r) {
"@babel/helpers - typeof";
return C = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(i) {
return typeof i;
} : function(i) {
return i && typeof Symbol == "function" && i.constructor === Symbol && i !== Symbol.prototype ? "symbol" : typeof i;
}, C(r);
}
function u(r, i) {
if (!(r instanceof i)) throw new TypeError("Cannot call a class as a function");
}
function _(r, i) {
for (var l = 0; l < i.length; l++) {
var a = i[l];
a.enumerable = a.enumerable || !1, a.configurable = !0, "value" in a && (a.writable = !0), Object.defineProperty(r, p(a.key), a);
}
}
function s(r, i, l) {
return i && _(r.prototype, i), Object.defineProperty(r, "prototype", { writable: !1 }), r;
}
function p(r) {
var i = f(r, "string");
return C(i) == "symbol" ? i : i + "";
}
function f(r, i) {
if (C(r) != "object" || !r) return r;
var l = r[Symbol.toPrimitive];
if (l !== void 0) {
var a = l.call(r, i);
if (C(a) != "object") return a;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return String(r);
}
P.default = /* @__PURE__ */ function() {
function r(i) {
if (u(this, r), this._drawCtx = null, this._renderQ = [], this._flushPromise = null, this._fbWidth = 0, this._fbHeight = 0, this._prevDrawStyle = "", h.Debug(">> Display.constructor"), this._target = i, !this._target)
throw new Error("Target must be set");
if (typeof this._target == "string")
throw new Error("target must be a DOM element");
if (!this._target.getContext)
throw new Error("no getContext method");
this._targetCtx = this._target.getContext("2d"), this._viewportLoc = {
x: 0,
y: 0,
w: this._target.width,
h: this._target.height
}, this._backbuffer = document.createElement("canvas"), this._drawCtx = this._backbuffer.getContext("2d"), this._damageBounds = {
left: 0,
top: 0,
right: this._backbuffer.width,
bottom: this._backbuffer.height
}, h.Debug("User Agent: " + navigator.userAgent), h.Debug("<< Display.constructor"), this._scale = 1, this._clipViewport = !1;
}
return s(r, [{
key: "scale",
get: function() {
return this._scale;
},
set: function(l) {
this._rescale(l);
}
}, {
key: "clipViewport",
get: function() {
return this._clipViewport;
},
set: function(l) {
this._clipViewport = l;
var a = this._viewportLoc;
this.viewportChangeSize(a.w, a.h), this.viewportChangePos(0, 0);
}
}, {
key: "width",
get: function() {
return this._fbWidth;
}
}, {
key: "height",
get: function() {
return this._fbHeight;
}
// ===== PUBLIC METHODS =====
}, {
key: "viewportChangePos",
value: function(l, a) {
var n = this._viewportLoc;
l = Math.floor(l), a = Math.floor(a), this._clipViewport || (l = -n.w, a = -n.h);
var c = n.x + n.w - 1, x = n.y + n.h - 1;
l < 0 && n.x + l < 0 && (l = -n.x), c + l >= this._fbWidth && (l -= c + l - this._fbWidth + 1), n.y + a < 0 && (a = -n.y), x + a >= this._fbHeight && (a -= x + a - this._fbHeight + 1), !(l === 0 && a === 0) && (h.Debug("viewportChange deltaX: " + l + ", deltaY: " + a), n.x += l, n.y += a, this._damage(n.x, n.y, n.w, n.h), this.flip());
}
}, {
key: "viewportChangeSize",
value: function(l, a) {
(!this._clipViewport || typeof l > "u" || typeof a > "u") && (h.Debug("Setting viewport to full display region"), l = this._fbWidth, a = this._fbHeight), l = Math.floor(l), a = Math.floor(a), l > this._fbWidth && (l = this._fbWidth), a > this._fbHeight && (a = this._fbHeight);
var n = this._viewportLoc;
if (n.w !== l || n.h !== a) {
n.w = l, n.h = a;
var c = this._target;
c.width = l, c.height = a, this.viewportChangePos(0, 0), this._damage(n.x, n.y, n.w, n.h), this.flip(), this._rescale(this._scale);
}
}
}, {
key: "absX",
value: function(l) {
return this._scale === 0 ? 0 : (0, A.toSigned32bit)(l / this._scale + this._viewportLoc.x);
}
}, {
key: "absY",
value: function(l) {
return this._scale === 0 ? 0 : (0, A.toSigned32bit)(l / this._scale + this._viewportLoc.y);
}
}, {
key: "resize",
value: function(l, a) {
this._prevDrawStyle = "", this._fbWidth = l, this._fbHeight = a;
var n = this._backbuffer;
if (n.width !== l || n.height !== a) {
var c = null;
n.width > 0 && n.height > 0 && (c = this._drawCtx.getImageData(0, 0, n.width, n.height)), n.width !== l && (n.width = l), n.height !== a && (n.height = a), c && this._drawCtx.putImageData(c, 0, 0);
}
var x = this._viewportLoc;
this.viewportChangeSize(x.w, x.h), this.viewportChangePos(0, 0);
}
}, {
key: "getImageData",
value: function() {
return this._drawCtx.getImageData(0, 0, this.width, this.height);
}
}, {
key: "toDataURL",
value: function(l, a) {
return this._backbuffer.toDataURL(l, a);
}
}, {
key: "toBlob",
value: function(l, a, n) {
return this._backbuffer.toBlob(l, a, n);
}
// Track what parts of the visible canvas that need updating
}, {
key: "_damage",
value: function(l, a, n, c) {
l < this._damageBounds.left && (this._damageBounds.left = l), a < this._damageBounds.top && (this._damageBounds.top = a), l + n > this._damageBounds.right && (this._damageBounds.right = l + n), a + c > this._damageBounds.bottom && (this._damageBounds.bottom = a + c);
}
// Update the visible canvas with the contents of the
// rendering canvas
}, {
key: "flip",
value: function(l) {
if (this._renderQ.length !== 0 && !l)
this._renderQPush({
type: "flip"
});
else {
var a = this._damageBounds.left, n = this._damageBounds.top, c = this._damageBounds.right - a, x = this._damageBounds.bottom - n, v = a - this._viewportLoc.x, b = n - this._viewportLoc.y;
v < 0 && (c += v, a -= v, v = 0), b < 0 && (x += b, n -= b, b = 0), v + c > this._viewportLoc.w && (c = this._viewportLoc.w - v), b + x > this._viewportLoc.h && (x = this._viewportLoc.h - b), c > 0 && x > 0 && this._targetCtx.drawImage(this._backbuffer, a, n, c, x, v, b, c, x), this._damageBounds.left = this._damageBounds.top = 65535, this._damageBounds.right = this._damageBounds.bottom = 0;
}
}
}, {
key: "pending",
value: function() {
return this._renderQ.length > 0;
}
}, {
key: "flush",
value: function() {
var l = this;
return this._renderQ.length === 0 ? Promise.resolve() : (this._flushPromise === null && (this._flushPromise = new Promise(function(a) {
l._flushResolve = a;
})), this._flushPromise);
}
}, {
key: "fillRect",
value: function(l, a, n, c, x, v) {
this._renderQ.length !== 0 && !v ? this._renderQPush({
type: "fill",
x: l,
y: a,
width: n,
height: c,
color: x
}) : (this._setFillColor(x), this._drawCtx.fillRect(l, a, n, c), this._damage(l, a, n, c));
}
}, {
key: "copyImage",
value: function(l, a, n, c, x, v, b) {
this._renderQ.length !== 0 && !b ? this._renderQPush({
type: "copy",
oldX: l,
oldY: a,
x: n,
y: c,
width: x,
height: v
}) : (this._drawCtx.mozImageSmoothingEnabled = !1, this._drawCtx.webkitImageSmoothingEnabled = !1, this._drawCtx.msImageSmoothingEnabled = !1, this._drawCtx.imageSmoothingEnabled = !1, this._drawCtx.drawImage(this._backbuffer, l, a, x, v, n, c, x, v), this._damage(n, c, x, v));
}
}, {
key: "imageRect",
value: function(l, a, n, c, x, v) {
if (!(n === 0 || c === 0)) {
var b = new Image();
b.src = "data: " + x + ";base64," + Y.default.encode(v), this._renderQPush({
type: "img",
img: b,
x: l,
y: a,
width: n,
height: c
});
}
}
}, {
key: "blitImage",
value: function(l, a, n, c, x, v, b) {
if (this._renderQ.length !== 0 && !b) {
var y = new Uint8Array(n * c * 4);
y.set(new Uint8Array(x.buffer, 0, y.length)), this._renderQPush({
type: "blit",
data: y,
x: l,
y: a,
width: n,
height: c
});
} else {
var g = new Uint8ClampedArray(x.buffer, x.byteOffset + v, n * c * 4), S = new ImageData(g, n, c);
this._drawCtx.putImageData(S, l, a), this._damage(l, a, n, c);
}
}
}, {
key: "drawImage",
value: function(l, a, n) {
this._drawCtx.drawImage(l, a, n), this._damage(a, n, l.width, l.height);
}
}, {
key: "autoscale",
value: function(l, a) {
var n;
if (l === 0 || a === 0)
n = 0;
else {
var c = this._viewportLoc, x = l / a, v = c.w / c.h;
v >= x ? n = l / c.w : n = a / c.h;
}
this._rescale(n);
}
// ===== PRIVATE METHODS =====
}, {
key: "_rescale",
value: function(l) {
this._scale = l;
var a = this._viewportLoc, n = l * a.w + "px", c = l * a.h + "px";
(this._target.style.width !== n || this._target.style.height !== c) && (this._target.style.width = n, this._target.style.height = c);
}
}, {
key: "_setFillColor",
value: function(l) {
var a = "rgb(" + l[0] + "," + l[1] + "," + l[2] + ")";
a !== this._prevDrawStyle && (this._drawCtx.fillStyle = a, this._prevDrawStyle = a);
}
}, {
key: "_renderQPush",
value: function(l) {
this._renderQ.push(l), this._renderQ.length === 1 && this._scanRenderQ();
}
}, {
key: "_resumeRenderQ",
value: function() {
this.removeEventListener("load", this._noVNCDisplay._resumeRenderQ), this._noVNCDisplay._scanRenderQ();
}
}, {
key: "_scanRenderQ",
value: function() {
for (var l = !0; l && this._renderQ.length > 0; ) {
var a = this._renderQ[0];
switch (a.type) {
case "flip":
this.flip(!0);
break;
case "copy":
this.copyImage(a.oldX, a.oldY, a.x, a.y, a.width, a.height, !0);
break;
case "fill":
this.fillRect(a.x, a.y, a.width, a.height, a.color, !0);
break;
case "blit":
this.blitImage(a.x, a.y, a.width, a.height, a.data, 0, !0);
break;
case "img":
if (a.img.complete) {
if (a.img.width !== a.width || a.img.height !== a.height) {
h.Error("Decoded image has incorrect dimensions. Got " + a.img.width + "x" + a.img.height + ". Expected " + a.width + "x" + a.height + ".");
return;
}
this.drawImage(a.img, a.x, a.y);
} else
a.img._noVNCDisplay = this, a.img.addEventListener("load", this._resumeRenderQ), l = !1;
break;
}
l && this._renderQ.shift();
}
this._renderQ.length === 0 && this._flushPromise !== null && (this._flushResolve(), this._flushPromise = null, this._flushResolve = null);
}
}]);
}();
}(Ot)), Ot;
}
var Qt = {}, He = {}, st = {}, Kr;
function At() {
if (Kr) return st;
Kr = 1, Object.defineProperty(st, "__esModule", {
value: !0
}), st.Buf8 = st.Buf32 = st.Buf16 = void 0, st.arraySet = h, st.flattenChunks = Y, st.shrinkBuf = P;
function P(A, K) {
return A.length === K ? A : A.subarray ? A.subarray(0, K) : (A.length = K, A);
}
function h(A, K, I, L, C) {
if (K.subarray && A.subarray) {
A.set(K.subarray(I, I + L), C);
return;
}
for (var u = 0; u < L; u++)
A[C + u] = K[I + u];
}
function Y(A) {
var K, I, L, C, u, _;
for (L = 0, K = 0, I = A.length; K < I; K++)
L += A[K].length;
for (_ = new Uint8Array(L), C = 0, K = 0, I = A.length; K < I; K++)
u = A[K], _.set(u, C), C += u.length;
return _;
}
return st.Buf8 = Uint8Array, st.Buf16 = Uint16Array, st.Buf32 = Int32Array, st;
}
var It = {}, Er;
function xn() {
return Er || (Er = 1, function(P) {
Object.defineProperty(P, "__esModule", {
value: !0
}), P.default = h;
function h(Y, A, K, I) {
for (var L = Y & 65535 | 0, C = Y >>> 16 & 65535 | 0, u = 0; K !== 0; ) {
u = K > 2e3 ? 2e3 : K, K -= u;
do
L = L + A[I++] | 0, C = C + L | 0;
while (--u);
L %= 65521, C %= 65521;
}
return L | C << 16 | 0;
}
}(It)), It;
}
var Ut = {}, Xr;
function gn() {
return Xr || (Xr = 1, function(P) {
Object.defineProperty(P, "__esModule", {
value: !0
}), P.default = h;
function h() {
for (var Y, A = [], K = 0; K < 256; K++) {
Y = K;
for (var I = 0; I < 8; I++)
Y = Y & 1 ? 3988292384 ^ Y >>> 1 : Y >>> 1;
A[K] = Y;
}
return A;
}
h();
}(Ut)), Ut;
}
var Nt = {}, Fr;
function Ln() {
return Fr || (Fr = 1, function(P) {
Object.defineProperty(P, "__esModule", {
value: !0
}), P.default = A;
var h = 30, Y = 12;
function A(K, I) {
var L, C, u, _, s, p, f, r, i, l, a, n, c, x, v, b, y, g, S, X, F, T, Q, D, j;
L = K.state, C = K.next_in, D = K.input, u = C + (K.avail_in - 5), _ = K.next_out, j = K.output, s = _ - (I - K.avail_out), p = _ + (K.avail_out - 257), f = L.dmax, r = L.wsize, i = L.whave, l = L.wnext, a = L.window, n = L.hold, c = L.bits, x = L.lencode, v = L.distcode, b = (1 << L.lenbits) - 1, y = (1 << L.distbits) - 1;
e: do {
c < 15 && (n += D[C++] << c, c += 8, n += D[C++] << c, c += 8), g = x[n & b];
t: for (; ; ) {
if (S = g >>> 24, n >>>= S, c -= S, S = g >>> 16 & 255, S === 0)
j[_++] = g & 65535;
else if (S & 16) {
X = g & 65535, S &= 15, S && (c < S && (n += D[C++] << c, c += 8), X += n & (1 << S) - 1, n >>>= S, c -= S), c < 15 && (n += D[C++] << c, c += 8, n += D[C++] << c, c += 8), g = v[n & y];
r: for (; ; ) {
if (S = g >>> 24, n >>>= S, c -= S, S = g >>> 16 & 255, S & 16) {
if (F = g & 65535, S &= 15, c < S && (n += D[C++] << c, c += 8, c < S && (n += D[C++] << c, c += 8)), F += n & (1 << S) - 1, F > f) {
K.msg = "invalid distance too far back", L.mode = h;
break e;
}
if (n >>>= S, c -= S, S = _ - s, F > S) {
if (S = F - S, S > i && L.sane) {
K.msg = "invalid distance too far back", L.mode = h;
break e;
}
if (T = 0, Q = a, l === 0) {
if (T += r - S, S < X) {
X -= S;
do
j[_++] = a[T++];
while (--S);
T = _ - F, Q = j;
}
} else if (l < S) {
if (T += r + l - S, S -= l, S < X) {
X -= S;
do
j[_++] = a[T++];
while (--S);
if (T = 0, l < X) {
S = l, X -= S;
do
j[_++] = a[T++];
while (--S);
T = _ - F, Q = j;
}
}
} else if (T += l - S, S < X) {
X -= S;
do
j[_++] = a[T++];
while (--S);
T = _ - F, Q = j;
}
for (; X > 2; )
j[_++] = Q[T++], j[_++] = Q[T++], j[_++] = Q[T++], X -= 3;
X && (j[_++] = Q[T++], X > 1 && (j[_++] = Q[T++]));
} else {
T = _ - F;
do
j[_++] = j[T++], j[_++] = j[T++], j[_++] = j[T++], X -= 3;
while (X > 2);
X && (j[_++] = j[T++], X > 1 && (j[_++] = j[T++]));
}
} else if ((S & 64) === 0) {
g = v[(g & 65535) + (n & (1 << S) - 1)];
continue r;
} else {
K.msg = "invalid distance code", L.mode = h;
break e;
}
break;
}
} else if ((S & 64) === 0) {
g = x[(g & 65535) + (n & (1 << S) - 1)];
continue t;
} else if (S & 32) {
L.mode = Y;
break e;
} else {
K.msg = "invalid literal/length code", L.mode = h;
break e;
}
break;
}
} while (C < u && _ < p);
X = c >> 3, C -= X, c -= X << 3, n &= (1 << c) - 1, K.next_in = C, K.next_out = _, K.avail_in = C < u ? 5 + (u - C) : 5 - (C - u), K.avail_out = _ < p ? 257 + (p - _) : 257 - (_ - p), L.hold = n, L.bits = c;
}
}(Nt)), Nt;
}
var jt = {}, Cr;
function Mn() {
return Cr || (Cr = 1, function(P) {
function h(a) {
"@babel/helpers - typeof";
return h = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
return typeof n;
} : function(n) {
return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
}, h(a);
}
Object.defineProperty(P, "__esModule", {
value: !0
}), P.default = l;
var Y = K(At());
function A(a) {
if (typeof WeakMap != "function") return null;
var n = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap();
return (A = function(v) {
return v ? c : n;
})(a);
}
function K(a, n) {
if (a && a.__esModule) return a;
if (a === null || h(a) != "object" && typeof a != "function") return { default: a };
var c = A(n);
if (c && c.has(a)) return c.get(a);
var x = { __proto__: null }, v = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var b in a) if (b !== "default" && {}.hasOwnProperty.call(a, b)) {
var y = v ? Object.getOwnPropertyDescriptor(a, b) : null;
y && (y.get || y.set) ? Object.defineProperty(x, b, y) : x[b] = a[b];
}
return x.default = a, c && c.set(a, x), x;
}
var I = 15, L = 852, C = 592, u = 0, _ = 1, s = 2, p = [
/* Length codes 257..285 base */
3,
4,
5,
6,
7,
8,
9,
10,
11,
13,
15,
17,
19,
23,
27,
31,
35,
43,
51,
59,
67,
83,
99,
115,
131,
163,
195,
227,
258,
0,
0
], f = [
/* Length codes 257..285 extra */
16,
16,
16,
16,
16,
16,
16,
16,
17,
17,
17,
17,
18,
18,
18,
18,
19,
19,
19,
19,
20,
20,
20,
20,
21,
21,
21,
21,
16,
72,
78
], r = [
/* Distance codes 0..29 base */
1,
2,
3,
4,
5,
7,
9,
13,
17,
25,
33,
49,
65,
97,
129,
193,
257,
385,
513,
769,
1025,
1537,
2049,
3073,
4097,
6145,
8193,
12289,
16385,
24577,
0,
0
], i = [
/* Distance codes 0..29 extra */
16,
16,
16,
16,
17,
17,
18,
18,
19,
19,
20,
20,
21,
21,
22,
22,
23,
23,
24,
24,
25,
25,
26,
26,
27,
27,
28,
28,
29,
29,
64,
64
];
function l(a, n, c, x, v, b, y, g) {
var S = g.bits, X = 0, F = 0, T = 0, Q = 0, D = 0, j = 0, te = 0, de = 0, ge = 0, ve = 0, Ke, Ee, _e, Se, Ae, Oe = null, J = 0, $, re = new Y.Buf16(I + 1), z = new Y.Buf16(I + 1), O = null, U = 0, se, ue, H;
for (X = 0; X <= I; X++)
re[X] = 0;
for (F = 0; F < x; F++)
re[n[c + F]]++;
for (D = S, Q = I; Q >= 1 && re[Q] === 0; Q--)
;
if (D > Q && (D = Q), Q === 0)
return v[b++] = 1 << 24 | 64 << 16 | 0, v[b++] = 1 << 24 | 64 << 16 | 0, g.bits = 1, 0;
for (T = 1; T < Q && re[T] === 0; T++)
;
for (D < T && (D = T), de = 1, X = 1; X <= I; X++)
if (de <<= 1, de -= re[X], de < 0)
return -1;
if (de > 0 && (a === u || Q !== 1))
return -1;
for (z[1] = 0, X = 1; X < I; X++)
z[X + 1] = z[X] + re[X];
for (F = 0; F < x; F++)
n[c + F] !== 0 && (y[z[n[c + F]]++] = F);
if (a === u ? (Oe = O = y, $ = 19) : a === _ ? (Oe = p, J -= 257, O = f, U -= 257, $ = 256) : (Oe = r, O = i, $ = -1), ve = 0, F = 0, X = T, Ae = b, j = D, te = 0, _e = -1, ge = 1 << D, Se = ge - 1, a === _ && ge > L || a === s && ge > C)
return 1;
for (; ; ) {
se = X - te, y[F] < $ ? (ue = 0, H = y[F]) : y[F] > $ ? (ue = O[U + y[F]], H = Oe[J + y[F]]) : (ue = 96, H = 0), Ke = 1 << X - te, Ee = 1 << j, T = Ee;
do
Ee -= Ke, v[Ae + (ve >> te) + Ee] = se << 24 | ue << 16 | H | 0;
while (Ee !== 0);
for (Ke = 1 << X - 1; ve & Ke; )
Ke >>= 1;
if (Ke !== 0 ? (ve &= Ke - 1, ve += Ke) : ve = 0, F++, --re[X] === 0) {
if (X === Q)
break;
X = n[c + y[F]];
}
if (X > D && (ve & Se) !== _e) {
for (te === 0 && (te = D), Ae += T, j = X - te, de = 1 << j; j + te < Q && (de -= re[j + te], !(de <= 0)); )
j++, de <<= 1;
if (ge += 1 << j, a === _ && ge > L || a === s && ge > C)
return 1;
_e = ve & Se, v[_e] = D << 24 | j << 16 | Ae - b | 0;
}
}
return ve !== 0 && (v[Ae + ve] = X - te << 24 | 64 << 16 | 0), g.bits = D, 0;
}
}(jt)), jt;
}
var Ar;
function Dn() {
if (Ar) return He;
Ar = 1;
function P(R) {
"@babel/helpers - typeof";
return P = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(Z) {
return typeof Z;
} : function(Z) {
return Z && typeof Symbol == "function" && Z.constructor === Symbol && Z !== Symbol.prototype ? "symbol" : typeof Z;
}, P(R);
}
Object.defineProperty(He, "__esModule", {
value: !0
}), He.Z_TREES = He.Z_STREAM_ERROR = He.Z_STREAM_END = He.Z_OK = He.Z_NEED_DICT = He.Z_MEM_ERROR = He.Z_FINISH = He.Z_DEFLATED = He.Z_DATA_ERROR = He.Z_BUF_ERROR = He.Z_BLOCK = void 0, He.inflate = oe, He.inflateEnd = fe, He.inflateGetHeader = ye, He.inflateInfo = void 0, He.inflateInit = Ze, He.inflateInit2 = We, He.inflateReset = qe, He.inflateReset2 = xe, He.inflateResetKeep = je, He.inflateSetDictionary = Ce;
var h = u(At()), Y = L(xn()), A = L(gn()), K = L(Ln()), I = L(Mn());
function L(R) {
return R && R.__esModule ? R : { default: R };
}
function C(R) {
if (typeof WeakMap != "function") return null;
var Z = /* @__PURE__ */ new WeakMap(), w = /* @__PURE__ */ new WeakMap();
return (C = function(Xe) {
return Xe ? w : Z;
})(R);
}
function u(R, Z) {
if (R && R.__esModule) return R;
if (R === null || P(R) != "object" && typeof R != "function") return { default: R };
var w = C(Z);
if (w && w.has(R)) return w.get(R);
var he = { __proto__: null }, Xe = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var e in R) if (e !== "default" && {}.hasOwnProperty.call(R, e)) {
var k = Xe ? Object.getOwnPropertyDescriptor(R, e) : null;
k && (k.get || k.set) ? Object.defineProperty(he, e, k) : he[e] = R[e];
}
return he.default = R, w && w.set(R, he), he;
}
var _ = 0, s = 1, p = 2, f = He.Z_FINISH = 4, r = He.Z_BLOCK = 5, i = He.Z_TREES = 6, l = He.Z_OK = 0, a = He.Z_STREAM_END = 1, n = He.Z_NEED_DICT = 2, c = He.Z_STREAM_ERROR = -2, x = He.Z_DATA_ERROR = -3, v = He.Z_MEM_ERROR = -4, b = He.Z_BUF_ERROR = -5, y = He.Z_DEFLATED = 8, g = 1, S = 2, X = 3, F = 4, T = 5, Q = 6, D = 7, j = 8, te = 9, de = 10, ge = 11, ve = 12, Ke = 13, Ee = 14, _e = 15, Se = 16, Ae = 17, Oe = 18, J = 19, $ = 20, re = 21, z = 22, O = 23, U = 24, se = 25, ue = 26, H = 27, W = 28, ee = 29, ne = 30, be = 31, V = 32, q = 852, ie = 592, ce = 15, B = ce;
function le(R) {
return (R >>> 24 & 255) + (R >>> 8 & 65280) + ((R & 65280) << 8) + ((R & 255) << 24);
}
function Te() {
this.mode = 0, this.last = !1, this.wrap = 0, this.havedict = !1, this.flags = 0, this.dmax = 0, this.check = 0, this.total = 0, this.head = null, this.wbits = 0, this.wsize = 0, this.whave = 0, this.wnext = 0, this.window = null, this.hold = 0, this.bits = 0, this.length = 0, this.offset = 0, this.extra = 0, this.lencode = null, this.distcode = null, this.lenbits = 0, this.distbits = 0, this.ncode = 0, this.nlen = 0, this.ndist = 0, this.have = 0, this.next = null, this.lens = new h.Buf16(320), this.work = new h.Buf16(288), this.lendyn = null, this.distdyn = null, this.sane = 0, this.back = 0, this.was = 0;
}
function je(R) {
var Z;
return !R || !R.state ? c : (Z = R.state, R.total_in = R.total_out = Z.total = 0, R.msg = "", Z.wrap && (R.adler = Z.wrap & 1), Z.mode = g, Z.last = 0, Z.havedict = 0, Z.dmax = 32768, Z.head = null, Z.hold = 0, Z.bits = 0, Z.lencode = Z.lendyn = new h.Buf32(q), Z.distcode = Z.distdyn = new h.Buf32(ie), Z.sane = 1, Z.back = -1, l);
}
function qe(R) {
var Z;
return !R || !R.state ? c : (Z = R.state, Z.wsize = 0, Z.whave = 0, Z.wnext = 0, je(R));
}
function xe(R, Z) {
var w, he;
return !R || !R.state || (he = R.state, Z < 0 ? (w = 0, Z = -Z) : (w = (Z >> 4) + 1, Z < 48 && (Z &= 15)), Z && (Z < 8 || Z > 15)) ? c : (he.window !== null && he.wbits !== Z && (he.window = null), he.wrap = w, he.wbits = Z, qe(R));
}
function We(R, Z) {
var w, he;
return R ? (he = new Te(), R.state = he, he.window = null, w = xe(R, Z), w !== l && (R.state = null), w) : c;
}
function Ze(R) {
return We(R, B);
}
var lt = !0, ut, tt;
function at(R) {
if (lt) {
var Z;
for (ut = new h.Buf32(512), tt = new h.Buf32(32), Z = 0; Z < 144; )
R.lens[Z++] = 8;
for (; Z < 256; )
R.lens[Z++] = 9;
for (; Z < 280; )
R.lens[Z++] = 7;
for (; Z < 288; )
R.lens[Z++] = 8;
for ((0, I.default)(s, R.lens, 0, 288, ut, 0, R.work, {
bits: 9
}), Z = 0; Z < 32; )
R.lens[Z++] = 5;
(0, I.default)(p, R.lens, 0, 32, tt, 0, R.work, {
bits: 5
}), lt = !1;
}
R.lencode = ut, R.lenbits = 9, R.distcode = tt, R.distbits = 5;
}
function E(R, Z, w, he) {
var Xe, e = R.state;
return e.window === null && (e.wsize = 1 << e.wbits, e.wnext = 0, e.whave = 0, e.window = new h.Buf8(e.wsize)), he >= e.wsize ? (h.arraySet(e.window, Z, w - e.wsize, e.wsize, 0), e.wnext = 0, e.whave = e.wsize) : (Xe = e.wsize - e.wnext, Xe > he && (Xe = he), h.arraySet(e.window, Z, w - he, Xe, e.wnext), he -= Xe, he ? (h.arraySet(e.window, Z, w - he, he, 0), e.wnext = he, e.whave = e.wsize) : (e.wnext += Xe, e.wnext === e.wsize && (e.wnext = 0), e.whave < e.wsize && (e.whave += Xe))), 0;
}
function oe(R, Z) {
var w, he, Xe, e, k, m, t, d, o, M, N, G, ae, Le, Pe = 0, Fe, Re, Be, ke, Ie, Ye, Ge, Ne, ze = new h.Buf8(4), et, rt, ot = (
/* permutation of code lengths */
[16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]
);
if (!R || !R.state || !R.output || !R.input && R.avail_in !== 0)
return c;
w = R.state, w.mode === ve && (w.mode = Ke), k = R.next_out, Xe = R.output, t = R.avail_out, e = R.next_in, he = R.input, m = R.avail_in, d = w.hold, o = w.bits, M = m, N = t, Ne = l;
e:
for (; ; )
switch (w.mode) {
case g:
if (w.wrap === 0) {
w.mode = Ke;
break;
}
for (; o < 16; ) {
if (m === 0)
break e;
m--, d += he[e++] << o, o += 8;
}
if (w.wrap & 2 && d === 35615) {
w.check = 0, ze[0] = d & 255, ze[1] = d >>> 8 & 255, w.check = (0, A.default)(w.check, ze, 2, 0), d = 0, o = 0, w.mode = S;
break;
}
if (w.flags = 0, w.head && (w.head.done = !1), !(w.wrap & 1) || /* check if zlib header allowed */
(((d & 255) << 8) + (d >> 8)) % 31) {
R.msg = "incorrect header check", w.mode = ne;
break;
}
if ((d & 15) !== y) {
R.msg = "unknown compression method", w.mode = ne;
break;
}
if (d >>>= 4, o -= 4, Ge = (d & 15) + 8, w.wbits === 0)
w.wbits = Ge;
else if (Ge > w.wbits) {
R.msg = "invalid window size", w.mode = ne;
break;
}
w.dmax = 1 << Ge, R.adler = w.check = 1, w.mode = d & 512 ? de : ve, d = 0, o = 0;
break;
case S:
for (; o < 16; ) {
if (m === 0)
break e;
m--, d += he[e++] << o, o += 8;
}
if (w.flags = d, (w.flags & 255) !== y) {
R.msg = "unknown compression method", w.mode = ne;
break;
}
if (w.flags & 57344) {
R.msg = "unknown header flags set", w.mode = ne;
break;
}
w.head && (w.head.text = d >> 8 & 1), w.flags & 512 && (ze[0] = d & 255, ze[1] = d >>> 8 & 255, w.check = (0, A.default)(w.check, ze, 2, 0)), d = 0, o = 0, w.mode = X;
/* falls through */
case X:
for (; o < 32; ) {
if (m === 0)
break e;
m--, d += he[e++] << o, o += 8;
}
w.head && (w.head.time = d), w.flags & 512 && (ze[0] = d & 255, ze[1] = d >>> 8 & 255, ze[2] = d >>> 16 & 255, ze[3] = d >>> 24 & 255, w.check = (0, A.default)(w.check, ze, 4, 0)), d = 0, o = 0, w.mode = F;
/* falls through */
case F:
for (; o < 16; ) {
if (m === 0)
break e;
m--, d += he[e++] << o, o += 8;
}
w.head && (w.head.xflags = d & 255, w.head.os = d >> 8), w.flags & 512 && (ze[0] = d & 255, ze[1] = d >>> 8 & 255, w.check = (0, A.default)(w.check, ze, 2, 0)), d = 0, o = 0, w.mode = T;
/* falls through */
case T:
if (w.flags & 1024) {
for (; o < 16; ) {
if (m === 0)
break e;
m--, d += he[e++] << o, o += 8;
}
w.length = d, w.head && (w.head.extra_len = d), w.flags & 512 && (ze[0] = d & 255, ze[1] = d >>> 8 & 255, w.check = (0, A.default)(w.check, ze, 2, 0)), d = 0, o = 0;
} else w.head && (w.head.extra = null);
w.mode = Q;
/* falls through */
case Q:
if (w.flags & 1024 && (G = w.length, G > m && (G = m), G && (w.head && (Ge = w.head.extra_len - w.length, w.head.extra || (w.head.extra = new Array(w.head.extra_len)), h.arraySet(
w.head.extra,
he,
e,
// extra field is limited to 65536 bytes
// - no need for additional size check
G,
/*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/
Ge
)), w.flags & 512 && (w.check = (0, A.default)(w.check, he, G, e)), m -= G, e += G, w.length -= G), w.length))
break e;
w.length = 0, w.mode = D;
/* falls through */
case D:
if (w.flags & 2048) {
if (m === 0)
break e;
G = 0;
do
Ge = he[e + G++], w.head && Ge && w.length < 65536 && (w.head.name += String.fromCharCode(Ge));
while (Ge && G < m);
if (w.flags & 512 && (w.check = (0, A.default)(w.check, he, G, e)), m -= G, e += G, Ge)
break e