@udixio/theme 1.0.0-beta.3 → 1.0.0-beta.30

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 (97) hide show
  1. package/dist/app.container.d.ts +5 -0
  2. package/dist/app.module.d.ts +2 -2
  3. package/dist/app.service.d.ts +9 -3
  4. package/dist/color/color.interface.d.ts +1 -2
  5. package/dist/color/color.module.d.ts +2 -2
  6. package/dist/color/entities/color.entity.d.ts +6 -1
  7. package/dist/color/entities/index.d.ts +1 -0
  8. package/dist/color/index.d.ts +5 -0
  9. package/dist/color/models/default-color.model.d.ts +2 -3
  10. package/dist/color/models/index.d.ts +1 -0
  11. package/dist/color/services/color-manager.service.d.ts +18 -0
  12. package/dist/color/services/color.service.d.ts +21 -0
  13. package/dist/color/services/index.d.ts +2 -0
  14. package/dist/config/config.interface.d.ts +13 -0
  15. package/dist/config/config.module.d.ts +2 -0
  16. package/dist/config/config.service.d.ts +12 -0
  17. package/dist/config/index.d.ts +3 -0
  18. package/dist/index.d.ts +11 -0
  19. package/dist/main.d.ts +6 -1
  20. package/dist/material-color-utilities/index.d.ts +1 -0
  21. package/dist/plugin/index.d.ts +3 -0
  22. package/dist/plugin/plugin.module.d.ts +2 -0
  23. package/dist/plugin/plugin.service.d.ts +8 -0
  24. package/dist/plugin/pluginAbstract.d.ts +18 -0
  25. package/dist/plugins/font/font.plugin.d.ts +49 -0
  26. package/dist/plugins/font/index.d.ts +1 -0
  27. package/dist/plugins/tailwind/index.d.ts +3 -0
  28. package/dist/plugins/tailwind/main.d.ts +13 -0
  29. package/dist/plugins/tailwind/plugins-tailwind/font.d.ts +5 -0
  30. package/dist/plugins/tailwind/plugins-tailwind/index.d.ts +2 -0
  31. package/dist/plugins/tailwind/plugins-tailwind/state.d.ts +4 -0
  32. package/dist/plugins/tailwind/plugins-tailwind/themer.d.ts +10 -0
  33. package/dist/plugins/tailwind/tailwind.plugin.d.ts +18 -0
  34. package/dist/theme/entities/index.d.ts +2 -0
  35. package/dist/theme/entities/variant.entity.d.ts +2 -1
  36. package/dist/theme/index.d.ts +4 -0
  37. package/dist/theme/models/index.d.ts +1 -0
  38. package/dist/theme/services/index.d.ts +3 -0
  39. package/dist/theme/services/scheme.service.d.ts +7 -2
  40. package/dist/theme/services/theme.service.d.ts +16 -7
  41. package/dist/theme/services/variant.service.d.ts +8 -2
  42. package/dist/theme/theme.module.d.ts +2 -2
  43. package/dist/theme.cjs.development.js +1416 -906
  44. package/dist/theme.cjs.development.js.map +1 -1
  45. package/dist/theme.cjs.production.min.js +1 -1
  46. package/dist/theme.cjs.production.min.js.map +1 -1
  47. package/dist/theme.esm.js +1383 -907
  48. package/dist/theme.esm.js.map +1 -1
  49. package/package.json +21 -22
  50. package/src/app.container.ts +46 -0
  51. package/src/app.module.ts +5 -8
  52. package/src/app.service.spec.ts +1 -1
  53. package/src/app.service.ts +20 -8
  54. package/src/color/color.interface.ts +1 -3
  55. package/src/color/color.module.ts +8 -10
  56. package/src/color/entities/color.entity.ts +13 -1
  57. package/src/color/entities/index.ts +1 -0
  58. package/src/color/index.ts +5 -0
  59. package/src/color/models/default-color.model.ts +205 -202
  60. package/src/color/models/index.ts +1 -0
  61. package/src/color/{color-manager.service.ts → services/color-manager.service.ts} +23 -15
  62. package/src/color/{color.service.spec.ts → services/color.service.spec.ts} +1 -1
  63. package/src/color/services/color.service.ts +75 -0
  64. package/src/color/services/index.ts +2 -0
  65. package/src/config/config.interface.ts +14 -0
  66. package/src/config/config.module.ts +7 -0
  67. package/src/config/config.service.ts +101 -0
  68. package/src/config/index.ts +3 -0
  69. package/src/index.ts +11 -0
  70. package/src/main.ts +13 -7
  71. package/src/material-color-utilities/index.ts +1 -0
  72. package/src/plugin/index.ts +3 -0
  73. package/src/plugin/plugin.module.ts +7 -0
  74. package/src/plugin/plugin.service.ts +42 -0
  75. package/src/plugin/pluginAbstract.ts +44 -0
  76. package/src/plugins/font/font.plugin.ts +203 -0
  77. package/src/plugins/font/index.ts +1 -0
  78. package/src/plugins/tailwind/index.ts +3 -0
  79. package/src/plugins/tailwind/main.ts +16 -0
  80. package/src/plugins/tailwind/plugins-tailwind/font.ts +69 -0
  81. package/src/plugins/tailwind/plugins-tailwind/index.ts +2 -0
  82. package/src/plugins/tailwind/plugins-tailwind/state.ts +88 -0
  83. package/src/plugins/tailwind/plugins-tailwind/themer.ts +137 -0
  84. package/src/plugins/tailwind/tailwind.plugin.ts +72 -0
  85. package/src/theme/entities/index.ts +2 -0
  86. package/src/theme/entities/variant.entity.ts +2 -1
  87. package/src/theme/index.ts +4 -0
  88. package/src/theme/models/index.ts +1 -0
  89. package/src/theme/models/variant.model.ts +7 -0
  90. package/src/theme/services/index.ts +3 -0
  91. package/src/theme/services/scheme.service.ts +39 -11
  92. package/src/theme/services/theme.service.ts +30 -14
  93. package/src/theme/services/variant.service.ts +40 -5
  94. package/src/theme/theme.module.ts +8 -9
  95. package/dist/color/color-manager.service.d.ts +0 -15
  96. package/dist/color/color.service.d.ts +0 -14
  97. package/src/color/color.service.ts +0 -58
@@ -2,36 +2,71 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var core = require('@nestjs/core');
6
- var tslib = require('tslib');
7
- var common = require('@nestjs/common');
5
+ var awilix = require('awilix');
8
6
  var materialColorUtilities = require('@material/material-color-utilities');
9
- var mergeDeep = require('merge-deep');
7
+ var node_path = require('node:path');
8
+ var node_fs = require('node:fs');
9
+ var plugin = require('tailwindcss/plugin');
10
10
 
11
- function asyncGeneratorStep(n, t, e, r, o, a, c) {
12
- try {
13
- var i = n[a](c),
14
- u = i.value;
15
- } catch (n) {
16
- return void e(n);
11
+ var ColorService = /*#__PURE__*/function () {
12
+ function ColorService(_ref) {
13
+ var colorManagerService = _ref.colorManagerService;
14
+ this.colorManagerService = void 0;
15
+ this.colorManagerService = colorManagerService;
17
16
  }
18
- i.done ? t(u) : Promise.resolve(u).then(r, o);
19
- }
20
- function _asyncToGenerator(n) {
21
- return function () {
22
- var t = this,
23
- e = arguments;
24
- return new Promise(function (r, o) {
25
- var a = n.apply(t, e);
26
- function _next(n) {
27
- asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
17
+ var _proto = ColorService.prototype;
18
+ _proto.getColors = function getColors() {
19
+ return this.colorManagerService.getAll();
20
+ }
21
+ // getColors() {
22
+ // const colors: Record<string, string> = {};
23
+ //
24
+ // for (const [key, value] of this.colorManagerService.getAll()) {
25
+ // colors[key] = hexFromArgb(value.getArgb(this.schemeService.get()));
26
+ // }
27
+ //
28
+ // return colors;
29
+ // }
30
+ ;
31
+ _proto.addColor = function addColor(key, color) {
32
+ return this.colorManagerService.createOrUpdate(key, color);
33
+ };
34
+ _proto.addColors = function addColors(args) {
35
+ var _this = this;
36
+ if (!Array.isArray(args)) args = [args];
37
+ args.forEach(function (args) {
38
+ if (typeof args === 'function') {
39
+ args = args(_this);
40
+ }
41
+ if (args.fromPalettes) {
42
+ if (!Array.isArray(args.fromPalettes)) args.fromPalettes = [args.fromPalettes];
43
+ args.fromPalettes.map(function (paletteKey) {
44
+ _this.colorManagerService.addFromPalette(paletteKey);
45
+ });
28
46
  }
29
- function _throw(n) {
30
- asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
47
+ if (args.colors) {
48
+ Object.keys(args.colors).map(function (key) {
49
+ return _this.addColor(key, args.colors[key]);
50
+ });
31
51
  }
32
- _next(void 0);
33
52
  });
34
53
  };
54
+ _proto.getColor = function getColor(key) {
55
+ return this.colorManagerService.get(key);
56
+ };
57
+ _proto.removeColor = function removeColor(key) {
58
+ return this.colorManagerService.remove(key);
59
+ };
60
+ _proto.updateColor = function updateColor(key, newColor) {
61
+ return this.colorManagerService.createOrUpdate(key, newColor);
62
+ };
63
+ return ColorService;
64
+ }();
65
+
66
+ function _arrayLikeToArray(r, a) {
67
+ (null == a || a > r.length) && (a = r.length);
68
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
69
+ return n;
35
70
  }
36
71
  function _defineProperties(e, r) {
37
72
  for (var t = 0; t < r.length; t++) {
@@ -44,6 +79,23 @@ function _createClass(e, r, t) {
44
79
  writable: !1
45
80
  }), e;
46
81
  }
82
+ function _createForOfIteratorHelperLoose(r, e) {
83
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
84
+ if (t) return (t = t.call(r)).next.bind(t);
85
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
86
+ t && (r = t);
87
+ var o = 0;
88
+ return function () {
89
+ return o >= r.length ? {
90
+ done: !0
91
+ } : {
92
+ done: !1,
93
+ value: r[o++]
94
+ };
95
+ };
96
+ }
97
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
98
+ }
47
99
  function _extends() {
48
100
  return _extends = Object.assign ? Object.assign.bind() : function (n) {
49
101
  for (var e = 1; e < arguments.length; e++) {
@@ -53,306 +105,13 @@ function _extends() {
53
105
  return n;
54
106
  }, _extends.apply(null, arguments);
55
107
  }
56
- function _regeneratorRuntime() {
57
- _regeneratorRuntime = function () {
58
- return e;
59
- };
60
- var t,
61
- e = {},
62
- r = Object.prototype,
63
- n = r.hasOwnProperty,
64
- o = Object.defineProperty || function (t, e, r) {
65
- t[e] = r.value;
66
- },
67
- i = "function" == typeof Symbol ? Symbol : {},
68
- a = i.iterator || "@@iterator",
69
- c = i.asyncIterator || "@@asyncIterator",
70
- u = i.toStringTag || "@@toStringTag";
71
- function define(t, e, r) {
72
- return Object.defineProperty(t, e, {
73
- value: r,
74
- enumerable: !0,
75
- configurable: !0,
76
- writable: !0
77
- }), t[e];
78
- }
79
- try {
80
- define({}, "");
81
- } catch (t) {
82
- define = function (t, e, r) {
83
- return t[e] = r;
84
- };
85
- }
86
- function wrap(t, e, r, n) {
87
- var i = e && e.prototype instanceof Generator ? e : Generator,
88
- a = Object.create(i.prototype),
89
- c = new Context(n || []);
90
- return o(a, "_invoke", {
91
- value: makeInvokeMethod(t, r, c)
92
- }), a;
93
- }
94
- function tryCatch(t, e, r) {
95
- try {
96
- return {
97
- type: "normal",
98
- arg: t.call(e, r)
99
- };
100
- } catch (t) {
101
- return {
102
- type: "throw",
103
- arg: t
104
- };
105
- }
106
- }
107
- e.wrap = wrap;
108
- var h = "suspendedStart",
109
- l = "suspendedYield",
110
- f = "executing",
111
- s = "completed",
112
- y = {};
113
- function Generator() {}
114
- function GeneratorFunction() {}
115
- function GeneratorFunctionPrototype() {}
116
- var p = {};
117
- define(p, a, function () {
118
- return this;
119
- });
120
- var d = Object.getPrototypeOf,
121
- v = d && d(d(values([])));
122
- v && v !== r && n.call(v, a) && (p = v);
123
- var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
124
- function defineIteratorMethods(t) {
125
- ["next", "throw", "return"].forEach(function (e) {
126
- define(t, e, function (t) {
127
- return this._invoke(e, t);
128
- });
129
- });
130
- }
131
- function AsyncIterator(t, e) {
132
- function invoke(r, o, i, a) {
133
- var c = tryCatch(t[r], t, o);
134
- if ("throw" !== c.type) {
135
- var u = c.arg,
136
- h = u.value;
137
- return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
138
- invoke("next", t, i, a);
139
- }, function (t) {
140
- invoke("throw", t, i, a);
141
- }) : e.resolve(h).then(function (t) {
142
- u.value = t, i(u);
143
- }, function (t) {
144
- return invoke("throw", t, i, a);
145
- });
146
- }
147
- a(c.arg);
148
- }
149
- var r;
150
- o(this, "_invoke", {
151
- value: function (t, n) {
152
- function callInvokeWithMethodAndArg() {
153
- return new e(function (e, r) {
154
- invoke(t, n, e, r);
155
- });
156
- }
157
- return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
158
- }
159
- });
160
- }
161
- function makeInvokeMethod(e, r, n) {
162
- var o = h;
163
- return function (i, a) {
164
- if (o === f) throw Error("Generator is already running");
165
- if (o === s) {
166
- if ("throw" === i) throw a;
167
- return {
168
- value: t,
169
- done: !0
170
- };
171
- }
172
- for (n.method = i, n.arg = a;;) {
173
- var c = n.delegate;
174
- if (c) {
175
- var u = maybeInvokeDelegate(c, n);
176
- if (u) {
177
- if (u === y) continue;
178
- return u;
179
- }
180
- }
181
- if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
182
- if (o === h) throw o = s, n.arg;
183
- n.dispatchException(n.arg);
184
- } else "return" === n.method && n.abrupt("return", n.arg);
185
- o = f;
186
- var p = tryCatch(e, r, n);
187
- if ("normal" === p.type) {
188
- if (o = n.done ? s : l, p.arg === y) continue;
189
- return {
190
- value: p.arg,
191
- done: n.done
192
- };
193
- }
194
- "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
195
- }
196
- };
197
- }
198
- function maybeInvokeDelegate(e, r) {
199
- var n = r.method,
200
- o = e.iterator[n];
201
- 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;
202
- var i = tryCatch(o, e.iterator, r.arg);
203
- if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
204
- var a = i.arg;
205
- 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);
206
- }
207
- function pushTryEntry(t) {
208
- var e = {
209
- tryLoc: t[0]
210
- };
211
- 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
212
- }
213
- function resetTryEntry(t) {
214
- var e = t.completion || {};
215
- e.type = "normal", delete e.arg, t.completion = e;
216
- }
217
- function Context(t) {
218
- this.tryEntries = [{
219
- tryLoc: "root"
220
- }], t.forEach(pushTryEntry, this), this.reset(!0);
221
- }
222
- function values(e) {
223
- if (e || "" === e) {
224
- var r = e[a];
225
- if (r) return r.call(e);
226
- if ("function" == typeof e.next) return e;
227
- if (!isNaN(e.length)) {
228
- var o = -1,
229
- i = function next() {
230
- for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
231
- return next.value = t, next.done = !0, next;
232
- };
233
- return i.next = i;
234
- }
235
- }
236
- throw new TypeError(typeof e + " is not iterable");
237
- }
238
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
239
- value: GeneratorFunctionPrototype,
240
- configurable: !0
241
- }), o(GeneratorFunctionPrototype, "constructor", {
242
- value: GeneratorFunction,
243
- configurable: !0
244
- }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
245
- var e = "function" == typeof t && t.constructor;
246
- return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
247
- }, e.mark = function (t) {
248
- return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
249
- }, e.awrap = function (t) {
250
- return {
251
- __await: t
252
- };
253
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
254
- return this;
255
- }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
256
- void 0 === i && (i = Promise);
257
- var a = new AsyncIterator(wrap(t, r, n, o), i);
258
- return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
259
- return t.done ? t.value : a.next();
260
- });
261
- }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
262
- return this;
263
- }), define(g, "toString", function () {
264
- return "[object Generator]";
265
- }), e.keys = function (t) {
266
- var e = Object(t),
267
- r = [];
268
- for (var n in e) r.push(n);
269
- return r.reverse(), function next() {
270
- for (; r.length;) {
271
- var t = r.pop();
272
- if (t in e) return next.value = t, next.done = !1, next;
273
- }
274
- return next.done = !0, next;
275
- };
276
- }, e.values = values, Context.prototype = {
277
- constructor: Context,
278
- reset: function (e) {
279
- 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);
280
- },
281
- stop: function () {
282
- this.done = !0;
283
- var t = this.tryEntries[0].completion;
284
- if ("throw" === t.type) throw t.arg;
285
- return this.rval;
286
- },
287
- dispatchException: function (e) {
288
- if (this.done) throw e;
289
- var r = this;
290
- function handle(n, o) {
291
- return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
292
- }
293
- for (var o = this.tryEntries.length - 1; o >= 0; --o) {
294
- var i = this.tryEntries[o],
295
- a = i.completion;
296
- if ("root" === i.tryLoc) return handle("end");
297
- if (i.tryLoc <= this.prev) {
298
- var c = n.call(i, "catchLoc"),
299
- u = n.call(i, "finallyLoc");
300
- if (c && u) {
301
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
302
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
303
- } else if (c) {
304
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
305
- } else {
306
- if (!u) throw Error("try statement without catch or finally");
307
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
308
- }
309
- }
310
- }
311
- },
312
- abrupt: function (t, e) {
313
- for (var r = this.tryEntries.length - 1; r >= 0; --r) {
314
- var o = this.tryEntries[r];
315
- if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
316
- var i = o;
317
- break;
318
- }
319
- }
320
- i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
321
- var a = i ? i.completion : {};
322
- return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
323
- },
324
- complete: function (t, e) {
325
- if ("throw" === t.type) throw t.arg;
326
- 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;
327
- },
328
- finish: function (t) {
329
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
330
- var r = this.tryEntries[e];
331
- if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
332
- }
333
- },
334
- catch: function (t) {
335
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
336
- var r = this.tryEntries[e];
337
- if (r.tryLoc === t) {
338
- var n = r.completion;
339
- if ("throw" === n.type) {
340
- var o = n.arg;
341
- resetTryEntry(r);
342
- }
343
- return o;
344
- }
345
- }
346
- throw Error("illegal catch attempt");
347
- },
348
- delegateYield: function (e, r, n) {
349
- return this.delegate = {
350
- iterator: values(e),
351
- resultName: r,
352
- nextLoc: n
353
- }, "next" === this.method && (this.arg = t), y;
354
- }
355
- }, e;
108
+ function _inheritsLoose(t, o) {
109
+ t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
110
+ }
111
+ function _setPrototypeOf(t, e) {
112
+ return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
113
+ return t.__proto__ = e, t;
114
+ }, _setPrototypeOf(t, e);
356
115
  }
