@udixio/theme 1.0.0-beta.5 → 1.0.0-beta.7

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/theme.esm.js CHANGED
@@ -1,369 +1,5 @@
1
- import { __decorate, __metadata } from 'tslib';
2
- import { Injectable, Module } from '@nestjs/common';
3
- import { lerp, Contrast, clampDouble, hexFromArgb, Hct, argbFromHex, DislikeAnalyzer, TonalPalette, sanitizeDegreesDouble } from '@material/material-color-utilities';
4
- import mergeDeep from 'merge-deep';
5
- import { NestFactory } from '@nestjs/core';
6
-
7
- function asyncGeneratorStep(n, t, e, r, o, a, c) {
8
- try {
9
- var i = n[a](c),
10
- u = i.value;
11
- } catch (n) {
12
- return void e(n);
13
- }
14
- i.done ? t(u) : Promise.resolve(u).then(r, o);
15
- }
16
- function _asyncToGenerator(n) {
17
- return function () {
18
- var t = this,
19
- e = arguments;
20
- return new Promise(function (r, o) {
21
- var a = n.apply(t, e);
22
- function _next(n) {
23
- asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
24
- }
25
- function _throw(n) {
26
- asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
27
- }
28
- _next(void 0);
29
- });
30
- };
31
- }
32
- function _defineProperties(e, r) {
33
- for (var t = 0; t < r.length; t++) {
34
- var o = r[t];
35
- o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
36
- }
37
- }
38
- function _createClass(e, r, t) {
39
- return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
40
- writable: !1
41
- }), e;
42
- }
43
- function _extends() {
44
- return _extends = Object.assign ? Object.assign.bind() : function (n) {
45
- for (var e = 1; e < arguments.length; e++) {
46
- var t = arguments[e];
47
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
48
- }
49
- return n;
50
- }, _extends.apply(null, arguments);
51
- }
52
- function _regeneratorRuntime() {
53
- _regeneratorRuntime = function () {
54
- return e;
55
- };
56
- var t,
57
- e = {},
58
- r = Object.prototype,
59
- n = r.hasOwnProperty,
60
- o = Object.defineProperty || function (t, e, r) {
61
- t[e] = r.value;
62
- },
63
- i = "function" == typeof Symbol ? Symbol : {},
64
- a = i.iterator || "@@iterator",
65
- c = i.asyncIterator || "@@asyncIterator",
66
- u = i.toStringTag || "@@toStringTag";
67
- function define(t, e, r) {
68
- return Object.defineProperty(t, e, {
69
- value: r,
70
- enumerable: !0,
71
- configurable: !0,
72
- writable: !0
73
- }), t[e];
74
- }
75
- try {
76
- define({}, "");
77
- } catch (t) {
78
- define = function (t, e, r) {
79
- return t[e] = r;
80
- };
81
- }
82
- function wrap(t, e, r, n) {
83
- var i = e && e.prototype instanceof Generator ? e : Generator,
84
- a = Object.create(i.prototype),
85
- c = new Context(n || []);
86
- return o(a, "_invoke", {
87
- value: makeInvokeMethod(t, r, c)
88
- }), a;
89
- }
90
- function tryCatch(t, e, r) {
91
- try {
92
- return {
93
- type: "normal",
94
- arg: t.call(e, r)
95
- };
96
- } catch (t) {
97
- return {
98
- type: "throw",
99
- arg: t
100
- };
101
- }
102
- }
103
- e.wrap = wrap;
104
- var h = "suspendedStart",
105
- l = "suspendedYield",
106
- f = "executing",
107
- s = "completed",
108
- y = {};
109
- function Generator() {}
110
- function GeneratorFunction() {}
111
- function GeneratorFunctionPrototype() {}
112
- var p = {};
113
- define(p, a, function () {
114
- return this;
115
- });
116
- var d = Object.getPrototypeOf,
117
- v = d && d(d(values([])));
118
- v && v !== r && n.call(v, a) && (p = v);
119
- var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
120
- function defineIteratorMethods(t) {
121
- ["next", "throw", "return"].forEach(function (e) {
122
- define(t, e, function (t) {
123
- return this._invoke(e, t);
124
- });
125
- });
126
- }
127
- function AsyncIterator(t, e) {
128
- function invoke(r, o, i, a) {
129
- var c = tryCatch(t[r], t, o);
130
- if ("throw" !== c.type) {
131
- var u = c.arg,
132
- h = u.value;
133
- return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
134
- invoke("next", t, i, a);
135
- }, function (t) {
136
- invoke("throw", t, i, a);
137
- }) : e.resolve(h).then(function (t) {
138
- u.value = t, i(u);
139
- }, function (t) {
140
- return invoke("throw", t, i, a);
141
- });
142
- }
143
- a(c.arg);
144
- }
145
- var r;
146
- o(this, "_invoke", {
147
- value: function (t, n) {
148
- function callInvokeWithMethodAndArg() {
149
- return new e(function (e, r) {
150
- invoke(t, n, e, r);
151
- });
152
- }
153
- return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
154
- }
155
- });
156
- }
157
- function makeInvokeMethod(e, r, n) {
158
- var o = h;
159
- return function (i, a) {
160
- if (o === f) throw Error("Generator is already running");
161
- if (o === s) {
162
- if ("throw" === i) throw a;
163
- return {
164
- value: t,
165
- done: !0
166
- };
167
- }
168
- for (n.method = i, n.arg = a;;) {
169
- var c = n.delegate;
170
- if (c) {
171
- var u = maybeInvokeDelegate(c, n);
172
- if (u) {
173
- if (u === y) continue;
174
- return u;
175
- }
176
- }
177
- if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
178
- if (o === h) throw o = s, n.arg;
179
- n.dispatchException(n.arg);
180
- } else "return" === n.method && n.abrupt("return", n.arg);
181
- o = f;
182
- var p = tryCatch(e, r, n);
183
- if ("normal" === p.type) {
184
- if (o = n.done ? s : l, p.arg === y) continue;
185
- return {
186
- value: p.arg,
187
- done: n.done
188
- };
189
- }
190
- "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
191
- }
192
- };
193
- }
194
- function maybeInvokeDelegate(e, r) {
195
- var n = r.method,
196
- o = e.iterator[n];
197
- if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
198
- var i = tryCatch(o, e.iterator, r.arg);
199
- if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
200
- var a = i.arg;
201
- return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
202
- }
203
- function pushTryEntry(t) {
204
- var e = {
205
- tryLoc: t[0]
206
- };
207
- 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
208
- }
209
- function resetTryEntry(t) {
210
- var e = t.completion || {};
211
- e.type = "normal", delete e.arg, t.completion = e;
212
- }
213
- function Context(t) {
214
- this.tryEntries = [{
215
- tryLoc: "root"
216
- }], t.forEach(pushTryEntry, this), this.reset(!0);
217
- }
218
- function values(e) {
219
- if (e || "" === e) {
220
- var r = e[a];
221
- if (r) return r.call(e);
222
- if ("function" == typeof e.next) return e;
223
- if (!isNaN(e.length)) {
224
- var o = -1,
225
- i = function next() {
226
- for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
227
- return next.value = t, next.done = !0, next;
228
- };
229
- return i.next = i;
230
- }
231
- }
232
- throw new TypeError(typeof e + " is not iterable");
233
- }
234
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
235
- value: GeneratorFunctionPrototype,
236
- configurable: !0
237
- }), o(GeneratorFunctionPrototype, "constructor", {
238
- value: GeneratorFunction,
239
- configurable: !0
240
- }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
241
- var e = "function" == typeof t && t.constructor;
242
- return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
243
- }, e.mark = function (t) {
244
- return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
245
- }, e.awrap = function (t) {
246
- return {
247
- __await: t
248
- };
249
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
250
- return this;
251
- }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
252
- void 0 === i && (i = Promise);
253
- var a = new AsyncIterator(wrap(t, r, n, o), i);
254
- return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
255
- return t.done ? t.value : a.next();
256
- });
257
- }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
258
- return this;
259
- }), define(g, "toString", function () {
260
- return "[object Generator]";
261
- }), e.keys = function (t) {
262
- var e = Object(t),
263
- r = [];
264
- for (var n in e) r.push(n);
265
- return r.reverse(), function next() {
266
- for (; r.length;) {
267
- var t = r.pop();
268
- if (t in e) return next.value = t, next.done = !1, next;
269
- }
270
- return next.done = !0, next;
271
- };
272
- }, e.values = values, Context.prototype = {
273
- constructor: Context,
274
- reset: function (e) {
275
- if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
276
- },
277
- stop: function () {
278
- this.done = !0;
279
- var t = this.tryEntries[0].completion;
280
- if ("throw" === t.type) throw t.arg;
281
- return this.rval;
282
- },
283
- dispatchException: function (e) {
284
- if (this.done) throw e;
285
- var r = this;
286
- function handle(n, o) {
287
- return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
288
- }
289
- for (var o = this.tryEntries.length - 1; o >= 0; --o) {
290
- var i = this.tryEntries[o],
291
- a = i.completion;
292
- if ("root" === i.tryLoc) return handle("end");
293
- if (i.tryLoc <= this.prev) {
294
- var c = n.call(i, "catchLoc"),
295
- u = n.call(i, "finallyLoc");
296
- if (c && u) {
297
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
298
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
299
- } else if (c) {
300
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
301
- } else {
302
- if (!u) throw Error("try statement without catch or finally");
303
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
304
- }
305
- }
306
- }
307
- },
308
- abrupt: function (t, e) {
309
- for (var r = this.tryEntries.length - 1; r >= 0; --r) {
310
- var o = this.tryEntries[r];
311
- if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
312
- var i = o;
313
- break;
314
- }
315
- }
316
- i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
317
- var a = i ? i.completion : {};
318
- return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
319
- },
320
- complete: function (t, e) {
321
- if ("throw" === t.type) throw t.arg;
322
- return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
323
- },
324
- finish: function (t) {
325
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
326
- var r = this.tryEntries[e];
327
- if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
328
- }
329
- },
330
- catch: function (t) {
331
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
332
- var r = this.tryEntries[e];
333
- if (r.tryLoc === t) {
334
- var n = r.completion;
335
- if ("throw" === n.type) {
336
- var o = n.arg;
337
- resetTryEntry(r);
338
- }
339
- return o;
340
- }
341
- }
342
- throw Error("illegal catch attempt");
343
- },
344
- delegateYield: function (e, r, n) {
345
- return this.delegate = {
346
- iterator: values(e),
347
- resultName: r,
348
- nextLoc: n
349
- }, "next" === this.method && (this.arg = t), y;
350
- }
351
- }, e;
352
- }
353
- function _toPrimitive(t, r) {
354
- if ("object" != typeof t || !t) return t;
355
- var e = t[Symbol.toPrimitive];
356
- if (void 0 !== e) {
357
- var i = e.call(t, r || "default");
358
- if ("object" != typeof i) return i;
359
- throw new TypeError("@@toPrimitive must return a primitive value.");
360
- }
361
- return ("string" === r ? String : Number)(t);
362
- }
363
- function _toPropertyKey(t) {
364
- var i = _toPrimitive(t, "string");
365
- return "symbol" == typeof i ? i : i + "";
366
- }
1
+ import { asClass, createContainer, InjectionMode } from 'awilix';
2
+ import { lerp, Contrast, clampDouble, hexFromArgb, DislikeAnalyzer, Hct, argbFromHex, TonalPalette, sanitizeDegreesDouble } from '@material/material-color-utilities';
367
3
 
