master 552f45af0a8c cached
31 files
258.6 KB
61.8k tokens
116 symbols
1 requests
Download .txt
Showing preview only (271K chars total). Download the full file or copy to clipboard to get everything.
Repository: node-vision/strapi-plugin-entity-relationship-chart
Branch: master
Commit: 552f45af0a8c
Files: 31
Total size: 258.6 KB

Directory structure:
gitextract_8lrq12pm/

├── .editorconfig
├── .gitattributes
├── .gitignore
├── README.md
├── admin/
│   └── src/
│       ├── components/
│       │   ├── Initializer/
│       │   │   └── index.js
│       │   └── PluginIcon/
│       │       └── index.js
│       ├── containers/
│       │   ├── App/
│       │   │   └── index.js
│       │   ├── HomePage/
│       │   │   └── index.js
│       │   └── Initializer/
│       │       └── index.js
│       ├── index.js
│       ├── pages/
│       │   ├── App/
│       │   │   └── index.js
│       │   └── HomePage/
│       │       ├── index.js
│       │       └── main.css
│       ├── pluginId.js
│       ├── translations/
│       │   ├── en.json
│       │   └── fr.json
│       └── utils/
│           ├── dagreLayout.js
│           ├── erChart.js
│           ├── getTrad.js
│           ├── requests.js
│           ├── storm-react-diagrams.js
│           └── trChart.js
├── package.json
├── server/
│   ├── config/
│   │   └── index.js
│   ├── controllers/
│   │   ├── entity-relationship-chart.js
│   │   └── index.js
│   ├── index.js
│   └── routes/
│       ├── index.js
│       └── routes.json
├── strapi-admin.js
└── strapi-server.js

================================================
FILE CONTENTS
================================================

================================================
FILE: .editorconfig
================================================
root = true

[*]
end_of_line = lf
insert_final_newline = false
indent_style = space
indent_size = 2


================================================
FILE: .gitattributes
================================================
# From https://github.com/Danimoth/gitattributes/blob/master/Web.gitattributes

# Handle line endings automatically for files detected as text
# and leave all files detected as binary untouched.
* text=auto

#
# The above will handle all files NOT found below
#

#
## These files are text and should be normalized (Convert crlf => lf)
#

# source code
*.php text
*.css text
*.sass text
*.scss text
*.less text
*.styl text
*.js text eol=lf
*.coffee text
*.json text
*.htm text
*.html text
*.xml text
*.svg text
*.txt text
*.ini text
*.inc text
*.pl text
*.rb text
*.py text
*.scm text
*.sql text
*.sh text
*.bat text

# templates
*.ejs text
*.hbt text
*.jade text
*.haml text
*.hbs text
*.dot text
*.tmpl text
*.phtml text

# git config
.gitattributes text
.gitignore text
.gitconfig text

# code analysis config
.jshintrc text
.jscsrc text
.jshintignore text
.csslintrc text

# misc config
*.yaml text
*.yml text
.editorconfig text

# build config
*.npmignore text
*.bowerrc text

# Heroku
Procfile text
.slugignore text

# Documentation
*.md text
LICENSE text
AUTHORS text


#
## These files are binary and should be left untouched
#

# (binary is a macro for -text -diff)
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.ico binary
*.mov binary
*.mp4 binary
*.mp3 binary
*.flv binary
*.fla binary
*.swf binary
*.gz binary
*.zip binary
*.7z binary
*.ttf binary
*.eot binary
*.woff binary
*.pyc binary
*.pdf binary


================================================
FILE: .gitignore
================================================
# Don't check auto-generated stuff into git
coverage
node_modules
stats.json
package-lock.json

# Cruft
.DS_Store
npm-debug.log
.idea


================================================
FILE: README.md
================================================
# Strapi plugin Entity Relationship Chart

Plugin displays Entity Relationship Diagram of all Strapi models, fields and relations.

