// packages/block-library/src/comment-edit-link/edit.js
import clsx from "clsx";
import {
  AlignmentControl,
  BlockControls,
  InspectorControls,
  useBlockProps
} from "@wordpress/block-editor";
import {
  ToggleControl,
  __experimentalToolsPanel as ToolsPanel,
  __experimentalToolsPanelItem as ToolsPanelItem
} from "@wordpress/components";
import { __ } from "@wordpress/i18n";
import { useToolsPanelDropdownMenuProps } from "../utils/hooks";
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
function Edit({
  attributes: { linkTarget, textAlign },
  setAttributes
}) {
  const blockProps = useBlockProps({
    className: clsx({
      [`has-text-align-${textAlign}`]: textAlign
    })
  });
  const dropdownMenuProps = useToolsPanelDropdownMenuProps();
  const blockControls = /* @__PURE__ */ jsx(BlockControls, { group: "block", children: /* @__PURE__ */ jsx(
    AlignmentControl,
    {
      value: textAlign,
      onChange: (newAlign) => setAttributes({ textAlign: newAlign })
    }
  ) });
  const inspectorControls = /* @__PURE__ */ jsx(InspectorControls, { children: /* @__PURE__ */ jsx(
    ToolsPanel,
    {
      label: __("Settings"),
      resetAll: () => {
        setAttributes({
          linkTarget: "_self"
        });
      },
      dropdownMenuProps,
      children: /* @__PURE__ */ jsx(
        ToolsPanelItem,
        {
          label: __("Open in new tab"),
          isShownByDefault: true,
          hasValue: () => linkTarget === "_blank",
          onDeselect: () => setAttributes({ linkTarget: "_self" }),
          children: /* @__PURE__ */ jsx(
            ToggleControl,
            {
              __nextHasNoMarginBottom: true,
              label: __("Open in new tab"),
              onChange: (value) => setAttributes({
                linkTarget: value ? "_blank" : "_self"
              }),
              checked: linkTarget === "_blank"
            }
          )
        }
      )
    }
  ) });
  return /* @__PURE__ */ jsxs(Fragment, { children: [
    blockControls,
    inspectorControls,
    /* @__PURE__ */ jsx("div", { ...blockProps, children: /* @__PURE__ */ jsx(
      "a",
      {
        href: "#edit-comment-pseudo-link",
        onClick: (event) => event.preventDefault(),
        children: __("Edit")
      }
    ) })
  ] });
}
export {
  Edit as default
};
//# sourceMappingURL=edit.js.map
