require("./chunk-9hOWP6kD.cjs");
const require_ScreenRenderer = require("./ScreenRenderer-CLDJUinO.cjs");
const require_registries = require("./registries-CpUM406S.cjs");
let react_jsx_runtime = require("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-2"
	},
	"2c-left-wider": {
		columns: 2,
		widths: ["2fr", "1fr"],
		gridClasses: "@md:grid-cols-[2fr_1fr]"
	},
	"2c-right-wider": {
		columns: 2,
		widths: ["1fr", "2fr"],
		gridClasses: "@md:grid-cols-[1fr_2fr]"
	},
	"2c-left-narrow": {
		columns: 2,
		widths: ["1fr", "3fr"],
		gridClasses: "@md:grid-cols-[1fr_3fr]"
	},
	"2c-right-narrow": {
		columns: 2,
		widths: ["3fr", "1fr"],
		gridClasses: "@md:grid-cols-[3fr_1fr]"
	},
	"3c-equal": {
		columns: 3,
		widths: [
			"1fr",
			"1fr",
			"1fr"
		],
		gridClasses: "@md:grid-cols-3"
	},
	"3c-middle-wider": {
		columns: 3,
		widths: [
			"1fr",
			"2fr",
			"1fr"
		],
		gridClasses: "@md:grid-cols-[1fr_2fr_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
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 = require_ScreenRenderer.useRegistry();
	const effectiveRegistry = registry || contextRegistry;
	const ScreenRenderer$1 = require_ScreenRenderer.useScreenRenderer() ?? require_ScreenRenderer.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 layoutConfig = sectionLayoutConfig[sectionLayout];
	const columnCount = layoutConfig.columns;
	const gapSizeValue = gapSize ? require_registries.gapValues[gapSize] : gap;
	const layoutClasses = [
		"grid",
		"grid-cols-1",
		layoutConfig.gridClasses,
		`bg-${backgroundColor} p-${padding} rounded-${borderRadius} ${require_registries.borderWidthClasses[borderWidth]} ${borderWidth !== "none" ? require_registries.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__ */ (0, react_jsx_runtime.jsx)("div", {
			className: layoutClasses,
			style: containerStyle
		});
	}
	return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
		className: "@container",
		children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
			className: layoutClasses,
			style: containerStyle,
			children: groupChildrenByColumn(children, columnCount).map((columnChildren, colIndex) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ScreenRenderer$1, {
				screen: columnChildren,
				registry: effectiveRegistry,
				className: `flex 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"
		},
		require_registries.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"
		},
		require_registries.getPaddingField({
			key: "padding",
			label: "Padding",
			description: "Padding for the layout container",
			defaultValue: 4,
			group: "Design"
		}),
		require_registries.getBorderRadiusField({
			key: "borderRadius",
			label: "Border Radius",
			description: "Border radius for the layout container",
			defaultValue: "md",
			group: "Design"
		}),
		require_registries.getBorderWidthField({
			key: "borderWidth",
			label: "Border Width",
			description: "Border width for the widget",
			defaultValue: "none",
			group: "Design"
		}),
		require_registries.getBorderColorField({
			key: "borderColor",
			label: "Border Color",
			description: "Border color for the widget",
			defaultValue: "muted",
			group: "Design"
		})
	]
};
//#endregion
Object.defineProperty(exports, "LayoutWidget", {
	enumerable: true,
	get: function() {
		return LayoutWidget;
	}
});
Object.defineProperty(exports, "groupChildrenByColumn", {
	enumerable: true,
	get: function() {
		return groupChildrenByColumn;
	}
});
Object.defineProperty(exports, "layoutWidgetPropertySchema", {
	enumerable: true,
	get: function() {
		return layoutWidgetPropertySchema;
	}
});
Object.defineProperty(exports, "sectionLayoutConfig", {
	enumerable: true,
	get: function() {
		return sectionLayoutConfig;
	}
});

//# sourceMappingURL=LayoutWidget-CG-dWz_c.cjs.map