@usecapsule/core-components 3.4.1 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. package/dist/capsule/capsule.esm.js +1 -1
  2. package/dist/capsule/capsule.esm.js.map +1 -1
  3. package/dist/capsule/index.esm.js +1 -1
  4. package/dist/capsule/index.esm.js.map +1 -1
  5. package/dist/capsule/p-286db996.js +2 -0
  6. package/dist/capsule/p-286db996.js.map +1 -0
  7. package/dist/capsule/p-c33942ad.entry.js +2 -0
  8. package/dist/capsule/p-c33942ad.entry.js.map +1 -0
  9. package/dist/capsule/p-e3d856af.entry.js +20 -0
  10. package/dist/capsule/p-e3d856af.entry.js.map +1 -0
  11. package/dist/cjs/capsule.cjs.js +1 -1
  12. package/dist/cjs/cpsl-alert_34.cjs.entry.js +67 -5
  13. package/dist/cjs/cpsl-alert_34.cjs.entry.js.map +1 -1
  14. package/dist/cjs/cpsl-identicon.cjs.entry.js +76 -30
  15. package/dist/cjs/cpsl-identicon.cjs.entry.js.map +1 -1
  16. package/dist/cjs/index.cjs.js +2 -0
  17. package/dist/cjs/index.cjs.js.map +1 -1
  18. package/dist/cjs/loader.cjs.js +1 -1
  19. package/dist/cjs/prand-a35ea6b2.js +209 -0
  20. package/dist/cjs/prand-a35ea6b2.js.map +1 -0
  21. package/dist/collection/assets/icons/check-circle-filled.svg +5 -0
  22. package/dist/collection/assets/icons/cosmos.svg +12 -0
  23. package/dist/collection/assets/icons/ethereum.svg +4 -0
  24. package/dist/collection/assets/icons/index.js +5 -1
  25. package/dist/collection/assets/icons/index.js.map +1 -1
  26. package/dist/collection/assets/icons/solana.svg +19 -0
  27. package/dist/collection/components/cpsl-alert/cpsl-alert.js +1 -1
  28. package/dist/collection/components/cpsl-auth-modal/cpsl-auth-modal.css +3 -1
  29. package/dist/collection/components/cpsl-button/cpsl-button.css +1 -1
  30. package/dist/collection/components/cpsl-icon/cpsl-icon.js +1 -1
  31. package/dist/collection/components/cpsl-identicon/cpsl-identicon.css +17 -10
  32. package/dist/collection/components/cpsl-identicon/cpsl-identicon.js +101 -36
  33. package/dist/collection/components/cpsl-identicon/cpsl-identicon.js.map +1 -1
  34. package/dist/collection/components/cpsl-identicon/cpsl-identicon.stories.js +1 -1
  35. package/dist/collection/components/cpsl-identicon/cpsl-identicon.stories.js.map +1 -1
  36. package/dist/collection/components/cpsl-input/cpsl-input.js +1 -1
  37. package/dist/collection/components/cpsl-slide-button/cpsl-slide-button.js +2 -2
  38. package/dist/collection/components/cpsl-tab/cpsl-tab.js +32 -1
  39. package/dist/collection/components/cpsl-tab/cpsl-tab.js.map +1 -1
  40. package/dist/collection/components/cpsl-tab/tab-interface.js.map +1 -1
  41. package/dist/collection/components/cpsl-tabs/cpsl-tabs.js +16 -1
  42. package/dist/collection/components/cpsl-tabs/cpsl-tabs.js.map +1 -1
  43. package/dist/collection/components/cpsl-tile-button/cpsl-tile-button.js +1 -1
  44. package/dist/collection/index.js +1 -0
  45. package/dist/collection/index.js.map +1 -1
  46. package/dist/collection/lib/prando.js +187 -0
  47. package/dist/collection/lib/prando.js.map +1 -0
  48. package/dist/collection/utils/prand.js +16 -0
  49. package/dist/collection/utils/prand.js.map +1 -0
  50. package/dist/esm/capsule.js +1 -1
  51. package/dist/esm/cpsl-alert_34.entry.js +67 -5
  52. package/dist/esm/cpsl-alert_34.entry.js.map +1 -1
  53. package/dist/esm/cpsl-identicon.entry.js +76 -30
  54. package/dist/esm/cpsl-identicon.entry.js.map +1 -1
  55. package/dist/esm/index.js +1 -0
  56. package/dist/esm/index.js.map +1 -1
  57. package/dist/esm/loader.js +1 -1
  58. package/dist/esm/prand-c8323494.js +205 -0
  59. package/dist/esm/prand-c8323494.js.map +1 -0
  60. package/dist/types/assets/icons/index.d.ts +4 -0
  61. package/dist/types/components/cpsl-identicon/cpsl-identicon.d.ts +5 -4
  62. package/dist/types/components/cpsl-tab/cpsl-tab.d.ts +7 -1
  63. package/dist/types/components/cpsl-tab/tab-interface.d.ts +3 -0
  64. package/dist/types/components/cpsl-tabs/cpsl-tabs.d.ts +2 -0
  65. package/dist/types/components.d.ts +11 -8
  66. package/dist/types/index.d.ts +1 -0
  67. package/dist/types/lib/prando.d.ts +92 -0
  68. package/dist/types/utils/prand.d.ts +3 -0
  69. package/package.json +4 -4
  70. package/dist/capsule/p-5d62e610.entry.js +0 -2
  71. package/dist/capsule/p-5d62e610.entry.js.map +0 -1
  72. package/dist/capsule/p-afbb1e6f.entry.js +0 -20
  73. package/dist/capsule/p-afbb1e6f.entry.js.map +0 -1
