"use client";
'use strict';

var react = require('react');
var jsxRuntime = require('react/jsx-runtime');

var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
function AdvancedChart({ symbol = "NASDAQ:AAPL" }) {
  const container = react.useRef(null);
  react.useEffect(() => {
    if (!container.current) return;
    if (container.current.dataset.initialized === "true") {
      return;
    }
    container.current.dataset.initialized = "true";
    const script = document.createElement("script");
    script.src = "https://s3.tradingview.com/external-embedding/embed-widget-advanced-chart.js";
    script.type = "text/javascript";
    script.async = true;
    script.innerHTML = JSON.stringify({
      width: "100%",
      height: "600",
      symbol,
      interval: "D",
      timezone: "Etc/UTC",
      theme: "dark",
      style: "1",
      locale: "en",
      allow_symbol_change: true,
      calendar: false,
      support_host: "https://www.tradingview.com"
    });
    container.current.appendChild(script);
    return () => {
      if (container.current) {
        delete container.current.dataset.initialized;
        const scripts = container.current.querySelectorAll("script");
        scripts.forEach((s) => s.remove());
      }
    };
  }, [symbol]);
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tradingview-widget-container w-full h-[600px]", ref: container, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tradingview-widget-container__widget h-full" }) });
}
__name(AdvancedChart, "AdvancedChart");
var AdvancedChart_default = react.memo(AdvancedChart);

module.exports = AdvancedChart_default;
