import { gt as useAccountApi } from "./PortalTenantClientProvider-BmRtQAbi.mjs";
import { B as useLanguagesApi, V as usePayApi, n as useFluidContext } from "./FluidProvider-mimp_bb9.mjs";
import { n as useCountriesApi } from "./countries-api-context-DScC_39w.mjs";
import { On as useZodForm, Q as DialogContent, R as Label, X as Dialog, et as DialogFooter, f as fluidToast, fn as BreadcrumbList, it as DialogTitle, k as Input, ln as Breadcrumb, pn as BreadcrumbPage, tt as DialogHeader, un as BreadcrumbItem, wn as Button } from "./src-CJw6JbdS.mjs";
import { n as ScreenHeaderBreadcrumbs } from "./ScreenHeaderContext-BjpQOCck.mjs";
import { n as payKeys, r as storeKeys, t as accountKeys } from "./query-keys-xJy_fapN.mjs";
import { t as useAccount } from "./use-account-CwGoFpwg.mjs";
import { a as AddressFormDialog, d as UserInfoDialog, f as ConfirmActionDialog, h as useProfileTranslation, i as CreditCardFormDialog, m as ProfileTranslationBridge, n as createFluidPayApiAdapter, o as EditPaymentMethodDialog, p as EllipsesDropdown, r as mapToFluidPayPaymentMethod, s as FluidPayCoreProvider, t as AddressAutocompleteInput } from "./AddressAutocompleteInput-Bre6nbGH.mjs";
import { f as usePortalUpdateSettings, s as usePortalMySiteProfile } from "./use-mysite-portal-ChDJ4z34.mjs";
import { useCallback, useMemo, useState } from "react";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
import { Copy, Facebook, Globe, Instagram, Link2, Linkedin, LogOut, Mail, MapPin, Pencil, Phone, Plus, Quote, Sparkles, Twitter, User, Youtube } from "lucide-react";
import { z } from "zod";
//#region src/screens/profile/derive-last-name.ts
function deriveLastName(firstName, fullName) {
	if (!firstName) return "";
	const prefix = `${firstName} `;
	return fullName.startsWith(prefix) ? fullName.slice(prefix.length) : "";
}
//#endregion
//#region src/screens/profile/ProfileLayout.tsx
function ProfileLayout(props) {
	const { t } = useProfileTranslation();
	const { account, pointsBalance, pointsLedger, rewardsEnabled, addresses, paymentMethods, mySiteDisplayUrl, socialLinks, onEditPersonalInfo, onAddAddress, onEditAddress, onDeleteAddress, onAddPaymentMethod, onEditPaymentMethod, onCopyMySiteLink, onEditMySiteLink, onConnectSocial, onSignOut } = props;
	const fullName = `${account.first_name ?? ""} ${account.last_name ?? ""}`.trim();
	const heroDisplay = (account.first_name || "").trim().split(" ")[0] || account.email?.split("@")[0] || t("account_fallback");
	const connectedSocialCount = Object.values(socialLinks).filter((v) => typeof v === "string" && v.length > 0).length;
	const [isPointsHistoryOpen, setIsPointsHistoryOpen] = useState(false);
	const POINTS_PREVIEW_COUNT = 4;
	const ledger = pointsLedger ?? [];
	const ledgerPreview = ledger.slice(0, POINTS_PREVIEW_COUNT);
	const hasMoreLedger = ledger.length > POINTS_PREVIEW_COUNT;
	return /* @__PURE__ */ jsx("div", {
		className: "relative",
		children: /* @__PURE__ */ jsxs("div", {
			className: "relative mx-auto max-w-4xl px-5 pt-8 pb-20 md:px-8",
			children: [
				/* @__PURE__ */ jsxs("section", {
					className: "flex items-center gap-3.5",
					children: [
						/* @__PURE__ */ jsx("div", {
							className: "relative size-12 shrink-0 overflow-hidden rounded-full ring-1 ring-black/5 md:size-13",
							children: account.avatar_url ? /* @__PURE__ */ jsx("img", {
								src: account.avatar_url,
								alt: "",
								className: "h-full w-full object-cover"
							}) : /* @__PURE__ */ jsx("div", {
								className: "bg-primary text-primary-foreground flex h-full w-full items-center justify-center text-lg font-semibold",
								children: heroDisplay.charAt(0).toUpperCase()
							})
						}),
						/* @__PURE__ */ jsxs("div", {
							className: "min-w-0 flex-1",
							children: [/* @__PURE__ */ jsx("h1", {
								className: "text-foreground truncate text-xl font-bold tracking-tight md:text-2xl",
								children: heroDisplay
							}), /* @__PURE__ */ jsx("p", {
								className: "text-muted-foreground mt-0.5 truncate text-sm",
								children: account.email
							})]
						}),
						/* @__PURE__ */ jsx("div", {
							className: "flex shrink-0 items-center gap-2",
							children: rewardsEnabled && /* @__PURE__ */ jsxs("div", {
								className: "ring-border text-foreground inline-flex items-center gap-1.5 rounded-md bg-transparent px-2.5 py-1 text-xs font-semibold ring-1",
								children: [
									/* @__PURE__ */ jsx(Sparkles, {
										className: "text-primary size-3",
										strokeWidth: 2.25
									}),
									(pointsBalance ?? 0).toLocaleString(),
									" ",
									t("pts")
								]
							})
						})
					]
				}),
				/* @__PURE__ */ jsx(SectionHeader, {
					title: t("personal_information"),
					action: /* @__PURE__ */ jsx(PillButton, {
						onClick: onEditPersonalInfo,
						icon: Pencil,
						label: t("edit")
					})
				}),
				/* @__PURE__ */ jsxs("div", {
					className: "ring-border mt-2.5 overflow-hidden rounded-2xl bg-transparent ring-1",
					children: [
						/* @__PURE__ */ jsx(FieldRow, {
							icon: User,
							label: t("name"),
							value: fullName || account.first_name || ""
						}),
						/* @__PURE__ */ jsx(FieldRow, {
							icon: Mail,
							label: t("email"),
							value: account.email ?? ""
						}),
						/* @__PURE__ */ jsx(FieldRow, {
							icon: Phone,
							label: t("phone"),
							value: account.phone ?? "",
							placeholder: t("add_phone_number")
						}),
						/* @__PURE__ */ jsx(FieldRow, {
							icon: Quote,
							label: t("bio"),
							value: account.bio ?? "",
							placeholder: t("add_a_short_bio"),
							multiline: true,
							isLast: true
						})
					]
				}),
				/* @__PURE__ */ jsx(SectionHeader, { title: t("payment_methods") }),
				/* @__PURE__ */ jsxs("div", {
					className: "mt-2.5 grid grid-cols-1 gap-2.5 sm:grid-cols-3",
					children: [paymentMethods.map((method) => /* @__PURE__ */ jsx(PaymentCardVisual, {
						method,
						onClick: () => onEditPaymentMethod(method)
					}, method.id)), /* @__PURE__ */ jsx(AddPaymentTile, { onClick: onAddPaymentMethod })]
				}),
				rewardsEnabled && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(SectionHeader, {
					title: t("points_history"),
					action: /* @__PURE__ */ jsx("span", {
						className: "text-muted-foreground/75 text-xs",
						children: t("pts_available", { count: String((pointsBalance ?? 0).toLocaleString()) })
					})
				}), ledger.length > 0 ? /* @__PURE__ */ jsxs("div", {
					className: "ring-border mt-2.5 overflow-hidden rounded-2xl bg-transparent ring-1",
					children: [ledgerPreview.map((entry, i) => /* @__PURE__ */ jsx(PointsLedgerRow, {
						entry,
						isLast: !hasMoreLedger && i === ledgerPreview.length - 1
					}, entry.id)), hasMoreLedger && /* @__PURE__ */ jsx("button", {
						type: "button",
						onClick: () => setIsPointsHistoryOpen(true),
						className: "text-foreground hover:bg-muted flex w-full items-center justify-center gap-1 px-4 py-3 text-xs font-bold transition-colors",
						children: t("see_all_transactions", { count: ledger.length })
					})]
				}) : /* @__PURE__ */ jsxs("div", {
					className: "ring-dashed ring-border mt-2.5 flex flex-col items-center justify-center gap-1 rounded-2xl bg-transparent px-4 py-8 text-center ring-1",
					children: [
						/* @__PURE__ */ jsx(Sparkles, {
							className: "text-muted-foreground/75 size-5",
							strokeWidth: 1.75
						}),
						/* @__PURE__ */ jsx("div", {
							className: "text-foreground text-sm font-bold",
							children: t("no_points_yet")
						}),
						/* @__PURE__ */ jsx("div", {
							className: "text-muted-foreground text-xs",
							children: t("earn_points_hint")
						})
					]
				})] }),
				/* @__PURE__ */ jsx(SectionHeader, {
					title: t("your_mysite_link"),
					action: onEditMySiteLink ? /* @__PURE__ */ jsx(PillButton, {
						onClick: onEditMySiteLink,
						icon: Pencil,
						label: t("edit_link")
					}) : void 0
				}),
				/* @__PURE__ */ jsxs("div", {
					className: "ring-border mt-2.5 flex items-center gap-3 rounded-2xl bg-transparent p-3.5 ring-1",
					children: [
						/* @__PURE__ */ jsx("div", {
							className: "bg-muted text-foreground flex size-11 shrink-0 items-center justify-center rounded-full",
							children: /* @__PURE__ */ jsx(Link2, {
								className: "size-[18px]",
								strokeWidth: 2
							})
						}),
						/* @__PURE__ */ jsxs("div", {
							className: "min-w-0 flex-1",
							children: [/* @__PURE__ */ jsx("div", {
								className: "text-muted-foreground/75 text-xs font-bold tracking-widest uppercase",
								children: t("public_link")
							}), /* @__PURE__ */ jsx("div", {
								className: "text-foreground mt-0.5 truncate font-mono text-sm font-semibold",
								children: mySiteDisplayUrl || t("set_your_mysite_link")
							})]
						}),
						/* @__PURE__ */ jsxs("button", {
							type: "button",
							onClick: onCopyMySiteLink,
							disabled: !mySiteDisplayUrl,
							className: "ring-border text-foreground hover:bg-muted inline-flex items-center gap-1 rounded-md bg-transparent px-3 py-1.5 text-xs font-bold ring-1 transition-all disabled:cursor-not-allowed disabled:opacity-40",
							children: [/* @__PURE__ */ jsx(Copy, {
								className: "size-3",
								strokeWidth: 2.25
							}), t("copy")]
						})
					]
				}),
				/* @__PURE__ */ jsx(SectionHeader, { title: t("shipping_addresses") }),
				/* @__PURE__ */ jsxs("div", {
					className: "mt-2.5 grid grid-cols-1 gap-2.5 sm:grid-cols-2",
					children: [addresses.map((address) => /* @__PURE__ */ jsx(AddressCard, {
						address,
						onEdit: () => onEditAddress(address),
						onDelete: address.default ? void 0 : () => onDeleteAddress(address)
					}, address.id)), /* @__PURE__ */ jsx(AddAddressTile, { onClick: onAddAddress })]
				}),
				/* @__PURE__ */ jsx(SectionHeader, {
					title: t("social_media"),
					action: /* @__PURE__ */ jsx("span", {
						className: "text-muted-foreground/75 text-xs",
						children: t("connected_count", { count: connectedSocialCount })
					})
				}),
				/* @__PURE__ */ jsx("div", {
					className: "ring-border mt-2.5 overflow-hidden rounded-2xl bg-transparent ring-1",
					children: SOCIAL_ENTRIES.map((entry, i) => /* @__PURE__ */ jsx(SocialRow, {
						entry,
						handle: socialLinks[entry.key] ?? "",
						isLast: i === SOCIAL_ENTRIES.length - 1,
						onConnect: () => onConnectSocial(entry.key)
					}, entry.key))
				}),
				/* @__PURE__ */ jsx(Dialog, {
					open: isPointsHistoryOpen,
					onOpenChange: setIsPointsHistoryOpen,
					children: /* @__PURE__ */ jsxs(DialogContent, {
						className: "max-w-md md:max-w-lg",
						children: [/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: t("points_history") }) }), /* @__PURE__ */ jsx("div", {
							className: "ring-border max-h-[60vh] overflow-y-auto rounded-2xl bg-transparent ring-1",
							children: ledger.map((entry, i) => /* @__PURE__ */ jsx(PointsLedgerRow, {
								entry,
								isLast: i === ledger.length - 1
							}, entry.id))
						})]
					})
				}),
				onSignOut && /* @__PURE__ */ jsxs("div", {
					className: "ring-border mt-8 flex flex-wrap items-center justify-between gap-3 rounded-2xl bg-transparent p-3.5 ring-1",
					children: [/* @__PURE__ */ jsxs("div", {
						className: "flex items-center gap-3",
						children: [/* @__PURE__ */ jsx("div", {
							className: "bg-destructive/10 flex size-9 items-center justify-center rounded-md",
							children: /* @__PURE__ */ jsx(LogOut, {
								className: "text-destructive size-4",
								strokeWidth: 2.25
							})
						}), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("div", {
							className: "text-foreground text-sm font-bold",
							children: t("sign_out")
						}), /* @__PURE__ */ jsx("div", {
							className: "text-muted-foreground text-xs",
							children: t("sign_out_description")
						})] })]
					}), /* @__PURE__ */ jsx("button", {
						type: "button",
						onClick: onSignOut,
						className: "bg-destructive/15 text-destructive hover:bg-destructive/25 rounded-md px-4 py-2 text-xs font-bold transition-colors",
						children: t("sign_out")
					})]
				})
			]
		})
	});
}
function SectionHeader({ title, action }) {
	return /* @__PURE__ */ jsxs("div", {
		className: "mt-8 flex items-end justify-between",
		children: [/* @__PURE__ */ jsx("h2", {
			className: "text-foreground text-base font-bold tracking-tight",
			children: title
		}), action ?? null]
	});
}
function PillButton({ onClick, icon: Icon, label, disabled }) {
	return /* @__PURE__ */ jsxs("button", {
		type: "button",
		onClick,
		disabled,
		className: "ring-border text-foreground hover:bg-muted inline-flex items-center gap-1 rounded-md bg-transparent px-3 py-1.5 text-xs font-bold ring-1 transition-all disabled:cursor-not-allowed disabled:opacity-40",
		children: [/* @__PURE__ */ jsx(Icon, {
			className: "size-3",
			strokeWidth: 2.25
		}), label]
	});
}
function PointsLedgerRow({ entry, isLast }) {
	const { t } = useProfileTranslation();
	const isCredit = entry.amount >= 0;
	const sign = isCredit ? "+" : "−";
	const magnitude = Math.abs(entry.amount).toLocaleString();
	const amountColor = isCredit ? "text-emerald-600" : "text-destructive";
	const sourceName = entry.metadata?.source?.name?.trim();
	const transactionType = entry.metadata?.transaction_type;
	const label = sourceName || (transactionType ? transactionType.charAt(0).toUpperCase() + transactionType.slice(1) : isCredit ? t("points_awarded") : t("points_redeemed"));
	const dateLabel = formatLedgerDate(entry.created_at);
	return /* @__PURE__ */ jsxs("div", {
		className: `flex items-center gap-3 px-4 py-3.5 ${isLast ? "" : "border-border border-b"}`,
		children: [
			/* @__PURE__ */ jsx("div", {
				className: "bg-muted flex size-9 shrink-0 items-center justify-center rounded-full",
				children: /* @__PURE__ */ jsx(Sparkles, {
					className: `size-4 ${isCredit ? "text-primary" : "text-muted-foreground"}`,
					strokeWidth: 2
				})
			}),
			/* @__PURE__ */ jsxs("div", {
				className: "min-w-0 flex-1",
				children: [/* @__PURE__ */ jsx("div", {
					className: "text-foreground truncate text-sm font-medium",
					children: label
				}), /* @__PURE__ */ jsx("div", {
					className: "text-muted-foreground text-xs",
					children: dateLabel
				})]
			}),
			/* @__PURE__ */ jsxs("div", {
				className: `shrink-0 font-mono text-sm font-bold tabular-nums ${amountColor}`,
				children: [sign, magnitude]
			})
		]
	});
}
function formatLedgerDate(iso) {
	try {
		return new Date(iso).toLocaleDateString(void 0, {
			month: "short",
			day: "numeric",
			year: "numeric"
		});
	} catch {
		return iso;
	}
}
function FieldRow({ icon: Icon, label, value, placeholder, isLast, multiline }) {
	const display = value || placeholder || "";
	return /* @__PURE__ */ jsxs("div", {
		className: `flex gap-3 px-4 py-3.5 ${multiline ? "items-start" : "items-center"} ${isLast ? "" : "border-border border-b"}`,
		children: [/* @__PURE__ */ jsx("div", {
			className: "bg-muted text-muted-foreground flex size-9 shrink-0 items-center justify-center rounded-full",
			children: /* @__PURE__ */ jsx(Icon, {
				className: "size-4",
				strokeWidth: 2
			})
		}), /* @__PURE__ */ jsxs("div", {
			className: "min-w-0 flex-1",
			children: [/* @__PURE__ */ jsx("div", {
				className: "text-muted-foreground/75 text-xs font-bold tracking-widest uppercase",
				children: label
			}), /* @__PURE__ */ jsx("div", {
				className: `mt-0.5 ${multiline ? "whitespace-pre-line" : "truncate"} text-sm font-medium ${!value && Boolean(placeholder) ? "text-muted-foreground/55" : "text-foreground"}`,
				children: display
			})]
		})]
	});
}
const CARD_BRAND_LABEL = {
	amex: "AMERICAN EXPRESS",
	visa: "VISA",
	mastercard: "MASTERCARD",
	discover: "DISCOVER",
	diners: "DINERS CLUB",
	jcb: "JCB",
	unionpay: "UNIONPAY"
};
const CARD_BRAND_BADGE = {
	amex: "AMEX",
	visa: "VISA",
	mastercard: "MC",
	discover: "DISC",
	diners: "DC",
	jcb: "JCB",
	unionpay: "UPI"
};
function PaymentCardVisual({ method, onClick }) {
	const { t } = useProfileTranslation();
	const brand = (method.details.card_brand || "").toLowerCase();
	const brandLabel = CARD_BRAND_LABEL[brand] || (brand ? brand.toUpperCase() : "CARD");
	const badge = CARD_BRAND_BADGE[brand] || "CARD";
	const last4 = method.details.last_four ?? "••••";
	const expMonth = String(method.details.exp_month ?? "").padStart(2, "0");
	const expYear = String(method.details.exp_year ?? "").slice(-2);
	const exp = expMonth && expYear ? `${expMonth}/${expYear}` : "";
	const holder = method.details.card_holder || method.billing_address?.name || "";
	const badgeBg = brand === "visa" ? "bg-[#1A1F71]" : brand === "mastercard" ? "bg-[#EB001B]" : "bg-[#0064D2]";
	return /* @__PURE__ */ jsxs("button", {
		type: "button",
		onClick,
		className: "group bg-foreground text-background ring-foreground/10 relative flex aspect-[1.586/1] flex-col justify-between overflow-hidden rounded-xl p-4 text-left shadow-sm ring-1 transition-all duration-200 hover:-translate-y-0.5 hover:shadow-lg",
		children: [
			/* @__PURE__ */ jsx("div", {
				"aria-hidden": true,
				className: "absolute inset-0 bg-[repeating-linear-gradient(135deg,transparent_0px,transparent_22px,currentColor_22px,currentColor_24px)] opacity-[0.04]"
			}),
			/* @__PURE__ */ jsxs("div", {
				className: "relative flex items-start justify-between",
				children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("div", {
					className: "text-background/50 text-xs font-semibold tracking-widest uppercase",
					children: brandLabel
				}), /* @__PURE__ */ jsx("div", {
					className: "text-background mt-1 font-mono text-xl font-bold tracking-wider",
					children: last4
				})] }), method.default && /* @__PURE__ */ jsx("span", {
					className: "bg-background/10 text-background/80 rounded-md px-2 py-0.5 text-xs font-bold tracking-wider uppercase",
					children: t("default")
				})]
			}),
			/* @__PURE__ */ jsxs("div", {
				className: "relative flex items-end justify-between gap-2",
				children: [
					/* @__PURE__ */ jsxs("div", {
						className: "min-w-0 flex-1",
						children: [/* @__PURE__ */ jsx("div", {
							className: "text-background/40 text-xs font-semibold tracking-widest uppercase",
							children: t("cardholder")
						}), /* @__PURE__ */ jsx("div", {
							className: "text-background truncate text-xs font-semibold",
							children: holder || " "
						})]
					}),
					/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("div", {
						className: "text-background/40 text-xs font-semibold tracking-widest uppercase",
						children: t("card_expires")
					}), /* @__PURE__ */ jsx("div", {
						className: "text-background font-mono text-xs font-semibold",
						children: exp
					})] }),
					/* @__PURE__ */ jsx("div", {
						className: `shrink-0 rounded px-1.5 py-0.5 text-xs font-bold tracking-wider text-white ${badgeBg}`,
						children: badge
					})
				]
			})
		]
	});
}
function AddPaymentTile({ onClick }) {
	const { t } = useProfileTranslation();
	return /* @__PURE__ */ jsxs("button", {
		type: "button",
		onClick,
		className: "group ring-dashed ring-border text-muted-foreground hover:bg-background hover:text-foreground flex aspect-[1.586/1] flex-col items-center justify-center gap-1.5 rounded-xl bg-transparent ring-1 transition-colors",
		children: [
			/* @__PURE__ */ jsx("div", {
				className: "ring-border flex size-9 items-center justify-center rounded-full bg-transparent ring-1",
				children: /* @__PURE__ */ jsx(Plus, {
					className: "size-4",
					strokeWidth: 2.25
				})
			}),
			/* @__PURE__ */ jsx("div", {
				className: "text-foreground text-xs font-bold",
				children: t("add_payment_method")
			}),
			/* @__PURE__ */ jsx("div", {
				className: "text-muted-foreground/75 text-xs",
				children: t("accepted_cards")
			})
		]
	});
}
function AddressCard({ address, onEdit, onDelete }) {
	const { t } = useProfileTranslation();
	const label = address.name?.trim() || t("address");
	const cityLine = [
		address.city,
		address.state,
		address.postal_code
	].filter(Boolean).join(", ");
	return /* @__PURE__ */ jsxs("div", {
		className: "ring-border hover:bg-muted focus-within:ring-foreground/40 relative flex flex-col rounded-2xl bg-transparent ring-1 transition-all duration-200 focus-within:ring-2 hover:ring-2",
		children: [/* @__PURE__ */ jsxs("button", {
			type: "button",
			onClick: onEdit,
			className: "flex w-full flex-col rounded-2xl p-4 pr-12 text-left focus-visible:outline-none",
			children: [/* @__PURE__ */ jsxs("div", {
				className: "flex items-start justify-between gap-2",
				children: [/* @__PURE__ */ jsxs("div", {
					className: "flex items-center gap-2",
					children: [/* @__PURE__ */ jsx("div", {
						className: "bg-muted flex size-8 items-center justify-center rounded-full",
						children: /* @__PURE__ */ jsx(MapPin, {
							className: "text-muted-foreground size-4",
							strokeWidth: 2
						})
					}), /* @__PURE__ */ jsx("div", {
						className: "text-foreground text-sm font-bold",
						children: label
					})]
				}), address.default && /* @__PURE__ */ jsx("span", {
					className: "bg-primary text-primary-foreground rounded-md px-2 py-0.5 text-xs font-bold tracking-wider uppercase",
					children: t("default")
				})]
			}), /* @__PURE__ */ jsxs("div", {
				className: "text-foreground mt-3 space-y-0.5 text-sm leading-snug",
				children: [
					address.address1 && /* @__PURE__ */ jsx("div", { children: address.address1 }),
					address.address2 && /* @__PURE__ */ jsx("div", { children: address.address2 }),
					cityLine && /* @__PURE__ */ jsx("div", { children: cityLine }),
					address.country_code && /* @__PURE__ */ jsx("div", {
						className: "text-muted-foreground",
						children: address.country_code
					})
				]
			})]
		}), onDelete && /* @__PURE__ */ jsx("div", {
			className: "absolute top-2 right-2 z-10",
			children: /* @__PURE__ */ jsx(EllipsesDropdown, {
				onEdit,
				onDelete,
				editLabel: t("edit"),
				deleteLabel: t("delete")
			})
		})]
	});
}
function AddAddressTile({ onClick }) {
	const { t } = useProfileTranslation();
	return /* @__PURE__ */ jsxs("button", {
		type: "button",
		onClick,
		className: "group ring-dashed ring-border text-muted-foreground hover:bg-background hover:text-foreground flex min-h-37 flex-col items-center justify-center gap-1.5 rounded-2xl bg-transparent ring-1 transition-colors",
		children: [/* @__PURE__ */ jsx("div", {
			className: "ring-border flex size-9 items-center justify-center rounded-full bg-transparent ring-1",
			children: /* @__PURE__ */ jsx(Plus, {
				className: "size-4",
				strokeWidth: 2.25
			})
		}), /* @__PURE__ */ jsx("div", {
			className: "text-foreground text-sm font-bold",
			children: t("add_an_address")
		})]
	});
}
const SOCIAL_ENTRIES = [
	{
		key: "linkedin",
		label: "LinkedIn",
		icon: Linkedin,
		placeholder: "linkedin.com/in/username"
	},
	{
		key: "facebook",
		label: "Facebook",
		icon: Facebook,
		placeholder: "facebook.com/username"
	},
	{
		key: "x",
		label: "X",
		icon: Twitter,
		placeholder: "x.com/username"
	},
	{
		key: "instagram",
		label: "Instagram",
		icon: Instagram,
		placeholder: "instagram.com/username"
	},
	{
		key: "youtube",
		label: "YouTube",
		icon: Youtube,
		placeholder: "youtube.com/@channel"
	},
	{
		key: "pinterest",
		label: "Pinterest",
		icon: Globe,
		placeholder: "pinterest.com/username"
	},
	{
		key: "tiktok",
		label: "TikTok",
		icon: Globe,
		placeholder: "tiktok.com/@username"
	}
];
function SocialRow({ entry, handle, isLast, onConnect }) {
	const { t } = useProfileTranslation();
	const Icon = entry.icon;
	return /* @__PURE__ */ jsxs("div", {
		className: `flex items-center gap-3 px-4 py-3.5 ${isLast ? "" : "border-border border-b"}`,
		children: [
			/* @__PURE__ */ jsx("div", {
				className: "bg-muted text-foreground flex size-9 shrink-0 items-center justify-center rounded-full",
				children: /* @__PURE__ */ jsx(Icon, {
					className: "size-4",
					strokeWidth: 2
				})
			}),
			/* @__PURE__ */ jsxs("div", {
				className: "min-w-0 flex-1",
				children: [/* @__PURE__ */ jsx("div", {
					className: "text-foreground text-sm font-bold",
					children: entry.label
				}), /* @__PURE__ */ jsx("div", {
					className: `truncate text-xs ${handle ? "text-muted-foreground" : "text-muted-foreground/55"}`,
					children: handle || entry.placeholder
				})]
			}),
			/* @__PURE__ */ jsx(PillButton, {
				onClick: onConnect,
				icon: handle ? Pencil : Plus,
				label: handle ? t("edit") : t("connect")
			})
		]
	});
}
//#endregion
//#region src/screens/ProfileContentScreen.tsx
function mapAccountToCustomerAccount(raw) {
	return {
		fluid_pay_account: {
			id: raw.id,
			email: raw.email,
			address_count: 0,
			payment_methods_count: 0,
			language_iso: null
		},
		customer: {
			id: raw.id,
			active: true,
			active_subscriptions_count: 0,
			display_total_spent: "0",
			email: raw.email,
			first_name: raw.first_name,
			full_name: `${raw.first_name} ${raw.last_name}`.trim(),
			inactive_subscriptions_count: 0,
			is_rep: raw.member_type === "rep",
			phone: raw.phone,
			orders_count: 0
		}
	};
}
function composeAddressName(firstName, lastName) {
	const combined = `${firstName} ${lastName}`.trim();
	return combined.length > 0 ? combined : null;
}
function mapToFluidPayAddress(raw) {
	return {
		id: raw.id,
		address1: raw.street1,
		address2: raw.street2,
		city: raw.city,
		country_code: raw.country,
		default: raw.default,
		name: raw.name,
		postal_code: raw.zip,
		state: raw.state,
		subdivision_code: null
	};
}
const SOCIAL_KEY_TO_FIELD = {
	linkedin: "linkedin",
	facebook: "facebook",
	x: "twitter",
	instagram: "instagram",
	youtube: "youtube",
	pinterest: null,
	tiktok: "tiktok"
};
const SOCIAL_LABELS = {
	linkedin: "LinkedIn",
	facebook: "Facebook",
	x: "X",
	instagram: "Instagram",
	youtube: "YouTube",
	pinterest: "Pinterest",
	tiktok: "TikTok"
};
const SOCIAL_PLACEHOLDERS = {
	linkedin: "linkedin.com/in/username",
	facebook: "facebook.com/username",
	x: "x.com/username",
	instagram: "instagram.com/username",
	youtube: "youtube.com/@channel",
	pinterest: "pinterest.com/username",
	tiktok: "tiktok.com/@username"
};
function ProfileContentScreen({ onToast, countryIso }) {
	const { t } = useProfileTranslation();
	const payApi = usePayApi();
	const accountApi = useAccountApi();
	const queryClient = useQueryClient();
	const fluidPayShim = useMemo(() => createFluidPayApiAdapter(payApi), [payApi]);
	const { data: mySiteProfile } = usePortalMySiteProfile();
	const updateMySiteSettingsMutation = usePortalUpdateSettings();
	const mySiteUrl = mySiteProfile?.mysite_url ?? "";
	const mySiteDisplayUrl = mySiteUrl ? mySiteUrl.replace(/^https?:\/\//, "") : "";
	const mySiteLastSlash = mySiteDisplayUrl.lastIndexOf("/");
	const mySiteUrlPrefix = mySiteLastSlash >= 0 ? mySiteDisplayUrl.slice(0, mySiteLastSlash + 1) : "";
	const mySiteCurrentSlug = mySiteLastSlash >= 0 ? mySiteDisplayUrl.slice(mySiteLastSlash + 1) : mySiteDisplayUrl;
	const { data: accountRep, isLoading: isLoadingAccount, isError: isAccountError } = useAccount();
	const accountData = useMemo(() => accountRep ? mapAccountToCustomerAccount(accountRep) : void 0, [accountRep]);
	const { data: addressesData } = useQuery({
		queryKey: payKeys.addresses.list(),
		queryFn: async () => {
			return (await payApi.fetchAddresses()).addresses.map(mapToFluidPayAddress);
		},
		enabled: true
	});
	const { data: paymentMethodsData } = useQuery({
		queryKey: payKeys.paymentMethods.list(),
		queryFn: async () => {
			return (await payApi.fetchPaymentMethods()).payment_methods.map(mapToFluidPayPaymentMethod);
		},
		enabled: true
	});
	const countriesAdapter = useCountriesApi();
	const languagesAdapter = useLanguagesApi();
	const { data: countriesData } = useQuery({
		queryKey: storeKeys.countries(),
		queryFn: () => countriesAdapter.listCountries(),
		enabled: true
	});
	const { data: languagesData } = useQuery({
		queryKey: storeKeys.languages(),
		queryFn: () => languagesAdapter.listLanguages(),
		enabled: true
	});
	const { data: pointsLedgerData, isError: isPointsLedgerError } = useQuery({
		queryKey: payKeys.pointsLedgers.list(),
		queryFn: () => payApi.fetchPointsLedgers(),
		enabled: true,
		retry: (failureCount, error) => {
			if (error instanceof Error && "status" in error && error.status === 403) return false;
			return failureCount < 1;
		}
	});
	const rewardPointsEnabled = !isPointsLedgerError && pointsLedgerData != null;
	const adaptedPointsLedger = useMemo(() => {
		return (pointsLedgerData?.points_ledgers ?? []).map((entry) => {
			const meta = entry.metadata;
			return {
				id: entry.id,
				amount: entry.amount,
				company_id: 0,
				created_at: entry.created_at,
				customer_id: 0,
				metadata: {
					transaction_type: meta?.transaction_type ?? void 0,
					source: meta?.source ?? void 0
				},
				total_balance: entry.total_balance,
				updated_at: entry.created_at
			};
		});
	}, [pointsLedgerData]);
	const updateCustomerMutation = useMutation({
		mutationFn: async (data) => {
			await accountApi.updateAccount({ account: {
				first_name: data.first_name,
				last_name: data.last_name,
				phone: data.phone_number,
				bio: data.bio
			} });
		},
		onSuccess: () => {
			queryClient.invalidateQueries({ queryKey: accountKeys.all });
			onToast(t("profile_updated"), "success");
		},
		onError: () => {
			onToast(t("failed_to_update_profile"), "error");
		}
	});
	const deletePaymentMethodMutation = useMutation({
		mutationFn: (paymentMethodId) => payApi.deletePaymentMethod(paymentMethodId),
		onSuccess: () => {
			queryClient.invalidateQueries({ queryKey: payKeys.paymentMethods.all });
		},
		onError: () => {
			onToast(t("failed_to_delete_payment_method"), "error");
		}
	});
	const updatePaymentMethodMutation = useMutation({
		mutationFn: ({ paymentMethodId, data }) => payApi.updatePaymentMethod(paymentMethodId, { payment_method: {
			default: data.set_as_default,
			billing_address: {
				name: data.billing_address.name,
				street1: data.billing_address.address1,
				street2: data.billing_address.address2 ?? null,
				city: data.billing_address.city,
				state: data.billing_address.state,
				zip: data.billing_address.zip,
				country: data.billing_address.country_code
			}
		} }),
		onSuccess: () => {
			queryClient.invalidateQueries({ queryKey: payKeys.paymentMethods.all });
		},
		onError: () => {
			onToast(t("failed_to_update_payment_method"), "error");
		}
	});
	const createAddressMutation = useMutation({
		mutationFn: async (body) => {
			const existingIds = new Set((addressesData ?? []).map((a) => a.id));
			const address = await payApi.createAddress({ address: {
				name: composeAddressName(body.address.first_name, body.address.last_name),
				street1: body.address.address1,
				street2: body.address.address2,
				city: body.address.city,
				state: body.address.state,
				zip: body.address.postal_code,
				country: body.address.country_code,
				default: body.address.default
			} });
			return {
				address,
				deduped: existingIds.has(address.id)
			};
		},
		onSuccess: ({ deduped }) => {
			queryClient.invalidateQueries({ queryKey: payKeys.addresses.all });
			if (deduped) onToast(t("address_already_exists"), "warning");
			else onToast(t("address_created"), "success");
		},
		onError: () => {
			onToast(t("failed_to_create_address"), "error");
		}
	});
	const updateAddressMutation = useMutation({
		mutationFn: ({ addressId, body }) => payApi.updateAddress(addressId, { address: {
			name: composeAddressName(body.address.first_name, body.address.last_name),
			street1: body.address.address1,
			street2: body.address.address2,
			city: body.address.city,
			state: body.address.state,
			zip: body.address.postal_code,
			country: body.address.country_code,
			default: body.address.default
		} }),
		onSuccess: () => {
			queryClient.invalidateQueries({ queryKey: payKeys.addresses.all });
			onToast(t("address_updated"), "success");
		},
		onError: () => {
			onToast(t("failed_to_update_address"), "error");
		}
	});
	const deleteAddressMutation = useMutation({
		mutationFn: (addressId) => payApi.deleteAddress(addressId),
		onSuccess: () => {
			queryClient.invalidateQueries({ queryKey: payKeys.addresses.all });
			onToast(t("address_deleted"), "success");
		},
		onError: () => {
			onToast(t("failed_to_delete_address"), "error");
		}
	});
	const addCreditCardMutation = useMutation({
		mutationFn: (data) => payApi.createPaymentMethod({
			payment_method: {
				type: "card",
				token: data.payment_method.token,
				token_provider: "vgs",
				exp_month: data.payment_method.exp_month,
				exp_year: data.payment_method.exp_year,
				cvv_token: data.payment_method.cvv_token,
				card_holder: data.payment_method.card_holder,
				default: data.set_as_default
			},
			billing_address_id: data.billing_address_id
		}),
		onSuccess: () => {
			queryClient.invalidateQueries({ queryKey: payKeys.paymentMethods.all });
			onToast(t("payment_method_added"), "success");
		},
		onError: () => {
			onToast(t("failed_to_add_payment_method"), "error");
		}
	});
	const addresses = addressesData ?? [];
	const paymentMethods = paymentMethodsData ?? [];
	const adaptedLanguages = (languagesData?.languages ?? []).map((l, i) => ({
		id: i,
		name: l.name,
		iso: l.code
	}));
	const countries = countriesData?.countries;
	const countryOptions = useMemo(() => [...countries ?? []].map((c) => ({
		iso: c.code,
		name: c.name
	})).sort((a, b) => a.name.localeCompare(b.name)), [countries]);
	const statesByCountry = useMemo(() => {
		const map = /* @__PURE__ */ new Map();
		for (const c of countries ?? []) map.set(c.code, c.states.map((s) => ({
			name: s.name,
			isoCode: s.code
		})));
		return map;
	}, [countries]);
	const fetchStatesFromCountries = useCallback((countryCode) => Promise.resolve(statesByCountry.get(countryCode) ?? []), [statesByCountry]);
	const [isInfoDialogOpen, setIsInfoDialogOpen] = useState(false);
	const [addressDialog, setAddressDialog] = useState({
		open: false,
		selected: null
	});
	const [deletingAddress, setDeletingAddress] = useState(null);
	const [isAddCardOpen, setIsAddCardOpen] = useState(false);
	const [editPaymentMethod, setEditPaymentMethod] = useState(null);
	const userInfoLanguage = useMemo(() => {
		return adaptedLanguages.find((l) => l.iso === accountData?.fluid_pay_account.language_iso)?.name ?? "";
	}, [adaptedLanguages, accountData]);
	const derivedLastName = useMemo(() => {
		if (!accountData) return "";
		const { first_name, full_name } = accountData.customer;
		return deriveLastName(first_name, full_name);
	}, [accountData]);
	const userInfoForm = useZodForm(useMemo(() => z.object({
		first_name: z.string().min(1, t("first_name_is_required")),
		last_name: z.string().min(1, t("last_name_is_required")),
		phone_number: z.string().optional(),
		language: z.string().min(1, t("language_is_required")),
		bio: z.string().optional()
	}), [t]), { defaultValues: {
		first_name: accountData?.customer.first_name ?? "",
		last_name: derivedLastName,
		phone_number: accountData?.customer.phone ?? "",
		language: userInfoLanguage,
		bio: accountRep?.bio ?? ""
	} });
	const handleOpenInfoDialog = useCallback(() => {
		userInfoForm.reset({
			first_name: accountData?.customer.first_name ?? "",
			last_name: derivedLastName,
			phone_number: accountData?.customer.phone ?? "",
			language: userInfoLanguage,
			bio: accountRep?.bio ?? ""
		});
		setIsInfoDialogOpen(true);
	}, [
		accountData,
		accountRep,
		derivedLastName,
		userInfoLanguage,
		userInfoForm
	]);
	const onSubmitUserInfo = userInfoForm.handleSubmit(async (data) => {
		try {
			await updateCustomerMutation.mutateAsync(data);
			setIsInfoDialogOpen(false);
		} catch {}
	});
	const socialLinks = useMemo(() => {
		const src = accountRep?.social_links ?? {};
		const result = {};
		for (const [key, field] of Object.entries(SOCIAL_KEY_TO_FIELD)) {
			if (!field) continue;
			const v = src[field];
			if (typeof v === "string" && v.length > 0) result[key] = v;
		}
		return result;
	}, [accountRep]);
	const handleCopyMySiteLink = useCallback(async () => {
		if (!mySiteUrl) return;
		try {
			await navigator.clipboard.writeText(mySiteUrl);
			onToast(t("mysite_link_copied"), "success");
		} catch {
			onToast(t("failed_to_copy_link"), "error");
		}
	}, [
		mySiteUrl,
		onToast,
		t
	]);
	const [isEditMySiteLinkOpen, setIsEditMySiteLinkOpen] = useState(false);
	const [mySiteSlugDraft, setMySiteSlugDraft] = useState("");
	const handleOpenEditMySiteLink = useCallback(() => {
		setMySiteSlugDraft(mySiteCurrentSlug);
		setIsEditMySiteLinkOpen(true);
	}, [mySiteCurrentSlug]);
	const handleSubmitMySiteLink = useCallback(async () => {
		const trimmed = mySiteSlugDraft.trim();
		if (!trimmed) {
			onToast(t("mysite_link_empty"), "error");
			return;
		}
		if (trimmed === mySiteCurrentSlug) {
			setIsEditMySiteLinkOpen(false);
			return;
		}
		try {
			await updateMySiteSettingsMutation.mutateAsync({ slug: trimmed });
			onToast(t("mysite_link_updated"), "success");
			setIsEditMySiteLinkOpen(false);
		} catch {
			onToast(t("failed_to_update_mysite_link"), "error");
		}
	}, [
		mySiteSlugDraft,
		mySiteCurrentSlug,
		updateMySiteSettingsMutation,
		onToast,
		t
	]);
	const [editingSocial, setEditingSocial] = useState(null);
	const [socialDraft, setSocialDraft] = useState("");
	const handleConnectSocial = useCallback((key) => {
		const field = SOCIAL_KEY_TO_FIELD[key];
		if (!field) {
			onToast(t("platform_not_editable"), "warning");
			return;
		}
		setSocialDraft(accountRep?.social_links?.[field] ?? "");
		setEditingSocial(key);
	}, [
		accountRep,
		onToast,
		t
	]);
	const updateSocialMutation = useMutation({
		mutationFn: async ({ field, value }) => {
			const current = accountRep?.social_links ?? {};
			await accountApi.updateAccount({ account: { social_links: {
				...current,
				[field]: value
			} } });
		},
		onSuccess: () => {
			queryClient.invalidateQueries({ queryKey: accountKeys.all });
			onToast(t("social_link_updated"), "success");
		},
		onError: () => {
			onToast(t("failed_to_update_social_link"), "error");
		}
	});
	const handleSubmitSocial = useCallback(async () => {
		if (!editingSocial) return;
		const field = SOCIAL_KEY_TO_FIELD[editingSocial];
		if (!field) return;
		await updateSocialMutation.mutateAsync({
			field,
			value: socialDraft.trim()
		});
		setEditingSocial(null);
	}, [
		editingSocial,
		socialDraft,
		updateSocialMutation
	]);
	if (isAccountError && !isLoadingAccount) return /* @__PURE__ */ jsx("div", {
		className: "px-4 py-8 sm:px-9",
		children: /* @__PURE__ */ jsx("div", {
			className: "text-muted-foreground text-center text-sm",
			children: t("unable_to_load_account")
		})
	});
	if (isLoadingAccount || !accountData || !accountRep) return /* @__PURE__ */ jsx("div", {
		className: "px-4 pt-4 sm:px-9 md:pt-8",
		children: /* @__PURE__ */ jsxs("div", {
			className: "space-y-4",
			children: [
				/* @__PURE__ */ jsx("div", { className: "bg-muted h-16 animate-pulse rounded" }),
				/* @__PURE__ */ jsx("div", { className: "bg-muted h-32 animate-pulse rounded" }),
				/* @__PURE__ */ jsx("div", { className: "bg-muted h-32 animate-pulse rounded" })
			]
		})
	});
	return /* @__PURE__ */ jsxs(FluidPayCoreProvider, {
		api: fluidPayShim,
		children: [
			/* @__PURE__ */ jsx(ProfileLayout, {
				account: accountRep,
				pointsBalance: rewardPointsEnabled ? pointsLedgerData?.points_ledgers?.[0]?.total_balance ?? 0 : void 0,
				pointsLedger: adaptedPointsLedger,
				rewardsEnabled: rewardPointsEnabled,
				addresses,
				paymentMethods,
				mySiteDisplayUrl,
				socialLinks,
				onEditPersonalInfo: handleOpenInfoDialog,
				onAddAddress: () => setAddressDialog({
					open: true,
					selected: null
				}),
				onEditAddress: (address) => setAddressDialog({
					open: true,
					selected: address
				}),
				onDeleteAddress: (address) => setDeletingAddress(address),
				onAddPaymentMethod: () => setIsAddCardOpen(true),
				onEditPaymentMethod: (pm) => setEditPaymentMethod(pm),
				onCopyMySiteLink: handleCopyMySiteLink,
				onEditMySiteLink: handleOpenEditMySiteLink,
				onConnectSocial: handleConnectSocial
			}),
			/* @__PURE__ */ jsx(UserInfoDialog, {
				control: userInfoForm.control,
				isOpen: isInfoDialogOpen,
				onSubmit: onSubmitUserInfo,
				handleClose: () => setIsInfoDialogOpen(false),
				languageOptions: adaptedLanguages.map((l) => ({
					name: l.name,
					value: l.name
				})),
				errorMsg: void 0,
				isSubmitting: updateCustomerMutation.isPending,
				email: accountRep.email ?? ""
			}),
			/* @__PURE__ */ jsx(AddressFormDialog, {
				isOpen: addressDialog.open,
				onClose: () => setAddressDialog({
					open: false,
					selected: null
				}),
				selectedAddress: addressDialog.selected,
				defaultCountry: addresses.find((a) => a.default)?.country_code ?? countryIso,
				t: (key) => t(key),
				onSubmit: async (formData) => {
					if (addressDialog.selected) await updateAddressMutation.mutateAsync({
						addressId: addressDialog.selected.id,
						body: formData
					});
					else await createAddressMutation.mutateAsync(formData);
					setAddressDialog({
						open: false,
						selected: null
					});
				},
				isSubmitting: createAddressMutation.isPending || updateAddressMutation.isPending,
				onDelete: addressDialog.selected && !addressDialog.selected.default ? async () => {
					if (!addressDialog.selected) return;
					try {
						await deleteAddressMutation.mutateAsync(addressDialog.selected.id);
						setAddressDialog({
							open: false,
							selected: null
						});
					} catch {}
				} : void 0,
				isDeleting: deleteAddressMutation.isPending,
				countries: countryOptions,
				fetchStates: fetchStatesFromCountries,
				renderAddressAutocomplete: ({ control, setValue, countryCode }) => /* @__PURE__ */ jsx(AddressAutocompleteInput, {
					control,
					setValue,
					countryIso: countryCode,
					addressLineField: "address1",
					cityField: "city",
					stateField: "state",
					postalCodeField: "postal_code",
					placeholder: t("address_line_1")
				})
			}),
			/* @__PURE__ */ jsx(ConfirmActionDialog, {
				title: t("delete_address"),
				description: t("delete_address_message"),
				openDialog: deletingAddress !== null,
				setOpenDialog: (open) => {
					if (!open) setDeletingAddress(null);
				},
				onAction: async () => {
					if (!deletingAddress) return;
					try {
						await deleteAddressMutation.mutateAsync(deletingAddress.id);
						setDeletingAddress(null);
					} catch {}
				},
				isLoading: deleteAddressMutation.isPending,
				actionText: t("delete")
			}),
			/* @__PURE__ */ jsx(CreditCardFormDialog, {
				isOpen: isAddCardOpen,
				onClose: () => setIsAddCardOpen(false),
				t: (key) => t(key),
				onSubmit: async (data) => {
					try {
						await addCreditCardMutation.mutateAsync(data);
						setIsAddCardOpen(false);
					} catch {}
				},
				isSubmitting: addCreditCardMutation.isPending,
				jwt: "",
				savedAddresses: addresses,
				defaultBillingAddressId: addresses.find((a) => a.default)?.id,
				renderAddressFormDialog: ({ isOpen, onClose, onAddressCreated }) => /* @__PURE__ */ jsx(AddressFormDialog, {
					isOpen,
					onClose,
					selectedAddress: null,
					onSubmit: async (data) => {
						try {
							const { address } = await createAddressMutation.mutateAsync(data);
							onAddressCreated(mapToFluidPayAddress(address));
						} catch {}
					},
					isSubmitting: createAddressMutation.isPending,
					countries: countryOptions,
					fetchStates: fetchStatesFromCountries,
					t: (key) => t(key),
					renderAddressAutocomplete: ({ control, setValue, countryCode }) => /* @__PURE__ */ jsx(AddressAutocompleteInput, {
						control,
						setValue,
						countryIso: countryCode,
						addressLineField: "address1",
						cityField: "city",
						stateField: "state",
						postalCodeField: "postal_code",
						placeholder: t("address_line_1")
					})
				})
			}),
			editPaymentMethod && /* @__PURE__ */ jsx(EditPaymentMethodDialog, {
				isOpen: true,
				onClose: () => setEditPaymentMethod(null),
				paymentMethod: editPaymentMethod,
				billingAddress: editPaymentMethod.billing_address,
				countries: countryOptions,
				onSubmit: (data) => {
					updatePaymentMethodMutation.mutate({
						paymentMethodId: editPaymentMethod.id,
						data
					}, { onSuccess: () => setEditPaymentMethod(null) });
				},
				isSubmitting: updatePaymentMethodMutation.isPending,
				onDelete: () => {
					deletePaymentMethodMutation.mutate(editPaymentMethod.id, { onSuccess: () => setEditPaymentMethod(null) });
				},
				isDeleting: deletePaymentMethodMutation.isPending
			}),
			/* @__PURE__ */ jsx(Dialog, {
				open: isEditMySiteLinkOpen,
				onOpenChange: (open) => {
					if (!open && updateMySiteSettingsMutation.isPending) return;
					setIsEditMySiteLinkOpen(open);
				},
				children: /* @__PURE__ */ jsxs(DialogContent, {
					className: "max-w-sm md:max-w-md",
					children: [
						/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: t("edit_link") }) }),
						/* @__PURE__ */ jsxs("div", {
							className: "space-y-2 pt-2",
							children: [/* @__PURE__ */ jsx(Label, {
								htmlFor: "mysite-slug",
								className: "mb-1.5 block text-sm font-medium",
								children: t("your_mysite_link")
							}), /* @__PURE__ */ jsxs("div", {
								className: "ring-border focus-within:ring-foreground/40 flex items-center gap-1 rounded-md bg-transparent px-3 py-2 ring-1 transition-all focus-within:ring-2",
								children: [mySiteUrlPrefix && /* @__PURE__ */ jsx("span", {
									className: "text-muted-foreground shrink-0 text-sm",
									children: mySiteUrlPrefix
								}), /* @__PURE__ */ jsx(Input, {
									id: "mysite-slug",
									value: mySiteSlugDraft,
									onChange: (e) => setMySiteSlugDraft(e.target.value),
									onKeyDown: (e) => {
										if (e.key === "Enter" && !updateMySiteSettingsMutation.isPending) {
											e.preventDefault();
											handleSubmitMySiteLink();
										}
									},
									className: "h-auto min-w-0 flex-1 border-0 p-0 shadow-none focus-visible:ring-0",
									autoFocus: true
								})]
							})]
						}),
						/* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
							type: "button",
							variant: "outline",
							onClick: () => setIsEditMySiteLinkOpen(false),
							disabled: updateMySiteSettingsMutation.isPending,
							children: t("cancel")
						}), /* @__PURE__ */ jsx(Button, {
							type: "button",
							onClick: () => {
								handleSubmitMySiteLink();
							},
							disabled: updateMySiteSettingsMutation.isPending,
							children: updateMySiteSettingsMutation.isPending ? t("saving") : t("save")
						})] })
					]
				})
			}),
			/* @__PURE__ */ jsx(Dialog, {
				open: editingSocial !== null,
				onOpenChange: (open) => !open && setEditingSocial(null),
				children: /* @__PURE__ */ jsxs(DialogContent, {
					className: "max-w-sm md:max-w-md",
					children: [
						/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: editingSocial ? t("edit_platform_link", { platform: SOCIAL_LABELS[editingSocial] ?? "" }) : t("edit_social_link") }) }),
						/* @__PURE__ */ jsxs("div", {
							className: "space-y-2 pt-2",
							children: [/* @__PURE__ */ jsx(Label, {
								htmlFor: "social-handle",
								className: "mb-1.5 block text-sm font-medium",
								children: t("url")
							}), /* @__PURE__ */ jsx(Input, {
								id: "social-handle",
								value: socialDraft,
								onChange: (e) => setSocialDraft(e.target.value),
								placeholder: editingSocial ? SOCIAL_PLACEHOLDERS[editingSocial] : "",
								onKeyDown: (e) => {
									if (e.key === "Enter") {
										e.preventDefault();
										handleSubmitSocial();
									}
								},
								autoFocus: true
							})]
						}),
						/* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
							type: "button",
							variant: "outline",
							onClick: () => setEditingSocial(null),
							disabled: updateSocialMutation.isPending,
							children: t("cancel")
						}), /* @__PURE__ */ jsx(Button, {
							type: "button",
							onClick: () => {
								handleSubmitSocial();
							},
							disabled: updateSocialMutation.isPending,
							children: updateSocialMutation.isPending ? t("saving") : t("save")
						})] })
					]
				})
			})
		]
	});
}
//#endregion
//#region src/screens/ProfileScreen.tsx
function defaultToast(message, type) {
	fluidToast({
		title: message,
		type
	});
}
function ProfileScreen({ onToast, background, textColor, accentColor, padding, borderRadius, ...divProps }) {
	const { config } = useFluidContext();
	return /* @__PURE__ */ jsx(ProfileTranslationBridge, { children: /* @__PURE__ */ jsx(ProfileScreenContent, {
		onToast: onToast ?? defaultToast,
		countryIso: config.countryIso ?? "US",
		divProps
	}) });
}
function ProfileScreenContent({ onToast, countryIso, divProps }) {
	const { t } = useProfileTranslation();
	return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(ScreenHeaderBreadcrumbs, { children: /* @__PURE__ */ jsx(Breadcrumb, { children: /* @__PURE__ */ jsx(BreadcrumbList, {
		className: "text-lg",
		children: /* @__PURE__ */ jsx(BreadcrumbItem, { children: /* @__PURE__ */ jsx(BreadcrumbPage, {
			className: "font-semibold",
			children: t("breadcrumb")
		}) })
	}) }) }), /* @__PURE__ */ jsx("div", {
		...divProps,
		children: /* @__PURE__ */ jsx(ProfileContentScreen, {
			onToast,
			countryIso
		})
	})] });
}
const profileScreenPropertySchema = {
	widgetType: "ProfileScreen",
	displayName: "Profile Screen",
	tabsConfig: [{
		id: "styling",
		label: "Styling"
	}],
	fields: []
};
//#endregion
export { profileScreenPropertySchema as n, ProfileScreen as t };

//# sourceMappingURL=ProfileScreen-CcniZNXj.mjs.map