import { g as defaultBaseState, p as createBaseState, t as PHDocumentController } from "./dist-JCXjvFc8.mjs";
import { a as utils, d as isGroupDocument, l as assertIsGroupDocument, t as Group } from "./module-Du2F4HUY.mjs";
import { a as useDocumentsInSelectedDrive, c as useSelectedDocument, i as useDocumentById, o as useDocumentsInSelectedFolder } from "./dist-Bg4aWBAL.mjs";
//#region document-models/group/v1/gen/ph-factories.ts
function defaultGlobalState() {
	return {
		name: null,
		channelIds: []
	};
}
function defaultLocalState() {
	return {};
}
function defaultPHState() {
	return {
		...defaultBaseState(),
		global: defaultGlobalState(),
		local: defaultLocalState()
	};
}
function createGlobalState(state) {
	return {
		...defaultGlobalState(),
		...state || {}
	};
}
function createLocalState(state) {
	return {
		...defaultLocalState(),
		...state || {}
	};
}
function createState(baseState, globalState, localState) {
	return {
		...createBaseState(baseState?.auth, baseState?.document),
		global: createGlobalState(globalState),
		local: createLocalState(localState)
	};
}
/**
* Creates a GroupDocument with custom global and local state
* This properly handles the PHBaseState requirements while allowing
* document-specific state to be set.
*/
function createGroupDocument(state) {
	return utils.createDocument(state ? createState(createBaseState(state.auth, state.document), state.global, state.local) : void 0);
}
//#endregion
//#region document-models/group/v1/gen/controller.ts
const GroupController = PHDocumentController.forDocumentModel(Group);
//#endregion
//#region document-models/group/v1/hooks.ts
/** Hook to get a Group document by its id */
function useGroupDocumentById(documentId) {
	const [document, dispatch] = useDocumentById(documentId);
	if (!isGroupDocument(document)) return [void 0, void 0];
	return [document, dispatch];
}
/** Hook to get the selected Group document */
function useSelectedGroupDocument() {
	const [document, dispatch] = useSelectedDocument();
	assertIsGroupDocument(document);
	return [document, dispatch];
}
/** Hook to get all Group documents in the selected drive */
function useGroupDocumentsInSelectedDrive() {
	return useDocumentsInSelectedDrive()?.filter(isGroupDocument);
}
/** Hook to get all Group documents in the selected folder */
function useGroupDocumentsInSelectedFolder() {
	return useDocumentsInSelectedFolder()?.filter(isGroupDocument);
}
//#endregion
export { GroupController as a, defaultGlobalState as c, useSelectedGroupDocument as i, defaultLocalState as l, useGroupDocumentsInSelectedDrive as n, createGroupDocument as o, useGroupDocumentsInSelectedFolder as r, createState as s, useGroupDocumentById as t, defaultPHState as u };

//# sourceMappingURL=group-DqixM7sY.mjs.map