function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
/*
 * 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 { Error as ErrorIcon, Spin } from "@blueprintjs/icons";
import React from "react";
import { useMediaContents } from "../../shared/hooks/useMediaContents.js";
import { TiffRenderer } from "./TiffRenderer.js";
import styles from "./TiffRenderer.module.css";
const transformToUint8Array = async response => {
  const buffer = await response.arrayBuffer();
  return new Uint8Array(buffer);
};
export function TiffViewerMedia({
  media,
  className,
  ...tiffRendererProps
}) {
  const {
    data: content,
    loading,
    error
  } = useMediaContents(media, transformToUint8Array);
  return /*#__PURE__*/React.createElement("div", {
    className: className
  }, loading && /*#__PURE__*/React.createElement("div", {
    className: styles.loadingContainer
  }, /*#__PURE__*/React.createElement(Spin, {
    className: styles.spinnerIcon
  }), "Loading\u2026"), error != null && /*#__PURE__*/React.createElement("div", {
    className: styles.errorContainer
  }, /*#__PURE__*/React.createElement(ErrorIcon, {
    className: styles.errorIcon
  }), "Failed to load TIFF: ", error.message), content != null && /*#__PURE__*/React.createElement(TiffRenderer, _extends({
    content: content
  }, tiffRendererProps)));
}
//# sourceMappingURL=TiffViewerMedia.js.map