import { p as createBaseState, t as PHDocumentController, v as defaultBaseState } from "./dist-uUUuTqM0.js";
import { a as utils, d as isAccountsDocument, l as assertIsAccountsDocument, t as Accounts } from "./module-DJjNH-7f.js";
import { O as useSelectedDocument, _ as useDocumentsInSelectedFolder, g as useDocumentsInSelectedDrive, p as useDocumentById } from "./dist-mx7YTOSV.js";
//#region document-models/accounts/v1/gen/ph-factories.ts
function defaultGlobalState() {
	return { accounts: [] };
}
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 AccountsDocument with custom global and local state
* This properly handles the PHBaseState requirements while allowing
* document-specific state to be set.
*/
function createAccountsDocument(state) {
	return utils.createDocument(state ? createState(createBaseState(state.auth, state.document), state.global, state.local) : void 0);
}
//#endregion
//#region document-models/accounts/v1/gen/controller.ts
const AccountsController = PHDocumentController.forDocumentModel(Accounts);
//#endregion
//#region document-models/accounts/v1/hooks.ts
/** Hook to get a Accounts document by its id */
function useAccountsDocumentById(documentId) {
	const [document, dispatch] = useDocumentById(documentId);
	if (!isAccountsDocument(document)) return [void 0, void 0];
	return [document, dispatch];
}
/** Hook to get the selected Accounts document */
function useSelectedAccountsDocument() {
	const [document, dispatch] = useSelectedDocument();
	assertIsAccountsDocument(document);
	return [document, dispatch];
}
/** Hook to get all Accounts documents in the selected drive */
function useAccountsDocumentsInSelectedDrive() {
	return useDocumentsInSelectedDrive()?.filter(isAccountsDocument);
}
/** Hook to get all Accounts documents in the selected folder */
function useAccountsDocumentsInSelectedFolder() {
	return useDocumentsInSelectedFolder()?.filter(isAccountsDocument);
}
//#endregion
export { AccountsController as a, defaultGlobalState as c, useSelectedAccountsDocument as i, defaultLocalState as l, useAccountsDocumentsInSelectedDrive as n, createAccountsDocument as o, useAccountsDocumentsInSelectedFolder as r, createState as s, useAccountsDocumentById as t, defaultPHState as u };

//# sourceMappingURL=accounts-BPRp-Roc.js.map