/*
 * Copyright 2026 Palantir Technologies, Inc. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import { Icons, SVGIconContainer } from "@blueprintjs/icons";
import React from "react";
export const BlueprintIcon = /*#__PURE__*/React.memo(function ({
  icon,
  size
}) {
  const paths = useIcon(icon.name, size);
  return /*#__PURE__*/React.createElement(SVGIconContainer, {
    iconName: icon.name,
    color: icon.color
  }, paths != null ? paths.map((d, i) => /*#__PURE__*/React.createElement("path", {
    key: i,
    d: d,
    fillRule: "evenodd"
  })) : []);
});

/**
 * Loads icon paths on demand via the public `Icons.load()` API
 * instead of the static `getIconPaths()` which bundles every icon definition.
 */
function useIcon(icon, size) {
  const [iconPaths, setIconPaths] = React.useState(() => Icons.getPaths(icon, size));
  React.useEffect(function () {
    let isMounted = true;
    const loadedIconPaths = Icons.getPaths(icon, size);
    if (loadedIconPaths != null) {
      setIconPaths(loadedIconPaths);
    } else {
      void Icons.load(icon, size).then(() => {
        if (isMounted) {
          setIconPaths(Icons.getPaths(icon, size));
        }
      });
    }
    return () => {
      isMounted = false;
    };
  }, [icon, size]);
  return iconPaths;
}
//# sourceMappingURL=BlueprintIcon.js.map