"use client";
'use strict';

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

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);
function MarketOverview() {
  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-market-overview.js";
    script.type = "text/javascript";
    script.async = true;
    script.innerHTML = JSON.stringify({
      colorTheme: "dark",
      dateRange: "12M",
      locale: "en",
      largeChartUrl: "",
      isTransparent: false,
      showFloatingTooltip: false,
      plotLineColorGrowing: "rgba(41, 98, 255, 1)",
      plotLineColorFalling: "rgba(41, 98, 255, 1)",
      gridLineColor: "rgba(240, 243, 250, 0)",
      scaleFontColor: "#DBDBDB",
      belowLineFillColorGrowing: "rgba(41, 98, 255, 0.12)",
      belowLineFillColorFalling: "rgba(41, 98, 255, 0.12)",
      belowLineFillColorGrowingBottom: "rgba(41, 98, 255, 0)",
      belowLineFillColorFallingBottom: "rgba(41, 98, 255, 0)",
      symbolActiveColor: "rgba(41, 98, 255, 0.12)",
      tabs: [
        {
          title: "Indices",
          symbols: [
            { s: "FOREXCOM:SPXUSD", d: "S&P 500 Index" },
            { s: "FOREXCOM:NSXUSD", d: "US 100 Cash CFD" },
            { s: "FOREXCOM:DJI", d: "Dow Jones Industrial Average Index" },
            { s: "INDEX:NKY", d: "Japan 225" },
            { s: "INDEX:DEU40", d: "DAX Index" },
            { s: "FOREXCOM:UKXGBP", d: "FTSE 100 Index" }
          ],
          originalTitle: "Indices"
        },
        {
          title: "Futures",
          symbols: [
            { s: "BMFBOVESPA:ISP1!", d: "S&P 500" },
            { s: "BMFBOVESPA:EUR1!", d: "Euro" },
            { s: "CMCMARKETS:GOLD", d: "Gold" },
            { s: "PYTH:WTI3!", d: "WTI Crude Oil" },
            { s: "BMFBOVESPA:CCM1!", d: "Corn" }
          ],
          originalTitle: "Futures"
        },
        {
          title: "Bonds",
          symbols: [
            { s: "EUREX:FGBL1!", d: "Euro Bund" },
            { s: "EUREX:FBTP1!", d: "Euro BTP" },
            { s: "EUREX:FGBM1!", d: "Euro BOBL" }
          ],
          originalTitle: "Bonds"
        },
        {
          title: "Forex",
          symbols: [
            { s: "FX:EURUSD", d: "EUR to USD" },
            { s: "FX:GBPUSD", d: "GBP to USD" },
            { s: "FX:USDJPY", d: "USD to JPY" },
            { s: "FX:USDCHF", d: "USD to CHF" },
            { s: "FX:AUDUSD", d: "AUD to USD" },
            { s: "FX:USDCAD", d: "USD to CAD" }
          ],
          originalTitle: "Forex"
        }
      ],
      support_host: "https://www.tradingview.com",
      backgroundColor: "#0f0f0f",
      width: "100%",
      height: "550",
      showSymbolLogo: true,
      showChart: true
    });
    container.current.appendChild(script);
    return () => {
      if (container.current) {
        delete container.current.dataset.initialized;
        const scripts = container.current.querySelectorAll("script");
        scripts.forEach((s) => s.remove());
      }
    };
  }, []);
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tradingview-widget-container w-full", ref: container, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tradingview-widget-container__widget" }) });
}
__name(MarketOverview, "MarketOverview");
var MarketOverview_default = react.memo(MarketOverview);
function TickerTape() {
  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-ticker-tape.js";
    script.type = "text/javascript";
    script.async = true;
    script.innerHTML = JSON.stringify({
      symbols: [
        { proName: "FOREXCOM:SPXUSD", title: "S&P 500" },
        { proName: "FOREXCOM:NSXUSD", title: "US 100" },
        { proName: "FX_IDC:EURUSD", title: "EUR/USD" },
        { proName: "BITSTAMP:BTCUSD", title: "Bitcoin" },
        { proName: "BITSTAMP:ETHUSD", title: "Ethereum" },
        { description: "Tesla", proName: "NASDAQ:TSLA" },
        { description: "Apple", proName: "NASDAQ:AAPL" },
        { description: "Amazon", proName: "NASDAQ:AMZN" },
        { description: "NVIDIA", proName: "NASDAQ:NVDA" },
        { description: "Microsoft", proName: "NASDAQ:MSFT" },
        { description: "Google", proName: "NASDAQ:GOOGL" },
        { description: "Meta", proName: "NASDAQ:META" }
      ],
      showSymbolLogo: true,
      isTransparent: false,
      displayMode: "adaptive",
      colorTheme: "dark",
      locale: "en"
    });
    container.current.appendChild(script);
    return () => {
      if (container.current) {
        delete container.current.dataset.initialized;
        const scripts = container.current.querySelectorAll("script");
        scripts.forEach((s) => s.remove());
      }
    };
  }, []);
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tradingview-widget-container w-full", ref: container, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tradingview-widget-container__widget" }) });
}
__name(TickerTape, "TickerTape");
var TickerTape_default = react.memo(TickerTape);
function StockScreener() {
  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-screener.js";
    script.type = "text/javascript";
    script.async = true;
    script.innerHTML = JSON.stringify({
      market: "america",
      showToolbar: true,
      defaultColumn: "overview",
      defaultScreen: "most_capitalized",
      isTransparent: false,
      locale: "en",
      colorTheme: "dark",
      width: "100%",
      height: 550
    });
    container.current.appendChild(script);
    return () => {
      if (container.current) {
        delete container.current.dataset.initialized;
        const scripts = container.current.querySelectorAll("script");
        scripts.forEach((s) => s.remove());
      }
    };
  }, []);
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tradingview-widget-container w-full", ref: container, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tradingview-widget-container__widget" }) });
}
__name(StockScreener, "StockScreener");
var StockScreener_default = react.memo(StockScreener);
function CryptoScreener() {
  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-screener.js";
    script.type = "text/javascript";
    script.async = true;
    script.innerHTML = JSON.stringify({
      defaultColumn: "overview",
      screener_type: "crypto_mkt",
      displayCurrency: "USD",
      colorTheme: "dark",
      isTransparent: false,
      locale: "en",
      width: "100%",
      height: 550
    });
    container.current.appendChild(script);
    return () => {
      if (container.current) {
        delete container.current.dataset.initialized;
        const scripts = container.current.querySelectorAll("script");
        scripts.forEach((s) => s.remove());
      }
    };
  }, []);
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tradingview-widget-container w-full", ref: container, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tradingview-widget-container__widget" }) });
}
__name(CryptoScreener, "CryptoScreener");
var CryptoScreener_default = react.memo(CryptoScreener);
function ForexScreener() {
  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-screener.js";
    script.type = "text/javascript";
    script.async = true;
    script.innerHTML = JSON.stringify({
      market: "forex",
      showToolbar: true,
      defaultColumn: "overview",
      defaultScreen: "general",
      isTransparent: false,
      locale: "en",
      colorTheme: "dark",
      width: "100%",
      height: 550
    });
    container.current.appendChild(script);
    return () => {
      if (container.current) {
        delete container.current.dataset.initialized;
        const scripts = container.current.querySelectorAll("script");
        scripts.forEach((s) => s.remove());
      }
    };
  }, []);
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tradingview-widget-container w-full", ref: container, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tradingview-widget-container__widget" }) });
}
__name(ForexScreener, "ForexScreener");
var ForexScreener_default = react.memo(ForexScreener);
function SymbolInfo({
  symbol = "NASDAQ:AAPL",
  width = "100%",
  locale = "en",
  colorTheme = "dark",
  isTransparent = false
}) {
  const containerRef = react.useRef(null);
  react.useEffect(() => {
    if (!containerRef.current) return;
    if (containerRef.current.dataset.initialized === "true") {
      return;
    }
    containerRef.current.dataset.initialized = "true";
    const script = document.createElement("script");
    script.src = "https://s3.tradingview.com/external-embedding/embed-widget-symbol-info.js";
    script.async = true;
    script.innerHTML = JSON.stringify({
      symbol,
      width,
      locale,
      colorTheme,
      isTransparent
    });
    containerRef.current.appendChild(script);
    return () => {
      if (containerRef.current) {
        delete containerRef.current.dataset.initialized;
        const scripts = containerRef.current.querySelectorAll("script");
        scripts.forEach((s) => s.remove());
      }
    };
  }, [symbol, width, locale, colorTheme, isTransparent]);
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tradingview-widget-container", ref: containerRef, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tradingview-widget-container__widget" }) });
}
__name(SymbolInfo, "SymbolInfo");
function CompanyProfile({
  symbol = "NASDAQ:AAPL",
  width = "100%",
  height = "100%",
  locale = "en",
  colorTheme = "dark",
  isTransparent = false
}) {
  const containerRef = react.useRef(null);
  react.useEffect(() => {
    if (!containerRef.current) return;
    if (containerRef.current.dataset.initialized === "true") {
      return;
    }
    containerRef.current.dataset.initialized = "true";
    const script = document.createElement("script");
    script.src = "https://s3.tradingview.com/external-embedding/embed-widget-symbol-profile.js";
    script.async = true;
    script.innerHTML = JSON.stringify({
      width,
      height,
      colorTheme,
      isTransparent,
      symbol,
      locale
    });
    containerRef.current.appendChild(script);
    return () => {
      if (containerRef.current) {
        delete containerRef.current.dataset.initialized;
        const scripts = containerRef.current.querySelectorAll("script");
        scripts.forEach((s) => s.remove());
      }
    };
  }, [symbol, width, height, locale, colorTheme, isTransparent]);
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tradingview-widget-container", ref: containerRef, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tradingview-widget-container__widget" }) });
}
__name(CompanyProfile, "CompanyProfile");
function Financials({
  symbol = "NASDAQ:AAPL",
  width = "100%",
  height = "500",
  locale = "en",
  colorTheme = "dark",
  isTransparent = false,
  displayMode = "adaptive",
  largeChartUrl = ""
}) {
  const containerRef = react.useRef(null);
  react.useEffect(() => {
    if (!containerRef.current) return;
    if (containerRef.current.dataset.initialized === "true") {
      return;
    }
    containerRef.current.dataset.initialized = "true";
    const script = document.createElement("script");
    script.src = "https://s3.tradingview.com/external-embedding/embed-widget-financials.js";
    script.async = true;
    script.innerHTML = JSON.stringify({
      colorTheme,
      isTransparent,
      largeChartUrl,
      displayMode,
      width,
      height,
      symbol,
      locale
    });
    containerRef.current.appendChild(script);
    return () => {
      if (containerRef.current) {
        delete containerRef.current.dataset.initialized;
        const scripts = containerRef.current.querySelectorAll("script");
        scripts.forEach((s) => s.remove());
      }
    };
  }, [symbol, width, height, locale, colorTheme, isTransparent, displayMode, largeChartUrl]);
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tradingview-widget-container w-full h-[500px]", ref: containerRef, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tradingview-widget-container__widget h-full" }) });
}
__name(Financials, "Financials");
function TechnicalAnalysis({
  symbol = "NASDAQ:AAPL",
  interval = "15m",
  width = "100%",
  height = "500",
  locale = "en",
  colorTheme = "dark",
  isTransparent = false,
  showIntervalTabs = true,
  displayMode = "single"
}) {
  const containerRef = react.useRef(null);
  react.useEffect(() => {
    if (!containerRef.current) return;
    if (containerRef.current.dataset.initialized === "true") {
      return;
    }
    containerRef.current.dataset.initialized = "true";
    const script = document.createElement("script");
    script.src = "https://s3.tradingview.com/external-embedding/embed-widget-technical-analysis.js";
    script.async = true;
    script.innerHTML = JSON.stringify({
      interval,
      width,
      isTransparent,
      height,
      symbol,
      showIntervalTabs,
      displayMode,
      locale,
      colorTheme
    });
    containerRef.current.appendChild(script);
    return () => {
      if (containerRef.current) {
        delete containerRef.current.dataset.initialized;
        const scripts = containerRef.current.querySelectorAll("script");
        scripts.forEach((s) => s.remove());
      }
    };
  }, [symbol, interval, width, height, locale, colorTheme, isTransparent, showIntervalTabs, displayMode]);
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tradingview-widget-container w-full h-[500px]", ref: containerRef, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tradingview-widget-container__widget h-full" }) });
}
__name(TechnicalAnalysis, "TechnicalAnalysis");
function NewsTimeline() {
  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-timeline.js";
    script.type = "text/javascript";
    script.async = true;
    script.innerHTML = JSON.stringify({
      displayMode: "regular",
      feedMode: "all_symbols",
      colorTheme: "dark",
      isTransparent: false,
      locale: "en",
      width: "100%",
      height: 550
    });
    container.current.appendChild(script);
    return () => {
      if (container.current) {
        delete container.current.dataset.initialized;
        const scripts = container.current.querySelectorAll("script");
        scripts.forEach((s) => s.remove());
      }
    };
  }, []);
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tradingview-widget-container w-full", ref: container, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tradingview-widget-container__widget" }) });
}
__name(NewsTimeline, "NewsTimeline");
var NewsTimeline_default = react.memo(NewsTimeline);
function TradingPanel({ symbol, currentPrice }) {
  const [orderType, setOrderType] = react.useState("buy");
  const [quantity, setQuantity] = react.useState("");
  const [portfolio, setPortfolio] = react.useState(null);
  const [message, setMessage] = react.useState(null);
  react.useEffect(() => {
    loadPortfolio();
  }, []);
  const loadPortfolio = /* @__PURE__ */ __name(() => {
    const storedPortfolio = localStorage.getItem("begm_portfolio");
    if (storedPortfolio) {
      setPortfolio(JSON.parse(storedPortfolio));
    } else {
      const initialPortfolio = {
        cash: 1e5,
        holdings: []
      };
      localStorage.setItem("begm_portfolio", JSON.stringify(initialPortfolio));
      setPortfolio(initialPortfolio);
    }
  }, "loadPortfolio");
  const executeTrade = /* @__PURE__ */ __name(() => {
    if (!quantity || parseFloat(quantity) <= 0) {
      setMessage({ type: "error", text: "Please enter a valid quantity" });
      return;
    }
    const qty = parseFloat(quantity);
    const total = qty * currentPrice;
    if (orderType === "buy") {
      if (total > portfolio.cash) {
        setMessage({ type: "error", text: "Insufficient funds" });
        return;
      }
      const existingHolding = portfolio.holdings.find((h) => h.symbol === symbol);
      if (existingHolding) {
        const newQuantity = existingHolding.quantity + qty;
        const newAveragePrice = (existingHolding.averagePrice * existingHolding.quantity + currentPrice * qty) / newQuantity;
        existingHolding.quantity = newQuantity;
        existingHolding.averagePrice = newAveragePrice;
        existingHolding.currentPrice = currentPrice;
      } else {
        portfolio.holdings.push({
          symbol,
          quantity: qty,
          averagePrice: currentPrice,
          currentPrice
        });
      }
      portfolio.cash -= total;
    } else {
      const existingHolding = portfolio.holdings.find((h) => h.symbol === symbol);
      if (!existingHolding || existingHolding.quantity < qty) {
        setMessage({ type: "error", text: "Insufficient shares" });
        return;
      }
      existingHolding.quantity -= qty;
      existingHolding.currentPrice = currentPrice;
      if (existingHolding.quantity === 0) {
        portfolio.holdings = portfolio.holdings.filter((h) => h.symbol !== symbol);
      }
      portfolio.cash += total;
    }
    localStorage.setItem("begm_portfolio", JSON.stringify(portfolio));
    setPortfolio({ ...portfolio });
    const orders = JSON.parse(localStorage.getItem("begm_orders") || "[]");
    orders.push({
      id: `ORD-${Date.now()}`,
      symbol,
      type: orderType,
      quantity: qty,
      price: currentPrice,
      total,
      timestamp: (/* @__PURE__ */ new Date()).toISOString(),
      status: "completed"
    });
    localStorage.setItem("begm_orders", JSON.stringify(orders));
    setMessage({
      type: "success",
      text: `Successfully ${orderType === "buy" ? "bought" : "sold"} ${qty} shares of ${symbol}`
    });
    setQuantity("");
    setTimeout(() => setMessage(null), 3e3);
  }, "executeTrade");
  const getHoldingInfo = /* @__PURE__ */ __name(() => {
    if (!portfolio) return null;
    const holding2 = portfolio.holdings.find((h) => h.symbol === symbol);
    return holding2;
  }, "getHoldingInfo");
  const holding = getHoldingInfo();
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-white/5 border border-white/10 rounded-lg p-6 backdrop-blur-xl", children: [
    /* @__PURE__ */ jsxRuntime.jsxs("h3", { className: "text-lg font-bold text-white mb-4", children: [
      "Trade ",
      symbol
    ] }),
    /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2 mb-4", children: [
      /* @__PURE__ */ jsxRuntime.jsxs(
        "button",
        {
          onClick: () => setOrderType("buy"),
          className: `flex-1 py-2 rounded-lg font-medium transition-all ${orderType === "buy" ? "bg-success text-white" : "bg-white/5 text-white/60 hover:bg-white/10"}`,
          children: [
            /* @__PURE__ */ jsxRuntime.jsx(lucideReact.TrendingUp, { size: 16, className: "inline mr-2" }),
            "Buy"
          ]
        }
      ),
      /* @__PURE__ */ jsxRuntime.jsxs(
        "button",
        {
          onClick: () => setOrderType("sell"),
          className: `flex-1 py-2 rounded-lg font-medium transition-all ${orderType === "sell" ? "bg-danger text-white" : "bg-white/5 text-white/60 hover:bg-white/10"}`,
          children: [
            /* @__PURE__ */ jsxRuntime.jsx(lucideReact.TrendingDown, { size: 16, className: "inline mr-2" }),
            "Sell"
          ]
        }
      )
    ] }),
    holding && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-4 p-3 bg-white/5 rounded-lg", children: [
      /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-white/60 mb-1", children: "Your Holdings" }),
      /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-white", children: [
        holding.quantity,
        " shares @ $",
        holding.averagePrice.toFixed(2),
        " avg"
      ] })
    ] }),
    /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-4 p-3 bg-white/5 rounded-lg", children: [
      /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-white/60 mb-1", children: "Current Price" }),
      /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-lg font-bold text-white", children: [
        "$",
        currentPrice.toFixed(2)
      ] })
    ] }),
    /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-4", children: [
      /* @__PURE__ */ jsxRuntime.jsx("label", { className: "block text-sm font-medium text-white/80 mb-2", children: "Quantity (Shares)" }),
      /* @__PURE__ */ jsxRuntime.jsx(
        "input",
        {
          type: "number",
          value: quantity,
          onChange: (e) => setQuantity(e.target.value),
          min: "1",
          step: "1",
          placeholder: "Enter quantity",
          className: "w-full px-4 py-2 bg-white/5 border border-white/10 rounded-lg text-white placeholder-white/40 focus:outline-none focus:border-success"
        }
      )
    ] }),
    quantity && parseFloat(quantity) > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-4 p-3 bg-white/5 rounded-lg", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between items-center", children: [
      /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-white/60", children: "Estimated Total" }),
      /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-lg font-bold text-white", children: [
        "$",
        (parseFloat(quantity) * currentPrice).toFixed(2)
      ] })
    ] }) }),
    /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-4 p-3 bg-white/5 rounded-lg", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between items-center", children: [
      /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-white/60", children: "Available Cash" }),
      /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-sm font-medium text-white", children: [
        "$",
        portfolio?.cash.toLocaleString() || "0"
      ] })
    ] }) }),
    message && /* @__PURE__ */ jsxRuntime.jsx("div", { className: `mb-4 p-3 rounded-lg ${message.type === "success" ? "bg-success/20 text-success" : "bg-danger/20 text-danger"}`, children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm", children: message.text }) }),
    /* @__PURE__ */ jsxRuntime.jsxs(
      "button",
      {
        onClick: executeTrade,
        className: `w-full py-3 rounded-lg font-medium transition-all ${orderType === "buy" ? "bg-success hover:bg-success/90 text-white" : "bg-danger hover:bg-danger/90 text-white"}`,
        children: [
          orderType === "buy" ? "Buy" : "Sell",
          " ",
          symbol
        ]
      }
    ),
    /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-white/40 text-center mt-4", children: "This is a demo account. No real money is at risk." })
  ] });
}
__name(TradingPanel, "TradingPanel");
function OrderEntry({
  symbol,
  accountBalance,
  onPlaceOrder,
  disabled = false
}) {
  const [orderType, setOrderType] = react.useState("market");
  const [orderSide, setOrderSide] = react.useState("buy");
  const [shares, setShares] = react.useState("");
  const [limitPrice, setLimitPrice] = react.useState("");
  const getTickerFromSymbol = /* @__PURE__ */ __name((symbol2) => {
    return symbol2.split(":")[1] || symbol2;
  }, "getTickerFromSymbol");
  const handlePlaceOrder = /* @__PURE__ */ __name(() => {
    if (!shares || orderType === "limit" && !limitPrice) return;
    onPlaceOrder({
      symbol,
      side: orderSide,
      orderType,
      shares: parseInt(shares),
      limitPrice: orderType === "limit" ? parseFloat(limitPrice) : void 0
    });
    setShares("");
    setLimitPrice("");
  }, "handlePlaceOrder");
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-4 space-y-4", children: [
    /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-white/5 rounded-lg p-3", children: [
      /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-white/60 mb-1", children: "Buying Power" }),
      /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-lg font-semibold text-white", children: [
        "$",
        accountBalance.toLocaleString()
      ] })
    ] }),
    /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-2", children: [
      /* @__PURE__ */ jsxRuntime.jsx(
        "button",
        {
          onClick: () => setOrderSide("buy"),
          disabled,
          className: `py-2.5 rounded-lg font-semibold transition-all ${orderSide === "buy" ? "bg-success text-white" : "bg-white/5 text-white/60 hover:bg-white/10"} disabled:opacity-50 disabled:cursor-not-allowed`,
          children: "Buy"
        }
      ),
      /* @__PURE__ */ jsxRuntime.jsx(
        "button",
        {
          onClick: () => setOrderSide("sell"),
          disabled,
          className: `py-2.5 rounded-lg font-semibold transition-all ${orderSide === "sell" ? "bg-danger text-white" : "bg-white/5 text-white/60 hover:bg-white/10"} disabled:opacity-50 disabled:cursor-not-allowed`,
          children: "Sell"
        }
      )
    ] }),
    /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
      /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-xs text-white/60 mb-2 block", children: "Order Type" }),
      /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-2", children: [
        /* @__PURE__ */ jsxRuntime.jsx(
          "button",
          {
            onClick: () => setOrderType("market"),
            disabled,
            className: `py-2 rounded-lg text-sm font-medium transition-all ${orderType === "market" ? "bg-white/10 text-white" : "bg-white/5 text-white/60 hover:bg-white/10"} disabled:opacity-50 disabled:cursor-not-allowed`,
            children: "Market"
          }
        ),
        /* @__PURE__ */ jsxRuntime.jsx(
          "button",
          {
            onClick: () => setOrderType("limit"),
            disabled,
            className: `py-2 rounded-lg text-sm font-medium transition-all ${orderType === "limit" ? "bg-white/10 text-white" : "bg-white/5 text-white/60 hover:bg-white/10"} disabled:opacity-50 disabled:cursor-not-allowed`,
            children: "Limit"
          }
        )
      ] })
    ] }),
    /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
      /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-xs text-white/60 mb-2 block", children: "Shares" }),
      /* @__PURE__ */ jsxRuntime.jsx(
        "input",
        {
          type: "number",
          value: shares,
          onChange: (e) => setShares(e.target.value),
          disabled,
          className: "w-full bg-white/5 border border-white/10 rounded-lg px-4 py-2.5 text-white focus:outline-none focus:border-success disabled:opacity-50 disabled:cursor-not-allowed",
          placeholder: "0"
        }
      )
    ] }),
    orderType === "limit" && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
      /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-xs text-white/60 mb-2 block", children: "Limit Price" }),
      /* @__PURE__ */ jsxRuntime.jsx(
        "input",
        {
          type: "number",
          value: limitPrice,
          onChange: (e) => setLimitPrice(e.target.value),
          disabled,
          className: "w-full bg-white/5 border border-white/10 rounded-lg px-4 py-2.5 text-white focus:outline-none focus:border-success disabled:opacity-50 disabled:cursor-not-allowed",
          placeholder: "0.00",
          step: "0.01"
        }
      )
    ] }),
    /* @__PURE__ */ jsxRuntime.jsxs(
      "button",
      {
        onClick: handlePlaceOrder,
        disabled: disabled || !shares || orderType === "limit" && !limitPrice,
        className: `w-full py-3 rounded-lg font-semibold transition-all ${orderSide === "buy" ? "bg-success hover:bg-success/90 text-white" : "bg-danger hover:bg-danger/90 text-white"} disabled:opacity-50 disabled:cursor-not-allowed`,
        children: [
          orderSide === "buy" ? "Buy" : "Sell",
          " ",
          getTickerFromSymbol(symbol)
        ]
      }
    )
  ] });
}
__name(OrderEntry, "OrderEntry");
function PositionsList({ positions, onPositionClick }) {
  const getTickerFromSymbol = /* @__PURE__ */ __name((symbol) => {
    return symbol.split(":")[1] || symbol;
  }, "getTickerFromSymbol");
  if (positions.length === 0) {
    return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 text-center py-8 text-white/40", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm", children: "No open positions" }) });
  }
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 space-y-2", children: positions.map((position) => {
    const pl = (position.currentPrice - position.avgPrice) * position.shares;
    const plPercent = (position.currentPrice - position.avgPrice) / position.avgPrice * 100;
    const totalValue = position.currentPrice * position.shares;
    return /* @__PURE__ */ jsxRuntime.jsxs(
      "div",
      {
        className: `bg-white/5 rounded-lg p-3 ${onPositionClick ? "cursor-pointer hover:bg-white/10 transition-colors" : ""}`,
        onClick: () => onPositionClick?.(position),
        children: [
          /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between mb-2", children: [
            /* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-semibold text-white", children: getTickerFromSymbol(position.symbol) }),
            /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex items-center gap-1 text-sm ${pl >= 0 ? "text-success" : "text-danger"}`, children: [
              pl >= 0 ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.TrendingUp, { size: 14 }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.TrendingDown, { size: 14 }),
              pl >= 0 ? "+" : "",
              plPercent.toFixed(2),
              "%"
            ] })
          ] }),
          /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-2 text-xs", children: [
            /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
              /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-white/60", children: "Shares" }),
              /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-white font-medium", children: position.shares })
            ] }),
            /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
              /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-white/60", children: "Avg Price" }),
              /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-white font-medium", children: [
                "$",
                position.avgPrice.toFixed(2)
              ] })
            ] })
          ] }),
          /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-2 text-xs mt-2 pt-2 border-t border-white/10", children: [
            /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
              /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-white/60", children: "Current Price" }),
              /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-white font-medium", children: [
                "$",
                position.currentPrice.toFixed(2)
              ] })
            ] }),
            /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
              /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-white/60", children: "Total Value" }),
              /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-white font-medium", children: [
                "$",
                totalValue.toFixed(2)
              ] })
            ] })
          ] }),
          /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 pt-2 border-t border-white/10", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between items-center text-xs", children: [
            /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-white/60", children: "P&L" }),
            /* @__PURE__ */ jsxRuntime.jsxs("span", { className: `font-semibold ${pl >= 0 ? "text-success" : "text-danger"}`, children: [
              pl >= 0 ? "+" : "",
              "$",
              pl.toFixed(2)
            ] })
          ] }) })
        ]
      },
      position.symbol
    );
  }) });
}
__name(PositionsList, "PositionsList");
function OrdersHistory({ orders, onCancelOrder, onOrderClick }) {
  const getTickerFromSymbol = /* @__PURE__ */ __name((symbol) => {
    return symbol.split(":")[1] || symbol;
  }, "getTickerFromSymbol");
  if (orders.length === 0) {
    return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 text-center py-8 text-white/40", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm", children: "No orders yet" }) });
  }
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 space-y-2", children: orders.map((order) => /* @__PURE__ */ jsxRuntime.jsxs(
    "div",
    {
      className: `bg-white/5 rounded-lg p-3 ${onOrderClick ? "cursor-pointer hover:bg-white/10 transition-colors" : ""}`,
      onClick: () => onOrderClick?.(order),
      children: [
        /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start justify-between mb-2", children: [
          /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
            /* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-semibold text-white", children: getTickerFromSymbol(order.symbol) }),
            /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-white/60", children: new Date(order.timestamp).toLocaleString() })
          ] }),
          /* @__PURE__ */ jsxRuntime.jsx("div", { className: `text-xs px-2 py-1 rounded ${order.status === "filled" ? "bg-success/20 text-success" : order.status === "cancelled" ? "bg-white/10 text-white/60" : order.status === "pending" ? "bg-yellow-500/20 text-yellow-400" : "bg-blue-500/20 text-blue-400"}`, children: order.status.charAt(0).toUpperCase() + order.status.slice(1) })
        ] }),
        /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-3 gap-2 text-xs", children: [
          /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
            /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-white/60", children: "Side" }),
            /* @__PURE__ */ jsxRuntime.jsx("div", { className: `font-medium ${order.type === "buy" ? "text-success" : "text-danger"}`, children: order.type.toUpperCase() })
          ] }),
          /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
            /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-white/60", children: "Shares" }),
            /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-white font-medium", children: order.shares })
          ] }),
          /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
            /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-white/60", children: "Price" }),
            /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-white font-medium", children: order.price > 0 ? `$${order.price.toFixed(2)}` : "Market" })
          ] })
        ] }),
        order.orderType && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-2 text-xs", children: [
          /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-white/60", children: "Type: " }),
          /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-white font-medium", children: order.orderType.charAt(0).toUpperCase() + order.orderType.slice(1) })
        ] }),
        order.status === "open" && onCancelOrder && /* @__PURE__ */ jsxRuntime.jsx(
          "button",
          {
            onClick: (e) => {
              e.stopPropagation();
              onCancelOrder(order.id);
            },
            className: "w-full mt-2 py-1.5 text-xs bg-white/5 hover:bg-white/10 text-white/80 rounded transition-colors",
            children: "Cancel Order"
          }
        )
      ]
    },
    order.id
  )) });
}
__name(OrdersHistory, "OrdersHistory");

exports.AdvancedChart = AdvancedChart_default;
exports.CompanyProfile = CompanyProfile;
exports.CryptoScreener = CryptoScreener_default;
exports.Financials = Financials;
exports.ForexScreener = ForexScreener_default;
exports.MarketOverview = MarketOverview_default;
exports.NewsTimeline = NewsTimeline_default;
exports.OrderEntry = OrderEntry;
exports.OrdersHistory = OrdersHistory;
exports.PositionsList = PositionsList;
exports.StockScreener = StockScreener_default;
exports.SymbolInfo = SymbolInfo;
exports.TechnicalAnalysis = TechnicalAnalysis;
exports.TickerTape = TickerTape_default;
exports.TradingPanel = TradingPanel;
