From 2827efc88f3d20c24b153834df877e1261843b73 Mon Sep 17 00:00:00 2001 From: jfh Date: Thu, 27 Aug 2020 00:09:55 +0200 Subject: [PATCH] add xml as import to allow roller to include in the build --- dist/common/browser.js | 285 + dist/common/jQuery.attr.js | 79 + dist/common/layer.js | 222 + dist/common/math.js | 222 + dist/common/namespaces.js | 33 + dist/common/svgpathseg.js | 972 + dist/common/svgtransformlist.js | 397 + dist/common/units.js | 313 + dist/common/utilities.js | 1363 + dist/editor/browser-not-supported.html | 54 + dist/editor/embedapi.html | 17 + dist/editor/embedapi.js | 395 + dist/editor/extensions/ext-arrows.js | 2006 + dist/editor/extensions/ext-arrows.js.map | 1 + dist/editor/extensions/ext-closepath.js | 4090 ++ dist/editor/extensions/ext-closepath.js.map | 1 + dist/editor/extensions/ext-connector.js | 2300 + dist/editor/extensions/ext-connector.js.map | 1 + dist/editor/extensions/ext-eyedropper.js | 1804 + dist/editor/extensions/ext-eyedropper.js.map | 1 + dist/editor/extensions/ext-foreignobject.js | 1965 + .../extensions/ext-foreignobject.js.map | 1 + dist/editor/extensions/ext-grid.js | 1824 + dist/editor/extensions/ext-grid.js.map | 1 + dist/editor/extensions/ext-helloworld.js | 1757 + dist/editor/extensions/ext-helloworld.js.map | 1 + dist/editor/extensions/ext-imagelib.js | 2170 + dist/editor/extensions/ext-imagelib.js.map | 1 + dist/editor/extensions/ext-imagelib.xml | 14 + .../editor/extensions/ext-locale/arrows/en.js | 21 + .../editor/extensions/ext-locale/arrows/fr.js | 21 + .../extensions/ext-locale/arrows/zh_CN.js | 21 + .../extensions/ext-locale/closepath/en.js | 13 + .../extensions/ext-locale/closepath/zh_CN.js | 13 + .../extensions/ext-locale/connector/en.js | 13 + .../extensions/ext-locale/connector/fr.js | 13 + .../extensions/ext-locale/connector/zh_CN.js | 13 + .../extensions/ext-locale/eyedropper/en.js | 11 + .../extensions/ext-locale/eyedropper/zh_CN.js | 11 + .../extensions/ext-locale/foreignobject/en.js | 27 + .../ext-locale/foreignobject/zh_CN.js | 27 + dist/editor/extensions/ext-locale/grid/en.js | 10 + .../extensions/ext-locale/grid/zh_CN.js | 10 + .../extensions/ext-locale/helloworld/en.js | 11 + .../extensions/ext-locale/helloworld/zh_CN.js | 11 + .../extensions/ext-locale/imagelib/de.js | 35 + .../extensions/ext-locale/imagelib/en.js | 40 + .../extensions/ext-locale/imagelib/fr.js | 35 + .../extensions/ext-locale/imagelib/pl.js | 35 + .../extensions/ext-locale/imagelib/pt_BR.js | 35 + .../extensions/ext-locale/imagelib/ro.js | 35 + .../extensions/ext-locale/imagelib/sk.js | 35 + .../extensions/ext-locale/imagelib/sl.js | 35 + .../extensions/ext-locale/imagelib/zh_CN.js | 35 + .../extensions/ext-locale/markers/en.js | 48 + .../extensions/ext-locale/markers/zh_CN.js | 48 + .../extensions/ext-locale/mathjax/en.js | 10 + .../extensions/ext-locale/mathjax/zh_CN.js | 10 + .../extensions/ext-locale/panning/en.js | 10 + .../extensions/ext-locale/panning/zh_CN.js | 10 + .../extensions/ext-locale/placemark/en.js | 42 + .../extensions/ext-locale/polygon/en.js | 16 + .../extensions/ext-locale/polygon/zh_CN.js | 16 + .../ext-locale/server_moinsave/en.js | 6 + .../ext-locale/server_moinsave/zh_CN.js | 6 + .../ext-locale/server_opensave/en.js | 6 + .../ext-locale/server_opensave/zh_CN.js | 6 + .../editor/extensions/ext-locale/shapes/en.js | 26 + .../editor/extensions/ext-locale/shapes/fr.js | 26 + .../extensions/ext-locale/shapes/zh_CN.js | 26 + dist/editor/extensions/ext-locale/star/en.js | 24 + .../extensions/ext-locale/star/zh_CN.js | 24 + .../extensions/ext-locale/storage/de.js | 16 + .../extensions/ext-locale/storage/en.js | 16 + .../extensions/ext-locale/storage/fr.js | 16 + .../extensions/ext-locale/storage/zh_CN.js | 13 + .../extensions/ext-locale/webappfind/en.js | 10 + .../extensions/ext-locale/webappfind/zh_CN.js | 10 + dist/editor/extensions/ext-markers.js | 2343 + dist/editor/extensions/ext-markers.js.map | 1 + dist/editor/extensions/ext-mathjax.js | 1914 + dist/editor/extensions/ext-mathjax.js.map | 1 + dist/editor/extensions/ext-overview_window.js | 149 + .../extensions/ext-overview_window.js.map | 1 + dist/editor/extensions/ext-panning.js | 1720 + dist/editor/extensions/ext-panning.js.map | 1 + dist/editor/extensions/ext-panning.xml | 6 + dist/editor/extensions/ext-php_savefile.js | 35 + .../editor/extensions/ext-php_savefile.js.map | 1 + dist/editor/extensions/ext-placemark.js | 2276 + dist/editor/extensions/ext-placemark.js.map | 1 + dist/editor/extensions/ext-polygon.js | 1928 + dist/editor/extensions/ext-polygon.js.map | 1 + dist/editor/extensions/ext-server_moinsave.js | 6626 ++ .../extensions/ext-server_moinsave.js.map | 1 + dist/editor/extensions/ext-server_opensave.js | 6874 ++ .../extensions/ext-server_opensave.js.map | 1 + dist/editor/extensions/ext-shapes.js | 1987 + dist/editor/extensions/ext-shapes.js.map | 1 + dist/editor/extensions/ext-shapes.xml | 10 + dist/editor/extensions/ext-star.js | 1897 + dist/editor/extensions/ext-star.js.map | 1 + dist/editor/extensions/ext-storage.js | 1996 + dist/editor/extensions/ext-storage.js.map | 1 + dist/editor/extensions/ext-webappfind.js | 1786 + dist/editor/extensions/ext-webappfind.js.map | 1 + .../extensions/ext-xdomain-messaging.js | 1709 + .../extensions/ext-xdomain-messaging.js.map | 1 + dist/editor/extensions/eyedropper-icon.xml | 34 + .../editor/extensions/foreignobject-icons.xml | 96 + dist/editor/extensions/grid-icon.xml | 30 + dist/editor/extensions/markers-icons.xml | 115 + dist/editor/extensions/polygon-icons.svg | 14 + dist/editor/extensions/star-icons.svg | 14 + dist/editor/images/README.txt | 60 + dist/editor/images/add_subpath.png | Bin 0 -> 35830 bytes dist/editor/images/align-bottom.png | Bin 0 -> 161 bytes dist/editor/images/align-bottom.svg | 277 + dist/editor/images/align-center.png | Bin 0 -> 221 bytes dist/editor/images/align-center.svg | 252 + dist/editor/images/align-left.png | Bin 0 -> 175 bytes dist/editor/images/align-left.svg | 235 + dist/editor/images/align-middle.png | Bin 0 -> 194 bytes dist/editor/images/align-middle.svg | 250 + dist/editor/images/align-right.png | Bin 0 -> 173 bytes dist/editor/images/align-right.svg | 233 + dist/editor/images/align-top.png | Bin 0 -> 165 bytes dist/editor/images/align-top.svg | 233 + dist/editor/images/align.png | Bin 0 -> 149 bytes dist/editor/images/angle.png | Bin 0 -> 487 bytes dist/editor/images/arrow_right.png | Bin 0 -> 2133 bytes dist/editor/images/arrow_right_big.png | Bin 0 -> 2138 bytes dist/editor/images/blur.png | Bin 0 -> 8270 bytes dist/editor/images/bold.png | Bin 0 -> 195 bytes dist/editor/images/c_radius.png | Bin 0 -> 308 bytes dist/editor/images/cancel.png | Bin 0 -> 1143 bytes dist/editor/images/circle.png | Bin 0 -> 907 bytes dist/editor/images/clear.png | Bin 0 -> 610 bytes dist/editor/images/clone.png | Bin 0 -> 597 bytes dist/editor/images/closepath.png | Bin 0 -> 8036 bytes dist/editor/images/config.png | Bin 0 -> 549 bytes dist/editor/images/config.svg | 1 + dist/editor/images/conn.svg | 29 + dist/editor/images/context_menu.png | Bin 0 -> 506 bytes dist/editor/images/copy.png | Bin 0 -> 637 bytes dist/editor/images/cut.png | Bin 0 -> 893 bytes dist/editor/images/delete.png | Bin 0 -> 390 bytes dist/editor/images/document-properties.png | Bin 0 -> 514 bytes dist/editor/images/dropdown.gif | Bin 0 -> 49 bytes dist/editor/images/ellipse.png | Bin 0 -> 733 bytes dist/editor/images/export.png | Bin 0 -> 771 bytes dist/editor/images/eye.png | Bin 0 -> 665 bytes dist/editor/images/fhpath.png | Bin 0 -> 1082 bytes dist/editor/images/fill.png | Bin 0 -> 644 bytes dist/editor/images/flyouth.png | Bin 0 -> 99 bytes dist/editor/images/flyup.gif | Bin 0 -> 48 bytes dist/editor/images/fontsize.png | Bin 0 -> 474 bytes dist/editor/images/freehand-circle.png | Bin 0 -> 1203 bytes dist/editor/images/freehand-square.png | Bin 0 -> 1021 bytes dist/editor/images/freehand-square.svg | 16 + dist/editor/images/globe_link.png | Bin 0 -> 5630 bytes dist/editor/images/go-down.png | Bin 0 -> 551 bytes dist/editor/images/go-up.png | Bin 0 -> 559 bytes dist/editor/images/group_elements.png | Bin 0 -> 398 bytes dist/editor/images/height.png | Bin 0 -> 247 bytes dist/editor/images/image.png | Bin 0 -> 799 bytes dist/editor/images/import.png | Bin 0 -> 727 bytes dist/editor/images/italic.png | Bin 0 -> 157 bytes dist/editor/images/line.png | Bin 0 -> 898 bytes dist/editor/images/linecap_butt.png | Bin 0 -> 1968 bytes dist/editor/images/linecap_round.png | Bin 0 -> 2828 bytes dist/editor/images/linecap_square.png | Bin 0 -> 1984 bytes dist/editor/images/linejoin_bevel.png | Bin 0 -> 2438 bytes dist/editor/images/linejoin_miter.png | Bin 0 -> 2367 bytes dist/editor/images/linejoin_round.png | Bin 0 -> 2437 bytes dist/editor/images/link_controls.png | Bin 0 -> 542 bytes dist/editor/images/logo.png | Bin 0 -> 3281 bytes dist/editor/images/logo.svg | 32 + dist/editor/images/move_bottom.png | Bin 0 -> 664 bytes dist/editor/images/move_top.png | Bin 0 -> 530 bytes dist/editor/images/no_color.png | Bin 0 -> 156 bytes dist/editor/images/node_clone.png | Bin 0 -> 526 bytes dist/editor/images/node_delete.png | Bin 0 -> 557 bytes dist/editor/images/none.png | Bin 0 -> 120 bytes dist/editor/images/opacity.png | Bin 0 -> 511 bytes dist/editor/images/open.png | Bin 0 -> 795 bytes dist/editor/images/openpath.png | Bin 0 -> 7955 bytes dist/editor/images/paste.png | Bin 0 -> 698 bytes dist/editor/images/path.png | Bin 0 -> 788 bytes dist/editor/images/polygon.png | Bin 0 -> 922 bytes dist/editor/images/polygon.svg | 76 + dist/editor/images/rect.png | Bin 0 -> 379 bytes dist/editor/images/redo.png | Bin 0 -> 656 bytes dist/editor/images/reorient.png | Bin 0 -> 646 bytes dist/editor/images/rotate.png | Bin 0 -> 694 bytes dist/editor/images/save.png | Bin 0 -> 825 bytes dist/editor/images/select.png | Bin 0 -> 389 bytes dist/editor/images/select_node.png | Bin 0 -> 731 bytes dist/editor/images/sep.png | Bin 0 -> 71 bytes dist/editor/images/shape_group_elements.png | Bin 0 -> 476 bytes dist/editor/images/shape_ungroup.png | Bin 0 -> 575 bytes dist/editor/images/source.png | Bin 0 -> 893 bytes dist/editor/images/spinbtn_updn_big.png | Bin 0 -> 1240 bytes dist/editor/images/square.png | Bin 0 -> 328 bytes dist/editor/images/stroke.png | Bin 0 -> 174 bytes dist/editor/images/svg_edit_icons.svg | 1035 + dist/editor/images/svg_edit_icons.svgz | Bin 0 -> 5493 bytes dist/editor/images/text.png | Bin 0 -> 600 bytes dist/editor/images/text.svg | 157 + dist/editor/images/to_path.png | Bin 0 -> 938 bytes dist/editor/images/undo.png | Bin 0 -> 837 bytes dist/editor/images/unlink_use.png | Bin 0 -> 3895 bytes dist/editor/images/view-refresh.png | Bin 0 -> 727 bytes dist/editor/images/warning.png | Bin 0 -> 758 bytes dist/editor/images/width.png | Bin 0 -> 278 bytes dist/editor/images/wireframe.png | Bin 0 -> 268 bytes dist/editor/images/zoom.png | Bin 0 -> 1032 bytes dist/editor/index.html | 773 + dist/editor/index.js | 54696 +++++++++++++++ dist/editor/index.js.map | 1 + dist/editor/jgraduate/LICENSE-Apache2.0.txt | 202 + dist/editor/jgraduate/README | 3 + dist/editor/jgraduate/css/jGraduate.css | 351 + dist/editor/jgraduate/css/jPicker.css | 1 + dist/editor/jgraduate/images/AlphaBar.png | Bin 0 -> 1699 bytes dist/editor/jgraduate/images/Bars.png | Bin 0 -> 265 bytes dist/editor/jgraduate/images/Maps.png | Bin 0 -> 61784 bytes dist/editor/jgraduate/images/NoColor.png | Bin 0 -> 473 bytes dist/editor/jgraduate/images/bar-opacity.png | Bin 0 -> 80 bytes dist/editor/jgraduate/images/map-opacity.png | Bin 0 -> 81 bytes dist/editor/jgraduate/images/mappoint.gif | Bin 0 -> 93 bytes dist/editor/jgraduate/images/mappoint_c.png | Bin 0 -> 143 bytes dist/editor/jgraduate/images/mappoint_f.png | Bin 0 -> 147 bytes dist/editor/jgraduate/images/picker.gif | Bin 0 -> 146 bytes .../jgraduate/images/preview-opacity.png | Bin 0 -> 80 bytes dist/editor/jgraduate/images/rangearrows.gif | Bin 0 -> 76 bytes dist/editor/jgraduate/images/rangearrows2.gif | Bin 0 -> 93 bytes dist/editor/jgraduate/jQuery.jGraduate.js | 1327 + dist/editor/jgraduate/jQuery.jPicker.js | 2512 + .../jquery-ui/jquery-ui-1.8.17.custom.min.js | 54 + dist/editor/jquery.min.js | 4 + dist/editor/locale/lang.af.js | 220 + dist/editor/locale/lang.ar.js | 220 + dist/editor/locale/lang.az.js | 220 + dist/editor/locale/lang.be.js | 220 + dist/editor/locale/lang.bg.js | 220 + dist/editor/locale/lang.ca.js | 220 + dist/editor/locale/lang.cs.js | 220 + dist/editor/locale/lang.cy.js | 220 + dist/editor/locale/lang.da.js | 220 + dist/editor/locale/lang.de.js | 220 + dist/editor/locale/lang.el.js | 220 + dist/editor/locale/lang.en.js | 220 + dist/editor/locale/lang.es.js | 220 + dist/editor/locale/lang.et.js | 220 + dist/editor/locale/lang.fa.js | 220 + dist/editor/locale/lang.fi.js | 220 + dist/editor/locale/lang.fr.js | 220 + dist/editor/locale/lang.fy.js | 220 + dist/editor/locale/lang.ga.js | 220 + dist/editor/locale/lang.gl.js | 220 + dist/editor/locale/lang.he.js | 220 + dist/editor/locale/lang.hi.js | 220 + dist/editor/locale/lang.hr.js | 220 + dist/editor/locale/lang.hu.js | 220 + dist/editor/locale/lang.hy.js | 220 + dist/editor/locale/lang.id.js | 220 + dist/editor/locale/lang.is.js | 220 + dist/editor/locale/lang.it.js | 220 + dist/editor/locale/lang.ja.js | 220 + dist/editor/locale/lang.ko.js | 220 + dist/editor/locale/lang.lt.js | 220 + dist/editor/locale/lang.lv.js | 220 + dist/editor/locale/lang.mk.js | 220 + dist/editor/locale/lang.ms.js | 220 + dist/editor/locale/lang.mt.js | 220 + dist/editor/locale/lang.nl.js | 220 + dist/editor/locale/lang.no.js | 220 + dist/editor/locale/lang.pl.js | 221 + dist/editor/locale/lang.pt-BR.js | 219 + dist/editor/locale/lang.pt-PT.js | 220 + dist/editor/locale/lang.ro.js | 219 + dist/editor/locale/lang.ru.js | 220 + dist/editor/locale/lang.sk.js | 220 + dist/editor/locale/lang.sl.js | 219 + dist/editor/locale/lang.sq.js | 220 + dist/editor/locale/lang.sr.js | 220 + dist/editor/locale/lang.sv.js | 220 + dist/editor/locale/lang.sw.js | 220 + dist/editor/locale/lang.test.js | 220 + dist/editor/locale/lang.th.js | 220 + dist/editor/locale/lang.tl.js | 220 + dist/editor/locale/lang.tr.js | 220 + dist/editor/locale/lang.uk.js | 220 + dist/editor/locale/lang.vi.js | 220 + dist/editor/locale/lang.yi.js | 220 + dist/editor/locale/lang.zh-CN.js | 220 + dist/editor/locale/lang.zh-HK.js | 220 + dist/editor/locale/lang.zh-TW.js | 220 + dist/editor/redirect-on-lacking-support.js | 5 + dist/editor/redirect-on-no-module-support.js | 8 + dist/editor/spinbtn/jQuery.SpinButton.css | 41 + dist/editor/spinbtn/jQuery.SpinButton.js | 328 + dist/editor/spinbtn/spinbtn_updn.png | Bin 0 -> 572 bytes dist/editor/svgedit.css | 1462 + dist/editor/system/browser-not-supported.html | 54 + dist/editor/system/embedapi.html | 17 + dist/editor/system/embedapi.js | 395 + dist/editor/system/extensions/ext-arrows.js | 2012 + .../editor/system/extensions/ext-closepath.js | 4096 ++ .../editor/system/extensions/ext-connector.js | 2306 + .../system/extensions/ext-eyedropper.js | 1810 + .../system/extensions/ext-foreignobject.js | 1971 + dist/editor/system/extensions/ext-grid.js | 1830 + .../system/extensions/ext-helloworld.js | 1763 + dist/editor/system/extensions/ext-imagelib.js | 2176 + .../editor/system/extensions/ext-imagelib.xml | 14 + .../system/extensions/ext-locale/arrows/en.js | 28 + .../system/extensions/ext-locale/arrows/fr.js | 28 + .../extensions/ext-locale/arrows/zh_CN.js | 28 + .../extensions/ext-locale/closepath/en.js | 20 + .../extensions/ext-locale/closepath/zh_CN.js | 20 + .../extensions/ext-locale/connector/en.js | 20 + .../extensions/ext-locale/connector/fr.js | 20 + .../extensions/ext-locale/connector/zh_CN.js | 20 + .../extensions/ext-locale/eyedropper/en.js | 18 + .../extensions/ext-locale/eyedropper/zh_CN.js | 18 + .../extensions/ext-locale/foreignobject/en.js | 34 + .../ext-locale/foreignobject/zh_CN.js | 34 + .../system/extensions/ext-locale/grid/en.js | 17 + .../extensions/ext-locale/grid/zh_CN.js | 17 + .../extensions/ext-locale/helloworld/en.js | 18 + .../extensions/ext-locale/helloworld/zh_CN.js | 18 + .../extensions/ext-locale/imagelib/de.js | 42 + .../extensions/ext-locale/imagelib/en.js | 47 + .../extensions/ext-locale/imagelib/fr.js | 42 + .../extensions/ext-locale/imagelib/pl.js | 42 + .../extensions/ext-locale/imagelib/pt_BR.js | 42 + .../extensions/ext-locale/imagelib/ro.js | 42 + .../extensions/ext-locale/imagelib/sk.js | 42 + .../extensions/ext-locale/imagelib/sl.js | 42 + .../extensions/ext-locale/imagelib/zh_CN.js | 42 + .../extensions/ext-locale/markers/en.js | 55 + .../extensions/ext-locale/markers/zh_CN.js | 55 + .../extensions/ext-locale/mathjax/en.js | 17 + .../extensions/ext-locale/mathjax/zh_CN.js | 17 + .../extensions/ext-locale/panning/en.js | 17 + .../extensions/ext-locale/panning/zh_CN.js | 17 + .../extensions/ext-locale/placemark/en.js | 49 + .../extensions/ext-locale/polygon/en.js | 23 + .../extensions/ext-locale/polygon/zh_CN.js | 23 + .../ext-locale/server_moinsave/en.js | 13 + .../ext-locale/server_moinsave/zh_CN.js | 13 + .../ext-locale/server_opensave/en.js | 13 + .../ext-locale/server_opensave/zh_CN.js | 13 + .../system/extensions/ext-locale/shapes/en.js | 33 + .../system/extensions/ext-locale/shapes/fr.js | 33 + .../extensions/ext-locale/shapes/zh_CN.js | 33 + .../system/extensions/ext-locale/star/en.js | 31 + .../extensions/ext-locale/star/zh_CN.js | 31 + .../extensions/ext-locale/storage/de.js | 23 + .../extensions/ext-locale/storage/en.js | 23 + .../extensions/ext-locale/storage/fr.js | 23 + .../extensions/ext-locale/storage/zh_CN.js | 20 + .../extensions/ext-locale/webappfind/en.js | 17 + .../extensions/ext-locale/webappfind/zh_CN.js | 17 + dist/editor/system/extensions/ext-markers.js | 2349 + dist/editor/system/extensions/ext-mathjax.js | 1920 + .../system/extensions/ext-overview_window.js | 155 + dist/editor/system/extensions/ext-panning.js | 1726 + dist/editor/system/extensions/ext-panning.xml | 6 + .../system/extensions/ext-php_savefile.js | 41 + .../editor/system/extensions/ext-placemark.js | 2282 + dist/editor/system/extensions/ext-polygon.js | 1934 + .../system/extensions/ext-server_moinsave.js | 6632 ++ .../system/extensions/ext-server_opensave.js | 6880 ++ dist/editor/system/extensions/ext-shapes.js | 1993 + dist/editor/system/extensions/ext-shapes.xml | 10 + dist/editor/system/extensions/ext-star.js | 1903 + dist/editor/system/extensions/ext-storage.js | 2002 + .../system/extensions/ext-webappfind.js | 1792 + .../extensions/ext-xdomain-messaging.js | 1715 + .../system/extensions/eyedropper-icon.xml | 34 + .../system/extensions/foreignobject-icons.xml | 96 + dist/editor/system/extensions/grid-icon.xml | 30 + .../system/extensions/markers-icons.xml | 115 + .../system/extensions/polygon-icons.svg | 14 + dist/editor/system/extensions/star-icons.svg | 14 + dist/editor/system/images/README.txt | 60 + dist/editor/system/images/add_subpath.png | Bin 0 -> 35830 bytes dist/editor/system/images/align-bottom.png | Bin 0 -> 161 bytes dist/editor/system/images/align-bottom.svg | 277 + dist/editor/system/images/align-center.png | Bin 0 -> 221 bytes dist/editor/system/images/align-center.svg | 252 + dist/editor/system/images/align-left.png | Bin 0 -> 175 bytes dist/editor/system/images/align-left.svg | 235 + dist/editor/system/images/align-middle.png | Bin 0 -> 194 bytes dist/editor/system/images/align-middle.svg | 250 + dist/editor/system/images/align-right.png | Bin 0 -> 173 bytes dist/editor/system/images/align-right.svg | 233 + dist/editor/system/images/align-top.png | Bin 0 -> 165 bytes dist/editor/system/images/align-top.svg | 233 + dist/editor/system/images/align.png | Bin 0 -> 149 bytes dist/editor/system/images/angle.png | Bin 0 -> 487 bytes dist/editor/system/images/arrow_right.png | Bin 0 -> 2133 bytes dist/editor/system/images/arrow_right_big.png | Bin 0 -> 2138 bytes dist/editor/system/images/blur.png | Bin 0 -> 8270 bytes dist/editor/system/images/bold.png | Bin 0 -> 195 bytes dist/editor/system/images/c_radius.png | Bin 0 -> 308 bytes dist/editor/system/images/cancel.png | Bin 0 -> 1143 bytes dist/editor/system/images/circle.png | Bin 0 -> 907 bytes dist/editor/system/images/clear.png | Bin 0 -> 610 bytes dist/editor/system/images/clone.png | Bin 0 -> 597 bytes dist/editor/system/images/closepath.png | Bin 0 -> 8036 bytes dist/editor/system/images/config.png | Bin 0 -> 549 bytes dist/editor/system/images/config.svg | 1 + dist/editor/system/images/conn.svg | 29 + dist/editor/system/images/context_menu.png | Bin 0 -> 506 bytes dist/editor/system/images/copy.png | Bin 0 -> 637 bytes dist/editor/system/images/cut.png | Bin 0 -> 893 bytes dist/editor/system/images/delete.png | Bin 0 -> 390 bytes .../system/images/document-properties.png | Bin 0 -> 514 bytes dist/editor/system/images/dropdown.gif | Bin 0 -> 49 bytes dist/editor/system/images/ellipse.png | Bin 0 -> 733 bytes dist/editor/system/images/export.png | Bin 0 -> 771 bytes dist/editor/system/images/eye.png | Bin 0 -> 665 bytes dist/editor/system/images/fhpath.png | Bin 0 -> 1082 bytes dist/editor/system/images/fill.png | Bin 0 -> 644 bytes dist/editor/system/images/flyouth.png | Bin 0 -> 99 bytes dist/editor/system/images/flyup.gif | Bin 0 -> 48 bytes dist/editor/system/images/fontsize.png | Bin 0 -> 474 bytes dist/editor/system/images/freehand-circle.png | Bin 0 -> 1203 bytes dist/editor/system/images/freehand-square.png | Bin 0 -> 1021 bytes dist/editor/system/images/freehand-square.svg | 16 + dist/editor/system/images/globe_link.png | Bin 0 -> 5630 bytes dist/editor/system/images/go-down.png | Bin 0 -> 551 bytes dist/editor/system/images/go-up.png | Bin 0 -> 559 bytes dist/editor/system/images/group_elements.png | Bin 0 -> 398 bytes dist/editor/system/images/height.png | Bin 0 -> 247 bytes dist/editor/system/images/image.png | Bin 0 -> 799 bytes dist/editor/system/images/import.png | Bin 0 -> 727 bytes dist/editor/system/images/italic.png | Bin 0 -> 157 bytes dist/editor/system/images/line.png | Bin 0 -> 898 bytes dist/editor/system/images/linecap_butt.png | Bin 0 -> 1968 bytes dist/editor/system/images/linecap_round.png | Bin 0 -> 2828 bytes dist/editor/system/images/linecap_square.png | Bin 0 -> 1984 bytes dist/editor/system/images/linejoin_bevel.png | Bin 0 -> 2438 bytes dist/editor/system/images/linejoin_miter.png | Bin 0 -> 2367 bytes dist/editor/system/images/linejoin_round.png | Bin 0 -> 2437 bytes dist/editor/system/images/link_controls.png | Bin 0 -> 542 bytes dist/editor/system/images/logo.png | Bin 0 -> 3281 bytes dist/editor/system/images/logo.svg | 32 + dist/editor/system/images/move_bottom.png | Bin 0 -> 664 bytes dist/editor/system/images/move_top.png | Bin 0 -> 530 bytes dist/editor/system/images/no_color.png | Bin 0 -> 156 bytes dist/editor/system/images/node_clone.png | Bin 0 -> 526 bytes dist/editor/system/images/node_delete.png | Bin 0 -> 557 bytes dist/editor/system/images/none.png | Bin 0 -> 120 bytes dist/editor/system/images/opacity.png | Bin 0 -> 511 bytes dist/editor/system/images/open.png | Bin 0 -> 795 bytes dist/editor/system/images/openpath.png | Bin 0 -> 7955 bytes dist/editor/system/images/paste.png | Bin 0 -> 698 bytes dist/editor/system/images/path.png | Bin 0 -> 788 bytes dist/editor/system/images/polygon.png | Bin 0 -> 922 bytes dist/editor/system/images/polygon.svg | 76 + dist/editor/system/images/rect.png | Bin 0 -> 379 bytes dist/editor/system/images/redo.png | Bin 0 -> 656 bytes dist/editor/system/images/reorient.png | Bin 0 -> 646 bytes dist/editor/system/images/rotate.png | Bin 0 -> 694 bytes dist/editor/system/images/save.png | Bin 0 -> 825 bytes dist/editor/system/images/select.png | Bin 0 -> 389 bytes dist/editor/system/images/select_node.png | Bin 0 -> 731 bytes dist/editor/system/images/sep.png | Bin 0 -> 71 bytes .../system/images/shape_group_elements.png | Bin 0 -> 476 bytes dist/editor/system/images/shape_ungroup.png | Bin 0 -> 575 bytes dist/editor/system/images/source.png | Bin 0 -> 893 bytes .../editor/system/images/spinbtn_updn_big.png | Bin 0 -> 1240 bytes dist/editor/system/images/square.png | Bin 0 -> 328 bytes dist/editor/system/images/stroke.png | Bin 0 -> 174 bytes dist/editor/system/images/svg_edit_icons.svg | 1035 + dist/editor/system/images/svg_edit_icons.svgz | Bin 0 -> 5493 bytes dist/editor/system/images/text.png | Bin 0 -> 600 bytes dist/editor/system/images/text.svg | 157 + dist/editor/system/images/to_path.png | Bin 0 -> 938 bytes dist/editor/system/images/undo.png | Bin 0 -> 837 bytes dist/editor/system/images/unlink_use.png | Bin 0 -> 3895 bytes dist/editor/system/images/view-refresh.png | Bin 0 -> 727 bytes dist/editor/system/images/warning.png | Bin 0 -> 758 bytes dist/editor/system/images/width.png | Bin 0 -> 278 bytes dist/editor/system/images/wireframe.png | Bin 0 -> 268 bytes dist/editor/system/images/zoom.png | Bin 0 -> 1032 bytes dist/editor/system/index.html | 780 + dist/editor/system/index.js | 54704 ++++++++++++++++ .../system/jgraduate/LICENSE-Apache2.0.txt | 202 + dist/editor/system/jgraduate/README | 3 + .../editor/system/jgraduate/css/jGraduate.css | 351 + dist/editor/system/jgraduate/css/jPicker.css | 1 + .../system/jgraduate/images/AlphaBar.png | Bin 0 -> 1699 bytes dist/editor/system/jgraduate/images/Bars.png | Bin 0 -> 265 bytes dist/editor/system/jgraduate/images/Maps.png | Bin 0 -> 61784 bytes .../system/jgraduate/images/NoColor.png | Bin 0 -> 473 bytes .../system/jgraduate/images/bar-opacity.png | Bin 0 -> 80 bytes .../system/jgraduate/images/map-opacity.png | Bin 0 -> 81 bytes .../system/jgraduate/images/mappoint.gif | Bin 0 -> 93 bytes .../system/jgraduate/images/mappoint_c.png | Bin 0 -> 143 bytes .../system/jgraduate/images/mappoint_f.png | Bin 0 -> 147 bytes .../editor/system/jgraduate/images/picker.gif | Bin 0 -> 146 bytes .../jgraduate/images/preview-opacity.png | Bin 0 -> 80 bytes .../system/jgraduate/images/rangearrows.gif | Bin 0 -> 76 bytes .../system/jgraduate/images/rangearrows2.gif | Bin 0 -> 93 bytes .../system/jgraduate/jQuery.jGraduate.js | 1327 + .../editor/system/jgraduate/jQuery.jPicker.js | 2512 + .../jquery-ui/jquery-ui-1.8.17.custom.min.js | 54 + dist/editor/system/jquery.min.js | 4 + dist/editor/system/locale/lang.af.js | 227 + dist/editor/system/locale/lang.ar.js | 227 + dist/editor/system/locale/lang.az.js | 227 + dist/editor/system/locale/lang.be.js | 227 + dist/editor/system/locale/lang.bg.js | 227 + dist/editor/system/locale/lang.ca.js | 227 + dist/editor/system/locale/lang.cs.js | 227 + dist/editor/system/locale/lang.cy.js | 227 + dist/editor/system/locale/lang.da.js | 227 + dist/editor/system/locale/lang.de.js | 227 + dist/editor/system/locale/lang.el.js | 227 + dist/editor/system/locale/lang.en.js | 227 + dist/editor/system/locale/lang.es.js | 227 + dist/editor/system/locale/lang.et.js | 227 + dist/editor/system/locale/lang.fa.js | 227 + dist/editor/system/locale/lang.fi.js | 227 + dist/editor/system/locale/lang.fr.js | 227 + dist/editor/system/locale/lang.fy.js | 227 + dist/editor/system/locale/lang.ga.js | 227 + dist/editor/system/locale/lang.gl.js | 227 + dist/editor/system/locale/lang.he.js | 227 + dist/editor/system/locale/lang.hi.js | 227 + dist/editor/system/locale/lang.hr.js | 227 + dist/editor/system/locale/lang.hu.js | 227 + dist/editor/system/locale/lang.hy.js | 227 + dist/editor/system/locale/lang.id.js | 227 + dist/editor/system/locale/lang.is.js | 227 + dist/editor/system/locale/lang.it.js | 227 + dist/editor/system/locale/lang.ja.js | 227 + dist/editor/system/locale/lang.ko.js | 227 + dist/editor/system/locale/lang.lt.js | 227 + dist/editor/system/locale/lang.lv.js | 227 + dist/editor/system/locale/lang.mk.js | 227 + dist/editor/system/locale/lang.ms.js | 227 + dist/editor/system/locale/lang.mt.js | 227 + dist/editor/system/locale/lang.nl.js | 227 + dist/editor/system/locale/lang.no.js | 227 + dist/editor/system/locale/lang.pl.js | 228 + dist/editor/system/locale/lang.pt-BR.js | 226 + dist/editor/system/locale/lang.pt-PT.js | 227 + dist/editor/system/locale/lang.ro.js | 226 + dist/editor/system/locale/lang.ru.js | 227 + dist/editor/system/locale/lang.sk.js | 227 + dist/editor/system/locale/lang.sl.js | 226 + dist/editor/system/locale/lang.sq.js | 227 + dist/editor/system/locale/lang.sr.js | 227 + dist/editor/system/locale/lang.sv.js | 227 + dist/editor/system/locale/lang.sw.js | 227 + dist/editor/system/locale/lang.test.js | 227 + dist/editor/system/locale/lang.th.js | 227 + dist/editor/system/locale/lang.tl.js | 227 + dist/editor/system/locale/lang.tr.js | 227 + dist/editor/system/locale/lang.uk.js | 227 + dist/editor/system/locale/lang.vi.js | 227 + dist/editor/system/locale/lang.yi.js | 227 + dist/editor/system/locale/lang.zh-CN.js | 227 + dist/editor/system/locale/lang.zh-HK.js | 227 + dist/editor/system/locale/lang.zh-TW.js | 227 + .../system/redirect-on-lacking-support.js | 5 + .../system/redirect-on-no-module-support.js | 8 + dist/editor/system/s.min.js | 2 + dist/editor/system/s.min.js.map | 1 + .../system/spinbtn/jQuery.SpinButton.css | 41 + .../system/spinbtn/jQuery.SpinButton.js | 328 + dist/editor/system/spinbtn/spinbtn_updn.png | Bin 0 -> 572 bytes dist/editor/system/svgedit.css | 1462 + dist/external/deparam/deparam.esm.js | 102 + dist/external/dom-polyfill/dom-polyfill.js | 121 + dist/external/jamilih/jml-es.js | 1932 + dist/external/load-stylesheets/index-es.js | 162 + .../external/qr-manipulation/dist/index-es.js | 556 + dist/external/query-result/esm/index.js | 124 + .../stackblur-canvas/dist/stackblur-es.js | 580 + rollup.config.js | 8 +- src/editor/extensions/ext-eyedropper.js | 2 + src/editor/extensions/ext-foreignobject.js | 2 + src/editor/extensions/ext-grid.js | 2 + src/editor/extensions/ext-imagelib.js | 3 + src/editor/extensions/ext-markers.js | 3 + src/editor/extensions/ext-panning.js | 3 + src/editor/extensions/ext-polygon.js | 3 + src/editor/extensions/ext-shapes.js | 3 + src/editor/extensions/ext-star.js | 3 + 597 files changed, 269162 insertions(+), 1 deletion(-) create mode 100644 dist/common/browser.js create mode 100644 dist/common/jQuery.attr.js create mode 100644 dist/common/layer.js create mode 100644 dist/common/math.js create mode 100644 dist/common/namespaces.js create mode 100644 dist/common/svgpathseg.js create mode 100644 dist/common/svgtransformlist.js create mode 100644 dist/common/units.js create mode 100644 dist/common/utilities.js create mode 100644 dist/editor/browser-not-supported.html create mode 100644 dist/editor/embedapi.html create mode 100644 dist/editor/embedapi.js create mode 100644 dist/editor/extensions/ext-arrows.js create mode 100644 dist/editor/extensions/ext-arrows.js.map create mode 100644 dist/editor/extensions/ext-closepath.js create mode 100644 dist/editor/extensions/ext-closepath.js.map create mode 100644 dist/editor/extensions/ext-connector.js create mode 100644 dist/editor/extensions/ext-connector.js.map create mode 100644 dist/editor/extensions/ext-eyedropper.js create mode 100644 dist/editor/extensions/ext-eyedropper.js.map create mode 100644 dist/editor/extensions/ext-foreignobject.js create mode 100644 dist/editor/extensions/ext-foreignobject.js.map create mode 100644 dist/editor/extensions/ext-grid.js create mode 100644 dist/editor/extensions/ext-grid.js.map create mode 100644 dist/editor/extensions/ext-helloworld.js create mode 100644 dist/editor/extensions/ext-helloworld.js.map create mode 100644 dist/editor/extensions/ext-imagelib.js create mode 100644 dist/editor/extensions/ext-imagelib.js.map create mode 100644 dist/editor/extensions/ext-imagelib.xml create mode 100644 dist/editor/extensions/ext-locale/arrows/en.js create mode 100644 dist/editor/extensions/ext-locale/arrows/fr.js create mode 100644 dist/editor/extensions/ext-locale/arrows/zh_CN.js create mode 100644 dist/editor/extensions/ext-locale/closepath/en.js create mode 100644 dist/editor/extensions/ext-locale/closepath/zh_CN.js create mode 100644 dist/editor/extensions/ext-locale/connector/en.js create mode 100644 dist/editor/extensions/ext-locale/connector/fr.js create mode 100644 dist/editor/extensions/ext-locale/connector/zh_CN.js create mode 100644 dist/editor/extensions/ext-locale/eyedropper/en.js create mode 100644 dist/editor/extensions/ext-locale/eyedropper/zh_CN.js create mode 100644 dist/editor/extensions/ext-locale/foreignobject/en.js create mode 100644 dist/editor/extensions/ext-locale/foreignobject/zh_CN.js create mode 100644 dist/editor/extensions/ext-locale/grid/en.js create mode 100644 dist/editor/extensions/ext-locale/grid/zh_CN.js create mode 100644 dist/editor/extensions/ext-locale/helloworld/en.js create mode 100644 dist/editor/extensions/ext-locale/helloworld/zh_CN.js create mode 100644 dist/editor/extensions/ext-locale/imagelib/de.js create mode 100644 dist/editor/extensions/ext-locale/imagelib/en.js create mode 100644 dist/editor/extensions/ext-locale/imagelib/fr.js create mode 100644 dist/editor/extensions/ext-locale/imagelib/pl.js create mode 100644 dist/editor/extensions/ext-locale/imagelib/pt_BR.js create mode 100644 dist/editor/extensions/ext-locale/imagelib/ro.js create mode 100644 dist/editor/extensions/ext-locale/imagelib/sk.js create mode 100644 dist/editor/extensions/ext-locale/imagelib/sl.js create mode 100644 dist/editor/extensions/ext-locale/imagelib/zh_CN.js create mode 100644 dist/editor/extensions/ext-locale/markers/en.js create mode 100644 dist/editor/extensions/ext-locale/markers/zh_CN.js create mode 100644 dist/editor/extensions/ext-locale/mathjax/en.js create mode 100644 dist/editor/extensions/ext-locale/mathjax/zh_CN.js create mode 100644 dist/editor/extensions/ext-locale/panning/en.js create mode 100644 dist/editor/extensions/ext-locale/panning/zh_CN.js create mode 100644 dist/editor/extensions/ext-locale/placemark/en.js create mode 100644 dist/editor/extensions/ext-locale/polygon/en.js create mode 100644 dist/editor/extensions/ext-locale/polygon/zh_CN.js create mode 100644 dist/editor/extensions/ext-locale/server_moinsave/en.js create mode 100644 dist/editor/extensions/ext-locale/server_moinsave/zh_CN.js create mode 100644 dist/editor/extensions/ext-locale/server_opensave/en.js create mode 100644 dist/editor/extensions/ext-locale/server_opensave/zh_CN.js create mode 100644 dist/editor/extensions/ext-locale/shapes/en.js create mode 100644 dist/editor/extensions/ext-locale/shapes/fr.js create mode 100644 dist/editor/extensions/ext-locale/shapes/zh_CN.js create mode 100644 dist/editor/extensions/ext-locale/star/en.js create mode 100644 dist/editor/extensions/ext-locale/star/zh_CN.js create mode 100644 dist/editor/extensions/ext-locale/storage/de.js create mode 100644 dist/editor/extensions/ext-locale/storage/en.js create mode 100644 dist/editor/extensions/ext-locale/storage/fr.js create mode 100644 dist/editor/extensions/ext-locale/storage/zh_CN.js create mode 100644 dist/editor/extensions/ext-locale/webappfind/en.js create mode 100644 dist/editor/extensions/ext-locale/webappfind/zh_CN.js create mode 100644 dist/editor/extensions/ext-markers.js create mode 100644 dist/editor/extensions/ext-markers.js.map create mode 100644 dist/editor/extensions/ext-mathjax.js create mode 100644 dist/editor/extensions/ext-mathjax.js.map create mode 100644 dist/editor/extensions/ext-overview_window.js create mode 100644 dist/editor/extensions/ext-overview_window.js.map create mode 100644 dist/editor/extensions/ext-panning.js create mode 100644 dist/editor/extensions/ext-panning.js.map create mode 100644 dist/editor/extensions/ext-panning.xml create mode 100644 dist/editor/extensions/ext-php_savefile.js create mode 100644 dist/editor/extensions/ext-php_savefile.js.map create mode 100644 dist/editor/extensions/ext-placemark.js create mode 100644 dist/editor/extensions/ext-placemark.js.map create mode 100644 dist/editor/extensions/ext-polygon.js create mode 100644 dist/editor/extensions/ext-polygon.js.map create mode 100644 dist/editor/extensions/ext-server_moinsave.js create mode 100644 dist/editor/extensions/ext-server_moinsave.js.map create mode 100644 dist/editor/extensions/ext-server_opensave.js create mode 100644 dist/editor/extensions/ext-server_opensave.js.map create mode 100644 dist/editor/extensions/ext-shapes.js create mode 100644 dist/editor/extensions/ext-shapes.js.map create mode 100644 dist/editor/extensions/ext-shapes.xml create mode 100644 dist/editor/extensions/ext-star.js create mode 100644 dist/editor/extensions/ext-star.js.map create mode 100644 dist/editor/extensions/ext-storage.js create mode 100644 dist/editor/extensions/ext-storage.js.map create mode 100644 dist/editor/extensions/ext-webappfind.js create mode 100644 dist/editor/extensions/ext-webappfind.js.map create mode 100644 dist/editor/extensions/ext-xdomain-messaging.js create mode 100644 dist/editor/extensions/ext-xdomain-messaging.js.map create mode 100644 dist/editor/extensions/eyedropper-icon.xml create mode 100644 dist/editor/extensions/foreignobject-icons.xml create mode 100644 dist/editor/extensions/grid-icon.xml create mode 100644 dist/editor/extensions/markers-icons.xml create mode 100644 dist/editor/extensions/polygon-icons.svg create mode 100644 dist/editor/extensions/star-icons.svg create mode 100644 dist/editor/images/README.txt create mode 100644 dist/editor/images/add_subpath.png create mode 100644 dist/editor/images/align-bottom.png create mode 100644 dist/editor/images/align-bottom.svg create mode 100644 dist/editor/images/align-center.png create mode 100644 dist/editor/images/align-center.svg create mode 100644 dist/editor/images/align-left.png create mode 100644 dist/editor/images/align-left.svg create mode 100644 dist/editor/images/align-middle.png create mode 100644 dist/editor/images/align-middle.svg create mode 100644 dist/editor/images/align-right.png create mode 100644 dist/editor/images/align-right.svg create mode 100644 dist/editor/images/align-top.png create mode 100644 dist/editor/images/align-top.svg create mode 100644 dist/editor/images/align.png create mode 100644 dist/editor/images/angle.png create mode 100644 dist/editor/images/arrow_right.png create mode 100644 dist/editor/images/arrow_right_big.png create mode 100644 dist/editor/images/blur.png create mode 100644 dist/editor/images/bold.png create mode 100644 dist/editor/images/c_radius.png create mode 100644 dist/editor/images/cancel.png create mode 100644 dist/editor/images/circle.png create mode 100644 dist/editor/images/clear.png create mode 100644 dist/editor/images/clone.png create mode 100644 dist/editor/images/closepath.png create mode 100644 dist/editor/images/config.png create mode 100644 dist/editor/images/config.svg create mode 100644 dist/editor/images/conn.svg create mode 100644 dist/editor/images/context_menu.png create mode 100644 dist/editor/images/copy.png create mode 100644 dist/editor/images/cut.png create mode 100644 dist/editor/images/delete.png create mode 100644 dist/editor/images/document-properties.png create mode 100644 dist/editor/images/dropdown.gif create mode 100644 dist/editor/images/ellipse.png create mode 100644 dist/editor/images/export.png create mode 100644 dist/editor/images/eye.png create mode 100644 dist/editor/images/fhpath.png create mode 100644 dist/editor/images/fill.png create mode 100644 dist/editor/images/flyouth.png create mode 100644 dist/editor/images/flyup.gif create mode 100644 dist/editor/images/fontsize.png create mode 100644 dist/editor/images/freehand-circle.png create mode 100644 dist/editor/images/freehand-square.png create mode 100644 dist/editor/images/freehand-square.svg create mode 100644 dist/editor/images/globe_link.png create mode 100644 dist/editor/images/go-down.png create mode 100644 dist/editor/images/go-up.png create mode 100644 dist/editor/images/group_elements.png create mode 100644 dist/editor/images/height.png create mode 100644 dist/editor/images/image.png create mode 100644 dist/editor/images/import.png create mode 100644 dist/editor/images/italic.png create mode 100644 dist/editor/images/line.png create mode 100644 dist/editor/images/linecap_butt.png create mode 100644 dist/editor/images/linecap_round.png create mode 100644 dist/editor/images/linecap_square.png create mode 100644 dist/editor/images/linejoin_bevel.png create mode 100644 dist/editor/images/linejoin_miter.png create mode 100644 dist/editor/images/linejoin_round.png create mode 100644 dist/editor/images/link_controls.png create mode 100644 dist/editor/images/logo.png create mode 100644 dist/editor/images/logo.svg create mode 100644 dist/editor/images/move_bottom.png create mode 100644 dist/editor/images/move_top.png create mode 100644 dist/editor/images/no_color.png create mode 100755 dist/editor/images/node_clone.png create mode 100755 dist/editor/images/node_delete.png create mode 100644 dist/editor/images/none.png create mode 100644 dist/editor/images/opacity.png create mode 100644 dist/editor/images/open.png create mode 100644 dist/editor/images/openpath.png create mode 100644 dist/editor/images/paste.png create mode 100644 dist/editor/images/path.png create mode 100644 dist/editor/images/polygon.png create mode 100644 dist/editor/images/polygon.svg create mode 100644 dist/editor/images/rect.png create mode 100644 dist/editor/images/redo.png create mode 100644 dist/editor/images/reorient.png create mode 100644 dist/editor/images/rotate.png create mode 100644 dist/editor/images/save.png create mode 100644 dist/editor/images/select.png create mode 100644 dist/editor/images/select_node.png create mode 100644 dist/editor/images/sep.png create mode 100644 dist/editor/images/shape_group_elements.png create mode 100644 dist/editor/images/shape_ungroup.png create mode 100644 dist/editor/images/source.png create mode 100644 dist/editor/images/spinbtn_updn_big.png create mode 100644 dist/editor/images/square.png create mode 100644 dist/editor/images/stroke.png create mode 100644 dist/editor/images/svg_edit_icons.svg create mode 100644 dist/editor/images/svg_edit_icons.svgz create mode 100644 dist/editor/images/text.png create mode 100644 dist/editor/images/text.svg create mode 100644 dist/editor/images/to_path.png create mode 100644 dist/editor/images/undo.png create mode 100644 dist/editor/images/unlink_use.png create mode 100644 dist/editor/images/view-refresh.png create mode 100644 dist/editor/images/warning.png create mode 100644 dist/editor/images/width.png create mode 100644 dist/editor/images/wireframe.png create mode 100644 dist/editor/images/zoom.png create mode 100644 dist/editor/index.html create mode 100644 dist/editor/index.js create mode 100644 dist/editor/index.js.map create mode 100644 dist/editor/jgraduate/LICENSE-Apache2.0.txt create mode 100644 dist/editor/jgraduate/README create mode 100644 dist/editor/jgraduate/css/jGraduate.css create mode 100644 dist/editor/jgraduate/css/jPicker.css create mode 100644 dist/editor/jgraduate/images/AlphaBar.png create mode 100644 dist/editor/jgraduate/images/Bars.png create mode 100644 dist/editor/jgraduate/images/Maps.png create mode 100644 dist/editor/jgraduate/images/NoColor.png create mode 100644 dist/editor/jgraduate/images/bar-opacity.png create mode 100644 dist/editor/jgraduate/images/map-opacity.png create mode 100644 dist/editor/jgraduate/images/mappoint.gif create mode 100644 dist/editor/jgraduate/images/mappoint_c.png create mode 100644 dist/editor/jgraduate/images/mappoint_f.png create mode 100644 dist/editor/jgraduate/images/picker.gif create mode 100644 dist/editor/jgraduate/images/preview-opacity.png create mode 100644 dist/editor/jgraduate/images/rangearrows.gif create mode 100644 dist/editor/jgraduate/images/rangearrows2.gif create mode 100644 dist/editor/jgraduate/jQuery.jGraduate.js create mode 100755 dist/editor/jgraduate/jQuery.jPicker.js create mode 100644 dist/editor/jquery-ui/jquery-ui-1.8.17.custom.min.js create mode 100644 dist/editor/jquery.min.js create mode 100644 dist/editor/locale/lang.af.js create mode 100644 dist/editor/locale/lang.ar.js create mode 100644 dist/editor/locale/lang.az.js create mode 100644 dist/editor/locale/lang.be.js create mode 100644 dist/editor/locale/lang.bg.js create mode 100644 dist/editor/locale/lang.ca.js create mode 100644 dist/editor/locale/lang.cs.js create mode 100644 dist/editor/locale/lang.cy.js create mode 100644 dist/editor/locale/lang.da.js create mode 100644 dist/editor/locale/lang.de.js create mode 100644 dist/editor/locale/lang.el.js create mode 100644 dist/editor/locale/lang.en.js create mode 100644 dist/editor/locale/lang.es.js create mode 100644 dist/editor/locale/lang.et.js create mode 100644 dist/editor/locale/lang.fa.js create mode 100644 dist/editor/locale/lang.fi.js create mode 100644 dist/editor/locale/lang.fr.js create mode 100644 dist/editor/locale/lang.fy.js create mode 100644 dist/editor/locale/lang.ga.js create mode 100644 dist/editor/locale/lang.gl.js create mode 100644 dist/editor/locale/lang.he.js create mode 100644 dist/editor/locale/lang.hi.js create mode 100644 dist/editor/locale/lang.hr.js create mode 100644 dist/editor/locale/lang.hu.js create mode 100644 dist/editor/locale/lang.hy.js create mode 100644 dist/editor/locale/lang.id.js create mode 100644 dist/editor/locale/lang.is.js create mode 100644 dist/editor/locale/lang.it.js create mode 100644 dist/editor/locale/lang.ja.js create mode 100644 dist/editor/locale/lang.ko.js create mode 100644 dist/editor/locale/lang.lt.js create mode 100644 dist/editor/locale/lang.lv.js create mode 100644 dist/editor/locale/lang.mk.js create mode 100644 dist/editor/locale/lang.ms.js create mode 100644 dist/editor/locale/lang.mt.js create mode 100644 dist/editor/locale/lang.nl.js create mode 100644 dist/editor/locale/lang.no.js create mode 100644 dist/editor/locale/lang.pl.js create mode 100644 dist/editor/locale/lang.pt-BR.js create mode 100644 dist/editor/locale/lang.pt-PT.js create mode 100644 dist/editor/locale/lang.ro.js create mode 100644 dist/editor/locale/lang.ru.js create mode 100644 dist/editor/locale/lang.sk.js create mode 100644 dist/editor/locale/lang.sl.js create mode 100644 dist/editor/locale/lang.sq.js create mode 100644 dist/editor/locale/lang.sr.js create mode 100644 dist/editor/locale/lang.sv.js create mode 100644 dist/editor/locale/lang.sw.js create mode 100644 dist/editor/locale/lang.test.js create mode 100644 dist/editor/locale/lang.th.js create mode 100644 dist/editor/locale/lang.tl.js create mode 100644 dist/editor/locale/lang.tr.js create mode 100644 dist/editor/locale/lang.uk.js create mode 100644 dist/editor/locale/lang.vi.js create mode 100644 dist/editor/locale/lang.yi.js create mode 100644 dist/editor/locale/lang.zh-CN.js create mode 100644 dist/editor/locale/lang.zh-HK.js create mode 100644 dist/editor/locale/lang.zh-TW.js create mode 100644 dist/editor/redirect-on-lacking-support.js create mode 100644 dist/editor/redirect-on-no-module-support.js create mode 100644 dist/editor/spinbtn/jQuery.SpinButton.css create mode 100644 dist/editor/spinbtn/jQuery.SpinButton.js create mode 100644 dist/editor/spinbtn/spinbtn_updn.png create mode 100644 dist/editor/svgedit.css create mode 100644 dist/editor/system/browser-not-supported.html create mode 100644 dist/editor/system/embedapi.html create mode 100644 dist/editor/system/embedapi.js create mode 100644 dist/editor/system/extensions/ext-arrows.js create mode 100644 dist/editor/system/extensions/ext-closepath.js create mode 100644 dist/editor/system/extensions/ext-connector.js create mode 100644 dist/editor/system/extensions/ext-eyedropper.js create mode 100644 dist/editor/system/extensions/ext-foreignobject.js create mode 100644 dist/editor/system/extensions/ext-grid.js create mode 100644 dist/editor/system/extensions/ext-helloworld.js create mode 100644 dist/editor/system/extensions/ext-imagelib.js create mode 100644 dist/editor/system/extensions/ext-imagelib.xml create mode 100644 dist/editor/system/extensions/ext-locale/arrows/en.js create mode 100644 dist/editor/system/extensions/ext-locale/arrows/fr.js create mode 100644 dist/editor/system/extensions/ext-locale/arrows/zh_CN.js create mode 100644 dist/editor/system/extensions/ext-locale/closepath/en.js create mode 100644 dist/editor/system/extensions/ext-locale/closepath/zh_CN.js create mode 100644 dist/editor/system/extensions/ext-locale/connector/en.js create mode 100644 dist/editor/system/extensions/ext-locale/connector/fr.js create mode 100644 dist/editor/system/extensions/ext-locale/connector/zh_CN.js create mode 100644 dist/editor/system/extensions/ext-locale/eyedropper/en.js create mode 100644 dist/editor/system/extensions/ext-locale/eyedropper/zh_CN.js create mode 100644 dist/editor/system/extensions/ext-locale/foreignobject/en.js create mode 100644 dist/editor/system/extensions/ext-locale/foreignobject/zh_CN.js create mode 100644 dist/editor/system/extensions/ext-locale/grid/en.js create mode 100644 dist/editor/system/extensions/ext-locale/grid/zh_CN.js create mode 100644 dist/editor/system/extensions/ext-locale/helloworld/en.js create mode 100644 dist/editor/system/extensions/ext-locale/helloworld/zh_CN.js create mode 100644 dist/editor/system/extensions/ext-locale/imagelib/de.js create mode 100644 dist/editor/system/extensions/ext-locale/imagelib/en.js create mode 100644 dist/editor/system/extensions/ext-locale/imagelib/fr.js create mode 100644 dist/editor/system/extensions/ext-locale/imagelib/pl.js create mode 100644 dist/editor/system/extensions/ext-locale/imagelib/pt_BR.js create mode 100644 dist/editor/system/extensions/ext-locale/imagelib/ro.js create mode 100644 dist/editor/system/extensions/ext-locale/imagelib/sk.js create mode 100644 dist/editor/system/extensions/ext-locale/imagelib/sl.js create mode 100644 dist/editor/system/extensions/ext-locale/imagelib/zh_CN.js create mode 100644 dist/editor/system/extensions/ext-locale/markers/en.js create mode 100644 dist/editor/system/extensions/ext-locale/markers/zh_CN.js create mode 100644 dist/editor/system/extensions/ext-locale/mathjax/en.js create mode 100644 dist/editor/system/extensions/ext-locale/mathjax/zh_CN.js create mode 100644 dist/editor/system/extensions/ext-locale/panning/en.js create mode 100644 dist/editor/system/extensions/ext-locale/panning/zh_CN.js create mode 100644 dist/editor/system/extensions/ext-locale/placemark/en.js create mode 100644 dist/editor/system/extensions/ext-locale/polygon/en.js create mode 100644 dist/editor/system/extensions/ext-locale/polygon/zh_CN.js create mode 100644 dist/editor/system/extensions/ext-locale/server_moinsave/en.js create mode 100644 dist/editor/system/extensions/ext-locale/server_moinsave/zh_CN.js create mode 100644 dist/editor/system/extensions/ext-locale/server_opensave/en.js create mode 100644 dist/editor/system/extensions/ext-locale/server_opensave/zh_CN.js create mode 100644 dist/editor/system/extensions/ext-locale/shapes/en.js create mode 100644 dist/editor/system/extensions/ext-locale/shapes/fr.js create mode 100644 dist/editor/system/extensions/ext-locale/shapes/zh_CN.js create mode 100644 dist/editor/system/extensions/ext-locale/star/en.js create mode 100644 dist/editor/system/extensions/ext-locale/star/zh_CN.js create mode 100644 dist/editor/system/extensions/ext-locale/storage/de.js create mode 100644 dist/editor/system/extensions/ext-locale/storage/en.js create mode 100644 dist/editor/system/extensions/ext-locale/storage/fr.js create mode 100644 dist/editor/system/extensions/ext-locale/storage/zh_CN.js create mode 100644 dist/editor/system/extensions/ext-locale/webappfind/en.js create mode 100644 dist/editor/system/extensions/ext-locale/webappfind/zh_CN.js create mode 100644 dist/editor/system/extensions/ext-markers.js create mode 100644 dist/editor/system/extensions/ext-mathjax.js create mode 100644 dist/editor/system/extensions/ext-overview_window.js create mode 100644 dist/editor/system/extensions/ext-panning.js create mode 100644 dist/editor/system/extensions/ext-panning.xml create mode 100644 dist/editor/system/extensions/ext-php_savefile.js create mode 100644 dist/editor/system/extensions/ext-placemark.js create mode 100644 dist/editor/system/extensions/ext-polygon.js create mode 100644 dist/editor/system/extensions/ext-server_moinsave.js create mode 100644 dist/editor/system/extensions/ext-server_opensave.js create mode 100644 dist/editor/system/extensions/ext-shapes.js create mode 100644 dist/editor/system/extensions/ext-shapes.xml create mode 100644 dist/editor/system/extensions/ext-star.js create mode 100644 dist/editor/system/extensions/ext-storage.js create mode 100644 dist/editor/system/extensions/ext-webappfind.js create mode 100644 dist/editor/system/extensions/ext-xdomain-messaging.js create mode 100644 dist/editor/system/extensions/eyedropper-icon.xml create mode 100644 dist/editor/system/extensions/foreignobject-icons.xml create mode 100644 dist/editor/system/extensions/grid-icon.xml create mode 100644 dist/editor/system/extensions/markers-icons.xml create mode 100644 dist/editor/system/extensions/polygon-icons.svg create mode 100644 dist/editor/system/extensions/star-icons.svg create mode 100644 dist/editor/system/images/README.txt create mode 100644 dist/editor/system/images/add_subpath.png create mode 100644 dist/editor/system/images/align-bottom.png create mode 100644 dist/editor/system/images/align-bottom.svg create mode 100644 dist/editor/system/images/align-center.png create mode 100644 dist/editor/system/images/align-center.svg create mode 100644 dist/editor/system/images/align-left.png create mode 100644 dist/editor/system/images/align-left.svg create mode 100644 dist/editor/system/images/align-middle.png create mode 100644 dist/editor/system/images/align-middle.svg create mode 100644 dist/editor/system/images/align-right.png create mode 100644 dist/editor/system/images/align-right.svg create mode 100644 dist/editor/system/images/align-top.png create mode 100644 dist/editor/system/images/align-top.svg create mode 100644 dist/editor/system/images/align.png create mode 100644 dist/editor/system/images/angle.png create mode 100644 dist/editor/system/images/arrow_right.png create mode 100644 dist/editor/system/images/arrow_right_big.png create mode 100644 dist/editor/system/images/blur.png create mode 100644 dist/editor/system/images/bold.png create mode 100644 dist/editor/system/images/c_radius.png create mode 100644 dist/editor/system/images/cancel.png create mode 100644 dist/editor/system/images/circle.png create mode 100644 dist/editor/system/images/clear.png create mode 100644 dist/editor/system/images/clone.png create mode 100644 dist/editor/system/images/closepath.png create mode 100644 dist/editor/system/images/config.png create mode 100644 dist/editor/system/images/config.svg create mode 100644 dist/editor/system/images/conn.svg create mode 100644 dist/editor/system/images/context_menu.png create mode 100644 dist/editor/system/images/copy.png create mode 100644 dist/editor/system/images/cut.png create mode 100644 dist/editor/system/images/delete.png create mode 100644 dist/editor/system/images/document-properties.png create mode 100644 dist/editor/system/images/dropdown.gif create mode 100644 dist/editor/system/images/ellipse.png create mode 100644 dist/editor/system/images/export.png create mode 100644 dist/editor/system/images/eye.png create mode 100644 dist/editor/system/images/fhpath.png create mode 100644 dist/editor/system/images/fill.png create mode 100644 dist/editor/system/images/flyouth.png create mode 100644 dist/editor/system/images/flyup.gif create mode 100644 dist/editor/system/images/fontsize.png create mode 100644 dist/editor/system/images/freehand-circle.png create mode 100644 dist/editor/system/images/freehand-square.png create mode 100644 dist/editor/system/images/freehand-square.svg create mode 100644 dist/editor/system/images/globe_link.png create mode 100644 dist/editor/system/images/go-down.png create mode 100644 dist/editor/system/images/go-up.png create mode 100644 dist/editor/system/images/group_elements.png create mode 100644 dist/editor/system/images/height.png create mode 100644 dist/editor/system/images/image.png create mode 100644 dist/editor/system/images/import.png create mode 100644 dist/editor/system/images/italic.png create mode 100644 dist/editor/system/images/line.png create mode 100644 dist/editor/system/images/linecap_butt.png create mode 100644 dist/editor/system/images/linecap_round.png create mode 100644 dist/editor/system/images/linecap_square.png create mode 100644 dist/editor/system/images/linejoin_bevel.png create mode 100644 dist/editor/system/images/linejoin_miter.png create mode 100644 dist/editor/system/images/linejoin_round.png create mode 100644 dist/editor/system/images/link_controls.png create mode 100644 dist/editor/system/images/logo.png create mode 100644 dist/editor/system/images/logo.svg create mode 100644 dist/editor/system/images/move_bottom.png create mode 100644 dist/editor/system/images/move_top.png create mode 100644 dist/editor/system/images/no_color.png create mode 100755 dist/editor/system/images/node_clone.png create mode 100755 dist/editor/system/images/node_delete.png create mode 100644 dist/editor/system/images/none.png create mode 100644 dist/editor/system/images/opacity.png create mode 100644 dist/editor/system/images/open.png create mode 100644 dist/editor/system/images/openpath.png create mode 100644 dist/editor/system/images/paste.png create mode 100644 dist/editor/system/images/path.png create mode 100644 dist/editor/system/images/polygon.png create mode 100644 dist/editor/system/images/polygon.svg create mode 100644 dist/editor/system/images/rect.png create mode 100644 dist/editor/system/images/redo.png create mode 100644 dist/editor/system/images/reorient.png create mode 100644 dist/editor/system/images/rotate.png create mode 100644 dist/editor/system/images/save.png create mode 100644 dist/editor/system/images/select.png create mode 100644 dist/editor/system/images/select_node.png create mode 100644 dist/editor/system/images/sep.png create mode 100644 dist/editor/system/images/shape_group_elements.png create mode 100644 dist/editor/system/images/shape_ungroup.png create mode 100644 dist/editor/system/images/source.png create mode 100644 dist/editor/system/images/spinbtn_updn_big.png create mode 100644 dist/editor/system/images/square.png create mode 100644 dist/editor/system/images/stroke.png create mode 100644 dist/editor/system/images/svg_edit_icons.svg create mode 100644 dist/editor/system/images/svg_edit_icons.svgz create mode 100644 dist/editor/system/images/text.png create mode 100644 dist/editor/system/images/text.svg create mode 100644 dist/editor/system/images/to_path.png create mode 100644 dist/editor/system/images/undo.png create mode 100644 dist/editor/system/images/unlink_use.png create mode 100644 dist/editor/system/images/view-refresh.png create mode 100644 dist/editor/system/images/warning.png create mode 100644 dist/editor/system/images/width.png create mode 100644 dist/editor/system/images/wireframe.png create mode 100644 dist/editor/system/images/zoom.png create mode 100644 dist/editor/system/index.html create mode 100644 dist/editor/system/index.js create mode 100644 dist/editor/system/jgraduate/LICENSE-Apache2.0.txt create mode 100644 dist/editor/system/jgraduate/README create mode 100644 dist/editor/system/jgraduate/css/jGraduate.css create mode 100644 dist/editor/system/jgraduate/css/jPicker.css create mode 100644 dist/editor/system/jgraduate/images/AlphaBar.png create mode 100644 dist/editor/system/jgraduate/images/Bars.png create mode 100644 dist/editor/system/jgraduate/images/Maps.png create mode 100644 dist/editor/system/jgraduate/images/NoColor.png create mode 100644 dist/editor/system/jgraduate/images/bar-opacity.png create mode 100644 dist/editor/system/jgraduate/images/map-opacity.png create mode 100644 dist/editor/system/jgraduate/images/mappoint.gif create mode 100644 dist/editor/system/jgraduate/images/mappoint_c.png create mode 100644 dist/editor/system/jgraduate/images/mappoint_f.png create mode 100644 dist/editor/system/jgraduate/images/picker.gif create mode 100644 dist/editor/system/jgraduate/images/preview-opacity.png create mode 100644 dist/editor/system/jgraduate/images/rangearrows.gif create mode 100644 dist/editor/system/jgraduate/images/rangearrows2.gif create mode 100644 dist/editor/system/jgraduate/jQuery.jGraduate.js create mode 100755 dist/editor/system/jgraduate/jQuery.jPicker.js create mode 100644 dist/editor/system/jquery-ui/jquery-ui-1.8.17.custom.min.js create mode 100644 dist/editor/system/jquery.min.js create mode 100644 dist/editor/system/locale/lang.af.js create mode 100644 dist/editor/system/locale/lang.ar.js create mode 100644 dist/editor/system/locale/lang.az.js create mode 100644 dist/editor/system/locale/lang.be.js create mode 100644 dist/editor/system/locale/lang.bg.js create mode 100644 dist/editor/system/locale/lang.ca.js create mode 100644 dist/editor/system/locale/lang.cs.js create mode 100644 dist/editor/system/locale/lang.cy.js create mode 100644 dist/editor/system/locale/lang.da.js create mode 100644 dist/editor/system/locale/lang.de.js create mode 100644 dist/editor/system/locale/lang.el.js create mode 100644 dist/editor/system/locale/lang.en.js create mode 100644 dist/editor/system/locale/lang.es.js create mode 100644 dist/editor/system/locale/lang.et.js create mode 100644 dist/editor/system/locale/lang.fa.js create mode 100644 dist/editor/system/locale/lang.fi.js create mode 100644 dist/editor/system/locale/lang.fr.js create mode 100644 dist/editor/system/locale/lang.fy.js create mode 100644 dist/editor/system/locale/lang.ga.js create mode 100644 dist/editor/system/locale/lang.gl.js create mode 100644 dist/editor/system/locale/lang.he.js create mode 100644 dist/editor/system/locale/lang.hi.js create mode 100644 dist/editor/system/locale/lang.hr.js create mode 100644 dist/editor/system/locale/lang.hu.js create mode 100644 dist/editor/system/locale/lang.hy.js create mode 100644 dist/editor/system/locale/lang.id.js create mode 100644 dist/editor/system/locale/lang.is.js create mode 100644 dist/editor/system/locale/lang.it.js create mode 100644 dist/editor/system/locale/lang.ja.js create mode 100644 dist/editor/system/locale/lang.ko.js create mode 100644 dist/editor/system/locale/lang.lt.js create mode 100644 dist/editor/system/locale/lang.lv.js create mode 100644 dist/editor/system/locale/lang.mk.js create mode 100644 dist/editor/system/locale/lang.ms.js create mode 100644 dist/editor/system/locale/lang.mt.js create mode 100644 dist/editor/system/locale/lang.nl.js create mode 100644 dist/editor/system/locale/lang.no.js create mode 100644 dist/editor/system/locale/lang.pl.js create mode 100644 dist/editor/system/locale/lang.pt-BR.js create mode 100644 dist/editor/system/locale/lang.pt-PT.js create mode 100644 dist/editor/system/locale/lang.ro.js create mode 100644 dist/editor/system/locale/lang.ru.js create mode 100644 dist/editor/system/locale/lang.sk.js create mode 100644 dist/editor/system/locale/lang.sl.js create mode 100644 dist/editor/system/locale/lang.sq.js create mode 100644 dist/editor/system/locale/lang.sr.js create mode 100644 dist/editor/system/locale/lang.sv.js create mode 100644 dist/editor/system/locale/lang.sw.js create mode 100644 dist/editor/system/locale/lang.test.js create mode 100644 dist/editor/system/locale/lang.th.js create mode 100644 dist/editor/system/locale/lang.tl.js create mode 100644 dist/editor/system/locale/lang.tr.js create mode 100644 dist/editor/system/locale/lang.uk.js create mode 100644 dist/editor/system/locale/lang.vi.js create mode 100644 dist/editor/system/locale/lang.yi.js create mode 100644 dist/editor/system/locale/lang.zh-CN.js create mode 100644 dist/editor/system/locale/lang.zh-HK.js create mode 100644 dist/editor/system/locale/lang.zh-TW.js create mode 100644 dist/editor/system/redirect-on-lacking-support.js create mode 100644 dist/editor/system/redirect-on-no-module-support.js create mode 100644 dist/editor/system/s.min.js create mode 100644 dist/editor/system/s.min.js.map create mode 100644 dist/editor/system/spinbtn/jQuery.SpinButton.css create mode 100644 dist/editor/system/spinbtn/jQuery.SpinButton.js create mode 100644 dist/editor/system/spinbtn/spinbtn_updn.png create mode 100644 dist/editor/system/svgedit.css create mode 100644 dist/external/deparam/deparam.esm.js create mode 100644 dist/external/dom-polyfill/dom-polyfill.js create mode 100644 dist/external/jamilih/jml-es.js create mode 100644 dist/external/load-stylesheets/index-es.js create mode 100644 dist/external/qr-manipulation/dist/index-es.js create mode 100644 dist/external/query-result/esm/index.js create mode 100644 dist/external/stackblur-canvas/dist/stackblur-es.js diff --git a/dist/common/browser.js b/dist/common/browser.js new file mode 100644 index 00000000..21875a30 --- /dev/null +++ b/dist/common/browser.js @@ -0,0 +1,285 @@ +/* globals jQuery */ +/** + * Browser detection. + * @module browser + * @license MIT + * + * @copyright 2010 Jeff Schiller, 2010 Alexis Deveria + */ + +// Dependencies: +// 1) jQuery (for $.alert()) + +import './svgpathseg.js'; +import {NS} from './namespaces.js'; + +const $ = jQuery; + +const supportsSVG_ = (function () { +return Boolean(document.createElementNS && document.createElementNS(NS.SVG, 'svg').createSVGRect); +}()); + +/** + * @function module:browser.supportsSvg + * @returns {boolean} +*/ +export const supportsSvg = () => supportsSVG_; + +const {userAgent} = navigator; +const svg = document.createElementNS(NS.SVG, 'svg'); + +// Note: Browser sniffing should only be used if no other detection method is possible +const isOpera_ = Boolean(window.opera); +const isWebkit_ = userAgent.includes('AppleWebKit'); +const isGecko_ = userAgent.includes('Gecko/'); +const isIE_ = userAgent.includes('MSIE'); +const isChrome_ = userAgent.includes('Chrome/'); +const isWindows_ = userAgent.includes('Windows'); +const isMac_ = userAgent.includes('Macintosh'); +const isTouch_ = 'ontouchstart' in window; + +const supportsSelectors_ = (function () { +return Boolean(svg.querySelector); +}()); + +const supportsXpath_ = (function () { +return Boolean(document.evaluate); +}()); + +// segList functions (for FF1.5 and 2.0) +const supportsPathReplaceItem_ = (function () { +const path = document.createElementNS(NS.SVG, 'path'); +path.setAttribute('d', 'M0,0 10,10'); +const seglist = path.pathSegList; +const seg = path.createSVGPathSegLinetoAbs(5, 5); +try { + seglist.replaceItem(seg, 1); + return true; +} catch (err) {} +return false; +}()); + +const supportsPathInsertItemBefore_ = (function () { +const path = document.createElementNS(NS.SVG, 'path'); +path.setAttribute('d', 'M0,0 10,10'); +const seglist = path.pathSegList; +const seg = path.createSVGPathSegLinetoAbs(5, 5); +try { + seglist.insertItemBefore(seg, 1); + return true; +} catch (err) {} +return false; +}()); + +// text character positioning (for IE9 and now Chrome) +const supportsGoodTextCharPos_ = (function () { +const svgroot = document.createElementNS(NS.SVG, 'svg'); +const svgcontent = document.createElementNS(NS.SVG, 'svg'); +document.documentElement.append(svgroot); +svgcontent.setAttribute('x', 5); +svgroot.append(svgcontent); +const text = document.createElementNS(NS.SVG, 'text'); +text.textContent = 'a'; +svgcontent.append(text); +try { // Chrome now fails here + const pos = text.getStartPositionOfChar(0).x; + return (pos === 0); +} catch (err) { + return false; +} finally { + svgroot.remove(); +} +}()); + +const supportsPathBBox_ = (function () { +const svgcontent = document.createElementNS(NS.SVG, 'svg'); +document.documentElement.append(svgcontent); +const path = document.createElementNS(NS.SVG, 'path'); +path.setAttribute('d', 'M0,0 C0,0 10,10 10,0'); +svgcontent.append(path); +const bbox = path.getBBox(); +svgcontent.remove(); +return (bbox.height > 4 && bbox.height < 5); +}()); + +// Support for correct bbox sizing on groups with horizontal/vertical lines +const supportsHVLineContainerBBox_ = (function () { +const svgcontent = document.createElementNS(NS.SVG, 'svg'); +document.documentElement.append(svgcontent); +const path = document.createElementNS(NS.SVG, 'path'); +path.setAttribute('d', 'M0,0 10,0'); +const path2 = document.createElementNS(NS.SVG, 'path'); +path2.setAttribute('d', 'M5,0 15,0'); +const g = document.createElementNS(NS.SVG, 'g'); +g.append(path, path2); +svgcontent.append(g); +const bbox = g.getBBox(); +svgcontent.remove(); +// Webkit gives 0, FF gives 10, Opera (correctly) gives 15 +return (bbox.width === 15); +}()); + +const supportsEditableText_ = (function () { +// TODO: Find better way to check support for this +return isOpera_; +}()); + +const supportsGoodDecimals_ = (function () { +// Correct decimals on clone attributes (Opera < 10.5/win/non-en) +const rect = document.createElementNS(NS.SVG, 'rect'); +rect.setAttribute('x', 0.1); +const crect = rect.cloneNode(false); +const retValue = (!crect.getAttribute('x').includes(',')); +if (!retValue) { + // Todo: i18nize or remove + $.alert( + 'NOTE: This version of Opera is known to contain bugs in SVG-edit.\n' + + 'Please upgrade to the latest version in which the problems have been fixed.' + ); +} +return retValue; +}()); + +const supportsNonScalingStroke_ = (function () { +const rect = document.createElementNS(NS.SVG, 'rect'); +rect.setAttribute('style', 'vector-effect:non-scaling-stroke'); +return rect.style.vectorEffect === 'non-scaling-stroke'; +}()); + +let supportsNativeSVGTransformLists_ = (function () { +const rect = document.createElementNS(NS.SVG, 'rect'); +const rxform = rect.transform.baseVal; +const t1 = svg.createSVGTransform(); +rxform.appendItem(t1); +const r1 = rxform.getItem(0); +const isSVGTransform = (o) => { + // https://developer.mozilla.org/en-US/docs/Web/API/SVGTransform + return o && typeof o === 'object' && typeof o.setMatrix === 'function' && 'angle' in o; +}; +return isSVGTransform(r1) && isSVGTransform(t1) && + r1.type === t1.type && r1.angle === t1.angle && + r1.matrix.a === t1.matrix.a && + r1.matrix.b === t1.matrix.b && + r1.matrix.c === t1.matrix.c && + r1.matrix.d === t1.matrix.d && + r1.matrix.e === t1.matrix.e && + r1.matrix.f === t1.matrix.f; +}()); + +// Public API + +/** + * @function module:browser.isOpera + * @returns {boolean} +*/ +export const isOpera = () => isOpera_; +/** + * @function module:browser.isWebkit + * @returns {boolean} +*/ +export const isWebkit = () => isWebkit_; +/** + * @function module:browser.isGecko + * @returns {boolean} +*/ +export const isGecko = () => isGecko_; +/** + * @function module:browser.isIE + * @returns {boolean} +*/ +export const isIE = () => isIE_; +/** + * @function module:browser.isChrome + * @returns {boolean} +*/ +export const isChrome = () => isChrome_; +/** + * @function module:browser.isWindows + * @returns {boolean} +*/ +export const isWindows = () => isWindows_; +/** + * @function module:browser.isMac + * @returns {boolean} +*/ +export const isMac = () => isMac_; +/** + * @function module:browser.isTouch + * @returns {boolean} +*/ +export const isTouch = () => isTouch_; + +/** + * @function module:browser.supportsSelectors + * @returns {boolean} +*/ +export const supportsSelectors = () => supportsSelectors_; + +/** + * @function module:browser.supportsXpath + * @returns {boolean} +*/ +export const supportsXpath = () => supportsXpath_; + +/** + * @function module:browser.supportsPathReplaceItem + * @returns {boolean} +*/ +export const supportsPathReplaceItem = () => supportsPathReplaceItem_; + +/** + * @function module:browser.supportsPathInsertItemBefore + * @returns {boolean} +*/ +export const supportsPathInsertItemBefore = () => supportsPathInsertItemBefore_; + +/** + * @function module:browser.supportsPathBBox + * @returns {boolean} +*/ +export const supportsPathBBox = () => supportsPathBBox_; + +/** + * @function module:browser.supportsHVLineContainerBBox + * @returns {boolean} +*/ +export const supportsHVLineContainerBBox = () => supportsHVLineContainerBBox_; + +/** + * @function module:browser.supportsGoodTextCharPos + * @returns {boolean} +*/ +export const supportsGoodTextCharPos = () => supportsGoodTextCharPos_; + +/** +* @function module:browser.supportsEditableText + * @returns {boolean} +*/ +export const supportsEditableText = () => supportsEditableText_; + +/** + * @function module:browser.supportsGoodDecimals + * @returns {boolean} +*/ +export const supportsGoodDecimals = () => supportsGoodDecimals_; + +/** +* @function module:browser.supportsNonScalingStroke +* @returns {boolean} +*/ +export const supportsNonScalingStroke = () => supportsNonScalingStroke_; + +/** +* @function module:browser.supportsNativeTransformLists +* @returns {boolean} +*/ +export const supportsNativeTransformLists = () => supportsNativeSVGTransformLists_; + +/** + * Set `supportsNativeSVGTransformLists_` to `false` (for unit testing). + * @function module:browser.disableSupportsNativeTransformLists + * @returns {void} +*/ +export const disableSupportsNativeTransformLists = () => { + supportsNativeSVGTransformLists_ = false; +}; diff --git a/dist/common/jQuery.attr.js b/dist/common/jQuery.attr.js new file mode 100644 index 00000000..eafb505e --- /dev/null +++ b/dist/common/jQuery.attr.js @@ -0,0 +1,79 @@ +/** + * A jQuery module to work with SVG attributes. + * @module jQueryAttr + * @license MIT + */ + +/** +* This fixes `$(...).attr()` to work as expected with SVG elements. +* Does not currently use `*AttributeNS()` since we rarely need that. +* Adds {@link external:jQuery.fn.attr}. +* See {@link https://api.jquery.com/attr/} for basic documentation of `.attr()`. +* +* Additional functionality: +* - When getting attributes, a string that's a number is returned as type number. +* - If an array is supplied as the first parameter, multiple values are returned +* as an object with values for each given attribute. +* @function module:jQueryAttr.jQueryAttr +* @param {external:jQuery} $ The jQuery object to which to add the plug-in +* @returns {external:jQuery} +*/ +export default function jQueryPluginSVG ($) { + const proxied = $.fn.attr, + svgns = 'http://www.w3.org/2000/svg'; + /** + * @typedef {PlainObject} module:jQueryAttr.Attributes + */ + /** + * @function external:jQuery.fn.attr + * @param {string|string[]|PlainObject} key + * @param {string} value + * @returns {external:jQuery|module:jQueryAttr.Attributes} + */ + $.fn.attr = function (key, value) { + const len = this.length; + if (!len) { return proxied.call(this, key, value); } + for (let i = 0; i < len; ++i) { + const elem = this[i]; + // set/get SVG attribute + if (elem.namespaceURI === svgns) { + // Setting attribute + if (value !== undefined) { + elem.setAttribute(key, value); + } else if (Array.isArray(key)) { + // Getting attributes from array + const obj = {}; + let j = key.length; + + while (j--) { + const aname = key[j]; + let attr = elem.getAttribute(aname); + // This returns a number when appropriate + if (attr || attr === '0') { + attr = isNaN(attr) ? attr : (attr - 0); + } + obj[aname] = attr; + } + return obj; + } + if (typeof key === 'object') { + // Setting attributes from object + for (const [name, val] of Object.entries(key)) { + elem.setAttribute(name, val); + } + // Getting attribute + } else { + let attr = elem.getAttribute(key); + if (attr || attr === '0') { + attr = isNaN(attr) ? attr : (attr - 0); + } + return attr; + } + } else { + return proxied.call(this, key, value); + } + } + return this; + }; + return $; +} diff --git a/dist/common/layer.js b/dist/common/layer.js new file mode 100644 index 00000000..9cc31d79 --- /dev/null +++ b/dist/common/layer.js @@ -0,0 +1,222 @@ +/* globals jQuery */ +/** + * Provides tools for the layer concept. + * @module layer + * @license MIT + * + * @copyright 2011 Jeff Schiller, 2016 Flint O'Brien + */ + +import {NS} from './namespaces.js'; +import {toXml, walkTree, isNullish} from './utilities.js'; + +const $ = jQuery; + +/** + * This class encapsulates the concept of a layer in the drawing. It can be constructed with + * an existing group element or, with three parameters, will create a new layer group element. + * + * @example + * const l1 = new Layer('name', group); // Use the existing group for this layer. + * const l2 = new Layer('name', group, svgElem); // Create a new group and add it to the DOM after group. + * const l3 = new Layer('name', null, svgElem); // Create a new group and add it to the DOM as the last layer. + * @memberof module:layer + */ +class Layer { + /** + * @param {string} name - Layer name + * @param {SVGGElement|null} group - An existing SVG group element or null. + * If group and no svgElem, use group for this layer. + * If group and svgElem, create a new group element and insert it in the DOM after group. + * If no group and svgElem, create a new group element and insert it in the DOM as the last layer. + * @param {SVGGElement} [svgElem] - The SVG DOM element. If defined, use this to add + * a new layer to the document. + */ + constructor (name, group, svgElem) { + this.name_ = name; + this.group_ = svgElem ? null : group; + + if (svgElem) { + // Create a group element with title and add it to the DOM. + const svgdoc = svgElem.ownerDocument; + this.group_ = svgdoc.createElementNS(NS.SVG, 'g'); + const layerTitle = svgdoc.createElementNS(NS.SVG, 'title'); + layerTitle.textContent = name; + this.group_.append(layerTitle); + if (group) { + $(group).after(this.group_); + } else { + svgElem.append(this.group_); + } + } + + addLayerClass(this.group_); + walkTree(this.group_, function (e) { + e.setAttribute('style', 'pointer-events:inherit'); + }); + + this.group_.setAttribute('style', svgElem ? 'pointer-events:all' : 'pointer-events:none'); + } + + /** + * Get the layer's name. + * @returns {string} The layer name + */ + getName () { + return this.name_; + } + + /** + * Get the group element for this layer. + * @returns {SVGGElement} The layer SVG group + */ + getGroup () { + return this.group_; + } + + /** + * Active this layer so it takes pointer events. + * @returns {void} + */ + activate () { + this.group_.setAttribute('style', 'pointer-events:all'); + } + + /** + * Deactive this layer so it does NOT take pointer events. + * @returns {void} + */ + deactivate () { + this.group_.setAttribute('style', 'pointer-events:none'); + } + + /** + * Set this layer visible or hidden based on 'visible' parameter. + * @param {boolean} visible - If true, make visible; otherwise, hide it. + * @returns {void} + */ + setVisible (visible) { + const expected = visible === undefined || visible ? 'inline' : 'none'; + const oldDisplay = this.group_.getAttribute('display'); + if (oldDisplay !== expected) { + this.group_.setAttribute('display', expected); + } + } + + /** + * Is this layer visible? + * @returns {boolean} True if visible. + */ + isVisible () { + return this.group_.getAttribute('display') !== 'none'; + } + + /** + * Get layer opacity. + * @returns {Float} Opacity value. + */ + getOpacity () { + const opacity = this.group_.getAttribute('opacity'); + if (isNullish(opacity)) { + return 1; + } + return Number.parseFloat(opacity); + } + + /** + * Sets the opacity of this layer. If opacity is not a value between 0.0 and 1.0, + * nothing happens. + * @param {Float} opacity - A float value in the range 0.0-1.0 + * @returns {void} + */ + setOpacity (opacity) { + if (typeof opacity === 'number' && opacity >= 0.0 && opacity <= 1.0) { + this.group_.setAttribute('opacity', opacity); + } + } + + /** + * Append children to this layer. + * @param {SVGGElement} children - The children to append to this layer. + * @returns {void} + */ + appendChildren (children) { + for (const child of children) { + this.group_.append(child); + } + } + + /** + * @returns {SVGTitleElement|null} + */ + getTitleElement () { + const len = this.group_.childNodes.length; + for (let i = 0; i < len; ++i) { + const child = this.group_.childNodes.item(i); + if (child && child.tagName === 'title') { + return child; + } + } + return null; + } + + /** + * Set the name of this layer. + * @param {string} name - The new name. + * @param {module:history.HistoryRecordingService} hrService - History recording service + * @returns {string|null} The new name if changed; otherwise, null. + */ + setName (name, hrService) { + const previousName = this.name_; + name = toXml(name); + // now change the underlying title element contents + const title = this.getTitleElement(); + if (title) { + $(title).empty(); + title.textContent = name; + this.name_ = name; + if (hrService) { + hrService.changeElement(title, {'#text': previousName}); + } + return this.name_; + } + return null; + } + + /** + * Remove this layer's group from the DOM. No more functions on group can be called after this. + * @returns {SVGGElement} The layer SVG group that was just removed. + */ + removeGroup () { + const group = this.group_; + this.group_.remove(); + this.group_ = undefined; + return group; + } +} +/** + * @property {string} CLASS_NAME - class attribute assigned to all layer groups. + */ +Layer.CLASS_NAME = 'layer'; + +/** + * @property {RegExp} CLASS_REGEX - Used to test presence of class Layer.CLASS_NAME + */ +Layer.CLASS_REGEX = new RegExp('(\\s|^)' + Layer.CLASS_NAME + '(\\s|$)'); + +/** + * Add class `Layer.CLASS_NAME` to the element (usually `class='layer'`). + * + * @param {SVGGElement} elem - The SVG element to update + * @returns {void} + */ +function addLayerClass (elem) { + const classes = elem.getAttribute('class'); + if (isNullish(classes) || !classes.length) { + elem.setAttribute('class', Layer.CLASS_NAME); + } else if (!Layer.CLASS_REGEX.test(classes)) { + elem.setAttribute('class', classes + ' ' + Layer.CLASS_NAME); + } +} + +export default Layer; diff --git a/dist/common/math.js b/dist/common/math.js new file mode 100644 index 00000000..0d474381 --- /dev/null +++ b/dist/common/math.js @@ -0,0 +1,222 @@ +/** + * Mathematical utilities. + * @module math + * @license MIT + * + * @copyright 2010 Alexis Deveria, 2010 Jeff Schiller + */ + +/** +* @typedef {PlainObject} module:math.AngleCoord45 +* @property {Float} x - The angle-snapped x value +* @property {Float} y - The angle-snapped y value +* @property {Integer} a - The angle at which to snap +*/ + +/** +* @typedef {PlainObject} module:math.XYObject +* @property {Float} x +* @property {Float} y +*/ + +import {NS} from './namespaces.js'; +import {getTransformList} from './svgtransformlist.js'; + +// Constants +const NEAR_ZERO = 1e-14; + +// Throw away SVGSVGElement used for creating matrices/transforms. +const svg = document.createElementNS(NS.SVG, 'svg'); + +/** + * A (hopefully) quicker function to transform a point by a matrix + * (this function avoids any DOM calls and just does the math). + * @function module:math.transformPoint + * @param {Float} x - Float representing the x coordinate + * @param {Float} y - Float representing the y coordinate + * @param {SVGMatrix} m - Matrix object to transform the point with + * @returns {module:math.XYObject} An x, y object representing the transformed point +*/ +export const transformPoint = function (x, y, m) { + return {x: m.a * x + m.c * y + m.e, y: m.b * x + m.d * y + m.f}; +}; + +/** + * Helper function to check if the matrix performs no actual transform + * (i.e. exists for identity purposes). + * @function module:math.isIdentity + * @param {SVGMatrix} m - The matrix object to check + * @returns {boolean} Indicates whether or not the matrix is 1,0,0,1,0,0 +*/ +export const isIdentity = function (m) { + return (m.a === 1 && m.b === 0 && m.c === 0 && m.d === 1 && m.e === 0 && m.f === 0); +}; + +/** + * This function tries to return a `SVGMatrix` that is the multiplication `m1 * m2`. + * We also round to zero when it's near zero. + * @function module:math.matrixMultiply + * @param {...SVGMatrix} args - Matrix objects to multiply + * @returns {SVGMatrix} The matrix object resulting from the calculation +*/ +export const matrixMultiply = function (...args) { + const m = args.reduceRight((prev, m1) => { + return m1.multiply(prev); + }); + + if (Math.abs(m.a) < NEAR_ZERO) { m.a = 0; } + if (Math.abs(m.b) < NEAR_ZERO) { m.b = 0; } + if (Math.abs(m.c) < NEAR_ZERO) { m.c = 0; } + if (Math.abs(m.d) < NEAR_ZERO) { m.d = 0; } + if (Math.abs(m.e) < NEAR_ZERO) { m.e = 0; } + if (Math.abs(m.f) < NEAR_ZERO) { m.f = 0; } + + return m; +}; + +/** + * See if the given transformlist includes a non-indentity matrix transform. + * @function module:math.hasMatrixTransform + * @param {SVGTransformList} [tlist] - The transformlist to check + * @returns {boolean} Whether or not a matrix transform was found +*/ +export const hasMatrixTransform = function (tlist) { + if (!tlist) { return false; } + let num = tlist.numberOfItems; + while (num--) { + const xform = tlist.getItem(num); + if (xform.type === 1 && !isIdentity(xform.matrix)) { return true; } + } + return false; +}; + +/** +* @typedef {PlainObject} module:math.TransformedBox An object with the following values +* @property {module:math.XYObject} tl - The top left coordinate +* @property {module:math.XYObject} tr - The top right coordinate +* @property {module:math.XYObject} bl - The bottom left coordinate +* @property {module:math.XYObject} br - The bottom right coordinate +* @property {PlainObject} aabox - Object with the following values: +* @property {Float} aabox.x - Float with the axis-aligned x coordinate +* @property {Float} aabox.y - Float with the axis-aligned y coordinate +* @property {Float} aabox.width - Float with the axis-aligned width coordinate +* @property {Float} aabox.height - Float with the axis-aligned height coordinate +*/ + +/** + * Transforms a rectangle based on the given matrix. + * @function module:math.transformBox + * @param {Float} l - Float with the box's left coordinate + * @param {Float} t - Float with the box's top coordinate + * @param {Float} w - Float with the box width + * @param {Float} h - Float with the box height + * @param {SVGMatrix} m - Matrix object to transform the box by + * @returns {module:math.TransformedBox} +*/ +export const transformBox = function (l, t, w, h, m) { + const tl = transformPoint(l, t, m), + tr = transformPoint((l + w), t, m), + bl = transformPoint(l, (t + h), m), + br = transformPoint((l + w), (t + h), m), + + minx = Math.min(tl.x, tr.x, bl.x, br.x), + maxx = Math.max(tl.x, tr.x, bl.x, br.x), + miny = Math.min(tl.y, tr.y, bl.y, br.y), + maxy = Math.max(tl.y, tr.y, bl.y, br.y); + + return { + tl, + tr, + bl, + br, + aabox: { + x: minx, + y: miny, + width: (maxx - minx), + height: (maxy - miny) + } + }; +}; + +/** + * This returns a single matrix Transform for a given Transform List + * (this is the equivalent of `SVGTransformList.consolidate()` but unlike + * that method, this one does not modify the actual `SVGTransformList`). + * This function is very liberal with its `min`, `max` arguments. + * @function module:math.transformListToTransform + * @param {SVGTransformList} tlist - The transformlist object + * @param {Integer} [min=0] - Optional integer indicating start transform position + * @param {Integer} [max] - Optional integer indicating end transform position; + * defaults to one less than the tlist's `numberOfItems` + * @returns {SVGTransform} A single matrix transform object +*/ +export const transformListToTransform = function (tlist, min, max) { + if (!tlist) { + // Or should tlist = null have been prevented before this? + return svg.createSVGTransformFromMatrix(svg.createSVGMatrix()); + } + min = min || 0; + max = max || (tlist.numberOfItems - 1); + min = Number.parseInt(min); + max = Number.parseInt(max); + if (min > max) { const temp = max; max = min; min = temp; } + let m = svg.createSVGMatrix(); + for (let i = min; i <= max; ++i) { + // if our indices are out of range, just use a harmless identity matrix + const mtom = (i >= 0 && i < tlist.numberOfItems + ? tlist.getItem(i).matrix + : svg.createSVGMatrix()); + m = matrixMultiply(m, mtom); + } + return svg.createSVGTransformFromMatrix(m); +}; + +/** + * Get the matrix object for a given element. + * @function module:math.getMatrix + * @param {Element} elem - The DOM element to check + * @returns {SVGMatrix} The matrix object associated with the element's transformlist +*/ +export const getMatrix = function (elem) { + const tlist = getTransformList(elem); + return transformListToTransform(tlist).matrix; +}; + +/** + * Returns a 45 degree angle coordinate associated with the two given + * coordinates. + * @function module:math.snapToAngle + * @param {Integer} x1 - First coordinate's x value + * @param {Integer} y1 - First coordinate's y value + * @param {Integer} x2 - Second coordinate's x value + * @param {Integer} y2 - Second coordinate's y value + * @returns {module:math.AngleCoord45} +*/ +export const snapToAngle = function (x1, y1, x2, y2) { + const snap = Math.PI / 4; // 45 degrees + const dx = x2 - x1; + const dy = y2 - y1; + const angle = Math.atan2(dy, dx); + const dist = Math.sqrt(dx * dx + dy * dy); + const snapangle = Math.round(angle / snap) * snap; + + return { + x: x1 + dist * Math.cos(snapangle), + y: y1 + dist * Math.sin(snapangle), + a: snapangle + }; +}; + +/** + * Check if two rectangles (BBoxes objects) intersect each other. + * @function module:math.rectsIntersect + * @param {SVGRect} r1 - The first BBox-like object + * @param {SVGRect} r2 - The second BBox-like object + * @returns {boolean} True if rectangles intersect + */ +export const rectsIntersect = function (r1, r2) { + return r2.x < (r1.x + r1.width) && + (r2.x + r2.width) > r1.x && + r2.y < (r1.y + r1.height) && + (r2.y + r2.height) > r1.y; +}; diff --git a/dist/common/namespaces.js b/dist/common/namespaces.js new file mode 100644 index 00000000..2658760f --- /dev/null +++ b/dist/common/namespaces.js @@ -0,0 +1,33 @@ +/** + * Namespaces or tools therefor. + * @module namespaces + * @license MIT +*/ + +/** +* Common namepaces constants in alpha order. +* @enum {string} +* @type {PlainObject} +* @memberof module:namespaces +*/ +export const NS = { + HTML: 'http://www.w3.org/1999/xhtml', + MATH: 'http://www.w3.org/1998/Math/MathML', + SE: 'http://svg-edit.googlecode.com', + SVG: 'http://www.w3.org/2000/svg', + XLINK: 'http://www.w3.org/1999/xlink', + XML: 'http://www.w3.org/XML/1998/namespace', + XMLNS: 'http://www.w3.org/2000/xmlns/' // see http://www.w3.org/TR/REC-xml-names/#xmlReserved +}; + +/** +* @function module:namespaces.getReverseNS +* @returns {string} The NS with key values switched and lowercase +*/ +export const getReverseNS = function () { + const reverseNS = {}; + Object.entries(NS).forEach(([name, URI]) => { + reverseNS[URI] = name.toLowerCase(); + }); + return reverseNS; +}; diff --git a/dist/common/svgpathseg.js b/dist/common/svgpathseg.js new file mode 100644 index 00000000..b78362f6 --- /dev/null +++ b/dist/common/svgpathseg.js @@ -0,0 +1,972 @@ +/* eslint-disable import/unambiguous, max-len */ +/* globals SVGPathSeg, SVGPathSegMovetoRel, SVGPathSegMovetoAbs, + SVGPathSegMovetoRel, SVGPathSegLinetoRel, SVGPathSegLinetoAbs, + SVGPathSegLinetoHorizontalRel, SVGPathSegLinetoHorizontalAbs, + SVGPathSegLinetoVerticalRel, SVGPathSegLinetoVerticalAbs, + SVGPathSegClosePath, SVGPathSegCurvetoCubicRel, + SVGPathSegCurvetoCubicAbs, SVGPathSegCurvetoCubicSmoothRel, + SVGPathSegCurvetoCubicSmoothAbs, SVGPathSegCurvetoQuadraticRel, + SVGPathSegCurvetoQuadraticAbs, SVGPathSegCurvetoQuadraticSmoothRel, + SVGPathSegCurvetoQuadraticSmoothAbs, SVGPathSegArcRel, SVGPathSegArcAbs */ +/** +* SVGPathSeg API polyfill +* https://github.com/progers/pathseg +* +* This is a drop-in replacement for the `SVGPathSeg` and `SVGPathSegList` APIs +* that were removed from SVG2 ({@link https://lists.w3.org/Archives/Public/www-svg/2015Jun/0044.html}), +* including the latest spec changes which were implemented in Firefox 43 and +* Chrome 46. +*/ +/* eslint-disable no-shadow, class-methods-use-this, jsdoc/require-jsdoc */ +// Linting: We avoid `no-shadow` as ESLint thinks these are still available globals +// Linting: We avoid `class-methods-use-this` as this is a polyfill that must +// follow the conventions +(() => { +if (!('SVGPathSeg' in window)) { + // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathSeg + class SVGPathSeg { + constructor (type, typeAsLetter, owningPathSegList) { + this.pathSegType = type; + this.pathSegTypeAsLetter = typeAsLetter; + this._owningPathSegList = owningPathSegList; + } + // Notify owning PathSegList on any changes so they can be synchronized back to the path element. + _segmentChanged () { + if (this._owningPathSegList) { + this._owningPathSegList.segmentChanged(this); + } + } + } + SVGPathSeg.prototype.classname = 'SVGPathSeg'; + + SVGPathSeg.PATHSEG_UNKNOWN = 0; + SVGPathSeg.PATHSEG_CLOSEPATH = 1; + SVGPathSeg.PATHSEG_MOVETO_ABS = 2; + SVGPathSeg.PATHSEG_MOVETO_REL = 3; + SVGPathSeg.PATHSEG_LINETO_ABS = 4; + SVGPathSeg.PATHSEG_LINETO_REL = 5; + SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS = 6; + SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL = 7; + SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS = 8; + SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL = 9; + SVGPathSeg.PATHSEG_ARC_ABS = 10; + SVGPathSeg.PATHSEG_ARC_REL = 11; + SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS = 12; + SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL = 13; + SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS = 14; + SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL = 15; + SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS = 16; + SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL = 17; + SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS = 18; + SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = 19; + + class SVGPathSegClosePath extends SVGPathSeg { + constructor (owningPathSegList) { + super(SVGPathSeg.PATHSEG_CLOSEPATH, 'z', owningPathSegList); + } + toString () { return '[object SVGPathSegClosePath]'; } + _asPathString () { return this.pathSegTypeAsLetter; } + clone () { return new SVGPathSegClosePath(undefined); } + } + + class SVGPathSegMovetoAbs extends SVGPathSeg { + constructor (owningPathSegList, x, y) { + super(SVGPathSeg.PATHSEG_MOVETO_ABS, 'M', owningPathSegList); + this._x = x; + this._y = y; + } + toString () { return '[object SVGPathSegMovetoAbs]'; } + _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; } + clone () { return new SVGPathSegMovetoAbs(undefined, this._x, this._y); } + } + Object.defineProperties(SVGPathSegMovetoAbs.prototype, { + x: { + get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true + }, + y: { + get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true + } + }); + + class SVGPathSegMovetoRel extends SVGPathSeg { + constructor (owningPathSegList, x, y) { + super(SVGPathSeg.PATHSEG_MOVETO_REL, 'm', owningPathSegList); + this._x = x; + this._y = y; + } + toString () { return '[object SVGPathSegMovetoRel]'; } + _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; } + clone () { return new SVGPathSegMovetoRel(undefined, this._x, this._y); } + } + Object.defineProperties(SVGPathSegMovetoRel.prototype, { + x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true}, + y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true} + }); + + class SVGPathSegLinetoAbs extends SVGPathSeg { + constructor (owningPathSegList, x, y) { + super(SVGPathSeg.PATHSEG_LINETO_ABS, 'L', owningPathSegList); + this._x = x; + this._y = y; + } + toString () { return '[object SVGPathSegLinetoAbs]'; } + _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; } + clone () { return new SVGPathSegLinetoAbs(undefined, this._x, this._y); } + } + Object.defineProperties(SVGPathSegLinetoAbs.prototype, { + x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true}, + y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true} + }); + + class SVGPathSegLinetoRel extends SVGPathSeg { + constructor (owningPathSegList, x, y) { + super(SVGPathSeg.PATHSEG_LINETO_REL, 'l', owningPathSegList); + this._x = x; + this._y = y; + } + toString () { return '[object SVGPathSegLinetoRel]'; } + _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; } + clone () { return new SVGPathSegLinetoRel(undefined, this._x, this._y); } + } + Object.defineProperties(SVGPathSegLinetoRel.prototype, { + x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true}, + y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true} + }); + + class SVGPathSegCurvetoCubicAbs extends SVGPathSeg { + constructor (owningPathSegList, x, y, x1, y1, x2, y2) { + super(SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS, 'C', owningPathSegList); + this._x = x; + this._y = y; + this._x1 = x1; + this._y1 = y1; + this._x2 = x2; + this._y2 = y2; + } + toString () { return '[object SVGPathSegCurvetoCubicAbs]'; } + _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x1 + ' ' + this._y1 + ' ' + this._x2 + ' ' + this._y2 + ' ' + this._x + ' ' + this._y; } + clone () { return new SVGPathSegCurvetoCubicAbs(undefined, this._x, this._y, this._x1, this._y1, this._x2, this._y2); } + } + Object.defineProperties(SVGPathSegCurvetoCubicAbs.prototype, { + x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true}, + y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true}, + x1: {get () { return this._x1; }, set (x1) { this._x1 = x1; this._segmentChanged(); }, enumerable: true}, + y1: {get () { return this._y1; }, set (y1) { this._y1 = y1; this._segmentChanged(); }, enumerable: true}, + x2: {get () { return this._x2; }, set (x2) { this._x2 = x2; this._segmentChanged(); }, enumerable: true}, + y2: {get () { return this._y2; }, set (y2) { this._y2 = y2; this._segmentChanged(); }, enumerable: true} + }); + + class SVGPathSegCurvetoCubicRel extends SVGPathSeg { + constructor (owningPathSegList, x, y, x1, y1, x2, y2) { + super(SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL, 'c', owningPathSegList); + this._x = x; + this._y = y; + this._x1 = x1; + this._y1 = y1; + this._x2 = x2; + this._y2 = y2; + } + toString () { return '[object SVGPathSegCurvetoCubicRel]'; } + _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x1 + ' ' + this._y1 + ' ' + this._x2 + ' ' + this._y2 + ' ' + this._x + ' ' + this._y; } + clone () { return new SVGPathSegCurvetoCubicRel(undefined, this._x, this._y, this._x1, this._y1, this._x2, this._y2); } + } + Object.defineProperties(SVGPathSegCurvetoCubicRel.prototype, { + x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true}, + y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true}, + x1: {get () { return this._x1; }, set (x1) { this._x1 = x1; this._segmentChanged(); }, enumerable: true}, + y1: {get () { return this._y1; }, set (y1) { this._y1 = y1; this._segmentChanged(); }, enumerable: true}, + x2: {get () { return this._x2; }, set (x2) { this._x2 = x2; this._segmentChanged(); }, enumerable: true}, + y2: {get () { return this._y2; }, set (y2) { this._y2 = y2; this._segmentChanged(); }, enumerable: true} + }); + + class SVGPathSegCurvetoQuadraticAbs extends SVGPathSeg { + constructor (owningPathSegList, x, y, x1, y1) { + super(SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS, 'Q', owningPathSegList); + this._x = x; + this._y = y; + this._x1 = x1; + this._y1 = y1; + } + toString () { return '[object SVGPathSegCurvetoQuadraticAbs]'; } + _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x1 + ' ' + this._y1 + ' ' + this._x + ' ' + this._y; } + clone () { return new SVGPathSegCurvetoQuadraticAbs(undefined, this._x, this._y, this._x1, this._y1); } + } + Object.defineProperties(SVGPathSegCurvetoQuadraticAbs.prototype, { + x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true}, + y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true}, + x1: {get () { return this._x1; }, set (x1) { this._x1 = x1; this._segmentChanged(); }, enumerable: true}, + y1: {get () { return this._y1; }, set (y1) { this._y1 = y1; this._segmentChanged(); }, enumerable: true} + }); + + class SVGPathSegCurvetoQuadraticRel extends SVGPathSeg { + constructor (owningPathSegList, x, y, x1, y1) { + super(SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL, 'q', owningPathSegList); + this._x = x; + this._y = y; + this._x1 = x1; + this._y1 = y1; + } + toString () { return '[object SVGPathSegCurvetoQuadraticRel]'; } + _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x1 + ' ' + this._y1 + ' ' + this._x + ' ' + this._y; } + clone () { return new SVGPathSegCurvetoQuadraticRel(undefined, this._x, this._y, this._x1, this._y1); } + } + Object.defineProperties(SVGPathSegCurvetoQuadraticRel.prototype, { + x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true}, + y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true}, + x1: {get () { return this._x1; }, set (x1) { this._x1 = x1; this._segmentChanged(); }, enumerable: true}, + y1: {get () { return this._y1; }, set (y1) { this._y1 = y1; this._segmentChanged(); }, enumerable: true} + }); + + class SVGPathSegArcAbs extends SVGPathSeg { + constructor (owningPathSegList, x, y, r1, r2, angle, largeArcFlag, sweepFlag) { + super(SVGPathSeg.PATHSEG_ARC_ABS, 'A', owningPathSegList); + this._x = x; + this._y = y; + this._r1 = r1; + this._r2 = r2; + this._angle = angle; + this._largeArcFlag = largeArcFlag; + this._sweepFlag = sweepFlag; + } + toString () { return '[object SVGPathSegArcAbs]'; } + _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._r1 + ' ' + this._r2 + ' ' + this._angle + ' ' + (this._largeArcFlag ? '1' : '0') + ' ' + (this._sweepFlag ? '1' : '0') + ' ' + this._x + ' ' + this._y; } + clone () { return new SVGPathSegArcAbs(undefined, this._x, this._y, this._r1, this._r2, this._angle, this._largeArcFlag, this._sweepFlag); } + } + Object.defineProperties(SVGPathSegArcAbs.prototype, { + x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true}, + y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true}, + r1: {get () { return this._r1; }, set (r1) { this._r1 = r1; this._segmentChanged(); }, enumerable: true}, + r2: {get () { return this._r2; }, set (r2) { this._r2 = r2; this._segmentChanged(); }, enumerable: true}, + angle: {get () { return this._angle; }, set (angle) { this._angle = angle; this._segmentChanged(); }, enumerable: true}, + largeArcFlag: {get () { return this._largeArcFlag; }, set (largeArcFlag) { this._largeArcFlag = largeArcFlag; this._segmentChanged(); }, enumerable: true}, + sweepFlag: {get () { return this._sweepFlag; }, set (sweepFlag) { this._sweepFlag = sweepFlag; this._segmentChanged(); }, enumerable: true} + }); + + class SVGPathSegArcRel extends SVGPathSeg { + constructor (owningPathSegList, x, y, r1, r2, angle, largeArcFlag, sweepFlag) { + super(SVGPathSeg.PATHSEG_ARC_REL, 'a', owningPathSegList); + this._x = x; + this._y = y; + this._r1 = r1; + this._r2 = r2; + this._angle = angle; + this._largeArcFlag = largeArcFlag; + this._sweepFlag = sweepFlag; + } + toString () { return '[object SVGPathSegArcRel]'; } + _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._r1 + ' ' + this._r2 + ' ' + this._angle + ' ' + (this._largeArcFlag ? '1' : '0') + ' ' + (this._sweepFlag ? '1' : '0') + ' ' + this._x + ' ' + this._y; } + clone () { return new SVGPathSegArcRel(undefined, this._x, this._y, this._r1, this._r2, this._angle, this._largeArcFlag, this._sweepFlag); } + } + Object.defineProperties(SVGPathSegArcRel.prototype, { + x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true}, + y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true}, + r1: {get () { return this._r1; }, set (r1) { this._r1 = r1; this._segmentChanged(); }, enumerable: true}, + r2: {get () { return this._r2; }, set (r2) { this._r2 = r2; this._segmentChanged(); }, enumerable: true}, + angle: {get () { return this._angle; }, set (angle) { this._angle = angle; this._segmentChanged(); }, enumerable: true}, + largeArcFlag: {get () { return this._largeArcFlag; }, set (largeArcFlag) { this._largeArcFlag = largeArcFlag; this._segmentChanged(); }, enumerable: true}, + sweepFlag: {get () { return this._sweepFlag; }, set (sweepFlag) { this._sweepFlag = sweepFlag; this._segmentChanged(); }, enumerable: true} + }); + + class SVGPathSegLinetoHorizontalAbs extends SVGPathSeg { + constructor (owningPathSegList, x) { + super(SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS, 'H', owningPathSegList); + this._x = x; + } + toString () { return '[object SVGPathSegLinetoHorizontalAbs]'; } + _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x; } + clone () { return new SVGPathSegLinetoHorizontalAbs(undefined, this._x); } + } + Object.defineProperty(SVGPathSegLinetoHorizontalAbs.prototype, 'x', {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true}); + + class SVGPathSegLinetoHorizontalRel extends SVGPathSeg { + constructor (owningPathSegList, x) { + super(SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL, 'h', owningPathSegList); + this._x = x; + } + toString () { return '[object SVGPathSegLinetoHorizontalRel]'; } + _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x; } + clone () { return new SVGPathSegLinetoHorizontalRel(undefined, this._x); } + } + Object.defineProperty(SVGPathSegLinetoHorizontalRel.prototype, 'x', {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true}); + + class SVGPathSegLinetoVerticalAbs extends SVGPathSeg { + constructor (owningPathSegList, y) { + super(SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS, 'V', owningPathSegList); + this._y = y; + } + toString () { return '[object SVGPathSegLinetoVerticalAbs]'; } + _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._y; } + clone () { return new SVGPathSegLinetoVerticalAbs(undefined, this._y); } + } + Object.defineProperty(SVGPathSegLinetoVerticalAbs.prototype, 'y', {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true}); + + class SVGPathSegLinetoVerticalRel extends SVGPathSeg { + constructor (owningPathSegList, y) { + super(SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL, 'v', owningPathSegList); + this._y = y; + } + toString () { return '[object SVGPathSegLinetoVerticalRel]'; } + _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._y; } + clone () { return new SVGPathSegLinetoVerticalRel(undefined, this._y); } + } + Object.defineProperty(SVGPathSegLinetoVerticalRel.prototype, 'y', {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true}); + + class SVGPathSegCurvetoCubicSmoothAbs extends SVGPathSeg { + constructor (owningPathSegList, x, y, x2, y2) { + super(SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS, 'S', owningPathSegList); + this._x = x; + this._y = y; + this._x2 = x2; + this._y2 = y2; + } + toString () { return '[object SVGPathSegCurvetoCubicSmoothAbs]'; } + _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x2 + ' ' + this._y2 + ' ' + this._x + ' ' + this._y; } + clone () { return new SVGPathSegCurvetoCubicSmoothAbs(undefined, this._x, this._y, this._x2, this._y2); } + } + Object.defineProperties(SVGPathSegCurvetoCubicSmoothAbs.prototype, { + x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true}, + y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true}, + x2: {get () { return this._x2; }, set (x2) { this._x2 = x2; this._segmentChanged(); }, enumerable: true}, + y2: {get () { return this._y2; }, set (y2) { this._y2 = y2; this._segmentChanged(); }, enumerable: true} + }); + + class SVGPathSegCurvetoCubicSmoothRel extends SVGPathSeg { + constructor (owningPathSegList, x, y, x2, y2) { + super(SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL, 's', owningPathSegList); + this._x = x; + this._y = y; + this._x2 = x2; + this._y2 = y2; + } + toString () { return '[object SVGPathSegCurvetoCubicSmoothRel]'; } + _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x2 + ' ' + this._y2 + ' ' + this._x + ' ' + this._y; } + clone () { return new SVGPathSegCurvetoCubicSmoothRel(undefined, this._x, this._y, this._x2, this._y2); } + } + Object.defineProperties(SVGPathSegCurvetoCubicSmoothRel.prototype, { + x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true}, + y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true}, + x2: {get () { return this._x2; }, set (x2) { this._x2 = x2; this._segmentChanged(); }, enumerable: true}, + y2: {get () { return this._y2; }, set (y2) { this._y2 = y2; this._segmentChanged(); }, enumerable: true} + }); + + class SVGPathSegCurvetoQuadraticSmoothAbs extends SVGPathSeg { + constructor (owningPathSegList, x, y) { + super(SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS, 'T', owningPathSegList); + this._x = x; + this._y = y; + } + toString () { return '[object SVGPathSegCurvetoQuadraticSmoothAbs]'; } + _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; } + clone () { return new SVGPathSegCurvetoQuadraticSmoothAbs(undefined, this._x, this._y); } + } + Object.defineProperties(SVGPathSegCurvetoQuadraticSmoothAbs.prototype, { + x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true}, + y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true} + }); + + class SVGPathSegCurvetoQuadraticSmoothRel extends SVGPathSeg { + constructor (owningPathSegList, x, y) { + super(SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL, 't', owningPathSegList); + this._x = x; + this._y = y; + } + toString () { return '[object SVGPathSegCurvetoQuadraticSmoothRel]'; } + _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; } + clone () { return new SVGPathSegCurvetoQuadraticSmoothRel(undefined, this._x, this._y); } + } + Object.defineProperties(SVGPathSegCurvetoQuadraticSmoothRel.prototype, { + x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true}, + y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true} + }); + + // Add createSVGPathSeg* functions to SVGPathElement. + // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathElement. + SVGPathElement.prototype.createSVGPathSegClosePath = function () { return new SVGPathSegClosePath(undefined); }; + SVGPathElement.prototype.createSVGPathSegMovetoAbs = function (x, y) { return new SVGPathSegMovetoAbs(undefined, x, y); }; + SVGPathElement.prototype.createSVGPathSegMovetoRel = function (x, y) { return new SVGPathSegMovetoRel(undefined, x, y); }; + SVGPathElement.prototype.createSVGPathSegLinetoAbs = function (x, y) { return new SVGPathSegLinetoAbs(undefined, x, y); }; + SVGPathElement.prototype.createSVGPathSegLinetoRel = function (x, y) { return new SVGPathSegLinetoRel(undefined, x, y); }; + SVGPathElement.prototype.createSVGPathSegCurvetoCubicAbs = function (x, y, x1, y1, x2, y2) { return new SVGPathSegCurvetoCubicAbs(undefined, x, y, x1, y1, x2, y2); }; + SVGPathElement.prototype.createSVGPathSegCurvetoCubicRel = function (x, y, x1, y1, x2, y2) { return new SVGPathSegCurvetoCubicRel(undefined, x, y, x1, y1, x2, y2); }; + SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticAbs = function (x, y, x1, y1) { return new SVGPathSegCurvetoQuadraticAbs(undefined, x, y, x1, y1); }; + SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticRel = function (x, y, x1, y1) { return new SVGPathSegCurvetoQuadraticRel(undefined, x, y, x1, y1); }; + SVGPathElement.prototype.createSVGPathSegArcAbs = function (x, y, r1, r2, angle, largeArcFlag, sweepFlag) { return new SVGPathSegArcAbs(undefined, x, y, r1, r2, angle, largeArcFlag, sweepFlag); }; + SVGPathElement.prototype.createSVGPathSegArcRel = function (x, y, r1, r2, angle, largeArcFlag, sweepFlag) { return new SVGPathSegArcRel(undefined, x, y, r1, r2, angle, largeArcFlag, sweepFlag); }; + SVGPathElement.prototype.createSVGPathSegLinetoHorizontalAbs = function (x) { return new SVGPathSegLinetoHorizontalAbs(undefined, x); }; + SVGPathElement.prototype.createSVGPathSegLinetoHorizontalRel = function (x) { return new SVGPathSegLinetoHorizontalRel(undefined, x); }; + SVGPathElement.prototype.createSVGPathSegLinetoVerticalAbs = function (y) { return new SVGPathSegLinetoVerticalAbs(undefined, y); }; + SVGPathElement.prototype.createSVGPathSegLinetoVerticalRel = function (y) { return new SVGPathSegLinetoVerticalRel(undefined, y); }; + SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothAbs = function (x, y, x2, y2) { return new SVGPathSegCurvetoCubicSmoothAbs(undefined, x, y, x2, y2); }; + SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothRel = function (x, y, x2, y2) { return new SVGPathSegCurvetoCubicSmoothRel(undefined, x, y, x2, y2); }; + SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothAbs = function (x, y) { return new SVGPathSegCurvetoQuadraticSmoothAbs(undefined, x, y); }; + SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothRel = function (x, y) { return new SVGPathSegCurvetoQuadraticSmoothRel(undefined, x, y); }; + + if (!('getPathSegAtLength' in SVGPathElement.prototype)) { + // Add getPathSegAtLength to SVGPathElement. + // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-__svg__SVGPathElement__getPathSegAtLength + // This polyfill requires SVGPathElement.getTotalLength to implement the distance-along-a-path algorithm. + SVGPathElement.prototype.getPathSegAtLength = function (distance) { + if (distance === undefined || !isFinite(distance)) { + throw new Error('Invalid arguments.'); + } + + const measurementElement = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + measurementElement.setAttribute('d', this.getAttribute('d')); + let lastPathSegment = measurementElement.pathSegList.numberOfItems - 1; + + // If the path is empty, return 0. + if (lastPathSegment <= 0) { + return 0; + } + + do { + measurementElement.pathSegList.removeItem(lastPathSegment); + if (distance > measurementElement.getTotalLength()) { + break; + } + lastPathSegment--; + } while (lastPathSegment > 0); + return lastPathSegment; + }; + } + + window.SVGPathSeg = SVGPathSeg; + window.SVGPathSegClosePath = SVGPathSegClosePath; + window.SVGPathSegMovetoAbs = SVGPathSegMovetoAbs; + window.SVGPathSegMovetoRel = SVGPathSegMovetoRel; + window.SVGPathSegLinetoAbs = SVGPathSegLinetoAbs; + window.SVGPathSegLinetoRel = SVGPathSegLinetoRel; + window.SVGPathSegCurvetoCubicAbs = SVGPathSegCurvetoCubicAbs; + window.SVGPathSegCurvetoCubicRel = SVGPathSegCurvetoCubicRel; + window.SVGPathSegCurvetoQuadraticAbs = SVGPathSegCurvetoQuadraticAbs; + window.SVGPathSegCurvetoQuadraticRel = SVGPathSegCurvetoQuadraticRel; + window.SVGPathSegArcAbs = SVGPathSegArcAbs; + window.SVGPathSegArcRel = SVGPathSegArcRel; + window.SVGPathSegLinetoHorizontalAbs = SVGPathSegLinetoHorizontalAbs; + window.SVGPathSegLinetoHorizontalRel = SVGPathSegLinetoHorizontalRel; + window.SVGPathSegLinetoVerticalAbs = SVGPathSegLinetoVerticalAbs; + window.SVGPathSegLinetoVerticalRel = SVGPathSegLinetoVerticalRel; + window.SVGPathSegCurvetoCubicSmoothAbs = SVGPathSegCurvetoCubicSmoothAbs; + window.SVGPathSegCurvetoCubicSmoothRel = SVGPathSegCurvetoCubicSmoothRel; + window.SVGPathSegCurvetoQuadraticSmoothAbs = SVGPathSegCurvetoQuadraticSmoothAbs; + window.SVGPathSegCurvetoQuadraticSmoothRel = SVGPathSegCurvetoQuadraticSmoothRel; +} + +// Checking for SVGPathSegList in window checks for the case of an implementation without the +// SVGPathSegList API. +// The second check for appendItem is specific to Firefox 59+ which removed only parts of the +// SVGPathSegList API (e.g., appendItem). In this case we need to re-implement the entire API +// so the polyfill data (i.e., _list) is used throughout. +if (!('SVGPathSegList' in window) || !('appendItem' in window.SVGPathSegList.prototype)) { + // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathSegList + class SVGPathSegList { + constructor (pathElement) { + this._pathElement = pathElement; + this._list = this._parsePath(this._pathElement.getAttribute('d')); + + // Use a MutationObserver to catch changes to the path's "d" attribute. + this._mutationObserverConfig = {attributes: true, attributeFilter: ['d']}; + this._pathElementMutationObserver = new MutationObserver(this._updateListFromPathMutations.bind(this)); + this._pathElementMutationObserver.observe(this._pathElement, this._mutationObserverConfig); + } + // Process any pending mutations to the path element and update the list as needed. + // This should be the first call of all public functions and is needed because + // MutationObservers are not synchronous so we can have pending asynchronous mutations. + _checkPathSynchronizedToList () { + this._updateListFromPathMutations(this._pathElementMutationObserver.takeRecords()); + } + + _updateListFromPathMutations (mutationRecords) { + if (!this._pathElement) { + return; + } + let hasPathMutations = false; + mutationRecords.forEach((record) => { + if (record.attributeName === 'd') { + hasPathMutations = true; + } + }); + if (hasPathMutations) { + this._list = this._parsePath(this._pathElement.getAttribute('d')); + } + } + + // Serialize the list and update the path's 'd' attribute. + _writeListToPath () { + this._pathElementMutationObserver.disconnect(); + this._pathElement.setAttribute('d', SVGPathSegList._pathSegArrayAsString(this._list)); + this._pathElementMutationObserver.observe(this._pathElement, this._mutationObserverConfig); + } + + // When a path segment changes the list needs to be synchronized back to the path element. + segmentChanged (pathSeg) { + this._writeListToPath(); + } + + clear () { + this._checkPathSynchronizedToList(); + + this._list.forEach((pathSeg) => { + pathSeg._owningPathSegList = null; + }); + this._list = []; + this._writeListToPath(); + } + + initialize (newItem) { + this._checkPathSynchronizedToList(); + + this._list = [newItem]; + newItem._owningPathSegList = this; + this._writeListToPath(); + return newItem; + } + + _checkValidIndex (index) { + if (isNaN(index) || index < 0 || index >= this.numberOfItems) { + throw new Error('INDEX_SIZE_ERR'); + } + } + + getItem (index) { + this._checkPathSynchronizedToList(); + + this._checkValidIndex(index); + return this._list[index]; + } + + insertItemBefore (newItem, index) { + this._checkPathSynchronizedToList(); + + // Spec: If the index is greater than or equal to numberOfItems, then the new item is appended to the end of the list. + if (index > this.numberOfItems) { + index = this.numberOfItems; + } + if (newItem._owningPathSegList) { + // SVG2 spec says to make a copy. + newItem = newItem.clone(); + } + this._list.splice(index, 0, newItem); + newItem._owningPathSegList = this; + this._writeListToPath(); + return newItem; + } + + replaceItem (newItem, index) { + this._checkPathSynchronizedToList(); + + if (newItem._owningPathSegList) { + // SVG2 spec says to make a copy. + newItem = newItem.clone(); + } + this._checkValidIndex(index); + this._list[index] = newItem; + newItem._owningPathSegList = this; + this._writeListToPath(); + return newItem; + } + + removeItem (index) { + this._checkPathSynchronizedToList(); + + this._checkValidIndex(index); + const item = this._list[index]; + this._list.splice(index, 1); + this._writeListToPath(); + return item; + } + + appendItem (newItem) { + this._checkPathSynchronizedToList(); + + if (newItem._owningPathSegList) { + // SVG2 spec says to make a copy. + newItem = newItem.clone(); + } + this._list.push(newItem); + newItem._owningPathSegList = this; + // TODO: Optimize this to just append to the existing attribute. + this._writeListToPath(); + return newItem; + } + + // This closely follows SVGPathParser::parsePath from Source/core/svg/SVGPathParser.cpp. + _parsePath (string) { + if (!string || !string.length) { + return []; + } + + const owningPathSegList = this; + + class Builder { + constructor () { + this.pathSegList = []; + } + appendSegment (pathSeg) { + this.pathSegList.push(pathSeg); + } + } + + class Source { + constructor (string) { + this._string = string; + this._currentIndex = 0; + this._endIndex = this._string.length; + this._previousCommand = SVGPathSeg.PATHSEG_UNKNOWN; + + this._skipOptionalSpaces(); + } + _isCurrentSpace () { + const character = this._string[this._currentIndex]; + return character <= ' ' && (character === ' ' || character === '\n' || character === '\t' || character === '\r' || character === '\f'); + } + + _skipOptionalSpaces () { + while (this._currentIndex < this._endIndex && this._isCurrentSpace()) { + this._currentIndex++; + } + return this._currentIndex < this._endIndex; + } + + _skipOptionalSpacesOrDelimiter () { + if (this._currentIndex < this._endIndex && !this._isCurrentSpace() && this._string.charAt(this._currentIndex) !== ',') { + return false; + } + if (this._skipOptionalSpaces()) { + if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) === ',') { + this._currentIndex++; + this._skipOptionalSpaces(); + } + } + return this._currentIndex < this._endIndex; + } + + hasMoreData () { + return this._currentIndex < this._endIndex; + } + + peekSegmentType () { + const lookahead = this._string[this._currentIndex]; + return this._pathSegTypeFromChar(lookahead); + } + + _pathSegTypeFromChar (lookahead) { + switch (lookahead) { + case 'Z': + case 'z': + return SVGPathSeg.PATHSEG_CLOSEPATH; + case 'M': + return SVGPathSeg.PATHSEG_MOVETO_ABS; + case 'm': + return SVGPathSeg.PATHSEG_MOVETO_REL; + case 'L': + return SVGPathSeg.PATHSEG_LINETO_ABS; + case 'l': + return SVGPathSeg.PATHSEG_LINETO_REL; + case 'C': + return SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS; + case 'c': + return SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL; + case 'Q': + return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS; + case 'q': + return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL; + case 'A': + return SVGPathSeg.PATHSEG_ARC_ABS; + case 'a': + return SVGPathSeg.PATHSEG_ARC_REL; + case 'H': + return SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS; + case 'h': + return SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL; + case 'V': + return SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS; + case 'v': + return SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL; + case 'S': + return SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS; + case 's': + return SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL; + case 'T': + return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS; + case 't': + return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL; + default: + return SVGPathSeg.PATHSEG_UNKNOWN; + } + } + + _nextCommandHelper (lookahead, previousCommand) { + // Check for remaining coordinates in the current command. + if ((lookahead === '+' || lookahead === '-' || lookahead === '.' || (lookahead >= '0' && lookahead <= '9')) && previousCommand !== SVGPathSeg.PATHSEG_CLOSEPATH) { + if (previousCommand === SVGPathSeg.PATHSEG_MOVETO_ABS) { + return SVGPathSeg.PATHSEG_LINETO_ABS; + } + if (previousCommand === SVGPathSeg.PATHSEG_MOVETO_REL) { + return SVGPathSeg.PATHSEG_LINETO_REL; + } + return previousCommand; + } + return SVGPathSeg.PATHSEG_UNKNOWN; + } + + initialCommandIsMoveTo () { + // If the path is empty it is still valid, so return true. + if (!this.hasMoreData()) { + return true; + } + const command = this.peekSegmentType(); + // Path must start with moveTo. + return command === SVGPathSeg.PATHSEG_MOVETO_ABS || command === SVGPathSeg.PATHSEG_MOVETO_REL; + } + + // Parse a number from an SVG path. This very closely follows genericParseNumber(...) from Source/core/svg/SVGParserUtilities.cpp. + // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-PathDataBNF + _parseNumber () { + let exponent = 0; + let integer = 0; + let frac = 1; + let decimal = 0; + let sign = 1; + let expsign = 1; + + const startIndex = this._currentIndex; + + this._skipOptionalSpaces(); + + // Read the sign. + if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) === '+') { + this._currentIndex++; + } else if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) === '-') { + this._currentIndex++; + sign = -1; + } + + if (this._currentIndex === this._endIndex || ((this._string.charAt(this._currentIndex) < '0' || this._string.charAt(this._currentIndex) > '9') && this._string.charAt(this._currentIndex) !== '.')) { + // The first character of a number must be one of [0-9+-.]. + return undefined; + } + + // Read the integer part, build right-to-left. + const startIntPartIndex = this._currentIndex; + while (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) >= '0' && this._string.charAt(this._currentIndex) <= '9') { + this._currentIndex++; // Advance to first non-digit. + } + + if (this._currentIndex !== startIntPartIndex) { + let scanIntPartIndex = this._currentIndex - 1; + let multiplier = 1; + while (scanIntPartIndex >= startIntPartIndex) { + integer += multiplier * (this._string.charAt(scanIntPartIndex--) - '0'); + multiplier *= 10; + } + } + + // Read the decimals. + if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) === '.') { + this._currentIndex++; + + // There must be a least one digit following the . + if (this._currentIndex >= this._endIndex || this._string.charAt(this._currentIndex) < '0' || this._string.charAt(this._currentIndex) > '9') { + return undefined; + } + while (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) >= '0' && this._string.charAt(this._currentIndex) <= '9') { + frac *= 10; + decimal += (this._string.charAt(this._currentIndex) - '0') / frac; + this._currentIndex += 1; + } + } + + // Read the exponent part. + if (this._currentIndex !== startIndex && this._currentIndex + 1 < this._endIndex && (this._string.charAt(this._currentIndex) === 'e' || this._string.charAt(this._currentIndex) === 'E') && (this._string.charAt(this._currentIndex + 1) !== 'x' && this._string.charAt(this._currentIndex + 1) !== 'm')) { + this._currentIndex++; + + // Read the sign of the exponent. + if (this._string.charAt(this._currentIndex) === '+') { + this._currentIndex++; + } else if (this._string.charAt(this._currentIndex) === '-') { + this._currentIndex++; + expsign = -1; + } + + // There must be an exponent. + if (this._currentIndex >= this._endIndex || this._string.charAt(this._currentIndex) < '0' || this._string.charAt(this._currentIndex) > '9') { + return undefined; + } + + while (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) >= '0' && this._string.charAt(this._currentIndex) <= '9') { + exponent *= 10; + exponent += (this._string.charAt(this._currentIndex) - '0'); + this._currentIndex++; + } + } + + let number = integer + decimal; + number *= sign; + + if (exponent) { + number *= 10 ** (expsign * exponent); + } + + if (startIndex === this._currentIndex) { + return undefined; + } + + this._skipOptionalSpacesOrDelimiter(); + + return number; + } + + _parseArcFlag () { + if (this._currentIndex >= this._endIndex) { + return undefined; + } + let flag = false; + const flagChar = this._string.charAt(this._currentIndex++); + if (flagChar === '0') { + flag = false; + } else if (flagChar === '1') { + flag = true; + } else { + return undefined; + } + + this._skipOptionalSpacesOrDelimiter(); + return flag; + } + + parseSegment () { + const lookahead = this._string[this._currentIndex]; + let command = this._pathSegTypeFromChar(lookahead); + if (command === SVGPathSeg.PATHSEG_UNKNOWN) { + // Possibly an implicit command. Not allowed if this is the first command. + if (this._previousCommand === SVGPathSeg.PATHSEG_UNKNOWN) { + return null; + } + command = this._nextCommandHelper(lookahead, this._previousCommand); + if (command === SVGPathSeg.PATHSEG_UNKNOWN) { + return null; + } + } else { + this._currentIndex++; + } + + this._previousCommand = command; + + switch (command) { + case SVGPathSeg.PATHSEG_MOVETO_REL: + return new SVGPathSegMovetoRel(owningPathSegList, this._parseNumber(), this._parseNumber()); + case SVGPathSeg.PATHSEG_MOVETO_ABS: + return new SVGPathSegMovetoAbs(owningPathSegList, this._parseNumber(), this._parseNumber()); + case SVGPathSeg.PATHSEG_LINETO_REL: + return new SVGPathSegLinetoRel(owningPathSegList, this._parseNumber(), this._parseNumber()); + case SVGPathSeg.PATHSEG_LINETO_ABS: + return new SVGPathSegLinetoAbs(owningPathSegList, this._parseNumber(), this._parseNumber()); + case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL: + return new SVGPathSegLinetoHorizontalRel(owningPathSegList, this._parseNumber()); + case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS: + return new SVGPathSegLinetoHorizontalAbs(owningPathSegList, this._parseNumber()); + case SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL: + return new SVGPathSegLinetoVerticalRel(owningPathSegList, this._parseNumber()); + case SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS: + return new SVGPathSegLinetoVerticalAbs(owningPathSegList, this._parseNumber()); + case SVGPathSeg.PATHSEG_CLOSEPATH: + this._skipOptionalSpaces(); + return new SVGPathSegClosePath(owningPathSegList); + case SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL: { + const points = {x1: this._parseNumber(), y1: this._parseNumber(), x2: this._parseNumber(), y2: this._parseNumber(), x: this._parseNumber(), y: this._parseNumber()}; + return new SVGPathSegCurvetoCubicRel(owningPathSegList, points.x, points.y, points.x1, points.y1, points.x2, points.y2); + } case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS: { + const points = {x1: this._parseNumber(), y1: this._parseNumber(), x2: this._parseNumber(), y2: this._parseNumber(), x: this._parseNumber(), y: this._parseNumber()}; + return new SVGPathSegCurvetoCubicAbs(owningPathSegList, points.x, points.y, points.x1, points.y1, points.x2, points.y2); + } case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL: { + const points = {x2: this._parseNumber(), y2: this._parseNumber(), x: this._parseNumber(), y: this._parseNumber()}; + return new SVGPathSegCurvetoCubicSmoothRel(owningPathSegList, points.x, points.y, points.x2, points.y2); + } case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: { + const points = {x2: this._parseNumber(), y2: this._parseNumber(), x: this._parseNumber(), y: this._parseNumber()}; + return new SVGPathSegCurvetoCubicSmoothAbs(owningPathSegList, points.x, points.y, points.x2, points.y2); + } case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL: { + const points = {x1: this._parseNumber(), y1: this._parseNumber(), x: this._parseNumber(), y: this._parseNumber()}; + return new SVGPathSegCurvetoQuadraticRel(owningPathSegList, points.x, points.y, points.x1, points.y1); + } case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS: { + const points = {x1: this._parseNumber(), y1: this._parseNumber(), x: this._parseNumber(), y: this._parseNumber()}; + return new SVGPathSegCurvetoQuadraticAbs(owningPathSegList, points.x, points.y, points.x1, points.y1); + } case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: + return new SVGPathSegCurvetoQuadraticSmoothRel(owningPathSegList, this._parseNumber(), this._parseNumber()); + case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: + return new SVGPathSegCurvetoQuadraticSmoothAbs(owningPathSegList, this._parseNumber(), this._parseNumber()); + case SVGPathSeg.PATHSEG_ARC_REL: { + const points = {x1: this._parseNumber(), y1: this._parseNumber(), arcAngle: this._parseNumber(), arcLarge: this._parseArcFlag(), arcSweep: this._parseArcFlag(), x: this._parseNumber(), y: this._parseNumber()}; + return new SVGPathSegArcRel(owningPathSegList, points.x, points.y, points.x1, points.y1, points.arcAngle, points.arcLarge, points.arcSweep); + } case SVGPathSeg.PATHSEG_ARC_ABS: { + const points = {x1: this._parseNumber(), y1: this._parseNumber(), arcAngle: this._parseNumber(), arcLarge: this._parseArcFlag(), arcSweep: this._parseArcFlag(), x: this._parseNumber(), y: this._parseNumber()}; + return new SVGPathSegArcAbs(owningPathSegList, points.x, points.y, points.x1, points.y1, points.arcAngle, points.arcLarge, points.arcSweep); + } default: + throw new Error('Unknown path seg type.'); + } + } + } + + const builder = new Builder(); + const source = new Source(string); + + if (!source.initialCommandIsMoveTo()) { + return []; + } + while (source.hasMoreData()) { + const pathSeg = source.parseSegment(); + if (!pathSeg) { + return []; + } + builder.appendSegment(pathSeg); + } + + return builder.pathSegList; + } + + // STATIC + static _pathSegArrayAsString (pathSegArray) { + let string = ''; + let first = true; + pathSegArray.forEach((pathSeg) => { + if (first) { + first = false; + string += pathSeg._asPathString(); + } else { + string += ' ' + pathSeg._asPathString(); + } + }); + return string; + } + } + + SVGPathSegList.prototype.classname = 'SVGPathSegList'; + + Object.defineProperty(SVGPathSegList.prototype, 'numberOfItems', { + get () { + this._checkPathSynchronizedToList(); + return this._list.length; + }, + enumerable: true + }); + + // Add the pathSegList accessors to SVGPathElement. + // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGAnimatedPathData + Object.defineProperties(SVGPathElement.prototype, { + pathSegList: { + get () { + if (!this._pathSegList) { + this._pathSegList = new SVGPathSegList(this); + } + return this._pathSegList; + }, + enumerable: true + }, + // TODO: The following are not implemented and simply return SVGPathElement.pathSegList. + normalizedPathSegList: {get () { return this.pathSegList; }, enumerable: true}, + animatedPathSegList: {get () { return this.pathSegList; }, enumerable: true}, + animatedNormalizedPathSegList: {get () { return this.pathSegList; }, enumerable: true} + }); + window.SVGPathSegList = SVGPathSegList; +} +})(); diff --git a/dist/common/svgtransformlist.js b/dist/common/svgtransformlist.js new file mode 100644 index 00000000..09d5eae6 --- /dev/null +++ b/dist/common/svgtransformlist.js @@ -0,0 +1,397 @@ +/** + * Partial polyfill of `SVGTransformList` + * @module SVGTransformList + * + * @license MIT + * + * @copyright 2010 Alexis Deveria, 2010 Jeff Schiller + */ + +import {NS} from './namespaces.js'; +import {supportsNativeTransformLists} from './browser.js'; + +const svgroot = document.createElementNS(NS.SVG, 'svg'); + +/** + * Helper function to convert `SVGTransform` to a string. + * @param {SVGTransform} xform + * @returns {string} + */ +function transformToString (xform) { + const m = xform.matrix; + let text = ''; + switch (xform.type) { + case 1: // MATRIX + text = 'matrix(' + [m.a, m.b, m.c, m.d, m.e, m.f].join(',') + ')'; + break; + case 2: // TRANSLATE + text = 'translate(' + m.e + ',' + m.f + ')'; + break; + case 3: // SCALE + if (m.a === m.d) { + text = 'scale(' + m.a + ')'; + } else { + text = 'scale(' + m.a + ',' + m.d + ')'; + } + break; + case 4: { // ROTATE + let cx = 0; + let cy = 0; + // this prevents divide by zero + if (xform.angle !== 0) { + const K = 1 - m.a; + cy = (K * m.f + m.b * m.e) / (K * K + m.b * m.b); + cx = (m.e - m.b * cy) / K; + } + text = 'rotate(' + xform.angle + ' ' + cx + ',' + cy + ')'; + break; + } + } + return text; +} + +/** + * Map of SVGTransformList objects. + */ +let listMap_ = {}; + +/** +* @interface module:SVGTransformList.SVGEditTransformList +* @property {Integer} numberOfItems unsigned long +*/ +/** +* @function module:SVGTransformList.SVGEditTransformList#clear +* @returns {void} +*/ +/** +* @function module:SVGTransformList.SVGEditTransformList#initialize +* @param {SVGTransform} newItem +* @returns {SVGTransform} +*/ +/** +* DOES NOT THROW DOMException, INDEX_SIZE_ERR. +* @function module:SVGTransformList.SVGEditTransformList#getItem +* @param {Integer} index unsigned long +* @returns {SVGTransform} +*/ +/** +* DOES NOT THROW DOMException, INDEX_SIZE_ERR. +* @function module:SVGTransformList.SVGEditTransformList#insertItemBefore +* @param {SVGTransform} newItem +* @param {Integer} index unsigned long +* @returns {SVGTransform} +*/ +/** +* DOES NOT THROW DOMException, INDEX_SIZE_ERR. +* @function module:SVGTransformList.SVGEditTransformList#replaceItem +* @param {SVGTransform} newItem +* @param {Integer} index unsigned long +* @returns {SVGTransform} +*/ +/** +* DOES NOT THROW DOMException, INDEX_SIZE_ERR. +* @function module:SVGTransformList.SVGEditTransformList#removeItem +* @param {Integer} index unsigned long +* @returns {SVGTransform} +*/ +/** +* @function module:SVGTransformList.SVGEditTransformList#appendItem +* @param {SVGTransform} newItem +* @returns {SVGTransform} +*/ +/** +* NOT IMPLEMENTED. +* @ignore +* @function module:SVGTransformList.SVGEditTransformList#createSVGTransformFromMatrix +* @param {SVGMatrix} matrix +* @returns {SVGTransform} +*/ +/** +* NOT IMPLEMENTED. +* @ignore +* @function module:SVGTransformList.SVGEditTransformList#consolidate +* @returns {SVGTransform} +*/ + +/** +* SVGTransformList implementation for Webkit. +* These methods do not currently raise any exceptions. +* These methods also do not check that transforms are being inserted. This is basically +* implementing as much of SVGTransformList that we need to get the job done. +* @implements {module:SVGTransformList.SVGEditTransformList} +*/ +export class SVGTransformList { // eslint-disable-line no-shadow + /** + * @param {Element} elem + * @returns {SVGTransformList} + */ + constructor (elem) { + this._elem = elem || null; + this._xforms = []; + // TODO: how do we capture the undo-ability in the changed transform list? + this._update = function () { + let tstr = ''; + // /* const concatMatrix = */ svgroot.createSVGMatrix(); + for (let i = 0; i < this.numberOfItems; ++i) { + const xform = this._list.getItem(i); + tstr += transformToString(xform) + ' '; + } + this._elem.setAttribute('transform', tstr); + }; + this._list = this; + this._init = function () { + // Transform attribute parser + let str = this._elem.getAttribute('transform'); + if (!str) { return; } + + // TODO: Add skew support in future + const re = /\s*((scale|matrix|rotate|translate)\s*\(.*?\))\s*,?\s*/; + // const re = /\s*(?(?:scale|matrix|rotate|translate)\s*\(.*?\))\s*,?\s*/; + let m = true; + while (m) { + m = str.match(re); + str = str.replace(re, ''); + if (m && m[1]) { + const x = m[1]; + const bits = x.split(/\s*\(/); + const name = bits[0]; + const valBits = bits[1].match(/\s*(.*?)\s*\)/); + valBits[1] = valBits[1].replace(/(\d)-/g, '$1 -'); + const valArr = valBits[1].split(/[, ]+/); + const letters = 'abcdef'.split(''); + /* + if (m && m.groups.xform) { + const x = m.groups.xform; + const [name, bits] = x.split(/\s*\(/); + const valBits = bits.match(/\s*(?.*?)\s*\)/); + valBits.groups.nonWhitespace = valBits.groups.nonWhitespace.replace( + /(?\d)-/g, '$ -' + ); + const valArr = valBits.groups.nonWhitespace.split(/[, ]+/); + const letters = [...'abcdef']; + */ + const mtx = svgroot.createSVGMatrix(); + Object.values(valArr).forEach(function (item, i) { + valArr[i] = Number.parseFloat(item); + if (name === 'matrix') { + mtx[letters[i]] = valArr[i]; + } + }); + const xform = svgroot.createSVGTransform(); + const fname = 'set' + name.charAt(0).toUpperCase() + name.slice(1); + const values = name === 'matrix' ? [mtx] : valArr; + + if (name === 'scale' && values.length === 1) { + values.push(values[0]); + } else if (name === 'translate' && values.length === 1) { + values.push(0); + } else if (name === 'rotate' && values.length === 1) { + values.push(0, 0); + } + xform[fname](...values); + this._list.appendItem(xform); + } + } + }; + this._removeFromOtherLists = function (item) { + if (item) { + // Check if this transform is already in a transformlist, and + // remove it if so. + Object.values(listMap_).some((tl) => { + for (let i = 0, len = tl._xforms.length; i < len; ++i) { + if (tl._xforms[i] === item) { + tl.removeItem(i); + return true; + } + } + return false; + }); + } + }; + + this.numberOfItems = 0; + } + /** + * @returns {void} + */ + clear () { + this.numberOfItems = 0; + this._xforms = []; + } + + /** + * @param {SVGTransform} newItem + * @returns {void} + */ + initialize (newItem) { + this.numberOfItems = 1; + this._removeFromOtherLists(newItem); + this._xforms = [newItem]; + } + + /** + * @param {Integer} index unsigned long + * @throws {Error} + * @returns {SVGTransform} + */ + getItem (index) { + if (index < this.numberOfItems && index >= 0) { + return this._xforms[index]; + } + const err = new Error('DOMException with code=INDEX_SIZE_ERR'); + err.code = 1; + throw err; + } + + /** + * @param {SVGTransform} newItem + * @param {Integer} index unsigned long + * @returns {SVGTransform} + */ + insertItemBefore (newItem, index) { + let retValue = null; + if (index >= 0) { + if (index < this.numberOfItems) { + this._removeFromOtherLists(newItem); + const newxforms = new Array(this.numberOfItems + 1); + // TODO: use array copying and slicing + let i; + for (i = 0; i < index; ++i) { + newxforms[i] = this._xforms[i]; + } + newxforms[i] = newItem; + for (let j = i + 1; i < this.numberOfItems; ++j, ++i) { + newxforms[j] = this._xforms[i]; + } + this.numberOfItems++; + this._xforms = newxforms; + retValue = newItem; + this._list._update(); + } else { + retValue = this._list.appendItem(newItem); + } + } + return retValue; + } + + /** + * @param {SVGTransform} newItem + * @param {Integer} index unsigned long + * @returns {SVGTransform} + */ + replaceItem (newItem, index) { + let retValue = null; + if (index < this.numberOfItems && index >= 0) { + this._removeFromOtherLists(newItem); + this._xforms[index] = newItem; + retValue = newItem; + this._list._update(); + } + return retValue; + } + + /** + * @param {Integer} index unsigned long + * @throws {Error} + * @returns {SVGTransform} + */ + removeItem (index) { + if (index < this.numberOfItems && index >= 0) { + const retValue = this._xforms[index]; + const newxforms = new Array(this.numberOfItems - 1); + let i; + for (i = 0; i < index; ++i) { + newxforms[i] = this._xforms[i]; + } + for (let j = i; j < this.numberOfItems - 1; ++j, ++i) { + newxforms[j] = this._xforms[i + 1]; + } + this.numberOfItems--; + this._xforms = newxforms; + this._list._update(); + return retValue; + } + const err = new Error('DOMException with code=INDEX_SIZE_ERR'); + err.code = 1; + throw err; + } + + /** + * @param {SVGTransform} newItem + * @returns {SVGTransform} + */ + appendItem (newItem) { + this._removeFromOtherLists(newItem); + this._xforms.push(newItem); + this.numberOfItems++; + this._list._update(); + return newItem; + } +} + +/** +* @function module:SVGTransformList.resetListMap +* @returns {void} +*/ +export const resetListMap = function () { + listMap_ = {}; +}; + +/** + * Removes transforms of the given element from the map. + * @function module:SVGTransformList.removeElementFromListMap + * @param {Element} elem - a DOM Element + * @returns {void} + */ +export let removeElementFromListMap = function (elem) { // eslint-disable-line import/no-mutable-exports + if (elem.id && listMap_[elem.id]) { + delete listMap_[elem.id]; + } +}; + +/** +* Returns an object that behaves like a `SVGTransformList` for the given DOM element. +* @function module:SVGTransformList.getTransformList +* @param {Element} elem - DOM element to get a transformlist from +* @todo The polyfill should have `SVGAnimatedTransformList` and this should use it +* @returns {SVGAnimatedTransformList|SVGTransformList} +*/ +export const getTransformList = function (elem) { + if (!supportsNativeTransformLists()) { + const id = elem.id || 'temp'; + let t = listMap_[id]; + if (!t || id === 'temp') { + listMap_[id] = new SVGTransformList(elem); + listMap_[id]._init(); + t = listMap_[id]; + } + return t; + } + if (elem.transform) { + return elem.transform.baseVal; + } + if (elem.gradientTransform) { + return elem.gradientTransform.baseVal; + } + if (elem.patternTransform) { + return elem.patternTransform.baseVal; + } + + return null; +}; + +/** +* @callback module:SVGTransformList.removeElementFromListMap +* @param {Element} elem +* @returns {void} +*/ +/** +* Replace `removeElementFromListMap` for unit-testing. +* @function module:SVGTransformList.changeRemoveElementFromListMap +* @param {module:SVGTransformList.removeElementFromListMap} cb Passed a single argument `elem` +* @returns {void} +*/ + +export const changeRemoveElementFromListMap = function (cb) { // eslint-disable-line promise/prefer-await-to-callbacks + removeElementFromListMap = cb; +}; diff --git a/dist/common/units.js b/dist/common/units.js new file mode 100644 index 00000000..c2bf694d --- /dev/null +++ b/dist/common/units.js @@ -0,0 +1,313 @@ +/** + * Tools for working with units. + * @module units + * @license MIT + * + * @copyright 2010 Alexis Deveria, 2010 Jeff Schiller + */ + +import {NS} from './namespaces.js'; + +const wAttrs = ['x', 'x1', 'cx', 'rx', 'width']; +const hAttrs = ['y', 'y1', 'cy', 'ry', 'height']; +const unitAttrs = ['r', 'radius', ...wAttrs, ...hAttrs]; +// unused +/* +const unitNumMap = { + '%': 2, + em: 3, + ex: 4, + px: 5, + cm: 6, + mm: 7, + in: 8, + pt: 9, + pc: 10 +}; +*/ +// Container of elements. +let elementContainer_; + +// Stores mapping of unit type to user coordinates. +let typeMap_ = {}; + +/** + * @interface module:units.ElementContainer + */ +/** + * @function module:units.ElementContainer#getBaseUnit + * @returns {string} The base unit type of the container ('em') + */ +/** + * @function module:units.ElementContainer#getElement + * @returns {?Element} An element in the container given an id + */ +/** + * @function module:units.ElementContainer#getHeight + * @returns {Float} The container's height + */ +/** + * @function module:units.ElementContainer#getWidth + * @returns {Float} The container's width + */ +/** + * @function module:units.ElementContainer#getRoundDigits + * @returns {Integer} The number of digits number should be rounded to + */ + +/* eslint-disable jsdoc/valid-types */ +/** + * @typedef {PlainObject} module:units.TypeMap + * @property {Float} em + * @property {Float} ex + * @property {Float} in + * @property {Float} cm + * @property {Float} mm + * @property {Float} pt + * @property {Float} pc + * @property {Integer} px + * @property {0} % + */ +/* eslint-enable jsdoc/valid-types */ + +/** + * Initializes this module. + * + * @function module:units.init + * @param {module:units.ElementContainer} elementContainer - An object implementing the ElementContainer interface. + * @returns {void} + */ +export const init = function (elementContainer) { + elementContainer_ = elementContainer; + + // Get correct em/ex values by creating a temporary SVG. + const svg = document.createElementNS(NS.SVG, 'svg'); + document.body.append(svg); + const rect = document.createElementNS(NS.SVG, 'rect'); + rect.setAttribute('width', '1em'); + rect.setAttribute('height', '1ex'); + rect.setAttribute('x', '1in'); + svg.append(rect); + const bb = rect.getBBox(); + svg.remove(); + + const inch = bb.x; + typeMap_ = { + em: bb.width, + ex: bb.height, + in: inch, + cm: inch / 2.54, + mm: inch / 25.4, + pt: inch / 72, + pc: inch / 6, + px: 1, + '%': 0 + }; +}; + +/** +* Group: Unit conversion functions. +*/ + +/** + * @function module:units.getTypeMap + * @returns {module:units.TypeMap} The unit object with values for each unit +*/ +export const getTypeMap = function () { + return typeMap_; +}; + +/** +* @typedef {GenericArray} module:units.CompareNumbers +* @property {Integer} length 2 +* @property {Float} 0 +* @property {Float} 1 +*/ + +/** +* Rounds a given value to a float with number of digits defined in +* `round_digits` of `saveOptions` +* +* @function module:units.shortFloat +* @param {string|Float|module:units.CompareNumbers} val - The value (or Array of two numbers) to be rounded +* @returns {Float|string} If a string/number was given, returns a Float. If an array, return a string +* with comma-separated floats +*/ +export const shortFloat = function (val) { + const digits = elementContainer_.getRoundDigits(); + if (!isNaN(val)) { + return Number(Number(val).toFixed(digits)); + } + if (Array.isArray(val)) { + return shortFloat(val[0]) + ',' + shortFloat(val[1]); + } + return Number.parseFloat(val).toFixed(digits) - 0; +}; + +/** +* Converts the number to given unit or baseUnit. +* @function module:units.convertUnit +* @param {string|Float} val +* @param {"em"|"ex"|"in"|"cm"|"mm"|"pt"|"pc"|"px"|"%"} [unit] +* @returns {Float} +*/ +export const convertUnit = function (val, unit) { + unit = unit || elementContainer_.getBaseUnit(); + // baseVal.convertToSpecifiedUnits(unitNumMap[unit]); + // const val = baseVal.valueInSpecifiedUnits; + // baseVal.convertToSpecifiedUnits(1); + return shortFloat(val / typeMap_[unit]); +}; + +/** +* Sets an element's attribute based on the unit in its current value. +* +* @function module:units.setUnitAttr +* @param {Element} elem - DOM element to be changed +* @param {string} attr - Name of the attribute associated with the value +* @param {string} val - Attribute value to convert +* @returns {void} +*/ +export const setUnitAttr = function (elem, attr, val) { + // if (!isNaN(val)) { + // New value is a number, so check currently used unit + // const oldVal = elem.getAttribute(attr); + + // Enable this for alternate mode + // if (oldVal !== null && (isNaN(oldVal) || elementContainer_.getBaseUnit() !== 'px')) { + // // Old value was a number, so get unit, then convert + // let unit; + // if (oldVal.substr(-1) === '%') { + // const res = getResolution(); + // unit = '%'; + // val *= 100; + // if (wAttrs.includes(attr)) { + // val = val / res.w; + // } else if (hAttrs.includes(attr)) { + // val = val / res.h; + // } else { + // return val / Math.sqrt((res.w*res.w) + (res.h*res.h))/Math.sqrt(2); + // } + // } else { + // if (elementContainer_.getBaseUnit() !== 'px') { + // unit = elementContainer_.getBaseUnit(); + // } else { + // unit = oldVal.substr(-2); + // } + // val = val / typeMap_[unit]; + // } + // + // val += unit; + // } + // } + elem.setAttribute(attr, val); +}; + +const attrsToConvert = { + line: ['x1', 'x2', 'y1', 'y2'], + circle: ['cx', 'cy', 'r'], + ellipse: ['cx', 'cy', 'rx', 'ry'], + foreignObject: ['x', 'y', 'width', 'height'], + rect: ['x', 'y', 'width', 'height'], + image: ['x', 'y', 'width', 'height'], + use: ['x', 'y', 'width', 'height'], + text: ['x', 'y'] +}; + +/** +* Converts all applicable attributes to the configured baseUnit. +* @function module:units.convertAttrs +* @param {Element} element - A DOM element whose attributes should be converted +* @returns {void} +*/ +export const convertAttrs = function (element) { + const elName = element.tagName; + const unit = elementContainer_.getBaseUnit(); + const attrs = attrsToConvert[elName]; + if (!attrs) { return; } + + const len = attrs.length; + for (let i = 0; i < len; i++) { + const attr = attrs[i]; + const cur = element.getAttribute(attr); + if (cur) { + if (!isNaN(cur)) { + element.setAttribute(attr, (cur / typeMap_[unit]) + unit); + } + // else { + // Convert existing? + // } + } + } +}; + +/** +* Converts given values to numbers. Attributes must be supplied in +* case a percentage is given. +* +* @function module:units.convertToNum +* @param {string} attr - Name of the attribute associated with the value +* @param {string} val - Attribute value to convert +* @returns {Float} The converted number +*/ +export const convertToNum = function (attr, val) { + // Return a number if that's what it already is + if (!isNaN(val)) { return val - 0; } + if (val.substr(-1) === '%') { + // Deal with percentage, depends on attribute + const num = val.substr(0, val.length - 1) / 100; + const width = elementContainer_.getWidth(); + const height = elementContainer_.getHeight(); + + if (wAttrs.includes(attr)) { + return num * width; + } + if (hAttrs.includes(attr)) { + return num * height; + } + return num * Math.sqrt((width * width) + (height * height)) / Math.sqrt(2); + } + const unit = val.substr(-2); + const num = val.substr(0, val.length - 2); + // Note that this multiplication turns the string into a number + return num * typeMap_[unit]; +}; + +/** +* Check if an attribute's value is in a valid format. +* @function module:units.isValidUnit +* @param {string} attr - The name of the attribute associated with the value +* @param {string} val - The attribute value to check +* @param {Element} selectedElement +* @returns {boolean} Whether the unit is valid +*/ +export const isValidUnit = function (attr, val, selectedElement) { + if (unitAttrs.includes(attr)) { + // True if it's just a number + if (!isNaN(val)) { + return true; + } + // Not a number, check if it has a valid unit + val = val.toLowerCase(); + return Object.keys(typeMap_).some((unit) => { + const re = new RegExp('^-?[\\d\\.]+' + unit + '$'); + return re.test(val); + }); + } + if (attr === 'id') { + // if we're trying to change the id, make sure it's not already present in the doc + // and the id value is valid. + + let result = false; + // because getElem() can throw an exception in the case of an invalid id + // (according to https://www.w3.org/TR/xml-id/ IDs must be a NCName) + // we wrap it in an exception and only return true if the ID was valid and + // not already present + try { + const elem = elementContainer_.getElement(val); + result = (!elem || elem === selectedElement); + } catch (e) {} + return result; + } + return true; +}; diff --git a/dist/common/utilities.js b/dist/common/utilities.js new file mode 100644 index 00000000..e30cf483 --- /dev/null +++ b/dist/common/utilities.js @@ -0,0 +1,1363 @@ +/* globals jQuery */ +/** + * Miscellaneous utilities. + * @module utilities + * @license MIT + * + * @copyright 2010 Alexis Deveria, 2010 Jeff Schiller + */ + +import './svgpathseg.js'; +import jQueryPluginSVG from './jQuery.attr.js'; // Needed for SVG attribute setting and array form with `attr` +import {NS} from './namespaces.js'; +import {getTransformList} from './svgtransformlist.js'; +import {setUnitAttr, getTypeMap} from './units.js'; +import { + hasMatrixTransform, transformListToTransform, transformBox +} from './math.js'; +import { + isWebkit, supportsHVLineContainerBBox, supportsPathBBox, supportsXpath, + supportsSelectors +} from './browser.js'; + +// Constants +const $ = jQueryPluginSVG(jQuery); + +// String used to encode base64. +const KEYSTR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; + +// Much faster than running getBBox() every time +const visElems = 'a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use,clipPath'; +const visElemsArr = visElems.split(','); +// const hidElems = 'defs,desc,feGaussianBlur,filter,linearGradient,marker,mask,metadata,pattern,radialGradient,stop,switch,symbol,title,textPath'; + +let editorContext_ = null; +let domdoc_ = null; +let domcontainer_ = null; +let svgroot_ = null; + +/** +* Object with the following keys/values. +* @typedef {PlainObject} module:utilities.SVGElementJSON +* @property {string} element - Tag name of the SVG element to create +* @property {PlainObject} attr - Has key-value attributes to assign to the new element. An `id` should be set so that {@link module:utilities.EditorContext#addSVGElementFromJson} can later re-identify the element for modification or replacement. +* @property {boolean} [curStyles=false] - Indicates whether current style attributes should be applied first +* @property {module:utilities.SVGElementJSON[]} [children] - Data objects to be added recursively as children +* @property {string} [namespace="http://www.w3.org/2000/svg"] - Indicate a (non-SVG) namespace +*/ + +/** + * An object that creates SVG elements for the canvas. + * + * @interface module:utilities.EditorContext + * @property {module:path.pathActions} pathActions + */ +/** + * @function module:utilities.EditorContext#getSVGContent + * @returns {SVGSVGElement} + */ +/** + * Create a new SVG element based on the given object keys/values and add it + * to the current layer. + * The element will be run through `cleanupElement` before being returned. + * @function module:utilities.EditorContext#addSVGElementFromJson + * @param {module:utilities.SVGElementJSON} data + * @returns {Element} The new element +*/ +/** + * @function module:utilities.EditorContext#getSelectedElements + * @returns {Element[]} the array with selected DOM elements +*/ +/** + * @function module:utilities.EditorContext#getDOMDocument + * @returns {HTMLDocument} +*/ +/** + * @function module:utilities.EditorContext#getDOMContainer + * @returns {HTMLElement} +*/ +/** + * @function module:utilities.EditorContext#getSVGRoot + * @returns {SVGSVGElement} +*/ +/** + * @function module:utilities.EditorContext#getBaseUnit + * @returns {string} +*/ +/** + * @function module:utilities.EditorContext#getSnappingStep + * @returns {Float|string} +*/ + +/** +* @function module:utilities.init +* @param {module:utilities.EditorContext} editorContext +* @returns {void} +*/ +export const init = function (editorContext) { + editorContext_ = editorContext; + domdoc_ = editorContext.getDOMDocument(); + domcontainer_ = editorContext.getDOMContainer(); + svgroot_ = editorContext.getSVGRoot(); +}; + +/** + * Used to prevent the [Billion laughs attack]{@link https://en.wikipedia.org/wiki/Billion_laughs_attack}. + * @function module:utilities.dropXMLInternalSubset + * @param {string} str String to be processed + * @returns {string} The string with entity declarations in the internal subset removed + * @todo This might be needed in other places `parseFromString` is used even without LGTM flagging + */ +export const dropXMLInternalSubset = (str) => { + return str.replace(/()/, '$1$2'); + // return str.replace(/(?\?\]>)/, '$$'); +}; + +/** +* Converts characters in a string to XML-friendly entities. +* @function module:utilities.toXml +* @example `&` becomes `&` +* @param {string} str - The string to be converted +* @returns {string} The converted string +*/ +export const toXml = function (str) { + // ' is ok in XML, but not HTML + // > does not normally need escaping, though it can if within a CDATA expression (and preceded by "]]") + return str + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); // Note: `'` is XML only +}; + +/** +* Converts XML entities in a string to single characters. +* @function module:utilities.fromXml +* @example `&` becomes `&` +* @param {string} str - The string to be converted +* @returns {string} The converted string +*/ +export function fromXml (str) { + return $('

').html(str).text(); +} + +// This code was written by Tyler Akins and has been placed in the +// public domain. It would be nice if you left this header intact. +// Base64 code from Tyler Akins -- http://rumkin.com + +// schiller: Removed string concatenation in favour of Array.join() optimization, +// also precalculate the size of the array needed. + +/** +* Converts a string to base64. +* @function module:utilities.encode64 +* @param {string} input +* @returns {string} Base64 output +*/ +export function encode64 (input) { + // base64 strings are 4/3 larger than the original string + input = encodeUTF8(input); // convert non-ASCII characters + // input = convertToXMLReferences(input); + if (window.btoa) { + return window.btoa(input); // Use native if available + } + const output = new Array(Math.floor((input.length + 2) / 3) * 4); + + let i = 0, + p = 0; + do { + const chr1 = input.charCodeAt(i++); + const chr2 = input.charCodeAt(i++); + const chr3 = input.charCodeAt(i++); + + /* eslint-disable no-bitwise */ + const enc1 = chr1 >> 2; + const enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); + + let enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); + let enc4 = chr3 & 63; + /* eslint-enable no-bitwise */ + + if (Number.isNaN(chr2)) { + enc3 = 64; + enc4 = 64; + } else if (Number.isNaN(chr3)) { + enc4 = 64; + } + + output[p++] = KEYSTR.charAt(enc1); + output[p++] = KEYSTR.charAt(enc2); + output[p++] = KEYSTR.charAt(enc3); + output[p++] = KEYSTR.charAt(enc4); + } while (i < input.length); + + return output.join(''); +} + +/** +* Converts a string from base64. +* @function module:utilities.decode64 +* @param {string} input Base64-encoded input +* @returns {string} Decoded output +*/ +export function decode64 (input) { + if (window.atob) { + return decodeUTF8(window.atob(input)); + } + + // remove all characters that are not A-Z, a-z, 0-9, +, /, or = + input = input.replace(/[^A-Za-z\d+/=]/g, ''); + + let output = ''; + let i = 0; + + do { + const enc1 = KEYSTR.indexOf(input.charAt(i++)); + const enc2 = KEYSTR.indexOf(input.charAt(i++)); + const enc3 = KEYSTR.indexOf(input.charAt(i++)); + const enc4 = KEYSTR.indexOf(input.charAt(i++)); + + /* eslint-disable no-bitwise */ + const chr1 = (enc1 << 2) | (enc2 >> 4); + const chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); + const chr3 = ((enc3 & 3) << 6) | enc4; + /* eslint-enable no-bitwise */ + + output += String.fromCharCode(chr1); + + if (enc3 !== 64) { + output += String.fromCharCode(chr2); + } + if (enc4 !== 64) { + output += String.fromCharCode(chr3); + } + } while (i < input.length); + return decodeUTF8(output); +} + +/** +* @function module:utilities.decodeUTF8 +* @param {string} argString +* @returns {string} +*/ +export function decodeUTF8 (argString) { + return decodeURIComponent(escape(argString)); +} + +// codedread:does not seem to work with webkit-based browsers on OSX // Brettz9: please test again as function upgraded +/** +* @function module:utilities.encodeUTF8 +* @param {string} argString +* @returns {string} +*/ +export const encodeUTF8 = function (argString) { + return unescape(encodeURIComponent(argString)); +}; + +/** + * Convert dataURL to object URL. + * @function module:utilities.dataURLToObjectURL + * @param {string} dataurl + * @returns {string} object URL or empty string + */ +export const dataURLToObjectURL = function (dataurl) { + if (typeof Uint8Array === 'undefined' || typeof Blob === 'undefined' || typeof URL === 'undefined' || !URL.createObjectURL) { + return ''; + } + const arr = dataurl.split(','), + mime = arr[0].match(/:(.*?);/)[1], + bstr = atob(arr[1]); + /* + const [prefix, suffix] = dataurl.split(','), + {groups: {mime}} = prefix.match(/:(?.*?);/), + bstr = atob(suffix); + */ + let n = bstr.length; + const u8arr = new Uint8Array(n); + while (n--) { + u8arr[n] = bstr.charCodeAt(n); + } + const blob = new Blob([u8arr], {type: mime}); + return URL.createObjectURL(blob); +}; + +/** + * Get object URL for a blob object. + * @function module:utilities.createObjectURL + * @param {Blob} blob A Blob object or File object + * @returns {string} object URL or empty string + */ +export const createObjectURL = function (blob) { + if (!blob || typeof URL === 'undefined' || !URL.createObjectURL) { + return ''; + } + return URL.createObjectURL(blob); +}; + +/** + * @property {string} blankPageObjectURL + */ +export const blankPageObjectURL = (function () { + if (typeof Blob === 'undefined') { + return ''; + } + const blob = new Blob(['SVG-edit '], {type: 'text/html'}); + return createObjectURL(blob); +})(); + +/** +* Converts a string to use XML references (for non-ASCII). +* @function module:utilities.convertToXMLReferences +* @param {string} input +* @returns {string} Decimal numeric character references +*/ +export const convertToXMLReferences = function (input) { + let output = ''; + [...input].forEach((ch) => { + const c = ch.charCodeAt(); + if (c <= 127) { + output += ch; + } else { + output += `&#${c};`; + } + }); + return output; +}; + +/** +* Cross-browser compatible method of converting a string to an XML tree. +* Found this function [here]{@link http://groups.google.com/group/jquery-dev/browse_thread/thread/c6d11387c580a77f}. +* @function module:utilities.text2xml +* @param {string} sXML +* @throws {Error} +* @returns {XMLDocument} +*/ +export const text2xml = function (sXML) { + if (sXML.includes('` +* - `` +* - `` +* @function module:utilities.getUrlFromAttr +* @param {string} attrVal The attribute value as a string +* @returns {string} String with just the URL, like "someFile.svg#foo" +*/ +export const getUrlFromAttr = function (attrVal) { + if (attrVal) { + // url('#somegrad') + if (attrVal.startsWith('url("')) { + return attrVal.substring(5, attrVal.indexOf('"', 6)); + } + // url('#somegrad') + if (attrVal.startsWith("url('")) { + return attrVal.substring(5, attrVal.indexOf("'", 6)); + } + if (attrVal.startsWith('url(')) { + return attrVal.substring(4, attrVal.indexOf(')')); + } + } + return null; +}; + +/** +* @function module:utilities.getHref +* @param {Element} elem +* @returns {string} The given element's `xlink:href` value +*/ +export let getHref = function (elem) { // eslint-disable-line import/no-mutable-exports + return elem.getAttributeNS(NS.XLINK, 'href'); +}; + +/** +* Sets the given element's `xlink:href` value. +* @function module:utilities.setHref +* @param {Element} elem +* @param {string} val +* @returns {void} +*/ +export let setHref = function (elem, val) { // eslint-disable-line import/no-mutable-exports + elem.setAttributeNS(NS.XLINK, 'xlink:href', val); +}; + +/** +* @function module:utilities.findDefs +* @returns {SVGDefsElement} The document's `` element, creating it first if necessary +*/ +export const findDefs = function () { + const svgElement = editorContext_.getSVGContent(); + let defs = svgElement.getElementsByTagNameNS(NS.SVG, 'defs'); + if (defs.length > 0) { + defs = defs[0]; + } else { + defs = svgElement.ownerDocument.createElementNS(NS.SVG, 'defs'); + if (svgElement.firstChild) { + // first child is a comment, so call nextSibling + svgElement.insertBefore(defs, svgElement.firstChild.nextSibling); + // svgElement.firstChild.nextSibling.before(defs); // Not safe + } else { + svgElement.append(defs); + } + } + return defs; +}; + +// TODO(codedread): Consider moving the next to functions to bbox.js + +/** +* Get correct BBox for a path in Webkit. +* Converted from code found [here]{@link http://blog.hackers-cafe.net/2009/06/how-to-calculate-bezier-curves-bounding.html}. +* @function module:utilities.getPathBBox +* @param {SVGPathElement} path - The path DOM element to get the BBox for +* @returns {module:utilities.BBoxObject} A BBox-like object +*/ +export const getPathBBox = function (path) { + const seglist = path.pathSegList; + const tot = seglist.numberOfItems; + + const bounds = [[], []]; + const start = seglist.getItem(0); + let P0 = [start.x, start.y]; + + const getCalc = function (j, P1, P2, P3) { + return function (t) { + return 1 - t ** 3 * P0[j] + + 3 * 1 - t ** 2 * t * P1[j] + + 3 * (1 - t) * t ** 2 * P2[j] + + t ** 3 * P3[j]; + }; + }; + + for (let i = 0; i < tot; i++) { + const seg = seglist.getItem(i); + + if (seg.x === undefined) { continue; } + + // Add actual points to limits + bounds[0].push(P0[0]); + bounds[1].push(P0[1]); + + if (seg.x1) { + const P1 = [seg.x1, seg.y1], + P2 = [seg.x2, seg.y2], + P3 = [seg.x, seg.y]; + + for (let j = 0; j < 2; j++) { + const calc = getCalc(j, P1, P2, P3); + + const b = 6 * P0[j] - 12 * P1[j] + 6 * P2[j]; + const a = -3 * P0[j] + 9 * P1[j] - 9 * P2[j] + 3 * P3[j]; + const c = 3 * P1[j] - 3 * P0[j]; + + if (a === 0) { + if (b === 0) { continue; } + const t = -c / b; + if (t > 0 && t < 1) { + bounds[j].push(calc(t)); + } + continue; + } + const b2ac = b ** 2 - 4 * c * a; + if (b2ac < 0) { continue; } + const t1 = (-b + Math.sqrt(b2ac)) / (2 * a); + if (t1 > 0 && t1 < 1) { bounds[j].push(calc(t1)); } + const t2 = (-b - Math.sqrt(b2ac)) / (2 * a); + if (t2 > 0 && t2 < 1) { bounds[j].push(calc(t2)); } + } + P0 = P3; + } else { + bounds[0].push(seg.x); + bounds[1].push(seg.y); + } + } + + const x = Math.min.apply(null, bounds[0]); + const w = Math.max.apply(null, bounds[0]) - x; + const y = Math.min.apply(null, bounds[1]); + const h = Math.max.apply(null, bounds[1]) - y; + return { + x, + y, + width: w, + height: h + }; +}; + +/** +* Get the given/selected element's bounding box object, checking for +* horizontal/vertical lines (see issue 717) +* Note that performance is currently terrible, so some way to improve would +* be great. +* @param {Element} selected - Container or `` DOM element +* @returns {DOMRect} Bounding box object +*/ +function groupBBFix (selected) { + if (supportsHVLineContainerBBox()) { + try { return selected.getBBox(); } catch (e) {} + } + const ref = $.data(selected, 'ref'); + let matched = null; + let ret, copy; + + if (ref) { + copy = $(ref).children().clone().attr('visibility', 'hidden'); + $(svgroot_).append(copy); + matched = copy.filter('line, path'); + } else { + matched = $(selected).find('line, path'); + } + + let issue = false; + if (matched.length) { + matched.each(function () { + const bb = this.getBBox(); + if (!bb.width || !bb.height) { + issue = true; + } + }); + if (issue) { + const elems = ref ? copy : $(selected).children(); + ret = getStrokedBBox(elems); + } else { + ret = selected.getBBox(); + } + } else { + ret = selected.getBBox(); + } + if (ref) { + copy.remove(); + } + return ret; +} + +/** +* Get the given/selected element's bounding box object, convert it to be more +* usable when necessary. +* @function module:utilities.getBBox +* @param {Element} elem - Optional DOM element to get the BBox for +* @returns {module:utilities.BBoxObject} Bounding box object +*/ +export const getBBox = function (elem) { + const selected = elem || editorContext_.geSelectedElements()[0]; + if (elem.nodeType !== 1) { return null; } + const elname = selected.nodeName; + + let ret = null; + switch (elname) { + case 'text': + if (selected.textContent === '') { + selected.textContent = 'a'; // Some character needed for the selector to use. + ret = selected.getBBox(); + selected.textContent = ''; + } else if (selected.getBBox) { + ret = selected.getBBox(); + } + break; + case 'path': + if (!supportsPathBBox()) { + ret = getPathBBox(selected); + } else if (selected.getBBox) { + ret = selected.getBBox(); + } + break; + case 'g': + case 'a': + ret = groupBBFix(selected); + break; + default: + + if (elname === 'use') { + ret = groupBBFix(selected); // , true); + } + if (elname === 'use' || (elname === 'foreignObject' && isWebkit())) { + if (!ret) { ret = selected.getBBox(); } + // This is resolved in later versions of webkit, perhaps we should + // have a featured detection for correct 'use' behavior? + // —————————— + if (!isWebkit()) { + const {x, y, width, height} = ret; + const bb = { + width, + height, + x: x + Number.parseFloat(selected.getAttribute('x') || 0), + y: y + Number.parseFloat(selected.getAttribute('y') || 0) + }; + ret = bb; + } + } else if (visElemsArr.includes(elname)) { + if (selected) { + try { + ret = selected.getBBox(); + } catch (err) { + // tspan (and textPath apparently) have no `getBBox` in Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=937268 + // Re: Chrome returning bbox for containing text element, see: https://bugs.chromium.org/p/chromium/issues/detail?id=349835 + const extent = selected.getExtentOfChar(0); // pos+dimensions of the first glyph + const width = selected.getComputedTextLength(); // width of the tspan + ret = { + x: extent.x, + y: extent.y, + width, + height: extent.height + }; + } + } else { + // Check if element is child of a foreignObject + const fo = $(selected).closest('foreignObject'); + if (fo.length) { + if (fo[0].getBBox) { + ret = fo[0].getBBox(); + } + } + } + } + } + if (ret) { + ret = bboxToObj(ret); + } + + // get the bounding box from the DOM (which is in that element's coordinate system) + return ret; +}; + +/** +* @typedef {GenericArray} module:utilities.PathSegmentArray +* @property {Integer} length 2 +* @property {"M"|"L"|"C"|"Z"} 0 +* @property {Float[]} 1 +*/ + +/** +* Create a path 'd' attribute from path segments. +* Each segment is an array of the form: `[singleChar, [x,y, x,y, ...]]` +* @function module:utilities.getPathDFromSegments +* @param {module:utilities.PathSegmentArray[]} pathSegments - An array of path segments to be converted +* @returns {string} The converted path d attribute. +*/ +export const getPathDFromSegments = function (pathSegments) { + let d = ''; + + $.each(pathSegments, function (j, [singleChar, pts]) { + d += singleChar; + for (let i = 0; i < pts.length; i += 2) { + d += (pts[i] + ',' + pts[i + 1]) + ' '; + } + }); + + return d; +}; + +/** +* Make a path 'd' attribute from a simple SVG element shape. +* @function module:utilities.getPathDFromElement +* @param {Element} elem - The element to be converted +* @returns {string} The path d attribute or `undefined` if the element type is unknown. +*/ +export const getPathDFromElement = function (elem) { + // Possibly the cubed root of 6, but 1.81 works best + let num = 1.81; + let d, a, rx, ry; + switch (elem.tagName) { + case 'ellipse': + case 'circle': { + a = $(elem).attr(['rx', 'ry', 'cx', 'cy']); + const {cx, cy} = a; + ({rx, ry} = a); + if (elem.tagName === 'circle') { + ry = $(elem).attr('r'); + rx = ry; + } + + d = getPathDFromSegments([ + ['M', [(cx - rx), (cy)]], + ['C', [(cx - rx), (cy - ry / num), (cx - rx / num), (cy - ry), (cx), (cy - ry)]], + ['C', [(cx + rx / num), (cy - ry), (cx + rx), (cy - ry / num), (cx + rx), (cy)]], + ['C', [(cx + rx), (cy + ry / num), (cx + rx / num), (cy + ry), (cx), (cy + ry)]], + ['C', [(cx - rx / num), (cy + ry), (cx - rx), (cy + ry / num), (cx - rx), (cy)]], + ['Z', []] + ]); + break; + } case 'path': + d = elem.getAttribute('d'); + break; + case 'line': + a = $(elem).attr(['x1', 'y1', 'x2', 'y2']); + d = 'M' + a.x1 + ',' + a.y1 + 'L' + a.x2 + ',' + a.y2; + break; + case 'polyline': + d = 'M' + elem.getAttribute('points'); + break; + case 'polygon': + d = 'M' + elem.getAttribute('points') + ' Z'; + break; + case 'rect': { + const r = $(elem).attr(['rx', 'ry']); + ({rx, ry} = r); + const b = elem.getBBox(); + const {x, y} = b, + w = b.width, + h = b.height; + num = 4 - num; // Why? Because! + + if (!rx && !ry) { + // Regular rect + d = getPathDFromSegments([ + ['M', [x, y]], + ['L', [x + w, y]], + ['L', [x + w, y + h]], + ['L', [x, y + h]], + ['L', [x, y]], + ['Z', []] + ]); + } else { + d = getPathDFromSegments([ + ['M', [x, y + ry]], + ['C', [x, y + ry / num, x + rx / num, y, x + rx, y]], + ['L', [x + w - rx, y]], + ['C', [x + w - rx / num, y, x + w, y + ry / num, x + w, y + ry]], + ['L', [x + w, y + h - ry]], + ['C', [x + w, y + h - ry / num, x + w - rx / num, y + h, x + w - rx, y + h]], + ['L', [x + rx, y + h]], + ['C', [x + rx / num, y + h, x, y + h - ry / num, x, y + h - ry]], + ['L', [x, y + ry]], + ['Z', []] + ]); + } + break; + } default: + break; + } + + return d; +}; + +/** +* Get a set of attributes from an element that is useful for convertToPath. +* @function module:utilities.getExtraAttributesForConvertToPath +* @param {Element} elem - The element to be probed +* @returns {PlainObject<"marker-start"|"marker-end"|"marker-mid"|"filter"|"clip-path", string>} An object with attributes. +*/ +export const getExtraAttributesForConvertToPath = function (elem) { + const attrs = {}; + // TODO: make this list global so that we can properly maintain it + // TODO: what about @transform, @clip-rule, @fill-rule, etc? + $.each(['marker-start', 'marker-end', 'marker-mid', 'filter', 'clip-path'], function () { + const a = elem.getAttribute(this); + if (a) { + attrs[this] = a; + } + }); + return attrs; +}; + +/** +* Get the BBox of an element-as-path. +* @function module:utilities.getBBoxOfElementAsPath +* @param {Element} elem - The DOM element to be probed +* @param {module:utilities.EditorContext#addSVGElementFromJson} addSVGElementFromJson - Function to add the path element to the current layer. See canvas.addSVGElementFromJson +* @param {module:path.pathActions} pathActions - If a transform exists, `pathActions.resetOrientation()` is used. See: canvas.pathActions. +* @returns {DOMRect|false} The resulting path's bounding box object. +*/ +export const getBBoxOfElementAsPath = function (elem, addSVGElementFromJson, pathActions) { + const path = addSVGElementFromJson({ + element: 'path', + attr: getExtraAttributesForConvertToPath(elem) + }); + + const eltrans = elem.getAttribute('transform'); + if (eltrans) { + path.setAttribute('transform', eltrans); + } + + const {parentNode} = elem; + if (elem.nextSibling) { + elem.before(path); + } else { + parentNode.append(path); + } + + const d = getPathDFromElement(elem); + if (d) { + path.setAttribute('d', d); + } else { + path.remove(); + } + + // Get the correct BBox of the new path, then discard it + pathActions.resetOrientation(path); + let bb = false; + try { + bb = path.getBBox(); + } catch (e) { + // Firefox fails + } + path.remove(); + return bb; +}; + +/** +* Convert selected element to a path. +* @function module:utilities.convertToPath +* @param {Element} elem - The DOM element to be converted +* @param {module:utilities.SVGElementJSON} attrs - Apply attributes to new path. see canvas.convertToPath +* @param {module:utilities.EditorContext#addSVGElementFromJson} addSVGElementFromJson - Function to add the path element to the current layer. See canvas.addSVGElementFromJson +* @param {module:path.pathActions} pathActions - If a transform exists, pathActions.resetOrientation() is used. See: canvas.pathActions. +* @param {module:draw.DrawCanvasInit#clearSelection|module:path.EditorContext#clearSelection} clearSelection - see [canvas.clearSelection]{@link module:svgcanvas.SvgCanvas#clearSelection} +* @param {module:path.EditorContext#addToSelection} addToSelection - see [canvas.addToSelection]{@link module:svgcanvas.SvgCanvas#addToSelection} +* @param {module:history} hstry - see history module +* @param {module:path.EditorContext#addCommandToHistory|module:draw.DrawCanvasInit#addCommandToHistory} addCommandToHistory - see [canvas.addCommandToHistory]{@link module:svgcanvas~addCommandToHistory} +* @returns {SVGPathElement|null} The converted path element or null if the DOM element was not recognized. +*/ +export const convertToPath = function ( + elem, attrs, addSVGElementFromJson, pathActions, + clearSelection, addToSelection, hstry, addCommandToHistory +) { + const batchCmd = new hstry.BatchCommand('Convert element to Path'); + + // Any attribute on the element not covered by the passed-in attributes + attrs = $.extend({}, attrs, getExtraAttributesForConvertToPath(elem)); + + const path = addSVGElementFromJson({ + element: 'path', + attr: attrs + }); + + const eltrans = elem.getAttribute('transform'); + if (eltrans) { + path.setAttribute('transform', eltrans); + } + + const {id} = elem; + const {parentNode} = elem; + if (elem.nextSibling) { + elem.before(path); + } else { + parentNode.append(path); + } + + const d = getPathDFromElement(elem); + if (d) { + path.setAttribute('d', d); + + // Replace the current element with the converted one + + // Reorient if it has a matrix + if (eltrans) { + const tlist = getTransformList(path); + if (hasMatrixTransform(tlist)) { + pathActions.resetOrientation(path); + } + } + + const {nextSibling} = elem; + batchCmd.addSubCommand(new hstry.RemoveElementCommand(elem, nextSibling, parent)); + batchCmd.addSubCommand(new hstry.InsertElementCommand(path)); + + clearSelection(); + elem.remove(); + path.setAttribute('id', id); + path.removeAttribute('visibility'); + addToSelection([path], true); + + addCommandToHistory(batchCmd); + + return path; + } + // the elem.tagName was not recognized, so no "d" attribute. Remove it, so we've haven't changed anything. + path.remove(); + return null; +}; + +/** +* Can the bbox be optimized over the native getBBox? The optimized bbox is the same as the native getBBox when +* the rotation angle is a multiple of 90 degrees and there are no complex transforms. +* Getting an optimized bbox can be dramatically slower, so we want to make sure it's worth it. +* +* The best example for this is a circle rotate 45 degrees. The circle doesn't get wider or taller when rotated +* about it's center. +* +* The standard, unoptimized technique gets the native bbox of the circle, rotates the box 45 degrees, uses +* that width and height, and applies any transforms to get the final bbox. This means the calculated bbox +* is much wider than the original circle. If the angle had been 0, 90, 180, etc. both techniques render the +* same bbox. +* +* The optimization is not needed if the rotation is a multiple 90 degrees. The default technique is to call +* getBBox then apply the angle and any transforms. +* +* @param {Float} angle - The rotation angle in degrees +* @param {boolean} hasAMatrixTransform - True if there is a matrix transform +* @returns {boolean} True if the bbox can be optimized. +*/ +function bBoxCanBeOptimizedOverNativeGetBBox (angle, hasAMatrixTransform) { + const angleModulo90 = angle % 90; + const closeTo90 = angleModulo90 < -89.99 || angleModulo90 > 89.99; + const closeTo0 = angleModulo90 > -0.001 && angleModulo90 < 0.001; + return hasAMatrixTransform || !(closeTo0 || closeTo90); +} + +/** +* Get bounding box that includes any transforms. +* @function module:utilities.getBBoxWithTransform +* @param {Element} elem - The DOM element to be converted +* @param {module:utilities.EditorContext#addSVGElementFromJson} addSVGElementFromJson - Function to add the path element to the current layer. See canvas.addSVGElementFromJson +* @param {module:path.pathActions} pathActions - If a transform exists, pathActions.resetOrientation() is used. See: canvas.pathActions. +* @returns {module:utilities.BBoxObject|module:math.TransformedBox|DOMRect} A single bounding box object +*/ +export const getBBoxWithTransform = function (elem, addSVGElementFromJson, pathActions) { + // TODO: Fix issue with rotated groups. Currently they work + // fine in FF, but not in other browsers (same problem mentioned + // in Issue 339 comment #2). + + let bb = getBBox(elem); + + if (!bb) { + return null; + } + + const tlist = getTransformList(elem); + const angle = getRotationAngleFromTransformList(tlist); + const hasMatrixXForm = hasMatrixTransform(tlist); + + if (angle || hasMatrixXForm) { + let goodBb = false; + if (bBoxCanBeOptimizedOverNativeGetBBox(angle, hasMatrixXForm)) { + // Get the BBox from the raw path for these elements + // TODO: why ellipse and not circle + const elemNames = ['ellipse', 'path', 'line', 'polyline', 'polygon']; + if (elemNames.includes(elem.tagName)) { + goodBb = getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions); + bb = goodBb; + } else if (elem.tagName === 'rect') { + // Look for radius + const rx = elem.getAttribute('rx'); + const ry = elem.getAttribute('ry'); + if (rx || ry) { + goodBb = getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions); + bb = goodBb; + } + } + } + + if (!goodBb) { + const {matrix} = transformListToTransform(tlist); + bb = transformBox(bb.x, bb.y, bb.width, bb.height, matrix).aabox; + + // Old technique that was exceedingly slow with large documents. + // + // Accurate way to get BBox of rotated element in Firefox: + // Put element in group and get its BBox + // + // Must use clone else FF freaks out + // const clone = elem.cloneNode(true); + // const g = document.createElementNS(NS.SVG, 'g'); + // const parent = elem.parentNode; + // parent.append(g); + // g.append(clone); + // const bb2 = bboxToObj(g.getBBox()); + // g.remove(); + } + } + return bb; +}; + +/** + * @param {Element} elem + * @returns {Float} + * @todo This is problematic with large stroke-width and, for example, a single + * horizontal line. The calculated BBox extends way beyond left and right sides. + */ +function getStrokeOffsetForBBox (elem) { + const sw = elem.getAttribute('stroke-width'); + return (!isNaN(sw) && elem.getAttribute('stroke') !== 'none') ? sw / 2 : 0; +} + +/** + * @typedef {PlainObject} BBox + * @property {Integer} x The x value + * @property {Integer} y The y value + * @property {Float} width + * @property {Float} height + */ + +/** +* Get the bounding box for one or more stroked and/or transformed elements. +* @function module:utilities.getStrokedBBox +* @param {Element[]} elems - Array with DOM elements to check +* @param {module:utilities.EditorContext#addSVGElementFromJson} addSVGElementFromJson - Function to add the path element to the current layer. See canvas.addSVGElementFromJson +* @param {module:path.pathActions} pathActions - If a transform exists, pathActions.resetOrientation() is used. See: canvas.pathActions. +* @returns {module:utilities.BBoxObject|module:math.TransformedBox|DOMRect} A single bounding box object +*/ +export const getStrokedBBox = function (elems, addSVGElementFromJson, pathActions) { + if (!elems || !elems.length) { return false; } + + let fullBb; + $.each(elems, function () { + if (fullBb) { return; } + if (!this.parentNode) { return; } + fullBb = getBBoxWithTransform(this, addSVGElementFromJson, pathActions); + }); + + // This shouldn't ever happen... + if (fullBb === undefined) { return null; } + + // fullBb doesn't include the stoke, so this does no good! + // if (elems.length == 1) return fullBb; + + let maxX = fullBb.x + fullBb.width; + let maxY = fullBb.y + fullBb.height; + let minX = fullBb.x; + let minY = fullBb.y; + + // If only one elem, don't call the potentially slow getBBoxWithTransform method again. + if (elems.length === 1) { + const offset = getStrokeOffsetForBBox(elems[0]); + minX -= offset; + minY -= offset; + maxX += offset; + maxY += offset; + } else { + $.each(elems, function (i, elem) { + const curBb = getBBoxWithTransform(elem, addSVGElementFromJson, pathActions); + if (curBb) { + const offset = getStrokeOffsetForBBox(elem); + minX = Math.min(minX, curBb.x - offset); + minY = Math.min(minY, curBb.y - offset); + // TODO: The old code had this test for max, but not min. I suspect this test should be for both min and max + if (elem.nodeType === 1) { + maxX = Math.max(maxX, curBb.x + curBb.width + offset); + maxY = Math.max(maxY, curBb.y + curBb.height + offset); + } + } + }); + } + + fullBb.x = minX; + fullBb.y = minY; + fullBb.width = maxX - minX; + fullBb.height = maxY - minY; + return fullBb; +}; + +/** +* Get all elements that have a BBox (excludes ``, ``, etc). +* Note that 0-opacity, off-screen etc elements are still considered "visible" +* for this function. +* @function module:utilities.getVisibleElements +* @param {Element} parentElement - The parent DOM element to search within +* @returns {Element[]} All "visible" elements. +*/ +export const getVisibleElements = function (parentElement) { + if (!parentElement) { + parentElement = $(editorContext_.getSVGContent()).children(); // Prevent layers from being included + } + + const contentElems = []; + $(parentElement).children().each(function (i, elem) { + if (elem.getBBox) { + contentElems.push(elem); + } + }); + return contentElems.reverse(); +}; + +/** +* Get the bounding box for one or more stroked and/or transformed elements. +* @function module:utilities.getStrokedBBoxDefaultVisible +* @param {Element[]} elems - Array with DOM elements to check +* @returns {module:utilities.BBoxObject} A single bounding box object +*/ +export const getStrokedBBoxDefaultVisible = function (elems) { + if (!elems) { elems = getVisibleElements(); } + return getStrokedBBox( + elems, + editorContext_.addSVGElementFromJson, + editorContext_.pathActions + ); +}; + +/** +* Get the rotation angle of the given transform list. +* @function module:utilities.getRotationAngleFromTransformList +* @param {SVGTransformList} tlist - List of transforms +* @param {boolean} toRad - When true returns the value in radians rather than degrees +* @returns {Float} The angle in degrees or radians +*/ +export const getRotationAngleFromTransformList = function (tlist, toRad) { + if (!tlist) { return 0; } // <svg> elements have no tlist + const N = tlist.numberOfItems; + for (let i = 0; i < N; ++i) { + const xform = tlist.getItem(i); + if (xform.type === 4) { + return toRad ? xform.angle * Math.PI / 180.0 : xform.angle; + } + } + return 0.0; +}; + +/** +* Get the rotation angle of the given/selected DOM element. +* @function module:utilities.getRotationAngle +* @param {Element} [elem] - DOM element to get the angle for. Default to first of selected elements. +* @param {boolean} [toRad=false] - When true returns the value in radians rather than degrees +* @returns {Float} The angle in degrees or radians +*/ +export let getRotationAngle = function (elem, toRad) { // eslint-disable-line import/no-mutable-exports + const selected = elem || editorContext_.getSelectedElements()[0]; + // find the rotation transform (if any) and set it + const tlist = getTransformList(selected); + return getRotationAngleFromTransformList(tlist, toRad); +}; + +/** +* Get the reference element associated with the given attribute value. +* @function module:utilities.getRefElem +* @param {string} attrVal - The attribute value as a string +* @returns {Element} Reference element +*/ +export const getRefElem = function (attrVal) { + return getElem(getUrlFromAttr(attrVal).substr(1)); +}; + +/** +* Get a DOM element by ID within the SVG root element. +* @function module:utilities.getElem +* @param {string} id - String with the element's new ID +* @returns {?Element} +*/ +export const getElem = (supportsSelectors()) + ? function (id) { + // querySelector lookup + return svgroot_.querySelector('#' + id); + } + : supportsXpath() + ? function (id) { + // xpath lookup + return domdoc_.evaluate( + 'svg:svg[@id="svgroot"]//svg:*[@id="' + id + '"]', + domcontainer_, + function () { return NS.SVG; }, + 9, + null + ).singleNodeValue; + } + : function (id) { + // jQuery lookup: twice as slow as xpath in FF + return $(svgroot_).find(`[id=${id}]`)[0]; + }; + +/** +* Assigns multiple attributes to an element. +* @function module:utilities.assignAttributes +* @param {Element} elem - DOM element to apply new attribute values to +* @param {PlainObject<string, string>} attrs - Object with attribute keys/values +* @param {Integer} [suspendLength] - Milliseconds to suspend redraw +* @param {boolean} [unitCheck=false] - Boolean to indicate the need to use units.setUnitAttr +* @returns {void} +*/ +export const assignAttributes = function (elem, attrs, suspendLength, unitCheck) { + for (const [key, value] of Object.entries(attrs)) { + const ns = (key.substr(0, 4) === 'xml:' + ? NS.XML + : key.substr(0, 6) === 'xlink:' ? NS.XLINK : null); + if (isNullish(value)) { + if (ns) { + elem.removeAttributeNS(ns, key); + } else { + elem.removeAttribute(key); + } + continue; + } + if (ns) { + elem.setAttributeNS(ns, key, value); + } else if (!unitCheck) { + elem.setAttribute(key, value); + } else { + setUnitAttr(elem, key, value); + } + } +}; + +/** +* Remove unneeded (default) attributes, making resulting SVG smaller. +* @function module:utilities.cleanupElement +* @param {Element} element - DOM element to clean up +* @returns {void} +*/ +export const cleanupElement = function (element) { + const defaults = { + 'fill-opacity': 1, + 'stop-opacity': 1, + opacity: 1, + stroke: 'none', + 'stroke-dasharray': 'none', + 'stroke-linejoin': 'miter', + 'stroke-linecap': 'butt', + 'stroke-opacity': 1, + 'stroke-width': 1, + rx: 0, + ry: 0 + }; + + if (element.nodeName === 'ellipse') { + // Ellipse elements require rx and ry attributes + delete defaults.rx; + delete defaults.ry; + } + + Object.entries(defaults).forEach(([attr, val]) => { + if (element.getAttribute(attr) === String(val)) { + element.removeAttribute(attr); + } + }); +}; + +/** +* Round value to for snapping. +* @function module:utilities.snapToGrid +* @param {Float} value +* @returns {Integer} +*/ +export const snapToGrid = function (value) { + const unit = editorContext_.getBaseUnit(); + let stepSize = editorContext_.getSnappingStep(); + if (unit !== 'px') { + stepSize *= getTypeMap()[unit]; + } + value = Math.round(value / stepSize) * stepSize; + return value; +}; + +/** +* Escapes special characters in a regular expression. +* @function module:utilities.regexEscape +* @param {string} str +* @returns {string} +*/ +export const regexEscape = function (str) { + // Originally from: http://phpjs.org/functions + return String(str).replace(/[.\\+*?[^\]$(){}=!<>|:-]/g, '\\$&'); +}; + +/** + * Prevents default browser click behaviour on the given element. + * @function module:utilities.preventClickDefault + * @param {Element} img - The DOM element to prevent the click on + * @returns {void} + */ +export const preventClickDefault = function (img) { + $(img).click(function (e) { e.preventDefault(); }); +}; + +/** + * @callback module:utilities.GetNextID + * @returns {string} The ID + */ + +/** + * Whether a value is `null` or `undefined`. + * @param {any} val + * @returns {boolean} + */ +export const isNullish = (val) => { + return val === null || val === undefined; +}; + +/** +* Overwrite methods for unit testing. +* @function module:utilities.mock +* @param {PlainObject} mockMethods +* @param {module:utilities.getHref} mockMethods.getHref +* @param {module:utilities.setHref} mockMethods.setHref +* @param {module:utilities.getRotationAngle} mockMethods.getRotationAngle +* @returns {void} +*/ +export const mock = ({ + getHref: getHrefUser, setHref: setHrefUser, getRotationAngle: getRotationAngleUser +}) => { + getHref = getHrefUser; + setHref = setHrefUser; + getRotationAngle = getRotationAngleUser; +}; + +export const $q = (sel) => document.querySelector(sel); +export const $qq = (sel) => [...document.querySelectorAll(sel)]; diff --git a/dist/editor/browser-not-supported.html b/dist/editor/browser-not-supported.html new file mode 100644 index 00000000..6ec7af4e --- /dev/null +++ b/dist/editor/browser-not-supported.html @@ -0,0 +1,54 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8" /> + <meta http-equiv="X-UA-Compatible" content="chrome=1"/> + <link rel="icon" type="image/png" href="images/logo.png"/> + <link rel="stylesheet" href="svg-editor.css"/> + <title>Browser does not support SVG | SVG-edit + + + + +

Sorry, but your browser does not support SVG. Below is a list of + alternate browsers and versions that support SVG and SVG-edit + (from caniuse.com). +

+

Try the latest version of + Firefox, + Chrome, + Safari, + Opera or + Internet Explorer. +

+
+ +
+ + diff --git a/dist/editor/embedapi.html b/dist/editor/embedapi.html new file mode 100644 index 00000000..dda45a19 --- /dev/null +++ b/dist/editor/embedapi.html @@ -0,0 +1,17 @@ + + + + + Embed API + + + + + + + + + +
+ + diff --git a/dist/editor/embedapi.js b/dist/editor/embedapi.js new file mode 100644 index 00000000..dd6459c4 --- /dev/null +++ b/dist/editor/embedapi.js @@ -0,0 +1,395 @@ +/** +* Handles underlying communication between the embedding window and the +* editor frame. +* @module EmbeddedSVGEdit +*/ + +let cbid = 0; + +/** +* @callback module:EmbeddedSVGEdit.CallbackSetter +* @param {GenericCallback} newCallback Callback to be stored (signature dependent on function) +* @returns {void} +*/ +/** +* @callback module:EmbeddedSVGEdit.CallbackSetGetter +* @param {...any} args Signature dependent on the function +* @returns {module:EmbeddedSVGEdit.CallbackSetter} +*/ + +/** +* @param {string} funcName +* @returns {module:EmbeddedSVGEdit.CallbackSetGetter} +*/ +function getCallbackSetter (funcName) { + return function (...args) { + const that = this, // New callback + callbackID = this.send(funcName, args, function () { /* */ }); // The callback (currently it's nothing, but will be set later) + + return function (newCallback) { + that.callbacks[callbackID] = newCallback; // Set callback + }; + }; +} + +/** +* Having this separate from messageListener allows us to +* avoid using JSON parsing (and its limitations) in the case +* of same domain control. +* @param {module:EmbeddedSVGEdit.EmbeddedSVGEdit} t The `this` value +* @param {PlainObject} data +* @param {JSON} data.result +* @param {string} data.error +* @param {Integer} data.id +* @returns {void} +*/ +function addCallback (t, {result, error, id: callbackID}) { + if (typeof callbackID === 'number' && t.callbacks[callbackID]) { + // These should be safe both because we check `cbid` is numeric and + // because the calls are from trusted origins + if (result) { + t.callbacks[callbackID](result); // lgtm [js/unvalidated-dynamic-method-call] + } else { + t.callbacks[callbackID](error, 'error'); // lgtm [js/unvalidated-dynamic-method-call] + } + } +} + +/** +* @param {Event} e +* @returns {void} +*/ +function messageListener (e) { + // We accept and post strings as opposed to objects for the sake of IE9 support; this + // will most likely be changed in the future + if (!e.data || !['string', 'object'].includes(typeof e.data)) { + return; + } + const {allowedOrigins} = this, + data = typeof e.data === 'object' ? e.data : JSON.parse(e.data); + if (!data || typeof data !== 'object' || data.namespace !== 'svg-edit' || + e.source !== this.frame.contentWindow || + (!allowedOrigins.includes('*') && !allowedOrigins.includes(e.origin)) + ) { + // eslint-disable-next-line no-console -- Info for developers + console.error( + `The origin ${e.origin} was not whitelisted as an origin from ` + + `which responses may be received by this ${window.origin} script.` + ); + return; + } + addCallback(this, data); +} + +/** +* @callback module:EmbeddedSVGEdit.MessageListener +* @param {MessageEvent} e +* @returns {void} +*/ +/** +* @param {module:EmbeddedSVGEdit.EmbeddedSVGEdit} t The `this` value +* @returns {module:EmbeddedSVGEdit.MessageListener} Event listener +*/ +function getMessageListener (t) { + return function (e) { + messageListener.call(t, e); + }; +} + +/** +* Embedded SVG-edit API. +* General usage: +* - Have an iframe somewhere pointing to a version of svg-edit > r1000. +* @example +// Initialize the magic with: +const svgCanvas = new EmbeddedSVGEdit(window.frames.svgedit); + +// Pass functions in this format: +svgCanvas.setSvgString('string'); + +// Or if a callback is needed: +svgCanvas.setSvgString('string')(function (data, error) { + if (error) { + // There was an error + } else { + // Handle data + } +}); + +// Everything is done with the same API as the real svg-edit, +// and all documentation is unchanged. + +// However, this file depends on the postMessage API which +// can only support JSON-serializable arguments and +// return values, so, for example, arguments whose value is +// 'undefined', a function, a non-finite number, or a built-in +// object like Date(), RegExp(), etc. will most likely not behave +// as expected. In such a case one may need to host +// the SVG editor on the same domain and reference the +// JavaScript methods on the frame itself. + +// The only other difference is when handling returns: +// the callback notation is used instead. +const blah = new EmbeddedSVGEdit(window.frames.svgedit); +blah.clearSelection('woot', 'blah', 1337, [1, 2, 3, 4, 5, 'moo'], -42, { + a: 'tree', b: 6, c: 9 +})(function () { console.log('GET DATA', args); }); +* +* @memberof module:EmbeddedSVGEdit +*/ +class EmbeddedSVGEdit { + /** + * @param {HTMLIFrameElement} frame + * @param {string[]} [allowedOrigins=[]] Array of origins from which incoming + * messages will be allowed when same origin is not used; defaults to none. + * If supplied, it should probably be the same as svgEditor's allowedOrigins + */ + constructor (frame, allowedOrigins) { + const that = this; + this.allowedOrigins = allowedOrigins || []; + // Initialize communication + this.frame = frame; + this.callbacks = {}; + // List of functions extracted with this: + // Run in firebug on http://svg-edit.googlecode.com/svn/trunk/docs/files/svgcanvas-js.html + + // for (const i=0,q=[],f = document.querySelectorAll('div.CFunction h3.CTitle a'); i < f.length; i++) { q.push(f[i].name); }; q + // const functions = ['clearSelection', 'addToSelection', 'removeFromSelection', 'open', 'save', 'getSvgString', 'setSvgString', + // 'createLayer', 'deleteCurrentLayer', 'setCurrentLayer', 'renameCurrentLayer', 'setCurrentLayerPosition', 'setLayerVisibility', + // 'moveSelectedToLayer', 'clear']; + + // Newer, well, it extracts things that aren't documented as well. All functions accessible through the normal thingy can now be accessed though the API + // const {svgCanvas} = frame.contentWindow; + // const l = []; + // for (const i in svgCanvas) { if (typeof svgCanvas[i] === 'function') { l.push(i);} }; + // alert("['" + l.join("', '") + "']"); + // Run in svgedit itself + const functions = [ + 'addExtension', + 'addSVGElementFromJson', + 'addToSelection', + 'alignSelectedElements', + 'assignAttributes', + 'bind', + 'call', + 'changeSelectedAttribute', + 'cleanupElement', + 'clear', + 'clearSelection', + 'clearSvgContentElement', + 'cloneLayer', + 'cloneSelectedElements', + 'convertGradients', + 'convertToGroup', + 'convertToNum', + 'convertToPath', + 'copySelectedElements', + 'createLayer', + 'cutSelectedElements', + 'cycleElement', + 'deleteCurrentLayer', + 'deleteSelectedElements', + 'embedImage', + 'exportPDF', + 'findDefs', + 'getBBox', + 'getBlur', + 'getBold', + 'getColor', + 'getContentElem', + 'getCurrentDrawing', + 'getDocumentTitle', + 'getEditorNS', + 'getElem', + 'getFillOpacity', + 'getFontColor', + 'getFontFamily', + 'getFontSize', + 'getHref', + 'getId', + 'getIntersectionList', + 'getItalic', + 'getMode', + 'getMouseTarget', + 'getNextId', + 'getOffset', + 'getOpacity', + 'getPaintOpacity', + 'getPrivateMethods', + 'getRefElem', + 'getResolution', + 'getRootElem', + 'getRotationAngle', + 'getSelectedElems', + 'getStrokeOpacity', + 'getStrokeWidth', + 'getStrokedBBox', + 'getStyle', + 'getSvgString', + 'getText', + 'getTitle', + 'getTransformList', + 'getUIStrings', + 'getUrlFromAttr', + 'getVersion', + 'getVisibleElements', + 'getVisibleElementsAndBBoxes', + 'getZoom', + 'groupSelectedElements', + 'groupSvgElem', + 'hasMatrixTransform', + 'identifyLayers', + 'importSvgString', + 'leaveContext', + 'linkControlPoints', + 'makeHyperlink', + 'matrixMultiply', + 'mergeAllLayers', + 'mergeLayer', + 'moveSelectedElements', + 'moveSelectedToLayer', + 'moveToBottomSelectedElement', + 'moveToTopSelectedElement', + 'moveUpDownSelected', + 'open', + 'pasteElements', + 'prepareSvg', + 'pushGroupProperties', + 'randomizeIds', + 'rasterExport', + 'ready', + 'recalculateAllSelectedDimensions', + 'recalculateDimensions', + 'remapElement', + 'removeFromSelection', + 'removeHyperlink', + 'removeUnusedDefElems', + 'renameCurrentLayer', + 'round', + 'runExtensions', + 'sanitizeSvg', + 'save', + 'selectAllInCurrentLayer', + 'selectOnly', + 'setBBoxZoom', + 'setBackground', + 'setBlur', + 'setBlurNoUndo', + 'setBlurOffsets', + 'setBold', + 'setColor', + 'setConfig', + 'setContext', + 'setCurrentLayer', + 'setCurrentLayerPosition', + 'setDocumentTitle', + 'setFillPaint', + 'setFontColor', + 'setFontFamily', + 'setFontSize', + 'setGoodImage', + 'setGradient', + 'setGroupTitle', + 'setHref', + 'setIdPrefix', + 'setImageURL', + 'setItalic', + 'setLayerVisibility', + 'setLinkURL', + 'setMode', + 'setOpacity', + 'setPaint', + 'setPaintOpacity', + 'setRectRadius', + 'setResolution', + 'setRotationAngle', + 'setSegType', + 'setStrokeAttr', + 'setStrokePaint', + 'setStrokeWidth', + 'setSvgString', + 'setTextContent', + 'setUiStrings', + 'setUseData', + 'setZoom', + 'svgCanvasToString', + 'svgToString', + 'transformListToTransform', + 'ungroupSelectedElement', + 'uniquifyElems', + 'updateCanvas', + 'zoomChanged' + ]; + + // TODO: rewrite the following, it's pretty scary. + for (const func of functions) { + this[func] = getCallbackSetter(func); + } + + // Older IE may need a polyfill for addEventListener, but so it would for SVG + window.addEventListener('message', getMessageListener(this)); + window.addEventListener('keydown', (e) => { + const {type, key} = e; + if (key === 'Backspace') { + e.preventDefault(); + const keyboardEvent = new KeyboardEvent(type, {key}); + that.frame.contentDocument.dispatchEvent(keyboardEvent); + } + }); + } + + /** + * @param {string} name + * @param {ArgumentsArray} args Signature dependent on function + * @param {GenericCallback} callback (This may be better than a promise in case adding an event.) + * @returns {Integer} + */ + send (name, args, callback) { // eslint-disable-line promise/prefer-await-to-callbacks + const that = this; + cbid++; + + this.callbacks[cbid] = callback; + setTimeout((function (callbackID) { + return function () { // Delay for the callback to be set in case its synchronous + /* + * Todo: Handle non-JSON arguments and return values (undefined, + * nonfinite numbers, functions, and built-in objects like Date, + * RegExp), etc.? Allow promises instead of callbacks? Review + * SVG-Edit functions for whether JSON-able parameters can be + * made compatile with all API functionality + */ + // We accept and post strings for the sake of IE9 support + let sameOriginWithGlobal = false; + try { + sameOriginWithGlobal = window.location.origin === that.frame.contentWindow.location.origin && + that.frame.contentWindow.svgEditor.canvas; + } catch (err) {} + + if (sameOriginWithGlobal) { + // Although we do not really need this API if we are working same + // domain, it could allow us to write in a way that would work + // cross-domain as well, assuming we stick to the argument limitations + // of the current JSON-based communication API (e.g., not passing + // callbacks). We might be able to address these shortcomings; see + // the todo elsewhere in this file. + const message = {id: callbackID}, + {svgEditor: {canvas: svgCanvas}} = that.frame.contentWindow; + try { + message.result = svgCanvas[name](...args); + } catch (err) { + message.error = err.message; + } + addCallback(that, message); + } else { // Requires the ext-xdomain-messaging.js extension + that.frame.contentWindow.postMessage(JSON.stringify({ + namespace: 'svgCanvas', id: callbackID, name, args + }), '*'); + } + }; + }(cbid)), 0); + + return cbid; + } +} + +export default EmbeddedSVGEdit; diff --git a/dist/editor/extensions/ext-arrows.js b/dist/editor/extensions/ext-arrows.js new file mode 100644 index 00000000..2b22cb0c --- /dev/null +++ b/dist/editor/extensions/ext-arrows.js @@ -0,0 +1,2006 @@ +function _typeof(obj) { + "@babel/helpers - typeof"; + + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function (obj) { + return typeof obj; + }; + } else { + _typeof = function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); +} + +var REACT_ELEMENT_TYPE; + +function _jsx(type, props, key, children) { + if (!REACT_ELEMENT_TYPE) { + REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol["for"] && Symbol["for"]("react.element") || 0xeac7; + } + + var defaultProps = type && type.defaultProps; + var childrenLength = arguments.length - 3; + + if (!props && childrenLength !== 0) { + props = { + children: void 0 + }; + } + + if (childrenLength === 1) { + props.children = children; + } else if (childrenLength > 1) { + var childArray = new Array(childrenLength); + + for (var i = 0; i < childrenLength; i++) { + childArray[i] = arguments[i + 3]; + } + + props.children = childArray; + } + + if (props && defaultProps) { + for (var propName in defaultProps) { + if (props[propName] === void 0) { + props[propName] = defaultProps[propName]; + } + } + } else if (!props) { + props = defaultProps || {}; + } + + return { + $$typeof: REACT_ELEMENT_TYPE, + type: type, + key: key === undefined ? null : '' + key, + ref: null, + props: props, + _owner: null + }; +} + +function _asyncIterator(iterable) { + var method; + + if (typeof Symbol !== "undefined") { + if (Symbol.asyncIterator) { + method = iterable[Symbol.asyncIterator]; + if (method != null) return method.call(iterable); + } + + if (Symbol.iterator) { + method = iterable[Symbol.iterator]; + if (method != null) return method.call(iterable); + } + } + + throw new TypeError("Object is not async iterable"); +} + +function _AwaitValue(value) { + this.wrapped = value; +} + +function _AsyncGenerator(gen) { + var front, back; + + function send(key, arg) { + return new Promise(function (resolve, reject) { + var request = { + key: key, + arg: arg, + resolve: resolve, + reject: reject, + next: null + }; + + if (back) { + back = back.next = request; + } else { + front = back = request; + resume(key, arg); + } + }); + } + + function resume(key, arg) { + try { + var result = gen[key](arg); + var value = result.value; + var wrappedAwait = value instanceof _AwaitValue; + Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { + if (wrappedAwait) { + resume(key === "return" ? "return" : "next", arg); + return; + } + + settle(result.done ? "return" : "normal", arg); + }, function (err) { + resume("throw", err); + }); + } catch (err) { + settle("throw", err); + } + } + + function settle(type, value) { + switch (type) { + case "return": + front.resolve({ + value: value, + done: true + }); + break; + + case "throw": + front.reject(value); + break; + + default: + front.resolve({ + value: value, + done: false + }); + break; + } + + front = front.next; + + if (front) { + resume(front.key, front.arg); + } else { + back = null; + } + } + + this._invoke = send; + + if (typeof gen.return !== "function") { + this.return = undefined; + } +} + +if (typeof Symbol === "function" && Symbol.asyncIterator) { + _AsyncGenerator.prototype[Symbol.asyncIterator] = function () { + return this; + }; +} + +_AsyncGenerator.prototype.next = function (arg) { + return this._invoke("next", arg); +}; + +_AsyncGenerator.prototype.throw = function (arg) { + return this._invoke("throw", arg); +}; + +_AsyncGenerator.prototype.return = function (arg) { + return this._invoke("return", arg); +}; + +function _wrapAsyncGenerator(fn) { + return function () { + return new _AsyncGenerator(fn.apply(this, arguments)); + }; +} + +function _awaitAsyncGenerator(value) { + return new _AwaitValue(value); +} + +function _asyncGeneratorDelegate(inner, awaitWrap) { + var iter = {}, + waiting = false; + + function pump(key, value) { + waiting = true; + value = new Promise(function (resolve) { + resolve(inner[key](value)); + }); + return { + done: false, + value: awaitWrap(value) + }; + } + + ; + + if (typeof Symbol === "function" && Symbol.iterator) { + iter[Symbol.iterator] = function () { + return this; + }; + } + + iter.next = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("next", value); + }; + + if (typeof inner.throw === "function") { + iter.throw = function (value) { + if (waiting) { + waiting = false; + throw value; + } + + return pump("throw", value); + }; + } + + if (typeof inner.return === "function") { + iter.return = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("return", value); + }; + } + + return iter; +} + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { + try { + var info = gen[key](arg); + var value = info.value; + } catch (error) { + reject(error); + return; + } + + if (info.done) { + resolve(value); + } else { + Promise.resolve(value).then(_next, _throw); + } +} + +function _asyncToGenerator(fn) { + return function () { + var self = this, + args = arguments; + return new Promise(function (resolve, reject) { + var gen = fn.apply(self, args); + + function _next(value) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); + } + + function _throw(err) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); + } + + _next(undefined); + }); + }; +} + +function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +} + +function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } +} + +function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; +} + +function _defineEnumerableProperties(obj, descs) { + for (var key in descs) { + var desc = descs[key]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, key, desc); + } + + if (Object.getOwnPropertySymbols) { + var objectSymbols = Object.getOwnPropertySymbols(descs); + + for (var i = 0; i < objectSymbols.length; i++) { + var sym = objectSymbols[i]; + var desc = descs[sym]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, sym, desc); + } + } + + return obj; +} + +function _defaults(obj, defaults) { + var keys = Object.getOwnPropertyNames(defaults); + + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var value = Object.getOwnPropertyDescriptor(defaults, key); + + if (value && value.configurable && obj[key] === undefined) { + Object.defineProperty(obj, key, value); + } + } + + return obj; +} + +function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; +} + +function _extends() { + _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + + return _extends.apply(this, arguments); +} + +function _objectSpread(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? Object(arguments[i]) : {}; + var ownKeys = Object.keys(source); + + if (typeof Object.getOwnPropertySymbols === 'function') { + ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { + return Object.getOwnPropertyDescriptor(source, sym).enumerable; + })); + } + + ownKeys.forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } + + return target; +} + +function ownKeys(object, enumerableOnly) { + var keys = Object.keys(object); + + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(object); + if (enumerableOnly) symbols = symbols.filter(function (sym) { + return Object.getOwnPropertyDescriptor(object, sym).enumerable; + }); + keys.push.apply(keys, symbols); + } + + return keys; +} + +function _objectSpread2(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? arguments[i] : {}; + + if (i % 2) { + ownKeys(Object(source), true).forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } else if (Object.getOwnPropertyDescriptors) { + Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); + } else { + ownKeys(Object(source)).forEach(function (key) { + Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); + }); + } + } + + return target; +} + +function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function"); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + writable: true, + configurable: true + } + }); + if (superClass) _setPrototypeOf(subClass, superClass); +} + +function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + subClass.__proto__ = superClass; +} + +function _getPrototypeOf(o) { + _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { + return o.__proto__ || Object.getPrototypeOf(o); + }; + return _getPrototypeOf(o); +} + +function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + + return _setPrototypeOf(o, p); +} + +function _isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + + try { + Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); + return true; + } catch (e) { + return false; + } +} + +function _construct(Parent, args, Class) { + if (_isNativeReflectConstruct()) { + _construct = Reflect.construct; + } else { + _construct = function _construct(Parent, args, Class) { + var a = [null]; + a.push.apply(a, args); + var Constructor = Function.bind.apply(Parent, a); + var instance = new Constructor(); + if (Class) _setPrototypeOf(instance, Class.prototype); + return instance; + }; + } + + return _construct.apply(null, arguments); +} + +function _isNativeFunction(fn) { + return Function.toString.call(fn).indexOf("[native code]") !== -1; +} + +function _wrapNativeSuper(Class) { + var _cache = typeof Map === "function" ? new Map() : undefined; + + _wrapNativeSuper = function _wrapNativeSuper(Class) { + if (Class === null || !_isNativeFunction(Class)) return Class; + + if (typeof Class !== "function") { + throw new TypeError("Super expression must either be null or a function"); + } + + if (typeof _cache !== "undefined") { + if (_cache.has(Class)) return _cache.get(Class); + + _cache.set(Class, Wrapper); + } + + function Wrapper() { + return _construct(Class, arguments, _getPrototypeOf(this).constructor); + } + + Wrapper.prototype = Object.create(Class.prototype, { + constructor: { + value: Wrapper, + enumerable: false, + writable: true, + configurable: true + } + }); + return _setPrototypeOf(Wrapper, Class); + }; + + return _wrapNativeSuper(Class); +} + +function _instanceof(left, right) { + if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { + return !!right[Symbol.hasInstance](left); + } else { + return left instanceof right; + } +} + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; +} + +function _getRequireWildcardCache() { + if (typeof WeakMap !== "function") return null; + var cache = new WeakMap(); + + _getRequireWildcardCache = function () { + return cache; + }; + + return cache; +} + +function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } + + if (obj === null || typeof obj !== "object" && typeof obj !== "function") { + return { + default: obj + }; + } + + var cache = _getRequireWildcardCache(); + + if (cache && cache.has(obj)) { + return cache.get(obj); + } + + var newObj = {}; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + + if (desc && (desc.get || desc.set)) { + Object.defineProperty(newObj, key, desc); + } else { + newObj[key] = obj[key]; + } + } + } + + newObj.default = obj; + + if (cache) { + cache.set(obj, newObj); + } + + return newObj; +} + +function _newArrowCheck(innerThis, boundThis) { + if (innerThis !== boundThis) { + throw new TypeError("Cannot instantiate an arrow function"); + } +} + +function _objectDestructuringEmpty(obj) { + if (obj == null) throw new TypeError("Cannot destructure undefined"); +} + +function _objectWithoutPropertiesLoose(source, excluded) { + if (source == null) return {}; + var target = {}; + var sourceKeys = Object.keys(source); + var key, i; + + for (i = 0; i < sourceKeys.length; i++) { + key = sourceKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + target[key] = source[key]; + } + + return target; +} + +function _objectWithoutProperties(source, excluded) { + if (source == null) return {}; + + var target = _objectWithoutPropertiesLoose(source, excluded); + + var key, i; + + if (Object.getOwnPropertySymbols) { + var sourceSymbolKeys = Object.getOwnPropertySymbols(source); + + for (i = 0; i < sourceSymbolKeys.length; i++) { + key = sourceSymbolKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; + target[key] = source[key]; + } + } + + return target; +} + +function _assertThisInitialized(self) { + if (self === void 0) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return self; +} + +function _possibleConstructorReturn(self, call) { + if (call && (typeof call === "object" || typeof call === "function")) { + return call; + } + + return _assertThisInitialized(self); +} + +function _createSuper(Derived) { + var hasNativeReflectConstruct = _isNativeReflectConstruct(); + + return function _createSuperInternal() { + var Super = _getPrototypeOf(Derived), + result; + + if (hasNativeReflectConstruct) { + var NewTarget = _getPrototypeOf(this).constructor; + + result = Reflect.construct(Super, arguments, NewTarget); + } else { + result = Super.apply(this, arguments); + } + + return _possibleConstructorReturn(this, result); + }; +} + +function _superPropBase(object, property) { + while (!Object.prototype.hasOwnProperty.call(object, property)) { + object = _getPrototypeOf(object); + if (object === null) break; + } + + return object; +} + +function _get(target, property, receiver) { + if (typeof Reflect !== "undefined" && Reflect.get) { + _get = Reflect.get; + } else { + _get = function _get(target, property, receiver) { + var base = _superPropBase(target, property); + + if (!base) return; + var desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.get) { + return desc.get.call(receiver); + } + + return desc.value; + }; + } + + return _get(target, property, receiver || target); +} + +function set(target, property, value, receiver) { + if (typeof Reflect !== "undefined" && Reflect.set) { + set = Reflect.set; + } else { + set = function set(target, property, value, receiver) { + var base = _superPropBase(target, property); + + var desc; + + if (base) { + desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.set) { + desc.set.call(receiver, value); + return true; + } else if (!desc.writable) { + return false; + } + } + + desc = Object.getOwnPropertyDescriptor(receiver, property); + + if (desc) { + if (!desc.writable) { + return false; + } + + desc.value = value; + Object.defineProperty(receiver, property, desc); + } else { + _defineProperty(receiver, property, value); + } + + return true; + }; + } + + return set(target, property, value, receiver); +} + +function _set(target, property, value, receiver, isStrict) { + var s = set(target, property, value, receiver || target); + + if (!s && isStrict) { + throw new Error('failed to set property'); + } + + return value; +} + +function _taggedTemplateLiteral(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + return Object.freeze(Object.defineProperties(strings, { + raw: { + value: Object.freeze(raw) + } + })); +} + +function _taggedTemplateLiteralLoose(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + strings.raw = raw; + return strings; +} + +function _readOnlyError(name) { + throw new Error("\"" + name + "\" is read-only"); +} + +function _classNameTDZError(name) { + throw new Error("Class \"" + name + "\" cannot be referenced in computed property keys."); +} + +function _temporalUndefined() {} + +function _tdz(name) { + throw new ReferenceError(name + " is not defined - temporal dead zone"); +} + +function _temporalRef(val, name) { + return val === _temporalUndefined ? _tdz(name) : val; +} + +function _slicedToArray(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); +} + +function _slicedToArrayLoose(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimitLoose(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); +} + +function _toArray(arr) { + return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); +} + +function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); +} + +function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) return _arrayLikeToArray(arr); +} + +function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; +} + +function _maybeArrayLike(next, arr, i) { + if (arr && !Array.isArray(arr) && typeof arr.length === "number") { + var len = arr.length; + return _arrayLikeToArray(arr, i !== void 0 && i < len ? i : len); + } + + return next(arr, i); +} + +function _iterableToArray(iter) { + if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); +} + +function _iterableToArrayLimit(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"] != null) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; +} + +function _iterableToArrayLimitLoose(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + + for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { + _arr.push(_step.value); + + if (i && _arr.length === i) break; + } + + return _arr; +} + +function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if (typeof o === "string") return _arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + if (n === "Object" && o.constructor) n = o.constructor.name; + if (n === "Map" || n === "Set") return Array.from(o); + if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); +} + +function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) len = arr.length; + + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + + return arr2; +} + +function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); +} + +function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); +} + +function _createForOfIteratorHelper(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + + var F = function () {}; + + return { + s: F, + n: function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }, + e: function (e) { + throw e; + }, + f: F + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + var normalCompletion = true, + didErr = false, + err; + return { + s: function () { + it = o[Symbol.iterator](); + }, + n: function () { + var step = it.next(); + normalCompletion = step.done; + return step; + }, + e: function (e) { + didErr = true; + err = e; + }, + f: function () { + try { + if (!normalCompletion && it.return != null) it.return(); + } finally { + if (didErr) throw err; + } + } + }; +} + +function _createForOfIteratorHelperLoose(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + return function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + it = o[Symbol.iterator](); + return it.next.bind(it); +} + +function _skipFirstGeneratorNext(fn) { + return function () { + var it = fn.apply(this, arguments); + it.next(); + return it; + }; +} + +function _toPrimitive(input, hint) { + if (typeof input !== "object" || input === null) return input; + var prim = input[Symbol.toPrimitive]; + + if (prim !== undefined) { + var res = prim.call(input, hint || "default"); + if (typeof res !== "object") return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + + return (hint === "string" ? String : Number)(input); +} + +function _toPropertyKey(arg) { + var key = _toPrimitive(arg, "string"); + + return typeof key === "symbol" ? key : String(key); +} + +function _initializerWarningHelper(descriptor, context) { + throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.'); +} + +function _initializerDefineProperty(target, property, descriptor, context) { + if (!descriptor) return; + Object.defineProperty(target, property, { + enumerable: descriptor.enumerable, + configurable: descriptor.configurable, + writable: descriptor.writable, + value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 + }); +} + +function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { + var desc = {}; + Object.keys(descriptor).forEach(function (key) { + desc[key] = descriptor[key]; + }); + desc.enumerable = !!desc.enumerable; + desc.configurable = !!desc.configurable; + + if ('value' in desc || desc.initializer) { + desc.writable = true; + } + + desc = decorators.slice().reverse().reduce(function (desc, decorator) { + return decorator(target, property, desc) || desc; + }, desc); + + if (context && desc.initializer !== void 0) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = undefined; + } + + if (desc.initializer === void 0) { + Object.defineProperty(target, property, desc); + desc = null; + } + + return desc; +} + +var id = 0; + +function _classPrivateFieldLooseKey(name) { + return "__private_" + id++ + "_" + name; +} + +function _classPrivateFieldLooseBase(receiver, privateKey) { + if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { + throw new TypeError("attempted to use private field on non-instance"); + } + + return receiver; +} + +function _classPrivateFieldGet(receiver, privateMap) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to get private field on non-instance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; +} + +function _classPrivateFieldSet(receiver, privateMap, value) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to set private field on non-instance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; +} + +function _classPrivateFieldDestructureSet(receiver, privateMap) { + if (!privateMap.has(receiver)) { + throw new TypeError("attempted to set private field on non-instance"); + } + + var descriptor = privateMap.get(receiver); + + if (descriptor.set) { + if (!("__destrObj" in descriptor)) { + descriptor.__destrObj = { + set value(v) { + descriptor.set.call(receiver, v); + } + + }; + } + + return descriptor.__destrObj; + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + return descriptor; + } +} + +function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; +} + +function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; +} + +function _classStaticPrivateMethodGet(receiver, classConstructor, method) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + return method; +} + +function _classStaticPrivateMethodSet() { + throw new TypeError("attempted to set read only static private field"); +} + +function _decorate(decorators, factory, superClass, mixins) { + var api = _getDecoratorsApi(); + + if (mixins) { + for (var i = 0; i < mixins.length; i++) { + api = mixins[i](api); + } + } + + var r = factory(function initialize(O) { + api.initializeInstanceElements(O, decorated.elements); + }, superClass); + var decorated = api.decorateClass(_coalesceClassElements(r.d.map(_createElementDescriptor)), decorators); + api.initializeClassElements(r.F, decorated.elements); + return api.runClassFinishers(r.F, decorated.finishers); +} + +function _getDecoratorsApi() { + _getDecoratorsApi = function () { + return api; + }; + + var api = { + elementsDefinitionOrder: [["method"], ["field"]], + initializeInstanceElements: function (O, elements) { + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + if (element.kind === kind && element.placement === "own") { + this.defineClassElement(O, element); + } + }, this); + }, this); + }, + initializeClassElements: function (F, elements) { + var proto = F.prototype; + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + var placement = element.placement; + + if (element.kind === kind && (placement === "static" || placement === "prototype")) { + var receiver = placement === "static" ? F : proto; + this.defineClassElement(receiver, element); + } + }, this); + }, this); + }, + defineClassElement: function (receiver, element) { + var descriptor = element.descriptor; + + if (element.kind === "field") { + var initializer = element.initializer; + descriptor = { + enumerable: descriptor.enumerable, + writable: descriptor.writable, + configurable: descriptor.configurable, + value: initializer === void 0 ? void 0 : initializer.call(receiver) + }; + } + + Object.defineProperty(receiver, element.key, descriptor); + }, + decorateClass: function (elements, decorators) { + var newElements = []; + var finishers = []; + var placements = { + static: [], + prototype: [], + own: [] + }; + elements.forEach(function (element) { + this.addElementPlacement(element, placements); + }, this); + elements.forEach(function (element) { + if (!_hasDecorators(element)) return newElements.push(element); + var elementFinishersExtras = this.decorateElement(element, placements); + newElements.push(elementFinishersExtras.element); + newElements.push.apply(newElements, elementFinishersExtras.extras); + finishers.push.apply(finishers, elementFinishersExtras.finishers); + }, this); + + if (!decorators) { + return { + elements: newElements, + finishers: finishers + }; + } + + var result = this.decorateConstructor(newElements, decorators); + finishers.push.apply(finishers, result.finishers); + result.finishers = finishers; + return result; + }, + addElementPlacement: function (element, placements, silent) { + var keys = placements[element.placement]; + + if (!silent && keys.indexOf(element.key) !== -1) { + throw new TypeError("Duplicated element (" + element.key + ")"); + } + + keys.push(element.key); + }, + decorateElement: function (element, placements) { + var extras = []; + var finishers = []; + + for (var decorators = element.decorators, i = decorators.length - 1; i >= 0; i--) { + var keys = placements[element.placement]; + keys.splice(keys.indexOf(element.key), 1); + var elementObject = this.fromElementDescriptor(element); + var elementFinisherExtras = this.toElementFinisherExtras((0, decorators[i])(elementObject) || elementObject); + element = elementFinisherExtras.element; + this.addElementPlacement(element, placements); + + if (elementFinisherExtras.finisher) { + finishers.push(elementFinisherExtras.finisher); + } + + var newExtras = elementFinisherExtras.extras; + + if (newExtras) { + for (var j = 0; j < newExtras.length; j++) { + this.addElementPlacement(newExtras[j], placements); + } + + extras.push.apply(extras, newExtras); + } + } + + return { + element: element, + finishers: finishers, + extras: extras + }; + }, + decorateConstructor: function (elements, decorators) { + var finishers = []; + + for (var i = decorators.length - 1; i >= 0; i--) { + var obj = this.fromClassDescriptor(elements); + var elementsAndFinisher = this.toClassDescriptor((0, decorators[i])(obj) || obj); + + if (elementsAndFinisher.finisher !== undefined) { + finishers.push(elementsAndFinisher.finisher); + } + + if (elementsAndFinisher.elements !== undefined) { + elements = elementsAndFinisher.elements; + + for (var j = 0; j < elements.length - 1; j++) { + for (var k = j + 1; k < elements.length; k++) { + if (elements[j].key === elements[k].key && elements[j].placement === elements[k].placement) { + throw new TypeError("Duplicated element (" + elements[j].key + ")"); + } + } + } + } + } + + return { + elements: elements, + finishers: finishers + }; + }, + fromElementDescriptor: function (element) { + var obj = { + kind: element.kind, + key: element.key, + placement: element.placement, + descriptor: element.descriptor + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + if (element.kind === "field") obj.initializer = element.initializer; + return obj; + }, + toElementDescriptors: function (elementObjects) { + if (elementObjects === undefined) return; + return _toArray(elementObjects).map(function (elementObject) { + var element = this.toElementDescriptor(elementObject); + this.disallowProperty(elementObject, "finisher", "An element descriptor"); + this.disallowProperty(elementObject, "extras", "An element descriptor"); + return element; + }, this); + }, + toElementDescriptor: function (elementObject) { + var kind = String(elementObject.kind); + + if (kind !== "method" && kind !== "field") { + throw new TypeError('An element descriptor\'s .kind property must be either "method" or' + ' "field", but a decorator created an element descriptor with' + ' .kind "' + kind + '"'); + } + + var key = _toPropertyKey(elementObject.key); + + var placement = String(elementObject.placement); + + if (placement !== "static" && placement !== "prototype" && placement !== "own") { + throw new TypeError('An element descriptor\'s .placement property must be one of "static",' + ' "prototype" or "own", but a decorator created an element descriptor' + ' with .placement "' + placement + '"'); + } + + var descriptor = elementObject.descriptor; + this.disallowProperty(elementObject, "elements", "An element descriptor"); + var element = { + kind: kind, + key: key, + placement: placement, + descriptor: Object.assign({}, descriptor) + }; + + if (kind !== "field") { + this.disallowProperty(elementObject, "initializer", "A method descriptor"); + } else { + this.disallowProperty(descriptor, "get", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "set", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "value", "The property descriptor of a field descriptor"); + element.initializer = elementObject.initializer; + } + + return element; + }, + toElementFinisherExtras: function (elementObject) { + var element = this.toElementDescriptor(elementObject); + + var finisher = _optionalCallableProperty(elementObject, "finisher"); + + var extras = this.toElementDescriptors(elementObject.extras); + return { + element: element, + finisher: finisher, + extras: extras + }; + }, + fromClassDescriptor: function (elements) { + var obj = { + kind: "class", + elements: elements.map(this.fromElementDescriptor, this) + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + return obj; + }, + toClassDescriptor: function (obj) { + var kind = String(obj.kind); + + if (kind !== "class") { + throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator' + ' created a class descriptor with .kind "' + kind + '"'); + } + + this.disallowProperty(obj, "key", "A class descriptor"); + this.disallowProperty(obj, "placement", "A class descriptor"); + this.disallowProperty(obj, "descriptor", "A class descriptor"); + this.disallowProperty(obj, "initializer", "A class descriptor"); + this.disallowProperty(obj, "extras", "A class descriptor"); + + var finisher = _optionalCallableProperty(obj, "finisher"); + + var elements = this.toElementDescriptors(obj.elements); + return { + elements: elements, + finisher: finisher + }; + }, + runClassFinishers: function (constructor, finishers) { + for (var i = 0; i < finishers.length; i++) { + var newConstructor = (0, finishers[i])(constructor); + + if (newConstructor !== undefined) { + if (typeof newConstructor !== "function") { + throw new TypeError("Finishers must return a constructor."); + } + + constructor = newConstructor; + } + } + + return constructor; + }, + disallowProperty: function (obj, name, objectType) { + if (obj[name] !== undefined) { + throw new TypeError(objectType + " can't have a ." + name + " property."); + } + } + }; + return api; +} + +function _createElementDescriptor(def) { + var key = _toPropertyKey(def.key); + + var descriptor; + + if (def.kind === "method") { + descriptor = { + value: def.value, + writable: true, + configurable: true, + enumerable: false + }; + } else if (def.kind === "get") { + descriptor = { + get: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "set") { + descriptor = { + set: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "field") { + descriptor = { + configurable: true, + writable: true, + enumerable: true + }; + } + + var element = { + kind: def.kind === "field" ? "field" : "method", + key: key, + placement: def.static ? "static" : def.kind === "field" ? "own" : "prototype", + descriptor: descriptor + }; + if (def.decorators) element.decorators = def.decorators; + if (def.kind === "field") element.initializer = def.value; + return element; +} + +function _coalesceGetterSetter(element, other) { + if (element.descriptor.get !== undefined) { + other.descriptor.get = element.descriptor.get; + } else { + other.descriptor.set = element.descriptor.set; + } +} + +function _coalesceClassElements(elements) { + var newElements = []; + + var isSameElement = function (other) { + return other.kind === "method" && other.key === element.key && other.placement === element.placement; + }; + + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + var other; + + if (element.kind === "method" && (other = newElements.find(isSameElement))) { + if (_isDataDescriptor(element.descriptor) || _isDataDescriptor(other.descriptor)) { + if (_hasDecorators(element) || _hasDecorators(other)) { + throw new ReferenceError("Duplicated methods (" + element.key + ") can't be decorated."); + } + + other.descriptor = element.descriptor; + } else { + if (_hasDecorators(element)) { + if (_hasDecorators(other)) { + throw new ReferenceError("Decorators can't be placed on different accessors with for " + "the same property (" + element.key + ")."); + } + + other.decorators = element.decorators; + } + + _coalesceGetterSetter(element, other); + } + } else { + newElements.push(element); + } + } + + return newElements; +} + +function _hasDecorators(element) { + return element.decorators && element.decorators.length; +} + +function _isDataDescriptor(desc) { + return desc !== undefined && !(desc.value === undefined && desc.writable === undefined); +} + +function _optionalCallableProperty(obj, name) { + var value = obj[name]; + + if (value !== undefined && typeof value !== "function") { + throw new TypeError("Expected '" + name + "' to be a function"); + } + + return value; +} + +function _classPrivateMethodGet(receiver, privateSet, fn) { + if (!privateSet.has(receiver)) { + throw new TypeError("attempted to get private field on non-instance"); + } + + return fn; +} + +function _classPrivateMethodSet() { + throw new TypeError("attempted to reassign private method"); +} + +function _wrapRegExp(re, groups) { + _wrapRegExp = function (re, groups) { + return new BabelRegExp(re, undefined, groups); + }; + + var _RegExp = _wrapNativeSuper(RegExp); + + var _super = RegExp.prototype; + + var _groups = new WeakMap(); + + function BabelRegExp(re, flags, groups) { + var _this = _RegExp.call(this, re, flags); + + _groups.set(_this, groups || _groups.get(re)); + + return _this; + } + + _inherits(BabelRegExp, _RegExp); + + BabelRegExp.prototype.exec = function (str) { + var result = _super.exec.call(this, str); + + if (result) result.groups = buildGroups(result, this); + return result; + }; + + BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { + if (typeof substitution === "string") { + var groups = _groups.get(this); + + return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { + return "$" + groups[name]; + })); + } else if (typeof substitution === "function") { + var _this = this; + + return _super[Symbol.replace].call(this, str, function () { + var args = []; + args.push.apply(args, arguments); + + if (typeof args[args.length - 1] !== "object") { + args.push(buildGroups(args, _this)); + } + + return substitution.apply(this, args); + }); + } else { + return _super[Symbol.replace].call(this, str, substitution); + } + }; + + function buildGroups(result, re) { + var g = _groups.get(re); + + return Object.keys(g).reduce(function (groups, name) { + groups[name] = result[g[name]]; + return groups; + }, Object.create(null)); + } + + return _wrapRegExp.apply(this, arguments); +} + +/** + * @file ext-arrows.js + * + * @license MIT + * + * @copyright 2010 Alexis Deveria + * + */ +var extArrows = { + name: 'arrows', + init: function init(S) { + var _this = this; + + return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() { + var strings, svgEditor, svgCanvas, addElem, nonce, $, prefix, selElems, arrowprefix, randomizeIds, setArrowNonce, unsetArrowNonce, pathdata, getLinked, showPanel, resetMarker, addMarker, setArrow, colorChanged, contextTools; + return regeneratorRuntime.wrap(function _callee2$(_context2) { + while (1) { + switch (_context2.prev = _context2.next) { + case 0: + colorChanged = function _colorChanged(elem) { + var color = elem.getAttribute('stroke'); + var mtypes = ['start', 'mid', 'end']; + var defs = svgCanvas.findDefs(); + $.each(mtypes, function (i, type) { + var marker = getLinked(elem, 'marker-' + type); + + if (!marker) { + return; + } + + var curColor = $(marker).children().attr('fill'); + var curD = $(marker).children().attr('d'); + + if (curColor === color) { + return; + } + + var allMarkers = $(defs).find('marker'); + var newMarker = null; // Different color, check if already made + + allMarkers.each(function () { + var attrs = $(this).children().attr(['fill', 'd']); + + if (attrs.fill === color && attrs.d === curD) { + // Found another marker with this color and this path + newMarker = this; + } + }); + + if (!newMarker) { + // Create a new marker with this color + var lastId = marker.id; + var dir = lastId.includes('_fw') ? 'fw' : 'bk'; + newMarker = addMarker(dir, type, arrowprefix + dir + allMarkers.length); + $(newMarker).children().attr('fill', color); + } + + $(elem).attr('marker-' + type, 'url(#' + newMarker.id + ')'); // Check if last marker can be removed + + var remove = true; + $(S.svgcontent).find('line, polyline, path, polygon').each(function () { + var element = this; + $.each(mtypes, function (j, mtype) { + if ($(element).attr('marker-' + mtype) === 'url(#' + marker.id + ')') { + remove = false; + return remove; + } + + return undefined; + }); + + if (!remove) { + return false; + } + + return undefined; + }); // Not found, so can safely remove + + if (remove) { + $(marker).remove(); + } + }); + }; + + setArrow = function _setArrow() { + resetMarker(); + var type = this.value; + + if (type === 'none') { + return; + } // Set marker on element + + + var dir = 'fw'; + + if (type === 'mid_bk') { + type = 'mid'; + dir = 'bk'; + } else if (type === 'both') { + addMarker('bk', type); + svgCanvas.changeSelectedAttribute('marker-start', 'url(#' + pathdata.bk.id + ')'); + type = 'end'; + dir = 'fw'; + } else if (type === 'start') { + dir = 'bk'; + } + + addMarker(dir, type); + svgCanvas.changeSelectedAttribute('marker-' + type, 'url(#' + pathdata[dir].id + ')'); + svgCanvas.call('changed', selElems); + }; + + addMarker = function _addMarker(dir, type, id) { + // TODO: Make marker (or use?) per arrow type, since refX can be different + id = id || arrowprefix + dir; + var data = pathdata[dir]; + + if (type === 'mid') { + data.refx = 5; + } + + var marker = svgCanvas.getElem(id); + + if (!marker) { + marker = addElem({ + element: 'marker', + attr: { + viewBox: '0 0 10 10', + id: id, + refY: 5, + markerUnits: 'strokeWidth', + markerWidth: 5, + markerHeight: 5, + orient: 'auto', + style: 'pointer-events:none' // Currently needed for Opera + + } + }); + var arrow = addElem({ + element: 'path', + attr: { + d: data.d, + fill: '#000000' + } + }); + marker.append(arrow); + svgCanvas.findDefs().append(marker); + } + + marker.setAttribute('refX', data.refx); + return marker; + }; + + resetMarker = function _resetMarker() { + var el = selElems[0]; + el.removeAttribute('marker-start'); + el.removeAttribute('marker-mid'); + el.removeAttribute('marker-end'); + }; + + showPanel = function _showPanel(on) { + $('#arrow_panel').toggle(on); + + if (on) { + var el = selElems[0]; + var end = el.getAttribute('marker-end'); + var start = el.getAttribute('marker-start'); + var mid = el.getAttribute('marker-mid'); + var val; + + if (end && start) { + val = 'both'; + } else if (end) { + val = 'end'; + } else if (start) { + val = 'start'; + } else if (mid) { + val = 'mid'; + + if (mid.includes('bk')) { + val = 'mid_bk'; + } + } + + if (!start && !mid && !end) { + val = 'none'; + } + + $('#arrow_list').val(val); + } + }; + + getLinked = function _getLinked(elem, attr) { + var str = elem.getAttribute(attr); + + if (!str) { + return null; + } + + var m = str.match(/\(#(.*)\)/); // const m = str.match(/\(#(?.+)\)/); + // if (!m || !m.groups.id) { + + if (!m || m.length !== 2) { + return null; + } + + return svgCanvas.getElem(m[1]); // return svgCanvas.getElem(m.groups.id); + }; + + unsetArrowNonce = function _unsetArrowNonce(win) { + randomizeIds = false; + arrowprefix = prefix; + pathdata.fw.id = arrowprefix + 'fw'; + pathdata.bk.id = arrowprefix + 'bk'; + }; + + setArrowNonce = function _setArrowNonce(win, n) { + randomizeIds = true; + arrowprefix = prefix + n + '_'; + pathdata.fw.id = arrowprefix + 'fw'; + pathdata.bk.id = arrowprefix + 'bk'; + }; + + _context2.next = 10; + return S.importLocale(); + + case 10: + strings = _context2.sent; + svgEditor = _this; + svgCanvas = svgEditor.canvas; + // {svgcontent} = S, + addElem = svgCanvas.addSVGElementFromJson, nonce = S.nonce, $ = S.$, prefix = 'se_arrow_'; + randomizeIds = S.randomize_ids; + /** + * @param {Window} win + * @param {!(string|Integer)} n + * @returns {void} + */ + + svgCanvas.bind('setnonce', setArrowNonce); + svgCanvas.bind('unsetnonce', unsetArrowNonce); + + if (randomizeIds) { + arrowprefix = prefix + nonce + '_'; + } else { + arrowprefix = prefix; + } + + pathdata = { + fw: { + d: 'm0,0l10,5l-10,5l5,-5l-5,-5z', + refx: 8, + id: arrowprefix + 'fw' + }, + bk: { + d: 'm10,0l-10,5l10,5l-5,-5l5,-5z', + refx: 2, + id: arrowprefix + 'bk' + } + }; + /** + * Gets linked element. + * @param {Element} elem + * @param {string} attr + * @returns {Element} + */ + + contextTools = [{ + type: 'select', + panel: 'arrow_panel', + id: 'arrow_list', + defval: 'none', + events: { + change: setArrow + } + }]; + return _context2.abrupt("return", { + name: strings.name, + context_tools: strings.contextTools.map(function (contextTool, i) { + return Object.assign(contextTools[i], contextTool); + }), + callback: function callback() { + $('#arrow_panel').hide(); // Set ID so it can be translated in locale file + + $('#arrow_list option')[0].id = 'connector_no_arrow'; + }, + addLangData: function addLangData(_ref) { + return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { + var lang, importLocale, _yield$importLocale, langList; + + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + lang = _ref.lang, importLocale = _ref.importLocale; + _context.next = 3; + return importLocale(); + + case 3: + _yield$importLocale = _context.sent; + langList = _yield$importLocale.langList; + return _context.abrupt("return", { + data: langList + }); + + case 6: + case "end": + return _context.stop(); + } + } + }, _callee); + }))(); + }, + selectedChanged: function selectedChanged(opts) { + // Use this to update the current selected elements + selElems = opts.elems; + var markerElems = ['line', 'path', 'polyline', 'polygon']; + var i = selElems.length; + + while (i--) { + var elem = selElems[i]; + + if (elem && markerElems.includes(elem.tagName)) { + if (opts.selectedElement && !opts.multiselected) { + showPanel(true); + } else { + showPanel(false); + } + } else { + showPanel(false); + } + } + }, + elementChanged: function elementChanged(opts) { + var elem = opts.elems[0]; + + if (elem && (elem.getAttribute('marker-start') || elem.getAttribute('marker-mid') || elem.getAttribute('marker-end'))) { + // const start = elem.getAttribute('marker-start'); + // const mid = elem.getAttribute('marker-mid'); + // const end = elem.getAttribute('marker-end'); + // Has marker, so see if it should match color + colorChanged(elem); + } + } + }); + + case 21: + case "end": + return _context2.stop(); + } + } + }, _callee2); + }))(); + } +}; + +export default extArrows; +//# sourceMappingURL=ext-arrows.js.map diff --git a/dist/editor/extensions/ext-arrows.js.map b/dist/editor/extensions/ext-arrows.js.map new file mode 100644 index 00000000..66481559 --- /dev/null +++ b/dist/editor/extensions/ext-arrows.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ext-arrows.js","sources":["../../../src/editor/extensions/ext-arrows.js"],"sourcesContent":["/**\n * @file ext-arrows.js\n *\n * @license MIT\n *\n * @copyright 2010 Alexis Deveria\n *\n */\n\nexport default {\n name: 'arrows',\n async init (S) {\n const strings = await S.importLocale();\n const svgEditor = this;\n const svgCanvas = svgEditor.canvas;\n const // {svgcontent} = S,\n addElem = svgCanvas.addSVGElementFromJson,\n {nonce, $} = S,\n prefix = 'se_arrow_';\n\n let selElems, arrowprefix, randomizeIds = S.randomize_ids;\n\n /**\n * @param {Window} win\n * @param {!(string|Integer)} n\n * @returns {void}\n */\n function setArrowNonce (win, n) {\n randomizeIds = true;\n arrowprefix = prefix + n + '_';\n pathdata.fw.id = arrowprefix + 'fw';\n pathdata.bk.id = arrowprefix + 'bk';\n }\n\n /**\n * @param {Window} win\n * @returns {void}\n */\n function unsetArrowNonce (win) {\n randomizeIds = false;\n arrowprefix = prefix;\n pathdata.fw.id = arrowprefix + 'fw';\n pathdata.bk.id = arrowprefix + 'bk';\n }\n\n svgCanvas.bind('setnonce', setArrowNonce);\n svgCanvas.bind('unsetnonce', unsetArrowNonce);\n\n if (randomizeIds) {\n arrowprefix = prefix + nonce + '_';\n } else {\n arrowprefix = prefix;\n }\n\n const pathdata = {\n fw: {d: 'm0,0l10,5l-10,5l5,-5l-5,-5z', refx: 8, id: arrowprefix + 'fw'},\n bk: {d: 'm10,0l-10,5l10,5l-5,-5l5,-5z', refx: 2, id: arrowprefix + 'bk'}\n };\n\n /**\n * Gets linked element.\n * @param {Element} elem\n * @param {string} attr\n * @returns {Element}\n */\n function getLinked (elem, attr) {\n const str = elem.getAttribute(attr);\n if (!str) { return null; }\n const m = str.match(/\\(#(.*)\\)/);\n // const m = str.match(/\\(#(?.+)\\)/);\n // if (!m || !m.groups.id) {\n if (!m || m.length !== 2) {\n return null;\n }\n return svgCanvas.getElem(m[1]);\n // return svgCanvas.getElem(m.groups.id);\n }\n\n /**\n * @param {boolean} on\n * @returns {void}\n */\n function showPanel (on) {\n $('#arrow_panel').toggle(on);\n if (on) {\n const el = selElems[0];\n const end = el.getAttribute('marker-end');\n const start = el.getAttribute('marker-start');\n const mid = el.getAttribute('marker-mid');\n let val;\n if (end && start) {\n val = 'both';\n } else if (end) {\n val = 'end';\n } else if (start) {\n val = 'start';\n } else if (mid) {\n val = 'mid';\n if (mid.includes('bk')) {\n val = 'mid_bk';\n }\n }\n\n if (!start && !mid && !end) {\n val = 'none';\n }\n\n $('#arrow_list').val(val);\n }\n }\n\n /**\n *\n * @returns {void}\n */\n function resetMarker () {\n const el = selElems[0];\n el.removeAttribute('marker-start');\n el.removeAttribute('marker-mid');\n el.removeAttribute('marker-end');\n }\n\n /**\n * @param {\"bk\"|\"fw\"} dir\n * @param {\"both\"|\"mid\"|\"end\"|\"start\"} type\n * @param {string} id\n * @returns {Element}\n */\n function addMarker (dir, type, id) {\n // TODO: Make marker (or use?) per arrow type, since refX can be different\n id = id || arrowprefix + dir;\n\n const data = pathdata[dir];\n\n if (type === 'mid') {\n data.refx = 5;\n }\n\n let marker = svgCanvas.getElem(id);\n if (!marker) {\n marker = addElem({\n element: 'marker',\n attr: {\n viewBox: '0 0 10 10',\n id,\n refY: 5,\n markerUnits: 'strokeWidth',\n markerWidth: 5,\n markerHeight: 5,\n orient: 'auto',\n style: 'pointer-events:none' // Currently needed for Opera\n }\n });\n const arrow = addElem({\n element: 'path',\n attr: {\n d: data.d,\n fill: '#000000'\n }\n });\n marker.append(arrow);\n svgCanvas.findDefs().append(marker);\n }\n\n marker.setAttribute('refX', data.refx);\n\n return marker;\n }\n\n /**\n *\n * @returns {void}\n */\n function setArrow () {\n resetMarker();\n\n let type = this.value;\n if (type === 'none') {\n return;\n }\n\n // Set marker on element\n let dir = 'fw';\n if (type === 'mid_bk') {\n type = 'mid';\n dir = 'bk';\n } else if (type === 'both') {\n addMarker('bk', type);\n svgCanvas.changeSelectedAttribute('marker-start', 'url(#' + pathdata.bk.id + ')');\n type = 'end';\n dir = 'fw';\n } else if (type === 'start') {\n dir = 'bk';\n }\n\n addMarker(dir, type);\n svgCanvas.changeSelectedAttribute('marker-' + type, 'url(#' + pathdata[dir].id + ')');\n svgCanvas.call('changed', selElems);\n }\n\n /**\n * @param {Element} elem\n * @returns {void}\n */\n function colorChanged (elem) {\n const color = elem.getAttribute('stroke');\n const mtypes = ['start', 'mid', 'end'];\n const defs = svgCanvas.findDefs();\n\n $.each(mtypes, function (i, type) {\n const marker = getLinked(elem, 'marker-' + type);\n if (!marker) { return; }\n\n const curColor = $(marker).children().attr('fill');\n const curD = $(marker).children().attr('d');\n if (curColor === color) { return; }\n\n const allMarkers = $(defs).find('marker');\n let newMarker = null;\n // Different color, check if already made\n allMarkers.each(function () {\n const attrs = $(this).children().attr(['fill', 'd']);\n if (attrs.fill === color && attrs.d === curD) {\n // Found another marker with this color and this path\n newMarker = this;\n }\n });\n\n if (!newMarker) {\n // Create a new marker with this color\n const lastId = marker.id;\n const dir = lastId.includes('_fw') ? 'fw' : 'bk';\n\n newMarker = addMarker(dir, type, arrowprefix + dir + allMarkers.length);\n\n $(newMarker).children().attr('fill', color);\n }\n\n $(elem).attr('marker-' + type, 'url(#' + newMarker.id + ')');\n\n // Check if last marker can be removed\n let remove = true;\n $(S.svgcontent).find('line, polyline, path, polygon').each(function () {\n const element = this;\n $.each(mtypes, function (j, mtype) {\n if ($(element).attr('marker-' + mtype) === 'url(#' + marker.id + ')') {\n remove = false;\n return remove;\n }\n return undefined;\n });\n if (!remove) { return false; }\n return undefined;\n });\n\n // Not found, so can safely remove\n if (remove) {\n $(marker).remove();\n }\n });\n }\n\n const contextTools = [\n {\n type: 'select',\n panel: 'arrow_panel',\n id: 'arrow_list',\n defval: 'none',\n events: {\n change: setArrow\n }\n }\n ];\n\n return {\n name: strings.name,\n context_tools: strings.contextTools.map((contextTool, i) => {\n return Object.assign(contextTools[i], contextTool);\n }),\n callback () {\n $('#arrow_panel').hide();\n // Set ID so it can be translated in locale file\n $('#arrow_list option')[0].id = 'connector_no_arrow';\n },\n async addLangData ({lang, importLocale}) {\n const {langList} = await importLocale();\n return {\n data: langList\n };\n },\n selectedChanged (opts) {\n // Use this to update the current selected elements\n selElems = opts.elems;\n\n const markerElems = ['line', 'path', 'polyline', 'polygon'];\n let i = selElems.length;\n while (i--) {\n const elem = selElems[i];\n if (elem && markerElems.includes(elem.tagName)) {\n if (opts.selectedElement && !opts.multiselected) {\n showPanel(true);\n } else {\n showPanel(false);\n }\n } else {\n showPanel(false);\n }\n }\n },\n elementChanged (opts) {\n const elem = opts.elems[0];\n if (elem && (\n elem.getAttribute('marker-start') ||\n elem.getAttribute('marker-mid') ||\n elem.getAttribute('marker-end')\n )) {\n // const start = elem.getAttribute('marker-start');\n // const mid = elem.getAttribute('marker-mid');\n // const end = elem.getAttribute('marker-end');\n // Has marker, so see if it should match color\n colorChanged(elem);\n }\n }\n };\n }\n};\n"],"names":["name","init","S","setArrowNonce","unsetArrowNonce","getLinked","showPanel","resetMarker","addMarker","setArrow","colorChanged","elem","color","getAttribute","mtypes","defs","svgCanvas","findDefs","$","each","i","type","marker","curColor","children","attr","curD","allMarkers","find","newMarker","attrs","fill","d","lastId","id","dir","includes","arrowprefix","length","remove","svgcontent","element","j","mtype","undefined","value","changeSelectedAttribute","pathdata","bk","call","selElems","data","refx","getElem","addElem","viewBox","refY","markerUnits","markerWidth","markerHeight","orient","style","arrow","append","setAttribute","el","removeAttribute","on","toggle","end","start","mid","val","str","m","match","win","randomizeIds","prefix","fw","n","importLocale","strings","svgEditor","canvas","addSVGElementFromJson","nonce","randomize_ids","bind","contextTools","panel","defval","events","change","context_tools","map","contextTool","Object","assign","callback","hide","addLangData","lang","langList","selectedChanged","opts","elems","markerElems","tagName","selectedElement","multiselected","elementChanged"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAL,IAAwB,CAACJ,IAAI,CAACK,aAAlC,EAAiD;AAC/CxG,wBAAAA,SAAS,CAAC,IAAD,CAAT;AACD,uBAFD,MAEO;AACLA,wBAAAA,SAAS,CAAC,KAAD,CAAT;AACD;AACF,qBAND,MAMO;AACLA,sBAAAA,SAAS,CAAC,KAAD,CAAT;AACD;AACF;AACF,iBAlCI;AAmCLyG,gBAAAA,cAnCK,0BAmCWN,IAnCX,EAmCiB;AACpB,sBAAM9F,IAAI,GAAG8F,IAAI,CAACC,KAAL,CAAW,CAAX,CAAb;;AACA,sBAAI/F,IAAI,KACNA,IAAI,CAACE,YAAL,CAAkB,cAAlB,KACAF,IAAI,CAACE,YAAL,CAAkB,YAAlB,CADA,IAEAF,IAAI,CAACE,YAAL,CAAkB,YAAlB,CAHM,CAAR,EAIG;AACD;AACA;AACA;AACA;AACAH,oBAAAA,YAAY,CAACC,IAAD,CAAZ;AACD;AACF;AAhDI,eAvQM;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyTd;AA3TY,CAAf;;;;"} \ No newline at end of file diff --git a/dist/editor/extensions/ext-closepath.js b/dist/editor/extensions/ext-closepath.js new file mode 100644 index 00000000..53a6a9cd --- /dev/null +++ b/dist/editor/extensions/ext-closepath.js @@ -0,0 +1,4090 @@ +function _typeof(obj) { + "@babel/helpers - typeof"; + + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function (obj) { + return typeof obj; + }; + } else { + _typeof = function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); +} + +var REACT_ELEMENT_TYPE; + +function _jsx(type, props, key, children) { + if (!REACT_ELEMENT_TYPE) { + REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol["for"] && Symbol["for"]("react.element") || 0xeac7; + } + + var defaultProps = type && type.defaultProps; + var childrenLength = arguments.length - 3; + + if (!props && childrenLength !== 0) { + props = { + children: void 0 + }; + } + + if (childrenLength === 1) { + props.children = children; + } else if (childrenLength > 1) { + var childArray = new Array(childrenLength); + + for (var i = 0; i < childrenLength; i++) { + childArray[i] = arguments[i + 3]; + } + + props.children = childArray; + } + + if (props && defaultProps) { + for (var propName in defaultProps) { + if (props[propName] === void 0) { + props[propName] = defaultProps[propName]; + } + } + } else if (!props) { + props = defaultProps || {}; + } + + return { + $$typeof: REACT_ELEMENT_TYPE, + type: type, + key: key === undefined ? null : '' + key, + ref: null, + props: props, + _owner: null + }; +} + +function _asyncIterator(iterable) { + var method; + + if (typeof Symbol !== "undefined") { + if (Symbol.asyncIterator) { + method = iterable[Symbol.asyncIterator]; + if (method != null) return method.call(iterable); + } + + if (Symbol.iterator) { + method = iterable[Symbol.iterator]; + if (method != null) return method.call(iterable); + } + } + + throw new TypeError("Object is not async iterable"); +} + +function _AwaitValue(value) { + this.wrapped = value; +} + +function _AsyncGenerator(gen) { + var front, back; + + function send(key, arg) { + return new Promise(function (resolve, reject) { + var request = { + key: key, + arg: arg, + resolve: resolve, + reject: reject, + next: null + }; + + if (back) { + back = back.next = request; + } else { + front = back = request; + resume(key, arg); + } + }); + } + + function resume(key, arg) { + try { + var result = gen[key](arg); + var value = result.value; + var wrappedAwait = value instanceof _AwaitValue; + Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { + if (wrappedAwait) { + resume(key === "return" ? "return" : "next", arg); + return; + } + + settle(result.done ? "return" : "normal", arg); + }, function (err) { + resume("throw", err); + }); + } catch (err) { + settle("throw", err); + } + } + + function settle(type, value) { + switch (type) { + case "return": + front.resolve({ + value: value, + done: true + }); + break; + + case "throw": + front.reject(value); + break; + + default: + front.resolve({ + value: value, + done: false + }); + break; + } + + front = front.next; + + if (front) { + resume(front.key, front.arg); + } else { + back = null; + } + } + + this._invoke = send; + + if (typeof gen.return !== "function") { + this.return = undefined; + } +} + +if (typeof Symbol === "function" && Symbol.asyncIterator) { + _AsyncGenerator.prototype[Symbol.asyncIterator] = function () { + return this; + }; +} + +_AsyncGenerator.prototype.next = function (arg) { + return this._invoke("next", arg); +}; + +_AsyncGenerator.prototype.throw = function (arg) { + return this._invoke("throw", arg); +}; + +_AsyncGenerator.prototype.return = function (arg) { + return this._invoke("return", arg); +}; + +function _wrapAsyncGenerator(fn) { + return function () { + return new _AsyncGenerator(fn.apply(this, arguments)); + }; +} + +function _awaitAsyncGenerator(value) { + return new _AwaitValue(value); +} + +function _asyncGeneratorDelegate(inner, awaitWrap) { + var iter = {}, + waiting = false; + + function pump(key, value) { + waiting = true; + value = new Promise(function (resolve) { + resolve(inner[key](value)); + }); + return { + done: false, + value: awaitWrap(value) + }; + } + + ; + + if (typeof Symbol === "function" && Symbol.iterator) { + iter[Symbol.iterator] = function () { + return this; + }; + } + + iter.next = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("next", value); + }; + + if (typeof inner.throw === "function") { + iter.throw = function (value) { + if (waiting) { + waiting = false; + throw value; + } + + return pump("throw", value); + }; + } + + if (typeof inner.return === "function") { + iter.return = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("return", value); + }; + } + + return iter; +} + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { + try { + var info = gen[key](arg); + var value = info.value; + } catch (error) { + reject(error); + return; + } + + if (info.done) { + resolve(value); + } else { + Promise.resolve(value).then(_next, _throw); + } +} + +function _asyncToGenerator(fn) { + return function () { + var self = this, + args = arguments; + return new Promise(function (resolve, reject) { + var gen = fn.apply(self, args); + + function _next(value) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); + } + + function _throw(err) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); + } + + _next(undefined); + }); + }; +} + +function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +} + +function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } +} + +function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; +} + +function _defineEnumerableProperties(obj, descs) { + for (var key in descs) { + var desc = descs[key]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, key, desc); + } + + if (Object.getOwnPropertySymbols) { + var objectSymbols = Object.getOwnPropertySymbols(descs); + + for (var i = 0; i < objectSymbols.length; i++) { + var sym = objectSymbols[i]; + var desc = descs[sym]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, sym, desc); + } + } + + return obj; +} + +function _defaults(obj, defaults) { + var keys = Object.getOwnPropertyNames(defaults); + + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var value = Object.getOwnPropertyDescriptor(defaults, key); + + if (value && value.configurable && obj[key] === undefined) { + Object.defineProperty(obj, key, value); + } + } + + return obj; +} + +function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; +} + +function _extends() { + _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + + return _extends.apply(this, arguments); +} + +function _objectSpread(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? Object(arguments[i]) : {}; + var ownKeys = Object.keys(source); + + if (typeof Object.getOwnPropertySymbols === 'function') { + ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { + return Object.getOwnPropertyDescriptor(source, sym).enumerable; + })); + } + + ownKeys.forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } + + return target; +} + +function ownKeys(object, enumerableOnly) { + var keys = Object.keys(object); + + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(object); + if (enumerableOnly) symbols = symbols.filter(function (sym) { + return Object.getOwnPropertyDescriptor(object, sym).enumerable; + }); + keys.push.apply(keys, symbols); + } + + return keys; +} + +function _objectSpread2(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? arguments[i] : {}; + + if (i % 2) { + ownKeys(Object(source), true).forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } else if (Object.getOwnPropertyDescriptors) { + Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); + } else { + ownKeys(Object(source)).forEach(function (key) { + Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); + }); + } + } + + return target; +} + +function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function"); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + writable: true, + configurable: true + } + }); + if (superClass) _setPrototypeOf(subClass, superClass); +} + +function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + subClass.__proto__ = superClass; +} + +function _getPrototypeOf(o) { + _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { + return o.__proto__ || Object.getPrototypeOf(o); + }; + return _getPrototypeOf(o); +} + +function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + + return _setPrototypeOf(o, p); +} + +function _isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + + try { + Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); + return true; + } catch (e) { + return false; + } +} + +function _construct(Parent, args, Class) { + if (_isNativeReflectConstruct()) { + _construct = Reflect.construct; + } else { + _construct = function _construct(Parent, args, Class) { + var a = [null]; + a.push.apply(a, args); + var Constructor = Function.bind.apply(Parent, a); + var instance = new Constructor(); + if (Class) _setPrototypeOf(instance, Class.prototype); + return instance; + }; + } + + return _construct.apply(null, arguments); +} + +function _isNativeFunction(fn) { + return Function.toString.call(fn).indexOf("[native code]") !== -1; +} + +function _wrapNativeSuper(Class) { + var _cache = typeof Map === "function" ? new Map() : undefined; + + _wrapNativeSuper = function _wrapNativeSuper(Class) { + if (Class === null || !_isNativeFunction(Class)) return Class; + + if (typeof Class !== "function") { + throw new TypeError("Super expression must either be null or a function"); + } + + if (typeof _cache !== "undefined") { + if (_cache.has(Class)) return _cache.get(Class); + + _cache.set(Class, Wrapper); + } + + function Wrapper() { + return _construct(Class, arguments, _getPrototypeOf(this).constructor); + } + + Wrapper.prototype = Object.create(Class.prototype, { + constructor: { + value: Wrapper, + enumerable: false, + writable: true, + configurable: true + } + }); + return _setPrototypeOf(Wrapper, Class); + }; + + return _wrapNativeSuper(Class); +} + +function _instanceof(left, right) { + if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { + return !!right[Symbol.hasInstance](left); + } else { + return left instanceof right; + } +} + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; +} + +function _getRequireWildcardCache() { + if (typeof WeakMap !== "function") return null; + var cache = new WeakMap(); + + _getRequireWildcardCache = function () { + return cache; + }; + + return cache; +} + +function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } + + if (obj === null || typeof obj !== "object" && typeof obj !== "function") { + return { + default: obj + }; + } + + var cache = _getRequireWildcardCache(); + + if (cache && cache.has(obj)) { + return cache.get(obj); + } + + var newObj = {}; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + + if (desc && (desc.get || desc.set)) { + Object.defineProperty(newObj, key, desc); + } else { + newObj[key] = obj[key]; + } + } + } + + newObj.default = obj; + + if (cache) { + cache.set(obj, newObj); + } + + return newObj; +} + +function _newArrowCheck(innerThis, boundThis) { + if (innerThis !== boundThis) { + throw new TypeError("Cannot instantiate an arrow function"); + } +} + +function _objectDestructuringEmpty(obj) { + if (obj == null) throw new TypeError("Cannot destructure undefined"); +} + +function _objectWithoutPropertiesLoose(source, excluded) { + if (source == null) return {}; + var target = {}; + var sourceKeys = Object.keys(source); + var key, i; + + for (i = 0; i < sourceKeys.length; i++) { + key = sourceKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + target[key] = source[key]; + } + + return target; +} + +function _objectWithoutProperties(source, excluded) { + if (source == null) return {}; + + var target = _objectWithoutPropertiesLoose(source, excluded); + + var key, i; + + if (Object.getOwnPropertySymbols) { + var sourceSymbolKeys = Object.getOwnPropertySymbols(source); + + for (i = 0; i < sourceSymbolKeys.length; i++) { + key = sourceSymbolKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; + target[key] = source[key]; + } + } + + return target; +} + +function _assertThisInitialized(self) { + if (self === void 0) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return self; +} + +function _possibleConstructorReturn(self, call) { + if (call && (typeof call === "object" || typeof call === "function")) { + return call; + } + + return _assertThisInitialized(self); +} + +function _createSuper(Derived) { + var hasNativeReflectConstruct = _isNativeReflectConstruct(); + + return function _createSuperInternal() { + var Super = _getPrototypeOf(Derived), + result; + + if (hasNativeReflectConstruct) { + var NewTarget = _getPrototypeOf(this).constructor; + + result = Reflect.construct(Super, arguments, NewTarget); + } else { + result = Super.apply(this, arguments); + } + + return _possibleConstructorReturn(this, result); + }; +} + +function _superPropBase(object, property) { + while (!Object.prototype.hasOwnProperty.call(object, property)) { + object = _getPrototypeOf(object); + if (object === null) break; + } + + return object; +} + +function _get(target, property, receiver) { + if (typeof Reflect !== "undefined" && Reflect.get) { + _get = Reflect.get; + } else { + _get = function _get(target, property, receiver) { + var base = _superPropBase(target, property); + + if (!base) return; + var desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.get) { + return desc.get.call(receiver); + } + + return desc.value; + }; + } + + return _get(target, property, receiver || target); +} + +function set(target, property, value, receiver) { + if (typeof Reflect !== "undefined" && Reflect.set) { + set = Reflect.set; + } else { + set = function set(target, property, value, receiver) { + var base = _superPropBase(target, property); + + var desc; + + if (base) { + desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.set) { + desc.set.call(receiver, value); + return true; + } else if (!desc.writable) { + return false; + } + } + + desc = Object.getOwnPropertyDescriptor(receiver, property); + + if (desc) { + if (!desc.writable) { + return false; + } + + desc.value = value; + Object.defineProperty(receiver, property, desc); + } else { + _defineProperty(receiver, property, value); + } + + return true; + }; + } + + return set(target, property, value, receiver); +} + +function _set(target, property, value, receiver, isStrict) { + var s = set(target, property, value, receiver || target); + + if (!s && isStrict) { + throw new Error('failed to set property'); + } + + return value; +} + +function _taggedTemplateLiteral(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + return Object.freeze(Object.defineProperties(strings, { + raw: { + value: Object.freeze(raw) + } + })); +} + +function _taggedTemplateLiteralLoose(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + strings.raw = raw; + return strings; +} + +function _readOnlyError(name) { + throw new Error("\"" + name + "\" is read-only"); +} + +function _classNameTDZError(name) { + throw new Error("Class \"" + name + "\" cannot be referenced in computed property keys."); +} + +function _temporalUndefined() {} + +function _tdz(name) { + throw new ReferenceError(name + " is not defined - temporal dead zone"); +} + +function _temporalRef(val, name) { + return val === _temporalUndefined ? _tdz(name) : val; +} + +function _slicedToArray(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); +} + +function _slicedToArrayLoose(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimitLoose(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); +} + +function _toArray(arr) { + return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); +} + +function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); +} + +function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) return _arrayLikeToArray(arr); +} + +function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; +} + +function _maybeArrayLike(next, arr, i) { + if (arr && !Array.isArray(arr) && typeof arr.length === "number") { + var len = arr.length; + return _arrayLikeToArray(arr, i !== void 0 && i < len ? i : len); + } + + return next(arr, i); +} + +function _iterableToArray(iter) { + if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); +} + +function _iterableToArrayLimit(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"] != null) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; +} + +function _iterableToArrayLimitLoose(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + + for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { + _arr.push(_step.value); + + if (i && _arr.length === i) break; + } + + return _arr; +} + +function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if (typeof o === "string") return _arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + if (n === "Object" && o.constructor) n = o.constructor.name; + if (n === "Map" || n === "Set") return Array.from(o); + if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); +} + +function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) len = arr.length; + + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + + return arr2; +} + +function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); +} + +function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); +} + +function _createForOfIteratorHelper(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + + var F = function () {}; + + return { + s: F, + n: function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }, + e: function (e) { + throw e; + }, + f: F + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + var normalCompletion = true, + didErr = false, + err; + return { + s: function () { + it = o[Symbol.iterator](); + }, + n: function () { + var step = it.next(); + normalCompletion = step.done; + return step; + }, + e: function (e) { + didErr = true; + err = e; + }, + f: function () { + try { + if (!normalCompletion && it.return != null) it.return(); + } finally { + if (didErr) throw err; + } + } + }; +} + +function _createForOfIteratorHelperLoose(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + return function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + it = o[Symbol.iterator](); + return it.next.bind(it); +} + +function _skipFirstGeneratorNext(fn) { + return function () { + var it = fn.apply(this, arguments); + it.next(); + return it; + }; +} + +function _toPrimitive(input, hint) { + if (typeof input !== "object" || input === null) return input; + var prim = input[Symbol.toPrimitive]; + + if (prim !== undefined) { + var res = prim.call(input, hint || "default"); + if (typeof res !== "object") return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + + return (hint === "string" ? String : Number)(input); +} + +function _toPropertyKey(arg) { + var key = _toPrimitive(arg, "string"); + + return typeof key === "symbol" ? key : String(key); +} + +function _initializerWarningHelper(descriptor, context) { + throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.'); +} + +function _initializerDefineProperty(target, property, descriptor, context) { + if (!descriptor) return; + Object.defineProperty(target, property, { + enumerable: descriptor.enumerable, + configurable: descriptor.configurable, + writable: descriptor.writable, + value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 + }); +} + +function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { + var desc = {}; + Object.keys(descriptor).forEach(function (key) { + desc[key] = descriptor[key]; + }); + desc.enumerable = !!desc.enumerable; + desc.configurable = !!desc.configurable; + + if ('value' in desc || desc.initializer) { + desc.writable = true; + } + + desc = decorators.slice().reverse().reduce(function (desc, decorator) { + return decorator(target, property, desc) || desc; + }, desc); + + if (context && desc.initializer !== void 0) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = undefined; + } + + if (desc.initializer === void 0) { + Object.defineProperty(target, property, desc); + desc = null; + } + + return desc; +} + +var id = 0; + +function _classPrivateFieldLooseKey(name) { + return "__private_" + id++ + "_" + name; +} + +function _classPrivateFieldLooseBase(receiver, privateKey) { + if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { + throw new TypeError("attempted to use private field on non-instance"); + } + + return receiver; +} + +function _classPrivateFieldGet(receiver, privateMap) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to get private field on non-instance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; +} + +function _classPrivateFieldSet(receiver, privateMap, value) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to set private field on non-instance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; +} + +function _classPrivateFieldDestructureSet(receiver, privateMap) { + if (!privateMap.has(receiver)) { + throw new TypeError("attempted to set private field on non-instance"); + } + + var descriptor = privateMap.get(receiver); + + if (descriptor.set) { + if (!("__destrObj" in descriptor)) { + descriptor.__destrObj = { + set value(v) { + descriptor.set.call(receiver, v); + } + + }; + } + + return descriptor.__destrObj; + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + return descriptor; + } +} + +function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; +} + +function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; +} + +function _classStaticPrivateMethodGet(receiver, classConstructor, method) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + return method; +} + +function _classStaticPrivateMethodSet() { + throw new TypeError("attempted to set read only static private field"); +} + +function _decorate(decorators, factory, superClass, mixins) { + var api = _getDecoratorsApi(); + + if (mixins) { + for (var i = 0; i < mixins.length; i++) { + api = mixins[i](api); + } + } + + var r = factory(function initialize(O) { + api.initializeInstanceElements(O, decorated.elements); + }, superClass); + var decorated = api.decorateClass(_coalesceClassElements(r.d.map(_createElementDescriptor)), decorators); + api.initializeClassElements(r.F, decorated.elements); + return api.runClassFinishers(r.F, decorated.finishers); +} + +function _getDecoratorsApi() { + _getDecoratorsApi = function () { + return api; + }; + + var api = { + elementsDefinitionOrder: [["method"], ["field"]], + initializeInstanceElements: function (O, elements) { + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + if (element.kind === kind && element.placement === "own") { + this.defineClassElement(O, element); + } + }, this); + }, this); + }, + initializeClassElements: function (F, elements) { + var proto = F.prototype; + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + var placement = element.placement; + + if (element.kind === kind && (placement === "static" || placement === "prototype")) { + var receiver = placement === "static" ? F : proto; + this.defineClassElement(receiver, element); + } + }, this); + }, this); + }, + defineClassElement: function (receiver, element) { + var descriptor = element.descriptor; + + if (element.kind === "field") { + var initializer = element.initializer; + descriptor = { + enumerable: descriptor.enumerable, + writable: descriptor.writable, + configurable: descriptor.configurable, + value: initializer === void 0 ? void 0 : initializer.call(receiver) + }; + } + + Object.defineProperty(receiver, element.key, descriptor); + }, + decorateClass: function (elements, decorators) { + var newElements = []; + var finishers = []; + var placements = { + static: [], + prototype: [], + own: [] + }; + elements.forEach(function (element) { + this.addElementPlacement(element, placements); + }, this); + elements.forEach(function (element) { + if (!_hasDecorators(element)) return newElements.push(element); + var elementFinishersExtras = this.decorateElement(element, placements); + newElements.push(elementFinishersExtras.element); + newElements.push.apply(newElements, elementFinishersExtras.extras); + finishers.push.apply(finishers, elementFinishersExtras.finishers); + }, this); + + if (!decorators) { + return { + elements: newElements, + finishers: finishers + }; + } + + var result = this.decorateConstructor(newElements, decorators); + finishers.push.apply(finishers, result.finishers); + result.finishers = finishers; + return result; + }, + addElementPlacement: function (element, placements, silent) { + var keys = placements[element.placement]; + + if (!silent && keys.indexOf(element.key) !== -1) { + throw new TypeError("Duplicated element (" + element.key + ")"); + } + + keys.push(element.key); + }, + decorateElement: function (element, placements) { + var extras = []; + var finishers = []; + + for (var decorators = element.decorators, i = decorators.length - 1; i >= 0; i--) { + var keys = placements[element.placement]; + keys.splice(keys.indexOf(element.key), 1); + var elementObject = this.fromElementDescriptor(element); + var elementFinisherExtras = this.toElementFinisherExtras((0, decorators[i])(elementObject) || elementObject); + element = elementFinisherExtras.element; + this.addElementPlacement(element, placements); + + if (elementFinisherExtras.finisher) { + finishers.push(elementFinisherExtras.finisher); + } + + var newExtras = elementFinisherExtras.extras; + + if (newExtras) { + for (var j = 0; j < newExtras.length; j++) { + this.addElementPlacement(newExtras[j], placements); + } + + extras.push.apply(extras, newExtras); + } + } + + return { + element: element, + finishers: finishers, + extras: extras + }; + }, + decorateConstructor: function (elements, decorators) { + var finishers = []; + + for (var i = decorators.length - 1; i >= 0; i--) { + var obj = this.fromClassDescriptor(elements); + var elementsAndFinisher = this.toClassDescriptor((0, decorators[i])(obj) || obj); + + if (elementsAndFinisher.finisher !== undefined) { + finishers.push(elementsAndFinisher.finisher); + } + + if (elementsAndFinisher.elements !== undefined) { + elements = elementsAndFinisher.elements; + + for (var j = 0; j < elements.length - 1; j++) { + for (var k = j + 1; k < elements.length; k++) { + if (elements[j].key === elements[k].key && elements[j].placement === elements[k].placement) { + throw new TypeError("Duplicated element (" + elements[j].key + ")"); + } + } + } + } + } + + return { + elements: elements, + finishers: finishers + }; + }, + fromElementDescriptor: function (element) { + var obj = { + kind: element.kind, + key: element.key, + placement: element.placement, + descriptor: element.descriptor + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + if (element.kind === "field") obj.initializer = element.initializer; + return obj; + }, + toElementDescriptors: function (elementObjects) { + if (elementObjects === undefined) return; + return _toArray(elementObjects).map(function (elementObject) { + var element = this.toElementDescriptor(elementObject); + this.disallowProperty(elementObject, "finisher", "An element descriptor"); + this.disallowProperty(elementObject, "extras", "An element descriptor"); + return element; + }, this); + }, + toElementDescriptor: function (elementObject) { + var kind = String(elementObject.kind); + + if (kind !== "method" && kind !== "field") { + throw new TypeError('An element descriptor\'s .kind property must be either "method" or' + ' "field", but a decorator created an element descriptor with' + ' .kind "' + kind + '"'); + } + + var key = _toPropertyKey(elementObject.key); + + var placement = String(elementObject.placement); + + if (placement !== "static" && placement !== "prototype" && placement !== "own") { + throw new TypeError('An element descriptor\'s .placement property must be one of "static",' + ' "prototype" or "own", but a decorator created an element descriptor' + ' with .placement "' + placement + '"'); + } + + var descriptor = elementObject.descriptor; + this.disallowProperty(elementObject, "elements", "An element descriptor"); + var element = { + kind: kind, + key: key, + placement: placement, + descriptor: Object.assign({}, descriptor) + }; + + if (kind !== "field") { + this.disallowProperty(elementObject, "initializer", "A method descriptor"); + } else { + this.disallowProperty(descriptor, "get", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "set", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "value", "The property descriptor of a field descriptor"); + element.initializer = elementObject.initializer; + } + + return element; + }, + toElementFinisherExtras: function (elementObject) { + var element = this.toElementDescriptor(elementObject); + + var finisher = _optionalCallableProperty(elementObject, "finisher"); + + var extras = this.toElementDescriptors(elementObject.extras); + return { + element: element, + finisher: finisher, + extras: extras + }; + }, + fromClassDescriptor: function (elements) { + var obj = { + kind: "class", + elements: elements.map(this.fromElementDescriptor, this) + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + return obj; + }, + toClassDescriptor: function (obj) { + var kind = String(obj.kind); + + if (kind !== "class") { + throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator' + ' created a class descriptor with .kind "' + kind + '"'); + } + + this.disallowProperty(obj, "key", "A class descriptor"); + this.disallowProperty(obj, "placement", "A class descriptor"); + this.disallowProperty(obj, "descriptor", "A class descriptor"); + this.disallowProperty(obj, "initializer", "A class descriptor"); + this.disallowProperty(obj, "extras", "A class descriptor"); + + var finisher = _optionalCallableProperty(obj, "finisher"); + + var elements = this.toElementDescriptors(obj.elements); + return { + elements: elements, + finisher: finisher + }; + }, + runClassFinishers: function (constructor, finishers) { + for (var i = 0; i < finishers.length; i++) { + var newConstructor = (0, finishers[i])(constructor); + + if (newConstructor !== undefined) { + if (typeof newConstructor !== "function") { + throw new TypeError("Finishers must return a constructor."); + } + + constructor = newConstructor; + } + } + + return constructor; + }, + disallowProperty: function (obj, name, objectType) { + if (obj[name] !== undefined) { + throw new TypeError(objectType + " can't have a ." + name + " property."); + } + } + }; + return api; +} + +function _createElementDescriptor(def) { + var key = _toPropertyKey(def.key); + + var descriptor; + + if (def.kind === "method") { + descriptor = { + value: def.value, + writable: true, + configurable: true, + enumerable: false + }; + } else if (def.kind === "get") { + descriptor = { + get: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "set") { + descriptor = { + set: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "field") { + descriptor = { + configurable: true, + writable: true, + enumerable: true + }; + } + + var element = { + kind: def.kind === "field" ? "field" : "method", + key: key, + placement: def.static ? "static" : def.kind === "field" ? "own" : "prototype", + descriptor: descriptor + }; + if (def.decorators) element.decorators = def.decorators; + if (def.kind === "field") element.initializer = def.value; + return element; +} + +function _coalesceGetterSetter(element, other) { + if (element.descriptor.get !== undefined) { + other.descriptor.get = element.descriptor.get; + } else { + other.descriptor.set = element.descriptor.set; + } +} + +function _coalesceClassElements(elements) { + var newElements = []; + + var isSameElement = function (other) { + return other.kind === "method" && other.key === element.key && other.placement === element.placement; + }; + + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + var other; + + if (element.kind === "method" && (other = newElements.find(isSameElement))) { + if (_isDataDescriptor(element.descriptor) || _isDataDescriptor(other.descriptor)) { + if (_hasDecorators(element) || _hasDecorators(other)) { + throw new ReferenceError("Duplicated methods (" + element.key + ") can't be decorated."); + } + + other.descriptor = element.descriptor; + } else { + if (_hasDecorators(element)) { + if (_hasDecorators(other)) { + throw new ReferenceError("Decorators can't be placed on different accessors with for " + "the same property (" + element.key + ")."); + } + + other.decorators = element.decorators; + } + + _coalesceGetterSetter(element, other); + } + } else { + newElements.push(element); + } + } + + return newElements; +} + +function _hasDecorators(element) { + return element.decorators && element.decorators.length; +} + +function _isDataDescriptor(desc) { + return desc !== undefined && !(desc.value === undefined && desc.writable === undefined); +} + +function _optionalCallableProperty(obj, name) { + var value = obj[name]; + + if (value !== undefined && typeof value !== "function") { + throw new TypeError("Expected '" + name + "' to be a function"); + } + + return value; +} + +function _classPrivateMethodGet(receiver, privateSet, fn) { + if (!privateSet.has(receiver)) { + throw new TypeError("attempted to get private field on non-instance"); + } + + return fn; +} + +function _classPrivateMethodSet() { + throw new TypeError("attempted to reassign private method"); +} + +function _wrapRegExp(re, groups) { + _wrapRegExp = function (re, groups) { + return new BabelRegExp(re, undefined, groups); + }; + + var _RegExp = _wrapNativeSuper(RegExp); + + var _super = RegExp.prototype; + + var _groups = new WeakMap(); + + function BabelRegExp(re, flags, groups) { + var _this = _RegExp.call(this, re, flags); + + _groups.set(_this, groups || _groups.get(re)); + + return _this; + } + + _inherits(BabelRegExp, _RegExp); + + BabelRegExp.prototype.exec = function (str) { + var result = _super.exec.call(this, str); + + if (result) result.groups = buildGroups(result, this); + return result; + }; + + BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { + if (typeof substitution === "string") { + var groups = _groups.get(this); + + return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { + return "$" + groups[name]; + })); + } else if (typeof substitution === "function") { + var _this = this; + + return _super[Symbol.replace].call(this, str, function () { + var args = []; + args.push.apply(args, arguments); + + if (typeof args[args.length - 1] !== "object") { + args.push(buildGroups(args, _this)); + } + + return substitution.apply(this, args); + }); + } else { + return _super[Symbol.replace].call(this, str, substitution); + } + }; + + function buildGroups(result, re) { + var g = _groups.get(re); + + return Object.keys(g).reduce(function (groups, name) { + groups[name] = result[g[name]]; + return groups; + }, Object.create(null)); + } + + return _wrapRegExp.apply(this, arguments); +} + +/* eslint-disable import/unambiguous, max-len */ + +/* globals SVGPathSeg, SVGPathSegMovetoRel, SVGPathSegMovetoAbs, + SVGPathSegMovetoRel, SVGPathSegLinetoRel, SVGPathSegLinetoAbs, + SVGPathSegLinetoHorizontalRel, SVGPathSegLinetoHorizontalAbs, + SVGPathSegLinetoVerticalRel, SVGPathSegLinetoVerticalAbs, + SVGPathSegClosePath, SVGPathSegCurvetoCubicRel, + SVGPathSegCurvetoCubicAbs, SVGPathSegCurvetoCubicSmoothRel, + SVGPathSegCurvetoCubicSmoothAbs, SVGPathSegCurvetoQuadraticRel, + SVGPathSegCurvetoQuadraticAbs, SVGPathSegCurvetoQuadraticSmoothRel, + SVGPathSegCurvetoQuadraticSmoothAbs, SVGPathSegArcRel, SVGPathSegArcAbs */ + +/** +* SVGPathSeg API polyfill +* https://github.com/progers/pathseg +* +* This is a drop-in replacement for the `SVGPathSeg` and `SVGPathSegList` APIs +* that were removed from SVG2 ({@link https://lists.w3.org/Archives/Public/www-svg/2015Jun/0044.html}), +* including the latest spec changes which were implemented in Firefox 43 and +* Chrome 46. +*/ + +/* eslint-disable no-shadow, class-methods-use-this, jsdoc/require-jsdoc */ +// Linting: We avoid `no-shadow` as ESLint thinks these are still available globals +// Linting: We avoid `class-methods-use-this` as this is a polyfill that must +// follow the conventions +(function () { + if (!('SVGPathSeg' in window)) { + // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathSeg + var _SVGPathSeg = /*#__PURE__*/function () { + function _SVGPathSeg(type, typeAsLetter, owningPathSegList) { + _classCallCheck(this, _SVGPathSeg); + + this.pathSegType = type; + this.pathSegTypeAsLetter = typeAsLetter; + this._owningPathSegList = owningPathSegList; + } // Notify owning PathSegList on any changes so they can be synchronized back to the path element. + + + _createClass(_SVGPathSeg, [{ + key: "_segmentChanged", + value: function _segmentChanged() { + if (this._owningPathSegList) { + this._owningPathSegList.segmentChanged(this); + } + } + }]); + + return _SVGPathSeg; + }(); + + _SVGPathSeg.prototype.classname = 'SVGPathSeg'; + _SVGPathSeg.PATHSEG_UNKNOWN = 0; + _SVGPathSeg.PATHSEG_CLOSEPATH = 1; + _SVGPathSeg.PATHSEG_MOVETO_ABS = 2; + _SVGPathSeg.PATHSEG_MOVETO_REL = 3; + _SVGPathSeg.PATHSEG_LINETO_ABS = 4; + _SVGPathSeg.PATHSEG_LINETO_REL = 5; + _SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS = 6; + _SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL = 7; + _SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS = 8; + _SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL = 9; + _SVGPathSeg.PATHSEG_ARC_ABS = 10; + _SVGPathSeg.PATHSEG_ARC_REL = 11; + _SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS = 12; + _SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL = 13; + _SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS = 14; + _SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL = 15; + _SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS = 16; + _SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL = 17; + _SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS = 18; + _SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = 19; + + var _SVGPathSegClosePath = /*#__PURE__*/function (_SVGPathSeg2) { + _inherits(_SVGPathSegClosePath, _SVGPathSeg2); + + var _super = _createSuper(_SVGPathSegClosePath); + + function _SVGPathSegClosePath(owningPathSegList) { + _classCallCheck(this, _SVGPathSegClosePath); + + return _super.call(this, _SVGPathSeg.PATHSEG_CLOSEPATH, 'z', owningPathSegList); + } + + _createClass(_SVGPathSegClosePath, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegClosePath]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegClosePath(undefined); + } + }]); + + return _SVGPathSegClosePath; + }(_SVGPathSeg); + + var _SVGPathSegMovetoAbs = /*#__PURE__*/function (_SVGPathSeg3) { + _inherits(_SVGPathSegMovetoAbs, _SVGPathSeg3); + + var _super2 = _createSuper(_SVGPathSegMovetoAbs); + + function _SVGPathSegMovetoAbs(owningPathSegList, x, y) { + var _this; + + _classCallCheck(this, _SVGPathSegMovetoAbs); + + _this = _super2.call(this, _SVGPathSeg.PATHSEG_MOVETO_ABS, 'M', owningPathSegList); + _this._x = x; + _this._y = y; + return _this; + } + + _createClass(_SVGPathSegMovetoAbs, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegMovetoAbs]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegMovetoAbs(undefined, this._x, this._y); + } + }]); + + return _SVGPathSegMovetoAbs; + }(_SVGPathSeg); + + Object.defineProperties(_SVGPathSegMovetoAbs.prototype, { + x: { + get: function get() { + return this._x; + }, + set: function set(x) { + this._x = x; + + this._segmentChanged(); + }, + enumerable: true + }, + y: { + get: function get() { + return this._y; + }, + set: function set(y) { + this._y = y; + + this._segmentChanged(); + }, + enumerable: true + } + }); + + var _SVGPathSegMovetoRel = /*#__PURE__*/function (_SVGPathSeg4) { + _inherits(_SVGPathSegMovetoRel, _SVGPathSeg4); + + var _super3 = _createSuper(_SVGPathSegMovetoRel); + + function _SVGPathSegMovetoRel(owningPathSegList, x, y) { + var _this2; + + _classCallCheck(this, _SVGPathSegMovetoRel); + + _this2 = _super3.call(this, _SVGPathSeg.PATHSEG_MOVETO_REL, 'm', owningPathSegList); + _this2._x = x; + _this2._y = y; + return _this2; + } + + _createClass(_SVGPathSegMovetoRel, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegMovetoRel]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegMovetoRel(undefined, this._x, this._y); + } + }]); + + return _SVGPathSegMovetoRel; + }(_SVGPathSeg); + + Object.defineProperties(_SVGPathSegMovetoRel.prototype, { + x: { + get: function get() { + return this._x; + }, + set: function set(x) { + this._x = x; + + this._segmentChanged(); + }, + enumerable: true + }, + y: { + get: function get() { + return this._y; + }, + set: function set(y) { + this._y = y; + + this._segmentChanged(); + }, + enumerable: true + } + }); + + var _SVGPathSegLinetoAbs = /*#__PURE__*/function (_SVGPathSeg5) { + _inherits(_SVGPathSegLinetoAbs, _SVGPathSeg5); + + var _super4 = _createSuper(_SVGPathSegLinetoAbs); + + function _SVGPathSegLinetoAbs(owningPathSegList, x, y) { + var _this3; + + _classCallCheck(this, _SVGPathSegLinetoAbs); + + _this3 = _super4.call(this, _SVGPathSeg.PATHSEG_LINETO_ABS, 'L', owningPathSegList); + _this3._x = x; + _this3._y = y; + return _this3; + } + + _createClass(_SVGPathSegLinetoAbs, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegLinetoAbs]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegLinetoAbs(undefined, this._x, this._y); + } + }]); + + return _SVGPathSegLinetoAbs; + }(_SVGPathSeg); + + Object.defineProperties(_SVGPathSegLinetoAbs.prototype, { + x: { + get: function get() { + return this._x; + }, + set: function set(x) { + this._x = x; + + this._segmentChanged(); + }, + enumerable: true + }, + y: { + get: function get() { + return this._y; + }, + set: function set(y) { + this._y = y; + + this._segmentChanged(); + }, + enumerable: true + } + }); + + var _SVGPathSegLinetoRel = /*#__PURE__*/function (_SVGPathSeg6) { + _inherits(_SVGPathSegLinetoRel, _SVGPathSeg6); + + var _super5 = _createSuper(_SVGPathSegLinetoRel); + + function _SVGPathSegLinetoRel(owningPathSegList, x, y) { + var _this4; + + _classCallCheck(this, _SVGPathSegLinetoRel); + + _this4 = _super5.call(this, _SVGPathSeg.PATHSEG_LINETO_REL, 'l', owningPathSegList); + _this4._x = x; + _this4._y = y; + return _this4; + } + + _createClass(_SVGPathSegLinetoRel, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegLinetoRel]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegLinetoRel(undefined, this._x, this._y); + } + }]); + + return _SVGPathSegLinetoRel; + }(_SVGPathSeg); + + Object.defineProperties(_SVGPathSegLinetoRel.prototype, { + x: { + get: function get() { + return this._x; + }, + set: function set(x) { + this._x = x; + + this._segmentChanged(); + }, + enumerable: true + }, + y: { + get: function get() { + return this._y; + }, + set: function set(y) { + this._y = y; + + this._segmentChanged(); + }, + enumerable: true + } + }); + + var _SVGPathSegCurvetoCubicAbs = /*#__PURE__*/function (_SVGPathSeg7) { + _inherits(_SVGPathSegCurvetoCubicAbs, _SVGPathSeg7); + + var _super6 = _createSuper(_SVGPathSegCurvetoCubicAbs); + + function _SVGPathSegCurvetoCubicAbs(owningPathSegList, x, y, x1, y1, x2, y2) { + var _this5; + + _classCallCheck(this, _SVGPathSegCurvetoCubicAbs); + + _this5 = _super6.call(this, _SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS, 'C', owningPathSegList); + _this5._x = x; + _this5._y = y; + _this5._x1 = x1; + _this5._y1 = y1; + _this5._x2 = x2; + _this5._y2 = y2; + return _this5; + } + + _createClass(_SVGPathSegCurvetoCubicAbs, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegCurvetoCubicAbs]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x1 + ' ' + this._y1 + ' ' + this._x2 + ' ' + this._y2 + ' ' + this._x + ' ' + this._y; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegCurvetoCubicAbs(undefined, this._x, this._y, this._x1, this._y1, this._x2, this._y2); + } + }]); + + return _SVGPathSegCurvetoCubicAbs; + }(_SVGPathSeg); + + Object.defineProperties(_SVGPathSegCurvetoCubicAbs.prototype, { + x: { + get: function get() { + return this._x; + }, + set: function set(x) { + this._x = x; + + this._segmentChanged(); + }, + enumerable: true + }, + y: { + get: function get() { + return this._y; + }, + set: function set(y) { + this._y = y; + + this._segmentChanged(); + }, + enumerable: true + }, + x1: { + get: function get() { + return this._x1; + }, + set: function set(x1) { + this._x1 = x1; + + this._segmentChanged(); + }, + enumerable: true + }, + y1: { + get: function get() { + return this._y1; + }, + set: function set(y1) { + this._y1 = y1; + + this._segmentChanged(); + }, + enumerable: true + }, + x2: { + get: function get() { + return this._x2; + }, + set: function set(x2) { + this._x2 = x2; + + this._segmentChanged(); + }, + enumerable: true + }, + y2: { + get: function get() { + return this._y2; + }, + set: function set(y2) { + this._y2 = y2; + + this._segmentChanged(); + }, + enumerable: true + } + }); + + var _SVGPathSegCurvetoCubicRel = /*#__PURE__*/function (_SVGPathSeg8) { + _inherits(_SVGPathSegCurvetoCubicRel, _SVGPathSeg8); + + var _super7 = _createSuper(_SVGPathSegCurvetoCubicRel); + + function _SVGPathSegCurvetoCubicRel(owningPathSegList, x, y, x1, y1, x2, y2) { + var _this6; + + _classCallCheck(this, _SVGPathSegCurvetoCubicRel); + + _this6 = _super7.call(this, _SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL, 'c', owningPathSegList); + _this6._x = x; + _this6._y = y; + _this6._x1 = x1; + _this6._y1 = y1; + _this6._x2 = x2; + _this6._y2 = y2; + return _this6; + } + + _createClass(_SVGPathSegCurvetoCubicRel, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegCurvetoCubicRel]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x1 + ' ' + this._y1 + ' ' + this._x2 + ' ' + this._y2 + ' ' + this._x + ' ' + this._y; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegCurvetoCubicRel(undefined, this._x, this._y, this._x1, this._y1, this._x2, this._y2); + } + }]); + + return _SVGPathSegCurvetoCubicRel; + }(_SVGPathSeg); + + Object.defineProperties(_SVGPathSegCurvetoCubicRel.prototype, { + x: { + get: function get() { + return this._x; + }, + set: function set(x) { + this._x = x; + + this._segmentChanged(); + }, + enumerable: true + }, + y: { + get: function get() { + return this._y; + }, + set: function set(y) { + this._y = y; + + this._segmentChanged(); + }, + enumerable: true + }, + x1: { + get: function get() { + return this._x1; + }, + set: function set(x1) { + this._x1 = x1; + + this._segmentChanged(); + }, + enumerable: true + }, + y1: { + get: function get() { + return this._y1; + }, + set: function set(y1) { + this._y1 = y1; + + this._segmentChanged(); + }, + enumerable: true + }, + x2: { + get: function get() { + return this._x2; + }, + set: function set(x2) { + this._x2 = x2; + + this._segmentChanged(); + }, + enumerable: true + }, + y2: { + get: function get() { + return this._y2; + }, + set: function set(y2) { + this._y2 = y2; + + this._segmentChanged(); + }, + enumerable: true + } + }); + + var _SVGPathSegCurvetoQuadraticAbs = /*#__PURE__*/function (_SVGPathSeg9) { + _inherits(_SVGPathSegCurvetoQuadraticAbs, _SVGPathSeg9); + + var _super8 = _createSuper(_SVGPathSegCurvetoQuadraticAbs); + + function _SVGPathSegCurvetoQuadraticAbs(owningPathSegList, x, y, x1, y1) { + var _this7; + + _classCallCheck(this, _SVGPathSegCurvetoQuadraticAbs); + + _this7 = _super8.call(this, _SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS, 'Q', owningPathSegList); + _this7._x = x; + _this7._y = y; + _this7._x1 = x1; + _this7._y1 = y1; + return _this7; + } + + _createClass(_SVGPathSegCurvetoQuadraticAbs, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegCurvetoQuadraticAbs]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x1 + ' ' + this._y1 + ' ' + this._x + ' ' + this._y; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegCurvetoQuadraticAbs(undefined, this._x, this._y, this._x1, this._y1); + } + }]); + + return _SVGPathSegCurvetoQuadraticAbs; + }(_SVGPathSeg); + + Object.defineProperties(_SVGPathSegCurvetoQuadraticAbs.prototype, { + x: { + get: function get() { + return this._x; + }, + set: function set(x) { + this._x = x; + + this._segmentChanged(); + }, + enumerable: true + }, + y: { + get: function get() { + return this._y; + }, + set: function set(y) { + this._y = y; + + this._segmentChanged(); + }, + enumerable: true + }, + x1: { + get: function get() { + return this._x1; + }, + set: function set(x1) { + this._x1 = x1; + + this._segmentChanged(); + }, + enumerable: true + }, + y1: { + get: function get() { + return this._y1; + }, + set: function set(y1) { + this._y1 = y1; + + this._segmentChanged(); + }, + enumerable: true + } + }); + + var _SVGPathSegCurvetoQuadraticRel = /*#__PURE__*/function (_SVGPathSeg10) { + _inherits(_SVGPathSegCurvetoQuadraticRel, _SVGPathSeg10); + + var _super9 = _createSuper(_SVGPathSegCurvetoQuadraticRel); + + function _SVGPathSegCurvetoQuadraticRel(owningPathSegList, x, y, x1, y1) { + var _this8; + + _classCallCheck(this, _SVGPathSegCurvetoQuadraticRel); + + _this8 = _super9.call(this, _SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL, 'q', owningPathSegList); + _this8._x = x; + _this8._y = y; + _this8._x1 = x1; + _this8._y1 = y1; + return _this8; + } + + _createClass(_SVGPathSegCurvetoQuadraticRel, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegCurvetoQuadraticRel]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x1 + ' ' + this._y1 + ' ' + this._x + ' ' + this._y; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegCurvetoQuadraticRel(undefined, this._x, this._y, this._x1, this._y1); + } + }]); + + return _SVGPathSegCurvetoQuadraticRel; + }(_SVGPathSeg); + + Object.defineProperties(_SVGPathSegCurvetoQuadraticRel.prototype, { + x: { + get: function get() { + return this._x; + }, + set: function set(x) { + this._x = x; + + this._segmentChanged(); + }, + enumerable: true + }, + y: { + get: function get() { + return this._y; + }, + set: function set(y) { + this._y = y; + + this._segmentChanged(); + }, + enumerable: true + }, + x1: { + get: function get() { + return this._x1; + }, + set: function set(x1) { + this._x1 = x1; + + this._segmentChanged(); + }, + enumerable: true + }, + y1: { + get: function get() { + return this._y1; + }, + set: function set(y1) { + this._y1 = y1; + + this._segmentChanged(); + }, + enumerable: true + } + }); + + var _SVGPathSegArcAbs = /*#__PURE__*/function (_SVGPathSeg11) { + _inherits(_SVGPathSegArcAbs, _SVGPathSeg11); + + var _super10 = _createSuper(_SVGPathSegArcAbs); + + function _SVGPathSegArcAbs(owningPathSegList, x, y, r1, r2, angle, largeArcFlag, sweepFlag) { + var _this9; + + _classCallCheck(this, _SVGPathSegArcAbs); + + _this9 = _super10.call(this, _SVGPathSeg.PATHSEG_ARC_ABS, 'A', owningPathSegList); + _this9._x = x; + _this9._y = y; + _this9._r1 = r1; + _this9._r2 = r2; + _this9._angle = angle; + _this9._largeArcFlag = largeArcFlag; + _this9._sweepFlag = sweepFlag; + return _this9; + } + + _createClass(_SVGPathSegArcAbs, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegArcAbs]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._r1 + ' ' + this._r2 + ' ' + this._angle + ' ' + (this._largeArcFlag ? '1' : '0') + ' ' + (this._sweepFlag ? '1' : '0') + ' ' + this._x + ' ' + this._y; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegArcAbs(undefined, this._x, this._y, this._r1, this._r2, this._angle, this._largeArcFlag, this._sweepFlag); + } + }]); + + return _SVGPathSegArcAbs; + }(_SVGPathSeg); + + Object.defineProperties(_SVGPathSegArcAbs.prototype, { + x: { + get: function get() { + return this._x; + }, + set: function set(x) { + this._x = x; + + this._segmentChanged(); + }, + enumerable: true + }, + y: { + get: function get() { + return this._y; + }, + set: function set(y) { + this._y = y; + + this._segmentChanged(); + }, + enumerable: true + }, + r1: { + get: function get() { + return this._r1; + }, + set: function set(r1) { + this._r1 = r1; + + this._segmentChanged(); + }, + enumerable: true + }, + r2: { + get: function get() { + return this._r2; + }, + set: function set(r2) { + this._r2 = r2; + + this._segmentChanged(); + }, + enumerable: true + }, + angle: { + get: function get() { + return this._angle; + }, + set: function set(angle) { + this._angle = angle; + + this._segmentChanged(); + }, + enumerable: true + }, + largeArcFlag: { + get: function get() { + return this._largeArcFlag; + }, + set: function set(largeArcFlag) { + this._largeArcFlag = largeArcFlag; + + this._segmentChanged(); + }, + enumerable: true + }, + sweepFlag: { + get: function get() { + return this._sweepFlag; + }, + set: function set(sweepFlag) { + this._sweepFlag = sweepFlag; + + this._segmentChanged(); + }, + enumerable: true + } + }); + + var _SVGPathSegArcRel = /*#__PURE__*/function (_SVGPathSeg12) { + _inherits(_SVGPathSegArcRel, _SVGPathSeg12); + + var _super11 = _createSuper(_SVGPathSegArcRel); + + function _SVGPathSegArcRel(owningPathSegList, x, y, r1, r2, angle, largeArcFlag, sweepFlag) { + var _this10; + + _classCallCheck(this, _SVGPathSegArcRel); + + _this10 = _super11.call(this, _SVGPathSeg.PATHSEG_ARC_REL, 'a', owningPathSegList); + _this10._x = x; + _this10._y = y; + _this10._r1 = r1; + _this10._r2 = r2; + _this10._angle = angle; + _this10._largeArcFlag = largeArcFlag; + _this10._sweepFlag = sweepFlag; + return _this10; + } + + _createClass(_SVGPathSegArcRel, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegArcRel]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._r1 + ' ' + this._r2 + ' ' + this._angle + ' ' + (this._largeArcFlag ? '1' : '0') + ' ' + (this._sweepFlag ? '1' : '0') + ' ' + this._x + ' ' + this._y; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegArcRel(undefined, this._x, this._y, this._r1, this._r2, this._angle, this._largeArcFlag, this._sweepFlag); + } + }]); + + return _SVGPathSegArcRel; + }(_SVGPathSeg); + + Object.defineProperties(_SVGPathSegArcRel.prototype, { + x: { + get: function get() { + return this._x; + }, + set: function set(x) { + this._x = x; + + this._segmentChanged(); + }, + enumerable: true + }, + y: { + get: function get() { + return this._y; + }, + set: function set(y) { + this._y = y; + + this._segmentChanged(); + }, + enumerable: true + }, + r1: { + get: function get() { + return this._r1; + }, + set: function set(r1) { + this._r1 = r1; + + this._segmentChanged(); + }, + enumerable: true + }, + r2: { + get: function get() { + return this._r2; + }, + set: function set(r2) { + this._r2 = r2; + + this._segmentChanged(); + }, + enumerable: true + }, + angle: { + get: function get() { + return this._angle; + }, + set: function set(angle) { + this._angle = angle; + + this._segmentChanged(); + }, + enumerable: true + }, + largeArcFlag: { + get: function get() { + return this._largeArcFlag; + }, + set: function set(largeArcFlag) { + this._largeArcFlag = largeArcFlag; + + this._segmentChanged(); + }, + enumerable: true + }, + sweepFlag: { + get: function get() { + return this._sweepFlag; + }, + set: function set(sweepFlag) { + this._sweepFlag = sweepFlag; + + this._segmentChanged(); + }, + enumerable: true + } + }); + + var _SVGPathSegLinetoHorizontalAbs = /*#__PURE__*/function (_SVGPathSeg13) { + _inherits(_SVGPathSegLinetoHorizontalAbs, _SVGPathSeg13); + + var _super12 = _createSuper(_SVGPathSegLinetoHorizontalAbs); + + function _SVGPathSegLinetoHorizontalAbs(owningPathSegList, x) { + var _this11; + + _classCallCheck(this, _SVGPathSegLinetoHorizontalAbs); + + _this11 = _super12.call(this, _SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS, 'H', owningPathSegList); + _this11._x = x; + return _this11; + } + + _createClass(_SVGPathSegLinetoHorizontalAbs, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegLinetoHorizontalAbs]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegLinetoHorizontalAbs(undefined, this._x); + } + }]); + + return _SVGPathSegLinetoHorizontalAbs; + }(_SVGPathSeg); + + Object.defineProperty(_SVGPathSegLinetoHorizontalAbs.prototype, 'x', { + get: function get() { + return this._x; + }, + set: function set(x) { + this._x = x; + + this._segmentChanged(); + }, + enumerable: true + }); + + var _SVGPathSegLinetoHorizontalRel = /*#__PURE__*/function (_SVGPathSeg14) { + _inherits(_SVGPathSegLinetoHorizontalRel, _SVGPathSeg14); + + var _super13 = _createSuper(_SVGPathSegLinetoHorizontalRel); + + function _SVGPathSegLinetoHorizontalRel(owningPathSegList, x) { + var _this12; + + _classCallCheck(this, _SVGPathSegLinetoHorizontalRel); + + _this12 = _super13.call(this, _SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL, 'h', owningPathSegList); + _this12._x = x; + return _this12; + } + + _createClass(_SVGPathSegLinetoHorizontalRel, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegLinetoHorizontalRel]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegLinetoHorizontalRel(undefined, this._x); + } + }]); + + return _SVGPathSegLinetoHorizontalRel; + }(_SVGPathSeg); + + Object.defineProperty(_SVGPathSegLinetoHorizontalRel.prototype, 'x', { + get: function get() { + return this._x; + }, + set: function set(x) { + this._x = x; + + this._segmentChanged(); + }, + enumerable: true + }); + + var _SVGPathSegLinetoVerticalAbs = /*#__PURE__*/function (_SVGPathSeg15) { + _inherits(_SVGPathSegLinetoVerticalAbs, _SVGPathSeg15); + + var _super14 = _createSuper(_SVGPathSegLinetoVerticalAbs); + + function _SVGPathSegLinetoVerticalAbs(owningPathSegList, y) { + var _this13; + + _classCallCheck(this, _SVGPathSegLinetoVerticalAbs); + + _this13 = _super14.call(this, _SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS, 'V', owningPathSegList); + _this13._y = y; + return _this13; + } + + _createClass(_SVGPathSegLinetoVerticalAbs, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegLinetoVerticalAbs]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._y; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegLinetoVerticalAbs(undefined, this._y); + } + }]); + + return _SVGPathSegLinetoVerticalAbs; + }(_SVGPathSeg); + + Object.defineProperty(_SVGPathSegLinetoVerticalAbs.prototype, 'y', { + get: function get() { + return this._y; + }, + set: function set(y) { + this._y = y; + + this._segmentChanged(); + }, + enumerable: true + }); + + var _SVGPathSegLinetoVerticalRel = /*#__PURE__*/function (_SVGPathSeg16) { + _inherits(_SVGPathSegLinetoVerticalRel, _SVGPathSeg16); + + var _super15 = _createSuper(_SVGPathSegLinetoVerticalRel); + + function _SVGPathSegLinetoVerticalRel(owningPathSegList, y) { + var _this14; + + _classCallCheck(this, _SVGPathSegLinetoVerticalRel); + + _this14 = _super15.call(this, _SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL, 'v', owningPathSegList); + _this14._y = y; + return _this14; + } + + _createClass(_SVGPathSegLinetoVerticalRel, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegLinetoVerticalRel]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._y; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegLinetoVerticalRel(undefined, this._y); + } + }]); + + return _SVGPathSegLinetoVerticalRel; + }(_SVGPathSeg); + + Object.defineProperty(_SVGPathSegLinetoVerticalRel.prototype, 'y', { + get: function get() { + return this._y; + }, + set: function set(y) { + this._y = y; + + this._segmentChanged(); + }, + enumerable: true + }); + + var _SVGPathSegCurvetoCubicSmoothAbs = /*#__PURE__*/function (_SVGPathSeg17) { + _inherits(_SVGPathSegCurvetoCubicSmoothAbs, _SVGPathSeg17); + + var _super16 = _createSuper(_SVGPathSegCurvetoCubicSmoothAbs); + + function _SVGPathSegCurvetoCubicSmoothAbs(owningPathSegList, x, y, x2, y2) { + var _this15; + + _classCallCheck(this, _SVGPathSegCurvetoCubicSmoothAbs); + + _this15 = _super16.call(this, _SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS, 'S', owningPathSegList); + _this15._x = x; + _this15._y = y; + _this15._x2 = x2; + _this15._y2 = y2; + return _this15; + } + + _createClass(_SVGPathSegCurvetoCubicSmoothAbs, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegCurvetoCubicSmoothAbs]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x2 + ' ' + this._y2 + ' ' + this._x + ' ' + this._y; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegCurvetoCubicSmoothAbs(undefined, this._x, this._y, this._x2, this._y2); + } + }]); + + return _SVGPathSegCurvetoCubicSmoothAbs; + }(_SVGPathSeg); + + Object.defineProperties(_SVGPathSegCurvetoCubicSmoothAbs.prototype, { + x: { + get: function get() { + return this._x; + }, + set: function set(x) { + this._x = x; + + this._segmentChanged(); + }, + enumerable: true + }, + y: { + get: function get() { + return this._y; + }, + set: function set(y) { + this._y = y; + + this._segmentChanged(); + }, + enumerable: true + }, + x2: { + get: function get() { + return this._x2; + }, + set: function set(x2) { + this._x2 = x2; + + this._segmentChanged(); + }, + enumerable: true + }, + y2: { + get: function get() { + return this._y2; + }, + set: function set(y2) { + this._y2 = y2; + + this._segmentChanged(); + }, + enumerable: true + } + }); + + var _SVGPathSegCurvetoCubicSmoothRel = /*#__PURE__*/function (_SVGPathSeg18) { + _inherits(_SVGPathSegCurvetoCubicSmoothRel, _SVGPathSeg18); + + var _super17 = _createSuper(_SVGPathSegCurvetoCubicSmoothRel); + + function _SVGPathSegCurvetoCubicSmoothRel(owningPathSegList, x, y, x2, y2) { + var _this16; + + _classCallCheck(this, _SVGPathSegCurvetoCubicSmoothRel); + + _this16 = _super17.call(this, _SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL, 's', owningPathSegList); + _this16._x = x; + _this16._y = y; + _this16._x2 = x2; + _this16._y2 = y2; + return _this16; + } + + _createClass(_SVGPathSegCurvetoCubicSmoothRel, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegCurvetoCubicSmoothRel]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x2 + ' ' + this._y2 + ' ' + this._x + ' ' + this._y; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegCurvetoCubicSmoothRel(undefined, this._x, this._y, this._x2, this._y2); + } + }]); + + return _SVGPathSegCurvetoCubicSmoothRel; + }(_SVGPathSeg); + + Object.defineProperties(_SVGPathSegCurvetoCubicSmoothRel.prototype, { + x: { + get: function get() { + return this._x; + }, + set: function set(x) { + this._x = x; + + this._segmentChanged(); + }, + enumerable: true + }, + y: { + get: function get() { + return this._y; + }, + set: function set(y) { + this._y = y; + + this._segmentChanged(); + }, + enumerable: true + }, + x2: { + get: function get() { + return this._x2; + }, + set: function set(x2) { + this._x2 = x2; + + this._segmentChanged(); + }, + enumerable: true + }, + y2: { + get: function get() { + return this._y2; + }, + set: function set(y2) { + this._y2 = y2; + + this._segmentChanged(); + }, + enumerable: true + } + }); + + var _SVGPathSegCurvetoQuadraticSmoothAbs = /*#__PURE__*/function (_SVGPathSeg19) { + _inherits(_SVGPathSegCurvetoQuadraticSmoothAbs, _SVGPathSeg19); + + var _super18 = _createSuper(_SVGPathSegCurvetoQuadraticSmoothAbs); + + function _SVGPathSegCurvetoQuadraticSmoothAbs(owningPathSegList, x, y) { + var _this17; + + _classCallCheck(this, _SVGPathSegCurvetoQuadraticSmoothAbs); + + _this17 = _super18.call(this, _SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS, 'T', owningPathSegList); + _this17._x = x; + _this17._y = y; + return _this17; + } + + _createClass(_SVGPathSegCurvetoQuadraticSmoothAbs, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegCurvetoQuadraticSmoothAbs]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegCurvetoQuadraticSmoothAbs(undefined, this._x, this._y); + } + }]); + + return _SVGPathSegCurvetoQuadraticSmoothAbs; + }(_SVGPathSeg); + + Object.defineProperties(_SVGPathSegCurvetoQuadraticSmoothAbs.prototype, { + x: { + get: function get() { + return this._x; + }, + set: function set(x) { + this._x = x; + + this._segmentChanged(); + }, + enumerable: true + }, + y: { + get: function get() { + return this._y; + }, + set: function set(y) { + this._y = y; + + this._segmentChanged(); + }, + enumerable: true + } + }); + + var _SVGPathSegCurvetoQuadraticSmoothRel = /*#__PURE__*/function (_SVGPathSeg20) { + _inherits(_SVGPathSegCurvetoQuadraticSmoothRel, _SVGPathSeg20); + + var _super19 = _createSuper(_SVGPathSegCurvetoQuadraticSmoothRel); + + function _SVGPathSegCurvetoQuadraticSmoothRel(owningPathSegList, x, y) { + var _this18; + + _classCallCheck(this, _SVGPathSegCurvetoQuadraticSmoothRel); + + _this18 = _super19.call(this, _SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL, 't', owningPathSegList); + _this18._x = x; + _this18._y = y; + return _this18; + } + + _createClass(_SVGPathSegCurvetoQuadraticSmoothRel, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegCurvetoQuadraticSmoothRel]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegCurvetoQuadraticSmoothRel(undefined, this._x, this._y); + } + }]); + + return _SVGPathSegCurvetoQuadraticSmoothRel; + }(_SVGPathSeg); + + Object.defineProperties(_SVGPathSegCurvetoQuadraticSmoothRel.prototype, { + x: { + get: function get() { + return this._x; + }, + set: function set(x) { + this._x = x; + + this._segmentChanged(); + }, + enumerable: true + }, + y: { + get: function get() { + return this._y; + }, + set: function set(y) { + this._y = y; + + this._segmentChanged(); + }, + enumerable: true + } + }); // Add createSVGPathSeg* functions to SVGPathElement. + // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathElement. + + SVGPathElement.prototype.createSVGPathSegClosePath = function () { + return new _SVGPathSegClosePath(undefined); + }; + + SVGPathElement.prototype.createSVGPathSegMovetoAbs = function (x, y) { + return new _SVGPathSegMovetoAbs(undefined, x, y); + }; + + SVGPathElement.prototype.createSVGPathSegMovetoRel = function (x, y) { + return new _SVGPathSegMovetoRel(undefined, x, y); + }; + + SVGPathElement.prototype.createSVGPathSegLinetoAbs = function (x, y) { + return new _SVGPathSegLinetoAbs(undefined, x, y); + }; + + SVGPathElement.prototype.createSVGPathSegLinetoRel = function (x, y) { + return new _SVGPathSegLinetoRel(undefined, x, y); + }; + + SVGPathElement.prototype.createSVGPathSegCurvetoCubicAbs = function (x, y, x1, y1, x2, y2) { + return new _SVGPathSegCurvetoCubicAbs(undefined, x, y, x1, y1, x2, y2); + }; + + SVGPathElement.prototype.createSVGPathSegCurvetoCubicRel = function (x, y, x1, y1, x2, y2) { + return new _SVGPathSegCurvetoCubicRel(undefined, x, y, x1, y1, x2, y2); + }; + + SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticAbs = function (x, y, x1, y1) { + return new _SVGPathSegCurvetoQuadraticAbs(undefined, x, y, x1, y1); + }; + + SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticRel = function (x, y, x1, y1) { + return new _SVGPathSegCurvetoQuadraticRel(undefined, x, y, x1, y1); + }; + + SVGPathElement.prototype.createSVGPathSegArcAbs = function (x, y, r1, r2, angle, largeArcFlag, sweepFlag) { + return new _SVGPathSegArcAbs(undefined, x, y, r1, r2, angle, largeArcFlag, sweepFlag); + }; + + SVGPathElement.prototype.createSVGPathSegArcRel = function (x, y, r1, r2, angle, largeArcFlag, sweepFlag) { + return new _SVGPathSegArcRel(undefined, x, y, r1, r2, angle, largeArcFlag, sweepFlag); + }; + + SVGPathElement.prototype.createSVGPathSegLinetoHorizontalAbs = function (x) { + return new _SVGPathSegLinetoHorizontalAbs(undefined, x); + }; + + SVGPathElement.prototype.createSVGPathSegLinetoHorizontalRel = function (x) { + return new _SVGPathSegLinetoHorizontalRel(undefined, x); + }; + + SVGPathElement.prototype.createSVGPathSegLinetoVerticalAbs = function (y) { + return new _SVGPathSegLinetoVerticalAbs(undefined, y); + }; + + SVGPathElement.prototype.createSVGPathSegLinetoVerticalRel = function (y) { + return new _SVGPathSegLinetoVerticalRel(undefined, y); + }; + + SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothAbs = function (x, y, x2, y2) { + return new _SVGPathSegCurvetoCubicSmoothAbs(undefined, x, y, x2, y2); + }; + + SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothRel = function (x, y, x2, y2) { + return new _SVGPathSegCurvetoCubicSmoothRel(undefined, x, y, x2, y2); + }; + + SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothAbs = function (x, y) { + return new _SVGPathSegCurvetoQuadraticSmoothAbs(undefined, x, y); + }; + + SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothRel = function (x, y) { + return new _SVGPathSegCurvetoQuadraticSmoothRel(undefined, x, y); + }; + + if (!('getPathSegAtLength' in SVGPathElement.prototype)) { + // Add getPathSegAtLength to SVGPathElement. + // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-__svg__SVGPathElement__getPathSegAtLength + // This polyfill requires SVGPathElement.getTotalLength to implement the distance-along-a-path algorithm. + SVGPathElement.prototype.getPathSegAtLength = function (distance) { + if (distance === undefined || !isFinite(distance)) { + throw new Error('Invalid arguments.'); + } + + var measurementElement = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + measurementElement.setAttribute('d', this.getAttribute('d')); + var lastPathSegment = measurementElement.pathSegList.numberOfItems - 1; // If the path is empty, return 0. + + if (lastPathSegment <= 0) { + return 0; + } + + do { + measurementElement.pathSegList.removeItem(lastPathSegment); + + if (distance > measurementElement.getTotalLength()) { + break; + } + + lastPathSegment--; + } while (lastPathSegment > 0); + + return lastPathSegment; + }; + } + + window.SVGPathSeg = _SVGPathSeg; + window.SVGPathSegClosePath = _SVGPathSegClosePath; + window.SVGPathSegMovetoAbs = _SVGPathSegMovetoAbs; + window.SVGPathSegMovetoRel = _SVGPathSegMovetoRel; + window.SVGPathSegLinetoAbs = _SVGPathSegLinetoAbs; + window.SVGPathSegLinetoRel = _SVGPathSegLinetoRel; + window.SVGPathSegCurvetoCubicAbs = _SVGPathSegCurvetoCubicAbs; + window.SVGPathSegCurvetoCubicRel = _SVGPathSegCurvetoCubicRel; + window.SVGPathSegCurvetoQuadraticAbs = _SVGPathSegCurvetoQuadraticAbs; + window.SVGPathSegCurvetoQuadraticRel = _SVGPathSegCurvetoQuadraticRel; + window.SVGPathSegArcAbs = _SVGPathSegArcAbs; + window.SVGPathSegArcRel = _SVGPathSegArcRel; + window.SVGPathSegLinetoHorizontalAbs = _SVGPathSegLinetoHorizontalAbs; + window.SVGPathSegLinetoHorizontalRel = _SVGPathSegLinetoHorizontalRel; + window.SVGPathSegLinetoVerticalAbs = _SVGPathSegLinetoVerticalAbs; + window.SVGPathSegLinetoVerticalRel = _SVGPathSegLinetoVerticalRel; + window.SVGPathSegCurvetoCubicSmoothAbs = _SVGPathSegCurvetoCubicSmoothAbs; + window.SVGPathSegCurvetoCubicSmoothRel = _SVGPathSegCurvetoCubicSmoothRel; + window.SVGPathSegCurvetoQuadraticSmoothAbs = _SVGPathSegCurvetoQuadraticSmoothAbs; + window.SVGPathSegCurvetoQuadraticSmoothRel = _SVGPathSegCurvetoQuadraticSmoothRel; + } // Checking for SVGPathSegList in window checks for the case of an implementation without the + // SVGPathSegList API. + // The second check for appendItem is specific to Firefox 59+ which removed only parts of the + // SVGPathSegList API (e.g., appendItem). In this case we need to re-implement the entire API + // so the polyfill data (i.e., _list) is used throughout. + + + if (!('SVGPathSegList' in window) || !('appendItem' in window.SVGPathSegList.prototype)) { + // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathSegList + var SVGPathSegList = /*#__PURE__*/function () { + function SVGPathSegList(pathElement) { + _classCallCheck(this, SVGPathSegList); + + this._pathElement = pathElement; + this._list = this._parsePath(this._pathElement.getAttribute('d')); // Use a MutationObserver to catch changes to the path's "d" attribute. + + this._mutationObserverConfig = { + attributes: true, + attributeFilter: ['d'] + }; + this._pathElementMutationObserver = new MutationObserver(this._updateListFromPathMutations.bind(this)); + + this._pathElementMutationObserver.observe(this._pathElement, this._mutationObserverConfig); + } // Process any pending mutations to the path element and update the list as needed. + // This should be the first call of all public functions and is needed because + // MutationObservers are not synchronous so we can have pending asynchronous mutations. + + + _createClass(SVGPathSegList, [{ + key: "_checkPathSynchronizedToList", + value: function _checkPathSynchronizedToList() { + this._updateListFromPathMutations(this._pathElementMutationObserver.takeRecords()); + } + }, { + key: "_updateListFromPathMutations", + value: function _updateListFromPathMutations(mutationRecords) { + if (!this._pathElement) { + return; + } + + var hasPathMutations = false; + mutationRecords.forEach(function (record) { + if (record.attributeName === 'd') { + hasPathMutations = true; + } + }); + + if (hasPathMutations) { + this._list = this._parsePath(this._pathElement.getAttribute('d')); + } + } // Serialize the list and update the path's 'd' attribute. + + }, { + key: "_writeListToPath", + value: function _writeListToPath() { + this._pathElementMutationObserver.disconnect(); + + this._pathElement.setAttribute('d', SVGPathSegList._pathSegArrayAsString(this._list)); + + this._pathElementMutationObserver.observe(this._pathElement, this._mutationObserverConfig); + } // When a path segment changes the list needs to be synchronized back to the path element. + + }, { + key: "segmentChanged", + value: function segmentChanged(pathSeg) { + this._writeListToPath(); + } + }, { + key: "clear", + value: function clear() { + this._checkPathSynchronizedToList(); + + this._list.forEach(function (pathSeg) { + pathSeg._owningPathSegList = null; + }); + + this._list = []; + + this._writeListToPath(); + } + }, { + key: "initialize", + value: function initialize(newItem) { + this._checkPathSynchronizedToList(); + + this._list = [newItem]; + newItem._owningPathSegList = this; + + this._writeListToPath(); + + return newItem; + } + }, { + key: "_checkValidIndex", + value: function _checkValidIndex(index) { + if (isNaN(index) || index < 0 || index >= this.numberOfItems) { + throw new Error('INDEX_SIZE_ERR'); + } + } + }, { + key: "getItem", + value: function getItem(index) { + this._checkPathSynchronizedToList(); + + this._checkValidIndex(index); + + return this._list[index]; + } + }, { + key: "insertItemBefore", + value: function insertItemBefore(newItem, index) { + this._checkPathSynchronizedToList(); // Spec: If the index is greater than or equal to numberOfItems, then the new item is appended to the end of the list. + + + if (index > this.numberOfItems) { + index = this.numberOfItems; + } + + if (newItem._owningPathSegList) { + // SVG2 spec says to make a copy. + newItem = newItem.clone(); + } + + this._list.splice(index, 0, newItem); + + newItem._owningPathSegList = this; + + this._writeListToPath(); + + return newItem; + } + }, { + key: "replaceItem", + value: function replaceItem(newItem, index) { + this._checkPathSynchronizedToList(); + + if (newItem._owningPathSegList) { + // SVG2 spec says to make a copy. + newItem = newItem.clone(); + } + + this._checkValidIndex(index); + + this._list[index] = newItem; + newItem._owningPathSegList = this; + + this._writeListToPath(); + + return newItem; + } + }, { + key: "removeItem", + value: function removeItem(index) { + this._checkPathSynchronizedToList(); + + this._checkValidIndex(index); + + var item = this._list[index]; + + this._list.splice(index, 1); + + this._writeListToPath(); + + return item; + } + }, { + key: "appendItem", + value: function appendItem(newItem) { + this._checkPathSynchronizedToList(); + + if (newItem._owningPathSegList) { + // SVG2 spec says to make a copy. + newItem = newItem.clone(); + } + + this._list.push(newItem); + + newItem._owningPathSegList = this; // TODO: Optimize this to just append to the existing attribute. + + this._writeListToPath(); + + return newItem; + } // This closely follows SVGPathParser::parsePath from Source/core/svg/SVGPathParser.cpp. + + }, { + key: "_parsePath", + value: function _parsePath(string) { + if (!string || !string.length) { + return []; + } + + var owningPathSegList = this; + + var Builder = /*#__PURE__*/function () { + function Builder() { + _classCallCheck(this, Builder); + + this.pathSegList = []; + } + + _createClass(Builder, [{ + key: "appendSegment", + value: function appendSegment(pathSeg) { + this.pathSegList.push(pathSeg); + } + }]); + + return Builder; + }(); + + var Source = /*#__PURE__*/function () { + function Source(string) { + _classCallCheck(this, Source); + + this._string = string; + this._currentIndex = 0; + this._endIndex = this._string.length; + this._previousCommand = SVGPathSeg.PATHSEG_UNKNOWN; + + this._skipOptionalSpaces(); + } + + _createClass(Source, [{ + key: "_isCurrentSpace", + value: function _isCurrentSpace() { + var character = this._string[this._currentIndex]; + return character <= ' ' && (character === ' ' || character === '\n' || character === '\t' || character === '\r' || character === '\f'); + } + }, { + key: "_skipOptionalSpaces", + value: function _skipOptionalSpaces() { + while (this._currentIndex < this._endIndex && this._isCurrentSpace()) { + this._currentIndex++; + } + + return this._currentIndex < this._endIndex; + } + }, { + key: "_skipOptionalSpacesOrDelimiter", + value: function _skipOptionalSpacesOrDelimiter() { + if (this._currentIndex < this._endIndex && !this._isCurrentSpace() && this._string.charAt(this._currentIndex) !== ',') { + return false; + } + + if (this._skipOptionalSpaces()) { + if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) === ',') { + this._currentIndex++; + + this._skipOptionalSpaces(); + } + } + + return this._currentIndex < this._endIndex; + } + }, { + key: "hasMoreData", + value: function hasMoreData() { + return this._currentIndex < this._endIndex; + } + }, { + key: "peekSegmentType", + value: function peekSegmentType() { + var lookahead = this._string[this._currentIndex]; + return this._pathSegTypeFromChar(lookahead); + } + }, { + key: "_pathSegTypeFromChar", + value: function _pathSegTypeFromChar(lookahead) { + switch (lookahead) { + case 'Z': + case 'z': + return SVGPathSeg.PATHSEG_CLOSEPATH; + + case 'M': + return SVGPathSeg.PATHSEG_MOVETO_ABS; + + case 'm': + return SVGPathSeg.PATHSEG_MOVETO_REL; + + case 'L': + return SVGPathSeg.PATHSEG_LINETO_ABS; + + case 'l': + return SVGPathSeg.PATHSEG_LINETO_REL; + + case 'C': + return SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS; + + case 'c': + return SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL; + + case 'Q': + return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS; + + case 'q': + return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL; + + case 'A': + return SVGPathSeg.PATHSEG_ARC_ABS; + + case 'a': + return SVGPathSeg.PATHSEG_ARC_REL; + + case 'H': + return SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS; + + case 'h': + return SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL; + + case 'V': + return SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS; + + case 'v': + return SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL; + + case 'S': + return SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS; + + case 's': + return SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL; + + case 'T': + return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS; + + case 't': + return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL; + + default: + return SVGPathSeg.PATHSEG_UNKNOWN; + } + } + }, { + key: "_nextCommandHelper", + value: function _nextCommandHelper(lookahead, previousCommand) { + // Check for remaining coordinates in the current command. + if ((lookahead === '+' || lookahead === '-' || lookahead === '.' || lookahead >= '0' && lookahead <= '9') && previousCommand !== SVGPathSeg.PATHSEG_CLOSEPATH) { + if (previousCommand === SVGPathSeg.PATHSEG_MOVETO_ABS) { + return SVGPathSeg.PATHSEG_LINETO_ABS; + } + + if (previousCommand === SVGPathSeg.PATHSEG_MOVETO_REL) { + return SVGPathSeg.PATHSEG_LINETO_REL; + } + + return previousCommand; + } + + return SVGPathSeg.PATHSEG_UNKNOWN; + } + }, { + key: "initialCommandIsMoveTo", + value: function initialCommandIsMoveTo() { + // If the path is empty it is still valid, so return true. + if (!this.hasMoreData()) { + return true; + } + + var command = this.peekSegmentType(); // Path must start with moveTo. + + return command === SVGPathSeg.PATHSEG_MOVETO_ABS || command === SVGPathSeg.PATHSEG_MOVETO_REL; + } // Parse a number from an SVG path. This very closely follows genericParseNumber(...) from Source/core/svg/SVGParserUtilities.cpp. + // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-PathDataBNF + + }, { + key: "_parseNumber", + value: function _parseNumber() { + var exponent = 0; + var integer = 0; + var frac = 1; + var decimal = 0; + var sign = 1; + var expsign = 1; + var startIndex = this._currentIndex; + + this._skipOptionalSpaces(); // Read the sign. + + + if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) === '+') { + this._currentIndex++; + } else if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) === '-') { + this._currentIndex++; + sign = -1; + } + + if (this._currentIndex === this._endIndex || (this._string.charAt(this._currentIndex) < '0' || this._string.charAt(this._currentIndex) > '9') && this._string.charAt(this._currentIndex) !== '.') { + // The first character of a number must be one of [0-9+-.]. + return undefined; + } // Read the integer part, build right-to-left. + + + var startIntPartIndex = this._currentIndex; + + while (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) >= '0' && this._string.charAt(this._currentIndex) <= '9') { + this._currentIndex++; // Advance to first non-digit. + } + + if (this._currentIndex !== startIntPartIndex) { + var scanIntPartIndex = this._currentIndex - 1; + var multiplier = 1; + + while (scanIntPartIndex >= startIntPartIndex) { + integer += multiplier * (this._string.charAt(scanIntPartIndex--) - '0'); + multiplier *= 10; + } + } // Read the decimals. + + + if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) === '.') { + this._currentIndex++; // There must be a least one digit following the . + + if (this._currentIndex >= this._endIndex || this._string.charAt(this._currentIndex) < '0' || this._string.charAt(this._currentIndex) > '9') { + return undefined; + } + + while (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) >= '0' && this._string.charAt(this._currentIndex) <= '9') { + frac *= 10; + decimal += (this._string.charAt(this._currentIndex) - '0') / frac; + this._currentIndex += 1; + } + } // Read the exponent part. + + + if (this._currentIndex !== startIndex && this._currentIndex + 1 < this._endIndex && (this._string.charAt(this._currentIndex) === 'e' || this._string.charAt(this._currentIndex) === 'E') && this._string.charAt(this._currentIndex + 1) !== 'x' && this._string.charAt(this._currentIndex + 1) !== 'm') { + this._currentIndex++; // Read the sign of the exponent. + + if (this._string.charAt(this._currentIndex) === '+') { + this._currentIndex++; + } else if (this._string.charAt(this._currentIndex) === '-') { + this._currentIndex++; + expsign = -1; + } // There must be an exponent. + + + if (this._currentIndex >= this._endIndex || this._string.charAt(this._currentIndex) < '0' || this._string.charAt(this._currentIndex) > '9') { + return undefined; + } + + while (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) >= '0' && this._string.charAt(this._currentIndex) <= '9') { + exponent *= 10; + exponent += this._string.charAt(this._currentIndex) - '0'; + this._currentIndex++; + } + } + + var number = integer + decimal; + number *= sign; + + if (exponent) { + number *= Math.pow(10, expsign * exponent); + } + + if (startIndex === this._currentIndex) { + return undefined; + } + + this._skipOptionalSpacesOrDelimiter(); + + return number; + } + }, { + key: "_parseArcFlag", + value: function _parseArcFlag() { + if (this._currentIndex >= this._endIndex) { + return undefined; + } + + var flag = false; + + var flagChar = this._string.charAt(this._currentIndex++); + + if (flagChar === '0') { + flag = false; + } else if (flagChar === '1') { + flag = true; + } else { + return undefined; + } + + this._skipOptionalSpacesOrDelimiter(); + + return flag; + } + }, { + key: "parseSegment", + value: function parseSegment() { + var lookahead = this._string[this._currentIndex]; + + var command = this._pathSegTypeFromChar(lookahead); + + if (command === SVGPathSeg.PATHSEG_UNKNOWN) { + // Possibly an implicit command. Not allowed if this is the first command. + if (this._previousCommand === SVGPathSeg.PATHSEG_UNKNOWN) { + return null; + } + + command = this._nextCommandHelper(lookahead, this._previousCommand); + + if (command === SVGPathSeg.PATHSEG_UNKNOWN) { + return null; + } + } else { + this._currentIndex++; + } + + this._previousCommand = command; + + switch (command) { + case SVGPathSeg.PATHSEG_MOVETO_REL: + return new SVGPathSegMovetoRel(owningPathSegList, this._parseNumber(), this._parseNumber()); + + case SVGPathSeg.PATHSEG_MOVETO_ABS: + return new SVGPathSegMovetoAbs(owningPathSegList, this._parseNumber(), this._parseNumber()); + + case SVGPathSeg.PATHSEG_LINETO_REL: + return new SVGPathSegLinetoRel(owningPathSegList, this._parseNumber(), this._parseNumber()); + + case SVGPathSeg.PATHSEG_LINETO_ABS: + return new SVGPathSegLinetoAbs(owningPathSegList, this._parseNumber(), this._parseNumber()); + + case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL: + return new SVGPathSegLinetoHorizontalRel(owningPathSegList, this._parseNumber()); + + case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS: + return new SVGPathSegLinetoHorizontalAbs(owningPathSegList, this._parseNumber()); + + case SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL: + return new SVGPathSegLinetoVerticalRel(owningPathSegList, this._parseNumber()); + + case SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS: + return new SVGPathSegLinetoVerticalAbs(owningPathSegList, this._parseNumber()); + + case SVGPathSeg.PATHSEG_CLOSEPATH: + this._skipOptionalSpaces(); + + return new SVGPathSegClosePath(owningPathSegList); + + case SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL: + { + var points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + x2: this._parseNumber(), + y2: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new SVGPathSegCurvetoCubicRel(owningPathSegList, points.x, points.y, points.x1, points.y1, points.x2, points.y2); + } + + case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS: + { + var _points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + x2: this._parseNumber(), + y2: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new SVGPathSegCurvetoCubicAbs(owningPathSegList, _points.x, _points.y, _points.x1, _points.y1, _points.x2, _points.y2); + } + + case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL: + { + var _points2 = { + x2: this._parseNumber(), + y2: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new SVGPathSegCurvetoCubicSmoothRel(owningPathSegList, _points2.x, _points2.y, _points2.x2, _points2.y2); + } + + case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: + { + var _points3 = { + x2: this._parseNumber(), + y2: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new SVGPathSegCurvetoCubicSmoothAbs(owningPathSegList, _points3.x, _points3.y, _points3.x2, _points3.y2); + } + + case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL: + { + var _points4 = { + x1: this._parseNumber(), + y1: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new SVGPathSegCurvetoQuadraticRel(owningPathSegList, _points4.x, _points4.y, _points4.x1, _points4.y1); + } + + case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS: + { + var _points5 = { + x1: this._parseNumber(), + y1: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new SVGPathSegCurvetoQuadraticAbs(owningPathSegList, _points5.x, _points5.y, _points5.x1, _points5.y1); + } + + case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: + return new SVGPathSegCurvetoQuadraticSmoothRel(owningPathSegList, this._parseNumber(), this._parseNumber()); + + case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: + return new SVGPathSegCurvetoQuadraticSmoothAbs(owningPathSegList, this._parseNumber(), this._parseNumber()); + + case SVGPathSeg.PATHSEG_ARC_REL: + { + var _points6 = { + x1: this._parseNumber(), + y1: this._parseNumber(), + arcAngle: this._parseNumber(), + arcLarge: this._parseArcFlag(), + arcSweep: this._parseArcFlag(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new SVGPathSegArcRel(owningPathSegList, _points6.x, _points6.y, _points6.x1, _points6.y1, _points6.arcAngle, _points6.arcLarge, _points6.arcSweep); + } + + case SVGPathSeg.PATHSEG_ARC_ABS: + { + var _points7 = { + x1: this._parseNumber(), + y1: this._parseNumber(), + arcAngle: this._parseNumber(), + arcLarge: this._parseArcFlag(), + arcSweep: this._parseArcFlag(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new SVGPathSegArcAbs(owningPathSegList, _points7.x, _points7.y, _points7.x1, _points7.y1, _points7.arcAngle, _points7.arcLarge, _points7.arcSweep); + } + + default: + throw new Error('Unknown path seg type.'); + } + } + }]); + + return Source; + }(); + + var builder = new Builder(); + var source = new Source(string); + + if (!source.initialCommandIsMoveTo()) { + return []; + } + + while (source.hasMoreData()) { + var pathSeg = source.parseSegment(); + + if (!pathSeg) { + return []; + } + + builder.appendSegment(pathSeg); + } + + return builder.pathSegList; + } // STATIC + + }], [{ + key: "_pathSegArrayAsString", + value: function _pathSegArrayAsString(pathSegArray) { + var string = ''; + var first = true; + pathSegArray.forEach(function (pathSeg) { + if (first) { + first = false; + string += pathSeg._asPathString(); + } else { + string += ' ' + pathSeg._asPathString(); + } + }); + return string; + } + }]); + + return SVGPathSegList; + }(); + + SVGPathSegList.prototype.classname = 'SVGPathSegList'; + Object.defineProperty(SVGPathSegList.prototype, 'numberOfItems', { + get: function get() { + this._checkPathSynchronizedToList(); + + return this._list.length; + }, + enumerable: true + }); // Add the pathSegList accessors to SVGPathElement. + // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGAnimatedPathData + + Object.defineProperties(SVGPathElement.prototype, { + pathSegList: { + get: function get() { + if (!this._pathSegList) { + this._pathSegList = new SVGPathSegList(this); + } + + return this._pathSegList; + }, + enumerable: true + }, + // TODO: The following are not implemented and simply return SVGPathElement.pathSegList. + normalizedPathSegList: { + get: function get() { + return this.pathSegList; + }, + enumerable: true + }, + animatedPathSegList: { + get: function get() { + return this.pathSegList; + }, + enumerable: true + }, + animatedNormalizedPathSegList: { + get: function get() { + return this.pathSegList; + }, + enumerable: true + } + }); + window.SVGPathSegList = SVGPathSegList; + } +})(); + +// The button toggles whether the path is open or closed + +var extClosepath = { + name: 'closepath', + init: function init(_ref) { + var _this = this; + + return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { + var importLocale, $, strings, svgEditor, selElems, updateButton, showPanel, toggleClosed, buttons; + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + importLocale = _ref.importLocale, $ = _ref.$; + _context.next = 3; + return importLocale(); + + case 3: + strings = _context.sent; + svgEditor = _this; + + updateButton = function updateButton(path) { + var seglist = path.pathSegList, + closed = seglist.getItem(seglist.numberOfItems - 1).pathSegType === 1, + showbutton = closed ? '#tool_openpath' : '#tool_closepath', + hidebutton = closed ? '#tool_closepath' : '#tool_openpath'; + $(hidebutton).hide(); + $(showbutton).show(); + }; + + showPanel = function showPanel(on) { + $('#closepath_panel').toggle(on); + + if (on) { + var path = selElems[0]; + + if (path) { + updateButton(path); + } + } + }; + + toggleClosed = function toggleClosed() { + var path = selElems[0]; + + if (path) { + var seglist = path.pathSegList, + last = seglist.numberOfItems - 1; // is closed + + if (seglist.getItem(last).pathSegType === 1) { + seglist.removeItem(last); + } else { + seglist.appendItem(path.createSVGPathSegClosePath()); + } + + updateButton(path); + } + }; + + buttons = [{ + id: 'tool_openpath', + icon: svgEditor.curConfig.extIconsPath + 'openpath.png', + type: 'context', + panel: 'closepath_panel', + events: { + click: function click() { + toggleClosed(); + } + } + }, { + id: 'tool_closepath', + icon: svgEditor.curConfig.extIconsPath + 'closepath.png', + type: 'context', + panel: 'closepath_panel', + events: { + click: function click() { + toggleClosed(); + } + } + }]; + return _context.abrupt("return", { + name: strings.name, + svgicons: svgEditor.curConfig.extIconsPath + 'closepath_icons.svg', + buttons: strings.buttons.map(function (button, i) { + return Object.assign(buttons[i], button); + }), + callback: function callback() { + $('#closepath_panel').hide(); + }, + selectedChanged: function selectedChanged(opts) { + selElems = opts.elems; + var i = selElems.length; + + while (i--) { + var elem = selElems[i]; + + if (elem && elem.tagName === 'path') { + if (opts.selectedElement && !opts.multiselected) { + showPanel(true); + } else { + showPanel(false); + } + } else { + showPanel(false); + } + } + } + }); + + case 10: + case "end": + return _context.stop(); + } + } + }, _callee); + }))(); + } +}; + +export default extClosepath; +//# sourceMappingURL=ext-closepath.js.map diff --git a/dist/editor/extensions/ext-closepath.js.map b/dist/editor/extensions/ext-closepath.js.map new file mode 100644 index 00000000..9eeda1d6 --- /dev/null +++ b/dist/editor/extensions/ext-closepath.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ext-closepath.js","sources":["../../../src/common/svgpathseg.js","../../../src/editor/extensions/ext-closepath.js"],"sourcesContent":["/* eslint-disable import/unambiguous, max-len */\n/* globals SVGPathSeg, SVGPathSegMovetoRel, SVGPathSegMovetoAbs,\n SVGPathSegMovetoRel, SVGPathSegLinetoRel, SVGPathSegLinetoAbs,\n SVGPathSegLinetoHorizontalRel, SVGPathSegLinetoHorizontalAbs,\n SVGPathSegLinetoVerticalRel, SVGPathSegLinetoVerticalAbs,\n SVGPathSegClosePath, SVGPathSegCurvetoCubicRel,\n SVGPathSegCurvetoCubicAbs, SVGPathSegCurvetoCubicSmoothRel,\n SVGPathSegCurvetoCubicSmoothAbs, SVGPathSegCurvetoQuadraticRel,\n SVGPathSegCurvetoQuadraticAbs, SVGPathSegCurvetoQuadraticSmoothRel,\n SVGPathSegCurvetoQuadraticSmoothAbs, SVGPathSegArcRel, SVGPathSegArcAbs */\n/**\n* SVGPathSeg API polyfill\n* https://github.com/progers/pathseg\n*\n* This is a drop-in replacement for the `SVGPathSeg` and `SVGPathSegList` APIs\n* that were removed from SVG2 ({@link https://lists.w3.org/Archives/Public/www-svg/2015Jun/0044.html}),\n* including the latest spec changes which were implemented in Firefox 43 and\n* Chrome 46.\n*/\n/* eslint-disable no-shadow, class-methods-use-this, jsdoc/require-jsdoc */\n// Linting: We avoid `no-shadow` as ESLint thinks these are still available globals\n// Linting: We avoid `class-methods-use-this` as this is a polyfill that must\n// follow the conventions\n(() => {\nif (!('SVGPathSeg' in window)) {\n // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathSeg\n class SVGPathSeg {\n constructor (type, typeAsLetter, owningPathSegList) {\n this.pathSegType = type;\n this.pathSegTypeAsLetter = typeAsLetter;\n this._owningPathSegList = owningPathSegList;\n }\n // Notify owning PathSegList on any changes so they can be synchronized back to the path element.\n _segmentChanged () {\n if (this._owningPathSegList) {\n this._owningPathSegList.segmentChanged(this);\n }\n }\n }\n SVGPathSeg.prototype.classname = 'SVGPathSeg';\n\n SVGPathSeg.PATHSEG_UNKNOWN = 0;\n SVGPathSeg.PATHSEG_CLOSEPATH = 1;\n SVGPathSeg.PATHSEG_MOVETO_ABS = 2;\n SVGPathSeg.PATHSEG_MOVETO_REL = 3;\n SVGPathSeg.PATHSEG_LINETO_ABS = 4;\n SVGPathSeg.PATHSEG_LINETO_REL = 5;\n SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS = 6;\n SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL = 7;\n SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS = 8;\n SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL = 9;\n SVGPathSeg.PATHSEG_ARC_ABS = 10;\n SVGPathSeg.PATHSEG_ARC_REL = 11;\n SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS = 12;\n SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL = 13;\n SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS = 14;\n SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL = 15;\n SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS = 16;\n SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL = 17;\n SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS = 18;\n SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = 19;\n\n class SVGPathSegClosePath extends SVGPathSeg {\n constructor (owningPathSegList) {\n super(SVGPathSeg.PATHSEG_CLOSEPATH, 'z', owningPathSegList);\n }\n toString () { return '[object SVGPathSegClosePath]'; }\n _asPathString () { return this.pathSegTypeAsLetter; }\n clone () { return new SVGPathSegClosePath(undefined); }\n }\n\n class SVGPathSegMovetoAbs extends SVGPathSeg {\n constructor (owningPathSegList, x, y) {\n super(SVGPathSeg.PATHSEG_MOVETO_ABS, 'M', owningPathSegList);\n this._x = x;\n this._y = y;\n }\n toString () { return '[object SVGPathSegMovetoAbs]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; }\n clone () { return new SVGPathSegMovetoAbs(undefined, this._x, this._y); }\n }\n Object.defineProperties(SVGPathSegMovetoAbs.prototype, {\n x: {\n get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true\n },\n y: {\n get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true\n }\n });\n\n class SVGPathSegMovetoRel extends SVGPathSeg {\n constructor (owningPathSegList, x, y) {\n super(SVGPathSeg.PATHSEG_MOVETO_REL, 'm', owningPathSegList);\n this._x = x;\n this._y = y;\n }\n toString () { return '[object SVGPathSegMovetoRel]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; }\n clone () { return new SVGPathSegMovetoRel(undefined, this._x, this._y); }\n }\n Object.defineProperties(SVGPathSegMovetoRel.prototype, {\n x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true},\n y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true}\n });\n\n class SVGPathSegLinetoAbs extends SVGPathSeg {\n constructor (owningPathSegList, x, y) {\n super(SVGPathSeg.PATHSEG_LINETO_ABS, 'L', owningPathSegList);\n this._x = x;\n this._y = y;\n }\n toString () { return '[object SVGPathSegLinetoAbs]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; }\n clone () { return new SVGPathSegLinetoAbs(undefined, this._x, this._y); }\n }\n Object.defineProperties(SVGPathSegLinetoAbs.prototype, {\n x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true},\n y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true}\n });\n\n class SVGPathSegLinetoRel extends SVGPathSeg {\n constructor (owningPathSegList, x, y) {\n super(SVGPathSeg.PATHSEG_LINETO_REL, 'l', owningPathSegList);\n this._x = x;\n this._y = y;\n }\n toString () { return '[object SVGPathSegLinetoRel]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; }\n clone () { return new SVGPathSegLinetoRel(undefined, this._x, this._y); }\n }\n Object.defineProperties(SVGPathSegLinetoRel.prototype, {\n x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true},\n y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true}\n });\n\n class SVGPathSegCurvetoCubicAbs extends SVGPathSeg {\n constructor (owningPathSegList, x, y, x1, y1, x2, y2) {\n super(SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS, 'C', owningPathSegList);\n this._x = x;\n this._y = y;\n this._x1 = x1;\n this._y1 = y1;\n this._x2 = x2;\n this._y2 = y2;\n }\n toString () { return '[object SVGPathSegCurvetoCubicAbs]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x1 + ' ' + this._y1 + ' ' + this._x2 + ' ' + this._y2 + ' ' + this._x + ' ' + this._y; }\n clone () { return new SVGPathSegCurvetoCubicAbs(undefined, this._x, this._y, this._x1, this._y1, this._x2, this._y2); }\n }\n Object.defineProperties(SVGPathSegCurvetoCubicAbs.prototype, {\n x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true},\n y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true},\n x1: {get () { return this._x1; }, set (x1) { this._x1 = x1; this._segmentChanged(); }, enumerable: true},\n y1: {get () { return this._y1; }, set (y1) { this._y1 = y1; this._segmentChanged(); }, enumerable: true},\n x2: {get () { return this._x2; }, set (x2) { this._x2 = x2; this._segmentChanged(); }, enumerable: true},\n y2: {get () { return this._y2; }, set (y2) { this._y2 = y2; this._segmentChanged(); }, enumerable: true}\n });\n\n class SVGPathSegCurvetoCubicRel extends SVGPathSeg {\n constructor (owningPathSegList, x, y, x1, y1, x2, y2) {\n super(SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL, 'c', owningPathSegList);\n this._x = x;\n this._y = y;\n this._x1 = x1;\n this._y1 = y1;\n this._x2 = x2;\n this._y2 = y2;\n }\n toString () { return '[object SVGPathSegCurvetoCubicRel]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x1 + ' ' + this._y1 + ' ' + this._x2 + ' ' + this._y2 + ' ' + this._x + ' ' + this._y; }\n clone () { return new SVGPathSegCurvetoCubicRel(undefined, this._x, this._y, this._x1, this._y1, this._x2, this._y2); }\n }\n Object.defineProperties(SVGPathSegCurvetoCubicRel.prototype, {\n x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true},\n y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true},\n x1: {get () { return this._x1; }, set (x1) { this._x1 = x1; this._segmentChanged(); }, enumerable: true},\n y1: {get () { return this._y1; }, set (y1) { this._y1 = y1; this._segmentChanged(); }, enumerable: true},\n x2: {get () { return this._x2; }, set (x2) { this._x2 = x2; this._segmentChanged(); }, enumerable: true},\n y2: {get () { return this._y2; }, set (y2) { this._y2 = y2; this._segmentChanged(); }, enumerable: true}\n });\n\n class SVGPathSegCurvetoQuadraticAbs extends SVGPathSeg {\n constructor (owningPathSegList, x, y, x1, y1) {\n super(SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS, 'Q', owningPathSegList);\n this._x = x;\n this._y = y;\n this._x1 = x1;\n this._y1 = y1;\n }\n toString () { return '[object SVGPathSegCurvetoQuadraticAbs]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x1 + ' ' + this._y1 + ' ' + this._x + ' ' + this._y; }\n clone () { return new SVGPathSegCurvetoQuadraticAbs(undefined, this._x, this._y, this._x1, this._y1); }\n }\n Object.defineProperties(SVGPathSegCurvetoQuadraticAbs.prototype, {\n x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true},\n y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true},\n x1: {get () { return this._x1; }, set (x1) { this._x1 = x1; this._segmentChanged(); }, enumerable: true},\n y1: {get () { return this._y1; }, set (y1) { this._y1 = y1; this._segmentChanged(); }, enumerable: true}\n });\n\n class SVGPathSegCurvetoQuadraticRel extends SVGPathSeg {\n constructor (owningPathSegList, x, y, x1, y1) {\n super(SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL, 'q', owningPathSegList);\n this._x = x;\n this._y = y;\n this._x1 = x1;\n this._y1 = y1;\n }\n toString () { return '[object SVGPathSegCurvetoQuadraticRel]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x1 + ' ' + this._y1 + ' ' + this._x + ' ' + this._y; }\n clone () { return new SVGPathSegCurvetoQuadraticRel(undefined, this._x, this._y, this._x1, this._y1); }\n }\n Object.defineProperties(SVGPathSegCurvetoQuadraticRel.prototype, {\n x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true},\n y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true},\n x1: {get () { return this._x1; }, set (x1) { this._x1 = x1; this._segmentChanged(); }, enumerable: true},\n y1: {get () { return this._y1; }, set (y1) { this._y1 = y1; this._segmentChanged(); }, enumerable: true}\n });\n\n class SVGPathSegArcAbs extends SVGPathSeg {\n constructor (owningPathSegList, x, y, r1, r2, angle, largeArcFlag, sweepFlag) {\n super(SVGPathSeg.PATHSEG_ARC_ABS, 'A', owningPathSegList);\n this._x = x;\n this._y = y;\n this._r1 = r1;\n this._r2 = r2;\n this._angle = angle;\n this._largeArcFlag = largeArcFlag;\n this._sweepFlag = sweepFlag;\n }\n toString () { return '[object SVGPathSegArcAbs]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._r1 + ' ' + this._r2 + ' ' + this._angle + ' ' + (this._largeArcFlag ? '1' : '0') + ' ' + (this._sweepFlag ? '1' : '0') + ' ' + this._x + ' ' + this._y; }\n clone () { return new SVGPathSegArcAbs(undefined, this._x, this._y, this._r1, this._r2, this._angle, this._largeArcFlag, this._sweepFlag); }\n }\n Object.defineProperties(SVGPathSegArcAbs.prototype, {\n x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true},\n y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true},\n r1: {get () { return this._r1; }, set (r1) { this._r1 = r1; this._segmentChanged(); }, enumerable: true},\n r2: {get () { return this._r2; }, set (r2) { this._r2 = r2; this._segmentChanged(); }, enumerable: true},\n angle: {get () { return this._angle; }, set (angle) { this._angle = angle; this._segmentChanged(); }, enumerable: true},\n largeArcFlag: {get () { return this._largeArcFlag; }, set (largeArcFlag) { this._largeArcFlag = largeArcFlag; this._segmentChanged(); }, enumerable: true},\n sweepFlag: {get () { return this._sweepFlag; }, set (sweepFlag) { this._sweepFlag = sweepFlag; this._segmentChanged(); }, enumerable: true}\n });\n\n class SVGPathSegArcRel extends SVGPathSeg {\n constructor (owningPathSegList, x, y, r1, r2, angle, largeArcFlag, sweepFlag) {\n super(SVGPathSeg.PATHSEG_ARC_REL, 'a', owningPathSegList);\n this._x = x;\n this._y = y;\n this._r1 = r1;\n this._r2 = r2;\n this._angle = angle;\n this._largeArcFlag = largeArcFlag;\n this._sweepFlag = sweepFlag;\n }\n toString () { return '[object SVGPathSegArcRel]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._r1 + ' ' + this._r2 + ' ' + this._angle + ' ' + (this._largeArcFlag ? '1' : '0') + ' ' + (this._sweepFlag ? '1' : '0') + ' ' + this._x + ' ' + this._y; }\n clone () { return new SVGPathSegArcRel(undefined, this._x, this._y, this._r1, this._r2, this._angle, this._largeArcFlag, this._sweepFlag); }\n }\n Object.defineProperties(SVGPathSegArcRel.prototype, {\n x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true},\n y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true},\n r1: {get () { return this._r1; }, set (r1) { this._r1 = r1; this._segmentChanged(); }, enumerable: true},\n r2: {get () { return this._r2; }, set (r2) { this._r2 = r2; this._segmentChanged(); }, enumerable: true},\n angle: {get () { return this._angle; }, set (angle) { this._angle = angle; this._segmentChanged(); }, enumerable: true},\n largeArcFlag: {get () { return this._largeArcFlag; }, set (largeArcFlag) { this._largeArcFlag = largeArcFlag; this._segmentChanged(); }, enumerable: true},\n sweepFlag: {get () { return this._sweepFlag; }, set (sweepFlag) { this._sweepFlag = sweepFlag; this._segmentChanged(); }, enumerable: true}\n });\n\n class SVGPathSegLinetoHorizontalAbs extends SVGPathSeg {\n constructor (owningPathSegList, x) {\n super(SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS, 'H', owningPathSegList);\n this._x = x;\n }\n toString () { return '[object SVGPathSegLinetoHorizontalAbs]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x; }\n clone () { return new SVGPathSegLinetoHorizontalAbs(undefined, this._x); }\n }\n Object.defineProperty(SVGPathSegLinetoHorizontalAbs.prototype, 'x', {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true});\n\n class SVGPathSegLinetoHorizontalRel extends SVGPathSeg {\n constructor (owningPathSegList, x) {\n super(SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL, 'h', owningPathSegList);\n this._x = x;\n }\n toString () { return '[object SVGPathSegLinetoHorizontalRel]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x; }\n clone () { return new SVGPathSegLinetoHorizontalRel(undefined, this._x); }\n }\n Object.defineProperty(SVGPathSegLinetoHorizontalRel.prototype, 'x', {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true});\n\n class SVGPathSegLinetoVerticalAbs extends SVGPathSeg {\n constructor (owningPathSegList, y) {\n super(SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS, 'V', owningPathSegList);\n this._y = y;\n }\n toString () { return '[object SVGPathSegLinetoVerticalAbs]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._y; }\n clone () { return new SVGPathSegLinetoVerticalAbs(undefined, this._y); }\n }\n Object.defineProperty(SVGPathSegLinetoVerticalAbs.prototype, 'y', {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true});\n\n class SVGPathSegLinetoVerticalRel extends SVGPathSeg {\n constructor (owningPathSegList, y) {\n super(SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL, 'v', owningPathSegList);\n this._y = y;\n }\n toString () { return '[object SVGPathSegLinetoVerticalRel]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._y; }\n clone () { return new SVGPathSegLinetoVerticalRel(undefined, this._y); }\n }\n Object.defineProperty(SVGPathSegLinetoVerticalRel.prototype, 'y', {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true});\n\n class SVGPathSegCurvetoCubicSmoothAbs extends SVGPathSeg {\n constructor (owningPathSegList, x, y, x2, y2) {\n super(SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS, 'S', owningPathSegList);\n this._x = x;\n this._y = y;\n this._x2 = x2;\n this._y2 = y2;\n }\n toString () { return '[object SVGPathSegCurvetoCubicSmoothAbs]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x2 + ' ' + this._y2 + ' ' + this._x + ' ' + this._y; }\n clone () { return new SVGPathSegCurvetoCubicSmoothAbs(undefined, this._x, this._y, this._x2, this._y2); }\n }\n Object.defineProperties(SVGPathSegCurvetoCubicSmoothAbs.prototype, {\n x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true},\n y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true},\n x2: {get () { return this._x2; }, set (x2) { this._x2 = x2; this._segmentChanged(); }, enumerable: true},\n y2: {get () { return this._y2; }, set (y2) { this._y2 = y2; this._segmentChanged(); }, enumerable: true}\n });\n\n class SVGPathSegCurvetoCubicSmoothRel extends SVGPathSeg {\n constructor (owningPathSegList, x, y, x2, y2) {\n super(SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL, 's', owningPathSegList);\n this._x = x;\n this._y = y;\n this._x2 = x2;\n this._y2 = y2;\n }\n toString () { return '[object SVGPathSegCurvetoCubicSmoothRel]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x2 + ' ' + this._y2 + ' ' + this._x + ' ' + this._y; }\n clone () { return new SVGPathSegCurvetoCubicSmoothRel(undefined, this._x, this._y, this._x2, this._y2); }\n }\n Object.defineProperties(SVGPathSegCurvetoCubicSmoothRel.prototype, {\n x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true},\n y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true},\n x2: {get () { return this._x2; }, set (x2) { this._x2 = x2; this._segmentChanged(); }, enumerable: true},\n y2: {get () { return this._y2; }, set (y2) { this._y2 = y2; this._segmentChanged(); }, enumerable: true}\n });\n\n class SVGPathSegCurvetoQuadraticSmoothAbs extends SVGPathSeg {\n constructor (owningPathSegList, x, y) {\n super(SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS, 'T', owningPathSegList);\n this._x = x;\n this._y = y;\n }\n toString () { return '[object SVGPathSegCurvetoQuadraticSmoothAbs]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; }\n clone () { return new SVGPathSegCurvetoQuadraticSmoothAbs(undefined, this._x, this._y); }\n }\n Object.defineProperties(SVGPathSegCurvetoQuadraticSmoothAbs.prototype, {\n x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true},\n y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true}\n });\n\n class SVGPathSegCurvetoQuadraticSmoothRel extends SVGPathSeg {\n constructor (owningPathSegList, x, y) {\n super(SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL, 't', owningPathSegList);\n this._x = x;\n this._y = y;\n }\n toString () { return '[object SVGPathSegCurvetoQuadraticSmoothRel]'; }\n _asPathString () { return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; }\n clone () { return new SVGPathSegCurvetoQuadraticSmoothRel(undefined, this._x, this._y); }\n }\n Object.defineProperties(SVGPathSegCurvetoQuadraticSmoothRel.prototype, {\n x: {get () { return this._x; }, set (x) { this._x = x; this._segmentChanged(); }, enumerable: true},\n y: {get () { return this._y; }, set (y) { this._y = y; this._segmentChanged(); }, enumerable: true}\n });\n\n // Add createSVGPathSeg* functions to SVGPathElement.\n // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathElement.\n SVGPathElement.prototype.createSVGPathSegClosePath = function () { return new SVGPathSegClosePath(undefined); };\n SVGPathElement.prototype.createSVGPathSegMovetoAbs = function (x, y) { return new SVGPathSegMovetoAbs(undefined, x, y); };\n SVGPathElement.prototype.createSVGPathSegMovetoRel = function (x, y) { return new SVGPathSegMovetoRel(undefined, x, y); };\n SVGPathElement.prototype.createSVGPathSegLinetoAbs = function (x, y) { return new SVGPathSegLinetoAbs(undefined, x, y); };\n SVGPathElement.prototype.createSVGPathSegLinetoRel = function (x, y) { return new SVGPathSegLinetoRel(undefined, x, y); };\n SVGPathElement.prototype.createSVGPathSegCurvetoCubicAbs = function (x, y, x1, y1, x2, y2) { return new SVGPathSegCurvetoCubicAbs(undefined, x, y, x1, y1, x2, y2); };\n SVGPathElement.prototype.createSVGPathSegCurvetoCubicRel = function (x, y, x1, y1, x2, y2) { return new SVGPathSegCurvetoCubicRel(undefined, x, y, x1, y1, x2, y2); };\n SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticAbs = function (x, y, x1, y1) { return new SVGPathSegCurvetoQuadraticAbs(undefined, x, y, x1, y1); };\n SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticRel = function (x, y, x1, y1) { return new SVGPathSegCurvetoQuadraticRel(undefined, x, y, x1, y1); };\n SVGPathElement.prototype.createSVGPathSegArcAbs = function (x, y, r1, r2, angle, largeArcFlag, sweepFlag) { return new SVGPathSegArcAbs(undefined, x, y, r1, r2, angle, largeArcFlag, sweepFlag); };\n SVGPathElement.prototype.createSVGPathSegArcRel = function (x, y, r1, r2, angle, largeArcFlag, sweepFlag) { return new SVGPathSegArcRel(undefined, x, y, r1, r2, angle, largeArcFlag, sweepFlag); };\n SVGPathElement.prototype.createSVGPathSegLinetoHorizontalAbs = function (x) { return new SVGPathSegLinetoHorizontalAbs(undefined, x); };\n SVGPathElement.prototype.createSVGPathSegLinetoHorizontalRel = function (x) { return new SVGPathSegLinetoHorizontalRel(undefined, x); };\n SVGPathElement.prototype.createSVGPathSegLinetoVerticalAbs = function (y) { return new SVGPathSegLinetoVerticalAbs(undefined, y); };\n SVGPathElement.prototype.createSVGPathSegLinetoVerticalRel = function (y) { return new SVGPathSegLinetoVerticalRel(undefined, y); };\n SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothAbs = function (x, y, x2, y2) { return new SVGPathSegCurvetoCubicSmoothAbs(undefined, x, y, x2, y2); };\n SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothRel = function (x, y, x2, y2) { return new SVGPathSegCurvetoCubicSmoothRel(undefined, x, y, x2, y2); };\n SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothAbs = function (x, y) { return new SVGPathSegCurvetoQuadraticSmoothAbs(undefined, x, y); };\n SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothRel = function (x, y) { return new SVGPathSegCurvetoQuadraticSmoothRel(undefined, x, y); };\n\n if (!('getPathSegAtLength' in SVGPathElement.prototype)) {\n // Add getPathSegAtLength to SVGPathElement.\n // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-__svg__SVGPathElement__getPathSegAtLength\n // This polyfill requires SVGPathElement.getTotalLength to implement the distance-along-a-path algorithm.\n SVGPathElement.prototype.getPathSegAtLength = function (distance) {\n if (distance === undefined || !isFinite(distance)) {\n throw new Error('Invalid arguments.');\n }\n\n const measurementElement = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n measurementElement.setAttribute('d', this.getAttribute('d'));\n let lastPathSegment = measurementElement.pathSegList.numberOfItems - 1;\n\n // If the path is empty, return 0.\n if (lastPathSegment <= 0) {\n return 0;\n }\n\n do {\n measurementElement.pathSegList.removeItem(lastPathSegment);\n if (distance > measurementElement.getTotalLength()) {\n break;\n }\n lastPathSegment--;\n } while (lastPathSegment > 0);\n return lastPathSegment;\n };\n }\n\n window.SVGPathSeg = SVGPathSeg;\n window.SVGPathSegClosePath = SVGPathSegClosePath;\n window.SVGPathSegMovetoAbs = SVGPathSegMovetoAbs;\n window.SVGPathSegMovetoRel = SVGPathSegMovetoRel;\n window.SVGPathSegLinetoAbs = SVGPathSegLinetoAbs;\n window.SVGPathSegLinetoRel = SVGPathSegLinetoRel;\n window.SVGPathSegCurvetoCubicAbs = SVGPathSegCurvetoCubicAbs;\n window.SVGPathSegCurvetoCubicRel = SVGPathSegCurvetoCubicRel;\n window.SVGPathSegCurvetoQuadraticAbs = SVGPathSegCurvetoQuadraticAbs;\n window.SVGPathSegCurvetoQuadraticRel = SVGPathSegCurvetoQuadraticRel;\n window.SVGPathSegArcAbs = SVGPathSegArcAbs;\n window.SVGPathSegArcRel = SVGPathSegArcRel;\n window.SVGPathSegLinetoHorizontalAbs = SVGPathSegLinetoHorizontalAbs;\n window.SVGPathSegLinetoHorizontalRel = SVGPathSegLinetoHorizontalRel;\n window.SVGPathSegLinetoVerticalAbs = SVGPathSegLinetoVerticalAbs;\n window.SVGPathSegLinetoVerticalRel = SVGPathSegLinetoVerticalRel;\n window.SVGPathSegCurvetoCubicSmoothAbs = SVGPathSegCurvetoCubicSmoothAbs;\n window.SVGPathSegCurvetoCubicSmoothRel = SVGPathSegCurvetoCubicSmoothRel;\n window.SVGPathSegCurvetoQuadraticSmoothAbs = SVGPathSegCurvetoQuadraticSmoothAbs;\n window.SVGPathSegCurvetoQuadraticSmoothRel = SVGPathSegCurvetoQuadraticSmoothRel;\n}\n\n// Checking for SVGPathSegList in window checks for the case of an implementation without the\n// SVGPathSegList API.\n// The second check for appendItem is specific to Firefox 59+ which removed only parts of the\n// SVGPathSegList API (e.g., appendItem). In this case we need to re-implement the entire API\n// so the polyfill data (i.e., _list) is used throughout.\nif (!('SVGPathSegList' in window) || !('appendItem' in window.SVGPathSegList.prototype)) {\n // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathSegList\n class SVGPathSegList {\n constructor (pathElement) {\n this._pathElement = pathElement;\n this._list = this._parsePath(this._pathElement.getAttribute('d'));\n\n // Use a MutationObserver to catch changes to the path's \"d\" attribute.\n this._mutationObserverConfig = {attributes: true, attributeFilter: ['d']};\n this._pathElementMutationObserver = new MutationObserver(this._updateListFromPathMutations.bind(this));\n this._pathElementMutationObserver.observe(this._pathElement, this._mutationObserverConfig);\n }\n // Process any pending mutations to the path element and update the list as needed.\n // This should be the first call of all public functions and is needed because\n // MutationObservers are not synchronous so we can have pending asynchronous mutations.\n _checkPathSynchronizedToList () {\n this._updateListFromPathMutations(this._pathElementMutationObserver.takeRecords());\n }\n\n _updateListFromPathMutations (mutationRecords) {\n if (!this._pathElement) {\n return;\n }\n let hasPathMutations = false;\n mutationRecords.forEach((record) => {\n if (record.attributeName === 'd') {\n hasPathMutations = true;\n }\n });\n if (hasPathMutations) {\n this._list = this._parsePath(this._pathElement.getAttribute('d'));\n }\n }\n\n // Serialize the list and update the path's 'd' attribute.\n _writeListToPath () {\n this._pathElementMutationObserver.disconnect();\n this._pathElement.setAttribute('d', SVGPathSegList._pathSegArrayAsString(this._list));\n this._pathElementMutationObserver.observe(this._pathElement, this._mutationObserverConfig);\n }\n\n // When a path segment changes the list needs to be synchronized back to the path element.\n segmentChanged (pathSeg) {\n this._writeListToPath();\n }\n\n clear () {\n this._checkPathSynchronizedToList();\n\n this._list.forEach((pathSeg) => {\n pathSeg._owningPathSegList = null;\n });\n this._list = [];\n this._writeListToPath();\n }\n\n initialize (newItem) {\n this._checkPathSynchronizedToList();\n\n this._list = [newItem];\n newItem._owningPathSegList = this;\n this._writeListToPath();\n return newItem;\n }\n\n _checkValidIndex (index) {\n if (isNaN(index) || index < 0 || index >= this.numberOfItems) {\n throw new Error('INDEX_SIZE_ERR');\n }\n }\n\n getItem (index) {\n this._checkPathSynchronizedToList();\n\n this._checkValidIndex(index);\n return this._list[index];\n }\n\n insertItemBefore (newItem, index) {\n this._checkPathSynchronizedToList();\n\n // Spec: If the index is greater than or equal to numberOfItems, then the new item is appended to the end of the list.\n if (index > this.numberOfItems) {\n index = this.numberOfItems;\n }\n if (newItem._owningPathSegList) {\n // SVG2 spec says to make a copy.\n newItem = newItem.clone();\n }\n this._list.splice(index, 0, newItem);\n newItem._owningPathSegList = this;\n this._writeListToPath();\n return newItem;\n }\n\n replaceItem (newItem, index) {\n this._checkPathSynchronizedToList();\n\n if (newItem._owningPathSegList) {\n // SVG2 spec says to make a copy.\n newItem = newItem.clone();\n }\n this._checkValidIndex(index);\n this._list[index] = newItem;\n newItem._owningPathSegList = this;\n this._writeListToPath();\n return newItem;\n }\n\n removeItem (index) {\n this._checkPathSynchronizedToList();\n\n this._checkValidIndex(index);\n const item = this._list[index];\n this._list.splice(index, 1);\n this._writeListToPath();\n return item;\n }\n\n appendItem (newItem) {\n this._checkPathSynchronizedToList();\n\n if (newItem._owningPathSegList) {\n // SVG2 spec says to make a copy.\n newItem = newItem.clone();\n }\n this._list.push(newItem);\n newItem._owningPathSegList = this;\n // TODO: Optimize this to just append to the existing attribute.\n this._writeListToPath();\n return newItem;\n }\n\n // This closely follows SVGPathParser::parsePath from Source/core/svg/SVGPathParser.cpp.\n _parsePath (string) {\n if (!string || !string.length) {\n return [];\n }\n\n const owningPathSegList = this;\n\n class Builder {\n constructor () {\n this.pathSegList = [];\n }\n appendSegment (pathSeg) {\n this.pathSegList.push(pathSeg);\n }\n }\n\n class Source {\n constructor (string) {\n this._string = string;\n this._currentIndex = 0;\n this._endIndex = this._string.length;\n this._previousCommand = SVGPathSeg.PATHSEG_UNKNOWN;\n\n this._skipOptionalSpaces();\n }\n _isCurrentSpace () {\n const character = this._string[this._currentIndex];\n return character <= ' ' && (character === ' ' || character === '\\n' || character === '\\t' || character === '\\r' || character === '\\f');\n }\n\n _skipOptionalSpaces () {\n while (this._currentIndex < this._endIndex && this._isCurrentSpace()) {\n this._currentIndex++;\n }\n return this._currentIndex < this._endIndex;\n }\n\n _skipOptionalSpacesOrDelimiter () {\n if (this._currentIndex < this._endIndex && !this._isCurrentSpace() && this._string.charAt(this._currentIndex) !== ',') {\n return false;\n }\n if (this._skipOptionalSpaces()) {\n if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) === ',') {\n this._currentIndex++;\n this._skipOptionalSpaces();\n }\n }\n return this._currentIndex < this._endIndex;\n }\n\n hasMoreData () {\n return this._currentIndex < this._endIndex;\n }\n\n peekSegmentType () {\n const lookahead = this._string[this._currentIndex];\n return this._pathSegTypeFromChar(lookahead);\n }\n\n _pathSegTypeFromChar (lookahead) {\n switch (lookahead) {\n case 'Z':\n case 'z':\n return SVGPathSeg.PATHSEG_CLOSEPATH;\n case 'M':\n return SVGPathSeg.PATHSEG_MOVETO_ABS;\n case 'm':\n return SVGPathSeg.PATHSEG_MOVETO_REL;\n case 'L':\n return SVGPathSeg.PATHSEG_LINETO_ABS;\n case 'l':\n return SVGPathSeg.PATHSEG_LINETO_REL;\n case 'C':\n return SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS;\n case 'c':\n return SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL;\n case 'Q':\n return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS;\n case 'q':\n return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL;\n case 'A':\n return SVGPathSeg.PATHSEG_ARC_ABS;\n case 'a':\n return SVGPathSeg.PATHSEG_ARC_REL;\n case 'H':\n return SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS;\n case 'h':\n return SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL;\n case 'V':\n return SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS;\n case 'v':\n return SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL;\n case 'S':\n return SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS;\n case 's':\n return SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL;\n case 'T':\n return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS;\n case 't':\n return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL;\n default:\n return SVGPathSeg.PATHSEG_UNKNOWN;\n }\n }\n\n _nextCommandHelper (lookahead, previousCommand) {\n // Check for remaining coordinates in the current command.\n if ((lookahead === '+' || lookahead === '-' || lookahead === '.' || (lookahead >= '0' && lookahead <= '9')) && previousCommand !== SVGPathSeg.PATHSEG_CLOSEPATH) {\n if (previousCommand === SVGPathSeg.PATHSEG_MOVETO_ABS) {\n return SVGPathSeg.PATHSEG_LINETO_ABS;\n }\n if (previousCommand === SVGPathSeg.PATHSEG_MOVETO_REL) {\n return SVGPathSeg.PATHSEG_LINETO_REL;\n }\n return previousCommand;\n }\n return SVGPathSeg.PATHSEG_UNKNOWN;\n }\n\n initialCommandIsMoveTo () {\n // If the path is empty it is still valid, so return true.\n if (!this.hasMoreData()) {\n return true;\n }\n const command = this.peekSegmentType();\n // Path must start with moveTo.\n return command === SVGPathSeg.PATHSEG_MOVETO_ABS || command === SVGPathSeg.PATHSEG_MOVETO_REL;\n }\n\n // Parse a number from an SVG path. This very closely follows genericParseNumber(...) from Source/core/svg/SVGParserUtilities.cpp.\n // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-PathDataBNF\n _parseNumber () {\n let exponent = 0;\n let integer = 0;\n let frac = 1;\n let decimal = 0;\n let sign = 1;\n let expsign = 1;\n\n const startIndex = this._currentIndex;\n\n this._skipOptionalSpaces();\n\n // Read the sign.\n if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) === '+') {\n this._currentIndex++;\n } else if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) === '-') {\n this._currentIndex++;\n sign = -1;\n }\n\n if (this._currentIndex === this._endIndex || ((this._string.charAt(this._currentIndex) < '0' || this._string.charAt(this._currentIndex) > '9') && this._string.charAt(this._currentIndex) !== '.')) {\n // The first character of a number must be one of [0-9+-.].\n return undefined;\n }\n\n // Read the integer part, build right-to-left.\n const startIntPartIndex = this._currentIndex;\n while (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) >= '0' && this._string.charAt(this._currentIndex) <= '9') {\n this._currentIndex++; // Advance to first non-digit.\n }\n\n if (this._currentIndex !== startIntPartIndex) {\n let scanIntPartIndex = this._currentIndex - 1;\n let multiplier = 1;\n while (scanIntPartIndex >= startIntPartIndex) {\n integer += multiplier * (this._string.charAt(scanIntPartIndex--) - '0');\n multiplier *= 10;\n }\n }\n\n // Read the decimals.\n if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) === '.') {\n this._currentIndex++;\n\n // There must be a least one digit following the .\n if (this._currentIndex >= this._endIndex || this._string.charAt(this._currentIndex) < '0' || this._string.charAt(this._currentIndex) > '9') {\n return undefined;\n }\n while (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) >= '0' && this._string.charAt(this._currentIndex) <= '9') {\n frac *= 10;\n decimal += (this._string.charAt(this._currentIndex) - '0') / frac;\n this._currentIndex += 1;\n }\n }\n\n // Read the exponent part.\n if (this._currentIndex !== startIndex && this._currentIndex + 1 < this._endIndex && (this._string.charAt(this._currentIndex) === 'e' || this._string.charAt(this._currentIndex) === 'E') && (this._string.charAt(this._currentIndex + 1) !== 'x' && this._string.charAt(this._currentIndex + 1) !== 'm')) {\n this._currentIndex++;\n\n // Read the sign of the exponent.\n if (this._string.charAt(this._currentIndex) === '+') {\n this._currentIndex++;\n } else if (this._string.charAt(this._currentIndex) === '-') {\n this._currentIndex++;\n expsign = -1;\n }\n\n // There must be an exponent.\n if (this._currentIndex >= this._endIndex || this._string.charAt(this._currentIndex) < '0' || this._string.charAt(this._currentIndex) > '9') {\n return undefined;\n }\n\n while (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) >= '0' && this._string.charAt(this._currentIndex) <= '9') {\n exponent *= 10;\n exponent += (this._string.charAt(this._currentIndex) - '0');\n this._currentIndex++;\n }\n }\n\n let number = integer + decimal;\n number *= sign;\n\n if (exponent) {\n number *= 10 ** (expsign * exponent);\n }\n\n if (startIndex === this._currentIndex) {\n return undefined;\n }\n\n this._skipOptionalSpacesOrDelimiter();\n\n return number;\n }\n\n _parseArcFlag () {\n if (this._currentIndex >= this._endIndex) {\n return undefined;\n }\n let flag = false;\n const flagChar = this._string.charAt(this._currentIndex++);\n if (flagChar === '0') {\n flag = false;\n } else if (flagChar === '1') {\n flag = true;\n } else {\n return undefined;\n }\n\n this._skipOptionalSpacesOrDelimiter();\n return flag;\n }\n\n parseSegment () {\n const lookahead = this._string[this._currentIndex];\n let command = this._pathSegTypeFromChar(lookahead);\n if (command === SVGPathSeg.PATHSEG_UNKNOWN) {\n // Possibly an implicit command. Not allowed if this is the first command.\n if (this._previousCommand === SVGPathSeg.PATHSEG_UNKNOWN) {\n return null;\n }\n command = this._nextCommandHelper(lookahead, this._previousCommand);\n if (command === SVGPathSeg.PATHSEG_UNKNOWN) {\n return null;\n }\n } else {\n this._currentIndex++;\n }\n\n this._previousCommand = command;\n\n switch (command) {\n case SVGPathSeg.PATHSEG_MOVETO_REL:\n return new SVGPathSegMovetoRel(owningPathSegList, this._parseNumber(), this._parseNumber());\n case SVGPathSeg.PATHSEG_MOVETO_ABS:\n return new SVGPathSegMovetoAbs(owningPathSegList, this._parseNumber(), this._parseNumber());\n case SVGPathSeg.PATHSEG_LINETO_REL:\n return new SVGPathSegLinetoRel(owningPathSegList, this._parseNumber(), this._parseNumber());\n case SVGPathSeg.PATHSEG_LINETO_ABS:\n return new SVGPathSegLinetoAbs(owningPathSegList, this._parseNumber(), this._parseNumber());\n case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL:\n return new SVGPathSegLinetoHorizontalRel(owningPathSegList, this._parseNumber());\n case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS:\n return new SVGPathSegLinetoHorizontalAbs(owningPathSegList, this._parseNumber());\n case SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL:\n return new SVGPathSegLinetoVerticalRel(owningPathSegList, this._parseNumber());\n case SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS:\n return new SVGPathSegLinetoVerticalAbs(owningPathSegList, this._parseNumber());\n case SVGPathSeg.PATHSEG_CLOSEPATH:\n this._skipOptionalSpaces();\n return new SVGPathSegClosePath(owningPathSegList);\n case SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL: {\n const points = {x1: this._parseNumber(), y1: this._parseNumber(), x2: this._parseNumber(), y2: this._parseNumber(), x: this._parseNumber(), y: this._parseNumber()};\n return new SVGPathSegCurvetoCubicRel(owningPathSegList, points.x, points.y, points.x1, points.y1, points.x2, points.y2);\n } case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS: {\n const points = {x1: this._parseNumber(), y1: this._parseNumber(), x2: this._parseNumber(), y2: this._parseNumber(), x: this._parseNumber(), y: this._parseNumber()};\n return new SVGPathSegCurvetoCubicAbs(owningPathSegList, points.x, points.y, points.x1, points.y1, points.x2, points.y2);\n } case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL: {\n const points = {x2: this._parseNumber(), y2: this._parseNumber(), x: this._parseNumber(), y: this._parseNumber()};\n return new SVGPathSegCurvetoCubicSmoothRel(owningPathSegList, points.x, points.y, points.x2, points.y2);\n } case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: {\n const points = {x2: this._parseNumber(), y2: this._parseNumber(), x: this._parseNumber(), y: this._parseNumber()};\n return new SVGPathSegCurvetoCubicSmoothAbs(owningPathSegList, points.x, points.y, points.x2, points.y2);\n } case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL: {\n const points = {x1: this._parseNumber(), y1: this._parseNumber(), x: this._parseNumber(), y: this._parseNumber()};\n return new SVGPathSegCurvetoQuadraticRel(owningPathSegList, points.x, points.y, points.x1, points.y1);\n } case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS: {\n const points = {x1: this._parseNumber(), y1: this._parseNumber(), x: this._parseNumber(), y: this._parseNumber()};\n return new SVGPathSegCurvetoQuadraticAbs(owningPathSegList, points.x, points.y, points.x1, points.y1);\n } case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:\n return new SVGPathSegCurvetoQuadraticSmoothRel(owningPathSegList, this._parseNumber(), this._parseNumber());\n case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:\n return new SVGPathSegCurvetoQuadraticSmoothAbs(owningPathSegList, this._parseNumber(), this._parseNumber());\n case SVGPathSeg.PATHSEG_ARC_REL: {\n const points = {x1: this._parseNumber(), y1: this._parseNumber(), arcAngle: this._parseNumber(), arcLarge: this._parseArcFlag(), arcSweep: this._parseArcFlag(), x: this._parseNumber(), y: this._parseNumber()};\n return new SVGPathSegArcRel(owningPathSegList, points.x, points.y, points.x1, points.y1, points.arcAngle, points.arcLarge, points.arcSweep);\n } case SVGPathSeg.PATHSEG_ARC_ABS: {\n const points = {x1: this._parseNumber(), y1: this._parseNumber(), arcAngle: this._parseNumber(), arcLarge: this._parseArcFlag(), arcSweep: this._parseArcFlag(), x: this._parseNumber(), y: this._parseNumber()};\n return new SVGPathSegArcAbs(owningPathSegList, points.x, points.y, points.x1, points.y1, points.arcAngle, points.arcLarge, points.arcSweep);\n } default:\n throw new Error('Unknown path seg type.');\n }\n }\n }\n\n const builder = new Builder();\n const source = new Source(string);\n\n if (!source.initialCommandIsMoveTo()) {\n return [];\n }\n while (source.hasMoreData()) {\n const pathSeg = source.parseSegment();\n if (!pathSeg) {\n return [];\n }\n builder.appendSegment(pathSeg);\n }\n\n return builder.pathSegList;\n }\n\n // STATIC\n static _pathSegArrayAsString (pathSegArray) {\n let string = '';\n let first = true;\n pathSegArray.forEach((pathSeg) => {\n if (first) {\n first = false;\n string += pathSeg._asPathString();\n } else {\n string += ' ' + pathSeg._asPathString();\n }\n });\n return string;\n }\n }\n\n SVGPathSegList.prototype.classname = 'SVGPathSegList';\n\n Object.defineProperty(SVGPathSegList.prototype, 'numberOfItems', {\n get () {\n this._checkPathSynchronizedToList();\n return this._list.length;\n },\n enumerable: true\n });\n\n // Add the pathSegList accessors to SVGPathElement.\n // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGAnimatedPathData\n Object.defineProperties(SVGPathElement.prototype, {\n pathSegList: {\n get () {\n if (!this._pathSegList) {\n this._pathSegList = new SVGPathSegList(this);\n }\n return this._pathSegList;\n },\n enumerable: true\n },\n // TODO: The following are not implemented and simply return SVGPathElement.pathSegList.\n normalizedPathSegList: {get () { return this.pathSegList; }, enumerable: true},\n animatedPathSegList: {get () { return this.pathSegList; }, enumerable: true},\n animatedNormalizedPathSegList: {get () { return this.pathSegList; }, enumerable: true}\n });\n window.SVGPathSegList = SVGPathSegList;\n}\n})();\n","/**\n * @file ext-closepath.js\n *\n * @license MIT\n *\n * @copyright 2010 Jeff Schiller\n *\n */\nimport '../../common/svgpathseg.js';\n\n// This extension adds a simple button to the contextual panel for paths\n// The button toggles whether the path is open or closed\nexport default {\n name: 'closepath',\n async init ({importLocale, $}) {\n const strings = await importLocale();\n const svgEditor = this;\n let selElems;\n const updateButton = function (path) {\n const seglist = path.pathSegList,\n closed = seglist.getItem(seglist.numberOfItems - 1).pathSegType === 1,\n showbutton = closed ? '#tool_openpath' : '#tool_closepath',\n hidebutton = closed ? '#tool_closepath' : '#tool_openpath';\n $(hidebutton).hide();\n $(showbutton).show();\n };\n const showPanel = function (on) {\n $('#closepath_panel').toggle(on);\n if (on) {\n const path = selElems[0];\n if (path) { updateButton(path); }\n }\n };\n const toggleClosed = function () {\n const path = selElems[0];\n if (path) {\n const seglist = path.pathSegList,\n last = seglist.numberOfItems - 1;\n // is closed\n if (seglist.getItem(last).pathSegType === 1) {\n seglist.removeItem(last);\n } else {\n seglist.appendItem(path.createSVGPathSegClosePath());\n }\n updateButton(path);\n }\n };\n\n const buttons = [\n {\n id: 'tool_openpath',\n icon: svgEditor.curConfig.extIconsPath + 'openpath.png',\n type: 'context',\n panel: 'closepath_panel',\n events: {\n click () {\n toggleClosed();\n }\n }\n },\n {\n id: 'tool_closepath',\n icon: svgEditor.curConfig.extIconsPath + 'closepath.png',\n type: 'context',\n panel: 'closepath_panel',\n events: {\n click () {\n toggleClosed();\n }\n }\n }\n ];\n\n return {\n name: strings.name,\n svgicons: svgEditor.curConfig.extIconsPath + 'closepath_icons.svg',\n buttons: strings.buttons.map((button, i) => {\n return Object.assign(buttons[i], button);\n }),\n callback () {\n $('#closepath_panel').hide();\n },\n selectedChanged (opts) {\n selElems = opts.elems;\n let i = selElems.length;\n while (i--) {\n const elem = selElems[i];\n if (elem && elem.tagName === 'path') {\n if (opts.selectedElement && !opts.multiselected) {\n showPanel(true);\n } else {\n showPanel(false);\n }\n } else {\n showPanel(false);\n }\n }\n }\n };\n }\n};\n"],"names":["window","SVGPathSeg","type","typeAsLetter","owningPathSegList","pathSegType","pathSegTypeAsLetter","_owningPathSegList","segmentChanged","prototype","classname","PATHSEG_UNKNOWN","PATHSEG_CLOSEPATH","PATHSEG_MOVETO_ABS","PATHSEG_MOVETO_REL","PATHSEG_LINETO_ABS","PATHSEG_LINETO_REL","PATHSEG_CURVETO_CUBIC_ABS","PATHSEG_CURVETO_CUBIC_REL","PATHSEG_CURVETO_QUADRATIC_ABS","PATHSEG_CURVETO_QUADRATIC_REL","PATHSEG_ARC_ABS","PATHSEG_ARC_REL","PATHSEG_LINETO_HORIZONTAL_ABS","PATHSEG_LINETO_HORIZONTAL_REL","PATHSEG_LINETO_VERTICAL_ABS","PATHSEG_LINETO_VERTICAL_REL","PATHSEG_CURVETO_CUBIC_SMOOTH_ABS","PATHSEG_CURVETO_CUBIC_SMOOTH_REL","PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS","PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL","SVGPathSegClosePath","undefined","SVGPathSegMovetoAbs","x","y","_x","_y","Object","defineProperties","get","set","_segmentChanged","enumerable","SVGPathSegMovetoRel","SVGPathSegLinetoAbs","SVGPathSegLinetoRel","SVGPathSegCurvetoCubicAbs","x1","y1","x2","y2","_x1","_y1","_x2","_y2","SVGPathSegCurvetoCubicRel","SVGPathSegCurvetoQuadraticAbs","SVGPathSegCurvetoQuadraticRel","SVGPathSegArcAbs","r1","r2","angle","largeArcFlag","sweepFlag","_r1","_r2","_angle","_largeArcFlag","_sweepFlag","SVGPathSegArcRel","SVGPathSegLinetoHorizontalAbs","defineProperty","SVGPathSegLinetoHorizontalRel","SVGPathSegLinetoVerticalAbs","SVGPathSegLinetoVerticalRel","SVGPathSegCurvetoCubicSmoothAbs","SVGPathSegCurvetoCubicSmoothRel","SVGPathSegCurvetoQuadraticSmoothAbs","SVGPathSegCurvetoQuadraticSmoothRel","SVGPathElement","createSVGPathSegClosePath","createSVGPathSegMovetoAbs","createSVGPathSegMovetoRel","createSVGPathSegLinetoAbs","createSVGPathSegLinetoRel","createSVGPathSegCurvetoCubicAbs","createSVGPathSegCurvetoCubicRel","createSVGPathSegCurvetoQuadraticAbs","createSVGPathSegCurvetoQuadraticRel","createSVGPathSegArcAbs","createSVGPathSegArcRel","createSVGPathSegLinetoHorizontalAbs","createSVGPathSegLinetoHorizontalRel","createSVGPathSegLinetoVerticalAbs","createSVGPathSegLinetoVerticalRel","createSVGPathSegCurvetoCubicSmoothAbs","createSVGPathSegCurvetoCubicSmoothRel","createSVGPathSegCurvetoQuadraticSmoothAbs","createSVGPathSegCurvetoQuadraticSmoothRel","getPathSegAtLength","distance","isFinite","Error","measurementElement","document","createElementNS","setAttribute","getAttribute","lastPathSegment","pathSegList","numberOfItems","removeItem","getTotalLength","SVGPathSegList","pathElement","_pathElement","_list","_parsePath","_mutationObserverConfig","attributes","attributeFilter","_pathElementMutationObserver","MutationObserver","_updateListFromPathMutations","bind","observe","takeRecords","mutationRecords","hasPathMutations","forEach","record","attributeName","disconnect","_pathSegArrayAsString","pathSeg","_writeListToPath","_checkPathSynchronizedToList","newItem","index","isNaN","_checkValidIndex","clone","splice","item","push","string","length","Builder","Source","_string","_currentIndex","_endIndex","_previousCommand","_skipOptionalSpaces","character","_isCurrentSpace","charAt","lookahead","_pathSegTypeFromChar","previousCommand","hasMoreData","command","peekSegmentType","exponent","integer","frac","decimal","sign","expsign","startIndex","startIntPartIndex","scanIntPartIndex","multiplier","number","_skipOptionalSpacesOrDelimiter","flag","flagChar","_nextCommandHelper","_parseNumber","points","arcAngle","arcLarge","_parseArcFlag","arcSweep","builder","source","initialCommandIsMoveTo","parseSegment","appendSegment","pathSegArray","first","_asPathString","_pathSegList","normalizedPathSegList","animatedPathSegList","animatedNormalizedPathSegList","name","init","importLocale","$","strings","svgEditor","updateButton","path","seglist","closed","getItem","showbutton","hidebutton","hide","show","showPanel","on","toggle","selElems","toggleClosed","last","appendItem","buttons","id","icon","curConfig","extIconsPath","panel","events","click","svgicons","map","button","i","assign","callback","selectedChanged","opts","elems","elem","tagName","selectedElement","multiselected"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AALV,eAZc,CAlCa;AAAA,+CA2DtB;AACLnB,gBAAAA,IAAI,EAAEI,OAAO,CAACJ,IADT;AAEL8B,gBAAAA,QAAQ,EAAEzB,SAAS,CAACoB,SAAV,CAAoBC,YAApB,GAAmC,qBAFxC;AAGLJ,gBAAAA,OAAO,EAAElB,OAAO,CAACkB,OAAR,CAAgBS,GAAhB,CAAoB,UAACC,MAAD,EAASC,CAAT,EAAe;AAC1C,yBAAOhM,MAAM,CAACiM,MAAP,CAAcZ,OAAO,CAACW,CAAD,CAArB,EAA0BD,MAA1B,CAAP;AACD,iBAFQ,CAHJ;AAMLG,gBAAAA,QANK,sBAMO;AACVhC,kBAAAA,CAAC,CAAC,kBAAD,CAAD,CAAsBU,IAAtB;AACD,iBARI;AASLuB,gBAAAA,eATK,2BASYC,IATZ,EASkB;AACrBnB,kBAAAA,QAAQ,GAAGmB,IAAI,CAACC,KAAhB;AACA,sBAAIL,CAAC,GAAGf,QAAQ,CAACpE,MAAjB;;AACA,yBAAOmF,CAAC,EAAR,EAAY;AACV,wBAAMM,IAAI,GAAGrB,QAAQ,CAACe,CAAD,CAArB;;AACA,wBAAIM,IAAI,IAAIA,IAAI,CAACC,OAAL,KAAiB,MAA7B,EAAqC;AACnC,0BAAIH,IAAI,CAACI,eAAL,IAAwB,CAACJ,IAAI,CAACK,aAAlC,EAAiD;AAC/C3B,wBAAAA,SAAS,CAAC,IAAD,CAAT;AACD,uBAFD,MAEO;AACLA,wBAAAA,SAAS,CAAC,KAAD,CAAT;AACD;AACF,qBAND,MAMO;AACLA,sBAAAA,SAAS,CAAC,KAAD,CAAT;AACD;AACF;AACF;AAxBI,eA3DsB;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqF9B;AAvFY,CAAf;;;;"} \ No newline at end of file diff --git a/dist/editor/extensions/ext-connector.js b/dist/editor/extensions/ext-connector.js new file mode 100644 index 00000000..d43dbd98 --- /dev/null +++ b/dist/editor/extensions/ext-connector.js @@ -0,0 +1,2300 @@ +function _typeof(obj) { + "@babel/helpers - typeof"; + + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function (obj) { + return typeof obj; + }; + } else { + _typeof = function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); +} + +var REACT_ELEMENT_TYPE; + +function _jsx(type, props, key, children) { + if (!REACT_ELEMENT_TYPE) { + REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol["for"] && Symbol["for"]("react.element") || 0xeac7; + } + + var defaultProps = type && type.defaultProps; + var childrenLength = arguments.length - 3; + + if (!props && childrenLength !== 0) { + props = { + children: void 0 + }; + } + + if (childrenLength === 1) { + props.children = children; + } else if (childrenLength > 1) { + var childArray = new Array(childrenLength); + + for (var i = 0; i < childrenLength; i++) { + childArray[i] = arguments[i + 3]; + } + + props.children = childArray; + } + + if (props && defaultProps) { + for (var propName in defaultProps) { + if (props[propName] === void 0) { + props[propName] = defaultProps[propName]; + } + } + } else if (!props) { + props = defaultProps || {}; + } + + return { + $$typeof: REACT_ELEMENT_TYPE, + type: type, + key: key === undefined ? null : '' + key, + ref: null, + props: props, + _owner: null + }; +} + +function _asyncIterator(iterable) { + var method; + + if (typeof Symbol !== "undefined") { + if (Symbol.asyncIterator) { + method = iterable[Symbol.asyncIterator]; + if (method != null) return method.call(iterable); + } + + if (Symbol.iterator) { + method = iterable[Symbol.iterator]; + if (method != null) return method.call(iterable); + } + } + + throw new TypeError("Object is not async iterable"); +} + +function _AwaitValue(value) { + this.wrapped = value; +} + +function _AsyncGenerator(gen) { + var front, back; + + function send(key, arg) { + return new Promise(function (resolve, reject) { + var request = { + key: key, + arg: arg, + resolve: resolve, + reject: reject, + next: null + }; + + if (back) { + back = back.next = request; + } else { + front = back = request; + resume(key, arg); + } + }); + } + + function resume(key, arg) { + try { + var result = gen[key](arg); + var value = result.value; + var wrappedAwait = value instanceof _AwaitValue; + Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { + if (wrappedAwait) { + resume(key === "return" ? "return" : "next", arg); + return; + } + + settle(result.done ? "return" : "normal", arg); + }, function (err) { + resume("throw", err); + }); + } catch (err) { + settle("throw", err); + } + } + + function settle(type, value) { + switch (type) { + case "return": + front.resolve({ + value: value, + done: true + }); + break; + + case "throw": + front.reject(value); + break; + + default: + front.resolve({ + value: value, + done: false + }); + break; + } + + front = front.next; + + if (front) { + resume(front.key, front.arg); + } else { + back = null; + } + } + + this._invoke = send; + + if (typeof gen.return !== "function") { + this.return = undefined; + } +} + +if (typeof Symbol === "function" && Symbol.asyncIterator) { + _AsyncGenerator.prototype[Symbol.asyncIterator] = function () { + return this; + }; +} + +_AsyncGenerator.prototype.next = function (arg) { + return this._invoke("next", arg); +}; + +_AsyncGenerator.prototype.throw = function (arg) { + return this._invoke("throw", arg); +}; + +_AsyncGenerator.prototype.return = function (arg) { + return this._invoke("return", arg); +}; + +function _wrapAsyncGenerator(fn) { + return function () { + return new _AsyncGenerator(fn.apply(this, arguments)); + }; +} + +function _awaitAsyncGenerator(value) { + return new _AwaitValue(value); +} + +function _asyncGeneratorDelegate(inner, awaitWrap) { + var iter = {}, + waiting = false; + + function pump(key, value) { + waiting = true; + value = new Promise(function (resolve) { + resolve(inner[key](value)); + }); + return { + done: false, + value: awaitWrap(value) + }; + } + + ; + + if (typeof Symbol === "function" && Symbol.iterator) { + iter[Symbol.iterator] = function () { + return this; + }; + } + + iter.next = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("next", value); + }; + + if (typeof inner.throw === "function") { + iter.throw = function (value) { + if (waiting) { + waiting = false; + throw value; + } + + return pump("throw", value); + }; + } + + if (typeof inner.return === "function") { + iter.return = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("return", value); + }; + } + + return iter; +} + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { + try { + var info = gen[key](arg); + var value = info.value; + } catch (error) { + reject(error); + return; + } + + if (info.done) { + resolve(value); + } else { + Promise.resolve(value).then(_next, _throw); + } +} + +function _asyncToGenerator(fn) { + return function () { + var self = this, + args = arguments; + return new Promise(function (resolve, reject) { + var gen = fn.apply(self, args); + + function _next(value) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); + } + + function _throw(err) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); + } + + _next(undefined); + }); + }; +} + +function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +} + +function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } +} + +function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; +} + +function _defineEnumerableProperties(obj, descs) { + for (var key in descs) { + var desc = descs[key]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, key, desc); + } + + if (Object.getOwnPropertySymbols) { + var objectSymbols = Object.getOwnPropertySymbols(descs); + + for (var i = 0; i < objectSymbols.length; i++) { + var sym = objectSymbols[i]; + var desc = descs[sym]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, sym, desc); + } + } + + return obj; +} + +function _defaults(obj, defaults) { + var keys = Object.getOwnPropertyNames(defaults); + + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var value = Object.getOwnPropertyDescriptor(defaults, key); + + if (value && value.configurable && obj[key] === undefined) { + Object.defineProperty(obj, key, value); + } + } + + return obj; +} + +function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; +} + +function _extends() { + _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + + return _extends.apply(this, arguments); +} + +function _objectSpread(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? Object(arguments[i]) : {}; + var ownKeys = Object.keys(source); + + if (typeof Object.getOwnPropertySymbols === 'function') { + ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { + return Object.getOwnPropertyDescriptor(source, sym).enumerable; + })); + } + + ownKeys.forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } + + return target; +} + +function ownKeys(object, enumerableOnly) { + var keys = Object.keys(object); + + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(object); + if (enumerableOnly) symbols = symbols.filter(function (sym) { + return Object.getOwnPropertyDescriptor(object, sym).enumerable; + }); + keys.push.apply(keys, symbols); + } + + return keys; +} + +function _objectSpread2(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? arguments[i] : {}; + + if (i % 2) { + ownKeys(Object(source), true).forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } else if (Object.getOwnPropertyDescriptors) { + Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); + } else { + ownKeys(Object(source)).forEach(function (key) { + Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); + }); + } + } + + return target; +} + +function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function"); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + writable: true, + configurable: true + } + }); + if (superClass) _setPrototypeOf(subClass, superClass); +} + +function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + subClass.__proto__ = superClass; +} + +function _getPrototypeOf(o) { + _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { + return o.__proto__ || Object.getPrototypeOf(o); + }; + return _getPrototypeOf(o); +} + +function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + + return _setPrototypeOf(o, p); +} + +function _isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + + try { + Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); + return true; + } catch (e) { + return false; + } +} + +function _construct(Parent, args, Class) { + if (_isNativeReflectConstruct()) { + _construct = Reflect.construct; + } else { + _construct = function _construct(Parent, args, Class) { + var a = [null]; + a.push.apply(a, args); + var Constructor = Function.bind.apply(Parent, a); + var instance = new Constructor(); + if (Class) _setPrototypeOf(instance, Class.prototype); + return instance; + }; + } + + return _construct.apply(null, arguments); +} + +function _isNativeFunction(fn) { + return Function.toString.call(fn).indexOf("[native code]") !== -1; +} + +function _wrapNativeSuper(Class) { + var _cache = typeof Map === "function" ? new Map() : undefined; + + _wrapNativeSuper = function _wrapNativeSuper(Class) { + if (Class === null || !_isNativeFunction(Class)) return Class; + + if (typeof Class !== "function") { + throw new TypeError("Super expression must either be null or a function"); + } + + if (typeof _cache !== "undefined") { + if (_cache.has(Class)) return _cache.get(Class); + + _cache.set(Class, Wrapper); + } + + function Wrapper() { + return _construct(Class, arguments, _getPrototypeOf(this).constructor); + } + + Wrapper.prototype = Object.create(Class.prototype, { + constructor: { + value: Wrapper, + enumerable: false, + writable: true, + configurable: true + } + }); + return _setPrototypeOf(Wrapper, Class); + }; + + return _wrapNativeSuper(Class); +} + +function _instanceof(left, right) { + if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { + return !!right[Symbol.hasInstance](left); + } else { + return left instanceof right; + } +} + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; +} + +function _getRequireWildcardCache() { + if (typeof WeakMap !== "function") return null; + var cache = new WeakMap(); + + _getRequireWildcardCache = function () { + return cache; + }; + + return cache; +} + +function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } + + if (obj === null || typeof obj !== "object" && typeof obj !== "function") { + return { + default: obj + }; + } + + var cache = _getRequireWildcardCache(); + + if (cache && cache.has(obj)) { + return cache.get(obj); + } + + var newObj = {}; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + + if (desc && (desc.get || desc.set)) { + Object.defineProperty(newObj, key, desc); + } else { + newObj[key] = obj[key]; + } + } + } + + newObj.default = obj; + + if (cache) { + cache.set(obj, newObj); + } + + return newObj; +} + +function _newArrowCheck(innerThis, boundThis) { + if (innerThis !== boundThis) { + throw new TypeError("Cannot instantiate an arrow function"); + } +} + +function _objectDestructuringEmpty(obj) { + if (obj == null) throw new TypeError("Cannot destructure undefined"); +} + +function _objectWithoutPropertiesLoose(source, excluded) { + if (source == null) return {}; + var target = {}; + var sourceKeys = Object.keys(source); + var key, i; + + for (i = 0; i < sourceKeys.length; i++) { + key = sourceKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + target[key] = source[key]; + } + + return target; +} + +function _objectWithoutProperties(source, excluded) { + if (source == null) return {}; + + var target = _objectWithoutPropertiesLoose(source, excluded); + + var key, i; + + if (Object.getOwnPropertySymbols) { + var sourceSymbolKeys = Object.getOwnPropertySymbols(source); + + for (i = 0; i < sourceSymbolKeys.length; i++) { + key = sourceSymbolKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; + target[key] = source[key]; + } + } + + return target; +} + +function _assertThisInitialized(self) { + if (self === void 0) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return self; +} + +function _possibleConstructorReturn(self, call) { + if (call && (typeof call === "object" || typeof call === "function")) { + return call; + } + + return _assertThisInitialized(self); +} + +function _createSuper(Derived) { + var hasNativeReflectConstruct = _isNativeReflectConstruct(); + + return function _createSuperInternal() { + var Super = _getPrototypeOf(Derived), + result; + + if (hasNativeReflectConstruct) { + var NewTarget = _getPrototypeOf(this).constructor; + + result = Reflect.construct(Super, arguments, NewTarget); + } else { + result = Super.apply(this, arguments); + } + + return _possibleConstructorReturn(this, result); + }; +} + +function _superPropBase(object, property) { + while (!Object.prototype.hasOwnProperty.call(object, property)) { + object = _getPrototypeOf(object); + if (object === null) break; + } + + return object; +} + +function _get(target, property, receiver) { + if (typeof Reflect !== "undefined" && Reflect.get) { + _get = Reflect.get; + } else { + _get = function _get(target, property, receiver) { + var base = _superPropBase(target, property); + + if (!base) return; + var desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.get) { + return desc.get.call(receiver); + } + + return desc.value; + }; + } + + return _get(target, property, receiver || target); +} + +function set(target, property, value, receiver) { + if (typeof Reflect !== "undefined" && Reflect.set) { + set = Reflect.set; + } else { + set = function set(target, property, value, receiver) { + var base = _superPropBase(target, property); + + var desc; + + if (base) { + desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.set) { + desc.set.call(receiver, value); + return true; + } else if (!desc.writable) { + return false; + } + } + + desc = Object.getOwnPropertyDescriptor(receiver, property); + + if (desc) { + if (!desc.writable) { + return false; + } + + desc.value = value; + Object.defineProperty(receiver, property, desc); + } else { + _defineProperty(receiver, property, value); + } + + return true; + }; + } + + return set(target, property, value, receiver); +} + +function _set(target, property, value, receiver, isStrict) { + var s = set(target, property, value, receiver || target); + + if (!s && isStrict) { + throw new Error('failed to set property'); + } + + return value; +} + +function _taggedTemplateLiteral(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + return Object.freeze(Object.defineProperties(strings, { + raw: { + value: Object.freeze(raw) + } + })); +} + +function _taggedTemplateLiteralLoose(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + strings.raw = raw; + return strings; +} + +function _readOnlyError(name) { + throw new Error("\"" + name + "\" is read-only"); +} + +function _classNameTDZError(name) { + throw new Error("Class \"" + name + "\" cannot be referenced in computed property keys."); +} + +function _temporalUndefined() {} + +function _tdz(name) { + throw new ReferenceError(name + " is not defined - temporal dead zone"); +} + +function _temporalRef(val, name) { + return val === _temporalUndefined ? _tdz(name) : val; +} + +function _slicedToArray(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); +} + +function _slicedToArrayLoose(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimitLoose(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); +} + +function _toArray(arr) { + return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); +} + +function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); +} + +function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) return _arrayLikeToArray(arr); +} + +function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; +} + +function _maybeArrayLike(next, arr, i) { + if (arr && !Array.isArray(arr) && typeof arr.length === "number") { + var len = arr.length; + return _arrayLikeToArray(arr, i !== void 0 && i < len ? i : len); + } + + return next(arr, i); +} + +function _iterableToArray(iter) { + if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); +} + +function _iterableToArrayLimit(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"] != null) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; +} + +function _iterableToArrayLimitLoose(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + + for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { + _arr.push(_step.value); + + if (i && _arr.length === i) break; + } + + return _arr; +} + +function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if (typeof o === "string") return _arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + if (n === "Object" && o.constructor) n = o.constructor.name; + if (n === "Map" || n === "Set") return Array.from(o); + if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); +} + +function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) len = arr.length; + + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + + return arr2; +} + +function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); +} + +function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); +} + +function _createForOfIteratorHelper(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + + var F = function () {}; + + return { + s: F, + n: function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }, + e: function (e) { + throw e; + }, + f: F + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + var normalCompletion = true, + didErr = false, + err; + return { + s: function () { + it = o[Symbol.iterator](); + }, + n: function () { + var step = it.next(); + normalCompletion = step.done; + return step; + }, + e: function (e) { + didErr = true; + err = e; + }, + f: function () { + try { + if (!normalCompletion && it.return != null) it.return(); + } finally { + if (didErr) throw err; + } + } + }; +} + +function _createForOfIteratorHelperLoose(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + return function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + it = o[Symbol.iterator](); + return it.next.bind(it); +} + +function _skipFirstGeneratorNext(fn) { + return function () { + var it = fn.apply(this, arguments); + it.next(); + return it; + }; +} + +function _toPrimitive(input, hint) { + if (typeof input !== "object" || input === null) return input; + var prim = input[Symbol.toPrimitive]; + + if (prim !== undefined) { + var res = prim.call(input, hint || "default"); + if (typeof res !== "object") return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + + return (hint === "string" ? String : Number)(input); +} + +function _toPropertyKey(arg) { + var key = _toPrimitive(arg, "string"); + + return typeof key === "symbol" ? key : String(key); +} + +function _initializerWarningHelper(descriptor, context) { + throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.'); +} + +function _initializerDefineProperty(target, property, descriptor, context) { + if (!descriptor) return; + Object.defineProperty(target, property, { + enumerable: descriptor.enumerable, + configurable: descriptor.configurable, + writable: descriptor.writable, + value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 + }); +} + +function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { + var desc = {}; + Object.keys(descriptor).forEach(function (key) { + desc[key] = descriptor[key]; + }); + desc.enumerable = !!desc.enumerable; + desc.configurable = !!desc.configurable; + + if ('value' in desc || desc.initializer) { + desc.writable = true; + } + + desc = decorators.slice().reverse().reduce(function (desc, decorator) { + return decorator(target, property, desc) || desc; + }, desc); + + if (context && desc.initializer !== void 0) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = undefined; + } + + if (desc.initializer === void 0) { + Object.defineProperty(target, property, desc); + desc = null; + } + + return desc; +} + +var id = 0; + +function _classPrivateFieldLooseKey(name) { + return "__private_" + id++ + "_" + name; +} + +function _classPrivateFieldLooseBase(receiver, privateKey) { + if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { + throw new TypeError("attempted to use private field on non-instance"); + } + + return receiver; +} + +function _classPrivateFieldGet(receiver, privateMap) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to get private field on non-instance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; +} + +function _classPrivateFieldSet(receiver, privateMap, value) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to set private field on non-instance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; +} + +function _classPrivateFieldDestructureSet(receiver, privateMap) { + if (!privateMap.has(receiver)) { + throw new TypeError("attempted to set private field on non-instance"); + } + + var descriptor = privateMap.get(receiver); + + if (descriptor.set) { + if (!("__destrObj" in descriptor)) { + descriptor.__destrObj = { + set value(v) { + descriptor.set.call(receiver, v); + } + + }; + } + + return descriptor.__destrObj; + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + return descriptor; + } +} + +function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; +} + +function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; +} + +function _classStaticPrivateMethodGet(receiver, classConstructor, method) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + return method; +} + +function _classStaticPrivateMethodSet() { + throw new TypeError("attempted to set read only static private field"); +} + +function _decorate(decorators, factory, superClass, mixins) { + var api = _getDecoratorsApi(); + + if (mixins) { + for (var i = 0; i < mixins.length; i++) { + api = mixins[i](api); + } + } + + var r = factory(function initialize(O) { + api.initializeInstanceElements(O, decorated.elements); + }, superClass); + var decorated = api.decorateClass(_coalesceClassElements(r.d.map(_createElementDescriptor)), decorators); + api.initializeClassElements(r.F, decorated.elements); + return api.runClassFinishers(r.F, decorated.finishers); +} + +function _getDecoratorsApi() { + _getDecoratorsApi = function () { + return api; + }; + + var api = { + elementsDefinitionOrder: [["method"], ["field"]], + initializeInstanceElements: function (O, elements) { + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + if (element.kind === kind && element.placement === "own") { + this.defineClassElement(O, element); + } + }, this); + }, this); + }, + initializeClassElements: function (F, elements) { + var proto = F.prototype; + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + var placement = element.placement; + + if (element.kind === kind && (placement === "static" || placement === "prototype")) { + var receiver = placement === "static" ? F : proto; + this.defineClassElement(receiver, element); + } + }, this); + }, this); + }, + defineClassElement: function (receiver, element) { + var descriptor = element.descriptor; + + if (element.kind === "field") { + var initializer = element.initializer; + descriptor = { + enumerable: descriptor.enumerable, + writable: descriptor.writable, + configurable: descriptor.configurable, + value: initializer === void 0 ? void 0 : initializer.call(receiver) + }; + } + + Object.defineProperty(receiver, element.key, descriptor); + }, + decorateClass: function (elements, decorators) { + var newElements = []; + var finishers = []; + var placements = { + static: [], + prototype: [], + own: [] + }; + elements.forEach(function (element) { + this.addElementPlacement(element, placements); + }, this); + elements.forEach(function (element) { + if (!_hasDecorators(element)) return newElements.push(element); + var elementFinishersExtras = this.decorateElement(element, placements); + newElements.push(elementFinishersExtras.element); + newElements.push.apply(newElements, elementFinishersExtras.extras); + finishers.push.apply(finishers, elementFinishersExtras.finishers); + }, this); + + if (!decorators) { + return { + elements: newElements, + finishers: finishers + }; + } + + var result = this.decorateConstructor(newElements, decorators); + finishers.push.apply(finishers, result.finishers); + result.finishers = finishers; + return result; + }, + addElementPlacement: function (element, placements, silent) { + var keys = placements[element.placement]; + + if (!silent && keys.indexOf(element.key) !== -1) { + throw new TypeError("Duplicated element (" + element.key + ")"); + } + + keys.push(element.key); + }, + decorateElement: function (element, placements) { + var extras = []; + var finishers = []; + + for (var decorators = element.decorators, i = decorators.length - 1; i >= 0; i--) { + var keys = placements[element.placement]; + keys.splice(keys.indexOf(element.key), 1); + var elementObject = this.fromElementDescriptor(element); + var elementFinisherExtras = this.toElementFinisherExtras((0, decorators[i])(elementObject) || elementObject); + element = elementFinisherExtras.element; + this.addElementPlacement(element, placements); + + if (elementFinisherExtras.finisher) { + finishers.push(elementFinisherExtras.finisher); + } + + var newExtras = elementFinisherExtras.extras; + + if (newExtras) { + for (var j = 0; j < newExtras.length; j++) { + this.addElementPlacement(newExtras[j], placements); + } + + extras.push.apply(extras, newExtras); + } + } + + return { + element: element, + finishers: finishers, + extras: extras + }; + }, + decorateConstructor: function (elements, decorators) { + var finishers = []; + + for (var i = decorators.length - 1; i >= 0; i--) { + var obj = this.fromClassDescriptor(elements); + var elementsAndFinisher = this.toClassDescriptor((0, decorators[i])(obj) || obj); + + if (elementsAndFinisher.finisher !== undefined) { + finishers.push(elementsAndFinisher.finisher); + } + + if (elementsAndFinisher.elements !== undefined) { + elements = elementsAndFinisher.elements; + + for (var j = 0; j < elements.length - 1; j++) { + for (var k = j + 1; k < elements.length; k++) { + if (elements[j].key === elements[k].key && elements[j].placement === elements[k].placement) { + throw new TypeError("Duplicated element (" + elements[j].key + ")"); + } + } + } + } + } + + return { + elements: elements, + finishers: finishers + }; + }, + fromElementDescriptor: function (element) { + var obj = { + kind: element.kind, + key: element.key, + placement: element.placement, + descriptor: element.descriptor + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + if (element.kind === "field") obj.initializer = element.initializer; + return obj; + }, + toElementDescriptors: function (elementObjects) { + if (elementObjects === undefined) return; + return _toArray(elementObjects).map(function (elementObject) { + var element = this.toElementDescriptor(elementObject); + this.disallowProperty(elementObject, "finisher", "An element descriptor"); + this.disallowProperty(elementObject, "extras", "An element descriptor"); + return element; + }, this); + }, + toElementDescriptor: function (elementObject) { + var kind = String(elementObject.kind); + + if (kind !== "method" && kind !== "field") { + throw new TypeError('An element descriptor\'s .kind property must be either "method" or' + ' "field", but a decorator created an element descriptor with' + ' .kind "' + kind + '"'); + } + + var key = _toPropertyKey(elementObject.key); + + var placement = String(elementObject.placement); + + if (placement !== "static" && placement !== "prototype" && placement !== "own") { + throw new TypeError('An element descriptor\'s .placement property must be one of "static",' + ' "prototype" or "own", but a decorator created an element descriptor' + ' with .placement "' + placement + '"'); + } + + var descriptor = elementObject.descriptor; + this.disallowProperty(elementObject, "elements", "An element descriptor"); + var element = { + kind: kind, + key: key, + placement: placement, + descriptor: Object.assign({}, descriptor) + }; + + if (kind !== "field") { + this.disallowProperty(elementObject, "initializer", "A method descriptor"); + } else { + this.disallowProperty(descriptor, "get", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "set", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "value", "The property descriptor of a field descriptor"); + element.initializer = elementObject.initializer; + } + + return element; + }, + toElementFinisherExtras: function (elementObject) { + var element = this.toElementDescriptor(elementObject); + + var finisher = _optionalCallableProperty(elementObject, "finisher"); + + var extras = this.toElementDescriptors(elementObject.extras); + return { + element: element, + finisher: finisher, + extras: extras + }; + }, + fromClassDescriptor: function (elements) { + var obj = { + kind: "class", + elements: elements.map(this.fromElementDescriptor, this) + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + return obj; + }, + toClassDescriptor: function (obj) { + var kind = String(obj.kind); + + if (kind !== "class") { + throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator' + ' created a class descriptor with .kind "' + kind + '"'); + } + + this.disallowProperty(obj, "key", "A class descriptor"); + this.disallowProperty(obj, "placement", "A class descriptor"); + this.disallowProperty(obj, "descriptor", "A class descriptor"); + this.disallowProperty(obj, "initializer", "A class descriptor"); + this.disallowProperty(obj, "extras", "A class descriptor"); + + var finisher = _optionalCallableProperty(obj, "finisher"); + + var elements = this.toElementDescriptors(obj.elements); + return { + elements: elements, + finisher: finisher + }; + }, + runClassFinishers: function (constructor, finishers) { + for (var i = 0; i < finishers.length; i++) { + var newConstructor = (0, finishers[i])(constructor); + + if (newConstructor !== undefined) { + if (typeof newConstructor !== "function") { + throw new TypeError("Finishers must return a constructor."); + } + + constructor = newConstructor; + } + } + + return constructor; + }, + disallowProperty: function (obj, name, objectType) { + if (obj[name] !== undefined) { + throw new TypeError(objectType + " can't have a ." + name + " property."); + } + } + }; + return api; +} + +function _createElementDescriptor(def) { + var key = _toPropertyKey(def.key); + + var descriptor; + + if (def.kind === "method") { + descriptor = { + value: def.value, + writable: true, + configurable: true, + enumerable: false + }; + } else if (def.kind === "get") { + descriptor = { + get: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "set") { + descriptor = { + set: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "field") { + descriptor = { + configurable: true, + writable: true, + enumerable: true + }; + } + + var element = { + kind: def.kind === "field" ? "field" : "method", + key: key, + placement: def.static ? "static" : def.kind === "field" ? "own" : "prototype", + descriptor: descriptor + }; + if (def.decorators) element.decorators = def.decorators; + if (def.kind === "field") element.initializer = def.value; + return element; +} + +function _coalesceGetterSetter(element, other) { + if (element.descriptor.get !== undefined) { + other.descriptor.get = element.descriptor.get; + } else { + other.descriptor.set = element.descriptor.set; + } +} + +function _coalesceClassElements(elements) { + var newElements = []; + + var isSameElement = function (other) { + return other.kind === "method" && other.key === element.key && other.placement === element.placement; + }; + + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + var other; + + if (element.kind === "method" && (other = newElements.find(isSameElement))) { + if (_isDataDescriptor(element.descriptor) || _isDataDescriptor(other.descriptor)) { + if (_hasDecorators(element) || _hasDecorators(other)) { + throw new ReferenceError("Duplicated methods (" + element.key + ") can't be decorated."); + } + + other.descriptor = element.descriptor; + } else { + if (_hasDecorators(element)) { + if (_hasDecorators(other)) { + throw new ReferenceError("Decorators can't be placed on different accessors with for " + "the same property (" + element.key + ")."); + } + + other.decorators = element.decorators; + } + + _coalesceGetterSetter(element, other); + } + } else { + newElements.push(element); + } + } + + return newElements; +} + +function _hasDecorators(element) { + return element.decorators && element.decorators.length; +} + +function _isDataDescriptor(desc) { + return desc !== undefined && !(desc.value === undefined && desc.writable === undefined); +} + +function _optionalCallableProperty(obj, name) { + var value = obj[name]; + + if (value !== undefined && typeof value !== "function") { + throw new TypeError("Expected '" + name + "' to be a function"); + } + + return value; +} + +function _classPrivateMethodGet(receiver, privateSet, fn) { + if (!privateSet.has(receiver)) { + throw new TypeError("attempted to get private field on non-instance"); + } + + return fn; +} + +function _classPrivateMethodSet() { + throw new TypeError("attempted to reassign private method"); +} + +function _wrapRegExp(re, groups) { + _wrapRegExp = function (re, groups) { + return new BabelRegExp(re, undefined, groups); + }; + + var _RegExp = _wrapNativeSuper(RegExp); + + var _super = RegExp.prototype; + + var _groups = new WeakMap(); + + function BabelRegExp(re, flags, groups) { + var _this = _RegExp.call(this, re, flags); + + _groups.set(_this, groups || _groups.get(re)); + + return _this; + } + + _inherits(BabelRegExp, _RegExp); + + BabelRegExp.prototype.exec = function (str) { + var result = _super.exec.call(this, str); + + if (result) result.groups = buildGroups(result, this); + return result; + }; + + BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { + if (typeof substitution === "string") { + var groups = _groups.get(this); + + return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { + return "$" + groups[name]; + })); + } else if (typeof substitution === "function") { + var _this = this; + + return _super[Symbol.replace].call(this, str, function () { + var args = []; + args.push.apply(args, arguments); + + if (typeof args[args.length - 1] !== "object") { + args.push(buildGroups(args, _this)); + } + + return substitution.apply(this, args); + }); + } else { + return _super[Symbol.replace].call(this, str, substitution); + } + }; + + function buildGroups(result, re) { + var g = _groups.get(re); + + return Object.keys(g).reduce(function (groups, name) { + groups[name] = result[g[name]]; + return groups; + }, Object.create(null)); + } + + return _wrapRegExp.apply(this, arguments); +} + +/** + * @file ext-connector.js + * + * @license MIT + * + * @copyright 2010 Alexis Deveria + * + */ +var extConnector = { + name: 'connector', + init: function init(S) { + var _this = this; + + return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { + var svgEditor, svgCanvas, getElem, $, svgroot, importLocale, addElem, selManager, connSel, elData, strings, startX, startY, curLine, startElem, endElem, seNs, svgcontent, started, connections, selElems, getBBintersect, getOffset, showPanel, setPoint, updateLine, findConnectors, updateConnectors, init, buttons; + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + init = function _init() { + // Make sure all connectors have data set + $(svgcontent).find('*').each(function () { + var conn = this.getAttributeNS(seNs, 'connector'); + + if (conn) { + this.setAttribute('class', connSel.substr(1)); + var connData = conn.split(' '); + var sbb = svgCanvas.getStrokedBBox([getElem(connData[0])]); + var ebb = svgCanvas.getStrokedBBox([getElem(connData[1])]); + $(this).data('c_start', connData[0]).data('c_end', connData[1]).data('start_bb', sbb).data('end_bb', ebb); + svgCanvas.getEditorNS(true); + } + }); // updateConnectors(); + }; + + updateConnectors = function _updateConnectors(elems) { + // Updates connector lines based on selected elements + // Is not used on mousemove, as it runs getStrokedBBox every time, + // which isn't necessary there. + findConnectors(elems); + + if (connections.length) { + // Update line with element + var i = connections.length; + + while (i--) { + var conn = connections[i]; + var line = conn.connector; + var elem = conn.elem; // const sw = line.getAttribute('stroke-width') * 5; + + var pre = conn.is_start ? 'start' : 'end'; // Update bbox for this element + + var bb = svgCanvas.getStrokedBBox([elem]); + bb.x = conn.start_x; + bb.y = conn.start_y; + elData(line, pre + '_bb', bb); + /* const addOffset = */ + + elData(line, pre + '_off'); + var altPre = conn.is_start ? 'end' : 'start'; // Get center pt of connected element + + var bb2 = elData(line, altPre + '_bb'); + var srcX = bb2.x + bb2.width / 2; + var srcY = bb2.y + bb2.height / 2; // Set point of element being moved + + var pt = getBBintersect(srcX, srcY, bb, getOffset(pre, line)); + setPoint(line, conn.is_start ? 0 : 'end', pt.x, pt.y, true); // Set point of connected element + + var pt2 = getBBintersect(pt.x, pt.y, elData(line, altPre + '_bb'), getOffset(altPre, line)); + setPoint(line, conn.is_start ? 'end' : 0, pt2.x, pt2.y, true); // Update points attribute manually for webkit + + if (navigator.userAgent.includes('AppleWebKit')) { + var pts = line.points; + var len = pts.numberOfItems; + var ptArr = []; + + for (var j = 0; j < len; j++) { + pt = pts.getItem(j); + ptArr[j] = pt.x + ',' + pt.y; + } + + line.setAttribute('points', ptArr.join(' ')); + } + } + } + }; + + findConnectors = function _findConnectors() { + var elems = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : selElems; + var connectors = $(svgcontent).find(connSel); + connections = []; // Loop through connectors to see if one is connected to the element + + connectors.each(function () { + var addThis; + /** + * + * @returns {void} + */ + + function add() { + if (elems.includes(this)) { + // Pretend this element is selected + addThis = true; + } + } // Grab the ends + + + var parts = []; + ['start', 'end'].forEach(function (pos, i) { + var key = 'c_' + pos; + var part = elData(this, key); + + if (part === null || part === undefined) { + // Does this ever return nullish values? + part = document.getElementById(this.attributes['se:connector'].value.split(' ')[i]); + elData(this, 'c_' + pos, part.id); + elData(this, pos + '_bb', svgCanvas.getStrokedBBox([part])); + } else part = document.getElementById(part); + + parts.push(part); + }, this); + + for (var i = 0; i < 2; i++) { + var cElem = parts[i]; + addThis = false; // The connected element might be part of a selected group + + $(cElem).parents().each(add); + + if (!cElem || !cElem.parentNode) { + $(this).remove(); + continue; + } + + if (elems.includes(cElem) || addThis) { + var bb = svgCanvas.getStrokedBBox([cElem]); + connections.push({ + elem: cElem, + connector: this, + is_start: i === 0, + start_x: bb.x, + start_y: bb.y + }); + } + } + }); + }; + + updateLine = function _updateLine(diffX, diffY) { + // Update line with element + var i = connections.length; + + while (i--) { + var conn = connections[i]; + var line = conn.connector; // const {elem} = conn; + + var pre = conn.is_start ? 'start' : 'end'; // const sw = line.getAttribute('stroke-width') * 5; + // Update bbox for this element + + var bb = elData(line, pre + '_bb'); + bb.x = conn.start_x + diffX; + bb.y = conn.start_y + diffY; + elData(line, pre + '_bb', bb); + var altPre = conn.is_start ? 'end' : 'start'; // Get center pt of connected element + + var bb2 = elData(line, altPre + '_bb'); + var srcX = bb2.x + bb2.width / 2; + var srcY = bb2.y + bb2.height / 2; // Set point of element being moved + + var pt = getBBintersect(srcX, srcY, bb, getOffset(pre, line)); // $(line).data(pre+'_off')?sw:0 + + setPoint(line, conn.is_start ? 0 : 'end', pt.x, pt.y, true); // Set point of connected element + + var pt2 = getBBintersect(pt.x, pt.y, elData(line, altPre + '_bb'), getOffset(altPre, line)); + setPoint(line, conn.is_start ? 'end' : 0, pt2.x, pt2.y, true); + } + }; + + setPoint = function _setPoint(elem, pos, x, y, setMid) { + var pts = elem.points; + var pt = svgroot.createSVGPoint(); + pt.x = x; + pt.y = y; + + if (pos === 'end') { + pos = pts.numberOfItems - 1; + } // TODO: Test for this on init, then use alt only if needed + + + try { + pts.replaceItem(pt, pos); + } catch (err) { + // Should only occur in FF which formats points attr as "n,n n,n", so just split + var ptArr = elem.getAttribute('points').split(' '); + + for (var i = 0; i < ptArr.length; i++) { + if (i === pos) { + ptArr[i] = x + ',' + y; + } + } + + elem.setAttribute('points', ptArr.join(' ')); + } + + if (setMid) { + // Add center point + var ptStart = pts.getItem(0); + var ptEnd = pts.getItem(pts.numberOfItems - 1); + setPoint(elem, 1, (ptEnd.x + ptStart.x) / 2, (ptEnd.y + ptStart.y) / 2); + } + }; + + showPanel = function _showPanel(on) { + var connRules = $('#connector_rules'); + + if (!connRules.length) { + connRules = $('').appendTo('head'); + } + + connRules.text(!on ? '' : '#tool_clone, #tool_topath, #tool_angle, #xy_panel { display: none !important; }'); + $('#connector_panel').toggle(on); + }; + + getOffset = function _getOffset(side, line) { + var giveOffset = line.getAttribute('marker-' + side); // const giveOffset = $(line).data(side+'_off'); + // TODO: Make this number (5) be based on marker width/height + + var size = line.getAttribute('stroke-width') * 5; + return giveOffset ? size : 0; + }; + + getBBintersect = function _getBBintersect(x, y, bb, offset) { + if (offset) { + offset -= 0; + bb = $.extend({}, bb); + bb.width += offset; + bb.height += offset; + bb.x -= offset / 2; + bb.y -= offset / 2; + } + + var midX = bb.x + bb.width / 2; + var midY = bb.y + bb.height / 2; + var lenX = x - midX; + var lenY = y - midY; + var slope = Math.abs(lenY / lenX); + var ratio; + + if (slope < bb.height / bb.width) { + ratio = bb.width / 2 / Math.abs(lenX); + } else { + ratio = lenY ? bb.height / 2 / Math.abs(lenY) : 0; + } + + return { + x: midX + lenX * ratio, + y: midY + lenY * ratio + }; + }; + + svgEditor = _this; + svgCanvas = svgEditor.canvas; + getElem = svgCanvas.getElem; + $ = S.$, svgroot = S.svgroot, importLocale = S.importLocale, addElem = svgCanvas.addSVGElementFromJson, selManager = S.selectorManager, connSel = '.se_connector', elData = $.data; + _context.next = 14; + return importLocale(); + + case 14: + strings = _context.sent; + svgcontent = S.svgcontent, started = false, connections = [], selElems = []; + /** + * + * @param {Float} x + * @param {Float} y + * @param {module:utilities.BBoxObject} bb + * @param {Float} offset + * @returns {module:math.XYObject} + */ + + // Do once + (function () { + var gse = svgCanvas.groupSelectedElements; + + svgCanvas.groupSelectedElements = function () { + svgCanvas.removeFromSelection($(connSel).toArray()); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return gse.apply(this, args); + }; + + var mse = svgCanvas.moveSelectedElements; + + svgCanvas.moveSelectedElements = function () { + for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + var cmd = mse.apply(this, args); + updateConnectors(); + return cmd; + }; + + seNs = svgCanvas.getEditorNS(); + })(); + /** + * Do on reset. + * @returns {void} + */ + + + // $(svgroot).parent().mousemove(function (e) { + // // if (started + // // || svgCanvas.getMode() !== 'connector' + // // || e.target.parentNode.parentNode !== svgcontent) return; + // + // console.log('y') + // // if (e.target.parentNode.parentNode === svgcontent) { + // // + // // } + // }); + buttons = [{ + id: 'mode_connect', + type: 'mode', + icon: svgEditor.curConfig.imgPath + 'cut.png', + includeWith: { + button: '#tool_line', + isDefault: false, + position: 1 + }, + events: { + click: function click() { + svgCanvas.setMode('connector'); + } + } + }]; + return _context.abrupt("return", { + name: strings.name, + svgicons: svgEditor.curConfig.imgPath + 'conn.svg', + buttons: strings.buttons.map(function (button, i) { + return Object.assign(buttons[i], button); + }), + + /* async */ + addLangData: function addLangData(_ref) { + var lang = _ref.lang; + // , importLocale: importLoc + return { + data: strings.langList + }; + }, + mouseDown: function mouseDown(opts) { + var e = opts.event; + startX = opts.start_x; + startY = opts.start_y; + var mode = svgCanvas.getMode(); + var initStroke = svgEditor.curConfig.initStroke; + + if (mode === 'connector') { + if (started) { + return undefined; + } + + var mouseTarget = e.target; + var parents = $(mouseTarget).parents(); + + if ($.inArray(svgcontent, parents) !== -1) { + // Connectable element + // If child of foreignObject, use parent + var fo = $(mouseTarget).closest('foreignObject'); + startElem = fo.length ? fo[0] : mouseTarget; // Get center of source element + + var bb = svgCanvas.getStrokedBBox([startElem]); + var x = bb.x + bb.width / 2; + var y = bb.y + bb.height / 2; + started = true; + curLine = addElem({ + element: 'polyline', + attr: { + id: svgCanvas.getNextId(), + points: x + ',' + y + ' ' + x + ',' + y + ' ' + startX + ',' + startY, + stroke: '#' + initStroke.color, + 'stroke-width': !startElem.stroke_width || startElem.stroke_width === 0 ? initStroke.width : startElem.stroke_width, + fill: 'none', + opacity: initStroke.opacity, + style: 'pointer-events:none' + } + }); + elData(curLine, 'start_bb', bb); + } + + return { + started: true + }; + } + + if (mode === 'select') { + findConnectors(); + } + + return undefined; + }, + mouseMove: function mouseMove(opts) { + var zoom = svgCanvas.getZoom(); // const e = opts.event; + + var x = opts.mouse_x / zoom; + var y = opts.mouse_y / zoom; + var diffX = x - startX, + diffY = y - startY; + var mode = svgCanvas.getMode(); + + if (mode === 'connector' && started) { + // const sw = curLine.getAttribute('stroke-width') * 3; + // Set start point (adjusts based on bb) + var pt = getBBintersect(x, y, elData(curLine, 'start_bb'), getOffset('start', curLine)); + startX = pt.x; + startY = pt.y; + setPoint(curLine, 0, pt.x, pt.y, true); // Set end point + + setPoint(curLine, 'end', x, y, true); + } else if (mode === 'select') { + var slen = selElems.length; + + while (slen--) { + var elem = selElems[slen]; // Look for selected connector elements + + if (elem && elData(elem, 'c_start')) { + // Remove the "translate" transform given to move + svgCanvas.removeFromSelection([elem]); + svgCanvas.getTransformList(elem).clear(); + } + } + + if (connections.length) { + updateLine(diffX, diffY); + } + } + }, + mouseUp: function mouseUp(opts) { + // const zoom = svgCanvas.getZoom(); + var e = opts.event; // , x = opts.mouse_x / zoom, + // , y = opts.mouse_y / zoom, + + var mouseTarget = e.target; + + if (svgCanvas.getMode() !== 'connector') { + return undefined; + } + + var fo = $(mouseTarget).closest('foreignObject'); + + if (fo.length) { + mouseTarget = fo[0]; + } + + var parents = $(mouseTarget).parents(); + + if (mouseTarget === startElem) { + // Start line through click + started = true; + return { + keep: true, + element: null, + started: started + }; + } + + if ($.inArray(svgcontent, parents) === -1) { + // Not a valid target element, so remove line + $(curLine).remove(); + started = false; + return { + keep: false, + element: null, + started: started + }; + } // Valid end element + + + endElem = mouseTarget; + var startId = startElem.id, + endId = endElem.id; + var connStr = startId + ' ' + endId; + var altStr = endId + ' ' + startId; // Don't create connector if one already exists + + var dupe = $(svgcontent).find(connSel).filter(function () { + var conn = this.getAttributeNS(seNs, 'connector'); + + if (conn === connStr || conn === altStr) { + return true; + } + + return false; + }); + + if (dupe.length) { + $(curLine).remove(); + return { + keep: false, + element: null, + started: false + }; + } + + var bb = svgCanvas.getStrokedBBox([endElem]); + var pt = getBBintersect(startX, startY, bb, getOffset('start', curLine)); + setPoint(curLine, 'end', pt.x, pt.y, true); + $(curLine).data('c_start', startId).data('c_end', endId).data('end_bb', bb); + seNs = svgCanvas.getEditorNS(true); + curLine.setAttributeNS(seNs, 'se:connector', connStr); + curLine.setAttribute('class', connSel.substr(1)); + curLine.setAttribute('opacity', 1); + svgCanvas.addToSelection([curLine]); + svgCanvas.moveToBottomSelectedElement(); + selManager.requestSelector(curLine).showGrips(false); + started = false; + return { + keep: true, + element: curLine, + started: started + }; + }, + selectedChanged: function selectedChanged(opts) { + // TODO: Find better way to skip operations if no connectors are in use + if (!$(svgcontent).find(connSel).length) { + return; + } + + if (svgCanvas.getMode() === 'connector') { + svgCanvas.setMode('select'); + } // Use this to update the current selected elements + + + selElems = opts.elems; + var i = selElems.length; + + while (i--) { + var elem = selElems[i]; + + if (elem && elData(elem, 'c_start')) { + selManager.requestSelector(elem).showGrips(false); + + if (opts.selectedElement && !opts.multiselected) { + // TODO: Set up context tools and hide most regular line tools + showPanel(true); + } else { + showPanel(false); + } + } else { + showPanel(false); + } + } + + updateConnectors(); + }, + elementChanged: function elementChanged(opts) { + var elem = opts.elems[0]; + if (!elem) return; + + if (elem.tagName === 'svg' && elem.id === 'svgcontent') { + // Update svgcontent (can change on import) + svgcontent = elem; + init(); + } // Has marker, so change offset + + + if (elem.getAttribute('marker-start') || elem.getAttribute('marker-mid') || elem.getAttribute('marker-end')) { + var start = elem.getAttribute('marker-start'); + var mid = elem.getAttribute('marker-mid'); + var end = elem.getAttribute('marker-end'); + curLine = elem; + $(elem).data('start_off', Boolean(start)).data('end_off', Boolean(end)); + + if (elem.tagName === 'line' && mid) { + // Convert to polyline to accept mid-arrow + var x1 = Number(elem.getAttribute('x1')); + var x2 = Number(elem.getAttribute('x2')); + var y1 = Number(elem.getAttribute('y1')); + var y2 = Number(elem.getAttribute('y2')); + var _elem = elem, + id = _elem.id; + var midPt = ' ' + (x1 + x2) / 2 + ',' + (y1 + y2) / 2 + ' '; + var pline = addElem({ + element: 'polyline', + attr: { + points: x1 + ',' + y1 + midPt + x2 + ',' + y2, + stroke: elem.getAttribute('stroke'), + 'stroke-width': elem.getAttribute('stroke-width'), + 'marker-mid': mid, + fill: 'none', + opacity: elem.getAttribute('opacity') || 1 + } + }); + $(elem).after(pline).remove(); + svgCanvas.clearSelection(); + pline.id = id; + svgCanvas.addToSelection([pline]); + elem = pline; + } + } // Update line if it's a connector + + + if (elem.getAttribute('class') === connSel.substr(1)) { + var _start = getElem(elData(elem, 'c_start')); + + updateConnectors([_start]); + } else { + updateConnectors(); + } + }, + IDsUpdated: function IDsUpdated(input) { + var remove = []; + input.elems.forEach(function (elem) { + if ('se:connector' in elem.attr) { + elem.attr['se:connector'] = elem.attr['se:connector'].split(' ').map(function (oldID) { + return input.changes[oldID]; + }).join(' '); // Check validity - the field would be something like 'svg_21 svg_22', but + // if one end is missing, it would be 'svg_21' and therefore fail this test + + if (!/. ./.test(elem.attr['se:connector'])) { + remove.push(elem.attr.id); + } + } + }); + return { + remove: remove + }; + }, + toolButtonStateUpdate: function toolButtonStateUpdate(opts) { + if (opts.nostroke) { + if ($('#mode_connect').hasClass('tool_button_current')) { + svgEditor.clickSelect(); + } + } + + $('#mode_connect').toggleClass('disabled', opts.nostroke); + } + }); + + case 19: + case "end": + return _context.stop(); + } + } + }, _callee); + }))(); + } +}; + +export default extConnector; +//# sourceMappingURL=ext-connector.js.map diff --git a/dist/editor/extensions/ext-connector.js.map b/dist/editor/extensions/ext-connector.js.map new file mode 100644 index 00000000..575f0436 --- /dev/null +++ b/dist/editor/extensions/ext-connector.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ext-connector.js","sources":["../../../src/editor/extensions/ext-connector.js"],"sourcesContent":["/**\n * @file ext-connector.js\n *\n * @license MIT\n *\n * @copyright 2010 Alexis Deveria\n *\n */\n\nexport default {\n name: 'connector',\n async init (S) {\n const svgEditor = this;\n const svgCanvas = svgEditor.canvas;\n const {getElem} = svgCanvas;\n const {$, svgroot, importLocale} = S,\n addElem = svgCanvas.addSVGElementFromJson,\n selManager = S.selectorManager,\n connSel = '.se_connector',\n // connect_str = '-SE_CONNECT-',\n elData = $.data;\n const strings = await importLocale();\n\n let startX,\n startY,\n curLine,\n startElem,\n endElem,\n seNs,\n {svgcontent} = S,\n started = false,\n connections = [],\n selElems = [];\n\n /**\n *\n * @param {Float} x\n * @param {Float} y\n * @param {module:utilities.BBoxObject} bb\n * @param {Float} offset\n * @returns {module:math.XYObject}\n */\n function getBBintersect (x, y, bb, offset) {\n if (offset) {\n offset -= 0;\n bb = $.extend({}, bb);\n bb.width += offset;\n bb.height += offset;\n bb.x -= offset / 2;\n bb.y -= offset / 2;\n }\n\n const midX = bb.x + bb.width / 2;\n const midY = bb.y + bb.height / 2;\n const lenX = x - midX;\n const lenY = y - midY;\n\n const slope = Math.abs(lenY / lenX);\n\n let ratio;\n if (slope < bb.height / bb.width) {\n ratio = (bb.width / 2) / Math.abs(lenX);\n } else {\n ratio = lenY\n ? (bb.height / 2) / Math.abs(lenY)\n : 0;\n }\n\n return {\n x: midX + lenX * ratio,\n y: midY + lenY * ratio\n };\n }\n\n /**\n * @param {\"start\"|\"end\"} side\n * @param {Element} line\n * @returns {Float}\n */\n function getOffset (side, line) {\n const giveOffset = line.getAttribute('marker-' + side);\n // const giveOffset = $(line).data(side+'_off');\n\n // TODO: Make this number (5) be based on marker width/height\n const size = line.getAttribute('stroke-width') * 5;\n return giveOffset ? size : 0;\n }\n\n /**\n * @param {boolean} on\n * @returns {void}\n */\n function showPanel (on) {\n let connRules = $('#connector_rules');\n if (!connRules.length) {\n connRules = $('').appendTo('head');\n }\n connRules.text(!on ? '' : '#tool_clone, #tool_topath, #tool_angle, #xy_panel { display: none !important; }');\n $('#connector_panel').toggle(on);\n }\n\n /**\n * @param {Element} elem\n * @param {Integer|\"end\"} pos\n * @param {Float} x\n * @param {Float} y\n * @param {boolean} [setMid]\n * @returns {void}\n */\n function setPoint (elem, pos, x, y, setMid) {\n const pts = elem.points;\n const pt = svgroot.createSVGPoint();\n pt.x = x;\n pt.y = y;\n if (pos === 'end') { pos = pts.numberOfItems - 1; }\n // TODO: Test for this on init, then use alt only if needed\n try {\n pts.replaceItem(pt, pos);\n } catch (err) {\n // Should only occur in FF which formats points attr as \"n,n n,n\", so just split\n const ptArr = elem.getAttribute('points').split(' ');\n for (let i = 0; i < ptArr.length; i++) {\n if (i === pos) {\n ptArr[i] = x + ',' + y;\n }\n }\n elem.setAttribute('points', ptArr.join(' '));\n }\n\n if (setMid) {\n // Add center point\n const ptStart = pts.getItem(0);\n const ptEnd = pts.getItem(pts.numberOfItems - 1);\n setPoint(elem, 1, (ptEnd.x + ptStart.x) / 2, (ptEnd.y + ptStart.y) / 2);\n }\n }\n\n /**\n * @param {Float} diffX\n * @param {Float} diffY\n * @returns {void}\n */\n function updateLine (diffX, diffY) {\n // Update line with element\n let i = connections.length;\n while (i--) {\n const conn = connections[i];\n const line = conn.connector;\n // const {elem} = conn;\n\n const pre = conn.is_start ? 'start' : 'end';\n // const sw = line.getAttribute('stroke-width') * 5;\n\n // Update bbox for this element\n const bb = elData(line, pre + '_bb');\n bb.x = conn.start_x + diffX;\n bb.y = conn.start_y + diffY;\n elData(line, pre + '_bb', bb);\n\n const altPre = conn.is_start ? 'end' : 'start';\n\n // Get center pt of connected element\n const bb2 = elData(line, altPre + '_bb');\n const srcX = bb2.x + bb2.width / 2;\n const srcY = bb2.y + bb2.height / 2;\n\n // Set point of element being moved\n const pt = getBBintersect(srcX, srcY, bb, getOffset(pre, line)); // $(line).data(pre+'_off')?sw:0\n setPoint(line, conn.is_start ? 0 : 'end', pt.x, pt.y, true);\n\n // Set point of connected element\n const pt2 = getBBintersect(pt.x, pt.y, elData(line, altPre + '_bb'), getOffset(altPre, line));\n setPoint(line, conn.is_start ? 'end' : 0, pt2.x, pt2.y, true);\n }\n }\n\n /**\n *\n * @param {Element[]} [elems=selElems] Array of elements\n * @returns {void}\n */\n function findConnectors (elems = selElems) {\n const connectors = $(svgcontent).find(connSel);\n connections = [];\n\n // Loop through connectors to see if one is connected to the element\n connectors.each(function () {\n let addThis;\n /**\n *\n * @returns {void}\n */\n function add () {\n if (elems.includes(this)) {\n // Pretend this element is selected\n addThis = true;\n }\n }\n\n // Grab the ends\n const parts = [];\n ['start', 'end'].forEach(function (pos, i) {\n const key = 'c_' + pos;\n let part = elData(this, key);\n if (part === null || part === undefined) { // Does this ever return nullish values?\n part = document.getElementById(\n this.attributes['se:connector'].value.split(' ')[i]\n );\n elData(this, 'c_' + pos, part.id);\n elData(this, pos + '_bb', svgCanvas.getStrokedBBox([part]));\n } else part = document.getElementById(part);\n parts.push(part);\n }, this);\n\n for (let i = 0; i < 2; i++) {\n const cElem = parts[i];\n\n addThis = false;\n // The connected element might be part of a selected group\n $(cElem).parents().each(add);\n\n if (!cElem || !cElem.parentNode) {\n $(this).remove();\n continue;\n }\n if (elems.includes(cElem) || addThis) {\n const bb = svgCanvas.getStrokedBBox([cElem]);\n connections.push({\n elem: cElem,\n connector: this,\n is_start: (i === 0),\n start_x: bb.x,\n start_y: bb.y\n });\n }\n }\n });\n }\n\n /**\n * @param {Element[]} [elems=selElems]\n * @returns {void}\n */\n function updateConnectors (elems) {\n // Updates connector lines based on selected elements\n // Is not used on mousemove, as it runs getStrokedBBox every time,\n // which isn't necessary there.\n findConnectors(elems);\n if (connections.length) {\n // Update line with element\n let i = connections.length;\n while (i--) {\n const conn = connections[i];\n const line = conn.connector;\n const {elem} = conn;\n\n // const sw = line.getAttribute('stroke-width') * 5;\n const pre = conn.is_start ? 'start' : 'end';\n\n // Update bbox for this element\n const bb = svgCanvas.getStrokedBBox([elem]);\n bb.x = conn.start_x;\n bb.y = conn.start_y;\n elData(line, pre + '_bb', bb);\n /* const addOffset = */ elData(line, pre + '_off');\n\n const altPre = conn.is_start ? 'end' : 'start';\n\n // Get center pt of connected element\n const bb2 = elData(line, altPre + '_bb');\n const srcX = bb2.x + bb2.width / 2;\n const srcY = bb2.y + bb2.height / 2;\n\n // Set point of element being moved\n let pt = getBBintersect(srcX, srcY, bb, getOffset(pre, line));\n setPoint(line, conn.is_start ? 0 : 'end', pt.x, pt.y, true);\n\n // Set point of connected element\n const pt2 = getBBintersect(pt.x, pt.y, elData(line, altPre + '_bb'), getOffset(altPre, line));\n setPoint(line, conn.is_start ? 'end' : 0, pt2.x, pt2.y, true);\n\n // Update points attribute manually for webkit\n if (navigator.userAgent.includes('AppleWebKit')) {\n const pts = line.points;\n const len = pts.numberOfItems;\n const ptArr = [];\n for (let j = 0; j < len; j++) {\n pt = pts.getItem(j);\n ptArr[j] = pt.x + ',' + pt.y;\n }\n line.setAttribute('points', ptArr.join(' '));\n }\n }\n }\n }\n\n // Do once\n (function () {\n const gse = svgCanvas.groupSelectedElements;\n\n svgCanvas.groupSelectedElements = function (...args) {\n svgCanvas.removeFromSelection($(connSel).toArray());\n return gse.apply(this, args);\n };\n\n const mse = svgCanvas.moveSelectedElements;\n\n svgCanvas.moveSelectedElements = function (...args) {\n const cmd = mse.apply(this, args);\n updateConnectors();\n return cmd;\n };\n\n seNs = svgCanvas.getEditorNS();\n }());\n\n /**\n * Do on reset.\n * @returns {void}\n */\n function init () {\n // Make sure all connectors have data set\n $(svgcontent).find('*').each(function () {\n const conn = this.getAttributeNS(seNs, 'connector');\n if (conn) {\n this.setAttribute('class', connSel.substr(1));\n const connData = conn.split(' ');\n const sbb = svgCanvas.getStrokedBBox([getElem(connData[0])]);\n const ebb = svgCanvas.getStrokedBBox([getElem(connData[1])]);\n $(this).data('c_start', connData[0])\n .data('c_end', connData[1])\n .data('start_bb', sbb)\n .data('end_bb', ebb);\n svgCanvas.getEditorNS(true);\n }\n });\n // updateConnectors();\n }\n\n // $(svgroot).parent().mousemove(function (e) {\n // // if (started\n // // || svgCanvas.getMode() !== 'connector'\n // // || e.target.parentNode.parentNode !== svgcontent) return;\n //\n // console.log('y')\n // // if (e.target.parentNode.parentNode === svgcontent) {\n // //\n // // }\n // });\n\n const buttons = [{\n id: 'mode_connect',\n type: 'mode',\n icon: svgEditor.curConfig.imgPath + 'cut.png',\n includeWith: {\n button: '#tool_line',\n isDefault: false,\n position: 1\n },\n events: {\n click () {\n svgCanvas.setMode('connector');\n }\n }\n }];\n\n return {\n name: strings.name,\n svgicons: svgEditor.curConfig.imgPath + 'conn.svg',\n buttons: strings.buttons.map((button, i) => {\n return Object.assign(buttons[i], button);\n }),\n /* async */ addLangData ({lang}) { // , importLocale: importLoc\n return {\n data: strings.langList\n };\n },\n mouseDown (opts) {\n const e = opts.event;\n startX = opts.start_x;\n startY = opts.start_y;\n const mode = svgCanvas.getMode();\n const {curConfig: {initStroke}} = svgEditor;\n\n if (mode === 'connector') {\n if (started) { return undefined; }\n\n const mouseTarget = e.target;\n\n const parents = $(mouseTarget).parents();\n\n if ($.inArray(svgcontent, parents) !== -1) {\n // Connectable element\n\n // If child of foreignObject, use parent\n const fo = $(mouseTarget).closest('foreignObject');\n startElem = fo.length ? fo[0] : mouseTarget;\n\n // Get center of source element\n const bb = svgCanvas.getStrokedBBox([startElem]);\n const x = bb.x + bb.width / 2;\n const y = bb.y + bb.height / 2;\n\n started = true;\n curLine = addElem({\n element: 'polyline',\n attr: {\n id: svgCanvas.getNextId(),\n points: (x + ',' + y + ' ' + x + ',' + y + ' ' + startX + ',' + startY),\n stroke: '#' + initStroke.color,\n 'stroke-width': (!startElem.stroke_width || startElem.stroke_width === 0)\n ? initStroke.width\n : startElem.stroke_width,\n fill: 'none',\n opacity: initStroke.opacity,\n style: 'pointer-events:none'\n }\n });\n elData(curLine, 'start_bb', bb);\n }\n return {\n started: true\n };\n }\n if (mode === 'select') {\n findConnectors();\n }\n return undefined;\n },\n mouseMove (opts) {\n const zoom = svgCanvas.getZoom();\n // const e = opts.event;\n const x = opts.mouse_x / zoom;\n const y = opts.mouse_y / zoom;\n\n const diffX = x - startX,\n diffY = y - startY;\n\n const mode = svgCanvas.getMode();\n\n if (mode === 'connector' && started) {\n // const sw = curLine.getAttribute('stroke-width') * 3;\n // Set start point (adjusts based on bb)\n const pt = getBBintersect(x, y, elData(curLine, 'start_bb'), getOffset('start', curLine));\n startX = pt.x;\n startY = pt.y;\n\n setPoint(curLine, 0, pt.x, pt.y, true);\n\n // Set end point\n setPoint(curLine, 'end', x, y, true);\n } else if (mode === 'select') {\n let slen = selElems.length;\n while (slen--) {\n const elem = selElems[slen];\n // Look for selected connector elements\n if (elem && elData(elem, 'c_start')) {\n // Remove the \"translate\" transform given to move\n svgCanvas.removeFromSelection([elem]);\n svgCanvas.getTransformList(elem).clear();\n }\n }\n if (connections.length) {\n updateLine(diffX, diffY);\n }\n }\n },\n mouseUp (opts) {\n // const zoom = svgCanvas.getZoom();\n const e = opts.event;\n // , x = opts.mouse_x / zoom,\n // , y = opts.mouse_y / zoom,\n let mouseTarget = e.target;\n\n if (svgCanvas.getMode() !== 'connector') {\n return undefined;\n }\n const fo = $(mouseTarget).closest('foreignObject');\n if (fo.length) { mouseTarget = fo[0]; }\n\n const parents = $(mouseTarget).parents();\n\n if (mouseTarget === startElem) {\n // Start line through click\n started = true;\n return {\n keep: true,\n element: null,\n started\n };\n }\n if ($.inArray(svgcontent, parents) === -1) {\n // Not a valid target element, so remove line\n $(curLine).remove();\n started = false;\n return {\n keep: false,\n element: null,\n started\n };\n }\n // Valid end element\n endElem = mouseTarget;\n\n const startId = startElem.id, endId = endElem.id;\n const connStr = startId + ' ' + endId;\n const altStr = endId + ' ' + startId;\n // Don't create connector if one already exists\n const dupe = $(svgcontent).find(connSel).filter(function () {\n const conn = this.getAttributeNS(seNs, 'connector');\n if (conn === connStr || conn === altStr) { return true; }\n return false;\n });\n if (dupe.length) {\n $(curLine).remove();\n return {\n keep: false,\n element: null,\n started: false\n };\n }\n\n const bb = svgCanvas.getStrokedBBox([endElem]);\n\n const pt = getBBintersect(startX, startY, bb, getOffset('start', curLine));\n setPoint(curLine, 'end', pt.x, pt.y, true);\n $(curLine)\n .data('c_start', startId)\n .data('c_end', endId)\n .data('end_bb', bb);\n seNs = svgCanvas.getEditorNS(true);\n curLine.setAttributeNS(seNs, 'se:connector', connStr);\n curLine.setAttribute('class', connSel.substr(1));\n curLine.setAttribute('opacity', 1);\n svgCanvas.addToSelection([curLine]);\n svgCanvas.moveToBottomSelectedElement();\n selManager.requestSelector(curLine).showGrips(false);\n started = false;\n return {\n keep: true,\n element: curLine,\n started\n };\n },\n selectedChanged (opts) {\n // TODO: Find better way to skip operations if no connectors are in use\n if (!$(svgcontent).find(connSel).length) { return; }\n\n if (svgCanvas.getMode() === 'connector') {\n svgCanvas.setMode('select');\n }\n\n // Use this to update the current selected elements\n selElems = opts.elems;\n\n let i = selElems.length;\n while (i--) {\n const elem = selElems[i];\n if (elem && elData(elem, 'c_start')) {\n selManager.requestSelector(elem).showGrips(false);\n if (opts.selectedElement && !opts.multiselected) {\n // TODO: Set up context tools and hide most regular line tools\n showPanel(true);\n } else {\n showPanel(false);\n }\n } else {\n showPanel(false);\n }\n }\n updateConnectors();\n },\n elementChanged (opts) {\n let elem = opts.elems[0];\n if (!elem) return;\n if (elem.tagName === 'svg' && elem.id === 'svgcontent') {\n // Update svgcontent (can change on import)\n svgcontent = elem;\n init();\n }\n\n // Has marker, so change offset\n if (\n elem.getAttribute('marker-start') ||\n elem.getAttribute('marker-mid') ||\n elem.getAttribute('marker-end')\n ) {\n const start = elem.getAttribute('marker-start');\n const mid = elem.getAttribute('marker-mid');\n const end = elem.getAttribute('marker-end');\n curLine = elem;\n $(elem)\n .data('start_off', Boolean(start))\n .data('end_off', Boolean(end));\n\n if (elem.tagName === 'line' && mid) {\n // Convert to polyline to accept mid-arrow\n\n const x1 = Number(elem.getAttribute('x1'));\n const x2 = Number(elem.getAttribute('x2'));\n const y1 = Number(elem.getAttribute('y1'));\n const y2 = Number(elem.getAttribute('y2'));\n const {id} = elem;\n\n const midPt = (' ' + ((x1 + x2) / 2) + ',' + ((y1 + y2) / 2) + ' ');\n const pline = addElem({\n element: 'polyline',\n attr: {\n points: (x1 + ',' + y1 + midPt + x2 + ',' + y2),\n stroke: elem.getAttribute('stroke'),\n 'stroke-width': elem.getAttribute('stroke-width'),\n 'marker-mid': mid,\n fill: 'none',\n opacity: elem.getAttribute('opacity') || 1\n }\n });\n $(elem).after(pline).remove();\n svgCanvas.clearSelection();\n pline.id = id;\n svgCanvas.addToSelection([pline]);\n elem = pline;\n }\n }\n // Update line if it's a connector\n if (elem.getAttribute('class') === connSel.substr(1)) {\n const start = getElem(elData(elem, 'c_start'));\n updateConnectors([start]);\n } else {\n updateConnectors();\n }\n },\n IDsUpdated (input) {\n const remove = [];\n input.elems.forEach(function (elem) {\n if ('se:connector' in elem.attr) {\n elem.attr['se:connector'] = elem.attr['se:connector'].split(' ')\n .map(function (oldID) { return input.changes[oldID]; }).join(' ');\n\n // Check validity - the field would be something like 'svg_21 svg_22', but\n // if one end is missing, it would be 'svg_21' and therefore fail this test\n if (!(/. ./).test(elem.attr['se:connector'])) {\n remove.push(elem.attr.id);\n }\n }\n });\n return {remove};\n },\n toolButtonStateUpdate (opts) {\n if (opts.nostroke) {\n if ($('#mode_connect').hasClass('tool_button_current')) {\n svgEditor.clickSelect();\n }\n }\n $('#mode_connect')\n .toggleClass('disabled', opts.nostroke);\n }\n };\n }\n};\n"],"names":["name","init","S","getBBintersect","getOffset","showPanel","setPoint","updateLine","findConnectors","updateConnectors","$","svgcontent","find","each","conn","getAttributeNS","seNs","setAttribute","connSel","substr","connData","split","sbb","svgCanvas","getStrokedBBox","getElem","ebb","data","getEditorNS","elems","connections","length","i","line","connector","elem","pre","is_start","bb","x","start_x","y","start_y","elData","altPre","bb2","srcX","width","srcY","height","pt","pt2","navigator","userAgent","includes","pts","points","len","numberOfItems","ptArr","j","getItem","join","selElems","connectors","addThis","add","parts","forEach","pos","key","part","undefined","document","getElementById","attributes","value","id","push","cElem","parents","parentNode","remove","diffX","diffY","setMid","svgroot","createSVGPoint","replaceItem","err","getAttribute","ptStart","ptEnd","on","connRules","appendTo","text","toggle","side","giveOffset","size","offset","extend","midX","midY","lenX","lenY","slope","Math","abs","ratio","svgEditor","canvas","importLocale","addElem","addSVGElementFromJson","selManager","selectorManager","strings","started","gse","groupSelectedElements","removeFromSelection","toArray","args","apply","mse","moveSelectedElements","cmd","buttons","type","icon","curConfig","imgPath","includeWith","button","isDefault","position","events","click","setMode","svgicons","map","Object","assign","addLangData","lang","langList","mouseDown","opts","e","event","startX","startY","mode","getMode","initStroke","mouseTarget","target","inArray","fo","closest","startElem","curLine","element","attr","getNextId","stroke","color","stroke_width","fill","opacity","style","mouseMove","zoom","getZoom","mouse_x","mouse_y","slen","getTransformList","clear","mouseUp","keep","endElem","startId","endId","connStr","altStr","dupe","filter","setAttributeNS","addToSelection","moveToBottomSelectedElement","requestSelector","showGrips","selectedChanged","selectedElement","multiselected","elementChanged","tagName","start","mid","end","Boolean","x1","Number","x2","y1","y2","midPt","pline","after","clearSelection","IDsUpdated","input","oldID","changes","test","toolButtonStateUpdate","nostroke","hasClass","clickSelect","toggleClass"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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A,CAAC,CAAC,eAAD,CAAD,CACGoN,WADH,CACe,UADf,EAC2BzE,IAAI,CAACsE,QADhC;AAED;AAjSI,eAnWM;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAsoBd;AAxoBY,CAAf;;;;"} \ No newline at end of file diff --git a/dist/editor/extensions/ext-eyedropper.js b/dist/editor/extensions/ext-eyedropper.js new file mode 100644 index 00000000..6799fb29 --- /dev/null +++ b/dist/editor/extensions/ext-eyedropper.js @@ -0,0 +1,1804 @@ +function _typeof(obj) { + "@babel/helpers - typeof"; + + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function (obj) { + return typeof obj; + }; + } else { + _typeof = function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); +} + +var REACT_ELEMENT_TYPE; + +function _jsx(type, props, key, children) { + if (!REACT_ELEMENT_TYPE) { + REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol["for"] && Symbol["for"]("react.element") || 0xeac7; + } + + var defaultProps = type && type.defaultProps; + var childrenLength = arguments.length - 3; + + if (!props && childrenLength !== 0) { + props = { + children: void 0 + }; + } + + if (childrenLength === 1) { + props.children = children; + } else if (childrenLength > 1) { + var childArray = new Array(childrenLength); + + for (var i = 0; i < childrenLength; i++) { + childArray[i] = arguments[i + 3]; + } + + props.children = childArray; + } + + if (props && defaultProps) { + for (var propName in defaultProps) { + if (props[propName] === void 0) { + props[propName] = defaultProps[propName]; + } + } + } else if (!props) { + props = defaultProps || {}; + } + + return { + $$typeof: REACT_ELEMENT_TYPE, + type: type, + key: key === undefined ? null : '' + key, + ref: null, + props: props, + _owner: null + }; +} + +function _asyncIterator(iterable) { + var method; + + if (typeof Symbol !== "undefined") { + if (Symbol.asyncIterator) { + method = iterable[Symbol.asyncIterator]; + if (method != null) return method.call(iterable); + } + + if (Symbol.iterator) { + method = iterable[Symbol.iterator]; + if (method != null) return method.call(iterable); + } + } + + throw new TypeError("Object is not async iterable"); +} + +function _AwaitValue(value) { + this.wrapped = value; +} + +function _AsyncGenerator(gen) { + var front, back; + + function send(key, arg) { + return new Promise(function (resolve, reject) { + var request = { + key: key, + arg: arg, + resolve: resolve, + reject: reject, + next: null + }; + + if (back) { + back = back.next = request; + } else { + front = back = request; + resume(key, arg); + } + }); + } + + function resume(key, arg) { + try { + var result = gen[key](arg); + var value = result.value; + var wrappedAwait = value instanceof _AwaitValue; + Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { + if (wrappedAwait) { + resume(key === "return" ? "return" : "next", arg); + return; + } + + settle(result.done ? "return" : "normal", arg); + }, function (err) { + resume("throw", err); + }); + } catch (err) { + settle("throw", err); + } + } + + function settle(type, value) { + switch (type) { + case "return": + front.resolve({ + value: value, + done: true + }); + break; + + case "throw": + front.reject(value); + break; + + default: + front.resolve({ + value: value, + done: false + }); + break; + } + + front = front.next; + + if (front) { + resume(front.key, front.arg); + } else { + back = null; + } + } + + this._invoke = send; + + if (typeof gen.return !== "function") { + this.return = undefined; + } +} + +if (typeof Symbol === "function" && Symbol.asyncIterator) { + _AsyncGenerator.prototype[Symbol.asyncIterator] = function () { + return this; + }; +} + +_AsyncGenerator.prototype.next = function (arg) { + return this._invoke("next", arg); +}; + +_AsyncGenerator.prototype.throw = function (arg) { + return this._invoke("throw", arg); +}; + +_AsyncGenerator.prototype.return = function (arg) { + return this._invoke("return", arg); +}; + +function _wrapAsyncGenerator(fn) { + return function () { + return new _AsyncGenerator(fn.apply(this, arguments)); + }; +} + +function _awaitAsyncGenerator(value) { + return new _AwaitValue(value); +} + +function _asyncGeneratorDelegate(inner, awaitWrap) { + var iter = {}, + waiting = false; + + function pump(key, value) { + waiting = true; + value = new Promise(function (resolve) { + resolve(inner[key](value)); + }); + return { + done: false, + value: awaitWrap(value) + }; + } + + ; + + if (typeof Symbol === "function" && Symbol.iterator) { + iter[Symbol.iterator] = function () { + return this; + }; + } + + iter.next = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("next", value); + }; + + if (typeof inner.throw === "function") { + iter.throw = function (value) { + if (waiting) { + waiting = false; + throw value; + } + + return pump("throw", value); + }; + } + + if (typeof inner.return === "function") { + iter.return = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("return", value); + }; + } + + return iter; +} + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { + try { + var info = gen[key](arg); + var value = info.value; + } catch (error) { + reject(error); + return; + } + + if (info.done) { + resolve(value); + } else { + Promise.resolve(value).then(_next, _throw); + } +} + +function _asyncToGenerator(fn) { + return function () { + var self = this, + args = arguments; + return new Promise(function (resolve, reject) { + var gen = fn.apply(self, args); + + function _next(value) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); + } + + function _throw(err) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); + } + + _next(undefined); + }); + }; +} + +function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +} + +function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } +} + +function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; +} + +function _defineEnumerableProperties(obj, descs) { + for (var key in descs) { + var desc = descs[key]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, key, desc); + } + + if (Object.getOwnPropertySymbols) { + var objectSymbols = Object.getOwnPropertySymbols(descs); + + for (var i = 0; i < objectSymbols.length; i++) { + var sym = objectSymbols[i]; + var desc = descs[sym]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, sym, desc); + } + } + + return obj; +} + +function _defaults(obj, defaults) { + var keys = Object.getOwnPropertyNames(defaults); + + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var value = Object.getOwnPropertyDescriptor(defaults, key); + + if (value && value.configurable && obj[key] === undefined) { + Object.defineProperty(obj, key, value); + } + } + + return obj; +} + +function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; +} + +function _extends() { + _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + + return _extends.apply(this, arguments); +} + +function _objectSpread(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? Object(arguments[i]) : {}; + var ownKeys = Object.keys(source); + + if (typeof Object.getOwnPropertySymbols === 'function') { + ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { + return Object.getOwnPropertyDescriptor(source, sym).enumerable; + })); + } + + ownKeys.forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } + + return target; +} + +function ownKeys(object, enumerableOnly) { + var keys = Object.keys(object); + + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(object); + if (enumerableOnly) symbols = symbols.filter(function (sym) { + return Object.getOwnPropertyDescriptor(object, sym).enumerable; + }); + keys.push.apply(keys, symbols); + } + + return keys; +} + +function _objectSpread2(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? arguments[i] : {}; + + if (i % 2) { + ownKeys(Object(source), true).forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } else if (Object.getOwnPropertyDescriptors) { + Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); + } else { + ownKeys(Object(source)).forEach(function (key) { + Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); + }); + } + } + + return target; +} + +function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function"); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + writable: true, + configurable: true + } + }); + if (superClass) _setPrototypeOf(subClass, superClass); +} + +function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + subClass.__proto__ = superClass; +} + +function _getPrototypeOf(o) { + _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { + return o.__proto__ || Object.getPrototypeOf(o); + }; + return _getPrototypeOf(o); +} + +function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + + return _setPrototypeOf(o, p); +} + +function _isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + + try { + Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); + return true; + } catch (e) { + return false; + } +} + +function _construct(Parent, args, Class) { + if (_isNativeReflectConstruct()) { + _construct = Reflect.construct; + } else { + _construct = function _construct(Parent, args, Class) { + var a = [null]; + a.push.apply(a, args); + var Constructor = Function.bind.apply(Parent, a); + var instance = new Constructor(); + if (Class) _setPrototypeOf(instance, Class.prototype); + return instance; + }; + } + + return _construct.apply(null, arguments); +} + +function _isNativeFunction(fn) { + return Function.toString.call(fn).indexOf("[native code]") !== -1; +} + +function _wrapNativeSuper(Class) { + var _cache = typeof Map === "function" ? new Map() : undefined; + + _wrapNativeSuper = function _wrapNativeSuper(Class) { + if (Class === null || !_isNativeFunction(Class)) return Class; + + if (typeof Class !== "function") { + throw new TypeError("Super expression must either be null or a function"); + } + + if (typeof _cache !== "undefined") { + if (_cache.has(Class)) return _cache.get(Class); + + _cache.set(Class, Wrapper); + } + + function Wrapper() { + return _construct(Class, arguments, _getPrototypeOf(this).constructor); + } + + Wrapper.prototype = Object.create(Class.prototype, { + constructor: { + value: Wrapper, + enumerable: false, + writable: true, + configurable: true + } + }); + return _setPrototypeOf(Wrapper, Class); + }; + + return _wrapNativeSuper(Class); +} + +function _instanceof(left, right) { + if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { + return !!right[Symbol.hasInstance](left); + } else { + return left instanceof right; + } +} + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; +} + +function _getRequireWildcardCache() { + if (typeof WeakMap !== "function") return null; + var cache = new WeakMap(); + + _getRequireWildcardCache = function () { + return cache; + }; + + return cache; +} + +function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } + + if (obj === null || typeof obj !== "object" && typeof obj !== "function") { + return { + default: obj + }; + } + + var cache = _getRequireWildcardCache(); + + if (cache && cache.has(obj)) { + return cache.get(obj); + } + + var newObj = {}; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + + if (desc && (desc.get || desc.set)) { + Object.defineProperty(newObj, key, desc); + } else { + newObj[key] = obj[key]; + } + } + } + + newObj.default = obj; + + if (cache) { + cache.set(obj, newObj); + } + + return newObj; +} + +function _newArrowCheck(innerThis, boundThis) { + if (innerThis !== boundThis) { + throw new TypeError("Cannot instantiate an arrow function"); + } +} + +function _objectDestructuringEmpty(obj) { + if (obj == null) throw new TypeError("Cannot destructure undefined"); +} + +function _objectWithoutPropertiesLoose(source, excluded) { + if (source == null) return {}; + var target = {}; + var sourceKeys = Object.keys(source); + var key, i; + + for (i = 0; i < sourceKeys.length; i++) { + key = sourceKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + target[key] = source[key]; + } + + return target; +} + +function _objectWithoutProperties(source, excluded) { + if (source == null) return {}; + + var target = _objectWithoutPropertiesLoose(source, excluded); + + var key, i; + + if (Object.getOwnPropertySymbols) { + var sourceSymbolKeys = Object.getOwnPropertySymbols(source); + + for (i = 0; i < sourceSymbolKeys.length; i++) { + key = sourceSymbolKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; + target[key] = source[key]; + } + } + + return target; +} + +function _assertThisInitialized(self) { + if (self === void 0) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return self; +} + +function _possibleConstructorReturn(self, call) { + if (call && (typeof call === "object" || typeof call === "function")) { + return call; + } + + return _assertThisInitialized(self); +} + +function _createSuper(Derived) { + var hasNativeReflectConstruct = _isNativeReflectConstruct(); + + return function _createSuperInternal() { + var Super = _getPrototypeOf(Derived), + result; + + if (hasNativeReflectConstruct) { + var NewTarget = _getPrototypeOf(this).constructor; + + result = Reflect.construct(Super, arguments, NewTarget); + } else { + result = Super.apply(this, arguments); + } + + return _possibleConstructorReturn(this, result); + }; +} + +function _superPropBase(object, property) { + while (!Object.prototype.hasOwnProperty.call(object, property)) { + object = _getPrototypeOf(object); + if (object === null) break; + } + + return object; +} + +function _get(target, property, receiver) { + if (typeof Reflect !== "undefined" && Reflect.get) { + _get = Reflect.get; + } else { + _get = function _get(target, property, receiver) { + var base = _superPropBase(target, property); + + if (!base) return; + var desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.get) { + return desc.get.call(receiver); + } + + return desc.value; + }; + } + + return _get(target, property, receiver || target); +} + +function set(target, property, value, receiver) { + if (typeof Reflect !== "undefined" && Reflect.set) { + set = Reflect.set; + } else { + set = function set(target, property, value, receiver) { + var base = _superPropBase(target, property); + + var desc; + + if (base) { + desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.set) { + desc.set.call(receiver, value); + return true; + } else if (!desc.writable) { + return false; + } + } + + desc = Object.getOwnPropertyDescriptor(receiver, property); + + if (desc) { + if (!desc.writable) { + return false; + } + + desc.value = value; + Object.defineProperty(receiver, property, desc); + } else { + _defineProperty(receiver, property, value); + } + + return true; + }; + } + + return set(target, property, value, receiver); +} + +function _set(target, property, value, receiver, isStrict) { + var s = set(target, property, value, receiver || target); + + if (!s && isStrict) { + throw new Error('failed to set property'); + } + + return value; +} + +function _taggedTemplateLiteral(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + return Object.freeze(Object.defineProperties(strings, { + raw: { + value: Object.freeze(raw) + } + })); +} + +function _taggedTemplateLiteralLoose(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + strings.raw = raw; + return strings; +} + +function _readOnlyError(name) { + throw new Error("\"" + name + "\" is read-only"); +} + +function _classNameTDZError(name) { + throw new Error("Class \"" + name + "\" cannot be referenced in computed property keys."); +} + +function _temporalUndefined() {} + +function _tdz(name) { + throw new ReferenceError(name + " is not defined - temporal dead zone"); +} + +function _temporalRef(val, name) { + return val === _temporalUndefined ? _tdz(name) : val; +} + +function _slicedToArray(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); +} + +function _slicedToArrayLoose(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimitLoose(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); +} + +function _toArray(arr) { + return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); +} + +function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); +} + +function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) return _arrayLikeToArray(arr); +} + +function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; +} + +function _maybeArrayLike(next, arr, i) { + if (arr && !Array.isArray(arr) && typeof arr.length === "number") { + var len = arr.length; + return _arrayLikeToArray(arr, i !== void 0 && i < len ? i : len); + } + + return next(arr, i); +} + +function _iterableToArray(iter) { + if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); +} + +function _iterableToArrayLimit(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"] != null) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; +} + +function _iterableToArrayLimitLoose(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + + for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { + _arr.push(_step.value); + + if (i && _arr.length === i) break; + } + + return _arr; +} + +function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if (typeof o === "string") return _arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + if (n === "Object" && o.constructor) n = o.constructor.name; + if (n === "Map" || n === "Set") return Array.from(o); + if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); +} + +function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) len = arr.length; + + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + + return arr2; +} + +function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); +} + +function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); +} + +function _createForOfIteratorHelper(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + + var F = function () {}; + + return { + s: F, + n: function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }, + e: function (e) { + throw e; + }, + f: F + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + var normalCompletion = true, + didErr = false, + err; + return { + s: function () { + it = o[Symbol.iterator](); + }, + n: function () { + var step = it.next(); + normalCompletion = step.done; + return step; + }, + e: function (e) { + didErr = true; + err = e; + }, + f: function () { + try { + if (!normalCompletion && it.return != null) it.return(); + } finally { + if (didErr) throw err; + } + } + }; +} + +function _createForOfIteratorHelperLoose(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + return function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + it = o[Symbol.iterator](); + return it.next.bind(it); +} + +function _skipFirstGeneratorNext(fn) { + return function () { + var it = fn.apply(this, arguments); + it.next(); + return it; + }; +} + +function _toPrimitive(input, hint) { + if (typeof input !== "object" || input === null) return input; + var prim = input[Symbol.toPrimitive]; + + if (prim !== undefined) { + var res = prim.call(input, hint || "default"); + if (typeof res !== "object") return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + + return (hint === "string" ? String : Number)(input); +} + +function _toPropertyKey(arg) { + var key = _toPrimitive(arg, "string"); + + return typeof key === "symbol" ? key : String(key); +} + +function _initializerWarningHelper(descriptor, context) { + throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.'); +} + +function _initializerDefineProperty(target, property, descriptor, context) { + if (!descriptor) return; + Object.defineProperty(target, property, { + enumerable: descriptor.enumerable, + configurable: descriptor.configurable, + writable: descriptor.writable, + value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 + }); +} + +function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { + var desc = {}; + Object.keys(descriptor).forEach(function (key) { + desc[key] = descriptor[key]; + }); + desc.enumerable = !!desc.enumerable; + desc.configurable = !!desc.configurable; + + if ('value' in desc || desc.initializer) { + desc.writable = true; + } + + desc = decorators.slice().reverse().reduce(function (desc, decorator) { + return decorator(target, property, desc) || desc; + }, desc); + + if (context && desc.initializer !== void 0) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = undefined; + } + + if (desc.initializer === void 0) { + Object.defineProperty(target, property, desc); + desc = null; + } + + return desc; +} + +var id = 0; + +function _classPrivateFieldLooseKey(name) { + return "__private_" + id++ + "_" + name; +} + +function _classPrivateFieldLooseBase(receiver, privateKey) { + if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { + throw new TypeError("attempted to use private field on non-instance"); + } + + return receiver; +} + +function _classPrivateFieldGet(receiver, privateMap) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to get private field on non-instance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; +} + +function _classPrivateFieldSet(receiver, privateMap, value) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to set private field on non-instance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; +} + +function _classPrivateFieldDestructureSet(receiver, privateMap) { + if (!privateMap.has(receiver)) { + throw new TypeError("attempted to set private field on non-instance"); + } + + var descriptor = privateMap.get(receiver); + + if (descriptor.set) { + if (!("__destrObj" in descriptor)) { + descriptor.__destrObj = { + set value(v) { + descriptor.set.call(receiver, v); + } + + }; + } + + return descriptor.__destrObj; + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + return descriptor; + } +} + +function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; +} + +function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; +} + +function _classStaticPrivateMethodGet(receiver, classConstructor, method) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + return method; +} + +function _classStaticPrivateMethodSet() { + throw new TypeError("attempted to set read only static private field"); +} + +function _decorate(decorators, factory, superClass, mixins) { + var api = _getDecoratorsApi(); + + if (mixins) { + for (var i = 0; i < mixins.length; i++) { + api = mixins[i](api); + } + } + + var r = factory(function initialize(O) { + api.initializeInstanceElements(O, decorated.elements); + }, superClass); + var decorated = api.decorateClass(_coalesceClassElements(r.d.map(_createElementDescriptor)), decorators); + api.initializeClassElements(r.F, decorated.elements); + return api.runClassFinishers(r.F, decorated.finishers); +} + +function _getDecoratorsApi() { + _getDecoratorsApi = function () { + return api; + }; + + var api = { + elementsDefinitionOrder: [["method"], ["field"]], + initializeInstanceElements: function (O, elements) { + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + if (element.kind === kind && element.placement === "own") { + this.defineClassElement(O, element); + } + }, this); + }, this); + }, + initializeClassElements: function (F, elements) { + var proto = F.prototype; + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + var placement = element.placement; + + if (element.kind === kind && (placement === "static" || placement === "prototype")) { + var receiver = placement === "static" ? F : proto; + this.defineClassElement(receiver, element); + } + }, this); + }, this); + }, + defineClassElement: function (receiver, element) { + var descriptor = element.descriptor; + + if (element.kind === "field") { + var initializer = element.initializer; + descriptor = { + enumerable: descriptor.enumerable, + writable: descriptor.writable, + configurable: descriptor.configurable, + value: initializer === void 0 ? void 0 : initializer.call(receiver) + }; + } + + Object.defineProperty(receiver, element.key, descriptor); + }, + decorateClass: function (elements, decorators) { + var newElements = []; + var finishers = []; + var placements = { + static: [], + prototype: [], + own: [] + }; + elements.forEach(function (element) { + this.addElementPlacement(element, placements); + }, this); + elements.forEach(function (element) { + if (!_hasDecorators(element)) return newElements.push(element); + var elementFinishersExtras = this.decorateElement(element, placements); + newElements.push(elementFinishersExtras.element); + newElements.push.apply(newElements, elementFinishersExtras.extras); + finishers.push.apply(finishers, elementFinishersExtras.finishers); + }, this); + + if (!decorators) { + return { + elements: newElements, + finishers: finishers + }; + } + + var result = this.decorateConstructor(newElements, decorators); + finishers.push.apply(finishers, result.finishers); + result.finishers = finishers; + return result; + }, + addElementPlacement: function (element, placements, silent) { + var keys = placements[element.placement]; + + if (!silent && keys.indexOf(element.key) !== -1) { + throw new TypeError("Duplicated element (" + element.key + ")"); + } + + keys.push(element.key); + }, + decorateElement: function (element, placements) { + var extras = []; + var finishers = []; + + for (var decorators = element.decorators, i = decorators.length - 1; i >= 0; i--) { + var keys = placements[element.placement]; + keys.splice(keys.indexOf(element.key), 1); + var elementObject = this.fromElementDescriptor(element); + var elementFinisherExtras = this.toElementFinisherExtras((0, decorators[i])(elementObject) || elementObject); + element = elementFinisherExtras.element; + this.addElementPlacement(element, placements); + + if (elementFinisherExtras.finisher) { + finishers.push(elementFinisherExtras.finisher); + } + + var newExtras = elementFinisherExtras.extras; + + if (newExtras) { + for (var j = 0; j < newExtras.length; j++) { + this.addElementPlacement(newExtras[j], placements); + } + + extras.push.apply(extras, newExtras); + } + } + + return { + element: element, + finishers: finishers, + extras: extras + }; + }, + decorateConstructor: function (elements, decorators) { + var finishers = []; + + for (var i = decorators.length - 1; i >= 0; i--) { + var obj = this.fromClassDescriptor(elements); + var elementsAndFinisher = this.toClassDescriptor((0, decorators[i])(obj) || obj); + + if (elementsAndFinisher.finisher !== undefined) { + finishers.push(elementsAndFinisher.finisher); + } + + if (elementsAndFinisher.elements !== undefined) { + elements = elementsAndFinisher.elements; + + for (var j = 0; j < elements.length - 1; j++) { + for (var k = j + 1; k < elements.length; k++) { + if (elements[j].key === elements[k].key && elements[j].placement === elements[k].placement) { + throw new TypeError("Duplicated element (" + elements[j].key + ")"); + } + } + } + } + } + + return { + elements: elements, + finishers: finishers + }; + }, + fromElementDescriptor: function (element) { + var obj = { + kind: element.kind, + key: element.key, + placement: element.placement, + descriptor: element.descriptor + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + if (element.kind === "field") obj.initializer = element.initializer; + return obj; + }, + toElementDescriptors: function (elementObjects) { + if (elementObjects === undefined) return; + return _toArray(elementObjects).map(function (elementObject) { + var element = this.toElementDescriptor(elementObject); + this.disallowProperty(elementObject, "finisher", "An element descriptor"); + this.disallowProperty(elementObject, "extras", "An element descriptor"); + return element; + }, this); + }, + toElementDescriptor: function (elementObject) { + var kind = String(elementObject.kind); + + if (kind !== "method" && kind !== "field") { + throw new TypeError('An element descriptor\'s .kind property must be either "method" or' + ' "field", but a decorator created an element descriptor with' + ' .kind "' + kind + '"'); + } + + var key = _toPropertyKey(elementObject.key); + + var placement = String(elementObject.placement); + + if (placement !== "static" && placement !== "prototype" && placement !== "own") { + throw new TypeError('An element descriptor\'s .placement property must be one of "static",' + ' "prototype" or "own", but a decorator created an element descriptor' + ' with .placement "' + placement + '"'); + } + + var descriptor = elementObject.descriptor; + this.disallowProperty(elementObject, "elements", "An element descriptor"); + var element = { + kind: kind, + key: key, + placement: placement, + descriptor: Object.assign({}, descriptor) + }; + + if (kind !== "field") { + this.disallowProperty(elementObject, "initializer", "A method descriptor"); + } else { + this.disallowProperty(descriptor, "get", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "set", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "value", "The property descriptor of a field descriptor"); + element.initializer = elementObject.initializer; + } + + return element; + }, + toElementFinisherExtras: function (elementObject) { + var element = this.toElementDescriptor(elementObject); + + var finisher = _optionalCallableProperty(elementObject, "finisher"); + + var extras = this.toElementDescriptors(elementObject.extras); + return { + element: element, + finisher: finisher, + extras: extras + }; + }, + fromClassDescriptor: function (elements) { + var obj = { + kind: "class", + elements: elements.map(this.fromElementDescriptor, this) + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + return obj; + }, + toClassDescriptor: function (obj) { + var kind = String(obj.kind); + + if (kind !== "class") { + throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator' + ' created a class descriptor with .kind "' + kind + '"'); + } + + this.disallowProperty(obj, "key", "A class descriptor"); + this.disallowProperty(obj, "placement", "A class descriptor"); + this.disallowProperty(obj, "descriptor", "A class descriptor"); + this.disallowProperty(obj, "initializer", "A class descriptor"); + this.disallowProperty(obj, "extras", "A class descriptor"); + + var finisher = _optionalCallableProperty(obj, "finisher"); + + var elements = this.toElementDescriptors(obj.elements); + return { + elements: elements, + finisher: finisher + }; + }, + runClassFinishers: function (constructor, finishers) { + for (var i = 0; i < finishers.length; i++) { + var newConstructor = (0, finishers[i])(constructor); + + if (newConstructor !== undefined) { + if (typeof newConstructor !== "function") { + throw new TypeError("Finishers must return a constructor."); + } + + constructor = newConstructor; + } + } + + return constructor; + }, + disallowProperty: function (obj, name, objectType) { + if (obj[name] !== undefined) { + throw new TypeError(objectType + " can't have a ." + name + " property."); + } + } + }; + return api; +} + +function _createElementDescriptor(def) { + var key = _toPropertyKey(def.key); + + var descriptor; + + if (def.kind === "method") { + descriptor = { + value: def.value, + writable: true, + configurable: true, + enumerable: false + }; + } else if (def.kind === "get") { + descriptor = { + get: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "set") { + descriptor = { + set: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "field") { + descriptor = { + configurable: true, + writable: true, + enumerable: true + }; + } + + var element = { + kind: def.kind === "field" ? "field" : "method", + key: key, + placement: def.static ? "static" : def.kind === "field" ? "own" : "prototype", + descriptor: descriptor + }; + if (def.decorators) element.decorators = def.decorators; + if (def.kind === "field") element.initializer = def.value; + return element; +} + +function _coalesceGetterSetter(element, other) { + if (element.descriptor.get !== undefined) { + other.descriptor.get = element.descriptor.get; + } else { + other.descriptor.set = element.descriptor.set; + } +} + +function _coalesceClassElements(elements) { + var newElements = []; + + var isSameElement = function (other) { + return other.kind === "method" && other.key === element.key && other.placement === element.placement; + }; + + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + var other; + + if (element.kind === "method" && (other = newElements.find(isSameElement))) { + if (_isDataDescriptor(element.descriptor) || _isDataDescriptor(other.descriptor)) { + if (_hasDecorators(element) || _hasDecorators(other)) { + throw new ReferenceError("Duplicated methods (" + element.key + ") can't be decorated."); + } + + other.descriptor = element.descriptor; + } else { + if (_hasDecorators(element)) { + if (_hasDecorators(other)) { + throw new ReferenceError("Decorators can't be placed on different accessors with for " + "the same property (" + element.key + ")."); + } + + other.decorators = element.decorators; + } + + _coalesceGetterSetter(element, other); + } + } else { + newElements.push(element); + } + } + + return newElements; +} + +function _hasDecorators(element) { + return element.decorators && element.decorators.length; +} + +function _isDataDescriptor(desc) { + return desc !== undefined && !(desc.value === undefined && desc.writable === undefined); +} + +function _optionalCallableProperty(obj, name) { + var value = obj[name]; + + if (value !== undefined && typeof value !== "function") { + throw new TypeError("Expected '" + name + "' to be a function"); + } + + return value; +} + +function _classPrivateMethodGet(receiver, privateSet, fn) { + if (!privateSet.has(receiver)) { + throw new TypeError("attempted to get private field on non-instance"); + } + + return fn; +} + +function _classPrivateMethodSet() { + throw new TypeError("attempted to reassign private method"); +} + +function _wrapRegExp(re, groups) { + _wrapRegExp = function (re, groups) { + return new BabelRegExp(re, undefined, groups); + }; + + var _RegExp = _wrapNativeSuper(RegExp); + + var _super = RegExp.prototype; + + var _groups = new WeakMap(); + + function BabelRegExp(re, flags, groups) { + var _this = _RegExp.call(this, re, flags); + + _groups.set(_this, groups || _groups.get(re)); + + return _this; + } + + _inherits(BabelRegExp, _RegExp); + + BabelRegExp.prototype.exec = function (str) { + var result = _super.exec.call(this, str); + + if (result) result.groups = buildGroups(result, this); + return result; + }; + + BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { + if (typeof substitution === "string") { + var groups = _groups.get(this); + + return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { + return "$" + groups[name]; + })); + } else if (typeof substitution === "function") { + var _this = this; + + return _super[Symbol.replace].call(this, str, function () { + var args = []; + args.push.apply(args, arguments); + + if (typeof args[args.length - 1] !== "object") { + args.push(buildGroups(args, _this)); + } + + return substitution.apply(this, args); + }); + } else { + return _super[Symbol.replace].call(this, str, substitution); + } + }; + + function buildGroups(result, re) { + var g = _groups.get(re); + + return Object.keys(g).reduce(function (groups, name) { + groups[name] = result[g[name]]; + return groups; + }, Object.create(null)); + } + + return _wrapRegExp.apply(this, arguments); +} + +var eyedropperIcon = "eyedropper-icon.xml"; + +var extEyedropper = { + name: 'eyedropper', + init: function init(S) { + var _this = this; + + return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { + var strings, svgEditor, $, ChangeElementCommand, svgCanvas, addToHistory, currentStyle, getStyle, buttons; + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + getStyle = function _getStyle(opts) { + // if we are in eyedropper mode, we don't want to disable the eye-dropper tool + var mode = svgCanvas.getMode(); + + if (mode === 'eyedropper') { + return; + } + + var tool = $('#tool_eyedropper'); // enable-eye-dropper if one element is selected + + var elem = null; + + if (!opts.multiselected && opts.elems[0] && !['svg', 'g', 'use'].includes(opts.elems[0].nodeName)) { + elem = opts.elems[0]; + tool.removeClass('disabled'); // grab the current style + + currentStyle.fillPaint = elem.getAttribute('fill') || 'black'; + currentStyle.fillOpacity = elem.getAttribute('fill-opacity') || 1.0; + currentStyle.strokePaint = elem.getAttribute('stroke'); + currentStyle.strokeOpacity = elem.getAttribute('stroke-opacity') || 1.0; + currentStyle.strokeWidth = elem.getAttribute('stroke-width'); + currentStyle.strokeDashArray = elem.getAttribute('stroke-dasharray'); + currentStyle.strokeLinecap = elem.getAttribute('stroke-linecap'); + currentStyle.strokeLinejoin = elem.getAttribute('stroke-linejoin'); + currentStyle.opacity = elem.getAttribute('opacity') || 1.0; // disable eye-dropper tool + } else { + tool.addClass('disabled'); + } + }; + + _context.next = 3; + return S.importLocale(); + + case 3: + strings = _context.sent; + svgEditor = _this; + $ = S.$, ChangeElementCommand = S.ChangeElementCommand, svgCanvas = svgEditor.canvas, addToHistory = function addToHistory(cmd) { + svgCanvas.undoMgr.addCommandToHistory(cmd); + }, currentStyle = { + fillPaint: 'red', + fillOpacity: 1.0, + strokePaint: 'black', + strokeOpacity: 1.0, + strokeWidth: 5, + strokeDashArray: null, + opacity: 1.0, + strokeLinecap: 'butt', + strokeLinejoin: 'miter' + }; + /** + * + * @param {module:svgcanvas.SvgCanvas#event:ext_selectedChanged|module:svgcanvas.SvgCanvas#event:ext_elementChanged} opts + * @returns {void} + */ + + buttons = [{ + id: 'tool_eyedropper', + icon: svgEditor.curConfig.extIconsPath + 'eyedropper.png', + type: 'mode', + events: { + click: function click() { + svgCanvas.setMode('eyedropper'); + } + } + }]; + return _context.abrupt("return", { + name: strings.name, + svgicons: svgEditor.curConfig.extIconsPath + 'eyedropper-icon.xml', + buttons: strings.buttons.map(function (button, i) { + return Object.assign(buttons[i], button); + }), + // if we have selected an element, grab its paint and enable the eye dropper button + selectedChanged: getStyle, + elementChanged: getStyle, + mouseDown: function mouseDown(opts) { + var mode = svgCanvas.getMode(); + + if (mode === 'eyedropper') { + var e = opts.event; + var target = e.target; + + if (!['svg', 'g', 'use'].includes(target.nodeName)) { + var changes = {}; + + var change = function change(elem, attrname, newvalue) { + changes[attrname] = elem.getAttribute(attrname); + elem.setAttribute(attrname, newvalue); + }; + + if (currentStyle.fillPaint) { + change(target, 'fill', currentStyle.fillPaint); + } + + if (currentStyle.fillOpacity) { + change(target, 'fill-opacity', currentStyle.fillOpacity); + } + + if (currentStyle.strokePaint) { + change(target, 'stroke', currentStyle.strokePaint); + } + + if (currentStyle.strokeOpacity) { + change(target, 'stroke-opacity', currentStyle.strokeOpacity); + } + + if (currentStyle.strokeWidth) { + change(target, 'stroke-width', currentStyle.strokeWidth); + } + + if (currentStyle.strokeDashArray) { + change(target, 'stroke-dasharray', currentStyle.strokeDashArray); + } + + if (currentStyle.opacity) { + change(target, 'opacity', currentStyle.opacity); + } + + if (currentStyle.strokeLinecap) { + change(target, 'stroke-linecap', currentStyle.strokeLinecap); + } + + if (currentStyle.strokeLinejoin) { + change(target, 'stroke-linejoin', currentStyle.strokeLinejoin); + } + + addToHistory(new ChangeElementCommand(target, changes)); + } + } + } + }); + + case 8: + case "end": + return _context.stop(); + } + } + }, _callee); + }))(); + } +}; + +export default extEyedropper; +//# sourceMappingURL=ext-eyedropper.js.map diff --git a/dist/editor/extensions/ext-eyedropper.js.map b/dist/editor/extensions/ext-eyedropper.js.map new file mode 100644 index 00000000..8d2bbbd9 --- /dev/null +++ b/dist/editor/extensions/ext-eyedropper.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ext-eyedropper.js","sources":["../../../src/editor/extensions/eyedropper-icon.xml","../../../src/editor/extensions/ext-eyedropper.js"],"sourcesContent":["export default \"eyedropper-icon.xml\"","/**\n * @file ext-eyedropper.js\n *\n * @license MIT\n *\n * @copyright 2010 Jeff Schiller\n *\n */\n\nimport './eyedropper-icon.xml';\n\nexport default {\n name: 'eyedropper',\n async init (S) {\n const strings = await S.importLocale();\n const svgEditor = this;\n const {$, ChangeElementCommand} = S, // , svgcontent,\n // svgdoc = S.svgroot.parentNode.ownerDocument,\n svgCanvas = svgEditor.canvas,\n addToHistory = function (cmd) { svgCanvas.undoMgr.addCommandToHistory(cmd); },\n currentStyle = {\n fillPaint: 'red', fillOpacity: 1.0,\n strokePaint: 'black', strokeOpacity: 1.0,\n strokeWidth: 5, strokeDashArray: null,\n opacity: 1.0,\n strokeLinecap: 'butt',\n strokeLinejoin: 'miter'\n };\n\n /**\n *\n * @param {module:svgcanvas.SvgCanvas#event:ext_selectedChanged|module:svgcanvas.SvgCanvas#event:ext_elementChanged} opts\n * @returns {void}\n */\n function getStyle (opts) {\n // if we are in eyedropper mode, we don't want to disable the eye-dropper tool\n const mode = svgCanvas.getMode();\n if (mode === 'eyedropper') { return; }\n\n const tool = $('#tool_eyedropper');\n // enable-eye-dropper if one element is selected\n let elem = null;\n if (!opts.multiselected && opts.elems[0] &&\n !['svg', 'g', 'use'].includes(opts.elems[0].nodeName)\n ) {\n elem = opts.elems[0];\n tool.removeClass('disabled');\n // grab the current style\n currentStyle.fillPaint = elem.getAttribute('fill') || 'black';\n currentStyle.fillOpacity = elem.getAttribute('fill-opacity') || 1.0;\n currentStyle.strokePaint = elem.getAttribute('stroke');\n currentStyle.strokeOpacity = elem.getAttribute('stroke-opacity') || 1.0;\n currentStyle.strokeWidth = elem.getAttribute('stroke-width');\n currentStyle.strokeDashArray = elem.getAttribute('stroke-dasharray');\n currentStyle.strokeLinecap = elem.getAttribute('stroke-linecap');\n currentStyle.strokeLinejoin = elem.getAttribute('stroke-linejoin');\n currentStyle.opacity = elem.getAttribute('opacity') || 1.0;\n // disable eye-dropper tool\n } else {\n tool.addClass('disabled');\n }\n }\n\n const buttons = [\n {\n id: 'tool_eyedropper',\n icon: svgEditor.curConfig.extIconsPath + 'eyedropper.png',\n type: 'mode',\n events: {\n click () {\n svgCanvas.setMode('eyedropper');\n }\n }\n }\n ];\n\n return {\n name: strings.name,\n svgicons: svgEditor.curConfig.extIconsPath + 'eyedropper-icon.xml',\n buttons: strings.buttons.map((button, i) => {\n return Object.assign(buttons[i], button);\n }),\n\n // if we have selected an element, grab its paint and enable the eye dropper button\n selectedChanged: getStyle,\n elementChanged: getStyle,\n\n mouseDown (opts) {\n const mode = svgCanvas.getMode();\n if (mode === 'eyedropper') {\n const e = opts.event;\n const {target} = e;\n if (!['svg', 'g', 'use'].includes(target.nodeName)) {\n const changes = {};\n\n const change = function (elem, attrname, newvalue) {\n changes[attrname] = elem.getAttribute(attrname);\n elem.setAttribute(attrname, newvalue);\n };\n\n if (currentStyle.fillPaint) { change(target, 'fill', currentStyle.fillPaint); }\n if (currentStyle.fillOpacity) { change(target, 'fill-opacity', currentStyle.fillOpacity); }\n if (currentStyle.strokePaint) { change(target, 'stroke', currentStyle.strokePaint); }\n if (currentStyle.strokeOpacity) { change(target, 'stroke-opacity', currentStyle.strokeOpacity); }\n if (currentStyle.strokeWidth) { change(target, 'stroke-width', currentStyle.strokeWidth); }\n if (currentStyle.strokeDashArray) { change(target, 'stroke-dasharray', currentStyle.strokeDashArray); }\n if (currentStyle.opacity) { change(target, 'opacity', currentStyle.opacity); }\n if (currentStyle.strokeLinecap) { change(target, 'stroke-linecap', currentStyle.strokeLinecap); }\n if (currentStyle.strokeLinejoin) { change(target, 'stroke-linejoin', currentStyle.strokeLinejoin); }\n\n addToHistory(new ChangeElementCommand(target, changes));\n }\n }\n }\n };\n }\n};\n"],"names":["name","init","S","getStyle","opts","mode","svgCanvas","getMode","tool","$","elem","multiselected","elems","includes","nodeName","removeClass","currentStyle","fillPaint","getAttribute","fillOpacity","strokePaint","strokeOpacity","strokeWidth","strokeDashArray","strokeLinecap","strokeLinejoin","opacity","addClass","importLocale","strings","svgEditor","ChangeElementCommand","canvas","addToHistory","cmd","undoMgr","addCommandToHistory","buttons","id","icon","curConfig","extIconsPath","type","events","click","setMode","svgicons","map","button","i","Object","assign","selectedChanged","elementChanged","mouseDown","e","event","target","changes","change","attrname","newvalue","setAttribute"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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O,eAA1C,CAAN;AAAmE;;AACvG,0BAAIP,YAAY,CAACU,OAAjB,EAA0B;AAAEiC,wBAAAA,MAAM,CAACF,MAAD,EAAS,SAAT,EAAoBzC,YAAY,CAACU,OAAjC,CAAN;AAAkD;;AAC9E,0BAAIV,YAAY,CAACQ,aAAjB,EAAgC;AAAEmC,wBAAAA,MAAM,CAACF,MAAD,EAAS,gBAAT,EAA2BzC,YAAY,CAACQ,aAAxC,CAAN;AAA+D;;AACjG,0BAAIR,YAAY,CAACS,cAAjB,EAAiC;AAAEkC,wBAAAA,MAAM,CAACF,MAAD,EAAS,iBAAT,EAA4BzC,YAAY,CAACS,cAAzC,CAAN;AAAiE;;AAEpGQ,sBAAAA,YAAY,CAAC,IAAIF,oBAAJ,CAAyB0B,MAAzB,EAAiCC,OAAjC,CAAD,CAAZ;AACD;AACF;AACF;AArCI,eA/DM;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAsGd;AAxGY,CAAf;;;;"} \ No newline at end of file diff --git a/dist/editor/extensions/ext-foreignobject.js b/dist/editor/extensions/ext-foreignobject.js new file mode 100644 index 00000000..8175f9b8 --- /dev/null +++ b/dist/editor/extensions/ext-foreignobject.js @@ -0,0 +1,1965 @@ +function _typeof(obj) { + "@babel/helpers - typeof"; + + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function (obj) { + return typeof obj; + }; + } else { + _typeof = function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); +} + +var REACT_ELEMENT_TYPE; + +function _jsx(type, props, key, children) { + if (!REACT_ELEMENT_TYPE) { + REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol["for"] && Symbol["for"]("react.element") || 0xeac7; + } + + var defaultProps = type && type.defaultProps; + var childrenLength = arguments.length - 3; + + if (!props && childrenLength !== 0) { + props = { + children: void 0 + }; + } + + if (childrenLength === 1) { + props.children = children; + } else if (childrenLength > 1) { + var childArray = new Array(childrenLength); + + for (var i = 0; i < childrenLength; i++) { + childArray[i] = arguments[i + 3]; + } + + props.children = childArray; + } + + if (props && defaultProps) { + for (var propName in defaultProps) { + if (props[propName] === void 0) { + props[propName] = defaultProps[propName]; + } + } + } else if (!props) { + props = defaultProps || {}; + } + + return { + $$typeof: REACT_ELEMENT_TYPE, + type: type, + key: key === undefined ? null : '' + key, + ref: null, + props: props, + _owner: null + }; +} + +function _asyncIterator(iterable) { + var method; + + if (typeof Symbol !== "undefined") { + if (Symbol.asyncIterator) { + method = iterable[Symbol.asyncIterator]; + if (method != null) return method.call(iterable); + } + + if (Symbol.iterator) { + method = iterable[Symbol.iterator]; + if (method != null) return method.call(iterable); + } + } + + throw new TypeError("Object is not async iterable"); +} + +function _AwaitValue(value) { + this.wrapped = value; +} + +function _AsyncGenerator(gen) { + var front, back; + + function send(key, arg) { + return new Promise(function (resolve, reject) { + var request = { + key: key, + arg: arg, + resolve: resolve, + reject: reject, + next: null + }; + + if (back) { + back = back.next = request; + } else { + front = back = request; + resume(key, arg); + } + }); + } + + function resume(key, arg) { + try { + var result = gen[key](arg); + var value = result.value; + var wrappedAwait = value instanceof _AwaitValue; + Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { + if (wrappedAwait) { + resume(key === "return" ? "return" : "next", arg); + return; + } + + settle(result.done ? "return" : "normal", arg); + }, function (err) { + resume("throw", err); + }); + } catch (err) { + settle("throw", err); + } + } + + function settle(type, value) { + switch (type) { + case "return": + front.resolve({ + value: value, + done: true + }); + break; + + case "throw": + front.reject(value); + break; + + default: + front.resolve({ + value: value, + done: false + }); + break; + } + + front = front.next; + + if (front) { + resume(front.key, front.arg); + } else { + back = null; + } + } + + this._invoke = send; + + if (typeof gen.return !== "function") { + this.return = undefined; + } +} + +if (typeof Symbol === "function" && Symbol.asyncIterator) { + _AsyncGenerator.prototype[Symbol.asyncIterator] = function () { + return this; + }; +} + +_AsyncGenerator.prototype.next = function (arg) { + return this._invoke("next", arg); +}; + +_AsyncGenerator.prototype.throw = function (arg) { + return this._invoke("throw", arg); +}; + +_AsyncGenerator.prototype.return = function (arg) { + return this._invoke("return", arg); +}; + +function _wrapAsyncGenerator(fn) { + return function () { + return new _AsyncGenerator(fn.apply(this, arguments)); + }; +} + +function _awaitAsyncGenerator(value) { + return new _AwaitValue(value); +} + +function _asyncGeneratorDelegate(inner, awaitWrap) { + var iter = {}, + waiting = false; + + function pump(key, value) { + waiting = true; + value = new Promise(function (resolve) { + resolve(inner[key](value)); + }); + return { + done: false, + value: awaitWrap(value) + }; + } + + ; + + if (typeof Symbol === "function" && Symbol.iterator) { + iter[Symbol.iterator] = function () { + return this; + }; + } + + iter.next = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("next", value); + }; + + if (typeof inner.throw === "function") { + iter.throw = function (value) { + if (waiting) { + waiting = false; + throw value; + } + + return pump("throw", value); + }; + } + + if (typeof inner.return === "function") { + iter.return = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("return", value); + }; + } + + return iter; +} + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { + try { + var info = gen[key](arg); + var value = info.value; + } catch (error) { + reject(error); + return; + } + + if (info.done) { + resolve(value); + } else { + Promise.resolve(value).then(_next, _throw); + } +} + +function _asyncToGenerator(fn) { + return function () { + var self = this, + args = arguments; + return new Promise(function (resolve, reject) { + var gen = fn.apply(self, args); + + function _next(value) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); + } + + function _throw(err) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); + } + + _next(undefined); + }); + }; +} + +function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +} + +function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } +} + +function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; +} + +function _defineEnumerableProperties(obj, descs) { + for (var key in descs) { + var desc = descs[key]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, key, desc); + } + + if (Object.getOwnPropertySymbols) { + var objectSymbols = Object.getOwnPropertySymbols(descs); + + for (var i = 0; i < objectSymbols.length; i++) { + var sym = objectSymbols[i]; + var desc = descs[sym]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, sym, desc); + } + } + + return obj; +} + +function _defaults(obj, defaults) { + var keys = Object.getOwnPropertyNames(defaults); + + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var value = Object.getOwnPropertyDescriptor(defaults, key); + + if (value && value.configurable && obj[key] === undefined) { + Object.defineProperty(obj, key, value); + } + } + + return obj; +} + +function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; +} + +function _extends() { + _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + + return _extends.apply(this, arguments); +} + +function _objectSpread(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? Object(arguments[i]) : {}; + var ownKeys = Object.keys(source); + + if (typeof Object.getOwnPropertySymbols === 'function') { + ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { + return Object.getOwnPropertyDescriptor(source, sym).enumerable; + })); + } + + ownKeys.forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } + + return target; +} + +function ownKeys(object, enumerableOnly) { + var keys = Object.keys(object); + + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(object); + if (enumerableOnly) symbols = symbols.filter(function (sym) { + return Object.getOwnPropertyDescriptor(object, sym).enumerable; + }); + keys.push.apply(keys, symbols); + } + + return keys; +} + +function _objectSpread2(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? arguments[i] : {}; + + if (i % 2) { + ownKeys(Object(source), true).forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } else if (Object.getOwnPropertyDescriptors) { + Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); + } else { + ownKeys(Object(source)).forEach(function (key) { + Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); + }); + } + } + + return target; +} + +function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function"); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + writable: true, + configurable: true + } + }); + if (superClass) _setPrototypeOf(subClass, superClass); +} + +function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + subClass.__proto__ = superClass; +} + +function _getPrototypeOf(o) { + _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { + return o.__proto__ || Object.getPrototypeOf(o); + }; + return _getPrototypeOf(o); +} + +function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + + return _setPrototypeOf(o, p); +} + +function _isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + + try { + Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); + return true; + } catch (e) { + return false; + } +} + +function _construct(Parent, args, Class) { + if (_isNativeReflectConstruct()) { + _construct = Reflect.construct; + } else { + _construct = function _construct(Parent, args, Class) { + var a = [null]; + a.push.apply(a, args); + var Constructor = Function.bind.apply(Parent, a); + var instance = new Constructor(); + if (Class) _setPrototypeOf(instance, Class.prototype); + return instance; + }; + } + + return _construct.apply(null, arguments); +} + +function _isNativeFunction(fn) { + return Function.toString.call(fn).indexOf("[native code]") !== -1; +} + +function _wrapNativeSuper(Class) { + var _cache = typeof Map === "function" ? new Map() : undefined; + + _wrapNativeSuper = function _wrapNativeSuper(Class) { + if (Class === null || !_isNativeFunction(Class)) return Class; + + if (typeof Class !== "function") { + throw new TypeError("Super expression must either be null or a function"); + } + + if (typeof _cache !== "undefined") { + if (_cache.has(Class)) return _cache.get(Class); + + _cache.set(Class, Wrapper); + } + + function Wrapper() { + return _construct(Class, arguments, _getPrototypeOf(this).constructor); + } + + Wrapper.prototype = Object.create(Class.prototype, { + constructor: { + value: Wrapper, + enumerable: false, + writable: true, + configurable: true + } + }); + return _setPrototypeOf(Wrapper, Class); + }; + + return _wrapNativeSuper(Class); +} + +function _instanceof(left, right) { + if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { + return !!right[Symbol.hasInstance](left); + } else { + return left instanceof right; + } +} + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; +} + +function _getRequireWildcardCache() { + if (typeof WeakMap !== "function") return null; + var cache = new WeakMap(); + + _getRequireWildcardCache = function () { + return cache; + }; + + return cache; +} + +function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } + + if (obj === null || typeof obj !== "object" && typeof obj !== "function") { + return { + default: obj + }; + } + + var cache = _getRequireWildcardCache(); + + if (cache && cache.has(obj)) { + return cache.get(obj); + } + + var newObj = {}; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + + if (desc && (desc.get || desc.set)) { + Object.defineProperty(newObj, key, desc); + } else { + newObj[key] = obj[key]; + } + } + } + + newObj.default = obj; + + if (cache) { + cache.set(obj, newObj); + } + + return newObj; +} + +function _newArrowCheck(innerThis, boundThis) { + if (innerThis !== boundThis) { + throw new TypeError("Cannot instantiate an arrow function"); + } +} + +function _objectDestructuringEmpty(obj) { + if (obj == null) throw new TypeError("Cannot destructure undefined"); +} + +function _objectWithoutPropertiesLoose(source, excluded) { + if (source == null) return {}; + var target = {}; + var sourceKeys = Object.keys(source); + var key, i; + + for (i = 0; i < sourceKeys.length; i++) { + key = sourceKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + target[key] = source[key]; + } + + return target; +} + +function _objectWithoutProperties(source, excluded) { + if (source == null) return {}; + + var target = _objectWithoutPropertiesLoose(source, excluded); + + var key, i; + + if (Object.getOwnPropertySymbols) { + var sourceSymbolKeys = Object.getOwnPropertySymbols(source); + + for (i = 0; i < sourceSymbolKeys.length; i++) { + key = sourceSymbolKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; + target[key] = source[key]; + } + } + + return target; +} + +function _assertThisInitialized(self) { + if (self === void 0) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return self; +} + +function _possibleConstructorReturn(self, call) { + if (call && (typeof call === "object" || typeof call === "function")) { + return call; + } + + return _assertThisInitialized(self); +} + +function _createSuper(Derived) { + var hasNativeReflectConstruct = _isNativeReflectConstruct(); + + return function _createSuperInternal() { + var Super = _getPrototypeOf(Derived), + result; + + if (hasNativeReflectConstruct) { + var NewTarget = _getPrototypeOf(this).constructor; + + result = Reflect.construct(Super, arguments, NewTarget); + } else { + result = Super.apply(this, arguments); + } + + return _possibleConstructorReturn(this, result); + }; +} + +function _superPropBase(object, property) { + while (!Object.prototype.hasOwnProperty.call(object, property)) { + object = _getPrototypeOf(object); + if (object === null) break; + } + + return object; +} + +function _get(target, property, receiver) { + if (typeof Reflect !== "undefined" && Reflect.get) { + _get = Reflect.get; + } else { + _get = function _get(target, property, receiver) { + var base = _superPropBase(target, property); + + if (!base) return; + var desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.get) { + return desc.get.call(receiver); + } + + return desc.value; + }; + } + + return _get(target, property, receiver || target); +} + +function set(target, property, value, receiver) { + if (typeof Reflect !== "undefined" && Reflect.set) { + set = Reflect.set; + } else { + set = function set(target, property, value, receiver) { + var base = _superPropBase(target, property); + + var desc; + + if (base) { + desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.set) { + desc.set.call(receiver, value); + return true; + } else if (!desc.writable) { + return false; + } + } + + desc = Object.getOwnPropertyDescriptor(receiver, property); + + if (desc) { + if (!desc.writable) { + return false; + } + + desc.value = value; + Object.defineProperty(receiver, property, desc); + } else { + _defineProperty(receiver, property, value); + } + + return true; + }; + } + + return set(target, property, value, receiver); +} + +function _set(target, property, value, receiver, isStrict) { + var s = set(target, property, value, receiver || target); + + if (!s && isStrict) { + throw new Error('failed to set property'); + } + + return value; +} + +function _taggedTemplateLiteral(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + return Object.freeze(Object.defineProperties(strings, { + raw: { + value: Object.freeze(raw) + } + })); +} + +function _taggedTemplateLiteralLoose(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + strings.raw = raw; + return strings; +} + +function _readOnlyError(name) { + throw new Error("\"" + name + "\" is read-only"); +} + +function _classNameTDZError(name) { + throw new Error("Class \"" + name + "\" cannot be referenced in computed property keys."); +} + +function _temporalUndefined() {} + +function _tdz(name) { + throw new ReferenceError(name + " is not defined - temporal dead zone"); +} + +function _temporalRef(val, name) { + return val === _temporalUndefined ? _tdz(name) : val; +} + +function _slicedToArray(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); +} + +function _slicedToArrayLoose(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimitLoose(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); +} + +function _toArray(arr) { + return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); +} + +function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); +} + +function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) return _arrayLikeToArray(arr); +} + +function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; +} + +function _maybeArrayLike(next, arr, i) { + if (arr && !Array.isArray(arr) && typeof arr.length === "number") { + var len = arr.length; + return _arrayLikeToArray(arr, i !== void 0 && i < len ? i : len); + } + + return next(arr, i); +} + +function _iterableToArray(iter) { + if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); +} + +function _iterableToArrayLimit(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"] != null) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; +} + +function _iterableToArrayLimitLoose(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + + for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { + _arr.push(_step.value); + + if (i && _arr.length === i) break; + } + + return _arr; +} + +function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if (typeof o === "string") return _arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + if (n === "Object" && o.constructor) n = o.constructor.name; + if (n === "Map" || n === "Set") return Array.from(o); + if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); +} + +function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) len = arr.length; + + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + + return arr2; +} + +function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); +} + +function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); +} + +function _createForOfIteratorHelper(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + + var F = function () {}; + + return { + s: F, + n: function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }, + e: function (e) { + throw e; + }, + f: F + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + var normalCompletion = true, + didErr = false, + err; + return { + s: function () { + it = o[Symbol.iterator](); + }, + n: function () { + var step = it.next(); + normalCompletion = step.done; + return step; + }, + e: function (e) { + didErr = true; + err = e; + }, + f: function () { + try { + if (!normalCompletion && it.return != null) it.return(); + } finally { + if (didErr) throw err; + } + } + }; +} + +function _createForOfIteratorHelperLoose(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + return function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + it = o[Symbol.iterator](); + return it.next.bind(it); +} + +function _skipFirstGeneratorNext(fn) { + return function () { + var it = fn.apply(this, arguments); + it.next(); + return it; + }; +} + +function _toPrimitive(input, hint) { + if (typeof input !== "object" || input === null) return input; + var prim = input[Symbol.toPrimitive]; + + if (prim !== undefined) { + var res = prim.call(input, hint || "default"); + if (typeof res !== "object") return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + + return (hint === "string" ? String : Number)(input); +} + +function _toPropertyKey(arg) { + var key = _toPrimitive(arg, "string"); + + return typeof key === "symbol" ? key : String(key); +} + +function _initializerWarningHelper(descriptor, context) { + throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.'); +} + +function _initializerDefineProperty(target, property, descriptor, context) { + if (!descriptor) return; + Object.defineProperty(target, property, { + enumerable: descriptor.enumerable, + configurable: descriptor.configurable, + writable: descriptor.writable, + value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 + }); +} + +function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { + var desc = {}; + Object.keys(descriptor).forEach(function (key) { + desc[key] = descriptor[key]; + }); + desc.enumerable = !!desc.enumerable; + desc.configurable = !!desc.configurable; + + if ('value' in desc || desc.initializer) { + desc.writable = true; + } + + desc = decorators.slice().reverse().reduce(function (desc, decorator) { + return decorator(target, property, desc) || desc; + }, desc); + + if (context && desc.initializer !== void 0) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = undefined; + } + + if (desc.initializer === void 0) { + Object.defineProperty(target, property, desc); + desc = null; + } + + return desc; +} + +var id = 0; + +function _classPrivateFieldLooseKey(name) { + return "__private_" + id++ + "_" + name; +} + +function _classPrivateFieldLooseBase(receiver, privateKey) { + if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { + throw new TypeError("attempted to use private field on non-instance"); + } + + return receiver; +} + +function _classPrivateFieldGet(receiver, privateMap) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to get private field on non-instance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; +} + +function _classPrivateFieldSet(receiver, privateMap, value) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to set private field on non-instance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; +} + +function _classPrivateFieldDestructureSet(receiver, privateMap) { + if (!privateMap.has(receiver)) { + throw new TypeError("attempted to set private field on non-instance"); + } + + var descriptor = privateMap.get(receiver); + + if (descriptor.set) { + if (!("__destrObj" in descriptor)) { + descriptor.__destrObj = { + set value(v) { + descriptor.set.call(receiver, v); + } + + }; + } + + return descriptor.__destrObj; + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + return descriptor; + } +} + +function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; +} + +function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; +} + +function _classStaticPrivateMethodGet(receiver, classConstructor, method) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + return method; +} + +function _classStaticPrivateMethodSet() { + throw new TypeError("attempted to set read only static private field"); +} + +function _decorate(decorators, factory, superClass, mixins) { + var api = _getDecoratorsApi(); + + if (mixins) { + for (var i = 0; i < mixins.length; i++) { + api = mixins[i](api); + } + } + + var r = factory(function initialize(O) { + api.initializeInstanceElements(O, decorated.elements); + }, superClass); + var decorated = api.decorateClass(_coalesceClassElements(r.d.map(_createElementDescriptor)), decorators); + api.initializeClassElements(r.F, decorated.elements); + return api.runClassFinishers(r.F, decorated.finishers); +} + +function _getDecoratorsApi() { + _getDecoratorsApi = function () { + return api; + }; + + var api = { + elementsDefinitionOrder: [["method"], ["field"]], + initializeInstanceElements: function (O, elements) { + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + if (element.kind === kind && element.placement === "own") { + this.defineClassElement(O, element); + } + }, this); + }, this); + }, + initializeClassElements: function (F, elements) { + var proto = F.prototype; + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + var placement = element.placement; + + if (element.kind === kind && (placement === "static" || placement === "prototype")) { + var receiver = placement === "static" ? F : proto; + this.defineClassElement(receiver, element); + } + }, this); + }, this); + }, + defineClassElement: function (receiver, element) { + var descriptor = element.descriptor; + + if (element.kind === "field") { + var initializer = element.initializer; + descriptor = { + enumerable: descriptor.enumerable, + writable: descriptor.writable, + configurable: descriptor.configurable, + value: initializer === void 0 ? void 0 : initializer.call(receiver) + }; + } + + Object.defineProperty(receiver, element.key, descriptor); + }, + decorateClass: function (elements, decorators) { + var newElements = []; + var finishers = []; + var placements = { + static: [], + prototype: [], + own: [] + }; + elements.forEach(function (element) { + this.addElementPlacement(element, placements); + }, this); + elements.forEach(function (element) { + if (!_hasDecorators(element)) return newElements.push(element); + var elementFinishersExtras = this.decorateElement(element, placements); + newElements.push(elementFinishersExtras.element); + newElements.push.apply(newElements, elementFinishersExtras.extras); + finishers.push.apply(finishers, elementFinishersExtras.finishers); + }, this); + + if (!decorators) { + return { + elements: newElements, + finishers: finishers + }; + } + + var result = this.decorateConstructor(newElements, decorators); + finishers.push.apply(finishers, result.finishers); + result.finishers = finishers; + return result; + }, + addElementPlacement: function (element, placements, silent) { + var keys = placements[element.placement]; + + if (!silent && keys.indexOf(element.key) !== -1) { + throw new TypeError("Duplicated element (" + element.key + ")"); + } + + keys.push(element.key); + }, + decorateElement: function (element, placements) { + var extras = []; + var finishers = []; + + for (var decorators = element.decorators, i = decorators.length - 1; i >= 0; i--) { + var keys = placements[element.placement]; + keys.splice(keys.indexOf(element.key), 1); + var elementObject = this.fromElementDescriptor(element); + var elementFinisherExtras = this.toElementFinisherExtras((0, decorators[i])(elementObject) || elementObject); + element = elementFinisherExtras.element; + this.addElementPlacement(element, placements); + + if (elementFinisherExtras.finisher) { + finishers.push(elementFinisherExtras.finisher); + } + + var newExtras = elementFinisherExtras.extras; + + if (newExtras) { + for (var j = 0; j < newExtras.length; j++) { + this.addElementPlacement(newExtras[j], placements); + } + + extras.push.apply(extras, newExtras); + } + } + + return { + element: element, + finishers: finishers, + extras: extras + }; + }, + decorateConstructor: function (elements, decorators) { + var finishers = []; + + for (var i = decorators.length - 1; i >= 0; i--) { + var obj = this.fromClassDescriptor(elements); + var elementsAndFinisher = this.toClassDescriptor((0, decorators[i])(obj) || obj); + + if (elementsAndFinisher.finisher !== undefined) { + finishers.push(elementsAndFinisher.finisher); + } + + if (elementsAndFinisher.elements !== undefined) { + elements = elementsAndFinisher.elements; + + for (var j = 0; j < elements.length - 1; j++) { + for (var k = j + 1; k < elements.length; k++) { + if (elements[j].key === elements[k].key && elements[j].placement === elements[k].placement) { + throw new TypeError("Duplicated element (" + elements[j].key + ")"); + } + } + } + } + } + + return { + elements: elements, + finishers: finishers + }; + }, + fromElementDescriptor: function (element) { + var obj = { + kind: element.kind, + key: element.key, + placement: element.placement, + descriptor: element.descriptor + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + if (element.kind === "field") obj.initializer = element.initializer; + return obj; + }, + toElementDescriptors: function (elementObjects) { + if (elementObjects === undefined) return; + return _toArray(elementObjects).map(function (elementObject) { + var element = this.toElementDescriptor(elementObject); + this.disallowProperty(elementObject, "finisher", "An element descriptor"); + this.disallowProperty(elementObject, "extras", "An element descriptor"); + return element; + }, this); + }, + toElementDescriptor: function (elementObject) { + var kind = String(elementObject.kind); + + if (kind !== "method" && kind !== "field") { + throw new TypeError('An element descriptor\'s .kind property must be either "method" or' + ' "field", but a decorator created an element descriptor with' + ' .kind "' + kind + '"'); + } + + var key = _toPropertyKey(elementObject.key); + + var placement = String(elementObject.placement); + + if (placement !== "static" && placement !== "prototype" && placement !== "own") { + throw new TypeError('An element descriptor\'s .placement property must be one of "static",' + ' "prototype" or "own", but a decorator created an element descriptor' + ' with .placement "' + placement + '"'); + } + + var descriptor = elementObject.descriptor; + this.disallowProperty(elementObject, "elements", "An element descriptor"); + var element = { + kind: kind, + key: key, + placement: placement, + descriptor: Object.assign({}, descriptor) + }; + + if (kind !== "field") { + this.disallowProperty(elementObject, "initializer", "A method descriptor"); + } else { + this.disallowProperty(descriptor, "get", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "set", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "value", "The property descriptor of a field descriptor"); + element.initializer = elementObject.initializer; + } + + return element; + }, + toElementFinisherExtras: function (elementObject) { + var element = this.toElementDescriptor(elementObject); + + var finisher = _optionalCallableProperty(elementObject, "finisher"); + + var extras = this.toElementDescriptors(elementObject.extras); + return { + element: element, + finisher: finisher, + extras: extras + }; + }, + fromClassDescriptor: function (elements) { + var obj = { + kind: "class", + elements: elements.map(this.fromElementDescriptor, this) + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + return obj; + }, + toClassDescriptor: function (obj) { + var kind = String(obj.kind); + + if (kind !== "class") { + throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator' + ' created a class descriptor with .kind "' + kind + '"'); + } + + this.disallowProperty(obj, "key", "A class descriptor"); + this.disallowProperty(obj, "placement", "A class descriptor"); + this.disallowProperty(obj, "descriptor", "A class descriptor"); + this.disallowProperty(obj, "initializer", "A class descriptor"); + this.disallowProperty(obj, "extras", "A class descriptor"); + + var finisher = _optionalCallableProperty(obj, "finisher"); + + var elements = this.toElementDescriptors(obj.elements); + return { + elements: elements, + finisher: finisher + }; + }, + runClassFinishers: function (constructor, finishers) { + for (var i = 0; i < finishers.length; i++) { + var newConstructor = (0, finishers[i])(constructor); + + if (newConstructor !== undefined) { + if (typeof newConstructor !== "function") { + throw new TypeError("Finishers must return a constructor."); + } + + constructor = newConstructor; + } + } + + return constructor; + }, + disallowProperty: function (obj, name, objectType) { + if (obj[name] !== undefined) { + throw new TypeError(objectType + " can't have a ." + name + " property."); + } + } + }; + return api; +} + +function _createElementDescriptor(def) { + var key = _toPropertyKey(def.key); + + var descriptor; + + if (def.kind === "method") { + descriptor = { + value: def.value, + writable: true, + configurable: true, + enumerable: false + }; + } else if (def.kind === "get") { + descriptor = { + get: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "set") { + descriptor = { + set: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "field") { + descriptor = { + configurable: true, + writable: true, + enumerable: true + }; + } + + var element = { + kind: def.kind === "field" ? "field" : "method", + key: key, + placement: def.static ? "static" : def.kind === "field" ? "own" : "prototype", + descriptor: descriptor + }; + if (def.decorators) element.decorators = def.decorators; + if (def.kind === "field") element.initializer = def.value; + return element; +} + +function _coalesceGetterSetter(element, other) { + if (element.descriptor.get !== undefined) { + other.descriptor.get = element.descriptor.get; + } else { + other.descriptor.set = element.descriptor.set; + } +} + +function _coalesceClassElements(elements) { + var newElements = []; + + var isSameElement = function (other) { + return other.kind === "method" && other.key === element.key && other.placement === element.placement; + }; + + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + var other; + + if (element.kind === "method" && (other = newElements.find(isSameElement))) { + if (_isDataDescriptor(element.descriptor) || _isDataDescriptor(other.descriptor)) { + if (_hasDecorators(element) || _hasDecorators(other)) { + throw new ReferenceError("Duplicated methods (" + element.key + ") can't be decorated."); + } + + other.descriptor = element.descriptor; + } else { + if (_hasDecorators(element)) { + if (_hasDecorators(other)) { + throw new ReferenceError("Decorators can't be placed on different accessors with for " + "the same property (" + element.key + ")."); + } + + other.decorators = element.decorators; + } + + _coalesceGetterSetter(element, other); + } + } else { + newElements.push(element); + } + } + + return newElements; +} + +function _hasDecorators(element) { + return element.decorators && element.decorators.length; +} + +function _isDataDescriptor(desc) { + return desc !== undefined && !(desc.value === undefined && desc.writable === undefined); +} + +function _optionalCallableProperty(obj, name) { + var value = obj[name]; + + if (value !== undefined && typeof value !== "function") { + throw new TypeError("Expected '" + name + "' to be a function"); + } + + return value; +} + +function _classPrivateMethodGet(receiver, privateSet, fn) { + if (!privateSet.has(receiver)) { + throw new TypeError("attempted to get private field on non-instance"); + } + + return fn; +} + +function _classPrivateMethodSet() { + throw new TypeError("attempted to reassign private method"); +} + +function _wrapRegExp(re, groups) { + _wrapRegExp = function (re, groups) { + return new BabelRegExp(re, undefined, groups); + }; + + var _RegExp = _wrapNativeSuper(RegExp); + + var _super = RegExp.prototype; + + var _groups = new WeakMap(); + + function BabelRegExp(re, flags, groups) { + var _this = _RegExp.call(this, re, flags); + + _groups.set(_this, groups || _groups.get(re)); + + return _this; + } + + _inherits(BabelRegExp, _RegExp); + + BabelRegExp.prototype.exec = function (str) { + var result = _super.exec.call(this, str); + + if (result) result.groups = buildGroups(result, this); + return result; + }; + + BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { + if (typeof substitution === "string") { + var groups = _groups.get(this); + + return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { + return "$" + groups[name]; + })); + } else if (typeof substitution === "function") { + var _this = this; + + return _super[Symbol.replace].call(this, str, function () { + var args = []; + args.push.apply(args, arguments); + + if (typeof args[args.length - 1] !== "object") { + args.push(buildGroups(args, _this)); + } + + return substitution.apply(this, args); + }); + } else { + return _super[Symbol.replace].call(this, str, substitution); + } + }; + + function buildGroups(result, re) { + var g = _groups.get(re); + + return Object.keys(g).reduce(function (groups, name) { + groups[name] = result[g[name]]; + return groups; + }, Object.create(null)); + } + + return _wrapRegExp.apply(this, arguments); +} + +var foreignobjectIcons = "foreignobject-icons.xml"; + +var extForeignobject = { + name: 'foreignobject', + init: function init(S) { + var _this = this; + + return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() { + var svgEditor, $, text2xml, NS, importLocale, svgCanvas, svgdoc, strings, properlySourceSizeTextArea, showPanel, toggleSourceButtons, selElems, started, newFO, editingforeign, setForeignString, showForeignEditor, setAttr, buttons, contextTools; + return regeneratorRuntime.wrap(function _callee2$(_context2) { + while (1) { + switch (_context2.prev = _context2.next) { + case 0: + setAttr = function _setAttr(attr, val) { + svgCanvas.changeSelectedAttribute(attr, val); + svgCanvas.call('changed', selElems); + }; + + showForeignEditor = function _showForeignEditor() { + var elt = selElems[0]; + + if (!elt || editingforeign) { + return; + } + + editingforeign = true; + toggleSourceButtons(true); + elt.removeAttribute('fill'); + var str = svgCanvas.svgToString(elt, 0); + $('#svg_source_textarea').val(str); + $('#svg_source_editor').fadeIn(); + properlySourceSizeTextArea(); + $('#svg_source_textarea').focus(); + }; + + setForeignString = function _setForeignString(xmlString) { + var elt = selElems[0]; // The parent `Element` to append to + + try { + // convert string into XML document + var newDoc = text2xml('' + xmlString + ''); // run it through our sanitizer to remove anything we do not support + + svgCanvas.sanitizeSvg(newDoc.documentElement); + elt.replaceWith(svgdoc.importNode(newDoc.documentElement.firstChild, true)); + svgCanvas.call('changed', [elt]); + svgCanvas.clearSelection(); + } catch (e) { + // Todo: Surface error to user + console.log(e); // eslint-disable-line no-console + + return false; + } + + return true; + }; + + toggleSourceButtons = function _toggleSourceButtons(on) { + $('#tool_source_save, #tool_source_cancel').toggle(!on); + $('#foreign_save, #foreign_cancel').toggle(on); + }; + + showPanel = function _showPanel(on) { + var fcRules = $('#fc_rules'); + + if (!fcRules.length) { + fcRules = $('').appendTo('head'); + } + + fcRules.text(!on ? '' : ' #tool_topath { display: none !important; }'); + $('#foreignObject_panel').toggle(on); + }; + + svgEditor = _this; + $ = S.$, text2xml = S.text2xml, NS = S.NS, importLocale = S.importLocale; + svgCanvas = svgEditor.canvas; + svgdoc = S.svgroot.parentNode.ownerDocument; + _context2.next = 11; + return importLocale(); + + case 11: + strings = _context2.sent; + + properlySourceSizeTextArea = function properlySourceSizeTextArea() { + // TODO: remove magic numbers here and get values from CSS + var height = $('#svg_source_container').height() - 80; + $('#svg_source_textarea').css('height', height); + }; + /** + * @param {boolean} on + * @returns {void} + */ + + + editingforeign = false; + /** + * This function sets the content of element elt to the input XML. + * @param {string} xmlString - The XML text + * @returns {boolean} This function returns false if the set was unsuccessful, true otherwise. + */ + + buttons = [{ + id: 'tool_foreign', + icon: svgEditor.curConfig.extIconsPath + 'foreignobject-tool.png', + type: 'mode', + events: { + click: function click() { + svgCanvas.setMode('foreign'); + } + } + }, { + id: 'edit_foreign', + icon: svgEditor.curConfig.extIconsPath + 'foreignobject-edit.png', + type: 'context', + panel: 'foreignObject_panel', + events: { + click: function click() { + showForeignEditor(); + } + } + }]; + contextTools = [{ + type: 'input', + panel: 'foreignObject_panel', + id: 'foreign_width', + size: 3, + events: { + change: function change() { + setAttr('width', this.value); + } + } + }, { + type: 'input', + panel: 'foreignObject_panel', + id: 'foreign_height', + events: { + change: function change() { + setAttr('height', this.value); + } + } + }, { + type: 'input', + panel: 'foreignObject_panel', + id: 'foreign_font_size', + size: 2, + defval: 16, + events: { + change: function change() { + setAttr('font-size', this.value); + } + } + }]; + return _context2.abrupt("return", { + name: strings.name, + svgicons: svgEditor.curConfig.extIconsPath + 'foreignobject-icons.xml', + buttons: strings.buttons.map(function (button, i) { + return Object.assign(buttons[i], button); + }), + context_tools: strings.contextTools.map(function (contextTool, i) { + return Object.assign(contextTools[i], contextTool); + }), + callback: function callback() { + $('#foreignObject_panel').hide(); + + var endChanges = function endChanges() { + $('#svg_source_editor').hide(); + editingforeign = false; + $('#svg_source_textarea').blur(); + toggleSourceButtons(false); + }; // TODO: Needs to be done after orig icon loads + + + setTimeout(function () { + // Create source save/cancel buttons + + /* const save = */ + $('#tool_source_save').clone().hide().attr('id', 'foreign_save').unbind().appendTo('#tool_source_back').click( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { + var ok; + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + if (editingforeign) { + _context.next = 2; + break; + } + + return _context.abrupt("return"); + + case 2: + if (setForeignString($('#svg_source_textarea').val())) { + _context.next = 11; + break; + } + + _context.next = 5; + return $.confirm('Errors found. Revert to original?'); + + case 5: + ok = _context.sent; + + if (ok) { + _context.next = 8; + break; + } + + return _context.abrupt("return"); + + case 8: + endChanges(); + _context.next = 12; + break; + + case 11: + endChanges(); + + case 12: + case "end": + return _context.stop(); + } + } + }, _callee); + }))); + /* const cancel = */ + + $('#tool_source_cancel').clone().hide().attr('id', 'foreign_cancel').unbind().appendTo('#tool_source_back').click(function () { + endChanges(); + }); + }, 3000); + }, + mouseDown: function mouseDown(opts) { + // const e = opts.event; + if (svgCanvas.getMode() !== 'foreign') { + return undefined; + } + + started = true; + newFO = svgCanvas.addSVGElementFromJson({ + element: 'foreignObject', + attr: { + x: opts.start_x, + y: opts.start_y, + id: svgCanvas.getNextId(), + 'font-size': 16, + // cur_text.font_size, + width: '48', + height: '20', + style: 'pointer-events:inherit' + } + }); + var m = svgdoc.createElementNS(NS.MATH, 'math'); + m.setAttributeNS(NS.XMLNS, 'xmlns', NS.MATH); + m.setAttribute('display', 'inline'); + var mi = svgdoc.createElementNS(NS.MATH, 'mi'); + mi.setAttribute('mathvariant', 'normal'); + mi.textContent = "\u03A6"; + var mo = svgdoc.createElementNS(NS.MATH, 'mo'); + mo.textContent = "\u222A"; + var mi2 = svgdoc.createElementNS(NS.MATH, 'mi'); + mi2.textContent = "\u2133"; + m.append(mi, mo, mi2); + newFO.append(m); + return { + started: true + }; + }, + mouseUp: function mouseUp(opts) { + // const e = opts.event; + if (svgCanvas.getMode() !== 'foreign' || !started) { + return undefined; + } + + var attrs = $(newFO).attr(['width', 'height']); + var keep = attrs.width !== '0' || attrs.height !== '0'; + svgCanvas.addToSelection([newFO], true); + return { + keep: keep, + element: newFO + }; + }, + selectedChanged: function selectedChanged(opts) { + // Use this to update the current selected elements + selElems = opts.elems; + var i = selElems.length; + + while (i--) { + var elem = selElems[i]; + + if (elem && elem.tagName === 'foreignObject') { + if (opts.selectedElement && !opts.multiselected) { + $('#foreign_font_size').val(elem.getAttribute('font-size')); + $('#foreign_width').val(elem.getAttribute('width')); + $('#foreign_height').val(elem.getAttribute('height')); + showPanel(true); + } else { + showPanel(false); + } + } else { + showPanel(false); + } + } + }, + elementChanged: function elementChanged(opts) {// const elem = opts.elems[0]; + } + }); + + case 17: + case "end": + return _context2.stop(); + } + } + }, _callee2); + }))(); + } +}; + +export default extForeignobject; +//# sourceMappingURL=ext-foreignobject.js.map diff --git a/dist/editor/extensions/ext-foreignobject.js.map b/dist/editor/extensions/ext-foreignobject.js.map new file mode 100644 index 00000000..0de36f92 --- /dev/null +++ b/dist/editor/extensions/ext-foreignobject.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ext-foreignobject.js","sources":["../../../src/editor/extensions/foreignobject-icons.xml","../../../src/editor/extensions/ext-foreignobject.js"],"sourcesContent":["export default \"foreignobject-icons.xml\"","/**\n * @file ext-foreignobject.js\n *\n * @license Apache-2.0\n *\n * @copyright 2010 Jacques Distler, 2010 Alexis Deveria\n *\n */\n\nimport './foreignobject-icons.xml';\n\nexport default {\n name: 'foreignobject',\n async init (S) {\n const svgEditor = this;\n const {$, text2xml, NS, importLocale} = S;\n const svgCanvas = svgEditor.canvas;\n const\n // {svgcontent} = S,\n // addElem = svgCanvas.addSVGElementFromJson,\n svgdoc = S.svgroot.parentNode.ownerDocument;\n const strings = await importLocale();\n\n const properlySourceSizeTextArea = function () {\n // TODO: remove magic numbers here and get values from CSS\n const height = $('#svg_source_container').height() - 80;\n $('#svg_source_textarea').css('height', height);\n };\n\n /**\n * @param {boolean} on\n * @returns {void}\n */\n function showPanel (on) {\n let fcRules = $('#fc_rules');\n if (!fcRules.length) {\n fcRules = $('').appendTo('head');\n }\n fcRules.text(!on ? '' : ' #tool_topath { display: none !important; }');\n $('#foreignObject_panel').toggle(on);\n }\n\n /**\n * @param {boolean} on\n * @returns {void}\n */\n function toggleSourceButtons (on) {\n $('#tool_source_save, #tool_source_cancel').toggle(!on);\n $('#foreign_save, #foreign_cancel').toggle(on);\n }\n\n let selElems,\n started,\n newFO,\n editingforeign = false;\n\n /**\n * This function sets the content of element elt to the input XML.\n * @param {string} xmlString - The XML text\n * @returns {boolean} This function returns false if the set was unsuccessful, true otherwise.\n */\n function setForeignString (xmlString) {\n const elt = selElems[0]; // The parent `Element` to append to\n try {\n // convert string into XML document\n const newDoc = text2xml('' + xmlString + '');\n // run it through our sanitizer to remove anything we do not support\n svgCanvas.sanitizeSvg(newDoc.documentElement);\n elt.replaceWith(svgdoc.importNode(newDoc.documentElement.firstChild, true));\n svgCanvas.call('changed', [elt]);\n svgCanvas.clearSelection();\n } catch (e) {\n // Todo: Surface error to user\n console.log(e); // eslint-disable-line no-console\n return false;\n }\n\n return true;\n }\n\n /**\n *\n * @returns {void}\n */\n function showForeignEditor () {\n const elt = selElems[0];\n if (!elt || editingforeign) { return; }\n editingforeign = true;\n toggleSourceButtons(true);\n elt.removeAttribute('fill');\n\n const str = svgCanvas.svgToString(elt, 0);\n $('#svg_source_textarea').val(str);\n $('#svg_source_editor').fadeIn();\n properlySourceSizeTextArea();\n $('#svg_source_textarea').focus();\n }\n\n /**\n * @param {string} attr\n * @param {string|Float} val\n * @returns {void}\n */\n function setAttr (attr, val) {\n svgCanvas.changeSelectedAttribute(attr, val);\n svgCanvas.call('changed', selElems);\n }\n\n const buttons = [{\n id: 'tool_foreign',\n icon: svgEditor.curConfig.extIconsPath + 'foreignobject-tool.png',\n type: 'mode',\n events: {\n click () {\n svgCanvas.setMode('foreign');\n }\n }\n }, {\n id: 'edit_foreign',\n icon: svgEditor.curConfig.extIconsPath + 'foreignobject-edit.png',\n type: 'context',\n panel: 'foreignObject_panel',\n events: {\n click () {\n showForeignEditor();\n }\n }\n }];\n\n const contextTools = [\n {\n type: 'input',\n panel: 'foreignObject_panel',\n id: 'foreign_width',\n size: 3,\n events: {\n change () {\n setAttr('width', this.value);\n }\n }\n }, {\n type: 'input',\n panel: 'foreignObject_panel',\n id: 'foreign_height',\n events: {\n change () {\n setAttr('height', this.value);\n }\n }\n }, {\n type: 'input',\n panel: 'foreignObject_panel',\n id: 'foreign_font_size',\n size: 2,\n defval: 16,\n events: {\n change () {\n setAttr('font-size', this.value);\n }\n }\n }\n ];\n\n return {\n name: strings.name,\n svgicons: svgEditor.curConfig.extIconsPath + 'foreignobject-icons.xml',\n buttons: strings.buttons.map((button, i) => {\n return Object.assign(buttons[i], button);\n }),\n context_tools: strings.contextTools.map((contextTool, i) => {\n return Object.assign(contextTools[i], contextTool);\n }),\n callback () {\n $('#foreignObject_panel').hide();\n\n const endChanges = function () {\n $('#svg_source_editor').hide();\n editingforeign = false;\n $('#svg_source_textarea').blur();\n toggleSourceButtons(false);\n };\n\n // TODO: Needs to be done after orig icon loads\n setTimeout(function () {\n // Create source save/cancel buttons\n /* const save = */ $('#tool_source_save').clone()\n .hide().attr('id', 'foreign_save').unbind()\n .appendTo('#tool_source_back').click(async function () {\n if (!editingforeign) { return; }\n\n if (!setForeignString($('#svg_source_textarea').val())) {\n const ok = await $.confirm('Errors found. Revert to original?');\n if (!ok) { return; }\n endChanges();\n } else {\n endChanges();\n }\n // setSelectMode();\n });\n\n /* const cancel = */ $('#tool_source_cancel').clone()\n .hide().attr('id', 'foreign_cancel').unbind()\n .appendTo('#tool_source_back').click(function () {\n endChanges();\n });\n }, 3000);\n },\n mouseDown (opts) {\n // const e = opts.event;\n if (svgCanvas.getMode() !== 'foreign') {\n return undefined;\n }\n started = true;\n newFO = svgCanvas.addSVGElementFromJson({\n element: 'foreignObject',\n attr: {\n x: opts.start_x,\n y: opts.start_y,\n id: svgCanvas.getNextId(),\n 'font-size': 16, // cur_text.font_size,\n width: '48',\n height: '20',\n style: 'pointer-events:inherit'\n }\n });\n const m = svgdoc.createElementNS(NS.MATH, 'math');\n m.setAttributeNS(NS.XMLNS, 'xmlns', NS.MATH);\n m.setAttribute('display', 'inline');\n const mi = svgdoc.createElementNS(NS.MATH, 'mi');\n mi.setAttribute('mathvariant', 'normal');\n mi.textContent = '\\u03A6';\n const mo = svgdoc.createElementNS(NS.MATH, 'mo');\n mo.textContent = '\\u222A';\n const mi2 = svgdoc.createElementNS(NS.MATH, 'mi');\n mi2.textContent = '\\u2133';\n m.append(mi, mo, mi2);\n newFO.append(m);\n return {\n started: true\n };\n },\n mouseUp (opts) {\n // const e = opts.event;\n if (svgCanvas.getMode() !== 'foreign' || !started) {\n return undefined;\n }\n const attrs = $(newFO).attr(['width', 'height']);\n const keep = (attrs.width !== '0' || attrs.height !== '0');\n svgCanvas.addToSelection([newFO], true);\n\n return {\n keep,\n element: newFO\n };\n },\n selectedChanged (opts) {\n // Use this to update the current selected elements\n selElems = opts.elems;\n\n let i = selElems.length;\n while (i--) {\n const elem = selElems[i];\n if (elem && elem.tagName === 'foreignObject') {\n if (opts.selectedElement && !opts.multiselected) {\n $('#foreign_font_size').val(elem.getAttribute('font-size'));\n $('#foreign_width').val(elem.getAttribute('width'));\n $('#foreign_height').val(elem.getAttribute('height'));\n showPanel(true);\n } else {\n showPanel(false);\n }\n } else {\n showPanel(false);\n }\n }\n },\n elementChanged (opts) {\n // const elem = opts.elems[0];\n }\n };\n }\n};\n"],"names":["name","init","S","showPanel","toggleSourceButtons","setForeignString","showForeignEditor","setAttr","attr","val","svgCanvas","changeSelectedAttribute","call","selElems","elt","editingforeign","removeAttribute","str","svgToString","$","fadeIn","properlySourceSizeTextArea","focus","xmlString","newDoc","text2xml","NS","SVG","XLINK","sanitizeSvg","documentElement","replaceWith","svgdoc","importNode","firstChild","clearSelection","e","console","log","on","toggle","fcRules","length","appendTo","text","svgEditor","importLocale","canvas","svgroot","parentNode","ownerDocument","strings","height","css","buttons","id","icon","curConfig","extIconsPath","type","events","click","setMode","panel","contextTools","size","change","value","defval","svgicons","map","button","i","Object","assign","context_tools","contextTool","callback","hide","endChanges","blur","setTimeout","clone","unbind","confirm","ok","mouseDown","opts","getMode","undefined","started","newFO","addSVGElementFromJson","element","x","start_x","y","start_y","getNextId","width","style","m","createElementNS","MATH","setAttributeNS","XMLNS","setAttribute","mi","textContent","mo","mi2","append","mouseUp","attrs","keep","add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gBAAD,CAAD,CAAoBV,GAApB,CAAwB6G,IAAI,CAACI,YAAL,CAAkB,OAAlB,CAAxB;AACAvG,wBAAAA,CAAC,CAAC,iBAAD,CAAD,CAAqBV,GAArB,CAAyB6G,IAAI,CAACI,YAAL,CAAkB,QAAlB,CAAzB;AACAvH,wBAAAA,SAAS,CAAC,IAAD,CAAT;AACD,uBALD,MAKO;AACLA,wBAAAA,SAAS,CAAC,KAAD,CAAT;AACD;AACF,qBATD,MASO;AACLA,sBAAAA,SAAS,CAAC,KAAD,CAAT;AACD;AACF;AACF,iBAhHI;AAiHLwH,gBAAAA,cAjHK,0BAiHWpC,IAjHX,EAiHiB;AAErB;AAnHI,eAtJM;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2Qd;AA7QY,CAAf;;;;"} \ No newline at end of file diff --git a/dist/editor/extensions/ext-grid.js b/dist/editor/extensions/ext-grid.js new file mode 100644 index 00000000..466b0490 --- /dev/null +++ b/dist/editor/extensions/ext-grid.js @@ -0,0 +1,1824 @@ +function _typeof(obj) { + "@babel/helpers - typeof"; + + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function (obj) { + return typeof obj; + }; + } else { + _typeof = function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); +} + +var REACT_ELEMENT_TYPE; + +function _jsx(type, props, key, children) { + if (!REACT_ELEMENT_TYPE) { + REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol["for"] && Symbol["for"]("react.element") || 0xeac7; + } + + var defaultProps = type && type.defaultProps; + var childrenLength = arguments.length - 3; + + if (!props && childrenLength !== 0) { + props = { + children: void 0 + }; + } + + if (childrenLength === 1) { + props.children = children; + } else if (childrenLength > 1) { + var childArray = new Array(childrenLength); + + for (var i = 0; i < childrenLength; i++) { + childArray[i] = arguments[i + 3]; + } + + props.children = childArray; + } + + if (props && defaultProps) { + for (var propName in defaultProps) { + if (props[propName] === void 0) { + props[propName] = defaultProps[propName]; + } + } + } else if (!props) { + props = defaultProps || {}; + } + + return { + $$typeof: REACT_ELEMENT_TYPE, + type: type, + key: key === undefined ? null : '' + key, + ref: null, + props: props, + _owner: null + }; +} + +function _asyncIterator(iterable) { + var method; + + if (typeof Symbol !== "undefined") { + if (Symbol.asyncIterator) { + method = iterable[Symbol.asyncIterator]; + if (method != null) return method.call(iterable); + } + + if (Symbol.iterator) { + method = iterable[Symbol.iterator]; + if (method != null) return method.call(iterable); + } + } + + throw new TypeError("Object is not async iterable"); +} + +function _AwaitValue(value) { + this.wrapped = value; +} + +function _AsyncGenerator(gen) { + var front, back; + + function send(key, arg) { + return new Promise(function (resolve, reject) { + var request = { + key: key, + arg: arg, + resolve: resolve, + reject: reject, + next: null + }; + + if (back) { + back = back.next = request; + } else { + front = back = request; + resume(key, arg); + } + }); + } + + function resume(key, arg) { + try { + var result = gen[key](arg); + var value = result.value; + var wrappedAwait = value instanceof _AwaitValue; + Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { + if (wrappedAwait) { + resume(key === "return" ? "return" : "next", arg); + return; + } + + settle(result.done ? "return" : "normal", arg); + }, function (err) { + resume("throw", err); + }); + } catch (err) { + settle("throw", err); + } + } + + function settle(type, value) { + switch (type) { + case "return": + front.resolve({ + value: value, + done: true + }); + break; + + case "throw": + front.reject(value); + break; + + default: + front.resolve({ + value: value, + done: false + }); + break; + } + + front = front.next; + + if (front) { + resume(front.key, front.arg); + } else { + back = null; + } + } + + this._invoke = send; + + if (typeof gen.return !== "function") { + this.return = undefined; + } +} + +if (typeof Symbol === "function" && Symbol.asyncIterator) { + _AsyncGenerator.prototype[Symbol.asyncIterator] = function () { + return this; + }; +} + +_AsyncGenerator.prototype.next = function (arg) { + return this._invoke("next", arg); +}; + +_AsyncGenerator.prototype.throw = function (arg) { + return this._invoke("throw", arg); +}; + +_AsyncGenerator.prototype.return = function (arg) { + return this._invoke("return", arg); +}; + +function _wrapAsyncGenerator(fn) { + return function () { + return new _AsyncGenerator(fn.apply(this, arguments)); + }; +} + +function _awaitAsyncGenerator(value) { + return new _AwaitValue(value); +} + +function _asyncGeneratorDelegate(inner, awaitWrap) { + var iter = {}, + waiting = false; + + function pump(key, value) { + waiting = true; + value = new Promise(function (resolve) { + resolve(inner[key](value)); + }); + return { + done: false, + value: awaitWrap(value) + }; + } + + ; + + if (typeof Symbol === "function" && Symbol.iterator) { + iter[Symbol.iterator] = function () { + return this; + }; + } + + iter.next = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("next", value); + }; + + if (typeof inner.throw === "function") { + iter.throw = function (value) { + if (waiting) { + waiting = false; + throw value; + } + + return pump("throw", value); + }; + } + + if (typeof inner.return === "function") { + iter.return = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("return", value); + }; + } + + return iter; +} + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { + try { + var info = gen[key](arg); + var value = info.value; + } catch (error) { + reject(error); + return; + } + + if (info.done) { + resolve(value); + } else { + Promise.resolve(value).then(_next, _throw); + } +} + +function _asyncToGenerator(fn) { + return function () { + var self = this, + args = arguments; + return new Promise(function (resolve, reject) { + var gen = fn.apply(self, args); + + function _next(value) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); + } + + function _throw(err) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); + } + + _next(undefined); + }); + }; +} + +function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +} + +function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } +} + +function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; +} + +function _defineEnumerableProperties(obj, descs) { + for (var key in descs) { + var desc = descs[key]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, key, desc); + } + + if (Object.getOwnPropertySymbols) { + var objectSymbols = Object.getOwnPropertySymbols(descs); + + for (var i = 0; i < objectSymbols.length; i++) { + var sym = objectSymbols[i]; + var desc = descs[sym]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, sym, desc); + } + } + + return obj; +} + +function _defaults(obj, defaults) { + var keys = Object.getOwnPropertyNames(defaults); + + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var value = Object.getOwnPropertyDescriptor(defaults, key); + + if (value && value.configurable && obj[key] === undefined) { + Object.defineProperty(obj, key, value); + } + } + + return obj; +} + +function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; +} + +function _extends() { + _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + + return _extends.apply(this, arguments); +} + +function _objectSpread(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? Object(arguments[i]) : {}; + var ownKeys = Object.keys(source); + + if (typeof Object.getOwnPropertySymbols === 'function') { + ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { + return Object.getOwnPropertyDescriptor(source, sym).enumerable; + })); + } + + ownKeys.forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } + + return target; +} + +function ownKeys(object, enumerableOnly) { + var keys = Object.keys(object); + + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(object); + if (enumerableOnly) symbols = symbols.filter(function (sym) { + return Object.getOwnPropertyDescriptor(object, sym).enumerable; + }); + keys.push.apply(keys, symbols); + } + + return keys; +} + +function _objectSpread2(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? arguments[i] : {}; + + if (i % 2) { + ownKeys(Object(source), true).forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } else if (Object.getOwnPropertyDescriptors) { + Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); + } else { + ownKeys(Object(source)).forEach(function (key) { + Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); + }); + } + } + + return target; +} + +function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function"); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + writable: true, + configurable: true + } + }); + if (superClass) _setPrototypeOf(subClass, superClass); +} + +function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + subClass.__proto__ = superClass; +} + +function _getPrototypeOf(o) { + _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { + return o.__proto__ || Object.getPrototypeOf(o); + }; + return _getPrototypeOf(o); +} + +function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + + return _setPrototypeOf(o, p); +} + +function _isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + + try { + Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); + return true; + } catch (e) { + return false; + } +} + +function _construct(Parent, args, Class) { + if (_isNativeReflectConstruct()) { + _construct = Reflect.construct; + } else { + _construct = function _construct(Parent, args, Class) { + var a = [null]; + a.push.apply(a, args); + var Constructor = Function.bind.apply(Parent, a); + var instance = new Constructor(); + if (Class) _setPrototypeOf(instance, Class.prototype); + return instance; + }; + } + + return _construct.apply(null, arguments); +} + +function _isNativeFunction(fn) { + return Function.toString.call(fn).indexOf("[native code]") !== -1; +} + +function _wrapNativeSuper(Class) { + var _cache = typeof Map === "function" ? new Map() : undefined; + + _wrapNativeSuper = function _wrapNativeSuper(Class) { + if (Class === null || !_isNativeFunction(Class)) return Class; + + if (typeof Class !== "function") { + throw new TypeError("Super expression must either be null or a function"); + } + + if (typeof _cache !== "undefined") { + if (_cache.has(Class)) return _cache.get(Class); + + _cache.set(Class, Wrapper); + } + + function Wrapper() { + return _construct(Class, arguments, _getPrototypeOf(this).constructor); + } + + Wrapper.prototype = Object.create(Class.prototype, { + constructor: { + value: Wrapper, + enumerable: false, + writable: true, + configurable: true + } + }); + return _setPrototypeOf(Wrapper, Class); + }; + + return _wrapNativeSuper(Class); +} + +function _instanceof(left, right) { + if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { + return !!right[Symbol.hasInstance](left); + } else { + return left instanceof right; + } +} + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; +} + +function _getRequireWildcardCache() { + if (typeof WeakMap !== "function") return null; + var cache = new WeakMap(); + + _getRequireWildcardCache = function () { + return cache; + }; + + return cache; +} + +function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } + + if (obj === null || typeof obj !== "object" && typeof obj !== "function") { + return { + default: obj + }; + } + + var cache = _getRequireWildcardCache(); + + if (cache && cache.has(obj)) { + return cache.get(obj); + } + + var newObj = {}; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + + if (desc && (desc.get || desc.set)) { + Object.defineProperty(newObj, key, desc); + } else { + newObj[key] = obj[key]; + } + } + } + + newObj.default = obj; + + if (cache) { + cache.set(obj, newObj); + } + + return newObj; +} + +function _newArrowCheck(innerThis, boundThis) { + if (innerThis !== boundThis) { + throw new TypeError("Cannot instantiate an arrow function"); + } +} + +function _objectDestructuringEmpty(obj) { + if (obj == null) throw new TypeError("Cannot destructure undefined"); +} + +function _objectWithoutPropertiesLoose(source, excluded) { + if (source == null) return {}; + var target = {}; + var sourceKeys = Object.keys(source); + var key, i; + + for (i = 0; i < sourceKeys.length; i++) { + key = sourceKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + target[key] = source[key]; + } + + return target; +} + +function _objectWithoutProperties(source, excluded) { + if (source == null) return {}; + + var target = _objectWithoutPropertiesLoose(source, excluded); + + var key, i; + + if (Object.getOwnPropertySymbols) { + var sourceSymbolKeys = Object.getOwnPropertySymbols(source); + + for (i = 0; i < sourceSymbolKeys.length; i++) { + key = sourceSymbolKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; + target[key] = source[key]; + } + } + + return target; +} + +function _assertThisInitialized(self) { + if (self === void 0) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return self; +} + +function _possibleConstructorReturn(self, call) { + if (call && (typeof call === "object" || typeof call === "function")) { + return call; + } + + return _assertThisInitialized(self); +} + +function _createSuper(Derived) { + var hasNativeReflectConstruct = _isNativeReflectConstruct(); + + return function _createSuperInternal() { + var Super = _getPrototypeOf(Derived), + result; + + if (hasNativeReflectConstruct) { + var NewTarget = _getPrototypeOf(this).constructor; + + result = Reflect.construct(Super, arguments, NewTarget); + } else { + result = Super.apply(this, arguments); + } + + return _possibleConstructorReturn(this, result); + }; +} + +function _superPropBase(object, property) { + while (!Object.prototype.hasOwnProperty.call(object, property)) { + object = _getPrototypeOf(object); + if (object === null) break; + } + + return object; +} + +function _get(target, property, receiver) { + if (typeof Reflect !== "undefined" && Reflect.get) { + _get = Reflect.get; + } else { + _get = function _get(target, property, receiver) { + var base = _superPropBase(target, property); + + if (!base) return; + var desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.get) { + return desc.get.call(receiver); + } + + return desc.value; + }; + } + + return _get(target, property, receiver || target); +} + +function set(target, property, value, receiver) { + if (typeof Reflect !== "undefined" && Reflect.set) { + set = Reflect.set; + } else { + set = function set(target, property, value, receiver) { + var base = _superPropBase(target, property); + + var desc; + + if (base) { + desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.set) { + desc.set.call(receiver, value); + return true; + } else if (!desc.writable) { + return false; + } + } + + desc = Object.getOwnPropertyDescriptor(receiver, property); + + if (desc) { + if (!desc.writable) { + return false; + } + + desc.value = value; + Object.defineProperty(receiver, property, desc); + } else { + _defineProperty(receiver, property, value); + } + + return true; + }; + } + + return set(target, property, value, receiver); +} + +function _set(target, property, value, receiver, isStrict) { + var s = set(target, property, value, receiver || target); + + if (!s && isStrict) { + throw new Error('failed to set property'); + } + + return value; +} + +function _taggedTemplateLiteral(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + return Object.freeze(Object.defineProperties(strings, { + raw: { + value: Object.freeze(raw) + } + })); +} + +function _taggedTemplateLiteralLoose(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + strings.raw = raw; + return strings; +} + +function _readOnlyError(name) { + throw new Error("\"" + name + "\" is read-only"); +} + +function _classNameTDZError(name) { + throw new Error("Class \"" + name + "\" cannot be referenced in computed property keys."); +} + +function _temporalUndefined() {} + +function _tdz(name) { + throw new ReferenceError(name + " is not defined - temporal dead zone"); +} + +function _temporalRef(val, name) { + return val === _temporalUndefined ? _tdz(name) : val; +} + +function _slicedToArray(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); +} + +function _slicedToArrayLoose(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimitLoose(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); +} + +function _toArray(arr) { + return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); +} + +function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); +} + +function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) return _arrayLikeToArray(arr); +} + +function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; +} + +function _maybeArrayLike(next, arr, i) { + if (arr && !Array.isArray(arr) && typeof arr.length === "number") { + var len = arr.length; + return _arrayLikeToArray(arr, i !== void 0 && i < len ? i : len); + } + + return next(arr, i); +} + +function _iterableToArray(iter) { + if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); +} + +function _iterableToArrayLimit(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"] != null) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; +} + +function _iterableToArrayLimitLoose(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + + for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { + _arr.push(_step.value); + + if (i && _arr.length === i) break; + } + + return _arr; +} + +function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if (typeof o === "string") return _arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + if (n === "Object" && o.constructor) n = o.constructor.name; + if (n === "Map" || n === "Set") return Array.from(o); + if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); +} + +function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) len = arr.length; + + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + + return arr2; +} + +function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); +} + +function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); +} + +function _createForOfIteratorHelper(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + + var F = function () {}; + + return { + s: F, + n: function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }, + e: function (e) { + throw e; + }, + f: F + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + var normalCompletion = true, + didErr = false, + err; + return { + s: function () { + it = o[Symbol.iterator](); + }, + n: function () { + var step = it.next(); + normalCompletion = step.done; + return step; + }, + e: function (e) { + didErr = true; + err = e; + }, + f: function () { + try { + if (!normalCompletion && it.return != null) it.return(); + } finally { + if (didErr) throw err; + } + } + }; +} + +function _createForOfIteratorHelperLoose(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + return function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + it = o[Symbol.iterator](); + return it.next.bind(it); +} + +function _skipFirstGeneratorNext(fn) { + return function () { + var it = fn.apply(this, arguments); + it.next(); + return it; + }; +} + +function _toPrimitive(input, hint) { + if (typeof input !== "object" || input === null) return input; + var prim = input[Symbol.toPrimitive]; + + if (prim !== undefined) { + var res = prim.call(input, hint || "default"); + if (typeof res !== "object") return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + + return (hint === "string" ? String : Number)(input); +} + +function _toPropertyKey(arg) { + var key = _toPrimitive(arg, "string"); + + return typeof key === "symbol" ? key : String(key); +} + +function _initializerWarningHelper(descriptor, context) { + throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.'); +} + +function _initializerDefineProperty(target, property, descriptor, context) { + if (!descriptor) return; + Object.defineProperty(target, property, { + enumerable: descriptor.enumerable, + configurable: descriptor.configurable, + writable: descriptor.writable, + value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 + }); +} + +function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { + var desc = {}; + Object.keys(descriptor).forEach(function (key) { + desc[key] = descriptor[key]; + }); + desc.enumerable = !!desc.enumerable; + desc.configurable = !!desc.configurable; + + if ('value' in desc || desc.initializer) { + desc.writable = true; + } + + desc = decorators.slice().reverse().reduce(function (desc, decorator) { + return decorator(target, property, desc) || desc; + }, desc); + + if (context && desc.initializer !== void 0) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = undefined; + } + + if (desc.initializer === void 0) { + Object.defineProperty(target, property, desc); + desc = null; + } + + return desc; +} + +var id = 0; + +function _classPrivateFieldLooseKey(name) { + return "__private_" + id++ + "_" + name; +} + +function _classPrivateFieldLooseBase(receiver, privateKey) { + if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { + throw new TypeError("attempted to use private field on non-instance"); + } + + return receiver; +} + +function _classPrivateFieldGet(receiver, privateMap) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to get private field on non-instance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; +} + +function _classPrivateFieldSet(receiver, privateMap, value) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to set private field on non-instance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; +} + +function _classPrivateFieldDestructureSet(receiver, privateMap) { + if (!privateMap.has(receiver)) { + throw new TypeError("attempted to set private field on non-instance"); + } + + var descriptor = privateMap.get(receiver); + + if (descriptor.set) { + if (!("__destrObj" in descriptor)) { + descriptor.__destrObj = { + set value(v) { + descriptor.set.call(receiver, v); + } + + }; + } + + return descriptor.__destrObj; + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + return descriptor; + } +} + +function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; +} + +function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; +} + +function _classStaticPrivateMethodGet(receiver, classConstructor, method) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + return method; +} + +function _classStaticPrivateMethodSet() { + throw new TypeError("attempted to set read only static private field"); +} + +function _decorate(decorators, factory, superClass, mixins) { + var api = _getDecoratorsApi(); + + if (mixins) { + for (var i = 0; i < mixins.length; i++) { + api = mixins[i](api); + } + } + + var r = factory(function initialize(O) { + api.initializeInstanceElements(O, decorated.elements); + }, superClass); + var decorated = api.decorateClass(_coalesceClassElements(r.d.map(_createElementDescriptor)), decorators); + api.initializeClassElements(r.F, decorated.elements); + return api.runClassFinishers(r.F, decorated.finishers); +} + +function _getDecoratorsApi() { + _getDecoratorsApi = function () { + return api; + }; + + var api = { + elementsDefinitionOrder: [["method"], ["field"]], + initializeInstanceElements: function (O, elements) { + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + if (element.kind === kind && element.placement === "own") { + this.defineClassElement(O, element); + } + }, this); + }, this); + }, + initializeClassElements: function (F, elements) { + var proto = F.prototype; + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + var placement = element.placement; + + if (element.kind === kind && (placement === "static" || placement === "prototype")) { + var receiver = placement === "static" ? F : proto; + this.defineClassElement(receiver, element); + } + }, this); + }, this); + }, + defineClassElement: function (receiver, element) { + var descriptor = element.descriptor; + + if (element.kind === "field") { + var initializer = element.initializer; + descriptor = { + enumerable: descriptor.enumerable, + writable: descriptor.writable, + configurable: descriptor.configurable, + value: initializer === void 0 ? void 0 : initializer.call(receiver) + }; + } + + Object.defineProperty(receiver, element.key, descriptor); + }, + decorateClass: function (elements, decorators) { + var newElements = []; + var finishers = []; + var placements = { + static: [], + prototype: [], + own: [] + }; + elements.forEach(function (element) { + this.addElementPlacement(element, placements); + }, this); + elements.forEach(function (element) { + if (!_hasDecorators(element)) return newElements.push(element); + var elementFinishersExtras = this.decorateElement(element, placements); + newElements.push(elementFinishersExtras.element); + newElements.push.apply(newElements, elementFinishersExtras.extras); + finishers.push.apply(finishers, elementFinishersExtras.finishers); + }, this); + + if (!decorators) { + return { + elements: newElements, + finishers: finishers + }; + } + + var result = this.decorateConstructor(newElements, decorators); + finishers.push.apply(finishers, result.finishers); + result.finishers = finishers; + return result; + }, + addElementPlacement: function (element, placements, silent) { + var keys = placements[element.placement]; + + if (!silent && keys.indexOf(element.key) !== -1) { + throw new TypeError("Duplicated element (" + element.key + ")"); + } + + keys.push(element.key); + }, + decorateElement: function (element, placements) { + var extras = []; + var finishers = []; + + for (var decorators = element.decorators, i = decorators.length - 1; i >= 0; i--) { + var keys = placements[element.placement]; + keys.splice(keys.indexOf(element.key), 1); + var elementObject = this.fromElementDescriptor(element); + var elementFinisherExtras = this.toElementFinisherExtras((0, decorators[i])(elementObject) || elementObject); + element = elementFinisherExtras.element; + this.addElementPlacement(element, placements); + + if (elementFinisherExtras.finisher) { + finishers.push(elementFinisherExtras.finisher); + } + + var newExtras = elementFinisherExtras.extras; + + if (newExtras) { + for (var j = 0; j < newExtras.length; j++) { + this.addElementPlacement(newExtras[j], placements); + } + + extras.push.apply(extras, newExtras); + } + } + + return { + element: element, + finishers: finishers, + extras: extras + }; + }, + decorateConstructor: function (elements, decorators) { + var finishers = []; + + for (var i = decorators.length - 1; i >= 0; i--) { + var obj = this.fromClassDescriptor(elements); + var elementsAndFinisher = this.toClassDescriptor((0, decorators[i])(obj) || obj); + + if (elementsAndFinisher.finisher !== undefined) { + finishers.push(elementsAndFinisher.finisher); + } + + if (elementsAndFinisher.elements !== undefined) { + elements = elementsAndFinisher.elements; + + for (var j = 0; j < elements.length - 1; j++) { + for (var k = j + 1; k < elements.length; k++) { + if (elements[j].key === elements[k].key && elements[j].placement === elements[k].placement) { + throw new TypeError("Duplicated element (" + elements[j].key + ")"); + } + } + } + } + } + + return { + elements: elements, + finishers: finishers + }; + }, + fromElementDescriptor: function (element) { + var obj = { + kind: element.kind, + key: element.key, + placement: element.placement, + descriptor: element.descriptor + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + if (element.kind === "field") obj.initializer = element.initializer; + return obj; + }, + toElementDescriptors: function (elementObjects) { + if (elementObjects === undefined) return; + return _toArray(elementObjects).map(function (elementObject) { + var element = this.toElementDescriptor(elementObject); + this.disallowProperty(elementObject, "finisher", "An element descriptor"); + this.disallowProperty(elementObject, "extras", "An element descriptor"); + return element; + }, this); + }, + toElementDescriptor: function (elementObject) { + var kind = String(elementObject.kind); + + if (kind !== "method" && kind !== "field") { + throw new TypeError('An element descriptor\'s .kind property must be either "method" or' + ' "field", but a decorator created an element descriptor with' + ' .kind "' + kind + '"'); + } + + var key = _toPropertyKey(elementObject.key); + + var placement = String(elementObject.placement); + + if (placement !== "static" && placement !== "prototype" && placement !== "own") { + throw new TypeError('An element descriptor\'s .placement property must be one of "static",' + ' "prototype" or "own", but a decorator created an element descriptor' + ' with .placement "' + placement + '"'); + } + + var descriptor = elementObject.descriptor; + this.disallowProperty(elementObject, "elements", "An element descriptor"); + var element = { + kind: kind, + key: key, + placement: placement, + descriptor: Object.assign({}, descriptor) + }; + + if (kind !== "field") { + this.disallowProperty(elementObject, "initializer", "A method descriptor"); + } else { + this.disallowProperty(descriptor, "get", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "set", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "value", "The property descriptor of a field descriptor"); + element.initializer = elementObject.initializer; + } + + return element; + }, + toElementFinisherExtras: function (elementObject) { + var element = this.toElementDescriptor(elementObject); + + var finisher = _optionalCallableProperty(elementObject, "finisher"); + + var extras = this.toElementDescriptors(elementObject.extras); + return { + element: element, + finisher: finisher, + extras: extras + }; + }, + fromClassDescriptor: function (elements) { + var obj = { + kind: "class", + elements: elements.map(this.fromElementDescriptor, this) + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + return obj; + }, + toClassDescriptor: function (obj) { + var kind = String(obj.kind); + + if (kind !== "class") { + throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator' + ' created a class descriptor with .kind "' + kind + '"'); + } + + this.disallowProperty(obj, "key", "A class descriptor"); + this.disallowProperty(obj, "placement", "A class descriptor"); + this.disallowProperty(obj, "descriptor", "A class descriptor"); + this.disallowProperty(obj, "initializer", "A class descriptor"); + this.disallowProperty(obj, "extras", "A class descriptor"); + + var finisher = _optionalCallableProperty(obj, "finisher"); + + var elements = this.toElementDescriptors(obj.elements); + return { + elements: elements, + finisher: finisher + }; + }, + runClassFinishers: function (constructor, finishers) { + for (var i = 0; i < finishers.length; i++) { + var newConstructor = (0, finishers[i])(constructor); + + if (newConstructor !== undefined) { + if (typeof newConstructor !== "function") { + throw new TypeError("Finishers must return a constructor."); + } + + constructor = newConstructor; + } + } + + return constructor; + }, + disallowProperty: function (obj, name, objectType) { + if (obj[name] !== undefined) { + throw new TypeError(objectType + " can't have a ." + name + " property."); + } + } + }; + return api; +} + +function _createElementDescriptor(def) { + var key = _toPropertyKey(def.key); + + var descriptor; + + if (def.kind === "method") { + descriptor = { + value: def.value, + writable: true, + configurable: true, + enumerable: false + }; + } else if (def.kind === "get") { + descriptor = { + get: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "set") { + descriptor = { + set: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "field") { + descriptor = { + configurable: true, + writable: true, + enumerable: true + }; + } + + var element = { + kind: def.kind === "field" ? "field" : "method", + key: key, + placement: def.static ? "static" : def.kind === "field" ? "own" : "prototype", + descriptor: descriptor + }; + if (def.decorators) element.decorators = def.decorators; + if (def.kind === "field") element.initializer = def.value; + return element; +} + +function _coalesceGetterSetter(element, other) { + if (element.descriptor.get !== undefined) { + other.descriptor.get = element.descriptor.get; + } else { + other.descriptor.set = element.descriptor.set; + } +} + +function _coalesceClassElements(elements) { + var newElements = []; + + var isSameElement = function (other) { + return other.kind === "method" && other.key === element.key && other.placement === element.placement; + }; + + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + var other; + + if (element.kind === "method" && (other = newElements.find(isSameElement))) { + if (_isDataDescriptor(element.descriptor) || _isDataDescriptor(other.descriptor)) { + if (_hasDecorators(element) || _hasDecorators(other)) { + throw new ReferenceError("Duplicated methods (" + element.key + ") can't be decorated."); + } + + other.descriptor = element.descriptor; + } else { + if (_hasDecorators(element)) { + if (_hasDecorators(other)) { + throw new ReferenceError("Decorators can't be placed on different accessors with for " + "the same property (" + element.key + ")."); + } + + other.decorators = element.decorators; + } + + _coalesceGetterSetter(element, other); + } + } else { + newElements.push(element); + } + } + + return newElements; +} + +function _hasDecorators(element) { + return element.decorators && element.decorators.length; +} + +function _isDataDescriptor(desc) { + return desc !== undefined && !(desc.value === undefined && desc.writable === undefined); +} + +function _optionalCallableProperty(obj, name) { + var value = obj[name]; + + if (value !== undefined && typeof value !== "function") { + throw new TypeError("Expected '" + name + "' to be a function"); + } + + return value; +} + +function _classPrivateMethodGet(receiver, privateSet, fn) { + if (!privateSet.has(receiver)) { + throw new TypeError("attempted to get private field on non-instance"); + } + + return fn; +} + +function _classPrivateMethodSet() { + throw new TypeError("attempted to reassign private method"); +} + +function _wrapRegExp(re, groups) { + _wrapRegExp = function (re, groups) { + return new BabelRegExp(re, undefined, groups); + }; + + var _RegExp = _wrapNativeSuper(RegExp); + + var _super = RegExp.prototype; + + var _groups = new WeakMap(); + + function BabelRegExp(re, flags, groups) { + var _this = _RegExp.call(this, re, flags); + + _groups.set(_this, groups || _groups.get(re)); + + return _this; + } + + _inherits(BabelRegExp, _RegExp); + + BabelRegExp.prototype.exec = function (str) { + var result = _super.exec.call(this, str); + + if (result) result.groups = buildGroups(result, this); + return result; + }; + + BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { + if (typeof substitution === "string") { + var groups = _groups.get(this); + + return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { + return "$" + groups[name]; + })); + } else if (typeof substitution === "function") { + var _this = this; + + return _super[Symbol.replace].call(this, str, function () { + var args = []; + args.push.apply(args, arguments); + + if (typeof args[args.length - 1] !== "object") { + args.push(buildGroups(args, _this)); + } + + return substitution.apply(this, args); + }); + } else { + return _super[Symbol.replace].call(this, str, substitution); + } + }; + + function buildGroups(result, re) { + var g = _groups.get(re); + + return Object.keys(g).reduce(function (groups, name) { + groups[name] = result[g[name]]; + return groups; + }, Object.create(null)); + } + + return _wrapRegExp.apply(this, arguments); +} + +var gridIcon = "grid-icon.xml"; + +var extGrid = { + name: 'grid', + init: function init(_ref) { + var _this = this; + + return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { + var $, NS, getTypeMap, importLocale, strings, svgEditor, svgCanvas, svgdoc, assignAttributes, hcanvas, canvBG, units, intervals, showGrid, canvasGrid, gridDefs, gridPattern, gridimg, gridBox, updateGrid, gridUpdate, buttons; + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + gridUpdate = function _gridUpdate() { + if (showGrid) { + updateGrid(svgCanvas.getZoom()); + } + + $('#canvasGrid').toggle(showGrid); + $('#view_grid').toggleClass('push_button_pressed tool_button'); + }; + + updateGrid = function _updateGrid(zoom) { + // TODO: Try this with elements, then compare performance difference + var unit = units[svgEditor.curConfig.baseUnit]; // 1 = 1px + + var uMulti = unit * zoom; // Calculate the main number interval + + var rawM = 100 / uMulti; + var multi = 1; + intervals.some(function (num) { + multi = num; + return rawM <= num; + }); + var bigInt = multi * uMulti; // Set the canvas size to the width of the container + + hcanvas.width = bigInt; + hcanvas.height = bigInt; + var ctx = hcanvas.getContext('2d'); + var curD = 0.5; + var part = bigInt / 10; + ctx.globalAlpha = 0.2; + ctx.strokeStyle = svgEditor.curConfig.gridColor; + + for (var i = 1; i < 10; i++) { + var subD = Math.round(part * i) + 0.5; // const lineNum = (i % 2)?12:10; + + var lineNum = 0; + ctx.moveTo(subD, bigInt); + ctx.lineTo(subD, lineNum); + ctx.moveTo(bigInt, subD); + ctx.lineTo(lineNum, subD); + } + + ctx.stroke(); + ctx.beginPath(); + ctx.globalAlpha = 0.5; + ctx.moveTo(curD, bigInt); + ctx.lineTo(curD, 0); + ctx.moveTo(bigInt, curD); + ctx.lineTo(0, curD); + ctx.stroke(); + var datauri = hcanvas.toDataURL('image/png'); + gridimg.setAttribute('width', bigInt); + gridimg.setAttribute('height', bigInt); + gridimg.parentNode.setAttribute('width', bigInt); + gridimg.parentNode.setAttribute('height', bigInt); + svgCanvas.setHref(gridimg, datauri); + }; + + $ = _ref.$, NS = _ref.NS, getTypeMap = _ref.getTypeMap, importLocale = _ref.importLocale; + _context.next = 5; + return importLocale(); + + case 5: + strings = _context.sent; + svgEditor = _this; + svgCanvas = svgEditor.canvas; + svgdoc = document.getElementById('svgcanvas').ownerDocument, assignAttributes = svgCanvas.assignAttributes, hcanvas = document.createElement('canvas'), canvBG = $('#canvasBackground'), units = getTypeMap(), intervals = [0.01, 0.1, 1, 10, 100, 1000]; + showGrid = svgEditor.curConfig.showGrid || false; + $(hcanvas).hide().appendTo('body'); + canvasGrid = svgdoc.createElementNS(NS.SVG, 'svg'); + assignAttributes(canvasGrid, { + id: 'canvasGrid', + width: '100%', + height: '100%', + x: 0, + y: 0, + overflow: 'visible', + display: 'none' + }); + canvBG.append(canvasGrid); + gridDefs = svgdoc.createElementNS(NS.SVG, 'defs'); // grid-pattern + + gridPattern = svgdoc.createElementNS(NS.SVG, 'pattern'); + assignAttributes(gridPattern, { + id: 'gridpattern', + patternUnits: 'userSpaceOnUse', + x: 0, + // -(value.strokeWidth / 2), // position for strokewidth + y: 0, + // -(value.strokeWidth / 2), // position for strokewidth + width: 100, + height: 100 + }); + gridimg = svgdoc.createElementNS(NS.SVG, 'image'); + assignAttributes(gridimg, { + x: 0, + y: 0, + width: 100, + height: 100 + }); + gridPattern.append(gridimg); + gridDefs.append(gridPattern); + $('#canvasGrid').append(gridDefs); // grid-box + + gridBox = svgdoc.createElementNS(NS.SVG, 'rect'); + assignAttributes(gridBox, { + width: '100%', + height: '100%', + x: 0, + y: 0, + 'stroke-width': 0, + stroke: 'none', + fill: 'url(#gridpattern)', + style: 'pointer-events: none; display:visible;' + }); + $('#canvasGrid').append(gridBox); + /** + * + * @param {Float} zoom + * @returns {void} + */ + + buttons = [{ + id: 'view_grid', + icon: svgEditor.curConfig.extIconsPath + 'grid.png', + type: 'context', + panel: 'editor_panel', + events: { + click: function click() { + svgEditor.curConfig.showGrid = showGrid = !showGrid; + gridUpdate(); + } + } + }]; + return _context.abrupt("return", { + name: strings.name, + svgicons: svgEditor.curConfig.extIconsPath + 'grid-icon.xml', + zoomChanged: function zoomChanged(zoom) { + if (showGrid) { + updateGrid(zoom); + } + }, + callback: function callback() { + if (showGrid) { + gridUpdate(); + } + }, + buttons: strings.buttons.map(function (button, i) { + return Object.assign(buttons[i], button); + }) + }); + + case 27: + case "end": + return _context.stop(); + } + } + }, _callee); + }))(); + } +}; + +export default extGrid; +//# sourceMappingURL=ext-grid.js.map diff --git a/dist/editor/extensions/ext-grid.js.map b/dist/editor/extensions/ext-grid.js.map new file mode 100644 index 00000000..8774cf80 --- /dev/null +++ b/dist/editor/extensions/ext-grid.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ext-grid.js","sources":["../../../src/editor/extensions/grid-icon.xml","../../../src/editor/extensions/ext-grid.js"],"sourcesContent":["export default \"grid-icon.xml\"","/**\n * @file ext-grid.js\n *\n * @license Apache-2.0\n *\n * @copyright 2010 Redou Mine, 2010 Alexis Deveria\n *\n */\n\nimport './grid-icon.xml';\n\nexport default {\n name: 'grid',\n async init ({$, NS, getTypeMap, importLocale}) {\n const strings = await importLocale();\n const svgEditor = this;\n const svgCanvas = svgEditor.canvas;\n const svgdoc = document.getElementById('svgcanvas').ownerDocument,\n {assignAttributes} = svgCanvas,\n hcanvas = document.createElement('canvas'),\n canvBG = $('#canvasBackground'),\n units = getTypeMap(), // Assumes prior `init()` call on `units.js` module\n intervals = [0.01, 0.1, 1, 10, 100, 1000];\n let showGrid = svgEditor.curConfig.showGrid || false;\n\n $(hcanvas).hide().appendTo('body');\n\n const canvasGrid = svgdoc.createElementNS(NS.SVG, 'svg');\n assignAttributes(canvasGrid, {\n id: 'canvasGrid',\n width: '100%',\n height: '100%',\n x: 0,\n y: 0,\n overflow: 'visible',\n display: 'none'\n });\n canvBG.append(canvasGrid);\n const gridDefs = svgdoc.createElementNS(NS.SVG, 'defs');\n // grid-pattern\n const gridPattern = svgdoc.createElementNS(NS.SVG, 'pattern');\n assignAttributes(gridPattern, {\n id: 'gridpattern',\n patternUnits: 'userSpaceOnUse',\n x: 0, // -(value.strokeWidth / 2), // position for strokewidth\n y: 0, // -(value.strokeWidth / 2), // position for strokewidth\n width: 100,\n height: 100\n });\n\n const gridimg = svgdoc.createElementNS(NS.SVG, 'image');\n assignAttributes(gridimg, {\n x: 0,\n y: 0,\n width: 100,\n height: 100\n });\n gridPattern.append(gridimg);\n gridDefs.append(gridPattern);\n $('#canvasGrid').append(gridDefs);\n\n // grid-box\n const gridBox = svgdoc.createElementNS(NS.SVG, 'rect');\n assignAttributes(gridBox, {\n width: '100%',\n height: '100%',\n x: 0,\n y: 0,\n 'stroke-width': 0,\n stroke: 'none',\n fill: 'url(#gridpattern)',\n style: 'pointer-events: none; display:visible;'\n });\n $('#canvasGrid').append(gridBox);\n\n /**\n *\n * @param {Float} zoom\n * @returns {void}\n */\n function updateGrid (zoom) {\n // TODO: Try this with elements, then compare performance difference\n const unit = units[svgEditor.curConfig.baseUnit]; // 1 = 1px\n const uMulti = unit * zoom;\n // Calculate the main number interval\n const rawM = 100 / uMulti;\n let multi = 1;\n intervals.some((num) => {\n multi = num;\n return rawM <= num;\n });\n const bigInt = multi * uMulti;\n\n // Set the canvas size to the width of the container\n hcanvas.width = bigInt;\n hcanvas.height = bigInt;\n const ctx = hcanvas.getContext('2d');\n const curD = 0.5;\n const part = bigInt / 10;\n\n ctx.globalAlpha = 0.2;\n ctx.strokeStyle = svgEditor.curConfig.gridColor;\n for (let i = 1; i < 10; i++) {\n const subD = Math.round(part * i) + 0.5;\n // const lineNum = (i % 2)?12:10;\n const lineNum = 0;\n ctx.moveTo(subD, bigInt);\n ctx.lineTo(subD, lineNum);\n ctx.moveTo(bigInt, subD);\n ctx.lineTo(lineNum, subD);\n }\n ctx.stroke();\n ctx.beginPath();\n ctx.globalAlpha = 0.5;\n ctx.moveTo(curD, bigInt);\n ctx.lineTo(curD, 0);\n\n ctx.moveTo(bigInt, curD);\n ctx.lineTo(0, curD);\n ctx.stroke();\n\n const datauri = hcanvas.toDataURL('image/png');\n gridimg.setAttribute('width', bigInt);\n gridimg.setAttribute('height', bigInt);\n gridimg.parentNode.setAttribute('width', bigInt);\n gridimg.parentNode.setAttribute('height', bigInt);\n svgCanvas.setHref(gridimg, datauri);\n }\n\n /**\n *\n * @returns {void}\n */\n function gridUpdate () {\n if (showGrid) {\n updateGrid(svgCanvas.getZoom());\n }\n $('#canvasGrid').toggle(showGrid);\n $('#view_grid').toggleClass('push_button_pressed tool_button');\n }\n const buttons = [{\n id: 'view_grid',\n icon: svgEditor.curConfig.extIconsPath + 'grid.png',\n type: 'context',\n panel: 'editor_panel',\n events: {\n click () {\n svgEditor.curConfig.showGrid = showGrid = !showGrid;\n gridUpdate();\n }\n }\n }];\n return {\n name: strings.name,\n svgicons: svgEditor.curConfig.extIconsPath + 'grid-icon.xml',\n\n zoomChanged (zoom) {\n if (showGrid) { updateGrid(zoom); }\n },\n callback () {\n if (showGrid) {\n gridUpdate();\n }\n },\n buttons: strings.buttons.map((button, i) => {\n return Object.assign(buttons[i], button);\n })\n };\n }\n};\n"],"names":["name","init","updateGrid","gridUpdate","showGrid","svgCanvas","getZoom","$","toggle","toggleClass","zoom","unit","units","svgEditor","curConfig","baseUnit","uMulti","rawM","multi","intervals","some","num","bigInt","hcanvas","width","height","ctx","getContext","curD","part","globalAlpha","strokeStyle","gridColor","i","subD","Math","round","lineNum","moveTo","lineTo","stroke","beginPath","datauri","toDataURL","gridimg","setAttribute","parentNode","setHref","NS","getTypeMap","importLocale","strings","canvas","svgdoc","document","getElementById","ownerDocument","assignAttributes","createElement","canvBG","hide","appendTo","canvasGrid","createElementNS","SVG","id","x","y","overflow","display","append","gridDefs","gridPattern","patternUnits","gridBox","fill","style","buttons","icon","extIconsPath","type","panel","events","click","svgicons","zoomChanged","callback","map","button","Object","assign"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,EAAEvE,SAAS,CAACC,SAAV,CAAoBiE,YAApB,GAAmC,eAFxC;AAILM,gBAAAA,WAJK,uBAIQ3E,IAJR,EAIc;AACjB,sBAAIN,QAAJ,EAAc;AAAEF,oBAAAA,UAAU,CAACQ,IAAD,CAAV;AAAmB;AACpC,iBANI;AAOL4E,gBAAAA,QAPK,sBAOO;AACV,sBAAIlF,QAAJ,EAAc;AACZD,oBAAAA,UAAU;AACX;AACF,iBAXI;AAYL0E,gBAAAA,OAAO,EAAE1B,OAAO,CAAC0B,OAAR,CAAgBU,GAAhB,CAAoB,UAACC,MAAD,EAASvD,CAAT,EAAe;AAC1C,yBAAOwD,MAAM,CAACC,MAAP,CAAcb,OAAO,CAAC5C,CAAD,CAArB,EAA0BuD,MAA1B,CAAP;AACD,iBAFQ;AAZJ,eA3IsC;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2J9C;AA7JY,CAAf;;;;"} \ No newline at end of file diff --git a/dist/editor/extensions/ext-helloworld.js b/dist/editor/extensions/ext-helloworld.js new file mode 100644 index 00000000..b9db0587 --- /dev/null +++ b/dist/editor/extensions/ext-helloworld.js @@ -0,0 +1,1757 @@ +function _typeof(obj) { + "@babel/helpers - typeof"; + + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function (obj) { + return typeof obj; + }; + } else { + _typeof = function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); +} + +var REACT_ELEMENT_TYPE; + +function _jsx(type, props, key, children) { + if (!REACT_ELEMENT_TYPE) { + REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol["for"] && Symbol["for"]("react.element") || 0xeac7; + } + + var defaultProps = type && type.defaultProps; + var childrenLength = arguments.length - 3; + + if (!props && childrenLength !== 0) { + props = { + children: void 0 + }; + } + + if (childrenLength === 1) { + props.children = children; + } else if (childrenLength > 1) { + var childArray = new Array(childrenLength); + + for (var i = 0; i < childrenLength; i++) { + childArray[i] = arguments[i + 3]; + } + + props.children = childArray; + } + + if (props && defaultProps) { + for (var propName in defaultProps) { + if (props[propName] === void 0) { + props[propName] = defaultProps[propName]; + } + } + } else if (!props) { + props = defaultProps || {}; + } + + return { + $$typeof: REACT_ELEMENT_TYPE, + type: type, + key: key === undefined ? null : '' + key, + ref: null, + props: props, + _owner: null + }; +} + +function _asyncIterator(iterable) { + var method; + + if (typeof Symbol !== "undefined") { + if (Symbol.asyncIterator) { + method = iterable[Symbol.asyncIterator]; + if (method != null) return method.call(iterable); + } + + if (Symbol.iterator) { + method = iterable[Symbol.iterator]; + if (method != null) return method.call(iterable); + } + } + + throw new TypeError("Object is not async iterable"); +} + +function _AwaitValue(value) { + this.wrapped = value; +} + +function _AsyncGenerator(gen) { + var front, back; + + function send(key, arg) { + return new Promise(function (resolve, reject) { + var request = { + key: key, + arg: arg, + resolve: resolve, + reject: reject, + next: null + }; + + if (back) { + back = back.next = request; + } else { + front = back = request; + resume(key, arg); + } + }); + } + + function resume(key, arg) { + try { + var result = gen[key](arg); + var value = result.value; + var wrappedAwait = value instanceof _AwaitValue; + Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { + if (wrappedAwait) { + resume(key === "return" ? "return" : "next", arg); + return; + } + + settle(result.done ? "return" : "normal", arg); + }, function (err) { + resume("throw", err); + }); + } catch (err) { + settle("throw", err); + } + } + + function settle(type, value) { + switch (type) { + case "return": + front.resolve({ + value: value, + done: true + }); + break; + + case "throw": + front.reject(value); + break; + + default: + front.resolve({ + value: value, + done: false + }); + break; + } + + front = front.next; + + if (front) { + resume(front.key, front.arg); + } else { + back = null; + } + } + + this._invoke = send; + + if (typeof gen.return !== "function") { + this.return = undefined; + } +} + +if (typeof Symbol === "function" && Symbol.asyncIterator) { + _AsyncGenerator.prototype[Symbol.asyncIterator] = function () { + return this; + }; +} + +_AsyncGenerator.prototype.next = function (arg) { + return this._invoke("next", arg); +}; + +_AsyncGenerator.prototype.throw = function (arg) { + return this._invoke("throw", arg); +}; + +_AsyncGenerator.prototype.return = function (arg) { + return this._invoke("return", arg); +}; + +function _wrapAsyncGenerator(fn) { + return function () { + return new _AsyncGenerator(fn.apply(this, arguments)); + }; +} + +function _awaitAsyncGenerator(value) { + return new _AwaitValue(value); +} + +function _asyncGeneratorDelegate(inner, awaitWrap) { + var iter = {}, + waiting = false; + + function pump(key, value) { + waiting = true; + value = new Promise(function (resolve) { + resolve(inner[key](value)); + }); + return { + done: false, + value: awaitWrap(value) + }; + } + + ; + + if (typeof Symbol === "function" && Symbol.iterator) { + iter[Symbol.iterator] = function () { + return this; + }; + } + + iter.next = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("next", value); + }; + + if (typeof inner.throw === "function") { + iter.throw = function (value) { + if (waiting) { + waiting = false; + throw value; + } + + return pump("throw", value); + }; + } + + if (typeof inner.return === "function") { + iter.return = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("return", value); + }; + } + + return iter; +} + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { + try { + var info = gen[key](arg); + var value = info.value; + } catch (error) { + reject(error); + return; + } + + if (info.done) { + resolve(value); + } else { + Promise.resolve(value).then(_next, _throw); + } +} + +function _asyncToGenerator(fn) { + return function () { + var self = this, + args = arguments; + return new Promise(function (resolve, reject) { + var gen = fn.apply(self, args); + + function _next(value) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); + } + + function _throw(err) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); + } + + _next(undefined); + }); + }; +} + +function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +} + +function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } +} + +function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; +} + +function _defineEnumerableProperties(obj, descs) { + for (var key in descs) { + var desc = descs[key]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, key, desc); + } + + if (Object.getOwnPropertySymbols) { + var objectSymbols = Object.getOwnPropertySymbols(descs); + + for (var i = 0; i < objectSymbols.length; i++) { + var sym = objectSymbols[i]; + var desc = descs[sym]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, sym, desc); + } + } + + return obj; +} + +function _defaults(obj, defaults) { + var keys = Object.getOwnPropertyNames(defaults); + + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var value = Object.getOwnPropertyDescriptor(defaults, key); + + if (value && value.configurable && obj[key] === undefined) { + Object.defineProperty(obj, key, value); + } + } + + return obj; +} + +function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; +} + +function _extends() { + _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + + return _extends.apply(this, arguments); +} + +function _objectSpread(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? Object(arguments[i]) : {}; + var ownKeys = Object.keys(source); + + if (typeof Object.getOwnPropertySymbols === 'function') { + ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { + return Object.getOwnPropertyDescriptor(source, sym).enumerable; + })); + } + + ownKeys.forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } + + return target; +} + +function ownKeys(object, enumerableOnly) { + var keys = Object.keys(object); + + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(object); + if (enumerableOnly) symbols = symbols.filter(function (sym) { + return Object.getOwnPropertyDescriptor(object, sym).enumerable; + }); + keys.push.apply(keys, symbols); + } + + return keys; +} + +function _objectSpread2(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? arguments[i] : {}; + + if (i % 2) { + ownKeys(Object(source), true).forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } else if (Object.getOwnPropertyDescriptors) { + Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); + } else { + ownKeys(Object(source)).forEach(function (key) { + Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); + }); + } + } + + return target; +} + +function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function"); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + writable: true, + configurable: true + } + }); + if (superClass) _setPrototypeOf(subClass, superClass); +} + +function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + subClass.__proto__ = superClass; +} + +function _getPrototypeOf(o) { + _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { + return o.__proto__ || Object.getPrototypeOf(o); + }; + return _getPrototypeOf(o); +} + +function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + + return _setPrototypeOf(o, p); +} + +function _isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + + try { + Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); + return true; + } catch (e) { + return false; + } +} + +function _construct(Parent, args, Class) { + if (_isNativeReflectConstruct()) { + _construct = Reflect.construct; + } else { + _construct = function _construct(Parent, args, Class) { + var a = [null]; + a.push.apply(a, args); + var Constructor = Function.bind.apply(Parent, a); + var instance = new Constructor(); + if (Class) _setPrototypeOf(instance, Class.prototype); + return instance; + }; + } + + return _construct.apply(null, arguments); +} + +function _isNativeFunction(fn) { + return Function.toString.call(fn).indexOf("[native code]") !== -1; +} + +function _wrapNativeSuper(Class) { + var _cache = typeof Map === "function" ? new Map() : undefined; + + _wrapNativeSuper = function _wrapNativeSuper(Class) { + if (Class === null || !_isNativeFunction(Class)) return Class; + + if (typeof Class !== "function") { + throw new TypeError("Super expression must either be null or a function"); + } + + if (typeof _cache !== "undefined") { + if (_cache.has(Class)) return _cache.get(Class); + + _cache.set(Class, Wrapper); + } + + function Wrapper() { + return _construct(Class, arguments, _getPrototypeOf(this).constructor); + } + + Wrapper.prototype = Object.create(Class.prototype, { + constructor: { + value: Wrapper, + enumerable: false, + writable: true, + configurable: true + } + }); + return _setPrototypeOf(Wrapper, Class); + }; + + return _wrapNativeSuper(Class); +} + +function _instanceof(left, right) { + if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { + return !!right[Symbol.hasInstance](left); + } else { + return left instanceof right; + } +} + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; +} + +function _getRequireWildcardCache() { + if (typeof WeakMap !== "function") return null; + var cache = new WeakMap(); + + _getRequireWildcardCache = function () { + return cache; + }; + + return cache; +} + +function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } + + if (obj === null || typeof obj !== "object" && typeof obj !== "function") { + return { + default: obj + }; + } + + var cache = _getRequireWildcardCache(); + + if (cache && cache.has(obj)) { + return cache.get(obj); + } + + var newObj = {}; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + + if (desc && (desc.get || desc.set)) { + Object.defineProperty(newObj, key, desc); + } else { + newObj[key] = obj[key]; + } + } + } + + newObj.default = obj; + + if (cache) { + cache.set(obj, newObj); + } + + return newObj; +} + +function _newArrowCheck(innerThis, boundThis) { + if (innerThis !== boundThis) { + throw new TypeError("Cannot instantiate an arrow function"); + } +} + +function _objectDestructuringEmpty(obj) { + if (obj == null) throw new TypeError("Cannot destructure undefined"); +} + +function _objectWithoutPropertiesLoose(source, excluded) { + if (source == null) return {}; + var target = {}; + var sourceKeys = Object.keys(source); + var key, i; + + for (i = 0; i < sourceKeys.length; i++) { + key = sourceKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + target[key] = source[key]; + } + + return target; +} + +function _objectWithoutProperties(source, excluded) { + if (source == null) return {}; + + var target = _objectWithoutPropertiesLoose(source, excluded); + + var key, i; + + if (Object.getOwnPropertySymbols) { + var sourceSymbolKeys = Object.getOwnPropertySymbols(source); + + for (i = 0; i < sourceSymbolKeys.length; i++) { + key = sourceSymbolKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; + target[key] = source[key]; + } + } + + return target; +} + +function _assertThisInitialized(self) { + if (self === void 0) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return self; +} + +function _possibleConstructorReturn(self, call) { + if (call && (typeof call === "object" || typeof call === "function")) { + return call; + } + + return _assertThisInitialized(self); +} + +function _createSuper(Derived) { + var hasNativeReflectConstruct = _isNativeReflectConstruct(); + + return function _createSuperInternal() { + var Super = _getPrototypeOf(Derived), + result; + + if (hasNativeReflectConstruct) { + var NewTarget = _getPrototypeOf(this).constructor; + + result = Reflect.construct(Super, arguments, NewTarget); + } else { + result = Super.apply(this, arguments); + } + + return _possibleConstructorReturn(this, result); + }; +} + +function _superPropBase(object, property) { + while (!Object.prototype.hasOwnProperty.call(object, property)) { + object = _getPrototypeOf(object); + if (object === null) break; + } + + return object; +} + +function _get(target, property, receiver) { + if (typeof Reflect !== "undefined" && Reflect.get) { + _get = Reflect.get; + } else { + _get = function _get(target, property, receiver) { + var base = _superPropBase(target, property); + + if (!base) return; + var desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.get) { + return desc.get.call(receiver); + } + + return desc.value; + }; + } + + return _get(target, property, receiver || target); +} + +function set(target, property, value, receiver) { + if (typeof Reflect !== "undefined" && Reflect.set) { + set = Reflect.set; + } else { + set = function set(target, property, value, receiver) { + var base = _superPropBase(target, property); + + var desc; + + if (base) { + desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.set) { + desc.set.call(receiver, value); + return true; + } else if (!desc.writable) { + return false; + } + } + + desc = Object.getOwnPropertyDescriptor(receiver, property); + + if (desc) { + if (!desc.writable) { + return false; + } + + desc.value = value; + Object.defineProperty(receiver, property, desc); + } else { + _defineProperty(receiver, property, value); + } + + return true; + }; + } + + return set(target, property, value, receiver); +} + +function _set(target, property, value, receiver, isStrict) { + var s = set(target, property, value, receiver || target); + + if (!s && isStrict) { + throw new Error('failed to set property'); + } + + return value; +} + +function _taggedTemplateLiteral(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + return Object.freeze(Object.defineProperties(strings, { + raw: { + value: Object.freeze(raw) + } + })); +} + +function _taggedTemplateLiteralLoose(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + strings.raw = raw; + return strings; +} + +function _readOnlyError(name) { + throw new Error("\"" + name + "\" is read-only"); +} + +function _classNameTDZError(name) { + throw new Error("Class \"" + name + "\" cannot be referenced in computed property keys."); +} + +function _temporalUndefined() {} + +function _tdz(name) { + throw new ReferenceError(name + " is not defined - temporal dead zone"); +} + +function _temporalRef(val, name) { + return val === _temporalUndefined ? _tdz(name) : val; +} + +function _slicedToArray(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); +} + +function _slicedToArrayLoose(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimitLoose(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); +} + +function _toArray(arr) { + return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); +} + +function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); +} + +function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) return _arrayLikeToArray(arr); +} + +function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; +} + +function _maybeArrayLike(next, arr, i) { + if (arr && !Array.isArray(arr) && typeof arr.length === "number") { + var len = arr.length; + return _arrayLikeToArray(arr, i !== void 0 && i < len ? i : len); + } + + return next(arr, i); +} + +function _iterableToArray(iter) { + if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); +} + +function _iterableToArrayLimit(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"] != null) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; +} + +function _iterableToArrayLimitLoose(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + + for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { + _arr.push(_step.value); + + if (i && _arr.length === i) break; + } + + return _arr; +} + +function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if (typeof o === "string") return _arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + if (n === "Object" && o.constructor) n = o.constructor.name; + if (n === "Map" || n === "Set") return Array.from(o); + if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); +} + +function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) len = arr.length; + + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + + return arr2; +} + +function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); +} + +function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); +} + +function _createForOfIteratorHelper(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + + var F = function () {}; + + return { + s: F, + n: function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }, + e: function (e) { + throw e; + }, + f: F + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + var normalCompletion = true, + didErr = false, + err; + return { + s: function () { + it = o[Symbol.iterator](); + }, + n: function () { + var step = it.next(); + normalCompletion = step.done; + return step; + }, + e: function (e) { + didErr = true; + err = e; + }, + f: function () { + try { + if (!normalCompletion && it.return != null) it.return(); + } finally { + if (didErr) throw err; + } + } + }; +} + +function _createForOfIteratorHelperLoose(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + return function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + it = o[Symbol.iterator](); + return it.next.bind(it); +} + +function _skipFirstGeneratorNext(fn) { + return function () { + var it = fn.apply(this, arguments); + it.next(); + return it; + }; +} + +function _toPrimitive(input, hint) { + if (typeof input !== "object" || input === null) return input; + var prim = input[Symbol.toPrimitive]; + + if (prim !== undefined) { + var res = prim.call(input, hint || "default"); + if (typeof res !== "object") return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + + return (hint === "string" ? String : Number)(input); +} + +function _toPropertyKey(arg) { + var key = _toPrimitive(arg, "string"); + + return typeof key === "symbol" ? key : String(key); +} + +function _initializerWarningHelper(descriptor, context) { + throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.'); +} + +function _initializerDefineProperty(target, property, descriptor, context) { + if (!descriptor) return; + Object.defineProperty(target, property, { + enumerable: descriptor.enumerable, + configurable: descriptor.configurable, + writable: descriptor.writable, + value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 + }); +} + +function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { + var desc = {}; + Object.keys(descriptor).forEach(function (key) { + desc[key] = descriptor[key]; + }); + desc.enumerable = !!desc.enumerable; + desc.configurable = !!desc.configurable; + + if ('value' in desc || desc.initializer) { + desc.writable = true; + } + + desc = decorators.slice().reverse().reduce(function (desc, decorator) { + return decorator(target, property, desc) || desc; + }, desc); + + if (context && desc.initializer !== void 0) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = undefined; + } + + if (desc.initializer === void 0) { + Object.defineProperty(target, property, desc); + desc = null; + } + + return desc; +} + +var id = 0; + +function _classPrivateFieldLooseKey(name) { + return "__private_" + id++ + "_" + name; +} + +function _classPrivateFieldLooseBase(receiver, privateKey) { + if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { + throw new TypeError("attempted to use private field on non-instance"); + } + + return receiver; +} + +function _classPrivateFieldGet(receiver, privateMap) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to get private field on non-instance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; +} + +function _classPrivateFieldSet(receiver, privateMap, value) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to set private field on non-instance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; +} + +function _classPrivateFieldDestructureSet(receiver, privateMap) { + if (!privateMap.has(receiver)) { + throw new TypeError("attempted to set private field on non-instance"); + } + + var descriptor = privateMap.get(receiver); + + if (descriptor.set) { + if (!("__destrObj" in descriptor)) { + descriptor.__destrObj = { + set value(v) { + descriptor.set.call(receiver, v); + } + + }; + } + + return descriptor.__destrObj; + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + return descriptor; + } +} + +function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; +} + +function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; +} + +function _classStaticPrivateMethodGet(receiver, classConstructor, method) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + return method; +} + +function _classStaticPrivateMethodSet() { + throw new TypeError("attempted to set read only static private field"); +} + +function _decorate(decorators, factory, superClass, mixins) { + var api = _getDecoratorsApi(); + + if (mixins) { + for (var i = 0; i < mixins.length; i++) { + api = mixins[i](api); + } + } + + var r = factory(function initialize(O) { + api.initializeInstanceElements(O, decorated.elements); + }, superClass); + var decorated = api.decorateClass(_coalesceClassElements(r.d.map(_createElementDescriptor)), decorators); + api.initializeClassElements(r.F, decorated.elements); + return api.runClassFinishers(r.F, decorated.finishers); +} + +function _getDecoratorsApi() { + _getDecoratorsApi = function () { + return api; + }; + + var api = { + elementsDefinitionOrder: [["method"], ["field"]], + initializeInstanceElements: function (O, elements) { + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + if (element.kind === kind && element.placement === "own") { + this.defineClassElement(O, element); + } + }, this); + }, this); + }, + initializeClassElements: function (F, elements) { + var proto = F.prototype; + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + var placement = element.placement; + + if (element.kind === kind && (placement === "static" || placement === "prototype")) { + var receiver = placement === "static" ? F : proto; + this.defineClassElement(receiver, element); + } + }, this); + }, this); + }, + defineClassElement: function (receiver, element) { + var descriptor = element.descriptor; + + if (element.kind === "field") { + var initializer = element.initializer; + descriptor = { + enumerable: descriptor.enumerable, + writable: descriptor.writable, + configurable: descriptor.configurable, + value: initializer === void 0 ? void 0 : initializer.call(receiver) + }; + } + + Object.defineProperty(receiver, element.key, descriptor); + }, + decorateClass: function (elements, decorators) { + var newElements = []; + var finishers = []; + var placements = { + static: [], + prototype: [], + own: [] + }; + elements.forEach(function (element) { + this.addElementPlacement(element, placements); + }, this); + elements.forEach(function (element) { + if (!_hasDecorators(element)) return newElements.push(element); + var elementFinishersExtras = this.decorateElement(element, placements); + newElements.push(elementFinishersExtras.element); + newElements.push.apply(newElements, elementFinishersExtras.extras); + finishers.push.apply(finishers, elementFinishersExtras.finishers); + }, this); + + if (!decorators) { + return { + elements: newElements, + finishers: finishers + }; + } + + var result = this.decorateConstructor(newElements, decorators); + finishers.push.apply(finishers, result.finishers); + result.finishers = finishers; + return result; + }, + addElementPlacement: function (element, placements, silent) { + var keys = placements[element.placement]; + + if (!silent && keys.indexOf(element.key) !== -1) { + throw new TypeError("Duplicated element (" + element.key + ")"); + } + + keys.push(element.key); + }, + decorateElement: function (element, placements) { + var extras = []; + var finishers = []; + + for (var decorators = element.decorators, i = decorators.length - 1; i >= 0; i--) { + var keys = placements[element.placement]; + keys.splice(keys.indexOf(element.key), 1); + var elementObject = this.fromElementDescriptor(element); + var elementFinisherExtras = this.toElementFinisherExtras((0, decorators[i])(elementObject) || elementObject); + element = elementFinisherExtras.element; + this.addElementPlacement(element, placements); + + if (elementFinisherExtras.finisher) { + finishers.push(elementFinisherExtras.finisher); + } + + var newExtras = elementFinisherExtras.extras; + + if (newExtras) { + for (var j = 0; j < newExtras.length; j++) { + this.addElementPlacement(newExtras[j], placements); + } + + extras.push.apply(extras, newExtras); + } + } + + return { + element: element, + finishers: finishers, + extras: extras + }; + }, + decorateConstructor: function (elements, decorators) { + var finishers = []; + + for (var i = decorators.length - 1; i >= 0; i--) { + var obj = this.fromClassDescriptor(elements); + var elementsAndFinisher = this.toClassDescriptor((0, decorators[i])(obj) || obj); + + if (elementsAndFinisher.finisher !== undefined) { + finishers.push(elementsAndFinisher.finisher); + } + + if (elementsAndFinisher.elements !== undefined) { + elements = elementsAndFinisher.elements; + + for (var j = 0; j < elements.length - 1; j++) { + for (var k = j + 1; k < elements.length; k++) { + if (elements[j].key === elements[k].key && elements[j].placement === elements[k].placement) { + throw new TypeError("Duplicated element (" + elements[j].key + ")"); + } + } + } + } + } + + return { + elements: elements, + finishers: finishers + }; + }, + fromElementDescriptor: function (element) { + var obj = { + kind: element.kind, + key: element.key, + placement: element.placement, + descriptor: element.descriptor + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + if (element.kind === "field") obj.initializer = element.initializer; + return obj; + }, + toElementDescriptors: function (elementObjects) { + if (elementObjects === undefined) return; + return _toArray(elementObjects).map(function (elementObject) { + var element = this.toElementDescriptor(elementObject); + this.disallowProperty(elementObject, "finisher", "An element descriptor"); + this.disallowProperty(elementObject, "extras", "An element descriptor"); + return element; + }, this); + }, + toElementDescriptor: function (elementObject) { + var kind = String(elementObject.kind); + + if (kind !== "method" && kind !== "field") { + throw new TypeError('An element descriptor\'s .kind property must be either "method" or' + ' "field", but a decorator created an element descriptor with' + ' .kind "' + kind + '"'); + } + + var key = _toPropertyKey(elementObject.key); + + var placement = String(elementObject.placement); + + if (placement !== "static" && placement !== "prototype" && placement !== "own") { + throw new TypeError('An element descriptor\'s .placement property must be one of "static",' + ' "prototype" or "own", but a decorator created an element descriptor' + ' with .placement "' + placement + '"'); + } + + var descriptor = elementObject.descriptor; + this.disallowProperty(elementObject, "elements", "An element descriptor"); + var element = { + kind: kind, + key: key, + placement: placement, + descriptor: Object.assign({}, descriptor) + }; + + if (kind !== "field") { + this.disallowProperty(elementObject, "initializer", "A method descriptor"); + } else { + this.disallowProperty(descriptor, "get", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "set", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "value", "The property descriptor of a field descriptor"); + element.initializer = elementObject.initializer; + } + + return element; + }, + toElementFinisherExtras: function (elementObject) { + var element = this.toElementDescriptor(elementObject); + + var finisher = _optionalCallableProperty(elementObject, "finisher"); + + var extras = this.toElementDescriptors(elementObject.extras); + return { + element: element, + finisher: finisher, + extras: extras + }; + }, + fromClassDescriptor: function (elements) { + var obj = { + kind: "class", + elements: elements.map(this.fromElementDescriptor, this) + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + return obj; + }, + toClassDescriptor: function (obj) { + var kind = String(obj.kind); + + if (kind !== "class") { + throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator' + ' created a class descriptor with .kind "' + kind + '"'); + } + + this.disallowProperty(obj, "key", "A class descriptor"); + this.disallowProperty(obj, "placement", "A class descriptor"); + this.disallowProperty(obj, "descriptor", "A class descriptor"); + this.disallowProperty(obj, "initializer", "A class descriptor"); + this.disallowProperty(obj, "extras", "A class descriptor"); + + var finisher = _optionalCallableProperty(obj, "finisher"); + + var elements = this.toElementDescriptors(obj.elements); + return { + elements: elements, + finisher: finisher + }; + }, + runClassFinishers: function (constructor, finishers) { + for (var i = 0; i < finishers.length; i++) { + var newConstructor = (0, finishers[i])(constructor); + + if (newConstructor !== undefined) { + if (typeof newConstructor !== "function") { + throw new TypeError("Finishers must return a constructor."); + } + + constructor = newConstructor; + } + } + + return constructor; + }, + disallowProperty: function (obj, name, objectType) { + if (obj[name] !== undefined) { + throw new TypeError(objectType + " can't have a ." + name + " property."); + } + } + }; + return api; +} + +function _createElementDescriptor(def) { + var key = _toPropertyKey(def.key); + + var descriptor; + + if (def.kind === "method") { + descriptor = { + value: def.value, + writable: true, + configurable: true, + enumerable: false + }; + } else if (def.kind === "get") { + descriptor = { + get: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "set") { + descriptor = { + set: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "field") { + descriptor = { + configurable: true, + writable: true, + enumerable: true + }; + } + + var element = { + kind: def.kind === "field" ? "field" : "method", + key: key, + placement: def.static ? "static" : def.kind === "field" ? "own" : "prototype", + descriptor: descriptor + }; + if (def.decorators) element.decorators = def.decorators; + if (def.kind === "field") element.initializer = def.value; + return element; +} + +function _coalesceGetterSetter(element, other) { + if (element.descriptor.get !== undefined) { + other.descriptor.get = element.descriptor.get; + } else { + other.descriptor.set = element.descriptor.set; + } +} + +function _coalesceClassElements(elements) { + var newElements = []; + + var isSameElement = function (other) { + return other.kind === "method" && other.key === element.key && other.placement === element.placement; + }; + + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + var other; + + if (element.kind === "method" && (other = newElements.find(isSameElement))) { + if (_isDataDescriptor(element.descriptor) || _isDataDescriptor(other.descriptor)) { + if (_hasDecorators(element) || _hasDecorators(other)) { + throw new ReferenceError("Duplicated methods (" + element.key + ") can't be decorated."); + } + + other.descriptor = element.descriptor; + } else { + if (_hasDecorators(element)) { + if (_hasDecorators(other)) { + throw new ReferenceError("Decorators can't be placed on different accessors with for " + "the same property (" + element.key + ")."); + } + + other.decorators = element.decorators; + } + + _coalesceGetterSetter(element, other); + } + } else { + newElements.push(element); + } + } + + return newElements; +} + +function _hasDecorators(element) { + return element.decorators && element.decorators.length; +} + +function _isDataDescriptor(desc) { + return desc !== undefined && !(desc.value === undefined && desc.writable === undefined); +} + +function _optionalCallableProperty(obj, name) { + var value = obj[name]; + + if (value !== undefined && typeof value !== "function") { + throw new TypeError("Expected '" + name + "' to be a function"); + } + + return value; +} + +function _classPrivateMethodGet(receiver, privateSet, fn) { + if (!privateSet.has(receiver)) { + throw new TypeError("attempted to get private field on non-instance"); + } + + return fn; +} + +function _classPrivateMethodSet() { + throw new TypeError("attempted to reassign private method"); +} + +function _wrapRegExp(re, groups) { + _wrapRegExp = function (re, groups) { + return new BabelRegExp(re, undefined, groups); + }; + + var _RegExp = _wrapNativeSuper(RegExp); + + var _super = RegExp.prototype; + + var _groups = new WeakMap(); + + function BabelRegExp(re, flags, groups) { + var _this = _RegExp.call(this, re, flags); + + _groups.set(_this, groups || _groups.get(re)); + + return _this; + } + + _inherits(BabelRegExp, _RegExp); + + BabelRegExp.prototype.exec = function (str) { + var result = _super.exec.call(this, str); + + if (result) result.groups = buildGroups(result, this); + return result; + }; + + BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { + if (typeof substitution === "string") { + var groups = _groups.get(this); + + return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { + return "$" + groups[name]; + })); + } else if (typeof substitution === "function") { + var _this = this; + + return _super[Symbol.replace].call(this, str, function () { + var args = []; + args.push.apply(args, arguments); + + if (typeof args[args.length - 1] !== "object") { + args.push(buildGroups(args, _this)); + } + + return substitution.apply(this, args); + }); + } else { + return _super[Symbol.replace].call(this, str, substitution); + } + }; + + function buildGroups(result, re) { + var g = _groups.get(re); + + return Object.keys(g).reduce(function (groups, name) { + groups[name] = result[g[name]]; + return groups; + }, Object.create(null)); + } + + return _wrapRegExp.apply(this, arguments); +} + +/** + * @file ext-helloworld.js + * + * @license MIT + * + * @copyright 2010 Alexis Deveria + * + */ + +/** +* This is a very basic SVG-Edit extension. It adds a "Hello World" button in +* the left ("mode") panel. Clicking on the button, and then the canvas +* will show the user the point on the canvas that was clicked on. +*/ +var extHelloworld = { + name: 'helloworld', + init: function init(_ref) { + var _this = this; + + return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { + var $, importLocale, strings, svgEditor, svgCanvas; + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + $ = _ref.$, importLocale = _ref.importLocale; + _context.next = 3; + return importLocale(); + + case 3: + strings = _context.sent; + svgEditor = _this; + svgCanvas = svgEditor.canvas; + return _context.abrupt("return", { + name: strings.name, + // For more notes on how to make an icon file, see the source of + // the helloworld-icon.xml + svgicons: svgEditor.curConfig.extIconsPath + 'helloworld-icon.xml', + // Multiple buttons can be added in this array + buttons: [{ + // Must match the icon ID in helloworld-icon.xml + id: 'hello_world', + // Fallback, e.g., for `file:///` access + icon: svgEditor.curConfig.extIconsPath + 'helloworld.png', + // This indicates that the button will be added to the "mode" + // button panel on the left side + type: 'mode', + // Tooltip text + title: strings.buttons[0].title, + // Events + events: { + click: function click() { + // The action taken when the button is clicked on. + // For "mode" buttons, any other button will + // automatically be de-pressed. + svgCanvas.setMode('hello_world'); + } + } + }], + // This is triggered when the main mouse button is pressed down + // on the editor canvas (not the tool panels) + mouseDown: function mouseDown() { + // Check the mode on mousedown + if (svgCanvas.getMode() === 'hello_world') { + // The returned object must include "started" with + // a value of true in order for mouseUp to be triggered + return { + started: true + }; + } + + return undefined; + }, + // This is triggered from anywhere, but "started" must have been set + // to true (see above). Note that "opts" is an object with event info + mouseUp: function mouseUp(opts) { + // Check the mode on mouseup + if (svgCanvas.getMode() === 'hello_world') { + var zoom = svgCanvas.getZoom(); // Get the actual coordinate by dividing by the zoom value + + var x = opts.mouse_x / zoom; + var y = opts.mouse_y / zoom; // We do our own formatting + + var text = strings.text; + [['x', x], ['y', y]].forEach(function (_ref2) { + var _ref3 = _slicedToArray(_ref2, 2), + prop = _ref3[0], + val = _ref3[1]; + + text = text.replace('{' + prop + '}', val); + }); // Show the text using the custom alert function + + $.alert(text); + } + } + }); + + case 7: + case "end": + return _context.stop(); + } + } + }, _callee); + }))(); + } +}; + +export default extHelloworld; +//# sourceMappingURL=ext-helloworld.js.map diff --git a/dist/editor/extensions/ext-helloworld.js.map b/dist/editor/extensions/ext-helloworld.js.map new file mode 100644 index 00000000..4b7881b5 --- /dev/null +++ b/dist/editor/extensions/ext-helloworld.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ext-helloworld.js","sources":["../../../src/editor/extensions/ext-helloworld.js"],"sourcesContent":["/**\n * @file ext-helloworld.js\n *\n * @license MIT\n *\n * @copyright 2010 Alexis Deveria\n *\n */\n\n/**\n* This is a very basic SVG-Edit extension. It adds a \"Hello World\" button in\n* the left (\"mode\") panel. Clicking on the button, and then the canvas\n* will show the user the point on the canvas that was clicked on.\n*/\nexport default {\n name: 'helloworld',\n async init ({$, importLocale}) {\n // See `/editor/extensions/ext-locale/helloworld/`\n const strings = await importLocale();\n const svgEditor = this;\n const svgCanvas = svgEditor.canvas;\n return {\n name: strings.name,\n // For more notes on how to make an icon file, see the source of\n // the helloworld-icon.xml\n svgicons: svgEditor.curConfig.extIconsPath + 'helloworld-icon.xml',\n\n // Multiple buttons can be added in this array\n buttons: [{\n // Must match the icon ID in helloworld-icon.xml\n id: 'hello_world',\n\n // Fallback, e.g., for `file:///` access\n icon: svgEditor.curConfig.extIconsPath + 'helloworld.png',\n\n // This indicates that the button will be added to the \"mode\"\n // button panel on the left side\n type: 'mode',\n\n // Tooltip text\n title: strings.buttons[0].title,\n\n // Events\n events: {\n click () {\n // The action taken when the button is clicked on.\n // For \"mode\" buttons, any other button will\n // automatically be de-pressed.\n svgCanvas.setMode('hello_world');\n }\n }\n }],\n // This is triggered when the main mouse button is pressed down\n // on the editor canvas (not the tool panels)\n mouseDown () {\n // Check the mode on mousedown\n if (svgCanvas.getMode() === 'hello_world') {\n // The returned object must include \"started\" with\n // a value of true in order for mouseUp to be triggered\n return {started: true};\n }\n return undefined;\n },\n\n // This is triggered from anywhere, but \"started\" must have been set\n // to true (see above). Note that \"opts\" is an object with event info\n mouseUp (opts) {\n // Check the mode on mouseup\n if (svgCanvas.getMode() === 'hello_world') {\n const zoom = svgCanvas.getZoom();\n\n // Get the actual coordinate by dividing by the zoom value\n const x = opts.mouse_x / zoom;\n const y = opts.mouse_y / zoom;\n\n // We do our own formatting\n let {text} = strings;\n [\n ['x', x],\n ['y', y]\n ].forEach(([prop, val]) => {\n text = text.replace('{' + prop + '}', val);\n });\n\n // Show the text using the custom alert function\n $.alert(text);\n }\n }\n };\n }\n};\n"],"names":["name","init","$","importLocale","strings","svgEditor","svgCanvas","canvas","svgicons","curConfig","extIconsPath","buttons","id","icon","type","title","events","click","setMode","mouseDown","getMode","started","undefined","mouseUp","opts","zoom","getZoom","x","mouse_x","y","mouse_y","text","forEach","prop","val","replace","alert"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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zB;AACA,wBAAMI,CAAC,GAAGL,IAAI,CAACM,OAAL,GAAeL,IAAzB,CALyC;;AAAA,wBAQpCM,IARoC,GAQ5B3B,OAR4B,CAQpC2B,IARoC;AASzC,qBACE,CAAC,GAAD,EAAMJ,CAAN,CADF,EAEE,CAAC,GAAD,EAAME,CAAN,CAFF,EAGEG,OAHF,CAGU,iBAAiB;AAAA;AAAA,0BAAfC,IAAe;AAAA,0BAATC,GAAS;;AACzBH,sBAAAA,IAAI,GAAGA,IAAI,CAACI,OAAL,CAAa,MAAMF,IAAN,GAAa,GAA1B,EAA+BC,GAA/B,CAAP;AACD,qBALD,EATyC;;AAiBzChC,oBAAAA,CAAC,CAACkC,KAAF,CAAQL,IAAR;AACD;AACF;AAlEI,eALsB;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyE9B;AA3EY,CAAf;;;;"} \ No newline at end of file diff --git a/dist/editor/extensions/ext-imagelib.js b/dist/editor/extensions/ext-imagelib.js new file mode 100644 index 00000000..2d654e3b --- /dev/null +++ b/dist/editor/extensions/ext-imagelib.js @@ -0,0 +1,2170 @@ +function _typeof(obj) { + "@babel/helpers - typeof"; + + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function (obj) { + return typeof obj; + }; + } else { + _typeof = function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); +} + +var REACT_ELEMENT_TYPE; + +function _jsx(type, props, key, children) { + if (!REACT_ELEMENT_TYPE) { + REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol["for"] && Symbol["for"]("react.element") || 0xeac7; + } + + var defaultProps = type && type.defaultProps; + var childrenLength = arguments.length - 3; + + if (!props && childrenLength !== 0) { + props = { + children: void 0 + }; + } + + if (childrenLength === 1) { + props.children = children; + } else if (childrenLength > 1) { + var childArray = new Array(childrenLength); + + for (var i = 0; i < childrenLength; i++) { + childArray[i] = arguments[i + 3]; + } + + props.children = childArray; + } + + if (props && defaultProps) { + for (var propName in defaultProps) { + if (props[propName] === void 0) { + props[propName] = defaultProps[propName]; + } + } + } else if (!props) { + props = defaultProps || {}; + } + + return { + $$typeof: REACT_ELEMENT_TYPE, + type: type, + key: key === undefined ? null : '' + key, + ref: null, + props: props, + _owner: null + }; +} + +function _asyncIterator(iterable) { + var method; + + if (typeof Symbol !== "undefined") { + if (Symbol.asyncIterator) { + method = iterable[Symbol.asyncIterator]; + if (method != null) return method.call(iterable); + } + + if (Symbol.iterator) { + method = iterable[Symbol.iterator]; + if (method != null) return method.call(iterable); + } + } + + throw new TypeError("Object is not async iterable"); +} + +function _AwaitValue(value) { + this.wrapped = value; +} + +function _AsyncGenerator(gen) { + var front, back; + + function send(key, arg) { + return new Promise(function (resolve, reject) { + var request = { + key: key, + arg: arg, + resolve: resolve, + reject: reject, + next: null + }; + + if (back) { + back = back.next = request; + } else { + front = back = request; + resume(key, arg); + } + }); + } + + function resume(key, arg) { + try { + var result = gen[key](arg); + var value = result.value; + var wrappedAwait = value instanceof _AwaitValue; + Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { + if (wrappedAwait) { + resume(key === "return" ? "return" : "next", arg); + return; + } + + settle(result.done ? "return" : "normal", arg); + }, function (err) { + resume("throw", err); + }); + } catch (err) { + settle("throw", err); + } + } + + function settle(type, value) { + switch (type) { + case "return": + front.resolve({ + value: value, + done: true + }); + break; + + case "throw": + front.reject(value); + break; + + default: + front.resolve({ + value: value, + done: false + }); + break; + } + + front = front.next; + + if (front) { + resume(front.key, front.arg); + } else { + back = null; + } + } + + this._invoke = send; + + if (typeof gen.return !== "function") { + this.return = undefined; + } +} + +if (typeof Symbol === "function" && Symbol.asyncIterator) { + _AsyncGenerator.prototype[Symbol.asyncIterator] = function () { + return this; + }; +} + +_AsyncGenerator.prototype.next = function (arg) { + return this._invoke("next", arg); +}; + +_AsyncGenerator.prototype.throw = function (arg) { + return this._invoke("throw", arg); +}; + +_AsyncGenerator.prototype.return = function (arg) { + return this._invoke("return", arg); +}; + +function _wrapAsyncGenerator(fn) { + return function () { + return new _AsyncGenerator(fn.apply(this, arguments)); + }; +} + +function _awaitAsyncGenerator(value) { + return new _AwaitValue(value); +} + +function _asyncGeneratorDelegate(inner, awaitWrap) { + var iter = {}, + waiting = false; + + function pump(key, value) { + waiting = true; + value = new Promise(function (resolve) { + resolve(inner[key](value)); + }); + return { + done: false, + value: awaitWrap(value) + }; + } + + ; + + if (typeof Symbol === "function" && Symbol.iterator) { + iter[Symbol.iterator] = function () { + return this; + }; + } + + iter.next = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("next", value); + }; + + if (typeof inner.throw === "function") { + iter.throw = function (value) { + if (waiting) { + waiting = false; + throw value; + } + + return pump("throw", value); + }; + } + + if (typeof inner.return === "function") { + iter.return = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("return", value); + }; + } + + return iter; +} + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { + try { + var info = gen[key](arg); + var value = info.value; + } catch (error) { + reject(error); + return; + } + + if (info.done) { + resolve(value); + } else { + Promise.resolve(value).then(_next, _throw); + } +} + +function _asyncToGenerator(fn) { + return function () { + var self = this, + args = arguments; + return new Promise(function (resolve, reject) { + var gen = fn.apply(self, args); + + function _next(value) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); + } + + function _throw(err) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); + } + + _next(undefined); + }); + }; +} + +function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +} + +function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } +} + +function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; +} + +function _defineEnumerableProperties(obj, descs) { + for (var key in descs) { + var desc = descs[key]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, key, desc); + } + + if (Object.getOwnPropertySymbols) { + var objectSymbols = Object.getOwnPropertySymbols(descs); + + for (var i = 0; i < objectSymbols.length; i++) { + var sym = objectSymbols[i]; + var desc = descs[sym]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, sym, desc); + } + } + + return obj; +} + +function _defaults(obj, defaults) { + var keys = Object.getOwnPropertyNames(defaults); + + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var value = Object.getOwnPropertyDescriptor(defaults, key); + + if (value && value.configurable && obj[key] === undefined) { + Object.defineProperty(obj, key, value); + } + } + + return obj; +} + +function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; +} + +function _extends() { + _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + + return _extends.apply(this, arguments); +} + +function _objectSpread(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? Object(arguments[i]) : {}; + var ownKeys = Object.keys(source); + + if (typeof Object.getOwnPropertySymbols === 'function') { + ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { + return Object.getOwnPropertyDescriptor(source, sym).enumerable; + })); + } + + ownKeys.forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } + + return target; +} + +function ownKeys(object, enumerableOnly) { + var keys = Object.keys(object); + + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(object); + if (enumerableOnly) symbols = symbols.filter(function (sym) { + return Object.getOwnPropertyDescriptor(object, sym).enumerable; + }); + keys.push.apply(keys, symbols); + } + + return keys; +} + +function _objectSpread2(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? arguments[i] : {}; + + if (i % 2) { + ownKeys(Object(source), true).forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } else if (Object.getOwnPropertyDescriptors) { + Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); + } else { + ownKeys(Object(source)).forEach(function (key) { + Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); + }); + } + } + + return target; +} + +function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function"); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + writable: true, + configurable: true + } + }); + if (superClass) _setPrototypeOf(subClass, superClass); +} + +function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + subClass.__proto__ = superClass; +} + +function _getPrototypeOf(o) { + _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { + return o.__proto__ || Object.getPrototypeOf(o); + }; + return _getPrototypeOf(o); +} + +function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + + return _setPrototypeOf(o, p); +} + +function _isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + + try { + Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); + return true; + } catch (e) { + return false; + } +} + +function _construct(Parent, args, Class) { + if (_isNativeReflectConstruct()) { + _construct = Reflect.construct; + } else { + _construct = function _construct(Parent, args, Class) { + var a = [null]; + a.push.apply(a, args); + var Constructor = Function.bind.apply(Parent, a); + var instance = new Constructor(); + if (Class) _setPrototypeOf(instance, Class.prototype); + return instance; + }; + } + + return _construct.apply(null, arguments); +} + +function _isNativeFunction(fn) { + return Function.toString.call(fn).indexOf("[native code]") !== -1; +} + +function _wrapNativeSuper(Class) { + var _cache = typeof Map === "function" ? new Map() : undefined; + + _wrapNativeSuper = function _wrapNativeSuper(Class) { + if (Class === null || !_isNativeFunction(Class)) return Class; + + if (typeof Class !== "function") { + throw new TypeError("Super expression must either be null or a function"); + } + + if (typeof _cache !== "undefined") { + if (_cache.has(Class)) return _cache.get(Class); + + _cache.set(Class, Wrapper); + } + + function Wrapper() { + return _construct(Class, arguments, _getPrototypeOf(this).constructor); + } + + Wrapper.prototype = Object.create(Class.prototype, { + constructor: { + value: Wrapper, + enumerable: false, + writable: true, + configurable: true + } + }); + return _setPrototypeOf(Wrapper, Class); + }; + + return _wrapNativeSuper(Class); +} + +function _instanceof(left, right) { + if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { + return !!right[Symbol.hasInstance](left); + } else { + return left instanceof right; + } +} + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; +} + +function _getRequireWildcardCache() { + if (typeof WeakMap !== "function") return null; + var cache = new WeakMap(); + + _getRequireWildcardCache = function () { + return cache; + }; + + return cache; +} + +function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } + + if (obj === null || typeof obj !== "object" && typeof obj !== "function") { + return { + default: obj + }; + } + + var cache = _getRequireWildcardCache(); + + if (cache && cache.has(obj)) { + return cache.get(obj); + } + + var newObj = {}; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + + if (desc && (desc.get || desc.set)) { + Object.defineProperty(newObj, key, desc); + } else { + newObj[key] = obj[key]; + } + } + } + + newObj.default = obj; + + if (cache) { + cache.set(obj, newObj); + } + + return newObj; +} + +function _newArrowCheck(innerThis, boundThis) { + if (innerThis !== boundThis) { + throw new TypeError("Cannot instantiate an arrow function"); + } +} + +function _objectDestructuringEmpty(obj) { + if (obj == null) throw new TypeError("Cannot destructure undefined"); +} + +function _objectWithoutPropertiesLoose(source, excluded) { + if (source == null) return {}; + var target = {}; + var sourceKeys = Object.keys(source); + var key, i; + + for (i = 0; i < sourceKeys.length; i++) { + key = sourceKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + target[key] = source[key]; + } + + return target; +} + +function _objectWithoutProperties(source, excluded) { + if (source == null) return {}; + + var target = _objectWithoutPropertiesLoose(source, excluded); + + var key, i; + + if (Object.getOwnPropertySymbols) { + var sourceSymbolKeys = Object.getOwnPropertySymbols(source); + + for (i = 0; i < sourceSymbolKeys.length; i++) { + key = sourceSymbolKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; + target[key] = source[key]; + } + } + + return target; +} + +function _assertThisInitialized(self) { + if (self === void 0) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return self; +} + +function _possibleConstructorReturn(self, call) { + if (call && (typeof call === "object" || typeof call === "function")) { + return call; + } + + return _assertThisInitialized(self); +} + +function _createSuper(Derived) { + var hasNativeReflectConstruct = _isNativeReflectConstruct(); + + return function _createSuperInternal() { + var Super = _getPrototypeOf(Derived), + result; + + if (hasNativeReflectConstruct) { + var NewTarget = _getPrototypeOf(this).constructor; + + result = Reflect.construct(Super, arguments, NewTarget); + } else { + result = Super.apply(this, arguments); + } + + return _possibleConstructorReturn(this, result); + }; +} + +function _superPropBase(object, property) { + while (!Object.prototype.hasOwnProperty.call(object, property)) { + object = _getPrototypeOf(object); + if (object === null) break; + } + + return object; +} + +function _get(target, property, receiver) { + if (typeof Reflect !== "undefined" && Reflect.get) { + _get = Reflect.get; + } else { + _get = function _get(target, property, receiver) { + var base = _superPropBase(target, property); + + if (!base) return; + var desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.get) { + return desc.get.call(receiver); + } + + return desc.value; + }; + } + + return _get(target, property, receiver || target); +} + +function set(target, property, value, receiver) { + if (typeof Reflect !== "undefined" && Reflect.set) { + set = Reflect.set; + } else { + set = function set(target, property, value, receiver) { + var base = _superPropBase(target, property); + + var desc; + + if (base) { + desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.set) { + desc.set.call(receiver, value); + return true; + } else if (!desc.writable) { + return false; + } + } + + desc = Object.getOwnPropertyDescriptor(receiver, property); + + if (desc) { + if (!desc.writable) { + return false; + } + + desc.value = value; + Object.defineProperty(receiver, property, desc); + } else { + _defineProperty(receiver, property, value); + } + + return true; + }; + } + + return set(target, property, value, receiver); +} + +function _set(target, property, value, receiver, isStrict) { + var s = set(target, property, value, receiver || target); + + if (!s && isStrict) { + throw new Error('failed to set property'); + } + + return value; +} + +function _taggedTemplateLiteral(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + return Object.freeze(Object.defineProperties(strings, { + raw: { + value: Object.freeze(raw) + } + })); +} + +function _taggedTemplateLiteralLoose(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + strings.raw = raw; + return strings; +} + +function _readOnlyError(name) { + throw new Error("\"" + name + "\" is read-only"); +} + +function _classNameTDZError(name) { + throw new Error("Class \"" + name + "\" cannot be referenced in computed property keys."); +} + +function _temporalUndefined() {} + +function _tdz(name) { + throw new ReferenceError(name + " is not defined - temporal dead zone"); +} + +function _temporalRef(val, name) { + return val === _temporalUndefined ? _tdz(name) : val; +} + +function _slicedToArray(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); +} + +function _slicedToArrayLoose(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimitLoose(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); +} + +function _toArray(arr) { + return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); +} + +function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); +} + +function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) return _arrayLikeToArray(arr); +} + +function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; +} + +function _maybeArrayLike(next, arr, i) { + if (arr && !Array.isArray(arr) && typeof arr.length === "number") { + var len = arr.length; + return _arrayLikeToArray(arr, i !== void 0 && i < len ? i : len); + } + + return next(arr, i); +} + +function _iterableToArray(iter) { + if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); +} + +function _iterableToArrayLimit(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"] != null) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; +} + +function _iterableToArrayLimitLoose(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + + for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { + _arr.push(_step.value); + + if (i && _arr.length === i) break; + } + + return _arr; +} + +function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if (typeof o === "string") return _arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + if (n === "Object" && o.constructor) n = o.constructor.name; + if (n === "Map" || n === "Set") return Array.from(o); + if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); +} + +function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) len = arr.length; + + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + + return arr2; +} + +function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); +} + +function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); +} + +function _createForOfIteratorHelper(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + + var F = function () {}; + + return { + s: F, + n: function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }, + e: function (e) { + throw e; + }, + f: F + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + var normalCompletion = true, + didErr = false, + err; + return { + s: function () { + it = o[Symbol.iterator](); + }, + n: function () { + var step = it.next(); + normalCompletion = step.done; + return step; + }, + e: function (e) { + didErr = true; + err = e; + }, + f: function () { + try { + if (!normalCompletion && it.return != null) it.return(); + } finally { + if (didErr) throw err; + } + } + }; +} + +function _createForOfIteratorHelperLoose(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + return function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + it = o[Symbol.iterator](); + return it.next.bind(it); +} + +function _skipFirstGeneratorNext(fn) { + return function () { + var it = fn.apply(this, arguments); + it.next(); + return it; + }; +} + +function _toPrimitive(input, hint) { + if (typeof input !== "object" || input === null) return input; + var prim = input[Symbol.toPrimitive]; + + if (prim !== undefined) { + var res = prim.call(input, hint || "default"); + if (typeof res !== "object") return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + + return (hint === "string" ? String : Number)(input); +} + +function _toPropertyKey(arg) { + var key = _toPrimitive(arg, "string"); + + return typeof key === "symbol" ? key : String(key); +} + +function _initializerWarningHelper(descriptor, context) { + throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.'); +} + +function _initializerDefineProperty(target, property, descriptor, context) { + if (!descriptor) return; + Object.defineProperty(target, property, { + enumerable: descriptor.enumerable, + configurable: descriptor.configurable, + writable: descriptor.writable, + value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 + }); +} + +function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { + var desc = {}; + Object.keys(descriptor).forEach(function (key) { + desc[key] = descriptor[key]; + }); + desc.enumerable = !!desc.enumerable; + desc.configurable = !!desc.configurable; + + if ('value' in desc || desc.initializer) { + desc.writable = true; + } + + desc = decorators.slice().reverse().reduce(function (desc, decorator) { + return decorator(target, property, desc) || desc; + }, desc); + + if (context && desc.initializer !== void 0) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = undefined; + } + + if (desc.initializer === void 0) { + Object.defineProperty(target, property, desc); + desc = null; + } + + return desc; +} + +var id = 0; + +function _classPrivateFieldLooseKey(name) { + return "__private_" + id++ + "_" + name; +} + +function _classPrivateFieldLooseBase(receiver, privateKey) { + if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { + throw new TypeError("attempted to use private field on non-instance"); + } + + return receiver; +} + +function _classPrivateFieldGet(receiver, privateMap) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to get private field on non-instance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; +} + +function _classPrivateFieldSet(receiver, privateMap, value) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to set private field on non-instance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; +} + +function _classPrivateFieldDestructureSet(receiver, privateMap) { + if (!privateMap.has(receiver)) { + throw new TypeError("attempted to set private field on non-instance"); + } + + var descriptor = privateMap.get(receiver); + + if (descriptor.set) { + if (!("__destrObj" in descriptor)) { + descriptor.__destrObj = { + set value(v) { + descriptor.set.call(receiver, v); + } + + }; + } + + return descriptor.__destrObj; + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + return descriptor; + } +} + +function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; +} + +function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; +} + +function _classStaticPrivateMethodGet(receiver, classConstructor, method) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + return method; +} + +function _classStaticPrivateMethodSet() { + throw new TypeError("attempted to set read only static private field"); +} + +function _decorate(decorators, factory, superClass, mixins) { + var api = _getDecoratorsApi(); + + if (mixins) { + for (var i = 0; i < mixins.length; i++) { + api = mixins[i](api); + } + } + + var r = factory(function initialize(O) { + api.initializeInstanceElements(O, decorated.elements); + }, superClass); + var decorated = api.decorateClass(_coalesceClassElements(r.d.map(_createElementDescriptor)), decorators); + api.initializeClassElements(r.F, decorated.elements); + return api.runClassFinishers(r.F, decorated.finishers); +} + +function _getDecoratorsApi() { + _getDecoratorsApi = function () { + return api; + }; + + var api = { + elementsDefinitionOrder: [["method"], ["field"]], + initializeInstanceElements: function (O, elements) { + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + if (element.kind === kind && element.placement === "own") { + this.defineClassElement(O, element); + } + }, this); + }, this); + }, + initializeClassElements: function (F, elements) { + var proto = F.prototype; + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + var placement = element.placement; + + if (element.kind === kind && (placement === "static" || placement === "prototype")) { + var receiver = placement === "static" ? F : proto; + this.defineClassElement(receiver, element); + } + }, this); + }, this); + }, + defineClassElement: function (receiver, element) { + var descriptor = element.descriptor; + + if (element.kind === "field") { + var initializer = element.initializer; + descriptor = { + enumerable: descriptor.enumerable, + writable: descriptor.writable, + configurable: descriptor.configurable, + value: initializer === void 0 ? void 0 : initializer.call(receiver) + }; + } + + Object.defineProperty(receiver, element.key, descriptor); + }, + decorateClass: function (elements, decorators) { + var newElements = []; + var finishers = []; + var placements = { + static: [], + prototype: [], + own: [] + }; + elements.forEach(function (element) { + this.addElementPlacement(element, placements); + }, this); + elements.forEach(function (element) { + if (!_hasDecorators(element)) return newElements.push(element); + var elementFinishersExtras = this.decorateElement(element, placements); + newElements.push(elementFinishersExtras.element); + newElements.push.apply(newElements, elementFinishersExtras.extras); + finishers.push.apply(finishers, elementFinishersExtras.finishers); + }, this); + + if (!decorators) { + return { + elements: newElements, + finishers: finishers + }; + } + + var result = this.decorateConstructor(newElements, decorators); + finishers.push.apply(finishers, result.finishers); + result.finishers = finishers; + return result; + }, + addElementPlacement: function (element, placements, silent) { + var keys = placements[element.placement]; + + if (!silent && keys.indexOf(element.key) !== -1) { + throw new TypeError("Duplicated element (" + element.key + ")"); + } + + keys.push(element.key); + }, + decorateElement: function (element, placements) { + var extras = []; + var finishers = []; + + for (var decorators = element.decorators, i = decorators.length - 1; i >= 0; i--) { + var keys = placements[element.placement]; + keys.splice(keys.indexOf(element.key), 1); + var elementObject = this.fromElementDescriptor(element); + var elementFinisherExtras = this.toElementFinisherExtras((0, decorators[i])(elementObject) || elementObject); + element = elementFinisherExtras.element; + this.addElementPlacement(element, placements); + + if (elementFinisherExtras.finisher) { + finishers.push(elementFinisherExtras.finisher); + } + + var newExtras = elementFinisherExtras.extras; + + if (newExtras) { + for (var j = 0; j < newExtras.length; j++) { + this.addElementPlacement(newExtras[j], placements); + } + + extras.push.apply(extras, newExtras); + } + } + + return { + element: element, + finishers: finishers, + extras: extras + }; + }, + decorateConstructor: function (elements, decorators) { + var finishers = []; + + for (var i = decorators.length - 1; i >= 0; i--) { + var obj = this.fromClassDescriptor(elements); + var elementsAndFinisher = this.toClassDescriptor((0, decorators[i])(obj) || obj); + + if (elementsAndFinisher.finisher !== undefined) { + finishers.push(elementsAndFinisher.finisher); + } + + if (elementsAndFinisher.elements !== undefined) { + elements = elementsAndFinisher.elements; + + for (var j = 0; j < elements.length - 1; j++) { + for (var k = j + 1; k < elements.length; k++) { + if (elements[j].key === elements[k].key && elements[j].placement === elements[k].placement) { + throw new TypeError("Duplicated element (" + elements[j].key + ")"); + } + } + } + } + } + + return { + elements: elements, + finishers: finishers + }; + }, + fromElementDescriptor: function (element) { + var obj = { + kind: element.kind, + key: element.key, + placement: element.placement, + descriptor: element.descriptor + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + if (element.kind === "field") obj.initializer = element.initializer; + return obj; + }, + toElementDescriptors: function (elementObjects) { + if (elementObjects === undefined) return; + return _toArray(elementObjects).map(function (elementObject) { + var element = this.toElementDescriptor(elementObject); + this.disallowProperty(elementObject, "finisher", "An element descriptor"); + this.disallowProperty(elementObject, "extras", "An element descriptor"); + return element; + }, this); + }, + toElementDescriptor: function (elementObject) { + var kind = String(elementObject.kind); + + if (kind !== "method" && kind !== "field") { + throw new TypeError('An element descriptor\'s .kind property must be either "method" or' + ' "field", but a decorator created an element descriptor with' + ' .kind "' + kind + '"'); + } + + var key = _toPropertyKey(elementObject.key); + + var placement = String(elementObject.placement); + + if (placement !== "static" && placement !== "prototype" && placement !== "own") { + throw new TypeError('An element descriptor\'s .placement property must be one of "static",' + ' "prototype" or "own", but a decorator created an element descriptor' + ' with .placement "' + placement + '"'); + } + + var descriptor = elementObject.descriptor; + this.disallowProperty(elementObject, "elements", "An element descriptor"); + var element = { + kind: kind, + key: key, + placement: placement, + descriptor: Object.assign({}, descriptor) + }; + + if (kind !== "field") { + this.disallowProperty(elementObject, "initializer", "A method descriptor"); + } else { + this.disallowProperty(descriptor, "get", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "set", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "value", "The property descriptor of a field descriptor"); + element.initializer = elementObject.initializer; + } + + return element; + }, + toElementFinisherExtras: function (elementObject) { + var element = this.toElementDescriptor(elementObject); + + var finisher = _optionalCallableProperty(elementObject, "finisher"); + + var extras = this.toElementDescriptors(elementObject.extras); + return { + element: element, + finisher: finisher, + extras: extras + }; + }, + fromClassDescriptor: function (elements) { + var obj = { + kind: "class", + elements: elements.map(this.fromElementDescriptor, this) + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + return obj; + }, + toClassDescriptor: function (obj) { + var kind = String(obj.kind); + + if (kind !== "class") { + throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator' + ' created a class descriptor with .kind "' + kind + '"'); + } + + this.disallowProperty(obj, "key", "A class descriptor"); + this.disallowProperty(obj, "placement", "A class descriptor"); + this.disallowProperty(obj, "descriptor", "A class descriptor"); + this.disallowProperty(obj, "initializer", "A class descriptor"); + this.disallowProperty(obj, "extras", "A class descriptor"); + + var finisher = _optionalCallableProperty(obj, "finisher"); + + var elements = this.toElementDescriptors(obj.elements); + return { + elements: elements, + finisher: finisher + }; + }, + runClassFinishers: function (constructor, finishers) { + for (var i = 0; i < finishers.length; i++) { + var newConstructor = (0, finishers[i])(constructor); + + if (newConstructor !== undefined) { + if (typeof newConstructor !== "function") { + throw new TypeError("Finishers must return a constructor."); + } + + constructor = newConstructor; + } + } + + return constructor; + }, + disallowProperty: function (obj, name, objectType) { + if (obj[name] !== undefined) { + throw new TypeError(objectType + " can't have a ." + name + " property."); + } + } + }; + return api; +} + +function _createElementDescriptor(def) { + var key = _toPropertyKey(def.key); + + var descriptor; + + if (def.kind === "method") { + descriptor = { + value: def.value, + writable: true, + configurable: true, + enumerable: false + }; + } else if (def.kind === "get") { + descriptor = { + get: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "set") { + descriptor = { + set: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "field") { + descriptor = { + configurable: true, + writable: true, + enumerable: true + }; + } + + var element = { + kind: def.kind === "field" ? "field" : "method", + key: key, + placement: def.static ? "static" : def.kind === "field" ? "own" : "prototype", + descriptor: descriptor + }; + if (def.decorators) element.decorators = def.decorators; + if (def.kind === "field") element.initializer = def.value; + return element; +} + +function _coalesceGetterSetter(element, other) { + if (element.descriptor.get !== undefined) { + other.descriptor.get = element.descriptor.get; + } else { + other.descriptor.set = element.descriptor.set; + } +} + +function _coalesceClassElements(elements) { + var newElements = []; + + var isSameElement = function (other) { + return other.kind === "method" && other.key === element.key && other.placement === element.placement; + }; + + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + var other; + + if (element.kind === "method" && (other = newElements.find(isSameElement))) { + if (_isDataDescriptor(element.descriptor) || _isDataDescriptor(other.descriptor)) { + if (_hasDecorators(element) || _hasDecorators(other)) { + throw new ReferenceError("Duplicated methods (" + element.key + ") can't be decorated."); + } + + other.descriptor = element.descriptor; + } else { + if (_hasDecorators(element)) { + if (_hasDecorators(other)) { + throw new ReferenceError("Decorators can't be placed on different accessors with for " + "the same property (" + element.key + ")."); + } + + other.decorators = element.decorators; + } + + _coalesceGetterSetter(element, other); + } + } else { + newElements.push(element); + } + } + + return newElements; +} + +function _hasDecorators(element) { + return element.decorators && element.decorators.length; +} + +function _isDataDescriptor(desc) { + return desc !== undefined && !(desc.value === undefined && desc.writable === undefined); +} + +function _optionalCallableProperty(obj, name) { + var value = obj[name]; + + if (value !== undefined && typeof value !== "function") { + throw new TypeError("Expected '" + name + "' to be a function"); + } + + return value; +} + +function _classPrivateMethodGet(receiver, privateSet, fn) { + if (!privateSet.has(receiver)) { + throw new TypeError("attempted to get private field on non-instance"); + } + + return fn; +} + +function _classPrivateMethodSet() { + throw new TypeError("attempted to reassign private method"); +} + +function _wrapRegExp(re, groups) { + _wrapRegExp = function (re, groups) { + return new BabelRegExp(re, undefined, groups); + }; + + var _RegExp = _wrapNativeSuper(RegExp); + + var _super = RegExp.prototype; + + var _groups = new WeakMap(); + + function BabelRegExp(re, flags, groups) { + var _this = _RegExp.call(this, re, flags); + + _groups.set(_this, groups || _groups.get(re)); + + return _this; + } + + _inherits(BabelRegExp, _RegExp); + + BabelRegExp.prototype.exec = function (str) { + var result = _super.exec.call(this, str); + + if (result) result.groups = buildGroups(result, this); + return result; + }; + + BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { + if (typeof substitution === "string") { + var groups = _groups.get(this); + + return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { + return "$" + groups[name]; + })); + } else if (typeof substitution === "function") { + var _this = this; + + return _super[Symbol.replace].call(this, str, function () { + var args = []; + args.push.apply(args, arguments); + + if (typeof args[args.length - 1] !== "object") { + args.push(buildGroups(args, _this)); + } + + return substitution.apply(this, args); + }); + } else { + return _super[Symbol.replace].call(this, str, substitution); + } + }; + + function buildGroups(result, re) { + var g = _groups.get(re); + + return Object.keys(g).reduce(function (groups, name) { + groups[name] = result[g[name]]; + return groups; + }, Object.create(null)); + } + + return _wrapRegExp.apply(this, arguments); +} + +var extImagelib = "ext-imagelib.xml"; + +var extImagelib$1 = { + name: 'imagelib', + init: function init(_ref) { + var _this = this; + + return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() { + var $, decode64, importLocale, dropXMLInternalSubset, imagelibStrings, modularVersion, svgEditor, uiStrings, svgCanvas, extIconsPath, allowedImageLibOrigins, closeBrowser, importImage, pending, mode, multiArr, transferStopped, preview, submit, onMessage, _onMessage, toggleMulti, showBrowser, buttons; + + return regeneratorRuntime.wrap(function _callee2$(_context2) { + while (1) { + switch (_context2.prev = _context2.next) { + case 0: + showBrowser = function _showBrowser() { + var browser = $('#imgbrowse'); + + if (!browser.length) { + $('
' + '
').insertAfter('#svg_docprops'); + browser = $('#imgbrowse'); + var allLibs = imagelibStrings.select_lib; + var libOpts = $('
    ').appendTo(browser); + var frame = $(' + + + diff --git a/dist/editor/system/embedapi.html b/dist/editor/system/embedapi.html new file mode 100644 index 00000000..dda45a19 --- /dev/null +++ b/dist/editor/system/embedapi.html @@ -0,0 +1,17 @@ + + + + + Embed API + + + + + + + + + +
    + + diff --git a/dist/editor/system/embedapi.js b/dist/editor/system/embedapi.js new file mode 100644 index 00000000..dd6459c4 --- /dev/null +++ b/dist/editor/system/embedapi.js @@ -0,0 +1,395 @@ +/** +* Handles underlying communication between the embedding window and the +* editor frame. +* @module EmbeddedSVGEdit +*/ + +let cbid = 0; + +/** +* @callback module:EmbeddedSVGEdit.CallbackSetter +* @param {GenericCallback} newCallback Callback to be stored (signature dependent on function) +* @returns {void} +*/ +/** +* @callback module:EmbeddedSVGEdit.CallbackSetGetter +* @param {...any} args Signature dependent on the function +* @returns {module:EmbeddedSVGEdit.CallbackSetter} +*/ + +/** +* @param {string} funcName +* @returns {module:EmbeddedSVGEdit.CallbackSetGetter} +*/ +function getCallbackSetter (funcName) { + return function (...args) { + const that = this, // New callback + callbackID = this.send(funcName, args, function () { /* */ }); // The callback (currently it's nothing, but will be set later) + + return function (newCallback) { + that.callbacks[callbackID] = newCallback; // Set callback + }; + }; +} + +/** +* Having this separate from messageListener allows us to +* avoid using JSON parsing (and its limitations) in the case +* of same domain control. +* @param {module:EmbeddedSVGEdit.EmbeddedSVGEdit} t The `this` value +* @param {PlainObject} data +* @param {JSON} data.result +* @param {string} data.error +* @param {Integer} data.id +* @returns {void} +*/ +function addCallback (t, {result, error, id: callbackID}) { + if (typeof callbackID === 'number' && t.callbacks[callbackID]) { + // These should be safe both because we check `cbid` is numeric and + // because the calls are from trusted origins + if (result) { + t.callbacks[callbackID](result); // lgtm [js/unvalidated-dynamic-method-call] + } else { + t.callbacks[callbackID](error, 'error'); // lgtm [js/unvalidated-dynamic-method-call] + } + } +} + +/** +* @param {Event} e +* @returns {void} +*/ +function messageListener (e) { + // We accept and post strings as opposed to objects for the sake of IE9 support; this + // will most likely be changed in the future + if (!e.data || !['string', 'object'].includes(typeof e.data)) { + return; + } + const {allowedOrigins} = this, + data = typeof e.data === 'object' ? e.data : JSON.parse(e.data); + if (!data || typeof data !== 'object' || data.namespace !== 'svg-edit' || + e.source !== this.frame.contentWindow || + (!allowedOrigins.includes('*') && !allowedOrigins.includes(e.origin)) + ) { + // eslint-disable-next-line no-console -- Info for developers + console.error( + `The origin ${e.origin} was not whitelisted as an origin from ` + + `which responses may be received by this ${window.origin} script.` + ); + return; + } + addCallback(this, data); +} + +/** +* @callback module:EmbeddedSVGEdit.MessageListener +* @param {MessageEvent} e +* @returns {void} +*/ +/** +* @param {module:EmbeddedSVGEdit.EmbeddedSVGEdit} t The `this` value +* @returns {module:EmbeddedSVGEdit.MessageListener} Event listener +*/ +function getMessageListener (t) { + return function (e) { + messageListener.call(t, e); + }; +} + +/** +* Embedded SVG-edit API. +* General usage: +* - Have an iframe somewhere pointing to a version of svg-edit > r1000. +* @example +// Initialize the magic with: +const svgCanvas = new EmbeddedSVGEdit(window.frames.svgedit); + +// Pass functions in this format: +svgCanvas.setSvgString('string'); + +// Or if a callback is needed: +svgCanvas.setSvgString('string')(function (data, error) { + if (error) { + // There was an error + } else { + // Handle data + } +}); + +// Everything is done with the same API as the real svg-edit, +// and all documentation is unchanged. + +// However, this file depends on the postMessage API which +// can only support JSON-serializable arguments and +// return values, so, for example, arguments whose value is +// 'undefined', a function, a non-finite number, or a built-in +// object like Date(), RegExp(), etc. will most likely not behave +// as expected. In such a case one may need to host +// the SVG editor on the same domain and reference the +// JavaScript methods on the frame itself. + +// The only other difference is when handling returns: +// the callback notation is used instead. +const blah = new EmbeddedSVGEdit(window.frames.svgedit); +blah.clearSelection('woot', 'blah', 1337, [1, 2, 3, 4, 5, 'moo'], -42, { + a: 'tree', b: 6, c: 9 +})(function () { console.log('GET DATA', args); }); +* +* @memberof module:EmbeddedSVGEdit +*/ +class EmbeddedSVGEdit { + /** + * @param {HTMLIFrameElement} frame + * @param {string[]} [allowedOrigins=[]] Array of origins from which incoming + * messages will be allowed when same origin is not used; defaults to none. + * If supplied, it should probably be the same as svgEditor's allowedOrigins + */ + constructor (frame, allowedOrigins) { + const that = this; + this.allowedOrigins = allowedOrigins || []; + // Initialize communication + this.frame = frame; + this.callbacks = {}; + // List of functions extracted with this: + // Run in firebug on http://svg-edit.googlecode.com/svn/trunk/docs/files/svgcanvas-js.html + + // for (const i=0,q=[],f = document.querySelectorAll('div.CFunction h3.CTitle a'); i < f.length; i++) { q.push(f[i].name); }; q + // const functions = ['clearSelection', 'addToSelection', 'removeFromSelection', 'open', 'save', 'getSvgString', 'setSvgString', + // 'createLayer', 'deleteCurrentLayer', 'setCurrentLayer', 'renameCurrentLayer', 'setCurrentLayerPosition', 'setLayerVisibility', + // 'moveSelectedToLayer', 'clear']; + + // Newer, well, it extracts things that aren't documented as well. All functions accessible through the normal thingy can now be accessed though the API + // const {svgCanvas} = frame.contentWindow; + // const l = []; + // for (const i in svgCanvas) { if (typeof svgCanvas[i] === 'function') { l.push(i);} }; + // alert("['" + l.join("', '") + "']"); + // Run in svgedit itself + const functions = [ + 'addExtension', + 'addSVGElementFromJson', + 'addToSelection', + 'alignSelectedElements', + 'assignAttributes', + 'bind', + 'call', + 'changeSelectedAttribute', + 'cleanupElement', + 'clear', + 'clearSelection', + 'clearSvgContentElement', + 'cloneLayer', + 'cloneSelectedElements', + 'convertGradients', + 'convertToGroup', + 'convertToNum', + 'convertToPath', + 'copySelectedElements', + 'createLayer', + 'cutSelectedElements', + 'cycleElement', + 'deleteCurrentLayer', + 'deleteSelectedElements', + 'embedImage', + 'exportPDF', + 'findDefs', + 'getBBox', + 'getBlur', + 'getBold', + 'getColor', + 'getContentElem', + 'getCurrentDrawing', + 'getDocumentTitle', + 'getEditorNS', + 'getElem', + 'getFillOpacity', + 'getFontColor', + 'getFontFamily', + 'getFontSize', + 'getHref', + 'getId', + 'getIntersectionList', + 'getItalic', + 'getMode', + 'getMouseTarget', + 'getNextId', + 'getOffset', + 'getOpacity', + 'getPaintOpacity', + 'getPrivateMethods', + 'getRefElem', + 'getResolution', + 'getRootElem', + 'getRotationAngle', + 'getSelectedElems', + 'getStrokeOpacity', + 'getStrokeWidth', + 'getStrokedBBox', + 'getStyle', + 'getSvgString', + 'getText', + 'getTitle', + 'getTransformList', + 'getUIStrings', + 'getUrlFromAttr', + 'getVersion', + 'getVisibleElements', + 'getVisibleElementsAndBBoxes', + 'getZoom', + 'groupSelectedElements', + 'groupSvgElem', + 'hasMatrixTransform', + 'identifyLayers', + 'importSvgString', + 'leaveContext', + 'linkControlPoints', + 'makeHyperlink', + 'matrixMultiply', + 'mergeAllLayers', + 'mergeLayer', + 'moveSelectedElements', + 'moveSelectedToLayer', + 'moveToBottomSelectedElement', + 'moveToTopSelectedElement', + 'moveUpDownSelected', + 'open', + 'pasteElements', + 'prepareSvg', + 'pushGroupProperties', + 'randomizeIds', + 'rasterExport', + 'ready', + 'recalculateAllSelectedDimensions', + 'recalculateDimensions', + 'remapElement', + 'removeFromSelection', + 'removeHyperlink', + 'removeUnusedDefElems', + 'renameCurrentLayer', + 'round', + 'runExtensions', + 'sanitizeSvg', + 'save', + 'selectAllInCurrentLayer', + 'selectOnly', + 'setBBoxZoom', + 'setBackground', + 'setBlur', + 'setBlurNoUndo', + 'setBlurOffsets', + 'setBold', + 'setColor', + 'setConfig', + 'setContext', + 'setCurrentLayer', + 'setCurrentLayerPosition', + 'setDocumentTitle', + 'setFillPaint', + 'setFontColor', + 'setFontFamily', + 'setFontSize', + 'setGoodImage', + 'setGradient', + 'setGroupTitle', + 'setHref', + 'setIdPrefix', + 'setImageURL', + 'setItalic', + 'setLayerVisibility', + 'setLinkURL', + 'setMode', + 'setOpacity', + 'setPaint', + 'setPaintOpacity', + 'setRectRadius', + 'setResolution', + 'setRotationAngle', + 'setSegType', + 'setStrokeAttr', + 'setStrokePaint', + 'setStrokeWidth', + 'setSvgString', + 'setTextContent', + 'setUiStrings', + 'setUseData', + 'setZoom', + 'svgCanvasToString', + 'svgToString', + 'transformListToTransform', + 'ungroupSelectedElement', + 'uniquifyElems', + 'updateCanvas', + 'zoomChanged' + ]; + + // TODO: rewrite the following, it's pretty scary. + for (const func of functions) { + this[func] = getCallbackSetter(func); + } + + // Older IE may need a polyfill for addEventListener, but so it would for SVG + window.addEventListener('message', getMessageListener(this)); + window.addEventListener('keydown', (e) => { + const {type, key} = e; + if (key === 'Backspace') { + e.preventDefault(); + const keyboardEvent = new KeyboardEvent(type, {key}); + that.frame.contentDocument.dispatchEvent(keyboardEvent); + } + }); + } + + /** + * @param {string} name + * @param {ArgumentsArray} args Signature dependent on function + * @param {GenericCallback} callback (This may be better than a promise in case adding an event.) + * @returns {Integer} + */ + send (name, args, callback) { // eslint-disable-line promise/prefer-await-to-callbacks + const that = this; + cbid++; + + this.callbacks[cbid] = callback; + setTimeout((function (callbackID) { + return function () { // Delay for the callback to be set in case its synchronous + /* + * Todo: Handle non-JSON arguments and return values (undefined, + * nonfinite numbers, functions, and built-in objects like Date, + * RegExp), etc.? Allow promises instead of callbacks? Review + * SVG-Edit functions for whether JSON-able parameters can be + * made compatile with all API functionality + */ + // We accept and post strings for the sake of IE9 support + let sameOriginWithGlobal = false; + try { + sameOriginWithGlobal = window.location.origin === that.frame.contentWindow.location.origin && + that.frame.contentWindow.svgEditor.canvas; + } catch (err) {} + + if (sameOriginWithGlobal) { + // Although we do not really need this API if we are working same + // domain, it could allow us to write in a way that would work + // cross-domain as well, assuming we stick to the argument limitations + // of the current JSON-based communication API (e.g., not passing + // callbacks). We might be able to address these shortcomings; see + // the todo elsewhere in this file. + const message = {id: callbackID}, + {svgEditor: {canvas: svgCanvas}} = that.frame.contentWindow; + try { + message.result = svgCanvas[name](...args); + } catch (err) { + message.error = err.message; + } + addCallback(that, message); + } else { // Requires the ext-xdomain-messaging.js extension + that.frame.contentWindow.postMessage(JSON.stringify({ + namespace: 'svgCanvas', id: callbackID, name, args + }), '*'); + } + }; + }(cbid)), 0); + + return cbid; + } +} + +export default EmbeddedSVGEdit; diff --git a/dist/editor/system/extensions/ext-arrows.js b/dist/editor/system/extensions/ext-arrows.js new file mode 100644 index 00000000..6fc1f8f2 --- /dev/null +++ b/dist/editor/system/extensions/ext-arrows.js @@ -0,0 +1,2012 @@ +System.register([], function (exports) { + 'use strict'; + return { + execute: function () { + + function _typeof(obj) { + "@babel/helpers - typeof"; + + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function (obj) { + return typeof obj; + }; + } else { + _typeof = function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); + } + + var REACT_ELEMENT_TYPE; + + function _jsx(type, props, key, children) { + if (!REACT_ELEMENT_TYPE) { + REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol["for"] && Symbol["for"]("react.element") || 0xeac7; + } + + var defaultProps = type && type.defaultProps; + var childrenLength = arguments.length - 3; + + if (!props && childrenLength !== 0) { + props = { + children: void 0 + }; + } + + if (childrenLength === 1) { + props.children = children; + } else if (childrenLength > 1) { + var childArray = new Array(childrenLength); + + for (var i = 0; i < childrenLength; i++) { + childArray[i] = arguments[i + 3]; + } + + props.children = childArray; + } + + if (props && defaultProps) { + for (var propName in defaultProps) { + if (props[propName] === void 0) { + props[propName] = defaultProps[propName]; + } + } + } else if (!props) { + props = defaultProps || {}; + } + + return { + $$typeof: REACT_ELEMENT_TYPE, + type: type, + key: key === undefined ? null : '' + key, + ref: null, + props: props, + _owner: null + }; + } + + function _asyncIterator(iterable) { + var method; + + if (typeof Symbol !== "undefined") { + if (Symbol.asyncIterator) { + method = iterable[Symbol.asyncIterator]; + if (method != null) return method.call(iterable); + } + + if (Symbol.iterator) { + method = iterable[Symbol.iterator]; + if (method != null) return method.call(iterable); + } + } + + throw new TypeError("Object is not async iterable"); + } + + function _AwaitValue(value) { + this.wrapped = value; + } + + function _AsyncGenerator(gen) { + var front, back; + + function send(key, arg) { + return new Promise(function (resolve, reject) { + var request = { + key: key, + arg: arg, + resolve: resolve, + reject: reject, + next: null + }; + + if (back) { + back = back.next = request; + } else { + front = back = request; + resume(key, arg); + } + }); + } + + function resume(key, arg) { + try { + var result = gen[key](arg); + var value = result.value; + var wrappedAwait = value instanceof _AwaitValue; + Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { + if (wrappedAwait) { + resume(key === "return" ? "return" : "next", arg); + return; + } + + settle(result.done ? "return" : "normal", arg); + }, function (err) { + resume("throw", err); + }); + } catch (err) { + settle("throw", err); + } + } + + function settle(type, value) { + switch (type) { + case "return": + front.resolve({ + value: value, + done: true + }); + break; + + case "throw": + front.reject(value); + break; + + default: + front.resolve({ + value: value, + done: false + }); + break; + } + + front = front.next; + + if (front) { + resume(front.key, front.arg); + } else { + back = null; + } + } + + this._invoke = send; + + if (typeof gen.return !== "function") { + this.return = undefined; + } + } + + if (typeof Symbol === "function" && Symbol.asyncIterator) { + _AsyncGenerator.prototype[Symbol.asyncIterator] = function () { + return this; + }; + } + + _AsyncGenerator.prototype.next = function (arg) { + return this._invoke("next", arg); + }; + + _AsyncGenerator.prototype.throw = function (arg) { + return this._invoke("throw", arg); + }; + + _AsyncGenerator.prototype.return = function (arg) { + return this._invoke("return", arg); + }; + + function _wrapAsyncGenerator(fn) { + return function () { + return new _AsyncGenerator(fn.apply(this, arguments)); + }; + } + + function _awaitAsyncGenerator(value) { + return new _AwaitValue(value); + } + + function _asyncGeneratorDelegate(inner, awaitWrap) { + var iter = {}, + waiting = false; + + function pump(key, value) { + waiting = true; + value = new Promise(function (resolve) { + resolve(inner[key](value)); + }); + return { + done: false, + value: awaitWrap(value) + }; + } + + ; + + if (typeof Symbol === "function" && Symbol.iterator) { + iter[Symbol.iterator] = function () { + return this; + }; + } + + iter.next = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("next", value); + }; + + if (typeof inner.throw === "function") { + iter.throw = function (value) { + if (waiting) { + waiting = false; + throw value; + } + + return pump("throw", value); + }; + } + + if (typeof inner.return === "function") { + iter.return = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("return", value); + }; + } + + return iter; + } + + function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { + try { + var info = gen[key](arg); + var value = info.value; + } catch (error) { + reject(error); + return; + } + + if (info.done) { + resolve(value); + } else { + Promise.resolve(value).then(_next, _throw); + } + } + + function _asyncToGenerator(fn) { + return function () { + var self = this, + args = arguments; + return new Promise(function (resolve, reject) { + var gen = fn.apply(self, args); + + function _next(value) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); + } + + function _throw(err) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); + } + + _next(undefined); + }); + }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; + } + + function _defineEnumerableProperties(obj, descs) { + for (var key in descs) { + var desc = descs[key]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, key, desc); + } + + if (Object.getOwnPropertySymbols) { + var objectSymbols = Object.getOwnPropertySymbols(descs); + + for (var i = 0; i < objectSymbols.length; i++) { + var sym = objectSymbols[i]; + var desc = descs[sym]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, sym, desc); + } + } + + return obj; + } + + function _defaults(obj, defaults) { + var keys = Object.getOwnPropertyNames(defaults); + + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var value = Object.getOwnPropertyDescriptor(defaults, key); + + if (value && value.configurable && obj[key] === undefined) { + Object.defineProperty(obj, key, value); + } + } + + return obj; + } + + function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; + } + + function _extends() { + _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + + return _extends.apply(this, arguments); + } + + function _objectSpread(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? Object(arguments[i]) : {}; + var ownKeys = Object.keys(source); + + if (typeof Object.getOwnPropertySymbols === 'function') { + ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { + return Object.getOwnPropertyDescriptor(source, sym).enumerable; + })); + } + + ownKeys.forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } + + return target; + } + + function ownKeys(object, enumerableOnly) { + var keys = Object.keys(object); + + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(object); + if (enumerableOnly) symbols = symbols.filter(function (sym) { + return Object.getOwnPropertyDescriptor(object, sym).enumerable; + }); + keys.push.apply(keys, symbols); + } + + return keys; + } + + function _objectSpread2(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? arguments[i] : {}; + + if (i % 2) { + ownKeys(Object(source), true).forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } else if (Object.getOwnPropertyDescriptors) { + Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); + } else { + ownKeys(Object(source)).forEach(function (key) { + Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); + }); + } + } + + return target; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function"); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + writable: true, + configurable: true + } + }); + if (superClass) _setPrototypeOf(subClass, superClass); + } + + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + subClass.__proto__ = superClass; + } + + function _getPrototypeOf(o) { + _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { + return o.__proto__ || Object.getPrototypeOf(o); + }; + return _getPrototypeOf(o); + } + + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + + return _setPrototypeOf(o, p); + } + + function _isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + + try { + Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); + return true; + } catch (e) { + return false; + } + } + + function _construct(Parent, args, Class) { + if (_isNativeReflectConstruct()) { + _construct = Reflect.construct; + } else { + _construct = function _construct(Parent, args, Class) { + var a = [null]; + a.push.apply(a, args); + var Constructor = Function.bind.apply(Parent, a); + var instance = new Constructor(); + if (Class) _setPrototypeOf(instance, Class.prototype); + return instance; + }; + } + + return _construct.apply(null, arguments); + } + + function _isNativeFunction(fn) { + return Function.toString.call(fn).indexOf("[native code]") !== -1; + } + + function _wrapNativeSuper(Class) { + var _cache = typeof Map === "function" ? new Map() : undefined; + + _wrapNativeSuper = function _wrapNativeSuper(Class) { + if (Class === null || !_isNativeFunction(Class)) return Class; + + if (typeof Class !== "function") { + throw new TypeError("Super expression must either be null or a function"); + } + + if (typeof _cache !== "undefined") { + if (_cache.has(Class)) return _cache.get(Class); + + _cache.set(Class, Wrapper); + } + + function Wrapper() { + return _construct(Class, arguments, _getPrototypeOf(this).constructor); + } + + Wrapper.prototype = Object.create(Class.prototype, { + constructor: { + value: Wrapper, + enumerable: false, + writable: true, + configurable: true + } + }); + return _setPrototypeOf(Wrapper, Class); + }; + + return _wrapNativeSuper(Class); + } + + function _instanceof(left, right) { + if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { + return !!right[Symbol.hasInstance](left); + } else { + return left instanceof right; + } + } + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + + function _getRequireWildcardCache() { + if (typeof WeakMap !== "function") return null; + var cache = new WeakMap(); + + _getRequireWildcardCache = function () { + return cache; + }; + + return cache; + } + + function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } + + if (obj === null || typeof obj !== "object" && typeof obj !== "function") { + return { + default: obj + }; + } + + var cache = _getRequireWildcardCache(); + + if (cache && cache.has(obj)) { + return cache.get(obj); + } + + var newObj = {}; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + + if (desc && (desc.get || desc.set)) { + Object.defineProperty(newObj, key, desc); + } else { + newObj[key] = obj[key]; + } + } + } + + newObj.default = obj; + + if (cache) { + cache.set(obj, newObj); + } + + return newObj; + } + + function _newArrowCheck(innerThis, boundThis) { + if (innerThis !== boundThis) { + throw new TypeError("Cannot instantiate an arrow function"); + } + } + + function _objectDestructuringEmpty(obj) { + if (obj == null) throw new TypeError("Cannot destructure undefined"); + } + + function _objectWithoutPropertiesLoose(source, excluded) { + if (source == null) return {}; + var target = {}; + var sourceKeys = Object.keys(source); + var key, i; + + for (i = 0; i < sourceKeys.length; i++) { + key = sourceKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + target[key] = source[key]; + } + + return target; + } + + function _objectWithoutProperties(source, excluded) { + if (source == null) return {}; + + var target = _objectWithoutPropertiesLoose(source, excluded); + + var key, i; + + if (Object.getOwnPropertySymbols) { + var sourceSymbolKeys = Object.getOwnPropertySymbols(source); + + for (i = 0; i < sourceSymbolKeys.length; i++) { + key = sourceSymbolKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; + target[key] = source[key]; + } + } + + return target; + } + + function _assertThisInitialized(self) { + if (self === void 0) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return self; + } + + function _possibleConstructorReturn(self, call) { + if (call && (typeof call === "object" || typeof call === "function")) { + return call; + } + + return _assertThisInitialized(self); + } + + function _createSuper(Derived) { + var hasNativeReflectConstruct = _isNativeReflectConstruct(); + + return function _createSuperInternal() { + var Super = _getPrototypeOf(Derived), + result; + + if (hasNativeReflectConstruct) { + var NewTarget = _getPrototypeOf(this).constructor; + + result = Reflect.construct(Super, arguments, NewTarget); + } else { + result = Super.apply(this, arguments); + } + + return _possibleConstructorReturn(this, result); + }; + } + + function _superPropBase(object, property) { + while (!Object.prototype.hasOwnProperty.call(object, property)) { + object = _getPrototypeOf(object); + if (object === null) break; + } + + return object; + } + + function _get(target, property, receiver) { + if (typeof Reflect !== "undefined" && Reflect.get) { + _get = Reflect.get; + } else { + _get = function _get(target, property, receiver) { + var base = _superPropBase(target, property); + + if (!base) return; + var desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.get) { + return desc.get.call(receiver); + } + + return desc.value; + }; + } + + return _get(target, property, receiver || target); + } + + function set(target, property, value, receiver) { + if (typeof Reflect !== "undefined" && Reflect.set) { + set = Reflect.set; + } else { + set = function set(target, property, value, receiver) { + var base = _superPropBase(target, property); + + var desc; + + if (base) { + desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.set) { + desc.set.call(receiver, value); + return true; + } else if (!desc.writable) { + return false; + } + } + + desc = Object.getOwnPropertyDescriptor(receiver, property); + + if (desc) { + if (!desc.writable) { + return false; + } + + desc.value = value; + Object.defineProperty(receiver, property, desc); + } else { + _defineProperty(receiver, property, value); + } + + return true; + }; + } + + return set(target, property, value, receiver); + } + + function _set(target, property, value, receiver, isStrict) { + var s = set(target, property, value, receiver || target); + + if (!s && isStrict) { + throw new Error('failed to set property'); + } + + return value; + } + + function _taggedTemplateLiteral(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + return Object.freeze(Object.defineProperties(strings, { + raw: { + value: Object.freeze(raw) + } + })); + } + + function _taggedTemplateLiteralLoose(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + strings.raw = raw; + return strings; + } + + function _readOnlyError(name) { + throw new Error("\"" + name + "\" is read-only"); + } + + function _classNameTDZError(name) { + throw new Error("Class \"" + name + "\" cannot be referenced in computed property keys."); + } + + function _temporalUndefined() {} + + function _tdz(name) { + throw new ReferenceError(name + " is not defined - temporal dead zone"); + } + + function _temporalRef(val, name) { + return val === _temporalUndefined ? _tdz(name) : val; + } + + function _slicedToArray(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); + } + + function _slicedToArrayLoose(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimitLoose(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); + } + + function _toArray(arr) { + return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); + } + + function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); + } + + function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) return _arrayLikeToArray(arr); + } + + function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; + } + + function _maybeArrayLike(next, arr, i) { + if (arr && !Array.isArray(arr) && typeof arr.length === "number") { + var len = arr.length; + return _arrayLikeToArray(arr, i !== void 0 && i < len ? i : len); + } + + return next(arr, i); + } + + function _iterableToArray(iter) { + if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); + } + + function _iterableToArrayLimit(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"] != null) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; + } + + function _iterableToArrayLimitLoose(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + + for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { + _arr.push(_step.value); + + if (i && _arr.length === i) break; + } + + return _arr; + } + + function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if (typeof o === "string") return _arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + if (n === "Object" && o.constructor) n = o.constructor.name; + if (n === "Map" || n === "Set") return Array.from(o); + if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); + } + + function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) len = arr.length; + + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + + return arr2; + } + + function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + function _createForOfIteratorHelper(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + + var F = function () {}; + + return { + s: F, + n: function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }, + e: function (e) { + throw e; + }, + f: F + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + var normalCompletion = true, + didErr = false, + err; + return { + s: function () { + it = o[Symbol.iterator](); + }, + n: function () { + var step = it.next(); + normalCompletion = step.done; + return step; + }, + e: function (e) { + didErr = true; + err = e; + }, + f: function () { + try { + if (!normalCompletion && it.return != null) it.return(); + } finally { + if (didErr) throw err; + } + } + }; + } + + function _createForOfIteratorHelperLoose(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + return function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + it = o[Symbol.iterator](); + return it.next.bind(it); + } + + function _skipFirstGeneratorNext(fn) { + return function () { + var it = fn.apply(this, arguments); + it.next(); + return it; + }; + } + + function _toPrimitive(input, hint) { + if (typeof input !== "object" || input === null) return input; + var prim = input[Symbol.toPrimitive]; + + if (prim !== undefined) { + var res = prim.call(input, hint || "default"); + if (typeof res !== "object") return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + + return (hint === "string" ? String : Number)(input); + } + + function _toPropertyKey(arg) { + var key = _toPrimitive(arg, "string"); + + return typeof key === "symbol" ? key : String(key); + } + + function _initializerWarningHelper(descriptor, context) { + throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.'); + } + + function _initializerDefineProperty(target, property, descriptor, context) { + if (!descriptor) return; + Object.defineProperty(target, property, { + enumerable: descriptor.enumerable, + configurable: descriptor.configurable, + writable: descriptor.writable, + value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 + }); + } + + function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { + var desc = {}; + Object.keys(descriptor).forEach(function (key) { + desc[key] = descriptor[key]; + }); + desc.enumerable = !!desc.enumerable; + desc.configurable = !!desc.configurable; + + if ('value' in desc || desc.initializer) { + desc.writable = true; + } + + desc = decorators.slice().reverse().reduce(function (desc, decorator) { + return decorator(target, property, desc) || desc; + }, desc); + + if (context && desc.initializer !== void 0) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = undefined; + } + + if (desc.initializer === void 0) { + Object.defineProperty(target, property, desc); + desc = null; + } + + return desc; + } + + var id = 0; + + function _classPrivateFieldLooseKey(name) { + return "__private_" + id++ + "_" + name; + } + + function _classPrivateFieldLooseBase(receiver, privateKey) { + if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { + throw new TypeError("attempted to use private field on non-instance"); + } + + return receiver; + } + + function _classPrivateFieldGet(receiver, privateMap) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to get private field on non-instance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; + } + + function _classPrivateFieldSet(receiver, privateMap, value) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to set private field on non-instance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; + } + + function _classPrivateFieldDestructureSet(receiver, privateMap) { + if (!privateMap.has(receiver)) { + throw new TypeError("attempted to set private field on non-instance"); + } + + var descriptor = privateMap.get(receiver); + + if (descriptor.set) { + if (!("__destrObj" in descriptor)) { + descriptor.__destrObj = { + set value(v) { + descriptor.set.call(receiver, v); + } + + }; + } + + return descriptor.__destrObj; + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + return descriptor; + } + } + + function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; + } + + function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; + } + + function _classStaticPrivateMethodGet(receiver, classConstructor, method) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + return method; + } + + function _classStaticPrivateMethodSet() { + throw new TypeError("attempted to set read only static private field"); + } + + function _decorate(decorators, factory, superClass, mixins) { + var api = _getDecoratorsApi(); + + if (mixins) { + for (var i = 0; i < mixins.length; i++) { + api = mixins[i](api); + } + } + + var r = factory(function initialize(O) { + api.initializeInstanceElements(O, decorated.elements); + }, superClass); + var decorated = api.decorateClass(_coalesceClassElements(r.d.map(_createElementDescriptor)), decorators); + api.initializeClassElements(r.F, decorated.elements); + return api.runClassFinishers(r.F, decorated.finishers); + } + + function _getDecoratorsApi() { + _getDecoratorsApi = function () { + return api; + }; + + var api = { + elementsDefinitionOrder: [["method"], ["field"]], + initializeInstanceElements: function (O, elements) { + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + if (element.kind === kind && element.placement === "own") { + this.defineClassElement(O, element); + } + }, this); + }, this); + }, + initializeClassElements: function (F, elements) { + var proto = F.prototype; + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + var placement = element.placement; + + if (element.kind === kind && (placement === "static" || placement === "prototype")) { + var receiver = placement === "static" ? F : proto; + this.defineClassElement(receiver, element); + } + }, this); + }, this); + }, + defineClassElement: function (receiver, element) { + var descriptor = element.descriptor; + + if (element.kind === "field") { + var initializer = element.initializer; + descriptor = { + enumerable: descriptor.enumerable, + writable: descriptor.writable, + configurable: descriptor.configurable, + value: initializer === void 0 ? void 0 : initializer.call(receiver) + }; + } + + Object.defineProperty(receiver, element.key, descriptor); + }, + decorateClass: function (elements, decorators) { + var newElements = []; + var finishers = []; + var placements = { + static: [], + prototype: [], + own: [] + }; + elements.forEach(function (element) { + this.addElementPlacement(element, placements); + }, this); + elements.forEach(function (element) { + if (!_hasDecorators(element)) return newElements.push(element); + var elementFinishersExtras = this.decorateElement(element, placements); + newElements.push(elementFinishersExtras.element); + newElements.push.apply(newElements, elementFinishersExtras.extras); + finishers.push.apply(finishers, elementFinishersExtras.finishers); + }, this); + + if (!decorators) { + return { + elements: newElements, + finishers: finishers + }; + } + + var result = this.decorateConstructor(newElements, decorators); + finishers.push.apply(finishers, result.finishers); + result.finishers = finishers; + return result; + }, + addElementPlacement: function (element, placements, silent) { + var keys = placements[element.placement]; + + if (!silent && keys.indexOf(element.key) !== -1) { + throw new TypeError("Duplicated element (" + element.key + ")"); + } + + keys.push(element.key); + }, + decorateElement: function (element, placements) { + var extras = []; + var finishers = []; + + for (var decorators = element.decorators, i = decorators.length - 1; i >= 0; i--) { + var keys = placements[element.placement]; + keys.splice(keys.indexOf(element.key), 1); + var elementObject = this.fromElementDescriptor(element); + var elementFinisherExtras = this.toElementFinisherExtras((0, decorators[i])(elementObject) || elementObject); + element = elementFinisherExtras.element; + this.addElementPlacement(element, placements); + + if (elementFinisherExtras.finisher) { + finishers.push(elementFinisherExtras.finisher); + } + + var newExtras = elementFinisherExtras.extras; + + if (newExtras) { + for (var j = 0; j < newExtras.length; j++) { + this.addElementPlacement(newExtras[j], placements); + } + + extras.push.apply(extras, newExtras); + } + } + + return { + element: element, + finishers: finishers, + extras: extras + }; + }, + decorateConstructor: function (elements, decorators) { + var finishers = []; + + for (var i = decorators.length - 1; i >= 0; i--) { + var obj = this.fromClassDescriptor(elements); + var elementsAndFinisher = this.toClassDescriptor((0, decorators[i])(obj) || obj); + + if (elementsAndFinisher.finisher !== undefined) { + finishers.push(elementsAndFinisher.finisher); + } + + if (elementsAndFinisher.elements !== undefined) { + elements = elementsAndFinisher.elements; + + for (var j = 0; j < elements.length - 1; j++) { + for (var k = j + 1; k < elements.length; k++) { + if (elements[j].key === elements[k].key && elements[j].placement === elements[k].placement) { + throw new TypeError("Duplicated element (" + elements[j].key + ")"); + } + } + } + } + } + + return { + elements: elements, + finishers: finishers + }; + }, + fromElementDescriptor: function (element) { + var obj = { + kind: element.kind, + key: element.key, + placement: element.placement, + descriptor: element.descriptor + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + if (element.kind === "field") obj.initializer = element.initializer; + return obj; + }, + toElementDescriptors: function (elementObjects) { + if (elementObjects === undefined) return; + return _toArray(elementObjects).map(function (elementObject) { + var element = this.toElementDescriptor(elementObject); + this.disallowProperty(elementObject, "finisher", "An element descriptor"); + this.disallowProperty(elementObject, "extras", "An element descriptor"); + return element; + }, this); + }, + toElementDescriptor: function (elementObject) { + var kind = String(elementObject.kind); + + if (kind !== "method" && kind !== "field") { + throw new TypeError('An element descriptor\'s .kind property must be either "method" or' + ' "field", but a decorator created an element descriptor with' + ' .kind "' + kind + '"'); + } + + var key = _toPropertyKey(elementObject.key); + + var placement = String(elementObject.placement); + + if (placement !== "static" && placement !== "prototype" && placement !== "own") { + throw new TypeError('An element descriptor\'s .placement property must be one of "static",' + ' "prototype" or "own", but a decorator created an element descriptor' + ' with .placement "' + placement + '"'); + } + + var descriptor = elementObject.descriptor; + this.disallowProperty(elementObject, "elements", "An element descriptor"); + var element = { + kind: kind, + key: key, + placement: placement, + descriptor: Object.assign({}, descriptor) + }; + + if (kind !== "field") { + this.disallowProperty(elementObject, "initializer", "A method descriptor"); + } else { + this.disallowProperty(descriptor, "get", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "set", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "value", "The property descriptor of a field descriptor"); + element.initializer = elementObject.initializer; + } + + return element; + }, + toElementFinisherExtras: function (elementObject) { + var element = this.toElementDescriptor(elementObject); + + var finisher = _optionalCallableProperty(elementObject, "finisher"); + + var extras = this.toElementDescriptors(elementObject.extras); + return { + element: element, + finisher: finisher, + extras: extras + }; + }, + fromClassDescriptor: function (elements) { + var obj = { + kind: "class", + elements: elements.map(this.fromElementDescriptor, this) + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + return obj; + }, + toClassDescriptor: function (obj) { + var kind = String(obj.kind); + + if (kind !== "class") { + throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator' + ' created a class descriptor with .kind "' + kind + '"'); + } + + this.disallowProperty(obj, "key", "A class descriptor"); + this.disallowProperty(obj, "placement", "A class descriptor"); + this.disallowProperty(obj, "descriptor", "A class descriptor"); + this.disallowProperty(obj, "initializer", "A class descriptor"); + this.disallowProperty(obj, "extras", "A class descriptor"); + + var finisher = _optionalCallableProperty(obj, "finisher"); + + var elements = this.toElementDescriptors(obj.elements); + return { + elements: elements, + finisher: finisher + }; + }, + runClassFinishers: function (constructor, finishers) { + for (var i = 0; i < finishers.length; i++) { + var newConstructor = (0, finishers[i])(constructor); + + if (newConstructor !== undefined) { + if (typeof newConstructor !== "function") { + throw new TypeError("Finishers must return a constructor."); + } + + constructor = newConstructor; + } + } + + return constructor; + }, + disallowProperty: function (obj, name, objectType) { + if (obj[name] !== undefined) { + throw new TypeError(objectType + " can't have a ." + name + " property."); + } + } + }; + return api; + } + + function _createElementDescriptor(def) { + var key = _toPropertyKey(def.key); + + var descriptor; + + if (def.kind === "method") { + descriptor = { + value: def.value, + writable: true, + configurable: true, + enumerable: false + }; + } else if (def.kind === "get") { + descriptor = { + get: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "set") { + descriptor = { + set: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "field") { + descriptor = { + configurable: true, + writable: true, + enumerable: true + }; + } + + var element = { + kind: def.kind === "field" ? "field" : "method", + key: key, + placement: def.static ? "static" : def.kind === "field" ? "own" : "prototype", + descriptor: descriptor + }; + if (def.decorators) element.decorators = def.decorators; + if (def.kind === "field") element.initializer = def.value; + return element; + } + + function _coalesceGetterSetter(element, other) { + if (element.descriptor.get !== undefined) { + other.descriptor.get = element.descriptor.get; + } else { + other.descriptor.set = element.descriptor.set; + } + } + + function _coalesceClassElements(elements) { + var newElements = []; + + var isSameElement = function (other) { + return other.kind === "method" && other.key === element.key && other.placement === element.placement; + }; + + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + var other; + + if (element.kind === "method" && (other = newElements.find(isSameElement))) { + if (_isDataDescriptor(element.descriptor) || _isDataDescriptor(other.descriptor)) { + if (_hasDecorators(element) || _hasDecorators(other)) { + throw new ReferenceError("Duplicated methods (" + element.key + ") can't be decorated."); + } + + other.descriptor = element.descriptor; + } else { + if (_hasDecorators(element)) { + if (_hasDecorators(other)) { + throw new ReferenceError("Decorators can't be placed on different accessors with for " + "the same property (" + element.key + ")."); + } + + other.decorators = element.decorators; + } + + _coalesceGetterSetter(element, other); + } + } else { + newElements.push(element); + } + } + + return newElements; + } + + function _hasDecorators(element) { + return element.decorators && element.decorators.length; + } + + function _isDataDescriptor(desc) { + return desc !== undefined && !(desc.value === undefined && desc.writable === undefined); + } + + function _optionalCallableProperty(obj, name) { + var value = obj[name]; + + if (value !== undefined && typeof value !== "function") { + throw new TypeError("Expected '" + name + "' to be a function"); + } + + return value; + } + + function _classPrivateMethodGet(receiver, privateSet, fn) { + if (!privateSet.has(receiver)) { + throw new TypeError("attempted to get private field on non-instance"); + } + + return fn; + } + + function _classPrivateMethodSet() { + throw new TypeError("attempted to reassign private method"); + } + + function _wrapRegExp(re, groups) { + _wrapRegExp = function (re, groups) { + return new BabelRegExp(re, undefined, groups); + }; + + var _RegExp = _wrapNativeSuper(RegExp); + + var _super = RegExp.prototype; + + var _groups = new WeakMap(); + + function BabelRegExp(re, flags, groups) { + var _this = _RegExp.call(this, re, flags); + + _groups.set(_this, groups || _groups.get(re)); + + return _this; + } + + _inherits(BabelRegExp, _RegExp); + + BabelRegExp.prototype.exec = function (str) { + var result = _super.exec.call(this, str); + + if (result) result.groups = buildGroups(result, this); + return result; + }; + + BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { + if (typeof substitution === "string") { + var groups = _groups.get(this); + + return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { + return "$" + groups[name]; + })); + } else if (typeof substitution === "function") { + var _this = this; + + return _super[Symbol.replace].call(this, str, function () { + var args = []; + args.push.apply(args, arguments); + + if (typeof args[args.length - 1] !== "object") { + args.push(buildGroups(args, _this)); + } + + return substitution.apply(this, args); + }); + } else { + return _super[Symbol.replace].call(this, str, substitution); + } + }; + + function buildGroups(result, re) { + var g = _groups.get(re); + + return Object.keys(g).reduce(function (groups, name) { + groups[name] = result[g[name]]; + return groups; + }, Object.create(null)); + } + + return _wrapRegExp.apply(this, arguments); + } + + /** + * @file ext-arrows.js + * + * @license MIT + * + * @copyright 2010 Alexis Deveria + * + */ + var extArrows = exports('default', { + name: 'arrows', + init: function init(S) { + var _this = this; + + return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() { + var strings, svgEditor, svgCanvas, addElem, nonce, $, prefix, selElems, arrowprefix, randomizeIds, setArrowNonce, unsetArrowNonce, pathdata, getLinked, showPanel, resetMarker, addMarker, setArrow, colorChanged, contextTools; + return regeneratorRuntime.wrap(function _callee2$(_context2) { + while (1) { + switch (_context2.prev = _context2.next) { + case 0: + colorChanged = function _colorChanged(elem) { + var color = elem.getAttribute('stroke'); + var mtypes = ['start', 'mid', 'end']; + var defs = svgCanvas.findDefs(); + $.each(mtypes, function (i, type) { + var marker = getLinked(elem, 'marker-' + type); + + if (!marker) { + return; + } + + var curColor = $(marker).children().attr('fill'); + var curD = $(marker).children().attr('d'); + + if (curColor === color) { + return; + } + + var allMarkers = $(defs).find('marker'); + var newMarker = null; // Different color, check if already made + + allMarkers.each(function () { + var attrs = $(this).children().attr(['fill', 'd']); + + if (attrs.fill === color && attrs.d === curD) { + // Found another marker with this color and this path + newMarker = this; + } + }); + + if (!newMarker) { + // Create a new marker with this color + var lastId = marker.id; + var dir = lastId.includes('_fw') ? 'fw' : 'bk'; + newMarker = addMarker(dir, type, arrowprefix + dir + allMarkers.length); + $(newMarker).children().attr('fill', color); + } + + $(elem).attr('marker-' + type, 'url(#' + newMarker.id + ')'); // Check if last marker can be removed + + var remove = true; + $(S.svgcontent).find('line, polyline, path, polygon').each(function () { + var element = this; + $.each(mtypes, function (j, mtype) { + if ($(element).attr('marker-' + mtype) === 'url(#' + marker.id + ')') { + remove = false; + return remove; + } + + return undefined; + }); + + if (!remove) { + return false; + } + + return undefined; + }); // Not found, so can safely remove + + if (remove) { + $(marker).remove(); + } + }); + }; + + setArrow = function _setArrow() { + resetMarker(); + var type = this.value; + + if (type === 'none') { + return; + } // Set marker on element + + + var dir = 'fw'; + + if (type === 'mid_bk') { + type = 'mid'; + dir = 'bk'; + } else if (type === 'both') { + addMarker('bk', type); + svgCanvas.changeSelectedAttribute('marker-start', 'url(#' + pathdata.bk.id + ')'); + type = 'end'; + dir = 'fw'; + } else if (type === 'start') { + dir = 'bk'; + } + + addMarker(dir, type); + svgCanvas.changeSelectedAttribute('marker-' + type, 'url(#' + pathdata[dir].id + ')'); + svgCanvas.call('changed', selElems); + }; + + addMarker = function _addMarker(dir, type, id) { + // TODO: Make marker (or use?) per arrow type, since refX can be different + id = id || arrowprefix + dir; + var data = pathdata[dir]; + + if (type === 'mid') { + data.refx = 5; + } + + var marker = svgCanvas.getElem(id); + + if (!marker) { + marker = addElem({ + element: 'marker', + attr: { + viewBox: '0 0 10 10', + id: id, + refY: 5, + markerUnits: 'strokeWidth', + markerWidth: 5, + markerHeight: 5, + orient: 'auto', + style: 'pointer-events:none' // Currently needed for Opera + + } + }); + var arrow = addElem({ + element: 'path', + attr: { + d: data.d, + fill: '#000000' + } + }); + marker.append(arrow); + svgCanvas.findDefs().append(marker); + } + + marker.setAttribute('refX', data.refx); + return marker; + }; + + resetMarker = function _resetMarker() { + var el = selElems[0]; + el.removeAttribute('marker-start'); + el.removeAttribute('marker-mid'); + el.removeAttribute('marker-end'); + }; + + showPanel = function _showPanel(on) { + $('#arrow_panel').toggle(on); + + if (on) { + var el = selElems[0]; + var end = el.getAttribute('marker-end'); + var start = el.getAttribute('marker-start'); + var mid = el.getAttribute('marker-mid'); + var val; + + if (end && start) { + val = 'both'; + } else if (end) { + val = 'end'; + } else if (start) { + val = 'start'; + } else if (mid) { + val = 'mid'; + + if (mid.includes('bk')) { + val = 'mid_bk'; + } + } + + if (!start && !mid && !end) { + val = 'none'; + } + + $('#arrow_list').val(val); + } + }; + + getLinked = function _getLinked(elem, attr) { + var str = elem.getAttribute(attr); + + if (!str) { + return null; + } + + var m = str.match(/\(#(.*)\)/); // const m = str.match(/\(#(?.+)\)/); + // if (!m || !m.groups.id) { + + if (!m || m.length !== 2) { + return null; + } + + return svgCanvas.getElem(m[1]); // return svgCanvas.getElem(m.groups.id); + }; + + unsetArrowNonce = function _unsetArrowNonce(win) { + randomizeIds = false; + arrowprefix = prefix; + pathdata.fw.id = arrowprefix + 'fw'; + pathdata.bk.id = arrowprefix + 'bk'; + }; + + setArrowNonce = function _setArrowNonce(win, n) { + randomizeIds = true; + arrowprefix = prefix + n + '_'; + pathdata.fw.id = arrowprefix + 'fw'; + pathdata.bk.id = arrowprefix + 'bk'; + }; + + _context2.next = 10; + return S.importLocale(); + + case 10: + strings = _context2.sent; + svgEditor = _this; + svgCanvas = svgEditor.canvas; + // {svgcontent} = S, + addElem = svgCanvas.addSVGElementFromJson, nonce = S.nonce, $ = S.$, prefix = 'se_arrow_'; + randomizeIds = S.randomize_ids; + /** + * @param {Window} win + * @param {!(string|Integer)} n + * @returns {void} + */ + + svgCanvas.bind('setnonce', setArrowNonce); + svgCanvas.bind('unsetnonce', unsetArrowNonce); + + if (randomizeIds) { + arrowprefix = prefix + nonce + '_'; + } else { + arrowprefix = prefix; + } + + pathdata = { + fw: { + d: 'm0,0l10,5l-10,5l5,-5l-5,-5z', + refx: 8, + id: arrowprefix + 'fw' + }, + bk: { + d: 'm10,0l-10,5l10,5l-5,-5l5,-5z', + refx: 2, + id: arrowprefix + 'bk' + } + }; + /** + * Gets linked element. + * @param {Element} elem + * @param {string} attr + * @returns {Element} + */ + + contextTools = [{ + type: 'select', + panel: 'arrow_panel', + id: 'arrow_list', + defval: 'none', + events: { + change: setArrow + } + }]; + return _context2.abrupt("return", { + name: strings.name, + context_tools: strings.contextTools.map(function (contextTool, i) { + return Object.assign(contextTools[i], contextTool); + }), + callback: function callback() { + $('#arrow_panel').hide(); // Set ID so it can be translated in locale file + + $('#arrow_list option')[0].id = 'connector_no_arrow'; + }, + addLangData: function addLangData(_ref) { + return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { + var lang, importLocale, _yield$importLocale, langList; + + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + lang = _ref.lang, importLocale = _ref.importLocale; + _context.next = 3; + return importLocale(); + + case 3: + _yield$importLocale = _context.sent; + langList = _yield$importLocale.langList; + return _context.abrupt("return", { + data: langList + }); + + case 6: + case "end": + return _context.stop(); + } + } + }, _callee); + }))(); + }, + selectedChanged: function selectedChanged(opts) { + // Use this to update the current selected elements + selElems = opts.elems; + var markerElems = ['line', 'path', 'polyline', 'polygon']; + var i = selElems.length; + + while (i--) { + var elem = selElems[i]; + + if (elem && markerElems.includes(elem.tagName)) { + if (opts.selectedElement && !opts.multiselected) { + showPanel(true); + } else { + showPanel(false); + } + } else { + showPanel(false); + } + } + }, + elementChanged: function elementChanged(opts) { + var elem = opts.elems[0]; + + if (elem && (elem.getAttribute('marker-start') || elem.getAttribute('marker-mid') || elem.getAttribute('marker-end'))) { + // const start = elem.getAttribute('marker-start'); + // const mid = elem.getAttribute('marker-mid'); + // const end = elem.getAttribute('marker-end'); + // Has marker, so see if it should match color + colorChanged(elem); + } + } + }); + + case 21: + case "end": + return _context2.stop(); + } + } + }, _callee2); + }))(); + } + }); + + } + }; +}); diff --git a/dist/editor/system/extensions/ext-closepath.js b/dist/editor/system/extensions/ext-closepath.js new file mode 100644 index 00000000..1b1a6212 --- /dev/null +++ b/dist/editor/system/extensions/ext-closepath.js @@ -0,0 +1,4096 @@ +System.register([], function (exports) { + 'use strict'; + return { + execute: function () { + + function _typeof(obj) { + "@babel/helpers - typeof"; + + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function (obj) { + return typeof obj; + }; + } else { + _typeof = function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); + } + + var REACT_ELEMENT_TYPE; + + function _jsx(type, props, key, children) { + if (!REACT_ELEMENT_TYPE) { + REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol["for"] && Symbol["for"]("react.element") || 0xeac7; + } + + var defaultProps = type && type.defaultProps; + var childrenLength = arguments.length - 3; + + if (!props && childrenLength !== 0) { + props = { + children: void 0 + }; + } + + if (childrenLength === 1) { + props.children = children; + } else if (childrenLength > 1) { + var childArray = new Array(childrenLength); + + for (var i = 0; i < childrenLength; i++) { + childArray[i] = arguments[i + 3]; + } + + props.children = childArray; + } + + if (props && defaultProps) { + for (var propName in defaultProps) { + if (props[propName] === void 0) { + props[propName] = defaultProps[propName]; + } + } + } else if (!props) { + props = defaultProps || {}; + } + + return { + $$typeof: REACT_ELEMENT_TYPE, + type: type, + key: key === undefined ? null : '' + key, + ref: null, + props: props, + _owner: null + }; + } + + function _asyncIterator(iterable) { + var method; + + if (typeof Symbol !== "undefined") { + if (Symbol.asyncIterator) { + method = iterable[Symbol.asyncIterator]; + if (method != null) return method.call(iterable); + } + + if (Symbol.iterator) { + method = iterable[Symbol.iterator]; + if (method != null) return method.call(iterable); + } + } + + throw new TypeError("Object is not async iterable"); + } + + function _AwaitValue(value) { + this.wrapped = value; + } + + function _AsyncGenerator(gen) { + var front, back; + + function send(key, arg) { + return new Promise(function (resolve, reject) { + var request = { + key: key, + arg: arg, + resolve: resolve, + reject: reject, + next: null + }; + + if (back) { + back = back.next = request; + } else { + front = back = request; + resume(key, arg); + } + }); + } + + function resume(key, arg) { + try { + var result = gen[key](arg); + var value = result.value; + var wrappedAwait = value instanceof _AwaitValue; + Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { + if (wrappedAwait) { + resume(key === "return" ? "return" : "next", arg); + return; + } + + settle(result.done ? "return" : "normal", arg); + }, function (err) { + resume("throw", err); + }); + } catch (err) { + settle("throw", err); + } + } + + function settle(type, value) { + switch (type) { + case "return": + front.resolve({ + value: value, + done: true + }); + break; + + case "throw": + front.reject(value); + break; + + default: + front.resolve({ + value: value, + done: false + }); + break; + } + + front = front.next; + + if (front) { + resume(front.key, front.arg); + } else { + back = null; + } + } + + this._invoke = send; + + if (typeof gen.return !== "function") { + this.return = undefined; + } + } + + if (typeof Symbol === "function" && Symbol.asyncIterator) { + _AsyncGenerator.prototype[Symbol.asyncIterator] = function () { + return this; + }; + } + + _AsyncGenerator.prototype.next = function (arg) { + return this._invoke("next", arg); + }; + + _AsyncGenerator.prototype.throw = function (arg) { + return this._invoke("throw", arg); + }; + + _AsyncGenerator.prototype.return = function (arg) { + return this._invoke("return", arg); + }; + + function _wrapAsyncGenerator(fn) { + return function () { + return new _AsyncGenerator(fn.apply(this, arguments)); + }; + } + + function _awaitAsyncGenerator(value) { + return new _AwaitValue(value); + } + + function _asyncGeneratorDelegate(inner, awaitWrap) { + var iter = {}, + waiting = false; + + function pump(key, value) { + waiting = true; + value = new Promise(function (resolve) { + resolve(inner[key](value)); + }); + return { + done: false, + value: awaitWrap(value) + }; + } + + ; + + if (typeof Symbol === "function" && Symbol.iterator) { + iter[Symbol.iterator] = function () { + return this; + }; + } + + iter.next = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("next", value); + }; + + if (typeof inner.throw === "function") { + iter.throw = function (value) { + if (waiting) { + waiting = false; + throw value; + } + + return pump("throw", value); + }; + } + + if (typeof inner.return === "function") { + iter.return = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("return", value); + }; + } + + return iter; + } + + function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { + try { + var info = gen[key](arg); + var value = info.value; + } catch (error) { + reject(error); + return; + } + + if (info.done) { + resolve(value); + } else { + Promise.resolve(value).then(_next, _throw); + } + } + + function _asyncToGenerator(fn) { + return function () { + var self = this, + args = arguments; + return new Promise(function (resolve, reject) { + var gen = fn.apply(self, args); + + function _next(value) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); + } + + function _throw(err) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); + } + + _next(undefined); + }); + }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; + } + + function _defineEnumerableProperties(obj, descs) { + for (var key in descs) { + var desc = descs[key]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, key, desc); + } + + if (Object.getOwnPropertySymbols) { + var objectSymbols = Object.getOwnPropertySymbols(descs); + + for (var i = 0; i < objectSymbols.length; i++) { + var sym = objectSymbols[i]; + var desc = descs[sym]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, sym, desc); + } + } + + return obj; + } + + function _defaults(obj, defaults) { + var keys = Object.getOwnPropertyNames(defaults); + + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var value = Object.getOwnPropertyDescriptor(defaults, key); + + if (value && value.configurable && obj[key] === undefined) { + Object.defineProperty(obj, key, value); + } + } + + return obj; + } + + function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; + } + + function _extends() { + _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + + return _extends.apply(this, arguments); + } + + function _objectSpread(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? Object(arguments[i]) : {}; + var ownKeys = Object.keys(source); + + if (typeof Object.getOwnPropertySymbols === 'function') { + ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { + return Object.getOwnPropertyDescriptor(source, sym).enumerable; + })); + } + + ownKeys.forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } + + return target; + } + + function ownKeys(object, enumerableOnly) { + var keys = Object.keys(object); + + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(object); + if (enumerableOnly) symbols = symbols.filter(function (sym) { + return Object.getOwnPropertyDescriptor(object, sym).enumerable; + }); + keys.push.apply(keys, symbols); + } + + return keys; + } + + function _objectSpread2(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? arguments[i] : {}; + + if (i % 2) { + ownKeys(Object(source), true).forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } else if (Object.getOwnPropertyDescriptors) { + Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); + } else { + ownKeys(Object(source)).forEach(function (key) { + Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); + }); + } + } + + return target; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function"); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + writable: true, + configurable: true + } + }); + if (superClass) _setPrototypeOf(subClass, superClass); + } + + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + subClass.__proto__ = superClass; + } + + function _getPrototypeOf(o) { + _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { + return o.__proto__ || Object.getPrototypeOf(o); + }; + return _getPrototypeOf(o); + } + + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + + return _setPrototypeOf(o, p); + } + + function _isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + + try { + Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); + return true; + } catch (e) { + return false; + } + } + + function _construct(Parent, args, Class) { + if (_isNativeReflectConstruct()) { + _construct = Reflect.construct; + } else { + _construct = function _construct(Parent, args, Class) { + var a = [null]; + a.push.apply(a, args); + var Constructor = Function.bind.apply(Parent, a); + var instance = new Constructor(); + if (Class) _setPrototypeOf(instance, Class.prototype); + return instance; + }; + } + + return _construct.apply(null, arguments); + } + + function _isNativeFunction(fn) { + return Function.toString.call(fn).indexOf("[native code]") !== -1; + } + + function _wrapNativeSuper(Class) { + var _cache = typeof Map === "function" ? new Map() : undefined; + + _wrapNativeSuper = function _wrapNativeSuper(Class) { + if (Class === null || !_isNativeFunction(Class)) return Class; + + if (typeof Class !== "function") { + throw new TypeError("Super expression must either be null or a function"); + } + + if (typeof _cache !== "undefined") { + if (_cache.has(Class)) return _cache.get(Class); + + _cache.set(Class, Wrapper); + } + + function Wrapper() { + return _construct(Class, arguments, _getPrototypeOf(this).constructor); + } + + Wrapper.prototype = Object.create(Class.prototype, { + constructor: { + value: Wrapper, + enumerable: false, + writable: true, + configurable: true + } + }); + return _setPrototypeOf(Wrapper, Class); + }; + + return _wrapNativeSuper(Class); + } + + function _instanceof(left, right) { + if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { + return !!right[Symbol.hasInstance](left); + } else { + return left instanceof right; + } + } + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + + function _getRequireWildcardCache() { + if (typeof WeakMap !== "function") return null; + var cache = new WeakMap(); + + _getRequireWildcardCache = function () { + return cache; + }; + + return cache; + } + + function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } + + if (obj === null || typeof obj !== "object" && typeof obj !== "function") { + return { + default: obj + }; + } + + var cache = _getRequireWildcardCache(); + + if (cache && cache.has(obj)) { + return cache.get(obj); + } + + var newObj = {}; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + + if (desc && (desc.get || desc.set)) { + Object.defineProperty(newObj, key, desc); + } else { + newObj[key] = obj[key]; + } + } + } + + newObj.default = obj; + + if (cache) { + cache.set(obj, newObj); + } + + return newObj; + } + + function _newArrowCheck(innerThis, boundThis) { + if (innerThis !== boundThis) { + throw new TypeError("Cannot instantiate an arrow function"); + } + } + + function _objectDestructuringEmpty(obj) { + if (obj == null) throw new TypeError("Cannot destructure undefined"); + } + + function _objectWithoutPropertiesLoose(source, excluded) { + if (source == null) return {}; + var target = {}; + var sourceKeys = Object.keys(source); + var key, i; + + for (i = 0; i < sourceKeys.length; i++) { + key = sourceKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + target[key] = source[key]; + } + + return target; + } + + function _objectWithoutProperties(source, excluded) { + if (source == null) return {}; + + var target = _objectWithoutPropertiesLoose(source, excluded); + + var key, i; + + if (Object.getOwnPropertySymbols) { + var sourceSymbolKeys = Object.getOwnPropertySymbols(source); + + for (i = 0; i < sourceSymbolKeys.length; i++) { + key = sourceSymbolKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; + target[key] = source[key]; + } + } + + return target; + } + + function _assertThisInitialized(self) { + if (self === void 0) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return self; + } + + function _possibleConstructorReturn(self, call) { + if (call && (typeof call === "object" || typeof call === "function")) { + return call; + } + + return _assertThisInitialized(self); + } + + function _createSuper(Derived) { + var hasNativeReflectConstruct = _isNativeReflectConstruct(); + + return function _createSuperInternal() { + var Super = _getPrototypeOf(Derived), + result; + + if (hasNativeReflectConstruct) { + var NewTarget = _getPrototypeOf(this).constructor; + + result = Reflect.construct(Super, arguments, NewTarget); + } else { + result = Super.apply(this, arguments); + } + + return _possibleConstructorReturn(this, result); + }; + } + + function _superPropBase(object, property) { + while (!Object.prototype.hasOwnProperty.call(object, property)) { + object = _getPrototypeOf(object); + if (object === null) break; + } + + return object; + } + + function _get(target, property, receiver) { + if (typeof Reflect !== "undefined" && Reflect.get) { + _get = Reflect.get; + } else { + _get = function _get(target, property, receiver) { + var base = _superPropBase(target, property); + + if (!base) return; + var desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.get) { + return desc.get.call(receiver); + } + + return desc.value; + }; + } + + return _get(target, property, receiver || target); + } + + function set(target, property, value, receiver) { + if (typeof Reflect !== "undefined" && Reflect.set) { + set = Reflect.set; + } else { + set = function set(target, property, value, receiver) { + var base = _superPropBase(target, property); + + var desc; + + if (base) { + desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.set) { + desc.set.call(receiver, value); + return true; + } else if (!desc.writable) { + return false; + } + } + + desc = Object.getOwnPropertyDescriptor(receiver, property); + + if (desc) { + if (!desc.writable) { + return false; + } + + desc.value = value; + Object.defineProperty(receiver, property, desc); + } else { + _defineProperty(receiver, property, value); + } + + return true; + }; + } + + return set(target, property, value, receiver); + } + + function _set(target, property, value, receiver, isStrict) { + var s = set(target, property, value, receiver || target); + + if (!s && isStrict) { + throw new Error('failed to set property'); + } + + return value; + } + + function _taggedTemplateLiteral(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + return Object.freeze(Object.defineProperties(strings, { + raw: { + value: Object.freeze(raw) + } + })); + } + + function _taggedTemplateLiteralLoose(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + strings.raw = raw; + return strings; + } + + function _readOnlyError(name) { + throw new Error("\"" + name + "\" is read-only"); + } + + function _classNameTDZError(name) { + throw new Error("Class \"" + name + "\" cannot be referenced in computed property keys."); + } + + function _temporalUndefined() {} + + function _tdz(name) { + throw new ReferenceError(name + " is not defined - temporal dead zone"); + } + + function _temporalRef(val, name) { + return val === _temporalUndefined ? _tdz(name) : val; + } + + function _slicedToArray(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); + } + + function _slicedToArrayLoose(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimitLoose(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); + } + + function _toArray(arr) { + return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); + } + + function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); + } + + function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) return _arrayLikeToArray(arr); + } + + function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; + } + + function _maybeArrayLike(next, arr, i) { + if (arr && !Array.isArray(arr) && typeof arr.length === "number") { + var len = arr.length; + return _arrayLikeToArray(arr, i !== void 0 && i < len ? i : len); + } + + return next(arr, i); + } + + function _iterableToArray(iter) { + if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); + } + + function _iterableToArrayLimit(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"] != null) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; + } + + function _iterableToArrayLimitLoose(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + + for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { + _arr.push(_step.value); + + if (i && _arr.length === i) break; + } + + return _arr; + } + + function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if (typeof o === "string") return _arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + if (n === "Object" && o.constructor) n = o.constructor.name; + if (n === "Map" || n === "Set") return Array.from(o); + if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); + } + + function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) len = arr.length; + + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + + return arr2; + } + + function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + function _createForOfIteratorHelper(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + + var F = function () {}; + + return { + s: F, + n: function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }, + e: function (e) { + throw e; + }, + f: F + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + var normalCompletion = true, + didErr = false, + err; + return { + s: function () { + it = o[Symbol.iterator](); + }, + n: function () { + var step = it.next(); + normalCompletion = step.done; + return step; + }, + e: function (e) { + didErr = true; + err = e; + }, + f: function () { + try { + if (!normalCompletion && it.return != null) it.return(); + } finally { + if (didErr) throw err; + } + } + }; + } + + function _createForOfIteratorHelperLoose(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + return function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + it = o[Symbol.iterator](); + return it.next.bind(it); + } + + function _skipFirstGeneratorNext(fn) { + return function () { + var it = fn.apply(this, arguments); + it.next(); + return it; + }; + } + + function _toPrimitive(input, hint) { + if (typeof input !== "object" || input === null) return input; + var prim = input[Symbol.toPrimitive]; + + if (prim !== undefined) { + var res = prim.call(input, hint || "default"); + if (typeof res !== "object") return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + + return (hint === "string" ? String : Number)(input); + } + + function _toPropertyKey(arg) { + var key = _toPrimitive(arg, "string"); + + return typeof key === "symbol" ? key : String(key); + } + + function _initializerWarningHelper(descriptor, context) { + throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.'); + } + + function _initializerDefineProperty(target, property, descriptor, context) { + if (!descriptor) return; + Object.defineProperty(target, property, { + enumerable: descriptor.enumerable, + configurable: descriptor.configurable, + writable: descriptor.writable, + value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 + }); + } + + function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { + var desc = {}; + Object.keys(descriptor).forEach(function (key) { + desc[key] = descriptor[key]; + }); + desc.enumerable = !!desc.enumerable; + desc.configurable = !!desc.configurable; + + if ('value' in desc || desc.initializer) { + desc.writable = true; + } + + desc = decorators.slice().reverse().reduce(function (desc, decorator) { + return decorator(target, property, desc) || desc; + }, desc); + + if (context && desc.initializer !== void 0) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = undefined; + } + + if (desc.initializer === void 0) { + Object.defineProperty(target, property, desc); + desc = null; + } + + return desc; + } + + var id = 0; + + function _classPrivateFieldLooseKey(name) { + return "__private_" + id++ + "_" + name; + } + + function _classPrivateFieldLooseBase(receiver, privateKey) { + if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { + throw new TypeError("attempted to use private field on non-instance"); + } + + return receiver; + } + + function _classPrivateFieldGet(receiver, privateMap) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to get private field on non-instance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; + } + + function _classPrivateFieldSet(receiver, privateMap, value) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to set private field on non-instance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; + } + + function _classPrivateFieldDestructureSet(receiver, privateMap) { + if (!privateMap.has(receiver)) { + throw new TypeError("attempted to set private field on non-instance"); + } + + var descriptor = privateMap.get(receiver); + + if (descriptor.set) { + if (!("__destrObj" in descriptor)) { + descriptor.__destrObj = { + set value(v) { + descriptor.set.call(receiver, v); + } + + }; + } + + return descriptor.__destrObj; + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + return descriptor; + } + } + + function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; + } + + function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; + } + + function _classStaticPrivateMethodGet(receiver, classConstructor, method) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + return method; + } + + function _classStaticPrivateMethodSet() { + throw new TypeError("attempted to set read only static private field"); + } + + function _decorate(decorators, factory, superClass, mixins) { + var api = _getDecoratorsApi(); + + if (mixins) { + for (var i = 0; i < mixins.length; i++) { + api = mixins[i](api); + } + } + + var r = factory(function initialize(O) { + api.initializeInstanceElements(O, decorated.elements); + }, superClass); + var decorated = api.decorateClass(_coalesceClassElements(r.d.map(_createElementDescriptor)), decorators); + api.initializeClassElements(r.F, decorated.elements); + return api.runClassFinishers(r.F, decorated.finishers); + } + + function _getDecoratorsApi() { + _getDecoratorsApi = function () { + return api; + }; + + var api = { + elementsDefinitionOrder: [["method"], ["field"]], + initializeInstanceElements: function (O, elements) { + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + if (element.kind === kind && element.placement === "own") { + this.defineClassElement(O, element); + } + }, this); + }, this); + }, + initializeClassElements: function (F, elements) { + var proto = F.prototype; + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + var placement = element.placement; + + if (element.kind === kind && (placement === "static" || placement === "prototype")) { + var receiver = placement === "static" ? F : proto; + this.defineClassElement(receiver, element); + } + }, this); + }, this); + }, + defineClassElement: function (receiver, element) { + var descriptor = element.descriptor; + + if (element.kind === "field") { + var initializer = element.initializer; + descriptor = { + enumerable: descriptor.enumerable, + writable: descriptor.writable, + configurable: descriptor.configurable, + value: initializer === void 0 ? void 0 : initializer.call(receiver) + }; + } + + Object.defineProperty(receiver, element.key, descriptor); + }, + decorateClass: function (elements, decorators) { + var newElements = []; + var finishers = []; + var placements = { + static: [], + prototype: [], + own: [] + }; + elements.forEach(function (element) { + this.addElementPlacement(element, placements); + }, this); + elements.forEach(function (element) { + if (!_hasDecorators(element)) return newElements.push(element); + var elementFinishersExtras = this.decorateElement(element, placements); + newElements.push(elementFinishersExtras.element); + newElements.push.apply(newElements, elementFinishersExtras.extras); + finishers.push.apply(finishers, elementFinishersExtras.finishers); + }, this); + + if (!decorators) { + return { + elements: newElements, + finishers: finishers + }; + } + + var result = this.decorateConstructor(newElements, decorators); + finishers.push.apply(finishers, result.finishers); + result.finishers = finishers; + return result; + }, + addElementPlacement: function (element, placements, silent) { + var keys = placements[element.placement]; + + if (!silent && keys.indexOf(element.key) !== -1) { + throw new TypeError("Duplicated element (" + element.key + ")"); + } + + keys.push(element.key); + }, + decorateElement: function (element, placements) { + var extras = []; + var finishers = []; + + for (var decorators = element.decorators, i = decorators.length - 1; i >= 0; i--) { + var keys = placements[element.placement]; + keys.splice(keys.indexOf(element.key), 1); + var elementObject = this.fromElementDescriptor(element); + var elementFinisherExtras = this.toElementFinisherExtras((0, decorators[i])(elementObject) || elementObject); + element = elementFinisherExtras.element; + this.addElementPlacement(element, placements); + + if (elementFinisherExtras.finisher) { + finishers.push(elementFinisherExtras.finisher); + } + + var newExtras = elementFinisherExtras.extras; + + if (newExtras) { + for (var j = 0; j < newExtras.length; j++) { + this.addElementPlacement(newExtras[j], placements); + } + + extras.push.apply(extras, newExtras); + } + } + + return { + element: element, + finishers: finishers, + extras: extras + }; + }, + decorateConstructor: function (elements, decorators) { + var finishers = []; + + for (var i = decorators.length - 1; i >= 0; i--) { + var obj = this.fromClassDescriptor(elements); + var elementsAndFinisher = this.toClassDescriptor((0, decorators[i])(obj) || obj); + + if (elementsAndFinisher.finisher !== undefined) { + finishers.push(elementsAndFinisher.finisher); + } + + if (elementsAndFinisher.elements !== undefined) { + elements = elementsAndFinisher.elements; + + for (var j = 0; j < elements.length - 1; j++) { + for (var k = j + 1; k < elements.length; k++) { + if (elements[j].key === elements[k].key && elements[j].placement === elements[k].placement) { + throw new TypeError("Duplicated element (" + elements[j].key + ")"); + } + } + } + } + } + + return { + elements: elements, + finishers: finishers + }; + }, + fromElementDescriptor: function (element) { + var obj = { + kind: element.kind, + key: element.key, + placement: element.placement, + descriptor: element.descriptor + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + if (element.kind === "field") obj.initializer = element.initializer; + return obj; + }, + toElementDescriptors: function (elementObjects) { + if (elementObjects === undefined) return; + return _toArray(elementObjects).map(function (elementObject) { + var element = this.toElementDescriptor(elementObject); + this.disallowProperty(elementObject, "finisher", "An element descriptor"); + this.disallowProperty(elementObject, "extras", "An element descriptor"); + return element; + }, this); + }, + toElementDescriptor: function (elementObject) { + var kind = String(elementObject.kind); + + if (kind !== "method" && kind !== "field") { + throw new TypeError('An element descriptor\'s .kind property must be either "method" or' + ' "field", but a decorator created an element descriptor with' + ' .kind "' + kind + '"'); + } + + var key = _toPropertyKey(elementObject.key); + + var placement = String(elementObject.placement); + + if (placement !== "static" && placement !== "prototype" && placement !== "own") { + throw new TypeError('An element descriptor\'s .placement property must be one of "static",' + ' "prototype" or "own", but a decorator created an element descriptor' + ' with .placement "' + placement + '"'); + } + + var descriptor = elementObject.descriptor; + this.disallowProperty(elementObject, "elements", "An element descriptor"); + var element = { + kind: kind, + key: key, + placement: placement, + descriptor: Object.assign({}, descriptor) + }; + + if (kind !== "field") { + this.disallowProperty(elementObject, "initializer", "A method descriptor"); + } else { + this.disallowProperty(descriptor, "get", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "set", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "value", "The property descriptor of a field descriptor"); + element.initializer = elementObject.initializer; + } + + return element; + }, + toElementFinisherExtras: function (elementObject) { + var element = this.toElementDescriptor(elementObject); + + var finisher = _optionalCallableProperty(elementObject, "finisher"); + + var extras = this.toElementDescriptors(elementObject.extras); + return { + element: element, + finisher: finisher, + extras: extras + }; + }, + fromClassDescriptor: function (elements) { + var obj = { + kind: "class", + elements: elements.map(this.fromElementDescriptor, this) + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + return obj; + }, + toClassDescriptor: function (obj) { + var kind = String(obj.kind); + + if (kind !== "class") { + throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator' + ' created a class descriptor with .kind "' + kind + '"'); + } + + this.disallowProperty(obj, "key", "A class descriptor"); + this.disallowProperty(obj, "placement", "A class descriptor"); + this.disallowProperty(obj, "descriptor", "A class descriptor"); + this.disallowProperty(obj, "initializer", "A class descriptor"); + this.disallowProperty(obj, "extras", "A class descriptor"); + + var finisher = _optionalCallableProperty(obj, "finisher"); + + var elements = this.toElementDescriptors(obj.elements); + return { + elements: elements, + finisher: finisher + }; + }, + runClassFinishers: function (constructor, finishers) { + for (var i = 0; i < finishers.length; i++) { + var newConstructor = (0, finishers[i])(constructor); + + if (newConstructor !== undefined) { + if (typeof newConstructor !== "function") { + throw new TypeError("Finishers must return a constructor."); + } + + constructor = newConstructor; + } + } + + return constructor; + }, + disallowProperty: function (obj, name, objectType) { + if (obj[name] !== undefined) { + throw new TypeError(objectType + " can't have a ." + name + " property."); + } + } + }; + return api; + } + + function _createElementDescriptor(def) { + var key = _toPropertyKey(def.key); + + var descriptor; + + if (def.kind === "method") { + descriptor = { + value: def.value, + writable: true, + configurable: true, + enumerable: false + }; + } else if (def.kind === "get") { + descriptor = { + get: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "set") { + descriptor = { + set: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "field") { + descriptor = { + configurable: true, + writable: true, + enumerable: true + }; + } + + var element = { + kind: def.kind === "field" ? "field" : "method", + key: key, + placement: def.static ? "static" : def.kind === "field" ? "own" : "prototype", + descriptor: descriptor + }; + if (def.decorators) element.decorators = def.decorators; + if (def.kind === "field") element.initializer = def.value; + return element; + } + + function _coalesceGetterSetter(element, other) { + if (element.descriptor.get !== undefined) { + other.descriptor.get = element.descriptor.get; + } else { + other.descriptor.set = element.descriptor.set; + } + } + + function _coalesceClassElements(elements) { + var newElements = []; + + var isSameElement = function (other) { + return other.kind === "method" && other.key === element.key && other.placement === element.placement; + }; + + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + var other; + + if (element.kind === "method" && (other = newElements.find(isSameElement))) { + if (_isDataDescriptor(element.descriptor) || _isDataDescriptor(other.descriptor)) { + if (_hasDecorators(element) || _hasDecorators(other)) { + throw new ReferenceError("Duplicated methods (" + element.key + ") can't be decorated."); + } + + other.descriptor = element.descriptor; + } else { + if (_hasDecorators(element)) { + if (_hasDecorators(other)) { + throw new ReferenceError("Decorators can't be placed on different accessors with for " + "the same property (" + element.key + ")."); + } + + other.decorators = element.decorators; + } + + _coalesceGetterSetter(element, other); + } + } else { + newElements.push(element); + } + } + + return newElements; + } + + function _hasDecorators(element) { + return element.decorators && element.decorators.length; + } + + function _isDataDescriptor(desc) { + return desc !== undefined && !(desc.value === undefined && desc.writable === undefined); + } + + function _optionalCallableProperty(obj, name) { + var value = obj[name]; + + if (value !== undefined && typeof value !== "function") { + throw new TypeError("Expected '" + name + "' to be a function"); + } + + return value; + } + + function _classPrivateMethodGet(receiver, privateSet, fn) { + if (!privateSet.has(receiver)) { + throw new TypeError("attempted to get private field on non-instance"); + } + + return fn; + } + + function _classPrivateMethodSet() { + throw new TypeError("attempted to reassign private method"); + } + + function _wrapRegExp(re, groups) { + _wrapRegExp = function (re, groups) { + return new BabelRegExp(re, undefined, groups); + }; + + var _RegExp = _wrapNativeSuper(RegExp); + + var _super = RegExp.prototype; + + var _groups = new WeakMap(); + + function BabelRegExp(re, flags, groups) { + var _this = _RegExp.call(this, re, flags); + + _groups.set(_this, groups || _groups.get(re)); + + return _this; + } + + _inherits(BabelRegExp, _RegExp); + + BabelRegExp.prototype.exec = function (str) { + var result = _super.exec.call(this, str); + + if (result) result.groups = buildGroups(result, this); + return result; + }; + + BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { + if (typeof substitution === "string") { + var groups = _groups.get(this); + + return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { + return "$" + groups[name]; + })); + } else if (typeof substitution === "function") { + var _this = this; + + return _super[Symbol.replace].call(this, str, function () { + var args = []; + args.push.apply(args, arguments); + + if (typeof args[args.length - 1] !== "object") { + args.push(buildGroups(args, _this)); + } + + return substitution.apply(this, args); + }); + } else { + return _super[Symbol.replace].call(this, str, substitution); + } + }; + + function buildGroups(result, re) { + var g = _groups.get(re); + + return Object.keys(g).reduce(function (groups, name) { + groups[name] = result[g[name]]; + return groups; + }, Object.create(null)); + } + + return _wrapRegExp.apply(this, arguments); + } + + /* eslint-disable import/unambiguous, max-len */ + + /* globals SVGPathSeg, SVGPathSegMovetoRel, SVGPathSegMovetoAbs, + SVGPathSegMovetoRel, SVGPathSegLinetoRel, SVGPathSegLinetoAbs, + SVGPathSegLinetoHorizontalRel, SVGPathSegLinetoHorizontalAbs, + SVGPathSegLinetoVerticalRel, SVGPathSegLinetoVerticalAbs, + SVGPathSegClosePath, SVGPathSegCurvetoCubicRel, + SVGPathSegCurvetoCubicAbs, SVGPathSegCurvetoCubicSmoothRel, + SVGPathSegCurvetoCubicSmoothAbs, SVGPathSegCurvetoQuadraticRel, + SVGPathSegCurvetoQuadraticAbs, SVGPathSegCurvetoQuadraticSmoothRel, + SVGPathSegCurvetoQuadraticSmoothAbs, SVGPathSegArcRel, SVGPathSegArcAbs */ + + /** + * SVGPathSeg API polyfill + * https://github.com/progers/pathseg + * + * This is a drop-in replacement for the `SVGPathSeg` and `SVGPathSegList` APIs + * that were removed from SVG2 ({@link https://lists.w3.org/Archives/Public/www-svg/2015Jun/0044.html}), + * including the latest spec changes which were implemented in Firefox 43 and + * Chrome 46. + */ + + /* eslint-disable no-shadow, class-methods-use-this, jsdoc/require-jsdoc */ + // Linting: We avoid `no-shadow` as ESLint thinks these are still available globals + // Linting: We avoid `class-methods-use-this` as this is a polyfill that must + // follow the conventions + (function () { + if (!('SVGPathSeg' in window)) { + // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathSeg + var _SVGPathSeg = /*#__PURE__*/function () { + function _SVGPathSeg(type, typeAsLetter, owningPathSegList) { + _classCallCheck(this, _SVGPathSeg); + + this.pathSegType = type; + this.pathSegTypeAsLetter = typeAsLetter; + this._owningPathSegList = owningPathSegList; + } // Notify owning PathSegList on any changes so they can be synchronized back to the path element. + + + _createClass(_SVGPathSeg, [{ + key: "_segmentChanged", + value: function _segmentChanged() { + if (this._owningPathSegList) { + this._owningPathSegList.segmentChanged(this); + } + } + }]); + + return _SVGPathSeg; + }(); + + _SVGPathSeg.prototype.classname = 'SVGPathSeg'; + _SVGPathSeg.PATHSEG_UNKNOWN = 0; + _SVGPathSeg.PATHSEG_CLOSEPATH = 1; + _SVGPathSeg.PATHSEG_MOVETO_ABS = 2; + _SVGPathSeg.PATHSEG_MOVETO_REL = 3; + _SVGPathSeg.PATHSEG_LINETO_ABS = 4; + _SVGPathSeg.PATHSEG_LINETO_REL = 5; + _SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS = 6; + _SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL = 7; + _SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS = 8; + _SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL = 9; + _SVGPathSeg.PATHSEG_ARC_ABS = 10; + _SVGPathSeg.PATHSEG_ARC_REL = 11; + _SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS = 12; + _SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL = 13; + _SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS = 14; + _SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL = 15; + _SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS = 16; + _SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL = 17; + _SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS = 18; + _SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = 19; + + var _SVGPathSegClosePath = /*#__PURE__*/function (_SVGPathSeg2) { + _inherits(_SVGPathSegClosePath, _SVGPathSeg2); + + var _super = _createSuper(_SVGPathSegClosePath); + + function _SVGPathSegClosePath(owningPathSegList) { + _classCallCheck(this, _SVGPathSegClosePath); + + return _super.call(this, _SVGPathSeg.PATHSEG_CLOSEPATH, 'z', owningPathSegList); + } + + _createClass(_SVGPathSegClosePath, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegClosePath]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegClosePath(undefined); + } + }]); + + return _SVGPathSegClosePath; + }(_SVGPathSeg); + + var _SVGPathSegMovetoAbs = /*#__PURE__*/function (_SVGPathSeg3) { + _inherits(_SVGPathSegMovetoAbs, _SVGPathSeg3); + + var _super2 = _createSuper(_SVGPathSegMovetoAbs); + + function _SVGPathSegMovetoAbs(owningPathSegList, x, y) { + var _this; + + _classCallCheck(this, _SVGPathSegMovetoAbs); + + _this = _super2.call(this, _SVGPathSeg.PATHSEG_MOVETO_ABS, 'M', owningPathSegList); + _this._x = x; + _this._y = y; + return _this; + } + + _createClass(_SVGPathSegMovetoAbs, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegMovetoAbs]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegMovetoAbs(undefined, this._x, this._y); + } + }]); + + return _SVGPathSegMovetoAbs; + }(_SVGPathSeg); + + Object.defineProperties(_SVGPathSegMovetoAbs.prototype, { + x: { + get: function get() { + return this._x; + }, + set: function set(x) { + this._x = x; + + this._segmentChanged(); + }, + enumerable: true + }, + y: { + get: function get() { + return this._y; + }, + set: function set(y) { + this._y = y; + + this._segmentChanged(); + }, + enumerable: true + } + }); + + var _SVGPathSegMovetoRel = /*#__PURE__*/function (_SVGPathSeg4) { + _inherits(_SVGPathSegMovetoRel, _SVGPathSeg4); + + var _super3 = _createSuper(_SVGPathSegMovetoRel); + + function _SVGPathSegMovetoRel(owningPathSegList, x, y) { + var _this2; + + _classCallCheck(this, _SVGPathSegMovetoRel); + + _this2 = _super3.call(this, _SVGPathSeg.PATHSEG_MOVETO_REL, 'm', owningPathSegList); + _this2._x = x; + _this2._y = y; + return _this2; + } + + _createClass(_SVGPathSegMovetoRel, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegMovetoRel]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegMovetoRel(undefined, this._x, this._y); + } + }]); + + return _SVGPathSegMovetoRel; + }(_SVGPathSeg); + + Object.defineProperties(_SVGPathSegMovetoRel.prototype, { + x: { + get: function get() { + return this._x; + }, + set: function set(x) { + this._x = x; + + this._segmentChanged(); + }, + enumerable: true + }, + y: { + get: function get() { + return this._y; + }, + set: function set(y) { + this._y = y; + + this._segmentChanged(); + }, + enumerable: true + } + }); + + var _SVGPathSegLinetoAbs = /*#__PURE__*/function (_SVGPathSeg5) { + _inherits(_SVGPathSegLinetoAbs, _SVGPathSeg5); + + var _super4 = _createSuper(_SVGPathSegLinetoAbs); + + function _SVGPathSegLinetoAbs(owningPathSegList, x, y) { + var _this3; + + _classCallCheck(this, _SVGPathSegLinetoAbs); + + _this3 = _super4.call(this, _SVGPathSeg.PATHSEG_LINETO_ABS, 'L', owningPathSegList); + _this3._x = x; + _this3._y = y; + return _this3; + } + + _createClass(_SVGPathSegLinetoAbs, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegLinetoAbs]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegLinetoAbs(undefined, this._x, this._y); + } + }]); + + return _SVGPathSegLinetoAbs; + }(_SVGPathSeg); + + Object.defineProperties(_SVGPathSegLinetoAbs.prototype, { + x: { + get: function get() { + return this._x; + }, + set: function set(x) { + this._x = x; + + this._segmentChanged(); + }, + enumerable: true + }, + y: { + get: function get() { + return this._y; + }, + set: function set(y) { + this._y = y; + + this._segmentChanged(); + }, + enumerable: true + } + }); + + var _SVGPathSegLinetoRel = /*#__PURE__*/function (_SVGPathSeg6) { + _inherits(_SVGPathSegLinetoRel, _SVGPathSeg6); + + var _super5 = _createSuper(_SVGPathSegLinetoRel); + + function _SVGPathSegLinetoRel(owningPathSegList, x, y) { + var _this4; + + _classCallCheck(this, _SVGPathSegLinetoRel); + + _this4 = _super5.call(this, _SVGPathSeg.PATHSEG_LINETO_REL, 'l', owningPathSegList); + _this4._x = x; + _this4._y = y; + return _this4; + } + + _createClass(_SVGPathSegLinetoRel, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegLinetoRel]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegLinetoRel(undefined, this._x, this._y); + } + }]); + + return _SVGPathSegLinetoRel; + }(_SVGPathSeg); + + Object.defineProperties(_SVGPathSegLinetoRel.prototype, { + x: { + get: function get() { + return this._x; + }, + set: function set(x) { + this._x = x; + + this._segmentChanged(); + }, + enumerable: true + }, + y: { + get: function get() { + return this._y; + }, + set: function set(y) { + this._y = y; + + this._segmentChanged(); + }, + enumerable: true + } + }); + + var _SVGPathSegCurvetoCubicAbs = /*#__PURE__*/function (_SVGPathSeg7) { + _inherits(_SVGPathSegCurvetoCubicAbs, _SVGPathSeg7); + + var _super6 = _createSuper(_SVGPathSegCurvetoCubicAbs); + + function _SVGPathSegCurvetoCubicAbs(owningPathSegList, x, y, x1, y1, x2, y2) { + var _this5; + + _classCallCheck(this, _SVGPathSegCurvetoCubicAbs); + + _this5 = _super6.call(this, _SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS, 'C', owningPathSegList); + _this5._x = x; + _this5._y = y; + _this5._x1 = x1; + _this5._y1 = y1; + _this5._x2 = x2; + _this5._y2 = y2; + return _this5; + } + + _createClass(_SVGPathSegCurvetoCubicAbs, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegCurvetoCubicAbs]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x1 + ' ' + this._y1 + ' ' + this._x2 + ' ' + this._y2 + ' ' + this._x + ' ' + this._y; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegCurvetoCubicAbs(undefined, this._x, this._y, this._x1, this._y1, this._x2, this._y2); + } + }]); + + return _SVGPathSegCurvetoCubicAbs; + }(_SVGPathSeg); + + Object.defineProperties(_SVGPathSegCurvetoCubicAbs.prototype, { + x: { + get: function get() { + return this._x; + }, + set: function set(x) { + this._x = x; + + this._segmentChanged(); + }, + enumerable: true + }, + y: { + get: function get() { + return this._y; + }, + set: function set(y) { + this._y = y; + + this._segmentChanged(); + }, + enumerable: true + }, + x1: { + get: function get() { + return this._x1; + }, + set: function set(x1) { + this._x1 = x1; + + this._segmentChanged(); + }, + enumerable: true + }, + y1: { + get: function get() { + return this._y1; + }, + set: function set(y1) { + this._y1 = y1; + + this._segmentChanged(); + }, + enumerable: true + }, + x2: { + get: function get() { + return this._x2; + }, + set: function set(x2) { + this._x2 = x2; + + this._segmentChanged(); + }, + enumerable: true + }, + y2: { + get: function get() { + return this._y2; + }, + set: function set(y2) { + this._y2 = y2; + + this._segmentChanged(); + }, + enumerable: true + } + }); + + var _SVGPathSegCurvetoCubicRel = /*#__PURE__*/function (_SVGPathSeg8) { + _inherits(_SVGPathSegCurvetoCubicRel, _SVGPathSeg8); + + var _super7 = _createSuper(_SVGPathSegCurvetoCubicRel); + + function _SVGPathSegCurvetoCubicRel(owningPathSegList, x, y, x1, y1, x2, y2) { + var _this6; + + _classCallCheck(this, _SVGPathSegCurvetoCubicRel); + + _this6 = _super7.call(this, _SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL, 'c', owningPathSegList); + _this6._x = x; + _this6._y = y; + _this6._x1 = x1; + _this6._y1 = y1; + _this6._x2 = x2; + _this6._y2 = y2; + return _this6; + } + + _createClass(_SVGPathSegCurvetoCubicRel, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegCurvetoCubicRel]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x1 + ' ' + this._y1 + ' ' + this._x2 + ' ' + this._y2 + ' ' + this._x + ' ' + this._y; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegCurvetoCubicRel(undefined, this._x, this._y, this._x1, this._y1, this._x2, this._y2); + } + }]); + + return _SVGPathSegCurvetoCubicRel; + }(_SVGPathSeg); + + Object.defineProperties(_SVGPathSegCurvetoCubicRel.prototype, { + x: { + get: function get() { + return this._x; + }, + set: function set(x) { + this._x = x; + + this._segmentChanged(); + }, + enumerable: true + }, + y: { + get: function get() { + return this._y; + }, + set: function set(y) { + this._y = y; + + this._segmentChanged(); + }, + enumerable: true + }, + x1: { + get: function get() { + return this._x1; + }, + set: function set(x1) { + this._x1 = x1; + + this._segmentChanged(); + }, + enumerable: true + }, + y1: { + get: function get() { + return this._y1; + }, + set: function set(y1) { + this._y1 = y1; + + this._segmentChanged(); + }, + enumerable: true + }, + x2: { + get: function get() { + return this._x2; + }, + set: function set(x2) { + this._x2 = x2; + + this._segmentChanged(); + }, + enumerable: true + }, + y2: { + get: function get() { + return this._y2; + }, + set: function set(y2) { + this._y2 = y2; + + this._segmentChanged(); + }, + enumerable: true + } + }); + + var _SVGPathSegCurvetoQuadraticAbs = /*#__PURE__*/function (_SVGPathSeg9) { + _inherits(_SVGPathSegCurvetoQuadraticAbs, _SVGPathSeg9); + + var _super8 = _createSuper(_SVGPathSegCurvetoQuadraticAbs); + + function _SVGPathSegCurvetoQuadraticAbs(owningPathSegList, x, y, x1, y1) { + var _this7; + + _classCallCheck(this, _SVGPathSegCurvetoQuadraticAbs); + + _this7 = _super8.call(this, _SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS, 'Q', owningPathSegList); + _this7._x = x; + _this7._y = y; + _this7._x1 = x1; + _this7._y1 = y1; + return _this7; + } + + _createClass(_SVGPathSegCurvetoQuadraticAbs, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegCurvetoQuadraticAbs]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x1 + ' ' + this._y1 + ' ' + this._x + ' ' + this._y; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegCurvetoQuadraticAbs(undefined, this._x, this._y, this._x1, this._y1); + } + }]); + + return _SVGPathSegCurvetoQuadraticAbs; + }(_SVGPathSeg); + + Object.defineProperties(_SVGPathSegCurvetoQuadraticAbs.prototype, { + x: { + get: function get() { + return this._x; + }, + set: function set(x) { + this._x = x; + + this._segmentChanged(); + }, + enumerable: true + }, + y: { + get: function get() { + return this._y; + }, + set: function set(y) { + this._y = y; + + this._segmentChanged(); + }, + enumerable: true + }, + x1: { + get: function get() { + return this._x1; + }, + set: function set(x1) { + this._x1 = x1; + + this._segmentChanged(); + }, + enumerable: true + }, + y1: { + get: function get() { + return this._y1; + }, + set: function set(y1) { + this._y1 = y1; + + this._segmentChanged(); + }, + enumerable: true + } + }); + + var _SVGPathSegCurvetoQuadraticRel = /*#__PURE__*/function (_SVGPathSeg10) { + _inherits(_SVGPathSegCurvetoQuadraticRel, _SVGPathSeg10); + + var _super9 = _createSuper(_SVGPathSegCurvetoQuadraticRel); + + function _SVGPathSegCurvetoQuadraticRel(owningPathSegList, x, y, x1, y1) { + var _this8; + + _classCallCheck(this, _SVGPathSegCurvetoQuadraticRel); + + _this8 = _super9.call(this, _SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL, 'q', owningPathSegList); + _this8._x = x; + _this8._y = y; + _this8._x1 = x1; + _this8._y1 = y1; + return _this8; + } + + _createClass(_SVGPathSegCurvetoQuadraticRel, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegCurvetoQuadraticRel]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x1 + ' ' + this._y1 + ' ' + this._x + ' ' + this._y; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegCurvetoQuadraticRel(undefined, this._x, this._y, this._x1, this._y1); + } + }]); + + return _SVGPathSegCurvetoQuadraticRel; + }(_SVGPathSeg); + + Object.defineProperties(_SVGPathSegCurvetoQuadraticRel.prototype, { + x: { + get: function get() { + return this._x; + }, + set: function set(x) { + this._x = x; + + this._segmentChanged(); + }, + enumerable: true + }, + y: { + get: function get() { + return this._y; + }, + set: function set(y) { + this._y = y; + + this._segmentChanged(); + }, + enumerable: true + }, + x1: { + get: function get() { + return this._x1; + }, + set: function set(x1) { + this._x1 = x1; + + this._segmentChanged(); + }, + enumerable: true + }, + y1: { + get: function get() { + return this._y1; + }, + set: function set(y1) { + this._y1 = y1; + + this._segmentChanged(); + }, + enumerable: true + } + }); + + var _SVGPathSegArcAbs = /*#__PURE__*/function (_SVGPathSeg11) { + _inherits(_SVGPathSegArcAbs, _SVGPathSeg11); + + var _super10 = _createSuper(_SVGPathSegArcAbs); + + function _SVGPathSegArcAbs(owningPathSegList, x, y, r1, r2, angle, largeArcFlag, sweepFlag) { + var _this9; + + _classCallCheck(this, _SVGPathSegArcAbs); + + _this9 = _super10.call(this, _SVGPathSeg.PATHSEG_ARC_ABS, 'A', owningPathSegList); + _this9._x = x; + _this9._y = y; + _this9._r1 = r1; + _this9._r2 = r2; + _this9._angle = angle; + _this9._largeArcFlag = largeArcFlag; + _this9._sweepFlag = sweepFlag; + return _this9; + } + + _createClass(_SVGPathSegArcAbs, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegArcAbs]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._r1 + ' ' + this._r2 + ' ' + this._angle + ' ' + (this._largeArcFlag ? '1' : '0') + ' ' + (this._sweepFlag ? '1' : '0') + ' ' + this._x + ' ' + this._y; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegArcAbs(undefined, this._x, this._y, this._r1, this._r2, this._angle, this._largeArcFlag, this._sweepFlag); + } + }]); + + return _SVGPathSegArcAbs; + }(_SVGPathSeg); + + Object.defineProperties(_SVGPathSegArcAbs.prototype, { + x: { + get: function get() { + return this._x; + }, + set: function set(x) { + this._x = x; + + this._segmentChanged(); + }, + enumerable: true + }, + y: { + get: function get() { + return this._y; + }, + set: function set(y) { + this._y = y; + + this._segmentChanged(); + }, + enumerable: true + }, + r1: { + get: function get() { + return this._r1; + }, + set: function set(r1) { + this._r1 = r1; + + this._segmentChanged(); + }, + enumerable: true + }, + r2: { + get: function get() { + return this._r2; + }, + set: function set(r2) { + this._r2 = r2; + + this._segmentChanged(); + }, + enumerable: true + }, + angle: { + get: function get() { + return this._angle; + }, + set: function set(angle) { + this._angle = angle; + + this._segmentChanged(); + }, + enumerable: true + }, + largeArcFlag: { + get: function get() { + return this._largeArcFlag; + }, + set: function set(largeArcFlag) { + this._largeArcFlag = largeArcFlag; + + this._segmentChanged(); + }, + enumerable: true + }, + sweepFlag: { + get: function get() { + return this._sweepFlag; + }, + set: function set(sweepFlag) { + this._sweepFlag = sweepFlag; + + this._segmentChanged(); + }, + enumerable: true + } + }); + + var _SVGPathSegArcRel = /*#__PURE__*/function (_SVGPathSeg12) { + _inherits(_SVGPathSegArcRel, _SVGPathSeg12); + + var _super11 = _createSuper(_SVGPathSegArcRel); + + function _SVGPathSegArcRel(owningPathSegList, x, y, r1, r2, angle, largeArcFlag, sweepFlag) { + var _this10; + + _classCallCheck(this, _SVGPathSegArcRel); + + _this10 = _super11.call(this, _SVGPathSeg.PATHSEG_ARC_REL, 'a', owningPathSegList); + _this10._x = x; + _this10._y = y; + _this10._r1 = r1; + _this10._r2 = r2; + _this10._angle = angle; + _this10._largeArcFlag = largeArcFlag; + _this10._sweepFlag = sweepFlag; + return _this10; + } + + _createClass(_SVGPathSegArcRel, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegArcRel]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._r1 + ' ' + this._r2 + ' ' + this._angle + ' ' + (this._largeArcFlag ? '1' : '0') + ' ' + (this._sweepFlag ? '1' : '0') + ' ' + this._x + ' ' + this._y; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegArcRel(undefined, this._x, this._y, this._r1, this._r2, this._angle, this._largeArcFlag, this._sweepFlag); + } + }]); + + return _SVGPathSegArcRel; + }(_SVGPathSeg); + + Object.defineProperties(_SVGPathSegArcRel.prototype, { + x: { + get: function get() { + return this._x; + }, + set: function set(x) { + this._x = x; + + this._segmentChanged(); + }, + enumerable: true + }, + y: { + get: function get() { + return this._y; + }, + set: function set(y) { + this._y = y; + + this._segmentChanged(); + }, + enumerable: true + }, + r1: { + get: function get() { + return this._r1; + }, + set: function set(r1) { + this._r1 = r1; + + this._segmentChanged(); + }, + enumerable: true + }, + r2: { + get: function get() { + return this._r2; + }, + set: function set(r2) { + this._r2 = r2; + + this._segmentChanged(); + }, + enumerable: true + }, + angle: { + get: function get() { + return this._angle; + }, + set: function set(angle) { + this._angle = angle; + + this._segmentChanged(); + }, + enumerable: true + }, + largeArcFlag: { + get: function get() { + return this._largeArcFlag; + }, + set: function set(largeArcFlag) { + this._largeArcFlag = largeArcFlag; + + this._segmentChanged(); + }, + enumerable: true + }, + sweepFlag: { + get: function get() { + return this._sweepFlag; + }, + set: function set(sweepFlag) { + this._sweepFlag = sweepFlag; + + this._segmentChanged(); + }, + enumerable: true + } + }); + + var _SVGPathSegLinetoHorizontalAbs = /*#__PURE__*/function (_SVGPathSeg13) { + _inherits(_SVGPathSegLinetoHorizontalAbs, _SVGPathSeg13); + + var _super12 = _createSuper(_SVGPathSegLinetoHorizontalAbs); + + function _SVGPathSegLinetoHorizontalAbs(owningPathSegList, x) { + var _this11; + + _classCallCheck(this, _SVGPathSegLinetoHorizontalAbs); + + _this11 = _super12.call(this, _SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS, 'H', owningPathSegList); + _this11._x = x; + return _this11; + } + + _createClass(_SVGPathSegLinetoHorizontalAbs, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegLinetoHorizontalAbs]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegLinetoHorizontalAbs(undefined, this._x); + } + }]); + + return _SVGPathSegLinetoHorizontalAbs; + }(_SVGPathSeg); + + Object.defineProperty(_SVGPathSegLinetoHorizontalAbs.prototype, 'x', { + get: function get() { + return this._x; + }, + set: function set(x) { + this._x = x; + + this._segmentChanged(); + }, + enumerable: true + }); + + var _SVGPathSegLinetoHorizontalRel = /*#__PURE__*/function (_SVGPathSeg14) { + _inherits(_SVGPathSegLinetoHorizontalRel, _SVGPathSeg14); + + var _super13 = _createSuper(_SVGPathSegLinetoHorizontalRel); + + function _SVGPathSegLinetoHorizontalRel(owningPathSegList, x) { + var _this12; + + _classCallCheck(this, _SVGPathSegLinetoHorizontalRel); + + _this12 = _super13.call(this, _SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL, 'h', owningPathSegList); + _this12._x = x; + return _this12; + } + + _createClass(_SVGPathSegLinetoHorizontalRel, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegLinetoHorizontalRel]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegLinetoHorizontalRel(undefined, this._x); + } + }]); + + return _SVGPathSegLinetoHorizontalRel; + }(_SVGPathSeg); + + Object.defineProperty(_SVGPathSegLinetoHorizontalRel.prototype, 'x', { + get: function get() { + return this._x; + }, + set: function set(x) { + this._x = x; + + this._segmentChanged(); + }, + enumerable: true + }); + + var _SVGPathSegLinetoVerticalAbs = /*#__PURE__*/function (_SVGPathSeg15) { + _inherits(_SVGPathSegLinetoVerticalAbs, _SVGPathSeg15); + + var _super14 = _createSuper(_SVGPathSegLinetoVerticalAbs); + + function _SVGPathSegLinetoVerticalAbs(owningPathSegList, y) { + var _this13; + + _classCallCheck(this, _SVGPathSegLinetoVerticalAbs); + + _this13 = _super14.call(this, _SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS, 'V', owningPathSegList); + _this13._y = y; + return _this13; + } + + _createClass(_SVGPathSegLinetoVerticalAbs, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegLinetoVerticalAbs]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._y; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegLinetoVerticalAbs(undefined, this._y); + } + }]); + + return _SVGPathSegLinetoVerticalAbs; + }(_SVGPathSeg); + + Object.defineProperty(_SVGPathSegLinetoVerticalAbs.prototype, 'y', { + get: function get() { + return this._y; + }, + set: function set(y) { + this._y = y; + + this._segmentChanged(); + }, + enumerable: true + }); + + var _SVGPathSegLinetoVerticalRel = /*#__PURE__*/function (_SVGPathSeg16) { + _inherits(_SVGPathSegLinetoVerticalRel, _SVGPathSeg16); + + var _super15 = _createSuper(_SVGPathSegLinetoVerticalRel); + + function _SVGPathSegLinetoVerticalRel(owningPathSegList, y) { + var _this14; + + _classCallCheck(this, _SVGPathSegLinetoVerticalRel); + + _this14 = _super15.call(this, _SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL, 'v', owningPathSegList); + _this14._y = y; + return _this14; + } + + _createClass(_SVGPathSegLinetoVerticalRel, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegLinetoVerticalRel]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._y; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegLinetoVerticalRel(undefined, this._y); + } + }]); + + return _SVGPathSegLinetoVerticalRel; + }(_SVGPathSeg); + + Object.defineProperty(_SVGPathSegLinetoVerticalRel.prototype, 'y', { + get: function get() { + return this._y; + }, + set: function set(y) { + this._y = y; + + this._segmentChanged(); + }, + enumerable: true + }); + + var _SVGPathSegCurvetoCubicSmoothAbs = /*#__PURE__*/function (_SVGPathSeg17) { + _inherits(_SVGPathSegCurvetoCubicSmoothAbs, _SVGPathSeg17); + + var _super16 = _createSuper(_SVGPathSegCurvetoCubicSmoothAbs); + + function _SVGPathSegCurvetoCubicSmoothAbs(owningPathSegList, x, y, x2, y2) { + var _this15; + + _classCallCheck(this, _SVGPathSegCurvetoCubicSmoothAbs); + + _this15 = _super16.call(this, _SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS, 'S', owningPathSegList); + _this15._x = x; + _this15._y = y; + _this15._x2 = x2; + _this15._y2 = y2; + return _this15; + } + + _createClass(_SVGPathSegCurvetoCubicSmoothAbs, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegCurvetoCubicSmoothAbs]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x2 + ' ' + this._y2 + ' ' + this._x + ' ' + this._y; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegCurvetoCubicSmoothAbs(undefined, this._x, this._y, this._x2, this._y2); + } + }]); + + return _SVGPathSegCurvetoCubicSmoothAbs; + }(_SVGPathSeg); + + Object.defineProperties(_SVGPathSegCurvetoCubicSmoothAbs.prototype, { + x: { + get: function get() { + return this._x; + }, + set: function set(x) { + this._x = x; + + this._segmentChanged(); + }, + enumerable: true + }, + y: { + get: function get() { + return this._y; + }, + set: function set(y) { + this._y = y; + + this._segmentChanged(); + }, + enumerable: true + }, + x2: { + get: function get() { + return this._x2; + }, + set: function set(x2) { + this._x2 = x2; + + this._segmentChanged(); + }, + enumerable: true + }, + y2: { + get: function get() { + return this._y2; + }, + set: function set(y2) { + this._y2 = y2; + + this._segmentChanged(); + }, + enumerable: true + } + }); + + var _SVGPathSegCurvetoCubicSmoothRel = /*#__PURE__*/function (_SVGPathSeg18) { + _inherits(_SVGPathSegCurvetoCubicSmoothRel, _SVGPathSeg18); + + var _super17 = _createSuper(_SVGPathSegCurvetoCubicSmoothRel); + + function _SVGPathSegCurvetoCubicSmoothRel(owningPathSegList, x, y, x2, y2) { + var _this16; + + _classCallCheck(this, _SVGPathSegCurvetoCubicSmoothRel); + + _this16 = _super17.call(this, _SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL, 's', owningPathSegList); + _this16._x = x; + _this16._y = y; + _this16._x2 = x2; + _this16._y2 = y2; + return _this16; + } + + _createClass(_SVGPathSegCurvetoCubicSmoothRel, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegCurvetoCubicSmoothRel]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x2 + ' ' + this._y2 + ' ' + this._x + ' ' + this._y; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegCurvetoCubicSmoothRel(undefined, this._x, this._y, this._x2, this._y2); + } + }]); + + return _SVGPathSegCurvetoCubicSmoothRel; + }(_SVGPathSeg); + + Object.defineProperties(_SVGPathSegCurvetoCubicSmoothRel.prototype, { + x: { + get: function get() { + return this._x; + }, + set: function set(x) { + this._x = x; + + this._segmentChanged(); + }, + enumerable: true + }, + y: { + get: function get() { + return this._y; + }, + set: function set(y) { + this._y = y; + + this._segmentChanged(); + }, + enumerable: true + }, + x2: { + get: function get() { + return this._x2; + }, + set: function set(x2) { + this._x2 = x2; + + this._segmentChanged(); + }, + enumerable: true + }, + y2: { + get: function get() { + return this._y2; + }, + set: function set(y2) { + this._y2 = y2; + + this._segmentChanged(); + }, + enumerable: true + } + }); + + var _SVGPathSegCurvetoQuadraticSmoothAbs = /*#__PURE__*/function (_SVGPathSeg19) { + _inherits(_SVGPathSegCurvetoQuadraticSmoothAbs, _SVGPathSeg19); + + var _super18 = _createSuper(_SVGPathSegCurvetoQuadraticSmoothAbs); + + function _SVGPathSegCurvetoQuadraticSmoothAbs(owningPathSegList, x, y) { + var _this17; + + _classCallCheck(this, _SVGPathSegCurvetoQuadraticSmoothAbs); + + _this17 = _super18.call(this, _SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS, 'T', owningPathSegList); + _this17._x = x; + _this17._y = y; + return _this17; + } + + _createClass(_SVGPathSegCurvetoQuadraticSmoothAbs, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegCurvetoQuadraticSmoothAbs]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegCurvetoQuadraticSmoothAbs(undefined, this._x, this._y); + } + }]); + + return _SVGPathSegCurvetoQuadraticSmoothAbs; + }(_SVGPathSeg); + + Object.defineProperties(_SVGPathSegCurvetoQuadraticSmoothAbs.prototype, { + x: { + get: function get() { + return this._x; + }, + set: function set(x) { + this._x = x; + + this._segmentChanged(); + }, + enumerable: true + }, + y: { + get: function get() { + return this._y; + }, + set: function set(y) { + this._y = y; + + this._segmentChanged(); + }, + enumerable: true + } + }); + + var _SVGPathSegCurvetoQuadraticSmoothRel = /*#__PURE__*/function (_SVGPathSeg20) { + _inherits(_SVGPathSegCurvetoQuadraticSmoothRel, _SVGPathSeg20); + + var _super19 = _createSuper(_SVGPathSegCurvetoQuadraticSmoothRel); + + function _SVGPathSegCurvetoQuadraticSmoothRel(owningPathSegList, x, y) { + var _this18; + + _classCallCheck(this, _SVGPathSegCurvetoQuadraticSmoothRel); + + _this18 = _super19.call(this, _SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL, 't', owningPathSegList); + _this18._x = x; + _this18._y = y; + return _this18; + } + + _createClass(_SVGPathSegCurvetoQuadraticSmoothRel, [{ + key: "toString", + value: function toString() { + return '[object SVGPathSegCurvetoQuadraticSmoothRel]'; + } + }, { + key: "_asPathString", + value: function _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; + } + }, { + key: "clone", + value: function clone() { + return new _SVGPathSegCurvetoQuadraticSmoothRel(undefined, this._x, this._y); + } + }]); + + return _SVGPathSegCurvetoQuadraticSmoothRel; + }(_SVGPathSeg); + + Object.defineProperties(_SVGPathSegCurvetoQuadraticSmoothRel.prototype, { + x: { + get: function get() { + return this._x; + }, + set: function set(x) { + this._x = x; + + this._segmentChanged(); + }, + enumerable: true + }, + y: { + get: function get() { + return this._y; + }, + set: function set(y) { + this._y = y; + + this._segmentChanged(); + }, + enumerable: true + } + }); // Add createSVGPathSeg* functions to SVGPathElement. + // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathElement. + + SVGPathElement.prototype.createSVGPathSegClosePath = function () { + return new _SVGPathSegClosePath(undefined); + }; + + SVGPathElement.prototype.createSVGPathSegMovetoAbs = function (x, y) { + return new _SVGPathSegMovetoAbs(undefined, x, y); + }; + + SVGPathElement.prototype.createSVGPathSegMovetoRel = function (x, y) { + return new _SVGPathSegMovetoRel(undefined, x, y); + }; + + SVGPathElement.prototype.createSVGPathSegLinetoAbs = function (x, y) { + return new _SVGPathSegLinetoAbs(undefined, x, y); + }; + + SVGPathElement.prototype.createSVGPathSegLinetoRel = function (x, y) { + return new _SVGPathSegLinetoRel(undefined, x, y); + }; + + SVGPathElement.prototype.createSVGPathSegCurvetoCubicAbs = function (x, y, x1, y1, x2, y2) { + return new _SVGPathSegCurvetoCubicAbs(undefined, x, y, x1, y1, x2, y2); + }; + + SVGPathElement.prototype.createSVGPathSegCurvetoCubicRel = function (x, y, x1, y1, x2, y2) { + return new _SVGPathSegCurvetoCubicRel(undefined, x, y, x1, y1, x2, y2); + }; + + SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticAbs = function (x, y, x1, y1) { + return new _SVGPathSegCurvetoQuadraticAbs(undefined, x, y, x1, y1); + }; + + SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticRel = function (x, y, x1, y1) { + return new _SVGPathSegCurvetoQuadraticRel(undefined, x, y, x1, y1); + }; + + SVGPathElement.prototype.createSVGPathSegArcAbs = function (x, y, r1, r2, angle, largeArcFlag, sweepFlag) { + return new _SVGPathSegArcAbs(undefined, x, y, r1, r2, angle, largeArcFlag, sweepFlag); + }; + + SVGPathElement.prototype.createSVGPathSegArcRel = function (x, y, r1, r2, angle, largeArcFlag, sweepFlag) { + return new _SVGPathSegArcRel(undefined, x, y, r1, r2, angle, largeArcFlag, sweepFlag); + }; + + SVGPathElement.prototype.createSVGPathSegLinetoHorizontalAbs = function (x) { + return new _SVGPathSegLinetoHorizontalAbs(undefined, x); + }; + + SVGPathElement.prototype.createSVGPathSegLinetoHorizontalRel = function (x) { + return new _SVGPathSegLinetoHorizontalRel(undefined, x); + }; + + SVGPathElement.prototype.createSVGPathSegLinetoVerticalAbs = function (y) { + return new _SVGPathSegLinetoVerticalAbs(undefined, y); + }; + + SVGPathElement.prototype.createSVGPathSegLinetoVerticalRel = function (y) { + return new _SVGPathSegLinetoVerticalRel(undefined, y); + }; + + SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothAbs = function (x, y, x2, y2) { + return new _SVGPathSegCurvetoCubicSmoothAbs(undefined, x, y, x2, y2); + }; + + SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothRel = function (x, y, x2, y2) { + return new _SVGPathSegCurvetoCubicSmoothRel(undefined, x, y, x2, y2); + }; + + SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothAbs = function (x, y) { + return new _SVGPathSegCurvetoQuadraticSmoothAbs(undefined, x, y); + }; + + SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothRel = function (x, y) { + return new _SVGPathSegCurvetoQuadraticSmoothRel(undefined, x, y); + }; + + if (!('getPathSegAtLength' in SVGPathElement.prototype)) { + // Add getPathSegAtLength to SVGPathElement. + // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-__svg__SVGPathElement__getPathSegAtLength + // This polyfill requires SVGPathElement.getTotalLength to implement the distance-along-a-path algorithm. + SVGPathElement.prototype.getPathSegAtLength = function (distance) { + if (distance === undefined || !isFinite(distance)) { + throw new Error('Invalid arguments.'); + } + + var measurementElement = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + measurementElement.setAttribute('d', this.getAttribute('d')); + var lastPathSegment = measurementElement.pathSegList.numberOfItems - 1; // If the path is empty, return 0. + + if (lastPathSegment <= 0) { + return 0; + } + + do { + measurementElement.pathSegList.removeItem(lastPathSegment); + + if (distance > measurementElement.getTotalLength()) { + break; + } + + lastPathSegment--; + } while (lastPathSegment > 0); + + return lastPathSegment; + }; + } + + window.SVGPathSeg = _SVGPathSeg; + window.SVGPathSegClosePath = _SVGPathSegClosePath; + window.SVGPathSegMovetoAbs = _SVGPathSegMovetoAbs; + window.SVGPathSegMovetoRel = _SVGPathSegMovetoRel; + window.SVGPathSegLinetoAbs = _SVGPathSegLinetoAbs; + window.SVGPathSegLinetoRel = _SVGPathSegLinetoRel; + window.SVGPathSegCurvetoCubicAbs = _SVGPathSegCurvetoCubicAbs; + window.SVGPathSegCurvetoCubicRel = _SVGPathSegCurvetoCubicRel; + window.SVGPathSegCurvetoQuadraticAbs = _SVGPathSegCurvetoQuadraticAbs; + window.SVGPathSegCurvetoQuadraticRel = _SVGPathSegCurvetoQuadraticRel; + window.SVGPathSegArcAbs = _SVGPathSegArcAbs; + window.SVGPathSegArcRel = _SVGPathSegArcRel; + window.SVGPathSegLinetoHorizontalAbs = _SVGPathSegLinetoHorizontalAbs; + window.SVGPathSegLinetoHorizontalRel = _SVGPathSegLinetoHorizontalRel; + window.SVGPathSegLinetoVerticalAbs = _SVGPathSegLinetoVerticalAbs; + window.SVGPathSegLinetoVerticalRel = _SVGPathSegLinetoVerticalRel; + window.SVGPathSegCurvetoCubicSmoothAbs = _SVGPathSegCurvetoCubicSmoothAbs; + window.SVGPathSegCurvetoCubicSmoothRel = _SVGPathSegCurvetoCubicSmoothRel; + window.SVGPathSegCurvetoQuadraticSmoothAbs = _SVGPathSegCurvetoQuadraticSmoothAbs; + window.SVGPathSegCurvetoQuadraticSmoothRel = _SVGPathSegCurvetoQuadraticSmoothRel; + } // Checking for SVGPathSegList in window checks for the case of an implementation without the + // SVGPathSegList API. + // The second check for appendItem is specific to Firefox 59+ which removed only parts of the + // SVGPathSegList API (e.g., appendItem). In this case we need to re-implement the entire API + // so the polyfill data (i.e., _list) is used throughout. + + + if (!('SVGPathSegList' in window) || !('appendItem' in window.SVGPathSegList.prototype)) { + // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathSegList + var SVGPathSegList = /*#__PURE__*/function () { + function SVGPathSegList(pathElement) { + _classCallCheck(this, SVGPathSegList); + + this._pathElement = pathElement; + this._list = this._parsePath(this._pathElement.getAttribute('d')); // Use a MutationObserver to catch changes to the path's "d" attribute. + + this._mutationObserverConfig = { + attributes: true, + attributeFilter: ['d'] + }; + this._pathElementMutationObserver = new MutationObserver(this._updateListFromPathMutations.bind(this)); + + this._pathElementMutationObserver.observe(this._pathElement, this._mutationObserverConfig); + } // Process any pending mutations to the path element and update the list as needed. + // This should be the first call of all public functions and is needed because + // MutationObservers are not synchronous so we can have pending asynchronous mutations. + + + _createClass(SVGPathSegList, [{ + key: "_checkPathSynchronizedToList", + value: function _checkPathSynchronizedToList() { + this._updateListFromPathMutations(this._pathElementMutationObserver.takeRecords()); + } + }, { + key: "_updateListFromPathMutations", + value: function _updateListFromPathMutations(mutationRecords) { + if (!this._pathElement) { + return; + } + + var hasPathMutations = false; + mutationRecords.forEach(function (record) { + if (record.attributeName === 'd') { + hasPathMutations = true; + } + }); + + if (hasPathMutations) { + this._list = this._parsePath(this._pathElement.getAttribute('d')); + } + } // Serialize the list and update the path's 'd' attribute. + + }, { + key: "_writeListToPath", + value: function _writeListToPath() { + this._pathElementMutationObserver.disconnect(); + + this._pathElement.setAttribute('d', SVGPathSegList._pathSegArrayAsString(this._list)); + + this._pathElementMutationObserver.observe(this._pathElement, this._mutationObserverConfig); + } // When a path segment changes the list needs to be synchronized back to the path element. + + }, { + key: "segmentChanged", + value: function segmentChanged(pathSeg) { + this._writeListToPath(); + } + }, { + key: "clear", + value: function clear() { + this._checkPathSynchronizedToList(); + + this._list.forEach(function (pathSeg) { + pathSeg._owningPathSegList = null; + }); + + this._list = []; + + this._writeListToPath(); + } + }, { + key: "initialize", + value: function initialize(newItem) { + this._checkPathSynchronizedToList(); + + this._list = [newItem]; + newItem._owningPathSegList = this; + + this._writeListToPath(); + + return newItem; + } + }, { + key: "_checkValidIndex", + value: function _checkValidIndex(index) { + if (isNaN(index) || index < 0 || index >= this.numberOfItems) { + throw new Error('INDEX_SIZE_ERR'); + } + } + }, { + key: "getItem", + value: function getItem(index) { + this._checkPathSynchronizedToList(); + + this._checkValidIndex(index); + + return this._list[index]; + } + }, { + key: "insertItemBefore", + value: function insertItemBefore(newItem, index) { + this._checkPathSynchronizedToList(); // Spec: If the index is greater than or equal to numberOfItems, then the new item is appended to the end of the list. + + + if (index > this.numberOfItems) { + index = this.numberOfItems; + } + + if (newItem._owningPathSegList) { + // SVG2 spec says to make a copy. + newItem = newItem.clone(); + } + + this._list.splice(index, 0, newItem); + + newItem._owningPathSegList = this; + + this._writeListToPath(); + + return newItem; + } + }, { + key: "replaceItem", + value: function replaceItem(newItem, index) { + this._checkPathSynchronizedToList(); + + if (newItem._owningPathSegList) { + // SVG2 spec says to make a copy. + newItem = newItem.clone(); + } + + this._checkValidIndex(index); + + this._list[index] = newItem; + newItem._owningPathSegList = this; + + this._writeListToPath(); + + return newItem; + } + }, { + key: "removeItem", + value: function removeItem(index) { + this._checkPathSynchronizedToList(); + + this._checkValidIndex(index); + + var item = this._list[index]; + + this._list.splice(index, 1); + + this._writeListToPath(); + + return item; + } + }, { + key: "appendItem", + value: function appendItem(newItem) { + this._checkPathSynchronizedToList(); + + if (newItem._owningPathSegList) { + // SVG2 spec says to make a copy. + newItem = newItem.clone(); + } + + this._list.push(newItem); + + newItem._owningPathSegList = this; // TODO: Optimize this to just append to the existing attribute. + + this._writeListToPath(); + + return newItem; + } // This closely follows SVGPathParser::parsePath from Source/core/svg/SVGPathParser.cpp. + + }, { + key: "_parsePath", + value: function _parsePath(string) { + if (!string || !string.length) { + return []; + } + + var owningPathSegList = this; + + var Builder = /*#__PURE__*/function () { + function Builder() { + _classCallCheck(this, Builder); + + this.pathSegList = []; + } + + _createClass(Builder, [{ + key: "appendSegment", + value: function appendSegment(pathSeg) { + this.pathSegList.push(pathSeg); + } + }]); + + return Builder; + }(); + + var Source = /*#__PURE__*/function () { + function Source(string) { + _classCallCheck(this, Source); + + this._string = string; + this._currentIndex = 0; + this._endIndex = this._string.length; + this._previousCommand = SVGPathSeg.PATHSEG_UNKNOWN; + + this._skipOptionalSpaces(); + } + + _createClass(Source, [{ + key: "_isCurrentSpace", + value: function _isCurrentSpace() { + var character = this._string[this._currentIndex]; + return character <= ' ' && (character === ' ' || character === '\n' || character === '\t' || character === '\r' || character === '\f'); + } + }, { + key: "_skipOptionalSpaces", + value: function _skipOptionalSpaces() { + while (this._currentIndex < this._endIndex && this._isCurrentSpace()) { + this._currentIndex++; + } + + return this._currentIndex < this._endIndex; + } + }, { + key: "_skipOptionalSpacesOrDelimiter", + value: function _skipOptionalSpacesOrDelimiter() { + if (this._currentIndex < this._endIndex && !this._isCurrentSpace() && this._string.charAt(this._currentIndex) !== ',') { + return false; + } + + if (this._skipOptionalSpaces()) { + if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) === ',') { + this._currentIndex++; + + this._skipOptionalSpaces(); + } + } + + return this._currentIndex < this._endIndex; + } + }, { + key: "hasMoreData", + value: function hasMoreData() { + return this._currentIndex < this._endIndex; + } + }, { + key: "peekSegmentType", + value: function peekSegmentType() { + var lookahead = this._string[this._currentIndex]; + return this._pathSegTypeFromChar(lookahead); + } + }, { + key: "_pathSegTypeFromChar", + value: function _pathSegTypeFromChar(lookahead) { + switch (lookahead) { + case 'Z': + case 'z': + return SVGPathSeg.PATHSEG_CLOSEPATH; + + case 'M': + return SVGPathSeg.PATHSEG_MOVETO_ABS; + + case 'm': + return SVGPathSeg.PATHSEG_MOVETO_REL; + + case 'L': + return SVGPathSeg.PATHSEG_LINETO_ABS; + + case 'l': + return SVGPathSeg.PATHSEG_LINETO_REL; + + case 'C': + return SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS; + + case 'c': + return SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL; + + case 'Q': + return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS; + + case 'q': + return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL; + + case 'A': + return SVGPathSeg.PATHSEG_ARC_ABS; + + case 'a': + return SVGPathSeg.PATHSEG_ARC_REL; + + case 'H': + return SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS; + + case 'h': + return SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL; + + case 'V': + return SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS; + + case 'v': + return SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL; + + case 'S': + return SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS; + + case 's': + return SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL; + + case 'T': + return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS; + + case 't': + return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL; + + default: + return SVGPathSeg.PATHSEG_UNKNOWN; + } + } + }, { + key: "_nextCommandHelper", + value: function _nextCommandHelper(lookahead, previousCommand) { + // Check for remaining coordinates in the current command. + if ((lookahead === '+' || lookahead === '-' || lookahead === '.' || lookahead >= '0' && lookahead <= '9') && previousCommand !== SVGPathSeg.PATHSEG_CLOSEPATH) { + if (previousCommand === SVGPathSeg.PATHSEG_MOVETO_ABS) { + return SVGPathSeg.PATHSEG_LINETO_ABS; + } + + if (previousCommand === SVGPathSeg.PATHSEG_MOVETO_REL) { + return SVGPathSeg.PATHSEG_LINETO_REL; + } + + return previousCommand; + } + + return SVGPathSeg.PATHSEG_UNKNOWN; + } + }, { + key: "initialCommandIsMoveTo", + value: function initialCommandIsMoveTo() { + // If the path is empty it is still valid, so return true. + if (!this.hasMoreData()) { + return true; + } + + var command = this.peekSegmentType(); // Path must start with moveTo. + + return command === SVGPathSeg.PATHSEG_MOVETO_ABS || command === SVGPathSeg.PATHSEG_MOVETO_REL; + } // Parse a number from an SVG path. This very closely follows genericParseNumber(...) from Source/core/svg/SVGParserUtilities.cpp. + // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-PathDataBNF + + }, { + key: "_parseNumber", + value: function _parseNumber() { + var exponent = 0; + var integer = 0; + var frac = 1; + var decimal = 0; + var sign = 1; + var expsign = 1; + var startIndex = this._currentIndex; + + this._skipOptionalSpaces(); // Read the sign. + + + if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) === '+') { + this._currentIndex++; + } else if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) === '-') { + this._currentIndex++; + sign = -1; + } + + if (this._currentIndex === this._endIndex || (this._string.charAt(this._currentIndex) < '0' || this._string.charAt(this._currentIndex) > '9') && this._string.charAt(this._currentIndex) !== '.') { + // The first character of a number must be one of [0-9+-.]. + return undefined; + } // Read the integer part, build right-to-left. + + + var startIntPartIndex = this._currentIndex; + + while (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) >= '0' && this._string.charAt(this._currentIndex) <= '9') { + this._currentIndex++; // Advance to first non-digit. + } + + if (this._currentIndex !== startIntPartIndex) { + var scanIntPartIndex = this._currentIndex - 1; + var multiplier = 1; + + while (scanIntPartIndex >= startIntPartIndex) { + integer += multiplier * (this._string.charAt(scanIntPartIndex--) - '0'); + multiplier *= 10; + } + } // Read the decimals. + + + if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) === '.') { + this._currentIndex++; // There must be a least one digit following the . + + if (this._currentIndex >= this._endIndex || this._string.charAt(this._currentIndex) < '0' || this._string.charAt(this._currentIndex) > '9') { + return undefined; + } + + while (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) >= '0' && this._string.charAt(this._currentIndex) <= '9') { + frac *= 10; + decimal += (this._string.charAt(this._currentIndex) - '0') / frac; + this._currentIndex += 1; + } + } // Read the exponent part. + + + if (this._currentIndex !== startIndex && this._currentIndex + 1 < this._endIndex && (this._string.charAt(this._currentIndex) === 'e' || this._string.charAt(this._currentIndex) === 'E') && this._string.charAt(this._currentIndex + 1) !== 'x' && this._string.charAt(this._currentIndex + 1) !== 'm') { + this._currentIndex++; // Read the sign of the exponent. + + if (this._string.charAt(this._currentIndex) === '+') { + this._currentIndex++; + } else if (this._string.charAt(this._currentIndex) === '-') { + this._currentIndex++; + expsign = -1; + } // There must be an exponent. + + + if (this._currentIndex >= this._endIndex || this._string.charAt(this._currentIndex) < '0' || this._string.charAt(this._currentIndex) > '9') { + return undefined; + } + + while (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) >= '0' && this._string.charAt(this._currentIndex) <= '9') { + exponent *= 10; + exponent += this._string.charAt(this._currentIndex) - '0'; + this._currentIndex++; + } + } + + var number = integer + decimal; + number *= sign; + + if (exponent) { + number *= Math.pow(10, expsign * exponent); + } + + if (startIndex === this._currentIndex) { + return undefined; + } + + this._skipOptionalSpacesOrDelimiter(); + + return number; + } + }, { + key: "_parseArcFlag", + value: function _parseArcFlag() { + if (this._currentIndex >= this._endIndex) { + return undefined; + } + + var flag = false; + + var flagChar = this._string.charAt(this._currentIndex++); + + if (flagChar === '0') { + flag = false; + } else if (flagChar === '1') { + flag = true; + } else { + return undefined; + } + + this._skipOptionalSpacesOrDelimiter(); + + return flag; + } + }, { + key: "parseSegment", + value: function parseSegment() { + var lookahead = this._string[this._currentIndex]; + + var command = this._pathSegTypeFromChar(lookahead); + + if (command === SVGPathSeg.PATHSEG_UNKNOWN) { + // Possibly an implicit command. Not allowed if this is the first command. + if (this._previousCommand === SVGPathSeg.PATHSEG_UNKNOWN) { + return null; + } + + command = this._nextCommandHelper(lookahead, this._previousCommand); + + if (command === SVGPathSeg.PATHSEG_UNKNOWN) { + return null; + } + } else { + this._currentIndex++; + } + + this._previousCommand = command; + + switch (command) { + case SVGPathSeg.PATHSEG_MOVETO_REL: + return new SVGPathSegMovetoRel(owningPathSegList, this._parseNumber(), this._parseNumber()); + + case SVGPathSeg.PATHSEG_MOVETO_ABS: + return new SVGPathSegMovetoAbs(owningPathSegList, this._parseNumber(), this._parseNumber()); + + case SVGPathSeg.PATHSEG_LINETO_REL: + return new SVGPathSegLinetoRel(owningPathSegList, this._parseNumber(), this._parseNumber()); + + case SVGPathSeg.PATHSEG_LINETO_ABS: + return new SVGPathSegLinetoAbs(owningPathSegList, this._parseNumber(), this._parseNumber()); + + case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL: + return new SVGPathSegLinetoHorizontalRel(owningPathSegList, this._parseNumber()); + + case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS: + return new SVGPathSegLinetoHorizontalAbs(owningPathSegList, this._parseNumber()); + + case SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL: + return new SVGPathSegLinetoVerticalRel(owningPathSegList, this._parseNumber()); + + case SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS: + return new SVGPathSegLinetoVerticalAbs(owningPathSegList, this._parseNumber()); + + case SVGPathSeg.PATHSEG_CLOSEPATH: + this._skipOptionalSpaces(); + + return new SVGPathSegClosePath(owningPathSegList); + + case SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL: + { + var points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + x2: this._parseNumber(), + y2: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new SVGPathSegCurvetoCubicRel(owningPathSegList, points.x, points.y, points.x1, points.y1, points.x2, points.y2); + } + + case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS: + { + var _points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + x2: this._parseNumber(), + y2: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new SVGPathSegCurvetoCubicAbs(owningPathSegList, _points.x, _points.y, _points.x1, _points.y1, _points.x2, _points.y2); + } + + case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL: + { + var _points2 = { + x2: this._parseNumber(), + y2: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new SVGPathSegCurvetoCubicSmoothRel(owningPathSegList, _points2.x, _points2.y, _points2.x2, _points2.y2); + } + + case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: + { + var _points3 = { + x2: this._parseNumber(), + y2: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new SVGPathSegCurvetoCubicSmoothAbs(owningPathSegList, _points3.x, _points3.y, _points3.x2, _points3.y2); + } + + case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL: + { + var _points4 = { + x1: this._parseNumber(), + y1: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new SVGPathSegCurvetoQuadraticRel(owningPathSegList, _points4.x, _points4.y, _points4.x1, _points4.y1); + } + + case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS: + { + var _points5 = { + x1: this._parseNumber(), + y1: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new SVGPathSegCurvetoQuadraticAbs(owningPathSegList, _points5.x, _points5.y, _points5.x1, _points5.y1); + } + + case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: + return new SVGPathSegCurvetoQuadraticSmoothRel(owningPathSegList, this._parseNumber(), this._parseNumber()); + + case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: + return new SVGPathSegCurvetoQuadraticSmoothAbs(owningPathSegList, this._parseNumber(), this._parseNumber()); + + case SVGPathSeg.PATHSEG_ARC_REL: + { + var _points6 = { + x1: this._parseNumber(), + y1: this._parseNumber(), + arcAngle: this._parseNumber(), + arcLarge: this._parseArcFlag(), + arcSweep: this._parseArcFlag(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new SVGPathSegArcRel(owningPathSegList, _points6.x, _points6.y, _points6.x1, _points6.y1, _points6.arcAngle, _points6.arcLarge, _points6.arcSweep); + } + + case SVGPathSeg.PATHSEG_ARC_ABS: + { + var _points7 = { + x1: this._parseNumber(), + y1: this._parseNumber(), + arcAngle: this._parseNumber(), + arcLarge: this._parseArcFlag(), + arcSweep: this._parseArcFlag(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new SVGPathSegArcAbs(owningPathSegList, _points7.x, _points7.y, _points7.x1, _points7.y1, _points7.arcAngle, _points7.arcLarge, _points7.arcSweep); + } + + default: + throw new Error('Unknown path seg type.'); + } + } + }]); + + return Source; + }(); + + var builder = new Builder(); + var source = new Source(string); + + if (!source.initialCommandIsMoveTo()) { + return []; + } + + while (source.hasMoreData()) { + var pathSeg = source.parseSegment(); + + if (!pathSeg) { + return []; + } + + builder.appendSegment(pathSeg); + } + + return builder.pathSegList; + } // STATIC + + }], [{ + key: "_pathSegArrayAsString", + value: function _pathSegArrayAsString(pathSegArray) { + var string = ''; + var first = true; + pathSegArray.forEach(function (pathSeg) { + if (first) { + first = false; + string += pathSeg._asPathString(); + } else { + string += ' ' + pathSeg._asPathString(); + } + }); + return string; + } + }]); + + return SVGPathSegList; + }(); + + SVGPathSegList.prototype.classname = 'SVGPathSegList'; + Object.defineProperty(SVGPathSegList.prototype, 'numberOfItems', { + get: function get() { + this._checkPathSynchronizedToList(); + + return this._list.length; + }, + enumerable: true + }); // Add the pathSegList accessors to SVGPathElement. + // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGAnimatedPathData + + Object.defineProperties(SVGPathElement.prototype, { + pathSegList: { + get: function get() { + if (!this._pathSegList) { + this._pathSegList = new SVGPathSegList(this); + } + + return this._pathSegList; + }, + enumerable: true + }, + // TODO: The following are not implemented and simply return SVGPathElement.pathSegList. + normalizedPathSegList: { + get: function get() { + return this.pathSegList; + }, + enumerable: true + }, + animatedPathSegList: { + get: function get() { + return this.pathSegList; + }, + enumerable: true + }, + animatedNormalizedPathSegList: { + get: function get() { + return this.pathSegList; + }, + enumerable: true + } + }); + window.SVGPathSegList = SVGPathSegList; + } + })(); + + // The button toggles whether the path is open or closed + + var extClosepath = exports('default', { + name: 'closepath', + init: function init(_ref) { + var _this = this; + + return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { + var importLocale, $, strings, svgEditor, selElems, updateButton, showPanel, toggleClosed, buttons; + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + importLocale = _ref.importLocale, $ = _ref.$; + _context.next = 3; + return importLocale(); + + case 3: + strings = _context.sent; + svgEditor = _this; + + updateButton = function updateButton(path) { + var seglist = path.pathSegList, + closed = seglist.getItem(seglist.numberOfItems - 1).pathSegType === 1, + showbutton = closed ? '#tool_openpath' : '#tool_closepath', + hidebutton = closed ? '#tool_closepath' : '#tool_openpath'; + $(hidebutton).hide(); + $(showbutton).show(); + }; + + showPanel = function showPanel(on) { + $('#closepath_panel').toggle(on); + + if (on) { + var path = selElems[0]; + + if (path) { + updateButton(path); + } + } + }; + + toggleClosed = function toggleClosed() { + var path = selElems[0]; + + if (path) { + var seglist = path.pathSegList, + last = seglist.numberOfItems - 1; // is closed + + if (seglist.getItem(last).pathSegType === 1) { + seglist.removeItem(last); + } else { + seglist.appendItem(path.createSVGPathSegClosePath()); + } + + updateButton(path); + } + }; + + buttons = [{ + id: 'tool_openpath', + icon: svgEditor.curConfig.extIconsPath + 'openpath.png', + type: 'context', + panel: 'closepath_panel', + events: { + click: function click() { + toggleClosed(); + } + } + }, { + id: 'tool_closepath', + icon: svgEditor.curConfig.extIconsPath + 'closepath.png', + type: 'context', + panel: 'closepath_panel', + events: { + click: function click() { + toggleClosed(); + } + } + }]; + return _context.abrupt("return", { + name: strings.name, + svgicons: svgEditor.curConfig.extIconsPath + 'closepath_icons.svg', + buttons: strings.buttons.map(function (button, i) { + return Object.assign(buttons[i], button); + }), + callback: function callback() { + $('#closepath_panel').hide(); + }, + selectedChanged: function selectedChanged(opts) { + selElems = opts.elems; + var i = selElems.length; + + while (i--) { + var elem = selElems[i]; + + if (elem && elem.tagName === 'path') { + if (opts.selectedElement && !opts.multiselected) { + showPanel(true); + } else { + showPanel(false); + } + } else { + showPanel(false); + } + } + } + }); + + case 10: + case "end": + return _context.stop(); + } + } + }, _callee); + }))(); + } + }); + + } + }; +}); diff --git a/dist/editor/system/extensions/ext-connector.js b/dist/editor/system/extensions/ext-connector.js new file mode 100644 index 00000000..c4b256a9 --- /dev/null +++ b/dist/editor/system/extensions/ext-connector.js @@ -0,0 +1,2306 @@ +System.register([], function (exports) { + 'use strict'; + return { + execute: function () { + + function _typeof(obj) { + "@babel/helpers - typeof"; + + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function (obj) { + return typeof obj; + }; + } else { + _typeof = function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); + } + + var REACT_ELEMENT_TYPE; + + function _jsx(type, props, key, children) { + if (!REACT_ELEMENT_TYPE) { + REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol["for"] && Symbol["for"]("react.element") || 0xeac7; + } + + var defaultProps = type && type.defaultProps; + var childrenLength = arguments.length - 3; + + if (!props && childrenLength !== 0) { + props = { + children: void 0 + }; + } + + if (childrenLength === 1) { + props.children = children; + } else if (childrenLength > 1) { + var childArray = new Array(childrenLength); + + for (var i = 0; i < childrenLength; i++) { + childArray[i] = arguments[i + 3]; + } + + props.children = childArray; + } + + if (props && defaultProps) { + for (var propName in defaultProps) { + if (props[propName] === void 0) { + props[propName] = defaultProps[propName]; + } + } + } else if (!props) { + props = defaultProps || {}; + } + + return { + $$typeof: REACT_ELEMENT_TYPE, + type: type, + key: key === undefined ? null : '' + key, + ref: null, + props: props, + _owner: null + }; + } + + function _asyncIterator(iterable) { + var method; + + if (typeof Symbol !== "undefined") { + if (Symbol.asyncIterator) { + method = iterable[Symbol.asyncIterator]; + if (method != null) return method.call(iterable); + } + + if (Symbol.iterator) { + method = iterable[Symbol.iterator]; + if (method != null) return method.call(iterable); + } + } + + throw new TypeError("Object is not async iterable"); + } + + function _AwaitValue(value) { + this.wrapped = value; + } + + function _AsyncGenerator(gen) { + var front, back; + + function send(key, arg) { + return new Promise(function (resolve, reject) { + var request = { + key: key, + arg: arg, + resolve: resolve, + reject: reject, + next: null + }; + + if (back) { + back = back.next = request; + } else { + front = back = request; + resume(key, arg); + } + }); + } + + function resume(key, arg) { + try { + var result = gen[key](arg); + var value = result.value; + var wrappedAwait = value instanceof _AwaitValue; + Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { + if (wrappedAwait) { + resume(key === "return" ? "return" : "next", arg); + return; + } + + settle(result.done ? "return" : "normal", arg); + }, function (err) { + resume("throw", err); + }); + } catch (err) { + settle("throw", err); + } + } + + function settle(type, value) { + switch (type) { + case "return": + front.resolve({ + value: value, + done: true + }); + break; + + case "throw": + front.reject(value); + break; + + default: + front.resolve({ + value: value, + done: false + }); + break; + } + + front = front.next; + + if (front) { + resume(front.key, front.arg); + } else { + back = null; + } + } + + this._invoke = send; + + if (typeof gen.return !== "function") { + this.return = undefined; + } + } + + if (typeof Symbol === "function" && Symbol.asyncIterator) { + _AsyncGenerator.prototype[Symbol.asyncIterator] = function () { + return this; + }; + } + + _AsyncGenerator.prototype.next = function (arg) { + return this._invoke("next", arg); + }; + + _AsyncGenerator.prototype.throw = function (arg) { + return this._invoke("throw", arg); + }; + + _AsyncGenerator.prototype.return = function (arg) { + return this._invoke("return", arg); + }; + + function _wrapAsyncGenerator(fn) { + return function () { + return new _AsyncGenerator(fn.apply(this, arguments)); + }; + } + + function _awaitAsyncGenerator(value) { + return new _AwaitValue(value); + } + + function _asyncGeneratorDelegate(inner, awaitWrap) { + var iter = {}, + waiting = false; + + function pump(key, value) { + waiting = true; + value = new Promise(function (resolve) { + resolve(inner[key](value)); + }); + return { + done: false, + value: awaitWrap(value) + }; + } + + ; + + if (typeof Symbol === "function" && Symbol.iterator) { + iter[Symbol.iterator] = function () { + return this; + }; + } + + iter.next = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("next", value); + }; + + if (typeof inner.throw === "function") { + iter.throw = function (value) { + if (waiting) { + waiting = false; + throw value; + } + + return pump("throw", value); + }; + } + + if (typeof inner.return === "function") { + iter.return = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("return", value); + }; + } + + return iter; + } + + function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { + try { + var info = gen[key](arg); + var value = info.value; + } catch (error) { + reject(error); + return; + } + + if (info.done) { + resolve(value); + } else { + Promise.resolve(value).then(_next, _throw); + } + } + + function _asyncToGenerator(fn) { + return function () { + var self = this, + args = arguments; + return new Promise(function (resolve, reject) { + var gen = fn.apply(self, args); + + function _next(value) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); + } + + function _throw(err) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); + } + + _next(undefined); + }); + }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; + } + + function _defineEnumerableProperties(obj, descs) { + for (var key in descs) { + var desc = descs[key]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, key, desc); + } + + if (Object.getOwnPropertySymbols) { + var objectSymbols = Object.getOwnPropertySymbols(descs); + + for (var i = 0; i < objectSymbols.length; i++) { + var sym = objectSymbols[i]; + var desc = descs[sym]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, sym, desc); + } + } + + return obj; + } + + function _defaults(obj, defaults) { + var keys = Object.getOwnPropertyNames(defaults); + + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var value = Object.getOwnPropertyDescriptor(defaults, key); + + if (value && value.configurable && obj[key] === undefined) { + Object.defineProperty(obj, key, value); + } + } + + return obj; + } + + function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; + } + + function _extends() { + _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + + return _extends.apply(this, arguments); + } + + function _objectSpread(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? Object(arguments[i]) : {}; + var ownKeys = Object.keys(source); + + if (typeof Object.getOwnPropertySymbols === 'function') { + ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { + return Object.getOwnPropertyDescriptor(source, sym).enumerable; + })); + } + + ownKeys.forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } + + return target; + } + + function ownKeys(object, enumerableOnly) { + var keys = Object.keys(object); + + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(object); + if (enumerableOnly) symbols = symbols.filter(function (sym) { + return Object.getOwnPropertyDescriptor(object, sym).enumerable; + }); + keys.push.apply(keys, symbols); + } + + return keys; + } + + function _objectSpread2(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? arguments[i] : {}; + + if (i % 2) { + ownKeys(Object(source), true).forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } else if (Object.getOwnPropertyDescriptors) { + Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); + } else { + ownKeys(Object(source)).forEach(function (key) { + Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); + }); + } + } + + return target; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function"); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + writable: true, + configurable: true + } + }); + if (superClass) _setPrototypeOf(subClass, superClass); + } + + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + subClass.__proto__ = superClass; + } + + function _getPrototypeOf(o) { + _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { + return o.__proto__ || Object.getPrototypeOf(o); + }; + return _getPrototypeOf(o); + } + + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + + return _setPrototypeOf(o, p); + } + + function _isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + + try { + Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); + return true; + } catch (e) { + return false; + } + } + + function _construct(Parent, args, Class) { + if (_isNativeReflectConstruct()) { + _construct = Reflect.construct; + } else { + _construct = function _construct(Parent, args, Class) { + var a = [null]; + a.push.apply(a, args); + var Constructor = Function.bind.apply(Parent, a); + var instance = new Constructor(); + if (Class) _setPrototypeOf(instance, Class.prototype); + return instance; + }; + } + + return _construct.apply(null, arguments); + } + + function _isNativeFunction(fn) { + return Function.toString.call(fn).indexOf("[native code]") !== -1; + } + + function _wrapNativeSuper(Class) { + var _cache = typeof Map === "function" ? new Map() : undefined; + + _wrapNativeSuper = function _wrapNativeSuper(Class) { + if (Class === null || !_isNativeFunction(Class)) return Class; + + if (typeof Class !== "function") { + throw new TypeError("Super expression must either be null or a function"); + } + + if (typeof _cache !== "undefined") { + if (_cache.has(Class)) return _cache.get(Class); + + _cache.set(Class, Wrapper); + } + + function Wrapper() { + return _construct(Class, arguments, _getPrototypeOf(this).constructor); + } + + Wrapper.prototype = Object.create(Class.prototype, { + constructor: { + value: Wrapper, + enumerable: false, + writable: true, + configurable: true + } + }); + return _setPrototypeOf(Wrapper, Class); + }; + + return _wrapNativeSuper(Class); + } + + function _instanceof(left, right) { + if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { + return !!right[Symbol.hasInstance](left); + } else { + return left instanceof right; + } + } + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + + function _getRequireWildcardCache() { + if (typeof WeakMap !== "function") return null; + var cache = new WeakMap(); + + _getRequireWildcardCache = function () { + return cache; + }; + + return cache; + } + + function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } + + if (obj === null || typeof obj !== "object" && typeof obj !== "function") { + return { + default: obj + }; + } + + var cache = _getRequireWildcardCache(); + + if (cache && cache.has(obj)) { + return cache.get(obj); + } + + var newObj = {}; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + + if (desc && (desc.get || desc.set)) { + Object.defineProperty(newObj, key, desc); + } else { + newObj[key] = obj[key]; + } + } + } + + newObj.default = obj; + + if (cache) { + cache.set(obj, newObj); + } + + return newObj; + } + + function _newArrowCheck(innerThis, boundThis) { + if (innerThis !== boundThis) { + throw new TypeError("Cannot instantiate an arrow function"); + } + } + + function _objectDestructuringEmpty(obj) { + if (obj == null) throw new TypeError("Cannot destructure undefined"); + } + + function _objectWithoutPropertiesLoose(source, excluded) { + if (source == null) return {}; + var target = {}; + var sourceKeys = Object.keys(source); + var key, i; + + for (i = 0; i < sourceKeys.length; i++) { + key = sourceKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + target[key] = source[key]; + } + + return target; + } + + function _objectWithoutProperties(source, excluded) { + if (source == null) return {}; + + var target = _objectWithoutPropertiesLoose(source, excluded); + + var key, i; + + if (Object.getOwnPropertySymbols) { + var sourceSymbolKeys = Object.getOwnPropertySymbols(source); + + for (i = 0; i < sourceSymbolKeys.length; i++) { + key = sourceSymbolKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; + target[key] = source[key]; + } + } + + return target; + } + + function _assertThisInitialized(self) { + if (self === void 0) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return self; + } + + function _possibleConstructorReturn(self, call) { + if (call && (typeof call === "object" || typeof call === "function")) { + return call; + } + + return _assertThisInitialized(self); + } + + function _createSuper(Derived) { + var hasNativeReflectConstruct = _isNativeReflectConstruct(); + + return function _createSuperInternal() { + var Super = _getPrototypeOf(Derived), + result; + + if (hasNativeReflectConstruct) { + var NewTarget = _getPrototypeOf(this).constructor; + + result = Reflect.construct(Super, arguments, NewTarget); + } else { + result = Super.apply(this, arguments); + } + + return _possibleConstructorReturn(this, result); + }; + } + + function _superPropBase(object, property) { + while (!Object.prototype.hasOwnProperty.call(object, property)) { + object = _getPrototypeOf(object); + if (object === null) break; + } + + return object; + } + + function _get(target, property, receiver) { + if (typeof Reflect !== "undefined" && Reflect.get) { + _get = Reflect.get; + } else { + _get = function _get(target, property, receiver) { + var base = _superPropBase(target, property); + + if (!base) return; + var desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.get) { + return desc.get.call(receiver); + } + + return desc.value; + }; + } + + return _get(target, property, receiver || target); + } + + function set(target, property, value, receiver) { + if (typeof Reflect !== "undefined" && Reflect.set) { + set = Reflect.set; + } else { + set = function set(target, property, value, receiver) { + var base = _superPropBase(target, property); + + var desc; + + if (base) { + desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.set) { + desc.set.call(receiver, value); + return true; + } else if (!desc.writable) { + return false; + } + } + + desc = Object.getOwnPropertyDescriptor(receiver, property); + + if (desc) { + if (!desc.writable) { + return false; + } + + desc.value = value; + Object.defineProperty(receiver, property, desc); + } else { + _defineProperty(receiver, property, value); + } + + return true; + }; + } + + return set(target, property, value, receiver); + } + + function _set(target, property, value, receiver, isStrict) { + var s = set(target, property, value, receiver || target); + + if (!s && isStrict) { + throw new Error('failed to set property'); + } + + return value; + } + + function _taggedTemplateLiteral(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + return Object.freeze(Object.defineProperties(strings, { + raw: { + value: Object.freeze(raw) + } + })); + } + + function _taggedTemplateLiteralLoose(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + strings.raw = raw; + return strings; + } + + function _readOnlyError(name) { + throw new Error("\"" + name + "\" is read-only"); + } + + function _classNameTDZError(name) { + throw new Error("Class \"" + name + "\" cannot be referenced in computed property keys."); + } + + function _temporalUndefined() {} + + function _tdz(name) { + throw new ReferenceError(name + " is not defined - temporal dead zone"); + } + + function _temporalRef(val, name) { + return val === _temporalUndefined ? _tdz(name) : val; + } + + function _slicedToArray(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); + } + + function _slicedToArrayLoose(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimitLoose(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); + } + + function _toArray(arr) { + return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); + } + + function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); + } + + function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) return _arrayLikeToArray(arr); + } + + function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; + } + + function _maybeArrayLike(next, arr, i) { + if (arr && !Array.isArray(arr) && typeof arr.length === "number") { + var len = arr.length; + return _arrayLikeToArray(arr, i !== void 0 && i < len ? i : len); + } + + return next(arr, i); + } + + function _iterableToArray(iter) { + if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); + } + + function _iterableToArrayLimit(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"] != null) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; + } + + function _iterableToArrayLimitLoose(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + + for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { + _arr.push(_step.value); + + if (i && _arr.length === i) break; + } + + return _arr; + } + + function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if (typeof o === "string") return _arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + if (n === "Object" && o.constructor) n = o.constructor.name; + if (n === "Map" || n === "Set") return Array.from(o); + if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); + } + + function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) len = arr.length; + + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + + return arr2; + } + + function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + function _createForOfIteratorHelper(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + + var F = function () {}; + + return { + s: F, + n: function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }, + e: function (e) { + throw e; + }, + f: F + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + var normalCompletion = true, + didErr = false, + err; + return { + s: function () { + it = o[Symbol.iterator](); + }, + n: function () { + var step = it.next(); + normalCompletion = step.done; + return step; + }, + e: function (e) { + didErr = true; + err = e; + }, + f: function () { + try { + if (!normalCompletion && it.return != null) it.return(); + } finally { + if (didErr) throw err; + } + } + }; + } + + function _createForOfIteratorHelperLoose(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + return function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + it = o[Symbol.iterator](); + return it.next.bind(it); + } + + function _skipFirstGeneratorNext(fn) { + return function () { + var it = fn.apply(this, arguments); + it.next(); + return it; + }; + } + + function _toPrimitive(input, hint) { + if (typeof input !== "object" || input === null) return input; + var prim = input[Symbol.toPrimitive]; + + if (prim !== undefined) { + var res = prim.call(input, hint || "default"); + if (typeof res !== "object") return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + + return (hint === "string" ? String : Number)(input); + } + + function _toPropertyKey(arg) { + var key = _toPrimitive(arg, "string"); + + return typeof key === "symbol" ? key : String(key); + } + + function _initializerWarningHelper(descriptor, context) { + throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.'); + } + + function _initializerDefineProperty(target, property, descriptor, context) { + if (!descriptor) return; + Object.defineProperty(target, property, { + enumerable: descriptor.enumerable, + configurable: descriptor.configurable, + writable: descriptor.writable, + value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 + }); + } + + function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { + var desc = {}; + Object.keys(descriptor).forEach(function (key) { + desc[key] = descriptor[key]; + }); + desc.enumerable = !!desc.enumerable; + desc.configurable = !!desc.configurable; + + if ('value' in desc || desc.initializer) { + desc.writable = true; + } + + desc = decorators.slice().reverse().reduce(function (desc, decorator) { + return decorator(target, property, desc) || desc; + }, desc); + + if (context && desc.initializer !== void 0) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = undefined; + } + + if (desc.initializer === void 0) { + Object.defineProperty(target, property, desc); + desc = null; + } + + return desc; + } + + var id = 0; + + function _classPrivateFieldLooseKey(name) { + return "__private_" + id++ + "_" + name; + } + + function _classPrivateFieldLooseBase(receiver, privateKey) { + if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { + throw new TypeError("attempted to use private field on non-instance"); + } + + return receiver; + } + + function _classPrivateFieldGet(receiver, privateMap) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to get private field on non-instance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; + } + + function _classPrivateFieldSet(receiver, privateMap, value) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to set private field on non-instance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; + } + + function _classPrivateFieldDestructureSet(receiver, privateMap) { + if (!privateMap.has(receiver)) { + throw new TypeError("attempted to set private field on non-instance"); + } + + var descriptor = privateMap.get(receiver); + + if (descriptor.set) { + if (!("__destrObj" in descriptor)) { + descriptor.__destrObj = { + set value(v) { + descriptor.set.call(receiver, v); + } + + }; + } + + return descriptor.__destrObj; + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + return descriptor; + } + } + + function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; + } + + function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; + } + + function _classStaticPrivateMethodGet(receiver, classConstructor, method) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + return method; + } + + function _classStaticPrivateMethodSet() { + throw new TypeError("attempted to set read only static private field"); + } + + function _decorate(decorators, factory, superClass, mixins) { + var api = _getDecoratorsApi(); + + if (mixins) { + for (var i = 0; i < mixins.length; i++) { + api = mixins[i](api); + } + } + + var r = factory(function initialize(O) { + api.initializeInstanceElements(O, decorated.elements); + }, superClass); + var decorated = api.decorateClass(_coalesceClassElements(r.d.map(_createElementDescriptor)), decorators); + api.initializeClassElements(r.F, decorated.elements); + return api.runClassFinishers(r.F, decorated.finishers); + } + + function _getDecoratorsApi() { + _getDecoratorsApi = function () { + return api; + }; + + var api = { + elementsDefinitionOrder: [["method"], ["field"]], + initializeInstanceElements: function (O, elements) { + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + if (element.kind === kind && element.placement === "own") { + this.defineClassElement(O, element); + } + }, this); + }, this); + }, + initializeClassElements: function (F, elements) { + var proto = F.prototype; + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + var placement = element.placement; + + if (element.kind === kind && (placement === "static" || placement === "prototype")) { + var receiver = placement === "static" ? F : proto; + this.defineClassElement(receiver, element); + } + }, this); + }, this); + }, + defineClassElement: function (receiver, element) { + var descriptor = element.descriptor; + + if (element.kind === "field") { + var initializer = element.initializer; + descriptor = { + enumerable: descriptor.enumerable, + writable: descriptor.writable, + configurable: descriptor.configurable, + value: initializer === void 0 ? void 0 : initializer.call(receiver) + }; + } + + Object.defineProperty(receiver, element.key, descriptor); + }, + decorateClass: function (elements, decorators) { + var newElements = []; + var finishers = []; + var placements = { + static: [], + prototype: [], + own: [] + }; + elements.forEach(function (element) { + this.addElementPlacement(element, placements); + }, this); + elements.forEach(function (element) { + if (!_hasDecorators(element)) return newElements.push(element); + var elementFinishersExtras = this.decorateElement(element, placements); + newElements.push(elementFinishersExtras.element); + newElements.push.apply(newElements, elementFinishersExtras.extras); + finishers.push.apply(finishers, elementFinishersExtras.finishers); + }, this); + + if (!decorators) { + return { + elements: newElements, + finishers: finishers + }; + } + + var result = this.decorateConstructor(newElements, decorators); + finishers.push.apply(finishers, result.finishers); + result.finishers = finishers; + return result; + }, + addElementPlacement: function (element, placements, silent) { + var keys = placements[element.placement]; + + if (!silent && keys.indexOf(element.key) !== -1) { + throw new TypeError("Duplicated element (" + element.key + ")"); + } + + keys.push(element.key); + }, + decorateElement: function (element, placements) { + var extras = []; + var finishers = []; + + for (var decorators = element.decorators, i = decorators.length - 1; i >= 0; i--) { + var keys = placements[element.placement]; + keys.splice(keys.indexOf(element.key), 1); + var elementObject = this.fromElementDescriptor(element); + var elementFinisherExtras = this.toElementFinisherExtras((0, decorators[i])(elementObject) || elementObject); + element = elementFinisherExtras.element; + this.addElementPlacement(element, placements); + + if (elementFinisherExtras.finisher) { + finishers.push(elementFinisherExtras.finisher); + } + + var newExtras = elementFinisherExtras.extras; + + if (newExtras) { + for (var j = 0; j < newExtras.length; j++) { + this.addElementPlacement(newExtras[j], placements); + } + + extras.push.apply(extras, newExtras); + } + } + + return { + element: element, + finishers: finishers, + extras: extras + }; + }, + decorateConstructor: function (elements, decorators) { + var finishers = []; + + for (var i = decorators.length - 1; i >= 0; i--) { + var obj = this.fromClassDescriptor(elements); + var elementsAndFinisher = this.toClassDescriptor((0, decorators[i])(obj) || obj); + + if (elementsAndFinisher.finisher !== undefined) { + finishers.push(elementsAndFinisher.finisher); + } + + if (elementsAndFinisher.elements !== undefined) { + elements = elementsAndFinisher.elements; + + for (var j = 0; j < elements.length - 1; j++) { + for (var k = j + 1; k < elements.length; k++) { + if (elements[j].key === elements[k].key && elements[j].placement === elements[k].placement) { + throw new TypeError("Duplicated element (" + elements[j].key + ")"); + } + } + } + } + } + + return { + elements: elements, + finishers: finishers + }; + }, + fromElementDescriptor: function (element) { + var obj = { + kind: element.kind, + key: element.key, + placement: element.placement, + descriptor: element.descriptor + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + if (element.kind === "field") obj.initializer = element.initializer; + return obj; + }, + toElementDescriptors: function (elementObjects) { + if (elementObjects === undefined) return; + return _toArray(elementObjects).map(function (elementObject) { + var element = this.toElementDescriptor(elementObject); + this.disallowProperty(elementObject, "finisher", "An element descriptor"); + this.disallowProperty(elementObject, "extras", "An element descriptor"); + return element; + }, this); + }, + toElementDescriptor: function (elementObject) { + var kind = String(elementObject.kind); + + if (kind !== "method" && kind !== "field") { + throw new TypeError('An element descriptor\'s .kind property must be either "method" or' + ' "field", but a decorator created an element descriptor with' + ' .kind "' + kind + '"'); + } + + var key = _toPropertyKey(elementObject.key); + + var placement = String(elementObject.placement); + + if (placement !== "static" && placement !== "prototype" && placement !== "own") { + throw new TypeError('An element descriptor\'s .placement property must be one of "static",' + ' "prototype" or "own", but a decorator created an element descriptor' + ' with .placement "' + placement + '"'); + } + + var descriptor = elementObject.descriptor; + this.disallowProperty(elementObject, "elements", "An element descriptor"); + var element = { + kind: kind, + key: key, + placement: placement, + descriptor: Object.assign({}, descriptor) + }; + + if (kind !== "field") { + this.disallowProperty(elementObject, "initializer", "A method descriptor"); + } else { + this.disallowProperty(descriptor, "get", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "set", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "value", "The property descriptor of a field descriptor"); + element.initializer = elementObject.initializer; + } + + return element; + }, + toElementFinisherExtras: function (elementObject) { + var element = this.toElementDescriptor(elementObject); + + var finisher = _optionalCallableProperty(elementObject, "finisher"); + + var extras = this.toElementDescriptors(elementObject.extras); + return { + element: element, + finisher: finisher, + extras: extras + }; + }, + fromClassDescriptor: function (elements) { + var obj = { + kind: "class", + elements: elements.map(this.fromElementDescriptor, this) + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + return obj; + }, + toClassDescriptor: function (obj) { + var kind = String(obj.kind); + + if (kind !== "class") { + throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator' + ' created a class descriptor with .kind "' + kind + '"'); + } + + this.disallowProperty(obj, "key", "A class descriptor"); + this.disallowProperty(obj, "placement", "A class descriptor"); + this.disallowProperty(obj, "descriptor", "A class descriptor"); + this.disallowProperty(obj, "initializer", "A class descriptor"); + this.disallowProperty(obj, "extras", "A class descriptor"); + + var finisher = _optionalCallableProperty(obj, "finisher"); + + var elements = this.toElementDescriptors(obj.elements); + return { + elements: elements, + finisher: finisher + }; + }, + runClassFinishers: function (constructor, finishers) { + for (var i = 0; i < finishers.length; i++) { + var newConstructor = (0, finishers[i])(constructor); + + if (newConstructor !== undefined) { + if (typeof newConstructor !== "function") { + throw new TypeError("Finishers must return a constructor."); + } + + constructor = newConstructor; + } + } + + return constructor; + }, + disallowProperty: function (obj, name, objectType) { + if (obj[name] !== undefined) { + throw new TypeError(objectType + " can't have a ." + name + " property."); + } + } + }; + return api; + } + + function _createElementDescriptor(def) { + var key = _toPropertyKey(def.key); + + var descriptor; + + if (def.kind === "method") { + descriptor = { + value: def.value, + writable: true, + configurable: true, + enumerable: false + }; + } else if (def.kind === "get") { + descriptor = { + get: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "set") { + descriptor = { + set: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "field") { + descriptor = { + configurable: true, + writable: true, + enumerable: true + }; + } + + var element = { + kind: def.kind === "field" ? "field" : "method", + key: key, + placement: def.static ? "static" : def.kind === "field" ? "own" : "prototype", + descriptor: descriptor + }; + if (def.decorators) element.decorators = def.decorators; + if (def.kind === "field") element.initializer = def.value; + return element; + } + + function _coalesceGetterSetter(element, other) { + if (element.descriptor.get !== undefined) { + other.descriptor.get = element.descriptor.get; + } else { + other.descriptor.set = element.descriptor.set; + } + } + + function _coalesceClassElements(elements) { + var newElements = []; + + var isSameElement = function (other) { + return other.kind === "method" && other.key === element.key && other.placement === element.placement; + }; + + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + var other; + + if (element.kind === "method" && (other = newElements.find(isSameElement))) { + if (_isDataDescriptor(element.descriptor) || _isDataDescriptor(other.descriptor)) { + if (_hasDecorators(element) || _hasDecorators(other)) { + throw new ReferenceError("Duplicated methods (" + element.key + ") can't be decorated."); + } + + other.descriptor = element.descriptor; + } else { + if (_hasDecorators(element)) { + if (_hasDecorators(other)) { + throw new ReferenceError("Decorators can't be placed on different accessors with for " + "the same property (" + element.key + ")."); + } + + other.decorators = element.decorators; + } + + _coalesceGetterSetter(element, other); + } + } else { + newElements.push(element); + } + } + + return newElements; + } + + function _hasDecorators(element) { + return element.decorators && element.decorators.length; + } + + function _isDataDescriptor(desc) { + return desc !== undefined && !(desc.value === undefined && desc.writable === undefined); + } + + function _optionalCallableProperty(obj, name) { + var value = obj[name]; + + if (value !== undefined && typeof value !== "function") { + throw new TypeError("Expected '" + name + "' to be a function"); + } + + return value; + } + + function _classPrivateMethodGet(receiver, privateSet, fn) { + if (!privateSet.has(receiver)) { + throw new TypeError("attempted to get private field on non-instance"); + } + + return fn; + } + + function _classPrivateMethodSet() { + throw new TypeError("attempted to reassign private method"); + } + + function _wrapRegExp(re, groups) { + _wrapRegExp = function (re, groups) { + return new BabelRegExp(re, undefined, groups); + }; + + var _RegExp = _wrapNativeSuper(RegExp); + + var _super = RegExp.prototype; + + var _groups = new WeakMap(); + + function BabelRegExp(re, flags, groups) { + var _this = _RegExp.call(this, re, flags); + + _groups.set(_this, groups || _groups.get(re)); + + return _this; + } + + _inherits(BabelRegExp, _RegExp); + + BabelRegExp.prototype.exec = function (str) { + var result = _super.exec.call(this, str); + + if (result) result.groups = buildGroups(result, this); + return result; + }; + + BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { + if (typeof substitution === "string") { + var groups = _groups.get(this); + + return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { + return "$" + groups[name]; + })); + } else if (typeof substitution === "function") { + var _this = this; + + return _super[Symbol.replace].call(this, str, function () { + var args = []; + args.push.apply(args, arguments); + + if (typeof args[args.length - 1] !== "object") { + args.push(buildGroups(args, _this)); + } + + return substitution.apply(this, args); + }); + } else { + return _super[Symbol.replace].call(this, str, substitution); + } + }; + + function buildGroups(result, re) { + var g = _groups.get(re); + + return Object.keys(g).reduce(function (groups, name) { + groups[name] = result[g[name]]; + return groups; + }, Object.create(null)); + } + + return _wrapRegExp.apply(this, arguments); + } + + /** + * @file ext-connector.js + * + * @license MIT + * + * @copyright 2010 Alexis Deveria + * + */ + var extConnector = exports('default', { + name: 'connector', + init: function init(S) { + var _this = this; + + return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { + var svgEditor, svgCanvas, getElem, $, svgroot, importLocale, addElem, selManager, connSel, elData, strings, startX, startY, curLine, startElem, endElem, seNs, svgcontent, started, connections, selElems, getBBintersect, getOffset, showPanel, setPoint, updateLine, findConnectors, updateConnectors, init, buttons; + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + init = function _init() { + // Make sure all connectors have data set + $(svgcontent).find('*').each(function () { + var conn = this.getAttributeNS(seNs, 'connector'); + + if (conn) { + this.setAttribute('class', connSel.substr(1)); + var connData = conn.split(' '); + var sbb = svgCanvas.getStrokedBBox([getElem(connData[0])]); + var ebb = svgCanvas.getStrokedBBox([getElem(connData[1])]); + $(this).data('c_start', connData[0]).data('c_end', connData[1]).data('start_bb', sbb).data('end_bb', ebb); + svgCanvas.getEditorNS(true); + } + }); // updateConnectors(); + }; + + updateConnectors = function _updateConnectors(elems) { + // Updates connector lines based on selected elements + // Is not used on mousemove, as it runs getStrokedBBox every time, + // which isn't necessary there. + findConnectors(elems); + + if (connections.length) { + // Update line with element + var i = connections.length; + + while (i--) { + var conn = connections[i]; + var line = conn.connector; + var elem = conn.elem; // const sw = line.getAttribute('stroke-width') * 5; + + var pre = conn.is_start ? 'start' : 'end'; // Update bbox for this element + + var bb = svgCanvas.getStrokedBBox([elem]); + bb.x = conn.start_x; + bb.y = conn.start_y; + elData(line, pre + '_bb', bb); + /* const addOffset = */ + + elData(line, pre + '_off'); + var altPre = conn.is_start ? 'end' : 'start'; // Get center pt of connected element + + var bb2 = elData(line, altPre + '_bb'); + var srcX = bb2.x + bb2.width / 2; + var srcY = bb2.y + bb2.height / 2; // Set point of element being moved + + var pt = getBBintersect(srcX, srcY, bb, getOffset(pre, line)); + setPoint(line, conn.is_start ? 0 : 'end', pt.x, pt.y, true); // Set point of connected element + + var pt2 = getBBintersect(pt.x, pt.y, elData(line, altPre + '_bb'), getOffset(altPre, line)); + setPoint(line, conn.is_start ? 'end' : 0, pt2.x, pt2.y, true); // Update points attribute manually for webkit + + if (navigator.userAgent.includes('AppleWebKit')) { + var pts = line.points; + var len = pts.numberOfItems; + var ptArr = []; + + for (var j = 0; j < len; j++) { + pt = pts.getItem(j); + ptArr[j] = pt.x + ',' + pt.y; + } + + line.setAttribute('points', ptArr.join(' ')); + } + } + } + }; + + findConnectors = function _findConnectors() { + var elems = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : selElems; + var connectors = $(svgcontent).find(connSel); + connections = []; // Loop through connectors to see if one is connected to the element + + connectors.each(function () { + var addThis; + /** + * + * @returns {void} + */ + + function add() { + if (elems.includes(this)) { + // Pretend this element is selected + addThis = true; + } + } // Grab the ends + + + var parts = []; + ['start', 'end'].forEach(function (pos, i) { + var key = 'c_' + pos; + var part = elData(this, key); + + if (part === null || part === undefined) { + // Does this ever return nullish values? + part = document.getElementById(this.attributes['se:connector'].value.split(' ')[i]); + elData(this, 'c_' + pos, part.id); + elData(this, pos + '_bb', svgCanvas.getStrokedBBox([part])); + } else part = document.getElementById(part); + + parts.push(part); + }, this); + + for (var i = 0; i < 2; i++) { + var cElem = parts[i]; + addThis = false; // The connected element might be part of a selected group + + $(cElem).parents().each(add); + + if (!cElem || !cElem.parentNode) { + $(this).remove(); + continue; + } + + if (elems.includes(cElem) || addThis) { + var bb = svgCanvas.getStrokedBBox([cElem]); + connections.push({ + elem: cElem, + connector: this, + is_start: i === 0, + start_x: bb.x, + start_y: bb.y + }); + } + } + }); + }; + + updateLine = function _updateLine(diffX, diffY) { + // Update line with element + var i = connections.length; + + while (i--) { + var conn = connections[i]; + var line = conn.connector; // const {elem} = conn; + + var pre = conn.is_start ? 'start' : 'end'; // const sw = line.getAttribute('stroke-width') * 5; + // Update bbox for this element + + var bb = elData(line, pre + '_bb'); + bb.x = conn.start_x + diffX; + bb.y = conn.start_y + diffY; + elData(line, pre + '_bb', bb); + var altPre = conn.is_start ? 'end' : 'start'; // Get center pt of connected element + + var bb2 = elData(line, altPre + '_bb'); + var srcX = bb2.x + bb2.width / 2; + var srcY = bb2.y + bb2.height / 2; // Set point of element being moved + + var pt = getBBintersect(srcX, srcY, bb, getOffset(pre, line)); // $(line).data(pre+'_off')?sw:0 + + setPoint(line, conn.is_start ? 0 : 'end', pt.x, pt.y, true); // Set point of connected element + + var pt2 = getBBintersect(pt.x, pt.y, elData(line, altPre + '_bb'), getOffset(altPre, line)); + setPoint(line, conn.is_start ? 'end' : 0, pt2.x, pt2.y, true); + } + }; + + setPoint = function _setPoint(elem, pos, x, y, setMid) { + var pts = elem.points; + var pt = svgroot.createSVGPoint(); + pt.x = x; + pt.y = y; + + if (pos === 'end') { + pos = pts.numberOfItems - 1; + } // TODO: Test for this on init, then use alt only if needed + + + try { + pts.replaceItem(pt, pos); + } catch (err) { + // Should only occur in FF which formats points attr as "n,n n,n", so just split + var ptArr = elem.getAttribute('points').split(' '); + + for (var i = 0; i < ptArr.length; i++) { + if (i === pos) { + ptArr[i] = x + ',' + y; + } + } + + elem.setAttribute('points', ptArr.join(' ')); + } + + if (setMid) { + // Add center point + var ptStart = pts.getItem(0); + var ptEnd = pts.getItem(pts.numberOfItems - 1); + setPoint(elem, 1, (ptEnd.x + ptStart.x) / 2, (ptEnd.y + ptStart.y) / 2); + } + }; + + showPanel = function _showPanel(on) { + var connRules = $('#connector_rules'); + + if (!connRules.length) { + connRules = $('').appendTo('head'); + } + + connRules.text(!on ? '' : '#tool_clone, #tool_topath, #tool_angle, #xy_panel { display: none !important; }'); + $('#connector_panel').toggle(on); + }; + + getOffset = function _getOffset(side, line) { + var giveOffset = line.getAttribute('marker-' + side); // const giveOffset = $(line).data(side+'_off'); + // TODO: Make this number (5) be based on marker width/height + + var size = line.getAttribute('stroke-width') * 5; + return giveOffset ? size : 0; + }; + + getBBintersect = function _getBBintersect(x, y, bb, offset) { + if (offset) { + offset -= 0; + bb = $.extend({}, bb); + bb.width += offset; + bb.height += offset; + bb.x -= offset / 2; + bb.y -= offset / 2; + } + + var midX = bb.x + bb.width / 2; + var midY = bb.y + bb.height / 2; + var lenX = x - midX; + var lenY = y - midY; + var slope = Math.abs(lenY / lenX); + var ratio; + + if (slope < bb.height / bb.width) { + ratio = bb.width / 2 / Math.abs(lenX); + } else { + ratio = lenY ? bb.height / 2 / Math.abs(lenY) : 0; + } + + return { + x: midX + lenX * ratio, + y: midY + lenY * ratio + }; + }; + + svgEditor = _this; + svgCanvas = svgEditor.canvas; + getElem = svgCanvas.getElem; + $ = S.$, svgroot = S.svgroot, importLocale = S.importLocale, addElem = svgCanvas.addSVGElementFromJson, selManager = S.selectorManager, connSel = '.se_connector', elData = $.data; + _context.next = 14; + return importLocale(); + + case 14: + strings = _context.sent; + svgcontent = S.svgcontent, started = false, connections = [], selElems = []; + /** + * + * @param {Float} x + * @param {Float} y + * @param {module:utilities.BBoxObject} bb + * @param {Float} offset + * @returns {module:math.XYObject} + */ + + // Do once + (function () { + var gse = svgCanvas.groupSelectedElements; + + svgCanvas.groupSelectedElements = function () { + svgCanvas.removeFromSelection($(connSel).toArray()); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return gse.apply(this, args); + }; + + var mse = svgCanvas.moveSelectedElements; + + svgCanvas.moveSelectedElements = function () { + for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + var cmd = mse.apply(this, args); + updateConnectors(); + return cmd; + }; + + seNs = svgCanvas.getEditorNS(); + })(); + /** + * Do on reset. + * @returns {void} + */ + + + // $(svgroot).parent().mousemove(function (e) { + // // if (started + // // || svgCanvas.getMode() !== 'connector' + // // || e.target.parentNode.parentNode !== svgcontent) return; + // + // console.log('y') + // // if (e.target.parentNode.parentNode === svgcontent) { + // // + // // } + // }); + buttons = [{ + id: 'mode_connect', + type: 'mode', + icon: svgEditor.curConfig.imgPath + 'cut.png', + includeWith: { + button: '#tool_line', + isDefault: false, + position: 1 + }, + events: { + click: function click() { + svgCanvas.setMode('connector'); + } + } + }]; + return _context.abrupt("return", { + name: strings.name, + svgicons: svgEditor.curConfig.imgPath + 'conn.svg', + buttons: strings.buttons.map(function (button, i) { + return Object.assign(buttons[i], button); + }), + + /* async */ + addLangData: function addLangData(_ref) { + var lang = _ref.lang; + // , importLocale: importLoc + return { + data: strings.langList + }; + }, + mouseDown: function mouseDown(opts) { + var e = opts.event; + startX = opts.start_x; + startY = opts.start_y; + var mode = svgCanvas.getMode(); + var initStroke = svgEditor.curConfig.initStroke; + + if (mode === 'connector') { + if (started) { + return undefined; + } + + var mouseTarget = e.target; + var parents = $(mouseTarget).parents(); + + if ($.inArray(svgcontent, parents) !== -1) { + // Connectable element + // If child of foreignObject, use parent + var fo = $(mouseTarget).closest('foreignObject'); + startElem = fo.length ? fo[0] : mouseTarget; // Get center of source element + + var bb = svgCanvas.getStrokedBBox([startElem]); + var x = bb.x + bb.width / 2; + var y = bb.y + bb.height / 2; + started = true; + curLine = addElem({ + element: 'polyline', + attr: { + id: svgCanvas.getNextId(), + points: x + ',' + y + ' ' + x + ',' + y + ' ' + startX + ',' + startY, + stroke: '#' + initStroke.color, + 'stroke-width': !startElem.stroke_width || startElem.stroke_width === 0 ? initStroke.width : startElem.stroke_width, + fill: 'none', + opacity: initStroke.opacity, + style: 'pointer-events:none' + } + }); + elData(curLine, 'start_bb', bb); + } + + return { + started: true + }; + } + + if (mode === 'select') { + findConnectors(); + } + + return undefined; + }, + mouseMove: function mouseMove(opts) { + var zoom = svgCanvas.getZoom(); // const e = opts.event; + + var x = opts.mouse_x / zoom; + var y = opts.mouse_y / zoom; + var diffX = x - startX, + diffY = y - startY; + var mode = svgCanvas.getMode(); + + if (mode === 'connector' && started) { + // const sw = curLine.getAttribute('stroke-width') * 3; + // Set start point (adjusts based on bb) + var pt = getBBintersect(x, y, elData(curLine, 'start_bb'), getOffset('start', curLine)); + startX = pt.x; + startY = pt.y; + setPoint(curLine, 0, pt.x, pt.y, true); // Set end point + + setPoint(curLine, 'end', x, y, true); + } else if (mode === 'select') { + var slen = selElems.length; + + while (slen--) { + var elem = selElems[slen]; // Look for selected connector elements + + if (elem && elData(elem, 'c_start')) { + // Remove the "translate" transform given to move + svgCanvas.removeFromSelection([elem]); + svgCanvas.getTransformList(elem).clear(); + } + } + + if (connections.length) { + updateLine(diffX, diffY); + } + } + }, + mouseUp: function mouseUp(opts) { + // const zoom = svgCanvas.getZoom(); + var e = opts.event; // , x = opts.mouse_x / zoom, + // , y = opts.mouse_y / zoom, + + var mouseTarget = e.target; + + if (svgCanvas.getMode() !== 'connector') { + return undefined; + } + + var fo = $(mouseTarget).closest('foreignObject'); + + if (fo.length) { + mouseTarget = fo[0]; + } + + var parents = $(mouseTarget).parents(); + + if (mouseTarget === startElem) { + // Start line through click + started = true; + return { + keep: true, + element: null, + started: started + }; + } + + if ($.inArray(svgcontent, parents) === -1) { + // Not a valid target element, so remove line + $(curLine).remove(); + started = false; + return { + keep: false, + element: null, + started: started + }; + } // Valid end element + + + endElem = mouseTarget; + var startId = startElem.id, + endId = endElem.id; + var connStr = startId + ' ' + endId; + var altStr = endId + ' ' + startId; // Don't create connector if one already exists + + var dupe = $(svgcontent).find(connSel).filter(function () { + var conn = this.getAttributeNS(seNs, 'connector'); + + if (conn === connStr || conn === altStr) { + return true; + } + + return false; + }); + + if (dupe.length) { + $(curLine).remove(); + return { + keep: false, + element: null, + started: false + }; + } + + var bb = svgCanvas.getStrokedBBox([endElem]); + var pt = getBBintersect(startX, startY, bb, getOffset('start', curLine)); + setPoint(curLine, 'end', pt.x, pt.y, true); + $(curLine).data('c_start', startId).data('c_end', endId).data('end_bb', bb); + seNs = svgCanvas.getEditorNS(true); + curLine.setAttributeNS(seNs, 'se:connector', connStr); + curLine.setAttribute('class', connSel.substr(1)); + curLine.setAttribute('opacity', 1); + svgCanvas.addToSelection([curLine]); + svgCanvas.moveToBottomSelectedElement(); + selManager.requestSelector(curLine).showGrips(false); + started = false; + return { + keep: true, + element: curLine, + started: started + }; + }, + selectedChanged: function selectedChanged(opts) { + // TODO: Find better way to skip operations if no connectors are in use + if (!$(svgcontent).find(connSel).length) { + return; + } + + if (svgCanvas.getMode() === 'connector') { + svgCanvas.setMode('select'); + } // Use this to update the current selected elements + + + selElems = opts.elems; + var i = selElems.length; + + while (i--) { + var elem = selElems[i]; + + if (elem && elData(elem, 'c_start')) { + selManager.requestSelector(elem).showGrips(false); + + if (opts.selectedElement && !opts.multiselected) { + // TODO: Set up context tools and hide most regular line tools + showPanel(true); + } else { + showPanel(false); + } + } else { + showPanel(false); + } + } + + updateConnectors(); + }, + elementChanged: function elementChanged(opts) { + var elem = opts.elems[0]; + if (!elem) return; + + if (elem.tagName === 'svg' && elem.id === 'svgcontent') { + // Update svgcontent (can change on import) + svgcontent = elem; + init(); + } // Has marker, so change offset + + + if (elem.getAttribute('marker-start') || elem.getAttribute('marker-mid') || elem.getAttribute('marker-end')) { + var start = elem.getAttribute('marker-start'); + var mid = elem.getAttribute('marker-mid'); + var end = elem.getAttribute('marker-end'); + curLine = elem; + $(elem).data('start_off', Boolean(start)).data('end_off', Boolean(end)); + + if (elem.tagName === 'line' && mid) { + // Convert to polyline to accept mid-arrow + var x1 = Number(elem.getAttribute('x1')); + var x2 = Number(elem.getAttribute('x2')); + var y1 = Number(elem.getAttribute('y1')); + var y2 = Number(elem.getAttribute('y2')); + var _elem = elem, + id = _elem.id; + var midPt = ' ' + (x1 + x2) / 2 + ',' + (y1 + y2) / 2 + ' '; + var pline = addElem({ + element: 'polyline', + attr: { + points: x1 + ',' + y1 + midPt + x2 + ',' + y2, + stroke: elem.getAttribute('stroke'), + 'stroke-width': elem.getAttribute('stroke-width'), + 'marker-mid': mid, + fill: 'none', + opacity: elem.getAttribute('opacity') || 1 + } + }); + $(elem).after(pline).remove(); + svgCanvas.clearSelection(); + pline.id = id; + svgCanvas.addToSelection([pline]); + elem = pline; + } + } // Update line if it's a connector + + + if (elem.getAttribute('class') === connSel.substr(1)) { + var _start = getElem(elData(elem, 'c_start')); + + updateConnectors([_start]); + } else { + updateConnectors(); + } + }, + IDsUpdated: function IDsUpdated(input) { + var remove = []; + input.elems.forEach(function (elem) { + if ('se:connector' in elem.attr) { + elem.attr['se:connector'] = elem.attr['se:connector'].split(' ').map(function (oldID) { + return input.changes[oldID]; + }).join(' '); // Check validity - the field would be something like 'svg_21 svg_22', but + // if one end is missing, it would be 'svg_21' and therefore fail this test + + if (!/. ./.test(elem.attr['se:connector'])) { + remove.push(elem.attr.id); + } + } + }); + return { + remove: remove + }; + }, + toolButtonStateUpdate: function toolButtonStateUpdate(opts) { + if (opts.nostroke) { + if ($('#mode_connect').hasClass('tool_button_current')) { + svgEditor.clickSelect(); + } + } + + $('#mode_connect').toggleClass('disabled', opts.nostroke); + } + }); + + case 19: + case "end": + return _context.stop(); + } + } + }, _callee); + }))(); + } + }); + + } + }; +}); diff --git a/dist/editor/system/extensions/ext-eyedropper.js b/dist/editor/system/extensions/ext-eyedropper.js new file mode 100644 index 00000000..4433b752 --- /dev/null +++ b/dist/editor/system/extensions/ext-eyedropper.js @@ -0,0 +1,1810 @@ +System.register([], function (exports) { + 'use strict'; + return { + execute: function () { + + function _typeof(obj) { + "@babel/helpers - typeof"; + + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function (obj) { + return typeof obj; + }; + } else { + _typeof = function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); + } + + var REACT_ELEMENT_TYPE; + + function _jsx(type, props, key, children) { + if (!REACT_ELEMENT_TYPE) { + REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol["for"] && Symbol["for"]("react.element") || 0xeac7; + } + + var defaultProps = type && type.defaultProps; + var childrenLength = arguments.length - 3; + + if (!props && childrenLength !== 0) { + props = { + children: void 0 + }; + } + + if (childrenLength === 1) { + props.children = children; + } else if (childrenLength > 1) { + var childArray = new Array(childrenLength); + + for (var i = 0; i < childrenLength; i++) { + childArray[i] = arguments[i + 3]; + } + + props.children = childArray; + } + + if (props && defaultProps) { + for (var propName in defaultProps) { + if (props[propName] === void 0) { + props[propName] = defaultProps[propName]; + } + } + } else if (!props) { + props = defaultProps || {}; + } + + return { + $$typeof: REACT_ELEMENT_TYPE, + type: type, + key: key === undefined ? null : '' + key, + ref: null, + props: props, + _owner: null + }; + } + + function _asyncIterator(iterable) { + var method; + + if (typeof Symbol !== "undefined") { + if (Symbol.asyncIterator) { + method = iterable[Symbol.asyncIterator]; + if (method != null) return method.call(iterable); + } + + if (Symbol.iterator) { + method = iterable[Symbol.iterator]; + if (method != null) return method.call(iterable); + } + } + + throw new TypeError("Object is not async iterable"); + } + + function _AwaitValue(value) { + this.wrapped = value; + } + + function _AsyncGenerator(gen) { + var front, back; + + function send(key, arg) { + return new Promise(function (resolve, reject) { + var request = { + key: key, + arg: arg, + resolve: resolve, + reject: reject, + next: null + }; + + if (back) { + back = back.next = request; + } else { + front = back = request; + resume(key, arg); + } + }); + } + + function resume(key, arg) { + try { + var result = gen[key](arg); + var value = result.value; + var wrappedAwait = value instanceof _AwaitValue; + Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { + if (wrappedAwait) { + resume(key === "return" ? "return" : "next", arg); + return; + } + + settle(result.done ? "return" : "normal", arg); + }, function (err) { + resume("throw", err); + }); + } catch (err) { + settle("throw", err); + } + } + + function settle(type, value) { + switch (type) { + case "return": + front.resolve({ + value: value, + done: true + }); + break; + + case "throw": + front.reject(value); + break; + + default: + front.resolve({ + value: value, + done: false + }); + break; + } + + front = front.next; + + if (front) { + resume(front.key, front.arg); + } else { + back = null; + } + } + + this._invoke = send; + + if (typeof gen.return !== "function") { + this.return = undefined; + } + } + + if (typeof Symbol === "function" && Symbol.asyncIterator) { + _AsyncGenerator.prototype[Symbol.asyncIterator] = function () { + return this; + }; + } + + _AsyncGenerator.prototype.next = function (arg) { + return this._invoke("next", arg); + }; + + _AsyncGenerator.prototype.throw = function (arg) { + return this._invoke("throw", arg); + }; + + _AsyncGenerator.prototype.return = function (arg) { + return this._invoke("return", arg); + }; + + function _wrapAsyncGenerator(fn) { + return function () { + return new _AsyncGenerator(fn.apply(this, arguments)); + }; + } + + function _awaitAsyncGenerator(value) { + return new _AwaitValue(value); + } + + function _asyncGeneratorDelegate(inner, awaitWrap) { + var iter = {}, + waiting = false; + + function pump(key, value) { + waiting = true; + value = new Promise(function (resolve) { + resolve(inner[key](value)); + }); + return { + done: false, + value: awaitWrap(value) + }; + } + + ; + + if (typeof Symbol === "function" && Symbol.iterator) { + iter[Symbol.iterator] = function () { + return this; + }; + } + + iter.next = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("next", value); + }; + + if (typeof inner.throw === "function") { + iter.throw = function (value) { + if (waiting) { + waiting = false; + throw value; + } + + return pump("throw", value); + }; + } + + if (typeof inner.return === "function") { + iter.return = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("return", value); + }; + } + + return iter; + } + + function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { + try { + var info = gen[key](arg); + var value = info.value; + } catch (error) { + reject(error); + return; + } + + if (info.done) { + resolve(value); + } else { + Promise.resolve(value).then(_next, _throw); + } + } + + function _asyncToGenerator(fn) { + return function () { + var self = this, + args = arguments; + return new Promise(function (resolve, reject) { + var gen = fn.apply(self, args); + + function _next(value) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); + } + + function _throw(err) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); + } + + _next(undefined); + }); + }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; + } + + function _defineEnumerableProperties(obj, descs) { + for (var key in descs) { + var desc = descs[key]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, key, desc); + } + + if (Object.getOwnPropertySymbols) { + var objectSymbols = Object.getOwnPropertySymbols(descs); + + for (var i = 0; i < objectSymbols.length; i++) { + var sym = objectSymbols[i]; + var desc = descs[sym]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, sym, desc); + } + } + + return obj; + } + + function _defaults(obj, defaults) { + var keys = Object.getOwnPropertyNames(defaults); + + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var value = Object.getOwnPropertyDescriptor(defaults, key); + + if (value && value.configurable && obj[key] === undefined) { + Object.defineProperty(obj, key, value); + } + } + + return obj; + } + + function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; + } + + function _extends() { + _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + + return _extends.apply(this, arguments); + } + + function _objectSpread(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? Object(arguments[i]) : {}; + var ownKeys = Object.keys(source); + + if (typeof Object.getOwnPropertySymbols === 'function') { + ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { + return Object.getOwnPropertyDescriptor(source, sym).enumerable; + })); + } + + ownKeys.forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } + + return target; + } + + function ownKeys(object, enumerableOnly) { + var keys = Object.keys(object); + + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(object); + if (enumerableOnly) symbols = symbols.filter(function (sym) { + return Object.getOwnPropertyDescriptor(object, sym).enumerable; + }); + keys.push.apply(keys, symbols); + } + + return keys; + } + + function _objectSpread2(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? arguments[i] : {}; + + if (i % 2) { + ownKeys(Object(source), true).forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } else if (Object.getOwnPropertyDescriptors) { + Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); + } else { + ownKeys(Object(source)).forEach(function (key) { + Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); + }); + } + } + + return target; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function"); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + writable: true, + configurable: true + } + }); + if (superClass) _setPrototypeOf(subClass, superClass); + } + + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + subClass.__proto__ = superClass; + } + + function _getPrototypeOf(o) { + _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { + return o.__proto__ || Object.getPrototypeOf(o); + }; + return _getPrototypeOf(o); + } + + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + + return _setPrototypeOf(o, p); + } + + function _isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + + try { + Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); + return true; + } catch (e) { + return false; + } + } + + function _construct(Parent, args, Class) { + if (_isNativeReflectConstruct()) { + _construct = Reflect.construct; + } else { + _construct = function _construct(Parent, args, Class) { + var a = [null]; + a.push.apply(a, args); + var Constructor = Function.bind.apply(Parent, a); + var instance = new Constructor(); + if (Class) _setPrototypeOf(instance, Class.prototype); + return instance; + }; + } + + return _construct.apply(null, arguments); + } + + function _isNativeFunction(fn) { + return Function.toString.call(fn).indexOf("[native code]") !== -1; + } + + function _wrapNativeSuper(Class) { + var _cache = typeof Map === "function" ? new Map() : undefined; + + _wrapNativeSuper = function _wrapNativeSuper(Class) { + if (Class === null || !_isNativeFunction(Class)) return Class; + + if (typeof Class !== "function") { + throw new TypeError("Super expression must either be null or a function"); + } + + if (typeof _cache !== "undefined") { + if (_cache.has(Class)) return _cache.get(Class); + + _cache.set(Class, Wrapper); + } + + function Wrapper() { + return _construct(Class, arguments, _getPrototypeOf(this).constructor); + } + + Wrapper.prototype = Object.create(Class.prototype, { + constructor: { + value: Wrapper, + enumerable: false, + writable: true, + configurable: true + } + }); + return _setPrototypeOf(Wrapper, Class); + }; + + return _wrapNativeSuper(Class); + } + + function _instanceof(left, right) { + if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { + return !!right[Symbol.hasInstance](left); + } else { + return left instanceof right; + } + } + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + + function _getRequireWildcardCache() { + if (typeof WeakMap !== "function") return null; + var cache = new WeakMap(); + + _getRequireWildcardCache = function () { + return cache; + }; + + return cache; + } + + function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } + + if (obj === null || typeof obj !== "object" && typeof obj !== "function") { + return { + default: obj + }; + } + + var cache = _getRequireWildcardCache(); + + if (cache && cache.has(obj)) { + return cache.get(obj); + } + + var newObj = {}; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + + if (desc && (desc.get || desc.set)) { + Object.defineProperty(newObj, key, desc); + } else { + newObj[key] = obj[key]; + } + } + } + + newObj.default = obj; + + if (cache) { + cache.set(obj, newObj); + } + + return newObj; + } + + function _newArrowCheck(innerThis, boundThis) { + if (innerThis !== boundThis) { + throw new TypeError("Cannot instantiate an arrow function"); + } + } + + function _objectDestructuringEmpty(obj) { + if (obj == null) throw new TypeError("Cannot destructure undefined"); + } + + function _objectWithoutPropertiesLoose(source, excluded) { + if (source == null) return {}; + var target = {}; + var sourceKeys = Object.keys(source); + var key, i; + + for (i = 0; i < sourceKeys.length; i++) { + key = sourceKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + target[key] = source[key]; + } + + return target; + } + + function _objectWithoutProperties(source, excluded) { + if (source == null) return {}; + + var target = _objectWithoutPropertiesLoose(source, excluded); + + var key, i; + + if (Object.getOwnPropertySymbols) { + var sourceSymbolKeys = Object.getOwnPropertySymbols(source); + + for (i = 0; i < sourceSymbolKeys.length; i++) { + key = sourceSymbolKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; + target[key] = source[key]; + } + } + + return target; + } + + function _assertThisInitialized(self) { + if (self === void 0) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return self; + } + + function _possibleConstructorReturn(self, call) { + if (call && (typeof call === "object" || typeof call === "function")) { + return call; + } + + return _assertThisInitialized(self); + } + + function _createSuper(Derived) { + var hasNativeReflectConstruct = _isNativeReflectConstruct(); + + return function _createSuperInternal() { + var Super = _getPrototypeOf(Derived), + result; + + if (hasNativeReflectConstruct) { + var NewTarget = _getPrototypeOf(this).constructor; + + result = Reflect.construct(Super, arguments, NewTarget); + } else { + result = Super.apply(this, arguments); + } + + return _possibleConstructorReturn(this, result); + }; + } + + function _superPropBase(object, property) { + while (!Object.prototype.hasOwnProperty.call(object, property)) { + object = _getPrototypeOf(object); + if (object === null) break; + } + + return object; + } + + function _get(target, property, receiver) { + if (typeof Reflect !== "undefined" && Reflect.get) { + _get = Reflect.get; + } else { + _get = function _get(target, property, receiver) { + var base = _superPropBase(target, property); + + if (!base) return; + var desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.get) { + return desc.get.call(receiver); + } + + return desc.value; + }; + } + + return _get(target, property, receiver || target); + } + + function set(target, property, value, receiver) { + if (typeof Reflect !== "undefined" && Reflect.set) { + set = Reflect.set; + } else { + set = function set(target, property, value, receiver) { + var base = _superPropBase(target, property); + + var desc; + + if (base) { + desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.set) { + desc.set.call(receiver, value); + return true; + } else if (!desc.writable) { + return false; + } + } + + desc = Object.getOwnPropertyDescriptor(receiver, property); + + if (desc) { + if (!desc.writable) { + return false; + } + + desc.value = value; + Object.defineProperty(receiver, property, desc); + } else { + _defineProperty(receiver, property, value); + } + + return true; + }; + } + + return set(target, property, value, receiver); + } + + function _set(target, property, value, receiver, isStrict) { + var s = set(target, property, value, receiver || target); + + if (!s && isStrict) { + throw new Error('failed to set property'); + } + + return value; + } + + function _taggedTemplateLiteral(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + return Object.freeze(Object.defineProperties(strings, { + raw: { + value: Object.freeze(raw) + } + })); + } + + function _taggedTemplateLiteralLoose(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + strings.raw = raw; + return strings; + } + + function _readOnlyError(name) { + throw new Error("\"" + name + "\" is read-only"); + } + + function _classNameTDZError(name) { + throw new Error("Class \"" + name + "\" cannot be referenced in computed property keys."); + } + + function _temporalUndefined() {} + + function _tdz(name) { + throw new ReferenceError(name + " is not defined - temporal dead zone"); + } + + function _temporalRef(val, name) { + return val === _temporalUndefined ? _tdz(name) : val; + } + + function _slicedToArray(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); + } + + function _slicedToArrayLoose(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimitLoose(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); + } + + function _toArray(arr) { + return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); + } + + function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); + } + + function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) return _arrayLikeToArray(arr); + } + + function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; + } + + function _maybeArrayLike(next, arr, i) { + if (arr && !Array.isArray(arr) && typeof arr.length === "number") { + var len = arr.length; + return _arrayLikeToArray(arr, i !== void 0 && i < len ? i : len); + } + + return next(arr, i); + } + + function _iterableToArray(iter) { + if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); + } + + function _iterableToArrayLimit(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"] != null) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; + } + + function _iterableToArrayLimitLoose(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + + for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { + _arr.push(_step.value); + + if (i && _arr.length === i) break; + } + + return _arr; + } + + function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if (typeof o === "string") return _arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + if (n === "Object" && o.constructor) n = o.constructor.name; + if (n === "Map" || n === "Set") return Array.from(o); + if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); + } + + function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) len = arr.length; + + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + + return arr2; + } + + function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + function _createForOfIteratorHelper(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + + var F = function () {}; + + return { + s: F, + n: function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }, + e: function (e) { + throw e; + }, + f: F + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + var normalCompletion = true, + didErr = false, + err; + return { + s: function () { + it = o[Symbol.iterator](); + }, + n: function () { + var step = it.next(); + normalCompletion = step.done; + return step; + }, + e: function (e) { + didErr = true; + err = e; + }, + f: function () { + try { + if (!normalCompletion && it.return != null) it.return(); + } finally { + if (didErr) throw err; + } + } + }; + } + + function _createForOfIteratorHelperLoose(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + return function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + it = o[Symbol.iterator](); + return it.next.bind(it); + } + + function _skipFirstGeneratorNext(fn) { + return function () { + var it = fn.apply(this, arguments); + it.next(); + return it; + }; + } + + function _toPrimitive(input, hint) { + if (typeof input !== "object" || input === null) return input; + var prim = input[Symbol.toPrimitive]; + + if (prim !== undefined) { + var res = prim.call(input, hint || "default"); + if (typeof res !== "object") return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + + return (hint === "string" ? String : Number)(input); + } + + function _toPropertyKey(arg) { + var key = _toPrimitive(arg, "string"); + + return typeof key === "symbol" ? key : String(key); + } + + function _initializerWarningHelper(descriptor, context) { + throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.'); + } + + function _initializerDefineProperty(target, property, descriptor, context) { + if (!descriptor) return; + Object.defineProperty(target, property, { + enumerable: descriptor.enumerable, + configurable: descriptor.configurable, + writable: descriptor.writable, + value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 + }); + } + + function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { + var desc = {}; + Object.keys(descriptor).forEach(function (key) { + desc[key] = descriptor[key]; + }); + desc.enumerable = !!desc.enumerable; + desc.configurable = !!desc.configurable; + + if ('value' in desc || desc.initializer) { + desc.writable = true; + } + + desc = decorators.slice().reverse().reduce(function (desc, decorator) { + return decorator(target, property, desc) || desc; + }, desc); + + if (context && desc.initializer !== void 0) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = undefined; + } + + if (desc.initializer === void 0) { + Object.defineProperty(target, property, desc); + desc = null; + } + + return desc; + } + + var id = 0; + + function _classPrivateFieldLooseKey(name) { + return "__private_" + id++ + "_" + name; + } + + function _classPrivateFieldLooseBase(receiver, privateKey) { + if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { + throw new TypeError("attempted to use private field on non-instance"); + } + + return receiver; + } + + function _classPrivateFieldGet(receiver, privateMap) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to get private field on non-instance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; + } + + function _classPrivateFieldSet(receiver, privateMap, value) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to set private field on non-instance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; + } + + function _classPrivateFieldDestructureSet(receiver, privateMap) { + if (!privateMap.has(receiver)) { + throw new TypeError("attempted to set private field on non-instance"); + } + + var descriptor = privateMap.get(receiver); + + if (descriptor.set) { + if (!("__destrObj" in descriptor)) { + descriptor.__destrObj = { + set value(v) { + descriptor.set.call(receiver, v); + } + + }; + } + + return descriptor.__destrObj; + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + return descriptor; + } + } + + function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; + } + + function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; + } + + function _classStaticPrivateMethodGet(receiver, classConstructor, method) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + return method; + } + + function _classStaticPrivateMethodSet() { + throw new TypeError("attempted to set read only static private field"); + } + + function _decorate(decorators, factory, superClass, mixins) { + var api = _getDecoratorsApi(); + + if (mixins) { + for (var i = 0; i < mixins.length; i++) { + api = mixins[i](api); + } + } + + var r = factory(function initialize(O) { + api.initializeInstanceElements(O, decorated.elements); + }, superClass); + var decorated = api.decorateClass(_coalesceClassElements(r.d.map(_createElementDescriptor)), decorators); + api.initializeClassElements(r.F, decorated.elements); + return api.runClassFinishers(r.F, decorated.finishers); + } + + function _getDecoratorsApi() { + _getDecoratorsApi = function () { + return api; + }; + + var api = { + elementsDefinitionOrder: [["method"], ["field"]], + initializeInstanceElements: function (O, elements) { + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + if (element.kind === kind && element.placement === "own") { + this.defineClassElement(O, element); + } + }, this); + }, this); + }, + initializeClassElements: function (F, elements) { + var proto = F.prototype; + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + var placement = element.placement; + + if (element.kind === kind && (placement === "static" || placement === "prototype")) { + var receiver = placement === "static" ? F : proto; + this.defineClassElement(receiver, element); + } + }, this); + }, this); + }, + defineClassElement: function (receiver, element) { + var descriptor = element.descriptor; + + if (element.kind === "field") { + var initializer = element.initializer; + descriptor = { + enumerable: descriptor.enumerable, + writable: descriptor.writable, + configurable: descriptor.configurable, + value: initializer === void 0 ? void 0 : initializer.call(receiver) + }; + } + + Object.defineProperty(receiver, element.key, descriptor); + }, + decorateClass: function (elements, decorators) { + var newElements = []; + var finishers = []; + var placements = { + static: [], + prototype: [], + own: [] + }; + elements.forEach(function (element) { + this.addElementPlacement(element, placements); + }, this); + elements.forEach(function (element) { + if (!_hasDecorators(element)) return newElements.push(element); + var elementFinishersExtras = this.decorateElement(element, placements); + newElements.push(elementFinishersExtras.element); + newElements.push.apply(newElements, elementFinishersExtras.extras); + finishers.push.apply(finishers, elementFinishersExtras.finishers); + }, this); + + if (!decorators) { + return { + elements: newElements, + finishers: finishers + }; + } + + var result = this.decorateConstructor(newElements, decorators); + finishers.push.apply(finishers, result.finishers); + result.finishers = finishers; + return result; + }, + addElementPlacement: function (element, placements, silent) { + var keys = placements[element.placement]; + + if (!silent && keys.indexOf(element.key) !== -1) { + throw new TypeError("Duplicated element (" + element.key + ")"); + } + + keys.push(element.key); + }, + decorateElement: function (element, placements) { + var extras = []; + var finishers = []; + + for (var decorators = element.decorators, i = decorators.length - 1; i >= 0; i--) { + var keys = placements[element.placement]; + keys.splice(keys.indexOf(element.key), 1); + var elementObject = this.fromElementDescriptor(element); + var elementFinisherExtras = this.toElementFinisherExtras((0, decorators[i])(elementObject) || elementObject); + element = elementFinisherExtras.element; + this.addElementPlacement(element, placements); + + if (elementFinisherExtras.finisher) { + finishers.push(elementFinisherExtras.finisher); + } + + var newExtras = elementFinisherExtras.extras; + + if (newExtras) { + for (var j = 0; j < newExtras.length; j++) { + this.addElementPlacement(newExtras[j], placements); + } + + extras.push.apply(extras, newExtras); + } + } + + return { + element: element, + finishers: finishers, + extras: extras + }; + }, + decorateConstructor: function (elements, decorators) { + var finishers = []; + + for (var i = decorators.length - 1; i >= 0; i--) { + var obj = this.fromClassDescriptor(elements); + var elementsAndFinisher = this.toClassDescriptor((0, decorators[i])(obj) || obj); + + if (elementsAndFinisher.finisher !== undefined) { + finishers.push(elementsAndFinisher.finisher); + } + + if (elementsAndFinisher.elements !== undefined) { + elements = elementsAndFinisher.elements; + + for (var j = 0; j < elements.length - 1; j++) { + for (var k = j + 1; k < elements.length; k++) { + if (elements[j].key === elements[k].key && elements[j].placement === elements[k].placement) { + throw new TypeError("Duplicated element (" + elements[j].key + ")"); + } + } + } + } + } + + return { + elements: elements, + finishers: finishers + }; + }, + fromElementDescriptor: function (element) { + var obj = { + kind: element.kind, + key: element.key, + placement: element.placement, + descriptor: element.descriptor + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + if (element.kind === "field") obj.initializer = element.initializer; + return obj; + }, + toElementDescriptors: function (elementObjects) { + if (elementObjects === undefined) return; + return _toArray(elementObjects).map(function (elementObject) { + var element = this.toElementDescriptor(elementObject); + this.disallowProperty(elementObject, "finisher", "An element descriptor"); + this.disallowProperty(elementObject, "extras", "An element descriptor"); + return element; + }, this); + }, + toElementDescriptor: function (elementObject) { + var kind = String(elementObject.kind); + + if (kind !== "method" && kind !== "field") { + throw new TypeError('An element descriptor\'s .kind property must be either "method" or' + ' "field", but a decorator created an element descriptor with' + ' .kind "' + kind + '"'); + } + + var key = _toPropertyKey(elementObject.key); + + var placement = String(elementObject.placement); + + if (placement !== "static" && placement !== "prototype" && placement !== "own") { + throw new TypeError('An element descriptor\'s .placement property must be one of "static",' + ' "prototype" or "own", but a decorator created an element descriptor' + ' with .placement "' + placement + '"'); + } + + var descriptor = elementObject.descriptor; + this.disallowProperty(elementObject, "elements", "An element descriptor"); + var element = { + kind: kind, + key: key, + placement: placement, + descriptor: Object.assign({}, descriptor) + }; + + if (kind !== "field") { + this.disallowProperty(elementObject, "initializer", "A method descriptor"); + } else { + this.disallowProperty(descriptor, "get", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "set", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "value", "The property descriptor of a field descriptor"); + element.initializer = elementObject.initializer; + } + + return element; + }, + toElementFinisherExtras: function (elementObject) { + var element = this.toElementDescriptor(elementObject); + + var finisher = _optionalCallableProperty(elementObject, "finisher"); + + var extras = this.toElementDescriptors(elementObject.extras); + return { + element: element, + finisher: finisher, + extras: extras + }; + }, + fromClassDescriptor: function (elements) { + var obj = { + kind: "class", + elements: elements.map(this.fromElementDescriptor, this) + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + return obj; + }, + toClassDescriptor: function (obj) { + var kind = String(obj.kind); + + if (kind !== "class") { + throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator' + ' created a class descriptor with .kind "' + kind + '"'); + } + + this.disallowProperty(obj, "key", "A class descriptor"); + this.disallowProperty(obj, "placement", "A class descriptor"); + this.disallowProperty(obj, "descriptor", "A class descriptor"); + this.disallowProperty(obj, "initializer", "A class descriptor"); + this.disallowProperty(obj, "extras", "A class descriptor"); + + var finisher = _optionalCallableProperty(obj, "finisher"); + + var elements = this.toElementDescriptors(obj.elements); + return { + elements: elements, + finisher: finisher + }; + }, + runClassFinishers: function (constructor, finishers) { + for (var i = 0; i < finishers.length; i++) { + var newConstructor = (0, finishers[i])(constructor); + + if (newConstructor !== undefined) { + if (typeof newConstructor !== "function") { + throw new TypeError("Finishers must return a constructor."); + } + + constructor = newConstructor; + } + } + + return constructor; + }, + disallowProperty: function (obj, name, objectType) { + if (obj[name] !== undefined) { + throw new TypeError(objectType + " can't have a ." + name + " property."); + } + } + }; + return api; + } + + function _createElementDescriptor(def) { + var key = _toPropertyKey(def.key); + + var descriptor; + + if (def.kind === "method") { + descriptor = { + value: def.value, + writable: true, + configurable: true, + enumerable: false + }; + } else if (def.kind === "get") { + descriptor = { + get: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "set") { + descriptor = { + set: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "field") { + descriptor = { + configurable: true, + writable: true, + enumerable: true + }; + } + + var element = { + kind: def.kind === "field" ? "field" : "method", + key: key, + placement: def.static ? "static" : def.kind === "field" ? "own" : "prototype", + descriptor: descriptor + }; + if (def.decorators) element.decorators = def.decorators; + if (def.kind === "field") element.initializer = def.value; + return element; + } + + function _coalesceGetterSetter(element, other) { + if (element.descriptor.get !== undefined) { + other.descriptor.get = element.descriptor.get; + } else { + other.descriptor.set = element.descriptor.set; + } + } + + function _coalesceClassElements(elements) { + var newElements = []; + + var isSameElement = function (other) { + return other.kind === "method" && other.key === element.key && other.placement === element.placement; + }; + + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + var other; + + if (element.kind === "method" && (other = newElements.find(isSameElement))) { + if (_isDataDescriptor(element.descriptor) || _isDataDescriptor(other.descriptor)) { + if (_hasDecorators(element) || _hasDecorators(other)) { + throw new ReferenceError("Duplicated methods (" + element.key + ") can't be decorated."); + } + + other.descriptor = element.descriptor; + } else { + if (_hasDecorators(element)) { + if (_hasDecorators(other)) { + throw new ReferenceError("Decorators can't be placed on different accessors with for " + "the same property (" + element.key + ")."); + } + + other.decorators = element.decorators; + } + + _coalesceGetterSetter(element, other); + } + } else { + newElements.push(element); + } + } + + return newElements; + } + + function _hasDecorators(element) { + return element.decorators && element.decorators.length; + } + + function _isDataDescriptor(desc) { + return desc !== undefined && !(desc.value === undefined && desc.writable === undefined); + } + + function _optionalCallableProperty(obj, name) { + var value = obj[name]; + + if (value !== undefined && typeof value !== "function") { + throw new TypeError("Expected '" + name + "' to be a function"); + } + + return value; + } + + function _classPrivateMethodGet(receiver, privateSet, fn) { + if (!privateSet.has(receiver)) { + throw new TypeError("attempted to get private field on non-instance"); + } + + return fn; + } + + function _classPrivateMethodSet() { + throw new TypeError("attempted to reassign private method"); + } + + function _wrapRegExp(re, groups) { + _wrapRegExp = function (re, groups) { + return new BabelRegExp(re, undefined, groups); + }; + + var _RegExp = _wrapNativeSuper(RegExp); + + var _super = RegExp.prototype; + + var _groups = new WeakMap(); + + function BabelRegExp(re, flags, groups) { + var _this = _RegExp.call(this, re, flags); + + _groups.set(_this, groups || _groups.get(re)); + + return _this; + } + + _inherits(BabelRegExp, _RegExp); + + BabelRegExp.prototype.exec = function (str) { + var result = _super.exec.call(this, str); + + if (result) result.groups = buildGroups(result, this); + return result; + }; + + BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { + if (typeof substitution === "string") { + var groups = _groups.get(this); + + return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { + return "$" + groups[name]; + })); + } else if (typeof substitution === "function") { + var _this = this; + + return _super[Symbol.replace].call(this, str, function () { + var args = []; + args.push.apply(args, arguments); + + if (typeof args[args.length - 1] !== "object") { + args.push(buildGroups(args, _this)); + } + + return substitution.apply(this, args); + }); + } else { + return _super[Symbol.replace].call(this, str, substitution); + } + }; + + function buildGroups(result, re) { + var g = _groups.get(re); + + return Object.keys(g).reduce(function (groups, name) { + groups[name] = result[g[name]]; + return groups; + }, Object.create(null)); + } + + return _wrapRegExp.apply(this, arguments); + } + + var eyedropperIcon = "eyedropper-icon.xml"; + + var extEyedropper = exports('default', { + name: 'eyedropper', + init: function init(S) { + var _this = this; + + return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { + var strings, svgEditor, $, ChangeElementCommand, svgCanvas, addToHistory, currentStyle, getStyle, buttons; + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + getStyle = function _getStyle(opts) { + // if we are in eyedropper mode, we don't want to disable the eye-dropper tool + var mode = svgCanvas.getMode(); + + if (mode === 'eyedropper') { + return; + } + + var tool = $('#tool_eyedropper'); // enable-eye-dropper if one element is selected + + var elem = null; + + if (!opts.multiselected && opts.elems[0] && !['svg', 'g', 'use'].includes(opts.elems[0].nodeName)) { + elem = opts.elems[0]; + tool.removeClass('disabled'); // grab the current style + + currentStyle.fillPaint = elem.getAttribute('fill') || 'black'; + currentStyle.fillOpacity = elem.getAttribute('fill-opacity') || 1.0; + currentStyle.strokePaint = elem.getAttribute('stroke'); + currentStyle.strokeOpacity = elem.getAttribute('stroke-opacity') || 1.0; + currentStyle.strokeWidth = elem.getAttribute('stroke-width'); + currentStyle.strokeDashArray = elem.getAttribute('stroke-dasharray'); + currentStyle.strokeLinecap = elem.getAttribute('stroke-linecap'); + currentStyle.strokeLinejoin = elem.getAttribute('stroke-linejoin'); + currentStyle.opacity = elem.getAttribute('opacity') || 1.0; // disable eye-dropper tool + } else { + tool.addClass('disabled'); + } + }; + + _context.next = 3; + return S.importLocale(); + + case 3: + strings = _context.sent; + svgEditor = _this; + $ = S.$, ChangeElementCommand = S.ChangeElementCommand, svgCanvas = svgEditor.canvas, addToHistory = function addToHistory(cmd) { + svgCanvas.undoMgr.addCommandToHistory(cmd); + }, currentStyle = { + fillPaint: 'red', + fillOpacity: 1.0, + strokePaint: 'black', + strokeOpacity: 1.0, + strokeWidth: 5, + strokeDashArray: null, + opacity: 1.0, + strokeLinecap: 'butt', + strokeLinejoin: 'miter' + }; + /** + * + * @param {module:svgcanvas.SvgCanvas#event:ext_selectedChanged|module:svgcanvas.SvgCanvas#event:ext_elementChanged} opts + * @returns {void} + */ + + buttons = [{ + id: 'tool_eyedropper', + icon: svgEditor.curConfig.extIconsPath + 'eyedropper.png', + type: 'mode', + events: { + click: function click() { + svgCanvas.setMode('eyedropper'); + } + } + }]; + return _context.abrupt("return", { + name: strings.name, + svgicons: svgEditor.curConfig.extIconsPath + 'eyedropper-icon.xml', + buttons: strings.buttons.map(function (button, i) { + return Object.assign(buttons[i], button); + }), + // if we have selected an element, grab its paint and enable the eye dropper button + selectedChanged: getStyle, + elementChanged: getStyle, + mouseDown: function mouseDown(opts) { + var mode = svgCanvas.getMode(); + + if (mode === 'eyedropper') { + var e = opts.event; + var target = e.target; + + if (!['svg', 'g', 'use'].includes(target.nodeName)) { + var changes = {}; + + var change = function change(elem, attrname, newvalue) { + changes[attrname] = elem.getAttribute(attrname); + elem.setAttribute(attrname, newvalue); + }; + + if (currentStyle.fillPaint) { + change(target, 'fill', currentStyle.fillPaint); + } + + if (currentStyle.fillOpacity) { + change(target, 'fill-opacity', currentStyle.fillOpacity); + } + + if (currentStyle.strokePaint) { + change(target, 'stroke', currentStyle.strokePaint); + } + + if (currentStyle.strokeOpacity) { + change(target, 'stroke-opacity', currentStyle.strokeOpacity); + } + + if (currentStyle.strokeWidth) { + change(target, 'stroke-width', currentStyle.strokeWidth); + } + + if (currentStyle.strokeDashArray) { + change(target, 'stroke-dasharray', currentStyle.strokeDashArray); + } + + if (currentStyle.opacity) { + change(target, 'opacity', currentStyle.opacity); + } + + if (currentStyle.strokeLinecap) { + change(target, 'stroke-linecap', currentStyle.strokeLinecap); + } + + if (currentStyle.strokeLinejoin) { + change(target, 'stroke-linejoin', currentStyle.strokeLinejoin); + } + + addToHistory(new ChangeElementCommand(target, changes)); + } + } + } + }); + + case 8: + case "end": + return _context.stop(); + } + } + }, _callee); + }))(); + } + }); + + } + }; +}); diff --git a/dist/editor/system/extensions/ext-foreignobject.js b/dist/editor/system/extensions/ext-foreignobject.js new file mode 100644 index 00000000..e37f723c --- /dev/null +++ b/dist/editor/system/extensions/ext-foreignobject.js @@ -0,0 +1,1971 @@ +System.register([], function (exports) { + 'use strict'; + return { + execute: function () { + + function _typeof(obj) { + "@babel/helpers - typeof"; + + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function (obj) { + return typeof obj; + }; + } else { + _typeof = function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); + } + + var REACT_ELEMENT_TYPE; + + function _jsx(type, props, key, children) { + if (!REACT_ELEMENT_TYPE) { + REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol["for"] && Symbol["for"]("react.element") || 0xeac7; + } + + var defaultProps = type && type.defaultProps; + var childrenLength = arguments.length - 3; + + if (!props && childrenLength !== 0) { + props = { + children: void 0 + }; + } + + if (childrenLength === 1) { + props.children = children; + } else if (childrenLength > 1) { + var childArray = new Array(childrenLength); + + for (var i = 0; i < childrenLength; i++) { + childArray[i] = arguments[i + 3]; + } + + props.children = childArray; + } + + if (props && defaultProps) { + for (var propName in defaultProps) { + if (props[propName] === void 0) { + props[propName] = defaultProps[propName]; + } + } + } else if (!props) { + props = defaultProps || {}; + } + + return { + $$typeof: REACT_ELEMENT_TYPE, + type: type, + key: key === undefined ? null : '' + key, + ref: null, + props: props, + _owner: null + }; + } + + function _asyncIterator(iterable) { + var method; + + if (typeof Symbol !== "undefined") { + if (Symbol.asyncIterator) { + method = iterable[Symbol.asyncIterator]; + if (method != null) return method.call(iterable); + } + + if (Symbol.iterator) { + method = iterable[Symbol.iterator]; + if (method != null) return method.call(iterable); + } + } + + throw new TypeError("Object is not async iterable"); + } + + function _AwaitValue(value) { + this.wrapped = value; + } + + function _AsyncGenerator(gen) { + var front, back; + + function send(key, arg) { + return new Promise(function (resolve, reject) { + var request = { + key: key, + arg: arg, + resolve: resolve, + reject: reject, + next: null + }; + + if (back) { + back = back.next = request; + } else { + front = back = request; + resume(key, arg); + } + }); + } + + function resume(key, arg) { + try { + var result = gen[key](arg); + var value = result.value; + var wrappedAwait = value instanceof _AwaitValue; + Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { + if (wrappedAwait) { + resume(key === "return" ? "return" : "next", arg); + return; + } + + settle(result.done ? "return" : "normal", arg); + }, function (err) { + resume("throw", err); + }); + } catch (err) { + settle("throw", err); + } + } + + function settle(type, value) { + switch (type) { + case "return": + front.resolve({ + value: value, + done: true + }); + break; + + case "throw": + front.reject(value); + break; + + default: + front.resolve({ + value: value, + done: false + }); + break; + } + + front = front.next; + + if (front) { + resume(front.key, front.arg); + } else { + back = null; + } + } + + this._invoke = send; + + if (typeof gen.return !== "function") { + this.return = undefined; + } + } + + if (typeof Symbol === "function" && Symbol.asyncIterator) { + _AsyncGenerator.prototype[Symbol.asyncIterator] = function () { + return this; + }; + } + + _AsyncGenerator.prototype.next = function (arg) { + return this._invoke("next", arg); + }; + + _AsyncGenerator.prototype.throw = function (arg) { + return this._invoke("throw", arg); + }; + + _AsyncGenerator.prototype.return = function (arg) { + return this._invoke("return", arg); + }; + + function _wrapAsyncGenerator(fn) { + return function () { + return new _AsyncGenerator(fn.apply(this, arguments)); + }; + } + + function _awaitAsyncGenerator(value) { + return new _AwaitValue(value); + } + + function _asyncGeneratorDelegate(inner, awaitWrap) { + var iter = {}, + waiting = false; + + function pump(key, value) { + waiting = true; + value = new Promise(function (resolve) { + resolve(inner[key](value)); + }); + return { + done: false, + value: awaitWrap(value) + }; + } + + ; + + if (typeof Symbol === "function" && Symbol.iterator) { + iter[Symbol.iterator] = function () { + return this; + }; + } + + iter.next = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("next", value); + }; + + if (typeof inner.throw === "function") { + iter.throw = function (value) { + if (waiting) { + waiting = false; + throw value; + } + + return pump("throw", value); + }; + } + + if (typeof inner.return === "function") { + iter.return = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("return", value); + }; + } + + return iter; + } + + function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { + try { + var info = gen[key](arg); + var value = info.value; + } catch (error) { + reject(error); + return; + } + + if (info.done) { + resolve(value); + } else { + Promise.resolve(value).then(_next, _throw); + } + } + + function _asyncToGenerator(fn) { + return function () { + var self = this, + args = arguments; + return new Promise(function (resolve, reject) { + var gen = fn.apply(self, args); + + function _next(value) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); + } + + function _throw(err) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); + } + + _next(undefined); + }); + }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; + } + + function _defineEnumerableProperties(obj, descs) { + for (var key in descs) { + var desc = descs[key]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, key, desc); + } + + if (Object.getOwnPropertySymbols) { + var objectSymbols = Object.getOwnPropertySymbols(descs); + + for (var i = 0; i < objectSymbols.length; i++) { + var sym = objectSymbols[i]; + var desc = descs[sym]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, sym, desc); + } + } + + return obj; + } + + function _defaults(obj, defaults) { + var keys = Object.getOwnPropertyNames(defaults); + + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var value = Object.getOwnPropertyDescriptor(defaults, key); + + if (value && value.configurable && obj[key] === undefined) { + Object.defineProperty(obj, key, value); + } + } + + return obj; + } + + function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; + } + + function _extends() { + _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + + return _extends.apply(this, arguments); + } + + function _objectSpread(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? Object(arguments[i]) : {}; + var ownKeys = Object.keys(source); + + if (typeof Object.getOwnPropertySymbols === 'function') { + ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { + return Object.getOwnPropertyDescriptor(source, sym).enumerable; + })); + } + + ownKeys.forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } + + return target; + } + + function ownKeys(object, enumerableOnly) { + var keys = Object.keys(object); + + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(object); + if (enumerableOnly) symbols = symbols.filter(function (sym) { + return Object.getOwnPropertyDescriptor(object, sym).enumerable; + }); + keys.push.apply(keys, symbols); + } + + return keys; + } + + function _objectSpread2(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? arguments[i] : {}; + + if (i % 2) { + ownKeys(Object(source), true).forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } else if (Object.getOwnPropertyDescriptors) { + Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); + } else { + ownKeys(Object(source)).forEach(function (key) { + Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); + }); + } + } + + return target; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function"); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + writable: true, + configurable: true + } + }); + if (superClass) _setPrototypeOf(subClass, superClass); + } + + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + subClass.__proto__ = superClass; + } + + function _getPrototypeOf(o) { + _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { + return o.__proto__ || Object.getPrototypeOf(o); + }; + return _getPrototypeOf(o); + } + + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + + return _setPrototypeOf(o, p); + } + + function _isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + + try { + Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); + return true; + } catch (e) { + return false; + } + } + + function _construct(Parent, args, Class) { + if (_isNativeReflectConstruct()) { + _construct = Reflect.construct; + } else { + _construct = function _construct(Parent, args, Class) { + var a = [null]; + a.push.apply(a, args); + var Constructor = Function.bind.apply(Parent, a); + var instance = new Constructor(); + if (Class) _setPrototypeOf(instance, Class.prototype); + return instance; + }; + } + + return _construct.apply(null, arguments); + } + + function _isNativeFunction(fn) { + return Function.toString.call(fn).indexOf("[native code]") !== -1; + } + + function _wrapNativeSuper(Class) { + var _cache = typeof Map === "function" ? new Map() : undefined; + + _wrapNativeSuper = function _wrapNativeSuper(Class) { + if (Class === null || !_isNativeFunction(Class)) return Class; + + if (typeof Class !== "function") { + throw new TypeError("Super expression must either be null or a function"); + } + + if (typeof _cache !== "undefined") { + if (_cache.has(Class)) return _cache.get(Class); + + _cache.set(Class, Wrapper); + } + + function Wrapper() { + return _construct(Class, arguments, _getPrototypeOf(this).constructor); + } + + Wrapper.prototype = Object.create(Class.prototype, { + constructor: { + value: Wrapper, + enumerable: false, + writable: true, + configurable: true + } + }); + return _setPrototypeOf(Wrapper, Class); + }; + + return _wrapNativeSuper(Class); + } + + function _instanceof(left, right) { + if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { + return !!right[Symbol.hasInstance](left); + } else { + return left instanceof right; + } + } + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + + function _getRequireWildcardCache() { + if (typeof WeakMap !== "function") return null; + var cache = new WeakMap(); + + _getRequireWildcardCache = function () { + return cache; + }; + + return cache; + } + + function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } + + if (obj === null || typeof obj !== "object" && typeof obj !== "function") { + return { + default: obj + }; + } + + var cache = _getRequireWildcardCache(); + + if (cache && cache.has(obj)) { + return cache.get(obj); + } + + var newObj = {}; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + + if (desc && (desc.get || desc.set)) { + Object.defineProperty(newObj, key, desc); + } else { + newObj[key] = obj[key]; + } + } + } + + newObj.default = obj; + + if (cache) { + cache.set(obj, newObj); + } + + return newObj; + } + + function _newArrowCheck(innerThis, boundThis) { + if (innerThis !== boundThis) { + throw new TypeError("Cannot instantiate an arrow function"); + } + } + + function _objectDestructuringEmpty(obj) { + if (obj == null) throw new TypeError("Cannot destructure undefined"); + } + + function _objectWithoutPropertiesLoose(source, excluded) { + if (source == null) return {}; + var target = {}; + var sourceKeys = Object.keys(source); + var key, i; + + for (i = 0; i < sourceKeys.length; i++) { + key = sourceKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + target[key] = source[key]; + } + + return target; + } + + function _objectWithoutProperties(source, excluded) { + if (source == null) return {}; + + var target = _objectWithoutPropertiesLoose(source, excluded); + + var key, i; + + if (Object.getOwnPropertySymbols) { + var sourceSymbolKeys = Object.getOwnPropertySymbols(source); + + for (i = 0; i < sourceSymbolKeys.length; i++) { + key = sourceSymbolKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; + target[key] = source[key]; + } + } + + return target; + } + + function _assertThisInitialized(self) { + if (self === void 0) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return self; + } + + function _possibleConstructorReturn(self, call) { + if (call && (typeof call === "object" || typeof call === "function")) { + return call; + } + + return _assertThisInitialized(self); + } + + function _createSuper(Derived) { + var hasNativeReflectConstruct = _isNativeReflectConstruct(); + + return function _createSuperInternal() { + var Super = _getPrototypeOf(Derived), + result; + + if (hasNativeReflectConstruct) { + var NewTarget = _getPrototypeOf(this).constructor; + + result = Reflect.construct(Super, arguments, NewTarget); + } else { + result = Super.apply(this, arguments); + } + + return _possibleConstructorReturn(this, result); + }; + } + + function _superPropBase(object, property) { + while (!Object.prototype.hasOwnProperty.call(object, property)) { + object = _getPrototypeOf(object); + if (object === null) break; + } + + return object; + } + + function _get(target, property, receiver) { + if (typeof Reflect !== "undefined" && Reflect.get) { + _get = Reflect.get; + } else { + _get = function _get(target, property, receiver) { + var base = _superPropBase(target, property); + + if (!base) return; + var desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.get) { + return desc.get.call(receiver); + } + + return desc.value; + }; + } + + return _get(target, property, receiver || target); + } + + function set(target, property, value, receiver) { + if (typeof Reflect !== "undefined" && Reflect.set) { + set = Reflect.set; + } else { + set = function set(target, property, value, receiver) { + var base = _superPropBase(target, property); + + var desc; + + if (base) { + desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.set) { + desc.set.call(receiver, value); + return true; + } else if (!desc.writable) { + return false; + } + } + + desc = Object.getOwnPropertyDescriptor(receiver, property); + + if (desc) { + if (!desc.writable) { + return false; + } + + desc.value = value; + Object.defineProperty(receiver, property, desc); + } else { + _defineProperty(receiver, property, value); + } + + return true; + }; + } + + return set(target, property, value, receiver); + } + + function _set(target, property, value, receiver, isStrict) { + var s = set(target, property, value, receiver || target); + + if (!s && isStrict) { + throw new Error('failed to set property'); + } + + return value; + } + + function _taggedTemplateLiteral(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + return Object.freeze(Object.defineProperties(strings, { + raw: { + value: Object.freeze(raw) + } + })); + } + + function _taggedTemplateLiteralLoose(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + strings.raw = raw; + return strings; + } + + function _readOnlyError(name) { + throw new Error("\"" + name + "\" is read-only"); + } + + function _classNameTDZError(name) { + throw new Error("Class \"" + name + "\" cannot be referenced in computed property keys."); + } + + function _temporalUndefined() {} + + function _tdz(name) { + throw new ReferenceError(name + " is not defined - temporal dead zone"); + } + + function _temporalRef(val, name) { + return val === _temporalUndefined ? _tdz(name) : val; + } + + function _slicedToArray(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); + } + + function _slicedToArrayLoose(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimitLoose(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); + } + + function _toArray(arr) { + return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); + } + + function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); + } + + function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) return _arrayLikeToArray(arr); + } + + function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; + } + + function _maybeArrayLike(next, arr, i) { + if (arr && !Array.isArray(arr) && typeof arr.length === "number") { + var len = arr.length; + return _arrayLikeToArray(arr, i !== void 0 && i < len ? i : len); + } + + return next(arr, i); + } + + function _iterableToArray(iter) { + if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); + } + + function _iterableToArrayLimit(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"] != null) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; + } + + function _iterableToArrayLimitLoose(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + + for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { + _arr.push(_step.value); + + if (i && _arr.length === i) break; + } + + return _arr; + } + + function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if (typeof o === "string") return _arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + if (n === "Object" && o.constructor) n = o.constructor.name; + if (n === "Map" || n === "Set") return Array.from(o); + if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); + } + + function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) len = arr.length; + + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + + return arr2; + } + + function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + function _createForOfIteratorHelper(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + + var F = function () {}; + + return { + s: F, + n: function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }, + e: function (e) { + throw e; + }, + f: F + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + var normalCompletion = true, + didErr = false, + err; + return { + s: function () { + it = o[Symbol.iterator](); + }, + n: function () { + var step = it.next(); + normalCompletion = step.done; + return step; + }, + e: function (e) { + didErr = true; + err = e; + }, + f: function () { + try { + if (!normalCompletion && it.return != null) it.return(); + } finally { + if (didErr) throw err; + } + } + }; + } + + function _createForOfIteratorHelperLoose(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + return function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + it = o[Symbol.iterator](); + return it.next.bind(it); + } + + function _skipFirstGeneratorNext(fn) { + return function () { + var it = fn.apply(this, arguments); + it.next(); + return it; + }; + } + + function _toPrimitive(input, hint) { + if (typeof input !== "object" || input === null) return input; + var prim = input[Symbol.toPrimitive]; + + if (prim !== undefined) { + var res = prim.call(input, hint || "default"); + if (typeof res !== "object") return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + + return (hint === "string" ? String : Number)(input); + } + + function _toPropertyKey(arg) { + var key = _toPrimitive(arg, "string"); + + return typeof key === "symbol" ? key : String(key); + } + + function _initializerWarningHelper(descriptor, context) { + throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.'); + } + + function _initializerDefineProperty(target, property, descriptor, context) { + if (!descriptor) return; + Object.defineProperty(target, property, { + enumerable: descriptor.enumerable, + configurable: descriptor.configurable, + writable: descriptor.writable, + value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 + }); + } + + function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { + var desc = {}; + Object.keys(descriptor).forEach(function (key) { + desc[key] = descriptor[key]; + }); + desc.enumerable = !!desc.enumerable; + desc.configurable = !!desc.configurable; + + if ('value' in desc || desc.initializer) { + desc.writable = true; + } + + desc = decorators.slice().reverse().reduce(function (desc, decorator) { + return decorator(target, property, desc) || desc; + }, desc); + + if (context && desc.initializer !== void 0) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = undefined; + } + + if (desc.initializer === void 0) { + Object.defineProperty(target, property, desc); + desc = null; + } + + return desc; + } + + var id = 0; + + function _classPrivateFieldLooseKey(name) { + return "__private_" + id++ + "_" + name; + } + + function _classPrivateFieldLooseBase(receiver, privateKey) { + if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { + throw new TypeError("attempted to use private field on non-instance"); + } + + return receiver; + } + + function _classPrivateFieldGet(receiver, privateMap) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to get private field on non-instance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; + } + + function _classPrivateFieldSet(receiver, privateMap, value) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to set private field on non-instance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; + } + + function _classPrivateFieldDestructureSet(receiver, privateMap) { + if (!privateMap.has(receiver)) { + throw new TypeError("attempted to set private field on non-instance"); + } + + var descriptor = privateMap.get(receiver); + + if (descriptor.set) { + if (!("__destrObj" in descriptor)) { + descriptor.__destrObj = { + set value(v) { + descriptor.set.call(receiver, v); + } + + }; + } + + return descriptor.__destrObj; + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + return descriptor; + } + } + + function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; + } + + function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; + } + + function _classStaticPrivateMethodGet(receiver, classConstructor, method) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + return method; + } + + function _classStaticPrivateMethodSet() { + throw new TypeError("attempted to set read only static private field"); + } + + function _decorate(decorators, factory, superClass, mixins) { + var api = _getDecoratorsApi(); + + if (mixins) { + for (var i = 0; i < mixins.length; i++) { + api = mixins[i](api); + } + } + + var r = factory(function initialize(O) { + api.initializeInstanceElements(O, decorated.elements); + }, superClass); + var decorated = api.decorateClass(_coalesceClassElements(r.d.map(_createElementDescriptor)), decorators); + api.initializeClassElements(r.F, decorated.elements); + return api.runClassFinishers(r.F, decorated.finishers); + } + + function _getDecoratorsApi() { + _getDecoratorsApi = function () { + return api; + }; + + var api = { + elementsDefinitionOrder: [["method"], ["field"]], + initializeInstanceElements: function (O, elements) { + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + if (element.kind === kind && element.placement === "own") { + this.defineClassElement(O, element); + } + }, this); + }, this); + }, + initializeClassElements: function (F, elements) { + var proto = F.prototype; + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + var placement = element.placement; + + if (element.kind === kind && (placement === "static" || placement === "prototype")) { + var receiver = placement === "static" ? F : proto; + this.defineClassElement(receiver, element); + } + }, this); + }, this); + }, + defineClassElement: function (receiver, element) { + var descriptor = element.descriptor; + + if (element.kind === "field") { + var initializer = element.initializer; + descriptor = { + enumerable: descriptor.enumerable, + writable: descriptor.writable, + configurable: descriptor.configurable, + value: initializer === void 0 ? void 0 : initializer.call(receiver) + }; + } + + Object.defineProperty(receiver, element.key, descriptor); + }, + decorateClass: function (elements, decorators) { + var newElements = []; + var finishers = []; + var placements = { + static: [], + prototype: [], + own: [] + }; + elements.forEach(function (element) { + this.addElementPlacement(element, placements); + }, this); + elements.forEach(function (element) { + if (!_hasDecorators(element)) return newElements.push(element); + var elementFinishersExtras = this.decorateElement(element, placements); + newElements.push(elementFinishersExtras.element); + newElements.push.apply(newElements, elementFinishersExtras.extras); + finishers.push.apply(finishers, elementFinishersExtras.finishers); + }, this); + + if (!decorators) { + return { + elements: newElements, + finishers: finishers + }; + } + + var result = this.decorateConstructor(newElements, decorators); + finishers.push.apply(finishers, result.finishers); + result.finishers = finishers; + return result; + }, + addElementPlacement: function (element, placements, silent) { + var keys = placements[element.placement]; + + if (!silent && keys.indexOf(element.key) !== -1) { + throw new TypeError("Duplicated element (" + element.key + ")"); + } + + keys.push(element.key); + }, + decorateElement: function (element, placements) { + var extras = []; + var finishers = []; + + for (var decorators = element.decorators, i = decorators.length - 1; i >= 0; i--) { + var keys = placements[element.placement]; + keys.splice(keys.indexOf(element.key), 1); + var elementObject = this.fromElementDescriptor(element); + var elementFinisherExtras = this.toElementFinisherExtras((0, decorators[i])(elementObject) || elementObject); + element = elementFinisherExtras.element; + this.addElementPlacement(element, placements); + + if (elementFinisherExtras.finisher) { + finishers.push(elementFinisherExtras.finisher); + } + + var newExtras = elementFinisherExtras.extras; + + if (newExtras) { + for (var j = 0; j < newExtras.length; j++) { + this.addElementPlacement(newExtras[j], placements); + } + + extras.push.apply(extras, newExtras); + } + } + + return { + element: element, + finishers: finishers, + extras: extras + }; + }, + decorateConstructor: function (elements, decorators) { + var finishers = []; + + for (var i = decorators.length - 1; i >= 0; i--) { + var obj = this.fromClassDescriptor(elements); + var elementsAndFinisher = this.toClassDescriptor((0, decorators[i])(obj) || obj); + + if (elementsAndFinisher.finisher !== undefined) { + finishers.push(elementsAndFinisher.finisher); + } + + if (elementsAndFinisher.elements !== undefined) { + elements = elementsAndFinisher.elements; + + for (var j = 0; j < elements.length - 1; j++) { + for (var k = j + 1; k < elements.length; k++) { + if (elements[j].key === elements[k].key && elements[j].placement === elements[k].placement) { + throw new TypeError("Duplicated element (" + elements[j].key + ")"); + } + } + } + } + } + + return { + elements: elements, + finishers: finishers + }; + }, + fromElementDescriptor: function (element) { + var obj = { + kind: element.kind, + key: element.key, + placement: element.placement, + descriptor: element.descriptor + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + if (element.kind === "field") obj.initializer = element.initializer; + return obj; + }, + toElementDescriptors: function (elementObjects) { + if (elementObjects === undefined) return; + return _toArray(elementObjects).map(function (elementObject) { + var element = this.toElementDescriptor(elementObject); + this.disallowProperty(elementObject, "finisher", "An element descriptor"); + this.disallowProperty(elementObject, "extras", "An element descriptor"); + return element; + }, this); + }, + toElementDescriptor: function (elementObject) { + var kind = String(elementObject.kind); + + if (kind !== "method" && kind !== "field") { + throw new TypeError('An element descriptor\'s .kind property must be either "method" or' + ' "field", but a decorator created an element descriptor with' + ' .kind "' + kind + '"'); + } + + var key = _toPropertyKey(elementObject.key); + + var placement = String(elementObject.placement); + + if (placement !== "static" && placement !== "prototype" && placement !== "own") { + throw new TypeError('An element descriptor\'s .placement property must be one of "static",' + ' "prototype" or "own", but a decorator created an element descriptor' + ' with .placement "' + placement + '"'); + } + + var descriptor = elementObject.descriptor; + this.disallowProperty(elementObject, "elements", "An element descriptor"); + var element = { + kind: kind, + key: key, + placement: placement, + descriptor: Object.assign({}, descriptor) + }; + + if (kind !== "field") { + this.disallowProperty(elementObject, "initializer", "A method descriptor"); + } else { + this.disallowProperty(descriptor, "get", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "set", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "value", "The property descriptor of a field descriptor"); + element.initializer = elementObject.initializer; + } + + return element; + }, + toElementFinisherExtras: function (elementObject) { + var element = this.toElementDescriptor(elementObject); + + var finisher = _optionalCallableProperty(elementObject, "finisher"); + + var extras = this.toElementDescriptors(elementObject.extras); + return { + element: element, + finisher: finisher, + extras: extras + }; + }, + fromClassDescriptor: function (elements) { + var obj = { + kind: "class", + elements: elements.map(this.fromElementDescriptor, this) + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + return obj; + }, + toClassDescriptor: function (obj) { + var kind = String(obj.kind); + + if (kind !== "class") { + throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator' + ' created a class descriptor with .kind "' + kind + '"'); + } + + this.disallowProperty(obj, "key", "A class descriptor"); + this.disallowProperty(obj, "placement", "A class descriptor"); + this.disallowProperty(obj, "descriptor", "A class descriptor"); + this.disallowProperty(obj, "initializer", "A class descriptor"); + this.disallowProperty(obj, "extras", "A class descriptor"); + + var finisher = _optionalCallableProperty(obj, "finisher"); + + var elements = this.toElementDescriptors(obj.elements); + return { + elements: elements, + finisher: finisher + }; + }, + runClassFinishers: function (constructor, finishers) { + for (var i = 0; i < finishers.length; i++) { + var newConstructor = (0, finishers[i])(constructor); + + if (newConstructor !== undefined) { + if (typeof newConstructor !== "function") { + throw new TypeError("Finishers must return a constructor."); + } + + constructor = newConstructor; + } + } + + return constructor; + }, + disallowProperty: function (obj, name, objectType) { + if (obj[name] !== undefined) { + throw new TypeError(objectType + " can't have a ." + name + " property."); + } + } + }; + return api; + } + + function _createElementDescriptor(def) { + var key = _toPropertyKey(def.key); + + var descriptor; + + if (def.kind === "method") { + descriptor = { + value: def.value, + writable: true, + configurable: true, + enumerable: false + }; + } else if (def.kind === "get") { + descriptor = { + get: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "set") { + descriptor = { + set: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "field") { + descriptor = { + configurable: true, + writable: true, + enumerable: true + }; + } + + var element = { + kind: def.kind === "field" ? "field" : "method", + key: key, + placement: def.static ? "static" : def.kind === "field" ? "own" : "prototype", + descriptor: descriptor + }; + if (def.decorators) element.decorators = def.decorators; + if (def.kind === "field") element.initializer = def.value; + return element; + } + + function _coalesceGetterSetter(element, other) { + if (element.descriptor.get !== undefined) { + other.descriptor.get = element.descriptor.get; + } else { + other.descriptor.set = element.descriptor.set; + } + } + + function _coalesceClassElements(elements) { + var newElements = []; + + var isSameElement = function (other) { + return other.kind === "method" && other.key === element.key && other.placement === element.placement; + }; + + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + var other; + + if (element.kind === "method" && (other = newElements.find(isSameElement))) { + if (_isDataDescriptor(element.descriptor) || _isDataDescriptor(other.descriptor)) { + if (_hasDecorators(element) || _hasDecorators(other)) { + throw new ReferenceError("Duplicated methods (" + element.key + ") can't be decorated."); + } + + other.descriptor = element.descriptor; + } else { + if (_hasDecorators(element)) { + if (_hasDecorators(other)) { + throw new ReferenceError("Decorators can't be placed on different accessors with for " + "the same property (" + element.key + ")."); + } + + other.decorators = element.decorators; + } + + _coalesceGetterSetter(element, other); + } + } else { + newElements.push(element); + } + } + + return newElements; + } + + function _hasDecorators(element) { + return element.decorators && element.decorators.length; + } + + function _isDataDescriptor(desc) { + return desc !== undefined && !(desc.value === undefined && desc.writable === undefined); + } + + function _optionalCallableProperty(obj, name) { + var value = obj[name]; + + if (value !== undefined && typeof value !== "function") { + throw new TypeError("Expected '" + name + "' to be a function"); + } + + return value; + } + + function _classPrivateMethodGet(receiver, privateSet, fn) { + if (!privateSet.has(receiver)) { + throw new TypeError("attempted to get private field on non-instance"); + } + + return fn; + } + + function _classPrivateMethodSet() { + throw new TypeError("attempted to reassign private method"); + } + + function _wrapRegExp(re, groups) { + _wrapRegExp = function (re, groups) { + return new BabelRegExp(re, undefined, groups); + }; + + var _RegExp = _wrapNativeSuper(RegExp); + + var _super = RegExp.prototype; + + var _groups = new WeakMap(); + + function BabelRegExp(re, flags, groups) { + var _this = _RegExp.call(this, re, flags); + + _groups.set(_this, groups || _groups.get(re)); + + return _this; + } + + _inherits(BabelRegExp, _RegExp); + + BabelRegExp.prototype.exec = function (str) { + var result = _super.exec.call(this, str); + + if (result) result.groups = buildGroups(result, this); + return result; + }; + + BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { + if (typeof substitution === "string") { + var groups = _groups.get(this); + + return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { + return "$" + groups[name]; + })); + } else if (typeof substitution === "function") { + var _this = this; + + return _super[Symbol.replace].call(this, str, function () { + var args = []; + args.push.apply(args, arguments); + + if (typeof args[args.length - 1] !== "object") { + args.push(buildGroups(args, _this)); + } + + return substitution.apply(this, args); + }); + } else { + return _super[Symbol.replace].call(this, str, substitution); + } + }; + + function buildGroups(result, re) { + var g = _groups.get(re); + + return Object.keys(g).reduce(function (groups, name) { + groups[name] = result[g[name]]; + return groups; + }, Object.create(null)); + } + + return _wrapRegExp.apply(this, arguments); + } + + var foreignobjectIcons = "foreignobject-icons.xml"; + + var extForeignobject = exports('default', { + name: 'foreignobject', + init: function init(S) { + var _this = this; + + return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() { + var svgEditor, $, text2xml, NS, importLocale, svgCanvas, svgdoc, strings, properlySourceSizeTextArea, showPanel, toggleSourceButtons, selElems, started, newFO, editingforeign, setForeignString, showForeignEditor, setAttr, buttons, contextTools; + return regeneratorRuntime.wrap(function _callee2$(_context2) { + while (1) { + switch (_context2.prev = _context2.next) { + case 0: + setAttr = function _setAttr(attr, val) { + svgCanvas.changeSelectedAttribute(attr, val); + svgCanvas.call('changed', selElems); + }; + + showForeignEditor = function _showForeignEditor() { + var elt = selElems[0]; + + if (!elt || editingforeign) { + return; + } + + editingforeign = true; + toggleSourceButtons(true); + elt.removeAttribute('fill'); + var str = svgCanvas.svgToString(elt, 0); + $('#svg_source_textarea').val(str); + $('#svg_source_editor').fadeIn(); + properlySourceSizeTextArea(); + $('#svg_source_textarea').focus(); + }; + + setForeignString = function _setForeignString(xmlString) { + var elt = selElems[0]; // The parent `Element` to append to + + try { + // convert string into XML document + var newDoc = text2xml('' + xmlString + ''); // run it through our sanitizer to remove anything we do not support + + svgCanvas.sanitizeSvg(newDoc.documentElement); + elt.replaceWith(svgdoc.importNode(newDoc.documentElement.firstChild, true)); + svgCanvas.call('changed', [elt]); + svgCanvas.clearSelection(); + } catch (e) { + // Todo: Surface error to user + console.log(e); // eslint-disable-line no-console + + return false; + } + + return true; + }; + + toggleSourceButtons = function _toggleSourceButtons(on) { + $('#tool_source_save, #tool_source_cancel').toggle(!on); + $('#foreign_save, #foreign_cancel').toggle(on); + }; + + showPanel = function _showPanel(on) { + var fcRules = $('#fc_rules'); + + if (!fcRules.length) { + fcRules = $('').appendTo('head'); + } + + fcRules.text(!on ? '' : ' #tool_topath { display: none !important; }'); + $('#foreignObject_panel').toggle(on); + }; + + svgEditor = _this; + $ = S.$, text2xml = S.text2xml, NS = S.NS, importLocale = S.importLocale; + svgCanvas = svgEditor.canvas; + svgdoc = S.svgroot.parentNode.ownerDocument; + _context2.next = 11; + return importLocale(); + + case 11: + strings = _context2.sent; + + properlySourceSizeTextArea = function properlySourceSizeTextArea() { + // TODO: remove magic numbers here and get values from CSS + var height = $('#svg_source_container').height() - 80; + $('#svg_source_textarea').css('height', height); + }; + /** + * @param {boolean} on + * @returns {void} + */ + + + editingforeign = false; + /** + * This function sets the content of element elt to the input XML. + * @param {string} xmlString - The XML text + * @returns {boolean} This function returns false if the set was unsuccessful, true otherwise. + */ + + buttons = [{ + id: 'tool_foreign', + icon: svgEditor.curConfig.extIconsPath + 'foreignobject-tool.png', + type: 'mode', + events: { + click: function click() { + svgCanvas.setMode('foreign'); + } + } + }, { + id: 'edit_foreign', + icon: svgEditor.curConfig.extIconsPath + 'foreignobject-edit.png', + type: 'context', + panel: 'foreignObject_panel', + events: { + click: function click() { + showForeignEditor(); + } + } + }]; + contextTools = [{ + type: 'input', + panel: 'foreignObject_panel', + id: 'foreign_width', + size: 3, + events: { + change: function change() { + setAttr('width', this.value); + } + } + }, { + type: 'input', + panel: 'foreignObject_panel', + id: 'foreign_height', + events: { + change: function change() { + setAttr('height', this.value); + } + } + }, { + type: 'input', + panel: 'foreignObject_panel', + id: 'foreign_font_size', + size: 2, + defval: 16, + events: { + change: function change() { + setAttr('font-size', this.value); + } + } + }]; + return _context2.abrupt("return", { + name: strings.name, + svgicons: svgEditor.curConfig.extIconsPath + 'foreignobject-icons.xml', + buttons: strings.buttons.map(function (button, i) { + return Object.assign(buttons[i], button); + }), + context_tools: strings.contextTools.map(function (contextTool, i) { + return Object.assign(contextTools[i], contextTool); + }), + callback: function callback() { + $('#foreignObject_panel').hide(); + + var endChanges = function endChanges() { + $('#svg_source_editor').hide(); + editingforeign = false; + $('#svg_source_textarea').blur(); + toggleSourceButtons(false); + }; // TODO: Needs to be done after orig icon loads + + + setTimeout(function () { + // Create source save/cancel buttons + + /* const save = */ + $('#tool_source_save').clone().hide().attr('id', 'foreign_save').unbind().appendTo('#tool_source_back').click( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { + var ok; + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + if (editingforeign) { + _context.next = 2; + break; + } + + return _context.abrupt("return"); + + case 2: + if (setForeignString($('#svg_source_textarea').val())) { + _context.next = 11; + break; + } + + _context.next = 5; + return $.confirm('Errors found. Revert to original?'); + + case 5: + ok = _context.sent; + + if (ok) { + _context.next = 8; + break; + } + + return _context.abrupt("return"); + + case 8: + endChanges(); + _context.next = 12; + break; + + case 11: + endChanges(); + + case 12: + case "end": + return _context.stop(); + } + } + }, _callee); + }))); + /* const cancel = */ + + $('#tool_source_cancel').clone().hide().attr('id', 'foreign_cancel').unbind().appendTo('#tool_source_back').click(function () { + endChanges(); + }); + }, 3000); + }, + mouseDown: function mouseDown(opts) { + // const e = opts.event; + if (svgCanvas.getMode() !== 'foreign') { + return undefined; + } + + started = true; + newFO = svgCanvas.addSVGElementFromJson({ + element: 'foreignObject', + attr: { + x: opts.start_x, + y: opts.start_y, + id: svgCanvas.getNextId(), + 'font-size': 16, + // cur_text.font_size, + width: '48', + height: '20', + style: 'pointer-events:inherit' + } + }); + var m = svgdoc.createElementNS(NS.MATH, 'math'); + m.setAttributeNS(NS.XMLNS, 'xmlns', NS.MATH); + m.setAttribute('display', 'inline'); + var mi = svgdoc.createElementNS(NS.MATH, 'mi'); + mi.setAttribute('mathvariant', 'normal'); + mi.textContent = "\u03A6"; + var mo = svgdoc.createElementNS(NS.MATH, 'mo'); + mo.textContent = "\u222A"; + var mi2 = svgdoc.createElementNS(NS.MATH, 'mi'); + mi2.textContent = "\u2133"; + m.append(mi, mo, mi2); + newFO.append(m); + return { + started: true + }; + }, + mouseUp: function mouseUp(opts) { + // const e = opts.event; + if (svgCanvas.getMode() !== 'foreign' || !started) { + return undefined; + } + + var attrs = $(newFO).attr(['width', 'height']); + var keep = attrs.width !== '0' || attrs.height !== '0'; + svgCanvas.addToSelection([newFO], true); + return { + keep: keep, + element: newFO + }; + }, + selectedChanged: function selectedChanged(opts) { + // Use this to update the current selected elements + selElems = opts.elems; + var i = selElems.length; + + while (i--) { + var elem = selElems[i]; + + if (elem && elem.tagName === 'foreignObject') { + if (opts.selectedElement && !opts.multiselected) { + $('#foreign_font_size').val(elem.getAttribute('font-size')); + $('#foreign_width').val(elem.getAttribute('width')); + $('#foreign_height').val(elem.getAttribute('height')); + showPanel(true); + } else { + showPanel(false); + } + } else { + showPanel(false); + } + } + }, + elementChanged: function elementChanged(opts) {// const elem = opts.elems[0]; + } + }); + + case 17: + case "end": + return _context2.stop(); + } + } + }, _callee2); + }))(); + } + }); + + } + }; +}); diff --git a/dist/editor/system/extensions/ext-grid.js b/dist/editor/system/extensions/ext-grid.js new file mode 100644 index 00000000..2ca252ef --- /dev/null +++ b/dist/editor/system/extensions/ext-grid.js @@ -0,0 +1,1830 @@ +System.register([], function (exports) { + 'use strict'; + return { + execute: function () { + + function _typeof(obj) { + "@babel/helpers - typeof"; + + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function (obj) { + return typeof obj; + }; + } else { + _typeof = function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); + } + + var REACT_ELEMENT_TYPE; + + function _jsx(type, props, key, children) { + if (!REACT_ELEMENT_TYPE) { + REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol["for"] && Symbol["for"]("react.element") || 0xeac7; + } + + var defaultProps = type && type.defaultProps; + var childrenLength = arguments.length - 3; + + if (!props && childrenLength !== 0) { + props = { + children: void 0 + }; + } + + if (childrenLength === 1) { + props.children = children; + } else if (childrenLength > 1) { + var childArray = new Array(childrenLength); + + for (var i = 0; i < childrenLength; i++) { + childArray[i] = arguments[i + 3]; + } + + props.children = childArray; + } + + if (props && defaultProps) { + for (var propName in defaultProps) { + if (props[propName] === void 0) { + props[propName] = defaultProps[propName]; + } + } + } else if (!props) { + props = defaultProps || {}; + } + + return { + $$typeof: REACT_ELEMENT_TYPE, + type: type, + key: key === undefined ? null : '' + key, + ref: null, + props: props, + _owner: null + }; + } + + function _asyncIterator(iterable) { + var method; + + if (typeof Symbol !== "undefined") { + if (Symbol.asyncIterator) { + method = iterable[Symbol.asyncIterator]; + if (method != null) return method.call(iterable); + } + + if (Symbol.iterator) { + method = iterable[Symbol.iterator]; + if (method != null) return method.call(iterable); + } + } + + throw new TypeError("Object is not async iterable"); + } + + function _AwaitValue(value) { + this.wrapped = value; + } + + function _AsyncGenerator(gen) { + var front, back; + + function send(key, arg) { + return new Promise(function (resolve, reject) { + var request = { + key: key, + arg: arg, + resolve: resolve, + reject: reject, + next: null + }; + + if (back) { + back = back.next = request; + } else { + front = back = request; + resume(key, arg); + } + }); + } + + function resume(key, arg) { + try { + var result = gen[key](arg); + var value = result.value; + var wrappedAwait = value instanceof _AwaitValue; + Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { + if (wrappedAwait) { + resume(key === "return" ? "return" : "next", arg); + return; + } + + settle(result.done ? "return" : "normal", arg); + }, function (err) { + resume("throw", err); + }); + } catch (err) { + settle("throw", err); + } + } + + function settle(type, value) { + switch (type) { + case "return": + front.resolve({ + value: value, + done: true + }); + break; + + case "throw": + front.reject(value); + break; + + default: + front.resolve({ + value: value, + done: false + }); + break; + } + + front = front.next; + + if (front) { + resume(front.key, front.arg); + } else { + back = null; + } + } + + this._invoke = send; + + if (typeof gen.return !== "function") { + this.return = undefined; + } + } + + if (typeof Symbol === "function" && Symbol.asyncIterator) { + _AsyncGenerator.prototype[Symbol.asyncIterator] = function () { + return this; + }; + } + + _AsyncGenerator.prototype.next = function (arg) { + return this._invoke("next", arg); + }; + + _AsyncGenerator.prototype.throw = function (arg) { + return this._invoke("throw", arg); + }; + + _AsyncGenerator.prototype.return = function (arg) { + return this._invoke("return", arg); + }; + + function _wrapAsyncGenerator(fn) { + return function () { + return new _AsyncGenerator(fn.apply(this, arguments)); + }; + } + + function _awaitAsyncGenerator(value) { + return new _AwaitValue(value); + } + + function _asyncGeneratorDelegate(inner, awaitWrap) { + var iter = {}, + waiting = false; + + function pump(key, value) { + waiting = true; + value = new Promise(function (resolve) { + resolve(inner[key](value)); + }); + return { + done: false, + value: awaitWrap(value) + }; + } + + ; + + if (typeof Symbol === "function" && Symbol.iterator) { + iter[Symbol.iterator] = function () { + return this; + }; + } + + iter.next = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("next", value); + }; + + if (typeof inner.throw === "function") { + iter.throw = function (value) { + if (waiting) { + waiting = false; + throw value; + } + + return pump("throw", value); + }; + } + + if (typeof inner.return === "function") { + iter.return = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("return", value); + }; + } + + return iter; + } + + function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { + try { + var info = gen[key](arg); + var value = info.value; + } catch (error) { + reject(error); + return; + } + + if (info.done) { + resolve(value); + } else { + Promise.resolve(value).then(_next, _throw); + } + } + + function _asyncToGenerator(fn) { + return function () { + var self = this, + args = arguments; + return new Promise(function (resolve, reject) { + var gen = fn.apply(self, args); + + function _next(value) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); + } + + function _throw(err) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); + } + + _next(undefined); + }); + }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; + } + + function _defineEnumerableProperties(obj, descs) { + for (var key in descs) { + var desc = descs[key]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, key, desc); + } + + if (Object.getOwnPropertySymbols) { + var objectSymbols = Object.getOwnPropertySymbols(descs); + + for (var i = 0; i < objectSymbols.length; i++) { + var sym = objectSymbols[i]; + var desc = descs[sym]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, sym, desc); + } + } + + return obj; + } + + function _defaults(obj, defaults) { + var keys = Object.getOwnPropertyNames(defaults); + + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var value = Object.getOwnPropertyDescriptor(defaults, key); + + if (value && value.configurable && obj[key] === undefined) { + Object.defineProperty(obj, key, value); + } + } + + return obj; + } + + function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; + } + + function _extends() { + _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + + return _extends.apply(this, arguments); + } + + function _objectSpread(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? Object(arguments[i]) : {}; + var ownKeys = Object.keys(source); + + if (typeof Object.getOwnPropertySymbols === 'function') { + ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { + return Object.getOwnPropertyDescriptor(source, sym).enumerable; + })); + } + + ownKeys.forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } + + return target; + } + + function ownKeys(object, enumerableOnly) { + var keys = Object.keys(object); + + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(object); + if (enumerableOnly) symbols = symbols.filter(function (sym) { + return Object.getOwnPropertyDescriptor(object, sym).enumerable; + }); + keys.push.apply(keys, symbols); + } + + return keys; + } + + function _objectSpread2(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? arguments[i] : {}; + + if (i % 2) { + ownKeys(Object(source), true).forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } else if (Object.getOwnPropertyDescriptors) { + Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); + } else { + ownKeys(Object(source)).forEach(function (key) { + Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); + }); + } + } + + return target; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function"); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + writable: true, + configurable: true + } + }); + if (superClass) _setPrototypeOf(subClass, superClass); + } + + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + subClass.__proto__ = superClass; + } + + function _getPrototypeOf(o) { + _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { + return o.__proto__ || Object.getPrototypeOf(o); + }; + return _getPrototypeOf(o); + } + + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + + return _setPrototypeOf(o, p); + } + + function _isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + + try { + Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); + return true; + } catch (e) { + return false; + } + } + + function _construct(Parent, args, Class) { + if (_isNativeReflectConstruct()) { + _construct = Reflect.construct; + } else { + _construct = function _construct(Parent, args, Class) { + var a = [null]; + a.push.apply(a, args); + var Constructor = Function.bind.apply(Parent, a); + var instance = new Constructor(); + if (Class) _setPrototypeOf(instance, Class.prototype); + return instance; + }; + } + + return _construct.apply(null, arguments); + } + + function _isNativeFunction(fn) { + return Function.toString.call(fn).indexOf("[native code]") !== -1; + } + + function _wrapNativeSuper(Class) { + var _cache = typeof Map === "function" ? new Map() : undefined; + + _wrapNativeSuper = function _wrapNativeSuper(Class) { + if (Class === null || !_isNativeFunction(Class)) return Class; + + if (typeof Class !== "function") { + throw new TypeError("Super expression must either be null or a function"); + } + + if (typeof _cache !== "undefined") { + if (_cache.has(Class)) return _cache.get(Class); + + _cache.set(Class, Wrapper); + } + + function Wrapper() { + return _construct(Class, arguments, _getPrototypeOf(this).constructor); + } + + Wrapper.prototype = Object.create(Class.prototype, { + constructor: { + value: Wrapper, + enumerable: false, + writable: true, + configurable: true + } + }); + return _setPrototypeOf(Wrapper, Class); + }; + + return _wrapNativeSuper(Class); + } + + function _instanceof(left, right) { + if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { + return !!right[Symbol.hasInstance](left); + } else { + return left instanceof right; + } + } + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + + function _getRequireWildcardCache() { + if (typeof WeakMap !== "function") return null; + var cache = new WeakMap(); + + _getRequireWildcardCache = function () { + return cache; + }; + + return cache; + } + + function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } + + if (obj === null || typeof obj !== "object" && typeof obj !== "function") { + return { + default: obj + }; + } + + var cache = _getRequireWildcardCache(); + + if (cache && cache.has(obj)) { + return cache.get(obj); + } + + var newObj = {}; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + + if (desc && (desc.get || desc.set)) { + Object.defineProperty(newObj, key, desc); + } else { + newObj[key] = obj[key]; + } + } + } + + newObj.default = obj; + + if (cache) { + cache.set(obj, newObj); + } + + return newObj; + } + + function _newArrowCheck(innerThis, boundThis) { + if (innerThis !== boundThis) { + throw new TypeError("Cannot instantiate an arrow function"); + } + } + + function _objectDestructuringEmpty(obj) { + if (obj == null) throw new TypeError("Cannot destructure undefined"); + } + + function _objectWithoutPropertiesLoose(source, excluded) { + if (source == null) return {}; + var target = {}; + var sourceKeys = Object.keys(source); + var key, i; + + for (i = 0; i < sourceKeys.length; i++) { + key = sourceKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + target[key] = source[key]; + } + + return target; + } + + function _objectWithoutProperties(source, excluded) { + if (source == null) return {}; + + var target = _objectWithoutPropertiesLoose(source, excluded); + + var key, i; + + if (Object.getOwnPropertySymbols) { + var sourceSymbolKeys = Object.getOwnPropertySymbols(source); + + for (i = 0; i < sourceSymbolKeys.length; i++) { + key = sourceSymbolKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; + target[key] = source[key]; + } + } + + return target; + } + + function _assertThisInitialized(self) { + if (self === void 0) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return self; + } + + function _possibleConstructorReturn(self, call) { + if (call && (typeof call === "object" || typeof call === "function")) { + return call; + } + + return _assertThisInitialized(self); + } + + function _createSuper(Derived) { + var hasNativeReflectConstruct = _isNativeReflectConstruct(); + + return function _createSuperInternal() { + var Super = _getPrototypeOf(Derived), + result; + + if (hasNativeReflectConstruct) { + var NewTarget = _getPrototypeOf(this).constructor; + + result = Reflect.construct(Super, arguments, NewTarget); + } else { + result = Super.apply(this, arguments); + } + + return _possibleConstructorReturn(this, result); + }; + } + + function _superPropBase(object, property) { + while (!Object.prototype.hasOwnProperty.call(object, property)) { + object = _getPrototypeOf(object); + if (object === null) break; + } + + return object; + } + + function _get(target, property, receiver) { + if (typeof Reflect !== "undefined" && Reflect.get) { + _get = Reflect.get; + } else { + _get = function _get(target, property, receiver) { + var base = _superPropBase(target, property); + + if (!base) return; + var desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.get) { + return desc.get.call(receiver); + } + + return desc.value; + }; + } + + return _get(target, property, receiver || target); + } + + function set(target, property, value, receiver) { + if (typeof Reflect !== "undefined" && Reflect.set) { + set = Reflect.set; + } else { + set = function set(target, property, value, receiver) { + var base = _superPropBase(target, property); + + var desc; + + if (base) { + desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.set) { + desc.set.call(receiver, value); + return true; + } else if (!desc.writable) { + return false; + } + } + + desc = Object.getOwnPropertyDescriptor(receiver, property); + + if (desc) { + if (!desc.writable) { + return false; + } + + desc.value = value; + Object.defineProperty(receiver, property, desc); + } else { + _defineProperty(receiver, property, value); + } + + return true; + }; + } + + return set(target, property, value, receiver); + } + + function _set(target, property, value, receiver, isStrict) { + var s = set(target, property, value, receiver || target); + + if (!s && isStrict) { + throw new Error('failed to set property'); + } + + return value; + } + + function _taggedTemplateLiteral(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + return Object.freeze(Object.defineProperties(strings, { + raw: { + value: Object.freeze(raw) + } + })); + } + + function _taggedTemplateLiteralLoose(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + strings.raw = raw; + return strings; + } + + function _readOnlyError(name) { + throw new Error("\"" + name + "\" is read-only"); + } + + function _classNameTDZError(name) { + throw new Error("Class \"" + name + "\" cannot be referenced in computed property keys."); + } + + function _temporalUndefined() {} + + function _tdz(name) { + throw new ReferenceError(name + " is not defined - temporal dead zone"); + } + + function _temporalRef(val, name) { + return val === _temporalUndefined ? _tdz(name) : val; + } + + function _slicedToArray(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); + } + + function _slicedToArrayLoose(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimitLoose(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); + } + + function _toArray(arr) { + return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); + } + + function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); + } + + function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) return _arrayLikeToArray(arr); + } + + function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; + } + + function _maybeArrayLike(next, arr, i) { + if (arr && !Array.isArray(arr) && typeof arr.length === "number") { + var len = arr.length; + return _arrayLikeToArray(arr, i !== void 0 && i < len ? i : len); + } + + return next(arr, i); + } + + function _iterableToArray(iter) { + if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); + } + + function _iterableToArrayLimit(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"] != null) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; + } + + function _iterableToArrayLimitLoose(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + + for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { + _arr.push(_step.value); + + if (i && _arr.length === i) break; + } + + return _arr; + } + + function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if (typeof o === "string") return _arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + if (n === "Object" && o.constructor) n = o.constructor.name; + if (n === "Map" || n === "Set") return Array.from(o); + if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); + } + + function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) len = arr.length; + + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + + return arr2; + } + + function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + function _createForOfIteratorHelper(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + + var F = function () {}; + + return { + s: F, + n: function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }, + e: function (e) { + throw e; + }, + f: F + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + var normalCompletion = true, + didErr = false, + err; + return { + s: function () { + it = o[Symbol.iterator](); + }, + n: function () { + var step = it.next(); + normalCompletion = step.done; + return step; + }, + e: function (e) { + didErr = true; + err = e; + }, + f: function () { + try { + if (!normalCompletion && it.return != null) it.return(); + } finally { + if (didErr) throw err; + } + } + }; + } + + function _createForOfIteratorHelperLoose(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + return function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + it = o[Symbol.iterator](); + return it.next.bind(it); + } + + function _skipFirstGeneratorNext(fn) { + return function () { + var it = fn.apply(this, arguments); + it.next(); + return it; + }; + } + + function _toPrimitive(input, hint) { + if (typeof input !== "object" || input === null) return input; + var prim = input[Symbol.toPrimitive]; + + if (prim !== undefined) { + var res = prim.call(input, hint || "default"); + if (typeof res !== "object") return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + + return (hint === "string" ? String : Number)(input); + } + + function _toPropertyKey(arg) { + var key = _toPrimitive(arg, "string"); + + return typeof key === "symbol" ? key : String(key); + } + + function _initializerWarningHelper(descriptor, context) { + throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.'); + } + + function _initializerDefineProperty(target, property, descriptor, context) { + if (!descriptor) return; + Object.defineProperty(target, property, { + enumerable: descriptor.enumerable, + configurable: descriptor.configurable, + writable: descriptor.writable, + value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 + }); + } + + function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { + var desc = {}; + Object.keys(descriptor).forEach(function (key) { + desc[key] = descriptor[key]; + }); + desc.enumerable = !!desc.enumerable; + desc.configurable = !!desc.configurable; + + if ('value' in desc || desc.initializer) { + desc.writable = true; + } + + desc = decorators.slice().reverse().reduce(function (desc, decorator) { + return decorator(target, property, desc) || desc; + }, desc); + + if (context && desc.initializer !== void 0) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = undefined; + } + + if (desc.initializer === void 0) { + Object.defineProperty(target, property, desc); + desc = null; + } + + return desc; + } + + var id = 0; + + function _classPrivateFieldLooseKey(name) { + return "__private_" + id++ + "_" + name; + } + + function _classPrivateFieldLooseBase(receiver, privateKey) { + if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { + throw new TypeError("attempted to use private field on non-instance"); + } + + return receiver; + } + + function _classPrivateFieldGet(receiver, privateMap) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to get private field on non-instance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; + } + + function _classPrivateFieldSet(receiver, privateMap, value) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to set private field on non-instance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; + } + + function _classPrivateFieldDestructureSet(receiver, privateMap) { + if (!privateMap.has(receiver)) { + throw new TypeError("attempted to set private field on non-instance"); + } + + var descriptor = privateMap.get(receiver); + + if (descriptor.set) { + if (!("__destrObj" in descriptor)) { + descriptor.__destrObj = { + set value(v) { + descriptor.set.call(receiver, v); + } + + }; + } + + return descriptor.__destrObj; + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + return descriptor; + } + } + + function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; + } + + function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; + } + + function _classStaticPrivateMethodGet(receiver, classConstructor, method) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + return method; + } + + function _classStaticPrivateMethodSet() { + throw new TypeError("attempted to set read only static private field"); + } + + function _decorate(decorators, factory, superClass, mixins) { + var api = _getDecoratorsApi(); + + if (mixins) { + for (var i = 0; i < mixins.length; i++) { + api = mixins[i](api); + } + } + + var r = factory(function initialize(O) { + api.initializeInstanceElements(O, decorated.elements); + }, superClass); + var decorated = api.decorateClass(_coalesceClassElements(r.d.map(_createElementDescriptor)), decorators); + api.initializeClassElements(r.F, decorated.elements); + return api.runClassFinishers(r.F, decorated.finishers); + } + + function _getDecoratorsApi() { + _getDecoratorsApi = function () { + return api; + }; + + var api = { + elementsDefinitionOrder: [["method"], ["field"]], + initializeInstanceElements: function (O, elements) { + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + if (element.kind === kind && element.placement === "own") { + this.defineClassElement(O, element); + } + }, this); + }, this); + }, + initializeClassElements: function (F, elements) { + var proto = F.prototype; + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + var placement = element.placement; + + if (element.kind === kind && (placement === "static" || placement === "prototype")) { + var receiver = placement === "static" ? F : proto; + this.defineClassElement(receiver, element); + } + }, this); + }, this); + }, + defineClassElement: function (receiver, element) { + var descriptor = element.descriptor; + + if (element.kind === "field") { + var initializer = element.initializer; + descriptor = { + enumerable: descriptor.enumerable, + writable: descriptor.writable, + configurable: descriptor.configurable, + value: initializer === void 0 ? void 0 : initializer.call(receiver) + }; + } + + Object.defineProperty(receiver, element.key, descriptor); + }, + decorateClass: function (elements, decorators) { + var newElements = []; + var finishers = []; + var placements = { + static: [], + prototype: [], + own: [] + }; + elements.forEach(function (element) { + this.addElementPlacement(element, placements); + }, this); + elements.forEach(function (element) { + if (!_hasDecorators(element)) return newElements.push(element); + var elementFinishersExtras = this.decorateElement(element, placements); + newElements.push(elementFinishersExtras.element); + newElements.push.apply(newElements, elementFinishersExtras.extras); + finishers.push.apply(finishers, elementFinishersExtras.finishers); + }, this); + + if (!decorators) { + return { + elements: newElements, + finishers: finishers + }; + } + + var result = this.decorateConstructor(newElements, decorators); + finishers.push.apply(finishers, result.finishers); + result.finishers = finishers; + return result; + }, + addElementPlacement: function (element, placements, silent) { + var keys = placements[element.placement]; + + if (!silent && keys.indexOf(element.key) !== -1) { + throw new TypeError("Duplicated element (" + element.key + ")"); + } + + keys.push(element.key); + }, + decorateElement: function (element, placements) { + var extras = []; + var finishers = []; + + for (var decorators = element.decorators, i = decorators.length - 1; i >= 0; i--) { + var keys = placements[element.placement]; + keys.splice(keys.indexOf(element.key), 1); + var elementObject = this.fromElementDescriptor(element); + var elementFinisherExtras = this.toElementFinisherExtras((0, decorators[i])(elementObject) || elementObject); + element = elementFinisherExtras.element; + this.addElementPlacement(element, placements); + + if (elementFinisherExtras.finisher) { + finishers.push(elementFinisherExtras.finisher); + } + + var newExtras = elementFinisherExtras.extras; + + if (newExtras) { + for (var j = 0; j < newExtras.length; j++) { + this.addElementPlacement(newExtras[j], placements); + } + + extras.push.apply(extras, newExtras); + } + } + + return { + element: element, + finishers: finishers, + extras: extras + }; + }, + decorateConstructor: function (elements, decorators) { + var finishers = []; + + for (var i = decorators.length - 1; i >= 0; i--) { + var obj = this.fromClassDescriptor(elements); + var elementsAndFinisher = this.toClassDescriptor((0, decorators[i])(obj) || obj); + + if (elementsAndFinisher.finisher !== undefined) { + finishers.push(elementsAndFinisher.finisher); + } + + if (elementsAndFinisher.elements !== undefined) { + elements = elementsAndFinisher.elements; + + for (var j = 0; j < elements.length - 1; j++) { + for (var k = j + 1; k < elements.length; k++) { + if (elements[j].key === elements[k].key && elements[j].placement === elements[k].placement) { + throw new TypeError("Duplicated element (" + elements[j].key + ")"); + } + } + } + } + } + + return { + elements: elements, + finishers: finishers + }; + }, + fromElementDescriptor: function (element) { + var obj = { + kind: element.kind, + key: element.key, + placement: element.placement, + descriptor: element.descriptor + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + if (element.kind === "field") obj.initializer = element.initializer; + return obj; + }, + toElementDescriptors: function (elementObjects) { + if (elementObjects === undefined) return; + return _toArray(elementObjects).map(function (elementObject) { + var element = this.toElementDescriptor(elementObject); + this.disallowProperty(elementObject, "finisher", "An element descriptor"); + this.disallowProperty(elementObject, "extras", "An element descriptor"); + return element; + }, this); + }, + toElementDescriptor: function (elementObject) { + var kind = String(elementObject.kind); + + if (kind !== "method" && kind !== "field") { + throw new TypeError('An element descriptor\'s .kind property must be either "method" or' + ' "field", but a decorator created an element descriptor with' + ' .kind "' + kind + '"'); + } + + var key = _toPropertyKey(elementObject.key); + + var placement = String(elementObject.placement); + + if (placement !== "static" && placement !== "prototype" && placement !== "own") { + throw new TypeError('An element descriptor\'s .placement property must be one of "static",' + ' "prototype" or "own", but a decorator created an element descriptor' + ' with .placement "' + placement + '"'); + } + + var descriptor = elementObject.descriptor; + this.disallowProperty(elementObject, "elements", "An element descriptor"); + var element = { + kind: kind, + key: key, + placement: placement, + descriptor: Object.assign({}, descriptor) + }; + + if (kind !== "field") { + this.disallowProperty(elementObject, "initializer", "A method descriptor"); + } else { + this.disallowProperty(descriptor, "get", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "set", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "value", "The property descriptor of a field descriptor"); + element.initializer = elementObject.initializer; + } + + return element; + }, + toElementFinisherExtras: function (elementObject) { + var element = this.toElementDescriptor(elementObject); + + var finisher = _optionalCallableProperty(elementObject, "finisher"); + + var extras = this.toElementDescriptors(elementObject.extras); + return { + element: element, + finisher: finisher, + extras: extras + }; + }, + fromClassDescriptor: function (elements) { + var obj = { + kind: "class", + elements: elements.map(this.fromElementDescriptor, this) + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + return obj; + }, + toClassDescriptor: function (obj) { + var kind = String(obj.kind); + + if (kind !== "class") { + throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator' + ' created a class descriptor with .kind "' + kind + '"'); + } + + this.disallowProperty(obj, "key", "A class descriptor"); + this.disallowProperty(obj, "placement", "A class descriptor"); + this.disallowProperty(obj, "descriptor", "A class descriptor"); + this.disallowProperty(obj, "initializer", "A class descriptor"); + this.disallowProperty(obj, "extras", "A class descriptor"); + + var finisher = _optionalCallableProperty(obj, "finisher"); + + var elements = this.toElementDescriptors(obj.elements); + return { + elements: elements, + finisher: finisher + }; + }, + runClassFinishers: function (constructor, finishers) { + for (var i = 0; i < finishers.length; i++) { + var newConstructor = (0, finishers[i])(constructor); + + if (newConstructor !== undefined) { + if (typeof newConstructor !== "function") { + throw new TypeError("Finishers must return a constructor."); + } + + constructor = newConstructor; + } + } + + return constructor; + }, + disallowProperty: function (obj, name, objectType) { + if (obj[name] !== undefined) { + throw new TypeError(objectType + " can't have a ." + name + " property."); + } + } + }; + return api; + } + + function _createElementDescriptor(def) { + var key = _toPropertyKey(def.key); + + var descriptor; + + if (def.kind === "method") { + descriptor = { + value: def.value, + writable: true, + configurable: true, + enumerable: false + }; + } else if (def.kind === "get") { + descriptor = { + get: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "set") { + descriptor = { + set: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "field") { + descriptor = { + configurable: true, + writable: true, + enumerable: true + }; + } + + var element = { + kind: def.kind === "field" ? "field" : "method", + key: key, + placement: def.static ? "static" : def.kind === "field" ? "own" : "prototype", + descriptor: descriptor + }; + if (def.decorators) element.decorators = def.decorators; + if (def.kind === "field") element.initializer = def.value; + return element; + } + + function _coalesceGetterSetter(element, other) { + if (element.descriptor.get !== undefined) { + other.descriptor.get = element.descriptor.get; + } else { + other.descriptor.set = element.descriptor.set; + } + } + + function _coalesceClassElements(elements) { + var newElements = []; + + var isSameElement = function (other) { + return other.kind === "method" && other.key === element.key && other.placement === element.placement; + }; + + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + var other; + + if (element.kind === "method" && (other = newElements.find(isSameElement))) { + if (_isDataDescriptor(element.descriptor) || _isDataDescriptor(other.descriptor)) { + if (_hasDecorators(element) || _hasDecorators(other)) { + throw new ReferenceError("Duplicated methods (" + element.key + ") can't be decorated."); + } + + other.descriptor = element.descriptor; + } else { + if (_hasDecorators(element)) { + if (_hasDecorators(other)) { + throw new ReferenceError("Decorators can't be placed on different accessors with for " + "the same property (" + element.key + ")."); + } + + other.decorators = element.decorators; + } + + _coalesceGetterSetter(element, other); + } + } else { + newElements.push(element); + } + } + + return newElements; + } + + function _hasDecorators(element) { + return element.decorators && element.decorators.length; + } + + function _isDataDescriptor(desc) { + return desc !== undefined && !(desc.value === undefined && desc.writable === undefined); + } + + function _optionalCallableProperty(obj, name) { + var value = obj[name]; + + if (value !== undefined && typeof value !== "function") { + throw new TypeError("Expected '" + name + "' to be a function"); + } + + return value; + } + + function _classPrivateMethodGet(receiver, privateSet, fn) { + if (!privateSet.has(receiver)) { + throw new TypeError("attempted to get private field on non-instance"); + } + + return fn; + } + + function _classPrivateMethodSet() { + throw new TypeError("attempted to reassign private method"); + } + + function _wrapRegExp(re, groups) { + _wrapRegExp = function (re, groups) { + return new BabelRegExp(re, undefined, groups); + }; + + var _RegExp = _wrapNativeSuper(RegExp); + + var _super = RegExp.prototype; + + var _groups = new WeakMap(); + + function BabelRegExp(re, flags, groups) { + var _this = _RegExp.call(this, re, flags); + + _groups.set(_this, groups || _groups.get(re)); + + return _this; + } + + _inherits(BabelRegExp, _RegExp); + + BabelRegExp.prototype.exec = function (str) { + var result = _super.exec.call(this, str); + + if (result) result.groups = buildGroups(result, this); + return result; + }; + + BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { + if (typeof substitution === "string") { + var groups = _groups.get(this); + + return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { + return "$" + groups[name]; + })); + } else if (typeof substitution === "function") { + var _this = this; + + return _super[Symbol.replace].call(this, str, function () { + var args = []; + args.push.apply(args, arguments); + + if (typeof args[args.length - 1] !== "object") { + args.push(buildGroups(args, _this)); + } + + return substitution.apply(this, args); + }); + } else { + return _super[Symbol.replace].call(this, str, substitution); + } + }; + + function buildGroups(result, re) { + var g = _groups.get(re); + + return Object.keys(g).reduce(function (groups, name) { + groups[name] = result[g[name]]; + return groups; + }, Object.create(null)); + } + + return _wrapRegExp.apply(this, arguments); + } + + var gridIcon = "grid-icon.xml"; + + var extGrid = exports('default', { + name: 'grid', + init: function init(_ref) { + var _this = this; + + return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { + var $, NS, getTypeMap, importLocale, strings, svgEditor, svgCanvas, svgdoc, assignAttributes, hcanvas, canvBG, units, intervals, showGrid, canvasGrid, gridDefs, gridPattern, gridimg, gridBox, updateGrid, gridUpdate, buttons; + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + gridUpdate = function _gridUpdate() { + if (showGrid) { + updateGrid(svgCanvas.getZoom()); + } + + $('#canvasGrid').toggle(showGrid); + $('#view_grid').toggleClass('push_button_pressed tool_button'); + }; + + updateGrid = function _updateGrid(zoom) { + // TODO: Try this with elements, then compare performance difference + var unit = units[svgEditor.curConfig.baseUnit]; // 1 = 1px + + var uMulti = unit * zoom; // Calculate the main number interval + + var rawM = 100 / uMulti; + var multi = 1; + intervals.some(function (num) { + multi = num; + return rawM <= num; + }); + var bigInt = multi * uMulti; // Set the canvas size to the width of the container + + hcanvas.width = bigInt; + hcanvas.height = bigInt; + var ctx = hcanvas.getContext('2d'); + var curD = 0.5; + var part = bigInt / 10; + ctx.globalAlpha = 0.2; + ctx.strokeStyle = svgEditor.curConfig.gridColor; + + for (var i = 1; i < 10; i++) { + var subD = Math.round(part * i) + 0.5; // const lineNum = (i % 2)?12:10; + + var lineNum = 0; + ctx.moveTo(subD, bigInt); + ctx.lineTo(subD, lineNum); + ctx.moveTo(bigInt, subD); + ctx.lineTo(lineNum, subD); + } + + ctx.stroke(); + ctx.beginPath(); + ctx.globalAlpha = 0.5; + ctx.moveTo(curD, bigInt); + ctx.lineTo(curD, 0); + ctx.moveTo(bigInt, curD); + ctx.lineTo(0, curD); + ctx.stroke(); + var datauri = hcanvas.toDataURL('image/png'); + gridimg.setAttribute('width', bigInt); + gridimg.setAttribute('height', bigInt); + gridimg.parentNode.setAttribute('width', bigInt); + gridimg.parentNode.setAttribute('height', bigInt); + svgCanvas.setHref(gridimg, datauri); + }; + + $ = _ref.$, NS = _ref.NS, getTypeMap = _ref.getTypeMap, importLocale = _ref.importLocale; + _context.next = 5; + return importLocale(); + + case 5: + strings = _context.sent; + svgEditor = _this; + svgCanvas = svgEditor.canvas; + svgdoc = document.getElementById('svgcanvas').ownerDocument, assignAttributes = svgCanvas.assignAttributes, hcanvas = document.createElement('canvas'), canvBG = $('#canvasBackground'), units = getTypeMap(), intervals = [0.01, 0.1, 1, 10, 100, 1000]; + showGrid = svgEditor.curConfig.showGrid || false; + $(hcanvas).hide().appendTo('body'); + canvasGrid = svgdoc.createElementNS(NS.SVG, 'svg'); + assignAttributes(canvasGrid, { + id: 'canvasGrid', + width: '100%', + height: '100%', + x: 0, + y: 0, + overflow: 'visible', + display: 'none' + }); + canvBG.append(canvasGrid); + gridDefs = svgdoc.createElementNS(NS.SVG, 'defs'); // grid-pattern + + gridPattern = svgdoc.createElementNS(NS.SVG, 'pattern'); + assignAttributes(gridPattern, { + id: 'gridpattern', + patternUnits: 'userSpaceOnUse', + x: 0, + // -(value.strokeWidth / 2), // position for strokewidth + y: 0, + // -(value.strokeWidth / 2), // position for strokewidth + width: 100, + height: 100 + }); + gridimg = svgdoc.createElementNS(NS.SVG, 'image'); + assignAttributes(gridimg, { + x: 0, + y: 0, + width: 100, + height: 100 + }); + gridPattern.append(gridimg); + gridDefs.append(gridPattern); + $('#canvasGrid').append(gridDefs); // grid-box + + gridBox = svgdoc.createElementNS(NS.SVG, 'rect'); + assignAttributes(gridBox, { + width: '100%', + height: '100%', + x: 0, + y: 0, + 'stroke-width': 0, + stroke: 'none', + fill: 'url(#gridpattern)', + style: 'pointer-events: none; display:visible;' + }); + $('#canvasGrid').append(gridBox); + /** + * + * @param {Float} zoom + * @returns {void} + */ + + buttons = [{ + id: 'view_grid', + icon: svgEditor.curConfig.extIconsPath + 'grid.png', + type: 'context', + panel: 'editor_panel', + events: { + click: function click() { + svgEditor.curConfig.showGrid = showGrid = !showGrid; + gridUpdate(); + } + } + }]; + return _context.abrupt("return", { + name: strings.name, + svgicons: svgEditor.curConfig.extIconsPath + 'grid-icon.xml', + zoomChanged: function zoomChanged(zoom) { + if (showGrid) { + updateGrid(zoom); + } + }, + callback: function callback() { + if (showGrid) { + gridUpdate(); + } + }, + buttons: strings.buttons.map(function (button, i) { + return Object.assign(buttons[i], button); + }) + }); + + case 27: + case "end": + return _context.stop(); + } + } + }, _callee); + }))(); + } + }); + + } + }; +}); diff --git a/dist/editor/system/extensions/ext-helloworld.js b/dist/editor/system/extensions/ext-helloworld.js new file mode 100644 index 00000000..14f91994 --- /dev/null +++ b/dist/editor/system/extensions/ext-helloworld.js @@ -0,0 +1,1763 @@ +System.register([], function (exports) { + 'use strict'; + return { + execute: function () { + + function _typeof(obj) { + "@babel/helpers - typeof"; + + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function (obj) { + return typeof obj; + }; + } else { + _typeof = function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); + } + + var REACT_ELEMENT_TYPE; + + function _jsx(type, props, key, children) { + if (!REACT_ELEMENT_TYPE) { + REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol["for"] && Symbol["for"]("react.element") || 0xeac7; + } + + var defaultProps = type && type.defaultProps; + var childrenLength = arguments.length - 3; + + if (!props && childrenLength !== 0) { + props = { + children: void 0 + }; + } + + if (childrenLength === 1) { + props.children = children; + } else if (childrenLength > 1) { + var childArray = new Array(childrenLength); + + for (var i = 0; i < childrenLength; i++) { + childArray[i] = arguments[i + 3]; + } + + props.children = childArray; + } + + if (props && defaultProps) { + for (var propName in defaultProps) { + if (props[propName] === void 0) { + props[propName] = defaultProps[propName]; + } + } + } else if (!props) { + props = defaultProps || {}; + } + + return { + $$typeof: REACT_ELEMENT_TYPE, + type: type, + key: key === undefined ? null : '' + key, + ref: null, + props: props, + _owner: null + }; + } + + function _asyncIterator(iterable) { + var method; + + if (typeof Symbol !== "undefined") { + if (Symbol.asyncIterator) { + method = iterable[Symbol.asyncIterator]; + if (method != null) return method.call(iterable); + } + + if (Symbol.iterator) { + method = iterable[Symbol.iterator]; + if (method != null) return method.call(iterable); + } + } + + throw new TypeError("Object is not async iterable"); + } + + function _AwaitValue(value) { + this.wrapped = value; + } + + function _AsyncGenerator(gen) { + var front, back; + + function send(key, arg) { + return new Promise(function (resolve, reject) { + var request = { + key: key, + arg: arg, + resolve: resolve, + reject: reject, + next: null + }; + + if (back) { + back = back.next = request; + } else { + front = back = request; + resume(key, arg); + } + }); + } + + function resume(key, arg) { + try { + var result = gen[key](arg); + var value = result.value; + var wrappedAwait = value instanceof _AwaitValue; + Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { + if (wrappedAwait) { + resume(key === "return" ? "return" : "next", arg); + return; + } + + settle(result.done ? "return" : "normal", arg); + }, function (err) { + resume("throw", err); + }); + } catch (err) { + settle("throw", err); + } + } + + function settle(type, value) { + switch (type) { + case "return": + front.resolve({ + value: value, + done: true + }); + break; + + case "throw": + front.reject(value); + break; + + default: + front.resolve({ + value: value, + done: false + }); + break; + } + + front = front.next; + + if (front) { + resume(front.key, front.arg); + } else { + back = null; + } + } + + this._invoke = send; + + if (typeof gen.return !== "function") { + this.return = undefined; + } + } + + if (typeof Symbol === "function" && Symbol.asyncIterator) { + _AsyncGenerator.prototype[Symbol.asyncIterator] = function () { + return this; + }; + } + + _AsyncGenerator.prototype.next = function (arg) { + return this._invoke("next", arg); + }; + + _AsyncGenerator.prototype.throw = function (arg) { + return this._invoke("throw", arg); + }; + + _AsyncGenerator.prototype.return = function (arg) { + return this._invoke("return", arg); + }; + + function _wrapAsyncGenerator(fn) { + return function () { + return new _AsyncGenerator(fn.apply(this, arguments)); + }; + } + + function _awaitAsyncGenerator(value) { + return new _AwaitValue(value); + } + + function _asyncGeneratorDelegate(inner, awaitWrap) { + var iter = {}, + waiting = false; + + function pump(key, value) { + waiting = true; + value = new Promise(function (resolve) { + resolve(inner[key](value)); + }); + return { + done: false, + value: awaitWrap(value) + }; + } + + ; + + if (typeof Symbol === "function" && Symbol.iterator) { + iter[Symbol.iterator] = function () { + return this; + }; + } + + iter.next = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("next", value); + }; + + if (typeof inner.throw === "function") { + iter.throw = function (value) { + if (waiting) { + waiting = false; + throw value; + } + + return pump("throw", value); + }; + } + + if (typeof inner.return === "function") { + iter.return = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("return", value); + }; + } + + return iter; + } + + function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { + try { + var info = gen[key](arg); + var value = info.value; + } catch (error) { + reject(error); + return; + } + + if (info.done) { + resolve(value); + } else { + Promise.resolve(value).then(_next, _throw); + } + } + + function _asyncToGenerator(fn) { + return function () { + var self = this, + args = arguments; + return new Promise(function (resolve, reject) { + var gen = fn.apply(self, args); + + function _next(value) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); + } + + function _throw(err) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); + } + + _next(undefined); + }); + }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; + } + + function _defineEnumerableProperties(obj, descs) { + for (var key in descs) { + var desc = descs[key]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, key, desc); + } + + if (Object.getOwnPropertySymbols) { + var objectSymbols = Object.getOwnPropertySymbols(descs); + + for (var i = 0; i < objectSymbols.length; i++) { + var sym = objectSymbols[i]; + var desc = descs[sym]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, sym, desc); + } + } + + return obj; + } + + function _defaults(obj, defaults) { + var keys = Object.getOwnPropertyNames(defaults); + + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var value = Object.getOwnPropertyDescriptor(defaults, key); + + if (value && value.configurable && obj[key] === undefined) { + Object.defineProperty(obj, key, value); + } + } + + return obj; + } + + function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; + } + + function _extends() { + _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + + return _extends.apply(this, arguments); + } + + function _objectSpread(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? Object(arguments[i]) : {}; + var ownKeys = Object.keys(source); + + if (typeof Object.getOwnPropertySymbols === 'function') { + ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { + return Object.getOwnPropertyDescriptor(source, sym).enumerable; + })); + } + + ownKeys.forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } + + return target; + } + + function ownKeys(object, enumerableOnly) { + var keys = Object.keys(object); + + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(object); + if (enumerableOnly) symbols = symbols.filter(function (sym) { + return Object.getOwnPropertyDescriptor(object, sym).enumerable; + }); + keys.push.apply(keys, symbols); + } + + return keys; + } + + function _objectSpread2(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? arguments[i] : {}; + + if (i % 2) { + ownKeys(Object(source), true).forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } else if (Object.getOwnPropertyDescriptors) { + Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); + } else { + ownKeys(Object(source)).forEach(function (key) { + Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); + }); + } + } + + return target; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function"); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + writable: true, + configurable: true + } + }); + if (superClass) _setPrototypeOf(subClass, superClass); + } + + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + subClass.__proto__ = superClass; + } + + function _getPrototypeOf(o) { + _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { + return o.__proto__ || Object.getPrototypeOf(o); + }; + return _getPrototypeOf(o); + } + + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + + return _setPrototypeOf(o, p); + } + + function _isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + + try { + Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); + return true; + } catch (e) { + return false; + } + } + + function _construct(Parent, args, Class) { + if (_isNativeReflectConstruct()) { + _construct = Reflect.construct; + } else { + _construct = function _construct(Parent, args, Class) { + var a = [null]; + a.push.apply(a, args); + var Constructor = Function.bind.apply(Parent, a); + var instance = new Constructor(); + if (Class) _setPrototypeOf(instance, Class.prototype); + return instance; + }; + } + + return _construct.apply(null, arguments); + } + + function _isNativeFunction(fn) { + return Function.toString.call(fn).indexOf("[native code]") !== -1; + } + + function _wrapNativeSuper(Class) { + var _cache = typeof Map === "function" ? new Map() : undefined; + + _wrapNativeSuper = function _wrapNativeSuper(Class) { + if (Class === null || !_isNativeFunction(Class)) return Class; + + if (typeof Class !== "function") { + throw new TypeError("Super expression must either be null or a function"); + } + + if (typeof _cache !== "undefined") { + if (_cache.has(Class)) return _cache.get(Class); + + _cache.set(Class, Wrapper); + } + + function Wrapper() { + return _construct(Class, arguments, _getPrototypeOf(this).constructor); + } + + Wrapper.prototype = Object.create(Class.prototype, { + constructor: { + value: Wrapper, + enumerable: false, + writable: true, + configurable: true + } + }); + return _setPrototypeOf(Wrapper, Class); + }; + + return _wrapNativeSuper(Class); + } + + function _instanceof(left, right) { + if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { + return !!right[Symbol.hasInstance](left); + } else { + return left instanceof right; + } + } + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + + function _getRequireWildcardCache() { + if (typeof WeakMap !== "function") return null; + var cache = new WeakMap(); + + _getRequireWildcardCache = function () { + return cache; + }; + + return cache; + } + + function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } + + if (obj === null || typeof obj !== "object" && typeof obj !== "function") { + return { + default: obj + }; + } + + var cache = _getRequireWildcardCache(); + + if (cache && cache.has(obj)) { + return cache.get(obj); + } + + var newObj = {}; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + + if (desc && (desc.get || desc.set)) { + Object.defineProperty(newObj, key, desc); + } else { + newObj[key] = obj[key]; + } + } + } + + newObj.default = obj; + + if (cache) { + cache.set(obj, newObj); + } + + return newObj; + } + + function _newArrowCheck(innerThis, boundThis) { + if (innerThis !== boundThis) { + throw new TypeError("Cannot instantiate an arrow function"); + } + } + + function _objectDestructuringEmpty(obj) { + if (obj == null) throw new TypeError("Cannot destructure undefined"); + } + + function _objectWithoutPropertiesLoose(source, excluded) { + if (source == null) return {}; + var target = {}; + var sourceKeys = Object.keys(source); + var key, i; + + for (i = 0; i < sourceKeys.length; i++) { + key = sourceKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + target[key] = source[key]; + } + + return target; + } + + function _objectWithoutProperties(source, excluded) { + if (source == null) return {}; + + var target = _objectWithoutPropertiesLoose(source, excluded); + + var key, i; + + if (Object.getOwnPropertySymbols) { + var sourceSymbolKeys = Object.getOwnPropertySymbols(source); + + for (i = 0; i < sourceSymbolKeys.length; i++) { + key = sourceSymbolKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; + target[key] = source[key]; + } + } + + return target; + } + + function _assertThisInitialized(self) { + if (self === void 0) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return self; + } + + function _possibleConstructorReturn(self, call) { + if (call && (typeof call === "object" || typeof call === "function")) { + return call; + } + + return _assertThisInitialized(self); + } + + function _createSuper(Derived) { + var hasNativeReflectConstruct = _isNativeReflectConstruct(); + + return function _createSuperInternal() { + var Super = _getPrototypeOf(Derived), + result; + + if (hasNativeReflectConstruct) { + var NewTarget = _getPrototypeOf(this).constructor; + + result = Reflect.construct(Super, arguments, NewTarget); + } else { + result = Super.apply(this, arguments); + } + + return _possibleConstructorReturn(this, result); + }; + } + + function _superPropBase(object, property) { + while (!Object.prototype.hasOwnProperty.call(object, property)) { + object = _getPrototypeOf(object); + if (object === null) break; + } + + return object; + } + + function _get(target, property, receiver) { + if (typeof Reflect !== "undefined" && Reflect.get) { + _get = Reflect.get; + } else { + _get = function _get(target, property, receiver) { + var base = _superPropBase(target, property); + + if (!base) return; + var desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.get) { + return desc.get.call(receiver); + } + + return desc.value; + }; + } + + return _get(target, property, receiver || target); + } + + function set(target, property, value, receiver) { + if (typeof Reflect !== "undefined" && Reflect.set) { + set = Reflect.set; + } else { + set = function set(target, property, value, receiver) { + var base = _superPropBase(target, property); + + var desc; + + if (base) { + desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.set) { + desc.set.call(receiver, value); + return true; + } else if (!desc.writable) { + return false; + } + } + + desc = Object.getOwnPropertyDescriptor(receiver, property); + + if (desc) { + if (!desc.writable) { + return false; + } + + desc.value = value; + Object.defineProperty(receiver, property, desc); + } else { + _defineProperty(receiver, property, value); + } + + return true; + }; + } + + return set(target, property, value, receiver); + } + + function _set(target, property, value, receiver, isStrict) { + var s = set(target, property, value, receiver || target); + + if (!s && isStrict) { + throw new Error('failed to set property'); + } + + return value; + } + + function _taggedTemplateLiteral(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + return Object.freeze(Object.defineProperties(strings, { + raw: { + value: Object.freeze(raw) + } + })); + } + + function _taggedTemplateLiteralLoose(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + strings.raw = raw; + return strings; + } + + function _readOnlyError(name) { + throw new Error("\"" + name + "\" is read-only"); + } + + function _classNameTDZError(name) { + throw new Error("Class \"" + name + "\" cannot be referenced in computed property keys."); + } + + function _temporalUndefined() {} + + function _tdz(name) { + throw new ReferenceError(name + " is not defined - temporal dead zone"); + } + + function _temporalRef(val, name) { + return val === _temporalUndefined ? _tdz(name) : val; + } + + function _slicedToArray(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); + } + + function _slicedToArrayLoose(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimitLoose(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); + } + + function _toArray(arr) { + return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); + } + + function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); + } + + function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) return _arrayLikeToArray(arr); + } + + function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; + } + + function _maybeArrayLike(next, arr, i) { + if (arr && !Array.isArray(arr) && typeof arr.length === "number") { + var len = arr.length; + return _arrayLikeToArray(arr, i !== void 0 && i < len ? i : len); + } + + return next(arr, i); + } + + function _iterableToArray(iter) { + if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); + } + + function _iterableToArrayLimit(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"] != null) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; + } + + function _iterableToArrayLimitLoose(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + + for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { + _arr.push(_step.value); + + if (i && _arr.length === i) break; + } + + return _arr; + } + + function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if (typeof o === "string") return _arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + if (n === "Object" && o.constructor) n = o.constructor.name; + if (n === "Map" || n === "Set") return Array.from(o); + if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); + } + + function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) len = arr.length; + + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + + return arr2; + } + + function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + function _createForOfIteratorHelper(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + + var F = function () {}; + + return { + s: F, + n: function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }, + e: function (e) { + throw e; + }, + f: F + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + var normalCompletion = true, + didErr = false, + err; + return { + s: function () { + it = o[Symbol.iterator](); + }, + n: function () { + var step = it.next(); + normalCompletion = step.done; + return step; + }, + e: function (e) { + didErr = true; + err = e; + }, + f: function () { + try { + if (!normalCompletion && it.return != null) it.return(); + } finally { + if (didErr) throw err; + } + } + }; + } + + function _createForOfIteratorHelperLoose(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + return function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + it = o[Symbol.iterator](); + return it.next.bind(it); + } + + function _skipFirstGeneratorNext(fn) { + return function () { + var it = fn.apply(this, arguments); + it.next(); + return it; + }; + } + + function _toPrimitive(input, hint) { + if (typeof input !== "object" || input === null) return input; + var prim = input[Symbol.toPrimitive]; + + if (prim !== undefined) { + var res = prim.call(input, hint || "default"); + if (typeof res !== "object") return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + + return (hint === "string" ? String : Number)(input); + } + + function _toPropertyKey(arg) { + var key = _toPrimitive(arg, "string"); + + return typeof key === "symbol" ? key : String(key); + } + + function _initializerWarningHelper(descriptor, context) { + throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.'); + } + + function _initializerDefineProperty(target, property, descriptor, context) { + if (!descriptor) return; + Object.defineProperty(target, property, { + enumerable: descriptor.enumerable, + configurable: descriptor.configurable, + writable: descriptor.writable, + value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 + }); + } + + function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { + var desc = {}; + Object.keys(descriptor).forEach(function (key) { + desc[key] = descriptor[key]; + }); + desc.enumerable = !!desc.enumerable; + desc.configurable = !!desc.configurable; + + if ('value' in desc || desc.initializer) { + desc.writable = true; + } + + desc = decorators.slice().reverse().reduce(function (desc, decorator) { + return decorator(target, property, desc) || desc; + }, desc); + + if (context && desc.initializer !== void 0) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = undefined; + } + + if (desc.initializer === void 0) { + Object.defineProperty(target, property, desc); + desc = null; + } + + return desc; + } + + var id = 0; + + function _classPrivateFieldLooseKey(name) { + return "__private_" + id++ + "_" + name; + } + + function _classPrivateFieldLooseBase(receiver, privateKey) { + if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { + throw new TypeError("attempted to use private field on non-instance"); + } + + return receiver; + } + + function _classPrivateFieldGet(receiver, privateMap) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to get private field on non-instance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; + } + + function _classPrivateFieldSet(receiver, privateMap, value) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to set private field on non-instance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; + } + + function _classPrivateFieldDestructureSet(receiver, privateMap) { + if (!privateMap.has(receiver)) { + throw new TypeError("attempted to set private field on non-instance"); + } + + var descriptor = privateMap.get(receiver); + + if (descriptor.set) { + if (!("__destrObj" in descriptor)) { + descriptor.__destrObj = { + set value(v) { + descriptor.set.call(receiver, v); + } + + }; + } + + return descriptor.__destrObj; + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + return descriptor; + } + } + + function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; + } + + function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; + } + + function _classStaticPrivateMethodGet(receiver, classConstructor, method) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + return method; + } + + function _classStaticPrivateMethodSet() { + throw new TypeError("attempted to set read only static private field"); + } + + function _decorate(decorators, factory, superClass, mixins) { + var api = _getDecoratorsApi(); + + if (mixins) { + for (var i = 0; i < mixins.length; i++) { + api = mixins[i](api); + } + } + + var r = factory(function initialize(O) { + api.initializeInstanceElements(O, decorated.elements); + }, superClass); + var decorated = api.decorateClass(_coalesceClassElements(r.d.map(_createElementDescriptor)), decorators); + api.initializeClassElements(r.F, decorated.elements); + return api.runClassFinishers(r.F, decorated.finishers); + } + + function _getDecoratorsApi() { + _getDecoratorsApi = function () { + return api; + }; + + var api = { + elementsDefinitionOrder: [["method"], ["field"]], + initializeInstanceElements: function (O, elements) { + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + if (element.kind === kind && element.placement === "own") { + this.defineClassElement(O, element); + } + }, this); + }, this); + }, + initializeClassElements: function (F, elements) { + var proto = F.prototype; + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + var placement = element.placement; + + if (element.kind === kind && (placement === "static" || placement === "prototype")) { + var receiver = placement === "static" ? F : proto; + this.defineClassElement(receiver, element); + } + }, this); + }, this); + }, + defineClassElement: function (receiver, element) { + var descriptor = element.descriptor; + + if (element.kind === "field") { + var initializer = element.initializer; + descriptor = { + enumerable: descriptor.enumerable, + writable: descriptor.writable, + configurable: descriptor.configurable, + value: initializer === void 0 ? void 0 : initializer.call(receiver) + }; + } + + Object.defineProperty(receiver, element.key, descriptor); + }, + decorateClass: function (elements, decorators) { + var newElements = []; + var finishers = []; + var placements = { + static: [], + prototype: [], + own: [] + }; + elements.forEach(function (element) { + this.addElementPlacement(element, placements); + }, this); + elements.forEach(function (element) { + if (!_hasDecorators(element)) return newElements.push(element); + var elementFinishersExtras = this.decorateElement(element, placements); + newElements.push(elementFinishersExtras.element); + newElements.push.apply(newElements, elementFinishersExtras.extras); + finishers.push.apply(finishers, elementFinishersExtras.finishers); + }, this); + + if (!decorators) { + return { + elements: newElements, + finishers: finishers + }; + } + + var result = this.decorateConstructor(newElements, decorators); + finishers.push.apply(finishers, result.finishers); + result.finishers = finishers; + return result; + }, + addElementPlacement: function (element, placements, silent) { + var keys = placements[element.placement]; + + if (!silent && keys.indexOf(element.key) !== -1) { + throw new TypeError("Duplicated element (" + element.key + ")"); + } + + keys.push(element.key); + }, + decorateElement: function (element, placements) { + var extras = []; + var finishers = []; + + for (var decorators = element.decorators, i = decorators.length - 1; i >= 0; i--) { + var keys = placements[element.placement]; + keys.splice(keys.indexOf(element.key), 1); + var elementObject = this.fromElementDescriptor(element); + var elementFinisherExtras = this.toElementFinisherExtras((0, decorators[i])(elementObject) || elementObject); + element = elementFinisherExtras.element; + this.addElementPlacement(element, placements); + + if (elementFinisherExtras.finisher) { + finishers.push(elementFinisherExtras.finisher); + } + + var newExtras = elementFinisherExtras.extras; + + if (newExtras) { + for (var j = 0; j < newExtras.length; j++) { + this.addElementPlacement(newExtras[j], placements); + } + + extras.push.apply(extras, newExtras); + } + } + + return { + element: element, + finishers: finishers, + extras: extras + }; + }, + decorateConstructor: function (elements, decorators) { + var finishers = []; + + for (var i = decorators.length - 1; i >= 0; i--) { + var obj = this.fromClassDescriptor(elements); + var elementsAndFinisher = this.toClassDescriptor((0, decorators[i])(obj) || obj); + + if (elementsAndFinisher.finisher !== undefined) { + finishers.push(elementsAndFinisher.finisher); + } + + if (elementsAndFinisher.elements !== undefined) { + elements = elementsAndFinisher.elements; + + for (var j = 0; j < elements.length - 1; j++) { + for (var k = j + 1; k < elements.length; k++) { + if (elements[j].key === elements[k].key && elements[j].placement === elements[k].placement) { + throw new TypeError("Duplicated element (" + elements[j].key + ")"); + } + } + } + } + } + + return { + elements: elements, + finishers: finishers + }; + }, + fromElementDescriptor: function (element) { + var obj = { + kind: element.kind, + key: element.key, + placement: element.placement, + descriptor: element.descriptor + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + if (element.kind === "field") obj.initializer = element.initializer; + return obj; + }, + toElementDescriptors: function (elementObjects) { + if (elementObjects === undefined) return; + return _toArray(elementObjects).map(function (elementObject) { + var element = this.toElementDescriptor(elementObject); + this.disallowProperty(elementObject, "finisher", "An element descriptor"); + this.disallowProperty(elementObject, "extras", "An element descriptor"); + return element; + }, this); + }, + toElementDescriptor: function (elementObject) { + var kind = String(elementObject.kind); + + if (kind !== "method" && kind !== "field") { + throw new TypeError('An element descriptor\'s .kind property must be either "method" or' + ' "field", but a decorator created an element descriptor with' + ' .kind "' + kind + '"'); + } + + var key = _toPropertyKey(elementObject.key); + + var placement = String(elementObject.placement); + + if (placement !== "static" && placement !== "prototype" && placement !== "own") { + throw new TypeError('An element descriptor\'s .placement property must be one of "static",' + ' "prototype" or "own", but a decorator created an element descriptor' + ' with .placement "' + placement + '"'); + } + + var descriptor = elementObject.descriptor; + this.disallowProperty(elementObject, "elements", "An element descriptor"); + var element = { + kind: kind, + key: key, + placement: placement, + descriptor: Object.assign({}, descriptor) + }; + + if (kind !== "field") { + this.disallowProperty(elementObject, "initializer", "A method descriptor"); + } else { + this.disallowProperty(descriptor, "get", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "set", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "value", "The property descriptor of a field descriptor"); + element.initializer = elementObject.initializer; + } + + return element; + }, + toElementFinisherExtras: function (elementObject) { + var element = this.toElementDescriptor(elementObject); + + var finisher = _optionalCallableProperty(elementObject, "finisher"); + + var extras = this.toElementDescriptors(elementObject.extras); + return { + element: element, + finisher: finisher, + extras: extras + }; + }, + fromClassDescriptor: function (elements) { + var obj = { + kind: "class", + elements: elements.map(this.fromElementDescriptor, this) + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + return obj; + }, + toClassDescriptor: function (obj) { + var kind = String(obj.kind); + + if (kind !== "class") { + throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator' + ' created a class descriptor with .kind "' + kind + '"'); + } + + this.disallowProperty(obj, "key", "A class descriptor"); + this.disallowProperty(obj, "placement", "A class descriptor"); + this.disallowProperty(obj, "descriptor", "A class descriptor"); + this.disallowProperty(obj, "initializer", "A class descriptor"); + this.disallowProperty(obj, "extras", "A class descriptor"); + + var finisher = _optionalCallableProperty(obj, "finisher"); + + var elements = this.toElementDescriptors(obj.elements); + return { + elements: elements, + finisher: finisher + }; + }, + runClassFinishers: function (constructor, finishers) { + for (var i = 0; i < finishers.length; i++) { + var newConstructor = (0, finishers[i])(constructor); + + if (newConstructor !== undefined) { + if (typeof newConstructor !== "function") { + throw new TypeError("Finishers must return a constructor."); + } + + constructor = newConstructor; + } + } + + return constructor; + }, + disallowProperty: function (obj, name, objectType) { + if (obj[name] !== undefined) { + throw new TypeError(objectType + " can't have a ." + name + " property."); + } + } + }; + return api; + } + + function _createElementDescriptor(def) { + var key = _toPropertyKey(def.key); + + var descriptor; + + if (def.kind === "method") { + descriptor = { + value: def.value, + writable: true, + configurable: true, + enumerable: false + }; + } else if (def.kind === "get") { + descriptor = { + get: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "set") { + descriptor = { + set: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "field") { + descriptor = { + configurable: true, + writable: true, + enumerable: true + }; + } + + var element = { + kind: def.kind === "field" ? "field" : "method", + key: key, + placement: def.static ? "static" : def.kind === "field" ? "own" : "prototype", + descriptor: descriptor + }; + if (def.decorators) element.decorators = def.decorators; + if (def.kind === "field") element.initializer = def.value; + return element; + } + + function _coalesceGetterSetter(element, other) { + if (element.descriptor.get !== undefined) { + other.descriptor.get = element.descriptor.get; + } else { + other.descriptor.set = element.descriptor.set; + } + } + + function _coalesceClassElements(elements) { + var newElements = []; + + var isSameElement = function (other) { + return other.kind === "method" && other.key === element.key && other.placement === element.placement; + }; + + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + var other; + + if (element.kind === "method" && (other = newElements.find(isSameElement))) { + if (_isDataDescriptor(element.descriptor) || _isDataDescriptor(other.descriptor)) { + if (_hasDecorators(element) || _hasDecorators(other)) { + throw new ReferenceError("Duplicated methods (" + element.key + ") can't be decorated."); + } + + other.descriptor = element.descriptor; + } else { + if (_hasDecorators(element)) { + if (_hasDecorators(other)) { + throw new ReferenceError("Decorators can't be placed on different accessors with for " + "the same property (" + element.key + ")."); + } + + other.decorators = element.decorators; + } + + _coalesceGetterSetter(element, other); + } + } else { + newElements.push(element); + } + } + + return newElements; + } + + function _hasDecorators(element) { + return element.decorators && element.decorators.length; + } + + function _isDataDescriptor(desc) { + return desc !== undefined && !(desc.value === undefined && desc.writable === undefined); + } + + function _optionalCallableProperty(obj, name) { + var value = obj[name]; + + if (value !== undefined && typeof value !== "function") { + throw new TypeError("Expected '" + name + "' to be a function"); + } + + return value; + } + + function _classPrivateMethodGet(receiver, privateSet, fn) { + if (!privateSet.has(receiver)) { + throw new TypeError("attempted to get private field on non-instance"); + } + + return fn; + } + + function _classPrivateMethodSet() { + throw new TypeError("attempted to reassign private method"); + } + + function _wrapRegExp(re, groups) { + _wrapRegExp = function (re, groups) { + return new BabelRegExp(re, undefined, groups); + }; + + var _RegExp = _wrapNativeSuper(RegExp); + + var _super = RegExp.prototype; + + var _groups = new WeakMap(); + + function BabelRegExp(re, flags, groups) { + var _this = _RegExp.call(this, re, flags); + + _groups.set(_this, groups || _groups.get(re)); + + return _this; + } + + _inherits(BabelRegExp, _RegExp); + + BabelRegExp.prototype.exec = function (str) { + var result = _super.exec.call(this, str); + + if (result) result.groups = buildGroups(result, this); + return result; + }; + + BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { + if (typeof substitution === "string") { + var groups = _groups.get(this); + + return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { + return "$" + groups[name]; + })); + } else if (typeof substitution === "function") { + var _this = this; + + return _super[Symbol.replace].call(this, str, function () { + var args = []; + args.push.apply(args, arguments); + + if (typeof args[args.length - 1] !== "object") { + args.push(buildGroups(args, _this)); + } + + return substitution.apply(this, args); + }); + } else { + return _super[Symbol.replace].call(this, str, substitution); + } + }; + + function buildGroups(result, re) { + var g = _groups.get(re); + + return Object.keys(g).reduce(function (groups, name) { + groups[name] = result[g[name]]; + return groups; + }, Object.create(null)); + } + + return _wrapRegExp.apply(this, arguments); + } + + /** + * @file ext-helloworld.js + * + * @license MIT + * + * @copyright 2010 Alexis Deveria + * + */ + + /** + * This is a very basic SVG-Edit extension. It adds a "Hello World" button in + * the left ("mode") panel. Clicking on the button, and then the canvas + * will show the user the point on the canvas that was clicked on. + */ + var extHelloworld = exports('default', { + name: 'helloworld', + init: function init(_ref) { + var _this = this; + + return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { + var $, importLocale, strings, svgEditor, svgCanvas; + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + $ = _ref.$, importLocale = _ref.importLocale; + _context.next = 3; + return importLocale(); + + case 3: + strings = _context.sent; + svgEditor = _this; + svgCanvas = svgEditor.canvas; + return _context.abrupt("return", { + name: strings.name, + // For more notes on how to make an icon file, see the source of + // the helloworld-icon.xml + svgicons: svgEditor.curConfig.extIconsPath + 'helloworld-icon.xml', + // Multiple buttons can be added in this array + buttons: [{ + // Must match the icon ID in helloworld-icon.xml + id: 'hello_world', + // Fallback, e.g., for `file:///` access + icon: svgEditor.curConfig.extIconsPath + 'helloworld.png', + // This indicates that the button will be added to the "mode" + // button panel on the left side + type: 'mode', + // Tooltip text + title: strings.buttons[0].title, + // Events + events: { + click: function click() { + // The action taken when the button is clicked on. + // For "mode" buttons, any other button will + // automatically be de-pressed. + svgCanvas.setMode('hello_world'); + } + } + }], + // This is triggered when the main mouse button is pressed down + // on the editor canvas (not the tool panels) + mouseDown: function mouseDown() { + // Check the mode on mousedown + if (svgCanvas.getMode() === 'hello_world') { + // The returned object must include "started" with + // a value of true in order for mouseUp to be triggered + return { + started: true + }; + } + + return undefined; + }, + // This is triggered from anywhere, but "started" must have been set + // to true (see above). Note that "opts" is an object with event info + mouseUp: function mouseUp(opts) { + // Check the mode on mouseup + if (svgCanvas.getMode() === 'hello_world') { + var zoom = svgCanvas.getZoom(); // Get the actual coordinate by dividing by the zoom value + + var x = opts.mouse_x / zoom; + var y = opts.mouse_y / zoom; // We do our own formatting + + var text = strings.text; + [['x', x], ['y', y]].forEach(function (_ref2) { + var _ref3 = _slicedToArray(_ref2, 2), + prop = _ref3[0], + val = _ref3[1]; + + text = text.replace('{' + prop + '}', val); + }); // Show the text using the custom alert function + + $.alert(text); + } + } + }); + + case 7: + case "end": + return _context.stop(); + } + } + }, _callee); + }))(); + } + }); + + } + }; +}); diff --git a/dist/editor/system/extensions/ext-imagelib.js b/dist/editor/system/extensions/ext-imagelib.js new file mode 100644 index 00000000..def88a46 --- /dev/null +++ b/dist/editor/system/extensions/ext-imagelib.js @@ -0,0 +1,2176 @@ +System.register([], function (exports) { + 'use strict'; + return { + execute: function () { + + function _typeof(obj) { + "@babel/helpers - typeof"; + + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function (obj) { + return typeof obj; + }; + } else { + _typeof = function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); + } + + var REACT_ELEMENT_TYPE; + + function _jsx(type, props, key, children) { + if (!REACT_ELEMENT_TYPE) { + REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol["for"] && Symbol["for"]("react.element") || 0xeac7; + } + + var defaultProps = type && type.defaultProps; + var childrenLength = arguments.length - 3; + + if (!props && childrenLength !== 0) { + props = { + children: void 0 + }; + } + + if (childrenLength === 1) { + props.children = children; + } else if (childrenLength > 1) { + var childArray = new Array(childrenLength); + + for (var i = 0; i < childrenLength; i++) { + childArray[i] = arguments[i + 3]; + } + + props.children = childArray; + } + + if (props && defaultProps) { + for (var propName in defaultProps) { + if (props[propName] === void 0) { + props[propName] = defaultProps[propName]; + } + } + } else if (!props) { + props = defaultProps || {}; + } + + return { + $$typeof: REACT_ELEMENT_TYPE, + type: type, + key: key === undefined ? null : '' + key, + ref: null, + props: props, + _owner: null + }; + } + + function _asyncIterator(iterable) { + var method; + + if (typeof Symbol !== "undefined") { + if (Symbol.asyncIterator) { + method = iterable[Symbol.asyncIterator]; + if (method != null) return method.call(iterable); + } + + if (Symbol.iterator) { + method = iterable[Symbol.iterator]; + if (method != null) return method.call(iterable); + } + } + + throw new TypeError("Object is not async iterable"); + } + + function _AwaitValue(value) { + this.wrapped = value; + } + + function _AsyncGenerator(gen) { + var front, back; + + function send(key, arg) { + return new Promise(function (resolve, reject) { + var request = { + key: key, + arg: arg, + resolve: resolve, + reject: reject, + next: null + }; + + if (back) { + back = back.next = request; + } else { + front = back = request; + resume(key, arg); + } + }); + } + + function resume(key, arg) { + try { + var result = gen[key](arg); + var value = result.value; + var wrappedAwait = value instanceof _AwaitValue; + Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { + if (wrappedAwait) { + resume(key === "return" ? "return" : "next", arg); + return; + } + + settle(result.done ? "return" : "normal", arg); + }, function (err) { + resume("throw", err); + }); + } catch (err) { + settle("throw", err); + } + } + + function settle(type, value) { + switch (type) { + case "return": + front.resolve({ + value: value, + done: true + }); + break; + + case "throw": + front.reject(value); + break; + + default: + front.resolve({ + value: value, + done: false + }); + break; + } + + front = front.next; + + if (front) { + resume(front.key, front.arg); + } else { + back = null; + } + } + + this._invoke = send; + + if (typeof gen.return !== "function") { + this.return = undefined; + } + } + + if (typeof Symbol === "function" && Symbol.asyncIterator) { + _AsyncGenerator.prototype[Symbol.asyncIterator] = function () { + return this; + }; + } + + _AsyncGenerator.prototype.next = function (arg) { + return this._invoke("next", arg); + }; + + _AsyncGenerator.prototype.throw = function (arg) { + return this._invoke("throw", arg); + }; + + _AsyncGenerator.prototype.return = function (arg) { + return this._invoke("return", arg); + }; + + function _wrapAsyncGenerator(fn) { + return function () { + return new _AsyncGenerator(fn.apply(this, arguments)); + }; + } + + function _awaitAsyncGenerator(value) { + return new _AwaitValue(value); + } + + function _asyncGeneratorDelegate(inner, awaitWrap) { + var iter = {}, + waiting = false; + + function pump(key, value) { + waiting = true; + value = new Promise(function (resolve) { + resolve(inner[key](value)); + }); + return { + done: false, + value: awaitWrap(value) + }; + } + + ; + + if (typeof Symbol === "function" && Symbol.iterator) { + iter[Symbol.iterator] = function () { + return this; + }; + } + + iter.next = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("next", value); + }; + + if (typeof inner.throw === "function") { + iter.throw = function (value) { + if (waiting) { + waiting = false; + throw value; + } + + return pump("throw", value); + }; + } + + if (typeof inner.return === "function") { + iter.return = function (value) { + if (waiting) { + waiting = false; + return value; + } + + return pump("return", value); + }; + } + + return iter; + } + + function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { + try { + var info = gen[key](arg); + var value = info.value; + } catch (error) { + reject(error); + return; + } + + if (info.done) { + resolve(value); + } else { + Promise.resolve(value).then(_next, _throw); + } + } + + function _asyncToGenerator(fn) { + return function () { + var self = this, + args = arguments; + return new Promise(function (resolve, reject) { + var gen = fn.apply(self, args); + + function _next(value) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); + } + + function _throw(err) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); + } + + _next(undefined); + }); + }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; + } + + function _defineEnumerableProperties(obj, descs) { + for (var key in descs) { + var desc = descs[key]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, key, desc); + } + + if (Object.getOwnPropertySymbols) { + var objectSymbols = Object.getOwnPropertySymbols(descs); + + for (var i = 0; i < objectSymbols.length; i++) { + var sym = objectSymbols[i]; + var desc = descs[sym]; + desc.configurable = desc.enumerable = true; + if ("value" in desc) desc.writable = true; + Object.defineProperty(obj, sym, desc); + } + } + + return obj; + } + + function _defaults(obj, defaults) { + var keys = Object.getOwnPropertyNames(defaults); + + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var value = Object.getOwnPropertyDescriptor(defaults, key); + + if (value && value.configurable && obj[key] === undefined) { + Object.defineProperty(obj, key, value); + } + } + + return obj; + } + + function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; + } + + function _extends() { + _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + + return _extends.apply(this, arguments); + } + + function _objectSpread(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? Object(arguments[i]) : {}; + var ownKeys = Object.keys(source); + + if (typeof Object.getOwnPropertySymbols === 'function') { + ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { + return Object.getOwnPropertyDescriptor(source, sym).enumerable; + })); + } + + ownKeys.forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } + + return target; + } + + function ownKeys(object, enumerableOnly) { + var keys = Object.keys(object); + + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(object); + if (enumerableOnly) symbols = symbols.filter(function (sym) { + return Object.getOwnPropertyDescriptor(object, sym).enumerable; + }); + keys.push.apply(keys, symbols); + } + + return keys; + } + + function _objectSpread2(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? arguments[i] : {}; + + if (i % 2) { + ownKeys(Object(source), true).forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } else if (Object.getOwnPropertyDescriptors) { + Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); + } else { + ownKeys(Object(source)).forEach(function (key) { + Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); + }); + } + } + + return target; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function"); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + writable: true, + configurable: true + } + }); + if (superClass) _setPrototypeOf(subClass, superClass); + } + + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + subClass.__proto__ = superClass; + } + + function _getPrototypeOf(o) { + _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { + return o.__proto__ || Object.getPrototypeOf(o); + }; + return _getPrototypeOf(o); + } + + function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + + return _setPrototypeOf(o, p); + } + + function _isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + + try { + Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); + return true; + } catch (e) { + return false; + } + } + + function _construct(Parent, args, Class) { + if (_isNativeReflectConstruct()) { + _construct = Reflect.construct; + } else { + _construct = function _construct(Parent, args, Class) { + var a = [null]; + a.push.apply(a, args); + var Constructor = Function.bind.apply(Parent, a); + var instance = new Constructor(); + if (Class) _setPrototypeOf(instance, Class.prototype); + return instance; + }; + } + + return _construct.apply(null, arguments); + } + + function _isNativeFunction(fn) { + return Function.toString.call(fn).indexOf("[native code]") !== -1; + } + + function _wrapNativeSuper(Class) { + var _cache = typeof Map === "function" ? new Map() : undefined; + + _wrapNativeSuper = function _wrapNativeSuper(Class) { + if (Class === null || !_isNativeFunction(Class)) return Class; + + if (typeof Class !== "function") { + throw new TypeError("Super expression must either be null or a function"); + } + + if (typeof _cache !== "undefined") { + if (_cache.has(Class)) return _cache.get(Class); + + _cache.set(Class, Wrapper); + } + + function Wrapper() { + return _construct(Class, arguments, _getPrototypeOf(this).constructor); + } + + Wrapper.prototype = Object.create(Class.prototype, { + constructor: { + value: Wrapper, + enumerable: false, + writable: true, + configurable: true + } + }); + return _setPrototypeOf(Wrapper, Class); + }; + + return _wrapNativeSuper(Class); + } + + function _instanceof(left, right) { + if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { + return !!right[Symbol.hasInstance](left); + } else { + return left instanceof right; + } + } + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + + function _getRequireWildcardCache() { + if (typeof WeakMap !== "function") return null; + var cache = new WeakMap(); + + _getRequireWildcardCache = function () { + return cache; + }; + + return cache; + } + + function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } + + if (obj === null || typeof obj !== "object" && typeof obj !== "function") { + return { + default: obj + }; + } + + var cache = _getRequireWildcardCache(); + + if (cache && cache.has(obj)) { + return cache.get(obj); + } + + var newObj = {}; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + + if (desc && (desc.get || desc.set)) { + Object.defineProperty(newObj, key, desc); + } else { + newObj[key] = obj[key]; + } + } + } + + newObj.default = obj; + + if (cache) { + cache.set(obj, newObj); + } + + return newObj; + } + + function _newArrowCheck(innerThis, boundThis) { + if (innerThis !== boundThis) { + throw new TypeError("Cannot instantiate an arrow function"); + } + } + + function _objectDestructuringEmpty(obj) { + if (obj == null) throw new TypeError("Cannot destructure undefined"); + } + + function _objectWithoutPropertiesLoose(source, excluded) { + if (source == null) return {}; + var target = {}; + var sourceKeys = Object.keys(source); + var key, i; + + for (i = 0; i < sourceKeys.length; i++) { + key = sourceKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + target[key] = source[key]; + } + + return target; + } + + function _objectWithoutProperties(source, excluded) { + if (source == null) return {}; + + var target = _objectWithoutPropertiesLoose(source, excluded); + + var key, i; + + if (Object.getOwnPropertySymbols) { + var sourceSymbolKeys = Object.getOwnPropertySymbols(source); + + for (i = 0; i < sourceSymbolKeys.length; i++) { + key = sourceSymbolKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; + target[key] = source[key]; + } + } + + return target; + } + + function _assertThisInitialized(self) { + if (self === void 0) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return self; + } + + function _possibleConstructorReturn(self, call) { + if (call && (typeof call === "object" || typeof call === "function")) { + return call; + } + + return _assertThisInitialized(self); + } + + function _createSuper(Derived) { + var hasNativeReflectConstruct = _isNativeReflectConstruct(); + + return function _createSuperInternal() { + var Super = _getPrototypeOf(Derived), + result; + + if (hasNativeReflectConstruct) { + var NewTarget = _getPrototypeOf(this).constructor; + + result = Reflect.construct(Super, arguments, NewTarget); + } else { + result = Super.apply(this, arguments); + } + + return _possibleConstructorReturn(this, result); + }; + } + + function _superPropBase(object, property) { + while (!Object.prototype.hasOwnProperty.call(object, property)) { + object = _getPrototypeOf(object); + if (object === null) break; + } + + return object; + } + + function _get(target, property, receiver) { + if (typeof Reflect !== "undefined" && Reflect.get) { + _get = Reflect.get; + } else { + _get = function _get(target, property, receiver) { + var base = _superPropBase(target, property); + + if (!base) return; + var desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.get) { + return desc.get.call(receiver); + } + + return desc.value; + }; + } + + return _get(target, property, receiver || target); + } + + function set(target, property, value, receiver) { + if (typeof Reflect !== "undefined" && Reflect.set) { + set = Reflect.set; + } else { + set = function set(target, property, value, receiver) { + var base = _superPropBase(target, property); + + var desc; + + if (base) { + desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.set) { + desc.set.call(receiver, value); + return true; + } else if (!desc.writable) { + return false; + } + } + + desc = Object.getOwnPropertyDescriptor(receiver, property); + + if (desc) { + if (!desc.writable) { + return false; + } + + desc.value = value; + Object.defineProperty(receiver, property, desc); + } else { + _defineProperty(receiver, property, value); + } + + return true; + }; + } + + return set(target, property, value, receiver); + } + + function _set(target, property, value, receiver, isStrict) { + var s = set(target, property, value, receiver || target); + + if (!s && isStrict) { + throw new Error('failed to set property'); + } + + return value; + } + + function _taggedTemplateLiteral(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + return Object.freeze(Object.defineProperties(strings, { + raw: { + value: Object.freeze(raw) + } + })); + } + + function _taggedTemplateLiteralLoose(strings, raw) { + if (!raw) { + raw = strings.slice(0); + } + + strings.raw = raw; + return strings; + } + + function _readOnlyError(name) { + throw new Error("\"" + name + "\" is read-only"); + } + + function _classNameTDZError(name) { + throw new Error("Class \"" + name + "\" cannot be referenced in computed property keys."); + } + + function _temporalUndefined() {} + + function _tdz(name) { + throw new ReferenceError(name + " is not defined - temporal dead zone"); + } + + function _temporalRef(val, name) { + return val === _temporalUndefined ? _tdz(name) : val; + } + + function _slicedToArray(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); + } + + function _slicedToArrayLoose(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimitLoose(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); + } + + function _toArray(arr) { + return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); + } + + function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); + } + + function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) return _arrayLikeToArray(arr); + } + + function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; + } + + function _maybeArrayLike(next, arr, i) { + if (arr && !Array.isArray(arr) && typeof arr.length === "number") { + var len = arr.length; + return _arrayLikeToArray(arr, i !== void 0 && i < len ? i : len); + } + + return next(arr, i); + } + + function _iterableToArray(iter) { + if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); + } + + function _iterableToArrayLimit(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"] != null) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; + } + + function _iterableToArrayLimitLoose(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + + for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { + _arr.push(_step.value); + + if (i && _arr.length === i) break; + } + + return _arr; + } + + function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if (typeof o === "string") return _arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + if (n === "Object" && o.constructor) n = o.constructor.name; + if (n === "Map" || n === "Set") return Array.from(o); + if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); + } + + function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) len = arr.length; + + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + + return arr2; + } + + function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + function _createForOfIteratorHelper(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + + var F = function () {}; + + return { + s: F, + n: function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }, + e: function (e) { + throw e; + }, + f: F + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + var normalCompletion = true, + didErr = false, + err; + return { + s: function () { + it = o[Symbol.iterator](); + }, + n: function () { + var step = it.next(); + normalCompletion = step.done; + return step; + }, + e: function (e) { + didErr = true; + err = e; + }, + f: function () { + try { + if (!normalCompletion && it.return != null) it.return(); + } finally { + if (didErr) throw err; + } + } + }; + } + + function _createForOfIteratorHelperLoose(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + return function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + it = o[Symbol.iterator](); + return it.next.bind(it); + } + + function _skipFirstGeneratorNext(fn) { + return function () { + var it = fn.apply(this, arguments); + it.next(); + return it; + }; + } + + function _toPrimitive(input, hint) { + if (typeof input !== "object" || input === null) return input; + var prim = input[Symbol.toPrimitive]; + + if (prim !== undefined) { + var res = prim.call(input, hint || "default"); + if (typeof res !== "object") return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + + return (hint === "string" ? String : Number)(input); + } + + function _toPropertyKey(arg) { + var key = _toPrimitive(arg, "string"); + + return typeof key === "symbol" ? key : String(key); + } + + function _initializerWarningHelper(descriptor, context) { + throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.'); + } + + function _initializerDefineProperty(target, property, descriptor, context) { + if (!descriptor) return; + Object.defineProperty(target, property, { + enumerable: descriptor.enumerable, + configurable: descriptor.configurable, + writable: descriptor.writable, + value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 + }); + } + + function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { + var desc = {}; + Object.keys(descriptor).forEach(function (key) { + desc[key] = descriptor[key]; + }); + desc.enumerable = !!desc.enumerable; + desc.configurable = !!desc.configurable; + + if ('value' in desc || desc.initializer) { + desc.writable = true; + } + + desc = decorators.slice().reverse().reduce(function (desc, decorator) { + return decorator(target, property, desc) || desc; + }, desc); + + if (context && desc.initializer !== void 0) { + desc.value = desc.initializer ? desc.initializer.call(context) : void 0; + desc.initializer = undefined; + } + + if (desc.initializer === void 0) { + Object.defineProperty(target, property, desc); + desc = null; + } + + return desc; + } + + var id = 0; + + function _classPrivateFieldLooseKey(name) { + return "__private_" + id++ + "_" + name; + } + + function _classPrivateFieldLooseBase(receiver, privateKey) { + if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { + throw new TypeError("attempted to use private field on non-instance"); + } + + return receiver; + } + + function _classPrivateFieldGet(receiver, privateMap) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to get private field on non-instance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; + } + + function _classPrivateFieldSet(receiver, privateMap, value) { + var descriptor = privateMap.get(receiver); + + if (!descriptor) { + throw new TypeError("attempted to set private field on non-instance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; + } + + function _classPrivateFieldDestructureSet(receiver, privateMap) { + if (!privateMap.has(receiver)) { + throw new TypeError("attempted to set private field on non-instance"); + } + + var descriptor = privateMap.get(receiver); + + if (descriptor.set) { + if (!("__destrObj" in descriptor)) { + descriptor.__destrObj = { + set value(v) { + descriptor.set.call(receiver, v); + } + + }; + } + + return descriptor.__destrObj; + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + return descriptor; + } + } + + function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (descriptor.get) { + return descriptor.get.call(receiver); + } + + return descriptor.value; + } + + function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + throw new TypeError("attempted to set read only private field"); + } + + descriptor.value = value; + } + + return value; + } + + function _classStaticPrivateMethodGet(receiver, classConstructor, method) { + if (receiver !== classConstructor) { + throw new TypeError("Private static access of wrong provenance"); + } + + return method; + } + + function _classStaticPrivateMethodSet() { + throw new TypeError("attempted to set read only static private field"); + } + + function _decorate(decorators, factory, superClass, mixins) { + var api = _getDecoratorsApi(); + + if (mixins) { + for (var i = 0; i < mixins.length; i++) { + api = mixins[i](api); + } + } + + var r = factory(function initialize(O) { + api.initializeInstanceElements(O, decorated.elements); + }, superClass); + var decorated = api.decorateClass(_coalesceClassElements(r.d.map(_createElementDescriptor)), decorators); + api.initializeClassElements(r.F, decorated.elements); + return api.runClassFinishers(r.F, decorated.finishers); + } + + function _getDecoratorsApi() { + _getDecoratorsApi = function () { + return api; + }; + + var api = { + elementsDefinitionOrder: [["method"], ["field"]], + initializeInstanceElements: function (O, elements) { + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + if (element.kind === kind && element.placement === "own") { + this.defineClassElement(O, element); + } + }, this); + }, this); + }, + initializeClassElements: function (F, elements) { + var proto = F.prototype; + ["method", "field"].forEach(function (kind) { + elements.forEach(function (element) { + var placement = element.placement; + + if (element.kind === kind && (placement === "static" || placement === "prototype")) { + var receiver = placement === "static" ? F : proto; + this.defineClassElement(receiver, element); + } + }, this); + }, this); + }, + defineClassElement: function (receiver, element) { + var descriptor = element.descriptor; + + if (element.kind === "field") { + var initializer = element.initializer; + descriptor = { + enumerable: descriptor.enumerable, + writable: descriptor.writable, + configurable: descriptor.configurable, + value: initializer === void 0 ? void 0 : initializer.call(receiver) + }; + } + + Object.defineProperty(receiver, element.key, descriptor); + }, + decorateClass: function (elements, decorators) { + var newElements = []; + var finishers = []; + var placements = { + static: [], + prototype: [], + own: [] + }; + elements.forEach(function (element) { + this.addElementPlacement(element, placements); + }, this); + elements.forEach(function (element) { + if (!_hasDecorators(element)) return newElements.push(element); + var elementFinishersExtras = this.decorateElement(element, placements); + newElements.push(elementFinishersExtras.element); + newElements.push.apply(newElements, elementFinishersExtras.extras); + finishers.push.apply(finishers, elementFinishersExtras.finishers); + }, this); + + if (!decorators) { + return { + elements: newElements, + finishers: finishers + }; + } + + var result = this.decorateConstructor(newElements, decorators); + finishers.push.apply(finishers, result.finishers); + result.finishers = finishers; + return result; + }, + addElementPlacement: function (element, placements, silent) { + var keys = placements[element.placement]; + + if (!silent && keys.indexOf(element.key) !== -1) { + throw new TypeError("Duplicated element (" + element.key + ")"); + } + + keys.push(element.key); + }, + decorateElement: function (element, placements) { + var extras = []; + var finishers = []; + + for (var decorators = element.decorators, i = decorators.length - 1; i >= 0; i--) { + var keys = placements[element.placement]; + keys.splice(keys.indexOf(element.key), 1); + var elementObject = this.fromElementDescriptor(element); + var elementFinisherExtras = this.toElementFinisherExtras((0, decorators[i])(elementObject) || elementObject); + element = elementFinisherExtras.element; + this.addElementPlacement(element, placements); + + if (elementFinisherExtras.finisher) { + finishers.push(elementFinisherExtras.finisher); + } + + var newExtras = elementFinisherExtras.extras; + + if (newExtras) { + for (var j = 0; j < newExtras.length; j++) { + this.addElementPlacement(newExtras[j], placements); + } + + extras.push.apply(extras, newExtras); + } + } + + return { + element: element, + finishers: finishers, + extras: extras + }; + }, + decorateConstructor: function (elements, decorators) { + var finishers = []; + + for (var i = decorators.length - 1; i >= 0; i--) { + var obj = this.fromClassDescriptor(elements); + var elementsAndFinisher = this.toClassDescriptor((0, decorators[i])(obj) || obj); + + if (elementsAndFinisher.finisher !== undefined) { + finishers.push(elementsAndFinisher.finisher); + } + + if (elementsAndFinisher.elements !== undefined) { + elements = elementsAndFinisher.elements; + + for (var j = 0; j < elements.length - 1; j++) { + for (var k = j + 1; k < elements.length; k++) { + if (elements[j].key === elements[k].key && elements[j].placement === elements[k].placement) { + throw new TypeError("Duplicated element (" + elements[j].key + ")"); + } + } + } + } + } + + return { + elements: elements, + finishers: finishers + }; + }, + fromElementDescriptor: function (element) { + var obj = { + kind: element.kind, + key: element.key, + placement: element.placement, + descriptor: element.descriptor + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + if (element.kind === "field") obj.initializer = element.initializer; + return obj; + }, + toElementDescriptors: function (elementObjects) { + if (elementObjects === undefined) return; + return _toArray(elementObjects).map(function (elementObject) { + var element = this.toElementDescriptor(elementObject); + this.disallowProperty(elementObject, "finisher", "An element descriptor"); + this.disallowProperty(elementObject, "extras", "An element descriptor"); + return element; + }, this); + }, + toElementDescriptor: function (elementObject) { + var kind = String(elementObject.kind); + + if (kind !== "method" && kind !== "field") { + throw new TypeError('An element descriptor\'s .kind property must be either "method" or' + ' "field", but a decorator created an element descriptor with' + ' .kind "' + kind + '"'); + } + + var key = _toPropertyKey(elementObject.key); + + var placement = String(elementObject.placement); + + if (placement !== "static" && placement !== "prototype" && placement !== "own") { + throw new TypeError('An element descriptor\'s .placement property must be one of "static",' + ' "prototype" or "own", but a decorator created an element descriptor' + ' with .placement "' + placement + '"'); + } + + var descriptor = elementObject.descriptor; + this.disallowProperty(elementObject, "elements", "An element descriptor"); + var element = { + kind: kind, + key: key, + placement: placement, + descriptor: Object.assign({}, descriptor) + }; + + if (kind !== "field") { + this.disallowProperty(elementObject, "initializer", "A method descriptor"); + } else { + this.disallowProperty(descriptor, "get", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "set", "The property descriptor of a field descriptor"); + this.disallowProperty(descriptor, "value", "The property descriptor of a field descriptor"); + element.initializer = elementObject.initializer; + } + + return element; + }, + toElementFinisherExtras: function (elementObject) { + var element = this.toElementDescriptor(elementObject); + + var finisher = _optionalCallableProperty(elementObject, "finisher"); + + var extras = this.toElementDescriptors(elementObject.extras); + return { + element: element, + finisher: finisher, + extras: extras + }; + }, + fromClassDescriptor: function (elements) { + var obj = { + kind: "class", + elements: elements.map(this.fromElementDescriptor, this) + }; + var desc = { + value: "Descriptor", + configurable: true + }; + Object.defineProperty(obj, Symbol.toStringTag, desc); + return obj; + }, + toClassDescriptor: function (obj) { + var kind = String(obj.kind); + + if (kind !== "class") { + throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator' + ' created a class descriptor with .kind "' + kind + '"'); + } + + this.disallowProperty(obj, "key", "A class descriptor"); + this.disallowProperty(obj, "placement", "A class descriptor"); + this.disallowProperty(obj, "descriptor", "A class descriptor"); + this.disallowProperty(obj, "initializer", "A class descriptor"); + this.disallowProperty(obj, "extras", "A class descriptor"); + + var finisher = _optionalCallableProperty(obj, "finisher"); + + var elements = this.toElementDescriptors(obj.elements); + return { + elements: elements, + finisher: finisher + }; + }, + runClassFinishers: function (constructor, finishers) { + for (var i = 0; i < finishers.length; i++) { + var newConstructor = (0, finishers[i])(constructor); + + if (newConstructor !== undefined) { + if (typeof newConstructor !== "function") { + throw new TypeError("Finishers must return a constructor."); + } + + constructor = newConstructor; + } + } + + return constructor; + }, + disallowProperty: function (obj, name, objectType) { + if (obj[name] !== undefined) { + throw new TypeError(objectType + " can't have a ." + name + " property."); + } + } + }; + return api; + } + + function _createElementDescriptor(def) { + var key = _toPropertyKey(def.key); + + var descriptor; + + if (def.kind === "method") { + descriptor = { + value: def.value, + writable: true, + configurable: true, + enumerable: false + }; + } else if (def.kind === "get") { + descriptor = { + get: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "set") { + descriptor = { + set: def.value, + configurable: true, + enumerable: false + }; + } else if (def.kind === "field") { + descriptor = { + configurable: true, + writable: true, + enumerable: true + }; + } + + var element = { + kind: def.kind === "field" ? "field" : "method", + key: key, + placement: def.static ? "static" : def.kind === "field" ? "own" : "prototype", + descriptor: descriptor + }; + if (def.decorators) element.decorators = def.decorators; + if (def.kind === "field") element.initializer = def.value; + return element; + } + + function _coalesceGetterSetter(element, other) { + if (element.descriptor.get !== undefined) { + other.descriptor.get = element.descriptor.get; + } else { + other.descriptor.set = element.descriptor.set; + } + } + + function _coalesceClassElements(elements) { + var newElements = []; + + var isSameElement = function (other) { + return other.kind === "method" && other.key === element.key && other.placement === element.placement; + }; + + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + var other; + + if (element.kind === "method" && (other = newElements.find(isSameElement))) { + if (_isDataDescriptor(element.descriptor) || _isDataDescriptor(other.descriptor)) { + if (_hasDecorators(element) || _hasDecorators(other)) { + throw new ReferenceError("Duplicated methods (" + element.key + ") can't be decorated."); + } + + other.descriptor = element.descriptor; + } else { + if (_hasDecorators(element)) { + if (_hasDecorators(other)) { + throw new ReferenceError("Decorators can't be placed on different accessors with for " + "the same property (" + element.key + ")."); + } + + other.decorators = element.decorators; + } + + _coalesceGetterSetter(element, other); + } + } else { + newElements.push(element); + } + } + + return newElements; + } + + function _hasDecorators(element) { + return element.decorators && element.decorators.length; + } + + function _isDataDescriptor(desc) { + return desc !== undefined && !(desc.value === undefined && desc.writable === undefined); + } + + function _optionalCallableProperty(obj, name) { + var value = obj[name]; + + if (value !== undefined && typeof value !== "function") { + throw new TypeError("Expected '" + name + "' to be a function"); + } + + return value; + } + + function _classPrivateMethodGet(receiver, privateSet, fn) { + if (!privateSet.has(receiver)) { + throw new TypeError("attempted to get private field on non-instance"); + } + + return fn; + } + + function _classPrivateMethodSet() { + throw new TypeError("attempted to reassign private method"); + } + + function _wrapRegExp(re, groups) { + _wrapRegExp = function (re, groups) { + return new BabelRegExp(re, undefined, groups); + }; + + var _RegExp = _wrapNativeSuper(RegExp); + + var _super = RegExp.prototype; + + var _groups = new WeakMap(); + + function BabelRegExp(re, flags, groups) { + var _this = _RegExp.call(this, re, flags); + + _groups.set(_this, groups || _groups.get(re)); + + return _this; + } + + _inherits(BabelRegExp, _RegExp); + + BabelRegExp.prototype.exec = function (str) { + var result = _super.exec.call(this, str); + + if (result) result.groups = buildGroups(result, this); + return result; + }; + + BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { + if (typeof substitution === "string") { + var groups = _groups.get(this); + + return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { + return "$" + groups[name]; + })); + } else if (typeof substitution === "function") { + var _this = this; + + return _super[Symbol.replace].call(this, str, function () { + var args = []; + args.push.apply(args, arguments); + + if (typeof args[args.length - 1] !== "object") { + args.push(buildGroups(args, _this)); + } + + return substitution.apply(this, args); + }); + } else { + return _super[Symbol.replace].call(this, str, substitution); + } + }; + + function buildGroups(result, re) { + var g = _groups.get(re); + + return Object.keys(g).reduce(function (groups, name) { + groups[name] = result[g[name]]; + return groups; + }, Object.create(null)); + } + + return _wrapRegExp.apply(this, arguments); + } + + var extImagelib = "ext-imagelib.xml"; + + var extImagelib$1 = exports('default', { + name: 'imagelib', + init: function init(_ref) { + var _this = this; + + return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() { + var $, decode64, importLocale, dropXMLInternalSubset, imagelibStrings, modularVersion, svgEditor, uiStrings, svgCanvas, extIconsPath, allowedImageLibOrigins, closeBrowser, importImage, pending, mode, multiArr, transferStopped, preview, submit, onMessage, _onMessage, toggleMulti, showBrowser, buttons; + + return regeneratorRuntime.wrap(function _callee2$(_context2) { + while (1) { + switch (_context2.prev = _context2.next) { + case 0: + showBrowser = function _showBrowser() { + var browser = $('#imgbrowse'); + + if (!browser.length) { + $('
    ' + '
    ').insertAfter('#svg_docprops'); + browser = $('#imgbrowse'); + var allLibs = imagelibStrings.select_lib; + var libOpts = $('
      ').appendTo(browser); + var frame = $('