-
Notifications
You must be signed in to change notification settings - Fork 7
/
ssvg.js.map
1 lines (1 loc) · 239 KB
/
ssvg.js.map
1
{"version":3,"sources":["webpack://SSVG/webpack/universalModuleDefinition","webpack://SSVG/webpack/bootstrap","webpack://SSVG/./util/safelogs.ts","webpack://SSVG/./canvasworker/drawingUtils.ts","webpack://SSVG/./node_modules/worker-loader/dist/workers/InlineWorker.js","webpack://SSVG/./frontend/exporter.ts","webpack://SSVG/./frontend/ssvg.ts","webpack://SSVG/./frontend/domhandler.ts","webpack://SSVG/./util/vdom/vdom-manager.ts","webpack://SSVG/./frontend/attrs.ts","webpack://SSVG/./canvasworker/canvasrenderer.ts","webpack://SSVG/./canvasworker/index.ts","webpack://SSVG/./canvasworker/canvasworker.ts","webpack://SSVG/./syncworker/index.ts","webpack://SSVG/./syncworker/syncworker.ts","webpack://SSVG/./frontend/interactionhandler.ts","webpack://SSVG/./frontend/redirector.ts"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","safeLogCount","logContents","console","log","error","DrawingUtils","transform","transformObject","translateX","translateY","scaleX","scaleY","rotate","translateBeforeScale","rotateLast","transformString","replace","translate","exec","parseFloat","scale","substr","matrix","transformA","transformB","size","fallback","defaultValue","undefined","Math","round","parseInt","match","warn","color","opacity","defaultColor","cacheKey","rgbaCache","CssNamedColorToHex","rgba","test","Error","substring","length","join","g","b","rgb","hslToRgb","h","hue2rgb","q","COLOR_HEXES","toUpperCase","selector","specificity","parts","concat","apply","split","map","part","start","countClasses","min","ALICEBLUE","ANTIQUEWHITE","AQUA","AQUAMARINE","AZURE","BEIGE","BISQUE","BLACK","BLANCHEDALMOND","BLUE","BLUEVIOLET","BROWN","BURLYWOOD","CADETBLUE","CHARTREUSE","CHOCOLATE","CORAL","CORNFLOWERBLUE","CORNSILK","CRIMSON","CYAN","DARKBLUE","DARKCYAN","DARKGOLDENROD","DARKGRAY","DARKGREY","DARKGREEN","DARKKHAKI","DARKMAGENTA","DARKOLIVEGREEN","DARKORANGE","DARKORCHID","DARKRED","DARKSALMON","DARKSEAGREEN","DARKSLATEBLUE","DARKSLATEGRAY","DARKSLATEGREY","DARKTURQUOISE","DARKVIOLET","DEEPPINK","DEEPSKYBLUE","DIMGRAY","DIMGREY","DODGERBLUE","FIREBRICK","FLORALWHITE","FORESTGREEN","FUCHSIA","GAINSBORO","GHOSTWHITE","GOLD","GOLDENROD","GRAY","GREY","GREEN","GREENYELLOW","HONEYDEW","HOTPINK","INDIANRED","INDIGO","IVORY","KHAKI","LAVENDER","LAVENDERBLUSH","LAWNGREEN","LEMONCHIFFON","LIGHTBLUE","LIGHTCORAL","LIGHTCYAN","LIGHTGOLDENRODYELLOW","LIGHTGRAY","LIGHTGREY","LIGHTGREEN","LIGHTPINK","LIGHTSALMON","LIGHTSEAGREEN","LIGHTSKYBLUE","LIGHTSLATEGRAY","LIGHTSLATEGREY","LIGHTSTEELBLUE","LIGHTYELLOW","LIME","LIMEGREEN","LINEN","MAGENTA","MAROON","MEDIUMAQUAMARINE","MEDIUMBLUE","MEDIUMORCHID","MEDIUMPURPLE","MEDIUMSEAGREEN","MEDIUMSLATEBLUE","MEDIUMSPRINGGREEN","MEDIUMTURQUOISE","MEDIUMVIOLETRED","MIDNIGHTBLUE","MINTCREAM","MISTYROSE","MOCCASIN","NAVAJOWHITE","NAVY","OLDLACE","OLIVE","OLIVEDRAB","ORANGE","ORANGERED","ORCHID","PALEGOLDENROD","PALEGREEN","PALETURQUOISE","PALEVIOLETRED","PAPAYAWHIP","PEACHPUFF","PERU","PINK","PLUM","POWDERBLUE","PURPLE","REBECCAPURPLE","RED","ROSYBROWN","ROYALBLUE","SADDLEBROWN","SALMON","SANDYBROWN","SEAGREEN","SEASHELL","SIENNA","SILVER","SKYBLUE","SLATEBLUE","SLATEGRAY","SLATEGREY","SNOW","SPRINGGREEN","STEELBLUE","TAN","TEAL","THISTLE","TOMATO","TURQUOISE","VIOLET","WHEAT","WHITE","WHITESMOKE","YELLOW","YELLOWGREEN","URL","webkitURL","content","url","blob","BlobBuilder","WebKitBlobBuilder","MozBlobBuilder","MSBlobBuilder","append","getBlob","e","Blob","Worker","createObjectURL","encodeURIComponent","options","svgAssignedAndSizeSet","lastCanvasDrawTimes","enterExitQueue","safeMode","useWorker","getFps","this","maxPixelRatio","canvas","document","createElement","worker","syncWorker","onmessage","data","msg","logDrawn","raf","updateFps","updateCanvas","requestAnimationFrame","domHandler","Domhandler","vdom","getVDom","interactions","Interactionhandler","redirector","Redirector","setCanvasSize","addNode","removeNode","setupElementsIfSvgExists","svg","setTimeout","svgEl","getElementsByTagName","urlConnector","location","href","indexOf","svgSwitchUrl","svgSwitchComment","createComment","parent","parentElement","nextSibling","next","insertBefore","appendChild","initialize","hasChanges","nodeUpdated","node","attr","renderer","applyStyles","transferBufferQueueDataToSynced","queue","getQueue","clearQueue","updatePropertiesFromQueue","sendUpdateToWorker","draw","width","height","devicePixelRatio","style","offscreen","transferControlToOffscreen","channel","MessageChannel","postMessage","cmd","visData","port","port2","port1","ensureNodesMapped","Canvasrenderer","parentNode","keepChildren","push","parentGlobalIndex","globalElementIndex","childGlobalIndex","Date","now","shift","timeForTenDrawsMs","fps","enterExit","update","ignoreDesign","nodes","elements","nodesToRestyle","maxGlobalElementIndex","removedNodeIndices","VdomManager","type","children","css","getAttribute","linkNodeToElement","display","addChildNodesToVisData","childNodes","enableFrontendDesignProperties","element","attrName","ensureInitialized","getNodeFromElement","index","evaluatedValue","__data__","set","safeLog","className","styleName","getNodeFromIndex","el","tagName","toLowerCase","id","text","textContent","RELEVANT_ATTRS","hasAttribute","ROUNDED_ATTRS","copyStylesFromElement","styleProp","CSS_STYLES","kebabCase","styleSheets","sheet","rules","cssRules","j","rule","selectorText","applyRuleToMatchingNodes","selectorString","selectorPartsLooseStrict","trim","relevantIds","nodeToBeStyled","getNodeParent","relevantIdMap","setStyle","child","longSpecName","checkNode","currentNode","looseIndex","strictIndex","selPart","childIndex","isCssRulePartialMatch","removedClass","removeRuleStylesFromNode","restyleIndex","splice","childEls","getNodeDataFromEl","parentSelector","elementType","getElementFromNode","parentEl","getNewElementIndex","isWithinSvg","getParentNode","parents","pop","totalTransform","parseTransform","addTransforms","isRenderer","sharedRenderData","values","buffers","syncedSharedData","sharedDataQueue","useSharedArrayFor","indexToNodeMap","changed","cachedListSelections","self","useBuffer","numNodes","newLength","newByteLength","Int32Array","BYTES_PER_ELEMENT","byteLength","buffer","createBufferTransferValues","prevData","SharedArrayBuffer","prevBufferVals","BUFFER_PRECISION_FACTOR","storage","addToMap","nodeData","parentNodeIndex","keys","removePendingChanges","styleValue","onNodeUpdated","applyStyleToNodeAndChildren","applyCssToNodeAndChildren","filtered","filter","attrs","Array","isArray","getSingle","setAttrQueue","attrNameStart","IGNOREDESIGN_ATTRIBUTES","childNode","lastSplitPos","lastIndexOf","selectorWithoutLast","lastPart","parentSel","nthChildPosition","selectedNodes","findMatchingChildren","visNode","addDirectChildrenIfMatch","matchIndex","selectedNodeSelectors","selParts","findChildrenOfType","matching","cssRuleSelectorPart","newSelPart","searchClassNames","allTrue","searchClassName","indexPart","targetIndex","cutoff","typeName","rect","circle","path","title","tspan","image","clippath","line","ROUNDED_ATTRS_ARR","forceSingle","onDrawn","parentValues","lastFullSecond","countSinceLastFullSecond","circlesByColor","rectsByColor","drawTexts","drawImages","linesByColor","ctx","getContext","save","restore","clearRect","drawLine","drawCircle","drawRect","drawText","drawImage","drawNodeAndChildren","fullSecond","performance","elData","drawClip","parentValuesBackup","saveRestoreContext","applyTransform","clipPathId","clipNode","getNodeById","Path2D","clip","safeErrorLog","drawSingleNode","fill","stroke","drawFct","handle","getFillStyle","getStrokeStyle","strokeStyle","cx","cy","beginPath","fillStyle","lineWidth","getStrokeWidth","moveTo","arc","PI","fillAndStrokeColor","fillColor","strokeColor","sampleData","includes","getAttributeStyleCss","defaultCol","colorToRgba","highestSpec","getCssRuleSpecificityNumber","x","y","fillRect","isClip","drawSingle","fontFamily","fontSize","customSize","convertSizeToPx","font","align","textAlign","dx","dy","fillText","strokeWidth","lineJoin","addPath","textAnchor","x1","x2","y1","y2","val","lineTo","CanvasWorkerImporter","SyncWorkerImporter","interactionSelections","getBoundingClientRect","position","setupListeners","addEventListener","propagateMouseEvent","propagateTouchEvent","lastHovered","hoveredElement","dispatchEvent","MouseEvent","duplicateTouchEvent","propagateWheelEvent","evt","propagateEvent","createEvent","initEvent","prop","writable","touches","touch","identifier","pageX","pageY","clientX","clientY","WheelEvent","new_event","triggeredElement","getMousePosition","interactionSel","getVisNode","nodeAtPosition","childElement","event","pos","sqrt","pow","elX","elY","centerX","centerY","distanceX","abs","distanceY","getTotalTransformation","matchAny","onSvgSizeSet","onAddNode","onRemoveNode","onSvgAppended","svgIsAssignedAndSizeSet","unassignedNodes","captureD3On","replaceNativeRemoveChild","replaceNativeAttribute","replaceNativePathFunctions","replaceNativeCreateElement","replaceNativeAppendChild","replaceD3Attr","replaceNativeSelect","replaceNativeGetComputedStyle","replaceD3Select","replaceD3Remove","replaceNativeGetScreenCtm","d3","originalOn","selection","on","me","_parents","arguments","getReplacement","original","_groups","childElements","getVisNodesFromSelector","returnValue","forEach","childEl","selectAll","select","origFilter","firstElement","selectors","sel","filteredNodes","matchingNodes","filterNodesBySelector","filteredElements","origGetComputedStyle","getComputedStyle","getPropertyValue","propertyName","origQuerySelector","Element","querySelector","originalFct","prefix","els","returnVal","getAttributeFromSelector","queueSetAttributeOnElement","queueSetAttributeOnSelection","origSelectionAttr","origSelectionStyle","originalClassed","classed","prevClassNames","newClassNames","originalTransition","transition","originalText","newRemove","getNewRemoveChild","d3Remove","remove","origCreate","createElementNS","newArgs","from","getNewAppendChild","origRemoveChild","skipUpdateSelectors","removeChild","origAppend","appended","el2","setProperty","removeProperty","addNodeToParent","restyleNode","origAppendChild","newAppend","newChild","refChild","origGetTotalLength","SVGPathElement","getTotalLength","origSetAttribute","setAttribute","getNewSetAttr","origSetAttr","setAttributeNS","origGetAttr","unassigned","within","orig","SVGGraphicsElement","getScreenCTM","origResult","createSVGMatrix"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAc,KAAID,IAElBD,EAAW,KAAIC,IARjB,CASGK,QAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHT,QAAS,IAUV,OANAU,EAAQH,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,GAG/DL,EAAOQ,GAAI,EAGJR,EAAOD,QA0Df,OArDAM,EAAoBM,EAAIF,EAGxBJ,EAAoBO,EAAIR,EAGxBC,EAAoBQ,EAAI,SAASd,EAASe,EAAMC,GAC3CV,EAAoBW,EAAEjB,EAASe,IAClCG,OAAOC,eAAenB,EAASe,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEV,EAAoBgB,EAAI,SAAStB,GACX,oBAAXuB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAenB,EAASuB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAenB,EAAS,aAAc,CAAEyB,OAAO,KAQvDnB,EAAoBoB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQnB,EAAoBmB,IAC/B,EAAPE,EAAU,OAAOF,EACpB,GAAW,EAAPE,GAA8B,iBAAVF,GAAsBA,GAASA,EAAMG,WAAY,OAAOH,EAChF,IAAII,EAAKX,OAAOY,OAAO,MAGvB,GAFAxB,EAAoBgB,EAAEO,GACtBX,OAAOC,eAAe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,QAAQhqB,UAAUkV,aAAe,SAA6BvW,GAC1D,MAAMuuB,GAAmD,IAAtC5E,EAAGjB,gBAAgBlW,QAAQlC,MACxCke,EAAS7E,EAAGtY,WAAWqJ,YAAYpK,MACzC,GAAIie,IAAeC,IAAW7E,EAAG1X,IAC7B,OAAOqc,EAAYlpB,MAAMkL,KAAMuZ,WAE/B,IACI,OAAOF,EAAGtY,WAAWsa,yBAAyBrb,KAAMtQ,GACtD,MAAO0P,GAEL,OADA/N,QAAQE,MAAM6N,GACP4e,EAAYlpB,MAAMkL,KAAMuZ,aAMvC,4BAEJ,MAAM4E,EAAOC,mBAAmBrtB,UAAUstB,aAC1CD,mBAAmBrtB,UAAUstB,aAAe,WACxC,MAAMC,EAAaH,EAAKrpB,MAAMkL,KAAMuZ,WACpC,GAAI+E,EACA,OAAOA,EAGX,MAAM3c,EAAMxB,SAASmc,gBAAgB,6BAA8B,OAEnE,OAAO3a,EAAI4c","file":"ssvg.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"SSVG\"] = factory();\n\telse\n\t\troot[\"SSVG\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 4);\n","let safeLogCount = 0;\n\nexport function safeLog(...logContents) {\n if (safeLogCount < 200) {\n safeLogCount++;\n console.log(...logContents);\n }\n}\nexport function safeErrorLog(...logContents) {\n if (safeLogCount < 200) {\n safeLogCount++;\n console.error(...logContents);\n }\n}\n","export interface Transformation {\n translateX: number;\n translateY: number;\n scaleX: number;\n scaleY: number;\n rotate: number;\n translateBeforeScale: boolean;\n rotateLast: boolean;\n}\n\nexport class DrawingUtils {\n static parseTransform(transform: string | {}): Transformation {\n const transformObject: Transformation = {\n translateX: 0,\n translateY: 0,\n scaleX: 1,\n scaleY: 1,\n rotate: 0,\n translateBeforeScale: false,\n rotateLast: false,\n };\n\n if (transform) {\n if (typeof transform !== 'string') {\n transformObject.scaleX = transform['k'];\n transformObject.scaleY = transform['k'];\n transformObject.translateX = transform['x'];\n transformObject.translateY = transform['y'];\n transformObject.translateBeforeScale = true;\n return transformObject;\n }\n let transformString = <string>transform;\n transformString = transformString.replace(/ /g, '');\n\n //let translate = /translate\\((\\d+),(\\d+)\\)/.exec(transform);\n const translate = /\\s*translate\\(([-0-9.]+),([-0-9.]+)\\)/.exec(transformString);\n if (translate) {\n transformObject.translateX = parseFloat(translate[1]);\n transformObject.translateY = parseFloat(translate[2]);\n } else {\n //console.error('no translate found', transform);\n }\n\n const scale = /\\s*scale\\(([-0-9.]+)(,[-0-9.]+)?\\)/.exec(transformString);\n if (scale) {\n transformObject.scaleX = parseFloat(scale[1]);\n transformObject.scaleY = scale[2]\n ? parseFloat(scale[2].substr(1))\n : parseFloat(scale[1]);\n } else {\n //console.error('no scale found', transform);\n }\n\n const rotate = /\\s*rotate\\(([-0-9.]+)\\)/.exec(transformString);\n if (rotate) {\n transformObject.rotate = parseFloat(rotate[1]);\n } else {\n //console.error('no rotate found', transform);\n }\n\n const translateScale = /\\s*translate\\(([-0-9.]+),([-0-9.]+)\\)scale\\(([-0-9.,]+)\\)/.exec(\n transformString\n );\n if (translateScale) {\n transformObject.translateBeforeScale = true;\n }\n\n const rotateLast = /\\s*rotate\\(([-0-9.,]+)\\)$/.exec(transformString);\n if (rotateLast) {\n transformObject.rotateLast = true;\n }\n\n const matrix = /\\s*matrix\\(([-0-9.]+),([-0-9.]+),([-0-9.]+),([-0-9.]+),([-0-9.]+),([-0-9.]+)\\)/.exec(\n transformString\n );\n if (matrix) {\n transformObject.scaleX = parseFloat(matrix[1]);\n // 2 is horizontal skewing\n // 3 is vertical skewing\n transformObject.scaleY = parseFloat(matrix[4]);\n transformObject.translateX = parseFloat(matrix[5]);\n transformObject.translateY = parseFloat(matrix[6]);\n }\n }\n\n return transformObject;\n }\n\n static addTransforms(transformA: Transformation, transformB: Transformation): Transformation {\n return {\n translateX: transformA.translateX + transformB.translateX,\n translateY: transformA.translateY + transformB.translateY,\n scaleX: transformA.scaleX * transformB.scaleX,\n scaleY: transformA.scaleY * transformB.scaleY,\n rotate: transformA.rotate + transformB.rotate,\n translateBeforeScale: false,\n rotateLast: false,\n };\n //TODO: consider translateBeforeScale and rotateLast\n }\n\n static convertSizeToPx(size: string | number, fallback = true): number | undefined {\n const defaultValue = fallback ? 14 : undefined;\n if (size === undefined) {\n return defaultValue;\n }\n if (typeof size === 'number') {\n return size;\n }\n if (size.substr(-2) === 'em') {\n return Math.round(parseFloat(size) * 12);\n }\n if (size.substr(-2) === 'px') {\n return parseInt(size);\n }\n if (size.match(/^[0-9]+$/)) {\n return parseInt(size);\n }\n console.warn('size in unsupported format: ', size);\n return defaultValue;\n }\n\n static rgbaCache = {};\n static colorToRgba(\n color: string | {r: number; g: number; b: number} | {h: number; s: number; l: number},\n opacity: string | number = 1,\n defaultColor = 'none'\n ): string {\n if (color === 'none') {\n return color;\n }\n if (!color) {\n color = defaultColor;\n }\n const cacheKey = `${color}-${opacity}`;\n if (DrawingUtils.rgbaCache[cacheKey]) {\n return DrawingUtils.rgbaCache[cacheKey];\n }\n\n color = DrawingUtils.CssNamedColorToHex(color);\n if (opacity === 1 && typeof color === 'string') {\n DrawingUtils.rgbaCache[cacheKey] = color;\n return color;\n }\n let rgba: string;\n if (typeof color === 'string' && color[0] === '#') {\n let c; // From https://stackoverflow.com/questions/21646738/convert-hex-to-rgba\n if (/^#([A-Fa-f0-9]{3}){1,2}$/.test(color)) {\n c = color.substring(1);\n if (c.length == 3) {\n c = c[0] + c[0] + c[1] + c[1] + c[2] + c[2];\n }\n c = '0x' + c;\n rgba =\n 'rgba(' +\n [(c >> 16) & 255, (c >> 8) & 255, c & 255].join(',') +\n ',' +\n opacity +\n ')';\n } else {\n throw new Error('Bad Hex');\n }\n } else if (typeof color === 'object') {\n if ('r' in color) {\n rgba = 'rgba(' + color.r + ',' + color.g + ',' + color.b + ',' + opacity + ')';\n } else if ('h' in color) {\n const rgb = DrawingUtils.hslToRgb(color.h / 360, color.s, color.l);\n rgba = 'rgba(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ',' + opacity + ')';\n }\n } else if (color.substr(0, 4) === 'rgb(') {\n rgba = color.substr(0, color.length - 1).replace('rgb', 'rgba') + ', ' + opacity + ')';\n }\n DrawingUtils.rgbaCache[cacheKey] = rgba;\n return rgba;\n }\n\n // From https://stackoverflow.com/questions/2353211/hsl-to-rgb-color-conversion\n static hslToRgb(h, s, l) {\n var r, g, b;\n\n if (s == 0) {\n r = g = b = l; // achromatic\n } else {\n var hue2rgb = function hue2rgb(p, q, t) {\n if (t < 0) t += 1;\n if (t > 1) t -= 1;\n if (t < 1 / 6) return p + (q - p) * 6 * t;\n if (t < 1 / 2) return q;\n if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;\n return p;\n };\n\n var q = l < 0.5 ? l * (1 + s) : l + s - l * s;\n var p = 2 * l - q;\n r = hue2rgb(p, q, h + 1 / 3);\n g = hue2rgb(p, q, h);\n b = hue2rgb(p, q, h - 1 / 3);\n }\n\n return {\n r: Math.round(r * 255),\n g: Math.round(g * 255),\n b: Math.round(b * 255),\n };\n }\n\n static CssNamedColorToHex(color: any) {\n if (typeof color === 'string' && COLOR_HEXES[color.toUpperCase()]) {\n return COLOR_HEXES[color.toUpperCase()];\n }\n return color;\n }\n\n /**\n * Basic implementation to get a sense of specificity. Numbers are completely made up.\n * Should eventually be more sophisticated, e.g. using https://github.com/keeganstreet/specificity.\n * @param selector CSS rule as string.\n */\n static getCssRuleSpecificityNumber(selector: string) {\n let specificity = 0;\n\n selector = selector.replace(/ >/g, '>').replace(/> /g, '>');\n\n const parts = [].concat.apply(\n [],\n selector.split(' ').map((part) => part.split('>'))\n );\n\n // Rough logic: the more stuff, the more specific. IDs and classes are more specific than other things.\n for (const part of parts) {\n specificity += 100;\n const start = part[0];\n\n if (start === '#') {\n specificity += 1000;\n } else if (start === '.') {\n // More classes are more specific, but never more specific than an ID.\n const countClasses = part.split('.').length - 1;\n specificity += Math.min(900, countClasses * 100);\n }\n }\n\n return specificity;\n }\n}\n\nconst COLOR_HEXES = {\n ALICEBLUE: '#F0F8FF',\n ANTIQUEWHITE: '#FAEBD7',\n AQUA: '#00FFFF',\n AQUAMARINE: '#7FFFD4',\n AZURE: '#F0FFFF',\n BEIGE: '#F5F5DC',\n BISQUE: '#FFE4C4',\n BLACK: '#000000',\n BLANCHEDALMOND: '#FFEBCD',\n BLUE: '#0000FF',\n BLUEVIOLET: '#8A2BE2',\n BROWN: '#A52A2A',\n BURLYWOOD: '#DEB887',\n CADETBLUE: '#5F9EA0',\n CHARTREUSE: '#7FFF00',\n CHOCOLATE: '#D2691E',\n CORAL: '#FF7F50',\n CORNFLOWERBLUE: '#6495ED',\n CORNSILK: '#FFF8DC',\n CRIMSON: '#DC143C',\n CYAN: '#00FFFF',\n DARKBLUE: '#00008B',\n DARKCYAN: '#008B8B',\n DARKGOLDENROD: '#B8860B',\n DARKGRAY: '#A9A9A9',\n DARKGREY: '#A9A9A9',\n DARKGREEN: '#006400',\n DARKKHAKI: '#BDB76B',\n DARKMAGENTA: '#8B008B',\n DARKOLIVEGREEN: '#556B2F',\n DARKORANGE: '#FF8C00',\n DARKORCHID: '#9932CC',\n DARKRED: '#8B0000',\n DARKSALMON: '#E9967A',\n DARKSEAGREEN: '#8FBC8F',\n DARKSLATEBLUE: '#483D8B',\n DARKSLATEGRAY: '#2F4F4F',\n DARKSLATEGREY: '#2F4F4F',\n DARKTURQUOISE: '#00CED1',\n DARKVIOLET: '#9400D3',\n DEEPPINK: '#FF1493',\n DEEPSKYBLUE: '#00BFFF',\n DIMGRAY: '#696969',\n DIMGREY: '#696969',\n DODGERBLUE: '#1E90FF',\n FIREBRICK: '#B22222',\n FLORALWHITE: '#FFFAF0',\n FORESTGREEN: '#228B22',\n FUCHSIA: '#FF00FF',\n GAINSBORO: '#DCDCDC',\n GHOSTWHITE: '#F8F8FF',\n GOLD: '#FFD700',\n GOLDENROD: '#DAA520',\n GRAY: '#808080',\n GREY: '#808080',\n GREEN: '#008000',\n GREENYELLOW: '#ADFF2F',\n HONEYDEW: '#F0FFF0',\n HOTPINK: '#FF69B4',\n INDIANRED: '#CD5C5C',\n INDIGO: '#4B0082',\n IVORY: '#FFFFF0',\n KHAKI: '#F0E68C',\n LAVENDER: '#E6E6FA',\n LAVENDERBLUSH: '#FFF0F5',\n LAWNGREEN: '#7CFC00',\n LEMONCHIFFON: '#FFFACD',\n LIGHTBLUE: '#ADD8E6',\n LIGHTCORAL: '#F08080',\n LIGHTCYAN: '#E0FFFF',\n LIGHTGOLDENRODYELLOW: '#FAFAD2',\n LIGHTGRAY: '#D3D3D3',\n LIGHTGREY: '#D3D3D3',\n LIGHTGREEN: '#90EE90',\n LIGHTPINK: '#FFB6C1',\n LIGHTSALMON: '#FFA07A',\n LIGHTSEAGREEN: '#20B2AA',\n LIGHTSKYBLUE: '#87CEFA',\n LIGHTSLATEGRAY: '#778899',\n LIGHTSLATEGREY: '#778899',\n LIGHTSTEELBLUE: '#B0C4DE',\n LIGHTYELLOW: '#FFFFE0',\n LIME: '#00FF00',\n LIMEGREEN: '#32CD32',\n LINEN: '#FAF0E6',\n MAGENTA: '#FF00FF',\n MAROON: '#800000',\n MEDIUMAQUAMARINE: '#66CDAA',\n MEDIUMBLUE: '#0000CD',\n MEDIUMORCHID: '#BA55D3',\n MEDIUMPURPLE: '#9370DB',\n MEDIUMSEAGREEN: '#3CB371',\n MEDIUMSLATEBLUE: '#7B68EE',\n MEDIUMSPRINGGREEN: '#00FA9A',\n MEDIUMTURQUOISE: '#48D1CC',\n MEDIUMVIOLETRED: '#C71585',\n MIDNIGHTBLUE: '#191970',\n MINTCREAM: '#F5FFFA',\n MISTYROSE: '#FFE4E1',\n MOCCASIN: '#FFE4B5',\n NAVAJOWHITE: '#FFDEAD',\n NAVY: '#000080',\n OLDLACE: '#FDF5E6',\n OLIVE: '#808000',\n OLIVEDRAB: '#6B8E23',\n ORANGE: '#FFA500',\n ORANGERED: '#FF4500',\n ORCHID: '#DA70D6',\n PALEGOLDENROD: '#EEE8AA',\n PALEGREEN: '#98FB98',\n PALETURQUOISE: '#AFEEEE',\n PALEVIOLETRED: '#DB7093',\n PAPAYAWHIP: '#FFEFD5',\n PEACHPUFF: '#FFDAB9',\n PERU: '#CD853F',\n PINK: '#FFC0CB',\n PLUM: '#DDA0DD',\n POWDERBLUE: '#B0E0E6',\n PURPLE: '#800080',\n REBECCAPURPLE: '#663399',\n RED: '#FF0000',\n ROSYBROWN: '#BC8F8F',\n ROYALBLUE: '#4169E1',\n SADDLEBROWN: '#8B4513',\n SALMON: '#FA8072',\n SANDYBROWN: '#F4A460',\n SEAGREEN: '#2E8B57',\n SEASHELL: '#FFF5EE',\n SIENNA: '#A0522D',\n SILVER: '#C0C0C0',\n SKYBLUE: '#87CEEB',\n SLATEBLUE: '#6A5ACD',\n SLATEGRAY: '#708090',\n SLATEGREY: '#708090',\n SNOW: '#FFFAFA',\n SPRINGGREEN: '#00FF7F',\n STEELBLUE: '#4682B4',\n TAN: '#D2B48C',\n TEAL: '#008080',\n THISTLE: '#D8BFD8',\n TOMATO: '#FF6347',\n TURQUOISE: '#40E0D0',\n VIOLET: '#EE82EE',\n WHEAT: '#F5DEB3',\n WHITE: '#FFFFFF',\n WHITESMOKE: '#F5F5F5',\n YELLOW: '#FFFF00',\n YELLOWGREEN: '#9ACD32',\n};\n","'use strict';\n\n// http://stackoverflow.com/questions/10343913/how-to-create-a-web-worker-from-a-string\n\nvar URL = window.URL || window.webkitURL;\n\nmodule.exports = function (content, url) {\n try {\n try {\n var blob;\n\n try {\n // BlobBuilder = Deprecated, but widely implemented\n var BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder;\n\n blob = new BlobBuilder();\n\n blob.append(content);\n\n blob = blob.getBlob();\n } catch (e) {\n // The proposed API\n blob = new Blob([content]);\n }\n\n return new Worker(URL.createObjectURL(blob));\n } catch (e) {\n return new Worker('data:application/javascript,' + encodeURIComponent(content));\n }\n } catch (e) {\n if (!url) {\n throw Error('Inline worker is not supported');\n }\n\n return new Worker(url);\n }\n};","import SSVG from './ssvg';\n\nexport = SSVG;\n","import {VdomManager} from '../util/vdom/vdom-manager';\nimport {CanvasUpdateWorkerMessage, CanvasUpdateData} from '../util/canvas-worker-message';\nimport {Domhandler, SsvgElement} from './domhandler';\nimport {CanvasWorker} from '../canvasworker/canvasworker';\nimport {Canvasrenderer} from '../canvasworker/canvasrenderer';\nimport CanvasWorkerImporter from '../canvasworker';\nimport SyncWorkerImporter from '../syncworker';\nimport {Interactionhandler} from './interactionhandler';\nimport {Redirector} from './redirector';\nimport {VdomNode} from '../util/vdom/vdom';\n\nexport default class SSVG {\n private worker: Worker;\n private syncWorker: Worker;\n private domHandler: Domhandler;\n private vdom: VdomManager;\n private readonly interactions: Interactionhandler;\n private renderer: CanvasWorker;\n private redirector: Redirector;\n\n private svg: (SVGElement & SsvgElement) | undefined;\n private readonly canvas: HTMLCanvasElement;\n private svgAssignedAndSizeSet = false;\n\n private lastCanvasDrawTimes: number[] = [];\n\n private enterExitQueue: CanvasUpdateData[] = [];\n\n private readonly safeMode: boolean = false;\n private readonly maxPixelRatio: number | undefined;\n private readonly useWorker: boolean = true;\n private readonly getFps: (fps: number) => void = () => {};\n\n constructor(options?: {\n safeMode?: boolean;\n maxPixelRatio?: number;\n useWorker?: boolean;\n getFps?: (fps: number) => void;\n svg?: SVGElement & SsvgElement;\n }) {\n if (options) {\n if (options.safeMode !== undefined) {\n this.safeMode = options.safeMode;\n }\n this.maxPixelRatio = options.maxPixelRatio;\n if (options.useWorker !== undefined) {\n this.useWorker = options.useWorker;\n }\n if (options.getFps !== undefined) {\n this.getFps = options.getFps;\n }\n }\n\n this.canvas = document.createElement('canvas');\n if (!('OffscreenCanvas' in window)) {\n this.useWorker = false;\n }\n\n if (this.useWorker) {\n this.worker = new CanvasWorkerImporter();\n this.syncWorker = new SyncWorkerImporter();\n\n this.worker.onmessage = (e) => {\n if (e.data && e.data.msg && e.data.msg === 'DRAWN') {\n this.logDrawn();\n //this.updateCanvas();\n }\n };\n const raf = () => {\n this.updateFps();\n this.updateCanvas();\n requestAnimationFrame(raf);\n };\n raf();\n } else {\n const raf = () => {\n this.updateFps();\n this.logDrawn();\n this.updateCanvas();\n requestAnimationFrame(raf);\n };\n raf();\n }\n\n this.domHandler = new Domhandler(this.useWorker, this.useWorker);\n this.vdom = this.domHandler.getVDom();\n\n this.interactions = new Interactionhandler();\n\n this.redirector = new Redirector(\n this.domHandler,\n this.vdom,\n this.interactions,\n this.setCanvasSize.bind(this),\n this.addNode.bind(this),\n this.removeNode.bind(this),\n () => this.svgAssignedAndSizeSet,\n this.setupElementsIfSvgExists.bind(this)\n );\n\n const svg = options && options.svg ? options.svg : undefined;\n this.setupElementsIfSvgExists(svg);\n\n setTimeout(() => {\n console.log(this.vdom.data);\n }, 1000);\n }\n\n private setupElementsIfSvgExists(svgEl?: SVGElement & SsvgElement) {\n if (this.svg) {\n return true;\n }\n\n const svg = !svgEl ? document.getElementsByTagName('svg')[0] : svgEl;\n\n if (!svg) {\n return false;\n }\n\n const urlConnector = document.location.href.indexOf('?') === -1 ? '?' : '&';\n const svgSwitchUrl = document.location.href + urlConnector + 'svg';\n const svgSwitchComment = document.createComment(\n ' This project uses SSVG.io to render a SVG as Canvas.\\r\\n' +\n 'To inspect the SVG, please open the following URL:\\r\\n' +\n svgSwitchUrl +\n '\\r\\n'\n );\n\n this.svg = svg as SVGElement & SsvgElement;\n const parent = this.svg.parentElement;\n\n if (this.svg.nextSibling) {\n const next = this.svg.nextSibling;\n parent.insertBefore(svgSwitchComment, next);\n parent.insertBefore(this.canvas, next);\n } else {\n parent.appendChild(svgSwitchComment);\n parent.appendChild(this.canvas);\n }\n\n this.domHandler.initialize(this.svg);\n this.redirector.initialize(this.svg);\n this.interactions.initialize(this.canvas, this.svg, this.domHandler, this.vdom);\n\n this.setCanvasSize();\n\n return true;\n }\n\n private updateCanvas() {\n if (!this.svgAssignedAndSizeSet) {\n return;\n }\n\n if (!this.vdom.hasChanges() && !this.domHandler.hasChanges()) {\n return;\n }\n\n const nodeUpdated = this.useWorker\n ? undefined\n : (node, attr) => this.renderer.nodeUpdated(node, attr);\n this.domHandler.applyStyles();\n\n this.vdom.transferBufferQueueDataToSynced();\n const queue = this.vdom.getQueue();\n this.vdom.clearQueue();\n this.vdom.updatePropertiesFromQueue(queue, nodeUpdated);\n\n if (this.useWorker) {\n this.sendUpdateToWorker(queue);\n } else {\n if (this.renderer.updatePropertiesFromQueue) {\n this.renderer.updatePropertiesFromQueue(queue);\n }\n this.renderer.draw();\n }\n }\n\n private setCanvasSize() {\n if (!this.svg || !this.vdom.data.width || !this.vdom.data.height) {\n return;\n }\n this.vdom.data.scale = window.devicePixelRatio;\n if (this.maxPixelRatio !== undefined && this.vdom.data.scale > this.maxPixelRatio) {\n this.vdom.data.scale = this.maxPixelRatio;\n }\n\n this.canvas.style.width = this.vdom.data.width + 'px';\n this.canvas.style.height = this.vdom.data.height + 'px';\n this.canvas.width = this.vdom.data.width * this.vdom.data.scale;\n this.canvas.height = this.vdom.data.height * this.vdom.data.scale;\n\n if (this.useWorker) {\n const offscreen = (this.canvas as any).transferControlToOffscreen();\n const channel = new MessageChannel();\n this.worker.postMessage(\n {\n cmd: 'INIT',\n data: {\n canvas: offscreen,\n visData: this.vdom.data,\n safeMode: this.safeMode,\n port: channel.port2,\n },\n },\n [offscreen, channel.port2]\n );\n this.syncWorker.postMessage(\n {\n cmd: 'INIT',\n data: {\n visData: this.vdom.data,\n safeMode: this.safeMode,\n port: channel.port1,\n },\n },\n [channel.port1]\n );\n\n this.vdom.ensureNodesMapped();\n } else {\n this.renderer = new Canvasrenderer(this.vdom, this.canvas, this.safeMode, () => {});\n }\n\n this.svgAssignedAndSizeSet = true;\n }\n\n addNode(node: VdomNode, parentNode: VdomNode, keepChildren: boolean) {\n if (this.useWorker) {\n this.enterExitQueue.push({\n cmd: 'ENTER',\n node: node,\n parentGlobalIndex: parentNode.globalElementIndex,\n keepChildren: keepChildren,\n });\n } else {\n if (this.renderer.addNode) {\n this.renderer.addNode(node);\n }\n }\n }\n\n removeNode(node: VdomNode, parentNode: VdomNode) {\n this.enterExitQueue.push({\n cmd: 'EXIT',\n childGlobalIndex: node.globalElementIndex,\n parentGlobalIndex: parentNode.globalElementIndex,\n });\n }\n\n private logDrawn() {\n this.lastCanvasDrawTimes.push(Date.now());\n\n if (this.lastCanvasDrawTimes.length > 20) {\n this.lastCanvasDrawTimes.shift(); // Remove first item\n }\n }\n\n private updateFps() {\n if (this.lastCanvasDrawTimes.length) {\n const timeForTenDrawsMs = Date.now() - this.lastCanvasDrawTimes[0];\n const fps = Math.round((this.lastCanvasDrawTimes.length / timeForTenDrawsMs) * 1000);\n this.getFps(fps);\n }\n }\n\n private sendUpdateToWorker(queue) {\n const msg: CanvasUpdateWorkerMessage = {\n cmd: 'UPDATE_NODES',\n data: {\n enterExit: this.enterExitQueue,\n update: queue,\n },\n };\n\n this.syncWorker.postMessage(msg);\n //this.worker.postMessage(msg);\n this.enterExitQueue = [];\n }\n}\n","import {VDOM, VdomNode, VdomNodeType} from '../util/vdom/vdom';\nimport {VdomManager} from '../util/vdom/vdom-manager';\nimport {DrawingUtils, Transformation} from '../canvasworker/drawingUtils';\nimport {CSS_STYLES, RELEVANT_ATTRS, ROUNDED_ATTRS} from './attrs';\nimport {safeLog} from '../util/safelogs';\n\nexport class Domhandler {\n private readonly vdom: VdomManager;\n nodes: {[globalElementIndex: number]: VdomNode} = {};\n elements: {[globalElementIndex: number]: SsvgElement} = {};\n private nodesToRestyle: VdomNode[] = [];\n private maxGlobalElementIndex = 0;\n private removedNodeIndices: number[] = [];\n private svg: SVGElement & SsvgElement;\n\n constructor(useWorker: boolean, private ignoreDesign: boolean) {\n const visData: VDOM = {\n type: 'svg',\n width: 0,\n height: 0,\n scale: 1,\n children: [],\n globalElementIndex: 0,\n style: {},\n css: {},\n };\n\n this.vdom = new VdomManager(visData, ignoreDesign, false);\n }\n\n initialize(svg: SVGElement & SsvgElement) {\n this.svg = svg;\n this.vdom.data.width = parseInt(this.svg.getAttribute('width'));\n this.vdom.data.height = parseInt(this.svg.getAttribute('height'));\n\n this.linkNodeToElement(this.vdom.data, this.svg);\n this.svg.style.display = 'none';\n this.svg['selector'] = 'svg';\n\n this.addChildNodesToVisData(this.svg.childNodes, this.vdom.data);\n }\n\n hasChanges() {\n return this.nodesToRestyle.length > 0;\n }\n\n enableFrontendDesignProperties() {\n this.ignoreDesign = false;\n this.vdom.enableFrontendDesignProperties();\n }\n\n getVDom() {\n return this.vdom;\n }\n\n queueSetAttributeOnElement(\n element: SsvgElement,\n attrName: string,\n value: number | string | ((el: HTMLElement) => number | string)\n ) {\n //TODO: merge with updatePropertiesFromQueue from VdomManager?\n this.vdom.ensureInitialized(attrName, false);\n\n const node = this.getNodeFromElement(element);\n\n const parentIndices = this.getNodeFromElement(\n element.parentNode as SsvgElement\n ).children.map((n) => n.globalElementIndex);\n const index = parentIndices.indexOf(node.globalElementIndex);\n const evaluatedValue =\n typeof value === 'function' ? value.call(element, element.__data__, index) : value;\n\n if (!node) {\n console.error('node not found for ', element);\n return;\n }\n this.vdom.ensureInitialized(attrName, true, this.maxGlobalElementIndex);\n this.vdom.set(node, attrName, evaluatedValue);\n\n if (attrName === 'href') {\n safeLog('href not yet supported.');\n /*\n try {\n fetch(location.origin + evaluatedValue, {mode: 'cors'})\n .then(resp => resp.blob())\n .then(blob => createImageBitmap(blob))\n .then(bitmap => {\n this.vdom.ensureInitialized('image', false);\n this.vdom.set(node, 'image', <string> bitmap, false);\n });\n }\n catch(e) {console.log(e);}\n */\n }\n\n if (attrName === 'class' || attrName.indexOf('style') !== -1) {\n // Apply classes immediately so styles can be applied correctly.\n if (attrName === 'class') {\n node.className = evaluatedValue;\n this.nodesToRestyle.push(node);\n } else {\n const styleName = attrName.substr(6);\n if (!node.style) {\n console.error('no styles on node ', node);\n }\n node.style[styleName] = evaluatedValue;\n }\n }\n }\n\n queueSetAttributeOnSelection(elements: SsvgElement[], attrName: string, value) {\n if (!elements.length) return;\n if (!elements[0]) {\n //console.error('selection elements not found', elements);\n return;\n }\n\n this.vdom.ensureInitialized(attrName, true, this.maxGlobalElementIndex);\n\n for (let i = 0; i < elements.length; i++) {\n const element = elements[i];\n const evaluatedValue = typeof value === 'function' ? value(element.__data__, i) : value;\n\n this.vdom.set(element, attrName, evaluatedValue);\n\n //TODO: re-implement.\n /*if(attrName === \"href\") {\n try {\n fetch(location.origin + evaluatedValue, {mode: 'cors'})\n .then(resp => resp.blob())\n .then(blob => createImageBitmap(blob))\n .then(bitmap => {\n //this.checkAttrName(parentSelector, \"image\", useSharedArray, parentNode);\n this.setAttrQueue.ensureInitialized(\"image\", false);\n this.setAttrQueue[parentSelector][\"image\"][indexOfParent] = bitmap;\n });\n }\n catch(e) {console.log(e);}\n }*/\n }\n\n if (attrName === 'className' || attrName.indexOf('style') !== -1) {\n // Apply classes immediately so styles can be applied correctly.\n for (let i = 0; i < elements.length; i++) {\n const element = elements[i];\n const node = this.getNodeFromElement(element);\n const evaluatedValue =\n typeof value === 'function' ? value(element.__data__, i) : value;\n\n if (attrName === 'className') {\n node.className = evaluatedValue;\n this.nodesToRestyle.push(node);\n } else {\n const styleName = attrName.substr(6);\n node.style[styleName] = evaluatedValue;\n }\n }\n }\n }\n\n getAttributeFromSelector(element: SsvgElement, name: string) {\n const node = this.getNodeFromElement(element);\n\n if (!node) {\n console.error(\n 'trying to get attribute for unfit selection',\n element,\n element.globalElementIndex,\n name\n );\n throw Error('element not found');\n }\n\n return node[name];\n }\n\n getVisNode(element: SsvgElement): VdomNode | null {\n if (element === this.svg) {\n return this.vdom.data;\n }\n return this.vdom.getNodeFromIndex(element.globalElementIndex);\n }\n\n getNodeDataFromEl(el: HTMLElement): VdomNode {\n const type = el.tagName.toLowerCase() as VdomNodeType;\n const node = {\n type,\n className: el.getAttribute('class'),\n transform: el.getAttribute('transform'),\n id: el.getAttribute('id'),\n style: {},\n css: {},\n children: [],\n globalElementIndex: -1,\n text:\n !el.childNodes ||\n (el.childNodes.length === 1 && !(el.childNodes[0] as HTMLElement).tagName)\n ? el.textContent\n : undefined,\n };\n\n for (const attr of RELEVANT_ATTRS[type]) {\n if (el.hasAttribute(attr)) {\n const value = el.getAttribute(attr);\n node[attr] = ROUNDED_ATTRS[attr] ? parseFloat(value) : value;\n }\n }\n\n this.copyStylesFromElement(el, node);\n\n /*const clean = obj => {\n const propNames = Object.getOwnPropertyNames(obj);\n for (let i = 0; i < propNames.length; i++) {\n const propName = propNames[i];\n if (obj[propName] === null || obj[propName] === undefined) {\n delete obj[propName];\n }\n }\n };\n \n clean(node);*/\n\n return node;\n }\n\n copyStylesFromElement(el: HTMLElement, node: VdomNode) {\n for (const styleProp of CSS_STYLES) {\n if (el.style.hasOwnProperty(styleProp)) {\n const val = el.style[styleProp];\n if (val && typeof el.style[styleProp] !== 'function') {\n const kebabCase = styleProp.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();\n node.style[kebabCase] = el.style[styleProp];\n }\n }\n }\n }\n\n applyStyles() {\n if (!this.nodesToRestyle || !this.nodesToRestyle.length) {\n return;\n }\n\n for (let i = 0; i < document.styleSheets.length; i++) {\n const sheet = document.styleSheets[i] as any;\n const rules = (sheet.rules ? sheet.rules : sheet.cssRules) as CSSRuleList;\n\n for (let j = 0; j < rules.length; j++) {\n const rule = rules[j] as any;\n const selector = rule.selectorText as string;\n if (!selector) {\n continue; // Skip @imports etc.\n }\n this.applyRuleToMatchingNodes(selector, rule);\n }\n }\n\n this.nodesToRestyle = [];\n }\n\n private applyRuleToMatchingNodes(\n selectorString: string,\n rule: {style: {[settingName: string]: string}}\n ): boolean {\n selectorString = selectorString.trim();\n\n const selector = selectorString.replace(' >', '>').replace('> ', '>').replace('svg>', '');\n\n const selectorPartsLooseStrict = selector.split(' ').map((part) => part.split('>'));\n\n // Find all relevant element IDs.\n const relevantIds = this.nodesToRestyle.map((n) => n.globalElementIndex);\n for (const nodeToBeStyled of this.nodesToRestyle) {\n if (nodeToBeStyled) {\n // I don't know why, but there are null values in there.\n let parent = this.getNodeParent(nodeToBeStyled);\n while (parent && relevantIds.indexOf(parent.globalElementIndex) === -1) {\n relevantIds.push(parent.globalElementIndex);\n parent = this.getNodeParent(parent);\n }\n }\n }\n const relevantIdMap: {[globalElementIndex: number]: true} = {};\n for (const index of relevantIds) {\n relevantIdMap[index] = true;\n }\n\n const setStyle = (\n styleName: string,\n rule: {style: {[settingName: string]: string}},\n child: VdomNode\n ) => {\n if (rule.style[styleName]) {\n const longSpecName = `css;${selectorString};${styleName}`;\n this.vdom.ensureInitialized(longSpecName);\n\n this.vdom.set(child, longSpecName, rule.style[styleName]);\n }\n };\n\n const checkNode = (currentNode: VdomNode, looseIndex = 0, strictIndex = 0): boolean => {\n const selPart = selectorPartsLooseStrict[looseIndex][strictIndex];\n\n for (let childIndex = 0; childIndex < currentNode.children.length; childIndex++) {\n const child = currentNode.children[childIndex];\n if (!relevantIdMap[child.globalElementIndex]) {\n continue;\n }\n let partialMatch = VdomManager.isCssRulePartialMatch(selPart, child, currentNode);\n\n if (partialMatch) {\n if (selectorPartsLooseStrict[looseIndex].length > strictIndex + 1) {\n checkNode(child, looseIndex, strictIndex + 1);\n } else if (selectorPartsLooseStrict.length > looseIndex + 1) {\n checkNode(child, looseIndex + 1, strictIndex);\n } else {\n if (!child.css[selectorString]) {\n for (const styleName of CSS_STYLES) {\n setStyle(styleName, rule, child);\n }\n }\n }\n } else {\n if (child['removedClasses']) {\n // temporarily add the class, see if it matches this rule, and if so, un-apply its stuff.\n for (const removedClass of child['removedClasses']) {\n child.className += ' ' + removedClass;\n\n let newPartialMatch = VdomManager.isCssRulePartialMatch(\n selPart,\n child,\n currentNode\n );\n if (newPartialMatch) {\n this.removeRuleStylesFromNode(selectorString, child);\n }\n\n child.className = child.className.substr(\n 0,\n child.className.length - removedClass.length - 1\n );\n }\n setTimeout(() => {\n delete child['removedClasses'];\n }); // After this frame, reset which classes have been removed.\n }\n checkNode(child, looseIndex, strictIndex);\n }\n }\n return false;\n };\n\n return checkNode(this.vdom.data);\n }\n\n removeRuleStylesFromNode(selector: string, child: VdomNode) {\n if (child.css[selector]) {\n this.vdom.ensureInitialized(`css;${selector};*`);\n this.vdom.set(child, `css;${selector};*`, '');\n }\n }\n\n removeNode(element: SsvgElement, node: VdomNode, parentNode: VdomNode) {\n //console.log('removing', node, 'from', parentNode, [...parentNode.children], childIndex, childIndex2);\n this.vdom.removeNode(node, parentNode);\n\n this.nodes[node.globalElementIndex] = null;\n this.elements[element.globalElementIndex] = null;\n\n const restyleIndex = this.nodesToRestyle.indexOf(node);\n if (restyleIndex !== -1) {\n this.nodesToRestyle.splice(restyleIndex, 1);\n }\n this.removedNodeIndices.push(element.globalElementIndex);\n }\n\n restyleNode(node: VdomNode) {\n if (!this.nodes[node.globalElementIndex] || this.nodes[node.globalElementIndex] !== node) {\n console.error(node);\n throw new Error('restyling incorrect node');\n }\n this.nodesToRestyle.push(node);\n }\n\n private addChildNodesToVisData(childEls: SsvgElement[] | NodeList, parentNode: VdomNode) {\n for (let i = 0; i < childEls.length; i++) {\n let el = childEls[i] as SsvgElement;\n\n try {\n const node = this.getNodeDataFromEl(el);\n\n parentNode.children.push(node);\n this.linkNodeToElement(node, el);\n this.nodesToRestyle.push(node);\n\n if (el.childNodes) {\n this.addChildNodesToVisData(el.childNodes, node);\n }\n if (node.type === 'tspan') {\n //console.log(node, el, el.childNodes, el.textContent);\n //console.log(el.childNodes[0])\n //console.log(node, style.textAnchor);\n }\n if (node.type === 'text') {\n //console.log(node, el, el.childNodes, el.textContent);\n }\n } catch (e) {\n //console.log(e);\n //console.log(el);\n }\n }\n }\n\n combineElementSelectors(parentSelector: string, elementType: string, childIndex: number) {\n return parentSelector + ' > ' + elementType + ':nth-child(' + childIndex + ')';\n }\n\n getNodeParent(node: VdomNode): VdomNode | null {\n if (node === this.vdom.data) {\n return null;\n }\n const el = this.getElementFromNode(node);\n if (!el) {\n console.error('can not find element for node ', node);\n return null;\n }\n const parentEl = el.parentNode as SsvgElement;\n return this.getNodeFromElement(parentEl);\n }\n\n private getNewElementIndex() {\n if (this.removedNodeIndices.length) {\n return this.removedNodeIndices.shift();\n }\n this.maxGlobalElementIndex++;\n return this.maxGlobalElementIndex - 1;\n }\n\n linkNodeToElement(node: VdomNode, element: SsvgElement) {\n const index = this.getNewElementIndex();\n node.globalElementIndex = index;\n element.globalElementIndex = index;\n\n this.nodes[index] = node;\n this.elements[index] = element;\n\n this.vdom.addNode(node);\n }\n\n getElementFromNode(node: VdomNode): SsvgElement {\n if (node === this.vdom.data) {\n return this.svg;\n }\n return this.elements[node.globalElementIndex];\n }\n\n getNodeFromElement(element: SsvgElement): VdomNode {\n if (element === this.svg) {\n return this.vdom.data;\n }\n return this.vdom.getNodeFromIndex(element.globalElementIndex);\n }\n\n isWithinSvg(element: Element) {\n let isWithinSvg = false;\n let parentEl = element;\n\n while (parentEl && parentEl.parentNode) {\n if (parentEl === this.svg) {\n isWithinSvg = true;\n }\n parentEl = <Element>parentEl.parentNode;\n }\n return isWithinSvg;\n }\n\n getParentNode(node: VdomNode): VdomNode | null {\n const element = this.getElementFromNode(node);\n const parentElement = element.parentNode as SsvgElement;\n return this.getNodeFromElement(parentElement);\n }\n\n getTotalTransformation(node: VdomNode): Transformation {\n let parent = this.getParentNode(node);\n const parents = [node];\n\n while (parent) {\n parents.push(parent);\n parent = this.getParentNode(parent);\n }\n\n parent = parents.pop();\n let totalTransform: Transformation = {\n translateX: 0,\n translateY: 0,\n scaleX: 0,\n scaleY: 0,\n rotate: 0,\n translateBeforeScale: false,\n rotateLast: false,\n };\n\n while (parent) {\n const transform = DrawingUtils.parseTransform(parent.transform);\n totalTransform = DrawingUtils.addTransforms(totalTransform, transform);\n parent = parents.pop();\n }\n\n return totalTransform;\n }\n}\n\nexport type SsvgElement = HTMLElement & {\n __data__: any;\n globalElementIndex: number;\n};\n","import {SetPropertyQueueData, AttrValues} from './set-property-queue-data';\nimport {VDOM, VdomNode} from './vdom';\nimport {SsvgElement} from '../../frontend/domhandler';\nimport {safeLog} from '../safelogs';\n\ninterface SharedDataStore {\n values: {[attrName: string]: Int32Array};\n buffers: {[attrName: string]: SharedArrayBuffer};\n}\n\nexport class VdomManager {\n private sharedRenderData: SharedDataStore = {values: {}, buffers: {}};\n private syncedSharedData: SharedDataStore = {values: {}, buffers: {}};\n private sharedDataQueue: SharedDataStore = {values: {}, buffers: {}};\n private queue: SetPropertyQueueData = {};\n private useSharedArrayFor = ['cx', 'cy', 'x1', 'x2', 'y1', 'y2', 'x', 'y'];\n private static IGNOREDESIGN_ATTRIBUTES = ['fill', 'stroke', 'opacity'];\n private indexToNodeMap: {[index: number]: VdomNode} = {};\n private static BUFFER_PRECISION_FACTOR = 10;\n private changed = false;\n\n constructor(public data: VDOM, private ignoreDesign: boolean, private isRenderer: boolean) {\n this.ensureNodesMapped();\n\n if (!('SharedArrayBuffer' in self)) {\n this.useSharedArrayFor = [];\n }\n }\n\n ensureInitialized(attrName: string, useBuffer = true, numNodes?: number) {\n if (attrName === 'class') {\n attrName = 'className';\n }\n\n if (!useBuffer || this.useSharedArrayFor.indexOf(attrName) === -1) {\n if (!this.queue[attrName]) {\n this.queue[attrName] = {};\n }\n } else {\n const newLength = numNodes < 500 ? 1000 : Math.round(numNodes * 2);\n\n if (!this.sharedDataQueue.values[attrName]) {\n let prevData: AttrValues;\n\n // If values have been previously set without a buffer, transfer them.\n if (this.queue[attrName] && !(this.queue[attrName] instanceof SharedArrayBuffer)) {\n prevData = <AttrValues>this.queue[attrName];\n }\n\n const {buffer, values} = this.createBufferTransferValues(\n newLength,\n undefined,\n prevData\n );\n this.sharedDataQueue.values[attrName] = values;\n this.sharedDataQueue.buffers[attrName] = buffer;\n this.queue[attrName] = buffer;\n } else {\n const newByteLength = Int32Array.BYTES_PER_ELEMENT * newLength;\n if (this.sharedDataQueue.values[attrName].byteLength / newByteLength < 0.6) {\n // Need to allocate more space\n const {buffer, values} = this.createBufferTransferValues(\n newLength,\n this.sharedDataQueue.values[attrName]\n );\n this.sharedDataQueue.values[attrName] = values;\n this.sharedDataQueue.buffers[attrName] = buffer;\n }\n }\n }\n }\n\n createBufferTransferValues(length: number, prevBufferVals?: Int32Array, prevData?: AttrValues) {\n let buffer = new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * length);\n const values = new Int32Array(buffer);\n\n // If values have been previously set without a buffer, transfer them.\n if (prevData) {\n for (const index in prevData) {\n if (prevData.hasOwnProperty(index)) {\n let value = prevData[index];\n if (typeof value === 'string') {\n value = parseFloat(value);\n }\n values[index] = value * VdomManager.BUFFER_PRECISION_FACTOR;\n }\n }\n }\n\n // If values have been previously set in a buffer, transfer them.\n if (prevBufferVals) {\n for (let i = 0; i < prevBufferVals.length; i++) {\n if (prevBufferVals[i]) {\n values[i] = prevBufferVals[i];\n }\n }\n }\n\n return {buffer, values};\n }\n\n set(\n element: VdomNode | SsvgElement,\n attrName: string,\n value: string | number,\n useBuffer = true\n ) {\n if (attrName === 'class') {\n attrName = 'className';\n }\n if (element.globalElementIndex === undefined) {\n console.error('No index', element);\n throw new Error('Element has no index');\n }\n const index = element.globalElementIndex;\n const storage =\n useBuffer && this.useSharedArrayFor.indexOf(attrName) !== -1 ? 'shared' : 'raw';\n try {\n this.changed = true;\n if (storage === 'shared') {\n if (typeof value === 'string') {\n value = parseFloat(value);\n }\n value *= VdomManager.BUFFER_PRECISION_FACTOR;\n value = Math.round(value); // This helps detect zeros.\n if (value === 0) {\n value = 56938516; // magical constant\n }\n\n this.sharedDataQueue.values[attrName][index] = value;\n } else {\n this.queue[attrName][index] = value;\n if (\n this.sharedDataQueue.values[attrName] &&\n this.syncedSharedData.values[attrName] &&\n this.syncedSharedData.values[attrName][index]\n ) {\n // un-set.\n this.sharedDataQueue.values[attrName][index] = 0;\n }\n }\n } catch (e) {\n console.error(e);\n console.log(\n this.queue,\n this.syncedSharedData.values,\n storage,\n attrName,\n element,\n index\n );\n }\n }\n\n removePendingChanges(node: VdomNode) {\n const index = node.globalElementIndex;\n for (const attrName in this.queue) {\n if (this.queue.hasOwnProperty(attrName)) {\n delete this.queue[attrName][index];\n }\n }\n for (const attrName in this.sharedDataQueue.values) {\n if (this.sharedDataQueue.values.hasOwnProperty(attrName)) {\n this.sharedDataQueue.values[attrName][index] = 0;\n }\n }\n }\n\n ensureNodesMapped() {\n const addToMap = (node: VdomNode) => {\n if (node.globalElementIndex === undefined) {\n console.error('no element index', node);\n }\n this.indexToNodeMap[node.globalElementIndex] = node;\n for (const child of node.children) {\n addToMap(child);\n }\n };\n addToMap(this.data);\n }\n\n enableFrontendDesignProperties() {\n this.ignoreDesign = false;\n }\n\n addNodeToParent(nodeData: VdomNode, parentNodeIndex: number) {\n if (nodeData.type !== 'svg') {\n const parentNode = this.getNodeFromIndex(parentNodeIndex);\n if (!parentNode) {\n console.error(\n 'could not add node without parent',\n parentNodeIndex,\n nodeData,\n Object.keys(this.indexToNodeMap)\n );\n new Error('parent not found');\n return;\n }\n parentNode.children.push(nodeData);\n }\n }\n\n addNode(node: VdomNode) {\n this.indexToNodeMap[node.globalElementIndex] = node;\n }\n\n removeNode(node: VdomNode, parent: VdomNode) {\n delete this.indexToNodeMap[node.globalElementIndex];\n const childIndex = parent.children.indexOf(node);\n\n parent.children.splice(childIndex, 1);\n this.cachedListSelections = {}; //TODO only remove relevant cache.\n\n this.removePendingChanges(node);\n }\n\n applyStyleToNodeAndChildren(\n node: VdomNode,\n styleName: string,\n styleValue: string,\n onNodeUpdated: (node: VdomNode, attrName: string) => void\n ) {\n node.style[styleName] = styleValue;\n onNodeUpdated(node, styleName);\n\n if (node.children) {\n for (let child of node.children) {\n this.applyStyleToNodeAndChildren(child, styleName, styleValue, onNodeUpdated);\n }\n }\n }\n\n applyCssToNodeAndChildren(\n node: VdomNode,\n selector: string,\n styleName: string,\n value: string,\n onNodeUpdated: (node: VdomNode, attrName: string) => void\n ) {\n if (styleName === '*' && !value) {\n delete node.css[selector];\n } else {\n if (!node.css[selector]) {\n node.css[selector] = {};\n }\n node.css[selector][styleName] = value;\n }\n onNodeUpdated(node, styleName);\n\n if (node.children) {\n for (let child of node.children) {\n this.applyCssToNodeAndChildren(child, selector, styleName, value, onNodeUpdated);\n }\n }\n }\n\n getNodeFromIndex(index: number): VdomNode {\n return this.indexToNodeMap[index];\n }\n\n getNodeById(id: string): VdomNode {\n const filtered = Object.values(this.indexToNodeMap).filter((node) => node.id === id);\n if (!filtered || filtered.length > 1) {\n safeLog(\n 'multiple nodes with this id!',\n Object.values(this.indexToNodeMap)\n .filter((node) => node.id)\n .map((node) => node.id),\n id\n );\n safeLog(filtered.length, filtered);\n }\n return !filtered || filtered.length !== 1 ? null : filtered[0];\n }\n\n private static ROUNDED_ATTRS = ['cx', 'cy'];\n\n get(node: VdomNode, attrs: string | string[]) {\n if (Array.isArray(attrs)) {\n return attrs.map((attrName) => this.getSingle(node, attrName));\n } else {\n return this.getSingle(node, attrs);\n }\n }\n\n private getSingle(node: VdomNode, attrName: string) {\n const data = this.isRenderer ? this.sharedRenderData.values : this.syncedSharedData.values;\n if (data[attrName] && data[attrName][node.globalElementIndex]) {\n const value = data[attrName][node.globalElementIndex];\n if (value === 56938516) {\n return 0;\n }\n return value / VdomManager.BUFFER_PRECISION_FACTOR;\n } else {\n return node[attrName];\n }\n }\n\n hasChanges() {\n return this.changed;\n }\n\n getQueue() {\n return this.queue;\n }\n\n clearQueue() {\n this.queue = {};\n this.changed = false;\n }\n\n transferSyncedDataToRenderData() {\n for (let attrName in this.syncedSharedData.values) {\n this.queue[attrName] = this.syncedSharedData.buffers[attrName];\n this.sharedRenderData.values[attrName] = this.syncedSharedData.values[attrName];\n\n const length =\n this.syncedSharedData.buffers[attrName].byteLength / Int32Array.BYTES_PER_ELEMENT;\n const {buffer, values} = this.createBufferTransferValues(\n length,\n this.syncedSharedData.values[attrName]\n );\n\n this.syncedSharedData.buffers[attrName] = buffer;\n this.syncedSharedData.values[attrName] = values;\n }\n }\n\n transferBufferQueueDataToSynced() {\n for (let attrName in this.sharedDataQueue.values) {\n this.queue[attrName] = this.sharedDataQueue.buffers[attrName];\n this.syncedSharedData.values[attrName] = this.sharedDataQueue.values[attrName];\n\n const length =\n this.sharedDataQueue.buffers[attrName].byteLength / Int32Array.BYTES_PER_ELEMENT;\n const {buffer, values} = this.createBufferTransferValues(\n length,\n this.sharedDataQueue.values[attrName]\n );\n\n this.sharedDataQueue.buffers[attrName] = buffer;\n this.sharedDataQueue.values[attrName] = values;\n }\n }\n\n addToQueue(setAttrQueue: SetPropertyQueueData) {\n for (let attrName in setAttrQueue) {\n if (!setAttrQueue.hasOwnProperty(attrName)) {\n continue;\n }\n if (\n 'SharedArrayBuffer' in self &&\n setAttrQueue[attrName] instanceof SharedArrayBuffer\n ) {\n const buffer = <SharedArrayBuffer>setAttrQueue[attrName];\n this.syncedSharedData.buffers[attrName] = buffer;\n this.syncedSharedData.values[attrName] = new Int32Array(buffer);\n } else {\n const values: AttrValues = <AttrValues>setAttrQueue[attrName];\n\n if (!this.queue[attrName]) {\n this.queue[attrName] = {};\n }\n\n for (let childIndex in values) {\n if (!values.hasOwnProperty(childIndex)) {\n continue;\n }\n const index = parseInt(childIndex);\n this.queue[attrName][index] = values[index];\n }\n }\n }\n }\n\n updatePropertiesFromQueue(\n setAttrQueue: SetPropertyQueueData,\n onNodeUpdated: (node: VdomNode, attrName: string) => void = () => {}\n ) {\n for (let attrName in setAttrQueue) {\n if (!setAttrQueue.hasOwnProperty(attrName)) {\n continue;\n }\n const attrNameStart = attrName.substr(0, 'style;'.length);\n if (\n this.ignoreDesign &&\n (attrNameStart === 'style;' ||\n VdomManager.IGNOREDESIGN_ATTRIBUTES.indexOf(attrName) !== -1)\n ) {\n continue;\n }\n\n let values: AttrValues | Int32Array;\n\n if (\n 'SharedArrayBuffer' in self &&\n setAttrQueue[attrName] instanceof SharedArrayBuffer\n ) {\n const buffer = <SharedArrayBuffer>setAttrQueue[attrName];\n if (!this.isRenderer) {\n this.syncedSharedData.buffers[attrName] = buffer;\n this.syncedSharedData.values[attrName] = new Int32Array(buffer);\n } else {\n this.sharedRenderData.buffers[attrName] = buffer;\n this.sharedRenderData.values[attrName] = new Int32Array(buffer);\n }\n } else {\n values = <AttrValues>setAttrQueue[attrName];\n\n for (let childIndex in values) {\n if (!values.hasOwnProperty(childIndex)) {\n continue;\n }\n const index = parseInt(childIndex);\n const childNode = this.getNodeFromIndex(index);\n if (!childNode) {\n console.error('node not found at index', index);\n continue;\n }\n let value: string | number = values[childIndex];\n if (attrNameStart === 'style;') {\n const styleName = attrName.substr('style;'.length);\n this.applyStyleToNodeAndChildren(\n childNode,\n styleName,\n <string>value,\n onNodeUpdated\n );\n } else if (attrName.substr(0, 4) === 'css;') {\n const [selector, styleName] = attrName.substr(4).split(';');\n this.applyCssToNodeAndChildren(\n childNode,\n selector,\n styleName,\n <string>value,\n onNodeUpdated\n );\n } else {\n if (VdomManager.ROUNDED_ATTRS.indexOf(attrName) !== -1) {\n if (typeof value === 'string') {\n value = parseFloat(value);\n }\n value = Math.round(value);\n }\n\n childNode[attrName] = value;\n onNodeUpdated(childNode, attrName);\n }\n }\n }\n }\n }\n\n private cachedListSelections: {\n [selector: string]: {[index: number]: VdomNode};\n } = {};\n public getVisNodeFromSelector(selector: string): VdomNode | null {\n const lastSplitPos = selector.lastIndexOf('>');\n const selectorWithoutLast = selector.substr(0, lastSplitPos);\n const lastPart = selector.substr(lastSplitPos + 1);\n const parentSel = selectorWithoutLast\n ? this.cachedListSelections[selectorWithoutLast]\n : null;\n let index = -1;\n const nthChildPosition = lastPart.indexOf(':nth-child(');\n if (nthChildPosition !== -1) {\n index = parseInt(lastPart.substr(nthChildPosition + 11)); // length of ':nth-child('\n if (parentSel && parentSel[index]) {\n return parentSel[index];\n }\n }\n\n const selectedNodes: VdomNode[] = [];\n this.findMatchingChildren(this.data, selector, 0, selectedNodes);\n\n if (selectedNodes && selectedNodes.length === 1) {\n const el = selectedNodes[0];\n if (index !== -1) {\n if (!this.cachedListSelections[selectorWithoutLast]) {\n this.cachedListSelections[selectorWithoutLast] = {};\n }\n this.cachedListSelections[selectorWithoutLast][index] = el;\n }\n return el;\n }\n return null;\n }\n\n public getVisNodesFromSelector(visNode: VdomNode, selector: string) {\n const selectedNodes = [];\n this.findMatchingChildren(visNode, selector, 0, selectedNodes);\n return selectedNodes;\n }\n\n private findChildrenOfType(visNode: VdomNode, type: string, selectedNodes: VdomNode[]) {\n const addDirectChildrenIfMatch = (node: VdomNode) => {\n for (const child of node.children) {\n if (child.type === type) {\n selectedNodes.push(child);\n }\n if (node.children.length !== 0) {\n addDirectChildrenIfMatch(child);\n }\n }\n };\n addDirectChildrenIfMatch(visNode);\n }\n\n public filterNodesBySelector(parentNode: VdomNode, nodes: VdomNode[], selector: string) {\n return nodes.filter((node) =>\n VdomManager.isCssRulePartialMatch(selector, node, parentNode)\n );\n }\n\n private findMatchingChildren(\n visNode: VdomNode,\n selector: string,\n matchIndex: number,\n selectedNodes: VdomNode[],\n selectedNodeSelectors: string[] = []\n ) {\n if (!selector && selector !== '') {\n console.error(visNode, selector, matchIndex, selectedNodes, selectedNodeSelectors);\n throw Error('undefined selector');\n }\n\n let selParts = selector.split('>').map((s) => s.trim());\n let selPart = selParts[matchIndex];\n\n if (matchIndex === 0 && selPart === 'svg') {\n matchIndex++;\n selPart = selParts[matchIndex];\n if (matchIndex === selParts.length) {\n selectedNodes.push(visNode);\n selectedNodeSelectors.push(selector);\n return;\n }\n }\n\n if (selector.match(/^[a-z]+$/)) {\n return this.findChildrenOfType(visNode, selector, selectedNodes);\n }\n\n for (let i = 0; i < visNode.children.length; i++) {\n let node = visNode.children[i];\n let matching = false;\n\n if (VdomManager.isCssRulePartialMatch(selPart, node, visNode)) {\n if (matchIndex === selParts.length - 1) {\n selectedNodes.push(node);\n selectedNodeSelectors.push(selector);\n } else {\n matching = true;\n }\n }\n\n if (\n node.children &&\n (matching || selParts.length < 2) &&\n matchIndex + 1 < selParts.length\n ) {\n this.findMatchingChildren(\n node,\n selector,\n matchIndex + 1,\n selectedNodes,\n selectedNodeSelectors\n );\n }\n }\n }\n\n public static isCssRulePartialMatch(\n cssRuleSelectorPart: string,\n node: VdomNode,\n parentNode: VdomNode\n ): boolean {\n if (cssRuleSelectorPart.substr(0, 5) === ':not(') {\n const newSelPart = cssRuleSelectorPart\n .substr(0, cssRuleSelectorPart.length - 1)\n .substr(5);\n return !VdomManager.isCssRulePartialMatch(newSelPart, node, parentNode);\n }\n if (cssRuleSelectorPart[0] === '.') {\n // Example: .className or .classnameA.classnameB\n const searchClassNames = cssRuleSelectorPart.split('.');\n searchClassNames.shift(); // remove empty first string.\n if (node.className) {\n let allTrue = true;\n for (const searchClassName of searchClassNames) {\n if (node.className.split(' ').indexOf(searchClassName) === -1) {\n allTrue = false;\n }\n }\n return allTrue;\n }\n } else if (cssRuleSelectorPart[0] === '#') {\n // Example: #id\n if (cssRuleSelectorPart.substr(1) === node.id) {\n return true;\n }\n } else if (cssRuleSelectorPart.match(/^[a-z]+$/)) {\n // Example: rect\n if (cssRuleSelectorPart === node.type) {\n return true;\n }\n } else if (cssRuleSelectorPart.indexOf(':nth-child(') !== -1) {\n let type = 'any';\n let indexPart = cssRuleSelectorPart;\n\n if (cssRuleSelectorPart[0] !== ':') {\n type = cssRuleSelectorPart.substr(0, cssRuleSelectorPart.indexOf(':'));\n indexPart = cssRuleSelectorPart.substr(cssRuleSelectorPart.indexOf(':'));\n }\n\n const targetIndex = parseInt(indexPart.substr(':nth-child('.length));\n const index = parentNode.children.indexOf(node);\n\n return index === targetIndex - 1 && (type === 'any' || node.type === type);\n } else if (cssRuleSelectorPart.indexOf('.') !== -1) {\n // Example: rect.className\n const cutoff = cssRuleSelectorPart.indexOf('.');\n const typeName = cssRuleSelectorPart.substr(0, cutoff);\n const className = cssRuleSelectorPart.substr(cutoff + 1);\n if (\n typeName === node.type &&\n node.className &&\n node.className.split(' ').indexOf(className) !== -1\n ) {\n return true;\n }\n }\n return false;\n }\n}\n","import {VdomNodeType} from '../util/vdom/vdom';\n\nexport const CSS_STYLES = [\n 'stroke',\n 'stroke-opacity',\n 'stroke-width',\n 'stroke-linejoin',\n 'fill',\n 'fill-opacity',\n 'font',\n 'opacity',\n 'font-family',\n 'font-size',\n];\n\nexport const RELEVANT_ATTRS: {[type in VdomNodeType]: string[]} = {\n svg: [\n 'fill',\n 'opacity',\n 'fill-opacity',\n 'stroke',\n 'stroke-opacity',\n 'stroke-width',\n 'font-size',\n 'font',\n 'font-family',\n 'text-anchor',\n ],\n g: [\n 'fill',\n 'opacity',\n 'fill-opacity',\n 'stroke',\n 'stroke-opacity',\n 'stroke-width',\n 'font-size',\n 'font',\n 'font-family',\n 'text-anchor',\n 'clip-path',\n ],\n rect: [\n 'fill',\n 'opacity',\n 'fill-opacity',\n 'stroke',\n 'stroke-opacity',\n 'stroke-width',\n 'x',\n 'y',\n 'width',\n 'height',\n 'clip-path',\n ],\n circle: [\n 'fill',\n 'opacity',\n 'fill-opacity',\n 'stroke',\n 'stroke-opacity',\n 'stroke-width',\n 'cx',\n 'cy',\n 'r',\n 'clip-path',\n ],\n path: [\n 'fill',\n 'opacity',\n 'fill-opacity',\n 'stroke',\n 'stroke-opacity',\n 'stroke-width',\n 'd',\n 'clip-path',\n ],\n title: [],\n tspan: ['dx', 'dy'],\n text: [\n 'fill',\n 'opacity',\n 'fill-opacity',\n 'stroke',\n 'stroke-opacity',\n 'stroke-width',\n 'font-size',\n 'font',\n 'font-family',\n 'text-anchor',\n 'href',\n 'x',\n 'y',\n 'dx',\n 'dy',\n ],\n image: ['opacity', 'x', 'y', 'width', 'height'],\n clippath: ['id', 'fill', 'opacity', 'fill-opacity', 'stroke', 'stroke-opacity', 'stroke-width'],\n line: [\n 'opacity',\n 'stroke',\n 'stroke-opacity',\n 'stroke-width',\n 'x1',\n 'x2',\n 'y1',\n 'y2',\n 'clip-path',\n ],\n};\n\nconst ROUNDED_ATTRS_ARR = [\n 'cx',\n 'cy',\n 'r',\n 'x',\n 'y',\n 'x1',\n 'x2',\n 'y1',\n 'y2',\n 'width',\n 'height',\n 'stroke-width',\n];\n\nexport const ROUNDED_ATTRS = {};\nfor (const attr of ROUNDED_ATTRS_ARR) {\n ROUNDED_ATTRS[attr] = true;\n}\n","import {VdomNode} from '../util/vdom/vdom';\nimport {VdomManager} from '../util/vdom/vdom-manager';\nimport {DrawingUtils} from './drawingUtils';\nimport {CanvasWorker} from './canvasworker';\nimport {safeErrorLog} from '../util/safelogs';\n\ntype DrawMode = 'start' | 'normal' | 'end' | 'forcesingle';\n\nexport class Canvasrenderer implements CanvasWorker {\n private ctx: CanvasRenderingContext2D;\n private parentValues: {[prop: string]: string | number} = {};\n\n constructor(\n private vdom: VdomManager,\n private canvas: HTMLCanvasElement,\n private forceSingle = false,\n private onDrawn = () => {}\n ) {\n const ctx = canvas.getContext('2d');\n if (!ctx) throw new Error('could not create canvas context');\n\n this.ctx = ctx;\n this.ctx.scale(this.vdom.data.scale, this.vdom.data.scale);\n this.ctx.save();\n\n this.draw();\n\n setTimeout(() => {\n console.log(this.forceSingle, this.vdom.data);\n //this.draw();\n }, 1000);\n }\n\n private lastFullSecond = 0;\n private countSinceLastFullSecond = 0;\n\n draw() {\n const ctx = this.ctx;\n\n ctx.restore();\n ctx.save();\n\n //ctx.fillStyle = '#fff';\n //ctx.fillRect(0, 0, this.vdom.data.width, this.vdom.data.height);\n ctx.clearRect(0, 0, this.vdom.data.width, this.vdom.data.height);\n\n //this.lastDrawn = null;\n this.drawLine(null, 'start');\n this.drawCircle(null, 'start');\n this.drawRect(null, 'start');\n this.drawText(null, 'start');\n this.drawImage(null, 'start');\n\n this.drawNodeAndChildren(this.vdom.data, this.forceSingle);\n\n this.drawLine(null, 'end');\n this.drawCircle(null, 'end');\n this.drawRect(null, 'end');\n this.drawText(null, 'end');\n this.drawImage(null, 'end');\n\n this.onDrawn();\n\n const fullSecond = Math.round(performance.now() / 1000);\n if (fullSecond !== this.lastFullSecond) {\n this.lastFullSecond = fullSecond;\n //console.log(this.countSinceLastFullSecond);\n this.countSinceLastFullSecond = 0;\n }\n this.countSinceLastFullSecond++;\n }\n\n private drawNodeAndChildren(elData: VdomNode, forceSingle: boolean, drawClip?: Path2D) {\n if (elData.type === 'clippath' && !drawClip) {\n return;\n }\n\n const ctx = this.ctx;\n const parentValuesBackup = {...this.parentValues};\n\n const saveRestoreContext = !drawClip && (elData.children.length || elData.transform);\n if (saveRestoreContext) {\n ctx.save();\n }\n\n this.applyTransform(elData.transform);\n\n if (elData.transform || drawClip) {\n forceSingle = true;\n }\n\n if (elData['clip-path']) {\n if (elData['clip-path'].substr(0, 5) === 'url(#') {\n const clipPathId = elData['clip-path'].substr(5, elData['clip-path'].length - 6);\n const clipNode = this.vdom.getNodeById(clipPathId);\n forceSingle = true;\n\n if (!clipNode) {\n //safeErrorLog('clip node not found', elData['clip-path'], clipPathId, this.vdom.data)\n } else {\n const path = new Path2D();\n this.drawNodeAndChildren(clipNode, forceSingle, path);\n ctx.clip(path);\n }\n } else {\n safeErrorLog('clip path format not supported:', elData['clip-path']);\n }\n }\n\n if (!elData.style.display || elData.style.display !== 'none') {\n if (!forceSingle) {\n this.drawSingleNode(elData, 'normal', drawClip);\n } else {\n this.drawSingleNode(elData, 'forcesingle', drawClip);\n }\n }\n\n if (elData.children) {\n this.parentValues['fill'] = elData.fill || this.parentValues['fill'];\n this.parentValues['style;fill'] = elData.style.fill || this.parentValues['style;fill'];\n this.parentValues['stroke'] = elData.stroke || this.parentValues['stroke'];\n this.parentValues['style;stroke'] =\n elData.style.stroke || this.parentValues['style;stroke'];\n this.parentValues['opacity'] = elData.opacity || this.parentValues['opacity'];\n\n for (let i = 0; i < elData.children.length; i++) {\n this.drawNodeAndChildren(elData.children[i], forceSingle, drawClip);\n }\n }\n\n if (saveRestoreContext) {\n //safeLog('restoring ctx', elData);\n ctx.restore();\n }\n this.parentValues = parentValuesBackup;\n }\n\n private drawSingleNode(elData: VdomNode, mode: DrawMode = 'normal', path?: Path2D) {\n const type: string = elData.type;\n const drawFct = this['draw' + type.substr(0, 1).toUpperCase() + type.substr(1)];\n if (!drawFct) {\n return console.error('no draw function yet for ', type);\n }\n drawFct.call(this, elData, mode, path);\n }\n\n private drawClippath(elData: VdomNode) {\n //safeLog('clippaths can not be rendered yet.')\n }\n\n private drawSvg() {}\n private drawTitle() {}\n private drawG() {}\n\n private circlesByColor: {[color: string]: VdomNode[]} = {};\n private drawCircle(elData: VdomNode, mode: DrawMode = 'normal', path?: Path2D) {\n if (mode === 'normal') {\n let fill = this.getFillStyle(elData, '#000');\n const stroke = this.getStrokeStyle(elData);\n const handle = fill + ';' + stroke;\n if (!this.circlesByColor[handle]) {\n this.circlesByColor[handle] = [];\n }\n this.circlesByColor[handle].push(elData);\n }\n if (mode === 'start') {\n this.circlesByColor = {};\n return;\n }\n if (mode === 'end') {\n for (let fillAndStrokeColor in this.circlesByColor) {\n if (this.circlesByColor.hasOwnProperty(fillAndStrokeColor)) {\n const split = fillAndStrokeColor.split(';');\n const fillColor = split[0];\n const strokeColor = split[1];\n\n this.ctx.fillStyle = fillColor;\n let sampleData = this.circlesByColor[fillAndStrokeColor][0];\n const lineWidth = this.getStrokeWidth(sampleData);\n this.ctx.lineWidth = lineWidth !== undefined ? lineWidth : 1;\n this.ctx.strokeStyle = strokeColor;\n\n this.ctx.beginPath();\n for (let elData of this.circlesByColor[fillAndStrokeColor]) {\n // Round values so that paths are connected correctly and there are no rendering glitches\n const cx = Math.round(this.vdom.get(elData, 'cx')) || 0;\n const cy = Math.round(this.vdom.get(elData, 'cy')) || 0;\n const r = Math.round(this.vdom.get(elData, 'r'));\n this.ctx.save();\n this.applyTransform(elData.transform);\n this.ctx.moveTo(cx + r, cy);\n this.ctx.arc(cx, cy, r, 0, 2 * Math.PI);\n this.ctx.restore();\n //this.ctx.restore();\n }\n\n if (fillColor !== 'none') {\n this.ctx.fill();\n }\n\n if (strokeColor && strokeColor !== 'none') {\n this.ctx.stroke();\n }\n }\n }\n return;\n }\n if (mode === 'forcesingle') {\n let fill = this.getFillStyle(elData, '#000');\n const strokeStyle = this.getStrokeStyle(elData);\n\n const cx = this.vdom.get(elData, 'cx') || 0;\n const cy = this.vdom.get(elData, 'cy') || 0;\n\n this.ctx.beginPath();\n this.ctx.fillStyle = fill;\n this.ctx.strokeStyle = strokeStyle;\n this.ctx.lineWidth = this.getStrokeWidth(elData);\n this.ctx.moveTo(cx + elData.r, cy);\n const context = path ? path : this.ctx;\n context.arc(cx, cy, elData.r, 0, 2 * Math.PI);\n if (fill !== 'none' && !path) {\n this.ctx.fill();\n }\n\n if (strokeStyle && strokeStyle !== 'none' && !path) {\n this.ctx.stroke();\n }\n }\n }\n\n nodeUpdated(node: VdomNode, attr: string) {\n if (attr === '*' || attr.includes('fill') || attr.includes('opacity')) {\n delete node['fill-cache'];\n }\n if (attr === '*' || attr.includes('stroke') || attr.includes('opacity')) {\n delete node['stroke-cache'];\n delete node['strokewidth-cache'];\n }\n }\n\n private getFillStyle(node: VdomNode, defaultColor = 'none'): string {\n if ('fill-cache' in node) {\n return node['fill-cache'];\n }\n let fill = this.getAttributeStyleCss(node, 'fill');\n let opacity = this.getAttributeStyleCss(node, 'opacity') || 1;\n const fillOpacity = this.getAttributeStyleCss(node, 'fill-opacity') || 1;\n opacity *= fillOpacity;\n\n let defaultCol = '';\n if (this.parentValues['fill']) {\n defaultCol = this.parentValues['fill'] as string;\n }\n if (this.parentValues['style;fill']) {\n defaultCol = this.parentValues['style;fill'] as string;\n }\n if (!this.parentValues['fill'] && !this.parentValues['style;fill']) {\n defaultCol = defaultColor;\n }\n\n fill = DrawingUtils.colorToRgba(fill, opacity, defaultCol);\n node['fill-cache'] = fill;\n return fill;\n }\n\n private getAttributeStyleCss(node: VdomNode, style: string) {\n if (node.style[style]) {\n return node.style[style];\n } else {\n if (this.parentValues[`style;${style}`]) {\n return this.parentValues[`style;${style}`];\n }\n let value = node[style];\n\n let highestSpec = -1;\n for (const selector in node.css) {\n if (node.css[selector][style]) {\n const specificity = DrawingUtils.getCssRuleSpecificityNumber(selector);\n if (specificity > highestSpec) {\n value = node.css[selector][style];\n highestSpec = specificity;\n }\n }\n }\n return value;\n }\n }\n\n private getStrokeStyle(node: VdomNode, defaultColor = 'none'): string {\n if ('stroke-cache' in node) {\n return node['stroke-cache'];\n }\n const stroke = this.getAttributeStyleCss(node, 'stroke');\n let opacity = this.getAttributeStyleCss(node, 'opacity') || 1;\n const fillOpacity = this.getAttributeStyleCss(node, 'stroke-opacity') || 1;\n opacity *= fillOpacity;\n\n let defaultCol = '';\n if (this.parentValues['stroke']) {\n defaultCol = this.parentValues['stroke'] as string;\n } else {\n defaultCol = defaultColor;\n }\n\n if (stroke !== undefined) {\n node['stroke-cache'] = DrawingUtils.colorToRgba(stroke, opacity);\n } else {\n node['stroke-cache'] = defaultCol;\n }\n return node['stroke-cache'];\n }\n\n private getStrokeWidth(node: VdomNode) {\n if ('strokewidth-cache' in node) {\n return node['strokewidth-cache'];\n }\n const width = this.getAttributeStyleCss(node, 'stroke-width');\n node['strokewidth-cache'] = width === undefined ? undefined : parseFloat(width);\n\n return node['strokewidth-cache'];\n }\n\n private rectsByColor = {};\n\n private drawRect(elData: VdomNode, mode: DrawMode = 'normal', path?: Path2D) {\n if (mode === 'normal') {\n let fill = this.getFillStyle(elData, '#000');\n const stroke = this.getStrokeStyle(elData);\n const handle = fill + ';' + stroke;\n if (!this.rectsByColor[handle]) {\n this.rectsByColor[handle] = [];\n }\n this.rectsByColor[handle].push(elData);\n }\n if (mode === 'start') {\n this.rectsByColor = {};\n return;\n }\n if (mode === 'end') {\n for (let fillAndStrokeColor in this.rectsByColor) {\n if (this.rectsByColor.hasOwnProperty(fillAndStrokeColor)) {\n const split = fillAndStrokeColor.split(';');\n const fillColor = split[0];\n const strokeColor = split[1];\n this.ctx.fillStyle = fillColor;\n\n let sampleData = this.rectsByColor[fillAndStrokeColor][0];\n const lineWidth = this.getStrokeWidth(sampleData);\n this.ctx.lineWidth = lineWidth !== undefined ? lineWidth : 1;\n this.ctx.strokeStyle = strokeColor;\n\n this.ctx.beginPath();\n for (let elData of this.rectsByColor[fillAndStrokeColor]) {\n // Round values so that paths are connected correctly and there are no rendering glitches\n const x = Math.round(this.vdom.get(elData, 'x')) || 0;\n const y = Math.round(this.vdom.get(elData, 'y')) || 0;\n this.ctx.save();\n this.applyTransform(elData.transform);\n this.ctx.moveTo(x, y);\n this.ctx.rect(x, y, elData.width, elData.height);\n this.ctx.restore();\n //this.ctx.restore();\n }\n if (fillColor !== 'none') {\n this.ctx.fill();\n }\n\n if (strokeColor && strokeColor !== 'none') {\n this.ctx.stroke();\n }\n }\n }\n return;\n }\n if (mode === 'forcesingle') {\n let fill = this.getFillStyle(elData, '#000');\n const stroke = this.getStrokeStyle(elData);\n\n const x = this.vdom.get(elData, 'x') || 0;\n const y = this.vdom.get(elData, 'y') || 0;\n\n if (fill && fill !== 'none' && !path) {\n this.ctx.fillStyle = fill;\n this.ctx.fillRect(x, y, elData.width, elData.height);\n }\n if (path) {\n path.rect(x, y, elData.width, elData.height);\n }\n\n if (stroke !== 'none' && !path) {\n this.ctx.strokeStyle = stroke;\n this.ctx.beginPath();\n this.ctx.rect(x, y, elData.width, elData.height);\n this.ctx.stroke();\n }\n }\n }\n\n private drawTexts: VdomNode[] = [];\n\n private drawText(node: VdomNode, mode: DrawMode = 'normal', isClip = false) {\n const drawSingle = (elData: VdomNode) => {\n if (elData.text === '') {\n return;\n }\n let fontFamily = this.getAttributeStyleCss(elData, 'font-family') || 'Times New Roman';\n\n let fontSize = '16px';\n const customSize = this.getAttributeStyleCss(elData, 'font-size');\n if (customSize) {\n fontSize = DrawingUtils.convertSizeToPx(customSize) + 'px';\n }\n let font = this.getAttributeStyleCss(elData, 'font');\n if (!font) {\n font = fontSize + ' ' + fontFamily;\n }\n let align = this.getAttributeStyleCss(elData, 'text-anchor');\n if (align) {\n if (align === 'middle') {\n align = 'center';\n }\n this.ctx.textAlign = align;\n }\n this.ctx.font = font;\n this.ctx.fillStyle = this.getFillStyle(elData, '#000');\n\n let x = this.vdom.get(elData, 'x') || 0;\n let y = this.vdom.get(elData, 'y') || 0;\n let dx = DrawingUtils.convertSizeToPx(elData.dx, false) || 0;\n let dy = DrawingUtils.convertSizeToPx(elData.dy, false) || 0;\n this.ctx.fillText(elData.text, x + dx, y + dy);\n };\n if (mode === 'start') {\n this.drawTexts = [];\n return;\n }\n if (mode === 'normal') {\n this.drawTexts.push(node);\n return;\n }\n if (mode === 'forcesingle') {\n return drawSingle(node);\n }\n if (mode === 'end') {\n for (const currentNode of this.drawTexts) {\n drawSingle(currentNode);\n }\n return;\n }\n }\n\n private drawImages: VdomNode[] = [];\n\n private drawImage(node: VdomNode, mode: DrawMode = 'normal') {\n const drawSingle = (elData: VdomNode) => {\n if (elData.href === '') {\n return;\n }\n let fill = elData['fill'] ? elData['fill'] : elData.style['fill'];\n if (!fill) fill = '#000';\n this.ctx.fillStyle = fill;\n let x = this.vdom.get(elData, 'x') || 0;\n let y = this.vdom.get(elData, 'y') || 0;\n let width = elData.width || 0;\n let height = elData.height || 0;\n if (elData.image) {\n try {\n this.ctx.drawImage(elData.image, x, y, width, height);\n } catch (e) {\n console.log(e);\n }\n }\n };\n if (mode === 'start') {\n this.drawImages = [];\n return;\n }\n if (mode === 'normal') {\n this.drawImages.push(node);\n return;\n }\n if (mode === 'forcesingle') {\n return drawSingle(node);\n }\n if (mode === 'end') {\n for (const currentNode of this.drawImages) {\n drawSingle(currentNode);\n }\n return;\n }\n }\n\n private drawPath(elData: VdomNode, mode: DrawMode = 'normal', path?: Path2D) {\n if (mode !== 'normal' && mode !== 'forcesingle') return;\n\n const fill = this.getFillStyle(elData, '#000');\n const stroke = this.getStrokeStyle(elData);\n const strokeWidth = this.getStrokeWidth(elData);\n\n let p = new Path2D(elData.d);\n this.ctx.fillStyle = fill;\n if (stroke !== undefined && stroke !== 'none') {\n if (strokeWidth !== undefined) {\n this.ctx.lineWidth = strokeWidth;\n }\n this.ctx.strokeStyle = stroke;\n\n const lineJoin = this.getAttributeStyleCss(elData, 'stroke-linejoin');\n\n if (lineJoin) {\n if (lineJoin === 'bevel' || lineJoin === 'round' || lineJoin === 'miter') {\n this.ctx.lineJoin = lineJoin;\n } else {\n console.error('unknown line join value:', lineJoin);\n }\n }\n if (!path) {\n this.ctx.stroke(p);\n }\n }\n\n if (fill && fill !== 'none' && !path) {\n this.ctx.fill(p);\n }\n if (path) {\n path.addPath(p);\n }\n }\n\n private drawTspan(elData: VdomNode, mode: DrawMode = 'normal') {\n if (mode !== 'normal' && mode !== 'forcesingle') return;\n\n this.ctx.font = '10px Arial';\n this.ctx.fillStyle = '#000000';\n const textAlign = <CanvasTextAlign>(\n (elData.style.textAnchor === 'middle' ? 'center' : elData.style.textAnchor)\n );\n this.ctx.textAlign = textAlign;\n this.ctx.fillText(elData.text, this.vdom.get(elData, 'x'), this.vdom.get(elData, 'y'));\n }\n\n private drawTextpath(elData: VdomNode) {\n console.warn('no draw function yet for textpath');\n }\n\n private linesByColor: {[color: string]: VdomNode[]} = {};\n private drawLine(elData, mode: DrawMode = 'normal') {\n if (this.vdom.data.scale > 1) {\n //mode = 'forcesingle';\n // In my tests, drawing a long connected path is very slow for high DPI devices.\n }\n if (mode === 'normal') {\n const stroke = this.getStrokeStyle(elData);\n const width = this.getStrokeWidth(elData);\n if (stroke === 'none' || width === 0) {\n return;\n }\n const selector = `${stroke};${width}`;\n if (!this.linesByColor[selector]) {\n this.linesByColor[selector] = [];\n }\n this.linesByColor[selector].push(elData);\n }\n if (mode === 'start') {\n this.linesByColor = {};\n return;\n }\n if (mode === 'end') {\n //safeLog(Object.keys(this.linesByColor), this.linesByColor);\n for (let selector in this.linesByColor) {\n if (this.linesByColor.hasOwnProperty(selector)) {\n const split = selector.split(';');\n const strokeColor = split[0];\n const width = split[1];\n\n this.ctx.strokeStyle = strokeColor;\n this.ctx.lineWidth = parseFloat(width);\n\n this.ctx.beginPath();\n for (let elData of this.linesByColor[selector]) {\n if (elData.transform) {\n this.ctx.save();\n this.applyTransform(elData.transform);\n }\n\n const [x1, x2, y1, y2] = this.vdom\n .get(elData, ['x1', 'x2', 'y1', 'y2'])\n .map((val) => Math.round(val) || 0);\n\n /*const dist = Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));\n if(dist > 50) {\n safeLog(elData, dist, x1, x2, y1, y2);\n }*/\n\n this.ctx.moveTo(x1, y1);\n this.ctx.lineTo(x2, y2);\n\n if (elData.transform) {\n //this.ctx.restore();\n this.ctx.restore();\n }\n }\n\n this.ctx.stroke();\n }\n }\n return;\n }\n if (mode === 'forcesingle') {\n this.ctx.beginPath();\n\n const [x1, x2, y1, y2] = this.vdom\n .get(elData, ['x1', 'x2', 'y1', 'y2'])\n .map((val) => Math.round(val) || 0);\n\n this.ctx.moveTo(x1, y1);\n this.ctx.lineTo(x2, y2);\n\n this.ctx.strokeStyle = this.getStrokeStyle(elData);\n this.ctx.lineWidth = this.getStrokeWidth(elData);\n //safeLog(stroke, this.ctx.strokeStyle);\n this.ctx.stroke();\n }\n }\n\n private drawDefs(node: VdomNode) {\n //TODO figure out.\n }\n\n private drawMarker(node: VdomNode) {\n //TODO figure out.\n }\n\n private applyTransform(transformString: string) {\n const transform = transformString ? DrawingUtils.parseTransform(transformString) : null;\n if (transform) {\n if (!transform.rotateLast) {\n this.ctx.rotate((transform.rotate * Math.PI) / 180);\n }\n\n const x = transform.translateBeforeScale\n ? transform.translateX\n : transform.translateX * transform.scaleX;\n const y = transform.translateBeforeScale\n ? transform.translateY\n : transform.translateY * transform.scaleY;\n this.ctx.transform(transform.scaleX, 0, 0, transform.scaleY, x, y);\n\n if (transform.rotateLast) {\n this.ctx.rotate((transform.rotate * Math.PI) / 180);\n }\n\n return true;\n }\n return false;\n }\n}\n","import '../worker-loader';\nimport CanvasWorkerImporter = require('worker-loader?inline=true!./canvasworker');\n\nexport default CanvasWorkerImporter;\n","module.exports = function() {\n return require(\"!!/home/micha/WebstormProjects/ssvg/node_modules/worker-loader/dist/workers/InlineWorker.js\")(\"!function(e){var t={};function s(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,s),i.l=!0,i.exports}s.m=e,s.c=t,s.d=function(e,t,r){s.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},s.r=function(e){\\\"undefined\\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\\\"Module\\\"}),Object.defineProperty(e,\\\"__esModule\\\",{value:!0})},s.t=function(e,t){if(1&t&&(e=s(e)),8&t)return e;if(4&t&&\\\"object\\\"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(s.r(r),Object.defineProperty(r,\\\"default\\\",{enumerable:!0,value:e}),2&t&&\\\"string\\\"!=typeof e)for(var i in e)s.d(r,i,function(t){return e[t]}.bind(null,i));return r},s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,\\\"a\\\",t),t},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.p=\\\"\\\",s(s.s=1)}([function(e,t,s){\\\"use strict\\\";Object.defineProperty(t,\\\"__esModule\\\",{value:!0});let r=0;t.safeLog=function(...e){r<200&&(r++,console.log(...e))},t.safeErrorLog=function(...e){r<200&&(r++,console.error(...e))}},function(e,t,s){\\\"use strict\\\";Object.defineProperty(t,\\\"__esModule\\\",{value:!0});const r=s(2),i=s(3);let a;const n=self;let o,l;n.onmessage=function(e){const t=e.data;if(t&&t.cmd)switch(t.cmd){case\\\"INIT\\\":o=new r.VdomManager(t.data.visData,!1,!0);const e=!!t.data.safeMode;l=t.data.port,a=new i.Canvasrenderer(o,t.data.canvas,e,()=>{l.postMessage({msg:\\\"DRAWN\\\"}),n.postMessage({msg:\\\"DRAWN\\\"})}),l.onmessage=e=>{const t=e.data;if(t&&t.cmd)switch(t.cmd){case\\\"UPDATE_NODES\\\":(e=>{for(let t of e.data.enterExit){if(\\\"EXIT\\\"===t.cmd){const e=o.getNodeFromIndex(t.childGlobalIndex),s=o.getNodeFromIndex(t.parentGlobalIndex);o.removeNode(e,s)}if(\\\"ENTER\\\"===t.cmd){const e=t.node;t.keepChildren||(e.children=[]),o.addNode(e),o.addNodeToParent(e,t.parentGlobalIndex),a.addNode&&a.addNode(e)}}a.updatePropertiesFromQueue?a.updatePropertiesFromQueue(e.data.update):o.updatePropertiesFromQueue(e.data.update,(e,t)=>{a.nodeUpdated(e,t)}),a.draw()})(t);break;default:console.error(\\\"did not find command \\\",t.cmd)}};break;case\\\"UPDATE_NODES\\\":console.error(\\\"update is now supposed to come from sync worker.\\\");break;default:console.error(\\\"did not find command \\\",t.cmd)}}},function(e,t,s){\\\"use strict\\\";Object.defineProperty(t,\\\"__esModule\\\",{value:!0});const r=s(0);class i{constructor(e,t,s){this.data=e,this.ignoreDesign=t,this.isRenderer=s,this.sharedRenderData={values:{},buffers:{}},this.syncedSharedData={values:{},buffers:{}},this.sharedDataQueue={values:{},buffers:{}},this.queue={},this.useSharedArrayFor=[\\\"cx\\\",\\\"cy\\\",\\\"x1\\\",\\\"x2\\\",\\\"y1\\\",\\\"y2\\\",\\\"x\\\",\\\"y\\\"],this.indexToNodeMap={},this.changed=!1,this.cachedListSelections={},this.ensureNodesMapped(),\\\"SharedArrayBuffer\\\"in self||(this.useSharedArrayFor=[])}ensureInitialized(e,t=!0,s){if(\\\"class\\\"===e&&(e=\\\"className\\\"),t&&-1!==this.useSharedArrayFor.indexOf(e)){const t=s<500?1e3:Math.round(2*s);if(this.sharedDataQueue.values[e]){const s=Int32Array.BYTES_PER_ELEMENT*t;if(this.sharedDataQueue.values[e].byteLength/s<.6){const{buffer:s,values:r}=this.createBufferTransferValues(t,this.sharedDataQueue.values[e]);this.sharedDataQueue.values[e]=r,this.sharedDataQueue.buffers[e]=s}}else{let s;!this.queue[e]||this.queue[e]instanceof SharedArrayBuffer||(s=this.queue[e]);const{buffer:r,values:i}=this.createBufferTransferValues(t,void 0,s);this.sharedDataQueue.values[e]=i,this.sharedDataQueue.buffers[e]=r,this.queue[e]=r}}else this.queue[e]||(this.queue[e]={})}createBufferTransferValues(e,t,s){let r=new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT*e);const a=new Int32Array(r);if(s)for(const e in s)if(s.hasOwnProperty(e)){let t=s[e];\\\"string\\\"==typeof t&&(t=parseFloat(t)),a[e]=t*i.BUFFER_PRECISION_FACTOR}if(t)for(let e=0;e<t.length;e++)t[e]&&(a[e]=t[e]);return{buffer:r,values:a}}set(e,t,s,r=!0){if(\\\"class\\\"===t&&(t=\\\"className\\\"),void 0===e.globalElementIndex)throw console.error(\\\"No index\\\",e),new Error(\\\"Element has no index\\\");const a=e.globalElementIndex,n=r&&-1!==this.useSharedArrayFor.indexOf(t)?\\\"shared\\\":\\\"raw\\\";try{this.changed=!0,\\\"shared\\\"===n?(\\\"string\\\"==typeof s&&(s=parseFloat(s)),s*=i.BUFFER_PRECISION_FACTOR,0===(s=Math.round(s))&&(s=56938516),this.sharedDataQueue.values[t][a]=s):(this.queue[t][a]=s,this.sharedDataQueue.values[t]&&this.syncedSharedData.values[t]&&this.syncedSharedData.values[t][a]&&(this.sharedDataQueue.values[t][a]=0))}catch(s){console.error(s),console.log(this.queue,this.syncedSharedData.values,n,t,e,a)}}removePendingChanges(e){const t=e.globalElementIndex;for(const e in this.queue)this.queue.hasOwnProperty(e)&&delete this.queue[e][t];for(const e in this.sharedDataQueue.values)this.sharedDataQueue.values.hasOwnProperty(e)&&(this.sharedDataQueue.values[e][t]=0)}ensureNodesMapped(){const e=t=>{void 0===t.globalElementIndex&&console.error(\\\"no element index\\\",t),this.indexToNodeMap[t.globalElementIndex]=t;for(const s of t.children)e(s)};e(this.data)}enableFrontendDesignProperties(){this.ignoreDesign=!1}addNodeToParent(e,t){if(\\\"svg\\\"!==e.type){const s=this.getNodeFromIndex(t);if(!s)return console.error(\\\"could not add node without parent\\\",t,e,Object.keys(this.indexToNodeMap)),void new Error(\\\"parent not found\\\");s.children.push(e)}}addNode(e){this.indexToNodeMap[e.globalElementIndex]=e}removeNode(e,t){delete this.indexToNodeMap[e.globalElementIndex];const s=t.children.indexOf(e);t.children.splice(s,1),this.cachedListSelections={},this.removePendingChanges(e)}applyStyleToNodeAndChildren(e,t,s,r){if(e.style[t]=s,r(e,t),e.children)for(let i of e.children)this.applyStyleToNodeAndChildren(i,t,s,r)}applyCssToNodeAndChildren(e,t,s,r,i){if(\\\"*\\\"!==s||r?(e.css[t]||(e.css[t]={}),e.css[t][s]=r):delete e.css[t],i(e,s),e.children)for(let a of e.children)this.applyCssToNodeAndChildren(a,t,s,r,i)}getNodeFromIndex(e){return this.indexToNodeMap[e]}getNodeById(e){const t=Object.values(this.indexToNodeMap).filter(t=>t.id===e);return(!t||t.length>1)&&(r.safeLog(\\\"multiple nodes with this id!\\\",Object.values(this.indexToNodeMap).filter(e=>e.id).map(e=>e.id),e),r.safeLog(t.length,t)),t&&1===t.length?t[0]:null}get(e,t){return Array.isArray(t)?t.map(t=>this.getSingle(e,t)):this.getSingle(e,t)}getSingle(e,t){const s=this.isRenderer?this.sharedRenderData.values:this.syncedSharedData.values;if(s[t]&&s[t][e.globalElementIndex]){const r=s[t][e.globalElementIndex];return 56938516===r?0:r/i.BUFFER_PRECISION_FACTOR}return e[t]}hasChanges(){return this.changed}getQueue(){return this.queue}clearQueue(){this.queue={},this.changed=!1}transferSyncedDataToRenderData(){for(let e in this.syncedSharedData.values){this.queue[e]=this.syncedSharedData.buffers[e],this.sharedRenderData.values[e]=this.syncedSharedData.values[e];const t=this.syncedSharedData.buffers[e].byteLength/Int32Array.BYTES_PER_ELEMENT,{buffer:s,values:r}=this.createBufferTransferValues(t,this.syncedSharedData.values[e]);this.syncedSharedData.buffers[e]=s,this.syncedSharedData.values[e]=r}}transferBufferQueueDataToSynced(){for(let e in this.sharedDataQueue.values){this.queue[e]=this.sharedDataQueue.buffers[e],this.syncedSharedData.values[e]=this.sharedDataQueue.values[e];const t=this.sharedDataQueue.buffers[e].byteLength/Int32Array.BYTES_PER_ELEMENT,{buffer:s,values:r}=this.createBufferTransferValues(t,this.sharedDataQueue.values[e]);this.sharedDataQueue.buffers[e]=s,this.sharedDataQueue.values[e]=r}}addToQueue(e){for(let t in e)if(e.hasOwnProperty(t))if(\\\"SharedArrayBuffer\\\"in self&&e[t]instanceof SharedArrayBuffer){const s=e[t];this.syncedSharedData.buffers[t]=s,this.syncedSharedData.values[t]=new Int32Array(s)}else{const s=e[t];this.queue[t]||(this.queue[t]={});for(let e in s){if(!s.hasOwnProperty(e))continue;const r=parseInt(e);this.queue[t][r]=s[r]}}}updatePropertiesFromQueue(e,t=(()=>{})){for(let s in e){if(!e.hasOwnProperty(s))continue;const r=s.substr(0,\\\"style;\\\".length);if(this.ignoreDesign&&(\\\"style;\\\"===r||-1!==i.IGNOREDESIGN_ATTRIBUTES.indexOf(s)))continue;let a;if(\\\"SharedArrayBuffer\\\"in self&&e[s]instanceof SharedArrayBuffer){const t=e[s];this.isRenderer?(this.sharedRenderData.buffers[s]=t,this.sharedRenderData.values[s]=new Int32Array(t)):(this.syncedSharedData.buffers[s]=t,this.syncedSharedData.values[s]=new Int32Array(t))}else{a=e[s];for(let e in a){if(!a.hasOwnProperty(e))continue;const n=parseInt(e),o=this.getNodeFromIndex(n);if(!o){console.error(\\\"node not found at index\\\",n);continue}let l=a[e];if(\\\"style;\\\"===r){const e=s.substr(\\\"style;\\\".length);this.applyStyleToNodeAndChildren(o,e,l,t)}else if(\\\"css;\\\"===s.substr(0,4)){const[e,r]=s.substr(4).split(\\\";\\\");this.applyCssToNodeAndChildren(o,e,r,l,t)}else-1!==i.ROUNDED_ATTRS.indexOf(s)&&(\\\"string\\\"==typeof l&&(l=parseFloat(l)),l=Math.round(l)),o[s]=l,t(o,s)}}}}getVisNodeFromSelector(e){const t=e.lastIndexOf(\\\">\\\"),s=e.substr(0,t),r=e.substr(t+1),i=s?this.cachedListSelections[s]:null;let a=-1;const n=r.indexOf(\\\":nth-child(\\\");if(-1!==n&&(a=parseInt(r.substr(n+11)),i&&i[a]))return i[a];const o=[];if(this.findMatchingChildren(this.data,e,0,o),o&&1===o.length){const e=o[0];return-1!==a&&(this.cachedListSelections[s]||(this.cachedListSelections[s]={}),this.cachedListSelections[s][a]=e),e}return null}getVisNodesFromSelector(e,t){const s=[];return this.findMatchingChildren(e,t,0,s),s}findChildrenOfType(e,t,s){const r=e=>{for(const i of e.children)i.type===t&&s.push(i),0!==e.children.length&&r(i)};r(e)}filterNodesBySelector(e,t,s){return t.filter(t=>i.isCssRulePartialMatch(s,t,e))}findMatchingChildren(e,t,s,r,a=[]){if(!t&&\\\"\\\"!==t)throw console.error(e,t,s,r,a),Error(\\\"undefined selector\\\");let n=t.split(\\\">\\\").map(e=>e.trim()),o=n[s];if(0===s&&\\\"svg\\\"===o&&(o=n[++s],s===n.length))return r.push(e),void a.push(t);if(t.match(/^[a-z]+$/))return this.findChildrenOfType(e,t,r);for(let l=0;l<e.children.length;l++){let h=e.children[l],c=!1;i.isCssRulePartialMatch(o,h,e)&&(s===n.length-1?(r.push(h),a.push(t)):c=!0),h.children&&(c||n.length<2)&&s+1<n.length&&this.findMatchingChildren(h,t,s+1,r,a)}}static isCssRulePartialMatch(e,t,s){if(\\\":not(\\\"===e.substr(0,5)){const r=e.substr(0,e.length-1).substr(5);return!i.isCssRulePartialMatch(r,t,s)}if(\\\".\\\"===e[0]){const s=e.split(\\\".\\\");if(s.shift(),t.className){let e=!0;for(const r of s)-1===t.className.split(\\\" \\\").indexOf(r)&&(e=!1);return e}}else if(\\\"#\\\"===e[0]){if(e.substr(1)===t.id)return!0}else if(e.match(/^[a-z]+$/)){if(e===t.type)return!0}else{if(-1!==e.indexOf(\\\":nth-child(\\\")){let r=\\\"any\\\",i=e;\\\":\\\"!==e[0]&&(r=e.substr(0,e.indexOf(\\\":\\\")),i=e.substr(e.indexOf(\\\":\\\")));const a=parseInt(i.substr(\\\":nth-child(\\\".length));return s.children.indexOf(t)===a-1&&(\\\"any\\\"===r||t.type===r)}if(-1!==e.indexOf(\\\".\\\")){const s=e.indexOf(\\\".\\\"),r=e.substr(0,s),i=e.substr(s+1);if(r===t.type&&t.className&&-1!==t.className.split(\\\" \\\").indexOf(i))return!0}}return!1}}t.VdomManager=i,i.IGNOREDESIGN_ATTRIBUTES=[\\\"fill\\\",\\\"stroke\\\",\\\"opacity\\\"],i.BUFFER_PRECISION_FACTOR=10,i.ROUNDED_ATTRS=[\\\"cx\\\",\\\"cy\\\"]},function(e,t,s){\\\"use strict\\\";Object.defineProperty(t,\\\"__esModule\\\",{value:!0});const r=s(4),i=s(0);t.Canvasrenderer=class{constructor(e,t,s=!1,r=(()=>{})){this.vdom=e,this.canvas=t,this.forceSingle=s,this.onDrawn=r,this.parentValues={},this.lastFullSecond=0,this.countSinceLastFullSecond=0,this.circlesByColor={},this.rectsByColor={},this.drawTexts=[],this.drawImages=[],this.linesByColor={};const i=t.getContext(\\\"2d\\\");if(!i)throw new Error(\\\"could not create canvas context\\\");this.ctx=i,this.ctx.scale(this.vdom.data.scale,this.vdom.data.scale),this.ctx.save(),this.draw(),setTimeout(()=>{console.log(this.forceSingle,this.vdom.data)},1e3)}draw(){const e=this.ctx;e.restore(),e.save(),e.clearRect(0,0,this.vdom.data.width,this.vdom.data.height),this.drawLine(null,\\\"start\\\"),this.drawCircle(null,\\\"start\\\"),this.drawRect(null,\\\"start\\\"),this.drawText(null,\\\"start\\\"),this.drawImage(null,\\\"start\\\"),this.drawNodeAndChildren(this.vdom.data,this.forceSingle),this.drawLine(null,\\\"end\\\"),this.drawCircle(null,\\\"end\\\"),this.drawRect(null,\\\"end\\\"),this.drawText(null,\\\"end\\\"),this.drawImage(null,\\\"end\\\"),this.onDrawn();const t=Math.round(performance.now()/1e3);t!==this.lastFullSecond&&(this.lastFullSecond=t,this.countSinceLastFullSecond=0),this.countSinceLastFullSecond++}drawNodeAndChildren(e,t,s){if(\\\"clippath\\\"===e.type&&!s)return;const r=this.ctx,a=Object.assign({},this.parentValues),n=!s&&(e.children.length||e.transform);if(n&&r.save(),this.applyTransform(e.transform),(e.transform||s)&&(t=!0),e[\\\"clip-path\\\"])if(\\\"url(#\\\"===e[\\\"clip-path\\\"].substr(0,5)){const s=e[\\\"clip-path\\\"].substr(5,e[\\\"clip-path\\\"].length-6),i=this.vdom.getNodeById(s);if(t=!0,i){const e=new Path2D;this.drawNodeAndChildren(i,t,e),r.clip(e)}else;}else i.safeErrorLog(\\\"clip path format not supported:\\\",e[\\\"clip-path\\\"]);if(e.style.display&&\\\"none\\\"===e.style.display||(t?this.drawSingleNode(e,\\\"forcesingle\\\",s):this.drawSingleNode(e,\\\"normal\\\",s)),e.children){this.parentValues.fill=e.fill||this.parentValues.fill,this.parentValues[\\\"style;fill\\\"]=e.style.fill||this.parentValues[\\\"style;fill\\\"],this.parentValues.stroke=e.stroke||this.parentValues.stroke,this.parentValues[\\\"style;stroke\\\"]=e.style.stroke||this.parentValues[\\\"style;stroke\\\"],this.parentValues.opacity=e.opacity||this.parentValues.opacity;for(let r=0;r<e.children.length;r++)this.drawNodeAndChildren(e.children[r],t,s)}n&&r.restore(),this.parentValues=a}drawSingleNode(e,t=\\\"normal\\\",s){const r=e.type,i=this[\\\"draw\\\"+r.substr(0,1).toUpperCase()+r.substr(1)];if(!i)return console.error(\\\"no draw function yet for \\\",r);i.call(this,e,t,s)}drawClippath(e){}drawSvg(){}drawTitle(){}drawG(){}drawCircle(e,t=\\\"normal\\\",s){if(\\\"normal\\\"===t){const t=this.getFillStyle(e,\\\"#000\\\")+\\\";\\\"+this.getStrokeStyle(e);this.circlesByColor[t]||(this.circlesByColor[t]=[]),this.circlesByColor[t].push(e)}if(\\\"start\\\"!==t){if(\\\"end\\\"!==t){if(\\\"forcesingle\\\"===t){let t=this.getFillStyle(e,\\\"#000\\\");const r=this.getStrokeStyle(e),i=this.vdom.get(e,\\\"cx\\\")||0,a=this.vdom.get(e,\\\"cy\\\")||0;this.ctx.beginPath(),this.ctx.fillStyle=t,this.ctx.strokeStyle=r,this.ctx.lineWidth=this.getStrokeWidth(e),this.ctx.moveTo(i+e.r,a),(s||this.ctx).arc(i,a,e.r,0,2*Math.PI),\\\"none\\\"===t||s||this.ctx.fill(),r&&\\\"none\\\"!==r&&!s&&this.ctx.stroke()}}else for(let e in this.circlesByColor)if(this.circlesByColor.hasOwnProperty(e)){const t=e.split(\\\";\\\"),s=t[0],r=t[1];this.ctx.fillStyle=s;let i=this.circlesByColor[e][0];const a=this.getStrokeWidth(i);this.ctx.lineWidth=void 0!==a?a:1,this.ctx.strokeStyle=r,this.ctx.beginPath();for(let t of this.circlesByColor[e]){const e=Math.round(this.vdom.get(t,\\\"cx\\\"))||0,s=Math.round(this.vdom.get(t,\\\"cy\\\"))||0,r=Math.round(this.vdom.get(t,\\\"r\\\"));this.ctx.save(),this.applyTransform(t.transform),this.ctx.moveTo(e+r,s),this.ctx.arc(e,s,r,0,2*Math.PI),this.ctx.restore()}\\\"none\\\"!==s&&this.ctx.fill(),r&&\\\"none\\\"!==r&&this.ctx.stroke()}}else this.circlesByColor={}}nodeUpdated(e,t){(\\\"*\\\"===t||t.includes(\\\"fill\\\")||t.includes(\\\"opacity\\\"))&&delete e[\\\"fill-cache\\\"],(\\\"*\\\"===t||t.includes(\\\"stroke\\\")||t.includes(\\\"opacity\\\"))&&(delete e[\\\"stroke-cache\\\"],delete e[\\\"strokewidth-cache\\\"])}getFillStyle(e,t=\\\"none\\\"){if(\\\"fill-cache\\\"in e)return e[\\\"fill-cache\\\"];let s=this.getAttributeStyleCss(e,\\\"fill\\\"),i=this.getAttributeStyleCss(e,\\\"opacity\\\")||1;i*=this.getAttributeStyleCss(e,\\\"fill-opacity\\\")||1;let a=\\\"\\\";return this.parentValues.fill&&(a=this.parentValues.fill),this.parentValues[\\\"style;fill\\\"]&&(a=this.parentValues[\\\"style;fill\\\"]),this.parentValues.fill||this.parentValues[\\\"style;fill\\\"]||(a=t),s=r.DrawingUtils.colorToRgba(s,i,a),e[\\\"fill-cache\\\"]=s,s}getAttributeStyleCss(e,t){if(e.style[t])return e.style[t];{if(this.parentValues[`style;${t}`])return this.parentValues[`style;${t}`];let s=e[t],i=-1;for(const a in e.css)if(e.css[a][t]){const n=r.DrawingUtils.getCssRuleSpecificityNumber(a);n>i&&(s=e.css[a][t],i=n)}return s}}getStrokeStyle(e,t=\\\"none\\\"){if(\\\"stroke-cache\\\"in e)return e[\\\"stroke-cache\\\"];const s=this.getAttributeStyleCss(e,\\\"stroke\\\");let i=this.getAttributeStyleCss(e,\\\"opacity\\\")||1;i*=this.getAttributeStyleCss(e,\\\"stroke-opacity\\\")||1;let a=\\\"\\\";return a=this.parentValues.stroke?this.parentValues.stroke:t,e[\\\"stroke-cache\\\"]=void 0!==s?r.DrawingUtils.colorToRgba(s,i):a,e[\\\"stroke-cache\\\"]}getStrokeWidth(e){if(\\\"strokewidth-cache\\\"in e)return e[\\\"strokewidth-cache\\\"];const t=this.getAttributeStyleCss(e,\\\"stroke-width\\\");return e[\\\"strokewidth-cache\\\"]=void 0===t?void 0:parseFloat(t),e[\\\"strokewidth-cache\\\"]}drawRect(e,t=\\\"normal\\\",s){if(\\\"normal\\\"===t){const t=this.getFillStyle(e,\\\"#000\\\")+\\\";\\\"+this.getStrokeStyle(e);this.rectsByColor[t]||(this.rectsByColor[t]=[]),this.rectsByColor[t].push(e)}if(\\\"start\\\"!==t){if(\\\"end\\\"!==t){if(\\\"forcesingle\\\"===t){let t=this.getFillStyle(e,\\\"#000\\\");const r=this.getStrokeStyle(e),i=this.vdom.get(e,\\\"x\\\")||0,a=this.vdom.get(e,\\\"y\\\")||0;t&&\\\"none\\\"!==t&&!s&&(this.ctx.fillStyle=t,this.ctx.fillRect(i,a,e.width,e.height)),s&&s.rect(i,a,e.width,e.height),\\\"none\\\"===r||s||(this.ctx.strokeStyle=r,this.ctx.beginPath(),this.ctx.rect(i,a,e.width,e.height),this.ctx.stroke())}}else for(let e in this.rectsByColor)if(this.rectsByColor.hasOwnProperty(e)){const t=e.split(\\\";\\\"),s=t[0],r=t[1];this.ctx.fillStyle=s;let i=this.rectsByColor[e][0];const a=this.getStrokeWidth(i);this.ctx.lineWidth=void 0!==a?a:1,this.ctx.strokeStyle=r,this.ctx.beginPath();for(let t of this.rectsByColor[e]){const e=Math.round(this.vdom.get(t,\\\"x\\\"))||0,s=Math.round(this.vdom.get(t,\\\"y\\\"))||0;this.ctx.save(),this.applyTransform(t.transform),this.ctx.moveTo(e,s),this.ctx.rect(e,s,t.width,t.height),this.ctx.restore()}\\\"none\\\"!==s&&this.ctx.fill(),r&&\\\"none\\\"!==r&&this.ctx.stroke()}}else this.rectsByColor={}}drawText(e,t=\\\"normal\\\",s=!1){const i=e=>{if(\\\"\\\"===e.text)return;let t=this.getAttributeStyleCss(e,\\\"font-family\\\")||\\\"Times New Roman\\\",s=\\\"16px\\\";const i=this.getAttributeStyleCss(e,\\\"font-size\\\");i&&(s=r.DrawingUtils.convertSizeToPx(i)+\\\"px\\\");let a=this.getAttributeStyleCss(e,\\\"font\\\");a||(a=s+\\\" \\\"+t);let n=this.getAttributeStyleCss(e,\\\"text-anchor\\\");n&&(\\\"middle\\\"===n&&(n=\\\"center\\\"),this.ctx.textAlign=n),this.ctx.font=a,this.ctx.fillStyle=this.getFillStyle(e,\\\"#000\\\");let o=this.vdom.get(e,\\\"x\\\")||0,l=this.vdom.get(e,\\\"y\\\")||0,h=r.DrawingUtils.convertSizeToPx(e.dx,!1)||0,c=r.DrawingUtils.convertSizeToPx(e.dy,!1)||0;this.ctx.fillText(e.text,o+h,l+c)};if(\\\"start\\\"!==t)if(\\\"normal\\\"!==t){if(\\\"forcesingle\\\"===t)return i(e);if(\\\"end\\\"!==t);else for(const e of this.drawTexts)i(e)}else this.drawTexts.push(e);else this.drawTexts=[]}drawImage(e,t=\\\"normal\\\"){const s=e=>{if(\\\"\\\"===e.href)return;let t=e.fill?e.fill:e.style.fill;t||(t=\\\"#000\\\"),this.ctx.fillStyle=t;let s=this.vdom.get(e,\\\"x\\\")||0,r=this.vdom.get(e,\\\"y\\\")||0,i=e.width||0,a=e.height||0;if(e.image)try{this.ctx.drawImage(e.image,s,r,i,a)}catch(e){console.log(e)}};if(\\\"start\\\"!==t)if(\\\"normal\\\"!==t){if(\\\"forcesingle\\\"===t)return s(e);if(\\\"end\\\"!==t);else for(const e of this.drawImages)s(e)}else this.drawImages.push(e);else this.drawImages=[]}drawPath(e,t=\\\"normal\\\",s){if(\\\"normal\\\"!==t&&\\\"forcesingle\\\"!==t)return;const r=this.getFillStyle(e,\\\"#000\\\"),i=this.getStrokeStyle(e),a=this.getStrokeWidth(e);let n=new Path2D(e.d);if(this.ctx.fillStyle=r,void 0!==i&&\\\"none\\\"!==i){void 0!==a&&(this.ctx.lineWidth=a),this.ctx.strokeStyle=i;const t=this.getAttributeStyleCss(e,\\\"stroke-linejoin\\\");t&&(\\\"bevel\\\"===t||\\\"round\\\"===t||\\\"miter\\\"===t?this.ctx.lineJoin=t:console.error(\\\"unknown line join value:\\\",t)),s||this.ctx.stroke(n)}r&&\\\"none\\\"!==r&&!s&&this.ctx.fill(n),s&&s.addPath(n)}drawTspan(e,t=\\\"normal\\\"){if(\\\"normal\\\"!==t&&\\\"forcesingle\\\"!==t)return;this.ctx.font=\\\"10px Arial\\\",this.ctx.fillStyle=\\\"#000000\\\";const s=\\\"middle\\\"===e.style.textAnchor?\\\"center\\\":e.style.textAnchor;this.ctx.textAlign=s,this.ctx.fillText(e.text,this.vdom.get(e,\\\"x\\\"),this.vdom.get(e,\\\"y\\\"))}drawTextpath(e){console.warn(\\\"no draw function yet for textpath\\\")}drawLine(e,t=\\\"normal\\\"){if(this.vdom.data.scale,\\\"normal\\\"===t){const t=this.getStrokeStyle(e),s=this.getStrokeWidth(e);if(\\\"none\\\"===t||0===s)return;const r=`${t};${s}`;this.linesByColor[r]||(this.linesByColor[r]=[]),this.linesByColor[r].push(e)}if(\\\"start\\\"!==t){if(\\\"end\\\"!==t){if(\\\"forcesingle\\\"===t){this.ctx.beginPath();const[t,s,r,i]=this.vdom.get(e,[\\\"x1\\\",\\\"x2\\\",\\\"y1\\\",\\\"y2\\\"]).map(e=>Math.round(e)||0);this.ctx.moveTo(t,r),this.ctx.lineTo(s,i),this.ctx.strokeStyle=this.getStrokeStyle(e),this.ctx.lineWidth=this.getStrokeWidth(e),this.ctx.stroke()}}else for(let e in this.linesByColor)if(this.linesByColor.hasOwnProperty(e)){const t=e.split(\\\";\\\"),s=t[0],r=t[1];this.ctx.strokeStyle=s,this.ctx.lineWidth=parseFloat(r),this.ctx.beginPath();for(let t of this.linesByColor[e]){t.transform&&(this.ctx.save(),this.applyTransform(t.transform));const[e,s,r,i]=this.vdom.get(t,[\\\"x1\\\",\\\"x2\\\",\\\"y1\\\",\\\"y2\\\"]).map(e=>Math.round(e)||0);this.ctx.moveTo(e,r),this.ctx.lineTo(s,i),t.transform&&this.ctx.restore()}this.ctx.stroke()}}else this.linesByColor={}}drawDefs(e){}drawMarker(e){}applyTransform(e){const t=e?r.DrawingUtils.parseTransform(e):null;if(t){t.rotateLast||this.ctx.rotate(t.rotate*Math.PI/180);const e=t.translateBeforeScale?t.translateX:t.translateX*t.scaleX,s=t.translateBeforeScale?t.translateY:t.translateY*t.scaleY;return this.ctx.transform(t.scaleX,0,0,t.scaleY,e,s),t.rotateLast&&this.ctx.rotate(t.rotate*Math.PI/180),!0}return!1}}},function(e,t,s){\\\"use strict\\\";Object.defineProperty(t,\\\"__esModule\\\",{value:!0});class r{static parseTransform(e){const t={translateX:0,translateY:0,scaleX:1,scaleY:1,rotate:0,translateBeforeScale:!1,rotateLast:!1};if(e){if(\\\"string\\\"!=typeof e)return t.scaleX=e.k,t.scaleY=e.k,t.translateX=e.x,t.translateY=e.y,t.translateBeforeScale=!0,t;let s=e;s=s.replace(/ /g,\\\"\\\");const r=/\\\\s*translate\\\\(([-0-9.]+),([-0-9.]+)\\\\)/.exec(s);r&&(t.translateX=parseFloat(r[1]),t.translateY=parseFloat(r[2]));const i=/\\\\s*scale\\\\(([-0-9.]+)(,[-0-9.]+)?\\\\)/.exec(s);i&&(t.scaleX=parseFloat(i[1]),t.scaleY=i[2]?parseFloat(i[2].substr(1)):parseFloat(i[1]));const a=/\\\\s*rotate\\\\(([-0-9.]+)\\\\)/.exec(s);a&&(t.rotate=parseFloat(a[1])),/\\\\s*translate\\\\(([-0-9.]+),([-0-9.]+)\\\\)scale\\\\(([-0-9.,]+)\\\\)/.exec(s)&&(t.translateBeforeScale=!0),/\\\\s*rotate\\\\(([-0-9.,]+)\\\\)$/.exec(s)&&(t.rotateLast=!0);const n=/\\\\s*matrix\\\\(([-0-9.]+),([-0-9.]+),([-0-9.]+),([-0-9.]+),([-0-9.]+),([-0-9.]+)\\\\)/.exec(s);n&&(t.scaleX=parseFloat(n[1]),t.scaleY=parseFloat(n[4]),t.translateX=parseFloat(n[5]),t.translateY=parseFloat(n[6]))}return t}static addTransforms(e,t){return{translateX:e.translateX+t.translateX,translateY:e.translateY+t.translateY,scaleX:e.scaleX*t.scaleX,scaleY:e.scaleY*t.scaleY,rotate:e.rotate+t.rotate,translateBeforeScale:!1,rotateLast:!1}}static convertSizeToPx(e,t=!0){const s=t?14:void 0;return void 0===e?s:\\\"number\\\"==typeof e?e:\\\"em\\\"===e.substr(-2)?Math.round(12*parseFloat(e)):\\\"px\\\"===e.substr(-2)?parseInt(e):e.match(/^[0-9]+$/)?parseInt(e):(console.warn(\\\"size in unsupported format: \\\",e),s)}static colorToRgba(e,t=1,s=\\\"none\\\"){if(\\\"none\\\"===e)return e;e||(e=s);const i=`${e}-${t}`;if(r.rgbaCache[i])return r.rgbaCache[i];if(e=r.CssNamedColorToHex(e),1===t&&\\\"string\\\"==typeof e)return r.rgbaCache[i]=e,e;let a;if(\\\"string\\\"==typeof e&&\\\"#\\\"===e[0]){let s;if(!/^#([A-Fa-f0-9]{3}){1,2}$/.test(e))throw new Error(\\\"Bad Hex\\\");s=e.substring(1),3==s.length&&(s=s[0]+s[0]+s[1]+s[1]+s[2]+s[2]),s=\\\"0x\\\"+s,a=\\\"rgba(\\\"+[s>>16&255,s>>8&255,255&s].join(\\\",\\\")+\\\",\\\"+t+\\\")\\\"}else if(\\\"object\\\"==typeof e){if(\\\"r\\\"in e)a=\\\"rgba(\\\"+e.r+\\\",\\\"+e.g+\\\",\\\"+e.b+\\\",\\\"+t+\\\")\\\";else if(\\\"h\\\"in e){const s=r.hslToRgb(e.h/360,e.s,e.l);a=\\\"rgba(\\\"+s.r+\\\",\\\"+s.g+\\\",\\\"+s.b+\\\",\\\"+t+\\\")\\\"}}else\\\"rgb(\\\"===e.substr(0,4)&&(a=e.substr(0,e.length-1).replace(\\\"rgb\\\",\\\"rgba\\\")+\\\", \\\"+t+\\\")\\\");return r.rgbaCache[i]=a,a}static hslToRgb(e,t,s){var r,i,a;if(0==t)r=i=a=s;else{var n=function(e,t,s){return s<0&&(s+=1),s>1&&(s-=1),s<1/6?e+6*(t-e)*s:s<.5?t:s<2/3?e+(t-e)*(2/3-s)*6:e},o=s<.5?s*(1+t):s+t-s*t,l=2*s-o;r=n(l,o,e+1/3),i=n(l,o,e),a=n(l,o,e-1/3)}return{r:Math.round(255*r),g:Math.round(255*i),b:Math.round(255*a)}}static CssNamedColorToHex(e){return\\\"string\\\"==typeof e&&i[e.toUpperCase()]?i[e.toUpperCase()]:e}static getCssRuleSpecificityNumber(e){let t=0;e=e.replace(/ >/g,\\\">\\\").replace(/> /g,\\\">\\\");const s=[].concat.apply([],e.split(\\\" \\\").map(e=>e.split(\\\">\\\")));for(const e of s){t+=100;const s=e[0];if(\\\"#\\\"===s)t+=1e3;else if(\\\".\\\"===s){const s=e.split(\\\".\\\").length-1;t+=Math.min(900,100*s)}}return t}}t.DrawingUtils=r,r.rgbaCache={};const i={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\\\",DARKGREY:\\\"#A9A9A9\\\",DARKGREEN:\\\"#006400\\\",DARKKHAKI:\\\"#BDB76B\\\",DARKMAGENTA:\\\"#8B008B\\\",DARKOLIVEGREEN:\\\"#556B2F\\\",DARKORANGE:\\\"#FF8C00\\\",DARKORCHID:\\\"#9932CC\\\",DARKRED:\\\"#8B0000\\\",DARKSALMON:\\\"#E9967A\\\",DARKSEAGREEN:\\\"#8FBC8F\\\",DARKSLATEBLUE:\\\"#483D8B\\\",DARKSLATEGRAY:\\\"#2F4F4F\\\",DARKSLATEGREY:\\\"#2F4F4F\\\",DARKTURQUOISE:\\\"#00CED1\\\",DARKVIOLET:\\\"#9400D3\\\",DEEPPINK:\\\"#FF1493\\\",DEEPSKYBLUE:\\\"#00BFFF\\\",DIMGRAY:\\\"#696969\\\",DIMGREY:\\\"#696969\\\",DODGERBLUE:\\\"#1E90FF\\\",FIREBRICK:\\\"#B22222\\\",FLORALWHITE:\\\"#FFFAF0\\\",FORESTGREEN:\\\"#228B22\\\",FUCHSIA:\\\"#FF00FF\\\",GAINSBORO:\\\"#DCDCDC\\\",GHOSTWHITE:\\\"#F8F8FF\\\",GOLD:\\\"#FFD700\\\",GOLDENROD:\\\"#DAA520\\\",GRAY:\\\"#808080\\\",GREY:\\\"#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\\\",LIGHTGRAY:\\\"#D3D3D3\\\",LIGHTGREY:\\\"#D3D3D3\\\",LIGHTGREEN:\\\"#90EE90\\\",LIGHTPINK:\\\"#FFB6C1\\\",LIGHTSALMON:\\\"#FFA07A\\\",LIGHTSEAGREEN:\\\"#20B2AA\\\",LIGHTSKYBLUE:\\\"#87CEFA\\\",LIGHTSLATEGRAY:\\\"#778899\\\",LIGHTSLATEGREY:\\\"#778899\\\",LIGHTSTEELBLUE:\\\"#B0C4DE\\\",LIGHTYELLOW:\\\"#FFFFE0\\\",LIME:\\\"#00FF00\\\",LIMEGREEN:\\\"#32CD32\\\",LINEN:\\\"#FAF0E6\\\",MAGENTA:\\\"#FF00FF\\\",MAROON:\\\"#800000\\\",MEDIUMAQUAMARINE:\\\"#66CDAA\\\",MEDIUMBLUE:\\\"#0000CD\\\",MEDIUMORCHID:\\\"#BA55D3\\\",MEDIUMPURPLE:\\\"#9370DB\\\",MEDIUMSEAGREEN:\\\"#3CB371\\\",MEDIUMSLATEBLUE:\\\"#7B68EE\\\",MEDIUMSPRINGGREEN:\\\"#00FA9A\\\",MEDIUMTURQUOISE:\\\"#48D1CC\\\",MEDIUMVIOLETRED:\\\"#C71585\\\",MIDNIGHTBLUE:\\\"#191970\\\",MINTCREAM:\\\"#F5FFFA\\\",MISTYROSE:\\\"#FFE4E1\\\",MOCCASIN:\\\"#FFE4B5\\\",NAVAJOWHITE:\\\"#FFDEAD\\\",NAVY:\\\"#000080\\\",OLDLACE:\\\"#FDF5E6\\\",OLIVE:\\\"#808000\\\",OLIVEDRAB:\\\"#6B8E23\\\",ORANGE:\\\"#FFA500\\\",ORANGERED:\\\"#FF4500\\\",ORCHID:\\\"#DA70D6\\\",PALEGOLDENROD:\\\"#EEE8AA\\\",PALEGREEN:\\\"#98FB98\\\",PALETURQUOISE:\\\"#AFEEEE\\\",PALEVIOLETRED:\\\"#DB7093\\\",PAPAYAWHIP:\\\"#FFEFD5\\\",PEACHPUFF:\\\"#FFDAB9\\\",PERU:\\\"#CD853F\\\",PINK:\\\"#FFC0CB\\\",PLUM:\\\"#DDA0DD\\\",POWDERBLUE:\\\"#B0E0E6\\\",PURPLE:\\\"#800080\\\",REBECCAPURPLE:\\\"#663399\\\",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\\\",SLATEGREY:\\\"#708090\\\",SNOW:\\\"#FFFAFA\\\",SPRINGGREEN:\\\"#00FF7F\\\",STEELBLUE:\\\"#4682B4\\\",TAN:\\\"#D2B48C\\\",TEAL:\\\"#008080\\\",THISTLE:\\\"#D8BFD8\\\",TOMATO:\\\"#FF6347\\\",TURQUOISE:\\\"#40E0D0\\\",VIOLET:\\\"#EE82EE\\\",WHEAT:\\\"#F5DEB3\\\",WHITE:\\\"#FFFFFF\\\",WHITESMOKE:\\\"#F5F5F5\\\",YELLOW:\\\"#FFFF00\\\",YELLOWGREEN:\\\"#9ACD32\\\"}}]);\\n//# sourceMappingURL=23cc5864bb48f7bc3ead.worker.js.map\", __webpack_public_path__ + \"23cc5864bb48f7bc3ead.worker.js\");\n};","import '../worker-loader';\nimport SyncWorkerImporter = require('worker-loader?inline=true!./syncworker');\n\nexport default SyncWorkerImporter;\n","module.exports = function() {\n return require(\"!!/home/micha/WebstormProjects/ssvg/node_modules/worker-loader/dist/workers/InlineWorker.js\")(\"!function(e){var t={};function s(r){if(t[r])return t[r].exports;var n=t[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,s),n.l=!0,n.exports}s.m=e,s.c=t,s.d=function(e,t,r){s.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},s.r=function(e){\\\"undefined\\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\\\"Module\\\"}),Object.defineProperty(e,\\\"__esModule\\\",{value:!0})},s.t=function(e,t){if(1&t&&(e=s(e)),8&t)return e;if(4&t&&\\\"object\\\"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(s.r(r),Object.defineProperty(r,\\\"default\\\",{enumerable:!0,value:e}),2&t&&\\\"string\\\"!=typeof e)for(var n in e)s.d(r,n,function(t){return e[t]}.bind(null,n));return r},s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,\\\"a\\\",t),t},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.p=\\\"\\\",s(s.s=0)}([function(e,t,s){\\\"use strict\\\";Object.defineProperty(t,\\\"__esModule\\\",{value:!0});const r=s(1);class n{constructor(e,t){this.port=t,this.enterExitQueue=[],this.hasNewData=!0,this.waitingToRender=!0,this.vdom=new r.VdomManager(e,!1,!1),this.port.onmessage=e=>{this.onRendererReady()}}onUpdateReceived(e){this.hasNewData=!0,this.enterExitQueue=this.enterExitQueue.concat(e.data.enterExit);const t=e.data.update;this.vdom.addToQueue(t),this.waitingToRender&&this.onRendererReady()}onRendererReady(){if(!this.hasNewData)return void(this.waitingToRender=!0);this.waitingToRender=!1,this.vdom.transferSyncedDataToRenderData();const e=this.vdom.getQueue();this.vdom.clearQueue();const t={cmd:\\\"UPDATE_NODES\\\",data:{enterExit:this.enterExitQueue,update:e}};this.port.postMessage(t),this.enterExitQueue=[],this.hasNewData=!1}}let a;self.onmessage=function(e){const t=e.data;if(t&&t.cmd)switch(t.cmd){case\\\"INIT\\\":a=new n(t.data.visData,t.data.port);break;case\\\"UPDATE_NODES\\\":a.onUpdateReceived(t);break;default:console.error(\\\"did not find command \\\",t.cmd)}}},function(e,t,s){\\\"use strict\\\";Object.defineProperty(t,\\\"__esModule\\\",{value:!0});const r=s(2);class n{constructor(e,t,s){this.data=e,this.ignoreDesign=t,this.isRenderer=s,this.sharedRenderData={values:{},buffers:{}},this.syncedSharedData={values:{},buffers:{}},this.sharedDataQueue={values:{},buffers:{}},this.queue={},this.useSharedArrayFor=[\\\"cx\\\",\\\"cy\\\",\\\"x1\\\",\\\"x2\\\",\\\"y1\\\",\\\"y2\\\",\\\"x\\\",\\\"y\\\"],this.indexToNodeMap={},this.changed=!1,this.cachedListSelections={},this.ensureNodesMapped(),\\\"SharedArrayBuffer\\\"in self||(this.useSharedArrayFor=[])}ensureInitialized(e,t=!0,s){if(\\\"class\\\"===e&&(e=\\\"className\\\"),t&&-1!==this.useSharedArrayFor.indexOf(e)){const t=s<500?1e3:Math.round(2*s);if(this.sharedDataQueue.values[e]){const s=Int32Array.BYTES_PER_ELEMENT*t;if(this.sharedDataQueue.values[e].byteLength/s<.6){const{buffer:s,values:r}=this.createBufferTransferValues(t,this.sharedDataQueue.values[e]);this.sharedDataQueue.values[e]=r,this.sharedDataQueue.buffers[e]=s}}else{let s;!this.queue[e]||this.queue[e]instanceof SharedArrayBuffer||(s=this.queue[e]);const{buffer:r,values:n}=this.createBufferTransferValues(t,void 0,s);this.sharedDataQueue.values[e]=n,this.sharedDataQueue.buffers[e]=r,this.queue[e]=r}}else this.queue[e]||(this.queue[e]={})}createBufferTransferValues(e,t,s){let r=new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT*e);const a=new Int32Array(r);if(s)for(const e in s)if(s.hasOwnProperty(e)){let t=s[e];\\\"string\\\"==typeof t&&(t=parseFloat(t)),a[e]=t*n.BUFFER_PRECISION_FACTOR}if(t)for(let e=0;e<t.length;e++)t[e]&&(a[e]=t[e]);return{buffer:r,values:a}}set(e,t,s,r=!0){if(\\\"class\\\"===t&&(t=\\\"className\\\"),void 0===e.globalElementIndex)throw console.error(\\\"No index\\\",e),new Error(\\\"Element has no index\\\");const a=e.globalElementIndex,i=r&&-1!==this.useSharedArrayFor.indexOf(t)?\\\"shared\\\":\\\"raw\\\";try{this.changed=!0,\\\"shared\\\"===i?(\\\"string\\\"==typeof s&&(s=parseFloat(s)),s*=n.BUFFER_PRECISION_FACTOR,0===(s=Math.round(s))&&(s=56938516),this.sharedDataQueue.values[t][a]=s):(this.queue[t][a]=s,this.sharedDataQueue.values[t]&&this.syncedSharedData.values[t]&&this.syncedSharedData.values[t][a]&&(this.sharedDataQueue.values[t][a]=0))}catch(s){console.error(s),console.log(this.queue,this.syncedSharedData.values,i,t,e,a)}}removePendingChanges(e){const t=e.globalElementIndex;for(const e in this.queue)this.queue.hasOwnProperty(e)&&delete this.queue[e][t];for(const e in this.sharedDataQueue.values)this.sharedDataQueue.values.hasOwnProperty(e)&&(this.sharedDataQueue.values[e][t]=0)}ensureNodesMapped(){const e=t=>{void 0===t.globalElementIndex&&console.error(\\\"no element index\\\",t),this.indexToNodeMap[t.globalElementIndex]=t;for(const s of t.children)e(s)};e(this.data)}enableFrontendDesignProperties(){this.ignoreDesign=!1}addNodeToParent(e,t){if(\\\"svg\\\"!==e.type){const s=this.getNodeFromIndex(t);if(!s)return console.error(\\\"could not add node without parent\\\",t,e,Object.keys(this.indexToNodeMap)),void new Error(\\\"parent not found\\\");s.children.push(e)}}addNode(e){this.indexToNodeMap[e.globalElementIndex]=e}removeNode(e,t){delete this.indexToNodeMap[e.globalElementIndex];const s=t.children.indexOf(e);t.children.splice(s,1),this.cachedListSelections={},this.removePendingChanges(e)}applyStyleToNodeAndChildren(e,t,s,r){if(e.style[t]=s,r(e,t),e.children)for(let n of e.children)this.applyStyleToNodeAndChildren(n,t,s,r)}applyCssToNodeAndChildren(e,t,s,r,n){if(\\\"*\\\"!==s||r?(e.css[t]||(e.css[t]={}),e.css[t][s]=r):delete e.css[t],n(e,s),e.children)for(let a of e.children)this.applyCssToNodeAndChildren(a,t,s,r,n)}getNodeFromIndex(e){return this.indexToNodeMap[e]}getNodeById(e){const t=Object.values(this.indexToNodeMap).filter(t=>t.id===e);return(!t||t.length>1)&&(r.safeLog(\\\"multiple nodes with this id!\\\",Object.values(this.indexToNodeMap).filter(e=>e.id).map(e=>e.id),e),r.safeLog(t.length,t)),t&&1===t.length?t[0]:null}get(e,t){return Array.isArray(t)?t.map(t=>this.getSingle(e,t)):this.getSingle(e,t)}getSingle(e,t){const s=this.isRenderer?this.sharedRenderData.values:this.syncedSharedData.values;if(s[t]&&s[t][e.globalElementIndex]){const r=s[t][e.globalElementIndex];return 56938516===r?0:r/n.BUFFER_PRECISION_FACTOR}return e[t]}hasChanges(){return this.changed}getQueue(){return this.queue}clearQueue(){this.queue={},this.changed=!1}transferSyncedDataToRenderData(){for(let e in this.syncedSharedData.values){this.queue[e]=this.syncedSharedData.buffers[e],this.sharedRenderData.values[e]=this.syncedSharedData.values[e];const t=this.syncedSharedData.buffers[e].byteLength/Int32Array.BYTES_PER_ELEMENT,{buffer:s,values:r}=this.createBufferTransferValues(t,this.syncedSharedData.values[e]);this.syncedSharedData.buffers[e]=s,this.syncedSharedData.values[e]=r}}transferBufferQueueDataToSynced(){for(let e in this.sharedDataQueue.values){this.queue[e]=this.sharedDataQueue.buffers[e],this.syncedSharedData.values[e]=this.sharedDataQueue.values[e];const t=this.sharedDataQueue.buffers[e].byteLength/Int32Array.BYTES_PER_ELEMENT,{buffer:s,values:r}=this.createBufferTransferValues(t,this.sharedDataQueue.values[e]);this.sharedDataQueue.buffers[e]=s,this.sharedDataQueue.values[e]=r}}addToQueue(e){for(let t in e)if(e.hasOwnProperty(t))if(\\\"SharedArrayBuffer\\\"in self&&e[t]instanceof SharedArrayBuffer){const s=e[t];this.syncedSharedData.buffers[t]=s,this.syncedSharedData.values[t]=new Int32Array(s)}else{const s=e[t];this.queue[t]||(this.queue[t]={});for(let e in s){if(!s.hasOwnProperty(e))continue;const r=parseInt(e);this.queue[t][r]=s[r]}}}updatePropertiesFromQueue(e,t=(()=>{})){for(let s in e){if(!e.hasOwnProperty(s))continue;const r=s.substr(0,\\\"style;\\\".length);if(this.ignoreDesign&&(\\\"style;\\\"===r||-1!==n.IGNOREDESIGN_ATTRIBUTES.indexOf(s)))continue;let a;if(\\\"SharedArrayBuffer\\\"in self&&e[s]instanceof SharedArrayBuffer){const t=e[s];this.isRenderer?(this.sharedRenderData.buffers[s]=t,this.sharedRenderData.values[s]=new Int32Array(t)):(this.syncedSharedData.buffers[s]=t,this.syncedSharedData.values[s]=new Int32Array(t))}else{a=e[s];for(let e in a){if(!a.hasOwnProperty(e))continue;const i=parseInt(e),o=this.getNodeFromIndex(i);if(!o){console.error(\\\"node not found at index\\\",i);continue}let u=a[e];if(\\\"style;\\\"===r){const e=s.substr(\\\"style;\\\".length);this.applyStyleToNodeAndChildren(o,e,u,t)}else if(\\\"css;\\\"===s.substr(0,4)){const[e,r]=s.substr(4).split(\\\";\\\");this.applyCssToNodeAndChildren(o,e,r,u,t)}else-1!==n.ROUNDED_ATTRS.indexOf(s)&&(\\\"string\\\"==typeof u&&(u=parseFloat(u)),u=Math.round(u)),o[s]=u,t(o,s)}}}}getVisNodeFromSelector(e){const t=e.lastIndexOf(\\\">\\\"),s=e.substr(0,t),r=e.substr(t+1),n=s?this.cachedListSelections[s]:null;let a=-1;const i=r.indexOf(\\\":nth-child(\\\");if(-1!==i&&(a=parseInt(r.substr(i+11)),n&&n[a]))return n[a];const o=[];if(this.findMatchingChildren(this.data,e,0,o),o&&1===o.length){const e=o[0];return-1!==a&&(this.cachedListSelections[s]||(this.cachedListSelections[s]={}),this.cachedListSelections[s][a]=e),e}return null}getVisNodesFromSelector(e,t){const s=[];return this.findMatchingChildren(e,t,0,s),s}findChildrenOfType(e,t,s){const r=e=>{for(const n of e.children)n.type===t&&s.push(n),0!==e.children.length&&r(n)};r(e)}filterNodesBySelector(e,t,s){return t.filter(t=>n.isCssRulePartialMatch(s,t,e))}findMatchingChildren(e,t,s,r,a=[]){if(!t&&\\\"\\\"!==t)throw console.error(e,t,s,r,a),Error(\\\"undefined selector\\\");let i=t.split(\\\">\\\").map(e=>e.trim()),o=i[s];if(0===s&&\\\"svg\\\"===o&&(o=i[++s],s===i.length))return r.push(e),void a.push(t);if(t.match(/^[a-z]+$/))return this.findChildrenOfType(e,t,r);for(let u=0;u<e.children.length;u++){let d=e.children[u],h=!1;n.isCssRulePartialMatch(o,d,e)&&(s===i.length-1?(r.push(d),a.push(t)):h=!0),d.children&&(h||i.length<2)&&s+1<i.length&&this.findMatchingChildren(d,t,s+1,r,a)}}static isCssRulePartialMatch(e,t,s){if(\\\":not(\\\"===e.substr(0,5)){const r=e.substr(0,e.length-1).substr(5);return!n.isCssRulePartialMatch(r,t,s)}if(\\\".\\\"===e[0]){const s=e.split(\\\".\\\");if(s.shift(),t.className){let e=!0;for(const r of s)-1===t.className.split(\\\" \\\").indexOf(r)&&(e=!1);return e}}else if(\\\"#\\\"===e[0]){if(e.substr(1)===t.id)return!0}else if(e.match(/^[a-z]+$/)){if(e===t.type)return!0}else{if(-1!==e.indexOf(\\\":nth-child(\\\")){let r=\\\"any\\\",n=e;\\\":\\\"!==e[0]&&(r=e.substr(0,e.indexOf(\\\":\\\")),n=e.substr(e.indexOf(\\\":\\\")));const a=parseInt(n.substr(\\\":nth-child(\\\".length));return s.children.indexOf(t)===a-1&&(\\\"any\\\"===r||t.type===r)}if(-1!==e.indexOf(\\\".\\\")){const s=e.indexOf(\\\".\\\"),r=e.substr(0,s),n=e.substr(s+1);if(r===t.type&&t.className&&-1!==t.className.split(\\\" \\\").indexOf(n))return!0}}return!1}}t.VdomManager=n,n.IGNOREDESIGN_ATTRIBUTES=[\\\"fill\\\",\\\"stroke\\\",\\\"opacity\\\"],n.BUFFER_PRECISION_FACTOR=10,n.ROUNDED_ATTRS=[\\\"cx\\\",\\\"cy\\\"]},function(e,t,s){\\\"use strict\\\";Object.defineProperty(t,\\\"__esModule\\\",{value:!0});let r=0;t.safeLog=function(...e){r<200&&(r++,console.log(...e))},t.safeErrorLog=function(...e){r<200&&(r++,console.error(...e))}}]);\\n//# sourceMappingURL=4d4630292d41c84b4030.worker.js.map\", __webpack_public_path__ + \"4d4630292d41c84b4030.worker.js\");\n};","import {Domhandler, SsvgElement} from './domhandler';\nimport {VdomNode} from '../util/vdom/vdom';\nimport {DrawingUtils} from '../canvasworker/drawingUtils';\nimport {VdomManager} from '../util/vdom/vdom-manager';\nimport {safeErrorLog} from '../util/safelogs';\n\nexport class Interactionhandler {\n private interactionSelections: SsvgElement[] = [];\n private hoveredElement: Element | undefined;\n private position: {x: number; y: number};\n private canvas: HTMLCanvasElement;\n private svg: SVGElement & SsvgElement;\n private domHandler: Domhandler;\n private vdom: VdomManager;\n\n constructor() {}\n\n initialize(\n canvas: HTMLCanvasElement,\n svg: SVGElement & SsvgElement,\n domHandler: Domhandler,\n vdom: VdomManager\n ) {\n this.canvas = canvas;\n this.svg = svg;\n this.domHandler = domHandler;\n this.vdom = vdom;\n\n const rect = this.canvas.getBoundingClientRect();\n if (!('x' in rect)) {\n throw new Error('SVG position not found');\n }\n this.position = {x: rect.x, y: rect.y};\n\n this.setupListeners();\n }\n\n private setupListeners() {\n this.canvas.addEventListener('mousedown', (e) => this.propagateMouseEvent(e));\n this.canvas.addEventListener('touchstart', (e) => this.propagateTouchEvent(e));\n this.canvas.addEventListener('mousemove', (e) => {\n const lastHovered = this.hoveredElement;\n this.hoveredElement = this.propagateMouseEvent(e);\n if (lastHovered !== this.hoveredElement) {\n if (lastHovered) {\n lastHovered.dispatchEvent(new MouseEvent('mouseout', e));\n }\n }\n this.propagateMouseEvent(e, 'mouseover');\n });\n this.canvas.addEventListener('touchmove', (e) => {\n const lastHovered = this.hoveredElement;\n this.hoveredElement = this.propagateTouchEvent(e);\n if (lastHovered !== this.hoveredElement) {\n if (lastHovered) {\n lastHovered.dispatchEvent(this.duplicateTouchEvent(e, 'mouseout'));\n }\n }\n this.propagateTouchEvent(e, 'mouseover');\n });\n this.canvas.addEventListener('mouseup', (e) => this.propagateMouseEvent(e));\n this.canvas.addEventListener('touchend', (e) => this.propagateTouchEvent(e));\n this.canvas.addEventListener('click', (e) => this.propagateMouseEvent(e));\n this.canvas.addEventListener('wheel', (e) => this.propagateWheelEvent(e));\n }\n\n captureD3On(el: SsvgElement) {\n if (el && this.interactionSelections.indexOf(el) === -1) {\n this.interactionSelections.push(el);\n }\n }\n\n private propagateMouseEvent(evt: MouseEvent, type?: string) {\n return this.propagateEvent(new MouseEvent(type ? type : evt.type, evt));\n }\n\n private duplicateTouchEvent(evt: TouchEvent, type?: string) {\n const e = document.createEvent('TouchEvent');\n if (!type) {\n type = evt.type;\n }\n e.initEvent(type, true, false);\n for (const prop in evt) {\n if (prop !== 'isTrusted' && evt.hasOwnProperty(prop)) {\n Object.defineProperty(e, prop, {\n writable: true,\n value: evt[prop],\n });\n }\n }\n Object.defineProperty(e, 'type', {\n writable: true,\n value: type,\n });\n const touches = [];\n for (let i = 0; i < evt.touches.length; i++) {\n const touch = evt.touches[i];\n touches.push({\n identifier: touch.identifier,\n pageX: touch.pageX,\n pageY: touch.pageY,\n clientX: touch.clientX,\n clientY: touch.clientY,\n });\n }\n Object.defineProperty(e, 'touches', {\n writable: true,\n value: touches,\n });\n return e;\n }\n\n private propagateTouchEvent(evt: TouchEvent, type?: string) {\n return this.propagateEvent(this.duplicateTouchEvent(evt, type));\n }\n\n private propagateWheelEvent(evt: WheelEvent) {\n return this.propagateEvent(new WheelEvent(evt.type, evt));\n }\n\n private propagateEvent(new_event: MouseEvent | TouchEvent | WheelEvent): undefined | Element {\n this.svg.dispatchEvent(new_event); // for EasyPZ\n\n let triggeredElement: undefined | Element;\n const {x, y} = Interactionhandler.getMousePosition(new_event);\n\n for (let interactionSel of this.interactionSelections) {\n let parentNode = this.domHandler.getVisNode(interactionSel);\n\n //let matchingVisParent = selectedNodes[i];\n let j = 1;\n\n if (!parentNode) {\n //console.error(interactionSel, parentSelector, parentNode);\n } else {\n for (let node of parentNode.children) {\n let childNode = this.nodeAtPosition(node, x, y);\n\n if (childNode) {\n const element = this.domHandler.getElementFromNode(node);\n const childElement = this.domHandler.getElementFromNode(childNode);\n\n if (childElement) {\n Object.defineProperty(new_event, 'target', {\n writable: true,\n value: childElement,\n });\n }\n\n if (childElement) {\n triggeredElement = childElement;\n childElement.dispatchEvent(new_event);\n }\n\n if (element !== childElement) {\n if (!triggeredElement) {\n triggeredElement = element;\n }\n element.dispatchEvent(new_event);\n }\n }\n j++;\n }\n }\n }\n return triggeredElement;\n }\n\n private static getMousePosition(event: MouseEvent | TouchEvent): {x: number; y: number} | null {\n let pos = {x: 0, y: 0};\n\n const mouseEvents = [\n 'wheel',\n 'click',\n 'mousemove',\n 'mousedown',\n 'mouseup',\n 'dblclick',\n 'contextmenu',\n 'mouseenter',\n 'mouseleave',\n 'mouseout',\n 'mouseover',\n ];\n if (mouseEvents.indexOf(event.type) !== -1 && 'clientX' in event) {\n pos = {x: event['clientX'], y: event['clientY']};\n } else if (event.type.substr(0, 5) === 'touch') {\n const touches = event['touches'] ? event['touches'] : [];\n if (touches.length < 1) return null;\n pos = {x: touches[0].clientX, y: touches[0].clientY};\n } else {\n safeErrorLog('no event pos for event type ', event);\n }\n\n return pos;\n }\n\n private nodeAtPosition(visNode: VdomNode, x: number, y: number): false | VdomNode {\n x -= this.position.x;\n y -= this.position.y;\n\n if (visNode.type === 'circle') {\n let cx = this.vdom.get(visNode, 'cx') || 0;\n let cy = this.vdom.get(visNode, 'cy') || 0;\n if (visNode.transform) {\n const transform = DrawingUtils.parseTransform(visNode.transform);\n if (transform.translateX) {\n cx += transform.translateX;\n }\n if (transform.translateY) {\n cy += transform.translateY;\n }\n }\n const distance = Math.sqrt(Math.pow(cx - x, 2) + Math.pow(cy - y, 2));\n return distance < visNode.r ? visNode : false;\n } else if (visNode.type === 'rect' || visNode.type === 'image') {\n let elX = this.vdom.get(visNode, 'x') || 0;\n let elY = this.vdom.get(visNode, 'y') || 0;\n const width = visNode.width;\n const height = visNode.height;\n\n if (visNode.transform) {\n const transform = DrawingUtils.parseTransform(visNode.transform);\n if (transform.translateX) {\n elX += transform.translateX;\n }\n if (transform.translateY) {\n elY += transform.translateY;\n }\n }\n\n const centerX = elX + width / 2;\n const centerY = elY + height / 2;\n\n const distanceX = Math.abs(centerX - x);\n const distanceY = Math.abs(centerY - y);\n\n return distanceX < width / 2 && distanceY < height / 2 ? visNode : false;\n } else if (visNode.type === 'g') {\n const transform = this.domHandler.getTotalTransformation(visNode);\n if (transform.translateX) {\n x -= transform.translateX;\n }\n if (transform.translateY) {\n y -= transform.translateY;\n }\n\n let matchAny: false | VdomNode = false;\n for (let i = 0; i < visNode.children.length; i++) {\n if (this.nodeAtPosition(visNode.children[i], x, y)) {\n matchAny = visNode.children[i];\n }\n }\n return matchAny;\n }\n return false;\n }\n}\n","import {Domhandler, SsvgElement} from './domhandler';\nimport {VdomManager} from '../util/vdom/vdom-manager';\nimport {VdomNode} from '../util/vdom/vdom';\nimport {Interactionhandler} from './interactionhandler';\nimport {safeLog} from '../util/safelogs';\n\nexport class Redirector {\n private unassignedNodes: Node[] = [];\n private svg: SVGElement & SsvgElement;\n\n constructor(\n private domHandler: Domhandler,\n private vdom: VdomManager,\n private interactions: Interactionhandler,\n private onSvgSizeSet: () => void,\n private onAddNode: (node: VdomNode, parentNode: VdomNode, keepChildren: boolean) => void,\n private onRemoveNode: (node: VdomNode, parentNode: VdomNode) => void,\n private onSvgAppended: (svgEl: SVGElement & SsvgElement) => void,\n private svgIsAssignedAndSizeSet: () => boolean\n ) {\n this.captureD3On();\n this.replaceNativeRemoveChild();\n this.replaceNativeAttribute();\n this.replaceNativePathFunctions();\n this.replaceNativeCreateElement();\n this.replaceNativeAppendChild();\n this.replaceD3Attr();\n this.replaceNativeSelect();\n this.replaceNativeGetComputedStyle();\n this.replaceD3Select();\n this.replaceD3Remove();\n this.replaceNativeGetScreenCtm();\n }\n\n initialize(svg: SVGElement & SsvgElement) {\n this.svg = svg;\n }\n\n private captureD3On() {\n if ((window as any)['d3']) {\n const d3 = (window as any)['d3'];\n const originalOn = d3.selection.prototype.on;\n const me = this;\n\n d3.selection.prototype.on = function () {\n let el =\n this._parents && this._parents.length ? this._parents[0] : this[0].parentNode;\n if (el === document.children[0]) {\n el = me.svg;\n }\n let isWithinSvg = me.domHandler.isWithinSvg(el);\n\n if (isWithinSvg) {\n me.interactions.captureD3On(el);\n }\n\n return originalOn.apply(this, arguments);\n };\n }\n }\n\n private replaceD3Select() {\n if ((window as any)['d3']) {\n const me = this;\n const d3 = (window as any)['d3'];\n\n const getReplacement = (original) => {\n return function (selector: string | (() => {})) {\n if (typeof selector === 'string') {\n if (selector === 'body') {\n return original.apply(this, arguments);\n }\n let elements: SsvgElement[];\n if (this === d3) {\n elements = [me.svg];\n } else {\n elements = this._groups ? this._groups[0] : this[0];\n }\n\n if (!elements.filter((e) => e).length) {\n safeLog(\n 'element not found within svg, using normal execution',\n this,\n selector\n );\n return original.apply(this, arguments);\n }\n\n let childElements: SsvgElement[] = [];\n\n for (let i = 0; i < elements.length; i++) {\n const element = elements[i];\n const node = me.domHandler.getVisNode(element);\n\n if (!node) {\n console.warn('node not found', element);\n return original.apply(this, arguments);\n }\n\n const childNodes = me.vdom.getVisNodesFromSelector(node, selector);\n childElements = childElements.concat(\n childNodes.map((node) => {\n return me.domHandler.getElementFromNode(node);\n })\n );\n }\n\n const returnValue = original.apply(this, arguments);\n const elementsOutsideSvg: NodeList = returnValue._groups\n ? returnValue._groups[0]\n : returnValue[0];\n elementsOutsideSvg.forEach((childNode) => {\n const childEl = <SsvgElement>(<any>childNode);\n if (childElements.indexOf(childEl) === -1) {\n childElements.push();\n }\n });\n\n if (returnValue._groups) {\n returnValue._groups[0] = childElements;\n } else {\n // Older d3 versions\n const parentNode = returnValue[0].parentNode;\n returnValue[0] = childElements;\n returnValue[0].parentNode = parentNode;\n }\n\n return returnValue;\n }\n\n return original.apply(this, arguments);\n };\n };\n\n d3.selection.prototype.selectAll = getReplacement(d3.selection.prototype.selectAll);\n d3.selectAll = getReplacement(d3.selectAll);\n d3.selection.prototype.select = getReplacement(d3.selection.prototype.select);\n d3.select = getReplacement(d3.select);\n\n const origFilter = d3.selection.prototype.filter;\n d3.selection.prototype.filter = function (selectorString: string) {\n const elements = this._groups ? this._groups[0] : this[0];\n if (typeof selectorString !== 'string') {\n return origFilter.apply(this, arguments);\n }\n let firstElement = elements[0];\n let i = 1;\n while (!firstElement && i < elements.length) {\n i++;\n firstElement = elements[i];\n }\n\n const parentNode = firstElement\n ? me.domHandler.getNodeFromElement(firstElement.parentNode)\n : null;\n const nodes = elements.map((element) => me.domHandler.getNodeFromElement(element));\n\n const selectors = selectorString.split(',').map((sel) => sel.trim());\n const filteredNodes = [];\n\n for (const selector of selectors) {\n const matchingNodes = me.vdom.filterNodesBySelector(\n parentNode,\n nodes,\n selector\n );\n\n for (const node of matchingNodes) {\n if (filteredNodes.indexOf(node) === -1) {\n filteredNodes.push(node);\n }\n }\n }\n\n const filteredElements = filteredNodes.map((node) =>\n me.domHandler.getElementFromNode(node)\n );\n\n const returnValue = origFilter.apply(this, arguments);\n\n if (returnValue._groups) {\n returnValue._groups[0] = filteredElements;\n } else {\n // Older d3 versions\n const parentNode = returnValue[0].parentNode;\n returnValue[0] = filteredElements;\n returnValue[0].parentNode = parentNode;\n }\n return returnValue;\n };\n }\n }\n\n private replaceNativeGetComputedStyle() {\n const origGetComputedStyle = window.getComputedStyle;\n const me = this;\n\n window.getComputedStyle = function (element: SsvgElement) {\n if (\n element &&\n !me.domHandler.isWithinSvg(element) &&\n <Window>(<any>element) !== window\n ) {\n return origGetComputedStyle.call(this, element);\n }\n\n const node = me.domHandler.getNodeFromElement(element);\n if (!node) {\n console.warn('node not found for ', this, element);\n return origGetComputedStyle.call(this, element);\n }\n return {\n getPropertyValue(propertyName: string): string {\n //console.log(propertyName, node, node.style[propertyName]);\n return node.style[propertyName];\n },\n } as CSSStyleDeclaration;\n };\n }\n\n private replaceNativeSelect() {\n const origQuerySelector = Element.prototype.querySelector;\n const me = this;\n\n Element.prototype.querySelector = function (this: SsvgElement, selector: string) {\n if (!me.domHandler.isWithinSvg(this)) {\n return origQuerySelector.apply(this, arguments);\n }\n\n const node = me.domHandler.getVisNode(this);\n const childNodes = me.vdom.getVisNodesFromSelector(node, selector);\n if (childNodes.length === 0) {\n console.warn(\n 'could not find selection',\n this,\n node,\n node.globalElementIndex,\n selector\n );\n return null;\n }\n return me.domHandler.getElementFromNode(childNodes[0]);\n };\n }\n\n private replaceD3Attr() {\n const me = this;\n\n function getReplacement(originalFct, prefix = '') {\n return function (name, value) {\n if (value === undefined) {\n if (me.unassignedNodes.indexOf(this) !== -1) {\n return originalFct.apply(this, arguments);\n } else {\n // Dealing with d3 v3.\n const els = this._groups ? this._groups[0] : this[0];\n if (els[0] && !me.domHandler.isWithinSvg(els[0])) {\n return originalFct.apply(this, arguments);\n }\n if (els.length > 1) {\n const returnVal = [];\n for (const el of els) {\n returnVal.push(me.domHandler.getAttributeFromSelector(el, name));\n }\n return returnVal;\n } else {\n return me.domHandler.getAttributeFromSelector(els[0], name);\n }\n }\n } else {\n if (name === 'class' || !me.svg) {\n return originalFct.apply(this, arguments);\n }\n // For d3 v4, this would just be this.groups[0]. The rest is for\n // earlier versions, where selectAll() returned other values.\n let elements = this._groups ? this._groups[0] : this[0];\n\n if (\n typeof elements === 'object' &&\n Object.keys(elements).length === 1 &&\n elements.parentNode\n ) {\n const parentElement = elements.parentNode;\n let parentNode: VdomNode;\n if (parentElement !== document.children[0]) {\n parentNode = me.domHandler.getVisNode(parentElement);\n } else {\n parentNode = me.vdom.data;\n }\n\n elements = [];\n for (const child of parentNode.children) {\n elements.push(me.domHandler.getElementFromNode(child));\n }\n }\n if (!elements) {\n return originalFct.apply(this, arguments);\n }\n const filteredElements = [];\n try {\n for (const element of elements) {\n if (element) {\n filteredElements.push(element);\n }\n }\n } catch (e) {\n console.error(elements, this);\n console.error(e);\n }\n if (filteredElements.length === 1) {\n const element = filteredElements[0];\n if (!element) {\n console.warn('element not found', this, name, value);\n return this;\n }\n if (!me.domHandler.isWithinSvg(element)) {\n return originalFct.apply(this, arguments);\n }\n me.domHandler.queueSetAttributeOnElement(element, prefix + name, value);\n } else {\n if (!me.domHandler.isWithinSvg(elements[0])) {\n return originalFct.apply(this, arguments);\n }\n me.domHandler.queueSetAttributeOnSelection(\n filteredElements,\n prefix + name,\n value\n );\n }\n\n if (filteredElements[0] === me.svg && (name === 'width' || name === 'height')) {\n me.vdom.data[name] = parseInt(value);\n me.onSvgSizeSet();\n }\n\n return this;\n }\n };\n }\n\n if ((window as any)['d3']) {\n const d3 = (window as any)['d3'];\n\n const origSelectionAttr = d3.selection.prototype.attr;\n d3.selection.prototype.attr = getReplacement(origSelectionAttr);\n\n const origSelectionStyle = d3.selection.prototype.style;\n d3.selection.prototype.style = getReplacement(origSelectionStyle, 'style;');\n\n const originalClassed = d3.selection.prototype.classed;\n d3.selection.prototype.classed = function (\n className: string,\n value?: boolean | ((data: any, index: number) => boolean)\n ) {\n if (value !== undefined) {\n me.domHandler.enableFrontendDesignProperties();\n let elements = this._groups ? this._groups[0] : this[0];\n let i = -1;\n for (let element of elements) {\n i++;\n if (element) {\n const node = me.domHandler.getNodeFromElement(element);\n if (!node) {\n console.warn('node not found', element);\n continue;\n }\n const prevClassNames = node.className || '';\n const evaluatedValue =\n typeof value === 'function' ? value(element.__data__, i) : value;\n if (evaluatedValue === true) {\n if (prevClassNames.indexOf(className) === -1) {\n let newClassNames = (prevClassNames + ' ' + className).trim();\n\n me.domHandler.queueSetAttributeOnElement(\n element,\n 'class',\n newClassNames\n );\n }\n } else if (evaluatedValue === false) {\n const containedPreviously =\n prevClassNames.indexOf(className) !== -1;\n if (containedPreviously) {\n const newClassNames = prevClassNames\n .replace(className, '')\n .replace(' ', ' ');\n me.domHandler.queueSetAttributeOnElement(\n element,\n 'class',\n newClassNames\n );\n\n if (!node['removedClasses']) {\n node['removedClasses'] = [];\n }\n node['removedClasses'].push(className); // For removing associated styles.\n }\n }\n }\n }\n }\n return originalClassed.apply(this, arguments);\n };\n\n const originalTransition = d3.selection.prototype.transition;\n d3.selection.prototype.transition = function () {\n me.domHandler.enableFrontendDesignProperties();\n return originalTransition.apply(this, arguments);\n };\n\n const originalText = d3.selection.prototype.text;\n d3.selection.prototype.text = function (\n value?: number | string | ((el: HTMLElement) => number | string)\n ) {\n if (value !== undefined) {\n let elements = this._groups ? this._groups[0] : this[0];\n let i = 0;\n for (let element of elements) {\n if (element && me.domHandler.isWithinSvg(element)) {\n me.domHandler.queueSetAttributeOnElement(element, 'text', value);\n }\n\n i++;\n }\n }\n return originalText.apply(this, arguments);\n };\n }\n }\n\n private replaceD3Remove() {\n if (window['d3']) {\n const d3 = window['d3'];\n\n const newRemove = this.getNewRemoveChild(() => {}, true);\n const d3Remove = function () {\n let elements = this._groups ? this._groups[0] : this[0];\n\n if (elements.length) {\n let parentElement: SsvgElement = null;\n for (let i = elements.length - 1; i > -1; i--) {\n const element = elements[i];\n if (element) {\n parentElement = element.parentNode;\n if (!parentElement) {\n console.error('element has no parent node', element);\n }\n newRemove.call(parentElement, element);\n }\n }\n }\n return this;\n };\n d3.selection.prototype.remove = d3Remove;\n //d3.transition.prototype.remove = d3Remove;\n }\n }\n\n private replaceNativeCreateElement() {\n const origCreate = document.createElementNS;\n const me = this;\n\n document.createElementNS = function () {\n let newArgs = Array.from(arguments);\n const el = origCreate.apply(this, newArgs);\n\n /*el.appendChild = () => {\n console.log('hi!!', el, arguments);\n //return el;\n };*/\n\n el.appendChild = me.getNewAppendChild(el.appendChild);\n\n me.unassignedNodes.push(el);\n\n //console.log(me.unassignedNodes);\n\n return el;\n };\n }\n\n private getNewRemoveChild(\n origRemoveChild: (<T extends Node>(oldChild: T) => T) | (() => void),\n skipUpdateSelectors = false\n ) {\n const me = this;\n\n return function <T extends Node>(this: SsvgElement, el: T & SsvgElement) {\n if (!this) {\n console.error('context not defined');\n return el;\n }\n if (!me.domHandler.isWithinSvg(el)) {\n return origRemoveChild.apply(this, arguments);\n }\n const parentNode = me.domHandler.getNodeFromElement(this);\n const node = me.domHandler.getNodeFromElement(el);\n\n if (!node) {\n console.error('node not found', node, el, this, parentNode);\n return origRemoveChild.apply(this, arguments);\n }\n\n // Remove all child elements.\n /*for(const childNode of node.children) {\n const childEl = me.domHandler.getElementFromNode(childNode);\n el.removeChild(childEl);\n }*/\n\n // Remove from current parent first.\n Object.defineProperty(el, 'parentNode', {\n writable: true,\n value: undefined,\n });\n\n //console.log('remove')\n /*me.enterExitQueue.push({\n cmd: 'EXIT',\n childGlobalIndex: el.globalElementIndex,\n parentGlobalIndex: parentNode.globalElementIndex\n });*/\n me.onRemoveNode(node, parentNode);\n\n me.domHandler.removeNode(el, node, parentNode);\n\n // Fix child indices of all children.\n if (!skipUpdateSelectors) {\n if (!parentNode) {\n console.error('parent not found', parentNode, this, el);\n }\n }\n\n delete el['selector'];\n\n return el;\n };\n }\n\n private replaceNativeRemoveChild() {\n Element.prototype.removeChild = this.getNewRemoveChild(Element.prototype.removeChild);\n }\n\n private getNewAppendChild(origAppend) {\n const me = this;\n\n return function <T extends Node>(this: SsvgElement, el: T & SsvgElement) {\n if (!me.svgIsAssignedAndSizeSet()) {\n if (!me.svg && el.tagName === 'svg') {\n const appended = origAppend.apply(this, arguments);\n me.onSvgAppended(<SVGElement & SsvgElement>(<unknown>el));\n return appended;\n } else {\n return origAppend.apply(this, arguments);\n }\n }\n\n if (!me.domHandler.isWithinSvg(this)) {\n return origAppend.apply(this, arguments);\n }\n\n Object.defineProperty(el, 'ownerSVGElement', {\n writable: true,\n value: me.svg,\n });\n el['appendChild'] = <T extends Node>(el2: T) => {\n return me.getNewAppendChild(origAppend).call(el, el2);\n };\n\n const parentNode = me.domHandler.getNodeFromElement(this);\n if (!parentNode) {\n return console.error('parent node not found', this);\n }\n let node: VdomNode;\n let keepChildren = false;\n\n if (el.globalElementIndex) {\n node = me.domHandler.getVisNode(el);\n\n me.getNewRemoveChild(() => {}).call(this, el);\n keepChildren = true; // If the element is being moved around, keep children.\n } else {\n node = me.domHandler.getNodeDataFromEl(el);\n }\n\n Object.defineProperty(el, 'style', {\n writable: true,\n value: {\n setProperty: function (styleProp: string, value: string) {\n me.domHandler.queueSetAttributeOnElement(el, 'style;' + styleProp, value);\n },\n getPropertyValue: function (styleProp) {\n me.domHandler.enableFrontendDesignProperties();\n return node.style[styleProp];\n },\n removeProperty: function () {\n console.log('remove property not yet implemented.');\n //TODO implement removeProperty CSS function.\n },\n },\n });\n\n Object.defineProperty(el, 'parentNode', {\n writable: true,\n value: this,\n });\n\n me.domHandler.linkNodeToElement(node, el);\n me.vdom.addNodeToParent(node, parentNode.globalElementIndex);\n me.domHandler.restyleNode(node);\n\n me.onAddNode(node, parentNode, keepChildren);\n /*if(me.useWorker) {\n me.enterExitQueue.push({\n cmd: 'ENTER',\n node: node,\n parentGlobalIndex: parentNode.globalElementIndex,\n keepChildren: keepChildren\n });\n } else {\n if(me.renderer.addNode) {\n me.renderer.addNode(node);\n }\n }*/\n\n if (me.unassignedNodes.indexOf(el) !== -1) {\n const index = me.unassignedNodes.indexOf(el);\n me.unassignedNodes.splice(index, 1);\n }\n\n return el;\n };\n }\n\n private replaceNativeAppendChild() {\n const origAppendChild = Element.prototype.appendChild;\n const newAppend = this.getNewAppendChild(origAppendChild);\n\n Element.prototype.appendChild = newAppend;\n Element.prototype.insertBefore = function <T extends Node>(\n newChild: T,\n refChild: Node | null\n ) {\n //TODO: Add insertBefore.\n newAppend.call(this, newChild);\n\n return newChild;\n };\n }\n\n private replaceNativePathFunctions() {\n const me = this;\n //const origGetPointAtLength = SVGPathElement.prototype.getPointAtLength;\n const origGetTotalLength = SVGPathElement.prototype.getTotalLength;\n\n /*SVGPathElement.prototype.getPointAtLength = function() {\n if(me.isWithinSvg(this)) {\n const d = this.getAttribute('d');\n me.origSetAttribute.call(this, 'd', d);\n }\n return origGetPointAtLength.apply(this, arguments);\n };*/\n SVGPathElement.prototype.getTotalLength = function () {\n if (me.domHandler.isWithinSvg(this)) {\n const d = this.getAttribute('d');\n me.origSetAttribute.call(this, 'd', d);\n }\n\n return origGetTotalLength.apply(this, arguments);\n };\n }\n\n private origSetAttribute;\n\n private replaceNativeAttribute() {\n this.origSetAttribute = Element.prototype.setAttribute;\n const me = this;\n\n const getNewSetAttr = (origSetAttr) => {\n return function (this: SsvgElement, name: string, value: any) {\n if (name === 'easypz' || me.unassignedNodes.indexOf(this) !== -1) {\n // Update the original SVG\n origSetAttr.apply(this, arguments);\n return;\n }\n if (name === 'class') {\n origSetAttr.apply(this, arguments);\n }\n if (!me.domHandler.isWithinSvg(this)) {\n return origSetAttr.apply(this, arguments);\n }\n me.domHandler.queueSetAttributeOnElement(this, name, value);\n };\n };\n\n Element.prototype.setAttribute = getNewSetAttr(Element.prototype.setAttribute);\n Element.prototype.setAttributeNS = getNewSetAttr(Element.prototype.setAttributeNS);\n\n //TODO: Figure out how to access the element when setting a style property.\n /*CSSStyleDeclaration.prototype.setProperty = function(name: string, value: any) {\n safeLog(this, arguments);\n me.elementHandler.queueSetAttributeOnElement(this, 'style;' + name, value);\n };*/\n\n const origGetAttr = Element.prototype.getAttribute;\n Element.prototype.getAttribute = function (this: SsvgElement, name) {\n const unassigned = me.unassignedNodes.indexOf(this) !== -1;\n const within = me.domHandler.isWithinSvg(this);\n if (unassigned || !within || !me.svg) {\n return origGetAttr.apply(this, arguments);\n } else {\n try {\n return me.domHandler.getAttributeFromSelector(this, name);\n } catch (e) {\n console.error(e);\n return origGetAttr.apply(this, arguments);\n }\n }\n };\n }\n\n private replaceNativeGetScreenCtm() {\n // Firefox always returns null for some reason. That is why this function is necessary.\n const orig = SVGGraphicsElement.prototype.getScreenCTM;\n SVGGraphicsElement.prototype.getScreenCTM = function (this: SsvgElement) {\n const origResult = orig.apply(this, arguments);\n if (origResult) {\n return origResult;\n }\n\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n\n return svg.createSVGMatrix();\n };\n }\n}\n"],"sourceRoot":""}