//#region src/components/IDE/createFileTree.ts
const createFileTree = (paths) => {
	const root = {
		path: "",
		subPath: [],
		isFile: false
	};
	paths.forEach((path) => {
		const parts = path.split("/").filter((part) => part !== "");
		let current = root;
		for (let i = 0; i < parts.length; i++) {
			const part = parts[i];
			const isFile = i === parts.length - 1;
			if (!current.subPath) current.subPath = [];
			let next = current.subPath.find((sub) => sub.path === part);
			if (!next) {
				next = {
					path: part,
					isFile,
					subPath: isFile ? void 0 : []
				};
				current.subPath.push(next);
			}
			current = next;
		}
	});
	return root.subPath ?? [];
};

//#endregion
export { createFileTree };
//# sourceMappingURL=createFileTree.mjs.map