aw-highstock_rails 7.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (697) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.travis.yml +7 -0
  4. data/CODE_OF_CONDUCT.md +74 -0
  5. data/Gemfile +6 -0
  6. data/Gemfile.lock +22 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +53 -0
  9. data/Rakefile +10 -0
  10. data/aw-highstock_rails.gemspec +28 -0
  11. data/bin/console +14 -0
  12. data/bin/setup +8 -0
  13. data/lib/aw/highstock_rails.rb +9 -0
  14. data/lib/aw/highstock_rails/version.rb +5 -0
  15. data/vendor/assets/javascripts/highstock/css/annotations/popup.css +229 -0
  16. data/vendor/assets/javascripts/highstock/css/annotations/popup.scss +235 -0
  17. data/vendor/assets/javascripts/highstock/css/highcharts.css +890 -0
  18. data/vendor/assets/javascripts/highstock/css/highcharts.scss +788 -0
  19. data/vendor/assets/javascripts/highstock/css/stocktools/gui.css +268 -0
  20. data/vendor/assets/javascripts/highstock/css/stocktools/gui.scss +270 -0
  21. data/vendor/assets/javascripts/highstock/css/themes/dark-unica.css +951 -0
  22. data/vendor/assets/javascripts/highstock/css/themes/dark-unica.scss +122 -0
  23. data/vendor/assets/javascripts/highstock/css/themes/grid-light.css +904 -0
  24. data/vendor/assets/javascripts/highstock/css/themes/grid-light.scss +33 -0
  25. data/vendor/assets/javascripts/highstock/css/themes/sand-signika.css +920 -0
  26. data/vendor/assets/javascripts/highstock/css/themes/sand-signika.scss +74 -0
  27. data/vendor/assets/javascripts/highstock/es-modules/annotations/ControlPoint.js +130 -0
  28. data/vendor/assets/javascripts/highstock/es-modules/annotations/MockPoint.js +415 -0
  29. data/vendor/assets/javascripts/highstock/es-modules/annotations/annotations.src.js +1231 -0
  30. data/vendor/assets/javascripts/highstock/es-modules/annotations/controllable/ControllableCircle.js +92 -0
  31. data/vendor/assets/javascripts/highstock/es-modules/annotations/controllable/ControllableImage.js +101 -0
  32. data/vendor/assets/javascripts/highstock/es-modules/annotations/controllable/ControllableLabel.js +452 -0
  33. data/vendor/assets/javascripts/highstock/es-modules/annotations/controllable/ControllablePath.js +175 -0
  34. data/vendor/assets/javascripts/highstock/es-modules/annotations/controllable/ControllableRect.js +93 -0
  35. data/vendor/assets/javascripts/highstock/es-modules/annotations/controllable/controllableMixin.js +411 -0
  36. data/vendor/assets/javascripts/highstock/es-modules/annotations/controllable/markerMixin.js +214 -0
  37. data/vendor/assets/javascripts/highstock/es-modules/annotations/eventEmitterMixin.js +271 -0
  38. data/vendor/assets/javascripts/highstock/es-modules/annotations/navigationBindings.js +1283 -0
  39. data/vendor/assets/javascripts/highstock/es-modules/annotations/popup.js +1069 -0
  40. data/vendor/assets/javascripts/highstock/es-modules/annotations/types/CrookedLine.js +191 -0
  41. data/vendor/assets/javascripts/highstock/es-modules/annotations/types/ElliottWave.js +76 -0
  42. data/vendor/assets/javascripts/highstock/es-modules/annotations/types/Fibonacci.js +247 -0
  43. data/vendor/assets/javascripts/highstock/es-modules/annotations/types/InfinityLine.js +185 -0
  44. data/vendor/assets/javascripts/highstock/es-modules/annotations/types/Measure.js +928 -0
  45. data/vendor/assets/javascripts/highstock/es-modules/annotations/types/Pitchfork.js +203 -0
  46. data/vendor/assets/javascripts/highstock/es-modules/annotations/types/Tunnel.js +242 -0
  47. data/vendor/assets/javascripts/highstock/es-modules/annotations/types/VerticalLine.js +157 -0
  48. data/vendor/assets/javascripts/highstock/es-modules/error-messages.js +128 -0
  49. data/vendor/assets/javascripts/highstock/es-modules/error.js +1 -0
  50. data/vendor/assets/javascripts/highstock/es-modules/indicators/acceleration-bands.src.js +199 -0
  51. data/vendor/assets/javascripts/highstock/es-modules/indicators/accumulation-distribution.src.js +129 -0
  52. data/vendor/assets/javascripts/highstock/es-modules/indicators/ao.src.js +206 -0
  53. data/vendor/assets/javascripts/highstock/es-modules/indicators/apo.src.js +148 -0
  54. data/vendor/assets/javascripts/highstock/es-modules/indicators/aroon-oscillator.src.js +128 -0
  55. data/vendor/assets/javascripts/highstock/es-modules/indicators/aroon.src.js +173 -0
  56. data/vendor/assets/javascripts/highstock/es-modules/indicators/atr.src.js +151 -0
  57. data/vendor/assets/javascripts/highstock/es-modules/indicators/bollinger-bands.src.js +209 -0
  58. data/vendor/assets/javascripts/highstock/es-modules/indicators/cci.src.js +131 -0
  59. data/vendor/assets/javascripts/highstock/es-modules/indicators/chaikin.src.js +167 -0
  60. data/vendor/assets/javascripts/highstock/es-modules/indicators/cmf.src.js +246 -0
  61. data/vendor/assets/javascripts/highstock/es-modules/indicators/dema.src.js +191 -0
  62. data/vendor/assets/javascripts/highstock/es-modules/indicators/dpo.src.js +138 -0
  63. data/vendor/assets/javascripts/highstock/es-modules/indicators/ema.src.js +166 -0
  64. data/vendor/assets/javascripts/highstock/es-modules/indicators/ichimoku-kinko-hyo.src.js +850 -0
  65. data/vendor/assets/javascripts/highstock/es-modules/indicators/indicators.src.js +425 -0
  66. data/vendor/assets/javascripts/highstock/es-modules/indicators/keltner-channels.src.js +193 -0
  67. data/vendor/assets/javascripts/highstock/es-modules/indicators/macd.src.js +417 -0
  68. data/vendor/assets/javascripts/highstock/es-modules/indicators/mfi.src.js +198 -0
  69. data/vendor/assets/javascripts/highstock/es-modules/indicators/momentum.src.js +119 -0
  70. data/vendor/assets/javascripts/highstock/es-modules/indicators/natr.src.js +74 -0
  71. data/vendor/assets/javascripts/highstock/es-modules/indicators/pivot-points.src.js +360 -0
  72. data/vendor/assets/javascripts/highstock/es-modules/indicators/ppo.src.js +152 -0
  73. data/vendor/assets/javascripts/highstock/es-modules/indicators/price-channel.src.js +149 -0
  74. data/vendor/assets/javascripts/highstock/es-modules/indicators/price-envelopes.src.js +251 -0
  75. data/vendor/assets/javascripts/highstock/es-modules/indicators/psar.src.js +307 -0
  76. data/vendor/assets/javascripts/highstock/es-modules/indicators/regressions.src.js +427 -0
  77. data/vendor/assets/javascripts/highstock/es-modules/indicators/roc.src.js +149 -0
  78. data/vendor/assets/javascripts/highstock/es-modules/indicators/rsi.src.js +163 -0
  79. data/vendor/assets/javascripts/highstock/es-modules/indicators/stochastic.src.js +193 -0
  80. data/vendor/assets/javascripts/highstock/es-modules/indicators/supertrend.src.js +544 -0
  81. data/vendor/assets/javascripts/highstock/es-modules/indicators/tema.src.js +247 -0
  82. data/vendor/assets/javascripts/highstock/es-modules/indicators/trix.src.js +96 -0
  83. data/vendor/assets/javascripts/highstock/es-modules/indicators/volume-by-price.src.js +671 -0
  84. data/vendor/assets/javascripts/highstock/es-modules/indicators/vwap.src.js +189 -0
  85. data/vendor/assets/javascripts/highstock/es-modules/indicators/williams-r.src.js +128 -0
  86. data/vendor/assets/javascripts/highstock/es-modules/indicators/wma.src.js +146 -0
  87. data/vendor/assets/javascripts/highstock/es-modules/indicators/zigzag.src.js +221 -0
  88. data/vendor/assets/javascripts/highstock/es-modules/masters/highcharts-3d.src.js +17 -0
  89. data/vendor/assets/javascripts/highstock/es-modules/masters/highcharts-more.src.js +22 -0
  90. data/vendor/assets/javascripts/highstock/es-modules/masters/highstock.src.js +11 -0
  91. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/acceleration-bands.src.js +11 -0
  92. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/accumulation-distribution.src.js +11 -0
  93. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/ao.src.js +11 -0
  94. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/apo.src.js +11 -0
  95. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/aroon-oscillator.src.js +11 -0
  96. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/aroon.src.js +11 -0
  97. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/atr.src.js +11 -0
  98. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/bollinger-bands.src.js +11 -0
  99. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/cci.src.js +11 -0
  100. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/chaikin.src.js +11 -0
  101. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/cmf.src.js +10 -0
  102. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/dema.src.js +11 -0
  103. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/dpo.src.js +11 -0
  104. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/ema.src.js +11 -0
  105. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/ichimoku-kinko-hyo.src.js +11 -0
  106. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/indicators-all.src.js +49 -0
  107. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/indicators.src.js +11 -0
  108. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/keltner-channels.src.js +11 -0
  109. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/macd.src.js +11 -0
  110. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/mfi.src.js +11 -0
  111. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/momentum.src.js +11 -0
  112. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/natr.src.js +11 -0
  113. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/pivot-points.src.js +11 -0
  114. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/ppo.src.js +11 -0
  115. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/price-channel.src.js +11 -0
  116. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/price-envelopes.src.js +11 -0
  117. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/psar.src.js +11 -0
  118. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/regressions.src.js +11 -0
  119. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/roc.src.js +11 -0
  120. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/rsi.src.js +11 -0
  121. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/stochastic.src.js +11 -0
  122. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/supertrend.src.js +11 -0
  123. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/tema.src.js +11 -0
  124. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/trix.src.js +11 -0
  125. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/volume-by-price.src.js +11 -0
  126. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/vwap.src.js +11 -0
  127. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/williams-r.src.js +11 -0
  128. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/wma.src.js +11 -0
  129. data/vendor/assets/javascripts/highstock/es-modules/masters/indicators/zigzag.src.js +11 -0
  130. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/accessibility.src.js +13 -0
  131. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/annotations-advanced.src.js +20 -0
  132. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/annotations.src.js +12 -0
  133. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/arrow-symbols.src.js +10 -0
  134. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/boost-canvas.src.js +11 -0
  135. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/boost.src.js +11 -0
  136. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/bullet.src.js +11 -0
  137. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/current-date-indicator.src.js +10 -0
  138. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/cylinder.src.js +10 -0
  139. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/data.src.js +10 -0
  140. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/datagrouping.src.js +12 -0
  141. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/debugger.src.js +13 -0
  142. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/dependency-wheel.src.js +10 -0
  143. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/drag-panes.src.js +11 -0
  144. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/draggable-points.src.js +9 -0
  145. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/drilldown.src.js +10 -0
  146. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/export-data.src.js +10 -0
  147. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/exporting.src.js +10 -0
  148. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/full-screen.src.js +11 -0
  149. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/funnel.src.js +10 -0
  150. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/grid-axis.src.js +10 -0
  151. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/heatmap.src.js +11 -0
  152. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/histogram-bellcurve.src.js +11 -0
  153. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/item-series.src.js +11 -0
  154. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/networkgraph.src.js +10 -0
  155. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/no-data-to-display.src.js +11 -0
  156. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/offline-exporting.src.js +10 -0
  157. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/oldie-polyfills.src.js +11 -0
  158. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/oldie.src.js +11 -0
  159. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/overlapping-datalabels.src.js +9 -0
  160. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/parallel-coordinates.src.js +11 -0
  161. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/pareto.src.js +11 -0
  162. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/pathfinder.src.js +10 -0
  163. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/pattern-fill.src.js +11 -0
  164. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/price-indicator.src.js +11 -0
  165. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/sankey.src.js +10 -0
  166. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/series-label.src.js +9 -0
  167. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/solid-gauge.src.js +10 -0
  168. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/sonification.src.js +12 -0
  169. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/static-scale.src.js +10 -0
  170. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/stock-tools.src.js +12 -0
  171. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/stock.src.js +19 -0
  172. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/streamgraph.src.js +10 -0
  173. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/sunburst.src.js +10 -0
  174. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/tilemap.src.js +10 -0
  175. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/timeline.src.js +11 -0
  176. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/treegrid.src.js +10 -0
  177. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/treemap.src.js +10 -0
  178. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/variable-pie.src.js +11 -0
  179. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/variwide.src.js +10 -0
  180. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/vector.src.js +10 -0
  181. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/venn.src.js +10 -0
  182. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/windbarb.src.js +10 -0
  183. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/wordcloud.src.js +10 -0
  184. data/vendor/assets/javascripts/highstock/es-modules/masters/modules/xrange.src.js +10 -0
  185. data/vendor/assets/javascripts/highstock/es-modules/masters/themes/avocado.js +9 -0
  186. data/vendor/assets/javascripts/highstock/es-modules/masters/themes/avocado.src.js +9 -0
  187. data/vendor/assets/javascripts/highstock/es-modules/masters/themes/dark-blue.src.js +9 -0
  188. data/vendor/assets/javascripts/highstock/es-modules/masters/themes/dark-green.src.js +9 -0
  189. data/vendor/assets/javascripts/highstock/es-modules/masters/themes/dark-unica.src.js +9 -0
  190. data/vendor/assets/javascripts/highstock/es-modules/masters/themes/gray.src.js +9 -0
  191. data/vendor/assets/javascripts/highstock/es-modules/masters/themes/grid-light.src.js +9 -0
  192. data/vendor/assets/javascripts/highstock/es-modules/masters/themes/grid.src.js +9 -0
  193. data/vendor/assets/javascripts/highstock/es-modules/masters/themes/sand-signika.src.js +9 -0
  194. data/vendor/assets/javascripts/highstock/es-modules/masters/themes/skies.src.js +9 -0
  195. data/vendor/assets/javascripts/highstock/es-modules/masters/themes/sunset.js +9 -0
  196. data/vendor/assets/javascripts/highstock/es-modules/masters/themes/sunset.src.js +9 -0
  197. data/vendor/assets/javascripts/highstock/es-modules/mixins/ajax.js +123 -0
  198. data/vendor/assets/javascripts/highstock/es-modules/mixins/centered-series.js +116 -0
  199. data/vendor/assets/javascripts/highstock/es-modules/mixins/derived-series.js +150 -0
  200. data/vendor/assets/javascripts/highstock/es-modules/mixins/download-url.js +103 -0
  201. data/vendor/assets/javascripts/highstock/es-modules/mixins/draw-point.js +51 -0
  202. data/vendor/assets/javascripts/highstock/es-modules/mixins/geometry-circles.js +300 -0
  203. data/vendor/assets/javascripts/highstock/es-modules/mixins/geometry.js +50 -0
  204. data/vendor/assets/javascripts/highstock/es-modules/mixins/indicator-required.js +49 -0
  205. data/vendor/assets/javascripts/highstock/es-modules/mixins/multipe-lines.js +223 -0
  206. data/vendor/assets/javascripts/highstock/es-modules/mixins/navigation.js +59 -0
  207. data/vendor/assets/javascripts/highstock/es-modules/mixins/nodes.js +76 -0
  208. data/vendor/assets/javascripts/highstock/es-modules/mixins/on-series.js +167 -0
  209. data/vendor/assets/javascripts/highstock/es-modules/mixins/polygon.js +293 -0
  210. data/vendor/assets/javascripts/highstock/es-modules/mixins/reduce-array.js +53 -0
  211. data/vendor/assets/javascripts/highstock/es-modules/mixins/tree-series.js +256 -0
  212. data/vendor/assets/javascripts/highstock/es-modules/modules/a11y-i18n.src.js +524 -0
  213. data/vendor/assets/javascripts/highstock/es-modules/modules/annotations-legacy.src.js +1951 -0
  214. data/vendor/assets/javascripts/highstock/es-modules/modules/bellcurve.src.js +173 -0
  215. data/vendor/assets/javascripts/highstock/es-modules/modules/boost-canvas.src.js +732 -0
  216. data/vendor/assets/javascripts/highstock/es-modules/modules/boost.src.js +3730 -0
  217. data/vendor/assets/javascripts/highstock/es-modules/modules/bullet.src.js +361 -0
  218. data/vendor/assets/javascripts/highstock/es-modules/modules/cylinder.src.js +389 -0
  219. data/vendor/assets/javascripts/highstock/es-modules/modules/data.src.js +2417 -0
  220. data/vendor/assets/javascripts/highstock/es-modules/modules/debugger.src.js +109 -0
  221. data/vendor/assets/javascripts/highstock/es-modules/modules/dependency-wheel.src.js +199 -0
  222. data/vendor/assets/javascripts/highstock/es-modules/modules/drag-panes.src.js +624 -0
  223. data/vendor/assets/javascripts/highstock/es-modules/modules/draggable-points.src.js +2625 -0
  224. data/vendor/assets/javascripts/highstock/es-modules/modules/drilldown.src.js +1300 -0
  225. data/vendor/assets/javascripts/highstock/es-modules/modules/export-data.src.js +983 -0
  226. data/vendor/assets/javascripts/highstock/es-modules/modules/exporting.src.js +2149 -0
  227. data/vendor/assets/javascripts/highstock/es-modules/modules/full-screen.src.js +40 -0
  228. data/vendor/assets/javascripts/highstock/es-modules/modules/funnel.src.js +552 -0
  229. data/vendor/assets/javascripts/highstock/es-modules/modules/histogram.src.js +229 -0
  230. data/vendor/assets/javascripts/highstock/es-modules/modules/item-series.src.js +150 -0
  231. data/vendor/assets/javascripts/highstock/es-modules/modules/keyboard-navigation.src.js +1606 -0
  232. data/vendor/assets/javascripts/highstock/es-modules/modules/networkgraph/QuadTree.js +175 -0
  233. data/vendor/assets/javascripts/highstock/es-modules/modules/networkgraph/layouts.js +506 -0
  234. data/vendor/assets/javascripts/highstock/es-modules/modules/networkgraph/networkgraph.src.js +740 -0
  235. data/vendor/assets/javascripts/highstock/es-modules/modules/no-data-to-display.src.js +260 -0
  236. data/vendor/assets/javascripts/highstock/es-modules/modules/offline-exporting.src.js +710 -0
  237. data/vendor/assets/javascripts/highstock/es-modules/modules/oldie-polyfills.src.js +121 -0
  238. data/vendor/assets/javascripts/highstock/es-modules/modules/oldie.src.js +1556 -0
  239. data/vendor/assets/javascripts/highstock/es-modules/modules/overlapping-datalabels.src.js +250 -0
  240. data/vendor/assets/javascripts/highstock/es-modules/modules/parallel-coordinates.src.js +492 -0
  241. data/vendor/assets/javascripts/highstock/es-modules/modules/pareto.src.js +152 -0
  242. data/vendor/assets/javascripts/highstock/es-modules/modules/pattern-fill.src.js +607 -0
  243. data/vendor/assets/javascripts/highstock/es-modules/modules/price-indicator.src.js +149 -0
  244. data/vendor/assets/javascripts/highstock/es-modules/modules/sankey.src.js +809 -0
  245. data/vendor/assets/javascripts/highstock/es-modules/modules/screen-reader.src.js +954 -0
  246. data/vendor/assets/javascripts/highstock/es-modules/modules/series-label.src.js +1042 -0
  247. data/vendor/assets/javascripts/highstock/es-modules/modules/solid-gauge.src.js +486 -0
  248. data/vendor/assets/javascripts/highstock/es-modules/modules/sonification/Earcon.js +184 -0
  249. data/vendor/assets/javascripts/highstock/es-modules/modules/sonification/Instrument.js +582 -0
  250. data/vendor/assets/javascripts/highstock/es-modules/modules/sonification/Timeline.js +702 -0
  251. data/vendor/assets/javascripts/highstock/es-modules/modules/sonification/chartSonify.js +1026 -0
  252. data/vendor/assets/javascripts/highstock/es-modules/modules/sonification/instrumentDefinitions.js +37 -0
  253. data/vendor/assets/javascripts/highstock/es-modules/modules/sonification/musicalFrequencies.js +113 -0
  254. data/vendor/assets/javascripts/highstock/es-modules/modules/sonification/pointSonify.js +385 -0
  255. data/vendor/assets/javascripts/highstock/es-modules/modules/sonification/sonification.js +107 -0
  256. data/vendor/assets/javascripts/highstock/es-modules/modules/sonification/utilities.js +178 -0
  257. data/vendor/assets/javascripts/highstock/es-modules/modules/static-scale.src.js +88 -0
  258. data/vendor/assets/javascripts/highstock/es-modules/modules/stock-tools-bindings.js +1950 -0
  259. data/vendor/assets/javascripts/highstock/es-modules/modules/stock-tools-gui.js +1458 -0
  260. data/vendor/assets/javascripts/highstock/es-modules/modules/streamgraph.src.js +132 -0
  261. data/vendor/assets/javascripts/highstock/es-modules/modules/sunburst.src.js +1041 -0
  262. data/vendor/assets/javascripts/highstock/es-modules/modules/tilemap.src.js +769 -0
  263. data/vendor/assets/javascripts/highstock/es-modules/modules/timeline.src.js +750 -0
  264. data/vendor/assets/javascripts/highstock/es-modules/modules/treemap.src.js +1803 -0
  265. data/vendor/assets/javascripts/highstock/es-modules/modules/variable-pie.src.js +459 -0
  266. data/vendor/assets/javascripts/highstock/es-modules/modules/variwide.src.js +350 -0
  267. data/vendor/assets/javascripts/highstock/es-modules/modules/vector.src.js +354 -0
  268. data/vendor/assets/javascripts/highstock/es-modules/modules/venn.src.js +1192 -0
  269. data/vendor/assets/javascripts/highstock/es-modules/modules/windbarb.src.js +380 -0
  270. data/vendor/assets/javascripts/highstock/es-modules/modules/wordcloud.src.js +1103 -0
  271. data/vendor/assets/javascripts/highstock/es-modules/modules/xrange.src.js +761 -0
  272. data/vendor/assets/javascripts/highstock/es-modules/parts-3d/Axis.js +669 -0
  273. data/vendor/assets/javascripts/highstock/es-modules/parts-3d/Chart.js +1753 -0
  274. data/vendor/assets/javascripts/highstock/es-modules/parts-3d/Column.js +437 -0
  275. data/vendor/assets/javascripts/highstock/es-modules/parts-3d/Math.js +206 -0
  276. data/vendor/assets/javascripts/highstock/es-modules/parts-3d/Pie.js +207 -0
  277. data/vendor/assets/javascripts/highstock/es-modules/parts-3d/SVGRenderer.js +1002 -0
  278. data/vendor/assets/javascripts/highstock/es-modules/parts-3d/Scatter.js +154 -0
  279. data/vendor/assets/javascripts/highstock/es-modules/parts-3d/Series.js +73 -0
  280. data/vendor/assets/javascripts/highstock/es-modules/parts-3d/VMLRenderer.js +62 -0
  281. data/vendor/assets/javascripts/highstock/es-modules/parts-gantt/ArrowSymbols.js +198 -0
  282. data/vendor/assets/javascripts/highstock/es-modules/parts-gantt/CurrentDateIndicator.js +100 -0
  283. data/vendor/assets/javascripts/highstock/es-modules/parts-gantt/GanttChart.js +140 -0
  284. data/vendor/assets/javascripts/highstock/es-modules/parts-gantt/GanttSeries.js +415 -0
  285. data/vendor/assets/javascripts/highstock/es-modules/parts-gantt/GridAxis.js +961 -0
  286. data/vendor/assets/javascripts/highstock/es-modules/parts-gantt/Pathfinder.js +1298 -0
  287. data/vendor/assets/javascripts/highstock/es-modules/parts-gantt/PathfinderAlgorithms.js +816 -0
  288. data/vendor/assets/javascripts/highstock/es-modules/parts-gantt/Tree.js +158 -0
  289. data/vendor/assets/javascripts/highstock/es-modules/parts-gantt/TreeGrid.js +1003 -0
  290. data/vendor/assets/javascripts/highstock/es-modules/parts-map/ColorAxis.js +1103 -0
  291. data/vendor/assets/javascripts/highstock/es-modules/parts-map/ColorSeriesMixin.js +138 -0
  292. data/vendor/assets/javascripts/highstock/es-modules/parts-map/GeoJSON.js +435 -0
  293. data/vendor/assets/javascripts/highstock/es-modules/parts-map/HeatmapSeries.js +474 -0
  294. data/vendor/assets/javascripts/highstock/es-modules/parts-map/Map.js +477 -0
  295. data/vendor/assets/javascripts/highstock/es-modules/parts-map/MapAxis.js +124 -0
  296. data/vendor/assets/javascripts/highstock/es-modules/parts-map/MapBubbleSeries.js +274 -0
  297. data/vendor/assets/javascripts/highstock/es-modules/parts-map/MapLineSeries.js +143 -0
  298. data/vendor/assets/javascripts/highstock/es-modules/parts-map/MapNavigation.js +357 -0
  299. data/vendor/assets/javascripts/highstock/es-modules/parts-map/MapPointSeries.js +187 -0
  300. data/vendor/assets/javascripts/highstock/es-modules/parts-map/MapPointer.js +132 -0
  301. data/vendor/assets/javascripts/highstock/es-modules/parts-map/MapSeries.js +1294 -0
  302. data/vendor/assets/javascripts/highstock/es-modules/parts-more/AreaRangeSeries.js +725 -0
  303. data/vendor/assets/javascripts/highstock/es-modules/parts-more/AreaSplineRangeSeries.js +98 -0
  304. data/vendor/assets/javascripts/highstock/es-modules/parts-more/BoxPlotSeries.js +617 -0
  305. data/vendor/assets/javascripts/highstock/es-modules/parts-more/BubbleLegend.js +1167 -0
  306. data/vendor/assets/javascripts/highstock/es-modules/parts-more/BubbleSeries.js +661 -0
  307. data/vendor/assets/javascripts/highstock/es-modules/parts-more/ColumnPyramidSeries.js +288 -0
  308. data/vendor/assets/javascripts/highstock/es-modules/parts-more/ColumnRangeSeries.js +278 -0
  309. data/vendor/assets/javascripts/highstock/es-modules/parts-more/ErrorBarSeries.js +172 -0
  310. data/vendor/assets/javascripts/highstock/es-modules/parts-more/GaugeSeries.js +618 -0
  311. data/vendor/assets/javascripts/highstock/es-modules/parts-more/PackedBubbleSeries.js +567 -0
  312. data/vendor/assets/javascripts/highstock/es-modules/parts-more/Pane.js +399 -0
  313. data/vendor/assets/javascripts/highstock/es-modules/parts-more/Polar.js +634 -0
  314. data/vendor/assets/javascripts/highstock/es-modules/parts-more/PolygonSeries.js +151 -0
  315. data/vendor/assets/javascripts/highstock/es-modules/parts-more/RadialAxis.js +685 -0
  316. data/vendor/assets/javascripts/highstock/es-modules/parts-more/WaterfallSeries.js +765 -0
  317. data/vendor/assets/javascripts/highstock/es-modules/parts.js +684 -0
  318. data/vendor/assets/javascripts/highstock/es-modules/parts/AreaSeries.js +578 -0
  319. data/vendor/assets/javascripts/highstock/es-modules/parts/AreaSplineSeries.js +122 -0
  320. data/vendor/assets/javascripts/highstock/es-modules/parts/Axis.js +6453 -0
  321. data/vendor/assets/javascripts/highstock/es-modules/parts/BarSeries.js +153 -0
  322. data/vendor/assets/javascripts/highstock/es-modules/parts/CandlestickSeries.js +358 -0
  323. data/vendor/assets/javascripts/highstock/es-modules/parts/Chart.js +2307 -0
  324. data/vendor/assets/javascripts/highstock/es-modules/parts/Color.js +301 -0
  325. data/vendor/assets/javascripts/highstock/es-modules/parts/ColumnSeries.js +1125 -0
  326. data/vendor/assets/javascripts/highstock/es-modules/parts/DataGrouping.js +1115 -0
  327. data/vendor/assets/javascripts/highstock/es-modules/parts/DataLabels.js +1431 -0
  328. data/vendor/assets/javascripts/highstock/es-modules/parts/DateTimeAxis.js +134 -0
  329. data/vendor/assets/javascripts/highstock/es-modules/parts/Dynamics.js +1301 -0
  330. data/vendor/assets/javascripts/highstock/es-modules/parts/FlagsSeries.js +739 -0
  331. data/vendor/assets/javascripts/highstock/es-modules/parts/Globals.js +75 -0
  332. data/vendor/assets/javascripts/highstock/es-modules/parts/Html.js +539 -0
  333. data/vendor/assets/javascripts/highstock/es-modules/parts/Interaction.js +1299 -0
  334. data/vendor/assets/javascripts/highstock/es-modules/parts/Legend.js +1411 -0
  335. data/vendor/assets/javascripts/highstock/es-modules/parts/LogarithmicAxis.js +168 -0
  336. data/vendor/assets/javascripts/highstock/es-modules/parts/MSPointer.js +176 -0
  337. data/vendor/assets/javascripts/highstock/es-modules/parts/Navigator.js +2486 -0
  338. data/vendor/assets/javascripts/highstock/es-modules/parts/OHLCSeries.js +412 -0
  339. data/vendor/assets/javascripts/highstock/es-modules/parts/Options.js +3732 -0
  340. data/vendor/assets/javascripts/highstock/es-modules/parts/OrdinalAxis.js +962 -0
  341. data/vendor/assets/javascripts/highstock/es-modules/parts/PieSeries.js +1328 -0
  342. data/vendor/assets/javascripts/highstock/es-modules/parts/PlotBandSeries.experimental.js +74 -0
  343. data/vendor/assets/javascripts/highstock/es-modules/parts/PlotLineOrBand.js +1061 -0
  344. data/vendor/assets/javascripts/highstock/es-modules/parts/Point.js +681 -0
  345. data/vendor/assets/javascripts/highstock/es-modules/parts/Pointer.js +1332 -0
  346. data/vendor/assets/javascripts/highstock/es-modules/parts/RangeSelector.js +2063 -0
  347. data/vendor/assets/javascripts/highstock/es-modules/parts/Responsive.js +295 -0
  348. data/vendor/assets/javascripts/highstock/es-modules/parts/ScatterSeries.js +278 -0
  349. data/vendor/assets/javascripts/highstock/es-modules/parts/ScrollablePlotArea.js +266 -0
  350. data/vendor/assets/javascripts/highstock/es-modules/parts/Scrollbar.js +1134 -0
  351. data/vendor/assets/javascripts/highstock/es-modules/parts/Series.js +5864 -0
  352. data/vendor/assets/javascripts/highstock/es-modules/parts/SplineSeries.js +267 -0
  353. data/vendor/assets/javascripts/highstock/es-modules/parts/Stacking.js +604 -0
  354. data/vendor/assets/javascripts/highstock/es-modules/parts/StockChart.js +951 -0
  355. data/vendor/assets/javascripts/highstock/es-modules/parts/SvgRenderer.js +5109 -0
  356. data/vendor/assets/javascripts/highstock/es-modules/parts/Tick.js +746 -0
  357. data/vendor/assets/javascripts/highstock/es-modules/parts/Time.js +881 -0
  358. data/vendor/assets/javascripts/highstock/es-modules/parts/Tooltip.js +1318 -0
  359. data/vendor/assets/javascripts/highstock/es-modules/parts/TouchPointer.js +404 -0
  360. data/vendor/assets/javascripts/highstock/es-modules/parts/Utilities.js +2751 -0
  361. data/vendor/assets/javascripts/highstock/es-modules/themes/avocado.js +37 -0
  362. data/vendor/assets/javascripts/highstock/es-modules/themes/dark-blue.js +259 -0
  363. data/vendor/assets/javascripts/highstock/es-modules/themes/dark-green.js +261 -0
  364. data/vendor/assets/javascripts/highstock/es-modules/themes/dark-unica.js +220 -0
  365. data/vendor/assets/javascripts/highstock/es-modules/themes/gray.js +267 -0
  366. data/vendor/assets/javascripts/highstock/es-modules/themes/grid-light.js +81 -0
  367. data/vendor/assets/javascripts/highstock/es-modules/themes/grid.js +110 -0
  368. data/vendor/assets/javascripts/highstock/es-modules/themes/sand-signika.js +111 -0
  369. data/vendor/assets/javascripts/highstock/es-modules/themes/skies.js +100 -0
  370. data/vendor/assets/javascripts/highstock/es-modules/themes/sunset.js +36 -0
  371. data/vendor/assets/javascripts/highstock/highcharts-3d.js +85 -0
  372. data/vendor/assets/javascripts/highstock/highcharts-3d.js.map +1 -0
  373. data/vendor/assets/javascripts/highstock/highcharts-more.js +101 -0
  374. data/vendor/assets/javascripts/highstock/highcharts-more.js.map +1 -0
  375. data/vendor/assets/javascripts/highstock/highstock.js +583 -0
  376. data/vendor/assets/javascripts/highstock/highstock.js.map +1 -0
  377. data/vendor/assets/javascripts/highstock/indicators/acceleration-bands.js +16 -0
  378. data/vendor/assets/javascripts/highstock/indicators/acceleration-bands.js.map +1 -0
  379. data/vendor/assets/javascripts/highstock/indicators/acceleration-bands.src.js +448 -0
  380. data/vendor/assets/javascripts/highstock/indicators/accumulation-distribution.js +12 -0
  381. data/vendor/assets/javascripts/highstock/indicators/accumulation-distribution.js.map +1 -0
  382. data/vendor/assets/javascripts/highstock/indicators/accumulation-distribution.src.js +156 -0
  383. data/vendor/assets/javascripts/highstock/indicators/ao.js +13 -0
  384. data/vendor/assets/javascripts/highstock/indicators/ao.js.map +1 -0
  385. data/vendor/assets/javascripts/highstock/indicators/ao.src.js +233 -0
  386. data/vendor/assets/javascripts/highstock/indicators/apo.js +13 -0
  387. data/vendor/assets/javascripts/highstock/indicators/apo.js.map +1 -0
  388. data/vendor/assets/javascripts/highstock/indicators/apo.src.js +223 -0
  389. data/vendor/assets/javascripts/highstock/indicators/aroon-oscillator.js +15 -0
  390. data/vendor/assets/javascripts/highstock/indicators/aroon-oscillator.js.map +1 -0
  391. data/vendor/assets/javascripts/highstock/indicators/aroon-oscillator.src.js +426 -0
  392. data/vendor/assets/javascripts/highstock/indicators/aroon.js +16 -0
  393. data/vendor/assets/javascripts/highstock/indicators/aroon.js.map +1 -0
  394. data/vendor/assets/javascripts/highstock/indicators/aroon.src.js +423 -0
  395. data/vendor/assets/javascripts/highstock/indicators/atr.js +12 -0
  396. data/vendor/assets/javascripts/highstock/indicators/atr.js.map +1 -0
  397. data/vendor/assets/javascripts/highstock/indicators/atr.src.js +178 -0
  398. data/vendor/assets/javascripts/highstock/indicators/bollinger-bands.js +16 -0
  399. data/vendor/assets/javascripts/highstock/indicators/bollinger-bands.js.map +1 -0
  400. data/vendor/assets/javascripts/highstock/indicators/bollinger-bands.src.js +458 -0
  401. data/vendor/assets/javascripts/highstock/indicators/cci.js +12 -0
  402. data/vendor/assets/javascripts/highstock/indicators/cci.js.map +1 -0
  403. data/vendor/assets/javascripts/highstock/indicators/cci.src.js +158 -0
  404. data/vendor/assets/javascripts/highstock/indicators/chaikin.js +15 -0
  405. data/vendor/assets/javascripts/highstock/indicators/chaikin.js.map +1 -0
  406. data/vendor/assets/javascripts/highstock/indicators/chaikin.src.js +370 -0
  407. data/vendor/assets/javascripts/highstock/indicators/cmf.js +12 -0
  408. data/vendor/assets/javascripts/highstock/indicators/cmf.js.map +1 -0
  409. data/vendor/assets/javascripts/highstock/indicators/cmf.src.js +273 -0
  410. data/vendor/assets/javascripts/highstock/indicators/dema.js +13 -0
  411. data/vendor/assets/javascripts/highstock/indicators/dema.js.map +1 -0
  412. data/vendor/assets/javascripts/highstock/indicators/dema.src.js +266 -0
  413. data/vendor/assets/javascripts/highstock/indicators/dpo.js +12 -0
  414. data/vendor/assets/javascripts/highstock/indicators/dpo.js.map +1 -0
  415. data/vendor/assets/javascripts/highstock/indicators/dpo.src.js +166 -0
  416. data/vendor/assets/javascripts/highstock/indicators/ema.js +12 -0
  417. data/vendor/assets/javascripts/highstock/indicators/ema.js.map +1 -0
  418. data/vendor/assets/javascripts/highstock/indicators/ema.src.js +193 -0
  419. data/vendor/assets/javascripts/highstock/indicators/ichimoku-kinko-hyo.js +22 -0
  420. data/vendor/assets/javascripts/highstock/indicators/ichimoku-kinko-hyo.js.map +1 -0
  421. data/vendor/assets/javascripts/highstock/indicators/ichimoku-kinko-hyo.src.js +877 -0
  422. data/vendor/assets/javascripts/highstock/indicators/indicators-all.js +117 -0
  423. data/vendor/assets/javascripts/highstock/indicators/indicators-all.js.map +1 -0
  424. data/vendor/assets/javascripts/highstock/indicators/indicators-all.src.js +9389 -0
  425. data/vendor/assets/javascripts/highstock/indicators/indicators.js +17 -0
  426. data/vendor/assets/javascripts/highstock/indicators/indicators.js.map +1 -0
  427. data/vendor/assets/javascripts/highstock/indicators/indicators.src.js +500 -0
  428. data/vendor/assets/javascripts/highstock/indicators/keltner-channels.js +16 -0
  429. data/vendor/assets/javascripts/highstock/indicators/keltner-channels.js.map +1 -0
  430. data/vendor/assets/javascripts/highstock/indicators/keltner-channels.src.js +442 -0
  431. data/vendor/assets/javascripts/highstock/indicators/macd.js +18 -0
  432. data/vendor/assets/javascripts/highstock/indicators/macd.js.map +1 -0
  433. data/vendor/assets/javascripts/highstock/indicators/macd.src.js +444 -0
  434. data/vendor/assets/javascripts/highstock/indicators/mfi.js +13 -0
  435. data/vendor/assets/javascripts/highstock/indicators/mfi.js.map +1 -0
  436. data/vendor/assets/javascripts/highstock/indicators/mfi.src.js +225 -0
  437. data/vendor/assets/javascripts/highstock/indicators/momentum.js +12 -0
  438. data/vendor/assets/javascripts/highstock/indicators/momentum.js.map +1 -0
  439. data/vendor/assets/javascripts/highstock/indicators/momentum.src.js +146 -0
  440. data/vendor/assets/javascripts/highstock/indicators/natr.js +12 -0
  441. data/vendor/assets/javascripts/highstock/indicators/natr.js.map +1 -0
  442. data/vendor/assets/javascripts/highstock/indicators/natr.src.js +101 -0
  443. data/vendor/assets/javascripts/highstock/indicators/pivot-points.js +16 -0
  444. data/vendor/assets/javascripts/highstock/indicators/pivot-points.js.map +1 -0
  445. data/vendor/assets/javascripts/highstock/indicators/pivot-points.src.js +387 -0
  446. data/vendor/assets/javascripts/highstock/indicators/ppo.js +13 -0
  447. data/vendor/assets/javascripts/highstock/indicators/ppo.js.map +1 -0
  448. data/vendor/assets/javascripts/highstock/indicators/ppo.src.js +227 -0
  449. data/vendor/assets/javascripts/highstock/indicators/price-channel.js +16 -0
  450. data/vendor/assets/javascripts/highstock/indicators/price-channel.js.map +1 -0
  451. data/vendor/assets/javascripts/highstock/indicators/price-channel.src.js +450 -0
  452. data/vendor/assets/javascripts/highstock/indicators/price-envelopes.js +15 -0
  453. data/vendor/assets/javascripts/highstock/indicators/price-envelopes.js.map +1 -0
  454. data/vendor/assets/javascripts/highstock/indicators/price-envelopes.src.js +278 -0
  455. data/vendor/assets/javascripts/highstock/indicators/psar.js +13 -0
  456. data/vendor/assets/javascripts/highstock/indicators/psar.js.map +1 -0
  457. data/vendor/assets/javascripts/highstock/indicators/psar.src.js +334 -0
  458. data/vendor/assets/javascripts/highstock/indicators/regressions.js +14 -0
  459. data/vendor/assets/javascripts/highstock/indicators/regressions.js.map +1 -0
  460. data/vendor/assets/javascripts/highstock/indicators/regressions.src.js +454 -0
  461. data/vendor/assets/javascripts/highstock/indicators/roc.js +12 -0
  462. data/vendor/assets/javascripts/highstock/indicators/roc.js.map +1 -0
  463. data/vendor/assets/javascripts/highstock/indicators/roc.src.js +176 -0
  464. data/vendor/assets/javascripts/highstock/indicators/rsi.js +12 -0
  465. data/vendor/assets/javascripts/highstock/indicators/rsi.js.map +1 -0
  466. data/vendor/assets/javascripts/highstock/indicators/rsi.src.js +190 -0
  467. data/vendor/assets/javascripts/highstock/indicators/stochastic.js +17 -0
  468. data/vendor/assets/javascripts/highstock/indicators/stochastic.js.map +1 -0
  469. data/vendor/assets/javascripts/highstock/indicators/stochastic.src.js +494 -0
  470. data/vendor/assets/javascripts/highstock/indicators/supertrend.js +17 -0
  471. data/vendor/assets/javascripts/highstock/indicators/supertrend.js.map +1 -0
  472. data/vendor/assets/javascripts/highstock/indicators/supertrend.src.js +571 -0
  473. data/vendor/assets/javascripts/highstock/indicators/tema.js +14 -0
  474. data/vendor/assets/javascripts/highstock/indicators/tema.js.map +1 -0
  475. data/vendor/assets/javascripts/highstock/indicators/tema.src.js +322 -0
  476. data/vendor/assets/javascripts/highstock/indicators/trix.js +12 -0
  477. data/vendor/assets/javascripts/highstock/indicators/trix.js.map +1 -0
  478. data/vendor/assets/javascripts/highstock/indicators/trix.src.js +171 -0
  479. data/vendor/assets/javascripts/highstock/indicators/volume-by-price.js +21 -0
  480. data/vendor/assets/javascripts/highstock/indicators/volume-by-price.js.map +1 -0
  481. data/vendor/assets/javascripts/highstock/indicators/volume-by-price.src.js +698 -0
  482. data/vendor/assets/javascripts/highstock/indicators/vwap.js +12 -0
  483. data/vendor/assets/javascripts/highstock/indicators/vwap.js.map +1 -0
  484. data/vendor/assets/javascripts/highstock/indicators/vwap.src.js +216 -0
  485. data/vendor/assets/javascripts/highstock/indicators/williams-r.js +13 -0
  486. data/vendor/assets/javascripts/highstock/indicators/williams-r.js.map +1 -0
  487. data/vendor/assets/javascripts/highstock/indicators/williams-r.src.js +207 -0
  488. data/vendor/assets/javascripts/highstock/indicators/wma.js +12 -0
  489. data/vendor/assets/javascripts/highstock/indicators/wma.js.map +1 -0
  490. data/vendor/assets/javascripts/highstock/indicators/wma.src.js +173 -0
  491. data/vendor/assets/javascripts/highstock/indicators/zigzag.js +13 -0
  492. data/vendor/assets/javascripts/highstock/indicators/zigzag.js.map +1 -0
  493. data/vendor/assets/javascripts/highstock/indicators/zigzag.src.js +248 -0
  494. data/vendor/assets/javascripts/highstock/lib/canvg.js +130 -0
  495. data/vendor/assets/javascripts/highstock/lib/canvg.src.js +3073 -0
  496. data/vendor/assets/javascripts/highstock/lib/jspdf.js +283 -0
  497. data/vendor/assets/javascripts/highstock/lib/jspdf.src.js +21627 -0
  498. data/vendor/assets/javascripts/highstock/lib/rgbcolor.js +17 -0
  499. data/vendor/assets/javascripts/highstock/lib/rgbcolor.src.js +299 -0
  500. data/vendor/assets/javascripts/highstock/lib/svg2pdf.js +38 -0
  501. data/vendor/assets/javascripts/highstock/lib/svg2pdf.src.js +4390 -0
  502. data/vendor/assets/javascripts/highstock/modules/accessibility.js +73 -0
  503. data/vendor/assets/javascripts/highstock/modules/accessibility.js.map +1 -0
  504. data/vendor/assets/javascripts/highstock/modules/accessibility.src.js +3103 -0
  505. data/vendor/assets/javascripts/highstock/modules/annotations-advanced.js +132 -0
  506. data/vendor/assets/javascripts/highstock/modules/annotations-advanced.js.map +1 -0
  507. data/vendor/assets/javascripts/highstock/modules/annotations-advanced.src.js +8230 -0
  508. data/vendor/assets/javascripts/highstock/modules/annotations.js +94 -0
  509. data/vendor/assets/javascripts/highstock/modules/annotations.js.map +1 -0
  510. data/vendor/assets/javascripts/highstock/modules/annotations.src.js +6001 -0
  511. data/vendor/assets/javascripts/highstock/modules/arrow-symbols.js +11 -0
  512. data/vendor/assets/javascripts/highstock/modules/arrow-symbols.js.map +1 -0
  513. data/vendor/assets/javascripts/highstock/modules/arrow-symbols.src.js +225 -0
  514. data/vendor/assets/javascripts/highstock/modules/boost-canvas.js +23 -0
  515. data/vendor/assets/javascripts/highstock/modules/boost-canvas.js.map +1 -0
  516. data/vendor/assets/javascripts/highstock/modules/boost-canvas.src.js +756 -0
  517. data/vendor/assets/javascripts/highstock/modules/boost.js +65 -0
  518. data/vendor/assets/javascripts/highstock/modules/boost.js.map +1 -0
  519. data/vendor/assets/javascripts/highstock/modules/boost.src.js +3752 -0
  520. data/vendor/assets/javascripts/highstock/modules/bullet.js +14 -0
  521. data/vendor/assets/javascripts/highstock/modules/bullet.js.map +1 -0
  522. data/vendor/assets/javascripts/highstock/modules/bullet.src.js +388 -0
  523. data/vendor/assets/javascripts/highstock/modules/current-date-indicator.js +11 -0
  524. data/vendor/assets/javascripts/highstock/modules/current-date-indicator.js.map +1 -0
  525. data/vendor/assets/javascripts/highstock/modules/current-date-indicator.src.js +127 -0
  526. data/vendor/assets/javascripts/highstock/modules/cylinder.js +14 -0
  527. data/vendor/assets/javascripts/highstock/modules/cylinder.js.map +1 -0
  528. data/vendor/assets/javascripts/highstock/modules/cylinder.src.js +413 -0
  529. data/vendor/assets/javascripts/highstock/modules/data.js +37 -0
  530. data/vendor/assets/javascripts/highstock/modules/data.js.map +1 -0
  531. data/vendor/assets/javascripts/highstock/modules/data.src.js +2565 -0
  532. data/vendor/assets/javascripts/highstock/modules/datagrouping.js +25 -0
  533. data/vendor/assets/javascripts/highstock/modules/datagrouping.js.map +1 -0
  534. data/vendor/assets/javascripts/highstock/modules/datagrouping.src.js +1140 -0
  535. data/vendor/assets/javascripts/highstock/modules/debugger.js +28 -0
  536. data/vendor/assets/javascripts/highstock/modules/debugger.js.map +1 -0
  537. data/vendor/assets/javascripts/highstock/modules/debugger.src.js +267 -0
  538. data/vendor/assets/javascripts/highstock/modules/dependency-wheel.js +15 -0
  539. data/vendor/assets/javascripts/highstock/modules/dependency-wheel.js.map +1 -0
  540. data/vendor/assets/javascripts/highstock/modules/dependency-wheel.src.js +301 -0
  541. data/vendor/assets/javascripts/highstock/modules/drag-panes.js +18 -0
  542. data/vendor/assets/javascripts/highstock/modules/drag-panes.js.map +1 -0
  543. data/vendor/assets/javascripts/highstock/modules/drag-panes.src.js +649 -0
  544. data/vendor/assets/javascripts/highstock/modules/draggable-points.js +40 -0
  545. data/vendor/assets/javascripts/highstock/modules/draggable-points.js.map +1 -0
  546. data/vendor/assets/javascripts/highstock/modules/draggable-points.src.js +2650 -0
  547. data/vendor/assets/javascripts/highstock/modules/drilldown.js +29 -0
  548. data/vendor/assets/javascripts/highstock/modules/drilldown.js.map +1 -0
  549. data/vendor/assets/javascripts/highstock/modules/drilldown.src.js +1321 -0
  550. data/vendor/assets/javascripts/highstock/modules/export-data.js +27 -0
  551. data/vendor/assets/javascripts/highstock/modules/export-data.js.map +1 -0
  552. data/vendor/assets/javascripts/highstock/modules/export-data.src.js +1234 -0
  553. data/vendor/assets/javascripts/highstock/modules/exporting.js +35 -0
  554. data/vendor/assets/javascripts/highstock/modules/exporting.js.map +1 -0
  555. data/vendor/assets/javascripts/highstock/modules/exporting.src.js +2233 -0
  556. data/vendor/assets/javascripts/highstock/modules/full-screen.js +11 -0
  557. data/vendor/assets/javascripts/highstock/modules/full-screen.js.map +1 -0
  558. data/vendor/assets/javascripts/highstock/modules/full-screen.src.js +68 -0
  559. data/vendor/assets/javascripts/highstock/modules/funnel.js +14 -0
  560. data/vendor/assets/javascripts/highstock/modules/funnel.js.map +1 -0
  561. data/vendor/assets/javascripts/highstock/modules/funnel.src.js +576 -0
  562. data/vendor/assets/javascripts/highstock/modules/grid-axis.js +23 -0
  563. data/vendor/assets/javascripts/highstock/modules/grid-axis.js.map +1 -0
  564. data/vendor/assets/javascripts/highstock/modules/grid-axis.src.js +988 -0
  565. data/vendor/assets/javascripts/highstock/modules/heatmap.js +28 -0
  566. data/vendor/assets/javascripts/highstock/modules/heatmap.js.map +1 -0
  567. data/vendor/assets/javascripts/highstock/modules/heatmap.src.js +1731 -0
  568. data/vendor/assets/javascripts/highstock/modules/histogram-bellcurve.js +16 -0
  569. data/vendor/assets/javascripts/highstock/modules/histogram-bellcurve.js.map +1 -0
  570. data/vendor/assets/javascripts/highstock/modules/histogram-bellcurve.src.js +570 -0
  571. data/vendor/assets/javascripts/highstock/modules/item-series.js +13 -0
  572. data/vendor/assets/javascripts/highstock/modules/item-series.js.map +1 -0
  573. data/vendor/assets/javascripts/highstock/modules/item-series.src.js +176 -0
  574. data/vendor/assets/javascripts/highstock/modules/networkgraph.js +31 -0
  575. data/vendor/assets/javascripts/highstock/modules/networkgraph.js.map +1 -0
  576. data/vendor/assets/javascripts/highstock/modules/networkgraph.src.js +1348 -0
  577. data/vendor/assets/javascripts/highstock/modules/no-data-to-display.js +13 -0
  578. data/vendor/assets/javascripts/highstock/modules/no-data-to-display.js.map +1 -0
  579. data/vendor/assets/javascripts/highstock/modules/no-data-to-display.src.js +285 -0
  580. data/vendor/assets/javascripts/highstock/modules/offline-exporting.js +22 -0
  581. data/vendor/assets/javascripts/highstock/modules/offline-exporting.js.map +1 -0
  582. data/vendor/assets/javascripts/highstock/modules/offline-exporting.src.js +838 -0
  583. data/vendor/assets/javascripts/highstock/modules/oldie-polyfills.js +13 -0
  584. data/vendor/assets/javascripts/highstock/modules/oldie-polyfills.js.map +1 -0
  585. data/vendor/assets/javascripts/highstock/modules/oldie-polyfills.src.js +150 -0
  586. data/vendor/assets/javascripts/highstock/modules/oldie.js +35 -0
  587. data/vendor/assets/javascripts/highstock/modules/oldie.js.map +1 -0
  588. data/vendor/assets/javascripts/highstock/modules/oldie.src.js +1582 -0
  589. data/vendor/assets/javascripts/highstock/modules/overlapping-datalabels.js +9 -0
  590. data/vendor/assets/javascripts/highstock/modules/overlapping-datalabels.js.map +1 -0
  591. data/vendor/assets/javascripts/highstock/modules/overlapping-datalabels.src.js +22 -0
  592. data/vendor/assets/javascripts/highstock/modules/parallel-coordinates.js +18 -0
  593. data/vendor/assets/javascripts/highstock/modules/parallel-coordinates.js.map +1 -0
  594. data/vendor/assets/javascripts/highstock/modules/parallel-coordinates.src.js +517 -0
  595. data/vendor/assets/javascripts/highstock/modules/pareto.js +14 -0
  596. data/vendor/assets/javascripts/highstock/modules/pareto.js.map +1 -0
  597. data/vendor/assets/javascripts/highstock/modules/pareto.src.js +327 -0
  598. data/vendor/assets/javascripts/highstock/modules/pathfinder.js +34 -0
  599. data/vendor/assets/javascripts/highstock/modules/pathfinder.js.map +1 -0
  600. data/vendor/assets/javascripts/highstock/modules/pathfinder.src.js +2336 -0
  601. data/vendor/assets/javascripts/highstock/modules/pattern-fill.js +21 -0
  602. data/vendor/assets/javascripts/highstock/modules/pattern-fill.js.map +1 -0
  603. data/vendor/assets/javascripts/highstock/modules/pattern-fill.src.js +634 -0
  604. data/vendor/assets/javascripts/highstock/modules/price-indicator.js +13 -0
  605. data/vendor/assets/javascripts/highstock/modules/price-indicator.js.map +1 -0
  606. data/vendor/assets/javascripts/highstock/modules/price-indicator.src.js +176 -0
  607. data/vendor/assets/javascripts/highstock/modules/sankey.js +22 -0
  608. data/vendor/assets/javascripts/highstock/modules/sankey.js.map +1 -0
  609. data/vendor/assets/javascripts/highstock/modules/sankey.src.js +911 -0
  610. data/vendor/assets/javascripts/highstock/modules/series-label.js +23 -0
  611. data/vendor/assets/javascripts/highstock/modules/series-label.js.map +1 -0
  612. data/vendor/assets/javascripts/highstock/modules/series-label.src.js +1065 -0
  613. data/vendor/assets/javascripts/highstock/modules/solid-gauge.js +15 -0
  614. data/vendor/assets/javascripts/highstock/modules/solid-gauge.js.map +1 -0
  615. data/vendor/assets/javascripts/highstock/modules/solid-gauge.src.js +510 -0
  616. data/vendor/assets/javascripts/highstock/modules/sonification.js +53 -0
  617. data/vendor/assets/javascripts/highstock/modules/sonification.js.map +1 -0
  618. data/vendor/assets/javascripts/highstock/modules/sonification.src.js +3341 -0
  619. data/vendor/assets/javascripts/highstock/modules/static-scale.js +12 -0
  620. data/vendor/assets/javascripts/highstock/modules/static-scale.js.map +1 -0
  621. data/vendor/assets/javascripts/highstock/modules/static-scale.src.js +114 -0
  622. data/vendor/assets/javascripts/highstock/modules/stock-tools.js +65 -0
  623. data/vendor/assets/javascripts/highstock/modules/stock-tools.js.map +1 -0
  624. data/vendor/assets/javascripts/highstock/modules/stock-tools.src.js +3437 -0
  625. data/vendor/assets/javascripts/highstock/modules/stock.js +151 -0
  626. data/vendor/assets/javascripts/highstock/modules/stock.js.map +1 -0
  627. data/vendor/assets/javascripts/highstock/modules/stock.src.js +10907 -0
  628. data/vendor/assets/javascripts/highstock/modules/streamgraph.js +10 -0
  629. data/vendor/assets/javascripts/highstock/modules/streamgraph.js.map +1 -0
  630. data/vendor/assets/javascripts/highstock/modules/streamgraph.src.js +158 -0
  631. data/vendor/assets/javascripts/highstock/modules/sunburst.js +52 -0
  632. data/vendor/assets/javascripts/highstock/modules/sunburst.js.map +1 -0
  633. data/vendor/assets/javascripts/highstock/modules/sunburst.src.js +3174 -0
  634. data/vendor/assets/javascripts/highstock/modules/tilemap.js +26 -0
  635. data/vendor/assets/javascripts/highstock/modules/tilemap.js.map +1 -0
  636. data/vendor/assets/javascripts/highstock/modules/tilemap.src.js +1402 -0
  637. data/vendor/assets/javascripts/highstock/modules/timeline.js +23 -0
  638. data/vendor/assets/javascripts/highstock/modules/timeline.js.map +1 -0
  639. data/vendor/assets/javascripts/highstock/modules/timeline.src.js +778 -0
  640. data/vendor/assets/javascripts/highstock/modules/treegrid.js +50 -0
  641. data/vendor/assets/javascripts/highstock/modules/treegrid.js.map +1 -0
  642. data/vendor/assets/javascripts/highstock/modules/treegrid.src.js +2917 -0
  643. data/vendor/assets/javascripts/highstock/modules/treemap.js +39 -0
  644. data/vendor/assets/javascripts/highstock/modules/treemap.js.map +1 -0
  645. data/vendor/assets/javascripts/highstock/modules/treemap.src.js +2083 -0
  646. data/vendor/assets/javascripts/highstock/modules/variable-pie.js +16 -0
  647. data/vendor/assets/javascripts/highstock/modules/variable-pie.js.map +1 -0
  648. data/vendor/assets/javascripts/highstock/modules/variable-pie.src.js +485 -0
  649. data/vendor/assets/javascripts/highstock/modules/variwide.js +15 -0
  650. data/vendor/assets/javascripts/highstock/modules/variwide.js.map +1 -0
  651. data/vendor/assets/javascripts/highstock/modules/variwide.src.js +376 -0
  652. data/vendor/assets/javascripts/highstock/modules/vector.js +13 -0
  653. data/vendor/assets/javascripts/highstock/modules/vector.js.map +1 -0
  654. data/vendor/assets/javascripts/highstock/modules/vector.src.js +381 -0
  655. data/vendor/assets/javascripts/highstock/modules/venn.js +30 -0
  656. data/vendor/assets/javascripts/highstock/modules/venn.js.map +1 -0
  657. data/vendor/assets/javascripts/highstock/modules/venn.src.js +1624 -0
  658. data/vendor/assets/javascripts/highstock/modules/windbarb.js +17 -0
  659. data/vendor/assets/javascripts/highstock/modules/windbarb.js.map +1 -0
  660. data/vendor/assets/javascripts/highstock/modules/windbarb.src.js +574 -0
  661. data/vendor/assets/javascripts/highstock/modules/wordcloud.js +25 -0
  662. data/vendor/assets/javascripts/highstock/modules/wordcloud.js.map +1 -0
  663. data/vendor/assets/javascripts/highstock/modules/wordcloud.src.js +1475 -0
  664. data/vendor/assets/javascripts/highstock/modules/xrange.js +20 -0
  665. data/vendor/assets/javascripts/highstock/modules/xrange.js.map +1 -0
  666. data/vendor/assets/javascripts/highstock/modules/xrange.src.js +788 -0
  667. data/vendor/assets/javascripts/highstock/themes/avocado.js +9 -0
  668. data/vendor/assets/javascripts/highstock/themes/avocado.js.map +1 -0
  669. data/vendor/assets/javascripts/highstock/themes/avocado.src.js +63 -0
  670. data/vendor/assets/javascripts/highstock/themes/dark-blue.js +15 -0
  671. data/vendor/assets/javascripts/highstock/themes/dark-blue.js.map +1 -0
  672. data/vendor/assets/javascripts/highstock/themes/dark-blue.src.js +285 -0
  673. data/vendor/assets/javascripts/highstock/themes/dark-green.js +15 -0
  674. data/vendor/assets/javascripts/highstock/themes/dark-green.js.map +1 -0
  675. data/vendor/assets/javascripts/highstock/themes/dark-green.src.js +287 -0
  676. data/vendor/assets/javascripts/highstock/themes/dark-unica.js +14 -0
  677. data/vendor/assets/javascripts/highstock/themes/dark-unica.js.map +1 -0
  678. data/vendor/assets/javascripts/highstock/themes/dark-unica.src.js +246 -0
  679. data/vendor/assets/javascripts/highstock/themes/gray.js +15 -0
  680. data/vendor/assets/javascripts/highstock/themes/gray.js.map +1 -0
  681. data/vendor/assets/javascripts/highstock/themes/gray.src.js +293 -0
  682. data/vendor/assets/javascripts/highstock/themes/grid-light.js +11 -0
  683. data/vendor/assets/javascripts/highstock/themes/grid-light.js.map +1 -0
  684. data/vendor/assets/javascripts/highstock/themes/grid-light.src.js +107 -0
  685. data/vendor/assets/javascripts/highstock/themes/grid.js +11 -0
  686. data/vendor/assets/javascripts/highstock/themes/grid.js.map +1 -0
  687. data/vendor/assets/javascripts/highstock/themes/grid.src.js +136 -0
  688. data/vendor/assets/javascripts/highstock/themes/sand-signika.js +11 -0
  689. data/vendor/assets/javascripts/highstock/themes/sand-signika.js.map +1 -0
  690. data/vendor/assets/javascripts/highstock/themes/sand-signika.src.js +137 -0
  691. data/vendor/assets/javascripts/highstock/themes/skies.js +11 -0
  692. data/vendor/assets/javascripts/highstock/themes/skies.js.map +1 -0
  693. data/vendor/assets/javascripts/highstock/themes/skies.src.js +126 -0
  694. data/vendor/assets/javascripts/highstock/themes/sunset.js +9 -0
  695. data/vendor/assets/javascripts/highstock/themes/sunset.js.map +1 -0
  696. data/vendor/assets/javascripts/highstock/themes/sunset.src.js +62 -0
  697. metadata +781 -0
@@ -0,0 +1,17 @@
1
+ /*
2
+
3
+ A class to parse color values
4
+ @author Stoyan Stefanov <sstoo@gmail.com>
5
+ @link http://www.phpied.com/rgb-color-parser-in-javascript/
6
+ @license Use it if you like it
7
+ */
8
+ (function(f){function g(b){this.ok=!1;"#"==b.charAt(0)&&(b=b.substr(1,6));b=b.replace(/ /g,"");b=b.toLowerCase();var m={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",
9
+ darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",
10
+ gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",
11
+ lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",
12
+ oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",
13
+ slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"},e;for(e in m)b==e&&(b=m[e]);var h=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(a){return[parseInt(a[1]),parseInt(a[2]),parseInt(a[3])]}},{re:/^(\w{2})(\w{2})(\w{2})$/,
14
+ example:["#00ff00","336699"],process:function(a){return[parseInt(a[1],16),parseInt(a[2],16),parseInt(a[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:["#fb0","f0f"],process:function(a){return[parseInt(a[1]+a[1],16),parseInt(a[2]+a[2],16),parseInt(a[3]+a[3],16)]}}];for(e=0;e<h.length;e++){var f=h[e].process,k=h[e].re.exec(b);k&&(channels=f(k),this.r=channels[0],this.g=channels[1],this.b=channels[2],this.ok=!0)}this.r=0>this.r||isNaN(this.r)?0:255<this.r?255:this.r;this.g=0>this.g||isNaN(this.g)?0:
15
+ 255<this.g?255:this.g;this.b=0>this.b||isNaN(this.b)?0:255<this.b?255:this.b;this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"};this.toHex=function(){var a=this.r.toString(16),c=this.g.toString(16),d=this.b.toString(16);1==a.length&&(a="0"+a);1==c.length&&(c="0"+c);1==d.length&&(d="0"+d);return"#"+a+c+d};this.getHelpXML=function(){for(var a=[],c=0;c<h.length;c++)for(var d=h[c].example,b=0;b<d.length;b++)a[a.length]=d[b];for(var e in m)a[a.length]=e;d=document.createElement("ul");
16
+ d.setAttribute("id","rgbcolor-examples");for(c=0;c<a.length;c++)try{var f=document.createElement("li"),l=new g(a[c]),n=document.createElement("div");n.style.cssText="margin: 3px; border: 1px solid black; background:"+l.toHex()+"; color:"+l.toHex();n.appendChild(document.createTextNode("test"));var k=document.createTextNode(" "+a[c]+" -> "+l.toRGB()+" -> "+l.toHex());f.appendChild(n);f.appendChild(k);d.appendChild(f)}catch(p){}return d}}"function"===typeof define&&define.amd?define(function(){return g}):
17
+ "undefined"!==typeof module&&module.exports?module.exports=g:f.RGBColor=g;return g})("undefined"!==typeof self&&self||"undefined"!==typeof window&&window||this);
@@ -0,0 +1,299 @@
1
+ /** @preserve
2
+ * A class to parse color values
3
+ * @author Stoyan Stefanov <sstoo@gmail.com>
4
+ * @link http://www.phpied.com/rgb-color-parser-in-javascript/
5
+ * @license Use it if you like it
6
+ */
7
+ (function (global) {
8
+ function RGBColor(color_string)
9
+ {
10
+ this.ok = false;
11
+
12
+ // strip any leading #
13
+ if (color_string.charAt(0) == '#') { // remove # if any
14
+ color_string = color_string.substr(1,6);
15
+ }
16
+
17
+ color_string = color_string.replace(/ /g,'');
18
+ color_string = color_string.toLowerCase();
19
+
20
+ // before getting into regexps, try simple matches
21
+ // and overwrite the input
22
+ var simple_colors = {
23
+ aliceblue: 'f0f8ff',
24
+ antiquewhite: 'faebd7',
25
+ aqua: '00ffff',
26
+ aquamarine: '7fffd4',
27
+ azure: 'f0ffff',
28
+ beige: 'f5f5dc',
29
+ bisque: 'ffe4c4',
30
+ black: '000000',
31
+ blanchedalmond: 'ffebcd',
32
+ blue: '0000ff',
33
+ blueviolet: '8a2be2',
34
+ brown: 'a52a2a',
35
+ burlywood: 'deb887',
36
+ cadetblue: '5f9ea0',
37
+ chartreuse: '7fff00',
38
+ chocolate: 'd2691e',
39
+ coral: 'ff7f50',
40
+ cornflowerblue: '6495ed',
41
+ cornsilk: 'fff8dc',
42
+ crimson: 'dc143c',
43
+ cyan: '00ffff',
44
+ darkblue: '00008b',
45
+ darkcyan: '008b8b',
46
+ darkgoldenrod: 'b8860b',
47
+ darkgray: 'a9a9a9',
48
+ darkgreen: '006400',
49
+ darkkhaki: 'bdb76b',
50
+ darkmagenta: '8b008b',
51
+ darkolivegreen: '556b2f',
52
+ darkorange: 'ff8c00',
53
+ darkorchid: '9932cc',
54
+ darkred: '8b0000',
55
+ darksalmon: 'e9967a',
56
+ darkseagreen: '8fbc8f',
57
+ darkslateblue: '483d8b',
58
+ darkslategray: '2f4f4f',
59
+ darkturquoise: '00ced1',
60
+ darkviolet: '9400d3',
61
+ deeppink: 'ff1493',
62
+ deepskyblue: '00bfff',
63
+ dimgray: '696969',
64
+ dodgerblue: '1e90ff',
65
+ feldspar: 'd19275',
66
+ firebrick: 'b22222',
67
+ floralwhite: 'fffaf0',
68
+ forestgreen: '228b22',
69
+ fuchsia: 'ff00ff',
70
+ gainsboro: 'dcdcdc',
71
+ ghostwhite: 'f8f8ff',
72
+ gold: 'ffd700',
73
+ goldenrod: 'daa520',
74
+ gray: '808080',
75
+ green: '008000',
76
+ greenyellow: 'adff2f',
77
+ honeydew: 'f0fff0',
78
+ hotpink: 'ff69b4',
79
+ indianred : 'cd5c5c',
80
+ indigo : '4b0082',
81
+ ivory: 'fffff0',
82
+ khaki: 'f0e68c',
83
+ lavender: 'e6e6fa',
84
+ lavenderblush: 'fff0f5',
85
+ lawngreen: '7cfc00',
86
+ lemonchiffon: 'fffacd',
87
+ lightblue: 'add8e6',
88
+ lightcoral: 'f08080',
89
+ lightcyan: 'e0ffff',
90
+ lightgoldenrodyellow: 'fafad2',
91
+ lightgrey: 'd3d3d3',
92
+ lightgreen: '90ee90',
93
+ lightpink: 'ffb6c1',
94
+ lightsalmon: 'ffa07a',
95
+ lightseagreen: '20b2aa',
96
+ lightskyblue: '87cefa',
97
+ lightslateblue: '8470ff',
98
+ lightslategray: '778899',
99
+ lightsteelblue: 'b0c4de',
100
+ lightyellow: 'ffffe0',
101
+ lime: '00ff00',
102
+ limegreen: '32cd32',
103
+ linen: 'faf0e6',
104
+ magenta: 'ff00ff',
105
+ maroon: '800000',
106
+ mediumaquamarine: '66cdaa',
107
+ mediumblue: '0000cd',
108
+ mediumorchid: 'ba55d3',
109
+ mediumpurple: '9370d8',
110
+ mediumseagreen: '3cb371',
111
+ mediumslateblue: '7b68ee',
112
+ mediumspringgreen: '00fa9a',
113
+ mediumturquoise: '48d1cc',
114
+ mediumvioletred: 'c71585',
115
+ midnightblue: '191970',
116
+ mintcream: 'f5fffa',
117
+ mistyrose: 'ffe4e1',
118
+ moccasin: 'ffe4b5',
119
+ navajowhite: 'ffdead',
120
+ navy: '000080',
121
+ oldlace: 'fdf5e6',
122
+ olive: '808000',
123
+ olivedrab: '6b8e23',
124
+ orange: 'ffa500',
125
+ orangered: 'ff4500',
126
+ orchid: 'da70d6',
127
+ palegoldenrod: 'eee8aa',
128
+ palegreen: '98fb98',
129
+ paleturquoise: 'afeeee',
130
+ palevioletred: 'd87093',
131
+ papayawhip: 'ffefd5',
132
+ peachpuff: 'ffdab9',
133
+ peru: 'cd853f',
134
+ pink: 'ffc0cb',
135
+ plum: 'dda0dd',
136
+ powderblue: 'b0e0e6',
137
+ purple: '800080',
138
+ red: 'ff0000',
139
+ rosybrown: 'bc8f8f',
140
+ royalblue: '4169e1',
141
+ saddlebrown: '8b4513',
142
+ salmon: 'fa8072',
143
+ sandybrown: 'f4a460',
144
+ seagreen: '2e8b57',
145
+ seashell: 'fff5ee',
146
+ sienna: 'a0522d',
147
+ silver: 'c0c0c0',
148
+ skyblue: '87ceeb',
149
+ slateblue: '6a5acd',
150
+ slategray: '708090',
151
+ snow: 'fffafa',
152
+ springgreen: '00ff7f',
153
+ steelblue: '4682b4',
154
+ tan: 'd2b48c',
155
+ teal: '008080',
156
+ thistle: 'd8bfd8',
157
+ tomato: 'ff6347',
158
+ turquoise: '40e0d0',
159
+ violet: 'ee82ee',
160
+ violetred: 'd02090',
161
+ wheat: 'f5deb3',
162
+ white: 'ffffff',
163
+ whitesmoke: 'f5f5f5',
164
+ yellow: 'ffff00',
165
+ yellowgreen: '9acd32'
166
+ };
167
+ for (var key in simple_colors) {
168
+ if (color_string == key) {
169
+ color_string = simple_colors[key];
170
+ }
171
+ }
172
+ // emd of simple type-in colors
173
+
174
+ // array of color definition objects
175
+ var color_defs = [
176
+ {
177
+ re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,
178
+ example: ['rgb(123, 234, 45)', 'rgb(255,234,245)'],
179
+ process: function (bits){
180
+ return [
181
+ parseInt(bits[1]),
182
+ parseInt(bits[2]),
183
+ parseInt(bits[3])
184
+ ];
185
+ }
186
+ },
187
+ {
188
+ re: /^(\w{2})(\w{2})(\w{2})$/,
189
+ example: ['#00ff00', '336699'],
190
+ process: function (bits){
191
+ return [
192
+ parseInt(bits[1], 16),
193
+ parseInt(bits[2], 16),
194
+ parseInt(bits[3], 16)
195
+ ];
196
+ }
197
+ },
198
+ {
199
+ re: /^(\w{1})(\w{1})(\w{1})$/,
200
+ example: ['#fb0', 'f0f'],
201
+ process: function (bits){
202
+ return [
203
+ parseInt(bits[1] + bits[1], 16),
204
+ parseInt(bits[2] + bits[2], 16),
205
+ parseInt(bits[3] + bits[3], 16)
206
+ ];
207
+ }
208
+ }
209
+ ];
210
+
211
+ // search through the definitions to find a match
212
+ for (var i = 0; i < color_defs.length; i++) {
213
+ var re = color_defs[i].re;
214
+ var processor = color_defs[i].process;
215
+ var bits = re.exec(color_string);
216
+ if (bits) {
217
+ channels = processor(bits);
218
+ this.r = channels[0];
219
+ this.g = channels[1];
220
+ this.b = channels[2];
221
+ this.ok = true;
222
+ }
223
+
224
+ }
225
+
226
+ // validate/cleanup values
227
+ this.r = (this.r < 0 || isNaN(this.r)) ? 0 : ((this.r > 255) ? 255 : this.r);
228
+ this.g = (this.g < 0 || isNaN(this.g)) ? 0 : ((this.g > 255) ? 255 : this.g);
229
+ this.b = (this.b < 0 || isNaN(this.b)) ? 0 : ((this.b > 255) ? 255 : this.b);
230
+
231
+ // some getters
232
+ this.toRGB = function () {
233
+ return 'rgb(' + this.r + ', ' + this.g + ', ' + this.b + ')';
234
+ }
235
+ this.toHex = function () {
236
+ var r = this.r.toString(16);
237
+ var g = this.g.toString(16);
238
+ var b = this.b.toString(16);
239
+ if (r.length == 1) r = '0' + r;
240
+ if (g.length == 1) g = '0' + g;
241
+ if (b.length == 1) b = '0' + b;
242
+ return '#' + r + g + b;
243
+ }
244
+
245
+ // help
246
+ this.getHelpXML = function () {
247
+
248
+ var examples = new Array();
249
+ // add regexps
250
+ for (var i = 0; i < color_defs.length; i++) {
251
+ var example = color_defs[i].example;
252
+ for (var j = 0; j < example.length; j++) {
253
+ examples[examples.length] = example[j];
254
+ }
255
+ }
256
+ // add type-in colors
257
+ for (var sc in simple_colors) {
258
+ examples[examples.length] = sc;
259
+ }
260
+
261
+ var xml = document.createElement('ul');
262
+ xml.setAttribute('id', 'rgbcolor-examples');
263
+ for (var i = 0; i < examples.length; i++) {
264
+ try {
265
+ var list_item = document.createElement('li');
266
+ var list_color = new RGBColor(examples[i]);
267
+ var example_div = document.createElement('div');
268
+ example_div.style.cssText =
269
+ 'margin: 3px; '
270
+ + 'border: 1px solid black; '
271
+ + 'background:' + list_color.toHex() + '; '
272
+ + 'color:' + list_color.toHex()
273
+ ;
274
+ example_div.appendChild(document.createTextNode('test'));
275
+ var list_item_value = document.createTextNode(
276
+ ' ' + examples[i] + ' -> ' + list_color.toRGB() + ' -> ' + list_color.toHex()
277
+ );
278
+ list_item.appendChild(example_div);
279
+ list_item.appendChild(list_item_value);
280
+ xml.appendChild(list_item);
281
+
282
+ } catch(e){}
283
+ }
284
+ return xml;
285
+
286
+ }
287
+
288
+ }
289
+ if (typeof define === "function" && define.amd) {
290
+ define(function () {
291
+ return RGBColor;
292
+ });
293
+ } else if (typeof module !== "undefined" && module.exports) {
294
+ module.exports = RGBColor;
295
+ } else {
296
+ global.RGBColor = RGBColor;
297
+ }
298
+ return RGBColor;
299
+ })(typeof self !== "undefined" && self || typeof window !== "undefined" && window || this);
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Modules in this bundle
3
+ * @license
4
+ *
5
+ * svg2pdf.js:
6
+ * license: MIT (http://opensource.org/licenses/MIT)
7
+ * author: yFiles for HTML Support Team <yfileshtml@yworks.com>
8
+ * homepage: https://github.com/yWorks/svg2pdf.js#readme
9
+ * version: 1.3.1
10
+ *
11
+ * cssesc:
12
+ * license: MIT (http://opensource.org/licenses/MIT)
13
+ * author: Mathias Bynens
14
+ * homepage: https://mths.be/cssesc
15
+ * version: 2.0.0
16
+ *
17
+ * font-family:
18
+ * license: MIT (http://opensource.org/licenses/MIT)
19
+ * author: Taro Hanamura <m@hanamurataro.com>
20
+ * homepage: https://github.com/hanamura/font-family
21
+ * version: 0.2.0
22
+ *
23
+ * svgpath:
24
+ * license: MIT (http://opensource.org/licenses/MIT)
25
+ * homepage: https://github.com/fontello/svgpath#readme
26
+ * version: 2.2.1
27
+ *
28
+ * This header is generated by licensify (https://github.com/twada/licensify)
29
+ */
30
+ !function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).svg2pdf=t()}}(function(){return function n(s,o,h){function c(e,t){if(!o[e]){if(!s[e]){var r="function"==typeof require&&require;if(!t&&r)return r(e,!0);if(u)return u(e,!0);var a=new Error("Cannot find module '"+e+"'");throw a.code="MODULE_NOT_FOUND",a}var i=o[e]={exports:{}};s[e][0].call(i.exports,function(t){return c(s[e][1][t]||t)},i,i.exports,n,s,o,h)}return o[e].exports}for(var u="function"==typeof require&&require,t=0;t<h.length;t++)c(h[t]);return c}({1:[function(t,e,r){"use strict";e.exports=t("./lib/svgpath")},{"./lib/svgpath":6}],2:[function(t,e,r){"use strict";var C=2*Math.PI;function I(t,e,r,a){var i=t*a-e*r<0?-1:1,n=(t*r+e*a)/(Math.sqrt(t*t+e*e)*Math.sqrt(t*t+e*e));return 1<n&&(n=1),n<-1&&(n=-1),i*Math.acos(n)}e.exports=function(t,e,r,a,i,n,s,o,h){var c=Math.sin(h*C/360),u=Math.cos(h*C/360),l=u*(t-r)/2+c*(e-a)/2,f=-c*(t-r)/2+u*(e-a)/2;if(0===l&&0===f)return[];if(0===s||0===o)return[];s=Math.abs(s),o=Math.abs(o);var d=l*l/(s*s)+f*f/(o*o);1<d&&(s*=Math.sqrt(d),o*=Math.sqrt(d));var p,g,x,b,m,v,y,k=function(t,e,r,a,i,n,s,o,h,c){var u=c*(t-r)/2+h*(e-a)/2,l=-h*(t-r)/2+c*(e-a)/2,f=s*s,d=o*o,p=u*u,g=l*l,x=f*d-f*g-d*p;x<0&&(x=0),x/=f*g+d*p;var b=(x=Math.sqrt(x)*(i===n?-1:1))*s/o*l,m=x*-o/s*u,v=c*b-h*m+(t+r)/2,y=h*b+c*m+(e+a)/2,k=(u-b)/s,w=(l-m)/o,M=(-u-b)/s,A=(-l-m)/o,S=I(1,0,k,w),F=I(k,w,M,A);return 0===n&&0<F&&(F-=C),1===n&&F<0&&(F+=C),[v,y,S,F]}(t,e,r,a,i,n,s,o,c,u),w=[],M=k[2],A=k[3],S=Math.max(Math.ceil(Math.abs(A)/(C/4)),1);A/=S;for(var F=0;F<S;F++)w.push((p=M,g=A,void 0,x=4/3*Math.tan(g/4),b=Math.cos(p),m=Math.sin(p),v=Math.cos(p+g),y=Math.sin(p+g),[b,m,b-m*x,m+b*x,v+y*x,y-v*x,v,y])),M+=A;return w.map(function(t){for(var e=0;e<t.length;e+=2){var r=t[e+0],a=t[e+1],i=u*(r*=s)-c*(a*=o),n=c*r+u*a;t[e+0]=i+k[0],t[e+1]=n+k[1]}return t})}},{}],3:[function(t,e,r){"use strict";var l=1e-10,f=Math.PI/180;function a(t,e,r){if(!(this instanceof a))return new a(t,e,r);this.rx=t,this.ry=e,this.ax=r}a.prototype.transform=function(t){var e=Math.cos(this.ax*f),r=Math.sin(this.ax*f),a=[this.rx*(t[0]*e+t[2]*r),this.rx*(t[1]*e+t[3]*r),this.ry*(-t[0]*r+t[2]*e),this.ry*(-t[1]*r+t[3]*e)],i=a[0]*a[0]+a[2]*a[2],n=a[1]*a[1]+a[3]*a[3],s=((a[0]-a[3])*(a[0]-a[3])+(a[2]+a[1])*(a[2]+a[1]))*((a[0]+a[3])*(a[0]+a[3])+(a[2]-a[1])*(a[2]-a[1])),o=(i+n)/2;if(s<l*o)return this.rx=this.ry=Math.sqrt(o),this.ax=0,this;var h=a[0]*a[1]+a[2]*a[3],c=o+(s=Math.sqrt(s))/2,u=o-s/2;return this.ax=Math.abs(h)<l&&Math.abs(c-n)<l?90:180*Math.atan(Math.abs(h)>Math.abs(c-n)?(c-i)/h:h/(c-n))/Math.PI,0<=this.ax?(this.rx=Math.sqrt(c),this.ry=Math.sqrt(u)):(this.ax+=90,this.rx=Math.sqrt(u),this.ry=Math.sqrt(c)),this},a.prototype.isDegenerate=function(){return this.rx<l*this.ry||this.ry<l*this.rx},e.exports=a},{}],4:[function(t,e,r){"use strict";function a(){if(!(this instanceof a))return new a;this.queue=[],this.cache=null}a.prototype.matrix=function(t){return 1===t[0]&&0===t[1]&&0===t[2]&&1===t[3]&&0===t[4]&&0===t[5]||(this.cache=null,this.queue.push(t)),this},a.prototype.translate=function(t,e){return 0===t&&0===e||(this.cache=null,this.queue.push([1,0,0,1,t,e])),this},a.prototype.scale=function(t,e){return 1===t&&1===e||(this.cache=null,this.queue.push([t,0,0,e,0,0])),this},a.prototype.rotate=function(t,e,r){var a,i,n;return 0!==t&&(this.translate(e,r),a=t*Math.PI/180,i=Math.cos(a),n=Math.sin(a),this.queue.push([i,n,-n,i,0,0]),this.cache=null,this.translate(-e,-r)),this},a.prototype.skewX=function(t){return 0!==t&&(this.cache=null,this.queue.push([1,0,Math.tan(t*Math.PI/180),1,0,0])),this},a.prototype.skewY=function(t){return 0!==t&&(this.cache=null,this.queue.push([1,Math.tan(t*Math.PI/180),0,1,0,0])),this},a.prototype.toArray=function(){if(this.cache)return this.cache;if(!this.queue.length)return this.cache=[1,0,0,1,0,0],this.cache;if(this.cache=this.queue[0],1===this.queue.length)return this.cache;for(var t=1;t<this.queue.length;t++)this.cache=(e=this.cache,r=this.queue[t],[e[0]*r[0]+e[2]*r[1],e[1]*r[0]+e[3]*r[1],e[0]*r[2]+e[2]*r[3],e[1]*r[2]+e[3]*r[3],e[0]*r[4]+e[2]*r[5]+e[4],e[1]*r[4]+e[3]*r[5]+e[5]]);var e,r;return this.cache},a.prototype.calc=function(t,e,r){var a;return this.queue.length?(this.cache||(this.cache=this.toArray()),[t*(a=this.cache)[0]+e*a[2]+(r?0:a[4]),t*a[1]+e*a[3]+(r?0:a[5])]):[t,e]},e.exports=a},{}],5:[function(t,e,r){"use strict";var s={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0},a=[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279];function c(t){return 48<=t&&t<=57}function i(t){this.index=0,this.path=t,this.max=t.length,this.result=[],this.param=0,this.err="",this.segmentStart=0,this.data=[]}function o(t){for(;t.index<t.max&&(10===(e=t.path.charCodeAt(t.index))||13===e||8232===e||8233===e||32===e||9===e||11===e||12===e||160===e||5760<=e&&0<=a.indexOf(e));)t.index++;var e}function h(t){var e,r=t.index,a=r,i=t.max,n=!1,s=!1,o=!1,h=!1;if(i<=a)t.err="SvgPath: missed param (at pos "+a+")";else if(43!==(e=t.path.charCodeAt(a))&&45!==e||(e=++a<i?t.path.charCodeAt(a):0),c(e)||46===e){if(46!==e){if(n=48===e,e=++a<i?t.path.charCodeAt(a):0,n&&a<i&&e&&c(e))return void(t.err="SvgPath: numbers started with `0` such as `09` are ilegal (at pos "+r+")");for(;a<i&&c(t.path.charCodeAt(a));)a++,s=!0;e=a<i?t.path.charCodeAt(a):0}if(46===e){for(h=!0,a++;c(t.path.charCodeAt(a));)a++,o=!0;e=a<i?t.path.charCodeAt(a):0}if(101===e||69===e){if(h&&!s&&!o)return void(t.err="SvgPath: invalid float exponent (at pos "+a+")");if(43!==(e=++a<i?t.path.charCodeAt(a):0)&&45!==e||a++,!(a<i&&c(t.path.charCodeAt(a))))return void(t.err="SvgPath: invalid float exponent (at pos "+a+")");for(;a<i&&c(t.path.charCodeAt(a));)a++}t.index=a,t.param=parseFloat(t.path.slice(r,a))+0}else t.err="SvgPath: param should start with 0..9 or `.` (at pos "+a+")"}function u(t){var e,r;r=(e=t.path[t.segmentStart]).toLowerCase();var a=t.data;if("m"===r&&2<a.length&&(t.result.push([e,a[0],a[1]]),a=a.slice(2),r="l",e="m"===e?"l":"L"),"r"===r)t.result.push([e].concat(a));else for(;a.length>=s[r]&&(t.result.push([e].concat(a.splice(0,s[r]))),s[r]););}function n(t){var e,r,a,i=t.max;if(t.segmentStart=t.index,function(t){switch(32|t){case 109:case 122:case 108:case 104:case 118:case 99:case 115:case 113:case 116:case 97:case 114:return!0}return!1}(t.path.charCodeAt(t.index)))if(r=s[t.path[t.index].toLowerCase()],t.index++,o(t),t.data=[],r){for(e=!1;;){for(a=r;0<a;a--){if(h(t),t.err.length)return;t.data.push(t.param),o(t),e=!1,t.index<i&&44===t.path.charCodeAt(t.index)&&(t.index++,o(t),e=!0)}if(!e){if(t.index>=t.max)break;if(!(48<=(n=t.path.charCodeAt(t.index))&&n<=57||43===n||45===n||46===n))break}}var n;u(t)}else u(t);else t.err="SvgPath: bad command "+t.path[t.index]+" (at pos "+t.index+")"}e.exports=function(t){var e=new i(t),r=e.max;for(o(e);e.index<r&&!e.err.length;)n(e);return e.err.length?e.result=[]:e.result.length&&("mM".indexOf(e.result[0][0])<0?(e.err="SvgPath: string should start with `M` or `m`",e.result=[]):e.result[0][0]="M"),{err:e.err,segments:e.result}}},{}],6:[function(t,e,r){"use strict";var a=t("./path_parse"),i=t("./transform_parse"),n=t("./matrix"),c=t("./a2c"),d=t("./ellipse");function s(t){if(!(this instanceof s))return new s(t);var e=a(t);this.segments=e.segments,this.err=e.err,this.__stack=[]}s.prototype.__matrix=function(u){var l,f=this;u.queue.length&&this.iterate(function(t,e,r,a){var i,n,s,o;switch(t[0]){case"v":n=0===(i=u.calc(0,t[1],!0))[0]?["v",i[1]]:["l",i[0],i[1]];break;case"V":n=(i=u.calc(r,t[1],!1))[0]===u.calc(r,a,!1)[0]?["V",i[1]]:["L",i[0],i[1]];break;case"h":n=0===(i=u.calc(t[1],0,!0))[1]?["h",i[0]]:["l",i[0],i[1]];break;case"H":n=(i=u.calc(t[1],a,!1))[1]===u.calc(r,a,!1)[1]?["H",i[0]]:["L",i[0],i[1]];break;case"a":case"A":var h=u.toArray(),c=d(t[1],t[2],t[3]).transform(h);if(h[0]*h[3]-h[1]*h[2]<0&&(t[5]=t[5]?"0":"1"),i=u.calc(t[6],t[7],"a"===t[0]),"A"===t[0]&&t[6]===r&&t[7]===a||"a"===t[0]&&0===t[6]&&0===t[7]){n=["a"===t[0]?"l":"L",i[0],i[1]];break}n=c.isDegenerate()?["a"===t[0]?"l":"L",i[0],i[1]]:[t[0],c.rx,c.ry,c.ax,t[4],t[5],i[0],i[1]];break;case"m":o=0<e,n=["m",(i=u.calc(t[1],t[2],o))[0],i[1]];break;default:for(n=[s=t[0]],o=s.toLowerCase()===s,l=1;l<t.length;l+=2)i=u.calc(t[l],t[l+1],o),n.push(i[0],i[1])}f.segments[e]=n},!0)},s.prototype.__evaluateStack=function(){var t,e;if(this.__stack.length){if(1===this.__stack.length)return this.__matrix(this.__stack[0]),void(this.__stack=[]);for(t=n(),e=this.__stack.length;0<=--e;)t.matrix(this.__stack[e].toArray());this.__matrix(t),this.__stack=[]}},s.prototype.toString=function(){var t,e,r=[];this.__evaluateStack();for(var a=0;a<this.segments.length;a++)e=this.segments[a][0],t=0<a&&"m"!==e&&"M"!==e&&e===this.segments[a-1][0],r=r.concat(t?this.segments[a].slice(1):this.segments[a]);return r.join(" ").replace(/ ?([achlmqrstvz]) ?/gi,"$1").replace(/ \-/g,"-").replace(/zm/g,"z m")},s.prototype.translate=function(t,e){return this.__stack.push(n().translate(t,e||0)),this},s.prototype.scale=function(t,e){return this.__stack.push(n().scale(t,e||0===e?e:t)),this},s.prototype.rotate=function(t,e,r){return this.__stack.push(n().rotate(t,e||0,r||0)),this},s.prototype.skewX=function(t){return this.__stack.push(n().skewX(t)),this},s.prototype.skewY=function(t){return this.__stack.push(n().skewY(t)),this},s.prototype.matrix=function(t){return this.__stack.push(n().matrix(t)),this},s.prototype.transform=function(t){return t.trim()&&this.__stack.push(i(t)),this},s.prototype.round=function(a){var e,i=0,n=0,s=0,o=0;return a=a||0,this.__evaluateStack(),this.segments.forEach(function(r){var t=r[0].toLowerCase()===r[0];switch(r[0]){case"H":case"h":return t&&(r[1]+=s),s=r[1]-r[1].toFixed(a),void(r[1]=+r[1].toFixed(a));case"V":case"v":return t&&(r[1]+=o),o=r[1]-r[1].toFixed(a),void(r[1]=+r[1].toFixed(a));case"Z":case"z":return s=i,void(o=n);case"M":case"m":return t&&(r[1]+=s,r[2]+=o),s=r[1]-r[1].toFixed(a),o=r[2]-r[2].toFixed(a),i=s,n=o,r[1]=+r[1].toFixed(a),void(r[2]=+r[2].toFixed(a));case"A":case"a":return t&&(r[6]+=s,r[7]+=o),s=r[6]-r[6].toFixed(a),o=r[7]-r[7].toFixed(a),r[1]=+r[1].toFixed(a),r[2]=+r[2].toFixed(a),r[3]=+r[3].toFixed(a+2),r[6]=+r[6].toFixed(a),void(r[7]=+r[7].toFixed(a));default:return e=r.length,t&&(r[e-2]+=s,r[e-1]+=o),s=r[e-2]-r[e-2].toFixed(a),o=r[e-1]-r[e-1].toFixed(a),void r.forEach(function(t,e){e&&(r[e]=+r[e].toFixed(a))})}}),this},s.prototype.iterate=function(i,t){var e,r,a,n=this.segments,s={},o=!1,h=0,c=0,u=0,l=0;if(t||this.__evaluateStack(),n.forEach(function(t,e){var r=i(t,e,h,c);Array.isArray(r)&&(s[e]=r,o=!0);var a=t[0]===t[0].toLowerCase();switch(t[0]){case"m":case"M":return h=t[1]+(a?h:0),c=t[2]+(a?c:0),u=h,void(l=c);case"h":case"H":return void(h=t[1]+(a?h:0));case"v":case"V":return void(c=t[1]+(a?c:0));case"z":case"Z":return h=u,void(c=l);default:h=t[t.length-2]+(a?h:0),c=t[t.length-1]+(a?c:0)}}),!o)return this;for(a=[],e=0;e<n.length;e++)if(void 0!==s[e])for(r=0;r<s[e].length;r++)a.push(s[e][r]);else a.push(n[e]);return this.segments=a,this},s.prototype.abs=function(){return this.iterate(function(t,e,r,a){var i,n=t[0],s=n.toUpperCase();if(n!==s)switch(t[0]=s,n){case"v":return void(t[1]+=a);case"a":return t[6]+=r,void(t[7]+=a);default:for(i=1;i<t.length;i++)t[i]+=i%2?r:a}},!0),this},s.prototype.rel=function(){return this.iterate(function(t,e,r,a){var i,n=t[0],s=n.toLowerCase();if(n!==s&&(0!==e||"M"!==n))switch(t[0]=s,n){case"V":return void(t[1]-=a);case"A":return t[6]-=r,void(t[7]-=a);default:for(i=1;i<t.length;i++)t[i]-=i%2?r:a}},!0),this},s.prototype.unarc=function(){return this.iterate(function(t,e,r,a){var i,n,s,o=[],h=t[0];return"A"!==h&&"a"!==h?null:("a"===h?(n=r+t[6],s=a+t[7]):(n=t[6],s=t[7]),0===(i=c(r,a,n,s,t[4],t[5],t[1],t[2],t[3])).length?[["a"===t[0]?"l":"L",t[6],t[7]]]:(i.forEach(function(t){o.push(["C",t[2],t[3],t[4],t[5],t[6],t[7]])}),o))}),this},s.prototype.unshort=function(){var o,h,c,u,l,f=this.segments;return this.iterate(function(t,e,r,a){var i,n=t[0],s=n.toUpperCase();e&&("T"===s?(i="t"===n,"Q"===(c=f[e-1])[0]?(o=c[1]-r,h=c[2]-a):"q"===c[0]?(o=c[1]-c[3],h=c[2]-c[4]):h=o=0,u=-o,l=-h,i||(u+=r,l+=a),f[e]=[i?"q":"Q",u,l,t[1],t[2]]):"S"===s&&(i="s"===n,"C"===(c=f[e-1])[0]?(o=c[3]-r,h=c[4]-a):"c"===c[0]?(o=c[3]-c[5],h=c[4]-c[6]):h=o=0,u=-o,l=-h,i||(u+=r,l+=a),f[e]=[i?"c":"C",u,l,t[1],t[2],t[3],t[4]]))}),this},e.exports=s},{"./a2c":2,"./ellipse":3,"./matrix":4,"./path_parse":5,"./transform_parse":7}],7:[function(t,e,r){"use strict";var i=t("./matrix"),n={matrix:!0,scale:!0,rotate:!0,translate:!0,skewX:!0,skewY:!0},s=/\s*(matrix|translate|scale|rotate|skewX|skewY)\s*\(\s*(.+?)\s*\)[\s,]*/,o=/[\s,]+/;e.exports=function(t){var e,r,a=new i;return t.split(s).forEach(function(t){if(t.length)if(void 0===n[t])switch(r=t.split(o).map(function(t){return+t||0}),e){case"matrix":return void(6===r.length&&a.matrix(r));case"scale":return void(1===r.length?a.scale(r[0],r[0]):2===r.length&&a.scale(r[0],r[1]));case"rotate":return void(1===r.length?a.rotate(r[0],0,0):3===r.length&&a.rotate(r[0],r[1],r[2]));case"translate":return void(1===r.length?a.translate(r[0],0):2===r.length&&a.translate(r[0],r[1]));case"skewX":return void(1===r.length&&a.skewX(r[0]));case"skewY":return void(1===r.length&&a.skewY(r[0]))}else e=t}),a}},{"./matrix":4}],8:[function(t,e,r){"use strict";var d={}.hasOwnProperty,p=/[ -,\.\/;-@\[-\^`\{-~]/,g=/[ -,\.\/;-@\[\]\^`\{-~]/,x=/(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g,a=function t(e,r){"single"!=(r=function(t,e){if(!t)return e;var r={};for(var a in e)r[a]=d.call(t,a)?t[a]:e[a];return r}(r,t.options)).quotes&&"double"!=r.quotes&&(r.quotes="single");for(var a="double"==r.quotes?'"':"'",i=r.isIdentifier,n=e.charAt(0),s="",o=0,h=e.length;o<h;){var c=e.charAt(o++),u=c.charCodeAt(),l=void 0;if(u<32||126<u){if(55296<=u&&u<=56319&&o<h){var f=e.charCodeAt(o++);56320==(64512&f)?u=((1023&u)<<10)+(1023&f)+65536:o--}l="\\"+u.toString(16).toUpperCase()+" "}else l=r.escapeEverything?p.test(c)?"\\"+c:"\\"+u.toString(16).toUpperCase()+" ":/[\t\n\f\r\x0B:]/.test(c)?i||":"!=c?"\\"+u.toString(16).toUpperCase()+" ":c:"\\"==c||!i&&('"'==c&&a==c||"'"==c&&a==c)||i&&g.test(c)?"\\"+c:c;s+=l}return i&&(/^_/.test(s)?s="\\_"+s.slice(1):/^-[-\d]/.test(s)?s="\\-"+s.slice(1):/\d/.test(n)&&(s="\\3"+n+" "+s.slice(1))),s=s.replace(x,function(t,e,r){return e&&e.length%2?t:(e||"")+r}),!i&&r.wrap?a+s+a:s};a.options={escapeEverything:!1,isIdentifier:!1,quotes:"single",wrap:!1},a.version="1.0.1",e.exports=a},{}],9:[function(t,e,r){var h=/[a-z0-9_-]/i,c=/[\s\t]/,o=/[^a-z0-9_-]/i;e.exports={parse:function(t){for(var e,r,a=!0,i=0,n="",s=0,o=[];;){if(r=t[s],0===i){if(!r&&a)break;if(!r&&!a)throw new Error("Parse error");if('"'===r||"'"===r)e=r,a=!(i=1);else if(c.test(r));else{if(!h.test(r))throw new Error("Parse error");a=!(i=3),s--}}else if(1===i){if(!r)throw new Error("Parse Error");"\\"===r?i=2:r===e?(o.push(n),n="",i=4):n+=r}else if(2===i){if(r!==e&&"\\"!==r)throw new Error("Parse error");n+=r,i=1}else if(3===i){if(!r){o.push(n);break}if(h.test(r))n+=r;else if(","===r)o.push(n),n="",i=0;else{if(!c.test(r))throw new Error("Parse error");o.push(n),n="",i=4}}else if(4===i){if(!r)break;if(","===r)i=0;else if(!c.test(r))throw new Error("Parse error")}s++}return o},stringify:function(t,e){var r=e&&e.quote||'"';if('"'!==r&&"'"!==r)throw new Error("Quote must be `'` or `\"`");for(var a=new RegExp(r,"g"),i=[],n=0;n<t.length;++n){var s=t[n];o.test(s)&&(s=r+(s=s.replace(/\\/g,"\\\\").replace(a,"\\"+r))+r),i.push(s)}return i.join(", ")}}},{}],10:[function(t,e,r){
31
+ /**
32
+ * A class to parse color values
33
+ * @author Stoyan Stefanov <sstoo@gmail.com>
34
+ * @link http://www.phpied.com/rgb-color-parser-in-javascript/
35
+ * @license Use it if you like it
36
+ */
37
+ !function(t){function f(t){this.ok=!1,"#"==t.charAt(0)&&(t=t.substr(1,6)),t=(t=t.replace(/ /g,"")).toLowerCase();var u={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"};for(var e in u)t==e&&(t=u[e]);for(var l=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(t){return[parseInt(t[1]),parseInt(t[2]),parseInt(t[3])]}},{re:/^(\w{2})(\w{2})(\w{2})$/,example:["#00ff00","336699"],process:function(t){return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:["#fb0","f0f"],process:function(t){return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)]}}],r=0;r<l.length;r++){var a=l[r].re,i=l[r].process,n=a.exec(t);if(n){var s=i(n);this.r=s[0],this.g=s[1],this.b=s[2],this.ok=!0}}this.r=this.r<0||isNaN(this.r)?0:255<this.r?255:this.r,this.g=this.g<0||isNaN(this.g)?0:255<this.g?255:this.g,this.b=this.b<0||isNaN(this.b)?0:255<this.b?255:this.b,this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},this.toHex=function(){var t=this.r.toString(16),e=this.g.toString(16),r=this.b.toString(16);return 1==t.length&&(t="0"+t),1==e.length&&(e="0"+e),1==r.length&&(r="0"+r),"#"+t+e+r},this.getHelpXML=function(){for(var t=new Array,e=0;e<l.length;e++)for(var r=l[e].example,a=0;a<r.length;a++)t[t.length]=r[a];for(var i in u)t[t.length]=i;var n=document.createElement("ul");n.setAttribute("id","rgbcolor-examples");for(e=0;e<t.length;e++)try{var s=document.createElement("li"),o=new f(t[e]),h=document.createElement("div");h.style.cssText="margin: 3px; border: 1px solid black; background:"+o.toHex()+"; color:"+o.toHex(),h.appendChild(document.createTextNode("test"));var c=document.createTextNode(" "+t[e]+" -> "+o.toRGB()+" -> "+o.toHex());s.appendChild(h),s.appendChild(c),n.appendChild(s)}catch(t){}return n}}void 0!==e&&e.exports?e.exports=f:t.RGBColor=f}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this)},{}],11:[function(r,p,t){!function(t){var rt,u,c,i,at,it=/url\(["']?#([^"']+)["']?\)/,nt=/^\s*data:(([^/,;]+\/[^/,;]+)(?:;([^,;=]+=[^,;=]+))?)?(?:;(base64))?,(.*\s*)$/i,h="http://www.w3.org/2000/svg",st=function(t){var e=t.getAttribute("d");u&&(e=u(e).unshort().unarc().abs().toString(),t.setAttribute("d",e));var r=t.pathSegList;if(r)return r;r=[];for(var a,i=/([a-df-zA-DF-Z])([^a-df-zA-DF-Z]*)/g;a=i.exec(e);){var n=kt(a[2]),s=a[1],o=0<="zZ".indexOf(s)?0:0<="hHvV".indexOf(s)?1:0<="mMlLtT".indexOf(s)?2:0<="sSqQ".indexOf(s)?4:0<="aA".indexOf(s)?7:0<="cC".indexOf(s)?6:-1,h=0;do{var c={pathSegTypeAsLetter:s};switch(s){case"h":case"H":c.x=n[h];break;case"v":case"V":c.y=n[h];break;case"c":case"C":c.x1=n[h+o-6],c.y1=n[h+o-5];case"s":case"S":c.x2=n[h+o-4],c.y2=n[h+o-3];case"t":case"T":case"l":case"L":case"m":case"M":c.x=n[h+o-2],c.y=n[h+o-1];break;case"q":case"Q":c.x1=n[h],c.y1=n[h+1],c.x=n[h+2],c.y=n[h+3];break;case"a":case"A":throw new Error("Cannot convert Arcs without SvgPath package")}r.push(c),"m"===s?s="l":"M"===s&&(s="L"),h+=o}while(h<n.length)}return r.getItem=function(t){return this[t]},r.numberOfItems=r.length,r},ot=function(t,e,r){return r=r||e,t.getAttribute(e)||t.style&&t.style[r]},ht=function(t,e){return 0<=e.split(",").indexOf(t.tagName.toLowerCase())},O=function(t,e){for(var r=[],a=0;a<t.childNodes.length;a++){var i=t.childNodes[a];"#"!==i.nodeName.charAt(0)&&r.push(i)}for(a=0;a<r.length;a++)e(a,r[a])},ct=function(t,e){return Math.atan2(e[1]-t[1],e[0]-t[0])};function ut(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]);return[t[0]/e,t[1]/e]}function lt(t,e){return ut([e[0]-t[0],e[1]-t[1]])}function ft(t,e){return[t[0]+e[0],t[1]+e[1]]}var s=function(t,e){var r=e[0]-t[0],a=e[1]-t[1];return[t[0]+2*r,t[1]+2*a]},dt=function(t,e){return[2/3*(e[0]-t[0])+t[0],2/3*(e[1]-t[1])+t[1]]},pt=function(t,e,r,a,i){var n=r.getItem(t-1);return 0<t&&("C"===n.pathSegTypeAsLetter||"S"===n.pathSegTypeAsLetter)?s([n.x2,n.y2],e):0<t&&("c"===n.pathSegTypeAsLetter||"s"===n.pathSegTypeAsLetter)?s([n.x2+a,n.y2+i],e):[e[0],e[1]]};function o(t){this.renderedElements={},this.rootSvg=t}o.prototype.getRendered=function(t){if(this.renderedElements.hasOwnProperty(t))return this.renderedElements[t];var e=this.rootSvg.querySelector("#"+i(t,{isIdentifier:!0}));if(ht(e,"lineargradient"))n(e,"axial",[e.getAttribute("x1")||0,e.getAttribute("y1")||0,e.getAttribute("x2")||1,e.getAttribute("y2")||0]);else if(ht(e,"radialgradient"))n(e,"radial",[e.getAttribute("fx")||e.getAttribute("cx")||.5,e.getAttribute("fy")||e.getAttribute("cy")||.5,0,e.getAttribute("cx")||.5,e.getAttribute("cy")||.5,e.getAttribute("r")||.5]);else if(ht(e,"pattern"))f(e,this,gt.default());else if(ht(e,"marker")){var r=mt(e),a=Mt(e);at.beginFormObject(a[0],a[1],a[2],a[3],r),St(e,at.unitMatrix,this,!1,!1,gt.default()),at.endFormObject(e.getAttribute("id"))}else ht(e,"clippath")||It(e,at.unitMatrix,this,!0,!1,gt.default());return this.renderedElements[t]=e};var gt=function(){this.xmlSpace=null,this.color=null,this.fill=null,this.fillOpacity=1,this.fontFamily=null,this.fontSize=16,this.fontStyle=null,this.fontWeight=null,this.opacity=1,this.stroke=null,this.strokeDasharray=null,this.strokeDashoffset=null,this.strokeLinecap=null,this.strokeLinejoin=null,this.strokeMiterlimit=4,this.strokeOpacity=1,this.strokeWidth=1,this.textAnchor=null,this.visibility=null};function xt(){this.markers=[]}function bt(t,e,r){this.id=t,this.anchor=e,this.angle=r}function I(t){return t.replace(/[\n\r]/g,"")}function L(t){return t.replace(/[\t]/g," ")}function T(t){return t.replace(/ +/g," ")}function l(t,e,r,a,i,n){var s,o,h=e[0],c=e[1],u=e[2],l=e[3],f=i/u,d=n/l,p=t.getAttribute("preserveAspectRatio");if(p){var g=p.split(" ");"defer"===g[0]&&(g=g.slice(1)),s=g[0],o=g[1]||"meet"}else s="xMidYMid",o="meet";"none"!==s&&("meet"===o?f=d=Math.min(f,d):"slice"===o&&(f=d=Math.max(f,d)));var x=r-h*f,b=a-c*d;0<=s.indexOf("xMid")?x+=(i-u*f)/2:0<=s.indexOf("xMax")&&(x+=i-u*f),0<=s.indexOf("yMid")?b+=(n-l*d)/2:0<=s.indexOf("yMax")&&(b+=n-l*d);var m=new at.Matrix(1,0,0,1,x,b),v=new at.Matrix(f,0,0,d,0,0);return at.matrixMult(v,m)}gt.default=function(){var t=new gt;return t.xmlSpace="default",t.fill=new rt("rgb(0, 0, 0)"),t.fillOpacity=1,t.fontFamily="times",t.fontSize=16,t.fontStyle="normal",t.fontWeight="normal",t.opacity=1,t.stroke=null,t.strokeDasharray=null,t.strokeDashoffset=null,t.strokeLinecap="butt",t.strokeLinejoin="miter",t.strokeMiterlimit=4,t.strokeOpacity=1,t.strokeWidth=1,t.textAnchor="start",t.visibility="visible",t},gt.prototype.clone=function(){var t=new gt;return t.xmlSpace=this.xmlSpace,t.fill=this.fill,t.fillOpacity=this.fillOpacity,t.fontFamily=this.fontFamily,t.fontSize=this.fontSize,t.fontStyle=this.fontStyle,t.fontWeight=this.fontWeight,t.opacity=this.opacity,t.stroke=this.stroke,t.strokeDasharray=this.strokeDasharray,t.strokeDashoffset=this.strokeDashoffset,t.strokeLinecap=this.strokeLinecap,t.strokeLinejoin=this.strokeLinejoin,t.strokeMiterlimit=this.strokeMiterlimit,t.strokeOpacity=this.strokeOpacity,t.strokeWidth=this.strokeWidth,t.textAnchor=this.textAnchor,t.visibility=this.visibility,t},xt.prototype.addMarker=function(t){this.markers.push(t)},xt.prototype.draw=function(t,e,r){for(var a=0;a<this.markers.length;a++){var i,n=this.markers[a],s=n.angle,o=n.anchor,h=Math.cos(s),c=Math.sin(s);i=new at.Matrix(h,c,-c,h,o[0],o[1]),i=at.matrixMult(new at.Matrix(r.strokeWidth,0,0,r.strokeWidth,0,0),i),i=at.matrixMult(i,t),at.saveGraphicsState(),at.setLineWidth(1),e.getRendered(n.id),at.doFormObject(n.id,i),at.restoreGraphicsState()}};var mt=function(t){var e,r,a,i=at.unitMatrix;if(ht(t,"svg,g"))if(r=parseFloat(t.getAttribute("x"))||0,a=parseFloat(t.getAttribute("y"))||0,e=t.getAttribute("viewBox")){var n=kt(e);i=l(t,n,r,a,parseFloat(t.getAttribute("width"))||n[2],parseFloat(t.getAttribute("height"))||n[3])}else i=new at.Matrix(1,0,0,1,r,a);else if(ht(t,"marker"))if(r=parseFloat(t.getAttribute("refX"))||0,a=parseFloat(t.getAttribute("refY"))||0,e=t.getAttribute("viewBox")){var s=kt(e);s[0]=s[1]=0,i=l(t,s,0,0,parseFloat(t.getAttribute("markerWidth"))||3,parseFloat(t.getAttribute("markerHeight"))||3),i=at.matrixMult(new at.Matrix(1,0,0,1,-r,-a),i)}else i=new at.Matrix(1,0,0,1,-r,-a);var o=t.getAttribute("transform");return o?at.matrixMult(i,yt(o)):i},vt=function(t){for(var e=kt(t),r=[],a=0;a<e.length-1;a+=2){var i=e[a],n=e[a+1];r.push([i,n])}return r},yt=function(t){if(!t)return at.unitMatrix;for(var e,r=/^\s*matrix\(([^\)]+)\)\s*/,a=/^\s*translate\(([^\)]+)\)\s*/,i=/^\s*rotate\(([^\)]+)\)\s*/,n=/^\s*scale\(([^\)]+)\)\s*/,s=/^\s*skewX\(([^\)]+)\)\s*/,o=/^\s*skewY\(([^\)]+)\)\s*/,h=at.unitMatrix;0<t.length;){var c=r.exec(t);if(c&&(e=kt(c[1]),h=at.matrixMult(new at.Matrix(e[0],e[1],e[2],e[3],e[4],e[5]),h),t=t.substr(c[0].length)),c=i.exec(t)){e=kt(c[1]);var u=Math.PI*e[0]/180;if(h=at.matrixMult(new at.Matrix(Math.cos(u),Math.sin(u),-Math.sin(u),Math.cos(u),0,0),h),e[1]&&e[2]){var l=new at.Matrix(1,0,0,1,e[1],e[2]),f=new at.Matrix(1,0,0,1,-e[1],-e[2]);h=at.matrixMult(f,at.matrixMult(h,l))}t=t.substr(c[0].length)}(c=a.exec(t))&&(e=kt(c[1]),h=at.matrixMult(new at.Matrix(1,0,0,1,e[0],e[1]||0),h),t=t.substr(c[0].length)),(c=n.exec(t))&&((e=kt(c[1]))[1]||(e[1]=e[0]),h=at.matrixMult(new at.Matrix(e[0],0,0,e[1],0,0),h),t=t.substr(c[0].length)),(c=s.exec(t))&&(e=parseFloat(c[1]),h=at.matrixMult(new at.Matrix(1,0,Math.tan(e),1,0,0),h),t=t.substr(c[0].length)),(c=o.exec(t))&&(e=parseFloat(c[1]),h=at.matrixMult(new at.Matrix(1,Math.tan(e),0,1,0,0),h),t=t.substr(c[0].length))}return h},kt=function(t){for(var e,r=[],a=/[+-]?(?:(?:\d+\.?\d*)|(?:\d*\.?\d+))(?:[eE][+-]?\d+)?/g;e=a.exec(t);)r.push(parseFloat(e[0]));return r},wt=function(t,e){var r=t[0],a=t[1];return[e.a*r+e.c*a+e.e,e.b*r+e.d*a+e.f]},Mt=function(t){if("none"===ot(t,"display"))return[0,0,0,0];var e,r,a,i,n,s,o,h,c=parseFloat;if(ht(t,"polygon,polyline")){var u=vt(t.getAttribute("points"));for(r=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,n=Number.NEGATIVE_INFINITY,e=0;e<u.length;e++){var l=u[e];r=Math.min(r,l[0]),i=Math.max(i,l[0]),a=Math.min(a,l[1]),n=Math.max(n,l[1])}h=[r,a,i-r,n-a]}else if(ht(t,"path")){var f=st(t);r=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,n=Number.NEGATIVE_INFINITY;var d,p,g,x,b,m,v,y=0,k=0;for(e=0;e<f.numberOfItems;e++){var w=f.getItem(e),M=w.pathSegTypeAsLetter;switch(M){case"H":g=w.x,x=k;break;case"h":g=w.x+y,x=k;break;case"V":g=y,x=w.y;break;case"v":g=y,x=w.y+k;break;case"C":b=[w.x1,w.y1],m=[w.x2,w.y2],v=[w.x,w.y];break;case"c":b=[w.x1+y,w.y1+k],m=[w.x2+y,w.y2+k],v=[w.x+y,w.y+k];break;case"S":b=pt(e,[y,k],f,d,p),m=[w.x2,w.y2],v=[w.x,w.y];break;case"s":b=pt(e,[y,k],f,d,p),m=[w.x2+y,w.y2+k],v=[w.x+y,w.y+k];break;case"Q":c=[w.x1,w.y1],b=dt([y,k],c),m=dt([w.x,w.y],c),v=[w.x,w.y];break;case"q":c=[w.x1+y,w.y1+k],b=dt([y,k],c),m=dt([y+w.x,k+w.y],c),v=[w.x+y,w.y+k];break;case"T":b=pt(e,[y,k],f,d,p),b=dt([y,k],c),m=dt([w.x,w.y],c),v=[w.x,w.y];break;case"t":c=pt(e,[y,k],f,d,p),b=dt([y,k],c),m=dt([y+w.x,k+w.y],c),v=[w.x+y,w.y+k]}0<="sScCqQtT".indexOf(M)&&(d=y,p=k),0<="MLCSQT".indexOf(M)?(y=w.x,k=w.y):0<="mlcsqt".indexOf(M)?(y=w.x+y,k=w.y+k):"zZ".indexOf(M)<0&&(y=g,k=x),0<="CSQTcsqt".indexOf(M)?(r=Math.min(r,y,b[0],m[0],v[0]),i=Math.max(i,y,b[0],m[0],v[0]),a=Math.min(a,k,b[1],m[1],v[1]),n=Math.max(n,k,b[1],m[1],v[1])):(r=Math.min(r,y),i=Math.max(i,y),a=Math.min(a,k),n=Math.max(n,k))}h=[r,a,i-r,n-a]}else{if(ht(t,"svg"))return(s=t.getAttribute("viewBox"))&&(o=kt(s)),[c(t.getAttribute("x"))||o&&o[0]||0,c(t.getAttribute("y"))||o&&o[1]||0,c(t.getAttribute("width"))||o&&o[2]||0,c(t.getAttribute("height"))||o&&o[3]||0];if(ht(t,"g,clippath"))h=[0,0,0,0],O(t,function(t,e){var r=Mt(e);h=[Math.min(h[0],r[0]),Math.min(h[1],r[1]),Math.max(h[0]+h[2],r[0]+r[2])-Math.min(h[0],r[0]),Math.max(h[1]+h[3],r[1]+r[3])-Math.min(h[1],r[1])]});else{if(ht(t,"marker"))return(s=t.getAttribute("viewBox"))&&(o=kt(s)),[o&&o[0]||0,o&&o[1]||0,o&&o[2]||c(t.getAttribute("marker-width"))||0,o&&o[3]||c(t.getAttribute("marker-height"))||0];if(ht(t,"pattern"))return[c(t.getAttribute("x"))||0,c(t.getAttribute("y"))||0,c(t.getAttribute("width"))||0,c(t.getAttribute("height"))||0];var A=c(t.getAttribute("x1"))||c(t.getAttribute("x"))||c(t.getAttribute("cx")-c(t.getAttribute("r")))||0,S=c(t.getAttribute("x2"))||A+c(t.getAttribute("width"))||c(t.getAttribute("cx"))+c(t.getAttribute("r"))||0,F=c(t.getAttribute("y1"))||c(t.getAttribute("y"))||c(t.getAttribute("cy"))-c(t.getAttribute("r"))||0,C=c(t.getAttribute("y2"))||F+c(t.getAttribute("height"))||c(t.getAttribute("cy"))+c(t.getAttribute("r"))||0;h=[Math.min(A,S),Math.min(F,C),Math.max(A,S)-Math.min(A,S),Math.max(F,C)-Math.min(F,C)]}}if(!ht(t,"marker,svg,g")){var I=ot(t,"stroke-width")||1;return ot(t,"stroke-miterlimit")&&(I*=.5/Math.sin(Math.PI/12)),[h[0]-I,h[1]-I,h[2]+2*I,h[3]+2*I]}return h},_=function(t,e){switch(ot(t,"text-transform")){case"uppercase":return e.toUpperCase();case"lowercase":return e.toLowerCase();default:return e}},a=function(){function i(t,e,r,a,i){var n=document.createElement("canvas").getContext("2d");return n.font=[a,i,r,e].join(" "),n.measureText(t).width}function n(t,e,r,a,i){var n=document.createElementNS(h,"text");n.setAttribute("font-family",e),n.setAttribute("font-size",r),n.setAttribute("font-style",a),n.setAttribute("font-weight",i),n.setAttributeNS("http://www.w3.org/XML/1998/namespace","xml:space","preserve"),n.appendChild(document.createTextNode(t));var s=document.createElementNS(h,"svg");s.appendChild(n),s.setAttribute("visibility","hidden"),document.body.appendChild(s);var o=n.getBBox().width;return document.body.removeChild(s),o}var s="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789!\"$%&/()=?'\\+*-_.:,;^}][{#~|<>",o={};return function(t){var e=o[t];if(!e){var r=i(s,t,"16px","normal","normal"),a=n(s,t,"16px","normal","normal");e=Math.abs(r-a)<.1?i:n,o[t]=e}return e}}();function N(t,e){if(0===t.length)return 0;var r=e.fontFamily;return a(r)(t,e.fontFamily,e.fontSize+"px",e.fontStyle,e.fontWeight)}function q(t,e,r){this.texts=[],this.textNodes=[],this.textAnchor=t,this.originX=e,this.originY=r}function P(t,e){var r;return(r=t&&t.toString().match(/^([\-0-9.]+)em$/))?parseFloat(r[1])*e:(r=t&&t.toString().match(/^([\-0-9.]+)(px|)$/))?parseFloat(r[1]):0}q.prototype.add=function(t,e){this.texts.push(e),this.textNodes.push(t)},q.prototype.put=function(t,e){var r,a,i,n=[],s=[],o=[],h=this.originX,c=this.originY,u=h,l=h;for(r=0;r<this.textNodes.length;r++){var f=h,d=c;if("#text"===(a=this.textNodes[r]).nodeName)p=e;else{var p=e.clone(),g=ot(a,"fill");Ft(a,g&&new rt(g),p);var x=a.getAttribute("dx");null!==x&&(f+=P(x,p.fontSize));var b=a.getAttribute("dy");null!==b&&(d+=P(b,p.fontSize))}o[r]=p,n[r]=f,s[r]=d,h=f+N(this.texts[r],p),c=d,u=Math.min(u,f),l=Math.max(l,h)}switch(this.textAnchor){case"start":i=0;break;case"middle":i=(l-u)/2;break;case"end":i=l-u}for(r=0;r<this.textNodes.length;r++){if("#text"!==(a=this.textNodes[r]).nodeName)if("hidden"===(ot(a,"visibility")||e.visibility))continue;at.saveGraphicsState(),Ct(o[r],e),at.text(n[r]-i,s[r],this.texts[r],void 0,t),at.restoreGraphicsState()}return[h,c]};var At=function(t,e,r,a,i){at.saveGraphicsState();var n,s,o=0,h=at.getFontSize(),c=P(t.getAttribute("x"),h),u=P(t.getAttribute("y"),h);n=P(t.getAttribute("dx"),h),s=P(t.getAttribute("dy"),h);var l,f,d=i.visibility,p=t.childElementCount;if(0===p){var g=(l=t.textContent,f=i,l=L(l=I(l)),"default"===f.xmlSpace&&(l=T(l=l.trim())),l),x=_(t,g);o=function(t,e){var r=e.textAnchor;if("start"===r)return 0;var a=N(t,e),i=0;switch(r){case"end":i=a;break;case"middle":i=a/2}return i}(x,i),"visible"===d&&at.text(c+n-o,u+s,x,void 0,e)}else{for(var b=new q(i.textAnchor,c+n,u+s),m=0;m<t.childNodes.length;m++){var v=t.childNodes[m];if(v.textContent){var y=i.xmlSpace;if("#text"===v.nodeName);else if(ht(v,"tspan")){var k,w=v,M=w.getAttribute("x");if(null!==M){var A=P(M,h);k=b.put(e,i),b=new q(w.getAttribute("text-anchor")||i.textAnchor,A,k[1])}var S=w.getAttribute("y");if(null!==S){var F=P(S,h);k=b.put(e,i),b=new q(w.getAttribute("text-anchor")||i.textAnchor,k[0],F)}var C=w.getAttribute("xml:space");C&&(y=C)}g=L(g=I(g=v.textContent)),"default"===y&&(0===m&&(g=g.replace(/^\s+/,"")),m===p-1&&(g=g.replace(/\s+$/,"")),g=T(g)),x=_(t,g),b.add(v,x)}}b.put(e,i)}at.restoreGraphicsState()},St=function(t,r,a,i,n,s){O(t,function(t,e){It(e,r,a,i,n,s)})},n=function(t,e,r){var a,i=[],n=0,s=!1;O(t,function(t,e){if("stop"===e.tagName.toLowerCase()){var r=new rt(ot(e,"stop-color"));i.push({offset:parseFloat(e.getAttribute("offset")),color:[r.r,r.g,r.b]});var a=ot(e,"stop-opacity");a&&1!=a&&(n+=parseFloat(a),s=!0)}}),s&&(a=new at.GState({opacity:n/i.length}));var o=new at.ShadingPattern(e,r,i,a),h=t.getAttribute("id");at.addShadingPattern(h,o)},f=function(t,e,r){var a=t.getAttribute("id"),i=Mt(t),n=new at.TilingPattern([i[0],i[1],i[0]+i[2],i[1]+i[3]],i[2],i[3],null,at.unitMatrix);at.beginTilingPattern(n),St(t,at.unitMatrix,e,!1,!1,r),at.endTilingPattern(a,n)},d={"sans-serif":"helvetica",verdana:"helvetica",arial:"helvetica",fixed:"courier",monospace:"courier",terminal:"courier",serif:"times",cursive:"times",fantasy:"times"};function Ft(t,e,r){e&&e.ok&&(r.fill=e);var a=ot(t,"font-weight");a&&(r.fontWeight=a);var i=ot(t,"font-style");i&&(r.fontStyle=i);var n=ot(t,"font-family");if(n){var s=c.parse(n);r.fontFamily=function(t,e){var r="";"bold"===t.fontWeight&&(r="bold"),"italic"===t.fontStyle&&(r+="italic"),""===r&&(r="normal");var a=at.getFontList(),i="";return e.some(function(t){var e=a[t];return e&&0<=e.indexOf(r)?(i=t,!0):(t=t.toLowerCase(),!!d.hasOwnProperty(t)&&(i=t,!0))})||(i="times"),i}(r,s)}var o=ot(t,"font-size");o&&(r.fontSize=parseFloat(o));var h=ot(t,"text-anchor");h&&(r.textAnchor=h)}function Ct(t,e){if(t.fontFamily!==e.fontFamily&&(d.hasOwnProperty(t.fontFamily)?at.setFont(d[t.fontFamily]):at.setFont(t.fontFamily)),t.fill!==e.fill&&t.fill.ok){var r=t.fill;at.setTextColor(r.r,r.g,r.b)}if(t.fontWeight!==e.fontWeight||t.fontStyle!==e.fontStyle){var a="";"bold"===t.fontWeight&&(a="bold"),"italic"===t.fontStyle&&(a+="italic"),""===a&&(a="normal"),at.setFontType(a)}t.fontSize!==e.fontSize&&at.setFontSize(t.fontSize)}var It=function(t,e,r,a,i,n){var s=n;if((n=n.clone(),!ht(t,"defs,clippath,pattern,lineargradient,radialgradient,marker"))&&("none"!==ot(t,"display")&&("hidden"!==(n.visibility=ot(t,"visibility")||n.visibility)||ht(t,"svg,g,marker,a,pattern,defs,text")))){var o,h,c=!1,u=null,l="inherit",f="inherit",d=void 0,p=a&&!ht(t,"lineargradient,radialgradient,pattern,clippath");p?(o=mt(t),h=Mt(t),at.beginFormObject(h[0],h[1],h[2],h[3],o),o=at.unitMatrix,a=!1):(o=at.matrixMult(mt(t),e),i||at.saveGraphicsState());var g=t.hasAttribute("clip-path")&&"none"!==t.getAttribute("clip-path");if(g){var x=it.exec(t.getAttribute("clip-path")),b=r.getRendered(x[1]),m=o;b.hasAttribute("clipPathUnits")&&"objectboundingbox"===b.getAttribute("clipPathUnits").toLowerCase()&&(h=Mt(t),m=at.matrixMult(new at.Matrix(h[2],0,0,h[3],h[0],h[1]),m)),m=at.matrixMult(mt(b),m),at.saveGraphicsState(),at.setCurrentTransformationMatrix(m),St(b,at.unitMatrix,r,!1,!0,n),at.clip().discardPath(),at.setCurrentTransformationMatrix(m.inversed())}if(ht(t,"g,path,rect,text,ellipse,line,circle,polygon,polyline")){var v=ot(t,"fill");if(v){var y=it.exec(v);if(y){var k=y[1],w=r.getRendered(k);if(w&&ht(w,"lineargradient,radialgradient")){var M;w.hasAttribute("gradientUnits")&&"objectboundingbox"!==w.getAttribute("gradientUnits").toLowerCase()?M=at.unitMatrix:(h||(h=Mt(t)),M=new at.Matrix(h[2],0,0,h[3],h[0],h[1]));var A=yt(w.getAttribute("gradientTransform"));d={key:k,matrix:at.matrixMult(A,M)},l=!0}else if(w&&ht(w,"pattern")){var S,F,C,I,O;d={key:k};var L=at.unitMatrix;w.hasAttribute("patternUnits")&&"objectboundingbox"!==w.getAttribute("patternUnits").toLowerCase()||(h||(h=Mt(t)),L=new at.Matrix(1,0,0,1,h[0],h[1]),O=(S=Mt(w))[0]*h[0],F=S[1]*h[1],C=S[2]*h[2],I=S[3]*h[3],d.boundingBox=[O,F,O+C,F+I],d.xStep=C,d.yStep=I);var T=at.unitMatrix;w.hasAttribute("patternContentUnits")&&"objectboundingbox"===w.getAttribute("patternContentUnits").toLowerCase()&&(h||(h=Mt(t)),T=new at.Matrix(h[2],0,0,h[3],0,0),O=(S=d.boundingBox||Mt(w))[0]/h[0],F=S[1]/h[1],C=S[2]/h[2],I=S[3]/h[3],d.boundingBox=[O,F,O+C,F+I],d.xStep=C,d.yStep=I);var _=at.unitMatrix;w.hasAttribute("patternTransform")&&(_=yt(w.getAttribute("patternTransform")));var N=T;N=at.matrixMult(N,L),N=at.matrixMult(N,_),N=at.matrixMult(N,o),d.matrix=N,l=!0}else u=new rt("rgb(0, 0, 0)"),l=c=!0}else u=function(t){if("transparent"===t){var e=new rt("rgb(0,0,0)");return e.a=0,e}var r=/\s*rgba\(((?:[^,\)]*,){3}[^,\)]*)\)\s*/.exec(t);if(r){var a=kt(r[1]),i=new rt("rgb("+a.slice(0,3).join(",")+")");return i.a=a[3],i}return new rt(t)}(v),l=!!u.ok&&(c=!0)}var q=1,P=1,E=ot(t,"fill-opacity");E&&(q*=parseFloat(E)),u&&"number"==typeof u.a&&(q*=u.a);var z=ot(t,"stroke-opacity");z&&(P*=parseFloat(z)),R&&"number"==typeof R.a&&(P*=R.a);var j=ot(t,"opacity");if(j){var G=parseFloat(j);P*=G,q*=G}var W=q<1,Y=P<1;if(W||Y){var D={};W&&(D.opacity=q),Y&&(D["stroke-opacity"]=P),at.setGState(new at.GState(D))}}if(ht(t,"g,path,rect,ellipse,line,circle,polygon,polyline")){c&&(n.fill=u,at.setFillColor(u.r,u.g,u.b));var V=ot(t,"stroke");if(V){var U=ot(t,"stroke-width");void 0!==U&&""!==U?(U=Math.abs(parseFloat(U)),n.strokeWidth=U,at.setLineWidth(U)):U=n.strokeWidth;var R=new rt(V);R.ok&&(n.stroke=R,at.setDrawColor(R.r,R.g,R.b),f=0!==U);var H=ot(t,"stroke-linecap");H&&at.setLineCap(n.strokeLinecap=H);var B=ot(t,"stroke-linejoin");B&&at.setLineJoin(n.strokeLinejoin=B);var X=ot(t,"stroke-dasharray");if(X){X=kt(X);var Q=parseInt(ot(t,"stroke-dashoffset"))||0;n.strokeDasharray=X,n.strokeDashoffset=Q,at.setLineDashPattern(X,Q)}var Z=ot(t,"stroke-miterlimit");void 0!==Z&&""!==Z&&at.setLineMiterLimit(n.strokeMiterlimit=parseFloat(Z))}}"inherit"===l&&(l=null!==n.fill),"inherit"===f&&(f=null!==n.stroke);var $,J,K,tt,et=t.getAttribute("xml:space");switch(et&&(n.xmlSpace=et),Ft(t,u,n),Ct(n,s),t.tagName.toLowerCase()){case"svg":case"g":case"a":St(t,o,r,a,!1,n);break;case"use":!function(t,e,r){var a=t.getAttribute("href")||t.getAttribute("xlink:href");if(a){var i=a.substring(1);r.getRendered(i);var n=at.getFormObject(i),s=t.getAttribute("x")||0,o=t.getAttribute("y")||0,h=t.getAttribute("width")||n.width,c=t.getAttribute("height")||n.height,u=new at.Matrix(h/n.width||0,0,0,c/n.height||0,s,o);u=at.matrixMult(u,e),at.doFormObject(i,u)}}(t,o,r);break;case"line":i||(at.setCurrentTransformationMatrix(o),function(t,e,r){var a=[parseFloat(t.getAttribute("x1")||0),parseFloat(t.getAttribute("y1")||0)],i=[parseFloat(t.getAttribute("x2")||0),parseFloat(t.getAttribute("y2")||0)];null!==r.stroke&&at.line(a[0],a[1],i[0],i[1]);var n=t.getAttribute("marker-start"),s=t.getAttribute("marker-end");if(n||s){var o=new xt,h=ct(a,i);n&&o.addMarker(new bt(it.exec(n)[1],a,h)),s&&o.addMarker(new bt(it.exec(s)[1],i,h)),o.draw(at.unitMatrix,e,r)}}(t,r,n));break;case"rect":i||at.setCurrentTransformationMatrix(o),tt=t,at.roundedRect(parseFloat(tt.getAttribute("x"))||0,parseFloat(tt.getAttribute("y"))||0,parseFloat(tt.getAttribute("width")),parseFloat(tt.getAttribute("height")),parseFloat(tt.getAttribute("rx"))||0,parseFloat(tt.getAttribute("ry"))||0);break;case"ellipse":i||at.setCurrentTransformationMatrix(o),K=t,at.ellipse(parseFloat(K.getAttribute("cx"))||0,parseFloat(K.getAttribute("cy"))||0,parseFloat(K.getAttribute("rx")),parseFloat(K.getAttribute("ry")));break;case"circle":i||at.setCurrentTransformationMatrix(o),$=t,J=parseFloat($.getAttribute("r"))||0,at.ellipse(parseFloat($.getAttribute("cx"))||0,parseFloat($.getAttribute("cy"))||0,J,J);break;case"text":At(t,o,0,0,n);break;case"path":i||at.setCurrentTransformationMatrix(o),function(t,A,e,S,r){var F=st(t),C=t.getAttribute("marker-end"),I=t.getAttribute("marker-start"),O=t.getAttribute("marker-mid");C&&(C=it.exec(C)[1]),I&&(I=it.exec(I)[1]),O&&(O=it.exec(O)[1]);var a=function(){for(var t,e,r,a,i,n,s,o,h,c,u=0,l=0,f=u,d=l,p=[],g=new xt,x=[0,0],b=0;b<F.numberOfItems;b++){var m=F.getItem(b),v=m.pathSegTypeAsLetter;switch(v){case"M":f=u,d=l,i=[m.x,m.y],h="m";break;case"m":f=u,d=l,i=[m.x+u,m.y+l],h="m";break;case"L":i=[m.x,m.y],h="l";break;case"l":i=[m.x+u,m.y+l],h="l";break;case"H":i=[m.x,l],h="l",r=m.x,a=l;break;case"h":i=[m.x+u,l],h="l",r=m.x+u,a=l;break;case"V":i=[u,m.y],h="l",r=u,a=m.y;break;case"v":i=[u,m.y+l],h="l",r=u,a=m.y+l;break;case"C":s=[m.x1,m.y1],o=[m.x2,m.y2],i=[m.x,m.y];break;case"c":s=[m.x1+u,m.y1+l],o=[m.x2+u,m.y2+l],i=[m.x+u,m.y+l];break;case"S":s=pt(b,[u,l],F,t,e),o=[m.x2,m.y2],i=[m.x,m.y];break;case"s":s=pt(b,[u,l],F,t,e),o=[m.x2+u,m.y2+l],i=[m.x+u,m.y+l];break;case"Q":n=[m.x1,m.y1],s=dt([u,l],n),o=dt([m.x,m.y],n),i=[m.x,m.y];break;case"q":n=[m.x1+u,m.y1+l],s=dt([u,l],n),o=dt([u+m.x,l+m.y],n),i=[m.x+u,m.y+l];break;case"T":n=pt(b,[u,l],F,t,e),s=dt([u,l],n),o=dt([m.x,m.y],n),i=[m.x,m.y];break;case"t":n=pt(b,[u,l],F,t,e),s=dt([u,l],n),o=dt([u+m.x,l+m.y],n),i=[m.x+u,m.y+l];break;case"Z":case"z":u=f,l=d,p.push({op:"h"})}var y=I&&(1===b||"mM".indexOf(v)<0&&0<="mM".indexOf(F.getItem(b-1).pathSegTypeAsLetter)),k=C&&(b===F.numberOfItems-1||"mM".indexOf(v)<0&&0<="mM".indexOf(F.getItem(b+1).pathSegTypeAsLetter)),w=O&&0<b&&!(1===b&&0<="mM".indexOf(F.getItem(b-1).pathSegTypeAsLetter));if(0<="sScCqQtT".indexOf(v))y&&g.addMarker(new bt(I,[u,l],ct([u,l],s))),k&&g.addMarker(new bt(C,i,ct(o,i))),w&&(c=lt([u,l],s),c=0<="mM".indexOf(F.getItem(b-1).pathSegTypeAsLetter)?c:ut(ft(x,c)),g.addMarker(new bt(O,[u,l],Math.atan2(c[1],c[0])))),x=lt(o,i),t=u,e=l,S&&(s=wt(s,A),o=wt(o,A),i=wt(i,A)),p.push({op:"c",c:[s[0],s[1],o[0],o[1],i[0],i[1]]});else if(0<="lLhHvVmM".indexOf(v)){if(c=lt([u,l],i),y&&g.addMarker(new bt(I,[u,l],Math.atan2(c[1],c[0]))),k&&g.addMarker(new bt(C,i,Math.atan2(c[1],c[0]))),w){var M=0<="mM".indexOf(v)?x:0<="mM".indexOf(F.getItem(b-1).pathSegTypeAsLetter)?c:ut(ft(x,c));g.addMarker(new bt(O,[u,l],Math.atan2(M[1],M[0])))}x=c,S&&(i=wt(i,A)),p.push({op:h,c:i})}0<="MLCSQT".indexOf(v)?(u=m.x,l=m.y):0<="mlcsqt".indexOf(v)?(u=m.x+u,l=m.y+l):"zZ".indexOf(v)<0&&(u=r,l=a)}return{lines:p,markers:g}}();0<a.lines.length&&at.path(a.lines),(C||I||O)&&a.markers.draw(at.unitMatrix,e,r)}(t,o,r,i,n);break;case"polygon":case"polyline":i||at.setCurrentTransformationMatrix(o),function(t,e,r,a){if(t.hasAttribute("points")&&""!==t.getAttribute("points")){var i,n,s=vt(t.getAttribute("points")),o=[{op:"m",c:s[0]}];for(i=1;i<s.length;i++)o.push({op:"l",c:s[i]});a&&o.push({op:"h"}),at.path(o);var h=t.getAttribute("marker-end"),c=t.getAttribute("marker-start"),u=t.getAttribute("marker-mid");if(c||u||h){var l=o.length,f=new xt;if(c&&(c=it.exec(c)[1],n=ft(lt(o[0].c,o[1].c),lt(o[l-2].c,o[0].c)),f.addMarker(new bt(c,o[0].c,Math.atan2(n[1],n[0])))),u){u=it.exec(u)[1];var d,p=lt(o[0].c,o[1].c);for(i=1;i<o.length-2;i++)n=ft(p,d=lt(o[i].c,o[i+1].c)),f.addMarker(new bt(u,o[i].c,Math.atan2(n[1],n[0]))),p=d;n=ft(p,d=lt(o[l-2].c,o[0].c)),f.addMarker(new bt(u,o[l-2].c,Math.atan2(n[1],n[0])))}h&&(h=it.exec(h)[1],n=ft(lt(o[0].c,o[1].c),lt(o[l-2].c,o[0].c)),f.addMarker(new bt(h,o[0].c,Math.atan2(n[1],n[0])))),f.draw(at.unitMatrix,e,r)}}}(t,r,n,"polygon"===t.tagName.toLowerCase());break;case"image":at.setCurrentTransformationMatrix(o),function(t){var e=parseFloat(t.getAttribute("width")),r=parseFloat(t.getAttribute("height")),a=parseFloat(t.getAttribute("x")||0),i=parseFloat(t.getAttribute("y")||0),n=t.getAttribute("xlink:href")||t.getAttribute("href"),s=n.match(nt);if(s&&"image/svg+xml"===s[2]){var o=s[5];o="base64"===s[4]?atob(o):decodeURIComponent(o);var h=(new DOMParser).parseFromString(o,"image/svg+xml").firstElementChild,c=t.getAttribute("preserveAspectRatio");return(!c||c.indexOf("defer")<0||!h.getAttribute("preserveAspectRatio"))&&h.setAttribute("preserveAspectRatio",c),h.setAttribute("x",String(a)),h.setAttribute("y",String(i)),h.setAttribute("width",String(e)),h.setAttribute("height",String(r)),It(h,at.unitMatrix,{},!1,!1,gt.default())}try{at.addImage(n,"",a,i,e,r)}catch(t){"object"==typeof console&&console.warn&&console.warn('svg2pdfjs: Images with external resource link are not supported! ("'+n+'")')}}(t)}ht(t,"path,rect,ellipse,circle,polygon,polyline")&&!i&&(l&&f?at.fillStroke(d):l?at.fill(d):f?at.stroke():at.discardPath()),p?at.endFormObject(t.getAttribute("id")):i||at.restoreGraphicsState(),g&&at.restoreGraphicsState()}},e=function(a,t,e){at=t;var i=e.scale||1,n=e.xOffset||0,s=e.yOffset||0;return at.advancedAPI(function(){at.saveGraphicsState(),at.setCurrentTransformationMatrix(new at.Matrix(i,0,0,i,n,s));var t=gt.default();at.setLineWidth(t.strokeWidth);var e=t.fill;at.setFillColor(e.r,e.g,e.b),at.setFont(t.fontFamily),at.setFontSize(t.fontSize);var r=new o(a);It(a.cloneNode(!0),at.unitMatrix,r,!1,!1,t),at.restoreGraphicsState()}),at};void 0!==p&&p.exports?(rt=r("./rgbcolor.js"),u=r("SvgPath"),c=r("font-family"),i=r("cssesc"),p.exports=e):(u=t.SvgPath,rt=t.RGBColor,c=t.FontFamily,i=t.cssesc,t.svg2pdf=e,t.svgElementToPdf=e)}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this)},{"./rgbcolor.js":10,SvgPath:1,cssesc:8,"font-family":9}]},{},[11])(11)});
38
+ //# sourceMappingURL=svg2pdf.min.js.map
@@ -0,0 +1,4390 @@
1
+ /**
2
+ * Modules in this bundle
3
+ * @license
4
+ *
5
+ * svg2pdf.js:
6
+ * license: MIT (http://opensource.org/licenses/MIT)
7
+ * author: yFiles for HTML Support Team <yfileshtml@yworks.com>
8
+ * homepage: https://github.com/yWorks/svg2pdf.js#readme
9
+ * version: 1.3.1
10
+ *
11
+ * cssesc:
12
+ * license: MIT (http://opensource.org/licenses/MIT)
13
+ * author: Mathias Bynens
14
+ * homepage: https://mths.be/cssesc
15
+ * version: 2.0.0
16
+ *
17
+ * font-family:
18
+ * license: MIT (http://opensource.org/licenses/MIT)
19
+ * author: Taro Hanamura <m@hanamurataro.com>
20
+ * homepage: https://github.com/hanamura/font-family
21
+ * version: 0.2.0
22
+ *
23
+ * svgpath:
24
+ * license: MIT (http://opensource.org/licenses/MIT)
25
+ * homepage: https://github.com/fontello/svgpath#readme
26
+ * version: 2.2.1
27
+ *
28
+ * This header is generated by licensify (https://github.com/twada/licensify)
29
+ */
30
+ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.svg2pdf = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
31
+ 'use strict';
32
+
33
+ module.exports = require('./lib/svgpath');
34
+
35
+ },{"./lib/svgpath":6}],2:[function(require,module,exports){
36
+ // Convert an arc to a sequence of cubic bézier curves
37
+ //
38
+ 'use strict';
39
+
40
+
41
+ var TAU = Math.PI * 2;
42
+
43
+
44
+ /* eslint-disable space-infix-ops */
45
+
46
+ // Calculate an angle between two vectors
47
+ //
48
+ function vector_angle(ux, uy, vx, vy) {
49
+ var sign = (ux * vy - uy * vx < 0) ? -1 : 1;
50
+ var umag = Math.sqrt(ux * ux + uy * uy);
51
+ var vmag = Math.sqrt(ux * ux + uy * uy);
52
+ var dot = ux * vx + uy * vy;
53
+ var div = dot / (umag * vmag);
54
+
55
+ // rounding errors, e.g. -1.0000000000000002 can screw up this
56
+ if (div > 1.0) { div = 1.0; }
57
+ if (div < -1.0) { div = -1.0; }
58
+
59
+ return sign * Math.acos(div);
60
+ }
61
+
62
+
63
+ // Convert from endpoint to center parameterization,
64
+ // see http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
65
+ //
66
+ // Return [cx, cy, theta1, delta_theta]
67
+ //
68
+ function get_arc_center(x1, y1, x2, y2, fa, fs, rx, ry, sin_phi, cos_phi) {
69
+ // Step 1.
70
+ //
71
+ // Moving an ellipse so origin will be the middlepoint between our two
72
+ // points. After that, rotate it to line up ellipse axes with coordinate
73
+ // axes.
74
+ //
75
+ var x1p = cos_phi*(x1-x2)/2 + sin_phi*(y1-y2)/2;
76
+ var y1p = -sin_phi*(x1-x2)/2 + cos_phi*(y1-y2)/2;
77
+
78
+ var rx_sq = rx * rx;
79
+ var ry_sq = ry * ry;
80
+ var x1p_sq = x1p * x1p;
81
+ var y1p_sq = y1p * y1p;
82
+
83
+ // Step 2.
84
+ //
85
+ // Compute coordinates of the centre of this ellipse (cx', cy')
86
+ // in the new coordinate system.
87
+ //
88
+ var radicant = (rx_sq * ry_sq) - (rx_sq * y1p_sq) - (ry_sq * x1p_sq);
89
+
90
+ if (radicant < 0) {
91
+ // due to rounding errors it might be e.g. -1.3877787807814457e-17
92
+ radicant = 0;
93
+ }
94
+
95
+ radicant /= (rx_sq * y1p_sq) + (ry_sq * x1p_sq);
96
+ radicant = Math.sqrt(radicant) * (fa === fs ? -1 : 1);
97
+
98
+ var cxp = radicant * rx/ry * y1p;
99
+ var cyp = radicant * -ry/rx * x1p;
100
+
101
+ // Step 3.
102
+ //
103
+ // Transform back to get centre coordinates (cx, cy) in the original
104
+ // coordinate system.
105
+ //
106
+ var cx = cos_phi*cxp - sin_phi*cyp + (x1+x2)/2;
107
+ var cy = sin_phi*cxp + cos_phi*cyp + (y1+y2)/2;
108
+
109
+ // Step 4.
110
+ //
111
+ // Compute angles (theta1, delta_theta).
112
+ //
113
+ var v1x = (x1p - cxp) / rx;
114
+ var v1y = (y1p - cyp) / ry;
115
+ var v2x = (-x1p - cxp) / rx;
116
+ var v2y = (-y1p - cyp) / ry;
117
+
118
+ var theta1 = vector_angle(1, 0, v1x, v1y);
119
+ var delta_theta = vector_angle(v1x, v1y, v2x, v2y);
120
+
121
+ if (fs === 0 && delta_theta > 0) {
122
+ delta_theta -= TAU;
123
+ }
124
+ if (fs === 1 && delta_theta < 0) {
125
+ delta_theta += TAU;
126
+ }
127
+
128
+ return [ cx, cy, theta1, delta_theta ];
129
+ }
130
+
131
+ //
132
+ // Approximate one unit arc segment with bézier curves,
133
+ // see http://math.stackexchange.com/questions/873224
134
+ //
135
+ function approximate_unit_arc(theta1, delta_theta) {
136
+ var alpha = 4/3 * Math.tan(delta_theta/4);
137
+
138
+ var x1 = Math.cos(theta1);
139
+ var y1 = Math.sin(theta1);
140
+ var x2 = Math.cos(theta1 + delta_theta);
141
+ var y2 = Math.sin(theta1 + delta_theta);
142
+
143
+ return [ x1, y1, x1 - y1*alpha, y1 + x1*alpha, x2 + y2*alpha, y2 - x2*alpha, x2, y2 ];
144
+ }
145
+
146
+ module.exports = function a2c(x1, y1, x2, y2, fa, fs, rx, ry, phi) {
147
+ var sin_phi = Math.sin(phi * TAU / 360);
148
+ var cos_phi = Math.cos(phi * TAU / 360);
149
+
150
+ // Make sure radii are valid
151
+ //
152
+ var x1p = cos_phi*(x1-x2)/2 + sin_phi*(y1-y2)/2;
153
+ var y1p = -sin_phi*(x1-x2)/2 + cos_phi*(y1-y2)/2;
154
+
155
+ if (x1p === 0 && y1p === 0) {
156
+ // we're asked to draw line to itself
157
+ return [];
158
+ }
159
+
160
+ if (rx === 0 || ry === 0) {
161
+ // one of the radii is zero
162
+ return [];
163
+ }
164
+
165
+
166
+ // Compensate out-of-range radii
167
+ //
168
+ rx = Math.abs(rx);
169
+ ry = Math.abs(ry);
170
+
171
+ var lambda = (x1p * x1p) / (rx * rx) + (y1p * y1p) / (ry * ry);
172
+ if (lambda > 1) {
173
+ rx *= Math.sqrt(lambda);
174
+ ry *= Math.sqrt(lambda);
175
+ }
176
+
177
+
178
+ // Get center parameters (cx, cy, theta1, delta_theta)
179
+ //
180
+ var cc = get_arc_center(x1, y1, x2, y2, fa, fs, rx, ry, sin_phi, cos_phi);
181
+
182
+ var result = [];
183
+ var theta1 = cc[2];
184
+ var delta_theta = cc[3];
185
+
186
+ // Split an arc to multiple segments, so each segment
187
+ // will be less than τ/4 (= 90°)
188
+ //
189
+ var segments = Math.max(Math.ceil(Math.abs(delta_theta) / (TAU / 4)), 1);
190
+ delta_theta /= segments;
191
+
192
+ for (var i = 0; i < segments; i++) {
193
+ result.push(approximate_unit_arc(theta1, delta_theta));
194
+ theta1 += delta_theta;
195
+ }
196
+
197
+ // We have a bezier approximation of a unit circle,
198
+ // now need to transform back to the original ellipse
199
+ //
200
+ return result.map(function (curve) {
201
+ for (var i = 0; i < curve.length; i += 2) {
202
+ var x = curve[i + 0];
203
+ var y = curve[i + 1];
204
+
205
+ // scale
206
+ x *= rx;
207
+ y *= ry;
208
+
209
+ // rotate
210
+ var xp = cos_phi*x - sin_phi*y;
211
+ var yp = sin_phi*x + cos_phi*y;
212
+
213
+ // translate
214
+ curve[i + 0] = xp + cc[0];
215
+ curve[i + 1] = yp + cc[1];
216
+ }
217
+
218
+ return curve;
219
+ });
220
+ };
221
+
222
+ },{}],3:[function(require,module,exports){
223
+ 'use strict';
224
+
225
+ /* eslint-disable space-infix-ops */
226
+
227
+ // The precision used to consider an ellipse as a circle
228
+ //
229
+ var epsilon = 0.0000000001;
230
+
231
+ // To convert degree in radians
232
+ //
233
+ var torad = Math.PI / 180;
234
+
235
+ // Class constructor :
236
+ // an ellipse centred at 0 with radii rx,ry and x - axis - angle ax.
237
+ //
238
+ function Ellipse(rx, ry, ax) {
239
+ if (!(this instanceof Ellipse)) { return new Ellipse(rx, ry, ax); }
240
+ this.rx = rx;
241
+ this.ry = ry;
242
+ this.ax = ax;
243
+ }
244
+
245
+ // Apply a linear transform m to the ellipse
246
+ // m is an array representing a matrix :
247
+ // - -
248
+ // | m[0] m[2] |
249
+ // | m[1] m[3] |
250
+ // - -
251
+ //
252
+ Ellipse.prototype.transform = function (m) {
253
+ // We consider the current ellipse as image of the unit circle
254
+ // by first scale(rx,ry) and then rotate(ax) ...
255
+ // So we apply ma = m x rotate(ax) x scale(rx,ry) to the unit circle.
256
+ var c = Math.cos(this.ax * torad), s = Math.sin(this.ax * torad);
257
+ var ma = [
258
+ this.rx * (m[0]*c + m[2]*s),
259
+ this.rx * (m[1]*c + m[3]*s),
260
+ this.ry * (-m[0]*s + m[2]*c),
261
+ this.ry * (-m[1]*s + m[3]*c)
262
+ ];
263
+
264
+ // ma * transpose(ma) = [ J L ]
265
+ // [ L K ]
266
+ // L is calculated later (if the image is not a circle)
267
+ var J = ma[0]*ma[0] + ma[2]*ma[2],
268
+ K = ma[1]*ma[1] + ma[3]*ma[3];
269
+
270
+ // the discriminant of the characteristic polynomial of ma * transpose(ma)
271
+ var D = ((ma[0]-ma[3])*(ma[0]-ma[3]) + (ma[2]+ma[1])*(ma[2]+ma[1])) *
272
+ ((ma[0]+ma[3])*(ma[0]+ma[3]) + (ma[2]-ma[1])*(ma[2]-ma[1]));
273
+
274
+ // the "mean eigenvalue"
275
+ var JK = (J + K) / 2;
276
+
277
+ // check if the image is (almost) a circle
278
+ if (D < epsilon * JK) {
279
+ // if it is
280
+ this.rx = this.ry = Math.sqrt(JK);
281
+ this.ax = 0;
282
+ return this;
283
+ }
284
+
285
+ // if it is not a circle
286
+ var L = ma[0]*ma[1] + ma[2]*ma[3];
287
+
288
+ D = Math.sqrt(D);
289
+
290
+ // {l1,l2} = the two eigen values of ma * transpose(ma)
291
+ var l1 = JK + D/2,
292
+ l2 = JK - D/2;
293
+ // the x - axis - rotation angle is the argument of the l1 - eigenvector
294
+ this.ax = (Math.abs(L) < epsilon && Math.abs(l1 - K) < epsilon) ?
295
+ 90
296
+ :
297
+ Math.atan(Math.abs(L) > Math.abs(l1 - K) ?
298
+ (l1 - J) / L
299
+ :
300
+ L / (l1 - K)
301
+ ) * 180 / Math.PI;
302
+
303
+ // if ax > 0 => rx = sqrt(l1), ry = sqrt(l2), else exchange axes and ax += 90
304
+ if (this.ax >= 0) {
305
+ // if ax in [0,90]
306
+ this.rx = Math.sqrt(l1);
307
+ this.ry = Math.sqrt(l2);
308
+ } else {
309
+ // if ax in ]-90,0[ => exchange axes
310
+ this.ax += 90;
311
+ this.rx = Math.sqrt(l2);
312
+ this.ry = Math.sqrt(l1);
313
+ }
314
+
315
+ return this;
316
+ };
317
+
318
+ // Check if the ellipse is (almost) degenerate, i.e. rx = 0 or ry = 0
319
+ //
320
+ Ellipse.prototype.isDegenerate = function () {
321
+ return (this.rx < epsilon * this.ry || this.ry < epsilon * this.rx);
322
+ };
323
+
324
+ module.exports = Ellipse;
325
+
326
+ },{}],4:[function(require,module,exports){
327
+ 'use strict';
328
+
329
+ // combine 2 matrixes
330
+ // m1, m2 - [a, b, c, d, e, g]
331
+ //
332
+ function combine(m1, m2) {
333
+ return [
334
+ m1[0] * m2[0] + m1[2] * m2[1],
335
+ m1[1] * m2[0] + m1[3] * m2[1],
336
+ m1[0] * m2[2] + m1[2] * m2[3],
337
+ m1[1] * m2[2] + m1[3] * m2[3],
338
+ m1[0] * m2[4] + m1[2] * m2[5] + m1[4],
339
+ m1[1] * m2[4] + m1[3] * m2[5] + m1[5]
340
+ ];
341
+ }
342
+
343
+
344
+ function Matrix() {
345
+ if (!(this instanceof Matrix)) { return new Matrix(); }
346
+ this.queue = []; // list of matrixes to apply
347
+ this.cache = null; // combined matrix cache
348
+ }
349
+
350
+
351
+ Matrix.prototype.matrix = function (m) {
352
+ if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1 && m[4] === 0 && m[5] === 0) {
353
+ return this;
354
+ }
355
+ this.cache = null;
356
+ this.queue.push(m);
357
+ return this;
358
+ };
359
+
360
+
361
+ Matrix.prototype.translate = function (tx, ty) {
362
+ if (tx !== 0 || ty !== 0) {
363
+ this.cache = null;
364
+ this.queue.push([ 1, 0, 0, 1, tx, ty ]);
365
+ }
366
+ return this;
367
+ };
368
+
369
+
370
+ Matrix.prototype.scale = function (sx, sy) {
371
+ if (sx !== 1 || sy !== 1) {
372
+ this.cache = null;
373
+ this.queue.push([ sx, 0, 0, sy, 0, 0 ]);
374
+ }
375
+ return this;
376
+ };
377
+
378
+
379
+ Matrix.prototype.rotate = function (angle, rx, ry) {
380
+ var rad, cos, sin;
381
+
382
+ if (angle !== 0) {
383
+ this.translate(rx, ry);
384
+
385
+ rad = angle * Math.PI / 180;
386
+ cos = Math.cos(rad);
387
+ sin = Math.sin(rad);
388
+
389
+ this.queue.push([ cos, sin, -sin, cos, 0, 0 ]);
390
+ this.cache = null;
391
+
392
+ this.translate(-rx, -ry);
393
+ }
394
+ return this;
395
+ };
396
+
397
+
398
+ Matrix.prototype.skewX = function (angle) {
399
+ if (angle !== 0) {
400
+ this.cache = null;
401
+ this.queue.push([ 1, 0, Math.tan(angle * Math.PI / 180), 1, 0, 0 ]);
402
+ }
403
+ return this;
404
+ };
405
+
406
+
407
+ Matrix.prototype.skewY = function (angle) {
408
+ if (angle !== 0) {
409
+ this.cache = null;
410
+ this.queue.push([ 1, Math.tan(angle * Math.PI / 180), 0, 1, 0, 0 ]);
411
+ }
412
+ return this;
413
+ };
414
+
415
+
416
+ // Flatten queue
417
+ //
418
+ Matrix.prototype.toArray = function () {
419
+ if (this.cache) {
420
+ return this.cache;
421
+ }
422
+
423
+ if (!this.queue.length) {
424
+ this.cache = [ 1, 0, 0, 1, 0, 0 ];
425
+ return this.cache;
426
+ }
427
+
428
+ this.cache = this.queue[0];
429
+
430
+ if (this.queue.length === 1) {
431
+ return this.cache;
432
+ }
433
+
434
+ for (var i = 1; i < this.queue.length; i++) {
435
+ this.cache = combine(this.cache, this.queue[i]);
436
+ }
437
+
438
+ return this.cache;
439
+ };
440
+
441
+
442
+ // Apply list of matrixes to (x,y) point.
443
+ // If `isRelative` set, `translate` component of matrix will be skipped
444
+ //
445
+ Matrix.prototype.calc = function (x, y, isRelative) {
446
+ var m;
447
+
448
+ // Don't change point on empty transforms queue
449
+ if (!this.queue.length) { return [ x, y ]; }
450
+
451
+ // Calculate final matrix, if not exists
452
+ //
453
+ // NB. if you deside to apply transforms to point one-by-one,
454
+ // they should be taken in reverse order
455
+
456
+ if (!this.cache) {
457
+ this.cache = this.toArray();
458
+ }
459
+
460
+ m = this.cache;
461
+
462
+ // Apply matrix to point
463
+ return [
464
+ x * m[0] + y * m[2] + (isRelative ? 0 : m[4]),
465
+ x * m[1] + y * m[3] + (isRelative ? 0 : m[5])
466
+ ];
467
+ };
468
+
469
+
470
+ module.exports = Matrix;
471
+
472
+ },{}],5:[function(require,module,exports){
473
+ 'use strict';
474
+
475
+
476
+ var paramCounts = { a: 7, c: 6, h: 1, l: 2, m: 2, r: 4, q: 4, s: 4, t: 2, v: 1, z: 0 };
477
+
478
+ var SPECIAL_SPACES = [
479
+ 0x1680, 0x180E, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006,
480
+ 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF
481
+ ];
482
+
483
+ function isSpace(ch) {
484
+ return (ch === 0x0A) || (ch === 0x0D) || (ch === 0x2028) || (ch === 0x2029) || // Line terminators
485
+ // White spaces
486
+ (ch === 0x20) || (ch === 0x09) || (ch === 0x0B) || (ch === 0x0C) || (ch === 0xA0) ||
487
+ (ch >= 0x1680 && SPECIAL_SPACES.indexOf(ch) >= 0);
488
+ }
489
+
490
+ function isCommand(code) {
491
+ /*eslint-disable no-bitwise*/
492
+ switch (code | 0x20) {
493
+ case 0x6D/* m */:
494
+ case 0x7A/* z */:
495
+ case 0x6C/* l */:
496
+ case 0x68/* h */:
497
+ case 0x76/* v */:
498
+ case 0x63/* c */:
499
+ case 0x73/* s */:
500
+ case 0x71/* q */:
501
+ case 0x74/* t */:
502
+ case 0x61/* a */:
503
+ case 0x72/* r */:
504
+ return true;
505
+ }
506
+ return false;
507
+ }
508
+
509
+ function isDigit(code) {
510
+ return (code >= 48 && code <= 57); // 0..9
511
+ }
512
+
513
+ function isDigitStart(code) {
514
+ return (code >= 48 && code <= 57) || /* 0..9 */
515
+ code === 0x2B || /* + */
516
+ code === 0x2D || /* - */
517
+ code === 0x2E; /* . */
518
+ }
519
+
520
+
521
+ function State(path) {
522
+ this.index = 0;
523
+ this.path = path;
524
+ this.max = path.length;
525
+ this.result = [];
526
+ this.param = 0.0;
527
+ this.err = '';
528
+ this.segmentStart = 0;
529
+ this.data = [];
530
+ }
531
+
532
+ function skipSpaces(state) {
533
+ while (state.index < state.max && isSpace(state.path.charCodeAt(state.index))) {
534
+ state.index++;
535
+ }
536
+ }
537
+
538
+
539
+ function scanParam(state) {
540
+ var start = state.index,
541
+ index = start,
542
+ max = state.max,
543
+ zeroFirst = false,
544
+ hasCeiling = false,
545
+ hasDecimal = false,
546
+ hasDot = false,
547
+ ch;
548
+
549
+ if (index >= max) {
550
+ state.err = 'SvgPath: missed param (at pos ' + index + ')';
551
+ return;
552
+ }
553
+ ch = state.path.charCodeAt(index);
554
+
555
+ if (ch === 0x2B/* + */ || ch === 0x2D/* - */) {
556
+ index++;
557
+ ch = (index < max) ? state.path.charCodeAt(index) : 0;
558
+ }
559
+
560
+ // This logic is shamelessly borrowed from Esprima
561
+ // https://github.com/ariya/esprimas
562
+ //
563
+ if (!isDigit(ch) && ch !== 0x2E/* . */) {
564
+ state.err = 'SvgPath: param should start with 0..9 or `.` (at pos ' + index + ')';
565
+ return;
566
+ }
567
+
568
+ if (ch !== 0x2E/* . */) {
569
+ zeroFirst = (ch === 0x30/* 0 */);
570
+ index++;
571
+
572
+ ch = (index < max) ? state.path.charCodeAt(index) : 0;
573
+
574
+ if (zeroFirst && index < max) {
575
+ // decimal number starts with '0' such as '09' is illegal.
576
+ if (ch && isDigit(ch)) {
577
+ state.err = 'SvgPath: numbers started with `0` such as `09` are ilegal (at pos ' + start + ')';
578
+ return;
579
+ }
580
+ }
581
+
582
+ while (index < max && isDigit(state.path.charCodeAt(index))) {
583
+ index++;
584
+ hasCeiling = true;
585
+ }
586
+ ch = (index < max) ? state.path.charCodeAt(index) : 0;
587
+ }
588
+
589
+ if (ch === 0x2E/* . */) {
590
+ hasDot = true;
591
+ index++;
592
+ while (isDigit(state.path.charCodeAt(index))) {
593
+ index++;
594
+ hasDecimal = true;
595
+ }
596
+ ch = (index < max) ? state.path.charCodeAt(index) : 0;
597
+ }
598
+
599
+ if (ch === 0x65/* e */ || ch === 0x45/* E */) {
600
+ if (hasDot && !hasCeiling && !hasDecimal) {
601
+ state.err = 'SvgPath: invalid float exponent (at pos ' + index + ')';
602
+ return;
603
+ }
604
+
605
+ index++;
606
+
607
+ ch = (index < max) ? state.path.charCodeAt(index) : 0;
608
+ if (ch === 0x2B/* + */ || ch === 0x2D/* - */) {
609
+ index++;
610
+ }
611
+ if (index < max && isDigit(state.path.charCodeAt(index))) {
612
+ while (index < max && isDigit(state.path.charCodeAt(index))) {
613
+ index++;
614
+ }
615
+ } else {
616
+ state.err = 'SvgPath: invalid float exponent (at pos ' + index + ')';
617
+ return;
618
+ }
619
+ }
620
+
621
+ state.index = index;
622
+ state.param = parseFloat(state.path.slice(start, index)) + 0.0;
623
+ }
624
+
625
+
626
+ function finalizeSegment(state) {
627
+ var cmd, cmdLC;
628
+
629
+ // Process duplicated commands (without comand name)
630
+
631
+ // This logic is shamelessly borrowed from Raphael
632
+ // https://github.com/DmitryBaranovskiy/raphael/
633
+ //
634
+ cmd = state.path[state.segmentStart];
635
+ cmdLC = cmd.toLowerCase();
636
+
637
+ var params = state.data;
638
+
639
+ if (cmdLC === 'm' && params.length > 2) {
640
+ state.result.push([ cmd, params[0], params[1] ]);
641
+ params = params.slice(2);
642
+ cmdLC = 'l';
643
+ cmd = (cmd === 'm') ? 'l' : 'L';
644
+ }
645
+
646
+ if (cmdLC === 'r') {
647
+ state.result.push([ cmd ].concat(params));
648
+ } else {
649
+
650
+ while (params.length >= paramCounts[cmdLC]) {
651
+ state.result.push([ cmd ].concat(params.splice(0, paramCounts[cmdLC])));
652
+ if (!paramCounts[cmdLC]) {
653
+ break;
654
+ }
655
+ }
656
+ }
657
+ }
658
+
659
+
660
+ function scanSegment(state) {
661
+ var max = state.max,
662
+ cmdCode, comma_found, need_params, i;
663
+
664
+ state.segmentStart = state.index;
665
+ cmdCode = state.path.charCodeAt(state.index);
666
+
667
+ if (!isCommand(cmdCode)) {
668
+ state.err = 'SvgPath: bad command ' + state.path[state.index] + ' (at pos ' + state.index + ')';
669
+ return;
670
+ }
671
+
672
+ need_params = paramCounts[state.path[state.index].toLowerCase()];
673
+
674
+ state.index++;
675
+ skipSpaces(state);
676
+
677
+ state.data = [];
678
+
679
+ if (!need_params) {
680
+ // Z
681
+ finalizeSegment(state);
682
+ return;
683
+ }
684
+
685
+ comma_found = false;
686
+
687
+ for (;;) {
688
+ for (i = need_params; i > 0; i--) {
689
+ scanParam(state);
690
+ if (state.err.length) {
691
+ return;
692
+ }
693
+ state.data.push(state.param);
694
+
695
+ skipSpaces(state);
696
+ comma_found = false;
697
+
698
+ if (state.index < max && state.path.charCodeAt(state.index) === 0x2C/* , */) {
699
+ state.index++;
700
+ skipSpaces(state);
701
+ comma_found = true;
702
+ }
703
+ }
704
+
705
+ // after ',' param is mandatory
706
+ if (comma_found) {
707
+ continue;
708
+ }
709
+
710
+ if (state.index >= state.max) {
711
+ break;
712
+ }
713
+
714
+ // Stop on next segment
715
+ if (!isDigitStart(state.path.charCodeAt(state.index))) {
716
+ break;
717
+ }
718
+ }
719
+
720
+ finalizeSegment(state);
721
+ }
722
+
723
+
724
+ /* Returns array of segments:
725
+ *
726
+ * [
727
+ * [ command, coord1, coord2, ... ]
728
+ * ]
729
+ */
730
+ module.exports = function pathParse(svgPath) {
731
+ var state = new State(svgPath);
732
+ var max = state.max;
733
+
734
+ skipSpaces(state);
735
+
736
+ while (state.index < max && !state.err.length) {
737
+ scanSegment(state);
738
+ }
739
+
740
+ if (state.err.length) {
741
+ state.result = [];
742
+
743
+ } else if (state.result.length) {
744
+
745
+ if ('mM'.indexOf(state.result[0][0]) < 0) {
746
+ state.err = 'SvgPath: string should start with `M` or `m`';
747
+ state.result = [];
748
+ } else {
749
+ state.result[0][0] = 'M';
750
+ }
751
+ }
752
+
753
+ return {
754
+ err: state.err,
755
+ segments: state.result
756
+ };
757
+ };
758
+
759
+ },{}],6:[function(require,module,exports){
760
+ // SVG Path transformations library
761
+ //
762
+ // Usage:
763
+ //
764
+ // SvgPath('...')
765
+ // .translate(-150, -100)
766
+ // .scale(0.5)
767
+ // .translate(-150, -100)
768
+ // .toFixed(1)
769
+ // .toString()
770
+ //
771
+
772
+ 'use strict';
773
+
774
+
775
+ var pathParse = require('./path_parse');
776
+ var transformParse = require('./transform_parse');
777
+ var matrix = require('./matrix');
778
+ var a2c = require('./a2c');
779
+ var ellipse = require('./ellipse');
780
+
781
+
782
+ // Class constructor
783
+ //
784
+ function SvgPath(path) {
785
+ if (!(this instanceof SvgPath)) { return new SvgPath(path); }
786
+
787
+ var pstate = pathParse(path);
788
+
789
+ // Array of path segments.
790
+ // Each segment is array [command, param1, param2, ...]
791
+ this.segments = pstate.segments;
792
+
793
+ // Error message on parse error.
794
+ this.err = pstate.err;
795
+
796
+ // Transforms stack for lazy evaluation
797
+ this.__stack = [];
798
+ }
799
+
800
+
801
+ SvgPath.prototype.__matrix = function (m) {
802
+ var self = this, i;
803
+
804
+ // Quick leave for empty matrix
805
+ if (!m.queue.length) { return; }
806
+
807
+ this.iterate(function (s, index, x, y) {
808
+ var p, result, name, isRelative;
809
+
810
+ switch (s[0]) {
811
+
812
+ // Process 'assymetric' commands separately
813
+ case 'v':
814
+ p = m.calc(0, s[1], true);
815
+ result = (p[0] === 0) ? [ 'v', p[1] ] : [ 'l', p[0], p[1] ];
816
+ break;
817
+
818
+ case 'V':
819
+ p = m.calc(x, s[1], false);
820
+ result = (p[0] === m.calc(x, y, false)[0]) ? [ 'V', p[1] ] : [ 'L', p[0], p[1] ];
821
+ break;
822
+
823
+ case 'h':
824
+ p = m.calc(s[1], 0, true);
825
+ result = (p[1] === 0) ? [ 'h', p[0] ] : [ 'l', p[0], p[1] ];
826
+ break;
827
+
828
+ case 'H':
829
+ p = m.calc(s[1], y, false);
830
+ result = (p[1] === m.calc(x, y, false)[1]) ? [ 'H', p[0] ] : [ 'L', p[0], p[1] ];
831
+ break;
832
+
833
+ case 'a':
834
+ case 'A':
835
+ // ARC is: ['A', rx, ry, x-axis-rotation, large-arc-flag, sweep-flag, x, y]
836
+
837
+ // Drop segment if arc is empty (end point === start point)
838
+ /*if ((s[0] === 'A' && s[6] === x && s[7] === y) ||
839
+ (s[0] === 'a' && s[6] === 0 && s[7] === 0)) {
840
+ return [];
841
+ }*/
842
+
843
+ // Transform rx, ry and the x-axis-rotation
844
+ var ma = m.toArray();
845
+ var e = ellipse(s[1], s[2], s[3]).transform(ma);
846
+
847
+ // flip sweep-flag if matrix is not orientation-preserving
848
+ if (ma[0] * ma[3] - ma[1] * ma[2] < 0) {
849
+ s[5] = s[5] ? '0' : '1';
850
+ }
851
+
852
+ // Transform end point as usual (without translation for relative notation)
853
+ p = m.calc(s[6], s[7], s[0] === 'a');
854
+
855
+ // Empty arcs can be ignored by renderer, but should not be dropped
856
+ // to avoid collisions with `S A S` and so on. Replace with empty line.
857
+ if ((s[0] === 'A' && s[6] === x && s[7] === y) ||
858
+ (s[0] === 'a' && s[6] === 0 && s[7] === 0)) {
859
+ result = [ s[0] === 'a' ? 'l' : 'L', p[0], p[1] ];
860
+ break;
861
+ }
862
+
863
+ // if the resulting ellipse is (almost) a segment ...
864
+ if (e.isDegenerate()) {
865
+ // replace the arc by a line
866
+ result = [ s[0] === 'a' ? 'l' : 'L', p[0], p[1] ];
867
+ } else {
868
+ // if it is a real ellipse
869
+ // s[0], s[4] and s[5] are not modified
870
+ result = [ s[0], e.rx, e.ry, e.ax, s[4], s[5], p[0], p[1] ];
871
+ }
872
+
873
+ break;
874
+
875
+ case 'm':
876
+ // Edge case. The very first `m` should be processed as absolute, if happens.
877
+ // Make sense for coord shift transforms.
878
+ isRelative = index > 0;
879
+
880
+ p = m.calc(s[1], s[2], isRelative);
881
+ result = [ 'm', p[0], p[1] ];
882
+ break;
883
+
884
+ default:
885
+ name = s[0];
886
+ result = [ name ];
887
+ isRelative = (name.toLowerCase() === name);
888
+
889
+ // Apply transformations to the segment
890
+ for (i = 1; i < s.length; i += 2) {
891
+ p = m.calc(s[i], s[i + 1], isRelative);
892
+ result.push(p[0], p[1]);
893
+ }
894
+ }
895
+
896
+ self.segments[index] = result;
897
+ }, true);
898
+ };
899
+
900
+
901
+ // Apply stacked commands
902
+ //
903
+ SvgPath.prototype.__evaluateStack = function () {
904
+ var m, i;
905
+
906
+ if (!this.__stack.length) { return; }
907
+
908
+ if (this.__stack.length === 1) {
909
+ this.__matrix(this.__stack[0]);
910
+ this.__stack = [];
911
+ return;
912
+ }
913
+
914
+ m = matrix();
915
+ i = this.__stack.length;
916
+
917
+ while (--i >= 0) {
918
+ m.matrix(this.__stack[i].toArray());
919
+ }
920
+
921
+ this.__matrix(m);
922
+ this.__stack = [];
923
+ };
924
+
925
+
926
+ // Convert processed SVG Path back to string
927
+ //
928
+ SvgPath.prototype.toString = function () {
929
+ var elements = [], skipCmd, cmd;
930
+
931
+ this.__evaluateStack();
932
+
933
+ for (var i = 0; i < this.segments.length; i++) {
934
+ // remove repeating commands names
935
+ cmd = this.segments[i][0];
936
+ skipCmd = i > 0 && cmd !== 'm' && cmd !== 'M' && cmd === this.segments[i - 1][0];
937
+ elements = elements.concat(skipCmd ? this.segments[i].slice(1) : this.segments[i]);
938
+ }
939
+
940
+ return elements.join(' ')
941
+ // Optimizations: remove spaces around commands & before `-`
942
+ //
943
+ // We could also remove leading zeros for `0.5`-like values,
944
+ // but their count is too small to spend time for.
945
+ .replace(/ ?([achlmqrstvz]) ?/gi, '$1')
946
+ .replace(/ \-/g, '-')
947
+ // workaround for FontForge SVG importing bug
948
+ .replace(/zm/g, 'z m');
949
+ };
950
+
951
+
952
+ // Translate path to (x [, y])
953
+ //
954
+ SvgPath.prototype.translate = function (x, y) {
955
+ this.__stack.push(matrix().translate(x, y || 0));
956
+ return this;
957
+ };
958
+
959
+
960
+ // Scale path to (sx [, sy])
961
+ // sy = sx if not defined
962
+ //
963
+ SvgPath.prototype.scale = function (sx, sy) {
964
+ this.__stack.push(matrix().scale(sx, (!sy && (sy !== 0)) ? sx : sy));
965
+ return this;
966
+ };
967
+
968
+
969
+ // Rotate path around point (sx [, sy])
970
+ // sy = sx if not defined
971
+ //
972
+ SvgPath.prototype.rotate = function (angle, rx, ry) {
973
+ this.__stack.push(matrix().rotate(angle, rx || 0, ry || 0));
974
+ return this;
975
+ };
976
+
977
+
978
+ // Skew path along the X axis by `degrees` angle
979
+ //
980
+ SvgPath.prototype.skewX = function (degrees) {
981
+ this.__stack.push(matrix().skewX(degrees));
982
+ return this;
983
+ };
984
+
985
+
986
+ // Skew path along the Y axis by `degrees` angle
987
+ //
988
+ SvgPath.prototype.skewY = function (degrees) {
989
+ this.__stack.push(matrix().skewY(degrees));
990
+ return this;
991
+ };
992
+
993
+
994
+ // Apply matrix transform (array of 6 elements)
995
+ //
996
+ SvgPath.prototype.matrix = function (m) {
997
+ this.__stack.push(matrix().matrix(m));
998
+ return this;
999
+ };
1000
+
1001
+
1002
+ // Transform path according to "transform" attr of SVG spec
1003
+ //
1004
+ SvgPath.prototype.transform = function (transformString) {
1005
+ if (!transformString.trim()) {
1006
+ return this;
1007
+ }
1008
+ this.__stack.push(transformParse(transformString));
1009
+ return this;
1010
+ };
1011
+
1012
+
1013
+ // Round coords with given decimal precition.
1014
+ // 0 by default (to integers)
1015
+ //
1016
+ SvgPath.prototype.round = function (d) {
1017
+ var contourStartDeltaX = 0, contourStartDeltaY = 0, deltaX = 0, deltaY = 0, l;
1018
+
1019
+ d = d || 0;
1020
+
1021
+ this.__evaluateStack();
1022
+
1023
+ this.segments.forEach(function (s) {
1024
+ var isRelative = (s[0].toLowerCase() === s[0]);
1025
+
1026
+ switch (s[0]) {
1027
+ case 'H':
1028
+ case 'h':
1029
+ if (isRelative) { s[1] += deltaX; }
1030
+ deltaX = s[1] - s[1].toFixed(d);
1031
+ s[1] = +s[1].toFixed(d);
1032
+ return;
1033
+
1034
+ case 'V':
1035
+ case 'v':
1036
+ if (isRelative) { s[1] += deltaY; }
1037
+ deltaY = s[1] - s[1].toFixed(d);
1038
+ s[1] = +s[1].toFixed(d);
1039
+ return;
1040
+
1041
+ case 'Z':
1042
+ case 'z':
1043
+ deltaX = contourStartDeltaX;
1044
+ deltaY = contourStartDeltaY;
1045
+ return;
1046
+
1047
+ case 'M':
1048
+ case 'm':
1049
+ if (isRelative) {
1050
+ s[1] += deltaX;
1051
+ s[2] += deltaY;
1052
+ }
1053
+
1054
+ deltaX = s[1] - s[1].toFixed(d);
1055
+ deltaY = s[2] - s[2].toFixed(d);
1056
+
1057
+ contourStartDeltaX = deltaX;
1058
+ contourStartDeltaY = deltaY;
1059
+
1060
+ s[1] = +s[1].toFixed(d);
1061
+ s[2] = +s[2].toFixed(d);
1062
+ return;
1063
+
1064
+ case 'A':
1065
+ case 'a':
1066
+ // [cmd, rx, ry, x-axis-rotation, large-arc-flag, sweep-flag, x, y]
1067
+ if (isRelative) {
1068
+ s[6] += deltaX;
1069
+ s[7] += deltaY;
1070
+ }
1071
+
1072
+ deltaX = s[6] - s[6].toFixed(d);
1073
+ deltaY = s[7] - s[7].toFixed(d);
1074
+
1075
+ s[1] = +s[1].toFixed(d);
1076
+ s[2] = +s[2].toFixed(d);
1077
+ s[3] = +s[3].toFixed(d + 2); // better precision for rotation
1078
+ s[6] = +s[6].toFixed(d);
1079
+ s[7] = +s[7].toFixed(d);
1080
+ return;
1081
+
1082
+ default:
1083
+ // a c l q s t
1084
+ l = s.length;
1085
+
1086
+ if (isRelative) {
1087
+ s[l - 2] += deltaX;
1088
+ s[l - 1] += deltaY;
1089
+ }
1090
+
1091
+ deltaX = s[l - 2] - s[l - 2].toFixed(d);
1092
+ deltaY = s[l - 1] - s[l - 1].toFixed(d);
1093
+
1094
+ s.forEach(function (val, i) {
1095
+ if (!i) { return; }
1096
+ s[i] = +s[i].toFixed(d);
1097
+ });
1098
+ return;
1099
+ }
1100
+ });
1101
+
1102
+ return this;
1103
+ };
1104
+
1105
+
1106
+ // Apply iterator function to all segments. If function returns result,
1107
+ // current segment will be replaced to array of returned segments.
1108
+ // If empty array is returned, current regment will be deleted.
1109
+ //
1110
+ SvgPath.prototype.iterate = function (iterator, keepLazyStack) {
1111
+ var segments = this.segments,
1112
+ replacements = {},
1113
+ needReplace = false,
1114
+ lastX = 0,
1115
+ lastY = 0,
1116
+ countourStartX = 0,
1117
+ countourStartY = 0;
1118
+ var i, j, newSegments;
1119
+
1120
+ if (!keepLazyStack) {
1121
+ this.__evaluateStack();
1122
+ }
1123
+
1124
+ segments.forEach(function (s, index) {
1125
+
1126
+ var res = iterator(s, index, lastX, lastY);
1127
+
1128
+ if (Array.isArray(res)) {
1129
+ replacements[index] = res;
1130
+ needReplace = true;
1131
+ }
1132
+
1133
+ var isRelative = (s[0] === s[0].toLowerCase());
1134
+
1135
+ // calculate absolute X and Y
1136
+ switch (s[0]) {
1137
+ case 'm':
1138
+ case 'M':
1139
+ lastX = s[1] + (isRelative ? lastX : 0);
1140
+ lastY = s[2] + (isRelative ? lastY : 0);
1141
+ countourStartX = lastX;
1142
+ countourStartY = lastY;
1143
+ return;
1144
+
1145
+ case 'h':
1146
+ case 'H':
1147
+ lastX = s[1] + (isRelative ? lastX : 0);
1148
+ return;
1149
+
1150
+ case 'v':
1151
+ case 'V':
1152
+ lastY = s[1] + (isRelative ? lastY : 0);
1153
+ return;
1154
+
1155
+ case 'z':
1156
+ case 'Z':
1157
+ // That make sence for multiple contours
1158
+ lastX = countourStartX;
1159
+ lastY = countourStartY;
1160
+ return;
1161
+
1162
+ default:
1163
+ lastX = s[s.length - 2] + (isRelative ? lastX : 0);
1164
+ lastY = s[s.length - 1] + (isRelative ? lastY : 0);
1165
+ }
1166
+ });
1167
+
1168
+ // Replace segments if iterator return results
1169
+
1170
+ if (!needReplace) { return this; }
1171
+
1172
+ newSegments = [];
1173
+
1174
+ for (i = 0; i < segments.length; i++) {
1175
+ if (typeof replacements[i] !== 'undefined') {
1176
+ for (j = 0; j < replacements[i].length; j++) {
1177
+ newSegments.push(replacements[i][j]);
1178
+ }
1179
+ } else {
1180
+ newSegments.push(segments[i]);
1181
+ }
1182
+ }
1183
+
1184
+ this.segments = newSegments;
1185
+
1186
+ return this;
1187
+ };
1188
+
1189
+
1190
+ // Converts segments from relative to absolute
1191
+ //
1192
+ SvgPath.prototype.abs = function () {
1193
+
1194
+ this.iterate(function (s, index, x, y) {
1195
+ var name = s[0],
1196
+ nameUC = name.toUpperCase(),
1197
+ i;
1198
+
1199
+ // Skip absolute commands
1200
+ if (name === nameUC) { return; }
1201
+
1202
+ s[0] = nameUC;
1203
+
1204
+ switch (name) {
1205
+ case 'v':
1206
+ // v has shifted coords parity
1207
+ s[1] += y;
1208
+ return;
1209
+
1210
+ case 'a':
1211
+ // ARC is: ['A', rx, ry, x-axis-rotation, large-arc-flag, sweep-flag, x, y]
1212
+ // touch x, y only
1213
+ s[6] += x;
1214
+ s[7] += y;
1215
+ return;
1216
+
1217
+ default:
1218
+ for (i = 1; i < s.length; i++) {
1219
+ s[i] += i % 2 ? x : y; // odd values are X, even - Y
1220
+ }
1221
+ }
1222
+ }, true);
1223
+
1224
+ return this;
1225
+ };
1226
+
1227
+
1228
+ // Converts segments from absolute to relative
1229
+ //
1230
+ SvgPath.prototype.rel = function () {
1231
+
1232
+ this.iterate(function (s, index, x, y) {
1233
+ var name = s[0],
1234
+ nameLC = name.toLowerCase(),
1235
+ i;
1236
+
1237
+ // Skip relative commands
1238
+ if (name === nameLC) { return; }
1239
+
1240
+ // Don't touch the first M to avoid potential confusions.
1241
+ if (index === 0 && name === 'M') { return; }
1242
+
1243
+ s[0] = nameLC;
1244
+
1245
+ switch (name) {
1246
+ case 'V':
1247
+ // V has shifted coords parity
1248
+ s[1] -= y;
1249
+ return;
1250
+
1251
+ case 'A':
1252
+ // ARC is: ['A', rx, ry, x-axis-rotation, large-arc-flag, sweep-flag, x, y]
1253
+ // touch x, y only
1254
+ s[6] -= x;
1255
+ s[7] -= y;
1256
+ return;
1257
+
1258
+ default:
1259
+ for (i = 1; i < s.length; i++) {
1260
+ s[i] -= i % 2 ? x : y; // odd values are X, even - Y
1261
+ }
1262
+ }
1263
+ }, true);
1264
+
1265
+ return this;
1266
+ };
1267
+
1268
+
1269
+ // Converts arcs to cubic bézier curves
1270
+ //
1271
+ SvgPath.prototype.unarc = function () {
1272
+ this.iterate(function (s, index, x, y) {
1273
+ var new_segments, nextX, nextY, result = [], name = s[0];
1274
+
1275
+ // Skip anything except arcs
1276
+ if (name !== 'A' && name !== 'a') { return null; }
1277
+
1278
+ if (name === 'a') {
1279
+ // convert relative arc coordinates to absolute
1280
+ nextX = x + s[6];
1281
+ nextY = y + s[7];
1282
+ } else {
1283
+ nextX = s[6];
1284
+ nextY = s[7];
1285
+ }
1286
+
1287
+ new_segments = a2c(x, y, nextX, nextY, s[4], s[5], s[1], s[2], s[3]);
1288
+
1289
+ // Degenerated arcs can be ignored by renderer, but should not be dropped
1290
+ // to avoid collisions with `S A S` and so on. Replace with empty line.
1291
+ if (new_segments.length === 0) {
1292
+ return [ [ s[0] === 'a' ? 'l' : 'L', s[6], s[7] ] ];
1293
+ }
1294
+
1295
+ new_segments.forEach(function (s) {
1296
+ result.push([ 'C', s[2], s[3], s[4], s[5], s[6], s[7] ]);
1297
+ });
1298
+
1299
+ return result;
1300
+ });
1301
+
1302
+ return this;
1303
+ };
1304
+
1305
+
1306
+ // Converts smooth curves (with missed control point) to generic curves
1307
+ //
1308
+ SvgPath.prototype.unshort = function () {
1309
+ var segments = this.segments;
1310
+ var prevControlX, prevControlY, prevSegment;
1311
+ var curControlX, curControlY;
1312
+
1313
+ // TODO: add lazy evaluation flag when relative commands supported
1314
+
1315
+ this.iterate(function (s, idx, x, y) {
1316
+ var name = s[0], nameUC = name.toUpperCase(), isRelative;
1317
+
1318
+ // First command MUST be M|m, it's safe to skip.
1319
+ // Protect from access to [-1] for sure.
1320
+ if (!idx) { return; }
1321
+
1322
+ if (nameUC === 'T') { // quadratic curve
1323
+ isRelative = (name === 't');
1324
+
1325
+ prevSegment = segments[idx - 1];
1326
+
1327
+ if (prevSegment[0] === 'Q') {
1328
+ prevControlX = prevSegment[1] - x;
1329
+ prevControlY = prevSegment[2] - y;
1330
+ } else if (prevSegment[0] === 'q') {
1331
+ prevControlX = prevSegment[1] - prevSegment[3];
1332
+ prevControlY = prevSegment[2] - prevSegment[4];
1333
+ } else {
1334
+ prevControlX = 0;
1335
+ prevControlY = 0;
1336
+ }
1337
+
1338
+ curControlX = -prevControlX;
1339
+ curControlY = -prevControlY;
1340
+
1341
+ if (!isRelative) {
1342
+ curControlX += x;
1343
+ curControlY += y;
1344
+ }
1345
+
1346
+ segments[idx] = [
1347
+ isRelative ? 'q' : 'Q',
1348
+ curControlX, curControlY,
1349
+ s[1], s[2]
1350
+ ];
1351
+
1352
+ } else if (nameUC === 'S') { // cubic curve
1353
+ isRelative = (name === 's');
1354
+
1355
+ prevSegment = segments[idx - 1];
1356
+
1357
+ if (prevSegment[0] === 'C') {
1358
+ prevControlX = prevSegment[3] - x;
1359
+ prevControlY = prevSegment[4] - y;
1360
+ } else if (prevSegment[0] === 'c') {
1361
+ prevControlX = prevSegment[3] - prevSegment[5];
1362
+ prevControlY = prevSegment[4] - prevSegment[6];
1363
+ } else {
1364
+ prevControlX = 0;
1365
+ prevControlY = 0;
1366
+ }
1367
+
1368
+ curControlX = -prevControlX;
1369
+ curControlY = -prevControlY;
1370
+
1371
+ if (!isRelative) {
1372
+ curControlX += x;
1373
+ curControlY += y;
1374
+ }
1375
+
1376
+ segments[idx] = [
1377
+ isRelative ? 'c' : 'C',
1378
+ curControlX, curControlY,
1379
+ s[1], s[2], s[3], s[4]
1380
+ ];
1381
+ }
1382
+ });
1383
+
1384
+ return this;
1385
+ };
1386
+
1387
+
1388
+ module.exports = SvgPath;
1389
+
1390
+ },{"./a2c":2,"./ellipse":3,"./matrix":4,"./path_parse":5,"./transform_parse":7}],7:[function(require,module,exports){
1391
+ 'use strict';
1392
+
1393
+
1394
+ var Matrix = require('./matrix');
1395
+
1396
+ var operations = {
1397
+ matrix: true,
1398
+ scale: true,
1399
+ rotate: true,
1400
+ translate: true,
1401
+ skewX: true,
1402
+ skewY: true
1403
+ };
1404
+
1405
+ var CMD_SPLIT_RE = /\s*(matrix|translate|scale|rotate|skewX|skewY)\s*\(\s*(.+?)\s*\)[\s,]*/;
1406
+ var PARAMS_SPLIT_RE = /[\s,]+/;
1407
+
1408
+
1409
+ module.exports = function transformParse(transformString) {
1410
+ var matrix = new Matrix();
1411
+ var cmd, params;
1412
+
1413
+ // Split value into ['', 'translate', '10 50', '', 'scale', '2', '', 'rotate', '-45', '']
1414
+ transformString.split(CMD_SPLIT_RE).forEach(function (item) {
1415
+
1416
+ // Skip empty elements
1417
+ if (!item.length) { return; }
1418
+
1419
+ // remember operation
1420
+ if (typeof operations[item] !== 'undefined') {
1421
+ cmd = item;
1422
+ return;
1423
+ }
1424
+
1425
+ // extract params & att operation to matrix
1426
+ params = item.split(PARAMS_SPLIT_RE).map(function (i) {
1427
+ return +i || 0;
1428
+ });
1429
+
1430
+ // If params count is not correct - ignore command
1431
+ switch (cmd) {
1432
+ case 'matrix':
1433
+ if (params.length === 6) {
1434
+ matrix.matrix(params);
1435
+ }
1436
+ return;
1437
+
1438
+ case 'scale':
1439
+ if (params.length === 1) {
1440
+ matrix.scale(params[0], params[0]);
1441
+ } else if (params.length === 2) {
1442
+ matrix.scale(params[0], params[1]);
1443
+ }
1444
+ return;
1445
+
1446
+ case 'rotate':
1447
+ if (params.length === 1) {
1448
+ matrix.rotate(params[0], 0, 0);
1449
+ } else if (params.length === 3) {
1450
+ matrix.rotate(params[0], params[1], params[2]);
1451
+ }
1452
+ return;
1453
+
1454
+ case 'translate':
1455
+ if (params.length === 1) {
1456
+ matrix.translate(params[0], 0);
1457
+ } else if (params.length === 2) {
1458
+ matrix.translate(params[0], params[1]);
1459
+ }
1460
+ return;
1461
+
1462
+ case 'skewX':
1463
+ if (params.length === 1) {
1464
+ matrix.skewX(params[0]);
1465
+ }
1466
+ return;
1467
+
1468
+ case 'skewY':
1469
+ if (params.length === 1) {
1470
+ matrix.skewY(params[0]);
1471
+ }
1472
+ return;
1473
+ }
1474
+ });
1475
+
1476
+ return matrix;
1477
+ };
1478
+
1479
+ },{"./matrix":4}],8:[function(require,module,exports){
1480
+ /*! https://mths.be/cssesc v1.0.1 by @mathias */
1481
+ 'use strict';
1482
+
1483
+ var object = {};
1484
+ var hasOwnProperty = object.hasOwnProperty;
1485
+ var merge = function merge(options, defaults) {
1486
+ if (!options) {
1487
+ return defaults;
1488
+ }
1489
+ var result = {};
1490
+ for (var key in defaults) {
1491
+ // `if (defaults.hasOwnProperty(key) { … }` is not needed here, since
1492
+ // only recognized option names are used.
1493
+ result[key] = hasOwnProperty.call(options, key) ? options[key] : defaults[key];
1494
+ }
1495
+ return result;
1496
+ };
1497
+
1498
+ var regexAnySingleEscape = /[ -,\.\/;-@\[-\^`\{-~]/;
1499
+ var regexSingleEscape = /[ -,\.\/;-@\[\]\^`\{-~]/;
1500
+ var regexAlwaysEscape = /['"\\]/;
1501
+ var regexExcessiveSpaces = /(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g;
1502
+
1503
+ // https://mathiasbynens.be/notes/css-escapes#css
1504
+ var cssesc = function cssesc(string, options) {
1505
+ options = merge(options, cssesc.options);
1506
+ if (options.quotes != 'single' && options.quotes != 'double') {
1507
+ options.quotes = 'single';
1508
+ }
1509
+ var quote = options.quotes == 'double' ? '"' : '\'';
1510
+ var isIdentifier = options.isIdentifier;
1511
+
1512
+ var firstChar = string.charAt(0);
1513
+ var output = '';
1514
+ var counter = 0;
1515
+ var length = string.length;
1516
+ while (counter < length) {
1517
+ var character = string.charAt(counter++);
1518
+ var codePoint = character.charCodeAt();
1519
+ var value = void 0;
1520
+ // If it’s not a printable ASCII character…
1521
+ if (codePoint < 0x20 || codePoint > 0x7E) {
1522
+ if (codePoint >= 0xD800 && codePoint <= 0xDBFF && counter < length) {
1523
+ // It’s a high surrogate, and there is a next character.
1524
+ var extra = string.charCodeAt(counter++);
1525
+ if ((extra & 0xFC00) == 0xDC00) {
1526
+ // next character is low surrogate
1527
+ codePoint = ((codePoint & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000;
1528
+ } else {
1529
+ // It’s an unmatched surrogate; only append this code unit, in case
1530
+ // the next code unit is the high surrogate of a surrogate pair.
1531
+ counter--;
1532
+ }
1533
+ }
1534
+ value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
1535
+ } else {
1536
+ if (options.escapeEverything) {
1537
+ if (regexAnySingleEscape.test(character)) {
1538
+ value = '\\' + character;
1539
+ } else {
1540
+ value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
1541
+ }
1542
+ // Note: `:` could be escaped as `\:`, but that fails in IE < 8.
1543
+ } else if (/[\t\n\f\r\x0B:]/.test(character)) {
1544
+ if (!isIdentifier && character == ':') {
1545
+ value = character;
1546
+ } else {
1547
+ value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
1548
+ }
1549
+ } else if (character == '\\' || !isIdentifier && (character == '"' && quote == character || character == '\'' && quote == character) || isIdentifier && regexSingleEscape.test(character)) {
1550
+ value = '\\' + character;
1551
+ } else {
1552
+ value = character;
1553
+ }
1554
+ }
1555
+ output += value;
1556
+ }
1557
+
1558
+ if (isIdentifier) {
1559
+ if (/^_/.test(output)) {
1560
+ // Prevent IE6 from ignoring the rule altogether (in case this is for an
1561
+ // identifier used as a selector)
1562
+ output = '\\_' + output.slice(1);
1563
+ } else if (/^-[-\d]/.test(output)) {
1564
+ output = '\\-' + output.slice(1);
1565
+ } else if (/\d/.test(firstChar)) {
1566
+ output = '\\3' + firstChar + ' ' + output.slice(1);
1567
+ }
1568
+ }
1569
+
1570
+ // Remove spaces after `\HEX` escapes that are not followed by a hex digit,
1571
+ // since they’re redundant. Note that this is only possible if the escape
1572
+ // sequence isn’t preceded by an odd number of backslashes.
1573
+ output = output.replace(regexExcessiveSpaces, function ($0, $1, $2) {
1574
+ if ($1 && $1.length % 2) {
1575
+ // It’s not safe to remove the space, so don’t.
1576
+ return $0;
1577
+ }
1578
+ // Strip the space.
1579
+ return ($1 || '') + $2;
1580
+ });
1581
+
1582
+ if (!isIdentifier && options.wrap) {
1583
+ return quote + output + quote;
1584
+ }
1585
+ return output;
1586
+ };
1587
+
1588
+ // Expose default options (so they can be overridden globally).
1589
+ cssesc.options = {
1590
+ 'escapeEverything': false,
1591
+ 'isIdentifier': false,
1592
+ 'quotes': 'single',
1593
+ 'wrap': false
1594
+ };
1595
+
1596
+ cssesc.version = '1.0.1';
1597
+
1598
+ module.exports = cssesc;
1599
+
1600
+ },{}],9:[function(require,module,exports){
1601
+ // parse
1602
+ // =====
1603
+
1604
+ // states
1605
+ // ------
1606
+
1607
+ var PLAIN = 0;
1608
+ var STRINGS = 1;
1609
+ var ESCAPING = 2;
1610
+ var IDENTIFIER = 3;
1611
+ var SEPARATING = 4;
1612
+
1613
+ // patterns
1614
+ // --------
1615
+
1616
+ var identifierPattern = /[a-z0-9_-]/i;
1617
+ var spacePattern = /[\s\t]/;
1618
+
1619
+ // ---
1620
+
1621
+ var parse = function(str) {
1622
+
1623
+ // vars
1624
+ // ----
1625
+
1626
+ var starting = true;
1627
+ var state = PLAIN;
1628
+ var buffer = '';
1629
+ var i = 0;
1630
+ var quote;
1631
+ var c;
1632
+
1633
+ // result
1634
+ // ------
1635
+
1636
+ var names = [];
1637
+
1638
+ // parse
1639
+ // -----
1640
+
1641
+ while (true) {
1642
+
1643
+ c = str[i];
1644
+
1645
+ if (state === PLAIN) {
1646
+
1647
+ if (!c && starting) {
1648
+
1649
+ break;
1650
+
1651
+ } else if (!c && !starting) {
1652
+
1653
+ throw new Error('Parse error');
1654
+
1655
+ } else if (c === '"' || c === "'") {
1656
+
1657
+ quote = c;
1658
+ state = STRINGS;
1659
+ starting = false;
1660
+
1661
+ } else if (spacePattern.test(c)) {
1662
+ } else if (identifierPattern.test(c)) {
1663
+
1664
+ state = IDENTIFIER;
1665
+ starting = false;
1666
+ i--;
1667
+
1668
+ } else {
1669
+
1670
+ throw new Error('Parse error');
1671
+
1672
+ }
1673
+
1674
+ } else if (state === STRINGS) {
1675
+
1676
+ if (!c) {
1677
+
1678
+ throw new Error('Parse Error');
1679
+
1680
+ } else if (c === "\\") {
1681
+
1682
+ state = ESCAPING;
1683
+
1684
+ } else if (c === quote) {
1685
+
1686
+ names.push(buffer);
1687
+ buffer = '';
1688
+ state = SEPARATING;
1689
+
1690
+ } else {
1691
+
1692
+ buffer += c;
1693
+
1694
+ }
1695
+
1696
+ } else if (state === ESCAPING) {
1697
+
1698
+ if (c === quote || c === "\\") {
1699
+
1700
+ buffer += c;
1701
+ state = STRINGS;
1702
+
1703
+ } else {
1704
+
1705
+ throw new Error('Parse error');
1706
+
1707
+ }
1708
+
1709
+ } else if (state === IDENTIFIER) {
1710
+
1711
+ if (!c) {
1712
+
1713
+ names.push(buffer);
1714
+ break;
1715
+
1716
+ } else if (identifierPattern.test(c)) {
1717
+
1718
+ buffer += c;
1719
+
1720
+ } else if (c === ',') {
1721
+
1722
+ names.push(buffer);
1723
+ buffer = '';
1724
+ state = PLAIN;
1725
+
1726
+ } else if (spacePattern.test(c)) {
1727
+
1728
+ names.push(buffer);
1729
+ buffer = '';
1730
+ state = SEPARATING;
1731
+
1732
+ } else {
1733
+
1734
+ throw new Error('Parse error');
1735
+
1736
+ }
1737
+
1738
+ } else if (state === SEPARATING) {
1739
+
1740
+ if (!c) {
1741
+
1742
+ break;
1743
+
1744
+ } else if (c === ',') {
1745
+
1746
+ state = PLAIN;
1747
+
1748
+ } else if (spacePattern.test(c)) {
1749
+ } else {
1750
+
1751
+ throw new Error('Parse error');
1752
+
1753
+ }
1754
+
1755
+ }
1756
+
1757
+ i++;
1758
+
1759
+ }
1760
+
1761
+ // result
1762
+ // ------
1763
+
1764
+ return names;
1765
+
1766
+ };
1767
+
1768
+ // stringify
1769
+ // =========
1770
+
1771
+ // pattern
1772
+ // -------
1773
+
1774
+ var stringsPattern = /[^a-z0-9_-]/i;
1775
+
1776
+ // ---
1777
+
1778
+ var stringify = function(names, options) {
1779
+
1780
+ // quote
1781
+ // -----
1782
+
1783
+ var quote = options && options.quote || '"';
1784
+ if (quote !== '"' && quote !== "'") {
1785
+ throw new Error('Quote must be `\'` or `"`');
1786
+ }
1787
+ var quotePattern = new RegExp(quote, 'g');
1788
+
1789
+ // stringify
1790
+ // ---------
1791
+
1792
+ var safeNames = [];
1793
+
1794
+ for (var i = 0; i < names.length; ++i) {
1795
+ var name = names[i];
1796
+
1797
+ if (stringsPattern.test(name)) {
1798
+ name = name
1799
+ .replace(/\\/g, "\\\\")
1800
+ .replace(quotePattern, "\\" + quote);
1801
+ name = quote + name + quote;
1802
+ }
1803
+ safeNames.push(name);
1804
+ }
1805
+
1806
+ // result
1807
+ // ------
1808
+
1809
+ return safeNames.join(', ');
1810
+ };
1811
+
1812
+ // export
1813
+ // ======
1814
+
1815
+ module.exports = {
1816
+ parse: parse,
1817
+ stringify: stringify,
1818
+ };
1819
+
1820
+ },{}],10:[function(require,module,exports){
1821
+ /**
1822
+ * A class to parse color values
1823
+ * @author Stoyan Stefanov <sstoo@gmail.com>
1824
+ * @link http://www.phpied.com/rgb-color-parser-in-javascript/
1825
+ * @license Use it if you like it
1826
+ */
1827
+ (function (global) {
1828
+ function RGBColor(color_string)
1829
+ {
1830
+ this.ok = false;
1831
+
1832
+ // strip any leading #
1833
+ if (color_string.charAt(0) == '#') { // remove # if any
1834
+ color_string = color_string.substr(1,6);
1835
+ }
1836
+
1837
+ color_string = color_string.replace(/ /g,'');
1838
+ color_string = color_string.toLowerCase();
1839
+
1840
+ // before getting into regexps, try simple matches
1841
+ // and overwrite the input
1842
+ var simple_colors = {
1843
+ aliceblue: 'f0f8ff',
1844
+ antiquewhite: 'faebd7',
1845
+ aqua: '00ffff',
1846
+ aquamarine: '7fffd4',
1847
+ azure: 'f0ffff',
1848
+ beige: 'f5f5dc',
1849
+ bisque: 'ffe4c4',
1850
+ black: '000000',
1851
+ blanchedalmond: 'ffebcd',
1852
+ blue: '0000ff',
1853
+ blueviolet: '8a2be2',
1854
+ brown: 'a52a2a',
1855
+ burlywood: 'deb887',
1856
+ cadetblue: '5f9ea0',
1857
+ chartreuse: '7fff00',
1858
+ chocolate: 'd2691e',
1859
+ coral: 'ff7f50',
1860
+ cornflowerblue: '6495ed',
1861
+ cornsilk: 'fff8dc',
1862
+ crimson: 'dc143c',
1863
+ cyan: '00ffff',
1864
+ darkblue: '00008b',
1865
+ darkcyan: '008b8b',
1866
+ darkgoldenrod: 'b8860b',
1867
+ darkgray: 'a9a9a9',
1868
+ darkgreen: '006400',
1869
+ darkkhaki: 'bdb76b',
1870
+ darkmagenta: '8b008b',
1871
+ darkolivegreen: '556b2f',
1872
+ darkorange: 'ff8c00',
1873
+ darkorchid: '9932cc',
1874
+ darkred: '8b0000',
1875
+ darksalmon: 'e9967a',
1876
+ darkseagreen: '8fbc8f',
1877
+ darkslateblue: '483d8b',
1878
+ darkslategray: '2f4f4f',
1879
+ darkturquoise: '00ced1',
1880
+ darkviolet: '9400d3',
1881
+ deeppink: 'ff1493',
1882
+ deepskyblue: '00bfff',
1883
+ dimgray: '696969',
1884
+ dodgerblue: '1e90ff',
1885
+ feldspar: 'd19275',
1886
+ firebrick: 'b22222',
1887
+ floralwhite: 'fffaf0',
1888
+ forestgreen: '228b22',
1889
+ fuchsia: 'ff00ff',
1890
+ gainsboro: 'dcdcdc',
1891
+ ghostwhite: 'f8f8ff',
1892
+ gold: 'ffd700',
1893
+ goldenrod: 'daa520',
1894
+ gray: '808080',
1895
+ green: '008000',
1896
+ greenyellow: 'adff2f',
1897
+ honeydew: 'f0fff0',
1898
+ hotpink: 'ff69b4',
1899
+ indianred : 'cd5c5c',
1900
+ indigo : '4b0082',
1901
+ ivory: 'fffff0',
1902
+ khaki: 'f0e68c',
1903
+ lavender: 'e6e6fa',
1904
+ lavenderblush: 'fff0f5',
1905
+ lawngreen: '7cfc00',
1906
+ lemonchiffon: 'fffacd',
1907
+ lightblue: 'add8e6',
1908
+ lightcoral: 'f08080',
1909
+ lightcyan: 'e0ffff',
1910
+ lightgoldenrodyellow: 'fafad2',
1911
+ lightgrey: 'd3d3d3',
1912
+ lightgreen: '90ee90',
1913
+ lightpink: 'ffb6c1',
1914
+ lightsalmon: 'ffa07a',
1915
+ lightseagreen: '20b2aa',
1916
+ lightskyblue: '87cefa',
1917
+ lightslateblue: '8470ff',
1918
+ lightslategray: '778899',
1919
+ lightsteelblue: 'b0c4de',
1920
+ lightyellow: 'ffffe0',
1921
+ lime: '00ff00',
1922
+ limegreen: '32cd32',
1923
+ linen: 'faf0e6',
1924
+ magenta: 'ff00ff',
1925
+ maroon: '800000',
1926
+ mediumaquamarine: '66cdaa',
1927
+ mediumblue: '0000cd',
1928
+ mediumorchid: 'ba55d3',
1929
+ mediumpurple: '9370d8',
1930
+ mediumseagreen: '3cb371',
1931
+ mediumslateblue: '7b68ee',
1932
+ mediumspringgreen: '00fa9a',
1933
+ mediumturquoise: '48d1cc',
1934
+ mediumvioletred: 'c71585',
1935
+ midnightblue: '191970',
1936
+ mintcream: 'f5fffa',
1937
+ mistyrose: 'ffe4e1',
1938
+ moccasin: 'ffe4b5',
1939
+ navajowhite: 'ffdead',
1940
+ navy: '000080',
1941
+ oldlace: 'fdf5e6',
1942
+ olive: '808000',
1943
+ olivedrab: '6b8e23',
1944
+ orange: 'ffa500',
1945
+ orangered: 'ff4500',
1946
+ orchid: 'da70d6',
1947
+ palegoldenrod: 'eee8aa',
1948
+ palegreen: '98fb98',
1949
+ paleturquoise: 'afeeee',
1950
+ palevioletred: 'd87093',
1951
+ papayawhip: 'ffefd5',
1952
+ peachpuff: 'ffdab9',
1953
+ peru: 'cd853f',
1954
+ pink: 'ffc0cb',
1955
+ plum: 'dda0dd',
1956
+ powderblue: 'b0e0e6',
1957
+ purple: '800080',
1958
+ red: 'ff0000',
1959
+ rosybrown: 'bc8f8f',
1960
+ royalblue: '4169e1',
1961
+ saddlebrown: '8b4513',
1962
+ salmon: 'fa8072',
1963
+ sandybrown: 'f4a460',
1964
+ seagreen: '2e8b57',
1965
+ seashell: 'fff5ee',
1966
+ sienna: 'a0522d',
1967
+ silver: 'c0c0c0',
1968
+ skyblue: '87ceeb',
1969
+ slateblue: '6a5acd',
1970
+ slategray: '708090',
1971
+ snow: 'fffafa',
1972
+ springgreen: '00ff7f',
1973
+ steelblue: '4682b4',
1974
+ tan: 'd2b48c',
1975
+ teal: '008080',
1976
+ thistle: 'd8bfd8',
1977
+ tomato: 'ff6347',
1978
+ turquoise: '40e0d0',
1979
+ violet: 'ee82ee',
1980
+ violetred: 'd02090',
1981
+ wheat: 'f5deb3',
1982
+ white: 'ffffff',
1983
+ whitesmoke: 'f5f5f5',
1984
+ yellow: 'ffff00',
1985
+ yellowgreen: '9acd32'
1986
+ };
1987
+ for (var key in simple_colors) {
1988
+ if (color_string == key) {
1989
+ color_string = simple_colors[key];
1990
+ }
1991
+ }
1992
+ // emd of simple type-in colors
1993
+
1994
+ // array of color definition objects
1995
+ var color_defs = [
1996
+ {
1997
+ re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,
1998
+ example: ['rgb(123, 234, 45)', 'rgb(255,234,245)'],
1999
+ process: function (bits){
2000
+ return [
2001
+ parseInt(bits[1]),
2002
+ parseInt(bits[2]),
2003
+ parseInt(bits[3])
2004
+ ];
2005
+ }
2006
+ },
2007
+ {
2008
+ re: /^(\w{2})(\w{2})(\w{2})$/,
2009
+ example: ['#00ff00', '336699'],
2010
+ process: function (bits){
2011
+ return [
2012
+ parseInt(bits[1], 16),
2013
+ parseInt(bits[2], 16),
2014
+ parseInt(bits[3], 16)
2015
+ ];
2016
+ }
2017
+ },
2018
+ {
2019
+ re: /^(\w{1})(\w{1})(\w{1})$/,
2020
+ example: ['#fb0', 'f0f'],
2021
+ process: function (bits){
2022
+ return [
2023
+ parseInt(bits[1] + bits[1], 16),
2024
+ parseInt(bits[2] + bits[2], 16),
2025
+ parseInt(bits[3] + bits[3], 16)
2026
+ ];
2027
+ }
2028
+ }
2029
+ ];
2030
+
2031
+ // search through the definitions to find a match
2032
+ for (var i = 0; i < color_defs.length; i++) {
2033
+ var re = color_defs[i].re;
2034
+ var processor = color_defs[i].process;
2035
+ var bits = re.exec(color_string);
2036
+ if (bits) {
2037
+ var channels = processor(bits);
2038
+ this.r = channels[0];
2039
+ this.g = channels[1];
2040
+ this.b = channels[2];
2041
+ this.ok = true;
2042
+ }
2043
+
2044
+ }
2045
+
2046
+ // validate/cleanup values
2047
+ this.r = (this.r < 0 || isNaN(this.r)) ? 0 : ((this.r > 255) ? 255 : this.r);
2048
+ this.g = (this.g < 0 || isNaN(this.g)) ? 0 : ((this.g > 255) ? 255 : this.g);
2049
+ this.b = (this.b < 0 || isNaN(this.b)) ? 0 : ((this.b > 255) ? 255 : this.b);
2050
+
2051
+ // some getters
2052
+ this.toRGB = function () {
2053
+ return 'rgb(' + this.r + ', ' + this.g + ', ' + this.b + ')';
2054
+ }
2055
+ this.toHex = function () {
2056
+ var r = this.r.toString(16);
2057
+ var g = this.g.toString(16);
2058
+ var b = this.b.toString(16);
2059
+ if (r.length == 1) r = '0' + r;
2060
+ if (g.length == 1) g = '0' + g;
2061
+ if (b.length == 1) b = '0' + b;
2062
+ return '#' + r + g + b;
2063
+ }
2064
+
2065
+ // help
2066
+ this.getHelpXML = function () {
2067
+
2068
+ var examples = new Array();
2069
+ // add regexps
2070
+ for (var i = 0; i < color_defs.length; i++) {
2071
+ var example = color_defs[i].example;
2072
+ for (var j = 0; j < example.length; j++) {
2073
+ examples[examples.length] = example[j];
2074
+ }
2075
+ }
2076
+ // add type-in colors
2077
+ for (var sc in simple_colors) {
2078
+ examples[examples.length] = sc;
2079
+ }
2080
+
2081
+ var xml = document.createElement('ul');
2082
+ xml.setAttribute('id', 'rgbcolor-examples');
2083
+ for (var i = 0; i < examples.length; i++) {
2084
+ try {
2085
+ var list_item = document.createElement('li');
2086
+ var list_color = new RGBColor(examples[i]);
2087
+ var example_div = document.createElement('div');
2088
+ example_div.style.cssText =
2089
+ 'margin: 3px; '
2090
+ + 'border: 1px solid black; '
2091
+ + 'background:' + list_color.toHex() + '; '
2092
+ + 'color:' + list_color.toHex()
2093
+ ;
2094
+ example_div.appendChild(document.createTextNode('test'));
2095
+ var list_item_value = document.createTextNode(
2096
+ ' ' + examples[i] + ' -> ' + list_color.toRGB() + ' -> ' + list_color.toHex()
2097
+ );
2098
+ list_item.appendChild(example_div);
2099
+ list_item.appendChild(list_item_value);
2100
+ xml.appendChild(list_item);
2101
+
2102
+ } catch(e){}
2103
+ }
2104
+ return xml;
2105
+
2106
+ }
2107
+
2108
+ }
2109
+ if (typeof define === "function" && define.amd) {
2110
+ define(function () {
2111
+ return RGBColor;
2112
+ });
2113
+ } else if (typeof module !== "undefined" && module.exports) {
2114
+ module.exports = RGBColor;
2115
+ } else {
2116
+ global.RGBColor = RGBColor;
2117
+ }
2118
+ return RGBColor;
2119
+ })(typeof self !== "undefined" && self || typeof window !== "undefined" && window || this);
2120
+
2121
+ },{}],11:[function(require,module,exports){
2122
+ /*
2123
+ The MIT License (MIT)
2124
+
2125
+ Copyright (c) 2015-2017 yWorks GmbH
2126
+
2127
+ Permission is hereby granted, free of charge, to any person obtaining a copy
2128
+ of this software and associated documentation files (the "Software"), to deal
2129
+ in the Software without restriction, including without limitation the rights
2130
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2131
+ copies of the Software, and to permit persons to whom the Software is
2132
+ furnished to do so, subject to the following conditions:
2133
+
2134
+ The above copyright notice and this permission notice shall be included in all
2135
+ copies or substantial portions of the Software.
2136
+
2137
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2138
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2139
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2140
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2141
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2142
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2143
+ SOFTWARE.
2144
+ */
2145
+
2146
+ /**
2147
+ * Renders an svg element to a jsPDF document.
2148
+ * For accurate results a DOM document is required (mainly used for text size measurement and image format conversion)
2149
+ * @param element {HTMLElement} The svg element, which will be cloned, so the original stays unchanged.
2150
+ * @param pdf {jsPDF} The jsPDF object.
2151
+ * @param options {object} An object that may contain render options. Currently supported are:
2152
+ * scale: The global factor by which everything is scaled.
2153
+ * xOffset, yOffset: Offsets that are added to every coordinate AFTER scaling (They are not
2154
+ * influenced by the scale attribute).
2155
+ */
2156
+ (function (global) {
2157
+ var RGBColor;
2158
+ var SvgPath;
2159
+ var FontFamily;
2160
+ var cssEsc;
2161
+
2162
+ var _pdf; // jsPDF pdf-document
2163
+
2164
+ var cToQ = 2 / 3; // ratio to convert quadratic bezier curves to cubic ones
2165
+
2166
+ var iriReference = /url\(["']?#([^"']+)["']?\)/;
2167
+
2168
+ // groups: 1: mime-type (+ charset), 2: mime-type (w/o charset), 3: charset, 4: base64?, 5: body
2169
+ var dataUrlRegex = /^\s*data:(([^/,;]+\/[^/,;]+)(?:;([^,;=]+=[^,;=]+))?)?(?:;(base64))?,(.*\s*)$/i;
2170
+
2171
+ var svgNamespaceURI = "http://www.w3.org/2000/svg";
2172
+
2173
+
2174
+ // pathSegList is marked deprecated in chrome, so parse the d attribute manually if necessary
2175
+ var getPathSegList = function (node) {
2176
+ var d = node.getAttribute("d");
2177
+
2178
+ // Replace arcs before path segment list is handled
2179
+ if (SvgPath) {
2180
+ d = SvgPath(d).unshort().unarc().abs().toString();
2181
+ node.setAttribute('d', d);
2182
+ }
2183
+
2184
+ var pathSegList = node.pathSegList;
2185
+
2186
+ if (pathSegList) {
2187
+ return pathSegList;
2188
+ }
2189
+
2190
+ pathSegList = [];
2191
+
2192
+ var regex = /([a-df-zA-DF-Z])([^a-df-zA-DF-Z]*)/g,
2193
+ match;
2194
+ while (match = regex.exec(d)) {
2195
+ var coords = parseFloats(match[2]);
2196
+
2197
+ var type = match[1];
2198
+ var length = "zZ".indexOf(type) >= 0 ? 0 :
2199
+ "hHvV".indexOf(type) >= 0 ? 1 :
2200
+ "mMlLtT".indexOf(type) >= 0 ? 2 :
2201
+ "sSqQ".indexOf(type) >= 0 ? 4 :
2202
+ "aA".indexOf(type) >= 0 ? 7 :
2203
+ "cC".indexOf(type) >= 0 ? 6 : -1;
2204
+
2205
+ var i = 0;
2206
+ do {
2207
+ var pathSeg = {pathSegTypeAsLetter: type};
2208
+ switch (type) {
2209
+ case "h":
2210
+ case "H":
2211
+ pathSeg.x = coords[i];
2212
+ break;
2213
+
2214
+ case "v":
2215
+ case "V":
2216
+ pathSeg.y = coords[i];
2217
+ break;
2218
+
2219
+ case "c":
2220
+ case "C":
2221
+ pathSeg.x1 = coords[i + length - 6];
2222
+ pathSeg.y1 = coords[i + length - 5];
2223
+ case "s":
2224
+ case "S":
2225
+ pathSeg.x2 = coords[i + length - 4];
2226
+ pathSeg.y2 = coords[i + length - 3];
2227
+ case "t":
2228
+ case "T":
2229
+ case "l":
2230
+ case "L":
2231
+ case "m":
2232
+ case "M":
2233
+ pathSeg.x = coords[i + length - 2];
2234
+ pathSeg.y = coords[i + length - 1];
2235
+ break;
2236
+
2237
+ case "q":
2238
+ case "Q":
2239
+ pathSeg.x1 = coords[i];
2240
+ pathSeg.y1 = coords[i + 1];
2241
+ pathSeg.x = coords[i + 2];
2242
+ pathSeg.y = coords[i + 3];
2243
+ break;
2244
+ case "a":
2245
+ case "A":
2246
+ throw new Error("Cannot convert Arcs without SvgPath package");
2247
+ }
2248
+
2249
+ pathSegList.push(pathSeg);
2250
+
2251
+ // "If a moveto is followed by multiple pairs of coordinates, the subsequent pairs are treated as implicit
2252
+ // lineto commands"
2253
+ if (type === "m") {
2254
+ type = "l";
2255
+ } else if (type === "M") {
2256
+ type = "L";
2257
+ }
2258
+
2259
+ i += length;
2260
+ } while(i < coords.length);
2261
+ }
2262
+
2263
+ pathSegList.getItem = function (i) {
2264
+ return this[i]
2265
+ };
2266
+ pathSegList.numberOfItems = pathSegList.length;
2267
+
2268
+ return pathSegList;
2269
+ };
2270
+
2271
+ // returns an attribute of a node, either from the node directly or from css
2272
+ var getAttribute = function (node, propertyNode, propertyCss) {
2273
+ propertyCss = propertyCss || propertyNode;
2274
+ return node.getAttribute(propertyNode) || node.style && node.style[propertyCss];
2275
+ };
2276
+
2277
+ /**
2278
+ * @param {Element} node
2279
+ * @param {string} tagsString
2280
+ * @return {boolean}
2281
+ */
2282
+ var nodeIs = function (node, tagsString) {
2283
+ return tagsString.split(",").indexOf(node.tagName.toLowerCase()) >= 0;
2284
+ };
2285
+
2286
+ var forEachChild = function (node, fn) {
2287
+ // copy list of children, as the original might be modified
2288
+ var children = [];
2289
+ for (var i = 0; i < node.childNodes.length; i++) {
2290
+ var childNode = node.childNodes[i];
2291
+ if (childNode.nodeName.charAt(0) !== "#")
2292
+ children.push(childNode);
2293
+ }
2294
+ for (i = 0; i < children.length; i++) {
2295
+ fn(i, children[i]);
2296
+ }
2297
+ };
2298
+
2299
+ var getAngle = function (from, to) {
2300
+ return Math.atan2(to[1] - from[1], to[0] - from[0]);
2301
+ };
2302
+
2303
+ function normalize(v) {
2304
+ var length = Math.sqrt(v[0] * v[0] + v[1] * v[1]);
2305
+ return [v[0] / length, v[1] / length];
2306
+ }
2307
+
2308
+ function getDirectionVector(from, to) {
2309
+ var v = [to[0] - from[0], to[1] - from[1]];
2310
+ return normalize(v);
2311
+ }
2312
+
2313
+ function addVectors(v1, v2) {
2314
+ return [v1[0] + v2[0], v1[1] + v2[1]];
2315
+ }
2316
+
2317
+ // mirrors p1 at p2
2318
+ var mirrorPoint = function (p1, p2) {
2319
+ var dx = p2[0] - p1[0];
2320
+ var dy = p2[1] - p1[1];
2321
+
2322
+ return [p1[0] + 2 * dx, p1[1] + 2 * dy];
2323
+ };
2324
+
2325
+ // transforms a cubic bezier control point to a quadratic one: returns from + (2/3) * (to - from)
2326
+ var toCubic = function (from, to) {
2327
+ return [cToQ * (to[0] - from[0]) + from[0], cToQ * (to[1] - from[1]) + from[1]];
2328
+ };
2329
+
2330
+ // extracts a control point from a previous path segment (for t,T,s,S segments)
2331
+ var getControlPointFromPrevious = function (i, from, list, prevX, prevY) {
2332
+ var prev = list.getItem(i - 1);
2333
+ var p2;
2334
+ if (i > 0 && (prev.pathSegTypeAsLetter === "C" || prev.pathSegTypeAsLetter === "S")) {
2335
+ p2 = mirrorPoint([prev.x2, prev.y2], from);
2336
+ } else if (i > 0 && (prev.pathSegTypeAsLetter === "c" || prev.pathSegTypeAsLetter === "s")) {
2337
+ p2 = mirrorPoint([prev.x2 + prevX, prev.y2 + prevY], from);
2338
+ } else {
2339
+ p2 = [from[0], from[1]];
2340
+ }
2341
+ return p2;
2342
+ };
2343
+
2344
+ /**
2345
+ * @param {Element} rootSvg
2346
+ * @constructor
2347
+ * @property {Object.<String,Element>} renderedElements
2348
+ * @property {Element} rootSvg
2349
+ */
2350
+ function ReferencesHandler(rootSvg) {
2351
+ this.renderedElements = {};
2352
+ this.rootSvg = rootSvg;
2353
+ }
2354
+
2355
+ /**
2356
+ * @param {string} id
2357
+ * @return {*}
2358
+ */
2359
+ ReferencesHandler.prototype.getRendered = function (id) {
2360
+ if (this.renderedElements.hasOwnProperty(id)) {
2361
+ return this.renderedElements[id];
2362
+ }
2363
+
2364
+ var node = this.rootSvg.querySelector("#" + cssEsc(id, {isIdentifier: true}));
2365
+
2366
+ if (nodeIs(node, "lineargradient")) {
2367
+ putGradient(node, "axial", [
2368
+ node.getAttribute("x1") || 0,
2369
+ node.getAttribute("y1") || 0,
2370
+ node.getAttribute("x2") || 1,
2371
+ node.getAttribute("y2") || 0
2372
+ ]);
2373
+ } else if (nodeIs(node, "radialgradient")) {
2374
+ putGradient(node, "radial", [
2375
+ node.getAttribute("fx") || node.getAttribute("cx") || 0.5,
2376
+ node.getAttribute("fy") || node.getAttribute("cy") || 0.5,
2377
+ 0,
2378
+ node.getAttribute("cx") || 0.5,
2379
+ node.getAttribute("cy") || 0.5,
2380
+ node.getAttribute("r") || 0.5
2381
+ ]);
2382
+ } else if (nodeIs(node, "pattern")) {
2383
+ pattern(node, this, AttributeState.default())
2384
+ } else if (nodeIs(node, "marker")) {
2385
+ // the transformations directly at the node are written to the pdf form object transformation matrix
2386
+ var tfMatrix = computeNodeTransform(node);
2387
+ var bBox = getUntransformedBBox(node);
2388
+
2389
+ _pdf.beginFormObject(bBox[0], bBox[1], bBox[2], bBox[3], tfMatrix);
2390
+ renderChildren(node, _pdf.unitMatrix, this, false, false, AttributeState.default());
2391
+ _pdf.endFormObject(node.getAttribute("id"));
2392
+ } else if (!nodeIs(node, "clippath")) {
2393
+ // all other nodes will be rendered as PDF form object
2394
+ renderNode(node, _pdf.unitMatrix, this, true, false, AttributeState.default());
2395
+ }
2396
+
2397
+ this.renderedElements[id] = node;
2398
+ return node;
2399
+ };
2400
+
2401
+ var AttributeState = function () {
2402
+ this.xmlSpace = null;
2403
+ this.color = null;
2404
+ this.fill = null;
2405
+ this.fillOpacity = 1.0;
2406
+ // this.fillRule = null;
2407
+ this.fontFamily = null;
2408
+ this.fontSize = 16;
2409
+ this.fontStyle = null;
2410
+ // this.fontVariant = null;
2411
+ this.fontWeight = null;
2412
+ this.opacity = 1.0;
2413
+ this.stroke = null;
2414
+ this.strokeDasharray = null;
2415
+ this.strokeDashoffset = null;
2416
+ this.strokeLinecap = null;
2417
+ this.strokeLinejoin = null;
2418
+ this.strokeMiterlimit = 4.0;
2419
+ this.strokeOpacity = 1.0;
2420
+ this.strokeWidth = 1.0;
2421
+ // this.textAlign = null;
2422
+ this.textAnchor = null;
2423
+ this.visibility = null;
2424
+ };
2425
+
2426
+ AttributeState.default = function () {
2427
+ var attributeState = new AttributeState();
2428
+
2429
+ attributeState.xmlSpace = "default";
2430
+ attributeState.fill = new RGBColor("rgb(0, 0, 0)");
2431
+ attributeState.fillOpacity = 1.0;
2432
+ // attributeState.fillRule = "nonzero";
2433
+ attributeState.fontFamily = "times";
2434
+ attributeState.fontSize = 16;
2435
+ attributeState.fontStyle = "normal";
2436
+ // attributeState.fontVariant = "normal";
2437
+ attributeState.fontWeight = "normal";
2438
+ attributeState.opacity = 1.0;
2439
+ attributeState.stroke = null;
2440
+ attributeState.strokeDasharray = null;
2441
+ attributeState.strokeDashoffset = null;
2442
+ attributeState.strokeLinecap = "butt";
2443
+ attributeState.strokeLinejoin = "miter";
2444
+ attributeState.strokeMiterlimit = 4.0;
2445
+ attributeState.strokeOpacity = 1.0;
2446
+ attributeState.strokeWidth = 1.0;
2447
+ // attributeState.textAlign = "start";
2448
+ attributeState.textAnchor = "start";
2449
+ attributeState.visibility = "visible";
2450
+
2451
+ return attributeState;
2452
+ };
2453
+
2454
+ AttributeState.prototype.clone = function () {
2455
+ var clone = new AttributeState();
2456
+
2457
+ clone.xmlSpace = this.xmlSpace;
2458
+ clone.fill = this.fill;
2459
+ clone.fillOpacity = this.fillOpacity;
2460
+ // clone.fillRule = this.fillRule;
2461
+ clone.fontFamily = this.fontFamily;
2462
+ clone.fontSize = this.fontSize;
2463
+ clone.fontStyle = this.fontStyle;
2464
+ // clone.fontVariant = this.fontVariant;
2465
+ clone.fontWeight = this.fontWeight;
2466
+ clone.opacity = this.opacity;
2467
+ clone.stroke = this.stroke;
2468
+ clone.strokeDasharray = this.strokeDasharray;
2469
+ clone.strokeDashoffset = this.strokeDashoffset;
2470
+ clone.strokeLinecap = this.strokeLinecap;
2471
+ clone.strokeLinejoin = this.strokeLinejoin;
2472
+ clone.strokeMiterlimit = this.strokeMiterlimit;
2473
+ clone.strokeOpacity = this.strokeOpacity;
2474
+ clone.strokeWidth = this.strokeWidth;
2475
+ // clone.textAlign = this.textAlign;
2476
+ clone.textAnchor = this.textAnchor;
2477
+ clone.visibility = this.visibility;
2478
+
2479
+ return clone;
2480
+ };
2481
+
2482
+ /**
2483
+ * @constructor
2484
+ * @property {Marker[]} markers
2485
+ */
2486
+ function MarkerList() {
2487
+ this.markers = [];
2488
+ }
2489
+
2490
+ /**
2491
+ * @param {Marker} marker
2492
+ */
2493
+ MarkerList.prototype.addMarker = function addMarker(marker) {
2494
+ this.markers.push(marker);
2495
+ };
2496
+
2497
+ MarkerList.prototype.draw = function (tfMatrix, refsHandler, attributeState) {
2498
+ for (var i = 0; i < this.markers.length; i++) {
2499
+ var marker = this.markers[i];
2500
+
2501
+ var tf;
2502
+ var angle = marker.angle, anchor = marker.anchor;
2503
+ var cos = Math.cos(angle);
2504
+ var sin = Math.sin(angle);
2505
+ // position at and rotate around anchor
2506
+ tf = new _pdf.Matrix(cos, sin, -sin, cos, anchor[0], anchor[1]);
2507
+ // scale with stroke-width
2508
+ tf = _pdf.matrixMult(new _pdf.Matrix(attributeState.strokeWidth, 0, 0, attributeState.strokeWidth, 0, 0), tf);
2509
+
2510
+ tf = _pdf.matrixMult(tf, tfMatrix);
2511
+
2512
+ // as the marker is already scaled by the current line width we must not apply the line width twice!
2513
+ _pdf.saveGraphicsState();
2514
+ _pdf.setLineWidth(1.0);
2515
+ refsHandler.getRendered(marker.id);
2516
+ _pdf.doFormObject(marker.id, tf);
2517
+ _pdf.restoreGraphicsState();
2518
+ }
2519
+ };
2520
+
2521
+ /**
2522
+ * @param {string} id
2523
+ * @param {[number,number]} anchor
2524
+ * @param {number} angle
2525
+ */
2526
+ function Marker(id, anchor, angle) {
2527
+ this.id = id;
2528
+ this.anchor = anchor;
2529
+ this.angle = angle;
2530
+ }
2531
+
2532
+ function removeNewlines(str) {
2533
+ return str.replace(/[\n\r]/g, "");
2534
+ }
2535
+
2536
+ function replaceTabsBySpace(str) {
2537
+ return str.replace(/[\t]/g, " ");
2538
+ }
2539
+
2540
+ function consolidateSpaces(str) {
2541
+ return str.replace(/ +/g, " ");
2542
+ }
2543
+
2544
+ function trimLeft(str) {
2545
+ return str.replace(/^\s+/,"");
2546
+ }
2547
+
2548
+ function trimRight(str) {
2549
+ return str.replace(/\s+$/,"");
2550
+ }
2551
+
2552
+ function computeViewBoxTransform(node, viewBox, eX, eY, eWidth, eHeight) {
2553
+ var vbX = viewBox[0];
2554
+ var vbY = viewBox[1];
2555
+ var vbWidth = viewBox[2];
2556
+ var vbHeight = viewBox[3];
2557
+
2558
+ var scaleX = eWidth / vbWidth;
2559
+ var scaleY = eHeight / vbHeight;
2560
+
2561
+ var align, meetOrSlice;
2562
+ var preserveAspectRatio = node.getAttribute("preserveAspectRatio");
2563
+ if (preserveAspectRatio) {
2564
+ var alignAndMeetOrSlice = preserveAspectRatio.split(" ");
2565
+ if (alignAndMeetOrSlice[0] === "defer") {
2566
+ alignAndMeetOrSlice = alignAndMeetOrSlice.slice(1);
2567
+ }
2568
+
2569
+ align = alignAndMeetOrSlice[0];
2570
+ meetOrSlice = alignAndMeetOrSlice[1] || "meet";
2571
+ } else {
2572
+ align = "xMidYMid";
2573
+ meetOrSlice = "meet"
2574
+ }
2575
+
2576
+ if (align !== "none") {
2577
+ if (meetOrSlice === "meet") {
2578
+ // uniform scaling with min scale
2579
+ scaleX = scaleY = Math.min(scaleX, scaleY);
2580
+ } else if (meetOrSlice === "slice") {
2581
+ // uniform scaling with max scale
2582
+ scaleX = scaleY = Math.max(scaleX, scaleY);
2583
+ }
2584
+ }
2585
+
2586
+ var translateX = eX - (vbX * scaleX);
2587
+ var translateY = eY - (vbY * scaleY);
2588
+
2589
+ if (align.indexOf("xMid") >= 0) {
2590
+ translateX += (eWidth - vbWidth * scaleX) / 2;
2591
+ } else if (align.indexOf("xMax") >= 0) {
2592
+ translateX += eWidth - vbWidth * scaleX;
2593
+ }
2594
+
2595
+ if (align.indexOf("yMid") >= 0) {
2596
+ translateY += (eHeight - vbHeight * scaleY) / 2;
2597
+ } else if (align.indexOf("yMax") >= 0) {
2598
+ translateY += (eHeight - vbHeight * scaleY);
2599
+ }
2600
+
2601
+ var translate = new _pdf.Matrix(1, 0, 0, 1, translateX, translateY);
2602
+ var scale = new _pdf.Matrix(scaleX, 0, 0, scaleY, 0, 0);
2603
+
2604
+ return _pdf.matrixMult(scale, translate);
2605
+ }
2606
+
2607
+ // computes the transform directly applied at the node (such as viewbox scaling and the "transform" atrribute)
2608
+ // x,y,cx,cy,r,... are omitted
2609
+ var computeNodeTransform = function (node) {
2610
+ var viewBox, x, y;
2611
+ var nodeTransform = _pdf.unitMatrix;
2612
+ if (nodeIs(node, "svg,g")) {
2613
+ x = parseFloat(node.getAttribute("x")) || 0;
2614
+ y = parseFloat(node.getAttribute("y")) || 0;
2615
+
2616
+ viewBox = node.getAttribute("viewBox");
2617
+ if (viewBox) {
2618
+ var box = parseFloats(viewBox);
2619
+ var width = parseFloat(node.getAttribute("width")) || box[2];
2620
+ var height = parseFloat(node.getAttribute("height")) || box[3];
2621
+ nodeTransform = computeViewBoxTransform(node, box, x, y, width, height)
2622
+ } else {
2623
+ nodeTransform = new _pdf.Matrix(1, 0, 0, 1, x, y);
2624
+ }
2625
+ } else if (nodeIs(node, "marker")) {
2626
+ x = parseFloat(node.getAttribute("refX")) || 0;
2627
+ y = parseFloat(node.getAttribute("refY")) || 0;
2628
+
2629
+ viewBox = node.getAttribute("viewBox");
2630
+ if (viewBox) {
2631
+ var bounds = parseFloats(viewBox);
2632
+ bounds[0] = bounds[1] = 0; // for some reason vbX anc vbY seem to be ignored for markers
2633
+ nodeTransform = computeViewBoxTransform(node,
2634
+ bounds,
2635
+ 0,
2636
+ 0,
2637
+ parseFloat(node.getAttribute("markerWidth")) || 3,
2638
+ parseFloat(node.getAttribute("markerHeight")) || 3
2639
+ );
2640
+ nodeTransform = _pdf.matrixMult(new _pdf.Matrix(1, 0, 0, 1, -x, -y), nodeTransform);
2641
+ } else {
2642
+ nodeTransform = new _pdf.Matrix(1, 0, 0, 1, -x, -y);
2643
+ }
2644
+ }
2645
+
2646
+ var transformString = node.getAttribute("transform");
2647
+ if (!transformString)
2648
+ return nodeTransform;
2649
+ else
2650
+ return _pdf.matrixMult(nodeTransform, parseTransform(transformString));
2651
+ };
2652
+
2653
+ // parses the "points" string used by polygons and returns an array of points
2654
+ var parsePointsString = function (string) {
2655
+ var floats = parseFloats(string);
2656
+ var result = [];
2657
+ for (var i = 0; i < floats.length - 1; i += 2) {
2658
+ var x = floats[i];
2659
+ var y = floats[i + 1];
2660
+ result.push([x, y]);
2661
+ }
2662
+ return result;
2663
+ };
2664
+
2665
+ // parses the "transform" string
2666
+ var parseTransform = function (transformString) {
2667
+ if (!transformString)
2668
+ return _pdf.unitMatrix;
2669
+
2670
+ var mRegex = /^\s*matrix\(([^\)]+)\)\s*/,
2671
+ tRegex = /^\s*translate\(([^\)]+)\)\s*/,
2672
+ rRegex = /^\s*rotate\(([^\)]+)\)\s*/,
2673
+ sRegex = /^\s*scale\(([^\)]+)\)\s*/,
2674
+ sXRegex = /^\s*skewX\(([^\)]+)\)\s*/,
2675
+ sYRegex = /^\s*skewY\(([^\)]+)\)\s*/;
2676
+
2677
+ var resultMatrix = _pdf.unitMatrix, m;
2678
+
2679
+ while (transformString.length > 0) {
2680
+ var match = mRegex.exec(transformString);
2681
+ if (match) {
2682
+ m = parseFloats(match[1]);
2683
+ resultMatrix = _pdf.matrixMult(new _pdf.Matrix(m[0], m[1], m[2], m[3], m[4], m[5]), resultMatrix);
2684
+ transformString = transformString.substr(match[0].length);
2685
+ }
2686
+ match = rRegex.exec(transformString);
2687
+ if (match) {
2688
+ m = parseFloats(match[1]);
2689
+ var a = Math.PI * m[0] / 180;
2690
+ resultMatrix = _pdf.matrixMult(new _pdf.Matrix(Math.cos(a), Math.sin(a), -Math.sin(a), Math.cos(a), 0, 0), resultMatrix);
2691
+ if (m[1] && m[2]) {
2692
+ var t1 = new _pdf.Matrix(1, 0, 0, 1, m[1], m[2]);
2693
+ var t2 = new _pdf.Matrix(1, 0, 0, 1, -m[1], -m[2]);
2694
+ resultMatrix = _pdf.matrixMult(t2, _pdf.matrixMult(resultMatrix, t1));
2695
+ }
2696
+ transformString = transformString.substr(match[0].length);
2697
+ }
2698
+ match = tRegex.exec(transformString);
2699
+ if (match) {
2700
+ m = parseFloats(match[1]);
2701
+ resultMatrix = _pdf.matrixMult(new _pdf.Matrix(1, 0, 0, 1, m[0], m[1] || 0), resultMatrix);
2702
+ transformString = transformString.substr(match[0].length);
2703
+ }
2704
+ match = sRegex.exec(transformString);
2705
+ if (match) {
2706
+ m = parseFloats(match[1]);
2707
+ if (!m[1])
2708
+ m[1] = m[0];
2709
+ resultMatrix = _pdf.matrixMult(new _pdf.Matrix(m[0], 0, 0, m[1], 0, 0), resultMatrix);
2710
+ transformString = transformString.substr(match[0].length);
2711
+ }
2712
+ match = sXRegex.exec(transformString);
2713
+ if (match) {
2714
+ m = parseFloat(match[1]);
2715
+ resultMatrix = _pdf.matrixMult(new _pdf.Matrix(1, 0, Math.tan(m), 1, 0, 0), resultMatrix);
2716
+ transformString = transformString.substr(match[0].length);
2717
+ }
2718
+ match = sYRegex.exec(transformString);
2719
+ if (match) {
2720
+ m = parseFloat(match[1]);
2721
+ resultMatrix = _pdf.matrixMult(new _pdf.Matrix(1, Math.tan(m), 0, 1, 0, 0), resultMatrix);
2722
+ transformString = transformString.substr(match[0].length);
2723
+ }
2724
+ }
2725
+ return resultMatrix;
2726
+ };
2727
+
2728
+ // parses a comma, sign and/or whitespace separated string of floats and returns the single floats in an array
2729
+ var parseFloats = function (str) {
2730
+ var floats = [], match,
2731
+ regex = /[+-]?(?:(?:\d+\.?\d*)|(?:\d*\.?\d+))(?:[eE][+-]?\d+)?/g;
2732
+ while(match = regex.exec(str)) {
2733
+ floats.push(parseFloat(match[0]));
2734
+ }
2735
+ return floats;
2736
+ };
2737
+
2738
+ // extends RGBColor by rgba colors as RGBColor is not capable of it
2739
+ var parseColor = function (colorString) {
2740
+ if (colorString === "transparent") {
2741
+ var transparent = new RGBColor("rgb(0,0,0)");
2742
+ transparent.a = 0;
2743
+ return transparent
2744
+ }
2745
+
2746
+ var match = /\s*rgba\(((?:[^,\)]*,){3}[^,\)]*)\)\s*/.exec(colorString);
2747
+ if (match) {
2748
+ var floats = parseFloats(match[1]);
2749
+ var color = new RGBColor("rgb(" + floats.slice(0,3).join(",") + ")");
2750
+ color.a = floats[3];
2751
+ return color;
2752
+ } else {
2753
+ return new RGBColor(colorString);
2754
+ }
2755
+ };
2756
+
2757
+ // multiplies a vector with a matrix: vec' = vec * matrix
2758
+ var multVecMatrix = function (vec, matrix) {
2759
+ var x = vec[0];
2760
+ var y = vec[1];
2761
+ return [
2762
+ matrix.a * x + matrix.c * y + matrix.e,
2763
+ matrix.b * x + matrix.d * y + matrix.f
2764
+ ];
2765
+ };
2766
+
2767
+ // returns the untransformed bounding box [x, y, width, height] of an svg element (quite expensive for path and polygon objects, as
2768
+ // the whole points/d-string has to be processed)
2769
+ var getUntransformedBBox = function (node) {
2770
+ if (getAttribute(node, "display") === "none") {
2771
+ return [0, 0, 0, 0];
2772
+ }
2773
+
2774
+ var i, minX, minY, maxX, maxY, viewBox, vb, boundingBox;
2775
+ var pf = parseFloat;
2776
+
2777
+ if (nodeIs(node, "polygon,polyline")) {
2778
+ var points = parsePointsString(node.getAttribute("points"));
2779
+ minX = Number.POSITIVE_INFINITY;
2780
+ minY = Number.POSITIVE_INFINITY;
2781
+ maxX = Number.NEGATIVE_INFINITY;
2782
+ maxY = Number.NEGATIVE_INFINITY;
2783
+ for (i = 0; i < points.length; i++) {
2784
+ var point = points[i];
2785
+ minX = Math.min(minX, point[0]);
2786
+ maxX = Math.max(maxX, point[0]);
2787
+ minY = Math.min(minY, point[1]);
2788
+ maxY = Math.max(maxY, point[1]);
2789
+ }
2790
+ boundingBox = [
2791
+ minX,
2792
+ minY,
2793
+ maxX - minX,
2794
+ maxY - minY
2795
+ ];
2796
+ } else if (nodeIs(node, "path")) {
2797
+ var list = getPathSegList(node);
2798
+ minX = Number.POSITIVE_INFINITY;
2799
+ minY = Number.POSITIVE_INFINITY;
2800
+ maxX = Number.NEGATIVE_INFINITY;
2801
+ maxY = Number.NEGATIVE_INFINITY;
2802
+ var x = 0, y = 0;
2803
+ var prevX, prevY, newX, newY;
2804
+ var p2, p3, to;
2805
+ for (i = 0; i < list.numberOfItems; i++) {
2806
+ var seg = list.getItem(i);
2807
+ var cmd = seg.pathSegTypeAsLetter;
2808
+ switch (cmd) {
2809
+ case "H":
2810
+ newX = seg.x;
2811
+ newY = y;
2812
+ break;
2813
+ case "h":
2814
+ newX = seg.x + x;
2815
+ newY = y;
2816
+ break;
2817
+ case "V":
2818
+ newX = x;
2819
+ newY = seg.y;
2820
+ break;
2821
+ case "v":
2822
+ newX = x;
2823
+ newY = seg.y + y;
2824
+ break;
2825
+ case "C":
2826
+ p2 = [seg.x1, seg.y1];
2827
+ p3 = [seg.x2, seg.y2];
2828
+ to = [seg.x, seg.y];
2829
+ break;
2830
+ case "c":
2831
+ p2 = [seg.x1 + x, seg.y1 + y];
2832
+ p3 = [seg.x2 + x, seg.y2 + y];
2833
+ to = [seg.x + x, seg.y + y];
2834
+ break;
2835
+ case "S":
2836
+ p2 = getControlPointFromPrevious(i, [x, y], list, prevX, prevY);
2837
+ p3 = [seg.x2, seg.y2];
2838
+ to = [seg.x, seg.y];
2839
+ break;
2840
+ case "s":
2841
+ p2 = getControlPointFromPrevious(i, [x, y], list, prevX, prevY);
2842
+ p3 = [seg.x2 + x, seg.y2 + y];
2843
+ to = [seg.x + x, seg.y + y];
2844
+ break;
2845
+ case "Q":
2846
+ pf = [seg.x1, seg.y1];
2847
+ p2 = toCubic([x, y], pf);
2848
+ p3 = toCubic([seg.x, seg.y], pf);
2849
+ to = [seg.x, seg.y];
2850
+ break;
2851
+ case "q":
2852
+ pf = [seg.x1 + x, seg.y1 + y];
2853
+ p2 = toCubic([x, y], pf);
2854
+ p3 = toCubic([x + seg.x, y + seg.y], pf);
2855
+ to = [seg.x + x, seg.y + y];
2856
+ break;
2857
+ case "T":
2858
+ p2 = getControlPointFromPrevious(i, [x, y], list, prevX, prevY);
2859
+ p2 = toCubic([x, y], pf);
2860
+ p3 = toCubic([seg.x, seg.y], pf);
2861
+ to = [seg.x, seg.y];
2862
+ break;
2863
+ case "t":
2864
+ pf = getControlPointFromPrevious(i, [x, y], list, prevX, prevY);
2865
+ p2 = toCubic([x, y], pf);
2866
+ p3 = toCubic([x + seg.x, y + seg.y], pf);
2867
+ to = [seg.x + x, seg.y + y];
2868
+ break;
2869
+ // TODO: A,a
2870
+ }
2871
+ if ("sScCqQtT".indexOf(cmd) >= 0) {
2872
+ prevX = x;
2873
+ prevY = y;
2874
+ }
2875
+ if ("MLCSQT".indexOf(cmd) >= 0) {
2876
+ x = seg.x;
2877
+ y = seg.y;
2878
+ } else if ("mlcsqt".indexOf(cmd) >= 0) {
2879
+ x = seg.x + x;
2880
+ y = seg.y + y;
2881
+ } else if ("zZ".indexOf(cmd) < 0) {
2882
+ x = newX;
2883
+ y = newY;
2884
+ }
2885
+ if ("CSQTcsqt".indexOf(cmd) >= 0) {
2886
+ minX = Math.min(minX, x, p2[0], p3[0], to[0]);
2887
+ maxX = Math.max(maxX, x, p2[0], p3[0], to[0]);
2888
+ minY = Math.min(minY, y, p2[1], p3[1], to[1]);
2889
+ maxY = Math.max(maxY, y, p2[1], p3[1], to[1]);
2890
+ } else {
2891
+ minX = Math.min(minX, x);
2892
+ maxX = Math.max(maxX, x);
2893
+ minY = Math.min(minY, y);
2894
+ maxY = Math.max(maxY, y);
2895
+ }
2896
+ }
2897
+ boundingBox = [
2898
+ minX,
2899
+ minY,
2900
+ maxX - minX,
2901
+ maxY - minY
2902
+ ];
2903
+ } else if (nodeIs(node, "svg")) {
2904
+ viewBox = node.getAttribute("viewBox");
2905
+ if (viewBox) {
2906
+ vb = parseFloats(viewBox);
2907
+ }
2908
+ return [
2909
+ pf(node.getAttribute("x")) || (vb && vb[0]) || 0,
2910
+ pf(node.getAttribute("y")) || (vb && vb[1]) || 0,
2911
+ pf(node.getAttribute("width")) || (vb && vb[2]) || 0,
2912
+ pf(node.getAttribute("height")) || (vb && vb[3]) || 0
2913
+ ];
2914
+ } else if (nodeIs(node, "g,clippath")) {
2915
+ boundingBox = [0, 0, 0, 0];
2916
+ forEachChild(node, function (i, node) {
2917
+ var nodeBox = getUntransformedBBox(node);
2918
+ boundingBox = [
2919
+ Math.min(boundingBox[0], nodeBox[0]),
2920
+ Math.min(boundingBox[1], nodeBox[1]),
2921
+ Math.max(boundingBox[0] + boundingBox[2], nodeBox[0] + nodeBox[2]) - Math.min(boundingBox[0], nodeBox[0]),
2922
+ Math.max(boundingBox[1] + boundingBox[3], nodeBox[1] + nodeBox[3]) - Math.min(boundingBox[1], nodeBox[1])
2923
+ ];
2924
+ });
2925
+ } else if (nodeIs(node, "marker")) {
2926
+ viewBox = node.getAttribute("viewBox");
2927
+ if (viewBox) {
2928
+ vb = parseFloats(viewBox);
2929
+ }
2930
+ return [
2931
+ (vb && vb[0]) || 0,
2932
+ (vb && vb[1]) || 0,
2933
+ (vb && vb[2]) || pf(node.getAttribute("marker-width")) || 0,
2934
+ (vb && vb[3]) || pf(node.getAttribute("marker-height")) || 0
2935
+ ];
2936
+ } else if (nodeIs(node, "pattern")) {
2937
+ return [
2938
+ pf(node.getAttribute("x")) || 0,
2939
+ pf(node.getAttribute("y")) || 0,
2940
+ pf(node.getAttribute("width")) || 0,
2941
+ pf(node.getAttribute("height")) || 0
2942
+ ]
2943
+ } else {
2944
+ // TODO: check if there are other possible coordinate attributes
2945
+ var x1 = pf(node.getAttribute("x1")) || pf(node.getAttribute("x")) || pf((node.getAttribute("cx")) - pf(node.getAttribute("r"))) || 0;
2946
+ var x2 = pf(node.getAttribute("x2")) || (x1 + pf(node.getAttribute("width"))) || (pf(node.getAttribute("cx")) + pf(node.getAttribute("r"))) || 0;
2947
+ var y1 = pf(node.getAttribute("y1")) || pf(node.getAttribute("y")) || (pf(node.getAttribute("cy")) - pf(node.getAttribute("r"))) || 0;
2948
+ var y2 = pf(node.getAttribute("y2")) || (y1 + pf(node.getAttribute("height"))) || (pf(node.getAttribute("cy")) + pf(node.getAttribute("r"))) || 0;
2949
+ boundingBox = [
2950
+ Math.min(x1, x2),
2951
+ Math.min(y1, y2),
2952
+ Math.max(x1, x2) - Math.min(x1, x2),
2953
+ Math.max(y1, y2) - Math.min(y1, y2)
2954
+ ];
2955
+ }
2956
+
2957
+ if (!nodeIs(node, "marker,svg,g")) {
2958
+ // add line-width
2959
+ var lineWidth = getAttribute(node, "stroke-width") || 1;
2960
+ var miterLimit = getAttribute(node, "stroke-miterlimit");
2961
+ // miterLength / lineWidth = 1 / sin(phi / 2)
2962
+ miterLimit && (lineWidth *= 0.5 / (Math.sin(Math.PI / 12)));
2963
+ return [
2964
+ boundingBox[0] - lineWidth,
2965
+ boundingBox[1] - lineWidth,
2966
+ boundingBox[2] + 2 * lineWidth,
2967
+ boundingBox[3] + 2 * lineWidth
2968
+ ];
2969
+ }
2970
+
2971
+ return boundingBox;
2972
+ };
2973
+
2974
+ // transforms a bounding box and returns a new rect that contains it
2975
+ var transformBBox = function (box, matrix) {
2976
+ var bl = multVecMatrix([box[0], box[1]], matrix);
2977
+ var br = multVecMatrix([box[0] + box[2], box[1]], matrix);
2978
+ var tl = multVecMatrix([box[0], box[1] + box[3]], matrix);
2979
+ var tr = multVecMatrix([box[0] + box[2], box[1] + box[3]], matrix);
2980
+
2981
+ var bottom = Math.min(bl[1], br[1], tl[1], tr[1]);
2982
+ var left = Math.min(bl[0], br[0], tl[0], tr[0]);
2983
+ var top = Math.max(bl[1], br[1], tl[1], tr[1]);
2984
+ var right = Math.max(bl[0], br[0], tl[0], tr[0]);
2985
+
2986
+ return [
2987
+ left,
2988
+ bottom,
2989
+ right - left,
2990
+ top - bottom
2991
+ ]
2992
+ };
2993
+
2994
+ // draws a polygon
2995
+ var polygon = function (node, refsHandler, attributeState, closed) {
2996
+ if (!node.hasAttribute("points") || node.getAttribute("points") === "") {
2997
+ return;
2998
+ }
2999
+
3000
+ var points = parsePointsString(node.getAttribute("points"));
3001
+ var lines = [{op: "m", c: points[0]}];
3002
+ var i, angle;
3003
+ for (i = 1; i < points.length; i++) {
3004
+ lines.push({op: "l", c: points[i]});
3005
+ }
3006
+
3007
+ if (closed) {
3008
+ lines.push({op: "h"});
3009
+ }
3010
+
3011
+ _pdf.path(lines);
3012
+
3013
+ var markerEnd = node.getAttribute("marker-end"),
3014
+ markerStart = node.getAttribute("marker-start"),
3015
+ markerMid = node.getAttribute("marker-mid");
3016
+
3017
+ if (markerStart || markerMid || markerEnd) {
3018
+ var length = lines.length;
3019
+ var markers = new MarkerList();
3020
+ if (markerStart) {
3021
+ markerStart = iriReference.exec(markerStart)[1];
3022
+ angle = addVectors(getDirectionVector(lines[0].c, lines[1].c), getDirectionVector(lines[length - 2].c, lines[0].c));
3023
+ markers.addMarker(new Marker(markerStart, lines[0].c, Math.atan2(angle[1], angle[0])));
3024
+ }
3025
+
3026
+ if (markerMid) {
3027
+ markerMid = iriReference.exec(markerMid)[1];
3028
+ var prevAngle = getDirectionVector(lines[0].c, lines[1].c), curAngle;
3029
+ for (i = 1; i < lines.length - 2; i++) {
3030
+ curAngle = getDirectionVector(lines[i].c, lines[i + 1].c);
3031
+ angle = addVectors(prevAngle, curAngle);
3032
+ markers.addMarker(new Marker(markerMid, lines[i].c, Math.atan2(angle[1], angle[0])));
3033
+ prevAngle = curAngle;
3034
+ }
3035
+
3036
+ curAngle = getDirectionVector(lines[length - 2].c, lines[0].c);
3037
+ angle = addVectors(prevAngle, curAngle);
3038
+ markers.addMarker(new Marker(markerMid, lines[length - 2].c, Math.atan2(angle[1], angle[0])));
3039
+ }
3040
+
3041
+ if (markerEnd) {
3042
+ markerEnd = iriReference.exec(markerEnd)[1];
3043
+ angle = addVectors(getDirectionVector(lines[0].c, lines[1].c), getDirectionVector(lines[length - 2].c, lines[0].c));
3044
+ markers.addMarker(new Marker(markerEnd, lines[0].c, Math.atan2(angle[1], angle[0])));
3045
+ }
3046
+
3047
+ markers.draw(_pdf.unitMatrix, refsHandler, attributeState);
3048
+ }
3049
+ };
3050
+
3051
+ // draws an image
3052
+ var image = function (node) {
3053
+ var width = parseFloat(node.getAttribute("width")),
3054
+ height = parseFloat(node.getAttribute("height")),
3055
+ x = parseFloat(node.getAttribute("x") || 0),
3056
+ y = parseFloat(node.getAttribute("y") || 0);
3057
+
3058
+
3059
+ var imageUrl = node.getAttribute("xlink:href") || node.getAttribute("href");
3060
+
3061
+ var dataUrl = imageUrl.match(dataUrlRegex);
3062
+ if (dataUrl && dataUrl[2] === "image/svg+xml") {
3063
+ var svgText = dataUrl[5];
3064
+ if (dataUrl[4] === "base64") {
3065
+ svgText = atob(svgText);
3066
+ } else {
3067
+ svgText = decodeURIComponent(svgText);
3068
+ }
3069
+
3070
+ var parser = new DOMParser();
3071
+ var svgElement = parser.parseFromString(svgText, "image/svg+xml").firstElementChild;
3072
+
3073
+ // unless preserveAspectRatio starts with "defer", the preserveAspectRatio attribute of the svg is ignored
3074
+ var preserveAspectRatio = node.getAttribute("preserveAspectRatio");
3075
+ if (!preserveAspectRatio
3076
+ || preserveAspectRatio.indexOf("defer") < 0
3077
+ || !svgElement.getAttribute("preserveAspectRatio")) {
3078
+ svgElement.setAttribute("preserveAspectRatio", preserveAspectRatio);
3079
+ }
3080
+
3081
+ svgElement.setAttribute("x", String(x));
3082
+ svgElement.setAttribute("y", String(y));
3083
+ svgElement.setAttribute("width", String(width));
3084
+ svgElement.setAttribute("height", String(height));
3085
+
3086
+ renderNode(svgElement, _pdf.unitMatrix, {}, false, false, AttributeState.default());
3087
+ return;
3088
+ }
3089
+
3090
+ try {
3091
+ _pdf.addImage(
3092
+ imageUrl,
3093
+ "", // will be ignored anyways if imageUrl is a data url
3094
+ x,
3095
+ y,
3096
+ width,
3097
+ height
3098
+ );
3099
+ } catch (e) {
3100
+ (typeof console === "object"
3101
+ && console.warn
3102
+ && console.warn('svg2pdfjs: Images with external resource link are not supported! ("' + imageUrl + '")'));
3103
+ }
3104
+ };
3105
+
3106
+ // draws a path
3107
+ var path = function (node, tfMatrix, refsHandler, withinClipPath, attributeState) {
3108
+ var list = getPathSegList(node);
3109
+ var markerEnd = node.getAttribute("marker-end"),
3110
+ markerStart = node.getAttribute("marker-start"),
3111
+ markerMid = node.getAttribute("marker-mid");
3112
+
3113
+ markerEnd && (markerEnd = iriReference.exec(markerEnd)[1]);
3114
+ markerStart && (markerStart = iriReference.exec(markerStart)[1]);
3115
+ markerMid && (markerMid = iriReference.exec(markerMid)[1]);
3116
+
3117
+ var getLinesFromPath = function () {
3118
+ var x = 0, y = 0;
3119
+ var x0 = x, y0 = y;
3120
+ var prevX, prevY, newX, newY;
3121
+ var to, p, p2, p3;
3122
+ var lines = [];
3123
+ var markers = new MarkerList();
3124
+ var op;
3125
+ var prevAngle = [0, 0], curAngle;
3126
+
3127
+ for (var i = 0; i < list.numberOfItems; i++) {
3128
+ var seg = list.getItem(i);
3129
+ var cmd = seg.pathSegTypeAsLetter;
3130
+ switch (cmd) {
3131
+ case "M":
3132
+ x0 = x;
3133
+ y0 = y;
3134
+ to = [seg.x, seg.y];
3135
+ op = "m";
3136
+ break;
3137
+ case "m":
3138
+ x0 = x;
3139
+ y0 = y;
3140
+ to = [seg.x + x, seg.y + y];
3141
+ op = "m";
3142
+ break;
3143
+ case "L":
3144
+ to = [seg.x, seg.y];
3145
+ op = "l";
3146
+ break;
3147
+ case "l":
3148
+ to = [seg.x + x, seg.y + y];
3149
+ op = "l";
3150
+ break;
3151
+ case "H":
3152
+ to = [seg.x, y];
3153
+ op = "l";
3154
+ newX = seg.x;
3155
+ newY = y;
3156
+ break;
3157
+ case "h":
3158
+ to = [seg.x + x, y];
3159
+ op = "l";
3160
+ newX = seg.x + x;
3161
+ newY = y;
3162
+ break;
3163
+ case "V":
3164
+ to = [x, seg.y];
3165
+ op = "l";
3166
+ newX = x;
3167
+ newY = seg.y;
3168
+ break;
3169
+ case "v":
3170
+ to = [x, seg.y + y];
3171
+ op = "l";
3172
+ newX = x;
3173
+ newY = seg.y + y;
3174
+ break;
3175
+ case "C":
3176
+ p2 = [seg.x1, seg.y1];
3177
+ p3 = [seg.x2, seg.y2];
3178
+ to = [seg.x, seg.y];
3179
+ break;
3180
+ case "c":
3181
+ p2 = [seg.x1 + x, seg.y1 + y];
3182
+ p3 = [seg.x2 + x, seg.y2 + y];
3183
+ to = [seg.x + x, seg.y + y];
3184
+ break;
3185
+ case "S":
3186
+ p2 = getControlPointFromPrevious(i, [x, y], list, prevX, prevY);
3187
+ p3 = [seg.x2, seg.y2];
3188
+ to = [seg.x, seg.y];
3189
+ break;
3190
+ case "s":
3191
+ p2 = getControlPointFromPrevious(i, [x, y], list, prevX, prevY);
3192
+ p3 = [seg.x2 + x, seg.y2 + y];
3193
+ to = [seg.x + x, seg.y + y];
3194
+ break;
3195
+ case "Q":
3196
+ p = [seg.x1, seg.y1];
3197
+ p2 = toCubic([x, y], p);
3198
+ p3 = toCubic([seg.x, seg.y], p);
3199
+ to = [seg.x, seg.y];
3200
+ break;
3201
+ case "q":
3202
+ p = [seg.x1 + x, seg.y1 + y];
3203
+ p2 = toCubic([x, y], p);
3204
+ p3 = toCubic([x + seg.x, y + seg.y], p);
3205
+ to = [seg.x + x, seg.y + y];
3206
+ break;
3207
+ case "T":
3208
+ p = getControlPointFromPrevious(i, [x, y], list, prevX, prevY);
3209
+ p2 = toCubic([x, y], p);
3210
+ p3 = toCubic([seg.x, seg.y], p);
3211
+ to = [seg.x, seg.y];
3212
+ break;
3213
+ case "t":
3214
+ p = getControlPointFromPrevious(i, [x, y], list, prevX, prevY);
3215
+ p2 = toCubic([x, y], p);
3216
+ p3 = toCubic([x + seg.x, y + seg.y], p);
3217
+ to = [seg.x + x, seg.y + y];
3218
+ break;
3219
+ // TODO: A,a
3220
+ case "Z":
3221
+ case "z":
3222
+ x = x0;
3223
+ y = y0;
3224
+ lines.push({op: "h"});
3225
+ break;
3226
+ }
3227
+
3228
+ var hasStartMarker = markerStart
3229
+ && (i === 1
3230
+ || ("mM".indexOf(cmd) < 0 && "mM".indexOf(list.getItem(i - 1).pathSegTypeAsLetter) >= 0));
3231
+ var hasEndMarker = markerEnd
3232
+ && (i === list.numberOfItems - 1
3233
+ || ("mM".indexOf(cmd) < 0 && "mM".indexOf(list.getItem(i + 1).pathSegTypeAsLetter) >= 0));
3234
+ var hasMidMarker = markerMid
3235
+ && i > 0
3236
+ && !(i === 1 && "mM".indexOf(list.getItem(i - 1).pathSegTypeAsLetter) >= 0);
3237
+
3238
+ if ("sScCqQtT".indexOf(cmd) >= 0) {
3239
+ hasStartMarker && markers.addMarker(new Marker(markerStart, [x, y], getAngle([x, y], p2)));
3240
+ hasEndMarker && markers.addMarker(new Marker(markerEnd, to, getAngle(p3, to)));
3241
+ if (hasMidMarker) {
3242
+ curAngle = getDirectionVector([x, y], p2);
3243
+ curAngle = "mM".indexOf(list.getItem(i - 1).pathSegTypeAsLetter) >= 0 ?
3244
+ curAngle : normalize(addVectors(prevAngle, curAngle));
3245
+ markers.addMarker(new Marker(markerMid, [x, y], Math.atan2(curAngle[1], curAngle[0])));
3246
+ }
3247
+
3248
+ prevAngle = getDirectionVector(p3, to);
3249
+
3250
+ prevX = x;
3251
+ prevY = y;
3252
+
3253
+ if (withinClipPath) {
3254
+ p2 = multVecMatrix(p2, tfMatrix);
3255
+ p3 = multVecMatrix(p3, tfMatrix);
3256
+ to = multVecMatrix(to, tfMatrix);
3257
+ }
3258
+
3259
+ lines.push({
3260
+ op: "c", c: [
3261
+ p2[0], p2[1],
3262
+ p3[0], p3[1],
3263
+ to[0], to[1]
3264
+ ]
3265
+ });
3266
+ } else if ("lLhHvVmM".indexOf(cmd) >= 0) {
3267
+ curAngle = getDirectionVector([x, y], to);
3268
+ hasStartMarker && markers.addMarker(new Marker(markerStart, [x, y], Math.atan2(curAngle[1], curAngle[0])));
3269
+ hasEndMarker && markers.addMarker(new Marker(markerEnd, to, Math.atan2(curAngle[1], curAngle[0])));
3270
+ if (hasMidMarker) {
3271
+ var angle = "mM".indexOf(cmd) >= 0 ?
3272
+ prevAngle : "mM".indexOf(list.getItem(i - 1).pathSegTypeAsLetter) >= 0 ?
3273
+ curAngle : normalize(addVectors(prevAngle, curAngle));
3274
+ markers.addMarker(new Marker(markerMid, [x, y], Math.atan2(angle[1], angle[0])));
3275
+ }
3276
+ prevAngle = curAngle;
3277
+
3278
+ if (withinClipPath) {
3279
+ to = multVecMatrix(to, tfMatrix);
3280
+ }
3281
+
3282
+ lines.push({op: op, c: to});
3283
+ }
3284
+
3285
+ if ("MLCSQT".indexOf(cmd) >= 0) {
3286
+ x = seg.x;
3287
+ y = seg.y;
3288
+ } else if ("mlcsqt".indexOf(cmd) >= 0) {
3289
+ x = seg.x + x;
3290
+ y = seg.y + y;
3291
+ } else if ("zZ".indexOf(cmd) < 0) {
3292
+ x = newX;
3293
+ y = newY;
3294
+ }
3295
+ }
3296
+
3297
+ return {lines: lines, markers: markers};
3298
+ };
3299
+ var lines = getLinesFromPath();
3300
+
3301
+ if (lines.lines.length > 0) {
3302
+ _pdf.path(lines.lines);
3303
+ }
3304
+
3305
+ if (markerEnd || markerStart || markerMid) {
3306
+ lines.markers.draw(_pdf.unitMatrix, refsHandler, attributeState);
3307
+ }
3308
+ };
3309
+
3310
+ // draws the element referenced by a use node, makes use of pdf's XObjects/FormObjects so nodes are only written once
3311
+ // to the pdf document. This highly reduces the file size and computation time.
3312
+ var use = function (node, tfMatrix, refsHandler) {
3313
+ var url = (node.getAttribute("href") || node.getAttribute("xlink:href"));
3314
+ // just in case someone has the idea to use empty use-tags, wtf???
3315
+ if (!url)
3316
+ return;
3317
+
3318
+ // get the size of the referenced form object (to apply the correct scaling)
3319
+ var id = url.substring(1);
3320
+ refsHandler.getRendered(id);
3321
+ var formObject = _pdf.getFormObject(id);
3322
+
3323
+ // scale and position it right
3324
+ var x = node.getAttribute("x") || 0;
3325
+ var y = node.getAttribute("y") || 0;
3326
+ var width = node.getAttribute("width") || formObject.width;
3327
+ var height = node.getAttribute("height") || formObject.height;
3328
+ var t = new _pdf.Matrix(width / formObject.width || 0, 0, 0, height / formObject.height || 0, x, y);
3329
+ t = _pdf.matrixMult(t, tfMatrix);
3330
+ _pdf.doFormObject(id, t);
3331
+ };
3332
+
3333
+ // draws a line
3334
+ var line = function (node, refsHandler, attributeState) {
3335
+ var p1 = [parseFloat(node.getAttribute('x1') || 0), parseFloat(node.getAttribute('y1') || 0)];
3336
+ var p2 = [parseFloat(node.getAttribute('x2') || 0), parseFloat(node.getAttribute('y2') || 0)];
3337
+
3338
+ if (attributeState.stroke !== null){
3339
+ _pdf.line(p1[0], p1[1], p2[0], p2[1]);
3340
+ }
3341
+
3342
+ var markerStart = node.getAttribute("marker-start"),
3343
+ markerEnd = node.getAttribute("marker-end");
3344
+
3345
+ if (markerStart || markerEnd) {
3346
+ var markers = new MarkerList();
3347
+ var angle = getAngle(p1, p2);
3348
+ if (markerStart) {
3349
+ markers.addMarker(new Marker(iriReference.exec(markerStart)[1], p1, angle));
3350
+ }
3351
+ if (markerEnd) {
3352
+ markers.addMarker(new Marker(iriReference.exec(markerEnd)[1], p2, angle));
3353
+ }
3354
+ markers.draw(_pdf.unitMatrix, refsHandler, attributeState);
3355
+ }
3356
+ };
3357
+
3358
+ // draws a rect
3359
+ var rect = function (node) {
3360
+ _pdf.roundedRect(
3361
+ parseFloat(node.getAttribute('x')) || 0,
3362
+ parseFloat(node.getAttribute('y')) || 0,
3363
+ parseFloat(node.getAttribute('width')),
3364
+ parseFloat(node.getAttribute('height')),
3365
+ parseFloat(node.getAttribute('rx')) || 0,
3366
+ parseFloat(node.getAttribute('ry')) || 0
3367
+ );
3368
+ };
3369
+
3370
+ // draws an ellipse
3371
+ var ellipse = function (node) {
3372
+ _pdf.ellipse(
3373
+ parseFloat(node.getAttribute('cx')) || 0,
3374
+ parseFloat(node.getAttribute('cy')) || 0,
3375
+ parseFloat(node.getAttribute('rx')),
3376
+ parseFloat(node.getAttribute('ry'))
3377
+ );
3378
+ };
3379
+
3380
+ // draws a circle
3381
+ var circle = function (node) {
3382
+ var radius = parseFloat(node.getAttribute('r')) || 0;
3383
+ _pdf.ellipse(
3384
+ parseFloat(node.getAttribute('cx')) || 0,
3385
+ parseFloat(node.getAttribute('cy')) || 0,
3386
+ radius,
3387
+ radius
3388
+ );
3389
+ };
3390
+
3391
+ // applies text transformations to a text node
3392
+ var transformText = function (node, text) {
3393
+ var textTransform = getAttribute(node, "text-transform");
3394
+ switch (textTransform) {
3395
+ case "uppercase": return text.toUpperCase();
3396
+ case "lowercase": return text.toLowerCase();
3397
+ default: return text;
3398
+ // TODO: capitalize, full-width
3399
+ }
3400
+ };
3401
+
3402
+ /**
3403
+ * Canvas text measuring is a lot faster than svg measuring. However, it is inaccurate for some fonts. So test each
3404
+ * font once and decide if canvas is accurate enough.
3405
+ * @param {string} text
3406
+ * @param {string} fontFamily
3407
+ * @returns {function(string, string, string, string, string)}
3408
+ */
3409
+ var getMeasureFunction = (function getMeasureFunction() {
3410
+ /**
3411
+ * @param {string} text
3412
+ * @param {string} fontFamily
3413
+ * @param {string} fontSize
3414
+ * @param {string} fontStyle
3415
+ * @param {string} fontWeight
3416
+ */
3417
+ function canvasTextMeasure(text, fontFamily, fontSize, fontStyle, fontWeight) {
3418
+ var canvas = document.createElement("canvas");
3419
+ var context = canvas.getContext("2d");
3420
+
3421
+ context.font = [fontStyle, fontWeight, fontSize, fontFamily].join(" ");
3422
+ return context.measureText(text).width;
3423
+ }
3424
+
3425
+ /**
3426
+ * @param {string} text
3427
+ * @param {string} fontFamily
3428
+ * @param {string} fontSize
3429
+ * @param {string} fontStyle
3430
+ * @param {string} fontWeight
3431
+ */
3432
+ function svgTextMeasure(text, fontFamily, fontSize, fontStyle, fontWeight) {
3433
+ var textNode = document.createElementNS(svgNamespaceURI, "text");
3434
+ textNode.setAttribute("font-family", fontFamily);
3435
+ textNode.setAttribute("font-size", fontSize);
3436
+ textNode.setAttribute("font-style", fontStyle);
3437
+ textNode.setAttribute("font-weight", fontWeight);
3438
+ textNode.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve");
3439
+ textNode.appendChild(document.createTextNode(text));
3440
+
3441
+ var svg = document.createElementNS(svgNamespaceURI, "svg");
3442
+ svg.appendChild(textNode);
3443
+ svg.setAttribute("visibility", "hidden");
3444
+ document.body.appendChild(svg);
3445
+
3446
+ var width = textNode.getBBox().width;
3447
+
3448
+ document.body.removeChild(svg);
3449
+
3450
+ return width;
3451
+ }
3452
+
3453
+ var testString = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789!\"$%&/()=?'\\+*-_.:,;^}][{#~|<>";
3454
+ var epsilon = 0.1;
3455
+ var measureMethods = {};
3456
+
3457
+ return function getMeasureFunction(fontFamily) {
3458
+ var method = measureMethods[fontFamily];
3459
+ if (!method) {
3460
+ var fontSize = "16px";
3461
+ var fontStyle = "normal";
3462
+ var fontWeight = "normal";
3463
+ var canvasWidth = canvasTextMeasure(testString, fontFamily, fontSize, fontStyle, fontWeight);
3464
+ var svgWidth = svgTextMeasure(testString, fontFamily, fontSize, fontStyle, fontWeight);
3465
+
3466
+ method = Math.abs(canvasWidth - svgWidth) < epsilon ? canvasTextMeasure : svgTextMeasure;
3467
+
3468
+ measureMethods[fontFamily] = method;
3469
+ }
3470
+
3471
+ return method;
3472
+ }
3473
+ })();
3474
+
3475
+ /**
3476
+ * @param {string} text
3477
+ * @param {AttributeState} attributeState
3478
+ * @returns {number}
3479
+ */
3480
+ function measureTextWidth(text, attributeState) {
3481
+ if (text.length === 0) {
3482
+ return 0;
3483
+ }
3484
+
3485
+ var fontFamily = attributeState.fontFamily;
3486
+ var measure = getMeasureFunction(fontFamily);
3487
+
3488
+ return measure(text, attributeState.fontFamily, attributeState.fontSize + "px", attributeState.fontStyle, attributeState.fontWeight);
3489
+ }
3490
+
3491
+ /**
3492
+ * @param {string} text
3493
+ * @param {AttributeState} attributeState
3494
+ * @returns {number}
3495
+ */
3496
+ function getTextOffset(text, attributeState) {
3497
+ var textAnchor = attributeState.textAnchor;
3498
+ if (textAnchor === "start") {
3499
+ return 0;
3500
+ }
3501
+
3502
+ var width = measureTextWidth(text, attributeState);
3503
+
3504
+ var xOffset = 0;
3505
+ switch (textAnchor) {
3506
+ case "end":
3507
+ xOffset = width;
3508
+ break;
3509
+ case "middle":
3510
+ xOffset = width / 2;
3511
+ break;
3512
+ }
3513
+
3514
+ return xOffset;
3515
+ }
3516
+
3517
+ /**
3518
+ * @param {string} textAnchor
3519
+ * @param {number} originX
3520
+ * @param {number} originY
3521
+ * @constructor
3522
+ */
3523
+ function TextChunk(textAnchor, originX, originY) {
3524
+ this.texts = [];
3525
+ this.textNodes = [];
3526
+ this.textAnchor = textAnchor;
3527
+ this.originX = originX;
3528
+ this.originY = originY;
3529
+ }
3530
+
3531
+ /**
3532
+ * @param {SVGElement} tSpan
3533
+ * @param {string} text
3534
+ */
3535
+ TextChunk.prototype.add = function(tSpan, text) {
3536
+ this.texts.push(text);
3537
+ this.textNodes.push(tSpan);
3538
+ };
3539
+ /**
3540
+ * Outputs the chunk to pdf.
3541
+ * @param {jsPDF.Matrix} transform
3542
+ * @param {AttributeState} attributeState
3543
+ * @returns {[number, number]} The last current text position.
3544
+ */
3545
+ TextChunk.prototype.put = function (transform, attributeState) {
3546
+ var i, textNode;
3547
+
3548
+ var xs = [], ys = [], attributeStates = [];
3549
+ var currentTextX = this.originX, currentTextY = this.originY;
3550
+ var minX = currentTextX, maxX = currentTextX;
3551
+ for (i = 0; i < this.textNodes.length; i++) {
3552
+ textNode = this.textNodes[i];
3553
+
3554
+ var x = currentTextX;
3555
+ var y = currentTextY;
3556
+
3557
+ if (textNode.nodeName === "#text") {
3558
+ textNodeAttributeState = attributeState
3559
+ } else {
3560
+ var textNodeAttributeState = attributeState.clone();
3561
+ var tSpanColor = getAttribute(textNode, "fill");
3562
+ setTextProperties(textNode, tSpanColor && new RGBColor(tSpanColor), textNodeAttributeState);
3563
+
3564
+ var tSpanDx = textNode.getAttribute("dx");
3565
+ if (tSpanDx !== null) {
3566
+ x += toPixels(tSpanDx, textNodeAttributeState.fontSize);
3567
+ }
3568
+
3569
+ var tSpanDy = textNode.getAttribute("dy");
3570
+ if (tSpanDy !== null) {
3571
+ y += toPixels(tSpanDy, textNodeAttributeState.fontSize);
3572
+ }
3573
+ }
3574
+
3575
+ attributeStates[i] = textNodeAttributeState;
3576
+
3577
+ xs[i] = x;
3578
+ ys[i] = y;
3579
+
3580
+ currentTextX = x + measureTextWidth(this.texts[i], textNodeAttributeState);
3581
+
3582
+ currentTextY = y;
3583
+
3584
+ minX = Math.min(minX, x);
3585
+ maxX = Math.max(maxX, currentTextX);
3586
+ }
3587
+
3588
+ var textOffset;
3589
+ switch (this.textAnchor) {
3590
+ case "start": textOffset = 0; break;
3591
+ case "middle": textOffset = (maxX - minX) / 2; break;
3592
+ case "end": textOffset = maxX - minX; break;
3593
+ }
3594
+
3595
+ for (i = 0; i < this.textNodes.length; i++) {
3596
+ textNode = this.textNodes[i];
3597
+
3598
+ if (textNode.nodeName !== "#text") {
3599
+ var tSpanVisibility = getAttribute(textNode, "visibility") || attributeState.visibility;
3600
+ if (tSpanVisibility === "hidden") {
3601
+ continue;
3602
+ }
3603
+ }
3604
+
3605
+ _pdf.saveGraphicsState();
3606
+ putTextProperties(attributeStates[i], attributeState);
3607
+
3608
+ _pdf.text(xs[i] - textOffset, ys[i], this.texts[i], void 0, transform);
3609
+
3610
+ _pdf.restoreGraphicsState();
3611
+ }
3612
+
3613
+ return [currentTextX, currentTextY];
3614
+ };
3615
+
3616
+ /**
3617
+ * Convert em, px and bare number attributes to pixel values
3618
+ * @param {string} value
3619
+ * @param {number} pdfFontSize
3620
+ */
3621
+ function toPixels(value, pdfFontSize) {
3622
+ var match;
3623
+
3624
+ // em
3625
+ match = value && value.toString().match(/^([\-0-9.]+)em$/);
3626
+ if (match) {
3627
+ return parseFloat(match[1]) * pdfFontSize;
3628
+ }
3629
+
3630
+ // pixels
3631
+ match = value && value.toString().match(/^([\-0-9.]+)(px|)$/);
3632
+ if (match) {
3633
+ return parseFloat(match[1]);
3634
+ }
3635
+ return 0;
3636
+ }
3637
+
3638
+
3639
+ function transformXmlSpace(trimmedText, attributeState) {
3640
+ trimmedText = removeNewlines(trimmedText);
3641
+ trimmedText = replaceTabsBySpace(trimmedText);
3642
+
3643
+ if (attributeState.xmlSpace === "default") {
3644
+ trimmedText = trimmedText.trim();
3645
+ trimmedText = consolidateSpaces(trimmedText);
3646
+ }
3647
+
3648
+ return trimmedText;
3649
+ }
3650
+
3651
+ /**
3652
+ * Draws a text element and its tspan children.
3653
+ * @param {SVGElement} node
3654
+ * @param {jsPDF.Matrix} tfMatrix
3655
+ * @param {boolean} hasFillColor
3656
+ * @param {RGBColor} fillRGB
3657
+ * @param {AttributeState} attributeState
3658
+ */
3659
+ var text = function (node, tfMatrix, hasFillColor, fillRGB, attributeState) {
3660
+ _pdf.saveGraphicsState();
3661
+
3662
+ var dx, dy, xOffset = 0;
3663
+
3664
+ var pdfFontSize = _pdf.getFontSize();
3665
+ var textX = toPixels(node.getAttribute('x'), pdfFontSize);
3666
+ var textY = toPixels(node.getAttribute('y'), pdfFontSize);
3667
+
3668
+ dx = toPixels(node.getAttribute("dx"), pdfFontSize);
3669
+ dy = toPixels(node.getAttribute("dy"), pdfFontSize);
3670
+
3671
+ var visibility = attributeState.visibility;
3672
+ // when there are no tspans draw the text directly
3673
+ var tSpanCount = node.childElementCount;
3674
+ if (tSpanCount === 0) {
3675
+ var trimmedText = transformXmlSpace(node.textContent, attributeState);
3676
+ var transformedText = transformText(node, trimmedText);
3677
+ xOffset = getTextOffset(transformedText, attributeState);
3678
+
3679
+ if (visibility === "visible") {
3680
+ _pdf.text(
3681
+ textX + dx - xOffset,
3682
+ textY + dy,
3683
+ transformedText,
3684
+ void 0,
3685
+ tfMatrix
3686
+ );
3687
+ }
3688
+ } else {
3689
+ // otherwise loop over tspans and position each relative to the previous one
3690
+ var currentTextSegment = new TextChunk(attributeState.textAnchor, textX + dx, textY + dy);
3691
+
3692
+ for (var i = 0; i < node.childNodes.length; i++) {
3693
+ var textNode = node.childNodes[i];
3694
+ if (!textNode.textContent) {
3695
+ continue;
3696
+ }
3697
+
3698
+ var xmlSpace = attributeState.xmlSpace;
3699
+
3700
+ if (textNode.nodeName === "#text") {
3701
+
3702
+ } else if (nodeIs(textNode, "tspan")) {
3703
+ var tSpan = textNode;
3704
+
3705
+ var lastPositions;
3706
+
3707
+ var tSpanAbsX = tSpan.getAttribute("x");
3708
+ if (tSpanAbsX !== null) {
3709
+ var x = toPixels(tSpanAbsX, pdfFontSize);
3710
+
3711
+ lastPositions = currentTextSegment.put(tfMatrix, attributeState);
3712
+ currentTextSegment = new TextChunk(tSpan.getAttribute("text-anchor") || attributeState.textAnchor, x, lastPositions[1]);
3713
+ }
3714
+
3715
+ var tSpanAbsY = tSpan.getAttribute("y");
3716
+ if (tSpanAbsY !== null) {
3717
+ var y = toPixels(tSpanAbsY, pdfFontSize);
3718
+
3719
+ lastPositions = currentTextSegment.put(tfMatrix, attributeState);
3720
+ currentTextSegment = new TextChunk(tSpan.getAttribute("text-anchor") || attributeState.textAnchor, lastPositions[0], y);
3721
+ }
3722
+
3723
+ var tSpanXmlSpace = tSpan.getAttribute("xml:space");
3724
+ if (tSpanXmlSpace) {
3725
+ xmlSpace = tSpanXmlSpace;
3726
+ }
3727
+ }
3728
+
3729
+ trimmedText = textNode.textContent;
3730
+ trimmedText = removeNewlines(trimmedText);
3731
+ trimmedText = replaceTabsBySpace(trimmedText);
3732
+
3733
+ if (xmlSpace === "default") {
3734
+ if (i === 0) {
3735
+ trimmedText = trimLeft(trimmedText);
3736
+ }
3737
+ if (i === tSpanCount - 1) {
3738
+ trimmedText = trimRight(trimmedText);
3739
+ }
3740
+
3741
+ trimmedText = consolidateSpaces(trimmedText);
3742
+ }
3743
+
3744
+ transformedText = transformText(node, trimmedText);
3745
+ currentTextSegment.add(textNode, transformedText);
3746
+ }
3747
+
3748
+ currentTextSegment.put(tfMatrix, attributeState);
3749
+ }
3750
+
3751
+ _pdf.restoreGraphicsState();
3752
+ };
3753
+
3754
+ // renders all children of a node
3755
+ var renderChildren = function (node, tfMatrix, refsHandler, withinDefs, withinClipPath, attributeState) {
3756
+ forEachChild(node, function (i, node) {
3757
+ renderNode(node, tfMatrix, refsHandler, withinDefs, withinClipPath, attributeState);
3758
+ });
3759
+ };
3760
+
3761
+ // adds a gradient to defs and the pdf document for later use, type is either "axial" or "radial"
3762
+ // opacity is only supported rudimentary by averaging over all stops
3763
+ // transforms are applied on use
3764
+ var putGradient = function (node, type, coords) {
3765
+ var colors = [];
3766
+ var opacitySum = 0;
3767
+ var hasOpacity = false;
3768
+ var gState;
3769
+ forEachChild(node, function (i, element) {
3770
+ // since opacity gradients are hard to realize, average the opacity over the control points
3771
+ if (element.tagName.toLowerCase() === "stop") {
3772
+ var color = new RGBColor(getAttribute(element, "stop-color"));
3773
+ colors.push({
3774
+ offset: parseFloat(element.getAttribute("offset")),
3775
+ color: [color.r, color.g, color.b]
3776
+ });
3777
+ var opacity = getAttribute(element, "stop-opacity");
3778
+ if (opacity && opacity != 1) {
3779
+ opacitySum += parseFloat(opacity);
3780
+ hasOpacity = true;
3781
+ }
3782
+ }
3783
+ });
3784
+
3785
+ if (hasOpacity) {
3786
+ gState = new _pdf.GState({opacity: opacitySum / colors.length});
3787
+ }
3788
+
3789
+ var pattern = new _pdf.ShadingPattern(type, coords, colors, gState);
3790
+ var id = node.getAttribute("id");
3791
+ _pdf.addShadingPattern(id, pattern);
3792
+ };
3793
+
3794
+ var pattern = function (node, refsHandler, attributeState) {
3795
+ var id = node.getAttribute("id");
3796
+
3797
+ // the transformations directly at the node are written to the pattern transformation matrix
3798
+ var bBox = getUntransformedBBox(node);
3799
+ var pattern = new _pdf.TilingPattern([bBox[0], bBox[1], bBox[0] + bBox[2], bBox[1] + bBox[3]], bBox[2], bBox[3],
3800
+ null, _pdf.unitMatrix /* this parameter is ignored !*/);
3801
+
3802
+ _pdf.beginTilingPattern(pattern);
3803
+ // continue without transformation
3804
+ renderChildren(node, _pdf.unitMatrix, refsHandler, false, false, attributeState);
3805
+ _pdf.endTilingPattern(id, pattern);
3806
+ };
3807
+
3808
+ var fontAliases = {
3809
+ "sans-serif": "helvetica",
3810
+ "verdana": "helvetica",
3811
+ "arial": "helvetica",
3812
+
3813
+ "fixed": "courier",
3814
+ "monospace": "courier",
3815
+ "terminal": "courier",
3816
+
3817
+ "serif": "times",
3818
+ "cursive": "times",
3819
+ "fantasy": "times"
3820
+ };
3821
+
3822
+ /**
3823
+ * @param {AttributeState} attributeState
3824
+ * @param {string[]} fontFamilies
3825
+ * @return {string}
3826
+ */
3827
+ function findFirstAvailableFontFamily(attributeState, fontFamilies) {
3828
+ var fontType = "";
3829
+ if (attributeState.fontWeight === "bold") {
3830
+ fontType = "bold";
3831
+ }
3832
+ if (attributeState.fontStyle === "italic") {
3833
+ fontType += "italic";
3834
+ }
3835
+ if (fontType === "") {
3836
+ fontType = "normal";
3837
+ }
3838
+
3839
+ var availableFonts = _pdf.getFontList();
3840
+ var firstAvailable = "";
3841
+ var fontIsAvailable = fontFamilies.some(function (font) {
3842
+ var availableStyles = availableFonts[font];
3843
+ if (availableStyles && availableStyles.indexOf(fontType) >= 0) {
3844
+ firstAvailable = font;
3845
+ return true;
3846
+ }
3847
+
3848
+ font = font.toLowerCase();
3849
+ if (fontAliases.hasOwnProperty(font)) {
3850
+ firstAvailable = font;
3851
+ return true;
3852
+ }
3853
+
3854
+ return false;
3855
+ });
3856
+
3857
+ if (!fontIsAvailable) {
3858
+ firstAvailable = "times";
3859
+ }
3860
+
3861
+ return firstAvailable;
3862
+ }
3863
+
3864
+ function setTextProperties(node, fillRGB, attributeState) {
3865
+ if (fillRGB && fillRGB.ok) {
3866
+ attributeState.fill = fillRGB;
3867
+ }
3868
+
3869
+ var fontWeight = getAttribute(node, "font-weight");
3870
+ if (fontWeight) {
3871
+ attributeState.fontWeight = fontWeight;
3872
+ }
3873
+
3874
+ var fontStyle = getAttribute(node, "font-style");
3875
+ if (fontStyle) {
3876
+ attributeState.fontStyle = fontStyle;
3877
+ }
3878
+
3879
+ var fontFamily = getAttribute(node, "font-family");
3880
+ if (fontFamily) {
3881
+ var fontFamilies = FontFamily.parse(fontFamily);
3882
+ attributeState.fontFamily = findFirstAvailableFontFamily(attributeState, fontFamilies);
3883
+ }
3884
+
3885
+ var fontSize = getAttribute(node, "font-size");
3886
+ if (fontSize) {
3887
+ attributeState.fontSize = parseFloat(fontSize);
3888
+ }
3889
+
3890
+ var textAnchor = getAttribute(node, "text-anchor");
3891
+ if (textAnchor) {
3892
+ attributeState.textAnchor = textAnchor;
3893
+ }
3894
+ }
3895
+
3896
+ /**
3897
+ * @param {AttributeState} attributeState
3898
+ * @param {AttributeState} parentAttributeState
3899
+ */
3900
+ function putTextProperties(attributeState, parentAttributeState) {
3901
+ if (attributeState.fontFamily !== parentAttributeState.fontFamily) {
3902
+ if (fontAliases.hasOwnProperty(attributeState.fontFamily)) {
3903
+ _pdf.setFont(fontAliases[attributeState.fontFamily]);
3904
+ } else {
3905
+ _pdf.setFont(attributeState.fontFamily);
3906
+ }
3907
+ }
3908
+
3909
+ if (attributeState.fill !== parentAttributeState.fill && attributeState.fill.ok) {
3910
+ var fillRGB = attributeState.fill;
3911
+ _pdf.setTextColor(fillRGB.r, fillRGB.g, fillRGB.b);
3912
+ }
3913
+
3914
+ if (attributeState.fontWeight !== parentAttributeState.fontWeight
3915
+ || attributeState.fontStyle !== parentAttributeState.fontStyle) {
3916
+ var fontType = "";
3917
+ if (attributeState.fontWeight === "bold") {
3918
+ fontType = "bold";
3919
+ }
3920
+ if (attributeState.fontStyle === "italic") {
3921
+ fontType += "italic";
3922
+ }
3923
+
3924
+ if (fontType === "") {
3925
+ fontType = "normal";
3926
+ }
3927
+
3928
+ _pdf.setFontType(fontType);
3929
+ }
3930
+
3931
+ if (attributeState.fontSize !== parentAttributeState.fontSize) {
3932
+ _pdf.setFontSize(attributeState.fontSize);
3933
+ }
3934
+ }
3935
+
3936
+
3937
+ /**
3938
+ * Renders a svg node.
3939
+ * @param node The svg element
3940
+ * @param contextTransform The current transformation matrix
3941
+ * @param refsHandler The handler that will render references on demand
3942
+ * @param withinDefs True iff we are top-level within a defs node, so the target can be switched to an pdf form object
3943
+ * @param {boolean} withinClipPath
3944
+ * @param {AttributeState} attributeState Keeps track of parent attributes that are inherited automatically
3945
+ */
3946
+ var renderNode = function (node, contextTransform, refsHandler, withinDefs, withinClipPath, attributeState) {
3947
+ var parentAttributeState = attributeState;
3948
+ attributeState = attributeState.clone();
3949
+
3950
+ if (nodeIs(node, "defs,clippath,pattern,lineargradient,radialgradient,marker")) {
3951
+ // we will only render them on demand
3952
+ return;
3953
+ }
3954
+
3955
+ if (getAttribute(node, "display") === "none") {
3956
+ return;
3957
+ }
3958
+
3959
+ var visibility = attributeState.visibility = getAttribute(node, "visibility") || attributeState.visibility;
3960
+ if (visibility === "hidden" && !nodeIs(node, "svg,g,marker,a,pattern,defs,text")) {
3961
+ return;
3962
+ }
3963
+
3964
+ var tfMatrix,
3965
+ hasFillColor = false,
3966
+ fillRGB = null,
3967
+ fill = "inherit",
3968
+ stroke = "inherit",
3969
+ patternOrGradient = undefined,
3970
+ bBox;
3971
+
3972
+ //
3973
+ // Decide about the render target and set the correct transformation
3974
+ //
3975
+
3976
+ // if we are within a defs node, start a new pdf form object and draw this node and all children on that instead
3977
+ // of the top-level page
3978
+ var targetIsFormObject = withinDefs && !nodeIs(node, "lineargradient,radialgradient,pattern,clippath");
3979
+ if (targetIsFormObject) {
3980
+
3981
+ // the transformations directly at the node are written to the pdf form object transformation matrix
3982
+ tfMatrix = computeNodeTransform(node);
3983
+ bBox = getUntransformedBBox(node);
3984
+
3985
+ _pdf.beginFormObject(bBox[0], bBox[1], bBox[2], bBox[3], tfMatrix);
3986
+
3987
+ // continue without transformation and set withinDefs to false to prevent child nodes from starting new form objects
3988
+ tfMatrix = _pdf.unitMatrix;
3989
+ withinDefs = false;
3990
+
3991
+ } else {
3992
+ tfMatrix = _pdf.matrixMult(computeNodeTransform(node), contextTransform);
3993
+
3994
+ if (!withinClipPath) {
3995
+ _pdf.saveGraphicsState();
3996
+ }
3997
+ }
3998
+
3999
+ var hasClipPath = node.hasAttribute("clip-path") && node.getAttribute("clip-path") !== "none";
4000
+ if (hasClipPath) {
4001
+ var clipPathId = iriReference.exec(node.getAttribute("clip-path"));
4002
+ var clipPathNode = refsHandler.getRendered(clipPathId[1]);
4003
+
4004
+ var clipPathMatrix = tfMatrix;
4005
+ if (clipPathNode.hasAttribute("clipPathUnits")
4006
+ && clipPathNode.getAttribute("clipPathUnits").toLowerCase() === "objectboundingbox") {
4007
+ bBox = getUntransformedBBox(node);
4008
+ clipPathMatrix = _pdf.matrixMult(new _pdf.Matrix(bBox[2], 0, 0, bBox[3], bBox[0], bBox[1]), clipPathMatrix);
4009
+ }
4010
+
4011
+ // here, browsers show different results for a "transform" attribute on the clipPath element itself:
4012
+ // IE/Edge considers it, Chrome and Firefox ignore it. However, the specification lists "transform" as a valid
4013
+ // attribute for clipPath elements, although not explicitly explaining its behavior. This implementation follows
4014
+ // IE/Edge and considers the "transform" attribute as additional transformation within the coordinate system
4015
+ // established by the "clipPathUnits" attribute.
4016
+ clipPathMatrix = _pdf.matrixMult(computeNodeTransform(clipPathNode), clipPathMatrix);
4017
+
4018
+ _pdf.saveGraphicsState();
4019
+ _pdf.setCurrentTransformationMatrix(clipPathMatrix);
4020
+
4021
+ renderChildren(clipPathNode, _pdf.unitMatrix, refsHandler, false, true, attributeState);
4022
+ _pdf.clip().discardPath();
4023
+
4024
+ // as we cannot use restoreGraphicsState() to reset the transform (this would reset the clipping path, as well),
4025
+ // we must append the inverse instead
4026
+ _pdf.setCurrentTransformationMatrix(clipPathMatrix.inversed());
4027
+ }
4028
+
4029
+ //
4030
+ // extract fill and stroke mode
4031
+ //
4032
+
4033
+ // fill mode
4034
+ if (nodeIs(node, "g,path,rect,text,ellipse,line,circle,polygon,polyline")) {
4035
+ function setDefaultColor() {
4036
+ fillRGB = new RGBColor("rgb(0, 0, 0)");
4037
+ hasFillColor = true;
4038
+ fill = true;
4039
+ }
4040
+
4041
+ var fillColor = getAttribute(node, "fill");
4042
+ if (fillColor) {
4043
+ var url = iriReference.exec(fillColor);
4044
+ if (url) {
4045
+ // probably a gradient or pattern (or something unsupported)
4046
+ var fillUrl = url[1];
4047
+ var fillNode = refsHandler.getRendered(fillUrl);
4048
+ if (fillNode && nodeIs(fillNode, "lineargradient,radialgradient")) {
4049
+
4050
+ // matrix to convert between gradient space and user space
4051
+ // for "userSpaceOnUse" this is the current transformation: tfMatrix
4052
+ // for "objectBoundingBox" or default, the gradient gets scaled and transformed to the bounding box
4053
+ var gradientUnitsMatrix;
4054
+ if (!fillNode.hasAttribute("gradientUnits")
4055
+ || fillNode.getAttribute("gradientUnits").toLowerCase() === "objectboundingbox") {
4056
+ bBox || (bBox = getUntransformedBBox(node));
4057
+ gradientUnitsMatrix = new _pdf.Matrix(bBox[2], 0, 0, bBox[3], bBox[0], bBox[1]);
4058
+ } else {
4059
+ gradientUnitsMatrix = _pdf.unitMatrix;
4060
+ }
4061
+
4062
+ // matrix that is applied to the gradient before any other transformations
4063
+ var gradientTransform = parseTransform(fillNode.getAttribute("gradientTransform"));
4064
+
4065
+ patternOrGradient = {
4066
+ key: fillUrl,
4067
+ matrix: _pdf.matrixMult(gradientTransform, gradientUnitsMatrix)
4068
+ };
4069
+
4070
+ fill = true;
4071
+ } else if (fillNode && nodeIs(fillNode, "pattern")) {
4072
+ var fillBBox, y, width, height, x;
4073
+ patternOrGradient = { key: fillUrl };
4074
+
4075
+ var patternUnitsMatrix = _pdf.unitMatrix;
4076
+ if (!fillNode.hasAttribute("patternUnits")
4077
+ || fillNode.getAttribute("patternUnits").toLowerCase() === "objectboundingbox") {
4078
+ bBox || (bBox = getUntransformedBBox(node));
4079
+ patternUnitsMatrix = new _pdf.Matrix(1, 0, 0, 1, bBox[0], bBox[1]);
4080
+
4081
+ // TODO: slightly inaccurate (rounding errors? line width bBoxes?)
4082
+ fillBBox = getUntransformedBBox(fillNode);
4083
+ x = fillBBox[0] * bBox[0];
4084
+ y = fillBBox[1] * bBox[1];
4085
+ width = fillBBox[2] * bBox[2];
4086
+ height = fillBBox[3] * bBox[3];
4087
+ patternOrGradient.boundingBox = [x, y, x + width, y + height];
4088
+ patternOrGradient.xStep = width;
4089
+ patternOrGradient.yStep = height;
4090
+ }
4091
+
4092
+ var patternContentUnitsMatrix = _pdf.unitMatrix;
4093
+ if (fillNode.hasAttribute("patternContentUnits")
4094
+ && fillNode.getAttribute("patternContentUnits").toLowerCase() === "objectboundingbox") {
4095
+ bBox || (bBox = getUntransformedBBox(node));
4096
+ patternContentUnitsMatrix = new _pdf.Matrix(bBox[2], 0, 0, bBox[3], 0, 0);
4097
+
4098
+ fillBBox = patternOrGradient.boundingBox || getUntransformedBBox(fillNode);
4099
+ x = fillBBox[0] / bBox[0];
4100
+ y = fillBBox[1] / bBox[1];
4101
+ width = fillBBox[2] / bBox[2];
4102
+ height = fillBBox[3] / bBox[3];
4103
+ patternOrGradient.boundingBox = [x, y, x + width, y + height];
4104
+ patternOrGradient.xStep = width;
4105
+ patternOrGradient.yStep = height;
4106
+ }
4107
+
4108
+ var patternTransformMatrix = _pdf.unitMatrix;
4109
+ if (fillNode.hasAttribute("patternTransform")) {
4110
+ patternTransformMatrix = parseTransform(fillNode.getAttribute("patternTransform"));
4111
+ }
4112
+
4113
+ var matrix = patternContentUnitsMatrix;
4114
+ matrix = _pdf.matrixMult(matrix, patternUnitsMatrix);
4115
+ matrix = _pdf.matrixMult(matrix, patternTransformMatrix);
4116
+ matrix = _pdf.matrixMult(matrix, tfMatrix);
4117
+
4118
+ patternOrGradient.matrix = matrix;
4119
+
4120
+ fill = true;
4121
+ } else {
4122
+ // unsupported fill argument -> fill black
4123
+ setDefaultColor();
4124
+ }
4125
+ } else {
4126
+ // plain color
4127
+ fillRGB = parseColor(fillColor);
4128
+ if (fillRGB.ok) {
4129
+ hasFillColor = true;
4130
+ fill = true;
4131
+ } else {
4132
+ fill = false;
4133
+ }
4134
+ }
4135
+ }
4136
+
4137
+ // opacity is realized via a pdf graphics state
4138
+ var fillOpacity = 1.0, strokeOpacity = 1.0;
4139
+ var nodeFillOpacity = getAttribute(node, "fill-opacity");
4140
+ if (nodeFillOpacity) {
4141
+ fillOpacity *= parseFloat(nodeFillOpacity);
4142
+ }
4143
+ if (fillRGB && typeof fillRGB.a === "number") {
4144
+ fillOpacity *= fillRGB.a;
4145
+ }
4146
+
4147
+ var nodeStrokeOpacity = getAttribute(node, "stroke-opacity");
4148
+ if (nodeStrokeOpacity) {
4149
+ strokeOpacity *= parseFloat(nodeStrokeOpacity);
4150
+ }
4151
+ if (strokeRGB && typeof strokeRGB.a === "number") {
4152
+ strokeOpacity *= strokeRGB.a;
4153
+ }
4154
+
4155
+ var nodeOpacity = getAttribute(node, "opacity");
4156
+ if (nodeOpacity) {
4157
+ var opacity = parseFloat(nodeOpacity);
4158
+ strokeOpacity *= opacity;
4159
+ fillOpacity *= opacity;
4160
+ }
4161
+
4162
+ var hasFillOpacity = fillOpacity < 1.0;
4163
+ var hasStrokeOpacity = strokeOpacity < 1.0;
4164
+ if (hasFillOpacity || hasStrokeOpacity) {
4165
+ var gState = {};
4166
+ hasFillOpacity && (gState["opacity"] = fillOpacity);
4167
+ hasStrokeOpacity && (gState["stroke-opacity"] = strokeOpacity);
4168
+ _pdf.setGState(new _pdf.GState(gState));
4169
+ }
4170
+
4171
+ }
4172
+
4173
+ if (nodeIs(node, "g,path,rect,ellipse,line,circle,polygon,polyline")) {
4174
+ // text has no fill color, so don't apply it until here
4175
+ if (hasFillColor) {
4176
+ attributeState.fill = fillRGB;
4177
+ _pdf.setFillColor(fillRGB.r, fillRGB.g, fillRGB.b);
4178
+ }
4179
+
4180
+ // stroke mode
4181
+ var strokeColor = getAttribute(node, "stroke");
4182
+ if (strokeColor) {
4183
+ var strokeWidth = getAttribute(node, "stroke-width");
4184
+ if (strokeWidth !== void 0 && strokeWidth !== "") {
4185
+ strokeWidth = Math.abs(parseFloat(strokeWidth));
4186
+ attributeState.strokeWidth = strokeWidth;
4187
+ _pdf.setLineWidth(strokeWidth);
4188
+ } else {
4189
+ // needed for inherited zero width strokes
4190
+ strokeWidth = attributeState.strokeWidth
4191
+ }
4192
+ var strokeRGB = new RGBColor(strokeColor);
4193
+ if (strokeRGB.ok) {
4194
+ attributeState.stroke = strokeRGB;
4195
+ _pdf.setDrawColor(strokeRGB.r, strokeRGB.g, strokeRGB.b);
4196
+
4197
+ // pdf spec states: "A line width of 0 denotes the thinnest line that can be rendered at device resolution:
4198
+ // 1 device pixel wide". SVG, however, does not draw zero width lines.
4199
+ stroke = strokeWidth !== 0;
4200
+ }
4201
+ var lineCap = getAttribute(node, "stroke-linecap");
4202
+ if (lineCap) {
4203
+ _pdf.setLineCap(attributeState.strokeLinecap = lineCap);
4204
+ }
4205
+ var lineJoin = getAttribute(node, "stroke-linejoin");
4206
+ if (lineJoin) {
4207
+ _pdf.setLineJoin(attributeState.strokeLinejoin = lineJoin);
4208
+ }
4209
+ var dashArray = getAttribute(node, "stroke-dasharray");
4210
+ if (dashArray) {
4211
+ dashArray = parseFloats(dashArray);
4212
+ var dashOffset = parseInt(getAttribute(node, "stroke-dashoffset")) || 0;
4213
+ attributeState.strokeDasharray = dashArray;
4214
+ attributeState.strokeDashoffset = dashOffset;
4215
+ _pdf.setLineDashPattern(dashArray, dashOffset);
4216
+ }
4217
+ var miterLimit = getAttribute(node, "stroke-miterlimit");
4218
+ if (miterLimit !== void 0 && miterLimit !== "") {
4219
+ _pdf.setLineMiterLimit(attributeState.strokeMiterlimit = parseFloat(miterLimit));
4220
+ }
4221
+ }
4222
+ }
4223
+
4224
+ // inherit fill and stroke mode if not specified at this node
4225
+ if (fill === "inherit") {
4226
+ fill = attributeState.fill !== null;
4227
+ }
4228
+ if (stroke === "inherit") {
4229
+ stroke = attributeState.stroke !== null;
4230
+ }
4231
+
4232
+ var xmlSpace = node.getAttribute("xml:space");
4233
+ if (xmlSpace) {
4234
+ attributeState.xmlSpace = xmlSpace;
4235
+ }
4236
+
4237
+ setTextProperties(node, fillRGB, attributeState);
4238
+ putTextProperties(attributeState, parentAttributeState);
4239
+
4240
+ // do the actual drawing
4241
+ switch (node.tagName.toLowerCase()) {
4242
+ case 'svg':
4243
+ case 'g':
4244
+ case 'a':
4245
+ renderChildren(node, tfMatrix, refsHandler, withinDefs, false, attributeState);
4246
+ break;
4247
+
4248
+ case 'use':
4249
+ use(node, tfMatrix, refsHandler);
4250
+ break;
4251
+
4252
+ case 'line':
4253
+ if (!withinClipPath) {
4254
+ _pdf.setCurrentTransformationMatrix(tfMatrix);
4255
+ line(node, refsHandler, attributeState);
4256
+ }
4257
+ break;
4258
+
4259
+ case 'rect':
4260
+ if (!withinClipPath) {
4261
+ _pdf.setCurrentTransformationMatrix(tfMatrix);
4262
+ }
4263
+ rect(node);
4264
+ break;
4265
+
4266
+ case 'ellipse':
4267
+ if (!withinClipPath) {
4268
+ _pdf.setCurrentTransformationMatrix(tfMatrix);
4269
+ }
4270
+ ellipse(node);
4271
+ break;
4272
+
4273
+ case 'circle':
4274
+ if (!withinClipPath) {
4275
+ _pdf.setCurrentTransformationMatrix(tfMatrix);
4276
+ }
4277
+ circle(node);
4278
+ break;
4279
+ case 'text':
4280
+ text(node, tfMatrix, hasFillColor, fillRGB, attributeState);
4281
+ break;
4282
+
4283
+ case 'path':
4284
+ if (!withinClipPath) {
4285
+ _pdf.setCurrentTransformationMatrix(tfMatrix);
4286
+ }
4287
+ path(node, tfMatrix, refsHandler, withinClipPath, attributeState);
4288
+ break;
4289
+
4290
+ case 'polygon':
4291
+ case 'polyline':
4292
+ if (!withinClipPath) {
4293
+ _pdf.setCurrentTransformationMatrix(tfMatrix);
4294
+ }
4295
+ polygon(node, refsHandler, attributeState, node.tagName.toLowerCase() === "polygon");
4296
+ break;
4297
+
4298
+ case 'image':
4299
+ _pdf.setCurrentTransformationMatrix(tfMatrix);
4300
+ image(node);
4301
+ break;
4302
+ }
4303
+
4304
+ if (nodeIs(node, "path,rect,ellipse,circle,polygon,polyline") && !withinClipPath) {
4305
+ if (fill && stroke) {
4306
+ _pdf.fillStroke(patternOrGradient);
4307
+ } else if (fill) {
4308
+ _pdf.fill(patternOrGradient);
4309
+ } else if (stroke) {
4310
+ _pdf.stroke();
4311
+ } else {
4312
+ _pdf.discardPath();
4313
+ }
4314
+ }
4315
+
4316
+ // close either the formObject or the graphics context
4317
+ if (targetIsFormObject) {
4318
+ _pdf.endFormObject(node.getAttribute("id"));
4319
+ } else if (!withinClipPath) {
4320
+ _pdf.restoreGraphicsState();
4321
+ }
4322
+
4323
+ if (hasClipPath) {
4324
+ _pdf.restoreGraphicsState();
4325
+ }
4326
+ };
4327
+
4328
+ // the actual svgToPdf function (see above)
4329
+ var svg2pdf = function (element, pdf, options) {
4330
+ _pdf = pdf;
4331
+
4332
+ var k = options.scale || 1.0,
4333
+ xOffset = options.xOffset || 0.0,
4334
+ yOffset = options.yOffset || 0.0;
4335
+
4336
+
4337
+ _pdf.advancedAPI(function () {
4338
+
4339
+ // set offsets and scale everything by k
4340
+ _pdf.saveGraphicsState();
4341
+ _pdf.setCurrentTransformationMatrix(new _pdf.Matrix(k, 0, 0, k, xOffset, yOffset));
4342
+
4343
+ // set default values that differ from pdf defaults
4344
+ var attributeState = AttributeState.default();
4345
+ _pdf.setLineWidth(attributeState.strokeWidth);
4346
+ var fill = attributeState.fill;
4347
+ _pdf.setFillColor(fill.r, fill.g, fill.b);
4348
+ _pdf.setFont(attributeState.fontFamily);
4349
+ _pdf.setFontSize(attributeState.fontSize);
4350
+
4351
+
4352
+ var refsHandler = new ReferencesHandler(element);
4353
+ renderNode(element.cloneNode(true), _pdf.unitMatrix, refsHandler, false, false, attributeState);
4354
+
4355
+ _pdf.restoreGraphicsState();
4356
+
4357
+ });
4358
+
4359
+ return _pdf;
4360
+ };
4361
+
4362
+ if (typeof define === "function" && define.amd) {
4363
+ define(["./rgbcolor", "SvgPath", "font-family", "cssesc"], function (rgbcolor, svgpath, fontFamily, cssesc) {
4364
+ RGBColor = rgbcolor;
4365
+ SvgPath = svgpath;
4366
+ FontFamily = fontFamily;
4367
+ cssEsc = cssesc;
4368
+ return svg2pdf;
4369
+ });
4370
+ } else if (typeof module !== "undefined" && module.exports) {
4371
+ RGBColor = require("./rgbcolor.js");
4372
+ SvgPath = require("SvgPath");
4373
+ FontFamily = require("font-family");
4374
+ cssEsc = require("cssesc");
4375
+ module.exports = svg2pdf;
4376
+ } else {
4377
+ SvgPath = global.SvgPath;
4378
+ RGBColor = global.RGBColor;
4379
+ FontFamily = global.FontFamily;
4380
+ cssEsc = global.cssesc;
4381
+ global.svg2pdf = svg2pdf;
4382
+ // for compatibility reasons
4383
+ global.svgElementToPdf = svg2pdf;
4384
+ }
4385
+ return svg2pdf;
4386
+ }(typeof self !== "undefined" && self || typeof window !== "undefined" && window || this));
4387
+
4388
+ },{"./rgbcolor.js":10,"SvgPath":1,"cssesc":8,"font-family":9}]},{},[11])(11)
4389
+ });
4390
+ //# sourceMappingURL=svg2pdf.js.map