"use client";
'use strict';

var React2 = require('react');
var clsx = require('clsx');
var tailwindMerge = require('tailwind-merge');
var pressable = require('@page-speed/pressable');
var icon = require('@page-speed/icon');
var jsxRuntime = require('react/jsx-runtime');
var usePlatformFromUrl = require('@opensite/hooks/usePlatformFromUrl');

function _interopNamespace(e) {
  if (e && e.__esModule) return e;
  var n = Object.create(null);
  if (e) {
    Object.keys(e).forEach(function (k) {
      if (k !== 'default') {
        var d = Object.getOwnPropertyDescriptor(e, k);
        Object.defineProperty(n, k, d.get ? d : {
          enumerable: true,
          get: function () { return e[k]; }
        });
      }
    });
  }
  n.default = e;
  return Object.freeze(n);
}

var React2__namespace = /*#__PURE__*/_interopNamespace(React2);

function cn(...inputs) {
  return tailwindMerge.twMerge(clsx.clsx(inputs));
}
var DEFAULT_ICON_API_KEY = "au382bi7fsh96w9h9xlrnat2jglx";
var DynamicIcon = React2__namespace.memo(function DynamicIcon2({
  apiKey,
  name,
  ...props
}) {
  if (name == null) return null;
  if (typeof name !== "string") {
    return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: name });
  }
  return /* @__PURE__ */ jsxRuntime.jsx(icon.Icon, { ...props, name, apiKey: apiKey ?? DEFAULT_ICON_API_KEY });
});
DynamicIcon.displayName = "DynamicIcon";
var platformIconMap = {
  instagram: "cib/instagram",
  linkedin: "cib/linkedin",
  google: "cib/google",
  facebook: "cib/facebook",
  tiktok: "cib/tiktok",
  youtube: "cib/youtube",
  yelp: "cib/yelp",
  spotify: "cib/spotify",
  apple: "cib/apple",
  x: "prime/twitter",
  github: "cib/github",
  snapchat: "cib/snapchat",
  discord: "cib/discord",
  dev: "simple-icons/devdotto",
  substack: "simple-icons/substack",
  reddit: "cib/reddit",
  pinterest: "cib/pinterest",
  threads: "simple-icons/threads",
  twitch: "cib/twitch",
  whatsapp: "cib/whatsapp",
  telegram: "cib/telegram",
  medium: "simple-icons/medium",
  patreon: "cib/patreon",
  onlyfans: "simple-icons/onlyfans",
  eventbrite: "cib/eventbrite",
  npmjs: "simple-icons/npm",
  crates: "cib/rust",
  rubygems: "cib/rubygems",
  behance: "cib/behance",
  dribbble: "cib/dribbble",
  unknown: "icon-park-solid/circular-connection"
};
var SocialLinkIcon = React2__namespace.forwardRef(
  ({
    platformName,
    label,
    iconSize = 20,
    iconColor,
    href,
    iconClassName,
    className,
    iconNameOverride,
    iconOnly = false,
    ...pressableProps
  }, ref) => {
    const platform = usePlatformFromUrl.usePlatformFromUrl(href);
    const smartPlatformName = React2__namespace.useMemo(() => {
      return platform || platformName;
    }, [platform, platformName]);
    const iconName = React2__namespace.useMemo(() => {
      return iconNameOverride || platformIconMap[smartPlatformName];
    }, [iconNameOverride, smartPlatformName]);
    const accessibleLabel = React2__namespace.useMemo(() => {
      return label || platformName;
    }, [label, platformName]);
    const icon = React2__namespace.useMemo(() => {
      return /* @__PURE__ */ jsxRuntime.jsx(
        DynamicIcon,
        {
          name: iconName,
          size: iconSize,
          color: iconColor,
          className: iconClassName,
          alt: accessibleLabel
        }
      );
    }, [iconName, iconSize, iconColor, iconClassName, accessibleLabel]);
    if (iconOnly) {
      return icon;
    }
    return /* @__PURE__ */ jsxRuntime.jsx(
      pressable.Pressable,
      {
        ref,
        href,
        "aria-label": accessibleLabel,
        className: cn(
          "inline-flex items-center justify-center transition-colors",
          className
        ),
        ...pressableProps,
        children: icon
      }
    );
  }
);
SocialLinkIcon.displayName = "SocialLinkIcon";

exports.SocialLinkIcon = SocialLinkIcon;
