"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const require$$0 = require("react/jsx-runtime");
const designSystem = require("@choiceform/design-system");
const codeBlockCode = require("./code-block-code.cjs");
const codeBlockTv = designSystem.tcv({
  slots: {
    code: "overflow-hidden",
    content: "flex w-fit flex-col overflow-clip"
  }
});
function BlockCode(props) {
  const { code, className, codeBlock } = props;
  if (!codeBlock) return null;
  const { language, isExpanded, codeExpanded, scrollRef, contentRef, lineCount, lineThreshold } = codeBlock;
  if (!isExpanded) {
    return null;
  }
  const tv = codeBlockTv();
  const shouldLimitHeight = lineCount > lineThreshold && !codeExpanded;
  return /* @__PURE__ */ require$$0.jsx("div", { className: tv.code(), children: /* @__PURE__ */ require$$0.jsx(designSystem.ScrollArea, { orientation: "both", children: /* @__PURE__ */ require$$0.jsx(
    designSystem.ScrollArea.Viewport,
    {
      ref: scrollRef,
      style: {
        maxHeight: shouldLimitHeight ? `${lineThreshold * 14 + 32}px` : "none"
      },
      children: /* @__PURE__ */ require$$0.jsx(
        designSystem.ScrollArea.Content,
        {
          ref: contentRef,
          className: tv.content(),
          children: /* @__PURE__ */ require$$0.jsx(
            codeBlockCode.CodeBlockCode,
            {
              code,
              language,
              className
            }
          )
        }
      )
    }
  ) }) });
}
exports.BlockCode = BlockCode;
//# sourceMappingURL=block-code.cjs.map
