@happyvertical/smrt-places 0.51.31 → 0.51.33

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/dist/types.d.ts CHANGED
@@ -1,253 +1,166 @@
1
- import { Asset } from '@happyvertical/smrt-assets';
2
- import { SmrtHierarchical } from '@happyvertical/smrt-core';
3
- import { SmrtObject } from '@happyvertical/smrt-core';
4
- import { SmrtObjectOptions } from '@happyvertical/smrt-core';
5
-
6
- /**
7
- * Options for `PlaceCollection.discoverNearby`. Mirrors the inputs to
8
- * `@happyvertical/geo`'s `findPoisNear` plus a couple of persistence knobs
9
- * (PlaceType override, parent linkage) to match `lookupOrCreate`'s shape.
10
- */
11
- export declare interface DiscoverNearbyOptions {
12
- /** Which geo provider to use. Defaults to openstreetmap. */
13
- geoProvider?: 'google' | 'openstreetmap';
14
- /**
15
- * POI category filter, forwarded to the provider. See
16
- * `@happyvertical/geo`'s `PoiSearchOptions.types` for provider-specific
17
- * interpretation.
18
- */
19
- types?: string[];
20
- /** Free-text keyword filter (provider-dependent; Google only). */
21
- keyword?: string;
22
- /** Max results per provider call. Default 20. */
23
- limit?: number;
24
- /** Preferred language for place names (Google only). */
25
- language?: string;
26
- /** Override the PlaceType slug assigned to created rows. */
27
- typeSlug?: string;
28
- /** Set parent place on created rows. */
29
- parentId?: string | null;
30
- }
31
-
32
- /**
33
- * Geographic data structure
34
- * All fields optional to support both real-world and abstract places
35
- */
36
- export declare interface GeoData {
37
- latitude: number | null;
38
- longitude: number | null;
39
- streetNumber?: string;
40
- streetName?: string;
41
- city?: string;
42
- region?: string;
43
- country?: string;
44
- postalCode?: string;
45
- countryCode?: string;
46
- timezone?: string;
47
- }
48
-
49
- /**
50
- * Options for lookupOrCreate method
51
- */
52
- export declare interface LookupOrCreateOptions {
53
- /**
54
- * Which geo provider to use for lookups
55
- */
56
- geoProvider?: 'google' | 'openstreetmap';
57
- /**
58
- * Force a specific place type
59
- */
60
- typeSlug?: string;
61
- /**
62
- * Set parent place if known
63
- */
64
- parentId?: string | null;
65
- /**
66
- * Whether to create if not found (default: true)
67
- */
68
- createIfNotFound?: boolean;
69
- /**
70
- * Coordinates for reverse geocoding
71
- */
72
- coords?: {
73
- lat: number;
74
- lng: number;
75
- };
76
- }
77
-
78
- declare class Place extends SmrtHierarchical {
79
- tenantId: string | null;
80
- typeId: string;
81
- name: string;
82
- description: string;
83
- latitude: number | null;
84
- longitude: number | null;
85
- streetNumber: string;
86
- streetName: string;
87
- city: string;
88
- region: string;
89
- country: string;
90
- postalCode: string;
91
- countryCode: string;
92
- timezone: string;
93
- externalId: string;
94
- source: string;
95
- metadata: string;
96
- createdAt: Date;
97
- updatedAt: Date;
98
- constructor(options?: PlaceOptions);
99
- /**
100
- * Get geographic data for this place
101
- *
102
- * @returns GeoData object with all geo fields
103
- */
104
- getGeoData(): GeoData;
105
- /**
106
- * Check if this place has geographic coordinates
107
- *
108
- * @returns True if latitude and longitude are set
109
- */
110
- hasCoordinates(): boolean;
111
- /**
112
- * Get metadata as parsed object
113
- *
114
- * @returns Parsed metadata object or empty object if no metadata
115
- */
116
- getMetadata(): Record<string, unknown>;
117
- /**
118
- * Set metadata from object
119
- *
120
- * @param data - Metadata object to store
121
- */
122
- setMetadata(data: Record<string, unknown>): void;
123
- /**
124
- * Update metadata by merging with existing values
125
- *
126
- * @param updates - Partial metadata to merge
127
- */
128
- updateMetadata(updates: Record<string, unknown>): void;
129
- /**
130
- * Get the place type
131
- *
132
- * @returns PlaceType instance or null if not found
133
- */
134
- getType(): Promise< PlaceType | null>;
135
- private getPlaceAssetCollection;
136
- getAssets(relationship?: string): Promise<Asset[]>;
137
- addAsset(asset: Asset, relationship?: string, sortOrder?: number): Promise<void>;
138
- removeAsset(assetId: string, relationship?: string): Promise<void>;
139
- }
140
-
141
- /**
142
- * Place hierarchy structure
143
- */
144
- export declare interface PlaceHierarchy {
145
- ancestors: Place[];
146
- current: Place;
147
- descendants: Place[];
148
- }
149
-
150
- /**
151
- * Options for creating/updating a Place
152
- */
153
- export declare interface PlaceOptions extends SmrtObjectOptions {
154
- id?: string;
155
- tenantId?: string | null;
156
- typeId?: string;
157
- parentId?: string | null;
158
- name?: string;
159
- description?: string;
160
- latitude?: number | null;
161
- longitude?: number | null;
162
- streetNumber?: string;
163
- streetName?: string;
164
- city?: string;
165
- region?: string;
166
- country?: string;
167
- postalCode?: string;
168
- countryCode?: string;
169
- timezone?: string;
170
- externalId?: string;
171
- source?: string;
172
- metadata?: Record<string, unknown> | string;
173
- createdAt?: Date;
174
- updatedAt?: Date;
175
- }
176
-
177
- declare class PlaceType extends SmrtObject {
178
- name: string;
179
- description?: string;
180
- createdAt: Date;
181
- updatedAt: Date;
182
- constructor(options?: PlaceTypeOptions);
183
- /**
184
- * Convenience method for slug-based lookup
185
- *
186
- * @param slug - The slug to search for
187
- * @returns PlaceType instance or null if not found
188
- */
189
- static getBySlug(_slug: string): Promise<PlaceType | null>;
190
- }
191
-
192
- /**
193
- * Options for creating/updating a PlaceType
194
- */
195
- export declare interface PlaceTypeOptions extends SmrtObjectOptions {
196
- id?: string;
197
- slug?: string;
198
- name?: string;
199
- description?: string;
200
- createdAt?: Date;
201
- updatedAt?: Date;
202
- }
203
-
204
- /**
205
- * Options for `PlaceCollection.resolveTrackPlaces`. Extends
206
- * `DiscoverNearbyOptions` with per-track knobs that control how the track
207
- * is bucketed + throttled before hitting the geo provider.
208
- */
209
- export declare interface ResolveTrackPlacesOptions extends DiscoverNearbyOptions {
210
- /**
211
- * Per-point POI search radius in meters. Default 50.
212
- */
213
- radiusMeters?: number;
214
- /**
215
- * Collapse points within this distance (m) into a single bucket so we
216
- * don't re-query the same ~50m area dozens of times for a slow drive-by.
217
- * Default 50.
218
- */
219
- bucketMeters?: number;
220
- /**
221
- * Minimum delay between provider requests. Default 1100ms — safely above
222
- * OSM's 1 req/sec community limit. Google can usually handle faster; set
223
- * to 100ms or less for paid tiers.
224
- */
225
- throttleMs?: number;
226
- }
227
-
228
- /**
229
- * Result of `PlaceCollection.resolveTrackPlaces`. Tracks are typically
230
- * long-running operations so the return payload includes counters that let
231
- * callers surface progress or estimate cost without re-walking.
232
- */
233
- export declare interface TrackPlacesResult {
234
- /** De-duplicated Place rows touched during resolution. */
235
- places: Place[];
236
- /** Number of provider requests issued. */
237
- requestCount: number;
238
- /** Number of bucketed points that reused existing Place rows. */
239
- cacheHitCount: number;
240
- /** Number of distinct geographic buckets walked. */
241
- bucketCount: number;
242
- }
243
-
244
- /**
245
- * A single point along a track. Matches the `{ lat, lng }` convention used
246
- * by `LookupOrCreateOptions.coords` so callers don't have to shuffle shapes.
247
- */
248
- export declare interface TrackPoint {
249
- lat: number;
250
- lng: number;
251
- }
252
-
253
- export { }
1
+ /**
2
+ * Type definitions for @have/places package
3
+ */
4
+ import type { SmrtObjectOptions } from '@happyvertical/smrt-core';
5
+ import type { Place } from './models/Place';
6
+ /**
7
+ * Geographic data structure
8
+ * All fields optional to support both real-world and abstract places
9
+ */
10
+ export interface GeoData {
11
+ latitude: number | null;
12
+ longitude: number | null;
13
+ streetNumber?: string;
14
+ streetName?: string;
15
+ city?: string;
16
+ region?: string;
17
+ country?: string;
18
+ postalCode?: string;
19
+ countryCode?: string;
20
+ timezone?: string;
21
+ }
22
+ /**
23
+ * Options for creating/updating a Place
24
+ */
25
+ export interface PlaceOptions extends SmrtObjectOptions {
26
+ id?: string;
27
+ tenantId?: string | null;
28
+ typeId?: string;
29
+ parentId?: string | null;
30
+ name?: string;
31
+ description?: string;
32
+ latitude?: number | null;
33
+ longitude?: number | null;
34
+ streetNumber?: string;
35
+ streetName?: string;
36
+ city?: string;
37
+ region?: string;
38
+ country?: string;
39
+ postalCode?: string;
40
+ countryCode?: string;
41
+ timezone?: string;
42
+ externalId?: string;
43
+ source?: string;
44
+ metadata?: Record<string, unknown> | string;
45
+ createdAt?: Date;
46
+ updatedAt?: Date;
47
+ }
48
+ /**
49
+ * Options for creating/updating a PlaceType
50
+ */
51
+ export interface PlaceTypeOptions extends SmrtObjectOptions {
52
+ id?: string;
53
+ slug?: string;
54
+ name?: string;
55
+ description?: string;
56
+ createdAt?: Date;
57
+ updatedAt?: Date;
58
+ }
59
+ /**
60
+ * Options for lookupOrCreate method
61
+ */
62
+ export interface LookupOrCreateOptions {
63
+ /**
64
+ * Which geo provider to use for lookups
65
+ */
66
+ geoProvider?: 'google' | 'openstreetmap';
67
+ /**
68
+ * Force a specific place type
69
+ */
70
+ typeSlug?: string;
71
+ /**
72
+ * Set parent place if known
73
+ */
74
+ parentId?: string | null;
75
+ /**
76
+ * Whether to create if not found (default: true)
77
+ */
78
+ createIfNotFound?: boolean;
79
+ /**
80
+ * Coordinates for reverse geocoding
81
+ */
82
+ coords?: {
83
+ lat: number;
84
+ lng: number;
85
+ };
86
+ }
87
+ /**
88
+ * Place hierarchy structure
89
+ */
90
+ export interface PlaceHierarchy {
91
+ ancestors: Place[];
92
+ current: Place;
93
+ descendants: Place[];
94
+ }
95
+ /**
96
+ * Options for `PlaceCollection.discoverNearby`. Mirrors the inputs to
97
+ * `@happyvertical/geo`'s `findPoisNear` plus a couple of persistence knobs
98
+ * (PlaceType override, parent linkage) to match `lookupOrCreate`'s shape.
99
+ */
100
+ export interface DiscoverNearbyOptions {
101
+ /** Which geo provider to use. Defaults to openstreetmap. */
102
+ geoProvider?: 'google' | 'openstreetmap';
103
+ /**
104
+ * POI category filter, forwarded to the provider. See
105
+ * `@happyvertical/geo`'s `PoiSearchOptions.types` for provider-specific
106
+ * interpretation.
107
+ */
108
+ types?: string[];
109
+ /** Free-text keyword filter (provider-dependent; Google only). */
110
+ keyword?: string;
111
+ /** Max results per provider call. Default 20. */
112
+ limit?: number;
113
+ /** Preferred language for place names (Google only). */
114
+ language?: string;
115
+ /** Override the PlaceType slug assigned to created rows. */
116
+ typeSlug?: string;
117
+ /** Set parent place on created rows. */
118
+ parentId?: string | null;
119
+ }
120
+ /**
121
+ * A single point along a track. Matches the `{ lat, lng }` convention used
122
+ * by `LookupOrCreateOptions.coords` so callers don't have to shuffle shapes.
123
+ */
124
+ export interface TrackPoint {
125
+ lat: number;
126
+ lng: number;
127
+ }
128
+ /**
129
+ * Options for `PlaceCollection.resolveTrackPlaces`. Extends
130
+ * `DiscoverNearbyOptions` with per-track knobs that control how the track
131
+ * is bucketed + throttled before hitting the geo provider.
132
+ */
133
+ export interface ResolveTrackPlacesOptions extends DiscoverNearbyOptions {
134
+ /**
135
+ * Per-point POI search radius in meters. Default 50.
136
+ */
137
+ radiusMeters?: number;
138
+ /**
139
+ * Collapse points within this distance (m) into a single bucket so we
140
+ * don't re-query the same ~50m area dozens of times for a slow drive-by.
141
+ * Default 50.
142
+ */
143
+ bucketMeters?: number;
144
+ /**
145
+ * Minimum delay between provider requests. Default 1100ms — safely above
146
+ * OSM's 1 req/sec community limit. Google can usually handle faster; set
147
+ * to 100ms or less for paid tiers.
148
+ */
149
+ throttleMs?: number;
150
+ }
151
+ /**
152
+ * Result of `PlaceCollection.resolveTrackPlaces`. Tracks are typically
153
+ * long-running operations so the return payload includes counters that let
154
+ * callers surface progress or estimate cost without re-walking.
155
+ */
156
+ export interface TrackPlacesResult {
157
+ /** De-duplicated Place rows touched during resolution. */
158
+ places: Place[];
159
+ /** Number of provider requests issued. */
160
+ requestCount: number;
161
+ /** Number of bucketed points that reused existing Place rows. */
162
+ cacheHitCount: number;
163
+ /** Number of distinct geographic buckets walked. */
164
+ bucketCount: number;
165
+ }
166
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C;;;GAGG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,MAAM,G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;AACH,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;GAIG;AACH,MAAM,WAAW,yBAA0B,SAAQ,qBAAqB;IACtE;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,0DAA0D;IAC1D,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,0CAA0C;IAC1C,YAAY,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,aAAa,EAAE,MAAM,CAAC;IACtB,oDAAoD;IACpD,WAAW,EAAE,MAAM,CAAC;CACrB"}
package/dist/utils.d.ts CHANGED
@@ -1,113 +1,90 @@
1
- import { Location } from '@happyvertical/geo';
2
-
3
- /**
4
- * Check if two coordinates are within a threshold distance
5
- *
6
- * @param lat1 - First latitude
7
- * @param lng1 - First longitude
8
- * @param lat2 - Second latitude
9
- * @param lng2 - Second longitude
10
- * @param thresholdKm - Distance threshold in kilometers
11
- * @returns True if coordinates are within threshold
12
- */
13
- export declare function areCoordinatesNear(lat1: number, lng1: number, lat2: number, lng2: number, thresholdKm?: number): boolean;
14
-
15
- /**
16
- * Calculate distance between two coordinates using Haversine formula
17
- *
18
- * @param lat1 - First latitude
19
- * @param lng1 - First longitude
20
- * @param lat2 - Second latitude
21
- * @param lng2 - Second longitude
22
- * @returns Distance in kilometers
23
- */
24
- export declare function calculateDistance(lat1: number, lng1: number, lat2: number, lng2: number): number;
25
-
26
- /**
27
- * Format coordinates as string
28
- *
29
- * @param latitude - Latitude value
30
- * @param longitude - Longitude value
31
- * @param precision - Number of decimal places (default: 6)
32
- * @returns Formatted coordinate string
33
- */
34
- export declare function formatCoordinates(latitude: number, longitude: number, precision?: number): string;
35
-
36
- /**
37
- * Generate a display name from address components
38
- *
39
- * @param components - Address components
40
- * @returns Formatted display name
41
- */
42
- export declare function generateDisplayName(components: Partial<GeoData>): string;
43
-
44
- /**
45
- * Geographic data structure
46
- * All fields optional to support both real-world and abstract places
47
- */
48
- declare interface GeoData {
49
- latitude: number | null;
50
- longitude: number | null;
51
- streetNumber?: string;
52
- streetName?: string;
53
- city?: string;
54
- region?: string;
55
- country?: string;
56
- postalCode?: string;
57
- countryCode?: string;
58
- timezone?: string;
59
- }
60
-
61
- /**
62
- * Convert Location from @happyvertical/geo to GeoData
63
- *
64
- * @param location - Location from geocoding
65
- * @returns GeoData object
66
- */
67
- export declare function locationToGeoData(location: Location): GeoData;
68
-
69
- /**
70
- * Map Location type from @happyvertical/geo to PlaceType slug
71
- *
72
- * @param locationType - Location type from geocoding provider
73
- * @returns PlaceType slug
74
- */
75
- export declare function mapLocationTypeToPlaceType(locationType: string): string;
76
-
77
- /**
78
- * Normalize address components by trimming and removing empty values
79
- *
80
- * @param components - Address components
81
- * @returns Normalized components
82
- */
83
- export declare function normalizeAddressComponents(components: Partial<GeoData>): Partial<GeoData>;
84
-
85
- /**
86
- * Parse coordinate string to lat/lng
87
- *
88
- * Supports formats:
89
- * - "lat, lng"
90
- * - "lat,lng"
91
- * - "lat lng"
92
- *
93
- * @param coordString - Coordinate string
94
- * @returns Object with lat and lng, or null if invalid
95
- */
96
- export declare function parseCoordinates(coordString: string): {
97
- lat: number;
98
- lng: number;
99
- } | null;
100
-
101
- /**
102
- * Validate geographic coordinates
103
- *
104
- * @param latitude - Latitude value
105
- * @param longitude - Longitude value
106
- * @returns Object with valid flag and optional error message
107
- */
108
- export declare function validateCoordinates(latitude: number, longitude: number): {
109
- valid: boolean;
110
- error?: string;
111
- };
112
-
113
- export { }
1
+ /**
2
+ * Utility functions for @have/places package
3
+ */
4
+ import type { Location } from '@happyvertical/geo';
5
+ import type { GeoData } from './types';
6
+ /**
7
+ * Map Location type from @happyvertical/geo to PlaceType slug
8
+ *
9
+ * @param locationType - Location type from geocoding provider
10
+ * @returns PlaceType slug
11
+ */
12
+ export declare function mapLocationTypeToPlaceType(locationType: string): string;
13
+ /**
14
+ * Convert Location from @happyvertical/geo to GeoData
15
+ *
16
+ * @param location - Location from geocoding
17
+ * @returns GeoData object
18
+ */
19
+ export declare function locationToGeoData(location: Location): GeoData;
20
+ /**
21
+ * Validate geographic coordinates
22
+ *
23
+ * @param latitude - Latitude value
24
+ * @param longitude - Longitude value
25
+ * @returns Object with valid flag and optional error message
26
+ */
27
+ export declare function validateCoordinates(latitude: number, longitude: number): {
28
+ valid: boolean;
29
+ error?: string;
30
+ };
31
+ /**
32
+ * Calculate distance between two coordinates using Haversine formula
33
+ *
34
+ * @param lat1 - First latitude
35
+ * @param lng1 - First longitude
36
+ * @param lat2 - Second latitude
37
+ * @param lng2 - Second longitude
38
+ * @returns Distance in kilometers
39
+ */
40
+ export declare function calculateDistance(lat1: number, lng1: number, lat2: number, lng2: number): number;
41
+ /**
42
+ * Format coordinates as string
43
+ *
44
+ * @param latitude - Latitude value
45
+ * @param longitude - Longitude value
46
+ * @param precision - Number of decimal places (default: 6)
47
+ * @returns Formatted coordinate string
48
+ */
49
+ export declare function formatCoordinates(latitude: number, longitude: number, precision?: number): string;
50
+ /**
51
+ * Parse coordinate string to lat/lng
52
+ *
53
+ * Supports formats:
54
+ * - "lat, lng"
55
+ * - "lat,lng"
56
+ * - "lat lng"
57
+ *
58
+ * @param coordString - Coordinate string
59
+ * @returns Object with lat and lng, or null if invalid
60
+ */
61
+ export declare function parseCoordinates(coordString: string): {
62
+ lat: number;
63
+ lng: number;
64
+ } | null;
65
+ /**
66
+ * Normalize address components by trimming and removing empty values
67
+ *
68
+ * @param components - Address components
69
+ * @returns Normalized components
70
+ */
71
+ export declare function normalizeAddressComponents(components: Partial<GeoData>): Partial<GeoData>;
72
+ /**
73
+ * Generate a display name from address components
74
+ *
75
+ * @param components - Address components
76
+ * @returns Formatted display name
77
+ */
78
+ export declare function generateDisplayName(components: Partial<GeoData>): string;
79
+ /**
80
+ * Check if two coordinates are within a threshold distance
81
+ *
82
+ * @param lat1 - First latitude
83
+ * @param lng1 - First longitude
84
+ * @param lat2 - Second latitude
85
+ * @param lng2 - Second longitude
86
+ * @param thresholdKm - Distance threshold in kilometers
87
+ * @returns True if coordinates are within threshold
88
+ */
89
+ export declare function areCoordinatesNear(lat1: number, lng1: number, lat2: number, lng2: number, thresholdKm?: number): boolean;
90
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAoBvE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAe7D;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAChB;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAUpC;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,MAAM,CAcR;AASD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,SAAS,GAAE,MAAU,GACpB,MAAM,CAER;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,MAAM,GAClB;IAAE,GAAG,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