main.js 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410
  1. /******/ (function(modules) { // webpackBootstrap
  2. /******/ // The module cache
  3. /******/ var installedModules = {};
  4. /******/
  5. /******/ // The require function
  6. /******/ function __webpack_require__(moduleId) {
  7. /******/
  8. /******/ // Check if module is in cache
  9. /******/ if(installedModules[moduleId]) {
  10. /******/ return installedModules[moduleId].exports;
  11. /******/ }
  12. /******/ // Create a new module (and put it into the cache)
  13. /******/ var module = installedModules[moduleId] = {
  14. /******/ i: moduleId,
  15. /******/ l: false,
  16. /******/ exports: {}
  17. /******/ };
  18. /******/
  19. /******/ // Execute the module function
  20. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  21. /******/
  22. /******/ // Flag the module as loaded
  23. /******/ module.l = true;
  24. /******/
  25. /******/ // Return the exports of the module
  26. /******/ return module.exports;
  27. /******/ }
  28. /******/
  29. /******/
  30. /******/ // expose the modules object (__webpack_modules__)
  31. /******/ __webpack_require__.m = modules;
  32. /******/
  33. /******/ // expose the module cache
  34. /******/ __webpack_require__.c = installedModules;
  35. /******/
  36. /******/ // define getter function for harmony exports
  37. /******/ __webpack_require__.d = function(exports, name, getter) {
  38. /******/ if(!__webpack_require__.o(exports, name)) {
  39. /******/ Object.defineProperty(exports, name, {
  40. /******/ configurable: false,
  41. /******/ enumerable: true,
  42. /******/ get: getter
  43. /******/ });
  44. /******/ }
  45. /******/ };
  46. /******/
  47. /******/ // getDefaultExport function for compatibility with non-harmony modules
  48. /******/ __webpack_require__.n = function(module) {
  49. /******/ var getter = module && module.__esModule ?
  50. /******/ function getDefault() { return module['default']; } :
  51. /******/ function getModuleExports() { return module; };
  52. /******/ __webpack_require__.d(getter, 'a', getter);
  53. /******/ return getter;
  54. /******/ };
  55. /******/
  56. /******/ // Object.prototype.hasOwnProperty.call
  57. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  58. /******/
  59. /******/ // __webpack_public_path__
  60. /******/ __webpack_require__.p = "";
  61. /******/
  62. /******/ // Load entry module and return exports
  63. /******/ return __webpack_require__(__webpack_require__.s = 1);
  64. /******/ })
  65. /************************************************************************/
  66. /******/ ([
  67. /* 0 */
  68. /***/ (function(module, exports) {
  69. var g;
  70. // This works in non-strict mode
  71. g = (function() {
  72. return this;
  73. })();
  74. try {
  75. // This works if eval is allowed (see CSP)
  76. g = g || Function("return this")() || (1,eval)("this");
  77. } catch(e) {
  78. // This works if the window reference is available
  79. if(typeof window === "object")
  80. g = window;
  81. }
  82. // g can still be undefined, but nothing to do about it...
  83. // We return undefined, instead of nothing here, so it's
  84. // easier to handle this case. if(!global) { ...}
  85. module.exports = g;
  86. /***/ }),
  87. /* 1 */
  88. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89. "use strict";
  90. Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
  91. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__assets_twitter_svg__ = __webpack_require__(2);
  92. /***/ }),
  93. /* 2 */
  94. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95. "use strict";
  96. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_svg_baker_runtime_browser_symbol__ = __webpack_require__(3);
  97. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_svg_baker_runtime_browser_symbol___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_svg_baker_runtime_browser_symbol__);
  98. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_svg_sprite_loader_runtime_browser_sprite_build__ = __webpack_require__(4);
  99. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_svg_sprite_loader_runtime_browser_sprite_build___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_svg_sprite_loader_runtime_browser_sprite_build__);
  100. var symbol = new __WEBPACK_IMPORTED_MODULE_0_svg_baker_runtime_browser_symbol___default.a({
  101. "id": "twitter",
  102. "use": "twitter-usage",
  103. "viewBox": "0 0 273.4 222.2",
  104. "content": "<symbol viewBox=\"0 0 273.4 222.2\" id=\"twitter\"><path d=\"M273.4 26.3c-10.1 4.5-20.9 7.5-32.2 8.8 11.6-6.9 20.5-17.9 24.7-31-10.9 6.4-22.9 11.1-35.7 13.6A55.919 55.919 0 0 0 189.3 0c-31 0-56.1 25.1-56.1 56.1 0 4.4.5 8.7 1.5 12.8C88 66.5 46.7 44.2 19 10.3c-4.8 8.3-7.6 17.9-7.6 28.2 0 19.5 9.9 36.6 25 46.7-9.2-.3-17.8-2.8-25.4-7v.7c0 27.2 19.3 49.8 45 55-4.7 1.3-9.7 2-14.8 2-3.6 0-7.1-.4-10.6-1 7.1 22.3 27.9 38.5 52.4 39-19.2 15-43.4 24-69.7 24-4.5 0-9-.3-13.4-.8 24.8 15.9 54.3 25.2 86 25.2 103.2 0 159.6-85.5 159.6-159.6 0-2.4-.1-4.9-.2-7.3 11.1-8 20.6-17.9 28.1-29.1z\" /></symbol>"
  105. });
  106. var result = __WEBPACK_IMPORTED_MODULE_1_svg_sprite_loader_runtime_browser_sprite_build___default.a.add(symbol);
  107. /* unused harmony default export */ var _unused_webpack_default_export = (symbol);
  108. /***/ }),
  109. /* 3 */
  110. /***/ (function(module, exports, __webpack_require__) {
  111. /* WEBPACK VAR INJECTION */(function(global) {(function (global, factory) {
  112. true ? module.exports = factory() :
  113. typeof define === 'function' && define.amd ? define(factory) :
  114. (global.BrowserSpriteSymbol = factory());
  115. }(this, (function () { 'use strict';
  116. var SpriteSymbol = function SpriteSymbol(ref) {
  117. var id = ref.id;
  118. var viewBox = ref.viewBox;
  119. var content = ref.content;
  120. this.id = id;
  121. this.viewBox = viewBox;
  122. this.content = content;
  123. };
  124. /**
  125. * @return {string}
  126. */
  127. SpriteSymbol.prototype.stringify = function stringify () {
  128. return this.content;
  129. };
  130. /**
  131. * @return {string}
  132. */
  133. SpriteSymbol.prototype.toString = function toString () {
  134. return this.stringify();
  135. };
  136. SpriteSymbol.prototype.destroy = function destroy () {
  137. var this$1 = this;
  138. ['id', 'viewBox', 'content'].forEach(function (prop) { return delete this$1[prop]; });
  139. };
  140. /**
  141. * @param {string} content
  142. * @return {Element}
  143. */
  144. var parse = function (content) {
  145. var hasImportNode = !!document.importNode;
  146. var doc = new DOMParser().parseFromString(content, 'image/svg+xml').documentElement;
  147. /**
  148. * Fix for browser which are throwing WrongDocumentError
  149. * if you insert an element which is not part of the document
  150. * @see http://stackoverflow.com/a/7986519/4624403
  151. */
  152. if (hasImportNode) {
  153. return document.importNode(doc, true);
  154. }
  155. return doc;
  156. };
  157. var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  158. function createCommonjsModule(fn, module) {
  159. return module = { exports: {} }, fn(module, module.exports), module.exports;
  160. }
  161. var index = createCommonjsModule(function (module, exports) {
  162. (function (root, factory) {
  163. if (false) {
  164. undefined(factory);
  165. } else {
  166. module.exports = factory();
  167. }
  168. }(commonjsGlobal, function () {
  169. function isMergeableObject(val) {
  170. var nonNullObject = val && typeof val === 'object';
  171. return nonNullObject
  172. && Object.prototype.toString.call(val) !== '[object RegExp]'
  173. && Object.prototype.toString.call(val) !== '[object Date]'
  174. }
  175. function emptyTarget(val) {
  176. return Array.isArray(val) ? [] : {}
  177. }
  178. function cloneIfNecessary(value, optionsArgument) {
  179. var clone = optionsArgument && optionsArgument.clone === true;
  180. return (clone && isMergeableObject(value)) ? deepmerge(emptyTarget(value), value, optionsArgument) : value
  181. }
  182. function defaultArrayMerge(target, source, optionsArgument) {
  183. var destination = target.slice();
  184. source.forEach(function(e, i) {
  185. if (typeof destination[i] === 'undefined') {
  186. destination[i] = cloneIfNecessary(e, optionsArgument);
  187. } else if (isMergeableObject(e)) {
  188. destination[i] = deepmerge(target[i], e, optionsArgument);
  189. } else if (target.indexOf(e) === -1) {
  190. destination.push(cloneIfNecessary(e, optionsArgument));
  191. }
  192. });
  193. return destination
  194. }
  195. function mergeObject(target, source, optionsArgument) {
  196. var destination = {};
  197. if (isMergeableObject(target)) {
  198. Object.keys(target).forEach(function (key) {
  199. destination[key] = cloneIfNecessary(target[key], optionsArgument);
  200. });
  201. }
  202. Object.keys(source).forEach(function (key) {
  203. if (!isMergeableObject(source[key]) || !target[key]) {
  204. destination[key] = cloneIfNecessary(source[key], optionsArgument);
  205. } else {
  206. destination[key] = deepmerge(target[key], source[key], optionsArgument);
  207. }
  208. });
  209. return destination
  210. }
  211. function deepmerge(target, source, optionsArgument) {
  212. var array = Array.isArray(source);
  213. var options = optionsArgument || { arrayMerge: defaultArrayMerge };
  214. var arrayMerge = options.arrayMerge || defaultArrayMerge;
  215. if (array) {
  216. return Array.isArray(target) ? arrayMerge(target, source, optionsArgument) : cloneIfNecessary(source, optionsArgument)
  217. } else {
  218. return mergeObject(target, source, optionsArgument)
  219. }
  220. }
  221. deepmerge.all = function deepmergeAll(array, optionsArgument) {
  222. if (!Array.isArray(array) || array.length < 2) {
  223. throw new Error('first argument should be an array with at least two elements')
  224. }
  225. // we are sure there are at least 2 values, so it is safe to have no initial value
  226. return array.reduce(function(prev, next) {
  227. return deepmerge(prev, next, optionsArgument)
  228. })
  229. };
  230. return deepmerge
  231. }));
  232. });
  233. var namespaces_1 = createCommonjsModule(function (module, exports) {
  234. var namespaces = {
  235. svg: {
  236. name: 'xmlns',
  237. uri: 'http://www.w3.org/2000/svg'
  238. },
  239. xlink: {
  240. name: 'xmlns:xlink',
  241. uri: 'http://www.w3.org/1999/xlink'
  242. }
  243. };
  244. exports.default = namespaces;
  245. module.exports = exports.default;
  246. });
  247. /**
  248. * @param {Object} attrs
  249. * @return {string}
  250. */
  251. var objectToAttrsString = function (attrs) {
  252. return Object.keys(attrs).map(function (attr) {
  253. var value = attrs[attr].toString().replace(/"/g, '&quot;');
  254. return (attr + "=\"" + value + "\"");
  255. }).join(' ');
  256. };
  257. var svg = namespaces_1.svg;
  258. var xlink = namespaces_1.xlink;
  259. var defaultAttrs = {};
  260. defaultAttrs[svg.name] = svg.uri;
  261. defaultAttrs[xlink.name] = xlink.uri;
  262. /**
  263. * @param {string} [content]
  264. * @param {Object} [attributes]
  265. * @return {string}
  266. */
  267. var wrapInSvgString = function (content, attributes) {
  268. if ( content === void 0 ) content = '';
  269. var attrs = index(defaultAttrs, attributes || {});
  270. var attrsRendered = objectToAttrsString(attrs);
  271. return ("<svg " + attrsRendered + ">" + content + "</svg>");
  272. };
  273. var BrowserSpriteSymbol = (function (SpriteSymbol$$1) {
  274. function BrowserSpriteSymbol () {
  275. SpriteSymbol$$1.apply(this, arguments);
  276. }
  277. if ( SpriteSymbol$$1 ) BrowserSpriteSymbol.__proto__ = SpriteSymbol$$1;
  278. BrowserSpriteSymbol.prototype = Object.create( SpriteSymbol$$1 && SpriteSymbol$$1.prototype );
  279. BrowserSpriteSymbol.prototype.constructor = BrowserSpriteSymbol;
  280. var prototypeAccessors = { isMounted: {} };
  281. prototypeAccessors.isMounted.get = function () {
  282. return !!this.node;
  283. };
  284. /**
  285. * @param {Element} node
  286. * @return {BrowserSpriteSymbol}
  287. */
  288. BrowserSpriteSymbol.createFromExistingNode = function createFromExistingNode (node) {
  289. return new BrowserSpriteSymbol({
  290. id: node.getAttribute('id'),
  291. viewBox: node.getAttribute('viewBox'),
  292. content: node.outerHTML
  293. });
  294. };
  295. BrowserSpriteSymbol.prototype.destroy = function destroy () {
  296. if (this.isMounted) {
  297. this.unmount();
  298. }
  299. SpriteSymbol$$1.prototype.destroy.call(this);
  300. };
  301. /**
  302. * @param {Element|string} target
  303. * @return {Element}
  304. */
  305. BrowserSpriteSymbol.prototype.mount = function mount (target) {
  306. if (this.isMounted) {
  307. return this.node;
  308. }
  309. var mountTarget = typeof target === 'string' ? document.querySelector(target) : target;
  310. var node = this.render();
  311. this.node = node;
  312. mountTarget.appendChild(node);
  313. return node;
  314. };
  315. /**
  316. * @return {Element}
  317. */
  318. BrowserSpriteSymbol.prototype.render = function render () {
  319. var content = this.stringify();
  320. return parse(wrapInSvgString(content)).childNodes[0];
  321. };
  322. BrowserSpriteSymbol.prototype.unmount = function unmount () {
  323. this.node.parentNode.removeChild(this.node);
  324. };
  325. Object.defineProperties( BrowserSpriteSymbol.prototype, prototypeAccessors );
  326. return BrowserSpriteSymbol;
  327. }(SpriteSymbol));
  328. return BrowserSpriteSymbol;
  329. })));
  330. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
  331. /***/ }),
  332. /* 4 */
  333. /***/ (function(module, exports, __webpack_require__) {
  334. /* WEBPACK VAR INJECTION */(function(global) {(function (global, factory) {
  335. true ? module.exports = factory() :
  336. typeof define === 'function' && define.amd ? define(factory) :
  337. (global.BrowserSprite = factory());
  338. }(this, (function () { 'use strict';
  339. var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  340. function createCommonjsModule(fn, module) {
  341. return module = { exports: {} }, fn(module, module.exports), module.exports;
  342. }
  343. var deepmerge = createCommonjsModule(function (module, exports) {
  344. (function (root, factory) {
  345. if (false) {
  346. undefined(factory);
  347. } else {
  348. module.exports = factory();
  349. }
  350. }(commonjsGlobal, function () {
  351. function isMergeableObject(val) {
  352. var nonNullObject = val && typeof val === 'object';
  353. return nonNullObject
  354. && Object.prototype.toString.call(val) !== '[object RegExp]'
  355. && Object.prototype.toString.call(val) !== '[object Date]'
  356. }
  357. function emptyTarget(val) {
  358. return Array.isArray(val) ? [] : {}
  359. }
  360. function cloneIfNecessary(value, optionsArgument) {
  361. var clone = optionsArgument && optionsArgument.clone === true;
  362. return (clone && isMergeableObject(value)) ? deepmerge(emptyTarget(value), value, optionsArgument) : value
  363. }
  364. function defaultArrayMerge(target, source, optionsArgument) {
  365. var destination = target.slice();
  366. source.forEach(function(e, i) {
  367. if (typeof destination[i] === 'undefined') {
  368. destination[i] = cloneIfNecessary(e, optionsArgument);
  369. } else if (isMergeableObject(e)) {
  370. destination[i] = deepmerge(target[i], e, optionsArgument);
  371. } else if (target.indexOf(e) === -1) {
  372. destination.push(cloneIfNecessary(e, optionsArgument));
  373. }
  374. });
  375. return destination
  376. }
  377. function mergeObject(target, source, optionsArgument) {
  378. var destination = {};
  379. if (isMergeableObject(target)) {
  380. Object.keys(target).forEach(function (key) {
  381. destination[key] = cloneIfNecessary(target[key], optionsArgument);
  382. });
  383. }
  384. Object.keys(source).forEach(function (key) {
  385. if (!isMergeableObject(source[key]) || !target[key]) {
  386. destination[key] = cloneIfNecessary(source[key], optionsArgument);
  387. } else {
  388. destination[key] = deepmerge(target[key], source[key], optionsArgument);
  389. }
  390. });
  391. return destination
  392. }
  393. function deepmerge(target, source, optionsArgument) {
  394. var array = Array.isArray(source);
  395. var options = optionsArgument || { arrayMerge: defaultArrayMerge };
  396. var arrayMerge = options.arrayMerge || defaultArrayMerge;
  397. if (array) {
  398. return Array.isArray(target) ? arrayMerge(target, source, optionsArgument) : cloneIfNecessary(source, optionsArgument)
  399. } else {
  400. return mergeObject(target, source, optionsArgument)
  401. }
  402. }
  403. deepmerge.all = function deepmergeAll(array, optionsArgument) {
  404. if (!Array.isArray(array) || array.length < 2) {
  405. throw new Error('first argument should be an array with at least two elements')
  406. }
  407. // we are sure there are at least 2 values, so it is safe to have no initial value
  408. return array.reduce(function(prev, next) {
  409. return deepmerge(prev, next, optionsArgument)
  410. })
  411. };
  412. return deepmerge
  413. }));
  414. });
  415. //
  416. // An event handler can take an optional event argument
  417. // and should not return a value
  418. // An array of all currently registered event handlers for a type
  419. // A map of event types and their corresponding event handlers.
  420. /** Mitt: Tiny (~200b) functional event emitter / pubsub.
  421. * @name mitt
  422. * @returns {Mitt}
  423. */
  424. function mitt(all ) {
  425. all = all || Object.create(null);
  426. return {
  427. /**
  428. * Register an event handler for the given type.
  429. *
  430. * @param {String} type Type of event to listen for, or `"*"` for all events
  431. * @param {Function} handler Function to call in response to given event
  432. * @memberOf mitt
  433. */
  434. on: function on(type , handler ) {
  435. (all[type] || (all[type] = [])).push(handler);
  436. },
  437. /**
  438. * Remove an event handler for the given type.
  439. *
  440. * @param {String} type Type of event to unregister `handler` from, or `"*"`
  441. * @param {Function} handler Handler function to remove
  442. * @memberOf mitt
  443. */
  444. off: function off(type , handler ) {
  445. if (all[type]) {
  446. all[type].splice(all[type].indexOf(handler) >>> 0, 1);
  447. }
  448. },
  449. /**
  450. * Invoke all handlers for the given type.
  451. * If present, `"*"` handlers are invoked after type-matched handlers.
  452. *
  453. * @param {String} type The event type to invoke
  454. * @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler
  455. * @memberof mitt
  456. */
  457. emit: function emit(type , evt ) {
  458. (all[type] || []).map(function (handler) { handler(evt); });
  459. (all['*'] || []).map(function (handler) { handler(type, evt); });
  460. }
  461. };
  462. }
  463. var namespaces_1 = createCommonjsModule(function (module, exports) {
  464. var namespaces = {
  465. svg: {
  466. name: 'xmlns',
  467. uri: 'http://www.w3.org/2000/svg'
  468. },
  469. xlink: {
  470. name: 'xmlns:xlink',
  471. uri: 'http://www.w3.org/1999/xlink'
  472. }
  473. };
  474. exports.default = namespaces;
  475. module.exports = exports.default;
  476. });
  477. /**
  478. * @param {Object} attrs
  479. * @return {string}
  480. */
  481. var objectToAttrsString = function (attrs) {
  482. return Object.keys(attrs).map(function (attr) {
  483. var value = attrs[attr].toString().replace(/"/g, '&quot;');
  484. return (attr + "=\"" + value + "\"");
  485. }).join(' ');
  486. };
  487. var svg = namespaces_1.svg;
  488. var xlink = namespaces_1.xlink;
  489. var defaultAttrs = {};
  490. defaultAttrs[svg.name] = svg.uri;
  491. defaultAttrs[xlink.name] = xlink.uri;
  492. /**
  493. * @param {string} [content]
  494. * @param {Object} [attributes]
  495. * @return {string}
  496. */
  497. var wrapInSvgString = function (content, attributes) {
  498. if ( content === void 0 ) content = '';
  499. var attrs = deepmerge(defaultAttrs, attributes || {});
  500. var attrsRendered = objectToAttrsString(attrs);
  501. return ("<svg " + attrsRendered + ">" + content + "</svg>");
  502. };
  503. var svg$1 = namespaces_1.svg;
  504. var xlink$1 = namespaces_1.xlink;
  505. var defaultConfig = {
  506. attrs: ( obj = {
  507. style: ['position: absolute', 'width: 0', 'height: 0'].join('; ')
  508. }, obj[svg$1.name] = svg$1.uri, obj[xlink$1.name] = xlink$1.uri, obj )
  509. };
  510. var obj;
  511. var Sprite = function Sprite(config) {
  512. this.config = deepmerge(defaultConfig, config || {});
  513. this.symbols = [];
  514. };
  515. /**
  516. * Add new symbol. If symbol with the same id exists it will be replaced.
  517. * @param {SpriteSymbol} symbol
  518. * @return {boolean} `true` - symbol was added, `false` - replaced
  519. */
  520. Sprite.prototype.add = function add (symbol) {
  521. var ref = this;
  522. var symbols = ref.symbols;
  523. var existing = this.find(symbol.id);
  524. if (existing) {
  525. symbols[symbols.indexOf(existing)] = symbol;
  526. return false;
  527. }
  528. symbols.push(symbol);
  529. return true;
  530. };
  531. /**
  532. * Remove symbol & destroy it
  533. * @param {string} id
  534. * @return {boolean} `true` - symbol was found & successfully destroyed, `false` - otherwise
  535. */
  536. Sprite.prototype.remove = function remove (id) {
  537. var ref = this;
  538. var symbols = ref.symbols;
  539. var symbol = this.find(id);
  540. if (symbol) {
  541. symbols.splice(symbols.indexOf(symbol), 1);
  542. symbol.destroy();
  543. return true;
  544. }
  545. return false;
  546. };
  547. /**
  548. * @param {string} id
  549. * @return {SpriteSymbol|null}
  550. */
  551. Sprite.prototype.find = function find (id) {
  552. return this.symbols.filter(function (s) { return s.id === id; })[0] || null;
  553. };
  554. /**
  555. * @param {string} id
  556. * @return {boolean}
  557. */
  558. Sprite.prototype.has = function has (id) {
  559. return this.find(id) !== null;
  560. };
  561. /**
  562. * @return {string}
  563. */
  564. Sprite.prototype.stringify = function stringify () {
  565. var ref = this.config;
  566. var attrs = ref.attrs;
  567. var stringifiedSymbols = this.symbols.map(function (s) { return s.stringify(); }).join('');
  568. return wrapInSvgString(stringifiedSymbols, attrs);
  569. };
  570. /**
  571. * @return {string}
  572. */
  573. Sprite.prototype.toString = function toString () {
  574. return this.stringify();
  575. };
  576. Sprite.prototype.destroy = function destroy () {
  577. this.symbols.forEach(function (s) { return s.destroy(); });
  578. };
  579. var SpriteSymbol = function SpriteSymbol(ref) {
  580. var id = ref.id;
  581. var viewBox = ref.viewBox;
  582. var content = ref.content;
  583. this.id = id;
  584. this.viewBox = viewBox;
  585. this.content = content;
  586. };
  587. /**
  588. * @return {string}
  589. */
  590. SpriteSymbol.prototype.stringify = function stringify () {
  591. return this.content;
  592. };
  593. /**
  594. * @return {string}
  595. */
  596. SpriteSymbol.prototype.toString = function toString () {
  597. return this.stringify();
  598. };
  599. SpriteSymbol.prototype.destroy = function destroy () {
  600. var this$1 = this;
  601. ['id', 'viewBox', 'content'].forEach(function (prop) { return delete this$1[prop]; });
  602. };
  603. /**
  604. * @param {string} content
  605. * @return {Element}
  606. */
  607. var parse = function (content) {
  608. var hasImportNode = !!document.importNode;
  609. var doc = new DOMParser().parseFromString(content, 'image/svg+xml').documentElement;
  610. /**
  611. * Fix for browser which are throwing WrongDocumentError
  612. * if you insert an element which is not part of the document
  613. * @see http://stackoverflow.com/a/7986519/4624403
  614. */
  615. if (hasImportNode) {
  616. return document.importNode(doc, true);
  617. }
  618. return doc;
  619. };
  620. var BrowserSpriteSymbol = (function (SpriteSymbol$$1) {
  621. function BrowserSpriteSymbol () {
  622. SpriteSymbol$$1.apply(this, arguments);
  623. }
  624. if ( SpriteSymbol$$1 ) BrowserSpriteSymbol.__proto__ = SpriteSymbol$$1;
  625. BrowserSpriteSymbol.prototype = Object.create( SpriteSymbol$$1 && SpriteSymbol$$1.prototype );
  626. BrowserSpriteSymbol.prototype.constructor = BrowserSpriteSymbol;
  627. var prototypeAccessors = { isMounted: {} };
  628. prototypeAccessors.isMounted.get = function () {
  629. return !!this.node;
  630. };
  631. /**
  632. * @param {Element} node
  633. * @return {BrowserSpriteSymbol}
  634. */
  635. BrowserSpriteSymbol.createFromExistingNode = function createFromExistingNode (node) {
  636. return new BrowserSpriteSymbol({
  637. id: node.getAttribute('id'),
  638. viewBox: node.getAttribute('viewBox'),
  639. content: node.outerHTML
  640. });
  641. };
  642. BrowserSpriteSymbol.prototype.destroy = function destroy () {
  643. if (this.isMounted) {
  644. this.unmount();
  645. }
  646. SpriteSymbol$$1.prototype.destroy.call(this);
  647. };
  648. /**
  649. * @param {Element|string} target
  650. * @return {Element}
  651. */
  652. BrowserSpriteSymbol.prototype.mount = function mount (target) {
  653. if (this.isMounted) {
  654. return this.node;
  655. }
  656. var mountTarget = typeof target === 'string' ? document.querySelector(target) : target;
  657. var node = this.render();
  658. this.node = node;
  659. mountTarget.appendChild(node);
  660. return node;
  661. };
  662. /**
  663. * @return {Element}
  664. */
  665. BrowserSpriteSymbol.prototype.render = function render () {
  666. var content = this.stringify();
  667. return parse(wrapInSvgString(content)).childNodes[0];
  668. };
  669. BrowserSpriteSymbol.prototype.unmount = function unmount () {
  670. this.node.parentNode.removeChild(this.node);
  671. };
  672. Object.defineProperties( BrowserSpriteSymbol.prototype, prototypeAccessors );
  673. return BrowserSpriteSymbol;
  674. }(SpriteSymbol));
  675. var defaultConfig$1 = {
  676. /**
  677. * Should following options be automatically configured:
  678. * - `syncUrlsWithBaseTag`
  679. * - `locationChangeAngularEmitter`
  680. * - `moveGradientsOutsideSymbol`
  681. * @type {boolean}
  682. */
  683. autoConfigure: true,
  684. /**
  685. * Default mounting selector
  686. * @type {string}
  687. */
  688. mountTo: 'body',
  689. /**
  690. * Fix disappearing SVG elements when <base href> exists.
  691. * Executes when sprite mounted.
  692. * @see http://stackoverflow.com/a/18265336/796152
  693. * @see https://github.com/everdimension/angular-svg-base-fix
  694. * @see https://github.com/angular/angular.js/issues/8934#issuecomment-56568466
  695. * @type {boolean}
  696. */
  697. syncUrlsWithBaseTag: false,
  698. /**
  699. * Should sprite listen custom location change event
  700. * @type {boolean}
  701. */
  702. listenLocationChangeEvent: true,
  703. /**
  704. * Custom window event name which should be emitted to update sprite urls
  705. * @type {string}
  706. */
  707. locationChangeEvent: 'locationChange',
  708. /**
  709. * Emit location change event in Angular automatically
  710. * @type {boolean}
  711. */
  712. locationChangeAngularEmitter: false,
  713. /**
  714. * Selector to find symbols usages when updating sprite urls
  715. * @type {string}
  716. */
  717. usagesToUpdate: 'use[*|href]',
  718. /**
  719. * Fix Firefox bug when gradients and patterns don't work if they are within a symbol.
  720. * Executes when sprite is rendered, but not mounted.
  721. * @see https://bugzilla.mozilla.org/show_bug.cgi?id=306674
  722. * @see https://bugzilla.mozilla.org/show_bug.cgi?id=353575
  723. * @see https://bugzilla.mozilla.org/show_bug.cgi?id=1235364
  724. * @type {boolean}
  725. */
  726. moveGradientsOutsideSymbol: false
  727. };
  728. /**
  729. * @param {*} arrayLike
  730. * @return {Array}
  731. */
  732. var arrayFrom = function (arrayLike) {
  733. return Array.prototype.slice.call(arrayLike, 0);
  734. };
  735. var ua = navigator.userAgent;
  736. var browser = {
  737. isChrome: /chrome/i.test(ua),
  738. isFirefox: /firefox/i.test(ua),
  739. // https://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx
  740. isIE: /msie/i.test(ua) || /trident/i.test(ua),
  741. isEdge: /edge/i.test(ua)
  742. };
  743. /**
  744. * @param {string} name
  745. * @param {*} data
  746. */
  747. var dispatchEvent = function (name, data) {
  748. var event = document.createEvent('CustomEvent');
  749. event.initCustomEvent(name, false, false, data);
  750. window.dispatchEvent(event);
  751. };
  752. /**
  753. * IE doesn't evaluate <style> tags in SVGs that are dynamically added to the page.
  754. * This trick will trigger IE to read and use any existing SVG <style> tags.
  755. * @see https://github.com/iconic/SVGInjector/issues/23
  756. * @see https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10898469/
  757. *
  758. * @param {Element} node DOM Element to search <style> tags in
  759. * @return {Array<HTMLStyleElement>}
  760. */
  761. var evalStylesIEWorkaround = function (node) {
  762. var updatedNodes = [];
  763. arrayFrom(node.querySelectorAll('style'))
  764. .forEach(function (style) {
  765. style.textContent += '';
  766. updatedNodes.push(style);
  767. });
  768. return updatedNodes;
  769. };
  770. /**
  771. * @param {string} [url] If not provided - current URL will be used
  772. * @return {string}
  773. */
  774. var getUrlWithoutFragment = function (url) {
  775. return (url || window.location.href).split('#')[0];
  776. };
  777. /* global angular */
  778. /**
  779. * @param {string} eventName
  780. */
  781. var locationChangeAngularEmitter = function (eventName) {
  782. angular.module('ng').run(['$rootScope', function ($rootScope) {
  783. $rootScope.$on('$locationChangeSuccess', function (e, newUrl, oldUrl) {
  784. dispatchEvent(eventName, { oldUrl: oldUrl, newUrl: newUrl });
  785. });
  786. }]);
  787. };
  788. var defaultSelector = 'linearGradient, radialGradient, pattern';
  789. /**
  790. * @param {Element} svg
  791. * @param {string} [selector]
  792. * @return {Element}
  793. */
  794. var moveGradientsOutsideSymbol = function (svg, selector) {
  795. if ( selector === void 0 ) selector = defaultSelector;
  796. arrayFrom(svg.querySelectorAll('symbol')).forEach(function (symbol) {
  797. arrayFrom(symbol.querySelectorAll(selector)).forEach(function (node) {
  798. symbol.parentNode.insertBefore(node, symbol);
  799. });
  800. });
  801. return svg;
  802. };
  803. /**
  804. * @param {NodeList} nodes
  805. * @param {Function} [matcher]
  806. * @return {Attr[]}
  807. */
  808. function selectAttributes(nodes, matcher) {
  809. var attrs = arrayFrom(nodes).reduce(function (acc, node) {
  810. if (!node.attributes) {
  811. return acc;
  812. }
  813. var arrayfied = arrayFrom(node.attributes);
  814. var matched = matcher ? arrayfied.filter(matcher) : arrayfied;
  815. return acc.concat(matched);
  816. }, []);
  817. return attrs;
  818. }
  819. /**
  820. * @param {NodeList|Node} nodes
  821. * @param {boolean} [clone=true]
  822. * @return {string}
  823. */
  824. var xLinkNS = namespaces_1.xlink.uri;
  825. var xLinkAttrName = 'xlink:href';
  826. // eslint-disable-next-line no-useless-escape
  827. var specialUrlCharsPattern = /[{}|\\\^\[\]`"<>]/g;
  828. function encoder(url) {
  829. return url.replace(specialUrlCharsPattern, function (match) {
  830. return ("%" + (match[0].charCodeAt(0).toString(16).toUpperCase()));
  831. });
  832. }
  833. /**
  834. * @param {NodeList} nodes
  835. * @param {string} startsWith
  836. * @param {string} replaceWith
  837. * @return {NodeList}
  838. */
  839. function updateReferences(nodes, startsWith, replaceWith) {
  840. arrayFrom(nodes).forEach(function (node) {
  841. var href = node.getAttribute(xLinkAttrName);
  842. if (href && href.indexOf(startsWith) === 0) {
  843. var newUrl = href.replace(startsWith, replaceWith);
  844. node.setAttributeNS(xLinkNS, xLinkAttrName, newUrl);
  845. }
  846. });
  847. return nodes;
  848. }
  849. /**
  850. * List of SVG attributes to update url() target in them
  851. */
  852. var attList = [
  853. 'clipPath',
  854. 'colorProfile',
  855. 'src',
  856. 'cursor',
  857. 'fill',
  858. 'filter',
  859. 'marker',
  860. 'markerStart',
  861. 'markerMid',
  862. 'markerEnd',
  863. 'mask',
  864. 'stroke',
  865. 'style'
  866. ];
  867. var attSelector = attList.map(function (attr) { return ("[" + attr + "]"); }).join(',');
  868. /**
  869. * Update URLs in svg image (like `fill="url(...)"`) and update referencing elements
  870. * @param {Element} svg
  871. * @param {NodeList} references
  872. * @param {string|RegExp} startsWith
  873. * @param {string} replaceWith
  874. * @return {void}
  875. *
  876. * @example
  877. * const sprite = document.querySelector('svg.sprite');
  878. * const usages = document.querySelectorAll('use');
  879. * updateUrls(sprite, usages, '#', 'prefix#');
  880. */
  881. var updateUrls = function (svg, references, startsWith, replaceWith) {
  882. var startsWithEncoded = encoder(startsWith);
  883. var replaceWithEncoded = encoder(replaceWith);
  884. var nodes = svg.querySelectorAll(attSelector);
  885. var attrs = selectAttributes(nodes, function (ref) {
  886. var localName = ref.localName;
  887. var value = ref.value;
  888. return attList.indexOf(localName) !== -1 && value.indexOf(("url(" + startsWithEncoded)) !== -1;
  889. });
  890. attrs.forEach(function (attr) { return attr.value = attr.value.replace(startsWithEncoded, replaceWithEncoded); });
  891. updateReferences(references, startsWithEncoded, replaceWithEncoded);
  892. };
  893. /**
  894. * Internal emitter events
  895. * @enum
  896. * @private
  897. */
  898. var Events = {
  899. MOUNT: 'mount',
  900. SYMBOL_MOUNT: 'symbol_mount'
  901. };
  902. var BrowserSprite = (function (Sprite$$1) {
  903. function BrowserSprite(cfg) {
  904. var this$1 = this;
  905. if ( cfg === void 0 ) cfg = {};
  906. Sprite$$1.call(this, deepmerge(defaultConfig$1, cfg));
  907. var emitter = mitt();
  908. this._emitter = emitter;
  909. this.node = null;
  910. var ref = this;
  911. var config = ref.config;
  912. if (config.autoConfigure) {
  913. this._autoConfigure(cfg);
  914. }
  915. if (config.syncUrlsWithBaseTag) {
  916. var baseUrl = document.getElementsByTagName('base')[0].getAttribute('href');
  917. emitter.on(Events.MOUNT, function () { return this$1.updateUrls('#', baseUrl); });
  918. }
  919. var handleLocationChange = this._handleLocationChange.bind(this);
  920. this._handleLocationChange = handleLocationChange;
  921. // Provide way to update sprite urls externally via dispatching custom window event
  922. if (config.listenLocationChangeEvent) {
  923. window.addEventListener(config.locationChangeEvent, handleLocationChange);
  924. }
  925. // Emit location change event in Angular automatically
  926. if (config.locationChangeAngularEmitter) {
  927. locationChangeAngularEmitter(config.locationChangeEvent);
  928. }
  929. // After sprite mounted
  930. emitter.on(Events.MOUNT, function (spriteNode) {
  931. if (config.moveGradientsOutsideSymbol) {
  932. moveGradientsOutsideSymbol(spriteNode);
  933. }
  934. });
  935. // After symbol mounted into sprite
  936. emitter.on(Events.SYMBOL_MOUNT, function (symbolNode) {
  937. if (config.moveGradientsOutsideSymbol) {
  938. moveGradientsOutsideSymbol(symbolNode.parentNode);
  939. }
  940. if (browser.isIE || browser.isEdge) {
  941. evalStylesIEWorkaround(symbolNode);
  942. }
  943. });
  944. }
  945. if ( Sprite$$1 ) BrowserSprite.__proto__ = Sprite$$1;
  946. BrowserSprite.prototype = Object.create( Sprite$$1 && Sprite$$1.prototype );
  947. BrowserSprite.prototype.constructor = BrowserSprite;
  948. var prototypeAccessors = { isMounted: {} };
  949. /**
  950. * @return {boolean}
  951. */
  952. prototypeAccessors.isMounted.get = function () {
  953. return !!this.node;
  954. };
  955. /**
  956. * Automatically configure following options
  957. * - `syncUrlsWithBaseTag`
  958. * - `locationChangeAngularEmitter`
  959. * - `moveGradientsOutsideSymbol`
  960. * @param {Object} cfg
  961. * @private
  962. */
  963. BrowserSprite.prototype._autoConfigure = function _autoConfigure (cfg) {
  964. var ref = this;
  965. var config = ref.config;
  966. if (typeof cfg.syncUrlsWithBaseTag === 'undefined') {
  967. config.syncUrlsWithBaseTag = typeof document.getElementsByTagName('base')[0] !== 'undefined';
  968. }
  969. if (typeof cfg.locationChangeAngularEmitter === 'undefined') {
  970. config.locationChangeAngularEmitter = 'angular' in window;
  971. }
  972. if (typeof cfg.moveGradientsOutsideSymbol === 'undefined') {
  973. config.moveGradientsOutsideSymbol = browser.isFirefox;
  974. }
  975. };
  976. /**
  977. * @param {Event} event
  978. * @param {Object} event.detail
  979. * @param {string} event.detail.oldUrl
  980. * @param {string} event.detail.newUrl
  981. * @private
  982. */
  983. BrowserSprite.prototype._handleLocationChange = function _handleLocationChange (event) {
  984. var ref = event.detail;
  985. var oldUrl = ref.oldUrl;
  986. var newUrl = ref.newUrl;
  987. this.updateUrls(oldUrl, newUrl);
  988. };
  989. /**
  990. * Add new symbol. If symbol with the same id exists it will be replaced.
  991. * If sprite already mounted - `symbol.mount(sprite.node)` will be called.
  992. * @fires Events#SYMBOL_MOUNT
  993. * @param {BrowserSpriteSymbol} symbol
  994. * @return {boolean} `true` - symbol was added, `false` - replaced
  995. */
  996. BrowserSprite.prototype.add = function add (symbol) {
  997. var sprite = this;
  998. var isNewSymbol = Sprite$$1.prototype.add.call(this, symbol);
  999. if (this.isMounted && isNewSymbol) {
  1000. symbol.mount(sprite.node);
  1001. this._emitter.emit(Events.SYMBOL_MOUNT, symbol.node);
  1002. }
  1003. return isNewSymbol;
  1004. };
  1005. /**
  1006. * Attach to existing DOM node
  1007. * @param {string|Element} target
  1008. * @return {Element|null} attached DOM Element. null if node to attach not found.
  1009. */
  1010. BrowserSprite.prototype.attach = function attach (target) {
  1011. var this$1 = this;
  1012. var sprite = this;
  1013. if (sprite.isMounted) {
  1014. return sprite.node;
  1015. }
  1016. /** @type Element */
  1017. var node = typeof target === 'string' ? document.querySelector(target) : target;
  1018. sprite.node = node;
  1019. // Already added symbols needs to be mounted
  1020. this.symbols.forEach(function (symbol) {
  1021. symbol.mount(sprite.node);
  1022. this$1._emitter.emit(Events.SYMBOL_MOUNT, symbol.node);
  1023. });
  1024. // Create symbols from existing DOM nodes, add and mount them
  1025. arrayFrom(node.querySelectorAll('symbol'))
  1026. .forEach(function (symbolNode) {
  1027. var symbol = BrowserSpriteSymbol.createFromExistingNode(symbolNode);
  1028. symbol.node = symbolNode; // hack to prevent symbol mounting to sprite when adding
  1029. sprite.add(symbol);
  1030. });
  1031. this._emitter.emit(Events.MOUNT, node);
  1032. return node;
  1033. };
  1034. BrowserSprite.prototype.destroy = function destroy () {
  1035. var ref = this;
  1036. var config = ref.config;
  1037. var symbols = ref.symbols;
  1038. var _emitter = ref._emitter;
  1039. symbols.forEach(function (s) { return s.destroy(); });
  1040. _emitter.off('*');
  1041. window.removeEventListener(config.locationChangeEvent, this._handleLocationChange);
  1042. if (this.isMounted) {
  1043. this.unmount();
  1044. }
  1045. };
  1046. /**
  1047. * @fires Events#MOUNT
  1048. * @param {string|Element} [target]
  1049. * @param {boolean} [prepend=false]
  1050. * @return {Element|null} rendered sprite node. null if mount node not found.
  1051. */
  1052. BrowserSprite.prototype.mount = function mount (target, prepend) {
  1053. if ( target === void 0 ) target = this.config.mountTo;
  1054. if ( prepend === void 0 ) prepend = false;
  1055. var sprite = this;
  1056. if (sprite.isMounted) {
  1057. return sprite.node;
  1058. }
  1059. var mountNode = typeof target === 'string' ? document.querySelector(target) : target;
  1060. var node = sprite.render();
  1061. this.node = node;
  1062. if (prepend && mountNode.childNodes[0]) {
  1063. mountNode.insertBefore(node, mountNode.childNodes[0]);
  1064. } else {
  1065. mountNode.appendChild(node);
  1066. }
  1067. this._emitter.emit(Events.MOUNT, node);
  1068. return node;
  1069. };
  1070. /**
  1071. * @return {Element}
  1072. */
  1073. BrowserSprite.prototype.render = function render () {
  1074. return parse(this.stringify());
  1075. };
  1076. /**
  1077. * Detach sprite from the DOM
  1078. */
  1079. BrowserSprite.prototype.unmount = function unmount () {
  1080. this.node.parentNode.removeChild(this.node);
  1081. };
  1082. /**
  1083. * Update URLs in sprite and usage elements
  1084. * @param {string} oldUrl
  1085. * @param {string} newUrl
  1086. * @return {boolean} `true` - URLs was updated, `false` - sprite is not mounted
  1087. */
  1088. BrowserSprite.prototype.updateUrls = function updateUrls$1 (oldUrl, newUrl) {
  1089. if (!this.isMounted) {
  1090. return false;
  1091. }
  1092. var usages = document.querySelectorAll(this.config.usagesToUpdate);
  1093. updateUrls(
  1094. this.node,
  1095. usages,
  1096. ((getUrlWithoutFragment(oldUrl)) + "#"),
  1097. ((getUrlWithoutFragment(newUrl)) + "#")
  1098. );
  1099. return true;
  1100. };
  1101. Object.defineProperties( BrowserSprite.prototype, prototypeAccessors );
  1102. return BrowserSprite;
  1103. }(Sprite));
  1104. var ready$1 = createCommonjsModule(function (module) {
  1105. /*!
  1106. * domready (c) Dustin Diaz 2014 - License MIT
  1107. */
  1108. !function (name, definition) {
  1109. { module.exports = definition(); }
  1110. }('domready', function () {
  1111. var fns = [], listener
  1112. , doc = document
  1113. , hack = doc.documentElement.doScroll
  1114. , domContentLoaded = 'DOMContentLoaded'
  1115. , loaded = (hack ? /^loaded|^c/ : /^loaded|^i|^c/).test(doc.readyState);
  1116. if (!loaded)
  1117. { doc.addEventListener(domContentLoaded, listener = function () {
  1118. doc.removeEventListener(domContentLoaded, listener);
  1119. loaded = 1;
  1120. while (listener = fns.shift()) { listener(); }
  1121. }); }
  1122. return function (fn) {
  1123. loaded ? setTimeout(fn, 0) : fns.push(fn);
  1124. }
  1125. });
  1126. });
  1127. var spriteNodeId = '__SVG_SPRITE_NODE__';
  1128. var spriteGlobalVarName = '__SVG_SPRITE__';
  1129. var isSpriteExists = !!window[spriteGlobalVarName];
  1130. // eslint-disable-next-line import/no-mutable-exports
  1131. var sprite;
  1132. if (isSpriteExists) {
  1133. sprite = window[spriteGlobalVarName];
  1134. } else {
  1135. sprite = new BrowserSprite({ attrs: { id: spriteNodeId } });
  1136. window[spriteGlobalVarName] = sprite;
  1137. }
  1138. var loadSprite = function () {
  1139. /**
  1140. * Check for page already contains sprite node
  1141. * If found - attach to and reuse it's content
  1142. * If not - render and mount the new sprite
  1143. */
  1144. var existing = document.getElementById(spriteNodeId);
  1145. if (existing) {
  1146. sprite.attach(existing);
  1147. } else {
  1148. sprite.mount(document.body, true);
  1149. }
  1150. };
  1151. if (document.body) {
  1152. loadSprite();
  1153. } else {
  1154. ready$1(loadSprite);
  1155. }
  1156. var sprite$1 = sprite;
  1157. return sprite$1;
  1158. })));
  1159. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
  1160. /***/ })
  1161. /******/ ]);