From 741d67c30bf08b8b137bc1687399ea83ad69a3e6 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 16 Feb 2021 17:19:26 +0100 Subject: [PATCH 01/15] :sparkles: Makes import SVG groups --- backend/resources/svgclean.js | 2 +- exporter/src/app/http/svgclean.js | 2 +- .../app/main/data/workspace/svg_upload.cljs | 124 +++++++++++------- frontend/src/app/main/ui/shapes/svg_raw.cljs | 55 ++++---- .../app/main/ui/workspace/shapes/svg_raw.cljs | 25 ++-- .../ui/workspace/sidebar/options/svg_raw.cljs | 8 +- frontend/src/app/util/svg.cljs | 34 +++++ vendor/svgclean/main.js | 1 + 8 files changed, 151 insertions(+), 100 deletions(-) diff --git a/backend/resources/svgclean.js b/backend/resources/svgclean.js index 898004202..80adc5883 100644 --- a/backend/resources/svgclean.js +++ b/backend/resources/svgclean.js @@ -1,4 +1,4 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).svgc=e()}}((function(){return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};t[o][0].call(u.exports,(function(e){return i(t[o][1][e]||e)}),u,u.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;oe.data))}},{"./src/svgclean.js":253}],2:[function(e,t,r){"use strict";r.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},r.toByteArray=function(e){var t,r,n=c(e),o=n[0],s=n[1],l=new a(function(e,t,r){return 3*(t+r)/4-r}(0,o,s)),u=0,d=s>0?o-4:o;for(r=0;r>16&255,l[u++]=t>>8&255,l[u++]=255&t;2===s&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,l[u++]=255&t);1===s&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,l[u++]=t>>8&255,l[u++]=255&t);return l},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,a=[],o=16383,s=0,l=r-i;sl?l:s+o));1===i?(t=e[r-1],a.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],a.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return a.join("")};for(var n=[],i=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,l=o.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,r){for(var i,a,o=[],s=t;s>18&63]+n[a>>12&63]+n[a>>6&63]+n[63&a]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(e,t,r){t.exports={trueFunc:function(){return!0},falseFunc:function(){return!1}}},{}],4:[function(e,t,r){},{}],5:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function a(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=l,this.end=c,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=u,this.end=d,t=3;break;default:return this.write=p,void(this.end=m)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function l(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function u(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function d(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function p(e){return e.toString(this.encoding)}function m(e){return e&&e.length?this.write(e):""}r.StringDecoder=a,a.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":6}],6:[function(e,t,r){ +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).svgc=e()}}((function(){return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};t[o][0].call(u.exports,(function(e){return i(t[o][1][e]||e)}),u,u.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;oe.data))}},{"./src/svgclean.js":253}],2:[function(e,t,r){"use strict";r.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},r.toByteArray=function(e){var t,r,n=c(e),o=n[0],s=n[1],l=new a(function(e,t,r){return 3*(t+r)/4-r}(0,o,s)),u=0,d=s>0?o-4:o;for(r=0;r>16&255,l[u++]=t>>8&255,l[u++]=255&t;2===s&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,l[u++]=255&t);1===s&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,l[u++]=t>>8&255,l[u++]=255&t);return l},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,a=[],o=16383,s=0,l=r-i;sl?l:s+o));1===i?(t=e[r-1],a.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],a.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return a.join("")};for(var n=[],i=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,l=o.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,r){for(var i,a,o=[],s=t;s>18&63]+n[a>>12&63]+n[a>>6&63]+n[63&a]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(e,t,r){t.exports={trueFunc:function(){return!0},falseFunc:function(){return!1}}},{}],4:[function(e,t,r){},{}],5:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function a(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=l,this.end=c,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=u,this.end=d,t=3;break;default:return this.write=p,void(this.end=m)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function l(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function u(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function d(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function p(e){return e.toString(this.encoding)}function m(e){return e&&e.length?this.write(e):""}r.StringDecoder=a,a.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":6}],6:[function(e,t,r){ /*! safe-buffer. MIT License. Feross Aboukhadijeh */ var n=e("buffer"),i=n.Buffer;function a(e,t){for(var r in e)t[r]=e[r]}function o(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(a(n,r),r.Buffer=o),o.prototype=Object.create(i.prototype),a(i,o),o.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,r)},o.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},{buffer:7}],7:[function(e,t,r){(function(t){(function(){ /*! diff --git a/exporter/src/app/http/svgclean.js b/exporter/src/app/http/svgclean.js index 898004202..80adc5883 100644 --- a/exporter/src/app/http/svgclean.js +++ b/exporter/src/app/http/svgclean.js @@ -1,4 +1,4 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).svgc=e()}}((function(){return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};t[o][0].call(u.exports,(function(e){return i(t[o][1][e]||e)}),u,u.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;oe.data))}},{"./src/svgclean.js":253}],2:[function(e,t,r){"use strict";r.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},r.toByteArray=function(e){var t,r,n=c(e),o=n[0],s=n[1],l=new a(function(e,t,r){return 3*(t+r)/4-r}(0,o,s)),u=0,d=s>0?o-4:o;for(r=0;r>16&255,l[u++]=t>>8&255,l[u++]=255&t;2===s&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,l[u++]=255&t);1===s&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,l[u++]=t>>8&255,l[u++]=255&t);return l},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,a=[],o=16383,s=0,l=r-i;sl?l:s+o));1===i?(t=e[r-1],a.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],a.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return a.join("")};for(var n=[],i=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,l=o.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,r){for(var i,a,o=[],s=t;s>18&63]+n[a>>12&63]+n[a>>6&63]+n[63&a]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(e,t,r){t.exports={trueFunc:function(){return!0},falseFunc:function(){return!1}}},{}],4:[function(e,t,r){},{}],5:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function a(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=l,this.end=c,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=u,this.end=d,t=3;break;default:return this.write=p,void(this.end=m)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function l(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function u(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function d(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function p(e){return e.toString(this.encoding)}function m(e){return e&&e.length?this.write(e):""}r.StringDecoder=a,a.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":6}],6:[function(e,t,r){ +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).svgc=e()}}((function(){return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};t[o][0].call(u.exports,(function(e){return i(t[o][1][e]||e)}),u,u.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;oe.data))}},{"./src/svgclean.js":253}],2:[function(e,t,r){"use strict";r.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},r.toByteArray=function(e){var t,r,n=c(e),o=n[0],s=n[1],l=new a(function(e,t,r){return 3*(t+r)/4-r}(0,o,s)),u=0,d=s>0?o-4:o;for(r=0;r>16&255,l[u++]=t>>8&255,l[u++]=255&t;2===s&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,l[u++]=255&t);1===s&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,l[u++]=t>>8&255,l[u++]=255&t);return l},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,a=[],o=16383,s=0,l=r-i;sl?l:s+o));1===i?(t=e[r-1],a.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],a.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return a.join("")};for(var n=[],i=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,l=o.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,r){for(var i,a,o=[],s=t;s>18&63]+n[a>>12&63]+n[a>>6&63]+n[63&a]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(e,t,r){t.exports={trueFunc:function(){return!0},falseFunc:function(){return!1}}},{}],4:[function(e,t,r){},{}],5:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function a(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=l,this.end=c,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=u,this.end=d,t=3;break;default:return this.write=p,void(this.end=m)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function l(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function u(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function d(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function p(e){return e.toString(this.encoding)}function m(e){return e&&e.length?this.write(e):""}r.StringDecoder=a,a.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":6}],6:[function(e,t,r){ /*! safe-buffer. MIT License. Feross Aboukhadijeh */ var n=e("buffer"),i=n.Buffer;function a(e,t){for(var r in e)t[r]=e[r]}function o(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(a(n,r),r.Buffer=o),o.prototype=Object.create(i.prototype),a(i,o),o.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,r)},o.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},{buffer:7}],7:[function(e,t,r){(function(t){(function(){ /*! diff --git a/frontend/src/app/main/data/workspace/svg_upload.cljs b/frontend/src/app/main/data/workspace/svg_upload.cljs index 96d7845ea..4eb41abaf 100644 --- a/frontend/src/app/main/data/workspace/svg_upload.cljs +++ b/frontend/src/app/main/data/workspace/svg_upload.cljs @@ -30,7 +30,7 @@ height (d/parse-integer height-str)] [width height])) -(defn tag-name [{:keys [tag]}] +(defn tag-name [tag] (cond (string? tag) tag (keyword? tag) (name tag) (nil? tag) "node" @@ -63,17 +63,35 @@ (d/any-key? attrs :stroke :stroke-width :stroke-opacity) (setup-stroke attrs))) -(defn create-raw-svg [name frame-id x y width height data] - (-> {:id (uuid/next) - :type :svg-raw - :name name - :frame-id frame-id - :width width - :height height - :x x - :y y - :content (if (map? data) (update data :attrs usvg/clean-attrs) data)} - (gsh/setup-selrect))) +(defn create-raw-svg [name frame-id svg-data element-data] + (let [{:keys [x y width height]} svg-data] + (-> {:id (uuid/next) + :type :svg-raw + :name name + :frame-id frame-id + :width width + :height height + :x x + :y y + :root-attrs (select-keys svg-data [:width :height]) + :content (cond-> element-data + (map? element-data) (update :attrs usvg/clean-attrs))} + (gsh/setup-selrect)))) + +(defn create-svg-root [frame-id svg-data] + (let [{:keys [name x y width height]} svg-data] + (-> {:id (uuid/next) + :type :group + :name name + :frame-id frame-id + :width width + :height height + :x x + :y y + :attrs (-> (get svg-data :attrs) usvg/clean-attrs) + ;;:content (if (map? data) (update data :attrs usvg/clean-attrs) data) + } + (gsh/setup-selrect)))) (defn parse-path [name frame-id {:keys [attrs] :as data}] (let [content (ugp/path->content (:d attrs)) @@ -89,23 +107,38 @@ (add-style-attributes data)))) -(defn parse-svg-element [root-shape data unames] - (let [root-id (:id root-shape) - frame-id (:frame-id root-shape) - {:keys [x y width height]} (:selrect root-shape) - {:keys [tag]} data - name (dwc/generate-unique-name unames (str "svg-" (tag-name data))) - - shape - (case tag - ;; :rect (parse-rect data) - ;; :path (parse-path name frame-id data) - (create-raw-svg name frame-id x y width height data))] +(defn parse-svg-element [frame-id svg-data element-data unames] + (let [{:keys [tag]} element-data + name (dwc/generate-unique-name unames (str "svg-" (tag-name tag)))] - (-> shape - (assoc :svg-id root-id)))) + (case tag + ;; :rect (parse-rect data) + ;; :path (parse-path name frame-id data) + (create-raw-svg name frame-id svg-data element-data)))) -(defn svg-uploaded [data x y] +(defn add-svg-child-changes [page-id objects selected frame-id parent-id svg-data ids-mappings result [index data]] + (let [[unames [rchs uchs]] result + data (update data :attrs usvg/replace-attrs-ids ids-mappings) + shape (parse-svg-element frame-id svg-data data unames) + shape-id (:id shape) + [rch1 uch1] (dwc/add-shape-changes page-id objects selected shape) + + ;; Mov-objects won't have undo because we "delete" the object in the undo of the + ;; previous operation + rch2 [{:type :mov-objects + :parent-id parent-id + :frame-id frame-id + :page-id page-id + :index index + :shapes [shape-id]}] + + ;; Careful! the undo changes are concatenated reversed (we undo in reverse order + changes [(d/concat rchs rch1 rch2) (d/concat uch1 uchs)] + unames (conj unames (:name shape)) + reducer-fn (partial add-svg-child-changes page-id objects selected frame-id shape-id svg-data ids-mappings)] + (reduce reducer-fn [unames changes] (d/enumerate (:content data))))) + +(defn svg-uploaded [svg-data x y] (ptk/reify ::svg-uploaded ptk/WatchEvent (watch [_ state stream] @@ -114,40 +147,29 @@ frame-id (cp/frame-id-by-position objects {:x x :y y}) selected (get-in state [:workspace-local :selected]) - [width height] (svg-dimensions data) + [width height] (svg-dimensions svg-data) x (- x (/ width 2)) y (- y (/ height 2)) - add-svg-child - (fn add-svg-child [parent-id root-shape [unames [rchs uchs]] [index {:keys [content] :as data}]] - (let [shape (parse-svg-element root-shape data unames) - shape-id (:id shape) - [rch1 uch1] (dwc/add-shape-changes page-id objects selected shape) - - ;; Mov-objects won't have undo because we "delete" the object in the undo of the - ;; previous operation - rch2 [{:type :mov-objects - :parent-id parent-id - :frame-id frame-id - :page-id page-id - :index index - :shapes [shape-id]}] - - ;; Careful! the undo changes are concatenated reversed (we undo in reverse order - changes [(d/concat rchs rch1 rch2) (d/concat uch1 uchs)] - unames (conj unames (:name shape))] - (reduce (partial add-svg-child shape-id root-shape) [unames changes] (d/enumerate content)))) - unames (dwc/retrieve-used-names objects) - svg-name (->> (str/replace (:name data) ".svg" "") + svg-name (->> (str/replace (:name svg-data) ".svg" "") (dwc/generate-unique-name unames)) - root-shape (create-raw-svg svg-name frame-id x y width height data) + ids-mappings (usvg/generate-id-mapping svg-data) + svg-data (-> svg-data + (assoc :x x + :y y + :width width + :height height + :name svg-name)) + + root-shape (create-svg-root frame-id svg-data) root-id (:id root-shape) changes (dwc/add-shape-changes page-id objects selected root-shape) - [_ [rchanges uchanges]] (reduce (partial add-svg-child root-id root-shape) [unames changes] (d/enumerate (:content data)))] + reducer-fn (partial add-svg-child-changes page-id objects selected frame-id root-id svg-data ids-mappings) + [_ [rchanges uchanges]] (reduce reducer-fn [unames changes] (d/enumerate (:content svg-data)))] (rx/of (dwc/commit-changes rchanges uchanges {:commit-local? true}) (dwc/select-shapes (d/ordered-set root-id))))))) diff --git a/frontend/src/app/main/ui/shapes/svg_raw.cljs b/frontend/src/app/main/ui/shapes/svg_raw.cljs index 01442e161..d47a7ff39 100644 --- a/frontend/src/app/main/ui/shapes/svg_raw.cljs +++ b/frontend/src/app/main/ui/shapes/svg_raw.cljs @@ -13,7 +13,6 @@ [app.common.geom.matrix :as gmt] [app.common.geom.point :as gpt] [app.common.geom.shapes :as gsh] - [app.common.uuid :as uuid] [app.main.ui.shapes.attrs :as usa] [app.util.data :as ud] [app.util.object :as obj] @@ -21,33 +20,12 @@ [cuerdas.core :as str] [rumext.alpha :as mf])) +;; Graphic tags +(defonce graphic-element? #{ :circle :ellipse :image :line :path :polygon :polyline :rect :text #_"use"}) + ;; Context to store a re-mapping of the ids (def svg-ids-ctx (mf/create-context nil)) -(defn generate-id-mapping [content] - (letfn [(visit-node [result node] - (let [element-id (get-in node [:attrs :id]) - result (cond-> result - element-id (assoc element-id (str (uuid/next))))] - (reduce visit-node result (:content node))))] - (visit-node {} content))) - - -(defonce replace-regex #"[^#]*#([^)\s]+).*") - -(defn replace-attrs-ids - "Replaces the ids inside a property" - [ids-mapping attrs] - - (letfn [(replace-ids [key val] - (if (map? val) - (cd/mapm replace-ids val) - (let [[_ from-id] (re-matches replace-regex val)] - (if (and from-id (contains? ids-mapping from-id)) - (str/replace val from-id (get ids-mapping from-id)) - val))))] - (cd/mapm replace-ids attrs))) - (defn set-styles [attrs shape] (let [custom-attrs (usa/extract-style-attrs shape) attrs (cond-> attrs @@ -58,6 +36,20 @@ (obj/merge! custom-attrs) (obj/set! "style" style)))) +(defn translate-shape [attrs shape] + (let [{svg-width :width svg-height :height :as root-shape} (:root-attrs shape) + {:keys [x y width height]} (:selrect shape) + transform (->> (:transform attrs "") + (str (gmt/multiply + (gmt/matrix) + (gsh/transform-matrix shape) + (gmt/translate-matrix (gpt/point x y)) + (gmt/scale-matrix (gpt/point (/ width svg-width) (/ height svg-height)))) + " "))] + (cond-> attrs + (and root-shape (graphic-element? (-> shape :content :tag))) + (assoc :transform transform)))) + (mf/defc svg-root {::mf/wrap-props false} [props] @@ -68,7 +60,7 @@ {:keys [x y width height]} shape {:keys [tag attrs] :as content} (:content shape) - ids-mapping (mf/use-memo #(generate-id-mapping content)) + ids-mapping (mf/use-memo #(usvg/generate-id-mapping content)) attrs (-> (set-styles attrs shape) (obj/set! "x" x) @@ -91,11 +83,16 @@ {:keys [attrs tag]} content ids-mapping (mf/use-ctx svg-ids-ctx) - attrs (mf/use-memo #(replace-attrs-ids ids-mapping attrs)) - element-id (get-in content [:attrs :id]) + attrs (mf/use-memo #(usvg/replace-attrs-ids attrs ids-mapping)) + + attrs (translate-shape attrs shape) + element-id (get-in content [:attrs :id]) attrs (cond-> (set-styles attrs shape) - element-id (obj/set! "id" (get ids-mapping element-id)))] + (and element-id (contains? ids-mapping element-id)) + (obj/set! "id" (get ids-mapping element-id))) + + {:keys [x y width height]} (:selrect shape)] [:> (name tag) attrs children])) (defn svg-raw-shape [shape-wrapper] diff --git a/frontend/src/app/main/ui/workspace/shapes/svg_raw.cljs b/frontend/src/app/main/ui/workspace/shapes/svg_raw.cljs index 3e26cca55..4ba0c4a8e 100644 --- a/frontend/src/app/main/ui/workspace/shapes/svg_raw.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/svg_raw.cljs @@ -57,19 +57,18 @@ :shape shape :childs childs}] - (when (= tag :svg) - [:rect.group-actions - {:x x - :y y - :transform transform - :width width - :height height - :fill "transparent" - :on-mouse-down handle-mouse-down - :on-double-click handle-double-click - :on-context-menu handle-context-menu - :on-pointer-over handle-pointer-enter - :on-pointer-out handle-pointer-leave}])] + [:rect.actions + {:x x + :y y + :transform transform + :width width + :height height + :fill "transparent" + :on-mouse-down handle-mouse-down + :on-double-click handle-double-click + :on-context-menu handle-context-menu + :on-pointer-over handle-pointer-enter + :on-pointer-out handle-pointer-leave}]] ;; We cannot wrap inside groups the shapes that go inside the defs tag ;; we use the context so we know when we should not render the container diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/svg_raw.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/svg_raw.cljs index e7bd3de77..6b024782d 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/svg_raw.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/svg_raw.cljs @@ -99,11 +99,9 @@ (when (contains? svg-elements tag) [:* - (when (= tag :svg) - [:* - [:& measures-menu {:ids ids - :type type - :values measure-values}]]) + [:& measures-menu {:ids ids + :type type + :values measure-values}] [:& fill-menu {:ids ids :type type diff --git a/frontend/src/app/util/svg.cljs b/frontend/src/app/util/svg.cljs index eedb6cb44..197130dbc 100644 --- a/frontend/src/app/util/svg.cljs +++ b/frontend/src/app/util/svg.cljs @@ -9,8 +9,12 @@ (ns app.util.svg (:require + [app.common.uuid :as uuid] + [app.common.data :as cd] [cuerdas.core :as str])) +(defonce replace-regex #"[^#]*#([^)\s]+).*") + (defn clean-attrs "Transforms attributes to their react equivalent" [attrs] @@ -40,3 +44,33 @@ (->> attrs (map map-fn) (into {})))) + +(defn replace-attrs-ids + "Replaces the ids inside a property" + [attrs ids-mapping] + (if (and ids-mapping (not (empty? ids-mapping))) + (letfn [(replace-ids [key val] + (cond + (map? val) + (cd/mapm replace-ids val) + + (and (= key :id) (contains? ids-mapping val)) + (get ids-mapping val) + + :else + (let [[_ from-id] (re-matches replace-regex val)] + (if (and from-id (contains? ids-mapping from-id)) + (str/replace val from-id (get ids-mapping from-id)) + val))))] + (cd/mapm replace-ids attrs)) + + ;; Ids-mapping is null + attrs)) + +(defn generate-id-mapping [content] + (letfn [(visit-node [result node] + (let [element-id (get-in node [:attrs :id]) + result (cond-> result + element-id (assoc element-id (str (uuid/next))))] + (reduce visit-node result (:content node))))] + (visit-node {} content))) diff --git a/vendor/svgclean/main.js b/vendor/svgclean/main.js index 40b62bba9..60ae9479c 100644 --- a/vendor/svgclean/main.js +++ b/vendor/svgclean/main.js @@ -4,6 +4,7 @@ const plugins = [ {removeViewBox: false}, {moveElemsAttrsToGroup: false}, {convertStyleToAttrs: false}, + {removeUselessDefs: false}, {convertPathData: { lineShorthands: false, curveSmoothShorthands: false, From 19febde547a735890a379e4c975a2f3b9b6eaa0c Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Mon, 22 Feb 2021 21:40:15 +0100 Subject: [PATCH 02/15] :sparkles: Import paths as native shapes --- backend/resources/svgclean.js | 2 +- common/app/common/data.cljc | 8 + common/app/common/geom/matrix.cljc | 25 ++- common/app/common/geom/shapes.cljc | 4 +- common/app/common/pages/spec.cljc | 2 +- exporter/src/app/http/svgclean.js | 2 +- frontend/resources/locales.json | 7 + .../resources/styles/common/framework.scss | 5 + .../partials/sidebar-element-options.scss | 3 +- .../src/app/main/data/workspace/common.cljs | 22 +- .../app/main/data/workspace/svg_upload.cljs | 173 ++++++++++----- frontend/src/app/main/ui/shapes/attrs.cljs | 83 ++++--- frontend/src/app/main/ui/shapes/group.cljs | 13 +- frontend/src/app/main/ui/shapes/shape.cljs | 4 +- frontend/src/app/main/ui/shapes/svg_defs.cljs | 103 +++++++++ frontend/src/app/main/ui/shapes/svg_raw.cljs | 16 +- .../app/main/ui/workspace/shapes/path.cljs | 1 - .../app/main/ui/workspace/shapes/svg_raw.cljs | 1 + .../ui/workspace/sidebar/options/group.cljs | 10 +- .../ui/workspace/sidebar/options/path.cljs | 8 +- .../sidebar/options/rows/input_row.cljs | 5 + .../workspace/sidebar/options/svg_attrs.cljs | 53 +++++ .../ui/workspace/sidebar/options/svg_raw.cljs | 10 +- frontend/src/app/util/a2c.js | 203 ++++++++++++++++++ frontend/src/app/util/color.cljs | 5 + frontend/src/app/util/geom/path.cljs | 172 +++++++++------ frontend/src/app/util/svg.cljs | 132 ++++++++++-- vendor/svgclean/main.js | 58 +++++ 28 files changed, 921 insertions(+), 209 deletions(-) create mode 100644 frontend/src/app/main/ui/shapes/svg_defs.cljs create mode 100644 frontend/src/app/main/ui/workspace/sidebar/options/svg_attrs.cljs create mode 100644 frontend/src/app/util/a2c.js diff --git a/backend/resources/svgclean.js b/backend/resources/svgclean.js index 80adc5883..b0d7507b9 100644 --- a/backend/resources/svgclean.js +++ b/backend/resources/svgclean.js @@ -1,4 +1,4 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).svgc=e()}}((function(){return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};t[o][0].call(u.exports,(function(e){return i(t[o][1][e]||e)}),u,u.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;oe.data))}},{"./src/svgclean.js":253}],2:[function(e,t,r){"use strict";r.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},r.toByteArray=function(e){var t,r,n=c(e),o=n[0],s=n[1],l=new a(function(e,t,r){return 3*(t+r)/4-r}(0,o,s)),u=0,d=s>0?o-4:o;for(r=0;r>16&255,l[u++]=t>>8&255,l[u++]=255&t;2===s&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,l[u++]=255&t);1===s&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,l[u++]=t>>8&255,l[u++]=255&t);return l},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,a=[],o=16383,s=0,l=r-i;sl?l:s+o));1===i?(t=e[r-1],a.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],a.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return a.join("")};for(var n=[],i=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,l=o.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,r){for(var i,a,o=[],s=t;s>18&63]+n[a>>12&63]+n[a>>6&63]+n[63&a]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(e,t,r){t.exports={trueFunc:function(){return!0},falseFunc:function(){return!1}}},{}],4:[function(e,t,r){},{}],5:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function a(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=l,this.end=c,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=u,this.end=d,t=3;break;default:return this.write=p,void(this.end=m)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function l(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function u(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function d(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function p(e){return e.toString(this.encoding)}function m(e){return e&&e.length?this.write(e):""}r.StringDecoder=a,a.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":6}],6:[function(e,t,r){ +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).svgc=e()}}((function(){return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};t[o][0].call(u.exports,(function(e){return i(t[o][1][e]||e)}),u,u.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;oe.data))}},{"./src/svgclean.js":253}],2:[function(e,t,r){"use strict";r.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},r.toByteArray=function(e){var t,r,n=c(e),o=n[0],s=n[1],l=new a(function(e,t,r){return 3*(t+r)/4-r}(0,o,s)),u=0,d=s>0?o-4:o;for(r=0;r>16&255,l[u++]=t>>8&255,l[u++]=255&t;2===s&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,l[u++]=255&t);1===s&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,l[u++]=t>>8&255,l[u++]=255&t);return l},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,a=[],o=16383,s=0,l=r-i;sl?l:s+o));1===i?(t=e[r-1],a.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],a.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return a.join("")};for(var n=[],i=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,l=o.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,r){for(var i,a,o=[],s=t;s>18&63]+n[a>>12&63]+n[a>>6&63]+n[63&a]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(e,t,r){t.exports={trueFunc:function(){return!0},falseFunc:function(){return!1}}},{}],4:[function(e,t,r){},{}],5:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function a(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=l,this.end=c,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=u,this.end=d,t=3;break;default:return this.write=p,void(this.end=m)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function l(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function u(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function d(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function p(e){return e.toString(this.encoding)}function m(e){return e&&e.length?this.write(e):""}r.StringDecoder=a,a.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":6}],6:[function(e,t,r){ /*! safe-buffer. MIT License. Feross Aboukhadijeh */ var n=e("buffer"),i=n.Buffer;function a(e,t){for(var r in e)t[r]=e[r]}function o(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(a(n,r),r.Buffer=o),o.prototype=Object.create(i.prototype),a(i,o),o.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,r)},o.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},{buffer:7}],7:[function(e,t,r){(function(t){(function(){ /*! diff --git a/common/app/common/data.cljc b/common/app/common/data.cljc index de3e6d59b..2606fb375 100644 --- a/common/app/common/data.cljc +++ b/common/app/common/data.cljc @@ -302,6 +302,14 @@ default v)))) +(defn num-string? [v] + ;; https://stackoverflow.com/questions/175739/built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number + #?(:cljs (and (string? v) + (not (js/isNaN v)) + (not (js/isNaN (parse-double v)))) + + :clj (not= (parse-double v :nan) :nan))) + (defn read-string [v] (r/read-string v)) diff --git a/common/app/common/geom/matrix.cljc b/common/app/common/geom/matrix.cljc index 69921998a..91f6ee630 100644 --- a/common/app/common/geom/matrix.cljc +++ b/common/app/common/geom/matrix.cljc @@ -11,6 +11,8 @@ (:require #?(:cljs [cljs.pprint :as pp] :clj [clojure.pprint :as pp]) + [cuerdas.core :as str] + [app.common.data :as d] [app.common.math :as mth] [app.common.geom.point :as gpt])) @@ -21,6 +23,22 @@ (toString [_] (str "matrix(" a "," b "," c "," d "," e "," f ")"))) +(defonce matrix-regex #"matrix\((.*),(.*),(.*),(.*),(.*),(.*)\)") + +(defn matrix + "Create a new matrix instance." + ([] + (Matrix. 1 0 0 1 0 0)) + ([a b c d e f] + (Matrix. a b c d e f))) + +(defn parse-matrix [mtx] + (let [[_ a b c d e f] (re-matches matrix-regex mtx)] + (->> [a b c d e f] + (map str/trim) + (map d/parse-double) + (apply matrix)))) + (defn multiply ([{m1a :a m1b :b m1c :c m1d :d m1e :e m1f :f} {m2a :a m2b :b m2c :c m2d :d m2e :e m2f :f}] @@ -46,12 +64,7 @@ [v] (instance? Matrix v)) -(defn matrix - "Create a new matrix instance." - ([] - (Matrix. 1 0 0 1 0 0)) - ([a b c d e f] - (Matrix. a b c d e f))) + (def base (matrix)) diff --git a/common/app/common/geom/shapes.cljc b/common/app/common/geom/shapes.cljc index 844664e22..1edcac312 100644 --- a/common/app/common/geom/shapes.cljc +++ b/common/app/common/geom/shapes.cljc @@ -148,10 +148,10 @@ (update-in [:selrect :x2] - x) (update-in [:selrect :y2] - y) - (d/update-when :points #(map move-point %)) + (d/update-when :points #(mapv move-point %)) (cond-> (= :path type) - (d/update-when :content #(map move-segment %)))))) + (d/update-when :content #(mapv move-segment %)))))) ;; --- Helpers diff --git a/common/app/common/pages/spec.cljc b/common/app/common/pages/spec.cljc index 2feef1d71..d99f44ef4 100644 --- a/common/app/common/pages/spec.cljc +++ b/common/app/common/pages/spec.cljc @@ -229,7 +229,7 @@ (s/def :internal.shape/stroke-color-ref-file (s/nilable uuid?)) (s/def :internal.shape/stroke-color-ref-id (s/nilable uuid?)) (s/def :internal.shape/stroke-opacity ::safe-number) -(s/def :internal.shape/stroke-style #{:solid :dotted :dashed :mixed :none}) +(s/def :internal.shape/stroke-style #{:solid :dotted :dashed :mixed :none :svg}) (s/def :internal.shape/stroke-width ::safe-number) (s/def :internal.shape/stroke-alignment #{:center :inner :outer}) (s/def :internal.shape/text-align #{"left" "right" "center" "justify"}) diff --git a/exporter/src/app/http/svgclean.js b/exporter/src/app/http/svgclean.js index 80adc5883..b0d7507b9 100644 --- a/exporter/src/app/http/svgclean.js +++ b/exporter/src/app/http/svgclean.js @@ -1,4 +1,4 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).svgc=e()}}((function(){return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};t[o][0].call(u.exports,(function(e){return i(t[o][1][e]||e)}),u,u.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;oe.data))}},{"./src/svgclean.js":253}],2:[function(e,t,r){"use strict";r.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},r.toByteArray=function(e){var t,r,n=c(e),o=n[0],s=n[1],l=new a(function(e,t,r){return 3*(t+r)/4-r}(0,o,s)),u=0,d=s>0?o-4:o;for(r=0;r>16&255,l[u++]=t>>8&255,l[u++]=255&t;2===s&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,l[u++]=255&t);1===s&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,l[u++]=t>>8&255,l[u++]=255&t);return l},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,a=[],o=16383,s=0,l=r-i;sl?l:s+o));1===i?(t=e[r-1],a.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],a.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return a.join("")};for(var n=[],i=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,l=o.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,r){for(var i,a,o=[],s=t;s>18&63]+n[a>>12&63]+n[a>>6&63]+n[63&a]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(e,t,r){t.exports={trueFunc:function(){return!0},falseFunc:function(){return!1}}},{}],4:[function(e,t,r){},{}],5:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function a(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=l,this.end=c,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=u,this.end=d,t=3;break;default:return this.write=p,void(this.end=m)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function l(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function u(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function d(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function p(e){return e.toString(this.encoding)}function m(e){return e&&e.length?this.write(e):""}r.StringDecoder=a,a.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":6}],6:[function(e,t,r){ +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).svgc=e()}}((function(){return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};t[o][0].call(u.exports,(function(e){return i(t[o][1][e]||e)}),u,u.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;oe.data))}},{"./src/svgclean.js":253}],2:[function(e,t,r){"use strict";r.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},r.toByteArray=function(e){var t,r,n=c(e),o=n[0],s=n[1],l=new a(function(e,t,r){return 3*(t+r)/4-r}(0,o,s)),u=0,d=s>0?o-4:o;for(r=0;r>16&255,l[u++]=t>>8&255,l[u++]=255&t;2===s&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,l[u++]=255&t);1===s&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,l[u++]=t>>8&255,l[u++]=255&t);return l},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,a=[],o=16383,s=0,l=r-i;sl?l:s+o));1===i?(t=e[r-1],a.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],a.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return a.join("")};for(var n=[],i=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,l=o.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,r){for(var i,a,o=[],s=t;s>18&63]+n[a>>12&63]+n[a>>6&63]+n[63&a]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(e,t,r){t.exports={trueFunc:function(){return!0},falseFunc:function(){return!1}}},{}],4:[function(e,t,r){},{}],5:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function a(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=l,this.end=c,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=u,this.end=d,t=3;break;default:return this.write=p,void(this.end=m)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function l(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function u(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function d(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function p(e){return e.toString(this.encoding)}function m(e){return e&&e.length?this.write(e):""}r.StringDecoder=a,a.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":6}],6:[function(e,t,r){ /*! safe-buffer. MIT License. Feross Aboukhadijeh */ var n=e("buffer"),i=n.Buffer;function a(e,t){for(var r in e)t[r]=e[r]}function o(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(a(n,r),r.Buffer=o),o.prototype=Object.create(i.prototype),a(i,o),o.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,r)},o.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},{buffer:7}],7:[function(e,t,r){(function(t){(function(){ /*! diff --git a/frontend/resources/locales.json b/frontend/resources/locales.json index 912b78ab1..b6dc8e929 100644 --- a/frontend/resources/locales.json +++ b/frontend/resources/locales.json @@ -5505,5 +5505,12 @@ "zh_cn" : "单击以闭合路径" }, "unused" : true + }, + + "workspace.sidebar.options.svg-attrs.title": { + "translations": { + "en": "Imported SVG Attributes", + "es": "Atributos del SVG Importado" + } } } diff --git a/frontend/resources/styles/common/framework.scss b/frontend/resources/styles/common/framework.scss index 064541a06..d538f3acd 100644 --- a/frontend/resources/styles/common/framework.scss +++ b/frontend/resources/styles/common/framework.scss @@ -449,6 +449,11 @@ ul.slider-dots { content: "Y"; } } + + &.large { + width: auto; + min-width: 9rem; + } } input, diff --git a/frontend/resources/styles/main/partials/sidebar-element-options.scss b/frontend/resources/styles/main/partials/sidebar-element-options.scss index dd6fb3808..86e12c59c 100644 --- a/frontend/resources/styles/main/partials/sidebar-element-options.scss +++ b/frontend/resources/styles/main/partials/sidebar-element-options.scss @@ -709,6 +709,8 @@ .element-set-content .input-row { & .element-set-subtitle { width: 5.5rem; + overflow: hidden; + text-overflow: ellipsis; } } @@ -771,7 +773,6 @@ min-width: 56px; max-height: 10rem; } - } } diff --git a/frontend/src/app/main/data/workspace/common.cljs b/frontend/src/app/main/data/workspace/common.cljs index a83b4c68f..499d25694 100644 --- a/frontend/src/app/main/data/workspace/common.cljs +++ b/frontend/src/app/main/data/workspace/common.cljs @@ -219,15 +219,19 @@ (defn generate-unique-name "A unique name generator" - [used basename] - (s/assert ::set-of-string used) - (s/assert ::us/string basename) - (let [[prefix initial] (extract-numeric-suffix basename)] - (loop [counter initial] - (let [candidate (str prefix "-" counter)] - (if (contains? used candidate) - (recur (inc counter)) - candidate))))) + ([used basename] + (generate-unique-name used basename false)) + ([used basename prefix-first?] + (s/assert ::set-of-string used) + (s/assert ::us/string basename) + (let [[prefix initial] (extract-numeric-suffix basename)] + (loop [counter initial] + (let [candidate (if (and (= 1 counter) prefix-first?) + (str prefix) + (str prefix "-" counter))] + (if (contains? used candidate) + (recur (inc counter)) + candidate)))))) ;; --- Shape attrs (Layers Sidebar) diff --git a/frontend/src/app/main/data/workspace/svg_upload.cljs b/frontend/src/app/main/data/workspace/svg_upload.cljs index 4eb41abaf..5480088ba 100644 --- a/frontend/src/app/main/data/workspace/svg_upload.cljs +++ b/frontend/src/app/main/data/workspace/svg_upload.cljs @@ -10,16 +10,19 @@ (ns app.main.data.workspace.svg-upload (:require [app.common.data :as d] - [app.util.data :as ud] + [app.common.geom.matrix :as gmt] + [app.common.geom.point :as gpt] [app.common.geom.shapes :as gsh] [app.common.pages :as cp] [app.common.uuid :as uuid] [app.main.data.workspace.common :as dwc] + [app.util.color :as uc] + [app.util.data :as ud] + [app.util.geom.path :as ugp] + [app.util.svg :as usvg] [beicon.core :as rx] [cuerdas.core :as str] - [potok.core :as ptk] - [app.util.svg :as usvg] - [app.util.geom.path :as ugp])) + [potok.core :as ptk])) (defn- svg-dimensions [data] (let [width (get-in data [:attrs :width] 100) @@ -30,40 +33,75 @@ height (d/parse-integer height-str)] [width height])) -(defn tag-name [tag] - (cond (string? tag) tag - (keyword? tag) (name tag) - (nil? tag) "node" - :else (str tag))) +(defn tag->name + "Given a tag returns its layer name" + [tag] + (str "svg-" (cond (string? tag) tag + (keyword? tag) (name tag) + (nil? tag) "node" + :else (str tag)))) -(defn setup-fill [shape attrs] - (let [fill-color (or (get-in attrs [:fill]) - (get-in attrs [:style :fill]) - "#000000") - fill-opacity (ud/parse-float (or (get-in attrs [:fill-opacity]) - (get-in attrs [:style :fill-opacity]) - "1"))] - (-> shape - (assoc :fill-color fill-color) - (assoc :fill-opacity fill-opacity)))) +(defn fix-dot-number + "Fixes decimal numbers starting in dot but without leading 0" + [num-str] + (if (str/starts-with? num-str ".") + (str "0" num-str) + num-str)) -(defn setup-stroke [shape attrs] - (-> shape - (assoc :stroke-color (:stroke attrs "#000000")) - (assoc :stroke-opacity (ud/parse-float (:stroke-opacity attrs 1))) - (assoc :stroke-style :solid) - (assoc :stroke-width (ud/parse-float (:stroke-width attrs "1"))) - (assoc :stroke-alignment :center))) - -(defn add-style-attributes [shape {:keys [attrs]}] +(defn setup-fill [shape] (cond-> shape - (d/any-key? attrs :fill :fill-opacity) - (setup-fill attrs) - - (d/any-key? attrs :stroke :stroke-width :stroke-opacity) - (setup-stroke attrs))) + ;; Color present as attribute + (uc/color? (get-in shape [:svg-attrs :fill])) + (-> (update :svg-attrs dissoc :fill) + (assoc :fill-color (-> (get-in shape [:svg-attrs :fill]) + (uc/parse-color)))) -(defn create-raw-svg [name frame-id svg-data element-data] + ;; Color present as style + (uc/color? (get-in shape [:svg-attrs :style :fill])) + (-> (update-in [:svg-attrs :style] dissoc :fill) + (assoc :fill-color (-> (get-in shape [:svg-attrs :style :fill]) + (uc/parse-color)))) + + (get-in shape [:svg-attrs :fill-opacity]) + (-> (update :svg-attrs dissoc :fill-opacity) + (assoc :fill-opacity (-> (get-in shape [:svg-attrs :fill-opacity]) + (ud/parse-float)))) + + (get-in shape [:svg-attrs :style :fill-opacity]) + (-> (update :svg-attrs dissoc :fill-opacity) + (assoc :fill-opacity (-> (get-in shape [:svg-attrs :style :fill-opacity]) + (ud/parse-float)))))) + +(defonce default-stroke {:stroke-color "#000000" + :stroke-opacity 1 + :stroke-alignment :center + :stroke-style :svg}) + +(defn setup-stroke [shape] + (let [shape + (cond-> shape + (uc/color? (get-in shape [:svg-attrs :stroke])) + (-> (update :svg-attrs dissoc :stroke) + (assoc :stroke-color (get-in shape [:svg-attrs :stroke]))) + + (uc/color? (get-in shape [:svg-attrs :style :stroke])) + (-> (update-in [:svg-attrs :style] dissoc :stroke) + (assoc :stroke-color (get-in shape [:svg-attrs :style :stroke]))) + + (get-in shape [:svg-attrs :stroke-width]) + (-> (update :svg-attrs dissoc :stroke-width) + (assoc :stroke-width (-> (get-in shape [:svg-attrs :stroke-width]) + (ud/parse-float)))) + + (get-in shape [:svg-attrs :style :stroke-width]) + (-> (update-in [:svg-attrs :style] dissoc :stroke-width) + (assoc :stroke-width (-> (get-in shape [:svg-attrs :style :stroke-width]) + (ud/parse-float)))))] + (if (d/any-key? shape :stroke-color :stroke-opacity :stroke-width) + (merge default-stroke shape) + shape))) + +(defn create-raw-svg [name frame-id svg-data {:keys [attrs] :as data}] (let [{:keys [x y width height]} svg-data] (-> {:id (uuid/next) :type :svg-raw @@ -73,9 +111,10 @@ :height height :x x :y y - :root-attrs (select-keys svg-data [:width :height]) - :content (cond-> element-data - (map? element-data) (update :attrs usvg/clean-attrs))} + :content (cond-> data + (map? data) (update :attrs usvg/clean-attrs))} + (assoc :svg-attrs attrs) + (assoc :svg-viewbox (select-keys svg-data [0 0 :width :height])) (gsh/setup-selrect)))) (defn create-svg-root [frame-id svg-data] @@ -87,14 +126,20 @@ :width width :height height :x x - :y y - :attrs (-> (get svg-data :attrs) usvg/clean-attrs) - ;;:content (if (map? data) (update data :attrs usvg/clean-attrs) data) - } - (gsh/setup-selrect)))) + :y y} + (gsh/setup-selrect) + (assoc :svg-attrs (-> (:attrs svg-data) + (dissoc :viewBox :xmlns)))))) + +(defn apply-svg-transform [content transform-str] + (let [transform (gmt/parse-matrix transform-str)] + (gsh/transform-content content transform))) + +(defn create-path-shape [name frame-id svg-data {:keys [attrs] :as data}] + (let [content (cond-> (ugp/path->content (:d attrs)) + (contains? attrs :transform) + (apply-svg-transform (:transform attrs))) -(defn parse-path [name frame-id {:keys [attrs] :as data}] - (let [content (ugp/path->content (:d attrs)) selrect (gsh/content->selrect content) points (gsh/rect->points selrect)] (-> {:id (uuid/next) @@ -104,21 +149,42 @@ :content content :selrect selrect :points points} + (assoc :svg-viewbox (select-keys selrect [:x :y :width :height])) + (assoc :svg-attrs (dissoc attrs :d :transform)) + (gsh/translate-to-frame svg-data)))) - (add-style-attributes data)))) +(defn create-group [name frame-id svg-data {:keys [attrs]}] + (let [{:keys [x y width height]} svg-data] + (-> {:id (uuid/next) + :type :group + :name name + :frame-id frame-id + :x x + :y y + :width width + :height height} + (assoc :svg-attrs attrs) + (assoc :svg-viewbox (select-keys svg-data [0 0 :width :height])) + (gsh/setup-selrect)))) (defn parse-svg-element [frame-id svg-data element-data unames] - (let [{:keys [tag]} element-data - name (dwc/generate-unique-name unames (str "svg-" (tag-name tag)))] + (let [{:keys [tag attrs]} element-data + name (dwc/generate-unique-name unames (or (:id attrs) (tag->name tag)) true) + att-refs (usvg/find-attr-references attrs) + references (usvg/find-def-references (:defs svg-data) att-refs)] - (case tag - ;; :rect (parse-rect data) - ;; :path (parse-path name frame-id data) - (create-raw-svg name frame-id svg-data element-data)))) + (-> (case tag + :g (create-group name frame-id svg-data element-data) + ;; :rect (parse-rect data) + :path (create-path-shape name frame-id (gpt/negate (gpt/point svg-data)) element-data) + (create-raw-svg name frame-id svg-data element-data)) + + (assoc :svg-defs (select-keys (:defs svg-data) references)) + (setup-fill) + (setup-stroke)))) (defn add-svg-child-changes [page-id objects selected frame-id parent-id svg-data ids-mappings result [index data]] (let [[unames [rchs uchs]] result - data (update data :attrs usvg/replace-attrs-ids ids-mappings) shape (parse-svg-element frame-id svg-data data unames) shape-id (:id shape) [rch1 uch1] (dwc/add-shape-changes page-id objects selected shape) @@ -164,6 +230,9 @@ :height height :name svg-name)) + [def-nodes svg-data] (usvg/extract-defs svg-data) + svg-data (assoc svg-data :defs def-nodes) + root-shape (create-svg-root frame-id svg-data) root-id (:id root-shape) diff --git a/frontend/src/app/main/ui/shapes/attrs.cljs b/frontend/src/app/main/ui/shapes/attrs.cljs index 66c1ac4a7..1f4dde2dd 100644 --- a/frontend/src/app/main/ui/shapes/attrs.cljs +++ b/frontend/src/app/main/ui/shapes/attrs.cljs @@ -12,7 +12,8 @@ [rumext.alpha :as mf] [cuerdas.core :as str] [app.util.object :as obj] - [app.main.ui.context :as muc])) + [app.main.ui.context :as muc] + [app.util.svg :as usvg])) (defn- stroke-type->dasharray [style] @@ -74,45 +75,77 @@ attrs))) (defn add-fill [attrs shape render-id] - (let [fill-color-gradient-id (str "fill-color-gradient_" render-id)] - (cond - (:fill-color-gradient shape) - (obj/merge! attrs #js {:fill (str/format "url(#%s)" fill-color-gradient-id)}) + (let [fill-attrs (cond + (contains? shape :fill-color-gradient) + (let [fill-color-gradient-id (str "fill-color-gradient_" render-id)] + {:fill (str/format "url(#%s)" fill-color-gradient-id)}) - (and (not= :svg-raw (:type shape)) - (not (:fill-color-gradient shape))) - (obj/merge! attrs #js {:fill (or (:fill-color shape) "transparent") - :fillOpacity (:fill-opacity shape nil)}) + (contains? shape :fill-color) + {:fill (:fill-color shape)} - (and (= :svg-raw (:type shape)) - (or (:fill-opacity shape) (:fill-color shape))) - (obj/merge! attrs #js {:fill (:fill-color shape) - :fillOpacity (:fill-opacity shape nil)}) + ;; If contains svg-attrs the origin is svg. If it's not svg origin + ;; we setup the default fill as transparent (instead of black) + (not (contains? shape :svg-attrs)) + {:fill "transparent"} - :else attrs))) + :else + {}) + + fill-attrs (cond-> fill-attrs + (contains? shape :fill-opacity) + (assoc :fillOpacity (:fill-opacity shape)))] + + (obj/merge! attrs (clj->js fill-attrs)))) (defn add-stroke [attrs shape render-id] (let [stroke-style (:stroke-style shape :none) stroke-color-gradient-id (str "stroke-color-gradient_" render-id)] (if (not= stroke-style :none) - (if (:stroke-color-gradient shape) - (obj/merge! attrs - #js {:stroke (str/format "url(#%s)" stroke-color-gradient-id) - :strokeWidth (:stroke-width shape 1) - :strokeDasharray (stroke-type->dasharray stroke-style)}) - (obj/merge! attrs - #js {:stroke (:stroke-color shape nil) - :strokeWidth (:stroke-width shape 1) - :strokeOpacity (:stroke-opacity shape nil) - :strokeDasharray (stroke-type->dasharray stroke-style)})))) - attrs) + (let [stroke-attrs + (cond-> {:strokeWidth (:stroke-width shape 1)} + (:stroke-color-gradient shape) + (assoc :stroke (str/format "url(#%s)" stroke-color-gradient-id)) + + (not (:stroke-color-gradient shape)) + (assoc :stroke (:stroke-color shape nil) + :strokeOpacity (:stroke-opacity shape nil)) + + (not= stroke-style :svg) + (assoc :strokeDasharray (stroke-type->dasharray stroke-style)))] + (obj/merge! attrs (clj->js stroke-attrs))) + attrs))) + + +(defn extract-svg-attrs + [render-id svg-defs svg-attrs] + (let [replace-id (fn [id] + (if (contains? svg-defs id) + (str render-id "-" id) + id)) + svg-attrs (-> svg-attrs + (usvg/update-attr-ids replace-id) + (usvg/clean-attrs)) + + attrs (-> svg-attrs (dissoc :style) (clj->js)) + styles (-> svg-attrs (:style {}) (clj->js))] + [attrs styles])) (defn extract-style-attrs ([shape] (let [render-id (mf/use-ctx muc/render-ctx) + svg-defs (:svg-defs shape {}) + svg-attrs (:svg-attrs shape {}) + + [svg-attrs svg-styles] (mf/use-memo + (mf/deps render-id svg-defs svg-attrs) + #(extract-svg-attrs render-id svg-defs svg-attrs)) + styles (-> (obj/new) + (obj/merge! svg-styles) (add-fill shape render-id) (add-stroke shape render-id))] + (-> (obj/new) + (obj/merge! svg-attrs) (add-border-radius shape) (obj/set! "style" styles))))) diff --git a/frontend/src/app/main/ui/shapes/group.cljs b/frontend/src/app/main/ui/shapes/group.cljs index 5e00ea9e3..d7e0f72f1 100644 --- a/frontend/src/app/main/ui/shapes/group.cljs +++ b/frontend/src/app/main/ui/shapes/group.cljs @@ -9,7 +9,9 @@ (ns app.main.ui.shapes.group (:require + [app.util.object :as obj] [rumext.alpha :as mf] + [app.main.ui.shapes.attrs :as attrs] [app.main.ui.shapes.mask :refer [mask-str mask-factory]])) (defn group-shape @@ -28,12 +30,15 @@ show-mask? (and (:masked-group? shape) (not expand-mask)) mask (when show-mask? (first childs)) - childs (if show-mask? (rest childs) childs)] + childs (if show-mask? (rest childs) childs) - [:g.group - {:pointer-events pointer-events - :mask (when (and mask (not expand-mask)) (mask-str mask))} + props (-> (attrs/extract-style-attrs shape) + (obj/merge! + #js {:className "group" + :pointerEvents pointer-events + :mask (when (and mask (not expand-mask)) (mask-str mask))}))] + [:> :g props (when mask [:> render-mask #js {:frame frame :mask mask}]) diff --git a/frontend/src/app/main/ui/shapes/shape.cljs b/frontend/src/app/main/ui/shapes/shape.cljs index 08953de39..3e18f6ea0 100644 --- a/frontend/src/app/main/ui/shapes/shape.cljs +++ b/frontend/src/app/main/ui/shapes/shape.cljs @@ -9,13 +9,12 @@ (ns app.main.ui.shapes.shape (:require - [app.common.geom.shapes :as geom] [app.common.uuid :as uuid] [app.main.ui.context :as muc] [app.main.ui.shapes.filters :as filters] [app.main.ui.shapes.gradients :as grad] + [app.main.ui.shapes.svg-defs :as defs] [app.util.object :as obj] - [cuerdas.core :as str] [rumext.alpha :as mf])) (mf/defc shape-container @@ -48,6 +47,7 @@ [:& (mf/provider muc/render-ctx) {:value render-id} [:> wrapper-tag group-props [:defs + [:& defs/svg-defs {:shape shape :render-id render-id}] [:& filters/filters {:shape shape :filter-id filter-id}] [:& grad/gradient {:shape shape :attr :fill-color-gradient}] [:& grad/gradient {:shape shape :attr :stroke-color-gradient}]] diff --git a/frontend/src/app/main/ui/shapes/svg_defs.cljs b/frontend/src/app/main/ui/shapes/svg_defs.cljs new file mode 100644 index 000000000..cd2ca9e6e --- /dev/null +++ b/frontend/src/app/main/ui/shapes/svg_defs.cljs @@ -0,0 +1,103 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; This Source Code Form is "Incompatible With Secondary Licenses", as +;; defined by the Mozilla Public License, v. 2.0. +;; +;; Copyright (c) 2020-2021 UXBOX Labs SL + +(ns app.main.ui.shapes.svg-defs + (:require + [app.common.data :as d] + [app.common.geom.matrix :as gmt] + [app.common.geom.point :as gpt] + [app.util.object :as obj] + [app.util.svg :as usvg] + [rumext.alpha :as mf])) + +(defn add-matrix [attrs transform-key transform-matrix] + (update attrs + transform-key + (fn [val] + (if val + (str transform-matrix " " val) + (str transform-matrix))))) + +(defn transform-region [attrs transform] + (let [{x-str :x y-str :y width-str :width height-str :height} attrs + data (map d/parse-double [x-str y-str width-str height-str])] + (if (every? (comp not nil?) data) + (let [[x y width height] data + p1 (-> (gpt/point x y) + (gpt/transform transform)) + p2 (-> (gpt/point (+ x width) (+ y height)) + (gpt/transform transform))] + + (assoc attrs + :x (:x p1) + :y (:y p1) + :width (- (:x p2) (:x p1)) + :height (- (:y p2) (:y p1)))) + attrs))) + +(mf/defc svg-node [{:keys [node prefix-id transform]}] + (cond + (string? node) node + + :else + (let [{:keys [tag attrs content]} node + + transform-gradient? (and (#{:linearGradient :radialGradient} tag) + (= "userSpaceOnUse" (get attrs :gradientUnits "userSpaceOnUse"))) + + transform-pattern? (and (= :pattern tag) + (every? d/num-string? [(:x attrs "0") (:y attrs "0") (:width attrs "0") (:height attrs "0")]) + (= "userSpaceOnUse" (get attrs :patternUnits "userSpaceOnUse"))) + + transform-filter? (and (= #{:filter + ;; Filter primitives. We need to remap subregions + :feBlend :feColorMatrix :feComponentTransfer :feComposite :feConvolveMatrix + :feDiffuseLighting :feDisplacementMap :feFlood :feGaussianBlur + :feImage :feMerge :feMorphology :feOffset + :feSpecularLighting :feTile :feTurbulence} tag) + (= "userSpaceOnUse" (get attrs :filterUnits "userSpaceOnUse"))) + + attrs (-> attrs + (usvg/update-attr-ids prefix-id) + (usvg/clean-attrs) + + (cond-> + transform-gradient? (add-matrix :gradientTransform transform) + transform-pattern? (add-matrix :patternTransform transform) + transform-filter? (transform-region transform))) + + [wrapper wrapper-props] (if (= tag :mask) + ["g" #js {:transform (str transform)}] + [mf/Fragment (obj/new)])] + + [:> (name tag) (clj->js attrs) + [:> wrapper wrapper-props + (for [node content] [:& svg-node {:node node + :prefix-id prefix-id + :transform transform}])]]))) + +(mf/defc svg-defs [{:keys [shape render-id]}] + (let [svg-defs (:svg-defs shape) + transform (mf/use-memo + (mf/deps shape) + #(if (= :svg-raw (:type shape)) + (gmt/matrix) + (usvg/svg-transform-matrix shape))) + + prefix-id + (fn [id] + (cond->> id + (contains? svg-defs id) (str render-id "-")))] + + (when (and svg-defs (not (empty? svg-defs))) + (for [svg-def (vals svg-defs)] + [:& svg-node {:node svg-def + :prefix-id prefix-id + :transform transform}])))) + diff --git a/frontend/src/app/main/ui/shapes/svg_raw.cljs b/frontend/src/app/main/ui/shapes/svg_raw.cljs index d47a7ff39..d8fc4829a 100644 --- a/frontend/src/app/main/ui/shapes/svg_raw.cljs +++ b/frontend/src/app/main/ui/shapes/svg_raw.cljs @@ -21,7 +21,7 @@ [rumext.alpha :as mf])) ;; Graphic tags -(defonce graphic-element? #{ :circle :ellipse :image :line :path :polygon :polyline :rect :text #_"use"}) +(defonce graphic-element? #{:circle :ellipse :image :line :path :polygon :polyline :rect :text :use}) ;; Context to store a re-mapping of the ids (def svg-ids-ctx (mf/create-context nil)) @@ -37,17 +37,11 @@ (obj/set! "style" style)))) (defn translate-shape [attrs shape] - (let [{svg-width :width svg-height :height :as root-shape} (:root-attrs shape) - {:keys [x y width height]} (:selrect shape) - transform (->> (:transform attrs "") - (str (gmt/multiply - (gmt/matrix) - (gsh/transform-matrix shape) - (gmt/translate-matrix (gpt/point x y)) - (gmt/scale-matrix (gpt/point (/ width svg-width) (/ height svg-height)))) - " "))] + (let [transform (str (usvg/svg-transform-matrix shape) + " " + (:transform attrs ""))] (cond-> attrs - (and root-shape (graphic-element? (-> shape :content :tag))) + (and (:svg-viewbox shape) (graphic-element? (-> shape :content :tag))) (assoc :transform transform)))) (mf/defc svg-root diff --git a/frontend/src/app/main/ui/workspace/shapes/path.cljs b/frontend/src/app/main/ui/workspace/shapes/path.cljs index fd9fbe173..b1935e84d 100644 --- a/frontend/src/app/main/ui/workspace/shapes/path.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/path.cljs @@ -33,7 +33,6 @@ {::mf/wrap-props false} [props] (let [shape (unchecked-get props "shape") - hover? (or (mf/deref refs/current-hover) #{}) content-modifiers-ref (pc/make-content-modifiers-ref (:id shape)) content-modifiers (mf/deref content-modifiers-ref) editing-id (mf/deref refs/selected-edition) diff --git a/frontend/src/app/main/ui/workspace/shapes/svg_raw.cljs b/frontend/src/app/main/ui/workspace/shapes/svg_raw.cljs index 4ba0c4a8e..5563f353b 100644 --- a/frontend/src/app/main/ui/workspace/shapes/svg_raw.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/svg_raw.cljs @@ -64,6 +64,7 @@ :width width :height height :fill "transparent" + :stroke "none" :on-mouse-down handle-mouse-down :on-double-click handle-double-click :on-context-menu handle-context-menu diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/group.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/group.cljs index 16687671c..82dabbf03 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/group.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/group.cljs @@ -19,7 +19,8 @@ [app.main.ui.workspace.sidebar.options.blur :refer [blur-menu]] [app.main.ui.workspace.sidebar.options.shadow :refer [shadow-menu]] [app.main.ui.workspace.sidebar.options.stroke :refer [stroke-menu]] - [app.main.ui.workspace.sidebar.options.text :as ot])) + [app.main.ui.workspace.sidebar.options.text :as ot] + [app.main.ui.workspace.sidebar.options.svg-attrs :refer [svg-attrs-menu]])) (mf/defc options {::mf/wrap [mf/memo] @@ -36,6 +37,7 @@ [blur-ids blur-values] (get-attrs [shape] objects :blur) [stroke-ids stroke-values] (get-attrs [shape] objects :stroke) [text-ids text-values] (get-attrs [shape] objects :text) + [svg-ids svg-values] [[(:id shape)] (select-keys shape [:svg-attrs])] [comp-ids comp-values] [[(:id shape)] (select-keys shape component-attrs)]] [:div.options @@ -55,6 +57,10 @@ [:& stroke-menu {:type type :ids stroke-ids :values stroke-values}]) (when-not (empty? text-ids) - [:& ot/text-menu {:type type :ids text-ids :values text-values}])])) + [:& ot/text-menu {:type type :ids text-ids :values text-values}]) + + (when-not (empty? svg-values) + [:& svg-attrs-menu {:ids svg-ids + :values svg-values}])])) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/path.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/path.cljs index 363385f2f..05ed93fe2 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/path.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/path.cljs @@ -15,7 +15,8 @@ [app.main.ui.workspace.sidebar.options.fill :refer [fill-attrs fill-menu]] [app.main.ui.workspace.sidebar.options.stroke :refer [stroke-attrs stroke-menu]] [app.main.ui.workspace.sidebar.options.shadow :refer [shadow-menu]] - [app.main.ui.workspace.sidebar.options.blur :refer [blur-menu]])) + [app.main.ui.workspace.sidebar.options.blur :refer [blur-menu]] + [app.main.ui.workspace.sidebar.options.svg-attrs :refer [svg-attrs-menu]])) (mf/defc options [{:keys [shape] :as props}] @@ -36,4 +37,7 @@ [:& shadow-menu {:ids ids :values (select-keys shape [:shadow])}] [:& blur-menu {:ids ids - :values (select-keys shape [:blur])}]])) + :values (select-keys shape [:blur])}] + + [:& svg-attrs-menu {:ids ids + :values (select-keys shape [:svg-attrs])}]])) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/rows/input_row.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/rows/input_row.cljs index c21ff370d..7b4086804 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/rows/input_row.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/rows/input_row.cljs @@ -36,6 +36,11 @@ :placeholder placeholder :on-change on-change}] + :text + [:input {:value value + :class "input-text" + :on-change on-change} ] + [:> numeric-input {:placeholder placeholder :min min :max max diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/svg_attrs.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/svg_attrs.cljs new file mode 100644 index 000000000..4fc5d5f91 --- /dev/null +++ b/frontend/src/app/main/ui/workspace/sidebar/options/svg_attrs.cljs @@ -0,0 +1,53 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; This Source Code Form is "Incompatible With Secondary Licenses", as +;; defined by the Mozilla Public License, v. 2.0. +;; +;; Copyright (c) 2020 UXBOX Labs SL + +(ns app.main.ui.workspace.sidebar.options.svg-attrs + (:require + [app.common.data :as d] + [app.main.data.workspace.common :as dwc] + [app.main.store :as st] + [app.main.ui.workspace.sidebar.options.rows.input-row :refer [input-row]] + [app.util.dom :as dom] + [app.util.i18n :refer [tr]] + [rumext.alpha :as mf])) + +(mf/defc attribute-value [{:keys [attr value on-change] :as props}] + (let [handle-change + (mf/use-callback + (mf/deps attr on-change) + (fn [event] + (on-change attr (dom/get-target-val event))))] + [:div.element-set-content + [:& input-row {:label (name attr) + :type :text + :class "large" + :value (str value) + :on-change handle-change}]])) + +(mf/defc svg-attrs-menu [{:keys [ids type values]}] + (let [handle-change + (mf/use-callback + (mf/deps ids) + (fn [attr value] + (let [update-fn + (fn [shape] (assoc-in shape [:svg-attrs attr] value))] + + (st/emit! (dwc/update-shapes ids update-fn)))))] + + (when-not (empty? (:svg-attrs values)) + [:div.element-set + [:div.element-set-title + [:span (tr "workspace.sidebar.options.svg-attrs.title")]] + + (for [[index [attr-key attr-value]] (d/enumerate (:svg-attrs values))] + [:& attribute-value {:key attr-key + :ids ids + :attr attr-key + :value attr-value + :on-change handle-change}])]))) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/svg_raw.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/svg_raw.cljs index 6b024782d..a6ee9d346 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/svg_raw.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/svg_raw.cljs @@ -17,11 +17,12 @@ [app.main.ui.workspace.sidebar.options.fill :refer [fill-attrs fill-menu]] [app.main.ui.workspace.sidebar.options.stroke :refer [stroke-attrs stroke-menu]] [app.main.ui.workspace.sidebar.options.shadow :refer [shadow-menu]] - [app.main.ui.workspace.sidebar.options.blur :refer [blur-menu]])) + [app.main.ui.workspace.sidebar.options.blur :refer [blur-menu]] + [app.main.ui.workspace.sidebar.options.svg-attrs :refer [svg-attrs-menu]])) ;; This is a list of svg tags that can be grouped in shape-container ;; this allows them to have gradients, shadows and masks -(def svg-elements #{:svg :circle :ellipse :image :line :path :polygon :polyline :rect :symbol :text :textPath}) +(def svg-elements #{:svg :g :circle :ellipse :image :line :path :polygon :polyline :rect :symbol :text :textPath}) (defn hex->number [hex] 1) (defn shorthex->longhex [hex] @@ -113,4 +114,7 @@ :values (select-keys shape [:shadow])}] [:& blur-menu {:ids ids - :values (select-keys shape [:blur])}]]))) + :values (select-keys shape [:blur])}] + + [:& svg-attrs-menu {:ids ids + :values (select-keys shape [:svg-attrs])}]]))) diff --git a/frontend/src/app/util/a2c.js b/frontend/src/app/util/a2c.js new file mode 100644 index 000000000..62c3dcae9 --- /dev/null +++ b/frontend/src/app/util/a2c.js @@ -0,0 +1,203 @@ +/** + * Arc to Bezier curves transformer + * + * Is a modified and google closure complatible version of the a2c + * functions by https://github.com/fontello/svgpath + * + * @author UXBOX Labs SL + * @license MIT License + */ + +"use strict"; + +goog.provide("app.util.a2c"); + +// https://raw.githubusercontent.com/fontello/svgpath/master/lib/a2c.js +goog.scope(function() { + const self = app.util.a2c; + + var TAU = Math.PI * 2; + + /* eslint-disable space-infix-ops */ + + // Calculate an angle between two unit vectors + // + // Since we measure angle between radii of circular arcs, + // we can use simplified math (without length normalization) + // + function unit_vector_angle(ux, uy, vx, vy) { + var sign = (ux * vy - uy * vx < 0) ? -1 : 1; + var dot = ux * vx + uy * vy; + + // Add this to work with arbitrary vectors: + // dot /= Math.sqrt(ux * ux + uy * uy) * Math.sqrt(vx * vx + vy * vy); + + // rounding errors, e.g. -1.0000000000000002 can screw up this + if (dot > 1.0) { dot = 1.0; } + if (dot < -1.0) { dot = -1.0; } + + return sign * Math.acos(dot); + } + + + // Convert from endpoint to center parameterization, + // see http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes + // + // Return [cx, cy, theta1, delta_theta] + // + function get_arc_center(x1, y1, x2, y2, fa, fs, rx, ry, sin_phi, cos_phi) { + // Step 1. + // + // Moving an ellipse so origin will be the middlepoint between our two + // points. After that, rotate it to line up ellipse axes with coordinate + // axes. + // + var x1p = cos_phi*(x1-x2)/2 + sin_phi*(y1-y2)/2; + var y1p = -sin_phi*(x1-x2)/2 + cos_phi*(y1-y2)/2; + + var rx_sq = rx * rx; + var ry_sq = ry * ry; + var x1p_sq = x1p * x1p; + var y1p_sq = y1p * y1p; + + // Step 2. + // + // Compute coordinates of the centre of this ellipse (cx', cy') + // in the new coordinate system. + // + var radicant = (rx_sq * ry_sq) - (rx_sq * y1p_sq) - (ry_sq * x1p_sq); + + if (radicant < 0) { + // due to rounding errors it might be e.g. -1.3877787807814457e-17 + radicant = 0; + } + + radicant /= (rx_sq * y1p_sq) + (ry_sq * x1p_sq); + radicant = Math.sqrt(radicant) * (fa === fs ? -1 : 1); + + var cxp = radicant * rx/ry * y1p; + var cyp = radicant * -ry/rx * x1p; + + // Step 3. + // + // Transform back to get centre coordinates (cx, cy) in the original + // coordinate system. + // + var cx = cos_phi*cxp - sin_phi*cyp + (x1+x2)/2; + var cy = sin_phi*cxp + cos_phi*cyp + (y1+y2)/2; + + // Step 4. + // + // Compute angles (theta1, delta_theta). + // + var v1x = (x1p - cxp) / rx; + var v1y = (y1p - cyp) / ry; + var v2x = (-x1p - cxp) / rx; + var v2y = (-y1p - cyp) / ry; + + var theta1 = unit_vector_angle(1, 0, v1x, v1y); + var delta_theta = unit_vector_angle(v1x, v1y, v2x, v2y); + + if (fs === 0 && delta_theta > 0) { + delta_theta -= TAU; + } + if (fs === 1 && delta_theta < 0) { + delta_theta += TAU; + } + + return [ cx, cy, theta1, delta_theta ]; + } + + // + // Approximate one unit arc segment with bézier curves, + // see http://math.stackexchange.com/questions/873224 + // + function approximate_unit_arc(theta1, delta_theta) { + var alpha = 4/3 * Math.tan(delta_theta/4); + + var x1 = Math.cos(theta1); + var y1 = Math.sin(theta1); + var x2 = Math.cos(theta1 + delta_theta); + var y2 = Math.sin(theta1 + delta_theta); + + return [ x1, y1, x1 - y1*alpha, y1 + x1*alpha, x2 + y2*alpha, y2 - x2*alpha, x2, y2 ]; + } + + function a2c(x1, y1, x2, y2, fa, fs, rx, ry, phi) { + var sin_phi = Math.sin(phi * TAU / 360); + var cos_phi = Math.cos(phi * TAU / 360); + + // Make sure radii are valid + // + var x1p = cos_phi*(x1-x2)/2 + sin_phi*(y1-y2)/2; + var y1p = -sin_phi*(x1-x2)/2 + cos_phi*(y1-y2)/2; + + if (x1p === 0 && y1p === 0) { + // we're asked to draw line to itself + return []; + } + + if (rx === 0 || ry === 0) { + // one of the radii is zero + return []; + } + + + // Compensate out-of-range radii + // + rx = Math.abs(rx); + ry = Math.abs(ry); + + var lambda = (x1p * x1p) / (rx * rx) + (y1p * y1p) / (ry * ry); + if (lambda > 1) { + rx *= Math.sqrt(lambda); + ry *= Math.sqrt(lambda); + } + + + // Get center parameters (cx, cy, theta1, delta_theta) + // + var cc = get_arc_center(x1, y1, x2, y2, fa, fs, rx, ry, sin_phi, cos_phi); + + var result = []; + var theta1 = cc[2]; + var delta_theta = cc[3]; + + // Split an arc to multiple segments, so each segment + // will be less than τ/4 (= 90°) + // + var segments = Math.max(Math.ceil(Math.abs(delta_theta) / (TAU / 4)), 1); + delta_theta /= segments; + + for (var i = 0; i < segments; i++) { + result.push(approximate_unit_arc(theta1, delta_theta)); + theta1 += delta_theta; + } + + // We have a bezier approximation of a unit circle, + // now need to transform back to the original ellipse + // + return result.map(function (curve) { + for (var i = 0; i < curve.length; i += 2) { + var x = curve[i + 0]; + var y = curve[i + 1]; + + // scale + x *= rx; + y *= ry; + + // rotate + var xp = cos_phi*x - sin_phi*y; + var yp = sin_phi*x + cos_phi*y; + + // translate + curve[i + 0] = xp + cc[0]; + curve[i + 1] = yp + cc[1]; + } + + return curve; + }); + } + + self.a2c = a2c; +}); diff --git a/frontend/src/app/util/color.cljs b/frontend/src/app/util/color.cljs index 4c3ad3f63..e4fd537bc 100644 --- a/frontend/src/app/util/color.cljs +++ b/frontend/src/app/util/color.cljs @@ -116,6 +116,11 @@ (= id :multiple) (= file-id :multiple))) +(defn color? [^string color-str] + (and (not (nil? color-str)) + (not (empty? color-str)) + (gcolor/isValidColor color-str))) + (defn parse-color [^string color-str] (let [result (gcolor/parse color-str)] (str (.-hex ^js result)))) diff --git a/frontend/src/app/util/geom/path.cljs b/frontend/src/app/util/geom/path.cljs index 8fe7de5f1..9a5440103 100644 --- a/frontend/src/app/util/geom/path.cljs +++ b/frontend/src/app/util/geom/path.cljs @@ -9,12 +9,13 @@ (ns app.util.geom.path (:require - [cuerdas.core :as str] [app.common.data :as cd] - [app.util.data :as d] [app.common.data :as cd] [app.common.geom.point :as gpt] - [app.util.geom.path-impl-simplify :as impl-simplify])) + [app.util.a2c :refer [a2c]] + [app.util.data :as d] + [app.util.geom.path-impl-simplify :as impl-simplify] + [cuerdas.core :as str])) (defn simplify ([points] @@ -28,23 +29,42 @@ ;; Matches numbers for path values allows values like... -.01, 10, +12.22 ;; 0 and 1 are special because can refer to flags -(def num-regex #"([+-]?(([1-9]\d*(\.\d+)?)|(\.\d+)|0|1))") +(def num-regex #"[+-]?(\d+(\.\d+)?|\.\d+)") +(def flag-regex #"[01]") -(defn coord-n [size] - (re-pattern (str "(?i)[a-z]\\s*" - (->> (range size) - (map #(identity num-regex)) - (str/join "\\s+"))))) +(defn fix-dot-number [val] + (if (str/starts-with? val ".") + (str "0" val) + val)) +(defn extract-params [cmd-str extract-commands] + (loop [result [] + extract-idx 0 + current {} + remain (-> cmd-str (subs 1) (str/trim))] -(defn parse-params [cmd-str num-params] - (let [fix-starting-dot (fn [arg] (str/replace arg #"([^\d]|^)\." "$10."))] - (->> (re-seq num-regex cmd-str) - (map first) - (map fix-starting-dot) - (map d/read-string) - (partition num-params)))) + (let [[param type] (nth extract-commands extract-idx) + regex (case type + :flag flag-regex + #_:number num-regex) + match (re-find regex remain)] + + (if match + (let [value (-> match first fix-dot-number d/read-string) + remain (str/replace-first remain regex "") + current (assoc current param value) + extract-idx (inc extract-idx) + [result current extract-idx] + (if (>= extract-idx (count extract-commands)) + [(conj result current) {} 0] + [result current extract-idx])] + (recur result + extract-idx + current + remain)) + (cond-> result + (not (empty? current)) (conj current)))))) (defn command->param-list [{:keys [command params]}] (case command @@ -73,96 +93,99 @@ (defmethod parse-command "M" [cmd] (let [relative (str/starts-with? cmd "m") - params (parse-params cmd 2)] - (for [[x y] params] + param-list (extract-params cmd [[:x :number] + [:y :number]])] + (for [params param-list] {:command :move-to :relative relative - :params {:x x :y y}}))) + :params params}))) (defmethod parse-command "Z" [cmd] [{:command :close-path}]) (defmethod parse-command "L" [cmd] (let [relative (str/starts-with? cmd "l") - params (parse-params cmd 2)] - (for [[x y] params] + param-list (extract-params cmd [[:x :number] + [:y :number]])] + (for [params param-list] {:command :line-to :relative relative - :params {:x x :y y}}))) + :params params}))) (defmethod parse-command "H" [cmd] (let [relative (str/starts-with? cmd "h") - params (parse-params cmd 1)] - (for [[value] params] + param-list (extract-params cmd [[:value :number]])] + (for [params param-list] {:command :line-to-horizontal :relative relative - :params {:value value}}))) + :params params}))) (defmethod parse-command "V" [cmd] (let [relative (str/starts-with? cmd "v") - params (parse-params cmd 1)] - (for [[value] params] + param-list (extract-params cmd [[:value :number]])] + (for [params param-list] {:command :line-to-vertical :relative relative - :params {:value value}}))) + :params params}))) (defmethod parse-command "C" [cmd] (let [relative (str/starts-with? cmd "c") - params (parse-params cmd 6)] - (for [[c1x c1y c2x c2y x y] params] + param-list (extract-params cmd [[:c1x :number] + [:c1y :number] + [:c2x :number] + [:c2y :number] + [:x :number] + [:y :number]]) + ] + (for [params param-list] {:command :curve-to :relative relative - :params {:c1x c1x - :c1y c1y - :c2x c2x - :c2y c2y - :x x - :y y}}))) + :params params}))) (defmethod parse-command "S" [cmd] (let [relative (str/starts-with? cmd "s") - params (parse-params cmd 4)] - (for [[cx cy x y] params] + param-list (extract-params cmd [[:c1x :number] + [:c2y :number] + [:x :number] + [:y :number]])] + (for [params param-list] {:command :smooth-curve-to :relative relative - :params {:cx cx - :cy cy - :x x - :y y}}))) + :params params}))) (defmethod parse-command "Q" [cmd] (let [relative (str/starts-with? cmd "s") - params (parse-params cmd 4)] - (for [[cx cy x y] params] + param-list (extract-params cmd [[:c1x :number] + [:c1y :number] + [:x :number] + [:y :number]])] + (for [params param-list] {:command :quadratic-bezier-curve-to :relative relative - :params {:cx cx - :cy cy - :x x - :y y}}))) + :params params}))) (defmethod parse-command "T" [cmd] (let [relative (str/starts-with? cmd "t") - params (parse-params cmd (coord-n 2))] - (for [[cx cy x y] params] + param-list (extract-params cmd [[:x :number] + [:y :number]])] + (for [params param-list] {:command :smooth-quadratic-bezier-curve-to :relative relative - :params {:x x - :y y}}))) + :params params}))) (defmethod parse-command "A" [cmd] (let [relative (str/starts-with? cmd "a") - params (parse-params cmd 7)] - (for [[rx ry x-axis-rotation large-arc-flag sweep-flag x y] params] + param-list (extract-params cmd [[:rx :number] + [:ry :number] + [:x-axis-rotation :number] + [:large-arc-flag :flag] + [:sweep-flag :flag] + [:x :number] + [:y :number]])] + (for [params param-list] {:command :elliptical-arc :relative relative - :params {:rx rx - :ry ry - :x-axis-rotation x-axis-rotation - :large-arc-flag large-arc-flag - :sweep-flag sweep-flag - :x x - :y y}}))) + :params params}))) (defn command->string [{:keys [command relative params] :as entry}] (let [command-str (case command @@ -185,6 +208,21 @@ (contains? params :y)) (gpt/point params))) +(defn arc->beziers [prev command] + (let [to-command + (fn [[_ _ c1x c1y c2x c2y x y]] + {:command :curve-to + :relative (:relative command) + :params {:c1x c1x :c1y c1y + :c2x c2x :c2y c2y + :x x :y y}}) + + {from-x :x from-y :y} (:params prev) + {:keys [rx ry x-axis-rotation large-arc-flag sweep-flag x y]} (:params command) + result (a2c from-x from-y x y large-arc-flag sweep-flag rx ry x-axis-rotation)] + + (mapv to-command result))) + (defn simplify-commands "Removes some commands and convert relative to absolute coordinates" [commands] @@ -208,11 +246,13 @@ (:relative command) (-> (assoc :relative false) (cd/update-in-when [:params :x] + (:x pos)) - (cd/update-in-when [:params :y] + (:y pos))) - - - )] - [(cmd-pos command) (conj result command)])) + (cd/update-in-when [:params :y] + (:y pos)))) + + result #_(conj result command) + (if (= :elliptical-arc (:command command)) + (cd/concat result (arc->beziers prev command)) + (conj result command))] + [(cmd-pos command) result])) start (first commands) start-pos (cmd-pos start)] diff --git a/frontend/src/app/util/svg.cljs b/frontend/src/app/util/svg.cljs index 197130dbc..5e77c4529 100644 --- a/frontend/src/app/util/svg.cljs +++ b/frontend/src/app/util/svg.cljs @@ -11,9 +11,16 @@ (:require [app.common.uuid :as uuid] [app.common.data :as cd] + [app.common.geom.matrix :as gmt] + [app.common.geom.point :as gpt] + [app.common.geom.shapes :as gsh] [cuerdas.core :as str])) -(defonce replace-regex #"[^#]*#([^)\s]+).*") +(defonce replace-regex #"#([^\W]+)") + +(defn extract-ids [val] + (->> (re-seq replace-regex val) + (mapv second))) (defn clean-attrs "Transforms attributes to their react equivalent" @@ -36,34 +43,39 @@ (into {}))) (map-fn [[key val]] - (cond - (= key :class) [:className val] - (and (= key :style) (string? val)) [key (format-styles val)] - :else (vector (transform-key key) val)))] + (let [key (keyword key)] + (cond + (= key :class) [:className val] + (and (= key :style) (string? val)) [key (format-styles val)] + :else (vector (transform-key key) val))))] (->> attrs (map map-fn) (into {})))) +(defn update-attr-ids + "Replaces the ids inside a property" + [attrs replace-fn] + (letfn [(update-ids [key val] + (cond + (map? val) + (cd/mapm update-ids val) + + (= key :id) + (replace-fn val) + + :else + (let [replace-id + (fn [result it] + (str/replace result it (replace-fn it)))] + (reduce replace-id val (extract-ids val)))))] + (cd/mapm update-ids attrs))) + (defn replace-attrs-ids "Replaces the ids inside a property" [attrs ids-mapping] (if (and ids-mapping (not (empty? ids-mapping))) - (letfn [(replace-ids [key val] - (cond - (map? val) - (cd/mapm replace-ids val) - - (and (= key :id) (contains? ids-mapping val)) - (get ids-mapping val) - - :else - (let [[_ from-id] (re-matches replace-regex val)] - (if (and from-id (contains? ids-mapping from-id)) - (str/replace val from-id (get ids-mapping from-id)) - val))))] - (cd/mapm replace-ids attrs)) - + (update-attr-ids attrs (fn [id] (get ids-mapping id id))) ;; Ids-mapping is null attrs)) @@ -74,3 +86,83 @@ element-id (assoc element-id (str (uuid/next))))] (reduce visit-node result (:content node))))] (visit-node {} content))) + +(defn extract-defs [{:keys [tag content] :as node}] + + (if-not (map? node) + [{} node] + (letfn [(def-tag? [{:keys [tag]}] (= tag :defs)) + + (assoc-node [result node] + (assoc result (-> node :attrs :id) node)) + + (node-data [node] + (->> (:content node) (reduce assoc-node {})))] + + (let [current-def (->> content + (filterv def-tag?) + (map node-data) + (reduce merge)) + result (->> content + (filter (comp not def-tag?)) + (map extract-defs)) + + current-def (->> result (map first) (reduce merge current-def)) + content (->> result (mapv second))] + + [current-def (assoc node :content content)])))) + +(defn find-attr-references [attrs] + (->> attrs + (mapcat (fn [[_ attr-value]] (extract-ids attr-value))))) + +(defn find-node-references [node] + (let [current (->> (find-attr-references (:attrs node)) (into #{})) + children (->> (:content node) (map find-node-references) (flatten) (into #{}))] + (-> (cd/concat current children) + (vec)))) + +(defn find-def-references [defs references] + (loop [result (into #{} references) + checked? #{} + to-check (first references) + pending (rest references)] + + (cond + (nil? to-check) + result + + (checked? to-check) + (recur result + checked? + (first pending) + (rest pending)) + + :else + (let [node (get defs to-check) + new-refs (find-node-references node)] + (recur (cd/concat result new-refs) + (conj checked? to-check) + (first pending) + (rest pending)))))) + +(defn svg-transform-matrix [shape] + (if (:svg-viewbox shape) + (let [{svg-x :x + svg-y :y + svg-width :width + svg-height :height} (:svg-viewbox shape) + {:keys [x y width height]} (:selrect shape) + + scale-x (/ width svg-width) + scale-y (/ height svg-height)] + + (gmt/multiply + (gmt/matrix) + (gsh/transform-matrix shape) + (gmt/translate-matrix (gpt/point (- x (* scale-x svg-x)) (- y (* scale-y svg-y)))) + (gmt/scale-matrix (gpt/point scale-x scale-y)))) + + ;; :else + (gmt/matrix))) + diff --git a/vendor/svgclean/main.js b/vendor/svgclean/main.js index 60ae9479c..e9009ea74 100644 --- a/vendor/svgclean/main.js +++ b/vendor/svgclean/main.js @@ -1,3 +1,4 @@ +/* const plugins = [ {removeDimensions: true}, {removeScriptElement: true}, @@ -11,6 +12,63 @@ const plugins = [ forceAbsolutePath: true, }} ]; +*/ + +const plugins = [ + 'removeDoctype', + 'removeXMLProcInst', + 'removeComments', + 'removeMetadata', + // 'removeXMLNS', + 'removeEditorsNSData', + 'cleanupAttrs', + 'inlineStyles', + 'minifyStyles', + // 'convertStyleToAttrs' + 'cleanupIDs', + // 'prefixIds', + // 'removeRasterImages', + // 'removeUselessDefs', + 'cleanupNumericValues', + // 'cleanupListOfValues', + 'convertColors', + 'removeUnknownsAndDefaults', + 'removeNonInheritableGroupAttrs', + 'removeUselessStrokeAndFill', + // 'removeViewBox', + 'cleanupEnableBackground', + 'removeHiddenElems', + 'removeEmptyText', + 'convertShapeToPath', + 'convertEllipseToCircle', + // 'moveElemsAttrsToGroup', + 'moveGroupAttrsToElems', + 'collapseGroups', + {'convertPathData': { + 'lineShorthands': false, + 'curveSmoothShorthands': false, + 'forceAbsolutePath': true, + }}, + 'convertTransform', + 'removeEmptyAttrs', + 'removeEmptyContainers', + 'mergePaths', + 'removeUnusedNS', + // 'sortAttrs', + 'sortDefsChildren', + 'removeTitle', + 'removeDesc', + 'removeDimensions', + 'removeAttrs', + // 'removeAttributesBySelector', + // 'removeElementsByAttr', + // 'addClassesToSVGElement', + 'removeStyleElement', + 'removeScriptElement', + // 'addAttributesToSVGElement', + // 'removeOffCanvasPaths', + // 'reusePaths', +]; const svgc = require("./src/svgclean.js"); const inst = svgc.configure({plugins}); From 23d531a664576b2ac824ac686c0674f348f3651e Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 23 Feb 2021 10:11:43 +0100 Subject: [PATCH 03/15] :sparkles: Changed config for svgclean --- backend/resources/svgclean.js | 2 +- exporter/src/app/http/svgclean.js | 2 +- frontend/src/app/main/data/workspace/svg_upload.cljs | 2 +- vendor/svgclean/main.js | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/resources/svgclean.js b/backend/resources/svgclean.js index b0d7507b9..c8e51b5a7 100644 --- a/backend/resources/svgclean.js +++ b/backend/resources/svgclean.js @@ -1,4 +1,4 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).svgc=e()}}((function(){return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};t[o][0].call(u.exports,(function(e){return i(t[o][1][e]||e)}),u,u.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;oe.data))}},{"./src/svgclean.js":253}],2:[function(e,t,r){"use strict";r.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},r.toByteArray=function(e){var t,r,n=c(e),o=n[0],s=n[1],l=new a(function(e,t,r){return 3*(t+r)/4-r}(0,o,s)),u=0,d=s>0?o-4:o;for(r=0;r>16&255,l[u++]=t>>8&255,l[u++]=255&t;2===s&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,l[u++]=255&t);1===s&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,l[u++]=t>>8&255,l[u++]=255&t);return l},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,a=[],o=16383,s=0,l=r-i;sl?l:s+o));1===i?(t=e[r-1],a.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],a.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return a.join("")};for(var n=[],i=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,l=o.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,r){for(var i,a,o=[],s=t;s>18&63]+n[a>>12&63]+n[a>>6&63]+n[63&a]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(e,t,r){t.exports={trueFunc:function(){return!0},falseFunc:function(){return!1}}},{}],4:[function(e,t,r){},{}],5:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function a(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=l,this.end=c,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=u,this.end=d,t=3;break;default:return this.write=p,void(this.end=m)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function l(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function u(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function d(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function p(e){return e.toString(this.encoding)}function m(e){return e&&e.length?this.write(e):""}r.StringDecoder=a,a.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":6}],6:[function(e,t,r){ +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).svgc=e()}}((function(){return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};t[o][0].call(u.exports,(function(e){return i(t[o][1][e]||e)}),u,u.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;oe.data))}},{"./src/svgclean.js":253}],2:[function(e,t,r){"use strict";r.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},r.toByteArray=function(e){var t,r,n=c(e),o=n[0],s=n[1],l=new a(function(e,t,r){return 3*(t+r)/4-r}(0,o,s)),u=0,d=s>0?o-4:o;for(r=0;r>16&255,l[u++]=t>>8&255,l[u++]=255&t;2===s&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,l[u++]=255&t);1===s&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,l[u++]=t>>8&255,l[u++]=255&t);return l},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,a=[],o=16383,s=0,l=r-i;sl?l:s+o));1===i?(t=e[r-1],a.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],a.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return a.join("")};for(var n=[],i=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,l=o.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,r){for(var i,a,o=[],s=t;s>18&63]+n[a>>12&63]+n[a>>6&63]+n[63&a]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(e,t,r){t.exports={trueFunc:function(){return!0},falseFunc:function(){return!1}}},{}],4:[function(e,t,r){},{}],5:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function a(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=l,this.end=c,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=u,this.end=d,t=3;break;default:return this.write=p,void(this.end=m)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function l(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function u(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function d(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function p(e){return e.toString(this.encoding)}function m(e){return e&&e.length?this.write(e):""}r.StringDecoder=a,a.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":6}],6:[function(e,t,r){ /*! safe-buffer. MIT License. Feross Aboukhadijeh */ var n=e("buffer"),i=n.Buffer;function a(e,t){for(var r in e)t[r]=e[r]}function o(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(a(n,r),r.Buffer=o),o.prototype=Object.create(i.prototype),a(i,o),o.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,r)},o.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},{buffer:7}],7:[function(e,t,r){(function(t){(function(){ /*! diff --git a/exporter/src/app/http/svgclean.js b/exporter/src/app/http/svgclean.js index b0d7507b9..c8e51b5a7 100644 --- a/exporter/src/app/http/svgclean.js +++ b/exporter/src/app/http/svgclean.js @@ -1,4 +1,4 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).svgc=e()}}((function(){return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};t[o][0].call(u.exports,(function(e){return i(t[o][1][e]||e)}),u,u.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;oe.data))}},{"./src/svgclean.js":253}],2:[function(e,t,r){"use strict";r.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},r.toByteArray=function(e){var t,r,n=c(e),o=n[0],s=n[1],l=new a(function(e,t,r){return 3*(t+r)/4-r}(0,o,s)),u=0,d=s>0?o-4:o;for(r=0;r>16&255,l[u++]=t>>8&255,l[u++]=255&t;2===s&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,l[u++]=255&t);1===s&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,l[u++]=t>>8&255,l[u++]=255&t);return l},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,a=[],o=16383,s=0,l=r-i;sl?l:s+o));1===i?(t=e[r-1],a.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],a.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return a.join("")};for(var n=[],i=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,l=o.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,r){for(var i,a,o=[],s=t;s>18&63]+n[a>>12&63]+n[a>>6&63]+n[63&a]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(e,t,r){t.exports={trueFunc:function(){return!0},falseFunc:function(){return!1}}},{}],4:[function(e,t,r){},{}],5:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function a(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=l,this.end=c,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=u,this.end=d,t=3;break;default:return this.write=p,void(this.end=m)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function l(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function u(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function d(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function p(e){return e.toString(this.encoding)}function m(e){return e&&e.length?this.write(e):""}r.StringDecoder=a,a.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":6}],6:[function(e,t,r){ +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).svgc=e()}}((function(){return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};t[o][0].call(u.exports,(function(e){return i(t[o][1][e]||e)}),u,u.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;oe.data))}},{"./src/svgclean.js":253}],2:[function(e,t,r){"use strict";r.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},r.toByteArray=function(e){var t,r,n=c(e),o=n[0],s=n[1],l=new a(function(e,t,r){return 3*(t+r)/4-r}(0,o,s)),u=0,d=s>0?o-4:o;for(r=0;r>16&255,l[u++]=t>>8&255,l[u++]=255&t;2===s&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,l[u++]=255&t);1===s&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,l[u++]=t>>8&255,l[u++]=255&t);return l},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,a=[],o=16383,s=0,l=r-i;sl?l:s+o));1===i?(t=e[r-1],a.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],a.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return a.join("")};for(var n=[],i=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,l=o.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,r){for(var i,a,o=[],s=t;s>18&63]+n[a>>12&63]+n[a>>6&63]+n[63&a]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(e,t,r){t.exports={trueFunc:function(){return!0},falseFunc:function(){return!1}}},{}],4:[function(e,t,r){},{}],5:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function a(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=l,this.end=c,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=u,this.end=d,t=3;break;default:return this.write=p,void(this.end=m)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function l(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function u(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function d(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function p(e){return e.toString(this.encoding)}function m(e){return e&&e.length?this.write(e):""}r.StringDecoder=a,a.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":6}],6:[function(e,t,r){ /*! safe-buffer. MIT License. Feross Aboukhadijeh */ var n=e("buffer"),i=n.Buffer;function a(e,t){for(var r in e)t[r]=e[r]}function o(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(a(n,r),r.Buffer=o),o.prototype=Object.create(i.prototype),a(i,o),o.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,r)},o.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},{buffer:7}],7:[function(e,t,r){(function(t){(function(){ /*! diff --git a/frontend/src/app/main/data/workspace/svg_upload.cljs b/frontend/src/app/main/data/workspace/svg_upload.cljs index 5480088ba..18214357e 100644 --- a/frontend/src/app/main/data/workspace/svg_upload.cljs +++ b/frontend/src/app/main/data/workspace/svg_upload.cljs @@ -151,7 +151,7 @@ :points points} (assoc :svg-viewbox (select-keys selrect [:x :y :width :height])) (assoc :svg-attrs (dissoc attrs :d :transform)) - (gsh/translate-to-frame svg-data)))) + #_(gsh/translate-to-frame svg-data)))) (defn create-group [name frame-id svg-data {:keys [attrs]}] (let [{:keys [x y width height]} svg-data] diff --git a/vendor/svgclean/main.js b/vendor/svgclean/main.js index e9009ea74..1c7bc181e 100644 --- a/vendor/svgclean/main.js +++ b/vendor/svgclean/main.js @@ -25,7 +25,7 @@ const plugins = [ 'inlineStyles', 'minifyStyles', // 'convertStyleToAttrs' - 'cleanupIDs', + // 'cleanupIDs', // 'prefixIds', // 'removeRasterImages', // 'removeUselessDefs', @@ -43,7 +43,7 @@ const plugins = [ 'convertEllipseToCircle', // 'moveElemsAttrsToGroup', 'moveGroupAttrsToElems', - 'collapseGroups', + // 'collapseGroups', {'convertPathData': { 'lineShorthands': false, 'curveSmoothShorthands': false, From 94c5004c332b932dc0e75df105d4488140b3f086 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 23 Feb 2021 21:26:31 +0100 Subject: [PATCH 04/15] :sparkles: Improved geometry for rects --- common/app/common/geom/matrix.cljc | 11 -- common/app/common/geom/point.cljc | 5 + .../app/main/data/workspace/svg_upload.cljs | 83 ++++++------ frontend/src/app/main/ui/shapes/attrs.cljs | 3 +- frontend/src/app/main/ui/shapes/svg_defs.cljs | 5 + frontend/src/app/util/geom/path.cljs | 127 ++++++++++++++---- frontend/src/app/util/svg.cljs | 82 ++++++++++- 7 files changed, 228 insertions(+), 88 deletions(-) diff --git a/common/app/common/geom/matrix.cljc b/common/app/common/geom/matrix.cljc index 91f6ee630..8b9c9a59d 100644 --- a/common/app/common/geom/matrix.cljc +++ b/common/app/common/geom/matrix.cljc @@ -23,8 +23,6 @@ (toString [_] (str "matrix(" a "," b "," c "," d "," e "," f ")"))) -(defonce matrix-regex #"matrix\((.*),(.*),(.*),(.*),(.*),(.*)\)") - (defn matrix "Create a new matrix instance." ([] @@ -32,13 +30,6 @@ ([a b c d e f] (Matrix. a b c d e f))) -(defn parse-matrix [mtx] - (let [[_ a b c d e f] (re-matches matrix-regex mtx)] - (->> [a b c d e f] - (map str/trim) - (map d/parse-double) - (apply matrix)))) - (defn multiply ([{m1a :a m1b :b m1c :c m1d :d m1e :e m1f :f} {m2a :a m2b :b m2c :c m2d :d m2e :e m2f :f}] @@ -64,8 +55,6 @@ [v] (instance? Matrix v)) - - (def base (matrix)) (defn base? diff --git a/common/app/common/geom/point.cljc b/common/app/common/geom/point.cljc index f55c2e37c..11fff0f4b 100644 --- a/common/app/common/geom/point.cljc +++ b/common/app/common/geom/point.cljc @@ -204,6 +204,11 @@ (defn to-vec [p1 p2] (subtract p2 p1)) +(defn scale [v scalar] + (-> v + (update :x * scalar) + (update :y * scalar))) + (defn dot [{x1 :x y1 :y} {x2 :x y2 :y}] (+ (* x1 x2) (* y1 y2))) diff --git a/frontend/src/app/main/data/workspace/svg_upload.cljs b/frontend/src/app/main/data/workspace/svg_upload.cljs index 18214357e..bfe9cc602 100644 --- a/frontend/src/app/main/data/workspace/svg_upload.cljs +++ b/frontend/src/app/main/data/workspace/svg_upload.cljs @@ -41,13 +41,6 @@ (nil? tag) "node" :else (str tag)))) -(defn fix-dot-number - "Fixes decimal numbers starting in dot but without leading 0" - [num-str] - (if (str/starts-with? num-str ".") - (str "0" num-str) - num-str)) - (defn setup-fill [shape] (cond-> shape ;; Color present as attribute @@ -97,7 +90,8 @@ (-> (update-in [:svg-attrs :style] dissoc :stroke-width) (assoc :stroke-width (-> (get-in shape [:svg-attrs :style :stroke-width]) (ud/parse-float)))))] - (if (d/any-key? shape :stroke-color :stroke-opacity :stroke-width) + shape + #_(if (d/any-key? shape :stroke-color :stroke-opacity :stroke-width) (merge default-stroke shape) shape))) @@ -131,14 +125,13 @@ (assoc :svg-attrs (-> (:attrs svg-data) (dissoc :viewBox :xmlns)))))) -(defn apply-svg-transform [content transform-str] - (let [transform (gmt/parse-matrix transform-str)] - (gsh/transform-content content transform))) - (defn create-path-shape [name frame-id svg-data {:keys [attrs] :as data}] - (let [content (cond-> (ugp/path->content (:d attrs)) - (contains? attrs :transform) - (apply-svg-transform (:transform attrs))) + (let [svg-transform (usvg/parse-transform (:transform attrs)) + content (cond-> (ugp/path->content (:d attrs)) + svg-transform + (gsh/transform-content svg-transform)) + + attrs (d/update-when attrs :transform #(-> (usvg/parse-transform %) str)) selrect (gsh/content->selrect content) points (gsh/rect->points selrect)] @@ -151,7 +144,8 @@ :points points} (assoc :svg-viewbox (select-keys selrect [:x :y :width :height])) (assoc :svg-attrs (dissoc attrs :d :transform)) - #_(gsh/translate-to-frame svg-data)))) + (assoc :svg-transform svg-transform) + (gsh/translate-to-frame svg-data)))) (defn create-group [name frame-id svg-data {:keys [attrs]}] (let [{:keys [x y width height]} svg-data] @@ -208,37 +202,42 @@ (ptk/reify ::svg-uploaded ptk/WatchEvent (watch [_ state stream] - (let [page-id (:current-page-id state) - objects (dwc/lookup-page-objects state page-id) - frame-id (cp/frame-id-by-position objects {:x x :y y}) - selected (get-in state [:workspace-local :selected]) + (try + (let [page-id (:current-page-id state) + objects (dwc/lookup-page-objects state page-id) + frame-id (cp/frame-id-by-position objects {:x x :y y}) + selected (get-in state [:workspace-local :selected]) - [width height] (svg-dimensions svg-data) - x (- x (/ width 2)) - y (- y (/ height 2)) + [width height] (svg-dimensions svg-data) + x (- x (/ width 2)) + y (- y (/ height 2)) - unames (dwc/retrieve-used-names objects) + unames (dwc/retrieve-used-names objects) - svg-name (->> (str/replace (:name svg-data) ".svg" "") - (dwc/generate-unique-name unames)) + svg-name (->> (str/replace (:name svg-data) ".svg" "") + (dwc/generate-unique-name unames)) - ids-mappings (usvg/generate-id-mapping svg-data) - svg-data (-> svg-data - (assoc :x x - :y y - :width width - :height height - :name svg-name)) + ids-mappings (usvg/generate-id-mapping svg-data) + svg-data (-> svg-data + (assoc :x x + :y y + :width width + :height height + :name svg-name)) - [def-nodes svg-data] (usvg/extract-defs svg-data) - svg-data (assoc svg-data :defs def-nodes) + [def-nodes svg-data] (usvg/extract-defs svg-data) + svg-data (assoc svg-data :defs def-nodes) - root-shape (create-svg-root frame-id svg-data) - root-id (:id root-shape) + root-shape (create-svg-root frame-id svg-data) + root-id (:id root-shape) - changes (dwc/add-shape-changes page-id objects selected root-shape) + changes (dwc/add-shape-changes page-id objects selected root-shape) - reducer-fn (partial add-svg-child-changes page-id objects selected frame-id root-id svg-data ids-mappings) - [_ [rchanges uchanges]] (reduce reducer-fn [unames changes] (d/enumerate (:content svg-data)))] - (rx/of (dwc/commit-changes rchanges uchanges {:commit-local? true}) - (dwc/select-shapes (d/ordered-set root-id))))))) + reducer-fn (partial add-svg-child-changes page-id objects selected frame-id root-id svg-data ids-mappings) + [_ [rchanges uchanges]] (reduce reducer-fn [unames changes] (d/enumerate (:content svg-data)))] + (rx/of (dwc/commit-changes rchanges uchanges {:commit-local? true}) + (dwc/select-shapes (d/ordered-set root-id)))) + + (catch :default e + (.error js/console e)) + )))) diff --git a/frontend/src/app/main/ui/shapes/attrs.cljs b/frontend/src/app/main/ui/shapes/attrs.cljs index 1f4dde2dd..36e10f271 100644 --- a/frontend/src/app/main/ui/shapes/attrs.cljs +++ b/frontend/src/app/main/ui/shapes/attrs.cljs @@ -85,7 +85,8 @@ ;; If contains svg-attrs the origin is svg. If it's not svg origin ;; we setup the default fill as transparent (instead of black) - (not (contains? shape :svg-attrs)) + (and (not (contains? shape :svg-attrs)) + (not (= :svg-raw (:type shape)))) {:fill "transparent"} :else diff --git a/frontend/src/app/main/ui/shapes/svg_defs.cljs b/frontend/src/app/main/ui/shapes/svg_defs.cljs index cd2ca9e6e..e677aef9c 100644 --- a/frontend/src/app/main/ui/shapes/svg_defs.cljs +++ b/frontend/src/app/main/ui/shapes/svg_defs.cljs @@ -84,12 +84,17 @@ (mf/defc svg-defs [{:keys [shape render-id]}] (let [svg-defs (:svg-defs shape) + _ (when (:svg-transform shape) (.log js/console (str (:svg-transform shape)))) transform (mf/use-memo (mf/deps shape) #(if (= :svg-raw (:type shape)) (gmt/matrix) (usvg/svg-transform-matrix shape))) + ;;transform (gmt/multiply + ;; transform + ;; (:svg-transform shape (gmt/matrix))) + prefix-id (fn [id] (cond->> id diff --git a/frontend/src/app/util/geom/path.cljs b/frontend/src/app/util/geom/path.cljs index 9a5440103..b2ee450eb 100644 --- a/frontend/src/app/util/geom/path.cljs +++ b/frontend/src/app/util/geom/path.cljs @@ -15,8 +15,17 @@ [app.util.a2c :refer [a2c]] [app.util.data :as d] [app.util.geom.path-impl-simplify :as impl-simplify] + [app.util.svg :as usvg] [cuerdas.core :as str])) +(defn calculate-opposite-handler + "Given a point and its handler, gives the symetric handler" + [point handler] + (let [handler-vector (gpt/to-vec point handler)] + (gpt/add point (gpt/negate handler-vector)))) + +;;; + (defn simplify ([points] (simplify points 0.1)) @@ -33,11 +42,6 @@ (def flag-regex #"[01]") -(defn fix-dot-number [val] - (if (str/starts-with? val ".") - (str "0" val) - val)) - (defn extract-params [cmd-str extract-commands] (loop [result [] extract-idx 0 @@ -51,7 +55,7 @@ match (re-find regex remain)] (if match - (let [value (-> match first fix-dot-number d/read-string) + (let [value (-> match first usvg/fix-dot-number d/read-string) remain (str/replace-first remain regex "") current (assoc current param value) extract-idx (inc extract-idx) @@ -144,8 +148,8 @@ (defmethod parse-command "S" [cmd] (let [relative (str/starts-with? cmd "s") - param-list (extract-params cmd [[:c1x :number] - [:c2y :number] + param-list (extract-params cmd [[:cx :number] + [:cy :number] [:x :number] [:y :number]])] (for [params param-list] @@ -155,8 +159,8 @@ (defmethod parse-command "Q" [cmd] (let [relative (str/starts-with? cmd "s") - param-list (extract-params cmd [[:c1x :number] - [:c1y :number] + param-list (extract-params cmd [[:cx :number] + [:cy :number] [:x :number] [:y :number]])] (for [params param-list] @@ -203,12 +207,13 @@ param-list (command->param-list entry)] (str/fmt "%s%s" command-str (str/join " " param-list)))) -(defn cmd-pos [{:keys [params]}] - (when (and (contains? params :x) - (contains? params :y)) - (gpt/point params))) +(defn cmd-pos [prev-pos {:keys [relative params]}] + (let [{:keys [x y] :or {x (:x prev-pos) y (:y prev-pos)}} params] + (if relative + (-> prev-pos (update :x + x) (update :y + y)) + (gpt/point x y)))) -(defn arc->beziers [prev command] +(defn arc->beziers [from-p command] (let [to-command (fn [[_ _ c1x c1y c2x c2y x y]] {:command :curve-to @@ -217,7 +222,7 @@ :c2x c2x :c2y c2y :x x :y y}}) - {from-x :x from-y :y} (:params prev) + {from-x :x from-y :y} from-p {:keys [rx ry x-axis-rotation large-arc-flag sweep-flag x y]} (:params command) result (a2c from-x from-y x y large-arc-flag sweep-flag rx ry x-axis-rotation)] @@ -227,35 +232,99 @@ "Removes some commands and convert relative to absolute coordinates" [commands] - (let [simplify-command + (let [smooth->curve (fn [{:keys [params]} pos] + {:c1x (:x pos) + :c1y (:y pos) + :c2x (:cx params) + :c2y (:cy params)}) + + quadratic->curve (fn [{:keys [params]} pos] + (let [sp (gpt/point (:x pos) (:y pos)) ;; start point + ep (gpt/point (:x params) (:y params)) ;; end-point + cp (gpt/point (:cx params) (:cy params)) ;; control-point + + cp1 (-> (gpt/to-vec sp cp) + (gpt/scale (/ 2 3)) + (gpt/add sp)) + + cp2 (-> (gpt/to-vec ep cp) + (gpt/scale (/ 2 3)) + (gpt/add ep))] + + {:c1x (:x cp1) + :c1y (:y cp1) + :c2x (:x cp2) + :c2y (:y cp2)})) + + + smooth-quadratic->curve (fn [cmd {:keys [params]} pos] + (let [point (gpt/point (:x params) (:y params)) + handler (gpt/point (:cx params) (:cy params)) + oh (calculate-opposite-handler point handler)] + (quadratic->curve (update cmd :params assoc :cx (:x oh) :cy (:y oh)) pos))) + + simplify-command (fn [[pos result] [command prev]] (let [command + (cond-> command + (:relative command) + (-> (assoc :relative false) + (cd/update-in-when [:params :c1x] + (:x pos)) + (cd/update-in-when [:params :c1y] + (:y pos)) + + (cd/update-in-when [:params :c2x] + (:x pos)) + (cd/update-in-when [:params :c2y] + (:y pos)) + + (cd/update-in-when [:params :cx] + (:x pos)) + (cd/update-in-when [:params :cy] + (:y pos)) + + (cd/update-in-when [:params :x] + (:x pos)) + (cd/update-in-when [:params :y] + (:y pos)) + + (cond-> + (= :line-to-horizontal (:command command)) + (cd/update-in-when [:params :value] + (:x pos)) + + (= :line-to-vertical (:command command)) + (cd/update-in-when [:params :value] + (:y pos))))) + + params (:params command) + command (cond-> command (= :line-to-horizontal (:command command)) (-> (assoc :command :line-to) (update :params dissoc :value) - (assoc-in [:params :x] (get-in command [:params :value])) - (assoc-in [:params :y] (if (:relative command) 0 (:y pos)))) + (assoc-in [:params :x] (:value params)) + (assoc-in [:params :y] (:y pos))) (= :line-to-vertical (:command command)) (-> (assoc :command :line-to) (update :params dissoc :value) - (assoc-in [:params :y] (get-in command [:params :value])) - (assoc-in [:params :x] (if (:relative command) 0 (:x pos)))) + (assoc-in [:params :y] (:value params)) + (assoc-in [:params :x] (:x pos))) - (:relative command) - (-> (assoc :relative false) - (cd/update-in-when [:params :x] + (:x pos)) - (cd/update-in-when [:params :y] + (:y pos)))) + (= :smooth-curve-to (:command command)) + (-> (assoc :command :curve-to) + (update :params dissoc :cx :cy) + (update :params merge (smooth->curve command pos))) + + (= :quadratic-bezier-curve-to (:command command)) + (-> (assoc :command :curve-to) + (update :params dissoc :cx :cy) + (update :params merge (quadratic->curve command pos))) + + (= :smooth-quadratic-bezier-curve-to (:command command)) + (-> (assoc :command :curve-to) + (update :params merge (smooth-quadratic->curve command prev pos)))) result #_(conj result command) (if (= :elliptical-arc (:command command)) - (cd/concat result (arc->beziers prev command)) - (conj result command))] - [(cmd-pos command) result])) + (cd/concat result (arc->beziers pos command)) + (conj result command))] + [(cmd-pos pos command) result])) start (first commands) - start-pos (cmd-pos start)] + start-pos (gpt/point (:params start))] (->> (map vector (rest commands) commands) diff --git a/frontend/src/app/util/svg.cljs b/frontend/src/app/util/svg.cljs index 5e77c4529..08cc1ef38 100644 --- a/frontend/src/app/util/svg.cljs +++ b/frontend/src/app/util/svg.cljs @@ -10,7 +10,7 @@ (ns app.util.svg (:require [app.common.uuid :as uuid] - [app.common.data :as cd] + [app.common.data :as d] [app.common.geom.matrix :as gmt] [app.common.geom.point :as gpt] [app.common.geom.shapes :as gsh] @@ -22,6 +22,19 @@ (->> (re-seq replace-regex val) (mapv second))) +(defn fix-dot-number + "Fixes decimal numbers starting in dot but without leading 0" + [num-str] + (cond + (str/starts-with? num-str ".") + (str "0" num-str) + + (str/starts-with? num-str "-.") + (str "-0" (subs num-str 1)) + + :else + num-str)) + (defn clean-attrs "Transforms attributes to their react equivalent" [attrs] @@ -59,7 +72,7 @@ (letfn [(update-ids [key val] (cond (map? val) - (cd/mapm update-ids val) + (d/mapm update-ids val) (= key :id) (replace-fn val) @@ -69,7 +82,7 @@ (fn [result it] (str/replace result it (replace-fn it)))] (reduce replace-id val (extract-ids val)))))] - (cd/mapm update-ids attrs))) + (d/mapm update-ids attrs))) (defn replace-attrs-ids "Replaces the ids inside a property" @@ -119,7 +132,7 @@ (defn find-node-references [node] (let [current (->> (find-attr-references (:attrs node)) (into #{})) children (->> (:content node) (map find-node-references) (flatten) (into #{}))] - (-> (cd/concat current children) + (-> (d/concat current children) (vec)))) (defn find-def-references [defs references] @@ -141,7 +154,7 @@ :else (let [node (get defs to-check) new-refs (find-node-references node)] - (recur (cd/concat result new-refs) + (recur (d/concat result new-refs) (conj checked? to-check) (first pending) (rest pending)))))) @@ -166,3 +179,62 @@ ;; :else (gmt/matrix))) +;; Parse transform attributes to native matrix format so we can transform paths instead of +;; relying in SVG transformation. This is necessary to import SVG's and not to break path tooling +;; +;; Transforms spec: +;; https://www.w3.org/TR/SVG11/single-page.html#coords-TransformAttribute + +(def matrices-regex #"(matrix|translate|scale|rotate|skewX|skewY)\(([^\)]*)\)") +(def params-regex #"[+-]?\d*(\.\d+)?(e[+-]?\d+)?") + +(defn format-translate-params [params] + (assert (or (= (count params) 1) (= (count params) 2))) + (if (= (count params) 1) + [(gpt/point (nth params 0))] + [(gpt/point (nth params 0) (nth params 1))])) + +(defn format-scale-params [params] + (assert (or (= (count params) 1) (= (count params) 2))) + (if (= (count params) 1) + [(gpt/point (nth params 0))] + [(gpt/point (nth params 0) (nth params 1))])) + +(defn format-rotate-params [params] + (assert (or (= (count params) 1) (= (count params) 3)) (str "??" (count params))) + (if (= (count params) 1) + [(nth params 0)] + [(nth params 0) (gpt/point (nth params 1) (nth params 2))])) + +(defn format-skew-x-params [params] + (assert (= (count params) 1)) + [(nth params 0) 0]) + +(defn format-skew-y-params [params] + (assert (= (count params) 1)) + [0 (nth params 0)]) + +(defn to-matrix [{:keys [type params]}] + (assert (#{"matrix" "translate" "scale" "rotate" "skewX" "skewY"} type)) + (case type + "matrix" (apply gmt/matrix params) + "translate" (apply gmt/translate-matrix (format-translate-params params)) + "scale" (apply gmt/scale-matrix (format-scale-params params)) + "rotate" (apply gmt/rotate-matrix (format-rotate-params params)) + "skewX" (apply gmt/skew-matrix (format-skew-x-params params)) + "skewY" (apply gmt/skew-matrix (format-skew-y-params params)))) + +(defn parse-transform [transform-attr] + (when transform-attr + (let [process-matrix + (fn [[_ type params]] + (let [params (->> (re-seq params-regex params) + (filter #(-> % first empty? not)) + (map (comp d/parse-double first)))] + {:type type :params params})) + + matrices (->> (re-seq matrices-regex transform-attr) + (map process-matrix) + (map to-matrix))] + (reduce gmt/multiply (gmt/matrix) matrices)))) + From 59022904fb5ed4bac47c56591488030f541eeca5 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Thu, 25 Feb 2021 09:41:57 +0100 Subject: [PATCH 05/15] :sparkles: Handling group inheritance --- backend/resources/svgclean.js | 2 +- exporter/src/app/http/svgclean.js | 2 +- frontend/src/app/main/store.cljs | 3 +- frontend/src/app/main/ui/shapes/attrs.cljs | 4 +- frontend/src/app/main/ui/shapes/svg_defs.cljs | 10 +-- vendor/svgclean/main.js | 72 +++++++++---------- 6 files changed, 48 insertions(+), 45 deletions(-) diff --git a/backend/resources/svgclean.js b/backend/resources/svgclean.js index c8e51b5a7..b7b3aaa81 100644 --- a/backend/resources/svgclean.js +++ b/backend/resources/svgclean.js @@ -1,4 +1,4 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).svgc=e()}}((function(){return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};t[o][0].call(u.exports,(function(e){return i(t[o][1][e]||e)}),u,u.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;oe.data))}},{"./src/svgclean.js":253}],2:[function(e,t,r){"use strict";r.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},r.toByteArray=function(e){var t,r,n=c(e),o=n[0],s=n[1],l=new a(function(e,t,r){return 3*(t+r)/4-r}(0,o,s)),u=0,d=s>0?o-4:o;for(r=0;r>16&255,l[u++]=t>>8&255,l[u++]=255&t;2===s&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,l[u++]=255&t);1===s&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,l[u++]=t>>8&255,l[u++]=255&t);return l},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,a=[],o=16383,s=0,l=r-i;sl?l:s+o));1===i?(t=e[r-1],a.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],a.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return a.join("")};for(var n=[],i=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,l=o.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,r){for(var i,a,o=[],s=t;s>18&63]+n[a>>12&63]+n[a>>6&63]+n[63&a]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(e,t,r){t.exports={trueFunc:function(){return!0},falseFunc:function(){return!1}}},{}],4:[function(e,t,r){},{}],5:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function a(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=l,this.end=c,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=u,this.end=d,t=3;break;default:return this.write=p,void(this.end=m)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function l(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function u(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function d(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function p(e){return e.toString(this.encoding)}function m(e){return e&&e.length?this.write(e):""}r.StringDecoder=a,a.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":6}],6:[function(e,t,r){ +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).svgc=e()}}((function(){return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};t[o][0].call(u.exports,(function(e){return i(t[o][1][e]||e)}),u,u.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;oe.data))}},{"./src/svgclean.js":253}],2:[function(e,t,r){"use strict";r.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},r.toByteArray=function(e){var t,r,n=c(e),o=n[0],s=n[1],l=new a(function(e,t,r){return 3*(t+r)/4-r}(0,o,s)),u=0,d=s>0?o-4:o;for(r=0;r>16&255,l[u++]=t>>8&255,l[u++]=255&t;2===s&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,l[u++]=255&t);1===s&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,l[u++]=t>>8&255,l[u++]=255&t);return l},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,a=[],o=16383,s=0,l=r-i;sl?l:s+o));1===i?(t=e[r-1],a.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],a.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return a.join("")};for(var n=[],i=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,l=o.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,r){for(var i,a,o=[],s=t;s>18&63]+n[a>>12&63]+n[a>>6&63]+n[63&a]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(e,t,r){t.exports={trueFunc:function(){return!0},falseFunc:function(){return!1}}},{}],4:[function(e,t,r){},{}],5:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function a(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=l,this.end=c,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=u,this.end=d,t=3;break;default:return this.write=p,void(this.end=m)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function l(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function u(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function d(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function p(e){return e.toString(this.encoding)}function m(e){return e&&e.length?this.write(e):""}r.StringDecoder=a,a.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":6}],6:[function(e,t,r){ /*! safe-buffer. MIT License. Feross Aboukhadijeh */ var n=e("buffer"),i=n.Buffer;function a(e,t){for(var r in e)t[r]=e[r]}function o(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(a(n,r),r.Buffer=o),o.prototype=Object.create(i.prototype),a(i,o),o.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,r)},o.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},{buffer:7}],7:[function(e,t,r){(function(t){(function(){ /*! diff --git a/exporter/src/app/http/svgclean.js b/exporter/src/app/http/svgclean.js index c8e51b5a7..b7b3aaa81 100644 --- a/exporter/src/app/http/svgclean.js +++ b/exporter/src/app/http/svgclean.js @@ -1,4 +1,4 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).svgc=e()}}((function(){return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};t[o][0].call(u.exports,(function(e){return i(t[o][1][e]||e)}),u,u.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;oe.data))}},{"./src/svgclean.js":253}],2:[function(e,t,r){"use strict";r.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},r.toByteArray=function(e){var t,r,n=c(e),o=n[0],s=n[1],l=new a(function(e,t,r){return 3*(t+r)/4-r}(0,o,s)),u=0,d=s>0?o-4:o;for(r=0;r>16&255,l[u++]=t>>8&255,l[u++]=255&t;2===s&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,l[u++]=255&t);1===s&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,l[u++]=t>>8&255,l[u++]=255&t);return l},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,a=[],o=16383,s=0,l=r-i;sl?l:s+o));1===i?(t=e[r-1],a.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],a.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return a.join("")};for(var n=[],i=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,l=o.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,r){for(var i,a,o=[],s=t;s>18&63]+n[a>>12&63]+n[a>>6&63]+n[63&a]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(e,t,r){t.exports={trueFunc:function(){return!0},falseFunc:function(){return!1}}},{}],4:[function(e,t,r){},{}],5:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function a(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=l,this.end=c,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=u,this.end=d,t=3;break;default:return this.write=p,void(this.end=m)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function l(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function u(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function d(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function p(e){return e.toString(this.encoding)}function m(e){return e&&e.length?this.write(e):""}r.StringDecoder=a,a.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":6}],6:[function(e,t,r){ +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).svgc=e()}}((function(){return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};t[o][0].call(u.exports,(function(e){return i(t[o][1][e]||e)}),u,u.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;oe.data))}},{"./src/svgclean.js":253}],2:[function(e,t,r){"use strict";r.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},r.toByteArray=function(e){var t,r,n=c(e),o=n[0],s=n[1],l=new a(function(e,t,r){return 3*(t+r)/4-r}(0,o,s)),u=0,d=s>0?o-4:o;for(r=0;r>16&255,l[u++]=t>>8&255,l[u++]=255&t;2===s&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,l[u++]=255&t);1===s&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,l[u++]=t>>8&255,l[u++]=255&t);return l},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,a=[],o=16383,s=0,l=r-i;sl?l:s+o));1===i?(t=e[r-1],a.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],a.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return a.join("")};for(var n=[],i=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,l=o.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,r){for(var i,a,o=[],s=t;s>18&63]+n[a>>12&63]+n[a>>6&63]+n[63&a]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(e,t,r){t.exports={trueFunc:function(){return!0},falseFunc:function(){return!1}}},{}],4:[function(e,t,r){},{}],5:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function a(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=l,this.end=c,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=u,this.end=d,t=3;break;default:return this.write=p,void(this.end=m)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function l(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function u(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function d(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function p(e){return e.toString(this.encoding)}function m(e){return e&&e.length?this.write(e):""}r.StringDecoder=a,a.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":6}],6:[function(e,t,r){ /*! safe-buffer. MIT License. Feross Aboukhadijeh */ var n=e("buffer"),i=n.Buffer;function a(e,t){for(var r in e)t[r]=e[r]}function o(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(a(n,r),r.Buffer=o),o.prototype=Object.create(i.prototype),a(i,o),o.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,r)},o.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},{buffer:7}],7:[function(e,t,r){(function(t){(function(){ /*! diff --git a/frontend/src/app/main/store.cljs b/frontend/src/app/main/store.cljs index b295aee83..72ec01dab 100644 --- a/frontend/src/app/main/store.cljs +++ b/frontend/src/app/main/store.cljs @@ -78,7 +78,8 @@ (defn ^:export dump-object [name] (let [page-id (get @state :current-page-id)] (let [objects (get-in @state [:workspace-data :pages-index page-id :objects]) - target (d/seek (fn [[id shape]] (= name (:name shape))) objects)] + target (or (d/seek (fn [[id shape]] (= name (:name shape))) objects) + (get objects (uuid name)))] (->> target (logjs "state"))))) diff --git a/frontend/src/app/main/ui/shapes/attrs.cljs b/frontend/src/app/main/ui/shapes/attrs.cljs index 36e10f271..b94cf0dce 100644 --- a/frontend/src/app/main/ui/shapes/attrs.cljs +++ b/frontend/src/app/main/ui/shapes/attrs.cljs @@ -116,7 +116,6 @@ (obj/merge! attrs (clj->js stroke-attrs))) attrs))) - (defn extract-svg-attrs [render-id svg-defs svg-attrs] (let [replace-id (fn [id] @@ -124,8 +123,9 @@ (str render-id "-" id) id)) svg-attrs (-> svg-attrs + (usvg/clean-attrs) (usvg/update-attr-ids replace-id) - (usvg/clean-attrs)) + ) attrs (-> svg-attrs (dissoc :style) (clj->js)) styles (-> svg-attrs (:style {}) (clj->js))] diff --git a/frontend/src/app/main/ui/shapes/svg_defs.cljs b/frontend/src/app/main/ui/shapes/svg_defs.cljs index e677aef9c..1c4cb2f62 100644 --- a/frontend/src/app/main/ui/shapes/svg_defs.cljs +++ b/frontend/src/app/main/ui/shapes/svg_defs.cljs @@ -84,16 +84,18 @@ (mf/defc svg-defs [{:keys [shape render-id]}] (let [svg-defs (:svg-defs shape) - _ (when (:svg-transform shape) (.log js/console (str (:svg-transform shape)))) + ;;_ (when (:svg-transform shape) + ;; (.log js/console (:name shape) (:old-transform shape) (str (:svg-transform shape)))) + transform (mf/use-memo (mf/deps shape) #(if (= :svg-raw (:type shape)) (gmt/matrix) (usvg/svg-transform-matrix shape))) - ;;transform (gmt/multiply - ;; transform - ;; (:svg-transform shape (gmt/matrix))) + transform (gmt/multiply + transform + (or (:svg-transform shape) (gmt/matrix))) prefix-id (fn [id] diff --git a/vendor/svgclean/main.js b/vendor/svgclean/main.js index 1c7bc181e..6a27edcf6 100644 --- a/vendor/svgclean/main.js +++ b/vendor/svgclean/main.js @@ -15,56 +15,56 @@ const plugins = [ */ const plugins = [ - 'removeDoctype', - 'removeXMLProcInst', - 'removeComments', - 'removeMetadata', + // 'removeDoctype', + // 'removeXMLProcInst', + // 'removeComments', + // 'removeMetadata', // 'removeXMLNS', - 'removeEditorsNSData', - 'cleanupAttrs', - 'inlineStyles', - 'minifyStyles', + // 'removeEditorsNSData', + // 'cleanupAttrs', + // 'inlineStyles', + // 'minifyStyles', // 'convertStyleToAttrs' // 'cleanupIDs', // 'prefixIds', // 'removeRasterImages', // 'removeUselessDefs', - 'cleanupNumericValues', + // 'cleanupNumericValues', // 'cleanupListOfValues', - 'convertColors', - 'removeUnknownsAndDefaults', - 'removeNonInheritableGroupAttrs', - 'removeUselessStrokeAndFill', + // 'convertColors', + // 'removeUnknownsAndDefaults', + // 'removeNonInheritableGroupAttrs', + // 'removeUselessStrokeAndFill', // 'removeViewBox', - 'cleanupEnableBackground', - 'removeHiddenElems', - 'removeEmptyText', - 'convertShapeToPath', - 'convertEllipseToCircle', + // 'cleanupEnableBackground', + // 'removeHiddenElems', + // 'removeEmptyText', + // 'convertShapeToPath', + // 'convertEllipseToCircle', // 'moveElemsAttrsToGroup', - 'moveGroupAttrsToElems', + // 'moveGroupAttrsToElems', // 'collapseGroups', - {'convertPathData': { - 'lineShorthands': false, - 'curveSmoothShorthands': false, - 'forceAbsolutePath': true, - }}, - 'convertTransform', - 'removeEmptyAttrs', - 'removeEmptyContainers', - 'mergePaths', - 'removeUnusedNS', + // {'convertPathData': { + // 'lineShorthands': false, + // 'curveSmoothShorthands': false, + // 'forceAbsolutePath': true, + // }}, + // 'convertTransform', + // 'removeEmptyAttrs', + // 'removeEmptyContainers', + // 'mergePaths', + // 'removeUnusedNS', // 'sortAttrs', - 'sortDefsChildren', - 'removeTitle', - 'removeDesc', - 'removeDimensions', - 'removeAttrs', + // 'sortDefsChildren', + // 'removeTitle', + // 'removeDesc', + // 'removeDimensions', + // 'removeAttrs', // 'removeAttributesBySelector', // 'removeElementsByAttr', // 'addClassesToSVGElement', - 'removeStyleElement', - 'removeScriptElement', + // 'removeStyleElement', + // 'removeScriptElement', // 'addAttributesToSVGElement', // 'removeOffCanvasPaths', // 'reusePaths', From 6e88d3a04c1fab884ea447af6dda0f8682bbcde5 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 26 Feb 2021 22:06:54 +0100 Subject: [PATCH 06/15] :sparkles: Adds imported rectangles SVGs --- backend/resources/svgclean.js | 4 +- common/app/common/geom/shapes.cljc | 1 + common/app/common/geom/shapes/transforms.cljc | 75 +++++++------ exporter/src/app/http/svgclean.js | 4 +- .../app/main/data/workspace/svg_upload.cljs | 101 +++++++++++++++--- frontend/src/app/main/ui/shapes/svg_raw.cljs | 3 +- .../ui/workspace/shapes/bounding_box.cljs | 41 +++---- frontend/src/app/util/svg.cljs | 5 +- vendor/svgclean/main.js | 100 ++++++----------- .../svgclean/plugins/moveGroupAttrsToElems.js | 3 - 10 files changed, 194 insertions(+), 143 deletions(-) diff --git a/backend/resources/svgclean.js b/backend/resources/svgclean.js index b7b3aaa81..76ad5235c 100644 --- a/backend/resources/svgclean.js +++ b/backend/resources/svgclean.js @@ -1,4 +1,4 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).svgc=e()}}((function(){return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};t[o][0].call(u.exports,(function(e){return i(t[o][1][e]||e)}),u,u.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;oe.data))}},{"./src/svgclean.js":253}],2:[function(e,t,r){"use strict";r.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},r.toByteArray=function(e){var t,r,n=c(e),o=n[0],s=n[1],l=new a(function(e,t,r){return 3*(t+r)/4-r}(0,o,s)),u=0,d=s>0?o-4:o;for(r=0;r>16&255,l[u++]=t>>8&255,l[u++]=255&t;2===s&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,l[u++]=255&t);1===s&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,l[u++]=t>>8&255,l[u++]=255&t);return l},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,a=[],o=16383,s=0,l=r-i;sl?l:s+o));1===i?(t=e[r-1],a.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],a.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return a.join("")};for(var n=[],i=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,l=o.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,r){for(var i,a,o=[],s=t;s>18&63]+n[a>>12&63]+n[a>>6&63]+n[63&a]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(e,t,r){t.exports={trueFunc:function(){return!0},falseFunc:function(){return!1}}},{}],4:[function(e,t,r){},{}],5:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function a(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=l,this.end=c,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=u,this.end=d,t=3;break;default:return this.write=p,void(this.end=m)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function l(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function u(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function d(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function p(e){return e.toString(this.encoding)}function m(e){return e&&e.length?this.write(e):""}r.StringDecoder=a,a.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":6}],6:[function(e,t,r){ +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).svgc=e()}}((function(){return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};t[o][0].call(u.exports,(function(e){return i(t[o][1][e]||e)}),u,u.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;oe.data))}},{"./src/svgclean.js":253}],2:[function(e,t,r){"use strict";r.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},r.toByteArray=function(e){var t,r,n=c(e),o=n[0],s=n[1],l=new a(function(e,t,r){return 3*(t+r)/4-r}(0,o,s)),u=0,d=s>0?o-4:o;for(r=0;r>16&255,l[u++]=t>>8&255,l[u++]=255&t;2===s&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,l[u++]=255&t);1===s&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,l[u++]=t>>8&255,l[u++]=255&t);return l},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,a=[],o=16383,s=0,l=r-i;sl?l:s+o));1===i?(t=e[r-1],a.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],a.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return a.join("")};for(var n=[],i=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,l=o.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,r){for(var i,a,o=[],s=t;s>18&63]+n[a>>12&63]+n[a>>6&63]+n[63&a]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],3:[function(e,t,r){t.exports={trueFunc:function(){return!0},falseFunc:function(){return!1}}},{}],4:[function(e,t,r){},{}],5:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer,i=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function a(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=l,this.end=c,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=u,this.end=d,t=3;break;default:return this.write=p,void(this.end=m)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function l(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function u(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function d(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function p(e){return e.toString(this.encoding)}function m(e){return e&&e.length?this.write(e):""}r.StringDecoder=a,a.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":6}],6:[function(e,t,r){ /*! safe-buffer. MIT License. Feross Aboukhadijeh */ var n=e("buffer"),i=n.Buffer;function a(e,t){for(var r in e)t[r]=e[r]}function o(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(a(n,r),r.Buffer=o),o.prototype=Object.create(i.prototype),a(i,o),o.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,r)},o.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},{buffer:7}],7:[function(e,t,r){(function(t){(function(){ /*! @@ -13,7 +13,7 @@ r.read=function(e,t,r,n,i){var a,o,s=8*i-n-1,l=(1<>1,u=-7,d=r?i-1:0,p= /*! http://mths.be/fromcodepoint v0.1.0 by @mathias */,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){var e;E(e=this),""!==e.cdata&&(A(e,"oncdata",e.cdata),e.cdata=""),""!==e.script&&(A(e,"onscript",e.script),e.script="")}};try{n=e("stream").Stream}catch(e){n=function(){}}var o=r.EVENTS.filter((function(e){return"error"!==e&&"end"!==e}));function s(e,t){if(!(this instanceof s))return new s(e,t);n.apply(this),this._parser=new a(e,t),this.writable=!0,this.readable=!0;var r=this;this._parser.onend=function(){r.emit("end")},this._parser.onerror=function(e){r.emit("error",e),r._parser.error=null},this._decoder=null,o.forEach((function(e){Object.defineProperty(r,"on"+e,{get:function(){return r._parser["on"+e]},set:function(t){if(!t)return r.removeAllListeners(e),r._parser["on"+e]=t,t;r.on(e,t)},enumerable:!0,configurable:!1})}))}s.prototype=Object.create(n.prototype,{constructor:{value:s}}),s.prototype.write=function(r){if("function"==typeof t&&"function"==typeof t.isBuffer&&t.isBuffer(r)){if(!this._decoder){var n=e("string_decoder").StringDecoder;this._decoder=new n("utf8")}r=this._decoder.write(r)}return this._parser.write(r.toString()),this.emit("data",r),!0},s.prototype.end=function(e){return e&&e.length&&this.write(e),this._parser.end(),!0},s.prototype.on=function(e,t){var r=this;return r._parser["on"+e]||-1===o.indexOf(e)||(r._parser["on"+e]=function(){var t=1===arguments.length?[arguments[0]]:Array.apply(null,arguments);t.splice(0,0,e),r.emit.apply(r,t)}),n.prototype.on.call(r,e,t)};var l="http://www.w3.org/XML/1998/namespace",c="http://www.w3.org/2000/xmlns/",u={xml:l,xmlns:c},d=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,p=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,m=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,h=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function f(e){return" "===e||"\n"===e||"\r"===e||"\t"===e}function g(e){return'"'===e||"'"===e}function y(e){return">"===e||f(e)}function b(e,t){return e.test(t)}function v(e,t){return!b(e,t)}var S,x,k,w=0;for(var C in r.STATE={BEGIN:w++,BEGIN_WHITESPACE:w++,TEXT:w++,TEXT_ENTITY:w++,OPEN_WAKA:w++,SGML_DECL:w++,SGML_DECL_QUOTED:w++,DOCTYPE:w++,DOCTYPE_QUOTED:w++,DOCTYPE_DTD:w++,DOCTYPE_DTD_QUOTED:w++,COMMENT_STARTING:w++,COMMENT:w++,COMMENT_ENDING:w++,COMMENT_ENDED:w++,CDATA:w++,CDATA_ENDING:w++,CDATA_ENDING_2:w++,PROC_INST:w++,PROC_INST_BODY:w++,PROC_INST_ENDING:w++,OPEN_TAG:w++,OPEN_TAG_SLASH:w++,ATTRIB:w++,ATTRIB_NAME:w++,ATTRIB_NAME_SAW_WHITE:w++,ATTRIB_VALUE:w++,ATTRIB_VALUE_QUOTED:w++,ATTRIB_VALUE_CLOSED:w++,ATTRIB_VALUE_UNQUOTED:w++,ATTRIB_VALUE_ENTITY_Q:w++,ATTRIB_VALUE_ENTITY_U:w++,CLOSE_TAG:w++,CLOSE_TAG_SAW_WHITE:w++,SCRIPT:w++,SCRIPT_ENDING:w++},r.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},r.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(r.ENTITIES).forEach((function(e){var t=r.ENTITIES[e],n="number"==typeof t?String.fromCharCode(t):t;r.ENTITIES[e]=n})),r.STATE)r.STATE[r.STATE[C]]=C;function T(e,t,r){e[t]&&e[t](r)}function A(e,t,r){e.textNode&&E(e),T(e,t,r)}function E(e){e.textNode=O(e.opt,e.textNode),e.textNode&&T(e,"ontext",e.textNode),e.textNode=""}function O(e,t){return e.trim&&(t=t.trim()),e.normalize&&(t=t.replace(/\s+/g," ")),t}function _(e,t){return E(e),e.trackPosition&&(t+="\nLine: "+e.line+"\nColumn: "+e.column+"\nChar: "+e.c),t=new Error(t),e.error=t,T(e,"onerror",t),e}function z(e){return e.sawRoot&&!e.closedRoot&&P(e,"Unclosed root tag"),e.state!==w.BEGIN&&e.state!==w.BEGIN_WHITESPACE&&e.state!==w.TEXT&&_(e,"Unexpected end"),E(e),e.c="",e.closed=!0,T(e,"onend"),a.call(e,e.strict,e.opt),e}function P(e,t){if("object"!=typeof e||!(e instanceof a))throw new Error("bad call to strictFail");e.strict&&_(e,t)}function L(e){e.strict||(e.tagName=e.tagName[e.looseCase]());var t=e.tags[e.tags.length-1]||e,r=e.tag={name:e.tagName,attributes:{}};e.opt.xmlns&&(r.ns=t.ns),e.attribList.length=0,A(e,"onopentagstart",r)}function R(e,t){var r=e.indexOf(":")<0?["",e]:e.split(":"),n=r[0],i=r[1];return t&&"xmlns"===e&&(n="xmlns",i=""),{prefix:n,local:i}}function B(e){if(e.strict||(e.attribName=e.attribName[e.looseCase]()),-1!==e.attribList.indexOf(e.attribName)||e.tag.attributes.hasOwnProperty(e.attribName))e.attribName=e.attribValue="";else{if(e.opt.xmlns){var t=R(e.attribName,!0),r=t.prefix,n=t.local;if("xmlns"===r)if("xml"===n&&e.attribValue!==l)P(e,"xml: prefix must be bound to "+l+"\nActual: "+e.attribValue);else if("xmlns"===n&&e.attribValue!==c)P(e,"xmlns: prefix must be bound to "+c+"\nActual: "+e.attribValue);else{var i=e.tag,a=e.tags[e.tags.length-1]||e;i.ns===a.ns&&(i.ns=Object.create(a.ns)),i.ns[n]=e.attribValue}e.attribList.push([e.attribName,e.attribValue])}else e.tag.attributes[e.attribName]=e.attribValue,A(e,"onattribute",{name:e.attribName,value:e.attribValue});e.attribName=e.attribValue=""}}function q(e,t){if(e.opt.xmlns){var r=e.tag,n=R(e.tagName);r.prefix=n.prefix,r.local=n.local,r.uri=r.ns[n.prefix]||"",r.prefix&&!r.uri&&(P(e,"Unbound namespace prefix: "+JSON.stringify(e.tagName)),r.uri=n.prefix);var i=e.tags[e.tags.length-1]||e;r.ns&&i.ns!==r.ns&&Object.keys(r.ns).forEach((function(t){A(e,"onopennamespace",{prefix:t,uri:r.ns[t]})}));for(var a=0,o=e.attribList.length;a",e.tagName="",void(e.state=w.SCRIPT);A(e,"onscript",e.script),e.script=""}var t=e.tags.length,r=e.tagName;e.strict||(r=r[e.looseCase]());for(var n=r;t--;){if(e.tags[t].name===n)break;P(e,"Unexpected close tag")}if(t<0)return P(e,"Unmatched closing tag: "+e.tagName),e.textNode+="",void(e.state=w.TEXT);e.tagName=r;for(var i=e.tags.length;i-- >t;){var a=e.tag=e.tags.pop();e.tagName=e.tag.name,A(e,"onclosetag",e.tagName);var o={};for(var s in a.ns)o[s]=a.ns[s];var l=e.tags[e.tags.length-1]||e;e.opt.xmlns&&a.ns!==l.ns&&Object.keys(a.ns).forEach((function(t){var r=a.ns[t];A(e,"onclosenamespace",{prefix:t,uri:r})}))}0===t&&(e.closedRoot=!0),e.tagName=e.attribValue=e.attribName="",e.attribList.length=0,e.state=w.TEXT}function I(e){var t,r=e.entity,n=r.toLowerCase(),i="";return e.ENTITIES[r]?e.ENTITIES[r]:e.ENTITIES[n]?e.ENTITIES[n]:("#"===(r=n).charAt(0)&&("x"===r.charAt(1)?(r=r.slice(2),i=(t=parseInt(r,16)).toString(16)):(r=r.slice(1),i=(t=parseInt(r,10)).toString(10))),r=r.replace(/^0+/,""),isNaN(t)||i.toLowerCase()!==r?(P(e,"Invalid character entity"),"&"+e.entity+";"):String.fromCodePoint(t))}function W(e,t){"<"===t?(e.state=w.OPEN_WAKA,e.startTagPosition=e.position):f(t)||(P(e,"Non-whitespace before first tag."),e.textNode=t,e.state=w.TEXT)}function D(e,t){var r="";return t1114111||x(s)!==s)throw RangeError("Invalid code point: "+s);s<=65535?n.push(s):(e=55296+((s-=65536)>>10),t=s%1024+56320,n.push(e,t)),(i+1===a||n.length>r)&&(o+=S.apply(null,n),n.length=0)}return o},Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:k,configurable:!0,writable:!0}):String.fromCodePoint=k)}(void 0===r?this.sax={}:r)}).call(this)}).call(this,e("buffer").Buffer)},{buffer:7,stream:235,string_decoder:5}],228:[function(e,t,r){var n=e("./util"),i=Object.prototype.hasOwnProperty,a="undefined"!=typeof Map;function o(){this._array=[],this._set=a?new Map:Object.create(null)}o.fromArray=function(e,t){for(var r=new o,n=0,i=e.length;n=0)return t}else{var r=n.toSetString(e);if(i.call(this._set,r))return this._set[r]}throw new Error('"'+e+'" is not in the set.')},o.prototype.at=function(e){if(e>=0&&e>>=5)>0&&(t|=32),r+=n.encode(t)}while(i>0);return r},r.decode=function(e,t,r){var i,a,o,s,l=e.length,c=0,u=0;do{if(t>=l)throw new Error("Expected more digits in base 64 VLQ value.");if(-1===(a=n.decode(e.charCodeAt(t++))))throw new Error("Invalid base64 digit: "+e.charAt(t-1));i=!!(32&a),c+=(a&=31)<>1,1==(1&o)?-s:s),r.rest=t}},{"./base64":230}],230:[function(e,t,r){var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");r.encode=function(e){if(0<=e&&ei||a==i&&s>=o||n.compareByGeneratedPositionsInflated(t,r)<=0?(this._last=e,this._array.push(e)):(this._sorted=!1,this._array.push(e))},i.prototype.toArray=function(){return this._sorted||(this._array.sort(n.compareByGeneratedPositionsInflated),this._sorted=!0),this._array},r.MappingList=i},{"./util":233}],232:[function(e,t,r){var n=e("./base64-vlq"),i=e("./util"),a=e("./array-set").ArraySet,o=e("./mapping-list").MappingList;function s(e){e||(e={}),this._file=i.getArg(e,"file",null),this._sourceRoot=i.getArg(e,"sourceRoot",null),this._skipValidation=i.getArg(e,"skipValidation",!1),this._sources=new a,this._names=new a,this._mappings=new o,this._sourcesContents=null}s.prototype._version=3,s.fromSourceMap=function(e){var t=e.sourceRoot,r=new s({file:e.file,sourceRoot:t});return e.eachMapping((function(e){var n={generated:{line:e.generatedLine,column:e.generatedColumn}};null!=e.source&&(n.source=e.source,null!=t&&(n.source=i.relative(t,n.source)),n.original={line:e.originalLine,column:e.originalColumn},null!=e.name&&(n.name=e.name)),r.addMapping(n)})),e.sources.forEach((function(n){var a=n;null!==t&&(a=i.relative(t,n)),r._sources.has(a)||r._sources.add(a);var o=e.sourceContentFor(n);null!=o&&r.setSourceContent(n,o)})),r},s.prototype.addMapping=function(e){var t=i.getArg(e,"generated"),r=i.getArg(e,"original",null),n=i.getArg(e,"source",null),a=i.getArg(e,"name",null);this._skipValidation||this._validateMapping(t,r,n,a),null!=n&&(n=String(n),this._sources.has(n)||this._sources.add(n)),null!=a&&(a=String(a),this._names.has(a)||this._names.add(a)),this._mappings.add({generatedLine:t.line,generatedColumn:t.column,originalLine:null!=r&&r.line,originalColumn:null!=r&&r.column,source:n,name:a})},s.prototype.setSourceContent=function(e,t){var r=e;null!=this._sourceRoot&&(r=i.relative(this._sourceRoot,r)),null!=t?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[i.toSetString(r)]=t):this._sourcesContents&&(delete this._sourcesContents[i.toSetString(r)],0===Object.keys(this._sourcesContents).length&&(this._sourcesContents=null))},s.prototype.applySourceMap=function(e,t,r){var n=t;if(null==t){if(null==e.file)throw new Error('SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map\'s "file" property. Both were omitted.');n=e.file}var o=this._sourceRoot;null!=o&&(n=i.relative(o,n));var s=new a,l=new a;this._mappings.unsortedForEach((function(t){if(t.source===n&&null!=t.originalLine){var a=e.originalPositionFor({line:t.originalLine,column:t.originalColumn});null!=a.source&&(t.source=a.source,null!=r&&(t.source=i.join(r,t.source)),null!=o&&(t.source=i.relative(o,t.source)),t.originalLine=a.line,t.originalColumn=a.column,null!=a.name&&(t.name=a.name))}var c=t.source;null==c||s.has(c)||s.add(c);var u=t.name;null==u||l.has(u)||l.add(u)}),this),this._sources=s,this._names=l,e.sources.forEach((function(t){var n=e.sourceContentFor(t);null!=n&&(null!=r&&(t=i.join(r,t)),null!=o&&(t=i.relative(o,t)),this.setSourceContent(t,n))}),this)},s.prototype._validateMapping=function(e,t,r,n){if(t&&"number"!=typeof t.line&&"number"!=typeof t.column)throw new Error("original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.");if((!(e&&"line"in e&&"column"in e&&e.line>0&&e.column>=0)||t||r||n)&&!(e&&"line"in e&&"column"in e&&t&&"line"in t&&"column"in t&&e.line>0&&e.column>=0&&t.line>0&&t.column>=0&&r))throw new Error("Invalid mapping: "+JSON.stringify({generated:e,source:r,original:t,name:n}))},s.prototype._serializeMappings=function(){for(var e,t,r,a,o=0,s=1,l=0,c=0,u=0,d=0,p="",m=this._mappings.toArray(),h=0,f=m.length;h0){if(!i.compareByGeneratedPositionsInflated(t,m[h-1]))continue;e+=","}e+=n.encode(t.generatedColumn-o),o=t.generatedColumn,null!=t.source&&(a=this._sources.indexOf(t.source),e+=n.encode(a-d),d=a,e+=n.encode(t.originalLine-1-c),c=t.originalLine-1,e+=n.encode(t.originalColumn-l),l=t.originalColumn,null!=t.name&&(r=this._names.indexOf(t.name),e+=n.encode(r-u),u=r)),p+=e}return p},s.prototype._generateSourcesContent=function(e,t){return e.map((function(e){if(!this._sourcesContents)return null;null!=t&&(e=i.relative(t,e));var r=i.toSetString(e);return Object.prototype.hasOwnProperty.call(this._sourcesContents,r)?this._sourcesContents[r]:null}),this)},s.prototype.toJSON=function(){var e={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return null!=this._file&&(e.file=this._file),null!=this._sourceRoot&&(e.sourceRoot=this._sourceRoot),this._sourcesContents&&(e.sourcesContent=this._generateSourcesContent(e.sources,e.sourceRoot)),e},s.prototype.toString=function(){return JSON.stringify(this.toJSON())},r.SourceMapGenerator=s},{"./array-set":228,"./base64-vlq":229,"./mapping-list":231,"./util":233}],233:[function(e,t,r){r.getArg=function(e,t,r){if(t in e)return e[t];if(3===arguments.length)return r;throw new Error('"'+t+'" is a required argument.')};var n=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,i=/^data:.+\,.+$/;function a(e){var t=e.match(n);return t?{scheme:t[1],auth:t[2],host:t[3],port:t[4],path:t[5]}:null}function o(e){var t="";return e.scheme&&(t+=e.scheme+":"),t+="//",e.auth&&(t+=e.auth+"@"),e.host&&(t+=e.host),e.port&&(t+=":"+e.port),e.path&&(t+=e.path),t}function s(e){var t=e,n=a(e);if(n){if(!n.path)return e;t=n.path}for(var i,s=r.isAbsolute(t),l=t.split(/\/+/),c=0,u=l.length-1;u>=0;u--)"."===(i=l[u])?l.splice(u,1):".."===i?c++:c>0&&(""===i?(l.splice(u+1,c),c=0):(l.splice(u,2),c--));return""===(t=l.join("/"))&&(t=s?"/":"."),n?(n.path=t,o(n)):t}function l(e,t){""===e&&(e="."),""===t&&(t=".");var r=a(t),n=a(e);if(n&&(e=n.path||"/"),r&&!r.scheme)return n&&(r.scheme=n.scheme),o(r);if(r||t.match(i))return t;if(n&&!n.host&&!n.path)return n.host=t,o(n);var l="/"===t.charAt(0)?t:s(e.replace(/\/+$/,"")+"/"+t);return n?(n.path=l,o(n)):l}r.urlParse=a,r.urlGenerate=o,r.normalize=s,r.join=l,r.isAbsolute=function(e){return"/"===e.charAt(0)||n.test(e)},r.relative=function(e,t){""===e&&(e="."),e=e.replace(/\/$/,"");for(var r=0;0!==t.indexOf(e+"/");){var n=e.lastIndexOf("/");if(n<0)return t;if((e=e.slice(0,n)).match(/^([^\/]+:\/)?\/*$/))return t;++r}return Array(r+1).join("../")+t.substr(e.length+1)};var c=!("__proto__"in Object.create(null));function u(e){return e}function d(e){if(!e)return!1;var t=e.length;if(t<9)return!1;if(95!==e.charCodeAt(t-1)||95!==e.charCodeAt(t-2)||111!==e.charCodeAt(t-3)||116!==e.charCodeAt(t-4)||111!==e.charCodeAt(t-5)||114!==e.charCodeAt(t-6)||112!==e.charCodeAt(t-7)||95!==e.charCodeAt(t-8)||95!==e.charCodeAt(t-9))return!1;for(var r=t-10;r>=0;r--)if(36!==e.charCodeAt(r))return!1;return!0}function p(e,t){return e===t?0:null===e?1:null===t?-1:e>t?1:-1}r.toSetString=c?u:function(e){return d(e)?"$"+e:e},r.fromSetString=c?u:function(e){return d(e)?e.slice(1):e},r.compareByOriginalPositions=function(e,t,r){var n=p(e.source,t.source);return 0!==n||0!==(n=e.originalLine-t.originalLine)||0!==(n=e.originalColumn-t.originalColumn)||r||0!==(n=e.generatedColumn-t.generatedColumn)||0!==(n=e.generatedLine-t.generatedLine)?n:p(e.name,t.name)},r.compareByGeneratedPositionsDeflated=function(e,t,r){var n=e.generatedLine-t.generatedLine;return 0!==n||0!==(n=e.generatedColumn-t.generatedColumn)||r||0!==(n=p(e.source,t.source))||0!==(n=e.originalLine-t.originalLine)||0!==(n=e.originalColumn-t.originalColumn)?n:p(e.name,t.name)},r.compareByGeneratedPositionsInflated=function(e,t){var r=e.generatedLine-t.generatedLine;return 0!==r||0!==(r=e.generatedColumn-t.generatedColumn)||0!==(r=p(e.source,t.source))||0!==(r=e.originalLine-t.originalLine)||0!==(r=e.originalColumn-t.originalColumn)?r:p(e.name,t.name)},r.parseSourceMapInput=function(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))},r.computeSourceURL=function(e,t,r){if(t=t||"",e&&("/"!==e[e.length-1]&&"/"!==t[0]&&(e+="/"),t=e+t),r){var n=a(r);if(!n)throw new Error("sourceMapURL could not be parsed");if(n.path){var i=n.path.lastIndexOf("/");i>=0&&(n.path=n.path.substring(0,i+1))}t=l(o(n),t)}return s(t)}},{}],234:[function(e,t,r){ //! stable.js 0.1.8, https://github.com/Two-Screen/stable //! © 2018 Angry Bytes and contributors. MIT licensed. -!function(e,n){"object"==typeof r&&void 0!==t?t.exports=n():e.stable=n()}(this,(function(){"use strict";var e=function(e,r){return t(e.slice(),r)};function t(e,t){"function"!=typeof t&&(t=function(e,t){return String(e).localeCompare(t)});var n=e.length;if(n<=1)return e;for(var i=new Array(n),a=1;ac&&(a=c),o>c&&(o=c),s=i,l=a;;)if(s2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:2===r?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}i("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),i("ERR_INVALID_ARG_TYPE",(function(e,t,r){var n,i,o,s;if("string"==typeof t&&(i="not ",t.substr(!o||o<0?0:+o,i.length)===i)?(n="must not be",t=t.replace(/^not /,"")):n="must be",function(e,t,r){return(void 0===r||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}(e," argument"))s="The ".concat(e," ").concat(n," ").concat(a(t,"type"));else{var l=function(e,t,r){return"number"!=typeof r&&(r=0),!(r+t.length>e.length)&&-1!==e.indexOf(t,r)}(e,".")?"property":"argument";s='The "'.concat(e,'" ').concat(l," ").concat(n," ").concat(a(t,"type"))}return s+=". Received type ".concat(typeof r)}),TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.codes=n},{}],237:[function(e,t,r){(function(r){(function(){"use strict";var n=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};t.exports=c;var i=e("./_stream_readable"),a=e("./_stream_writable");e("inherits")(c,i);for(var o=n(a.prototype),s=0;s0)if("string"==typeof t||o.objectMode||Object.getPrototypeOf(t)===s.prototype||(t=function(e){return s.from(e)}(t)),n)o.endEmitted?k(e,new x):E(e,o,t,!0);else if(o.ended)k(e,new v);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!r?(t=o.decoder.write(t),o.objectMode||0!==t.length?E(e,o,t,!1):L(e,o)):E(e,o,t,!1)}else n||(o.reading=!1,L(e,o));return!o.ended&&(o.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=O?e=O:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function z(e){var t=e._readableState;c("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(c("emitReadable",t.flowing),t.emittedReadable=!0,r.nextTick(P,e))}function P(e){var t=e._readableState;c("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,I(e)}function L(e,t){t.readingMore||(t.readingMore=!0,r.nextTick(R,e,t))}function R(e,t){for(;!t.reading&&!t.ended&&(t.length0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function q(e){c("readable nexttick read 0"),e.read(0)}function M(e,t){c("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),I(e),t.flowing&&!t.reading&&e.read(0)}function I(e){var t=e._readableState;for(c("flow",t.flowing);t.flowing&&null!==e.read(););}function W(e,t){return 0===t.length?null:(t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r);var r}function D(e){var t=e._readableState;c("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,r.nextTick(N,t,e))}function N(e,t){if(c("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}function j(e,t){for(var r=0,n=e.length;r=t.highWaterMark:t.length>0)||t.ended))return c("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?D(this):z(this),null;if(0===(e=_(e,t))&&t.ended)return 0===t.length&&D(this),null;var n,i=t.needReadable;return c("need readable",i),(0===t.length||t.length-e0?W(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&D(this)),null!==n&&this.emit("data",n),n},T.prototype._read=function(e){k(this,new S("_read()"))},T.prototype.pipe=function(e,t){var n=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=e;break;case 1:i.pipes=[i.pipes,e];break;default:i.pipes.push(e)}i.pipesCount+=1,c("pipe count=%d opts=%j",i.pipesCount,t);var o=(!t||!1!==t.end)&&e!==r.stdout&&e!==r.stderr?l:g;function s(t,r){c("onunpipe"),t===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,c("cleanup"),e.removeListener("close",h),e.removeListener("finish",f),e.removeListener("drain",u),e.removeListener("error",m),e.removeListener("unpipe",s),n.removeListener("end",l),n.removeListener("end",g),n.removeListener("data",p),d=!0,!i.awaitDrain||e._writableState&&!e._writableState.needDrain||u())}function l(){c("onend"),e.end()}i.endEmitted?r.nextTick(o):n.once("end",o),e.on("unpipe",s);var u=function(e){return function(){var t=e._readableState;c("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&a(e,"data")&&(t.flowing=!0,I(e))}}(n);e.on("drain",u);var d=!1;function p(t){c("ondata");var r=e.write(t);c("dest.write",r),!1===r&&((1===i.pipesCount&&i.pipes===e||i.pipesCount>1&&-1!==j(i.pipes,e))&&!d&&(c("false write response, pause",i.awaitDrain),i.awaitDrain++),n.pause())}function m(t){c("onerror",t),g(),e.removeListener("error",m),0===a(e,"error")&&k(e,t)}function h(){e.removeListener("finish",f),g()}function f(){c("onfinish"),e.removeListener("close",h),g()}function g(){c("unpipe"),n.unpipe(e)}return n.on("data",p),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",m),e.once("close",h),e.once("finish",f),e.emit("pipe",n),i.flowing||(c("pipe resume"),n.resume()),e},T.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var a=0;a0,!1!==i.flowing&&this.resume()):"readable"===e&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,c("on readable",i.length,i.reading),i.length?z(this):i.reading||r.nextTick(q,this))),n},T.prototype.addListener=T.prototype.on,T.prototype.removeListener=function(e,t){var n=o.prototype.removeListener.call(this,e,t);return"readable"===e&&r.nextTick(B,this),n},T.prototype.removeAllListeners=function(e){var t=o.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||r.nextTick(B,this),t},T.prototype.resume=function(){var e=this._readableState;return e.flowing||(c("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,r.nextTick(M,e,t))}(this,e)),e.paused=!1,this},T.prototype.pause=function(){return c("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(c("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},T.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;for(var i in e.on("end",(function(){if(c("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(i){(c("wrapped data"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i)||(r.objectMode||i&&i.length)&&(t.push(i)||(n=!0,e.pause()))})),e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var a=0;a-1))throw new x(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(T.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(T.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),T.prototype._write=function(e,t,r){r(new f("_write()"))},T.prototype._writev=null,T.prototype.end=function(e,t,n){var i=this._writableState;return"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!=e&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||function(e,t,n){t.ending=!0,P(e,t),n&&(t.finished?r.nextTick(n):e.once("finish",n));t.ended=!0,e.writable=!1}(this,i,n),this},Object.defineProperty(T.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),T.prototype.destroy=d.destroy,T.prototype._undestroy=d.undestroy,T.prototype._destroy=function(e,t){t(e)}}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":236,"./_stream_duplex":237,"./internal/streams/destroy":244,"./internal/streams/state":248,"./internal/streams/stream":249,_process:225,buffer:7,inherits:210,"util-deprecate":252}],242:[function(e,t,r){(function(r){(function(){"use strict";var n;function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var a=e("./end-of-stream"),o=Symbol("lastResolve"),s=Symbol("lastReject"),l=Symbol("error"),c=Symbol("ended"),u=Symbol("lastPromise"),d=Symbol("handlePromise"),p=Symbol("stream");function m(e,t){return{value:e,done:t}}function h(e){var t=e[o];if(null!==t){var r=e[p].read();null!==r&&(e[u]=null,e[o]=null,e[s]=null,t(m(r,!1)))}}function f(e){r.nextTick(h,e)}var g=Object.getPrototypeOf((function(){})),y=Object.setPrototypeOf((i(n={get stream(){return this[p]},next:function(){var e=this,t=this[l];if(null!==t)return Promise.reject(t);if(this[c])return Promise.resolve(m(void 0,!0));if(this[p].destroyed)return new Promise((function(t,n){r.nextTick((function(){e[l]?n(e[l]):t(m(void 0,!0))}))}));var n,i=this[u];if(i)n=new Promise(function(e,t){return function(r,n){e.then((function(){t[c]?r(m(void 0,!0)):t[d](r,n)}),n)}}(i,this));else{var a=this[p].read();if(null!==a)return Promise.resolve(m(a,!1));n=new Promise(this[d])}return this[u]=n,n}},Symbol.asyncIterator,(function(){return this})),i(n,"return",(function(){var e=this;return new Promise((function(t,r){e[p].destroy(null,(function(e){e?r(e):t(m(void 0,!0))}))}))})),n),g);t.exports=function(e){var t,r=Object.create(y,(i(t={},p,{value:e,writable:!0}),i(t,o,{value:null,writable:!0}),i(t,s,{value:null,writable:!0}),i(t,l,{value:null,writable:!0}),i(t,c,{value:e._readableState.endEmitted,writable:!0}),i(t,d,{value:function(e,t){var n=r[p].read();n?(r[u]=null,r[o]=null,r[s]=null,e(m(n,!1))):(r[o]=e,r[s]=t)},writable:!0}),t));return r[u]=null,a(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=r[s];return null!==t&&(r[u]=null,r[o]=null,r[s]=null,t(e)),void(r[l]=e)}var n=r[o];null!==n&&(r[u]=null,r[o]=null,r[s]=null,n(m(void 0,!0))),r[c]=!0})),e.on("readable",f.bind(null,r)),r}}).call(this)}).call(this,e("_process"))},{"./end-of-stream":245,_process:225}],243:[function(e,t,r){"use strict";function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function a(e,t){for(var r=0;r0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r}},{key:"concat",value:function(e){if(0===this.length)return o.alloc(0);for(var t,r,n,i=o.allocUnsafe(e>>>0),a=this.head,s=0;a;)t=a.data,r=i,n=s,o.prototype.copy.call(t,r,n),s+=a.data.length,a=a.next;return i}},{key:"consume",value:function(e,t){var r;return ei.length?i.length:e;if(a===i.length?n+=i:n+=i.slice(0,e),0==(e-=a)){a===i.length?(++r,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(a));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(e){var t=o.allocUnsafe(e),r=this.head,n=1;for(r.data.copy(t),e-=r.data.length;r=r.next;){var i=r.data,a=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,a),0==(e-=a)){a===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(a));break}++n}return this.length-=n,t}},{key:l,value:function(e,t){return s(this,function(e){for(var t=1;t0,(function(e){n||(n=e),e&&o.forEach(c),a||(o.forEach(c),i(n))}))}));return t.reduce(u)}},{"../../../errors":236,"./end-of-stream":245}],248:[function(e,t,r){"use strict";var n=e("../../../errors").codes.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(e,t,r,i){var a=function(e,t,r){return null!=e.highWaterMark?e.highWaterMark:t?e[r]:null}(t,i,r);if(null!=a){if(!isFinite(a)||Math.floor(a)!==a||a<0)throw new n(i?r:"highWaterMark",a);return Math.floor(a)}return e.objectMode?16:16384}}},{"../../../errors":236}],249:[function(e,t,r){t.exports=e("events").EventEmitter},{events:202}],250:[function(e,t,r){arguments[4][5][0].apply(r,arguments)},{dup:5,"safe-buffer":226}],251:[function(e,t,r){var n=/[\'\"]/;t.exports=function(e){return e?(n.test(e.charAt(0))&&(e=e.substr(1)),n.test(e.charAt(e.length-1))&&(e=e.substr(0,e.length-1)),e):""}},{}],252:[function(e,t,r){(function(e){(function(){function r(t){try{if(!e.localStorage)return!1}catch(e){return!1}var r=e.localStorage[t];return null!=r&&"true"===String(r).toLowerCase()}t.exports=function(e,t){if(r("noDeprecation"))return e;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],253:[function(e,t,r){"use strict";const n=e("./svgclean/config.js"),i=e("./svgclean/svg2js.js"),a=e("./svgclean/js2svg.js");function o(e,t,r,o){const s=e.plugins;i(t).then((function(t){t=n.executePlugins(s,t,r),o(a(t,e.format||{}))}),(function(e){o({error:e})}))}r.configure=function(e={}){const t=n.loadPlugins(e);return Object.assign({},e,{plugins:t})},r.optimize=function(e,t){const r={};return new Promise(((n,i)=>{let a=e.multipass?10:1,s=0,l=Number.POSITIVE_INFINITY;o(e,t,r,(function t(c){c.error?i(c.error):(r.multipassCount=s,++st[r])return 1}return 0}function l(e,t){return s(o(e),o(t))}function c(e,t){return l(e.item.data,t.item.data)}t.exports.flattenToSelectors=function(e){var t=[];return n.walk(e,{visit:"Rule",enter:function(e){if("Rule"===e.type){var r=this.atrule,n=e;e.prelude.children.each((function(e,i){var a={item:i,atrule:r,rule:n,pseudos:[]};e.children.each((function(e,t,r){"PseudoClassSelector"!==e.type&&"PseudoElementSelector"!==e.type||a.pseudos.push({item:t,list:r})})),t.push(a)}))}}}),t},t.exports.filterByMqs=function(e,t){return e.filter((function(e){if(null===e.atrule)return~t.indexOf("");var r=e.atrule.name,i=r;e.atrule.expression&&"MediaQueryList"===e.atrule.expression.children.first().type&&(i=[r,n.generate(e.atrule.expression)].join(" "));return~t.indexOf(i)}))},t.exports.filterByPseudos=function(e,t){return e.filter((function(e){var r=n.generate({type:"Selector",children:(new i).fromArray(e.pseudos.map((function(e){return e.item.data})))});return~t.indexOf(r)}))},t.exports.cleanPseudos=function(e){e.forEach((function(e){e.pseudos.forEach((function(e){e.list.remove(e.item)}))}))},t.exports.compareSpecificity=s,t.exports.compareSimpleSelectorNode=l,t.exports.sortSelectors=function(e){return a(e,c)},t.exports.csstreeToStyleDeclaration=function(e){return{name:e.property,value:n.generate(e.value),priority:e.important?"important":""}},t.exports.getCssStr=function(e){return e.content[0].text||e.content[0].cdata||[]},t.exports.setCssStr=function(e,t){return e.content[0].cdata?(e.content[0].cdata=t,e.content[0].cdata):(e.content[0].text=t,e.content[0].text)}},{"css-tree":38,"csso/lib/restructure/prepare/specificity":175,stable:234}],259:[function(e,t,r){"use strict";const n="\n",i=e("./plugins/_collections.js").elemsGroups.textContent.concat("title");var a={doctypeStart:"",procInstStart:"",tagOpenStart:"<",tagOpenEnd:">",tagCloseStart:"",tagShortStart:"<",tagShortEnd:"/>",attrStart:'="',attrEnd:'"',commentStart:"\x3c!--",commentEnd:"--\x3e",cdataStart:"",textStart:"",textEnd:"",indent:4,regEntities:/[&'"<>]/g,regValEntities:/[&"<>]/g,encodeEntity:function(e){return o[e]},pretty:!1,useShortTags:!0},o={"&":"&","'":"'",'"':""",">":">","<":"<"};function s(e){this.config=e?Object.assign({},a,e):Object.assign({},a);var t=this.config.indent;"number"!=typeof t||isNaN(t)?"string"!=typeof t&&(this.config.indent=" "):this.config.indent=t<0?"\t":" ".repeat(t),this.config.pretty&&(this.config.doctypeEnd+=n,this.config.procInstEnd+=n,this.config.commentEnd+=n,this.config.cdataEnd+=n,this.config.tagShortEnd+=n,this.config.tagOpenEnd+=n,this.config.tagCloseEnd+=n,this.config.textEnd+=n),this.indentLevel=0,this.textContext=null}t.exports=function(e,t){return new s(t).convert(e)},s.prototype.convert=function(e){var t="";return e.content&&(this.indentLevel++,e.content.forEach((function(e){e.elem?t+=this.createElem(e):e.text?t+=this.createText(e.text):e.doctype?t+=this.createDoctype(e.doctype):e.processinginstruction?t+=this.createProcInst(e.processinginstruction):e.comment?t+=this.createComment(e.comment):e.cdata&&(t+=this.createCDATA(e.cdata))}),this)),this.indentLevel--,{data:t,info:{width:this.width,height:this.height}}},s.prototype.createIndent=function(){var e="";return this.config.pretty&&!this.textContext&&(e=this.config.indent.repeat(this.indentLevel-1)),e},s.prototype.createDoctype=function(e){return this.config.doctypeStart+e+this.config.doctypeEnd},s.prototype.createProcInst=function(e){return this.config.procInstStart+e.name+" "+e.body+this.config.procInstEnd},s.prototype.createComment=function(e){return this.config.commentStart+e+this.config.commentEnd},s.prototype.createCDATA=function(e){return this.createIndent()+this.config.cdataStart+e+this.config.cdataEnd},s.prototype.createElem=function(e){if(e.isElem("svg")&&e.hasAttr("width")&&e.hasAttr("height")&&(this.width=e.attr("width").value,this.height=e.attr("height").value),e.isEmpty())return this.config.useShortTags?this.createIndent()+this.config.tagShortStart+e.elem+this.createAttrs(e)+this.config.tagShortEnd:this.createIndent()+this.config.tagShortStart+e.elem+this.createAttrs(e)+this.config.tagOpenEnd+this.config.tagCloseStart+e.elem+this.config.tagCloseEnd;var t=this.config.tagOpenStart,r=this.config.tagOpenEnd,o=this.config.tagCloseStart,s=this.config.tagCloseEnd,l=this.createIndent(),c="",u="",d="";return this.textContext?(t=a.tagOpenStart,r=a.tagOpenEnd,o=a.tagCloseStart,s=a.tagCloseEnd,l=""):e.isElem(i)&&(this.config.pretty&&(c+=l+this.config.indent),this.textContext=e),u+=this.convert(e).data,this.textContext==e&&(this.textContext=null,this.config.pretty&&(d=n)),l+t+e.elem+this.createAttrs(e)+r+c+u+d+this.createIndent()+o+e.elem+s},s.prototype.createAttrs=function(e){var t="";return e.eachAttr((function(e){void 0!==e.value?t+=" "+e.name+this.config.attrStart+String(e.value).replace(this.config.regValEntities,this.config.encodeEntity)+this.config.attrEnd:t+=" "+e.name}),this),t},s.prototype.createText=function(e){return this.createIndent()+this.config.textStart+e.replace(this.config.regEntities,this.config.encodeEntity)+(this.textContext?"":this.config.textEnd)}},{"./plugins/_collections.js":261}],260:[function(e,t,r){"use strict";var n=e("css-select"),i={xmlMode:!0,adapter:e("./css-select-adapter")},a=t.exports=function(e,t){Object.assign(this,e),t&&Object.defineProperty(this,"parentNode",{writable:!0,value:t})};a.prototype.clone=function(){var e=this,t={};Object.keys(e).forEach((function(r){"class"!==r&&"style"!==r&&"content"!==r&&(t[r]=e[r])})),t=JSON.parse(JSON.stringify(t));var r=new a(t,!!e.parentNode);return e.class&&(r.class=e.class.clone(r)),e.style&&(r.style=e.style.clone(r)),e.content&&(r.content=e.content.map((function(e){var t=e.clone();return t.parentNode=r,t}))),r},a.prototype.isElem=function(e){return e?Array.isArray(e)?!!this.elem&&e.indexOf(this.elem)>-1:!!this.elem&&this.elem===e:!!this.elem},a.prototype.renameElem=function(e){return e&&"string"==typeof e&&(this.elem=this.local=e),this},a.prototype.isEmpty=function(){return!this.content||!this.content.length},a.prototype.closestElem=function(e){for(var t=this;(t=t.parentNode)&&!t.isElem(e););return t},a.prototype.spliceContent=function(e,t,r){return arguments.length<2?[]:(Array.isArray(r)||(r=Array.apply(null,arguments).slice(2)),r.forEach((function(e){e.parentNode=this}),this),this.content.splice.apply(this.content,[e,t].concat(r)))},a.prototype.hasAttr=function(e,t){return!(!this.attrs||!Object.keys(this.attrs).length)&&(arguments.length?void 0!==t?!!this.attrs[e]&&this.attrs[e].value===t.toString():!!this.attrs[e]:!!this.attrs)},a.prototype.hasAttrLocal=function(e,t){if(!this.attrs||!Object.keys(this.attrs).length)return!1;if(!arguments.length)return!!this.attrs;var r;switch(null!=t&&t.constructor&&t.constructor.name){case"Number":case"String":r=i;break;case"RegExp":r=a;break;case"Function":r=o;break;default:r=n}return this.someAttr(r);function n(t){return t.local===e}function i(r){return r.local===e&&t==r.value}function a(r){return r.local===e&&t.test(r.value)}function o(r){return r.local===e&&t(r.value)}},a.prototype.attr=function(e,t){if(this.hasAttr()&&arguments.length)return void 0!==t?this.hasAttr(e,t)?this.attrs[e]:void 0:this.attrs[e]},a.prototype.computedAttr=function(e,t){if(arguments.length){for(var r=this;r&&(!r.hasAttr(e)||!r.attr(e).value);r=r.parentNode);return null!=t?!!r&&r.hasAttr(e,t):r&&r.hasAttr(e)?r.attrs[e].value:void 0}},a.prototype.removeAttr=function(e,t,r){return!!arguments.length&&(Array.isArray(e)?(e.forEach(this.removeAttr,this),!1):!!this.hasAttr(e)&&(!(!r&&t&&this.attrs[e].value!==t)&&(delete this.attrs[e],Object.keys(this.attrs).length||delete this.attrs,!0)))},a.prototype.addAttr=function(e){return void 0!==(e=e||{}).name&&void 0!==e.prefix&&void 0!==e.local&&(this.attrs=this.attrs||{},this.attrs[e.name]=e,"class"===e.name&&this.class.hasClass(),"style"===e.name&&this.style.hasStyle(),this.attrs[e.name])},a.prototype.eachAttr=function(e,t){if(!this.hasAttr())return!1;for(var r in this.attrs)e.call(t,this.attrs[r]);return!0},a.prototype.someAttr=function(e,t){if(!this.hasAttr())return!1;for(var r in this.attrs)if(e.call(t,this.attrs[r]))return!0;return!1},a.prototype.querySelectorAll=function(e){var t=n.selectAll(e,this,i);return t.length>0?t:null},a.prototype.querySelector=function(e){return n.selectOne(e,this,i)},a.prototype.matches=function(e){return n.is(this,e,i)}},{"./css-select-adapter":256,"css-select":14}],261:[function(e,t,r){"use strict";r.elemsGroups={animation:["animate","animateColor","animateMotion","animateTransform","set"],descriptive:["desc","metadata","title"],shape:["circle","ellipse","line","path","polygon","polyline","rect"],structural:["defs","g","svg","symbol","use"],paintServer:["solidColor","linearGradient","radialGradient","meshGradient","pattern","hatch"],nonRendering:["linearGradient","radialGradient","pattern","clipPath","mask","marker","symbol","filter","solidColor"],container:["a","defs","g","marker","mask","missing-glyph","pattern","svg","switch","symbol","foreignObject"],textContent:["altGlyph","altGlyphDef","altGlyphItem","glyph","glyphRef","textPath","text","tref","tspan"],textContentChild:["altGlyph","textPath","tref","tspan"],lightSource:["feDiffuseLighting","feSpecularLighting","feDistantLight","fePointLight","feSpotLight"],filterPrimitive:["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence"]},r.pathElems=["path","glyph","missing-glyph"],r.attrsGroups={animationAddition:["additive","accumulate"],animationAttributeTarget:["attributeType","attributeName"],animationEvent:["onbegin","onend","onrepeat","onload"],animationTiming:["begin","dur","end","min","max","restart","repeatCount","repeatDur","fill"],animationValue:["calcMode","values","keyTimes","keySplines","from","to","by"],conditionalProcessing:["requiredFeatures","requiredExtensions","systemLanguage"],core:["id","tabindex","xml:base","xml:lang","xml:space"],graphicalEvent:["onfocusin","onfocusout","onactivate","onclick","onmousedown","onmouseup","onmouseover","onmousemove","onmouseout","onload"],presentation:["alignment-baseline","baseline-shift","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cursor","direction","display","dominant-baseline","enable-background","fill","fill-opacity","fill-rule","filter","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","glyph-orientation-horizontal","glyph-orientation-vertical","image-rendering","letter-spacing","lighting-color","marker-end","marker-mid","marker-start","mask","opacity","overflow","paint-order","pointer-events","shape-rendering","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-anchor","text-decoration","text-overflow","text-rendering","transform","unicode-bidi","vector-effect","visibility","word-spacing","writing-mode"],xlink:["xlink:href","xlink:show","xlink:actuate","xlink:type","xlink:role","xlink:arcrole","xlink:title"],documentEvent:["onunload","onabort","onerror","onresize","onscroll","onzoom"],filterPrimitive:["x","y","width","height","result"],transferFunction:["type","tableValues","slope","intercept","amplitude","exponent","offset"]},r.attrsGroupsDefaults={core:{"xml:space":"preserve"},filterPrimitive:{x:"0",y:"0",width:"100%",height:"100%"},presentation:{clip:"auto","clip-path":"none","clip-rule":"nonzero",mask:"none",opacity:"1","stop-color":"#000","stop-opacity":"1","fill-opacity":"1","fill-rule":"nonzero",fill:"#000",stroke:"none","stroke-width":"1","stroke-linecap":"butt","stroke-linejoin":"miter","stroke-miterlimit":"4","stroke-dasharray":"none","stroke-dashoffset":"0","stroke-opacity":"1","paint-order":"normal","vector-effect":"none",display:"inline",visibility:"visible","marker-start":"none","marker-mid":"none","marker-end":"none","color-interpolation":"sRGB","color-interpolation-filters":"linearRGB","color-rendering":"auto","shape-rendering":"auto","text-rendering":"auto","image-rendering":"auto","font-style":"normal","font-variant":"normal","font-weight":"normal","font-stretch":"normal","font-size":"medium","font-size-adjust":"none",kerning:"auto","letter-spacing":"normal","word-spacing":"normal","text-decoration":"none","text-anchor":"start","text-overflow":"clip","writing-mode":"lr-tb","glyph-orientation-vertical":"auto","glyph-orientation-horizontal":"0deg",direction:"ltr","unicode-bidi":"normal","dominant-baseline":"auto","alignment-baseline":"baseline","baseline-shift":"baseline"},transferFunction:{slope:"1",intercept:"0",amplitude:"1",exponent:"1",offset:"0"}},r.elems={a:{attrsGroups:["conditionalProcessing","core","graphicalEvent","presentation","xlink"],attrs:["class","style","externalResourcesRequired","transform","target"],defaults:{target:"_self"},contentGroups:["animation","descriptive","shape","structural","paintServer"],content:["a","altGlyphDef","clipPath","color-profile","cursor","filter","font","font-face","foreignObject","image","marker","mask","pattern","script","style","switch","text","view"]},altGlyph:{attrsGroups:["conditionalProcessing","core","graphicalEvent","presentation","xlink"],attrs:["class","style","externalResourcesRequired","x","y","dx","dy","glyphRef","format","rotate"]},altGlyphDef:{attrsGroups:["core"],content:["glyphRef"]},altGlyphItem:{attrsGroups:["core"],content:["glyphRef","altGlyphItem"]},animate:{attrsGroups:["conditionalProcessing","core","animationAddition","animationAttributeTarget","animationEvent","animationTiming","animationValue","presentation","xlink"],attrs:["externalResourcesRequired"],contentGroups:["descriptive"]},animateColor:{attrsGroups:["conditionalProcessing","core","animationEvent","xlink","animationAttributeTarget","animationTiming","animationValue","animationAddition","presentation"],attrs:["externalResourcesRequired"],contentGroups:["descriptive"]},animateMotion:{attrsGroups:["conditionalProcessing","core","animationEvent","xlink","animationTiming","animationValue","animationAddition"],attrs:["externalResourcesRequired","path","keyPoints","rotate","origin"],defaults:{rotate:"0"},contentGroups:["descriptive"],content:["mpath"]},animateTransform:{attrsGroups:["conditionalProcessing","core","animationEvent","xlink","animationAttributeTarget","animationTiming","animationValue","animationAddition"],attrs:["externalResourcesRequired","type"],contentGroups:["descriptive"]},circle:{attrsGroups:["conditionalProcessing","core","graphicalEvent","presentation"],attrs:["class","style","externalResourcesRequired","transform","cx","cy","r"],defaults:{cx:"0",cy:"0"},contentGroups:["animation","descriptive"]},clipPath:{attrsGroups:["conditionalProcessing","core","presentation"],attrs:["class","style","externalResourcesRequired","transform","clipPathUnits"],defaults:{clipPathUnits:"userSpaceOnUse"},contentGroups:["animation","descriptive","shape"],content:["text","use"]},"color-profile":{attrsGroups:["core","xlink"],attrs:["local","name","rendering-intent"],defaults:{name:"sRGB","rendering-intent":"auto"},contentGroups:["descriptive"]},cursor:{attrsGroups:["core","conditionalProcessing","xlink"],attrs:["externalResourcesRequired","x","y"],defaults:{x:"0",y:"0"},contentGroups:["descriptive"]},defs:{attrsGroups:["conditionalProcessing","core","graphicalEvent","presentation"],attrs:["class","style","externalResourcesRequired","transform"],contentGroups:["animation","descriptive","shape","structural","paintServer"],content:["a","altGlyphDef","clipPath","color-profile","cursor","filter","font","font-face","foreignObject","image","marker","mask","pattern","script","style","switch","text","view"]},desc:{attrsGroups:["core"],attrs:["class","style"]},ellipse:{attrsGroups:["conditionalProcessing","core","graphicalEvent","presentation"],attrs:["class","style","externalResourcesRequired","transform","cx","cy","rx","ry"],defaults:{cx:"0",cy:"0"},contentGroups:["animation","descriptive"]},feBlend:{attrsGroups:["core","presentation","filterPrimitive"],attrs:["class","style","in","in2","mode"],defaults:{mode:"normal"},content:["animate","set"]},feColorMatrix:{attrsGroups:["core","presentation","filterPrimitive"],attrs:["class","style","in","type","values"],defaults:{type:"matrix"},content:["animate","set"]},feComponentTransfer:{attrsGroups:["core","presentation","filterPrimitive"],attrs:["class","style","in"],content:["feFuncA","feFuncB","feFuncG","feFuncR"]},feComposite:{attrsGroups:["core","presentation","filterPrimitive"],attrs:["class","style","in","in2","operator","k1","k2","k3","k4"],defaults:{operator:"over",k1:"0",k2:"0",k3:"0",k4:"0"},content:["animate","set"]},feConvolveMatrix:{attrsGroups:["core","presentation","filterPrimitive"],attrs:["class","style","in","order","kernelMatrix","divisor","bias","targetX","targetY","edgeMode","kernelUnitLength","preserveAlpha"],defaults:{order:"3",bias:"0",edgeMode:"duplicate",preserveAlpha:"false"},content:["animate","set"]},feDiffuseLighting:{attrsGroups:["core","presentation","filterPrimitive"],attrs:["class","style","in","surfaceScale","diffuseConstant","kernelUnitLength"],defaults:{surfaceScale:"1",diffuseConstant:"1"},contentGroups:["descriptive"],content:["feDistantLight","fePointLight","feSpotLight"]},feDisplacementMap:{attrsGroups:["core","presentation","filterPrimitive"],attrs:["class","style","in","in2","scale","xChannelSelector","yChannelSelector"],defaults:{scale:"0",xChannelSelector:"A",yChannelSelector:"A"},content:["animate","set"]},feDistantLight:{attrsGroups:["core"],attrs:["azimuth","elevation"],defaults:{azimuth:"0",elevation:"0"},content:["animate","set"]},feFlood:{attrsGroups:["core","presentation","filterPrimitive"],attrs:["class","style"],content:["animate","animateColor","set"]},feFuncA:{attrsGroups:["core","transferFunction"],content:["set","animate"]},feFuncB:{attrsGroups:["core","transferFunction"],content:["set","animate"]},feFuncG:{attrsGroups:["core","transferFunction"],content:["set","animate"]},feFuncR:{attrsGroups:["core","transferFunction"],content:["set","animate"]},feGaussianBlur:{attrsGroups:["core","presentation","filterPrimitive"],attrs:["class","style","in","stdDeviation"],defaults:{stdDeviation:"0"},content:["set","animate"]},feImage:{attrsGroups:["core","presentation","filterPrimitive","xlink"],attrs:["class","style","externalResourcesRequired","preserveAspectRatio","href","xlink:href"],defaults:{preserveAspectRatio:"xMidYMid meet"},content:["animate","animateTransform","set"]},feMerge:{attrsGroups:["core","presentation","filterPrimitive"],attrs:["class","style"],content:["feMergeNode"]},feMergeNode:{attrsGroups:["core"],attrs:["in"],content:["animate","set"]},feMorphology:{attrsGroups:["core","presentation","filterPrimitive"],attrs:["class","style","in","operator","radius"],defaults:{operator:"erode",radius:"0"},content:["animate","set"]},feOffset:{attrsGroups:["core","presentation","filterPrimitive"],attrs:["class","style","in","dx","dy"],defaults:{dx:"0",dy:"0"},content:["animate","set"]},fePointLight:{attrsGroups:["core"],attrs:["x","y","z"],defaults:{x:"0",y:"0",z:"0"},content:["animate","set"]},feSpecularLighting:{attrsGroups:["core","presentation","filterPrimitive"],attrs:["class","style","in","surfaceScale","specularConstant","specularExponent","kernelUnitLength"],defaults:{surfaceScale:"1",specularConstant:"1",specularExponent:"1"},contentGroups:["descriptive","lightSource"]},feSpotLight:{attrsGroups:["core"],attrs:["x","y","z","pointsAtX","pointsAtY","pointsAtZ","specularExponent","limitingConeAngle"],defaults:{x:"0",y:"0",z:"0",pointsAtX:"0",pointsAtY:"0",pointsAtZ:"0",specularExponent:"1"},content:["animate","set"]},feTile:{attrsGroups:["core","presentation","filterPrimitive"],attrs:["class","style","in"],content:["animate","set"]},feTurbulence:{attrsGroups:["core","presentation","filterPrimitive"],attrs:["class","style","baseFrequency","numOctaves","seed","stitchTiles","type"],defaults:{baseFrequency:"0",numOctaves:"1",seed:"0",stitchTiles:"noStitch",type:"turbulence"},content:["animate","set"]},filter:{attrsGroups:["core","presentation","xlink"],attrs:["class","style","externalResourcesRequired","x","y","width","height","filterRes","filterUnits","primitiveUnits","href","xlink:href"],defaults:{primitiveUnits:"userSpaceOnUse",x:"-10%",y:"-10%",width:"120%",height:"120%"},contentGroups:["descriptive","filterPrimitive"],content:["animate","set"]},font:{attrsGroups:["core","presentation"],attrs:["class","style","externalResourcesRequired","horiz-origin-x","horiz-origin-y","horiz-adv-x","vert-origin-x","vert-origin-y","vert-adv-y"],defaults:{"horiz-origin-x":"0","horiz-origin-y":"0"},contentGroups:["descriptive"],content:["font-face","glyph","hkern","missing-glyph","vkern"]},"font-face":{attrsGroups:["core"],attrs:["font-family","font-style","font-variant","font-weight","font-stretch","font-size","unicode-range","units-per-em","panose-1","stemv","stemh","slope","cap-height","x-height","accent-height","ascent","descent","widths","bbox","ideographic","alphabetic","mathematical","hanging","v-ideographic","v-alphabetic","v-mathematical","v-hanging","underline-position","underline-thickness","strikethrough-position","strikethrough-thickness","overline-position","overline-thickness"],defaults:{"font-style":"all","font-variant":"normal","font-weight":"all","font-stretch":"normal","unicode-range":"U+0-10FFFF","units-per-em":"1000","panose-1":"0 0 0 0 0 0 0 0 0 0",slope:"0"},contentGroups:["descriptive"],content:["font-face-src"]},"font-face-format":{attrsGroups:["core"],attrs:["string"]},"font-face-name":{attrsGroups:["core"],attrs:["name"]},"font-face-src":{attrsGroups:["core"],content:["font-face-name","font-face-uri"]},"font-face-uri":{attrsGroups:["core","xlink"],attrs:["href","xlink:href"],content:["font-face-format"]},foreignObject:{attrsGroups:["core","conditionalProcessing","graphicalEvent","presentation"],attrs:["class","style","externalResourcesRequired","transform","x","y","width","height"],defaults:{x:0,y:0}},g:{attrsGroups:["conditionalProcessing","core","graphicalEvent","presentation"],attrs:["class","style","externalResourcesRequired","transform"],contentGroups:["animation","descriptive","shape","structural","paintServer"],content:["a","altGlyphDef","clipPath","color-profile","cursor","filter","font","font-face","foreignObject","image","marker","mask","pattern","script","style","switch","text","view"]},glyph:{attrsGroups:["core","presentation"],attrs:["class","style","d","horiz-adv-x","vert-origin-x","vert-origin-y","vert-adv-y","unicode","glyph-name","orientation","arabic-form","lang"],defaults:{"arabic-form":"initial"},contentGroups:["animation","descriptive","shape","structural","paintServer"],content:["a","altGlyphDef","clipPath","color-profile","cursor","filter","font","font-face","foreignObject","image","marker","mask","pattern","script","style","switch","text","view"]},glyphRef:{attrsGroups:["core","presentation"],attrs:["class","style","d","horiz-adv-x","vert-origin-x","vert-origin-y","vert-adv-y"],contentGroups:["animation","descriptive","shape","structural","paintServer"],content:["a","altGlyphDef","clipPath","color-profile","cursor","filter","font","font-face","foreignObject","image","marker","mask","pattern","script","style","switch","text","view"]},hatch:{attrsGroups:["core","presentation","xlink"],attrs:["class","style","x","y","pitch","rotate","hatchUnits","hatchContentUnits","transform"],defaults:{hatchUnits:"objectBoundingBox",hatchContentUnits:"userSpaceOnUse",x:"0",y:"0",pitch:"0",rotate:"0"},contentGroups:["animation","descriptive"],content:["hatchPath"]},hatchPath:{attrsGroups:["core","presentation","xlink"],attrs:["class","style","d","offset"],defaults:{offset:"0"},contentGroups:["animation","descriptive"]},hkern:{attrsGroups:["core"],attrs:["u1","g1","u2","g2","k"]},image:{attrsGroups:["core","conditionalProcessing","graphicalEvent","xlink","presentation"],attrs:["class","style","externalResourcesRequired","preserveAspectRatio","transform","x","y","width","height","href","xlink:href"],defaults:{x:"0",y:"0",preserveAspectRatio:"xMidYMid meet"},contentGroups:["animation","descriptive"]},line:{attrsGroups:["conditionalProcessing","core","graphicalEvent","presentation"],attrs:["class","style","externalResourcesRequired","transform","x1","y1","x2","y2"],defaults:{x1:"0",y1:"0",x2:"0",y2:"0"},contentGroups:["animation","descriptive"]},linearGradient:{attrsGroups:["core","presentation","xlink"],attrs:["class","style","externalResourcesRequired","x1","y1","x2","y2","gradientUnits","gradientTransform","spreadMethod","href","xlink:href"],defaults:{x1:"0",y1:"0",x2:"100%",y2:"0",spreadMethod:"pad"},contentGroups:["descriptive"],content:["animate","animateTransform","set","stop"]},marker:{attrsGroups:["core","presentation"],attrs:["class","style","externalResourcesRequired","viewBox","preserveAspectRatio","refX","refY","markerUnits","markerWidth","markerHeight","orient"],defaults:{markerUnits:"strokeWidth",refX:"0",refY:"0",markerWidth:"3",markerHeight:"3"},contentGroups:["animation","descriptive","shape","structural","paintServer"],content:["a","altGlyphDef","clipPath","color-profile","cursor","filter","font","font-face","foreignObject","image","marker","mask","pattern","script","style","switch","text","view"]},mask:{attrsGroups:["conditionalProcessing","core","presentation"],attrs:["class","style","externalResourcesRequired","x","y","width","height","maskUnits","maskContentUnits"],defaults:{maskUnits:"objectBoundingBox",maskContentUnits:"userSpaceOnUse",x:"-10%",y:"-10%",width:"120%",height:"120%"},contentGroups:["animation","descriptive","shape","structural","paintServer"],content:["a","altGlyphDef","clipPath","color-profile","cursor","filter","font","font-face","foreignObject","image","marker","mask","pattern","script","style","switch","text","view"]},metadata:{attrsGroups:["core"]},"missing-glyph":{attrsGroups:["core","presentation"],attrs:["class","style","d","horiz-adv-x","vert-origin-x","vert-origin-y","vert-adv-y"],contentGroups:["animation","descriptive","shape","structural","paintServer"],content:["a","altGlyphDef","clipPath","color-profile","cursor","filter","font","font-face","foreignObject","image","marker","mask","pattern","script","style","switch","text","view"]},mpath:{attrsGroups:["core","xlink"],attrs:["externalResourcesRequired","href","xlink:href"],contentGroups:["descriptive"]},path:{attrsGroups:["conditionalProcessing","core","graphicalEvent","presentation"],attrs:["class","style","externalResourcesRequired","transform","d","pathLength"],contentGroups:["animation","descriptive"]},pattern:{attrsGroups:["conditionalProcessing","core","presentation","xlink"],attrs:["class","style","externalResourcesRequired","viewBox","preserveAspectRatio","x","y","width","height","patternUnits","patternContentUnits","patternTransform","href","xlink:href"],defaults:{patternUnits:"objectBoundingBox",patternContentUnits:"userSpaceOnUse",x:"0",y:"0",width:"0",height:"0",preserveAspectRatio:"xMidYMid meet"},contentGroups:["animation","descriptive","paintServer","shape","structural"],content:["a","altGlyphDef","clipPath","color-profile","cursor","filter","font","font-face","foreignObject","image","marker","mask","pattern","script","style","switch","text","view"]},polygon:{attrsGroups:["conditionalProcessing","core","graphicalEvent","presentation"],attrs:["class","style","externalResourcesRequired","transform","points"],contentGroups:["animation","descriptive"]},polyline:{attrsGroups:["conditionalProcessing","core","graphicalEvent","presentation"],attrs:["class","style","externalResourcesRequired","transform","points"],contentGroups:["animation","descriptive"]},radialGradient:{attrsGroups:["core","presentation","xlink"],attrs:["class","style","externalResourcesRequired","cx","cy","r","fx","fy","fr","gradientUnits","gradientTransform","spreadMethod","href","xlink:href"],defaults:{gradientUnits:"objectBoundingBox",cx:"50%",cy:"50%",r:"50%"},contentGroups:["descriptive"],content:["animate","animateTransform","set","stop"]},meshGradient:{attrsGroups:["core","presentation","xlink"],attrs:["class","style","x","y","gradientUnits","transform"],contentGroups:["descriptive","paintServer","animation"],content:["meshRow"]},meshRow:{attrsGroups:["core","presentation"],attrs:["class","style"],contentGroups:["descriptive"],content:["meshPatch"]},meshPatch:{attrsGroups:["core","presentation"],attrs:["class","style"],contentGroups:["descriptive"],content:["stop"]},rect:{attrsGroups:["conditionalProcessing","core","graphicalEvent","presentation"],attrs:["class","style","externalResourcesRequired","transform","x","y","width","height","rx","ry"],defaults:{x:"0",y:"0"},contentGroups:["animation","descriptive"]},script:{attrsGroups:["core","xlink"],attrs:["externalResourcesRequired","type","href","xlink:href"]},set:{attrsGroups:["conditionalProcessing","core","animation","xlink","animationAttributeTarget","animationTiming"],attrs:["externalResourcesRequired","to"],contentGroups:["descriptive"]},solidColor:{attrsGroups:["core","presentation"],attrs:["class","style"],contentGroups:["paintServer"]},stop:{attrsGroups:["core","presentation"],attrs:["class","style","offset","path"],content:["animate","animateColor","set"]},style:{attrsGroups:["core"],attrs:["type","media","title"],defaults:{type:"text/css"}},svg:{attrsGroups:["conditionalProcessing","core","documentEvent","graphicalEvent","presentation"],attrs:["class","style","x","y","width","height","viewBox","preserveAspectRatio","zoomAndPan","version","baseProfile","contentScriptType","contentStyleType"],defaults:{x:"0",y:"0",width:"100%",height:"100%",preserveAspectRatio:"xMidYMid meet",zoomAndPan:"magnify",version:"1.1",baseProfile:"none",contentScriptType:"application/ecmascript",contentStyleType:"text/css"},contentGroups:["animation","descriptive","shape","structural","paintServer"],content:["a","altGlyphDef","clipPath","color-profile","cursor","filter","font","font-face","foreignObject","image","marker","mask","pattern","script","style","switch","text","view"]},switch:{attrsGroups:["conditionalProcessing","core","graphicalEvent","presentation"],attrs:["class","style","externalResourcesRequired","transform"],contentGroups:["animation","descriptive","shape"],content:["a","foreignObject","g","image","svg","switch","text","use"]},symbol:{attrsGroups:["core","graphicalEvent","presentation"],attrs:["class","style","externalResourcesRequired","preserveAspectRatio","viewBox","refX","refY"],defaults:{refX:0,refY:0},contentGroups:["animation","descriptive","shape","structural","paintServer"],content:["a","altGlyphDef","clipPath","color-profile","cursor","filter","font","font-face","foreignObject","image","marker","mask","pattern","script","style","switch","text","view"]},text:{attrsGroups:["conditionalProcessing","core","graphicalEvent","presentation"],attrs:["class","style","externalResourcesRequired","transform","lengthAdjust","x","y","dx","dy","rotate","textLength"],defaults:{x:"0",y:"0",lengthAdjust:"spacing"},contentGroups:["animation","descriptive","textContentChild"],content:["a"]},textPath:{attrsGroups:["conditionalProcessing","core","graphicalEvent","presentation","xlink"],attrs:["class","style","externalResourcesRequired","href","xlink:href","startOffset","method","spacing","d"],defaults:{startOffset:"0",method:"align",spacing:"exact"},contentGroups:["descriptive"],content:["a","altGlyph","animate","animateColor","set","tref","tspan"]},title:{attrsGroups:["core"],attrs:["class","style"]},tref:{attrsGroups:["conditionalProcessing","core","graphicalEvent","presentation","xlink"],attrs:["class","style","externalResourcesRequired","href","xlink:href"],contentGroups:["descriptive"],content:["animate","animateColor","set"]},tspan:{attrsGroups:["conditionalProcessing","core","graphicalEvent","presentation"],attrs:["class","style","externalResourcesRequired","x","y","dx","dy","rotate","textLength","lengthAdjust"],contentGroups:["descriptive"],content:["a","altGlyph","animate","animateColor","set","tref","tspan"]},use:{attrsGroups:["core","conditionalProcessing","graphicalEvent","presentation","xlink"],attrs:["class","style","externalResourcesRequired","transform","x","y","width","height","href","xlink:href"],defaults:{x:"0",y:"0"},contentGroups:["animation","descriptive"]},view:{attrsGroups:["core"],attrs:["externalResourcesRequired","viewBox","preserveAspectRatio","zoomAndPan","viewTarget"],contentGroups:["descriptive"]},vkern:{attrsGroups:["core"],attrs:["u1","g1","u2","g2","k"]}},r.editorNamespaces=["http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd","http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd","http://www.inkscape.org/namespaces/inkscape","http://www.bohemiancoding.com/sketch/ns","http://ns.adobe.com/AdobeIllustrator/10.0/","http://ns.adobe.com/Graphs/1.0/","http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/","http://ns.adobe.com/Variables/1.0/","http://ns.adobe.com/SaveForWeb/1.0/","http://ns.adobe.com/Extensibility/1.0/","http://ns.adobe.com/Flows/1.0/","http://ns.adobe.com/ImageReplacement/1.0/","http://ns.adobe.com/GenericCustomNamespace/1.0/","http://ns.adobe.com/XPath/1.0/","http://schemas.microsoft.com/visio/2003/SVGExtensions/","http://taptrix.com/vectorillustrator/svg_extensions","http://www.figma.com/figma/ns","http://purl.org/dc/elements/1.1/","http://creativecommons.org/ns#","http://www.w3.org/1999/02/22-rdf-syntax-ns#","http://www.serif.com/","http://www.vector.evaxdesign.sk"],r.referencesProps=["clip-path","color-profile","fill","filter","marker-start","marker-mid","marker-end","mask","stroke","style"],r.inheritableAttrs=["clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cursor","direction","dominant-baseline","fill","fill-opacity","fill-rule","font","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","glyph-orientation-horizontal","glyph-orientation-vertical","image-rendering","letter-spacing","marker","marker-end","marker-mid","marker-start","paint-order","pointer-events","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-anchor","text-rendering","transform","visibility","word-spacing","writing-mode"],r.presentationNonInheritableGroupAttrs=["display","clip-path","filter","mask","opacity","text-decoration","transform","unicode-bidi","visibility"],r.colorsNames={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#0ff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000",blanchedalmond:"#ffebcd",blue:"#00f",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#0ff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#f0f",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#789",lightslategrey:"#789",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#0f0",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#f0f",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#639",red:"#f00",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#fff",whitesmoke:"#f5f5f5",yellow:"#ff0",yellowgreen:"#9acd32"},r.colorsShortNames={"#f0ffff":"azure","#f5f5dc":"beige","#ffe4c4":"bisque","#a52a2a":"brown","#ff7f50":"coral","#ffd700":"gold","#808080":"gray","#008000":"green","#4b0082":"indigo","#fffff0":"ivory","#f0e68c":"khaki","#faf0e6":"linen","#800000":"maroon","#000080":"navy","#808000":"olive","#ffa500":"orange","#da70d6":"orchid","#cd853f":"peru","#ffc0cb":"pink","#dda0dd":"plum","#800080":"purple","#f00":"red","#ff0000":"red","#fa8072":"salmon","#a0522d":"sienna","#c0c0c0":"silver","#fffafa":"snow","#d2b48c":"tan","#008080":"teal","#ff6347":"tomato","#ee82ee":"violet","#f5deb3":"wheat"},r.colorsProps=["color","fill","stroke","stop-color","flood-color","lighting-color"]},{}],262:[function(e,t,r){"use strict";var n,i=String.raw`[-+]?(?:\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?\s*`,a=String.raw`(?:\s,?\s*|,\s*)`,o=`(${i})`+a,s=`([01])${a}?`,l=String.raw`(${i})${a}?(${i})`,c=(o+"?").repeat(2)+o+s.repeat(2)+l,u=/([MmLlHhVvCcSsQqTtAaZz])\s*/,d=new RegExp(i,"g"),p=new RegExp(c,"g"),m=/[-+]?(\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?/,h=e("./_transforms").transform2js,f=e("./_transforms").transformsMultiply,g=e("./_transforms").transformArc,y=e("./_collections.js"),b=y.referencesProps,v=y.attrsGroupsDefaults.presentation["stroke-width"],S=e("../tools").cleanupOutData,x=e("../tools").removeLeadingZero;r.path2js=function(e){if(e.pathJS)return e.pathJS;var t,r={H:1,V:1,M:2,L:2,T:2,Q:4,S:4,C:6,A:7,h:1,v:1,m:2,l:2,t:2,q:4,s:4,c:6,a:7},n=[],i=!1;return e.attr("d").value.split(u).forEach((function(e){if(e){if(!i){if("M"!=e&&"m"!=e)return;i=!0}if(u.test(e))"Z"!=(t=e)&&"z"!=t||n.push({instruction:"z"});else{if("A"==t||"a"==t){for(var a,o=[];a=p.exec(e);)for(var s=1;s-1){for(t=0;t-1?O(r,a):"H"==i?r[0]=a[0]:"V"==i?r[1]=a[0]:"z"==i&&O(r,n);return"z"==i?{instruction:"z"}:{instruction:i.toUpperCase(),data:a}}))};function w(e,t,r){return[e[0]*t+e[2]*r+e[4],e[1]*t+e[3]*r+e[5]]}function C(e,t,r,n,i){var a=1-e;return a*a*a*t+3*a*a*e*r+3*a*e*e*n+e*e*e*i}function T(e,t,r,n){var i=[-1,-1],a=2*t-e-r,o=-Math.sqrt(-e*(r-n)+t*t-t*(r+n)+r*r),s=3*t-e-3*r+n;return 0!==s&&(i[0]=(a+o)/s,i[1]=(a-o)/s),i}function A(e,t,r,n){var i=1-e;return i*i*t+2*i*e*r+e*e*n}function E(e,t,r){var n=-1,i=e-2*t+r;return 0!==i&&(n=(e-t)/i),n}function O(e,t){return e[0]=t[t.length-2],e[1]=t[t.length-1],e}function _(e,t){if(2==e.length){var r=e[1],n=e[0];L(s=z(e[1]),a=P(n,r))>0?O(t,R(a,r)):(O(t,s),e.shift())}else{r=e[2],n=e[1];var i=e[0],a=P(n,r),o=P(i,r),s=z(r),l=R(a,o),c=R(o,a);if(L(l,s)>0)L(a,s)>0?(O(t,l),e.shift()):(O(t,s),e.splice(0,2));else{if(!(L(c,s)>0))return!0;L(o,s)>0?(O(t,c),e.splice(1,1)):(O(t,s),e.splice(0,2))}}return!1}function z(e){return[-e[0],-e[1]]}function P(e,t){return[e[0]-t[0],e[1]-t[1]]}function L(e,t){return e[0]*t[0]+e[1]*t[1]}function R(e,t){var r=[-e[1],e[0]];return L(r,z(t))<0?z(r):r}function B(e,t,r,i){var a=e.length&&e[e.length-1],o=r&&i[r-1],s=a.length&&a[a.length-1],l=t.data,c=s;switch(t.instruction){case"M":e.push(a=[]);break;case"H":m(a,[l[0],s[1]]);break;case"V":m(a,[s[0],l[0]]);break;case"Q":m(a,l.slice(0,2)),n=[l[2]-l[0],l[3]-l[1]];break;case"T":"Q"!=o.instruction&&"T"!=o.instruction||(m(a,c=[s[0]+n[0],s[1]+n[1]]),n=[l[0]-c[0],l[1]-c[1]]);break;case"C":m(a,[.5*(s[0]+l[0]),.5*(s[1]+l[1])]),m(a,[.5*(l[0]+l[2]),.5*(l[1]+l[3])]),m(a,[.5*(l[2]+l[4]),.5*(l[3]+l[5])]),n=[l[4]-l[2],l[5]-l[3]];break;case"S":"C"!=o.instruction&&"S"!=o.instruction||(m(a,[s[0]+.5*n[0],s[1]+.5*n[1]]),c=[s[0]+n[0],s[1]+n[1]]),m(a,[.5*(c[0]+l[0]),.5*(c[1]+l[1])]),m(a,[.5*(l[0]+l[2]),.5*(l[1]+l[3])]),n=[l[2]-l[0],l[3]-l[1]];break;case"A":for(var u,d=I.apply(0,s.concat(l));(u=d.splice(0,6).map(p)).length;)m(a,[.5*(s[0]+u[0]),.5*(s[1]+u[1])]),m(a,[.5*(u[0]+u[2]),.5*(u[1]+u[3])]),m(a,[.5*(u[2]+u[4]),.5*(u[3]+u[5])]),d.length&&m(a,s=u.slice(-2))}return l&&l.length>=2&&m(a,l.slice(-2)),e;function p(e,t){return e+s[t%2]}function m(t,r){(!t.length||r[1]>t[t.maxY][1])&&(t.maxY=t.length,e.maxY=e.length?Math.max(r[1],e.maxY):r[1]),(!t.length||r[0]>t[t.maxX][0])&&(t.maxX=t.length,e.maxX=e.length?Math.max(r[0],e.maxX):r[0]),(!t.length||r[1]=2&&M(t[t.length-2],t[t.length-1],e[i])<=0;)t.pop();e[i][1]=2&&M(a[a.length-2],a[a.length-1],e[i])<=0;)a.pop();e[i][1]>e[o][1]&&(o=i,s=a.length),a.push(e[i])}a.pop(),t.pop();var l=t.concat(a);return l.minX=0,l.maxX=t.length,l.minY=n,l.maxY=(t.length+s)%l.length,l}function M(e,t,r){return(t[0]-e[0])*(r[1]-e[1])-(t[1]-e[1])*(r[0]-e[0])}function I(e,t,r,n,i,a,o,s,l,c){var u=120*Math.PI/180,d=Math.PI/180*(+i||0),p=[],m=function(e,t,r){return e*Math.cos(r)-t*Math.sin(r)},h=function(e,t,r){return e*Math.sin(r)+t*Math.cos(r)};if(c)w=c[0],C=c[1],x=c[2],k=c[3];else{t=h(e=m(e,t,-d),t,-d);var f=(e-(s=m(s,l,-d)))/2,g=(t-(l=h(s,l,-d)))/2,y=f*f/(r*r)+g*g/(n*n);y>1&&(r*=y=Math.sqrt(y),n*=y);var b=r*r,v=n*n,S=(a==o?-1:1)*Math.sqrt(Math.abs((b*v-b*g*g-v*f*f)/(b*g*g+v*f*f))),x=S*r*g/n+(e+s)/2,k=S*-n*f/r+(t+l)/2,w=Math.asin(((t-k)/n).toFixed(9)),C=Math.asin(((l-k)/n).toFixed(9));w=eC&&(w-=2*Math.PI),!o&&C>w&&(C-=2*Math.PI)}var T=C-w;if(Math.abs(T)>u){var A=C,E=s,O=l;C=w+u*(o&&C>w?1:-1),p=I(s=x+r*Math.cos(C),l=k+n*Math.sin(C),r,n,i,0,o,E,O,[C,A,x,k])}T=C-w;var _=Math.cos(w),z=Math.sin(w),P=Math.cos(C),L=Math.sin(C),R=Math.tan(T/4),B=4/3*r*R,q=4/3*n*R,M=[-B*z,q*_,s+B*L-e,l-q*P-t,s-e,l-t];if(c)return M.concat(p);for(var W=[],D=0,N=(p=M.concat(p)).length;D80){var t=e.data[0],r=e.data[2];e.data[0]=e.data[1],e.data[1]=t,e.data[2]=r+(r>0?-90:90)}n=w(a.data,e.data[5],e.data[6]),e.data[5]=n[0],e.data[6]=n[1]}else for(var i=0;if&&(f=e),of&&(f=o),l=T(e,r,i,o),p=0;p=0&&c<=1&&((u=C(c,e,r,i,o))f&&(f=u));for(tg&&(g=t),sg&&(g=s),l=T(t,n,a,s),p=0;p=0&&c<=1&&((d=C(c,t,n,a,s))g&&(g=d));return{minx:m,miny:h,maxx:f,maxy:g}},r.computeQuadraticBoundingBox=function(e,t,r,n,i,a){var o,s,l,c=Number.POSITIVE_INFINITY,u=Number.POSITIVE_INFINITY,d=Number.NEGATIVE_INFINITY,p=Number.NEGATIVE_INFINITY;return ed&&(d=e),id&&(d=i),(o=E(e,r,i))>=0&&o<=1&&((s=A(o,e,r,i))d&&(d=s)),tp&&(p=t),ap&&(p=a),(o=E(t,n,a))>=0&&o<=1&&((l=A(o,t,n,a))p&&(p=l)),{minx:c,miny:u,maxx:d,maxy:p}},r.js2path=function(e,t,r){e.pathJS=t,r.collapseRepeated&&(t=function(e){var t,r;return e=e.reduce((function(e,n){return t&&n.data&&n.instruction==t.instruction?"M"!=n.instruction?t=e[r]={instruction:t.instruction,data:t.data.concat(n.data),coords:n.coords,base:t.base}:(t.data=n.data,t.coords=n.coords):(e.push(n),t=n,r=e.length-1),e}),[])}(t)),e.attr("d").value=t.reduce((function(e,t){var n="";return t.data&&(n=S(t.data,r,t.instruction)),e+(t.instruction+n)}),"")},r.intersects=function(e,t){if(e.length<3||t.length<3)return!1;var r=k(e).reduce(B,[]),n=k(t).reduce(B,[]);if(r.maxX<=n.minX||n.maxX<=r.minX||r.maxY<=n.minY||n.maxY<=r.minY||r.every((function(e){return n.every((function(t){return e[e.maxX][0]<=t[t.minX][0]||t[t.maxX][0]<=e[e.minX][0]||e[e.maxY][1]<=t[t.minY][1]||t[t.maxY][1]<=e[e.minY][1]}))})))return!1;var i=r.map(q),a=n.map(q);return i.some((function(e){return!(e.length<3)&&a.some((function(t){if(t.length<3)return!1;for(var r=[o(e,t,[1,0])],n=z(r[0]),i=1e4;;){if(0==i--)return console.error("Error: infinite loop while processing mergePaths plugin."),!0;if(r.push(o(e,t,n)),L(n,r[r.length-1])<=0)return!1;if(_(r,n))return!0}}))}));function o(e,t,r){return P(s(e,r),s(t,z(r)))}function s(e,t){for(var r,n=t[1]>=0?t[0]<0?e.maxY:e.maxX:t[0]<0?e.minX:e.minY,i=-1/0;(r=L(e[n],t))>i;)i=r,n=++n%e.length;return e[(n||e.length)-1]}}},{"../tools":314,"./_collections.js":261,"./_transforms":263}],263:[function(e,t,r){"use strict";var n=/matrix|translate|scale|rotate|skewX|skewY/,i=/\s*(matrix|translate|scale|rotate|skewX|skewY)\s*\(\s*(.+?)\s*\)[\s,]*/,a=/[-+]?(?:\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?/g;r.transform2js=function(e){var t,r=[];return e.split(i).forEach((function(e){var i;if(e)if(n.test(e))r.push(t={name:e});else for(;i=a.exec(e);)i=Number(i),t.data?t.data.push(i):t.data=[i]})),t&&t.data?r:[]},r.transformsMultiply=function(e){return e={name:"matrix",data:(e=e.map((function(e){return"matrix"===e.name?e.data:function(e){if("matrix"===e.name)return e.data;var t;switch(e.name){case"translate":t=[1,0,0,1,e.data[0],e.data[1]||0];break;case"scale":t=[e.data[0],0,0,e.data[1]||e.data[0],0,0];break;case"rotate":var r=o.cos(e.data[0]),n=o.sin(e.data[0]),i=e.data[1]||0,a=e.data[2]||0;t=[r,n,-n,r,(1-r)*i+n*a,(1-r)*a-n*i];break;case"skewX":t=[1,0,o.tan(e.data[0]),1,0,0];break;case"skewY":t=[1,o.tan(e.data[0]),0,1,0,0]}return t}(e)}))).length>0?e.reduce(s):[]}};var o=r.mth={rad:function(e){return e*Math.PI/180},deg:function(e){return 180*e/Math.PI},cos:function(e){return Math.cos(this.rad(e))},acos:function(e,t){return+this.deg(Math.acos(e)).toFixed(t)},sin:function(e){return Math.sin(this.rad(e))},asin:function(e,t){return+this.deg(Math.asin(e)).toFixed(t)},tan:function(e){return Math.tan(this.rad(e))},atan:function(e,t){return+this.deg(Math.atan(e)).toFixed(t)}};function s(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}r.matrixToTransform=function(e,t){var r=t.floatPrecision,n=e.data,i=[],a=+Math.hypot(n[0],n[1]).toFixed(t.transformPrecision),s=+((n[0]*n[3]-n[1]*n[2])/a).toFixed(t.transformPrecision),l=n[0]*n[2]+n[1]*n[3],c=n[0]*n[1]+n[2]*n[3],u=0!=c||a==s;if((n[4]||n[5])&&i.push({name:"translate",data:n.slice(4,n[5]?6:5)}),!n[1]&&n[2])i.push({name:"skewX",data:[o.atan(n[2]/s,r)]});else if(n[1]&&!n[2])i.push({name:"skewY",data:[o.atan(n[1]/n[0],r)]}),a=n[0],s=n[3];else if(!l||1==a&&1==s||!u){u||(a=(n[0]<0?-1:1)*Math.hypot(n[0],n[2]),s=(n[3]<0?-1:1)*Math.hypot(n[1],n[3]),i.push({name:"scale",data:[a,s]}));var d=Math.min(Math.max(-1,n[0]/a),1),p=[o.acos(d,r)*((u?1:s)*n[1]<0?-1:1)];if(p[0]&&i.push({name:"rotate",data:p}),c&&l&&i.push({name:"skewX",data:[o.atan(l/(a*a),r)]}),p[0]&&(n[4]||n[5])){i.shift();var m=n[0]/a,h=n[1]/(u?a:s),f=n[4]*(u||s),g=n[5]*(u||a),y=(Math.pow(1-m,2)+Math.pow(h,2))*(u||a*s);p.push(((1-m)*f-h*g)/y),p.push(((1-m)*g+h*f)/y)}}else if(n[1]||n[2])return e;return(!u||1==a&&1==s)&&i.length||i.push({name:"scale",data:a==s?[a]:[a,s]}),i},r.transformArc=function(e,t){var r=e[0],n=e[1],i=e[2]*Math.PI/180,a=Math.cos(i),o=Math.sin(i),l=Math.pow(e[5]*a+e[6]*o,2)/(4*r*r)+Math.pow(e[6]*a-e[5]*o,2)/(4*n*n);l>1&&(r*=l=Math.sqrt(l),n*=l);var c=s(t,[r*a,r*o,-n*o,n*a,0,0]),u=c[2]*c[2]+c[3]*c[3],d=c[0]*c[0]+c[1]*c[1]+u,p=Math.hypot(c[0]-c[3],c[1]+c[2])*Math.hypot(c[0]+c[3],c[1]-c[2]);if(p){var m=(d+p)/2,h=(d-p)/2,f=Math.abs(m-u)>1e-6,g=(f?m:h)-u,y=c[0]*c[2]+c[1]*c[3],b=c[0]*g+c[2]*y,v=c[1]*g+c[3]*y;e[0]=Math.sqrt(m),e[1]=Math.sqrt(h),e[2]=((f?v<0:b>0)?-1:1)*Math.acos((f?b:v)/Math.hypot(b,v))*180/Math.PI}else e[0]=e[1]=Math.sqrt(d/2),e[2]=0;return t[0]<0!=t[3]<0&&(e[4]=1-e[4]),e}},{}],264:[function(e,t,r){"use strict";r.type="full",r.active=!1,r.description="adds attributes to an outer element";r.fn=function(e,t){if(!t||!Array.isArray(t.attributes)&&!t.attribute)return console.error('Error in plugin "addAttributesToSVGElement": absent parameters.\nIt should have a list of "attributes" or one "attribute".\nConfig example:\n\nplugins:\n- addAttributesToSVGElement:\n attribute: "mySvg"\n\nplugins:\n- addAttributesToSVGElement:\n attributes: ["mySvg", "size-big"]\n\nplugins:\n- addAttributesToSVGElement:\n attributes:\n - focusable: false\n - data-image: icon'),e;var r=t.attributes||[t.attribute],n=e.content[0];return n.isElem("svg")&&r.forEach((function(e){"string"==typeof e?n.hasAttr(e)||n.addAttr({name:e,prefix:"",local:e}):"object"==typeof e&&Object.keys(e).forEach((function(t){n.hasAttr(t)||n.addAttr({name:t,value:e[t],prefix:"",local:t})}))})),e}},{}],265:[function(e,t,r){"use strict";r.type="full",r.active=!1,r.description="adds classnames to an outer element";r.fn=function(e,t){if(!t||!(Array.isArray(t.classNames)&&t.classNames.some(String)||t.className))return console.error('Error in plugin "addClassesToSVGElement": absent parameters.\nIt should have a list of classes in "classNames" or one "className".\nConfig example:\n\nplugins:\n- addClassesToSVGElement:\n className: "mySvg"\n\nplugins:\n- addClassesToSVGElement:\n classNames: ["mySvg", "size-big"]\n'),e;var r=t.classNames||[t.className],n=e.content[0];return n.isElem("svg")&&n.class.add.apply(n.class,r),e}},{}],266:[function(e,t,r){"use strict";r.type="perItem",r.active=!0,r.description="cleanups attributes from newlines, trailing and repeating spaces",r.params={newlines:!0,trim:!0,spaces:!0};var n=/(\S)\r?\n(\S)/g,i=/\r?\n/g,a=/\s{2,}/g;r.fn=function(e,t){e.isElem()&&e.eachAttr((function(e){t.newlines&&(e.value=e.value.replace(n,(function(e,t,r){return t+" "+r})),e.value=e.value.replace(i,"")),t.trim&&(e.value=e.value.trim()),t.spaces&&(e.value=e.value.replace(a," "))}))}},{}],267:[function(e,t,r){"use strict";r.type="full",r.active=!0,r.description="remove or cleanup enable-background attribute when possible",r.fn=function(e){var t=/^new\s0\s0\s([\-+]?\d*\.?\d+([eE][\-+]?\d+)?)\s([\-+]?\d*\.?\d+([eE][\-+]?\d+)?)$/,r=!1,n=["svg","mask","pattern"];function i(e,t){return e.content.forEach((function(e){t(e),e.content&&i(e,t)})),e}var a=i(e,(function(e){!function(e){if(e.isElem(n)&&e.hasAttr("enable-background")&&e.hasAttr("width")&&e.hasAttr("height")){var r=e.attr("enable-background").value.match(t);r&&e.attr("width").value===r[1]&&e.attr("height").value===r[3]&&(e.isElem("svg")?e.removeAttr("enable-background"):e.attr("enable-background").value="new")}}(e),r||function(e){e.isElem("filter")&&(r=!0)}(e)}));return r?a:i(a,(function(e){e.removeAttr("enable-background")}))}},{}],268:[function(e,t,r){"use strict";r.type="full",r.active=!0,r.description="removes unused IDs and minifies used",r.params={remove:!0,minify:!0,prefix:"",preserve:[],preservePrefixes:[],force:!1};var n=new Set(e("./_collections").referencesProps),i=/\burl\(("|')?#(.+?)\1\)/,a=/^#(.+?)$/,o=/(\w+)\./,s=["style","script"],l=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],c=l.length-1;function u(e){if(!e)return[0];e[e.length-1]++;for(var t=e.length-1;t>0;t--)e[t]>c&&(e[t]=0,void 0!==e[t-1]&&e[t-1]++);return e[0]>c&&(e[0]=0,e.unshift(0)),e}function d(e,t){return t.prefix+e.map((e=>l[e])).join("")}r.fn=function(e,t){var r,l,c=new Map,p=new Map,m=!1,h=new Set(Array.isArray(t.preserve)?t.preserve:t.preserve?[t.preserve]:[]),f=new Set(Array.isArray(t.preservePrefixes)?t.preservePrefixes:t.preservePrefixes?[t.preservePrefixes]:[]);if(e=function e(r){for(var l=0;lh.has(e)||function(e,t){if(!t)return!1;for(var r of e)if(t.startsWith(r))return!0;return!1}(f,e);for(var y of p){var b=y[0];if(c.has(b)){if(t.minify&&!g(b)){do{l=d(r=u(r),t)}while(g(l));for(var v of(c.get(b).attr("id").value=l,y[1]))v.value=v.value.includes("#")?v.value.replace("#"+b,"#"+l):v.value.replace(b+".",l+".")}c.delete(b)}}if(t.remove)for(var S of c)g(S[0])||S[1].removeAttr("id");return e}},{"./_collections":261}],269:[function(e,t,r){"use strict";r.type="perItem",r.active=!1,r.description="rounds list of values to the fixed precision",r.params={floatPrecision:3,leadingZero:!0,defaultPx:!0,convertToPx:!0};var n=/^([\-+]?\d*\.?\d+([eE][\-+]?\d+)?)(px|pt|pc|mm|cm|m|in|ft|em|ex|%)?$/,i=/\s+,?\s*|,\s*/,a=e("../tools").removeLeadingZero,o={cm:96/2.54,mm:96/25.4,in:96,pt:4/3,pc:16};r.fn=function(e,t){function r(e){var r,s,l,c,u,d=e.value.split(i),p=[];d.forEach((function(e){if(l=e.match(n),c=e.match(/new/),l){if(r=+(+l[1]).toFixed(t.floatPrecision),s=l[3]||"",t.convertToPx&&s&&s in o){var i=+(o[s]*l[1]).toFixed(t.floatPrecision);String(i).length-1){var r,i=e.value;if(t.currentColor&&(r="string"==typeof t.currentColor?i===t.currentColor:t.currentColor.exec?t.currentColor.exec(i):!i.match(l))&&(i="currentColor"),t.names2hex&&i.toLowerCase()in n.colorsNames&&(i=n.colorsNames[i.toLowerCase()]),t.rgb2hex&&(r=i.match(o))&&(r=r.slice(1,4).map((function(e){return e.indexOf("%")>-1&&(e=Math.round(2.55*parseFloat(e))),Math.max(0,Math.min(e,255))})),i="#"+("00000"+((c=r)[0]<<16|c[1]<<8|c[2]).toString(16)).slice(-6).toUpperCase()),t.shorthex&&(r=i.match(s))&&(i="#"+r[0][1]+r[0][3]+r[0][5]),t.shortname){var a=i.toLowerCase();a in n.colorsShortNames&&(i=n.colorsShortNames[a])}e.value=i}var c}))}},{"./_collections":261}],273:[function(e,t,r){"use strict";r.type="perItem",r.active=!0,r.description="converts non-eccentric s to s",r.fn=function(e){if(e.isElem("ellipse")){var t=e.attr("rx").value||0,r=e.attr("ry").value||0;if(t===r||"auto"===t||"auto"===r){var n="auto"!==t?t:r;e.renameElem("circle"),e.removeAttr(["rx","ry"]),e.addAttr({name:"r",value:n,prefix:"",local:"r"})}}}},{}],274:[function(e,t,r){"use strict";r.type="perItem",r.active=!0,r.description="optimizes path data: writes in shorter form, applies transformations",r.params={applyTransforms:!0,applyTransformsStroked:!0,makeArcs:{threshold:2.5,tolerance:.5},straightCurves:!0,lineShorthands:!0,curveSmoothShorthands:!0,floatPrecision:3,transformPrecision:5,removeUseless:!0,collapseRepeated:!0,utilizeAbsolute:!0,leadingZero:!0,negativeExtraSpace:!0,noSpaceAfterFlags:!0,forceAbsolutePath:!1};var n,i,a,o,s,l,c,u=e("./_collections.js").pathElems,d=e("./_path.js").path2js,p=e("./_path.js").js2path,m=e("./_path.js").applyTransforms,h=e("../tools").cleanupOutData;function f(e){var t=g([0,0,e[2],e[3],e[0],e[1],e[4],e[5]]);return t&&e[2]0;)if(e[t].toFixed(i)!=e[t]){var r=+e[t].toFixed(i-1);e[t]=+Math.abs(r-e[t]).toFixed(i+1)>=a?+e[t].toFixed(i):r}return e}function b(e){for(var t=e.length;t-- >0;)e[t]=Math.round(e[t]);return e}function v(e){var t=e.length-2,r=-e[t+1],n=e[t],i=1/(r*r+n*n);if(t<=1||!isFinite(i))return!1;for(;(t-=2)>=0;)if(Math.sqrt(Math.pow(r*e[t]+n*e[t+1],2)*i)>a)return!1;return!0}function S(e,t){switch(e.instruction){case"s":e.instruction="c";break;case"t":e.instruction="q"}return e.data.unshift(t[t.length-2]-t[t.length-4],t[t.length-1]-t[t.length-3]),e}function x(e,t){return Math.hypot(e[0]-t[0],e[1]-t[1])}function k(e,t){var r=t*t,n=r*t,i=1-t,a=i*i;return[3*a*t*e[0]+3*i*r*e[2]+n*e[4],3*a*t*e[1]+3*i*r*e[3]+n*e[5]]}function w(e,t){var r=Math.min(o*a,s*t.radius/100);return[0,1/4,.5,3/4,1].every((function(n){return Math.abs(x(k(e,n),t.center)-t.radius)<=r}))}function C(e,t){return w(e,{center:[t.center[0]+e[4],t.center[1]+e[5]],radius:t.radius})}function T(e,t){var r=-t.center[0],n=-t.center[1],i=e[4]-t.center[0],a=e[5]-t.center[1];return Math.acos((r*i+n*a)/Math.sqrt((r*r+n*n)*(i*i+a*a)))}function A(e,t){return t.reduce((function(t,r){var i="";return r.data&&(i=h(n(r.data.slice()),e)),t+r.instruction+i}),"")}r.fn=function(e,t){if(e.isElem(u)&&e.hasAttr("d")){i=t.floatPrecision,a=!1!==i?+Math.pow(.1,i).toFixed(i):.01,n=i>0&&i<20?y:b,t.makeArcs&&(o=t.makeArcs.threshold,s=t.makeArcs.tolerance),l=e.hasAttr("marker-mid");var r=e.computedAttr("stroke"),E=e.computedAttr("stroke");c=r&&"none"!=r&&E&&"butt"!=E;var O=d(e);O.length&&(P=[0,0],L=[0,0],(_=O).forEach((function(e,t){var r=e.instruction,n=e.data;n?("mcslqta".indexOf(r)>-1?(P[0]+=n[n.length-2],P[1]+=n[n.length-1],"m"===r&&(L[0]=P[0],L[1]=P[1],z=e)):"h"===r?P[0]+=n[0]:"v"===r&&(P[1]+=n[0]),"M"===r?(t>0&&(r="m"),n[0]-=P[0],n[1]-=P[1],L[0]=P[0]+=n[0],L[1]=P[1]+=n[1],z=e):"LT".indexOf(r)>-1?(r=r.toLowerCase(),n[0]-=P[0],n[1]-=P[1],P[0]+=n[0],P[1]+=n[1]):"C"===r?(r="c",n[0]-=P[0],n[1]-=P[1],n[2]-=P[0],n[3]-=P[1],n[4]-=P[0],n[5]-=P[1],P[0]+=n[4],P[1]+=n[5]):"SQ".indexOf(r)>-1?(r=r.toLowerCase(),n[0]-=P[0],n[1]-=P[1],n[2]-=P[0],n[3]-=P[1],P[0]+=n[2],P[1]+=n[3]):"A"===r?(r="a",n[5]-=P[0],n[6]-=P[1],P[0]+=n[5],P[1]+=n[6]):"H"===r?(r="h",n[0]-=P[0],P[0]+=n[0]):"V"===r&&(r="v",n[0]-=P[1],P[1]+=n[0]),e.instruction=r,e.data=n,e.coords=P.slice(-2)):"z"==r&&(z&&(e.coords=z.coords),P[0]=L[0],P[1]=L[1]),e.base=t>0?_[t-1].coords:[0,0]})),t.applyTransforms&&(O=m(e,O,t)),O=function(e,t){var r=A.bind(null,t),u=[0,0],d=[0,0],p={};return e=e.filter((function(e,m,h){var y=e.instruction,b=e.data,A=h[m+1];if(b){var E,O=b;if("s"===y&&(O=[0,0].concat(b),"cs".indexOf(p.instruction)>-1)){var _=p.data,z=_.length;O[0]=_[z-2]-_[z-4],O[1]=_[z-1]-_[z-3]}if(t.makeArcs&&("c"==y||"s"==y)&&f(O)&&(E=function(e){var t=k(e,.5),r=[t[0]/2,t[1]/2],n=[(t[0]+e[4])/2,(t[1]+e[5])/2],i=g([r[0],r[1],r[0]+r[1],r[1]-r[0],n[0],n[1],n[0]+(n[1]-t[1]),n[1]-(n[0]-t[0])]),l=i&&x([0,0],i),c=Math.min(o*a,s*l/100);if(i&&l<1e15&&[1/4,3/4].every((function(t){return Math.abs(x(k(e,t),i)-l)<=c})))return{center:i,radius:l}}(O))){var P,L=n([E.radius])[0],R=T(O,E),B=O[5]*O[0]-O[4]*O[1]>0?1:0,q={instruction:"a",data:[L,L,0,0,B,O[4],O[5]],coords:e.coords.slice(),base:e.base},M=[q],I=[E.center[0]-O[4],E.center[1]-O[5]],W={center:I,radius:E.radius},D=[e],N=0,j="";if("c"==p.instruction&&f(p.data)&&C(p.data,E)||"a"==p.instruction&&p.sdata&&C(p.sdata,E)){D.unshift(p),q.base=p.base,q.data[5]=q.coords[0]-q.base[0],q.data[6]=q.coords[1]-q.base[1];var F="a"==p.instruction?p.sdata:p.data;(R+=T(F,{center:[F[4]+E.center[0],F[5]+E.center[1]],radius:E.radius}))>Math.PI&&(q.data[3]=1),N=1}for(var G=m;(A=h[++G])&&~"cs".indexOf(A.instruction);){var U=A.data;if("s"==A.instruction&&(U=(P=S({instruction:"s",data:A.data.slice()},h[G-1].data)).data,P.data=U.slice(0,2),j=r([P])),!f(U)||!w(U,W))break;if((R+=T(U,W))-2*Math.PI>.001)break;if(R>Math.PI&&(q.data[3]=1),D.push(A),!(2*Math.PI-R>.001)){q.data[5]=2*(W.center[0]-U[4]),q.data[6]=2*(W.center[1]-U[5]),q.coords=[q.base[0]+q.data[5],q.base[1]+q.data[6]],q={instruction:"a",data:[L,L,0,0,B,A.coords[0]-q.coords[0],A.coords[1]-q.coords[1]],coords:A.coords,base:q.coords},M.push(q),G++;break}q.coords=A.coords,q.data[5]=q.coords[0]-q.base[0],q.data[6]=q.coords[1]-q.base[1],I[0]-=U[4],I[1]-=U[5]}if((r(M)+j).length0&&h.splice.apply(h,[m+1,D.length-1-N].concat(M)),!q)return!1;y="a",b=q.data,e.coords=q.coords}}if(!1!==i){if("mltqsc".indexOf(y)>-1)for(var H=b.length;H--;)b[H]+=e.base[H%2]-u[H%2];else"h"==y?b[0]+=e.base[0]-u[0]:"v"==y?b[0]+=e.base[1]-u[1]:"a"==y&&(b[5]+=e.base[0]-u[0],b[6]+=e.base[1]-u[1]);n(b),"h"==y?u[0]+=b[0]:"v"==y?u[1]+=b[0]:(u[0]+=b[b.length-2],u[1]+=b[b.length-1]),n(u),"m"==y.toLowerCase()&&(d[0]=u[0],d[1]=u[1])}if(t.straightCurves&&("c"===y&&v(b)||"s"===y&&v(O)?(A&&"s"==A.instruction&&S(A,b),y="l",b=b.slice(-2)):"q"===y&&v(b)?(A&&"t"==A.instruction&&S(A,b),y="l",b=b.slice(-2)):"t"===y&&"q"!==p.instruction&&"t"!==p.instruction?(y="l",b=b.slice(-2)):"a"!==y||0!==b[0]&&0!==b[1]||(y="l",b=b.slice(-2))),t.lineShorthands&&"l"===y&&(0===b[1]?(y="h",b.pop()):0===b[0]&&(y="v",b.shift())),t.collapseRepeated&&!l&&"mhv".indexOf(y)>-1&&p.instruction&&y==p.instruction.toLowerCase()&&("h"!=y&&"v"!=y||p.data[0]>=0==b[0]>=0))return p.data[0]+=b[0],"h"!=y&&"v"!=y&&(p.data[1]+=b[1]),p.coords=e.coords,h[m]=p,!1;if(t.curveSmoothShorthands&&p.instruction&&("c"===y?("c"===p.instruction&&b[0]===-(p.data[2]-p.data[4])&&b[1]===-(p.data[3]-p.data[5])||"s"===p.instruction&&b[0]===-(p.data[0]-p.data[2])&&b[1]===-(p.data[1]-p.data[3])||-1==="cs".indexOf(p.instruction)&&0===b[0]&&0===b[1])&&(y="s",b=b.slice(2)):"q"===y&&("q"===p.instruction&&b[0]===p.data[2]-p.data[0]&&b[1]===p.data[3]-p.data[1]||"t"===p.instruction&&b[2]===p.data[0]&&b[3]===p.data[1])&&(y="t",b=b.slice(2))),t.removeUseless&&!c){if("lhvqtcs".indexOf(y)>-1&&b.every((function(e){return 0===e})))return h[m]=p,!1;if("a"===y&&0===b[5]&&0===b[6])return h[m]=p,!1}e.instruction=y,e.data=b,p=e}else{if(u[0]=d[0],u[1]=d[1],"z"==p.instruction)return!1;p=e}return!0}))}(O,t),t.utilizeAbsolute&&(O=function(e,t){var r=e[0];return e=e.filter((function(e,i){if(0==i)return!0;if(!e.data)return r=e,!0;var a=e.instruction,o=e.data,s=o&&o.slice(0);if("mltqsc".indexOf(a)>-1)for(var l=s.length;l--;)s[l]+=e.base[l%2];else"h"==a?s[0]+=e.base[0]:"v"==a?s[0]+=e.base[1]:"a"==a&&(s[5]+=e.base[0],s[6]+=e.base[1]);n(s);var c=h(s,t),u=h(o,t);return(t.forceAbsolutePath||c.length96&&c.length==u.length-1&&(o[0]<0||/^0\./.test(o[0])&&r.data[r.data.length-1]%1)))&&(e.instruction=a.toUpperCase(),e.data=s),r=e,!0}))}(O,t)),p(e,O,t))}var _,z,P,L}},{"../tools":314,"./_collections.js":261,"./_path.js":262}],275:[function(e,t,r){"use strict";r.type="perItem",r.active=!0,r.description="converts basic shapes to more compact path form",r.params={convertArcs:!1};var n={value:0},i=/[-+]?(?:\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?/g;r.fn=function(e,t){var r=t&&t.convertArcs;if(e.isElem("rect")&&e.hasAttr("width")&&e.hasAttr("height")&&!e.hasAttr("rx")&&!e.hasAttr("ry")){var a=+(e.attr("x")||n).value,o=+(e.attr("y")||n).value,s=+e.attr("width").value,l=+e.attr("height").value;if(isNaN(a-o+s-l))return;var c="M"+a+" "+o+"H"+(a+s)+"V"+(o+l)+"H"+a+"z";e.addAttr({name:"d",value:c,prefix:"",local:"d"}),e.renameElem("path").removeAttr(["x","y","width","height"])}else if(e.isElem("line")){var u=+(e.attr("x1")||n).value,d=+(e.attr("y1")||n).value,p=+(e.attr("x2")||n).value,m=+(e.attr("y2")||n).value;if(isNaN(u-d+p-m))return;e.addAttr({name:"d",value:"M"+u+" "+d+"L"+p+" "+m,prefix:"",local:"d"}),e.renameElem("path").removeAttr(["x1","y1","x2","y2"])}else if((e.isElem("polyline")||e.isElem("polygon"))&&e.hasAttr("points")){var h=(e.attr("points").value.match(i)||[]).map(Number);if(h.length<4)return!1;e.addAttr({name:"d",value:"M"+h.slice(0,2).join(" ")+"L"+h.slice(2).join(" ")+(e.isElem("polygon")?"z":""),prefix:"",local:"d"}),e.renameElem("path").removeAttr("points")}else if(e.isElem("circle")&&r){var f=+(e.attr("cx")||n).value,g=+(e.attr("cy")||n).value,y=+(e.attr("r")||n).value;if(isNaN(f-g+y))return;var b="M"+f+" "+(g-y)+"A"+y+" "+y+" 0 1 0 "+f+" "+(g+y)+"A"+y+" "+y+" 0 1 0 "+f+" "+(g-y)+"Z";e.addAttr({name:"d",value:b,prefix:"",local:"d"}),e.renameElem("path").removeAttr(["cx","cy","r"])}else if(e.isElem("ellipse")&&r){var v=+(e.attr("cx")||n).value,S=+(e.attr("cy")||n).value,x=+(e.attr("rx")||n).value,k=+(e.attr("ry")||n).value;if(isNaN(v-S+x-k))return;var w="M"+v+" "+(S-k)+"A"+x+" "+k+" 0 1 0 "+v+" "+(S+k)+"A"+x+" "+k+" 0 1 0 "+v+" "+(S-k)+"Z";e.addAttr({name:"d",value:w,prefix:"",local:"d"}),e.renameElem("path").removeAttr(["cx","cy","rx","ry"])}}},{}],276:[function(e,t,r){"use strict";r.type="perItem",r.active=!0,r.description="converts style to attributes",r.params={keepImportant:!1};var n=e("./_collections").attrsGroups.presentation,i="\\\\(?:[0-9a-f]{1,6}\\s?|\\r\\n|.)",a="\\s*("+m("[^:;\\\\]",i)+"*?)\\s*",o="'(?:[^'\\n\\r\\\\]|"+i+")*?(?:'|$)",s='"(?:[^"\\n\\r\\\\]|'+i+')*?(?:"|$)',l=new RegExp("^"+m(o,s)+"$"),c="\\("+m("[^'\"()\\\\]+",i,o,s)+"*?\\)",u="\\s*("+m("[^!'\"();\\\\]+?",i,o,s,c,"[^;]*?")+"*?)",d=new RegExp(a+":"+u+"(\\s*!important(?![-(w]))?\\s*(?:;\\s*|$)","ig"),p=new RegExp(m(i,o,s,"/\\*[^]*?\\*/"),"ig");function m(){return"(?:"+Array.prototype.join.call(arguments,"|")+")"}r.fn=function(e,t){if(e.elem&&e.hasAttr("style")){var r,i=e.attr("style").value,a=[],o={};for(i=i.replace(p,(function(e){return"/"==e[0]?"":"\\"==e[0]&&/[-g-z]/i.test(e[1])?e[1]:e})),d.lastIndex=0;r=d.exec(i);)t.keepImportant&&r[3]||a.push([r[1],r[2]]);a.length&&(a=a.filter((function(e){if(e[0]){var t=e[0].toLowerCase(),r=e[1];if(l.test(r)&&(r=r.slice(1,-1)),n.indexOf(t)>-1)return o[t]={name:t,value:r,local:t,prefix:""},!1}return!0})),Object.assign(e.attrs,o),a.length?e.attr("style").value=a.map((function(e){return e.join(":")})).join(";"):e.removeAttr("style"))}}},{"./_collections":261}],277:[function(e,t,r){"use strict";r.type="perItem",r.active=!0,r.description="collapses multiple transformations and optimizes it",r.params={convertToShorts:!0,floatPrecision:3,transformPrecision:5,matrixToTransform:!0,shortTranslate:!0,shortScale:!0,shortRotate:!0,removeUseless:!0,collapseIntoOne:!0,leadingZero:!0,negativeExtraSpace:!1};var n,i,a,o=e("../tools").cleanupOutData,s=e("./_transforms.js").transform2js,l=e("./_transforms.js").transformsMultiply,c=e("./_transforms.js").matrixToTransform;function u(e,t,r){var o=s(e.attr(t).value);(r=function(e,t){var r=e.reduce(d,[]),o=t.transformPrecision;t=Object.assign({},t),r.length&&(t.transformPrecision=Math.min(t.transformPrecision,Math.max.apply(Math,r.map(p))||t.transformPrecision),o=Math.max.apply(Math,r.map((function(e){return String(e).replace(/\D+/g,"").length}))));"degPrecision"in t||(t.degPrecision=Math.max(0,Math.min(t.floatPrecision,o-2)));return i=t.floatPrecision>=1&&t.floatPrecision<20?g.bind(this,t.floatPrecision):f,n=t.degPrecision>=1&&t.floatPrecision<20?g.bind(this,t.degPrecision):f,a=t.transformPrecision>=1&&t.floatPrecision<20?g.bind(this,t.transformPrecision):f,t}(o,r)).collapseIntoOne&&o.length>1&&(o=[l(o)]),r.convertToShorts?o=function(e,t){for(var r=0;r-1&&(1==e.data.length||"rotate"==e.name)&&!e.data[0]||"translate"==e.name&&!e.data[0]&&!e.data[1]||"scale"==e.name&&1==e.data[0]&&(e.data.length<2||1==e.data[1])||"matrix"==e.name&&1==e.data[0]&&1==e.data[3]&&!(e.data[1]||e.data[2]||e.data[4]||e.data[5]))}))),o.length?e.attr(t).value=m(o,r):e.removeAttr(t)}function d(e,t){return"matrix"==t.name?e.concat(t.data.slice(0,4)):e}function p(e){return(e=String(e)).slice(e.indexOf(".")).length-1}function m(e,t){var r="";return e.forEach((function(e){h(e),r+=(r&&" ")+e.name+"("+o(e.data,t)+")"})),r}function h(e){switch(e.name){case"translate":e.data=i(e.data);break;case"rotate":e.data=n(e.data.slice(0,1)).concat(i(e.data.slice(1)));break;case"skewX":case"skewY":e.data=n(e.data);break;case"scale":e.data=a(e.data);break;case"matrix":e.data=a(e.data.slice(0,4)).concat(i(e.data.slice(4)))}return e}function f(e){return e.map(Math.round)}function g(e,t){for(var r=t.length,n=+Math.pow(.1,e).toFixed(e);r--;)if(t[r].toFixed(e)!=t[r]){var i=+t[r].toFixed(e-1);t[r]=+Math.abs(i-t[r]).toFixed(e+1)>=n?+t[r].toFixed(e):i}return t}r.fn=function(e,t){e.elem&&(e.hasAttr("transform")&&u(e,"transform",t),e.hasAttr("gradientTransform")&&u(e,"gradientTransform",t),e.hasAttr("patternTransform")&&u(e,"patternTransform",t))}},{"../tools":314,"./_transforms.js":263}],278:[function(e,t,r){"use strict";r.type="full",r.active=!0,r.params={onlyMatchedOnce:!0,removeMatchedSelectors:!0,useMqs:["","screen"],usePseudos:[""]},r.description="inline styles (additional options)";var n=e("css-tree"),i=e("../css-tools");r.fn=function(e,t){var r=e.querySelectorAll("style");if(null===r)return e;var a=[],o=[];for(var s of r)if(!s.isEmpty()&&!s.closestElem("foreignObject")){var l=i.getCssStr(s),c={};try{c=n.parse(l,{parseValue:!1,parseCustomProperty:!1})}catch(e){continue}a.push({styleEl:s,cssAst:c}),o=o.concat(i.flattenToSelectors(c))}var u=i.filterByMqs(o,t.useMqs),d=i.filterByPseudos(u,t.usePseudos);i.cleanPseudos(d);var p,m,h=i.sortSelectors(d).reverse();for(p of h){var f=n.generate(p.item.data),g=null;try{g=e.querySelectorAll(f)}catch(e){if(e.constructor===SyntaxError)continue;throw e}null!==g&&(p.selectedEls=g)}for(p of h)if(p.selectedEls&&!(t.onlyMatchedOnce&&null!==p.selectedEls&&p.selectedEls.length>1)){for(m of p.selectedEls)null!==p.rule&&n.walk(p.rule,{visit:"Declaration",enter:function(e){var t=i.csstreeToStyleDeclaration(e);null!==m.style.getPropertyValue(t.name)&&m.style.getPropertyPriority(t.name)>=t.priority||m.style.setProperty(t.name,t.value,t.priority)}});t.removeMatchedSelectors&&null!==p.selectedEls&&p.selectedEls.length>0&&p.rule.prelude.children.remove(p.item)}if(!t.removeMatchedSelectors)return e;for(p of h)if(p.selectedEls&&!(t.onlyMatchedOnce&&null!==p.selectedEls&&p.selectedEls.length>1))for(m of p.selectedEls){var y=p.item.data.children.first();"ClassSelector"===y.type&&m.class.remove(y.name),void 0===m.class.item(0)&&m.removeAttr("class"),"IdSelector"===y.type&&m.removeAttr("id",y.name)}for(var b of a)if(n.walk(b.cssAst,{visit:"Rule",enter:function(e,t,r){("Atrule"===e.type&&null!==e.block&&e.block.children.isEmpty()||"Rule"===e.type&&e.prelude.children.isEmpty())&&r.remove(t)}}),b.cssAst.children.isEmpty()){var v=b.styleEl.parentNode;if(v.spliceContent(v.content.indexOf(b.styleEl),1),"defs"===v.elem&&0===v.content.length){var S=v.parentNode;S.spliceContent(S.content.indexOf(v),1)}}else i.setCssStr(b.styleEl,n.generate(b.cssAst));return e}},{"../css-tools":258,"css-tree":38}],279:[function(e,t,r){"use strict";r.type="perItem",r.active=!0,r.description="merges multiple paths in one if possible",r.params={collapseRepeated:!0,force:!1,leadingZero:!0,negativeExtraSpace:!0,noSpaceAfterFlags:!0};var n=e("./_path.js").path2js,i=e("./_path.js").js2path,a=e("./_path.js").intersects;r.fn=function(e,t){if(e.isElem()&&!e.isEmpty()){var r=null,o=null;e.content=e.content.filter((function(e){if(r&&r.isElem("path")&&r.isEmpty()&&r.hasAttr("d")&&e.isElem("path")&&e.isEmpty()&&e.hasAttr("d")){o||(o=Object.keys(r.attrs));var s=Object.keys(e.attrs),l=o.length==s.length&&s.every((function(t){return"d"==t||r.hasAttr(t)&&r.attr(t).value==e.attr(t).value})),c=n(r),u=n(e);if(l&&(t.force||!a(c,u)))return i(r,c.concat(u),t),!1}return r=e,o=null,!0}))}}},{"./_path.js":262}],280:[function(e,t,r){"use strict";r.type="full",r.active=!0,r.description="minifies styles and removes unused styles based on usage data",r.params={usage:{force:!1,ids:!0,classes:!0,tags:!0}};var n=e("csso");function i(e){var t={};for(var r in e)t[r]=e[r];return t}function a(e,t){return"usage"in e==!1||(!(!e.usage||t in e.usage!=!1)||Boolean(e.usage&&e.usage[t]))}r.fn=function(e,t){var r=i(t=t||{}),o=i(t),s=function(e){function t(e,r){for(var n=0;n")>=0||t.indexOf("<")>=0?"cdata":"text";e.content[0][i]=n.minify(t,r).css}else{var a=e.attr("style").value;e.attr("style").value=n.minifyBlock(a,o).css}})),e}},{csso:148}],281:[function(e,t,r){"use strict";r.type="perItemReverse",r.active=!0,r.description="moves elements attributes to the existing group wrapper";var n=e("./_collections").inheritableAttrs,i=e("./_collections.js").pathElems;r.fn=function(e){if(e.isElem("g")&&!e.isEmpty()&&e.content.length>1){var t={},r=!1,a=e.hasAttr("clip-path")||e.hasAttr("mask"),o=e.content.every((function(e){if(e.isElem()&&e.hasAttr()){if(e.hasAttr("class"))return!1;if(Object.keys(t).length){if(!(t=function(e,t){var r={};for(var i in e)t.hasOwnProperty(i)&&n.indexOf(i)>-1&&e[i].name===t[i].name&&e[i].value===t[i].value&&e[i].prefix===t[i].prefix&&e[i].local===t[i].local&&(r[i]=e[i]);return!!Object.keys(r).length&&r}(t,e.attrs)))return!1}else t=e.attrs;return!0}})),s=e.content.every((function(e){return e.isElem(i)}));o&&e.content.forEach((function(n){for(var i in t)(s||a)&&"transform"===i||(n.removeAttr(i),"transform"===i?r||(e.hasAttr("transform")?e.attr("transform").value+=" "+t[i].value:e.addAttr(t[i]),r=!0):e.addAttr(t[i]))}))}}},{"./_collections":261,"./_collections.js":261}],282:[function(e,t,r){"use strict";r.type="perItem",r.active=!0,r.description="moves some group attributes to the content elements";var n=e("./_collections.js"),i=n.pathElems.concat(["g","text"]),a=n.referencesProps;r.fn=function(e){e.isElem("g")&&e.hasAttr("transform")&&!e.isEmpty()&&!e.someAttr((function(e){return~a.indexOf(e.name)&&~e.value.indexOf("url(")}))&&e.content.every((function(e){return e.isElem(i)&&!e.hasAttr("id")}))&&(e.content.forEach((function(t){var r=e.attr("transform");t.hasAttr("transform")?t.attr("transform").value=r.value+" "+t.attr("transform").value:t.addAttr({name:r.name,local:r.local,prefix:r.prefix,value:r.value})})),e.removeAttr("transform"))}},{"./_collections.js":261}],283:[function(e,t,r){"use strict";r.type="perItem",r.active=!1,r.params={delim:"__",prefixIds:!0,prefixClassNames:!0},r.description="prefix IDs";var n=e("path"),i=e("css-tree"),a=e("unquote"),o=e("./_collections.js").referencesProps,s=/^#(.*)$/,l=null,c=function(e){return e.replace(/[\. ]/g,"_")},u=function(e){return e&&e.value&&e.value.length>0},d=function(e){var t,r=null!==(t=e.match(s))&&t[1];return!!r&&"#"+l(r)},p=function(e){if(u(e)){var t=d(e.value);t&&(e.value=t)}},m=function(e){if(u(e)){var t,r,n=(t=e.value,null!==(r=/url\((.*?)\)/gi.exec(t))&&r[1]);if(n){var i=d(n);i&&(e.value="url("+i+")")}}},h=function(e){if(u(e)){var t=e.value.split("; ").map((function(e){if((e=e.trim()).endsWith(".end")||e.endsWith(".start")){var t=e.split("."),r=t[0],n=t[1],i=d(`#${r}`);return i?`${i=i.slice(1)}.${n}`:e}return e}));e.value=t.join("; ")}};r.fn=function(e,t,r){if(r.multipassCount&&r.multipassCount>0)return e;var s,f="prefix";if(t.prefix)f="function"==typeof t.prefix?t.prefix(e,r):t.prefix;else if(!1===t.prefix)f=!1;else if(r&&r.path&&r.path.length>0){var g=n.basename(r.path);f=g}if(l=function(e){return c(!1===f?e:f+t.delim+e)},"style"===e.elem){if(e.isEmpty())return e;var y=e.content[0].text||e.content[0].cdata||[],b={};try{b=i.parse(y,{parseValue:!0,parseCustomProperty:!1})}catch(t){return console.warn("Warning: Parse error of styles of element, skipped. Error details: "+t),e}var v="";return i.walk(b,(function(e){if((t.prefixIds&&"IdSelector"===e.type||t.prefixClassNames&&"ClassSelector"===e.type)&&e.name)e.name=l(e.name);else if("Url"===e.type&&e.value.value&&e.value.value.length>0){if(!(v=d(a(e.value.value))))return;e.value.value=v}})),e.content[0].text=i.generate(b),e}if(!e.attrs)return e;for(var S of(t.prefixIds&&(s=e.attrs.id,u(s)&&(s.value=l(s.value))),t.prefixClassNames&&function(e){u(e)&&(e.value=e.value.split(/\s+/).map(l).join(" "))}(e.attrs.class),p(e.attrs.href),p(e.attrs["xlink:href"]),o))m(e.attrs[S]);return h(e.attrs.begin),h(e.attrs.end),e}},{"./_collections.js":261,"css-tree":38,path:224,unquote:251}],284:[function(e,t,r){"use strict";r.type="perItem",r.active=!1,r.description="removes attributes of elements that match a css selector",r.fn=function(e,t){(Array.isArray(t.selectors)?t.selectors:[t]).map((function(t){e.matches(t.selector)&&e.removeAttr(t.attributes)}))}},{}],285:[function(e,t,r){"use strict";r.type="perItem",r.active=!1,r.description="removes specified attributes",r.params={elemSeparator:":",preserveCurrentColor:!1,attrs:[]},r.fn=function(e,t){if(Array.isArray(t.attrs)||(t.attrs=[t.attrs]),e.isElem()){var r="string"==typeof t.elemSeparator?t.elemSeparator:":",n="boolean"==typeof t.preserveCurrentColor&&t.preserveCurrentColor;t.attrs.map((function(e){return-1===e.indexOf(r)?e=[".*",r,e,r,".*"].join(""):e.split(r).length<3&&(e=[e,r,".*"].join("")),e.split(r).map((function(e){return"*"===e&&(e=".*"),new RegExp(["^",e,"$"].join(""),"i")}))})).forEach((function(t){t[0].test(e.elem)&&e.eachAttr((function(r){var i=r.name,a=r.value;n&&"fill"==i&&"currentColor"==a||n&&"stroke"==i&&"currentColor"==a||t[1].test(i)&&t[2].test(r.value)&&e.removeAttr(i)}))}))}}},{}],286:[function(e,t,r){"use strict";r.type="perItem",r.active=!0,r.description="removes comments",r.fn=function(e){if(e.comment&&"!"!==e.comment.charAt(0))return!1}},{}],287:[function(e,t,r){"use strict";r.type="perItem",r.active=!0,r.params={removeAny:!0},r.description="removes ";var n=/^(Created with|Created using)/;r.fn=function(e,t){return!e.isElem("desc")||!(t.removeAny||e.isEmpty()||n.test(e.content[0].text))}},{}],288:[function(e,t,r){"use strict";r.type="perItem",r.active=!1,r.description="removes width and height in presence of viewBox (opposite to removeViewBox, disable it first)",r.fn=function(e){e.isElem("svg")&&(e.hasAttr("viewBox")?(e.removeAttr("width"),e.removeAttr("height")):e.hasAttr("width")&&e.hasAttr("height")&&!isNaN(Number(e.attr("width").value))&&!isNaN(Number(e.attr("height").value))&&(e.addAttr({name:"viewBox",value:"0 0 "+Number(e.attr("width").value)+" "+Number(e.attr("height").value),prefix:"",local:"viewBox"}),e.removeAttr("width"),e.removeAttr("height")))}},{}],289:[function(e,t,r){"use strict";r.type="perItem",r.active=!0,r.description="removes doctype declaration",r.fn=function(e){if(e.doctype)return!1}},{}],290:[function(e,t,r){"use strict";r.type="perItem",r.active=!0,r.description="removes editors namespaces, elements and attributes";var n=e("./_collections").editorNamespaces,i=[];r.params={additionalNamespaces:[]},r.fn=function(e,t){if(Array.isArray(t.additionalNamespaces)&&(n=n.concat(t.additionalNamespaces)),e.elem&&(e.isElem("svg")&&e.eachAttr((function(t){"xmlns"===t.prefix&&n.indexOf(t.value)>-1&&(i.push(t.local),e.removeAttr(t.name))})),e.eachAttr((function(t){i.indexOf(t.prefix)>-1&&e.removeAttr(t.name)})),i.indexOf(e.prefix)>-1))return!1}},{"./_collections":261}],291:[function(e,t,r){"use strict";r.type="perItem",r.active=!1,r.description="removes arbitrary elements by ID or className (disabled by default)",r.params={id:[],class:[]},r.fn=function(e,t){var r,n;if(["id","class"].forEach((function(e){Array.isArray(t[e])||(t[e]=[t[e]])})),e.isElem()){if(r=e.attr("id"))return-1===t.id.indexOf(r.value);if(n=e.attr("class"))return!new RegExp(t.class.join("|")).test(n.value)}}},{}],292:[function(e,t,r){"use strict";r.type="perItem",r.active=!0,r.description="removes empty attributes",r.fn=function(e){e.elem&&e.eachAttr((function(t){""===t.value&&e.removeAttr(t.name)}))}},{}],293:[function(e,t,r){"use strict";r.type="perItemReverse",r.active=!0,r.description="removes empty container elements";var n=e("./_collections").elemsGroups.container;r.fn=function(e){return!(e.isElem(n)&&!e.isElem("svg")&&e.isEmpty()&&(!e.isElem("pattern")||!e.hasAttrLocal("href")))}},{"./_collections":261}],294:[function(e,t,r){"use strict";r.type="perItem",r.active=!0,r.description="removes empty elements",r.params={text:!0,tspan:!0,tref:!0},r.fn=function(e,t){return!(t.text&&e.isElem("text")&&e.isEmpty())&&(!(t.tspan&&e.isElem("tspan")&&e.isEmpty())&&(!(t.tref&&e.isElem("tref")&&!e.hasAttrLocal("href"))&&void 0))}},{}],295:[function(e,t,r){"use strict";r.type="perItem",r.active=!0,r.description="removes hidden elements (zero sized, with absent attributes)",r.params={isHidden:!0,displayNone:!0,opacity0:!0,circleR0:!0,ellipseRX0:!0,ellipseRY0:!0,rectWidth0:!0,rectHeight0:!0,patternWidth0:!0,patternHeight0:!0,imageWidth0:!0,imageHeight0:!0,pathEmptyD:!0,polylineEmptyPoints:!0,polygonEmptyPoints:!0};var n=/M\s*(?:[-+]?(?:\d*\.\d+|\d+(?:\.|(?!\.)))([eE][-+]?\d+)?(?!\d)\s*,?\s*){2}\D*\d/i;r.fn=function(e,t){if(e.elem){if(t.isHidden&&e.hasAttr("visibility","hidden"))return!1;if(t.displayNone&&e.hasAttr("display","none"))return!1;if(t.opacity0&&e.hasAttr("opacity","0"))return!1;if(t.circleR0&&e.isElem("circle")&&e.isEmpty()&&e.hasAttr("r","0"))return!1;if(t.ellipseRX0&&e.isElem("ellipse")&&e.isEmpty()&&e.hasAttr("rx","0"))return!1;if(t.ellipseRY0&&e.isElem("ellipse")&&e.isEmpty()&&e.hasAttr("ry","0"))return!1;if(t.rectWidth0&&e.isElem("rect")&&e.isEmpty()&&e.hasAttr("width","0"))return!1;if(t.rectHeight0&&t.rectWidth0&&e.isElem("rect")&&e.isEmpty()&&e.hasAttr("height","0"))return!1;if(t.patternWidth0&&e.isElem("pattern")&&e.hasAttr("width","0"))return!1;if(t.patternHeight0&&e.isElem("pattern")&&e.hasAttr("height","0"))return!1;if(t.imageWidth0&&e.isElem("image")&&e.hasAttr("width","0"))return!1;if(t.imageHeight0&&e.isElem("image")&&e.hasAttr("height","0"))return!1;if(t.pathEmptyD&&e.isElem("path")&&(!e.hasAttr("d")||!n.test(e.attr("d").value)))return!1;if(t.polylineEmptyPoints&&e.isElem("polyline")&&!e.hasAttr("points"))return!1;if(t.polygonEmptyPoints&&e.isElem("polygon")&&!e.hasAttr("points"))return!1}}},{}],296:[function(e,t,r){"use strict";r.type="perItem",r.active=!0,r.description="removes ",r.fn=function(e){return!e.isElem("metadata")}},{}],297:[function(e,t,r){"use strict";r.type="perItem",r.active=!0,r.description="removes non-inheritable group’s presentational attributes";var n=e("./_collections").inheritableAttrs,i=e("./_collections").attrsGroups,a=e("./_collections").presentationNonInheritableGroupAttrs;r.fn=function(e){e.isElem("g")&&e.eachAttr((function(t){!~i.presentation.indexOf(t.name)||~n.indexOf(t.name)||~a.indexOf(t.name)||e.removeAttr(t.name)}))}},{"./_collections":261}],298:[function(e,t,r){"use strict";r.type="perItem",r.active=!1,r.description="removes elements that are drawn outside of the viewbox (disabled by default)";var n,i,a=e("../tools"),o=e("./_path.js"),s=o.intersects,l=o.path2js;function c(e){return e.hasAttr("transform")||e.parentNode&&c(e.parentNode)}r.fn=function(e){if(e.isElem("path")&&e.hasAttr("d")&&void 0!==n){if(c(e)||function(e){var t,r=/M\s*(-?\d*\.?\d+)(?!\d)\s*(-?\d*\.?\d+)/g;for(;null!==(t=r.exec(e));)if(t[1]>=n.left&&t[1]<=n.right&&t[2]>=n.top&&t[2]<=n.bottom)return!0;return!1}(e.attr("d").value))return!0;var t=l(e);return 2===t.length&&(t=JSON.parse(JSON.stringify(t))).push({instruction:"z"}),s(i,t)}return e.isElem("svg")&&function(e){var t="";e.hasAttr("viewBox")?t=e.attr("viewBox").value:e.hasAttr("height")&&e.hasAttr("width")&&(t="0 0 "+e.attr("width").value+" "+e.attr("height").value);t=t.replace(/[,+]|px/g," ").replace(/\s+/g," ").replace(/^\s*|\s*$/g,"");var r=/^(-?\d*\.?\d+) (-?\d*\.?\d+) (\d*\.?\d+) (\d*\.?\d+)$/.exec(t);if(!r)return;n={left:parseFloat(r[1]),top:parseFloat(r[2]),right:parseFloat(r[1])+parseFloat(r[3]),bottom:parseFloat(r[2])+parseFloat(r[4])};var o=a.createContentItem({elem:"path",prefix:"",local:"path"});o.addAttr({name:"d",prefix:"",local:"d",value:"M"+r[1]+" "+r[2]+"h"+r[3]+"v"+r[4]+"H"+r[1]+"z"}),i=l(o)}(e),!0}},{"../tools":314,"./_path.js":262}],299:[function(e,t,r){"use strict";r.type="perItem",r.active=!1,r.description="removes raster images (disabled by default)",r.fn=function(e){if(e.isElem("image")&&e.hasAttrLocal("href",/(\.|image\/)(jpg|png|gif)/))return!1}},{}],300:[function(e,t,r){"use strict";r.type="perItem",r.active=!1,r.description="removes