@@ -0,0 +1,205 @@
1
+ /*
2
+ * This file contains code from prando, which is licensed under the MIT License:
3
+ *
4
+ * Copyright (c) 2016 Zeh Fernando
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+ class Prando {
25
+ // ================================================================================================================
26
+ // CONSTRUCTOR ----------------------------------------------------------------------------------------------------
27
+ /**
28
+ * Generate a new Prando pseudo-random number generator.
29
+ *
30
+ * @param seed - A number or string seed that determines which pseudo-random number sequence will be created. Defaults to a random seed based on `Math.random()`.
31
+ */
32
+ constructor(seed) {
33
+ this._value = NaN;
34
+ if (typeof seed === 'string') {
35
+ // String seed
36
+ this._seed = this.hashCode(seed);
37
+ }
38
+ else if (typeof seed === 'number') {
39
+ // Numeric seed
40
+ this._seed = this.getSafeSeed(seed);
41
+ }
42
+ else {
43
+ // Pseudo-random seed
44
+ this._seed = this.getSafeSeed(Prando.MIN + Math.floor((Prando.MAX - Prando.MIN) * Math.random()));
45
+ }
46
+ this.reset();
47
+ }
48
+ // ================================================================================================================
49
+ // PUBLIC INTERFACE -----------------------------------------------------------------------------------------------
50
+ /**
51
+ * Generates a pseudo-random number between a lower (inclusive) and a higher (exclusive) bounds.
52
+ *
53
+ * @param min - The minimum number that can be randomly generated.
54
+ * @param pseudoMax - The maximum number that can be randomly generated (exclusive).
55
+ * @return The generated pseudo-random number.
56
+ */
57
+ next(min = 0, pseudoMax = 1) {
58
+ this.recalculate();
59
+ return this.map(this._value, Prando.MIN, Prando.MAX, min, pseudoMax);
60
+ }
61
+ /**
62
+ * Generates a pseudo-random integer number in a range (inclusive).
63
+ *
64
+ * @param min - The minimum number that can be randomly generated.
65
+ * @param max - The maximum number that can be randomly generated.
66
+ * @return The generated pseudo-random number.
67
+ */
68
+ nextInt(min = 10, max = 100) {
69
+ this.recalculate();
70
+ return Math.floor(this.map(this._value, Prando.MIN, Prando.MAX, min, max + 1));
71
+ }
72
+ /**
73
+ * Generates a pseudo-random string sequence of a particular length from a specific character range.
74
+ *
75
+ * Note: keep in mind that creating a random string sequence does not guarantee uniqueness; there is always a
76
+ * 1 in (char_length^string_length) chance of collision. For real unique string ids, always check for
77
+ * pre-existing ids, or employ a robust GUID/UUID generator.
78
+ *
79
+ * @param length - Length of the string to be generated.
80
+ * @param chars - Characters that are used when creating the random string. Defaults to all alphanumeric chars (A-Z, a-z, 0-9).
81
+ * @return The generated string sequence.
82
+ */
83
+ nextString(length = 16, chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789') {
84
+ let str = '';
85
+ while (str.length < length) {
86
+ str += this.nextChar(chars);
87
+ }
88
+ return str;
89
+ }
90
+ /**
91
+ * Generates a pseudo-random string of 1 character specific character range.
92
+ *
93
+ * @param chars - Characters that are used when creating the random string. Defaults to all alphanumeric chars (A-Z, a-z, 0-9).
94
+ * @return The generated character.
95
+ */
96
+ nextChar(chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789') {
97
+ return chars.substr(this.nextInt(0, chars.length - 1), 1);
98
+ }
99
+ /**
100
+ * Picks a pseudo-random item from an array. The array is left unmodified.
101
+ *
102
+ * Note: keep in mind that while the returned item will be random enough, picking one item from the array at a time
103
+ * does not guarantee nor imply that a sequence of random non-repeating items will be picked. If you want to
104
+ * *pick items in a random order* from an array, instead of *pick one random item from an array*, it's best to
105
+ * apply a *shuffle* transformation to the array instead, then read it linearly.
106
+ *
107
+ * @param array - Array of any type containing one or more candidates for random picking.
108
+ * @return An item from the array.
109
+ */
110
+ nextArrayItem(array) {
111
+ return array[this.nextInt(0, array.length - 1)];
112
+ }
113
+ /**
114
+ * Generates a pseudo-random boolean.
115
+ *
116
+ * @return A value of true or false.
117
+ */
118
+ nextBoolean() {
119
+ this.recalculate();
120
+ return this._value > 0.5;
121
+ }
122
+ /**
123
+ * Skips ahead in the sequence of numbers that are being generated. This is equivalent to
124
+ * calling next() a specified number of times, but faster since it doesn't need to map the
125
+ * new random numbers to a range and return it.
126
+ *
127
+ * @param iterations - The number of items to skip ahead.
128
+ */
129
+ skip(iterations = 1) {
130
+ while (iterations-- > 0) {
131
+ this.recalculate();
132
+ }
133
+ }
134
+ /**
135
+ * Reset the pseudo-random number sequence back to its starting seed. Further calls to next()
136
+ * will then produce the same sequence of numbers it had produced before. This is equivalent to
137
+ * creating a new Prando instance with the same seed as another Prando instance.
138
+ *
139
+ * Example:
140
+ * let rng = new Prando(12345678);
141
+ * console.log(rng.next()); // 0.6177754114889017
142
+ * console.log(rng.next()); // 0.5784605181725837
143
+ * rng.reset();
144
+ * console.log(rng.next()); // 0.6177754114889017 again
145
+ * console.log(rng.next()); // 0.5784605181725837 again
146
+ */
147
+ reset() {
148
+ this._value = this._seed;
149
+ }
150
+ // ================================================================================================================
151
+ // PRIVATE INTERFACE ----------------------------------------------------------------------------------------------
152
+ recalculate() {
153
+ this._value = this.xorshift(this._value);
154
+ }
155
+ xorshift(value) {
156
+ // Xorshift*32
157
+ // Based on George Marsaglia's work: http://www.jstatsoft.org/v08/i14/paper
158
+ value ^= value << 13;
159
+ value ^= value >> 17;
160
+ value ^= value << 5;
161
+ return value;
162
+ }
163
+ map(val, minFrom, maxFrom, minTo, maxTo) {
164
+ return ((val - minFrom) / (maxFrom - minFrom)) * (maxTo - minTo) + minTo;
165
+ }
166
+ hashCode(str) {
167
+ let hash = 0;
168
+ if (str) {
169
+ const l = str.length;
170
+ for (let i = 0; i < l; i++) {
171
+ hash = (hash << 5) - hash + str.charCodeAt(i);
172
+ hash |= 0;
173
+ hash = this.xorshift(hash);
174
+ }
175
+ }
176
+ return this.getSafeSeed(hash);
177
+ }
178
+ getSafeSeed(seed) {
179
+ if (seed === 0)
180
+ return 1;
181
+ return seed;
182
+ }
183
+ }
184
+ Prando.MIN = -2147483648; // Int32 min
185
+ Prando.MAX = 2147483647; // Int32 max
186
+ const Prando$1 = Prando;
187
+
188
+ const COLORS = ['red', 'orange', 'yellow', 'green', 'blue', 'purple'];
189
+ const GRADIENTS = {
190
+ red: ['#FF4270', '#FF7C7C'],
191
+ orange: ['#F45532', '#FF9B63'],
192
+ yellow: ['#FFA756', '#FBFF47'],
193
+ green: ['#0CAE60', '#7BFFD0'],
194
+ blue: ['#476FFF', '#47C8FF'],
195
+ purple: ['#9747FF', '#DA47FF'],
196
+ };
197
+ function getPseudoRandomBackground(seed) {
198
+ const rng = new Prando$1(seed);
199
+ const [start, stop] = GRADIENTS[COLORS[rng.nextInt(0, COLORS.length - 1)]];
200
+ return `linear-gradient(136deg, ${start} 6.86%, ${stop} 93.78%)`;
201
+ }
202
+
203
+ export { COLORS as C, Prando$1 as P, getPseudoRandomBackground as g };
204
+
205
+ //# sourceMappingURL=prand-c8323494.js.map
@@ -0,0 +1 @@
1
+ {"file":"prand-c8323494.js","mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAqB,MAAM;;;;;;;;IAezB,YAAY,IAAsB;QAV1B,WAAM,GAAG,GAAG,CAAC;QAWnB,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;;YAE5B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;SAClC;aAAM,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;;YAEnC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;SACrC;aAAM;;YAEL,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;SACnG;QACD,IAAI,CAAC,KAAK,EAAE,CAAC;KACd;;;;;;;;;;IAYM,IAAI,CAAC,GAAG,GAAG,CAAC,EAAE,SAAS,GAAG,CAAC;QAChC,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;KACtE;;;;;;;;IASM,OAAO,CAAC,GAAG,GAAG,EAAE,EAAE,GAAG,GAAG,GAAG;QAChC,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CA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IAC9B,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,KAAK,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;IAC7B,IAAI,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;IAC5B,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;CAC/B,CAAC;SAEc,yBAAyB,CAAC,IAAY;IACpD,MAAM,GAAG,GAAG,IAAIA,QAAM,CAAC,IAAI,CAAC,CAAC;IAE7B,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAE3E,OAAO,2BAA2B,KAAK,WAAW,IAAI,UAAU,CAAC;AACnE;;;;","names":["Prando"],"sources":["src/lib/prando.ts","src/utils/prand.ts"],"sourcesContent":["/*\n * This file contains code from prando, which is licensed under the MIT License:\n *\n * Copyright (c) 2016 Zeh Fernando\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nexport default class Prando {\n private static readonly MIN: number = -2147483648; // Int32 min\n private static readonly MAX: number = 2147483647; // Int32 max\n\n private _seed: number;\n private _value = NaN;\n\n // ================================================================================================================\n // CONSTRUCTOR ----------------------------------------------------------------------------------------------------\n\n /**\n * Generate a new Prando pseudo-random number generator.\n *\n * @param seed - A number or string seed that determines which pseudo-random number sequence will be created. Defaults to a random seed based on `Math.random()`.\n */\n constructor(seed?: number | string) {\n if (typeof seed === 'string') {\n // String seed\n this._seed = this.hashCode(seed);\n } else if (typeof seed === 'number') {\n // Numeric seed\n this._seed = this.getSafeSeed(seed);\n } else {\n // Pseudo-random seed\n this._seed = this.getSafeSeed(Prando.MIN + Math.floor((Prando.MAX - Prando.MIN) * Math.random()));\n }\n this.reset();\n }\n\n // ================================================================================================================\n // PUBLIC INTERFACE -----------------------------------------------------------------------------------------------\n\n /**\n * Generates a pseudo-random number between a lower (inclusive) and a higher (exclusive) bounds.\n *\n * @param min - The minimum number that can be randomly generated.\n * @param pseudoMax - The maximum number that can be randomly generated (exclusive).\n * @return The generated pseudo-random number.\n */\n public next(min = 0, pseudoMax = 1): number {\n this.recalculate();\n return this.map(this._value, Prando.MIN, Prando.MAX, min, pseudoMax);\n }\n\n /**\n * Generates a pseudo-random integer number in a range (inclusive).\n *\n * @param min - The minimum number that can be randomly generated.\n * @param max - The maximum number that can be randomly generated.\n * @return The generated pseudo-random number.\n */\n public nextInt(min = 10, max = 100): number {\n this.recalculate();\n return Math.floor(this.map(this._value, Prando.MIN, Prando.MAX, min, max + 1));\n }\n\n /**\n * Generates a pseudo-random string sequence of a particular length from a specific character range.\n *\n * Note: keep in mind that creating a random string sequence does not guarantee uniqueness; there is always a\n * 1 in (char_length^string_length) chance of collision. For real unique string ids, always check for\n * pre-existing ids, or employ a robust GUID/UUID generator.\n *\n * @param length - Length of the string to be generated.\n * @param chars - Characters that are used when creating the random string. Defaults to all alphanumeric chars (A-Z, a-z, 0-9).\n * @return The generated string sequence.\n */\n public nextString(length = 16, chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'): string {\n let str = '';\n while (str.length < length) {\n str += this.nextChar(chars);\n }\n return str;\n }\n\n /**\n * Generates a pseudo-random string of 1 character specific character range.\n *\n * @param chars - Characters that are used when creating the random string. Defaults to all alphanumeric chars (A-Z, a-z, 0-9).\n * @return The generated character.\n */\n public nextChar(chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'): string {\n return chars.substr(this.nextInt(0, chars.length - 1), 1);\n }\n\n /**\n * Picks a pseudo-random item from an array. The array is left unmodified.\n *\n * Note: keep in mind that while the returned item will be random enough, picking one item from the array at a time\n * does not guarantee nor imply that a sequence of random non-repeating items will be picked. If you want to\n * *pick items in a random order* from an array, instead of *pick one random item from an array*, it's best to\n * apply a *shuffle* transformation to the array instead, then read it linearly.\n *\n * @param array - Array of any type containing one or more candidates for random picking.\n * @return An item from the array.\n */\n public nextArrayItem<T>(array: T[]): T {\n return array[this.nextInt(0, array.length - 1)];\n }\n\n /**\n * Generates a pseudo-random boolean.\n *\n * @return A value of true or false.\n */\n public nextBoolean(): boolean {\n this.recalculate();\n return this._value > 0.5;\n }\n\n /**\n * Skips ahead in the sequence of numbers that are being generated. This is equivalent to\n * calling next() a specified number of times, but faster since it doesn't need to map the\n * new random numbers to a range and return it.\n *\n * @param iterations - The number of items to skip ahead.\n */\n public skip(iterations = 1): void {\n while (iterations-- > 0) {\n this.recalculate();\n }\n }\n\n /**\n * Reset the pseudo-random number sequence back to its starting seed. Further calls to next()\n * will then produce the same sequence of numbers it had produced before. This is equivalent to\n * creating a new Prando instance with the same seed as another Prando instance.\n *\n * Example:\n * let rng = new Prando(12345678);\n * console.log(rng.next()); // 0.6177754114889017\n * console.log(rng.next()); // 0.5784605181725837\n * rng.reset();\n * console.log(rng.next()); // 0.6177754114889017 again\n * console.log(rng.next()); // 0.5784605181725837 again\n */\n public reset(): void {\n this._value = this._seed;\n }\n\n // ================================================================================================================\n // PRIVATE INTERFACE ----------------------------------------------------------------------------------------------\n\n private recalculate(): void {\n this._value = this.xorshift(this._value);\n }\n\n private xorshift(value: number): number {\n // Xorshift*32\n // Based on George Marsaglia's work: http://www.jstatsoft.org/v08/i14/paper\n value ^= value << 13;\n value ^= value >> 17;\n value ^= value << 5;\n return value;\n }\n\n private map(val: number, minFrom: number, maxFrom: number, minTo: number, maxTo: number): number {\n return ((val - minFrom) / (maxFrom - minFrom)) * (maxTo - minTo) + minTo;\n }\n\n private hashCode(str: string): number {\n let hash = 0;\n if (str) {\n const l = str.length;\n for (let i = 0; i < l; i++) {\n hash = (hash << 5) - hash + str.charCodeAt(i);\n hash |= 0;\n hash = this.xorshift(hash);\n }\n }\n return this.getSafeSeed(hash);\n }\n\n private getSafeSeed(seed: number): number {\n if (seed === 0) return 1;\n return seed;\n }\n}\n","import Prando from '../lib/prando';\n\nexport type Color = 'red' | 'orange' | 'yellow' | 'green' | 'blue' | 'purple';\n\nexport const COLORS: Color[] = ['red', 'orange', 'yellow', 'green', 'blue', 'purple'];\n\nconst GRADIENTS = {\n red: ['#FF4270', '#FF7C7C'],\n orange: ['#F45532', '#FF9B63'],\n yellow: ['#FFA756', '#FBFF47'],\n green: ['#0CAE60', '#7BFFD0'],\n blue: ['#476FFF', '#47C8FF'],\n purple: ['#9747FF', '#DA47FF'],\n};\n\nexport function getPseudoRandomBackground(seed: string): string {\n const rng = new Prando(seed);\n\n const [start, stop] = GRADIENTS[COLORS[rng.nextInt(0, COLORS.length - 1)]];\n\n return `linear-gradient(136deg, ${start} 6.86%, ${stop} 93.78%)`;\n}\n"],"version":3}
@@ -14,6 +14,7 @@ export declare const Icons: {
14
14
  capsuleRingsDark: string;
15
15
  capsuleRings: string;
16
16
  capsule: string;
17
+ checkCircleFilled: string;
17
18
  checkCircle: string;
18
19
  check: string;
19
20
  chevronUp: string;
@@ -22,6 +23,7 @@ export declare const Icons: {
22
23
  clubhouseBrand: string;
23
24
  clubhouse: string;
24
25
  copy: string;
26
+ cosmos: string;
25
27
  creditCard: string;
26
28
  cube: string;
27
29
  decentBrand: string;
@@ -34,6 +36,7 @@ export declare const Icons: {
34
36
  dribbbleBrand: string;
35
37
  dribbble: string;
36
38
  earth: string;
39
+ ethereum: string;
37
40
  eyeOff: string;
38
41
  eye: string;
39
42
  facebookBrand: string;
@@ -97,6 +100,7 @@ export declare const Icons: {
97
100
  signal: string;
98
101
  snapchatBrand: string;
99
102
  snapchat: string;
103
+ solana: string;
100
104
  stars: string;
101
105
  stripeBrand: string;
102
106
  telegramBrand: string;
@@ -1,9 +1,10 @@
1
1
  export declare class CpslIdenticon {
2
- hash: string;
2
+ hash?: string | undefined;
3
3
  /**
4
- * The size of the identicon.
5
- * Default is: 40.
4
+ * The CSS width and height of the identicon.
5
+ * Default is: 40px.
6
6
  */
7
- size: number;
7
+ size: string;
8
+ variant: 'default' | 'avatar';
8
9
  render(): any;
9
10
  }
@@ -1,5 +1,5 @@
1
1
  import { EventEmitter } from '../../stencil-public-runtime';
2
- import { TabClickEventDetail } from './tab-interface';
2
+ import { TabClickEventDetail, TabSizeChangeEventDetail } from './tab-interface';
3
3
  import { TabsChangedEventDetail } from '../cpsl-tabs/tabs-interface';
4
4
  export declare class CpslTab {
5
5
  el: HTMLCpslTabElement;
@@ -17,8 +17,14 @@ export declare class CpslTab {
17
17
  * @internal
18
18
  */
19
19
  cpslTabButtonClick: EventEmitter<TabClickEventDetail>;
20
+ /**
21
+ * Emitted when tab size changes
22
+ * @internal
23
+ */
24
+ cpslTabButtonSizeChange: EventEmitter<TabSizeChangeEventDetail>;
20
25
  onTabsChanged(ev: CustomEvent<TabsChangedEventDetail>): void;
21
26
  onTabsInit(ev: CustomEvent<TabsChangedEventDetail>): void;
27
+ componentDidLoad(): void;
22
28
  private setSelected;
23
29
  private onTabClicked;
24
30
  render(): any;
@@ -2,3 +2,6 @@ export interface TabClickEventDetail {
2
2
  tab: string;
3
3
  selected: boolean;
4
4
  }
5
+ export interface TabSizeChangeEventDetail {
6
+ tab: string;
7
+ }
@@ -1,4 +1,5 @@
1
1
  import { EventEmitter } from '../../stencil-public-runtime';
2
+ import { TabSizeChangeEventDetail } from '../cpsl-tab/tab-interface';
2
3
  import { TabsChangedEventDetail } from './tabs-interface';
3
4
  export declare class CpslTabs {
4
5
  el: HTMLCpslTabsElement;
@@ -23,6 +24,7 @@ export declare class CpslTabs {
23
24
  cpslTabsInit: EventEmitter<TabsChangedEventDetail>;
24
25
  updateSlider(): void;
25
26
  updateTab(newValue?: string, oldValue?: string): void;
27
+ onTabSizeChange(ev: CustomEvent<TabSizeChangeEventDetail>): void;
26
28
  componentWillLoad(): void;
27
29
  componentDidLoad(): void;
28
30
  private get tabs();
@@ -9,13 +9,13 @@ import { AutocompleteTypes, IconType, TextFieldTypes } from "./interface";
9
9
  import { CodeChangeEventDetail } from "./components/cpsl-code-input/code-change-interface";
10
10
  import { DropdownInputEventDetail } from "./components/cpsl-dropdown/dropdown-interface";
11
11
  import { InputChangeEventDetail, InputInputEventDetail } from "./components/cpsl-input/input-interface";
12
- import { TabClickEventDetail } from "./components/cpsl-tab/tab-interface";
12
+ import { TabClickEventDetail, TabSizeChangeEventDetail } from "./components/cpsl-tab/tab-interface";
13
13
  import { TabsChangedEventDetail } from "./components/cpsl-tabs/tabs-interface";
14
14
  export { AutocompleteTypes, IconType, TextFieldTypes } from "./interface";
15
15
  export { CodeChangeEventDetail } from "./components/cpsl-code-input/code-change-interface";
16
16
  export { DropdownInputEventDetail } from "./components/cpsl-dropdown/dropdown-interface";
17
17
  export { InputChangeEventDetail, InputInputEventDetail } from "./components/cpsl-input/input-interface";
18
- export { TabClickEventDetail } from "./components/cpsl-tab/tab-interface";
18
+ export { TabClickEventDetail, TabSizeChangeEventDetail } from "./components/cpsl-tab/tab-interface";
19
19
  export { TabsChangedEventDetail } from "./components/cpsl-tabs/tabs-interface";
20
20
  export namespace Components {
21
21
  interface CpslAlert {
@@ -389,11 +389,12 @@ export namespace Components {
389
389
  "icons": (IconType | string)[];
390
390
  }
391
391
  interface CpslIdenticon {
392
- "hash": string;
392
+ "hash"?: string | undefined;
393
393
  /**
394
- * The size of the identicon. Default is: 40.
394
+ * The CSS width and height of the identicon. Default is: 40px.
395
395
  */
396
- "size": number;
396
+ "size": string;
397
+ "variant": 'default' | 'avatar';
397
398
  }
398
399
  interface CpslInfoBox {
399
400
  }
@@ -1332,6 +1333,7 @@ declare global {
1332
1333
  };
1333
1334
  interface HTMLCpslTabElementEventMap {
1334
1335
  "cpslTabButtonClick": TabClickEventDetail;
1336
+ "cpslTabButtonSizeChange": TabSizeChangeEventDetail;
1335
1337
  }
1336
1338
  interface HTMLCpslTabElement extends Components.CpslTab, HTMLStencilElement {
1337
1339
  addEventListener<K extends keyof HTMLCpslTabElementEventMap>(type: K, listener: (this: HTMLCpslTabElement, ev: CpslTabCustomEvent<HTMLCpslTabElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
@@ -1852,11 +1854,12 @@ declare namespace LocalJSX {
1852
1854
  "icons"?: (IconType | string)[];
1853
1855
  }
1854
1856
  interface CpslIdenticon {
1855
- "hash"?: string;
1857
+ "hash"?: string | undefined;
1856
1858
  /**
1857
- * The size of the identicon. Default is: 40.
1859
+ * The CSS width and height of the identicon. Default is: 40px.
1858
1860
  */
1859
- "size"?: number;
1861
+ "size"?: string;
1862
+ "variant"?: 'default' | 'avatar';
1860
1863
  }
1861
1864
  interface CpslInfoBox {
1862
1865
  }
@@ -1,3 +1,4 @@
1
1
  export * from './components';
2
2
  export { generateTheme } from './utils/theme/generateTheme';
3
3
  export type { Theme, BorderRadius, IconType } from './interface';
4
+ export { getPseudoRandomBackground } from './utils/prand';
@@ -0,0 +1,92 @@
1
+ export default class Prando {
2
+ private static readonly MIN;
3
+ private static readonly MAX;
4
+ private _seed;
5
+ private _value;
6
+ /**
7
+ * Generate a new Prando pseudo-random number generator.
8
+ *
9
+ * @param seed - A number or string seed that determines which pseudo-random number sequence will be created. Defaults to a random seed based on `Math.random()`.
10
+ */
11
+ constructor(seed?: number | string);
12
+ /**
13
+ * Generates a pseudo-random number between a lower (inclusive) and a higher (exclusive) bounds.
14
+ *
15
+ * @param min - The minimum number that can be randomly generated.
16
+ * @param pseudoMax - The maximum number that can be randomly generated (exclusive).
17
+ * @return The generated pseudo-random number.
18
+ */
19
+ next(min?: number, pseudoMax?: number): number;
20
+ /**
21
+ * Generates a pseudo-random integer number in a range (inclusive).
22
+ *
23
+ * @param min - The minimum number that can be randomly generated.
24
+ * @param max - The maximum number that can be randomly generated.
25
+ * @return The generated pseudo-random number.
26
+ */
27
+ nextInt(min?: number, max?: number): number;
28
+ /**
29
+ * Generates a pseudo-random string sequence of a particular length from a specific character range.
30
+ *
31
+ * Note: keep in mind that creating a random string sequence does not guarantee uniqueness; there is always a
32
+ * 1 in (char_length^string_length) chance of collision. For real unique string ids, always check for
33
+ * pre-existing ids, or employ a robust GUID/UUID generator.
34
+ *
35
+ * @param length - Length of the string to be generated.
36
+ * @param chars - Characters that are used when creating the random string. Defaults to all alphanumeric chars (A-Z, a-z, 0-9).
37
+ * @return The generated string sequence.
38
+ */
39
+ nextString(length?: number, chars?: string): string;
40
+ /**
41
+ * Generates a pseudo-random string of 1 character specific character range.
42
+ *
43
+ * @param chars - Characters that are used when creating the random string. Defaults to all alphanumeric chars (A-Z, a-z, 0-9).
44
+ * @return The generated character.
45
+ */
46
+ nextChar(chars?: string): string;
47
+ /**
48
+ * Picks a pseudo-random item from an array. The array is left unmodified.
49
+ *
50
+ * Note: keep in mind that while the returned item will be random enough, picking one item from the array at a time
51
+ * does not guarantee nor imply that a sequence of random non-repeating items will be picked. If you want to
52
+ * *pick items in a random order* from an array, instead of *pick one random item from an array*, it's best to
53
+ * apply a *shuffle* transformation to the array instead, then read it linearly.
54
+ *
55
+ * @param array - Array of any type containing one or more candidates for random picking.
56
+ * @return An item from the array.
57
+ */
58
+ nextArrayItem<T>(array: T[]): T;
59
+ /**
60
+ * Generates a pseudo-random boolean.
61
+ *
62
+ * @return A value of true or false.
63
+ */
64
+ nextBoolean(): boolean;
65
+ /**
66
+ * Skips ahead in the sequence of numbers that are being generated. This is equivalent to
67
+ * calling next() a specified number of times, but faster since it doesn't need to map the
68
+ * new random numbers to a range and return it.
69
+ *
70
+ * @param iterations - The number of items to skip ahead.
71
+ */
72
+ skip(iterations?: number): void;
73
+ /**
74
+ * Reset the pseudo-random number sequence back to its starting seed. Further calls to next()
75
+ * will then produce the same sequence of numbers it had produced before. This is equivalent to
76
+ * creating a new Prando instance with the same seed as another Prando instance.
77
+ *
78
+ * Example:
79
+ * let rng = new Prando(12345678);
80
+ * console.log(rng.next()); // 0.6177754114889017
81
+ * console.log(rng.next()); // 0.5784605181725837
82
+ * rng.reset();
83
+ * console.log(rng.next()); // 0.6177754114889017 again
84
+ * console.log(rng.next()); // 0.5784605181725837 again
85
+ */
86
+ reset(): void;
87
+ private recalculate;
88
+ private xorshift;
89
+ private map;
90
+ private hashCode;
91
+ private getSafeSeed;
92
+ }
@@ -0,0 +1,3 @@
1
+ export type Color = 'red' | 'orange' | 'yellow' | 'green' | 'blue' | 'purple';
2
+ export declare const COLORS: Color[];
3
+ export declare function getPseudoRandomBackground(seed: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usecapsule/core-components",
3
- "version": "3.4.1",
3
+ "version": "3.5.0",
4
4
  "description": "Capsule Core Components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",
@@ -18,8 +18,8 @@
18
18
  "scripts": {
19
19
  "build": "yarn build:assets && yarn build:css && stencil build",
20
20
  "start": "yarn build:assets && yarn build:css && stencil build --dev --watch --serve",
21
- "test": "stencil test --spec --e2e",
22
- "test.watch": "stencil test --spec --e2e --watchAll",
21
+ "test": "stencil test --spec",
22
+ "test.watch": "stencil test --spec --watchAll",
23
23
  "generate": "stencil generate",
24
24
  "build:css": "sass --embed-sources src/css:./css",
25
25
  "build:assets": "ts-node -T ./scripts/buildAssets.ts",
@@ -60,5 +60,5 @@
60
60
  "storybook-addon-stencil": "^0.2.1",
61
61
  "ts-node": "^10.9.2"
62
62
  },
63
- "gitHead": "e360ffa87553d566b73df627fbcc114e6e737391"
63
+ "gitHead": "6ba94d306d6770db6cfe9b3feb0de84d94c3b26e"
64
64
  }
@@ -1,2 +0,0 @@
1
- import{r as t,h as e,H as o}from"./p-fa6b7678.js";const r=":host{--identicon-background-red:linear-gradient(136deg, #FF4270 6.86%, #FF7C7C 93.78%);--identicon-background-orange:linear-gradient(136deg, #F45532 6.86%, #FF9B63 93.78%);--identicon-background-yellow:linear-gradient(136deg, #FFA756 6.86%, #FBFF47 93.78%);--identicon-background-green:linear-gradient(136deg, #0CAE60 6.86%, #7BFFD0 93.78%);--identicon-background-blue:linear-gradient(136deg, #476FFF 6.86%, #47C8FF 93.78%);--identicon-background-purple:linear-gradient(136deg, #9747FF 6.86%, #DA47FF 93.78%);display:block;width:62px;height:62px;aspect-ratio:1;border-radius:6px;position:relative;border:1px solid var(--cpsl-color-background-8)}:host>svg{fill:rgba(255, 255, 255, 0.6);position:absolute;width:35%}:host>svg.rotate90{transform:rotate(0.25turn)}:host>svg.rotate180{transform:rotate(0.5turn)}:host>svg.rotate270{transform:rotate(0.75turn)}:host>svg:nth-child(1){right:50%;bottom:50%}:host>svg:nth-child(2){left:50%;bottom:50%}:host>svg:nth-child(3){right:50%;top:50%}:host>svg:nth-child(4){left:50%;top:50%}:host(.red){background:var(--identicon-background-red)}:host(.orange){background:var(--identicon-background-orange)}:host(.green){background:var(--identicon-background-green)}:host(.yellow){background:var(--identicon-background-yellow)}:host(.blue){background:var(--identicon-background-blue)}:host(.purple){background:var(--identicon-background-purple)}";const n=r;const d=t=>e("svg",{class:{rotate90:t===1,rotate180:t===2,rotate270:t===3},viewBox:"0 0 12 12",xmlns:"http://www.w3.org/2000/svg"},e("g",{"clip-path":"url(#clip0_674_66)"},e("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M12 24C18.6274 24 24 18.6274 24 12C24 5.37258 18.6274 0 12 0C5.37258 0 0 5.37258 0 12C0 18.6274 5.37258 24 12 24ZM12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21Z"})),e("defs",null,e("clipPath",{id:"clip0_674_66"},e("rect",{width:"12",height:"12"}))));const i=t=>e("svg",{class:{rotate90:t===1,rotate180:t===2,rotate270:t===3},viewBox:"0 0 12 12",xmlns:"http://www.w3.org/2000/svg"},e("g",{"clip-path":"url(#clip0_674_255)"},e("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M12 24C18.6274 24 24 18.6274 24 12C24 5.37258 18.6274 0 12 0C5.37258 0 0 5.37258 0 12C0 18.6274 5.37258 24 12 24ZM12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21Z"}),e("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M12 18C15.3137 18 18 15.3137 18 12C18 8.68629 15.3137 6 12 6C8.68629 6 6 8.68629 6 12C6 15.3137 8.68629 18 12 18ZM12 15C13.6569 15 15 13.6569 15 12C15 10.3431 13.6569 9 12 9C10.3431 9 9 10.3431 9 12C9 13.6569 10.3431 15 12 15Z"})),e("defs",null,e("clipPath",{id:"clip0_674_255"},e("rect",{width:"12",height:"12"}))));const a=class{constructor(e){t(this,e);this.hash=undefined;this.size=40}render(){const[t,r]=l(this.hash);const n=(t>>2&1)!==0;const a=(t>>3&1)!==0;const c=(t>>4&1)!==0;const s=(t>>5&1)!==0;const g=t>>6&3;const u=t>>7&3;const h=t>>8&3;const p=t>>9&3;const[b,v]=[[n,a,c,s],[g,u,h,p]];return e(o,{key:"39bcae00e3fd58ff94639fbb43c77fd942899e51",class:{red:r==="red",orange:r==="orange",yellow:r==="yellow",green:r==="green",blue:r==="blue",purple:r==="purple"}},b.map(((t,e)=>t?i(v[e]):d(v[e]))))}};const c=["red","orange","yellow","green","blue","purple"];function l(t){const e=t.charCodeAt(0)<<24|t.charCodeAt(1)<<16|t.charCodeAt(2)<<8|t.charCodeAt(3);const o=c[Math.abs(e%6)];return[e,o]}a.style=n;export{a as cpsl_identicon};
2
- //# sourceMappingURL=p-5d62e610.entry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["cpslIdenticonCss","CpslIdenticonStyle0","SingleArc","rotation","h","class","rotate90","rotate180","rotate270","viewBox","xmlns","d","id","width","height","DoubleArc","CpslIdenticon","render","code","color","stringToBinaryAndColor","this","hash","shapeA","shapeB","shapeC","shapeD","rotationA","rotationB","rotationC","rotationD","shapes","rotations","Host","key","red","orange","yellow","green","blue","purple","map","isDouble","index","COLORS","charCodeAt","Math","abs"],"sources":["src/components/cpsl-identicon/cpsl-identicon.scss?tag=cpsl-identicon&encapsulation=shadow","src/components/cpsl-identicon/cpsl-identicon.tsx"],"sourcesContent":[":host {\n --identicon-background-red: linear-gradient(136deg, #FF4270 6.86%, #FF7C7C 93.78%);\n --identicon-background-orange: linear-gradient(136deg, #F45532 6.86%, #FF9B63 93.78%);\n --identicon-background-yellow: linear-gradient(136deg, #FFA756 6.86%, #FBFF47 93.78%);\n --identicon-background-green: linear-gradient(136deg, #0CAE60 6.86%, #7BFFD0 93.78%);\n --identicon-background-blue: linear-gradient(136deg, #476FFF 6.86%, #47C8FF 93.78%);\n --identicon-background-purple: linear-gradient(136deg, #9747FF 6.86%, #DA47FF 93.78%);\n\n display: block;\n width: 62px;\n height: 62px;\n aspect-ratio: 1;\n border-radius: 6px;\n position: relative;\n border: 1px solid var(--cpsl-color-background-8);\n\n & > svg {\n fill: rgba(255, 255, 255, 0.6);\n position: absolute;\n width: 35%;\n }\n\n & > svg.rotate90 {\n transform: rotate(.25turn);\n }\n\n & > svg.rotate180 {\n transform: rotate(.5turn);\n }\n\n & > svg.rotate270 {\n transform: rotate(.75turn);\n }\n\n & > svg:nth-child(1) {\n right: 50%;\n bottom: 50%;\n }\n\n & > svg:nth-child(2) {\n left: 50%;\n bottom: 50%;\n }\n\n & > svg:nth-child(3) {\n right: 50%;\n top: 50%;\n }\n\n & > svg:nth-child(4) {\n left: 50%;\n top: 50%;\n }\n}\n\n:host(.red) {\n background: var(--identicon-background-red);\n}\n\n:host(.orange) {\n background: var(--identicon-background-orange);\n}\n\n:host(.green) {\n background: var(--identicon-background-green);\n}\n\n:host(.yellow) {\n background: var(--identicon-background-yellow);\n}\n\n:host(.blue) {\n background: var(--identicon-background-blue);\n}\n\n:host(.purple) {\n background: var(--identicon-background-purple);\n}\n","import { Component, Host, Prop, h } from '@stencil/core';\n\nconst SingleArc = (rotation: number) => (\n <svg\n class={{\n rotate90: rotation === 1,\n rotate180: rotation === 2,\n rotate270: rotation === 3,\n }}\n viewBox=\"0 0 12 12\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <g clip-path=\"url(#clip0_674_66)\">\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M12 24C18.6274 24 24 18.6274 24 12C24 5.37258 18.6274 0 12 0C5.37258 0 0 5.37258 0 12C0 18.6274 5.37258 24 12 24ZM12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21Z\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_674_66\">\n <rect width=\"12\" height=\"12\" />\n </clipPath>\n </defs>\n </svg>\n);\n\nconst DoubleArc = (rotation: number) => (\n <svg\n class={{\n rotate90: rotation === 1,\n rotate180: rotation === 2,\n rotate270: rotation === 3,\n }}\n viewBox=\"0 0 12 12\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <g clip-path=\"url(#clip0_674_255)\">\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M12 24C18.6274 24 24 18.6274 24 12C24 5.37258 18.6274 0 12 0C5.37258 0 0 5.37258 0 12C0 18.6274 5.37258 24 12 24ZM12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21Z\"\n />\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M12 18C15.3137 18 18 15.3137 18 12C18 8.68629 15.3137 6 12 6C8.68629 6 6 8.68629 6 12C6 15.3137 8.68629 18 12 18ZM12 15C13.6569 15 15 13.6569 15 12C15 10.3431 13.6569 9 12 9C10.3431 9 9 10.3431 9 12C9 13.6569 10.3431 15 12 15Z\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_674_255\">\n <rect width=\"12\" height=\"12\" />\n </clipPath>\n </defs>\n </svg>\n);\n\n@Component({\n tag: 'cpsl-identicon',\n styleUrl: 'cpsl-identicon.scss',\n shadow: true,\n})\nexport class CpslIdenticon {\n @Prop() hash: string;\n\n /**\n * The size of the identicon.\n * Default is: 40.\n */\n @Prop() size: number = 40;\n\n render() {\n const [code, color] = stringToBinaryAndColor(this.hash);\n const shapeA = ((code >> 2) & 1) !== 0;\n const shapeB = ((code >> 3) & 1) !== 0;\n const shapeC = ((code >> 4) & 1) !== 0;\n const shapeD = ((code >> 5) & 1) !== 0;\n const rotationA = (code >> 6) & 3;\n const rotationB = (code >> 7) & 3;\n const rotationC = (code >> 8) & 3;\n const rotationD = (code >> 9) & 3;\n\n const [shapes, rotations] = [\n [shapeA, shapeB, shapeC, shapeD],\n [rotationA, rotationB, rotationC, rotationD],\n ];\n\n return (\n <Host\n class={{\n red: color === 'red',\n orange: color === 'orange',\n yellow: color === 'yellow',\n green: color === 'green',\n blue: color === 'blue',\n purple: color === 'purple',\n }}\n >\n {shapes.map((isDouble, index) => {\n return isDouble ? DoubleArc(rotations[index]) : SingleArc(rotations[index]);\n })}\n </Host>\n );\n }\n}\n\ntype Color = 'red' | 'orange' | 'yellow' | 'green' | 'blue' | 'purple';\n\nconst COLORS: Color[] = ['red', 'orange', 'yellow', 'green', 'blue', 'purple'];\n\nfunction stringToBinaryAndColor(hash: string): [number, Color] {\n const code = (hash.charCodeAt(0) << 24) | (hash.charCodeAt(1) << 16) | (hash.charCodeAt(2) << 8) | hash.charCodeAt(3);\n\n const color = COLORS[Math.abs(code % 6)];\n\n return [code, color];\n}\n"],"mappings":"kDAAA,MAAMA,EAAmB,k2CACzB,MAAAC,EAAeD,ECCf,MAAME,EAAaC,GACjBC,EAAA,OACEC,MAAO,CACLC,SAAUH,IAAa,EACvBI,UAAWJ,IAAa,EACxBK,UAAWL,IAAa,GAE1BM,QAAQ,YACRC,MAAM,8BAENN,EAAA,iBAAa,sBACXA,EAAA,oBACY,UAAS,YACT,UACVO,EAAE,wOAGNP,EAAA,YACEA,EAAA,YAAUQ,GAAG,gBACXR,EAAA,QAAMS,MAAM,KAAKC,OAAO,UAMhC,MAAMC,EAAaZ,GACjBC,EAAA,OACEC,MAAO,CACLC,SAAUH,IAAa,EACvBI,UAAWJ,IAAa,EACxBK,UAAWL,IAAa,GAE1BM,QAAQ,YACRC,MAAM,8BAENN,EAAA,iBAAa,uBACXA,EAAA,oBACY,UAAS,YACT,UACVO,EAAE,uOAEJP,EAAA,oBACY,UAAS,YACT,UACVO,EAAE,wOAGNP,EAAA,YACEA,EAAA,YAAUQ,GAAG,iBACXR,EAAA,QAAMS,MAAM,KAAKC,OAAO,U,MAWnBE,EAAa,M,uDAOD,E,CAEvB,MAAAC,GACE,MAAOC,EAAMC,GAASC,EAAuBC,KAAKC,MAClD,MAAMC,GAAWL,GAAQ,EAAK,KAAO,EACrC,MAAMM,GAAWN,GAAQ,EAAK,KAAO,EACrC,MAAMO,GAAWP,GAAQ,EAAK,KAAO,EACrC,MAAMQ,GAAWR,GAAQ,EAAK,KAAO,EACrC,MAAMS,EAAaT,GAAQ,EAAK,EAChC,MAAMU,EAAaV,GAAQ,EAAK,EAChC,MAAMW,EAAaX,GAAQ,EAAK,EAChC,MAAMY,EAAa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