�PNG  IHDR��;���IDATx��ܻn�0���K�� �)(�pA��� ���7�LeG{�� �§㻢|��ذaÆ 6lذaÆ 6lذaÆ 6lom��$^�y���ذag�5bÆ 6lذaÆ 6lذa{���� 6lذaÆ �`����}H�Fkm�,�m����Ӫ���ô�ô!� �x�|'ܢ˟;�E:���9�&ᶒ�}�{�v]�n&�6� �h��_��t�ڠ͵-ҫ���Z;��Z$�.�P���k�ž)�!��o���>}l�eQfJ�T��u і���چ��\��X=8��Rن4`Vw�l�>����n�G�^��i�s��"ms�$�u��i��?w�bs[m�6�K4���O���.�4��%����/����b�C%��t ��M�ז� �-l�G6�mrz2���s�%�9��s@���-�k�9�=���)������k�B5����\��+͂�Zsٲ ��Rn��~G���R���C����� �wIcI��n7jJ���hۛNCS|���j0��8y�iHKֶۛ�k�Ɉ+;Sz������L/��F�*\��Ԕ�#"5��m�2��[S��������=�g��n�a�P�e�ғ�L�� lذaÆ 6l�^k��̱aÆ 6lذaÆ 6lذa;���� �_��ذaÆ 6lذaÆ 6lذaÆ ���R���IEND�B` 'use strict'; const { detachNodeFromParent } = require('../lib/xast.js'); const { computeStyle } = require('../lib/style.js'); const { path2js, js2path, intersects } = require('./_path.js'); exports.type = 'visitor'; exports.active = true; exports.description = 'merges multiple paths in one if possible'; /** * Merge multiple Paths into one. * * @param {Object} root * @param {Object} params * * @author Kir Belevich, Lev Solntsev */ exports.fn = (root, params) => { const { force = false, floatPrecision, noSpaceAfterFlags = false, // a20 60 45 0 1 30 20 → a20 60 45 0130 20 } = params; return { element: { enter: (node) => { let prevChild = null; for (const child of node.children) { // skip if previous element is not path or contains animation elements if ( prevChild == null || prevChild.type !== 'element' || prevChild.name !== 'path' || prevChild.children.length !== 0 || prevChild.attributes.d == null ) { prevChild = child; continue; } // skip if element is not path or contains animation elements if ( child.type !== 'element' || child.name !== 'path' || child.children.length !== 0 || child.attributes.d == null ) { prevChild = child; continue; } // preserve paths with markers const computedStyle = computeStyle(child); if ( computedStyle['marker-start'] || computedStyle['marker-mid'] || computedStyle['marker-end'] ) { prevChild = child; continue; } const prevChildAttrs = Object.keys(prevChild.attributes); const childAttrs = Object.keys(child.attributes); let attributesAreEqual = prevChildAttrs.length === childAttrs.length; for (const name of childAttrs) { if (name !== 'd') { if ( prevChild.attributes[name] == null || prevChild.attributes[name] !== child.attributes[name] ) { attributesAreEqual = false; } } } const prevPathJS = path2js(prevChild); const curPathJS = path2js(child); if ( attributesAreEqual && (force || !intersects(prevPathJS, curPathJS)) ) { js2path(prevChild, prevPathJS.concat(curPathJS), { floatPrecision, noSpaceAfterFlags, }); detachNodeFromParent(child); continue; } prevChild = child; } }, }, }; };