@taiga-ui/cdk 4.0.0-rc.8 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/constants/used-icons.d.ts +1 -1
  2. package/constants/version.d.ts +1 -1
  3. package/constants/version.js +1 -1
  4. package/esm2022/constants/used-icons.mjs +9 -1
  5. package/esm2022/constants/version.mjs +2 -2
  6. package/esm2022/services/index.mjs +2 -2
  7. package/esm2022/services/theme-color.service.mjs +30 -0
  8. package/fesm2022/taiga-ui-cdk-constants.mjs +9 -1
  9. package/fesm2022/taiga-ui-cdk-constants.mjs.map +1 -1
  10. package/fesm2022/taiga-ui-cdk-services.mjs +19 -22
  11. package/fesm2022/taiga-ui-cdk-services.mjs.map +1 -1
  12. package/package.json +4 -4
  13. package/schematics/ng-update/interfaces/html-comment.d.ts +3 -2
  14. package/schematics/ng-update/interfaces/replacement-attribute-value.d.ts +6 -2
  15. package/schematics/ng-update/interfaces/replacement-identifier.d.ts +4 -11
  16. package/schematics/ng-update/steps/replace-identifier.js +16 -11
  17. package/schematics/ng-update/utils/templates/replace-attr-values.js +39 -10
  18. package/schematics/ng-update/utils/templates/template-comments.js +7 -1
  19. package/schematics/ng-update/v4/index.js +2 -0
  20. package/schematics/ng-update/v4/migrate-icons/index.js +2 -2
  21. package/schematics/ng-update/v4/migrate-icons/rename-proprietary-icons.d.ts +2 -1
  22. package/schematics/ng-update/v4/migrate-icons/rename-proprietary-icons.js +16 -3
  23. package/schematics/ng-update/v4/steps/constants/attr-with-values-to-replace.js +42 -2
  24. package/schematics/ng-update/v4/steps/constants/attrs-to-replace.js +28 -0
  25. package/schematics/ng-update/v4/steps/constants/html-comments.js +4 -0
  26. package/schematics/ng-update/v4/steps/constants/identifiers-to-replace.js +231 -231
  27. package/schematics/ng-update/v4/steps/constants/migration-warnings.js +21 -1
  28. package/schematics/ng-update/v4/steps/constants/modules-to-remove.js +4 -0
  29. package/schematics/ng-update/v4/steps/constants/types.js +12 -0
  30. package/schematics/ng-update/v4/steps/index.d.ts +2 -0
  31. package/schematics/ng-update/v4/steps/index.js +2 -0
  32. package/schematics/ng-update/v4/steps/migrate-alert-service.js +31 -9
  33. package/schematics/ng-update/v4/steps/migrate-month-context.d.ts +2 -0
  34. package/schematics/ng-update/v4/steps/migrate-month-context.js +39 -0
  35. package/schematics/ng-update/v4/steps/migrate-number-format-settings.d.ts +2 -0
  36. package/schematics/ng-update/v4/steps/migrate-number-format-settings.js +64 -0
  37. package/schematics/ng-update/v4/steps/migrate-root.js +7 -2
  38. package/schematics/ng-update/v4/steps/styles/index.js +12 -2
  39. package/schematics/ng-update/v4/steps/styles/migrate-less-scss-constants.d.ts +1 -0
  40. package/schematics/ng-update/v4/steps/styles/migrate-less-scss-constants.js +13 -0
  41. package/schematics/ng-update/v4/steps/styles/migrate-scrollbar-behavior.d.ts +1 -0
  42. package/schematics/ng-update/v4/steps/styles/migrate-scrollbar-behavior.js +10 -0
  43. package/schematics/ng-update/v4/steps/styles/migrate-shadow-mixins.d.ts +1 -0
  44. package/schematics/ng-update/v4/steps/styles/migrate-shadow-mixins.js +23 -0
  45. package/schematics/ng-update/v4/steps/styles/migrate-space-mixins.js +2 -2
  46. package/schematics/ng-update/v4/steps/styles/migrate-text-mixins.d.ts +1 -0
  47. package/schematics/ng-update/v4/steps/styles/migrate-text-mixins.js +54 -0
  48. package/schematics/ng-update/v4/steps/templates/migrate-badged-content.js +1 -1
  49. package/schematics/ng-update/v4/steps/templates/migrate-labeled.js +1 -1
  50. package/schematics/ng-update/v4/steps/templates/migrate-notification.js +21 -3
  51. package/services/index.d.ts +1 -1
  52. package/services/theme-color.service.d.ts +16 -0
  53. package/esm2022/services/static-request.service.mjs +0 -33
  54. package/schematics/ng-update/v3/constants/breakpoints.d.ts +0 -82
  55. package/schematics/ng-update/v3/constants/breakpoints.js +0 -34
  56. package/schematics/ng-update/v3/constants/constants.d.ts +0 -2
  57. package/schematics/ng-update/v3/constants/constants.js +0 -466
  58. package/schematics/ng-update/v3/constants/deprecated-functions.d.ts +0 -2
  59. package/schematics/ng-update/v3/constants/deprecated-functions.js +0 -680
  60. package/schematics/ng-update/v3/constants/enums.d.ts +0 -2
  61. package/schematics/ng-update/v3/constants/enums.js +0 -284
  62. package/schematics/ng-update/v3/constants/modules.d.ts +0 -2
  63. package/schematics/ng-update/v3/constants/modules.js +0 -9
  64. package/schematics/ng-update/v3/constants/services.d.ts +0 -2
  65. package/schematics/ng-update/v3/constants/services.js +0 -53
  66. package/schematics/ng-update/v3/constants/templates.d.ts +0 -57
  67. package/schematics/ng-update/v3/constants/templates.js +0 -744
  68. package/schematics/ng-update/v3/constants/tui-interactive-selectors.d.ts +0 -1
  69. package/schematics/ng-update/v3/constants/tui-interactive-selectors.js +0 -55
  70. package/schematics/ng-update/v3/constants/types.d.ts +0 -2
  71. package/schematics/ng-update/v3/constants/types.js +0 -156
  72. package/schematics/ng-update/v3/constants/warnings.d.ts +0 -2
  73. package/schematics/ng-update/v3/constants/warnings.js +0 -111
  74. package/schematics/ng-update/v3/index.d.ts +0 -3
  75. package/schematics/ng-update/v3/index.js +0 -105
  76. package/schematics/ng-update/v3/schema.json +0 -13
  77. package/schematics/ng-update/v3/steps/migrate-date-time.d.ts +0 -2
  78. package/schematics/ng-update/v3/steps/migrate-date-time.js +0 -207
  79. package/schematics/ng-update/v3/steps/migrate-polymorpheus.d.ts +0 -8
  80. package/schematics/ng-update/v3/steps/migrate-polymorpheus.js +0 -78
  81. package/schematics/ng-update/v3/steps/migrate-progress.d.ts +0 -8
  82. package/schematics/ng-update/v3/steps/migrate-progress.js +0 -49
  83. package/schematics/ng-update/v3/steps/migrate-sliders/index.d.ts +0 -3
  84. package/schematics/ng-update/v3/steps/migrate-sliders/index.js +0 -19
  85. package/schematics/ng-update/v3/steps/migrate-sliders/migrate-input-range.d.ts +0 -3
  86. package/schematics/ng-update/v3/steps/migrate-sliders/migrate-input-range.js +0 -103
  87. package/schematics/ng-update/v3/steps/migrate-sliders/migrate-input-slider.d.ts +0 -3
  88. package/schematics/ng-update/v3/steps/migrate-sliders/migrate-input-slider.js +0 -90
  89. package/schematics/ng-update/v3/steps/migrate-taiga-proprietary-icons.d.ts +0 -3
  90. package/schematics/ng-update/v3/steps/migrate-taiga-proprietary-icons.js +0 -70
  91. package/schematics/ng-update/v3/steps/migrate-templates.d.ts +0 -4
  92. package/schematics/ng-update/v3/steps/migrate-templates.js +0 -216
  93. package/schematics/ng-update/v3/steps/migrate-textfield-controller.d.ts +0 -8
  94. package/schematics/ng-update/v3/steps/migrate-textfield-controller.js +0 -98
  95. package/schematics/ng-update/v3/steps/miscellaneous.d.ts +0 -2
  96. package/schematics/ng-update/v3/steps/miscellaneous.js +0 -81
  97. package/schematics/ng-update/v3/steps/replace-functions.d.ts +0 -2
  98. package/schematics/ng-update/v3/steps/replace-functions.js +0 -138
  99. package/schematics/ng-update/v3/steps/replace-styles.d.ts +0 -3
  100. package/schematics/ng-update/v3/steps/replace-styles.js +0 -33
  101. package/schematics/ng-update/v3-30/constants/constants.d.ts +0 -2
  102. package/schematics/ng-update/v3-30/constants/constants.js +0 -8
  103. package/schematics/ng-update/v3-30/constants/icons.d.ts +0 -4
  104. package/schematics/ng-update/v3-30/constants/icons.js +0 -993
  105. package/schematics/ng-update/v3-30/index.d.ts +0 -3
  106. package/schematics/ng-update/v3-30/index.js +0 -33
  107. package/schematics/ng-update/v3-35/constants/constants.d.ts +0 -2
  108. package/schematics/ng-update/v3-35/constants/constants.js +0 -8
  109. package/schematics/ng-update/v3-35/constants/icons.d.ts +0 -4
  110. package/schematics/ng-update/v3-35/constants/icons.js +0 -2537
  111. package/schematics/ng-update/v3-35/index.d.ts +0 -3
  112. package/schematics/ng-update/v3-35/index.js +0 -33
  113. package/schematics/ng-update/v3-36/index.d.ts +0 -3
  114. package/schematics/ng-update/v3-36/index.js +0 -23
  115. package/schematics/ng-update/v3-40/index.d.ts +0 -3
  116. package/schematics/ng-update/v3-40/index.js +0 -62
  117. package/schematics/ng-update/v3-5/index.d.ts +0 -3
  118. package/schematics/ng-update/v3-5/index.js +0 -20
  119. package/schematics/ng-update/v3-5/steps/migrate-expand-templates.d.ts +0 -3
  120. package/schematics/ng-update/v3-5/steps/migrate-expand-templates.js +0 -44
  121. package/services/static-request.service.d.ts +0 -8
