"use client";
'use strict';

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

var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
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.OrdersHistory = OrdersHistory;
