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

var _chunkW3THU56Ecjs = require('./chunk-W3THU56E.cjs');


var _chunkMFKERIW4cjs = require('./chunk-MFKERIW4.cjs');


var _chunkRSHN4K6Ncjs = require('./chunk-RSHN4K6N.cjs');


var _chunkOBHJBBPCcjs = require('./chunk-OBHJBBPC.cjs');


var _chunkQQDRBCBYcjs = require('./chunk-QQDRBCBY.cjs');



var _chunkZ6EUSUADcjs = require('./chunk-Z6EUSUAD.cjs');

// src/components/CodeBlock.tsx
var _styled = require('@emotion/styled'); var _styled2 = _interopRequireDefault(_styled);
var _prismjs = require('prismjs'); var _prismjs2 = _interopRequireDefault(_prismjs);
require('prismjs/components/prism-dart.min.js');
require('prismjs/components/prism-go.min.js');
require('prismjs/components/prism-graphql.min.js');
require('prismjs/components/prism-java.min.js');
require('prismjs/components/prism-json.min.js');
require('prismjs/components/prism-jsx.min.js');
require('prismjs/components/prism-kotlin.min.js');
require('prismjs/components/prism-python.min.js');
require('prismjs/components/prism-rust.min.js');
require('prismjs/components/prism-swift.min.js');
require('prismjs/themes/prism-tomorrow.css');
var _react = require('react');
var _reactselect = require('react-select'); var _reactselect2 = _interopRequireDefault(_reactselect);
var _jsxruntime = require('@emotion/react/jsx-runtime');
var ProgrammingLanguageOptions = {
  Bash: "bash",
  Flutter: "dart",
  Go: "go",
  GraphQL: "graphql",
  Java: "java",
  JavaScript: "js",
  JSON: "json",
  Kotlin: "kotlin",
  Python: "python",
  React: "react",
  ReactNative: "tsx",
  Rust: "rust",
  Swift: "swift",
  Text: "txt"
};
var backgroundColor = "#2d2d2d";
var InlineCode = _styled2.default.span`
  font-family: "Roboto Mono", monospace;
  background-color: #2d2d2d;
  border: 1px solid ${_chunkOBHJBBPCcjs.themeOr.call(void 0, _chunkQQDRBCBYcjs.colors.gray90, _chunkQQDRBCBYcjs.colors.gray20)};
  border-radius: 3px;
  line-height: 24px;
  padding: 0 4px;
`;
var codeSelectStyles = {
  container: (styles) => _chunkZ6EUSUADcjs.__spreadProps.call(void 0, _chunkZ6EUSUADcjs.__spreadValues.call(void 0, {}, styles), {
    display: "flex"
  }),
  control: (styles) => _chunkZ6EUSUADcjs.__spreadProps.call(void 0, _chunkZ6EUSUADcjs.__spreadValues.call(void 0, {}, styles), {
    backgroundColor,
    border: "none",
    cursor: "pointer",
    "&:hover": {
      border: "#none"
    },
    boxShadow: "none",
    minHeight: 0
  }),
  dropdownIndicator: (styles) => _chunkZ6EUSUADcjs.__spreadProps.call(void 0, _chunkZ6EUSUADcjs.__spreadValues.call(void 0, {}, styles), {
    color: "#ffffff",
    padding: "0 0 0 4px",
    "&:hover": {
      color: "#ffffff"
    }
  }),
  indicatorSeparator: () => ({
    display: "none"
  }),
  input: (styles) => _chunkZ6EUSUADcjs.__spreadProps.call(void 0, _chunkZ6EUSUADcjs.__spreadValues.call(void 0, {}, styles), {
    fontSize: "1rem",
    margin: 0,
    color: "transparent"
  }),
  menu: (styles) => _chunkZ6EUSUADcjs.__spreadProps.call(void 0, _chunkZ6EUSUADcjs.__spreadValues.call(void 0, {}, styles), {
    backgroundColor,
    width: "auto"
  }),
  menuList: (styles) => _chunkZ6EUSUADcjs.__spreadProps.call(void 0, _chunkZ6EUSUADcjs.__spreadValues.call(void 0, {}, styles), {
    borderRadius: "4px",
    padding: 0
  }),
  option: (styles, state) => _chunkZ6EUSUADcjs.__spreadProps.call(void 0, _chunkZ6EUSUADcjs.__spreadValues.call(void 0, {}, styles), {
    cursor: "pointer",
    backgroundColor: state.isSelected ? _chunkQQDRBCBYcjs.colors.gray25 : backgroundColor,
    "&:hover": {
      backgroundColor: _chunkQQDRBCBYcjs.colors.gray25
    }
  }),
  singleValue: (styles) => _chunkZ6EUSUADcjs.__spreadProps.call(void 0, _chunkZ6EUSUADcjs.__spreadValues.call(void 0, {}, styles), {
    color: "#ffffff",
    margin: 0
  }),
  valueContainer: (styles) => _chunkZ6EUSUADcjs.__spreadProps.call(void 0, _chunkZ6EUSUADcjs.__spreadValues.call(void 0, {}, styles), {
    padding: 0
  })
};
var CodeBlock = ({
  title,
  children,
  className,
  language = "Text",
  languageOptions,
  onSelectLanguage,
  withCopyButton
}) => {
  _react.useLayoutEffect.call(void 0, () => {
    _prismjs2.default.highlightAll();
  }, [children, language]);
  const header = withCopyButton || languageOptions && onSelectLanguage ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, CodeBlockHeader, { children: [
    title && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CodeBlockHeaderTitle, { children: title }),
    /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, 
      "div",
      {
        css: {
          display: "flex",
          alignItems: "center",
          justifyContent: title ? "flex-end" : "space-between",
          width: "100%"
        },
        children: [
          languageOptions && onSelectLanguage ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { css: { margin: title ? "0 16px 0 auto" : "0" }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
            _reactselect2.default,
            {
              value: { value: language, label: language },
              options: languageOptions.map((lang) => ({
                value: lang,
                label: lang
              })),
              onChange: (selected) => {
                if (selected == null ? void 0 : selected.value) {
                  onSelectLanguage(selected.value);
                }
              },
              styles: codeSelectStyles
            }
          ) }) : null,
          withCopyButton ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkW3THU56Ecjs.CopyToClipboardButton, { value: children }) : null
        ]
      }
    )
  ] }) : null;
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, StyledCodeBlock, { className, children: [
    header,
    /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CodeBlockContainer, { hasHeader: header !== null, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "code", { className: `language-${ProgrammingLanguageOptions[language]}`, children }) })
  ] });
};
var StyledCodeBlock = _styled2.default.div``;
var CodeBlockHeader = _styled2.default.div`
  align-items: center;
  background-color: #2d2d2d;
  border-bottom: 1px solid ${_chunkQQDRBCBYcjs.colors.gray25};
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  color: #ffffff;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  padding: 16px 20px;
`;
var CodeBlockContainer = _styled2.default.pre`
  ${_chunkMFKERIW4cjs.overflowAutoWithoutScrollbars}
  &[class*="language-"] {
    padding: 20px;
    font-weight: 500;
    ${_chunkRSHN4K6Ncjs.standardBorderRadius.call(void 0, 8)}
    ${(props) => props.hasHeader ? `border-top-left-radius: 0;
            border-top-right-radius: 0;
            margin-top: 0;` : ""}
  }
`;
var CodeBlockHeaderTitle = _styled2.default.div`
  width: 100%;
  font-weight: 500;
  color: ${({ theme }) => theme.hcNeutralFromBg(backgroundColor)};
`;






exports.ProgrammingLanguageOptions = ProgrammingLanguageOptions; exports.InlineCode = InlineCode; exports.CodeBlock = CodeBlock; exports.StyledCodeBlock = StyledCodeBlock;
