"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const universalApi = require("@tencentcloud/universal-api");
const room = require("tuikit-atomicx-vue3/room");
function generateRoomLink(roomId, password, roomType = room.RoomType.Standard) {
  if (!roomId) {
    return "";
  }
  const baseUrl = `${window.location.protocol}//${window.location.host}`;
  const isHashRouter = window.location.hash.includes("#");
  const currentPath = window.location.pathname;
  const roomParams = password ? `roomId=${roomId}&roomType=${roomType}&password=${password}` : `roomId=${roomId}&roomType=${roomType}`;
  if (isHashRouter) {
    return `${baseUrl}${currentPath}#/room?${roomParams}`;
  }
  return `${baseUrl}/room?${roomParams}`;
}
async function copyText(text) {
  try {
    if (navigator.clipboard && window.isSecureContext) {
      await navigator.clipboard.writeText(text);
      return true;
    }
    const textArea = document.createElement("textarea");
    textArea.value = text;
    textArea.style.position = "fixed";
    textArea.style.left = "-999999px";
    textArea.style.top = "-999999px";
    document.body.appendChild(textArea);
    textArea.focus();
    textArea.select();
    const successful = document.execCommand("copy");
    document.body.removeChild(textArea);
    return successful;
  } catch {
    return false;
  }
}
function generateRoomSchemeLink(roomId, password, roomType = room.RoomType.Standard) {
  if (!roomId) {
    return "";
  }
  return `tuiroom://joinroom?roomId=${roomId}&roomType=${roomType}${password ? `&password=${password}` : ""}`;
}
universalApi.getPlatform();
exports.copyText = copyText;
exports.generateRoomLink = generateRoomLink;
exports.generateRoomSchemeLink = generateRoomSchemeLink;
