@agentshouse/mdruntime 0.1.0-alpha.25 → 0.1.0-alpha.26
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 +25 -4
- package/dist/client.d.ts +2 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +3 -0
- package/dist/client.js.map +1 -1
- package/dist/connection.d.ts +2 -0
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +19 -3
- package/dist/connection.js.map +1 -1
- package/dist/conversation.d.ts +3 -0
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +17 -0
- package/dist/conversation.js.map +1 -1
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +2 -0
- package/dist/host.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/query.d.ts +7 -0
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +23 -10
- package/dist/query.js.map +1 -1
- package/dist/read-side.d.ts +3 -0
- package/dist/read-side.d.ts.map +1 -1
- package/dist/read-side.js +19 -0
- package/dist/read-side.js.map +1 -1
- package/dist/search.d.ts +61 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +155 -0
- package/dist/search.js.map +1 -0
- package/dist/wire.d.ts +2 -2
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +2 -1
- package/dist/wire.js.map +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/workspace/packages/mdruntime/src/search.ts"],"sourcesContent":["import MiniSearch from 'minisearch';\nimport type { ChangeSet } from './change-set.js';\nimport { invalid, known, limitOf, plain, type Filter } from './query.js';\n\nexport type DocumentPart = 'fields' | 'sections' | 'preamble' | 'path';\n\nexport type SearchRequest = {\n text: string;\n documents?: Filter;\n conversations?: readonly string[];\n limit?: number;\n};\n\nexport type DocumentHit = {\n room: string;\n path: string;\n type: string;\n score: number;\n matches: Readonly<Record<string, readonly DocumentPart[]>>;\n};\n\nexport type MessageHit = {\n conversation: string;\n identity: string;\n score: number;\n matches: Readonly<Record<string, readonly 'text'[]>>;\n};\n\nexport type SearchResult = {\n documents: readonly DocumentHit[];\n messages: readonly MessageHit[];\n};\n\nexport type SearchedDocument = {\n room: string;\n path: string;\n type: string;\n fields: Readonly<Record<string, unknown>>;\n preamble: string;\n sections: Readonly<Record<string, string>>;\n};\n\nexport type SearchedMessage = { conversation: string; identity: string; text: string };\n\nexport type SearchSource = {\n documents(): readonly SearchedDocument[];\n document(room: string, path: string): SearchedDocument | null;\n messages(): readonly SearchedMessage[];\n message(conversation: string, identity: string): SearchedMessage | null;\n};\n\nexport type SearchPlan = {\n text: string;\n documents: unknown;\n conversations: readonly string[] | null;\n limit: number | null;\n};\n\nexport type SearchIndex = {\n changed(set: ChangeSet): void;\n search(\n plan: SearchPlan,\n documents: readonly { room: string; path: string }[] | null,\n ): SearchResult;\n};\n\ntype Indexed = {\n id: string;\n fields?: string;\n sections?: string;\n preamble?: string;\n path?: string;\n text?: string;\n};\n\nconst FIELDS = ['fields', 'sections', 'preamble', 'path', 'text'];\n\nfunction documentId(room: string, path: string): string {\n return JSON.stringify(['document', room, path]);\n}\n\nfunction messageId(conversation: string, identity: string): string {\n return JSON.stringify(['message', conversation, identity]);\n}\n\nfunction scalars(value: unknown): readonly string[] {\n if (value === null || value === undefined) return [];\n if (Array.isArray(value)) return value.flatMap(scalars);\n if (typeof value === 'object') return Object.values(value).flatMap(scalars);\n return [String(value)];\n}\n\nexport function searchPlanOf(input: unknown): SearchPlan {\n if (!plain(input)) invalid('search', 'expects a search object');\n known(input, ['text', 'documents', 'conversations', 'limit'], '');\n if (typeof input.text !== 'string') invalid('text', 'expects text');\n const conversations = input.conversations;\n if (\n conversations !== undefined &&\n (!Array.isArray(conversations) || conversations.some((named) => typeof named !== 'string'))\n ) {\n invalid('conversations', 'expects a list of conversations');\n }\n return {\n text: input.text,\n documents: input.documents,\n conversations: (conversations as readonly string[] | undefined) ?? null,\n limit: limitOf(input.limit),\n };\n}\n\ntype DocumentEntry = { room: string; path: string; type: string };\n\ntype MessageEntry = { conversation: string; identity: string };\n\nexport function createSearchIndex(source: SearchSource): SearchIndex {\n let index: MiniSearch<Indexed> | null = null;\n const documents = new Map<string, DocumentEntry>();\n const messages = new Map<string, MessageEntry>();\n const changedDocuments = new Map<string, { room: string; path: string }>();\n const changedMessages = new Map<string, MessageEntry>();\n\n function addDocument(built: MiniSearch<Indexed>, document: SearchedDocument) {\n const id = documentId(document.room, document.path);\n documents.set(id, { room: document.room, path: document.path, type: document.type });\n built.add({\n id,\n fields: scalars(document.fields).join('\\n'),\n sections: Object.entries(document.sections)\n .map(([heading, text]) => `${heading}\\n${text}`)\n .join('\\n'),\n preamble: document.preamble,\n path: document.path,\n });\n }\n\n function addMessage(built: MiniSearch<Indexed>, message: SearchedMessage) {\n const id = messageId(message.conversation, message.identity);\n messages.set(id, { conversation: message.conversation, identity: message.identity });\n built.add({ id, text: message.text });\n }\n\n function current(): MiniSearch<Indexed> {\n if (index === null) {\n const built = new MiniSearch<Indexed>({ fields: FIELDS });\n for (const document of source.documents()) addDocument(built, document);\n for (const message of source.messages()) addMessage(built, message);\n index = built;\n return built;\n }\n const built = index;\n for (const [id, { room, path }] of changedDocuments) {\n if (documents.delete(id)) built.discard(id);\n const document = source.document(room, path);\n if (document !== null) addDocument(built, document);\n }\n changedDocuments.clear();\n for (const [id, { conversation, identity }] of changedMessages) {\n if (messages.delete(id)) built.discard(id);\n const message = source.message(conversation, identity);\n if (message !== null) addMessage(built, message);\n }\n changedMessages.clear();\n return built;\n }\n\n function ranked<Entry>(\n built: MiniSearch<Indexed>,\n text: string,\n entries: ReadonlyMap<string, Entry>,\n keep: (entry: Entry, id: string) => boolean,\n limit: number | null,\n ) {\n const found = built.search(text, {\n filter: ({ id }) => {\n const entry = entries.get(id);\n return entry !== undefined && keep(entry, id);\n },\n });\n return (limit === null ? found : found.slice(0, limit)).map(({ id, score, match }) => ({\n ...(entries.get(id) as Entry),\n score,\n match,\n }));\n }\n\n return {\n changed(set) {\n if (index === null) return;\n for (const { locator, path } of set.documents) {\n changedDocuments.set(documentId(locator, path), { room: locator, path });\n }\n for (const { conversation, identity } of set.messages) {\n changedMessages.set(messageId(conversation, identity), { conversation, identity });\n }\n },\n search({ text, conversations, limit }, selected) {\n const built = current();\n const chosen =\n selected === null\n ? null\n : new Set(selected.map(({ room, path }) => documentId(room, path)));\n return {\n documents: ranked(\n built,\n text,\n documents,\n (_entry, id) => chosen === null || chosen.has(id),\n limit,\n ).map(({ match, ...hit }) => ({ ...hit, matches: match as DocumentHit['matches'] })),\n messages: ranked(\n built,\n text,\n messages,\n ({ conversation }) => conversations === null || conversations.includes(conversation),\n limit,\n ).map(({ match, ...hit }) => ({ ...hit, matches: match as MessageHit['matches'] })),\n };\n },\n };\n}\n"],"names":["MiniSearch","invalid","known","limitOf","plain","FIELDS","documentId","room","path","JSON","stringify","messageId","conversation","identity","scalars","value","undefined","Array","isArray","flatMap","Object","values","String","searchPlanOf","input","text","conversations","some","named","documents","limit","createSearchIndex","source","index","Map","messages","changedDocuments","changedMessages","addDocument","built","document","id","set","type","add","fields","join","sections","entries","map","heading","preamble","addMessage","message","current","delete","discard","clear","ranked","keep","found","search","filter","entry","get","slice","score","match","changed","locator","selected","chosen","Set","_entry","has","hit","matches","includes"],"mappings":"AAAA,OAAOA,gBAAgB,aAAa;AAEpC,SAASC,OAAO,EAAEC,KAAK,EAAEC,OAAO,EAAEC,KAAK,QAAqB,aAAa;AAyEzE,MAAMC,SAAS;IAAC;IAAU;IAAY;IAAY;IAAQ;CAAO;AAEjE,SAASC,WAAWC,IAAY,EAAEC,IAAY;IAC5C,OAAOC,KAAKC,SAAS,CAAC;QAAC;QAAYH;QAAMC;KAAK;AAChD;AAEA,SAASG,UAAUC,YAAoB,EAAEC,QAAgB;IACvD,OAAOJ,KAAKC,SAAS,CAAC;QAAC;QAAWE;QAAcC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;YACd,MAAMiB,SACJD,aAAa,OACT,OACA,IAAIE,IAAIF,SAASrB,GAAG,CAAC,CAAC,EAAE1C,IAAI,EAAEC,IAAI,EAAE,GAAKF,WAAWC,MAAMC;YAChE,OAAO;gBACLqB,WAAW6B,OACTnB,OACAd,MACAI,WACA,CAAC4C,QAAQhC,KAAO8B,WAAW,QAAQA,OAAOG,GAAG,CAACjC,KAC9CX,OACAmB,GAAG,CAAC,CAAC,EAAEkB,KAAK,EAAE,GAAGQ,KAAK,GAAM,CAAA;wBAAE,GAAGA,GAAG;wBAAEC,SAAST;oBAAgC,CAAA;gBACjFhC,UAAUuB,OACRnB,OACAd,MACAU,UACA,CAAC,EAAEvB,YAAY,EAAE,GAAKc,kBAAkB,QAAQA,cAAcmD,QAAQ,CAACjE,eACvEkB,OACAmB,GAAG,CAAC,CAAC,EAAEkB,KAAK,EAAE,GAAGQ,KAAK,GAAM,CAAA;wBAAE,GAAGA,GAAG;wBAAEC,SAAST;oBAA+B,CAAA;YAClF;QACF;IACF;AACF"}
|
package/dist/wire.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ConnectionRefusal } from './connection.js';
|
|
2
|
-
export declare const RUNTIME_WIRE_PROTOCOL =
|
|
2
|
+
export declare const RUNTIME_WIRE_PROTOCOL = 6;
|
|
3
3
|
export declare const PROTOCOL_MISMATCH: ConnectionRefusal;
|
|
4
4
|
export type RuntimePort = {
|
|
5
5
|
postMessage(message: unknown): void;
|
|
@@ -8,7 +8,7 @@ export type RuntimePort = {
|
|
|
8
8
|
}) => void): void;
|
|
9
9
|
start(): void;
|
|
10
10
|
};
|
|
11
|
-
declare const MEMBERS: readonly ['rooms', 'slots', 'query', 'types', 'syncStatus', 'save', 'outcome', 'history', 'call', 'log', 'storageLoss', 'persistence', 'deploymentFacts', 'reauthorize', 'roomDraft.list', 'roomDraft.read', 'roomDraft.write', 'roomDraft.discard', 'presentation.read', 'presentation.write', 'conversation.list', 'conversation.read', 'conversation.create', 'conversation.send', 'conversation.answer', 'conversation.interrupt', 'conversation.kill', 'conversation.cancel', 'conversation.delete', 'chatDraft.write', 'chatDraft.discard'];
|
|
11
|
+
declare const MEMBERS: readonly ['rooms', 'slots', 'query', 'search', 'types', 'syncStatus', 'save', 'outcome', 'history', 'call', 'log', 'storageLoss', 'persistence', 'deploymentFacts', 'reauthorize', 'roomDraft.list', 'roomDraft.read', 'roomDraft.write', 'roomDraft.discard', 'presentation.read', 'presentation.write', 'conversation.list', 'conversation.read', 'conversation.create', 'conversation.send', 'conversation.answer', 'conversation.interrupt', 'conversation.kill', 'conversation.cancel', 'conversation.delete', 'chatDraft.write', 'chatDraft.discard'];
|
|
12
12
|
declare const TOPICS: readonly ['rooms', 'connection-refusal', 'storage-loss', 'deployment-facts', 'sync-status', 'query', 'queue', 'room-drafts', 'presentation', 'conversation'];
|
|
13
13
|
export type WireMember = (typeof MEMBERS)[number];
|
|
14
14
|
export type WireTopic = (typeof TOPICS)[number];
|
package/dist/wire.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../src/wire.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAEvC,eAAO,MAAM,iBAAiB,EAAE,iBAI/B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACpC,gBAAgB,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,GAAG,IAAI,CAAC;IACjG,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAEF,QAAA,MAAM,OAAO,YACX,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP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IRE_PROTOCOL =
|
|
1
|
+
export const RUNTIME_WIRE_PROTOCOL = 6;
|
|
2
2
|
export const PROTOCOL_MISMATCH = {
|
|
3
3
|
reason: 'client-host-protocol-mismatch',
|
|
4
4
|
reauthorizationOffered: false,
|
|
@@ -8,6 +8,7 @@ const MEMBERS = [
|
|
|
8
8
|
'rooms',
|
|
9
9
|
'slots',
|
|
10
10
|
'query',
|
|
11
|
+
'search',
|
|
11
12
|
'types',
|
|
12
13
|
'syncStatus',
|
|
13
14
|
'save',
|
package/dist/wire.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/workspace/packages/mdruntime/src/wire.ts"],"sourcesContent":["import type { ConnectionRefusal } from './connection.js';\n\nexport const RUNTIME_WIRE_PROTOCOL =
|
|
1
|
+
{"version":3,"sources":["/workspace/packages/mdruntime/src/wire.ts"],"sourcesContent":["import type { ConnectionRefusal } from './connection.js';\n\nexport const RUNTIME_WIRE_PROTOCOL = 6;\n\nexport const PROTOCOL_MISMATCH: ConnectionRefusal = {\n reason: 'client-host-protocol-mismatch',\n reauthorizationOffered: false,\n refusal: null,\n};\n\nexport type RuntimePort = {\n postMessage(message: unknown): void;\n addEventListener(type: 'message' | 'close', listener: (event: { data?: unknown }) => void): void;\n start(): void;\n};\n\nconst MEMBERS = [\n 'rooms',\n 'slots',\n 'query',\n 'search',\n 'types',\n 'syncStatus',\n 'save',\n 'outcome',\n 'history',\n 'call',\n 'log',\n 'storageLoss',\n 'persistence',\n 'deploymentFacts',\n 'reauthorize',\n 'roomDraft.list',\n 'roomDraft.read',\n 'roomDraft.write',\n 'roomDraft.discard',\n 'presentation.read',\n 'presentation.write',\n 'conversation.list',\n 'conversation.read',\n 'conversation.create',\n 'conversation.send',\n 'conversation.answer',\n 'conversation.interrupt',\n 'conversation.kill',\n 'conversation.cancel',\n 'conversation.delete',\n 'chatDraft.write',\n 'chatDraft.discard',\n] as const;\n\nconst TOPICS = [\n 'rooms',\n 'connection-refusal',\n 'storage-loss',\n 'deployment-facts',\n 'sync-status',\n 'query',\n 'queue',\n 'room-drafts',\n 'presentation',\n 'conversation',\n] as const;\n\nexport type WireMember = (typeof MEMBERS)[number];\nexport type WireTopic = (typeof TOPICS)[number];\n\nexport type WireRequest =\n | { kind: 'hello' }\n | { kind: 'call'; id: number; member: WireMember; input: readonly unknown[] }\n | { kind: 'observe'; id: number; topic: WireTopic; input: readonly unknown[] }\n | { kind: 'stop'; id: number };\n\nexport type WireAnswer =\n | { kind: 'result'; id: number; value: unknown }\n | { kind: 'failure'; id: number; message: string }\n | { kind: 'event'; id: number; value: unknown }\n | { kind: 'refusal'; refusal: ConnectionRefusal }\n | { kind: 'ended' };\n\nexport const AUTHORIZATION_ENDED = 'the host authorization ended';\n\nexport type WireEnvelope = { mdRuntime: number; message: WireRequest | WireAnswer };\n\nexport type Carried = { matching: boolean; message: unknown };\n\nexport function envelope(message: WireRequest | WireAnswer): WireEnvelope {\n return { mdRuntime: RUNTIME_WIRE_PROTOCOL, message };\n}\n\nexport function carried(data: unknown): Carried | null {\n if (typeof data !== 'object' || data === null || !('mdRuntime' in data)) return null;\n const record = data as { mdRuntime: unknown; message?: unknown };\n return { matching: record.mdRuntime === RUNTIME_WIRE_PROTOCOL, message: record.message };\n}\n\nfunction body(message: unknown): { kind: unknown; id: unknown } | null {\n if (typeof message !== 'object' || message === null) return null;\n const record = message as { kind?: unknown; id?: unknown };\n return { kind: record.kind, id: record.id };\n}\n\nexport function request(message: unknown): WireRequest | null {\n const shape = body(message);\n if (shape === null) return null;\n if (shape.kind === 'hello') return { kind: 'hello' };\n if (typeof shape.id !== 'number') return null;\n const record = message as { input?: unknown; member?: unknown; topic?: unknown };\n if (shape.kind === 'stop') return { kind: 'stop', id: shape.id };\n if (!Array.isArray(record.input)) return null;\n if (shape.kind === 'call' && MEMBERS.includes(record.member as WireMember)) {\n return {\n kind: 'call',\n id: shape.id,\n member: record.member as WireMember,\n input: record.input as readonly unknown[],\n };\n }\n if (shape.kind === 'observe' && TOPICS.includes(record.topic as WireTopic)) {\n return {\n kind: 'observe',\n id: shape.id,\n topic: record.topic as WireTopic,\n input: record.input as readonly unknown[],\n };\n }\n return null;\n}\n\nexport function answer(message: unknown): WireAnswer | null {\n const shape = body(message);\n if (shape === null) return null;\n const record = message as { value?: unknown; message?: unknown; refusal?: unknown };\n if (shape.kind === 'refusal') {\n return { kind: 'refusal', refusal: record.refusal as ConnectionRefusal };\n }\n if (shape.kind === 'ended') return { kind: 'ended' };\n if (typeof shape.id !== 'number') return null;\n if (shape.kind === 'result') return { kind: 'result', id: shape.id, value: record.value };\n if (shape.kind === 'event') return { kind: 'event', id: shape.id, value: record.value };\n if (shape.kind === 'failure' && typeof record.message === 'string') {\n return { kind: 'failure', id: shape.id, message: record.message };\n }\n return null;\n}\n"],"names":["RUNTIME_WIRE_PROTOCOL","PROTOCOL_MISMATCH","reason","reauthorizationOffered","refusal","MEMBERS","TOPICS","AUTHORIZATION_ENDED","envelope","message","mdRuntime","carried","data","record","matching","body","kind","id","request","shape","Array","isArray","input","includes","member","topic","answer","value"],"mappings":"AAEA,OAAO,MAAMA,wBAAwB,EAAE;AAEvC,OAAO,MAAMC,oBAAuC;IAClDC,QAAQ;IACRC,wBAAwB;IACxBC,SAAS;AACX,EAAE;AAQF,MAAMC,UAAU;IACd;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,MAAMC,SAAS;IACb;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAkBD,OAAO,MAAMC,sBAAsB,+BAA+B;AAMlE,OAAO,SAASC,SAASC,OAAiC;IACxD,OAAO;QAAEC,WAAWV;QAAuBS;IAAQ;AACrD;AAEA,OAAO,SAASE,QAAQC,IAAa;IACnC,IAAI,OAAOA,SAAS,YAAYA,SAAS,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MAAMN,SAASJ;IACf,IAAIU,MAAMH,IAAI,KAAK,WAAW;QAC5B,OAAO;YAAEA,MAAM;YAAWZ,SAASS,OAAOT,OAAO;QAAsB;IACzE;IACA,IAAIe,MAAMH,IAAI,KAAK,SAAS,OAAO;QAAEA,MAAM;IAAQ;IACnD,IAAI,OAAOG,MAAMF,EAAE,KAAK,UAAU,OAAO;IACzC,IAAIE,MAAMH,IAAI,KAAK,UAAU,OAAO;QAAEA,MAAM;QAAUC,IAAIE,MAAMF,EAAE;QAAEU,OAAOd,OAAOc,KAAK;IAAC;IACxF,IAAIR,MAAMH,IAAI,KAAK,SAAS,OAAO;QAAEA,MAAM;QAASC,IAAIE,MAAMF,EAAE;QAAEU,OAAOd,OAAOc,KAAK;IAAC;IACtF,IAAIR,MAAMH,IAAI,KAAK,aAAa,OAAOH,OAAOJ,OAAO,KAAK,UAAU;QAClE,OAAO;YAAEO,MAAM;YAAWC,IAAIE,MAAMF,EAAE;YAAER,SAASI,OAAOJ,OAAO;QAAC;IAClE;IACA,OAAO;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentshouse/mdruntime",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.26",
|
|
4
4
|
"description": "The headless core of MD App",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@agentshouse/mdmodel": "0.1.0-alpha.14",
|
|
49
|
-
"@tanstack/db": "0.9.2"
|
|
49
|
+
"@tanstack/db": "0.9.2",
|
|
50
|
+
"minisearch": "7.2.0"
|
|
50
51
|
}
|
|
51
52
|
}
|