"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var audio_upload_exports = {};
__export(audio_upload_exports, {
  AudioUpload: () => AudioUpload
});
module.exports = __toCommonJS(audio_upload_exports);
var import_design_system = require("@wix/design-system");
var import_react = __toESM(require("react"));
var import_ricos_context = require("./../../ricos-context/index.js");
var import_wix_instance_context = require("./../../_shared/request-service-provider/wix-instance-context.js");
var import_some_editor_props_context = require("./../../_shared/some-editor-props-context.js");
var import_wix_rich_content_common = require("./../../wix-rich-content-common/index.js");
var import_handle_audio_upload = require("./../handle-audio-upload.js");
var import_consts = require("../consts.js");
var import_data_hooks = require("../data-hooks.js");
var import_types = require("../types.js");
const AudioUpload = ({ nodeId, closeModal, logBi }) => {
  const { t } = (0, import_react.useContext)(import_ricos_context.RicosContext);
  const { getPublicCommands } = (0, import_react.useContext)(import_ricos_context.EditorContext);
  const { uploadService } = (0, import_react.useContext)(import_ricos_context.UploadContext);
  const pluginsEvents = (0, import_react.useContext)(import_ricos_context.PluginsEventsContext);
  const wixInstance = (0, import_wix_instance_context.useWixInstanceService)();
  const editorProps = (0, import_some_editor_props_context.useEditorProps)();
  const { metaSiteId } = wixInstance();
  const modalService = (0, import_react.useContext)(import_ricos_context.ModalServiceContext);
  const devService = (0, import_ricos_context.useDevService)();
  const publicCommands = getPublicCommands();
  const handleUploadClick = async () => {
    pluginsEvents.publishPluginPopoverClick?.({
      pluginId: import_types.AUDIO_TYPE,
      buttonName: import_wix_rich_content_common.MEDIA_POPOVERS_BUTTONS_NAMES_BI.upload
    });
    logBi({ dataHook: import_data_hooks.UPLOAD_TAB_UPLOAD_BUTTON });
    (0, import_handle_audio_upload.handleAudioUpload)({
      services: {
        uploadService,
        devService,
        wixInstance,
        editorProps,
        modals: modalService
      },
      publicCommands,
      nodeId,
      type: "audio"
    });
    closeModal();
  };
  return /* @__PURE__ */ import_react.default.createElement(import_design_system.FormField, { label: t("AudioModal_Upload_Title"), maxLines: 2 }, metaSiteId || devService().handleFileSelection || devService().handleFileUpload || editorProps.pickMedia?.pickAudio ? /* @__PURE__ */ import_react.default.createElement(import_design_system.FileUpload, { onChange: () => {
  }, accept: import_consts.audioFileTypes }, () => /* @__PURE__ */ import_react.default.createElement(
    import_design_system.Button,
    {
      dataHook: import_data_hooks.UPLOAD_TAB_UPLOAD_BUTTON,
      onClick: handleUploadClick,
      fullWidth: true,
      size: "small"
    },
    t("AudioModal_Upload_ButtonText")
  )) : null);
};
//# sourceMappingURL=audio-upload.js.map
