import { p as createBaseState, t as PHDocumentController, v as defaultBaseState } from "./dist-uUUuTqM0.js";
import { a as utils, d as isInvoiceDocument, l as assertIsInvoiceDocument, t as Invoice } from "./module-DXiftdEs.js";
import { O as useSelectedDocument, _ as useDocumentsInSelectedFolder, g as useDocumentsInSelectedDrive, p as useDocumentById } from "./dist-mx7YTOSV.js";
//#region document-models/invoice/v1/gen/ph-factories.ts
function defaultGlobalState() {
	return {
		status: "DRAFT",
		invoiceNo: "",
		dateIssued: null,
		dateDue: null,
		dateDelivered: null,
		issuer: {
			id: null,
			name: null,
			address: null,
			contactInfo: null,
			country: null,
			paymentRouting: null
		},
		payer: {
			id: null,
			name: null,
			address: null,
			contactInfo: null,
			country: null,
			paymentRouting: null
		},
		currency: "",
		lineItems: [],
		totalPriceTaxExcl: 0,
		totalPriceTaxIncl: 0,
		notes: null,
		rejections: [],
		payments: [],
		payAfter: null,
		invoiceTags: [],
		exported: {
			timestamp: null,
			exportedLineItems: []
		},
		closureReason: null
	};
}
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 InvoiceDocument with custom global and local state
* This properly handles the PHBaseState requirements while allowing
* document-specific state to be set.
*/
function createInvoiceDocument(state) {
	return utils.createDocument(state ? createState(createBaseState(state.auth, state.document), state.global, state.local) : void 0);
}
//#endregion
//#region document-models/invoice/v1/gen/controller.ts
const InvoiceController = PHDocumentController.forDocumentModel(Invoice);
//#endregion
//#region document-models/invoice/v1/hooks.ts
/** Hook to get a Invoice document by its id */
function useInvoiceDocumentById(documentId) {
	const [document, dispatch] = useDocumentById(documentId);
	if (!isInvoiceDocument(document)) return [void 0, void 0];
	return [document, dispatch];
}
/** Hook to get the selected Invoice document */
function useSelectedInvoiceDocument() {
	const [document, dispatch] = useSelectedDocument();
	assertIsInvoiceDocument(document);
	return [document, dispatch];
}
/** Hook to get all Invoice documents in the selected drive */
function useInvoiceDocumentsInSelectedDrive() {
	return useDocumentsInSelectedDrive()?.filter(isInvoiceDocument);
}
/** Hook to get all Invoice documents in the selected folder */
function useInvoiceDocumentsInSelectedFolder() {
	return useDocumentsInSelectedFolder()?.filter(isInvoiceDocument);
}
//#endregion
export { InvoiceController as a, defaultGlobalState as c, useSelectedInvoiceDocument as i, defaultLocalState as l, useInvoiceDocumentsInSelectedDrive as n, createInvoiceDocument as o, useInvoiceDocumentsInSelectedFolder as r, createState as s, useInvoiceDocumentById as t, defaultPHState as u };

//# sourceMappingURL=invoice-ovu7ZPDp.js.map