// SignalLoader — the loading state shown while the synthesis service is
// in-flight (synthesis takes ~3–8s). Pure presentational; no engine logic, no
// signal-set parsing. Used by both the Opportunities surface and the
// What-Matters-Now panel.
//
//   <window.SignalLoader label="Analyzing your financials…" lines={3} />

(function () {
  const R = window.React;
  if (!R) return;

  function SignalLoader({ label, lines }) {
    const n = lines || 3;
    const skeletons = [];
    for (let i = 0; i < n; i++) {
      skeletons.push(
        R.createElement("div", {
          key: i,
          className: "pc-intel-skeleton",
          style: {
            height: 84, borderRadius: 10, marginBottom: 12,
            background: "linear-gradient(90deg, var(--surface-2,#f1f3f5) 25%, var(--surface-1,#fff) 37%, var(--surface-2,#f1f3f5) 63%)",
            backgroundSize: "400% 100%",
            animation: "pc-intel-shimmer 1.4s ease infinite",
          },
        })
      );
    }
    return R.createElement("div", { className: "pc-intel-loader", "data-intel-state": "loading" },
      R.createElement("div", {
        style: { display: "flex", alignItems: "center", gap: 8, marginBottom: 12, color: "var(--text-2,#667085)", fontSize: 13 },
      },
        R.createElement("span", { className: "pc-spinner", "aria-hidden": "true" }),
        R.createElement("span", null, label || "Analyzing your financials…")
      ),
      skeletons,
      // Keyframes are injected once; harmless if duplicated across mounts.
      R.createElement("style", null,
        "@keyframes pc-intel-shimmer { 0% { background-position: 100% 0 } 100% { background-position: -100% 0 } }")
    );
  }

  window.SignalLoader = SignalLoader;
})();
