@codama/renderers-js 1.5.2 → 1.5.3

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.
@@ -1,52 +1,37 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var nodes = require('@codama/nodes');
6
+ var renderersCore = require('@codama/renderers-core');
7
+ var visitorsCore = require('@codama/visitors-core');
8
+ var codecsStrings = require('@solana/codecs-strings');
9
+ var prettier = require('prettier');
10
+ var estreePlugin = require('prettier/plugins/estree');
11
+ var typeScriptPlugin = require('prettier/plugins/typescript');
12
+ var errors = require('@codama/errors');
13
+ var semver = require('semver');
14
+
15
+ function _interopNamespace(e) {
16
+ if (e && e.__esModule) return e;
17
+ var n = Object.create(null);
18
+ if (e) {
19
+ Object.keys(e).forEach(function (k) {
20
+ if (k !== 'default') {
21
+ var d = Object.getOwnPropertyDescriptor(e, k);
22
+ Object.defineProperty(n, k, d.get ? d : {
23
+ enumerable: true,
24
+ get: function () { return e[k]; }
25
+ });
26
+ }
27
+ });
17
28
  }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ n.default = e;
30
+ return Object.freeze(n);
31
+ }
29
32
 
30
- // src/index.ts
31
- var index_exports = {};
32
- __export(index_exports, {
33
- DEFAULT_NAME_TRANSFORMERS: () => DEFAULT_NAME_TRANSFORMERS,
34
- addToImportMap: () => addToImportMap,
35
- createImportMap: () => createImportMap,
36
- default: () => renderVisitor,
37
- getExternalDependencies: () => getExternalDependencies,
38
- getNameApi: () => getNameApi,
39
- getRenderMapVisitor: () => getRenderMapVisitor,
40
- getTypeManifestVisitor: () => getTypeManifestVisitor,
41
- importMapToString: () => importMapToString,
42
- mergeImportMaps: () => mergeImportMaps,
43
- mergeTypeManifests: () => mergeTypeManifests,
44
- parseImportInput: () => parseImportInput,
45
- removeFromImportMap: () => removeFromImportMap,
46
- renderVisitor: () => renderVisitor,
47
- typeManifest: () => typeManifest
48
- });
49
- module.exports = __toCommonJS(index_exports);
33
+ var estreePlugin__namespace = /*#__PURE__*/_interopNamespace(estreePlugin);
34
+ var typeScriptPlugin__namespace = /*#__PURE__*/_interopNamespace(typeScriptPlugin);
50
35
 
51
36
  // src/utils/importMap.ts
52
37
  var DEFAULT_EXTERNAL_MODULE_MAP = {
@@ -103,20 +88,20 @@ function parseImportInput(input) {
103
88
  usedIdentifier: alias ?? name
104
89
  });
105
90
  }
