@hasna/economy 0.3.10 → 0.3.15

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.
@@ -1,83 +1,3 @@
1
- import type { Env } from "./mode.js";
2
- import { createClientTransport, type HasnaHttpTransport, type HasnaRequestOptions, type QueryParams } from "./transport.js";
3
- /** Options for a list() call: filters/pagination as query params. */
4
- export interface StorageListOptions extends Pick<HasnaRequestOptions, "timeoutMs" | "headers" | "retry" | "signal"> {
5
- /** Query params (limit, offset, cursor, filters, ...). */
6
- query?: QueryParams;
7
- }
8
- /** Options for a get() call. */
9
- export type StorageGetOptions = Pick<HasnaRequestOptions, "timeoutMs" | "headers" | "retry" | "signal" | "query">;
10
- /** Options for a create() call. */
11
- export interface StorageCreateOptions extends Pick<HasnaRequestOptions, "timeoutMs" | "headers" | "retry" | "signal" | "query"> {
12
- /**
13
- * Idempotency key for the create. Defaults to a fresh UUID so a transparently
14
- * retried POST is deduped by the server instead of creating a duplicate. Pass
15
- * a stable value to make an app-level operation idempotent across calls.
16
- */
17
- idempotencyKey?: string;
18
- }
19
- /** Options for an update() call. */
20
- export interface StorageUpdateOptions extends Pick<HasnaRequestOptions, "timeoutMs" | "headers" | "retry" | "signal" | "query"> {
21
- /** HTTP verb for the update. Default `PATCH` (partial); use `PUT` for replace. */
22
- method?: "PATCH" | "PUT";
23
- /** Idempotency key. PUT is idempotent by definition; set this to make PATCH retry-safe too. */
24
- idempotencyKey?: string;
25
- }
26
- /** Options for a delete() call. */
27
- export type StorageDeleteOptions = Pick<HasnaRequestOptions, "timeoutMs" | "headers" | "retry" | "signal" | "query">;
28
- /** Result of a list() call. `items` is the extracted array; `raw` is the full envelope. */
29
- export interface StorageListResult<T> {
30
- items: T[];
31
- /** Total count when the server reports one (`total`/`count`), else null. */
32
- total: number | null;
33
- /** Opaque pagination cursor when the server reports one, else null. */
34
- cursor: string | null;
35
- /** The full parsed response body (envelope preserved). */
36
- raw: unknown;
37
- }
38
- /**
39
- * The app storage interface, HTTP edition. This is deliberately the same small
40
- * CRUD surface a local store exposes, so an app's resolver can return either a
41
- * local implementation or this one behind one interface.
42
- */
43
- export interface HasnaStorageClient {
44
- /** App slug this client targets. */
45
- readonly name: string;
46
- /** `<origin>/v1` base URL. */
47
- readonly baseUrl: string;
48
- /** The underlying HTTP transport (escape hatch for non-CRUD routes). */
49
- readonly transport: HasnaHttpTransport;
50
- /** List a collection. Returns extracted `items` plus the raw envelope. */
51
- list<T = unknown>(resource: string, options?: StorageListOptions): Promise<StorageListResult<T>>;
52
- /** Fetch one entity by id. Returns `null` on 404. */
53
- get<T = unknown>(resource: string, id: string, options?: StorageGetOptions): Promise<T | null>;
54
- /** Create one entity. Retry-safe via an auto `Idempotency-Key`. */
55
- create<T = unknown>(resource: string, body: unknown, options?: StorageCreateOptions): Promise<T>;
56
- /** Update one entity by id (PATCH by default). */
57
- update<T = unknown>(resource: string, id: string, patch: unknown, options?: StorageUpdateOptions): Promise<T>;
58
- /** Delete one entity by id. Resolves for 2xx and 404 (already gone). */
59
- delete(resource: string, id: string, options?: StorageDeleteOptions): Promise<void>;
60
- }
61
- /**
62
- * Wrap an HTTP transport with the resource CRUD storage interface. Use this when
63
- * you already have a transport (e.g. from `createClientTransport`).
64
- */
65
- export declare function createHasnaStorageClient(name: string, transport: HasnaHttpTransport): HasnaStorageClient;
66
- /** Result of {@link resolveStorageClient}. */
67
- export type ResolveStorageClientResult = {
68
- transport: "local";
69
- client: null;
70
- } | {
71
- transport: "cloud-http";
72
- client: HasnaStorageClient;
73
- };
74
- /**
75
- * The one call an app's storage resolver makes. Reads the client-flip env for
76
- * `name`; when it resolves to `cloud-http` (mode=cloud/self_hosted + API_URL +
77
- * API_KEY), returns a ready {@link HasnaStorageClient}. Otherwise returns
78
- * `{ transport: 'local', client: null }` so the app uses its local store.
79
- * Throws if cloud was requested but is misconfigured (so callers never silently
80
- * read the wrong dataset).
81
- */
82
- export declare function resolveStorageClient(name: string, env?: Env, overrides?: Parameters<typeof createClientTransport>[2]): ResolveStorageClientResult;
1
+ export { resolveStorageClient } from "@hasna/contracts/client/storage";
2
+ export type { HasnaStorageClient } from "@hasna/contracts/client/storage";
83
3
  //# sourceMappingURL=storage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/lib/contracts-client/storage.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EACL,qBAAqB,EAErB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EACjB,MAAM,gBAAgB,CAAC;AAExB,qEAAqE;AACrE,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,mBAAmB,EAAE,WAAW,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;IACjH,0DAA0D;IAC1D,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB;AAED,gCAAgC;AAChC,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,mBAAmB,EAAE,WAAW,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC,CAAC;AAElH,mCAAmC;AACnC,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAAC,mBAAmB,EAAE,WAAW,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IAC7H;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,oCAAoC;AACpC,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAAC,mBAAmB,EAAE,WAAW,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IAC7H,kFAAkF;IAClF,MAAM,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IACzB,+FAA+F;IAC/F,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,mCAAmC;AACnC,MAAM,MAAM,oBAAoB,GAAG,IAAI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,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC9G,wEAAwE;IACxE,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrF;AAqDD;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,kBAAkB,GAAG,kBAAkB,CAiDxG;AAED,8CAA8C;AAC9C,MAAM,MAAM,0BAA0B,GAClC;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,IAAI,CAAA;CAAE,GACpC;IAAE,SAAS,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAE5D;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,GAAG,GAAE,GAAiB,EACtB,SAAS,CAAC,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC,CAAC,CAAC,GACtD,0BAA0B,CAM5B"}
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/lib/contracts-client/storage.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,YAAY,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC"}
@@ -1,148 +1,2 @@
1
- import { type Env, type StorageMode } from "./mode.js";
2
- /** Default cloud host template. `<app>` is the app slug. */
3
- export declare function defaultCloudBaseUrl(name: string): string;
4
- export interface ClientTransportEnvKeys {
5
- /** Mode keys, in precedence order. */
6
- modeKeys: string[];
7
- /** API base-URL keys, in precedence order. */
8
- apiUrlKeys: string[];
9
- /** API-key keys, in precedence order. */
10
- apiKeyKeys: string[];
11
- }
12
- /** Resolve the canonical client-flip env-key spec for an app. */
13
- export declare function clientTransportEnvKeys(name: string): ClientTransportEnvKeys;
14
- /** Normalize a base URL to `<origin>/v1` (dropping any trailing slash or existing /v1). */
15
- export declare function toV1BaseUrl(apiUrl: string): string;
16
- export type ClientTransportKind = "local" | "cloud-http";
17
- export interface ClientTransportResolution {
18
- /** Where the client should read/write from. */
19
- transport: ClientTransportKind;
20
- /** Resolved storage mode (`local` | `cloud`). */
21
- mode: StorageMode;
22
- /** Deprecated mode alias that was normalized (e.g. `self_hosted`), if any. */
23
- deprecatedAlias: string | null;
24
- /** Env key the mode was read from, or `"default"`. */
25
- modeSource: string;
26
- /** `<origin>/v1` base for the cloud API when transport is cloud-http, else null. */
27
- baseUrl: string | null;
28
- /** Env key the API URL came from, `"default"` (host template), or null. */
29
- apiUrlSource: string | null;
30
- /** Whether an API key is present (value never exposed). */
31
- apiKeyPresent: boolean;
32
- /** Env key the API key came from, or null. */
33
- apiKeySource: string | null;
34
- /**
35
- * True when the operator asked for cloud but the config is incomplete (no API
36
- * key), so we fell back to local. Callers SHOULD treat this as an error rather
37
- * than silently reading local data.
38
- */
39
- misconfigured: boolean;
40
- /** Human-readable warning, or null. Never contains secret values. */
41
- warning: string | null;
42
- }
43
- /**
44
- * Resolve how a client should reach an app's data given the environment.
45
- *
46
- * Precedence for the mode: the first present of `HASNA_<NAME>_STORAGE_MODE`,
47
- * `HASNA_<NAME>_MODE`, `<NAME>_STORAGE_MODE`, `<NAME>_MODE`, else `local`.
48
- */
49
- export declare function resolveClientTransport(name: string, env?: Env): ClientTransportResolution;
50
- /** Thrown when a cloud HTTP request returns a non-2xx status. */
51
- export declare class HasnaHttpError extends Error {
52
- readonly status: number;
53
- readonly method: string;
54
- readonly path: string;
55
- readonly body: unknown;
56
- constructor(method: string, path: string, status: number, body: unknown);
57
- }
58
- type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
59
- /** Query params for a request. Nullish values are dropped; arrays repeat the key. */
60
- export type QueryParams = URLSearchParams | Record<string, string | number | boolean | null | undefined | ReadonlyArray<string | number | boolean>>;
61
- /** Retry policy for transient failures (network errors, timeouts, 5xx, 429). */
62
- export interface HasnaRetryOptions {
63
- /** Max RETRY attempts after the first try. Default 2 (=> up to 3 total tries). */
64
- retries?: number;
65
- /** Base backoff in ms for exponential backoff. Default 200. */
66
- baseDelayMs?: number;
67
- /** Backoff ceiling in ms. Default 2000. */
68
- maxDelayMs?: number;
69
- /** HTTP statuses that trigger a retry. Default 408, 425, 429, 500, 502, 503, 504. */
70
- retryStatuses?: number[];
71
- }
72
- /** Per-call request options: query, idempotency, timeout, retry, extra headers. */
73
- export interface HasnaRequestOptions {
74
- /** Query string params appended to the URL. */
75
- query?: QueryParams;
76
- /**
77
- * Idempotency key sent as `Idempotency-Key`. When set, unsafe methods (POST)
78
- * become safe to retry: the server dedupes replays. Auto-generated for
79
- * `create()` in the storage client.
80
- */
81
- idempotencyKey?: string;
82
- /** Override the transport timeout for this call (ms). */
83
- timeoutMs?: number;
84
- /** Extra headers merged into this call (override transport headers). */
85
- headers?: Record<string, string>;
86
- /** Override or disable retry for this call. `false` disables retries. */
87
- retry?: HasnaRetryOptions | false;
88
- /** Caller abort signal, combined with the internal timeout. */
89
- signal?: AbortSignal;
90
- }
91
- export interface HasnaHttpTransportOptions {
92
- /** App slug (for error context / default host). */
93
- name: string;
94
- /** `<origin>/v1` base. Usually from `resolveClientTransport().baseUrl`. */
95
- baseUrl: string;
96
- /** The API key (secret). Sent as both `x-api-key` and `Authorization: Bearer`. */
97
- apiKey: string;
98
- /** Override fetch (tests). Defaults to global fetch. */
99
- fetchImpl?: FetchLike;
100
- /** Extra headers merged into every request. */
101
- headers?: Record<string, string>;
102
- /** Per-request timeout in ms. Default 30000. */
103
- timeoutMs?: number;
104
- /** Default retry policy for all requests. Pass `false` to disable. */
105
- retry?: HasnaRetryOptions | false;
106
- /** Injectable sleep (tests). Defaults to a real timer. */
107
- sleepImpl?: (ms: number) => Promise<void>;
108
- }
109
- export interface HasnaHttpTransport {
110
- readonly baseUrl: string;
111
- request<T = unknown>(method: string, path: string, body?: unknown, opts?: HasnaRequestOptions): Promise<T>;
112
- get<T = unknown>(path: string, opts?: HasnaRequestOptions): Promise<T>;
113
- post<T = unknown>(path: string, body?: unknown, opts?: HasnaRequestOptions): Promise<T>;
114
- put<T = unknown>(path: string, body?: unknown, opts?: HasnaRequestOptions): Promise<T>;
115
- patch<T = unknown>(path: string, body?: unknown, opts?: HasnaRequestOptions): Promise<T>;
116
- del<T = unknown>(path: string, body?: unknown, opts?: HasnaRequestOptions): Promise<T>;
117
- }
118
- /** Append query params to a `/v1`-relative path (no-op when empty). */
119
- export declare function appendQuery(path: string, query?: QueryParams): string;
120
- /**
121
- * Build an authenticated HTTP transport for an app's cloud `/v1` API. Sends the
122
- * API key on every request as BOTH `x-api-key` and `Authorization: Bearer`
123
- * (serve apps accept either), returns parsed JSON, times out, and retries
124
- * transient failures with exponential backoff + jitter. Never logs the key.
125
- *
126
- * Retry safety: idempotent methods (GET/HEAD/PUT/DELETE/OPTIONS) are always
127
- * retried on transient failure; POST/PATCH are retried ONLY when an
128
- * `Idempotency-Key` is supplied, so replays can't create duplicates.
129
- */
130
- export declare function createHasnaHttpTransport(options: HasnaHttpTransportOptions): HasnaHttpTransport;
131
- /**
132
- * Convenience: resolve transport from env and, when cloud-http, build the HTTP
133
- * client in one call. Returns `{ transport: 'local', resolution }` for local, or
134
- * `{ transport: 'cloud-http', client, resolution }` for cloud. Throws if the
135
- * config is `misconfigured` (cloud requested but unusable) so callers can't drift
136
- * onto local data by accident.
137
- */
138
- export declare function createClientTransport(name: string, env?: Env, overrides?: Partial<Pick<HasnaHttpTransportOptions, "fetchImpl" | "headers" | "timeoutMs" | "retry" | "sleepImpl">>): {
139
- transport: "local";
140
- client: null;
141
- resolution: ClientTransportResolution;
142
- } | {
143
- transport: "cloud-http";
144
- client: HasnaHttpTransport;
145
- resolution: ClientTransportResolution;
146
- };
147
- export {};
1
+ export { HasnaHttpError } from "@hasna/contracts/client";
148
2
  //# sourceMappingURL=transport.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"trans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AAI,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACvF,KAAK,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACzF,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CACxF;AAED,uEAAuE;AACvE,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,WAAW,GAAG,MAAM,CAgBrE;AAID;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,kBAAkB,CA6G/F;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,EACZ,GAAG,GAAE,GAAiB,EACtB,SAAS,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,yBAAyB,EAAE,WAAW,GAAG,SAAS,GAAG,WAAW,GAAG,OAAO,GAAG,WAAW,CAAC,CAAC,GAEjH;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,IAAI,CAAC;IAAC,UAAU,EAAE,yBAAyB,CAAA;CAAE,GAC3E;IAAE,SAAS,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,kBAAkB,CAAC;IAAC,UAAU,EAAE,yBAAyB,CAAA;CAAE,CA4BjG"}
