"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CustomizedContent = void 0;
var react_1 = __importStar(require("react"));
var nanoid_1 = require("nanoid");
var recharts_1 = require("recharts");
var useClickableChartStyle_1 = require("../../../hooks/useClickableChartStyle");
var styles_1 = require("./styles");
var CustomizedContent = function (_a) {
    var x = _a.x, y = _a.y, width = _a.width, height = _a.height, label = _a.label, onClick = _a.onClick, group = _a.group;
    var styles = (0, styles_1.useStyles)();
    var clickable = (0, useClickableChartStyle_1.useClickableChartStyle)(onClick);
    var clipPathId = (0, react_1.useRef)((0, nanoid_1.nanoid)()).current;
    var strokeWidth = 2;
    var handleClick = function () {
        if (!onClick)
            return;
        onClick(group);
    };
    return (react_1.default.createElement("g", { "data-reltio-id": "tree-chart-content", className: clickable, onClick: handleClick },
        react_1.default.createElement("clipPath", { id: clipPathId },
            react_1.default.createElement("rect", { x: x + strokeWidth, y: y + strokeWidth, width: Math.max(width - strokeWidth * 2, 0), height: Math.max(height - strokeWidth * 2, 0) })),
        react_1.default.createElement("rect", { x: x, y: y, width: width, height: height, strokeWidth: strokeWidth, className: styles.treeBlock }),
        react_1.default.createElement(recharts_1.Text, { clipPath: "url(#".concat(clipPathId, ")"), textAnchor: "middle", verticalAnchor: "middle", width: width, x: x + width / 2, y: y + height / 2, className: styles.treeLabel }, label)));
};
exports.CustomizedContent = CustomizedContent;
