"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var _chunkZU72XWNEcjs = require('./chunk-ZU72XWNE.cjs');

// src/components/LightboxImage.tsx
var _styled = require('@emotion/styled'); var _styled2 = _interopRequireDefault(_styled);




var _react = require('react');
var _jsxruntime = require('@emotion/react/jsx-runtime');
var LightboxImage = ({ children }) => {
  const [isOpen, setIsOpen] = _react.useState.call(void 0, false);
  const [boundingRect, setBoundingRect] = _react.useState.call(void 0, {
    x: 0,
    y: 0,
    width: 0,
    height: 0
  });
  const imageRef = _react.useRef.call(void 0, null);
  const handleMouseUp = () => {
    setIsOpen(!isOpen);
  };
  const handleSetBoundingRect = (ref) => {
    var _a;
    const rect = (_a = ref.current) == null ? void 0 : _a.getBoundingClientRect();
    if (rect) {
      setBoundingRect({
        x: rect.x,
        y: rect.y,
        width: rect.width,
        height: rect.height
      });
    }
  };
  _react.useEffect.call(void 0, () => {
    handleSetBoundingRect(imageRef);
  }, [imageRef]);
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
    /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DummyImage, { isOpen, boundingRect }),
    /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
      StyledImage,
      {
        isOpen,
        ref: imageRef,
        boundingRect,
        onMouseDown: () => handleSetBoundingRect(imageRef),
        onMouseUp: handleMouseUp,
        children
      }
    ),
    /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Lightbox, { isOpen, onClick: handleMouseUp })
  ] });
};
var DummyImage = _styled2.default.div`
  ${(props) => props.isOpen ? `height: ${props.boundingRect.height}px; width: ${props.boundingRect.width}px;` : ``}
`;
var StyledImage = _styled2.default.div`
  display: flex;
  justify-content: start;
  align-items: center;
  z-index: ${_chunkZU72XWNEcjs.z.modalContainer};

  animation-duration: 0.4s;
  animation-fill-mode: forwards;
  transition: all 0.2s ease-out;

  ${(props) => props.isOpen ? `
    animation-direction: normal;
    position: fixed;
    animation-name: zoomIn;
    pointer-events: none;
  ` : `
    &:hover {
      cursor: zoom-in;
    }
  `}

  img {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }

  @keyframes zoomIn {
    from {
      ${(props) => {
  const { x, y, width, height } = props.boundingRect;
  return `
          top: ${y}px;
          left: ${x}px;
          width: ${width}px;
          height: ${height}px;
        `;
}}
    }
    to {
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      padding: 24px;
    }
  }
`;
var Lightbox = _styled2.default.div`
  transition: opacity 0.2s ease-out;
  position: fixed;
  opacity: 0;
  z-index: ${_chunkZU72XWNEcjs.z.modalOverlay};
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;

  ${({ theme, isOpen }) => isOpen ? `
    opacity: 1;
    background: ${theme.bg};

    &:hover {
      cursor: zoom-out;
    }
  ` : `
    pointer-events: none;
  `}
`;



exports.LightboxImage = LightboxImage;
