@pixerate/editor 0.135.0 → 0.136.0
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/animation-editor/index.cjs +58 -55
- package/dist/animation-editor/index.cjs.map +1 -1
- package/dist/animation-editor/index.d.cts +8 -5
- package/dist/animation-editor/index.d.ts +8 -5
- package/dist/animation-editor/index.js +5 -2
- package/dist/animation-editor/index.js.map +1 -1
- package/dist/{bezier-J8i4uqSH.d.cts → bezier-CdccFsF8.d.cts} +1 -1
- package/dist/{bezier-lNEOp0Jx.d.ts → bezier-DG9qNZQV.d.ts} +1 -1
- package/dist/canvas/index.d.cts +10 -7
- package/dist/canvas/index.d.ts +10 -7
- package/dist/{chunk-Z2H7KECK.cjs → chunk-2R3UW57U.cjs} +13 -2
- package/dist/chunk-2R3UW57U.cjs.map +1 -0
- package/dist/{chunk-ESIWZMMK.js → chunk-6QQR4LKE.js} +2 -2
- package/dist/chunk-A3BVTI3G.js +150 -0
- package/dist/chunk-A3BVTI3G.js.map +1 -0
- package/dist/{chunk-T6TV6HY6.cjs → chunk-B2CUCM7Y.cjs} +36 -36
- package/dist/{chunk-T6TV6HY6.cjs.map → chunk-B2CUCM7Y.cjs.map} +1 -1
- package/dist/chunk-ECCXGELC.cjs +727 -0
- package/dist/chunk-ECCXGELC.cjs.map +1 -0
- package/dist/{chunk-OXSV64JX.js → chunk-G6IKY6PL.js} +4 -4
- package/dist/chunk-I52DRGGJ.js +727 -0
- package/dist/chunk-I52DRGGJ.js.map +1 -0
- package/dist/{chunk-YAFS2QFZ.cjs → chunk-JLGNZMUV.cjs} +82 -82
- package/dist/{chunk-YAFS2QFZ.cjs.map → chunk-JLGNZMUV.cjs.map} +1 -1
- package/dist/{chunk-7RJ6P7MI.js → chunk-KZXLZCQ7.js} +2 -2
- package/dist/{chunk-HHTCDFZC.js → chunk-MAHQC3SK.js} +13 -2
- package/dist/chunk-MAHQC3SK.js.map +1 -0
- package/dist/{chunk-FWEO3HSL.js → chunk-PQQF5KOW.js} +8 -8
- package/dist/chunk-Q6OUXEK3.cjs +150 -0
- package/dist/chunk-Q6OUXEK3.cjs.map +1 -0
- package/dist/{chunk-P3RQ5UJE.cjs → chunk-UTQKC66X.cjs} +4 -4
- package/dist/{chunk-P3RQ5UJE.cjs.map → chunk-UTQKC66X.cjs.map} +1 -1
- package/dist/{chunk-J3B45HTA.cjs → chunk-XB25WOC2.cjs} +6 -6
- package/dist/{chunk-J3B45HTA.cjs.map → chunk-XB25WOC2.cjs.map} +1 -1
- package/dist/effects/index.d.cts +7 -4
- package/dist/effects/index.d.ts +7 -4
- package/dist/{export-AZSwX087.d.cts → export-BOheWw2R.d.cts} +3 -3
- package/dist/{export-BDkyDNM8.d.ts → export-ByKKIA2S.d.ts} +3 -3
- package/dist/{export-KzubBKo7.d.cts → export-CEYeRQXH.d.cts} +1 -1
- package/dist/{export-DMeG6E06.d.ts → export-Ds7zgGD8.d.ts} +1 -1
- package/dist/extensions/index.cjs +3 -3
- package/dist/extensions/index.cjs.map +1 -1
- package/dist/extensions/index.js +2 -2
- package/dist/generation/index.cjs +150 -945
- package/dist/generation/index.cjs.map +1 -1
- package/dist/generation/index.d.cts +3 -423
- package/dist/generation/index.d.ts +3 -423
- package/dist/generation/index.js +59 -854
- package/dist/generation/index.js.map +1 -1
- package/dist/grammar/index.cjs +3 -3
- package/dist/grammar/index.cjs.map +1 -1
- package/dist/grammar/index.js +2 -2
- package/dist/{helpers-Coa4e2j_.d.ts → helpers--ns3W2D7.d.ts} +7 -1
- package/dist/{helpers-DHl28yLO.d.cts → helpers-BVkU4oUi.d.cts} +7 -1
- package/dist/image-editor/index.cjs +617 -614
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +11 -8
- package/dist/image-editor/index.d.ts +11 -8
- package/dist/image-editor/index.js +5 -2
- package/dist/image-editor/index.js.map +1 -1
- package/dist/index.cjs +28 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +36 -36
- package/dist/{opentype-Dfcx6wFx.d.ts → opentype-DfoVYgmG.d.ts} +1 -1
- package/dist/{opentype-BWR7Qv8W.d.cts → opentype-yi-Kz4ND.d.cts} +1 -1
- package/dist/paint-editor/index.cjs +10 -7
- package/dist/paint-editor/index.cjs.map +1 -1
- package/dist/paint-editor/index.d.cts +8 -5
- package/dist/paint-editor/index.d.ts +8 -5
- package/dist/paint-editor/index.js +5 -2
- package/dist/paint-editor/index.js.map +1 -1
- package/dist/{pathfinder-D8KQ6blQ.d.cts → pathfinder-7JkMwYvC.d.cts} +1 -1
- package/dist/{pathfinder-Celbi3e6.d.ts → pathfinder-GM3UWdBZ.d.ts} +1 -1
- package/dist/{pool-BfuxBKTd.d.cts → pool-04qp8iW4.d.cts} +1 -1
- package/dist/{pool-8JZGWHvR.d.ts → pool-CkTxlLMC.d.ts} +1 -1
- package/dist/provenance-DmlcgdzT.d.cts +426 -0
- package/dist/provenance-uh5r2TQ8.d.ts +426 -0
- package/dist/{svg-pwXWq6s2.d.cts → svg-BDDKvWWY.d.cts} +2 -2
- package/dist/{svg-CxxqG3_W.d.ts → svg-rV6_HPmn.d.ts} +2 -2
- package/dist/{tools-3EBjR91b.d.cts → tools-BAjSbTdY.d.cts} +1 -1
- package/dist/{tools-y1M6O3UT.d.ts → tools-DPYerqeR.d.ts} +1 -1
- package/dist/vector/index.cjs +2684 -1860
- package/dist/vector/index.cjs.map +1 -1
- package/dist/vector/index.d.cts +313 -71
- package/dist/vector/index.d.ts +313 -71
- package/dist/vector/index.js +4700 -3876
- package/dist/vector/index.js.map +1 -1
- package/dist/video-editor/index.d.cts +7 -4
- package/dist/video-editor/index.d.ts +7 -4
- package/dist/{warp-Ceqdz7kj.d.cts → warp-DQh9R7Ie.d.cts} +1 -1
- package/dist/{warp-C1gwu2G_.d.ts → warp-XVL6SpSh.d.ts} +1 -1
- package/package.json +1 -1
- package/skills/pixerate-vector/SKILL.md +14 -0
- package/dist/chunk-HHTCDFZC.js.map +0 -1
- package/dist/chunk-Z2H7KECK.cjs.map +0 -1
- /package/dist/{chunk-ESIWZMMK.js.map → chunk-6QQR4LKE.js.map} +0 -0
- /package/dist/{chunk-OXSV64JX.js.map → chunk-G6IKY6PL.js.map} +0 -0
- /package/dist/{chunk-7RJ6P7MI.js.map → chunk-KZXLZCQ7.js.map} +0 -0
- /package/dist/{chunk-FWEO3HSL.js.map → chunk-PQQF5KOW.js.map} +0 -0
|
@@ -123,7 +123,7 @@ import {
|
|
|
123
123
|
textRectPath,
|
|
124
124
|
translateMatrix,
|
|
125
125
|
warpPresetMesh
|
|
126
|
-
} from "./chunk-
|
|
126
|
+
} from "./chunk-MAHQC3SK.js";
|
|
127
127
|
import {
|
|
128
128
|
bezierPathBounds,
|
|
129
129
|
outlineStroke,
|
|
@@ -11805,4 +11805,4 @@ export {
|
|
|
11805
11805
|
smartContentsFile,
|
|
11806
11806
|
exportPsd
|
|
11807
11807
|
};
|
|
11808
|
-
//# sourceMappingURL=chunk-
|
|
11808
|
+
//# sourceMappingURL=chunk-6QQR4LKE.js.map
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getLatestVersion,
|
|
3
|
+
getTemplateBody,
|
|
4
|
+
resolvePrompt,
|
|
5
|
+
tokenizePrompt
|
|
6
|
+
} from "./chunk-FPENXAEJ.js";
|
|
7
|
+
|
|
8
|
+
// src/generation/provenance.ts
|
|
9
|
+
var PROVENANCE_FORMAT = "pixerate.generation-provenance";
|
|
10
|
+
var PROVENANCE_VERSION = 1;
|
|
11
|
+
var ProvenanceParseError = class extends Error {
|
|
12
|
+
constructor(message) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = "ProvenanceParseError";
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var toIso = (value) => new Date(value).toISOString();
|
|
18
|
+
var clone = (value) => value === void 0 ? value : JSON.parse(JSON.stringify(value));
|
|
19
|
+
function pinTemplates(rawPrompt, templates, bindings, maxDepth) {
|
|
20
|
+
const byName = new Map(templates.map((t) => [t.name, t]));
|
|
21
|
+
const pinned = /* @__PURE__ */ new Map();
|
|
22
|
+
const visit = (text, depth) => {
|
|
23
|
+
if (depth > maxDepth) return;
|
|
24
|
+
for (const token of tokenizePrompt(text)) {
|
|
25
|
+
if (token.type !== "template" || pinned.has(token.value)) continue;
|
|
26
|
+
const template = byName.get(token.value);
|
|
27
|
+
if (!template) continue;
|
|
28
|
+
const body = getTemplateBody(template, bindings);
|
|
29
|
+
if (body === void 0) continue;
|
|
30
|
+
const bound = bindings[template.name];
|
|
31
|
+
const version = bound && template.versions ? template.versions.find((v) => v.id === bound || v.version === bound) : getLatestVersion(template);
|
|
32
|
+
const isVersioned = !!template.versions?.length && !!version;
|
|
33
|
+
pinned.set(template.name, {
|
|
34
|
+
name: template.name,
|
|
35
|
+
...template.id !== void 0 ? { templateId: template.id } : {},
|
|
36
|
+
...isVersioned ? { versionId: version.id, version: version.version } : {},
|
|
37
|
+
body
|
|
38
|
+
});
|
|
39
|
+
visit(body, depth + 1);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
visit(rawPrompt, 0);
|
|
43
|
+
return [...pinned.values()];
|
|
44
|
+
}
|
|
45
|
+
function pinnedTemplatesToTemplates(pinned) {
|
|
46
|
+
return pinned.map(
|
|
47
|
+
(p) => p.versionId !== void 0 ? {
|
|
48
|
+
...p.templateId !== void 0 ? { id: p.templateId } : {},
|
|
49
|
+
name: p.name,
|
|
50
|
+
latestVersion: p.version,
|
|
51
|
+
versions: [{ id: p.versionId, version: p.version ?? p.versionId, body: p.body }]
|
|
52
|
+
} : { ...p.templateId !== void 0 ? { id: p.templateId } : {}, name: p.name, body: p.body }
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
function createProvenance(options) {
|
|
56
|
+
const templates = options.templates ?? [];
|
|
57
|
+
const maxDepth = options.maxDepth ?? 10;
|
|
58
|
+
const resolved = resolvePrompt(options.rawPrompt, templates, {
|
|
59
|
+
bindings: options.bindings,
|
|
60
|
+
values: options.values,
|
|
61
|
+
maxDepth
|
|
62
|
+
});
|
|
63
|
+
const pinned = pinTemplates(options.rawPrompt, templates, options.bindings ?? {}, maxDepth);
|
|
64
|
+
const bindings = {};
|
|
65
|
+
for (const p of pinned) if (p.versionId !== void 0) bindings[p.name] = p.versionId;
|
|
66
|
+
const modelId = typeof options.model === "string" ? options.model : options.model.id;
|
|
67
|
+
const request = clone(options.plan?.request ?? options.request ?? {});
|
|
68
|
+
request.model = modelId;
|
|
69
|
+
if (request.prompt === void 0) request.prompt = resolved.text;
|
|
70
|
+
const adjustments = clone(options.adjustments ?? options.plan?.adjustments ?? []);
|
|
71
|
+
return {
|
|
72
|
+
format: PROVENANCE_FORMAT,
|
|
73
|
+
version: PROVENANCE_VERSION,
|
|
74
|
+
rawPrompt: options.rawPrompt,
|
|
75
|
+
templates: pinned,
|
|
76
|
+
bindings,
|
|
77
|
+
values: options.values ? clone(options.values) : null,
|
|
78
|
+
resolvedPrompt: resolved.text,
|
|
79
|
+
sourceMap: resolved.map.map((segment) => {
|
|
80
|
+
const { locked: _locked, ...rest } = segment;
|
|
81
|
+
return rest;
|
|
82
|
+
}),
|
|
83
|
+
modelId,
|
|
84
|
+
request,
|
|
85
|
+
adjustments,
|
|
86
|
+
references: (request.references ?? []).map(({ id, role }) => ({ id, role })),
|
|
87
|
+
createdAt: toIso(options.createdAt ?? Date.now()),
|
|
88
|
+
...options.startedAt !== void 0 ? { startedAt: toIso(options.startedAt) } : {},
|
|
89
|
+
...options.completedAt !== void 0 ? { completedAt: toIso(options.completedAt) } : {},
|
|
90
|
+
...options.outputIds ? { outputIds: [...options.outputIds] } : {},
|
|
91
|
+
...options.meta ? { meta: clone(options.meta) } : {}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function serializeProvenance(provenance) {
|
|
95
|
+
return JSON.stringify(provenance);
|
|
96
|
+
}
|
|
97
|
+
var isRecord = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
98
|
+
function parseProvenance(input) {
|
|
99
|
+
let data = input;
|
|
100
|
+
if (typeof input === "string") {
|
|
101
|
+
try {
|
|
102
|
+
data = JSON.parse(input);
|
|
103
|
+
} catch {
|
|
104
|
+
throw new ProvenanceParseError("Provenance is not valid JSON.");
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (!isRecord(data) || data.format !== PROVENANCE_FORMAT) {
|
|
108
|
+
throw new ProvenanceParseError("Not a generation provenance record.");
|
|
109
|
+
}
|
|
110
|
+
if (typeof data.version !== "number" || data.version > PROVENANCE_VERSION) {
|
|
111
|
+
throw new ProvenanceParseError(`Unsupported provenance version ${JSON.stringify(data.version)}.`);
|
|
112
|
+
}
|
|
113
|
+
const checks = [
|
|
114
|
+
["rawPrompt", typeof data.rawPrompt === "string"],
|
|
115
|
+
["resolvedPrompt", typeof data.resolvedPrompt === "string"],
|
|
116
|
+
["modelId", typeof data.modelId === "string"],
|
|
117
|
+
["createdAt", typeof data.createdAt === "string"],
|
|
118
|
+
["request", isRecord(data.request)],
|
|
119
|
+
["templates", Array.isArray(data.templates) && data.templates.every((t) => isRecord(t) && typeof t.name === "string" && typeof t.body === "string")],
|
|
120
|
+
["sourceMap", Array.isArray(data.sourceMap)],
|
|
121
|
+
["adjustments", Array.isArray(data.adjustments)],
|
|
122
|
+
["references", Array.isArray(data.references)]
|
|
123
|
+
];
|
|
124
|
+
const bad = checks.find(([, ok]) => !ok);
|
|
125
|
+
if (bad) throw new ProvenanceParseError(`Invalid provenance field "${bad[0]}".`);
|
|
126
|
+
return {
|
|
127
|
+
...data,
|
|
128
|
+
bindings: isRecord(data.bindings) ? data.bindings : {},
|
|
129
|
+
values: isRecord(data.values) ? data.values : null
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function replayProvenancePrompt(provenance) {
|
|
133
|
+
const result = resolvePrompt(provenance.rawPrompt, pinnedTemplatesToTemplates(provenance.templates), {
|
|
134
|
+
bindings: provenance.bindings,
|
|
135
|
+
...provenance.values ? { values: provenance.values } : {}
|
|
136
|
+
});
|
|
137
|
+
return { text: result.text, map: result.map, matches: result.text === provenance.resolvedPrompt };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export {
|
|
141
|
+
PROVENANCE_FORMAT,
|
|
142
|
+
PROVENANCE_VERSION,
|
|
143
|
+
ProvenanceParseError,
|
|
144
|
+
pinnedTemplatesToTemplates,
|
|
145
|
+
createProvenance,
|
|
146
|
+
serializeProvenance,
|
|
147
|
+
parseProvenance,
|
|
148
|
+
replayProvenancePrompt
|
|
149
|
+
};
|
|
150
|
+
//# sourceMappingURL=chunk-A3BVTI3G.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/generation/provenance.ts"],"sourcesContent":["import { getLatestVersion, getTemplateBody, resolvePrompt } from '../grammar/engine.js';\nimport type { SourceMapSegment } from '../grammar/sourcemap.js';\nimport { tokenizePrompt } from '../grammar/tokenizer.js';\nimport type { PromptValues, Template } from '../grammar/tokens.js';\nimport type { GenerationRequest, ModelCapabilities, ReferenceRole } from './capabilities.js';\nimport type { GenerationPlan, PlanAdjustment } from './plan.js';\n\nexport const PROVENANCE_FORMAT = 'pixerate.generation-provenance';\nexport const PROVENANCE_VERSION = 1;\n\n/** The exact template body a generation used. */\nexport interface PinnedTemplate {\n\tname: string;\n\ttemplateId?: string;\n\t/** Version id or version label the body came from (absent for unversioned templates). */\n\tversionId?: string;\n\tversion?: string | number;\n\tbody: string;\n}\n\n/** Everything needed to explain and reproduce one generation. */\nexport interface GenerationProvenance {\n\tformat: typeof PROVENANCE_FORMAT;\n\tversion: typeof PROVENANCE_VERSION;\n\t/** Raw prompt as typed, with `{{templates}}` and `{variables}`. */\n\trawPrompt: string;\n\t/** Every template the prompt reached (recursively), pinned to the body used. */\n\ttemplates: PinnedTemplate[];\n\t/** Version bindings in effect (`{ templateName: versionId }`) for every pinned versioned template. */\n\tbindings: Record<string, string>;\n\t/** Variable values, or `null` when variables were left unresolved. */\n\tvalues: PromptValues | null;\n\tresolvedPrompt: string;\n\tsourceMap: SourceMapSegment[];\n\tmodelId: string;\n\t/** The planned (adjusted) request that was sent. */\n\trequest: GenerationRequest;\n\tadjustments: PlanAdjustment[];\n\treferences: { id: string; role: ReferenceRole }[];\n\t/** ISO timestamps. */\n\tcreatedAt: string;\n\tstartedAt?: string;\n\tcompletedAt?: string;\n\t/** Ids of the outputs this generation produced. */\n\toutputIds?: string[];\n\tmeta?: Record<string, unknown>;\n}\n\nexport interface CreateProvenanceOptions {\n\trawPrompt: string;\n\ttemplates?: Template[];\n\t/** Template version bindings (`{ templateName: versionIdOrVersion }`). */\n\tbindings?: Record<string, string>;\n\tvalues?: PromptValues;\n\tmodel: string | ModelCapabilities;\n\t/** The plan the request came from (its request and adjustments are recorded) … */\n\tplan?: GenerationPlan;\n\t/** … or the request that was sent. */\n\trequest?: GenerationRequest;\n\tadjustments?: PlanAdjustment[];\n\t/** Creation time (default `Date.now()`). */\n\tcreatedAt?: Date | number | string;\n\tstartedAt?: Date | number | string;\n\tcompletedAt?: Date | number | string;\n\toutputIds?: string[];\n\tmeta?: Record<string, unknown>;\n\tmaxDepth?: number;\n}\n\nexport class ProvenanceParseError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = 'ProvenanceParseError';\n\t}\n}\n\nconst toIso = (value: Date | number | string) => new Date(value).toISOString();\nconst clone = <T>(value: T): T => (value === undefined ? value : JSON.parse(JSON.stringify(value)));\n\n/** Collects the templates a prompt reaches, with the body each one resolves to. */\nfunction pinTemplates(\n\trawPrompt: string,\n\ttemplates: Template[],\n\tbindings: Record<string, string>,\n\tmaxDepth: number\n): PinnedTemplate[] {\n\tconst byName = new Map(templates.map((t) => [t.name, t]));\n\tconst pinned = new Map<string, PinnedTemplate>();\n\tconst visit = (text: string, depth: number) => {\n\t\tif (depth > maxDepth) return;\n\t\tfor (const token of tokenizePrompt(text)) {\n\t\t\tif (token.type !== 'template' || pinned.has(token.value)) continue;\n\t\t\tconst template = byName.get(token.value);\n\t\t\tif (!template) continue;\n\t\t\t// Mirror `getTemplateBody` so the pinned body is the one `resolvePrompt` used.\n\t\t\tconst body = getTemplateBody(template, bindings);\n\t\t\tif (body === undefined) continue;\n\t\t\tconst bound = bindings[template.name];\n\t\t\tconst version =\n\t\t\t\tbound && template.versions\n\t\t\t\t\t? template.versions.find((v) => v.id === bound || v.version === bound)\n\t\t\t\t\t: getLatestVersion(template);\n\t\t\tconst isVersioned = !!template.versions?.length && !!version;\n\t\t\tpinned.set(template.name, {\n\t\t\t\tname: template.name,\n\t\t\t\t...(template.id !== undefined ? { templateId: template.id } : {}),\n\t\t\t\t...(isVersioned ? { versionId: version!.id, version: version!.version } : {}),\n\t\t\t\tbody\n\t\t\t});\n\t\t\tvisit(body, depth + 1);\n\t\t}\n\t};\n\tvisit(rawPrompt, 0);\n\treturn [...pinned.values()];\n}\n\n/** Templates that reproduce the pinned bodies exactly (one single-version template each). */\nexport function pinnedTemplatesToTemplates(pinned: readonly PinnedTemplate[]): Template[] {\n\treturn pinned.map((p) =>\n\t\tp.versionId !== undefined\n\t\t\t? {\n\t\t\t\t\t...(p.templateId !== undefined ? { id: p.templateId } : {}),\n\t\t\t\t\tname: p.name,\n\t\t\t\t\tlatestVersion: p.version,\n\t\t\t\t\tversions: [{ id: p.versionId, version: p.version ?? p.versionId, body: p.body }]\n\t\t\t\t}\n\t\t\t: { ...(p.templateId !== undefined ? { id: p.templateId } : {}), name: p.name, body: p.body }\n\t);\n}\n\n/**\n * Records what produced an output: the raw prompt, the exact template bodies\n * and versions it reached, variable values, the resolved prompt and its\n * source map, the model, the planned settings and adjustments, and the\n * references by role.\n */\nexport function createProvenance(options: CreateProvenanceOptions): GenerationProvenance {\n\tconst templates = options.templates ?? [];\n\tconst maxDepth = options.maxDepth ?? 10;\n\tconst resolved = resolvePrompt(options.rawPrompt, templates, {\n\t\tbindings: options.bindings,\n\t\tvalues: options.values,\n\t\tmaxDepth\n\t});\n\tconst pinned = pinTemplates(options.rawPrompt, templates, options.bindings ?? {}, maxDepth);\n\tconst bindings: Record<string, string> = {};\n\tfor (const p of pinned) if (p.versionId !== undefined) bindings[p.name] = p.versionId;\n\n\tconst modelId = typeof options.model === 'string' ? options.model : options.model.id;\n\tconst request: GenerationRequest = clone(options.plan?.request ?? options.request ?? {});\n\trequest.model = modelId;\n\tif (request.prompt === undefined) request.prompt = resolved.text;\n\tconst adjustments = clone(options.adjustments ?? options.plan?.adjustments ?? []);\n\n\treturn {\n\t\tformat: PROVENANCE_FORMAT,\n\t\tversion: PROVENANCE_VERSION,\n\t\trawPrompt: options.rawPrompt,\n\t\ttemplates: pinned,\n\t\tbindings,\n\t\tvalues: options.values ? clone(options.values) : null,\n\t\tresolvedPrompt: resolved.text,\n\t\tsourceMap: resolved.map.map((segment) => {\n\t\t\tconst { locked: _locked, ...rest } = segment as SourceMapSegment & { locked?: boolean };\n\t\t\treturn rest;\n\t\t}),\n\t\tmodelId,\n\t\trequest,\n\t\tadjustments,\n\t\treferences: (request.references ?? []).map(({ id, role }) => ({ id, role })),\n\t\tcreatedAt: toIso(options.createdAt ?? Date.now()),\n\t\t...(options.startedAt !== undefined ? { startedAt: toIso(options.startedAt) } : {}),\n\t\t...(options.completedAt !== undefined ? { completedAt: toIso(options.completedAt) } : {}),\n\t\t...(options.outputIds ? { outputIds: [...options.outputIds] } : {}),\n\t\t...(options.meta ? { meta: clone(options.meta) } : {})\n\t};\n}\n\n/** Versioned JSON for storage next to an output. */\nexport function serializeProvenance(provenance: GenerationProvenance): string {\n\treturn JSON.stringify(provenance);\n}\n\nconst isRecord = (value: unknown): value is Record<string, any> =>\n\t!!value && typeof value === 'object' && !Array.isArray(value);\n\n/** Parses and checks serialized provenance. Throws {@link ProvenanceParseError}. */\nexport function parseProvenance(input: string | unknown): GenerationProvenance {\n\tlet data: unknown = input;\n\tif (typeof input === 'string') {\n\t\ttry {\n\t\t\tdata = JSON.parse(input);\n\t\t} catch {\n\t\t\tthrow new ProvenanceParseError('Provenance is not valid JSON.');\n\t\t}\n\t}\n\tif (!isRecord(data) || data.format !== PROVENANCE_FORMAT) {\n\t\tthrow new ProvenanceParseError('Not a generation provenance record.');\n\t}\n\tif (typeof data.version !== 'number' || data.version > PROVENANCE_VERSION) {\n\t\tthrow new ProvenanceParseError(`Unsupported provenance version ${JSON.stringify(data.version)}.`);\n\t}\n\tconst checks: [string, boolean][] = [\n\t\t['rawPrompt', typeof data.rawPrompt === 'string'],\n\t\t['resolvedPrompt', typeof data.resolvedPrompt === 'string'],\n\t\t['modelId', typeof data.modelId === 'string'],\n\t\t['createdAt', typeof data.createdAt === 'string'],\n\t\t['request', isRecord(data.request)],\n\t\t['templates', Array.isArray(data.templates) && data.templates.every((t: any) => isRecord(t) && typeof t.name === 'string' && typeof t.body === 'string')],\n\t\t['sourceMap', Array.isArray(data.sourceMap)],\n\t\t['adjustments', Array.isArray(data.adjustments)],\n\t\t['references', Array.isArray(data.references)]\n\t];\n\tconst bad = checks.find(([, ok]) => !ok);\n\tif (bad) throw new ProvenanceParseError(`Invalid provenance field \"${bad[0]}\".`);\n\treturn {\n\t\t...(data as GenerationProvenance),\n\t\tbindings: isRecord(data.bindings) ? data.bindings : {},\n\t\tvalues: isRecord(data.values) ? data.values : null\n\t};\n}\n\n/**\n * Re-resolves the raw prompt against the pinned template bodies and values,\n * e.g. to check a record or to open it in an editor with its source map.\n */\nexport function replayProvenancePrompt(provenance: GenerationProvenance): {\n\ttext: string;\n\tmap: SourceMapSegment[];\n\tmatches: boolean;\n} {\n\tconst result = resolvePrompt(provenance.rawPrompt, pinnedTemplatesToTemplates(provenance.templates), {\n\t\tbindings: provenance.bindings,\n\t\t...(provenance.values ? { values: provenance.values } : {})\n\t});\n\treturn { text: result.text, map: result.map, matches: result.text === provenance.resolvedPrompt };\n}\n"],"mappings":";;;;;;;;AAOO,IAAM,oBAAoB;AAC1B,IAAM,qBAAqB;AA6D3B,IAAM,uBAAN,cAAmC,MAAM;AAAA,EAC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AAW,OAAO,IAAI,CAAC;AAAA,EAC1D,CAAC;AACD,SAAO,EAAE,MAAM,OAAO,MAAM,KAAK,OAAO,KAAK,SAAS,OAAO,SAAS,WAAW,eAAe;AACjG;","names":[]}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
var
|
|
21
|
+
var _chunk2R3UW57Ucjs = require('./chunk-2R3UW57U.cjs');
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
|
|
@@ -37,7 +37,7 @@ var lerpP = (a, b, t) => [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t];
|
|
|
37
37
|
var toP = (v) => [v.x, v.y];
|
|
38
38
|
var mapP = (m, p) => [m[0] * p[0] + m[2] * p[1] + m[4], m[1] * p[0] + m[3] * p[1] + m[5]];
|
|
39
39
|
var curvesOf = (c) => Math.max(0, (c.pts.length - 1) / 3) | 0;
|
|
40
|
-
function subpathToMorphContour(sp, m =
|
|
40
|
+
function subpathToMorphContour(sp, m = _chunk2R3UW57Ucjs.IDENTITY_MATRIX) {
|
|
41
41
|
const n = sp.anchors.length;
|
|
42
42
|
if (!n) return null;
|
|
43
43
|
const first = mapP(m, toP(sp.anchors[0]));
|
|
@@ -67,8 +67,8 @@ function isStraight(p0, p1, p2, p3) {
|
|
|
67
67
|
const u2 = along(p2);
|
|
68
68
|
return off(p1) < tol && off(p2) < tol && u1 >= -1e-9 && u1 <= 1 + 1e-9 && u2 >= -1e-9 && u2 <= 1 + 1e-9;
|
|
69
69
|
}
|
|
70
|
-
function morphContourToSubpath(c, m =
|
|
71
|
-
const pts =
|
|
70
|
+
function morphContourToSubpath(c, m = _chunk2R3UW57Ucjs.IDENTITY_MATRIX, closed = c.closed) {
|
|
71
|
+
const pts = _chunk2R3UW57Ucjs.isIdentityMatrix.call(void 0, m) ? c.pts : c.pts.map((p) => mapP(m, p));
|
|
72
72
|
const curves = curvesOf(c);
|
|
73
73
|
const dropLast = closed && c.closed && curves > 0;
|
|
74
74
|
const count = dropLast ? curves : curves + 1;
|
|
@@ -84,7 +84,7 @@ function morphContourToSubpath(c, m = _chunkZ2H7KECKcjs.IDENTITY_MATRIX, closed
|
|
|
84
84
|
anchors[(k + 1) % count].in = { x: p2[0], y: p2[1] };
|
|
85
85
|
}
|
|
86
86
|
for (const a of anchors) {
|
|
87
|
-
const type =
|
|
87
|
+
const type = _chunk2R3UW57Ucjs.inferAnchorType.call(void 0, a);
|
|
88
88
|
if (type !== "corner") a.type = type;
|
|
89
89
|
}
|
|
90
90
|
const isClosed = closed && curves > 0;
|
|
@@ -267,7 +267,7 @@ function bestStart(fixed, free, useShapeContext) {
|
|
|
267
267
|
return best;
|
|
268
268
|
}
|
|
269
269
|
function placeIn(c, from, to) {
|
|
270
|
-
const b =
|
|
270
|
+
const b = _chunk2R3UW57Ucjs.unionBounds.call(void 0, [boundsOfPoints(c.pts)]);
|
|
271
271
|
const p = b ? [b.x + b.width / 2, b.y + b.height / 2] : c.pts[0];
|
|
272
272
|
if (!from || !to) return p;
|
|
273
273
|
const fx = from.width > 0 ? (p[0] - from.x) / from.width : 0.5;
|
|
@@ -456,7 +456,7 @@ function interpolateVectorColor(a, b, t) {
|
|
|
456
456
|
}
|
|
457
457
|
function resampleGradientStops(g, offsets) {
|
|
458
458
|
return offsets.map((offset) => {
|
|
459
|
-
const s =
|
|
459
|
+
const s = _chunk2R3UW57Ucjs.sampleVectorGradient.call(void 0, g, offset);
|
|
460
460
|
return s.opacity < 1 ? { offset, color: s.color, opacity: Math.round(s.opacity * 1e4) / 1e4 } : { offset, color: s.color };
|
|
461
461
|
});
|
|
462
462
|
}
|
|
@@ -467,11 +467,11 @@ function lerpAngle(a, b, t) {
|
|
|
467
467
|
var lerpPoint = (a, b, t) => ({ x: lerpN(a.x, b.x, t), y: lerpN(a.y, b.y, t) });
|
|
468
468
|
var sameColourModel = (a, b) => (_nullishCoalesce(a.interpolation, () => ( "srgb"))) === (_nullishCoalesce(b.interpolation, () => ( "srgb"))) && (_nullishCoalesce(a.smoothness, () => ( 0))) === (_nullishCoalesce(b.smoothness, () => ( 0)));
|
|
469
469
|
function lerpStops(a, b, t) {
|
|
470
|
-
let stopsA =
|
|
471
|
-
let stopsB =
|
|
470
|
+
let stopsA = _chunk2R3UW57Ucjs.sortedVectorGradientStops.call(void 0, a);
|
|
471
|
+
let stopsB = _chunk2R3UW57Ucjs.sortedVectorGradientStops.call(void 0, b);
|
|
472
472
|
const resampled = stopsA.length !== stopsB.length || !sameColourModel(a, b);
|
|
473
473
|
if (resampled) {
|
|
474
|
-
const offs = [...
|
|
474
|
+
const offs = [..._chunk2R3UW57Ucjs.expandVectorGradientStops.call(void 0, a), ..._chunk2R3UW57Ucjs.expandVectorGradientStops.call(void 0, b), ...stopsA, ...stopsB].map((s) => s.offset).filter(Number.isFinite).sort((x, y) => x - y);
|
|
475
475
|
const common = offs.filter((o, i) => i === 0 || o - offs[i - 1] > 1e-4);
|
|
476
476
|
stopsA = resampleGradientStops(a, common);
|
|
477
477
|
stopsB = resampleGradientStops(b, common);
|
|
@@ -498,8 +498,8 @@ function lerpGradient(a, b, t) {
|
|
|
498
498
|
}
|
|
499
499
|
if (near.spread && near.spread !== "pad") out.spread = near.spread;
|
|
500
500
|
if (near.strokeMode && near.strokeMode !== "within") out.strokeMode = near.strokeMode;
|
|
501
|
-
const ea =
|
|
502
|
-
const eb =
|
|
501
|
+
const ea = _chunk2R3UW57Ucjs.hasExplicitGradientGeometry.call(void 0, a);
|
|
502
|
+
const eb = _chunk2R3UW57Ucjs.hasExplicitGradientGeometry.call(void 0, b);
|
|
503
503
|
if (!ea && !eb) {
|
|
504
504
|
if (a.angle !== void 0 || b.angle !== void 0 || a.type === "linear" || a.type === "reflected") {
|
|
505
505
|
const fallback = a.type === "linear" || a.type === "reflected" ? 180 : 90;
|
|
@@ -512,10 +512,10 @@ function lerpGradient(a, b, t) {
|
|
|
512
512
|
}
|
|
513
513
|
return out;
|
|
514
514
|
}
|
|
515
|
-
const pa =
|
|
516
|
-
const pb =
|
|
515
|
+
const pa = _chunk2R3UW57Ucjs.vectorGradientPoints.call(void 0, a);
|
|
516
|
+
const pb = _chunk2R3UW57Ucjs.vectorGradientPoints.call(void 0, b);
|
|
517
517
|
if (pa.units !== pb.units) {
|
|
518
|
-
const src =
|
|
518
|
+
const src = _chunk2R3UW57Ucjs.explicitVectorGradient.call(void 0, near);
|
|
519
519
|
return { ...src, stops: out.stops, ...out.interpolation ? { interpolation: out.interpolation } : {}, ...out.smoothness ? { smoothness: out.smoothness } : {} };
|
|
520
520
|
}
|
|
521
521
|
out.start = lerpPoint(pa.start, pb.start, t);
|
|
@@ -535,14 +535,14 @@ function solidLike(color, like) {
|
|
|
535
535
|
function interpolateVectorPaint(a, b, t) {
|
|
536
536
|
if (t <= 0) return a;
|
|
537
537
|
if (t >= 1) return b;
|
|
538
|
-
const pa =
|
|
539
|
-
const pb =
|
|
538
|
+
const pa = _chunk2R3UW57Ucjs.hasPaint.call(void 0, a);
|
|
539
|
+
const pb = _chunk2R3UW57Ucjs.hasPaint.call(void 0, b);
|
|
540
540
|
if (!pa && !pb) return t < 0.5 ? a : b;
|
|
541
541
|
if (typeof a === "string" && pa && typeof b === "string" && pb) return interpolateVectorColor(a, b, t);
|
|
542
542
|
if (!pa && typeof b === "string") return interpolateVectorColor("transparent", b, t);
|
|
543
543
|
if (!pb && typeof a === "string") return interpolateVectorColor(a, "transparent", t);
|
|
544
|
-
const ga = pa &&
|
|
545
|
-
const gb = pb &&
|
|
544
|
+
const ga = pa && _chunk2R3UW57Ucjs.isVectorGradient.call(void 0, a) ? a : null;
|
|
545
|
+
const gb = pb && _chunk2R3UW57Ucjs.isVectorGradient.call(void 0, b) ? b : null;
|
|
546
546
|
if (ga && gb) return _nullishCoalesce(lerpGradient(ga, gb, t), () => ( (t < 0.5 ? a : b)));
|
|
547
547
|
if (gb) return _nullishCoalesce(lerpGradient(solidLike(pa ? a : null, gb), gb, t), () => ( b));
|
|
548
548
|
if (ga) return _nullishCoalesce(lerpGradient(ga, solidLike(pb ? b : null, ga), t), () => ( a));
|
|
@@ -553,8 +553,8 @@ function interpolateWidthProfiles(a, b, t) {
|
|
|
553
553
|
const at = [..._nullishCoalesce(a, () => ( [])), ..._nullishCoalesce(b, () => ( [])), { t: 0 }, { t: 1 }].map((p) => p.t).sort((x, y) => x - y);
|
|
554
554
|
const ts = at.filter((v, i) => i === 0 || v - at[i - 1] > 1e-6);
|
|
555
555
|
return ts.map((pos) => {
|
|
556
|
-
const x =
|
|
557
|
-
const y =
|
|
556
|
+
const x = _chunk2R3UW57Ucjs.widthProfileAt.call(void 0, a, pos);
|
|
557
|
+
const y = _chunk2R3UW57Ucjs.widthProfileAt.call(void 0, b, pos);
|
|
558
558
|
return { t: pos, left: lerpN(x.left, y.left, t), right: lerpN(x.right, y.right, t) };
|
|
559
559
|
});
|
|
560
560
|
}
|
|
@@ -597,7 +597,7 @@ function reversedStyle(s) {
|
|
|
597
597
|
out.endArrow = s.startArrow;
|
|
598
598
|
out.startArrowScale = s.endArrowScale;
|
|
599
599
|
out.endArrowScale = s.startArrowScale;
|
|
600
|
-
if (_optionalChain([s, 'access', _6 => _6.strokeWidthProfile, 'optionalAccess', _7 => _7.length])) out.strokeWidthProfile =
|
|
600
|
+
if (_optionalChain([s, 'access', _6 => _6.strokeWidthProfile, 'optionalAccess', _7 => _7.length])) out.strokeWidthProfile = _chunk2R3UW57Ucjs.reverseWidthProfile.call(void 0, s.strokeWidthProfile);
|
|
601
601
|
for (const k of ["startArrow", "endArrow", "startArrowScale", "endArrowScale"]) if (out[k] === void 0) delete out[k];
|
|
602
602
|
return out;
|
|
603
603
|
}
|
|
@@ -623,19 +623,19 @@ function styleOf(n) {
|
|
|
623
623
|
return out;
|
|
624
624
|
}
|
|
625
625
|
function contoursOf(node, m) {
|
|
626
|
-
return
|
|
626
|
+
return _chunk2R3UW57Ucjs.expandVectorCorners.call(void 0, node.subpaths).map((sp) => subpathToMorphContour(sp, m)).filter((c) => !!c);
|
|
627
627
|
}
|
|
628
|
-
function preparePathMorph(a, b, options, ma =
|
|
628
|
+
function preparePathMorph(a, b, options, ma = _chunk2R3UW57Ucjs.nodeMatrix.call(void 0, a), mb = _chunk2R3UW57Ucjs.nodeMatrix.call(void 0, b)) {
|
|
629
629
|
const corr = correspondMorphContours(contoursOf(a, ma), contoursOf(b, mb), options);
|
|
630
630
|
const sim = procrustes(corr.a, corr.b);
|
|
631
631
|
const styleA = styleOf(a);
|
|
632
632
|
const styleB = corr.reversed ? reversedStyle(styleOf(b)) : styleOf(b);
|
|
633
|
-
const rigid = !
|
|
633
|
+
const rigid = !_chunk2R3UW57Ucjs.isIdentityMatrix.call(void 0, ma) || !_chunk2R3UW57Ucjs.isIdentityMatrix.call(void 0, mb);
|
|
634
634
|
const id = _nullishCoalesce(options.id, () => ( a.id));
|
|
635
635
|
return (t) => {
|
|
636
636
|
const contours = interpolateMorphContours(corr.a, corr.b, t, { linear: options.linear, rigidity: options.rigidity, similarity: sim });
|
|
637
|
-
const m = rigid ? interpolateRigidMatrix(ma, mb, t) :
|
|
638
|
-
const back = rigid ?
|
|
637
|
+
const m = rigid ? interpolateRigidMatrix(ma, mb, t) : _chunk2R3UW57Ucjs.IDENTITY_MATRIX;
|
|
638
|
+
const back = rigid ? _chunk2R3UW57Ucjs.invertMatrix.call(void 0, m) : _chunk2R3UW57Ucjs.IDENTITY_MATRIX;
|
|
639
639
|
const subpaths = contours.map((c, k) => {
|
|
640
640
|
const closed = t <= 0 ? corr.a[k].closed : t >= 1 ? corr.b[k].closed : corr.a[k].closed && corr.b[k].closed;
|
|
641
641
|
return morphContourToSubpath({ closed: corr.a[k].closed && corr.b[k].closed, pts: c.pts }, back, closed);
|
|
@@ -643,14 +643,14 @@ function preparePathMorph(a, b, options, ma = _chunkZ2H7KECKcjs.nodeMatrix.call(
|
|
|
643
643
|
const node = { id, type: "path", subpaths, ...interpolateVectorStyle(styleA, styleB, t) };
|
|
644
644
|
const opacity = lerpN(_nullishCoalesce(a.opacity, () => ( 1)), _nullishCoalesce(b.opacity, () => ( 1)), t);
|
|
645
645
|
if (opacity < 1) node.opacity = opacity;
|
|
646
|
-
if (rigid && !
|
|
646
|
+
if (rigid && !_chunk2R3UW57Ucjs.isIdentityMatrix.call(void 0, m)) node.transform = m;
|
|
647
647
|
return node;
|
|
648
648
|
};
|
|
649
649
|
}
|
|
650
|
-
function flattenPaths(node, parent =
|
|
651
|
-
const m =
|
|
650
|
+
function flattenPaths(node, parent = _chunk2R3UW57Ucjs.IDENTITY_MATRIX) {
|
|
651
|
+
const m = _chunk2R3UW57Ucjs.multiplyMatrices.call(void 0, _chunk2R3UW57Ucjs.nodeMatrix.call(void 0, node), parent);
|
|
652
652
|
if (node.type === "path") return [{ path: node, m, opacity: 1 }];
|
|
653
|
-
if (node.type === "text" || node.type === "instance") return flattenPaths(
|
|
653
|
+
if (node.type === "text" || node.type === "instance") return flattenPaths(_chunk2R3UW57Ucjs.expandVectorAppearance.call(void 0, node), parent);
|
|
654
654
|
const o = _nullishCoalesce(node.opacity, () => ( 1));
|
|
655
655
|
return node.children.filter((c) => c.visible !== false).flatMap((c) => flattenPaths(c, m)).map((e) => ({ ...e, opacity: e.opacity * o }));
|
|
656
656
|
}
|
|
@@ -672,8 +672,8 @@ function createVectorMorph(a, b, options = {}) {
|
|
|
672
672
|
}
|
|
673
673
|
const pa = flattenPaths(a);
|
|
674
674
|
const pb = flattenPaths(b);
|
|
675
|
-
const ba =
|
|
676
|
-
const bb =
|
|
675
|
+
const ba = _chunk2R3UW57Ucjs.unionBounds.call(void 0, pa.map((e) => placedBounds(e.path, e.m)));
|
|
676
|
+
const bb = _chunk2R3UW57Ucjs.unionBounds.call(void 0, pb.map((e) => placedBounds(e.path, e.m)));
|
|
677
677
|
const id = _nullishCoalesce(options.id, () => ( a.id));
|
|
678
678
|
const parts = [];
|
|
679
679
|
const opacities = [];
|
|
@@ -685,10 +685,10 @@ function createVectorMorph(a, b, options = {}) {
|
|
|
685
685
|
parts.push(preparePathMorph(x.path, y.path, sub, x.m, y.m));
|
|
686
686
|
opacities.push([x.opacity, y.opacity]);
|
|
687
687
|
} else if (x) {
|
|
688
|
-
parts.push(preparePathMorph(x.path, collapsedPath(x.path, x.m, ba, bb), sub, x.m,
|
|
688
|
+
parts.push(preparePathMorph(x.path, collapsedPath(x.path, x.m, ba, bb), sub, x.m, _chunk2R3UW57Ucjs.IDENTITY_MATRIX));
|
|
689
689
|
opacities.push([x.opacity, x.opacity]);
|
|
690
690
|
} else if (y) {
|
|
691
|
-
parts.push(preparePathMorph(collapsedPath(y.path, y.m, bb, ba), y.path, sub,
|
|
691
|
+
parts.push(preparePathMorph(collapsedPath(y.path, y.m, bb, ba), y.path, sub, _chunk2R3UW57Ucjs.IDENTITY_MATRIX, y.m));
|
|
692
692
|
opacities.push([y.opacity, y.opacity]);
|
|
693
693
|
}
|
|
694
694
|
}
|
|
@@ -750,4 +750,4 @@ function evaluateVectorPathKeyframes(keyframes, time, options = {}) {
|
|
|
750
750
|
|
|
751
751
|
|
|
752
752
|
exports.subpathToMorphContour = subpathToMorphContour; exports.morphContourToSubpath = morphContourToSubpath; exports.refineMorphContour = refineMorphContour; exports.reverseMorphContour = reverseMorphContour; exports.turnMorphContour = turnMorphContour; exports.correspondMorphContours = correspondMorphContours; exports.morphPathsCross = morphPathsCross; exports.interpolateMorphContours = interpolateMorphContours; exports.interpolateRigidMatrix = interpolateRigidMatrix; exports.interpolateVectorColor = interpolateVectorColor; exports.resampleGradientStops = resampleGradientStops; exports.interpolateVectorPaint = interpolateVectorPaint; exports.interpolateWidthProfiles = interpolateWidthProfiles; exports.interpolateVectorStyle = interpolateVectorStyle; exports.createVectorMorph = createVectorMorph; exports.interpolateVectorPaths = interpolateVectorPaths; exports.evaluateVectorPathKeyframes = evaluateVectorPathKeyframes;
|
|
753
|
-
//# sourceMappingURL=chunk-
|
|
753
|
+
//# sourceMappingURL=chunk-B2CUCM7Y.cjs.map
|