106
- function addToImportMap(importMap, module2, imports) {
91
+ function addToImportMap(importMap, module, imports) {
107
92
  const parsedImports = imports.map(parseImportInput).map((i) => [i.usedIdentifier, i]);
108
- return mergeImportMaps([importMap, /* @__PURE__ */ new Map([[module2, new Map(parsedImports)]])]);
93
+ return mergeImportMaps([importMap, /* @__PURE__ */ new Map([[module, new Map(parsedImports)]])]);
109
94
  }
110
- function removeFromImportMap(importMap, module2, usedIdentifiers) {
95
+ function removeFromImportMap(importMap, module, usedIdentifiers) {
111
96
  const newMap = new Map(importMap);
112
- const newModuleMap = new Map(newMap.get(module2));
97
+ const newModuleMap = new Map(newMap.get(module));
113
98
  usedIdentifiers.forEach((usedIdentifier) => {
114
99
  newModuleMap.delete(usedIdentifier);
115
100
  });
116
101
  if (newModuleMap.size === 0) {
117
- newMap.delete(module2);
102
+ newMap.delete(module);
118
103
  } else {
119
- newMap.set(module2, newModuleMap);
104
+ newMap.set(module, newModuleMap);
120
105
  }
121
106
  return Object.freeze(newMap);
122
107
  }
@@ -125,8 +110,8 @@ function mergeImportMaps(importMaps) {
125
110
  if (importMaps.length === 1) return importMaps[0];
126
111
  const mergedMap = new Map(importMaps[0]);
127
112
  for (const map of importMaps.slice(1)) {
128
- for (const [module2, imports] of map) {
129
- const mergedModuleMap = mergedMap.get(module2) ?? /* @__PURE__ */ new Map();
113
+ for (const [module, imports] of map) {
114
+ const mergedModuleMap = mergedMap.get(module) ?? /* @__PURE__ */ new Map();
130
115
  for (const [usedIdentifier, importInfo] of imports) {
131
116
  const existingImportInfo = mergedModuleMap.get(usedIdentifier);
132
117
  const shouldOverwriteTypeOnly = existingImportInfo && existingImportInfo.importedIdentifier === importInfo.importedIdentifier && existingImportInfo.isType && !importInfo.isType;
@@ -134,7 +119,7 @@ function mergeImportMaps(importMaps) {
134
119
  mergedModuleMap.set(usedIdentifier, importInfo);
135
120
  }
136
121
  }
137
- mergedMap.set(module2, mergedModuleMap);
122
+ mergedMap.set(module, mergedModuleMap);
138
123
  }
139
124
  }
140
125
  return Object.freeze(mergedMap);
@@ -145,14 +130,14 @@ function importMapToString(importMap, dependencyMap = {}, useGranularImports = f
145
130
  const relative = Number(a.startsWith(".")) - Number(b.startsWith("."));
146
131
  if (relative !== 0) return relative;
147
132
  return a.localeCompare(b);
148
- }).map(([module2, imports]) => {
133
+ }).map(([module, imports]) => {
149
134
  const innerImports = [...imports.values()].map(importInfoToString).sort((a, b) => a.localeCompare(b)).join(", ");
150
- return `import { ${innerImports} } from '${module2}';`;
135
+ return `import { ${innerImports} } from '${module}';`;
151
136
  }).join("\n");
152
137
  }
153
138
  function getExternalDependencies(importMap, dependencyMap, useGranularImports) {
154
139
  const resolvedImports = resolveImportMapModules(importMap, dependencyMap, useGranularImports);
155
- return new Set([...resolvedImports.keys()].filter((module2) => !module2.startsWith(".")));
140
+ return new Set([...resolvedImports.keys()].filter((module) => !module.startsWith(".")));
156
141
  }
157
142
  function resolveImportMapModules(importMap, dependencyMap, useGranularImports) {
158
143
  const dependencyMapWithDefaults = {
@@ -161,8 +146,8 @@ function resolveImportMapModules(importMap, dependencyMap, useGranularImports) {
161
146
  ...dependencyMap
162
147
  };
163
148
  return mergeImportMaps(
164
- [...importMap.entries()].map(([module2, imports]) => {
165
- const resolvedModule = dependencyMapWithDefaults[module2] ?? module2;
149
+ [...importMap.entries()].map(([module, imports]) => {
150
+ const resolvedModule = dependencyMapWithDefaults[module] ?? module;
166
151
  return /* @__PURE__ */ new Map([[resolvedModule, imports]]);
167
152
  })
168
153
  );
@@ -171,73 +156,67 @@ function importInfoToString({ importedIdentifier, isType, usedIdentifier }) {
171
156
  const alias = importedIdentifier !== usedIdentifier ? ` as ${usedIdentifier}` : "";
172
157
  return `${isType ? "type " : ""}${importedIdentifier}${alias}`;
173
158
  }
174
-
175
- // src/utils/nameTransformers.ts
176
- var import_nodes = require("@codama/nodes");
177
159
  function getNameApi(transformers) {
178
160
  const helpers = {
179
- camelCase: import_nodes.camelCase,
180
- capitalize: import_nodes.capitalize,
181
- kebabCase: import_nodes.kebabCase,
182
- pascalCase: import_nodes.pascalCase,
183
- snakeCase: import_nodes.snakeCase,
184
- titleCase: import_nodes.titleCase
161
+ camelCase: nodes.camelCase,
162
+ capitalize: nodes.capitalize,
163
+ kebabCase: nodes.kebabCase,
164
+ pascalCase: nodes.pascalCase,
165
+ snakeCase: nodes.snakeCase,
166
+ titleCase: nodes.titleCase
185
167
  };
186
168
  return Object.fromEntries(
187
169
  Object.entries(transformers).map(([key, transformer]) => [key, (name) => transformer(name, helpers)])
188
170
  );
189
171
  }
190
172
  var DEFAULT_NAME_TRANSFORMERS = {
191
- accountDecodeFunction: (name) => `decode${(0, import_nodes.pascalCase)(name)}`,
192
- accountFetchAllFunction: (name) => `fetchAll${(0, import_nodes.pascalCase)(name)}`,
193
- accountFetchAllMaybeFunction: (name) => `fetchAllMaybe${(0, import_nodes.pascalCase)(name)}`,
194
- accountFetchFromSeedsFunction: (name) => `fetch${(0, import_nodes.pascalCase)(name)}FromSeeds`,
195
- accountFetchFunction: (name) => `fetch${(0, import_nodes.pascalCase)(name)}`,
196
- accountFetchMaybeFromSeedsFunction: (name) => `fetchMaybe${(0, import_nodes.pascalCase)(name)}FromSeeds`,
197
- accountFetchMaybeFunction: (name) => `fetchMaybe${(0, import_nodes.pascalCase)(name)}`,
198
- accountGetSizeFunction: (name) => `get${(0, import_nodes.pascalCase)(name)}Size`,
199
- codecFunction: (name) => `get${(0, import_nodes.pascalCase)(name)}Codec`,
200
- constant: (name) => (0, import_nodes.snakeCase)(name).toUpperCase(),
201
- constantFunction: (name) => `get${(0, import_nodes.pascalCase)(name)}Bytes`,
202
- dataArgsType: (name) => `${(0, import_nodes.pascalCase)(name)}Args`,
203
- dataType: (name) => `${(0, import_nodes.pascalCase)(name)}`,
204
- decoderFunction: (name) => `get${(0, import_nodes.pascalCase)(name)}Decoder`,
173
+ accountDecodeFunction: (name) => `decode${nodes.pascalCase(name)}`,
174
+ accountFetchAllFunction: (name) => `fetchAll${nodes.pascalCase(name)}`,
175
+ accountFetchAllMaybeFunction: (name) => `fetchAllMaybe${nodes.pascalCase(name)}`,
176
+ accountFetchFromSeedsFunction: (name) => `fetch${nodes.pascalCase(name)}FromSeeds`,
177
+ accountFetchFunction: (name) => `fetch${nodes.pascalCase(name)}`,
178
+ accountFetchMaybeFromSeedsFunction: (name) => `fetchMaybe${nodes.pascalCase(name)}FromSeeds`,
179
+ accountFetchMaybeFunction: (name) => `fetchMaybe${nodes.pascalCase(name)}`,
180
+ accountGetSizeFunction: (name) => `get${nodes.pascalCase(name)}Size`,
181
+ codecFunction: (name) => `get${nodes.pascalCase(name)}Codec`,
182
+ constant: (name) => nodes.snakeCase(name).toUpperCase(),
183
+ constantFunction: (name) => `get${nodes.pascalCase(name)}Bytes`,
184
+ dataArgsType: (name) => `${nodes.pascalCase(name)}Args`,
185
+ dataType: (name) => `${nodes.pascalCase(name)}`,
186
+ decoderFunction: (name) => `get${nodes.pascalCase(name)}Decoder`,
205
187
  discriminatedUnionDiscriminator: () => "__kind",
206
- discriminatedUnionFunction: (name) => `${(0, import_nodes.camelCase)(name)}`,
207
- discriminatedUnionVariant: (name) => `${(0, import_nodes.pascalCase)(name)}`,
208
- encoderFunction: (name) => `get${(0, import_nodes.pascalCase)(name)}Encoder`,
209
- enumVariant: (name) => `${(0, import_nodes.pascalCase)(name)}`,
210
- instructionAsyncFunction: (name) => `get${(0, import_nodes.pascalCase)(name)}InstructionAsync`,
211
- instructionAsyncInputType: (name) => `${(0, import_nodes.pascalCase)(name)}AsyncInput`,
212
- instructionDataType: (name) => `${(0, import_nodes.pascalCase)(name)}InstructionData`,
213
- instructionExtraType: (name) => `${(0, import_nodes.pascalCase)(name)}InstructionExtra`,
214
- instructionParseFunction: (name) => `parse${(0, import_nodes.pascalCase)(name)}Instruction`,
215
- instructionParsedType: (name) => `Parsed${(0, import_nodes.pascalCase)(name)}Instruction`,
216
- instructionSyncFunction: (name) => `get${(0, import_nodes.pascalCase)(name)}Instruction`,
217
- instructionSyncInputType: (name) => `${(0, import_nodes.pascalCase)(name)}Input`,
218
- instructionType: (name) => `${(0, import_nodes.pascalCase)(name)}Instruction`,
219
- isDiscriminatedUnionFunction: (name) => `is${(0, import_nodes.pascalCase)(name)}`,
220
- pdaFindFunction: (name) => `find${(0, import_nodes.pascalCase)(name)}Pda`,
221
- pdaSeedsType: (name) => `${(0, import_nodes.pascalCase)(name)}Seeds`,
222
- programAccountsEnum: (name) => `${(0, import_nodes.pascalCase)(name)}Account`,
223
- programAccountsEnumVariant: (name) => `${(0, import_nodes.pascalCase)(name)}`,
224
- programAccountsIdentifierFunction: (name) => `identify${(0, import_nodes.pascalCase)(name)}Account`,
225
- programAddressConstant: (name) => `${(0, import_nodes.snakeCase)(name).toUpperCase()}_PROGRAM_ADDRESS`,
226
- programErrorConstant: (name) => (0, import_nodes.snakeCase)(name).toUpperCase(),
227
- programErrorConstantPrefix: (name) => `${(0, import_nodes.snakeCase)(name).toUpperCase()}_ERROR__`,
228
- programErrorMessagesMap: (name) => `${(0, import_nodes.camelCase)(name)}ErrorMessages`,
229
- programErrorUnion: (name) => `${(0, import_nodes.pascalCase)(name)}Error`,
230
- programGetErrorMessageFunction: (name) => `get${(0, import_nodes.pascalCase)(name)}ErrorMessage`,
231
- programInstructionsEnum: (name) => `${(0, import_nodes.pascalCase)(name)}Instruction`,
232
- programInstructionsEnumVariant: (name) => `${(0, import_nodes.pascalCase)(name)}`,
233
- programInstructionsIdentifierFunction: (name) => `identify${(0, import_nodes.pascalCase)(name)}Instruction`,
234
- programInstructionsParsedUnionType: (name) => `Parsed${(0, import_nodes.pascalCase)(name)}Instruction`,
235
- programIsErrorFunction: (name) => `is${(0, import_nodes.pascalCase)(name)}Error`,
236
- resolverFunction: (name) => `${(0, import_nodes.camelCase)(name)}`
188
+ discriminatedUnionFunction: (name) => `${nodes.camelCase(name)}`,
189
+ discriminatedUnionVariant: (name) => `${nodes.pascalCase(name)}`,
190
+ encoderFunction: (name) => `get${nodes.pascalCase(name)}Encoder`,
191
+ enumVariant: (name) => `${nodes.pascalCase(name)}`,
192
+ instructionAsyncFunction: (name) => `get${nodes.pascalCase(name)}InstructionAsync`,
193
+ instructionAsyncInputType: (name) => `${nodes.pascalCase(name)}AsyncInput`,
194
+ instructionDataType: (name) => `${nodes.pascalCase(name)}InstructionData`,
195
+ instructionExtraType: (name) => `${nodes.pascalCase(name)}InstructionExtra`,
196
+ instructionParseFunction: (name) => `parse${nodes.pascalCase(name)}Instruction`,
197
+ instructionParsedType: (name) => `Parsed${nodes.pascalCase(name)}Instruction`,
198
+ instructionSyncFunction: (name) => `get${nodes.pascalCase(name)}Instruction`,
199
+ instructionSyncInputType: (name) => `${nodes.pascalCase(name)}Input`,
200
+ instructionType: (name) => `${nodes.pascalCase(name)}Instruction`,
201
+ isDiscriminatedUnionFunction: (name) => `is${nodes.pascalCase(name)}`,
202
+ pdaFindFunction: (name) => `find${nodes.pascalCase(name)}Pda`,
203
+ pdaSeedsType: (name) => `${nodes.pascalCase(name)}Seeds`,
204
+ programAccountsEnum: (name) => `${nodes.pascalCase(name)}Account`,
205
+ programAccountsEnumVariant: (name) => `${nodes.pascalCase(name)}`,
206
+ programAccountsIdentifierFunction: (name) => `identify${nodes.pascalCase(name)}Account`,
207
+ programAddressConstant: (name) => `${nodes.snakeCase(name).toUpperCase()}_PROGRAM_ADDRESS`,
208
+ programErrorConstant: (name) => nodes.snakeCase(name).toUpperCase(),
209
+ programErrorConstantPrefix: (name) => `${nodes.snakeCase(name).toUpperCase()}_ERROR__`,
210
+ programErrorMessagesMap: (name) => `${nodes.camelCase(name)}ErrorMessages`,
211
+ programErrorUnion: (name) => `${nodes.pascalCase(name)}Error`,
212
+ programGetErrorMessageFunction: (name) => `get${nodes.pascalCase(name)}ErrorMessage`,
213
+ programInstructionsEnum: (name) => `${nodes.pascalCase(name)}Instruction`,
214
+ programInstructionsEnumVariant: (name) => `${nodes.pascalCase(name)}`,
215
+ programInstructionsIdentifierFunction: (name) => `identify${nodes.pascalCase(name)}Instruction`,
216
+ programInstructionsParsedUnionType: (name) => `Parsed${nodes.pascalCase(name)}Instruction`,
217
+ programIsErrorFunction: (name) => `is${nodes.pascalCase(name)}Error`,
218
+ resolverFunction: (name) => `${nodes.camelCase(name)}`
237
219
  };
238
-
239
- // src/utils/fragment.ts
240
- var import_renderers_core = require("@codama/renderers-core");
241
220
  function createFragment(content) {
242
221
  return Object.freeze({ content, features: /* @__PURE__ */ new Set(), imports: createImportMap() });
243
222
  }
@@ -245,7 +224,7 @@ function isFragment(value) {
245
224
  return typeof value === "object" && value !== null && "content" in value;
246
225
  }
247
226
  function fragment(template, ...items) {
248
- return (0, import_renderers_core.createFragmentTemplate)(template, items, isFragment, mergeFragments);
227
+ return renderersCore.createFragmentTemplate(template, items, isFragment, mergeFragments);
249
228
  }
250
229
  function mergeFragments(fragments, mergeContent) {
251
230
  const filteredFragments = fragments.filter((f) => f !== void 0);
@@ -255,24 +234,24 @@ function mergeFragments(fragments, mergeContent) {
255
234
  imports: mergeImportMaps(filteredFragments.map((f) => f.imports))
256
235
  });
257
236
  }
258
- function use(importInput, module2) {
237
+ function use(importInput, module) {
259
238
  const importInfo = parseImportInput(importInput);
260
- return addFragmentImports(createFragment(importInfo.usedIdentifier), module2, [importInput]);
239
+ return addFragmentImports(createFragment(importInfo.usedIdentifier), module, [importInput]);
261
240
  }
262
241
  function mergeFragmentImports(fragment2, importMaps) {
263
242
  return Object.freeze({ ...fragment2, imports: mergeImportMaps([fragment2.imports, ...importMaps]) });
264
243
  }
265
- function addFragmentImports(fragment2, module2, importInputs) {
266
- return Object.freeze({ ...fragment2, imports: addToImportMap(fragment2.imports, module2, importInputs) });
244
+ function addFragmentImports(fragment2, module, importInputs) {
245
+ return Object.freeze({ ...fragment2, imports: addToImportMap(fragment2.imports, module, importInputs) });
267
246
  }
268
- function removeFragmentImports(fragment2, module2, usedIdentifiers) {
269
- return Object.freeze({ ...fragment2, imports: removeFromImportMap(fragment2.imports, module2, usedIdentifiers) });
247
+ function removeFragmentImports(fragment2, module, usedIdentifiers) {
248
+ return Object.freeze({ ...fragment2, imports: removeFromImportMap(fragment2.imports, module, usedIdentifiers) });
270
249
  }
271
250
  function addFragmentFeatures(fragment2, features) {
272
251
  return Object.freeze({ ...fragment2, features: /* @__PURE__ */ new Set([...fragment2.features, ...features]) });
273
252
  }
274
- function getExportAllFragment(module2) {
275
- return fragment`export * from '${module2}';`;
253
+ function getExportAllFragment(module) {
254
+ return fragment`export * from '${module}';`;
276
255
  }
277
256
  function getDocblockFragment(lines, withLineJump = false) {
278
257
  const lineJump = withLineJump ? "\n" : "";
@@ -317,24 +296,12 @@ function mergeTypeManifests(manifests, options = {}) {
317
296
  value: merge((m) => m.value, mergeValues)
318
297
  });
319
298
  }
320
-
321
- // src/visitors/getRenderMapVisitor.ts
322
- var import_nodes29 = require("@codama/nodes");
323
- var import_renderers_core14 = require("@codama/renderers-core");
324
- var import_visitors_core29 = require("@codama/visitors-core");
325
-
326
- // src/fragments/accountFetchHelpers.ts
327
- var import_visitors_core2 = require("@codama/visitors-core");
328
-
329
- // src/utils/async.ts
330
- var import_nodes2 = require("@codama/nodes");
331
- var import_visitors_core = require("@codama/visitors-core");
332
299
  function hasAsyncFunction(instructionNode, resolvedInputs, asyncResolvers) {
333
300
  const hasByteDeltasAsync = (instructionNode.byteDeltas ?? []).some(
334
- ({ value }) => (0, import_nodes2.isNode)(value, "resolverValueNode") && asyncResolvers.includes(value.name)
301
+ ({ value }) => nodes.isNode(value, "resolverValueNode") && asyncResolvers.includes(value.name)
335
302
  );
336
303
  const hasRemainingAccountsAsync = (instructionNode.remainingAccounts ?? []).some(
337
- ({ value }) => (0, import_nodes2.isNode)(value, "resolverValueNode") && asyncResolvers.includes(value.name)
304
+ ({ value }) => nodes.isNode(value, "resolverValueNode") && asyncResolvers.includes(value.name)
338
305
  );
339
306
  return hasAsyncDefaultValues(resolvedInputs, asyncResolvers) || hasByteDeltasAsync || hasRemainingAccountsAsync;
340
307
  }
@@ -356,8 +323,8 @@ function isAsyncDefaultValue(defaultValue, asyncResolvers) {
356
323
  }
357
324
  }
358
325
  function getInstructionDependencies(input, asyncResolvers, useAsync) {
359
- if ((0, import_nodes2.isNode)(input, "instructionNode")) {
360
- return (0, import_visitors_core.deduplicateInstructionDependencies)([
326
+ if (nodes.isNode(input, "instructionNode")) {
327
+ return visitorsCore.deduplicateInstructionDependencies([
361
328
  ...input.accounts.flatMap((x) => getInstructionDependencies(x, asyncResolvers, useAsync)),
362
329
  ...input.arguments.flatMap((x) => getInstructionDependencies(x, asyncResolvers, useAsync)),
363
330
  ...(input.extraArguments ?? []).flatMap((x) => getInstructionDependencies(x, asyncResolvers, useAsync))
@@ -368,29 +335,29 @@ function getInstructionDependencies(input, asyncResolvers, useAsync) {
368
335
  if (!defaultValue) return [];
369
336
  return getInstructionDependencies({ ...input, defaultValue }, asyncResolvers, useAsync);
370
337
  };
371
- if ((0, import_nodes2.isNode)(input.defaultValue, ["accountValueNode", "accountBumpValueNode"])) {
372
- return [(0, import_nodes2.accountValueNode)(input.defaultValue.name)];
338
+ if (nodes.isNode(input.defaultValue, ["accountValueNode", "accountBumpValueNode"])) {
339
+ return [nodes.accountValueNode(input.defaultValue.name)];
373
340
  }
374
- if ((0, import_nodes2.isNode)(input.defaultValue, ["argumentValueNode"])) {
375
- return [(0, import_nodes2.argumentValueNode)(input.defaultValue.name)];
341
+ if (nodes.isNode(input.defaultValue, ["argumentValueNode"])) {
342
+ return [nodes.argumentValueNode(input.defaultValue.name)];
376
343
  }
377
- if ((0, import_nodes2.isNode)(input.defaultValue, "pdaValueNode")) {
344
+ if (nodes.isNode(input.defaultValue, "pdaValueNode")) {
378
345
  const dependencies = /* @__PURE__ */ new Map();
379
346
  input.defaultValue.seeds.forEach((seed) => {
380
- if ((0, import_nodes2.isNode)(seed.value, ["accountValueNode", "argumentValueNode"])) {
347
+ if (nodes.isNode(seed.value, ["accountValueNode", "argumentValueNode"])) {
381
348
  dependencies.set(seed.value.name, { ...seed.value });
382
349
  }
383
350
  });
384
351
  return [...dependencies.values()];
385
352
  }
386
- if ((0, import_nodes2.isNode)(input.defaultValue, "resolverValueNode")) {
353
+ if (nodes.isNode(input.defaultValue, "resolverValueNode")) {
387
354
  const isSynchronousResolver = !asyncResolvers.includes(input.defaultValue.name);
388
355
  if (useAsync || isSynchronousResolver) {
389
356
  return input.defaultValue.dependsOn ?? [];
390
357
  }
391
358
  }
392
- if ((0, import_nodes2.isNode)(input.defaultValue, "conditionalValueNode")) {
393
- return (0, import_visitors_core.deduplicateInstructionDependencies)([
359
+ if (nodes.isNode(input.defaultValue, "conditionalValueNode")) {
360
+ return visitorsCore.deduplicateInstructionDependencies([
394
361
  ...getNestedDependencies(input.defaultValue.condition),
395
362
  ...getNestedDependencies(input.defaultValue.ifTrue),
396
363
  ...getNestedDependencies(input.defaultValue.ifFalse)
@@ -398,58 +365,74 @@ function getInstructionDependencies(input, asyncResolvers, useAsync) {
398
365
  }
399
366
  return [];
400
367
  }
401
-
402
- // src/utils/codecs.ts
403
- var import_codecs_strings = require("@solana/codecs-strings");
404
368
  function getBytesFromBytesValueNode(node) {
405
369
  switch (node.encoding) {
406
370
  case "utf8":
407
- return (0, import_codecs_strings.getUtf8Encoder)().encode(node.data);
371
+ return codecsStrings.getUtf8Encoder().encode(node.data);
408
372
  case "base16":
409
- return (0, import_codecs_strings.getBase16Encoder)().encode(node.data);
373
+ return codecsStrings.getBase16Encoder().encode(node.data);
410
374
  case "base58":
411
- return (0, import_codecs_strings.getBase58Encoder)().encode(node.data);
375
+ return codecsStrings.getBase58Encoder().encode(node.data);
412
376
  case "base64":
413
377
  default:
414
- return (0, import_codecs_strings.getBase64Encoder)().encode(node.data);
378
+ return codecsStrings.getBase64Encoder().encode(node.data);
415
379
  }
416
380
  }
417
-
418
- // src/utils/customData.ts
419
- var import_nodes3 = require("@codama/nodes");
420
381
  var parseCustomDataOptions = (customDataOptions, defaultSuffix) => new Map(
421
382
  customDataOptions.map((o) => {
422
383
  const options = typeof o === "string" ? { name: o } : o;
423
- const importAs = (0, import_nodes3.camelCase)(options.importAs ?? `${options.name}${defaultSuffix}`);
384
+ const importAs = nodes.camelCase(options.importAs ?? `${options.name}${defaultSuffix}`);
424
385
  const importFrom = options.importFrom ?? "hooked";
425
386
  return [
426
- (0, import_nodes3.camelCase)(options.name),
387
+ nodes.camelCase(options.name),
427
388
  {
428
389
  extract: options.extract ?? false,
429
- extractAs: options.extractAs ? (0, import_nodes3.camelCase)(options.extractAs) : importAs,
390
+ extractAs: options.extractAs ? nodes.camelCase(options.extractAs) : importAs,
430
391
  importAs,
431
392
  importFrom,
432
- linkNode: (0, import_nodes3.definedTypeLinkNode)(importAs)
393
+ linkNode: nodes.definedTypeLinkNode(importAs)
433
394
  }
434
395
  ];
435
396
  })
436
397
  );
437
- var getDefinedTypeNodesToExtract = (nodes, parsedCustomDataOptions) => nodes.flatMap((node) => {
398
+ var getDefinedTypeNodesToExtract = (nodes$1, parsedCustomDataOptions) => nodes$1.flatMap((node) => {
438
399
  const options = parsedCustomDataOptions.get(node.name);
439
400
  if (!options || !options.extract) return [];
440
- if ((0, import_nodes3.isNode)(node, "accountNode")) {
441
- return [(0, import_nodes3.definedTypeNode)({ name: options.extractAs, type: { ...node.data } })];
401
+ if (nodes.isNode(node, "accountNode")) {
402
+ return [nodes.definedTypeNode({ name: options.extractAs, type: { ...node.data } })];
442
403
  }
443
404
  return [
444
- (0, import_nodes3.definedTypeNode)({
405
+ nodes.definedTypeNode({
445
406
  name: options.extractAs,
446
- type: (0, import_nodes3.structTypeNodeFromInstructionArgumentNodes)(node.arguments)
407
+ type: nodes.structTypeNodeFromInstructionArgumentNodes(node.arguments)
447
408
  })
448
409
  ];
449
410
  });
450
-
451
- // src/utils/linkOverrides.ts
452
- var import_errors = require("@codama/errors");
411
+ var DEFAULT_PRETTIER_OPTIONS = {
412
+ arrowParens: "always",
413
+ parser: "typescript",
414
+ plugins: [estreePlugin__namespace, typeScriptPlugin__namespace],
415
+ printWidth: 80,
416
+ semi: true,
417
+ singleQuote: true,
418
+ tabWidth: 2,
419
+ trailingComma: "es5",
420
+ useTabs: false
421
+ };
422
+ async function formatCode(renderMap, options) {
423
+ const shouldFormatCode = options.formatCode ?? true;
424
+ if (!shouldFormatCode) return renderMap;
425
+ const prettierOptions = {
426
+ ...DEFAULT_PRETTIER_OPTIONS,
427
+ ...await resolvePrettierOptions(options.packageFolder),
428
+ ...options.prettierOptions
429
+ };
430
+ return await renderersCore.mapRenderMapContentAsync(renderMap, (code) => prettier.format(code, prettierOptions));
431
+ }
432
+ async function resolvePrettierOptions(packageFolder) {
433
+ if (!packageFolder) return null;
434
+ return await prettier.resolveConfig(packageFolder);
435
+ }
453
436
  function getImportFromFactory(overrides, customAccountData, customInstructionData) {
454
437
  const customDataOverrides = Object.fromEntries(
455
438
  [...customAccountData.values(), ...customInstructionData.values()].map(({ importFrom, importAs }) => [
@@ -481,7 +464,7 @@ function getImportFromFactory(overrides, customAccountData, customInstructionDat
481
464
  case "resolverValueNode":
482
465
  return linkOverrides.resolvers[node.name] ?? "hooked";
483
466
  default:
484
- throw new import_errors.CodamaError(import_errors.CODAMA_ERROR__UNEXPECTED_NODE_KIND, {
467
+ throw new errors.CodamaError(errors.CODAMA_ERROR__UNEXPECTED_NODE_KIND, {
485
468
  expectedKinds: [
486
469
  "AccountLinkNode",
487
470
  "DefinedTypeLinkNode",
@@ -496,11 +479,6 @@ function getImportFromFactory(overrides, customAccountData, customInstructionDat
496
479
  }
497
480
  };
498
481
  }
499
-
500
- // src/utils/packageJson.ts
501
- var import_errors2 = require("@codama/errors");
502
- var import_renderers_core2 = require("@codama/renderers-core");
503
- var import_semver = require("semver");
504
482
  var DEFAULT_DEPENDENCY_VERSIONS = {
505
483
  "@solana/accounts": "^5.0.0",
506
484
  "@solana/addresses": "^5.0.0",
@@ -517,11 +495,11 @@ function syncPackageJson(renderMap, options) {
517
495
  const packageFolder = options.packageFolder;
518
496
  if (!packageFolder) {
519
497
  if (shouldSyncPackageJson) {
520
- (0, import_errors2.logWarn)("Cannot sync package.json. Please provide the 'packageFolder' option.");
498
+ errors.logWarn("Cannot sync package.json. Please provide the 'packageFolder' option.");
521
499
  }
522
500
  return;
523
501
  }
524
- const packageJsonPath = (0, import_renderers_core2.joinPath)(packageFolder, "package.json");
502
+ const packageJsonPath = renderersCore.joinPath(packageFolder, "package.json");
525
503
  const usedDependencies = getUsedDependencyVersions(
526
504
  renderMap,
527
505
  options.dependencyMap ?? {},
@@ -529,17 +507,17 @@ function syncPackageJson(renderMap, options) {
529
507
  options.useGranularImports ?? false
530
508
  );
531
509
  if (!shouldSyncPackageJson) {
532
- if ((0, import_renderers_core2.fileExists)(packageJsonPath)) {
533
- checkExistingPackageJson((0, import_renderers_core2.readJson)(packageJsonPath), usedDependencies);
510
+ if (renderersCore.fileExists(packageJsonPath)) {
511
+ checkExistingPackageJson(renderersCore.readJson(packageJsonPath), usedDependencies);
534
512
  }
535
513
  return;
536
514
  }
537
- if ((0, import_renderers_core2.fileExists)(packageJsonPath)) {
538
- const packageJson = updateExistingPackageJson((0, import_renderers_core2.readJson)(packageJsonPath), usedDependencies);
539
- (0, import_renderers_core2.writeFile)(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n");
515
+ if (renderersCore.fileExists(packageJsonPath)) {
516
+ const packageJson = updateExistingPackageJson(renderersCore.readJson(packageJsonPath), usedDependencies);
517
+ renderersCore.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n");
540
518
  } else {
541
519
  const packageJson = createNewPackageJson(usedDependencies);
542
- (0, import_renderers_core2.writeFile)(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n");
520
+ renderersCore.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n");
543
521
  }
544
522
  }
545
523
  function createNewPackageJson(dependencyVersions) {
@@ -609,7 +587,7 @@ function checkExistingPackageJson(packageJson, dependencyVersions) {
609
587
  `).join("");
610
588
  const outdatedList = dependenciesToUpdate.map((d) => `- ${d} outdated: ${existingDependencies[d]} -> ${dependencyVersions[d]}
611
589
  `).join("");
612
- (0, import_errors2.logWarn)(
590
+ errors.logWarn(
613
591
  `The following dependencies in your \`package.json\` are out-of-date or missing:
614
592
  ${missingList}${outdatedList}`
615
593
  );
@@ -634,7 +612,7 @@ function getUsedDependencyVersions(renderMap, dependencyMap, dependencyVersions,
634
612
  [{}, /* @__PURE__ */ new Set()]
635
613
  );
636
614
  if (missingDependencies.size > 0) {
637
- throw new import_errors2.CodamaError(import_errors2.CODAMA_ERROR__RENDERERS__MISSING_DEPENDENCY_VERSIONS, {
615
+ throw new errors.CodamaError(errors.CODAMA_ERROR__RENDERERS__MISSING_DEPENDENCY_VERSIONS, {
638
616
  dependencies: [...missingDependencies],
639
617
  message: "Please add these dependencies to the `dependencyVersions` option."
640
618
  });
@@ -643,15 +621,15 @@ function getUsedDependencyVersions(renderMap, dependencyMap, dependencyVersions,
643
621
  }
644
622
  function shouldUpdateRange(dependency, currentRange, requiredRange) {
645
623
  try {
646
- if ((0, import_semver.subset)(currentRange, requiredRange)) {
624
+ if (semver.subset(currentRange, requiredRange)) {
647
625
  return false;
648
626
  }
649
- const minRequiredVersion = (0, import_semver.minVersion)(requiredRange);
650
- const minCurrentVersion = (0, import_semver.minVersion)(currentRange);
627
+ const minRequiredVersion = semver.minVersion(requiredRange);
628
+ const minCurrentVersion = semver.minVersion(currentRange);
651
629
  if (!minCurrentVersion || !minRequiredVersion) {
652
630
  throw new Error("Could not determine minimum versions.");
653
631
  }
654
- if ((0, import_semver.lt)(minCurrentVersion, minRequiredVersion)) {
632
+ if (semver.lt(minCurrentVersion, minRequiredVersion)) {
655
633
  return true;
656
634
  }
657
635
  return false;
@@ -671,7 +649,7 @@ function updateDependency(dependencyGroup, dependency, requiredRange) {
671
649
  // src/fragments/accountFetchHelpers.ts
672
650
  function getAccountFetchHelpersFragment(scope) {
673
651
  const { accountPath, typeManifest: typeManifest2, nameApi, customAccountData } = scope;
674
- const accountNode = (0, import_visitors_core2.getLastNodeFromPath)(accountPath);
652
+ const accountNode = visitorsCore.getLastNodeFromPath(accountPath);
675
653
  const decodeFunction = nameApi.accountDecodeFunction(accountNode.name);
676
654
  const fetchAllFunction = nameApi.accountFetchAllFunction(accountNode.name);
677
655
  const fetchAllMaybeFunction = nameApi.accountFetchAllMaybeFunction(accountNode.name);
@@ -680,7 +658,7 @@ function getAccountFetchHelpersFragment(scope) {
680
658
  const hasCustomData = customAccountData.has(accountNode.name);
681
659
  const accountType = hasCustomData ? typeManifest2.strictType : nameApi.dataType(accountNode.name);
682
660
  const decoderFunction = hasCustomData ? typeManifest2.decoder : `${nameApi.decoderFunction(accountNode.name)}()`;
683
- return (0, import_visitors_core2.pipe)(
661
+ return visitorsCore.pipe(
684
662
  fragment`export function ${decodeFunction}<TAddress extends string = string>(encodedAccount: EncodedAccount<TAddress>): Account<${accountType}, TAddress>;
685
663
  export function ${decodeFunction}<TAddress extends string = string>(encodedAccount: MaybeEncodedAccount<TAddress>): MaybeAccount<${accountType}, TAddress>;
686
664
  export function ${decodeFunction}<TAddress extends string = string>(encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress>): Account<${accountType}, TAddress> | MaybeAccount<${accountType}, TAddress> {
@@ -740,28 +718,20 @@ export async function ${fetchAllMaybeFunction}(
740
718
  ])
741
719
  );
742
720
  }
743
-
744
- // src/fragments/accountPage.ts
745
- var import_nodes9 = require("@codama/nodes");
746
- var import_visitors_core7 = require("@codama/visitors-core");
747
-
748
- // src/fragments/accountPdaHelpers.ts
749
- var import_nodes4 = require("@codama/nodes");
750
- var import_visitors_core3 = require("@codama/visitors-core");
751
721
  function getAccountPdaHelpersFragment(scope) {
752
722
  const { accountPath, nameApi, linkables, customAccountData, typeManifest: typeManifest2 } = scope;
753
- const accountNode = (0, import_visitors_core3.getLastNodeFromPath)(accountPath);
723
+ const accountNode = visitorsCore.getLastNodeFromPath(accountPath);
754
724
  const pdaNode = accountNode.pda ? linkables.get([...accountPath, accountNode.pda]) : void 0;
755
725
  if (!pdaNode) return;
756
726
  const accountType = customAccountData.has(accountNode.name) ? typeManifest2.strictType : nameApi.dataType(accountNode.name);
757
727
  const importFrom = "generatedPdas";
758
728
  const pdaSeedsType = nameApi.pdaSeedsType(pdaNode.name);
759
729
  const findPdaFunction = nameApi.pdaFindFunction(pdaNode.name);
760
- const hasVariableSeeds = pdaNode.seeds.filter((0, import_nodes4.isNodeFilter)("variablePdaSeedNode")).length > 0;
730
+ const hasVariableSeeds = pdaNode.seeds.filter(nodes.isNodeFilter("variablePdaSeedNode")).length > 0;
761
731
  const fetchFromSeedsFunction = nameApi.accountFetchFromSeedsFunction(accountNode.name);
762
732
  const fetchMaybeFromSeedsFunction = nameApi.accountFetchMaybeFromSeedsFunction(accountNode.name);
763
733
  const fetchMaybeFunction = nameApi.accountFetchMaybeFunction(accountNode.name);
764
- return (0, import_visitors_core3.pipe)(
734
+ return visitorsCore.pipe(
765
735
  fragment`export async function ${fetchFromSeedsFunction}(
766
736
  rpc: Parameters<typeof fetchEncodedAccount>[0],
767
737
  ${hasVariableSeeds ? `seeds: ${pdaSeedsType},` : ""}
@@ -791,12 +761,9 @@ export async function ${fetchMaybeFromSeedsFunction}(
791
761
  ])
792
762
  );
793
763
  }
794
-
795
- // src/fragments/accountSizeHelpers.ts
796
- var import_visitors_core4 = require("@codama/visitors-core");
797
764
  function getAccountSizeHelpersFragment(scope) {
798
765
  const { accountPath, nameApi } = scope;
799
- const accountNode = (0, import_visitors_core4.getLastNodeFromPath)(accountPath);
766
+ const accountNode = visitorsCore.getLastNodeFromPath(accountPath);
800
767
  if (accountNode.size == null) return;
801
768
  const getSizeFunction = nameApi.accountGetSizeFunction(accountNode.name);
802
769
  return fragment`export function ${getSizeFunction}(): number {
@@ -804,10 +771,6 @@ function getAccountSizeHelpersFragment(scope) {
804
771
  }`;
805
772
  }
806
773
 
807
- // src/fragments/accountType.ts
808
- var import_nodes7 = require("@codama/nodes");
809
- var import_visitors_core5 = require("@codama/visitors-core");
810
-
811
774
  // src/fragments/type.ts
812
775
  function getTypeFragment(scope) {
813
776
  const { name, manifest, nameApi, docs = [] } = scope;
@@ -821,9 +784,6 @@ function getTypeFragment(scope) {
821
784
  const looseExport = manifest.strictType.content === manifest.looseType.content ? aliasedLooseName : fragment`export type ${looseName} = ${manifest.looseType};`;
822
785
  return fragment`${docblock}export type ${strictName} = ${manifest.strictType};\n\n${looseExport}`;
823
786
  }
824
-
825
- // src/fragments/typeDecoder.ts
826
- var import_nodes5 = require("@codama/nodes");
827
787
  function getTypeDecoderFragment(scope) {
828
788
  const { name, node, manifest, nameApi, docs = [] } = scope;
829
789
  const decoderFunction = nameApi.decoderFunction(name);
@@ -833,15 +793,12 @@ function getTypeDecoderFragment(scope) {
833
793
  typeof scope.size === "number" ? "type FixedSizeDecoder" : "type Decoder",
834
794
  "solanaCodecsCore"
835
795
  );
836
- const useTypeCast = (0, import_nodes5.isNode)(node, "enumTypeNode") && (0, import_nodes5.isDataEnum)(node) && typeof scope.size === "number";
796
+ const useTypeCast = nodes.isNode(node, "enumTypeNode") && nodes.isDataEnum(node) && typeof scope.size === "number";
837
797
  const typeCast = useTypeCast ? fragment` as ${decoderType}<${strictName}>` : "";
838
798
  return fragment`${docblock}export function ${decoderFunction}(): ${decoderType}<${strictName}> {
839
799
  return ${manifest.decoder}${typeCast};
840
800
  }`;
841
801
  }
842
-
843
- // src/fragments/typeEncoder.ts
844
- var import_nodes6 = require("@codama/nodes");
845
802
  function getTypeEncoderFragment(scope) {
846
803
  const { name, node, manifest, nameApi, docs = [] } = scope;
847
804
  const encoderFunction = nameApi.encoderFunction(name);
@@ -851,7 +808,7 @@ function getTypeEncoderFragment(scope) {
851
808
  typeof scope.size === "number" ? "type FixedSizeEncoder" : "type Encoder",
852
809
  "solanaCodecsCore"
853
810
  );
854
- const useTypeCast = (0, import_nodes6.isNode)(node, "enumTypeNode") && (0, import_nodes6.isDataEnum)(node) && typeof scope.size === "number";
811
+ const useTypeCast = nodes.isNode(node, "enumTypeNode") && nodes.isDataEnum(node) && typeof scope.size === "number";
855
812
  const typeCast = useTypeCast ? fragment` as ${encoderType}<${looseName}>` : "";
856
813
  return fragment`${docblock}export function ${encoderFunction}(): ${encoderType}<${looseName}> {
857
814
  return ${manifest.encoder}${typeCast};
@@ -891,7 +848,7 @@ function getTypeWithCodecFragment(scope) {
891
848
  // src/fragments/accountType.ts
892
849
  function getAccountTypeFragment(scope) {
893
850
  const { accountPath, typeManifest: typeManifest2, nameApi, customAccountData } = scope;
894
- const accountNode = (0, import_visitors_core5.getLastNodeFromPath)(accountPath);
851
+ const accountNode = visitorsCore.getLastNodeFromPath(accountPath);
895
852
  if (customAccountData.has(accountNode.name)) return;
896
853
  return getTypeWithCodecFragment({
897
854
  codecDocs: [`Gets the codec for {@link ${nameApi.dataType(accountNode.name)}} account data.`],
@@ -900,15 +857,11 @@ function getAccountTypeFragment(scope) {
900
857
  manifest: typeManifest2,
901
858
  name: accountNode.name,
902
859
  nameApi,
903
- node: (0, import_nodes7.resolveNestedTypeNode)(accountNode.data),
860
+ node: nodes.resolveNestedTypeNode(accountNode.data),
904
861
  size: scope.size,
905
862
  typeDocs: accountNode.docs
906
863
  });
907
864
  }
908
-
909
- // src/fragments/discriminatorConstants.ts
910
- var import_nodes8 = require("@codama/nodes");
911
- var import_visitors_core6 = require("@codama/visitors-core");
912
865
  function getDiscriminatorConstantsFragment(scope) {
913
866
  const fragments = scope.discriminatorNodes.map((node) => getDiscriminatorConstantFragment(node, scope)).filter(Boolean);
914
867
  return mergeFragments(fragments, (c) => c.join("\n\n"));
@@ -925,22 +878,22 @@ function getDiscriminatorConstantFragment(discriminatorNode, scope) {
925
878
  }
926
879
  function getConstantDiscriminatorConstantFragment(discriminatorNode, scope) {
927
880
  const { discriminatorNodes, typeManifestVisitor, prefix } = scope;
928
- const index = discriminatorNodes.filter((0, import_nodes8.isNodeFilter)("constantDiscriminatorNode")).indexOf(discriminatorNode);
881
+ const index = discriminatorNodes.filter(nodes.isNodeFilter("constantDiscriminatorNode")).indexOf(discriminatorNode);
929
882
  const suffix = index <= 0 ? "" : `_${index + 1}`;
930
- const name = (0, import_nodes8.camelCase)(`${prefix}_discriminator${suffix}`);
931
- const encoder = (0, import_visitors_core6.visit)(discriminatorNode.constant.type, typeManifestVisitor).encoder;
932
- const value = (0, import_visitors_core6.visit)(discriminatorNode.constant.value, typeManifestVisitor).value;
883
+ const name = nodes.camelCase(`${prefix}_discriminator${suffix}`);
884
+ const encoder = visitorsCore.visit(discriminatorNode.constant.type, typeManifestVisitor).encoder;
885
+ const value = visitorsCore.visit(discriminatorNode.constant.value, typeManifestVisitor).value;
933
886
  return getConstantFragment({ ...scope, encoder, name, value });
934
887
  }
935
888
  function getFieldDiscriminatorConstantFragment(discriminatorNode, scope) {
936
889
  const { fields, prefix, typeManifestVisitor } = scope;
937
890
  const field = fields.find((f) => f.name === discriminatorNode.name);
938
- if (!field || !field.defaultValue || !(0, import_nodes8.isNode)(field.defaultValue, import_nodes8.VALUE_NODES)) {
891
+ if (!field || !field.defaultValue || !nodes.isNode(field.defaultValue, nodes.VALUE_NODES)) {
939
892
  return null;
940
893
  }
941
- const name = (0, import_nodes8.camelCase)(`${prefix}_${discriminatorNode.name}`);
942
- const encoder = (0, import_visitors_core6.visit)(field.type, typeManifestVisitor).encoder;
943
- const value = (0, import_visitors_core6.visit)(field.defaultValue, typeManifestVisitor).value;
894
+ const name = nodes.camelCase(`${prefix}_${discriminatorNode.name}`);
895
+ const encoder = visitorsCore.visit(field.type, typeManifestVisitor).encoder;
896
+ const value = visitorsCore.visit(field.defaultValue, typeManifestVisitor).value;
944
897
  return getConstantFragment({ ...scope, encoder, name, value });
945
898
  }
946
899
  function getConstantFragment(scope) {
@@ -952,12 +905,12 @@ function getConstantFragment(scope) {
952
905
 
953
906
  // src/fragments/accountPage.ts
954
907
  function getAccountPageFragment(scope) {
955
- const node = (0, import_visitors_core7.getLastNodeFromPath)(scope.accountPath);
956
- if (!(0, import_visitors_core7.findProgramNodeFromPath)(scope.accountPath)) {
908
+ const node = visitorsCore.getLastNodeFromPath(scope.accountPath);
909
+ if (!visitorsCore.findProgramNodeFromPath(scope.accountPath)) {
957
910
  throw new Error("Account must be visited inside a program.");
958
911
  }
959
- const typeManifest2 = (0, import_visitors_core7.visit)(node, scope.typeManifestVisitor);
960
- const fields = (0, import_nodes9.resolveNestedTypeNode)(node.data).fields;
912
+ const typeManifest2 = visitorsCore.visit(node, scope.typeManifestVisitor);
913
+ const fields = nodes.resolveNestedTypeNode(node.data).fields;
961
914
  return mergeFragments(
962
915
  [
963
916
  getDiscriminatorConstantsFragment({
@@ -974,30 +927,24 @@ function getAccountPageFragment(scope) {
974
927
  (cs) => cs.join("\n\n")
975
928
  );
976
929
  }
977
-
978
- // src/fragments/discriminatorCondition.ts
979
- var import_nodes10 = require("@codama/nodes");
980
- var import_renderers_core3 = require("@codama/renderers-core");
981
- var import_visitors_core8 = require("@codama/visitors-core");
982
- var import_codecs_strings2 = require("@solana/codecs-strings");
983
930
  function getDiscriminatorConditionFragment(scope) {
984
- return (0, import_visitors_core8.pipe)(
931
+ return visitorsCore.pipe(
985
932
  mergeFragments(
986
933
  scope.discriminators.flatMap((discriminator) => {
987
- if ((0, import_nodes10.isNode)(discriminator, "sizeDiscriminatorNode")) {
934
+ if (nodes.isNode(discriminator, "sizeDiscriminatorNode")) {
988
935
  return [getSizeConditionFragment(discriminator, scope)];
989
936
  }
990
- if ((0, import_nodes10.isNode)(discriminator, "constantDiscriminatorNode")) {
937
+ if (nodes.isNode(discriminator, "constantDiscriminatorNode")) {
991
938
  return [getByteConditionFragment(discriminator, scope)];
992
939
  }
993
- if ((0, import_nodes10.isNode)(discriminator, "fieldDiscriminatorNode")) {
940
+ if (nodes.isNode(discriminator, "fieldDiscriminatorNode")) {
994
941
  return [getFieldConditionFragment(discriminator, scope)];
995
942
  }
996
943
  return [];
997
944
  }),
998
945
  (c) => c.join(" && ")
999
946
  ),
1000
- (f) => (0, import_renderers_core3.mapFragmentContent)(f, (c) => `if (${c}) { ${scope.ifTrue} }`)
947
+ (f) => renderersCore.mapFragmentContent(f, (c) => `if (${c}) { ${scope.ifTrue} }`)
1001
948
  );
1002
949
  }
1003
950
  function getSizeConditionFragment(discriminator, scope) {
@@ -1006,7 +953,7 @@ function getSizeConditionFragment(discriminator, scope) {
1006
953
  }
1007
954
  function getByteConditionFragment(discriminator, scope) {
1008
955
  const { dataName, typeManifestVisitor } = scope;
1009
- const constant = (0, import_visitors_core8.visit)(discriminator.constant, typeManifestVisitor).value;
956
+ const constant = visitorsCore.visit(discriminator.constant, typeManifestVisitor).value;
1010
957
  return fragment`${use("containsBytes", "solanaCodecsCore")}(${dataName}, ${constant}, ${discriminator.offset})`;
1011
958
  }
1012
959
  function getFieldConditionFragment(discriminator, scope) {
@@ -1016,17 +963,17 @@ function getFieldConditionFragment(discriminator, scope) {
1016
963
  `Field discriminator "${discriminator.name}" does not have a matching argument with default value.`
1017
964
  );
1018
965
  }
1019
- if ((0, import_nodes10.isNode)(field.type, "arrayTypeNode") && (0, import_nodes10.isNode)(field.type.item, "numberTypeNode") && field.type.item.format === "u8" && (0, import_nodes10.isNode)(field.type.count, "fixedCountNode") && (0, import_nodes10.isNode)(field.defaultValue, "arrayValueNode") && field.defaultValue.items.every((0, import_nodes10.isNodeFilter)("numberValueNode"))) {
1020
- const base64Bytes = (0, import_codecs_strings2.getBase64Decoder)().decode(
966
+ if (nodes.isNode(field.type, "arrayTypeNode") && nodes.isNode(field.type.item, "numberTypeNode") && field.type.item.format === "u8" && nodes.isNode(field.type.count, "fixedCountNode") && nodes.isNode(field.defaultValue, "arrayValueNode") && field.defaultValue.items.every(nodes.isNodeFilter("numberValueNode"))) {
967
+ const base64Bytes = codecsStrings.getBase64Decoder().decode(
1021
968
  new Uint8Array(field.defaultValue.items.map((node) => node.number))
1022
969
  );
1023
970
  return getByteConditionFragment(
1024
- (0, import_nodes10.constantDiscriminatorNode)((0, import_nodes10.constantValueNodeFromBytes)("base64", base64Bytes), discriminator.offset),
971
+ nodes.constantDiscriminatorNode(nodes.constantValueNodeFromBytes("base64", base64Bytes), discriminator.offset),
1025
972
  scope
1026
973
  );
1027
974
  }
1028
975
  return getByteConditionFragment(
1029
- (0, import_nodes10.constantDiscriminatorNode)((0, import_nodes10.constantValueNode)(field.type, field.defaultValue), discriminator.offset),
976
+ nodes.constantDiscriminatorNode(nodes.constantValueNode(field.type, field.defaultValue), discriminator.offset),
1030
977
  scope
1031
978
  );
1032
979
  }
@@ -1106,19 +1053,13 @@ function getIsErrorFunctionFragment(scope) {
1106
1053
  return ${use("isProgramError", "solanaPrograms")}<TProgramErrorCode>(error, transactionMessage, ${programAddressConstant}, code);
1107
1054
  }`;
1108
1055
  }
1109
-
1110
- // src/fragments/indexPage.ts
1111
- var import_nodes11 = require("@codama/nodes");
1112
1056
  function getIndexPageFragment(items) {
1113
1057
  if (items.length === 0) return;
1114
- const names = items.map((item) => (0, import_nodes11.camelCase)(item.name)).sort((a, b) => a.localeCompare(b)).map((name) => getExportAllFragment(`./${name}`));
1058
+ const names = items.map((item) => nodes.camelCase(item.name)).sort((a, b) => a.localeCompare(b)).map((name) => getExportAllFragment(`./${name}`));
1115
1059
  return mergeFragments(names, (cs) => cs.join("\n"));
1116
1060
  }
1117
-
1118
- // src/fragments/instructionAccountMeta.ts
1119
- var import_nodes12 = require("@codama/nodes");
1120
1061
  function getInstructionAccountMetaFragment(instructionAccountNode) {
1121
- const typeParam = `TAccount${(0, import_nodes12.pascalCase)(instructionAccountNode.name)}`;
1062
+ const typeParam = `TAccount${nodes.pascalCase(instructionAccountNode.name)}`;
1122
1063
  if (instructionAccountNode.isSigner === true && instructionAccountNode.isWritable) {
1123
1064
  return fragment`${use("type WritableSignerAccount", "solanaInstructions")}<${typeParam}> & ${use("type AccountSignerMeta", "solanaSigners")}<${typeParam}>`;
1124
1065
  }
@@ -1130,17 +1071,13 @@ function getInstructionAccountMetaFragment(instructionAccountNode) {
1130
1071
  }
1131
1072
  return fragment`${use("type ReadonlyAccount", "solanaInstructions")}<${typeParam}>`;
1132
1073
  }
1133
-
1134
- // src/fragments/instructionAccountTypeParam.ts
1135
- var import_nodes13 = require("@codama/nodes");
1136
- var import_visitors_core9 = require("@codama/visitors-core");
1137
1074
  function getInstructionAccountTypeParamFragment(scope) {
1138
- const { instructionAccountPath, allowAccountMeta, linkables } = scope;
1139
- const instructionAccountNode = (0, import_visitors_core9.getLastNodeFromPath)(instructionAccountPath);
1140
- const instructionNode = (0, import_visitors_core9.findInstructionNodeFromPath)(instructionAccountPath);
1141
- const programNode = (0, import_visitors_core9.findProgramNodeFromPath)(instructionAccountPath);
1142
- const typeParam = `TAccount${(0, import_nodes13.pascalCase)(instructionAccountNode.name)}`;
1143
- const accountMeta = allowAccountMeta ? fragment` | ${use("type AccountMeta", "solanaInstructions")}<string>` : void 0;
1075
+ const { instructionAccountPath, linkables } = scope;
1076
+ const instructionAccountNode = visitorsCore.getLastNodeFromPath(instructionAccountPath);
1077
+ const instructionNode = visitorsCore.findInstructionNodeFromPath(instructionAccountPath);
1078
+ const programNode = visitorsCore.findProgramNodeFromPath(instructionAccountPath);
1079
+ const typeParam = `TAccount${nodes.pascalCase(instructionAccountNode.name)}`;
1080
+ const accountMeta = fragment` | ${use("type AccountMeta", "solanaInstructions")}<string>` ;
1144
1081
  if (instructionNode.optionalAccountStrategy === "omitted" && instructionAccountNode.isOptional) {
1145
1082
  return fragment`${typeParam} extends string${accountMeta} | undefined = undefined`;
1146
1083
  }
@@ -1160,13 +1097,8 @@ function getDefaultAddress(defaultValue, programId, linkables) {
1160
1097
  return "string";
1161
1098
  }
1162
1099
  }
1163
-
1164
- // src/fragments/instructionByteDelta.ts
1165
- var import_nodes14 = require("@codama/nodes");
1166
- var import_renderers_core4 = require("@codama/renderers-core");
1167
- var import_visitors_core10 = require("@codama/visitors-core");
1168
1100
  function getInstructionByteDeltaFragment(scope) {
1169
- const { byteDeltas } = (0, import_visitors_core10.getLastNodeFromPath)(scope.instructionPath);
1101
+ const { byteDeltas } = visitorsCore.getLastNodeFromPath(scope.instructionPath);
1170
1102
  const fragments = (byteDeltas ?? []).flatMap((c) => getByteDeltaFragment(c, scope));
1171
1103
  if (fragments.length === 0) return;
1172
1104
  return mergeFragments(
@@ -1177,16 +1109,16 @@ const byteDelta: number = [${c.join(",")}].reduce((a, b) => a + b, 0);`
1177
1109
  }
1178
1110
  function getByteDeltaFragment(byteDelta, scope) {
1179
1111
  let bytesFragment = (() => {
1180
- if ((0, import_nodes14.isNode)(byteDelta.value, "numberValueNode")) {
1112
+ if (nodes.isNode(byteDelta.value, "numberValueNode")) {
1181
1113
  return getNumberValueNodeFragment(byteDelta);
1182
1114
  }
1183
- if ((0, import_nodes14.isNode)(byteDelta.value, "argumentValueNode")) {
1115
+ if (nodes.isNode(byteDelta.value, "argumentValueNode")) {
1184
1116
  return getArgumentValueNodeFragment(byteDelta);
1185
1117
  }
1186
- if ((0, import_nodes14.isNode)(byteDelta.value, "accountLinkNode")) {
1118
+ if (nodes.isNode(byteDelta.value, "accountLinkNode")) {
1187
1119
  return getAccountLinkNodeFragment(byteDelta, scope);
1188
1120
  }
1189
- if ((0, import_nodes14.isNode)(byteDelta.value, "resolverValueNode")) {
1121
+ if (nodes.isNode(byteDelta.value, "resolverValueNode")) {
1190
1122
  return getResolverValueNodeFragment(byteDelta, scope);
1191
1123
  }
1192
1124
  return null;
@@ -1196,21 +1128,21 @@ function getByteDeltaFragment(byteDelta, scope) {
1196
1128
  bytesFragment = fragment`${bytesFragment} + ${use("BASE_ACCOUNT_SIZE", "solanaAccounts")}`;
1197
1129
  }
1198
1130
  if (byteDelta.subtract) {
1199
- bytesFragment = (0, import_visitors_core10.pipe)(bytesFragment, (f) => (0, import_renderers_core4.mapFragmentContent)(f, (c) => `- (${c})`));
1131
+ bytesFragment = visitorsCore.pipe(bytesFragment, (f) => renderersCore.mapFragmentContent(f, (c) => `- (${c})`));
1200
1132
  }
1201
1133
  return [bytesFragment];
1202
1134
  }
1203
1135
  function getNumberValueNodeFragment(byteDelta) {
1204
- (0, import_nodes14.assertIsNode)(byteDelta.value, "numberValueNode");
1136
+ nodes.assertIsNode(byteDelta.value, "numberValueNode");
1205
1137
  return fragment`${byteDelta.value.number}`;
1206
1138
  }
1207
1139
  function getArgumentValueNodeFragment(byteDelta) {
1208
- (0, import_nodes14.assertIsNode)(byteDelta.value, "argumentValueNode");
1209
- const argumentName = (0, import_nodes14.camelCase)(byteDelta.value.name);
1140
+ nodes.assertIsNode(byteDelta.value, "argumentValueNode");
1141
+ const argumentName = nodes.camelCase(byteDelta.value.name);
1210
1142
  return fragment`Number(args.${argumentName})`;
1211
1143
  }
1212
1144
  function getAccountLinkNodeFragment(byteDelta, scope) {
1213
- (0, import_nodes14.assertIsNode)(byteDelta.value, "accountLinkNode");
1145
+ nodes.assertIsNode(byteDelta.value, "accountLinkNode");
1214
1146
  const functionName = use(
1215
1147
  scope.nameApi.accountGetSizeFunction(byteDelta.value.name),
1216
1148
  scope.getImportFrom(byteDelta.value)
@@ -1218,7 +1150,7 @@ function getAccountLinkNodeFragment(byteDelta, scope) {
1218
1150
  return fragment`${functionName}()`;
1219
1151
  }
1220
1152
  function getResolverValueNodeFragment(byteDelta, scope) {
1221
- (0, import_nodes14.assertIsNode)(byteDelta.value, "resolverValueNode");
1153
+ nodes.assertIsNode(byteDelta.value, "resolverValueNode");
1222
1154
  const isAsync = scope.asyncResolvers.includes(byteDelta.value.name);
1223
1155
  if (!scope.useAsync && isAsync) return null;
1224
1156
  const awaitKeyword = scope.useAsync && isAsync ? "await " : "";
@@ -1226,55 +1158,32 @@ function getResolverValueNodeFragment(byteDelta, scope) {
1226
1158
  scope.nameApi.resolverFunction(byteDelta.value.name),
1227
1159
  scope.getImportFrom(byteDelta.value)
1228
1160
  );
1229
- return (0, import_visitors_core10.pipe)(
1161
+ return visitorsCore.pipe(
1230
1162
  fragment`${awaitKeyword}${functionName}(resolverScope)`,
1231
1163
  (f) => addFragmentFeatures(f, ["instruction:resolverScopeVariable"])
1232
1164
  );
1233
1165
  }
1234
-
1235
- // src/fragments/instructionData.ts
1236
- var import_nodes15 = require("@codama/nodes");
1237
- var import_visitors_core11 = require("@codama/visitors-core");
1238
1166
  function getInstructionDataFragment(scope) {
1239
1167
  const { instructionPath, dataArgsManifest, nameApi, customInstructionData } = scope;
1240
- const instructionNode = (0, import_visitors_core11.getLastNodeFromPath)(instructionPath);
1168
+ const instructionNode = visitorsCore.getLastNodeFromPath(instructionPath);
1241
1169
  if (instructionNode.arguments.length === 0 || customInstructionData.has(instructionNode.name)) return;
1242
1170
  const instructionDataName = nameApi.instructionDataType(instructionNode.name);
1243
1171
  return getTypeWithCodecFragment({
1244
1172
  manifest: dataArgsManifest,
1245
1173
  name: instructionDataName,
1246
1174
  nameApi,
1247
- node: (0, import_nodes15.structTypeNodeFromInstructionArgumentNodes)(instructionNode.arguments),
1175
+ node: nodes.structTypeNodeFromInstructionArgumentNodes(instructionNode.arguments),
1248
1176
  size: scope.size
1249
1177
  });
1250
1178
  }
1251
-
1252
- // src/fragments/instructionExtraArgs.ts
1253
- var import_renderers_core5 = require("@codama/renderers-core");
1254
- var import_visitors_core12 = require("@codama/visitors-core");
1255
1179
  function getInstructionExtraArgsFragment(scope) {
1256
1180
  const { instructionPath, extraArgsManifest, nameApi } = scope;
1257
- const instructionNode = (0, import_visitors_core12.getLastNodeFromPath)(instructionPath);
1181
+ const instructionNode = visitorsCore.getLastNodeFromPath(instructionPath);
1258
1182
  if ((instructionNode.extraArguments ?? []).length === 0) return;
1259
1183
  const instructionExtraName = nameApi.instructionExtraType(instructionNode.name);
1260
1184
  const looseName = nameApi.dataArgsType(instructionExtraName);
1261
- return (0, import_renderers_core5.mapFragmentContent)(extraArgsManifest.looseType, (c) => `export type ${looseName} = ${c};`);
1185
+ return renderersCore.mapFragmentContent(extraArgsManifest.looseType, (c) => `export type ${looseName} = ${c};`);
1262
1186
  }
1263
-
1264
- // src/fragments/instructionFunction.ts
1265
- var import_nodes20 = require("@codama/nodes");
1266
- var import_renderers_core9 = require("@codama/renderers-core");
1267
- var import_visitors_core17 = require("@codama/visitors-core");
1268
-
1269
- // src/fragments/instructionInputResolved.ts
1270
- var import_nodes17 = require("@codama/nodes");
1271
- var import_renderers_core7 = require("@codama/renderers-core");
1272
- var import_visitors_core14 = require("@codama/visitors-core");
1273
-
1274
- // src/fragments/instructionInputDefault.ts
1275
- var import_nodes16 = require("@codama/nodes");
1276
- var import_renderers_core6 = require("@codama/renderers-core");
1277
- var import_visitors_core13 = require("@codama/visitors-core");
1278
1187
  function getInstructionInputDefaultFragment(scope) {
1279
1188
  const { input, optionalAccountStrategy, asyncResolvers, useAsync, nameApi, typeManifestVisitor, getImportFrom } = scope;
1280
1189
  if (!input.defaultValue) {
@@ -1285,8 +1194,8 @@ function getInstructionInputDefaultFragment(scope) {
1285
1194
  }
1286
1195
  const { defaultValue } = input;
1287
1196
  const defaultFragment = (renderedValue, isWritable) => {
1288
- const inputName = (0, import_nodes16.camelCase)(input.name);
1289
- if (input.kind === "instructionAccountNode" && (0, import_nodes16.isNode)(defaultValue, "resolverValueNode")) {
1197
+ const inputName = nodes.camelCase(input.name);
1198
+ if (input.kind === "instructionAccountNode" && nodes.isNode(defaultValue, "resolverValueNode")) {
1290
1199
  return fragment`accounts.${inputName} = { ...accounts.${inputName}, ...${renderedValue} };`;
1291
1200
  }
1292
1201
  if (input.kind === "instructionAccountNode" && isWritable === void 0) {
@@ -1304,7 +1213,7 @@ function getInstructionInputDefaultFragment(scope) {
1304
1213
  const addressType = use("type Address", "solanaAddresses");
1305
1214
  switch (defaultValue.kind) {
1306
1215
  case "accountValueNode":
1307
- const name = (0, import_nodes16.camelCase)(defaultValue.name);
1216
+ const name = nodes.camelCase(defaultValue.name);
1308
1217
  if (input.kind === "instructionAccountNode" && input.resolvedIsSigner && !input.isSigner) {
1309
1218
  return defaultFragment(fragment`${expectTransactionSigner}(accounts.${name}.value).address`);
1310
1219
  }
@@ -1314,13 +1223,13 @@ function getInstructionInputDefaultFragment(scope) {
1314
1223
  return defaultFragment(fragment`${expectAddress}(accounts.${name}.value)`);
1315
1224
  case "pdaValueNode":
1316
1225
  let pdaProgramValue;
1317
- if ((0, import_nodes16.isNode)(defaultValue.programId, "accountValueNode")) {
1318
- pdaProgramValue = fragment`${expectAddress}(accounts.${(0, import_nodes16.camelCase)(defaultValue.programId.name)}.value)`;
1226
+ if (nodes.isNode(defaultValue.programId, "accountValueNode")) {
1227
+ pdaProgramValue = fragment`${expectAddress}(accounts.${nodes.camelCase(defaultValue.programId.name)}.value)`;
1319
1228
  }
1320
- if ((0, import_nodes16.isNode)(defaultValue.programId, "argumentValueNode")) {
1321
- pdaProgramValue = fragment`${expectAddress}(args.${(0, import_nodes16.camelCase)(defaultValue.programId.name)})`;
1229
+ if (nodes.isNode(defaultValue.programId, "argumentValueNode")) {
1230
+ pdaProgramValue = fragment`${expectAddress}(args.${nodes.camelCase(defaultValue.programId.name)})`;
1322
1231
  }
1323
- if ((0, import_nodes16.isNode)(defaultValue.pda, "pdaNode")) {
1232
+ if (nodes.isNode(defaultValue.pda, "pdaNode")) {
1324
1233
  let pdaProgram = fragment`programAddress`;
1325
1234
  if (pdaProgramValue) {
1326
1235
  pdaProgram = pdaProgramValue;
@@ -1328,29 +1237,29 @@ function getInstructionInputDefaultFragment(scope) {
1328
1237
  pdaProgram = fragment`'${defaultValue.pda.programId}' as ${addressType}<'${defaultValue.pda.programId}'>`;
1329
1238
  }
1330
1239
  const pdaSeeds2 = defaultValue.pda.seeds.flatMap((seed) => {
1331
- if ((0, import_nodes16.isNode)(seed, "constantPdaSeedNode") && (0, import_nodes16.isNode)(seed.value, "programIdValueNode")) {
1240
+ if (nodes.isNode(seed, "constantPdaSeedNode") && nodes.isNode(seed.value, "programIdValueNode")) {
1332
1241
  return [fragment`${use("getAddressEncoder", "solanaAddresses")}().encode(${pdaProgram})`];
1333
1242
  }
1334
- if ((0, import_nodes16.isNode)(seed, "constantPdaSeedNode") && !(0, import_nodes16.isNode)(seed.value, "programIdValueNode")) {
1335
- const typeManifest2 = (0, import_visitors_core13.visit)(seed.type, typeManifestVisitor);
1336
- const valueManifest2 = (0, import_visitors_core13.visit)(seed.value, typeManifestVisitor);
1243
+ if (nodes.isNode(seed, "constantPdaSeedNode") && !nodes.isNode(seed.value, "programIdValueNode")) {
1244
+ const typeManifest2 = visitorsCore.visit(seed.type, typeManifestVisitor);
1245
+ const valueManifest2 = visitorsCore.visit(seed.value, typeManifestVisitor);
1337
1246
  return [fragment`${typeManifest2.encoder}.encode(${valueManifest2.value})`];
1338
1247
  }
1339
- if ((0, import_nodes16.isNode)(seed, "variablePdaSeedNode")) {
1340
- const typeManifest2 = (0, import_visitors_core13.visit)(seed.type, typeManifestVisitor);
1248
+ if (nodes.isNode(seed, "variablePdaSeedNode")) {
1249
+ const typeManifest2 = visitorsCore.visit(seed.type, typeManifestVisitor);
1341
1250
  const valueSeed = defaultValue.seeds.find((s) => s.name === seed.name)?.value;
1342
1251
  if (!valueSeed) return [];
1343
- if ((0, import_nodes16.isNode)(valueSeed, "accountValueNode")) {
1252
+ if (nodes.isNode(valueSeed, "accountValueNode")) {
1344
1253
  return [
1345
- fragment`${typeManifest2.encoder}.encode(${expectAddress}(accounts.${(0, import_nodes16.camelCase)(valueSeed.name)}.value))`
1254
+ fragment`${typeManifest2.encoder}.encode(${expectAddress}(accounts.${nodes.camelCase(valueSeed.name)}.value))`
1346
1255
  ];
1347
1256
  }
1348
- if ((0, import_nodes16.isNode)(valueSeed, "argumentValueNode")) {
1257
+ if (nodes.isNode(valueSeed, "argumentValueNode")) {
1349
1258
  return [
1350
- fragment`${typeManifest2.encoder}.encode(${expectSome}(args.${(0, import_nodes16.camelCase)(valueSeed.name)}))`
1259
+ fragment`${typeManifest2.encoder}.encode(${expectSome}(args.${nodes.camelCase(valueSeed.name)}))`
1351
1260
  ];
1352
1261
  }
1353
- const valueManifest2 = (0, import_visitors_core13.visit)(valueSeed, typeManifestVisitor);
1262
+ const valueManifest2 = visitorsCore.visit(valueSeed, typeManifestVisitor);
1354
1263
  return [fragment`${typeManifest2.encoder}.encode(${valueManifest2.value})`];
1355
1264
  }
1356
1265
  return [];
@@ -1365,20 +1274,20 @@ function getInstructionInputDefaultFragment(scope) {
1365
1274
  const pdaFunction = use(nameApi.pdaFindFunction(defaultValue.pda.name), getImportFrom(defaultValue.pda));
1366
1275
  const pdaArgs = [];
1367
1276
  const pdaSeeds = defaultValue.seeds.map((seed) => {
1368
- if ((0, import_nodes16.isNode)(seed.value, "accountValueNode")) {
1369
- return fragment`${seed.name}: ${expectAddress}(accounts.${(0, import_nodes16.camelCase)(seed.value.name)}.value)`;
1277
+ if (nodes.isNode(seed.value, "accountValueNode")) {
1278
+ return fragment`${seed.name}: ${expectAddress}(accounts.${nodes.camelCase(seed.value.name)}.value)`;
1370
1279
  }
1371
- if ((0, import_nodes16.isNode)(seed.value, "argumentValueNode")) {
1372
- return fragment`${seed.name}: ${expectSome}(args.${(0, import_nodes16.camelCase)(seed.value.name)})`;
1280
+ if (nodes.isNode(seed.value, "argumentValueNode")) {
1281
+ return fragment`${seed.name}: ${expectSome}(args.${nodes.camelCase(seed.value.name)})`;
1373
1282
  }
1374
- return (0, import_visitors_core13.pipe)(
1375
- (0, import_visitors_core13.visit)(seed.value, typeManifestVisitor).value,
1376
- (f) => (0, import_renderers_core6.mapFragmentContent)(f, (c) => `${seed.name}: ${c}`)
1283
+ return visitorsCore.pipe(
1284
+ visitorsCore.visit(seed.value, typeManifestVisitor).value,
1285
+ (f) => renderersCore.mapFragmentContent(f, (c) => `${seed.name}: ${c}`)
1377
1286
  );
1378
1287
  });
1379
- const pdaSeedsFragment = (0, import_visitors_core13.pipe)(
1288
+ const pdaSeedsFragment = visitorsCore.pipe(
1380
1289
  mergeFragments(pdaSeeds, (renders) => renders.join(", ")),
1381
- (f) => (0, import_renderers_core6.mapFragmentContent)(f, (c) => `{ ${c} }`)
1290
+ (f) => renderersCore.mapFragmentContent(f, (c) => `{ ${c} }`)
1382
1291
  );
1383
1292
  if (pdaSeeds.length > 0) {
1384
1293
  pdaArgs.push(pdaSeedsFragment);
@@ -1404,14 +1313,14 @@ function getInstructionInputDefaultFragment(scope) {
1404
1313
  return fragment``;
1405
1314
  case "accountBumpValueNode":
1406
1315
  return defaultFragment(
1407
- fragment`${expectProgramDerivedAddress}(accounts.${(0, import_nodes16.camelCase)(defaultValue.name)}.value)[1]`
1316
+ fragment`${expectProgramDerivedAddress}(accounts.${nodes.camelCase(defaultValue.name)}.value)[1]`
1408
1317
  );
1409
1318
  case "argumentValueNode":
1410
- return defaultFragment(fragment`${expectSome}(args.${(0, import_nodes16.camelCase)(defaultValue.name)})`);
1319
+ return defaultFragment(fragment`${expectSome}(args.${nodes.camelCase(defaultValue.name)})`);
1411
1320
  case "resolverValueNode":
1412
1321
  const resolverFunction = use(nameApi.resolverFunction(defaultValue.name), getImportFrom(defaultValue));
1413
1322
  const resolverAwait = useAsync && asyncResolvers.includes(defaultValue.name) ? "await " : "";
1414
- return (0, import_visitors_core13.pipe)(
1323
+ return visitorsCore.pipe(
1415
1324
  defaultFragment(fragment`${resolverAwait}${resolverFunction}(resolverScope)`),
1416
1325
  (f) => addFragmentFeatures(f, ["instruction:resolverScopeVariable"])
1417
1326
  );
@@ -1436,21 +1345,21 @@ function getInstructionInputDefaultFragment(scope) {
1436
1345
  }
1437
1346
  const negatedCondition = !ifTrueRenderer;
1438
1347
  let condition = "true";
1439
- if ((0, import_nodes16.isNode)(defaultValue.condition, "resolverValueNode")) {
1348
+ if (nodes.isNode(defaultValue.condition, "resolverValueNode")) {
1440
1349
  const conditionalResolverFunction = nameApi.resolverFunction(defaultValue.condition.name);
1441
- const module2 = getImportFrom(defaultValue.condition);
1442
- conditionalFragment = (0, import_visitors_core13.pipe)(
1350
+ const module = getImportFrom(defaultValue.condition);
1351
+ conditionalFragment = visitorsCore.pipe(
1443
1352
  conditionalFragment,
1444
- (f) => addFragmentImports(f, module2, [conditionalResolverFunction]),
1353
+ (f) => addFragmentImports(f, module, [conditionalResolverFunction]),
1445
1354
  (f) => addFragmentFeatures(f, ["instruction:resolverScopeVariable"])
1446
1355
  );
1447
1356
  const conditionalResolverAwait = useAsync && asyncResolvers.includes(defaultValue.condition.name) ? "await " : "";
1448
1357
  condition = `${conditionalResolverAwait}${conditionalResolverFunction}(resolverScope)`;
1449
1358
  condition = negatedCondition ? `!${condition}` : condition;
1450
1359
  } else {
1451
- const comparedInputName = (0, import_nodes16.isNode)(defaultValue.condition, "accountValueNode") ? `accounts.${(0, import_nodes16.camelCase)(defaultValue.condition.name)}.value` : `args.${(0, import_nodes16.camelCase)(defaultValue.condition.name)}`;
1360
+ const comparedInputName = nodes.isNode(defaultValue.condition, "accountValueNode") ? `accounts.${nodes.camelCase(defaultValue.condition.name)}.value` : `args.${nodes.camelCase(defaultValue.condition.name)}`;
1452
1361
  if (defaultValue.value) {
1453
- const comparedValue = (0, import_visitors_core13.visit)(defaultValue.value, typeManifestVisitor).value;
1362
+ const comparedValue = visitorsCore.visit(defaultValue.value, typeManifestVisitor).value;
1454
1363
  conditionalFragment = mergeFragments([conditionalFragment, comparedValue], (c) => c[0]);
1455
1364
  const operator = negatedCondition ? "!==" : "===";
1456
1365
  condition = `${comparedInputName} ${operator} ${comparedValue.content}`;
@@ -1459,7 +1368,7 @@ function getInstructionInputDefaultFragment(scope) {
1459
1368
  }
1460
1369
  }
1461
1370
  if (ifTrueRenderer && ifFalseRenderer) {
1462
- return (0, import_renderers_core6.setFragmentContent)(
1371
+ return renderersCore.setFragmentContent(
1463
1372
  conditionalFragment,
1464
1373
  `if (${condition}) {
1465
1374
  ${ifTrueRenderer.content}
@@ -1468,14 +1377,14 @@ ${ifFalseRenderer.content}
1468
1377
  }`
1469
1378
  );
1470
1379
  }
1471
- return (0, import_renderers_core6.setFragmentContent)(
1380
+ return renderersCore.setFragmentContent(
1472
1381
  conditionalFragment,
1473
1382
  `if (${condition}) {
1474
1383
  ${ifTrueRenderer ? ifTrueRenderer.content : ifFalseRenderer?.content}
1475
1384
  }`
1476
1385
  );
1477
1386
  default:
1478
- const valueManifest = (0, import_visitors_core13.visit)(defaultValue, typeManifestVisitor).value;
1387
+ const valueManifest = visitorsCore.visit(defaultValue, typeManifestVisitor).value;
1479
1388
  return defaultFragment(valueManifest);
1480
1389
  }
1481
1390
  }
@@ -1490,19 +1399,19 @@ function renderNestedInstructionDefault(scope) {
1490
1399
 
1491
1400
  // src/fragments/instructionInputResolved.ts
1492
1401
  function getInstructionInputResolvedFragment(scope) {
1493
- const instructionNode = (0, import_visitors_core14.getLastNodeFromPath)(scope.instructionPath);
1402
+ const instructionNode = visitorsCore.getLastNodeFromPath(scope.instructionPath);
1494
1403
  const resolvedInputFragments = scope.resolvedInputs.flatMap((input) => {
1495
1404
  const inputFragment = getInstructionInputDefaultFragment({
1496
1405
  ...scope,
1497
1406
  input,
1498
- optionalAccountStrategy: (0, import_nodes17.parseOptionalAccountStrategy)(instructionNode.optionalAccountStrategy)
1407
+ optionalAccountStrategy: nodes.parseOptionalAccountStrategy(instructionNode.optionalAccountStrategy)
1499
1408
  });
1500
1409
  if (!inputFragment.content) return [];
1501
- const camelName = (0, import_nodes17.camelCase)(input.name);
1410
+ const camelName = nodes.camelCase(input.name);
1502
1411
  return [
1503
- (0, import_renderers_core7.mapFragmentContent)(
1412
+ renderersCore.mapFragmentContent(
1504
1413
  inputFragment,
1505
- (c) => (0, import_nodes17.isNode)(input, "instructionArgumentNode") ? `if (!args.${camelName}) {
1414
+ (c) => nodes.isNode(input, "instructionArgumentNode") ? `if (!args.${camelName}) {
1506
1415
  ${c}
1507
1416
  }` : `if (!accounts.${camelName}.value) {
1508
1417
  ${c}
@@ -1515,19 +1424,14 @@ ${c}
1515
1424
  }
1516
1425
  return mergeFragments([fragment`// Resolve default values.`, ...resolvedInputFragments], (c) => c.join("\n"));
1517
1426
  }
1518
-
1519
- // src/fragments/instructionInputType.ts
1520
- var import_nodes18 = require("@codama/nodes");
1521
- var import_renderers_core8 = require("@codama/renderers-core");
1522
- var import_visitors_core15 = require("@codama/visitors-core");
1523
1427
  function getInstructionInputTypeFragment(scope) {
1524
1428
  const { instructionPath, useAsync, nameApi } = scope;
1525
- const instructionNode = (0, import_visitors_core15.getLastNodeFromPath)(instructionPath);
1429
+ const instructionNode = visitorsCore.getLastNodeFromPath(instructionPath);
1526
1430
  const instructionInputType = useAsync ? nameApi.instructionAsyncInputType(instructionNode.name) : nameApi.instructionSyncInputType(instructionNode.name);
1527
1431
  const [dataArgumentsFragment, customDataArgumentsFragment] = getDataArgumentsFragments(scope);
1528
1432
  let accountTypeParams = "";
1529
1433
  if (instructionNode.accounts.length > 0) {
1530
- accountTypeParams = instructionNode.accounts.map((account) => `TAccount${(0, import_nodes18.pascalCase)(account.name)} extends string = string`).join(", ");
1434
+ accountTypeParams = instructionNode.accounts.map((account) => `TAccount${nodes.pascalCase(account.name)} extends string = string`).join(", ");
1531
1435
  accountTypeParams = `<${accountTypeParams}>`;
1532
1436
  }
1533
1437
  const typeBodyFragment = mergeFragments(
@@ -1545,20 +1449,20 @@ function getInstructionInputTypeFragment(scope) {
1545
1449
  }
1546
1450
  function getAccountsFragment(scope) {
1547
1451
  const { instructionPath, resolvedInputs, useAsync, asyncResolvers } = scope;
1548
- const instructionNode = (0, import_visitors_core15.getLastNodeFromPath)(instructionPath);
1452
+ const instructionNode = visitorsCore.getLastNodeFromPath(instructionPath);
1549
1453
  const fragments = instructionNode.accounts.map((account) => {
1550
1454
  const resolvedAccount = resolvedInputs.find(
1551
1455
  (input) => input.kind === "instructionAccountNode" && input.name === account.name
1552
1456
  );
1553
- const hasDefaultValue = !!resolvedAccount.defaultValue && !(0, import_nodes18.isNode)(resolvedAccount.defaultValue, ["identityValueNode", "payerValueNode"]) && (useAsync || !isAsyncDefaultValue(resolvedAccount.defaultValue, asyncResolvers));
1457
+ const hasDefaultValue = !!resolvedAccount.defaultValue && !nodes.isNode(resolvedAccount.defaultValue, ["identityValueNode", "payerValueNode"]) && (useAsync || !isAsyncDefaultValue(resolvedAccount.defaultValue, asyncResolvers));
1554
1458
  const docs = getDocblockFragment(account.docs ?? [], true);
1555
1459
  const optionalSign = hasDefaultValue || resolvedAccount.isOptional ? "?" : "";
1556
- return fragment`${docs}${(0, import_nodes18.camelCase)(account.name)}${optionalSign}: ${getAccountTypeFragment2(resolvedAccount)};`;
1460
+ return fragment`${docs}${nodes.camelCase(account.name)}${optionalSign}: ${getAccountTypeFragment2(resolvedAccount)};`;
1557
1461
  });
1558
1462
  return mergeFragments(fragments, (c) => c.join("\n"));
1559
1463
  }
1560
1464
  function getAccountTypeFragment2(account) {
1561
- const typeParam = `TAccount${(0, import_nodes18.pascalCase)(account.name)}`;
1465
+ const typeParam = `TAccount${nodes.pascalCase(account.name)}`;
1562
1466
  const address = use("type Address", "solanaAddresses");
1563
1467
  const signer = use("type TransactionSigner", "solanaSigners");
1564
1468
  const pda = use("type ProgramDerivedAddress", "solanaAddresses");
@@ -1570,15 +1474,15 @@ function getAccountTypeFragment2(account) {
1570
1474
  }
1571
1475
  function getDataArgumentsFragments(scope) {
1572
1476
  const { instructionPath, nameApi } = scope;
1573
- const instructionNode = (0, import_visitors_core15.getLastNodeFromPath)(instructionPath);
1477
+ const instructionNode = visitorsCore.getLastNodeFromPath(instructionPath);
1574
1478
  const customData = scope.customInstructionData.get(instructionNode.name);
1575
1479
  if (customData) {
1576
1480
  return [
1577
1481
  void 0,
1578
- (0, import_visitors_core15.pipe)(
1482
+ visitorsCore.pipe(
1579
1483
  fragment`${nameApi.dataArgsType(customData.importAs)}`,
1580
1484
  (f) => mergeFragmentImports(f, [scope.dataArgsManifest.looseType.imports]),
1581
- (f) => (0, import_renderers_core8.mapFragmentContent)(f, (c) => `${c} & `)
1485
+ (f) => renderersCore.mapFragmentContent(f, (c) => `${c} & `)
1582
1486
  )
1583
1487
  ];
1584
1488
  }
@@ -1592,7 +1496,7 @@ function getDataArgumentsFragments(scope) {
1592
1496
  }
1593
1497
  function getExtraArgumentsFragment(scope) {
1594
1498
  const { instructionPath, nameApi } = scope;
1595
- const instructionNode = (0, import_visitors_core15.getLastNodeFromPath)(instructionPath);
1499
+ const instructionNode = visitorsCore.getLastNodeFromPath(instructionPath);
1596
1500
  const instructionExtraName = nameApi.instructionExtraType(instructionNode.name);
1597
1501
  const extraArgsType = nameApi.dataArgsType(instructionExtraName);
1598
1502
  const fragments = (instructionNode.extraArguments ?? []).flatMap((arg) => {
@@ -1604,18 +1508,18 @@ function getExtraArgumentsFragment(scope) {
1604
1508
  }
1605
1509
  function getArgumentFragment(arg, argsType, resolvedInputs, renamedArgs) {
1606
1510
  const resolvedArg = resolvedInputs.find(
1607
- (input) => (0, import_nodes18.isNode)(input, "instructionArgumentNode") && input.name === arg.name
1511
+ (input) => nodes.isNode(input, "instructionArgumentNode") && input.name === arg.name
1608
1512
  );
1609
1513
  if (arg.defaultValue && arg.defaultValueStrategy === "omitted") return null;
1610
1514
  const renamedName = renamedArgs.get(arg.name) ?? arg.name;
1611
1515
  const optionalSign = arg.defaultValue || resolvedArg?.defaultValue ? "?" : "";
1612
- return fragment`${(0, import_nodes18.camelCase)(renamedName)}${optionalSign}: ${argsType}["${(0, import_nodes18.camelCase)(arg.name)}"];`;
1516
+ return fragment`${nodes.camelCase(renamedName)}${optionalSign}: ${argsType}["${nodes.camelCase(arg.name)}"];`;
1613
1517
  }
1614
1518
  function getRemainingAccountsFragment(instructionNode) {
1615
1519
  const fragments = (instructionNode.remainingAccounts ?? []).flatMap((remainingAccountsNode) => {
1616
- if ((0, import_nodes18.isNode)(remainingAccountsNode.value, "resolverValueNode")) return [];
1520
+ if (nodes.isNode(remainingAccountsNode.value, "resolverValueNode")) return [];
1617
1521
  const { name } = remainingAccountsNode.value;
1618
- const allArguments = (0, import_nodes18.getAllInstructionArguments)(instructionNode);
1522
+ const allArguments = nodes.getAllInstructionArguments(instructionNode);
1619
1523
  const argumentExists = allArguments.some((arg) => arg.name === name);
1620
1524
  if (argumentExists) return [];
1621
1525
  const isSigner = remainingAccountsNode.isSigner ?? false;
@@ -1626,20 +1530,16 @@ function getRemainingAccountsFragment(instructionNode) {
1626
1530
  if (isSigner === "either") return fragment`${signerFragment} | ${addressFragment}`;
1627
1531
  return isSigner ? signerFragment : addressFragment;
1628
1532
  })();
1629
- return fragment`${(0, import_nodes18.camelCase)(name)}${optionalSign}: Array<${typeFragment}>;`;
1533
+ return fragment`${nodes.camelCase(name)}${optionalSign}: Array<${typeFragment}>;`;
1630
1534
  });
1631
1535
  if (fragments.length === 0) return;
1632
1536
  return mergeFragments(fragments, (c) => c.join("\n"));
1633
1537
  }
1634
-
1635
- // src/fragments/instructionRemainingAccounts.ts
1636
- var import_nodes19 = require("@codama/nodes");
1637
- var import_visitors_core16 = require("@codama/visitors-core");
1638
1538
  function getInstructionRemainingAccountsFragment(scope) {
1639
- const { remainingAccounts } = (0, import_visitors_core16.getLastNodeFromPath)(scope.instructionPath);
1539
+ const { remainingAccounts } = visitorsCore.getLastNodeFromPath(scope.instructionPath);
1640
1540
  const fragments = (remainingAccounts ?? []).flatMap((a) => getRemainingAccountsFragment2(a, scope));
1641
1541
  if (fragments.length === 0) return;
1642
- return (0, import_visitors_core16.pipe)(
1542
+ return visitorsCore.pipe(
1643
1543
  mergeFragments(
1644
1544
  fragments,
1645
1545
  (c) => `// Remaining accounts.
@@ -1650,10 +1550,10 @@ const remainingAccounts: AccountMeta[] = ${c.length === 1 ? c[0] : `[...${c.join
1650
1550
  }
1651
1551
  function getRemainingAccountsFragment2(remainingAccounts, scope) {
1652
1552
  const remainingAccountsFragment = (() => {
1653
- if ((0, import_nodes19.isNode)(remainingAccounts.value, "argumentValueNode")) {
1553
+ if (nodes.isNode(remainingAccounts.value, "argumentValueNode")) {
1654
1554
  return getArgumentValueNodeFragment2(remainingAccounts, scope);
1655
1555
  }
1656
- if ((0, import_nodes19.isNode)(remainingAccounts.value, "resolverValueNode")) {
1556
+ if (nodes.isNode(remainingAccounts.value, "resolverValueNode")) {
1657
1557
  return getResolverValueNodeFragment2(remainingAccounts, scope);
1658
1558
  }
1659
1559
  return null;
@@ -1662,9 +1562,9 @@ function getRemainingAccountsFragment2(remainingAccounts, scope) {
1662
1562
  return [remainingAccountsFragment];
1663
1563
  }
1664
1564
  function getArgumentValueNodeFragment2(remainingAccounts, scope) {
1665
- const instructionNode = (0, import_visitors_core16.getLastNodeFromPath)(scope.instructionPath);
1666
- (0, import_nodes19.assertIsNode)(remainingAccounts.value, "argumentValueNode");
1667
- const argumentName = (0, import_nodes19.camelCase)(remainingAccounts.value.name);
1565
+ const instructionNode = visitorsCore.getLastNodeFromPath(scope.instructionPath);
1566
+ nodes.assertIsNode(remainingAccounts.value, "argumentValueNode");
1567
+ const argumentName = nodes.camelCase(remainingAccounts.value.name);
1668
1568
  const isOptional = remainingAccounts.isOptional ?? false;
1669
1569
  const isSigner = remainingAccounts.isSigner ?? false;
1670
1570
  const isWritable = remainingAccounts.isWritable ?? false;
@@ -1673,7 +1573,7 @@ function getArgumentValueNodeFragment2(remainingAccounts, scope) {
1673
1573
  const signerRole = isWritable ? fragment`${accountRole}.WRITABLE_SIGNER` : fragment`${accountRole}.READONLY_SIGNER`;
1674
1574
  const role = isSigner === true ? signerRole : nonSignerRole;
1675
1575
  const argumentArray = isOptional ? `(args.${argumentName} ?? [])` : `args.${argumentName}`;
1676
- const allArguments = (0, import_nodes19.getAllInstructionArguments)(instructionNode);
1576
+ const allArguments = nodes.getAllInstructionArguments(instructionNode);
1677
1577
  const argumentExists = allArguments.some((arg) => arg.name === remainingAccounts.value.name);
1678
1578
  if (argumentExists || isSigner === false) {
1679
1579
  return fragment`${argumentArray}.map((address) => ({ address, role: ${role} }))`;
@@ -1684,7 +1584,7 @@ function getArgumentValueNodeFragment2(remainingAccounts, scope) {
1684
1584
  return fragment`${argumentArray}.map((signer) => ({ address: signer.address, role: ${signerRole}, signer }))`;
1685
1585
  }
1686
1586
  function getResolverValueNodeFragment2(remainingAccounts, scope) {
1687
- (0, import_nodes19.assertIsNode)(remainingAccounts.value, "resolverValueNode");
1587
+ nodes.assertIsNode(remainingAccounts.value, "resolverValueNode");
1688
1588
  const isAsync = scope.asyncResolvers.includes(remainingAccounts.value.name);
1689
1589
  if (!scope.useAsync && isAsync) return null;
1690
1590
  const awaitKeyword = scope.useAsync && isAsync ? "await " : "";
@@ -1692,7 +1592,7 @@ function getResolverValueNodeFragment2(remainingAccounts, scope) {
1692
1592
  scope.nameApi.resolverFunction(remainingAccounts.value.name),
1693
1593
  scope.getImportFrom(remainingAccounts.value)
1694
1594
  );
1695
- return (0, import_visitors_core16.pipe)(
1595
+ return visitorsCore.pipe(
1696
1596
  fragment`${awaitKeyword}${functionName}(resolverScope)`,
1697
1597
  (f) => addFragmentFeatures(f, ["instruction:resolverScopeVariable"])
1698
1598
  );
@@ -1701,13 +1601,13 @@ function getResolverValueNodeFragment2(remainingAccounts, scope) {
1701
1601
  // src/fragments/instructionFunction.ts
1702
1602
  function getInstructionFunctionFragment(scope) {
1703
1603
  const { useAsync, instructionPath, resolvedInputs, renamedArgs, asyncResolvers, nameApi, customInstructionData } = scope;
1704
- const instructionNode = (0, import_visitors_core17.getLastNodeFromPath)(instructionPath);
1705
- const programNode = (0, import_visitors_core17.findProgramNodeFromPath)(instructionPath);
1604
+ const instructionNode = visitorsCore.getLastNodeFromPath(instructionPath);
1605
+ const programNode = visitorsCore.findProgramNodeFromPath(instructionPath);
1706
1606
  if (useAsync && !hasAsyncFunction(instructionNode, resolvedInputs, asyncResolvers)) return;
1707
1607
  const customData = customInstructionData.get(instructionNode.name);
1708
1608
  const hasAccounts = instructionNode.accounts.length > 0;
1709
1609
  const instructionDependencies = getInstructionDependencies(instructionNode, asyncResolvers, useAsync);
1710
- const argDependencies = instructionDependencies.filter((0, import_nodes20.isNodeFilter)("argumentValueNode")).map((node) => node.name);
1610
+ const argDependencies = instructionDependencies.filter(nodes.isNodeFilter("argumentValueNode")).map((node) => node.name);
1711
1611
  const hasData = !!customData || instructionNode.arguments.length > 0;
1712
1612
  const argIsNotOmitted = (arg) => !(arg.defaultValue && arg.defaultValueStrategy === "omitted");
1713
1613
  const argIsDependent = (arg) => argDependencies.includes(arg.name);
@@ -1720,7 +1620,7 @@ function getInstructionFunctionFragment(scope) {
1720
1620
  const hasExtraArgs = (instructionNode.extraArguments ?? []).filter(
1721
1621
  (field) => argIsNotOmitted(field) && (argIsDependent(field) || argHasDefaultValue(field))
1722
1622
  ).length > 0;
1723
- const hasRemainingAccountArgs = (instructionNode.remainingAccounts ?? []).filter(({ value }) => (0, import_nodes20.isNode)(value, "argumentValueNode")).length > 0;
1623
+ const hasRemainingAccountArgs = (instructionNode.remainingAccounts ?? []).filter(({ value }) => nodes.isNode(value, "argumentValueNode")).length > 0;
1724
1624
  const hasAnyArgs = hasDataArgs || hasExtraArgs || hasRemainingAccountArgs;
1725
1625
  const hasInput = hasAccounts || hasAnyArgs;
1726
1626
  const programAddressConstant = use(nameApi.programAddressConstant(programNode.name), "generatedPrograms");
@@ -1739,7 +1639,7 @@ function getInstructionFunctionFragment(scope) {
1739
1639
  const typeParams = getTypeParamsFragment(instructionNode, programAddressConstant);
1740
1640
  const returnType = getReturnTypeFragment(instructionTypeFragment, hasByteDeltas, useAsync);
1741
1641
  const inputType = getInstructionInputTypeFragment(scope);
1742
- const inputArg = (0, import_renderers_core9.mapFragmentContent)(getInputTypeCallFragment(scope), (c) => hasInput ? `input: ${c}, ` : "");
1642
+ const inputArg = renderersCore.mapFragmentContent(getInputTypeCallFragment(scope), (c) => hasInput ? `input: ${c}, ` : "");
1743
1643
  const functionBody = mergeFragments(
1744
1644
  [
1745
1645
  getProgramAddressInitializationFragment(programAddressConstant),
@@ -1771,7 +1671,7 @@ function getAccountsInitializationFragment(instructionNode) {
1771
1671
  if (instructionNode.accounts.length === 0) return;
1772
1672
  const accounts = mergeFragments(
1773
1673
  instructionNode.accounts.map((account) => {
1774
- const name = (0, import_nodes20.camelCase)(account.name);
1674
+ const name = nodes.camelCase(account.name);
1775
1675
  const isWritable = account.isWritable ? "true" : "false";
1776
1676
  return fragment`${name}: { value: input.${name} ?? null, isWritable: ${isWritable} }`;
1777
1677
  }),
@@ -1806,7 +1706,7 @@ function getReturnStatementFragment(scope) {
1806
1706
  const hasLegacyOptionalAccounts = instructionNode.optionalAccountStrategy === "omitted" && instructionNode.accounts.some((account) => account.isOptional);
1807
1707
  const getAccountMeta = hasAccounts ? fragment`const getAccountMeta = ${use("getAccountMetaFactory", "shared")}(programAddress, '${optionalAccountStrategy}');` : "";
1808
1708
  const accountItems = [
1809
- ...instructionNode.accounts.map((account) => `getAccountMeta(accounts.${(0, import_nodes20.camelCase)(account.name)})`),
1709
+ ...instructionNode.accounts.map((account) => `getAccountMeta(accounts.${nodes.camelCase(account.name)})`),
1810
1710
  ...hasRemainingAccounts ? ["...remainingAccounts"] : []
1811
1711
  ].join(", ");
1812
1712
  let accounts;
@@ -1827,14 +1727,14 @@ function getReturnStatementFragment(scope) {
1827
1727
  } else if (hasData) {
1828
1728
  data = fragment`data: ${encoderFunctionFragment}.encode({})`;
1829
1729
  }
1830
- const instructionAttributes = (0, import_visitors_core17.pipe)(
1730
+ const instructionAttributes = visitorsCore.pipe(
1831
1731
  [accounts, hasByteDeltas ? fragment`byteDelta` : void 0, data, fragment`programAddress`],
1832
1732
  (fs) => mergeFragments(fs, (cs) => cs.join(", "))
1833
1733
  );
1834
1734
  return fragment`${getAccountMeta}\nreturn Object.freeze({ ${instructionAttributes} } as ${scope.syncReturnTypeFragment});`;
1835
1735
  }
1836
1736
  function getReturnTypeFragment(instructionTypeFragment, hasByteDeltas, useAsync) {
1837
- return (0, import_visitors_core17.pipe)(
1737
+ return visitorsCore.pipe(
1838
1738
  instructionTypeFragment,
1839
1739
  (f) => hasByteDeltas ? fragment`${f} & ${use("type InstructionWithByteDelta", "shared")}` : f,
1840
1740
  (f) => useAsync ? fragment`Promise<${f}>` : f
@@ -1843,7 +1743,7 @@ function getReturnTypeFragment(instructionTypeFragment, hasByteDeltas, useAsync)
1843
1743
  function getTypeParamsFragment(instructionNode, programAddressConstant) {
1844
1744
  return mergeFragments(
1845
1745
  [
1846
- ...instructionNode.accounts.map((account) => fragment`TAccount${(0, import_nodes20.pascalCase)(account.name)} extends string`),
1746
+ ...instructionNode.accounts.map((account) => fragment`TAccount${nodes.pascalCase(account.name)} extends string`),
1847
1747
  fragment`TProgramAddress extends ${use("type Address", "solanaAddresses")} = typeof ${programAddressConstant}`
1848
1748
  ],
1849
1749
  (cs) => `<${cs.join(", ")}>`
@@ -1851,48 +1751,39 @@ function getTypeParamsFragment(instructionNode, programAddressConstant) {
1851
1751
  }
1852
1752
  function getInstructionTypeFragment(scope) {
1853
1753
  const { instructionPath, nameApi } = scope;
1854
- const instructionNode = (0, import_visitors_core17.getLastNodeFromPath)(instructionPath);
1754
+ const instructionNode = visitorsCore.getLastNodeFromPath(instructionPath);
1855
1755
  const instructionTypeName = nameApi.instructionType(instructionNode.name);
1856
1756
  const accountTypeParamsFragments = instructionNode.accounts.map((account) => {
1857
- const typeParam = fragment`TAccount${(0, import_nodes20.pascalCase)(account.name)}`;
1858
- const camelName = (0, import_nodes20.camelCase)(account.name);
1757
+ const typeParam = fragment`TAccount${nodes.pascalCase(account.name)}`;
1758
+ const camelName = nodes.camelCase(account.name);
1859
1759
  if (account.isSigner === "either") {
1860
1760
  const signerRole = use(
1861
1761
  account.isWritable ? "type WritableSignerAccount" : "type ReadonlySignerAccount",
1862
1762
  "solanaInstructions"
1863
1763
  );
1864
- return (0, import_visitors_core17.pipe)(
1764
+ return visitorsCore.pipe(
1865
1765
  fragment`typeof input["${camelName}"] extends TransactionSigner<${typeParam}> ? ${signerRole}<${typeParam}> & AccountSignerMeta<${typeParam}> : ${typeParam}`,
1866
1766
  (f) => addFragmentImports(f, "solanaSigners", ["type AccountSignerMeta", "type TransactionSigner"])
1867
1767
  );
1868
1768
  }
1869
1769
  return typeParam;
1870
1770
  });
1871
- return (0, import_visitors_core17.pipe)(
1771
+ return visitorsCore.pipe(
1872
1772
  mergeFragments([fragment`TProgramAddress`, ...accountTypeParamsFragments], (c) => c.join(", ")),
1873
- (f) => (0, import_renderers_core9.mapFragmentContent)(f, (c) => `${instructionTypeName}<${c}>`)
1773
+ (f) => renderersCore.mapFragmentContent(f, (c) => `${instructionTypeName}<${c}>`)
1874
1774
  );
1875
1775
  }
1876
1776
  function getInputTypeCallFragment(scope) {
1877
1777
  const { instructionPath, useAsync, nameApi } = scope;
1878
- const instructionNode = (0, import_visitors_core17.getLastNodeFromPath)(instructionPath);
1778
+ const instructionNode = visitorsCore.getLastNodeFromPath(instructionPath);
1879
1779
  const inputTypeName = useAsync ? nameApi.instructionAsyncInputType(instructionNode.name) : nameApi.instructionSyncInputType(instructionNode.name);
1880
1780
  if (instructionNode.accounts.length === 0) return fragment`${inputTypeName}`;
1881
- const accountTypeParams = instructionNode.accounts.map((account) => `TAccount${(0, import_nodes20.pascalCase)(account.name)}`).join(", ");
1781
+ const accountTypeParams = instructionNode.accounts.map((account) => `TAccount${nodes.pascalCase(account.name)}`).join(", ");
1882
1782
  return fragment`${inputTypeName}<${accountTypeParams}>`;
1883
1783
  }
1884
-
1885
- // src/fragments/instructionPage.ts
1886
- var import_errors3 = require("@codama/errors");
1887
- var import_nodes23 = require("@codama/nodes");
1888
- var import_visitors_core20 = require("@codama/visitors-core");
1889
-
1890
- // src/fragments/instructionParseFunction.ts
1891
- var import_nodes21 = require("@codama/nodes");
1892
- var import_visitors_core18 = require("@codama/visitors-core");
1893
1784
  function getInstructionParseFunctionFragment(scope) {
1894
- const instructionNode = (0, import_visitors_core18.getLastNodeFromPath)(scope.instructionPath);
1895
- const programNode = (0, import_visitors_core18.findProgramNodeFromPath)(scope.instructionPath);
1785
+ const instructionNode = visitorsCore.getLastNodeFromPath(scope.instructionPath);
1786
+ const programNode = visitorsCore.findProgramNodeFromPath(scope.instructionPath);
1896
1787
  const programAddressConstant = use(scope.nameApi.programAddressConstant(programNode.name), "generatedPrograms");
1897
1788
  const childScope = { ...scope, instructionNode, programAddressConstant };
1898
1789
  return mergeFragments([getTypeFragment2(childScope), getFunctionFragment(childScope)], (cs) => cs.join("\n\n"));
@@ -1913,7 +1804,7 @@ function getTypeFragment2(scope) {
1913
1804
  const accounts = mergeFragments(
1914
1805
  scope.instructionNode.accounts.map((account, i) => {
1915
1806
  const docs = getDocblockFragment(account.docs ?? [], true);
1916
- const name = (0, import_nodes21.camelCase)(account.name);
1807
+ const name = nodes.camelCase(account.name);
1917
1808
  return fragment`${docs}${name}${account.isOptional ? "?" : ""}: TAccountMetas[${i}]${account.isOptional ? " | undefined" : ""};`;
1918
1809
  }),
1919
1810
  (cs) => hasAccounts ? `
@@ -1947,7 +1838,7 @@ function getFunctionFragment(scope) {
1947
1838
  [
1948
1839
  fragment`${use("type Instruction", "solanaInstructions")}<TProgram>`,
1949
1840
  hasAccounts ? fragment`${use("type InstructionWithAccounts", "solanaInstructions")}<TAccountMetas>` : void 0,
1950
- hasData ? (0, import_visitors_core18.pipe)(
1841
+ hasData ? visitorsCore.pipe(
1951
1842
  fragment`InstructionWithData<ReadonlyUint8Array>`,
1952
1843
  (f) => addFragmentImports(f, "solanaInstructions", ["type InstructionWithData"]),
1953
1844
  (f) => addFragmentImports(f, "solanaCodecsCore", ["type ReadonlyUint8Array"])
@@ -1985,7 +1876,7 @@ const getNextOptionalAccount = () => {
1985
1876
  }
1986
1877
  const accounts = mergeFragments(
1987
1878
  scope.instructionNode.accounts.map(
1988
- (account) => account.isOptional ? fragment`${(0, import_nodes21.camelCase)(account.name)}: getNextOptionalAccount()` : fragment`${(0, import_nodes21.camelCase)(account.name)}: getNextAccount()`
1879
+ (account) => account.isOptional ? fragment`${nodes.camelCase(account.name)}: getNextOptionalAccount()` : fragment`${nodes.camelCase(account.name)}: getNextAccount()`
1989
1880
  ),
1990
1881
  (cs) => hasAccounts ? `, accounts: { ${cs.join(", ")} }` : ""
1991
1882
  );
@@ -1995,15 +1886,10 @@ const getNextOptionalAccount = () => {
1995
1886
  return { programAddress: instruction.programAddress${accounts}${data} };
1996
1887
  }`;
1997
1888
  }
1998
-
1999
- // src/fragments/instructionType.ts
2000
- var import_nodes22 = require("@codama/nodes");
2001
- var import_renderers_core10 = require("@codama/renderers-core");
2002
- var import_visitors_core19 = require("@codama/visitors-core");
2003
1889
  function getInstructionTypeFragment2(scope) {
2004
1890
  const { instructionPath, nameApi, customInstructionData } = scope;
2005
- const instructionNode = (0, import_visitors_core19.getLastNodeFromPath)(instructionPath);
2006
- const programNode = (0, import_visitors_core19.findProgramNodeFromPath)(instructionPath);
1891
+ const instructionNode = visitorsCore.getLastNodeFromPath(instructionPath);
1892
+ const programNode = visitorsCore.findProgramNodeFromPath(instructionPath);
2007
1893
  const hasAccounts = instructionNode.accounts.length > 0;
2008
1894
  const customData = customInstructionData.get(instructionNode.name);
2009
1895
  const hasData = !!customData || instructionNode.arguments.length > 0;
@@ -2013,7 +1899,6 @@ function getInstructionTypeFragment2(scope) {
2013
1899
  instructionNode.accounts.map(
2014
1900
  (account) => getInstructionAccountTypeParamFragment({
2015
1901
  ...scope,
2016
- allowAccountMeta: true,
2017
1902
  instructionAccountPath: [...instructionPath, account]
2018
1903
  })
2019
1904
  ),
@@ -2023,8 +1908,8 @@ function getInstructionTypeFragment2(scope) {
2023
1908
  const usesLegacyOptionalAccounts = instructionNode.optionalAccountStrategy === "omitted";
2024
1909
  const accountMetasFragment = mergeFragments(
2025
1910
  instructionNode.accounts.map(
2026
- (account) => (0, import_renderers_core10.mapFragmentContent)(getInstructionAccountMetaFragment(account), (c) => {
2027
- const typeParam = `TAccount${(0, import_nodes22.pascalCase)(account.name)}`;
1911
+ (account) => renderersCore.mapFragmentContent(getInstructionAccountMetaFragment(account), (c) => {
1912
+ const typeParam = `TAccount${nodes.pascalCase(account.name)}`;
2028
1913
  const isLegacyOptional = account.isOptional && usesLegacyOptionalAccounts;
2029
1914
  const type = `${typeParam} extends string ? ${c} : ${typeParam}`;
2030
1915
  if (!isLegacyOptional) return type;
@@ -2041,17 +1926,17 @@ ${use("type Instruction", "solanaInstructions")}<TProgram>${data}${accounts};`;
2041
1926
 
2042
1927
  // src/fragments/instructionPage.ts
2043
1928
  function getInstructionPageFragment(scope) {
2044
- const node = (0, import_visitors_core20.getLastNodeFromPath)(scope.instructionPath);
2045
- if (!(0, import_visitors_core20.findProgramNodeFromPath)(scope.instructionPath)) {
1929
+ const node = visitorsCore.getLastNodeFromPath(scope.instructionPath);
1930
+ if (!visitorsCore.findProgramNodeFromPath(scope.instructionPath)) {
2046
1931
  throw new Error("Instruction must be visited inside a program.");
2047
1932
  }
2048
1933
  const childScope = {
2049
1934
  ...scope,
2050
- dataArgsManifest: (0, import_visitors_core20.visit)(node, scope.typeManifestVisitor),
2051
- extraArgsManifest: (0, import_visitors_core20.visit)(
2052
- (0, import_nodes23.definedTypeNode)({
1935
+ dataArgsManifest: visitorsCore.visit(node, scope.typeManifestVisitor),
1936
+ extraArgsManifest: visitorsCore.visit(
1937
+ nodes.definedTypeNode({
2053
1938
  name: scope.nameApi.instructionExtraType(node.name),
2054
- type: (0, import_nodes23.structTypeNodeFromInstructionArgumentNodes)(node.extraArguments ?? [])
1939
+ type: nodes.structTypeNodeFromInstructionArgumentNodes(node.extraArguments ?? [])
2055
1940
  }),
2056
1941
  scope.typeManifestVisitor
2057
1942
  ),
@@ -2087,17 +1972,13 @@ function getRenamedArgsMap(instruction) {
2087
1972
  const allNames = [...instruction.accounts.map((account) => account.name), ...argNames];
2088
1973
  const duplicates = allNames.filter((e, i, a) => a.indexOf(e) !== i);
2089
1974
  if (duplicates.length === 0) return /* @__PURE__ */ new Map();
2090
- (0, import_errors3.logWarn)(
1975
+ errors.logWarn(
2091
1976
  `[JavaScript] Accounts and args of instruction [${instruction.name}] have the following conflicting attributes [${duplicates.join(", ")}]. Thus, the arguments have been renamed to avoid conflicts in the input type.`
2092
1977
  );
2093
- return new Map(duplicates.map((name) => [(0, import_nodes23.camelCase)(name), (0, import_nodes23.camelCase)(`${name}Arg`)]));
1978
+ return new Map(duplicates.map((name) => [nodes.camelCase(name), nodes.camelCase(`${name}Arg`)]));
2094
1979
  }
2095
-
2096
- // src/fragments/pdaFunction.ts
2097
- var import_nodes24 = require("@codama/nodes");
2098
- var import_visitors_core21 = require("@codama/visitors-core");
2099
1980
  function getPdaFunctionFragment(scope) {
2100
- const pdaNode = (0, import_visitors_core21.getLastNodeFromPath)(scope.pdaPath);
1981
+ const pdaNode = visitorsCore.getLastNodeFromPath(scope.pdaPath);
2101
1982
  const seeds = parsePdaSeedNodes(pdaNode.seeds, scope);
2102
1983
  return mergeFragments(
2103
1984
  [getSeedInputTypeFragment(seeds, scope), getFunctionFragment2(seeds, scope)],
@@ -2105,9 +1986,9 @@ function getPdaFunctionFragment(scope) {
2105
1986
  );
2106
1987
  }
2107
1988
  function getSeedInputTypeFragment(seeds, scope) {
2108
- const variableSeeds = seeds.filter((0, import_nodes24.isNodeFilter)("variablePdaSeedNode"));
1989
+ const variableSeeds = seeds.filter(nodes.isNodeFilter("variablePdaSeedNode"));
2109
1990
  if (variableSeeds.length === 0) return;
2110
- const pdaNode = (0, import_visitors_core21.getLastNodeFromPath)(scope.pdaPath);
1991
+ const pdaNode = visitorsCore.getLastNodeFromPath(scope.pdaPath);
2111
1992
  const seedTypeName = scope.nameApi.pdaSeedsType(pdaNode.name);
2112
1993
  const seedAttributes = mergeFragments(
2113
1994
  variableSeeds.map((seed) => seed.inputAttribute),
@@ -2116,15 +1997,15 @@ function getSeedInputTypeFragment(seeds, scope) {
2116
1997
  return fragment`export type ${seedTypeName} = {\n${seedAttributes}\n};`;
2117
1998
  }
2118
1999
  function getFunctionFragment2(seeds, scope) {
2119
- const pdaNode = (0, import_visitors_core21.getLastNodeFromPath)(scope.pdaPath);
2120
- const programNode = (0, import_visitors_core21.findProgramNodeFromPath)(scope.pdaPath);
2000
+ const pdaNode = visitorsCore.getLastNodeFromPath(scope.pdaPath);
2001
+ const programNode = visitorsCore.findProgramNodeFromPath(scope.pdaPath);
2121
2002
  const addressType = use("type Address", "solanaAddresses");
2122
2003
  const pdaType = use("type ProgramDerivedAddress", "solanaAddresses");
2123
2004
  const getPdaFunction = use("getProgramDerivedAddress", "solanaAddresses");
2124
2005
  const seedTypeName = scope.nameApi.pdaSeedsType(pdaNode.name);
2125
2006
  const findPdaFunction = scope.nameApi.pdaFindFunction(pdaNode.name);
2126
2007
  const docs = getDocblockFragment(pdaNode.docs ?? [], true);
2127
- const hasVariableSeeds = seeds.filter((0, import_nodes24.isNodeFilter)("variablePdaSeedNode")).length > 0;
2008
+ const hasVariableSeeds = seeds.filter(nodes.isNodeFilter("variablePdaSeedNode")).length > 0;
2128
2009
  const seedArgument = hasVariableSeeds ? `seeds: ${seedTypeName}, ` : "";
2129
2010
  const programAddress = pdaNode.programId ?? programNode.publicKey;
2130
2011
  const encodedSeeds = mergeFragments(
@@ -2138,39 +2019,31 @@ function getFunctionFragment2(seeds, scope) {
2138
2019
  }
2139
2020
  function parsePdaSeedNodes(seeds, scope) {
2140
2021
  return seeds.map((seed) => {
2141
- if ((0, import_nodes24.isNode)(seed, "variablePdaSeedNode")) {
2142
- const name = (0, import_nodes24.camelCase)(seed.name);
2022
+ if (nodes.isNode(seed, "variablePdaSeedNode")) {
2023
+ const name = nodes.camelCase(seed.name);
2143
2024
  const docs = getDocblockFragment(seed.docs ?? [], true);
2144
- const { encoder: encoder2, looseType } = (0, import_visitors_core21.visit)(seed.type, scope.typeManifestVisitor);
2025
+ const { encoder: encoder2, looseType } = visitorsCore.visit(seed.type, scope.typeManifestVisitor);
2145
2026
  return {
2146
2027
  ...seed,
2147
2028
  encodedValue: fragment`${encoder2}.encode(seeds.${name})`,
2148
2029
  inputAttribute: fragment`${docs}${name}: ${looseType};`
2149
2030
  };
2150
2031
  }
2151
- if ((0, import_nodes24.isNode)(seed.value, "programIdValueNode")) {
2032
+ if (nodes.isNode(seed.value, "programIdValueNode")) {
2152
2033
  const addressEncoder = use("getAddressEncoder", "solanaAddresses");
2153
2034
  return { ...seed, encodedValue: fragment`${addressEncoder}().encode(programAddress)` };
2154
2035
  }
2155
- const { encoder } = (0, import_visitors_core21.visit)(seed.type, scope.typeManifestVisitor);
2156
- const { value } = (0, import_visitors_core21.visit)(seed.value, scope.typeManifestVisitor);
2036
+ const { encoder } = visitorsCore.visit(seed.type, scope.typeManifestVisitor);
2037
+ const { value } = visitorsCore.visit(seed.value, scope.typeManifestVisitor);
2157
2038
  return { ...seed, encodedValue: fragment`${encoder}.encode(${value})` };
2158
2039
  });
2159
2040
  }
2160
-
2161
- // src/fragments/pdaPage.ts
2162
- var import_visitors_core22 = require("@codama/visitors-core");
2163
2041
  function getPdaPageFragment(scope) {
2164
- if (!(0, import_visitors_core22.findProgramNodeFromPath)(scope.pdaPath)) {
2042
+ if (!visitorsCore.findProgramNodeFromPath(scope.pdaPath)) {
2165
2043
  throw new Error("PDA must be visited inside a program.");
2166
2044
  }
2167
2045
  return getPdaFunctionFragment(scope);
2168
2046
  }
2169
-
2170
- // src/fragments/programAccounts.ts
2171
- var import_nodes25 = require("@codama/nodes");
2172
- var import_renderers_core11 = require("@codama/renderers-core");
2173
- var import_visitors_core23 = require("@codama/visitors-core");
2174
2047
  function getProgramAccountsFragment(scope) {
2175
2048
  if (scope.programNode.accounts.length === 0) return;
2176
2049
  return mergeFragments(
@@ -2195,7 +2068,7 @@ function getProgramAccountsIdentifierFunctionFragment(scope) {
2195
2068
  if (!hasAccountDiscriminators) return;
2196
2069
  const programAccountsEnum = nameApi.programAccountsEnum(programNode.name);
2197
2070
  const programAccountsIdentifierFunction = nameApi.programAccountsIdentifierFunction(programNode.name);
2198
- return (0, import_visitors_core23.pipe)(
2071
+ return visitorsCore.pipe(
2199
2072
  mergeFragments(
2200
2073
  accountsWithDiscriminators.map((account) => {
2201
2074
  const variant = nameApi.programAccountsEnumVariant(account.name);
@@ -2204,12 +2077,12 @@ function getProgramAccountsIdentifierFunctionFragment(scope) {
2204
2077
  dataName: "data",
2205
2078
  discriminators: account.discriminators ?? [],
2206
2079
  ifTrue: `return ${programAccountsEnum}.${variant};`,
2207
- struct: (0, import_nodes25.resolveNestedTypeNode)(account.data)
2080
+ struct: nodes.resolveNestedTypeNode(account.data)
2208
2081
  });
2209
2082
  }),
2210
2083
  (c) => c.join("\n")
2211
2084
  ),
2212
- (f) => (0, import_renderers_core11.mapFragmentContent)(
2085
+ (f) => renderersCore.mapFragmentContent(
2213
2086
  f,
2214
2087
  (discriminators) => `export function ${programAccountsIdentifierFunction}(account: { data: ReadonlyUint8Array } | ReadonlyUint8Array): ${programAccountsEnum} {
2215
2088
  const data = 'data' in account ? account.data : account;
@@ -2220,25 +2093,17 @@ throw new Error("The provided account could not be identified as a ${programNode
2220
2093
  (f) => addFragmentImports(f, "solanaCodecsCore", ["type ReadonlyUint8Array"])
2221
2094
  );
2222
2095
  }
2223
-
2224
- // src/fragments/programConstant.ts
2225
- var import_visitors_core24 = require("@codama/visitors-core");
2226
2096
  function getProgramConstantFragment(scope) {
2227
2097
  const { programNode, nameApi } = scope;
2228
2098
  const programAddressConstant = nameApi.programAddressConstant(programNode.name);
2229
- return (0, import_visitors_core24.pipe)(
2099
+ return visitorsCore.pipe(
2230
2100
  fragment`export const ${programAddressConstant} = '${programNode.publicKey}' as Address<'${programNode.publicKey}'>;`,
2231
2101
  (f) => addFragmentImports(f, "solanaAddresses", ["type Address"])
2232
2102
  );
2233
2103
  }
2234
-
2235
- // src/fragments/programInstructions.ts
2236
- var import_nodes26 = require("@codama/nodes");
2237
- var import_renderers_core12 = require("@codama/renderers-core");
2238
- var import_visitors_core25 = require("@codama/visitors-core");
2239
2104
  function getProgramInstructionsFragment(scope) {
2240
2105
  if (scope.programNode.instructions.length === 0) return;
2241
- const allInstructions = (0, import_nodes26.getAllInstructionsWithSubs)(scope.programNode, {
2106
+ const allInstructions = nodes.getAllInstructionsWithSubs(scope.programNode, {
2242
2107
  leavesOnly: !scope.renderParentInstructions,
2243
2108
  subInstructionsFirst: true
2244
2109
  });
@@ -2277,14 +2142,14 @@ function getProgramInstructionsIdentifierFunctionFragment(scope) {
2277
2142
  dataName: "data",
2278
2143
  discriminators: instruction.discriminators ?? [],
2279
2144
  ifTrue: `return ${programInstructionsEnum}.${variant};`,
2280
- struct: (0, import_nodes26.structTypeNodeFromInstructionArgumentNodes)(instruction.arguments)
2145
+ struct: nodes.structTypeNodeFromInstructionArgumentNodes(instruction.arguments)
2281
2146
  });
2282
2147
  }),
2283
2148
  (c) => c.join("\n")
2284
2149
  );
2285
- return (0, import_visitors_core25.pipe)(
2150
+ return visitorsCore.pipe(
2286
2151
  discriminatorsFragment,
2287
- (f) => (0, import_renderers_core12.mapFragmentContent)(
2152
+ (f) => renderersCore.mapFragmentContent(
2288
2153
  f,
2289
2154
  (discriminators) => `export function ${programInstructionsIdentifierFunction}(instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array): ${programInstructionsEnum} {
2290
2155
  const data = 'data' in instruction ? instruction.data : instruction;
@@ -2344,9 +2209,6 @@ function getRootIndexPageFragment(scope) {
2344
2209
  (cs) => cs.join("\n")
2345
2210
  );
2346
2211
  }
2347
-
2348
- // src/fragments/sharedPage.ts
2349
- var import_visitors_core26 = require("@codama/visitors-core");
2350
2212
  function getSharedPageFragment() {
2351
2213
  const sharedPage = fragment`/**
2352
2214
  * Asserts that the given value is not null or undefined.
@@ -2447,7 +2309,7 @@ export function getAccountMetaFactory(
2447
2309
  export function isTransactionSigner<TAddress extends string = string>(value: Address<TAddress> | ProgramDerivedAddress<TAddress> | TransactionSigner<TAddress>): value is TransactionSigner<TAddress> {
2448
2310
  return !!value && typeof value === 'object' && 'address' in value && kitIsTransactionSigner(value);
2449
2311
  }`;
2450
- return (0, import_visitors_core26.pipe)(
2312
+ return visitorsCore.pipe(
2451
2313
  sharedPage,
2452
2314
  (f) => addFragmentImports(f, "solanaAddresses", [
2453
2315
  "type Address",
@@ -2462,12 +2324,9 @@ export function isTransactionSigner<TAddress extends string = string>(value: Add
2462
2324
  ])
2463
2325
  );
2464
2326
  }
2465
-
2466
- // src/fragments/typeDiscriminatedUnionHelpers.ts
2467
- var import_nodes27 = require("@codama/nodes");
2468
2327
  function getTypeDiscriminatedUnionHelpersFragment(scope) {
2469
2328
  const { name, typeNode, nameApi } = scope;
2470
- const isDiscriminatedUnion = (0, import_nodes27.isNode)(typeNode, "enumTypeNode") && (0, import_nodes27.isDataEnum)(typeNode);
2329
+ const isDiscriminatedUnion = nodes.isNode(typeNode, "enumTypeNode") && nodes.isDataEnum(typeNode);
2471
2330
  if (!isDiscriminatedUnion) return;
2472
2331
  const functionName = nameApi.discriminatedUnionFunction(name);
2473
2332
  const isDiscriminatedUnionFunctionName = nameApi.isDiscriminatedUnionFunction(name);
@@ -2479,10 +2338,10 @@ function getTypeDiscriminatedUnionHelpersFragment(scope) {
2479
2338
  const variantSignatures = mergeFragments(
2480
2339
  typeNode.variants.map((variant) => {
2481
2340
  const variantName = nameApi.discriminatedUnionVariant(variant.name);
2482
- if ((0, import_nodes27.isNode)(variant, "enumStructVariantTypeNode")) {
2341
+ if (nodes.isNode(variant, "enumStructVariantTypeNode")) {
2483
2342
  return fragment`export function ${functionName}(kind: '${variantName}', data: ${getVariantContentType}<${looseName}, '${discriminatorName}', '${variantName}'>): ${getVariantType}<${looseName}, '${discriminatorName}', '${variantName}'>;`;
2484
2343
  }
2485
- if ((0, import_nodes27.isNode)(variant, "enumTupleVariantTypeNode")) {
2344
+ if (nodes.isNode(variant, "enumTupleVariantTypeNode")) {
2486
2345
  return fragment`export function ${functionName}(kind: '${variantName}', data: ${getVariantContentType}<${looseName}, '${discriminatorName}', '${variantName}'>['fields']): ${getVariantType}<${looseName}, '${discriminatorName}', '${variantName}'>;`;
2487
2346
  }
2488
2347
  return fragment`export function ${functionName}(kind: '${variantName}'): ${getVariantType}<${looseName}, '${discriminatorName}', '${variantName}'>;`;
@@ -2500,13 +2359,10 @@ export function ${isDiscriminatedUnionFunctionName}<K extends ${strictName}['${d
2500
2359
  };
2501
2360
  `;
2502
2361
  }
2503
-
2504
- // src/fragments/typePage.ts
2505
- var import_visitors_core27 = require("@codama/visitors-core");
2506
2362
  function getTypePageFragment(scope) {
2507
2363
  const node = scope.node;
2508
- const manifest = (0, import_visitors_core27.visit)(node, scope.typeManifestVisitor);
2509
- return (0, import_visitors_core27.pipe)(
2364
+ const manifest = visitorsCore.visit(node, scope.typeManifestVisitor);
2365
+ return visitorsCore.pipe(
2510
2366
  mergeFragments(
2511
2367
  [
2512
2368
  getTypeWithCodecFragment({ ...scope, manifest, name: node.name, node: node.type, typeDocs: node.docs }),
@@ -2523,42 +2379,37 @@ function getTypePageFragment(scope) {
2523
2379
  ])
2524
2380
  );
2525
2381
  }
2526
-
2527
- // src/visitors/getTypeManifestVisitor.ts
2528
- var import_nodes28 = require("@codama/nodes");
2529
- var import_renderers_core13 = require("@codama/renderers-core");
2530
- var import_visitors_core28 = require("@codama/visitors-core");
2531
2382
  function getTypeManifestVisitor(input) {
2532
2383
  const { nameApi, linkables, nonScalarEnums, customAccountData, customInstructionData, getImportFrom } = input;
2533
- const stack = input.stack ?? new import_visitors_core28.NodeStack();
2384
+ const stack = input.stack ?? new visitorsCore.NodeStack();
2534
2385
  let parentName = null;
2535
- return (0, import_visitors_core28.pipe)(
2536
- (0, import_visitors_core28.staticVisitor)(() => typeManifest(), {
2386
+ return visitorsCore.pipe(
2387
+ visitorsCore.staticVisitor(() => typeManifest(), {
2537
2388
  keys: [
2538
- ...import_nodes28.REGISTERED_TYPE_NODE_KINDS,
2539
- ...import_nodes28.REGISTERED_VALUE_NODE_KINDS,
2389
+ ...nodes.REGISTERED_TYPE_NODE_KINDS,
2390
+ ...nodes.REGISTERED_VALUE_NODE_KINDS,
2540
2391
  "definedTypeLinkNode",
2541
2392
  "definedTypeNode",
2542
2393
  "accountNode",
2543
2394
  "instructionNode"
2544
2395
  ]
2545
2396
  }),
2546
- (visitor) => (0, import_visitors_core28.extendVisitor)(visitor, {
2397
+ (visitor) => visitorsCore.extendVisitor(visitor, {
2547
2398
  visitAccount(account, { self }) {
2548
2399
  parentName = {
2549
2400
  loose: nameApi.dataArgsType(account.name),
2550
2401
  strict: nameApi.dataType(account.name)
2551
2402
  };
2552
2403
  const link = customAccountData.get(account.name)?.linkNode;
2553
- const manifest = link ? (0, import_visitors_core28.visit)(link, self) : (0, import_visitors_core28.visit)(account.data, self);
2404
+ const manifest = link ? visitorsCore.visit(link, self) : visitorsCore.visit(account.data, self);
2554
2405
  parentName = null;
2555
2406
  return manifest;
2556
2407
  },
2557
2408
  visitAmountType(amountType, { self }) {
2558
- return (0, import_visitors_core28.visit)(amountType.number, self);
2409
+ return visitorsCore.visit(amountType.number, self);
2559
2410
  },
2560
2411
  visitArrayType(arrayType, { self }) {
2561
- const childManifest = (0, import_visitors_core28.visit)(arrayType.item, self);
2412
+ const childManifest = visitorsCore.visit(arrayType.item, self);
2562
2413
  const sizeManifest = getArrayLikeSizeOption(arrayType.count, self);
2563
2414
  const encoderOptions = sizeManifest.encoder ? fragment`, { ${sizeManifest.encoder} }` : "";
2564
2415
  const decoderOptions = sizeManifest.decoder ? fragment`, { ${sizeManifest.decoder} }` : "";
@@ -2572,16 +2423,16 @@ function getTypeManifestVisitor(input) {
2572
2423
  },
2573
2424
  visitArrayValue(node, { self }) {
2574
2425
  return mergeTypeManifests(
2575
- node.items.map((v) => (0, import_visitors_core28.visit)(v, self)),
2426
+ node.items.map((v) => visitorsCore.visit(v, self)),
2576
2427
  { mergeValues: (renders) => `[${renders.join(", ")}]` }
2577
2428
  );
2578
2429
  },
2579
2430
  visitBooleanType(booleanType, { self }) {
2580
2431
  let sizeEncoder = fragment``;
2581
2432
  let sizeDecoder = fragment``;
2582
- const resolvedSize = (0, import_nodes28.resolveNestedTypeNode)(booleanType.size);
2433
+ const resolvedSize = nodes.resolveNestedTypeNode(booleanType.size);
2583
2434
  if (resolvedSize.format !== "u8" || resolvedSize.endian !== "le") {
2584
- const size = (0, import_visitors_core28.visit)(booleanType.size, self);
2435
+ const size = visitorsCore.visit(booleanType.size, self);
2585
2436
  sizeEncoder = fragment`{ size: ${size.encoder} }`;
2586
2437
  sizeDecoder = fragment`{ size: ${size.decoder} }`;
2587
2438
  }
@@ -2609,22 +2460,22 @@ function getTypeManifestVisitor(input) {
2609
2460
  return typeManifest({ value: fragment`new Uint8Array([${Array.from(bytes).join(", ")}])` });
2610
2461
  },
2611
2462
  visitConstantValue(node, { self }) {
2612
- if ((0, import_nodes28.isNode)(node.type, "bytesTypeNode") && (0, import_nodes28.isNode)(node.value, "bytesValueNode")) {
2613
- return (0, import_visitors_core28.visit)(node.value, self);
2463
+ if (nodes.isNode(node.type, "bytesTypeNode") && nodes.isNode(node.value, "bytesValueNode")) {
2464
+ return visitorsCore.visit(node.value, self);
2614
2465
  }
2615
2466
  return typeManifest({
2616
- value: fragment`${(0, import_visitors_core28.visit)(node.type, self).encoder}.encode(${(0, import_visitors_core28.visit)(node.value, self).value})`
2467
+ value: fragment`${visitorsCore.visit(node.type, self).encoder}.encode(${visitorsCore.visit(node.value, self).value})`
2617
2468
  });
2618
2469
  },
2619
2470
  visitDateTimeType(dateTimeType, { self }) {
2620
- return (0, import_visitors_core28.visit)(dateTimeType.number, self);
2471
+ return visitorsCore.visit(dateTimeType.number, self);
2621
2472
  },
2622
2473
  visitDefinedType(definedType, { self }) {
2623
2474
  parentName = {
2624
2475
  loose: nameApi.dataArgsType(definedType.name),
2625
2476
  strict: nameApi.dataType(definedType.name)
2626
2477
  };
2627
- const manifest = (0, import_visitors_core28.visit)(definedType.type, self);
2478
+ const manifest = visitorsCore.visit(definedType.type, self);
2628
2479
  parentName = null;
2629
2480
  return manifest;
2630
2481
  },
@@ -2642,7 +2493,7 @@ function getTypeManifestVisitor(input) {
2642
2493
  });
2643
2494
  },
2644
2495
  visitEnumEmptyVariantType(enumEmptyVariantType) {
2645
- const discriminator = nameApi.discriminatedUnionDiscriminator((0, import_nodes28.camelCase)(parentName?.strict ?? ""));
2496
+ const discriminator = nameApi.discriminatedUnionDiscriminator(nodes.camelCase(parentName?.strict ?? ""));
2646
2497
  const name = nameApi.discriminatedUnionVariant(enumEmptyVariantType.name);
2647
2498
  const kindAttribute = `${discriminator}: "${name}"`;
2648
2499
  return typeManifest({
@@ -2655,54 +2506,54 @@ function getTypeManifestVisitor(input) {
2655
2506
  visitEnumStructVariantType(enumStructVariantType, { self }) {
2656
2507
  const currentParentName = parentName;
2657
2508
  const discriminator = nameApi.discriminatedUnionDiscriminator(
2658
- (0, import_nodes28.camelCase)(currentParentName?.strict ?? "")
2509
+ nodes.camelCase(currentParentName?.strict ?? "")
2659
2510
  );
2660
2511
  const name = nameApi.discriminatedUnionVariant(enumStructVariantType.name);
2661
2512
  const kindAttribute = `${discriminator}: "${name}"`;
2662
2513
  parentName = null;
2663
- const structManifest = (0, import_visitors_core28.visit)(enumStructVariantType.struct, self);
2514
+ const structManifest = visitorsCore.visit(enumStructVariantType.struct, self);
2664
2515
  parentName = currentParentName;
2665
2516
  return typeManifest({
2666
2517
  ...structManifest,
2667
2518
  decoder: fragment`['${name}', ${structManifest.decoder}]`,
2668
2519
  encoder: fragment`['${name}', ${structManifest.encoder}]`,
2669
- looseType: (0, import_visitors_core28.pipe)(
2520
+ looseType: visitorsCore.pipe(
2670
2521
  structManifest.looseType,
2671
- (f) => (0, import_renderers_core13.mapFragmentContent)(f, (c) => `{ ${kindAttribute},${c.slice(1, -1)}}`)
2522
+ (f) => renderersCore.mapFragmentContent(f, (c) => `{ ${kindAttribute},${c.slice(1, -1)}}`)
2672
2523
  ),
2673
- strictType: (0, import_visitors_core28.pipe)(
2524
+ strictType: visitorsCore.pipe(
2674
2525
  structManifest.strictType,
2675
- (f) => (0, import_renderers_core13.mapFragmentContent)(f, (c) => `{ ${kindAttribute},${c.slice(1, -1)}}`)
2526
+ (f) => renderersCore.mapFragmentContent(f, (c) => `{ ${kindAttribute},${c.slice(1, -1)}}`)
2676
2527
  )
2677
2528
  });
2678
2529
  },
2679
2530
  visitEnumTupleVariantType(enumTupleVariantType, { self }) {
2680
2531
  const currentParentName = parentName;
2681
2532
  const discriminator = nameApi.discriminatedUnionDiscriminator(
2682
- (0, import_nodes28.camelCase)(currentParentName?.strict ?? "")
2533
+ nodes.camelCase(currentParentName?.strict ?? "")
2683
2534
  );
2684
2535
  const name = nameApi.discriminatedUnionVariant(enumTupleVariantType.name);
2685
2536
  const kindAttribute = `${discriminator}: "${name}"`;
2686
- const struct = (0, import_nodes28.structTypeNode)([
2687
- (0, import_nodes28.structFieldTypeNode)({
2537
+ const struct = nodes.structTypeNode([
2538
+ nodes.structFieldTypeNode({
2688
2539
  name: "fields",
2689
2540
  type: enumTupleVariantType.tuple
2690
2541
  })
2691
2542
  ]);
2692
2543
  parentName = null;
2693
- const structManifest = (0, import_visitors_core28.visit)(struct, self);
2544
+ const structManifest = visitorsCore.visit(struct, self);
2694
2545
  parentName = currentParentName;
2695
2546
  return typeManifest({
2696
2547
  ...structManifest,
2697
2548
  decoder: fragment`['${name}', ${structManifest.decoder}]`,
2698
2549
  encoder: fragment`['${name}', ${structManifest.encoder}]`,
2699
- looseType: (0, import_visitors_core28.pipe)(
2550
+ looseType: visitorsCore.pipe(
2700
2551
  structManifest.looseType,
2701
- (f) => (0, import_renderers_core13.mapFragmentContent)(f, (c) => `{ ${kindAttribute},${c.slice(1, -1)}}`)
2552
+ (f) => renderersCore.mapFragmentContent(f, (c) => `{ ${kindAttribute},${c.slice(1, -1)}}`)
2702
2553
  ),
2703
- strictType: (0, import_visitors_core28.pipe)(
2554
+ strictType: visitorsCore.pipe(
2704
2555
  structManifest.strictType,
2705
- (f) => (0, import_renderers_core13.mapFragmentContent)(f, (c) => `{ ${kindAttribute},${c.slice(1, -1)}}`)
2556
+ (f) => renderersCore.mapFragmentContent(f, (c) => `{ ${kindAttribute},${c.slice(1, -1)}}`)
2706
2557
  )
2707
2558
  });
2708
2559
  },
@@ -2710,16 +2561,16 @@ function getTypeManifestVisitor(input) {
2710
2561
  const currentParentName = parentName;
2711
2562
  const encoderOptions = [];
2712
2563
  const decoderOptions = [];
2713
- const enumSize = (0, import_nodes28.resolveNestedTypeNode)(enumType.size);
2564
+ const enumSize = nodes.resolveNestedTypeNode(enumType.size);
2714
2565
  if (enumSize.format !== "u8" || enumSize.endian !== "le") {
2715
- const sizeManifest = (0, import_visitors_core28.visit)(enumType.size, self);
2566
+ const sizeManifest = visitorsCore.visit(enumType.size, self);
2716
2567
  encoderOptions.push(fragment`size: ${sizeManifest.encoder}`);
2717
2568
  decoderOptions.push(fragment`size: ${sizeManifest.decoder}`);
2718
2569
  }
2719
2570
  const discriminator = nameApi.discriminatedUnionDiscriminator(
2720
- (0, import_nodes28.camelCase)(currentParentName?.strict ?? "")
2571
+ nodes.camelCase(currentParentName?.strict ?? "")
2721
2572
  );
2722
- if (!(0, import_nodes28.isScalarEnum)(enumType) && discriminator !== "__kind") {
2573
+ if (!nodes.isScalarEnum(enumType) && discriminator !== "__kind") {
2723
2574
  encoderOptions.push(fragment`discriminator: '${discriminator}'`);
2724
2575
  decoderOptions.push(fragment`discriminator: '${discriminator}'`);
2725
2576
  }
@@ -2731,7 +2582,7 @@ function getTypeManifestVisitor(input) {
2731
2582
  decoderOptions,
2732
2583
  (cs) => cs.length > 0 ? `, { ${cs.join(", ")} }` : ""
2733
2584
  );
2734
- if ((0, import_nodes28.isScalarEnum)(enumType)) {
2585
+ if (nodes.isScalarEnum(enumType)) {
2735
2586
  if (currentParentName === null) {
2736
2587
  throw new Error(
2737
2588
  "Scalar enums cannot be inlined and must be introduced via a defined type. Ensure you are not inlining a defined type that is a scalar enum through a visitor."
@@ -2747,7 +2598,7 @@ function getTypeManifestVisitor(input) {
2747
2598
  });
2748
2599
  }
2749
2600
  const mergedManifest = mergeTypeManifests(
2750
- enumType.variants.map((variant) => (0, import_visitors_core28.visit)(variant, self)),
2601
+ enumType.variants.map((variant) => visitorsCore.visit(variant, self)),
2751
2602
  {
2752
2603
  mergeCodecs: (renders) => renders.join(", "),
2753
2604
  mergeTypes: (renders) => renders.join(" | ")
@@ -2765,14 +2616,14 @@ function getTypeManifestVisitor(input) {
2765
2616
  const enumFunction = nameApi.discriminatedUnionFunction(node.enum.name);
2766
2617
  const importFrom = getImportFrom(node.enum);
2767
2618
  const enumNode = linkables.get([...stack.getPath(), node.enum])?.type;
2768
- const isScalar = enumNode && (0, import_nodes28.isNode)(enumNode, "enumTypeNode") ? (0, import_nodes28.isScalarEnum)(enumNode) : !nonScalarEnums.includes(node.enum.name);
2619
+ const isScalar = enumNode && nodes.isNode(enumNode, "enumTypeNode") ? nodes.isScalarEnum(enumNode) : !nonScalarEnums.includes(node.enum.name);
2769
2620
  if (!node.value && isScalar) {
2770
2621
  const variantName2 = nameApi.enumVariant(node.variant);
2771
2622
  return typeManifest({
2772
2623
  ...manifest,
2773
- value: (0, import_visitors_core28.pipe)(
2624
+ value: visitorsCore.pipe(
2774
2625
  manifest.value,
2775
- (f) => (0, import_renderers_core13.setFragmentContent)(f, `${enumName}.${variantName2}`),
2626
+ (f) => renderersCore.setFragmentContent(f, `${enumName}.${variantName2}`),
2776
2627
  (f) => addFragmentImports(f, importFrom, [enumName])
2777
2628
  )
2778
2629
  });
@@ -2781,24 +2632,24 @@ function getTypeManifestVisitor(input) {
2781
2632
  if (!node.value) {
2782
2633
  return typeManifest({
2783
2634
  ...manifest,
2784
- value: (0, import_visitors_core28.pipe)(
2635
+ value: visitorsCore.pipe(
2785
2636
  manifest.value,
2786
- (f) => (0, import_renderers_core13.setFragmentContent)(f, `${enumFunction}('${variantName}')`),
2637
+ (f) => renderersCore.setFragmentContent(f, `${enumFunction}('${variantName}')`),
2787
2638
  (f) => addFragmentImports(f, importFrom, [enumFunction])
2788
2639
  )
2789
2640
  });
2790
2641
  }
2791
2642
  return typeManifest({
2792
2643
  ...manifest,
2793
- value: (0, import_visitors_core28.pipe)(
2794
- (0, import_visitors_core28.visit)(node.value, self).value,
2795
- (f) => (0, import_renderers_core13.mapFragmentContent)(f, (c) => `${enumFunction}('${variantName}', ${c})`),
2644
+ value: visitorsCore.pipe(
2645
+ visitorsCore.visit(node.value, self).value,
2646
+ (f) => renderersCore.mapFragmentContent(f, (c) => `${enumFunction}('${variantName}', ${c})`),
2796
2647
  (f) => addFragmentImports(f, importFrom, [enumFunction])
2797
2648
  )
2798
2649
  });
2799
2650
  },
2800
2651
  visitFixedSizeType(node, { self }) {
2801
- const manifest = (0, import_visitors_core28.visit)(node.type, self);
2652
+ const manifest = visitorsCore.visit(node.type, self);
2802
2653
  return typeManifest({
2803
2654
  ...manifest,
2804
2655
  decoder: fragment`${use("fixDecoderSize", "solanaCodecsCore")}(${manifest.decoder}, ${node.size})`,
@@ -2806,13 +2657,13 @@ function getTypeManifestVisitor(input) {
2806
2657
  });
2807
2658
  },
2808
2659
  visitHiddenPrefixType(node, { self }) {
2809
- const manifest = (0, import_visitors_core28.visit)(node.type, self);
2810
- const prefixes = node.prefix.map((c) => (0, import_visitors_core28.visit)(c, self).value);
2811
- const prefixEncoders = (0, import_visitors_core28.pipe)(
2660
+ const manifest = visitorsCore.visit(node.type, self);
2661
+ const prefixes = node.prefix.map((c) => visitorsCore.visit(c, self).value);
2662
+ const prefixEncoders = visitorsCore.pipe(
2812
2663
  mergeFragments(prefixes, (cs) => cs.map((c) => `getConstantEncoder(${c})`).join(", ")),
2813
2664
  (f) => addFragmentImports(f, "solanaCodecsCore", ["getConstantEncoder"])
2814
2665
  );
2815
- const prefixDecoders = (0, import_visitors_core28.pipe)(
2666
+ const prefixDecoders = visitorsCore.pipe(
2816
2667
  mergeFragments(prefixes, (cs) => cs.map((c) => `getConstantDecoder(${c})`).join(", ")),
2817
2668
  (f) => addFragmentImports(f, "solanaCodecsCore", ["getConstantDecoder"])
2818
2669
  );
@@ -2823,13 +2674,13 @@ function getTypeManifestVisitor(input) {
2823
2674
  });
2824
2675
  },
2825
2676
  visitHiddenSuffixType(node, { self }) {
2826
- const manifest = (0, import_visitors_core28.visit)(node.type, self);
2827
- const suffixes = node.suffix.map((c) => (0, import_visitors_core28.visit)(c, self).value);
2828
- const suffixEncoders = (0, import_visitors_core28.pipe)(
2677
+ const manifest = visitorsCore.visit(node.type, self);
2678
+ const suffixes = node.suffix.map((c) => visitorsCore.visit(c, self).value);
2679
+ const suffixEncoders = visitorsCore.pipe(
2829
2680
  mergeFragments(suffixes, (cs) => cs.map((c) => `getConstantEncoder(${c})`).join(", ")),
2830
2681
  (f) => addFragmentImports(f, "solanaCodecsCore", ["getConstantEncoder"])
2831
2682
  );
2832
- const suffixDecoders = (0, import_visitors_core28.pipe)(
2683
+ const suffixDecoders = visitorsCore.pipe(
2833
2684
  mergeFragments(suffixes, (cs) => cs.map((c) => `getConstantDecoder(${c})`).join(", ")),
2834
2685
  (f) => addFragmentImports(f, "solanaCodecsCore", ["getConstantDecoder"])
2835
2686
  );
@@ -2846,19 +2697,19 @@ function getTypeManifestVisitor(input) {
2846
2697
  strict: nameApi.dataType(instructionDataName)
2847
2698
  };
2848
2699
  const link = customInstructionData.get(instruction.name)?.linkNode;
2849
- const struct = (0, import_nodes28.structTypeNodeFromInstructionArgumentNodes)(instruction.arguments);
2850
- const manifest = link ? (0, import_visitors_core28.visit)(link, self) : (0, import_visitors_core28.visit)(struct, self);
2700
+ const struct = nodes.structTypeNodeFromInstructionArgumentNodes(instruction.arguments);
2701
+ const manifest = link ? visitorsCore.visit(link, self) : visitorsCore.visit(struct, self);
2851
2702
  parentName = null;
2852
2703
  return manifest;
2853
2704
  },
2854
2705
  visitMapEntryValue(node, { self }) {
2855
- return mergeTypeManifests([(0, import_visitors_core28.visit)(node.key, self), (0, import_visitors_core28.visit)(node.value, self)], {
2706
+ return mergeTypeManifests([visitorsCore.visit(node.key, self), visitorsCore.visit(node.value, self)], {
2856
2707
  mergeValues: (renders) => `[${renders.join(", ")}]`
2857
2708
  });
2858
2709
  },
2859
2710
  visitMapType(mapType, { self }) {
2860
- const key = (0, import_visitors_core28.visit)(mapType.key, self);
2861
- const value = (0, import_visitors_core28.visit)(mapType.value, self);
2711
+ const key = visitorsCore.visit(mapType.key, self);
2712
+ const value = visitorsCore.visit(mapType.value, self);
2862
2713
  const mergedManifest = mergeTypeManifests([key, value], {
2863
2714
  mergeCodecs: ([k, v]) => `${k}, ${v}`,
2864
2715
  mergeTypes: ([k, v]) => `Map<${k}, ${v}>`
@@ -2873,7 +2724,7 @@ function getTypeManifestVisitor(input) {
2873
2724
  });
2874
2725
  },
2875
2726
  visitMapValue(node, { self }) {
2876
- const entryFragments = node.entries.map((entry) => (0, import_visitors_core28.visit)(entry, self));
2727
+ const entryFragments = node.entries.map((entry) => visitorsCore.visit(entry, self));
2877
2728
  return mergeTypeManifests(entryFragments, {
2878
2729
  mergeValues: (renders) => `new Map([${renders.join(", ")}])`
2879
2730
  });
@@ -2899,12 +2750,12 @@ function getTypeManifestVisitor(input) {
2899
2750
  return typeManifest({ value: fragment`${JSON.stringify(node.number)}` });
2900
2751
  },
2901
2752
  visitOptionType(optionType, { self }) {
2902
- const childManifest = (0, import_visitors_core28.visit)(optionType.item, self);
2753
+ const childManifest = visitorsCore.visit(optionType.item, self);
2903
2754
  const encoderOptions = [];
2904
2755
  const decoderOptions = [];
2905
- const optionPrefix = (0, import_nodes28.resolveNestedTypeNode)(optionType.prefix);
2756
+ const optionPrefix = nodes.resolveNestedTypeNode(optionType.prefix);
2906
2757
  if (optionPrefix.format !== "u8" || optionPrefix.endian !== "le") {
2907
- const prefixManifest = (0, import_visitors_core28.visit)(optionType.prefix, self);
2758
+ const prefixManifest = visitorsCore.visit(optionType.prefix, self);
2908
2759
  encoderOptions.push(fragment`prefix: ${prefixManifest.encoder}`);
2909
2760
  decoderOptions.push(fragment`prefix: ${prefixManifest.decoder}`);
2910
2761
  }
@@ -2929,7 +2780,7 @@ function getTypeManifestVisitor(input) {
2929
2780
  });
2930
2781
  },
2931
2782
  visitPostOffsetType(node, { self }) {
2932
- const manifest = (0, import_visitors_core28.visit)(node.type, self);
2783
+ const manifest = visitorsCore.visit(node.type, self);
2933
2784
  if (node.strategy === "padded") {
2934
2785
  return typeManifest({
2935
2786
  ...manifest,
@@ -2955,7 +2806,7 @@ function getTypeManifestVisitor(input) {
2955
2806
  });
2956
2807
  },
2957
2808
  visitPreOffsetType(node, { self }) {
2958
- const manifest = (0, import_visitors_core28.visit)(node.type, self);
2809
+ const manifest = visitorsCore.visit(node.type, self);
2959
2810
  if (node.strategy === "padded") {
2960
2811
  return typeManifest({
2961
2812
  ...manifest,
@@ -2992,7 +2843,7 @@ function getTypeManifestVisitor(input) {
2992
2843
  });
2993
2844
  },
2994
2845
  visitRemainderOptionType(node, { self }) {
2995
- const childManifest = (0, import_visitors_core28.visit)(node.item, self);
2846
+ const childManifest = visitorsCore.visit(node.item, self);
2996
2847
  const encoderOptions = ["prefix: null"];
2997
2848
  const decoderOptions = ["prefix: null"];
2998
2849
  const encoderOptionsAsString = encoderOptions.length > 0 ? `, { ${encoderOptions.join(", ")} }` : "";
@@ -3006,8 +2857,8 @@ function getTypeManifestVisitor(input) {
3006
2857
  });
3007
2858
  },
3008
2859
  visitSentinelType(node, { self }) {
3009
- const manifest = (0, import_visitors_core28.visit)(node.type, self);
3010
- const sentinel = (0, import_visitors_core28.visit)(node.sentinel, self).value;
2860
+ const manifest = visitorsCore.visit(node.type, self);
2861
+ const sentinel = visitorsCore.visit(node.sentinel, self).value;
3011
2862
  return typeManifest({
3012
2863
  ...manifest,
3013
2864
  decoder: fragment`${use("addDecoderSentinel", "solanaCodecsCore")}(${manifest.decoder}, ${sentinel})`,
@@ -3015,7 +2866,7 @@ function getTypeManifestVisitor(input) {
3015
2866
  });
3016
2867
  },
3017
2868
  visitSetType(setType, { self }) {
3018
- const childManifest = (0, import_visitors_core28.visit)(setType.item, self);
2869
+ const childManifest = visitorsCore.visit(setType.item, self);
3019
2870
  const sizeManifest = getArrayLikeSizeOption(setType.count, self);
3020
2871
  const encoderOptions = sizeManifest.encoder ? fragment`, { ${sizeManifest.encoder} }` : "";
3021
2872
  const decoderOptions = sizeManifest.decoder ? fragment`, { ${sizeManifest.decoder} }` : "";
@@ -3029,13 +2880,13 @@ function getTypeManifestVisitor(input) {
3029
2880
  },
3030
2881
  visitSetValue(node, { self }) {
3031
2882
  return mergeTypeManifests(
3032
- node.items.map((v) => (0, import_visitors_core28.visit)(v, self)),
2883
+ node.items.map((v) => visitorsCore.visit(v, self)),
3033
2884
  { mergeValues: (renders) => `new Set([${renders.join(", ")}])` }
3034
2885
  );
3035
2886
  },
3036
2887
  visitSizePrefixType(node, { self }) {
3037
- const manifest = (0, import_visitors_core28.visit)(node.type, self);
3038
- const prefix = (0, import_visitors_core28.visit)(node.prefix, self);
2888
+ const manifest = visitorsCore.visit(node.type, self);
2889
+ const prefix = visitorsCore.visit(node.prefix, self);
3039
2890
  return typeManifest({
3040
2891
  ...manifest,
3041
2892
  decoder: fragment`${use("addDecoderSizePrefix", "solanaCodecsCore")}(${manifest.decoder}, ${prefix.decoder})`,
@@ -3043,7 +2894,7 @@ function getTypeManifestVisitor(input) {
3043
2894
  });
3044
2895
  },
3045
2896
  visitSolAmountType({ number }, { self }) {
3046
- const numberManifest = (0, import_visitors_core28.visit)(number, self);
2897
+ const numberManifest = visitorsCore.visit(number, self);
3047
2898
  return typeManifest({
3048
2899
  ...numberManifest,
3049
2900
  decoder: fragment`${use("getLamportsDecoder", "solanaRpcTypes")}(${numberManifest.decoder})`,
@@ -3053,7 +2904,7 @@ function getTypeManifestVisitor(input) {
3053
2904
  });
3054
2905
  },
3055
2906
  visitSomeValue(node, { self }) {
3056
- const innerValue = (0, import_visitors_core28.visit)(node.value, self).value;
2907
+ const innerValue = visitorsCore.visit(node.value, self).value;
3057
2908
  return typeManifest({
3058
2909
  value: fragment`${use("some", "solanaOptions")}(${innerValue})`
3059
2910
  });
@@ -3086,8 +2937,8 @@ function getTypeManifestVisitor(input) {
3086
2937
  });
3087
2938
  },
3088
2939
  visitStructFieldType(structFieldType, { self }) {
3089
- const name = (0, import_nodes28.camelCase)(structFieldType.name);
3090
- const originalChildManifest = (0, import_visitors_core28.visit)(structFieldType.type, self);
2940
+ const name = nodes.camelCase(structFieldType.name);
2941
+ const originalChildManifest = visitorsCore.visit(structFieldType.type, self);
3091
2942
  let docs = getDocblockFragment(structFieldType.docs ?? [], true);
3092
2943
  docs = docs ? fragment`\n${docs}` : docs;
3093
2944
  const childManifest = typeManifest({
@@ -3109,16 +2960,16 @@ function getTypeManifestVisitor(input) {
3109
2960
  return typeManifest({ ...childManifest, looseType: fragment`` });
3110
2961
  },
3111
2962
  visitStructFieldValue(node, { self }) {
3112
- const innerValue = (0, import_visitors_core28.visit)(node.value, self).value;
2963
+ const innerValue = visitorsCore.visit(node.value, self).value;
3113
2964
  return typeManifest({
3114
2965
  value: fragment`${node.name}: ${innerValue}`
3115
2966
  });
3116
2967
  },
3117
2968
  visitStructType(structType, { self }) {
3118
2969
  const optionalFields = structType.fields.filter((f) => !!f.defaultValue);
3119
- const mergedManifest = (0, import_visitors_core28.pipe)(
2970
+ const mergedManifest = visitorsCore.pipe(
3120
2971
  mergeTypeManifests(
3121
- structType.fields.map((field) => (0, import_visitors_core28.visit)(field, self)),
2972
+ structType.fields.map((field) => visitorsCore.visit(field, self)),
3122
2973
  {
3123
2974
  mergeCodecs: (renders) => `([${renders.join(", ")}])`,
3124
2975
  mergeTypes: (renders) => `{ ${renders.join("")} }`
@@ -3134,20 +2985,20 @@ function getTypeManifestVisitor(input) {
3134
2985
  return mergedManifest;
3135
2986
  }
3136
2987
  const parentPath = stack.getPath();
3137
- const instructionNode = (0, import_visitors_core28.findLastNodeFromPath)(parentPath, "instructionNode");
3138
- const accountNode = (0, import_visitors_core28.findLastNodeFromPath)(parentPath, "accountNode");
2988
+ const instructionNode = visitorsCore.findLastNodeFromPath(parentPath, "instructionNode");
2989
+ const accountNode = visitorsCore.findLastNodeFromPath(parentPath, "accountNode");
3139
2990
  const discriminatorPrefix = instructionNode ? instructionNode.name : accountNode?.name;
3140
2991
  const discriminators = (instructionNode ? instructionNode.discriminators : accountNode?.discriminators) ?? [];
3141
- const fieldDiscriminators = discriminators.filter((0, import_nodes28.isNodeFilter)("fieldDiscriminatorNode"));
2992
+ const fieldDiscriminators = discriminators.filter(nodes.isNodeFilter("fieldDiscriminatorNode"));
3142
2993
  const defaultValues = mergeFragments(
3143
2994
  optionalFields.map((f) => {
3144
- const key = (0, import_nodes28.camelCase)(f.name);
2995
+ const key = nodes.camelCase(f.name);
3145
2996
  if (fieldDiscriminators.some((d) => d.name === f.name)) {
3146
- const constantName = nameApi.constant((0, import_nodes28.camelCase)(`${discriminatorPrefix}_${f.name}`));
2997
+ const constantName = nameApi.constant(nodes.camelCase(`${discriminatorPrefix}_${f.name}`));
3147
2998
  return f.defaultValueStrategy === "omitted" ? fragment`${key}: ${constantName}` : fragment`${key}: value.${key} ?? ${constantName}`;
3148
2999
  }
3149
3000
  const defaultValue = f.defaultValue;
3150
- const value = (0, import_visitors_core28.visit)(defaultValue, self).value;
3001
+ const value = visitorsCore.visit(defaultValue, self).value;
3151
3002
  return f.defaultValueStrategy === "omitted" ? fragment`${key}: ${value}` : fragment`${key}: value.${key} ?? ${value}`;
3152
3003
  }),
3153
3004
  (cs) => cs.join(", ")
@@ -3159,12 +3010,12 @@ function getTypeManifestVisitor(input) {
3159
3010
  },
3160
3011
  visitStructValue(node, { self }) {
3161
3012
  return mergeTypeManifests(
3162
- node.fields.map((field) => (0, import_visitors_core28.visit)(field, self)),
3013
+ node.fields.map((field) => visitorsCore.visit(field, self)),
3163
3014
  { mergeValues: (renders) => `{ ${renders.join(", ")} }` }
3164
3015
  );
3165
3016
  },
3166
3017
  visitTupleType(tupleType, { self }) {
3167
- const items = tupleType.items.map((item) => (0, import_visitors_core28.visit)(item, self));
3018
+ const items = tupleType.items.map((item) => visitorsCore.visit(item, self));
3168
3019
  const mergedManifest = mergeTypeManifests(items, {
3169
3020
  mergeCodecs: (codecs) => `[${codecs.join(", ")}]`,
3170
3021
  mergeTypes: (types) => `readonly [${types.join(", ")}]`
@@ -3177,16 +3028,16 @@ function getTypeManifestVisitor(input) {
3177
3028
  },
3178
3029
  visitTupleValue(node, { self }) {
3179
3030
  return mergeTypeManifests(
3180
- node.items.map((v) => (0, import_visitors_core28.visit)(v, self)),
3031
+ node.items.map((v) => visitorsCore.visit(v, self)),
3181
3032
  { mergeValues: (renders) => `[${renders.join(", ")}]` }
3182
3033
  );
3183
3034
  },
3184
3035
  visitZeroableOptionType(node, { self }) {
3185
- const childManifest = (0, import_visitors_core28.visit)(node.item, self);
3036
+ const childManifest = visitorsCore.visit(node.item, self);
3186
3037
  const encoderOptions = [fragment`prefix: null`];
3187
3038
  const decoderOptions = [fragment`prefix: null`];
3188
3039
  if (node.zeroValue) {
3189
- const zeroValueManifest = (0, import_visitors_core28.visit)(node.zeroValue, self);
3040
+ const zeroValueManifest = visitorsCore.visit(node.zeroValue, self);
3190
3041
  encoderOptions.push(fragment`noneValue: ${zeroValueManifest.value}`);
3191
3042
  decoderOptions.push(fragment`noneValue: ${zeroValueManifest.value}`);
3192
3043
  } else {
@@ -3210,41 +3061,41 @@ function getTypeManifestVisitor(input) {
3210
3061
  });
3211
3062
  }
3212
3063
  }),
3213
- (visitor) => (0, import_visitors_core28.recordNodeStackVisitor)(visitor, stack)
3064
+ (visitor) => visitorsCore.recordNodeStackVisitor(visitor, stack)
3214
3065
  );
3215
3066
  }
3216
3067
  function getArrayLikeSizeOption(count, visitor) {
3217
- if ((0, import_nodes28.isNode)(count, "fixedCountNode")) {
3068
+ if (nodes.isNode(count, "fixedCountNode")) {
3218
3069
  return {
3219
3070
  decoder: fragment`size: ${count.value}`,
3220
3071
  encoder: fragment`size: ${count.value}`
3221
3072
  };
3222
3073
  }
3223
- if ((0, import_nodes28.isNode)(count, "remainderCountNode")) {
3074
+ if (nodes.isNode(count, "remainderCountNode")) {
3224
3075
  return {
3225
3076
  decoder: fragment`size: 'remainder'`,
3226
3077
  encoder: fragment`size: 'remainder'`
3227
3078
  };
3228
3079
  }
3229
- const prefix = (0, import_nodes28.resolveNestedTypeNode)(count.prefix);
3080
+ const prefix = nodes.resolveNestedTypeNode(count.prefix);
3230
3081
  if (prefix.format === "u32" && prefix.endian === "le") {
3231
3082
  return { decoder: void 0, encoder: void 0 };
3232
3083
  }
3233
- const prefixManifest = (0, import_visitors_core28.visit)(count.prefix, visitor);
3084
+ const prefixManifest = visitorsCore.visit(count.prefix, visitor);
3234
3085
  return {
3235
- decoder: (0, import_visitors_core28.pipe)(prefixManifest.decoder, (f) => (0, import_renderers_core13.mapFragmentContent)(f, (c) => `size: ${c}`)),
3236
- encoder: (0, import_visitors_core28.pipe)(prefixManifest.encoder, (f) => (0, import_renderers_core13.mapFragmentContent)(f, (c) => `size: ${c}`))
3086
+ decoder: visitorsCore.pipe(prefixManifest.decoder, (f) => renderersCore.mapFragmentContent(f, (c) => `size: ${c}`)),
3087
+ encoder: visitorsCore.pipe(prefixManifest.encoder, (f) => renderersCore.mapFragmentContent(f, (c) => `size: ${c}`))
3237
3088
  };
3238
3089
  }
3239
3090
 
3240
3091
  // src/visitors/getRenderMapVisitor.ts
3241
3092
  function getRenderMapVisitor(options = {}) {
3242
- const linkables = new import_visitors_core29.LinkableDictionary();
3243
- const stack = new import_visitors_core29.NodeStack();
3093
+ const linkables = new visitorsCore.LinkableDictionary();
3094
+ const stack = new visitorsCore.NodeStack();
3244
3095
  const customAccountData = parseCustomDataOptions(options.customAccountData ?? [], "AccountData");
3245
3096
  const customInstructionData = parseCustomDataOptions(options.customInstructionData ?? [], "InstructionData");
3246
3097
  const renderScopeWithTypeManifestVisitor = {
3247
- asyncResolvers: (options.asyncResolvers ?? []).map(import_nodes29.camelCase),
3098
+ asyncResolvers: (options.asyncResolvers ?? []).map(nodes.camelCase),
3248
3099
  customAccountData,
3249
3100
  customInstructionData,
3250
3101
  dependencyMap: options.dependencyMap ?? {},
@@ -3252,15 +3103,15 @@ function getRenderMapVisitor(options = {}) {
3252
3103
  getImportFrom: getImportFromFactory(options.linkOverrides ?? {}, customAccountData, customInstructionData),
3253
3104
  linkables,
3254
3105
  nameApi: getNameApi({ ...DEFAULT_NAME_TRANSFORMERS, ...options.nameTransformers }),
3255
- nonScalarEnums: (options.nonScalarEnums ?? []).map(import_nodes29.camelCase),
3106
+ nonScalarEnums: (options.nonScalarEnums ?? []).map(nodes.camelCase),
3256
3107
  renderParentInstructions: options.renderParentInstructions ?? false,
3257
3108
  useGranularImports: options.useGranularImports ?? false
3258
3109
  };
3259
3110
  const typeManifestVisitor = getTypeManifestVisitor({ ...renderScopeWithTypeManifestVisitor, stack });
3260
3111
  const renderScope = { ...renderScopeWithTypeManifestVisitor, typeManifestVisitor };
3261
- const internalNodes = (options.internalNodes ?? []).map(import_nodes29.camelCase);
3262
- const resolvedInstructionInputVisitor = (0, import_visitors_core29.getResolvedInstructionInputsVisitor)();
3263
- const byteSizeVisitor = (0, import_visitors_core29.getByteSizeVisitor)(linkables, { stack });
3112
+ const internalNodes = (options.internalNodes ?? []).map(nodes.camelCase);
3113
+ const resolvedInstructionInputVisitor = visitorsCore.getResolvedInstructionInputsVisitor();
3114
+ const byteSizeVisitor = visitorsCore.getByteSizeVisitor(linkables, { stack });
3264
3115
  const asPage = (fragment2, dependencyMap = {}) => {
3265
3116
  if (!fragment2) return void 0;
3266
3117
  return getPageFragment(fragment2, {
@@ -3268,47 +3119,47 @@ function getRenderMapVisitor(options = {}) {
3268
3119
  dependencyMap: { ...renderScope.dependencyMap, ...dependencyMap }
3269
3120
  });
3270
3121
  };
3271
- return (0, import_visitors_core29.pipe)(
3272
- (0, import_visitors_core29.staticVisitor)(() => (0, import_renderers_core14.createRenderMap)(), {
3122
+ return visitorsCore.pipe(
3123
+ visitorsCore.staticVisitor(() => renderersCore.createRenderMap(), {
3273
3124
  keys: ["rootNode", "programNode", "pdaNode", "accountNode", "definedTypeNode", "instructionNode"]
3274
3125
  }),
3275
- (v) => (0, import_visitors_core29.extendVisitor)(v, {
3126
+ (v) => visitorsCore.extendVisitor(v, {
3276
3127
  visitAccount(node) {
3277
- return (0, import_renderers_core14.createRenderMap)(
3278
- `accounts/${(0, import_nodes29.camelCase)(node.name)}.ts`,
3128
+ return renderersCore.createRenderMap(
3129
+ `accounts/${nodes.camelCase(node.name)}.ts`,
3279
3130
  asPage(
3280
3131
  getAccountPageFragment({
3281
3132
  ...renderScope,
3282
3133
  accountPath: stack.getPath("accountNode"),
3283
- size: (0, import_visitors_core29.visit)(node, byteSizeVisitor)
3134
+ size: visitorsCore.visit(node, byteSizeVisitor)
3284
3135
  })
3285
3136
  )
3286
3137
  );
3287
3138
  },
3288
3139
  visitDefinedType(node) {
3289
- return (0, import_renderers_core14.createRenderMap)(
3290
- `types/${(0, import_nodes29.camelCase)(node.name)}.ts`,
3291
- asPage(getTypePageFragment({ ...renderScope, node, size: (0, import_visitors_core29.visit)(node, byteSizeVisitor) }), {
3140
+ return renderersCore.createRenderMap(
3141
+ `types/${nodes.camelCase(node.name)}.ts`,
3142
+ asPage(getTypePageFragment({ ...renderScope, node, size: visitorsCore.visit(node, byteSizeVisitor) }), {
3292
3143
  generatedTypes: "."
3293
3144
  })
3294
3145
  );
3295
3146
  },
3296
3147
  visitInstruction(node) {
3297
- return (0, import_renderers_core14.createRenderMap)(
3298
- `instructions/${(0, import_nodes29.camelCase)(node.name)}.ts`,
3148
+ return renderersCore.createRenderMap(
3149
+ `instructions/${nodes.camelCase(node.name)}.ts`,
3299
3150
  asPage(
3300
3151
  getInstructionPageFragment({
3301
3152
  ...renderScope,
3302
3153
  instructionPath: stack.getPath("instructionNode"),
3303
- resolvedInputs: (0, import_visitors_core29.visit)(node, resolvedInstructionInputVisitor),
3304
- size: (0, import_visitors_core29.visit)(node, byteSizeVisitor)
3154
+ resolvedInputs: visitorsCore.visit(node, resolvedInstructionInputVisitor),
3155
+ size: visitorsCore.visit(node, byteSizeVisitor)
3305
3156
  })
3306
3157
  )
3307
3158
  );
3308
3159
  },
3309
3160
  visitPda(node) {
3310
- return (0, import_renderers_core14.createRenderMap)(
3311
- `pdas/${(0, import_nodes29.camelCase)(node.name)}.ts`,
3161
+ return renderersCore.createRenderMap(
3162
+ `pdas/${nodes.camelCase(node.name)}.ts`,
3312
3163
  asPage(getPdaPageFragment({ ...renderScope, pdaPath: stack.getPath("pdaNode") }))
3313
3164
  );
3314
3165
  },
@@ -3318,41 +3169,40 @@ function getRenderMapVisitor(options = {}) {
3318
3169
  ...getDefinedTypeNodesToExtract(node.instructions, customInstructionData)
3319
3170
  ];
3320
3171
  const scope = { ...renderScope, programNode: node };
3321
- return (0, import_renderers_core14.mergeRenderMaps)([
3322
- (0, import_renderers_core14.createRenderMap)({
3323
- [`programs/${(0, import_nodes29.camelCase)(node.name)}.ts`]: asPage(getProgramPageFragment(scope)),
3324
- [`errors/${(0, import_nodes29.camelCase)(node.name)}.ts`]: node.errors.length > 0 ? asPage(getErrorPageFragment(scope)) : void 0
3172
+ return renderersCore.mergeRenderMaps([
3173
+ renderersCore.createRenderMap({
3174
+ [`programs/${nodes.camelCase(node.name)}.ts`]: asPage(getProgramPageFragment(scope)),
3175
+ [`errors/${nodes.camelCase(node.name)}.ts`]: node.errors.length > 0 ? asPage(getErrorPageFragment(scope)) : void 0
3325
3176
  }),
3326
- ...node.pdas.map((p) => (0, import_visitors_core29.visit)(p, self)),
3327
- ...node.accounts.map((a) => (0, import_visitors_core29.visit)(a, self)),
3328
- ...node.definedTypes.map((t) => (0, import_visitors_core29.visit)(t, self)),
3329
- ...customDataDefinedType.map((t) => (0, import_visitors_core29.visit)(t, self)),
3330
- ...(0, import_nodes29.getAllInstructionsWithSubs)(node, { leavesOnly: !renderScope.renderParentInstructions }).map(
3331
- (i) => (0, import_visitors_core29.visit)(i, self)
3177
+ ...node.pdas.map((p) => visitorsCore.visit(p, self)),
3178
+ ...node.accounts.map((a) => visitorsCore.visit(a, self)),
3179
+ ...node.definedTypes.map((t) => visitorsCore.visit(t, self)),
3180
+ ...customDataDefinedType.map((t) => visitorsCore.visit(t, self)),
3181
+ ...nodes.getAllInstructionsWithSubs(node, { leavesOnly: !renderScope.renderParentInstructions }).map(
3182
+ (i) => visitorsCore.visit(i, self)
3332
3183
  )
3333
3184
  ]);
3334
3185
  },
3335
3186
  visitRoot(node, { self }) {
3336
3187
  const isNotInternal = (n) => !internalNodes.includes(n.name);
3337
- const programsToExport = (0, import_nodes29.getAllPrograms)(node).filter(isNotInternal);
3188
+ const programsToExport = nodes.getAllPrograms(node).filter(isNotInternal);
3338
3189
  const programsWithErrorsToExport = programsToExport.filter((p) => p.errors.length > 0);
3339
- const pdasToExport = (0, import_nodes29.getAllPdas)(node);
3340
- const accountsToExport = (0, import_nodes29.getAllAccounts)(node).filter(isNotInternal);
3341
- const instructionsToExport = (0, import_nodes29.getAllInstructionsWithSubs)(node, {
3190
+ const pdasToExport = nodes.getAllPdas(node);
3191
+ const accountsToExport = nodes.getAllAccounts(node).filter(isNotInternal);
3192
+ const instructionsToExport = nodes.getAllInstructionsWithSubs(node, {
3342
3193
  leavesOnly: !renderScope.renderParentInstructions
3343
3194
  }).filter(isNotInternal);
3344
- const definedTypesToExport = (0, import_nodes29.getAllDefinedTypes)(node).filter(isNotInternal);
3195
+ const definedTypesToExport = nodes.getAllDefinedTypes(node).filter(isNotInternal);
3345
3196
  const hasAnythingToExport = programsToExport.length > 0 || accountsToExport.length > 0 || instructionsToExport.length > 0 || definedTypesToExport.length > 0;
3346
3197
  const scope = {
3347
- ...renderScope,
3348
3198
  accountsToExport,
3349
3199
  definedTypesToExport,
3350
3200
  instructionsToExport,
3351
3201
  pdasToExport,
3352
3202
  programsToExport
3353
3203
  };
3354
- return (0, import_renderers_core14.mergeRenderMaps)([
3355
- (0, import_renderers_core14.createRenderMap)({
3204
+ return renderersCore.mergeRenderMaps([
3205
+ renderersCore.createRenderMap({
3356
3206
  ["accounts/index.ts"]: asPage(getIndexPageFragment(accountsToExport)),
3357
3207
  ["errors/index.ts"]: asPage(getIndexPageFragment(programsWithErrorsToExport)),
3358
3208
  ["index.ts"]: asPage(getRootIndexPageFragment(scope)),
@@ -3362,61 +3212,40 @@ function getRenderMapVisitor(options = {}) {
3362
3212
  ["shared/index.ts"]: hasAnythingToExport ? asPage(getSharedPageFragment()) : void 0,
3363
3213
  ["types/index.ts"]: asPage(getIndexPageFragment(definedTypesToExport))
3364
3214
  }),
3365
- ...(0, import_nodes29.getAllPrograms)(node).map((p) => (0, import_visitors_core29.visit)(p, self))
3215
+ ...nodes.getAllPrograms(node).map((p) => visitorsCore.visit(p, self))
3366
3216
  ]);
3367
3217
  }
3368
3218
  }),
3369
- (v) => (0, import_visitors_core29.recordNodeStackVisitor)(v, stack),
3370
- (v) => (0, import_visitors_core29.recordLinkablesOnFirstVisitVisitor)(v, linkables)
3219
+ (v) => visitorsCore.recordNodeStackVisitor(v, stack),
3220
+ (v) => visitorsCore.recordLinkablesOnFirstVisitVisitor(v, linkables)
3371
3221
  );
3372
3222
  }
3373
-
3374
- // src/visitors/renderVisitor.ts
3375
- var import_renderers_core15 = require("@codama/renderers-core");
3376
- var import_visitors_core30 = require("@codama/visitors-core");
3377
- var estreePlugin = __toESM(require("prettier/plugins/estree"));
3378
- var typeScriptPlugin = __toESM(require("prettier/plugins/typescript"));
3379
- var import_standalone = require("prettier/standalone");
3380
- var DEFAULT_PRETTIER_OPTIONS = {
3381
- arrowParens: "always",
3382
- parser: "typescript",
3383
- plugins: [estreePlugin, typeScriptPlugin],
3384
- printWidth: 80,
3385
- semi: true,
3386
- singleQuote: true,
3387
- tabWidth: 2,
3388
- trailingComma: "es5",
3389
- useTabs: false
3390
- };
3391
3223
  function renderVisitor(path, options = {}) {
3392
- return (0, import_visitors_core30.rootNodeVisitor)(async (root) => {
3224
+ return visitorsCore.rootNodeVisitor(async (root) => {
3393
3225
  if (options.deleteFolderBeforeRendering ?? true) {
3394
- (0, import_renderers_core15.deleteDirectory)(path);
3395
- }
3396
- let renderMap = (0, import_visitors_core30.visit)(root, getRenderMapVisitor(options));
3397
- if (options.formatCode ?? true) {
3398
- const prettierOptions = { ...DEFAULT_PRETTIER_OPTIONS, ...options.prettierOptions };
3399
- renderMap = await (0, import_renderers_core15.mapRenderMapContentAsync)(renderMap, (code) => (0, import_standalone.format)(code, prettierOptions));
3226
+ renderersCore.deleteDirectory(path);
3400
3227
  }
3228
+ let renderMap = visitorsCore.visit(root, getRenderMapVisitor(options));
3229
+ renderMap = await formatCode(renderMap, options);
3401
3230
  syncPackageJson(renderMap, options);
3402
- (0, import_renderers_core15.writeRenderMap)(renderMap, path);
3231
+ renderersCore.writeRenderMap(renderMap, path);
3403
3232
  });
3404
3233
  }
3405
- // Annotate the CommonJS export names for ESM import in node:
3406
- 0 && (module.exports = {
3407
- DEFAULT_NAME_TRANSFORMERS,
3408
- addToImportMap,
3409
- createImportMap,
3410
- getExternalDependencies,
3411
- getNameApi,
3412
- getRenderMapVisitor,
3413
- getTypeManifestVisitor,
3414
- importMapToString,
3415
- mergeImportMaps,
3416
- mergeTypeManifests,
3417
- parseImportInput,
3418
- removeFromImportMap,
3419
- renderVisitor,
3420
- typeManifest
3421
- });
3234
+
3235
+ exports.DEFAULT_NAME_TRANSFORMERS = DEFAULT_NAME_TRANSFORMERS;
3236
+ exports.addToImportMap = addToImportMap;
3237
+ exports.createImportMap = createImportMap;
3238
+ exports.default = renderVisitor;
3239
+ exports.getExternalDependencies = getExternalDependencies;
3240
+ exports.getNameApi = getNameApi;
3241
+ exports.getRenderMapVisitor = getRenderMapVisitor;
3242
+ exports.getTypeManifestVisitor = getTypeManifestVisitor;
3243
+ exports.importMapToString = importMapToString;
3244
+ exports.mergeImportMaps = mergeImportMaps;
3245
+ exports.mergeTypeManifests = mergeTypeManifests;
3246
+ exports.parseImportInput = parseImportInput;
3247
+ exports.removeFromImportMap = removeFromImportMap;
3248
+ exports.renderVisitor = renderVisitor;
3249
+ exports.typeManifest = typeManifest;
3250
+ //# sourceMappingURL=index.node.cjs.map
3422
3251
  //# sourceMappingURL=index.node.cjs.map