"use strict";
var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const environment = require("../../utils/environment.js");
const room = require("../../constants/room.js");
class BasicBeauty {
  constructor(service) {
    __publicField(this, "service");
    __publicField(this, "basicBeautyPluginReady", false);
    __publicField(this, "handleUnmount", async () => {
      await this.setBasicBeauty(room.TRTCBeautyStyle.TRTCBeautyStyleNature, 0, 0, 0);
    });
    this.service = service;
    if (environment.isElectron || environment.isWeChat) return;
    this.bindEvent();
  }
  dispose() {
    this.service.lifeCycleManager.off("unmount", this.handleUnmount);
  }
  async initBasicBeauty() {
    var _a;
    if (!this.basicBeautyPluginReady && ((_a = this.trtcCloud) == null ? void 0 : _a.useBeautyStyle)) {
      await this.trtcCloud.useBeautyStyle();
      this.basicBeautyPluginReady = true;
    }
  }
  async setBasicBeauty(style, beautyLevel, whitenessLevel, ruddinessLevel) {
    await this.initBasicBeauty();
    await this.trtcCloud.setBeautyStyle(
      style,
      beautyLevel,
      whitenessLevel,
      ruddinessLevel
    );
  }
  async setTestBasicBeauty(style, beautyLevel, whitenessLevel, ruddinessLevel) {
    await this.initBasicBeauty();
    await this.trtcCloud.callExperimentalAPI(
      JSON.stringify({
        api: "enableTestBeautyStyle",
        params: { style, beautyLevel, whitenessLevel, ruddinessLevel }
      })
    );
  }
  get trtcCloud() {
    var _a, _b;
    return (_b = (_a = this.service.roomEngine) == null ? void 0 : _a.instance) == null ? void 0 : _b.getTRTCCloud();
  }
  bindEvent() {
    this.service.lifeCycleManager.on("unmount", this.handleUnmount);
  }
}
exports.BasicBeauty = BasicBeauty;
