const require_chunk = require("./chunk-9hOWP6kD.cjs");
const require_registry_context = require("./registry-context-DZOQLVi4.cjs");
const require_error_state = require("./error-state-CVDJL77c.cjs");
const require_registries = require("./registries-yZkFfBWj.cjs");
let _tanstack_react_query = require("@tanstack/react-query");
let react_jsx_runtime = require("react/jsx-runtime");
let lucide_react = require("lucide-react");
//#region ../widgets/src/hooks/use-catchups.preview.ts
const PREVIEW_DATA = [
	{
		id: 1,
		suggestionTitle: "Check in with Sarah about her recent order"
	},
	{
		id: 2,
		suggestionTitle: "Follow up with Mike on product samples"
	},
	{
		id: 3,
		suggestionTitle: "Reconnect with Lisa — last contact 30 days ago"
	},
	{
		id: 4,
		suggestionTitle: "Thank Alex for their referral last week"
	},
	{
		id: 5,
		suggestionTitle: "Share new catalog with Jordan"
	}
];
//#endregion
//#region ../widgets/src/hooks/use-catchups.ts
function useCatchUps() {
	const widgetsApi = require_error_state.useWidgetsApi();
	const { isPreview } = require_error_state.useWidgetPreviewContext();
	const { baseUrl } = require_registry_context.useDataSourceRegistryConfig();
	return (0, _tanstack_react_query.useQuery)({
		queryKey: [
			"portal-widget-use",
			"catchups",
			isPreview ? "preview" : baseUrl
		],
		queryFn: ({ signal }) => widgetsApi.fetchCatchUps(signal),
		enabled: !isPreview,
		...isPreview && { placeholderData: PREVIEW_DATA }
	});
}
//#endregion
//#region ../widgets/src/widgets/CatchUpWidget.tsx
var CatchUpWidget_exports = /* @__PURE__ */ require_chunk.__exportAll({
	CatchUpWidget: () => CatchUpWidget,
	catchUpWidgetPropertySchema: () => catchUpWidgetPropertySchema
});
const fontSizeClasses = {
	"2xl": "text-2xl",
	xl: "text-xl",
	lg: "text-lg",
	md: "text-base",
	sm: "text-sm",
	xs: "text-xs"
};
function CatchUpWidget({ titleEnabled = true, titleText = "Catch Ups", titleFontSize = "xl", titleColor = "foreground", background = {
	type: "solid",
	color: "background"
}, textColor = "foreground", accentColor = "primary", padding = 4, borderRadius = "md", borderWidth = "none", borderColor = "muted", maxItems = 5, className, ...props }) {
	const backgroundColor = background.color || "background";
	const backgroundImage = (background.resource?.image_url || background.resource?.imageUrl) && background.type === "image" ? `url(${background.resource.image_url || background.resource.imageUrl})` : "none";
	const { data = [], isLoading, isError } = useCatchUps();
	const catchUpsToShow = data.slice(0, maxItems);
	const moreCatchUps = data.length - catchUpsToShow.length;
	return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
		className: `flex flex-col rounded-${borderRadius} ${require_registries.borderWidthClasses[borderWidth]} ${borderWidth !== "none" ? require_registries.borderColorClasses[borderColor] : ""} bg-${backgroundColor} p-${padding} text-${textColor} ${className || ""}`,
		style: { backgroundImage },
		...props,
		children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
			className: "flex items-center justify-between",
			children: [titleEnabled && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
				className: `${fontSizeClasses[titleFontSize]} font-header font-semibold text-${titleColor}`,
				children: titleText
			}), !isLoading && !isError && data.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
				className: `text-3xl font-bold text-${accentColor}`,
				children: data.length
			})]
		}), isLoading ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
			className: "flex min-h-[150px] flex-1 items-center justify-center",
			children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Loader2, { className: `h-8 w-8 animate-spin text-${accentColor}` })
		}) : isError ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_error_state.ErrorState, {}) : data.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
			className: "flex min-h-[150px] flex-1 flex-col items-center justify-center gap-2",
			children: [
				/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Sparkles, { className: `h-8 w-8 text-${accentColor}` }),
				/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
					className: "text-center font-semibold",
					children: "You're all caught up."
				}),
				/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
					className: "text-sm opacity-60",
					children: "See you next time!"
				})
			]
		}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
			className: "mt-3 flex-1",
			children: catchUpsToShow.map((catchUp, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
				className: `py-2 ${index !== catchUpsToShow.length - 1 ? "border-b border-current/10" : ""}`,
				children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
					className: "line-clamp-1 text-sm",
					children: catchUp.suggestionTitle
				})
			}, catchUp.id || index))
		}), moreCatchUps > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
			className: "mt-2 text-sm opacity-60",
			children: [
				moreCatchUps,
				" more catch up",
				moreCatchUps > 1 ? "s" : ""
			]
		})] })]
	});
}
const catchUpWidgetPropertySchema = {
	widgetType: "CatchUpWidget",
	displayName: "Catch Up Widget",
	tabsConfig: [{
		id: "styling",
		label: "Styling"
	}],
	fields: [
		{
			key: "titleEnabled",
			label: "Widget Title",
			type: "boolean",
			description: "Enable the title displayed above the catch ups",
			defaultValue: true,
			tab: "styling",
			group: "Title"
		},
		{
			key: "titleText",
			label: "Title",
			type: "text",
			description: "Title text displayed above the catch ups",
			defaultValue: "Catch Ups",
			tab: "styling",
			group: "Title",
			requiresKeyToBeTrue: "titleEnabled"
		},
		require_registries.getFontSizeField({
			key: "titleFontSize",
			label: "Title Font Size",
			description: "Font size for the widget title",
			defaultValue: "xl",
			tab: "styling",
			group: "Title",
			requiresKeyToBeTrue: "titleEnabled"
		}),
		require_registries.getColorField({
			key: "titleColor",
			label: "Title Color",
			description: "Color for the widget title",
			defaultValue: "foreground",
			tab: "styling",
			group: "Title",
			requiresKeyToBeTrue: "titleEnabled"
		}),
		{
			type: "background",
			key: "background",
			label: "Background",
			description: "Background for the container",
			defaultValue: "background",
			tab: "styling",
			group: "Design"
		},
		require_registries.getColorField({
			key: "textColor",
			label: "Text Color",
			description: "Default text color for catch up items",
			defaultValue: "foreground",
			tab: "styling",
			group: "Design"
		}),
		require_registries.getColorField({
			key: "accentColor",
			label: "Accent Color",
			description: "Color used for count display and icons",
			defaultValue: "primary",
			tab: "styling",
			group: "Design"
		}),
		{
			key: "separator",
			type: "separator",
			label: "Separator",
			tab: "styling",
			group: "Design"
		},
		{
			key: "maxItems",
			label: "Max Items",
			type: "number",
			description: "Maximum number of catch ups to display",
			defaultValue: 5,
			min: 1,
			max: 10,
			tab: "styling",
			group: "Design"
		},
		require_registries.getPaddingField({
			key: "padding",
			label: "Padding",
			description: "Padding around the container",
			defaultValue: 4,
			tab: "styling",
			group: "Design"
		}),
		require_registries.getBorderRadiusField({
			key: "borderRadius",
			label: "Border Radius",
			description: "Border radius for the container",
			defaultValue: "md",
			tab: "styling",
			group: "Design"
		}),
		require_registries.getBorderWidthField({
			key: "borderWidth",
			label: "Border Width",
			description: "Border width for the widget",
			defaultValue: "none",
			tab: "styling",
			group: "Design"
		}),
		require_registries.getBorderColorField({
			key: "borderColor",
			label: "Border Color",
			description: "Border color for the widget",
			defaultValue: "muted",
			tab: "styling",
			group: "Design"
		})
	]
};
//#endregion
Object.defineProperty(exports, "CatchUpWidget", {
	enumerable: true,
	get: function() {
		return CatchUpWidget;
	}
});
Object.defineProperty(exports, "CatchUpWidget_exports", {
	enumerable: true,
	get: function() {
		return CatchUpWidget_exports;
	}
});
Object.defineProperty(exports, "catchUpWidgetPropertySchema", {
	enumerable: true,
	get: function() {
		return catchUpWidgetPropertySchema;
	}
});

//# sourceMappingURL=CatchUpWidget-CjemRhbH.cjs.map