UNPKG

react-together

Version:

A library to seamlessly add real-time multi-user interaction to your React app!

713 lines (712 loc) 26.5 kB
import { jsxs as b, Fragment as te, jsx as M } from "react/jsx-runtime"; import "primeicons/primeicons.css"; import { Dialog as oe } from "primereact/dialog"; import w, { useState as F, useCallback as L } from "react"; import "@croquet/react"; import "primereact/avatar"; import "primereact/avatargroup"; import { d as ne, e as re } from "../index-37cec024.js"; import "./HoverHighlighter.js"; import "../context/ReactTogetherContext.js"; import "../models/ReactTogetherModel.js"; import "unique-names-generator"; import '../assets/Cursors.css';import '../assets/Chat.css';import '../assets/SessionManager.css';/* empty css *//* empty css */import "object-hash"; import "../models/ChatModel.js"; import { Icons as se } from "./icons.js"; import ie from "../hooks/useLeaveSession.js"; import le from "../hooks/useCreateRandomSession.js"; var ae = Object.defineProperty, O = Object.getOwnPropertySymbols, Q = Object.prototype.hasOwnProperty, H = Object.prototype.propertyIsEnumerable, k = (h, r, a) => r in h ? ae(h, r, { enumerable: !0, configurable: !0, writable: !0, value: a }) : h[r] = a, S = (h, r) => { for (var a in r || (r = {})) Q.call(r, a) && k(h, a, r[a]); if (O) for (var a of O(r)) H.call(r, a) && k(h, a, r[a]); return h; }, T = (h, r) => { var a = {}; for (var i in h) Q.call(h, i) && r.indexOf(i) < 0 && (a[i] = h[i]); if (h != null && O) for (var i of O(h)) r.indexOf(i) < 0 && H.call(h, i) && (a[i] = h[i]); return a; }; /** * @license QR Code generator library (TypeScript) * Copyright (c) Project Nayuki. * SPDX-License-Identifier: MIT */ var _; ((h) => { const r = class { constructor(e, t, o, n) { if (this.version = e, this.errorCorrectionLevel = t, this.modules = [], this.isFunction = [], e < r.MIN_VERSION || e > r.MAX_VERSION) throw new RangeError("Version value out of range"); if (n < -1 || n > 7) throw new RangeError("Mask value out of range"); this.size = e * 4 + 17; let s = []; for (let l = 0; l < this.size; l++) s.push(!1); for (let l = 0; l < this.size; l++) this.modules.push(s.slice()), this.isFunction.push(s.slice()); this.drawFunctionPatterns(); const c = this.addEccAndInterleave(o); if (this.drawCodewords(c), n == -1) { let l = 1e9; for (let E = 0; E < 8; E++) { this.applyMask(E), this.drawFormatBits(E); const f = this.getPenaltyScore(); f < l && (n = E, l = f), this.applyMask(E); } } u(0 <= n && n <= 7), this.mask = n, this.applyMask(n), this.drawFormatBits(n), this.isFunction = []; } static encodeText(e, t) { const o = h.QrSegment.makeSegments(e); return r.encodeSegments(o, t); } static encodeBinary(e, t) { const o = h.QrSegment.makeBytes(e); return r.encodeSegments([o], t); } static encodeSegments(e, t, o = 1, n = 40, s = -1, c = !0) { if (!(r.MIN_VERSION <= o && o <= n && n <= r.MAX_VERSION) || s < -1 || s > 7) throw new RangeError("Invalid value"); let l, E; for (l = o; ; l++) { const m = r.getNumDataCodewords(l, t) * 8, p = g.getTotalBits(e, l); if (p <= m) { E = p; break; } if (l >= n) throw new RangeError("Data too long"); } for (const m of [r.Ecc.MEDIUM, r.Ecc.QUARTILE, r.Ecc.HIGH]) c && E <= r.getNumDataCodewords(l, m) * 8 && (t = m); let f = []; for (const m of e) { i(m.mode.modeBits, 4, f), i(m.numChars, m.mode.numCharCountBits(l), f); for (const p of m.getData()) f.push(p); } u(f.length == E); const N = r.getNumDataCodewords(l, t) * 8; u(f.length <= N), i(0, Math.min(4, N - f.length), f), i(0, (8 - f.length % 8) % 8, f), u(f.length % 8 == 0); for (let m = 236; f.length < N; m ^= 253) i(m, 8, f); let v = []; for (; v.length * 8 < f.length; ) v.push(0); return f.forEach((m, p) => v[p >>> 3] |= m << 7 - (p & 7)), new r(l, t, v, s); } getModule(e, t) { return 0 <= e && e < this.size && 0 <= t && t < this.size && this.modules[t][e]; } getModules() { return this.modules; } drawFunctionPatterns() { for (let o = 0; o < this.size; o++) this.setFunctionModule(6, o, o % 2 == 0), this.setFunctionModule(o, 6, o % 2 == 0); this.drawFinderPattern(3, 3), this.drawFinderPattern(this.size - 4, 3), this.drawFinderPattern(3, this.size - 4); const e = this.getAlignmentPatternPositions(), t = e.length; for (let o = 0; o < t; o++) for (let n = 0; n < t; n++) o == 0 && n == 0 || o == 0 && n == t - 1 || o == t - 1 && n == 0 || this.drawAlignmentPattern(e[o], e[n]); this.drawFormatBits(0), this.drawVersion(); } drawFormatBits(e) { const t = this.errorCorrectionLevel.formatBits << 3 | e; let o = t; for (let s = 0; s < 10; s++) o = o << 1 ^ (o >>> 9) * 1335; const n = (t << 10 | o) ^ 21522; u(n >>> 15 == 0); for (let s = 0; s <= 5; s++) this.setFunctionModule(8, s, C(n, s)); this.setFunctionModule(8, 7, C(n, 6)), this.setFunctionModule(8, 8, C(n, 7)), this.setFunctionModule(7, 8, C(n, 8)); for (let s = 9; s < 15; s++) this.setFunctionModule(14 - s, 8, C(n, s)); for (let s = 0; s < 8; s++) this.setFunctionModule(this.size - 1 - s, 8, C(n, s)); for (let s = 8; s < 15; s++) this.setFunctionModule(8, this.size - 15 + s, C(n, s)); this.setFunctionModule(8, this.size - 8, !0); } drawVersion() { if (this.version < 7) return; let e = this.version; for (let o = 0; o < 12; o++) e = e << 1 ^ (e >>> 11) * 7973; const t = this.version << 12 | e; u(t >>> 18 == 0); for (let o = 0; o < 18; o++) { const n = C(t, o), s = this.size - 11 + o % 3, c = Math.floor(o / 3); this.setFunctionModule(s, c, n), this.setFunctionModule(c, s, n); } } drawFinderPattern(e, t) { for (let o = -4; o <= 4; o++) for (let n = -4; n <= 4; n++) { const s = Math.max(Math.abs(n), Math.abs(o)), c = e + n, l = t + o; 0 <= c && c < this.size && 0 <= l && l < this.size && this.setFunctionModule(c, l, s != 2 && s != 4); } } drawAlignmentPattern(e, t) { for (let o = -2; o <= 2; o++) for (let n = -2; n <= 2; n++) this.setFunctionModule(e + n, t + o, Math.max(Math.abs(n), Math.abs(o)) != 1); } setFunctionModule(e, t, o) { this.modules[t][e] = o, this.isFunction[t][e] = !0; } addEccAndInterleave(e) { const t = this.version, o = this.errorCorrectionLevel; if (e.length != r.getNumDataCodewords(t, o)) throw new RangeError("Invalid argument"); const n = r.NUM_ERROR_CORRECTION_BLOCKS[o.ordinal][t], s = r.ECC_CODEWORDS_PER_BLOCK[o.ordinal][t], c = Math.floor(r.getNumRawDataModules(t) / 8), l = n - c % n, E = Math.floor(c / n); let f = []; const N = r.reedSolomonComputeDivisor(s); for (let m = 0, p = 0; m < n; m++) { let R = e.slice(p, p + E - s + (m < l ? 0 : 1)); p += R.length; const y = r.reedSolomonComputeRemainder(R, N); m < l && R.push(0), f.push(R.concat(y)); } let v = []; for (let m = 0; m < f[0].length; m++) f.forEach((p, R) => { (m != E - s || R >= l) && v.push(p[m]); }); return u(v.length == c), v; } drawCodewords(e) { if (e.length != Math.floor(r.getNumRawDataModules(this.version) / 8)) throw new RangeError("Invalid argument"); let t = 0; for (let o = this.size - 1; o >= 1; o -= 2) { o == 6 && (o = 5); for (let n = 0; n < this.size; n++) for (let s = 0; s < 2; s++) { const c = o - s, E = (o + 1 & 2) == 0 ? this.size - 1 - n : n; !this.isFunction[E][c] && t < e.length * 8 && (this.modules[E][c] = C(e[t >>> 3], 7 - (t & 7)), t++); } } u(t == e.length * 8); } applyMask(e) { if (e < 0 || e > 7) throw new RangeError("Mask value out of range"); for (let t = 0; t < this.size; t++) for (let o = 0; o < this.size; o++) { let n; switch (e) { case 0: n = (o + t) % 2 == 0; break; case 1: n = t % 2 == 0; break; case 2: n = o % 3 == 0; break; case 3: n = (o + t) % 3 == 0; break; case 4: n = (Math.floor(o / 3) + Math.floor(t / 2)) % 2 == 0; break; case 5: n = o * t % 2 + o * t % 3 == 0; break; case 6: n = (o * t % 2 + o * t % 3) % 2 == 0; break; case 7: n = ((o + t) % 2 + o * t % 3) % 2 == 0; break; default: throw new Error("Unreachable"); } !this.isFunction[t][o] && n && (this.modules[t][o] = !this.modules[t][o]); } } getPenaltyScore() { let e = 0; for (let s = 0; s < this.size; s++) { let c = !1, l = 0, E = [0, 0, 0, 0, 0, 0, 0]; for (let f = 0; f < this.size; f++) this.modules[s][f] == c ? (l++, l == 5 ? e += r.PENALTY_N1 : l > 5 && e++) : (this.finderPenaltyAddHistory(l, E), c || (e += this.finderPenaltyCountPatterns(E) * r.PENALTY_N3), c = this.modules[s][f], l = 1); e += this.finderPenaltyTerminateAndCount(c, l, E) * r.PENALTY_N3; } for (let s = 0; s < this.size; s++) { let c = !1, l = 0, E = [0, 0, 0, 0, 0, 0, 0]; for (let f = 0; f < this.size; f++) this.modules[f][s] == c ? (l++, l == 5 ? e += r.PENALTY_N1 : l > 5 && e++) : (this.finderPenaltyAddHistory(l, E), c || (e += this.finderPenaltyCountPatterns(E) * r.PENALTY_N3), c = this.modules[f][s], l = 1); e += this.finderPenaltyTerminateAndCount(c, l, E) * r.PENALTY_N3; } for (let s = 0; s < this.size - 1; s++) for (let c = 0; c < this.size - 1; c++) { const l = this.modules[s][c]; l == this.modules[s][c + 1] && l == this.modules[s + 1][c] && l == this.modules[s + 1][c + 1] && (e += r.PENALTY_N2); } let t = 0; for (const s of this.modules) t = s.reduce((c, l) => c + (l ? 1 : 0), t); const o = this.size * this.size, n = Math.ceil(Math.abs(t * 20 - o * 10) / o) - 1; return u(0 <= n && n <= 9), e += n * r.PENALTY_N4, u(0 <= e && e <= 2568888), e; } getAlignmentPatternPositions() { if (this.version == 1) return []; { const e = Math.floor(this.version / 7) + 2, t = this.version == 32 ? 26 : Math.ceil((this.version * 4 + 4) / (e * 2 - 2)) * 2; let o = [6]; for (let n = this.size - 7; o.length < e; n -= t) o.splice(1, 0, n); return o; } } static getNumRawDataModules(e) { if (e < r.MIN_VERSION || e > r.MAX_VERSION) throw new RangeError("Version number out of range"); let t = (16 * e + 128) * e + 64; if (e >= 2) { const o = Math.floor(e / 7) + 2; t -= (25 * o - 10) * o - 55, e >= 7 && (t -= 36); } return u(208 <= t && t <= 29648), t; } static getNumDataCodewords(e, t) { return Math.floor(r.getNumRawDataModules(e) / 8) - r.ECC_CODEWORDS_PER_BLOCK[t.ordinal][e] * r.NUM_ERROR_CORRECTION_BLOCKS[t.ordinal][e]; } static reedSolomonComputeDivisor(e) { if (e < 1 || e > 255) throw new RangeError("Degree out of range"); let t = []; for (let n = 0; n < e - 1; n++) t.push(0); t.push(1); let o = 1; for (let n = 0; n < e; n++) { for (let s = 0; s < t.length; s++) t[s] = r.reedSolomonMultiply(t[s], o), s + 1 < t.length && (t[s] ^= t[s + 1]); o = r.reedSolomonMultiply(o, 2); } return t; } static reedSolomonComputeRemainder(e, t) { let o = t.map((n) => 0); for (const n of e) { const s = n ^ o.shift(); o.push(0), t.forEach((c, l) => o[l] ^= r.reedSolomonMultiply(c, s)); } return o; } static reedSolomonMultiply(e, t) { if (e >>> 8 || t >>> 8) throw new RangeError("Byte out of range"); let o = 0; for (let n = 7; n >= 0; n--) o = o << 1 ^ (o >>> 7) * 285, o ^= (t >>> n & 1) * e; return u(o >>> 8 == 0), o; } finderPenaltyCountPatterns(e) { const t = e[1]; u(t <= this.size * 3); const o = t > 0 && e[2] == t && e[3] == t * 3 && e[4] == t && e[5] == t; return (o && e[0] >= t * 4 && e[6] >= t ? 1 : 0) + (o && e[6] >= t * 4 && e[0] >= t ? 1 : 0); } finderPenaltyTerminateAndCount(e, t, o) { return e && (this.finderPenaltyAddHistory(t, o), t = 0), t += this.size, this.finderPenaltyAddHistory(t, o), this.finderPenaltyCountPatterns(o); } finderPenaltyAddHistory(e, t) { t[0] == 0 && (e += this.size), t.pop(), t.unshift(e); } }; let a = r; a.MIN_VERSION = 1, a.MAX_VERSION = 40, a.PENALTY_N1 = 3, a.PENALTY_N2 = 3, a.PENALTY_N3 = 40, a.PENALTY_N4 = 10, a.ECC_CODEWORDS_PER_BLOCK = [ [-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30], [-1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28], [-1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30], [-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30] ], a.NUM_ERROR_CORRECTION_BLOCKS = [ [-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25], [-1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49], [-1, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68], [-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81] ], h.QrCode = a; function i(e, t, o) { if (t < 0 || t > 31 || e >>> t) throw new RangeError("Value out of range"); for (let n = t - 1; n >= 0; n--) o.push(e >>> n & 1); } function C(e, t) { return (e >>> t & 1) != 0; } function u(e) { if (!e) throw new Error("Assertion error"); } const d = class { constructor(e, t, o) { if (this.mode = e, this.numChars = t, this.bitData = o, t < 0) throw new RangeError("Invalid argument"); this.bitData = o.slice(); } static makeBytes(e) { let t = []; for (const o of e) i(o, 8, t); return new d(d.Mode.BYTE, e.length, t); } static makeNumeric(e) { if (!d.isNumeric(e)) throw new RangeError("String contains non-numeric characters"); let t = []; for (let o = 0; o < e.length; ) { const n = Math.min(e.length - o, 3); i(parseInt(e.substr(o, n), 10), n * 3 + 1, t), o += n; } return new d(d.Mode.NUMERIC, e.length, t); } static makeAlphanumeric(e) { if (!d.isAlphanumeric(e)) throw new RangeError("String contains unencodable characters in alphanumeric mode"); let t = [], o; for (o = 0; o + 2 <= e.length; o += 2) { let n = d.ALPHANUMERIC_CHARSET.indexOf(e.charAt(o)) * 45; n += d.ALPHANUMERIC_CHARSET.indexOf(e.charAt(o + 1)), i(n, 11, t); } return o < e.length && i(d.ALPHANUMERIC_CHARSET.indexOf(e.charAt(o)), 6, t), new d(d.Mode.ALPHANUMERIC, e.length, t); } static makeSegments(e) { return e == "" ? [] : d.isNumeric(e) ? [d.makeNumeric(e)] : d.isAlphanumeric(e) ? [d.makeAlphanumeric(e)] : [d.makeBytes(d.toUtf8ByteArray(e))]; } static makeEci(e) { let t = []; if (e < 0) throw new RangeError("ECI assignment value out of range"); if (e < 128) i(e, 8, t); else if (e < 16384) i(2, 2, t), i(e, 14, t); else if (e < 1e6) i(6, 3, t), i(e, 21, t); else throw new RangeError("ECI assignment value out of range"); return new d(d.Mode.ECI, 0, t); } static isNumeric(e) { return d.NUMERIC_REGEX.test(e); } static isAlphanumeric(e) { return d.ALPHANUMERIC_REGEX.test(e); } getData() { return this.bitData.slice(); } static getTotalBits(e, t) { let o = 0; for (const n of e) { const s = n.mode.numCharCountBits(t); if (n.numChars >= 1 << s) return 1 / 0; o += 4 + s + n.bitData.length; } return o; } static toUtf8ByteArray(e) { e = encodeURI(e); let t = []; for (let o = 0; o < e.length; o++) e.charAt(o) != "%" ? t.push(e.charCodeAt(o)) : (t.push(parseInt(e.substr(o + 1, 2), 16)), o += 2); return t; } }; let g = d; g.NUMERIC_REGEX = /^[0-9]*$/, g.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\/:-]*$/, g.ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:", h.QrSegment = g; })(_ || (_ = {})); ((h) => { ((r) => { const a = class { constructor(C, u) { this.ordinal = C, this.formatBits = u; } }; let i = a; i.LOW = new a(0, 1), i.MEDIUM = new a(1, 0), i.QUARTILE = new a(2, 3), i.HIGH = new a(3, 2), r.Ecc = i; })(h.QrCode || (h.QrCode = {})); })(_ || (_ = {})); ((h) => { ((r) => { const a = class { constructor(C, u) { this.modeBits = C, this.numBitsCharCount = u; } numCharCountBits(C) { return this.numBitsCharCount[Math.floor((C + 7) / 17)]; } }; let i = a; i.NUMERIC = new a(1, [10, 12, 14]), i.ALPHANUMERIC = new a(2, [9, 11, 13]), i.BYTE = new a(4, [8, 16, 16]), i.KANJI = new a(8, [8, 10, 12]), i.ECI = new a(7, [0, 0, 0]), r.Mode = i; })(h.QrSegment || (h.QrSegment = {})); })(_ || (_ = {})); var P = _; /** * @license qrcode.react * Copyright (c) Paul O'Shannessy * SPDX-License-Identifier: ISC */ var $ = { L: P.QrCode.Ecc.LOW, M: P.QrCode.Ecc.MEDIUM, Q: P.QrCode.Ecc.QUARTILE, H: P.QrCode.Ecc.HIGH }, x = 128, Y = "L", G = "#FFFFFF", j = "#000000", X = !1, B = 4, ce = 0.1; function K(h, r = 0) { const a = []; return h.forEach(function(i, C) { let u = null; i.forEach(function(d, g) { if (!d && u !== null) { a.push(`M${u + r} ${C + r}h${g - u}v1H${u + r}z`), u = null; return; } if (g === i.length - 1) { if (!d) return; u === null ? a.push(`M${g + r},${C + r} h1v1H${g + r}z`) : a.push(`M${u + r},${C + r} h${g + 1 - u}v1H${u + r}z`); return; } d && u === null && (u = g); }); }), a.join(""); } function V(h, r) { return h.slice().map((a, i) => i < r.y || i >= r.y + r.h ? a : a.map((C, u) => u < r.x || u >= r.x + r.w ? C : !1)); } function W(h, r, a, i) { if (i == null) return null; const C = a ? B : 0, u = h.length + C * 2, d = Math.floor(r * ce), g = u / r, e = (i.width || d) * g, t = (i.height || d) * g, o = i.x == null ? h.length / 2 - e / 2 : i.x * g, n = i.y == null ? h.length / 2 - t / 2 : i.y * g; let s = null; if (i.excavate) { let c = Math.floor(o), l = Math.floor(n), E = Math.ceil(e + o - c), f = Math.ceil(t + n - l); s = { x: c, y: l, w: E, h: f }; } return { x: o, y: n, h: t, w: e, excavation: s }; } var he = function() { try { new Path2D().addPath(new Path2D()); } catch { return !1; } return !0; }(); function ue(h) { const r = h, { value: a, size: i = x, level: C = Y, bgColor: u = G, fgColor: d = j, includeMargin: g = X, style: e, imageSettings: t } = r, o = T(r, [ "value", "size", "level", "bgColor", "fgColor", "includeMargin", "style", "imageSettings" ]), n = t == null ? void 0 : t.src, s = w.useRef(null), c = w.useRef(null), [l, E] = w.useState(!1); w.useEffect(() => { if (s.current != null) { const v = s.current, m = v.getContext("2d"); if (!m) return; let p = P.QrCode.encodeText(a, $[C]).getModules(); const R = g ? B : 0, y = p.length + R * 2, A = W(p, i, g, t), I = c.current, z = A != null && I !== null && I.complete && I.naturalHeight !== 0 && I.naturalWidth !== 0; z && A.excavation != null && (p = V(p, A.excavation)); const D = window.devicePixelRatio || 1; v.height = v.width = i * D; const U = i / y * D; m.scale(U, U), m.fillStyle = u, m.fillRect(0, 0, y, y), m.fillStyle = d, he ? m.fill(new Path2D(K(p, R))) : p.forEach(function(Z, J) { Z.forEach(function(q, ee) { q && m.fillRect(ee + R, J + R, 1, 1); }); }), z && m.drawImage(I, A.x + R, A.y + R, A.w, A.h); } }), w.useEffect(() => { E(!1); }, [n]); const f = S({ height: i, width: i }, e); let N = null; return n != null && (N = /* @__PURE__ */ w.createElement("img", { src: n, key: n, style: { display: "none" }, onLoad: () => { E(!0); }, ref: c })), /* @__PURE__ */ w.createElement(w.Fragment, null, /* @__PURE__ */ w.createElement("canvas", S({ style: f, height: i, width: i, ref: s }, o)), N); } function de(h) { const r = h, { value: a, size: i = x, level: C = Y, bgColor: u = G, fgColor: d = j, includeMargin: g = X, imageSettings: e } = r, t = T(r, [ "value", "size", "level", "bgColor", "fgColor", "includeMargin", "imageSettings" ]); let o = P.QrCode.encodeText(a, $[C]).getModules(); const n = g ? B : 0, s = o.length + n * 2, c = W(o, i, g, e); let l = null; e != null && c != null && (c.excavation != null && (o = V(o, c.excavation)), l = /* @__PURE__ */ w.createElement("image", { xlinkHref: e.src, height: c.h, width: c.w, x: c.x + n, y: c.y + n, preserveAspectRatio: "none" })); const E = K(o, n); return /* @__PURE__ */ w.createElement("svg", S({ height: i, width: i, viewBox: `0 0 ${s} ${s}` }, t), /* @__PURE__ */ w.createElement("path", { fill: u, d: `M0,0 h${s}v${s}H0z`, shapeRendering: "crispEdges" }), /* @__PURE__ */ w.createElement("path", { fill: d, d: E, shapeRendering: "crispEdges" }), l); } var fe = (h) => { const r = h, { renderAs: a } = r, i = T(r, ["renderAs"]); return a === "svg" ? /* @__PURE__ */ w.createElement(de, S({}, i)) : /* @__PURE__ */ w.createElement(ue, S({}, i)); }; function Fe() { const [h, r] = F(!1), [a, i] = F(!1), C = ie(), u = le(), d = ne(), g = re(), [e, t] = F(!1), o = L(() => { r(!1), setTimeout(u, 50); }, [u, r]), n = L(() => { C(), r(!1); }, [C]), s = L(() => { g && navigator.clipboard.writeText(g).then(() => { i(!0), setTimeout(() => i(!1), 2e3); }).catch((l) => console.error("Failed to copy text: ", l)); }, [g]), c = L(() => { t((l) => !l); }, []); return /* @__PURE__ */ b(te, { children: [ /* @__PURE__ */ M( "button", { className: "session-button button-primary interactive-border", onClick: () => r(!0), children: /* @__PURE__ */ M(se.logo, { style: { width: "1.5rem" } }) } ), /* @__PURE__ */ M( oe, { position: "bottom-right", visible: h, draggable: !1, resizable: !1, onHide: () => r(!1), pt: { root: { style: { overflow: "hidden", borderRadius: "1rem" }, className: "interactive-border" }, header: { style: { padding: "0.5rem" } }, content: { style: { paddingBottom: "1rem" } } }, children: d ? /* @__PURE__ */ b("div", { className: "sessionMenuContent-container", children: [ /* @__PURE__ */ b("p", { className: "sessionMenu-description", children: [ "Send this url to your friends to", /* @__PURE__ */ M("br", {}), " join the current session!" ] }), /* @__PURE__ */ b("div", { className: "sessionMenuContent-container", children: [ e && g && /* @__PURE__ */ M("div", { className: "qrCode-container", children: /* @__PURE__ */ M( fe, { value: g, size: 130, bgColor: "#fff", fgColor: "#373b43", level: "H", includeMargin: !1 } ) }), /* @__PURE__ */ b("div", { className: "input-container interactive-border", children: [ /* @__PURE__ */ b( "button", { onClick: s, className: "input-button", disabled: !g, children: [ /* @__PURE__ */ M("label", { className: "url-container", children: a ? "Copied!" : g }), /* @__PURE__ */ M("i", { className: a ? "pi pi-check" : "pi pi-copy" }) ] } ), /* @__PURE__ */ M("button", { onClick: c, disabled: !g, children: /* @__PURE__ */ M("i", { className: "pi pi-qrcode" }) }) ] }) ] }), /* @__PURE__ */ M( "button", { className: "session-button button-caution interactive-border", onClick: n, style: { width: "100%" }, children: /* @__PURE__ */ M("label", { children: "Leave Session" }) } ) ] }) : /* @__PURE__ */ M( "button", { className: "session-button button-primary interactive-border", onClick: o, style: { width: "100%" }, children: /* @__PURE__ */ M("label", { children: "Create Private Session" }) } ) } ) ] }); } export { Fe as default };