@@ -155,6 +155,26 @@ exports.MIGRATION_WARNINGS = [
155
155
  {
156
156
  name: 'TuiIllustrationsModule',
157
157
  moduleSpecifier: '@taiga-ui/proprietary-icons',
158
- message: 'Import TuiIconPipe and use <img [src]="icon | tuiIcon" /> instead. See https://taiga-ui.tcsbank.ru/icons',
158
+ message: 'TuiIllustrationsModule was deleted. Import TuiIconPipe and use <img [src]="icon | tuiIcon" /> instead. See https://taiga-ui.tcsbank.ru/icons',
159
+ },
160
+ {
161
+ name: 'TuiIllustrationsPipe',
162
+ moduleSpecifier: '@taiga-ui/proprietary-icons',
163
+ message: 'TuiIllustrationsPipe was deleted. Import TuiIconPipe and use <img [src]="icon | tuiIcon" /> instead. See https://taiga-ui.tcsbank.ru/icons',
164
+ },
165
+ {
166
+ name: 'TuiIllustrationModePipe',
167
+ moduleSpecifier: '@taiga-ui/proprietary-icons',
168
+ message: 'TuiIllustrationModePipe was deleted. Import TuiIconPipe and use <img [src]="icon | tuiIcon" /> instead. See https://taiga-ui.tcsbank.ru/icons',
169
+ },
170
+ {
171
+ name: 'TUI_IS_MOBILE_RES',
172
+ moduleSpecifier: '@taiga-ui/core',
173
+ message: 'use TuiBreakpointService instead of TUI_IS_MOBILE_RES. Learn more https://taiga-ui.dev/services/breakpoint-service',
174
+ },
175
+ {
176
+ name: 'TUI_ANIMATIONS_DURATION',
177
+ moduleSpecifier: '@taiga-ui/core',
178
+ message: 'TUI_ANIMATIONS_DURATION is deleted. Use TUI_ANIMATIONS_SPEED instead (300ms divided by your previous value of TUI_ANIMATIONS_DURATION)',
159
179
  },
160
180
  ];
