@happyvertical/smrt-ledgers 0.57.2 → 0.57.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +9 -0
- package/README.md +73 -0
- package/dist/chunks/{Account-b0RgfbjM.js → Account-IFuMKhPt.js} +42 -8
- package/dist/chunks/Account-IFuMKhPt.js.map +1 -0
- package/dist/chunks/Ledger-DwxK6NRF.js +68 -0
- package/dist/chunks/Ledger-DwxK6NRF.js.map +1 -0
- package/dist/collections/JournalEntries.d.ts +26 -0
- package/dist/collections/JournalEntries.d.ts.map +1 -1
- package/dist/collections/Journals.d.ts.map +1 -1
- package/dist/collections/Ledgers.d.ts +6 -0
- package/dist/collections/Ledgers.d.ts.map +1 -0
- package/dist/collections/index.d.ts +1 -0
- package/dist/collections/index.d.ts.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +380 -17
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +639 -13
- package/dist/models/Account.d.ts +4 -0
- package/dist/models/Account.d.ts.map +1 -1
- package/dist/models/Journal.d.ts +9 -0
- package/dist/models/Journal.d.ts.map +1 -1
- package/dist/models/JournalEntry.d.ts +10 -0
- package/dist/models/JournalEntry.d.ts.map +1 -1
- package/dist/models/Ledger.d.ts +18 -0
- package/dist/models/Ledger.d.ts.map +1 -0
- package/dist/models/index.d.ts +1 -0
- package/dist/models/index.d.ts.map +1 -1
- package/dist/postings.d.ts +33 -0
- package/dist/postings.d.ts.map +1 -0
- package/dist/recipes.d.ts +9 -0
- package/dist/recipes.d.ts.map +1 -1
- package/dist/smrt-knowledge.json +475 -9
- package/dist/types.d.ts +23 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +5 -5
- package/dist/chunks/Account-b0RgfbjM.js.map +0 -1
package/dist/types.d.ts
CHANGED
|
@@ -15,6 +15,13 @@ export type AccountType = 'asset' | 'liability' | 'equity' | 'revenue' | 'expens
|
|
|
15
15
|
* Journal status lifecycle
|
|
16
16
|
*/
|
|
17
17
|
export type JournalStatus = 'draft' | 'posted' | 'voided';
|
|
18
|
+
export type LedgerBalanceMode = 'tolerant' | 'exact-integer';
|
|
19
|
+
export interface LedgerOptions extends SmrtClassOptions {
|
|
20
|
+
tenantId?: string | null;
|
|
21
|
+
name?: string;
|
|
22
|
+
currency?: string;
|
|
23
|
+
balanceMode?: LedgerBalanceMode;
|
|
24
|
+
}
|
|
18
25
|
/**
|
|
19
26
|
* Options for creating an Account
|
|
20
27
|
*/
|
|
@@ -25,6 +32,7 @@ export interface AccountOptions extends SmrtClassOptions {
|
|
|
25
32
|
description?: string;
|
|
26
33
|
type?: AccountType;
|
|
27
34
|
parentId?: string | null;
|
|
35
|
+
ledgerId?: string | null;
|
|
28
36
|
active?: boolean;
|
|
29
37
|
metadata?: Record<string, unknown>;
|
|
30
38
|
}
|
|
@@ -38,6 +46,9 @@ export interface JournalOptions extends SmrtClassOptions {
|
|
|
38
46
|
description?: string;
|
|
39
47
|
sourceModule?: string;
|
|
40
48
|
sourceRef?: string | null;
|
|
49
|
+
ledgerId?: string | null;
|
|
50
|
+
idempotencyKey?: string | null;
|
|
51
|
+
requestDigest?: string | null;
|
|
41
52
|
status?: JournalStatus;
|
|
42
53
|
postedAt?: Date | null;
|
|
43
54
|
voidedAt?: Date | null;
|
|
@@ -51,6 +62,10 @@ export interface JournalEntryOptions extends SmrtClassOptions {
|
|
|
51
62
|
tenantId?: string | null;
|
|
52
63
|
journalId?: string;
|
|
53
64
|
accountId?: string;
|
|
65
|
+
counterpartyKind?: string | null;
|
|
66
|
+
counterpartyId?: string | null;
|
|
67
|
+
dueDate?: Date | null;
|
|
68
|
+
settlesSourceRef?: string | null;
|
|
54
69
|
debit?: number;
|
|
55
70
|
credit?: number;
|
|
56
71
|
currency?: string;
|
|
@@ -87,6 +102,10 @@ export interface AccountTree {
|
|
|
87
102
|
*/
|
|
88
103
|
export interface JournalEntryData {
|
|
89
104
|
accountId: string;
|
|
105
|
+
counterpartyKind?: string | null;
|
|
106
|
+
counterpartyId?: string | null;
|
|
107
|
+
dueDate?: Date | null;
|
|
108
|
+
settlesSourceRef?: string | null;
|
|
90
109
|
debit?: number;
|
|
91
110
|
credit?: number;
|
|
92
111
|
currency?: string;
|
|
@@ -97,10 +116,14 @@ export interface JournalEntryData {
|
|
|
97
116
|
* Data for creating a complete journal with entries
|
|
98
117
|
*/
|
|
99
118
|
export interface CreateJournalData {
|
|
119
|
+
tenantId?: string | null;
|
|
100
120
|
date?: Date;
|
|
101
121
|
description: string;
|
|
102
122
|
sourceModule?: string;
|
|
103
123
|
sourceRef?: string | null;
|
|
124
|
+
ledgerId?: string | null;
|
|
125
|
+
idempotencyKey?: string | null;
|
|
126
|
+
requestDigest?: string | null;
|
|
104
127
|
entries: JournalEntryData[];
|
|
105
128
|
metadata?: Record<string, unknown>;
|
|
106
129
|
}
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEjE;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAQ,CAAC;AAErC;;GAEG;AACH,MAAM,MAAM,WAAW,GACnB,OAAO,GACP,WAAW,GACX,QAAQ,GACR,SAAS,GACT,SAAS,CAAC;AAEd;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,gBAAgB;IACtD,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,E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EG;AACH,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,eAAe,EAAE,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,OAAO,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["/**\n * Type definitions for smrt-ledgers\n */\n\nimport type { SmrtClassOptions } from '@happyvertical/smrt-core';\n\n/**\n * Epsilon value for floating-point balance comparisons.\n * Used to determine if debits and credits are balanced.\n */\nexport const BALANCE_EPSILON = 0.001;\n\n/**\n * The five core account types in double-entry accounting\n */\nexport type AccountType =\n | 'asset'\n | 'liability'\n | 'equity'\n | 'revenue'\n | 'expense';\n\n/**\n * Journal status lifecycle\n */\nexport type JournalStatus = 'draft' | 'posted' | 'voided';\n\n/**\n * Options for creating an Account\n */\nexport interface AccountOptions extends SmrtClassOptions {\n tenantId?: string | null;\n number?: string;\n name?: string;\n description?: string;\n type?: AccountType;\n parentId?: string | null;\n active?: boolean;\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Options for creating a Journal\n */\nexport interface JournalOptions extends SmrtClassOptions {\n tenantId?: string | null;\n number?: string;\n date?: Date;\n description?: string;\n sourceModule?: string;\n sourceRef?: string | null;\n status?: JournalStatus;\n postedAt?: Date | null;\n voidedAt?: Date | null;\n voidReason?: string | null;\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Options for creating a JournalEntry\n */\nexport interface JournalEntryOptions extends SmrtClassOptions {\n tenantId?: string | null;\n journalId?: string;\n accountId?: string;\n debit?: number;\n credit?: number;\n currency?: string;\n exchangeRate?: number;\n memo?: string;\n metadata?: Record<string, unknown>;\n}\n\n/**\n * A row in the trial balance report\n */\nexport interface TrialBalanceRow {\n accountId: string;\n accountNumber: string;\n accountName: string;\n accountType: AccountType;\n debitBalance: number;\n creditBalance: number;\n}\n\n/**\n * Account tree node for hierarchical display\n */\nexport interface AccountTreeNode {\n account: import('./models/Account').Account;\n children: AccountTreeNode[];\n}\n\n/**\n * Account tree structure\n */\nexport interface AccountTree {\n roots: AccountTreeNode[];\n}\n\n/**\n * Entry data for creating journal entries\n */\nexport interface JournalEntryData {\n accountId: string;\n debit?: number;\n credit?: number;\n currency?: string;\n exchangeRate?: number;\n memo?: string;\n}\n\n/**\n * Data for creating a complete journal with entries\n */\nexport interface CreateJournalData {\n date?: Date;\n description: string;\n sourceModule?: string;\n sourceRef?: string | null;\n entries: JournalEntryData[];\n metadata?: Record<string, unknown>;\n}\n"],"mappings":";AAUO,IAAM,kBAAkB"}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["/**\n * Type definitions for smrt-ledgers\n */\n\nimport type { SmrtClassOptions } from '@happyvertical/smrt-core';\n\n/**\n * Epsilon value for floating-point balance comparisons.\n * Used to determine if debits and credits are balanced.\n */\nexport const BALANCE_EPSILON = 0.001;\n\n/**\n * The five core account types in double-entry accounting\n */\nexport type AccountType =\n | 'asset'\n | 'liability'\n | 'equity'\n | 'revenue'\n | 'expense';\n\n/**\n * Journal status lifecycle\n */\nexport type JournalStatus = 'draft' | 'posted' | 'voided';\n\nexport type LedgerBalanceMode = 'tolerant' | 'exact-integer';\n\nexport interface LedgerOptions extends SmrtClassOptions {\n tenantId?: string | null;\n name?: string;\n currency?: string;\n balanceMode?: LedgerBalanceMode;\n}\n\n/**\n * Options for creating an Account\n */\nexport interface AccountOptions extends SmrtClassOptions {\n tenantId?: string | null;\n number?: string;\n name?: string;\n description?: string;\n type?: AccountType;\n parentId?: string | null;\n ledgerId?: string | null;\n active?: boolean;\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Options for creating a Journal\n */\nexport interface JournalOptions extends SmrtClassOptions {\n tenantId?: string | null;\n number?: string;\n date?: Date;\n description?: string;\n sourceModule?: string;\n sourceRef?: string | null;\n ledgerId?: string | null;\n idempotencyKey?: string | null;\n requestDigest?: string | null;\n status?: JournalStatus;\n postedAt?: Date | null;\n voidedAt?: Date | null;\n voidReason?: string | null;\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Options for creating a JournalEntry\n */\nexport interface JournalEntryOptions extends SmrtClassOptions {\n tenantId?: string | null;\n journalId?: string;\n accountId?: string;\n counterpartyKind?: string | null;\n counterpartyId?: string | null;\n dueDate?: Date | null;\n settlesSourceRef?: string | null;\n debit?: number;\n credit?: number;\n currency?: string;\n exchangeRate?: number;\n memo?: string;\n metadata?: Record<string, unknown>;\n}\n\n/**\n * A row in the trial balance report\n */\nexport interface TrialBalanceRow {\n accountId: string;\n accountNumber: string;\n accountName: string;\n accountType: AccountType;\n debitBalance: number;\n creditBalance: number;\n}\n\n/**\n * Account tree node for hierarchical display\n */\nexport interface AccountTreeNode {\n account: import('./models/Account').Account;\n children: AccountTreeNode[];\n}\n\n/**\n * Account tree structure\n */\nexport interface AccountTree {\n roots: AccountTreeNode[];\n}\n\n/**\n * Entry data for creating journal entries\n */\nexport interface JournalEntryData {\n accountId: string;\n counterpartyKind?: string | null;\n counterpartyId?: string | null;\n dueDate?: Date | null;\n settlesSourceRef?: string | null;\n debit?: number;\n credit?: number;\n currency?: string;\n exchangeRate?: number;\n memo?: string;\n}\n\n/**\n * Data for creating a complete journal with entries\n */\nexport interface CreateJournalData {\n tenantId?: string | null;\n date?: Date;\n description: string;\n sourceModule?: string;\n sourceRef?: string | null;\n ledgerId?: string | null;\n idempotencyKey?: string | null;\n requestDigest?: string | null;\n entries: JournalEntryData[];\n metadata?: Record<string, unknown>;\n}\n"],"mappings":";AAUO,IAAM,kBAAkB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@happyvertical/smrt-ledgers",
|
|
3
|
-
"version": "0.57.
|
|
3
|
+
"version": "0.57.3",
|
|
4
4
|
"description": "Double-entry accounting ledger for the SMRT framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@happyvertical/smrt-core": "0.57.
|
|
42
|
-
"@happyvertical/smrt-prompts": "0.57.
|
|
43
|
-
"@happyvertical/smrt-tenancy": "0.57.
|
|
41
|
+
"@happyvertical/smrt-core": "0.57.3",
|
|
42
|
+
"@happyvertical/smrt-prompts": "0.57.3",
|
|
43
|
+
"@happyvertical/smrt-tenancy": "0.57.3"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@happyvertical/smrt-vitest": "0.57.
|
|
46
|
+
"@happyvertical/smrt-vitest": "0.57.3",
|
|
47
47
|
"@types/node": "24.13.6",
|
|
48
48
|
"fast-glob": "^3.3.3",
|
|
49
49
|
"typescript": "6.0.3",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Account-b0RgfbjM.js","names":[],"sources":["../../src/models/Account.ts"],"sourcesContent":["/**\n * Account model - Chart of accounts entry\n *\n * Represents a single account in the chart of accounts.\n * The 5 core types: Asset, Liability, Equity, Revenue, Expense\n */\n\nimport { field, SmrtHierarchical, smrt } from '@happyvertical/smrt-core';\nimport { TenantScoped, tenantId } from '@happyvertical/smrt-tenancy';\nimport type { AccountOptions, AccountTreeNode, AccountType } from '../types';\n\n@TenantScoped({ mode: 'optional' })\n@smrt({\n // Own table, never the derived `accounts`: smrt-messages declares an\n // unrelated `Account` on that table (#3098). Existing `accounts`-hosted\n // ledgers move with `smrt db:migrate-ledger-accounts`.\n tableName: 'ledger_accounts',\n api: { include: ['list', 'get', 'create', 'update', 'delete'] },\n mcp: { include: ['list', 'get', 'create'] },\n cli: { skipApiCheck: true },\n})\nexport class Account extends SmrtHierarchical { static __smrtPackage__ = \"@happyvertical/smrt-ledgers\";\n /**\n * Tenant ID for multi-tenancy support (nullable for global accounts)\n */\n @tenantId({ nullable: true })\n tenantId: string | null = null;\n\n /**\n * Account number (e.g., \"1000\", \"5030\")\n */\n @field({ description: 'The account number in your chart of accounts.' })\n number: string = '';\n\n /**\n * Account name (e.g., \"Cash\", \"Coffee Expense\")\n */\n @field({ description: 'What the account is called.' })\n name: string = '';\n\n /**\n * Account description\n */\n @field({ description: 'What the account is used for.' })\n description: string = '';\n\n /**\n * Account type - one of the 5 core types\n */\n @field({ description: 'asset, liability, equity, revenue or expense.' })\n type: AccountType = 'asset';\n\n // parentId inherited from SmrtHierarchical (null = top-level)\n\n /**\n * Whether the account is active\n */\n @field({\n description:\n 'Whether the account is in use; deactivate it instead of deleting it.',\n })\n active: boolean = true;\n\n /**\n * Extensible metadata\n */\n metadata: Record<string, unknown> = {};\n\n constructor(options: AccountOptions = {}) {\n super(options);\n if (options.number !== undefined) this.number = options.number;\n if (options.name !== undefined) this.name = options.name;\n if (options.description !== undefined)\n this.description = options.description;\n if (options.type !== undefined) this.type = options.type;\n if (options.parentId !== undefined) this.parentId = options.parentId;\n if (options.active !== undefined) this.active = options.active;\n if (options.metadata !== undefined) this.metadata = options.metadata;\n }\n\n /**\n * Check if this is a top-level account (no parent)\n */\n isTopLevel(): boolean {\n return this.parentId === null;\n }\n\n /**\n * Check if this is a debit-normal account (Asset, Expense)\n * Debit-normal accounts increase with debits\n */\n isDebitNormal(): boolean {\n return this.type === 'asset' || this.type === 'expense';\n }\n\n /**\n * Check if this is a credit-normal account (Liability, Equity, Revenue)\n * Credit-normal accounts increase with credits\n */\n isCreditNormal(): boolean {\n return (\n this.type === 'liability' ||\n this.type === 'equity' ||\n this.type === 'revenue'\n );\n }\n\n // Hierarchy traversal (getParent / getChildren / getAncestors /\n // getDescendants / getHierarchy / moveTo) provided by SmrtHierarchical.\n // Account-specific helpers (getFullPath / getBalance / createChild /\n // toTreeNode) remain below.\n\n /**\n * Get full account path (e.g., \"Assets > Current > Cash\")\n */\n async getFullPath(): Promise<string> {\n const ancestors = await this.getAncestors();\n const names = [...ancestors.map((a) => a.name), this.name];\n return names.join(' > ');\n }\n\n /**\n * Build tree node for this account and its children\n */\n async toTreeNode(): Promise<AccountTreeNode> {\n const children = await this.getChildren();\n const childNodes = await Promise.all(children.map((c) => c.toTreeNode()));\n return {\n account: this,\n children: childNodes,\n };\n }\n\n /**\n * Get the current balance of this account\n */\n async getBalance(asOfDate?: Date): Promise<number> {\n if (!this.id) return 0;\n const { JournalEntryCollection } = await import(\n '../collections/JournalEntries'\n );\n const collection = await JournalEntryCollection.create(this.options);\n return await collection.getAccountBalance(this.id, asOfDate);\n }\n\n /**\n * Create a sub-account under this account\n */\n async createChild(\n options: Omit<AccountOptions, 'parentId' | 'type'>,\n ): Promise<Account> {\n if (!this.id) {\n throw new Error('Account must be saved before creating children');\n }\n const { AccountCollection } = await import('../collections/Accounts');\n const collection = await AccountCollection.create(this.options);\n const account = await collection.create({\n ...options,\n parentId: this.id,\n type: this.type, // Inherit type from parent\n });\n await account.save();\n return account;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAqBO,IAAM,UAAN,cAAsB,iBAAiB;CAK5C,WAA0B;CAM1B,SAAiB;CAMjB,OAAe;CAMf,cAAsB;CAMtB,OAAoB;CAWpB,SAAkB;;;;CAKlB,WAAoC,CAAC;CAErC,YAAY,UAA0B,CAAC,GAAG;EACxC,MAAM,OAAO;EACb,IAAI,QAAQ,WAAW,KAAA,GAAW,KAAK,SAAS,QAAQ;EACxD,IAAI,QAAQ,SAAS,KAAA,GAAW,KAAK,OAAO,QAAQ;EACpD,IAAI,QAAQ,gBAAgB,KAAA,GAC1B,KAAK,cAAc,QAAQ;EAC7B,IAAI,QAAQ,SAAS,KAAA,GAAW,KAAK,OAAO,QAAQ;EACpD,IAAI,QAAQ,aAAa,KAAA,GAAW,KAAK,WAAW,QAAQ;EAC5D,IAAI,QAAQ,WAAW,KAAA,GAAW,KAAK,SAAS,QAAQ;EACxD,IAAI,QAAQ,aAAa,KAAA,GAAW,KAAK,WAAW,QAAQ;CAC9D;;;;CAKA,aAAsB;EACpB,OAAO,KAAK,aAAa;CAC3B;;;;;CAMA,gBAAyB;EACvB,OAAO,KAAK,SAAS,WAAW,KAAK,SAAS;CAChD;;;;;CAMA,iBAA0B;EACxB,OACE,KAAK,SAAS,eACd,KAAK,SAAS,YACd,KAAK,SAAS;CAElB;;;;CAUA,MAAM,cAA+B;EAGnC,OAAO,CADQ,IAAG,MADM,KAAK,aAAa,EAAA,CACd,KAAK,MAAM,EAAE,IAAI,GAAG,KAAK,IAC9C,CAAA,CAAM,KAAK,KAAK;CACzB;;;;CAKA,MAAM,aAAuC;EAC3C,M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