@xray-network/xray-cardano-lib-plutus 0.0.0-stage → 1.0.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.
Files changed (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +122 -2
  3. package/dist/esm/api.d.ts +29 -0
  4. package/dist/esm/api.d.ts.map +1 -0
  5. package/dist/esm/api.js +93 -0
  6. package/dist/esm/api.js.map +1 -0
  7. package/dist/esm/blueprint/index.d.ts +15 -0
  8. package/dist/esm/blueprint/index.d.ts.map +1 -0
  9. package/dist/esm/blueprint/index.js +579 -0
  10. package/dist/esm/blueprint/index.js.map +1 -0
  11. package/dist/esm/index.d.ts +8 -0
  12. package/dist/esm/index.d.ts.map +1 -0
  13. package/dist/esm/index.js +7 -0
  14. package/dist/esm/index.js.map +1 -0
  15. package/dist/esm/ledger/context.d.ts +16 -0
  16. package/dist/esm/ledger/context.d.ts.map +1 -0
  17. package/dist/esm/ledger/context.js +788 -0
  18. package/dist/esm/ledger/context.js.map +1 -0
  19. package/dist/esm/ledger/evaluate.d.ts +8 -0
  20. package/dist/esm/ledger/evaluate.d.ts.map +1 -0
  21. package/dist/esm/ledger/evaluate.js +533 -0
  22. package/dist/esm/ledger/evaluate.js.map +1 -0
  23. package/dist/esm/typed_data/index.d.ts +3 -0
  24. package/dist/esm/typed_data/index.d.ts.map +1 -0
  25. package/dist/esm/typed_data/index.js +3 -0
  26. package/dist/esm/typed_data/index.js.map +1 -0
  27. package/dist/esm/typed_data/typed_data.d.ts +81 -0
  28. package/dist/esm/typed_data/typed_data.d.ts.map +1 -0
  29. package/dist/esm/typed_data/typed_data.js +527 -0
  30. package/dist/esm/typed_data/typed_data.js.map +1 -0
  31. package/dist/esm/typed_data/types.d.ts +86 -0
  32. package/dist/esm/typed_data/types.d.ts.map +1 -0
  33. package/dist/esm/typed_data/types.js +12 -0
  34. package/dist/esm/typed_data/types.js.map +1 -0
  35. package/dist/esm/uplc/ast.d.ts +76 -0
  36. package/dist/esm/uplc/ast.d.ts.map +1 -0
  37. package/dist/esm/uplc/ast.js +4 -0
  38. package/dist/esm/uplc/ast.js.map +1 -0
  39. package/dist/esm/uplc/cost-model-data.d.ts +3 -0
  40. package/dist/esm/uplc/cost-model-data.d.ts.map +1 -0
  41. package/dist/esm/uplc/cost-model-data.js +1026 -0
  42. package/dist/esm/uplc/cost-model-data.js.map +1 -0
  43. package/dist/esm/uplc/cost-model.d.ts +22 -0
  44. package/dist/esm/uplc/cost-model.d.ts.map +1 -0
  45. package/dist/esm/uplc/cost-model.js +273 -0
  46. package/dist/esm/uplc/cost-model.js.map +1 -0
  47. package/dist/esm/uplc/flat.d.ts +19 -0
  48. package/dist/esm/uplc/flat.d.ts.map +1 -0
  49. package/dist/esm/uplc/flat.js +687 -0
  50. package/dist/esm/uplc/flat.js.map +1 -0
  51. package/dist/esm/uplc/index.d.ts +11 -0
  52. package/dist/esm/uplc/index.d.ts.map +1 -0
  53. package/dist/esm/uplc/index.js +7 -0
  54. package/dist/esm/uplc/index.js.map +1 -0
  55. package/dist/esm/uplc/machine.d.ts +33 -0
  56. package/dist/esm/uplc/machine.d.ts.map +1 -0
  57. package/dist/esm/uplc/machine.js +1437 -0
  58. package/dist/esm/uplc/machine.js.map +1 -0
  59. package/dist/esm/uplc/serialized-script.d.ts +19 -0
  60. package/dist/esm/uplc/serialized-script.d.ts.map +1 -0
  61. package/dist/esm/uplc/serialized-script.js +52 -0
  62. package/dist/esm/uplc/serialized-script.js.map +1 -0
  63. package/dist/esm/uplc/text.d.ts +3 -0
  64. package/dist/esm/uplc/text.d.ts.map +1 -0
  65. package/dist/esm/uplc/text.js +518 -0
  66. package/dist/esm/uplc/text.js.map +1 -0
  67. package/package.json +54 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 XRAY/Network <https://xray.app>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,123 @@
1
- # Temporary Holding Version
1
+ # Cardano Plutus
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ `@xray-network/xray-cardano-lib-plutus` provides typed Plutus Data, UPLC parsing and serialization,
4
+ budgeted CEK evaluation, script parameter application, and phase-two transaction evaluation.
5
+
6
+ ## Installation
7
+
8
+ ```sh
9
+ npm install @xray-network/xray-cardano-lib-plutus
10
+ ```
11
+
12
+ ## Requirements
13
+
14
+ ESM-only, with TypeScript declarations included. Use Node.js 20.19 or newer, or a modern browser
15
+ with `Uint8Array`, `bigint`, and Web Platform APIs. No CommonJS, native addon, or WebAssembly build is shipped.
16
+
17
+ ## Quickstart
18
+
19
+ Encode and decode a typed datum:
20
+
21
+ ```ts
22
+ import { Data } from "@xray-network/xray-cardano-lib-plutus/data";
23
+
24
+ const paymentSchema = Data.Object({
25
+ owner: Data.Bytes({ minLength: 28, maxLength: 28 }),
26
+ amount: Data.Integer({ minimum: 0 }),
27
+ });
28
+ const payment = { owner: "11".repeat(28), amount: 42n };
29
+ const cbor = Data.to(payment, paymentSchema);
30
+ const decoded = Data.from(cbor, paymentSchema);
31
+ console.log(decoded.amount); // 42n
32
+ ```
33
+
34
+ ## UPLC
35
+
36
+ ```ts
37
+ import {
38
+ encodeProgramEnvelope,
39
+ evaluateProgram,
40
+ parseUplcText,
41
+ } from "@xray-network/xray-cardano-lib-plutus/uplc";
42
+
43
+ const program = parseUplcText("(program 1.0.0 (con unit ()))");
44
+ const script = encodeProgramEnvelope(program);
45
+ const result = evaluateProgram(program, [], {
46
+ cpu: 10_000_000n,
47
+ memory: 10_000_000n,
48
+ });
49
+ ```
50
+
51
+ The root entry point exports the same UPLC API together with `Data`, `applyParamsToScript`, and
52
+ `evaluatePhaseTwoRaw`. It also exposes `data`, `uplc`, and `blueprint` namespaces for predictable
53
+ domain access. Generic CEK evaluation is explicitly budgeted and does not perform ledger phase-one
54
+ validation.
55
+
56
+ `SerializedPlutusScript.from_raw_flat`, `from_single_cbor`, and `from_double_cbor` explicitly own
57
+ the three serialized-script forms. Each constructor validates an exact Flat program and its exact
58
+ CBOR nesting; `to_raw_flat`, `to_single_cbor`, and `to_double_cbor` convert without envelope
59
+ guessing.
60
+
61
+ `evaluatePhaseTwo(transaction, resolvedInputs, costModels, ...)` accepts the existing chain-owned
62
+ ledger bindings and returns immutable evaluations paired with chain-owned `RedeemerWitnessKey`
63
+ values. `evaluatePhaseTwoRaw` remains available for byte-oriented compatibility.
64
+
65
+ ## Typed Data
66
+
67
+ ```ts
68
+ import { Data } from "@xray-network/xray-cardano-lib-plutus/data";
69
+
70
+ const payment = Data.Object({
71
+ owner: Data.Bytes({ minLength: 28, maxLength: 28 }),
72
+ amount: Data.Integer({ minimum: 0 }),
73
+ });
74
+
75
+ const voidSchema = Data.Void();
76
+ Data.to(undefined, voidSchema); // "d87980"
77
+ ```
78
+
79
+ `Data.Void()` is the typed schema for constructor alternative zero with no fields. The existing
80
+ lowercase `Data.void()` helper continues to return that raw CBOR directly.
81
+
82
+ Ledger wire types such as `PlutusData`, scripts, redeemers, and `ExUnits` remain owned by
83
+ `@xray-network/xray-cardano-lib-chain`.
84
+
85
+ ## Contract blueprints
86
+
87
+ `@xray-network/xray-cardano-lib-plutus/blueprint` parses bounded CIP-57 blueprint documents,
88
+ validates their declared Plutus Data schemas, and verifies compiled validator hashes without
89
+ executing a validator. Parsed documents are immutable; recursive or oversized untrusted schemas
90
+ fail through the package error boundary.
91
+
92
+ ## Entry points
93
+
94
+ | Entry point | Domain |
95
+ | ------------------------------------------------- | ---------------------------------------------------------------- |
96
+ | `@xray-network/xray-cardano-lib-plutus` | Flat owning APIs plus `data`, `uplc`, and `blueprint` namespaces |
97
+ | `@xray-network/xray-cardano-lib-plutus/data` | Typed Plutus Data schemas and codecs |
98
+ | `@xray-network/xray-cardano-lib-plutus/blueprint` | CIP-57 documents, validators, and schema validation |
99
+ | `@xray-network/xray-cardano-lib-plutus/uplc` | UPLC AST, Flat/text codecs, costs, and CEK evaluation |
100
+
101
+ ## Evaluation boundaries
102
+
103
+ Choose budgets and cost models appropriate to the ledger version you target. Generic UPLC
104
+ execution is not transaction validation; resolve inputs and apply the required ledger checks in
105
+ the surrounding application.
106
+
107
+ ## Development
108
+
109
+ From a repository checkout, run these commands at the repository root:
110
+
111
+ ```sh
112
+ npm --prefix libs/typescript ci
113
+ npm --prefix libs/typescript run check
114
+ ```
115
+
116
+ ## Documentation
117
+
118
+ See the [TypeScript package overview](https://github.com/xray-network/xray-cardano-lib/blob/main/libs/typescript/README.md) and
119
+ [architecture decisions](https://github.com/xray-network/xray-cardano-lib/blob/main/docs/README.md).
120
+
121
+ ## License
122
+
123
+ MIT. See [LICENSE](./LICENSE).
@@ -0,0 +1,29 @@
1
+ import { CostModels, RedeemerWitnessKey, Transaction, TransactionUnspentOutput } from "@xray-network/xray-cardano-lib-chain";
2
+ export interface UplcExBudget {
3
+ readonly cpu: bigint;
4
+ readonly memory: bigint;
5
+ }
6
+ export interface PhaseTwoEvaluation {
7
+ readonly cost: UplcExBudget;
8
+ readonly logs: readonly string[];
9
+ }
10
+ export type PhaseTwoRawEvaluation = readonly [
11
+ redeemerBytes: Uint8Array,
12
+ evaluation: PhaseTwoEvaluation
13
+ ];
14
+ export interface TypedPhaseTwoEvaluation {
15
+ readonly redeemer: RedeemerWitnessKey;
16
+ readonly evaluation: PhaseTwoEvaluation;
17
+ }
18
+ export declare function applyParamsToScript(paramsBytes: Uint8Array, plutusScriptBytes: Uint8Array): Uint8Array;
19
+ export declare function evaluatePhaseTwoRaw(txBytes: Uint8Array, utxosBytes: readonly (readonly [inputBytes: Uint8Array, outputBytes: Uint8Array])[], costModelsBytes: Uint8Array, maxBudget: readonly [cpu: bigint, memory: bigint], slotConfig: readonly [
20
+ zeroTimeMilliseconds: bigint,
21
+ zeroSlot: bigint,
22
+ slotLengthMilliseconds: bigint
23
+ ], protocolMajorVersion: number, runPhaseOne: boolean): readonly PhaseTwoRawEvaluation[];
24
+ export declare function evaluatePhaseTwo(transaction: Transaction, resolvedInputs: readonly TransactionUnspentOutput[], costModels: CostModels, maxBudget: readonly [cpu: bigint, memory: bigint], slotConfig: readonly [
25
+ zeroTimeMilliseconds: bigint,
26
+ zeroSlot: bigint,
27
+ slotLengthMilliseconds: bigint
28
+ ], protocolMajorVersion: number, runPhaseOne: boolean): readonly TypedPhaseTwoEvaluation[];
29
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,UAAU,EAEV,kBAAkB,EAClB,WAAW,EACX,wBAAwB,EACzB,MAAM,sCAAsC,CAAC;AAW9C,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,kBAAkB;IACj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uBAAuB,EAAE,CAiBpC"}
@@ -0,0 +1,93 @@
1
+ import { CardanoBoundsError, DeserializeError, decodeCbor, encodeCbor, } from "@xray-network/xray-cardano-lib-core";
2
+ import { CostModels, LegacyRedeemer, RedeemerWitnessKey, Transaction, TransactionUnspentOutput, } from "@xray-network/xray-cardano-lib-chain";
3
+ import { evaluateRaw } from "./ledger/evaluate.js";
4
+ import { dataConstant } from "./uplc/ast.js";
5
+ import { decodeProgramEnvelope, encodeProgramEnvelope, validatePlutusDataNode, } from "./uplc/flat.js";
6
+ const MAX_STANDALONE_BYTES = 16 * 1024 * 1024;
7
+ export function applyParamsToScript(paramsBytes, plutusScriptBytes) {
8
+ assertStandaloneLength("parameter bytes", paramsBytes);
9
+ assertStandaloneLength("script bytes", plutusScriptBytes);
10
+ let parameters;
11
+ try {
12
+ parameters = decodeCbor(Uint8Array.from(paramsBytes));
13
+ }
14
+ catch (cause) {
15
+ if (cause instanceof DeserializeError)
16
+ throw cause;
17
+ throw new DeserializeError("INVALID_CBOR", "invalid parameter CBOR", { cause });
18
+ }
19
+ if (parameters.kind !== "array") {
20
+ throw new DeserializeError("INVALID_STRUCTURE", "script parameters must be a CBOR array");
21
+ }
22
+ const program = decodeProgramEnvelope(Uint8Array.from(plutusScriptBytes));
23
+ let term = program.term;
24
+ for (const parameter of parameters.values) {
25
+ validatePlutusDataNode(parameter);
26
+ term = {
27
+ kind: "apply",
28
+ function: term,
29
+ argument: { kind: "constant", constant: dataConstant(parameter) },
30
+ };
31
+ }
32
+ assertClosed(term);
33
+ return Uint8Array.from(encodeProgramEnvelope({ version: program.version, term }));
34
+ }
35
+ export function evaluatePhaseTwoRaw(txBytes, utxosBytes, costModelsBytes, maxBudget, slotConfig, protocolMajorVersion, runPhaseOne) {
36
+ const results = evaluateRaw(Uint8Array.from(txBytes), utxosBytes.map(([input, output]) => [Uint8Array.from(input), Uint8Array.from(output)]), Uint8Array.from(costModelsBytes), { cpu: maxBudget[0], memory: maxBudget[1] }, [...slotConfig], protocolMajorVersion, runPhaseOne);
37
+ return Object.freeze(results.map((result) => Object.freeze([
38
+ Uint8Array.from(result.redeemer),
39
+ Object.freeze({
40
+ cost: Object.freeze({ cpu: result.cost.cpu, memory: result.cost.memory }),
41
+ logs: Object.freeze([...result.logs]),
42
+ }),
43
+ ])));
44
+ }
45
+ export function evaluatePhaseTwo(transaction, resolvedInputs, costModels, maxBudget, slotConfig, protocolMajorVersion, runPhaseOne) {
46
+ const raw = evaluatePhaseTwoRaw(transaction.to_cbor_bytes(), resolvedInputs.map((utxo) => [utxo.input().to_cbor_bytes(), utxo.output().to_cbor_bytes()]), costModels.to_cbor_bytes(), maxBudget, slotConfig, protocolMajorVersion, runPhaseOne);
47
+ return Object.freeze(raw.map(([redeemer, evaluation]) => Object.freeze({
48
+ redeemer: RedeemerWitnessKey.from_redeemer(LegacyRedeemer.from_cbor_bytes(redeemer)),
49
+ evaluation: Object.freeze({
50
+ cost: Object.freeze({ cpu: evaluation.cost.cpu, memory: evaluation.cost.memory }),
51
+ logs: Object.freeze([...evaluation.logs]),
52
+ }),
53
+ })));
54
+ }
55
+ function assertStandaloneLength(name, value) {
56
+ if (value.length > MAX_STANDALONE_BYTES) {
57
+ throw new CardanoBoundsError(name, 0n, BigInt(MAX_STANDALONE_BYTES), BigInt(value.length));
58
+ }
59
+ }
60
+ function assertClosed(term) {
61
+ const stack = [[term, 0n]];
62
+ while (stack.length !== 0) {
63
+ const [current, depth] = stack.pop();
64
+ switch (current.kind) {
65
+ case "var":
66
+ if (current.index < 1n || current.index > depth) {
67
+ throw new DeserializeError("INVALID_STRUCTURE", "UPLC program contains a free variable");
68
+ }
69
+ break;
70
+ case "lambda":
71
+ stack.push([current.body, depth + 1n]);
72
+ break;
73
+ case "delay":
74
+ case "force":
75
+ stack.push([current.term, depth]);
76
+ break;
77
+ case "apply":
78
+ stack.push([current.argument, depth], [current.function, depth]);
79
+ break;
80
+ case "constr":
81
+ for (const field of current.fields)
82
+ stack.push([field, depth]);
83
+ break;
84
+ case "case":
85
+ stack.push([current.scrutinee, depth]);
86
+ for (const branch of current.branches)
87
+ stack.push([branch, depth]);
88
+ break;
89
+ default: break;
90
+ }
91
+ }
92
+ }
93
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACV,UAAU,GAEX,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,WAAW,EACX,wBAAwB,GACzB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAiB,MAAM,eAAe,CAAC;AAC5D,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AAExB,MAAM,oBAAoB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAsB9C,MAAM,UAAU,mBAAmB,CACjC,WAAuB,EACvB,iBAA6B;IAE7B,sBAAsB,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAC;IACvD,sBAAsB,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAC;IAC1D,IAAI,UAAqB,CAAC;IAC1B,IAAI,CAAC;QACH,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IACxD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,gBAAgB;YAAE,MAAM,KAAK,CAAC;QACnD,MAAM,IAAI,gBAAgB,CAAC,cAAc,EAAE,wBAAwB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAClF,CAAC;IACD,IAAI,UAAU,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAChC,MAAM,IAAI,gBAAgB,CAA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AC,CAAC,CAAC;gBAAC,MAAM;YACvD,KAAK,OAAO;gBAAE,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;gBAAC,MAAM;YACtF,KAAK,QAAQ;gBAAE,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,MAAM;oBAAE,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;gBAAC,MAAM;YACrF,KAAK,MAAM;gBACT,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;gBACvC,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,QAAQ;oBAAE,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;gBACnE,MAAM;YACR,OAAO,CAAC,CAAC,MAAM;QACjB,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,15 @@
1
+ export interface BlueprintViolation {
2
+ readonly code: string;
3
+ readonly path: string;
4
+ readonly message: string;
5
+ }
6
+ export interface PlutusBlueprint {
7
+ readonly preamble: Readonly<Record<string, unknown>>;
8
+ readonly validators: readonly Readonly<Record<string, unknown>>[];
9
+ readonly definitions?: Readonly<Record<string, unknown>>;
10
+ readonly source: Readonly<Record<string, unknown>>;
11
+ }
12
+ export declare function parse_plutus_blueprint(json: string): PlutusBlueprint;
13
+ export declare function validate_plutus_blueprint(value: unknown): PlutusBlueprint;
14
+ export declare function validate_blueprint_value(schema: unknown, value: unknown): readonly BlueprintViolation[];
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/blueprint/index.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,kBAAkB;IAAG,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE;AAC9G,MAAM,WAAW,eAAe;IAAG,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;IAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CAAE;AAkL1Q,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAIpE;AACD,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,CAAoC;AAQ9G,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,SAAS,kBAAkB,EAAE,CA4EvG"}