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

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