import { ft as __exportAll } from "./translation-adapter-RsuBioxm.mjs";
import { c as useScreenRenderer, t as ScreenRenderer, u as useRegistry } from "./ScreenRenderer-BQz-1cCn.mjs";
import { f as getGapField, i as getBorderColorField, m as getPaddingField, n as borderWidthClasses, o as getBorderRadiusField, r as gapValues, s as getBorderWidthField, t as borderColorClasses } from "./registries-DXVOnKV2.mjs";
import { jsx } from "react/jsx-runtime";
/** @deprecated Use SECTION_LAYOUT_CONFIG instead */
const sectionLayoutConfig = {
	"single-column": {
		columns: 1,
		widths: ["1fr"],
		gridClasses: ""
	},
	"2c-equal": {
		columns: 2,
		widths: ["1fr", "1fr"],
		gridClasses: "@md:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]"
	},
	"2c-left-wider": {
		columns: 2,
		widths: ["2fr", "1fr"],
		gridClasses: "@md:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]"
	},
	"2c-right-wider": {
		columns: 2,
		widths: ["1fr", "2fr"],
		gridClasses: "@md:grid-cols-[minmax(0,1fr)_minmax(0,2fr)]"
	},
	"2c-left-narrow": {
		columns: 2,
		widths: ["1fr", "3fr"],
		gridClasses: "@md:grid-cols-[minmax(0,1fr)_minmax(0,3fr)]"
	},
	"2c-right-narrow": {
		columns: 2,
		widths: ["3fr", "1fr"],
		gridClasses: "@md:grid-cols-[minmax(0,3fr)_minmax(0,1fr)]"
	},
	"3c-equal": {
		columns: 3,
		widths: [
			"1fr",
			"1fr",
			"1fr"
		],
		gridClasses: "@md:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)]"
	},
	"3c-middle-wider": {
		columns: 3,
		widths: [
			"1fr",
			"2fr",
			"1fr"
		],
		gridClasses: "@md:grid-cols-[minmax(0,1fr)_minmax(0,2fr)_minmax(0,1fr)]"
	}
};
//#endregion
//#region ../core/src/widget-utils/widget-utils.ts
/**
* Groups children by column index.
* Accepts nullable children (sparse arrays from grid layouts) and filters them out.
*/
function groupChildrenByColumn(children, columnCount) {
	const columns = Array.from({ length: columnCount }, () => []);
	const nonNullChildren = children.filter((child) => child !== null);
	for (const child of nonNullChildren) {
		const column = columns[Math.min(child.columnIndex ?? 0, columnCount - 1)];
		if (column) column.push(child);
	}
	return columns;
}
//#endregion
//#region ../widgets/src/widgets/LayoutWidget.tsx
var LayoutWidget_exports = /* @__PURE__ */ __exportAll({
	LayoutWidget: () => LayoutWidget,
	layoutWidgetPropertySchema: () => layoutWidgetPropertySchema
});
const DEFAULT_BACKGROUND = {
	type: "solid",
	color: "background"
};
const DEFAULT_CHILDREN = [];
const LayoutWidget = ({ sectionLayout = "single-column", gap = 4, gapSize, background = DEFAULT_BACKGROUND, padding = 0, borderRadius = "md", borderWidth = "none", borderColor = "muted", children = DEFAULT_CHILDREN, registry, className = "", minHeight }) => {
	const contextRegistry = useRegistry();
	const effectiveRegistry = registry || contextRegistry;
	const ScreenRenderer$1 = useScreenRenderer() ?? ScreenRenderer;
	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 resolvedLayout = sectionLayoutConfig[sectionLayout];
	if (!resolvedLayout) console.warn(`LayoutWidget: unknown sectionLayout key "${sectionLayout}", falling back to "single-column"`);
	const layoutConfig = resolvedLayout ?? sectionLayoutConfig["single-column"];
	const columnCount = layoutConfig.columns;
	const gapSizeValue = gapSize ? gapValues[gapSize] : gap;
	const layoutClasses = [
		"grid",
		"w-full",
		"min-w-0",
		"grid-cols-1",
		layoutConfig.gridClasses,
		`bg-${backgroundColor} p-${padding} rounded-${borderRadius} ${borderWidthClasses[borderWidth]} ${borderWidth !== "none" ? borderColorClasses[borderColor] : ""}`,
		`gap-${gapSizeValue}`,
		className
	].filter(Boolean).join(" ");
	const containerStyle = {
		...minHeight ? { minHeight: `${minHeight}px` } : {},
		alignItems: "start",
		backgroundImage
	};
	if (!effectiveRegistry) {
		console.warn("Layout widget: No registry provided, cannot render children");
		return /* @__PURE__ */ jsx("div", {
			className: layoutClasses,
			style: containerStyle
		});
	}
	return /* @__PURE__ */ jsx("div", {
		className: "@container w-full min-w-0",
		children: /* @__PURE__ */ jsx("div", {
			className: layoutClasses,
			style: containerStyle,
			children: groupChildrenByColumn(children, columnCount).map((columnChildren, colIndex) => /* @__PURE__ */ jsx(ScreenRenderer$1, {
				screen: columnChildren,
				registry: effectiveRegistry,
				className: `flex w-full min-w-0 flex-col gap-${gapSizeValue}`
			}, colIndex))
		})
	});
};
const layoutWidgetPropertySchema = {
	widgetType: "LayoutWidget",
	displayName: "Layout",
	fields: [
		{
			key: "sectionLayout",
			label: "Layout Type",
			type: "sectionLayoutSelect",
			description: "Column layout configuration",
			defaultValue: "single-column",
			group: "Layout"
		},
		getGapField({
			key: "gapSize",
			label: "Gap",
			description: "Gap between columns and widgets",
			defaultValue: "md",
			group: "Design"
		}),
		{
			type: "background",
			key: "background",
			label: "Background",
			description: "Background for the layout container",
			defaultValue: "background",
			group: "Design"
		},
		getPaddingField({
			key: "padding",
			label: "Padding",
			description: "Padding for the layout container",
			defaultValue: 4,
			group: "Design"
		}),
		getBorderRadiusField({
			key: "borderRadius",
			label: "Border Radius",
			description: "Border radius for the layout container",
			defaultValue: "md",
			group: "Design"
		}),
		getBorderWidthField({
			key: "borderWidth",
			label: "Border Width",
			description: "Border width for the widget",
			defaultValue: "none",
			group: "Design"
		}),
		getBorderColorField({
			key: "borderColor",
			label: "Border Color",
			description: "Border color for the widget",
			defaultValue: "muted",
			group: "Design"
		})
	]
};
//#endregion
export { sectionLayoutConfig as a, groupChildrenByColumn as i, LayoutWidget_exports as n, layoutWidgetPropertySchema as r, LayoutWidget as t };

//# sourceMappingURL=LayoutWidget-ENLd1G__.mjs.map