You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2539 lines
79 KiB

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