diagram-js-minimap.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. import {
  2. import_css
  3. } from "./chunk-PGYCW7PW.js";
  4. import {
  5. require_hammer
  6. } from "./chunk-NAPKCKEX.js";
  7. import {
  8. attr as attr2,
  9. classes as classes2,
  10. event,
  11. query
  12. } from "./chunk-XZ2PVW7M.js";
  13. import {
  14. append,
  15. attr,
  16. classes,
  17. clear,
  18. clone,
  19. create,
  20. remove
  21. } from "./chunk-IQOBXLIK.js";
  22. import {
  23. assign,
  24. every,
  25. isNumber,
  26. isObject
  27. } from "./chunk-4AK4GF4H.js";
  28. import {
  29. __toESM
  30. } from "./chunk-2LSFTFF7.js";
  31. // node_modules/.pnpm/diagram-js-minimap@4.1.0/node_modules/diagram-js-minimap/dist/index.esm.js
  32. var import_hammerjs = __toESM(require_hammer());
  33. // node_modules/.pnpm/diagram-js@11.9.1/node_modules/diagram-js/lib/util/GraphicsUtil.js
  34. function getVisual(gfx) {
  35. return gfx.childNodes[0];
  36. }
  37. // node_modules/.pnpm/diagram-js-minimap@4.1.0/node_modules/diagram-js-minimap/dist/index.esm.js
  38. var MINIMAP_VIEWBOX_PADDING = 50;
  39. var RANGE = { min: 0.2, max: 4 };
  40. var NUM_STEPS = 10;
  41. var DELTA_THRESHOLD = 0.1;
  42. var LOW_PRIORITY = 250;
  43. function Minimap(config, injector, eventBus, canvas, elementRegistry) {
  44. var self = this;
  45. this._canvas = canvas;
  46. this._elementRegistry = elementRegistry;
  47. this._eventBus = eventBus;
  48. this._injector = injector;
  49. this._state = {
  50. isOpen: void 0,
  51. isDragging: false,
  52. initialDragPosition: null,
  53. offsetViewport: null,
  54. cachedViewbox: null,
  55. dragger: null,
  56. svgClientRect: null,
  57. parentClientRect: null,
  58. zoomDelta: 0
  59. };
  60. this._init();
  61. var documentManager = new import_hammerjs.default.Manager(document);
  62. documentManager.add(new import_hammerjs.default.Pan());
  63. documentManager.on("panmove", onMousemove);
  64. documentManager.on("panend", onMouseup);
  65. var svgManager = new import_hammerjs.default.Manager(this._svg);
  66. svgManager.add(new import_hammerjs.default.Pan());
  67. svgManager.on("panstart", mousedown(true));
  68. svgManager.add(new import_hammerjs.default.Tap());
  69. svgManager.on("tap", function(event2) {
  70. centerViewbox(getPoint(event2));
  71. });
  72. var viewportDomManager = new import_hammerjs.default.Manager(this._viewportDom);
  73. viewportDomManager.add(new import_hammerjs.default.Pan());
  74. viewportDomManager.on("panstart", mousedown(false));
  75. this.toggle(config && config.open || false);
  76. function centerViewbox(point) {
  77. if (!self._state._svgClientRect || isZeroDimensional(self._state._svgClientRect)) {
  78. self._state._svgClientRect = self._svg.getBoundingClientRect();
  79. }
  80. var diagramPoint = mapMousePositionToDiagramPoint({
  81. x: point.x - self._state._svgClientRect.left,
  82. y: point.y - self._state._svgClientRect.top
  83. }, self._svg, self._lastViewbox);
  84. setViewboxCenteredAroundPoint(diagramPoint, self._canvas);
  85. self._update();
  86. }
  87. function mousedown(center) {
  88. return function onMousedown(event$1) {
  89. var point = getPoint(event$1);
  90. if (!self._state._svgClientRect || isZeroDimensional(self._state._svgClientRect)) {
  91. self._state._svgClientRect = self._svg.getBoundingClientRect();
  92. }
  93. if (center) {
  94. centerViewbox(point);
  95. }
  96. var diagramPoint = mapMousePositionToDiagramPoint({
  97. x: point.x - self._state._svgClientRect.left,
  98. y: point.y - self._state._svgClientRect.top
  99. }, self._svg, self._lastViewbox);
  100. var viewbox = canvas.viewbox();
  101. var offsetViewport = getOffsetViewport(diagramPoint, viewbox);
  102. var initialViewportDomRect = self._viewportDom.getBoundingClientRect();
  103. var offsetViewportDom = {
  104. x: point.x - initialViewportDomRect.left + 1,
  105. y: point.y - initialViewportDomRect.top + 1
  106. };
  107. assign(self._state, {
  108. cachedViewbox: viewbox,
  109. initialDragPosition: {
  110. x: point.x,
  111. y: point.y
  112. },
  113. isDragging: true,
  114. offsetViewport,
  115. offsetViewportDom,
  116. viewportClientRect: self._viewport.getBoundingClientRect(),
  117. parentClientRect: self._parent.getBoundingClientRect()
  118. });
  119. event.bind(document, "mousemove", onMousemove);
  120. event.bind(document, "mouseup", onMouseup);
  121. };
  122. }
  123. function onMousemove(event2) {
  124. var point = getPoint(event2);
  125. if (self._state.isDragging) {
  126. if (!self._state._svgClientRect || isZeroDimensional(self._state._svgClientRect)) {
  127. self._state._svgClientRect = self._svg.getBoundingClientRect();
  128. }
  129. var offsetViewportDom = self._state.offsetViewportDom, viewportClientRect = self._state.viewportClientRect, parentClientRect = self._state.parentClientRect;
  130. assign(self._viewportDom.style, {
  131. top: point.y - offsetViewportDom.y - parentClientRect.top + "px",
  132. left: point.x - offsetViewportDom.x - parentClientRect.left + "px"
  133. });
  134. var clipPath = getOverlayClipPath(parentClientRect, {
  135. top: point.y - offsetViewportDom.y - parentClientRect.top,
  136. left: point.x - offsetViewportDom.x - parentClientRect.left,
  137. width: viewportClientRect.width,
  138. height: viewportClientRect.height
  139. });
  140. assign(self._overlay.style, {
  141. clipPath
  142. });
  143. var diagramPoint = mapMousePositionToDiagramPoint({
  144. x: point.x - self._state._svgClientRect.left,
  145. y: point.y - self._state._svgClientRect.top
  146. }, self._svg, self._lastViewbox);
  147. setViewboxCenteredAroundPoint({
  148. x: diagramPoint.x - self._state.offsetViewport.x,
  149. y: diagramPoint.y - self._state.offsetViewport.y
  150. }, self._canvas);
  151. }
  152. }
  153. function onMouseup(event$1) {
  154. var point = getPoint(event$1);
  155. if (self._state.isDragging) {
  156. if (self._state.initialDragPosition.x === point.x && self._state.initialDragPosition.y === point.y) {
  157. centerViewbox(event$1);
  158. }
  159. self._update();
  160. assign(self._state, {
  161. cachedViewbox: null,
  162. initialDragPosition: null,
  163. isDragging: false,
  164. offsetViewport: null,
  165. offsetViewportDom: null
  166. });
  167. event.unbind(document, "mousemove", onMousemove);
  168. event.unbind(document, "mouseup", onMouseup);
  169. }
  170. }
  171. event.bind(this._viewportDom, "mousedown", mousedown(false));
  172. event.bind(this._svg, "mousedown", mousedown(true));
  173. event.bind(this._parent, "wheel", function(event2) {
  174. event2.preventDefault();
  175. event2.stopPropagation();
  176. if (!event2.ctrlKey) {
  177. return;
  178. }
  179. if (!self._state._svgClientRect || isZeroDimensional(self._state._svgClientRect)) {
  180. self._state._svgClientRect = self._svg.getBoundingClientRect();
  181. }
  182. if (!isPointInside(event2, self._state._svgClientRect)) {
  183. return;
  184. }
  185. var factor = event2.deltaMode === 0 ? 0.02 : 0.32;
  186. var delta = Math.sqrt(
  187. Math.pow(event2.deltaY, 2) + Math.pow(event2.deltaX, 2)
  188. ) * sign(event2.deltaY) * -factor;
  189. self._state.zoomDelta += delta;
  190. if (Math.abs(self._state.zoomDelta) > DELTA_THRESHOLD) {
  191. var direction = delta > 0 ? 1 : -1;
  192. var currentLinearZoomLevel = Math.log(canvas.zoom()) / Math.log(10);
  193. var stepSize = getStepSize(RANGE, NUM_STEPS * 2);
  194. var newLinearZoomLevel = Math.round(currentLinearZoomLevel / stepSize) * stepSize;
  195. newLinearZoomLevel += stepSize * direction;
  196. var newLogZoomLevel = Math.pow(10, newLinearZoomLevel);
  197. canvas.zoom(cap(RANGE, newLogZoomLevel), diagramPoint);
  198. self._state.zoomDelta = 0;
  199. var diagramPoint = mapMousePositionToDiagramPoint({
  200. x: event2.clientX - self._state._svgClientRect.left,
  201. y: event2.clientY - self._state._svgClientRect.top
  202. }, self._svg, self._lastViewbox);
  203. setViewboxCenteredAroundPoint(diagramPoint, self._canvas);
  204. self._update();
  205. }
  206. });
  207. event.bind(this._toggle, "click", function(event2) {
  208. event2.preventDefault();
  209. event2.stopPropagation();
  210. self.toggle();
  211. });
  212. eventBus.on(["shape.added", "connection.added"], function(context) {
  213. var element = context.element;
  214. self._addElement(element);
  215. self._update();
  216. });
  217. eventBus.on(["shape.removed", "connection.removed"], function(context) {
  218. var element = context.element;
  219. self._removeElement(element);
  220. self._update();
  221. });
  222. eventBus.on("elements.changed", LOW_PRIORITY, function(context) {
  223. var elements = context.elements;
  224. elements.forEach(function(element) {
  225. self._updateElement(element);
  226. });
  227. self._update();
  228. });
  229. eventBus.on("element.updateId", function(context) {
  230. var element = context.element, newId = context.newId;
  231. self._updateElementId(element, newId);
  232. });
  233. eventBus.on("canvas.viewbox.changed", function() {
  234. if (!self._state.isDragging) {
  235. self._update();
  236. }
  237. });
  238. eventBus.on("canvas.resized", function() {
  239. if (document.body.contains(self._parent)) {
  240. if (!self._state.isDragging) {
  241. self._update();
  242. }
  243. self._state._svgClientRect = self._svg.getBoundingClientRect();
  244. }
  245. });
  246. eventBus.on(["root.set", "plane.set"], function(event2) {
  247. self._clear();
  248. var element = event2.element || event2.plane.rootElement;
  249. element.children.forEach(function(el) {
  250. self._addElement(el);
  251. });
  252. self._update();
  253. });
  254. }
  255. Minimap.$inject = [
  256. "config.minimap",
  257. "injector",
  258. "eventBus",
  259. "canvas",
  260. "elementRegistry"
  261. ];
  262. Minimap.prototype._init = function() {
  263. var canvas = this._canvas, container = canvas.getContainer();
  264. var parent = this._parent = document.createElement("div");
  265. classes2(parent).add("djs-minimap");
  266. container.appendChild(parent);
  267. var toggle = this._toggle = document.createElement("div");
  268. classes2(toggle).add("toggle");
  269. parent.appendChild(toggle);
  270. var map2 = this._map = document.createElement("div");
  271. classes2(map2).add("map");
  272. parent.appendChild(map2);
  273. var svg = this._svg = create("svg");
  274. attr(svg, { width: "100%", height: "100%" });
  275. append(map2, svg);
  276. var elementsGroup = this._elementsGroup = create("g");
  277. append(svg, elementsGroup);
  278. var viewportGroup = this._viewportGroup = create("g");
  279. append(svg, viewportGroup);
  280. var viewport = this._viewport = create("rect");
  281. classes(viewport).add("viewport");
  282. append(viewportGroup, viewport);
  283. event.bind(parent, "mousedown", function(event2) {
  284. event2.stopPropagation();
  285. });
  286. var viewportDom = this._viewportDom = document.createElement("div");
  287. classes2(viewportDom).add("viewport-dom");
  288. this._parent.appendChild(viewportDom);
  289. var overlay = this._overlay = document.createElement("div");
  290. classes2(overlay).add("overlay");
  291. this._parent.appendChild(overlay);
  292. };
  293. Minimap.prototype._update = function() {
  294. var viewbox = this._canvas.viewbox(), innerViewbox = viewbox.inner, outerViewbox = viewbox.outer;
  295. if (!validViewbox(viewbox)) {
  296. return;
  297. }
  298. var x, y, width, height;
  299. var widthDifference = outerViewbox.width - innerViewbox.width, heightDifference = outerViewbox.height - innerViewbox.height;
  300. if (innerViewbox.width < outerViewbox.width) {
  301. x = innerViewbox.x - widthDifference / 2;
  302. width = outerViewbox.width;
  303. if (innerViewbox.x + innerViewbox.width < outerViewbox.width) {
  304. x = Math.min(0, innerViewbox.x);
  305. }
  306. } else {
  307. x = innerViewbox.x;
  308. width = innerViewbox.width;
  309. }
  310. if (innerViewbox.height < outerViewbox.height) {
  311. y = innerViewbox.y - heightDifference / 2;
  312. height = outerViewbox.height;
  313. if (innerViewbox.y + innerViewbox.height < outerViewbox.height) {
  314. y = Math.min(0, innerViewbox.y);
  315. }
  316. } else {
  317. y = innerViewbox.y;
  318. height = innerViewbox.height;
  319. }
  320. x = x - MINIMAP_VIEWBOX_PADDING;
  321. y = y - MINIMAP_VIEWBOX_PADDING;
  322. width = width + MINIMAP_VIEWBOX_PADDING * 2;
  323. height = height + MINIMAP_VIEWBOX_PADDING * 2;
  324. this._lastViewbox = {
  325. x,
  326. y,
  327. width,
  328. height
  329. };
  330. attr(this._svg, {
  331. viewBox: x + ", " + y + ", " + width + ", " + height
  332. });
  333. attr(this._viewport, {
  334. x: viewbox.x,
  335. y: viewbox.y,
  336. width: viewbox.width,
  337. height: viewbox.height
  338. });
  339. var parentClientRect = this._state._parentClientRect = this._parent.getBoundingClientRect();
  340. var viewportClientRect = this._viewport.getBoundingClientRect();
  341. var withoutParentOffset = {
  342. top: viewportClientRect.top - parentClientRect.top,
  343. left: viewportClientRect.left - parentClientRect.left,
  344. width: viewportClientRect.width,
  345. height: viewportClientRect.height
  346. };
  347. assign(this._viewportDom.style, {
  348. top: withoutParentOffset.top + "px",
  349. left: withoutParentOffset.left + "px",
  350. width: withoutParentOffset.width + "px",
  351. height: withoutParentOffset.height + "px"
  352. });
  353. var clipPath = getOverlayClipPath(parentClientRect, withoutParentOffset);
  354. assign(this._overlay.style, {
  355. clipPath
  356. });
  357. };
  358. Minimap.prototype.open = function() {
  359. assign(this._state, { isOpen: true });
  360. classes2(this._parent).add("open");
  361. var translate = this._injector.get("translate", false) || function(s) {
  362. return s;
  363. };
  364. attr2(this._toggle, "title", translate("Close minimap"));
  365. this._update();
  366. this._eventBus.fire("minimap.toggle", { open: true });
  367. };
  368. Minimap.prototype.close = function() {
  369. assign(this._state, { isOpen: false });
  370. classes2(this._parent).remove("open");
  371. var translate = this._injector.get("translate", false) || function(s) {
  372. return s;
  373. };
  374. attr2(this._toggle, "title", translate("Open minimap"));
  375. this._eventBus.fire("minimap.toggle", { open: false });
  376. };
  377. Minimap.prototype.toggle = function(open) {
  378. var currentOpen = this.isOpen();
  379. if (typeof open === "undefined") {
  380. open = !currentOpen;
  381. }
  382. if (open == currentOpen) {
  383. return;
  384. }
  385. if (open) {
  386. this.open();
  387. } else {
  388. this.close();
  389. }
  390. };
  391. Minimap.prototype.isOpen = function() {
  392. return this._state.isOpen;
  393. };
  394. Minimap.prototype._updateElement = function(element) {
  395. try {
  396. if (element.parent !== void 0 && element.parent !== null) {
  397. this._removeElement(element);
  398. this._addElement(element);
  399. }
  400. } catch (error) {
  401. console.warn("Minimap#_updateElement errored", error);
  402. }
  403. };
  404. Minimap.prototype._updateElementId = function(element, newId) {
  405. try {
  406. var elementGfx = query("#" + (0, import_css.default)(element.id), this._elementsGroup);
  407. if (elementGfx) {
  408. elementGfx.id = newId;
  409. }
  410. } catch (error) {
  411. console.warn("Minimap#_updateElementId errored", error);
  412. }
  413. };
  414. Minimap.prototype.isOnActivePlane = function(element) {
  415. var canvas = this._canvas;
  416. if (canvas.findRoot) {
  417. return canvas.findRoot(element) === canvas.getRootElement();
  418. }
  419. if (canvas.findPlane) {
  420. return canvas.findPlane(element) === canvas.getActivePlane();
  421. }
  422. return true;
  423. };
  424. Minimap.prototype._addElement = function(element) {
  425. var self = this;
  426. this._removeElement(element);
  427. if (!this.isOnActivePlane(element)) {
  428. return;
  429. }
  430. var parent, x, y;
  431. var newElementGfx = this._createElement(element);
  432. var newElementParentGfx = query("#" + (0, import_css.default)(element.parent.id), this._elementsGroup);
  433. if (newElementGfx) {
  434. var elementGfx = this._elementRegistry.getGraphics(element);
  435. var parentGfx = this._elementRegistry.getGraphics(element.parent);
  436. var index2 = getIndexOfChildInParentChildren(elementGfx, parentGfx);
  437. if (index2 !== "undefined") {
  438. if (newElementParentGfx) {
  439. if (newElementParentGfx.childNodes.length > index2) {
  440. insertChildAtIndex(newElementGfx, newElementParentGfx, index2);
  441. } else {
  442. insertChildAtIndex(newElementGfx, newElementParentGfx, newElementParentGfx.childNodes.length - 1);
  443. }
  444. } else {
  445. this._elementsGroup.appendChild(newElementGfx);
  446. }
  447. } else {
  448. this._elementsGroup.appendChild(newElementGfx);
  449. }
  450. if (isConnection(element)) {
  451. parent = element.parent;
  452. x = 0;
  453. y = 0;
  454. if (typeof parent.x !== "undefined" && typeof parent.y !== "undefined") {
  455. x = -parent.x;
  456. y = -parent.y;
  457. }
  458. attr(newElementGfx, { transform: "translate(" + x + " " + y + ")" });
  459. } else {
  460. x = element.x;
  461. y = element.y;
  462. if (newElementParentGfx) {
  463. parent = element.parent;
  464. x -= parent.x;
  465. y -= parent.y;
  466. }
  467. attr(newElementGfx, { transform: "translate(" + x + " " + y + ")" });
  468. }
  469. if (element.children && element.children.length) {
  470. element.children.forEach(function(child) {
  471. self._addElement(child);
  472. });
  473. }
  474. return newElementGfx;
  475. }
  476. };
  477. Minimap.prototype._removeElement = function(element) {
  478. var elementGfx = this._svg.getElementById(element.id);
  479. if (elementGfx) {
  480. remove(elementGfx);
  481. }
  482. };
  483. Minimap.prototype._createElement = function(element) {
  484. var gfx = this._elementRegistry.getGraphics(element), visual;
  485. if (gfx) {
  486. visual = getVisual(gfx);
  487. if (visual) {
  488. var elementGfx = clone(visual);
  489. attr(elementGfx, { id: element.id });
  490. return elementGfx;
  491. }
  492. }
  493. };
  494. Minimap.prototype._clear = function() {
  495. clear(this._elementsGroup);
  496. };
  497. function isConnection(element) {
  498. return element.waypoints;
  499. }
  500. function getOffsetViewport(diagramPoint, viewbox) {
  501. var viewboxCenter = {
  502. x: viewbox.x + viewbox.width / 2,
  503. y: viewbox.y + viewbox.height / 2
  504. };
  505. return {
  506. x: diagramPoint.x - viewboxCenter.x,
  507. y: diagramPoint.y - viewboxCenter.y
  508. };
  509. }
  510. function mapMousePositionToDiagramPoint(position, svg, lastViewbox) {
  511. var boundingClientRect = svg.getBoundingClientRect();
  512. var bBox = fitAspectRatio(lastViewbox, boundingClientRect.width / boundingClientRect.height);
  513. var diagramX = map(position.x, 0, boundingClientRect.width, bBox.x, bBox.x + bBox.width), diagramY = map(position.y, 0, boundingClientRect.height, bBox.y, bBox.y + bBox.height);
  514. return {
  515. x: diagramX,
  516. y: diagramY
  517. };
  518. }
  519. function setViewboxCenteredAroundPoint(point, canvas) {
  520. var cachedViewbox = canvas.viewbox(), cachedViewboxWidth = cachedViewbox.width, cachedViewboxHeight = cachedViewbox.height;
  521. canvas.viewbox({
  522. x: point.x - cachedViewboxWidth / 2,
  523. y: point.y - cachedViewboxHeight / 2,
  524. width: cachedViewboxWidth,
  525. height: cachedViewboxHeight
  526. });
  527. }
  528. function fitAspectRatio(bounds, targetAspectRatio) {
  529. var aspectRatio = bounds.width / bounds.height;
  530. var newBounds = assign({}, {
  531. x: bounds.x,
  532. y: bounds.y,
  533. width: bounds.width,
  534. height: bounds.height
  535. });
  536. if (aspectRatio > targetAspectRatio) {
  537. var height = newBounds.width * (1 / targetAspectRatio), y = newBounds.y - (height - newBounds.height) / 2;
  538. assign(newBounds, {
  539. y,
  540. height
  541. });
  542. } else if (aspectRatio < targetAspectRatio) {
  543. var width = newBounds.height * targetAspectRatio, x = newBounds.x - (width - newBounds.width) / 2;
  544. assign(newBounds, {
  545. x,
  546. width
  547. });
  548. }
  549. return newBounds;
  550. }
  551. function map(x, inMin, inMax, outMin, outMax) {
  552. var inRange = inMax - inMin, outRange = outMax - outMin;
  553. return (x - inMin) * outRange / inRange + outMin;
  554. }
  555. function getIndexOfChildInParentChildren(childGfx, parentGfx) {
  556. var childrenGroup = query(".djs-children", parentGfx.parentNode);
  557. if (!childrenGroup) {
  558. return;
  559. }
  560. var childrenArray = [].slice.call(childrenGroup.childNodes);
  561. var indexOfChild = -1;
  562. childrenArray.forEach(function(childGroup, index2) {
  563. if (query(".djs-element", childGroup) === childGfx) {
  564. indexOfChild = index2;
  565. }
  566. });
  567. return indexOfChild;
  568. }
  569. function insertChildAtIndex(childGfx, parentGfx, index2) {
  570. var childContainer = getChildContainer(parentGfx);
  571. var childrenArray = [].slice.call(childContainer.childNodes);
  572. var childAtIndex = childrenArray[index2];
  573. if (childAtIndex) {
  574. parentGfx.insertBefore(childGfx, childAtIndex.nextSibling);
  575. } else {
  576. parentGfx.appendChild(childGfx);
  577. }
  578. }
  579. function getChildContainer(parentGfx) {
  580. var container = query(".children", parentGfx);
  581. if (!container) {
  582. container = create("g", { class: "children" });
  583. append(parentGfx, container);
  584. }
  585. return container;
  586. }
  587. function isZeroDimensional(clientRect) {
  588. return clientRect.width === 0 && clientRect.height === 0;
  589. }
  590. function isPointInside(point, rect) {
  591. return point.x > rect.left && point.x < rect.left + rect.width && point.y > rect.top && point.y < rect.top + rect.height;
  592. }
  593. var sign = Math.sign || function(n) {
  594. return n >= 0 ? 1 : -1;
  595. };
  596. function getStepSize(range, steps) {
  597. var minLinearRange = Math.log(range.min) / Math.log(10), maxLinearRange = Math.log(range.max) / Math.log(10);
  598. var absoluteLinearRange = Math.abs(minLinearRange) + Math.abs(maxLinearRange);
  599. return absoluteLinearRange / steps;
  600. }
  601. function cap(range, scale) {
  602. return Math.max(range.min, Math.min(range.max, scale));
  603. }
  604. function getOverlayClipPath(outer, inner) {
  605. var coordinates = [
  606. toCoordinatesString(inner.left, inner.top),
  607. toCoordinatesString(inner.left + inner.width, inner.top),
  608. toCoordinatesString(inner.left + inner.width, inner.top + inner.height),
  609. toCoordinatesString(inner.left, inner.top + inner.height),
  610. toCoordinatesString(inner.left, outer.height),
  611. toCoordinatesString(outer.width, outer.height),
  612. toCoordinatesString(outer.width, 0),
  613. toCoordinatesString(0, 0),
  614. toCoordinatesString(0, outer.height),
  615. toCoordinatesString(inner.left, outer.height)
  616. ].join(", ");
  617. return "polygon(" + coordinates + ")";
  618. }
  619. function toCoordinatesString(x, y) {
  620. return x + "px " + y + "px";
  621. }
  622. function validViewbox(viewBox) {
  623. return every(viewBox, function(value) {
  624. if (isObject(value)) {
  625. return validViewbox(value);
  626. }
  627. return isNumber(value) && isFinite(value);
  628. });
  629. }
  630. function getPoint(event2) {
  631. if (event2.center) {
  632. return event2.center;
  633. }
  634. return {
  635. x: event2.clientX,
  636. y: event2.clientY
  637. };
  638. }
  639. var index = {
  640. __init__: ["minimap"],
  641. minimap: ["type", Minimap]
  642. };
  643. export {
  644. index as default
  645. };
  646. //# sourceMappingURL=diagram-js-minimap.js.map