![Preview](https://raw.githubusercontent.com/node-vision/strapi-plugin-entity-relationship-chart/master/preview.png)

## How to install:

1. In a root folder of your strapi project run `npm install strapi-plugin-entity-relationship-chart --save`
2. Rebuild admin UI `strapi build`
3. Run strapi `strapi develop`

## Exclude models from chart

You can exclude **contentTypes** or **components** from the chart by adding their ids to `exclude` plugin configuration property:

```js
// file: config/plugins.js
"use strict";

module.exports = () => ({
  // ...
  "entity-relationship-chart": {
    enabled: true,
    config: {
      // By default all contentTypes and components are included.
      // To exlclude strapi's internal models, use:
      exclude: [
        "strapi::core-store",
        "webhook",
        "admin::permission",
        "admin::user",
        "admin::role",
        "admin::api-token",
        "plugin::upload.file",
        "plugin::i18n.locale",
        "plugin::users-permissions.permission",
        "plugin::users-permissions.role",
      ],
    },
  },
  // ...
});
```

## Submitting issues:
Use github issues on the repo: - https://github.com/node-vision/strapi-plugin-entity-relationship-chart/issues

## Version Notes:

- this plugin was tested with stable Strapi - 4.0.6


================================================
FILE: admin/src/components/Initializer/index.js
================================================
/**
 *
 * Initializer
 *
 */

import { useEffect, useRef } from 'react';
import PropTypes from 'prop-types';
import pluginId from '../../pluginId';

const Initializer = ({ setPlugin }) => {
  const ref = useRef();
  ref.current = setPlugin;

  useEffect(() => {
    ref.current(pluginId);
  }, []);

  return null;
};

Initializer.propTypes = {
  setPlugin: PropTypes.func.isRequired,
};

export default Initializer;


================================================
FILE: admin/src/components/PluginIcon/index.js
================================================
/**
 *
 * PluginIcon
 *
 */

import React from 'react';
import OneToMany from '@strapi/icons/OneToMany';

const PluginIcon = () => <OneToMany />;

export default PluginIcon;


================================================
FILE: admin/src/containers/App/index.js
================================================
/**
 *
 * This component is the skeleton around the actual pages, and should only
 * contain code that should be seen on all pages. (e.g. navigation bar)
 *
 */

import React from 'react';
import { Switch, Route } from 'react-router-dom';
import { NotFound } from '@strapi/helper-plugin';
import pluginId from '../../pluginId';
import HomePage from '../HomePage';

const App = () => {
  return (
    <div>
      <Switch>
        <Route path={`/plugins/${pluginId}`} component={HomePage} exact />
        <Route component={NotFound} />
      </Switch>
    </div>
  );
};

export default App;


================================================
FILE: admin/src/containers/HomePage/index.js
================================================
/*
 *
 * HomePage
 *
 */

import React, { memo } from 'react';
// import PropTypes from 'prop-types';
import pluginId from '../../pluginId';

const HomePage = () => {
  return (
    <div>
      <h1>{pluginId}&apos;s HomePage</h1>
      <p>Happy coding</p>
    </div>
  );
};

export default memo(HomePage);


================================================
FILE: admin/src/containers/Initializer/index.js
================================================
/**
 *
 * Initializer
 *
 */

import { useEffect, useRef } from 'react';
import PropTypes from 'prop-types';
import pluginId from '../../pluginId';

const Initializer = ({ setPlugin }) => {
  const ref = useRef();
  ref.current = setPlugin;

  useEffect(() => {
    ref.current(pluginId);
  }, []);

  return null;
};

Initializer.propTypes = {
  setPlugin: PropTypes.func.isRequired,
};

export default Initializer;


================================================
FILE: admin/src/index.js
================================================
import { prefixPluginTranslations } from '@strapi/helper-plugin';
import pluginPkg from '../../package.json';
import pluginId from './pluginId';
import Initializer from './components/Initializer';
import PluginIcon from './components/PluginIcon';

const name = pluginPkg.strapi.name;

export default {
  register(app) {
    app.addMenuLink({
      to: `/plugins/${pluginId}`,
      icon: PluginIcon,
      intlLabel: {
        id: `${pluginId}.plugin.name`,
        defaultMessage: 'ER Chart',
      },
      Component: async () => {
        const component = await import(/* webpackChunkName: "[request]" */ './pages/App');

        return component;
      },
      permissions: [
        // Uncomment to set the permissions of the plugin here
        // {
        //   action: '', // the action name should be plugin::plugin-name.actionType
        //   subject: null,
        // },
      ],
    });
    app.registerPlugin({
      id: pluginId,
      initializer: Initializer,
      isReady: false,
      name,
    });
  },

  bootstrap(app) {},
  async registerTrads({ locales }) {
    const importedTrads = await Promise.all(
      locales.map((locale) => {
        return import(`./translations/${locale}.json`)
          .then(({ default: data }) => {
            return {
              data: prefixPluginTranslations(data, pluginId),
              locale,
            };
          })
          .catch(() => {
            return {
              data: {},
              locale,
            };
          });
      })
    );

    return Promise.resolve(importedTrads);
  },
};


================================================
FILE: admin/src/pages/App/index.js
================================================
/**
 *
 * This component is the skeleton around the actual pages, and should only
 * contain code that should be seen on all pages. (e.g. navigation bar)
 *
 */

import React from 'react';
import { Switch, Route } from 'react-router-dom';
import { NotFound } from '@strapi/helper-plugin';
import pluginId from '../../pluginId';
import HomePage from '../HomePage';

const App = () => {
  return (
    <div>
      <Switch>
        <Route path={`/plugins/${pluginId}`} component={HomePage} exact />
        <Route component={NotFound} />
      </Switch>
    </div>
  );
};

export default App;


================================================
FILE: admin/src/pages/HomePage/index.js
================================================
import React, { memo, useEffect, useState } from 'react';
import styled from 'styled-components'
import {
  useParams
} from "react-router-dom";
import { useIntl } from "react-intl";
import { ContentLayout, HeaderLayout } from "@strapi/design-system/Layout";
import { Box } from "@strapi/design-system/Box";
import { Button } from "@strapi/design-system/Button";
import getTrad from "../../utils/getTrad";
import { DiagramWidget } from '../../utils/storm-react-diagrams';
import { dagreLayout } from '../../utils/dagreLayout';
import { getTablesRelationData, getEntitiesRelationData } from '../../utils/requests';
import { drawEntityNodes } from '../../utils/erChart';
import { drawDatabaseNodes } from '../../utils/trChart';
import '../../utils/style.min.css';
import './main.css';

const Legend = styled.span`
  width: 12px;
  height: 3px;
  vertical-align: middle;
  display: inline-block;
  margin: 0 8px 0 4px;
  border-radius: 1px;

  background-color: ${props => props.color ? props.color : "#999"};
`;

const Icon = styled.span`
  svg {
    width: 1em;
    height: 1em;
    vertical-align: middle;

    > g,
    path {
      fill: none
    }
  }
`
function FeatherDatabase(props) {
  return <Icon>
    <svg width="1em" height="1em" viewBox="0 0 24 24" {...props}><g fill="none" stroke="#ffffff" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><ellipse cx="12" cy="5" rx="9" ry="3"></ellipse><path d="M21 12c0 1.66-4 3-9 3s-9-1.34-9-3"></path><path d="M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5"></path></g></svg>
  </Icon>
}

function FeatherBox(props) {
  return <Icon>
    <svg width="1em" height="1em" viewBox="0 0 24 24" {...props}><g fill="none" stroke="#ffffff" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path><path d="M3.27 6.96L12 12.01l8.73-5.05"></path><path d="M12 22.08V12"></path></g></svg>
  </Icon>
}

function updateQuery(key, value) {
  const url = new URL(window.location);
  if (!value) {
    url.searchParams.delete(key);
  } else {
    url.searchParams.set(key, value);
  }
  window.history.pushState({}, '', url);
}

const HomePage = () => {
  const url = new URL(window.location);
  const [type, setType] = useState(url.searchParams.get('type'));
  const [engine, setEngine] = useState();
  const [erData, setERData] = useState();
  const [trData, setTRData] = useState();
  const [error, setError] = useState();
  const [relations, setRelations] = useState(true);
  const [components, setComponents] = useState(true);
  const [dynamiczones, setDynamiczones] = useState(true);

  const { formatMessage } = useIntl();
  const title = formatMessage({
    id: getTrad("name"),
    defaultMessage: "Entity Relationship Chart",
  });
  const subtitle = formatMessage({
    id: getTrad("description"),
    defaultMessage: "Displays Entity Relationship Diagram of all Strapi models, fields and relations.",
  });

  useEffect(() => {
    async function getData() {
      try {
        if (type === undefined && !erData) {
          setERData(await getEntitiesRelationData());
        } else if (type === 'database' && !trData) {
          setTRData(await getTablesRelationData());
        }
      } catch (e) {
        setError(e);
      }
    }
    getData();
  }, [type, setERData, setTRData, setError]);

  useEffect(() => {
    setEngine(null);
    setTimeout(() => {
      if (type === undefined && erData) {
        const { engine, model } = drawEntityNodes(erData, { relations, components, dynamiczones });
        setEngine(engine);
        setTimeout(() => {
          dagreLayout(model)
          engine.repaintCanvas();
        }, 0)
      } else if (type === 'database' && trData) {
        const { engine, model } = drawDatabaseNodes(trData, { relations, components, dynamiczones });
        setEngine(engine);
        setTimeout(() => {
          dagreLayout(model);
          engine.repaintCanvas();
        }, 0);

      }
    }, 0)
  }, [type, erData, trData, relations, components, dynamiczones]);

  useEffect(() => {
    updateQuery('type', type);
  }, [type])

  return (
    <main>
      <HeaderLayout
        title={title}
        subtitle={subtitle}
        primaryAction={
          type === undefined
            ? <Button startIcon={<FeatherDatabase />} onClick={() => setType('database')}>Switch to Database view</Button> 
            : <Button startIcon={<FeatherBox />} onClick={() => setType()}>Switch to API view</Button>
        }
      />
      <ContentLayout>
        {error && (
          <Box padding={7} background="neutral0" hasRadius>
            <h2>{error.toString()}</h2>
            <pre><code>{error.stack}</code></pre>
          </Box>
        )}
        {!error && (
          <>
            <Box padding={1}>
              <label>
                <input type="checkbox" checked={relations} onChange={(e) => setRelations(e.target.checked)} /> relations
                <Legend />
              </label>
              <label>
                <input type="checkbox" checked={components} onChange={(e) => setComponents(e.target.checked)} /> components
                <Legend color="#ffc800"/>
              </label>
              <label>
                <input type="checkbox" checked={dynamiczones} onChange={(e) => setDynamiczones(e.target.checked)} /> dynamiczones
                <Legend color="#ff6400" />
              </label>
            </Box>
            <Box background="neutral0" hasRadius style={{height: "80vh", width: "100%"}}>
              {engine && <DiagramWidget diagramEngine={engine} />}
            </Box>
          </>
        )}
      </ContentLayout>
    </main>
  );
};

export default memo(HomePage);


================================================
FILE: admin/src/pages/HomePage/main.css
================================================
.srd-diagram {
  height: 80vh;
  overflow: hidden;
}

/* .srd-default-link path {
  stroke: #000;
} */

.erc-header-title p {
  width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.3rem;
  font-weight: 400;
  line-height: normal;
  color: rgb(120, 126, 143);
  margin: 0px;
  overflow: hidden;
}

.erc-header-title h1 {
  position: relative;
  width: -webkit-fit-content;
  width: -moz-fit-content;
  width: fit-content;
  max-width: 100%;
  margin-bottom: 0;
  padding-right: 18px;
  font-size: 2.4rem;
  line-height: normal;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


================================================
FILE: admin/src/pluginId.js
================================================
const pluginPkg = require('../../package.json');

const pluginId = pluginPkg.name.replace(/^strapi-plugin-/i, '');

module.exports = pluginId;


================================================
FILE: admin/src/translations/en.json
================================================
{}


================================================
FILE: admin/src/translations/fr.json
================================================
{}


================================================
FILE: admin/src/utils/dagreLayout.js
================================================
import dagre from '@dagrejs/dagre';
import { 
  PointModel,
} from './storm-react-diagrams';

export function dagreLayout(model) {
  // Create a new directed graph
  const g = new dagre.graphlib.Graph({
    multigraph: true,
    compound: true,
  });
  g.setGraph({
    align: 'DR',
    rankdir: 'RL',
    ranker: 'longest-path',
    marginx: 25,
    marginy: 25,
  });
  g.setDefaultEdgeLabel(function () {
    return {};
  });

  // set nodes
  _.forEach(model.getNodes(), (node) => {
    g.setNode(node.getID(), {label: node.getID(), width: node.width, height: node.height });
  });

  _.forEach(model.getLinks(), (link) => {
    // set edges
    if (link.getSourcePort() && link.getTargetPort()) {
      g.setEdge({
        v: link.getSourcePort().getNode().getID(),
        w: link.getTargetPort().getNode().getID(),
        name: link.getID(),
      });
    }
  });

  // layout the graph
  dagre.layout(g);

  g.nodes().forEach((v) => {
    const node = g.node(v);
    model.getNode(v).setPosition(node.x - node.width / 2, node.y - node.height / 2);
  });

  g.edges().forEach((e) => {
    const edge = g.edge(e);
    const link = model.getLink(e.name);

    const points = [link.getFirstPoint()];
      for (let i = 1; i < edge.points.length - 1; i++) {
        points.push(new PointModel(link, { x: edge.points[i].x, y: edge.points[i].y }));
      }
    link.setPoints(points.concat(link.getLastPoint()));
  });
}

================================================
FILE: admin/src/utils/erChart.js
================================================

import _ from 'lodash';
import  { 
  DiagramEngine, 
  DiagramModel, 
  DefaultNodeModel,
  DefaultNodeFactory, 
  DefaultLinkFactory, 
  DefaultPortFactory, 
  DefaultLabelFactory 
} from './storm-react-diagrams';

export function drawEntityNodes(data, options) {
  const engine = new DiagramEngine();

  // engine.installDefaultFactories();
  engine.registerNodeFactory(new DefaultNodeFactory());
  engine.registerLinkFactory(new DefaultLinkFactory());
  engine.registerPortFactory(new DefaultPortFactory());
  engine.registerLabelFactory(new DefaultLabelFactory());
  
  const model = new DiagramModel();
  const nodes = [],
    nodesMap = {},
    links = [];

  // build nodes and ports
  for (const index in data) {
    const model = data[index];
    const color = model.modelType === 'component' ? 'rgb(255, 200, 0)' : model.kind === 'collectionType' ? 'rgb(0,126,255)' : 'rgb(85, 171, 0)'
    const node = new DefaultNodeModel(model.key, color);
    const ports = {};
    const attributes = Object.keys(model.attributes)

    ports.id = node.addInPort('id')

    for (const attr of attributes) {
      const fieldData = model.attributes[attr];
      const relation = fieldData.type === 'relation';
      const component = fieldData.type === 'component';
      const dynamiczone = fieldData.type === 'dynamiczone';
      
      if (relation) {
        ports[attr] = node.addOutPort(attr);
      } else if (component) {
        ports[attr] = node.addOutPort(attr);
      } else if (dynamiczone) {
        ports[attr] = node.addOutPort(attr);
      } else {
        //if scalar field
        ports[attr] = node.addInPort(attr);
      }
    }
    
    node.setPosition(0, 0);
    nodes.push(node);
    nodesMap[model.key] = { node, ports };
  }

  // build links
  for (const index in data) {
    const model = data[index];
    const { node, ports } = nodesMap[model.key]
    const attributes = Object.keys(model.attributes)

    for (const attr of attributes) {
      const fieldData = model.attributes[attr];
      const relation = fieldData.type === 'relation';
      const component = fieldData.type === 'component' && fieldData?.component;
      const dynamiczone = fieldData.type === 'dynamiczone' && fieldData?.components;
      const relationTarget = fieldData?.target
      // const relationField = fieldData.inversedBy || fieldData.morphBy || fieldData.mappedBy;
      
      if (relation && options.relations && relationTarget && nodesMap[relationTarget]) {
        //if relation
        const outPort = ports[attr]
        const link = outPort.link(nodesMap[relationTarget].ports.id);
        link.setColor('#999');
        links.push(link);
      } else if (component && nodesMap[component] && options.components) {
        //if component
        const outPort = ports[attr];
        const link = outPort.link(nodesMap[component].ports.id);
        link.setColor('#ffc800');
        links.push(link);
      } else if (dynamiczone && Array.isArray(dynamiczone) && options.dynamiczones) {
        //if dynamiczone
        for (const compId of dynamiczone) {
          if (nodesMap[compId]) {
            const outPort = ports[attr];
            const link = outPort.link(nodesMap[compId].ports.id);
            link.setColor('#ff6400');
            links.push(link);
          }
        }
      }
    }
    nodesMap[model.key] = { node, ports };
  }

  model.addAll(...nodes, ...links);
  engine.setDiagramModel(model);
  return { engine, model };
}

================================================
FILE: admin/src/utils/getTrad.js
================================================
import pluginId from '../pluginId';

const getTrad = (id) => `${pluginId}.${id}`;

export default getTrad;


================================================
FILE: admin/src/utils/requests.js
================================================

import { request } from '@strapi/helper-plugin';
import pluginId from '../pluginId';

export async function getEntitiesRelationData() {
  return await request(`/${pluginId}/er-data`);
}
export async function getTablesRelationData() {
  return await request(`/${pluginId}/tr-data`);
}

================================================
FILE: admin/src/utils/storm-react-diagrams.js
================================================
/**
 * This is a copy of storm-react-diagrams/dist/main.js with 2 replaces:
 * '"_"' replaced as 'lodash'
 * 'var _ = __webpack_require__(0);' replaced as 'var _ = require("lodash")'
 * Cleaner solution is to use webpack alias: {resolve} in webpack config, but strapi plugin doesn't allow
 * to change webpack config on plugin level, so users of this plugin would need to manually update
 * src/admin/webpack.config.js in their project. This override makes it easier.
 */

(function webpackUniversalModuleDefinition(root, factory) {
  if (typeof exports === 'object' && typeof module === 'object') {
    module.exports = factory(require('lodash'), require('react'));
  } else if (typeof define === 'function' && define.amd) define(['lodash', 'react'], factory);
  else if (typeof exports === 'object') exports['storm-react-diagrams'] = factory(require('lodash'), require('react'));
  else root['storm-react-diagrams'] = factory(root['lodash'], root['React']);
})(window, function (__WEBPACK_EXTERNAL_MODULE__0__, __WEBPACK_EXTERNAL_MODULE__1__) {
  return (function (modules) {
    var installedModules = {};

    function __webpack_require__(moduleId) {
      if (installedModules[moduleId]) {
        return installedModules[moduleId].exports;
      }
      var module = (installedModules[moduleId] = { i: moduleId, l: false, exports: {} });
      modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
      module.l = true;
      return module.exports;
    }

    __webpack_require__.m = modules;
    __webpack_require__.c = installedModules;
    __webpack_require__.d = function (exports, name, getter) {
      if (!__webpack_require__.o(exports, name)) {
        Object.defineProperty(exports, name, { configurable: false, enumerable: true, get: getter });
      }
    };
    __webpack_require__.r = function (exports) {
      Object.defineProperty(exports, '__esModule', { value: true });
    };
    __webpack_require__.n = function (module) {
      var getter =
        module && module.__esModule
          ? function getDefault() {
              return module['default'];
            }
          : function getModuleExports() {
              return module;
            };
      __webpack_require__.d(getter, 'a', getter);
      return getter;
    };
    __webpack_require__.o = function (object, property) {
      return Object.prototype.hasOwnProperty.call(object, property);
    };
    __webpack_require__.p = '';
    return __webpack_require__((__webpack_require__.s = 45));
  })([
    function (module, exports) {
      module.exports = __WEBPACK_EXTERNAL_MODULE__0__;
    },
    function (module, exports) {
      module.exports = __WEBPACK_EXTERNAL_MODULE__1__;
    },
    function (module, exports) {
      var DiagonalMovement = { Always: 1, Never: 2, IfAtMostOneObstacle: 3, OnlyWhenNoObstacles: 4 };
      module.exports = DiagonalMovement;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      var __assign =
        (this && this.__assign) ||
        Object.assign ||
        function (t) {
          for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
          }
          return t;
        };
      Object.defineProperty(exports, '__esModule', { value: true });
      var React = __webpack_require__(1);
      var BaseWidget = (function (_super) {
        __extends(BaseWidget, _super);

        function BaseWidget(name, props) {
          var _this = _super.call(this, props) || this;
          _this.className = name;
          return _this;
        }

        BaseWidget.prototype.bem = function (selector) {
          return (this.props.baseClass || this.className) + selector + ' ';
        };
        BaseWidget.prototype.getClassName = function () {
          return (this.props.baseClass || this.className) + ' ' + (this.props.className ? this.props.className + ' ' : '');
        };
        BaseWidget.prototype.getProps = function () {
          return __assign({}, this.props.extraProps || {}, { className: this.getClassName() });
        };
        return BaseWidget;
      })(React.Component);
      exports.BaseWidget = BaseWidget;
    },
    function (module, exports) {
      function backtrace(node) {
        var path = [[node.x, node.y]];
        while (node.parent) {
          node = node.parent;
          path.push([node.x, node.y]);
        }
        return path.reverse();
      }

      exports.backtrace = backtrace;

      function biBacktrace(nodeA, nodeB) {
        var pathA = backtrace(nodeA),
          pathB = backtrace(nodeB);
        return pathA.concat(pathB.reverse());
      }

      exports.biBacktrace = biBacktrace;

      function pathLength(path) {
        var i,
          sum = 0,
          a,
          b,
          dx,
          dy;
        for (i = 1; i < path.length; ++i) {
          a = path[i - 1];
          b = path[i];
          dx = a[0] - b[0];
          dy = a[1] - b[1];
          sum += Math.sqrt(dx * dx + dy * dy);
        }
        return sum;
      }

      exports.pathLength = pathLength;

      function interpolate(x0, y0, x1, y1) {
        var abs = Math.abs,
          line = [],
          sx,
          sy,
          dx,
          dy,
          err,
          e2;
        dx = abs(x1 - x0);
        dy = abs(y1 - y0);
        sx = x0 < x1 ? 1 : -1;
        sy = y0 < y1 ? 1 : -1;
        err = dx - dy;
        while (true) {
          line.push([x0, y0]);
          if (x0 === x1 && y0 === y1) {
            break;
          }
          e2 = 2 * err;
          if (e2 > -dy) {
            err = err - dy;
            x0 = x0 + sx;
          }
          if (e2 < dx) {
            err = err + dx;
            y0 = y0 + sy;
          }
        }
        return line;
      }

      exports.interpolate = interpolate;

      function expandPath(path) {
        var expanded = [],
          len = path.length,
          coord0,
          coord1,
          interpolated,
          interpolatedLen,
          i,
          j;
        if (len < 2) {
          return expanded;
        }
        for (i = 0; i < len - 1; ++i) {
          coord0 = path[i];
          coord1 = path[i + 1];
          interpolated = interpolate(coord0[0], coord0[1], coord1[0], coord1[1]);
          interpolatedLen = interpolated.length;
          for (j = 0; j < interpolatedLen - 1; ++j) {
            expanded.push(interpolated[j]);
          }
        }
        expanded.push(path[len - 1]);
        return expanded;
      }

      exports.expandPath = expandPath;

      function smoothenPath(grid, path) {
        var len = path.length,
          x0 = path[0][0],
          y0 = path[0][1],
          x1 = path[len - 1][0],
          y1 = path[len - 1][1],
          sx,
          sy,
          ex,
          ey,
          newPath,
          i,
          j,
          coord,
          line,
          testCoord,
          blocked;
        sx = x0;
        sy = y0;
        newPath = [[sx, sy]];
        for (i = 2; i < len; ++i) {
          coord = path[i];
          ex = coord[0];
          ey = coord[1];
          line = interpolate(sx, sy, ex, ey);
          blocked = false;
          for (j = 1; j < line.length; ++j) {
            testCoord = line[j];
            if (!grid.isWalkableAt(testCoord[0], testCoord[1])) {
              blocked = true;
              break;
            }
          }
          if (blocked) {
            lastValidCoord = path[i - 1];
            newPath.push(lastValidCoord);
            sx = lastValidCoord[0];
            sy = lastValidCoord[1];
          }
        }
        newPath.push([x1, y1]);
        return newPath;
      }

      exports.smoothenPath = smoothenPath;

      function compressPath(path) {
        if (path.length < 3) {
          return path;
        }
        var compressed = [],
          sx = path[0][0],
          sy = path[0][1],
          px = path[1][0],
          py = path[1][1],
          dx = px - sx,
          dy = py - sy,
          lx,
          ly,
          ldx,
          ldy,
          sq,
          i;
        sq = Math.sqrt(dx * dx + dy * dy);
        dx /= sq;
        dy /= sq;
        compressed.push([sx, sy]);
        for (i = 2; i < path.length; i++) {
          lx = px;
          ly = py;
          ldx = dx;
          ldy = dy;
          px = path[i][0];
          py = path[i][1];
          dx = px - lx;
          dy = py - ly;
          sq = Math.sqrt(dx * dx + dy * dy);
          dx /= sq;
          dy /= sq;
          if (dx !== ldx || dy !== ldy) {
            compressed.push([lx, ly]);
          }
        }
        compressed.push([px, py]);
        return compressed;
      }

      exports.compressPath = compressPath;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      Object.defineProperty(exports, '__esModule', { value: true });
      var BaseModel_1 = __webpack_require__(6);

      var PointModel = (function (_super) {
        __extends(PointModel, _super);

        function PointModel(link, points) {
          var _this = _super.call(this) || this;
          _this.x = points.x;
          _this.y = points.y;
          _this.parent = link;
          return _this;
        }

        PointModel.prototype.getSelectedEntities = function () {
          if (_super.prototype.isSelected.call(this) && !this.isConnectedToPort()) {
            return [this];
          }
          return [];
        };
        PointModel.prototype.isConnectedToPort = function () {
          return this.parent.getPortForPoint(this) !== null;
        };
        PointModel.prototype.getLink = function () {
          return this.getParent();
        };
        PointModel.prototype.deSerialize = function (ob, engine) {
          _super.prototype.deSerialize.call(this, ob, engine);
          this.x = ob.x;
          this.y = ob.y;
        };
        PointModel.prototype.serialize = function () {
          return _.merge(_super.prototype.serialize.call(this), { x: this.x, y: this.y });
        };
        PointModel.prototype.remove = function () {
          if (this.parent) {
            this.parent.removePoint(this);
          }
          _super.prototype.remove.call(this);
        };
        PointModel.prototype.updateLocation = function (points) {
          this.x = points.x;
          this.y = points.y;
        };
        PointModel.prototype.getX = function () {
          return this.x;
        };
        PointModel.prototype.getY = function () {
          return this.y;
        };
        PointModel.prototype.isLocked = function () {
          return _super.prototype.isLocked.call(this) || this.getParent().isLocked();
        };
        return PointModel;
      })(BaseModel_1.BaseModel);
      exports.PointModel = PointModel;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      var __assign =
        (this && this.__assign) ||
        Object.assign ||
        function (t) {
          for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
          }
          return t;
        };
      Object.defineProperty(exports, '__esModule', { value: true });
      var BaseEntity_1 = __webpack_require__(13);
      var _ = require('lodash');
      var BaseModel = (function (_super) {
        __extends(BaseModel, _super);

        function BaseModel(type, id) {
          var _this = _super.call(this, id) || this;
          _this.type = type;
          _this.selected = false;
          return _this;
        }

        BaseModel.prototype.getParent = function () {
          return this.parent;
        };
        BaseModel.prototype.setParent = function (parent) {
          this.parent = parent;
        };
        BaseModel.prototype.getSelectedEntities = function () {
          if (this.isSelected()) {
            return [this];
          }
          return [];
        };
        BaseModel.prototype.deSerialize = function (ob, engine) {
          _super.prototype.deSerialize.call(this, ob, engine);
          this.type = ob.type;
          this.selected = ob.selected;
        };
        BaseModel.prototype.serialize = function () {
          return _.merge(_super.prototype.serialize.call(this), { type: this.type, selected: this.selected });
        };
        BaseModel.prototype.getType = function () {
          return this.type;
        };
        BaseModel.prototype.getID = function () {
          return this.id;
        };
        BaseModel.prototype.isSelected = function () {
          return this.selected;
        };
        BaseModel.prototype.setSelected = function (selected) {
          if (selected === void 0) {
            selected = true;
          }
          this.selected = selected;
          this.iterateListeners(function (listener, event) {
            if (listener.selectionChanged) {
              listener.selectionChanged(__assign({}, event, { isSelected: selected }));
            }
          });
        };
        BaseModel.prototype.remove = function () {
          this.iterateListeners(function (listener, event) {
            if (listener.entityRemoved) {
              listener.entityRemoved(event);
            }
          });
        };
        return BaseModel;
      })(BaseEntity_1.BaseEntity);
      exports.BaseModel = BaseModel;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      Object.defineProperty(exports, '__esModule', { value: true });
      var closest = __webpack_require__(70);
      var PathFinding_1 = __webpack_require__(16);
      var Path = __webpack_require__(51);
      var Toolkit = (function () {
        function Toolkit() {}

        Toolkit.UID = function () {
          if (Toolkit.TESTING) {
            Toolkit.TESTING_UID++;
            return '' + Toolkit.TESTING_UID;
          }
          return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
            var r = (Math.random() * 16) | 0;
            var v = c === 'x' ? r : (r & 3) | 8;
            return v.toString(16);
          });
        };
        Toolkit.closest = function (element, selector) {
          if (document.body.closest) {
            return element.closest(selector);
          }
          return closest(element, selector);
        };
        Toolkit.generateLinePath = function (firstPoint, lastPoint) {
          return 'M' + firstPoint.x + ',' + firstPoint.y + ' L ' + lastPoint.x + ',' + lastPoint.y;
        };
        Toolkit.generateCurvePath = function (firstPoint, lastPoint, curvy) {
          if (curvy === void 0) {
            curvy = 0;
          }
          var isHorizontal = Math.abs(firstPoint.x - lastPoint.x) > Math.abs(firstPoint.y - lastPoint.y);
          var curvyX = isHorizontal ? curvy : 0;
          var curvyY = isHorizontal ? 0 : curvy;
          return (
            'M' +
            firstPoint.x +
            ',' +
            firstPoint.y +
            ' C ' +
            (firstPoint.x + curvyX) +
            ',' +
            (firstPoint.y + curvyY) +
            '\n    ' +
            (lastPoint.x - curvyX) +
            ',' +
            (lastPoint.y - curvyY) +
            ' ' +
            lastPoint.x +
            ',' +
            lastPoint.y
          );
        };
        Toolkit.generateDynamicPath = function (pathCoords) {
          var path = Path();
          path = path.moveto(pathCoords[0][0] * PathFinding_1.ROUTING_SCALING_FACTOR, pathCoords[0][1] * PathFinding_1.ROUTING_SCALING_FACTOR);
          pathCoords.slice(1).forEach(function (coords) {
            path = path.lineto(coords[0] * PathFinding_1.ROUTING_SCALING_FACTOR, coords[1] * PathFinding_1.ROUTING_SCALING_FACTOR);
          });
          return path.print();
        };
        Toolkit.TESTING = false;
        Toolkit.TESTING_UID = 0;
        return Toolkit;
      })();
      exports.Toolkit = Toolkit;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      Object.defineProperty(exports, '__esModule', { value: true });
      var AbstractFactory = (function () {
        function AbstractFactory(name) {
          this.type = name;
        }

        AbstractFactory.prototype.getType = function () {
          return this.type;
        };
        return AbstractFactory;
      })();
      exports.AbstractFactory = AbstractFactory;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      Object.defineProperty(exports, '__esModule', { value: true });
      var BaseModel_1 = __webpack_require__(6);
      var _ = require('lodash');
      var NodeModel = (function (_super) {
        __extends(NodeModel, _super);

        function NodeModel(nodeType, id) {
          if (nodeType === void 0) {
            nodeType = 'default';
          }
          var _this = _super.call(this, nodeType, id) || this;
          _this.x = 0;
          _this.y = 0;
          _this.extras = {};
          _this.ports = {};
          return _this;
        }

        NodeModel.prototype.setPosition = function (x, y) {
          var oldX = this.x;
          var oldY = this.y;
          _.forEach(this.ports, function (port) {
            _.forEach(port.getLinks(), function (link) {
              var point = link.getPointForPort(port);
              point.x = point.x + x - oldX;
              point.y = point.y + y - oldY;
            });
          });
          this.x = x;
          this.y = y;
        };
        NodeModel.prototype.getSelectedEntities = function () {
          var entities = _super.prototype.getSelectedEntities.call(this);
          if (this.isSelected()) {
            _.forEach(this.ports, function (port) {
              entities = entities.concat(
                _.map(port.getLinks(), function (link) {
                  return link.getPointForPort(port);
                })
              );
            });
          }
          return entities;
        };
        NodeModel.prototype.deSerialize = function (ob, engine) {
          var _this = this;
          _super.prototype.deSerialize.call(this, ob, engine);
          this.x = ob.x;
          this.y = ob.y;
          this.extras = ob.extras;
          _.forEach(ob.ports, function (port) {
            var portOb = engine.getPortFactory(port.type).getNewInstance();
            portOb.deSerialize(port, engine);
            _this.addPort(portOb);
          });
        };
        NodeModel.prototype.serialize = function () {
          return _.merge(_super.prototype.serialize.call(this), {
            x: this.x,
            y: this.y,
            extras: this.extras,
            ports: _.map(this.ports, function (port) {
              return port.serialize();
            }),
          });
        };
        NodeModel.prototype.doClone = function (lookupTable, clone) {
          if (lookupTable === void 0) {
            lookupTable = {};
          }
          clone.ports = {};
          _.forEach(this.ports, function (port) {
            clone.addPort(port.clone(lookupTable));
          });
        };
        NodeModel.prototype.remove = function () {
          _super.prototype.remove.call(this);
          _.forEach(this.ports, function (port) {
            _.forEach(port.getLinks(), function (link) {
              link.remove();
            });
          });
        };
        NodeModel.prototype.getPortFromID = function (id) {
          for (var i in this.ports) {
            if (this.ports[i].id === id) {
              return this.ports[i];
            }
          }
          return null;
        };
        NodeModel.prototype.getPort = function (name) {
          return this.ports[name];
        };
        NodeModel.prototype.getPorts = function () {
          return this.ports;
        };
        NodeModel.prototype.removePort = function (port) {
          if (this.ports[port.name]) {
            this.ports[port.name].setParent(null);
            delete this.ports[port.name];
          }
        };
        NodeModel.prototype.addPort = function (port) {
          port.setParent(this);
          this.ports[port.name] = port;
          return port;
        };
        NodeModel.prototype.updateDimensions = function (_a) {
          var width = _a.width,
            height = _a.height;
          this.width = width;
          this.height = height;
        };
        return NodeModel;
      })(BaseModel_1.BaseModel);
      exports.NodeModel = NodeModel;
    },
    function (module, exports) {
      module.exports = {
        manhattan: function (dx, dy) {
          return dx + dy;
        },
        euclidean: function (dx, dy) {
          return Math.sqrt(dx * dx + dy * dy);
        },
        octile: function (dx, dy) {
          var F = Math.SQRT2 - 1;
          return dx < dy ? F * dx + dy : F * dy + dx;
        },
        chebyshev: function (dx, dy) {
          return Math.max(dx, dy);
        },
      };
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      Object.defineProperty(exports, '__esModule', { value: true });
      var BaseAction = (function () {
        function BaseAction(mouseX, mouseY) {
          this.mouseX = mouseX;
          this.mouseY = mouseY;
          this.ms = new Date().getTime();
        }

        return BaseAction;
      })();
      exports.BaseAction = BaseAction;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      Object.defineProperty(exports, '__esModule', { value: true });
      var BaseModel_1 = __webpack_require__(6);
      var _ = require('lodash');
      var PortModel = (function (_super) {
        __extends(PortModel, _super);

        function PortModel(name, type, id, maximumLinks) {
          var _this = _super.call(this, type, id) || this;
          _this.name = name;
          _this.links = {};
          _this.maximumLinks = maximumLinks;
          return _this;
        }

        PortModel.prototype.deSerialize = function (ob, engine) {
          _super.prototype.deSerialize.call(this, ob, engine);
          this.name = ob.name;
          this.maximumLinks = ob.maximumLinks;
        };
        PortModel.prototype.serialize = function () {
          return _.merge(_super.prototype.serialize.call(this), {
            name: this.name,
            parentNode: this.parent.id,
            links: _.map(this.links, function (link) {
              return link.id;
            }),
            maximumLinks: this.maximumLinks,
          });
        };
        PortModel.prototype.doClone = function (lookupTable, clone) {
          if (lookupTable === void 0) {
            lookupTable = {};
          }
          clone.links = {};
          clone.parentNode = this.getParent().clone(lookupTable);
        };
        PortModel.prototype.getNode = function () {
          return this.getParent();
        };
        PortModel.prototype.getName = function () {
          return this.name;
        };
        PortModel.prototype.getMaximumLinks = function () {
          return this.maximumLinks;
        };
        PortModel.prototype.setMaximumLinks = function (maximumLinks) {
          this.maximumLinks = maximumLinks;
        };
        PortModel.prototype.removeLink = function (link) {
          delete this.links[link.getID()];
        };
        PortModel.prototype.addLink = function (link) {
          this.links[link.getID()] = link;
        };
        PortModel.prototype.getLinks = function () {
          return this.links;
        };
        PortModel.prototype.createLinkModel = function () {
          if (_.isFinite(this.maximumLinks)) {
            var numberOfLinks = _.size(this.links);
            if (this.maximumLinks === 1 && numberOfLinks >= 1) {
              return _.values(this.links)[0];
            } else if (numberOfLinks >= this.maximumLinks) {
              return null;
            }
          }
          return null;
        };
        PortModel.prototype.updateCoords = function (_a) {
          var x = _a.x,
            y = _a.y,
            width = _a.width,
            height = _a.height;
          this.x = x;
          this.y = y;
          this.width = width;
          this.height = height;
        };
        PortModel.prototype.canLinkToPort = function (port) {
          return true;
        };
        PortModel.prototype.isLocked = function () {
          return _super.prototype.isLocked.call(this) || this.getParent().isLocked();
        };
        return PortModel;
      })(BaseModel_1.BaseModel);
      exports.PortModel = PortModel;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __assign =
        (this && this.__assign) ||
        Object.assign ||
        function (t) {
          for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
          }
          return t;
        };
      Object.defineProperty(exports, '__esModule', { value: true });
      var Toolkit_1 = __webpack_require__(7);
      var _ = require('lodash');
      var BaseEntity = (function () {
        function BaseEntity(id) {
          this.listeners = {};
          this.id = id || Toolkit_1.Toolkit.UID();
          this.locked = false;
        }

        BaseEntity.prototype.getID = function () {
          return this.id;
        };
        BaseEntity.prototype.doClone = function (lookupTable, clone) {
          if (lookupTable === void 0) {
            lookupTable = {};
          }
        };
        BaseEntity.prototype.clone = function (lookupTable) {
          if (lookupTable === void 0) {
            lookupTable = {};
          }
          if (lookupTable[this.id]) {
            return lookupTable[this.id];
          }
          var clone = _.clone(this);
          clone.id = Toolkit_1.Toolkit.UID();
          clone.clearListeners();
          lookupTable[this.id] = clone;
          this.doClone(lookupTable, clone);
          return clone;
        };
        BaseEntity.prototype.clearListeners = function () {
          this.listeners = {};
        };
        BaseEntity.prototype.deSerialize = function (data, engine) {
          this.id = data.id;
        };
        BaseEntity.prototype.serialize = function () {
          return { id: this.id };
        };
        BaseEntity.prototype.iterateListeners = function (cb) {
          var event = {
            id: Toolkit_1.Toolkit.UID(),
            firing: true,
            entity: this,
            stopPropagation: function () {
              event.firing = false;
            },
          };
          for (var i in this.listeners) {
            if (this.listeners.hasOwnProperty(i)) {
              if (!event.firing) {
                return;
              }
              cb(this.listeners[i], event);
            }
          }
        };
        BaseEntity.prototype.removeListener = function (listener) {
          if (this.listeners[listener]) {
            delete this.listeners[listener];
            return true;
          }
          return false;
        };
        BaseEntity.prototype.addListener = function (listener) {
          var uid = Toolkit_1.Toolkit.UID();
          this.listeners[uid] = listener;
          return uid;
        };
        BaseEntity.prototype.isLocked = function () {
          return this.locked;
        };
        BaseEntity.prototype.setLocked = function (locked) {
          if (locked === void 0) {
            locked = true;
          }
          this.locked = locked;
          this.iterateListeners(function (listener, event) {
            if (listener.lockChanged) {
              listener.lockChanged(__assign({}, event, { locked: locked }));
            }
          });
        };
        return BaseEntity;
      })();
      exports.BaseEntity = BaseEntity;
    },
    function (module, exports, __webpack_require__) {
      var Heap = __webpack_require__(15);
      var Util = __webpack_require__(4);
      var Heuristic = __webpack_require__(10);
      var DiagonalMovement = __webpack_require__(2);

      function JumpPointFinderBase(opt) {
        opt = opt || {};
        this.heuristic = opt.heuristic || Heuristic.manhattan;
        this.trackJumpRecursion = opt.trackJumpRecursion || false;
      }

      JumpPointFinderBase.prototype.findPath = function (startX, startY, endX, endY, grid) {
        var openList = (this.openList = new Heap(function (nodeA, nodeB) {
            return nodeA.f - nodeB.f;
          })),
          startNode = (this.startNode = grid.getNodeAt(startX, startY)),
          endNode = (this.endNode = grid.getNodeAt(endX, endY)),
          node;
        this.grid = grid;
        startNode.g = 0;
        startNode.f = 0;
        openList.push(startNode);
        startNode.opened = true;
        while (!openList.empty()) {
          node = openList.pop();
          node.closed = true;
          if (node === endNode) {
            return Util.expandPath(Util.backtrace(endNode));
          }
          this._identifySuccessors(node);
        }
        return [];
      };
      JumpPointFinderBase.prototype._identifySuccessors = function (node) {
        var grid = this.grid,
          heuristic = this.heuristic,
          openList = this.openList,
          endX = this.endNode.x,
          endY = this.endNode.y,
          neighbors,
          neighbor,
          jumpPoint,
          i,
          l,
          x = node.x,
          y = node.y,
          jx,
          jy,
          dx,
          dy,
          d,
          ng,
          jumpNode,
          abs = Math.abs,
          max = Math.max;
        neighbors = this._findNeighbors(node);
        for (i = 0, l = neighbors.length; i < l; ++i) {
          neighbor = neighbors[i];
          jumpPoint = this._jump(neighbor[0], neighbor[1], x, y);
          if (jumpPoint) {
            jx = jumpPoint[0];
            jy = jumpPoint[1];
            jumpNode = grid.getNodeAt(jx, jy);
            if (jumpNode.closed) {
              continue;
            }
            d = Heuristic.octile(abs(jx - x), abs(jy - y));
            ng = node.g + d;
            if (!jumpNode.opened || ng < jumpNode.g) {
              jumpNode.g = ng;
              jumpNode.h = jumpNode.h || heuristic(abs(jx - endX), abs(jy - endY));
              jumpNode.f = jumpNode.g + jumpNode.h;
              jumpNode.parent = node;
              if (!jumpNode.opened) {
                openList.push(jumpNode);
                jumpNode.opened = true;
              } else {
                openList.updateItem(jumpNode);
              }
            }
          }
        }
      };
      module.exports = JumpPointFinderBase;
    },
    function (module, exports, __webpack_require__) {
      module.exports = __webpack_require__(66);
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      Object.defineProperty(exports, '__esModule', { value: true });
      var PF = __webpack_require__(68);
      exports.ROUTING_SCALING_FACTOR = 5;
      var pathFinderInstance = new PF.JumpPointFinder({
        heuristic: PF.Heuristic.manhattan,
        diagonalMovement: PF.DiagonalMovement.Never,
      });
      var PathFinding = (function () {
        function PathFinding(diagramEngine) {
          this.instance = pathFinderInstance;
          this.diagramEngine = diagramEngine;
        }

        PathFinding.prototype.calculateDirectPath = function (from, to) {
          var matrix = this.diagramEngine.getCanvasMatrix();
          var grid = new PF.Grid(matrix);
          return pathFinderInstance.findPath(
            this.diagramEngine.translateRoutingX(Math.floor(from.x / exports.ROUTING_SCALING_FACTOR)),
            this.diagramEngine.translateRoutingY(Math.floor(from.y / exports.ROUTING_SCALING_FACTOR)),
            this.diagramEngine.translateRoutingX(Math.floor(to.x / exports.ROUTING_SCALING_FACTOR)),
            this.diagramEngine.translateRoutingY(Math.floor(to.y / exports.ROUTING_SCALING_FACTOR)),
            grid
          );
        };
        PathFinding.prototype.calculateLinkStartEndCoords = function (matrix, path) {
          var startIndex = path.findIndex(function (point) {
            return matrix[point[1]][point[0]] === 0;
          });
          var endIndex =
            path.length -
            1 -
            path
              .slice()
              .reverse()
              .findIndex(function (point) {
                return matrix[point[1]][point[0]] === 0;
              });
          if (startIndex === -1 || endIndex === -1) {
            return undefined;
          }
          var pathToStart = path.slice(0, startIndex);
          var pathToEnd = path.slice(endIndex);
          return {
            start: { x: path[startIndex][0], y: path[startIndex][1] },
            end: { x: path[endIndex][0], y: path[endIndex][1] },
            pathToStart: pathToStart,
            pathToEnd: pathToEnd,
          };
        };
        PathFinding.prototype.calculateDynamicPath = function (routingMatrix, start, end, pathToStart, pathToEnd) {
          var _this = this;
          var grid = new PF.Grid(routingMatrix);
          var dynamicPath = pathFinderInstance.findPath(start.x, start.y, end.x, end.y, grid);
          var pathCoords = pathToStart.concat(dynamicPath, pathToEnd).map(function (coords) {
            return [_this.diagramEngine.translateRoutingX(coords[0], true), _this.diagramEngine.translateRoutingY(coords[1], true)];
          });
          return PF.Util.compressPath(pathCoords);
        };
        return PathFinding;
      })();
      exports.default = PathFinding;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      Object.defineProperty(exports, '__esModule', { value: true });
      var BaseModel_1 = __webpack_require__(6);
      var _ = require('lodash');
      var LabelModel = (function (_super) {
        __extends(LabelModel, _super);

        function LabelModel(type, id) {
          var _this = _super.call(this, type, id) || this;
          _this.offsetX = 0;
          _this.offsetY = 0;
          return _this;
        }

        LabelModel.prototype.deSerialize = function (ob, engine) {
          _super.prototype.deSerialize.call(this, ob, engine);
          this.offsetX = ob.offsetX;
          this.offsetY = ob.offsetY;
        };
        LabelModel.prototype.serialize = function () {
          return _.merge(_super.prototype.serialize.call(this), { offsetX: this.offsetX, offsetY: this.offsetY });
        };
        return LabelModel;
      })(BaseModel_1.BaseModel);
      exports.LabelModel = LabelModel;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      Object.defineProperty(exports, '__esModule', { value: true });
      var LabelModel_1 = __webpack_require__(17);
      var _ = require('lodash');
      var DefaultLabelModel = (function (_super) {
        __extends(DefaultLabelModel, _super);

        function DefaultLabelModel() {
          var _this = _super.call(this, 'default') || this;
          _this.offsetY = -23;
          return _this;
        }

        DefaultLabelModel.prototype.setLabel = function (label) {
          this.label = label;
        };
        DefaultLabelModel.prototype.deSerialize = function (ob, engine) {
          _super.prototype.deSerialize.call(this, ob, engine);
          this.label = ob.label;
        };
        DefaultLabelModel.prototype.serialize = function () {
          return _.merge(_super.prototype.serialize.call(this), { label: this.label });
        };
        return DefaultLabelModel;
      })(LabelModel_1.LabelModel);
      exports.DefaultLabelModel = DefaultLabelModel;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      var __assign =
        (this && this.__assign) ||
        Object.assign ||
        function (t) {
          for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
          }
          return t;
        };
      Object.defineProperty(exports, '__esModule', { value: true });
      var LinkModel_1 = __webpack_require__(21);
      var _ = require('lodash');
      var DefaultLabelModel_1 = __webpack_require__(18);
      var LabelModel_1 = __webpack_require__(17);
      var DefaultLinkModel = (function (_super) {
        __extends(DefaultLinkModel, _super);

        function DefaultLinkModel(type) {
          if (type === void 0) {
            type = 'default';
          }
          var _this = _super.call(this, type) || this;
          _this.color = 'rgba(255,255,255,0.5)';
          _this.width = 3;
          _this.curvyness = 50;
          return _this;
        }

        DefaultLinkModel.prototype.serialize = function () {
          return _.merge(_super.prototype.serialize.call(this), {
            width: this.width,
            color: this.color,
            curvyness: this.curvyness,
          });
        };
        DefaultLinkModel.prototype.deSerialize = function (ob, engine) {
          _super.prototype.deSerialize.call(this, ob, engine);
          this.color = ob.color;
          this.width = ob.width;
          this.curvyness = ob.curvyness;
        };
        DefaultLinkModel.prototype.addLabel = function (label) {
          if (label instanceof LabelModel_1.LabelModel) {
            return _super.prototype.addLabel.call(this, label);
          }
          var labelOb = new DefaultLabelModel_1.DefaultLabelModel();
          labelOb.setLabel(label);
          return _super.prototype.addLabel.call(this, labelOb);
        };
        DefaultLinkModel.prototype.setWidth = function (width) {
          this.width = width;
          this.iterateListeners(function (listener, event) {
            if (listener.widthChanged) {
              listener.widthChanged(__assign({}, event, { width: width }));
            }
          });
        };
        DefaultLinkModel.prototype.setColor = function (color) {
          this.color = color;
          this.iterateListeners(function (listener, event) {
            if (listener.colorChanged) {
              listener.colorChanged(__assign({}, event, { color: color }));
            }
          });
        };
        return DefaultLinkModel;
      })(LinkModel_1.LinkModel);
      exports.DefaultLinkModel = DefaultLinkModel;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      Object.defineProperty(exports, '__esModule', { value: true });
      var _ = require('lodash');
      var PortModel_1 = __webpack_require__(12);
      var DefaultLinkModel_1 = __webpack_require__(19);
      var DefaultPortModel = (function (_super) {
        __extends(DefaultPortModel, _super);

        function DefaultPortModel(isInput, name, label, id) {
          if (label === void 0) {
            label = null;
          }
          var _this = _super.call(this, name, 'default', id) || this;
          _this.in = isInput;
          _this.label = label || name;
          return _this;
        }

        DefaultPortModel.prototype.deSerialize = function (object, engine) {
          _super.prototype.deSerialize.call(this, object, engine);
          this.in = object.in;
          this.label = object.label;
        };
        DefaultPortModel.prototype.serialize = function () {
          return _.merge(_super.prototype.serialize.call(this), { in: this.in, label: this.label });
        };
        DefaultPortModel.prototype.link = function (port) {
          var link = this.createLinkModel();
          link.setSourcePort(this);
          link.setTargetPort(port);
          return link;
        };
        DefaultPortModel.prototype.canLinkToPort = function (port) {
          if (port instanceof DefaultPortModel) {
            return this.in !== port.in;
          }
          return true;
        };
        DefaultPortModel.prototype.createLinkModel = function () {
          var link = _super.prototype.createLinkModel.call(this);
          return link || new DefaultLinkModel_1.DefaultLinkModel();
        };
        return DefaultPortModel;
      })(PortModel_1.PortModel);
      exports.DefaultPortModel = DefaultPortModel;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      var __assign =
        (this && this.__assign) ||
        Object.assign ||
        function (t) {
          for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
          }
          return t;
        };
      Object.defineProperty(exports, '__esModule', { value: true });
      var BaseModel_1 = __webpack_require__(6);
      var PointModel_1 = __webpack_require__(5);
      var _ = require('lodash');
      var LinkModel = (function (_super) {
        __extends(LinkModel, _super);

        function LinkModel(linkType, id) {
          if (linkType === void 0) {
            linkType = 'default';
          }
          var _this = _super.call(this, linkType, id) || this;
          _this.points = [
            new PointModel_1.PointModel(_this, { x: 0, y: 0 }),
            new PointModel_1.PointModel(_this, {
              x: 0,
              y: 0,
            }),
          ];
          _this.extras = {};
          _this.sourcePort = null;
          _this.targetPort = null;
          _this.labels = [];
          return _this;
        }

        LinkModel.prototype.deSerialize = function (ob, engine) {
          var _this = this;
          _super.prototype.deSerialize.call(this, ob, engine);
          this.extras = ob.extras;
          this.points = _.map(ob.points || [], function (point) {
            var p = new PointModel_1.PointModel(_this, { x: point.x, y: point.y });
            p.deSerialize(point, engine);
            return p;
          });
          _.forEach(ob.labels || [], function (label) {
            var labelOb = engine.getLabelFactory(label.type).getNewInstance();
            labelOb.deSerialize(label, engine);
            _this.addLabel(labelOb);
          });
          if (ob.target) {
            this.setTargetPort(this.getParent().getNode(ob.target).getPortFromID(ob.targetPort));
          }
          if (ob.source) {
            this.setSourcePort(this.getParent().getNode(ob.source).getPortFromID(ob.sourcePort));
          }
        };
        LinkModel.prototype.serialize = function () {
          return _.merge(_super.prototype.serialize.call(this), {
            source: this.sourcePort ? this.sourcePort.getParent().id : null,
            sourcePort: this.sourcePort ? this.sourcePort.id : null,
            target: this.targetPort ? this.targetPort.getParent().id : null,
            targetPort: this.targetPort ? this.targetPort.id : null,
            points: _.map(this.points, function (point) {
              return point.serialize();
            }),
            extras: this.extras,
            labels: _.map(this.labels, function (label) {
              return label.serialize();
            }),
          });
        };
        LinkModel.prototype.doClone = function (lookupTable, clone) {
          if (lookupTable === void 0) {
            lookupTable = {};
          }
          clone.setPoints(
            _.map(this.getPoints(), function (point) {
              return point.clone(lookupTable);
            })
          );
          if (this.sourcePort) {
            clone.setSourcePort(this.sourcePort.clone(lookupTable));
          }
          if (this.targetPort) {
            clone.setTargetPort(this.targetPort.clone(lookupTable));
          }
        };
        LinkModel.prototype.remove = function () {
          if (this.sourcePort) {
            this.sourcePort.removeLink(this);
          }
          if (this.targetPort) {
            this.targetPort.removeLink(this);
          }
          _super.prototype.remove.call(this);
        };
        LinkModel.prototype.isLastPoint = function (point) {
          var index = this.getPointIndex(point);
          return index === this.points.length - 1;
        };
        LinkModel.prototype.getPointIndex = function (point) {
          return this.points.indexOf(point);
        };
        LinkModel.prototype.getPointModel = function (id) {
          for (var i = 0; i < this.points.length; i++) {
            if (this.points[i].id === id) {
              return this.points[i];
            }
          }
          return null;
        };
        LinkModel.prototype.getPortForPoint = function (point) {
          if (this.sourcePort !== null && this.getFirstPoint().getID() === point.getID()) {
            return this.sourcePort;
          }
          if (this.targetPort !== null && this.getLastPoint().getID() === point.getID()) {
            return this.targetPort;
          }
          return null;
        };
        LinkModel.prototype.getPointForPort = function (port) {
          if (this.sourcePort !== null && this.sourcePort.getID() === port.getID()) {
            return this.getFirstPoint();
          }
          if (this.targetPort !== null && this.targetPort.getID() === port.getID()) {
            return this.getLastPoint();
          }
          return null;
        };
        LinkModel.prototype.getFirstPoint = function () {
          return this.points[0];
        };
        LinkModel.prototype.getLastPoint = function () {
          return this.points[this.points.length - 1];
        };
        LinkModel.prototype.setSourcePort = function (port) {
          if (port !== null) {
            port.addLink(this);
          }
          if (this.sourcePort !== null) {
            this.sourcePort.removeLink(this);
          }
          this.sourcePort = port;
          this.iterateListeners(function (listener, event) {
            if (listener.sourcePortChanged) {
              listener.sourcePortChanged(__assign({}, event, { port: port }));
            }
          });
        };
        LinkModel.prototype.getSourcePort = function () {
          return this.sourcePort;
        };
        LinkModel.prototype.getTargetPort = function () {
          return this.targetPort;
        };
        LinkModel.prototype.setTargetPort = function (port) {
          if (port !== null) {
            port.addLink(this);
          }
          if (this.targetPort !== null) {
            this.targetPort.removeLink(this);
          }
          this.targetPort = port;
          this.iterateListeners(function (listener, event) {
            if (listener.targetPortChanged) {
              listener.targetPortChanged(__assign({}, event, { port: port }));
            }
          });
        };
        LinkModel.prototype.point = function (x, y) {
          return this.addPoint(this.generatePoint(x, y));
        };
        LinkModel.prototype.addLabel = function (label) {
          label.setParent(this);
          this.labels.push(label);
        };
        LinkModel.prototype.getPoints = function () {
          return this.points;
        };
        LinkModel.prototype.setPoints = function (points) {
          var _this = this;
          _.forEach(points, function (point) {
            point.setParent(_this);
          });
          this.points = points;
        };
        LinkModel.prototype.removePoint = function (pointModel) {
          this.points.splice(this.getPointIndex(pointModel), 1);
        };
        LinkModel.prototype.removePointsBefore = function (pointModel) {
          this.points.splice(0, this.getPointIndex(pointModel));
        };
        LinkModel.prototype.removePointsAfter = function (pointModel) {
          this.points.splice(this.getPointIndex(pointModel) + 1);
        };
        LinkModel.prototype.removeMiddlePoints = function () {
          if (this.points.length > 2) {
            this.points.splice(0, this.points.length - 2);
          }
        };
        LinkModel.prototype.addPoint = function (pointModel, index) {
          if (index === void 0) {
            index = 1;
          }
          pointModel.setParent(this);
          this.points.splice(index, 0, pointModel);
          return pointModel;
        };
        LinkModel.prototype.generatePoint = function (x, y) {
          if (x === void 0) {
            x = 0;
          }
          if (y === void 0) {
            y = 0;
          }
          return new PointModel_1.PointModel(this, { x: x, y: y });
        };
        return LinkModel;
      })(BaseModel_1.BaseModel);
      exports.LinkModel = LinkModel;
    },
    function (module, exports, __webpack_require__) {
      var Heap = __webpack_require__(15);
      var Util = __webpack_require__(4);
      var Heuristic = __webpack_require__(10);
      var DiagonalMovement = __webpack_require__(2);

      function BiAStarFinder(opt) {
        opt = opt || {};
        this.allowDiagonal = opt.allowDiagonal;
        this.dontCrossCorners = opt.dontCrossCorners;
        this.diagonalMovement = opt.diagonalMovement;
        this.heuristic = opt.heuristic || Heuristic.manhattan;
        this.weight = opt.weight || 1;
        if (!this.diagonalMovement) {
          if (!this.allowDiagonal) {
            this.diagonalMovement = DiagonalMovement.Never;
          } else {
            if (this.dontCrossCorners) {
              this.diagonalMovement = DiagonalMovement.OnlyWhenNoObstacles;
            } else {
              this.diagonalMovement = DiagonalMovement.IfAtMostOneObstacle;
            }
          }
        }
        if (this.diagonalMovement === DiagonalMovement.Never) {
          this.heuristic = opt.heuristic || Heuristic.manhattan;
        } else {
          this.heuristic = opt.heuristic || Heuristic.octile;
        }
      }

      BiAStarFinder.prototype.findPath = function (startX, startY, endX, endY, grid) {
        var cmp = function (nodeA, nodeB) {
            return nodeA.f - nodeB.f;
          },
          startOpenList = new Heap(cmp),
          endOpenList = new Heap(cmp),
          startNode = grid.getNodeAt(startX, startY),
          endNode = grid.getNodeAt(endX, endY),
          heuristic = this.heuristic,
          diagonalMovement = this.diagonalMovement,
          weight = this.weight,
          abs = Math.abs,
          SQRT2 = Math.SQRT2,
          node,
          neighbors,
          neighbor,
          i,
          l,
          x,
          y,
          ng,
          BY_START = 1,
          BY_END = 2;
        startNode.g = 0;
        startNode.f = 0;
        startOpenList.push(startNode);
        startNode.opened = BY_START;
        endNode.g = 0;
        endNode.f = 0;
        endOpenList.push(endNode);
        endNode.opened = BY_END;
        while (!startOpenList.empty() && !endOpenList.empty()) {
          node = startOpenList.pop();
          node.closed = true;
          neighbors = grid.getNeighbors(node, diagonalMovement);
          for (i = 0, l = neighbors.length; i < l; ++i) {
            neighbor = neighbors[i];
            if (neighbor.closed) {
              continue;
            }
            if (neighbor.opened === BY_END) {
              return Util.biBacktrace(node, neighbor);
            }
            x = neighbor.x;
            y = neighbor.y;
            ng = node.g + (x - node.x === 0 || y - node.y === 0 ? 1 : SQRT2);
            if (!neighbor.opened || ng < neighbor.g) {
              neighbor.g = ng;
              neighbor.h = neighbor.h || weight * heuristic(abs(x - endX), abs(y - endY));
              neighbor.f = neighbor.g + neighbor.h;
              neighbor.parent = node;
              if (!neighbor.opened) {
                startOpenList.push(neighbor);
                neighbor.opened = BY_START;
              } else {
                startOpenList.updateItem(neighbor);
              }
            }
          }
          node = endOpenList.pop();
          node.closed = true;
          neighbors = grid.getNeighbors(node, diagonalMovement);
          for (i = 0, l = neighbors.length; i < l; ++i) {
            neighbor = neighbors[i];
            if (neighbor.closed) {
              continue;
            }
            if (neighbor.opened === BY_START) {
              return Util.biBacktrace(neighbor, node);
            }
            x = neighbor.x;
            y = neighbor.y;
            ng = node.g + (x - node.x === 0 || y - node.y === 0 ? 1 : SQRT2);
            if (!neighbor.opened || ng < neighbor.g) {
              neighbor.g = ng;
              neighbor.h = neighbor.h || weight * heuristic(abs(x - startX), abs(y - startY));
              neighbor.f = neighbor.g + neighbor.h;
              neighbor.parent = node;
              if (!neighbor.opened) {
                endOpenList.push(neighbor);
                neighbor.opened = BY_END;
              } else {
                endOpenList.updateItem(neighbor);
              }
            }
          }
        }
        return [];
      };
      module.exports = BiAStarFinder;
    },
    function (module, exports, __webpack_require__) {
      var Heap = __webpack_require__(15);
      var Util = __webpack_require__(4);
      var Heuristic = __webpack_require__(10);
      var DiagonalMovement = __webpack_require__(2);

      function AStarFinder(opt) {
        opt = opt || {};
        this.allowDiagonal = opt.allowDiagonal;
        this.dontCrossCorners = opt.dontCrossCorners;
        this.heuristic = opt.heuristic || Heuristic.manhattan;
        this.weight = opt.weight || 1;
        this.diagonalMovement = opt.diagonalMovement;
        if (!this.diagonalMovement) {
          if (!this.allowDiagonal) {
            this.diagonalMovement = DiagonalMovement.Never;
          } else {
            if (this.dontCrossCorners) {
              this.diagonalMovement = DiagonalMovement.OnlyWhenNoObstacles;
            } else {
              this.diagonalMovement = DiagonalMovement.IfAtMostOneObstacle;
            }
          }
        }
        if (this.diagonalMovement === DiagonalMovement.Never) {
          this.heuristic = opt.heuristic || Heuristic.manhattan;
        } else {
          this.heuristic = opt.heuristic || Heuristic.octile;
        }
      }

      AStarFinder.prototype.findPath = function (startX, startY, endX, endY, grid) {
        var openList = new Heap(function (nodeA, nodeB) {
            return nodeA.f - nodeB.f;
          }),
          startNode = grid.getNodeAt(startX, startY),
          endNode = grid.getNodeAt(endX, endY),
          heuristic = this.heuristic,
          diagonalMovement = this.diagonalMovement,
          weight = this.weight,
          abs = Math.abs,
          SQRT2 = Math.SQRT2,
          node,
          neighbors,
          neighbor,
          i,
          l,
          x,
          y,
          ng;
        startNode.g = 0;
        startNode.f = 0;
        openList.push(startNode);
        startNode.opened = true;
        while (!openList.empty()) {
          node = openList.pop();
          node.closed = true;
          if (node === endNode) {
            return Util.backtrace(endNode);
          }
          neighbors = grid.getNeighbors(node, diagonalMovement);
          for (i = 0, l = neighbors.length; i < l; ++i) {
            neighbor = neighbors[i];
            if (neighbor.closed) {
              continue;
            }
            x = neighbor.x;
            y = neighbor.y;
            ng = node.g + (x - node.x === 0 || y - node.y === 0 ? 1 : SQRT2);
            if (!neighbor.opened || ng < neighbor.g) {
              neighbor.g = ng;
              neighbor.h = neighbor.h || weight * heuristic(abs(x - endX), abs(y - endY));
              neighbor.f = neighbor.g + neighbor.h;
              neighbor.parent = node;
              if (!neighbor.opened) {
                openList.push(neighbor);
                neighbor.opened = true;
              } else {
                openList.updateItem(neighbor);
              }
            }
          }
        }
        return [];
      };
      module.exports = AStarFinder;
    },
    function (module, exports) {
      function Node(x, y, walkable) {
        this.x = x;
        this.y = y;
        this.walkable = walkable === undefined ? true : walkable;
      }

      module.exports = Node;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      var __assign =
        (this && this.__assign) ||
        Object.assign ||
        function (t) {
          for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
          }
          return t;
        };
      Object.defineProperty(exports, '__esModule', { value: true });
      var React = __webpack_require__(1);
      var BaseWidget_1 = __webpack_require__(3);
      var NodeWidget = (function (_super) {
        __extends(NodeWidget, _super);

        function NodeWidget(props) {
          var _this = _super.call(this, 'srd-node', props) || this;
          _this.state = {};
          return _this;
        }

        NodeWidget.prototype.shouldComponentUpdate = function () {
          return this.props.diagramEngine.canEntityRepaint(this.props.node);
        };
        NodeWidget.prototype.getClassName = function () {
          return 'node ' + _super.prototype.getClassName.call(this) + (this.props.node.isSelected() ? this.bem('--selected') : '');
        };
        NodeWidget.prototype.render = function () {
          return React.createElement(
            'div',
            __assign({}, this.getProps(), {
              'data-nodeid': this.props.node.id,
              style: { top: this.props.node.y, left: this.props.node.x },
            }),
            this.props.children
          );
        };
        return NodeWidget;
      })(BaseWidget_1.BaseWidget);
      exports.NodeWidget = NodeWidget;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      var __assign =
        (this && this.__assign) ||
        Object.assign ||
        function (t) {
          for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
          }
          return t;
        };
      Object.defineProperty(exports, '__esModule', { value: true });
      var React = __webpack_require__(1);
      var _ = require('lodash');
      var NodeWidget_1 = __webpack_require__(25);
      var BaseWidget_1 = __webpack_require__(3);
      var NodeLayerWidget = (function (_super) {
        __extends(NodeLayerWidget, _super);

        function NodeLayerWidget(props) {
          var _this = _super.call(this, 'srd-node-layer', props) || this;
          _this.updateNodeDimensions = function () {
            if (!_this.props.diagramEngine.nodesRendered) {
              var diagramModel = _this.props.diagramEngine.getDiagramModel();
              _.map(diagramModel.getNodes(), function (node) {
                node.updateDimensions(_this.props.diagramEngine.getNodeDimensions(node));
              });
            }
          };
          _this.state = {};
          return _this;
        }

        NodeLayerWidget.prototype.componentDidUpdate = function () {
          this.updateNodeDimensions();
          this.props.diagramEngine.nodesRendered = true;
        };
        NodeLayerWidget.prototype.render = function () {
          var _this = this;
          var diagramModel = this.props.diagramEngine.getDiagramModel();
          return React.createElement(
            'div',
            __assign({}, this.getProps(), {
              style: {
                transform:
                  'translate(' + diagramModel.getOffsetX() + 'px,' + diagramModel.getOffsetY() + 'px) scale(' + diagramModel.getZoomLevel() / 100 + ')',
              },
            }),
            _.map(diagramModel.getNodes(), function (node) {
              return React.createElement(
                NodeWidget_1.NodeWidget,
                {
                  diagramEngine: _this.props.diagramEngine,
                  key: node.id,
                  node: node,
                },
                _this.props.diagramEngine.generateWidgetForNode(node)
              );
            })
          );
        };
        return NodeLayerWidget;
      })(BaseWidget_1.BaseWidget);
      exports.NodeLayerWidget = NodeLayerWidget;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      Object.defineProperty(exports, '__esModule', { value: true });
      var BaseWidget_1 = __webpack_require__(3);
      var LinkWidget = (function (_super) {
        __extends(LinkWidget, _super);

        function LinkWidget(props) {
          var _this = _super.call(this, 'srd-link', props) || this;
          _this.state = {};
          return _this;
        }

        LinkWidget.prototype.shouldComponentUpdate = function () {
          return this.props.diagramEngine.canEntityRepaint(this.props.link);
        };
        LinkWidget.prototype.render = function () {
          return this.props.children;
        };
        return LinkWidget;
      })(BaseWidget_1.BaseWidget);
      exports.LinkWidget = LinkWidget;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      var __assign =
        (this && this.__assign) ||
        Object.assign ||
        function (t) {
          for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
          }
          return t;
        };
      Object.defineProperty(exports, '__esModule', { value: true });
      var React = __webpack_require__(1);
      var LinkWidget_1 = __webpack_require__(27);
      var _ = require('lodash');
      var BaseWidget_1 = __webpack_require__(3);
      var LinkLayerWidget = (function (_super) {
        __extends(LinkLayerWidget, _super);

        function LinkLayerWidget(props) {
          var _this = _super.call(this, 'srd-link-layer', props) || this;
          _this.state = {};
          return _this;
        }

        LinkLayerWidget.prototype.render = function () {
          var _this = this;
          var diagramModel = this.props.diagramEngine.getDiagramModel();
          return React.createElement(
            'svg',
            __assign({}, this.getProps(), {
              style: {
                transform:
                  'translate(' + diagramModel.getOffsetX() + 'px,' + diagramModel.getOffsetY() + 'px) scale(' + diagramModel.getZoomLevel() / 100 + ')',
              },
            }),
            this.props.diagramEngine.canvas &&
              _.map(diagramModel.getLinks(), function (link) {
                if (_this.props.diagramEngine.nodesRendered && !_this.props.diagramEngine.linksThatHaveInitiallyRendered[link.id]) {
                  if (link.sourcePort !== null) {
                    try {
                      var portCenter = _this.props.diagramEngine.getPortCenter(link.sourcePort);
                      link.points[0].updateLocation(portCenter);
                      var portCoords = _this.props.diagramEngine.getPortCoords(link.sourcePort);
                      link.sourcePort.updateCoords(portCoords);
                      _this.props.diagramEngine.linksThatHaveInitiallyRendered[link.id] = true;
                    } catch (ignore) {}
                  }
                  if (link.targetPort !== null) {
                    try {
                      var portCenter = _this.props.diagramEngine.getPortCenter(link.targetPort);
                      _.last(link.points).updateLocation(portCenter);
                      var portCoords = _this.props.diagramEngine.getPortCoords(link.targetPort);
                      link.targetPort.updateCoords(portCoords);
                      _this.props.diagramEngine.linksThatHaveInitiallyRendered[link.id] = true;
                    } catch (ignore) {}
                  }
                }
                var generatedLink = _this.props.diagramEngine.generateWidgetForLink(link);
                if (!generatedLink) {
                  throw new Error('no link generated for type: ' + link.getType());
                }
                return React.createElement(
                  LinkWidget_1.LinkWidget,
                  {
                    key: link.getID(),
                    link: link,
                    diagramEngine: _this.props.diagramEngine,
                  },
                  React.cloneElement(generatedLink, { pointAdded: _this.props.pointAdded })
                );
              })
          );
        };
        return LinkLayerWidget;
      })(BaseWidget_1.BaseWidget);
      exports.LinkLayerWidget = LinkLayerWidget;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      Object.defineProperty(exports, '__esModule', { value: true });
      var BaseAction_1 = __webpack_require__(11);
      var SelectingAction = (function (_super) {
        __extends(SelectingAction, _super);

        function SelectingAction(mouseX, mouseY) {
          var _this = _super.call(this, mouseX, mouseY) || this;
          _this.mouseX2 = mouseX;
          _this.mouseY2 = mouseY;
          return _this;
        }

        SelectingAction.prototype.getBoxDimensions = function () {
          return {
            left: this.mouseX2 > this.mouseX ? this.mouseX : this.mouseX2,
            top: this.mouseY2 > this.mouseY ? this.mouseY : this.mouseY2,
            width: Math.abs(this.mouseX2 - this.mouseX),
            height: Math.abs(this.mouseY2 - this.mouseY),
            right: this.mouseX2 < this.mouseX ? this.mouseX : this.mouseX2,
            bottom: this.mouseY2 < this.mouseY ? this.mouseY : this.mouseY2,
          };
        };
        SelectingAction.prototype.containsElement = function (x, y, diagramModel) {
          var z = diagramModel.getZoomLevel() / 100;
          var dimensions = this.getBoxDimensions();
          return (
            x * z + diagramModel.getOffsetX() > dimensions.left &&
            x * z + diagramModel.getOffsetX() < dimensions.right &&
            y * z + diagramModel.getOffsetY() > dimensions.top &&
            y * z + diagramModel.getOffsetY() < dimensions.bottom
          );
        };
        return SelectingAction;
      })(BaseAction_1.BaseAction);
      exports.SelectingAction = SelectingAction;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      Object.defineProperty(exports, '__esModule', { value: true });
      var BaseAction_1 = __webpack_require__(11);
      var MoveItemsAction = (function (_super) {
        __extends(MoveItemsAction, _super);

        function MoveItemsAction(mouseX, mouseY, diagramEngine) {
          var _this = _super.call(this, mouseX, mouseY) || this;
          _this.moved = false;
          diagramEngine.enableRepaintEntities(diagramEngine.getDiagramModel().getSelectedItems());
          var selectedItems = diagramEngine.getDiagramModel().getSelectedItems();
          selectedItems = selectedItems.filter(function (item) {
            return !diagramEngine.isModelLocked(item);
          });
          _this.selectionModels = selectedItems.map(function (item) {
            return { model: item, initialX: item.x, initialY: item.y };
          });
          return _this;
        }

        return MoveItemsAction;
      })(BaseAction_1.BaseAction);
      exports.MoveItemsAction = MoveItemsAction;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      Object.defineProperty(exports, '__esModule', { value: true });
      var BaseAction_1 = __webpack_require__(11);
      var MoveCanvasAction = (function (_super) {
        __extends(MoveCanvasAction, _super);

        function MoveCanvasAction(mouseX, mouseY, diagramModel) {
          var _this = _super.call(this, mouseX, mouseY) || this;
          _this.initialOffsetX = diagramModel.getOffsetX();
          _this.initialOffsetY = diagramModel.getOffsetY();
          return _this;
        }

        return MoveCanvasAction;
      })(BaseAction_1.BaseAction);
      exports.MoveCanvasAction = MoveCanvasAction;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      Object.defineProperty(exports, '__esModule', { value: true });
      var AbstractFactory_1 = __webpack_require__(8);
      var AbstractNodeFactory = (function (_super) {
        __extends(AbstractNodeFactory, _super);

        function AbstractNodeFactory() {
          return (_super !== null && _super.apply(this, arguments)) || this;
        }

        return AbstractNodeFactory;
      })(AbstractFactory_1.AbstractFactory);
      exports.AbstractNodeFactory = AbstractNodeFactory;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      var __assign =
        (this && this.__assign) ||
        Object.assign ||
        function (t) {
          for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
          }
          return t;
        };
      Object.defineProperty(exports, '__esModule', { value: true });
      var React = __webpack_require__(1);
      var BaseWidget_1 = __webpack_require__(3);
      var PortWidget = (function (_super) {
        __extends(PortWidget, _super);

        function PortWidget(props) {
          var _this = _super.call(this, 'srd-port', props) || this;
          _this.state = { selected: false };
          return _this;
        }

        PortWidget.prototype.getClassName = function () {
          return 'port ' + _super.prototype.getClassName.call(this) + (this.state.selected ? this.bem('--selected') : '');
        };
        PortWidget.prototype.render = function () {
          var _this = this;
          return React.createElement(
            'div',
            __assign({}, this.getProps(), {
              onMouseEnter: function () {
                _this.setState({ selected: true });
              },
              onMouseLeave: function () {
                _this.setState({ selected: false });
              },
              'data-name': this.props.name,
              'data-nodeid': this.props.node.getID(),
            })
          );
        };
        return PortWidget;
      })(BaseWidget_1.BaseWidget);
      exports.PortWidget = PortWidget;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      var __assign =
        (this && this.__assign) ||
        Object.assign ||
        function (t) {
          for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
          }
          return t;
        };
      Object.defineProperty(exports, '__esModule', { value: true });
      var React = __webpack_require__(1);
      var PortWidget_1 = __webpack_require__(33);
      var BaseWidget_1 = __webpack_require__(3);
      var DefaultPortLabel = (function (_super) {
        __extends(DefaultPortLabel, _super);

        function DefaultPortLabel(props) {
          return _super.call(this, 'srd-default-port', props) || this;
        }

        DefaultPortLabel.prototype.getClassName = function () {
          return _super.prototype.getClassName.call(this) + (this.props.model.in ? this.bem('--in') : this.bem('--out'));
        };
        DefaultPortLabel.prototype.render = function () {
          var port = React.createElement(PortWidget_1.PortWidget, {
            node: this.props.model.getParent(),
            name: this.props.model.name,
          });
          var label = React.createElement('div', { className: 'name' }, this.props.model.label);
          return React.createElement('div', __assign({}, this.getProps()), this.props.model.in ? port : label, this.props.model.in ? label : port);
        };
        return DefaultPortLabel;
      })(BaseWidget_1.BaseWidget);
      exports.DefaultPortLabel = DefaultPortLabel;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      var __assign =
        (this && this.__assign) ||
        Object.assign ||
        function (t) {
          for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
          }
          return t;
        };
      Object.defineProperty(exports, '__esModule', { value: true });
      var React = __webpack_require__(1);
      var _ = require('lodash');
      var DefaultPortLabelWidget_1 = __webpack_require__(34);
      var BaseWidget_1 = __webpack_require__(3);
      var DefaultNodeWidget = (function (_super) {
        __extends(DefaultNodeWidget, _super);

        function DefaultNodeWidget(props) {
          var _this = _super.call(this, 'srd-default-node', props) || this;
          _this.state = {};
          return _this;
        }

        DefaultNodeWidget.prototype.generatePort = function (port) {
          return React.createElement(DefaultPortLabelWidget_1.DefaultPortLabel, { model: port, key: port.id });
        };
        DefaultNodeWidget.prototype.render = function () {
          return React.createElement(
            'div',
            __assign({}, this.getProps(), { style: { background: this.props.node.color } }),
            React.createElement('div', { className: this.bem('__title') }, React.createElement('div', { className: this.bem('__name') }, this.props.node.name)),
            React.createElement(
              'div',
              { className: this.bem('__ports') },
              React.createElement('div', { className: this.bem('__in') }, _.map(this.props.node.getInPorts(), this.generatePort.bind(this))),
              React.createElement('div', { className: this.bem('__out') }, _.map(this.props.node.getOutPorts(), this.generatePort.bind(this)))
            )
          );
        };
        return DefaultNodeWidget;
      })(BaseWidget_1.BaseWidget);
      exports.DefaultNodeWidget = DefaultNodeWidget;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      Object.defineProperty(exports, '__esModule', { value: true });
      var AbstractFactory_1 = __webpack_require__(8);
      var AbstractLinkFactory = (function (_super) {
        __extends(AbstractLinkFactory, _super);

        function AbstractLinkFactory() {
          return (_super !== null && _super.apply(this, arguments)) || this;
        }

        return AbstractLinkFactory;
      })(AbstractFactory_1.AbstractFactory);
      exports.AbstractLinkFactory = AbstractLinkFactory;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      var __assign =
        (this && this.__assign) ||
        Object.assign ||
        function (t) {
          for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
          }
          return t;
        };
      Object.defineProperty(exports, '__esModule', { value: true });
      var React = __webpack_require__(1);
      var PointModel_1 = __webpack_require__(5);
      var Toolkit_1 = __webpack_require__(7);
      var PathFinding_1 = __webpack_require__(16);
      var _ = require('lodash');
      var BaseWidget_1 = __webpack_require__(3);
      var DefaultLinkWidget = (function (_super) {
        __extends(DefaultLinkWidget, _super);

        function DefaultLinkWidget(props) {
          var _this = _super.call(this, 'srd-default-link', props) || this;
          _this.addPointToLink = function (event, index) {
            if (
              !event.shiftKey &&
              !_this.props.diagramEngine.isModelLocked(_this.props.link) &&
              _this.props.link.points.length - 1 <= _this.props.diagramEngine.getMaxNumberPointsPerLink()
            ) {
              var point = new PointModel_1.PointModel(_this.props.link, _this.props.diagramEngine.getRelativeMousePoint(event));
              point.setSelected(true);
              _this.forceUpdate();
              _this.props.link.addPoint(point, index);
              _this.props.pointAdded(point, event);
            }
          };
          _this.findPathAndRelativePositionToRenderLabel = function (index) {
            var lengths = _this.refPaths.map(function (path) {
              return path.getTotalLength();
            });
            var labelPosition =
              lengths.reduce(function (previousValue, currentValue) {
                return previousValue + currentValue;
              }, 0) *
              (index / (_this.props.link.labels.length + 1));
            var pathIndex = 0;
            while (pathIndex < _this.refPaths.length) {
              if (labelPosition - lengths[pathIndex] < 0) {
                return { path: _this.refPaths[pathIndex], position: labelPosition };
              }
              labelPosition -= lengths[pathIndex];
              pathIndex++;
            }
          };
          _this.calculateLabelPosition = function (label, index) {
            if (!_this.refLabels[label.id]) {
              return;
            }
            var _a = _this.findPathAndRelativePositionToRenderLabel(index),
              path = _a.path,
              position = _a.position;
            var labelDimensions = {
              width: _this.refLabels[label.id].offsetWidth,
              height: _this.refLabels[label.id].offsetHeight,
            };
            var pathCentre = path.getPointAtLength(position);
            var labelCoordinates = {
              x: pathCentre.x - labelDimensions.width / 2 + label.offsetX,
              y: pathCentre.y - labelDimensions.height / 2 + label.offsetY,
            };
            _this.refLabels[label.id].setAttribute('style', 'transform: translate(' + labelCoordinates.x + 'px, ' + labelCoordinates.y + 'px);');
          };
          _this.refLabels = {};
          _this.refPaths = [];
          _this.state = { selected: false };
          if (props.diagramEngine.isSmartRoutingEnabled()) {
            _this.pathFinding = new PathFinding_1.default(_this.props.diagramEngine);
          }
          return _this;
        }

        DefaultLinkWidget.prototype.calculateAllLabelPosition = function () {
          var _this = this;
          _.forEach(this.props.link.labels, function (label, index) {
            _this.calculateLabelPosition(label, index + 1);
          });
        };
        DefaultLinkWidget.prototype.componentDidUpdate = function () {
          if (this.props.link.labels.length > 0) {
            window.requestAnimationFrame(this.calculateAllLabelPosition.bind(this));
          }
        };
        DefaultLinkWidget.prototype.componentDidMount = function () {
          if (this.props.link.labels.length > 0) {
            window.requestAnimationFrame(this.calculateAllLabelPosition.bind(this));
          }
        };
        DefaultLinkWidget.prototype.generatePoint = function (pointIndex) {
          var _this = this;
          var x = this.props.link.points[pointIndex].x;
          var y = this.props.link.points[pointIndex].y;
          return React.createElement(
            'g',
            { key: 'point-' + this.props.link.points[pointIndex].id },
            React.createElement('circle', {
              cx: x,
              cy: y,
              r: 5,
              className: 'point ' + this.bem('__point') + (this.props.link.points[pointIndex].isSelected() ? this.bem('--point-selected') : ''),
            }),
            React.createElement('circle', {
              onMouseLeave: function () {
                _this.setState({ selected: false });
              },
              onMouseEnter: function () {
                _this.setState({ selected: true });
              },
              'data-id': this.props.link.points[pointIndex].id,
              'data-linkid': this.props.link.id,
              cx: x,
              cy: y,
              r: 15,
              opacity: 0,
              className: 'point ' + this.bem('__point'),
            })
          );
        };
        DefaultLinkWidget.prototype.generateLabel = function (label) {
          var _this = this;
          var canvas = this.props.diagramEngine.canvas;
          return React.createElement(
            'foreignObject',
            {
              key: label.id,
              className: this.bem('__label'),
              width: canvas.offsetWidth,
              height: canvas.offsetHeight,
            },
            React.createElement(
              'div',
              {
                ref: function (ref) {
                  return (_this.refLabels[label.id] = ref);
                },
              },
              this.props.diagramEngine.getFactoryForLabel(label).generateReactWidget(this.props.diagramEngine, label)
            )
          );
        };
        DefaultLinkWidget.prototype.generateLink = function (path, extraProps, id) {
          var _this = this;
          var props = this.props;
          var Bottom = React.cloneElement(
            props.diagramEngine
              .getFactoryForLink(this.props.link)
              .generateLinkSegment(this.props.link, this, this.state.selected || this.props.link.isSelected(), path),
            {
              ref: function (ref) {
                return ref && _this.refPaths.push(ref);
              },
            }
          );
          var Top = React.cloneElement(
            Bottom,
            __assign({}, extraProps, {
              strokeLinecap: 'round',
              onMouseLeave: function () {
                _this.setState({ selected: false });
              },
              onMouseEnter: function () {
                _this.setState({ selected: true });
              },
              ref: null,
              'data-linkid': this.props.link.getID(),
              strokeOpacity: this.state.selected ? 0.1 : 0,
              strokeWidth: 20,
              onContextMenu: function () {
                if (!_this.props.diagramEngine.isModelLocked(_this.props.link)) {
                  event.preventDefault();
                  _this.props.link.remove();
                }
              },
            })
          );
          return React.createElement('g', { key: 'link-' + id }, Bottom, Top);
        };
        DefaultLinkWidget.prototype.isSmartRoutingApplicable = function () {
          var _a = this.props,
            diagramEngine = _a.diagramEngine,
            link = _a.link;
          if (!diagramEngine.isSmartRoutingEnabled()) {
            return false;
          }
          if (link.points.length !== 2) {
            return false;
          }
          if (link.sourcePort === null || link.targetPort === null) {
            return false;
          }
          return true;
        };
        DefaultLinkWidget.prototype.render = function () {
          var _this = this;
          var diagramEngine = this.props.diagramEngine;
          if (!diagramEngine.nodesRendered) {
            return null;
          }
          var points = this.props.link.points;
          var paths = [];
          if (this.isSmartRoutingApplicable()) {
            var directPathCoords = this.pathFinding.calculateDirectPath(_.first(points), _.last(points));
            var routingMatrix = diagramEngine.getRoutingMatrix();
            var smartLink = this.pathFinding.calculateLinkStartEndCoords(routingMatrix, directPathCoords);
            if (smartLink) {
              var start = smartLink.start,
                end = smartLink.end,
                pathToStart = smartLink.pathToStart,
                pathToEnd = smartLink.pathToEnd;
              var simplifiedPath = this.pathFinding.calculateDynamicPath(routingMatrix, start, end, pathToStart, pathToEnd);
              paths.push(
                this.generateLink(
                  Toolkit_1.Toolkit.generateDynamicPath(simplifiedPath),
                  {
                    onMouseDown: function (event) {
                      _this.addPointToLink(event, 1);
                    },
                  },
                  '0'
                )
              );
            }
          }
          if (paths.length === 0) {
            if (points.length === 2) {
              var isHorizontal = Math.abs(points[0].x - points[1].x) > Math.abs(points[0].y - points[1].y);
              var xOrY = isHorizontal ? 'x' : 'y';
              var margin = 50;
              if (Math.abs(points[0][xOrY] - points[1][xOrY]) < 50) {
                margin = 5;
              }
              var pointLeft = points[0];
              var pointRight = points[1];
              if (pointLeft[xOrY] > pointRight[xOrY]) {
                pointLeft = points[1];
                pointRight = points[0];
              }
              paths.push(
                this.generateLink(
                  Toolkit_1.Toolkit.generateCurvePath(pointLeft, pointRight, this.props.link.curvyness),
                  {
                    onMouseDown: function (event) {
                      _this.addPointToLink(event, 1);
                    },
                  },
                  '0'
                )
              );
              if (this.props.link.targetPort === null) {
                paths.push(this.generatePoint(1));
              }
            } else {
              var _loop_1 = function (j) {
                paths.push(
                  this_1.generateLink(
                    Toolkit_1.Toolkit.generateLinePath(points[j], points[j + 1]),
                    {
                      'data-linkid': this_1.props.link.id,
                      'data-point': j,
                      onMouseDown: function (event) {
                        _this.addPointToLink(event, j + 1);
                      },
                    },
                    j
                  )
                );
              };
              var this_1 = this;
              for (var j = 0; j < points.length - 1; j++) {
                _loop_1(j);
              }
              for (var i = 1; i < points.length - 1; i++) {
                paths.push(this.generatePoint(i));
              }
              if (this.props.link.targetPort === null) {
                paths.push(this.generatePoint(points.length - 1));
              }
            }
          }
          this.refPaths = [];
          return React.createElement(
            'g',
            __assign({}, this.getProps()),
            paths,
            _.map(this.props.link.labels, function (labelModel) {
              return _this.generateLabel(labelModel);
            })
          );
        };
        DefaultLinkWidget.defaultProps = {
          color: 'black',
          width: 3,
          link: null,
          engine: null,
          smooth: false,
          diagramEngine: null,
        };
        return DefaultLinkWidget;
      })(BaseWidget_1.BaseWidget);
      exports.DefaultLinkWidget = DefaultLinkWidget;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      Object.defineProperty(exports, '__esModule', { value: true });
      var DefaultPortModel_1 = __webpack_require__(20);
      var _ = require('lodash');
      var NodeModel_1 = __webpack_require__(9);
      var Toolkit_1 = __webpack_require__(7);
      var DefaultNodeModel = (function (_super) {
        __extends(DefaultNodeModel, _super);

        function DefaultNodeModel(name, color) {
          if (name === void 0) {
            name = 'Untitled';
          }
          if (color === void 0) {
            color = 'rgb(0,192,255)';
          }
          var _this = _super.call(this, 'default') || this;
          _this.name = name;
          _this.color = color;
          return _this;
        }

        DefaultNodeModel.prototype.addInPort = function (label) {
          return this.addPort(new DefaultPortModel_1.DefaultPortModel(true, Toolkit_1.Toolkit.UID(), label));
        };
        DefaultNodeModel.prototype.addOutPort = function (label) {
          return this.addPort(new DefaultPortModel_1.DefaultPortModel(false, Toolkit_1.Toolkit.UID(), label));
        };
        DefaultNodeModel.prototype.deSerialize = function (object, engine) {
          _super.prototype.deSerialize.call(this, object, engine);
          this.name = object.name;
          this.color = object.color;
        };
        DefaultNodeModel.prototype.serialize = function () {
          return _.merge(_super.prototype.serialize.call(this), { name: this.name, color: this.color });
        };
        DefaultNodeModel.prototype.getInPorts = function () {
          return _.filter(this.ports, function (portModel) {
            return portModel.in;
          });
        };
        DefaultNodeModel.prototype.getOutPorts = function () {
          return _.filter(this.ports, function (portModel) {
            return !portModel.in;
          });
        };
        return DefaultNodeModel;
      })(NodeModel_1.NodeModel);
      exports.DefaultNodeModel = DefaultNodeModel;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      var __assign =
        (this && this.__assign) ||
        Object.assign ||
        function (t) {
          for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
          }
          return t;
        };
      Object.defineProperty(exports, '__esModule', { value: true });
      var React = __webpack_require__(1);
      var BaseWidget_1 = __webpack_require__(3);
      var DefaultLabelWidget = (function (_super) {
        __extends(DefaultLabelWidget, _super);

        function DefaultLabelWidget(props) {
          return _super.call(this, 'srd-default-label', props) || this;
        }

        DefaultLabelWidget.prototype.render = function () {
          return React.createElement('div', __assign({}, this.getProps()), this.props.model.label);
        };
        return DefaultLabelWidget;
      })(BaseWidget_1.BaseWidget);
      exports.DefaultLabelWidget = DefaultLabelWidget;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      Object.defineProperty(exports, '__esModule', { value: true });
      var AbstractFactory_1 = __webpack_require__(8);
      var AbstractLabelFactory = (function (_super) {
        __extends(AbstractLabelFactory, _super);

        function AbstractLabelFactory() {
          return (_super !== null && _super.apply(this, arguments)) || this;
        }

        return AbstractLabelFactory;
      })(AbstractFactory_1.AbstractFactory);
      exports.AbstractLabelFactory = AbstractLabelFactory;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      Object.defineProperty(exports, '__esModule', { value: true });
      var React = __webpack_require__(1);
      var AbstractLabelFactory_1 = __webpack_require__(40);
      var DefaultLabelModel_1 = __webpack_require__(18);
      var DefaultLabelWidget_1 = __webpack_require__(39);
      var DefaultLabelFactory = (function (_super) {
        __extends(DefaultLabelFactory, _super);

        function DefaultLabelFactory() {
          return _super.call(this, 'default') || this;
        }

        DefaultLabelFactory.prototype.generateReactWidget = function (diagramEngine, label) {
          return React.createElement(DefaultLabelWidget_1.DefaultLabelWidget, { model: label });
        };
        DefaultLabelFactory.prototype.getNewInstance = function (initialConfig) {
          return new DefaultLabelModel_1.DefaultLabelModel();
        };
        return DefaultLabelFactory;
      })(AbstractLabelFactory_1.AbstractLabelFactory);
      exports.DefaultLabelFactory = DefaultLabelFactory;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      Object.defineProperty(exports, '__esModule', { value: true });
      var AbstractFactory_1 = __webpack_require__(8);
      var AbstractPortFactory = (function (_super) {
        __extends(AbstractPortFactory, _super);

        function AbstractPortFactory() {
          return (_super !== null && _super.apply(this, arguments)) || this;
        }

        return AbstractPortFactory;
      })(AbstractFactory_1.AbstractFactory);
      exports.AbstractPortFactory = AbstractPortFactory;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      Object.defineProperty(exports, '__esModule', { value: true });
      var DefaultPortModel_1 = __webpack_require__(20);
      var AbstractPortFactory_1 = __webpack_require__(42);
      var DefaultPortFactory = (function (_super) {
        __extends(DefaultPortFactory, _super);

        function DefaultPortFactory() {
          return _super.call(this, 'default') || this;
        }

        DefaultPortFactory.prototype.getNewInstance = function (initialConfig) {
          return new DefaultPortModel_1.DefaultPortModel(true, 'unknown');
        };
        return DefaultPortFactory;
      })(AbstractPortFactory_1.AbstractPortFactory);
      exports.DefaultPortFactory = DefaultPortFactory;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      var __assign =
        (this && this.__assign) ||
        Object.assign ||
        function (t) {
          for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
          }
          return t;
        };
      Object.defineProperty(exports, '__esModule', { value: true });
      var BaseEntity_1 = __webpack_require__(13);
      var _ = require('lodash');
      var LinkModel_1 = __webpack_require__(21);
      var NodeModel_1 = __webpack_require__(9);
      var PortModel_1 = __webpack_require__(12);
      var PointModel_1 = __webpack_require__(5);
      var DiagramModel = (function (_super) {
        __extends(DiagramModel, _super);

        function DiagramModel() {
          var _this = _super.call(this) || this;
          _this.links = {};
          _this.nodes = {};
          _this.offsetX = 0;
          _this.offsetY = 0;
          _this.zoom = 100;
          _this.rendered = false;
          _this.gridSize = 0;
          return _this;
        }

        DiagramModel.prototype.setGridSize = function (size) {
          if (size === void 0) {
            size = 0;
          }
          this.gridSize = size;
          this.iterateListeners(function (listener, event) {
            if (listener.gridUpdated) {
              listener.gridUpdated(__assign({}, event, { size: size }));
            }
          });
        };
        DiagramModel.prototype.getGridPosition = function (pos) {
          if (this.gridSize === 0) {
            return pos;
          }
          return this.gridSize * Math.floor((pos + this.gridSize / 2) / this.gridSize);
        };
        DiagramModel.prototype.deSerializeDiagram = function (object, diagramEngine) {
          var _this = this;
          this.deSerialize(object, diagramEngine);
          this.offsetX = object.offsetX;
          this.offsetY = object.offsetY;
          this.zoom = object.zoom;
          this.gridSize = object.gridSize;
          _.forEach(object.nodes, function (node) {
            var nodeOb = diagramEngine.getNodeFactory(node.type).getNewInstance(node);
            nodeOb.setParent(_this);
            nodeOb.deSerialize(node, diagramEngine);
            _this.addNode(nodeOb);
          });
          _.forEach(object.links, function (link) {
            var linkOb = diagramEngine.getLinkFactory(link.type).getNewInstance();
            linkOb.setParent(_this);
            linkOb.deSerialize(link, diagramEngine);
            _this.addLink(linkOb);
          });
        };
        DiagramModel.prototype.serializeDiagram = function () {
          return _.merge(this.serialize(), {
            offsetX: this.offsetX,
            offsetY: this.offsetY,
            zoom: this.zoom,
            gridSize: this.gridSize,
            links: _.map(this.links, function (link) {
              return link.serialize();
            }),
            nodes: _.map(this.nodes, function (node) {
              return node.serialize();
            }),
          });
        };
        DiagramModel.prototype.clearSelection = function (ignore) {
          if (ignore === void 0) {
            ignore = null;
          }
          _.forEach(this.getSelectedItems(), function (element) {
            if (ignore && ignore.getID() === element.getID()) {
              return;
            }
            element.setSelected(false);
          });
        };
        DiagramModel.prototype.getSelectedItems = function () {
          var filters = [];
          for (var _i = 0; _i < arguments.length; _i++) {
            filters[_i] = arguments[_i];
          }
          if (!Array.isArray(filters)) {
            filters = [filters];
          }
          var items = [];
          items = items.concat(
            _.flatMap(this.nodes, function (node) {
              return node.getSelectedEntities();
            })
          );
          items = items.concat(
            _.flatMap(this.links, function (link) {
              return link.getSelectedEntities();
            })
          );
          items = items.concat(
            _.flatMap(this.links, function (link) {
              return _.flatMap(link.points, function (point) {
                return point.getSelectedEntities();
              });
            })
          );
          items = _.uniq(items);
          if (filters.length > 0) {
            items = _.filter(_.uniq(items), function (item) {
              if (_.includes(filters, 'node') && item instanceof NodeModel_1.NodeModel) {
                return true;
              }
              if (_.includes(filters, 'link') && item instanceof LinkModel_1.LinkModel) {
                return true;
              }
              if (_.includes(filters, 'port') && item instanceof PortModel_1.PortModel) {
                return true;
              }
              if (_.includes(filters, 'point') && item instanceof PointModel_1.PointModel) {
                return true;
              }
              return false;
            });
          }
          return items;
        };
        DiagramModel.prototype.setZoomLevel = function (zoom) {
          this.zoom = zoom;
          this.iterateListeners(function (listener, event) {
            if (listener.zoomUpdated) {
              listener.zoomUpdated(__assign({}, event, { zoom: zoom }));
            }
          });
        };
        DiagramModel.prototype.setOffset = function (offsetX, offsetY) {
          this.offsetX = offsetX;
          this.offsetY = offsetY;
          this.iterateListeners(function (listener, event) {
            if (listener.offsetUpdated) {
              listener.offsetUpdated(__assign({}, event, { offsetX: offsetX, offsetY: offsetY }));
            }
          });
        };
        DiagramModel.prototype.setOffsetX = function (offsetX) {
          var _this = this;
          this.offsetX = offsetX;
          this.iterateListeners(function (listener, event) {
            if (listener.offsetUpdated) {
              listener.offsetUpdated(__assign({}, event, { offsetX: offsetX, offsetY: _this.offsetY }));
            }
          });
        };
        DiagramModel.prototype.setOffsetY = function (offsetY) {
          var _this = this;
          this.offsetY = offsetY;
          this.iterateListeners(function (listener, event) {
            if (listener.offsetUpdated) {
              listener.offsetUpdated(__assign({}, event, { offsetX: _this.offsetX, offsetY: _this.offsetY }));
            }
          });
        };
        DiagramModel.prototype.getOffsetY = function () {
          return this.offsetY;
        };
        DiagramModel.prototype.getOffsetX = function () {
          return this.offsetX;
        };
        DiagramModel.prototype.getZoomLevel = function () {
          return this.zoom;
        };
        DiagramModel.prototype.getNode = function (node) {
          if (node instanceof NodeModel_1.NodeModel) {
            return node;
          }
          if (!this.nodes[node]) {
            return null;
          }
          return this.nodes[node];
        };
        DiagramModel.prototype.getLink = function (link) {
          if (link instanceof LinkModel_1.LinkModel) {
            return link;
          }
          if (!this.links[link]) {
            return null;
          }
          return this.links[link];
        };
        DiagramModel.prototype.addAll = function () {
          var _this = this;
          var models = [];
          for (var _i = 0; _i < arguments.length; _i++) {
            models[_i] = arguments[_i];
          }
          _.forEach(models, function (model) {
            if (model instanceof LinkModel_1.LinkModel) {
              _this.addLink(model);
            } else if (model instanceof NodeModel_1.NodeModel) {
              _this.addNode(model);
            }
          });
          return models;
        };
        DiagramModel.prototype.addLink = function (link) {
          var _this = this;
          link.addListener({
            entityRemoved: function () {
              _this.removeLink(link);
            },
          });
          this.links[link.getID()] = link;
          this.iterateListeners(function (listener, event) {
            if (listener.linksUpdated) {
              listener.linksUpdated(__assign({}, event, { link: link, isCreated: true }));
            }
          });
          return link;
        };
        DiagramModel.prototype.addNode = function (node) {
          var _this = this;
          node.addListener({
            entityRemoved: function () {
              _this.removeNode(node);
            },
          });
          this.nodes[node.getID()] = node;
          this.iterateListeners(function (listener, event) {
            if (listener.nodesUpdated) {
              listener.nodesUpdated(__assign({}, event, { node: node, isCreated: true }));
            }
          });
          return node;
        };
        DiagramModel.prototype.removeLink = function (link) {
          link = this.getLink(link);
          delete this.links[link.getID()];
          this.iterateListeners(function (listener, event) {
            if (listener.linksUpdated) {
              listener.linksUpdated(__assign({}, event, { link: link, isCreated: false }));
            }
          });
        };
        DiagramModel.prototype.removeNode = function (node) {
          node = this.getNode(node);
          delete this.nodes[node.getID()];
          this.iterateListeners(function (listener, event) {
            if (listener.nodesUpdated) {
              listener.nodesUpdated(__assign({}, event, { node: node, isCreated: false }));
            }
          });
        };
        DiagramModel.prototype.getLinks = function () {
          return this.links;
        };
        DiagramModel.prototype.getNodes = function () {
          return this.nodes;
        };
        return DiagramModel;
      })(BaseEntity_1.BaseEntity);
      exports.DiagramModel = DiagramModel;
    },
    function (module, exports, __webpack_require__) {
      'use strict';

      function __export(m) {
        for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
      }

      Object.defineProperty(exports, '__esModule', { value: true });
      __export(__webpack_require__(7));
      __export(__webpack_require__(13));
      __export(__webpack_require__(49));
      __export(__webpack_require__(38));
      __export(__webpack_require__(20));
      __export(__webpack_require__(19));
      __export(__webpack_require__(18));
      __export(__webpack_require__(48));
      __export(__webpack_require__(47));
      __export(__webpack_require__(43));
      __export(__webpack_require__(41));
      __export(__webpack_require__(37));
      __export(__webpack_require__(39));
      __export(__webpack_require__(35));
      __export(__webpack_require__(34));
      __export(__webpack_require__(8));
      __export(__webpack_require__(40));
      __export(__webpack_require__(36));
      __export(__webpack_require__(32));
      __export(__webpack_require__(42));
      __export(__webpack_require__(16));
      __export(__webpack_require__(11));
      __export(__webpack_require__(31));
      __export(__webpack_require__(30));
      __export(__webpack_require__(29));
      __export(__webpack_require__(6));
      __export(__webpack_require__(44));
      __export(__webpack_require__(21));
      __export(__webpack_require__(9));
      __export(__webpack_require__(5));
      __export(__webpack_require__(12));
      __export(__webpack_require__(17));
      __export(__webpack_require__(46));
      __export(__webpack_require__(27));
      __export(__webpack_require__(25));
      __export(__webpack_require__(33));
      __export(__webpack_require__(3));
      __export(__webpack_require__(28));
      __export(__webpack_require__(26));
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      var __assign =
        (this && this.__assign) ||
        Object.assign ||
        function (t) {
          for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
          }
          return t;
        };
      Object.defineProperty(exports, '__esModule', { value: true });
      var React = __webpack_require__(1);
      var _ = require('lodash');
      var LinkLayerWidget_1 = __webpack_require__(28);
      var NodeLayerWidget_1 = __webpack_require__(26);
      var Toolkit_1 = __webpack_require__(7);
      var MoveCanvasAction_1 = __webpack_require__(31);
      var MoveItemsAction_1 = __webpack_require__(30);
      var SelectingAction_1 = __webpack_require__(29);
      var NodeModel_1 = __webpack_require__(9);
      var PointModel_1 = __webpack_require__(5);
      var PortModel_1 = __webpack_require__(12);
      var BaseWidget_1 = __webpack_require__(3);
      var DiagramWidget = (function (_super) {
        __extends(DiagramWidget, _super);

        function DiagramWidget(props) {
          var _this = _super.call(this, 'srd-diagram', props) || this;
          _this.onKeyUpPointer = null;
          _this.onMouseMove = _this.onMouseMove.bind(_this);
          _this.onMouseUp = _this.onMouseUp.bind(_this);
          _this.state = {
            action: null,
            wasMoved: false,
            renderedNodes: false,
            windowListener: null,
            diagramEngineListener: null,
            document: null,
          };
          return _this;
        }

        DiagramWidget.prototype.componentWillUnmount = function () {
          this.props.diagramEngine.removeListener(this.state.diagramEngineListener);
          this.props.diagramEngine.setCanvas(null);
          window.removeEventListener('keyup', this.onKeyUpPointer);
          window.removeEventListener('mouseUp', this.onMouseUp);
          window.removeEventListener('mouseMove', this.onMouseMove);
        };
        DiagramWidget.prototype.componentWillReceiveProps = function (nextProps) {
          var _this = this;
          if (this.props.diagramEngine !== nextProps.diagramEngine) {
            this.props.diagramEngine.removeListener(this.state.diagramEngineListener);
            var diagramEngineListener = nextProps.diagramEngine.addListener({
              repaintCanvas: function () {
                return _this.forceUpdate();
              },
            });
            this.setState({ diagramEngineListener: diagramEngineListener });
          }
        };
        DiagramWidget.prototype.componentWillUpdate = function (nextProps) {
          if (this.props.diagramEngine.diagramModel.id !== nextProps.diagramEngine.diagramModel.id) {
            this.setState({ renderedNodes: false });
            nextProps.diagramEngine.diagramModel.rendered = true;
          }
          if (!nextProps.diagramEngine.diagramModel.rendered) {
            this.setState({ renderedNodes: false });
            nextProps.diagramEngine.diagramModel.rendered = true;
          }
        };
        DiagramWidget.prototype.componentDidUpdate = function () {
          if (!this.state.renderedNodes) {
            this.setState({ renderedNodes: true });
          }
        };
        DiagramWidget.prototype.componentDidMount = function () {
          var _this = this;
          this.onKeyUpPointer = this.onKeyUp.bind(this);
          this.setState({
            document: document,
            renderedNodes: true,
            diagramEngineListener: this.props.diagramEngine.addListener({
              repaintCanvas: function () {
                _this.forceUpdate();
              },
            }),
          });
          window.addEventListener('keyup', this.onKeyUpPointer, false);
          if (true) {
            window.focus();
          }
        };
        DiagramWidget.prototype.getMouseElement = function (event) {
          var target = event.target;
          var diagramModel = this.props.diagramEngine.diagramModel;
          var element = Toolkit_1.Toolkit.closest(target, '.port[data-name]');
          if (element) {
            var nodeElement = Toolkit_1.Toolkit.closest(target, '.node[data-nodeid]');
            return {
              model: diagramModel.getNode(nodeElement.getAttribute('data-nodeid')).getPort(element.getAttribute('data-name')),
              element: element,
            };
          }
          element = Toolkit_1.Toolkit.closest(target, '.point[data-id]');
          if (element) {
            return {
              model: diagramModel.getLink(element.getAttribute('data-linkid')).getPointModel(element.getAttribute('data-id')),
              element: element,
            };
          }
          element = Toolkit_1.Toolkit.closest(target, '[data-linkid]');
          if (element) {
            return { model: diagramModel.getLink(element.getAttribute('data-linkid')), element: element };
          }
          element = Toolkit_1.Toolkit.closest(target, '.node[data-nodeid]');
          if (element) {
            return { model: diagramModel.getNode(element.getAttribute('data-nodeid')), element: element };
          }
          return null;
        };
        DiagramWidget.prototype.fireAction = function () {
          if (this.state.action && this.props.actionStillFiring) {
            this.props.actionStillFiring(this.state.action);
          }
        };
        DiagramWidget.prototype.stopFiringAction = function (shouldSkipEvent) {
          if (this.props.actionStoppedFiring && !shouldSkipEvent) {
            this.props.actionStoppedFiring(this.state.action);
          }
          this.setState({ action: null });
        };
        DiagramWidget.prototype.startFiringAction = function (action) {
          var setState = true;
          if (this.props.actionStartedFiring) {
            setState = this.props.actionStartedFiring(action);
          }
          if (setState) {
            this.setState({ action: action });
          }
        };
        DiagramWidget.prototype.onMouseMove = function (event) {
          var _this = this;
          var diagramEngine = this.props.diagramEngine;
          var diagramModel = diagramEngine.getDiagramModel();
          if (this.state.action instanceof SelectingAction_1.SelectingAction) {
            var relative = diagramEngine.getRelativePoint(event.clientX, event.clientY);
            _.forEach(diagramModel.getNodes(), function (node) {
              if (_this.state.action.containsElement(node.x, node.y, diagramModel)) {
                node.setSelected(true);
              }
            });
            _.forEach(diagramModel.getLinks(), function (link) {
              var allSelected = true;
              _.forEach(link.points, function (point) {
                if (_this.state.action.containsElement(point.x, point.y, diagramModel)) {
                  point.setSelected(true);
                } else {
                  allSelected = false;
                }
              });
              if (allSelected) {
                link.setSelected(true);
              }
            });
            this.state.action.mouseX2 = relative.x;
            this.state.action.mouseY2 = relative.y;
            this.fireAction();
            this.setState({ action: this.state.action });
            return;
          } else if (this.state.action instanceof MoveItemsAction_1.MoveItemsAction) {
            var amountX_1 = event.clientX - this.state.action.mouseX;
            var amountY_1 = event.clientY - this.state.action.mouseY;
            var amountZoom_1 = diagramModel.getZoomLevel() / 100;
            _.forEach(this.state.action.selectionModels, function (model) {
              if (model.model instanceof NodeModel_1.NodeModel || (model.model instanceof PointModel_1.PointModel && !model.model.isConnectedToPort())) {
                model.model.x = diagramModel.getGridPosition(model.initialX + amountX_1 / amountZoom_1);
                model.model.y = diagramModel.getGridPosition(model.initialY + amountY_1 / amountZoom_1);
                if (model.model instanceof NodeModel_1.NodeModel) {
                  _.forEach(model.model.getPorts(), function (port) {
                    var portCoords = _this.props.diagramEngine.getPortCoords(port);
                    port.updateCoords(portCoords);
                  });
                }
                if (diagramEngine.isSmartRoutingEnabled()) {
                  diagramEngine.calculateRoutingMatrix();
                }
              } else if (model.model instanceof PointModel_1.PointModel) {
                model.model.x = model.initialX + diagramModel.getGridPosition(amountX_1 / amountZoom_1);
                model.model.y = model.initialY + diagramModel.getGridPosition(amountY_1 / amountZoom_1);
              }
            });
            if (diagramEngine.isSmartRoutingEnabled()) {
              diagramEngine.calculateCanvasMatrix();
            }
            this.fireAction();
            if (!this.state.wasMoved) {
              this.setState({ wasMoved: true });
            } else {
              this.forceUpdate();
            }
          } else if (this.state.action instanceof MoveCanvasAction_1.MoveCanvasAction) {
            if (this.props.allowCanvasTranslation) {
              diagramModel.setOffset(
                this.state.action.initialOffsetX + (event.clientX - this.state.action.mouseX),
                this.state.action.initialOffsetY + (event.clientY - this.state.action.mouseY)
              );
              this.fireAction();
              this.forceUpdate();
            }
          }
        };
        DiagramWidget.prototype.onKeyUp = function (event) {
          var _this = this;
          if (this.props.deleteKeys.indexOf(event.keyCode) !== -1) {
            _.forEach(this.props.diagramEngine.getDiagramModel().getSelectedItems(), function (element) {
              if (!_this.props.diagramEngine.isModelLocked(element)) {
                element.remove();
              }
            });
            this.forceUpdate();
          }
        };
        DiagramWidget.prototype.onMouseUp = function (event) {
          var _this = this;
          var diagramEngine = this.props.diagramEngine;
          if (this.state.action instanceof MoveItemsAction_1.MoveItemsAction) {
            var element = this.getMouseElement(event);
            _.forEach(this.state.action.selectionModels, function (model) {
              if (!(model.model instanceof PointModel_1.PointModel)) {
                return;
              }
              if (element && element.model instanceof PortModel_1.PortModel && !diagramEngine.isModelLocked(element.model)) {
                var link = model.model.getLink();
                if (link.getTargetPort() !== null) {
                  if (link.getTargetPort() !== element.model && link.getSourcePort() !== element.model) {
                    var targetPort = link.getTargetPort();
                    var newLink = link.clone({});
                    newLink.setSourcePort(element.model);
                    newLink.setTargetPort(targetPort);
                    link.setTargetPort(element.model);
                    targetPort.removeLink(link);
                    newLink.removePointsBefore(newLink.getPoints()[link.getPointIndex(model.model)]);
                    link.removePointsAfter(model.model);
                    diagramEngine.getDiagramModel().addLink(newLink);
                  } else if (link.getTargetPort() === element.model) {
                    link.removePointsAfter(model.model);
                  } else if (link.getSourcePort() === element.model) {
                    link.removePointsBefore(model.model);
                  }
                } else {
                  link.setTargetPort(element.model);
                }
                delete _this.props.diagramEngine.linksThatHaveInitiallyRendered[link.getID()];
              }
            });
            if (!this.props.allowLooseLinks && this.state.wasMoved) {
              _.forEach(this.state.action.selectionModels, function (model) {
                if (!(model.model instanceof PointModel_1.PointModel)) {
                  return;
                }
                var selectedPoint = model.model;
                var link = selectedPoint.getLink();
                if (link.getSourcePort() === null || link.getTargetPort() === null) {
                  link.remove();
                }
              });
            }
            _.forEach(this.state.action.selectionModels, function (model) {
              if (!(model.model instanceof PointModel_1.PointModel)) {
                return;
              }
              var link = model.model.getLink();
              var sourcePort = link.getSourcePort();
              var targetPort = link.getTargetPort();
              if (sourcePort !== null && targetPort !== null) {
                if (!sourcePort.canLinkToPort(targetPort)) {
                  link.remove();
                } else if (
                  _.some(_.values(targetPort.getLinks()), function (l) {
                    return l !== link && (l.getSourcePort() === sourcePort || l.getTargetPort() === sourcePort);
                  })
                ) {
                  link.remove();
                }
              }
            });
            diagramEngine.clearRepaintEntities();
            this.stopFiringAction(!this.state.wasMoved);
          } else {
            diagramEngine.clearRepaintEntities();
            this.stopFiringAction();
          }
          this.state.document.removeEventListener('mousemove', this.onMouseMove);
          this.state.document.removeEventListener('mouseup', this.onMouseUp);
        };
        DiagramWidget.prototype.drawSelectionBox = function () {
          var dimensions = this.state.action.getBoxDimensions();
          return React.createElement('div', {
            className: this.bem('__selector'),
            style: { top: dimensions.top, left: dimensions.left, width: dimensions.width, height: dimensions.height },
          });
        };
        DiagramWidget.prototype.render = function () {
          var _this = this;
          var diagramEngine = this.props.diagramEngine;
          diagramEngine.setMaxNumberPointsPerLink(this.props.maxNumberPointsPerLink);
          diagramEngine.setSmartRoutingStatus(this.props.smartRouting);
          var diagramModel = diagramEngine.getDiagramModel();
          return React.createElement(
            'div',
            __assign({}, this.getProps(), {
              ref: function (ref) {
                if (ref) {
                  _this.props.diagramEngine.setCanvas(ref);
                }
              },
              onWheel: function (event) {
                if (_this.props.allowCanvasZoom) {
                  event.preventDefault();
                  event.stopPropagation();
                  var oldZoomFactor = diagramModel.getZoomLevel() / 100;
                  var scrollDelta = _this.props.inverseZoom ? -event.deltaY : event.deltaY;
                  if (event.ctrlKey && scrollDelta % 1 !== 0) {
                    scrollDelta /= 3;
                  } else {
                    scrollDelta /= 60;
                  }
                  if (diagramModel.getZoomLevel() + scrollDelta > 10) {
                    diagramModel.setZoomLevel(diagramModel.getZoomLevel() + scrollDelta);
                  }
                  var zoomFactor = diagramModel.getZoomLevel() / 100;
                  var boundingRect = event.currentTarget.getBoundingClientRect();
                  var clientWidth = boundingRect.width;
                  var clientHeight = boundingRect.height;
                  var widthDiff = clientWidth * zoomFactor - clientWidth * oldZoomFactor;
                  var heightDiff = clientHeight * zoomFactor - clientHeight * oldZoomFactor;
                  var clientX = event.clientX - boundingRect.left;
                  var clientY = event.clientY - boundingRect.top;
                  var xFactor = (clientX - diagramModel.getOffsetX()) / oldZoomFactor / clientWidth;
                  var yFactor = (clientY - diagramModel.getOffsetY()) / oldZoomFactor / clientHeight;
                  diagramModel.setOffset(diagramModel.getOffsetX() - widthDiff * xFactor, diagramModel.getOffsetY() - heightDiff * yFactor);
                  diagramEngine.enableRepaintEntities([]);
                  _this.forceUpdate();
                }
              },
              onMouseDown: function (event) {
                _this.setState(__assign({}, _this.state, { wasMoved: false }));
                diagramEngine.clearRepaintEntities();
                var model = _this.getMouseElement(event);
                if (model === null) {
                  if (event.shiftKey) {
                    var relative = diagramEngine.getRelativePoint(event.clientX, event.clientY);
                    _this.startFiringAction(new SelectingAction_1.SelectingAction(relative.x, relative.y));
                  } else {
                    diagramModel.clearSelection();
                    _this.startFiringAction(new MoveCanvasAction_1.MoveCanvasAction(event.clientX, event.clientY, diagramModel));
                  }
                } else if (model.model instanceof PortModel_1.PortModel) {
                  if (!_this.props.diagramEngine.isModelLocked(model.model)) {
                    var relative = diagramEngine.getRelativeMousePoint(event);
                    var sourcePort = model.model;
                    var link = sourcePort.createLinkModel();
                    link.setSourcePort(sourcePort);
                    if (link) {
                      link.removeMiddlePoints();
                      if (link.getSourcePort() !== sourcePort) {
                        link.setSourcePort(sourcePort);
                      }
                      link.setTargetPort(null);
                      link.getFirstPoint().updateLocation(relative);
                      link.getLastPoint().updateLocation(relative);
                      diagramModel.clearSelection();
                      link.getLastPoint().setSelected(true);
                      diagramModel.addLink(link);
                      _this.startFiringAction(new MoveItemsAction_1.MoveItemsAction(event.clientX, event.clientY, diagramEngine));
                    }
                  } else {
                    diagramModel.clearSelection();
                  }
                } else {
                  if (!event.shiftKey && !model.model.isSelected()) {
                    diagramModel.clearSelection();
                  }
                  model.model.setSelected(true);
                  _this.startFiringAction(new MoveItemsAction_1.MoveItemsAction(event.clientX, event.clientY, diagramEngine));
                }
                _this.state.document.addEventListener('mousemove', _this.onMouseMove);
                _this.state.document.addEventListener('mouseup', _this.onMouseUp);
              },
            }),
            this.state.renderedNodes &&
              React.createElement(LinkLayerWidget_1.LinkLayerWidget, {
                diagramEngine: diagramEngine,
                pointAdded: function (point, event) {
                  _this.state.document.addEventListener('mousemove', _this.onMouseMove);
                  _this.state.document.addEventListener('mouseup', _this.onMouseUp);
                  event.stopPropagation();
                  diagramModel.clearSelection(point);
                  _this.setState({ action: new MoveItemsAction_1.MoveItemsAction(event.clientX, event.clientY, diagramEngine) });
                },
              }),
            React.createElement(NodeLayerWidget_1.NodeLayerWidget, { diagramEngine: diagramEngine }),
            this.state.action instanceof SelectingAction_1.SelectingAction && this.drawSelectionBox()
          );
        };
        DiagramWidget.defaultProps = {
          diagramEngine: null,
          allowLooseLinks: true,
          allowCanvasTranslation: true,
          allowCanvasZoom: true,
          inverseZoom: false,
          maxNumberPointsPerLink: Infinity,
          smartRouting: false,
          deleteKeys: [46, 8],
        };
        return DiagramWidget;
      })(BaseWidget_1.BaseWidget);
      exports.DiagramWidget = DiagramWidget;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      Object.defineProperty(exports, '__esModule', { value: true });
      var DefaultNodeModel_1 = __webpack_require__(38);
      var React = __webpack_require__(1);
      var DefaultNodeWidget_1 = __webpack_require__(35);
      var AbstractNodeFactory_1 = __webpack_require__(32);
      var DefaultNodeFactory = (function (_super) {
        __extends(DefaultNodeFactory, _super);

        function DefaultNodeFactory() {
          return _super.call(this, 'default') || this;
        }

        DefaultNodeFactory.prototype.generateReactWidget = function (diagramEngine, node) {
          return React.createElement(DefaultNodeWidget_1.DefaultNodeWidget, { node: node, diagramEngine: diagramEngine });
        };
        DefaultNodeFactory.prototype.getNewInstance = function (initialConfig) {
          return new DefaultNodeModel_1.DefaultNodeModel();
        };
        return DefaultNodeFactory;
      })(AbstractNodeFactory_1.AbstractNodeFactory);
      exports.DefaultNodeFactory = DefaultNodeFactory;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      Object.defineProperty(exports, '__esModule', { value: true });
      var React = __webpack_require__(1);
      var DefaultLinkWidget_1 = __webpack_require__(37);
      var AbstractLinkFactory_1 = __webpack_require__(36);
      var DefaultLinkModel_1 = __webpack_require__(19);
      var DefaultLinkFactory = (function (_super) {
        __extends(DefaultLinkFactory, _super);

        function DefaultLinkFactory() {
          return _super.call(this, 'default') || this;
        }

        DefaultLinkFactory.prototype.generateReactWidget = function (diagramEngine, link) {
          return React.createElement(DefaultLinkWidget_1.DefaultLinkWidget, { link: link, diagramEngine: diagramEngine });
        };
        DefaultLinkFactory.prototype.getNewInstance = function (initialConfig) {
          return new DefaultLinkModel_1.DefaultLinkModel();
        };
        DefaultLinkFactory.prototype.generateLinkSegment = function (model, widget, selected, path) {
          return React.createElement('path', {
            className: selected ? widget.bem('--path-selected') : '',
            strokeWidth: model.width,
            stroke: model.color,
            d: path,
          });
        };
        return DefaultLinkFactory;
      })(AbstractLinkFactory_1.AbstractLinkFactory);
      exports.DefaultLinkFactory = DefaultLinkFactory;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      var __extends =
        (this && this.__extends) ||
        (function () {
          var extendStatics =
            Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array &&
              function (d, b) {
                d.__proto__ = b;
              }) ||
            function (d, b) {
              for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
            };
          return function (d, b) {
            extendStatics(d, b);

            function __() {
              this.constructor = d;
            }

            d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
          };
        })();
      Object.defineProperty(exports, '__esModule', { value: true });
      var BaseEntity_1 = __webpack_require__(13);
      var DiagramModel_1 = __webpack_require__(44);
      var _ = require('lodash');
      var NodeModel_1 = __webpack_require__(9);
      var PointModel_1 = __webpack_require__(5);
      var main_1 = __webpack_require__(45);
      var PathFinding_1 = __webpack_require__(16);
      var DefaultPortFactory_1 = __webpack_require__(43);
      var DefaultLabelFactory_1 = __webpack_require__(41);
      var Toolkit_1 = __webpack_require__(7);
      var DiagramEngine = (function (_super) {
        __extends(DiagramEngine, _super);

        function DiagramEngine() {
          var _this = _super.call(this) || this;
          _this.canvasMatrix = [];
          _this.routingMatrix = [];
          _this.hAdjustmentFactor = 0;
          _this.vAdjustmentFactor = 0;
          _this.calculateMatrixDimensions = function () {
            var allNodesCoords = _.values(_this.diagramModel.nodes).map(function (item) {
              return { x: item.x, width: item.width, y: item.y, height: item.height };
            });
            var allLinks = _.values(_this.diagramModel.links);
            var allPortsCoords = _.flatMap(
              allLinks.map(function (link) {
                return [link.sourcePort, link.targetPort];
              })
            )
              .filter(function (port) {
                return port !== null;
              })
              .map(function (item) {
                return { x: item.x, width: item.width, y: item.y, height: item.height };
              });
            var allPointsCoords = _.flatMap(
              allLinks.map(function (link) {
                return link.points;
              })
            ).map(function (item) {
              return { x: item.x, width: 0, y: item.y, height: 0 };
            });
            var canvas = _this.canvas;
            var minX =
              Math.floor(
                Math.min(
                  _.minBy(_.concat(allNodesCoords, allPortsCoords, allPointsCoords), function (item) {
                    return item.x;
                  }).x,
                  0
                ) / PathFinding_1.ROUTING_SCALING_FACTOR
              ) * PathFinding_1.ROUTING_SCALING_FACTOR;
            var maxXElement = _.maxBy(_.concat(allNodesCoords, allPortsCoords, allPointsCoords), function (item) {
              return item.x + item.width;
            });
            var maxX = Math.max(maxXElement.x + maxXElement.width, canvas.offsetWidth);
            var minY =
              Math.floor(
                Math.min(
                  _.minBy(_.concat(allNodesCoords, allPortsCoords, allPointsCoords), function (item) {
                    return item.y;
                  }).y,
                  0
                ) / PathFinding_1.ROUTING_SCALING_FACTOR
              ) * PathFinding_1.ROUTING_SCALING_FACTOR;
            var maxYElement = _.maxBy(_.concat(allNodesCoords, allPortsCoords, allPointsCoords), function (item) {
              return item.y + item.height;
            });
            var maxY = Math.max(maxYElement.y + maxYElement.height, canvas.offsetHeight);
            return {
              width: Math.ceil(Math.abs(minX) + maxX),
              hAdjustmentFactor: Math.abs(minX) / PathFinding_1.ROUTING_SCALING_FACTOR + 1,
              height: Math.ceil(Math.abs(minY) + maxY),
              vAdjustmentFactor: Math.abs(minY) / PathFinding_1.ROUTING_SCALING_FACTOR + 1,
            };
          };
          _this.markNodes = function (matrix) {
            _.values(_this.diagramModel.nodes).forEach(function (node) {
              var startX = Math.floor(node.x / PathFinding_1.ROUTING_SCALING_FACTOR);
              var endX = Math.ceil((node.x + node.width) / PathFinding_1.ROUTING_SCALING_FACTOR);
              var startY = Math.floor(node.y / PathFinding_1.ROUTING_SCALING_FACTOR);
              var endY = Math.ceil((node.y + node.height) / PathFinding_1.ROUTING_SCALING_FACTOR);
              for (var x = startX - 1; x <= endX + 1; x++) {
                for (var y = startY - 1; y < endY + 1; y++) {
                  _this.markMatrixPoint(matrix, _this.translateRoutingX(x), _this.translateRoutingY(y));
                }
              }
            });
          };
          _this.markPorts = function (matrix) {
            var allElements = _.flatMap(
              _.values(_this.diagramModel.links).map(function (link) {
                return [].concat(link.sourcePort, link.targetPort);
              })
            );
            allElements
              .filter(function (port) {
                return port !== null;
              })
              .forEach(function (port) {
                var startX = Math.floor(port.x / PathFinding_1.ROUTING_SCALING_FACTOR);
                var endX = Math.ceil((port.x + port.width) / PathFinding_1.ROUTING_SCALING_FACTOR);
                var startY = Math.floor(port.y / PathFinding_1.ROUTING_SCALING_FACTOR);
                var endY = Math.ceil((port.y + port.height) / PathFinding_1.ROUTING_SCALING_FACTOR);
                for (var x = startX - 1; x <= endX + 1; x++) {
                  for (var y = startY - 1; y < endY + 1; y++) {
                    _this.markMatrixPoint(matrix, _this.translateRoutingX(x), _this.translateRoutingY(y));
                  }
                }
              });
          };
          _this.markMatrixPoint = function (matrix, x, y) {
            if (matrix[y] !== undefined && matrix[y][x] !== undefined) {
              matrix[y][x] = 1;
            }
          };
          _this.diagramModel = new DiagramModel_1.DiagramModel();
          _this.nodeFactories = {};
          _this.linkFactories = {};
          _this.portFactories = {};
          _this.labelFactories = {};
          _this.canvas = null;
          _this.paintableWidgets = null;
          _this.linksThatHaveInitiallyRendered = {};
          if (Toolkit_1.Toolkit.TESTING) {
            Toolkit_1.Toolkit.TESTING_UID = 0;
            if (window) {
              window['diagram_instance'] = _this;
            }
          }
          return _this;
        }

        DiagramEngine.prototype.installDefaultFactories = function () {
          this.registerNodeFactory(new main_1.DefaultNodeFactory());
          this.registerLinkFactory(new main_1.DefaultLinkFactory());
          this.registerPortFactory(new DefaultPortFactory_1.DefaultPortFactory());
          this.registerLabelFactory(new DefaultLabelFactory_1.DefaultLabelFactory());
        };
        DiagramEngine.prototype.repaintCanvas = function () {
          this.iterateListeners(function (listener) {
            if (listener.repaintCanvas) {
              listener.repaintCanvas();
            }
          });
        };
        DiagramEngine.prototype.clearRepaintEntities = function () {
          this.paintableWidgets = null;
        };
        DiagramEngine.prototype.enableRepaintEntities = function (entities) {
          var _this = this;
          this.paintableWidgets = {};
          entities.forEach(function (entity) {
            if (entity instanceof NodeModel_1.NodeModel) {
              _.forEach(entity.getPorts(), function (port) {
                _.forEach(port.getLinks(), function (link) {
                  _this.paintableWidgets[link.getID()] = true;
                });
              });
            }
            if (entity instanceof PointModel_1.PointModel) {
              _this.paintableWidgets[entity.getLink().getID()] = true;
            }
            _this.paintableWidgets[entity.getID()] = true;
          });
        };
        DiagramEngine.prototype.isModelLocked = function (model) {
          if (this.diagramModel.isLocked()) {
            return true;
          }
          return model.isLocked();
        };
        DiagramEngine.prototype.recalculatePortsVisually = function () {
          this.nodesRendered = false;
          this.linksThatHaveInitiallyRendered = {};
        };
        DiagramEngine.prototype.canEntityRepaint = function (baseModel) {
          if (this.paintableWidgets === null) {
            return true;
          }
          return this.paintableWidgets[baseModel.getID()] !== undefined;
        };
        DiagramEngine.prototype.setCanvas = function (canvas) {
          this.canvas = canvas;
        };
        DiagramEngine.prototype.setDiagramModel = function (model) {
          this.diagramModel = model;
          this.recalculatePortsVisually();
        };
        DiagramEngine.prototype.getDiagramModel = function () {
          return this.diagramModel;
        };
        //!-------------- FACTORIES ------------
        DiagramEngine.prototype.getNodeFactories = function () {
          return this.nodeFactories;
        };
        DiagramEngine.prototype.getLinkFactories = function () {
          return this.linkFactories;
        };
        DiagramEngine.prototype.getLabelFactories = function () {
          return this.labelFactories;
        };
        DiagramEngine.prototype.registerLabelFactory = function (factory) {
          this.labelFactories[factory.getType()] = factory;
          this.iterateListeners(function (listener) {
            if (listener.labelFactoriesUpdated) {
              listener.labelFactoriesUpdated();
            }
          });
        };
        DiagramEngine.prototype.registerPortFactory = function (factory) {
          this.portFactories[factory.getType()] = factory;
          this.iterateListeners(function (listener) {
            if (listener.portFactoriesUpdated) {
              listener.portFactoriesUpdated();
            }
          });
        };
        DiagramEngine.prototype.registerNodeFactory = function (factory) {
          this.nodeFactories[factory.getType()] = factory;
          this.iterateListeners(function (listener) {
            if (listener.nodeFactoriesUpdated) {
              listener.nodeFactoriesUpdated();
            }
          });
        };
        DiagramEngine.prototype.registerLinkFactory = function (factory) {
          this.linkFactories[factory.getType()] = factory;
          this.iterateListeners(function (listener) {
            if (listener.linkFactoriesUpdated) {
              listener.linkFactoriesUpdated();
            }
          });
        };
        DiagramEngine.prototype.getPortFactory = function (type) {
          if (this.portFactories[type]) {
            return this.portFactories[type];
          }
          throw new Error('cannot find factory for port of type: [' + type + ']');
        };
        DiagramEngine.prototype.getNodeFactory = function (type) {
          if (this.nodeFactories[type]) {
            return this.nodeFactories[type];
          }
          throw new Error('cannot find factory for node of type: [' + type + ']');
        };
        DiagramEngine.prototype.getLinkFactory = function (type) {
          if (this.linkFactories[type]) {
            return this.linkFactories[type];
          }
          throw new Error('cannot find factory for link of type: [' + type + ']');
        };
        DiagramEngine.prototype.getLabelFactory = function (type) {
          if (this.labelFactories[type]) {
            return this.labelFactories[type];
          }
          throw new Error('cannot find factory for label of type: [' + type + ']');
        };
        DiagramEngine.prototype.getFactoryForNode = function (node) {
          return this.getNodeFactory(node.getType());
        };
        DiagramEngine.prototype.getFactoryForLink = function (link) {
          return this.getLinkFactory(link.getType());
        };
        DiagramEngine.prototype.getFactoryForLabel = function (label) {
          return this.getLabelFactory(label.getType());
        };
        DiagramEngine.prototype.generateWidgetForLink = function (link) {
          var linkFactory = this.getFactoryForLink(link);
          if (!linkFactory) {
            throw new Error('Cannot find link factory for link: ' + link.getType());
          }
          return linkFactory.generateReactWidget(this, link);
        };
        DiagramEngine.prototype.generateWidgetForNode = function (node) {
          var nodeFactory = this.getFactoryForNode(node);
          if (!nodeFactory) {
            throw new Error('Cannot find widget factory for node: ' + node.getType());
          }
          return nodeFactory.generateReactWidget(this, node);
        };
        DiagramEngine.prototype.getRelativeMousePoint = function (event) {
          var point = this.getRelativePoint(event.clientX, event.clientY);
          return {
            x: (point.x - this.diagramModel.getOffsetX()) / (this.diagramModel.getZoomLevel() / 100),
            y: (point.y - this.diagramModel.getOffsetY()) / (this.diagramModel.getZoomLevel() / 100),
          };
        };
        DiagramEngine.prototype.getRelativePoint = function (x, y) {
          var canvasRect = this.canvas.getBoundingClientRect();
          return { x: x - canvasRect.left, y: y - canvasRect.top };
        };
        DiagramEngine.prototype.getNodeElement = function (node) {
          var selector = this.canvas.querySelector('.node[data-nodeid="' + node.getID() + '"]');
          if (selector === null) {
            throw new Error('Cannot find Node element with nodeID: [' + node.getID() + ']');
          }
          return selector;
        };
        DiagramEngine.prototype.getNodePortElement = function (port) {
          var selector = this.canvas.querySelector('.port[data-name="' + port.getName() + '"][data-nodeid="' + port.getParent().getID() + '"]');
          if (selector === null) {
            throw new Error('Cannot find Node Port element with nodeID: [' + port.getParent().getID() + '] and name: [' + port.getName() + ']');
          }
          return selector;
        };
        DiagramEngine.prototype.getPortCenter = function (port) {
          var sourceElement = this.getNodePortElement(port);
          var sourceRect = sourceElement.getBoundingClientRect();
          var rel = this.getRelativePoint(sourceRect.left, sourceRect.top);
          return {
            x: sourceElement.offsetWidth / 2 + (rel.x - this.diagramModel.getOffsetX()) / (this.diagramModel.getZoomLevel() / 100),
            y: sourceElement.offsetHeight / 2 + (rel.y - this.diagramModel.getOffsetY()) / (this.diagramModel.getZoomLevel() / 100),
          };
        };
        DiagramEngine.prototype.getPortCoords = function (port) {
          var sourceElement = this.getNodePortElement(port);
          var sourceRect = sourceElement.getBoundingClientRect();
          var canvasRect = this.canvas.getBoundingClientRect();
          return {
            x: (sourceRect.x - this.diagramModel.getOffsetX()) / (this.diagramModel.getZoomLevel() / 100) - canvasRect.left,
            y: (sourceRect.y - this.diagramModel.getOffsetY()) / (this.diagramModel.getZoomLevel() / 100) - canvasRect.top,
            width: sourceRect.width,
            height: sourceRect.height,
          };
        };
        DiagramEngine.prototype.getNodeDimensions = function (node) {
          if (!this.canvas) {
            return { width: 0, height: 0 };
          }
          var nodeElement = this.getNodeElement(node);
          var nodeRect = nodeElement.getBoundingClientRect();
          return { width: nodeRect.width, height: nodeRect.height };
        };
        DiagramEngine.prototype.getMaxNumberPointsPerLink = function () {
          return this.maxNumberPointsPerLink;
        };
        DiagramEngine.prototype.setMaxNumberPointsPerLink = function (max) {
          this.maxNumberPointsPerLink = max;
        };
        DiagramEngine.prototype.isSmartRoutingEnabled = function () {
          return !!this.smartRouting;
        };
        DiagramEngine.prototype.setSmartRoutingStatus = function (status) {
          this.smartRouting = status;
        };
        DiagramEngine.prototype.getCanvasMatrix = function () {
          if (this.canvasMatrix.length === 0) {
            this.calculateCanvasMatrix();
          }
          return this.canvasMatrix;
        };
        DiagramEngine.prototype.calculateCanvasMatrix = function () {
          var _a = this.calculateMatrixDimensions(),
            canvasWidth = _a.width,
            hAdjustmentFactor = _a.hAdjustmentFactor,
            canvasHeight = _a.height,
            vAdjustmentFactor = _a.vAdjustmentFactor;
          this.hAdjustmentFactor = hAdjustmentFactor;
          this.vAdjustmentFactor = vAdjustmentFactor;
          var matrixWidth = Math.ceil(canvasWidth / PathFinding_1.ROUTING_SCALING_FACTOR);
          var matrixHeight = Math.ceil(canvasHeight / PathFinding_1.ROUTING_SCALING_FACTOR);
          this.canvasMatrix = _.range(0, matrixHeight).map(function () {
            return new Array(matrixWidth).fill(0);
          });
        };
        DiagramEngine.prototype.getRoutingMatrix = function () {
          if (this.routingMatrix.length === 0) {
            this.calculateRoutingMatrix();
          }
          return this.routingMatrix;
        };
        DiagramEngine.prototype.calculateRoutingMatrix = function () {
          var matrix = _.cloneDeep(this.getCanvasMatrix());
          this.markNodes(matrix);
          this.markPorts(matrix);
          this.routingMatrix = matrix;
        };
        DiagramEngine.prototype.translateRoutingX = function (x, reverse) {
          if (reverse === void 0) {
            reverse = false;
          }
          return x + this.hAdjustmentFactor * (reverse ? -1 : 1);
        };
        DiagramEngine.prototype.translateRoutingY = function (y, reverse) {
          if (reverse === void 0) {
            reverse = false;
          }
          return y + this.vAdjustmentFactor * (reverse ? -1 : 1);
        };
        DiagramEngine.prototype.zoomToFit = function () {
          var xFactor = this.canvas.clientWidth / this.canvas.scrollWidth;
          var yFactor = this.canvas.clientHeight / this.canvas.scrollHeight;
          var zoomFactor = xFactor < yFactor ? xFactor : yFactor;
          this.diagramModel.setZoomLevel(this.diagramModel.getZoomLevel() * zoomFactor);
          this.diagramModel.setOffset(0, 0);
          this.repaintCanvas();
        };
        return DiagramEngine;
      })(BaseEntity_1.BaseEntity);
      exports.DiagramEngine = DiagramEngine;
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      Object.defineProperty(exports, '__esModule', { value: true });
      var _slicedToArray = (function () {
        function sliceIterator(arr, i) {
          var _arr = [];
          var _n = true;
          var _d = false;
          var _e = undefined;
          try {
            for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
              _arr.push(_s.value);
              if (i && _arr.length === i) break;
            }
          } catch (err) {
            _d = true;
            _e = err;
          } finally {
            try {
              if (!_n && _i['return']) _i['return']();
            } finally {
              if (_d) throw _e;
            }
          }
          return _arr;
        }

        return function (arr, i) {
          if (Array.isArray(arr)) {
            return arr;
          } else if (Symbol.iterator in Object(arr)) {
            return sliceIterator(arr, i);
          } else {
            throw new TypeError('Invalid attempt to destructure non-iterable instance');
          }
        };
      })();
      var sq = function sq(x) {
        return x * x;
      };
      var distPointToPoint = function distPointToPoint(_ref, _ref3) {
        var _ref2 = _slicedToArray(_ref, 2);
        var ax = _ref2[0];
        var ay = _ref2[1];
        var _ref32 = _slicedToArray(_ref3, 2);
        var bx = _ref32[0];
        var by = _ref32[1];
        return Math.sqrt(sq(ax - bx) + sq(ay - by));
      };
      var distPointToParabol = function distPointToParabol(a, f) {
        var p = distPointToPoint(a, f);
        return p == 0 ? Infinity : sq(p) / (2 * Math.abs(a[1] - f[1]));
      };
      var circumCenter = function circumCenter(a, b, c) {
        var d = (a[0] - c[0]) * (b[1] - c[1]) - (b[0] - c[0]) * (a[1] - c[1]);
        if (d == 0) return [Infinity, Infinity];
        var xc =
          ((((a[0] - c[0]) * (a[0] + c[0]) + (a[1] - c[1]) * (a[1] + c[1])) / 2) * (b[1] - c[1]) -
            (((b[0] - c[0]) * (b[0] + c[0]) + (b[1] - c[1]) * (b[1] + c[1])) / 2) * (a[1] - c[1])) /
          d;
        var yc =
          ((((b[0] - c[0]) * (b[0] + c[0]) + (b[1] - c[1]) * (b[1] + c[1])) / 2) * (a[0] - c[0]) -
            (((a[0] - c[0]) * (a[0] + c[0]) + (a[1] - c[1]) * (a[1] + c[1])) / 2) * (b[0] - c[0])) /
          d;
        return [xc, yc];
      };
      var parabolsCrossX = function parabolsCrossX(fa, fb, q) {
        if (fa[1] === fb[1]) return [(fa[0] + fb[0]) / 2, (fa[0] + fb[0]) / 2];
        var s1 =
          (fa[1] * fb[0] -
            fa[0] * fb[1] +
            fa[0] * q -
            fb[0] * q +
            Math.sqrt(
              (fa[0] * fa[0] + fa[1] * fa[1] - 2 * fa[0] * fb[0] + fb[0] * fb[0] - 2 * fa[1] * fb[1] + fb[1] * fb[1]) *
                (fa[1] * fb[1] - fa[1] * q - fb[1] * q + q * q)
            )) /
          (fa[1] - fb[1]);
        var s2 =
          (fa[1] * fb[0] -
            fa[0] * fb[1] +
            fa[0] * q -
            fb[0] * q -
            Math.sqrt(
              (fa[0] * fa[0] + fa[1] * fa[1] - 2 * fa[0] * fb[0] + fb[0] * fb[0] - 2 * fa[1] * fb[1] + fb[1] * fb[1]) *
                (fa[1] * fb[1] - fa[1] * q - fb[1] * q + q * q)
            )) /
          (fa[1] - fb[1]);
        return s1 < s2 ? [s1, s2] : [s2, s1];
      };
      var doHalflinesCross = function doHalflinesCross(sa, sb) {
        var approx = arguments.length <= 2 || arguments[2] === undefined ? 1e-10 : arguments[2];
        var dx = sb.ps[0] - sa.ps[0];
        var dy = sb.ps[1] - sa.ps[1];
        if (sa.m == Infinity) return sa.hp * (sb.m * dx - dy) <= approx && sb.vec[0] * dx <= approx;
        if (sb.m == Infinity) return sb.hp * (sa.m * dx - dy) >= -approx && sa.vec[0] * dx >= -approx;
        var det = sb.vec[0] * sa.vec[1] - sb.vec[1] * sa.vec[0];
        if (det === 0) return false;
        var u = (dy * sb.vec[0] - dx * sb.vec[1]) / det;
        var v = (dy * sa.vec[0] - dx * sa.vec[1]) / det;
        return (u >= -approx && v >= approx) || (u >= approx && v >= -approx);
      };
      var matrixTransform = function matrixTransform(points, matrix) {
        return points.map(function (point) {
          return {
            x: point.x * matrix[0] + point.y * matrix[2] + matrix[4],
            y: point.x * matrix[1] + point.y * matrix[3] + matrix[5],
          };
        });
      };
      var transformEllipse = function transformEllipse(rx, ry, ax, m) {
        var torad = Math.PI / 180;
        var epsilon = 1e-10;
        var c = Math.cos(ax * torad),
          s = Math.sin(ax * torad);
        var ma = [rx * (m[0] * c + m[2] * s), rx * (m[1] * c + m[3] * s), ry * (-m[0] * s + m[2] * c), ry * (-m[1] * s + m[3] * c)];
        var J = ma[0] * ma[0] + ma[2] * ma[2],
          K = ma[1] * ma[1] + ma[3] * ma[3];
        var D =
          ((ma[0] - ma[3]) * (ma[0] - ma[3]) + (ma[2] + ma[1]) * (ma[2] + ma[1])) * ((ma[0] + ma[3]) * (ma[0] + ma[3]) + (ma[2] - ma[1]) * (ma[2] - ma[1]));
        var JK = (J + K) / 2;
        if (D < epsilon * JK) {
          return { rx: Math.sqrt(JK), ry: Math.sqrt(JK), ax: 0, isDegenerate: false };
        }
        var L = ma[0] * ma[1] + ma[2] * ma[3];
        D = Math.sqrt(D);
        var l1 = JK + D / 2,
          l2 = JK - D / 2;
        var newAx = undefined,
          newRx = undefined,
          newRy = undefined;
        newAx =
          Math.abs(L) < epsilon && Math.abs(l1 - K) < epsilon ? 90 : (Math.atan(Math.abs(L) > Math.abs(l1 - K) ? (l1 - J) / L : L / (l1 - K)) * 180) / Math.PI;
        if (newAx >= 0) {
          newRx = Math.sqrt(l1);
          newRy = Math.sqrt(l2);
        } else {
          newAx += 90;
          newRx = Math.sqrt(l2);
          newRy = Math.sqrt(l1);
        }
        return { rx: newRx, ry: newRy, ax: newAx, isDegenerate: newRx < epsilon * newRy || newRy < epsilon * newRx };
      };
      exports['default'] = {
        distPointToPoint: distPointToPoint,
        distPointToParabol: distPointToParabol,
        circumCenter: circumCenter,
        parabolsCrossX: parabolsCrossX,
        doHalflinesCross: doHalflinesCross,
        matrixTransform: matrixTransform,
        transformEllipse: transformEllipse,
      };
      module.exports = exports['default'];
    },
    function (module, exports, __webpack_require__) {
      'use strict';
      Object.defineProperty(exports, '__esModule', { value: true });
      var _slicedToArray = (function () {
        function sliceIterator(arr, i) {
          var _arr = [];
          var _n = true;
          var _d = false;
          var _e = undefined;
          try {
            for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
              _arr.push(_s.value);
              if (i && _arr.length === i) break;
            }
          } catch (err) {
            _d = true;
            _e = err;
          } finally {
            try {
              if (!_n && _i['return']) _i['return']();
            } finally {
              if (_d) throw _e;
            }
          }
          return _arr;
        }

        return function (arr, i) {
          if (Array.isArray(arr)) {
            return arr;
          } else if (Symbol.iterator in Object(arr)) {
            return sliceIterator(arr, i);
          } else {
            throw new TypeError('Invalid attempt to destructure non-iterable instance');
          }
        };
      })();
      var _geom = __webpack_require__(50);
      var Path = function Path(init) {
        var _instructions = init || [];
        var push = function push(arr, el) {
          var copy = arr.slice(0, arr.length);
          copy.push(el);
          return copy;
        };
        var areEqualPoints = function areEqualPoints(_ref, _ref3) {
          var _ref2 = _slicedToArray(_ref, 2);
          var a1 = _ref2[0];
          var b1 = _ref2[1];
          var _ref32 = _slicedToArray(_ref3, 2);
          var a2 = _ref32[0];
          var b2 = _ref32[1];
          return a1 === a2 && b1 === b2;
        };
        var trimZeros = function trimZeros(string, char) {
          var l = string.length;
          while (string.charAt(l - 1) === '0') {
            l = l - 1;
          }
          if (string.charAt(l - 1) === '.') {
            l = l - 1;
          }
          return string.substr(0, l);
        };
        var round = function round(number, digits) {
          var str = number.toFixed(digits);
          return trimZeros(str);
        };
        var printInstrunction = function printInstrunction(_ref4) {
          var command = _ref4.command;
          var params = _ref4.params;
          var numbers = params.map(function (param) {
            return round(par
Download .txt
gitextract_8lrq12pm/

├── .editorconfig
├── .gitattributes
├── .gitignore
├── README.md
├── admin/
│   └── src/
│       ├── components/
│       │   ├── Initializer/
│       │   │   └── index.js
│       │   └── PluginIcon/
│       │       └── index.js
│       ├── containers/
│       │   ├── App/
│       │   │   └── index.js
│       │   ├── HomePage/
│       │   │   └── index.js
│       │   └── Initializer/
│       │       └── index.js
│       ├── index.js
│       ├── pages/
│       │   ├── App/
│       │   │   └── index.js
│       │   └── HomePage/
│       │       ├── index.js
│       │       └── main.css
│       ├── pluginId.js
│       ├── translations/
│       │   ├── en.json
│       │   └── fr.json
│       └── utils/
│           ├── dagreLayout.js
│           ├── erChart.js
│           ├── getTrad.js
│           ├── requests.js
│           ├── storm-react-diagrams.js
│           └── trChart.js
├── package.json
├── server/
│   ├── config/
│   │   └── index.js
│   ├── controllers/
│   │   ├── entity-relationship-chart.js
│   │   └── index.js
│   ├── index.js
│   └── routes/
│       ├── index.js
│       └── routes.json
├── strapi-admin.js
└── strapi-server.js
Download .txt
SYMBOL INDEX (116 symbols across 8 files)

FILE: admin/src/index.js
  method register (line 10) | register(app) {
  method bootstrap (line 39) | bootstrap(app) {}
  method registerTrads (line 40) | async registerTrads({ locales }) {

FILE: admin/src/pages/HomePage/index.js
  function FeatherDatabase (line 42) | function FeatherDatabase(props) {
  function FeatherBox (line 48) | function FeatherBox(props) {
  function updateQuery (line 54) | function updateQuery(key, value) {
  function getData (line 86) | async function getData() {

FILE: admin/src/utils/dagreLayout.js
  function dagreLayout (line 6) | function dagreLayout(model) {

FILE: admin/src/utils/erChart.js
  function drawEntityNodes (line 13) | function drawEntityNodes(data, options) {

FILE: admin/src/utils/requests.js
  function getEntitiesRelationData (line 5) | async function getEntitiesRelationData() {
  function getTablesRelationData (line 8) | async function getTablesRelationData() {

FILE: admin/src/utils/storm-react-diagrams.js
  function __webpack_require__ (line 20) | function __webpack_require__(moduleId) {
  function __ (line 85) | function __() {
  function BaseWidget (line 107) | function BaseWidget(name, props) {
  function backtrace (line 127) | function backtrace(node) {
  function biBacktrace (line 138) | function biBacktrace(nodeA, nodeB) {
  function pathLength (line 146) | function pathLength(path) {
  function interpolate (line 165) | function interpolate(x0, y0, x1, y1) {
  function expandPath (line 199) | function expandPath(path) {
  function smoothenPath (line 226) | function smoothenPath(grid, path) {
  function compressPath (line 272) | function compressPath(path) {
  function __ (line 332) | function __() {
  function PointModel (line 345) | function PointModel(link, points) {
  function __ (line 413) | function __() {
  function BaseModel (line 436) | function BaseModel(type, id) {
  function Toolkit (line 501) | function Toolkit() {}
  function AbstractFactory (line 567) | function AbstractFactory(name) {
  function __ (line 595) | function __() {
  function NodeModel (line 608) | function NodeModel(nodeType, id) {
  function BaseAction (line 741) | function BaseAction(mouseX, mouseY) {
  function __ (line 768) | function __() {
  function PortModel (line 781) | function PortModel(name, type, id, maximumLinks) {
  function BaseEntity (line 879) | function BaseEntity(id) {
  function JumpPointFinderBase (line 970) | function JumpPointFinderBase(opt) {
  function PathFinding (line 1063) | function PathFinding(diagramEngine) {
  function __ (line 1134) | function __() {
  function LabelModel (line 1147) | function LabelModel(type, id) {
  function __ (line 1183) | function __() {
  function DefaultLabelModel (line 1196) | function DefaultLabelModel() {
  function __ (line 1233) | function __() {
  function DefaultLinkModel (line 1258) | function DefaultLinkModel(type) {
  function __ (line 1327) | function __() {
  function DefaultPortModel (line 1341) | function DefaultPortModel(isInput, name, label, id) {
  function __ (line 1396) | function __() {
  function LinkModel (line 1420) | function LinkModel(linkType, id) {
  function BiAStarFinder (line 1631) | function BiAStarFinder(opt) {
  function AStarFinder (line 1753) | function AStarFinder(opt) {
  function Node (line 1835) | function Node(x, y, walkable) {
  function __ (line 1860) | function __() {
  function NodeWidget (line 1883) | function NodeWidget(props) {
  function __ (line 1926) | function __() {
  function NodeLayerWidget (line 1951) | function NodeLayerWidget(props) {
  function __ (line 2014) | function __() {
  function LinkWidget (line 2026) | function LinkWidget(props) {
  function __ (line 2059) | function __() {
  function LinkLayerWidget (line 2084) | function LinkLayerWidget(props) {
  function __ (line 2160) | function __() {
  function SelectingAction (line 2172) | function SelectingAction(mouseX, mouseY) {
  function __ (line 2220) | function __() {
  function MoveItemsAction (line 2232) | function MoveItemsAction(mouseX, mouseY, diagramEngine) {
  function __ (line 2267) | function __() {
  function MoveCanvasAction (line 2279) | function MoveCanvasAction(mouseX, mouseY, diagramModel) {
  function __ (line 2307) | function __() {
  function AbstractNodeFactory (line 2319) | function AbstractNodeFactory() {
  function __ (line 2344) | function __() {
  function PortWidget (line 2367) | function PortWidget(props) {
  function __ (line 2413) | function __() {
  function DefaultPortLabel (line 2437) | function DefaultPortLabel(props) {
  function __ (line 2473) | function __() {
  function DefaultNodeWidget (line 2498) | function DefaultNodeWidget(props) {
  function __ (line 2541) | function __() {
  function AbstractLinkFactory (line 2553) | function AbstractLinkFactory() {
  function __ (line 2578) | function __() {
  function DefaultLinkWidget (line 2605) | function DefaultLinkWidget(props) {
  function __ (line 2911) | function __() {
  function DefaultNodeModel (line 2926) | function DefaultNodeModel(name, color) {
  function __ (line 2984) | function __() {
  function DefaultLabelWidget (line 3007) | function DefaultLabelWidget(props) {
  function __ (line 3035) | function __() {
  function AbstractLabelFactory (line 3047) | function AbstractLabelFactory() {
  function __ (line 3072) | function __() {
  function DefaultLabelFactory (line 3087) | function DefaultLabelFactory() {
  function __ (line 3118) | function __() {
  function AbstractPortFactory (line 3130) | function AbstractPortFactory() {
  function __ (line 3155) | function __() {
  function DefaultPortFactory (line 3168) | function DefaultPortFactory() {
  function __ (line 3196) | function __() {
  function DiagramModel (line 3223) | function DiagramModel() {
  function __export (line 3481) | function __export(m) {
  function __ (line 3543) | function __() {
  function DiagramWidget (line 3576) | function DiagramWidget(props) {
  function __ (line 3987) | function __() {
  function DefaultNodeFactory (line 4002) | function DefaultNodeFactory() {
  function __ (line 4033) | function __() {
  function DefaultLinkFactory (line 4048) | function DefaultLinkFactory() {
  function __ (line 4087) | function __() {
  function DiagramEngine (line 4108) | function DiagramEngine() {
  function sliceIterator (line 4501) | function sliceIterator(arr, i) {
  function sliceIterator (line 4655) | function sliceIterator(arr, i) {
  function JPFMoveDiagonallyIfAtMostOneObstacle (line 5051) | function JPFMoveDiagonallyIfAtMostOneObstacle(opt) {
  function JPFMoveDiagonallyIfNoObstacles (line 5169) | function JPFMoveDiagonallyIfNoObstacles(opt) {
  function JPFAlwaysMoveDiagonally (line 5297) | function JPFAlwaysMoveDiagonally(opt) {
  function JPFNeverMoveDiagonally (line 5411) | function JPFNeverMoveDiagonally(opt) {
  function JumpPointFinder (line 5506) | function JumpPointFinder(opt) {
  function IDAStarFinder (line 5527) | function IDAStarFinder(opt) {
  function BiDijkstraFinder (line 5621) | function BiDijkstraFinder(opt) {
  function BiBreadthFirstFinder (line 5636) | function BiBreadthFirstFinder(opt) {
  function BiBestFirstFinder (line 5720) | function BiBestFirstFinder(opt) {
  function DijkstraFinder (line 5735) | function DijkstraFinder(opt) {
  function BreadthFirstFinder (line 5750) | function BreadthFirstFinder(opt) {
  function BestFirstFinder (line 5804) | function BestFirstFinder(opt) {
  function Grid (line 5820) | function Grid(width_or_matrix, height, matrix) {
  function Heap (line 6186) | function Heap(cmp) {
  function match (line 6276) | function match(el, selector) {

FILE: admin/src/utils/trChart.js
  function drawDatabaseNodes (line 13) | function drawDatabaseNodes(data, options) {

FILE: server/config/index.js
  method validator (line 17) | validator() {}
Condensed preview — 31 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (274K chars).
[
  {
    "path": ".editorconfig",
    "chars": 100,
    "preview": "root = true\n\n[*]\nend_of_line = lf\ninsert_final_newline = false\nindent_style = space\nindent_size = 2\n"
  },
  {
    "path": ".gitattributes",
    "chars": 1421,
    "preview": "# From https://github.com/Danimoth/gitattributes/blob/master/Web.gitattributes\n\n# Handle line endings automatically for "
  },
  {
    "path": ".gitignore",
    "chars": 134,
    "preview": "# Don't check auto-generated stuff into git\ncoverage\nnode_modules\nstats.json\npackage-lock.json\n\n# Cruft\n.DS_Store\nnpm-de"
  },
  {
    "path": "README.md",
    "chars": 1438,
    "preview": "# Strapi plugin Entity Relationship Chart\n\nPlugin displays Entity Relationship Diagram of all Strapi models, fields and "
  },
  {
    "path": "admin/src/components/Initializer/index.js",
    "chars": 417,
    "preview": "/**\n *\n * Initializer\n *\n */\n\nimport { useEffect, useRef } from 'react';\nimport PropTypes from 'prop-types';\nimport plug"
  },
  {
    "path": "admin/src/components/PluginIcon/index.js",
    "chars": 174,
    "preview": "/**\n *\n * PluginIcon\n *\n */\n\nimport React from 'react';\nimport OneToMany from '@strapi/icons/OneToMany';\n\nconst PluginIc"
  },
  {
    "path": "admin/src/containers/App/index.js",
    "chars": 591,
    "preview": "/**\n *\n * This component is the skeleton around the actual pages, and should only\n * contain code that should be seen on"
  },
  {
    "path": "admin/src/containers/HomePage/index.js",
    "chars": 307,
    "preview": "/*\n *\n * HomePage\n *\n */\n\nimport React, { memo } from 'react';\n// import PropTypes from 'prop-types';\nimport pluginId fr"
  },
  {
    "path": "admin/src/containers/Initializer/index.js",
    "chars": 417,
    "preview": "/**\n *\n * Initializer\n *\n */\n\nimport { useEffect, useRef } from 'react';\nimport PropTypes from 'prop-types';\nimport plug"
  },
  {
    "path": "admin/src/index.js",
    "chars": 1580,
    "preview": "import { prefixPluginTranslations } from '@strapi/helper-plugin';\nimport pluginPkg from '../../package.json';\nimport plu"
  },
  {
    "path": "admin/src/pages/App/index.js",
    "chars": 591,
    "preview": "/**\n *\n * This component is the skeleton around the actual pages, and should only\n * contain code that should be seen on"
  },
  {
    "path": "admin/src/pages/HomePage/index.js",
    "chars": 5756,
    "preview": "import React, { memo, useEffect, useState } from 'react';\nimport styled from 'styled-components'\nimport {\n  useParams\n} "
  },
  {
    "path": "admin/src/pages/HomePage/main.css",
    "chars": 644,
    "preview": ".srd-diagram {\n  height: 80vh;\n  overflow: hidden;\n}\n\n/* .srd-default-link path {\n  stroke: #000;\n} */\n\n.erc-header-titl"
  },
  {
    "path": "admin/src/pluginId.js",
    "chars": 143,
    "preview": "const pluginPkg = require('../../package.json');\n\nconst pluginId = pluginPkg.name.replace(/^strapi-plugin-/i, '');\n\nmodu"
  },
  {
    "path": "admin/src/translations/en.json",
    "chars": 3,
    "preview": "{}\n"
  },
  {
    "path": "admin/src/translations/fr.json",
    "chars": 3,
    "preview": "{}\n"
  },
  {
    "path": "admin/src/utils/dagreLayout.js",
    "chars": 1422,
    "preview": "import dagre from '@dagrejs/dagre';\nimport { \n  PointModel,\n} from './storm-react-diagrams';\n\nexport function dagreLayou"
  },
  {
    "path": "admin/src/utils/erChart.js",
    "chars": 3464,
    "preview": "\nimport _ from 'lodash';\nimport  { \n  DiagramEngine, \n  DiagramModel, \n  DefaultNodeModel,\n  DefaultNodeFactory, \n  Defa"
  },
  {
    "path": "admin/src/utils/getTrad.js",
    "chars": 107,
    "preview": "import pluginId from '../pluginId';\n\nconst getTrad = (id) => `${pluginId}.${id}`;\n\nexport default getTrad;\n"
  },
  {
    "path": "admin/src/utils/requests.js",
    "chars": 284,
    "preview": "\nimport { request } from '@strapi/helper-plugin';\nimport pluginId from '../pluginId';\n\nexport async function getEntities"
  },
  {
    "path": "admin/src/utils/storm-react-diagrams.js",
    "chars": 235373,
    "preview": "/**\n * This is a copy of storm-react-diagrams/dist/main.js with 2 replaces:\n * '\"_\"' replaced as 'lodash'\n * 'var _ = __"
  },
  {
    "path": "admin/src/utils/trChart.js",
    "chars": 6713,
    "preview": "\nimport _ from 'lodash';\nimport  { \n  DiagramEngine, \n  DiagramModel, \n  DefaultNodeModel,\n  DefaultNodeFactory, \n  Defa"
  },
  {
    "path": "package.json",
    "chars": 1254,
    "preview": "{\n  \"name\": \"strapi-plugin-entity-relationship-chart\",\n  \"version\": \"4.14.6\",\n  \"description\": \"Plugin displays Entity R"
  },
  {
    "path": "server/config/index.js",
    "chars": 376,
    "preview": "'use strict';\n\nmodule.exports = {\n  default: {\n    exclude: [\n      // \"strapi::core-store\",\n      // \"webhook\",\n      /"
  },
  {
    "path": "server/controllers/entity-relationship-chart.js",
    "chars": 1165,
    "preview": "\"use strict\";\n\n/**\n * entity-relationship-chart.js controller\n *\n * @description: A set of functions called \"actions\" of"
  },
  {
    "path": "server/controllers/index.js",
    "chars": 126,
    "preview": "'use strict';\n\nconst erc = require('./entity-relationship-chart');\n\nmodule.exports = {\n  'entity-relationship-chart': er"
  },
  {
    "path": "server/index.js",
    "chars": 191,
    "preview": "'use strict';\n\nconst config = require('./config');\nconst controllers = require('./controllers');\nconst routes = require("
  },
  {
    "path": "server/routes/index.js",
    "chars": 334,
    "preview": "module.exports = [\n  {\n    method: 'GET',\n    path: '/er-data',\n    handler: 'entity-relationship-chart.getEntitiesRelat"
  },
  {
    "path": "server/routes/routes.json",
    "chars": 188,
    "preview": "{\n  \"routes\": [\n    {\n      \"method\": \"GET\",\n      \"path\": \"/er-data\",\n      \"handler\": \"entity-relationship-chart.getER"
  },
  {
    "path": "strapi-admin.js",
    "chars": 64,
    "preview": "'use strict';\n\nmodule.exports = require('./admin/src').default;\n"
  },
  {
    "path": "strapi-server.js",
    "chars": 53,
    "preview": "'use strict';\n\nmodule.exports = require('./server');\n"
  }
]

About this extraction

This page contains the full source code of the node-vision/strapi-plugin-entity-relationship-chart GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 31 files (258.6 KB), approximately 61.8k tokens, and a symbol index with 116 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!