@makeswift/runtime 0.24.2-canary.0 → 0.24.2
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/cjs/next/api-handler/handlers/manifest.js +1 -1
- package/dist/cjs/next/api-handler/handlers/redirect-preview.js +4 -3
- package/dist/cjs/next/api-handler/handlers/redirect-preview.js.map +1 -1
- package/dist/esm/next/api-handler/handlers/manifest.js +1 -1
- package/dist/esm/next/api-handler/handlers/redirect-preview.js +4 -3
- package/dist/esm/next/api-handler/handlers/redirect-preview.js.map +1 -1
- package/package.json +1 -1
|
@@ -37,7 +37,7 @@ async function handler(...args) {
|
|
|
37
37
|
const supportsDraftMode = (0, import_ts_pattern.match)(args).with(routeHandlerPattern, () => true).with(apiRoutePattern, () => false).exhaustive();
|
|
38
38
|
const supportsWebhook = (0, import_ts_pattern.match)(args).with(routeHandlerPattern, () => true).with(apiRoutePattern, () => false).exhaustive();
|
|
39
39
|
const body = {
|
|
40
|
-
version: "0.24.2
|
|
40
|
+
version: "0.24.2",
|
|
41
41
|
previewMode: supportsPreviewMode,
|
|
42
42
|
draftMode: supportsDraftMode,
|
|
43
43
|
interactionMode: true,
|
|
@@ -39,14 +39,15 @@ async function redirectPreviewRouteHandler(_request, _context, {}) {
|
|
|
39
39
|
}
|
|
40
40
|
async function redirectPreviewApiRouteHandler(req, res, { apiKey }) {
|
|
41
41
|
const secret = req.query[import_draft.SearchParams.PreviewMode];
|
|
42
|
+
const pathname = req.query.path;
|
|
42
43
|
if (secret == null) {
|
|
43
44
|
return res.status(401).send("Unauthorized to enable preview mode: no secret provided");
|
|
44
45
|
}
|
|
45
46
|
if (secret !== apiKey) {
|
|
46
47
|
return res.status(401).send("Unauthorized to enable preview mode: secret is incorrect");
|
|
47
48
|
}
|
|
48
|
-
if (
|
|
49
|
-
return res.status(400).send("Bad request: incoming request does not have
|
|
49
|
+
if (pathname == null) {
|
|
50
|
+
return res.status(400).send("Bad request: incoming request does not have an associated pathname");
|
|
50
51
|
}
|
|
51
52
|
const setCookie = res.setPreviewData({ makeswift: true, siteVersion: import_site_version.MakeswiftSiteVersion.Working }).getHeader(import_draft.SET_COOKIE_HEADER);
|
|
52
53
|
res.removeHeader(import_draft.SET_COOKIE_HEADER);
|
|
@@ -60,7 +61,7 @@ async function redirectPreviewApiRouteHandler(req, res, { apiKey }) {
|
|
|
60
61
|
return (0, import_cookie.serialize)(name, value, { ...import_draft.cookieSettingOptions });
|
|
61
62
|
});
|
|
62
63
|
res.setHeader(import_draft.SET_COOKIE_HEADER, patchedCookies);
|
|
63
|
-
const destinationUrl = new URL(
|
|
64
|
+
const destinationUrl = new URL(pathname, "http://test.com");
|
|
64
65
|
destinationUrl.searchParams.delete(import_draft.SearchParams.PreviewMode);
|
|
65
66
|
res.redirect(`${destinationUrl.pathname}?${destinationUrl.searchParams.toString()}`);
|
|
66
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/next/api-handler/handlers/redirect-preview.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { NextRequest, NextResponse } from 'next/server'\nimport { P, match } from 'ts-pattern'\n\nimport { parse as parseSetCookie } from 'set-cookie-parser'\nimport { serialize as serializeCookie } from 'cookie'\n\nimport { MakeswiftSiteVersion } from '../../../api/site-version'\nimport {\n cookieSettingOptions,\n PRERENDER_BYPASS_COOKIE,\n PREVIEW_DATA_COOKIE,\n SearchParams,\n SET_COOKIE_HEADER,\n} from './utils/draft'\n\ntype Context = { params: { [key: string]: string | string[] } }\n\ntype RedirectPreviewError = string\n\ntype Response = unknown\n\nexport type RedirectPreviewResponse = RedirectPreviewError | Response\n\ntype RedirectPreviewHandlerArgs =\n | [request: NextRequest, context: Context, params: { apiKey: string }]\n | [req: NextApiRequest, res: NextApiResponse<RedirectPreviewResponse>, params: { apiKey: string }]\n\nconst routeHandlerPattern = [P.instanceOf(Request), P.any, P.any] as const\nconst apiRoutePattern = [P.any, P.any, P.any] as const\n\nexport default async function redirectPreviewHandler(\n request: NextRequest,\n context: Context,\n { apiKey }: { apiKey: string },\n): Promise<NextResponse<RedirectPreviewResponse>>\nexport default async function redirectPreviewHandler(\n req: NextApiRequest,\n res: NextApiResponse<RedirectPreviewResponse>,\n { apiKey }: { apiKey: string },\n): Promise<void>\nexport default async function redirectPreviewHandler(\n ...args: RedirectPreviewHandlerArgs\n): Promise<NextResponse<RedirectPreviewResponse> | void> {\n return match(args)\n .with(routeHandlerPattern, args => redirectPreviewRouteHandler(...args))\n .with(apiRoutePattern, args => redirectPreviewApiRouteHandler(...args))\n .exhaustive()\n}\n\nasync function redirectPreviewRouteHandler(\n _request: NextRequest,\n _context: Context,\n {}: { apiKey: string },\n): Promise<NextResponse<RedirectPreviewResponse>> {\n const message =\n 'Cannot request preview endpoint from an API handler registered in `app`. Move your Makeswift API handler to the `pages/api` directory'\n console.error(message)\n return NextResponse.json(message, { status: 500 })\n}\n\nasync function redirectPreviewApiRouteHandler(\n req: NextApiRequest,\n res: NextApiResponse<RedirectPreviewResponse>,\n { apiKey }: { apiKey: string },\n): Promise<void> {\n const secret = req.query[SearchParams.PreviewMode]\n\n if (secret == null) {\n return res.status(401).send('Unauthorized to enable preview mode: no secret provided')\n }\n if (secret !== apiKey) {\n return res.status(401).send('Unauthorized to enable preview mode: secret is incorrect')\n }\n\n if (
|
|
1
|
+
{"version":3,"sources":["../../../../../src/next/api-handler/handlers/redirect-preview.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { NextRequest, NextResponse } from 'next/server'\nimport { P, match } from 'ts-pattern'\n\nimport { parse as parseSetCookie } from 'set-cookie-parser'\nimport { serialize as serializeCookie } from 'cookie'\n\nimport { MakeswiftSiteVersion } from '../../../api/site-version'\nimport {\n cookieSettingOptions,\n PRERENDER_BYPASS_COOKIE,\n PREVIEW_DATA_COOKIE,\n SearchParams,\n SET_COOKIE_HEADER,\n} from './utils/draft'\n\ntype Context = { params: { [key: string]: string | string[] } }\n\ntype RedirectPreviewError = string\n\ntype Response = unknown\n\nexport type RedirectPreviewResponse = RedirectPreviewError | Response\n\ntype RedirectPreviewHandlerArgs =\n | [request: NextRequest, context: Context, params: { apiKey: string }]\n | [req: NextApiRequest, res: NextApiResponse<RedirectPreviewResponse>, params: { apiKey: string }]\n\nconst routeHandlerPattern = [P.instanceOf(Request), P.any, P.any] as const\nconst apiRoutePattern = [P.any, P.any, P.any] as const\n\nexport default async function redirectPreviewHandler(\n request: NextRequest,\n context: Context,\n { apiKey }: { apiKey: string },\n): Promise<NextResponse<RedirectPreviewResponse>>\nexport default async function redirectPreviewHandler(\n req: NextApiRequest,\n res: NextApiResponse<RedirectPreviewResponse>,\n { apiKey }: { apiKey: string },\n): Promise<void>\nexport default async function redirectPreviewHandler(\n ...args: RedirectPreviewHandlerArgs\n): Promise<NextResponse<RedirectPreviewResponse> | void> {\n return match(args)\n .with(routeHandlerPattern, args => redirectPreviewRouteHandler(...args))\n .with(apiRoutePattern, args => redirectPreviewApiRouteHandler(...args))\n .exhaustive()\n}\n\nasync function redirectPreviewRouteHandler(\n _request: NextRequest,\n _context: Context,\n { }: { apiKey: string },\n): Promise<NextResponse<RedirectPreviewResponse>> {\n const message =\n 'Cannot request preview endpoint from an API handler registered in `app`. Move your Makeswift API handler to the `pages/api` directory'\n console.error(message)\n return NextResponse.json(message, { status: 500 })\n}\n\n\nasync function redirectPreviewApiRouteHandler(\n req: NextApiRequest,\n res: NextApiResponse<RedirectPreviewResponse>,\n { apiKey }: { apiKey: string },\n): Promise<void> {\n const secret = req.query[SearchParams.PreviewMode]\n // Next.js automatically strips the locale prefix from rewritten request's URL, even when the\n // rewrite's `locale` option is set to `false`: https://github.com/vercel/next.js/discussions/21798.\n // At the same time, it also maps rewrite's URL segments (e.g. `:path`) to query parameters\n // on the rewritten request, so we use `query.path` to recover the original request path.\n const pathname = req.query.path as string | undefined\n\n if (secret == null) {\n return res.status(401).send('Unauthorized to enable preview mode: no secret provided')\n }\n\n if (secret !== apiKey) {\n return res.status(401).send('Unauthorized to enable preview mode: secret is incorrect')\n }\n\n if (pathname == null) {\n return res.status(400).send('Bad request: incoming request does not have an associated pathname')\n }\n\n const setCookie = res\n // Eventually, we can make the preview data value dynamic using the request\n .setPreviewData({ makeswift: true, siteVersion: MakeswiftSiteVersion.Working })\n .getHeader(SET_COOKIE_HEADER)\n\n res.removeHeader(SET_COOKIE_HEADER)\n\n const parsedCookies = parseSetCookie(Array.isArray(setCookie) ? setCookie : '')\n\n const prerenderBypassCookie = parsedCookies.find(c => c.name === PRERENDER_BYPASS_COOKIE)\n const previewDataCookie = parsedCookies.find(c => c.name === PREVIEW_DATA_COOKIE)\n\n if (prerenderBypassCookie?.value == null || previewDataCookie?.value == null) {\n return res.status(500).send('Could not retrieve preview mode cookies')\n }\n\n const patchedCookies = [prerenderBypassCookie, previewDataCookie].map(({ name, value }) => {\n return serializeCookie(name, value, { ...cookieSettingOptions })\n })\n\n res.setHeader(SET_COOKIE_HEADER, patchedCookies)\n\n const destinationUrl = new URL(pathname, 'http://test.com')\n destinationUrl.searchParams.delete(SearchParams.PreviewMode)\n\n res.redirect(`${destinationUrl.pathname}?${destinationUrl.searchParams.toString()}`)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA0C;AAC1C,wBAAyB;AAEzB,+BAAwC;AACxC,oBAA6C;AAE7C,0BAAqC;AACrC,mBAMO;AAcP,MAAM,sBAAsB,CAAC,oBAAE,WAAW,OAAO,GAAG,oBAAE,KAAK,oBAAE,GAAG;AAChE,MAAM,kBAAkB,CAAC,oBAAE,KAAK,oBAAE,KAAK,oBAAE,GAAG;AAY5C,eAAO,0BACF,MACoD;AACvD,aAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,CAAAA,UAAQ,4BAA4B,GAAGA,KAAI,CAAC,EACtE,KAAK,iBAAiB,CAAAA,UAAQ,+BAA+B,GAAGA,KAAI,CAAC,EACrE,W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e,aAAa,OAAO,0BAAa,WAAW;AAE3D,MAAI,SAAS,GAAG,eAAe,QAAQ,IAAI,eAAe,aAAa,SAAS,CAAC,EAAE;AACrF;","names":["args","parseSetCookie","serializeCookie"]}
|
|
@@ -14,7 +14,7 @@ async function handler(...args) {
|
|
|
14
14
|
const supportsDraftMode = match(args).with(routeHandlerPattern, () => true).with(apiRoutePattern, () => false).exhaustive();
|
|
15
15
|
const supportsWebhook = match(args).with(routeHandlerPattern, () => true).with(apiRoutePattern, () => false).exhaustive();
|
|
16
16
|
const body = {
|
|
17
|
-
version: "0.24.2
|
|
17
|
+
version: "0.24.2",
|
|
18
18
|
previewMode: supportsPreviewMode,
|
|
19
19
|
draftMode: supportsDraftMode,
|
|
20
20
|
interactionMode: true,
|
|
@@ -22,14 +22,15 @@ async function redirectPreviewRouteHandler(_request, _context, {}) {
|
|
|
22
22
|
}
|
|
23
23
|
async function redirectPreviewApiRouteHandler(req, res, { apiKey }) {
|
|
24
24
|
const secret = req.query[SearchParams.PreviewMode];
|
|
25
|
+
const pathname = req.query.path;
|
|
25
26
|
if (secret == null) {
|
|
26
27
|
return res.status(401).send("Unauthorized to enable preview mode: no secret provided");
|
|
27
28
|
}
|
|
28
29
|
if (secret !== apiKey) {
|
|
29
30
|
return res.status(401).send("Unauthorized to enable preview mode: secret is incorrect");
|
|
30
31
|
}
|
|
31
|
-
if (
|
|
32
|
-
return res.status(400).send("Bad request: incoming request does not have
|
|
32
|
+
if (pathname == null) {
|
|
33
|
+
return res.status(400).send("Bad request: incoming request does not have an associated pathname");
|
|
33
34
|
}
|
|
34
35
|
const setCookie = res.setPreviewData({ makeswift: true, siteVersion: MakeswiftSiteVersion.Working }).getHeader(SET_COOKIE_HEADER);
|
|
35
36
|
res.removeHeader(SET_COOKIE_HEADER);
|
|
@@ -43,7 +44,7 @@ async function redirectPreviewApiRouteHandler(req, res, { apiKey }) {
|
|
|
43
44
|
return serializeCookie(name, value, { ...cookieSettingOptions });
|
|
44
45
|
});
|
|
45
46
|
res.setHeader(SET_COOKIE_HEADER, patchedCookies);
|
|
46
|
-
const destinationUrl = new URL(
|
|
47
|
+
const destinationUrl = new URL(pathname, "http://test.com");
|
|
47
48
|
destinationUrl.searchParams.delete(SearchParams.PreviewMode);
|
|
48
49
|
res.redirect(`${destinationUrl.pathname}?${destinationUrl.searchParams.toString()}`);
|
|
49
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/next/api-handler/handlers/redirect-preview.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { NextRequest, NextResponse } from 'next/server'\nimport { P, match } from 'ts-pattern'\n\nimport { parse as parseSetCookie } from 'set-cookie-parser'\nimport { serialize as serializeCookie } from 'cookie'\n\nimport { MakeswiftSiteVersion } from '../../../api/site-version'\nimport {\n cookieSettingOptions,\n PRERENDER_BYPASS_COOKIE,\n PREVIEW_DATA_COOKIE,\n SearchParams,\n SET_COOKIE_HEADER,\n} from './utils/draft'\n\ntype Context = { params: { [key: string]: string | string[] } }\n\ntype RedirectPreviewError = string\n\ntype Response = unknown\n\nexport type RedirectPreviewResponse = RedirectPreviewError | Response\n\ntype RedirectPreviewHandlerArgs =\n | [request: NextRequest, context: Context, params: { apiKey: string }]\n | [req: NextApiRequest, res: NextApiResponse<RedirectPreviewResponse>, params: { apiKey: string }]\n\nconst routeHandlerPattern = [P.instanceOf(Request), P.any, P.any] as const\nconst apiRoutePattern = [P.any, P.any, P.any] as const\n\nexport default async function redirectPreviewHandler(\n request: NextRequest,\n context: Context,\n { apiKey }: { apiKey: string },\n): Promise<NextResponse<RedirectPreviewResponse>>\nexport default async function redirectPreviewHandler(\n req: NextApiRequest,\n res: NextApiResponse<RedirectPreviewResponse>,\n { apiKey }: { apiKey: string },\n): Promise<void>\nexport default async function redirectPreviewHandler(\n ...args: RedirectPreviewHandlerArgs\n): Promise<NextResponse<RedirectPreviewResponse> | void> {\n return match(args)\n .with(routeHandlerPattern, args => redirectPreviewRouteHandler(...args))\n .with(apiRoutePattern, args => redirectPreviewApiRouteHandler(...args))\n .exhaustive()\n}\n\nasync function redirectPreviewRouteHandler(\n _request: NextRequest,\n _context: Context,\n {}: { apiKey: string },\n): Promise<NextResponse<RedirectPreviewResponse>> {\n const message =\n 'Cannot request preview endpoint from an API handler registered in `app`. Move your Makeswift API handler to the `pages/api` directory'\n console.error(message)\n return NextResponse.json(message, { status: 500 })\n}\n\nasync function redirectPreviewApiRouteHandler(\n req: NextApiRequest,\n res: NextApiResponse<RedirectPreviewResponse>,\n { apiKey }: { apiKey: string },\n): Promise<void> {\n const secret = req.query[SearchParams.PreviewMode]\n\n if (secret == null) {\n return res.status(401).send('Unauthorized to enable preview mode: no secret provided')\n }\n if (secret !== apiKey) {\n return res.status(401).send('Unauthorized to enable preview mode: secret is incorrect')\n }\n\n if (
|
|
1
|
+
{"version":3,"sources":["../../../../../src/next/api-handler/handlers/redirect-preview.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { NextRequest, NextResponse } from 'next/server'\nimport { P, match } from 'ts-pattern'\n\nimport { parse as parseSetCookie } from 'set-cookie-parser'\nimport { serialize as serializeCookie } from 'cookie'\n\nimport { MakeswiftSiteVersion } from '../../../api/site-version'\nimport {\n cookieSettingOptions,\n PRERENDER_BYPASS_COOKIE,\n PREVIEW_DATA_COOKIE,\n SearchParams,\n SET_COOKIE_HEADER,\n} from './utils/draft'\n\ntype Context = { params: { [key: string]: string | string[] } }\n\ntype RedirectPreviewError = string\n\ntype Response = unknown\n\nexport type RedirectPreviewResponse = RedirectPreviewError | Response\n\ntype RedirectPreviewHandlerArgs =\n | [request: NextRequest, context: Context, params: { apiKey: string }]\n | [req: NextApiRequest, res: NextApiResponse<RedirectPreviewResponse>, params: { apiKey: string }]\n\nconst routeHandlerPattern = [P.instanceOf(Request), P.any, P.any] as const\nconst apiRoutePattern = [P.any, P.any, P.any] as const\n\nexport default async function redirectPreviewHandler(\n request: NextRequest,\n context: Context,\n { apiKey }: { apiKey: string },\n): Promise<NextResponse<RedirectPreviewResponse>>\nexport default async function redirectPreviewHandler(\n req: NextApiRequest,\n res: NextApiResponse<RedirectPreviewResponse>,\n { apiKey }: { apiKey: string },\n): Promise<void>\nexport default async function redirectPreviewHandler(\n ...args: RedirectPreviewHandlerArgs\n): Promise<NextResponse<RedirectPreviewResponse> | void> {\n return match(args)\n .with(routeHandlerPattern, args => redirectPreviewRouteHandler(...args))\n .with(apiRoutePattern, args => redirectPreviewApiRouteHandler(...args))\n .exhaustive()\n}\n\nasync function redirectPreviewRouteHandler(\n _request: NextRequest,\n _context: Context,\n { }: { apiKey: string },\n): Promise<NextResponse<RedirectPreviewResponse>> {\n const message =\n 'Cannot request preview endpoint from an API handler registered in `app`. Move your Makeswift API handler to the `pages/api` directory'\n console.error(message)\n return NextResponse.json(message, { status: 500 })\n}\n\n\nasync function redirectPreviewApiRouteHandler(\n req: NextApiRequest,\n res: NextApiResponse<RedirectPreviewResponse>,\n { apiKey }: { apiKey: string },\n): Promise<void> {\n const secret = req.query[SearchParams.PreviewMode]\n // Next.js automatically strips the locale prefix from rewritten request's URL, even when the\n // rewrite's `locale` option is set to `false`: https://github.com/vercel/next.js/discussions/21798.\n // At the same time, it also maps rewrite's URL segments (e.g. `:path`) to query parameters\n // on the rewritten request, so we use `query.path` to recover the original request path.\n const pathname = req.query.path as string | undefined\n\n if (secret == null) {\n return res.status(401).send('Unauthorized to enable preview mode: no secret provided')\n }\n\n if (secret !== apiKey) {\n return res.status(401).send('Unauthorized to enable preview mode: secret is incorrect')\n }\n\n if (pathname == null) {\n return res.status(400).send('Bad request: incoming request does not have an associated pathname')\n }\n\n const setCookie = res\n // Eventually, we can make the preview data value dynamic using the request\n .setPreviewData({ makeswift: true, siteVersion: MakeswiftSiteVersion.Working })\n .getHeader(SET_COOKIE_HEADER)\n\n res.removeHeader(SET_COOKIE_HEADER)\n\n const parsedCookies = parseSetCookie(Array.isArray(setCookie) ? setCookie : '')\n\n const prerenderBypassCookie = parsedCookies.find(c => c.name === PRERENDER_BYPASS_COOKIE)\n const previewDataCookie = parsedCookies.find(c => c.name === PREVIEW_DATA_COOKIE)\n\n if (prerenderBypassCookie?.value == null || previewDataCookie?.value == null) {\n return res.status(500).send('Could not retrieve preview mode cookies')\n }\n\n const patchedCookies = [prerenderBypassCookie, previewDataCookie].map(({ name, value }) => {\n return serializeCookie(name, value, { ...cookieSettingOptions })\n })\n\n res.setHeader(SET_COOKIE_HEADER, patchedCookies)\n\n const destinationUrl = new URL(pathname, 'http://test.com')\n destinationUrl.searchParams.delete(SearchParams.PreviewMode)\n\n res.redirect(`${destinationUrl.pathname}?${destinationUrl.searchParams.toString()}`)\n}\n"],"mappings":"AACA,SAAsB,oBAAoB;AAC1C,SAAS,GAAG,aAAa;AAEzB,SAAS,SAAS,sBAAsB;AACxC,SAAS,aAAa,uBAAuB;AAE7C,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAcP,MAAM,sBAAsB,CAAC,EAAE,WAAW,OAAO,GAAG,EAAE,KAAK,EAAE,GAAG;AAChE,MAAM,kBAAkB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG;AAY5C,eAAO,0BACF,MACoD;AACvD,SAAO,MAAM,IAAI,EACd,KAAK,qBAAqB,CAAAA,UAAQ,4BAA4B,GAAGA,KAAI,CAAC,EACtE,KAAK,iBAAiB,CAAAA,UAAQ,+BAA+B,GAAGA,KAAI,CAAC,EACrE,WAAW;AAChB;AAEA,eAAe,4BACb,UACA,UACA,CAAE,GAC8C;AAChD,QAAM,UACJ;AACF,UAAQ,MAAM,OAAO;AACrB,SAAO,aAAa,KAAK,SAAS,EAAE,QAAQ,IAAI,CAAC;AACnD;AAGA,eAAe,+BACb,KACA,KACA,EAAE,OAAO,GACM;AACf,QAAM,SAAS,IAAI,MAAM,aAAa,WAAW;AAKjD,QAAM,WAAW,IAAI,MAAM;AAE3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