/**
 * 无 renderItemByKind 时的占位渲染（装饰、舞台等），避免画布上不显示
 */
import React from 'react';
import { FLOOR_MAP_STAGE_ELEMENT_KIND } from "../types";
import { isFloorMapImageElementKind } from "./floorMapElementKindUtils";
import { FloorMapImageElement } from "../components/FloorMapImageElement";
import { STAGE_DECO_DEFAULT } from "./floorMapStageDefaults";

/**
 * @returns 与 PisellFloorMapLayout 内联 fallback 一致的渲染函数（useCallback 由调用方包裹）
 */
/** 绑定校验失败或 renderItemByKind 抛错时的占位 */
export function renderFloorMapRenderError(message) {
  return /*#__PURE__*/React.createElement("div", {
    style: {
      padding: 8,
      fontSize: 12,
      color: '#cf1322',
      background: '#fff2f0',
      border: '1px solid #ffccc7',
      borderRadius: 4,
      height: '100%',
      boxSizing: 'border-box',
      display: 'flex',
      alignItems: 'center',
      justifyContent: 'center',
      textAlign: 'center',
      wordBreak: 'break-word'
    }
  }, message);
}
export function renderFloorMapFallbackPlaceholder(item) {
  var kind = (item === null || item === void 0 ? void 0 : item.elementKind) || 'item';
  var isCircle = (item === null || item === void 0 ? void 0 : item.shape) === 'circle';
  var isStage = kind === FLOOR_MAP_STAGE_ELEMENT_KIND;
  var nameText = (item === null || item === void 0 ? void 0 : item.name) != null ? String(item.name).trim() : '';
  var fallbackLabel = nameText || kind;
  if (isFloorMapImageElementKind(kind)) {
    var _item$_sceneElement, _item$name, _item$_sceneElement2;
    var url = (_item$_sceneElement = item._sceneElement) === null || _item$_sceneElement === void 0 ? void 0 : _item$_sceneElement.imageUrl;
    return /*#__PURE__*/React.createElement(FloorMapImageElement, {
      imageUrl: url,
      name: (_item$name = item.name) !== null && _item$name !== void 0 ? _item$name : (_item$_sceneElement2 = item._sceneElement) === null || _item$_sceneElement2 === void 0 ? void 0 : _item$_sceneElement2.name
    });
  }
  if (isStage) {
    var display = nameText || STAGE_DECO_DEFAULT.name;
    return /*#__PURE__*/React.createElement("div", {
      style: {
        width: '100%',
        height: '100%',
        boxSizing: 'border-box',
        display: 'flex',
        alignItems: 'center',
        justifyContent: 'center',
        padding: 8,
        background: 'linear-gradient(180deg, #fafafa 0%, #ececec 100%)',
        border: '2px dashed #595959',
        borderRadius: 8,
        fontSize: 15,
        fontWeight: 600,
        color: '#262626',
        textAlign: 'center',
        wordBreak: 'break-word',
        lineHeight: 1.35,
        overflow: 'hidden'
      }
    }, display);
  }
  return /*#__PURE__*/React.createElement("div", {
    style: {
      width: '100%',
      height: '100%',
      display: 'flex',
      alignItems: 'center',
      justifyContent: 'center',
      background: '#f0f0f0',
      border: '1px solid #d9d9d9',
      borderRadius: isCircle ? '50%' : 4,
      fontSize: 12,
      color: '#666',
      overflow: 'hidden',
      padding: 4,
      textAlign: 'center',
      wordBreak: 'break-word'
    }
  }, fallbackLabel);
}