import { p as createBaseState, t as PHDocumentController, v as defaultBaseState } from "./dist-CYoGQ6PD.mjs";
import { a as utils, d as isGovernanceDocument, l as assertIsGovernanceDocument, t as Governance } from "./module-DRNJYxYD.mjs";
import { c as useDocumentsInSelectedDrive, l as useDocumentsInSelectedFolder, p as useSelectedDocument, s as useDocumentById } from "./dist-LFSG_0Q3.mjs";
//#region document-models/governance/v1/gen/ph-factories.ts
function defaultGlobalState() {
	return {
		disputes: [],
		publisherDecisions: [],
		rfcs: [],
		policies: []
	};
}
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 GovernanceDocument with custom global and local state
* This properly handles the PHBaseState requirements while allowing
* document-specific state to be set.
*/
function createGovernanceDocument(state) {
	return utils.createDocument(state ? createState(createBaseState(state.auth, state.document), state.global, state.local) : void 0);
}
//#endregion
//#region document-models/governance/v1/gen/controller.ts
const GovernanceController = PHDocumentController.forDocumentModel(Governance);
//#endregion
//#region document-models/governance/v1/hooks.ts
/** Hook to get a Governance document by its id */
function useGovernanceDocumentById(documentId) {
	const [document, dispatch] = useDocumentById(documentId);
	if (!isGovernanceDocument(document)) return [void 0, void 0];
	return [document, dispatch];
}
/** Hook to get the selected Governance document */
function useSelectedGovernanceDocument() {
	const [document, dispatch] = useSelectedDocument();
	assertIsGovernanceDocument(document);
	return [document, dispatch];
}
/** Hook to get all Governance documents in the selected drive */
function useGovernanceDocumentsInSelectedDrive() {
	return useDocumentsInSelectedDrive()?.filter(isGovernanceDocument);
}
/** Hook to get all Governance documents in the selected folder */
function useGovernanceDocumentsInSelectedFolder() {
	return useDocumentsInSelectedFolder()?.filter(isGovernanceDocument);
}
//#endregion
export { GovernanceController as a, defaultGlobalState as c, useSelectedGovernanceDocument as i, defaultLocalState as l, useGovernanceDocumentsInSelectedDrive as n, createGovernanceDocument as o, useGovernanceDocumentsInSelectedFolder as r, createState as s, useGovernanceDocumentById as t, defaultPHState as u };

//# sourceMappingURL=governance-DOk1ubuX.mjs.map