1
+ {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../src/lib/contracts-client/transport.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"open-projects.d.ts","sourceRoot":"","sources":["../../src/lib/open-projects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAGxE;;;;;;GAMG;AACH,UAAU,WAAW;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,KAAK,gBAAgB,GAAG,CAAC,OAAO,EAAE;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,KAAK,WAAW,EAAE,CAAA;AAIvF,wBAAsB,wBAAwB,CAC5C,EAAE,EAAE,QAAQ,EACZ,kBAAkB,CAAC,EAAE,gBAAgB,GACpC,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CA4BhD"}
1
+ {"version":3,"file":"open-projects.d.ts","sourceRoot":"","sources":["../../src/lib/open-projects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAGxE;;;;;;GAMG;AACH,UAAU,WAAW;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,KAAK,gBAAgB,GAAG,CAAC,OAAO,EAAE;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,KAAK,WAAW,EAAE,CAAA;AAgBvF,wBAAsB,wBAAwB,CAC5C,EAAE,EAAE,QAAQ,EACZ,kBAAkB,CAAC,EAAE,gBAAgB,GACpC,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CA4BhD"}
@@ -0,0 +1,15 @@
1
+ import type { SqliteAdapter as Database } from '../db/sqlite-adapter.js';
2
+ import type { ZeroCostModelBreakdown } from '../types/index.js';
3
+ /** Tag rows that carry no machine_id with the current machine id. */
4
+ export declare function backfillMachineId(db: Database): {
5
+ requests: number;
6
+ sessions: number;
7
+ };
8
+ export interface RecalculateResult {
9
+ fixed: number;
10
+ total: number;
11
+ buckets: ZeroCostModelBreakdown[];
12
+ }
13
+ /** Re-price zero-cost requests from the pricing table; re-rolls touched sessions. */
14
+ export declare function recalculateZeroCostRequests(db: Database): Promise<RecalculateResult>;
15
+ //# sourceMappingURL=sync-maintenance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync-maintenance.d.ts","sourceRoot":"","sources":["../../src/lib/sync-maintenance.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAExE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAE/D,qEAAqE;AACrE,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,QAAQ,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAKtF;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,sBAAsB,EAAE,CAAA;CAClC;AAED,qFAAqF;AACrF,wBAAsB,2BAA2B,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAsC1F"}