368
4
  /**
369
5
  * @license
@@ -828,6 +464,41 @@ function ToneDeltaPair(roleA, roleB, delta, polarity, stayTogether) {
828
464
  this.stayTogether = stayTogether;
829
465
  };
830
466
 
467
+ function _defineProperties(e, r) {
468
+ for (var t = 0; t < r.length; t++) {
469
+ var o = r[t];
470
+ o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
471
+ }
472
+ }
473
+ function _createClass(e, r, t) {
474
+ return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
475
+ writable: !1
476
+ }), e;
477
+ }
478
+ function _extends() {
479
+ return _extends = Object.assign ? Object.assign.bind() : function (n) {
480
+ for (var e = 1; e < arguments.length; e++) {
481
+ var t = arguments[e];
482
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
483
+ }
484
+ return n;
485
+ }, _extends.apply(null, arguments);
486
+ }
487
+ function _toPrimitive(t, r) {
488
+ if ("object" != typeof t || !t) return t;
489
+ var e = t[Symbol.toPrimitive];
490
+ if (void 0 !== e) {
491
+ var i = e.call(t, r || "default");
492
+ if ("object" != typeof i) return i;
493
+ throw new TypeError("@@toPrimitive must return a primitive value.");
494
+ }
495
+ return ("string" === r ? String : Number)(t);
496
+ }
497
+ function _toPropertyKey(t) {
498
+ var i = _toPrimitive(t, "string");
499
+ return "symbol" == typeof i ? i : i + "";
500
+ }
501
+
831
502
  var ColorEntity = /*#__PURE__*/function () {
832
503
  function ColorEntity(option, schemeService, colorService) {
833
504
  this.option = void 0;
@@ -863,85 +534,6 @@ var ColorEntity = /*#__PURE__*/function () {
863
534
  return ColorEntity;
864
535
  }();
865
536
 
866
- var SchemeEntity = /*#__PURE__*/function () {
867
- function SchemeEntity(options) {
868
- this.options = void 0;
869
- this.options = options;
870
- }
871
- var _proto = SchemeEntity.prototype;
872
- _proto.getPalette = function getPalette(key) {
873
- if (!this.options) {
874
- throw new Error('Scheme options is not set');
875
- }
876
- var palette = this.options.palettes.get(key);
877
- if (!palette) {
878
- throw new Error("Palette " + key + " not found");
879
- }
880
- return palette;
881
- };
882
- return _createClass(SchemeEntity, [{
883
- key: "contrastLevel",
884
- get: function get() {
885
- if (!this.options) {
886
- throw new Error('Scheme options is not set');
887
- }
888
- return this.options.contrastLevel;
889
- }
890
- }, {
891
- key: "isDark",
892
- get: function get() {
893
- if (!this.options) {
894
- throw new Error('Scheme options is not set');
895
- }
896
- return this.options.isDark;
897
- }
898
- }, {
899
- key: "sourceColorHct",
900
- get: function get() {
901
- if (!this.options) {
902
- throw new Error('Scheme options is not set');
903
- }
904
- return Hct.fromInt(this.options.sourceColorArgb);
905
- }
906
- }]);
907
- }();
908
-
909
- var SchemeService = /*#__PURE__*/function () {
910
- function SchemeService() {
911
- this.schemeEntity = void 0;
912
- this.options = void 0;
913
- }
914
- var _proto = SchemeService.prototype;
915
- _proto.createOrUpdate = function createOrUpdate(options) {
916
- this.options = mergeDeep(options, this.options);
917
- var palettes = new Map();
918
- var sourceColorArgb = argbFromHex(this.options.sourceColorHex);
919
- var sourceColorHct = Hct.fromInt(sourceColorArgb);
920
- if (!this.options.palettes) {
921
- return;
922
- }
923
- for (var _i = 0, _Object$entries = Object.entries(this.options.palettes); _i < _Object$entries.length; _i++) {
924
- var _Object$entries$_i = _Object$entries[_i],
925
- key = _Object$entries$_i[0],
926
- paletteFunction = _Object$entries$_i[1];
927
- var palette = paletteFunction(sourceColorHct);
928
- palettes.set(key, palette);
929
- }
930
- this.schemeEntity = new SchemeEntity(_extends({}, this.options, {
931
- palettes: palettes,
932
- sourceColorArgb: sourceColorArgb
933
- }));
934
- };
935
- _proto.get = function get() {
936
- if (!this.schemeEntity) {
937
- throw new Error('Scheme is not created');
938
- }
939
- return this.schemeEntity;
940
- };
941
- return SchemeService;
942
- }();
943
- SchemeService = /*#__PURE__*/__decorate([/*#__PURE__*/Injectable()], SchemeService);
944
-
945
537
  function capitalizeFirstLetter(string) {
946
538
  return string.charAt(0).toUpperCase() + string.slice(1);
947
539
  }
@@ -949,9 +541,10 @@ var highestSurface = function highestSurface(s, colorManagerService) {
949
541
  return s.isDark ? colorManagerService.get('surfaceBright').getDynamicColor() : colorManagerService.get('surfaceDim').getDynamicColor();
950
542
  };
951
543
  var ColorManagerService = /*#__PURE__*/function () {
952
- function ColorManagerService(schemeService) {
953
- this.schemeService = void 0;
544
+ function ColorManagerService(_ref) {
545
+ var schemeService = _ref.schemeService;
954
546
  this.colorMap = new Map();
547
+ this.schemeService = void 0;
955
548
  this.schemeService = schemeService;
956
549
  }
957
550
  var _proto = ColorManagerService.prototype;
@@ -1137,7 +730,6 @@ var ColorManagerService = /*#__PURE__*/function () {
1137
730
  };
1138
731
  return ColorManagerService;
1139
732
  }();
1140
- ColorManagerService = /*#__PURE__*/__decorate([/*#__PURE__*/Injectable(), /*#__PURE__*/__metadata("design:paramtypes", [SchemeService])], ColorManagerService);
1141
733
 
1142
734
  function findDesiredChromaByTone(hue, chroma, tone, byDecreasingTone) {
1143
735
  var answer = tone;
@@ -1478,7 +1070,8 @@ var defaultColors = function defaultColors(colorManagerService) {
1478
1070
  };
1479
1071
 
1480
1072
  var ColorService = /*#__PURE__*/function () {
1481
- function ColorService(colorManagerService) {
1073
+ function ColorService(_ref) {
1074
+ var colorManagerService = _ref.colorManagerService;
1482
1075
  this.colorManagerService = void 0;
1483
1076
  this.colorManagerService = colorManagerService;
1484
1077
  }
@@ -1528,28 +1121,97 @@ var ColorService = /*#__PURE__*/function () {
1528
1121
  };
1529
1122
  return ColorService;
1530
1123
  }();
1531
- ColorService = /*#__PURE__*/__decorate([/*#__PURE__*/Injectable(), /*#__PURE__*/__metadata("design:paramtypes", [ColorManagerService])], ColorService);
1532
1124
 
1533
- var VariantService = /*#__PURE__*/function () {
1534
- function VariantService(schemeService) {
1535
- this.schemeService = void 0;
1536
- this.schemeService = schemeService;
1125
+ var ColorModule = {
1126
+ colorManagerService: /*#__PURE__*/asClass(ColorManagerService).singleton(),
1127
+ colorService: /*#__PURE__*/asClass(ColorService).singleton()
1128
+ };
1129
+
1130
+ var SchemeEntity = /*#__PURE__*/function () {
1131
+ function SchemeEntity(options) {
1132
+ this.options = void 0;
1133
+ this.options = options;
1537
1134
  }
1538
- var _proto = VariantService.prototype;
1539
- _proto.set = function set(variantEntity) {
1540
- if (!variantEntity.palettes.error) {
1541
- variantEntity.palettes.error = function () {
1542
- return TonalPalette.fromHueAndChroma(25.0, 84.0);
1543
- };
1135
+ var _proto = SchemeEntity.prototype;
1136
+ _proto.getPalette = function getPalette(key) {
1137
+ if (!this.options) {
1138
+ throw new Error('Scheme options is not set');
1544
1139
  }
1545
- this.schemeService.createOrUpdate(variantEntity);
1140
+ var palette = this.options.palettes.get(key);
1141
+ if (!palette) {
1142
+ throw new Error("Palette " + key + " not found");
1143
+ }
1144
+ return palette;
1546
1145
  };
1547
- return VariantService;
1146
+ return _createClass(SchemeEntity, [{
1147
+ key: "contrastLevel",
1148
+ get: function get() {
1149
+ if (!this.options) {
1150
+ throw new Error('Scheme options is not set');
1151
+ }
1152
+ return this.options.contrastLevel;
1153
+ }
1154
+ }, {
1155
+ key: "isDark",
1156
+ get: function get() {
1157
+ if (!this.options) {
1158
+ throw new Error('Scheme options is not set');
1159
+ }
1160
+ return this.options.isDark;
1161
+ }
1162
+ }, {
1163
+ key: "sourceColorHct",
1164
+ get: function get() {
1165
+ if (!this.options) {
1166
+ throw new Error('Scheme options is not set');
1167
+ }
1168
+ return Hct.fromInt(this.options.sourceColorArgb);
1169
+ }
1170
+ }]);
1171
+ }();
1172
+
1173
+ var SchemeService = /*#__PURE__*/function () {
1174
+ function SchemeService() {
1175
+ this.schemeEntity = void 0;
1176
+ this.options = void 0;
1177
+ }
1178
+ var _proto = SchemeService.prototype;
1179
+ _proto.createOrUpdate = function createOrUpdate(options) {
1180
+ var _this$options;
1181
+ this.options = _extends({}, this.options, options, {
1182
+ palettes: _extends({}, (_this$options = this.options) == null ? void 0 : _this$options.palettes, options.palettes)
1183
+ });
1184
+ var palettes = new Map();
1185
+ var sourceColorArgb = argbFromHex(this.options.sourceColorHex);
1186
+ var sourceColorHct = Hct.fromInt(sourceColorArgb);
1187
+ if (!this.options.palettes) {
1188
+ return;
1189
+ }
1190
+ for (var _i = 0, _Object$entries = Object.entries(this.options.palettes); _i < _Object$entries.length; _i++) {
1191
+ var _Object$entries$_i = _Object$entries[_i],
1192
+ key = _Object$entries$_i[0],
1193
+ paletteFunction = _Object$entries$_i[1];
1194
+ var palette = paletteFunction(sourceColorHct);
1195
+ palettes.set(key, palette);
1196
+ }
1197
+ this.schemeEntity = new SchemeEntity(_extends({}, this.options, {
1198
+ palettes: palettes,
1199
+ sourceColorArgb: sourceColorArgb
1200
+ }));
1201
+ };
1202
+ _proto.get = function get() {
1203
+ if (!this.schemeEntity) {
1204
+ throw new Error('Scheme is not created');
1205
+ }
1206
+ return this.schemeEntity;
1207
+ };
1208
+ return SchemeService;
1548
1209
  }();
1549
- VariantService = /*#__PURE__*/__decorate([/*#__PURE__*/Injectable(), /*#__PURE__*/__metadata("design:paramtypes", [SchemeService])], VariantService);
1550
1210
 
1551
1211
  var ThemeService = /*#__PURE__*/function () {
1552
- function ThemeService(schemeService, variantService) {
1212
+ function ThemeService(_ref) {
1213
+ var schemeService = _ref.schemeService,
1214
+ variantService = _ref.variantService;
1553
1215
  this.schemeService = void 0;
1554
1216
  this.variantService = void 0;
1555
1217
  this.schemeService = schemeService;
@@ -1587,60 +1249,61 @@ var ThemeService = /*#__PURE__*/function () {
1587
1249
  };
1588
1250
  return ThemeService;
1589
1251
  }();
1590
- ThemeService = /*#__PURE__*/__decorate([/*#__PURE__*/Injectable(), /*#__PURE__*/__metadata("design:paramtypes", [SchemeService, VariantService])], ThemeService);
1591
1252
 
1592
- var AppService = function AppService(colorService, themeService) {
1253
+ var VariantService = /*#__PURE__*/function () {
1254
+ function VariantService(_ref) {
1255
+ var schemeService = _ref.schemeService;
1256
+ this.schemeService = void 0;
1257
+ this.schemeService = schemeService;
1258
+ }
1259
+ var _proto = VariantService.prototype;
1260
+ _proto.set = function set(variantEntity) {
1261
+ if (!variantEntity.palettes.error) {
1262
+ variantEntity.palettes.error = function () {
1263
+ return TonalPalette.fromHueAndChroma(25.0, 84.0);
1264
+ };
1265
+ }
1266
+ this.schemeService.createOrUpdate(variantEntity);
1267
+ };
1268
+ return VariantService;
1269
+ }();
1270
+
1271
+ var ThemeModule = {
1272
+ schemeService: /*#__PURE__*/asClass(SchemeService).singleton(),
1273
+ variantService: /*#__PURE__*/asClass(VariantService).singleton(),
1274
+ themeService: /*#__PURE__*/asClass(ThemeService).singleton()
1275
+ };
1276
+
1277
+ var AppService = function AppService(_ref) {
1278
+ var colorService = _ref.colorService,
1279
+ themeService = _ref.themeService;
1593
1280
  this.colorService = void 0;
1594
1281
  this.themeService = void 0;
1595
1282
  this.colorService = colorService;
1596
1283
  this.themeService = themeService;
1597
1284
  };
1598
- AppService = /*#__PURE__*/__decorate([/*#__PURE__*/Injectable(), /*#__PURE__*/__metadata("design:paramtypes", [ColorService, ThemeService])], AppService);
1599
1285
 
1600
- var ThemeModule = function ThemeModule() {};
1601
- ThemeModule = /*#__PURE__*/__decorate([/*#__PURE__*/Module({
1602
- providers: [SchemeService, ThemeService, VariantService],
1603
- exports: [ThemeService, SchemeService]
1604
- })], ThemeModule);
1605
-
1606
- var ColorModule = function ColorModule() {};
1607
- ColorModule = /*#__PURE__*/__decorate([/*#__PURE__*/Module({
1608
- imports: [ThemeModule],
1609
- providers: [ColorService, ColorManagerService],
1610
- exports: [ColorService]
1611
- })], ColorModule);
1286
+ var AppModule = {
1287
+ appService: /*#__PURE__*/asClass(AppService).singleton()
1288
+ };
1612
1289
 
1613
- var AppModule = function AppModule() {};
1614
- AppModule = /*#__PURE__*/__decorate([/*#__PURE__*/Module({
1615
- imports: [ColorModule, ThemeModule],
1616
- providers: [AppService]
1617
- })], AppModule);
1290
+ function importContainer(container, services) {
1291
+ services.forEach(function (service) {
1292
+ Object.entries(service).forEach(function (_ref) {
1293
+ var name = _ref[0],
1294
+ serviceClass = _ref[1];
1295
+ container.register(name, serviceClass);
1296
+ });
1297
+ });
1298
+ return container;
1299
+ }
1300
+ var AppContainer = /*#__PURE__*/createContainer({
1301
+ injectionMode: InjectionMode.PROXY
1302
+ });
1303
+ importContainer(AppContainer, [AppModule, ColorModule, ThemeModule]);
1618
1304
 
1619
1305
  function main() {
1620
- return _main.apply(this, arguments);
1621
- }
1622
- function _main() {
1623
- _main = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1624
- var app, appService, close;
1625
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1626
- while (1) switch (_context.prev = _context.next) {
1627
- case 0:
1628
- _context.next = 2;
1629
- return NestFactory.create(AppModule);
1630
- case 2:
1631
- app = _context.sent;
1632
- appService = app.get(AppService);
1633
- close = function close() {
1634
- return app.close();
1635
- };
1636
- return _context.abrupt("return", [appService, close]);
1637
- case 6:
1638
- case "end":
1639
- return _context.stop();
1640
- }
1641
- }, _callee);
1642
- }));
1643
- return _main.apply(this, arguments);
1306
+ return AppContainer.resolve('appService');
1644
1307
  }
1645
1308
 
1646
1309
  var getRotatedHue = function getRotatedHue(sourceColor, hues, rotations) {
@@ -1716,5 +1379,5 @@ VariantModel.hues = [0.0, 41.0, 61.0, 101.0, 131.0, 181.0, 251.0, 301.0, 360.0];
1716
1379
  VariantModel.secondaryRotations = [18.0, 15.0, 10.0, 12.0, 15.0, 18.0, 15.0, 12.0, 12.0];
1717
1380
  VariantModel.tertiaryRotations = [35.0, 30.0, 20.0, 25.0, 30.0, 35.0, 30.0, 25.0, 25.0];
1718
1381
 
1719
- export { AppModule, AppService, ColorEntity, ColorManagerService, ColorModule, ColorService, ContrastCurve, DynamicColor, SchemeEntity, SchemeService, ThemeModule, ThemeService, ToneDeltaPair, VariantEntity, VariantModel, VariantService, defaultColors, getRotatedHue, highestSurface, main };
1382
+ export { AppContainer, AppModule, AppService, ColorEntity, ColorManagerService, ColorModule, ColorService, ContrastCurve, DynamicColor, SchemeEntity, SchemeService, ThemeModule, ThemeService, ToneDeltaPair, VariantEntity, VariantModel, VariantService, defaultColors, getRotatedHue, highestSurface, importContainer, main };
1720
1383
  //# sourceMappingURL=theme.esm.js.map