which-url 0.0.7 → 0.0.8
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/README.md +55 -8
- package/dist/env-var.d.ts +1 -1
- package/dist/env-var.d.ts.map +1 -1
- package/dist/env.d.ts +1 -1
- package/dist/env.d.ts.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +59 -35
- package/dist/resolve.d.ts +2 -2
- package/dist/resolve.d.ts.map +1 -1
- package/dist/types.d.ts +12 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ Preview https://myapp-git-feat.vercel.app "preview"
|
|
|
20
20
|
Production https://myapp.com "production"
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
Works across environments (local, preview, production),
|
|
23
|
+
Works across environments (local, preview, production), browser bundles, Node/Bun servers, and edge runtimes that expose compatible env vars through `process.env` or build-time public env replacement.
|
|
24
24
|
|
|
25
25
|
The default export gives you everything as an object:
|
|
26
26
|
|
|
@@ -85,7 +85,31 @@ Reads environment variables that hosting providers set automatically:
|
|
|
85
85
|
3. `window.location.origin` (browser fallback)
|
|
86
86
|
4. `http://localhost:${PORT || 3000}` (development fallback)
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
When you call `createUrl({ env })`, the passed object replaces `process.env` as the source for steps 1–2.
|
|
89
|
+
|
|
90
|
+
If nothing is detected in production, the default singleton returns empty URL strings so imports stay safe in tests, client bundles, and build tools. Call `createUrl()` directly when a missing URL should throw.
|
|
91
|
+
|
|
92
|
+
## Strict mode with `createUrl()`
|
|
93
|
+
|
|
94
|
+
Use the default export or named constants for convenience:
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
import { origin } from 'which-url'
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Use `createUrl()` for production-critical configuration like auth, CORS, emails, and webhooks:
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
import { createUrl } from 'which-url'
|
|
104
|
+
|
|
105
|
+
const appUrl = createUrl()
|
|
106
|
+
|
|
107
|
+
auth({ baseURL: appUrl.origin })
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
`createUrl()` resolves fresh environment values when called. If no URL can be detected in production, it throws with instructions to set `APP_URL`.
|
|
111
|
+
|
|
112
|
+
For runtimes that pass env as an argument (e.g. Cloudflare Workers), call `createUrl({ env })` and the passed object replaces `process.env` for that resolution. See [Cloudflare Workers](#cloudflare-workers) below.
|
|
89
113
|
|
|
90
114
|
## Override with `APP_URL`
|
|
91
115
|
|
|
@@ -172,14 +196,32 @@ APP_URL=https://abc123.ngrok-free.app npm run dev
|
|
|
172
196
|
|
|
173
197
|
### Cloudflare Workers
|
|
174
198
|
|
|
175
|
-
Cloudflare Workers
|
|
199
|
+
Cloudflare Workers pass config through the `env` argument to `fetch`, not `process.env`. Pass it to `createUrl({ env })`:
|
|
200
|
+
|
|
201
|
+
```typescript
|
|
202
|
+
import { createUrl } from "which-url"
|
|
203
|
+
|
|
204
|
+
export default {
|
|
205
|
+
async fetch(request: Request, env: Env) {
|
|
206
|
+
const appUrl = createUrl({ env })
|
|
207
|
+
|
|
208
|
+
return Response.json({ origin: appUrl.origin, env: appUrl.env })
|
|
209
|
+
},
|
|
210
|
+
}
|
|
211
|
+
```
|
|
176
212
|
|
|
177
213
|
```toml
|
|
214
|
+
# wrangler.toml
|
|
178
215
|
[vars]
|
|
179
|
-
APP_URL = "https://
|
|
216
|
+
APP_URL = "https://api.example.com"
|
|
217
|
+
APP_ENV = "production"
|
|
180
218
|
```
|
|
181
219
|
|
|
182
|
-
|
|
220
|
+
Non-string bindings (KV, Durable Objects, R2, service bindings) are ignored automatically — only string `[vars]` participate in URL detection.
|
|
221
|
+
|
|
222
|
+
> ⚠️ The default singleton (`import appUrl from "which-url"`) and named exports (`origin`, `env`, etc.) resolve at **module load**, before your `fetch` handler runs. On Workers they will not see your `[vars]`. Use `createUrl({ env })` from inside your handler.
|
|
223
|
+
|
|
224
|
+
If you're on `nodejs_compat` and prefer `process.env`, the default singleton works too — but `createUrl({ env })` is the runtime-native path and doesn't require the compat flag.
|
|
183
225
|
|
|
184
226
|
### Debugging
|
|
185
227
|
|
|
@@ -197,7 +239,11 @@ console.log(appUrl.debug)
|
|
|
197
239
|
|
|
198
240
|
### Default export
|
|
199
241
|
|
|
200
|
-
An object with URL properties and environment helpers.
|
|
242
|
+
An import-safe singleton object with URL properties and environment helpers. It resolves once when the package is imported.
|
|
243
|
+
|
|
244
|
+
### `createUrl()`
|
|
245
|
+
|
|
246
|
+
Strict resolver function. It resolves when called and throws if no URL can be detected.
|
|
201
247
|
|
|
202
248
|
### Named exports
|
|
203
249
|
|
|
@@ -212,11 +258,12 @@ An object with URL properties and environment helpers.
|
|
|
212
258
|
| `env` | `AppEnv` | `"production"` \| `"preview"` \| `"local"` |
|
|
213
259
|
| `platform` | `Platform` | `"vercel"` \| `"netlify"` \| ... \| `null` |
|
|
214
260
|
| `debug`* | `string` | `"[provider:vercel] url=myapp.com \| env=production (vercel:production)"` |
|
|
215
|
-
|
|
216
|
-
\* `debug` is non-enumerable — excluded from `JSON.stringify` to avoid React hydration mismatches. Access via `appUrl.debug`.
|
|
217
261
|
| `isProduction` | `boolean` | |
|
|
218
262
|
| `isPreview` | `boolean` | |
|
|
219
263
|
| `isLocal` | `boolean` | |
|
|
264
|
+
| `createUrl` | `(options?: { env?: Record<string, unknown> }) => WhichUrlWithDebug` | strict resolver |
|
|
265
|
+
|
|
266
|
+
\* `debug` is non-enumerable on the default export and objects returned by `createUrl()` — excluded from `JSON.stringify` to avoid React hydration mismatches. It is also available as a named export.
|
|
220
267
|
|
|
221
268
|
## License
|
|
222
269
|
|
package/dist/env-var.d.ts
CHANGED
|
@@ -7,5 +7,5 @@
|
|
|
7
7
|
* falls back to dynamic lookup for test/server compatibility.
|
|
8
8
|
*/
|
|
9
9
|
export declare function getVar(env: Record<string, string | undefined>, name: string): string | undefined;
|
|
10
|
-
export declare function getEnv(): Record<string, string | undefined>;
|
|
10
|
+
export declare function getEnv(override?: Record<string, unknown>): Record<string, string | undefined>;
|
|
11
11
|
//# sourceMappingURL=env-var.d.ts.map
|
package/dist/env-var.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-var.d.ts","sourceRoot":"","sources":["../src/env-var.ts"],"names":[],"mappings":"AAkGA;;;;;;;GAOG;AACH,wBAAgB,MAAM,CACpB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,EACvC,IAAI,EAAE,MAAM,GACX,MAAM,GAAG,SAAS,CA4BpB;AAED,wBAAgB,MAAM,
|
|
1
|
+
{"version":3,"file":"env-var.d.ts","sourceRoot":"","sources":["../src/env-var.ts"],"names":[],"mappings":"AAkGA;;;;;;;GAOG;AACH,wBAAgB,MAAM,CACpB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,EACvC,IAAI,EAAE,MAAM,GACX,MAAM,GAAG,SAAS,CA4BpB;AAED,wBAAgB,MAAM,CACpB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAQpC"}
|
package/dist/env.d.ts
CHANGED
package/dist/env.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAIrC,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,UAAU,
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAIrC,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,UAAU,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAyB3E"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { WhichUrlWithDebug, AppEnv, Platform } from "./types";
|
|
1
|
+
import type { WhichUrlWithDebug, AppEnv, Platform, CreateUrlOptions } from "./types";
|
|
2
|
+
export declare function createUrl(options?: CreateUrlOptions): WhichUrlWithDebug;
|
|
2
3
|
declare let _resolved: WhichUrlWithDebug;
|
|
3
4
|
/** Full URL including protocol — `"https://myapp.com"` */
|
|
4
5
|
export declare const href: string;
|
|
@@ -16,6 +17,8 @@ export declare const port: string;
|
|
|
16
17
|
export declare const env: AppEnv;
|
|
17
18
|
/** Detected hosting platform — `"vercel"`, `"netlify"`, etc. or `null` */
|
|
18
19
|
export declare const platform: Platform;
|
|
20
|
+
/** Resolution debug string. */
|
|
21
|
+
export declare const debug: string;
|
|
19
22
|
/** `true` when running in production */
|
|
20
23
|
export declare const isProduction: boolean;
|
|
21
24
|
/** `true` when running in a preview/staging deployment */
|
|
@@ -36,5 +39,5 @@ export declare const isLocal: boolean;
|
|
|
36
39
|
* ```
|
|
37
40
|
*/
|
|
38
41
|
export default _resolved;
|
|
39
|
-
export type { WhichUrl, WhichUrlWithDebug, AppEnv, Platform, PlatformName } from "./types";
|
|
42
|
+
export type { WhichUrl, WhichUrlWithDebug, AppEnv, Platform, PlatformName, CreateUrlOptions } from "./types";
|
|
40
43
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OA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AAS,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -52,12 +52,24 @@ function getVar(env, name) {
|
|
|
52
52
|
}
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
|
-
function getEnv() {
|
|
55
|
+
function getEnv(override) {
|
|
56
|
+
if (override !== undefined) {
|
|
57
|
+
return filterStrings(override);
|
|
58
|
+
}
|
|
56
59
|
if (typeof process !== "undefined" && process?.env) {
|
|
57
60
|
return process.env;
|
|
58
61
|
}
|
|
59
62
|
return {};
|
|
60
63
|
}
|
|
64
|
+
function filterStrings(source) {
|
|
65
|
+
const out = {};
|
|
66
|
+
for (const key in source) {
|
|
67
|
+
const value = source[key];
|
|
68
|
+
if (typeof value === "string")
|
|
69
|
+
out[key] = value;
|
|
70
|
+
}
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
61
73
|
|
|
62
74
|
// src/providers.ts
|
|
63
75
|
var providers = [
|
|
@@ -156,8 +168,8 @@ function normalizeUrl(raw) {
|
|
|
156
168
|
}
|
|
157
169
|
|
|
158
170
|
// src/resolve.ts
|
|
159
|
-
function resolveUrl() {
|
|
160
|
-
const env = getEnv();
|
|
171
|
+
function resolveUrl(envOverride) {
|
|
172
|
+
const env = getEnv(envOverride);
|
|
161
173
|
const override = getVar(env, "APP_URL");
|
|
162
174
|
if (override)
|
|
163
175
|
return { url: normalizeUrl(override), debugLabel: `[override] APP_URL=${override}` };
|
|
@@ -184,8 +196,8 @@ function resolveUrl() {
|
|
|
184
196
|
}
|
|
185
197
|
throw new Error("which-url: Cannot detect app URL. Set APP_URL environment variable.");
|
|
186
198
|
}
|
|
187
|
-
function resolvePlatform() {
|
|
188
|
-
const env = getEnv();
|
|
199
|
+
function resolvePlatform(envOverride) {
|
|
200
|
+
const env = getEnv(envOverride);
|
|
189
201
|
for (const p of providers) {
|
|
190
202
|
if (p.detect(env)) {
|
|
191
203
|
return p.name;
|
|
@@ -196,8 +208,8 @@ function resolvePlatform() {
|
|
|
196
208
|
|
|
197
209
|
// src/env.ts
|
|
198
210
|
var validEnvs = ["production", "preview", "local"];
|
|
199
|
-
function resolveEnv() {
|
|
200
|
-
const env = getEnv();
|
|
211
|
+
function resolveEnv(envOverride) {
|
|
212
|
+
const env = getEnv(envOverride);
|
|
201
213
|
const appEnv = getVar(env, "APP_ENV");
|
|
202
214
|
if (appEnv && validEnvs.includes(appEnv)) {
|
|
203
215
|
return { env: appEnv, debugLabel: `APP_ENV=${appEnv}` };
|
|
@@ -216,11 +228,20 @@ function resolveEnv() {
|
|
|
216
228
|
}
|
|
217
229
|
|
|
218
230
|
// src/index.ts
|
|
219
|
-
function
|
|
220
|
-
|
|
231
|
+
function makeDebugNonEnumerable(result) {
|
|
232
|
+
Object.defineProperty(result, "debug", {
|
|
233
|
+
value: result.debug,
|
|
234
|
+
enumerable: false,
|
|
235
|
+
configurable: false
|
|
236
|
+
});
|
|
237
|
+
return result;
|
|
238
|
+
}
|
|
239
|
+
function createUrl(options) {
|
|
240
|
+
const envOverride = options?.env;
|
|
241
|
+
const { url, debugLabel: urlDebug } = resolveUrl(envOverride);
|
|
221
242
|
const parsed = new URL(url);
|
|
222
|
-
const { env, debugLabel: envDebug } = resolveEnv();
|
|
223
|
-
const platform = resolvePlatform();
|
|
243
|
+
const { env, debugLabel: envDebug } = resolveEnv(envOverride);
|
|
244
|
+
const platform = resolvePlatform(envOverride);
|
|
224
245
|
const debug = `${urlDebug} | env=${env} (${envDebug})`;
|
|
225
246
|
const result = {
|
|
226
247
|
href: parsed.origin,
|
|
@@ -236,18 +257,17 @@ function resolve() {
|
|
|
236
257
|
isPreview: env === "preview",
|
|
237
258
|
isLocal: env === "local"
|
|
238
259
|
};
|
|
239
|
-
|
|
240
|
-
value: debug,
|
|
241
|
-
enumerable: false,
|
|
242
|
-
configurable: false
|
|
243
|
-
});
|
|
244
|
-
return result;
|
|
260
|
+
return makeDebugNonEnumerable(result);
|
|
245
261
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
262
|
+
function createFallback(error) {
|
|
263
|
+
const message = error instanceof Error ? error.message : "resolution failed";
|
|
264
|
+
let resolvedEnv = "local";
|
|
265
|
+
let envDebug = "default";
|
|
266
|
+
try {
|
|
267
|
+
const result = resolveEnv();
|
|
268
|
+
resolvedEnv = result.env;
|
|
269
|
+
envDebug = result.debugLabel;
|
|
270
|
+
} catch {}
|
|
251
271
|
const fallback = {
|
|
252
272
|
href: "",
|
|
253
273
|
origin: "",
|
|
@@ -255,19 +275,20 @@ try {
|
|
|
255
275
|
host: "",
|
|
256
276
|
protocol: "",
|
|
257
277
|
port: "",
|
|
258
|
-
env:
|
|
259
|
-
platform:
|
|
260
|
-
debug:
|
|
261
|
-
isProduction:
|
|
262
|
-
isPreview:
|
|
263
|
-
isLocal:
|
|
278
|
+
env: resolvedEnv,
|
|
279
|
+
platform: resolvePlatform(),
|
|
280
|
+
debug: `[error] ${message} | env=${resolvedEnv} (${envDebug})`,
|
|
281
|
+
isProduction: resolvedEnv === "production",
|
|
282
|
+
isPreview: resolvedEnv === "preview",
|
|
283
|
+
isLocal: resolvedEnv === "local"
|
|
264
284
|
};
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
285
|
+
return makeDebugNonEnumerable(fallback);
|
|
286
|
+
}
|
|
287
|
+
var _resolved;
|
|
288
|
+
try {
|
|
289
|
+
_resolved = createUrl();
|
|
290
|
+
} catch (e) {
|
|
291
|
+
_resolved = createFallback(e);
|
|
271
292
|
}
|
|
272
293
|
var href = _resolved.href;
|
|
273
294
|
var origin = _resolved.origin;
|
|
@@ -277,6 +298,7 @@ var protocol = _resolved.protocol;
|
|
|
277
298
|
var port = _resolved.port;
|
|
278
299
|
var env = _resolved.env;
|
|
279
300
|
var platform = _resolved.platform;
|
|
301
|
+
var debug = _resolved.debug;
|
|
280
302
|
var isProduction = _resolved.isProduction;
|
|
281
303
|
var isPreview = _resolved.isPreview;
|
|
282
304
|
var isLocal = _resolved.isLocal;
|
|
@@ -293,5 +315,7 @@ export {
|
|
|
293
315
|
hostname,
|
|
294
316
|
host,
|
|
295
317
|
env,
|
|
296
|
-
src_default as default
|
|
318
|
+
src_default as default,
|
|
319
|
+
debug,
|
|
320
|
+
createUrl
|
|
297
321
|
};
|
package/dist/resolve.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ export interface ResolveResult {
|
|
|
3
3
|
url: string;
|
|
4
4
|
debugLabel: string;
|
|
5
5
|
}
|
|
6
|
-
export declare function resolveUrl(): ResolveResult;
|
|
7
|
-
export declare function resolvePlatform(): Platform;
|
|
6
|
+
export declare function resolveUrl(envOverride?: Record<string, unknown>): ResolveResult;
|
|
7
|
+
export declare function resolvePlatform(envOverride?: Record<string, unknown>): Platform;
|
|
8
8
|
//# sourceMappingURL=resolve.d.ts.map
|
package/dist/resolve.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEvC,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,UAAU,
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEvC,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,UAAU,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa,CAuC/E;AAED,wBAAgB,eAAe,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,QAAQ,CAQ/E"}
|
package/dist/types.d.ts
CHANGED
|
@@ -29,6 +29,18 @@ export interface WhichUrlWithDebug extends WhichUrl {
|
|
|
29
29
|
/** Resolution debug string (non-enumerable — excluded from JSON.stringify and object spread). */
|
|
30
30
|
readonly debug: string;
|
|
31
31
|
}
|
|
32
|
+
export interface CreateUrlOptions {
|
|
33
|
+
/**
|
|
34
|
+
* Runtime environment source. Pass this when `process.env` isn't available
|
|
35
|
+
* or doesn't contain your config — e.g. on Cloudflare Workers, where the
|
|
36
|
+
* Worker `env` argument carries `[vars]` from `wrangler.toml`.
|
|
37
|
+
*
|
|
38
|
+
* When provided, `process.env` is ignored entirely. Only string-valued
|
|
39
|
+
* entries participate in URL detection — non-string Workers bindings
|
|
40
|
+
* (KV namespaces, Durable Objects, R2 buckets, service bindings) are dropped.
|
|
41
|
+
*/
|
|
42
|
+
env?: Record<string, unknown>;
|
|
43
|
+
}
|
|
32
44
|
export interface ProviderDetector {
|
|
33
45
|
name: PlatformName;
|
|
34
46
|
detect: (env: Record<string, string | undefined>) => boolean;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GAAG,YAAY,GAAG,SAAS,GAAG,OAAO,CAAA;AAEvD,MAAM,MAAM,YAAY,GACpB,QAAQ,GACR,SAAS,GACT,YAAY,GACZ,SAAS,GACT,KAAK,GACL,QAAQ,GACR,cAAc,GACd,QAAQ,CAAA;AAEZ,MAAM,MAAM,QAAQ,GAAG,YAAY,GAAG,IAAI,CAAA;AAE1C,MAAM,WAAW,QAAQ;IACvB,0DAA0D;IAC1D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,yDAAyD;IACzD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,4CAA4C;IAC5C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB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