@happyvertical/smrt-comments 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.
Files changed (50) hide show
  1. package/README.md +72 -0
  2. package/dist/chunks/participation-LA_cfrM2.js +276 -0
  3. package/dist/chunks/participation-LA_cfrM2.js.map +1 -0
  4. package/dist/collections/CommentReportCollection.d.ts +6 -0
  5. package/dist/collections/CommentReportCollection.d.ts.map +1 -0
  6. package/dist/collections/CommentRevisionCollection.d.ts +6 -0
  7. package/dist/collections/CommentRevisionCollection.d.ts.map +1 -0
  8. package/dist/collections/ParticipationCollection.d.ts +14 -0
  9. package/dist/collections/ParticipationCollection.d.ts.map +1 -0
  10. package/dist/index.d.ts +10 -0
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +364 -59
  13. package/dist/index.js.map +1 -1
  14. package/dist/manifest.json +1853 -224
  15. package/dist/models/Comment.d.ts +8 -1
  16. package/dist/models/Comment.d.ts.map +1 -1
  17. package/dist/models/CommentReport.d.ts +10 -0
  18. package/dist/models/CommentReport.d.ts.map +1 -0
  19. package/dist/models/CommentRevision.d.ts +9 -0
  20. package/dist/models/CommentRevision.d.ts.map +1 -0
  21. package/dist/models/ParticipationBan.d.ts +12 -0
  22. package/dist/models/ParticipationBan.d.ts.map +1 -0
  23. package/dist/models/ParticipationPolicy.d.ts +13 -0
  24. package/dist/models/ParticipationPolicy.d.ts.map +1 -0
  25. package/dist/models/ParticipationRateBucket.d.ts +8 -0
  26. package/dist/models/ParticipationRateBucket.d.ts.map +1 -0
  27. package/dist/participation-contract.d.ts +37 -0
  28. package/dist/participation-contract.d.ts.map +1 -0
  29. package/dist/participation.d.ts +4 -0
  30. package/dist/participation.d.ts.map +1 -0
  31. package/dist/participation.js +2 -0
  32. package/dist/recipes.d.ts +6 -1
  33. package/dist/recipes.d.ts.map +1 -1
  34. package/dist/services/CommentService.d.ts +10 -1
  35. package/dist/services/CommentService.d.ts.map +1 -1
  36. package/dist/services/ParticipationService.d.ts +25 -0
  37. package/dist/services/ParticipationService.d.ts.map +1 -0
  38. package/dist/smrt-knowledge.json +477 -12
  39. package/dist/svelte/ModerationQueue.svelte +60 -0
  40. package/dist/svelte/ModerationQueue.svelte.d.ts +17 -0
  41. package/dist/svelte/ModerationQueue.svelte.d.ts.map +1 -0
  42. package/dist/svelte/RecordComments.svelte +21 -6
  43. package/dist/svelte/RecordComments.svelte.d.ts +2 -0
  44. package/dist/svelte/RecordComments.svelte.d.ts.map +1 -1
  45. package/dist/svelte/index.d.ts +2 -0
  46. package/dist/svelte/index.d.ts.map +1 -1
  47. package/dist/svelte/index.js +1 -0
  48. package/dist/types.d.ts +7 -1
  49. package/dist/types.d.ts.map +1 -1
  50. package/package.json +9 -5
@@ -1,5 +1,5 @@
1
1
  import { SmrtPolymorphicAssociation } from '@happyvertical/smrt-core';
