1 | function _typeof(obj) {
|
2 | if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
3 | _typeof = function (obj) {
|
4 | return typeof obj;
|
5 | };
|
6 | } else {
|
7 | _typeof = function (obj) {
|
8 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
9 | };
|
10 | }
|
11 |
|
12 | return _typeof(obj);
|
13 | }
|
14 |
|
15 | function _classCallCheck(instance, Constructor) {
|
16 | if (!(instance instanceof Constructor)) {
|
17 | throw new TypeError("Cannot call a class as a function");
|
18 | }
|
19 | }
|
20 |
|
21 | function _defineProperties(target, props) {
|
22 | for (var i = 0; i < props.length; i++) {
|
23 | var descriptor = props[i];
|
24 | descriptor.enumerable = descriptor.enumerable || false;
|
25 | descriptor.configurable = true;
|
26 | if ("value" in descriptor) descriptor.writable = true;
|
27 | Object.defineProperty(target, descriptor.key, descriptor);
|
28 | }
|
29 | }
|
30 |
|
31 | function _createClass(Constructor, protoProps, staticProps) {
|
32 | if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
33 | if (staticProps) _defineProperties(Constructor, staticProps);
|
34 | return Constructor;
|
35 | }
|
36 |
|
37 | function _defineProperty(obj, key, value) {
|
38 | if (key in obj) {
|
39 | Object.defineProperty(obj, key, {
|
40 | value: value,
|
41 | enumerable: true,
|
42 | configurable: true,
|
43 | writable: true
|
44 | });
|
45 | } else {
|
46 | obj[key] = value;
|
47 | }
|
48 |
|
49 | return obj;
|
50 | }
|
51 |
|
52 | function _objectSpread(target) {
|
53 | for (var i = 1; i < arguments.length; i++) {
|
54 | var source = arguments[i] != null ? arguments[i] : {};
|
55 | var ownKeys = Object.keys(source);
|
56 |
|
57 | if (typeof Object.getOwnPropertySymbols === 'function') {
|
58 | ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
|
59 | return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
60 | }));
|
61 | }
|
62 |
|
63 | ownKeys.forEach(function (key) {
|
64 | _defineProperty(target, key, source[key]);
|
65 | });
|
66 | }
|
67 |
|
68 | return target;
|
69 | }
|
70 |
|
71 | function _slicedToArray(arr, i) {
|
72 | return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
|
73 | }
|
74 |
|
75 | function _toConsumableArray(arr) {
|
76 | return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
|
77 | }
|
78 |
|
79 | function _arrayWithoutHoles(arr) {
|
80 | if (Array.isArray(arr)) {
|
81 | for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
|
82 |
|
83 | return arr2;
|
84 | }
|
85 | }
|
86 |
|
87 | function _arrayWithHoles(arr) {
|
88 | if (Array.isArray(arr)) return arr;
|
89 | }
|
90 |
|
91 | function _iterableToArray(iter) {
|
92 | if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
|
93 | }
|
94 |
|
95 | function _iterableToArrayLimit(arr, i) {
|
96 | var _arr = [];
|
97 | var _n = true;
|
98 | var _d = false;
|
99 | var _e = undefined;
|
100 |
|
101 | try {
|
102 | for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
103 | _arr.push(_s.value);
|
104 |
|
105 | if (i && _arr.length === i) break;
|
106 | }
|
107 | } catch (err) {
|
108 | _d = true;
|
109 | _e = err;
|
110 | } finally {
|
111 | try {
|
112 | if (!_n && _i["return"] != null) _i["return"]();
|
113 | } finally {
|
114 | if (_d) throw _e;
|
115 | }
|
116 | }
|
117 |
|
118 | return _arr;
|
119 | }
|
120 |
|
121 | function _nonIterableSpread() {
|
122 | throw new TypeError("Invalid attempt to spread non-iterable instance");
|
123 | }
|
124 |
|
125 | function _nonIterableRest() {
|
126 | throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
127 | }
|
128 |
|
129 | var noop = function noop() {};
|
130 |
|
131 | var _WINDOW = {};
|
132 | var _DOCUMENT = {};
|
133 | var _MUTATION_OBSERVER = null;
|
134 | var _PERFORMANCE = {
|
135 | mark: noop,
|
136 | measure: noop
|
137 | };
|
138 |
|
139 | try {
|
140 | if (typeof window !== 'undefined') _WINDOW = window;
|
141 | if (typeof document !== 'undefined') _DOCUMENT = document;
|
142 | if (typeof MutationObserver !== 'undefined') _MUTATION_OBSERVER = MutationObserver;
|
143 | if (typeof performance !== 'undefined') _PERFORMANCE = performance;
|
144 | } catch (e) {}
|
145 |
|
146 | var _ref = _WINDOW.navigator || {},
|
147 | _ref$userAgent = _ref.userAgent,
|
148 | userAgent = _ref$userAgent === void 0 ? '' : _ref$userAgent;
|
149 |
|
150 | var WINDOW = _WINDOW;
|
151 | var DOCUMENT = _DOCUMENT;
|
152 | var MUTATION_OBSERVER = _MUTATION_OBSERVER;
|
153 | var PERFORMANCE = _PERFORMANCE;
|
154 | var IS_BROWSER = !!WINDOW.document;
|
155 | var IS_DOM = !!DOCUMENT.documentElement && !!DOCUMENT.head && typeof DOCUMENT.addEventListener === 'function' && typeof DOCUMENT.createElement === 'function';
|
156 | var IS_IE = ~userAgent.indexOf('MSIE') || ~userAgent.indexOf('Trident/');
|
157 |
|
158 | var NAMESPACE_IDENTIFIER = '___FONT_AWESOME___';
|
159 | var UNITS_IN_GRID = 16;
|
160 | var DEFAULT_FAMILY_PREFIX = 'fa';
|
161 | var DEFAULT_REPLACEMENT_CLASS = 'svg-inline--fa';
|
162 | var DATA_FA_I2SVG = 'data-fa-i2svg';
|
163 | var DATA_FA_PSEUDO_ELEMENT = 'data-fa-pseudo-element';
|
164 | var DATA_FA_PSEUDO_ELEMENT_PENDING = 'data-fa-pseudo-element-pending';
|
165 | var DATA_PREFIX = 'data-prefix';
|
166 | var DATA_ICON = 'data-icon';
|
167 | var HTML_CLASS_I2SVG_BASE_CLASS = 'fontawesome-i2svg';
|
168 | var MUTATION_APPROACH_ASYNC = 'async';
|
169 | var TAGNAMES_TO_SKIP_FOR_PSEUDOELEMENTS = ['HTML', 'HEAD', 'STYLE', 'SCRIPT'];
|
170 | var PRODUCTION = function () {
|
171 | try {
|
172 | return process.env.NODE_ENV === 'production';
|
173 | } catch (e) {
|
174 | return false;
|
175 | }
|
176 | }();
|
177 | var PREFIX_TO_STYLE = {
|
178 | 'fas': 'solid',
|
179 | 'far': 'regular',
|
180 | 'fal': 'light',
|
181 | 'fab': 'brands',
|
182 | 'fa': 'solid'
|
183 | };
|
184 | var STYLE_TO_PREFIX = {
|
185 | 'solid': 'fas',
|
186 | 'regular': 'far',
|
187 | 'light': 'fal',
|
188 | 'brands': 'fab'
|
189 | };
|
190 | var LAYERS_TEXT_CLASSNAME = 'fa-layers-text';
|
191 | var FONT_FAMILY_PATTERN = /Font Awesome 5 (Solid|Regular|Light|Brands|Free|Pro)/;
|
192 | var FONT_WEIGHT_TO_PREFIX = {
|
193 | '900': 'fas',
|
194 | '400': 'far',
|
195 | 'normal': 'far',
|
196 | '300': 'fal'
|
197 | };
|
198 | var oneToTen = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
199 | var oneToTwenty = oneToTen.concat([11, 12, 13, 14, 15, 16, 17, 18, 19, 20]);
|
200 | var ATTRIBUTES_WATCHED_FOR_MUTATION = ['class', 'data-prefix', 'data-icon', 'data-fa-transform', 'data-fa-mask'];
|
201 | var RESERVED_CLASSES = ['xs', 'sm', 'lg', 'fw', 'ul', 'li', 'border', 'pull-left', 'pull-right', 'spin', 'pulse', 'rotate-90', 'rotate-180', 'rotate-270', 'flip-horizontal', 'flip-vertical', 'flip-both', 'stack', 'stack-1x', 'stack-2x', 'inverse', 'layers', 'layers-text', 'layers-counter'].concat(oneToTen.map(function (n) {
|
202 | return "".concat(n, "x");
|
203 | })).concat(oneToTwenty.map(function (n) {
|
204 | return "w-".concat(n);
|
205 | }));
|
206 |
|
207 | var initial = WINDOW.FontAwesomeConfig || {};
|
208 |
|
209 | function getAttrConfig(attr) {
|
210 | var element = DOCUMENT.querySelector('script[' + attr + ']');
|
211 |
|
212 | if (element) {
|
213 | return element.getAttribute(attr);
|
214 | }
|
215 | }
|
216 |
|
217 | function coerce(val) {
|
218 |
|
219 |
|
220 |
|
221 | if (val === '') return true;
|
222 | if (val === 'false') return false;
|
223 | if (val === 'true') return true;
|
224 | return val;
|
225 | }
|
226 |
|
227 | if (DOCUMENT && typeof DOCUMENT.querySelector === 'function') {
|
228 | var attrs = [['data-family-prefix', 'familyPrefix'], ['data-replacement-class', 'replacementClass'], ['data-auto-replace-svg', 'autoReplaceSvg'], ['data-auto-add-css', 'autoAddCss'], ['data-auto-a11y', 'autoA11y'], ['data-search-pseudo-elements', 'searchPseudoElements'], ['data-observe-mutations', 'observeMutations'], ['data-mutate-approach', 'mutateApproach'], ['data-keep-original-source', 'keepOriginalSource'], ['data-measure-performance', 'measurePerformance'], ['data-show-missing-icons', 'showMissingIcons']];
|
229 | attrs.forEach(function (_ref) {
|
230 | var _ref2 = _slicedToArray(_ref, 2),
|
231 | attr = _ref2[0],
|
232 | key = _ref2[1];
|
233 |
|
234 | var val = coerce(getAttrConfig(attr));
|
235 |
|
236 | if (val !== undefined && val !== null) {
|
237 | initial[key] = val;
|
238 | }
|
239 | });
|
240 | }
|
241 |
|
242 | var _default = {
|
243 | familyPrefix: DEFAULT_FAMILY_PREFIX,
|
244 | replacementClass: DEFAULT_REPLACEMENT_CLASS,
|
245 | autoReplaceSvg: true,
|
246 | autoAddCss: true,
|
247 | autoA11y: true,
|
248 | searchPseudoElements: false,
|
249 | observeMutations: true,
|
250 | mutateApproach: 'async',
|
251 | keepOriginalSource: true,
|
252 | measurePerformance: false,
|
253 | showMissingIcons: true
|
254 | };
|
255 |
|
256 | var _config = _objectSpread({}, _default, initial);
|
257 |
|
258 | if (!_config.autoReplaceSvg) _config.observeMutations = false;
|
259 |
|
260 | var config = _objectSpread({}, _config);
|
261 |
|
262 | WINDOW.FontAwesomeConfig = config;
|
263 |
|
264 | var w = WINDOW || {};
|
265 | if (!w[NAMESPACE_IDENTIFIER]) w[NAMESPACE_IDENTIFIER] = {};
|
266 | if (!w[NAMESPACE_IDENTIFIER].styles) w[NAMESPACE_IDENTIFIER].styles = {};
|
267 | if (!w[NAMESPACE_IDENTIFIER].hooks) w[NAMESPACE_IDENTIFIER].hooks = {};
|
268 | if (!w[NAMESPACE_IDENTIFIER].shims) w[NAMESPACE_IDENTIFIER].shims = [];
|
269 | var namespace = w[NAMESPACE_IDENTIFIER];
|
270 |
|
271 | var functions = [];
|
272 |
|
273 | var listener = function listener() {
|
274 | DOCUMENT.removeEventListener('DOMContentLoaded', listener);
|
275 | loaded = 1;
|
276 | functions.map(function (fn) {
|
277 | return fn();
|
278 | });
|
279 | };
|
280 |
|
281 | var loaded = false;
|
282 |
|
283 | if (IS_DOM) {
|
284 | loaded = (DOCUMENT.documentElement.doScroll ? /^loaded|^c/ : /^loaded|^i|^c/).test(DOCUMENT.readyState);
|
285 | if (!loaded) DOCUMENT.addEventListener('DOMContentLoaded', listener);
|
286 | }
|
287 |
|
288 | function domready (fn) {
|
289 | if (!IS_DOM) return;
|
290 | loaded ? setTimeout(fn, 0) : functions.push(fn);
|
291 | }
|
292 |
|
293 | var PENDING = 'pending';
|
294 | var SETTLED = 'settled';
|
295 | var FULFILLED = 'fulfilled';
|
296 | var REJECTED = 'rejected';
|
297 |
|
298 | var NOOP = function NOOP() {};
|
299 |
|
300 | var isNode = typeof global !== 'undefined' && typeof global.process !== 'undefined' && typeof global.process.emit === 'function';
|
301 | var asyncSetTimer = typeof setImmediate === 'undefined' ? setTimeout : setImmediate;
|
302 | var asyncQueue = [];
|
303 | var asyncTimer;
|
304 |
|
305 | function asyncFlush() {
|
306 |
|
307 | for (var i = 0; i < asyncQueue.length; i++) {
|
308 | asyncQueue[i][0](asyncQueue[i][1]);
|
309 | }
|
310 |
|
311 |
|
312 | asyncQueue = [];
|
313 | asyncTimer = false;
|
314 | }
|
315 |
|
316 | function asyncCall(callback, arg) {
|
317 | asyncQueue.push([callback, arg]);
|
318 |
|
319 | if (!asyncTimer) {
|
320 | asyncTimer = true;
|
321 | asyncSetTimer(asyncFlush, 0);
|
322 | }
|
323 | }
|
324 |
|
325 | function invokeResolver(resolver, promise) {
|
326 | function resolvePromise(value) {
|
327 | resolve(promise, value);
|
328 | }
|
329 |
|
330 | function rejectPromise(reason) {
|
331 | reject(promise, reason);
|
332 | }
|
333 |
|
334 | try {
|
335 | resolver(resolvePromise, rejectPromise);
|
336 | } catch (e) {
|
337 | rejectPromise(e);
|
338 | }
|
339 | }
|
340 |
|
341 | function invokeCallback(subscriber) {
|
342 | var owner = subscriber.owner;
|
343 | var settled = owner._state;
|
344 | var value = owner._data;
|
345 | var callback = subscriber[settled];
|
346 | var promise = subscriber.then;
|
347 |
|
348 | if (typeof callback === 'function') {
|
349 | settled = FULFILLED;
|
350 |
|
351 | try {
|
352 | value = callback(value);
|
353 | } catch (e) {
|
354 | reject(promise, e);
|
355 | }
|
356 | }
|
357 |
|
358 | if (!handleThenable(promise, value)) {
|
359 | if (settled === FULFILLED) {
|
360 | resolve(promise, value);
|
361 | }
|
362 |
|
363 | if (settled === REJECTED) {
|
364 | reject(promise, value);
|
365 | }
|
366 | }
|
367 | }
|
368 |
|
369 | function handleThenable(promise, value) {
|
370 | var resolved;
|
371 |
|
372 | try {
|
373 | if (promise === value) {
|
374 | throw new TypeError('A promises callback cannot return that same promise.');
|
375 | }
|
376 |
|
377 | if (value && (typeof value === 'function' || _typeof(value) === 'object')) {
|
378 |
|
379 | var then = value.then;
|
380 |
|
381 | if (typeof then === 'function') {
|
382 | then.call(value, function (val) {
|
383 | if (!resolved) {
|
384 | resolved = true;
|
385 |
|
386 | if (value === val) {
|
387 | fulfill(promise, val);
|
388 | } else {
|
389 | resolve(promise, val);
|
390 | }
|
391 | }
|
392 | }, function (reason) {
|
393 | if (!resolved) {
|
394 | resolved = true;
|
395 | reject(promise, reason);
|
396 | }
|
397 | });
|
398 | return true;
|
399 | }
|
400 | }
|
401 | } catch (e) {
|
402 | if (!resolved) {
|
403 | reject(promise, e);
|
404 | }
|
405 |
|
406 | return true;
|
407 | }
|
408 |
|
409 | return false;
|
410 | }
|
411 |
|
412 | function resolve(promise, value) {
|
413 | if (promise === value || !handleThenable(promise, value)) {
|
414 | fulfill(promise, value);
|
415 | }
|
416 | }
|
417 |
|
418 | function fulfill(promise, value) {
|
419 | if (promise._state === PENDING) {
|
420 | promise._state = SETTLED;
|
421 | promise._data = value;
|
422 | asyncCall(publishFulfillment, promise);
|
423 | }
|
424 | }
|
425 |
|
426 | function reject(promise, reason) {
|
427 | if (promise._state === PENDING) {
|
428 | promise._state = SETTLED;
|
429 | promise._data = reason;
|
430 | asyncCall(publishRejection, promise);
|
431 | }
|
432 | }
|
433 |
|
434 | function publish(promise) {
|
435 | promise._then = promise._then.forEach(invokeCallback);
|
436 | }
|
437 |
|
438 | function publishFulfillment(promise) {
|
439 | promise._state = FULFILLED;
|
440 | publish(promise);
|
441 | }
|
442 |
|
443 | function publishRejection(promise) {
|
444 | promise._state = REJECTED;
|
445 | publish(promise);
|
446 |
|
447 | if (!promise._handled && isNode) {
|
448 | global.process.emit('unhandledRejection', promise._data, promise);
|
449 | }
|
450 | }
|
451 |
|
452 | function notifyRejectionHandled(promise) {
|
453 | global.process.emit('rejectionHandled', promise);
|
454 | }
|
455 |
|
456 |
|
457 |
|
458 |
|
459 |
|
460 | function P(resolver) {
|
461 | if (typeof resolver !== 'function') {
|
462 | throw new TypeError('Promise resolver ' + resolver + ' is not a function');
|
463 | }
|
464 |
|
465 | if (this instanceof P === false) {
|
466 | throw new TypeError('Failed to construct \'Promise\': Please use the \'new\' operator, this object constructor cannot be called as a function.');
|
467 | }
|
468 |
|
469 | this._then = [];
|
470 | invokeResolver(resolver, this);
|
471 | }
|
472 |
|
473 | P.prototype = {
|
474 | constructor: P,
|
475 | _state: PENDING,
|
476 | _then: null,
|
477 | _data: undefined,
|
478 | _handled: false,
|
479 | then: function then(onFulfillment, onRejection) {
|
480 | var subscriber = {
|
481 | owner: this,
|
482 | then: new this.constructor(NOOP),
|
483 | fulfilled: onFulfillment,
|
484 | rejected: onRejection
|
485 | };
|
486 |
|
487 | if ((onRejection || onFulfillment) && !this._handled) {
|
488 | this._handled = true;
|
489 |
|
490 | if (this._state === REJECTED && isNode) {
|
491 | asyncCall(notifyRejectionHandled, this);
|
492 | }
|
493 | }
|
494 |
|
495 | if (this._state === FULFILLED || this._state === REJECTED) {
|
496 |
|
497 | asyncCall(invokeCallback, subscriber);
|
498 | } else {
|
499 |
|
500 | this._then.push(subscriber);
|
501 | }
|
502 |
|
503 | return subscriber.then;
|
504 | },
|
505 | catch: function _catch(onRejection) {
|
506 | return this.then(null, onRejection);
|
507 | }
|
508 | };
|
509 |
|
510 | P.all = function (promises) {
|
511 | if (!Array.isArray(promises)) {
|
512 | throw new TypeError('You must pass an array to Promise.all().');
|
513 | }
|
514 |
|
515 | return new P(function (resolve, reject) {
|
516 | var results = [];
|
517 | var remaining = 0;
|
518 |
|
519 | function resolver(index) {
|
520 | remaining++;
|
521 | return function (value) {
|
522 | results[index] = value;
|
523 |
|
524 | if (! --remaining) {
|
525 | resolve(results);
|
526 | }
|
527 | };
|
528 | }
|
529 |
|
530 | for (var i = 0, promise; i < promises.length; i++) {
|
531 | promise = promises[i];
|
532 |
|
533 | if (promise && typeof promise.then === 'function') {
|
534 | promise.then(resolver(i), reject);
|
535 | } else {
|
536 | results[i] = promise;
|
537 | }
|
538 | }
|
539 |
|
540 | if (!remaining) {
|
541 | resolve(results);
|
542 | }
|
543 | });
|
544 | };
|
545 |
|
546 | P.race = function (promises) {
|
547 | if (!Array.isArray(promises)) {
|
548 | throw new TypeError('You must pass an array to Promise.race().');
|
549 | }
|
550 |
|
551 | return new P(function (resolve, reject) {
|
552 | for (var i = 0, promise; i < promises.length; i++) {
|
553 | promise = promises[i];
|
554 |
|
555 | if (promise && typeof promise.then === 'function') {
|
556 | promise.then(resolve, reject);
|
557 | } else {
|
558 | resolve(promise);
|
559 | }
|
560 | }
|
561 | });
|
562 | };
|
563 |
|
564 | P.resolve = function (value) {
|
565 | if (value && _typeof(value) === 'object' && value.constructor === P) {
|
566 | return value;
|
567 | }
|
568 |
|
569 | return new P(function (resolve) {
|
570 | resolve(value);
|
571 | });
|
572 | };
|
573 |
|
574 | P.reject = function (reason) {
|
575 | return new P(function (resolve, reject) {
|
576 | reject(reason);
|
577 | });
|
578 | };
|
579 |
|
580 | var picked = typeof Promise === 'function' ? Promise : P;
|
581 |
|
582 | var d = UNITS_IN_GRID;
|
583 | var meaninglessTransform = {
|
584 | size: 16,
|
585 | x: 0,
|
586 | y: 0,
|
587 | rotate: 0,
|
588 | flipX: false,
|
589 | flipY: false
|
590 | };
|
591 |
|
592 | function isReserved(name) {
|
593 | return ~RESERVED_CLASSES.indexOf(name);
|
594 | }
|
595 | function insertCss(css) {
|
596 | if (!css || !IS_DOM) {
|
597 | return;
|
598 | }
|
599 |
|
600 | var style = DOCUMENT.createElement('style');
|
601 | style.setAttribute('type', 'text/css');
|
602 | style.innerHTML = css;
|
603 | var headChildren = DOCUMENT.head.childNodes;
|
604 | var beforeChild = null;
|
605 |
|
606 | for (var i = headChildren.length - 1; i > -1; i--) {
|
607 | var child = headChildren[i];
|
608 | var tagName = (child.tagName || '').toUpperCase();
|
609 |
|
610 | if (['STYLE', 'LINK'].indexOf(tagName) > -1) {
|
611 | beforeChild = child;
|
612 | }
|
613 | }
|
614 |
|
615 | DOCUMENT.head.insertBefore(style, beforeChild);
|
616 | return css;
|
617 | }
|
618 | var idPool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
619 | function nextUniqueId() {
|
620 | var size = 12;
|
621 | var id = '';
|
622 |
|
623 | while (size-- > 0) {
|
624 | id += idPool[Math.random() * 62 | 0];
|
625 | }
|
626 |
|
627 | return id;
|
628 | }
|
629 | function toArray(obj) {
|
630 | var array = [];
|
631 |
|
632 | for (var i = (obj || []).length >>> 0; i--;) {
|
633 | array[i] = obj[i];
|
634 | }
|
635 |
|
636 | return array;
|
637 | }
|
638 | function classArray(node) {
|
639 | if (node.classList) {
|
640 | return toArray(node.classList);
|
641 | } else {
|
642 | return (node.getAttribute('class') || '').split(' ').filter(function (i) {
|
643 | return i;
|
644 | });
|
645 | }
|
646 | }
|
647 | function getIconName(familyPrefix, cls) {
|
648 | var parts = cls.split('-');
|
649 | var prefix = parts[0];
|
650 | var iconName = parts.slice(1).join('-');
|
651 |
|
652 | if (prefix === familyPrefix && iconName !== '' && !isReserved(iconName)) {
|
653 | return iconName;
|
654 | } else {
|
655 | return null;
|
656 | }
|
657 | }
|
658 | function htmlEscape(str) {
|
659 | return "".concat(str).replace(/&/g, '&').replace(/"/g, '"').replace(/'/g, ''').replace(/</g, '<').replace(/>/g, '>');
|
660 | }
|
661 | function joinAttributes(attributes) {
|
662 | return Object.keys(attributes || {}).reduce(function (acc, attributeName) {
|
663 | return acc + "".concat(attributeName, "=\"").concat(htmlEscape(attributes[attributeName]), "\" ");
|
664 | }, '').trim();
|
665 | }
|
666 | function joinStyles(styles) {
|
667 | return Object.keys(styles || {}).reduce(function (acc, styleName) {
|
668 | return acc + "".concat(styleName, ": ").concat(styles[styleName], ";");
|
669 | }, '');
|
670 | }
|
671 | function transformIsMeaningful(transform) {
|
672 | return transform.size !== meaninglessTransform.size || transform.x !== meaninglessTransform.x || transform.y !== meaninglessTransform.y || transform.rotate !== meaninglessTransform.rotate || transform.flipX || transform.flipY;
|
673 | }
|
674 | function transformForSvg(_ref) {
|
675 | var transform = _ref.transform,
|
676 | containerWidth = _ref.containerWidth,
|
677 | iconWidth = _ref.iconWidth;
|
678 | var outer = {
|
679 | transform: "translate(".concat(containerWidth / 2, " 256)")
|
680 | };
|
681 | var innerTranslate = "translate(".concat(transform.x * 32, ", ").concat(transform.y * 32, ") ");
|
682 | var innerScale = "scale(".concat(transform.size / 16 * (transform.flipX ? -1 : 1), ", ").concat(transform.size / 16 * (transform.flipY ? -1 : 1), ") ");
|
683 | var innerRotate = "rotate(".concat(transform.rotate, " 0 0)");
|
684 | var inner = {
|
685 | transform: "".concat(innerTranslate, " ").concat(innerScale, " ").concat(innerRotate)
|
686 | };
|
687 | var path = {
|
688 | transform: "translate(".concat(iconWidth / 2 * -1, " -256)")
|
689 | };
|
690 | return {
|
691 | outer: outer,
|
692 | inner: inner,
|
693 | path: path
|
694 | };
|
695 | }
|
696 | function transformForCss(_ref2) {
|
697 | var transform = _ref2.transform,
|
698 | _ref2$width = _ref2.width,
|
699 | width = _ref2$width === void 0 ? UNITS_IN_GRID : _ref2$width,
|
700 | _ref2$height = _ref2.height,
|
701 | height = _ref2$height === void 0 ? UNITS_IN_GRID : _ref2$height,
|
702 | _ref2$startCentered = _ref2.startCentered,
|
703 | startCentered = _ref2$startCentered === void 0 ? false : _ref2$startCentered;
|
704 | var val = '';
|
705 |
|
706 | if (startCentered && IS_IE) {
|
707 | val += "translate(".concat(transform.x / d - width / 2, "em, ").concat(transform.y / d - height / 2, "em) ");
|
708 | } else if (startCentered) {
|
709 | val += "translate(calc(-50% + ".concat(transform.x / d, "em), calc(-50% + ").concat(transform.y / d, "em)) ");
|
710 | } else {
|
711 | val += "translate(".concat(transform.x / d, "em, ").concat(transform.y / d, "em) ");
|
712 | }
|
713 |
|
714 | val += "scale(".concat(transform.size / d * (transform.flipX ? -1 : 1), ", ").concat(transform.size / d * (transform.flipY ? -1 : 1), ") ");
|
715 | val += "rotate(".concat(transform.rotate, "deg) ");
|
716 | return val;
|
717 | }
|
718 |
|
719 | var ALL_SPACE = {
|
720 | x: 0,
|
721 | y: 0,
|
722 | width: '100%',
|
723 | height: '100%'
|
724 | };
|
725 | function makeIconMasking (_ref) {
|
726 | var children = _ref.children,
|
727 | attributes = _ref.attributes,
|
728 | main = _ref.main,
|
729 | mask = _ref.mask,
|
730 | transform = _ref.transform;
|
731 | var mainWidth = main.width,
|
732 | mainPath = main.icon;
|
733 | var maskWidth = mask.width,
|
734 | maskPath = mask.icon;
|
735 | var trans = transformForSvg({
|
736 | transform: transform,
|
737 | containerWidth: maskWidth,
|
738 | iconWidth: mainWidth
|
739 | });
|
740 | var maskRect = {
|
741 | tag: 'rect',
|
742 | attributes: _objectSpread({}, ALL_SPACE, {
|
743 | fill: 'white'
|
744 | })
|
745 | };
|
746 | var maskInnerGroup = {
|
747 | tag: 'g',
|
748 | attributes: _objectSpread({}, trans.inner),
|
749 | children: [{
|
750 | tag: 'path',
|
751 | attributes: _objectSpread({}, mainPath.attributes, trans.path, {
|
752 | fill: 'black'
|
753 | })
|
754 | }]
|
755 | };
|
756 | var maskOuterGroup = {
|
757 | tag: 'g',
|
758 | attributes: _objectSpread({}, trans.outer),
|
759 | children: [maskInnerGroup]
|
760 | };
|
761 | var maskId = "mask-".concat(nextUniqueId());
|
762 | var clipId = "clip-".concat(nextUniqueId());
|
763 | var maskTag = {
|
764 | tag: 'mask',
|
765 | attributes: _objectSpread({}, ALL_SPACE, {
|
766 | id: maskId,
|
767 | maskUnits: 'userSpaceOnUse',
|
768 | maskContentUnits: 'userSpaceOnUse'
|
769 | }),
|
770 | children: [maskRect, maskOuterGroup]
|
771 | };
|
772 | var defs = {
|
773 | tag: 'defs',
|
774 | children: [{
|
775 | tag: 'clipPath',
|
776 | attributes: {
|
777 | id: clipId
|
778 | },
|
779 | children: [maskPath]
|
780 | }, maskTag]
|
781 | };
|
782 | children.push(defs, {
|
783 | tag: 'rect',
|
784 | attributes: _objectSpread({
|
785 | fill: 'currentColor',
|
786 | 'clip-path': "url(#".concat(clipId, ")"),
|
787 | mask: "url(#".concat(maskId, ")")
|
788 | }, ALL_SPACE)
|
789 | });
|
790 | return {
|
791 | children: children,
|
792 | attributes: attributes
|
793 | };
|
794 | }
|
795 |
|
796 | function makeIconStandard (_ref) {
|
797 | var children = _ref.children,
|
798 | attributes = _ref.attributes,
|
799 | main = _ref.main,
|
800 | transform = _ref.transform,
|
801 | styles = _ref.styles;
|
802 | var styleString = joinStyles(styles);
|
803 |
|
804 | if (styleString.length > 0) {
|
805 | attributes['style'] = styleString;
|
806 | }
|
807 |
|
808 | if (transformIsMeaningful(transform)) {
|
809 | var trans = transformForSvg({
|
810 | transform: transform,
|
811 | containerWidth: main.width,
|
812 | iconWidth: main.width
|
813 | });
|
814 | children.push({
|
815 | tag: 'g',
|
816 | attributes: _objectSpread({}, trans.outer),
|
817 | children: [{
|
818 | tag: 'g',
|
819 | attributes: _objectSpread({}, trans.inner),
|
820 | children: [{
|
821 | tag: main.icon.tag,
|
822 | children: main.icon.children,
|
823 | attributes: _objectSpread({}, main.icon.attributes, trans.path)
|
824 | }]
|
825 | }]
|
826 | });
|
827 | } else {
|
828 | children.push(main.icon);
|
829 | }
|
830 |
|
831 | return {
|
832 | children: children,
|
833 | attributes: attributes
|
834 | };
|
835 | }
|
836 |
|
837 | function asIcon (_ref) {
|
838 | var children = _ref.children,
|
839 | main = _ref.main,
|
840 | mask = _ref.mask,
|
841 | attributes = _ref.attributes,
|
842 | styles = _ref.styles,
|
843 | transform = _ref.transform;
|
844 |
|
845 | if (transformIsMeaningful(transform) && main.found && !mask.found) {
|
846 | var width = main.width,
|
847 | height = main.height;
|
848 | var offset = {
|
849 | x: width / height / 2,
|
850 | y: 0.5
|
851 | };
|
852 | attributes['style'] = joinStyles(_objectSpread({}, styles, {
|
853 | 'transform-origin': "".concat(offset.x + transform.x / 16, "em ").concat(offset.y + transform.y / 16, "em")
|
854 | }));
|
855 | }
|
856 |
|
857 | return [{
|
858 | tag: 'svg',
|
859 | attributes: attributes,
|
860 | children: children
|
861 | }];
|
862 | }
|
863 |
|
864 | function asSymbol (_ref) {
|
865 | var prefix = _ref.prefix,
|
866 | iconName = _ref.iconName,
|
867 | children = _ref.children,
|
868 | attributes = _ref.attributes,
|
869 | symbol = _ref.symbol;
|
870 | var id = symbol === true ? "".concat(prefix, "-").concat(config.familyPrefix, "-").concat(iconName) : symbol;
|
871 | return [{
|
872 | tag: 'svg',
|
873 | attributes: {
|
874 | style: 'display: none;'
|
875 | },
|
876 | children: [{
|
877 | tag: 'symbol',
|
878 | attributes: _objectSpread({}, attributes, {
|
879 | id: id
|
880 | }),
|
881 | children: children
|
882 | }]
|
883 | }];
|
884 | }
|
885 |
|
886 | function makeInlineSvgAbstract(params) {
|
887 | var _params$icons = params.icons,
|
888 | main = _params$icons.main,
|
889 | mask = _params$icons.mask,
|
890 | prefix = params.prefix,
|
891 | iconName = params.iconName,
|
892 | transform = params.transform,
|
893 | symbol = params.symbol,
|
894 | title = params.title,
|
895 | extra = params.extra,
|
896 | _params$watchable = params.watchable,
|
897 | watchable = _params$watchable === void 0 ? false : _params$watchable;
|
898 |
|
899 | var _ref = mask.found ? mask : main,
|
900 | width = _ref.width,
|
901 | height = _ref.height;
|
902 |
|
903 | var widthClass = "fa-w-".concat(Math.ceil(width / height * 16));
|
904 | var attrClass = [config.replacementClass, iconName ? "".concat(config.familyPrefix, "-").concat(iconName) : '', widthClass].filter(function (c) {
|
905 | return extra.classes.indexOf(c) === -1;
|
906 | }).concat(extra.classes).join(' ');
|
907 | var content = {
|
908 | children: [],
|
909 | attributes: _objectSpread({}, extra.attributes, {
|
910 | 'data-prefix': prefix,
|
911 | 'data-icon': iconName,
|
912 | 'class': attrClass,
|
913 | 'role': extra.attributes.role || 'img',
|
914 | 'xmlns': 'http://www.w3.org/2000/svg',
|
915 | 'viewBox': "0 0 ".concat(width, " ").concat(height)
|
916 | })
|
917 | };
|
918 |
|
919 | if (watchable) {
|
920 | content.attributes[DATA_FA_I2SVG] = '';
|
921 | }
|
922 |
|
923 | if (title) content.children.push({
|
924 | tag: 'title',
|
925 | attributes: {
|
926 | id: content.attributes['aria-labelledby'] || "title-".concat(nextUniqueId())
|
927 | },
|
928 | children: [title]
|
929 | });
|
930 |
|
931 | var args = _objectSpread({}, content, {
|
932 | prefix: prefix,
|
933 | iconName: iconName,
|
934 | main: main,
|
935 | mask: mask,
|
936 | transform: transform,
|
937 | symbol: symbol,
|
938 | styles: extra.styles
|
939 | });
|
940 |
|
941 | var _ref2 = mask.found && main.found ? makeIconMasking(args) : makeIconStandard(args),
|
942 | children = _ref2.children,
|
943 | attributes = _ref2.attributes;
|
944 |
|
945 | args.children = children;
|
946 | args.attributes = attributes;
|
947 |
|
948 | if (symbol) {
|
949 | return asSymbol(args);
|
950 | } else {
|
951 | return asIcon(args);
|
952 | }
|
953 | }
|
954 | function makeLayersTextAbstract(params) {
|
955 | var content = params.content,
|
956 | width = params.width,
|
957 | height = params.height,
|
958 | transform = params.transform,
|
959 | title = params.title,
|
960 | extra = params.extra,
|
961 | _params$watchable2 = params.watchable,
|
962 | watchable = _params$watchable2 === void 0 ? false : _params$watchable2;
|
963 |
|
964 | var attributes = _objectSpread({}, extra.attributes, title ? {
|
965 | 'title': title
|
966 | } : {}, {
|
967 | 'class': extra.classes.join(' ')
|
968 | });
|
969 |
|
970 | if (watchable) {
|
971 | attributes[DATA_FA_I2SVG] = '';
|
972 | }
|
973 |
|
974 | var styles = _objectSpread({}, extra.styles);
|
975 |
|
976 | if (transformIsMeaningful(transform)) {
|
977 | styles['transform'] = transformForCss({
|
978 | transform: transform,
|
979 | startCentered: true,
|
980 | width: width,
|
981 | height: height
|
982 | });
|
983 | styles['-webkit-transform'] = styles['transform'];
|
984 | }
|
985 |
|
986 | var styleString = joinStyles(styles);
|
987 |
|
988 | if (styleString.length > 0) {
|
989 | attributes['style'] = styleString;
|
990 | }
|
991 |
|
992 | var val = [];
|
993 | val.push({
|
994 | tag: 'span',
|
995 | attributes: attributes,
|
996 | children: [content]
|
997 | });
|
998 |
|
999 | if (title) {
|
1000 | val.push({
|
1001 | tag: 'span',
|
1002 | attributes: {
|
1003 | class: 'sr-only'
|
1004 | },
|
1005 | children: [title]
|
1006 | });
|
1007 | }
|
1008 |
|
1009 | return val;
|
1010 | }
|
1011 | function makeLayersCounterAbstract(params) {
|
1012 | var content = params.content,
|
1013 | title = params.title,
|
1014 | extra = params.extra;
|
1015 |
|
1016 | var attributes = _objectSpread({}, extra.attributes, title ? {
|
1017 | 'title': title
|
1018 | } : {}, {
|
1019 | 'class': extra.classes.join(' ')
|
1020 | });
|
1021 |
|
1022 | var styleString = joinStyles(extra.styles);
|
1023 |
|
1024 | if (styleString.length > 0) {
|
1025 | attributes['style'] = styleString;
|
1026 | }
|
1027 |
|
1028 | var val = [];
|
1029 | val.push({
|
1030 | tag: 'span',
|
1031 | attributes: attributes,
|
1032 | children: [content]
|
1033 | });
|
1034 |
|
1035 | if (title) {
|
1036 | val.push({
|
1037 | tag: 'span',
|
1038 | attributes: {
|
1039 | class: 'sr-only'
|
1040 | },
|
1041 | children: [title]
|
1042 | });
|
1043 | }
|
1044 |
|
1045 | return val;
|
1046 | }
|
1047 |
|
1048 | var noop$1 = function noop() {};
|
1049 |
|
1050 | var p = config.measurePerformance && PERFORMANCE && PERFORMANCE.mark && PERFORMANCE.measure ? PERFORMANCE : {
|
1051 | mark: noop$1,
|
1052 | measure: noop$1
|
1053 | };
|
1054 | var preamble = "FA \"5.8.2\"";
|
1055 |
|
1056 | var begin = function begin(name) {
|
1057 | p.mark("".concat(preamble, " ").concat(name, " begins"));
|
1058 | return function () {
|
1059 | return end(name);
|
1060 | };
|
1061 | };
|
1062 |
|
1063 | var end = function end(name) {
|
1064 | p.mark("".concat(preamble, " ").concat(name, " ends"));
|
1065 | p.measure("".concat(preamble, " ").concat(name), "".concat(preamble, " ").concat(name, " begins"), "".concat(preamble, " ").concat(name, " ends"));
|
1066 | };
|
1067 |
|
1068 | var perf = {
|
1069 | begin: begin,
|
1070 | end: end
|
1071 | };
|
1072 |
|
1073 |
|
1074 |
|
1075 |
|
1076 |
|
1077 |
|
1078 | var bindInternal4 = function bindInternal4(func, thisContext) {
|
1079 | return function (a, b, c, d) {
|
1080 | return func.call(thisContext, a, b, c, d);
|
1081 | };
|
1082 | };
|
1083 |
|
1084 |
|
1085 |
|
1086 |
|
1087 |
|
1088 |
|
1089 |
|
1090 |
|
1091 |
|
1092 |
|
1093 |
|
1094 |
|
1095 |
|
1096 |
|
1097 | var reduce = function fastReduceObject(subject, fn, initialValue, thisContext) {
|
1098 | var keys = Object.keys(subject),
|
1099 | length = keys.length,
|
1100 | iterator = thisContext !== undefined ? bindInternal4(fn, thisContext) : fn,
|
1101 | i,
|
1102 | key,
|
1103 | result;
|
1104 |
|
1105 | if (initialValue === undefined) {
|
1106 | i = 1;
|
1107 | result = subject[keys[0]];
|
1108 | } else {
|
1109 | i = 0;
|
1110 | result = initialValue;
|
1111 | }
|
1112 |
|
1113 | for (; i < length; i++) {
|
1114 | key = keys[i];
|
1115 | result = iterator(result, subject[key], key, subject);
|
1116 | }
|
1117 |
|
1118 | return result;
|
1119 | };
|
1120 |
|
1121 | function toHex(unicode) {
|
1122 | var result = '';
|
1123 |
|
1124 | for (var i = 0; i < unicode.length; i++) {
|
1125 | var hex = unicode.charCodeAt(i).toString(16);
|
1126 | result += ('000' + hex).slice(-4);
|
1127 | }
|
1128 |
|
1129 | return result;
|
1130 | }
|
1131 |
|
1132 | function defineIcons(prefix, icons) {
|
1133 | var params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
1134 | var _params$skipHooks = params.skipHooks,
|
1135 | skipHooks = _params$skipHooks === void 0 ? false : _params$skipHooks;
|
1136 | var normalized = Object.keys(icons).reduce(function (acc, iconName) {
|
1137 | var icon = icons[iconName];
|
1138 | var expanded = !!icon.icon;
|
1139 |
|
1140 | if (expanded) {
|
1141 | acc[icon.iconName] = icon.icon;
|
1142 | } else {
|
1143 | acc[iconName] = icon;
|
1144 | }
|
1145 |
|
1146 | return acc;
|
1147 | }, {});
|
1148 |
|
1149 | if (typeof namespace.hooks.addPack === 'function' && !skipHooks) {
|
1150 | namespace.hooks.addPack(prefix, normalized);
|
1151 | } else {
|
1152 | namespace.styles[prefix] = _objectSpread({}, namespace.styles[prefix] || {}, normalized);
|
1153 | }
|
1154 | |
1155 |
|
1156 |
|
1157 |
|
1158 |
|
1159 |
|
1160 |
|
1161 |
|
1162 | if (prefix === 'fas') {
|
1163 | defineIcons('fa', icons);
|
1164 | }
|
1165 | }
|
1166 |
|
1167 | var styles = namespace.styles,
|
1168 | shims = namespace.shims;
|
1169 | var _byUnicode = {};
|
1170 | var _byLigature = {};
|
1171 | var _byOldName = {};
|
1172 | var build = function build() {
|
1173 | var lookup = function lookup(reducer) {
|
1174 | return reduce(styles, function (o, style, prefix) {
|
1175 | o[prefix] = reduce(style, reducer, {});
|
1176 | return o;
|
1177 | }, {});
|
1178 | };
|
1179 |
|
1180 | _byUnicode = lookup(function (acc, icon, iconName) {
|
1181 | if (icon[3]) {
|
1182 | acc[icon[3]] = iconName;
|
1183 | }
|
1184 |
|
1185 | return acc;
|
1186 | });
|
1187 | _byLigature = lookup(function (acc, icon, iconName) {
|
1188 | var ligatures = icon[2];
|
1189 | acc[iconName] = iconName;
|
1190 | ligatures.forEach(function (ligature) {
|
1191 | acc[ligature] = iconName;
|
1192 | });
|
1193 | return acc;
|
1194 | });
|
1195 | var hasRegular = 'far' in styles;
|
1196 | _byOldName = reduce(shims, function (acc, shim) {
|
1197 | var oldName = shim[0];
|
1198 | var prefix = shim[1];
|
1199 | var iconName = shim[2];
|
1200 |
|
1201 | if (prefix === 'far' && !hasRegular) {
|
1202 | prefix = 'fas';
|
1203 | }
|
1204 |
|
1205 | acc[oldName] = {
|
1206 | prefix: prefix,
|
1207 | iconName: iconName
|
1208 | };
|
1209 | return acc;
|
1210 | }, {});
|
1211 | };
|
1212 | build();
|
1213 | function byUnicode(prefix, unicode) {
|
1214 | return (_byUnicode[prefix] || {})[unicode];
|
1215 | }
|
1216 | function byLigature(prefix, ligature) {
|
1217 | return (_byLigature[prefix] || {})[ligature];
|
1218 | }
|
1219 | function byOldName(name) {
|
1220 | return _byOldName[name] || {
|
1221 | prefix: null,
|
1222 | iconName: null
|
1223 | };
|
1224 | }
|
1225 |
|
1226 | var styles$1 = namespace.styles;
|
1227 | var emptyCanonicalIcon = function emptyCanonicalIcon() {
|
1228 | return {
|
1229 | prefix: null,
|
1230 | iconName: null,
|
1231 | rest: []
|
1232 | };
|
1233 | };
|
1234 | function getCanonicalIcon(values) {
|
1235 | return values.reduce(function (acc, cls) {
|
1236 | var iconName = getIconName(config.familyPrefix, cls);
|
1237 |
|
1238 | if (styles$1[cls]) {
|
1239 | acc.prefix = cls;
|
1240 | } else if (config.autoFetchSvg && ['fas', 'far', 'fal', 'fab', 'fa'].indexOf(cls) > -1) {
|
1241 | acc.prefix = cls;
|
1242 | } else if (iconName) {
|
1243 | var shim = acc.prefix === 'fa' ? byOldName(iconName) : {};
|
1244 | acc.iconName = shim.iconName || iconName;
|
1245 | acc.prefix = shim.prefix || acc.prefix;
|
1246 | } else if (cls !== config.replacementClass && cls.indexOf('fa-w-') !== 0) {
|
1247 | acc.rest.push(cls);
|
1248 | }
|
1249 |
|
1250 | return acc;
|
1251 | }, emptyCanonicalIcon());
|
1252 | }
|
1253 | function iconFromMapping(mapping, prefix, iconName) {
|
1254 | if (mapping && mapping[prefix] && mapping[prefix][iconName]) {
|
1255 | return {
|
1256 | prefix: prefix,
|
1257 | iconName: iconName,
|
1258 | icon: mapping[prefix][iconName]
|
1259 | };
|
1260 | }
|
1261 | }
|
1262 |
|
1263 | function toHtml(abstractNodes) {
|
1264 | var tag = abstractNodes.tag,
|
1265 | _abstractNodes$attrib = abstractNodes.attributes,
|
1266 | attributes = _abstractNodes$attrib === void 0 ? {} : _abstractNodes$attrib,
|
1267 | _abstractNodes$childr = abstractNodes.children,
|
1268 | children = _abstractNodes$childr === void 0 ? [] : _abstractNodes$childr;
|
1269 |
|
1270 | if (typeof abstractNodes === 'string') {
|
1271 | return htmlEscape(abstractNodes);
|
1272 | } else {
|
1273 | return "<".concat(tag, " ").concat(joinAttributes(attributes), ">").concat(children.map(toHtml).join(''), "</").concat(tag, ">");
|
1274 | }
|
1275 | }
|
1276 |
|
1277 | var noop$2 = function noop() {};
|
1278 |
|
1279 | function isWatched(node) {
|
1280 | var i2svg = node.getAttribute ? node.getAttribute(DATA_FA_I2SVG) : null;
|
1281 | return typeof i2svg === 'string';
|
1282 | }
|
1283 |
|
1284 | function getMutator() {
|
1285 | if (config.autoReplaceSvg === true) {
|
1286 | return mutators.replace;
|
1287 | }
|
1288 |
|
1289 | var mutator = mutators[config.autoReplaceSvg];
|
1290 | return mutator || mutators.replace;
|
1291 | }
|
1292 |
|
1293 | var mutators = {
|
1294 | replace: function replace(mutation) {
|
1295 | var node = mutation[0];
|
1296 | var abstract = mutation[1];
|
1297 | var newOuterHTML = abstract.map(function (a) {
|
1298 | return toHtml(a);
|
1299 | }).join('\n');
|
1300 |
|
1301 | if (node.parentNode && node.outerHTML) {
|
1302 | node.outerHTML = newOuterHTML + (config.keepOriginalSource && node.tagName.toLowerCase() !== 'svg' ? "<!-- ".concat(node.outerHTML, " -->") : '');
|
1303 | } else if (node.parentNode) {
|
1304 | var newNode = document.createElement('span');
|
1305 | node.parentNode.replaceChild(newNode, node);
|
1306 | newNode.outerHTML = newOuterHTML;
|
1307 | }
|
1308 | },
|
1309 | nest: function nest(mutation) {
|
1310 | var node = mutation[0];
|
1311 | var abstract = mutation[1];
|
1312 |
|
1313 |
|
1314 | if (~classArray(node).indexOf(config.replacementClass)) {
|
1315 | return mutators.replace(mutation);
|
1316 | }
|
1317 |
|
1318 | var forSvg = new RegExp("".concat(config.familyPrefix, "-.*"));
|
1319 | delete abstract[0].attributes.style;
|
1320 | var splitClasses = abstract[0].attributes.class.split(' ').reduce(function (acc, cls) {
|
1321 | if (cls === config.replacementClass || cls.match(forSvg)) {
|
1322 | acc.toSvg.push(cls);
|
1323 | } else {
|
1324 | acc.toNode.push(cls);
|
1325 | }
|
1326 |
|
1327 | return acc;
|
1328 | }, {
|
1329 | toNode: [],
|
1330 | toSvg: []
|
1331 | });
|
1332 | abstract[0].attributes.class = splitClasses.toSvg.join(' ');
|
1333 | var newInnerHTML = abstract.map(function (a) {
|
1334 | return toHtml(a);
|
1335 | }).join('\n');
|
1336 | node.setAttribute('class', splitClasses.toNode.join(' '));
|
1337 | node.setAttribute(DATA_FA_I2SVG, '');
|
1338 | node.innerHTML = newInnerHTML;
|
1339 | }
|
1340 | };
|
1341 |
|
1342 | function performOperationSync(op) {
|
1343 | op();
|
1344 | }
|
1345 |
|
1346 | function perform(mutations, callback) {
|
1347 | var callbackFunction = typeof callback === 'function' ? callback : noop$2;
|
1348 |
|
1349 | if (mutations.length === 0) {
|
1350 | callbackFunction();
|
1351 | } else {
|
1352 | var frame = performOperationSync;
|
1353 |
|
1354 | if (config.mutateApproach === MUTATION_APPROACH_ASYNC) {
|
1355 | frame = WINDOW.requestAnimationFrame || performOperationSync;
|
1356 | }
|
1357 |
|
1358 | frame(function () {
|
1359 | var mutator = getMutator();
|
1360 | var mark = perf.begin('mutate');
|
1361 | mutations.map(mutator);
|
1362 | mark();
|
1363 | callbackFunction();
|
1364 | });
|
1365 | }
|
1366 | }
|
1367 | var disabled = false;
|
1368 | function disableObservation() {
|
1369 | disabled = true;
|
1370 | }
|
1371 | function enableObservation() {
|
1372 | disabled = false;
|
1373 | }
|
1374 | var mo = null;
|
1375 | function observe(options) {
|
1376 | if (!MUTATION_OBSERVER) {
|
1377 | return;
|
1378 | }
|
1379 |
|
1380 | if (!config.observeMutations) {
|
1381 | return;
|
1382 | }
|
1383 |
|
1384 | var treeCallback = options.treeCallback,
|
1385 | nodeCallback = options.nodeCallback,
|
1386 | pseudoElementsCallback = options.pseudoElementsCallback,
|
1387 | _options$observeMutat = options.observeMutationsRoot,
|
1388 | observeMutationsRoot = _options$observeMutat === void 0 ? DOCUMENT : _options$observeMutat;
|
1389 | mo = new MUTATION_OBSERVER(function (objects) {
|
1390 | if (disabled) return;
|
1391 | toArray(objects).forEach(function (mutationRecord) {
|
1392 | if (mutationRecord.type === 'childList' && mutationRecord.addedNodes.length > 0 && !isWatched(mutationRecord.addedNodes[0])) {
|
1393 | if (config.searchPseudoElements) {
|
1394 | pseudoElementsCallback(mutationRecord.target);
|
1395 | }
|
1396 |
|
1397 | treeCallback(mutationRecord.target);
|
1398 | }
|
1399 |
|
1400 | if (mutationRecord.type === 'attributes' && mutationRecord.target.parentNode && config.searchPseudoElements) {
|
1401 | pseudoElementsCallback(mutationRecord.target.parentNode);
|
1402 | }
|
1403 |
|
1404 | if (mutationRecord.type === 'attributes' && isWatched(mutationRecord.target) && ~ATTRIBUTES_WATCHED_FOR_MUTATION.indexOf(mutationRecord.attributeName)) {
|
1405 | if (mutationRecord.attributeName === 'class') {
|
1406 | var _getCanonicalIcon = getCanonicalIcon(classArray(mutationRecord.target)),
|
1407 | prefix = _getCanonicalIcon.prefix,
|
1408 | iconName = _getCanonicalIcon.iconName;
|
1409 |
|
1410 | if (prefix) mutationRecord.target.setAttribute('data-prefix', prefix);
|
1411 | if (iconName) mutationRecord.target.setAttribute('data-icon', iconName);
|
1412 | } else {
|
1413 | nodeCallback(mutationRecord.target);
|
1414 | }
|
1415 | }
|
1416 | });
|
1417 | });
|
1418 | if (!IS_DOM) return;
|
1419 | mo.observe(observeMutationsRoot, {
|
1420 | childList: true,
|
1421 | attributes: true,
|
1422 | characterData: true,
|
1423 | subtree: true
|
1424 | });
|
1425 | }
|
1426 | function disconnect() {
|
1427 | if (!mo) return;
|
1428 | mo.disconnect();
|
1429 | }
|
1430 |
|
1431 | function styleParser (node) {
|
1432 | var style = node.getAttribute('style');
|
1433 | var val = [];
|
1434 |
|
1435 | if (style) {
|
1436 | val = style.split(';').reduce(function (acc, style) {
|
1437 | var styles = style.split(':');
|
1438 | var prop = styles[0];
|
1439 | var value = styles.slice(1);
|
1440 |
|
1441 | if (prop && value.length > 0) {
|
1442 | acc[prop] = value.join(':').trim();
|
1443 | }
|
1444 |
|
1445 | return acc;
|
1446 | }, {});
|
1447 | }
|
1448 |
|
1449 | return val;
|
1450 | }
|
1451 |
|
1452 | function classParser (node) {
|
1453 | var existingPrefix = node.getAttribute('data-prefix');
|
1454 | var existingIconName = node.getAttribute('data-icon');
|
1455 | var innerText = node.innerText !== undefined ? node.innerText.trim() : '';
|
1456 | var val = getCanonicalIcon(classArray(node));
|
1457 |
|
1458 | if (existingPrefix && existingIconName) {
|
1459 | val.prefix = existingPrefix;
|
1460 | val.iconName = existingIconName;
|
1461 | }
|
1462 |
|
1463 | if (val.prefix && innerText.length > 1) {
|
1464 | val.iconName = byLigature(val.prefix, node.innerText);
|
1465 | } else if (val.prefix && innerText.length === 1) {
|
1466 | val.iconName = byUnicode(val.prefix, toHex(node.innerText));
|
1467 | }
|
1468 |
|
1469 | return val;
|
1470 | }
|
1471 |
|
1472 | var parseTransformString = function parseTransformString(transformString) {
|
1473 | var transform = {
|
1474 | size: 16,
|
1475 | x: 0,
|
1476 | y: 0,
|
1477 | flipX: false,
|
1478 | flipY: false,
|
1479 | rotate: 0
|
1480 | };
|
1481 |
|
1482 | if (!transformString) {
|
1483 | return transform;
|
1484 | } else {
|
1485 | return transformString.toLowerCase().split(' ').reduce(function (acc, n) {
|
1486 | var parts = n.toLowerCase().split('-');
|
1487 | var first = parts[0];
|
1488 | var rest = parts.slice(1).join('-');
|
1489 |
|
1490 | if (first && rest === 'h') {
|
1491 | acc.flipX = true;
|
1492 | return acc;
|
1493 | }
|
1494 |
|
1495 | if (first && rest === 'v') {
|
1496 | acc.flipY = true;
|
1497 | return acc;
|
1498 | }
|
1499 |
|
1500 | rest = parseFloat(rest);
|
1501 |
|
1502 | if (isNaN(rest)) {
|
1503 | return acc;
|
1504 | }
|
1505 |
|
1506 | switch (first) {
|
1507 | case 'grow':
|
1508 | acc.size = acc.size + rest;
|
1509 | break;
|
1510 |
|
1511 | case 'shrink':
|
1512 | acc.size = acc.size - rest;
|
1513 | break;
|
1514 |
|
1515 | case 'left':
|
1516 | acc.x = acc.x - rest;
|
1517 | break;
|
1518 |
|
1519 | case 'right':
|
1520 | acc.x = acc.x + rest;
|
1521 | break;
|
1522 |
|
1523 | case 'up':
|
1524 | acc.y = acc.y - rest;
|
1525 | break;
|
1526 |
|
1527 | case 'down':
|
1528 | acc.y = acc.y + rest;
|
1529 | break;
|
1530 |
|
1531 | case 'rotate':
|
1532 | acc.rotate = acc.rotate + rest;
|
1533 | break;
|
1534 | }
|
1535 |
|
1536 | return acc;
|
1537 | }, transform);
|
1538 | }
|
1539 | };
|
1540 | function transformParser (node) {
|
1541 | return parseTransformString(node.getAttribute('data-fa-transform'));
|
1542 | }
|
1543 |
|
1544 | function symbolParser (node) {
|
1545 | var symbol = node.getAttribute('data-fa-symbol');
|
1546 | return symbol === null ? false : symbol === '' ? true : symbol;
|
1547 | }
|
1548 |
|
1549 | function attributesParser (node) {
|
1550 | var extraAttributes = toArray(node.attributes).reduce(function (acc, attr) {
|
1551 | if (acc.name !== 'class' && acc.name !== 'style') {
|
1552 | acc[attr.name] = attr.value;
|
1553 | }
|
1554 |
|
1555 | return acc;
|
1556 | }, {});
|
1557 | var title = node.getAttribute('title');
|
1558 |
|
1559 | if (config.autoA11y) {
|
1560 | if (title) {
|
1561 | extraAttributes['aria-labelledby'] = "".concat(config.replacementClass, "-title-").concat(nextUniqueId());
|
1562 | } else {
|
1563 | extraAttributes['aria-hidden'] = 'true';
|
1564 | extraAttributes['focusable'] = 'false';
|
1565 | }
|
1566 | }
|
1567 |
|
1568 | return extraAttributes;
|
1569 | }
|
1570 |
|
1571 | function maskParser (node) {
|
1572 | var mask = node.getAttribute('data-fa-mask');
|
1573 |
|
1574 | if (!mask) {
|
1575 | return emptyCanonicalIcon();
|
1576 | } else {
|
1577 | return getCanonicalIcon(mask.split(' ').map(function (i) {
|
1578 | return i.trim();
|
1579 | }));
|
1580 | }
|
1581 | }
|
1582 |
|
1583 | function blankMeta() {
|
1584 | return {
|
1585 | iconName: null,
|
1586 | title: null,
|
1587 | prefix: null,
|
1588 | transform: meaninglessTransform,
|
1589 | symbol: false,
|
1590 | mask: null,
|
1591 | extra: {
|
1592 | classes: [],
|
1593 | styles: {},
|
1594 | attributes: {}
|
1595 | }
|
1596 | };
|
1597 | }
|
1598 | function parseMeta(node) {
|
1599 | var _classParser = classParser(node),
|
1600 | iconName = _classParser.iconName,
|
1601 | prefix = _classParser.prefix,
|
1602 | extraClasses = _classParser.rest;
|
1603 |
|
1604 | var extraStyles = styleParser(node);
|
1605 | var transform = transformParser(node);
|
1606 | var symbol = symbolParser(node);
|
1607 | var extraAttributes = attributesParser(node);
|
1608 | var mask = maskParser(node);
|
1609 | return {
|
1610 | iconName: iconName,
|
1611 | title: node.getAttribute('title'),
|
1612 | prefix: prefix,
|
1613 | transform: transform,
|
1614 | symbol: symbol,
|
1615 | mask: mask,
|
1616 | extra: {
|
1617 | classes: extraClasses,
|
1618 | styles: extraStyles,
|
1619 | attributes: extraAttributes
|
1620 | }
|
1621 | };
|
1622 | }
|
1623 |
|
1624 | function MissingIcon(error) {
|
1625 | this.name = 'MissingIcon';
|
1626 | this.message = error || 'Icon unavailable';
|
1627 | this.stack = new Error().stack;
|
1628 | }
|
1629 | MissingIcon.prototype = Object.create(Error.prototype);
|
1630 | MissingIcon.prototype.constructor = MissingIcon;
|
1631 |
|
1632 | var FILL = {
|
1633 | fill: 'currentColor'
|
1634 | };
|
1635 | var ANIMATION_BASE = {
|
1636 | attributeType: 'XML',
|
1637 | repeatCount: 'indefinite',
|
1638 | dur: '2s'
|
1639 | };
|
1640 | var RING = {
|
1641 | tag: 'path',
|
1642 | attributes: _objectSpread({}, FILL, {
|
1643 | d: 'M156.5,447.7l-12.6,29.5c-18.7-9.5-35.9-21.2-51.5-34.9l22.7-22.7C127.6,430.5,141.5,440,156.5,447.7z M40.6,272H8.5 c1.4,21.2,5.4,41.7,11.7,61.1L50,321.2C45.1,305.5,41.8,289,40.6,272z M40.6,240c1.4-18.8,5.2-37,11.1-54.1l-29.5-12.6 C14.7,194.3,10,216.7,8.5,240H40.6z M64.3,156.5c7.8-14.9,17.2-28.8,28.1-41.5L69.7,92.3c-13.7,15.6-25.5,32.8-34.9,51.5 L64.3,156.5z M397,419.6c-13.9,12-29.4,22.3-46.1,30.4l11.9,29.8c20.7-9.9,39.8-22.6,56.9-37.6L397,419.6z M115,92.4 c13.9-12,29.4-22.3,46.1-30.4l-11.9-29.8c-20.7,9.9-39.8,22.6-56.8,37.6L115,92.4z M447.7,355.5c-7.8,14.9-17.2,28.8-28.1,41.5 l22.7,22.7c13.7-15.6,25.5-32.9,34.9-51.5L447.7,355.5z M471.4,272c-1.4,18.8-5.2,37-11.1,54.1l29.5,12.6 c7.5-21.1,12.2-43.5,13.6-66.8H471.4z M321.2,462c-15.7,5-32.2,8.2-49.2,9.4v32.1c21.2-1.4,41.7-5.4,61.1-11.7L321.2,462z M240,471.4c-18.8-1.4-37-5.2-54.1-11.1l-12.6,29.5c21.1,7.5,43.5,12.2,66.8,13.6V471.4z M462,190.8c5,15.7,8.2,32.2,9.4,49.2h32.1 c-1.4-21.2-5.4-41.7-11.7-61.1L462,190.8z M92.4,397c-12-13.9-22.3-29.4-30.4-46.1l-29.8,11.9c9.9,20.7,22.6,39.8,37.6,56.9 L92.4,397z M272,40.6c18.8,1.4,36.9,5.2,54.1,11.1l12.6-29.5C317.7,14.7,295.3,10,272,8.5V40.6z M190.8,50 c15.7-5,32.2-8.2,49.2-9.4V8.5c-21.2,1.4-41.7,5.4-61.1,11.7L190.8,50z M442.3,92.3L419.6,115c12,13.9,22.3,29.4,30.5,46.1 l29.8-11.9C470,128.5,457.3,109.4,442.3,92.3z M397,92.4l22.7-22.7c-15.6-13.7-32.8-25.5-51.5-34.9l-12.6,29.5 C370.4,72.1,384.4,81.5,397,92.4z'
|
1644 | })
|
1645 | };
|
1646 |
|
1647 | var OPACITY_ANIMATE = _objectSpread({}, ANIMATION_BASE, {
|
1648 | attributeName: 'opacity'
|
1649 | });
|
1650 |
|
1651 | var DOT = {
|
1652 | tag: 'circle',
|
1653 | attributes: _objectSpread({}, FILL, {
|
1654 | cx: '256',
|
1655 | cy: '364',
|
1656 | r: '28'
|
1657 | }),
|
1658 | children: [{
|
1659 | tag: 'animate',
|
1660 | attributes: _objectSpread({}, ANIMATION_BASE, {
|
1661 | attributeName: 'r',
|
1662 | values: '28;14;28;28;14;28;'
|
1663 | })
|
1664 | }, {
|
1665 | tag: 'animate',
|
1666 | attributes: _objectSpread({}, OPACITY_ANIMATE, {
|
1667 | values: '1;0;1;1;0;1;'
|
1668 | })
|
1669 | }]
|
1670 | };
|
1671 | var QUESTION = {
|
1672 | tag: 'path',
|
1673 | attributes: _objectSpread({}, FILL, {
|
1674 | opacity: '1',
|
1675 | d: 'M263.7,312h-16c-6.6,0-12-5.4-12-12c0-71,77.4-63.9,77.4-107.8c0-20-17.8-40.2-57.4-40.2c-29.1,0-44.3,9.6-59.2,28.7 c-3.9,5-11.1,6-16.2,2.4l-13.1-9.2c-5.6-3.9-6.9-11.8-2.6-17.2c21.2-27.2,46.4-44.7,91.2-44.7c52.3,0,97.4,29.8,97.4,80.2 c0,67.6-77.4,63.5-77.4,107.8C275.7,306.6,270.3,312,263.7,312z'
|
1676 | }),
|
1677 | children: [{
|
1678 | tag: 'animate',
|
1679 | attributes: _objectSpread({}, OPACITY_ANIMATE, {
|
1680 | values: '1;0;0;0;0;1;'
|
1681 | })
|
1682 | }]
|
1683 | };
|
1684 | var EXCLAMATION = {
|
1685 | tag: 'path',
|
1686 | attributes: _objectSpread({}, FILL, {
|
1687 | opacity: '0',
|
1688 | d: 'M232.5,134.5l7,168c0.3,6.4,5.6,11.5,12,11.5h9c6.4,0,11.7-5.1,12-11.5l7-168c0.3-6.8-5.2-12.5-12-12.5h-23 C237.7,122,232.2,127.7,232.5,134.5z'
|
1689 | }),
|
1690 | children: [{
|
1691 | tag: 'animate',
|
1692 | attributes: _objectSpread({}, OPACITY_ANIMATE, {
|
1693 | values: '0;0;1;1;0;0;'
|
1694 | })
|
1695 | }]
|
1696 | };
|
1697 | var missing = {
|
1698 | tag: 'g',
|
1699 | children: [RING, DOT, QUESTION, EXCLAMATION]
|
1700 | };
|
1701 |
|
1702 | var styles$2 = namespace.styles;
|
1703 | function findIcon(iconName, prefix) {
|
1704 | return new picked(function (resolve, reject) {
|
1705 | var val = {
|
1706 | found: false,
|
1707 | width: 512,
|
1708 | height: 512,
|
1709 | icon: missing
|
1710 | };
|
1711 |
|
1712 | if (iconName && prefix && styles$2[prefix] && styles$2[prefix][iconName]) {
|
1713 | var icon = styles$2[prefix][iconName];
|
1714 | var width = icon[0];
|
1715 | var height = icon[1];
|
1716 | var vectorData = icon.slice(4);
|
1717 | val = {
|
1718 | found: true,
|
1719 | width: width,
|
1720 | height: height,
|
1721 | icon: {
|
1722 | tag: 'path',
|
1723 | attributes: {
|
1724 | fill: 'currentColor',
|
1725 | d: vectorData[0]
|
1726 | }
|
1727 | }
|
1728 | };
|
1729 | return resolve(val);
|
1730 | }
|
1731 |
|
1732 | if (iconName && prefix && !config.showMissingIcons) {
|
1733 | reject(new MissingIcon("Icon is missing for prefix ".concat(prefix, " with icon name ").concat(iconName)));
|
1734 | } else {
|
1735 | resolve(val);
|
1736 | }
|
1737 | });
|
1738 | }
|
1739 |
|
1740 | var styles$3 = namespace.styles;
|
1741 |
|
1742 | function generateSvgReplacementMutation(node, nodeMeta) {
|
1743 | var iconName = nodeMeta.iconName,
|
1744 | title = nodeMeta.title,
|
1745 | prefix = nodeMeta.prefix,
|
1746 | transform = nodeMeta.transform,
|
1747 | symbol = nodeMeta.symbol,
|
1748 | mask = nodeMeta.mask,
|
1749 | extra = nodeMeta.extra;
|
1750 | return new picked(function (resolve, reject) {
|
1751 | picked.all([findIcon(iconName, prefix), findIcon(mask.iconName, mask.prefix)]).then(function (_ref) {
|
1752 | var _ref2 = _slicedToArray(_ref, 2),
|
1753 | main = _ref2[0],
|
1754 | mask = _ref2[1];
|
1755 |
|
1756 | resolve([node, makeInlineSvgAbstract({
|
1757 | icons: {
|
1758 | main: main,
|
1759 | mask: mask
|
1760 | },
|
1761 | prefix: prefix,
|
1762 | iconName: iconName,
|
1763 | transform: transform,
|
1764 | symbol: symbol,
|
1765 | mask: mask,
|
1766 | title: title,
|
1767 | extra: extra,
|
1768 | watchable: true
|
1769 | })]);
|
1770 | });
|
1771 | });
|
1772 | }
|
1773 |
|
1774 | function generateLayersText(node, nodeMeta) {
|
1775 | var title = nodeMeta.title,
|
1776 | transform = nodeMeta.transform,
|
1777 | extra = nodeMeta.extra;
|
1778 | var width = null;
|
1779 | var height = null;
|
1780 |
|
1781 | if (IS_IE) {
|
1782 | var computedFontSize = parseInt(getComputedStyle(node).fontSize, 10);
|
1783 | var boundingClientRect = node.getBoundingClientRect();
|
1784 | width = boundingClientRect.width / computedFontSize;
|
1785 | height = boundingClientRect.height / computedFontSize;
|
1786 | }
|
1787 |
|
1788 | if (config.autoA11y && !title) {
|
1789 | extra.attributes['aria-hidden'] = 'true';
|
1790 | }
|
1791 |
|
1792 | return picked.resolve([node, makeLayersTextAbstract({
|
1793 | content: node.innerHTML,
|
1794 | width: width,
|
1795 | height: height,
|
1796 | transform: transform,
|
1797 | title: title,
|
1798 | extra: extra,
|
1799 | watchable: true
|
1800 | })]);
|
1801 | }
|
1802 |
|
1803 | function generateMutation(node) {
|
1804 | var nodeMeta = parseMeta(node);
|
1805 |
|
1806 | if (~nodeMeta.extra.classes.indexOf(LAYERS_TEXT_CLASSNAME)) {
|
1807 | return generateLayersText(node, nodeMeta);
|
1808 | } else {
|
1809 | return generateSvgReplacementMutation(node, nodeMeta);
|
1810 | }
|
1811 | }
|
1812 |
|
1813 | function onTree(root) {
|
1814 | var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
1815 | if (!IS_DOM) return;
|
1816 | var htmlClassList = DOCUMENT.documentElement.classList;
|
1817 |
|
1818 | var hclAdd = function hclAdd(suffix) {
|
1819 | return htmlClassList.add("".concat(HTML_CLASS_I2SVG_BASE_CLASS, "-").concat(suffix));
|
1820 | };
|
1821 |
|
1822 | var hclRemove = function hclRemove(suffix) {
|
1823 | return htmlClassList.remove("".concat(HTML_CLASS_I2SVG_BASE_CLASS, "-").concat(suffix));
|
1824 | };
|
1825 |
|
1826 | var prefixes = config.autoFetchSvg ? Object.keys(PREFIX_TO_STYLE) : Object.keys(styles$3);
|
1827 | var prefixesDomQuery = [".".concat(LAYERS_TEXT_CLASSNAME, ":not([").concat(DATA_FA_I2SVG, "])")].concat(prefixes.map(function (p) {
|
1828 | return ".".concat(p, ":not([").concat(DATA_FA_I2SVG, "])");
|
1829 | })).join(', ');
|
1830 |
|
1831 | if (prefixesDomQuery.length === 0) {
|
1832 | return;
|
1833 | }
|
1834 |
|
1835 | var candidates = [];
|
1836 |
|
1837 | try {
|
1838 | candidates = toArray(root.querySelectorAll(prefixesDomQuery));
|
1839 | } catch (e) {
|
1840 | }
|
1841 |
|
1842 | if (candidates.length > 0) {
|
1843 | hclAdd('pending');
|
1844 | hclRemove('complete');
|
1845 | } else {
|
1846 | return;
|
1847 | }
|
1848 |
|
1849 | var mark = perf.begin('onTree');
|
1850 | var mutations = candidates.reduce(function (acc, node) {
|
1851 | try {
|
1852 | var mutation = generateMutation(node);
|
1853 |
|
1854 | if (mutation) {
|
1855 | acc.push(mutation);
|
1856 | }
|
1857 | } catch (e) {
|
1858 | if (!PRODUCTION) {
|
1859 | if (e instanceof MissingIcon) {
|
1860 | console.error(e);
|
1861 | }
|
1862 | }
|
1863 | }
|
1864 |
|
1865 | return acc;
|
1866 | }, []);
|
1867 | return new picked(function (resolve, reject) {
|
1868 | picked.all(mutations).then(function (resolvedMutations) {
|
1869 | perform(resolvedMutations, function () {
|
1870 | hclAdd('active');
|
1871 | hclAdd('complete');
|
1872 | hclRemove('pending');
|
1873 | if (typeof callback === 'function') callback();
|
1874 | mark();
|
1875 | resolve();
|
1876 | });
|
1877 | }).catch(function () {
|
1878 | mark();
|
1879 | reject();
|
1880 | });
|
1881 | });
|
1882 | }
|
1883 | function onNode(node) {
|
1884 | var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
1885 | generateMutation(node).then(function (mutation) {
|
1886 | if (mutation) {
|
1887 | perform([mutation], callback);
|
1888 | }
|
1889 | });
|
1890 | }
|
1891 |
|
1892 | function replaceForPosition(node, position) {
|
1893 | var pendingAttribute = "".concat(DATA_FA_PSEUDO_ELEMENT_PENDING).concat(position.replace(':', '-'));
|
1894 | return new picked(function (resolve, reject) {
|
1895 | if (node.getAttribute(pendingAttribute) !== null) {
|
1896 |
|
1897 | return resolve();
|
1898 | }
|
1899 |
|
1900 | var children = toArray(node.children);
|
1901 | var alreadyProcessedPseudoElement = children.filter(function (c) {
|
1902 | return c.getAttribute(DATA_FA_PSEUDO_ELEMENT) === position;
|
1903 | })[0];
|
1904 | var styles = WINDOW.getComputedStyle(node, position);
|
1905 | var fontFamily = styles.getPropertyValue('font-family').match(FONT_FAMILY_PATTERN);
|
1906 | var fontWeight = styles.getPropertyValue('font-weight');
|
1907 |
|
1908 | if (alreadyProcessedPseudoElement && !fontFamily) {
|
1909 |
|
1910 |
|
1911 |
|
1912 | node.removeChild(alreadyProcessedPseudoElement);
|
1913 | return resolve();
|
1914 | } else if (fontFamily) {
|
1915 | var content = styles.getPropertyValue('content');
|
1916 | var prefix = ~['Light', 'Regular', 'Solid', 'Brands'].indexOf(fontFamily[1]) ? STYLE_TO_PREFIX[fontFamily[1].toLowerCase()] : FONT_WEIGHT_TO_PREFIX[fontWeight];
|
1917 | var hexValue = toHex(content.length === 3 ? content.substr(1, 1) : content);
|
1918 | var iconName = byUnicode(prefix, hexValue);
|
1919 | var iconIdentifier = iconName;
|
1920 |
|
1921 |
|
1922 | if (iconName && (!alreadyProcessedPseudoElement || alreadyProcessedPseudoElement.getAttribute(DATA_PREFIX) !== prefix || alreadyProcessedPseudoElement.getAttribute(DATA_ICON) !== iconIdentifier)) {
|
1923 | node.setAttribute(pendingAttribute, iconIdentifier);
|
1924 |
|
1925 | if (alreadyProcessedPseudoElement) {
|
1926 |
|
1927 | node.removeChild(alreadyProcessedPseudoElement);
|
1928 | }
|
1929 |
|
1930 | var meta = blankMeta();
|
1931 | var extra = meta.extra;
|
1932 | extra.attributes[DATA_FA_PSEUDO_ELEMENT] = position;
|
1933 | findIcon(iconName, prefix).then(function (main) {
|
1934 | var abstract = makeInlineSvgAbstract(_objectSpread({}, meta, {
|
1935 | icons: {
|
1936 | main: main,
|
1937 | mask: emptyCanonicalIcon()
|
1938 | },
|
1939 | prefix: prefix,
|
1940 | iconName: iconIdentifier,
|
1941 | extra: extra,
|
1942 | watchable: true
|
1943 | }));
|
1944 | var element = DOCUMENT.createElement('svg');
|
1945 |
|
1946 | if (position === ':before') {
|
1947 | node.insertBefore(element, node.firstChild);
|
1948 | } else {
|
1949 | node.appendChild(element);
|
1950 | }
|
1951 |
|
1952 | element.outerHTML = abstract.map(function (a) {
|
1953 | return toHtml(a);
|
1954 | }).join('\n');
|
1955 | node.removeAttribute(pendingAttribute);
|
1956 | resolve();
|
1957 | }).catch(reject);
|
1958 | } else {
|
1959 | resolve();
|
1960 | }
|
1961 | } else {
|
1962 | resolve();
|
1963 | }
|
1964 | });
|
1965 | }
|
1966 |
|
1967 | function replace(node) {
|
1968 | return picked.all([replaceForPosition(node, ':before'), replaceForPosition(node, ':after')]);
|
1969 | }
|
1970 |
|
1971 | function processable(node) {
|
1972 | return node.parentNode !== document.head && !~TAGNAMES_TO_SKIP_FOR_PSEUDOELEMENTS.indexOf(node.tagName.toUpperCase()) && !node.getAttribute(DATA_FA_PSEUDO_ELEMENT) && (!node.parentNode || node.parentNode.tagName !== 'svg');
|
1973 | }
|
1974 |
|
1975 | function searchPseudoElements (root) {
|
1976 | if (!IS_DOM) return;
|
1977 | return new picked(function (resolve, reject) {
|
1978 | var operations = toArray(root.querySelectorAll('*')).filter(processable).map(replace);
|
1979 | var end = perf.begin('searchPseudoElements');
|
1980 | disableObservation();
|
1981 | picked.all(operations).then(function () {
|
1982 | end();
|
1983 | enableObservation();
|
1984 | resolve();
|
1985 | }).catch(function () {
|
1986 | end();
|
1987 | enableObservation();
|
1988 | reject();
|
1989 | });
|
1990 | });
|
1991 | }
|
1992 |
|
1993 | var baseStyles = "svg:not(:root).svg-inline--fa {\n overflow: visible;\n}\n\n.svg-inline--fa {\n display: inline-block;\n font-size: inherit;\n height: 1em;\n overflow: visible;\n vertical-align: -0.125em;\n}\n.svg-inline--fa.fa-lg {\n vertical-align: -0.225em;\n}\n.svg-inline--fa.fa-w-1 {\n width: 0.0625em;\n}\n.svg-inline--fa.fa-w-2 {\n width: 0.125em;\n}\n.svg-inline--fa.fa-w-3 {\n width: 0.1875em;\n}\n.svg-inline--fa.fa-w-4 {\n width: 0.25em;\n}\n.svg-inline--fa.fa-w-5 {\n width: 0.3125em;\n}\n.svg-inline--fa.fa-w-6 {\n width: 0.375em;\n}\n.svg-inline--fa.fa-w-7 {\n width: 0.4375em;\n}\n.svg-inline--fa.fa-w-8 {\n width: 0.5em;\n}\n.svg-inline--fa.fa-w-9 {\n width: 0.5625em;\n}\n.svg-inline--fa.fa-w-10 {\n width: 0.625em;\n}\n.svg-inline--fa.fa-w-11 {\n width: 0.6875em;\n}\n.svg-inline--fa.fa-w-12 {\n width: 0.75em;\n}\n.svg-inline--fa.fa-w-13 {\n width: 0.8125em;\n}\n.svg-inline--fa.fa-w-14 {\n width: 0.875em;\n}\n.svg-inline--fa.fa-w-15 {\n width: 0.9375em;\n}\n.svg-inline--fa.fa-w-16 {\n width: 1em;\n}\n.svg-inline--fa.fa-w-17 {\n width: 1.0625em;\n}\n.svg-inline--fa.fa-w-18 {\n width: 1.125em;\n}\n.svg-inline--fa.fa-w-19 {\n width: 1.1875em;\n}\n.svg-inline--fa.fa-w-20 {\n width: 1.25em;\n}\n.svg-inline--fa.fa-pull-left {\n margin-right: 0.3em;\n width: auto;\n}\n.svg-inline--fa.fa-pull-right {\n margin-left: 0.3em;\n width: auto;\n}\n.svg-inline--fa.fa-border {\n height: 1.5em;\n}\n.svg-inline--fa.fa-li {\n width: 2em;\n}\n.svg-inline--fa.fa-fw {\n width: 1.25em;\n}\n\n.fa-layers svg.svg-inline--fa {\n bottom: 0;\n left: 0;\n margin: auto;\n position: absolute;\n right: 0;\n top: 0;\n}\n\n.fa-layers {\n display: inline-block;\n height: 1em;\n position: relative;\n text-align: center;\n vertical-align: -0.125em;\n width: 1em;\n}\n.fa-layers svg.svg-inline--fa {\n -webkit-transform-origin: center center;\n transform-origin: center center;\n}\n\n.fa-layers-counter, .fa-layers-text {\n display: inline-block;\n position: absolute;\n text-align: center;\n}\n\n.fa-layers-text {\n left: 50%;\n top: 50%;\n -webkit-transform: translate(-50%, -50%);\n transform: translate(-50%, -50%);\n -webkit-transform-origin: center center;\n transform-origin: center center;\n}\n\n.fa-layers-counter {\n background-color: #ff253a;\n border-radius: 1em;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n color: #fff;\n height: 1.5em;\n line-height: 1;\n max-width: 5em;\n min-width: 1.5em;\n overflow: hidden;\n padding: 0.25em;\n right: 0;\n text-overflow: ellipsis;\n top: 0;\n -webkit-transform: scale(0.25);\n transform: scale(0.25);\n -webkit-transform-origin: top right;\n transform-origin: top right;\n}\n\n.fa-layers-bottom-right {\n bottom: 0;\n right: 0;\n top: auto;\n -webkit-transform: scale(0.25);\n transform: scale(0.25);\n -webkit-transform-origin: bottom right;\n transform-origin: bottom right;\n}\n\n.fa-layers-bottom-left {\n bottom: 0;\n left: 0;\n right: auto;\n top: auto;\n -webkit-transform: scale(0.25);\n transform: scale(0.25);\n -webkit-transform-origin: bottom left;\n transform-origin: bottom left;\n}\n\n.fa-layers-top-right {\n right: 0;\n top: 0;\n -webkit-transform: scale(0.25);\n transform: scale(0.25);\n -webkit-transform-origin: top right;\n transform-origin: top right;\n}\n\n.fa-layers-top-left {\n left: 0;\n right: auto;\n top: 0;\n -webkit-transform: scale(0.25);\n transform: scale(0.25);\n -webkit-transform-origin: top left;\n transform-origin: top left;\n}\n\n.fa-lg {\n font-size: 1.3333333333em;\n line-height: 0.75em;\n vertical-align: -0.0667em;\n}\n\n.fa-xs {\n font-size: 0.75em;\n}\n\n.fa-sm {\n font-size: 0.875em;\n}\n\n.fa-1x {\n font-size: 1em;\n}\n\n.fa-2x {\n font-size: 2em;\n}\n\n.fa-3x {\n font-size: 3em;\n}\n\n.fa-4x {\n font-size: 4em;\n}\n\n.fa-5x {\n font-size: 5em;\n}\n\n.fa-6x {\n font-size: 6em;\n}\n\n.fa-7x {\n font-size: 7em;\n}\n\n.fa-8x {\n font-size: 8em;\n}\n\n.fa-9x {\n font-size: 9em;\n}\n\n.fa-10x {\n font-size: 10em;\n}\n\n.fa-fw {\n text-align: center;\n width: 1.25em;\n}\n\n.fa-ul {\n list-style-type: none;\n margin-left: 2.5em;\n padding-left: 0;\n}\n.fa-ul > li {\n position: relative;\n}\n\n.fa-li {\n left: -2em;\n position: absolute;\n text-align: center;\n width: 2em;\n line-height: inherit;\n}\n\n.fa-border {\n border: solid 0.08em #eee;\n border-radius: 0.1em;\n padding: 0.2em 0.25em 0.15em;\n}\n\n.fa-pull-left {\n float: left;\n}\n\n.fa-pull-right {\n float: right;\n}\n\n.fa.fa-pull-left,\n.fas.fa-pull-left,\n.far.fa-pull-left,\n.fal.fa-pull-left,\n.fab.fa-pull-left {\n margin-right: 0.3em;\n}\n.fa.fa-pull-right,\n.fas.fa-pull-right,\n.far.fa-pull-right,\n.fal.fa-pull-right,\n.fab.fa-pull-right {\n margin-left: 0.3em;\n}\n\n.fa-spin {\n -webkit-animation: fa-spin 2s infinite linear;\n animation: fa-spin 2s infinite linear;\n}\n\n.fa-pulse {\n -webkit-animation: fa-spin 1s infinite steps(8);\n animation: fa-spin 1s infinite steps(8);\n}\n\n@-webkit-keyframes fa-spin {\n 0% {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n\n@keyframes fa-spin {\n 0% {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n.fa-rotate-90 {\n -ms-filter: \"progid:DXImageTransform.Microsoft.BasicImage(rotation=1)\";\n -webkit-transform: rotate(90deg);\n transform: rotate(90deg);\n}\n\n.fa-rotate-180 {\n -ms-filter: \"progid:DXImageTransform.Microsoft.BasicImage(rotation=2)\";\n -webkit-transform: rotate(180deg);\n transform: rotate(180deg);\n}\n\n.fa-rotate-270 {\n -ms-filter: \"progid:DXImageTransform.Microsoft.BasicImage(rotation=3)\";\n -webkit-transform: rotate(270deg);\n transform: rotate(270deg);\n}\n\n.fa-flip-horizontal {\n -ms-filter: \"progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1)\";\n -webkit-transform: scale(-1, 1);\n transform: scale(-1, 1);\n}\n\n.fa-flip-vertical {\n -ms-filter: \"progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)\";\n -webkit-transform: scale(1, -1);\n transform: scale(1, -1);\n}\n\n.fa-flip-both, .fa-flip-horizontal.fa-flip-vertical {\n -ms-filter: \"progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)\";\n -webkit-transform: scale(-1, -1);\n transform: scale(-1, -1);\n}\n\n:root .fa-rotate-90,\n:root .fa-rotate-180,\n:root .fa-rotate-270,\n:root .fa-flip-horizontal,\n:root .fa-flip-vertical,\n:root .fa-flip-both {\n -webkit-filter: none;\n filter: none;\n}\n\n.fa-stack {\n display: inline-block;\n height: 2em;\n position: relative;\n width: 2.5em;\n}\n\n.fa-stack-1x,\n.fa-stack-2x {\n bottom: 0;\n left: 0;\n margin: auto;\n position: absolute;\n right: 0;\n top: 0;\n}\n\n.svg-inline--fa.fa-stack-1x {\n height: 1em;\n width: 1.25em;\n}\n.svg-inline--fa.fa-stack-2x {\n height: 2em;\n width: 2.5em;\n}\n\n.fa-inverse {\n color: #fff;\n}\n\n.sr-only {\n border: 0;\n clip: rect(0, 0, 0, 0);\n height: 1px;\n margin: -1px;\n overflow: hidden;\n padding: 0;\n position: absolute;\n width: 1px;\n}\n\n.sr-only-focusable:active, .sr-only-focusable:focus {\n clip: auto;\n height: auto;\n margin: 0;\n overflow: visible;\n position: static;\n width: auto;\n}";
|
1994 |
|
1995 | function css () {
|
1996 | var dfp = DEFAULT_FAMILY_PREFIX;
|
1997 | var drc = DEFAULT_REPLACEMENT_CLASS;
|
1998 | var fp = config.familyPrefix;
|
1999 | var rc = config.replacementClass;
|
2000 | var s = baseStyles;
|
2001 |
|
2002 | if (fp !== dfp || rc !== drc) {
|
2003 | var dPatt = new RegExp("\\.".concat(dfp, "\\-"), 'g');
|
2004 | var rPatt = new RegExp("\\.".concat(drc), 'g');
|
2005 | s = s.replace(dPatt, ".".concat(fp, "-")).replace(rPatt, ".".concat(rc));
|
2006 | }
|
2007 |
|
2008 | return s;
|
2009 | }
|
2010 |
|
2011 | var Library =
|
2012 |
|
2013 | function () {
|
2014 | function Library() {
|
2015 | _classCallCheck(this, Library);
|
2016 |
|
2017 | this.definitions = {};
|
2018 | }
|
2019 |
|
2020 | _createClass(Library, [{
|
2021 | key: "add",
|
2022 | value: function add() {
|
2023 | var _this = this;
|
2024 |
|
2025 | for (var _len = arguments.length, definitions = new Array(_len), _key = 0; _key < _len; _key++) {
|
2026 | definitions[_key] = arguments[_key];
|
2027 | }
|
2028 |
|
2029 | var additions = definitions.reduce(this._pullDefinitions, {});
|
2030 | Object.keys(additions).forEach(function (key) {
|
2031 | _this.definitions[key] = _objectSpread({}, _this.definitions[key] || {}, additions[key]);
|
2032 | defineIcons(key, additions[key]);
|
2033 | build();
|
2034 | });
|
2035 | }
|
2036 | }, {
|
2037 | key: "reset",
|
2038 | value: function reset() {
|
2039 | this.definitions = {};
|
2040 | }
|
2041 | }, {
|
2042 | key: "_pullDefinitions",
|
2043 | value: function _pullDefinitions(additions, definition) {
|
2044 | var normalized = definition.prefix && definition.iconName && definition.icon ? {
|
2045 | 0: definition
|
2046 | } : definition;
|
2047 | Object.keys(normalized).map(function (key) {
|
2048 | var _normalized$key = normalized[key],
|
2049 | prefix = _normalized$key.prefix,
|
2050 | iconName = _normalized$key.iconName,
|
2051 | icon = _normalized$key.icon;
|
2052 | if (!additions[prefix]) additions[prefix] = {};
|
2053 | additions[prefix][iconName] = icon;
|
2054 | });
|
2055 | return additions;
|
2056 | }
|
2057 | }]);
|
2058 |
|
2059 | return Library;
|
2060 | }();
|
2061 |
|
2062 | function prepIcon(icon) {
|
2063 | var width = icon[0];
|
2064 | var height = icon[1];
|
2065 | var vectorData = icon.slice(4);
|
2066 | return {
|
2067 | found: true,
|
2068 | width: width,
|
2069 | height: height,
|
2070 | icon: {
|
2071 | tag: 'path',
|
2072 | attributes: {
|
2073 | fill: 'currentColor',
|
2074 | d: vectorData[0]
|
2075 | }
|
2076 | }
|
2077 | };
|
2078 | }
|
2079 |
|
2080 | function ensureCss() {
|
2081 | if (config.autoAddCss && !_cssInserted) {
|
2082 | insertCss(css());
|
2083 |
|
2084 | _cssInserted = true;
|
2085 | }
|
2086 | }
|
2087 |
|
2088 | function apiObject(val, abstractCreator) {
|
2089 | Object.defineProperty(val, 'abstract', {
|
2090 | get: abstractCreator
|
2091 | });
|
2092 | Object.defineProperty(val, 'html', {
|
2093 | get: function get() {
|
2094 | return val.abstract.map(function (a) {
|
2095 | return toHtml(a);
|
2096 | });
|
2097 | }
|
2098 | });
|
2099 | Object.defineProperty(val, 'node', {
|
2100 | get: function get() {
|
2101 | if (!IS_DOM) return;
|
2102 | var container = DOCUMENT.createElement('div');
|
2103 | container.innerHTML = val.html;
|
2104 | return container.children;
|
2105 | }
|
2106 | });
|
2107 | return val;
|
2108 | }
|
2109 |
|
2110 | function findIconDefinition(iconLookup) {
|
2111 | var _iconLookup$prefix = iconLookup.prefix,
|
2112 | prefix = _iconLookup$prefix === void 0 ? 'fa' : _iconLookup$prefix,
|
2113 | iconName = iconLookup.iconName;
|
2114 | if (!iconName) return;
|
2115 | return iconFromMapping(library.definitions, prefix, iconName) || iconFromMapping(namespace.styles, prefix, iconName);
|
2116 | }
|
2117 |
|
2118 | function resolveIcons(next) {
|
2119 | return function (maybeIconDefinition) {
|
2120 | var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
2121 | var iconDefinition = (maybeIconDefinition || {}).icon ? maybeIconDefinition : findIconDefinition(maybeIconDefinition || {});
|
2122 | var mask = params.mask;
|
2123 |
|
2124 | if (mask) {
|
2125 | mask = (mask || {}).icon ? mask : findIconDefinition(mask || {});
|
2126 | }
|
2127 |
|
2128 | return next(iconDefinition, _objectSpread({}, params, {
|
2129 | mask: mask
|
2130 | }));
|
2131 | };
|
2132 | }
|
2133 |
|
2134 | var library = new Library();
|
2135 | var noAuto = function noAuto() {
|
2136 | config.autoReplaceSvg = false;
|
2137 | config.observeMutations = false;
|
2138 | disconnect();
|
2139 | };
|
2140 | var _cssInserted = false;
|
2141 | var dom = {
|
2142 | i2svg: function i2svg() {
|
2143 | var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
2144 |
|
2145 | if (IS_DOM) {
|
2146 | ensureCss();
|
2147 | var _params$node = params.node,
|
2148 | node = _params$node === void 0 ? DOCUMENT : _params$node,
|
2149 | _params$callback = params.callback,
|
2150 | callback = _params$callback === void 0 ? function () {} : _params$callback;
|
2151 |
|
2152 | if (config.searchPseudoElements) {
|
2153 | searchPseudoElements(node);
|
2154 | }
|
2155 |
|
2156 | return onTree(node, callback);
|
2157 | } else {
|
2158 | return picked.reject('Operation requires a DOM of some kind.');
|
2159 | }
|
2160 | },
|
2161 | css: css,
|
2162 | insertCss: function insertCss$$1() {
|
2163 | if (!_cssInserted) {
|
2164 | insertCss(css());
|
2165 |
|
2166 | _cssInserted = true;
|
2167 | }
|
2168 | },
|
2169 | watch: function watch() {
|
2170 | var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
2171 | var autoReplaceSvgRoot = params.autoReplaceSvgRoot,
|
2172 | observeMutationsRoot = params.observeMutationsRoot;
|
2173 |
|
2174 | if (config.autoReplaceSvg === false) {
|
2175 | config.autoReplaceSvg = true;
|
2176 | }
|
2177 |
|
2178 | config.observeMutations = true;
|
2179 | domready(function () {
|
2180 | autoReplace({
|
2181 | autoReplaceSvgRoot: autoReplaceSvgRoot
|
2182 | });
|
2183 | observe({
|
2184 | treeCallback: onTree,
|
2185 | nodeCallback: onNode,
|
2186 | pseudoElementsCallback: searchPseudoElements,
|
2187 | observeMutationsRoot: observeMutationsRoot
|
2188 | });
|
2189 | });
|
2190 | }
|
2191 | };
|
2192 | var parse = {
|
2193 | transform: function transform(transformString) {
|
2194 | return parseTransformString(transformString);
|
2195 | }
|
2196 | };
|
2197 | var icon = resolveIcons(function (iconDefinition) {
|
2198 | var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
2199 | var _params$transform = params.transform,
|
2200 | transform = _params$transform === void 0 ? meaninglessTransform : _params$transform,
|
2201 | _params$symbol = params.symbol,
|
2202 | symbol = _params$symbol === void 0 ? false : _params$symbol,
|
2203 | _params$mask = params.mask,
|
2204 | mask = _params$mask === void 0 ? null : _params$mask,
|
2205 | _params$title = params.title,
|
2206 | title = _params$title === void 0 ? null : _params$title,
|
2207 | _params$classes = params.classes,
|
2208 | classes = _params$classes === void 0 ? [] : _params$classes,
|
2209 | _params$attributes = params.attributes,
|
2210 | attributes = _params$attributes === void 0 ? {} : _params$attributes,
|
2211 | _params$styles = params.styles,
|
2212 | styles = _params$styles === void 0 ? {} : _params$styles;
|
2213 | if (!iconDefinition) return;
|
2214 | var prefix = iconDefinition.prefix,
|
2215 | iconName = iconDefinition.iconName,
|
2216 | icon = iconDefinition.icon;
|
2217 | return apiObject(_objectSpread({
|
2218 | type: 'icon'
|
2219 | }, iconDefinition), function () {
|
2220 | ensureCss();
|
2221 |
|
2222 | if (config.autoA11y) {
|
2223 | if (title) {
|
2224 | attributes['aria-labelledby'] = "".concat(config.replacementClass, "-title-").concat(nextUniqueId());
|
2225 | } else {
|
2226 | attributes['aria-hidden'] = 'true';
|
2227 | attributes['focusable'] = 'false';
|
2228 | }
|
2229 | }
|
2230 |
|
2231 | return makeInlineSvgAbstract({
|
2232 | icons: {
|
2233 | main: prepIcon(icon),
|
2234 | mask: mask ? prepIcon(mask.icon) : {
|
2235 | found: false,
|
2236 | width: null,
|
2237 | height: null,
|
2238 | icon: {}
|
2239 | }
|
2240 | },
|
2241 | prefix: prefix,
|
2242 | iconName: iconName,
|
2243 | transform: _objectSpread({}, meaninglessTransform, transform),
|
2244 | symbol: symbol,
|
2245 | title: title,
|
2246 | extra: {
|
2247 | attributes: attributes,
|
2248 | styles: styles,
|
2249 | classes: classes
|
2250 | }
|
2251 | });
|
2252 | });
|
2253 | });
|
2254 | var text = function text(content) {
|
2255 | var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
2256 | var _params$transform2 = params.transform,
|
2257 | transform = _params$transform2 === void 0 ? meaninglessTransform : _params$transform2,
|
2258 | _params$title2 = params.title,
|
2259 | title = _params$title2 === void 0 ? null : _params$title2,
|
2260 | _params$classes2 = params.classes,
|
2261 | classes = _params$classes2 === void 0 ? [] : _params$classes2,
|
2262 | _params$attributes2 = params.attributes,
|
2263 | attributes = _params$attributes2 === void 0 ? {} : _params$attributes2,
|
2264 | _params$styles2 = params.styles,
|
2265 | styles = _params$styles2 === void 0 ? {} : _params$styles2;
|
2266 | return apiObject({
|
2267 | type: 'text',
|
2268 | content: content
|
2269 | }, function () {
|
2270 | ensureCss();
|
2271 | return makeLayersTextAbstract({
|
2272 | content: content,
|
2273 | transform: _objectSpread({}, meaninglessTransform, transform),
|
2274 | title: title,
|
2275 | extra: {
|
2276 | attributes: attributes,
|
2277 | styles: styles,
|
2278 | classes: ["".concat(config.familyPrefix, "-layers-text")].concat(_toConsumableArray(classes))
|
2279 | }
|
2280 | });
|
2281 | });
|
2282 | };
|
2283 | var counter = function counter(content) {
|
2284 | var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
2285 | var _params$title3 = params.title,
|
2286 | title = _params$title3 === void 0 ? null : _params$title3,
|
2287 | _params$classes3 = params.classes,
|
2288 | classes = _params$classes3 === void 0 ? [] : _params$classes3,
|
2289 | _params$attributes3 = params.attributes,
|
2290 | attributes = _params$attributes3 === void 0 ? {} : _params$attributes3,
|
2291 | _params$styles3 = params.styles,
|
2292 | styles = _params$styles3 === void 0 ? {} : _params$styles3;
|
2293 | return apiObject({
|
2294 | type: 'counter',
|
2295 | content: content
|
2296 | }, function () {
|
2297 | ensureCss();
|
2298 | return makeLayersCounterAbstract({
|
2299 | content: content.toString(),
|
2300 | title: title,
|
2301 | extra: {
|
2302 | attributes: attributes,
|
2303 | styles: styles,
|
2304 | classes: ["".concat(config.familyPrefix, "-layers-counter")].concat(_toConsumableArray(classes))
|
2305 | }
|
2306 | });
|
2307 | });
|
2308 | };
|
2309 | var layer = function layer(assembler) {
|
2310 | return apiObject({
|
2311 | type: 'layer'
|
2312 | }, function () {
|
2313 | ensureCss();
|
2314 | var children = [];
|
2315 | assembler(function (args) {
|
2316 | Array.isArray(args) ? args.map(function (a) {
|
2317 | children = children.concat(a.abstract);
|
2318 | }) : children = children.concat(args.abstract);
|
2319 | });
|
2320 | return [{
|
2321 | tag: 'span',
|
2322 | attributes: {
|
2323 | class: "".concat(config.familyPrefix, "-layers")
|
2324 | },
|
2325 | children: children
|
2326 | }];
|
2327 | });
|
2328 | };
|
2329 | var api = {
|
2330 | noAuto: noAuto,
|
2331 | config: config,
|
2332 | dom: dom,
|
2333 | library: library,
|
2334 | parse: parse,
|
2335 | findIconDefinition: findIconDefinition,
|
2336 | icon: icon,
|
2337 | text: text,
|
2338 | counter: counter,
|
2339 | layer: layer,
|
2340 | toHtml: toHtml
|
2341 | };
|
2342 |
|
2343 | var autoReplace = function autoReplace() {
|
2344 | var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
2345 | var _params$autoReplaceSv = params.autoReplaceSvgRoot,
|
2346 | autoReplaceSvgRoot = _params$autoReplaceSv === void 0 ? DOCUMENT : _params$autoReplaceSv;
|
2347 | if ((Object.keys(namespace.styles).length > 0 || config.autoFetchSvg) && IS_DOM && config.autoReplaceSvg) api.dom.i2svg({
|
2348 | node: autoReplaceSvgRoot
|
2349 | });
|
2350 | };
|
2351 |
|
2352 | export { icon, noAuto, config, toHtml, layer, text, counter, library, dom, parse, findIconDefinition };
|