dll.js 39 KB

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