@r_masseater/vite-plus-adopt 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/attw.mjs CHANGED
@@ -1,7 +1,8 @@
1
- import { Array as Array$1, MutableRef, Option, Predicate, Record, String as String$1, pipe } from "effect";
1
+ import { t as parseJson } from "./json-D-rhjlSM.mjs";
2
+ import { Array as Array$1, Function, MutableRef, Option, Order, Predicate, Record, String as String$1, pipe } from "effect";
3
+ import semver, { major, maxSatisfying, minor, valid, validRange } from "semver";
2
4
  import { untar } from "@andrewbranch/untar.js";
3
5
  import { FlateErrorCode, Gunzip } from "fflate";
4
- import semver, { major, maxSatisfying, minor, valid, validRange } from "semver";
5
6
  import { serverFS } from "typescript/fs";
6
7
  import { API, ModuleKind, ModuleResolutionKind, ObjectFlags, SignatureKind, SymbolFlags, TypeFlags, isObjectType } from "typescript/sync";
7
8
  import { init, parse } from "cjs-module-lexer";
@@ -10,34 +11,38 @@ import { isArrayBindingPattern, isArrayLiteralExpression, isArrowFunction, isBin
10
11
  import validatePackgeName from "validate-npm-package-name";
11
12
  import * as cjs from "@loaderkit/resolve/cjs";
12
13
  import * as esm from "@loaderkit/resolve/esm";
14
+ // src/attw/flags.ts
15
+ const DATA_FIRST_ARITY$36 = 2;
13
16
  const SET_BIT = 1;
14
17
  const BINARY = 2;
15
18
  const sharedFlags = (left, right) => {
16
19
  if (left === 0 || right === 0) return 0;
17
20
  return Number(left % BINARY === SET_BIT && right % BINARY === SET_BIT) + BINARY * sharedFlags(Math.floor(left / BINARY), Math.floor(right / BINARY));
18
21
  };
19
- const hasFlag = (flags, mask) => sharedFlags(flags, mask) !== 0;
20
- const withFlags = (flags, mask) => flags + mask - sharedFlags(flags, mask);
21
- const withoutFlags = (flags, mask) => flags - sharedFlags(flags, mask);
22
+ const hasFlag = Function.dual(DATA_FIRST_ARITY$36, (flags, mask) => sharedFlags(flags, mask) !== 0);
23
+ const withFlags = Function.dual(DATA_FIRST_ARITY$36, (flags, mask) => flags + mask - sharedFlags(flags, mask));
24
+ const withoutFlags = Function.dual(DATA_FIRST_ARITY$36, (flags, mask) => flags - sharedFlags(flags, mask));
22
25
  const combineFlags = (...masks) => Array$1.reduce(masks, 0, withFlags);
23
26
  // src/attw/binder-symbols.ts
27
+ const DATA_FIRST_ARITY$35 = 2;
28
+ const DATA_FIRST_ARITY_3$22 = 3;
24
29
  const UNDERSCORE = "_";
25
30
  const DOUBLE_UNDERSCORE = "__";
26
31
  const TRIPLE_UNDERSCORE = "___";
27
32
  const MISSING_NAME = "__missing";
28
33
  const unescapeLeadingUnderscores = (name) => {
29
- if (name.startsWith(TRIPLE_UNDERSCORE)) return name.slice(1);
34
+ if (String$1.startsWith(TRIPLE_UNDERSCORE)(name)) return String$1.slice(1)(name);
30
35
  return name;
31
36
  };
32
37
  const escapeLeadingUnderscores$1 = (name) => {
33
- if (name.startsWith(DOUBLE_UNDERSCORE)) return `${UNDERSCORE}${name}`;
38
+ if (String$1.startsWith(DOUBLE_UNDERSCORE)(name)) return `${UNDERSCORE}${name}`;
34
39
  return name;
35
40
  };
36
- const createSymbol = (flags, escapedName) => ({
41
+ const createSymbol = Function.dual(DATA_FIRST_ARITY$35, (flags, escapedName) => ({
37
42
  flags,
38
43
  escapedName,
39
44
  name: unescapeLeadingUnderscores(escapedName)
40
- });
45
+ }));
41
46
  const isInJsFileNode = (node) => {
42
47
  let current = node;
43
48
  while (!isSourceFile(current)) current = current.parent;
@@ -57,10 +62,10 @@ const isAmbientOverride = (existing, node) => isAmbientNode(node) && !isInJsFile
57
62
  const replacesAssignmentDeclaration = (existing, node) => !isAmbientOverride(existing, node) && isAssignmentDeclarationNode(existing) && !isAssignmentDeclarationNode(node);
58
63
  const replacesModuleDeclaration = (existing, node) => existing.kind !== node.kind && isEffectiveModuleDeclaration(existing);
59
64
  const replacesValueDeclaration = (existing, node) => replacesAssignmentDeclaration(existing, node) || replacesModuleDeclaration(existing, node);
60
- const setValueDeclaration = (symbol, node) => {
65
+ const setValueDeclaration = Function.dual(DATA_FIRST_ARITY$35, (symbol, node) => {
61
66
  const existing = symbol.valueDeclaration;
62
67
  if (Predicate.isUndefined(existing) || replacesValueDeclaration(existing, node)) symbol.valueDeclaration = node;
63
- };
68
+ });
64
69
  const EXPORT_TABLE_FLAGS = combineFlags(SymbolFlags.Class, SymbolFlags.Enum, SymbolFlags.Module, SymbolFlags.Variable);
65
70
  const MEMBER_TABLE_FLAGS = combineFlags(SymbolFlags.Class, SymbolFlags.Interface, SymbolFlags.TypeLiteral, SymbolFlags.ObjectLiteral);
66
71
  const recordDeclaration = (symbol, node) => {
@@ -75,13 +80,15 @@ const DECLARATION_EFFECTS = [
75
80
  [MEMBER_TABLE_FLAGS, (symbol) => {
76
81
  symbol.members ??= /* @__PURE__ */ new Map();
77
82
  }],
78
- [SymbolFlags.Value, setValueDeclaration]
83
+ [SymbolFlags.Value, (symbol, node) => {
84
+ setValueDeclaration(symbol, node);
85
+ }]
79
86
  ];
80
- const addDeclarationToSymbol = (symbol, node, flags) => {
87
+ const addDeclarationToSymbol = Function.dual(DATA_FIRST_ARITY_3$22, (symbol, node, flags) => {
81
88
  symbol.flags = withFlags(symbol.flags, flags);
82
89
  recordDeclaration(symbol, node);
83
90
  for (const [required, apply] of DECLARATION_EFFECTS) if (hasFlag(flags, required)) apply(symbol, node);
84
- };
91
+ });
85
92
  const conflicts = (found, declaration) => hasFlag(found.flags, declaration.excludes) && !(hasFlag(declaration.includes, SymbolFlags.Variable) && hasFlag(found.flags, SymbolFlags.Assignment));
86
93
  const symbolInTable = (table, name, declaration) => {
87
94
  const found = table.get(name);
@@ -93,7 +100,7 @@ const symbolInTable = (table, name, declaration) => {
93
100
  if (conflicts(found, declaration)) return createSymbol(0, name);
94
101
  return found;
95
102
  };
96
- const exportOf = (owner, name) => Option.flatMap(Option.fromNullishOr(owner.exports), (table) => Option.fromNullishOr(table.get(name)));
103
+ const exportOf = Function.dual(DATA_FIRST_ARITY$35, (owner, name) => Option.flatMap(Option.fromNullishOr(owner.exports), (table) => Option.fromNullishOr(table.get(name))));
97
104
  const declareSymbol = (declaration) => {
98
105
  const symbol = Option.getOrElse(Option.zipWith(declaration.table, declaration.name, (table, name) => symbolInTable(table, name, declaration)), () => createSymbol(0, MISSING_NAME));
99
106
  addDeclarationToSymbol(symbol, declaration.node, declaration.includes);
@@ -101,6 +108,7 @@ const declareSymbol = (declaration) => {
101
108
  return symbol;
102
109
  };
103
110
  // src/attw/binder-syntax.ts
111
+ const DATA_FIRST_ARITY$34 = 2;
104
112
  const REQUIRE_ARGUMENTS = 1;
105
113
  const DEFINE_PROPERTY_ARGUMENTS = 3;
106
114
  const ZERO_TEXT = "0";
@@ -127,7 +135,7 @@ const isStaticAccess = (node) => isPropertyAccessExpression(node) || isLiteralLi
127
135
  const hasStaticName = (node) => !isPropertyAccessExpression(node) || isIdentifier(node.name);
128
136
  const isAllowedThis = (node, rules) => !rules.excludeThisKeyword && isThisKeyword(node);
129
137
  const hasBindableOwner = (node, rules, isBindable) => isAllowedThis(node.expression, rules) || hasStaticName(node) && isBindable(node.expression, STATIC_NAME);
130
- const isBindableStatic = (node, rules) => isAllowedEntityName(node, rules) || isStaticAccess(node) && hasBindableOwner(node, rules, isBindableStatic);
138
+ const isBindableStatic = Function.dual(DATA_FIRST_ARITY$34, (node, rules) => isAllowedEntityName(node, rules) || isStaticAccess(node) && hasBindableOwner(node, rules, isBindableStatic));
131
139
  const nameText = (node) => {
132
140
  if (isIdentifier(node) || isStringOrNumericLiteralLike(node)) return Option.some(node.text);
133
141
  return Option.none();
@@ -136,14 +144,14 @@ const getElementOrPropertyAccessName = (node) => {
136
144
  if (isPropertyAccessExpression(node)) return nameText(node.name).pipe(Option.map(escapeLeadingUnderscores$1));
137
145
  return Option.liftPredicate(skipParentheses(node.argumentExpression), isStringOrNumericLiteralLike).pipe(Option.map((literal) => escapeLeadingUnderscores$1(literal.text)));
138
146
  };
139
- const isNamedIdentifier = (node, name) => isIdentifier(node) && node.text === name;
147
+ const isNamedIdentifier = Function.dual(DATA_FIRST_ARITY$34, (node, name) => isIdentifier(node) && node.text === name);
140
148
  const isExportsIdentifier = (node) => isIdentifier(node) && node.text === "exports";
141
149
  const isModuleExportsAccessExpression = (node) => (isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node)) && isNamedIdentifier(node.expression, "module") && Option.contains(getElementOrPropertyAccessName(node), "exports");
142
150
  const hasRequireArgument = (node, requireStringLiteral) => {
143
151
  const [argument] = node.arguments;
144
152
  return node.arguments.length === REQUIRE_ARGUMENTS && (!requireStringLiteral || Option.fromNullishOr(argument).pipe(Option.exists((value) => isStringLiteralLikeNode(value))));
145
153
  };
146
- const isRequireCall$1 = (node, requireStringLiteral) => isCallExpression(node) && isNamedIdentifier(node.expression, "require") && hasRequireArgument(node, requireStringLiteral);
154
+ const isRequireCall$1 = Function.dual(DATA_FIRST_ARITY$34, (node, requireStringLiteral) => isCallExpression(node) && isNamedIdentifier(node.expression, "require") && hasRequireArgument(node, requireStringLiteral));
147
155
  const isAssignmentExpression = (node) => isBinaryExpression(node) && node.operatorToken.kind === SyntaxKind.EqualsToken;
148
156
  const getRightMostAssignedExpression = (node) => {
149
157
  let current = node;
@@ -164,6 +172,7 @@ const isBindableObjectDefinePropertyCall = (node) => {
164
172
  };
165
173
  const isAliasableExpression = (node) => isEntityNameExpression(node) || node.kind === SyntaxKind.ClassExpression;
166
174
  // src/attw/binder-assignment.ts
175
+ const DATA_FIRST_ARITY$33 = 2;
167
176
  const AssignmentKind = {
168
177
  None: "None",
169
178
  ExportsProperty: "ExportsProperty",
@@ -197,7 +206,7 @@ const leftmostAccess = (node) => {
197
206
  return current;
198
207
  };
199
208
  const isExportsTarget = (nextToLast) => isNamedIdentifier(nextToLast.expression, "exports") || isNamedIdentifier(nextToLast.expression, "module") && Option.contains(getElementOrPropertyAccessName(nextToLast), "exports");
200
- const firstMatchingKind = (rules, subject) => Option.fromNullishOr(rules.find(([matches]) => matches(subject))).pipe(Option.map(([, kind]) => kind), Option.getOrElse(() => AssignmentKind.None));
209
+ const firstMatchingKind = (rules, subject) => Array$1.findFirst(rules, ([matches]) => matches(subject)).pipe(Option.map(([, kind]) => kind), Option.getOrElse(() => AssignmentKind.None));
201
210
  const isExportsProperty = (left) => isExportsTarget(leftmostAccess(left)) && isBindableStatic(left, STATIC_ACCESS);
202
211
  const isNamedProperty = (left) => isBindableStatic(left, STATIC_NAME) || isDynamicElementAccess(left);
203
212
  const STATIC_NAME_KINDS = [
@@ -225,7 +234,7 @@ const accessAssignmentKind = (node, left) => {
225
234
  return propertyAccessKind(left);
226
235
  };
227
236
  const binaryAssignmentKind = (node) => assignedAccess(node).pipe(Option.map((left) => accessAssignmentKind(node, left)), Option.getOrElse(() => AssignmentKind.None));
228
- const getAssignmentDeclarationKind = (node, inJsFile) => {
237
+ const getAssignmentDeclarationKind = Function.dual(DATA_FIRST_ARITY$33, (node, inJsFile) => {
229
238
  const kind = Option.match(Option.liftPredicate(node, isCallExpression), {
230
239
  onNone: () => Option.match(Option.liftPredicate(node, isBinaryExpression), {
231
240
  onNone: () => AssignmentKind.None,
@@ -235,8 +244,9 @@ const getAssignmentDeclarationKind = (node, inJsFile) => {
235
244
  });
236
245
  if (kind === AssignmentKind.Property || inJsFile) return kind;
237
246
  return AssignmentKind.None;
238
- };
247
+ });
239
248
  // src/attw/binder-names.ts
249
+ const DATA_FIRST_ARITY$32 = 2;
240
250
  const isNodeValue = (value) => Predicate.hasProperty(value, "kind") && Predicate.isNumber(value.kind);
241
251
  const declaredName = (node) => {
242
252
  if ("name" in node && isNodeValue(node.name)) return Option.some(node.name);
@@ -246,7 +256,7 @@ const syntacticModifierFlags = (node) => {
246
256
  if ("modifierFlags" in node && Predicate.isNumber(node.modifierFlags)) return node.modifierFlags;
247
257
  return 0;
248
258
  };
249
- const hasSyntacticModifier = (node, flag) => hasFlag(syntacticModifierFlags(node), flag);
259
+ const hasSyntacticModifier = Function.dual(DATA_FIRST_ARITY$32, (node, flag) => hasFlag(syntacticModifierFlags(node), flag));
250
260
  const declarationOfBinding$1 = (node) => {
251
261
  let current = node;
252
262
  while (isBindingElement(current)) current = current.parent.parent;
@@ -302,7 +312,7 @@ const unnamedDeclarationName = (node) => {
302
312
  if (node.kind === SyntaxKind.SourceFile || node.kind === SyntaxKind.BinaryExpression) return Option.some("export=");
303
313
  return Option.none();
304
314
  };
305
- const declarationName = (node, inJsFile) => {
315
+ const declarationName = Function.dual(DATA_FIRST_ARITY$32, (node, inJsFile) => {
306
316
  if (isExportAssignment(node)) return Option.some(Option.match(Option.liftPredicate(node, () => node.isExportEquals), {
307
317
  onNone: () => "default",
308
318
  onSome: () => "export="
@@ -311,8 +321,9 @@ const declarationName = (node, inJsFile) => {
311
321
  onNone: () => unnamedDeclarationName(node),
312
322
  onSome: (name) => nameOfNamedDeclaration(node, name)
313
323
  });
314
- };
324
+ });
315
325
  // src/attw/messages.ts
326
+ const DATA_FIRST_ARITY$31 = 2;
316
327
  const Messages = {
317
328
  directoryDoesNotExist: "Directory '{0}' does not exist, skipping all lookups in it.",
318
329
  directoryHasNoPackageScope: "Directory '{0}' has no containing package.json scope. Imports will not resolve.",
@@ -368,19 +379,29 @@ const Messages = {
368
379
  packageJsonInvalidTarget: "package.json scope '{0}' has invalid type for target of specifier '{1}'",
369
380
  packageJsonNoImports: "package.json scope '{0}' has no imports defined."
370
381
  };
371
- const PLACEHOLDER = /\{(?<index>\d+)\}/gu;
372
- const formatMessage = (message, ...args) => message.replaceAll(PLACEHOLDER, (placeholder, index) => args[Number(index)] ?? placeholder);
373
- const emitTrace = (trace, message) => {
374
- for (const sink of Option.toArray(trace)) sink(message);
382
+ const PLACEHOLDER = /\{(?<index>\d+)\}/u;
383
+ const PLACEHOLDER_STEP = 2;
384
+ const TEXT_PART = 0;
385
+ const filled = (args) => (part, position) => {
386
+ if (position % PLACEHOLDER_STEP === TEXT_PART) return part;
387
+ return args[Number(part)] ?? `{${part}}`;
375
388
  };
389
+ const formatMessage = (message, ...args) => pipe(String$1.split(message, PLACEHOLDER), Array$1.map(filled(args)), Array$1.join(""));
390
+ const emitTrace = Function.dual(DATA_FIRST_ARITY$31, (trace, message) => {
391
+ for (const sink of Option.toArray(trace)) sink(message);
392
+ });
376
393
  const traceMessage = (state, message, ...args) => {
377
394
  emitTrace(state.trace, formatMessage(message, ...args));
378
395
  };
396
+ // src/attw/text-search.ts
397
+ const DATA_FIRST_ARITY_3$21 = 3;
398
+ const START$6 = 0;
399
+ const indexFrom = Function.dual(DATA_FIRST_ARITY_3$21, (text, search, from) => Option.map(String$1.indexOf(search)(String$1.slice(from)(text)), (found) => found + from));
400
+ const lastIndexUpTo = Function.dual(DATA_FIRST_ARITY_3$21, (text, search, position) => String$1.lastIndexOf(search)(String$1.slice(START$6, Math.max(position, START$6) + search.length)(text)));
379
401
  // src/attw/path-roots.ts
380
- const FIRST$1 = 0;
402
+ const FIRST$2 = 0;
381
403
  const NEXT$2 = 1;
382
404
  const AFTER_NEXT = 2;
383
- const NOT_FOUND$6 = -1;
384
405
  const DOS_ROOT_LENGTH = 3;
385
406
  const DOS_DRIVE_LENGTH = 2;
386
407
  const ENCODED_SEPARATOR_LENGTH = 3;
@@ -394,7 +415,7 @@ const ENCODED_VOLUME_SEPARATOR = /^%3[Aa]/u;
394
415
  const FILE_SCHEME = "file";
395
416
  const LOCAL_AUTHORITIES = /* @__PURE__ */ new Set(["", "localhost"]);
396
417
  const RELATIVE = {
397
- length: FIRST$1,
418
+ length: FIRST$2,
398
419
  isUrl: false
399
420
  };
400
421
  const diskRoot = (length) => ({
@@ -408,9 +429,10 @@ const urlRoot = (length) => ({
408
429
  const isVolumeCharacter = (character) => Predicate.isNotUndefined(character) && VOLUME_CHARACTER.test(character);
409
430
  const posixOrUncRoot = (path, separator) => {
410
431
  if (path[NEXT$2] !== separator) return diskRoot(NEXT$2);
411
- const serverEnd = path.indexOf(separator, AFTER_NEXT);
412
- if (serverEnd === NOT_FOUND$6) return diskRoot(path.length);
413
- return diskRoot(serverEnd + NEXT$2);
432
+ return Option.match(indexFrom(path, separator, AFTER_NEXT), {
433
+ onNone: () => diskRoot(path.length),
434
+ onSome: (serverEnd) => diskRoot(serverEnd + NEXT$2)
435
+ });
414
436
  };
415
437
  const dosRoot = (path) => {
416
438
  if (DOS_ROOT.test(path)) return Option.some(diskRoot(DOS_ROOT_LENGTH));
@@ -418,39 +440,41 @@ const dosRoot = (path) => {
418
440
  };
419
441
  const fileUrlVolumeSeparatorEnd = (url, start) => {
420
442
  if (url[start] === ":") return Option.some(start + NEXT$2);
421
- return Option.liftPredicate(start + ENCODED_SEPARATOR_LENGTH, () => ENCODED_VOLUME_SEPARATOR.test(url.slice(start)));
443
+ return Option.liftPredicate(start + ENCODED_SEPARATOR_LENGTH, () => ENCODED_VOLUME_SEPARATOR.test(String$1.slice(start)(url)));
422
444
  };
423
445
  const fileUrlVolumeRoot = (url, authorityEnd) => fileUrlVolumeSeparatorEnd(url, authorityEnd + AFTER_NEXT).pipe(Option.flatMap((end) => {
424
446
  if (url[end] === SLASH) return Option.some(urlRoot(end + NEXT$2));
425
447
  return Option.liftPredicate(urlRoot(end), () => end === url.length);
426
448
  }));
427
- const isLocalFileUrl = (url, schemeEnd, authorityEnd) => url.slice(FIRST$1, schemeEnd) === FILE_SCHEME && LOCAL_AUTHORITIES.has(url.slice(schemeEnd + 3, authorityEnd)) && isVolumeCharacter(url[authorityEnd + NEXT$2]);
428
- const urlRootOf = (url, schemeEnd) => {
429
- const authorityEnd = url.indexOf(SLASH, schemeEnd + 3);
430
- if (authorityEnd === NOT_FOUND$6) return urlRoot(url.length);
449
+ const isLocalFileUrl = (url, schemeEnd, authorityEnd) => String$1.slice(FIRST$2, schemeEnd)(url) === FILE_SCHEME && LOCAL_AUTHORITIES.has(String$1.slice(schemeEnd + 3, authorityEnd)(url)) && isVolumeCharacter(url[authorityEnd + NEXT$2]);
450
+ const urlRootAt = (url, schemeEnd, authorityEnd) => {
431
451
  const volume = Option.liftPredicate(url, () => isLocalFileUrl(url, schemeEnd, authorityEnd)).pipe(Option.flatMap(() => fileUrlVolumeRoot(url, authorityEnd)));
432
452
  return Option.getOrElse(volume, () => urlRoot(authorityEnd + NEXT$2));
433
453
  };
454
+ const urlRootOf = (url, schemeEnd) => Option.match(indexFrom(url, SLASH, schemeEnd + 3), {
455
+ onNone: () => urlRoot(url.length),
456
+ onSome: (authorityEnd) => urlRootAt(url, schemeEnd, authorityEnd)
457
+ });
434
458
  const getPathRoot = (path) => {
435
459
  const [first] = path;
436
460
  if (first === SLASH || first === BACKSLASH) return posixOrUncRoot(path, first);
437
- return dosRoot(path).pipe(Option.getOrElse(() => {
438
- const schemeEnd = path.indexOf(SCHEME_SEPARATOR);
439
- if (schemeEnd === NOT_FOUND$6) return RELATIVE;
440
- return urlRootOf(path, schemeEnd);
441
- }));
461
+ return dosRoot(path).pipe(Option.getOrElse(() => Option.match(String$1.indexOf(SCHEME_SEPARATOR)(path), {
462
+ onNone: () => RELATIVE,
463
+ onSome: (schemeEnd) => urlRootOf(path, schemeEnd)
464
+ })));
442
465
  };
443
466
  const getRootLength = (path) => getPathRoot(path).length;
444
467
  const isRootedDiskPath = (path) => {
445
468
  const root = getPathRoot(path);
446
- return root.length > FIRST$1 && !root.isUrl;
469
+ return root.length > FIRST$2 && !root.isUrl;
447
470
  };
448
471
  // src/attw/paths.ts
472
+ const DATA_FIRST_ARITY$30 = 2;
449
473
  const SEPARATOR$1 = "/";
450
474
  const ROOT_LENGTH$1 = 1;
451
- const NOT_FOUND$5 = -1;
452
- const FIRST = 0;
453
- const SECOND$1 = 1;
475
+ const NOT_FOUND$1 = -1;
476
+ const FIRST$1 = 0;
477
+ const SECOND$2 = 1;
454
478
  const PARENT = "..";
455
479
  const CURRENT = ".";
456
480
  const RELATIVE_SEGMENT = /\/\/|(?:^|\/)\.\.?(?:$|\/)/u;
@@ -461,37 +485,37 @@ const RELATIVE_PREFIXES = [
461
485
  "../",
462
486
  "..\\"
463
487
  ];
464
- const normalizeSlashes = (path) => path.replaceAll("\\", SEPARATOR$1);
465
- const hasTrailingDirectorySeparator = (path) => path.endsWith(SEPARATOR$1);
488
+ const normalizeSlashes = (path) => String$1.replaceAll("\\", SEPARATOR$1)(path);
489
+ const hasTrailingDirectorySeparator = (path) => String$1.endsWith(SEPARATOR$1)(path);
466
490
  const removeTrailingDirectorySeparator = (path) => Option.liftPredicate(path, hasTrailingDirectorySeparator).pipe(Option.match({
467
491
  onNone: () => path,
468
- onSome: (value) => value.slice(FIRST, NOT_FOUND$5)
492
+ onSome: (value) => String$1.slice(FIRST$1, NOT_FOUND$1)(value)
469
493
  }));
470
494
  const ensureTrailingDirectorySeparator = (path) => Option.liftPredicate(path, hasTrailingDirectorySeparator).pipe(Option.getOrElse(() => `${path}${SEPARATOR$1}`));
471
495
  const combineTwo = (base, next) => {
472
- if (next.length === FIRST) return base;
496
+ if (next.length === FIRST$1) return base;
473
497
  const relative = normalizeSlashes(next);
474
- if (base.length === FIRST || getRootLength(relative) !== FIRST) return relative;
498
+ if (base.length === FIRST$1 || getRootLength(relative) !== FIRST$1) return relative;
475
499
  return `${ensureTrailingDirectorySeparator(base)}${relative}`;
476
500
  };
477
501
  const combinePaths = (path, ...paths) => Array$1.reduce(paths, normalizeSlashes(path), combineTwo);
478
502
  const pathComponents = (path, rootLength) => {
479
- const rest = path.slice(rootLength).split(SEPARATOR$1);
503
+ const rest = String$1.split(String$1.slice(rootLength)(path), SEPARATOR$1);
480
504
  const trimmed = Option.liftPredicate(rest, (parts) => Array$1.last(parts).pipe(Option.contains("")));
481
- return [path.slice(FIRST, rootLength), ...Option.match(trimmed, {
505
+ return [String$1.slice(FIRST$1, rootLength)(path), ...Option.match(trimmed, {
482
506
  onNone: () => rest,
483
- onSome: (parts) => parts.slice(FIRST, NOT_FOUND$5)
507
+ onSome: (parts) => parts.slice(FIRST$1, NOT_FOUND$1)
484
508
  })];
485
509
  };
486
510
  const getPathComponents = (path) => {
487
511
  const normalized = normalizeSlashes(path);
488
512
  return pathComponents(normalized, getRootLength(normalized));
489
513
  };
490
- const isNoopComponent = (component) => component.length === FIRST || component === CURRENT;
491
- const canPopParent = (reduced) => reduced.length > SECOND$1 && Array$1.last(reduced).pipe(Option.exists((last) => last !== PARENT));
492
- const keepsParent = (reduced) => reduced.length > SECOND$1 || reduced[FIRST] === "";
514
+ const isNoopComponent = (component) => component.length === FIRST$1 || component === CURRENT;
515
+ const canPopParent = (reduced) => reduced.length > SECOND$2 && Array$1.last(reduced).pipe(Option.exists((last) => last !== PARENT));
516
+ const keepsParent = (reduced) => reduced.length > SECOND$2 || reduced[FIRST$1] === "";
493
517
  const applyParent = (reduced, component) => {
494
- if (canPopParent(reduced)) return reduced.slice(FIRST, NOT_FOUND$5);
518
+ if (canPopParent(reduced)) return reduced.slice(FIRST$1, NOT_FOUND$1);
495
519
  if (keepsParent(reduced)) return [...reduced, component];
496
520
  return reduced;
497
521
  };
@@ -509,16 +533,16 @@ const getPathFromPathComponents = (components) => Array$1.match(components, {
509
533
  onNonEmpty: ([root, ...rest]) => `${Option.liftPredicate(root, String$1.isNonEmpty).pipe(Option.match({
510
534
  onNone: () => "",
511
535
  onSome: ensureTrailingDirectorySeparator
512
- }))}${rest.join(SEPARATOR$1)}`
536
+ }))}${pipe(rest, Array$1.join(SEPARATOR$1))}`
513
537
  });
514
538
  const normalizeComponents = (path) => {
515
539
  const normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path)));
516
- return Option.liftPredicate(normalized, (value) => value.length > FIRST && hasTrailingDirectorySeparator(path)).pipe(Option.match({
540
+ return Option.liftPredicate(normalized, (value) => value.length > FIRST$1 && hasTrailingDirectorySeparator(path)).pipe(Option.match({
517
541
  onNone: () => normalized,
518
542
  onSome: ensureTrailingDirectorySeparator
519
543
  }));
520
544
  };
521
- const simplifyCurrentSegments = (path) => path.replaceAll("/./", SEPARATOR$1).replace(/^\.\//u, "");
545
+ const simplifyCurrentSegments = (path) => String$1.replace(/^\.\//u, "")(String$1.replaceAll("/./", SEPARATOR$1)(path));
522
546
  const normalizePath = (path) => {
523
547
  const slashed = normalizeSlashes(path);
524
548
  if (!RELATIVE_SEGMENT.test(slashed)) return slashed;
@@ -531,23 +555,32 @@ const getDirectoryPath = (path) => {
531
555
  const rootLength = getRootLength(slashed);
532
556
  if (rootLength === slashed.length) return slashed;
533
557
  const trimmed = removeTrailingDirectorySeparator(slashed);
534
- return trimmed.slice(FIRST, Math.max(rootLength, trimmed.lastIndexOf(SEPARATOR$1)));
558
+ const end = Option.match(String$1.lastIndexOf(SEPARATOR$1)(trimmed), {
559
+ onNone: () => rootLength,
560
+ onSome: (separator) => Math.max(rootLength, separator)
561
+ });
562
+ return String$1.slice(FIRST$1, end)(trimmed);
535
563
  };
536
564
  const getBaseFileName = (path) => {
537
565
  const slashed = normalizeSlashes(path);
538
566
  if (getRootLength(slashed) === slashed.length) return "";
539
567
  const trimmed = removeTrailingDirectorySeparator(slashed);
540
- return trimmed.slice(Math.max(getRootLength(trimmed), trimmed.lastIndexOf(SEPARATOR$1) + ROOT_LENGTH$1));
568
+ const rootLength = getRootLength(trimmed);
569
+ const start = Option.match(String$1.lastIndexOf(SEPARATOR$1)(trimmed), {
570
+ onNone: () => rootLength,
571
+ onSome: (separator) => Math.max(rootLength, separator + ROOT_LENGTH$1)
572
+ });
573
+ return String$1.slice(start)(trimmed);
541
574
  };
542
- const getNormalizedAbsolutePath = (path, currentDirectory) => {
575
+ const getNormalizedAbsolutePath = Function.dual(DATA_FIRST_ARITY$30, (path, currentDirectory) => {
543
576
  const components = getPathComponents(combinePaths(currentDirectory, path));
544
577
  return getPathFromPathComponents(reducePathComponents(components));
545
- };
578
+ });
546
579
  const toPath = (fileName) => Option.liftPredicate(fileName, isRootedDiskPath).pipe(Option.match({
547
580
  onNone: () => getNormalizedAbsolutePath(fileName, SEPARATOR$1),
548
581
  onSome: normalizePath
549
582
  }), String$1.toLowerCase);
550
- const forEachAncestorDirectory$1 = (directory, visit) => {
583
+ const forEachAncestorDirectory$1 = Function.dual(DATA_FIRST_ARITY$30, (directory, visit) => {
551
584
  let current = directory;
552
585
  for (;;) {
553
586
  const result = visit(current);
@@ -555,53 +588,40 @@ const forEachAncestorDirectory$1 = (directory, visit) => {
555
588
  if (Option.isSome(result) || parent === current) return result;
556
589
  current = parent;
557
590
  }
558
- };
559
- const pathIsRelative = (path) => RELATIVE_NAMES.has(path) || RELATIVE_PREFIXES.some((prefix) => path.startsWith(prefix));
591
+ });
592
+ const pathIsRelative = (path) => RELATIVE_NAMES.has(path) || pipe(RELATIVE_PREFIXES, Array$1.some((prefix) => String$1.startsWith(prefix)(path)));
560
593
  const isExternalModuleNameRelative = (moduleName) => pathIsRelative(moduleName) || isRootedDiskPath(moduleName);
561
594
  const sharedPrefixLength = (from, to) => {
562
595
  const limit = Math.min(from.length, to.length);
563
- let index = FIRST;
596
+ let index = FIRST$1;
564
597
  while (index < limit && from[index] === to[index]) index += ROOT_LENGTH$1;
565
598
  return index;
566
599
  };
567
- const getRelativePathFromDirectory = (fromDirectory, to) => {
600
+ const getRelativePathFromDirectory = Function.dual(DATA_FIRST_ARITY$30, (fromDirectory, to) => {
568
601
  const from = reducePathComponents(getPathComponents(fromDirectory));
569
602
  const target = reducePathComponents(getPathComponents(to));
570
603
  const start = sharedPrefixLength(from, target);
571
- if (start === FIRST) return getPathFromPathComponents(target);
604
+ if (start === FIRST$1) return getPathFromPathComponents(target);
572
605
  return getPathFromPathComponents([
573
606
  "",
574
607
  ...Array.from({ length: from.length - start }, () => PARENT),
575
608
  ...target.slice(start)
576
609
  ]);
577
- };
578
- const containsPath = (parent, child) => {
610
+ });
611
+ const containsPath = Function.dual(DATA_FIRST_ARITY$30, (parent, child) => {
579
612
  const parentComponents = reducePathComponents(getPathComponents(parent));
580
613
  const childComponents = reducePathComponents(getPathComponents(child));
581
614
  return parent === child || childComponents.length >= parentComponents.length && sharedPrefixLength(parentComponents, childComponents) === parentComponents.length;
582
- };
583
- const compareStrings = (left, right) => Math.sign(Number(left > right) - Number(left < right));
584
- const compareCaseInsensitive = (left, right) => compareStrings(left.toUpperCase(), right.toUpperCase());
585
- const compareComponents = (left, right) => {
586
- return Array$1.zip(left, right).slice(SECOND$1).map(([leftComponent, rightComponent]) => compareCaseInsensitive(leftComponent, rightComponent)).find((result) => result !== FIRST) ?? Math.sign(left.length - right.length);
587
- };
588
- const compareRests = (left, right) => {
589
- if (!RELATIVE_SEGMENT.test(left) && !RELATIVE_SEGMENT.test(right)) return compareCaseInsensitive(left, right);
590
- return compareComponents(reducePathComponents(getPathComponents(left)), reducePathComponents(getPathComponents(right)));
591
- };
592
- const comparePathsCaseInsensitive = (left, right) => {
593
- const leftRoot = left.slice(FIRST, getRootLength(left));
594
- const rightRoot = right.slice(FIRST, getRootLength(right));
595
- return Option.liftPredicate(compareCaseInsensitive(leftRoot, rightRoot), (result) => result !== FIRST).pipe(Option.getOrElse(() => compareRests(left.slice(leftRoot.length), right.slice(rightRoot.length))));
596
- };
615
+ });
597
616
  // src/attw/package-json-fields.ts
617
+ const DATA_FIRST_ARITY_3$20 = 3;
598
618
  const EMPTY$6 = 0;
599
619
  const typeName = (value) => {
600
620
  if (Predicate.isNull(value)) return "null";
601
621
  return typeof value;
602
622
  };
603
- const resolvePackageJsonFieldWithTrace = (content, { field, expected }, state) => {
604
- if (!Object.hasOwn(content, field)) {
623
+ const resolvePackageJsonFieldWithTrace = Function.dual(DATA_FIRST_ARITY_3$20, (content, { field, expected }, state) => {
624
+ if (!Record.has(content, field)) {
605
625
  traceMessage(state, Messages.packageJsonMissingField, field);
606
626
  return Option.none();
607
627
  }
@@ -611,7 +631,7 @@ const resolvePackageJsonFieldWithTrace = (content, { field, expected }, state) =
611
631
  return Option.none();
612
632
  }
613
633
  return Option.some(value);
614
- };
634
+ });
615
635
  const resolvePathWithTrace = (fileName, { field, baseDirectory }, state) => {
616
636
  if (fileName.length === EMPTY$6) {
617
637
  traceMessage(state, Messages.packageJsonFalsyField, field);
@@ -625,19 +645,20 @@ const resolvePackageJsonPathWithTrace = (content, request, state) => resolvePack
625
645
  field: request.field,
626
646
  expected: "string"
627
647
  }, state).pipe(Option.filter((value) => Predicate.isString(value)), Option.flatMap((fileName) => resolvePathWithTrace(fileName, request, state)));
628
- const readPackageJsonTypesFields = (content, baseDirectory, state) => resolvePackageJsonPathWithTrace(content, {
648
+ const readPackageJsonTypesFields = Function.dual(DATA_FIRST_ARITY_3$20, (content, baseDirectory, state) => resolvePackageJsonPathWithTrace(content, {
629
649
  field: "typings",
630
650
  baseDirectory
631
651
  }, state).pipe(Option.orElse(() => resolvePackageJsonPathWithTrace(content, {
632
652
  field: "types",
633
653
  baseDirectory
634
- }, state)));
635
- const readPackageJsonMainField = (content, baseDirectory, state) => resolvePackageJsonPathWithTrace(content, {
654
+ }, state))));
655
+ const readPackageJsonMainField = Function.dual(DATA_FIRST_ARITY_3$20, (content, baseDirectory, state) => resolvePackageJsonPathWithTrace(content, {
636
656
  field: "main",
637
657
  baseDirectory
638
- }, state);
658
+ }, state));
639
659
  const asRecord = (value) => Option.liftPredicate(value, Predicate.isObject).pipe(Option.getOrElse(() => ({})));
640
660
  // src/attw/types-versions.ts
661
+ const DATA_FIRST_ARITY$29 = 2;
641
662
  const RESOLUTION_VERSION = "5.6.1-rc";
642
663
  const RESOLUTION_VERSION_MAJOR_MINOR = "5.6";
643
664
  const RANGE_OPTIONS$1 = { includePrerelease: true };
@@ -671,8 +692,10 @@ const resolveTypesVersionPathsWithTrace = (content, state) => resolvePackageJson
671
692
  field: "typesVersions",
672
693
  expected: "object"
673
694
  }, state).pipe(Option.flatMap((typesVersions) => selectVersionPathsWithTrace(asRecord(typesVersions), state)));
674
- const getVersionPaths = (info, state) => info.contents.versionPaths(() => resolveTypesVersionPathsWithTrace(info.contents.packageJsonContent, state));
695
+ const getVersionPaths = Function.dual(DATA_FIRST_ARITY$29, (info, state) => info.contents.versionPaths(() => resolveTypesVersionPathsWithTrace(info.contents.packageJsonContent, state)));
675
696
  // src/attw/binder-declarations.ts
697
+ const DATA_FIRST_ARITY$28 = 2;
698
+ const DATA_FIRST_ARITY_3$19 = 3;
676
699
  const DEFAULT_NAME = "default";
677
700
  const exportsOf = (owner) => ({
678
701
  table: owner.pipe(Option.flatMap((symbol) => Option.fromNullishOr(symbol.exports))),
@@ -685,7 +708,7 @@ const fileLocals = (binding) => ({
685
708
  });
686
709
  const isExportSpecifierNamedDefault = (node) => isExportSpecifier(node) && Option.contains(nameText(node.name), DEFAULT_NAME);
687
710
  const isDefaultExport = (request) => Option.isSome(request.target.parent) && (hasSyntacticModifier(request.node, ModifierFlags.Default) || isExportSpecifierNamedDefault(request.node));
688
- const declare = (binding, request) => {
711
+ const declare = Function.dual(DATA_FIRST_ARITY$28, (binding, request) => {
689
712
  const name = Option.orElse(Option.liftPredicate(DEFAULT_NAME, () => isDefaultExport(request)), () => declarationName(request.node, binding.isJs));
690
713
  return declareSymbol({
691
714
  table: request.target.table,
@@ -695,17 +718,17 @@ const declare = (binding, request) => {
695
718
  includes: request.flags.includes,
696
719
  excludes: request.flags.excludes
697
720
  });
698
- };
721
+ });
699
722
  const declareLocal = (binding, node, flags) => declare(binding, {
700
723
  target: fileLocals(binding),
701
724
  node,
702
725
  flags
703
726
  });
704
- const declareExport = (binding, node, flags) => declare(binding, {
727
+ const declareExport = Function.dual(DATA_FIRST_ARITY_3$19, (binding, node, flags) => declare(binding, {
705
728
  target: fileExports(binding),
706
729
  node,
707
730
  flags
708
- });
731
+ }));
709
732
  const isJSDocTypeAliasWithName = (node) => (isJSDocTypedefTag(node) || isJSDocCallbackTag(node)) && Predicate.isNotUndefined(node.name);
710
733
  const isExportedMember = (node) => hasExportModifier(node) || isJSDocTypeAliasWithName(node);
711
734
  const declareAlias = (binding, node, flags) => {
@@ -728,15 +751,17 @@ const declareModuleMember = (binding, node, flags) => {
728
751
  if (isExportedDeclaration(binding, node)) return declareExportedMember(binding, node, flags);
729
752
  return declareLocal(binding, node, flags);
730
753
  };
731
- const declareSourceFileMember = (binding, node, flags) => {
754
+ const declareSourceFileMember = Function.dual(DATA_FIRST_ARITY_3$19, (binding, node, flags) => {
732
755
  if (binding.isExternalModule) return declareModuleMember(binding, node, flags);
733
756
  return declareLocal(binding, node, flags);
734
- };
735
- const declareBlockScoped = (binding, node, flags) => {
757
+ });
758
+ const declareBlockScoped = Function.dual(DATA_FIRST_ARITY_3$19, (binding, node, flags) => {
736
759
  if (binding.isExternalModule || Predicate.isNotUndefined(binding.commonJsModuleIndicator)) return declareModuleMember(binding, node, flags);
737
760
  return declareLocal(binding, node, flags);
738
- };
761
+ });
739
762
  // src/attw/binder-cjs.ts
763
+ const DATA_FIRST_ARITY$27 = 2;
764
+ const DATA_FIRST_ARITY_3$18 = 3;
740
765
  const MAX_ALIAS_STEPS = 100;
741
766
  const ALIAS_STEP = 1;
742
767
  const EXTENSION = /\.[^./]*$/u;
@@ -750,15 +775,15 @@ const EXPORT_ALIAS$1 = {
750
775
  excludes: 0
751
776
  };
752
777
  const createFileSymbol = (binding) => {
753
- const symbol = createSymbol(0, `"${binding.file.fileName.replace(EXTENSION, "")}"`);
778
+ const symbol = createSymbol(0, `"${String$1.replace(EXTENSION, "")(binding.file.fileName)}"`);
754
779
  addDeclarationToSymbol(symbol, binding.file, SymbolFlags.ValueModule);
755
780
  binding.symbol = symbol;
756
781
  };
757
- const lookupSymbolForName = (binding, name) => {
782
+ const lookupSymbolForName = Function.dual(DATA_FIRST_ARITY$27, (binding, name) => {
758
783
  return Option.fromNullishOr(binding.locals.get(name)).pipe(Option.map((found) => found.exportSymbol ?? found)).pipe(Option.orElse(() => Option.fromNullishOr(binding.symbol).pipe(Option.flatMap((file) => exportOf(file, name)))));
759
- };
760
- const lookupIdentifier = (binding, node) => Option.flatMap(Option.liftPredicate(node, isIdentifier), (identifier) => lookupSymbolForName(binding, escapeLeadingUnderscores$1(identifier.text)));
761
- const variableInitializer = (binding, node) => lookupIdentifier(binding, node).pipe(Option.flatMap((symbol) => Option.fromNullishOr(symbol.valueDeclaration)), Option.filter(isVariableDeclaration), Option.flatMap((declaration) => Option.fromNullishOr(declaration.initializer)));
784
+ });
785
+ const lookupIdentifier = Function.dual(DATA_FIRST_ARITY$27, (binding, node) => Option.flatMap(Option.liftPredicate(node, isIdentifier), (identifier) => lookupSymbolForName(binding, escapeLeadingUnderscores$1(identifier.text))));
786
+ const variableInitializer = Function.dual(DATA_FIRST_ARITY$27, (binding, node) => lookupIdentifier(binding, node).pipe(Option.flatMap((symbol) => Option.fromNullishOr(symbol.valueDeclaration)), Option.filter(isVariableDeclaration), Option.flatMap((declaration) => Option.fromNullishOr(declaration.initializer))));
762
787
  const aliasSources = (binding, node) => variableInitializer(binding, node).pipe(Option.map((initializer) => Option.match(Option.liftPredicate(initializer, isAssignmentExpression), {
763
788
  onNone: () => [initializer],
764
789
  onSome: (assignment) => [
@@ -773,22 +798,22 @@ const searchExportsAlias = (binding, queue, steps) => {
773
798
  if (Predicate.isUndefined(next) || steps >= MAX_ALIAS_STEPS) return false;
774
799
  return isExportsReference(next) || searchExportsAlias(binding, [...rest, ...aliasSources(binding, next)], steps + ALIAS_STEP);
775
800
  };
776
- const isExportsOrModuleExportsOrAlias = (binding, node) => searchExportsAlias(binding, [node], 0);
777
- const setCommonJsModuleIndicator = (binding, node) => {
801
+ const isExportsOrModuleExportsOrAlias = Function.dual(DATA_FIRST_ARITY$27, (binding, node) => searchExportsAlias(binding, [node], 0));
802
+ const setCommonJsModuleIndicator = Function.dual(DATA_FIRST_ARITY$27, (binding, node) => {
778
803
  if (binding.isExternalModule) return false;
779
804
  if (Predicate.isUndefined(binding.commonJsModuleIndicator)) {
780
805
  binding.commonJsModuleIndicator = node;
781
806
  createFileSymbol(binding);
782
807
  }
783
808
  return true;
784
- };
809
+ });
785
810
  const accessNameOrArgument = (node) => {
786
811
  if (isPropertyAccessExpression(node)) return node.name;
787
812
  return node.argumentExpression;
788
813
  };
789
814
  const lookupInFileContainer = (binding, walk) => Option.liftPredicate(binding, () => walk.containerIsFile).pipe(Option.flatMap((bound) => lookupIdentifier(bound, walk.node)));
790
815
  const memberOfAccess = (node, parent) => getElementOrPropertyAccessName(node).pipe(Option.flatMap((key) => parent.pipe(Option.flatMap((symbol) => exportOf(symbol, key)))));
791
- const forEachIdentifierInEntityName = (binding, walk) => {
816
+ const forEachIdentifierInEntityName = Function.dual(DATA_FIRST_ARITY$27, (binding, walk) => {
792
817
  const { node } = walk;
793
818
  if (isExportsOrModuleExportsOrAlias(binding, node)) return Option.fromNullishOr(binding.symbol);
794
819
  if (isIdentifier(node)) return walk.action(node, lookupInFileContainer(binding, walk), Option.none());
@@ -798,7 +823,7 @@ const forEachIdentifierInEntityName = (binding, walk) => {
798
823
  node: node.expression
799
824
  });
800
825
  return walk.action(accessNameOrArgument(node), memberOfAccess(node, parent), parent);
801
- };
826
+ });
802
827
  const markModuleAssignment = (name, symbol) => symbol.pipe(Option.map((found) => {
803
828
  addDeclarationToSymbol(found, name, MODULE_ASSIGNMENT);
804
829
  return found;
@@ -808,7 +833,7 @@ const exportsPropertyFlags = (node) => {
808
833
  const isAlias = isAliasableExpression(node.right) && isAccessExpression(target) && (isExportsIdentifier(target.expression) || isModuleExportsAccessExpression(target.expression));
809
834
  return Option.getOrElse(Option.liftPredicate(EXPORT_ALIAS$1, () => isAlias), () => EXPORT_PROPERTY$1);
810
835
  };
811
- const bindExportsPropertyAssignment = (binding, node, scope) => {
836
+ const bindExportsPropertyAssignment = Function.dual(DATA_FIRST_ARITY_3$18, (binding, node, scope) => {
812
837
  const { left } = node;
813
838
  if (!setCommonJsModuleIndicator(binding, node) || !isAccessExpression(left)) return;
814
839
  const owner = forEachIdentifierInEntityName(binding, {
@@ -821,8 +846,8 @@ const bindExportsPropertyAssignment = (binding, node, scope) => {
821
846
  node: left,
822
847
  flags: exportsPropertyFlags(node)
823
848
  });
824
- };
825
- const bindObjectDefinePropertyExport = (binding, node, scope) => {
849
+ });
850
+ const bindObjectDefinePropertyExport = Function.dual(DATA_FIRST_ARITY_3$18, (binding, node, scope) => {
826
851
  const [target] = node.arguments;
827
852
  if (!setCommonJsModuleIndicator(binding, node) || Predicate.isUndefined(target)) return;
828
853
  const owner = forEachIdentifierInEntityName(binding, {
@@ -835,7 +860,7 @@ const bindObjectDefinePropertyExport = (binding, node, scope) => {
835
860
  node,
836
861
  flags: EXPORT_PROPERTY$1
837
862
  });
838
- };
863
+ });
839
864
  // src/attw/binder-scopes.ts
840
865
  const CONTAINER_KINDS = /* @__PURE__ */ new Set([
841
866
  SyntaxKind.ClassExpression,
@@ -905,6 +930,7 @@ const hasAncestor = (node, predicate) => {
905
930
  const containerIsFile = (node) => !hasAncestor(node, isContainer);
906
931
  const blockScopeIsFile = (node) => !hasAncestor(node, isBlockScopeContainer);
907
932
  // src/attw/binder-jsdoc.ts
933
+ const DATA_FIRST_ARITY$26 = 2;
908
934
  const TYPE_ALIAS = {
909
935
  includes: SymbolFlags.TypeAlias,
910
936
  excludes: SymbolFlags.TypeAliasExcludes
@@ -912,14 +938,14 @@ const TYPE_ALIAS = {
912
938
  const NO_TAGS = [];
913
939
  const isTypeAliasTag = (tag) => isJSDocTypedefTag(tag) || isJSDocCallbackTag(tag);
914
940
  const typeAliasTagsOf = (host) => pipe(host.jsDoc ?? [], Array$1.filter(isJSDoc), Array$1.flatMap((doc) => pipe(doc.tags ?? NO_TAGS, Array$1.filter(isTypeAliasTag))));
915
- const typeAliasTagSites = (hosts) => Array$1.dedupeWith(hosts.flatMap((host) => typeAliasTagsOf(host).map((tag) => ({
941
+ const typeAliasTagSites = (hosts) => Array$1.dedupeWith(pipe(hosts, Array$1.flatMap((host) => pipe(typeAliasTagsOf(host), Array$1.map((tag) => ({
916
942
  tag,
917
943
  host
918
- }))), (left, right) => left.tag.pos === right.tag.pos);
944
+ }))))), (left, right) => left.tag.pos === right.tag.pos);
919
945
  const declaresFileTypeAlias = (site) => Predicate.isNotUndefined(site.tag.name) && isIdentifier(site.tag.name) && containerIsFile(site.host) && blockScopeIsFile(site.host);
920
- const bindJSDocTypeAliases = (binding, hosts) => {
946
+ const bindJSDocTypeAliases = Function.dual(DATA_FIRST_ARITY$26, (binding, hosts) => {
921
947
  for (const site of typeAliasTagSites(hosts)) if (declaresFileTypeAlias(site)) declareBlockScoped(binding, site.tag, TYPE_ALIAS);
922
- };
948
+ });
923
949
  // src/attw/binder-expando-symbol.ts
924
950
  const EXPANDO_FLAGS = combineFlags(SymbolFlags.Function, SymbolFlags.Class, SymbolFlags.NamespaceModule);
925
951
  const isFunctionOrArrow = (node) => isFunctionExpression(node) || isArrowFunction(node);
@@ -954,6 +980,7 @@ const isExpandoSymbol = (symbol) => hasFlag(symbol.flags, EXPANDO_FLAGS) || Opti
954
980
  const isFunctionSymbol = (symbol) => symbol.pipe(Option.flatMap((found) => Option.fromNullishOr(found.valueDeclaration)), Option.exists((declaration) => isFunctionDeclaration(declaration) || isVariableDeclaration(declaration) && isFunctionLike(declaration.initializer)));
955
981
  const hasFunctionLikeExpandoInitializer = (declaration) => Option.exists(assignedExpandoInitializer(declaration), isFunctionOrArrow);
956
982
  // src/attw/binder-expando.ts
983
+ const DATA_FIRST_ARITY_3$17 = 3;
957
984
  const DESCRIPTOR_ARGUMENT = 2;
958
985
  const NAMESPACE_FLAGS = {
959
986
  includes: combineFlags(SymbolFlags.Module, SymbolFlags.Assignment),
@@ -1000,17 +1027,17 @@ const bindMissingNamespaces = (binding, entityName) => forEachIdentifierInEntity
1000
1027
  const descriptorPropertyNames = (call) => {
1001
1028
  const descriptor = call.arguments[DESCRIPTOR_ARGUMENT];
1002
1029
  if (Predicate.isUndefined(descriptor) || !isObjectLiteralExpression(descriptor)) return [];
1003
- return descriptor.properties.flatMap((property) => {
1030
+ return pipe(descriptor.properties, Array$1.flatMap((property) => {
1004
1031
  if ("name" in property && isIdentifier(property.name)) return [property.name.text];
1005
1032
  return [];
1006
- });
1033
+ }));
1007
1034
  };
1008
1035
  const accessorFlags = (call) => {
1009
1036
  const names = descriptorPropertyNames(call);
1010
- const matched = ACCESSOR_FLAGS.filter(([name]) => names.includes(name)).map(([, flags]) => flags);
1037
+ const matched = pipe(ACCESSOR_FLAGS, Array$1.filter(([name]) => names.includes(name)), Array$1.map(([, flags]) => flags));
1011
1038
  return {
1012
- includes: combineFlags(...matched.map((flags) => flags.includes)),
1013
- excludes: combineFlags(...matched.map((flags) => flags.excludes))
1039
+ includes: combineFlags(...pipe(matched, Array$1.map((flags) => flags.includes))),
1040
+ excludes: combineFlags(...pipe(matched, Array$1.map((flags) => flags.excludes)))
1014
1041
  };
1015
1042
  };
1016
1043
  const expandoMemberFlags = (declaration) => {
@@ -1061,7 +1088,7 @@ const bindPropertyOfNamespace = (binding, left) => {
1061
1088
  };
1062
1089
  const bindableAccess = (binding, node, scope) => Option.liftPredicate(node.left, isAccessExpression).pipe(Option.filter((left) => scope.containerIsFile && !skipsPropertyAssignment(binding, left)));
1063
1090
  const isExportsAliasAccess = (binding, left) => isIdentifier(left.expression) && isExportsOrModuleExportsOrAlias(binding, left.expression);
1064
- const bindSpecialPropertyAssignment = (binding, node, scope) => {
1091
+ const bindSpecialPropertyAssignment = Function.dual(DATA_FIRST_ARITY_3$17, (binding, node, scope) => {
1065
1092
  const left = bindableAccess(binding, node, scope);
1066
1093
  if (Option.isNone(left)) return;
1067
1094
  if (isExportsAliasAccess(binding, left.value)) {
@@ -1069,14 +1096,15 @@ const bindSpecialPropertyAssignment = (binding, node, scope) => {
1069
1096
  return;
1070
1097
  }
1071
1098
  bindPropertyOfNamespace(binding, left.value);
1072
- };
1073
- const bindObjectDefinePropertyAssignment = (binding, call, scope) => {
1099
+ });
1100
+ const bindObjectDefinePropertyAssignment = Function.dual(DATA_FIRST_ARITY_3$17, (binding, call, scope) => {
1074
1101
  const [target] = call.arguments;
1075
1102
  if (!scope.containerIsFile || Predicate.isUndefined(target)) return;
1076
1103
  const isTopLevel = isSourceFile(call.parent.parent);
1077
1104
  bindExpandoMember(binding, call, namespaceFor(binding, target, isTopLevel));
1078
- };
1105
+ });
1079
1106
  // src/attw/binder-module-exports.ts
1107
+ const DATA_FIRST_ARITY_3$16 = 3;
1080
1108
  const isEmptyObjectLiteral = (node) => isObjectLiteralExpression(node) && !Array$1.isReadonlyArrayNonEmpty(node.properties);
1081
1109
  const MODULE_EXPORTS_ALIAS = {
1082
1110
  includes: combineFlags(SymbolFlags.Alias, SymbolFlags.Assignment),
@@ -1087,24 +1115,24 @@ const MODULE_EXPORTS_VALUE = {
1087
1115
  excludes: 0
1088
1116
  };
1089
1117
  const bindShorthandExports = (binding, assigned) => {
1090
- if (!isObjectLiteralExpression(assigned) || !assigned.properties.every(isShorthandPropertyAssignment)) return false;
1118
+ if (!isObjectLiteralExpression(assigned) || !pipe(assigned.properties, Array$1.every(isShorthandPropertyAssignment))) return false;
1091
1119
  for (const property of assigned.properties) declareExport(binding, property, MODULE_EXPORTS_ALIAS);
1092
1120
  return true;
1093
1121
  };
1094
1122
  const isUnboundModuleExportsValue = (binding, assigned, scope) => isEmptyObjectLiteral(assigned) || scope.containerIsFile && isExportsOrModuleExportsOrAlias(binding, assigned);
1095
- const bindModuleExportsAssignment = (binding, node, scope) => {
1123
+ const bindModuleExportsAssignment = Function.dual(DATA_FIRST_ARITY_3$16, (binding, node, scope) => {
1096
1124
  const assigned = getRightMostAssignedExpression(node.right);
1097
1125
  if (!setCommonJsModuleIndicator(binding, node) || isUnboundModuleExportsValue(binding, assigned, scope) || bindShorthandExports(binding, assigned)) return;
1098
1126
  const flags = Option.getOrElse(Option.liftPredicate(MODULE_EXPORTS_ALIAS, () => isAliasableExpression(node.right)), () => MODULE_EXPORTS_VALUE);
1099
1127
  setValueDeclaration(declareExport(binding, node, flags), node);
1100
- };
1128
+ });
1101
1129
  const MODULE_LOCAL = {
1102
1130
  includes: combineFlags(SymbolFlags.FunctionScopedVariable, SymbolFlags.ModuleExports),
1103
1131
  excludes: SymbolFlags.FunctionScopedVariableExcludes
1104
1132
  };
1105
1133
  const shadowsModule = (binding, scope) => scope.blockIsFile && Option.isSome(lookupSymbolForName(binding, "module"));
1106
1134
  const isTrackedModuleExportsAccess = (binding, node) => binding.isJs && Predicate.isNotUndefined(binding.commonJsModuleIndicator) && isModuleExportsAccessExpression(node);
1107
- const bindModuleExportsAccess = (binding, node, scope) => {
1135
+ const bindModuleExportsAccess = Function.dual(DATA_FIRST_ARITY_3$16, (binding, node, scope) => {
1108
1136
  if (!isAccessExpression(node) || !isTrackedModuleExportsAccess(binding, node) || shadowsModule(binding, scope)) return;
1109
1137
  declare(binding, {
1110
1138
  target: {
@@ -1114,8 +1142,9 @@ const bindModuleExportsAccess = (binding, node, scope) => {
1114
1142
  node: node.expression,
1115
1143
  flags: MODULE_LOCAL
1116
1144
  });
1117
- };
1145
+ });
1118
1146
  // src/attw/binder-this.ts
1147
+ const DATA_FIRST_ARITY$25 = 2;
1119
1148
  const THIS_CONTAINER_KINDS = /* @__PURE__ */ new Set([
1120
1149
  SyntaxKind.FunctionDeclaration,
1121
1150
  SyntaxKind.FunctionExpression,
@@ -1147,16 +1176,17 @@ const thisContainerIsFile = (node) => {
1147
1176
  while (!THIS_CONTAINER_KINDS.has(current.kind)) current = current.parent;
1148
1177
  return isSourceFile(current);
1149
1178
  };
1150
- const bindThisPropertyAssignment = (binding, node) => {
1179
+ const bindThisPropertyAssignment = Function.dual(DATA_FIRST_ARITY$25, (binding, node) => {
1151
1180
  if (!thisContainerIsFile(node) || isDynamicElementAccess(node.left)) return;
1152
1181
  if (Predicate.isNotUndefined(binding.commonJsModuleIndicator)) {
1153
1182
  declareExport(binding, node, THIS_PROPERTY_EXPORT);
1154
1183
  return;
1155
1184
  }
1156
1185
  declareSourceFileMember(binding, node, THIS_PROPERTY_LOCAL);
1157
- };
1158
- const isThisInitialized = (binding, node) => isAccessExpression(node.left) && variableInitializer(binding, node.left.expression).pipe(Option.exists(isThisKeyword));
1186
+ });
1187
+ const isThisInitialized = Function.dual(DATA_FIRST_ARITY$25, (binding, node) => isAccessExpression(node.left) && variableInitializer(binding, node.left.expression).pipe(Option.exists(isThisKeyword)));
1159
1188
  // src/attw/binder-expressions.ts
1189
+ const EXPRESSION_ARITY = 3;
1160
1190
  const isThisAliasAssignment = (binding, node, scope) => binding.isJs && scope.blockIsFile && isThisInitialized(binding, node);
1161
1191
  const bindPropertyAssignment = (binding, node, scope) => {
1162
1192
  if (isThisAliasAssignment(binding, node, scope)) {
@@ -1166,9 +1196,15 @@ const bindPropertyAssignment = (binding, node, scope) => {
1166
1196
  bindSpecialPropertyAssignment(binding, node, scope);
1167
1197
  };
1168
1198
  const BINARY_BINDERS = /* @__PURE__ */ new Map([
1169
- [AssignmentKind.ExportsProperty, bindExportsPropertyAssignment],
1170
- [AssignmentKind.ModuleExports, bindModuleExportsAssignment],
1171
- [AssignmentKind.ThisProperty, bindThisPropertyAssignment],
1199
+ [AssignmentKind.ExportsProperty, (binding, node, scope) => {
1200
+ bindExportsPropertyAssignment(binding, node, scope);
1201
+ }],
1202
+ [AssignmentKind.ModuleExports, (binding, node, scope) => {
1203
+ bindModuleExportsAssignment(binding, node, scope);
1204
+ }],
1205
+ [AssignmentKind.ThisProperty, (binding, node) => {
1206
+ bindThisPropertyAssignment(binding, node);
1207
+ }],
1172
1208
  [AssignmentKind.Property, bindPropertyAssignment]
1173
1209
  ]);
1174
1210
  const CALL_BINDERS = /* @__PURE__ */ new Map([[AssignmentKind.ObjectDefinePropertyExports, bindObjectDefinePropertyExport], [AssignmentKind.ObjectDefinePropertyValue, bindObjectDefinePropertyAssignment]]);
@@ -1186,7 +1222,7 @@ const bindCallExpression = (binding, node, scope) => {
1186
1222
  }
1187
1223
  if (kind === AssignmentKind.None && marksCommonJsModule(binding, node)) setCommonJsModuleIndicator(binding, node);
1188
1224
  };
1189
- const bindExpression = (binding, node, scope) => {
1225
+ const bindExpression = Function.dual(EXPRESSION_ARITY, (binding, node, scope) => {
1190
1226
  if (isBinaryExpression(node)) {
1191
1227
  bindBinaryExpression(binding, node, scope);
1192
1228
  return;
@@ -1196,7 +1232,7 @@ const bindExpression = (binding, node, scope) => {
1196
1232
  return;
1197
1233
  }
1198
1234
  bindModuleExportsAccess(binding, node, scope);
1199
- };
1235
+ });
1200
1236
  const INSTANTIATED = 1;
1201
1237
  const CONST_ENUM_ONLY = 2;
1202
1238
  const isConstEnum = (node) => hasSyntacticModifier(node, ModifierFlags.Const);
@@ -1215,7 +1251,7 @@ const statementsOf = (node) => {
1215
1251
  };
1216
1252
  const aliasTargetState = (specifier, stateOf) => {
1217
1253
  const name = Option.getOrElse(nameText(specifier.propertyName ?? specifier.name), () => "");
1218
- const matching = statementsOf(specifier.parent.parent.parent).filter((statement) => declaresName(statement, name));
1254
+ const matching = pipe(statementsOf(specifier.parent.parent.parent), Array$1.filter((statement) => declaresName(statement, name)));
1219
1255
  if (!Array$1.isReadonlyArrayNonEmpty(matching)) return INSTANTIATED;
1220
1256
  return Array$1.reduce(matching, 0, (state, statement) => keepFirstInstantiated(state, stateOf(statement)));
1221
1257
  };
@@ -1235,7 +1271,7 @@ const DECLARATION_STATES = [
1235
1271
  [isConstEnumDeclaration, CONST_ENUM_ONLY],
1236
1272
  [isUnexportedImport, 0]
1237
1273
  ];
1238
- const declarationState = (node) => Option.fromNullishOr(DECLARATION_STATES.find(([matches]) => matches(node))).pipe(Option.map(([, state]) => state));
1274
+ const declarationState = (node) => Array$1.findFirst(DECLARATION_STATES, ([matches]) => matches(node)).pipe(Option.map(([, state]) => state));
1239
1275
  const containerState = (node, stateOf) => {
1240
1276
  if (isExportDeclaration(node)) return exportDeclarationState(node, stateOf);
1241
1277
  if (isModuleBlock(node)) return Array$1.reduce(node.statements, 0, (state, statement) => keepBlockState(state, stateOf(statement)));
@@ -1326,6 +1362,7 @@ const DECLARATION_BINDERS = /* @__PURE__ */ new Map([
1326
1362
  [SyntaxKind.ExportAssignment, bindExportAssignment]
1327
1363
  ]);
1328
1364
  // src/attw/binder-variables.ts
1365
+ const DATA_FIRST_ARITY_3$15 = 3;
1329
1366
  const ALIAS = {
1330
1367
  includes: SymbolFlags.Alias,
1331
1368
  excludes: SymbolFlags.AliasExcludes
@@ -1376,9 +1413,9 @@ const variableBinderFor = (binding, node) => {
1376
1413
  if (isBlockOrCatchScoped(node)) return bindBlockVariable;
1377
1414
  return bindFunctionVariable;
1378
1415
  };
1379
- const bindVariable = (binding, node, scope) => {
1416
+ const bindVariable = Function.dual(DATA_FIRST_ARITY_3$15, (binding, node, scope) => {
1380
1417
  if (!isBindingPattern(node.name)) variableBinderFor(binding, node)(binding, node, scope);
1381
- };
1418
+ });
1382
1419
  // src/attw/binder-walk.ts
1383
1420
  const FILE_SCOPE = {
1384
1421
  containerIsFile: true,
@@ -1432,7 +1469,7 @@ const bindFileNodes = (binding) => {
1432
1469
  stack.push(...bindFrame(binding, frame));
1433
1470
  frame = stack.pop();
1434
1471
  }
1435
- return bound.filter((node) => !isReparsed(node));
1472
+ return pipe(bound, Array$1.filter((node) => !isReparsed(node)));
1436
1473
  };
1437
1474
  // src/attw/binder.ts
1438
1475
  const USE_STRICT = "use strict";
@@ -1442,9 +1479,9 @@ const JSON_EXPORT = {
1442
1479
  };
1443
1480
  const bindings = /* @__PURE__ */ new WeakMap();
1444
1481
  const isJsFile = (file) => file.scriptKind === ScriptKind.JS || file.scriptKind === ScriptKind.JSX;
1445
- const hasExportDeclarations = (file) => file.statements.some((statement) => isExportDeclaration(statement) || isExportAssignment(statement));
1482
+ const hasExportDeclarations = (file) => pipe(file.statements, Array$1.some((statement) => isExportDeclaration(statement) || isExportAssignment(statement)));
1446
1483
  const directiveText = (statement) => Option.liftPredicate(statement, isExpressionStatement).pipe(Option.map((directive) => directive.expression), Option.filter(isStringLiteral), Option.map((literal) => literal.text));
1447
- const hasUseStrictPrologue = (file) => Array$1.takeWhile(file.statements.map(directiveText), Option.isSome).some((text) => Option.contains(text, USE_STRICT));
1484
+ const hasUseStrictPrologue = (file) => pipe(file.statements, Array$1.map(directiveText), Array$1.takeWhile(Option.isSome), Array$1.some((text) => Option.contains(text, USE_STRICT)));
1448
1485
  const createBinding = (file) => {
1449
1486
  const isExternalModule = Predicate.isNotUndefined(file.externalModuleIndicator) && file.externalModuleIndicator !== true;
1450
1487
  return {
@@ -1490,6 +1527,7 @@ const bindSourceFile = (file) => {
1490
1527
  exposeOnSourceFile(binding);
1491
1528
  };
1492
1529
  // src/attw/extensions.ts
1530
+ const DATA_FIRST_ARITY$24 = 2;
1493
1531
  const Extension = {
1494
1532
  Ts: ".ts",
1495
1533
  Tsx: ".tsx",
@@ -1519,9 +1557,9 @@ const EXTENSION_KIND_NAMES = {
1519
1557
  };
1520
1558
  const extensionsOf = (...kinds) => pipe(EXTENSION_KIND_ORDER, Array$1.filter((kind) => kinds.includes(kind)));
1521
1559
  const PRIORITY_KINDS = extensionsOf("TypeScript", "Declaration");
1522
- const intersectExtensions = (left, right) => pipe(left, Array$1.filter((kind) => right.includes(kind)));
1523
- const subtractExtensions = (left, right) => pipe(left, Array$1.filter((kind) => !right.includes(kind)));
1524
- const formatExtensions = (extensions) => extensions.map((kind) => EXTENSION_KIND_NAMES[kind]).join(", ");
1560
+ const intersectExtensions = Function.dual(DATA_FIRST_ARITY$24, (left, right) => pipe(left, Array$1.filter((kind) => right.includes(kind))));
1561
+ const subtractExtensions = Function.dual(DATA_FIRST_ARITY$24, (left, right) => pipe(left, Array$1.filter((kind) => !right.includes(kind))));
1562
+ const formatExtensions = (extensions) => pipe(extensions, Array$1.map((kind) => EXTENSION_KIND_NAMES[kind]), Array$1.join(", "));
1525
1563
  const SUPPORTED_TS = [
1526
1564
  Extension.Ts,
1527
1565
  Extension.Tsx,
@@ -1572,29 +1610,29 @@ const REMOVABLE = [
1572
1610
  Extension.Json
1573
1611
  ];
1574
1612
  const ZERO = 0;
1575
- const fileExtensionIs = (path, extension) => path.length > extension.length && path.endsWith(extension);
1576
- const fileExtensionIsOneOf = (path, extensions) => extensions.some((extension) => fileExtensionIs(path, extension));
1613
+ const fileExtensionIs = (path, extension) => path.length > extension.length && String$1.endsWith(extension)(path);
1614
+ const fileExtensionIsOneOf = Function.dual(DATA_FIRST_ARITY$24, (path, extensions) => pipe(extensions, Array$1.some((extension) => fileExtensionIs(path, extension))));
1577
1615
  const findExtension = (path, extensions) => Array$1.findFirst(extensions, (extension) => fileExtensionIs(path, extension));
1578
1616
  const hasTSFileExtension = (fileName) => fileExtensionIsOneOf(fileName, SUPPORTED_TS);
1579
1617
  const hasJSFileExtension = (fileName) => fileExtensionIsOneOf(fileName, SUPPORTED_JS);
1580
1618
  const ARBITRARY_DECLARATION = ".d.";
1581
- const getArbitraryDeclarationExtension = (fileName) => Option.liftPredicate(fileName, (name) => fileExtensionIs(name, Extension.Ts)).pipe(Option.flatMap((name) => Option.liftPredicate(getBaseFileName(name).lastIndexOf(ARBITRARY_DECLARATION), (index) => index >= ZERO).pipe(Option.map((index) => name.slice(name.length - getBaseFileName(name).length + index)))));
1582
- const getDeclarationFileExtension = (fileName) => Array$1.findFirst(SUPPORTED_DECLARATION, (extension) => fileName.endsWith(extension)).pipe(Option.orElse(() => getArbitraryDeclarationExtension(fileName)));
1619
+ const getArbitraryDeclarationExtension = (fileName) => Option.liftPredicate(fileName, (name) => fileExtensionIs(name, Extension.Ts)).pipe(Option.flatMap((name) => String$1.lastIndexOf(ARBITRARY_DECLARATION)(getBaseFileName(name)).pipe(Option.map((index) => String$1.slice(name.length - getBaseFileName(name).length + index)(name)))));
1620
+ const getDeclarationFileExtension = (fileName) => Array$1.findFirst(SUPPORTED_DECLARATION, (extension) => String$1.endsWith(extension)(fileName)).pipe(Option.orElse(() => getArbitraryDeclarationExtension(fileName)));
1583
1621
  const isDeclarationFileName = (fileName) => Option.isSome(getDeclarationFileExtension(fileName));
1584
1622
  const getAnyExtensionFromPath = (path) => {
1585
1623
  const base = getBaseFileName(path);
1586
- return Option.liftPredicate(base.lastIndexOf("."), (index) => index >= ZERO).pipe(Option.match({
1624
+ return String$1.lastIndexOf(".")(base).pipe(Option.match({
1587
1625
  onNone: () => "",
1588
- onSome: (index) => base.slice(index)
1626
+ onSome: (index) => String$1.slice(index)(base)
1589
1627
  }));
1590
1628
  };
1591
1629
  const removeFileExtension = (path) => findExtension(path, REMOVABLE).pipe(Option.match({
1592
1630
  onNone: () => path,
1593
- onSome: (extension) => path.slice(ZERO, path.length - extension.length)
1631
+ onSome: (extension) => String$1.slice(ZERO, path.length - extension.length)(path)
1594
1632
  }));
1595
1633
  const tryGetExtensionFromPath = (path) => findExtension(path, REMOVABLE);
1596
1634
  const tryExtractTSExtension = (fileName) => findExtension(fileName, EXTRACTABLE_TS);
1597
- const isTSFileExtensionForPackageField = (extensions, candidate) => extensions.includes("TypeScript") && fileExtensionIsOneOf(candidate, SUPPORTED_TS_IMPLEMENTATION) || extensions.includes("Declaration") && fileExtensionIsOneOf(candidate, SUPPORTED_DECLARATION);
1635
+ const isTSFileExtensionForPackageField = Function.dual(DATA_FIRST_ARITY$24, (extensions, candidate) => extensions.includes("TypeScript") && fileExtensionIsOneOf(candidate, SUPPORTED_TS_IMPLEMENTATION) || extensions.includes("Declaration") && fileExtensionIsOneOf(candidate, SUPPORTED_DECLARATION));
1598
1636
  const EXTENSIONS_FOR_KIND = {
1599
1637
  TypeScript: [
1600
1638
  Extension.Ts,
@@ -1615,15 +1653,16 @@ const EXTENSIONS_FOR_KIND = {
1615
1653
  ],
1616
1654
  Json: [Extension.Json]
1617
1655
  };
1618
- const extensionIsOk = (extensions, extension) => EXTENSION_KIND_ORDER.some((kind) => extensions.includes(kind) && EXTENSIONS_FOR_KIND[kind].includes(extension));
1656
+ const extensionIsOk = Function.dual(DATA_FIRST_ARITY$24, (extensions, extension) => pipe(EXTENSION_KIND_ORDER, Array$1.some((kind) => extensions.includes(kind) && EXTENSIONS_FOR_KIND[kind].includes(extension))));
1619
1657
  // src/attw/source-file.ts
1658
+ const DATA_FIRST_ARITY$23 = 2;
1620
1659
  const infos = /* @__PURE__ */ new WeakMap();
1621
1660
  const UNSET = Object.freeze({
1622
1661
  writable: true,
1623
1662
  configurable: true,
1624
1663
  enumerable: true
1625
1664
  });
1626
- const attachFileInfo = (sourceFile, impliedNodeFormat) => {
1665
+ const attachFileInfo = Function.dual(DATA_FIRST_ARITY$23, (sourceFile, impliedNodeFormat) => {
1627
1666
  infos.set(sourceFile, {
1628
1667
  impliedNodeFormat,
1629
1668
  packageJsonScope: Option.none(),
@@ -1633,16 +1672,16 @@ const attachFileInfo = (sourceFile, impliedNodeFormat) => {
1633
1672
  Object.defineProperty(sourceFile, "imports", UNSET);
1634
1673
  Object.defineProperty(sourceFile, "moduleAugmentations", UNSET);
1635
1674
  return sourceFile;
1636
- };
1675
+ });
1637
1676
  const infoOf = (sourceFile) => Option.fromNullishOr(infos.get(sourceFile));
1638
1677
  const impliedNodeFormatOf = (sourceFile) => Option.flatMap(infoOf(sourceFile), (info) => info.impliedNodeFormat);
1639
1678
  const packageJsonScopeOf$1 = (sourceFile) => Option.flatMap(infoOf(sourceFile), (info) => info.packageJsonScope);
1640
- const setPackageJsonScope = (sourceFile, scope) => {
1679
+ const setPackageJsonScope = Function.dual(DATA_FIRST_ARITY$23, (sourceFile, scope) => {
1641
1680
  Option.map(infoOf(sourceFile), (info) => infos.set(sourceFile, {
1642
1681
  ...info,
1643
1682
  packageJsonScope: scope
1644
1683
  }));
1645
- };
1684
+ });
1646
1685
  const collectExternalModuleReferences = (sourceFile) => {
1647
1686
  Option.map(infoOf(sourceFile), (info) => {
1648
1687
  Object.defineProperty(sourceFile, "imports", {
@@ -1667,6 +1706,8 @@ const moduleAugmentationsOf = (sourceFile) => Option.match(infoOf(sourceFile), {
1667
1706
  const isSourceFileJS = (sourceFile) => sourceFile.scriptKind === ScriptKind.JS || sourceFile.scriptKind === ScriptKind.JSX;
1668
1707
  const isJSDocNode = (node) => hasFlag(node.flags, NodeFlags.JSDoc);
1669
1708
  // src/attw/module-mode.ts
1709
+ const DATA_FIRST_ARITY$22 = 2;
1710
+ const DATA_FIRST_ARITY_3$14 = 3;
1670
1711
  const SINGLE = 1;
1671
1712
  const RESOLUTION_MODES = /* @__PURE__ */ new Map([["import", "ESNext"], ["require", "CommonJS"]]);
1672
1713
  const resolutionModeOf = (text) => Option.fromNullishOr(RESOLUTION_MODES.get(text));
@@ -1691,8 +1732,7 @@ const EXPLICIT_FORMATS = [{
1691
1732
  const declaresFormat = (sourceFile, scopeType, explicit) => Option.contains(scopeType, explicit.scopeType) || fileExtensionIsOneOf(sourceFile.fileName, explicit.extensions);
1692
1733
  const explicitFormatOf = (sourceFile, implied) => {
1693
1734
  const scopeType = packageJsonScopeOf$1(sourceFile).pipe(Option.map((scope) => scope.contents.packageJsonContent["type"]));
1694
- const matching = EXPLICIT_FORMATS.find((explicit) => Option.contains(implied, explicit.format) && declaresFormat(sourceFile, scopeType, explicit));
1695
- return Option.fromNullishOr(matching).pipe(Option.map((explicit) => explicit.format));
1735
+ return Array$1.findFirst(EXPLICIT_FORMATS, (explicit) => Option.contains(implied, explicit.format) && declaresFormat(sourceFile, scopeType, explicit)).pipe(Option.map((explicit) => explicit.format));
1696
1736
  };
1697
1737
  const impliedNodeFormatForEmit = (sourceFile, options) => {
1698
1738
  const implied = impliedNodeFormatOf(sourceFile);
@@ -1718,8 +1758,8 @@ const emitSyntaxForUsage = (sourceFile, usage, options) => {
1718
1758
  if (isImportCall(container)) return Option.some(importCallMode(sourceFile, options));
1719
1759
  return Option.liftPredicate(emitModuleFormat(sourceFile, options), (format) => format !== "Node16");
1720
1760
  };
1721
- const getModeForUsageLocation$1 = (sourceFile, usage, options) => typeOnlyOverride(usage).pipe(Option.orElse(() => importTypeOverride(usage)), Option.orElse(() => Option.liftPredicate(options, importSyntaxAffectsModuleResolution).pipe(Option.flatMap(() => emitSyntaxForUsage(sourceFile, usage, options)))));
1722
- const getDefaultResolutionModeForFile = (sourceFile, options) => Option.liftPredicate(options, importSyntaxAffectsModuleResolution).pipe(Option.flatMap(() => impliedNodeFormatForEmit(sourceFile, options)));
1761
+ const getModeForUsageLocation$1 = Function.dual(DATA_FIRST_ARITY_3$14, (sourceFile, usage, options) => typeOnlyOverride(usage).pipe(Option.orElse(() => importTypeOverride(usage)), Option.orElse(() => Option.liftPredicate(options, importSyntaxAffectsModuleResolution).pipe(Option.flatMap(() => emitSyntaxForUsage(sourceFile, usage, options))))));
1762
+ const getDefaultResolutionModeForFile = Function.dual(DATA_FIRST_ARITY$22, (sourceFile, options) => Option.liftPredicate(options, importSyntaxAffectsModuleResolution).pipe(Option.flatMap(() => impliedNodeFormatForEmit(sourceFile, options))));
1723
1763
  // src/attw/resolution-mode-numbers.ts
1724
1764
  const MODE_NUMBERS = {
1725
1765
  CommonJS: ModuleKind.CommonJS,
@@ -1729,22 +1769,22 @@ const MODES_BY_NUMBER = /* @__PURE__ */ new Map([[ModuleKind.CommonJS, "CommonJS
1729
1769
  const modeFromNumber = (mode) => Option.fromNullishOr(mode).pipe(Option.flatMap((value) => Option.fromNullishOr(MODES_BY_NUMBER.get(value))));
1730
1770
  const modeToNumber = (mode) => MODE_NUMBERS[mode];
1731
1771
  // src/attw/ts-api.ts
1772
+ const DATA_FIRST_ARITY_3$13 = 3;
1732
1773
  const MOUNT_ROOT = "/attw";
1733
1774
  const SEPARATOR = "/";
1734
1775
  const START$5 = 0;
1735
- const SECOND = 1;
1736
- const MOUNT_DIRECTORY = MOUNT_ROOT.slice(1);
1776
+ const SECOND$1 = 1;
1777
+ const MOUNT_DIRECTORY = String$1.slice(1)(MOUNT_ROOT);
1737
1778
  const mounts = /* @__PURE__ */ new Map();
1738
1779
  const counter = { next: 0 };
1739
1780
  const mountOf = (path) => {
1740
- if (!path.startsWith(`${MOUNT_ROOT}${SEPARATOR}`)) return Option.none();
1741
- const rest = path.slice(6);
1742
- const end = rest.indexOf(SEPARATOR);
1743
- const id = Option.match(Option.liftPredicate(end, (index) => index >= SECOND), {
1781
+ if (!String$1.startsWith(`${MOUNT_ROOT}${SEPARATOR}`)(path)) return Option.none();
1782
+ const rest = String$1.slice(6)(path);
1783
+ const id = Option.match(Option.filter(String$1.indexOf(SEPARATOR)(rest), (index) => index >= SECOND$1), {
1744
1784
  onNone: () => rest,
1745
- onSome: (index) => rest.slice(START$5, index)
1785
+ onSome: (index) => String$1.slice(START$5, index)(rest)
1746
1786
  });
1747
- const inner = Option.liftPredicate(rest.slice(id.length), (remainder) => remainder.length > START$5);
1787
+ const inner = Option.liftPredicate(String$1.slice(id.length)(rest), (remainder) => remainder.length > START$5);
1748
1788
  return Option.fromNullishOr(mounts.get(id)).pipe(Option.flatMap((reference) => Option.fromNullishOr(reference.deref())), Option.map((fileSystem) => ({
1749
1789
  fileSystem,
1750
1790
  path: Option.getOrElse(inner, () => SEPARATOR)
@@ -1753,15 +1793,18 @@ const mountOf = (path) => {
1753
1793
  const uniqueEntries = (names) => [...new Set(names)];
1754
1794
  const childEntries = (paths, directory) => {
1755
1795
  const prefix = ensureTrailingDirectorySeparator(directory);
1756
- const children = paths.filter((path) => path.startsWith(prefix)).map((path) => path.slice(prefix.length));
1757
- const nested = children.filter((child) => child.includes(SEPARATOR));
1796
+ const children = pipe(paths, Array$1.filter((path) => String$1.startsWith(prefix)(path)), Array$1.map((path) => String$1.slice(prefix.length)(path)));
1797
+ const nested = pipe(children, Array$1.filter((child) => String$1.includes(SEPARATOR)(child)));
1758
1798
  return {
1759
- files: uniqueEntries(children.filter((child) => !child.includes(SEPARATOR))),
1760
- directories: uniqueEntries(nested.map((child) => child.slice(START$5, child.indexOf(SEPARATOR)))),
1799
+ files: uniqueEntries(pipe(children, Array$1.filter((child) => !String$1.includes(SEPARATOR)(child)))),
1800
+ directories: uniqueEntries(pipe(nested, Array$1.map((child) => Option.match(String$1.indexOf(SEPARATOR)(child), {
1801
+ onNone: () => child,
1802
+ onSome: (end) => String$1.slice(START$5, end)(child)
1803
+ })))),
1761
1804
  symlinks: []
1762
1805
  };
1763
1806
  };
1764
- const liveMountIds = () => [...mounts.entries()].filter(([, reference]) => Predicate.isNotUndefined(reference.deref())).map(([id]) => id);
1807
+ const liveMountIds = () => pipe([...mounts.entries()], Array$1.filter(([, reference]) => Predicate.isNotUndefined(reference.deref())), Array$1.map(([id]) => id));
1765
1808
  const ANCESTOR_DIRECTORIES = /* @__PURE__ */ new Map([[SEPARATOR, () => [MOUNT_DIRECTORY]], [MOUNT_ROOT, liveMountIds]]);
1766
1809
  const ancestorEntries = (path) => ({
1767
1810
  files: [],
@@ -1799,7 +1842,7 @@ const sharedApi = () => Option.getOrElse(holder.api, () => {
1799
1842
  return created;
1800
1843
  });
1801
1844
  const mount = (fileSystem) => {
1802
- counter.next += SECOND;
1845
+ counter.next += SECOND$1;
1803
1846
  const id = String(counter.next);
1804
1847
  for (const [key, reference] of mounts) if (Predicate.isUndefined(reference.deref())) mounts.delete(key);
1805
1848
  mounts.set(id, new WeakRef(fileSystem));
@@ -1808,7 +1851,7 @@ const mount = (fileSystem) => {
1808
1851
  root: `${MOUNT_ROOT}${SEPARATOR}${id}`
1809
1852
  };
1810
1853
  };
1811
- const parseSourceFile = (fileName, text, scriptKind) => {
1854
+ const parseSourceFile = Function.dual(DATA_FIRST_ARITY_3$13, (fileName, text, scriptKind) => {
1812
1855
  const retained = sharedApi().createSourceFile(fileName, text, Option.match(scriptKind, {
1813
1856
  onNone: () => ({}),
1814
1857
  onSome: (kind) => ({ scriptKind: kind })
@@ -1816,7 +1859,7 @@ const parseSourceFile = (fileName, text, scriptKind) => {
1816
1859
  const { sourceFile } = retained;
1817
1860
  retained.dispose();
1818
1861
  return sourceFile;
1819
- };
1862
+ });
1820
1863
  // src/attw/typescript-files.ts
1821
1864
  const ROOT = "/";
1822
1865
  const SCRIPT_KIND_AFTER_TEXT = 2;
@@ -1832,7 +1875,7 @@ const MODULE_NAMES = /* @__PURE__ */ new Map([
1832
1875
  [ModuleKind.Node16, "Node16"],
1833
1876
  [ModuleKind.NodeNext, "Node16"]
1834
1877
  ]);
1835
- const SCRIPT_KINDS = new Set(Object.values(ScriptKind));
1878
+ const SCRIPT_KINDS = new Set(Record.values(ScriptKind));
1836
1879
  const resolutionNameOf = (kind) => Option.fromNullishOr(kind).pipe(Option.flatMapNullishOr((value) => RESOLUTION_NAMES.get(value)), Option.getOrElse(() => "Node10"));
1837
1880
  const moduleNameOf = (kind) => Option.fromNullishOr(kind).pipe(Option.flatMapNullishOr((value) => MODULE_NAMES.get(value)), Option.getOrElse(() => "CommonJS"));
1838
1881
  const modeOptionsOf = (options) => ({
@@ -1892,43 +1935,58 @@ const nodeFunctions = {
1892
1935
  skipParentheses
1893
1936
  };
1894
1937
  // src/attw/package-names.ts
1895
- const NOT_FOUND$4 = -1;
1938
+ const DATA_FIRST_ARITY$21 = 2;
1896
1939
  const NEXT$1 = 1;
1897
1940
  const START$4 = 0;
1898
1941
  const SCOPE_SEPARATOR = "__";
1899
1942
  const SCOPE_MARKER_LENGTH = 1;
1900
1943
  const packageNameEnd = (moduleName) => {
1901
- const first = moduleName.indexOf("/");
1902
- if (moduleName.startsWith("@")) return moduleName.indexOf("/", first + NEXT$1);
1944
+ const first = String$1.indexOf("/")(moduleName);
1945
+ if (String$1.startsWith("@")(moduleName)) return first.pipe(Option.flatMap((index) => indexFrom(moduleName, "/", index + NEXT$1)));
1903
1946
  return first;
1904
1947
  };
1905
- const parsePackageName = (moduleName) => {
1906
- const end = packageNameEnd(moduleName);
1907
- if (end === NOT_FOUND$4) return {
1948
+ const parsePackageName = (moduleName) => Option.match(packageNameEnd(moduleName), {
1949
+ onNone: () => ({
1908
1950
  packageName: moduleName,
1909
1951
  rest: ""
1910
- };
1911
- return {
1912
- packageName: moduleName.slice(START$4, end),
1913
- rest: moduleName.slice(end + NEXT$1)
1914
- };
1915
- };
1952
+ }),
1953
+ onSome: (end) => ({
1954
+ packageName: String$1.slice(START$4, end)(moduleName),
1955
+ rest: String$1.slice(end + NEXT$1)(moduleName)
1956
+ })
1957
+ });
1916
1958
  const mangleScopedPackageName = (packageName) => {
1917
- if (!packageName.startsWith("@")) return packageName;
1918
- const replaced = packageName.replace("/", SCOPE_SEPARATOR);
1959
+ if (!String$1.startsWith("@")(packageName)) return packageName;
1960
+ const replaced = String$1.replace("/", SCOPE_SEPARATOR)(packageName);
1919
1961
  if (replaced === packageName) return packageName;
1920
- return replaced.slice(SCOPE_MARKER_LENGTH);
1962
+ return String$1.slice(SCOPE_MARKER_LENGTH)(replaced);
1921
1963
  };
1922
1964
  const unmangleScopedPackageName = (typesPackageName) => {
1923
- if (!typesPackageName.includes(SCOPE_SEPARATOR)) return typesPackageName;
1924
- return `@${typesPackageName.replace(SCOPE_SEPARATOR, "/")}`;
1965
+ if (!String$1.includes(SCOPE_SEPARATOR)(typesPackageName)) return typesPackageName;
1966
+ return `@${String$1.replace(SCOPE_SEPARATOR, "/")(typesPackageName)}`;
1925
1967
  };
1926
1968
  const getTypesPackageName = (packageName) => `@types/${mangleScopedPackageName(packageName)}`;
1927
- const mangleScopedPackageNameWithTrace = (packageName, state) => {
1969
+ const mangleScopedPackageNameWithTrace = Function.dual(DATA_FIRST_ARITY$21, (packageName, state) => {
1928
1970
  const mangled = mangleScopedPackageName(packageName);
1929
1971
  if (mangled !== packageName) traceMessage(state, Messages.scopedPackageDetected, mangled);
1930
1972
  return mangled;
1973
+ });
1974
+ // src/attw/path-compare.ts
1975
+ const DATA_FIRST_ARITY$20 = 2;
1976
+ const FIRST = 0;
1977
+ const SECOND = 1;
1978
+ const compareStrings = (left, right) => Math.sign(Number(left > right) - Number(left < right));
1979
+ const compareCaseInsensitive = (left, right) => compareStrings(String$1.toUpperCase(left), String$1.toUpperCase(right));
1980
+ const compareComponents = (left, right) => pipe(Array$1.zip(left, right), Array$1.drop(SECOND), Array$1.map(([leftComponent, rightComponent]) => compareCaseInsensitive(leftComponent, rightComponent)), Array$1.findFirst((result) => result !== FIRST), Option.getOrElse(() => Math.sign(left.length - right.length)));
1981
+ const compareRests = (left, right) => {
1982
+ if (!RELATIVE_SEGMENT.test(left) && !RELATIVE_SEGMENT.test(right)) return compareCaseInsensitive(left, right);
1983
+ return compareComponents(reducePathComponents(getPathComponents(left)), reducePathComponents(getPathComponents(right)));
1931
1984
  };
1985
+ const comparePathsCaseInsensitive = Function.dual(DATA_FIRST_ARITY$20, (left, right) => {
1986
+ const leftRoot = String$1.slice(FIRST, getRootLength(left))(left);
1987
+ const rightRoot = String$1.slice(FIRST, getRootLength(right))(right);
1988
+ return Option.liftPredicate(compareCaseInsensitive(leftRoot, rightRoot), (result) => result !== FIRST).pipe(Option.getOrElse(() => compareRests(String$1.slice(leftRoot.length)(left), String$1.slice(rightRoot.length)(right))));
1989
+ });
1932
1990
  // src/attw/typescript-paths.ts
1933
1991
  const forEachAncestorDirectory = (directory, visit) => Option.getOrUndefined(forEachAncestorDirectory$1(directory, (ancestor) => Option.fromUndefinedOr(visit(ancestor))));
1934
1992
  const pathFunctions = {
@@ -2903,7 +2961,7 @@ const openCheckerSession = (program) => {
2903
2961
  const api = sharedApi();
2904
2962
  const moduleResolver = api.createModuleResolver(program.compilerOptions, { resolveModuleName: (moduleName, containingDirectory, mode) => Option.getOrUndefined(program.resolve(moduleName, containingDirectory, mode)) });
2905
2963
  const snapshot = api.createSnapshot({ createPrograms: [{
2906
- rootFiles: program.rootNames.map((name) => `${program.mountPath}${name}`),
2964
+ rootFiles: pipe(program.rootNames, Array$1.map((name) => `${program.mountPath}${name}`)),
2907
2965
  compilerOptions: program.compilerOptions,
2908
2966
  options: { moduleResolver }
2909
2967
  }] });
@@ -2920,6 +2978,7 @@ const openCheckerSession = (program) => {
2920
2978
  };
2921
2979
  };
2922
2980
  // src/attw/checker-symbols.ts
2981
+ const DATA_FIRST_ARITY$19 = 2;
2923
2982
  const EXPORT_EQUALS = "export=";
2924
2983
  const isCheckerSymbol = (symbol) => "getExports" in symbol;
2925
2984
  const sourceFileOf = (node) => {
@@ -2945,7 +3004,7 @@ const NAMEABLE_GUARDS = [
2945
3004
  isExportAssignment,
2946
3005
  isNamespaceExport
2947
3006
  ];
2948
- const isNameable = (node) => NAMEABLE_GUARDS.some((guard) => guard(node));
3007
+ const isNameable = (node) => pipe(NAMEABLE_GUARDS, Array$1.some((guard) => guard(node)));
2949
3008
  const nameNode = (declaration) => Option.liftPredicate(declaration, isNameable).pipe(Option.flatMapNullishOr((nameable) => getNameOfDeclaration(nameable)), Option.getOrElse(() => declaration));
2950
3009
  const missingSymbol = (symbol) => /* @__PURE__ */ new Error(`TypeScript has no symbol for ${symbol.name}`);
2951
3010
  const fromSourceFile = (session, file, symbol) => Option.fromNullishOr(session.checker.getSymbolOfSourceFile(`${session.mountPath}${file.fileName}`)).pipe(Option.getOrThrowWith(() => missingSymbol(symbol)));
@@ -2961,26 +3020,26 @@ const fromBound = (session, symbol, convert) => {
2961
3020
  if (isSourceFile(declaration)) return fromSourceFile(session, declaration, symbol);
2962
3021
  return fromParentExports(session, symbol, convert).pipe(Option.getOrElse(() => fromPosition(session, declaration, symbol)));
2963
3022
  };
2964
- const toCheckerSymbol = (session, symbol) => {
3023
+ const toCheckerSymbol = Function.dual(DATA_FIRST_ARITY$19, (session, symbol) => {
2965
3024
  if (isCheckerSymbol(symbol)) return symbol;
2966
3025
  return fromBound(session, symbol, toCheckerSymbol);
2967
- };
3026
+ });
2968
3027
  const assignedIdentifier = (declaration) => {
2969
3028
  if (isBinaryExpression(declaration)) return Option.liftPredicate(declaration.right, (node) => isIdentifier(node));
2970
3029
  if (isExportAssignment(declaration)) return Option.liftPredicate(declaration.expression, (node) => isIdentifier(node));
2971
3030
  return Option.none();
2972
3031
  };
2973
3032
  const localNamed = (identifier) => bindingOf(sourceFileOf(identifier)).pipe(Option.flatMap((binding) => Option.liftPredicate(identifier, (node) => isIdentifier(node)).pipe(Option.flatMap((node) => Option.fromNullishOr(binding.locals.get(escapeLeadingUnderscores$1(node.text)))))));
2974
- const boundExpandoExports = (moduleSymbol) => Option.fromNullishOr(moduleSymbol.exports).pipe(Option.flatMap((exports) => Option.fromNullishOr(exports.get(EXPORT_EQUALS))), Option.flatMap((exportEquals) => firstDeclaration(exportEquals)), Option.flatMap((declaration) => assignedIdentifier(declaration)), Option.flatMap((identifier) => localNamed(identifier)), Option.flatMap((local) => Option.fromNullishOr(local.exports)), Option.map((members) => [...members.values()].filter((member) => hasFlag(member.flags, SymbolFlags.Assignment))), Option.getOrElse(() => []));
3033
+ const boundExpandoExports = (moduleSymbol) => Option.fromNullishOr(moduleSymbol.exports).pipe(Option.flatMap((exports) => Option.fromNullishOr(exports.get(EXPORT_EQUALS))), Option.flatMap((exportEquals) => firstDeclaration(exportEquals)), Option.flatMap((declaration) => assignedIdentifier(declaration)), Option.flatMap((identifier) => localNamed(identifier)), Option.flatMap((local) => Option.fromNullishOr(local.exports)), Option.map((members) => pipe([...members.values()], Array$1.filter((member) => hasFlag(member.flags, SymbolFlags.Assignment)))), Option.getOrElse(() => []));
2975
3034
  // src/attw/type-only.ts
2976
3035
  const isTypeOnlyImportClause = (node) => isImportClause(node) && node.phaseModifier === SyntaxKind.TypeKeyword;
2977
3036
  const rule = (guard, test) => (node) => Option.liftPredicate(node, guard).pipe(Option.map(test));
2978
3037
  const isTypeOnlyExportStatement = (node) => isExportDeclaration(node) && node.isTypeOnly;
2979
- const isTypeOnlyReexportAll = (node) => [
3038
+ const isTypeOnlyReexportAll = (node) => pipe([
2980
3039
  node.isTypeOnly,
2981
3040
  Predicate.isNotUndefined(node.moduleSpecifier),
2982
3041
  Predicate.isUndefined(node.exportClause)
2983
- ].every(Boolean);
3042
+ ], Array$1.every(Boolean));
2984
3043
  const TYPE_ONLY_RULES = [
2985
3044
  rule(isImportSpecifier, (specifier) => specifier.isTypeOnly || isTypeOnlyImportClause(specifier.parent.parent)),
2986
3045
  rule(isNamespaceImport, (namespace) => isTypeOnlyImportClause(namespace.parent)),
@@ -3008,8 +3067,8 @@ const isListType = (checker, type) => checker.isArrayType(type) || checker.isTup
3008
3067
  const shouldTreatPropertiesAsExports = (checker, type) => !hasFlag(type.flags, TypeFlags.Primitive) && !isClassInstanceType(type) && !isListType(checker, type);
3009
3068
  const expandosOf = (symbol, properties) => {
3010
3069
  if (isCheckerSymbol(symbol)) return [];
3011
- const names = new Set(properties.map((property) => property.name));
3012
- return boundExpandoExports(symbol).filter((member) => !names.has(member.name));
3070
+ const names = new Set(pipe(properties, Array$1.map((property) => property.name)));
3071
+ return pipe(boundExpandoExports(symbol), Array$1.filter((member) => !names.has(member.name)));
3013
3072
  };
3014
3073
  const propertiesAsExports = (session, symbol, exportEquals) => {
3015
3074
  const type = session.checker.getTypeOfSymbol(exportEquals);
@@ -3024,7 +3083,7 @@ const exportsAndPropertiesOf = (session, symbol) => {
3024
3083
  if (exportEquals.id === moduleSymbol.id) return exports;
3025
3084
  return [...exports, ...propertiesAsExports(session, symbol, exportEquals)];
3026
3085
  };
3027
- const aliasHasTypeOnlyDeclaration = (session, symbol) => symbol.declarations.some((handle) => Option.fromNullishOr(handle.resolve(session.project)).pipe(Option.exists((declaration) => isTypeOnlyImportOrExportDeclaration(declaration))));
3086
+ const aliasHasTypeOnlyDeclaration = (session, symbol) => pipe(symbol.declarations, Array$1.some((handle) => Option.fromNullishOr(handle.resolve(session.project)).pipe(Option.exists((declaration) => isTypeOnlyImportOrExportDeclaration(declaration)))));
3028
3087
  const aliasChainIsTypeOnly = (session, symbol) => {
3029
3088
  const seen = /* @__PURE__ */ new Set();
3030
3089
  const isUnvisitedAlias = (candidate) => isAlias(candidate) && !seen.has(candidate.id);
@@ -3066,6 +3125,8 @@ const createTypeChecker = (program) => {
3066
3125
  };
3067
3126
  };
3068
3127
  // src/attw/package-json.ts
3128
+ const DATA_FIRST_ARITY$18 = 2;
3129
+ const DATA_FIRST_ARITY_3$12 = 3;
3069
3130
  const PACKAGE_JSON = "package.json";
3070
3131
  const NODE_MODULES = "node_modules";
3071
3132
  const SEPARATOR_LENGTH = 1;
@@ -3093,8 +3154,8 @@ const createPackageJsonCache = () => {
3093
3154
  }
3094
3155
  };
3095
3156
  };
3096
- const parseJson = (text) => Option.liftThrowable((source) => JSON.parse(source))(text.replace(BYTE_ORDER_MARK, ""));
3097
- const readJson = (path, state) => state.host.readFile(path).pipe(Option.flatMap((text) => parseJson(text)), Option.map((value) => asRecord(value)), Option.getOrElse(() => ({})));
3157
+ const parseText = (text) => parseJson(String$1.replace(BYTE_ORDER_MARK, "")(text));
3158
+ const readJson = (path, state) => state.host.readFile(path).pipe(Option.flatMap((text) => parseText(text)), Option.map((value) => asRecord(value)), Option.getOrElse(() => ({})));
3098
3159
  const reuseCachedWithTrace$1 = ({ packageDirectory, packageJsonPath }, entry, state) => {
3099
3160
  if (entry.kind === "found") {
3100
3161
  traceMessage(state, Messages.fileExistsCached, packageJsonPath);
@@ -3136,7 +3197,7 @@ const resolveAndCacheWithTrace = (location, state) => {
3136
3197
  });
3137
3198
  return Option.none();
3138
3199
  };
3139
- const resolvePackageJsonInfo = (packageDirectory, onlyRecordFailures, state) => {
3200
+ const resolvePackageJsonInfo = Function.dual(DATA_FIRST_ARITY_3$12, (packageDirectory, onlyRecordFailures, state) => {
3140
3201
  if (onlyRecordFailures) return Option.none();
3141
3202
  const location = {
3142
3203
  packageDirectory,
@@ -3146,8 +3207,8 @@ const resolvePackageJsonInfo = (packageDirectory, onlyRecordFailures, state) =>
3146
3207
  onNone: () => resolveAndCacheWithTrace(location, state),
3147
3208
  onSome: (entry) => reuseCachedWithTrace$1(location, entry, state)
3148
3209
  }));
3149
- };
3150
- const getPackageScopeForPath = (directory, state) => forEachAncestorDirectory$1(directory, (ancestor) => resolvePackageJsonInfo(ancestor, false, state));
3210
+ });
3211
+ const getPackageScopeForPath = Function.dual(DATA_FIRST_ARITY$18, (directory, state) => forEachAncestorDirectory$1(directory, (ancestor) => resolvePackageJsonInfo(ancestor, false, state)));
3151
3212
  const peerVersion = (peer, nodeModules, state) => resolvePackageJsonInfo(`${nodeModules}${peer}`, false, state).pipe(Option.match({
3152
3213
  onNone: () => {
3153
3214
  traceMessage(state, Messages.failedToFindPeerDependency, peer);
@@ -3159,14 +3220,20 @@ const peerVersion = (peer, nodeModules, state) => resolvePackageJsonInfo(`${node
3159
3220
  return `+${peer}@${version}`;
3160
3221
  }
3161
3222
  }));
3162
- const nodeModulesOf = (packageDirectory) => `${packageDirectory.slice(EMPTY$5, packageDirectory.lastIndexOf(NODE_MODULES) + 12)}/`;
3223
+ const nodeModulesOf = (packageDirectory) => {
3224
+ const end = Option.match(String$1.lastIndexOf(NODE_MODULES)(packageDirectory), {
3225
+ onNone: () => packageDirectory.length,
3226
+ onSome: (index) => index + 12
3227
+ });
3228
+ return `${String$1.slice(EMPTY$5, end)(packageDirectory)}/`;
3229
+ };
3163
3230
  const resolvePeerDependenciesWithTrace = (info, state) => resolvePackageJsonFieldWithTrace(info.contents.packageJsonContent, {
3164
3231
  field: "peerDependencies",
3165
3232
  expected: "object"
3166
3233
  }, state).pipe(Option.map((peers) => {
3167
3234
  traceMessage(state, Messages.packageJsonHasPeerDependencies);
3168
3235
  const nodeModules = nodeModulesOf(info.packageDirectory);
3169
- return Record.keys(asRecord(peers)).map((peer) => peerVersion(peer, nodeModules, state)).join("");
3236
+ return pipe(Record.keys(asRecord(peers)), Array$1.map((peer) => peerVersion(peer, nodeModules, state)), Array$1.join(""));
3170
3237
  }), Option.filter((joined) => String$1.isNonEmpty(joined)));
3171
3238
  const getPeerDependencies = (info, state) => info.contents.peerDependencies(() => resolvePeerDependenciesWithTrace(info, state)).pipe(Option.getOrElse(() => ""));
3172
3239
  const packageIdOf = (info, resolved, state) => {
@@ -3174,70 +3241,67 @@ const packageIdOf = (info, resolved, state) => {
3174
3241
  if (!Predicate.isString(name) || !Predicate.isString(version)) return Option.none();
3175
3242
  return Option.some({
3176
3243
  name,
3177
- subModuleName: resolved.path.slice(info.packageDirectory.length + SEPARATOR_LENGTH),
3244
+ subModuleName: String$1.slice(info.packageDirectory.length + SEPARATOR_LENGTH)(resolved.path),
3178
3245
  version,
3179
3246
  peerDependencies: getPeerDependencies(info, state)
3180
3247
  });
3181
3248
  };
3182
- const withPackageId = (info, resolved, state) => resolved.pipe(Option.map((value) => ({
3249
+ const withPackageId = Function.dual(DATA_FIRST_ARITY_3$12, (info, resolved, state) => resolved.pipe(Option.map((value) => ({
3183
3250
  path: value.path,
3184
3251
  extension: value.extension,
3185
3252
  resolvedUsingTsExtension: value.resolvedUsingTsExtension,
3186
3253
  packageId: info.pipe(Option.flatMap((packageInfo) => packageIdOf(packageInfo, value, state))),
3187
3254
  originalPath: Option.none()
3188
- })));
3255
+ }))));
3189
3256
  const qualifiedName = (packageId) => {
3190
3257
  if (packageId.subModuleName.length > EMPTY$5) return `${packageId.name}/${packageId.subModuleName}`;
3191
3258
  return packageId.name;
3192
3259
  };
3193
3260
  const packageIdToString = (packageId) => `${qualifiedName(packageId)}@${packageId.version}${packageId.peerDependencies}`;
3194
3261
  // src/attw/resolver-patterns.ts
3195
- const NOT_FOUND$3 = -1;
3262
+ const DATA_FIRST_ARITY$17 = 2;
3263
+ const DATA_FIRST_ARITY_3$11 = 3;
3264
+ const NOT_FOUND = -1;
3196
3265
  const STAR_LENGTH$1 = 1;
3197
3266
  const START$3 = 0;
3198
3267
  const BEFORE = -1;
3199
3268
  const AFTER = 1;
3200
3269
  const EQUAL = 0;
3201
- const baseLength = (key) => {
3202
- const star = key.indexOf("*");
3203
- if (star === NOT_FOUND$3) return key.length;
3204
- return star + STAR_LENGTH$1;
3205
- };
3270
+ const baseLength = (key) => Option.match(String$1.indexOf("*")(key), {
3271
+ onNone: () => key.length,
3272
+ onSome: (star) => star + STAR_LENGTH$1
3273
+ });
3206
3274
  const KEY_ORDER_RULES = [
3207
3275
  ({ left, right }) => Option.liftPredicate(Math.sign(baseLength(right) - baseLength(left)), (sign) => sign !== EQUAL),
3208
- ({ left }) => Option.liftPredicate(AFTER, () => !left.includes("*")),
3209
- ({ right }) => Option.liftPredicate(BEFORE, () => !right.includes("*"))
3276
+ ({ left }) => Option.liftPredicate(AFTER, () => !String$1.includes("*")(left)),
3277
+ ({ right }) => Option.liftPredicate(BEFORE, () => !String$1.includes("*")(right))
3210
3278
  ];
3211
- const comparePatternKeys = (left, right) => Array$1.findFirst(KEY_ORDER_RULES, (rule) => rule({
3279
+ const comparePatternKeys = Function.dual(DATA_FIRST_ARITY$17, (left, right) => Array$1.findFirst(KEY_ORDER_RULES, (rule) => rule({
3212
3280
  left,
3213
3281
  right
3214
- })).pipe(Option.getOrElse(() => Math.sign(right.length - left.length)));
3215
- const hasOneAsterisk = (key) => {
3216
- const first = key.indexOf("*");
3217
- return first !== NOT_FOUND$3 && first === key.lastIndexOf("*");
3218
- };
3219
- const matchesPatternWithTrailer = (target, name) => {
3220
- const star = target.indexOf("*");
3221
- return !target.endsWith("*") && star !== NOT_FOUND$3 && name.startsWith(target.slice(START$3, star)) && name.endsWith(target.slice(star + STAR_LENGTH$1));
3222
- };
3223
- const trailerExpansion = (key, name, state) => Option.liftPredicate(key, (candidate) => state.features.patternTrailers && matchesPatternWithTrailer(candidate, name)).pipe(Option.map((candidate) => {
3224
- const star = candidate.indexOf("*");
3282
+ })).pipe(Option.getOrElse(() => Math.sign(right.length - left.length))));
3283
+ const hasOneAsterisk = (key) => Option.exists(String$1.indexOf("*")(key), (first) => Option.contains(String$1.lastIndexOf("*")(key), first));
3284
+ const surroundsName = (target, star, name) => String$1.startsWith(String$1.slice(START$3, star)(target))(name) && String$1.endsWith(String$1.slice(star + STAR_LENGTH$1)(target))(name);
3285
+ const matchesPatternWithTrailer = (target, name) => !String$1.endsWith("*")(target) && Option.exists(String$1.indexOf("*")(target), (star) => surroundsName(target, star, name));
3286
+ const trailerExpansion = (key, name, state) => Option.liftPredicate(key, (candidate) => state.features.patternTrailers && matchesPatternWithTrailer(candidate, name)).pipe(Option.flatMap((candidate) => Option.map(String$1.indexOf("*")(candidate), (star) => {
3225
3287
  const end = name.length - (candidate.length - STAR_LENGTH$1 - star);
3226
3288
  return {
3227
- subpath: name.slice(star, end),
3289
+ subpath: String$1.slice(star, end)(name),
3228
3290
  pattern: true
3229
3291
  };
3230
- }));
3292
+ })));
3231
3293
  const starSuffixExpansion = (key, name) => Option.liftPredicate({
3232
- subpath: name.slice(key.length - STAR_LENGTH$1),
3294
+ subpath: String$1.slice(key.length - STAR_LENGTH$1)(name),
3233
3295
  pattern: true
3234
- }, () => key.endsWith("*") && name.startsWith(key.slice(START$3, NOT_FOUND$3)));
3296
+ }, () => String$1.endsWith("*")(key) && String$1.startsWith(String$1.slice(START$3, NOT_FOUND)(key))(name));
3235
3297
  const prefixExpansion = (key, name) => Option.liftPredicate({
3236
- subpath: name.slice(key.length),
3298
+ subpath: String$1.slice(key.length)(name),
3237
3299
  pattern: false
3238
- }, () => name.startsWith(key));
3239
- const expandedSubpath = (key, name, state) => trailerExpansion(key, name, state).pipe(Option.orElse(() => starSuffixExpansion(key, name)), Option.orElse(() => prefixExpansion(key, name)));
3300
+ }, () => String$1.startsWith(key)(name));
3301
+ const expandedSubpath = Function.dual(DATA_FIRST_ARITY_3$11, (key, name, state) => trailerExpansion(key, name, state).pipe(Option.orElse(() => starSuffixExpansion(key, name)), Option.orElse(() => prefixExpansion(key, name))));
3240
3302
  // src/attw/resolver-files.ts
3303
+ const DATA_FIRST_ARITY$16 = 2;
3304
+ const DATA_FIRST_ARITY_3$10 = 3;
3241
3305
  const attempt = (kind, extension, usingTsExtension = false) => ({
3242
3306
  kind,
3243
3307
  extension,
@@ -3304,7 +3368,7 @@ const attemptsFor = (candidate, original) => Option.fromNullishOr(ATTEMPTS_BY_EX
3304
3368
  onSome: (attempts) => attempts(original)
3305
3369
  }));
3306
3370
  const NONE = 0;
3307
- const tryFile = (fileName, onlyRecordFailures, state) => {
3371
+ const tryFile = Function.dual(DATA_FIRST_ARITY_3$10, (fileName, onlyRecordFailures, state) => {
3308
3372
  if (onlyRecordFailures) return Option.none();
3309
3373
  if (state.host.fileExists(fileName)) {
3310
3374
  traceMessage(state, Messages.fileExistsUseIt, fileName);
@@ -3312,7 +3376,7 @@ const tryFile = (fileName, onlyRecordFailures, state) => {
3312
3376
  }
3313
3377
  traceMessage(state, Messages.fileDoesNotExist, fileName);
3314
3378
  return Option.none();
3315
- };
3379
+ });
3316
3380
  const directoryProbablyMissing = (candidate, state) => {
3317
3381
  const directory = getDirectoryPath(candidate);
3318
3382
  return directory.length > NONE && !state.host.directoryExists(directory);
@@ -3324,15 +3388,18 @@ const tryAttempt = (candidate, { extension, usingTsExtension }, state) => tryFil
3324
3388
  })));
3325
3389
  const tryAddingExtensions = (request, state) => {
3326
3390
  if (request.onlyRecordFailures || directoryProbablyMissing(request.candidate, state)) return Option.none();
3327
- const attempts = attemptsFor(request.candidate, request.originalExtension).filter(({ kind }) => request.extensions.includes(kind));
3391
+ const attempts = pipe(attemptsFor(request.candidate, request.originalExtension), Array$1.filter(({ kind }) => request.extensions.includes(kind)));
3328
3392
  return Array$1.findFirst(attempts, (current) => tryAttempt(request.candidate, current, state));
3329
3393
  };
3330
3394
  const resolveBySwappingExtensionWithTrace = (request, state) => {
3331
3395
  const { candidate } = request;
3332
- if (!getBaseFileName(candidate).includes(".")) return Option.none();
3396
+ if (!String$1.includes(".")(getBaseFileName(candidate))) return Option.none();
3333
3397
  const removed = removeFileExtension(candidate);
3334
- const extensionless = Option.liftPredicate(removed, (path) => path !== candidate).pipe(Option.getOrElse(() => candidate.slice(NONE, candidate.lastIndexOf("."))));
3335
- const extension = candidate.slice(extensionless.length);
3398
+ const extensionless = Option.liftPredicate(removed, (path) => path !== candidate).pipe(Option.getOrElse(() => Option.match(String$1.lastIndexOf(".")(candidate), {
3399
+ onNone: () => candidate,
3400
+ onSome: (dot) => String$1.slice(NONE, dot)(candidate)
3401
+ })));
3402
+ const extension = String$1.slice(extensionless.length)(candidate);
3336
3403
  traceMessage(state, Messages.fileHasExtensionStripping, candidate, extension);
3337
3404
  return tryAddingExtensions({
3338
3405
  ...request,
@@ -3340,11 +3407,11 @@ const resolveBySwappingExtensionWithTrace = (request, state) => {
3340
3407
  originalExtension: extension
3341
3408
  }, state);
3342
3409
  };
3343
- const loadModuleFromFile = (request, state) => resolveBySwappingExtensionWithTrace(request, state).pipe(Option.orElse(() => Option.liftPredicate(state, ({ features }) => !features.esmMode).pipe(Option.flatMap(() => tryAddingExtensions({
3410
+ const loadModuleFromFile = Function.dual(DATA_FIRST_ARITY$16, (request, state) => resolveBySwappingExtensionWithTrace(request, state).pipe(Option.orElse(() => Option.liftPredicate(state, ({ features }) => !features.esmMode).pipe(Option.flatMap(() => tryAddingExtensions({
3344
3411
  ...request,
3345
3412
  originalExtension: ""
3346
- }, state)))));
3347
- const loadFileNameFromPackageJsonField = (request, state) => {
3413
+ }, state))))));
3414
+ const loadFileNameFromPackageJsonField = Function.dual(DATA_FIRST_ARITY$16, (request, state) => {
3348
3415
  const { candidate } = request;
3349
3416
  if (!isTSFileExtensionForPackageField(request.extensions, candidate)) return resolveBySwappingExtensionWithTrace(request, state);
3350
3417
  return tryFile(candidate, request.onlyRecordFailures, state).pipe(Option.map(() => ({
@@ -3352,8 +3419,9 @@ const loadFileNameFromPackageJsonField = (request, state) => {
3352
3419
  extension: Option.getOrElse(tryExtractTSExtension(candidate), () => ""),
3353
3420
  resolvedUsingTsExtension: false
3354
3421
  })));
3355
- };
3422
+ });
3356
3423
  // src/attw/resolver-target.ts
3424
+ const DATA_FIRST_ARITY_3$9 = 3;
3357
3425
  const FORBIDDEN_SEGMENTS = /* @__PURE__ */ new Set([
3358
3426
  "..",
3359
3427
  ".",
@@ -3374,10 +3442,10 @@ const fieldName = (context) => {
3374
3442
  return "exports";
3375
3443
  };
3376
3444
  const substitute = (target, request) => {
3377
- if (request.pattern) return target.replaceAll("*", request.subpath);
3445
+ if (request.pattern) return String$1.replaceAll("*", request.subpath)(target);
3378
3446
  return `${target}${request.subpath}`;
3379
3447
  };
3380
- const hasForbiddenSegment = (parts) => parts.some((part) => FORBIDDEN_SEGMENTS.has(part));
3448
+ const hasForbiddenSegment = (parts) => pipe(parts, Array$1.some((part) => FORBIDDEN_SEGMENTS.has(part)));
3381
3449
  const resolveImportToPackage = (target, { context, request }, state) => {
3382
3450
  const combinedLookup = substitute(target, request);
3383
3451
  const containingDirectory = `${context.scope.packageDirectory}/`;
@@ -3396,7 +3464,7 @@ const resolveImportToPackage = (target, { context, request }, state) => {
3396
3464
  resolvedUsingTsExtension: module.resolvedUsingTsExtension
3397
3465
  }))));
3398
3466
  };
3399
- const isPackageImportTarget = (target, context) => context.isImports && !target.startsWith("../") && !target.startsWith("/");
3467
+ const isPackageImportTarget = (target, context) => context.isImports && !String$1.startsWith("../")(target) && !String$1.startsWith("/")(target);
3400
3468
  const targetParts = (target) => {
3401
3469
  const parts = getPathComponents(target);
3402
3470
  if (pathIsRelative(target)) return parts.slice(FIRST_SEGMENT);
@@ -3414,8 +3482,8 @@ const resolveRelativeTargetWithTrace = (target, site, state) => {
3414
3482
  }, state);
3415
3483
  return asSearchResult(withPackageId(Option.some(context.scope), loaded, state));
3416
3484
  };
3417
- const STRING_TARGET_LOADERS = [[(target) => target.startsWith("./"), resolveRelativeTargetWithTrace], [isPackageImportTarget, resolveImportToPackage]];
3418
- const isMissingTrailingSlash = (target, request) => !request.pattern && request.subpath.length > EMPTY$4 && !target.endsWith("/");
3485
+ const STRING_TARGET_LOADERS = [[(target) => String$1.startsWith("./")(target), resolveRelativeTargetWithTrace], [isPackageImportTarget, resolveImportToPackage]];
3486
+ const isMissingTrailingSlash = (target, request) => !request.pattern && request.subpath.length > EMPTY$4 && !String$1.endsWith("/")(target);
3419
3487
  const loadStringTarget = (target, site, state) => {
3420
3488
  if (isMissingTrailingSlash(target, site.request)) return invalidTarget(site, state);
3421
3489
  return Array$1.findFirst(STRING_TARGET_LOADERS, ([applies]) => applies(target, site.context)).pipe(Option.match({
@@ -3424,8 +3492,8 @@ const loadStringTarget = (target, site, state) => {
3424
3492
  }));
3425
3493
  };
3426
3494
  const isApplicableVersionedTypesKey = (conditions, key) => {
3427
- const range = key.slice(6);
3428
- return conditions.includes("types") && key.startsWith(VERSIONED_TYPES_PREFIX) && Predicate.isNotNull(semver.validRange(range, RANGE_OPTIONS)) && semver.satisfies("5.6.1-rc", range, RANGE_OPTIONS);
3495
+ const range = String$1.slice(6)(key);
3496
+ return conditions.includes("types") && String$1.startsWith(VERSIONED_TYPES_PREFIX)(key) && Predicate.isNotNull(semver.validRange(range, RANGE_OPTIONS)) && semver.satisfies("5.6.1-rc", range, RANGE_OPTIONS);
3429
3497
  };
3430
3498
  const conditionMatches = (condition, state) => condition === "default" || state.conditions.includes(condition) || isApplicableVersionedTypesKey(state.conditions, condition);
3431
3499
  const tryCondition = (loadTarget, target) => (condition, site, state) => {
@@ -3462,15 +3530,19 @@ const loadScalarTarget = (target, site, state) => {
3462
3530
  return invalidTarget(site, state);
3463
3531
  };
3464
3532
  const loadStructuredTarget = (loadTarget) => (target, site, state) => {
3465
- if (Array.isArray(target)) return loadArrayTarget(loadTarget)(target, site, state);
3533
+ if (Array$1.isArray(target)) return loadArrayTarget(loadTarget)(target, site, state);
3466
3534
  if (Predicate.isObject(target)) return resolveConditionsWithTrace(loadTarget)(target, site, state);
3467
3535
  return loadScalarTarget(target, site, state);
3468
3536
  };
3469
- const loadTarget = (target, site, state) => {
3537
+ const loadTarget = Function.dual(DATA_FIRST_ARITY_3$9, (target, site, state) => {
3470
3538
  if (Predicate.isString(target)) return loadStringTarget(target, site, state);
3471
3539
  return loadStructuredTarget(loadTarget)(target, site, state);
3472
- };
3540
+ });
3473
3541
  // src/attw/resolver-exports.ts
3542
+ const DATA_FIRST_ARITY_3$8 = 3;
3543
+ const DATA_FIRST_ARITY$15 = 2;
3544
+ const SAME_ORDER = 0;
3545
+ const patternKeyOrder = (left, right) => Order.Number(comparePatternKeys(left, right), SAME_ORDER);
3474
3546
  const expandKey = (key, site, state) => expandedSubpath(key, site.context.moduleName, state).pipe(Option.map((expansion) => loadTarget(site.lookupTable[key], {
3475
3547
  context: site.context,
3476
3548
  request: {
@@ -3481,7 +3553,7 @@ const expandKey = (key, site, state) => expandedSubpath(key, site.context.module
3481
3553
  const loadModuleFromImportsOrExports = (site, state) => {
3482
3554
  const { context, lookupTable } = site;
3483
3555
  const name = context.moduleName;
3484
- if (!name.endsWith("/") && !name.includes("*") && Object.hasOwn(lookupTable, name)) return loadTarget(lookupTable[name], {
3556
+ if (!String$1.endsWith("/")(name) && !String$1.includes("*")(name) && Record.has(lookupTable, name)) return loadTarget(lookupTable[name], {
3485
3557
  context,
3486
3558
  request: {
3487
3559
  subpath: "",
@@ -3489,15 +3561,15 @@ const loadModuleFromImportsOrExports = (site, state) => {
3489
3561
  key: name
3490
3562
  }
3491
3563
  }, state);
3492
- const expandingKeys = Record.keys(lookupTable).filter((key) => hasOneAsterisk(key) || key.endsWith("/")).toSorted(comparePatternKeys);
3564
+ const expandingKeys = pipe(Record.keys(lookupTable), Array$1.filter((key) => hasOneAsterisk(key) || String$1.endsWith("/")(key)), (keys) => Array$1.sort(keys, patternKeyOrder));
3493
3565
  return Array$1.findFirst(expandingKeys, (key) => expandKey(key, site, state)).pipe(Option.flatten);
3494
3566
  };
3495
- const noKeyStartsWithDot = (value) => !Record.keys(value).some((key) => key.startsWith("."));
3496
- const allKeysStartWithDot = (value) => Record.keys(value).every((key) => key.startsWith("."));
3497
- const isDirectExport = (exports) => Predicate.isString(exports) || Array.isArray(exports);
3567
+ const noKeyStartsWithDot = (value) => !pipe(Record.keys(value), Array$1.some((key) => String$1.startsWith(".")(key)));
3568
+ const allKeysStartWithDot = (value) => pipe(Record.keys(value), Array$1.every((key) => String$1.startsWith(".")(key)));
3569
+ const isDirectExport = (exports) => Predicate.isString(exports) || Array$1.isArray(exports);
3498
3570
  const objectMainExport = (exports) => {
3499
3571
  if (noKeyStartsWithDot(exports)) return Option.some(exports);
3500
- return Option.liftPredicate(exports["."], Predicate.isTruthy).pipe(Option.filter(() => Object.hasOwn(exports, ".")));
3572
+ return Option.liftPredicate(exports["."], Predicate.isTruthy).pipe(Option.filter(() => Record.has(exports, ".")));
3501
3573
  };
3502
3574
  const mainExportOf = (exports) => {
3503
3575
  if (isDirectExport(exports)) return Option.some(exports);
@@ -3514,7 +3586,7 @@ const loadSubpathExport = (exports, context, state) => {
3514
3586
  context
3515
3587
  }, state).pipe(Option.orElse(() => exportDoesNotExist(context, state)));
3516
3588
  };
3517
- const loadModuleFromExports = (scope, { extensions, subpath }, state) => {
3589
+ const loadModuleFromExports = Function.dual(DATA_FIRST_ARITY_3$8, (scope, { extensions, subpath }, state) => {
3518
3590
  const { exports } = scope.contents.packageJsonContent;
3519
3591
  if (!Predicate.isTruthy(exports)) return Option.none();
3520
3592
  const context = {
@@ -3535,7 +3607,7 @@ const loadModuleFromExports = (scope, { extensions, subpath }, state) => {
3535
3607
  }
3536
3608
  }, state)
3537
3609
  }));
3538
- };
3610
+ });
3539
3611
  const asLookupTable = (value) => Option.liftPredicate(value, Predicate.isObject).pipe(Option.getOrElse(() => ({})));
3540
3612
  const reportMissingImport = (context, state) => {
3541
3613
  traceMessage(state, Messages.importSpecifierDoesNotExist, context.moduleName, context.scope.packageDirectory);
@@ -3562,9 +3634,9 @@ const reportMissingScope = (directoryPath, state) => {
3562
3634
  traceMessage(state, Messages.directoryHasNoPackageScope, directoryPath);
3563
3635
  return notFound;
3564
3636
  };
3565
- const resolvePackageImportWithTrace = (lookup, state) => {
3637
+ const resolvePackageImportWithTrace = Function.dual(DATA_FIRST_ARITY$15, (lookup, state) => {
3566
3638
  const { moduleName } = lookup;
3567
- if (moduleName === "#" || moduleName.startsWith("#/")) {
3639
+ if (moduleName === "#" || String$1.startsWith("#/")(moduleName)) {
3568
3640
  traceMessage(state, Messages.invalidImportSpecifier, moduleName);
3569
3641
  return notFound;
3570
3642
  }
@@ -3573,13 +3645,13 @@ const resolvePackageImportWithTrace = (lookup, state) => {
3573
3645
  onNone: () => reportMissingScope(directoryPath, state),
3574
3646
  onSome: (scope) => resolveImportsWithTrace(lookup, scope, state)
3575
3647
  }));
3576
- };
3648
+ });
3577
3649
  const selfNameSubpath = (moduleName, packageName) => {
3578
3650
  const parts = getPathComponents(moduleName);
3579
3651
  const nameParts = getPathComponents(packageName);
3580
- if (!nameParts.every((part, index) => parts[index] === part)) return Option.none();
3652
+ if (!pipe(nameParts, Array$1.every((part, index) => parts[index] === part))) return Option.none();
3581
3653
  const trailing = parts.slice(nameParts.length);
3582
- if (Array$1.isReadonlyArrayNonEmpty(trailing)) return Option.some(`./${trailing.join("/")}`);
3654
+ if (Array$1.isReadonlyArrayNonEmpty(trailing)) return Option.some(`./${pipe(trailing, Array$1.join("/"))}`);
3583
3655
  return Option.some(".");
3584
3656
  };
3585
3657
  const loadFromOwnExports = (scope, { extensions, subpath }, state) => loadModuleFromExports(scope, {
@@ -3589,29 +3661,29 @@ const loadFromOwnExports = (scope, { extensions, subpath }, state) => loadModule
3589
3661
  extensions: subtractExtensions(extensions, PRIORITY_KINDS),
3590
3662
  subpath
3591
3663
  }, state)));
3592
- const loadModuleFromSelfNameReference = (lookup, state) => getPackageScopeForPath(getNormalizedAbsolutePath(lookup.directory, "/"), state).pipe(Option.filter((scope) => Predicate.isTruthy(scope.contents.packageJsonContent["exports"])), Option.flatMap((scope) => Option.liftPredicate(scope.contents.packageJsonContent["name"], Predicate.isString).pipe(Option.flatMap((name) => selfNameSubpath(lookup.moduleName, name)), Option.flatMap((subpath) => loadFromOwnExports(scope, {
3664
+ const loadModuleFromSelfNameReference = Function.dual(DATA_FIRST_ARITY$15, (lookup, state) => getPackageScopeForPath(getNormalizedAbsolutePath(lookup.directory, "/"), state).pipe(Option.filter((scope) => Predicate.isTruthy(scope.contents.packageJsonContent["exports"])), Option.flatMap((scope) => Option.liftPredicate(scope.contents.packageJsonContent["name"], Predicate.isString).pipe(Option.flatMap((name) => selfNameSubpath(lookup.moduleName, name)), Option.flatMap((subpath) => loadFromOwnExports(scope, {
3593
3665
  extensions: lookup.extensions,
3594
3666
  subpath
3595
- }, state)))));
3667
+ }, state))))));
3596
3668
  // src/attw/paths-mapping.ts
3597
- const NOT_FOUND$2 = -1;
3669
+ const DATA_FIRST_ARITY$14 = 2;
3598
3670
  const STAR_LENGTH = 1;
3599
3671
  const START$2 = 0;
3600
- const tryParsePattern = (key) => {
3601
- const star = key.indexOf("*");
3602
- if (star === NOT_FOUND$2) return Option.some({
3672
+ const patternAt = (key, star) => Option.liftPredicate(key, (text) => !String$1.includes("*", star + STAR_LENGTH)(text)).pipe(Option.map((text) => ({
3673
+ kind: "pattern",
3674
+ pattern: {
3675
+ prefix: String$1.slice(START$2, star)(text),
3676
+ suffix: String$1.slice(star + STAR_LENGTH)(text)
3677
+ }
3678
+ })));
3679
+ const tryParsePattern = (key) => Option.match(String$1.indexOf("*")(key), {
3680
+ onNone: () => Option.some({
3603
3681
  kind: "exact",
3604
3682
  text: key
3605
- });
3606
- return Option.liftPredicate(key, (text) => !text.includes("*", star + STAR_LENGTH)).pipe(Option.map((text) => ({
3607
- kind: "pattern",
3608
- pattern: {
3609
- prefix: text.slice(START$2, star),
3610
- suffix: text.slice(star + STAR_LENGTH)
3611
- }
3612
- })));
3613
- };
3614
- const isPatternMatch = ({ prefix, suffix }, candidate) => candidate.length >= prefix.length + suffix.length && candidate.startsWith(prefix) && candidate.endsWith(suffix);
3683
+ }),
3684
+ onSome: (star) => patternAt(key, star)
3685
+ });
3686
+ const isPatternMatch = ({ prefix, suffix }, candidate) => candidate.length >= prefix.length + suffix.length && String$1.startsWith(prefix)(candidate) && String$1.endsWith(suffix)(candidate);
3615
3687
  const bestPattern = (patterns, candidate) => Array$1.reduce(patterns, Option.none(), (best, pattern) => Option.liftPredicate(pattern, (current) => isPatternMatch(current, candidate) && Option.match(best, {
3616
3688
  onNone: () => true,
3617
3689
  onSome: (previous) => current.prefix.length > previous.prefix.length
@@ -3620,18 +3692,23 @@ const patternOf = (entry) => {
3620
3692
  if (entry.kind === "pattern") return Option.some(entry.pattern);
3621
3693
  return Option.none();
3622
3694
  };
3623
- const matchPatternOrExact = (entries, candidate) => pipe(entries, Array$1.findFirst((entry) => entry.kind === "exact" && entry.text === candidate)).pipe(Option.map(() => ({
3695
+ const matchedBy = (candidate) => (pattern) => ({
3696
+ text: `${pattern.prefix}*${pattern.suffix}`,
3697
+ star: String$1.slice(pattern.prefix.length, candidate.length - pattern.suffix.length)(candidate)
3698
+ });
3699
+ const patternMatch = (entries, candidate) => {
3700
+ const patterns = pipe(entries, Array$1.map((entry) => patternOf(entry)), Array$1.getSomes);
3701
+ return Option.map(bestPattern(patterns, candidate), matchedBy(candidate));
3702
+ };
3703
+ const matchPatternOrExact = (entries, candidate) => pipe(entries, Array$1.findFirst((entry) => entry.kind === "exact" && entry.text === candidate), Option.map(() => ({
3624
3704
  text: candidate,
3625
3705
  star: ""
3626
- })), Option.orElse(() => bestPattern(Array$1.getSomes(entries.map((entry) => patternOf(entry))), candidate).pipe(Option.map((pattern) => ({
3627
- text: `${pattern.prefix}*${pattern.suffix}`,
3628
- star: candidate.slice(pattern.prefix.length, candidate.length - pattern.suffix.length)
3629
- })))));
3630
- const substitutionsOf = (paths, key) => Option.fromNullishOr(paths[key]).pipe(Option.filter((value) => Array.isArray(value)), Option.map((values) => values.filter((value) => Predicate.isString(value))), Option.getOrElse(() => []));
3706
+ })), Option.orElse(() => patternMatch(entries, candidate)));
3707
+ const substitutionsOf = (paths, key) => Option.fromNullishOr(paths[key]).pipe(Option.filter((value) => Array$1.isArray(value)), Option.map((values) => pipe(values, Array$1.filter((value) => Predicate.isString(value)))), Option.getOrElse(() => []));
3631
3708
  const trySubstitution = ({ text, matched }, context, state) => {
3632
3709
  const path = Option.liftPredicate(matched.star, (star) => star.length > START$2).pipe(Option.match({
3633
3710
  onNone: () => text,
3634
- onSome: (star) => text.replace("*", star)
3711
+ onSome: (star) => String$1.replace("*", star)(text)
3635
3712
  }));
3636
3713
  const candidate = normalizePath(combinePaths(context.baseDirectory, path));
3637
3714
  traceMessage(state, Messages.tryingSubstitution, text, path);
@@ -3645,8 +3722,8 @@ const trySubstitution = ({ text, matched }, context, state) => {
3645
3722
  onlyRecordFailures: context.onlyRecordFailures || !state.host.directoryExists(getDirectoryPath(candidate))
3646
3723
  }, state)));
3647
3724
  };
3648
- const tryLoadModuleUsingPaths = (context, state) => {
3649
- const entries = Array$1.getSomes(Record.keys(context.paths).map((key) => tryParsePattern(key)));
3725
+ const tryLoadModuleUsingPaths = Function.dual(DATA_FIRST_ARITY$14, (context, state) => {
3726
+ const entries = Array$1.getSomes(pipe(Record.keys(context.paths), Array$1.map((key) => tryParsePattern(key))));
3650
3727
  return matchPatternOrExact(entries, context.moduleName).pipe(Option.map((matched) => {
3651
3728
  traceMessage(state, Messages.matchedPattern, context.moduleName, matched.text);
3652
3729
  return pipe(substitutionsOf(context.paths, matched.text), Array$1.findFirst((text) => trySubstitution({
@@ -3654,8 +3731,9 @@ const tryLoadModuleUsingPaths = (context, state) => {
3654
3731
  matched
3655
3732
  }, context, state)));
3656
3733
  }));
3657
- };
3734
+ });
3658
3735
  // src/attw/resolver-directory.ts
3736
+ const DATA_FIRST_ARITY$13 = 2;
3659
3737
  const DECLARATION_ONLY_SIZE = 1;
3660
3738
  const INDEX = "index";
3661
3739
  const expandDeclarationOnly = (extensions) => {
@@ -3726,11 +3804,11 @@ const fromPackageFileOrIndex = (request, entry, state) => entry.packageFile.pipe
3726
3804
  candidate: file,
3727
3805
  onlyRecordFailures: entry.onlyRecordFailuresForPackageFile
3728
3806
  }, state)), Option.orElse(() => fromIndexFile(request, entry, state)));
3729
- const loadNodeModuleFromDirectoryWorker = (request, state) => {
3807
+ const loadNodeModuleFromDirectoryWorker = Function.dual(DATA_FIRST_ARITY$13, (request, state) => {
3730
3808
  const entry = packageEntryOf(request, state);
3731
3809
  return fromVersionPaths(request, entry, state).pipe(Option.getOrElse(() => fromPackageFileOrIndex(request, entry, state)));
3732
- };
3733
- const loadNodeModuleFromDirectory = (request, state) => {
3810
+ });
3811
+ const loadNodeModuleFromDirectory = Function.dual(DATA_FIRST_ARITY$13, (request, state) => {
3734
3812
  const info = Option.liftPredicate(request.considerPackageJson, (consider) => consider).pipe(Option.flatMap(() => resolvePackageJsonInfo(request.candidate, request.onlyRecordFailures, state)));
3735
3813
  const versionPaths = info.pipe(Option.flatMap((packageInfo) => getVersionPaths(packageInfo, state)));
3736
3814
  const jsonContent = info.pipe(Option.map((packageInfo) => packageInfo.contents.packageJsonContent));
@@ -3740,17 +3818,12 @@ const loadNodeModuleFromDirectory = (request, state) => {
3740
3818
  versionPaths
3741
3819
  }, state);
3742
3820
  return withPackageId(info, found, state);
3743
- };
3821
+ });
3744
3822
  // src/attw/node-modules-paths.ts
3745
- const NOT_FOUND$1 = -1;
3746
3823
  const START$1 = 0;
3747
3824
  const SEPARATOR_STEP = 1;
3748
3825
  const NODE_MODULES_PART = "/node_modules/";
3749
- const nextSeparator = (path, previous) => {
3750
- const index = path.indexOf("/", previous + SEPARATOR_STEP);
3751
- if (index === NOT_FOUND$1) return previous;
3752
- return index;
3753
- };
3826
+ const nextSeparator = (path, previous) => Option.getOrElse(indexFrom(path, "/", previous + SEPARATOR_STEP), () => previous);
3754
3827
  const packageDirectoryEnd = (path, nodeModulesIndex) => {
3755
3828
  const afterNodeModules = nodeModulesIndex + 14;
3756
3829
  const afterName = nextSeparator(path, afterNodeModules);
@@ -3759,12 +3832,12 @@ const packageDirectoryEnd = (path, nodeModulesIndex) => {
3759
3832
  };
3760
3833
  const parseNodeModuleFromPath = (resolved) => {
3761
3834
  const path = normalizePath(resolved);
3762
- const index = path.lastIndexOf(NODE_MODULES_PART);
3763
- if (index === NOT_FOUND$1) return Option.none();
3764
- return Option.some(path.slice(START$1, packageDirectoryEnd(path, index)));
3835
+ return Option.map(String$1.lastIndexOf(NODE_MODULES_PART)(path), (index) => String$1.slice(START$1, packageDirectoryEnd(path, index))(path));
3765
3836
  };
3766
- const pathContainsNodeModules = (path) => path.includes(NODE_MODULES_PART);
3837
+ const pathContainsNodeModules = (path) => String$1.includes(NODE_MODULES_PART)(path);
3767
3838
  // src/attw/resolver-state.ts
3839
+ const DATA_FIRST_ARITY$12 = 2;
3840
+ const DATA_FIRST_ARITY_3$7 = 3;
3768
3841
  const LAST = -1;
3769
3842
  const NO_FEATURES = {
3770
3843
  imports: false,
@@ -3801,12 +3874,12 @@ const moduleCondition = (esm) => {
3801
3874
  };
3802
3875
  const isUnconditional = (options, mode) => Option.isNone(mode) && options.moduleResolution === "Node10";
3803
3876
  const usesImportCondition = (options, mode) => mode.pipe(Option.map((kind) => kind === "ESNext"), Option.getOrElse(() => options.moduleResolution === "Bundler"));
3804
- const getConditions = (options, mode) => {
3877
+ const getConditions = Function.dual(DATA_FIRST_ARITY$12, (options, mode) => {
3805
3878
  if (isUnconditional(options, mode)) return [];
3806
- const optional = OPTIONAL_CONDITIONS.filter(([, applies]) => applies(options)).map(([name]) => name);
3879
+ const optional = pipe(OPTIONAL_CONDITIONS, Array$1.filter(([, applies]) => applies(options)), Array$1.map(([name]) => name));
3807
3880
  return [moduleCondition(usesImportCondition(options, mode)), ...optional];
3808
- };
3809
- const normalizePathForCJSResolution = (containingDirectory, moduleName) => {
3881
+ });
3882
+ const normalizePathForCJSResolution = Function.dual(DATA_FIRST_ARITY$12, (containingDirectory, moduleName) => {
3810
3883
  const combined = combinePaths(containingDirectory, moduleName);
3811
3884
  const parts = getPathComponents(combined);
3812
3885
  const last = parts.at(LAST) ?? "";
@@ -3819,26 +3892,26 @@ const normalizePathForCJSResolution = (containingDirectory, moduleName) => {
3819
3892
  path: normalized,
3820
3893
  parts
3821
3894
  };
3822
- };
3895
+ });
3823
3896
  const workerMode = (request) => {
3824
3897
  if (request.options.moduleResolution !== "Node16") return Option.none();
3825
3898
  if (request.features.esmMode) return Option.some("ESNext");
3826
3899
  return Option.some("CommonJS");
3827
3900
  };
3828
- const nestedRequest = (state, nested) => ({
3901
+ const nestedRequest = Function.dual(DATA_FIRST_ARITY$12, (state, nested) => ({
3829
3902
  features: state.features,
3830
3903
  moduleName: nested.moduleName,
3831
3904
  containingDirectory: nested.containingDirectory,
3832
3905
  options: state.options,
3833
3906
  extensions: nested.extensions,
3834
3907
  conditions: Option.some(state.conditions)
3835
- });
3908
+ }));
3836
3909
  const nestedContext = (state) => ({
3837
3910
  host: state.host,
3838
3911
  trace: state.trace,
3839
3912
  cache: state.cache
3840
3913
  });
3841
- const createState = (request, context, conditions) => ({
3914
+ const createState = Function.dual(DATA_FIRST_ARITY_3$7, (request, context, conditions) => ({
3842
3915
  host: context.host,
3843
3916
  trace: context.trace,
3844
3917
  options: request.options,
@@ -3848,13 +3921,14 @@ const createState = (request, context, conditions) => ({
3848
3921
  conditions,
3849
3922
  candidateIsFromPackageJsonField: false,
3850
3923
  outcome: createOutcome()
3851
- });
3924
+ }));
3852
3925
  // src/attw/resolver-relative.ts
3853
- const directoryMissing = (directory, state) => {
3926
+ const DATA_FIRST_ARITY$11 = 2;
3927
+ const directoryMissing = Function.dual(DATA_FIRST_ARITY$11, (directory, state) => {
3854
3928
  if (state.host.directoryExists(directory)) return false;
3855
3929
  traceMessage(state, Messages.directoryDoesNotExist, directory);
3856
3930
  return true;
3857
- };
3931
+ });
3858
3932
  const packageInfoOfFile = (request, resolved, state) => Option.liftPredicate(request.considerPackageJson, (consider) => consider).pipe(Option.flatMap(() => parseNodeModuleFromPath(resolved.path)), Option.flatMap((packageDirectory) => resolvePackageJsonInfo(packageDirectory, false, state)));
3859
3933
  const loadAsFile = (request, state) => loadModuleFromFile(request, state).pipe(Option.flatMap((resolved) => withPackageId(packageInfoOfFile(request, resolved, state), Option.some(resolved), state)));
3860
3934
  const fileAttempt = (request, state) => {
@@ -3871,7 +3945,7 @@ const fileAttempt = (request, state) => {
3871
3945
  onlyRecordFailures
3872
3946
  };
3873
3947
  };
3874
- const nodeLoadModuleByRelativeName = (request, state) => {
3948
+ const nodeLoadModuleByRelativeName = Function.dual(DATA_FIRST_ARITY$11, (request, state) => {
3875
3949
  traceMessage(state, Messages.loadingAsFileOrFolder, request.candidate, formatExtensions(request.extensions));
3876
3950
  const attempt = fileAttempt(request, state);
3877
3951
  if (Option.isSome(attempt.found)) return attempt.found;
@@ -3882,8 +3956,8 @@ const nodeLoadModuleByRelativeName = (request, state) => {
3882
3956
  onlyRecordFailures,
3883
3957
  loadRelative: nodeLoadModuleByRelativeName
3884
3958
  }, state);
3885
- };
3886
- const loadRelativeModule = (lookup, state) => {
3959
+ });
3960
+ const loadRelativeModule = Function.dual(DATA_FIRST_ARITY$11, (lookup, state) => {
3887
3961
  const { path, parts } = normalizePathForCJSResolution(lookup.directory, lookup.moduleName);
3888
3962
  return {
3889
3963
  resolved: nodeLoadModuleByRelativeName({
@@ -3894,15 +3968,17 @@ const loadRelativeModule = (lookup, state) => {
3894
3968
  }, state),
3895
3969
  insideNodeModules: parts.includes("node_modules")
3896
3970
  };
3897
- };
3971
+ });
3898
3972
  // src/attw/resolver-package-loader.ts
3973
+ const DATA_FIRST_ARITY$10 = 2;
3974
+ const DATA_FIRST_ARITY_3$6 = 3;
3899
3975
  const EMPTY$3 = 0;
3900
- const loadFromDirectory = (request, packageInfo, state) => loadNodeModuleFromDirectoryWorker({
3976
+ const loadFromDirectory = Function.dual(DATA_FIRST_ARITY_3$6, (request, packageInfo, state) => loadNodeModuleFromDirectoryWorker({
3901
3977
  ...request,
3902
3978
  jsonContent: packageInfo.pipe(Option.map((info) => info.contents.packageJsonContent)),
3903
3979
  versionPaths: packageInfo.pipe(Option.flatMap((info) => getVersionPaths(info, state))),
3904
3980
  loadRelative: nodeLoadModuleByRelativeName
3905
- }, state);
3981
+ }, state));
3906
3982
  const loadEsmIndexFallback = (request, packageInfo, state) => packageInfo.pipe(Option.filter((info) => state.features.esmMode && Predicate.isNullish(info.contents.packageJsonContent["exports"])), Option.flatMap(() => loadModuleFromFile({
3907
3983
  ...request,
3908
3984
  candidate: combinePaths(request.candidate, "index.js")
@@ -3911,16 +3987,16 @@ const loadFileFirst = (request, rest, state) => {
3911
3987
  if (rest.length > EMPTY$3 || !state.features.esmMode) return loadModuleFromFile(request, state);
3912
3988
  return Option.none();
3913
3989
  };
3914
- const specificLoader = (packageInfo, rest) => (request, state) => {
3990
+ const specificLoader = Function.dual(DATA_FIRST_ARITY$10, (packageInfo, rest) => (request, state) => {
3915
3991
  const pathAndExtension = loadFileFirst(request, rest, state).pipe(Option.orElse(() => loadFromDirectory(request, packageInfo, state)), Option.orElse(() => loadEsmIndexFallback(request, packageInfo, state)));
3916
3992
  return withPackageId(packageInfo, pathAndExtension, state);
3917
- };
3993
+ });
3918
3994
  const withoutPackageMetadata = (file) => ({
3919
3995
  ...file,
3920
3996
  packageId: Option.none(),
3921
3997
  originalPath: Option.none()
3922
3998
  });
3923
- const resolveVersionPathsWithTrace = (request, location, state) => Option.liftPredicate(location.rest, (rest) => rest.length > EMPTY$3).pipe(Option.flatMap(() => location.packageInfo.pipe(Option.flatMap((info) => getVersionPaths(info, state)))), Option.flatMap((versionPaths) => {
3999
+ const resolveVersionPathsWithTrace = Function.dual(DATA_FIRST_ARITY_3$6, (request, location, state) => Option.liftPredicate(location.rest, (rest) => rest.length > EMPTY$3).pipe(Option.flatMap(() => location.packageInfo.pipe(Option.flatMap((info) => getVersionPaths(info, state)))), Option.flatMap((versionPaths) => {
3924
4000
  traceMessage(state, Messages.packageJsonTypesVersionsMatch, versionPaths.version, RESOLUTION_VERSION, location.rest);
3925
4001
  const packageDirectoryExists = request.nodeModulesDirectoryExists && state.host.directoryExists(location.packageDirectory);
3926
4002
  return tryLoadModuleUsingPaths({
@@ -3932,8 +4008,9 @@ const resolveVersionPathsWithTrace = (request, location, state) => Option.liftPr
3932
4008
  onlyRecordFailures: !packageDirectoryExists,
3933
4009
  fromFile: withoutPackageMetadata
3934
4010
  }, state);
3935
- }));
4011
+ })));
3936
4012
  // src/attw/resolver-package.ts
4013
+ const DATA_FIRST_ARITY_3$5 = 3;
3937
4014
  const loadSubpathWithoutExports = (request, location, state) => {
3938
4015
  const candidateRequest = {
3939
4016
  extensions: request.extensions,
@@ -3946,8 +4023,8 @@ const loadSubpathWithoutExports = (request, location, state) => {
3946
4023
  const fromDirectory = loadFromDirectory(candidateRequest, packageInfo, state);
3947
4024
  return withPackageId(packageInfo, fromDirectory, state);
3948
4025
  };
3949
- const rootHasExports = (rootInfo) => Option.exists(rootInfo, (info) => Object.hasOwn(info.contents.packageJsonContent, "exports"));
3950
- const resolveInPackage = (request, location, state) => {
4026
+ const rootHasExports = (rootInfo) => Option.exists(rootInfo, (info) => Record.has(info.contents.packageJsonContent, "exports"));
4027
+ const resolveInPackage = Function.dual(DATA_FIRST_ARITY_3$5, (request, location, state) => {
3951
4028
  if (Option.isSome(location.packageInfo)) state.outcome.markResolvedPackageDirectory();
3952
4029
  const exportsInfo = location.packageInfo.pipe(Option.filter((info) => state.features.exports && Predicate.isTruthy(info.contents.packageJsonContent["exports"])));
3953
4030
  if (Option.isSome(exportsInfo)) {
@@ -3962,7 +4039,7 @@ const resolveInPackage = (request, location, state) => {
3962
4039
  candidate: location.candidate,
3963
4040
  onlyRecordFailures: !request.nodeModulesDirectoryExists
3964
4041
  }, state)));
3965
- };
4042
+ });
3966
4043
  const loadSubpathOfNestedPackage = (request, location, state) => {
3967
4044
  if (!state.features.exports) return loadSubpathWithoutExports(request, location, state);
3968
4045
  const missing = !request.nodeModulesDirectoryExists;
@@ -3973,7 +4050,7 @@ const loadSubpathOfNestedPackage = (request, location, state) => {
3973
4050
  packageInfo: rootInfo
3974
4051
  }, state);
3975
4052
  };
3976
- const loadSubpath = (request, location, state) => {
4053
+ const loadSubpath = Function.dual(DATA_FIRST_ARITY_3$5, (request, location, state) => {
3977
4054
  if (Option.isSome(location.packageInfo)) return loadSubpathOfNestedPackage(request, {
3978
4055
  ...location,
3979
4056
  packageInfo: location.packageInfo.value
@@ -3984,8 +4061,9 @@ const loadSubpath = (request, location, state) => {
3984
4061
  ...location,
3985
4062
  packageInfo
3986
4063
  }, state);
3987
- };
4064
+ });
3988
4065
  // src/attw/resolver-node-modules.ts
4066
+ const DATA_FIRST_ARITY$9 = 2;
3989
4067
  const EMPTY$2 = 0;
3990
4068
  const FEATURE_NAMES = [
3991
4069
  "imports",
@@ -3994,7 +4072,7 @@ const FEATURE_NAMES = [
3994
4072
  "patternTrailers",
3995
4073
  "esmMode"
3996
4074
  ];
3997
- const hasNoFeatures = ({ features }) => !FEATURE_NAMES.some((name) => features[name]);
4075
+ const hasNoFeatures = ({ features }) => !pipe(FEATURE_NAMES, Array$1.some((name) => features[name]));
3998
4076
  const cacheModeOf = (state) => {
3999
4077
  if (hasNoFeatures(state)) return Option.none();
4000
4078
  if (state.features.esmMode) return Option.some("ESNext");
@@ -4081,12 +4159,14 @@ const resolveFallbackWithTrace = (search, state) => {
4081
4159
  extensions: fallback
4082
4160
  }, state);
4083
4161
  };
4084
- const loadModuleFromNearestNodeModulesDirectory = (search, state) => resolvePreferredWithTrace(search, state).pipe(Option.orElse(() => resolveFallbackWithTrace(search, state)));
4162
+ const loadModuleFromNearestNodeModulesDirectory = Function.dual(DATA_FIRST_ARITY$9, (search, state) => resolvePreferredWithTrace(search, state).pipe(Option.orElse(() => resolveFallbackWithTrace(search, state))));
4085
4163
  // src/attw/resolver-attempt.ts
4164
+ const DATA_FIRST_ARITY$8 = 2;
4165
+ const DATA_FIRST_ARITY_3$4 = 3;
4086
4166
  const EMPTY$1 = 0;
4087
4167
  const resolveFromNodeModulesWithTrace = (lookup, state) => {
4088
4168
  const extensions = formatExtensions(lookup.extensions);
4089
- if (lookup.moduleName.includes(":")) {
4169
+ if (String$1.includes(":")(lookup.moduleName)) {
4090
4170
  traceMessage(state, Messages.skippingAbsoluteUri, lookup.moduleName, extensions);
4091
4171
  return Option.none();
4092
4172
  }
@@ -4097,7 +4177,7 @@ const resolveFromNodeModulesWithTrace = (lookup, state) => {
4097
4177
  }, state);
4098
4178
  };
4099
4179
  const fromPackageImports = (lookup, features, state) => {
4100
- if (features.imports && lookup.moduleName.startsWith("#")) return resolvePackageImportWithTrace(lookup, state);
4180
+ if (features.imports && String$1.startsWith("#")(lookup.moduleName)) return resolvePackageImportWithTrace(lookup, state);
4101
4181
  return Option.none();
4102
4182
  };
4103
4183
  const fromSelfName = (lookup, features, state) => {
@@ -4128,10 +4208,10 @@ const tryNonEmpty = (extensions, request, state) => {
4128
4208
  if (extensions.length === EMPTY$1) return Option.none();
4129
4209
  return tryResolve(extensions, request, state);
4130
4210
  };
4131
- const resolveWithPriority = (request, state) => {
4211
+ const resolveWithPriority = Function.dual(DATA_FIRST_ARITY$8, (request, state) => {
4132
4212
  if (request.options.moduleResolution !== "Node10") return tryResolve(request.extensions, request, state);
4133
4213
  return tryNonEmpty(intersectExtensions(request.extensions, PRIORITY_KINDS), request, state).pipe(Option.orElse(() => tryNonEmpty(subtractExtensions(request.extensions, PRIORITY_KINDS), request, state)));
4134
- };
4214
+ });
4135
4215
  const diagnosticPath = (request, state) => tryResolve(intersectExtensions(request.extensions, PRIORITY_KINDS), request, state).pipe(Option.flatten, Option.filter((found) => found.isExternalLibraryImport), Option.map((found) => found.resolved.path));
4136
4216
  const wantedTypesButGotJs = (request, result) => {
4137
4217
  const wantsTypes = request.extensions.includes("TypeScript") || request.extensions.includes("Declaration");
@@ -4153,7 +4233,7 @@ const retryWithBundler = (request, state) => {
4153
4233
  outcome: createOutcome()
4154
4234
  });
4155
4235
  };
4156
- const resolveAlternateResultWithTrace = (request, result, state) => {
4236
+ const resolveAlternateResultWithTrace = Function.dual(DATA_FIRST_ARITY_3$4, (request, result, state) => {
4157
4237
  if (shouldRetryWithoutExports(request, result, state)) {
4158
4238
  traceMessage(state, Messages.retryWithoutModernFeatures);
4159
4239
  return diagnosticPath(request, {
@@ -4167,8 +4247,9 @@ const resolveAlternateResultWithTrace = (request, result, state) => {
4167
4247
  }
4168
4248
  if (shouldRetryWithBundler(request, result)) return retryWithBundler(request, state);
4169
4249
  return Option.none();
4170
- };
4250
+ });
4171
4251
  // src/attw/resolver.ts
4252
+ const DATA_FIRST_ARITY$7 = 2;
4172
4253
  const supportsExportsAndImports = (request) => request.options.moduleResolution !== "Node10";
4173
4254
  const modeLabel = (features) => {
4174
4255
  if (features.esmMode) return "ESM";
@@ -4176,7 +4257,7 @@ const modeLabel = (features) => {
4176
4257
  };
4177
4258
  const announceMode = (request, state) => {
4178
4259
  if (!supportsExportsAndImports(request)) return;
4179
- traceMessage(state, Messages.resolvingInMode, modeLabel(request.features), state.conditions.map((condition) => `'${condition}'`).join(", "));
4260
+ traceMessage(state, Messages.resolvingInMode, modeLabel(request.features), pipe(state.conditions, Array$1.map((condition) => `'${condition}'`), Array$1.join(", ")));
4180
4261
  };
4181
4262
  const toResolutionResult = (found, alternateResult) => ({
4182
4263
  resolvedModule: found.pipe(Option.map(({ resolved, isExternalLibraryImport }) => ({
@@ -4204,7 +4285,7 @@ const nodeModuleNameResolverWorker = (request, context) => {
4204
4285
  const alternateResult = alternateResultOf(request, result, state);
4205
4286
  return state.outcome.resultFromCache().pipe(Option.getOrElse(() => toResolutionResult(result, alternateResult)));
4206
4287
  };
4207
- const resolveNestedModule = (state, nested) => nodeModuleNameResolverWorker(nestedRequest(state, nested), nestedContext(state));
4288
+ const resolveNestedModule = Function.dual(DATA_FIRST_ARITY$7, (state, nested) => nodeModuleNameResolverWorker(nestedRequest(state, nested), nestedContext(state)));
4208
4289
  const extensionsFor = (options) => {
4209
4290
  if (options.noDtsResolution) return extensionsOf("TypeScript", "JavaScript", "Json");
4210
4291
  return extensionsOf("TypeScript", "JavaScript", "Declaration", "Json");
@@ -4221,14 +4302,14 @@ const conditionsFor$1 = (request) => {
4221
4302
  if (request.options.moduleResolution === "Node16") return Option.none();
4222
4303
  return request.mode.pipe(Option.map((mode) => getConditions(request.options, Option.some(mode))));
4223
4304
  };
4224
- const resolveInDirectory = (request, context) => nodeModuleNameResolverWorker({
4305
+ const resolveInDirectory = Function.dual(DATA_FIRST_ARITY$7, (request, context) => nodeModuleNameResolverWorker({
4225
4306
  features: featuresFor$1(request),
4226
4307
  moduleName: request.moduleName,
4227
4308
  containingDirectory: request.containingDirectory,
4228
4309
  options: request.options,
4229
4310
  extensions: extensionsFor(request.options),
4230
4311
  conditions: conditionsFor$1(request)
4231
- }, context);
4312
+ }, context));
4232
4313
  const resolveUncached = (request, context) => {
4233
4314
  const containingDirectory = getDirectoryPath(request.containingFile);
4234
4315
  traceMessage(context, Messages.explicitResolutionKind, request.options.moduleResolution);
@@ -4269,13 +4350,14 @@ const reuseCachedWithTrace = (request, context) => {
4269
4350
  return cached;
4270
4351
  }));
4271
4352
  };
4272
- const resolveModuleName = (request, context) => {
4353
+ const resolveModuleName = Function.dual(DATA_FIRST_ARITY$7, (request, context) => {
4273
4354
  traceMessage(context, Messages.resolvingModule, request.moduleName, request.containingFile);
4274
4355
  const result = reuseCachedWithTrace(request, context).pipe(Option.getOrElse(() => resolveUncached(request, context)));
4275
4356
  traceOutcome(request.moduleName, result, context.trace);
4276
4357
  return result;
4277
- };
4358
+ });
4278
4359
  // src/attw/compiler-checker.ts
4360
+ const DATA_FIRST_ARITY_3$3 = 3;
4279
4361
  const checkerOptions = (core) => ({
4280
4362
  module: core.compilerOptions["module"],
4281
4363
  moduleResolution: core.compilerOptions["moduleResolution"],
@@ -4285,11 +4367,11 @@ const checkerOptions = (core) => ({
4285
4367
  types: []
4286
4368
  });
4287
4369
  const relativeDirectory = (site, directory) => {
4288
- const relative = directory.slice(site.mountRoot.length);
4370
+ const relative = String$1.slice(site.mountRoot.length)(directory);
4289
4371
  if (relative === "") return "/";
4290
4372
  return relative;
4291
4373
  };
4292
- const checkerResolver = (site, isProgramFile) => (moduleName, containingDirectory, mode) => Option.liftPredicate(containingDirectory, (directory) => directory.startsWith(site.mountRoot)).pipe(Option.flatMap((directory) => resolveInDirectory({
4374
+ const checkerResolver = (site, isProgramFile) => (moduleName, containingDirectory, mode) => Option.liftPredicate(containingDirectory, (directory) => String$1.startsWith(site.mountRoot)(directory)).pipe(Option.flatMap((directory) => resolveInDirectory({
4293
4375
  moduleName,
4294
4376
  containingDirectory: relativeDirectory(site, directory),
4295
4377
  options: {
@@ -4302,20 +4384,21 @@ const checkerResolver = (site, isProgramFile) => (moduleName, containingDirector
4302
4384
  trace: Option.none(),
4303
4385
  cache: Option.none()
4304
4386
  }).resolvedModule), Option.filter((module) => isProgramFile(toPath(module.resolvedFileName))), Option.map((module) => ({ resolvedFileName: `${site.mountRoot}${module.resolvedFileName}` })));
4305
- const openChecker = (site, files, rootNames) => {
4387
+ const openChecker = Function.dual(DATA_FIRST_ARITY_3$3, (site, files, rootNames) => {
4306
4388
  for (const file of files) bindSourceFile(file.sourceFile);
4307
- const fileNames = files.map((file) => file.fileName);
4308
- const filePaths = new Set(fileNames.map((name) => toPath(name)));
4389
+ const fileNames = pipe(files, Array$1.map((file) => file.fileName));
4390
+ const filePaths = new Set(pipe(fileNames, Array$1.map((name) => toPath(name))));
4309
4391
  return createTypeChecker({
4310
4392
  mountPath: site.mountRoot,
4311
4393
  rootNames: [.../* @__PURE__ */ new Set([...fileNames, ...rootNames])],
4312
4394
  compilerOptions: checkerOptions(site.core),
4313
4395
  resolve: checkerResolver(site, (path) => filePaths.has(path))
4314
4396
  });
4315
- };
4397
+ });
4316
4398
  // src/attw/host-types.ts
4317
4399
  const LIB_FILE_NAME = "/node_modules/typescript/lib/lib.d.ts";
4318
4400
  // src/attw/program-build.ts
4401
+ const DATA_FIRST_ARITY$6 = 2;
4319
4402
  const OUTSIDE_NODE_MODULES$1 = 0;
4320
4403
  const createDepthCounter = () => {
4321
4404
  const depth = MutableRef.make(OUTSIDE_NODE_MODULES$1);
@@ -4375,13 +4458,14 @@ const createFileRegistry = () => {
4375
4458
  })
4376
4459
  };
4377
4460
  };
4378
- const createProgramBuild = (host, options) => ({
4461
+ const createProgramBuild = Function.dual(DATA_FIRST_ARITY$6, (host, options) => ({
4379
4462
  host,
4380
4463
  options,
4381
4464
  registry: createFileRegistry(),
4382
4465
  depth: createDepthCounter()
4383
- });
4466
+ }));
4384
4467
  // src/attw/program-imports.ts
4468
+ const DATA_FIRST_ARITY_3$2 = 3;
4385
4469
  const MAX_NODE_MODULE_JS_DEPTH$1 = 0;
4386
4470
  const EMPTY = 0;
4387
4471
  const TS_EXTENSIONS$1 = /* @__PURE__ */ new Set([
@@ -4400,17 +4484,17 @@ const JS_EXTENSIONS$1 = /* @__PURE__ */ new Set([
4400
4484
  ".cjs"
4401
4485
  ]);
4402
4486
  const JSX_EXTENSIONS = /* @__PURE__ */ new Set([".tsx", ".jsx"]);
4403
- const isTsOrJsonResolution = (extension) => TS_EXTENSIONS$1.has(extension) || extension === ".json" || extension.startsWith(".d.") && extension.endsWith(".ts");
4487
+ const isTsOrJsonResolution = (extension) => TS_EXTENSIONS$1.has(extension) || extension === ".json" || String$1.startsWith(".d.")(extension) && String$1.endsWith(".ts")(extension);
4404
4488
  const isKnownExtension = (extension) => TS_EXTENSIONS$1.has(extension) || JS_EXTENSIONS$1.has(extension) || extension === ".json";
4405
4489
  const hasResolutionDiagnostic = (module, importer) => JSX_EXTENSIONS.has(module.extension) || !isKnownExtension(module.extension) && !importer.isDeclarationFile;
4406
- const literalSites = (nodes, isImport) => nodes.flatMap((node) => {
4490
+ const literalSites = (nodes, isImport) => pipe(nodes, Array$1.flatMap((node) => {
4407
4491
  if (isStringLiteralLikeNode(node)) return [{
4408
4492
  node,
4409
4493
  text: node.text,
4410
4494
  isImport
4411
4495
  }];
4412
4496
  return [];
4413
- });
4497
+ }));
4414
4498
  const moduleNameSitesOf = (sourceFile) => [...literalSites(importsOf(sourceFile), true), ...literalSites(moduleAugmentationsOf(sourceFile), false)];
4415
4499
  const resolveSite = (build, importer, site) => {
4416
4500
  const mode = getModeForUsageLocation$1(importer, site.node, build.host.modeOptions);
@@ -4444,20 +4528,21 @@ const followResolvedModule = (walk, site, module) => {
4444
4528
  });
4445
4529
  build.depth.leave(module.isExternalLibraryImport);
4446
4530
  };
4447
- const processImportedModules = (build, importer, include) => {
4531
+ const processImportedModules = Function.dual(DATA_FIRST_ARITY_3$2, (build, importer, include) => {
4448
4532
  collectExternalModuleReferences(importer);
4449
4533
  const sites = moduleNameSitesOf(importer);
4450
4534
  if (sites.length === EMPTY) return;
4451
- const resolved = sites.map((site) => resolveSite(build, importer, site));
4452
- build.registry.recordResolutions(importer.fileName, resolved.map(({ entry }) => entry));
4535
+ const resolved = pipe(sites, Array$1.map((site) => resolveSite(build, importer, site)));
4536
+ build.registry.recordResolutions(importer.fileName, pipe(resolved, Array$1.map(({ entry }) => entry)));
4453
4537
  const walk = {
4454
4538
  build,
4455
4539
  include,
4456
4540
  importer
4457
4541
  };
4458
4542
  for (const { site, entry } of resolved) for (const module of Option.toArray(entry.resolution.resolvedModule)) followResolvedModule(walk, site, module);
4459
- };
4543
+ });
4460
4544
  // src/attw/program.ts
4545
+ const DATA_FIRST_ARITY_3$1 = 3;
4461
4546
  const TS_EXTENSIONS = [
4462
4547
  ".ts",
4463
4548
  ".tsx",
@@ -4491,14 +4576,14 @@ const supportedExtensions = (options) => {
4491
4576
  };
4492
4577
  const processSourceFile = (build, request, include) => {
4493
4578
  const { fileName } = request;
4494
- if (getBaseFileName(fileName).includes(".")) {
4495
- if (fileExtensionIsOneOf(fileName.toLowerCase(), supportedExtensions(build.options))) include(build, request);
4579
+ if (String$1.includes(".")(getBaseFileName(fileName))) {
4580
+ if (fileExtensionIsOneOf(String$1.toLowerCase(fileName), supportedExtensions(build.options))) include(build, request);
4496
4581
  return;
4497
4582
  }
4498
- IMPLICIT_EXTENSIONS.some((extension) => Option.isSome(include(build, {
4583
+ pipe(IMPLICIT_EXTENSIONS, Array$1.some((extension) => Option.isSome(include(build, {
4499
4584
  ...request,
4500
4585
  fileName: `${fileName}${extension}`
4501
- })));
4586
+ }))));
4502
4587
  };
4503
4588
  const processReferencedFiles = (walk) => {
4504
4589
  const directory = getDirectoryPath(walk.sourceFile.fileName);
@@ -4536,7 +4621,7 @@ const processTypeReferenceDirectives = (walk) => {
4536
4621
  const processLibReferenceDirectives = (walk) => {
4537
4622
  const libDirectory = getDirectoryPath(walk.build.host.defaultLibFileName);
4538
4623
  for (const reference of walk.sourceFile.libReferenceDirectives) {
4539
- const fileName = combinePaths(libDirectory, `lib.${reference.fileName.toLowerCase()}.d.ts`);
4624
+ const fileName = combinePaths(libDirectory, `lib.${String$1.toLowerCase(reference.fileName)}.d.ts`);
4540
4625
  processSourceFile(walk.build, {
4541
4626
  fileName,
4542
4627
  isDefaultLib: true,
@@ -4608,7 +4693,7 @@ const includeSourceFile = (build, request) => {
4608
4693
  return file;
4609
4694
  }));
4610
4695
  };
4611
- const createProgramFiles = (rootNames, options, host) => {
4696
+ const createProgramFiles = Function.dual(DATA_FIRST_ARITY_3$1, (rootNames, options, host) => {
4612
4697
  const build = createProgramBuild(host, options);
4613
4698
  for (const rootName of rootNames) {
4614
4699
  const request = {
@@ -4627,8 +4712,9 @@ const createProgramFiles = (rootNames, options, host) => {
4627
4712
  processSourceFile(build, request, includeSourceFile);
4628
4713
  }
4629
4714
  return build.registry.result();
4630
- };
4715
+ });
4631
4716
  // src/attw/compiler-program.ts
4717
+ const DATA_FIRST_ARITY$5 = 2;
4632
4718
  const buildProgramFiles = (site, rootNames) => createProgramFiles(rootNames, site.options, {
4633
4719
  modeOptions: site.core.modeOptions,
4634
4720
  defaultLibFileName: LIB_FILE_NAME,
@@ -4637,7 +4723,7 @@ const buildProgramFiles = (site, rootNames) => createProgramFiles(rootNames, sit
4637
4723
  resolveTypeReference: site.core.resolveTypeReference,
4638
4724
  packageJsonScopeFor: site.core.packageJsonScopeFor
4639
4725
  });
4640
- const createProgram = (site, rootNames) => {
4726
+ const createProgram = Function.dual(DATA_FIRST_ARITY$5, (site, rootNames) => {
4641
4727
  const programFiles = buildProgramFiles(site, rootNames);
4642
4728
  const checkerSite = {
4643
4729
  core: site.core,
@@ -4660,13 +4746,13 @@ const createProgram = (site, rootNames) => {
4660
4746
  for (const created of Option.toArray(MutableRef.get(checker))) created.dispose();
4661
4747
  }
4662
4748
  };
4663
- };
4749
+ });
4664
4750
  // src/attw/resolution-cache.ts
4751
+ const DATA_FIRST_ARITY$4 = 2;
4665
4752
  const NEXT = 1;
4666
4753
  const START = 0;
4667
4754
  const ROOT_LENGTH = 1;
4668
- const NOT_FOUND = -1;
4669
- const modeKey = (name, mode) => `${Option.getOrElse(mode, () => "")}|${name}`;
4755
+ const modeKey = Function.dual(DATA_FIRST_ARITY$4, (name, mode) => `${Option.getOrElse(mode, () => "")}|${name}`);
4670
4756
  const resolvedFileNameOf = (result) => result.resolvedModule.pipe(Option.map((module) => Option.getOrElse(module.originalPath, () => module.resolvedFileName)));
4671
4757
  const sharedLength = (left, right) => {
4672
4758
  const limit = Math.min(left.length, right.length);
@@ -4675,7 +4761,7 @@ const sharedLength = (left, right) => {
4675
4761
  return index;
4676
4762
  };
4677
4763
  const isWholeDirectoryShared = (directory, resolutionDirectory, index) => index === directory.length && (resolutionDirectory.length === index || resolutionDirectory[index] === "/");
4678
- const enclosingDirectory = (directory, index) => Option.liftPredicate(directory.lastIndexOf("/", index - NEXT), (separator) => separator !== NOT_FOUND).pipe(Option.map((separator) => directory.slice(START, Math.max(separator, ROOT_LENGTH))));
4764
+ const enclosingDirectory = (directory, index) => lastIndexUpTo(directory, "/", index - NEXT).pipe(Option.map((separator) => String$1.slice(START, Math.max(separator, ROOT_LENGTH))(directory)));
4679
4765
  const getCommonPrefix = (directory, resolution) => {
4680
4766
  const resolutionDirectory = toPath(getDirectoryPath(resolution));
4681
4767
  const index = sharedLength(directory, resolutionDirectory);
@@ -4791,6 +4877,7 @@ const createResolutionStore = (source) => {
4791
4877
  };
4792
4878
  };
4793
4879
  // src/attw/compiler-host-wrapper.ts
4880
+ const DATA_FIRST_ARITY$3 = 2;
4794
4881
  const PROGRAM_CACHE_SIZE = 2;
4795
4882
  const PRIMARY_OPTIONS = {
4796
4883
  allowJs: false,
@@ -4799,11 +4886,11 @@ const PRIMARY_OPTIONS = {
4799
4886
  const createProgramCache = (site) => {
4800
4887
  const programs = /* @__PURE__ */ new Map();
4801
4888
  return (rootNames, options) => {
4802
- const key = JSON.stringify([
4803
- rootNames,
4804
- options.allowJs,
4805
- options.noDtsResolution
4806
- ]);
4889
+ const key = Array$1.join([
4890
+ ...rootNames,
4891
+ String(options.allowJs),
4892
+ String(options.noDtsResolution)
4893
+ ], "\0");
4807
4894
  const program = programs.get(key) ?? createProgram({
4808
4895
  ...site,
4809
4896
  options
@@ -4849,7 +4936,7 @@ const resolveModuleNameWith = (core) => (...[moduleName, containingFile, resolut
4849
4936
  trace: entry.trace
4850
4937
  };
4851
4938
  };
4852
- const wrapHost = (core, site) => {
4939
+ const wrapHost = Function.dual(DATA_FIRST_ARITY$3, (core, site) => {
4853
4940
  const getProgram = createProgramCache({
4854
4941
  ...site,
4855
4942
  core
@@ -4875,7 +4962,7 @@ const wrapHost = (core, site) => {
4875
4962
  createAuxiliaryProgram: (rootNames, extraOptions) => getProgram(rootNames, auxiliaryOptions(extraOptions)).program,
4876
4963
  getResolvedModule: (sourceFile, moduleName, resolutionMode) => Option.getOrUndefined(resolvedModules.lookup(sourceFile.fileName, moduleName, modeFromNumber(resolutionMode)))
4877
4964
  };
4878
- };
4965
+ });
4879
4966
  // src/attw/host-files.ts
4880
4967
  const ESM_EXTENSIONS = [
4881
4968
  ".d.mts",
@@ -4980,6 +5067,7 @@ const createSourceFileStore = (origin) => {
4980
5067
  };
4981
5068
  };
4982
5069
  // src/attw/type-reference-state.ts
5070
+ const DATA_FIRST_ARITY$2 = 2;
4983
5071
  const conditionsFor = (request, exportsEnabled) => {
4984
5072
  if (!exportsEnabled) return [];
4985
5073
  return getConditions(request.options, request.mode);
@@ -4988,7 +5076,7 @@ const featuresFor = (request) => {
4988
5076
  if (request.options.moduleResolution !== "Node10" || Option.isSome(request.mode)) return ALL_FEATURES;
4989
5077
  return NO_FEATURES;
4990
5078
  };
4991
- const stateFor = (request, host) => {
5079
+ const stateFor = Function.dual(DATA_FIRST_ARITY$2, (request, host) => {
4992
5080
  const kind = request.options.moduleResolution;
4993
5081
  const features = {
4994
5082
  ...featuresFor(request),
@@ -5006,8 +5094,9 @@ const stateFor = (request, host) => {
5006
5094
  outcome: createOutcome(),
5007
5095
  resolveNested: resolveNestedModule
5008
5096
  };
5009
- };
5097
+ });
5010
5098
  // src/attw/type-reference.ts
5099
+ const DATA_FIRST_ARITY$1 = 2;
5011
5100
  const TYPE_ROOT = "/node_modules/@types";
5012
5101
  const DECLARATION = extensionsOf("Declaration");
5013
5102
  const primaryLookup = (request, state) => {
@@ -5035,14 +5124,14 @@ const secondaryLookup = (request, state) => {
5035
5124
  directory
5036
5125
  }, state).resolved;
5037
5126
  };
5038
- const resolveTypeReferenceDirective = (request, host) => {
5127
+ const resolveTypeReferenceDirective = Function.dual(DATA_FIRST_ARITY$1, (request, host) => {
5039
5128
  const state = stateFor(request, host);
5040
5129
  return primaryLookup(request, state).pipe(Option.orElse(() => secondaryLookup(request, state)), Option.map((resolved) => ({
5041
5130
  resolvedFileName: resolved.path,
5042
5131
  packageId: resolved.packageId,
5043
5132
  isExternalLibraryImport: pathContainsNodeModules(resolved.path)
5044
5133
  })));
5045
- };
5134
+ });
5046
5135
  // src/attw/host-wrapper.ts
5047
5136
  const TARGET_LATEST = 99;
5048
5137
  const MODULE_KINDS = {
@@ -5119,7 +5208,15 @@ const createHostWrapper = (source) => {
5119
5208
  }, resolverHost)
5120
5209
  };
5121
5210
  };
5122
- ModuleResolutionKind.Node10, ModuleResolutionKind.Node16, ModuleResolutionKind.NodeNext, ModuleResolutionKind.Bundler;
5211
+ // src/attw/compiler-hosts.ts
5212
+ const DATA_FIRST_ARITY = 2;
5213
+ const DATA_FIRST_ARITY_3 = 3;
5214
+ const RESOLUTION_KINDS_BY_OPTION = /* @__PURE__ */ new Map([
5215
+ [ModuleResolutionKind.Node10, "Node10"],
5216
+ [ModuleResolutionKind.Node16, "Node16"],
5217
+ [ModuleResolutionKind.NodeNext, "Node16"],
5218
+ [ModuleResolutionKind.Bundler, "Bundler"]
5219
+ ]);
5123
5220
  const mountFileSystem = (fs, minimalLib) => mount({
5124
5221
  fileExists: (path) => path === "/node_modules/typescript/lib/lib.d.ts" || fs.fileExists(path),
5125
5222
  directoryExists: (path) => fs.directoryExists(path),
@@ -5129,7 +5226,17 @@ const mountFileSystem = (fs, minimalLib) => mount({
5129
5226
  },
5130
5227
  listFiles: () => [LIB_FILE_NAME, ...fs.listFiles()]
5131
5228
  });
5132
- const createCompilerHostsWith = (fs, minimalLib) => {
5229
+ Function.dual(DATA_FIRST_ARITY_3, (fs, moduleResolution, minimalLib) => {
5230
+ const kind = RESOLUTION_KINDS_BY_OPTION.get(moduleResolution);
5231
+ if (Predicate.isUndefined(kind)) throw new TypeError(`Unsupported module resolution kind: ${String(moduleResolution)}`);
5232
+ return wrapHost(createHostWrapper({
5233
+ fs,
5234
+ kind,
5235
+ minimalLib
5236
+ }), { mounted: mountFileSystem(fs, minimalLib) });
5237
+ });
5238
+ const holdsAll = (files) => (host) => pipe(files, Array$1.every((file) => Predicate.isNotUndefined(host.getSourceFileFromCache(file))));
5239
+ const createCompilerHostsWith = Function.dual(DATA_FIRST_ARITY, (fs, minimalLib) => {
5133
5240
  const mounted = mountFileSystem(fs, minimalLib);
5134
5241
  const create = (kind) => wrapHost(createHostWrapper({
5135
5242
  fs,
@@ -5143,13 +5250,13 @@ const createCompilerHostsWith = (fs, minimalLib) => {
5143
5250
  node10,
5144
5251
  node16,
5145
5252
  bundler,
5146
- findHostForFiles: (files) => [
5253
+ findHostForFiles: (files) => Option.getOrUndefined(Array$1.findFirst([
5147
5254
  node10,
5148
5255
  node16,
5149
5256
  bundler
5150
- ].find((host) => files.every((file) => Predicate.isNotUndefined(host.getSourceFileFromCache(file))))
5257
+ ], holdsAll(files)))
5151
5258
  };
5152
- };
5259
+ });
5153
5260
  // \0attw-compiler-hosts
5154
5261
  const createCompilerHosts = (fs) => createCompilerHostsWith(fs, minimalLibDts_default);
5155
5262
  // upstream/attw-core/lib/internal/getEntrypointInfo.js