fontawesome.js 77 KB

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