import { r as __exportAll } from "./chunk-olfrzTEO.js";
import { B as lazy, H as number, I as _enum, J as datetime, L as any, R as array, U as object, V as literal, W as string, a as BaseDocumentHeaderSchema, b as generateId, c as baseCreateDocument, f as createAction, g as createState, h as createReducer, l as baseLoadFromInput, o as BaseDocumentStateSchema, s as baseActions, u as baseSaveToFileHandle, v as defaultBaseState, x as isDocumentAction } from "./dist-uUUuTqM0.js";
//#region document-models/snapshot-report/v1/gen/document-model.ts
const documentModel = {
	id: "powerhouse/snapshot-report",
	name: "SnapshotReport",
	author: {
		name: "Powerhouse",
		website: "https://www.powerhouse.inc/"
	},
	extension: "",
	description: "Document model for creating snapshot reports that track fund flows through categorized accounts over a specified accounting period.",
	specifications: [{
		state: {
			local: {
				schema: "",
				examples: [],
				initialValue: ""
			},
			global: {
				schema: "type SnapshotReportState {\n  ownerIds: [PHID!]!\n  accountsDocumentId: PHID\n  startDate: DateTime\n  endDate: DateTime\n  reportName: String\n  reportPeriodStart: DateTime\n  reportPeriodEnd: DateTime\n  snapshotAccounts: [SnapshotAccount!]!\n}\n\ntype SnapshotAccount {\n  id: OID!\n  accountId: OID!\n  accountAddress: String!\n  accountName: String!\n  type: AccountType!\n  accountTransactionsId: PHID\n  startingBalances: [TokenBalance!]!\n  endingBalances: [TokenBalance!]!\n  transactions: [SnapshotTransaction!]!\n}\n\ntype TokenBalance {\n  id: OID!\n  token: Currency!\n  amount: Amount_Currency!\n}\n\ntype SnapshotTransaction {\n  id: OID!\n  transactionId: String!\n  counterParty: EthereumAddress\n  amount: Amount_Currency!\n  datetime: DateTime!\n  txHash: String!\n  token: Currency!\n  blockNumber: Int\n  direction: TransactionDirection!\n  flowType: TransactionFlowType\n  counterPartyAccountId: OID\n}\n\nenum AccountType {\n  Source\n  Internal\n  Destination\n  External\n}\n\nenum AccountTypeInput {\n  Source\n  Internal\n  Destination\n  External\n}\n\nenum TransactionDirection {\n  INFLOW\n  OUTFLOW\n}\n\nenum TransactionDirectionInput {\n  INFLOW\n  OUTFLOW\n}\n\nenum TransactionFlowType {\n  TopUp\n  Return\n  Internal\n  External\n  Swap\n}\n\nenum TransactionFlowTypeInput {\n  TopUp\n  Return\n  Internal\n  External\n  Swap\n}",
				examples: [],
				initialValue: "{\"ownerIds\": [], \"accountsDocumentId\": null, \"startDate\": null, \"endDate\": null, \"reportName\": null, \"reportPeriodStart\": null, \"reportPeriodEnd\": null, \"snapshotAccounts\": []}"
			}
		},
		modules: [
			{
				id: "config",
				name: "configuration",
				operations: [
					{
						id: "set-report-config",
						name: "setReportConfig",
						scope: "global",
						errors: [],
						schema: "input SetReportConfigInput {\n  reportName: String\n  startDate: DateTime\n  endDate: DateTime\n  accountsDocumentId: PHID\n}",
						reducer: "if (action.input.reportName !== undefined && action.input.reportName !== null) {\n  state.reportName = action.input.reportName;\n}\nif (action.input.startDate !== undefined && action.input.startDate !== null) {\n  state.startDate = action.input.startDate;\n}\nif (action.input.endDate !== undefined && action.input.endDate !== null) {\n  state.endDate = action.input.endDate;\n}\nif (action.input.accountsDocumentId !== undefined && action.input.accountsDocumentId !== null) {\n  state.accountsDocumentId = action.input.accountsDocumentId;\n}",
						examples: [],
						template: "Set the report configuration including name, period, and accounts document reference",
						description: "Set the report configuration including name, period, and accounts document reference"
					},
					{
						id: "set-accounts-document",
						name: "setAccountsDocument",
						scope: "global",
						errors: [],
						schema: "input SetAccountsDocumentInput {\n  accountsDocumentId: PHID!\n}",
						reducer: "state.accountsDocumentId = action.input.accountsDocumentId;",
						examples: [],
						template: "Link the snapshot report to an Accounts document",
						description: "Link the snapshot report to an Accounts document"
					},
					{
						id: "set-period",
						name: "setPeriod",
						scope: "global",
						errors: [],
						schema: "input SetPeriodInput {\n  startDate: DateTime!\n  endDate: DateTime!\n}",
						reducer: "state.startDate = action.input.startDate;\nstate.endDate = action.input.endDate;",
						examples: [],
						template: "Set the accounting period for the snapshot report",
						description: "Set the accounting period for the snapshot report"
					},
					{
						id: "set-owner-id",
						name: "addOwnerId",
						scope: "global",
						errors: [],
						schema: "input AddOwnerIdInput {\n  ownerId: PHID!\n}",
						reducer: "if (!state.ownerIds.includes(action.input.ownerId)) {\n  state.ownerIds.push(action.input.ownerId);\n}",
						examples: [],
						template: "Set the owner ID (builder team) for the snapshot report",
						description: "Add an owner ID (builder team) to the snapshot report"
					},
					{
						id: "80c12645-0005-4534-b578-52a40582d18e",
						name: "setPeriodStart",
						scope: "global",
						errors: [],
						schema: "input SetPeriodStartInput {\n  periodStart: DateTime!\n}",
						reducer: "",
						examples: [],
						template: "",
						description: ""
					},
					{
						id: "05d31622-9b31-493a-948b-c817867ce5eb",
						name: "setPeriodEnd",
						scope: "global",
						errors: [],
						schema: "input SetPeriodEndInput {\n  periodEnd: DateTime!\n}",
						reducer: "",
						examples: [],
						template: "",
						description: ""
					},
					{
						id: "remove-owner-id",
						name: "removeOwnerId",
						scope: "global",
						errors: [],
						schema: "input RemoveOwnerIdInput {\n  ownerId: PHID!\n}",
						reducer: "const index = state.ownerIds.indexOf(action.input.ownerId);\nif (index !== -1) {\n  state.ownerIds.splice(index, 1);\n}",
						examples: [],
						template: "Remove an owner ID from the snapshot report",
						description: "Remove an owner ID from the snapshot report"
					}
				],
				description: "Operations for configuring the snapshot report"
			},
			{
				id: "accounts",
				name: "accounts",
				operations: [
					{
						id: "add-snapshot-account",
						name: "addSnapshotAccount",
						scope: "global",
						errors: [{
							id: "duplicate-account-error",
							code: "DUPLICATE_ACCOUNT",
							name: "DuplicateAccountError",
							template: "",
							description: "An account with this ID already exists in the snapshot"
						}],
						schema: "input AddSnapshotAccountInput {\n  id: OID!\n  accountId: OID!\n  accountAddress: String!\n  accountName: String!\n  type: AccountTypeInput!\n  accountTransactionsId: PHID\n}",
						reducer: "const existingAccount = state.snapshotAccounts.find(a => a.id === action.input.id);\nif (existingAccount) {\n  throw new DuplicateAccountError(`Account with ID ${action.input.id} already exists`);\n}\n\nconst newAccount = {\n  id: action.input.id,\n  accountId: action.input.accountId,\n  accountAddress: action.input.accountAddress,\n  accountName: action.input.accountName,\n  type: action.input.type,\n  accountTransactionsId: action.input.accountTransactionsId || null,\n  startingBalances: [],\n  endingBalances: [],\n  transactions: []\n};\n\nstate.snapshotAccounts.push(newAccount);",
						examples: [],
						template: "Add an account to the snapshot report",
						description: "Add an account to the snapshot report"
					},
					{
						id: "update-account-type",
						name: "updateSnapshotAccountType",
						scope: "global",
						errors: [{
							id: "account-not-found-error",
							code: "UPDATE_ACCOUNT_TYPE_ACCOUNT_NOT_FOUND",
							name: "UpdateAccountTypeNotFoundError",
							template: "",
							description: "The specified account was not found in the snapshot"
						}],
						schema: "input UpdateSnapshotAccountTypeInput {\n  id: OID!\n  type: AccountTypeInput!\n}",
						reducer: "const account = state.snapshotAccounts.find(a => a.id === action.input.id);\nif (!account) {\n  throw new UpdateAccountTypeNotFoundError(`Account with ID ${action.input.id} not found`);\n}\n\naccount.type = action.input.type;",
						examples: [],
						template: "Update the type categorization of a snapshot account",
						description: "Update the type categorization of a snapshot account"
					},
					{
						id: "remove-snapshot-account",
						name: "removeSnapshotAccount",
						scope: "global",
						errors: [{
							id: "account-not-found-error-2",
							code: "REMOVE_ACCOUNT_NOT_FOUND",
							name: "RemoveAccountNotFoundError",
							template: "",
							description: "The specified account was not found in the snapshot"
						}],
						schema: "input RemoveSnapshotAccountInput {\n  id: OID!\n}",
						reducer: "const accountIndex = state.snapshotAccounts.findIndex(a => a.id === action.input.id);\nif (accountIndex === -1) {\n  throw new RemoveAccountNotFoundError(`Account with ID ${action.input.id} not found`);\n}\n\nstate.snapshotAccounts.splice(accountIndex, 1);",
						examples: [],
						template: "Remove an account from the snapshot report",
						description: "Remove an account from the snapshot report"
					}
				],
				description: "Operations for managing snapshot accounts"
			},
			{
				id: "balances",
				name: "balances",
				operations: [
					{
						id: "set-starting-balance",
						name: "setStartingBalance",
						scope: "global",
						errors: [{
							id: "account-not-found-error-3",
							code: "SET_STARTING_BALANCE_ACCOUNT_NOT_FOUND",
							name: "SetStartingBalanceAccountNotFoundError",
							template: "",
							description: "The specified account was not found in the snapshot"
						}],
						schema: "input SetStartingBalanceInput {\n  accountId: OID!\n  balanceId: OID!\n  token: Currency!\n  amount: Amount_Currency!\n}",
						reducer: "const account = state.snapshotAccounts.find(a => a.id === action.input.accountId);\nif (!account) {\n  throw new SetStartingBalanceAccountNotFoundError(`Account with ID ${action.input.accountId} not found`);\n}\n\nconst existingBalance = account.startingBalances.find(b => b.id === action.input.balanceId);\nif (existingBalance) {\n  existingBalance.token = action.input.token;\n  existingBalance.amount = action.input.amount;\n} else {\n  account.startingBalances.push({\n    id: action.input.balanceId,\n    token: action.input.token,\n    amount: action.input.amount\n  });\n}",
						examples: [],
						template: "Set or update a starting balance for a token in a snapshot account",
						description: "Set or update a starting balance for a token in a snapshot account"
					},
					{
						id: "set-ending-balance",
						name: "setEndingBalance",
						scope: "global",
						errors: [{
							id: "account-not-found-error-4",
							code: "SET_ENDING_BALANCE_ACCOUNT_NOT_FOUND",
							name: "SetEndingBalanceAccountNotFoundError",
							template: "",
							description: "The specified account was not found in the snapshot"
						}],
						schema: "input SetEndingBalanceInput {\n  accountId: OID!\n  balanceId: OID!\n  token: Currency!\n  amount: Amount_Currency!\n}",
						reducer: "const account = state.snapshotAccounts.find(a => a.id === action.input.accountId);\nif (!account) {\n  throw new SetEndingBalanceAccountNotFoundError(`Account with ID ${action.input.accountId} not found`);\n}\n\nconst existingBalance = account.endingBalances.find(b => b.id === action.input.balanceId);\nif (existingBalance) {\n  existingBalance.token = action.input.token;\n  existingBalance.amount = action.input.amount;\n} else {\n  account.endingBalances.push({\n    id: action.input.balanceId,\n    token: action.input.token,\n    amount: action.input.amount\n  });\n}",
						examples: [],
						template: "Set or update an ending balance for a token in a snapshot account",
						description: "Set or update an ending balance for a token in a snapshot account"
					},
					{
						id: "remove-starting-balance",
						name: "removeStartingBalance",
						scope: "global",
						errors: [{
							id: "balance-not-found-error",
							code: "REMOVE_STARTING_BALANCE_NOT_FOUND",
							name: "RemoveStartingBalanceNotFoundError",
							template: "",
							description: "The specified balance was not found"
						}],
						schema: "input RemoveStartingBalanceInput {\n  accountId: OID!\n  balanceId: OID!\n}",
						reducer: "const account = state.snapshotAccounts.find(a => a.id === action.input.accountId);\nif (!account) {\n  throw new SetStartingBalanceAccountNotFoundError(`Account with ID ${action.input.accountId} not found`);\n}\n\nconst balanceIndex = account.startingBalances.findIndex(b => b.id === action.input.balanceId);\nif (balanceIndex === -1) {\n  throw new RemoveStartingBalanceNotFoundError(`Balance with ID ${action.input.balanceId} not found`);\n}\n\naccount.startingBalances.splice(balanceIndex, 1);",
						examples: [],
						template: "Remove a starting balance entry from a snapshot account",
						description: "Remove a starting balance entry from a snapshot account"
					},
					{
						id: "remove-ending-balance",
						name: "removeEndingBalance",
						scope: "global",
						errors: [{
							id: "balance-not-found-error-2",
							code: "REMOVE_ENDING_BALANCE_NOT_FOUND",
							name: "RemoveEndingBalanceNotFoundError",
							template: "",
							description: "The specified balance was not found"
						}],
						schema: "input RemoveEndingBalanceInput {\n  accountId: OID!\n  balanceId: OID!\n}",
						reducer: "const account = state.snapshotAccounts.find(a => a.id === action.input.accountId);\nif (!account) {\n  throw new SetEndingBalanceAccountNotFoundError(`Account with ID ${action.input.accountId} not found`);\n}\n\nconst balanceIndex = account.endingBalances.findIndex(b => b.id === action.input.balanceId);\nif (balanceIndex === -1) {\n  throw new RemoveEndingBalanceNotFoundError(`Balance with ID ${action.input.balanceId} not found`);\n}\n\naccount.endingBalances.splice(balanceIndex, 1);",
						examples: [],
						template: "Remove an ending balance entry from a snapshot account",
						description: "Remove an ending balance entry from a snapshot account"
					}
				],
				description: "Operations for managing account token balances"
			},
			{
				id: "transactions",
				name: "transactions",
				operations: [
					{
						id: "add-transaction",
						name: "addTransaction",
						scope: "global",
						errors: [{
							id: "duplicate-transaction-error",
							code: "DUPLICATE_TRANSACTION",
							name: "DuplicateTransactionError",
							template: "",
							description: "A transaction with this ID already exists in the snapshot"
						}, {
							id: "account-not-found-error-5",
							code: "ADD_TRANSACTION_ACCOUNT_NOT_FOUND",
							name: "AddTransactionAccountNotFoundError",
							template: "",
							description: "The specified account was not found in the snapshot"
						}],
						schema: "input AddTransactionInput {\n  accountId: OID!\n  id: OID!\n  transactionId: String!\n  counterParty: EthereumAddress\n  amount: Amount_Currency!\n  datetime: DateTime!\n  txHash: String!\n  token: Currency!\n  blockNumber: Int\n  direction: TransactionDirectionInput!\n  flowType: TransactionFlowTypeInput\n  counterPartyAccountId: OID\n}\n",
						reducer: "const account = state.snapshotAccounts.find(a => a.id === action.input.accountId);\nif (!account) {\n  throw new AddTransactionAccountNotFoundError(`Account with ID ${action.input.accountId} not found`);\n}\n\nconst existingTransaction = account.transactions.find(t => t.id === action.input.id);\nif (existingTransaction) {\n  throw new DuplicateTransactionError(`Transaction with ID ${action.input.id} already exists`);\n}\n\n// Known swap protocol addresses (lowercase)\nconst SWAP_ADDRESSES = new Set([\n  '0x9008d19f58aabd9ed0d60971565aa8510560ab41', // CoW Protocol Settlement\n  '0x7a250d5630b4cf539739df2c5dacb4c659f2488d', // Uniswap V2 Router\n  '0xe592427a0aece92de3edee1f18e0157c05861564', // Uniswap V3 Router\n  '0x68b3465833fb72a70ecdf485e0e4c7bd8665fc45', // Uniswap V3 Router 2\n  '0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad', // Uniswap Universal Router\n  '0xd9e1ce17f2641f24ae83637ab66a2cca9c378b9f', // SushiSwap Router\n  '0x1111111254eeb25477b68fb85ed929f73a960582', // 1inch Router v5\n  '0x1111111254fb6c44bac0bed2854e76f90643097d', // 1inch Router v4\n  '0xdef1c0ded9bec7f1a1670819833240f027b25eff', // 0x Exchange Proxy\n  '0x881d40237659c251811cec9c364ef91dc08d300c', // Metamask Swap Router\n]);\n\nfunction isSwapAddress(address) {\n  if (!address) return false;\n  return SWAP_ADDRESSES.has(address.toLowerCase());\n}\n\n// AUTO-CATEGORIZATION: Determine flow type and counter-party account ID\nlet flowType = action.input.flowType || null;\nlet counterPartyAccountId = action.input.counterPartyAccountId || null;\n\n// Check for swap transactions first (highest priority)\nif (!flowType && isSwapAddress(action.input.counterParty)) {\n  flowType = 'Swap';\n} else if (action.input.counterParty) {\n  // Find counter-party account in snapshot\n  const counterPartyAccount = state.snapshotAccounts.find(\n    (acc) => acc.accountAddress.toLowerCase() === action.input.counterParty.toLowerCase(),\n  );\n\n  if (counterPartyAccount) {\n    // Auto-link counter-party account\n    counterPartyAccountId = counterPartyAccount.id;\n\n    // Auto-categorize flow type if not explicitly provided\n    if (!flowType) {\n      // Determine sender and receiver types based on transaction direction\n      const fromType =\n        action.input.direction === 'OUTFLOW'\n          ? account.type\n          : counterPartyAccount.type;\n      const toType =\n        action.input.direction === 'OUTFLOW'\n          ? counterPartyAccount.type\n          : account.type;\n\n      // Flow categorization rules\n      if (fromType === 'Source') {\n        flowType = 'TopUp';\n      } else if (toType === 'Source') {\n        flowType = 'Return';\n      } else if (toType === 'Destination') {\n        flowType = 'TopUp';\n      } else if (fromType === 'External') {\n        flowType = 'External';\n      } else if (fromType === 'Internal' && toType === 'Internal') {\n        flowType = 'Internal';\n      } else if (fromType === 'Internal' && toType === 'External') {\n        flowType = 'External';\n      } else {\n        flowType = 'External';\n      }\n    }\n  } else if (!flowType) {\n    // FALLBACK: Counter-party not found in snapshot, default to External\n    flowType = 'External';\n  }\n} else if (!flowType) {\n  // FALLBACK: No counter-party provided, default to External\n  flowType = 'External';\n}\n\nconst newTransaction = {\n  id: action.input.id,\n  transactionId: action.input.transactionId,\n  counterParty: action.input.counterParty || null,\n  amount: action.input.amount,\n  datetime: action.input.datetime,\n  txHash: action.input.txHash,\n  token: action.input.token,\n  blockNumber: action.input.blockNumber || null,\n  direction: action.input.direction,\n  flowType: flowType,\n  counterPartyAccountId: counterPartyAccountId,\n};\n\naccount.transactions.push(newTransaction);",
						examples: [],
						template: "Add a transaction to the snapshot with enrichment data",
						description: "Add a transaction to the snapshot with enrichment data"
					},
					{
						id: "remove-transaction",
						name: "removeTransaction",
						scope: "global",
						errors: [{
							id: "transaction-not-found-error",
							code: "REMOVE_TRANSACTION_NOT_FOUND",
							name: "RemoveTransactionNotFoundError",
							template: "",
							description: "The specified transaction was not found"
						}],
						schema: "input RemoveTransactionInput {\n  id: OID!\n}",
						reducer: "let found = false;\n\nfor (const account of state.snapshotAccounts) {\n  const transactionIndex = account.transactions.findIndex(t => t.id === action.input.id);\n  if (transactionIndex !== -1) {\n    account.transactions.splice(transactionIndex, 1);\n    found = true;\n    break;\n  }\n}\n\nif (!found) {\n  throw new RemoveTransactionNotFoundError(`Transaction with ID ${action.input.id} not found`);\n}",
						examples: [],
						template: "Remove a transaction from the snapshot",
						description: "Remove a transaction from the snapshot"
					},
					{
						id: "update-flow-type",
						name: "updateTransactionFlowType",
						scope: "global",
						errors: [{
							id: "transaction-not-found-error-2",
							code: "UPDATE_FLOW_TYPE_TRANSACTION_NOT_FOUND",
							name: "UpdateFlowTypeTransactionNotFoundError",
							template: "",
							description: "The specified transaction was not found"
						}],
						schema: "input UpdateTransactionFlowTypeInput {\n  id: OID!\n  flowType: TransactionFlowTypeInput!\n}",
						reducer: "let transaction = null;\n\nfor (const account of state.snapshotAccounts) {\n  transaction = account.transactions.find(t => t.id === action.input.id);\n  if (transaction) {\n    break;\n  }\n}\n\nif (!transaction) {\n  throw new UpdateFlowTypeTransactionNotFoundError(`Transaction with ID ${action.input.id} not found`);\n}\n\ntransaction.flowType = action.input.flowType;",
						examples: [],
						template: "Update the flow type categorization of a transaction",
						description: "Update the flow type categorization of a transaction"
					},
					{
						id: "recalculate-flow-types",
						name: "recalculateFlowTypes",
						scope: "global",
						errors: [],
						schema: "input RecalculateFlowTypesInput {\n  _: String\n}",
						reducer: "// Known swap protocol addresses (lowercase)\nconst SWAP_ADDRESSES = new Set([\n  '0x9008d19f58aabd9ed0d60971565aa8510560ab41', // CoW Protocol Settlement\n  '0x7a250d5630b4cf539739df2c5dacb4c659f2488d', // Uniswap V2 Router\n  '0xe592427a0aece92de3edee1f18e0157c05861564', // Uniswap V3 Router\n  '0x68b3465833fb72a70ecdf485e0e4c7bd8665fc45', // Uniswap V3 Router 2\n  '0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad', // Uniswap Universal Router\n  '0xd9e1ce17f2641f24ae83637ab66a2cca9c378b9f', // SushiSwap Router\n  '0x1111111254eeb25477b68fb85ed929f73a960582', // 1inch Router v5\n  '0x1111111254fb6c44bac0bed2854e76f90643097d', // 1inch Router v4\n  '0xdef1c0ded9bec7f1a1670819833240f027b25eff', // 0x Exchange Proxy\n  '0x881d40237659c251811cec9c364ef91dc08d300c', // Metamask Swap Router\n]);\n\nfunction isSwapAddress(address) {\n  if (!address) return false;\n  return SWAP_ADDRESSES.has(address.toLowerCase());\n}\n\nfor (const account of state.snapshotAccounts) {\n  for (const tx of account.transactions) {\n    // Check for swap transactions first\n    if (isSwapAddress(tx.counterParty)) {\n      tx.flowType = 'Swap';\n      continue;\n    }\n\n    if (!tx.counterParty) continue;\n\n    // Find counter-party account\n    const counterPartyAccount = state.snapshotAccounts.find(\n      (acc) => acc.accountAddress.toLowerCase() === tx.counterParty.toLowerCase(),\n    );\n\n    if (counterPartyAccount) {\n      // Update counter-party link if missing\n      if (!tx.counterPartyAccountId) {\n        tx.counterPartyAccountId = counterPartyAccount.id;\n      }\n\n      // Recalculate flow type based on account types\n      const fromType =\n        tx.direction === 'OUTFLOW' ? account.type : counterPartyAccount.type;\n      const toType =\n        tx.direction === 'OUTFLOW' ? counterPartyAccount.type : account.type;\n\n      // Flow categorization rules\n      if (fromType === 'Source') {\n        tx.flowType = 'TopUp';\n      } else if (toType === 'Source') {\n        tx.flowType = 'Return';\n      } else if (toType === 'Destination') {\n        tx.flowType = 'TopUp';\n      } else if (fromType === 'External') {\n        tx.flowType = 'External';\n      } else if (fromType === 'Internal' && toType === 'Internal') {\n        tx.flowType = 'Internal';\n      } else if (fromType === 'Internal' && toType === 'External') {\n        tx.flowType = 'External';\n      } else {\n        tx.flowType = 'External';\n      }\n    }\n  }\n}",
						examples: [],
						template: "Recalculate all transaction flow types based on current account types",
						description: "Recalculate all transaction flow types based on current account types and counter-party relationships"
					}
				],
				description: "Operations for managing snapshot transactions"
			}
		],
		version: 1,
		changeLog: []
	}]
};
//#endregion
//#region document-models/snapshot-report/v1/src/reducers/configuration.ts
const snapshotReportConfigurationOperations = {
	setReportConfigOperation(state, action) {
		if (action.input.reportName !== void 0 && action.input.reportName !== null) state.reportName = action.input.reportName;
		if (action.input.startDate !== void 0 && action.input.startDate !== null) state.startDate = action.input.startDate;
		if (action.input.endDate !== void 0 && action.input.endDate !== null) state.endDate = action.input.endDate;
		if (action.input.accountsDocumentId !== void 0 && action.input.accountsDocumentId !== null) state.accountsDocumentId = action.input.accountsDocumentId;
	},
	setAccountsDocumentOperation(state, action) {
		state.accountsDocumentId = action.input.accountsDocumentId;
	},
	setPeriodOperation(state, action) {
		state.startDate = action.input.startDate;
		state.endDate = action.input.endDate;
	},
	addOwnerIdOperation(state, action) {
		if (!state.ownerIds.includes(action.input.ownerId)) state.ownerIds.push(action.input.ownerId);
	},
	setPeriodStartOperation(state, action) {
		state.reportPeriodStart = action.input.periodStart;
	},
	setPeriodEndOperation(state, action) {
		state.reportPeriodEnd = action.input.periodEnd;
	},
	removeOwnerIdOperation(state, action) {
		const index = state.ownerIds.indexOf(action.input.ownerId);
		if (index !== -1) state.ownerIds.splice(index, 1);
	}
};
//#endregion
//#region document-models/snapshot-report/v1/gen/accounts/error.ts
var DuplicateAccountError = class extends Error {
	errorCode = "DuplicateAccountError";
	constructor(message = "DuplicateAccountError") {
		super(message);
	}
};
var UpdateAccountTypeNotFoundError = class extends Error {
	errorCode = "UpdateAccountTypeNotFoundError";
	constructor(message = "UpdateAccountTypeNotFoundError") {
		super(message);
	}
};
var RemoveAccountNotFoundError = class extends Error {
	errorCode = "RemoveAccountNotFoundError";
	constructor(message = "RemoveAccountNotFoundError") {
		super(message);
	}
};
//#endregion
//#region document-models/snapshot-report/v1/src/reducers/accounts.ts
const snapshotReportAccountsOperations = {
	addSnapshotAccountOperation(state, action) {
		if (state.snapshotAccounts.find((a) => a.id === action.input.id)) throw new DuplicateAccountError(`Account with ID ${action.input.id} already exists`);
		const newAccount = {
			id: action.input.id,
			accountId: action.input.accountId,
			accountAddress: action.input.accountAddress,
			accountName: action.input.accountName,
			type: action.input.type,
			accountTransactionsId: action.input.accountTransactionsId || null,
			startingBalances: [],
			endingBalances: [],
			transactions: []
		};
		state.snapshotAccounts.push(newAccount);
	},
	updateSnapshotAccountTypeOperation(state, action) {
		const account = state.snapshotAccounts.find((a) => a.id === action.input.id);
		if (!account) throw new UpdateAccountTypeNotFoundError(`Account with ID ${action.input.id} not found`);
		account.type = action.input.type;
	},
	removeSnapshotAccountOperation(state, action) {
		const accountIndex = state.snapshotAccounts.findIndex((a) => a.id === action.input.id);
		if (accountIndex === -1) throw new RemoveAccountNotFoundError(`Account with ID ${action.input.id} not found`);
		state.snapshotAccounts.splice(accountIndex, 1);
	}
};
//#endregion
//#region document-models/snapshot-report/v1/gen/balances/error.ts
var SetStartingBalanceAccountNotFoundError = class extends Error {
	errorCode = "SetStartingBalanceAccountNotFoundError";
	constructor(message = "SetStartingBalanceAccountNotFoundError") {
		super(message);
	}
};
var SetEndingBalanceAccountNotFoundError = class extends Error {
	errorCode = "SetEndingBalanceAccountNotFoundError";
	constructor(message = "SetEndingBalanceAccountNotFoundError") {
		super(message);
	}
};
var RemoveStartingBalanceNotFoundError = class extends Error {
	errorCode = "RemoveStartingBalanceNotFoundError";
	constructor(message = "RemoveStartingBalanceNotFoundError") {
		super(message);
	}
};
var RemoveEndingBalanceNotFoundError = class extends Error {
	errorCode = "RemoveEndingBalanceNotFoundError";
	constructor(message = "RemoveEndingBalanceNotFoundError") {
		super(message);
	}
};
//#endregion
//#region document-models/snapshot-report/v1/src/reducers/balances.ts
const snapshotReportBalancesOperations = {
	setStartingBalanceOperation(state, action) {
		const account = state.snapshotAccounts.find((a) => a.id === action.input.accountId);
		if (!account) throw new SetStartingBalanceAccountNotFoundError(`Account with ID ${action.input.accountId} not found`);
		const existingById = account.startingBalances.find((b) => b.id === action.input.balanceId);
		if (existingById) {
			existingById.token = action.input.token;
			existingById.amount = action.input.amount;
			return;
		}
		const existingByToken = account.startingBalances.find((b) => b.token === action.input.token);
		if (existingByToken) {
			existingByToken.id = action.input.balanceId;
			existingByToken.amount = action.input.amount;
			return;
		}
		account.startingBalances.push({
			id: action.input.balanceId,
			token: action.input.token,
			amount: action.input.amount
		});
	},
	setEndingBalanceOperation(state, action) {
		const account = state.snapshotAccounts.find((a) => a.id === action.input.accountId);
		if (!account) throw new SetEndingBalanceAccountNotFoundError(`Account with ID ${action.input.accountId} not found`);
		const existingById = account.endingBalances.find((b) => b.id === action.input.balanceId);
		if (existingById) {
			existingById.token = action.input.token;
			existingById.amount = action.input.amount;
			return;
		}
		const existingByToken = account.endingBalances.find((b) => b.token === action.input.token);
		if (existingByToken) {
			existingByToken.id = action.input.balanceId;
			existingByToken.amount = action.input.amount;
			return;
		}
		account.endingBalances.push({
			id: action.input.balanceId,
			token: action.input.token,
			amount: action.input.amount
		});
	},
	removeStartingBalanceOperation(state, action) {
		const account = state.snapshotAccounts.find((a) => a.id === action.input.accountId);
		if (!account) throw new SetStartingBalanceAccountNotFoundError(`Account with ID ${action.input.accountId} not found`);
		const balanceIndex = account.startingBalances.findIndex((b) => b.id === action.input.balanceId);
		if (balanceIndex === -1) throw new RemoveStartingBalanceNotFoundError(`Balance with ID ${action.input.balanceId} not found`);
		account.startingBalances.splice(balanceIndex, 1);
	},
	removeEndingBalanceOperation(state, action) {
		const account = state.snapshotAccounts.find((a) => a.id === action.input.accountId);
		if (!account) throw new SetEndingBalanceAccountNotFoundError(`Account with ID ${action.input.accountId} not found`);
		const balanceIndex = account.endingBalances.findIndex((b) => b.id === action.input.balanceId);
		if (balanceIndex === -1) throw new RemoveEndingBalanceNotFoundError(`Balance with ID ${action.input.balanceId} not found`);
		account.endingBalances.splice(balanceIndex, 1);
	}
};
//#endregion
//#region document-models/snapshot-report/v1/gen/transactions/error.ts
var DuplicateTransactionError = class extends Error {
	errorCode = "DuplicateTransactionError";
	constructor(message = "DuplicateTransactionError") {
		super(message);
	}
};
var AddTransactionAccountNotFoundError = class extends Error {
	errorCode = "AddTransactionAccountNotFoundError";
	constructor(message = "AddTransactionAccountNotFoundError") {
		super(message);
	}
};
var RemoveTransactionNotFoundError = class extends Error {
	errorCode = "RemoveTransactionNotFoundError";
	constructor(message = "RemoveTransactionNotFoundError") {
		super(message);
	}
};
var UpdateFlowTypeTransactionNotFoundError = class extends Error {
	errorCode = "UpdateFlowTypeTransactionNotFoundError";
	constructor(message = "UpdateFlowTypeTransactionNotFoundError") {
		super(message);
	}
};
//#endregion
//#region document-models/snapshot-report/v1/src/reducers/transactions.ts
const snapshotReportTransactionsOperations = {
	addTransactionOperation(state, action) {
		const account = state.snapshotAccounts.find((a) => a.id === action.input.accountId);
		if (!account) throw new AddTransactionAccountNotFoundError(`Account with ID ${action.input.accountId} not found`);
		if (account.transactions.find((t) => t.id === action.input.id)) throw new DuplicateTransactionError(`Transaction with ID ${action.input.id} already exists`);
		const SWAP_ADDRESSES = new Set([
			"0x9008d19f58aabd9ed0d60971565aa8510560ab41",
			"0x7a250d5630b4cf539739df2c5dacb4c659f2488d",
			"0xe592427a0aece92de3edee1f18e0157c05861564",
			"0x68b3465833fb72a70ecdf485e0e4c7bd8665fc45",
			"0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad",
			"0xd9e1ce17f2641f24ae83637ab66a2cca9c378b9f",
			"0x1111111254eeb25477b68fb85ed929f73a960582",
			"0x1111111254fb6c44bac0bed2854e76f90643097d",
			"0xdef1c0ded9bec7f1a1670819833240f027b25eff",
			"0x881d40237659c251811cec9c364ef91dc08d300c"
		]);
		function isSwapAddress(address) {
			if (!address) return false;
			return SWAP_ADDRESSES.has(address.toLowerCase());
		}
		let flowType = action.input.flowType || null;
		let counterPartyAccountId = action.input.counterPartyAccountId || null;
		if (!flowType && isSwapAddress(action.input.counterParty)) flowType = "Swap";
		else if (action.input.counterParty) {
			const counterPartyAccount = state.snapshotAccounts.find((acc) => acc.accountAddress.toLowerCase() === action.input.counterParty.toLowerCase());
			if (counterPartyAccount) {
				counterPartyAccountId = counterPartyAccount.id;
				if (!flowType) {
					const fromType = action.input.direction === "OUTFLOW" ? account.type : counterPartyAccount.type;
					const toType = action.input.direction === "OUTFLOW" ? counterPartyAccount.type : account.type;
					if (fromType === "Source") flowType = "TopUp";
					else if (toType === "Source") flowType = "Return";
					else if (toType === "Destination") flowType = "TopUp";
					else if (fromType === "External") flowType = "External";
					else if (fromType === "Internal" && toType === "Internal") flowType = "Internal";
					else if (fromType === "Internal" && toType === "External") flowType = "External";
					else flowType = "External";
				}
			} else if (!flowType) flowType = "External";
		} else if (!flowType) flowType = "External";
		const newTransaction = {
			id: action.input.id,
			transactionId: action.input.transactionId,
			counterParty: action.input.counterParty || null,
			amount: action.input.amount,
			datetime: action.input.datetime,
			txHash: action.input.txHash,
			token: action.input.token,
			blockNumber: action.input.blockNumber || null,
			direction: action.input.direction,
			flowType,
			counterPartyAccountId
		};
		account.transactions.push(newTransaction);
	},
	removeTransactionOperation(state, action) {
		let found = false;
		for (const account of state.snapshotAccounts) {
			const transactionIndex = account.transactions.findIndex((t) => t.id === action.input.id);
			if (transactionIndex !== -1) {
				account.transactions.splice(transactionIndex, 1);
				found = true;
				break;
			}
		}
		if (!found) throw new RemoveTransactionNotFoundError(`Transaction with ID ${action.input.id} not found`);
	},
	updateTransactionFlowTypeOperation(state, action) {
		let transaction = null;
		for (const account of state.snapshotAccounts) {
			transaction = account.transactions.find((t) => t.id === action.input.id);
			if (transaction) break;
		}
		if (!transaction) throw new UpdateFlowTypeTransactionNotFoundError(`Transaction with ID ${action.input.id} not found`);
		transaction.flowType = action.input.flowType;
	},
	recalculateFlowTypesOperation(state, action) {
		const SWAP_ADDRESSES = new Set([
			"0x9008d19f58aabd9ed0d60971565aa8510560ab41",
			"0x7a250d5630b4cf539739df2c5dacb4c659f2488d",
			"0xe592427a0aece92de3edee1f18e0157c05861564",
			"0x68b3465833fb72a70ecdf485e0e4c7bd8665fc45",
			"0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad",
			"0xd9e1ce17f2641f24ae83637ab66a2cca9c378b9f",
			"0x1111111254eeb25477b68fb85ed929f73a960582",
			"0x1111111254fb6c44bac0bed2854e76f90643097d",
			"0xdef1c0ded9bec7f1a1670819833240f027b25eff",
			"0x881d40237659c251811cec9c364ef91dc08d300c"
		]);
		function isSwapAddress(address) {
			if (!address) return false;
			return SWAP_ADDRESSES.has(address.toLowerCase());
		}
		for (const account of state.snapshotAccounts) for (const tx of account.transactions) {
			if (isSwapAddress(tx.counterParty)) {
				tx.flowType = "Swap";
				continue;
			}
			if (!tx.counterParty) continue;
			const counterPartyAccount = state.snapshotAccounts.find((acc) => acc.accountAddress.toLowerCase() === tx.counterParty.toLowerCase());
			if (counterPartyAccount) {
				if (!tx.counterPartyAccountId) tx.counterPartyAccountId = counterPartyAccount.id;
				const fromType = tx.direction === "OUTFLOW" ? account.type : counterPartyAccount.type;
				const toType = tx.direction === "OUTFLOW" ? counterPartyAccount.type : account.type;
				if (fromType === "Source") tx.flowType = "TopUp";
				else if (toType === "Source") tx.flowType = "Return";
				else if (toType === "Destination") tx.flowType = "TopUp";
				else if (fromType === "External") tx.flowType = "External";
				else if (fromType === "Internal" && toType === "Internal") tx.flowType = "Internal";
				else if (fromType === "Internal" && toType === "External") tx.flowType = "External";
				else tx.flowType = "External";
			}
		}
	}
};
//#endregion
//#region document-models/snapshot-report/v1/gen/schema/zod.ts
const isDefinedNonNullAny = (v) => v !== void 0 && v !== null;
const definedNonNullAnySchema = any().refine((v) => isDefinedNonNullAny(v));
const AccountTypeSchema = _enum([
	"Destination",
	"External",
	"Internal",
	"Source"
]);
const AccountTypeInputSchema = _enum([
	"Destination",
	"External",
	"Internal",
	"Source"
]);
const TransactionDirectionSchema = _enum(["INFLOW", "OUTFLOW"]);
const TransactionDirectionInputSchema = _enum(["INFLOW", "OUTFLOW"]);
const TransactionFlowTypeSchema = _enum([
	"External",
	"Internal",
	"Return",
	"Swap",
	"TopUp"
]);
const TransactionFlowTypeInputSchema = _enum([
	"External",
	"Internal",
	"Return",
	"Swap",
	"TopUp"
]);
function AddOwnerIdInputSchema() {
	return object({ ownerId: string() });
}
function AddSnapshotAccountInputSchema() {
	return object({
		accountAddress: string(),
		accountId: string(),
		accountName: string(),
		accountTransactionsId: string().nullish(),
		id: string(),
		type: AccountTypeInputSchema
	});
}
function AddTransactionInputSchema() {
	return object({
		accountId: string(),
		amount: object({
			unit: string(),
			value: string()
		}),
		blockNumber: number().nullish(),
		counterParty: string().regex(/^0x[a-fA-F0-9]{40}$/, { message: "Invalid Ethereum address format" }).nullish(),
		counterPartyAccountId: string().nullish(),
		datetime: datetime(),
		direction: TransactionDirectionInputSchema,
		flowType: TransactionFlowTypeInputSchema.nullish(),
		id: string(),
		token: string(),
		transactionId: string(),
		txHash: string()
	});
}
function RecalculateFlowTypesInputSchema() {
	return object({ _: string().nullish() });
}
function RemoveEndingBalanceInputSchema() {
	return object({
		accountId: string(),
		balanceId: string()
	});
}
function RemoveOwnerIdInputSchema() {
	return object({ ownerId: string() });
}
function RemoveSnapshotAccountInputSchema() {
	return object({ id: string() });
}
function RemoveStartingBalanceInputSchema() {
	return object({
		accountId: string(),
		balanceId: string()
	});
}
function RemoveTransactionInputSchema() {
	return object({ id: string() });
}
function SetAccountsDocumentInputSchema() {
	return object({ accountsDocumentId: string() });
}
function SetEndingBalanceInputSchema() {
	return object({
		accountId: string(),
		amount: object({
			unit: string(),
			value: string()
		}),
		balanceId: string(),
		token: string()
	});
}
function SetPeriodEndInputSchema() {
	return object({ periodEnd: datetime() });
}
function SetPeriodInputSchema() {
	return object({
		endDate: datetime(),
		startDate: datetime()
	});
}
function SetPeriodStartInputSchema() {
	return object({ periodStart: datetime() });
}
function SetReportConfigInputSchema() {
	return object({
		accountsDocumentId: string().nullish(),
		endDate: datetime().nullish(),
		reportName: string().nullish(),
		startDate: datetime().nullish()
	});
}
function SetStartingBalanceInputSchema() {
	return object({
		accountId: string(),
		amount: object({
			unit: string(),
			value: string()
		}),
		balanceId: string(),
		token: string()
	});
}
function SnapshotAccountSchema() {
	return object({
		__typename: literal("SnapshotAccount").optional(),
		accountAddress: string(),
		accountId: string(),
		accountName: string(),
		accountTransactionsId: string().nullish(),
		endingBalances: array(lazy(() => TokenBalanceSchema())),
		id: string(),
		startingBalances: array(lazy(() => TokenBalanceSchema())),
		transactions: array(lazy(() => SnapshotTransactionSchema())),
		type: AccountTypeSchema
	});
}
function SnapshotReportStateSchema() {
	return object({
		__typename: literal("SnapshotReportState").optional(),
		accountsDocumentId: string().nullish(),
		endDate: datetime().nullish(),
		ownerIds: array(string()),
		reportName: string().nullish(),
		reportPeriodEnd: datetime().nullish(),
		reportPeriodStart: datetime().nullish(),
		snapshotAccounts: array(lazy(() => SnapshotAccountSchema())),
		startDate: datetime().nullish()
	});
}
function SnapshotTransactionSchema() {
	return object({
		__typename: literal("SnapshotTransaction").optional(),
		amount: object({
			unit: string(),
			value: string()
		}),
		blockNumber: number().nullish(),
		counterParty: string().regex(/^0x[a-fA-F0-9]{40}$/, { message: "Invalid Ethereum address format" }).nullish(),
		counterPartyAccountId: string().nullish(),
		datetime: datetime(),
		direction: TransactionDirectionSchema,
		flowType: TransactionFlowTypeSchema.nullish(),
		id: string(),
		token: string(),
		transactionId: string(),
		txHash: string()
	});
}
function TokenBalanceSchema() {
	return object({
		__typename: literal("TokenBalance").optional(),
		amount: object({
			unit: string(),
			value: string()
		}),
		id: string(),
		token: string()
	});
}
function UpdateSnapshotAccountTypeInputSchema() {
	return object({
		id: string(),
		type: AccountTypeInputSchema
	});
}
function UpdateTransactionFlowTypeInputSchema() {
	return object({
		flowType: TransactionFlowTypeInputSchema,
		id: string()
	});
}
//#endregion
//#region document-models/snapshot-report/v1/gen/reducer.ts
const stateReducer = (state, action, dispatch) => {
	if (isDocumentAction(action)) return state;
	switch (action.type) {
		case "SET_REPORT_CONFIG":
			SetReportConfigInputSchema().parse(action.input);
			snapshotReportConfigurationOperations.setReportConfigOperation(state[action.scope], action, dispatch);
			break;
		case "SET_ACCOUNTS_DOCUMENT":
			SetAccountsDocumentInputSchema().parse(action.input);
			snapshotReportConfigurationOperations.setAccountsDocumentOperation(state[action.scope], action, dispatch);
			break;
		case "SET_PERIOD":
			SetPeriodInputSchema().parse(action.input);
			snapshotReportConfigurationOperations.setPeriodOperation(state[action.scope], action, dispatch);
			break;
		case "ADD_OWNER_ID":
			AddOwnerIdInputSchema().parse(action.input);
			snapshotReportConfigurationOperations.addOwnerIdOperation(state[action.scope], action, dispatch);
			break;
		case "SET_PERIOD_START":
			SetPeriodStartInputSchema().parse(action.input);
			snapshotReportConfigurationOperations.setPeriodStartOperation(state[action.scope], action, dispatch);
			break;
		case "SET_PERIOD_END":
			SetPeriodEndInputSchema().parse(action.input);
			snapshotReportConfigurationOperations.setPeriodEndOperation(state[action.scope], action, dispatch);
			break;
		case "REMOVE_OWNER_ID":
			RemoveOwnerIdInputSchema().parse(action.input);
			snapshotReportConfigurationOperations.removeOwnerIdOperation(state[action.scope], action, dispatch);
			break;
		case "ADD_SNAPSHOT_ACCOUNT":
			AddSnapshotAccountInputSchema().parse(action.input);
			snapshotReportAccountsOperations.addSnapshotAccountOperation(state[action.scope], action, dispatch);
			break;
		case "UPDATE_SNAPSHOT_ACCOUNT_TYPE":
			UpdateSnapshotAccountTypeInputSchema().parse(action.input);
			snapshotReportAccountsOperations.updateSnapshotAccountTypeOperation(state[action.scope], action, dispatch);
			break;
		case "REMOVE_SNAPSHOT_ACCOUNT":
			RemoveSnapshotAccountInputSchema().parse(action.input);
			snapshotReportAccountsOperations.removeSnapshotAccountOperation(state[action.scope], action, dispatch);
			break;
		case "SET_STARTING_BALANCE":
			SetStartingBalanceInputSchema().parse(action.input);
			snapshotReportBalancesOperations.setStartingBalanceOperation(state[action.scope], action, dispatch);
			break;
		case "SET_ENDING_BALANCE":
			SetEndingBalanceInputSchema().parse(action.input);
			snapshotReportBalancesOperations.setEndingBalanceOperation(state[action.scope], action, dispatch);
			break;
		case "REMOVE_STARTING_BALANCE":
			RemoveStartingBalanceInputSchema().parse(action.input);
			snapshotReportBalancesOperations.removeStartingBalanceOperation(state[action.scope], action, dispatch);
			break;
		case "REMOVE_ENDING_BALANCE":
			RemoveEndingBalanceInputSchema().parse(action.input);
			snapshotReportBalancesOperations.removeEndingBalanceOperation(state[action.scope], action, dispatch);
			break;
		case "ADD_TRANSACTION":
			AddTransactionInputSchema().parse(action.input);
			snapshotReportTransactionsOperations.addTransactionOperation(state[action.scope], action, dispatch);
			break;
		case "REMOVE_TRANSACTION":
			RemoveTransactionInputSchema().parse(action.input);
			snapshotReportTransactionsOperations.removeTransactionOperation(state[action.scope], action, dispatch);
			break;
		case "UPDATE_TRANSACTION_FLOW_TYPE":
			UpdateTransactionFlowTypeInputSchema().parse(action.input);
			snapshotReportTransactionsOperations.updateTransactionFlowTypeOperation(state[action.scope], action, dispatch);
			break;
		case "RECALCULATE_FLOW_TYPES":
			RecalculateFlowTypesInputSchema().parse(action.input);
			snapshotReportTransactionsOperations.recalculateFlowTypesOperation(state[action.scope], action, dispatch);
			break;
		default: return state;
	}
};
const reducer = createReducer(stateReducer);
//#endregion
//#region document-models/snapshot-report/v1/gen/configuration/creators.ts
var creators_exports$3 = /* @__PURE__ */ __exportAll({
	addOwnerId: () => addOwnerId,
	removeOwnerId: () => removeOwnerId,
	setAccountsDocument: () => setAccountsDocument,
	setPeriod: () => setPeriod,
	setPeriodEnd: () => setPeriodEnd,
	setPeriodStart: () => setPeriodStart,
	setReportConfig: () => setReportConfig
});
const setReportConfig = (input) => createAction("SET_REPORT_CONFIG", { ...input }, void 0, SetReportConfigInputSchema, "global");
const setAccountsDocument = (input) => createAction("SET_ACCOUNTS_DOCUMENT", { ...input }, void 0, SetAccountsDocumentInputSchema, "global");
const setPeriod = (input) => createAction("SET_PERIOD", { ...input }, void 0, SetPeriodInputSchema, "global");
const addOwnerId = (input) => createAction("ADD_OWNER_ID", { ...input }, void 0, AddOwnerIdInputSchema, "global");
const setPeriodStart = (input) => createAction("SET_PERIOD_START", { ...input }, void 0, SetPeriodStartInputSchema, "global");
const setPeriodEnd = (input) => createAction("SET_PERIOD_END", { ...input }, void 0, SetPeriodEndInputSchema, "global");
const removeOwnerId = (input) => createAction("REMOVE_OWNER_ID", { ...input }, void 0, RemoveOwnerIdInputSchema, "global");
//#endregion
//#region document-models/snapshot-report/v1/gen/accounts/creators.ts
var creators_exports$2 = /* @__PURE__ */ __exportAll({
	addSnapshotAccount: () => addSnapshotAccount,
	removeSnapshotAccount: () => removeSnapshotAccount,
	updateSnapshotAccountType: () => updateSnapshotAccountType
});
const addSnapshotAccount = (input) => createAction("ADD_SNAPSHOT_ACCOUNT", { ...input }, void 0, AddSnapshotAccountInputSchema, "global");
const updateSnapshotAccountType = (input) => createAction("UPDATE_SNAPSHOT_ACCOUNT_TYPE", { ...input }, void 0, UpdateSnapshotAccountTypeInputSchema, "global");
const removeSnapshotAccount = (input) => createAction("REMOVE_SNAPSHOT_ACCOUNT", { ...input }, void 0, RemoveSnapshotAccountInputSchema, "global");
//#endregion
//#region document-models/snapshot-report/v1/gen/balances/creators.ts
var creators_exports$1 = /* @__PURE__ */ __exportAll({
	removeEndingBalance: () => removeEndingBalance,
	removeStartingBalance: () => removeStartingBalance,
	setEndingBalance: () => setEndingBalance,
	setStartingBalance: () => setStartingBalance
});
const setStartingBalance = (input) => createAction("SET_STARTING_BALANCE", { ...input }, void 0, SetStartingBalanceInputSchema, "global");
const setEndingBalance = (input) => createAction("SET_ENDING_BALANCE", { ...input }, void 0, SetEndingBalanceInputSchema, "global");
const removeStartingBalance = (input) => createAction("REMOVE_STARTING_BALANCE", { ...input }, void 0, RemoveStartingBalanceInputSchema, "global");
const removeEndingBalance = (input) => createAction("REMOVE_ENDING_BALANCE", { ...input }, void 0, RemoveEndingBalanceInputSchema, "global");
//#endregion
//#region document-models/snapshot-report/v1/gen/transactions/creators.ts
var creators_exports = /* @__PURE__ */ __exportAll({
	addTransaction: () => addTransaction,
	recalculateFlowTypes: () => recalculateFlowTypes,
	removeTransaction: () => removeTransaction,
	updateTransactionFlowType: () => updateTransactionFlowType
});
const addTransaction = (input) => createAction("ADD_TRANSACTION", { ...input }, void 0, AddTransactionInputSchema, "global");
const removeTransaction = (input) => createAction("REMOVE_TRANSACTION", { ...input }, void 0, RemoveTransactionInputSchema, "global");
const updateTransactionFlowType = (input) => createAction("UPDATE_TRANSACTION_FLOW_TYPE", { ...input }, void 0, UpdateTransactionFlowTypeInputSchema, "global");
const recalculateFlowTypes = (input) => createAction("RECALCULATE_FLOW_TYPES", { ...input }, void 0, RecalculateFlowTypesInputSchema, "global");
//#endregion
//#region document-models/snapshot-report/v1/actions.ts
/** Actions for the SnapshotReport document model */
const actions = {
	...baseActions,
	...creators_exports$3,
	...creators_exports$2,
	...creators_exports$1,
	...creators_exports
};
//#endregion
//#region document-models/snapshot-report/v1/gen/document-type.ts
const snapshotReportDocumentType = "powerhouse/snapshot-report";
//#endregion
//#region document-models/snapshot-report/v1/gen/document-schema.ts
/** Schema for validating the header object of a SnapshotReport document */
const SnapshotReportDocumentHeaderSchema = BaseDocumentHeaderSchema.extend({ documentType: literal(snapshotReportDocumentType) });
/** Schema for validating the state object of a SnapshotReport document */
const SnapshotReportPHStateSchema = BaseDocumentStateSchema.extend({ global: SnapshotReportStateSchema() });
const SnapshotReportDocumentSchema = object({
	header: SnapshotReportDocumentHeaderSchema,
	state: SnapshotReportPHStateSchema,
	initialState: SnapshotReportPHStateSchema
});
/** Simple helper function to check if a state object is a SnapshotReport document state object */
function isSnapshotReportState(state) {
	return SnapshotReportPHStateSchema.safeParse(state).success;
}
/** Simple helper function to assert that a document state object is a SnapshotReport document state object */
function assertIsSnapshotReportState(state) {
	SnapshotReportPHStateSchema.parse(state);
}
/** Simple helper function to check if a document is a SnapshotReport document */
function isSnapshotReportDocument(document) {
	return SnapshotReportDocumentSchema.safeParse(document).success;
}
/** Simple helper function to assert that a document is a SnapshotReport document */
function assertIsSnapshotReportDocument(document) {
	SnapshotReportDocumentSchema.parse(document);
}
//#endregion
//#region document-models/snapshot-report/v1/gen/utils.ts
const initialGlobalState = {
	ownerIds: [],
	accountsDocumentId: null,
	startDate: null,
	endDate: null,
	reportName: null,
	reportPeriodStart: null,
	reportPeriodEnd: null,
	snapshotAccounts: []
};
const initialLocalState = {};
const utils$1 = {
	fileExtension: "",
	createState(state) {
		return {
			...defaultBaseState(),
			global: {
				...initialGlobalState,
				...state?.global
			},
			local: {
				...initialLocalState,
				...state?.local
			}
		};
	},
	createDocument(state) {
		const document = baseCreateDocument(utils$1.createState, state);
		document.header.documentType = snapshotReportDocumentType;
		document.header.id = generateId();
		return document;
	},
	saveToFileHandle(document, input) {
		return baseSaveToFileHandle(document, input);
	},
	loadFromInput(input) {
		return baseLoadFromInput(input, reducer);
	},
	isStateOfType(state) {
		return isSnapshotReportState(state);
	},
	assertIsStateOfType(state) {
		return assertIsSnapshotReportState(state);
	},
	isDocumentOfType(document) {
		return isSnapshotReportDocument(document);
	},
	assertIsDocumentOfType(document) {
		return assertIsSnapshotReportDocument(document);
	}
};
//#endregion
//#region document-models/snapshot-report/v1/src/utils.ts
var utils_exports = /* @__PURE__ */ __exportAll({});
//#endregion
//#region document-models/snapshot-report/v1/utils.ts
/** Utils for the SnapshotReport document model */
const utils = {
	...utils$1,
	...utils_exports
};
//#endregion
//#region document-models/snapshot-report/v1/module.ts
/** Document model module for the SnapshotReport document type */
const SnapshotReport = {
	version: 1,
	reducer,
	actions,
	utils,
	documentModel: createState(defaultBaseState(), documentModel)
};
//#endregion
export { SetPeriodStartInputSchema as $, creators_exports$3 as A, AddOwnerIdInputSchema as B, setEndingBalance as C, removeSnapshotAccount as D, creators_exports$2 as E, setPeriodStart as F, RemoveOwnerIdInputSchema as G, AddTransactionInputSchema as H, setReportConfig as I, RemoveTransactionInputSchema as J, RemoveSnapshotAccountInputSchema as K, reducer as L, setAccountsDocument as M, setPeriod as N, updateSnapshotAccountType as O, setPeriodEnd as P, SetPeriodInputSchema as Q, AccountTypeInputSchema as R, removeStartingBalance as S, addSnapshotAccount as T, RecalculateFlowTypesInputSchema as U, AddSnapshotAccountInputSchema as V, RemoveEndingBalanceInputSchema as W, SetEndingBalanceInputSchema as X, SetAccountsDocumentInputSchema as Y, SetPeriodEndInputSchema as Z, recalculateFlowTypes as _, utils$1 as a, TokenBalanceSchema as at, creators_exports$1 as b, SnapshotReportPHStateSchema as c, TransactionFlowTypeInputSchema as ct, isSnapshotReportDocument as d, UpdateTransactionFlowTypeInputSchema as dt, SetReportConfigInputSchema as et, isSnapshotReportState as f, definedNonNullAnySchema as ft, creators_exports as g, addTransaction as h, initialLocalState as i, SnapshotTransactionSchema as it, removeOwnerId as j, addOwnerId as k, assertIsSnapshotReportDocument as l, TransactionFlowTypeSchema as lt, actions as m, documentModel as mt, utils as n, SnapshotAccountSchema as nt, SnapshotReportDocumentHeaderSchema as o, TransactionDirectionInputSchema as ot, snapshotReportDocumentType as p, isDefinedNonNullAny as pt, RemoveStartingBalanceInputSchema as q, initialGlobalState as r, SnapshotReportStateSchema as rt, SnapshotReportDocumentSchema as s, TransactionDirectionSchema as st, SnapshotReport as t, SetStartingBalanceInputSchema as tt, assertIsSnapshotReportState as u, UpdateSnapshotAccountTypeInputSchema as ut, removeTransaction as v, setStartingBalance as w, removeEndingBalance as x, updateTransactionFlowType as y, AccountTypeSchema as z };

//# sourceMappingURL=module-CIT3HO-c.js.map