@@ -18,6 +18,10 @@ exports.MODULES_TO_REMOVE = [
18
18
  name: 'TuiPromptDialogModule',
19
19
  moduleSpecifier: '@taiga-ui/proprietary-core',
20
20
  },
21
+ {
22
+ name: 'TuiPromptModule',
23
+ moduleSpecifier: '@taiga-ui/kit',
24
+ },
21
25
  {
22
26
  name: 'TuiThemeTinkoff2023NightModule',
23
27
  moduleSpecifier: '@taiga-ui/proprietary-core',
@@ -23,12 +23,24 @@ exports.TYPES_TO_RENAME = [
23
23
  to: 'string',
24
24
  removeImport: true,
25
25
  },
26
+ {
27
+ from: 'TuiIllustrationCategory',
28
+ moduleSpecifier: ['@taiga-ui/proprietary-icons'],
29
+ to: 'string',
30
+ removeImport: true,
31
+ },
26
32
  {
27
33
  from: 'TuiNotificationT',
28
34
  moduleSpecifier: ['@taiga-ui/core'],
29
35
  to: 'string',
30
36
  removeImport: true,
31
37
  },
38
+ {
39
+ from: 'TuiMarkerIconMode',
40
+ moduleSpecifier: ['@taiga-ui/kit'],
41
+ to: 'string',
42
+ removeImport: true,
43
+ },
32
44
  {
33
45
  from: 'TuiOperationIcon',
34
46
  moduleSpecifier: ['@taiga-ui/proprietary-banking'],
@@ -2,6 +2,8 @@ export * from './migrate-alert-service';
2
2
  export * from './migrate-all-country-iso-codes';
3
3
  export * from './migrate-destroy-service';
4
4
  export * from './migrate-legacy-mask';
5
+ export * from './migrate-month-context';
6
+ export * from './migrate-number-format-settings';
5
7
  export * from './migrate-option-providers';
6
8
  export * from './migrate-proprietary';
7
9
  export * from './migrate-templates';
@@ -5,6 +5,8 @@ tslib_1.__exportStar(require("./migrate-alert-service"), exports);
5
5
  tslib_1.__exportStar(require("./migrate-all-country-iso-codes"), exports);
6
6
  tslib_1.__exportStar(require("./migrate-destroy-service"), exports);
7
7
  tslib_1.__exportStar(require("./migrate-legacy-mask"), exports);
8
+ tslib_1.__exportStar(require("./migrate-month-context"), exports);
9
+ tslib_1.__exportStar(require("./migrate-number-format-settings"), exports);
8
10
  tslib_1.__exportStar(require("./migrate-option-providers"), exports);
9
11
  tslib_1.__exportStar(require("./migrate-proprietary"), exports);
10
12
  tslib_1.__exportStar(require("./migrate-templates"), exports);
@@ -38,7 +38,7 @@ function migrateAlertService(options) {
38
38
  // inject(TuiAlertService).open(...)
39
39
  const viaDirectInjects = alertServiceRefs.map((x) => x.getFirstAncestor((node) => node.isKind(ng_morph_1.SyntaxKind.CallExpression) &&
40
40
  node.getFullText().includes('inject(TuiAlertService') &&
41
- node.getFullText().includes('.open(')));
41
+ node.getFullText().includes('.open')));
42
42
  // readonly alertService = inject(TuiAlertService);
43
43
  const viaClassProperty = alertServiceRefs
44
44
  .map((x) => {
@@ -53,21 +53,43 @@ function migrateAlertService(options) {
53
53
  .map((x) => { var _a; return (_a = x.getFirstAncestorByKind(ng_morph_1.SyntaxKind.Parameter)) === null || _a === void 0 ? void 0 : _a.findReferencesAsNodes(); })
54
54
  .flat()
55
55
  .map(toAlertServiceOpenCallExpression);
56
- [...viaDirectInjects, ...viaClassProperty, ...viaConstructorParam].forEach((callExpression) => {
56
+ const inlineAlertOptions = [
57
+ ...viaDirectInjects,
58
+ ...viaClassProperty,
59
+ ...viaConstructorParam,
60
+ ]
61
+ .map((callExpression) => {
57
62
  if (!callExpression || callExpression.wasForgotten()) {
58
63
  return;
59
64
  }
60
65
  const [, arg] = callExpression.getArguments();
61
- const options = (arg === null || arg === void 0 ? void 0 : arg.isKind(ng_morph_1.SyntaxKind.PropertyAccessExpression))
66
+ return (arg === null || arg === void 0 ? void 0 : arg.isKind(ng_morph_1.SyntaxKind.PropertyAccessExpression))
62
67
  ? findOptionsInitializer(arg)
63
68
  : arg;
64
- if (!(options === null || options === void 0 ? void 0 : options.isKind(ng_morph_1.SyntaxKind.ObjectLiteralExpression))) {
65
- return;
66
- }
69
+ })
70
+ .filter(ng_morph_1.Node.isObjectLiteralExpression);
71
+ const standaloneAlertOptions = (0, get_named_import_references_1.getNamedImportReferences)('TuiAlertOptions', '@taiga-ui/core')
72
+ .map((n) => {
73
+ const type = n.getFirstAncestorByKind(ng_morph_1.SyntaxKind.TypeReference);
74
+ const siblings = [
75
+ ...((type === null || type === void 0 ? void 0 : type.getPreviousSiblings()) || []),
76
+ ...((type === null || type === void 0 ? void 0 : type.getNextSiblings()) || []),
77
+ ];
78
+ return siblings.find(ng_morph_1.Node.isObjectLiteralExpression);
79
+ })
80
+ .filter((x) => !!x);
81
+ [...inlineAlertOptions, ...standaloneAlertOptions].forEach((options) => {
67
82
  Object.entries(OPTIONS_MIGRATIONS).forEach(([propertyName, migration]) => {
68
83
  const property = options.getProperty(propertyName);
69
- if (property) {
70
- migration(property);
84
+ if (!property) {
85
+ return;
86
+ }
87
+ const isShorthandPropertyAssignment = ng_morph_1.Node.isShorthandPropertyAssignment(property) &&
88
+ !property.hasObjectAssignmentInitializer();
89
+ const previousPropertyText = property.getText();
90
+ migration(property);
91
+ if (isShorthandPropertyAssignment && !property.wasForgotten()) {
92
+ property.replaceWithText(`${property.getText()}: ${previousPropertyText}`);
71
93
  }
72
94
  });
73
95
  });
@@ -76,7 +98,7 @@ function migrateAlertService(options) {
76
98
  }
77
99
  exports.migrateAlertService = migrateAlertService;
78
100
  function toAlertServiceOpenCallExpression(node) {
79
- return node === null || node === void 0 ? void 0 : node.getFirstAncestor((x) => x.isKind(ng_morph_1.SyntaxKind.CallExpression) && x.getFullText().includes('.open('));
101
+ return node === null || node === void 0 ? void 0 : node.getFirstAncestor((x) => x.isKind(ng_morph_1.SyntaxKind.CallExpression) && x.getFullText().includes('.open'));
80
102
  }
81
103
  function findOptionsInitializer(ref) {
82
104
  var _a;
@@ -0,0 +1,2 @@
1
+ import type { TuiSchema } from '../../../ng-add/schema';
2
+ export declare function migrateMonthContext(options: TuiSchema): void;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.migrateMonthContext = void 0;
4
+ const ng_morph_1 = require("ng-morph");
5
+ const add_unique_import_1 = require("../../../utils/add-unique-import");
6
+ const colored_log_1 = require("../../../utils/colored-log");
7
+ const get_named_import_references_1 = require("../../../utils/get-named-import-references");
8
+ const import_manipulations_1 = require("../../../utils/import-manipulations");
9
+ function migrateMonthContext(options) {
10
+ !options['skip-logs'] &&
11
+ (0, colored_log_1.infoLog)(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.REPLACE_SYMBOL} migrating TuiBooleanHandlerWithContext<TuiMonth, TuiMonthContext> ...`);
12
+ const monthContextRefs = (0, get_named_import_references_1.getNamedImportReferences)('TuiMonthContext', '@taiga-ui/kit');
13
+ monthContextRefs
14
+ .map((n) => n.getFirstAncestorByKind(ng_morph_1.SyntaxKind.TypeReference))
15
+ .forEach((ref) => {
16
+ if (!ref || ref.wasForgotten()) {
17
+ return;
18
+ }
19
+ const booleanHandlerWithContext = ref.getFirstAncestor((node) => node.isKind(ng_morph_1.SyntaxKind.TypeReference) &&
20
+ !!node
21
+ .getText()
22
+ .match(/TuiBooleanHandlerWithContext<\s*TuiMonth\s*,\s*TuiMonthContext\s*>/));
23
+ if (!booleanHandlerWithContext) {
24
+ return;
25
+ }
26
+ booleanHandlerWithContext.replaceWithText('TuiBooleanHandler<TuiMonth>');
27
+ (0, add_unique_import_1.addUniqueImport)(booleanHandlerWithContext.getSourceFile().getFilePath(), 'TuiBooleanHandler', '@taiga-ui/cdk');
28
+ });
29
+ [
30
+ ...monthContextRefs,
31
+ ...(0, get_named_import_references_1.getNamedImportReferences)('TuiBooleanHandlerWithContext', '@taiga-ui/kit'),
32
+ ]
33
+ .map((node) => !node.wasForgotten() &&
34
+ node.getFirstAncestorByKind(ng_morph_1.SyntaxKind.ImportSpecifier))
35
+ .filter((x) => !!x)
36
+ .forEach(import_manipulations_1.removeImport);
37
+ !options['skip-logs'] && (0, colored_log_1.titleLog)(`${colored_log_1.FINISH_SYMBOL} successfully migrated \n`);
38
+ }
39
+ exports.migrateMonthContext = migrateMonthContext;
@@ -0,0 +1,2 @@
1
+ import type { TuiSchema } from '../../../ng-add/schema';
2
+ export declare function migrateNumberFormatSettings(options: TuiSchema): void;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.migrateNumberFormatSettings = void 0;
4
+ const ng_morph_1 = require("ng-morph");
5
+ const colored_log_1 = require("../../../utils/colored-log");
6
+ const get_named_import_references_1 = require("../../../utils/get-named-import-references");
7
+ const OPTIONS_MIGRATIONS = {
8
+ decimalLimit: (property) => property.replaceWithText(property.getText().replace('decimalLimit', 'precision')),
9
+ decimal: (property) => {
10
+ const [, propertyValue] = property.getText().split(/\s?:\s?/);
11
+ property.replaceWithText(propertyValue.match(/^['"`]never['"`]$/)
12
+ ? 'precision: 0'
13
+ : property.getText().replace('decimal', 'decimalMode'));
14
+ },
15
+ zeroPadding: (property) => {
16
+ const [, propertyValue] = property.getText().split(/\s?:\s?/);
17
+ if (propertyValue === 'true') {
18
+ property.replaceWithText('decimalMode: "always"');
19
+ }
20
+ else {
21
+ property.replaceWithText(`// TODO: (Taiga UI migration) "zeroPadding" is deleted. Use "decimalMode" instead https://taiga-ui.dev/pipes/format-number/API \n${property.getText()}`);
22
+ }
23
+ },
24
+ };
25
+ function migrateNumberFormatSettings(options) {
26
+ !options['skip-logs'] &&
27
+ (0, colored_log_1.infoLog)(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.REPLACE_SYMBOL} migrating TuiNumberFormatSettings...`);
28
+ const asFunctionArgument = [
29
+ ...(0, get_named_import_references_1.getNamedImportReferences)('tuiFormatNumber', '@taiga-ui/core'),
30
+ ...(0, get_named_import_references_1.getNamedImportReferences)('tuiNumberFormatProvider', '@taiga-ui/core'),
31
+ ].map((n) => {
32
+ var _a;
33
+ return (_a = n
34
+ .getFirstAncestorByKind(ng_morph_1.SyntaxKind.CallExpression)) === null || _a === void 0 ? void 0 : _a.getFirstDescendantByKind(ng_morph_1.SyntaxKind.ObjectLiteralExpression);
35
+ });
36
+ const asStandaloneSettingsObject = (0, get_named_import_references_1.getNamedImportReferences)('TuiNumberFormatSettings', '@taiga-ui/core').map((n) => {
37
+ const type = n.getFirstAncestorByKind(ng_morph_1.SyntaxKind.TypeReference);
38
+ const siblings = [
39
+ ...((type === null || type === void 0 ? void 0 : type.getPreviousSiblings()) || []),
40
+ ...((type === null || type === void 0 ? void 0 : type.getNextSiblings()) || []),
41
+ ];
42
+ return siblings.find(ng_morph_1.Node.isObjectLiteralExpression);
43
+ });
44
+ [...asFunctionArgument, ...asStandaloneSettingsObject]
45
+ .filter(ng_morph_1.Node.isObjectLiteralExpression)
46
+ .forEach((options) => {
47
+ Object.entries(OPTIONS_MIGRATIONS).forEach(([propertyName, migration]) => {
48
+ const property = options.getProperty(propertyName);
49
+ if (!property) {
50
+ return;
51
+ }
52
+ const isShorthandPropertyAssignment = ng_morph_1.Node.isShorthandPropertyAssignment(property) &&
53
+ !property.hasObjectAssignmentInitializer();
54
+ const previousPropertyText = property.getText();
55
+ migration(property);
56
+ if (isShorthandPropertyAssignment && !property.wasForgotten()) {
57
+ property.replaceWithText(`${property.getText()}: ${previousPropertyText}`);
58
+ }
59
+ });
60
+ });
61
+ !options['skip-logs'] &&
62
+ (0, colored_log_1.successLog)(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.SUCCESS_SYMBOL} migration of TuiNumberFormatSettings completes \n`);
63
+ }
64
+ exports.migrateNumberFormatSettings = migrateNumberFormatSettings;
@@ -33,8 +33,13 @@ function replaceRootIdentifier(ref, fileSystem) {
33
33
  const callExpression = ref.getParentWhile(ng_morph_1.Node.isCallExpression);
34
34
  if (callExpression &&
35
35
  callExpression.getExpression().getText() === 'importProvidersFrom') {
36
- ref.replaceWithText('');
37
- addProviders(callExpression, fileSystem);
36
+ const node = callExpression
37
+ .getArguments()
38
+ .find((arg) => arg.getText() === ref.getText());
39
+ if (node) {
40
+ callExpression.removeArgument(node);
41
+ addProviders(callExpression, fileSystem);
42
+ }
38
43
  }
39
44
  else {
40
45
  ref.replaceWithText('TuiRoot');
@@ -3,7 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.migrateStyles = exports.TUI_RATING_WARNING = void 0;
4
4
  /// <reference lib="es2021" />
5
5
  const ng_morph_1 = require("ng-morph");
6
+ const migrate_less_scss_constants_1 = require("./migrate-less-scss-constants");
7
+ const migrate_scrollbar_behavior_1 = require("./migrate-scrollbar-behavior");
8
+ const migrate_shadow_mixins_1 = require("./migrate-shadow-mixins");
6
9
  const migrate_space_mixins_1 = require("./migrate-space-mixins");
10
+ const migrate_text_mixins_1 = require("./migrate-text-mixins");
7
11
  exports.TUI_RATING_WARNING = '// TODO: (Taiga UI migration): use css to customize rating gap and size. See https://taiga-ui.dev/components/rating#basic';
8
12
  function migrateStyles() {
9
13
  var _a;
@@ -20,8 +24,14 @@ function migrateStyles() {
20
24
  .replaceAll('@taiga-ui/proprietary-core/styles/theme-tinkoff-mobile-2023', '@taiga-ui/proprietary/styles/tbank-theme-mobile.less')
21
25
  .replaceAll('@taiga-ui/proprietary-core/styles/theme-tinkoff-mobile', '@taiga-ui/proprietary/styles/tbank-theme-mobile.less')
22
26
  .replaceAll('@taiga-ui/proprietary-core/styles/theme-tinkoff', '@taiga-ui/proprietary/styles/tbank-theme');
23
- fullText = (0, migrate_space_mixins_1.migrateSpaceMixins)(fullText);
24
- sourceFile.replaceWithText(fullText);
27
+ const newFileContent = [
28
+ migrate_space_mixins_1.migrateSpaceMixins,
29
+ migrate_text_mixins_1.migrateTextMixins,
30
+ migrate_shadow_mixins_1.migrateShadowMixins,
31
+ migrate_less_scss_constants_1.migrateLessSCSSConstants,
32
+ migrate_scrollbar_behavior_1.migrateScrollbarBehavior,
33
+ ].reduce((text, migrate) => migrate(text), fullText);
34
+ sourceFile.replaceWithText(newFileContent);
25
35
  });
26
36
  (0, ng_morph_1.saveActiveProject)();
27
37
  }
@@ -0,0 +1 @@
1
+ export declare function migrateLessSCSSConstants(fileContent: string): string;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.migrateLessSCSSConstants = void 0;
4
+ const MAPPING = {
5
+ space: '0.25rem',
6
+ };
7
+ function migrateLessSCSSConstants(fileContent) {
8
+ if (!fileContent.includes('@taiga-ui/core/styles/taiga-ui-local')) {
9
+ return fileContent;
10
+ }
11
+ return fileContent.replaceAll(new RegExp(`[$|@](${Object.keys(MAPPING).join('|')})`, 'g'), (_, variable) => MAPPING[variable]);
12
+ }
13
+ exports.migrateLessSCSSConstants = migrateLessSCSSConstants;
@@ -0,0 +1 @@
1
+ export declare function migrateScrollbarBehavior(fileContent: string): string;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.migrateScrollbarBehavior = void 0;
4
+ function migrateScrollbarBehavior(fileContent) {
5
+ if (!fileContent.includes('@taiga-ui/core/styles/taiga-ui-local')) {
6
+ return fileContent;
7
+ }
8
+ return fileContent.replaceAll('.scroll-behavior()', 'scroll-behavior: var(--tui-scroll-behavior)');
9
+ }
10
+ exports.migrateScrollbarBehavior = migrateScrollbarBehavior;
@@ -0,0 +1 @@
1
+ export declare function migrateShadowMixins(fileContent: string): string;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.migrateShadowMixins = void 0;
4
+ const MAPPING = {
5
+ 'shadow()': 'var(--tui-shadow-small)',
6
+ 'shadow(1)': 'var(--tui-shadow-small)',
7
+ 'shadow(2)': 'var(--tui-shadow-medium)',
8
+ 'shadow(3)': 'var(--tui-shadow-popup)',
9
+ 'shadow(4)': 'var(--tui-shadow-medium)',
10
+ 'shadow(5)': 'var(--tui-shadow-small-hover)',
11
+ 'shadow(6)': 'var(--tui-shadow-small)',
12
+ 'shadow(7)': 'var(--tui-shadow-popup)',
13
+ };
14
+ // .shadow(2);
15
+ // @include shadow(2);
16
+ const MIXIN_RE = /(?:@include\s|\.)(shadow\(\d*\))(\s?!important)?;/g;
17
+ function migrateShadowMixins(fileContent) {
18
+ if (!fileContent.includes('@taiga-ui/core/styles/taiga-ui-local')) {
19
+ return fileContent;
20
+ }
21
+ return fileContent.replaceAll(MIXIN_RE, (_, mixin, important = '') => `box-shadow: ${MAPPING[mixin]}${important};`);
22
+ }
23
+ exports.migrateShadowMixins = migrateShadowMixins;
@@ -13,8 +13,8 @@ const DIRECTION_MAPPING = {
13
13
  const SPACE = 0.25;
14
14
  // .tui-space(top, 4);
15
15
  // @include tui-space(top, 4);
16
- const MIXIN_RE = new RegExp(`(?:@include\\s|\\.)tui-space\\((?<direction>${Object.keys(DIRECTION_MAPPING).join('|')}),\\s?(?<size>-?\\d+)\\);`, 'g');
16
+ const MIXIN_RE = new RegExp(`(?:@include\\s|\\.)tui-space\\((?<direction>${Object.keys(DIRECTION_MAPPING).join('|')}),\\s?(?<size>-?\\d+)\\)(\\s?!important)?;`, 'g');
17
17
  function migrateSpaceMixins(fileContent) {
18
- return fileContent.replaceAll(MIXIN_RE, (_, direction, size) => `${DIRECTION_MAPPING[direction].map((property) => `${property}: ${Number(size) * SPACE}rem;`).join('\n')}`);
18
+ return fileContent.replaceAll(MIXIN_RE, (_, direction, size, important = '') => `${DIRECTION_MAPPING[direction].map((property) => `${property}: ${Number(size) * SPACE}rem${important};`).join('\n')}`);
19
19
  }
20
20
  exports.migrateSpaceMixins = migrateSpaceMixins;
@@ -0,0 +1 @@
1
+ export declare function migrateTextMixins(fileContent: string): string;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.migrateTextMixins = void 0;
4
+ const MAPPING = {
5
+ 'text-h1': ['font: var(--tui-font-heading-1)'],
6
+ 'text-h2': ['font: var(--tui-font-heading-2)'],
7
+ 'text-h3': ['font: var(--tui-font-heading-3)'],
8
+ 'text-h4': ['font: var(--tui-font-heading-4)'],
9
+ 'text-h5': ['font: var(--tui-font-heading-5)'],
10
+ 'text-h6': ['font: var(--tui-font-heading-6)'],
11
+ 'text-body-xl-bold': ['font: var(--tui-font-text-xl)', 'font-weight: bold'],
12
+ 'text-body-xl': ['font: var(--tui-font-text-xl)'],
13
+ 'text-body-xs': ['font: var(--tui-font-text-xs)'],
14
+ 'text-caption-l-bold': [
15
+ 'font-size: 0.8125rem',
16
+ 'font-weight: bold',
17
+ 'font-family: var(--tui-font-text)',
18
+ 'letter-spacing: 0.0625rem',
19
+ 'text-transform: uppercase',
20
+ ],
21
+ 'text-caption-l': [
22
+ 'font-size: 0.8125rem',
23
+ 'font-weight: normal',
24
+ 'font-family: var(--tui-font-text)',
25
+ 'letter-spacing: 0.0625rem',
26
+ 'text-transform: uppercase',
27
+ ],
28
+ 'text-caption-bold': [
29
+ 'font-size: 0.6875rem',
30
+ 'font-weight: bold',
31
+ 'font-family: var(--tui-font-text)',
32
+ 'letter-spacing: 0.0625rem',
33
+ 'text-transform: uppercase',
34
+ ],
35
+ 'text-caption': [
36
+ 'font-size: 0.6875rem',
37
+ 'font-weight: normal',
38
+ 'font-family: var(--tui-font-text)',
39
+ 'letter-spacing: 0.0625rem',
40
+ 'text-transform: uppercase',
41
+ ],
42
+ };
43
+ // .tui-text-h1();
44
+ // @include tui-text-h1();
45
+ const MIXIN_RE = /(?:@include\s|\.)(text-[\w-]+)\(([\w-,\s]+)?\)(\s?!important)?;/g;
46
+ function migrateTextMixins(fileContent) {
47
+ if (!fileContent.includes('@taiga-ui/core/styles/taiga-ui-local')) {
48
+ return fileContent;
49
+ }
50
+ return fileContent.replaceAll(MIXIN_RE, (originalString, mixinName, important = '') => MAPPING[mixinName]
51
+ ? `${MAPPING[mixinName].map((newValue) => `${newValue}${important};`).join('\n')}`
52
+ : `${originalString} // TODO: this mixin was deleted. Replace it with inline styles. Find it source code in https://github.com/taiga-family/taiga-ui/blob/v3.x/projects/core/styles/mixins/text.less`);
53
+ }
54
+ exports.migrateTextMixins = migrateTextMixins;
@@ -59,7 +59,7 @@ function migrateBadgedContent({ resource, recorder, fileSystem, }) {
59
59
  });
60
60
  if (!rounded || rounded.value === 'true') {
61
61
  const insertTo = (_b = (_a = sourceCodeLocation.startTag) === null || _a === void 0 ? void 0 : _a.endOffset) !== null && _b !== void 0 ? _b : 0;
62
- recorder.insertRight(insertTo + templateOffset - 1, '[style.--tui-radius.%]="50"');
62
+ recorder.insertRight(insertTo + templateOffset - 1, ' [style.--tui-radius.%]="50"');
63
63
  }
64
64
  const attrsToRemove = [
65
65
  colorBottomAttr,
@@ -15,7 +15,7 @@ function migrateLabeled({ resource, recorder, fileSystem, }) {
15
15
  data: [
16
16
  {
17
17
  attrNames: ['size'],
18
- values: [
18
+ valueReplacer: [
19
19
  { from: 'l', to: 'm' },
20
20
  { from: 'm', to: 's' },
21
21
  ],
@@ -14,14 +14,16 @@ function migrateNotification({ resource, recorder, fileSystem, }) {
14
14
  ...(0, elements_1.findElementsWithAttributeOnTag)(template, ['tuiNotification'], ['button', 'a']),
15
15
  ];
16
16
  elements.forEach(({ attrs, sourceCodeLocation, tagName, childNodes }) => {
17
- var _a, _b, _c;
17
+ var _a, _b, _c, _d;
18
18
  const sizeAttr = (0, inputs_1.findAttr)(attrs, 'size');
19
+ const hasIconAttr = (0, inputs_1.findAttr)(attrs, 'hasIcon');
19
20
  const hideCloseAttr = (0, inputs_1.findAttr)(attrs, 'hideClose');
20
21
  const closeListener = (0, inputs_1.findAttr)(attrs, '(close)');
21
22
  const { startTag, endTag } = sourceCodeLocation || {};
22
23
  const hideCloseAttrLocation = (_a = sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.attrs) === null || _a === void 0 ? void 0 : _a[(hideCloseAttr === null || hideCloseAttr === void 0 ? void 0 : hideCloseAttr.name) || ''];
24
+ const hasIconAttrLocation = (_b = sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.attrs) === null || _b === void 0 ? void 0 : _b[(hasIconAttr === null || hasIconAttr === void 0 ? void 0 : hasIconAttr.name) || ''];
23
25
  if (!sizeAttr) {
24
- recorder.insertRight(templateOffset + ((_b = startTag === null || startTag === void 0 ? void 0 : startTag.startOffset) !== null && _b !== void 0 ? _b : 0) + `<${tagName}`.length, ' size="m"');
26
+ recorder.insertRight(templateOffset + ((_c = startTag === null || startTag === void 0 ? void 0 : startTag.startOffset) !== null && _c !== void 0 ? _c : 0) + `<${tagName}`.length, ' size="m"');
25
27
  }
26
28
  if (closeListener) {
27
29
  const hasProprietaryPackages = !!(0, ng_morph_1.getPackageJsonDependency)(fileSystem.tree, '@taiga-ui/proprietary-core');
@@ -31,12 +33,28 @@ function migrateNotification({ resource, recorder, fileSystem, }) {
31
33
  ? '@tui.pragmatic.small.cross'
32
34
  : '@tui.x';
33
35
  const closeButtonTemplate = ` <button${ifCondition} tuiIconButton iconStart="${closeIconName}"></button>`;
34
- recorder.insertRight(templateOffset + ((_c = endTag === null || endTag === void 0 ? void 0 : endTag.startOffset) !== null && _c !== void 0 ? _c : 0), closeButtonTemplate);
36
+ recorder.insertRight(templateOffset + ((_d = endTag === null || endTag === void 0 ? void 0 : endTag.startOffset) !== null && _d !== void 0 ? _d : 0), closeButtonTemplate);
35
37
  if (hideCloseAttrLocation) {
36
38
  const { startOffset, endOffset } = hideCloseAttrLocation;
37
39
  recorder.remove(templateOffset + startOffset, endOffset - startOffset);
38
40
  }
39
41
  }
42
+ if (hasIconAttr && hasIconAttrLocation) {
43
+ const { startOffset, endOffset } = hasIconAttrLocation;
44
+ const attrOffset = templateOffset + startOffset;
45
+ const attrLength = endOffset - startOffset;
46
+ switch (hasIconAttr.value) {
47
+ case 'false':
48
+ recorder.remove(attrOffset, attrLength);
49
+ recorder.insertRight(attrOffset, 'icon=""');
50
+ break;
51
+ case 'true':
52
+ recorder.remove(attrOffset, attrLength);
53
+ break;
54
+ default:
55
+ recorder.insertLeft(templateOffset + ((startTag === null || startTag === void 0 ? void 0 : startTag.startOffset) || 0), '<!-- TODO: (Taiga UI migration) "hasIcon" is deleted. Use icon="" to hide icon. Or pass TUI_NOTIFICATION_DEFAULT_OPTIONS["icon"] to show it again. Learn more: https://taiga-ui.dev/components/notification -->\n');
56
+ }
57
+ }
40
58
  if (childNodes.length > 1 && startTag && endTag) {
41
59
  recorder.insertRight(templateOffset + startTag.endOffset, '<div>');
42
60
  recorder.insertLeft(templateOffset + endTag.startOffset, '</div>');
@@ -1,4 +1,4 @@
1
1
  export * from './id.service';
2
2
  export * from './popover.service';
3
3
  export * from './scroll.service';
4
- export * from './static-request.service';
4
+ export * from './theme-color.service';
@@ -0,0 +1,16 @@
1
+ import * as i0 from "@angular/core";
2
+ export declare const TUI_THEME_COLOR: import("@angular/core").InjectionToken<string>;
3
+ interface TuiThemeColor {
4
+ get color(): string;
5
+ set color(value: string);
6
+ }
7
+ export declare class TuiThemeColorService implements TuiThemeColor {
8
+ private readonly current;
9
+ private readonly doc;
10
+ private readonly meta;
11
+ get color(): string;
12
+ set color(content: string);
13
+ static ɵfac: i0.ɵɵFactoryDeclaration<TuiThemeColorService, never>;
14
+ static ɵprov: i0.ɵɵInjectableDeclaration<TuiThemeColorService>;
15
+ }
16
+ export {};
@@ -1,33 +0,0 @@
1
- import { Injectable } from '@angular/core';
2
- import { shareReplay, switchMap } from 'rxjs';
3
- import { fromFetch } from 'rxjs/fetch';
4
- import * as i0 from "@angular/core";
5
- class TuiStaticRequestService {
6
- constructor() {
7
- this.cache = new Map();
8
- }
9
- request(url) {
10
- const cache = this.cache.get(url);
11
- if (cache) {
12
- return cache;
13
- }
14
- const piped = fromFetch(url).pipe(switchMap(async (response) => {
15
- if (response.ok) {
16
- return response.text();
17
- }
18
- throw new Error(`Failed to load ${url} (${response.statusText})`);
19
- }), shareReplay({ bufferSize: 1, refCount: false }));
20
- this.cache.set(url, piped);
21
- return piped;
22
- }
23
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TuiStaticRequestService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
24
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TuiStaticRequestService, providedIn: 'root' }); }
25
- }
26
- export { TuiStaticRequestService };
27
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TuiStaticRequestService, decorators: [{
28
- type: Injectable,
29
- args: [{
30
- providedIn: 'root',
31
- }]
32
- }] });
33
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhdGljLXJlcXVlc3Quc2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Byb2plY3RzL2Nkay9zZXJ2aWNlcy9zdGF0aWMtcmVxdWVzdC5zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBQyxVQUFVLEVBQUMsTUFBTSxlQUFlLENBQUM7QUFFekMsT0FBTyxFQUFDLFdBQVcsRUFBRSxTQUFTLEVBQUMsTUFBTSxNQUFNLENBQUM7QUFDNUMsT0FBTyxFQUFDLFNBQVMsRUFBQyxNQUFNLFlBQVksQ0FBQzs7QUFFckMsTUFHYSx1QkFBdUI7SUFIcEM7UUFJcUIsVUFBSyxHQUFHLElBQUksR0FBRyxFQUE4QixDQUFDO0tBd0JsRTtJQXRCVSxPQUFPLENBQUMsR0FBVztRQUN0QixNQUFNLEtBQUssR0FBRyxJQUFJLENBQUMsS0FBSyxDQUFDLEdBQUcsQ0FBQyxHQUFHLENBQUMsQ0FBQztRQUVsQyxJQUFJLEtBQUssRUFBRTtZQUNQLE9BQU8sS0FBSyxDQUFDO1NBQ2hCO1FBRUQsTUFBTSxLQUFLLEdBQUcsU0FBUyxDQUFDLEdBQUcsQ0FBQyxDQUFDLElBQUksQ0FDN0IsU0FBUyxDQUFDLEtBQUssRUFBRSxRQUFRLEVBQUUsRUFBRTtZQUN6QixJQUFJLFFBQVEsQ0FBQyxFQUFFLEVBQUU7Z0JBQ2IsT0FBTyxRQUFRLENBQUMsSUFBSSxFQUFFLENBQUM7YUFDMUI7WUFFRCxNQUFNLElBQUksS0FBSyxDQUFDLGtCQUFrQixHQUFHLEtBQUssUUFBUSxDQUFDLFVBQVUsR0FBRyxDQUFDLENBQUM7UUFDdEUsQ0FBQyxDQUFDLEVBQ0YsV0FBVyxDQUFDLEVBQUMsVUFBVSxFQUFFLENBQUMsRUFBRSxRQUFRLEVBQUUsS0FBSyxFQUFDLENBQUMsQ0FDaEQsQ0FBQztRQUVGLElBQUksQ0FBQyxLQUFLLENBQUMsR0FBRyxDQUFDLEdBQUcsRUFBRSxLQUFLLENBQUMsQ0FBQztRQUUzQixPQUFPLEtBQUssQ0FBQztJQUNqQixDQUFDOytHQXhCUSx1QkFBdUI7bUhBQXZCLHVCQUF1QixjQUZwQixNQUFNOztTQUVULHVCQUF1Qjs0RkFBdkIsdUJBQXVCO2tCQUhuQyxVQUFVO21CQUFDO29CQUNSLFVBQVUsRUFBRSxNQUFNO2lCQUNyQiIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7SW5qZWN0YWJsZX0gZnJvbSAnQGFuZ3VsYXIvY29yZSc7XG5pbXBvcnQgdHlwZSB7T2JzZXJ2YWJsZX0gZnJvbSAncnhqcyc7XG5pbXBvcnQge3NoYXJlUmVwbGF5LCBzd2l0Y2hNYXB9IGZyb20gJ3J4anMnO1xuaW1wb3J0IHtmcm9tRmV0Y2h9IGZyb20gJ3J4anMvZmV0Y2gnO1xuXG5ASW5qZWN0YWJsZSh7XG4gICAgcHJvdmlkZWRJbjogJ3Jvb3QnLFxufSlcbmV4cG9ydCBjbGFzcyBUdWlTdGF0aWNSZXF1ZXN0U2VydmljZSB7XG4gICAgcHJpdmF0ZSByZWFkb25seSBjYWNoZSA9IG5ldyBNYXA8c3RyaW5nLCBPYnNlcnZhYmxlPHN0cmluZz4+KCk7XG5cbiAgICBwdWJsaWMgcmVxdWVzdCh1cmw6IHN0cmluZyk6IE9ic2VydmFibGU8c3RyaW5nPiB7XG4gICAgICAgIGNvbnN0IGNhY2hlID0gdGhpcy5jYWNoZS5nZXQodXJsKTtcblxuICAgICAgICBpZiAoY2FjaGUpIHtcbiAgICAgICAgICAgIHJldHVybiBjYWNoZTtcbiAgICAgICAgfVxuXG4gICAgICAgIGNvbnN0IHBpcGVkID0gZnJvbUZldGNoKHVybCkucGlwZShcbiAgICAgICAgICAgIHN3aXRjaE1hcChhc3luYyAocmVzcG9uc2UpID0+IHtcbiAgICAgICAgICAgICAgICBpZiAocmVzcG9uc2Uub2spIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3BvbnNlLnRleHQoKTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoYEZhaWxlZCB0byBsb2FkICR7dXJsfSAoJHtyZXNwb25zZS5zdGF0dXNUZXh0fSlgKTtcbiAgICAgICAgICAgIH0pLFxuICAgICAgICAgICAgc2hhcmVSZXBsYXkoe2J1ZmZlclNpemU6IDEsIHJlZkNvdW50OiBmYWxzZX0pLFxuICAgICAgICApO1xuXG4gICAgICAgIHRoaXMuY2FjaGUuc2V0KHVybCwgcGlwZWQpO1xuXG4gICAgICAgIHJldHVybiBwaXBlZDtcbiAgICB9XG59XG4iXX0=