2
- import type { CommentOptions } from '../types.js';
2
+ import type { CommentOptions, CommentStatus } from '../types.js';
3
3
  export declare class Comment extends SmrtPolymorphicAssociation {
4
4
  tenantId: string;
5
5
  authorUserId: string;
@@ -12,6 +12,13 @@ export declare class Comment extends SmrtPolymorphicAssociation {
12
12
  retryTenantId: string | null;
13
13
  /** Digest of the original authenticated author, parent and normalized payload. */
14
14
  requestDigest: string | null;
15
+ /** A reply stays within this comment's already-authorized record thread. */
16
+ parentCommentId: string | null;
17
+ /** Visible comments are public to the host's authorized record readers. */
18
+ status: CommentStatus;
19
+ /** JSON retained from the host participation decision at post time. */
20
+ participationSnapshot: string | null;
21
+ editedAt: Date | null;
15
22
  constructor(options?: CommentOptions);
16
23
  get mentionUserIds(): string[];
17
24
  set mentionUserIds(value: readonly string[]);
@@ -1 +1 @@
1
- {"version":3,"file":"Comment.d.ts","sourceRoot":"","sources":["../../src/models/Comment.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,0BAA0B,EAE3B,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aA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MAAM,EAAE,CAU7B;IAED,IAAI,cAAc,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAQ1C;CACF"}
@@ -0,0 +1,10 @@
1
+ import { SmrtObject } from '@happyvertical/smrt-core';
2
+ /** A tenant-local report; moderation resolution never deletes the report. */
3
+ export declare class CommentReport extends SmrtObject {
4
+ tenantId: string;
5
+ commentId: string;
6
+ reporterUserId: string;
7
+ reason: string;
8
+ status: 'open' | 'resolved' | 'dismissed';
9
+ }
10
+ //# sourceMappingURL=CommentReport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommentReport.d.ts","sourceRoot":"","sources":["../../src/models/CommentReport.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,UAAU,EAEX,MAAM,0BAA0B,CAAC;AAGlC,6EAA6E;AAC7E,qBAkBa,aAAc,SAAQ,UAAU;IAE3C,QAAQ,SAAM;IAId,SAAS,SAAM;IAGf,cAAc,SAAM;IAGpB,MAAM,SAAM;IAGZ,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,CAAU;CACpD"}
@@ -0,0 +1,9 @@
1
+ import { SmrtObject } from '@happyvertical/smrt-core';
2
+ /** Immutable prior body retained whenever an author edits a comment. */
3
+ export declare class CommentRevision extends SmrtObject {
4
+ tenantId: string;
5
+ commentId: string;
6
+ editorUserId: string;
7
+ body: string;
8
+ }
9
+ //# sourceMappingURL=CommentRevision.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommentRevision.d.ts","sourceRoot":"","sources":["../../src/models/CommentRevision.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,UAAU,EAEX,MAAM,0BAA0B,CAAC;AAGlC,wEAAwE;AACxE,qBAEa,eAAgB,SAAQ,UAAU;IAE7C,QAAQ,SAAM;IAId,SAAS,SAAM;IAGf,YAAY,SAAM;IAGlB,IAAI,SAAM;CACX"}
@@ -0,0 +1,12 @@
1
+ import { SmrtObject } from '@happyvertical/smrt-core';
2
+ /** Tenant-local, reusable participation ban; a blank target applies tenant-wide. */
3
+ export declare class ParticipationBan extends SmrtObject {
4
+ tenantId: string;
5
+ actorUserId: string;
6
+ recordType: string;
7
+ recordId: string;
8
+ reason: string;
9
+ expiresAt: Date | null;
10
+ protected validateBeforeSave(): Promise<void>;
11
+ }
12
+ //# sourceMappingURL=ParticipationBan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ParticipationBan.d.ts","sourceRoot":"","sources":["../../src/models/ParticipationBan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,UAAU,EAAQ,MAAM,0BAA0B,CAAC;AAGnE,oFAAoF;AACpF,qBAEa,gBAAiB,SAAQ,UAAU;IAClC,QAAQ,SAAM;IACC,WAAW,SAAM;IACnC,UAAU,SAAM;IAChB,QAAQ,SAAM;IACI,MAAM,SAAM;IACM,SAAS,EAAE,IAAI,GAAG,IAAI,CAAQ;cAClD,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;CAkB7D"}
@@ -0,0 +1,13 @@
1
+ import { SmrtObject } from '@happyvertical/smrt-core';
2
+ /** A generic tenant default or exact-record override for participation actions. */
3
+ export declare class ParticipationPolicy extends SmrtObject {
4
+ tenantId: string;
5
+ recordType: string;
6
+ recordId: string;
7
+ action: string;
8
+ moderationMode: 'open' | 'pre_moderated' | 'members_only' | 'closed';
9
+ maxActions: number;
10
+ windowSeconds: number;
11
+ protected validateBeforeSave(): Promise<void>;
12
+ }
13
+ //# sourceMappingURL=ParticipationPolicy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ParticipationPolicy.d.ts","sourceRoot":"","sources":["../../src/models/ParticipationPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,UAAU,EAAQ,MAAM,0BAA0B,CAAC;AAGnE,mFAAmF;AACnF,qBAOa,mBAAoB,SAAQ,UAAU;IACrC,QAAQ,SAAM;IACjB,UAAU,SAAM;IAChB,QAAQ,SAAM;IACI,MAAM,SAAa;IACnB,cAAc,EACrC,MAAM,GACN,eAAe,GACf,cAAc,GACd,QAAQ,CAAU;IACK,UAAU,SAAK;IACf,aAAa,SAAK;cACpB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;CA8B7D"}
@@ -0,0 +1,8 @@
1
+ import { SmrtObject } from '@happyvertical/smrt-core';
2
+ /** Service-owned fixed-window counter. Never delete a currently active bucket. */
3
+ export declare class ParticipationRateBucket extends SmrtObject {
4
+ tenantId: string;
5
+ bucketKey: string;
6
+ actionCount: number;
7
+ }
8
+ //# sourceMappingURL=ParticipationRateBucket.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ParticipationRateBucket.d.ts","sourceRoot":"","sources":["../../src/models/ParticipationRateBucket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,UAAU,EAAQ,MAAM,0BAA0B,CAAC;AAGnE,kFAAkF;AAClF,qBAca,uBAAwB,SAAQ,UAAU;IACzC,QAAQ,SAAM;IACC,SAAS,SAAM;IACf,WAAW,SAAK;CAC5C"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Neutral participation boundary shared by record discussions and lightweight
3
+ * reactions/votes. This package owns the generic policy/ban schema; hosts bind
4
+ * only identity and entitlement facts through the authorizer.
5
+ */
6
+ export type ParticipationAction = 'comment' | 'react' | 'vote' | 'report';
7
+ export interface ParticipationTarget {
8
+ tenantId: string;
9
+ recordType: string;
10
+ recordId: string;
11
+ }
12
+ export interface ParticipationRequest extends ParticipationTarget {
13
+ actorUserId: string;
14
+ action: ParticipationAction;
15
+ }
16
+ export interface ParticipationDecision {
17
+ allowed: boolean;
18
+ /** Trusted entitlement fact required by members_only policy. */
19
+ member?: boolean;
20
+ /** Immutable host-provided entitlement/roll evidence retained by the row. */
21
+ snapshot?: Record<string, unknown>;
22
+ /** Comments may enter the moderation queue without exposing host policy. */
23
+ initialCommentStatus?: 'visible' | 'pending';
24
+ reason?: string;
25
+ }
26
+ /**
27
+ * The host supplies entitlement facts; the package's policy/ban/rate service
28
+ * combines them with its tenant-scoped generic anti-abuse records.
29
+ */
30
+ export interface ParticipationAuthorizer {
31
+ authorize(request: ParticipationRequest): Promise<ParticipationDecision>;
32
+ }
33
+ export declare class ParticipationDeniedError extends Error {
34
+ readonly reason?: string | undefined;
35
+ constructor(reason?: string | undefined);
36
+ }
37
+ //# sourceMappingURL=participation-contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"participation-contract.d.ts","sourceRoot":"","sources":["../src/participation-contract.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE1E,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,oBAAqB,SAAQ,mBAAmB;IAC/D,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,mBAAmB,CAAC;CAC7B;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,gEAAgE;IAChE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,4EAA4E;IAC5E,oBAAoB,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC,SAAS,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;CAC1E;AAED,qBAAa,wBAAyB,SAAQ,KAAK;IACrC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM;gBAAf,MAAM,CAAC,EAAE,MAAM,YAAA;CAIrC"}
@@ -0,0 +1,4 @@
1
+ import './__smrt-register__.js';
2
+ export * from './participation-contract.js';
3
+ export { ParticipationService } from './services/ParticipationService.js';
4
+ //# sourceMappingURL=participation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"participation.d.ts","sourceRoot":"","sources":["../src/participation.ts"],"names":[],"mappings":"AAAA,OAAO,wBAAwB,CAAC;AAEhC,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { n as ParticipationDeniedError, t as ParticipationService } from "./chunks/participation-LA_cfrM2.js";
2
+ export { ParticipationDeniedError, ParticipationService };
package/dist/recipes.d.ts CHANGED
@@ -1,5 +1,10 @@
1
1
  import { SmrtRecipe } from '@happyvertical/smrt-core';
2
2
  import { Comment } from './models/Comment.js';
3
+ import { CommentReport } from './models/CommentReport.js';
4
+ import { CommentRevision } from './models/CommentRevision.js';
5
+ import { ParticipationBan } from './models/ParticipationBan.js';
6
+ import { ParticipationPolicy } from './models/ParticipationPolicy.js';
7
+ import { ParticipationRateBucket } from './models/ParticipationRateBucket.js';
3
8
  /** Discussion attached to any authorized business record. */
4
9
  export declare class RecordCommentsRecipe extends SmrtRecipe {
5
10
  static id: string;
@@ -11,7 +16,7 @@ export declare class RecordCommentsRecipe extends SmrtRecipe {
11
16
  label: string;
12
17
  summary: string;
13
18
  };
14
- static models: (typeof Comment)[];
19
+ static models: (typeof Comment | typeof CommentReport | typeof CommentRevision | typeof ParticipationBan | typeof ParticipationPolicy | typeof ParticipationRateBucket)[];
15
20
  static nav: never[];
16
21
  static runtime: "both";
17
22
  static surfaces: readonly [{
@@ -1 +1 @@
1
- {"version":3,"file":"recipes.d.ts","sourceRoot":"","sources":["../src/recipes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,6DAA6D;AAC7D,qBAAa,oBAAqB,SAAQ,UAAU;IAClD,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6 +1,7 @@
1
1
  import { type SmrtClassOptions } from '@happyvertical/smrt-core';
2
2
  import { Comment } from '../models/Comment.js';
3
- import type { CommentActorContext, CommentMentionNotificationAdapter, CommentRecordAccess, CreateCommentInput } from '../types.js';
3
+ import type { ParticipationAuthorizer } from '../participation-contract.js';
4
+ import type { CommentActorContext, CommentMentionNotificationAdapter, CommentRecordAccess, CommentStatus, CreateCommentInput } from '../types.js';
4
5
  /** A reused request differs, or its retained comment is no longer available. */
5
6
  export declare class CommentIdempotencyError extends Error {
6
7
  readonly code: 'COMMENT_REQUEST_CONFLICT' | 'COMMENT_REQUEST_UNAVAILABLE';
@@ -12,9 +13,17 @@ export declare class CommentService {
12
13
  db: SmrtClassOptions['db'];
13
14
  actor: CommentActorContext;
14
15
  authorizeRecord: (access: CommentRecordAccess) => Promise<boolean>;
16
+ participation?: ParticipationAuthorizer;
15
17
  mentionNotifications?: CommentMentionNotificationAdapter;
16
18
  });
17
19
  private authorize;
20
+ private getAuthorizedComment;
21
+ /** Edits retain the exact former body before changing the visible comment. */
22
+ edit(commentId: string, body: string): Promise<Comment>;
23
+ /** A moderator may make a row visible, hidden, pending, or deleted. */
24
+ moderate(commentId: string, status: CommentStatus): Promise<Comment>;
25
+ /** One retained report per actor/comment; new reports consume shared report quota. */
26
+ report(commentId: string, reason: string): Promise<import("../index.js").CommentReport>;
18
27
  listForRecord(recordType: string, recordId: string): Promise<Comment[]>;
19
28
  private loadBoundComment;
20
29
  create(commentOptions: CreateCommentInput): Promise<Comment>;
@@ -1 +1 @@
1
- {"version":3,"file":"CommentService.d.ts","sourceRoot":"","sources":["../../src/services/CommentService.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,KAAK,EACV,mBAAmB,EACnB,iCAAiC,EACjC,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,aAAa,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P,OAAO,EAAE;QACxB,EAAE,EAAE,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAC3B,KAAK,EAAE,mBAAmB,CAAC;QAC3B,eAAe,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;QACnE,aAAa,CAAC,EAAE,uBAAuB,CAAC;QACxC,oBAAoB,CAAC,EAAE,iCAAiC,CAAC;KAC1D;YAGW,SAAS;YAsBT,oBAAoB;IAclC,8EAA8E;IACxE,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAwE7D,uEAAuE;IACjE,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;IA4B1E,sFAAsF;IAChF,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IA0ExC,aAAa,CACjB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,OAAO,EAAE,CAAC;YAwCP,gBAAgB;IA6BxB,MAAM,CAAC,cAAc,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;CAiOnE"}
@@ -0,0 +1,25 @@
1
+ import { type SmrtClassOptions } from '@happyvertical/smrt-core';
2
+ import { ParticipationRateBucketCollection } from '../collections/ParticipationCollection.js';
3
+ import { type ParticipationAuthorizer, type ParticipationDecision, type ParticipationRequest } from '../participation-contract.js';
4
+ type Database = ParticipationRateBucketCollection['db'];
5
+ /** Shared generic policy, ban, and transactional quota enforcement. */
6
+ export declare class ParticipationService {
7
+ private readonly options;
8
+ constructor(options: {
9
+ db: SmrtClassOptions['db'];
10
+ entitlement?: ParticipationAuthorizer;
11
+ /** Trusted clock for deterministic fixed-window boundaries. */
12
+ now?: () => Date;
13
+ });
14
+ private normalize;
15
+ private evaluate;
16
+ /** Checks current permission without consuming quota (including keyed replays). */
17
+ authorize(input: ParticipationRequest): Promise<ParticipationDecision>;
18
+ private reserve;
19
+ /** Run one new mutation atomically with its reservation. Caller owns retry identity. */
20
+ execute<T>(input: ParticipationRequest, work: (db: Database, decision: ParticipationDecision) => Promise<T>): Promise<T>;
21
+ /** Compose with an existing caller-owned transaction; propagate failures to roll it back. */
22
+ executeInTransaction<T>(tx: Database, input: ParticipationRequest, work: (db: Database, decision: ParticipationDecision) => Promise<T>): Promise<T>;
23
+ }
24
+ export {};
25
+ //# sourceMappingURL=ParticipationService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ParticipationService.d.ts","sourceRoot":"","sources":["../../src/services/ParticipationService.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAGL,iCAAiC,EAClC,MAAM,2CAA2C,CAAC;AAEnD,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAE1B,KAAK,oBAAoB,EAC1B,MAAM,8BAA8B,CAAC;AAEtC,KAAK,QAAQ,GAAG,iCAAiC,CAAC,IAAI,CAAC,CAAC;AAMxD,uEAAuE;AACvE,qBAAa,oBAAoB;IAE7B,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE;QACxB,EAAE,EAAE,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAC3B,WAAW,CAAC,EAAE,uBAAuB,CAAC;QACtC,+DAA+D;QAC/D,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;KAClB;IAGH,OAAO,CAAC,SAAS;YAqBH,QAAQ;IAgFtB,mFAAmF;IAC7E,SAAS,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;YAQ9D,OAAO;IAgCrB,wFAAwF;IAClF,OAAO,CAAC,CAAC,EACb,KAAK,EAAE,oBAAoB,EAC3B,IAAI,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,qBAAqB,KAAK,OAAO,CAAC,CAAC,CAAC,GAClE,OAAO,CAAC,CAAC,CAAC;IAcb,6FAA6F;IACvF,oBAAoB,CAAC,CAAC,EAC1B,EAAE,EAAE,QAAQ,EACZ,KAAK,EAAE,oBAAoB,EAC3B,IAAI,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,qBAAqB,KAAK,OAAO,CAAC,CAAC,CAAC,GAClE,OAAO,CAAC,CAAC,CAAC;CAQd"}