import { n as __toESM } from "../_runtime.mjs";
import { u as require_react } from "../_libs/@floating-ui/react-dom+[...].mjs";
import { p as require_jsx_runtime } from "../_libs/@radix-ui/react-checkbox+[...].mjs";
import { f as useStore, r as Input, t as Button } from "./categories-MJJjwt1u.mjs";
import { h as Link } from "../_libs/@tanstack/react-router+[...].mjs";
import { C as Radio, E as Package, it as ArrowRight } from "../_libs/lucide-react.mjs";
import { l as Header, n as CheckoutFlow, t as CartDrawer, u as SignInModal } from "./Modals-PUPoXlMv.mjs";
import { t as Footer } from "./Footer-VqEE5AJo.mjs";
import { t as LiveMapTracker } from "./LiveMapTracker-CGaH0qfR.mjs";
//#region node_modules/.nitro/vite/services/ssr/assets/track-order-CtjZGxTK.js
var import_react = /* @__PURE__ */ __toESM(require_react());
var import_jsx_runtime = require_jsx_runtime();
function TrackOrderPage() {
	const [signInOpen, setSignInOpen] = (0, import_react.useState)(false);
	const [cartOpen, setCartOpen] = (0, import_react.useState)(false);
	const [checkoutOpen, setCheckoutOpen] = (0, import_react.useState)(false);
	const [orderIdInput, setOrderIdInput] = (0, import_react.useState)("");
	const { orders } = useStore();
	const matchedOrder = orders.find((o) => o.id.toLowerCase() === orderIdInput.trim().toLowerCase());
	return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
		className: "min-h-screen bg-neutral-50 flex flex-col",
		children: [
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SignInModal, {
				open: signInOpen,
				onOpenChange: setSignInOpen
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CartDrawer, {
				open: cartOpen,
				onOpenChange: setCartOpen,
				onCheckout: () => {
					setCartOpen(false);
					setCheckoutOpen(true);
				}
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CheckoutFlow, {
				open: checkoutOpen,
				onOpenChange: setCheckoutOpen
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Header, {
				onOpenCart: () => setCartOpen(true),
				onOpenSignIn: () => setSignInOpen(true)
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("main", {
				className: "flex-1 max-w-[800px] w-full mx-auto px-4 py-12 space-y-6",
				children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
					className: "bg-white p-8 rounded-xl border text-center space-y-4 shadow-sm",
					children: [
						/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
							className: "w-14 h-14 rounded-full bg-orange-100 text-orange-500 flex items-center justify-center mx-auto",
							children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Radio, { className: "w-7 h-7 animate-pulse" })
						}),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", {
							className: "text-2xl font-black text-neutral-900",
							children: "Live Order Milestone Tracking"
						}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
							className: "text-neutral-500 text-xs mt-1",
							children: "Enter your order ID (e.g. ORD-...) to track live package location on map."
						})] }),
						/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
							className: "flex gap-2 max-w-md mx-auto",
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
								value: orderIdInput,
								onChange: (e) => setOrderIdInput(e.target.value),
								placeholder: "Enter Order ID (e.g. ORD-123)",
								className: "text-sm h-11"
							}), orderIdInput ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Link, {
								to: "/orders/$id",
								params: { id: orderIdInput.trim() },
								className: "shrink-0",
								children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
									className: "bg-orange-500 hover:bg-orange-600 h-11 px-5 gap-1 font-semibold",
									children: ["Track ", /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ArrowRight, { className: "w-4 h-4" })]
								})
							}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
								disabled: true,
								className: "shrink-0 bg-orange-500 opacity-50 h-11 px-5",
								children: "Track"
							})]
						}),
						orders.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
							className: "pt-4 border-t text-left",
							children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
								className: "text-xs font-bold text-neutral-500 uppercase tracking-wider mb-2",
								children: "Recent Orders"
							}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
								className: "flex flex-wrap gap-2",
								children: orders.slice(0, 4).map((o) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Link, {
									to: "/orders/$id",
									params: { id: o.id },
									children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
										className: "text-xs font-medium px-3 py-1.5 rounded-lg border bg-neutral-50 hover:bg-orange-50 hover:border-orange-300 text-neutral-800 flex items-center gap-1.5 transition",
										children: [
											/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Package, { className: "w-3.5 h-3.5 text-orange-500" }),
											" ",
											o.id,
											" (",
											o.status,
											")"
										]
									})
								}, o.id))
							})]
						})
					]
				}), matchedOrder && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LiveMapTracker, {
					orderId: matchedOrder.id,
					status: matchedOrder.status,
					destinationAddress: matchedOrder.address,
					driverPhone: matchedOrder.driverPhone
				})]
			}),
			/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Footer, {})
		]
	});
}
//#endregion
export { TrackOrderPage as component };
