import { Box, Divider, SidePanel } from "@wix/design-system";
import React, { useContext } from "react";
import { RicosContext } from "./../../../ricos-context/index.js";
import { Panel, PanelHeader } from "./../../../ui-components/index.js";
import { MODAL_ROOT } from "../data-hooks/data-hooks.js";
import { AttributesMobile } from "./attributes/attributes-mobile.js";
import { Footer } from "./footer.js";
import { SectionMobile } from "./section/section-mobile.js";
import { TypeSelect } from "./type-select.js";
import { useLinkModalState } from "./use-link-modal-state.js";
import { WebAddress } from "./web-address.js";
const ModalMobile = ({
  initialValue,
  enabledLinkTypes: enabledLinkTypesProp,
  onClose,
  onSave,
  onUnlink
}) => {
  const { t } = useContext(RicosContext);
  const {
    link,
    linkType,
    submitError,
    enabledLinkTypes,
    onChangeAttributes,
    onChangeWebAddress,
    onClickUnlink,
    onSelectSection,
    onSelectType,
    onSubmit,
    onValidateWebAddress
  } = useLinkModalState({
    initialValue,
    onClose,
    onSave,
    onUnlink,
    enabledLinkTypes: enabledLinkTypesProp
  });
  return /* @__PURE__ */ React.createElement(
    Panel,
    {
      dataHook: MODAL_ROOT,
      closeButtonProps: { onClick: onClose },
      skin: "floating",
      width: "100%"
    },
    /* @__PURE__ */ React.createElement(PanelHeader, { title: t("LinkSettings_Modal_Title") }),
    /* @__PURE__ */ React.createElement(SidePanel.Content, { noPadding: true }, /* @__PURE__ */ React.createElement(Box, { boxSizing: "border-box", direction: "vertical", gap: "SP3", height: "100%", padding: 0 }, /* @__PURE__ */ React.createElement(Box, { padding: "SP3", paddingBottom: 0 }, enabledLinkTypes && enabledLinkTypes.length === 1 ? null : /* @__PURE__ */ React.createElement(
      TypeSelect,
      {
        autoFocus: false,
        onSelect: onSelectType,
        showSitePages: false,
        t,
        type: linkType,
        enabledLinkTypes
      }
    )), linkType === "section" ? /* @__PURE__ */ React.createElement(SectionMobile, { link, onSelect: onSelectSection, t }) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Box, { direction: "vertical", paddingLeft: "SP3", paddingRight: "SP3" }, /* @__PURE__ */ React.createElement(
      WebAddress,
      {
        autoFocus: true,
        link,
        onChangeUrl: onChangeWebAddress,
        onValidateUrl: onValidateWebAddress,
        submitError,
        t
      }
    )), /* @__PURE__ */ React.createElement(Divider, null), /* @__PURE__ */ React.createElement(Box, { direction: "vertical", padding: "SP3" }, /* @__PURE__ */ React.createElement(AttributesMobile, { link, onChange: onChangeAttributes, t }))))),
    /* @__PURE__ */ React.createElement(SidePanel.Footer, { showDivider: true }, /* @__PURE__ */ React.createElement(
      Footer,
      {
        onClickCancel: onClose,
        onClickSave: onSubmit,
        onClickUnlink,
        showUnlink: Boolean(initialValue?.url || initialValue?.anchor),
        t
      }
    ))
  );
};
export {
  ModalMobile
};
//# sourceMappingURL=modal-mobile.js.map
