// packages/block-library/src/navigation-link/index.js
import { _x, __ } from "@wordpress/i18n";
import { customLink as linkIcon } from "@wordpress/icons";
import { InnerBlocks } from "@wordpress/block-editor";
import { addFilter } from "@wordpress/hooks";
import initBlock from "../utils/init-block";
import metadata from "./block.json";
import edit from "./edit";
import save from "./save";
import { enhanceNavigationLinkVariations } from "./hooks";
import transforms from "./transforms";
import { jsx } from "react/jsx-runtime";
var { name } = metadata;
var settings = {
  icon: linkIcon,
  __experimentalLabel: ({ label }) => label,
  merge(leftAttributes, { label: rightLabel = "" }) {
    return {
      ...leftAttributes,
      label: leftAttributes.label + rightLabel
    };
  },
  edit,
  save,
  example: {
    attributes: {
      label: _x("Example Link", "navigation link preview example"),
      url: "https://example.com"
    }
  },
  deprecated: [
    {
      isEligible(attributes) {
        return attributes.nofollow;
      },
      attributes: {
        label: {
          type: "string"
        },
        type: {
          type: "string"
        },
        nofollow: {
          type: "boolean"
        },
        description: {
          type: "string"
        },
        id: {
          type: "number"
        },
        opensInNewTab: {
          type: "boolean",
          default: false
        },
        url: {
          type: "string"
        }
      },
      migrate({ nofollow, ...rest }) {
        return {
          rel: nofollow ? "nofollow" : "",
          ...rest
        };
      },
      save() {
        return /* @__PURE__ */ jsx(InnerBlocks.Content, {});
      }
    }
  ],
  transforms
};
if (window.__experimentalContentOnlyPatternInsertion) {
  settings.fields = [
    {
      label: __("Label"),
      type: "RichText",
      shownByDefault: true,
      mapping: {
        value: "label"
      }
    },
    {
      label: __("Link"),
      type: "Link",
      shownByDefault: false,
      mapping: {
        href: "url",
        rel: "rel"
        // TODO - opens in new tab? id?
      }
    }
  ];
}
var init = () => {
  addFilter(
    "blocks.registerBlockType",
    "core/navigation-link",
    enhanceNavigationLinkVariations
  );
  return initBlock({ name, metadata, settings });
};
export {
  init,
  metadata,
  name,
  settings
};
//# sourceMappingURL=index.js.map
