"use strict";
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);
var html_placeholder_exports = {};
__export(html_placeholder_exports, {
  HtmlPlaceholder: () => HtmlPlaceholder,
  HtmlPlaceholderMocked: () => HtmlPlaceholderMocked
});
module.exports = __toCommonJS(html_placeholder_exports);
var import_design_system = require("@wix/design-system");
var import_react = __toESM(require("react"));
var import_defaults = require("./../plugin-html/defaults.js");
var import_html_placeholder_scss = __toESM(require("./html-placeholder-scss.js"));
const HtmlPlaceholder = ({ node }) => {
  const html = node.htmlData.html || "";
  return /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: import_html_placeholder_scss.default.container,
      style: {
        maxWidth: (node.htmlData.containerData?.width?.custom || import_defaults.INIT_WIDTH) + "px"
      }
    },
    /* @__PURE__ */ import_react.default.createElement("div", { className: import_html_placeholder_scss.default.overlay }, /* @__PURE__ */ import_react.default.createElement("div", { style: { display: "flex", gap: "8px", alignItems: "center" } }, /* @__PURE__ */ import_react.default.createElement(import_design_system.Loader, { size: "tiny" }), "Writing code...")),
    /* @__PURE__ */ import_react.default.createElement("div", { className: import_html_placeholder_scss.default.innerContainer }, formatWithLineNumbers(html))
  );
};
const formatWithLineNumbers = (inputHtml) => {
  const allLines = inputHtml.split("\n").map((line, index) => `${(index + 1).toString().padStart(4, " ")}: ${line}`);
  const lastLines = allLines.slice(-30);
  return lastLines.join("\n");
};
const HtmlPlaceholderMocked = () => {
  const lines = "sample code\nline two".split("\n");
  const [currentCuttof, setCurrentCutoff] = import_react.default.useState(1);
  import_react.default.useEffect(() => {
    if (currentCuttof < lines.length) {
      const timeout = setInterval(() => {
        setCurrentCutoff((s) => s + 3);
      }, 500);
      return () => clearInterval(timeout);
    }
  }, []);
  const sampleHtml = lines.slice(0, currentCuttof).join("\n");
  return /* @__PURE__ */ import_react.default.createElement("div", { style: { margin: "20px auto", width: "826px" } }, /* @__PURE__ */ import_react.default.createElement(HtmlPlaceholder, { node: { type: "html", htmlData: { html: sampleHtml } } }));
};
//# sourceMappingURL=html-placeholder.js.map
