var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/pisellFloorMapLayout/components/FloorMapImageElement.tsx
var FloorMapImageElement_exports = {};
__export(FloorMapImageElement_exports, {
  FloorMapImageElement: () => FloorMapImageElement
});
module.exports = __toCommonJS(FloorMapImageElement_exports);
var import_react = __toESM(require("react"));
var import_utils = require("@pisell/utils");
var PREFIX = "pisell-floor-map-layout";
var I18N_IMG = "pisell-floor-map-layout.image-element";
function FloorMapImageElement(props) {
  const { imageUrl, name } = props;
  const [broken, setBroken] = (0, import_react.useState)(false);
  const trimmed = imageUrl != null ? String(imageUrl).trim() : "";
  (0, import_react.useEffect)(() => {
    setBroken(false);
  }, [trimmed]);
  const label = name != null && String(name).trim() ? String(name).trim() : import_utils.locales.getText(`${I18N_IMG}.default-name`);
  if (!trimmed || broken) {
    return /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: `${PREFIX}-image-element-placeholder`,
        style: {
          width: "100%",
          height: "100%",
          boxSizing: "border-box",
          display: "flex",
          flexDirection: "column",
          alignItems: "center",
          justifyContent: "center",
          padding: 8,
          background: "#fafafa",
          border: "2px dashed #bfbfbf",
          borderRadius: 4,
          fontSize: 11,
          color: "#8c8c8c",
          textAlign: "center",
          lineHeight: 1.4,
          overflow: "hidden"
        }
      },
      /* @__PURE__ */ import_react.default.createElement("span", { style: { fontWeight: 600, color: "#595959", marginBottom: 4 } }, label),
      /* @__PURE__ */ import_react.default.createElement("span", null, !trimmed ? import_utils.locales.getText(`${I18N_IMG}.hint-no-url`) : import_utils.locales.getText(`${I18N_IMG}.hint-load-fail`))
    );
  }
  return /* @__PURE__ */ import_react.default.createElement(
    "img",
    {
      src: trimmed,
      alt: label,
      draggable: false,
      onError: () => setBroken(true),
      style: {
        width: "100%",
        height: "100%",
        objectFit: "cover",
        display: "block",
        pointerEvents: "none",
        userSelect: "none"
      }
    }
  );
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  FloorMapImageElement
});