357
116
  function _toPrimitive(t, r) {
358
117
  if ("object" != typeof t || !t) return t;
@@ -368,6 +127,13 @@ function _toPropertyKey(t) {
368
127
  var i = _toPrimitive(t, "string");
369
128
  return "symbol" == typeof i ? i : i + "";
370
129
  }
130
+ function _unsupportedIterableToArray(r, a) {
131
+ if (r) {
132
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
133
+ var t = {}.toString.call(r).slice(8, -1);
134
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
135
+ }
136
+ }
371
137
 
372
138
  /**
373
139
  * @license
@@ -435,67 +201,6 @@ var ContrastCurve = /*#__PURE__*/function () {
435
201
  return ContrastCurve;
436
202
  }();
437
203
 
438
- /**
439
- * @license
440
- * Copyright 2023 Google LLC
441
- *
442
- * Licensed under the Apache License, Version 2.0 (the "License");
443
- * you may not use this file except in compliance with the License.
444
- * You may obtain a copy of the License at
445
- *
446
- * http://www.apache.org/licenses/LICENSE-2.0
447
- *
448
- * Unless required by applicable law or agreed to in writing, software
449
- * distributed under the License is distributed on an "AS IS" BASIS,
450
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
451
- * See the License for the specific language governing permissions and
452
- * limitations under the License.
453
- */
454
- /**
455
- * Documents a constraint between two DynamicColors, in which their tones must
456
- * have a certain distance from each other.
457
- *
458
- * Prefer a DynamicColor with a background, this is for special cases when
459
- * designers want tonal distance, literally contrast, between two colors that
460
- * don't have a background / foreground relationship or a contrast guarantee.
461
- */
462
- var ToneDeltaPair =
463
- /**
464
- * Documents a constraint in tone distance between two DynamicColors.
465
- *
466
- * The polarity is an adjective that describes "A", compared to "B".
467
- *
468
- * For instance, ToneDeltaPair(A, B, 15, 'darker', stayTogether) states that
469
- * A's tone should be at least 15 darker than B's.
470
- *
471
- * 'nearer' and 'farther' describes closeness to the surface roles. For
472
- * instance, ToneDeltaPair(A, B, 10, 'nearer', stayTogether) states that A
473
- * should be 10 lighter than B in light mode, and 10 darker than B in dark
474
- * mode.
475
- *
476
- * @param roleA The first role in a pair.
477
- * @param roleB The second role in a pair.
478
- * @param delta Required difference between tones. Absolute value, negative
479
- * values have undefined behavior.
480
- * @param polarity The relative relation between tones of roleA and roleB,
481
- * as described above.
482
- * @param stayTogether Whether these two roles should stay on the same side of
483
- * the "awkward zone" (T50-59). This is necessary for certain cases where
484
- * one role has two backgrounds.
485
- */
486
- function ToneDeltaPair(roleA, roleB, delta, polarity, stayTogether) {
487
- this.roleA = void 0;
488
- this.roleB = void 0;
489
- this.delta = void 0;
490
- this.polarity = void 0;
491
- this.stayTogether = void 0;
492
- this.roleA = roleA;
493
- this.roleB = roleB;
494
- this.delta = delta;
495
- this.polarity = polarity;
496
- this.stayTogether = stayTogether;
497
- };
498
-
499
204
  /**
500
205
  * @license
501
206
  * Copyright 2022 Google LLC
@@ -832,6 +537,74 @@ var DynamicColor = /*#__PURE__*/function () {
832
537
  return DynamicColor;
833
538
  }();
834
539
 
540
+ /**
541
+ * @license
542
+ * Copyright 2023 Google LLC
543
+ *
544
+ * Licensed under the Apache License, Version 2.0 (the "License");
545
+ * you may not use this file except in compliance with the License.
546
+ * You may obtain a copy of the License at
547
+ *
548
+ * http://www.apache.org/licenses/LICENSE-2.0
549
+ *
550
+ * Unless required by applicable law or agreed to in writing, software
551
+ * distributed under the License is distributed on an "AS IS" BASIS,
552
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
553
+ * See the License for the specific language governing permissions and
554
+ * limitations under the License.
555
+ */
556
+ /**
557
+ * Documents a constraint between two DynamicColors, in which their tones must
558
+ * have a certain distance from each other.
559
+ *
560
+ * Prefer a DynamicColor with a background, this is for special cases when
561
+ * designers want tonal distance, literally contrast, between two colors that
562
+ * don't have a background / foreground relationship or a contrast guarantee.
563
+ */
564
+ var ToneDeltaPair =
565
+ /**
566
+ * Documents a constraint in tone distance between two DynamicColors.
567
+ *
568
+ * The polarity is an adjective that describes "A", compared to "B".
569
+ *
570
+ * For instance, ToneDeltaPair(A, B, 15, 'darker', stayTogether) states that
571
+ * A's tone should be at least 15 darker than B's.
572
+ *
573
+ * 'nearer' and 'farther' describes closeness to the surface roles. For
574
+ * instance, ToneDeltaPair(A, B, 10, 'nearer', stayTogether) states that A
575
+ * should be 10 lighter than B in light mode, and 10 darker than B in dark
576
+ * mode.
577
+ *
578
+ * @param roleA The first role in a pair.
579
+ * @param roleB The second role in a pair.
580
+ * @param delta Required difference between tones. Absolute value, negative
581
+ * values have undefined behavior.
582
+ * @param polarity The relative relation between tones of roleA and roleB,
583
+ * as described above.
584
+ * @param stayTogether Whether these two roles should stay on the same side of
585
+ * the "awkward zone" (T50-59). This is necessary for certain cases where
586
+ * one role has two backgrounds.
587
+ */
588
+ function ToneDeltaPair(roleA, roleB, delta, polarity, stayTogether) {
589
+ this.roleA = void 0;
590
+ this.roleB = void 0;
591
+ this.delta = void 0;
592
+ this.polarity = void 0;
593
+ this.stayTogether = void 0;
594
+ this.roleA = roleA;
595
+ this.roleB = roleB;
596
+ this.delta = delta;
597
+ this.polarity = polarity;
598
+ this.stayTogether = stayTogether;
599
+ };
600
+
601
+ function argbToRgb(argb) {
602
+ return {
603
+ r: argb >> 16 & 0xff,
604
+ g: argb >> 8 & 0xff,
605
+ b: argb & 0xff
606
+ };
607
+ }
835
608
  var ColorEntity = /*#__PURE__*/function () {
836
609
  function ColorEntity(option, schemeService, colorService) {
837
610
  this.option = void 0;
@@ -853,6 +626,9 @@ var ColorEntity = /*#__PURE__*/function () {
853
626
  _proto.getArgb = function getArgb() {
854
627
  return this.getDynamicColor().getArgb(this.schemeService.get());
855
628
  };
629
+ _proto.getRgb = function getRgb() {
630
+ return argbToRgb(this.getArgb());
631
+ };
856
632
  _proto.getName = function getName() {
857
633
  return this.option.name.replace(/([A-Z])/g, '_$1').toLowerCase();
858
634
  };
@@ -867,95 +643,21 @@ var ColorEntity = /*#__PURE__*/function () {
867
643
  return ColorEntity;
868
644
  }();
869
645
 
870
- var SchemeEntity = /*#__PURE__*/function () {
871
- function SchemeEntity(options) {
872
- this.options = void 0;
873
- this.options = options;
646
+ function capitalizeFirstLetter(string) {
647
+ return string.charAt(0).toUpperCase() + string.slice(1);
648
+ }
649
+ var highestSurface = function highestSurface(s, colorService) {
650
+ if (colorService instanceof ColorService) {
651
+ return s.isDark ? colorService.getColor('surfaceBright').getDynamicColor() : colorService.getColor('surfaceDim').getDynamicColor();
652
+ } else {
653
+ return s.isDark ? colorService.get('surfaceBright').getDynamicColor() : colorService.get('surfaceDim').getDynamicColor();
874
654
  }
875
- var _proto = SchemeEntity.prototype;
876
- _proto.getPalette = function getPalette(key) {
877
- if (!this.options) {
878
- throw new Error('Scheme options is not set');
879
- }
880
- var palette = this.options.palettes.get(key);
881
- if (!palette) {
882
- throw new Error("Palette " + key + " not found");
883
- }
884
- return palette;
885
- };
886
- return _createClass(SchemeEntity, [{
887
- key: "contrastLevel",
888
- get: function get() {
889
- if (!this.options) {
890
- throw new Error('Scheme options is not set');
891
- }
892
- return this.options.contrastLevel;
893
- }
894
- }, {
895
- key: "isDark",
896
- get: function get() {
897
- if (!this.options) {
898
- throw new Error('Scheme options is not set');
899
- }
900
- return this.options.isDark;
901
- }
902
- }, {
903
- key: "sourceColorHct",
904
- get: function get() {
905
- if (!this.options) {
906
- throw new Error('Scheme options is not set');
907
- }
908
- return materialColorUtilities.Hct.fromInt(this.options.sourceColorArgb);
909
- }
910
- }]);
911
- }();
912
-
913
- var SchemeService = /*#__PURE__*/function () {
914
- function SchemeService() {
915
- this.schemeEntity = void 0;
916
- this.options = void 0;
917
- }
918
- var _proto = SchemeService.prototype;
919
- _proto.createOrUpdate = function createOrUpdate(options) {
920
- this.options = mergeDeep(options, this.options);
921
- var palettes = new Map();
922
- var sourceColorArgb = materialColorUtilities.argbFromHex(this.options.sourceColorHex);
923
- var sourceColorHct = materialColorUtilities.Hct.fromInt(sourceColorArgb);
924
- if (!this.options.palettes) {
925
- return;
926
- }
927
- for (var _i = 0, _Object$entries = Object.entries(this.options.palettes); _i < _Object$entries.length; _i++) {
928
- var _Object$entries$_i = _Object$entries[_i],
929
- key = _Object$entries$_i[0],
930
- paletteFunction = _Object$entries$_i[1];
931
- var palette = paletteFunction(sourceColorHct);
932
- palettes.set(key, palette);
933
- }
934
- this.schemeEntity = new SchemeEntity(_extends({}, this.options, {
935
- palettes: palettes,
936
- sourceColorArgb: sourceColorArgb
937
- }));
938
- };
939
- _proto.get = function get() {
940
- if (!this.schemeEntity) {
941
- throw new Error('Scheme is not created');
942
- }
943
- return this.schemeEntity;
944
- };
945
- return SchemeService;
946
- }();
947
- SchemeService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable()], SchemeService);
948
-
949
- function capitalizeFirstLetter(string) {
950
- return string.charAt(0).toUpperCase() + string.slice(1);
951
- }
952
- var highestSurface = function highestSurface(s, colorManagerService) {
953
- return s.isDark ? colorManagerService.get('surfaceBright').getDynamicColor() : colorManagerService.get('surfaceDim').getDynamicColor();
954
655
  };
955
656
  var ColorManagerService = /*#__PURE__*/function () {
956
- function ColorManagerService(schemeService) {
957
- this.schemeService = void 0;
657
+ function ColorManagerService(_ref) {
658
+ var schemeService = _ref.schemeService;
958
659
  this.colorMap = new Map();
660
+ this.schemeService = void 0;
959
661
  this.schemeService = schemeService;
960
662
  }
961
663
  var _proto = ColorManagerService.prototype;
@@ -1021,7 +723,7 @@ var ColorManagerService = /*#__PURE__*/function () {
1021
723
  },
1022
724
  contrastCurve: new ContrastCurve(3, 4.5, 7, 11),
1023
725
  toneDeltaPair: function toneDeltaPair(s) {
1024
- return new ToneDeltaPair(_this.get(colorKeyContainer).getDynamicColor(), _this.get(colorKey).getDynamicColor(), 15, 'nearer', false);
726
+ return new ToneDeltaPair(_this.get(colorKeyContainer).getDynamicColor(), _this.get(colorKey).getDynamicColor(), 10, 'nearer', false);
1025
727
  }
1026
728
  });
1027
729
  this.createOrUpdate(onColorKey, {
@@ -1049,7 +751,7 @@ var ColorManagerService = /*#__PURE__*/function () {
1049
751
  },
1050
752
  contrastCurve: new ContrastCurve(1, 1, 3, 7),
1051
753
  toneDeltaPair: function toneDeltaPair(s) {
1052
- return new ToneDeltaPair(_this.get(colorKeyContainer).getDynamicColor(), _this.get(colorKey).getDynamicColor(), 15, 'nearer', false);
754
+ return new ToneDeltaPair(_this.get(colorKeyContainer).getDynamicColor(), _this.get(colorKey).getDynamicColor(), 10, 'nearer', false);
1053
755
  }
1054
756
  });
1055
757
  this.createOrUpdate(onColorKeyContainer, {
@@ -1141,7 +843,226 @@ var ColorManagerService = /*#__PURE__*/function () {
1141
843
  };
1142
844
  return ColorManagerService;
1143
845
  }();
1144
- ColorManagerService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable(), /*#__PURE__*/tslib.__metadata("design:paramtypes", [SchemeService])], ColorManagerService);
846
+
847
+ var ColorModule = {
848
+ colorManagerService: /*#__PURE__*/awilix.asClass(ColorManagerService).singleton(),
849
+ colorService: /*#__PURE__*/awilix.asClass(ColorService).singleton()
850
+ };
851
+
852
+ var SchemeEntity = /*#__PURE__*/function () {
853
+ function SchemeEntity(options) {
854
+ this.options = void 0;
855
+ this.options = options;
856
+ }
857
+ var _proto = SchemeEntity.prototype;
858
+ _proto.getPalette = function getPalette(key) {
859
+ if (!this.options) {
860
+ throw new Error('Scheme options is not set');
861
+ }
862
+ var palette = this.options.palettes.get(key);
863
+ if (!palette) {
864
+ throw new Error("Palette " + key + " not found");
865
+ }
866
+ return palette;
867
+ };
868
+ return _createClass(SchemeEntity, [{
869
+ key: "contrastLevel",
870
+ get: function get() {
871
+ if (!this.options) {
872
+ throw new Error('Scheme options is not set');
873
+ }
874
+ return this.options.contrastLevel;
875
+ }
876
+ }, {
877
+ key: "isDark",
878
+ get: function get() {
879
+ if (!this.options) {
880
+ throw new Error('Scheme options is not set');
881
+ }
882
+ return this.options.isDark;
883
+ }
884
+ }, {
885
+ key: "sourceColorHct",
886
+ get: function get() {
887
+ if (!this.options) {
888
+ throw new Error('Scheme options is not set');
889
+ }
890
+ return materialColorUtilities.Hct.fromInt(this.options.sourceColorArgb);
891
+ }
892
+ }]);
893
+ }();
894
+
895
+ var SchemeService = /*#__PURE__*/function () {
896
+ function SchemeService() {
897
+ this.schemeEntity = void 0;
898
+ this.options = void 0;
899
+ }
900
+ var _proto = SchemeService.prototype;
901
+ _proto.createOrUpdate = function createOrUpdate(options) {
902
+ var _this$options, _this$options2;
903
+ this.options = _extends({}, this.options, options, {
904
+ sourcesColorHex: _extends({}, (_this$options = this.options) == null ? void 0 : _this$options.sourcesColorHex, options.sourcesColorHex),
905
+ palettes: _extends({}, (_this$options2 = this.options) == null ? void 0 : _this$options2.palettes, options.palettes)
906
+ });
907
+ var palettes = new Map();
908
+ if (!this.options.sourcesColorHex.primary) {
909
+ throw new Error('Primary source color is not set');
910
+ }
911
+ var sourceColorArgb = materialColorUtilities.argbFromHex(this.options.sourcesColorHex.primary);
912
+ var sourceColorHct = materialColorUtilities.Hct.fromInt(sourceColorArgb);
913
+ if (!this.options.palettes) {
914
+ return;
915
+ }
916
+ for (var _i = 0, _Object$entries = Object.entries(this.options.palettes); _i < _Object$entries.length; _i++) {
917
+ var _Object$entries$_i = _Object$entries[_i],
918
+ key = _Object$entries$_i[0],
919
+ _Object$entries$_i$ = _Object$entries$_i[1],
920
+ sourceColorkey = _Object$entries$_i$.sourceColorkey,
921
+ paletteFunction = _Object$entries$_i$.tonalPalette;
922
+ var palette = void 0;
923
+ if (!sourceColorkey) {
924
+ palette = paletteFunction(sourceColorHct);
925
+ } else {
926
+ var _sourceColorArgb = materialColorUtilities.argbFromHex(this.options.sourcesColorHex[sourceColorkey]);
927
+ var _sourceColorHct = materialColorUtilities.Hct.fromInt(_sourceColorArgb);
928
+ palette = paletteFunction(_sourceColorHct);
929
+ }
930
+ palettes.set(key, palette);
931
+ }
932
+ this.schemeEntity = new SchemeEntity(_extends({}, this.options, {
933
+ palettes: palettes,
934
+ sourceColorArgb: sourceColorArgb
935
+ }));
936
+ };
937
+ _proto.get = function get() {
938
+ if (!this.schemeEntity) {
939
+ throw new Error('Scheme is not created');
940
+ }
941
+ return this.schemeEntity;
942
+ };
943
+ return SchemeService;
944
+ }();
945
+
946
+ var ThemeService = /*#__PURE__*/function () {
947
+ function ThemeService(_ref) {
948
+ var schemeService = _ref.schemeService,
949
+ variantService = _ref.variantService;
950
+ this.schemeService = void 0;
951
+ this.variantService = void 0;
952
+ this.schemeService = schemeService;
953
+ this.variantService = variantService;
954
+ // this.addPalette({key: "primary", addDefaultColors: true})
955
+ // this.addPalette({key: "secondary", addDefaultColors: true})
956
+ // this.addPalette({key: "tertiary", addDefaultColors: true})
957
+ // this.addPalette({key: "error", palette: TonalPalette.fromHueAndChroma(25.0, 84.0)})
958
+ // this.addPalette({key: "neutral"})
959
+ // this.addPalette({key: "neutralVariant"})
960
+ }
961
+ // addPalette({key, palette, addDefaultColors}: {key: string; palette: TonalPalette; addDefaultColors: boolean}) {
962
+ // this.themeOptions.palettes.set(key, palette);
963
+ // if (addDefaultColors){
964
+ // this.colorService.addPalette(key)
965
+ // }
966
+ // }
967
+ // create(args: ThemeOptions): SchemeService {
968
+ // return new SchemeService(args, this.colorService)
969
+ // }
970
+ //
971
+ // update(options: Partial<ThemeOptions>): SchemeService {
972
+ // Object.assign(this.themeOptions, options);
973
+ // return this.theme();
974
+ // }
975
+ var _proto = ThemeService.prototype;
976
+ _proto.create = function create(options) {
977
+ this.schemeService.createOrUpdate(_extends({}, options, {
978
+ sourcesColorHex: {
979
+ primary: options.sourceColorHex
980
+ }
981
+ }));
982
+ this.variantService.set(options.variant);
983
+ };
984
+ _proto.update = function update(options) {
985
+ var themeOptions = _extends({}, options);
986
+ if (options.sourceColorHex) themeOptions.sourcesColorHex = {
987
+ primary: options.sourceColorHex
988
+ };
989
+ this.schemeService.createOrUpdate(themeOptions);
990
+ if (options.variant) this.variantService.set(options.variant);
991
+ };
992
+ _proto.addCustomPalette = function addCustomPalette(key, colorHex) {
993
+ this.variantService.addCustomPalette(key, colorHex);
994
+ };
995
+ return ThemeService;
996
+ }();
997
+
998
+ var VariantService = /*#__PURE__*/function () {
999
+ function VariantService(_ref) {
1000
+ var schemeService = _ref.schemeService;
1001
+ this.customPalettes = {};
1002
+ this.variantEntity = void 0;
1003
+ this.schemeService = void 0;
1004
+ this.schemeService = schemeService;
1005
+ }
1006
+ var _proto = VariantService.prototype;
1007
+ _proto.addCustomPalette = function addCustomPalette(key, colorHex) {
1008
+ this.customPalettes[key] = colorHex;
1009
+ this.update();
1010
+ };
1011
+ _proto.set = function set(variantEntity) {
1012
+ this.variantEntity = variantEntity;
1013
+ if (!variantEntity.palettes.error) {
1014
+ variantEntity.palettes.error = function () {
1015
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(25.0, 84.0);
1016
+ };
1017
+ }
1018
+ this.update();
1019
+ };
1020
+ _proto.update = function update() {
1021
+ var _this = this;
1022
+ if (!this.variantEntity) return;
1023
+ var palettes = {};
1024
+ Object.keys(this.variantEntity.palettes).forEach(function (key) {
1025
+ palettes[key] = {
1026
+ tonalPalette: _this.variantEntity.palettes[key]
1027
+ };
1028
+ });
1029
+ if (this.variantEntity.customPalettes) {
1030
+ Object.keys(this.customPalettes).forEach(function (key) {
1031
+ palettes[key] = {
1032
+ sourceColorkey: key,
1033
+ tonalPalette: _this.variantEntity.customPalettes
1034
+ };
1035
+ });
1036
+ }
1037
+ this.schemeService.createOrUpdate({
1038
+ sourcesColorHex: this.customPalettes,
1039
+ palettes: palettes
1040
+ });
1041
+ };
1042
+ return VariantService;
1043
+ }();
1044
+
1045
+ var ThemeModule = {
1046
+ schemeService: /*#__PURE__*/awilix.asClass(SchemeService).singleton(),
1047
+ variantService: /*#__PURE__*/awilix.asClass(VariantService).singleton(),
1048
+ themeService: /*#__PURE__*/awilix.asClass(ThemeService).singleton()
1049
+ };
1050
+
1051
+ var AppService = function AppService(_ref) {
1052
+ var colorService = _ref.colorService,
1053
+ themeService = _ref.themeService,
1054
+ pluginService = _ref.pluginService;
1055
+ this.colorService = void 0;
1056
+ this.themeService = void 0;
1057
+ this.pluginService = void 0;
1058
+ this.pluginService = pluginService;
1059
+ this.colorService = colorService;
1060
+ this.themeService = themeService;
1061
+ };
1062
+
1063
+ var AppModule = {
1064
+ appService: /*#__PURE__*/awilix.asClass(AppService).singleton()
1065
+ };
1145
1066
 
1146
1067
  function findDesiredChromaByTone(hue, chroma, tone, byDecreasingTone) {
1147
1068
  var answer = tone;
@@ -1167,485 +1088,1074 @@ function findDesiredChromaByTone(hue, chroma, tone, byDecreasingTone) {
1167
1088
  }
1168
1089
  return answer;
1169
1090
  }
1170
- var defaultColors = function defaultColors(colorManagerService) {
1091
+ var defaultColors = function defaultColors(colorService) {
1171
1092
  return {
1172
- background: {
1173
- palette: function palette(s) {
1174
- return s.getPalette('neutral');
1093
+ fromPalettes: ['primary', 'secondary', 'tertiary'],
1094
+ colors: {
1095
+ background: {
1096
+ palette: function palette(s) {
1097
+ return s.getPalette('neutral');
1098
+ },
1099
+ tone: function tone(s) {
1100
+ return s.isDark ? 6 : 98;
1101
+ },
1102
+ isBackground: true
1103
+ },
1104
+ onBackground: {
1105
+ palette: function palette(s) {
1106
+ return s.getPalette('neutral');
1107
+ },
1108
+ tone: function tone(s) {
1109
+ return s.isDark ? 90 : 10;
1110
+ },
1111
+ background: function background(s) {
1112
+ return colorService.getColor('background').getDynamicColor();
1113
+ },
1114
+ contrastCurve: new ContrastCurve(3, 3, 4.5, 7)
1115
+ },
1116
+ surface: {
1117
+ palette: function palette(s) {
1118
+ return s.getPalette('neutral');
1119
+ },
1120
+ tone: function tone(s) {
1121
+ return s.isDark ? 6 : 98;
1122
+ },
1123
+ isBackground: true
1124
+ },
1125
+ surfaceDim: {
1126
+ palette: function palette(s) {
1127
+ return s.getPalette('neutral');
1128
+ },
1129
+ tone: function tone(s) {
1130
+ return s.isDark ? 6 : 87;
1131
+ },
1132
+ isBackground: true
1133
+ },
1134
+ surfaceBright: {
1135
+ palette: function palette(s) {
1136
+ return s.getPalette('neutral');
1137
+ },
1138
+ tone: function tone(s) {
1139
+ return s.isDark ? 24 : 98;
1140
+ },
1141
+ isBackground: true
1142
+ },
1143
+ surfaceContainerLowest: {
1144
+ palette: function palette(s) {
1145
+ return s.getPalette('neutral');
1146
+ },
1147
+ tone: function tone(s) {
1148
+ return s.isDark ? 4 : 100;
1149
+ },
1150
+ isBackground: true
1151
+ },
1152
+ surfaceContainerLow: {
1153
+ palette: function palette(s) {
1154
+ return s.getPalette('neutral');
1155
+ },
1156
+ tone: function tone(s) {
1157
+ return s.isDark ? 10 : 96;
1158
+ },
1159
+ isBackground: true
1160
+ },
1161
+ surfaceContainer: {
1162
+ palette: function palette(s) {
1163
+ return s.getPalette('neutral');
1164
+ },
1165
+ tone: function tone(s) {
1166
+ return s.isDark ? 12 : 94;
1167
+ },
1168
+ isBackground: true
1169
+ },
1170
+ surfaceContainerHigh: {
1171
+ palette: function palette(s) {
1172
+ return s.getPalette('neutral');
1173
+ },
1174
+ tone: function tone(s) {
1175
+ return s.isDark ? 17 : 92;
1176
+ },
1177
+ isBackground: true
1178
+ },
1179
+ surfaceContainerHighest: {
1180
+ palette: function palette(s) {
1181
+ return s.getPalette('neutral');
1182
+ },
1183
+ tone: function tone(s) {
1184
+ return s.isDark ? 22 : 90;
1185
+ },
1186
+ isBackground: true
1187
+ },
1188
+ onSurface: {
1189
+ palette: function palette(s) {
1190
+ return s.getPalette('neutral');
1191
+ },
1192
+ tone: function tone(s) {
1193
+ return s.isDark ? 90 : 10;
1194
+ },
1195
+ background: function background(s) {
1196
+ return highestSurface(s, colorService);
1197
+ },
1198
+ contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
1199
+ },
1200
+ surfaceVariant: {
1201
+ palette: function palette(s) {
1202
+ return s.getPalette('neutralVariant');
1203
+ },
1204
+ tone: function tone(s) {
1205
+ return s.isDark ? 30 : 90;
1206
+ },
1207
+ isBackground: true
1208
+ },
1209
+ onSurfaceVariant: {
1210
+ palette: function palette(s) {
1211
+ return s.getPalette('neutralVariant');
1212
+ },
1213
+ tone: function tone(s) {
1214
+ return s.isDark ? 80 : 30;
1215
+ },
1216
+ background: function background(s) {
1217
+ return highestSurface(s, colorService);
1218
+ },
1219
+ contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
1220
+ },
1221
+ inverseSurface: {
1222
+ palette: function palette(s) {
1223
+ return s.getPalette('neutral');
1224
+ },
1225
+ tone: function tone(s) {
1226
+ return s.isDark ? 90 : 20;
1227
+ }
1175
1228
  },
1176
- tone: function tone(s) {
1177
- return s.isDark ? 6 : 98;
1229
+ inverseOnSurface: {
1230
+ palette: function palette(s) {
1231
+ return s.getPalette('neutral');
1232
+ },
1233
+ tone: function tone(s) {
1234
+ return s.isDark ? 20 : 95;
1235
+ },
1236
+ background: function background(s) {
1237
+ return colorService.getColor('inverseSurface').getDynamicColor();
1238
+ },
1239
+ contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
1240
+ },
1241
+ outline: {
1242
+ palette: function palette(s) {
1243
+ return s.getPalette('neutralVariant');
1244
+ },
1245
+ tone: function tone(s) {
1246
+ return s.isDark ? 60 : 50;
1247
+ },
1248
+ background: function background(s) {
1249
+ return highestSurface(s, colorService);
1250
+ },
1251
+ contrastCurve: new ContrastCurve(1.5, 3, 4.5, 7)
1252
+ },
1253
+ outlineVariant: {
1254
+ palette: function palette(s) {
1255
+ return s.getPalette('neutralVariant');
1256
+ },
1257
+ tone: function tone(s) {
1258
+ return s.isDark ? 30 : 80;
1259
+ },
1260
+ background: function background(s) {
1261
+ return highestSurface(s, colorService);
1262
+ },
1263
+ contrastCurve: new ContrastCurve(1, 1, 3, 7)
1264
+ },
1265
+ shadow: {
1266
+ palette: function palette(s) {
1267
+ return s.getPalette('neutral');
1268
+ },
1269
+ tone: function tone(s) {
1270
+ return 0;
1271
+ }
1178
1272
  },
1179
- isBackground: true
1180
- },
1181
- onBackground: {
1182
- palette: function palette(s) {
1183
- return s.getPalette('neutral');
1273
+ scrim: {
1274
+ palette: function palette(s) {
1275
+ return s.getPalette('neutral');
1276
+ },
1277
+ tone: function tone(s) {
1278
+ return 0;
1279
+ }
1184
1280
  },
1185
- tone: function tone(s) {
1186
- return s.isDark ? 90 : 10;
1281
+ surfaceTint: {
1282
+ palette: function palette(s) {
1283
+ return s.getPalette('neutral');
1284
+ },
1285
+ tone: function tone(s) {
1286
+ return s.isDark ? 80 : 40;
1287
+ },
1288
+ isBackground: true
1289
+ },
1290
+ secondaryContainer: {
1291
+ tone: function tone(s) {
1292
+ var initialTone = s.isDark ? 30 : 90;
1293
+ return findDesiredChromaByTone(s.getPalette('secondary').hue, s.getPalette('secondary').chroma, initialTone, !s.isDark);
1294
+ }
1187
1295
  },
1188
- background: function background(s) {
1189
- return colorManagerService.get('background').getDynamicColor();
1296
+ onSecondaryContainer: {
1297
+ tone: function tone(s) {
1298
+ return DynamicColor.foregroundTone(colorService.getColor('secondaryContainer').getDynamicColor().tone(s), 4.5);
1299
+ }
1190
1300
  },
1191
- contrastCurve: new ContrastCurve(3, 3, 4.5, 7)
1192
- },
1193
- surface: {
1194
- palette: function palette(s) {
1195
- return s.getPalette('neutral');
1301
+ tertiaryContainer: {
1302
+ palette: function palette(s) {
1303
+ return s.getPalette('tertiary');
1304
+ },
1305
+ tone: function tone(s) {
1306
+ var proposedHct = s.getPalette('tertiary').getHct(s.sourceColorHct.tone);
1307
+ return materialColorUtilities.DislikeAnalyzer.fixIfDisliked(proposedHct).tone;
1308
+ }
1196
1309
  },
1197
- tone: function tone(s) {
1198
- return s.isDark ? 6 : 98;
1310
+ onTertiaryContainer: {
1311
+ palette: function palette(s) {
1312
+ return s.getPalette('tertiary');
1313
+ },
1314
+ tone: function tone(s) {
1315
+ return DynamicColor.foregroundTone(colorService.getColor('tertiaryContainer').getDynamicColor().tone(s), 4.5);
1316
+ }
1199
1317
  },
1200
- isBackground: true
1201
- },
1202
- surfaceDim: {
1203
- palette: function palette(s) {
1204
- return s.getPalette('neutral');
1318
+ error: {
1319
+ palette: function palette(s) {
1320
+ return s.getPalette('error');
1321
+ },
1322
+ tone: function tone(s) {
1323
+ return s.isDark ? 80 : 40;
1324
+ },
1325
+ isBackground: true,
1326
+ background: function background(s) {
1327
+ return highestSurface(s, colorService);
1328
+ },
1329
+ contrastCurve: new ContrastCurve(3, 4.5, 7, 11),
1330
+ toneDeltaPair: function toneDeltaPair(s) {
1331
+ return new ToneDeltaPair(colorService.getColor('errorContainer').getDynamicColor(), colorService.getColor('error').getDynamicColor(), 15, 'nearer', false);
1332
+ }
1205
1333
  },
1206
- tone: function tone(s) {
1207
- return s.isDark ? 6 : 87;
1334
+ onError: {
1335
+ palette: function palette(s) {
1336
+ return s.getPalette('error');
1337
+ },
1338
+ tone: function tone(s) {
1339
+ return s.isDark ? 20 : 100;
1340
+ },
1341
+ background: function background(s) {
1342
+ return colorService.getColor('error').getDynamicColor();
1343
+ },
1344
+ contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
1345
+ },
1346
+ errorContainer: {
1347
+ palette: function palette(s) {
1348
+ return s.getPalette('error');
1349
+ },
1350
+ tone: function tone(s) {
1351
+ return s.isDark ? 30 : 90;
1352
+ },
1353
+ isBackground: true,
1354
+ background: function background(s) {
1355
+ return highestSurface(s, colorService);
1356
+ },
1357
+ contrastCurve: new ContrastCurve(1, 1, 3, 7),
1358
+ toneDeltaPair: function toneDeltaPair(s) {
1359
+ return new ToneDeltaPair(colorService.getColor('errorContainer').getDynamicColor(), colorService.getColor('error').getDynamicColor(), 15, 'nearer', false);
1360
+ }
1208
1361
  },
1209
- isBackground: true
1362
+ onErrorContainer: {
1363
+ palette: function palette(s) {
1364
+ return s.getPalette('error');
1365
+ },
1366
+ tone: function tone(s) {
1367
+ return s.isDark ? 90 : 10;
1368
+ },
1369
+ background: function background(s) {
1370
+ return colorService.getColor('errorContainer').getDynamicColor();
1371
+ },
1372
+ contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
1373
+ },
1374
+ onTertiaryFixed: {
1375
+ palette: function palette(s) {
1376
+ return s.getPalette('tertiary');
1377
+ },
1378
+ tone: function tone(s) {
1379
+ return 10.0;
1380
+ },
1381
+ background: function background(s) {
1382
+ return colorService.getColor('tertiaryFixedDim').getDynamicColor();
1383
+ },
1384
+ secondBackground: function secondBackground(s) {
1385
+ return colorService.getColor('tertiaryFixed').getDynamicColor();
1386
+ },
1387
+ contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
1388
+ },
1389
+ onTertiaryFixedVariant: {
1390
+ palette: function palette(s) {
1391
+ return s.getPalette('tertiary');
1392
+ },
1393
+ tone: function tone(s) {
1394
+ return 30.0;
1395
+ },
1396
+ background: function background(s) {
1397
+ return colorService.getColor('tertiaryFixedDim').getDynamicColor();
1398
+ },
1399
+ secondBackground: function secondBackground(s) {
1400
+ return colorService.getColor('tertiaryFixed').getDynamicColor();
1401
+ },
1402
+ contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
1403
+ }
1404
+ }
1405
+ };
1406
+ };
1407
+
1408
+ var getRotatedHue = function getRotatedHue(sourceColor, hues, rotations) {
1409
+ var sourceHue = sourceColor.hue;
1410
+ if (hues.length !== rotations.length) {
1411
+ throw new Error("mismatch between hue length " + hues.length + " & rotations " + rotations.length);
1412
+ }
1413
+ if (rotations.length === 1) {
1414
+ return materialColorUtilities.sanitizeDegreesDouble(sourceColor.hue + rotations[0]);
1415
+ }
1416
+ var size = hues.length;
1417
+ for (var i = 0; i <= size - 2; i++) {
1418
+ var thisHue = hues[i];
1419
+ var nextHue = hues[i + 1];
1420
+ if (thisHue < sourceHue && sourceHue < nextHue) {
1421
+ return materialColorUtilities.sanitizeDegreesDouble(sourceHue + rotations[i]);
1422
+ }
1423
+ }
1424
+ // If this statement executes, something is wrong, there should have been a
1425
+ // rotation found using the arrays.
1426
+ return sourceHue;
1427
+ };
1428
+ var VariantEntity = function VariantEntity(palettes, customPalettes) {
1429
+ if (palettes === void 0) {
1430
+ palettes = {};
1431
+ }
1432
+ this.palettes = void 0;
1433
+ this.customPalettes = void 0;
1434
+ this.palettes = palettes;
1435
+ this.customPalettes = customPalettes;
1436
+ };
1437
+
1438
+ var _VariantModel;
1439
+ var VariantModel = function VariantModel() {};
1440
+ _VariantModel = VariantModel;
1441
+ VariantModel.tonalSpot = {
1442
+ palettes: {
1443
+ primary: function primary(sourceColorHct) {
1444
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 36.0);
1210
1445
  },
1211
- surfaceBright: {
1212
- palette: function palette(s) {
1213
- return s.getPalette('neutral');
1214
- },
1215
- tone: function tone(s) {
1216
- return s.isDark ? 24 : 98;
1217
- },
1218
- isBackground: true
1446
+ secondary: function secondary(sourceColorHct) {
1447
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 16.0);
1219
1448
  },
1220
- surfaceContainerLowest: {
1221
- palette: function palette(s) {
1222
- return s.getPalette('neutral');
1223
- },
1224
- tone: function tone(s) {
1225
- return s.isDark ? 4 : 100;
1226
- },
1227
- isBackground: true
1449
+ tertiary: function tertiary(sourceColorHct) {
1450
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(materialColorUtilities.sanitizeDegreesDouble(sourceColorHct.hue + 60.0), 24.0);
1228
1451
  },
1229
- surfaceContainerLow: {
1230
- palette: function palette(s) {
1231
- return s.getPalette('neutral');
1232
- },
1233
- tone: function tone(s) {
1234
- return s.isDark ? 10 : 96;
1235
- },
1236
- isBackground: true
1452
+ neutral: function neutral(sourceColorHct) {
1453
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 6.0);
1237
1454
  },
1238
- surfaceContainer: {
1239
- palette: function palette(s) {
1240
- return s.getPalette('neutral');
1241
- },
1242
- tone: function tone(s) {
1243
- return s.isDark ? 12 : 94;
1244
- },
1245
- isBackground: true
1455
+ neutralVariant: function neutralVariant(sourceColorHct) {
1456
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 8.0);
1457
+ }
1458
+ },
1459
+ customPalettes: function customPalettes(colorHct) {
1460
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(colorHct.hue, 16);
1461
+ }
1462
+ };
1463
+ VariantModel.vibrant = {
1464
+ palettes: {
1465
+ primary: function primary(sourceColorHct) {
1466
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 200.0);
1246
1467
  },
1247
- surfaceContainerHigh: {
1248
- palette: function palette(s) {
1249
- return s.getPalette('neutral');
1250
- },
1251
- tone: function tone(s) {
1252
- return s.isDark ? 17 : 92;
1253
- },
1254
- isBackground: true
1468
+ secondary: function secondary(sourceColorHct) {
1469
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(getRotatedHue(sourceColorHct, _VariantModel.hues, _VariantModel.secondaryRotations), 24.0);
1255
1470
  },
1256
- surfaceContainerHighest: {
1257
- palette: function palette(s) {
1258
- return s.getPalette('neutral');
1259
- },
1260
- tone: function tone(s) {
1261
- return s.isDark ? 22 : 90;
1262
- },
1263
- isBackground: true
1471
+ tertiary: function tertiary(sourceColorHct) {
1472
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(getRotatedHue(sourceColorHct, _VariantModel.hues, _VariantModel.tertiaryRotations), 32.0);
1264
1473
  },
1265
- onSurface: {
1266
- palette: function palette(s) {
1267
- return s.getPalette('neutral');
1268
- },
1269
- tone: function tone(s) {
1270
- return s.isDark ? 90 : 10;
1271
- },
1272
- background: function background(s) {
1273
- return highestSurface(s, colorManagerService);
1274
- },
1275
- contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
1276
- },
1277
- surfaceVariant: {
1278
- palette: function palette(s) {
1279
- return s.getPalette('neutralVariant');
1280
- },
1281
- tone: function tone(s) {
1282
- return s.isDark ? 30 : 90;
1283
- },
1284
- isBackground: true
1285
- },
1286
- onSurfaceVariant: {
1287
- palette: function palette(s) {
1288
- return s.getPalette('neutralVariant');
1289
- },
1290
- tone: function tone(s) {
1291
- return s.isDark ? 80 : 30;
1292
- },
1293
- background: function background(s) {
1294
- return highestSurface(s, colorManagerService);
1295
- },
1296
- contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
1474
+ neutral: function neutral(sourceColorHct) {
1475
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 6.0);
1297
1476
  },
1298
- inverseSurface: {
1299
- palette: function palette(s) {
1300
- return s.getPalette('neutral');
1301
- },
1302
- tone: function tone(s) {
1303
- return s.isDark ? 90 : 20;
1477
+ neutralVariant: function neutralVariant(sourceColorHct) {
1478
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 8.0);
1479
+ }
1480
+ },
1481
+ customPalettes: function customPalettes(colorHct) {
1482
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(getRotatedHue(colorHct, _VariantModel.hues, _VariantModel.secondaryRotations), 24.0);
1483
+ }
1484
+ };
1485
+ VariantModel.hues = [0.0, 41.0, 61.0, 101.0, 131.0, 181.0, 251.0, 301.0, 360.0];
1486
+ VariantModel.secondaryRotations = [18.0, 15.0, 10.0, 12.0, 15.0, 18.0, 15.0, 12.0, 12.0];
1487
+ VariantModel.tertiaryRotations = [35.0, 30.0, 20.0, 25.0, 30.0, 35.0, 30.0, 25.0, 25.0];
1488
+
1489
+ function defineConfig(configObject) {
1490
+ if (!configObject || typeof configObject !== 'object') {
1491
+ throw new Error('The configuration is missing or not an object');
1492
+ }
1493
+ if (!('sourceColor' in configObject)) {
1494
+ throw new Error('Invalid configuration');
1495
+ }
1496
+ return configObject;
1497
+ }
1498
+ var ConfigService = /*#__PURE__*/function () {
1499
+ function ConfigService(_ref) {
1500
+ var appService = _ref.appService;
1501
+ this.configPath = './theme.config';
1502
+ this.appService = void 0;
1503
+ this.appService = appService;
1504
+ }
1505
+ var _proto = ConfigService.prototype;
1506
+ _proto.loadConfig = function loadConfig(config) {
1507
+ var _this$appService = this.appService,
1508
+ themeService = _this$appService.themeService,
1509
+ colorService = _this$appService.colorService,
1510
+ pluginService = _this$appService.pluginService;
1511
+ var _ref2 = config != null ? config : this.getConfig(),
1512
+ sourceColor = _ref2.sourceColor,
1513
+ _ref2$contrastLevel = _ref2.contrastLevel,
1514
+ contrastLevel = _ref2$contrastLevel === void 0 ? 0 : _ref2$contrastLevel,
1515
+ _ref2$isDark = _ref2.isDark,
1516
+ isDark = _ref2$isDark === void 0 ? false : _ref2$isDark,
1517
+ _ref2$variant = _ref2.variant,
1518
+ variant = _ref2$variant === void 0 ? VariantModel.tonalSpot : _ref2$variant,
1519
+ palettes = _ref2.palettes,
1520
+ colors = _ref2.colors,
1521
+ _ref2$useDefaultColor = _ref2.useDefaultColors,
1522
+ useDefaultColors = _ref2$useDefaultColor === void 0 ? true : _ref2$useDefaultColor,
1523
+ plugins = _ref2.plugins;
1524
+ themeService.create({
1525
+ contrastLevel: contrastLevel,
1526
+ isDark: isDark,
1527
+ sourceColorHex: sourceColor,
1528
+ variant: variant
1529
+ });
1530
+ if (palettes) {
1531
+ Object.entries(palettes).forEach(function (_ref3) {
1532
+ var key = _ref3[0],
1533
+ value = _ref3[1];
1534
+ return themeService.addCustomPalette(key, value);
1535
+ });
1536
+ }
1537
+ if (useDefaultColors) {
1538
+ colorService.addColors(defaultColors);
1539
+ }
1540
+ if (colors) {
1541
+ colorService.addColors(colors);
1542
+ }
1543
+ if (plugins) {
1544
+ plugins.forEach(function (plugin) {
1545
+ pluginService.addPlugin(plugin);
1546
+ });
1547
+ pluginService.loadPlugins(this.appService);
1548
+ }
1549
+ };
1550
+ _proto.getConfig = function getConfig() {
1551
+ if (typeof process !== 'undefined' && process.release && process.release.name === 'node') {
1552
+ var base = node_path.resolve(this.configPath);
1553
+ var extensions = ['.js', '.ts', '.jms', '.jcs'];
1554
+ var configImport = null;
1555
+ for (var _i = 0, _extensions = extensions; _i < _extensions.length; _i++) {
1556
+ var ext = _extensions[_i];
1557
+ var path = base + ext;
1558
+ if (node_fs.existsSync(path)) {
1559
+ configImport = require(path);
1560
+ break;
1561
+ }
1304
1562
  }
1305
- },
1306
- inverseOnSurface: {
1307
- palette: function palette(s) {
1308
- return s.getPalette('neutral');
1309
- },
1310
- tone: function tone(s) {
1311
- return s.isDark ? 20 : 95;
1312
- },
1313
- background: function background(s) {
1314
- return colorManagerService.get('inverseSurface').getDynamicColor();
1315
- },
1316
- contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
1317
- },
1318
- outline: {
1319
- palette: function palette(s) {
1320
- return s.getPalette('neutralVariant');
1321
- },
1322
- tone: function tone(s) {
1323
- return s.isDark ? 60 : 50;
1324
- },
1325
- background: function background(s) {
1326
- return highestSurface(s, colorManagerService);
1327
- },
1328
- contrastCurve: new ContrastCurve(1.5, 3, 4.5, 7)
1329
- },
1330
- outlineVariant: {
1331
- palette: function palette(s) {
1332
- return s.getPalette('neutralVariant');
1333
- },
1334
- tone: function tone(s) {
1335
- return s.isDark ? 30 : 80;
1563
+ if (!configImport) {
1564
+ throw new Error('Configuration file not found');
1565
+ }
1566
+ var config;
1567
+ if ('default' in configImport) {
1568
+ config = configImport["default"];
1569
+ } else {
1570
+ config = configImport;
1571
+ }
1572
+ return config;
1573
+ } else {
1574
+ throw new Error('You must provide configuration object when using this library in a browser.');
1575
+ }
1576
+ };
1577
+ return ConfigService;
1578
+ }();
1579
+
1580
+ var ConfigModule = {
1581
+ configService: /*#__PURE__*/awilix.asClass(ConfigService).singleton()
1582
+ };
1583
+
1584
+ var PluginService = /*#__PURE__*/function () {
1585
+ function PluginService() {
1586
+ this.plugins = new Map();
1587
+ }
1588
+ var _proto = PluginService.prototype;
1589
+ _proto.addPlugin = function addPlugin(plugin) {
1590
+ this.plugins.set(plugin.name, plugin);
1591
+ };
1592
+ _proto.loadPlugins = function loadPlugins(appService) {
1593
+ var _this = this;
1594
+ var plugins = new Map(this.plugins);
1595
+ var size = 0;
1596
+ do {
1597
+ size = plugins.size;
1598
+ plugins.forEach(function (plugin, key) {
1599
+ var deps = plugin.dependencies.filter(function (dep) {
1600
+ return !_this.plugins.has(new dep().name);
1601
+ });
1602
+ if (deps.length === 0) {
1603
+ _this.plugins.set(plugin.name, plugin.init(appService));
1604
+ plugins["delete"](key);
1605
+ }
1606
+ });
1607
+ } while (plugins.size != 0 && plugins.size < size);
1608
+ if (plugins.size > 0) throw new Error("Some plugins couldn't be loaded due to missing dependencies: " + Array.from(plugins.keys()));
1609
+ };
1610
+ _proto.getPlugin = function getPlugin(plugin) {
1611
+ var pluginInstance = this.plugins.get(new plugin().name);
1612
+ if (!pluginInstance) throw new Error("Plugin " + plugin.name + " not found");
1613
+ return pluginInstance;
1614
+ };
1615
+ return PluginService;
1616
+ }();
1617
+
1618
+ var PluginModule = {
1619
+ pluginService: /*#__PURE__*/awilix.asClass(PluginService).singleton()
1620
+ };
1621
+
1622
+ function importContainer(container, services) {
1623
+ services.forEach(function (service) {
1624
+ Object.entries(service).forEach(function (_ref) {
1625
+ var name = _ref[0],
1626
+ serviceClass = _ref[1];
1627
+ container.register(name, serviceClass);
1628
+ });
1629
+ });
1630
+ return container;
1631
+ }
1632
+ var AppContainer = /*#__PURE__*/awilix.createContainer({
1633
+ injectionMode: awilix.InjectionMode.PROXY
1634
+ });
1635
+ importContainer(AppContainer, [ConfigModule, AppModule, PluginModule, ColorModule, ThemeModule]);
1636
+
1637
+ function bootstrap() {
1638
+ return AppContainer.resolve('appService');
1639
+ }
1640
+ function bootstrapFromConfig(args) {
1641
+ var configService = AppContainer.resolve('configService');
1642
+ if (args != null && args.path) configService.configPath = args.path;
1643
+ configService.loadConfig(args == null ? void 0 : args.config);
1644
+ return AppContainer.resolve('appService');
1645
+ }
1646
+
1647
+ var PluginAbstract = /*#__PURE__*/function () {
1648
+ function PluginAbstract(options) {
1649
+ this.options = void 0;
1650
+ this.pluginInstance = void 0;
1651
+ this.options = options;
1652
+ }
1653
+ var _proto = PluginAbstract.prototype;
1654
+ _proto.init = function init(appService) {
1655
+ this.pluginInstance = new this.pluginClass(appService, this.options);
1656
+ this.pluginInstance.onInit();
1657
+ return this;
1658
+ };
1659
+ _proto.getInstance = function getInstance() {
1660
+ if (!this.pluginInstance) {
1661
+ throw new Error("Plugin " + this.name + " is not initialized");
1662
+ }
1663
+ return this.pluginInstance;
1664
+ };
1665
+ return PluginAbstract;
1666
+ }();
1667
+ var PluginImplAbstract = function PluginImplAbstract(appService, options) {
1668
+ this.appService = void 0;
1669
+ this.options = void 0;
1670
+ this.appService = appService;
1671
+ this.options = options;
1672
+ this.onInit();
1673
+ };
1674
+
1675
+ exports.FontFamily = void 0;
1676
+ (function (FontFamily) {
1677
+ FontFamily["Expressive"] = "expressive";
1678
+ FontFamily["Neutral"] = "neutral";
1679
+ })(exports.FontFamily || (exports.FontFamily = {}));
1680
+ var FontPlugin = /*#__PURE__*/function (_PluginAbstract) {
1681
+ function FontPlugin() {
1682
+ var _this;
1683
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1684
+ args[_key] = arguments[_key];
1685
+ }
1686
+ _this = _PluginAbstract.call.apply(_PluginAbstract, [this].concat(args)) || this;
1687
+ _this.dependencies = [];
1688
+ _this.name = 'font';
1689
+ _this.pluginClass = FontPluginImpl;
1690
+ return _this;
1691
+ }
1692
+ _inheritsLoose(FontPlugin, _PluginAbstract);
1693
+ return FontPlugin;
1694
+ }(PluginAbstract);
1695
+ var FontPluginImpl = /*#__PURE__*/function (_PluginImplAbstract) {
1696
+ function FontPluginImpl() {
1697
+ var _this2;
1698
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
1699
+ args[_key2] = arguments[_key2];
1700
+ }
1701
+ _this2 = _PluginImplAbstract.call.apply(_PluginImplAbstract, [this].concat(args)) || this;
1702
+ _this2._fontFamily = void 0;
1703
+ _this2._fontStyles = void 0;
1704
+ return _this2;
1705
+ }
1706
+ _inheritsLoose(FontPluginImpl, _PluginImplAbstract);
1707
+ var _proto = FontPluginImpl.prototype;
1708
+ _proto.getFonts = function getFonts() {
1709
+ return {
1710
+ fontStyles: this.fontStyles,
1711
+ fontFamily: this.fontFamily
1712
+ };
1713
+ };
1714
+ _proto.onInit = function onInit() {
1715
+ var _this$options$fontFam,
1716
+ _this$options,
1717
+ _this$options$fontFam2,
1718
+ _this$options2,
1719
+ _this3 = this;
1720
+ this.fontFamily = {
1721
+ expressive: (_this$options$fontFam = (_this$options = this.options) == null || (_this$options = _this$options.fontFamily) == null ? void 0 : _this$options.expressive) != null ? _this$options$fontFam : ['Roboto', 'sans-serif'],
1722
+ neutral: (_this$options$fontFam2 = (_this$options2 = this.options) == null || (_this$options2 = _this$options2.fontFamily) == null ? void 0 : _this$options2.neutral) != null ? _this$options$fontFam2 : ['Roboto', 'sans-serif']
1723
+ };
1724
+ this.fontStyles = {
1725
+ display: {
1726
+ large: {
1727
+ fontWeight: 400,
1728
+ fontSize: 3.5625,
1729
+ lineHeight: 4,
1730
+ letterSpacing: -0.015625,
1731
+ fontFamily: exports.FontFamily.Expressive
1732
+ },
1733
+ medium: {
1734
+ fontWeight: 400,
1735
+ fontSize: 2.8125,
1736
+ lineHeight: 3.25,
1737
+ fontFamily: exports.FontFamily.Expressive
1738
+ },
1739
+ small: {
1740
+ fontWeight: 400,
1741
+ fontSize: 2.25,
1742
+ lineHeight: 2.75,
1743
+ fontFamily: exports.FontFamily.Expressive
1744
+ }
1336
1745
  },
1337
- background: function background(s) {
1338
- return highestSurface(s, colorManagerService);
1746
+ headline: {
1747
+ large: {
1748
+ fontWeight: 400,
1749
+ fontSize: 2,
1750
+ lineHeight: 2.5,
1751
+ fontFamily: exports.FontFamily.Expressive
1752
+ },
1753
+ medium: {
1754
+ fontWeight: 400,
1755
+ fontSize: 1.75,
1756
+ lineHeight: 2.25,
1757
+ fontFamily: exports.FontFamily.Expressive
1758
+ },
1759
+ small: {
1760
+ fontWeight: 400,
1761
+ fontSize: 1.5,
1762
+ lineHeight: 2,
1763
+ fontFamily: exports.FontFamily.Expressive
1764
+ }
1339
1765
  },
1340
- contrastCurve: new ContrastCurve(1, 1, 3, 7)
1341
- },
1342
- shadow: {
1343
- palette: function palette(s) {
1344
- return s.getPalette('neutral');
1766
+ title: {
1767
+ large: {
1768
+ fontWeight: 400,
1769
+ fontSize: 1.375,
1770
+ lineHeight: 1.75,
1771
+ fontFamily: exports.FontFamily.Neutral
1772
+ },
1773
+ medium: {
1774
+ fontWeight: 500,
1775
+ fontSize: 1,
1776
+ lineHeight: 1.5,
1777
+ fontFamily: exports.FontFamily.Neutral,
1778
+ letterSpacing: 0.009375
1779
+ },
1780
+ small: {
1781
+ fontWeight: 500,
1782
+ fontSize: 0.875,
1783
+ lineHeight: 1.25,
1784
+ fontFamily: exports.FontFamily.Neutral,
1785
+ letterSpacing: 0.00625
1786
+ }
1345
1787
  },
1346
- tone: function tone(s) {
1347
- return 0;
1348
- }
1349
- },
1350
- scrim: {
1351
- palette: function palette(s) {
1352
- return s.getPalette('neutral');
1788
+ label: {
1789
+ large: {
1790
+ fontWeight: 500,
1791
+ fontSize: 0.875,
1792
+ lineHeight: 1.25,
1793
+ fontFamily: exports.FontFamily.Neutral,
1794
+ letterSpacing: 0.00625
1795
+ },
1796
+ medium: {
1797
+ fontWeight: 500,
1798
+ fontSize: 0.75,
1799
+ lineHeight: 1,
1800
+ fontFamily: exports.FontFamily.Neutral,
1801
+ letterSpacing: 0.03125
1802
+ },
1803
+ small: {
1804
+ fontWeight: 500,
1805
+ fontSize: 0.6875,
1806
+ lineHeight: 1,
1807
+ fontFamily: exports.FontFamily.Neutral,
1808
+ letterSpacing: 0.03125
1809
+ }
1353
1810
  },
1354
- tone: function tone(s) {
1355
- return 0;
1811
+ body: {
1812
+ large: {
1813
+ fontWeight: 400,
1814
+ fontSize: 1,
1815
+ lineHeight: 1.5625,
1816
+ fontFamily: exports.FontFamily.Neutral,
1817
+ letterSpacing: 0.03125
1818
+ },
1819
+ medium: {
1820
+ fontWeight: 400,
1821
+ fontSize: 0.875,
1822
+ lineHeight: 1.25,
1823
+ fontFamily: exports.FontFamily.Neutral,
1824
+ letterSpacing: 0.015625
1825
+ },
1826
+ small: {
1827
+ fontWeight: 400,
1828
+ fontSize: 0.75,
1829
+ lineHeight: 1,
1830
+ fontFamily: exports.FontFamily.Neutral,
1831
+ letterSpacing: 0.025
1832
+ }
1356
1833
  }
1834
+ };
1835
+ if (this.options && this.options.fontStyles) Object.entries(this.options.fontStyles).forEach(function (_ref) {
1836
+ var key = _ref[0],
1837
+ fontParam = _ref[1];
1838
+ var fontRole = key;
1839
+ Object.entries(fontParam).forEach(function (_ref2) {
1840
+ var size = _ref2[0],
1841
+ fontStyle = _ref2[1];
1842
+ var fontSize = size;
1843
+ if (fontStyle) {
1844
+ _this3.fontStyles[fontRole][fontSize] = _extends({}, _this3.fontStyles[fontRole][fontSize], fontStyle);
1845
+ }
1846
+ });
1847
+ });
1848
+ };
1849
+ return _createClass(FontPluginImpl, [{
1850
+ key: "fontFamily",
1851
+ get: function get() {
1852
+ if (!this._fontFamily) throw new Error('Font family not initialized');
1853
+ return this._fontFamily;
1357
1854
  },
1358
- surfaceTint: {
1359
- palette: function palette(s) {
1360
- return s.getPalette('neutral');
1361
- },
1362
- tone: function tone(s) {
1363
- return s.isDark ? 80 : 40;
1364
- },
1365
- isBackground: true
1366
- },
1367
- secondaryContainer: {
1368
- tone: function tone(s) {
1369
- var initialTone = s.isDark ? 30 : 90;
1370
- return findDesiredChromaByTone(s.getPalette('secondary').hue, s.getPalette('secondary').chroma, initialTone, !s.isDark);
1371
- }
1855
+ set: function set(value) {
1856
+ this._fontFamily = value;
1857
+ }
1858
+ }, {
1859
+ key: "fontStyles",
1860
+ get: function get() {
1861
+ if (!this._fontStyles) throw new Error('Font styles not initialized');
1862
+ return this._fontStyles;
1372
1863
  },
1373
- onSecondaryContainer: {
1374
- tone: function tone(s) {
1375
- return DynamicColor.foregroundTone(colorManagerService.get('secondaryContainer').getDynamicColor().tone(s), 4.5);
1864
+ set: function set(value) {
1865
+ this._fontStyles = value;
1866
+ }
1867
+ }]);
1868
+ }(PluginImplAbstract);
1869
+
1870
+ var state = function state(colorkeys) {
1871
+ return plugin(function (pluginArgs) {
1872
+ addAllNewComponents(pluginArgs, {
1873
+ statePrefix: 'state',
1874
+ disabledStyles: {
1875
+ textOpacity: 0.38,
1876
+ backgroundOpacity: 0.12
1877
+ },
1878
+ transition: {
1879
+ duration: 150
1376
1880
  }
1377
- },
1378
- tertiaryContainer: {
1379
- palette: function palette(s) {
1380
- return s.getPalette('tertiary');
1381
- },
1382
- tone: function tone(s) {
1383
- var proposedHct = s.getPalette('tertiary').getHct(s.sourceColorHct.tone);
1384
- return materialColorUtilities.DislikeAnalyzer.fixIfDisliked(proposedHct).tone;
1881
+ }, colorkeys);
1882
+ }, {});
1883
+ };
1884
+ var addAllNewComponents = function addAllNewComponents(_ref, _ref2, colorKeys) {
1885
+ var addComponents = _ref.addComponents;
1886
+ var statePrefix = _ref2.statePrefix,
1887
+ disabledStyles = _ref2.disabledStyles,
1888
+ transition = _ref2.transition;
1889
+ var newComponents = {};
1890
+ for (var _i = 0, _arr = [false, true]; _i < _arr.length; _i++) {
1891
+ var isGroup = _arr[_i];
1892
+ var group = isGroup ? 'group-' : '';
1893
+ for (var _iterator = _createForOfIteratorHelperLoose(colorKeys), _step; !(_step = _iterator()).done;) {
1894
+ var _newComponents$classN;
1895
+ var colorName = _step.value;
1896
+ var className = "." + group + statePrefix + "-" + colorName;
1897
+ newComponents[className] = (_newComponents$classN = {}, _newComponents$classN["@apply " + group + "hover:bg-" + colorName + "/[0.08]"] = {}, _newComponents$classN["@apply " + group + "active:bg-" + colorName + "/[0.12]"] = {}, _newComponents$classN["@apply " + group + "focus-visible:bg-" + colorName + "/[0.12]"] = {}, _newComponents$classN);
1898
+ if (transition) {
1899
+ newComponents[className]["@apply transition-colors"] = {};
1900
+ newComponents[className]["@apply duration-" + transition.duration] = {};
1385
1901
  }
1386
- },
1387
- onTertiaryContainer: {
1388
- palette: function palette(s) {
1389
- return s.getPalette('tertiary');
1390
- },
1391
- tone: function tone(s) {
1392
- return DynamicColor.foregroundTone(colorManagerService.get('tertiaryContainer').getDynamicColor().tone(s), 4.5);
1902
+ if (disabledStyles) {
1903
+ newComponents[className]["@apply " + group + "disabled:text-on-surface/[" + disabledStyles.textOpacity + "]"] = {};
1904
+ newComponents[className]["@apply " + group + "disabled:bg-on-surface/[" + disabledStyles.backgroundOpacity + "]"] = {};
1393
1905
  }
1394
- },
1395
- error: {
1396
- palette: function palette(s) {
1397
- return s.getPalette('error');
1398
- },
1399
- tone: function tone(s) {
1400
- return s.isDark ? 80 : 40;
1401
- },
1402
- isBackground: true,
1403
- background: function background(s) {
1404
- return highestSurface(s, colorManagerService);
1405
- },
1406
- contrastCurve: new ContrastCurve(3, 4.5, 7, 11),
1407
- toneDeltaPair: function toneDeltaPair(s) {
1408
- return new ToneDeltaPair(colorManagerService.get('errorContainer').getDynamicColor(), colorManagerService.get('error').getDynamicColor(), 15, 'nearer', false);
1409
- }
1410
- },
1411
- onError: {
1412
- palette: function palette(s) {
1413
- return s.getPalette('error');
1414
- },
1415
- tone: function tone(s) {
1416
- return s.isDark ? 20 : 100;
1417
- },
1418
- background: function background(s) {
1419
- return colorManagerService.get('error').getDynamicColor();
1420
- },
1421
- contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
1422
- },
1423
- errorContainer: {
1424
- palette: function palette(s) {
1425
- return s.getPalette('error');
1426
- },
1427
- tone: function tone(s) {
1428
- return s.isDark ? 30 : 90;
1429
- },
1430
- isBackground: true,
1431
- background: function background(s) {
1432
- return highestSurface(s, colorManagerService);
1433
- },
1434
- contrastCurve: new ContrastCurve(1, 1, 3, 7),
1435
- toneDeltaPair: function toneDeltaPair(s) {
1436
- return new ToneDeltaPair(colorManagerService.get('errorContainer').getDynamicColor(), colorManagerService.get('error').getDynamicColor(), 15, 'nearer', false);
1906
+ }
1907
+ }
1908
+ for (var _iterator2 = _createForOfIteratorHelperLoose(colorKeys), _step2; !(_step2 = _iterator2()).done;) {
1909
+ var _colorName = _step2.value;
1910
+ for (var _i2 = 0, _arr2 = ['hover', 'active', 'focus', 'disabled']; _i2 < _arr2.length; _i2++) {
1911
+ var stateName = _arr2[_i2];
1912
+ var _className = "." + stateName + "-" + statePrefix + "-" + _colorName;
1913
+ if (stateName === 'active' || stateName === 'focus') {
1914
+ var _newComponents$_class;
1915
+ newComponents[_className] = (_newComponents$_class = {}, _newComponents$_class["@apply bg-" + _colorName + "/[0.12]"] = {}, _newComponents$_class);
1916
+ } else if (stateName === 'hover') {
1917
+ var _newComponents$_class2;
1918
+ newComponents[_className] = (_newComponents$_class2 = {}, _newComponents$_class2["@apply bg-" + _colorName + "/[0.08]"] = {}, _newComponents$_class2);
1919
+ } else if (stateName === 'disabled') {
1920
+ var _newComponents$_class3, _newComponents$_class4;
1921
+ newComponents[_className] = (_newComponents$_class3 = {}, _newComponents$_class3["@apply text-on-surface/[" + disabledStyles.textOpacity + "]"] = {}, _newComponents$_class3);
1922
+ newComponents[_className] = (_newComponents$_class4 = {}, _newComponents$_class4["@apply bg-on-surface/[" + disabledStyles.backgroundOpacity + "]"] = {}, _newComponents$_class4);
1437
1923
  }
1438
- },
1439
- onErrorContainer: {
1440
- palette: function palette(s) {
1441
- return s.getPalette('error');
1442
- },
1443
- tone: function tone(s) {
1444
- return s.isDark ? 90 : 10;
1445
- },
1446
- background: function background(s) {
1447
- return colorManagerService.get('errorContainer').getDynamicColor();
1448
- },
1449
- contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
1450
- },
1451
- onTertiaryFixed: {
1452
- palette: function palette(s) {
1453
- return s.getPalette('tertiary');
1454
- },
1455
- tone: function tone(s) {
1456
- return 10.0;
1457
- },
1458
- background: function background(s) {
1459
- return colorManagerService.get('tertiaryFixedDim').getDynamicColor();
1460
- },
1461
- secondBackground: function secondBackground(s) {
1462
- return colorManagerService.get('tertiaryFixed').getDynamicColor();
1463
- },
1464
- contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
1465
- },
1466
- onTertiaryFixedVariant: {
1467
- palette: function palette(s) {
1468
- return s.getPalette('tertiary');
1469
- },
1470
- tone: function tone(s) {
1471
- return 30.0;
1472
- },
1473
- background: function background(s) {
1474
- return colorManagerService.get('tertiaryFixedDim').getDynamicColor();
1475
- },
1476
- secondBackground: function secondBackground(s) {
1477
- return colorManagerService.get('tertiaryFixed').getDynamicColor();
1478
- },
1479
- contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
1480
1924
  }
1481
- };
1925
+ }
1926
+ addComponents(newComponents);
1482
1927
  };
1483
1928
 
1484
- var ColorService = /*#__PURE__*/function () {
1485
- function ColorService(colorManagerService) {
1486
- this.colorManagerService = void 0;
1487
- this.colorManagerService = colorManagerService;
1488
- }
1489
- var _proto = ColorService.prototype;
1490
- _proto.getAllColors = function getAllColors() {
1491
- return this.colorManagerService.getAll();
1492
- }
1493
- // getColors() {
1494
- // const colors: Record<string, string> = {};
1495
- //
1496
- // for (const [key, value] of this.colorManagerService.getAll()) {
1497
- // colors[key] = hexFromArgb(value.getArgb(this.schemeService.get()));
1498
- // }
1499
- //
1500
- // return colors;
1501
- // }
1502
- ;
1503
- _proto.addBaseColors = function addBaseColors() {
1504
- var _this = this;
1505
- this.colorManagerService.addFromPalette('primary');
1506
- this.colorManagerService.addFromPalette('secondary');
1507
- this.colorManagerService.addFromPalette('tertiary');
1508
- var colors = defaultColors(this.colorManagerService);
1509
- Object.keys(colors).map(function (key) {
1510
- var color = colors[key];
1511
- if (!color) return;
1512
- return _this.colorManagerService.createOrUpdate(key, color);
1513
- });
1929
+ function createSubTheme(_ref) {
1930
+ var name = _ref.name,
1931
+ darkMode = _ref.darkMode,
1932
+ isDarkTheme = _ref.isDarkTheme,
1933
+ colors = _ref.colors;
1934
+ var theme = {
1935
+ name: isDarkTheme ? name + 'Dark' : name,
1936
+ selectors: isDarkTheme && darkMode === 'class' ? ['.dark-mode .theme-' + name, '.dark-mode.theme-' + name, '[data-theme="dark"] .theme-' + name, '[data-theme="dark"].theme-' + name] : ['.theme-' + name, ".theme-" + name + " .light-mode", ".theme-" + name + " [data-theme=\"light\"]", ".light-mode .theme-" + name, ".light-mode.theme-" + name, "[data-theme=\"light\"] .theme-" + name, "[data-theme=\"light\"].theme-" + name],
1937
+ mediaQuery: isDarkTheme && darkMode === 'media' ? '@media (prefers-color-scheme: dark)' : undefined,
1938
+ extend: {
1939
+ colors: colors
1940
+ }
1514
1941
  };
1515
- _proto.addColor = function addColor(key, color) {
1516
- return this.colorManagerService.createOrUpdate(key, color);
1942
+ return theme;
1943
+ }
1944
+ var themer = function themer(args) {
1945
+ var _args$appService = args.appService,
1946
+ themeService = _args$appService.themeService,
1947
+ colorService = _args$appService.colorService;
1948
+ var options = {
1949
+ defaultTheme: {
1950
+ extend: {
1951
+ colors: {}
1952
+ }
1953
+ },
1954
+ themes: [{
1955
+ name: 'darkTheme',
1956
+ extend: {
1957
+ colors: {}
1958
+ }
1959
+ }]
1517
1960
  };
1518
- _proto.addColors = function addColors(colors) {
1519
- var _this2 = this;
1520
- return Object.keys(colors).map(function (key) {
1521
- return _this2.addColor(key, colors[key]);
1961
+ Object.entries(args.colors).forEach(function (_ref2) {
1962
+ var key = _ref2[0],
1963
+ value = _ref2[1];
1964
+ options.defaultTheme.extend.colors[key] = value.light;
1965
+ options.themes[0].extend.colors[key] = value.dark;
1966
+ });
1967
+ options.themes[0].selectors = args.darkMode === 'class' ? ['.dark-mode', '[data-theme="dark"]'] : undefined;
1968
+ options.themes[0].mediaQuery = args.darkMode === 'media' ? '@media (prefers-color-scheme: dark)' : undefined;
1969
+ if (args.subThemes) {
1970
+ Object.entries(args.subThemes).forEach(function (_ref3) {
1971
+ var key = _ref3[0],
1972
+ value = _ref3[1];
1973
+ themeService.update({
1974
+ sourceColorHex: value
1975
+ });
1976
+ for (var _i = 0, _arr = [true, false]; _i < _arr.length; _i++) {
1977
+ var isDarkTheme = _arr[_i];
1978
+ var colors = {};
1979
+ themeService.update({
1980
+ isDark: isDarkTheme
1981
+ });
1982
+ for (var _iterator = _createForOfIteratorHelperLoose(colorService.getColors().entries()), _step; !(_step = _iterator()).done;) {
1983
+ var _step$value = _step.value,
1984
+ _key = _step$value[0],
1985
+ _value = _step$value[1];
1986
+ var newKey = _key.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();
1987
+ colors[newKey] = _value.getHex();
1988
+ }
1989
+ options.themes.push(createSubTheme({
1990
+ name: key,
1991
+ isDarkTheme: isDarkTheme,
1992
+ darkMode: args.darkMode,
1993
+ colors: colors
1994
+ }));
1995
+ }
1522
1996
  });
1523
- };
1524
- _proto.getColor = function getColor(key) {
1525
- return this.colorManagerService.get(key);
1526
- };
1527
- _proto.removeColor = function removeColor(key) {
1528
- return this.colorManagerService.remove(key);
1529
- };
1530
- _proto.updateColor = function updateColor(key, newColor) {
1531
- return this.colorManagerService.createOrUpdate(key, newColor);
1532
- };
1533
- return ColorService;
1534
- }();
1535
- ColorService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable(), /*#__PURE__*/tslib.__metadata("design:paramtypes", [ColorManagerService])], ColorService);
1536
-
1537
- var VariantService = /*#__PURE__*/function () {
1538
- function VariantService(schemeService) {
1539
- this.schemeService = void 0;
1540
- this.schemeService = schemeService;
1541
1997
  }
1542
- var _proto = VariantService.prototype;
1543
- _proto.set = function set(variantEntity) {
1544
- if (!variantEntity.palettes.error) {
1545
- variantEntity.palettes.error = function () {
1546
- return materialColorUtilities.TonalPalette.fromHueAndChroma(25.0, 84.0);
1998
+ return require('tailwindcss-themer')(options);
1999
+ };
2000
+
2001
+ var font = function font(fontStyles, responsiveBreakPoints) {
2002
+ var createUtilities = function createUtilities(_ref) {
2003
+ var theme = _ref.theme;
2004
+ var pixelUnit = 'rem';
2005
+ var newUtilities = {};
2006
+ var baseTextStyle = function baseTextStyle(sizeValue) {
2007
+ return {
2008
+ fontSize: sizeValue.fontSize + pixelUnit,
2009
+ fontWeight: sizeValue.fontWeight,
2010
+ lineHeight: sizeValue.lineHeight + pixelUnit,
2011
+ letterSpacing: sizeValue.letterSpacing ? sizeValue.letterSpacing + pixelUnit : null,
2012
+ fontFamily: theme('fontFamily.' + sizeValue.fontFamily)
1547
2013
  };
2014
+ };
2015
+ var responsiveTextStyle = function responsiveTextStyle(sizeValue, breakPointName, breakPointRatio) {
2016
+ var _ref2;
2017
+ return _ref2 = {}, _ref2["@media (min-width: " + theme('screens.' + breakPointName, {}) + ")"] = {
2018
+ fontSize: sizeValue.fontSize * breakPointRatio + pixelUnit,
2019
+ lineHeight: sizeValue.lineHeight * breakPointRatio + pixelUnit
2020
+ }, _ref2;
2021
+ };
2022
+ for (var _i = 0, _Object$entries = Object.entries(fontStyles); _i < _Object$entries.length; _i++) {
2023
+ var _Object$entries$_i = _Object$entries[_i],
2024
+ roleName = _Object$entries$_i[0],
2025
+ roleValue = _Object$entries$_i[1];
2026
+ var _loop = function _loop() {
2027
+ var _Object$entries2$_i = _Object$entries2[_i2],
2028
+ sizeName = _Object$entries2$_i[0],
2029
+ sizeValue = _Object$entries2$_i[1];
2030
+ newUtilities['.text-' + roleName + '-' + sizeName] = _extends({}, baseTextStyle(sizeValue), Object.entries(responsiveBreakPoints).reduce(function (acc, _ref3) {
2031
+ var breakPointName = _ref3[0],
2032
+ breakPointRatio = _ref3[1];
2033
+ acc = _extends({}, acc, responsiveTextStyle(sizeValue, breakPointName, breakPointRatio));
2034
+ return acc;
2035
+ }, {}));
2036
+ };
2037
+ for (var _i2 = 0, _Object$entries2 = Object.entries(roleValue); _i2 < _Object$entries2.length; _i2++) {
2038
+ _loop();
2039
+ }
1548
2040
  }
1549
- this.schemeService.createOrUpdate(variantEntity);
2041
+ return newUtilities;
1550
2042
  };
1551
- return VariantService;
1552
- }();
1553
- VariantService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable(), /*#__PURE__*/tslib.__metadata("design:paramtypes", [SchemeService])], VariantService);
2043
+ return plugin(function (_ref4) {
2044
+ var addUtilities = _ref4.addUtilities,
2045
+ theme = _ref4.theme;
2046
+ var newUtilities = createUtilities({
2047
+ theme: theme
2048
+ });
2049
+ addUtilities(newUtilities);
2050
+ });
2051
+ };
1554
2052
 
1555
- var ThemeService = /*#__PURE__*/function () {
1556
- function ThemeService(schemeService, variantService) {
1557
- this.schemeService = void 0;
1558
- this.variantService = void 0;
1559
- this.schemeService = schemeService;
1560
- this.variantService = variantService;
1561
- // this.addPalette({key: "primary", addDefaultColors: true})
1562
- // this.addPalette({key: "secondary", addDefaultColors: true})
1563
- // this.addPalette({key: "tertiary", addDefaultColors: true})
1564
- // this.addPalette({key: "error", palette: TonalPalette.fromHueAndChroma(25.0, 84.0)})
1565
- // this.addPalette({key: "neutral"})
1566
- // this.addPalette({key: "neutralVariant"})
2053
+ var TailwindPlugin = /*#__PURE__*/function (_PluginAbstract) {
2054
+ function TailwindPlugin() {
2055
+ var _this;
2056
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2057
+ args[_key] = arguments[_key];
2058
+ }
2059
+ _this = _PluginAbstract.call.apply(_PluginAbstract, [this].concat(args)) || this;
2060
+ _this.dependencies = [FontPlugin];
2061
+ _this.name = 'tailwind';
2062
+ _this.pluginClass = TailwindImplPlugin;
2063
+ return _this;
1567
2064
  }
1568
- // addPalette({key, palette, addDefaultColors}: {key: string; palette: TonalPalette; addDefaultColors: boolean}) {
1569
- // this.themeOptions.palettes.set(key, palette);
1570
- // if (addDefaultColors){
1571
- // this.colorService.addPalette(key)
1572
- // }
1573
- // }
1574
- // create(args: ThemeOptions): SchemeService {
1575
- // return new SchemeService(args, this.colorService)
1576
- // }
1577
- //
1578
- // update(options: Partial<ThemeOptions>): SchemeService {
1579
- // Object.assign(this.themeOptions, options);
1580
- // return this.theme();
1581
- // }
1582
- var _proto = ThemeService.prototype;
1583
- _proto.create = function create(options) {
1584
- this.schemeService.createOrUpdate(options);
1585
- };
1586
- _proto.addVariant = function addVariant(variant) {
1587
- this.variantService.set(variant);
2065
+ _inheritsLoose(TailwindPlugin, _PluginAbstract);
2066
+ return TailwindPlugin;
2067
+ }(PluginAbstract);
2068
+ var TailwindImplPlugin = /*#__PURE__*/function (_PluginImplAbstract) {
2069
+ function TailwindImplPlugin() {
2070
+ return _PluginImplAbstract.apply(this, arguments) || this;
2071
+ }
2072
+ _inheritsLoose(TailwindImplPlugin, _PluginImplAbstract);
2073
+ var _proto = TailwindImplPlugin.prototype;
2074
+ _proto.onInit = function onInit() {
2075
+ var _this$options, _this$options$darkMod, _this$options2, _this$options2$respon;
2076
+ (_this$options$darkMod = (_this$options = this.options).darkMode) != null ? _this$options$darkMod : _this$options.darkMode = 'class';
2077
+ (_this$options2$respon = (_this$options2 = this.options).responsiveBreakPoints) != null ? _this$options2$respon : _this$options2.responsiveBreakPoints = {
2078
+ lg: 1.125
2079
+ };
1588
2080
  };
1589
- _proto.update = function update(options) {
1590
- this.schemeService.createOrUpdate(options);
2081
+ _proto.getTheme = function getTheme() {
2082
+ var colors = {};
2083
+ for (var _i = 0, _arr = [false, true]; _i < _arr.length; _i++) {
2084
+ var isDark = _arr[_i];
2085
+ this.appService.themeService.update({
2086
+ isDark: isDark
2087
+ });
2088
+ for (var _iterator = _createForOfIteratorHelperLoose(this.appService.colorService.getColors().entries()), _step; !(_step = _iterator()).done;) {
2089
+ var _colors$newKey;
2090
+ var _step$value = _step.value,
2091
+ key = _step$value[0],
2092
+ value = _step$value[1];
2093
+ var newKey = key.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();
2094
+ (_colors$newKey = colors[newKey]) != null ? _colors$newKey : colors[newKey] = {
2095
+ light: '',
2096
+ dark: ''
2097
+ };
2098
+ colors[newKey][isDark ? 'dark' : 'light'] = value.getHex();
2099
+ }
2100
+ }
2101
+ var _this$appService$plug = this.appService.pluginService.getPlugin(FontPlugin).getInstance().getFonts(),
2102
+ fontStyles = _this$appService$plug.fontStyles,
2103
+ fontFamily = _this$appService$plug.fontFamily;
2104
+ return {
2105
+ colors: {},
2106
+ fontFamily: fontFamily,
2107
+ plugins: [state(Object.keys(colors)), font(fontStyles, this.options.responsiveBreakPoints), themer({
2108
+ colors: colors,
2109
+ darkMode: this.options.darkMode,
2110
+ subThemes: this.options.subThemes,
2111
+ appService: this.appService
2112
+ })]
2113
+ };
1591
2114
  };
1592
- return ThemeService;
1593
- }();
1594
- ThemeService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable(), /*#__PURE__*/tslib.__metadata("design:paramtypes", [SchemeService, VariantService])], ThemeService);
2115
+ return TailwindImplPlugin;
2116
+ }(PluginImplAbstract);
1595
2117
 
1596
- var AppService = function AppService(colorService, themeService) {
1597
- this.colorService = void 0;
1598
- this.themeService = void 0;
1599
- this.colorService = colorService;
1600
- this.themeService = themeService;
2118
+ var createTheme = function createTheme() {
2119
+ var app = bootstrapFromConfig();
2120
+ var plugin = app.pluginService.getPlugin(TailwindPlugin).getInstance();
2121
+ return _extends({}, plugin.getTheme(), {
2122
+ appService: app
2123
+ });
1601
2124
  };
1602
- AppService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable(), /*#__PURE__*/tslib.__metadata("design:paramtypes", [ColorService, ThemeService])], AppService);
1603
-
1604
- var ThemeModule = function ThemeModule() {};
1605
- ThemeModule = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Module({
1606
- providers: [SchemeService, ThemeService, VariantService],
1607
- exports: [ThemeService, SchemeService]
1608
- })], ThemeModule);
1609
-
1610
- var ColorModule = function ColorModule() {};
1611
- ColorModule = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Module({
1612
- imports: [ThemeModule],
1613
- providers: [ColorService, ColorManagerService],
1614
- exports: [ColorService]
1615
- })], ColorModule);
1616
-
1617
- var AppModule = function AppModule() {};
1618
- AppModule = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Module({
1619
- imports: [ColorModule, ThemeModule],
1620
- providers: [AppService]
1621
- })], AppModule);
1622
-
1623
- function main() {
1624
- return _main.apply(this, arguments);
1625
- }
1626
- function _main() {
1627
- _main = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1628
- var app, appService, close;
1629
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1630
- while (1) switch (_context.prev = _context.next) {
1631
- case 0:
1632
- _context.next = 2;
1633
- return core.NestFactory.create(AppModule);
1634
- case 2:
1635
- app = _context.sent;
1636
- appService = app.get(AppService);
1637
- close = function close() {
1638
- return app.close();
1639
- };
1640
- return _context.abrupt("return", [appService, close]);
1641
- case 6:
1642
- case "end":
1643
- return _context.stop();
1644
- }
1645
- }, _callee);
1646
- }));
1647
- return _main.apply(this, arguments);
1648
- }
1649
2125
 
1650
- exports.main = main;
2126
+ exports.AppContainer = AppContainer;
2127
+ exports.AppModule = AppModule;
2128
+ exports.AppService = AppService;
2129
+ exports.ColorEntity = ColorEntity;
2130
+ exports.ColorManagerService = ColorManagerService;
2131
+ exports.ColorModule = ColorModule;
2132
+ exports.ColorService = ColorService;
2133
+ exports.ConfigModule = ConfigModule;
2134
+ exports.ConfigService = ConfigService;
2135
+ exports.ContrastCurve = ContrastCurve;
2136
+ exports.DynamicColor = DynamicColor;
2137
+ exports.FontPlugin = FontPlugin;
2138
+ exports.PluginAbstract = PluginAbstract;
2139
+ exports.PluginImplAbstract = PluginImplAbstract;
2140
+ exports.PluginModule = PluginModule;
2141
+ exports.PluginService = PluginService;
2142
+ exports.SchemeEntity = SchemeEntity;
2143
+ exports.SchemeService = SchemeService;
2144
+ exports.TailwindPlugin = TailwindPlugin;
2145
+ exports.ThemeModule = ThemeModule;
2146
+ exports.ThemeService = ThemeService;
2147
+ exports.ToneDeltaPair = ToneDeltaPair;
2148
+ exports.VariantEntity = VariantEntity;
2149
+ exports.VariantModel = VariantModel;
2150
+ exports.VariantService = VariantService;
2151
+ exports.bootstrap = bootstrap;
2152
+ exports.bootstrapFromConfig = bootstrapFromConfig;
2153
+ exports.createTheme = createTheme;
2154
+ exports.defaultColors = defaultColors;
2155
+ exports.defineConfig = defineConfig;
2156
+ exports.getRotatedHue = getRotatedHue;
2157
+ exports.highestSurface = highestSurface;
2158
+ exports.importContainer = importContainer;
2159
+ exports.state = state;
2160
+ exports.themer = themer;
1651
2161
  //# sourceMappingURL=theme.cjs.development.js.map