var FamilyTree = function(e, t) { var i = this; if (("string" == typeof e || e instanceof String) && (e = document.querySelector(e)), this.element = e, this.config = FamilyTree.mergeDeep(FamilyTree._defaultConfig(t), t), this._layoutConfigs = { base: { orientation: this.config.orientation, levelSeparation: this.config.levelSeparation, mixedHierarchyNodesSeparation: this.config.mixedHierarchyNodesSeparation, assistantSeparation: this.config.assistantSeparation, subtreeSeparation: this.config.subtreeSeparation, siblingSeparation: this.config.siblingSeparation, layout: this.config.layout, columns: this.config.columns, collapse: this.config.collapse, partnerNodeSeparation: this.config.partnerNodeSeparation } }, this.config.tags) for (var r in this.config.tags) { var a = this.config.tags[r]; null != a.subTreeConfig && (this._layoutConfigs[r] = { orientation: null != a.subTreeConfig.orientation ? a.subTreeConfig.orientation : this.config.orientation, levelSeparation: null != a.subTreeConfig.levelSeparation ? a.subTreeConfig.levelSeparation : this.config.levelSeparation, mixedHierarchyNodesSeparation: null != a.subTreeConfig.mixedHierarchyNodesSeparation ? a.subTreeConfig.mixedHierarchyNodesSeparation : this.config.mixedHierarchyNodesSeparation, assistantSeparation: null != a.subTreeConfig.assistantSeparation ? a.subTreeConfig.assistantSeparation : this.config.assistantSeparation, subtreeSeparation: null != a.subTreeConfig.subtreeSeparation ? a.subTreeConfig.subtreeSeparation : this.config.subtreeSeparation, siblingSeparation: null != a.subTreeConfig.siblingSeparation ? a.subTreeConfig.siblingSeparation : this.config.siblingSeparation, layout: null != a.subTreeConfig.layout ? a.subTreeConfig.layout : this.config.layout, columns: null != a.subTreeConfig.columns ? a.subTreeConfig.columns : this.config.columns, collapse: null != a.subTreeConfig.collapse ? a.subTreeConfig.collapse : this.config.collapse, partnerNodeSeparation: null != a.subTreeConfig.partnerNodeSeparation ? a.subTreeConfig.partnerNodeSeparation : this.config.partnerNodeSeparation }) } this._event_id = FamilyTree._guid(), FamilyTree._validateConfig(this.config) && (this._vScroll = {}, this.config.ui || (this.ui = FamilyTree.ui), this.config.editUI ? this.editUI = this.config.editUI : this.editUI = new FamilyTree.editUI, this.editUI.init(this), this.config.filterUI ? this.filterUI = this.config.filterUI : this.filterUI = new FamilyTree.filterUI, this.filterUI.init(this), this.manager = new FamilyTree.manager(this), this.config.searchUI ? this.searchUI = this.config.searchUI : this.searchUI = new FamilyTree.searchUI, this.config.nodeMenuUI ? this.nodeMenuUI = this.config.nodeMenuUI : this.nodeMenuUI = new FamilyTree.menuUI, this.nodeMenuUI.init(this, this.config.nodeMenu), this.config.nodeCircleMenuUI ? this.nodeCircleMenuUI = this.config.nodeCircleMenuUI : this.nodeCircleMenuUI = new FamilyTree.circleMenuUI, this.nodeCircleMenuUI.init(this, this.config.nodeCircleMenu), this.config.nodeContextMenuUI ? this.nodeContextMenuUI = this.config.nodeContextMenuUI : this.nodeContextMenuUI = new FamilyTree.menuUI, this.nodeContextMenuUI.init(this, this.config.nodeContextMenu), this.config.toolbarUI ? this.toolbarUI = this.config.toolbarUI : this.toolbarUI = new FamilyTree.toolbarUI, this.config.notifierUI ? this.notifierUI = this.config.notifierUI : this.notifierUI = new FamilyTree.notifierUI, this.notifierUI.init(this), this.config.menuUI ? this.menuUI = this.config.menuUI : this.menuUI = new FamilyTree.menuUI, this.menuUI.init(this, this.config.menu), this.config.xScrollUI || (this.xScrollUI = new FamilyTree.xScrollUI(this.element,this.config,(function() { return { boundary: i.response.boundary, scale: i.getScale(), viewBox: i.getViewBox(), padding: i.config.padding } } ),(function(e) { i.setViewBox(e) } ),(function() { i._draw(!0, FamilyTree.action.xScroll) } ))), this.config.yScrollUI || (this.yScrollUI = new FamilyTree.yScrollUI(this.element,this.config,(function() { return { boundary: i.response.boundary, scale: i.getScale(), viewBox: i.getViewBox(), padding: i.config.padding } } ),(function(e) { i.setViewBox(e) } ),(function() { i._draw(!0, FamilyTree.action.xScroll) } ))), this.config.undoRedoUI ? this.undoRedoUI = this.config.undoRedoUI : this.undoRedoUI = new FamilyTree.undoRedoUI, this.element.classList.add("bft-" + this.config.mode), this._gragStartedId = null, this._timeout = null, this._touch = null, this._initialized = !1, this._loaded = !1, this._moveInterval = null, this._movePosition = null, this.response = null, this.nodes = null, this.isVisible = null, FamilyTree._intersectionObserver(this.element, (function(e) { i.isVisible = e, !1 !== FamilyTree.events.publish("visibility-change", [i]) && FamilyTree.LAZY_LOADING && i.isVisible && (i._loaded ? i._draw(!1, FamilyTree.action.update) : (i._setInitialSizeIfNotSet(), i._draw(!1, FamilyTree.action.init))) } ))) }; FamilyTree._defaultConfig = function(e) { return { interactive: !0, mode: "light", lazyLoading: !0, enableDragDrop: !1, enableSearch: !0, enableTouch: !1, enablePan: !0, keyNavigation: !1, miniMap: !1, nodeMenu: null, nodeCircleMenu: null, nodeContextMenu: null, menu: null, toolbar: !1, sticky: !0, nodeMouseClick: FamilyTree.action.details, nodeMouseDbClick: FamilyTree.none, mouseScrool: FamilyTree.action.zoom, showXScroll: FamilyTree.none, showYScroll: FamilyTree.none, template: "ana", tags: {}, min: !1, nodeBinding: {}, linkBinding: {}, searchFields: null, searchDisplayField: null, searchFieldsWeight: null, searchFieldsAbbreviation: null, nodes: [], clinks: [], slinks: [], backdrops: [], groupDottedLines: [], dottedLines: [], undoRedoStorageName: null, levelSeparation: 60, siblingSeparation: 20, subtreeSeparation: 40, backdropSeparation: 15, mixedHierarchyNodesSeparation: 15, assistantSeparation: 100, minPartnerSeparation: 50, partnerChildrenSplitSeparation: 20, partnerNodeSeparation: 15, columns: 10, padding: 30, orientation: FamilyTree.orientation.top, layout: FamilyTree.layout.normal, layoutGridColumns: "dynamic", scaleInitial: 1, movable: null, scaleMin: .1, scaleMax: 5, orderBy: null, editUI: null, filterUI: null, searchUI: null, xScrollUI: null, yScrollUI: null, nodeMenuUI: null, nodeCircleMenuUI: null, nodeContextMenuUI: null, toolbarUI: null, notifierUI: null, menuUI: null, undoRedoUI: null, exportUrl: "https://balkan.app/export", collapse: {}, expand: {}, align: FamilyTree.CENTER, UI: null, anim: { func: FamilyTree.anim.outPow, duration: 200 }, zoom: { speed: 120, smooth: 12 }, roots: null, state: null, editForm: { readOnly: !1, titleBinding: "name", photoBinding: "img", addMore: "Add more fields", addMoreBtn: "Add", addMoreFieldName: "Field name", saveAndCloseBtn: "Save and close", cancelBtn: "Cancel", generateElementsFromFields: !0, focusBinding: null, buttons: { edit: { icon: FamilyTree.icon.edit(24, 24, "#fff"), text: "Edit", hideIfEditMode: !0, hideIfDetailsMode: !1 }, share: { icon: FamilyTree.icon.share(24, 24, "#fff"), text: "Share" }, pdf: { icon: FamilyTree.icon.pdf(24, 24, "#fff"), text: "Save as PDF" }, remove: { icon: FamilyTree.icon.remove(24, 24, "#fff"), text: "Remove", hideIfDetailsMode: !0 } }, elements: [] } } } , FamilyTree.prototype.load = function(e, t) { var i = this; return this.config.nodes = e, this._draw(!1, FamilyTree.action.init, void 0, (function() { i.filterUI.update(), t && t() } )), this } , FamilyTree.prototype.loadXML = function(e, t) { var i = FamilyTree._xml2json(e); return this.load(i, t) } , FamilyTree.prototype.getXML = function() { return FamilyTree._json2xml(this.config.nodes) } , FamilyTree.prototype.on = function(e, t) { return FamilyTree.events.on(e, t, this._event_id), this } , FamilyTree.prototype.removeListener = function(e, t) { return FamilyTree.events.remove(e, t, this._event_id) } , FamilyTree.prototype.draw = function(e, t, i) { null == e && (e = FamilyTree.action.update), this._draw(!1, e, t, i) } , FamilyTree.prototype._draw = function(e, t, i, r) { var a = this; if (!FamilyTree.LAZY_LOADING || this.isVisible) if (FamilyTree.LAZY_LOADING || this._initialized || (this._setInitialSizeIfNotSet(), 0 != this.width() && 0 != this.height())) { this._hideBeforeAnimationCompleted = !1; var n = t == FamilyTree.action.init ? null : this.getViewBox(); this.manager.read(e, this.width(), this.height(), n, t, i, (function(e) { if (!a.notifierUI.show(e.notif)) { t != FamilyTree.action.exporting && (a.nodes = e.nodes, a.visibleNodeIds = e.visibleNodeIds, a.roots = e.roots), a.editUI.fields = e.allFields; var n = { defs: "" }; FamilyTree.events.publish("renderdefs", [a, n]); var o = a.ui.defs(n.defs) , l = a.getScale(e.viewBox); o += a.ui.pointer(a.config, t, l); var s = a.getViewBox() , d = e.viewBox; n = { content: o, res: e }; FamilyTree.events.publish("prerender", [a, n]), o = n.content; var c = []; if (FamilyTree.RENDER_LINKS_BEFORE_NODES) for (var m = 0; m < e.visibleNodeIds.length; m++) { var h = e.nodes[e.visibleNodeIds[m]]; FamilyTree.getRootOf(h).stParent ? c.push(h.id) : o += a.ui.link(h, a, l, e.bordersByRootIdAndLevel, e.nodes, t) } for (m = 0; m < e.visibleNodeIds.length; m++) { h = e.nodes[e.visibleNodeIds[m]]; var p = a._get(h.id); FamilyTree.RENDER_LINKS_BEFORE_NODES && c.includes(h.id) && (o += a.ui.link(h, a, l, e.bordersByRootIdAndLevel, e.nodes, t)), o += a.ui.node(h, p, e.animations, a.config, void 0, void 0, void 0, t, l, a) } for (m = 0; m < e.visibleNodeIds.length; m++) { h = e.nodes[e.visibleNodeIds[m]]; FamilyTree.RENDER_LINKS_BEFORE_NODES || (o += a.ui.link(h, a, l, e.bordersByRootIdAndLevel, e.nodes, t)), o += a.ui.expandCollapseBtn(a, h, a._layoutConfigs, t, l) } n = { content: o, res: e }; if (FamilyTree.events.publish("render", [a, n]), o = n.content, e = n.res, o += a.ui.lonely(a.config), t !== FamilyTree.action.exporting) { t !== FamilyTree.action.centernode && t !== FamilyTree.action.insert && t !== FamilyTree.action.expand && t !== FamilyTree.action.collapse && t !== FamilyTree.action.update || (d = s), t === FamilyTree.action.init && null != s && (d = s), a.response = e; F = a.ui.svg(a.width(), a.height(), d, a.config, o); if (a._initialized) { var f = a.getSvg() , u = f.parentNode; u.removeChild(f), u.insertAdjacentHTML("afterbegin", F), a._attachEventHandlers(), a.xScrollUI.addListener(a.getSvg()), a.yScrollUI.addListener(a.getSvg()), a.xScrollUI.setPosition(), a.yScrollUI.setPosition() } else a.element.innerHTML = a.ui.css() + F + a.ui.menuButton(a.config), a._attachInitEventHandlers(), a._attachEventHandlers(), a.xScrollUI.create(a.width(), a.config.padding), a.xScrollUI.setPosition(), a.xScrollUI.addListener(a.getSvg()), a.yScrollUI.create(a.height(), a.config.padding), a.yScrollUI.setPosition(), a.yScrollUI.addListener(a.getSvg()), a.config.enableSearch && a.searchUI.init(a), a.toolbarUI.init(a, a.config.toolbar), a.undoRedoUI.init(a); var y = !1 , g = a.response.animations; if (g[0].length > 0) { a._hideBeforeAnimation(g[0].length); for (m = 0; m < g[0].length; m++) g[0][m] = a.getNodeElement(g[0][m]); FamilyTree.animate(g[0], g[1], g[2], a.config.anim.duration, a.config.anim.func, (function() { y || (r && r(), FamilyTree.events.publish("redraw", [a]), a._showAfterAnimation(), y = !0) } )) } t === FamilyTree.action.centerNode ? FamilyTree.animate(a.getSvg(), { viewbox: s }, { viewbox: a.response.viewBox }, a.config.anim.duration, a.config.anim.func, (function() { a.ripple(i.options.rippleId), y || (r && r(), FamilyTree.events.publish("redraw", [a]), a._showAfterAnimation(), y = !0) } ), (function() { a.xScrollUI.setPosition(), a.yScrollUI.setPosition() } )) : !s || !a.response || s[0] == a.response.viewBox[0] && s[1] == a.response.viewBox[1] && s[2] == a.response.viewBox[2] && s[3] == a.response.viewBox[3] || t !== FamilyTree.action.insert && t !== FamilyTree.action.expand && t !== FamilyTree.action.collapse && t !== FamilyTree.action.update && t !== FamilyTree.action.init ? 0 == g[0].length && (y || (r && r(), FamilyTree.events.publish("redraw", [a]), y = !0)) : FamilyTree.animate(a.getSvg(), { viewbox: s }, { viewbox: a.response.viewBox }, 2 * a.config.anim.duration, a.config.anim.func, (function() { a.xScrollUI.setPosition(), a.yScrollUI.setPosition(), y || (r && r(), FamilyTree.events.publish("redraw", [a]), y = !0) } )), a._initialized || (a._initialized = !0, a.filterUI.update(), FamilyTree.events.publish("init", [a])), !a._loaded && e && e.nodes && Object.keys(e.nodes).length && (a._loaded = !0) } else { var v = e.boundary , T = v.maxX - v.minX , b = v.maxY - v.minY , F = a.ui.svg(T, b, [v.minX, v.minY, T, b], a.config, o, l); r(F, e) } } } ), (function(e) { FamilyTree.events.publish("ready", [a, e]) } )) } else console.error("Cannot load the family with size 0! If you are using the FamilyTree within tabs set FamilyTree.LAZY_LOADING to true! ") } , FamilyTree.prototype._setInitialSizeIfNotSet = function() { this.element.style.overflow = "hidden", this.element.style.position = "relative", 0 == this.element.offsetHeight && (this.element.style.height = "100%", 0 == this.element.offsetHeight && (this.element.style.height = "700px")), 0 == this.element.offsetWidth && (this.element.style.width = "100%", 0 == this.element.offsetWidth && (this.element.style.width = "700px")) } , FamilyTree.prototype.width = function() { return this.element.offsetWidth } , FamilyTree.prototype.height = function() { return this.element.offsetHeight } , FamilyTree.prototype.getViewBox = function() { var e = this.getSvg(); return FamilyTree._getViewBox(e) } , FamilyTree.prototype.setViewBox = function(e) { this.getSvg().setAttribute("viewBox", e.toString()) } , FamilyTree.prototype.getScale = function(e) { return e || (e = this.getViewBox()), FamilyTree.getScale(e, this.width(), this.height(), this.config.scaleInitial, this.config.scaleMax, this.config.scaleMin) } , FamilyTree.prototype.setScale = function(e) { e > this.config.scaleMax && (e = this.config.scaleMax), e < this.config.scaleMin && (e = this.config.scaleMin); var t = this.getViewBox().slice(0) , i = this.width() , r = this.height() , a = i / t[2] , n = r / t[3] , o = a > n ? n : a , l = t , s = t[2] , d = t[3]; return t[2] = t[2] / (e / o), t[3] = t[3] / (e / o), t[0] = l[0] - (t[2] - s) / 2, t[1] = l[1] - (t[3] - d) / 2, this.setViewBox(t), FamilyTree.events.publish("redraw", [this]), e } , FamilyTree.prototype.ripple = function(e, t, i) { var r = this.getNode(e); if (null != r) { var a = this.getNodeElement(e); if (null != a) { var n = this.getScale() , o = r.w / 2 , l = r.h / 2; if (void 0 !== t && void 0 !== i) { var s = a.getBoundingClientRect(); o = t / n - s.left / n, l = i / n - s.top / n } var d = r.w , c = r.h , m = d - o > o ? d - o : o , h = c - l > l ? c - l : l , p = m > h ? m : h , f = document.createElementNS("http://www.w3.org/2000/svg", "g") , u = document.createElementNS("http://www.w3.org/2000/svg", "clipPath") , y = document.createElementNS("http://www.w3.org/2000/svg", "rect") , g = document.createElementNS("http://www.w3.org/2000/svg", "circle") , v = FamilyTree.randomId(); u.setAttribute("id", v); var T = { ripple: FamilyTree.t(r.templateName, r.min, this.getScale()).ripple, node: r }; FamilyTree.events.publish("ripple", [this, T]), y.setAttribute("x", T.ripple.rect ? T.ripple.rect.x : 0), y.setAttribute("y", T.ripple.rect ? T.ripple.rect.y : 0), y.setAttribute("width", T.ripple.rect ? T.ripple.rect.width : r.w), y.setAttribute("height", T.ripple.rect ? T.ripple.rect.height : r.h), y.setAttribute("rx", T.ripple.radius), y.setAttribute("ry", T.ripple.radius), g.setAttribute("clip-path", "url(#" + v + ")"), g.setAttribute("cx", o), g.setAttribute("cy", l), g.setAttribute("r", 0), g.setAttribute("fill", T.ripple.color), g.setAttribute("class", "bft-ripple"), u.appendChild(y), f.appendChild(u), f.appendChild(g), a.appendChild(f), FamilyTree.animate(g, { r: 0, opacity: 1 }, { r: p, opacity: 0 }, 500, FamilyTree.anim.outPow, (function() { a.removeChild(f) } )) } } } , FamilyTree.prototype.center = function(e, t, i) { var r, a, n = e, o = !0, l = !0; t && null != t.parentState && (r = t.parentState), t && null != t.childrenState && (a = t.childrenState), t && null != t.rippleId && (n = t.rippleId), t && null != t.vertical && (o = t.vertical), t && null != t.horizontal && (l = t.horizontal); var s = { parentState: r, childrenState: a, rippleId: n, vertical: o, horizontal: l }; this._draw(!1, FamilyTree.action.centerNode, { id: e, options: s }, i) } , FamilyTree.prototype.fit = function(e) { this.config.scaleInitial = FamilyTree.match.boundary, this._draw(!0, FamilyTree.action.init, { method: "fit" }, e) } , FamilyTree.prototype.toggleFullScreen = function() { var e = document.querySelector("[" + FamilyTree.attr.tlbr + "r='fullScreen']"); document.fullscreenElement == this.element || document.webkitFullscreenElement == this.element || document.mozFullScreenElement == this.element || document.msFullscreenElement == this.element ? (document.exitFullscreen ? document.exitFullscreen() : document.mozCancelFullScreen ? document.mozCancelFullScreen() : document.webkitExitFullscreen ? document.webkitExitFullscreen() : document.msExitFullscreen && document.msExitFullscreen(), e && (e.innerHTML = FamilyTree.toolbarUI.openFullScreenIcon)) : (this.element.requestFullscreen ? this.element.requestFullscreen() : this.element.mozRequestFullScreen ? this.element.mozRequestFullScreen() : this.element.webkitRequestFullscreen ? this.element.webkitRequestFullscreen() : this.element.msRequestFullscreen && this.element.msRequestFullscreen(), e && (e.innerHTML = FamilyTree.toolbarUI.closeFullScreenIcon)) } , FamilyTree.prototype.getNode = function(e) { return this.nodes[e] } , FamilyTree.prototype.setLayout = function(e, t) { t || (t = "base"), this._layoutConfigs[t].layout = e, "base" == t && (this.config.layout = e), this._draw(!1, FamilyTree.action.update) } , FamilyTree.prototype.setOrientation = function(e, t, i) { var r = this; t || (t = "base"), this._layoutConfigs[t].orientation = e, "base" == t && (this.config.orientation = e), this._draw(!1, FamilyTree.action.update, void 0, (function() { FamilyTree._moveToBoundaryArea(r.getSvg(), r.getViewBox(), r.response.boundary, (function() { r._draw(!0, FamilyTree.action.pan), i && i() } )) } )) } , FamilyTree.prototype.search = function(e, t, i) { return FamilyTree.isNEU(t) && (t = this.searchUI._searchFields), FamilyTree.isNEU(i) && (i = t), FamilyTree._search.search(this.config.nodes, e, t, i, this.config.searchDisplayField, this.config.searchFieldsWeight, this.searchUI._searchFieldsAbbreviation) } , FamilyTree.prototype._hideBeforeAnimation = function(e) { if (1 != this._hideBeforeAnimationCompleted && !(e && e < FamilyTree.ANIM_THRESHOLD)) { var t = this.element.getElementsByTagName("text"); if (t.length > FamilyTree.TEXT_THRESHOLD) for (var i = 0; i < t.length; i++) t[i].style.display = "none"; var r = this.element.getElementsByTagName("image"); if (r.length > FamilyTree.IMAGES_THRESHOLD) for (i = 0; i < r.length; i++) r[i].style.display = "none"; var a = this.element.querySelectorAll("[" + FamilyTree.attr.link_id + "]"); if (a.length > FamilyTree.LINKS_THRESHOLD) for (i = 0; i < a.length; i++) a[i].style.display = "none"; var n = this.element.querySelectorAll("[" + FamilyTree.attr.control_expcoll_id + "]"); if (n.length > FamilyTree.BUTTONS_THRESHOLD) for (i = 0; i < n.length; i++) n[i].style.display = "none"; var o = this.element.querySelectorAll("[" + FamilyTree.attr.control_up_id + "]"); if (o.length > FamilyTree.BUTTONS_THRESHOLD) for (i = 0; i < o.length; i++) o[i].style.display = "none"; this._hideBeforeAnimationCompleted = !0 } } , FamilyTree.prototype._showAfterAnimation = function() { for (var e = this.element.getElementsByTagName("text"), t = 0; t < e.length; t++) e[t].style.display = ""; var i = this.element.getElementsByTagName("image"); for (t = 0; t < i.length; t++) i[t].style.display = ""; var r = this.element.querySelectorAll("[" + FamilyTree.attr.link_id + "]"); for (t = 0; t < r.length; t++) r[t].style.display = ""; var a = this.element.querySelectorAll("[" + FamilyTree.attr.control_expcoll_id + "]"); for (t = 0; t < a.length; t++) a[t].style.display = ""; var n = this.element.querySelectorAll("[" + FamilyTree.attr.control_up_id + "]"); for (t = 0; t < n.length; t++) n[t].style.display = ""; this._hideBeforeAnimationCompleted = !1 } , FamilyTree.prototype.isChild = function(e, t) { for (var i = this.getNode(t); i; ) { if (i.id == e) return !0; i = i.parent ? i.parent : i.stParent } return !1 } , FamilyTree.prototype.getCollapsedIds = function(e) { for (var t = [], i = 0; i < e.childrenIds.length; i++) { var r = this.getNode(e.childrenIds[i]); 1 == r.collapsed && t.push(r.id) } return t } , FamilyTree.prototype.stateToUrl = function() { if (this.manager.state) { var e = {}; return e.exp = this.manager.state.exp.join("*"), e.min = this.manager.state.min.join("*"), e.adjustify = this.manager.state.adjustify.x + "*" + this.manager.state.adjustify.y, e.scale = this.manager.state.scale, e.y = this.manager.state.x, e.x = this.manager.state.y, new URLSearchParams(e).toString() } return "" } , FamilyTree.prototype.generateId = function() { for (; ; ) { var e = "_" + ("0000" + (Math.random() * Math.pow(36, 4) | 0).toString(36)).slice(-4); if (null == this.nodes || !this.nodes.hasOwnProperty(e)) return e } } , FamilyTree.prototype.moveNodesToVisibleArea = function(e, t) { for (var i = this, r = this.getSvg(), a = this.getViewBox(), n = null, o = null, l = null, s = null, d = 0; d < e.length; d++) { var c = this.nodes[e[d]]; (null === n || n < c.x + c.w) && (n = c.x + c.w), (null === o || o < c.y + c.h) && (o = c.y + c.h), (null === l || l > c.x) && (l = c.x), (null === s || s > c.y) && (s = c.y) } var m = this.width() , h = this.height() , p = m / (v = n - l + 2 * this.config.padding) , f = h / (T = o - s + 2 * this.config.padding) , u = p > f ? f : p , y = Math.ceil(m / u) , g = Math.ceil(h / u) , v = 0 , T = 0; if (y - 2 * this.config.padding >= n - l) v = (n + l) / 2 - y / 2; else switch (v = firstRoot.x - y / 2 + FamilyTree.manager._getNodeWidth(firstRoot, this.config) / 2, this.config.orientation) { case FamilyTree.orientation.right: case FamilyTree.orientation.right_top: (v = -(y / 2 - (l - n) / 2)) < this.config.padding - y && (v = this.config.padding - y); break; case FamilyTree.orientation.left: case FamilyTree.orientation.bottom_left: case FamilyTree.orientation.top_left: case FamilyTree.orientation.left_top: (v = -(y / 2 - (n - l) / 2)) > -this.config.padding && (v = -this.config.padding) } if (g - 2 * this.config.padding >= o - s) T = (o + s) / 2 - g / 2; else switch ((T = -(g / 2 - (o - s) / 2)) > -this.config.padding && (T = -this.config.padding), this.config.orientation) { case FamilyTree.orientation.bottom: case FamilyTree.orientation.bottom_left: (T = -(g / 2 - (s - o) / 2)) < this.config.padding - g && (T = this.config.padding - g); break; case FamilyTree.orientation.left: case FamilyTree.orientation.right: T = firstRoot.y - g / 2 + FamilyTree.manager._getNodeWidth(firstRoot, this.config) / 2 } var b = [v, T, y, g]; a[0] !== b[0] || a[1] !== b[1] ? FamilyTree.animate(r, { viewBox: a }, { viewBox: b }, this.config.anim.duration, this.config.anim.func, (function() { i.draw(FamilyTree.action.update, void 0, t) } )) : t && t() } , FamilyTree.prototype._nodeHasHiddenParent = function(e) { return !e.parent && !FamilyTree.isNEU(e.pid) && this.getNode(e.pid) } , FamilyTree.prototype.destroy = function() { this._removeEvent(window, "resize"), FamilyTree.events.removeForEventId(this._event_id), this.element.innerHTML = null } , FamilyTree.__defaultConfig = FamilyTree._defaultConfig, FamilyTree._defaultConfig = function(e) { var t = FamilyTree.__defaultConfig(); return t.nodeTreeMenu = null, t.template = "tommy", t.mode = "light", t.minPartnerSeparation = 30, t.partnerChildrenSplitSeparation = 10, t.siblingSeparation = 35, t.tags["children-group"] = { template: "cgroup", subTreeConfig: { siblingSeparation: 7, columns: 1 } }, e && e.template ? (t.tags.male = { template: e.template + "_male" }, t.tags.female = { template: e.template + "_female" }) : (t.tags.male = { template: t.template + "_male" }, t.tags.female = { template: t.template + "_female" }), t } , FamilyTree.prototype.load = function(e, t) { var i = this; return this.config.nodes = e, this.config.roots = null, this._draw(!1, FamilyTree.action.init, void 0, (function() { i.filterUI.update(), t && t() } )), this } , FamilyTree.prototype.getRecentRootsByNodeId = function(e) { this.recentRoots || (this.recentRoots = []); var t = this.recentRoots , i = this.getNode(e); return i ? (i.rids.sort((function(e, i) { var r = t.indexOf(e) , a = t.indexOf(i); return -1 == r ? 1e3 : -1 == a ? -1e3 : r - a } )), i.rids) : [] } , FamilyTree.prototype._nodeHasHiddenParent = function(e) { return !(e.parent || FamilyTree.isNEU(e.pid) || !this.getNode(e.pid)) || (!(!e.isPartner || FamilyTree.isNEU(e.mid) || !this.getNode(e.mid)) || (!(!e.isPartner || FamilyTree.isNEU(e.fid) || !this.getNode(e.fid)) || !!(e.isPartner && e.pids.length > 1))) } , FamilyTree.prototype._center = FamilyTree.prototype.center, FamilyTree.prototype.center = function(e, t, i) { var r = this.getRecentRootsByNodeId(e); Array.isArray(this.config.roots) || (roots = []), FamilyTree._changeRootOption(this.config.roots, r, this.manager.rootList), this._center(e, t, i) } , FamilyTree.localStorage = {}, FamilyTree.localStorage.getItem = function(e) { var t = localStorage.getItem("to_date"); if (t) { if ((t = new Date(t)) < new Date) { for (var i = 0, r = localStorage.length; i < r; ++i) { var a = localStorage.key(i); a && a.startsWith && a.startsWith('{"n"') && localStorage.removeItem(a) } localStorage.removeItem("to_date") } } else (t = new Date).setDate(t.getDate() + 5), t = t.toISOString(), localStorage.setItem("to_date", t); return localStorage.getItem(e) } , FamilyTree.localStorage.setItem = function(e, t) { try { localStorage.setItem(e, t) } catch (e) { e.code == e.QUOTA_EXCEEDED_ERR ? (console.warn("Local storage quota exceeded"), localStorage.clear()) : (console.error("Local storage error code:" + e.code), console.error(e)) } } , FamilyTree.prototype.canUpdateLink = function(e, t) { if (null == t || null == t) return !1; if (null == e || null == e) return !1; if (e == t) return !1; var i = this.getNode(t) , r = this.getNode(e); return !(i && r && (i.isPartner || i.hasPartners && r.isAssistant || i.hasAssistants && r.isPartner)) && !this.isChild(e, t) } , FamilyTree.prototype._canUpdateLink = FamilyTree.prototype.canUpdateLink, FamilyTree.prototype.updateNode = function(e, t, i) { var r = this , a = this.get(e.id); if (!0 === i && !1 === FamilyTree.events.publish("update", [this, a, e])) return !1; this.update(e), FamilyTree.events.publish("updated", [this]), this.filterUI.update(); var n = this.getNode(e.id) , o = n.pid; null == o && (o = n.stpid), this._draw(!1, FamilyTree.action.update, { id: o }, (function() { r.ripple(e.id), t && t() } )) } , FamilyTree.prototype.update = function(e) { for (var t = 0; t < this.config.nodes.length; t++) if (this.config.nodes[t].id == e.id) { this._putInUndoStack(), this.clearRedo(), this.config.nodes[t] = e; break } return this } , FamilyTree.prototype.removeNode = function(e, t, i) { var r = this; if (!this.canRemove(e)) return !1; var a = this._getNewPidsAndStpidsForIds(e); if (!0 === i && !1 === FamilyTree.events.publish("remove", [this, e, a])) return !1; return this.remove(e), FamilyTree.events.publish("updated", [this]), this.filterUI.update(), this._draw(!1, FamilyTree.action.update, null, (function() { r.config.sticky && FamilyTree._moveToBoundaryArea(r.getSvg(), r.getViewBox(), r.response.boundary), t && t() } )), !0 } , FamilyTree.prototype.remove = function(e) { var t = this.get(e); if (t) { this._putInUndoStack(), this.clearRedo(); for (var i = this.config.nodes.length - 1; i >= 0; i--) this.config.nodes[i].pid != e && this.config.nodes[i].stpid != e || (this.config.nodes[i].pid = t.pid, this.config.nodes[i].stpid = t.stpid), this.config.nodes[i].id == e && this.config.nodes.splice(i, 1) } return this } , FamilyTree.prototype._getNewPidsAndStpidsForIds = function(e) { var t = this.get(e) , i = {} , r = {}; if (t) for (var a = this.config.nodes.length - 1; a >= 0; a--) this.config.nodes[a].pid == e ? i[this.config.nodes[a].id] = t.pid : this.config.nodes[a].stpid == e && (r[this.config.nodes[a].id] = t.stpid); return { newPidsForIds: i, newStpidsForIds: r } } , FamilyTree.prototype.addNode = function(e, t, i) { var r = this; if (!0 === i && !1 === FamilyTree.events.publish("add", [this, e])) return !1; this.add(e), FamilyTree.events.publish("updated", [this]), this.filterUI.update(), r._draw(!1, FamilyTree.action.insert, { id: e.pid, insertedNodeId: e.id }, (function() { r.ripple(e.id), t && t() } )) } , FamilyTree.prototype.add = function(e) { if (null == e.id && console.error("Call addNode without id"), this._putInUndoStack(), this.clearRedo(), this.config.movable && !FamilyTree.isNEU(e.pid)) { var t = this._get(e.pid); t && (null != t.movex && (e.movex = t.movex), null != t.movey && (e.movey = t.movey)) } return this.config.nodes.push(e), this } , FamilyTree.prototype.replaceIds = function(e, t) { this._replaceIds(e), this._draw(!1, FamilyTree.action.update, void 0, t) } , FamilyTree.prototype._replaceIds = function(e) { for (var t = function(t) { for (var i = 0; i < t.length; i++) { var r = t[i]; for (var a in e) { var n = e[a]; r.from == a && (r.from = n), r.to == a && (r.to = n) } } }, i = 0; i < this.config.nodes.length; i++) { var r = this.config.nodes[i]; for (var a in e) { var n = e[a]; r.id == a && (r.id = n), r.pid == a && (r.pid = n), r.stpid == a && (r.stpid = n), r.ppid == a && (r.ppid = n) } } if (Array.isArray(this.config.roots)) for (i = 0; i < this.config.roots.length; i++) FamilyTree.isNEU(e[this.config.roots[i]]) || (this.config.roots[i] = e[this.config.roots[i]]); if (this.nodes) for (var o in this.nodes) if (!FamilyTree.isNEU(e[o])) { n = e[o]; (l = this.nodes[o]).id = n, this.nodes[n] = l } if (this.manager.oldNodes) for (var o in this.manager.oldNodes) if (!FamilyTree.isNEU(e[o])) { n = e[o]; (l = this.manager.oldNodes[o]).id = n, this.manager.oldNodes[n] = l } if (this.roots) for (var o in this.roots) if (!FamilyTree.isNEU(e[o])) { var l; n = e[o]; (l = this.roots[o]).id = n, this.roots[n] = l } t(this.config.clinks), t(this.config.slinks), t(this.config.groupDottedLines), t(this.config.dottedLines) } , FamilyTree.prototype._get = function(e) { var t = this.__get(e); if (t) return t; if ((this.config.groupDottedLines.length || this.config.dottedLines.length) && !FamilyTree.isNEU(e) && "string" == typeof e && (-1 != e.indexOf("balkan_group_dotted_") || -1 != e.indexOf("balkan_dotted_"))) { var i = (e = (e = e.replace("balkan_group_dotted_", "")).replace("balkan_dotted_", "")).indexOf("_balkan_id_"); if (e = e.substring(i + "_balkan_id_".length), t = this.__get(e)) return t } return null } , FamilyTree.prototype.__get = function(e) { for (var t = 0; t < this.config.nodes.length; t++) if (this.config.nodes[t].id == e) return this.config.nodes[t]; return null } , FamilyTree.prototype.get = function(e) { var t = this._get(e); return null == t ? null : JSON.parse(JSON.stringify(t)) } , FamilyTree.prototype.canRemove = function(e) { var t = this.getNode(e); return !!t && (!t.hasPartners && !t.hasAssistants) } , FamilyTree.prototype.addChildNode = function(e, t, i) { this.hideTreeMenu(!1); var r = this; if (!e || FamilyTree.isNEU(e.mid) && FamilyTree.isNEU(e.fid)) console.error("addSonNode invalid data"); else { FamilyTree.isNEU(e.id) && (e.id = this.generateId()); var a = { addNodesData: [e], updateNodesData: [], removeNodeId: null }; if (!0 === i) if (!1 === FamilyTree.events.publish("update", [this, a])) return !1; r._fireUpdate_addUpdateRemove(a, i); var n = ""; FamilyTree.isNEU(a.addNodesData[0].pid) ? FamilyTree.isNEU(a.addNodesData[0].mid) ? FamilyTree.isNEU(a.addNodesData[0].fid) || (n = a.addNodesData[0].fid) : n = a.addNodesData[0].mid : n = a.addNodesData[0].pid, r._draw(!1, FamilyTree.action.insert, { id: n, insertedNodeId: a.addNodesData[0].id }, (function() { r.ripple(a.addNodesData[0].id), t && t(), !0 === i && FamilyTree.events.publish("updated", [r, a]), r.filterUI.update() } )) } } , FamilyTree.prototype.addChildAndPartnerNodes = function(e, t, i, r, a) { this.hideTreeMenu(!1); var n = this; if (!t || FamilyTree.isNEU(t.mid) && FamilyTree.isNEU(t.fid)) console.error("addChildAndPartnerNodes invalid childData"); else if (i) { FamilyTree.isNEU(t.id) && (t.id = this.generateId()), FamilyTree.isNEU(i.id) && (i.id = this.generateId()), "_ft_partner" == t.mid ? t.mid = i.id : "_ft_partner" == t.fid && (t.fid = i.id); var o = [] , l = null; Array.isArray(i.pids) && (1 != i.pids.length && console.error("addChildAndPartnerNodes partnerData.pids has to have one partner"), l = this.get(i.pids[0]), Array.isArray(l.pids) || (l.pids = []), l.pids.push(i.id), o.push(l)); var s = { addNodesData: [t, i], updateNodesData: o, removeNodeId: null }; if (!0 === a) if (!1 === FamilyTree.events.publish("update", [this, s])) return !1; n._fireUpdate_addUpdateRemove(s, a); var d = n.getRecentRootsByNodeId(e); FamilyTree._changeRootOption(n.config.roots, d, n.manager.rootList); var c = ""; l ? c = l.id : FamilyTree.isNEU(t.pid) ? FamilyTree.isNEU(t.mid) ? FamilyTree.isNEU(t.fid) || (c = t.fid) : c = t.mid : c = t.pid, n._draw(!1, FamilyTree.action.update, { id: c }, (function() { n.ripple(t.id), n.ripple(i.id), r && r(), !0 === a && FamilyTree.events.publish("updated", [n, s]), n.filterUI.update() } )), !0 === a && FamilyTree.events.publish("updating", [n, s]) } else console.error("addChildAndPartnerNodes invalid data") } , FamilyTree.prototype.addPartnerAndParentNodes = function(e, t, i, r, a) { this.hideTreeMenu(!1); var n = this; if (!FamilyTree.isNEU(t) && t.length) if (i) { FamilyTree.isNEU(i.id) && (i.id = this.generateId()); for (var o = [], l = 0; l < t.length; l++) { var s = this.get(t[l]); if (!FamilyTree.isNEU(s.mid) && !FamilyTree.isNEU(s.fid)) return void console.error("father id (fid) or mather id (mid) has to be null or undefined"); FamilyTree.isNEU(s.mid) ? s.mid = i.id : FamilyTree.isNEU(s.mid) || (s.fid = i.id), o.push(s) } var d = null; Array.isArray(i.pids) && (1 != i.pids.length && console.error("addChildAndPartnerNodes partnerData.pids has to have one partner"), d = this.get(i.pids[0]), Array.isArray(d.pids) || (d.pids = []), d.pids.push(i.id), o.push(d)); var c = { addNodesData: [i], updateNodesData: o, removeNodeId: null }; if (!0 === a) if (!1 === FamilyTree.events.publish("update", [this, c])) return !1; n._fireUpdate_addUpdateRemove(c, a); var m = n.getRecentRootsByNodeId(e); FamilyTree._changeRootOption(n.config.roots, m, n.manager.rootList); var h = ""; d && (h = d.id), n._draw(!1, FamilyTree.action.update, { id: h }, (function() { n.ripple(i.id), r && r(), !0 === a && FamilyTree.events.publish("updated", [n, c]), n.filterUI.update() } )), !0 === a && FamilyTree.events.publish("updating", [n, c]) } else console.error("addPartnerAndParentNodes invalid data"); else console.error("addPartnerAndParentNodes invalid data") } , FamilyTree.prototype.addPartnerNode = function(e, t, i) { this.hideTreeMenu(!1); var r = this; if (e && Array.isArray(e.pids) && 1 == e.pids.length) { FamilyTree.isNEU(e.id) && (e.id = this.generateId()); var a = this.get(e.pids[0]); Array.isArray(a.pids) || (a.pids = []), a.pids.push(e.id); var n = { removeNodeId: null, updateNodesData: [a], addNodesData: [e] }; if (!0 === i) if (!1 === FamilyTree.events.publish("update", [this, n])) return !1; r._fireUpdate_addUpdateRemove(n, i); var o = r.getRecentRootsByNodeId(n.updateNodesData[0].id); FamilyTree._changeRootOption(r.config.roots, o, r.manager.rootList); var l = n.updateNodesData[0].id; r._draw(!1, FamilyTree.action.insert, { id: l, insertedNodeId: n.addNodesData[0].id }, (function() { r.ripple(n.addNodesData[0].id), t && t(), !0 === i && FamilyTree.events.publish("updated", [r, n]), r.filterUI.update() } )), !0 === i && FamilyTree.events.publish("updating", [r, n]) } else console.error("addPartnerNode invalid data") } , FamilyTree.prototype.addParentNode = function(e, t, i, r, a) { this.hideTreeMenu(!1); var n = this; if (i) { if (["mid", "fid"].has(t)) if (FamilyTree.isNEU(e)) console.error("addParentNode invalid childId"); else { FamilyTree.isNEU(i.id) && (i.id = this.generateId()); var o = [] , l = this.get(e); l[t] = i.id, o.push(l); var s = null; Array.isArray(i.pids) && (1 != i.pids.length && console.error("addParentNode: data has to have one partner"), s = this.get(i.pids[0]), Array.isArray(s.pids) || (s.pids = []), s.pids.push(i.id), o.push(s)); var d = { removeNodeId: null, updateNodesData: o, addNodesData: [i] }; if (!0 === a) if (!1 === FamilyTree.events.publish("update", [this, d])) return !1; n._fireUpdate_addUpdateRemove(d, a); var c = e; n.config.roots = [d.addNodesData[0].id], n._draw(!1, FamilyTree.action.insert, { id: c, insertedNodeId: d.addNodesData[0].id }, (function() { n.ripple(d.addNodesData[0].id), r && r(), !0 === a && FamilyTree.events.publish("updated", [n, d]), n.filterUI.update() } )), !0 === a && FamilyTree.events.publish("updating", [n, d]) } else console.error("addParentNode invalid type") } else console.error("addParentNode invalid data") } , FamilyTree.prototype.canRemove = function(e) { var t = this.getNode(e); if (!t) return !1; var i = this.getNode(t.mid) , r = this.getNode(t.fid) , a = t.ftChildrenIds.length > 0 , n = !1 , o = t.pids.length > 0 , l = t.pids.length > 1; if (1 == t.pids.length) { var s = this.getNode(t.pids[0]); n = t.ftChildrenIds.compare(s.ftChildrenIds) } return !(!i && !r || a || o) || (!(i || r || a || l || !o || n) || (!(i || r || !a || !n) || (!(i || r || !a || n) || !(i || r || a || !n)))) } , FamilyTree.prototype.removeNode = function(e, t, i) { var r = this; if (this.canRemove(e)) { var a = this.getNode(e) , n = []; if (Array.isArray(a.pids)) for (var o = 0; o < a.pids.length; o++) { var l = this.get(a.pids[o]); if (l) -1 != (d = l.pids.indexOf(a.id)) && (l.pids.splice(d, 1), n.push(l)) } if (Array.isArray(a.ftChildrenIds)) for (o = 0; o < a.ftChildrenIds.length; o++) { var s = this.get(a.ftChildrenIds[o]); s && (s.mid == a.id ? (s.mid = void 0, n.push(s)) : s.fid == a.id && (s.fid = void 0, n.push(s))) } var d, c = { removeNodeId: e, updateNodesData: n, addNodesData: [] }; if (!0 === i) if (!1 === FamilyTree.events.publish("update", [this, c])) return !1; r._fireUpdate_addUpdateRemove(c, i), -1 != (d = r.config.roots.indexOf(e)) && r.config.roots.splice(d, 1), r._draw(!1, FamilyTree.action.update, null, (function() { r.config.sticky && FamilyTree._moveToBoundaryArea(r.getSvg(), r.getViewBox(), r.response.boundary), t && t(), !0 === i && FamilyTree.events.publish("updated", [r, c]), r.filterUI.update() } )), !0 === i && FamilyTree.events.publish("updating", [r, c]) } } , FamilyTree.prototype.updateNode = function(e, t, i) { var r = this , a = this.getNode(e.id); e.pids || (e.pids = []); var n = []; n.push(e); for (var o = 0; o < a.pids.length; o++) { if (!e.pids.has(a.pids[o])) if ((s = this._get(a.pids[o])) && s.pids) { var l = s.pids.indexOf(e.id); -1 != l && (s.pids.splice(l, 1), n.push(e)), a.pids.splice(o, 1), n.push(s) } } for (o = 0; o < e.pids.length; o++) { var s; if (!a.pids || !a.pids.has(e.pids[o])) (s = this._get(e.pids[o])).pids || (s.pids = []), s.pids.push(e.pids[o]), n.push(s) } var d = { removeNodeId: null, updateNodesData: n, addNodesData: [] }; if (!0 === i && !1 === FamilyTree.events.publish("update", [this, d])) return !1; r._fireUpdate_addUpdateRemove(d, i), r._draw(!1, FamilyTree.action.update, null, (function() { r.config.sticky && FamilyTree._moveToBoundaryArea(r.getSvg(), r.getViewBox(), r.response.boundary), t && t(), !0 === i && FamilyTree.events.publish("updated", [r, d]), r.filterUI.update() } )) } , FamilyTree.prototype._fireUpdate_addUpdateRemove = function(e, t) { for (var i = 0; i < e.addNodesData.length; i++) this.add(e.addNodesData[i]); for (i = 0; i < e.updateNodesData.length; i++) this.update(e.updateNodesData[i]); FamilyTree.isNEU(e.removeNodeId) || this.remove(e.removeNodeId), !0 === t && FamilyTree.events.publish("updating", [this, e]) } , FamilyTree.prototype.__replaceIds = FamilyTree.prototype._replaceIds, FamilyTree.prototype._replaceIds = function(e) { this.__replaceIds(e); for (var t = 0; t < this.config.nodes.length; t++) { var i = this.config.nodes[t]; for (var r in e) { var a = e[r]; if (i.fid == r && (i.fid = a), i.mid == r && (i.mid = a), Array.isArray(i.pids)) for (var n = 0; n < i.pids.length; n++) i.pids[n] == r && (i.pids[n] = a) } } } , void 0 === FamilyTree && (FamilyTree = {}), FamilyTree._ajax = function(e, t, i, r, a) { null == r && (r = "arraybuffer"); var n = new XMLHttpRequest; n.onload = function(e) { 4 == n.readyState && 200 === this.status && (null == e.target ? a(this.response) : a(e.target.response)) } , n.onerror = function(e) { a({ error: e }) } , n.open(t, e), n.responseType = r, n.setRequestHeader("Content-Type", "application/json"), null == i ? n.send() : n.send(i) } , void 0 === FamilyTree && (FamilyTree = {}), FamilyTree.animate = function(e, t, i, r, a, n, o) { var l, s = 10, d = 1, c = r / s + 1; document.getElementsByTagName("g"); return Array.isArray(e) || (e = [e]), Array.isArray(t) || (t = [t]), Array.isArray(i) || (i = [i]), l = setInterval((function() { for (var m = 0; m < e.length; m++) for (var h in i[m]) { var p = FamilyTree._arrayContains(["top", "left", "right", "bottom", "width", "height"], h.toLowerCase()) ? "px" : ""; switch (h.toLowerCase()) { case "d": var f = a((d * s - s) / r) * (i[m][h][0] - t[m][h][0]) + t[m][h][0] , u = a((d * s - s) / r) * (i[m][h][1] - t[m][h][1]) + t[m][h][1]; e[m].setAttribute("d", e[m].getAttribute("d") + " L" + f + " " + u); break; case "r": var y = a((d * s - s) / r) * (i[m][h] - t[m][h]) + t[m][h]; e[m].setAttribute("r", y); break; case "x1": y = a((d * s - s) / r) * (i[m][h] - t[m][h]) + t[m][h]; e[m].setAttribute("x1", y); break; case "x2": y = a((d * s - s) / r) * (i[m][h] - t[m][h]) + t[m][h]; e[m].setAttribute("x2", y); break; case "y1": y = a((d * s - s) / r) * (i[m][h] - t[m][h]) + t[m][h]; e[m].setAttribute("y1", y); break; case "y2": y = a((d * s - s) / r) * (i[m][h] - t[m][h]) + t[m][h]; e[m].setAttribute("y2", y); break; case "rotate3d": if (i[m][h]) { var g = t[m][h] , v = i[m][h] , T = [0, 0, 0, 0]; for (var b in g) T[b] = a((d * s - s) / r) * (v[b] - g[b]) + g[b]; e[m].style.transform = "rotate3d(" + T.toString() + "deg)" } break; case "transform": if (i[m][h]) { g = t[m][h], v = i[m][h], T = [0, 0, 0, 0, 0, 0]; for (var b in g) T[b] = a((d * s - s) / r) * (v[b] - g[b]) + g[b]; e[m].hasAttribute("transform") ? e[m].setAttribute("transform", "matrix(" + T.toString() + ")") : e[m].style.transform = "matrix(" + T.toString() + ")" } break; case "viewbox": if (i[m][h]) { g = t[m][h], v = i[m][h], T = [0, 0, 0, 0]; for (var b in g) T[b] = a((d * s - s) / r) * (v[b] - g[b]) + g[b]; e[m].setAttribute("viewBox", T.toString()) } break; case "margin": if (i[m][h]) { g = t[m][h], v = i[m][h], T = [0, 0, 0, 0]; for (var b in g) T[b] = a((d * s - s) / r) * (v[b] - g[b]) + g[b]; var F = ""; for (b = 0; b < T.length; b++) F += parseInt(T[b]) + "px "; e[m] && e[m].style && (e[m].style[h] = F) } break; case "scrolly": y = a((d * s - s) / r) * (i[m][h] - t[m][h]) + t[m][h]; e[m].scrollTo(0, y); break; default: y = a((d * s - s) / r) * (i[m][h] - t[m][h]) + t[m][h]; e[m] && e[m].style && (e[m].style[h] = y + p) } } o && o(), (d += 1) > c + 1 && (clearInterval(l), n && n(e)) } ), s) } , FamilyTree.anim = {}, FamilyTree.anim.inPow = function(e) { return e < 0 ? 0 : e > 1 ? 1 : Math.pow(e, 2) } , FamilyTree.anim.outPow = function(e) { if (e < 0) return 0; if (e > 1) return 1; return -1 * (Math.pow(e - 1, 2) + -1) } , FamilyTree.anim.inOutPow = function(e) { if (e < 0) return 0; if (e > 1) return 1; if ((e *= 2) < 1) return FamilyTree.anim.inPow(e, 2) / 2; return -.5 * (Math.pow(e - 2, 2) + -2) } , FamilyTree.anim.inSin = function(e) { return e < 0 ? 0 : e > 1 ? 1 : 1 - Math.cos(e * (Math.PI / 2)) } , FamilyTree.anim.outSin = function(e) { return e < 0 ? 0 : e > 1 ? 1 : Math.sin(e * (Math.PI / 2)) } , FamilyTree.anim.inOutSin = function(e) { return e < 0 ? 0 : e > 1 ? 1 : -.5 * (Math.cos(Math.PI * e) - 1) } , FamilyTree.anim.inExp = function(e) { return e < 0 ? 0 : e > 1 ? 1 : Math.pow(2, 10 * (e - 1)) } , FamilyTree.anim.outExp = function(e) { return e < 0 ? 0 : e > 1 ? 1 : 1 - Math.pow(2, -10 * e) } , FamilyTree.anim.inOutExp = function(e) { return e < 0 ? 0 : e > 1 ? 1 : e < .5 ? .5 * Math.pow(2, 10 * (2 * e - 1)) : .5 * (2 - Math.pow(2, 10 * (-2 * e + 1))) } , FamilyTree.anim.inCirc = function(e) { return e < 0 ? 0 : e > 1 ? 1 : -(Math.sqrt(1 - e * e) - 1) } , FamilyTree.anim.outCirc = function(e) { return e < 0 ? 0 : e > 1 ? 1 : Math.sqrt(1 - (e - 1) * (e - 1)) } , FamilyTree.anim.inOutCirc = function(e) { return e < 0 ? 0 : e > 1 ? 1 : e < 1 ? -.5 * (Math.sqrt(1 - e * e) - 1) : .5 * (Math.sqrt(1 - (2 * e - 2) * (2 * e - 2)) + 1) } , FamilyTree.anim.rebound = function(e) { return e < 0 ? 0 : e > 1 ? 1 : e < 1 / 2.75 ? 1 - 7.5625 * e * e : e < 2 / 2.75 ? 1 - (7.5625 * (e - 1.5 / 2.75) * (e - 1.5 / 2.75) + .75) : e < 2.5 / 2.75 ? 1 - (7.5625 * (e - 2.25 / 2.75) * (e - 2.25 / 2.75) + .9375) : 1 - (7.5625 * (e - 2.625 / 2.75) * (e - 2.625 / 2.75) + .984375) } , FamilyTree.anim.inBack = function(e) { return e < 0 ? 0 : e > 1 ? 1 : e * e * (2.70158 * e - 1.70158) } , FamilyTree.anim.outBack = function(e) { return e < 0 ? 0 : e > 1 ? 1 : (e - 1) * (e - 1) * (2.70158 * (e - 1) + 1.70158) + 1 } , FamilyTree.anim.inOutBack = function(e) { return e < 0 ? 0 : e > 1 ? 1 : e < .5 ? 4 * e * e * (7.1898 * e - 2.5949) * .5 : .5 * ((2 * e - 2) * (2 * e - 2) * (3.5949 * (2 * e - 2) + 2.5949) + 2) } , FamilyTree.anim.impulse = function(e) { var t = 2 * e; return t * Math.exp(1 - t) } , FamilyTree.anim.expPulse = function(e) { return Math.exp(-2 * Math.pow(e, 2)) } , void 0 === FamilyTree && (FamilyTree = {}), FamilyTree.prototype._attachInitEventHandlers = function(e) { this._addEvent(window, "resize", this._resizeHandler) } , FamilyTree.prototype._attachEventHandlers = function(e) { if (this.config.interactive) { e = this.getSvg(); this.config.enableTouch || FamilyTree.isMobile() ? (this._addEvent(e, "touchstart", this._globalMouseDownHandler), this._addEvent(e, "touchend", this._globalClickHandler)) : (this._addEvent(e, "mousedown", this._globalMouseDownHandler), this._addEvent(e, "click", this._globalClickHandler), this._addEvent(e, "contextmenu", this._globalContextHandler), this._addEvent(e, "dblclick", this._globalDbClickHandler), this.config.mouseScrool != FamilyTree.action.none && this._addEvent(e, "wheel", this._mouseScrollHandler)); var t = this.getMenuButton(); t && this._addEvent(t, "click", this._menuClickHandler) } } , FamilyTree.prototype._addEvent = function(e, t, i, r) { var a, n; (r || (r = ""), e.getListenerList || (e.getListenerList = {}), e.getListenerList[t + r]) || (a = this, n = i, i = function() { if (n) return n.apply(a, [this, arguments[0]]) } , e.addEventListener ? "mousewheel" == t ? e.addEventListener(t, o, { passive: !1 }) : e.addEventListener(t, o, !1) : e.attachEvent("on" + t, (function() { var t = i.call(e, window.event); return !1 === t && (window.event.returnValue = !1, window.event.cancelBubble = !0), t } )), e.getListenerList[t + r] = o); function o(e) { var t = i.apply(this, arguments); return !1 === t && (e.stopPropagation(), e.preventDefault()), t } } , FamilyTree.prototype._removeEvent = function(e, t) { if (e.getListenerList[t]) { var i = e.getListenerList[t]; e.removeEventListener(t, i, !1), delete e.getListenerList[t] } } , void 0 === FamilyTree && (FamilyTree = {}), FamilyTree.VERSION = "8.14.54", FamilyTree.orientation = {}, FamilyTree.orientation.top = 0, FamilyTree.orientation.bottom = 1, FamilyTree.orientation.right = 2, FamilyTree.orientation.left = 3, FamilyTree.orientation.top_left = 4, FamilyTree.orientation.bottom_left = 5, FamilyTree.orientation.right_top = 6, FamilyTree.orientation.left_top = 7, FamilyTree.align = {}, FamilyTree.align.center = FamilyTree.CENTER = 8, FamilyTree.align.orientation = FamilyTree.ORIENTATION = 9, FamilyTree.attr = {}, FamilyTree.attr.l = "data-l", FamilyTree.attr.id = "data-id", FamilyTree.attr.sl = "data-sl", FamilyTree.attr.lbl = "data-lbl", FamilyTree.attr.val = "data-val", FamilyTree.attr.tlbr = "data-tlbr", FamilyTree.attr.item = "data-item", FamilyTree.attr.layout = "data-layout", FamilyTree.attr.node_id = "data-n-id", FamilyTree.attr.link_id = "data-l-id", FamilyTree.attr.field_name = "data-f-name", FamilyTree.attr.c_link_to = "data-c-l-to", FamilyTree.attr.c_link_from = "data-c-l-from", FamilyTree.attr.s_link_to = "data-s-l-to", FamilyTree.attr.s_link_from = "data-s-l-from", FamilyTree.attr.control_add = "data-ctrl-add", FamilyTree.attr.control_expcoll_id = "data-ctrl-ec-id", FamilyTree.attr.control_up_id = "data-ctrl-up-id", FamilyTree.attr.control_export_menu = "data-ctrl-menu", FamilyTree.attr.control_node_menu_id = "data-ctrl-n-menu-id", FamilyTree.attr.control_node_circle_menu_id = "data-ctrl-n-c-menu-id", FamilyTree.attr.control_node_circle_menu_name = "data-ctrl-n-c-menu-name", FamilyTree.attr.control_node_circle_menu_wrraper_id = "data-ctrl-n-c-menu-wrapper-id", FamilyTree.attr.width = "data-width", FamilyTree.attr.text_overflow = "data-text-overflow", FamilyTree.ID = "id", FamilyTree.PID = "pid", FamilyTree.STPID = "stpid", FamilyTree.TAGS = "tags", FamilyTree.NODES = "nodes", FamilyTree.ELASTIC = "elastic", FamilyTree.ASSISTANT = "Assistant", FamilyTree.action = {}, FamilyTree.action.expand = 0, FamilyTree.action.collapse = 1, FamilyTree.action.maximize = 101, FamilyTree.action.minimize = 102, FamilyTree.action.expandCollapse = 501, FamilyTree.action.edit = 1, FamilyTree.action.zoom = 2, FamilyTree.action.ctrlZoom = 22, FamilyTree.action.scroll = 41, FamilyTree.action.xScroll = 3, FamilyTree.action.yScroll = 4, FamilyTree.action.none = 5, FamilyTree.action.init = 6, FamilyTree.action.update = 7, FamilyTree.action.move = 70, FamilyTree.action.pan = 8, FamilyTree.action.centerNode = 9, FamilyTree.action.resize = 10, FamilyTree.action.insert = 11, FamilyTree.action.insertfirst = 12, FamilyTree.action.details = 13, FamilyTree.action.exporting = 14, FamilyTree.none = 400001, FamilyTree.scroll = {}, FamilyTree.scroll.visible = !0, FamilyTree.scroll.smooth = 12, FamilyTree.scroll.speed = 120, FamilyTree.scroll.safari = { smooth: 12, speed: 250 }, FamilyTree.match = {}, FamilyTree.match.height = 100001, FamilyTree.match.width = 100002, FamilyTree.match.boundary = 100003, FamilyTree.movable = {}, FamilyTree.movable.node = "node", FamilyTree.movable.tree = "tree", FamilyTree.movable.detachTree = "detachTree", FamilyTree.layout = {}, FamilyTree.layout.normal = FamilyTree.normal = 0, FamilyTree.layout.mixed = FamilyTree.mixed = 1, FamilyTree.layout.tree = FamilyTree.tree = 2, FamilyTree.layout.treeLeftOffset = FamilyTree.treeLeftOffset = 3, FamilyTree.layout.treeRightOffset = FamilyTree.treeRightOffset = 4, FamilyTree.layout.treeLeft = 5, FamilyTree.layout.treeRight = 6, FamilyTree.layout.grid = -1, FamilyTree.nodeOpenTag = "", FamilyTree.linkOpenTag = "', FamilyTree.expcollOpenTag = "', FamilyTree.upOpenTag = "', FamilyTree.linkFieldsOpenTag = '', FamilyTree.grCloseTag = "", FamilyTree.A5w = 420, FamilyTree.A5h = 595, FamilyTree.A4w = 595, FamilyTree.A4h = 842, FamilyTree.A3w = 842, FamilyTree.A3h = 1191, FamilyTree.A2w = 1191, FamilyTree.A2h = 1684, FamilyTree.A1w = 1684, FamilyTree.A1h = 2384, FamilyTree.Letterw = 612, FamilyTree.Letterh = 791, FamilyTree.Legalw = 612, FamilyTree.Legalh = 1009, FamilyTree.COLLAPSE_PARENT_NEIGHBORS = 1, FamilyTree.COLLAPSE_SUB_CHILDRENS = 2, FamilyTree.COLLAPSE_PARENT_SUB_CHILDREN_EXCEPT_CLICKED = 3, FamilyTree.TEXT_THRESHOLD = 400, FamilyTree.IMAGES_THRESHOLD = 100, FamilyTree.LINKS_THRESHOLD = 200, FamilyTree.BUTTONS_THRESHOLD = 70, FamilyTree.ANIM_THRESHOLD = 50, FamilyTree.IT_IS_LONELY_HERE = '{link}', FamilyTree.RES = {}, FamilyTree.IT_IS_LONELY_HERE_LINK = FamilyTree.RES.IT_IS_LONELY_HERE_LINK = "It's lonely here, add your first node", FamilyTree.FIRE_DRAG_NOT_CLICK_IF_MOVE = 3, FamilyTree.STRING_TAGS = !1, FamilyTree.MAX_NODES_MESS = "The trial has expired or 200 nodes limit was reached!
See more", FamilyTree.OFFLINE_MESS = "The evaluation version requires internet connection!
See more", FamilyTree.SEARCH_PLACEHOLDER = "Search... type ? to get help.", FamilyTree.SEARCH_HELP_SYMBOL = "?", FamilyTree.SEARCH_CLOSE_RESULT_ON_ESCAPE_OR_CLICKOUTSIDE = !1, FamilyTree.SEARCH_RESULT_LIMIT = 10, FamilyTree.IMPORT_MESSAGE = "Choose the columns (fields) in your data file that contain the required information.", FamilyTree.FIXED_POSITION_ON_CLICK = !1, FamilyTree.RENDER_LINKS_BEFORE_NODES = !1, FamilyTree.RENDER_CLINKS_BEFORE_NODES = !1, FamilyTree.MIXED_LAYOUT_ALL_NODES = !0, FamilyTree.MIXED_LAYOUT_FOR_NODES_WITH_COLLAPSED_CHILDREN = !1, FamilyTree.MIXED_LAYOUT_IF_NUMBER_OF_CHILDREN_IS_MORE_THEN = 1, FamilyTree.LINK_ROUNDED_CORNERS = 5, FamilyTree.MOVE_STEP = 5, FamilyTree.CLINK_CURVE = 1, FamilyTree.MAX_DEPTH = 200, FamilyTree.SCALE_FACTOR = 1.44, FamilyTree.LAZY_LOADING_FACTOR = 500, FamilyTree.HIDE_EDIT_FORM_ON_PAN = !0, FamilyTree.LAZY_LOADING = !0, FamilyTree.ARRAY_FIELDS = ["tags"], FamilyTree.CSV_DELIMITER = ",", FamilyTree.EDITFORM_CLOSE_BTN = '', FamilyTree.ESCAPE_HTML = !1, FamilyTree.VERTICAL_CHILDREN_ASSISTANT = !1, FamilyTree.EXPORT_PAGES_CUT_NODES = !1, FamilyTree.RESET_MOVABLE_ONEXPANDCOLLAPSE = !1, FamilyTree.FILTER_ALPHABETICALLY = !0, FamilyTree.SERVER_PREFIX = ".azurewebsites.net/api/OrgChartJS", FamilyTree.FUNC_URL_NAME = "func-url-orgfamilyjs", FamilyTree.MINIMUM_SYMBOLS_IN_SEARCH_INPUT = 1, "undefined" != typeof module && (module.exports = FamilyTree), FamilyTree.SERVER_PREFIX = ".azurewebsites.net/api/FamilyTreeJS", FamilyTree.FUNC_URL_NAME = "func-url-familytreejs", FamilyTree.OC_VERSION = FamilyTree.VERSION, FamilyTree.VERSION = "1.09.43", FamilyTree.RENDER_LINKS_BEFORE_NODES = !0, FamilyTree.ARRAY_FIELDS = ["tags", "pids"], FamilyTree._intersects = function(e, t, i) { var r = e.x - i.siblingSeparation / 4 , a = e.y , n = e.x + e.w + i.siblingSeparation / 4 , o = e.y; switch (i.orientation) { case FamilyTree.orientation.right: case FamilyTree.orientation.right_top: case FamilyTree.orientation.left: case FamilyTree.orientation.left_top: r = e.x, a = e.y - i.siblingSeparation / 4, n = e.x, o = e.y + e.h + i.siblingSeparation / 4 } var l, s, d, c = t.p, m = t.q, h = t.r, p = t.s; return 0 !== (l = (n - r) * (p - m) - (h - c) * (o - a)) && (s = ((a - o) * (h - r) + (n - r) * (p - a)) / l, 0 < (d = ((p - m) * (h - r) + (c - h) * (p - a)) / l) && d < 1 && 0 < s && s < 1) } , FamilyTree._addPoint = function(e, t, i, r, a) { switch (i.orientation) { case FamilyTree.orientation.top: case FamilyTree.orientation.top_left: return FamilyTree._addPointTop(e, t, i, r, a); case FamilyTree.orientation.bottom: case FamilyTree.orientation.bottom_left: return FamilyTree._addPointBottom(e, t, i, r, a); case FamilyTree.orientation.left: case FamilyTree.orientation.left_top: return FamilyTree._addPointLeft(e, t, i, r, a); case FamilyTree.orientation.right: case FamilyTree.orientation.right_top: return FamilyTree._addPointRight(e, t, i, r, a) } } , FamilyTree._addPointTop = function(e, t, i, r, a) { var n, o, l; return "left" == a ? n = e.leftNeighbor ? e.x + (e.leftNeighbor.x + e.leftNeighbor.w - e.x) / 2 : e.x - i.siblingSeparation / 2 : "right" == a && (n = e.rightNeighbor ? e.x + e.w + (e.rightNeighbor.x - (e.x + e.w)) / 2 : e.x + e.w + i.siblingSeparation / 2), t.push([n, t[t.length - 1][1]]), t.push([n, e.y - i.levelSeparation / 3]), o = t[t.length - 1][1], l = n, r.p = n, r.q = o, r.r = l, r } , FamilyTree._addPointBottom = function(e, t, i, r, a) { var n, o, l; return "left" == a ? n = e.leftNeighbor ? e.x + (e.leftNeighbor.x + e.leftNeighbor.w - e.x) / 2 : e.x - i.siblingSeparation / 2 : "right" == a && (n = e.rightNeighbor ? e.x + e.w + (e.rightNeighbor.x - (e.x + e.w)) / 2 : e.x + e.w + i.siblingSeparation / 2), t.push([n, t[t.length - 1][1]]), t.push([n, e.y + e.h + i.levelSeparation / 3]), o = t[t.length - 1][1], l = n, r.p = n, r.q = o, r.r = l, r } , FamilyTree._addPointLeft = function(e, t, i, r, a) { var n, o = t[t.length - 1][0]; "bottom" == a ? n = e.rightNeighbor ? e.y + e.h + (e.rightNeighbor.y - (e.y + e.h)) / 2 : e.y + e.h + i.siblingSeparation / 2 : "top" == a && (n = e.leftNeighbor ? e.y + (e.leftNeighbor.y + e.leftNeighbor.h - e.y) / 2 : e.y - i.siblingSeparation / 2), t.push([t[t.length - 1][0], n]), t.push([e.x - i.levelSeparation / 3, n]), o = t[t.length - 1][0]; var l = n; return r.p = o, r.q = n, r.s = l, r } , FamilyTree._addPointRight = function(e, t, i, r, a) { var n, o = t[t.length - 1][0]; "bottom" == a ? n = e.rightNeighbor ? e.y + e.h + (e.rightNeighbor.y - (e.y + e.h)) / 2 : e.y + e.h + i.siblingSeparation / 2 : "top" == a && (n = e.leftNeighbor ? e.y + (e.leftNeighbor.y + e.leftNeighbor.h - e.y) / 2 : e.y - i.siblingSeparation / 2), t.push([t[t.length - 1][0], n]), t.push([e.x + e.w + i.levelSeparation / 3, n]), o = t[t.length - 1][0]; var l = n; return r.p = o, r.q = n, r.s = l, r } , FamilyTree.editUI = function() {} , FamilyTree.editUI.prototype.init = function(e) { this.obj = e, this.fields = null, this._event_id = FamilyTree._guid() } , FamilyTree.editUI.prototype.on = function(e, t) { return FamilyTree.events.on(e, t, this._event_id), this } , FamilyTree.editUI.prototype.show = function(e, t, i) { if (this.hide(), !1 === FamilyTree.events.publish("show", [this, e])) return !1; var r = this , a = this.content(e, t, i); this.obj.element.appendChild(a.element), FamilyTree.input.init(this.obj.element), i ? t || this._focusElement(a.focusId) : this.interval = FamilyTree.animate(a.element, { right: -20, opacity: 0 }, { right: 0, opacity: 1 }, 300, FamilyTree.anim.outSin, (function() { t || r._focusElement(a.focusId) } )), this.obj.element.querySelector("[data-edit-from-close]").addEventListener("click", (function(t) { t.preventDefault(), !1 !== FamilyTree.events.publish("cancel", [r, { id: e }]) && r.hide() } )), this.obj.element.querySelector("[data-edit-from-cancel]").addEventListener("click", (function(t) { t.preventDefault(), !1 !== FamilyTree.events.publish("cancel", [r, { id: e }]) && r.hide() } )), this.obj.element.querySelector("[data-edit-from-save]").addEventListener("click", (function(t) { t.preventDefault(); var i = FamilyTree.input.validateAndGetData(a.element); if (!1 !== i) { var n = r.obj.get(e) , o = { data: FamilyTree.mergeDeep(n, i) }; if (!1 === FamilyTree.events.publish("save", [r, o])) return; r.obj.updateNode(o.data, null, !0), r.hide() } } )); for (var n = this.obj.element.querySelectorAll("[data-input-btn]"), o = 0; o < n.length; o++) { n[o].addEventListener("click", (function(t) { t.preventDefault(), FamilyTree.events.publish("element-btn-click", [r, { input: this.parentNode.querySelector("input"), nodeId: e, event: t }]) } )) } this.obj.element.querySelector("[data-add-more-fields-btn]").addEventListener("click", (function(e) { e.stopPropagation(), e.preventDefault(); var t = this , i = FamilyTree.elements.textbox({}, { type: "textbox", label: r.obj.config.editForm.addMoreFieldName, btn: r.obj.config.editForm.addMoreBtn }, "280px"); t.parentNode.insertAdjacentHTML("beforebegin", i.html), t.style.display = "none", FamilyTree.input.init(t.parentNode.previousSibling); var a = document.getElementById(i.id); a.focus(), a.nextElementSibling.addEventListener("click", (function(e) { e.stopPropagation(), e.preventDefault(); var i = a.value , n = r.obj.element.querySelector('[data-binding="' + FamilyTree._escapeDoubleQuotes(a.value) + '"]'); if (FamilyTree.isNEU(i) || n) a.focus(); else { var o = FamilyTree.elements.textbox({}, { type: "textbox", label: i, binding: i }, "280px"); a.parentNode.parentNode.parentNode.removeChild(a.parentNode.parentNode), t.parentNode.insertAdjacentHTML("beforebegin", o.html), t.style.display = "", FamilyTree.input.init(t.parentNode.previousSibling), document.getElementById(o.id).focus() } } )) } )), this.obj.element.querySelector("[data-bft-edit-from-btns]").addEventListener("click", (function(t) { for (var i = t.target; i && i.hasAttribute && !i.hasAttribute("data-edit-from-btn"); ) i = i.parentNode; if (i && i.hasAttribute) { var n = i.getAttribute("data-edit-from-btn") , o = { button: r.obj.config.editForm.buttons[n], name: n, nodeId: e, event: t }; if (!1 === FamilyTree.events.publish("button-click", [r, o])) return !1; switch (n) { case "edit": r.obj.editUI.show(e, !1, !0); break; case "pdf": r.obj.exportPDFProfile({ id: e, filename: a.title }), r.hide(); break; case "png": r.obj.exportPNGProfile({ id: e, filename: a.title }), r.hide(); break; case "share": r.obj.shareProfile(e); break; case "remove": r.obj.removeNode(e, null, !0), r.hide() } } } )) } , FamilyTree.editUI.prototype._focusElement = function(e) { var t = null; FamilyTree.isNEU(this.obj.config.editForm.focusBinding) ? FamilyTree.isNEU(e) || (t = document.getElementById(e)) : t = this.obj.element.querySelector('[data-binding="' + this.obj.config.editForm.focusBinding + '"]'), t && (t.value && t.value.length && t.setSelectionRange(t.value.length, t.value.length), t.focus()) } , FamilyTree.editUI.prototype.setAvatar = function(e) { var t = this.obj.element.querySelector("#bft-avatar"); FamilyTree.isNEU(e) ? t.innerHTML = FamilyTree.icon.user(150, 150, "#8C8C8C", 0, 0) : t.innerHTML = `` } , FamilyTree.editUI.prototype.content = function(e, t, i, r, a) { var n, o = this.obj.config.editForm.readOnly, l = JSON.parse(JSON.stringify(this.obj.config.editForm.elements)), s = this.obj.config.editForm.addMore, d = this.obj.config.editForm.saveAndCloseBtn, c = this.obj.config.editForm.cancelBtn, m = this.obj.config.editForm.buttons, h = this.obj.config.editForm.titleBinding, p = this.obj.config.editForm.photoBinding, f = this.obj.getNode(e), u = this.obj._get(e), y = FamilyTree.t(f.templateName, f.min, this.obj.getScale()), g = u[h], v = u[p]; if (this.obj.config.editForm.generateElementsFromFields) for (var T = 0; T < this.fields.length; T++) { var b = this.fields[T]; if ("tags" != b) { for (var F = !1, x = 0; x < l.length; x++) { if (Array.isArray(l[x])) { for (var _ = 0; _ < l[x].length; _++) if (b == l[x][_].binding) { F = !0; break } } else if (b == l[x].binding) { F = !0; break } if (F) break } F || l.push({ type: "textbox", label: b, binding: b }) } } FamilyTree.isNEU(g) && (g = ""), v = FamilyTree.isNEU(v) ? FamilyTree.icon.user(150, 150, "#8C8C8C", 0, 0) : ``; var w = !t , k = t ? "display:none;" : "" , S = t || !s ? "display:none;" : "" , C = y.editFormHeaderColor ? `style="background-color:${y.editFormHeaderColor};"` : "" , I = document.createElement("form"); if (I.setAttribute("data-bft-edit-form", ""), I.classList.add("bft-edit-form"), I.classList.add(this.obj.config.mode), I.classList.add(f.templateName.replaceAll(" ", "")), I.classList.add(FamilyTree.ui._defsIds[f.templateName]), Array.isArray(f.tags) && f.tags.length) for (T = 0; T < f.tags.length; T++) I.classList.add(f.tags[T].replaceAll(" ", "")); I.style.display = "flex", I.style.opacity = i ? 1 : 0, I.style.right = i ? 0 : "-20px", r && (I.style.width = r); var N = [] , A = a ? "" : FamilyTree.EDITFORM_CLOSE_BTN; return I.innerHTML = `
\n
\n ${A}\n ${FamilyTree.editUI.renderHeaderContent(g, v, f, u)}\n
\n
\n ${function() { if (a) return ""; var e = ""; for (var i in m) { var r = m[i]; FamilyTree.isNEU(r) || (w && r.hideIfEditMode || t && r.hideIfDetailsMode || o && "Edit" == r.text || (e += `
${r.icon}
`)) } return e }()} \n
\n
\n
\n
\n
\n ${function() { for (var e = "", i = 0; i < l.length; i++) { var r = l[i]; if (Array.isArray(r)) { e += '
'; for (var a = 0; a < r.length; a++) { var o = r[a] , s = FamilyTree.elements[o.type](u, o, "unset", t); !FamilyTree.isNEU(s.id) && FamilyTree.isNEU(n) && FamilyTree.isNEU(s.value) && (n = s.id), FamilyTree.isNEU(s.value) || N.push(`${o.label}: ${s.value}`), e += s.html } e += "
" } else { s = FamilyTree.elements[r.type](u, r, "280px", t); !FamilyTree.isNEU(s.id) && FamilyTree.isNEU(n) && FamilyTree.isNEU(s.value) && (n = s.id), FamilyTree.isNEU(s.value) || N.push(`${r.label}: ${s.value}`), e += s.html } } return e }()}\n\n
\n ${s}\n
\n
\n
\n
\n
\n
\n \n
\n
\n \n
\n
`, { element: I, focusId: n, title: g, shareText: N.join("\n") } } , FamilyTree.editUI.prototype.hide = function() { if (!1 === FamilyTree.events.publish("hide", [this])) return !1; FamilyTree.isNEU(this.interval) && (clearInterval(this.interval), this.interval = null); var e = this.obj.element.querySelector("[data-bft-edit-form]"); e && e.parentNode && e.parentNode.removeChild(e) } , FamilyTree.editUI.renderHeaderContent = function(e, t, i, r) { return `

${FamilyTree._escapeGreaterLessSign(e)}

\n
${t}
` } , FamilyTree.prototype.getSvg = function() { var e = this.element.getElementsByTagName("svg"); return e && e.length ? e[0] : null } , FamilyTree.prototype.getPointerElement = function() { return this.element.querySelector("g[data-pointer]") } , FamilyTree.prototype.getNodeElement = function(e) { return this.element.querySelector("[" + FamilyTree.attr.node_id + "='" + e + "']") } , FamilyTree.prototype.getMenuButton = function() { return this.element.querySelector("[" + FamilyTree.attr.control_export_menu + "]") } , FamilyTree.menuUI = function() {} , FamilyTree.menuUI.prototype.init = function(e, t) { this.obj = e, this.wrapper = null, this.menu = t, this._event_id = FamilyTree._guid() } , FamilyTree.menuUI.prototype.showStickIn = function(e, t, i, r) { this._show(e, null, t, i, r) } , FamilyTree.menuUI.prototype.show = function(e, t, i, r, a) { this._show(e, t, i, r, a) } , FamilyTree.menuUI.prototype._show = function(e, t, i, r, a) { var n = this; this.hide(); var o = ""; a || (a = this.menu); var l = { firstNodeId: i, secondNodeId: r, menu: a }; if (!1 === FamilyTree.events.publish("show", [this, l])) return !1; for (var s in a = l.menu) { var d = a[s].icon , c = a[s].text; void 0 === d && (d = FamilyTree.icon[s] ? FamilyTree.icon[s](24, 24, "#7A7A7A") : ""), "function" == typeof c && (c = c()), "function" == typeof d && (d = d()), o += "
' + d + "  " + c + "
" } if ("" != o) { if (this.wrapper = document.createElement("div"), this.wrapper.className = "bft-family-menu", this.wrapper.style.left = "-99999px", this.wrapper.style.top = "-99999px", this.wrapper.innerHTML = o, this.obj.element.appendChild(this.wrapper), null == t) { var m = FamilyTree._menuPosition(e, this.wrapper, this.obj.getSvg()); e = m.x, t = m.y } var h = e + 45; this.wrapper.style.left = h + "px", this.wrapper.style.top = t + "px", this.wrapper.style.left = h - this.wrapper.offsetWidth + "px"; var p = e - this.wrapper.offsetWidth; FamilyTree.animate(this.wrapper, { opacity: 0, left: h - this.wrapper.offsetWidth }, { opacity: 1, left: p }, 300, FamilyTree.anim.inOutPow); for (var f = this.wrapper.getElementsByTagName("div"), u = 0; u < f.length; u++) { (s = f[u]).addEventListener("click", (function(e) { var t, o = this.getAttribute(FamilyTree.attr.item); if (void 0 === a[o].onClick) if ("add" === o) { var l = { id: n.obj.generateId(), pid: i }; n.obj.addNode(l, null, !0) } else if ("edit" === o) { var s = n.obj.getNode(i); n.obj.editUI.show(s.id) } else if ("details" === o) { s = n.obj.getNode(i); n.obj.editUI.show(s.id, !0) } else "remove" === o ? n.obj.removeNode(i, null, !0) : "svg" === o ? n.obj.exportSVG({ filename: "FamilyTree.svg", expandChildren: !1, nodeId: i }) : "pdf" === o ? n.obj.exportPDF({ filename: "FamilyTree.pdf", expandChildren: !1, nodeId: i }) : "png" === o ? n.obj.exportPNG({ filename: "FamilyTree.png", expandChildren: !1, nodeId: i }) : "csv" === o ? n.obj.exportCSV({ nodeId: i }) : "xml" === o ? n.obj.exportXML({ nodeId: i }) : "json" === o && n.obj.exportJSON({ nodeId: i }); else t = a[o].onClick.call(n.obj, i, r); 0 != t && n.hide() } )) } } } , FamilyTree.menuUI.prototype.isVisible = function() { return null != this.wrapper } , FamilyTree.menuUI.prototype.hide = function() { null != this.wrapper && (this.obj.element.removeChild(this.wrapper), this.wrapper = null) } , FamilyTree.menuUI.prototype.on = function(e, t) { return FamilyTree.events.on(e, t, this._event_id), this } , FamilyTree.circleMenuUI = function() {} , FamilyTree.circleMenuUI.prototype.init = function(e, t) { this.obj = e, this.menu = t, this._menu = null, this._buttonsInterval = [], this._linesInterval = [], this._event_id = FamilyTree._guid() } , FamilyTree.circleMenuUI.prototype.show = function(e, t) { this._show(e, t) } , FamilyTree.circleMenuUI.prototype._show = function(e, t) { var i = this , r = this.obj.getNode(e) , a = FamilyTree.t(r.templateName, r.min, this.obj.getScale()); if (!FamilyTree.isNEU(a.nodeCircleMenuButton)) { var n = this.obj.getSvg() , o = this.obj.element.querySelector("[" + FamilyTree.attr.control_node_circle_menu_id + '="' + e + '"]') , l = this.obj.getNodeElement(e) , s = FamilyTree._getTransform(o) , d = FamilyTree._getTransform(l) , c = s[4] + d[4] , m = s[5] + d[5] , h = o.querySelectorAll("line") , p = this.obj.element.querySelector("[" + FamilyTree.attr.control_node_circle_menu_wrraper_id + "]"); if (FamilyTree.isNEU(p) || p.getAttribute(FamilyTree.attr.control_node_circle_menu_wrraper_id) != e) { this.hide(), t || (t = this.menu); var f = { nodeId: e, menu: t } , u = FamilyTree.events.publish("show", [this, f]); if (this._menu = t, !1 === u) return !1; for (var y = 0, g = Object.keys(f.menu).length, v = 2 * a.nodeCircleMenuButton.radius + 4, T = 2 * Math.PI * v, b = T / g - (2 * a.nodeCircleMenuButton.radius + 2); b < 0; ) v += 8, b = (T = 2 * Math.PI * v) / g - (2 * a.nodeCircleMenuButton.radius + 2); for (var F in (p = document.createElementNS("http://www.w3.org/2000/svg", "g")).setAttribute(FamilyTree.attr.control_node_circle_menu_wrraper_id, e), p.setAttribute("transform", "matrix(1,0,0,1," + c + "," + m + ")"), n.appendChild(p), f.menu) { var x = f.menu[F].icon , _ = f.menu[F].color , w = f.menu[F].text; "function" == typeof x && (x = x()), "function" == typeof _ && (_ = _()), "function" == typeof w && (w = w()); var k = document.createElementNS("http://www.w3.org/2000/svg", "g"); k.setAttribute("transform", "matrix(1,0,0,1,0,0)"), k.setAttribute(FamilyTree.attr.control_node_circle_menu_name, F), k.style.cursor = "pointer"; var S = document.createElementNS("http://www.w3.org/2000/svg", "title"); FamilyTree.isNEU(w) || (S.innerHTML = w); var C = document.createElementNS("http://www.w3.org/2000/svg", "circle"); C.setAttribute("cx", 0), C.setAttribute("cy", 0), C.setAttribute("r", a.nodeCircleMenuButton.radius), C.setAttribute("fill", _), C.setAttribute("stroke-width", "1"), C.setAttribute("stroke", a.nodeCircleMenuButton.stroke), k.appendChild(C), k.appendChild(S), k.innerHTML += x, p.appendChild(k); var I = k.getElementsByTagName("svg")[0]; if (I.setAttribute("pointer-events", "none"), I) { var N = parseInt(I.getAttribute("width")) , A = parseInt(I.getAttribute("height")); I.setAttribute("x", -N / 2), I.setAttribute("y", -A / 2) } var L = y * Math.PI / (g / 2); y++; var E = Math.cos(L) * v , M = Math.sin(L) * v; this._buttonsInterval.push(FamilyTree.animate(k, { transform: [1, 0, 0, 1, 0, 0] }, { transform: [1, 0, 0, 1, E, M] }, 250, FamilyTree.anim.outBack, (function(e) { var t = e[0].getAttribute(FamilyTree.attr.control_node_circle_menu_name) , r = e[0].parentNode.getAttribute(FamilyTree.attr.control_node_circle_menu_wrraper_id); e[0].addEventListener("mouseenter", (function(e) { FamilyTree.events.publish("mouseenter", [i, { from: r, menuItem: f.menu[t], menuItemName: t, event: e }]) } )), e[0].addEventListener("mouseout", (function(e) { FamilyTree.events.publish("mouseout", [i, { from: r, menuItem: f.menu[t], menuItemName: t, event: e }]) } )) } ))) } this._linesInterval.push(FamilyTree.animate(h[0], { x1: -a.nodeCircleMenuButton.radius / 2, y1: -6, x2: a.nodeCircleMenuButton.radius / 2, y2: -6 }, { x1: -7, y1: -7, x2: 7, y2: 7 }, 500, FamilyTree.anim.inOutSin)), this._linesInterval.push(FamilyTree.animate(h[1], { x1: -a.nodeCircleMenuButton.radius / 2, y1: 0, x2: a.nodeCircleMenuButton.radius / 2, y2: 0 }, { x1: 0, y1: 0, x2: 0, y2: 0 }, 500, FamilyTree.anim.inOutSin)), this._linesInterval.push(FamilyTree.animate(h[2], { x1: -a.nodeCircleMenuButton.radius / 2, y1: 6, x2: a.nodeCircleMenuButton.radius / 2, y2: 6 }, { x1: -7, y1: 7, x2: 7, y2: -7 }, 500, FamilyTree.anim.inOutSin)) } else this.hide() } } , FamilyTree.circleMenuUI.prototype.hide = function() { for (var e = this._buttonsInterval.length - 1; e >= 0; e--) clearInterval(this._buttonsInterval[e]), this._buttonsInterval.splice(e, 1); this._buttonsInterval = []; for (e = this._linesInterval.length - 1; e >= 0; e--) clearInterval(this._linesInterval[e]), this._linesInterval.splice(e, 1); this._linesInterval = []; var t = this.obj.element.querySelector("[" + FamilyTree.attr.control_node_circle_menu_wrraper_id + "]"); if (null != t) { var i = t.getAttribute(FamilyTree.attr.control_node_circle_menu_wrraper_id) , r = this.obj.getNode(i) , a = FamilyTree.t(r.templateName, r.min, this.obj.getScale()) , n = this.obj.element.querySelector("[" + FamilyTree.attr.control_node_circle_menu_id + '="' + i + '"]').querySelectorAll("line"); n[0].setAttribute("x1", -a.nodeCircleMenuButton.radius / 2), n[0].setAttribute("x2", a.nodeCircleMenuButton.radius / 2), n[0].setAttribute("y1", -6), n[0].setAttribute("y2", -6), n[1].setAttribute("x1", -a.nodeCircleMenuButton.radius / 2), n[1].setAttribute("x2", a.nodeCircleMenuButton.radius / 2), n[1].setAttribute("y1", 0), n[1].setAttribute("y2", 0), n[2].setAttribute("x1", -a.nodeCircleMenuButton.radius / 2), n[2].setAttribute("x2", a.nodeCircleMenuButton.radius / 2), n[2].setAttribute("y1", 6), n[2].setAttribute("y2", 6), t.parentElement.removeChild(t), t = null } } , FamilyTree.circleMenuUI.prototype.on = function(e, t) { return FamilyTree.events.on(e, t, this._event_id), this } , void 0 === FamilyTree && (FamilyTree = {}), FamilyTree.idb = { version: 1, dbName: "BALKAN", tableName: "familytree-js", keyPath: "id" }, FamilyTree.idb.db = null, FamilyTree.idb._open = function(e) { if (FamilyTree._browser().msie) e && e(!1); else if ((navigator.userAgent.toLowerCase().indexOf("safari") > 0 || navigator.userAgent.toLowerCase().indexOf("firefox") > 0) && window.location !== window.parent.location) e && e(!1); else { if (!window.indexedDB) return console.error("Your browser doesn't support a stable version of IndexedDB."), void (e && e(!1)); if (null == FamilyTree.idb.db) { var t = indexedDB.open(FamilyTree.idb.dbName, FamilyTree.idb.version); t.onerror = function(t) { console.error("Cannot open database!"), e && e(!1) } , t.onsuccess = function(t) { FamilyTree.idb.db = t.target.result, e && e(!0) } , t.onupgradeneeded = function(e) { var t = e.target.result; t.objectStoreNames.contains(FamilyTree.idb.tableName) && t.deleteObjectStore(FamilyTree.idb.tableName); t.createObjectStore(FamilyTree.idb.tableName, { keyPath: FamilyTree.idb.keyPath }) } } else e && e(!0) } } , FamilyTree.idb.read = function(e, t) { FamilyTree.idb._open((function(i) { if (i) { var r = FamilyTree.idb.db.transaction([FamilyTree.idb.tableName]).objectStore(FamilyTree.idb.tableName).get(e); r.onerror = function(e) { console.error("Unable to retrieve data from database!"), t && t(!1) } , r.onsuccess = function(e) { r.result ? t && t(!0, r.result) : t && t(null) } } else t && t(!1) } )) } , FamilyTree.idb.write = function(e, t) { FamilyTree.idb.read(e.id, (function(i) { if (null == i) { var r = FamilyTree.idb.db.transaction([FamilyTree.idb.tableName], "readwrite").objectStore(FamilyTree.idb.tableName).add(e); r.onerror = function(e) { console.error("Unable to add data to database!"), t && t(!1) } , r.onsuccess = function(e) { t && t(!0) } } else t && t(i) } )) } , FamilyTree.idb.put = function(e, t) { FamilyTree.idb._open((function(i) { if (i) { var r = FamilyTree.idb.db.transaction([FamilyTree.idb.tableName], "readwrite").objectStore(FamilyTree.idb.tableName).put(e); r.onerror = function(e) { console.error("Unable to put data to database!"), t && t(!1) } , r.onsuccess = function(e) { t && t(!0) } } else t && t(!1) } )) } , FamilyTree.idb.delete = function(e, t) { FamilyTree.idb._open((function(i) { if (i) { var r = FamilyTree.idb.db.transaction([FamilyTree.idb.tableName], "readwrite").objectStore(FamilyTree.idb.tableName).delete(e); r.onerror = function(e) { console.error("Unable to retrieve data from database!"), t && t(!1) } , r.onsuccess = function(e) { r.error ? t && t(!1) : t && t(!0) } } else t && t(!1) } )) } , FamilyTree.toolbarUI = function() {} , FamilyTree.toolbarUI.expandAllIcon = '', FamilyTree.toolbarUI.fitIcon = '', FamilyTree.toolbarUI.openFullScreenIcon = '', FamilyTree.toolbarUI.closeFullScreenIcon = '', FamilyTree.toolbarUI.zoomInIcon = '', FamilyTree.toolbarUI.zoomOutIcon = '', FamilyTree.toolbarUI.layoutIcon = "', FamilyTree.toolbarUI.prototype.init = function(e, t) { if (t) { this.obj = e, this.toolbar = t, this._visible = !1, this.div = document.createElement("div"), this.div.classList.add("bft-toolbar-container"), Object.assign(this.div.style, { position: "absolute", padding: "3px", right: this.obj.config.padding - 10 + "px", bottom: this.obj.config.padding - 10 + "px" }), t.expandAll && (this.div.innerHTML += "
' + FamilyTree.toolbarUI.expandAllIcon + "
"), t.fit && (this.div.innerHTML += "
' + FamilyTree.toolbarUI.fitIcon + "
"), t.zoom && (this.div.innerHTML += "
' + FamilyTree.toolbarUI.zoomInIcon + "
", this.div.innerHTML += "
' + FamilyTree.toolbarUI.zoomOutIcon + "
"), t.layout && (this.div.innerHTML += "
' + FamilyTree.toolbarUI.layoutIcon + "
", this.layouts = document.createElement("div"), this.layouts.classList.add("bft-toolbar-layout"), this.layouts.innerHTML = '\n \n \n \n \n ', this.obj.element.appendChild(this.layouts)), t.fullScreen && (this.div.innerHTML += "
' + FamilyTree.toolbarUI.openFullScreenIcon + "
"), this.obj.element.appendChild(this.div), this.layoutBtn = this.div.querySelector("[" + FamilyTree.attr.tlbr + '="layout"]'); var i = this.div.querySelector("[" + FamilyTree.attr.tlbr + '="plus"]') , r = this.div.querySelector("[" + FamilyTree.attr.tlbr + '="minus"]') , a = this.div.querySelector("[" + FamilyTree.attr.tlbr + '="fit"]') , n = this.div.querySelector("[" + FamilyTree.attr.tlbr + '="fullScreen"]') , o = this.div.querySelector("[" + FamilyTree.attr.tlbr + '="expand"]') , l = this; i && i.addEventListener("click", (function() { l.obj.zoom(!0, null, !0) } )), r && r.addEventListener("click", (function() { l.obj.zoom(!1, null, !0) } )), a && a.addEventListener("click", (function() { l.obj.fit() } )), n && n.addEventListener("click", (function() { l.obj.toggleFullScreen() } )), o && o.addEventListener("click", (function() { l.obj.expand(null, "all") } )), this.layoutBtn && this.layoutBtn.addEventListener("click", (function() { l._visible ? l.hideLayout() : l.showLayout() } )), this.layouts && this.layouts.addEventListener("click", (function(e) { for (var t = e.target; t; ) { if (t.hasAttribute && t.hasAttribute(FamilyTree.attr.layout)) { t = t.getAttribute(FamilyTree.attr.layout), l.obj.setLayout(FamilyTree.layout[t]); break } t = t.parentNode } } )) } } , FamilyTree.toolbarUI.prototype.showLayout = function() { this._visible = !0, this.layoutBtn.style.transform = "rotate(180deg) translateX(0px) translateY(0px)", FamilyTree.animate(this.div, { bottom: this.obj.config.padding - 10 }, { bottom: this.obj.config.padding + 135 }, this.obj.config.anim.duration, this.obj.config.anim.func), FamilyTree.animate(this.layouts, { bottom: -145 }, { bottom: 0 }, this.obj.config.anim.duration, this.obj.config.anim.func) } , FamilyTree.toolbarUI.prototype.hideLayout = function() { this._visible = !1, this.layoutBtn.style.transform = "rotate(0deg) translateX(0px) translateY(0px)", FamilyTree.animate(this.div, { bottom: this.obj.config.padding + 135 }, { bottom: this.obj.config.padding - 10 }, this.obj.config.anim.duration, this.obj.config.anim.func), FamilyTree.animate(this.layouts, { bottom: 0 }, { bottom: -145 }, this.obj.config.anim.duration, this.obj.config.anim.func) } , FamilyTree.notifierUI = function() {} , FamilyTree.notifierUI.prototype.init = function(e) { this.obj = e } , FamilyTree.notifierUI.prototype.show = function(e, t) { if (null == e) return !1; 1 == e && (e = FamilyTree.MAX_NODES_MESS, t = "#FFCA28"), 2 == e && (e = FamilyTree.OFFLINE_MESS, t = "#FFCA28"); var i = document.createElement("div"); i.innerHTML = e, Object.assign(i.style, { position: "absolute", "background-color": t, color: "#ffffff", padding: "15px", "border-radius": "40px", opacity: 0, overflow: "hidden", "white-space": "nowrap", "text-align": "center" }), this.obj.element.appendChild(i); var r = this.obj.width() / 2 - i.offsetWidth / 2 , a = this.obj.height() / 2 - i.offsetHeight / 2; i.style.left = r + "px", i.style.top = a + "px"; var n = i.offsetWidth; return i.style.width = "20px", FamilyTree.animate(i, { opacity: 0, width: 10 }, { opacity: 1, width: n }, this.obj.config.anim.duration, this.obj.config.anim.func), !0 } , void 0 === FamilyTree && (FamilyTree = {}), FamilyTree._validateConfig = function(e) { return !!e || (console.error("config is not defined"), !1) } , FamilyTree._arrayContains = function(e, t) { if (e && Array.isArray(e)) for (var i = e.length; i--; ) if (e[i] === t) return !0; return !1 } , FamilyTree._interceptions = function(e, t) { if (!e) return []; if (!t) return []; var i = []; if (Array.isArray(e) && Array.isArray(t)) for (var r in e) for (var a in t) e[r] == t[a] && i.push(e[r]); else if (Array.isArray(e) && !Array.isArray(t)) for (var r in e) for (var a in t) e[r] == a && i.push(e[r]); else if (!Array.isArray(e) && Array.isArray(t)) for (var r in e) for (var a in t) r == t[a] && i.push(t[a]); return i } , FamilyTree._getTags = function(e) { return e.tags && !Array.isArray(e.tags) ? e.tags.split(",") : e.tags && Array.isArray(e.tags) ? e.tags : [] } , FamilyTree._centerPointInPercent = function(e, t, i) { var r = e.getBoundingClientRect() , a = t - r.left , n = i - r.top; return [a / (r.width / 100), n / (r.height / 100)] } , FamilyTree._trim = function(e) { return e.replace(/^\s+|\s+$/g, "") } , FamilyTree._getTransform = function(e) { var t = e.getAttribute("transform"); return t = t.replace("matrix", "").replace("(", "").replace(")", ""), FamilyTree._browser().msie && (t = t.replace(/ /g, ",")), t = "[" + (t = FamilyTree._trim(t)) + "]", t = JSON.parse(t) } , FamilyTree.getScale = function(e, t, i, r, a, n, o, l) { var s = 1; if (e || r !== FamilyTree.match.boundary) if (e || r !== FamilyTree.match.width) if (e || r !== FamilyTree.match.height) if (e) { var d, c; s = (d = t / e[2]) > (c = i / e[3]) ? c : d } else s = r; else s = i / l; else s = t / o; else s = (d = t / o) > (c = i / l) ? c : d; return s && s > a && (s = a), s && s < n && (s = n), s } , FamilyTree.isObject = function(e) { return e && "object" == typeof e && !Array.isArray(e) && null !== e } , FamilyTree.fileUploadDialog = function(e) { var t = document.createElement("INPUT"); t.setAttribute("type", "file"), t.style.display = "none", t.onchange = function() { var t = this.files[0]; e(t) } , document.body.appendChild(t), t.click() } , FamilyTree.mergeDeep = function(e, t) { if (FamilyTree.isObject(e) && FamilyTree.isObject(t)) for (var i in t) FamilyTree.isObject(t[i]) ? (e[i] || Object.assign(e, { [i]: {} }), FamilyTree.mergeDeep(e[i], t[i])) : Object.assign(e, { [i]: t[i] }); return e } , FamilyTree._lblIsImg = function(e, t) { return !(!e.nodeBinding || "string" != typeof t || -1 == t.indexOf("img") || !e.nodeBinding[t]) } , FamilyTree._getFistImgField = function(e) { if (e.nodeBinding) for (var t in e.nodeBinding) if (-1 != t.indexOf("img")) return e.nodeBinding[t]; return !1 } , FamilyTree._fieldIsImg = function(e, t) { if (e.nodeBinding) for (var i in e.nodeBinding) if (e.nodeBinding[i] == t) return FamilyTree._lblIsImg(e, i); return !1 } , FamilyTree._guid = function() { function e() { return Math.floor(65536 * (1 + Math.random())).toString(16).substring(1) } return e() + e() + "-" + e() + "-" + e() + "-" + e() + "-" + e() + e() + e() } , FamilyTree.htmlRipple = function(e) { var t = document.createElement("style"); t.type = "text/css", t.innerHTML = " .bft-ripple-container {position: absolute; top: 0; right: 0; bottom: 0; left: 0; } .bft-ripple-container span {transform: scale(0);border-radius:100%;position:absolute;opacity:0.75;background-color:#fff;animation: bft-ripple 1000ms; }@-moz-keyframes bft-ripple {to {opacity: 0;transform: scale(2);}}@-webkit-keyframes bft-ripple {to {opacity: 0;transform: scale(2);}}@-o-keyframes bft-ripple {to {opacity: 0;transform: scale(2);}}@keyframes bft-ripple {to {opacity: 0;transform: scale(2);}}", document.head.appendChild(t); var i, r, a, n = document.createElement("div"); n.className = "bft-ripple-container", e.addEventListener("mousedown", (function(t) { var i, r, a, n, o; return this, r = document.createElement("span"), a = this.offsetWidth, i = this.getBoundingClientRect(), o = t.pageX - i.left - a / 2, n = "top:" + (t.pageY - i.top - a / 2) + "px; left: " + o + "px; height: " + a + "px; width: " + a + "px;", e.rippleContainer.appendChild(r), r.setAttribute("style", n) } )), e.addEventListener("mouseup", (i = function() { for (; this.rippleContainer.firstChild; ) this.rippleContainer.removeChild(this.rippleContainer.firstChild) } , r = 2e3, a = void 0, function() { var e, t; return t = this, e = arguments, clearTimeout(a), a = setTimeout((function() { return i.apply(t, e) } ), r) } )), e.rippleContainer = n, e.appendChild(n) } , FamilyTree._moveToBoundaryArea = function(e, t, i, r) { var a = t.slice(0); t[0] < i.left && t[0] < i.right && (a[0] = i.left > i.right ? i.right : i.left), t[0] > i.right && t[0] > i.left && (a[0] = i.left > i.right ? i.left : i.right), t[1] < i.top && t[1] < i.bottom && (a[1] = i.top > i.bottom ? i.bottom : i.top), t[1] > i.bottom && t[1] > i.top && (a[1] = i.top > i.bottom ? i.top : i.bottom), t[0] !== a[0] || t[1] !== a[1] ? FamilyTree.animate(e, { viewBox: t }, { viewBox: a }, 300, FamilyTree.anim.outPow, (function() { r && r() } )) : r && r() } , FamilyTree.randomId = function() { return "_" + ("0000" + (Math.random() * Math.pow(36, 4) | 0).toString(36)).slice(-4) } , FamilyTree._getClientXY = function(e) { return -1 == e.type.indexOf("touch") ? { x: e.clientX, y: e.clientY } : e.changedTouches.length ? { x: e.changedTouches[0].clientX, y: e.changedTouches[0].clientY } : void 0 } , FamilyTree._getClientTouchesXY = function(e, t) { return -1 != e.type.indexOf("touch") ? e.touches.length < t + 1 ? { x: null, y: null } : { x: e.touches[t].clientX, y: e.touches[t].clientY } : { x: e.clientX, y: e.clientY } } , FamilyTree._getOffset = function(e, t) { e && (t.x += e.offsetLeft, t.y += e.offsetTop, FamilyTree._getOffset(e.offsetParent, t)) } , FamilyTree._getTopLeft = function(e) { var t = { x: 0, y: 0 }; return FamilyTree._getOffset(e, t), t } , FamilyTree._getOffsetXY = function(e, t) { if (-1 == t.type.indexOf("touch")) return { x: t.offsetX, y: t.offsetY }; if (t.touches.length) { var i = FamilyTree._getTopLeft(e); return { x: t.touches[0].pageX - i.x, y: t.touches[0].pageY - i.y } } if (t.changedTouches.length) { i = FamilyTree._getTopLeft(e); return isNaN(i.x) || isNaN(i.y) ? { x: t.changedTouches[0].pageX, y: t.changedTouches[0].pageY } : { x: t.changedTouches[0].pageX - i.x, y: t.changedTouches[0].pageY - i.y } } } , FamilyTree._pinchMiddlePointInPercent = function(e, t, i, r) { var a = FamilyTree._getTopLeft(e) , n = r.touches[0].pageX - a.x , o = r.touches[0].pageY - a.y , l = r.touches[1].pageX - a.x , s = r.touches[1].pageY - a.y; return [((n - l) / 2 + l) / (t / 100), ((o - s) / 2 + s) / (i / 100)] } , FamilyTree._browser = function() { var e = !!window.opr && !!window.opr.addons || !!window.opera || navigator.userAgent.indexOf(" OPR/") >= 0 , t = "undefined" != typeof InstallTrigger , i = /constructor/i.test(window.HTMLElement) || "[object SafariRemoteNotification]" === (!window.safari || void 0 !== window.safari && safari.pushNotification).toString() , r = !!document.documentMode , a = !r && !!window.StyleMedia , n = !(!window.chrome || !window.chrome.webstore && !window.chrome.runtime); return { opera: e, firefox: t, safari: i, msie: r, edge: a, chrome: n, blink: (n || e) && !!window.CSS } } , FamilyTree._menuPosition = function(e, t, i) { var r = e.getBoundingClientRect() , a = i.getBoundingClientRect() , n = t.getBoundingClientRect() , o = r.left - a.left , l = r.top - a.top; return r.top + n.height > a.top + a.height && (l -= n.height), r.left - n.width < a.left && (o += n.width), { x: o, y: l } } , FamilyTree._getTemplate = function(e, t, i) { if (Array.isArray(e)) for (var r = 0; r < e.length; r++) { var a = t[e[r]]; if (a && a.template) return a.template } return i } , FamilyTree._getMin = function(e, t) { if (e.tags && e.tags.length && t.tags) for (var i = 0; i < e.tags.length; i++) { var r = t.tags[e.tags[i]]; if (r && !0 === r.min) return !0 } return t.min } , FamilyTree._getSubLevels = function(e, t) { if (e && e.length) for (var i = 0; i < e.length; i++) { var r = t[e[i]]; if (r && r.subLevels) return r.subLevels } return 0 } , FamilyTree._isHTML = function(e) { var t = (new DOMParser).parseFromString(e, "text/html"); return Array.from(t.body.childNodes).some((e=>1 === e.nodeType)) } , FamilyTree._getTestDiv = function() { var e = document.getElementById("orgfamily_js_test_div"); return e || ((e = document.createElement("div")).id = "orgfamily_js_test_div", e.style.position = "fixed", e.style.top = "-10000px", e.style.left = "-10000px", document.body.appendChild(e)), e } , FamilyTree._getLabelSize = function(e) { var t = FamilyTree._getTestDiv(); return t.innerHTML = "" + e + "", t.querySelector("text").getBoundingClientRect() } , FamilyTree.wrapText = function(e, t) { var i = t.toLowerCase(); if (-1 == i.indexOf(""; var a, n, o = (new DOMParser).parseFromString(t, "text/xml").getElementsByTagName("text")[0], l = parseFloat(o.getAttribute("x")), s = parseFloat(o.getAttribute("y")), d = o.getAttribute("text-anchor"), c = o.getAttribute(FamilyTree.attr.width), m = o.getAttribute(FamilyTree.attr.text_overflow), h = "http://www.w3.org/2000/svg", p = r.getElementsByTagName("svg")[0].getElementsByTagName("text")[0]; m || (m = "ellipsis"); var f = m.split("-"); if (f.length > 1 && (a = parseInt(m.split("-")[1]), f.length > 2 && "ellipsis" == f[2] && (n = !0)), !c) return FamilyTree._escapeHtml(e); if (c = parseFloat(c), l || (l = 0), s || (s = 0), l || (d = "start"), "ellipsis" == m) { p.removeChild(p.firstChild), p.textContent = e; for (var u = p.getComputedTextLength(), y = 2; u > c; ) p.textContent = e.substring(0, e.length - y), p.textContent += "...", u = p.getComputedTextLength(), y++; return y > 2 ? `${FamilyTree._escapeHtml(e)}${p.textContent}` : FamilyTree._escapeHtml(e) } if (-1 != m.indexOf("multiline")) { var g = e.split(" ") , v = p.getBBox().height; p.textContent = ""; var T = document.createElementNS(h, "tspan") , b = document.createTextNode(g[0]); T.setAttributeNS(null, "x", l), T.setAttributeNS(null, "y", s), T.setAttributeNS(null, "text-anchor", d), T.appendChild(b), p.appendChild(T); y = 1; for (var F = 1, x = !1, _ = 1; _ < g.length; _++) { var w = T.firstChild.data.length; if (T.firstChild.data += " " + g[_], T.getComputedTextLength() > c) { if (T.firstChild.data = T.firstChild.data.slice(0, w), F++, a && F > a) { if (n && p.children.length == a) { var k = p.children[a - 1].textContent; p.children[a - 1].textContent = k.substring(0, k.length - 3) + "...", x = !0 } break } (T = document.createElementNS(h, "tspan")).setAttributeNS(null, "x", l), T.setAttributeNS(null, "y", s + v * y), T.setAttributeNS(null, "text-anchor", d), b = document.createTextNode(g[_]), T.appendChild(b), p.appendChild(T), y++ } } var S = ""; if (null != p.innerHTML) S = p.innerHTML, p.innerHTML = ""; else { var C = ""; for (_ = p.childNodes.length - 1; _ >= 0; _--) C = XMLSerializer().serializeToString(p.childNodes[_]) + C, p.removeChild(p.childNodes[_]); S = C } return x ? `${FamilyTree._escapeHtml(e)}${S}` : S } } , FamilyTree._downloadFile = function(e, t, i, r, a) { var n = new Blob([t],{ type: e }); if (1 == r) { var o = URL.createObjectURL(n); window.open(o, "_blank").focus() } else if (navigator.msSaveBlob) navigator.msSaveBlob(n, i); else { var l = document.createElement("a"); if (void 0 !== l.download) { o = URL.createObjectURL(n); l.setAttribute("href", o); var s = i; s.toLowerCase().endsWith(a.toLowerCase()) || (s = s + "." + a), l.setAttribute("download", s), l.style.visibility = "hidden", document.body.appendChild(l), l.click(), document.body.removeChild(l) } } } , FamilyTree._getPosition = function(e, t, i, r) { var a = { x: t.x, y: t.y }; if (null != i && (a.x = i), null != r && (a.y = i), e && 3 == e.length) { var n = e[0].indexOf(t.id); -1 != n && null != e[1][n].transform && (null == i && (a.x = e[1][n].transform[4]), null == r && (a.y = e[1][n].transform[5])) } return a } , FamilyTree._getOpacity = function(e, t) { var i = 1; if (e && 3 == e.length) { var r = e[0].indexOf(t.id); -1 != r && null != e[1][r].opacity && (i = e[1][r].opacity) } return i } , FamilyTree.t = function(e, t, i) { var r = FamilyTree.templates[e]; null == r && console.error(`Template "${e}" does not exist!`); var a = null; if (null != i && r.scaleLessThen) { var n = []; for (var o in r.scaleLessThen) { var l = parseFloat(o); i < l && n.push(l) } if (n.length > 0) { n.sort((function(e, t) { return e - t } )); var s = r.scaleLessThen[n[0]]; for (var d in s) null == a && (a = Object.assign({}, r)), a[d] = s[d] } } return t ? null == a ? r.min ? r.min : r : a.min ? a.min : a : null == a ? r : a } , FamilyTree.setNodeSize = function(e) { var t = FamilyTree.t(e.templateName, e.min); e.w = t && t.size ? t.size[0] : 0, e.h = t && t.size ? t.size[1] : 0 } , FamilyTree._imgs2base64 = function(e, t, i, r) { var a = e.getElementsByTagName(t) , n = a.length; 0 == n && r(); for (var o = 0; o < n; o++) !function() { var e = o , t = a[e]; FamilyTree._getDataUri(t.getAttribute(i), (function(a) { a.success && t.setAttribute(i, a.result), e == n - 1 && r() } )) }() } , FamilyTree._getDataUri = function(e, t) { if (-1 != e.indexOf("base64")) t({ success: !1 }); else { var i = new XMLHttpRequest; i.open("GET", e), i.responseType = "blob", i.onload = function() { 200 === i.status ? r.readAsDataURL(i.response) : 404 === i.status && t({ success: !1, result: i.status }) } ; var r = new FileReader; r.onloadend = function() { t({ success: !0, result: r.result }) } , i.send() } } , FamilyTree._convertStringToArray = function(e, t) { return -1 != FamilyTree.ARRAY_FIELDS.indexOf(e) ? FamilyTree.isNEU(t) ? [] : t.split(",") : t } , FamilyTree._convertArrayToString = function(e) { return !FamilyTree.isNEU(e) && Array.isArray(e) ? e.join() : e } , FamilyTree._csvToArray = function(e, t) { t = t || FamilyTree.CSV_DELIMITER; for (var i = new RegExp("(\\" + t + '|\\r?\\n|\\r|^)(?:"([^"]*(?:""[^"]*)*)"|([^"\\' + t + "\\r\\n]*))","gi"), r = [[]], a = null; a = i.exec(e); ) { var n, o = a[1]; o.length && o !== t && r.push([]), n = a[2] ? a[2].replace(new RegExp('""',"g"), '"') : a[3], r[r.length - 1].push(n) } return r } , FamilyTree._json2xml = function(e) { for (var t = document.implementation.createDocument("", "", null), i = t.createElement("nodes"), r = 0; r < e.length; r++) { var a = t.createElement("node") , n = e[r]; for (var o in n) { var l = n[o]; a.setAttribute(o, FamilyTree._convertArrayToString(l)) } i.appendChild(a) } return t.appendChild(i), '' + (new XMLSerializer).serializeToString(t.documentElement) } , FamilyTree._xml2json = function(e) { for (var t = (new DOMParser).parseFromString(e, "text/xml").getElementsByTagName("node"), i = [], r = 0; r < t.length; r++) { for (var a = t[r], n = {}, o = 0; o < a.attributes.length; o++) { var l = a.attributes[o]; n[l.name] = FamilyTree._convertStringToArray(l.name, l.value) } i.push(n) } return i } , FamilyTree.convertNodesToCsv = function(e) { return FamilyTree._json2csv(e) } , FamilyTree._json2csv = function(e) { for (var t = [], i = function(e) { for (var i = "", r = 0; r < t.length; r++) { var a; (a = "reportsTo" == t[r] ? null : null == e[t[r]] ? "" : e[t[r]])instanceof Date && (a = a.toLocaleString()); var n = (a = null === a ? "" : a.toString()).replace(/"/g, '""') , o = new RegExp('("|;|\n)',"g"); n.search(o) >= 0 && (n = '"' + n + '"'), r > 0 && (i += FamilyTree.CSV_DELIMITER), i += n } return i + "\n" }, r = "", a = 0; a < e.length; a++) for (var n in e[a]) FamilyTree._arrayContains(t, n) || (t.push(n), r += n + FamilyTree.CSV_DELIMITER); r = r.substring(0, r.length - 1), r += "\n"; for (a = 0; a < e.length; a++) r += i(e[a]); return r = r.substring(0, r.length - 1) } , FamilyTree.accentFold = function(e) { return (e = e.toString().toLowerCase()).replace(/([àáâãäå])|([ç])|([èéêë])|([ìíîï])|([ñ])|([òóôõöø])|([ß])|([ùúûü])|([ÿ])|([æ])/g, (function(e, t, i, r, a, n, o, l, s, d, c) { return t ? "a" : i ? "c" : r ? "e" : a ? "i" : n ? "n" : o ? "o" : l ? "s" : s ? "u" : d ? "y" : c ? "ae" : void 0 } )) } , FamilyTree.copy = function(e) { if (null === e || "object" != typeof e || "isActiveClone"in e) return e; if (e instanceof Date) var t = new e.constructor; else t = e.constructor(); for (var i in e) Object.prototype.hasOwnProperty.call(e, i) && (e.isActiveClone = null, t[i] = FamilyTree.copy(e[i]), delete e.isActiveClone); return t } , FamilyTree._getScrollSensitivity = function() { var e = FamilyTree._browser(); return e.msie && FamilyTree.scroll.ie ? FamilyTree.scroll.ie : e.edge && FamilyTree.scroll.edge ? FamilyTree.scroll.edge : e.safari && FamilyTree.scroll.safari ? FamilyTree.scroll.safari : e.chrome && FamilyTree.scroll.chrome ? FamilyTree.scroll.chrome : e.firefox && FamilyTree.scroll.firefox ? FamilyTree.scroll.firefox : e.opera && FamilyTree.scroll.opera ? FamilyTree.scroll.opera : { smooth: FamilyTree.scroll.smooth, speed: FamilyTree.scroll.speed } } , FamilyTree.isMobile = function() { return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) } , FamilyTree.isTrial = function() { return void 0 !== FamilyTree.remote } , FamilyTree.childrenCount = function(e, t) { for (var i = 0, r = 0; r < t.childrenIds.length; r++) { e.nodes[t.childrenIds[r]] && i++ } return i } , FamilyTree.childrenTotalCount = function(e, t) { for (var i = 0, r = 0; r < t.childrenIds.length; r++) { var a = e.nodes[t.childrenIds[r]]; a && (i++, i += FamilyTree.childrenTotalCount(e, a)) } return i } , FamilyTree.collapsedChildrenCount = function(e, t) { for (var i = 0, r = 0; r < t.childrenIds.length; r++) { var a = e.nodes[t.childrenIds[r]]; a && !0 === a.collapsed && i++ } return i } , FamilyTree.collapsedChildrenTotalCount = function(e, t, i) { for (var r = 0, a = 0; a < t.childrenIds.length; a++) { var n = e.nodes[t.childrenIds[a]]; n && ((i || !0 === n.collapsed) && r++, r += FamilyTree.collapsedChildrenTotalCount(e, n, !0)) } return r } , FamilyTree._setMinMaxXY = function(e, t) { (null == t.minX || null != e.x && e.x < t.minX) && (t.minX = e.x), (null == t.minY || null != e.y && e.y < t.minY) && (t.minY = e.y), (null == t.maxX || null != e.x && e.x + e.w > t.maxX) && (t.maxX = e.x + e.w), (null == t.maxY || null != e.y && e.y + e.h > t.maxY) && (t.maxY = e.y + e.h) } , FamilyTree.getStParentNodes = function(e, t) { for (t || (t = []); e.parent; ) e = e.parent; return e.stParent && (t.push(e.stParent), FamilyTree.getStParentNodes(e.stParent, t)), t } , FamilyTree.getRootOf = function(e) { for (; e && e.parent; ) e = e.parent; return e } , FamilyTree._getViewBox = function(e) { var t = null; return e ? (t = (t = "[" + (t = e.getAttribute("viewBox")) + "]").replace(/\ /g, ","), t = JSON.parse(t)) : null } , FamilyTree.isNEU = function(e) { return null == e || "" === e } , FamilyTree.gradientCircleForDefs = function(e, t, i, r) { function a(e, t, i, r) { var a = (r - 90) * Math.PI / 180; return { x: e + i * Math.cos(a), y: t + i * Math.sin(a) } } function n(e, t, i, r, n) { var o = a(e, t, i, n) , l = a(e, t, i, r) , s = n - r <= 180 ? "0" : "1"; return ["M", o.x, o.y, "A", i, i, 0, s, 0, l.x, l.y].join(" ") } return Array.isArray(t) || (t = [t, t, t, t, t, t]), `\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ` } , FamilyTree._intersectionObserver = function(e, t) { "function" == typeof IntersectionObserver ? new IntersectionObserver((function(e, i) { e.forEach((function(e) { var i = e.intersectionRatio > 0; 0 == e.intersectionRatio && (i = e.isIntersecting), t(i) } )) } )).observe(e) : t(!0) } , FamilyTree.convertCsvToNodes = function(e) { for (var t = FamilyTree._csvToArray(e), i = t[0], r = [], a = 1; a < t.length; a++) { for (var n = {}, o = 0; o < t[a].length; o++) { var l = i[o] , s = t[a][o]; n[i[o]] = FamilyTree._convertStringToArray(l, s) } "" != n.id.trim() && r.push(n) } return r } , FamilyTree._escapeHtml = function(e) { return FamilyTree.ESCAPE_HTML && "string" == typeof e ? e.replace(/&/g, "&").replace(//g, ">").replace(/"/g, """).replace(/'/g, "'") : e } , FamilyTree._escapeDoubleQuotes = function(e) { return "string" == typeof e ? e.replace(/"/g, """) : e } , FamilyTree._escapeGreaterLessSign = function(e) { return "string" == typeof e ? e.replace(//g, ">") : e } , FamilyTree.roundPathCorners = function(e, t, i) { function r(e, t, i) { var r = t.x - e.x , n = t.y - e.y , o = Math.sqrt(r * r + n * n); return a(e, t, Math.min(1, i / o)) } function a(e, t, i) { return { x: e.x + (t.x - e.x) * i, y: e.y + (t.y - e.y) * i } } function n(e, t) { e.length > 2 && (e[e.length - 2] = t.x, e[e.length - 1] = t.y) } function o(e) { return { x: parseFloat(e[e.length - 2]), y: parseFloat(e[e.length - 1]) } } Array.isArray(e) || (e = (e = e.split(/[,\s]/).reduce((function(e, t) { var i = t.match("([a-zA-Z])(.+)"); return i ? (e.push(i[1]), e.push(i[2])) : e.push(t), e } ), [])).reduce((function(e, t) { return parseFloat(t) == t && e.length ? e[e.length - 1].push(t) : e.push([t]), e } ), [])); var l = []; if (e.length > 1) { var s = o(e[0]) , d = null; "Z" == e[e.length - 1][0] && e[0].length > 2 && (d = ["L", s.x, s.y], e[e.length - 1] = d), l.push(e[0]); for (var c = 1; c < e.length; c++) { var m = l[l.length - 1] , h = e[c] , p = h == d ? e[1] : e[c + 1]; if (p && m && m.length > 2 && "L" == h[0] && p.length > 2 && "L" == p[0]) { var f, u, y = o(m), g = o(h), v = o(p); i ? (f = a(g, m.origPoint || y, t), u = a(g, p.origPoint || v, t)) : (f = r(g, y, t), u = r(g, v, t)), n(h, f), h.origPoint = g, l.push(h); var T = a(f, g, .5) , b = a(g, u, .5) , F = ["C", T.x, T.y, b.x, b.y, u.x, u.y]; F.origPoint = g, l.push(F) } else l.push(h) } if (d) { var x = o(l[l.length - 1]); l.push(["Z"]), n(l[0], x) } } else l = e; return l.reduce((function(e, t) { return e + t.join(" ") + " " } ), "") } , FamilyTree._isMoved = function(e) { return null != e.movex || null != e.movey } , FamilyTree._getDynamicGridCoulumns = function(e) { for (var t = 1; t < e && (e / t, !(e / t - t <= 0)); t++) ; return t % 2 != 0 && t > 2 && t--, t } , FamilyTree._changeRootOption = function(e, t, i) { for (var r = [], a = 0; a < t.length; a++) for (var n = 0; n < i.length; n++) if (i[n].has(t[a])) { r = i[n]; break } for (a = 0; a < r.length; a++) { var o = e.indexOf(r[a]); -1 != o && e.splice(o, 1) } t.length && e.push(t[0]) } , FamilyTree._convertStringToArrayOnImport = function(e, t) { return "tags" == e || "pids" == e ? FamilyTree.isNEU(t) ? [] : t.split(",") : t } , void 0 === FamilyTree && (FamilyTree = {}), FamilyTree.icon = {}, FamilyTree.icon.png = function(e, t, i) { return '' } , FamilyTree.icon.pdf = function(e, t, i) { return '' } , FamilyTree.icon.svg = function(e, t, i) { return '' } , FamilyTree.icon.csv = function(e, t, i) { return '' } , FamilyTree.icon.json = function(e, t, i) { return '' } , FamilyTree.icon.excel = function(e, t, i) { return '' } , FamilyTree.icon.edit = function(e, t, i) { return '' } , FamilyTree.icon.details = function(e, t, i) { return '' } , FamilyTree.icon.remove = function(e, t, i) { return '' } , FamilyTree.icon.add = function(e, t, i) { return '' } , FamilyTree.icon.search = function(e, t, i) { return '' } , FamilyTree.icon.xml = function(e, t, i) { return '' } , FamilyTree.icon.link = function(e, t, i) { return '' } , FamilyTree.icon.happy = function(e, t, i) { return '' } , FamilyTree.icon.sad = function(e, t, i) { return '' } , FamilyTree.icon.share = function(e, t, i, r, a) { return null == r && (r = 0), null == a && (a = 0), `\n \n ` } , FamilyTree.icon.user = function(e, t, i, r, a) { return FamilyTree.isNEU(r) && (r = 0), FamilyTree.isNEU(a) && (a = 0), `\n \n \n ` } , FamilyTree.icon.close = function(e, t, i, r, a) { return null == r && (r = 0), null == a && (a = 0), `\n \n ` } , FamilyTree.icon.undo = function(e, t, i, r, a) { return null == r && (r = 0), null == a && (a = 0), `\n \n \n ` } , FamilyTree.icon.redo = function(e, t, i, r, a) { return null == r && (r = 0), null == a && (a = 0), `\n \n \n ` } , FamilyTree.icon.ft = function(e, t, i, r, a) { return `\n \n \n \n \n \n \n \n \n ` } , FamilyTree.icon.addUser = function(e, t, i, r, a) { return FamilyTree.isNEU(r) && (r = 0), FamilyTree.isNEU(a) && (a = 0), `\n \n \n \n ` } , FamilyTree.icon.daughter = function(e, t, i, r, a) { return FamilyTree.isNEU(r) && (r = 0), FamilyTree.isNEU(a) && (a = 0), `\n \n \n \n \n \n \n \n ` } , FamilyTree.icon.son = function(e, t, i, r, a) { return FamilyTree.isNEU(r) && (r = 0), FamilyTree.isNEU(a) && (a = 0), `\n \n \n \n \n \n \n ` } , FamilyTree.icon.wife = function(e, t, i, r, a) { return FamilyTree.isNEU(r) && (r = 0), FamilyTree.isNEU(a) && (a = 0), `\n \n \n \n \n \n \n \n \n \n \n ` } , FamilyTree.icon.husband = function(e, t, i, r, a) { return FamilyTree.isNEU(r) && (r = 0), FamilyTree.isNEU(a) && (a = 0), `\n \n \n \n \n \n \n ` } , FamilyTree.icon.father = function(e, t, i, r, a) { return FamilyTree.isNEU(r) && (r = 0), FamilyTree.isNEU(a) && (a = 0), `\n \n \n \n \n \n \n \n \n \n \n ` } , FamilyTree.icon.mother = function(e, t, i, r, a) { return FamilyTree.isNEU(r) && (r = 0), FamilyTree.isNEU(a) && (a = 0), `\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ` } , FamilyTree.icon.teddy = function(e, t, i, r, a) { return FamilyTree.isNEU(r) && (r = 0), FamilyTree.isNEU(a) && (a = 0), `\n \n \n \n \n \n \n \n \n \n \n ` } , FamilyTree.prototype.exportPDFProfile = function(e, t) { e = this._defaultExportProfileOptions(e, "pdf"), this._exportProfile(e, t) } , FamilyTree.prototype.exportPDFPreview = function(e) { FamilyTree.pdfPrevUI.show(this, e) } , FamilyTree.prototype.exportPNGProfile = function(e, t) { e = this._defaultExportProfileOptions(e, "png"), this._exportProfile(e, t) } , FamilyTree.prototype.shareProfile = function(e) { var t; "object" == typeof e ? e = (t = e).focusId : t = this.editUI.content(e, !0, !0, "100%", !0); var i = new URL(window.location.href); i.searchParams.append("nodeId", e); var r = { title: t.title, text: t.shareText, url: i.href }; try { navigator.share(r) } catch (e) { console.error("error: " + e) } } , FamilyTree.prototype.exportPDF = function(e, t) { e = this._defaultExportOptions(e, "pdf"), this._export(e, t) } , FamilyTree.prototype.exportPNG = function(e, t) { e = this._defaultExportOptions(e, "png"), this._export(e, t) } , FamilyTree.prototype.exportSVG = function(e, t) { e = this._defaultExportOptions(e, "svg"), this._export(e, t) } , FamilyTree.prototype._defaultExportOptions = function(e, t) { return null == e && (e = {}), "svg" == t ? (e.ext = "svg", e.mime = "image/svg+xml") : "pdf" == t ? (e.mime = "application/pdf", e.ext = "pdf") : "png" == t && (e.mime = "image/png", e.ext = "png"), null == e.margin && (e.margin = [50, 40, 50, 40]), null == e.padding && (e.padding = 0), null == e.landscape && (e.landscape = !1), null == e.filename && (e.filename = "FamilyTree." + e.ext), null == e.scale && (e.scale = "fit"), null == e.format && (e.format = "fit"), null == e.header && (e.header = ""), "pdf" == t && null == e.footer ? e.footer = "Page {current-page} of {total-pages}" : null == e.footer && (e.footer = ""), null == e.openInNewTab && (e.openInNewTab = !1), null == e.mode && (e.mode = "bft-" + this.config.mode), e } , FamilyTree.prototype._export = function(e, t) { var i = this , r = { id: e.nodeId, expandChildren: e.expandChildren, min: e.min }; e.margin && e.margin[0] < 2 && (e.margin[0] = 2), e.margin && e.margin[1] < 2 && (e.margin[1] = 2), e.margin && e.margin[2] < 2 && (e.margin[2] = 2), e.margin && e.margin[3] < 2 && (e.margin[3] = 2), this._draw(!1, FamilyTree.action.exporting, r, (function(r, a) { var n = document.createElement("div"); if (n.innerHTML = r, e.padding > 0) { var o = n.querySelector("svg") , l = FamilyTree._getViewBox(o); l[0] -= e.padding, l[1] -= e.padding, l[2] += 2 * e.padding, l[3] += 2 * e.padding, o.setAttribute("viewBox", l.join()), o.setAttribute("width", l[2]), o.setAttribute("height", l[3]) } if ("svg" == e.ext) if (t) t(e, n.innerHTML); else { (o = n.querySelector("svg")).classList.add("bft-" + i.config.mode); var s = { content: n.innerHTML, options: e, styles: "" } , d = FamilyTree.events.publish("exportstart", [i, s]) , c = i.element.querySelector("[data-bft-styles]"); if (c && (s.styles += c.outerHTML), s.styles && (n.childNodes[0].insertAdjacentHTML("afterbegin", s.styles), s.content = n.innerHTML), !1 === d) return !1; if (!1 === (d = FamilyTree.events.publish("exportend", [i, s]))) return !1; FamilyTree._downloadFile(e.mime, s.content, s.options.filename, s.options.openInNewTab, s.options.ext) } else i._pages(e, n.querySelector("svg"), a, (function(r) { var a = { content: n.innerHTML, options: e, pages: r, styles: "" } , o = FamilyTree.events.publish("exportstart", [i, a]) , l = i.element.querySelector("[data-bft-styles]"); if (l && (a.styles += l.outerHTML), !1 === o) return !1; t || FamilyTree.loading.show(i), t ? t(i, a, n.querySelector("svg")) : (a = JSON.stringify(a), FamilyTree._ajax(i.config.exportUrl + "/v3", "POST", a, "arraybuffer", (function(t) { var r = FamilyTree.events.publish("exportend", [i, t]); if (FamilyTree.loading.hide(i), !1 === r) return !1; FamilyTree._downloadFile(e.mime, t, e.filename, e.openInNewTab, e.ext) } ))) } )) } )) } , FamilyTree.prototype.exportCSV = function(e) { var t = FamilyTree._defaultExportProfileOptionsForCSV_SVG_JSON(e, "csv") , i = this.getNode(t.nodeId) , r = null; i ? (r = [], FamilyTree._exportIterateForJSON_XML_CSV(this, i, t, r)) : !1 === t.min || !1 === t.expandChildren ? FamilyTree._exportIterateForJSON_XML_CSV(this, this.roots, t, r) : r = JSON.parse(JSON.stringify(this.config.nodes)); var a = { ext: "csv", filename: e, options: t, nodes: r }; if (!1 === FamilyTree.events.publish("exportstart", [this, a])) return !1; var n = FamilyTree._json2csv(a.nodes) , o = { ext: a.ext, filename: a.filename, options: t, nodes: a.nodes, content: n }; if (!1 === FamilyTree.events.publish("exportend", [this, o])) return !1; FamilyTree._downloadFile("text/csv;charset=utf-8;", "\ufeff" + o.content, o.options.filename, o.options.openInNewTab, o.ext) } , FamilyTree.prototype.exportXML = function(e) { var t = FamilyTree._defaultExportProfileOptionsForCSV_SVG_JSON(e, "xml") , i = this.getNode(t.nodeId) , r = null; i ? (r = [], FamilyTree._exportIterateForJSON_XML_CSV(this, i, t, r)) : !1 === t.min || !1 === t.expandChildren ? FamilyTree._exportIterateForJSON_XML_CSV(this, this.roots, t, r) : r = JSON.parse(JSON.stringify(this.config.nodes)); var a = { ext: "xml", filename: e, options: t, nodes: r }; if (!1 === FamilyTree.events.publish("exportstart", [this, a])) return !1; var n = FamilyTree._json2xml(a.nodes) , o = { ext: a.ext, filename: a.filename, options: t, nodes: a.nodes, content: n }; if (!1 === FamilyTree.events.publish("exportend", [this, o])) return !1; FamilyTree._downloadFile("application/xml", o.content, o.options.filename, o.options.openInNewTab, o.ext) } , FamilyTree.prototype.exportJSON = function(e) { var t = FamilyTree._defaultExportProfileOptionsForCSV_SVG_JSON(e, "json") , i = this.getNode(t.nodeId) , r = null; i ? (r = [], FamilyTree._exportIterateForJSON_XML_CSV(this, i, t, r)) : !1 === t.min || !1 === t.expandChildren ? FamilyTree._exportIterateForJSON_XML_CSV(this, this.roots, t, r) : r = JSON.parse(JSON.stringify(this.config.nodes)); var a = { ext: "json", filename: t.filename, options: t, nodes: r }; if (!1 === FamilyTree.events.publish("exportstart", [this, a])) return !1; var n = { ext: a.ext, filename: a.filename, options: t, nodes: a.nodes, content: JSON.stringify(a.nodes) }; if (!1 === FamilyTree.events.publish("exportend", [this, n])) return !1; FamilyTree._downloadFile("application/json", n.content, n.options.filename, n.options.openInNewTab, n.ext) } , FamilyTree._exportIterateForJSON_XML_CSV = function(e, t, i, r) { if (Array.isArray(t)) for (var a = 0; a < t.length; a++) FamilyTree._exportIterateForJSON_XML_CSV(e, t[a], i, r); else { var n = e.get(t.id); if (r.push(n), i.min) for (a = 0; a < t.stChildrenIds.length; a++) FamilyTree._exportIterateForJSON_XML_CSV(e, e.getNode(t.stChildrenIds[a]), i, r); else for (a = 0; a < t.stChildren.length; a++) FamilyTree._exportIterateForJSON_XML_CSV(e, t.stChildren[a], i, r); if (i.expandChildren) for (a = 0; a < t.childrenIds.length; a++) FamilyTree._exportIterateForJSON_XML_CSV(e, e.getNode(t.childrenIds[a]), i, r); else for (a = 0; a < t.children.length; a++) FamilyTree._exportIterateForJSON_XML_CSV(e, t.children[a], i, r) } } , FamilyTree.prototype._pages = function(e, t, i, r) { "A5" == e.format && "fit" != e.scale || "A4" == e.format && "fit" != e.scale || "A3" == e.format && "fit" != e.scale || "A2" == e.format && "fit" != e.scale || "A1" == e.format && "fit" != e.scale || "Letter" == e.format && "fit" != e.scale || "Legal" == e.format && "fit" != e.scale ? r(this._pagesA100(e, t, e.scale)) : "A5" == e.format && "fit" == e.scale || "A4" == e.format && "fit" == e.scale || "A3" == e.format && "fit" == e.scale || "A2" == e.format && "fit" == e.scale || "A1" == e.format && "fit" == e.scale || "Letter" == e.format && "fit" == e.scale || "Legal" == e.format && "fit" == e.scale ? r(this._pagesAfit(e, t, i)) : "fit" == e.format && r(this._pagesFit(e, t)) } , FamilyTree.prototype._pagesFit = function(e, t) { var i = t.getAttribute("width") , r = t.getAttribute("height") , a = FamilyTree._getViewBox(t) , n = { w: parseFloat(i), h: parseFloat(r) }; return [{ vb: a, size: { w: n.w + (e.margin[1] + e.margin[3]), h: n.h + (e.margin[0] + e.margin[2]) }, innerSize: n }] } , FamilyTree.prototype._pagesAfit = function(e, t, i) { var r = t.getAttribute("width") , a = 0 , n = 0; switch (e.format) { case "A5": a = FamilyTree.A5w, n = FamilyTree.A5h; break; case "A4": a = FamilyTree.A4w, n = FamilyTree.A4h; break; case "A3": a = FamilyTree.A3w, n = FamilyTree.A3h; break; case "A2": a = FamilyTree.A2w, n = FamilyTree.A2h; break; case "A1": a = FamilyTree.A1w, n = FamilyTree.A1h; break; case "Letter": a = FamilyTree.Letterw, n = FamilyTree.Letterh; break; case "Legal": a = FamilyTree.Legalw, n = FamilyTree.Legalh } var o = e.landscape ? n - (e.margin[1] + e.margin[3]) : a - (e.margin[1] + e.margin[3]) , l = (e.landscape ? (e.margin[0], e.margin[2]) : (e.margin[0], e.margin[2]), o / r); return this._pagesA100(e, t, 100 * l, i) } , FamilyTree.prototype._pagesA100 = function(e, t, i, r) { var a = FamilyTree._getViewBox(t) , n = 0 , o = 0; switch (e.format) { case "A5": n = FamilyTree.A5w, o = FamilyTree.A5h; break; case "A4": n = FamilyTree.A4w, o = FamilyTree.A4h; break; case "A3": n = FamilyTree.A3w, o = FamilyTree.A3h; break; case "A2": n = FamilyTree.A2w, o = FamilyTree.A2h; break; case "A1": n = FamilyTree.A1w, o = FamilyTree.A1h; break; case "Letter": n = FamilyTree.Letterw, o = FamilyTree.Letterh; break; case "Legal": n = FamilyTree.Legalw, o = FamilyTree.Legalh } var l = a[0] , s = a[1] , d = a[2] , c = a[3] , m = { w: e.landscape ? o - (e.margin[1] + e.margin[3]) : n - (e.margin[1] + e.margin[3]), h: e.landscape ? n - (e.margin[0] + e.margin[2]) : o - (e.margin[0] + e.margin[2]) } , h = { w: e.landscape ? o : n, h: e.landscape ? n : o }; t.setAttribute("width", m.w), t.setAttribute("height", m.h); var p = m.w * (100 / i) , f = m.h * (100 / i) , u = l , y = s , g = [] , v = !0; if (!FamilyTree.EXPORT_PAGES_CUT_NODES && "fit" == e.scale) { t.setAttribute("preserveAspectRatio", "xMinYMin"); for (var T = Object.keys(r.bordersByRootIdAndLevel), b = r.bordersByRootIdAndLevel[T[0]], F = Object.keys(b).length, x = 1; x < T.length; x++) F < Object.keys(r.bordersByRootIdAndLevel[T[x]]).length && (b = r.bordersByRootIdAndLevel[T[x]], F = Object.keys(b).length); for (var _ = 0, w = 0; ; ) { for (w = _; !(F <= _); ) { if ((b[_].maxY - b[_].minY) / (100 / i) > m.h) { v = !1; break } var k = (b[_].minY - b[w].minY) / (100 / i); if (_ == F - 1 && (k = (b[_].maxY - b[w].minY) / (100 / i)), k > m.h) break; _++ } if (!v) break; var S = (_ == F ? b[_ - 1].maxY : b[_ - 1].minY) - b[w].minY; if (0 == S) { v = !1; break } if (C = (C = [u, b[w].minY, p, S]).join(), g.push({ vb: C, innerSize: { w: m.x, h: S / (100 / i) - 1 }, size: h }), _ == F) break; _-- } g.length && (g[g.length - 1].innerSize.h += 1) } if (!v || FamilyTree.EXPORT_PAGES_CUT_NODES || "fit" != e.scale) for (t.setAttribute("preserveAspectRatio", "xMinYMin slice"), g = []; u < d + l; ) { for (; y < c + s; ) { var C; C = (C = [u, y, p, f]).join(), g.push({ vb: C, innerSize: m, size: h }), y += f } u += p, y = s } return g } , FamilyTree.prototype._defaultExportProfileOptions = function(e, t) { return FamilyTree.isNEU(e) || null == e.id || null != e.nodeId || (e.nodeId = e.id), (FamilyTree.isNEU(e) || FamilyTree.isNEU(e.nodeId)) && console.error("options.nodeId is not defilned"), "svg" == t ? (e.ext = "svg", e.mime = "image/svg+xml") : "pdf" == t ? (e.mime = "application/pdf", e.ext = "pdf") : "png" == t && (e.mime = "image/png", e.ext = "png"), null == e.margin && (e.margin = [50, 40, 50, 40]), null == e.padding && (e.padding = 0), null == e.landscape && (e.landscape = !1), null == e.filename && (e.filename = "Profile." + e.ext), null == e.scale && (e.scale = "fit"), null == e.format && (e.format = "A4"), null == e.header && (e.header = ""), null == e.footer && (e.footer = ""), null == e.openInNewTab && (e.openInNewTab = !1), null == e.mode && (e.mode = "bft-" + this.config.mode), e } , FamilyTree._defaultExportProfileOptionsForCSV_SVG_JSON = function(e, t) { return FamilyTree.isNEU(e) && (e = {}), "string" == typeof e && (e = { filename: e }), FamilyTree.isNEU(e.filename) && (e.filename = `FamilyTree.${t}`), FamilyTree.isNEU(e.expandChildren) && (e.expandChildren = !0), FamilyTree.isNEU(e.min) && (e.min = !0), FamilyTree.isNEU(e.openInNewTab) && (e.openInNewTab = !1), e } , FamilyTree.prototype._exportProfile = function(e, t) { var i = this , r = 0 , a = 0; switch (e.format) { case "A5": r = FamilyTree.A5w, a = FamilyTree.A5h; break; case "A4": r = FamilyTree.A4w, a = FamilyTree.A4h; break; case "A3": r = FamilyTree.A3w, a = FamilyTree.A3h; break; case "A2": r = FamilyTree.A2w, a = FamilyTree.A2h; break; case "A1": r = FamilyTree.A1w, a = FamilyTree.A1h; break; case "Letter": r = FamilyTree.Letterw, a = FamilyTree.Letterh; break; case "Legal": r = FamilyTree.Legalw, a = FamilyTree.Legalh } var n = { w: e.landscape ? a - (e.margin[1] + e.margin[3]) : r - (e.margin[1] + e.margin[3]), h: e.landscape ? r - (e.margin[0] + e.margin[2]) : a - (e.margin[0] + e.margin[2]) } , o = { w: e.landscape ? a : r, h: e.landscape ? r : a } , l = this.editUI.content(e.nodeId, !0, !0, "100%", !0).element; FamilyTree.input.init(l); var s = { content: l.outerHTML, options: e, pages: [{ vb: "", innerSize: n, size: o }], styles: "" }; if (!t) { if (!1 === FamilyTree.events.publish("exportstart", [i, s])) return !1; FamilyTree.loading.show(i) } var d = this.element.querySelector("[data-bft-styles]"); d && (s.styles += d.outerHTML); var c = this.getSvg().querySelector("defs"); if (c) for (var m = 0; m < c.children.length; m++) "style" == c.children[m].nodeName.toLowerCase() && (s.styles += c.children[m].outerHTML); s = JSON.stringify(s), FamilyTree._ajax(this.config.exportUrl + "/v3", "POST", s, "arraybuffer", (function(r) { if (t) t(i, r); else { var a = FamilyTree.events.publish("exportend", [i, r]); if (FamilyTree.loading.hide(i), !1 === a) return !1; FamilyTree._downloadFile(e.mime, r, e.filename, e.openInNewTab, e.ext) } } )) } , void 0 === FamilyTree && (FamilyTree = {}), FamilyTree.events = function() { var e = {}; return { on: function(t, i, r) { Array.isArray(e[t]) || (e[t] = []), e[t].push({ listener: i, event_id: r }) }, removeAll: function(t) { Array.isArray(e[t]) || (e[t] = []), e[t] = [] }, remove: function(t, i, r) { var a = !1; if (e[t] && Array.isArray(e[t]) && e[t].length > 0) for (var n = e[t].length - 1; n >= 0; n--) (!FamilyTree.isNEU(r) && !FamilyTree.isNEU(i) && e[t][n].event_id == r && e[t][n].listener == i || !FamilyTree.isNEU(r) && FamilyTree.isNEU(i) && e[t][n].event_id == r || FamilyTree.isNEU(r) && !FamilyTree.isNEU(i) && e[t][n].listener == i || FamilyTree.isNEU(r) && FamilyTree.isNEU(i)) && (e[t].splice(n, 1), a = !0); return a }, has: function(t, i) { if (e[t] && Array.isArray(e[t]) && e[t].length > 0) { if (FamilyTree.isNEU(i)) return !0; for (var r = 0; r < e[t].length; r++) if (e[t][r].event_id == i) return !0 } return !1 }, removeForEventId: function(t) { for (var i in e) if (Array.isArray(e[i])) for (var r = e[i].length - 1; r >= 0; r--) e[i][r].event_id == t && e[i].splice(r, 1) }, publish: function(t, i) { if (e[t]) { for (var r = [], a = 0; a < e[t].length; a++) { var n = e[t][a]; null != n.event_id && n.event_id != i[0]._event_id || r.push(n.listener) } if (r.length > 0) { var o = !0; for (a = 0; a < r.length && (1 == i.length ? o = r[a](i[0]) && o : 2 == i.length ? o = r[a](i[0], i[1]) && o : 3 == i.length ? o = r[a](i[0], i[1], i[2]) && o : 4 == i.length ? o = r[a](i[0], i[1], i[2], i[3]) && o : 5 == i.length && (o = r[a](i[0], i[1], i[2], i[3], i[4]) && o), !1 !== o); a++) ; return o } } } } }(), FamilyTree.prototype.importCSV = function() { var e = this , t = document.createElement("INPUT"); t.setAttribute("type", "file"), t.setAttribute("accept", ".csv"), t.style.display = "none", t.onchange = function(t) { var i = t.target , r = new FileReader; r.onload = function() { var t = r.result , i = FamilyTree._csvToArray(t) , a = [] , n = i[0]; FamilyTree._importSetColumnNames(n, (function(t) { for (var r = 1; r < i.length; r++) { for (var n = {}, o = 0; o < i[r].length; o++) { var l = t[o] , s = i[r][o]; n[l] = FamilyTree._convertStringToArray(l, s) } "" != n.id.trim() && a.push(n) } var d = { nodes: a, columnNames: i[0] }; 0 != FamilyTree.events.publish("import", [e, d]) && (e._putInUndoStack(), e.clearRedo(), e.config.nodes = d.nodes, FamilyTree.events.publish("updated", [e]), e.filterUI.update(), e.draw()) } )) } , r.readAsText(i.files[0]) } , t.click() } , FamilyTree._importSetColumnNames = function(e, t) { if (-1 == e.indexOf("id") || -1 == e.indexOf("pid")) { var i = document.createElement("DIV") , r = document.createElement("P"); r.style.padding = "5px", r.style.color = "rgb(122, 122, 122)", r.innerHTML = FamilyTree.IMPORT_MESSAGE, i.appendChild(r); var a = document.createElement("div") , n = document.createElement("div") , o = document.createElement("div") , l = document.createElement("span"); a.setAttribute("id", "bft-sampleDialog"), a.style.height = "260px", a.style.width = "400px", a.style.background = "white", a.style.border = "0.5px solid grey", a.style.position = "fixed", a.style.overflow = "hidden", a.style.zIndex = "99", n.setAttribute("id", "title"), n.style.backgroundColor = "#e5e5e5", n.style.fontWeight = "bold", n.style.color = "rgb(122, 122, 122)", n.style.height = "20px", n.style.padding = "3px 0 0 7px", l.setAttribute("id", "close"), l.style.cursor = "pointer", l.style.position = "absolute", l.style.color = "rgb(122, 122, 122)", l.style.fontWeight = "bold", l.style.top = "2px", l.style.zIndex = 100, o.setAttribute("id", "content"), o.style.padding = "2px", n.innerHTML = "Import Organizational Chart Data", l.innerHTML = "×"; var s = document.createElement("HR"); s.style.height = "0.1px", s.style.backgroundColor = "#aeaeae", s.style.border = "none", s.style.margin = "0", a.appendChild(n), a.appendChild(s), o.appendChild(i), a.appendChild(o), a.appendChild(l), document.body.appendChild(a), FamilyTree._importCenter(a), l.style.left = a.offsetWidth - 20 + "px"; var d = document.createElement("div"); d.setAttribute("id", "overlay"), d.style.width = "100%", d.style.height = "100%", d.style.left = 0, d.style.top = 0, d.style.position = "fixed", d.style.background = "grey", d.style.opacity = "0.5", d.style.zIndex = 98, document.body.appendChild(d), a._overlay = d; var c = document.createElement("LABEL") , m = document.createTextNode("Name:"); c.setAttribute("for", "bft-id-select"), c.appendChild(m), c.style.fontSize = "16px", c.style.color = "rgb(122, 122, 122)", c.style.padding = "5px", c.style.margin = "5px", c.style.width = "30%", c.style.textAlign = "right", c.style.display = "inline-block", i.appendChild(c); var h = document.createElement("SELECT"); h.id = "bft-id-select", h.style.fontSize = "16px", h.style.color = "rgb(122, 122, 122)", h.style.padding = "5px", h.style.margin = "5px", h.style.width = "60%", h.style.border = "1px solid #aeaeae", i.appendChild(h); var p = document.createElement("BR"); i.appendChild(p); for (var f = 0; f < e.length; f++) { (T = document.createElement("option")).setAttribute("value", e[f]); var u = document.createTextNode(e[f]); T.appendChild(u), h.appendChild(T) } var y = document.createElement("LABEL") , g = document.createTextNode("Reports to:"); y.setAttribute("for", "pid-select"), y.appendChild(g), y.style.fontSize = "16px", y.style.color = "rgb(122, 122, 122)", y.style.padding = "5px", y.style.margin = "5px", y.style.width = "30%", y.style.textAlign = "right", y.style.display = "inline-block", i.appendChild(y); var v = document.createElement("SELECT"); v.id = "pid-select", v.style.fontSize = "16px", v.style.color = "rgb(122, 122, 122)", v.style.padding = "5px", v.style.margin = "5px", v.style.width = "60%", v.style.border = "1px solid #aeaeae", i.appendChild(v); for (f = 0; f < e.length; f++) { var T; (T = document.createElement("option")).setAttribute("value", e[f]); u = document.createTextNode(e[f]); T.appendChild(u), v.appendChild(T) } var b = document.createElement("BUTTON"); b.innerHTML = "Import", b.style.fontSize = "16px", b.style.color = "rgb(122, 122, 122)", b.style.padding = "5px 20px", b.style.margin = "20px auto", b.style.display = "block", b.onclick = function() { a.style.display = "none", a._overlay && a._overlay.parentNode.removeChild(a._overlay); var i = h.options[h.selectedIndex].value , r = e.indexOf(i); e[r] = "id"; var n = v.options[v.selectedIndex].value , o = e.indexOf(n); e[o] = "pid", t(e) } ; var F = document.createElement("DIV"); return F.appendChild(b), i.appendChild(F), l.onclick = function(e) { a._overlay && a._overlay.parentNode.removeChild(a._overlay), a.parentNode.removeChild(a), e.stopPropagation() } , n.onmousedown = function(e) { e = e || window.event, a._dragging = !0, a._originalLeft = a.offsetLeft, a._originalTop = a.offsetTop, a._mouseLeft = e.clientX, a._mouseTop = e.clientY } , document.onmousemove = function(e) { e = e || window.event, a._dragging && (a.style.left = a._originalLeft + e.clientX - a._mouseLeft + "px", a.style.top = a._originalTop + e.clientY - a._mouseTop + "px") } , document.onmouseup = function(e) { e = e || window.event, a._dragging && (a.style.left = a._originalLeft + e.clientX - a._mouseLeft + "px", a.style.top = a._originalTop + e.clientY - a._mouseTop + "px", a._dragging = !1) } , a } t(e) } , FamilyTree._importCenter = function(e) { e && (e.style.left = (window.innerWidth - e.offsetWidth) / 2 + "px", e.style.top = (window.innerHeight - e.offsetHeight) / 2 + "px") } , FamilyTree.prototype.importXML = function() { var e = this , t = document.createElement("INPUT"); t.setAttribute("type", "file"), t.setAttribute("accept", ".xml"), t.style.display = "none", t.onchange = function(t) { var i = t.target , r = new FileReader; r.onload = function() { var t = r.result , i = FamilyTree._xml2json(t); 0 != FamilyTree.events.publish("import", [e, i]) && (e._putInUndoStack(), e.clearRedo(), e.config.nodes = i, FamilyTree.events.publish("updated", [e]), e.filterUI.update(), e.draw()) } , r.readAsText(i.files[0]) } , t.click() } , FamilyTree.prototype.importJSON = function() { var e = this , t = document.createElement("INPUT"); t.setAttribute("type", "file"), t.setAttribute("accept", ".json"), t.style.display = "none", t.onchange = function(t) { var i = t.target , r = new FileReader; r.onload = function() { var t = r.result , i = JSON.parse(t); 0 != FamilyTree.events.publish("import", [e, i]) && (e._putInUndoStack(), e.clearRedo(), e.config.nodes = i, FamilyTree.events.publish("updated", [e]), e.filterUI.update(), e.draw()) } , r.readAsText(i.files[0]) } , t.click() } , FamilyTree.prototype.__importJSON = FamilyTree.prototype.importJSON, FamilyTree.prototype.importJSON = function() { this.config.roots = [], this.__importJSON() } , FamilyTree.prototype.__importCSV = FamilyTree.prototype.importCSV, FamilyTree.prototype.importCSV = function() { this.config.roots = [], this.__importCSV() } , FamilyTree.prototype.__importXML = FamilyTree.prototype.importXML, FamilyTree.prototype.importXML = function() { this.config.roots = [], this.__importXML() } , FamilyTree._importSetColumnNames = function(e, t) { t(e) } , FamilyTree.prototype.expand = function(e, t, i) { this._resetMovableNodes(); var r = { id: e, ids: t }; this._draw(!1, FamilyTree.action.expand, r, i) } , FamilyTree.prototype.collapse = function(e, t, i) { this._resetMovableNodes(); var r = { id: e, ids: t }; this._draw(!1, FamilyTree.action.collapse, r, i) } , FamilyTree.prototype.expandCollapse = function(e, t, i, r) { this._resetMovableNodes(), Array.isArray(t) || (t = []), Array.isArray(i) || (i = []); var a = { id: e, expandIds: t, collapseIds: i, ids: t.concat(i) }; this._draw(!1, FamilyTree.action.collapse, a, r) } , FamilyTree.prototype.changeRoots = function(e, t, i) { this.config.roots = t; var r = { id: e, changeRoots: t }; this._draw(!1, FamilyTree.action.update, r, i) } , FamilyTree.prototype._resetMovableNodes = function() { if (FamilyTree.RESET_MOVABLE_ONEXPANDCOLLAPSE && null != this.config.movable) { for (var e = !1, t = 0; t < this.config.nodes.length; t++) { var i = this.config.nodes[t]; null != i.movex && (i.movex = 0, e = !0), null != i.movey && (i.movey = 0, e = !0) } e && FamilyTree.events.publish("updated", [this]) } } , FamilyTree.prototype.maximize = function(e, t, i, r) { var a = this , n = { id: e, options: {} }; FamilyTree.isNEU(n.id) && (n.id = this.roots[0].id, n.all = !0), n.options.horizontal = !1, n.options.vertical = !1, t && (n.options.horizontal = t), i && (n.options.vertical = i), this._draw(!1, FamilyTree.action.maximize, n, (function() { a.ripple(e), r && r() } )) } , FamilyTree.prototype.minimize = function(e, t) { var i = this , r = { id: e }; FamilyTree.isNEU(r.id) && (r.id = this.roots[0].id, r.all = !0), this._draw(!1, FamilyTree.action.minimize, r, (function() { i.ripple(e), t && t() } )) } , FamilyTree.prototype._expCollHandler = function(e) { this.nodeMenuUI.hide(), this.nodeContextMenuUI.hide(), this.menuUI.hide(), this.nodeCircleMenuUI.hide(); var t = this.getNode(e) , i = this.getCollapsedIds(t); if (i.length) { if (!1 === FamilyTree.events.publish("expcollclick", [this, !1, e, i])) return !1; this.expand(e, i, !1) } else { if (!1 === FamilyTree.events.publish("expcollclick", [this, !0, e, t.childrenIds])) return !1; this.collapse(e, t.childrenIds, !1) } } , FamilyTree.prototype._upHandler = function(e) { this.nodeMenuUI.hide(), this.nodeContextMenuUI.hide(), this.menuUI.hide(), this.nodeCircleMenuUI.hide(); var t = this._upHandlerCreateArgs(e); if (!1 === FamilyTree.events.publish("up-click", [this, t])) return !1; this.changeRoots(t.id, t.roots, !1) } , FamilyTree.prototype._upHandlerCreateArgs = function(e) { var t, i = this.getNode(e), r = Object.assign([], this.config.roots), a = this.getNode(i.pid); if (a && (t = a), t) { if (Array.isArray(r)) { var n = r.indexOf(i.id); -1 != n && r.splice(n, 1) } else r = []; r.push(t.id) } return { id: i.id, roots: r } } , FamilyTree.prototype._upHandlerCreateArgs = function(e) { var t = this.getNode(e) , i = Object.assign([], this.config.roots) , r = this.getRecentRootsByNodeId(e); return Array.isArray(i) || (i = []), FamilyTree._changeRootOption(i, r, this.manager.rootList), { id: t.id, roots: i } } , String.prototype.replaceAll || (String.prototype.replaceAll = function(e, t) { return this.replace(new RegExp(e,"g"), t) } ), String.prototype.endsWith || (String.prototype.endsWith = function(e) { return -1 !== this.indexOf(e, this.length - e.length) } ), String.prototype.splice || (String.prototype.splice = function(e, t, i) { return this.slice(0, e) + i + this.slice(e + Math.abs(t)) } ), String.prototype.insert || (String.prototype.insert = function(e, t) { return e > 0 ? this.substring(0, e) + t + this.substr(e) : t + this } ), Array.prototype.unique || Object.defineProperty(Array.prototype, "unique", { value: function() { for (var e = this.concat(), t = 0; t < e.length; ++t) for (var i = t + 1; i < e.length; ++i) e[t] === e[i] && e.splice(i--, 1); return e }, writable: !0, configurable: !0, enumerable: !1 }), Array.prototype.has || Object.defineProperty(Array.prototype, "has", { value: function(e) { for (var t = 0; t < this.length; t++) if (this[t] == e) return !0; return !1 }, writable: !0, configurable: !0, enumerable: !1 }), Array.prototype.compare || Object.defineProperty(Array.prototype, "compare", { value: function(e) { if (this.length != e.length) return !1; for (var t = 0; t < this.length; t++) if (!e.has(this[t])) return !1; return !0 }, writable: !0, configurable: !0, enumerable: !1 }), Object.assign || Object.defineProperty(Object, "assign", { value: function(e, t) { "use strict"; if (null == e) throw new TypeError("Cannot convert undefined or null to object"); for (var i = Object(e), r = 1; r < arguments.length; r++) { var a = arguments[r]; if (null != a) for (var n in a) Object.prototype.hasOwnProperty.call(a, n) && (i[n] = a[n]) } return i }, writable: !0, configurable: !0 }), FamilyTree.prototype._globalMouseDownHandler = function(e, t) { var i = { move: "mousemove", up: "mouseup", leave: "mouseleave" }; if (-1 != t.type.indexOf("touch") && (1 == t.touches.length ? this._touch = { x: t.touches[0].clientX, y: t.touches[0].clientY } : this._touch = null, i = { move: "touchmove", up: "touchend", touchstart: "touchstart" }), e == t.target) return t.stopPropagation(), t.preventDefault(), void this._mouseDownHandler(e, t, i); if (this.config.nodeMouseClick == FamilyTree.action.pan) { for (var r = t.target; r != e && !r.hasAttribute(FamilyTree.attr.control_expcoll_id) && !r.hasAttribute(FamilyTree.attr.control_up_id); ) r = r.parentNode; if (!r.hasAttribute(FamilyTree.attr.control_expcoll_id) && !r.hasAttribute(FamilyTree.attr.control_up_id)) return t.stopPropagation(), t.preventDefault(), void this._mouseDownHandler(e, t, i) } for (var a = t.target; a != e; ) { if (a.hasAttribute(FamilyTree.attr.node_id)) return void this._nodeMouseDownHandler(a, t, i); if (a.hasAttribute(FamilyTree.attr.control_node_circle_menu_name)) return t.stopPropagation(), t.preventDefault(), void this._nodeCircleNodeMenuItemMouseDownHandler(a, t, i); a = a.parentNode } } , FamilyTree.prototype._globalClickHandler = function(e, t) { if (-1 != t.type.indexOf("touch") && this._touch && 1 == t.changedTouches.length) { if (t.changedTouches.length) { var i = { x: t.changedTouches[0].clientX, y: t.changedTouches[0].clientY } , r = FamilyTree.t(this.config.template, !1, this.getScale()).size , a = this.getScale() , n = Math.abs(i.x - this._touch.x) / a , o = Math.abs(i.y - this._touch.y) / a; if (this._touch = null, n > r[0] / 10) return; if (o > r[1] / 10) return } } else if (-1 != t.type.indexOf("touch") && null == this._touch) return; for (var l = t.target; l != e; ) { if (l.hasAttribute(FamilyTree.attr.control_expcoll_id)) { var s = l.getAttribute(FamilyTree.attr.control_expcoll_id) , d = this.getNode(s); return void this._expCollHandler(d.id) } if (l.hasAttribute(FamilyTree.attr.node_id)) { s = l.getAttribute(FamilyTree.attr.node_id), d = this.getNode(s); return void this._nodeClickHandler(d.id, t) } if (l.hasAttribute(FamilyTree.attr.control_node_menu_id)) { t.stopPropagation(), t.preventDefault(); s = l.getAttribute(FamilyTree.attr.control_node_menu_id), d = this.getNode(s); return void this._nodeMenuClickHandler(d.id, l, t) } if (l.hasAttribute(FamilyTree.attr.control_node_circle_menu_id)) { t.stopPropagation(), t.preventDefault(); s = l.getAttribute(FamilyTree.attr.control_node_circle_menu_id); return void this._nodeCircleMenuClickHandler(s) } if (l.hasAttribute(FamilyTree.attr.control_node_circle_menu_name)) return t.stopPropagation(), t.preventDefault(), void this._nodeCircleMenuItemClickHandler(l, t); if (l.hasAttribute(FamilyTree.attr.control_add)) return void this._lonelyButtonHandler(); if (l.hasAttribute(FamilyTree.attr.control_up_id)) { s = l.getAttribute(FamilyTree.attr.control_up_id); return t.stopPropagation(), t.preventDefault(), void this._upHandler(s) } if (l.hasAttribute(FamilyTree.attr.c_link_from)) return void FamilyTree.events.publish("clink-click", [this, { from: l.getAttribute(FamilyTree.attr.c_link_from), to: l.getAttribute(FamilyTree.attr.c_link_to), event: t }]); if (l.hasAttribute(FamilyTree.attr.s_link_from)) return void FamilyTree.events.publish("slink-click", [this, { from: l.getAttribute(FamilyTree.attr.s_link_from), to: l.getAttribute(FamilyTree.attr.s_link_to), event: t }]); l = l.parentNode } } , FamilyTree.prototype._globalContextHandler = function(e, t) { for (var i = t.target; i != e; ) { if (i.hasAttribute(FamilyTree.attr.node_id)) { var r = i.getAttribute(FamilyTree.attr.node_id) , a = this.getNode(r); return void this._nodeContextHandler(a.id, t) } i = i.parentNode } } , FamilyTree.prototype._nodeContextHandler = function(e, t) { t.preventDefault(), FamilyTree.SEARCH_CLOSE_RESULT_ON_ESCAPE_OR_CLICKOUTSIDE && this.searchUI.hide(), this.nodeMenuUI.hide(), this.nodeContextMenuUI.hide(), this.menuUI.hide(), this.nodeCircleMenuUI.hide(); var i = this.get(e) , r = null; if (null != i && Array.isArray(i.tags)) for (var a = 0; a < i.tags.length; a++) { var n = i.tags[a]; this.config.tags[n] && this.config.tags[n].nodeContextMenu && (r = this.config.tags[n].nodeContextMenu) } var o = this.element.getBoundingClientRect() , l = t.clientX - o.left , s = t.clientY - o.top; this.nodeContextMenuUI.show(l, s, e, null, r) } , FamilyTree.prototype._globalDbClickHandler = function(e, t) { for (var i = t.target; i != e; ) { if (i.hasAttribute(FamilyTree.attr.node_id)) { var r = i.getAttribute(FamilyTree.attr.node_id) , a = this.getNode(r); return void this._nodeDbClickHandler(a.id, t) } i = i.parentNode } } , FamilyTree.prototype._mouseScrollHandler = function(e, t) { this.__mouseScrollHandler(this.getSvg(), t) } , FamilyTree.prototype.__mouseScrollHandler = function(e, t) { if (t.ctrlKey) { if (this.config.mouseScrool == FamilyTree.action.zoom) return } else { if (this.config.mouseScrool == FamilyTree.action.ctrlZoom) return; if (this.config.mouseScrool != FamilyTree.action.zoom) return } var i = this , r = !1 , a = this.config.zoom.speed , n = this.config.zoom.smooth , o = 0 , l = this.getScale() , s = FamilyTree._centerPointInPercent(e, t.pageX, t.pageY); var d = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(e) { setTimeout(e, 20) } ; t.preventDefault(); var c = t.delta || t.wheelDelta; void 0 === c && (c = -t.detail), c = Math.max(-1, Math.min(1, c)), o += -c * a, r || function e() { r = !0; var t = (o - l) / n; t > 0 ? t++ : t--, l += t, i.zoom(1 - t / 12 / 50, s), parseInt(l) == parseInt(o) ? r = !1 : d(e) }() } , FamilyTree.prototype._nodeCircleNodeMenuItemMouseDownHandler = function(e, t, i) { var r = e.parentNode.getAttribute(FamilyTree.attr.control_node_circle_menu_wrraper_id) , a = e.getAttribute(FamilyTree.attr.control_node_circle_menu_name) , n = this.nodeCircleMenuUI._menu[a]; if (n.draggable) { var o = this , l = FamilyTree._getClientXY(t) , s = this.getNode(r); e._dragEventFired = !1; var d = o.getScale() , c = null , m = null; this._gragStartedId = r, document.body.style.mozUserSelect = document.body.style.webkitUserSelect = document.body.style.userSelect = "none"; var h = this.getSvg() , p = { x: l.x, y: l.y } , f = e.cloneNode(!0); h.insertBefore(f, h.firstChild); var u = FamilyTree._getTransform(f) , y = u[4] , g = u[5] , v = function(e) { for (; e && !e.hasAttribute(FamilyTree.attr.control_node_circle_menu_wrraper_id); ) e = e.parentNode; if (e) { var t = FamilyTree._getTransform(e); return { x: t[4], y: t[5] } } console.error("cannot find parent" + FamilyTree.attr.control_node_circle_menu_wrraper_id) }(e); f.setAttribute("transform", "matrix(1,0,0,1," + (y + v.x) + "," + (g + v.y) + ")"), f.style.opacity = .7; var T = function(e, t) { if (null != e) { t.classList.remove("bft-drag-over"); for (var i = FamilyTree.getStParentNodes(o.getNode(c)), r = 0; r < i.length; r++) { var a = o.getNodeElement(i[r].id); a && (a.style.opacity = 1) } } } , b = function(t) { if (p) { var i = FamilyTree._getClientXY(t) , r = t.target; FamilyTree.isMobile() && (r = document.elementFromPoint(i.x, i.y)), i.x += v.x * d, i.y += v.y * d; var l = FamilyTree._getOffsetXY(o.element, t) , s = { left: o.width() - (l.x + o.config.padding) < 0, right: l.x - o.config.padding < 0, up: o.height() - (l.y + o.config.padding) < 0, down: l.y - o.config.padding < 0 }; if (s.left || s.right || s.up || s.down) { h.classList && (h.classList.remove("bft-cursor-grab"), h.classList.add("bft-cursor-move"), h.classList.remove("bft-cursor-nodrop"), h.classList.remove("bft-cursor-copy")); var b = u[4] , x = u[5] , _ = p.x , w = p.y , k = i.x , S = i.y; o.moveStart(s, (function(e) { u[4] = b + e.x, u[5] = x + e.y, p.x = _ - e.xWithoutScale, p.y = w - e.yWithoutScale, i.x = k - e.xWithoutScale, i.y = S - e.yWithoutScale, f.setAttribute("transform", "matrix(" + u.toString() + ")") } )) } else { for (o.moveEnd(), h.classList && (h.classList.add("bft-cursor-grab"), h.classList.remove("bft-cursor-move"), h.classList.remove("bft-cursor-nodrop"), h.classList.remove("bft-cursor-copy")), T(c, m), c = null, m = null; null != r && r != h; ) { if (r.hasAttribute && r.hasAttribute(FamilyTree.attr.node_id)) { var C = r.getAttribute(FamilyTree.attr.node_id); c = C, m = r; break } r = r.parentNode } if (null != c) { m.classList.add("bft-drag-over"); for (var I = o.getNode(c), N = FamilyTree.getStParentNodes(I), A = 0; A < N.length; A++) { var L = o.getNodeElement(N[A].id); L && (L.style.opacity = .1) } h.classList.remove("bft-cursor-grab"), h.classList.remove("bft-cursor-move"), h.classList.add("bft-cursor-copy"), h.classList.remove("bft-cursor-nodrop") } var E = (i.x - p.x) / d , M = (i.y - p.y) / d; if (u[4] = y + E, u[5] = g + M, !e._dragEventFired && (Math.abs(i.x - p.x) > FamilyTree.FIRE_DRAG_NOT_CLICK_IF_MOVE || Math.abs(i.y - p.y) > FamilyTree.FIRE_DRAG_NOT_CLICK_IF_MOVE)) !1 === FamilyTree.events.publish("drag", [o.nodeCircleMenuUI, { from: C, menuItem: n, menuItemName: a }]) && F(), e._dragEventFired = !0; f.setAttribute("transform", "matrix(" + u.toString() + ")") } } } , F = function(t) { if (o.moveEnd(), h.classList && (h.classList.remove("bft-cursor-grab"), h.classList.remove("bft-cursor-move"), h.classList.remove("bft-cursor-nodrop"), h.classList.remove("bft-cursor-copy")), h.removeEventListener(i.move, b), h.removeEventListener(i.up, F), i.leave && h.removeEventListener(i.leave, F), s.id == c || null == c) return h.removeChild(f), o._gragStartedId = null, void (e._dragEventFired && FamilyTree.events.publish("drop", [o.nodeCircleMenuUI, { from: s.id, menuItemName: a, menuItem: n, event: t }])); var r = o.getNode(c); FamilyTree.events.publish("drop", [o.nodeCircleMenuUI, { from: s.id, to: r.id, menuItem: n, menuItemName: a, event: t }]), T(c, m), h.removeChild(f), o._gragStartedId = null }; h.addEventListener(i.move, b), h.addEventListener(i.up, F), i.leave && h.addEventListener(i.leave, F) } } , FamilyTree.prototype._nodeMouseDownHandler = function(e, t, i) { var r = e.getAttribute(FamilyTree.attr.node_id) , a = this.getNode(r); this.config.movable && !FamilyTree.getRootOf(a).stParent ? this._movableHandler(e, t, i) : this.config.enableDragDrop && this._dragDropHandler(e, t, i) } , FamilyTree.prototype._movableHandler = function(e, t, i) { var r = this , a = e.getAttribute(FamilyTree.attr.node_id) , n = [] , o = function(e, t) { if (Array.isArray(e)) for (var i = 0; i < e.length; i++) o(e[i], t); else { t.push(e.id); for (i = 0; i < e.stChildren.length; i++) o(e.stChildren[i], t); for (i = 0; i < e.children.length; i++) o(e.children[i], t) } } , l = function(e, t) { if (Array.isArray(e)) for (var i = 0; i < e.length; i++) o(e[i], t); else { t.push(e.id); for (i = 0; i < e.stChildrenIds.length; i++) l(r.getNode(e.stChildrenIds[i]), t); for (i = 0; i < e.childrenIds.length; i++) l(r.getNode(e.childrenIds[i]), t) } } , s = this.getNode(a); o(s, n); for (var d = this.getSvg(), c = FamilyTree._getClientXY(t), m = [], h = [], p = [], f = [], u = [], y = [], g = [], v = [], T = 0; T < n.length; T++) { var b = this.getNode(n[T]); m.push(b), p.push({ x: b.x, y: b.y }); var F = this.getNodeElement(n[T]); if (F) { u.push(F); var x = FamilyTree._getTransform(F); f.push({ x: x[4], y: x[5] }), h.push(x); var _ = this.element.querySelector(`[data-ctrl-ec-id="${n[T]}"]`); if (_) { y.push(_); var w = FamilyTree._getTransform(_); g.push(w), v.push({ x: w[4], y: w[5] }) } else y.push(null), g.push(null), v.push(null); if (this.config.movable == FamilyTree.movable.node) break } } e._dragEventFired = !1; var k = null , S = null; this._gragStartedId = n[0], document.body.style.mozUserSelect = document.body.style.webkitUserSelect = document.body.style.userSelect = "none"; var C = { x: c.x, y: c.y } , I = r.getScale() , N = function(e, t) { if (null != e) { t.classList.remove("bft-drag-over"); for (var i = r.getNode(k), a = FamilyTree.getStParentNodes(i), n = 0; n < a.length; n++) { var o = r.getNodeElement(a[n].id); o && (o.style.opacity = 1) } } } , A = function(t) { if (C) { var i = FamilyTree._getClientXY(t) , o = t.target; FamilyTree.isMobile() && (o = document.elementFromPoint(i.x, i.y)); var l = FamilyTree._getOffsetXY(r.element, t) , c = { left: r.width() - (l.x + r.config.padding) < 0, right: l.x - r.config.padding < 0, up: r.height() - (l.y + r.config.padding) < 0, down: l.y - r.config.padding < 0 }; if (c.left || c.right || c.up || c.down) { d.classList && (d.classList.remove("bft-cursor-grab"), d.classList.add("bft-cursor-move"), d.classList.remove("bft-cursor-nodrop"), d.classList.remove("bft-cursor-copy")); for (var T = [], b = [], F = [], x = [], _ = 0; _ < h.length; _++) T.push(h[_][4]), b.push(h[_][5]), g[_] ? (F.push(g[_][4]), x.push(g[_][5])) : (F.push(null), x.push(null)); var w = C.x , A = C.y , E = i.x , M = i.y; r.moveStart(c, (function(e) { for (var t = 0; t < h.length; t++) { var a = T[t] , n = b[t] , o = F[t] , l = x[t]; h[t][4] = a + e.x, h[t][5] = n + e.y, C.x = w - e.xWithoutScale, C.y = A - e.yWithoutScale, i.x = E - e.xWithoutScale, i.y = M - e.yWithoutScale, m[t].x = a + e.x, m[t].y = n + e.y, m[t].movex = e.x, m[t].movey = e.y, g[t] && (g[t][4] = o + e.x, g[t][5] = l + e.y); for (var s = FamilyTree.ui.link(m[t], r, I, r.response.bordersByRootIdAndLevel, r.nodes, FamilyTree.action.update, !0), d = 0; d < s.length; d++) { var c = s[d]; (p = r.element.querySelector(`[data-l-id="[${c.id}][${c.childId}]"]`)) && (p.innerHTML = c.html) } if (m[t].parent) for (s = FamilyTree.ui.link(m[t].parent, r, I, r.response.bordersByRootIdAndLevel, r.nodes, FamilyTree.action.update, !0), d = 0; d < s.length; d++) { var p; c = s[d]; (p = r.element.querySelector(`[data-l-id="[${c.id}][${c.childId}]"]`)) && (p.innerHTML = c.html) } u[t].setAttribute("transform", "matrix(" + h[t].toString() + ")"), y[t] && y[t].setAttribute("transform", "matrix(" + g[t].toString() + ")") } } )) } else { if (r.moveEnd(), d.classList && (d.classList.add("bft-cursor-grab"), d.classList.remove("bft-cursor-move"), d.classList.remove("bft-cursor-nodrop"), d.classList.remove("bft-cursor-copy")), N(k, S), k = null, S = null, r.config.enableDragDrop) for (; null != o && o != d; ) { if (o.hasAttribute && o.hasAttribute(FamilyTree.attr.node_id)) { var O = o.getAttribute(FamilyTree.attr.node_id); if (r._gragStartedId && O != r._gragStartedId) { k = O, S = o; break } } o = o.parentNode } if (null != k) { S.classList.add("bft-drag-over"); for (var U = r.getNode(k), B = FamilyTree.getStParentNodes(U), R = 0; R < B.length; R++) { var P = r.getNodeElement(B[R].id); P && (P.style.opacity = .1) } !r.canUpdateLink(m[0].id, k) && d.classList ? (d.classList.remove("bft-cursor-grab"), d.classList.remove("bft-cursor-move"), d.classList.remove("bft-cursor-copy"), d.classList.add("bft-cursor-nodrop")) : d.classList && (d.classList.remove("bft-cursor-grab"), d.classList.remove("bft-cursor-move"), d.classList.add("bft-cursor-copy"), d.classList.remove("bft-cursor-nodrop")) } var D = (i.x - C.x) / I , H = (i.y - C.y) / I; for (_ = 0; _ < h.length; _++) { h[_][4] = f[_].x + D, h[_][5] = f[_].y + H, g[_] && (g[_][4] = v[_].x + D, g[_][5] = v[_].y + H), m[_].x = p[_].x + D, m[_].y = p[_].y + H, m[_].movex = D, m[_].movey = H; var z = FamilyTree.ui.link(m[_], r, I, r.response.bordersByRootIdAndLevel, r.nodes, FamilyTree.action.update, !0); for (R = 0; R < z.length; R++) { var $ = z[R]; (j = r.element.querySelector(`[data-l-id="[${$.id}][${$.childId}]"]`)) && (j.innerHTML = $.html) } } if (s.parent) if (r.config.movable == FamilyTree.movable.detachTree) (j = r.element.querySelector(`[data-l-id="[${s.parent.id}][${s.id}]"]`)) && j.parentElement.removeChild(j); else for (z = FamilyTree.ui.link(s.parent, r, I, r.response.bordersByRootIdAndLevel, r.nodes, FamilyTree.action.update, !0), R = 0; R < z.length; R++) { var j; $ = z[R]; (j = r.element.querySelector(`[data-l-id="[${$.id}][${$.childId}]"]`)) && (j.innerHTML = $.html) } if (!e._dragEventFired && (Math.abs(i.x - C.x) > FamilyTree.FIRE_DRAG_NOT_CLICK_IF_MOVE || Math.abs(i.y - C.y) > FamilyTree.FIRE_DRAG_NOT_CLICK_IF_MOVE)) { if (!1 === FamilyTree.events.publish("drag", [r, a, t, n]) && L(), r.config.enableDragDrop) for (_ = 0; _ < u.length; _++) d.insertBefore(u[_], d.firstChild); e._dragEventFired = !0 } for (_ = 0; _ < h.length; _++) u[_].setAttribute("transform", "matrix(" + h[_].toString() + ")"), y[_] && y[_].setAttribute("transform", "matrix(" + g[_].toString() + ")") } } } , L = function(t) { for (var a = 0; a < m.length; a++) m[a].x = p[a].x, m[a].y = p[a].y; if (r.moveEnd(), d.classList && (d.classList.remove("bft-cursor-grab"), d.classList.remove("bft-cursor-move"), d.classList.remove("bft-cursor-nodrop"), d.classList.remove("bft-cursor-copy")), d.removeEventListener(i.move, A), d.removeEventListener(i.up, L), i.leave && d.removeEventListener(i.leave, L), m[0].id != k && null != k) { var n = r.getNode(k); if (!1 === (o = FamilyTree.events.publish("drop", [r, m[0].id, n.id, u[0], t]))) return N(k, S), void (r._gragStartedId = null); if (r.canUpdateLink(m[0].id, k)) (g = r.get(m[0].id)).pid = k, g.stpid = null, r.updateNode(g, null, !0); else N(k, S); r._gragStartedId = null } else { if (e._dragEventFired) { var o = FamilyTree.events.publish("drop", [r, m[0].id, void 0, u[0], t]); if (r.config.movable && !1 !== o) if (r.config.movable == FamilyTree.movable.detachTree) { var c = FamilyTree._getTransform(r.getNodeElement(s.id)); (g = r.get(s.id)).pid = null, g.stpid = null, r.updateNode(g, null, !0) } else { var h = []; r.config.movable == FamilyTree.movable.node ? h.push(s.id) : l(s, h); var f = (c = FamilyTree._getTransform(r.getNodeElement(s.id)))[4] - s.x , y = c[5] - s.y; for (a = 0; a < h.length; a++) { var g; (g = r.get(h[a])) && (null != g.movex ? g.movex += f : g.movex = f, null != g.movey ? g.movey += y : g.movey = y, r.update(g)) } FamilyTree.events.publish("updated", [r]), r.draw(FamilyTree.action.update, { dragNodeIdList: h }) } } r._gragStartedId = null } }; d.addEventListener(i.move, A), d.addEventListener(i.up, L), i.leave && d.addEventListener(i.leave, L) } , FamilyTree.prototype._dragDropHandler = function(e, t, i) { var r = FamilyTree._getClientXY(t) , a = e.getAttribute(FamilyTree.attr.node_id) , n = this.getNode(a); e._dragEventFired = !1; var o = null , l = null; this._gragStartedId = a, this.element.style.mozUserSelect = this.element.style.webkitUserSelect = this.element.style.userSelect = "none"; var s = this , d = this.getSvg() , c = { x: r.x, y: r.y } , m = FamilyTree._getTransform(e) , h = m[4] , p = m[5] , f = s.getScale() , u = e.cloneNode(!0); u.setAttribute("data-n-id", "draging"), d.insertBefore(u, d.firstChild), u.style.opacity = .7; var y = function(e, t) { if (null != e) { t.classList.remove("bft-drag-over"); for (var i = s.getNode(o), r = FamilyTree.getStParentNodes(i), a = 0; a < r.length; a++) { var n = s.getNodeElement(r[a].id); n && (n.style.opacity = 1) } } } , g = function(t) { if (c) { var i = FamilyTree._getClientXY(t) , r = t.target; FamilyTree.isMobile() && (r = document.elementFromPoint(i.x, i.y)); var a = FamilyTree._getOffsetXY(s.element, t) , g = { left: s.width() - (a.x + s.config.padding) < 0, right: a.x - s.config.padding < 0, up: s.height() - (a.y + s.config.padding) < 0, down: a.y - s.config.padding < 0 }; if (g.left || g.right || g.up || g.down) { d.classList && (d.classList.remove("bft-cursor-grab"), d.classList.add("bft-cursor-move"), d.classList.remove("bft-cursor-nodrop"), d.classList.remove("bft-cursor-copy")); var T = m[4] , b = m[5] , F = c.x , x = c.y , _ = i.x , w = i.y; s.moveStart(g, (function(e) { m[4] = T + e.x, m[5] = b + e.y, c.x = F - e.xWithoutScale, c.y = x - e.yWithoutScale, i.x = _ - e.xWithoutScale, i.y = w - e.yWithoutScale, u.setAttribute("transform", "matrix(" + m.toString() + ")") } )) } else { if (s.moveEnd(), d.classList && (d.classList.add("bft-cursor-grab"), d.classList.remove("bft-cursor-move"), d.classList.remove("bft-cursor-nodrop"), d.classList.remove("bft-cursor-copy")), y(o, l), o = null, l = null, s.config.enableDragDrop) for (; null != r && r != d; ) { if (r.hasAttribute && r.hasAttribute(FamilyTree.attr.node_id)) { var k = r.getAttribute(FamilyTree.attr.node_id); if (s._gragStartedId && k != s._gragStartedId) { o = k, l = r; break } } r = r.parentNode } if ("draging" == o && (o = null, l = null), null != o) { l.classList.add("bft-drag-over"); for (var S = s.getNode(o), C = FamilyTree.getStParentNodes(S), I = 0; I < C.length; I++) { var N = s.getNodeElement(C[I].id); N && (N.style.opacity = .1) } !s.canUpdateLink(n.id, o) && d.classList ? (d.classList.remove("bft-cursor-grab"), d.classList.remove("bft-cursor-move"), d.classList.remove("bft-cursor-copy"), d.classList.add("bft-cursor-nodrop")) : d.classList && (d.classList.remove("bft-cursor-grab"), d.classList.remove("bft-cursor-move"), d.classList.add("bft-cursor-copy"), d.classList.remove("bft-cursor-nodrop")) } var A = (i.x - c.x) / f , L = (i.y - c.y) / f; if (m[4] = h + A, m[5] = p + L, !e._dragEventFired && (Math.abs(i.x - c.x) > FamilyTree.FIRE_DRAG_NOT_CLICK_IF_MOVE || Math.abs(i.y - c.y) > FamilyTree.FIRE_DRAG_NOT_CLICK_IF_MOVE)) !1 === FamilyTree.events.publish("drag", [s, k, t]) && v(), e._dragEventFired = !0; u.setAttribute("transform", "matrix(" + m.toString() + ")") } } } , v = function(t) { if (s.moveEnd(), d.classList && (d.classList.remove("bft-cursor-grab"), d.classList.remove("bft-cursor-move"), d.classList.remove("bft-cursor-nodrop"), d.classList.remove("bft-cursor-copy")), d.removeEventListener(i.move, g), d.removeEventListener(i.up, v), i.leave && d.removeEventListener(i.leave, v), n.id == o || null == o) return e._dragEventFired && FamilyTree.events.publish("drop", [s, n.id, void 0, u, t]), d.removeChild(u), void (s._gragStartedId = null); var r = s.getNode(o); if (!1 === FamilyTree.events.publish("drop", [s, n.id, r.id, u, t])) return y(o, l), d.removeChild(u), void (s._gragStartedId = null); if (s.canUpdateLink(n.id, o)) { var a = s.get(n.id); a.pid = o, a.stpid = null, null != a.movex && (a.movex = void 0), null != a.movey && (a.movey = void 0), s.updateNode(a, null, !0) } else d.removeChild(u), y(o, l); s._gragStartedId = null }; d.addEventListener(i.move, g), d.addEventListener(i.up, v), i.leave && d.addEventListener(i.leave, v) } , FamilyTree.prototype._resizeHandler = function(e, t) { if (this.isVisible) { var i = this.getViewBox() , r = this.getSvg() , a = r.getAttribute("width") , n = r.getAttribute("height") , o = a / i[2] , l = n / i[3] , s = o > l ? l : o; r.setAttribute("width", this.width()), r.setAttribute("height", this.height()), i[2] = this.width() / s, i[3] = this.height() / s, this.setViewBox(i), this.xScrollUI.create(this.width()), this.yScrollUI.create(this.height()), this._draw(!1, FamilyTree.action.resize) } } , FamilyTree.prototype._nodeDbClickHandler = function(e, t) { if (!1 === FamilyTree.events.publish("dbclick", [this, this.get(e)])) return !1; this._commonClickHandler(e, t, this.config.nodeMouseDbClick) } , FamilyTree.prototype._nodeClickHandler = function(e, t) { var i = this.getNodeElement(e); if (i && i._dragEventFired) i._dragEventFired = !1; else { if (!1 === FamilyTree.events.publish("click", [this, { node: this.getNode(e), event: t }])) return !1; this._commonClickHandler(e, t, this.config.nodeMouseClick) } } , FamilyTree.prototype._nodeCircleMenuItemClickHandler = function(e, t) { var i = e.parentNode.getAttribute(FamilyTree.attr.control_node_circle_menu_wrraper_id) , r = e.getAttribute(FamilyTree.attr.control_node_circle_menu_name) , a = this.nodeCircleMenuUI._menu[r]; FamilyTree.events.publish("click", [this.nodeCircleMenuUI, { nodeId: i, menuItemName: r, menuItem: a, event: t }]) } , FamilyTree.prototype._nodeCircleMenuClickHandler = function(e) { FamilyTree.SEARCH_CLOSE_RESULT_ON_ESCAPE_OR_CLICKOUTSIDE && this.searchUI.hide(), this.nodeMenuUI.hide(), this.nodeContextMenuUI.hide(), this.menuUI.hide(); var t = this.getNode(e) , i = null; if (Array.isArray(t.tags)) for (var r = 0; r < t.tags.length; r++) { var a = t.tags[r]; this.config.tags[a] && this.config.tags[a].nodeCircleMenu && (i = this.config.tags[a].nodeCircleMenu) } this.nodeCircleMenuUI.show(e, i) } , FamilyTree.prototype._commonClickHandler = function(e, t, i) { var r; (FamilyTree.SEARCH_CLOSE_RESULT_ON_ESCAPE_OR_CLICKOUTSIDE && this.searchUI.hide(), this.nodeMenuUI.hide(), this.nodeContextMenuUI.hide(), this.menuUI.hide(), this.nodeCircleMenuUI.hide(), i == FamilyTree.action.expandCollapse && this.toggleExpandCollapse(e, t), i == FamilyTree.action.edit) && ((r = this.getNode(e)) && (this.editUI.show(r.id), this.ripple(r.id, t.clientX, t.clientY))); i == FamilyTree.action.details && ((r = this.getNode(e)) && (this.editUI.show(r.id, !0), this.ripple(r.id, t.clientX, t.clientY))) } , FamilyTree.prototype._menuHandlerMouseDownHandler = function(e, t) { t.stopPropagation(), t.preventDefault() } , FamilyTree.prototype._nodeMenuClickHandler = function(e, t, i) { FamilyTree.SEARCH_CLOSE_RESULT_ON_ESCAPE_OR_CLICKOUTSIDE && this.searchUI.hide(), this.nodeMenuUI.hide(), this.nodeContextMenuUI.hide(), this.menuUI.hide(), this.nodeCircleMenuUI.hide(); var r = this.getNode(e) , a = null; if (Array.isArray(r.tags)) for (var n = 0; n < r.tags.length; n++) { var o = r.tags[n]; this.config.tags[o] && this.config.tags[o].nodeMenu && (a = this.config.tags[o].nodeMenu) } this.nodeMenuUI.showStickIn(t, e, null, a) } , FamilyTree.prototype._menuClickHandler = function(e, t) { t.stopPropagation(), t.preventDefault(), this.nodeMenuUI.hide(), this.nodeContextMenuUI.hide(), this.menuUI.show(e.offsetLeft, e.offsetTop) } , FamilyTree.prototype._lonelyButtonHandler = function() { var e = { id: this.generateId() }; !1 !== this.addNode(e, null, !0) && this.center(e.id) } , FamilyTree.prototype.toggleExpandCollapse = function(e, t) { var i = this.getNode(e) , r = this.getCollapsedIds(i); if (r.length) { if (!1 === FamilyTree.events.publish("expcollclick", [this, !1, e, r])) return !1; this.expand(e, r, !1) } else { if (!1 === FamilyTree.events.publish("expcollclick", [this, !0, e, i.childrenIds])) return !1; this.collapse(e, i.childrenIds, !1) } t && this.ripple(i.id, t.clientX, t.clientY) } , FamilyTree.prototype._move = function(e, t, i) { i[0] = t, i[1] = e, this.setViewBox(i), this.xScrollUI.setPosition(), this.yScrollUI.setPosition() } , FamilyTree.prototype.moveStart = function(e, t, i, r) { if (e) { if (!this._moveInterval) { var a = this , n = this.getViewBox().slice(0) , o = this.getScale() , l = 0 , s = 0 , d = 1; FamilyTree.isNEU(i) && (i = FamilyTree.anim.inSin), FamilyTree.isNEU(r) && (r = 3e3), this._moveInterval = setInterval((function() { var c = { x: 0, y: 0, xWithoutScale: 0, yWithoutScale: 0 }; e.left ? (l++, c.x = l * FamilyTree.MOVE_STEP / o, c.xWithoutScale = l * FamilyTree.MOVE_STEP) : e.right && (l++, c.x = -l * FamilyTree.MOVE_STEP / o, c.xWithoutScale = -l * FamilyTree.MOVE_STEP), e.up ? (s++, c.y = s * FamilyTree.MOVE_STEP / o, c.yWithoutScale = s * FamilyTree.MOVE_STEP) : e.down && (s++, c.y = -s * FamilyTree.MOVE_STEP / o, c.yWithoutScale = -s * FamilyTree.MOVE_STEP); var m = i((10 * d - 10) / r); c.x = c.x * m, c.xWithoutScale = c.xWithoutScale * m, c.y = c.y * m, c.yWithoutScale = c.yWithoutScale * m, a.setViewBox([n[0] + c.x, n[1] + c.y, n[2], n[3]]), t && t(c), d += 1 } ), 10) } } else console.error("movePosition parameter not defined") } , FamilyTree.prototype.moveEnd = function() { this._moveInterval && (clearInterval(this._moveInterval), this._moveInterval = null) } , void 0 === FamilyTree && (FamilyTree = {}), FamilyTree.node = function(e, t, i, r) { this.templateName = r, this.id = e, this.pid = t, this.children = [], this.childrenIds = [], this.parent = null, this.stpid = null, this.stParent = null, this.stChildren = [], this.stChildrenIds = [], this.tags = i, this.tags || (this.tags = []) } , FamilyTree.prototype._mouseDownHandler = function(e, t, i) { var r = this; FamilyTree.HIDE_EDIT_FORM_ON_PAN && this.editUI.hide(), FamilyTree.SEARCH_CLOSE_RESULT_ON_ESCAPE_OR_CLICKOUTSIDE && this.searchUI.hide(), this.nodeMenuUI.hide(), this.nodeContextMenuUI.hide(), this.menuUI.hide(), this.nodeCircleMenuUI.hide(); var a = this.getViewBox() , n = this.getScale() , o = FamilyTree._getClientTouchesXY(t, 0) , l = FamilyTree._getClientTouchesXY(t, 1) , s = { diffX: 0, diffY: 0, x0: o.x, y0: o.y, type: "pan", viewBoxLeft: a[0], viewBoxTop: a[1] }; t.touches && t.touches.length > 1 && (s.type = "pinch", s.dist = Math.sqrt((o.x - l.x) * (o.x - l.x) + (o.y - l.y) * (o.y - l.y))), "pan" == s.type && (this._hideBeforeAnimation(), this._changeCursorOnPanStart(a, n, t)); var d = function(e) { var t = FamilyTree._getClientTouchesXY(e, 0); if (s && "pan" == s.type) { r._hideBeforeAnimation(), s.diffX = t.x - s.x0, s.diffY = t.y - s.y0; var i = -s.diffY / n + s.viewBoxTop , o = -s.diffX / n + s.viewBoxLeft; r._move(i, o, a) } else if (s && "pinch" == s.type) { var l = FamilyTree._getClientTouchesXY(e, 1) , d = Math.sqrt((t.x - l.x) * (t.x - l.x) + (t.y - l.y) * (t.y - l.y)) , c = 1 + (d - s.dist) / (s.dist / 100) / 100; s.dist = d; var m = FamilyTree._pinchMiddlePointInPercent(r.element, r.width(), r.height(), e); r.zoom(c, m) } } , c = function() { "pan" == s.type && r.config.sticky ? setTimeout((function() { FamilyTree._moveToBoundaryArea(e, r.getViewBox(), r.response.boundary, (function() { r._draw(!0, FamilyTree.action.pan) } )) } ), 0) : "pan" != s.type || r.config.sticky || setTimeout((function() { r._draw(!0, FamilyTree.action.pan) } ), 0), "pan" == s.type && r._changeCursorOnPanEnd(), s = null, e.removeEventListener(i.move, d), e.removeEventListener(i.up, c), i.leave && e.removeEventListener(i.leave, c), i.touchstart && e.removeEventListener(i.touchstart, c) }; this.config.enablePan && (e.addEventListener(i.move, d), e.addEventListener(i.up, c), i.leave && e.addEventListener(i.leave, c), i.touchstart && e.addEventListener(i.touchstart, c)) } , FamilyTree.prototype._changeCursorOnPanStart = function(e, t, i) { var r = this.getPointerElement() , a = FamilyTree._getOffsetXY(this.element, i) , n = a.x / t + e[0] - 16 / t , o = a.y / t + e[1] - 16 / t; r.style.display = "inherit", r.setAttribute("transform", "matrix(0,0,0,0," + n + "," + o + ")"), FamilyTree.animate(r, { transform: [0, 0, 0, 0, n, o], opacity: 0 }, { transform: [1 / t, 0, 0, 1 / t, n, o], opacity: 1 }, 300, FamilyTree.anim.outBack) } , FamilyTree.prototype._changeCursorOnPanEnd = function() { this.getPointerElement().style.display = "none" } , FamilyTree.searchUI = function() { this.lastSearch = [], this._searchAfterEnterPress = !1, this._event_id = FamilyTree._guid(), this.instance = null } , FamilyTree.searchUI.prototype.init = function(e) { this.instance = e, this.obj = this.instance, this._initSearchFields(); var t = this , i = this.instance.config.padding - 10 , r = this.instance.config.padding - 10 , a = this.instance.getMenuButton(); if (a) { var n = a.getBoundingClientRect() , o = this.instance.getSvg().getBoundingClientRect(); i = o.right - n.left + 10, r = n.top - o.top - 10 } var l = document.createElement("div"); l.classList.add("bft-search"), l.style.right = i + "px", l.style.top = r + "px"; var s = FamilyTree.elements.textbox({}, { label: FamilyTree.SEARCH_PLACEHOLDER, btn: "X" }, "320px"); l.innerHTML += s.html, this.xBtn = l.querySelector("[data-input-btn]"), this.xBtn.style.display = "none", this.searchTableWrapper = document.createElement("div"), l.appendChild(this.searchTableWrapper); var d = this.instance.getSvg().nextSibling; this.instance.element.insertBefore(l, d), FamilyTree.input.init(l), this.input = document.getElementById(s.id), this.xBtn.addEventListener("click", (function(e) { e.preventDefault(), t.hide() } )), this.input.addEventListener("keypress", (function(e) { "Enter" == e.key && e.preventDefault() } )), this.input.addEventListener("focus", (function(e) { t.xBtn.style.display = "", t._search() } )), this.input.addEventListener("blur", (function(e) { FamilyTree.isNEU(t.input.value) && FamilyTree.SEARCH_HELP_SYMBOL != t.input.value && (t.xBtn.style.display = "none") } )), this.input.addEventListener("keydown", (function(e) { ("ArrowDown" == e.key || "ArrowUp" == e.key) && e.preventDefault() } )), this.input.addEventListener("keyup", (function(e) { "ArrowDown" == e.key ? c() : "ArrowUp" == e.key ? m() : "Enter" == e.key ? t._enterHandler() : "Escape" == e.key ? t.hide() : this.value.length >= FamilyTree.MINIMUM_SYMBOLS_IN_SEARCH_INPUT && t._search() } )); var c = function() { var e = t.instance.element.querySelectorAll("[data-search-item-id]") , i = t.instance.element.querySelector('[data-selected="yes"]'); null == i && e.length > 0 ? e[0].setAttribute("data-selected", "yes") : e.length > 0 && i.nextSibling && i.nextSibling.setAttribute && (i.removeAttribute("data-selected"), i.nextSibling.setAttribute("data-selected", "yes")) } , m = function() { var e = t.instance.element.querySelectorAll("[data-search-item-id]") , i = t.instance.element.querySelector('[data-selected="yes"]'); null == i && e.length > 0 ? e[e.length - 1].setAttribute("data-selected", "yes") : e.length > 0 && i.previousSibling && i.previousSibling.setAttribute && (i.removeAttribute("data-selected"), i.previousSibling.setAttribute("data-selected", "yes")) } } , FamilyTree.searchUI.prototype._enterHandler = function() { var e = this.instance.element.querySelector('[data-selected="yes"]'); if (e) { if (e.hasAttribute("data-search-item-id")) { var t = e.getAttribute("data-search-item-id"); if (this.input.value != FamilyTree.SEARCH_HELP_SYMBOL) { var i = FamilyTree.events.publish("", [this.instance, t]) , r = FamilyTree.events.publish("searchclick", [this, { nodeId: t }]); !1 === i && (r = !1), 0 != r && this.instance.center(t) } else this.input.value = t + " ", this.searchTableWrapper.innerHTML = "" } } else this._searchAfterEnterPress = !0, this.__search(), this.searchTableWrapper.innerHTML = "", this.instance.draw() } , FamilyTree.searchUI.prototype._initSearchFields = function() { if (null == this.instance.config.searchFields) { this._searchFields = []; for (var e = 0; e < this.instance.response.allFields.length; e++) { var t = this.instance.response.allFields[e]; "tags" == t || FamilyTree._fieldIsImg(this.instance.config, t) || -1 == this._searchFields.indexOf(t) && this._searchFields.push(t) } } else this._searchFields = this.instance.config.searchFields; if (null == this.instance.config.searchFieldsAbbreviation) { this.searchFieldsAbbreviation = {}; for (e = 0; e < this._searchFields.length; e++) { for (var i = this._searchFields[e], r = 0, a = i.slice(0, r + 1).toLowerCase(); this.searchFieldsAbbreviation[a]; ) r++, a = i.slice(0, r + 1).toLowerCase(); this.searchFieldsAbbreviation[a] = i } } else this.searchFieldsAbbreviation = this.instance.config.searchFieldsAbbreviation; this._searchFieldsAbbreviation = this.searchFieldsAbbreviation } , FamilyTree.searchUI.prototype.find = function(e) { this.input && (this.input.value = e, document.activeElement == this.input ? this._search(e) : this.input.focus()) } , FamilyTree.searchUI.prototype.addMatchTag = function(e) { if (this._searchAfterEnterPress) { for (var t = 0; t < this.lastSearch.length; t++) if (this.lastSearch[t].id == e) return !0; return !1 } return null } , FamilyTree.searchUI.prototype.__search = function() { this.lastSearch = FamilyTree._search.search(this.instance.config.nodes, this.input.value, this._searchFields, this._searchFields, this.instance.config.searchDisplayField, this.instance.config.searchFieldsWeight, this.searchFieldsAbbreviation) } , FamilyTree.searchUI.prototype._search = function() { var e, t = this; if (this._searchAfterEnterPress = !1, this.input.value == FamilyTree.SEARCH_HELP_SYMBOL) e = this.helpView(); else { this.__search(); var i = FamilyTree._getFistImgField(this.instance.config); e = `\n \n ${function() { for (var e = "", r = 0; r < t.lastSearch.length && !(r >= FamilyTree.SEARCH_RESULT_LIMIT); r++) { var a = t.lastSearch[r] , n = ""; if (i) { var o = t.instance._get(a.id); "function" == typeof i ? n = i(t.instance, t.instance.getNode(a.id), o) : o[i] && (n = o[i]) } var l = "" , s = ""; t.instance.config.searchDisplayField == a.__searchField ? l = a.__searchMarks : t.instance.config.searchDisplayField ? (l = a[t.instance.config.searchDisplayField], FamilyTree.isNEU(l) && (l = ""), s = a.__searchMarks) : l = a.__searchMarks; var d = { img: n, nodeId: a.id, first: l, second: s, searchItem: a, html: FamilyTree.searchUI.createItem(n, a.id, l, s) }; FamilyTree.events.publish("add-item", [t, d]), e += d.html } return e }()} \n \n
` } this.searchTableWrapper.innerHTML = e; for (var r = this.instance.element.querySelectorAll("[data-search-item-id]"), a = 0; a < r.length; a++) r[a].addEventListener("click", (function() { if (this.hasAttribute("data-search-item-id")) { var e = this.getAttribute("data-search-item-id"); if (t.input.value != FamilyTree.SEARCH_HELP_SYMBOL) { var i = FamilyTree.events.publish("searchclick", [t.instance, e]) , r = FamilyTree.events.publish("searchclick", [t, { nodeId: e }]); if (!1 === i && (r = !1), !1 !== r) { t.instance.center(this.getAttribute("data-search-item-id")); var a = t.instance.element.querySelector('[data-selected="yes"]'); a && a.removeAttribute("data-selected"), this.setAttribute("data-selected", "yes"), t.input.focus() } } else t.input.value = e + " ", t.searchTableWrapper.innerHTML = "", t.input.focus() } } )); FamilyTree.events.publish("show-items", [this, {}]) } , FamilyTree.searchUI.prototype.helpView = function() { var e = ''; for (var t in this.searchFieldsAbbreviation) e += ``; return e += "
${t}${this.searchFieldsAbbreviation[t]}
" } , FamilyTree.searchUI.createItem = function(e, t, i, r) { return i && (i = "" + i + ""), `\n \n ${e = e ? `
` : `
${FamilyTree.icon.user(32, 32, "#aeaeae")}
`}\n \n ${i}
${r}\n ` } , FamilyTree.searchUI.prototype.hide = function() { if (!1 === FamilyTree.events.publish("hide", [this])) return !1; this._searchAfterEnterPress && (this._searchAfterEnterPress = !1, this.instance.draw()), this.lastSearch = [], this.xBtn && (this.xBtn.style.display = "none"), this.searchTableWrapper && (this.searchTableWrapper.innerHTML = ""), this.input && (this.input.value = "", document.activeElement == this.input && this.input.blur(), document.activeElement == this.xBtn && FamilyTree.input.blurHandler(this.input)) } , FamilyTree.searchUI.prototype.on = function(e, t) { return FamilyTree.events.on(e, t, this._event_id), this } , void 0 === FamilyTree && (FamilyTree = {}), FamilyTree.manager = function(e) { this.config = e.config, this.layoutConfigs = e._layoutConfigs, this.visibleNodeIds = [], this.viewBox = null, this.action = null, this.actionParams = null, this.nodes = {}, this.oldNodes = {}, this.maxX = null, this.maxY = null, this.minX = null, this.minY = null, this.bordersByRootIdAndLevel = null, this.roots = null, this.state = null, this.vbIsInitializedFromState = !1, this.rootList = [], this.instance = e, this._fixAdjustForExport = { x: 0, y: 0 } } , FamilyTree.manager.prototype.read = function(e, t, i, r, a, n, o, l) { var s = this; FamilyTree.state._get(this.config.state, t, i, (function(d) { s.state = d, s.action = a, s.actionParams = n, a != FamilyTree.action.init || !s.state || n && n.method && "fit" == n.method ? (s.viewBox = r, s.vbIsInitializedFromState = !1) : (s.viewBox = s.state.vb, s.vbIsInitializedFromState = !0, Array.isArray(s.state.roots) && (s.config.roots = s.state.roots)); var c = s.maxX , m = s.maxY , h = s.minX , p = s.minY , f = s.bordersByRootIdAndLevel , u = s.roots , y = s.nodes; if (e) { var g = FamilyTree.manager._getResponse(t, i, s.visibleNodeIds, s.config, c, m, h, p, s.viewBox, u, s.action, s.actionParams, y, s.oldNodes, s.vbIsInitializedFromState); a != FamilyTree.action.exporting && (s.maxX = c, s.maxY = m, s.minX = h, s.minY = p, s.roots = u, s.nodes = y, s.visibleNodeIds = g.visibleNodeIds), g.bordersByRootIdAndLevel = f, g.roots = u, g.adjustify = { x: 0, y: 0 }, s.state && (g.adjustify = s.state.adjustify), o(g) } else s.oldNodes = y || null, s._read((function(e) { c = e.maxX, m = e.maxY, h = e.minX, p = e.minY, f = e.bordersByRootIdAndLevel, u = e.roots, y = e.nodes; var r = FamilyTree.manager._getResponse(t, i, s.visibleNodeIds, s.config, c, m, h, p, s.viewBox, u, s.action, s.actionParams, y, s.oldNodes, s.vbIsInitializedFromState); r.notif = e.limit, r.roots = u, r.bordersByRootIdAndLevel = f, r.adjustify = e.adjustify, a != FamilyTree.action.exporting && (s.maxX = c, s.maxY = m, s.minX = h, s.minY = p, s.roots = u, s.nodes = y, s.visibleNodeIds = r.visibleNodeIds, s.bordersByRootIdAndLevel = f, s.rootList = e.rootList), o(r) } ), l) } )) } , FamilyTree.manager.prototype._read = function(e, t) { var i = this , r = FamilyTree.manager._createNodes(this.instance); t(r); var a = r.nodes , n = r.roots , o = FamilyTree.remote; null == o && (o = FamilyTree.local), o._setPositions(n, i.layoutConfigs, (function(t) { var o = FamilyTree.manager._doNotChangePositionOfClickedNodeIfAny(n, a, i.action, i.actionParams, i.oldNodes, i.config.orientation); i.state && i.action == FamilyTree.action.init && (o = i.state.adjustify), i.action == FamilyTree.action.exporting ? o = i._fixAdjustForExport : i._fixAdjustForExport = o; for (var l = { minX: null, minY: null, maxX: null, maxY: null }, s = {}, d = [], c = 0; c < n.length; c++) FamilyTree.manager._setMinMaxXYAdjustifyIterate(n[c], n[c], l, 0, s, o, i.config.orientation, d); for (var m in d) for (var h in d[m]) { var p = s[m][h] , f = d[m][h]; null == p.minX && null == p.minY && null == p.maxX && null == p.maxY && FamilyTree._setMinMaxXY(f, p) } e({ minX: l.minX, minY: l.minY, maxX: l.maxX, maxY: l.maxY, bordersByRootIdAndLevel: s, nodes: a, roots: n, rootList: r.rootList, limit: t, adjustify: o }) } ), a) } , void 0 === FamilyTree && (FamilyTree = {}), FamilyTree.manager._initDinamicNode = function(e, t, i) { t && (e.lcn = t), i && (e.isAssistant = !0); var r = FamilyTree.t(e.templateName); e.w = r && r.size ? r.size[0] : 0, e.h = r && r.size ? r.size[1] : 0, e.isSplit = "split" == e.templateName, e.isMirror = "mirror" == e.templateName, e.isSubLevel = "subLevel" == e.templateName } , FamilyTree.manager._setCollpasedProperty = function(e, t, i, r, a, n, o) { null == e.collapsed && t.collapse && t.collapse.allChildren ? e.collapsed = !0 : null == e.collapsed && (e.collapsed = !1), a == FamilyTree.action.expand && -1 != i.ids.indexOf(e.id) && (e.collapsed = !1), a == FamilyTree.action.collapse && (i.expandIds || i.collapseIds) ? i.expandIds && -1 != i.expandIds.indexOf(e.id) ? e.collapsed = !1 : i.collapseIds && -1 != i.collapseIds.indexOf(e.id) && (e.collapsed = !0) : a == FamilyTree.action.collapse && -1 != i.ids.indexOf(e.id) && (e.collapsed = !0), a == FamilyTree.action.expand && "all" == i.ids && (e.collapsed = !1), a == FamilyTree.action.exporting && i.expandChildren && (e.collapsed = !1), a == FamilyTree.action.init && null != o ? e.collapsed = !o.exp.has(e.id) : a == FamilyTree.action.init ? -1 != e.tags.indexOf("left-partner") || -1 != e.tags.indexOf("right-partner") || -1 != e.tags.indexOf("partner") || e.parentPartner ? e.collapsed = t.collapse && n >= t.collapse.level && -1 == r.indexOf(e.id) : e.collapsed = t.collapse && n >= t.collapse.level - 1 && -1 == r.indexOf(e.id) : a == FamilyTree.action.centerNode || a == FamilyTree.action.insert || a == FamilyTree.action.expand || a == FamilyTree.action.collapse ? r.has(e.id) && (e.collapsed = !1) : a == FamilyTree.action.update && i && i.changeRoots && i.changeRoots.has(e.id) && (e.collapsed = !1) } , FamilyTree.manager._initNode = function(e, t, i, r, a, n, o) { var l = o.manager.config , s = o.manager.layoutConfigs , d = o.manager.action , c = o.manager.actionParams , m = o.manager.state , h = s[i || "base"]; null == e.parent && FamilyTree.manager._setCollpasedProperty(e, h, c, a, d, r - 1, m); for (var p = 0; p < e.childrenIds.length; p++) { var f = t[e.childrenIds[p]]; if (FamilyTree.manager._setCollpasedProperty(f, h, c, a, d, r, m), !f.collapsed) { if (f.parent = e, null != f.ppid) { var u = t[f.ppid]; u && (f.parentPartner = u) } (-1 != f.tags.indexOf("left-partner") || -1 != f.tags.indexOf("right-partner") || -1 != f.tags.indexOf("partner") || f.parentPartner) && -1 == n.indexOf(e.id) && n.push(e.id), e.children.push(f) } } if (d != FamilyTree.action.minimize || e.min ? d == FamilyTree.action.maximize && !0 === e.min ? (c.all || c.id == e.id) && (e.min = !1) : d == FamilyTree.action.exporting && !1 === c.min ? e.min = !1 : d == FamilyTree.action.init && null != m && (e.min = m.min.has(e.id)) : (c.all || c.id == e.id) && (e.min = !0), !e.min) for (p = 0; p < e.stChildrenIds.length; p++) { f = t[e.stChildrenIds[p]]; e.tags && e.tags.has("filter") || (f.stParent = e, e.stChildren.push(f)) } null != r && (e.level = r), i && (e.lcn = i); var y = FamilyTree._getSubLevels(e.tags, l.tags); y > 0 && (e.subLevels = y), -1 != e.tags.indexOf("assistant") && null != e.parent && (e.isAssistant = !0); var g = FamilyTree.t(e.templateName, e.min); e.w = g && g.size ? g.size[0] : 0, e.h = g && g.size ? g.size[1] : 0, e.padding = g && g.padding ? g.padding : [0, 0, 0, 0]; var v = { node: e }; FamilyTree.events.publish("node-initialized", [o, v]) } , FamilyTree.manager._iterate = function(e, t, i, r, a, n, o, l, s, d, c, m) { var h = m.manager.layoutConfigs; if (FamilyTree.manager._initNode(t, i, s, r, d, c, m), t.isAssistant && (n[t.pid] || (n[t.pid] = []), n[t.pid].push(t.id)), t.subLevels > 0 && o.push(t.id), FamilyTree.MIXED_LAYOUT_FOR_NODES_WITH_COLLAPSED_CHILDREN && !t.isAssistant && t.parent) { if (t.parent && t.parent.children.length && t.parent.children[t.parent.children.length - 1] == t) { for (var p = [], f = 0, u = 0, y = 0; y < t.parent.children.length; y++) { -1 == (g = t.parent.children[y]).tags.indexOf("partner") && -1 == g.tags.indexOf("left-partner") && -1 == g.tags.indexOf("right-partner") && -1 == g.tags.indexOf("assistant") && 0 == g.children.length ? p.push(g.id) : -1 != g.tags.indexOf("assistant") ? f++ : -1 == g.tags.indexOf("partner") && -1 == g.tags.indexOf("left-partner") && -1 == g.tags.indexOf("right-partner") || u++ } (FamilyTree.MIXED_LAYOUT_ALL_NODES && p.length > 1 && p.length == t.parent.children.length - f - u || !FamilyTree.MIXED_LAYOUT_ALL_NODES && p.length > 1) && (l[t.pid] = p) } } else if (!t.isAssistant && 0 == t.childrenIds.length && t.parent && !l[t.pid]) { for (p = [], f = 0, u = 0, y = 0; y < t.parent.children.length; y++) { var g; -1 == (g = t.parent.children[y]).tags.indexOf("partner") && -1 == g.tags.indexOf("left-partner") && -1 == g.tags.indexOf("right-partner") && -1 == g.tags.indexOf("assistant") && 0 == g.childrenIds.length ? p.push(g.id) : -1 != g.tags.indexOf("assistant") ? f++ : -1 == g.tags.indexOf("partner") && -1 == g.tags.indexOf("left-partner") && -1 == g.tags.indexOf("right-partner") || u++ } (FamilyTree.MIXED_LAYOUT_ALL_NODES && p.length > FamilyTree.MIXED_LAYOUT_IF_NUMBER_OF_CHILDREN_IS_MORE_THEN && p.length == t.parent.childrenIds.length - f - u || !FamilyTree.MIXED_LAYOUT_ALL_NODES && p.length > FamilyTree.MIXED_LAYOUT_IF_NUMBER_OF_CHILDREN_IS_MORE_THEN) && (l[t.pid] = p) } t.stChildren.length && (e.stContainerNodes || (e.stContainerNodes = []), e.stContainerNodes.push(t)); for (var v = 0; v < t.stChildren.length; v++) { var T = ""; for (y = 0; y < t.tags.length; y++) if (h[t.tags[y]]) { T = t.tags[y]; break } a.push(t.stChildren[v].id), FamilyTree.manager._iterate(e, t.stChildren[v], i, 0, a, n, o, l, T, d, c, m) } r++; for (v = 0; v < t.children.length; v++) FamilyTree.manager._iterate(e, t.children[v], i, r, a, n, o, l, s, d, c, m) } , FamilyTree.manager.__createNodes = function(e, t, i, r, a, n, o, l) { for (var s = [], d = FamilyTree._addDottedLines(i), c = 0; c < d.length; c++) { var m, h = d[c]; m = FamilyTree.STRING_TAGS ? h.tags ? h.tags.split(",") : [] : Array.isArray(h.tags) ? h.tags.slice(0) : [], l.filterUI.addFilterTag(h) && m.unshift("filter"); var p = l.searchUI.addMatchTag(h.id); !0 === p ? m.unshift("match") : !1 === p && m.unshift("no-match"); var f = FamilyTree._getTemplate(m, i.tags, i.template) , u = new FamilyTree.node(h.id,h.pid,m,f); FamilyTree.isNEU(h.ppid) || (u.ppid = h.ppid), FamilyTree.isNEU(h.stpid) || (u.stpid = h.stpid), null != i.orderBy && (u.order = FamilyTree.manager._getOrderFieldValue(h, i.orderBy)), null != h.movex && (u.movex = h.movex), null != h.movey && (u.movey = h.movey), e[h.id] = u, s.push(h.id) } null != i.orderBy && s.sort((function(t, r) { var a = e[t].order , n = e[r].order; return "number" == typeof a || "number" == typeof n ? (null == a && (a = -1), null == n && (n = -1), i.orderBy.desc ? n - a : a - n) : "string" == typeof a || "string" == typeof n ? (null == a && (a = ""), null == n && (n = ""), i.orderBy.desc ? n.localeCompare(a) : a.localeCompare(n)) : void 0 } )); for (c = 0; c < s.length; c++) { var y = s[c] , g = (u = e[y], n ? n[y] : null) , v = e[u.stpid] , T = e[u.pid]; if (v || (u.stpid = null), T || (u.pid = null), v) { var b = n ? n[v.id] : null; b && (v.min = b.min), v.stChildrenIds.push(u.id) } else T ? (g && (u.collapsed = g.collapsed, u.min = g.min), T.childrenIds.push(u.id)) : (g && (u.collapsed = g.collapsed, u.min = g.min), t.push(u), o.push(u.id)); r == FamilyTree.action.init && (u.min = FamilyTree._getMin(u, i)) } } , FamilyTree.manager._createNodes = function(e) { var t = e.manager.config , i = e.manager.layoutConfigs , r = e.manager.action , a = e.manager.actionParams , n = e.manager.oldNodes , o = e.manager.state , l = {} , s = [] , d = []; if (FamilyTree.manager.__createNodes(l, s, t, r, a, n, d, e), null != t.roots) { s = []; for (var c = 0; c < t.roots.length; c++) { var m = l[t.roots[c]]; if (m && r == FamilyTree.action.centerNode) { for (var h = m; null != h.pid || null != h.stpid; ) h = null == h.pid && null != h.stpid ? l[h.stpid] : l[h.pid]; for (var p = l[a.id]; (null != p.pid || null != p.stpid) && p != m; ) p = null == p.pid && null != p.stpid ? l[p.stpid] : l[p.pid]; h == p && (m = h) } if (m) { for (var f = !1, u = 0; u < s.length; u++) if (s[u].id == m.id) { f = !0; break } if (!f) { if (!FamilyTree.isNEU(m.pid)) (ue = (v = l[m.pid]).childrenIds.indexOf(m.id)) > -1 && v.childrenIds.splice(ue, 1); s.push(m) } } } t.roots = []; for (c = 0; c < s.length; c++) t.roots.push(s[c].id) } r == FamilyTree.action.exporting && null != a.id && ((g = l[a.id]) && (g.pid = null, s = [g])); var y = []; if (r == FamilyTree.action.init && t.expand && t.expand.nodes && null == o) for (c = 0; c < t.expand.nodes.length; c++) { var g = l[t.expand.nodes[c]]; for (!0 === t.expand.allChildren && FamilyTree.manager._addExpandedNodeIdsIterate(g, l, y); g; ) y.push(g.id), null == g.pid && null != g.stpid ? (g = l[g.stpid]).min = !1 : g = l[g.pid] } else if (r == FamilyTree.action.expand && a.ids && "all" != a.ids || r == FamilyTree.action.collapse && a && a.expandIds) { re = r == FamilyTree.action.expand ? a.ids : a.expandIds; for (c = 0; c < re.length; c++) for (var v = l[(g = l[re[c]]).pid]; v; ) y.push(v.id), null == v.pid && null != v.stpid ? (v = l[v.stpid]).min = !1 : v = l[v.pid] } else if (r == FamilyTree.action.centerNode) { for (var T = l[a.id]; T; ) { if (y.push(T.id), a.options.parentState === FamilyTree.COLLAPSE_PARENT_NEIGHBORS && T) for (c = 0; c < T.childrenIds.length; c++) { (D = l[T.childrenIds[c]]).collapsed = !0 } null == T.pid && null != T.stpid ? (T = l[T.stpid]).min = !1 : T = l[T.pid] } T = l[a.id]; if (a.options.childrenState === FamilyTree.COLLAPSE_SUB_CHILDRENS) for (c = 0; c < T.childrenIds.length; c++) { (F = l[T.childrenIds[c]]).collapsed = !1; for (var b = 0; b < F.childrenIds.length; b++) { l[F.childrenIds[b]].collapsed = !0 } } if (a.options.parentState === FamilyTree.COLLAPSE_PARENT_SUB_CHILDREN_EXCEPT_CLICKED) if (v = l[T.pid]) for (c = 0; c < v.childrenIds.length; c++) { var F; if ((F = l[v.childrenIds[c]]) != T) { F.collapsed = !1; for (b = 0; b < F.childrenIds.length; b++) { l[F.childrenIds[b]].collapsed = !0 } } } } else if (r == FamilyTree.action.insert) for (g = l[a.insertedNodeId]; g; ) y.push(g.id), null == g.pid && null != g.stpid ? (g = l[g.stpid]).min = !1 : g = l[g.pid]; var x = [] , _ = {} , w = [] , k = {} , S = []; for (c = 0; c < s.length; c++) FamilyTree.manager._iterate(s[c], s[c], l, 0, x, _, w, k, "", y, S, e); if (r == FamilyTree.action.collapse && a && Array.isArray(a.expandIds) && Array.isArray(a.collapseIds)) for (c = 0; c < a.ids.length; c++) { if (a.expandIds.has(a.collapseIds[c])) console.error(`id ${a.collapseIds[c]} exist in both collapseIds and expandIds`); else (g = l[a.collapseIds[c]]) && (g.collapsed = !0) } for (c = s.length - 1; c >= 0; c--) s[c].collapsed && s.splice(c, 1); for (c = 0; c < S.length; c++) { g = l[S[c]]; var C = [] , I = [] , N = [] , A = {} , L = 0 , E = 0 , M = 0 , O = [] , U = []; for (b = 0; b < g.children.length; b++) { (D = g.children[b]).isAssistant ? C.push(D.id) : -1 != D.tags.indexOf("right-partner") ? (D.isPartner = 1, D.children = [], I.push(D.id)) : -1 != D.tags.indexOf("left-partner") ? (D.isPartner = 2, D.children = [], N.push(D.id)) : -1 == D.tags.indexOf("partner") || L % 2 ? -1 != D.tags.indexOf("partner") && L % 2 ? (D.isPartner = 2, D.children = [], N.push(D.id), L++) : D.parentPartner ? (A[D.parentPartner.id] || (A[D.parentPartner.id] = []), A[D.parentPartner.id].push(D.id)) : C.push(D.id) : (D.isPartner = 1, D.children = [], I.push(D.id), L++) } g.children = []; var B = []; for (b = 0; b < I.length; b++) { A[(D = l[I[b]]).id] ? g.children.push(D) : g.children.splice(0, 0, D); for (var R = 0; R < D.childrenIds.length; R++) B.push(D.childrenIds[R]) } var P = []; for (b = 0; b < N.length; b++) { A[(D = l[N[b]]).id] ? g.children.push(D) : g.children.splice(0, 0, D); for (R = 0; R < D.childrenIds.length; R++) P.push(D.childrenIds[R]) } for (b = 0; b < P.length; b++) { (D = l[P[b]]).collapsed || (D.parentPartner = D.parent, D.parent = g, D.isChildOfPartner = !0, g.children.push(D)) } for (b = N.length - 1; b >= 0; b--) if (A[N[b]]) for (u = 0; u < A[N[b]].length; u++) g.children.push(l[A[N[b]][u]]), E++, -1 == U.indexOf(N[b]) && U.push(N[b]); for (b = 0; b < C.length; b++) { var D = l[C[b]]; g.children.push(D) } for (b = 0; b < I.length; b++) if (A[I[b]]) for (u = 0; u < A[I[b]].length; u++) g.children.push(l[A[I[b]][u]]), M++, -1 == O.indexOf(I[b]) && O.push(I[b]); for (b = 0; b < B.length; b++) { (D = l[B[b]]).collapsed || (D.parentPartner = D.parent, D.parent = g, D.isChildOfPartner = !0, g.children.push(D)) } g.partnerSeparation = Math.max(U.length, O.length) * t.partnerChildrenSplitSeparation + t.minPartnerSeparation, C.length || !E || M ? C.length || E || !M ? C.length || 1 != E || 1 != M ? C.length || E || M ? !C.length || E || M ? C.length && (E || M) ? g.hasPartners = 7 : g.hasPartners = 1 : g.hasPartners = 6 : g.hasPartners = 5 : g.hasPartners = 4 : g.hasPartners = 3 : g.hasPartners = 2 } for (c = 0; c < w.length; c++) { var H = i[(g = l[w[c]]).lcn ? g.lcn : "base"]; for (b = 0; b < g.subLevels; b++) { var z = new FamilyTree.node(g.id + "_sub_level_index_" + b,g.pid,[],"subLevel"); if (FamilyTree.manager._initDinamicNode(z, g.lcn), v = g.parent) (ue = v.children.indexOf(g)) > -1 && (v.children.splice(ue, 1), v.children.splice(ue, 0, z)), z.children.push(g), z.parent = v, g.parent = z, l[z.id] = z } } for (var $ in _) { (v = l[$]).hasAssistants = !0; z = new FamilyTree.node(v.id + "_split_assitant_0",v.id,["assistant"],"split"); FamilyTree.manager._initDinamicNode(z, v.lcn, !0), l[z.id] = z; var j = []; for (b = v.children.length - 1; b >= 0; b--) { (D = v.children[b]).isAssistant ? (D.parent = null, v.children.splice(b, 1), j.splice(0, 0, D.id)) : D.isPartner || (D.parent && k[D.parent.id] && z && D.parent.id != z.id && (Object.defineProperty(k, z.id, Object.getOwnPropertyDescriptor(k, D.parent.id)), delete k[D.parent.id]), D.parent = z, z.children.unshift(D), v.children.splice(b, 1)) } if (j.length % 2) { var Y = l[j[j.length - 1]] , X = new FamilyTree.node(Y.id + "_mirror",v.pid,[],"mirror"); FamilyTree.manager._initDinamicNode(X, Y.lcn, !0), X.isAssistant = !0, X.w = Y.w, X.h = Y.h, l[X.id] = X, j.splice(j.length - 1, 0, X.id) } var q = 1; for (b = j.length - 1; b >= 0; b--) if (b % 2 && b != j.length - 1) { var V = new FamilyTree.node(v.id + "_split_assitant_" + q,v.pid,[],"split"); FamilyTree.manager._initDinamicNode(V, v.lcn, !0), l[V.id] = V, j.splice(b, 0, V.id), q++ } else b % 2 && j.splice(b, 0, z.id); for (b = 0; b < j.length; b += 3) { var G = null; G = 0 == b ? v : l[j[b - 2]]; var W = l[j[b]] , J = l[j[b + 1]] , K = l[j[b + 2]]; W.parent = G, J.parent = G, K.parent = G, G.children.push(W), G.children.push(J), G.children.push(K) } } var Z = !1; for (var Q in i) { if (0 != (H = i[Q]).layout) { Z = !0; break } } var ee = FamilyTree.events.has("node-layout", e._event_id); if (Z || ee) { var te = { nodes: l, config: t, action: r, actionParams: a }; if (w.length) { var ie = !1; for (var $ in k) { var re = k[$]; for (c = 0; c < re.length; c++) { if ((g = l[re[c]]).subLevels) { ie = !0; break } } if (ie) break } if (ie) { var ae = {} , ne = {} , oe = {}; for (var $ in k) { re = k[$]; var le = !1 , se = null; for (c = 0; c < re.length; c++) { var de = re[c]; (null === se || w.has(de)) && (se = l[de].parent.id, le || FamilyTree.isNEU(l[de].subLevels) || (le = l[de].subLevels > 0)), ae[se] || (ae[se] = []), ae[se].push(de), le && (oe[se] = $, ne[se] || (ne[se] = []), ne[se].push(de)) } } for (var $ in k = {}, ne) if (ne[$].length > FamilyTree.MIXED_LAYOUT_IF_NUMBER_OF_CHILDREN_IS_MORE_THEN) { var ce = oe[$]; for (c = l[ce].children.length - 1; c >= 0; c--) { D = l[ce].children[c]; ne[$].has(D.id) && l[ce].children.splice(c, 1) } } for (var $ in ae) ae[$].length > FamilyTree.MIXED_LAYOUT_IF_NUMBER_OF_CHILDREN_IS_MORE_THEN && (k[$] = ae[$]) } } for (var $ in k) { for (var me = v = l[$]; me.isSplit; ) me = l[me.pid]; for (; me.isSubLevel; ) me = l[me.pid]; if (0 != (H = i[v.lcn ? v.lcn : "base"]).layout || ee) { te.pnode = v, te.layout = H.layout, te.layoutGridColumns = t.layoutGridColumns, te.childrenIds = k[$], te.lastChildrenPidIds = k, te.subLevels = 0, te.layouts = [], FamilyTree.events.publish("node-layout", [e, te]), FamilyTree.events.publish("layout", [te]), te.layouts.length || te.layouts.push({ layout: te.layout, childrenIds: te.childrenIds, subLevels: te.subLevels, layoutGridColumns: te.layoutGridColumns }); for (var he = 0; he < te.layouts.length; he++) { var pe = te.layouts[he]; for (FamilyTree.isNEU(pe.subLevels) && (pe.subLevels = 0), FamilyTree.isNEU(pe.layout) && (pe.layout = H.layout), me = v = l[$]; me.isSplit; ) me = l[me.pid]; for (; me.isSubLevel; ) me = l[me.pid]; var fe = v; for (b = 0; b < pe.subLevels; b++) { z = new FamilyTree.node(he + "_sublevel_layout_" + b,fe.id,[],"subLevel"); FamilyTree.manager._initDinamicNode(z, fe.lcn), z.parent = fe, fe.children.push(z), l[z.id] = z, fe = z } if (pe.subLevels) { for (b = 0; b < pe.childrenIds.length; b++) { var ue; D = l[pe.childrenIds[b]]; -1 != (ue = v.children.indexOf(D)) && v.children.splice(ue, 1), D.parent = fe, fe.children.push(D) } v = fe } if (pe.layout == FamilyTree.layout.grid && pe.childrenIds.length > 2) { "dynamic" == pe.layoutGridColumns && (pe.layoutGridColumns = FamilyTree._getDynamicGridCoulumns(pe.childrenIds.length)); var ye = v.id; for (c = v.children.length - 1; c >= 0; c--) for (b = 0; b < pe.childrenIds.length; b++) { de = pe.childrenIds[b]; if (v.children[c].id == de) { v.children.splice(c, 1); break } } var ge = pe.layoutGridColumns; ge % 2 != 0 && ge > 2 && ge--; for (c = 0; c < pe.childrenIds.length; c += ge) { var ve = null; for (b = 0; b < ge; b++) { var Te = c + ge >= pe.childrenIds.length; if (pe.childrenIds.length - 1 < c + b) break; (D = l[de = pe.childrenIds[c + b]]).parent = l[ye], l[ye].children.push(D), Te || (ge / 2 - 1 == b && (ve = new FamilyTree.node(pe.childrenIds[c + b - 1] + "_grid_pseudo_node_" + pe.childrenIds[c + b + 1],ye,[],"subLevel"), FamilyTree.manager._initDinamicNode(ve, v.lcn), ve.parent = l[ye], l[ye].children.push(ve), l[ve.id] = ve), ge - 1 == b && (ye = ve.id)) } } } if (pe.layout == FamilyTree.layout.mixed) { var be = pe.childrenIds; for (c = be.length - 1; c >= 0; c--) { v = (D = l[be[c]]).parent, D.layout = FamilyTree.layout.mixed; for (b = v.children.length - 1; b >= 0; b--) if (D.id == v.children[b].id) { v.children.splice(b, 1); break } if (c > 0) { var Fe = l[be[c - 1]]; D.parent = Fe, D.layout = FamilyTree.layout.mixed, Fe.children.push(D) } else v.children.push(D) } } else if (pe.layout > 1) { z = new FamilyTree.node(he + "_" + v.id + "_split_0",me.id,[],"split"); FamilyTree.manager._initDinamicNode(z, v.lcn), l[z.id] = z, z.layout = pe.layout; var xe = []; for (c = pe.childrenIds.length - 1; c >= 0; c--) { for (D = l[pe.childrenIds[c]], b = 0; b < v.children.length; b++) v.children[b].id == D.id && v.children.splice(b, 1); if (D.parent = null, D.layout = pe.layout, pe.layout != FamilyTree.layout.treeRightOffset && pe.layout != FamilyTree.layout.treeRight || xe.splice(0, 0, D.id), pe.layout > 2) { var _e = new FamilyTree.node(he + "_" + D.id + "_mirror",me.id,[],"mirror"); FamilyTree.manager._initDinamicNode(_e, D.lcn), _e.layout = pe.layout, l[_e.id] = _e, xe.splice(0, 0, _e.id) } pe.layout != FamilyTree.layout.treeRightOffset && pe.layout != FamilyTree.layout.treeRight && xe.splice(0, 0, D.id) } for (q = 1, b = xe.length - 1; b >= 0; b--) if (b % 2 && b != xe.length - 1) { V = new FamilyTree.node(he + "_" + v.id + "_split_" + q,me.id,[],"split"); FamilyTree.manager._initDinamicNode(V, v.lcn), V.layout = pe.layout, l[V.id] = V, xe.splice(b, 0, V.id), q++ } else b % 2 && xe.splice(b, 0, z.id); for (b = 0; b < xe.length; b += 3) { G = null; 0 == b && (G = v); W = l[xe[b]], J = l[xe[b + 1]], K = l[xe[b + 2]]; 0 != b && (G = l[xe[b - 3]]), 0 == b || J || (G = l[xe[b - 2]]), W.parent = G, G.children.push(W), J && (0 != b && (G = l[xe[b - 2]]), J.parent = G, G.children.push(J)), K && (0 != b && (G = l[xe[b - 1]]), K.parent = G, G.children.push(K)) } } } } } } if (FamilyTree.VERTICAL_CHILDREN_ASSISTANT) for (c = 0; c < s.length; c++) FamilyTree.manager._verticalAssistantIterate(s[c], l); te = { nodes: l, roots: s }; return FamilyTree.events.publish("nodes-initialized", [e, te]), { nodes: te.nodes, roots: te.roots, rootList: d } } , FamilyTree.manager._getOrderFieldValue = function(e, t) { var i = t; return t.field && (i = t.field), e[i] } , FamilyTree.manager._getNodeWidth = function(e, t) { switch (t.orientation) { case FamilyTree.orientation.top: case FamilyTree.orientation.top_left: case FamilyTree.orientation.bottom: case FamilyTree.orientation.bottom_left: return e.w; case FamilyTree.orientation.right: case FamilyTree.orientation.right_top: case FamilyTree.orientation.left: case FamilyTree.orientation.left_top: return e.h } return 0 } , FamilyTree.manager._isVisible = function(e, t, i, r) { if (null != e.x && null != e.y) { if (t.lazyLoading && r !== FamilyTree.action.exporting) { function a(e, t) { var i = e.x , r = e.y , a = e.w , n = e.h , o = t[0] - FamilyTree.LAZY_LOADING_FACTOR , l = t[2] + FamilyTree.LAZY_LOADING_FACTOR + t[0] , s = t[1] - FamilyTree.LAZY_LOADING_FACTOR , d = t[3] + FamilyTree.LAZY_LOADING_FACTOR + t[1] , c = i + a > o && l > i; return c && (c = r + n > s && d > r), c } if (a(e, i)) return !0; for (var n = 0; n < e.children.length; n++) if (a(e.children[n], i)) return !0; return !1 } return !0 } } , FamilyTree.manager.getAllFields = function(e) { var t = [FamilyTree.TAGS]; for (var i in e.nodeBinding) t.push(e.nodeBinding[i]); for (i = 0; i < e.nodes.length; i++) for (var r in e.nodes[i]) r !== FamilyTree.ID && r !== FamilyTree.TAGS && r !== FamilyTree.NODES && r !== FamilyTree.PID && r !== FamilyTree.STPID && "movex" !== r && "movey" !== r && (e.nodeBinding[r] || t.has(r) || t.push(r)); return t } , FamilyTree.manager._getMostDeepChild = function(e) { if (e) { var t = e; return function e(i) { i.sl > t.sl && (t = i); for (var r = 0; r < i.children.length; r++) e(i.children[r]) }(e), t } } , FamilyTree.manager._getResponse = function(e, t, i, r, a, n, o, l, s, d, c, m, h, p, f) { var u = d[0] , y = [] , g = { top: null, left: null, bottom: null, right: null, minX: null, maxX: null, minY: null, maxY: null } , v = [[], [], []] , T = a - o + 2 * r.padding , b = n - l + 2 * r.padding , F = FamilyTree.getScale(s, e, t, r.scaleInitial, r.scaleMax, r.scaleMin, T, b); if (g.top = l - r.padding, g.left = o - r.padding, g.bottom = n + r.padding - t / F, g.right = a + r.padding - e / F, g.maxX = a, g.minX = o, g.maxY = n, g.minY = l, 0 == d.length || null == s && !f && r.align == FamilyTree.CENTER) { var x = Math.ceil(e / F) , _ = Math.ceil(t / F) , w = 0 , k = 0; if (x - 2 * r.padding >= a - o) switch (w = (a + o) / 2 - x / 2, r.orientation) { case FamilyTree.orientation.right: case FamilyTree.orientation.right_top: w = (o - a) / 2 - x / 2 } else switch (w = u.x - x / 2 + FamilyTree.manager._getNodeWidth(u, r) / 2, r.orientation) { case FamilyTree.orientation.right: case FamilyTree.orientation.right_top: (w = -(x / 2 - (o - a) / 2)) < r.padding - x && (w = r.padding - x); break; case FamilyTree.orientation.left: case FamilyTree.orientation.bottom_left: case FamilyTree.orientation.top_left: case FamilyTree.orientation.left_top: (w = -(x / 2 - (a - o) / 2)) > -r.padding && (w = -r.padding) } if (_ - 2 * r.padding >= n - l) switch (k = (n + l) / 2 - _ / 2, r.orientation) { case FamilyTree.orientation.bottom: case FamilyTree.orientation.bottom_left: k = (l - n) / 2 - _ / 2 } else switch ((k = -(_ / 2 - (n - l) / 2)) > -r.padding && (k = -r.padding), r.orientation) { case FamilyTree.orientation.bottom: case FamilyTree.orientation.bottom_left: (k = -(_ / 2 - (l - n) / 2)) < r.padding - _ && (k = r.padding - _); break; case FamilyTree.orientation.left: case FamilyTree.orientation.right: k = u.y - _ / 2 + FamilyTree.manager._getNodeWidth(u, r) / 2 } s = [w, k, x, _] } else if (null == s && !f && r.align == FamilyTree.ORIENTATION) { x = Math.ceil(e / F), _ = Math.ceil(t / F), w = 0, k = 0; switch (r.orientation) { case FamilyTree.orientation.top: w = u.x - x / 2 + FamilyTree.manager._getNodeWidth(u, r) / 2, k = -r.padding; break; case FamilyTree.orientation.bottom: w = u.x - x / 2 + FamilyTree.manager._getNodeWidth(u, r) / 2, k = r.padding - _; break; case FamilyTree.orientation.left: w = -r.padding, k = u.y - _ / 2 + FamilyTree.manager._getNodeWidth(u, r) / 2; break; case FamilyTree.orientation.right: w = r.padding - x, k = u.y - _ / 2 + FamilyTree.manager._getNodeWidth(u, r) / 2; break; case FamilyTree.orientation.top_left: w = -r.padding, k = -r.padding; break; case FamilyTree.orientation.right_top: w = r.padding - x, k = -r.padding; break; case FamilyTree.orientation.left_top: w = -r.padding, k = -r.padding; break; case FamilyTree.orientation.bottom_left: w = -r.padding, k = r.padding - _ } s = [w, k, x, _], r.sticky && (s[0] < g.left && s[0] < g.right && (s[0] = g.left > g.right ? g.right : g.left), s[0] > g.right && s[0] > g.left && (s[0] = g.left > g.right ? g.left : g.right), s[1] < g.top && s[1] < g.bottom && (s[1] = g.top > g.bottom ? g.bottom : g.top), s[1] > g.bottom && s[1] > g.top && (s[1] = g.top > g.bottom ? g.top : g.bottom)) } if (c == FamilyTree.action.centerNode || c == FamilyTree.action.maximize) { var S = h[m.id]; 1 == m.options.horizontal && (s[0] = S.x + S.w / 2 - s[2] / 2), 1 == m.options.vertical && (s[1] = S.y + S.h / 2 - s[3] / 2), r.sticky && (s[0] < g.left && s[0] < g.right && (s[0] = g.left > g.right ? g.right : g.left), s[0] > g.right && s[0] > g.left && (s[0] = g.left > g.right ? g.left : g.right), s[1] < g.top && s[1] < g.bottom && (s[1] = g.top > g.bottom ? g.bottom : g.top), s[1] > g.bottom && s[1] > g.top && (s[1] = g.top > g.bottom ? g.top : g.bottom)) } if (c == FamilyTree.action.insert || c == FamilyTree.action.expand || c == FamilyTree.action.collapse || c == FamilyTree.action.update || c == FamilyTree.action.centerNode) { var C = null; if (c == FamilyTree.action.insert && m && null != m.insertedNodeId && null != m.insertedNodeId) C = h[m.insertedNodeId]; else if (c == FamilyTree.action.update && m && null != m.visId && null != m.visId) C = h[m.visId]; else if (c != FamilyTree.action.expand && c != FamilyTree.action.collapse || !m || null == m.id || null == m.id) { if (c == FamilyTree.action.centerNode) { switch (r.orientation) { case FamilyTree.orientation.top: case FamilyTree.orientation.top_left: case FamilyTree.orientation.bottom: case FamilyTree.orientation.bottom_left: m.options.vertical || (C = h[m.id]); break; case FamilyTree.orientation.right: case FamilyTree.orientation.right_top: case FamilyTree.orientation.left: case FamilyTree.orientation.left_top: m.options.horizontal || (C = h[m.id]) } C && (C = FamilyTree.manager._getMostDeepChild(C, h)) } } else C = h[m.id], C = FamilyTree.manager._getMostDeepChild(C, h); if (!FamilyTree.FIXED_POSITION_ON_CLICK && C) switch (r.orientation) { case FamilyTree.orientation.top: case FamilyTree.orientation.top_left: var I = C.y + C.h - s[3] + r.padding; s[1] < I && (s[1] = I); break; case FamilyTree.orientation.bottom: case FamilyTree.orientation.bottom_left: I = C.y - r.padding; s[1] > I && (s[1] = I); break; case FamilyTree.orientation.right: case FamilyTree.orientation.right_top: I = C.x - r.padding; s[0] > I && (s[0] = I); break; case FamilyTree.orientation.left: case FamilyTree.orientation.left_top: I = C.x + C.w - s[2] + r.padding; s[0] < I && (s[0] = I) } } for (var N = 0; N < d.length; N++) FamilyTree.manager._iterate2(d[N], h, r, s, c, m, y, p, i, v); return { animations: v, boundary: g, viewBox: s, visibleNodeIds: y, nodes: h, allFields: FamilyTree.manager.getAllFields(r) } } , FamilyTree.manager._iterate2 = function(e, t, i, r, a, n, o, l, s, d) { if (FamilyTree.manager._isVisible(e, i, r, a)) { o.push(e.id); var c = null; if ((a == FamilyTree.action.expand || a == FamilyTree.action.collapse || a == FamilyTree.action.maximize) && l && l[e.id] && "expandCollapseToLevel" == n.method) { if (c = { x: (f = l[e.id]).x, y: f.y }, f) { c = { x: f.x, y: f.y }; for (var m = e, h = null; null != m; ) l[m.id] && l[m.id].collapsed && (h = m), m = m.parent; h && h.parent && (c = { x: h.parent.x, y: h.parent.y }) } if (u = t[n.id]) { for (m = e.parent; null != m; ) m = m.parent; m && (c = { x: u.x + u.w / 2 - e.w / 2, y: u.y + u.h / 2 - e.h / 2 }) } } else if ((a == FamilyTree.action.expand || a == FamilyTree.action.collapse) && l && l[e.id]) { if (c = { x: (f = l[e.id]).x, y: f.y }, "all" == n.ids && f) { c = { x: f.x, y: f.y }; for (m = e, h = null; null != m; ) l[m.id] && l[m.id].collapsed && (h = m), m = m.parent; h && h.parent && (c = { x: h.parent.x, y: h.parent.y }) } if (u = t[n.id]) { for (m = e.parent; null != m && -1 == n.ids.indexOf(e.id) && -1 == n.ids.indexOf(m.id); ) m = m.parent; m && (c = { x: u.x + u.w / 2 - e.w / 2, y: u.y + u.h / 2 - e.h / 2 }) } } else if (a == FamilyTree.action.centerNode && l && l[e.id]) { if (null != (f = l[e.id]).x && null != f.y && (c = { x: f.x, y: f.y }), (p = t[n.id]) && p == e) (m = e.parent) && m.id == n.id && (c = { x: p.x + p.w / 2 - e.w / 2, y: p.y + p.h / 2 - e.h / 2 }) } else if (a == FamilyTree.action.maximize && l && l[e.id]) { var p; if (null != (f = l[e.id]).x && null != f.y && (c = { x: f.x, y: f.y }), (p = t[n.id]) && p == e) (m = e.parent) && m.id == n.id && (c = { x: p.x + p.w / 2 - e.w / 2, y: p.y + p.h / 2 - e.h / 2 }) } else if (a == FamilyTree.action.minimize && l && l[e.id]) { c = { x: (f = l[e.id]).x, y: f.y } } else if (a == FamilyTree.action.insert && n && n.insertedNodeId == e.id && e.parent) c = { x: e.parent.x, y: e.parent.y }; else if (a != FamilyTree.action.update && a != FamilyTree.action.insert || !l) a !== FamilyTree.action.exporting && a !== FamilyTree.action.init && -1 == s.indexOf(e.id) && (d[0].push(e.id), d[1].push({ opacity: 0 }), d[2].push({ opacity: 1 })); else { var f, u; if ((!(f = l[e.id]) || FamilyTree.isNEU(f.x) && FamilyTree.isNEU(f.y)) && n) { if (u = t[n.id]) { for (m = u; m && m.id == e.id; ) m = m.parent; m && (c = { x: u.x, y: u.y }) } } else f && (c = { x: f.x, y: f.y }) } if (null != c && null != c.x && null != c.y) if (c.x != e.x || c.y != e.y) n && n.dragNodeIdList && -1 != n.dragNodeIdList.indexOf(e.id) || (d[0].push(e.id), d[1].push({ transform: [1, 0, 0, 1, c.x, c.y] }), d[2].push({ transform: [1, 0, 0, 1, e.x, e.y] })) } for (var y = 0; y < e.stChildren.length; y++) FamilyTree.manager._iterate2(e.stChildren[y], t, i, r, a, n, o, l, s, d); for (y = 0; y < e.children.length; y++) FamilyTree.manager._iterate2(e.children[y], t, i, r, a, n, o, l, s, d) } , FamilyTree.manager._addExpandedNodeIdsIterate = function(e, t, i) { for (var r = 0; r < e.childrenIds.length; r++) i.push(e.childrenIds[r]), FamilyTree.manager._addExpandedNodeIdsIterate(t[e.childrenIds[r]], t, i) } , FamilyTree.manager._setMinMaxXYAdjustifyIterate = function(e, t, i, r, a, n, o, l) { e.x += n.x, e.y += n.y; for (var s = 0; s < e.stChildren.length; s++) FamilyTree.manager._setMinMaxXYAdjustifyIterate(e.stChildren[s], e.stChildren[s], i, 0, a, n, o, l); e.isPartner ? e.sl = r - 1 : e.sl = r, null == a[t.id] && (a[t.id] = {}), null == a[t.id][e.sl] && (a[t.id][e.sl] = { minX: null, minY: null, maxX: null, maxY: null }), e.layout ? (null == l[t.id] && (l[t.id] = {}), null == l[t.id][e.sl] && (l[t.id][e.sl] = e)) : FamilyTree._setMinMaxXY(e, a[t.id][e.sl]), null != e.movex && (e.x += e.movex), null != e.movey && (e.y += e.movey), FamilyTree._setMinMaxXY(e, i), r++; for (s = 0; s < e.children.length; s++) FamilyTree.manager._setMinMaxXYAdjustifyIterate(e.children[s], t, i, r, a, n, o, l) } , FamilyTree.manager._doNotChangePositionOfClickedNodeIfAny = function(e, t, i, r, a, n) { if (i != FamilyTree.action.expand && i != FamilyTree.action.collapse && i != FamilyTree.action.minimize && i != FamilyTree.action.maximize && i != FamilyTree.action.centerNode && i != FamilyTree.action.update && i != FamilyTree.action.insert) return { x: 0, y: 0 }; if (i == FamilyTree.action.update && (!r || null == r.id)) { if (!e || !e.length) return { x: 0, y: 0 }; r = { id: e[0].id } } if (null == r.id) return { x: 0, y: 0 }; var o = r.id; (i == FamilyTree.action.minimize && t[o].parent || i == FamilyTree.action.maximize && t[o].parent) && (o = t[o].pid); var l = t[o] , s = a[o]; if (!s) return { x: 0, y: 0 }; var d = null != s.movex ? s.movex : 0 , c = null != s.movey ? s.movey : 0; return { x: (s.x ? s.x - d : 0) - l.x, y: (s.y ? s.y - c : 0) - l.y } } , FamilyTree.manager._verticalAssistantIterate = function(e, t) { for (var i = 0; i < e.stChildren.length; i++) FamilyTree.manager._verticalAssistantIterate(e.stChildren[i], t); if (3 == e.children.length) FamilyTree.manager._verticalAssistantIterate(e.children[0], t), FamilyTree.manager._verticalAssistantIterate(e.children[2], t), FamilyTree.manager._verticalAssistantIterate(e.children[1], t); else for (i = 0; i < e.children.length; i++) FamilyTree.manager._verticalAssistantIterate(e.children[i], t); if (e.isAssistant && e.isSplit && e.children.length) { for (var r = e.parent.children[0], a = e.parent.children[2], n = e.parent; !n.hasAssistants; ) n = n.parent; var o = { max: 0 } , l = { max: 0 }; FamilyTree.manager._verticalAssistantLevelCountIterate(r, 0, o), FamilyTree.manager._verticalAssistantLevelCountIterate(a, 0, l); var s = Math.max(o.max, l.max) , d = []; for (i = 0; i < s; i++) { var c = new FamilyTree.node(e.parent.id + "_split_assitant_level_" + i,e.pid,[],"subLevel"); FamilyTree.manager._initDinamicNode(c, e.lcn, !0), i > 0 && (d[i - 1].children.push(c), c.parent = d[i - 1]), t[c.id] = c, d.push(c) } if (d.length) { for (var m = d[d.length - 1], h = d[0], p = e.children.length - 1; p >= 0; p--) { var f = e.children[p]; m.children.unshift(f), f.parent = m, e.children.splice(p, 1) } e.children.push(h), h.parent = e } } } , FamilyTree.manager._verticalAssistantLevelCountIterate = function(e, t, i) { i.max < t && (i.max = t), t++; for (var r = 0; r < e.children.length; r++) FamilyTree.manager._verticalAssistantLevelCountIterate(e.children[r], t, i) } , FamilyTree._addDottedLines = function(e) { var t = e.nodes; if ((e.groupDottedLines.length || e.dottedLines.length) && (t = JSON.parse(JSON.stringify(t))), e.groupDottedLines.length) for (var i = [], r = 0; r < e.groupDottedLines.length; r++) { var a = e.groupDottedLines[r]; null == a.rootId && (a.rootId = a.to); var n = `balkan_group_dotted_${a.rootId}`; if (!i.has(n)) for (var o = 0; o < t.length; o++) if (t[o].id == a.rootId) { (c = JSON.parse(JSON.stringify(t[o]))).id = `balkan_group_dotted_${a.rootId}_balkan_id_${t[o].id}`, c.pid = void 0, c.stpid = t[o].id, t.push(c), i.push(n), t[o].tags || (t[o].tags = []), t[o].tags.push("group-dotted-lines"), t[o].tags.push("group-dotted-lines-" + n); break } for (o = 0; o < t.length; o++) if (t[o].id == a.from) { if ((c = JSON.parse(JSON.stringify(t[o]))).id = `balkan_group_dotted_${a.rootId}_balkan_id_${t[o].id}`, c.pid = `balkan_group_dotted_${a.rootId}_balkan_id_${a.to}`, c.tags) { var l = c.tags.indexOf("group-dotted-lines"); -1 != l && c.tags.splice(l, 1) } if (c.tags || (c.tags = []), c.tags.push("bft-dotted-connector"), a.tags) for (var s = 0; s < a.tags.length; s++) c.tags.push(a.tags[s]); t.push(c); break } } if (e.dottedLines.length) for (r = 0; r < e.dottedLines.length; r++) { var d = e.dottedLines[r]; null == d.rootId && (d.rootId = d.to); for (o = 0; o < t.length; o++) if (t[o].id == d.from) { var c; if ((c = JSON.parse(JSON.stringify(t[o]))).id = `balkan_dotted_${d.rootId}_balkan_id_${t[o].id}`, d.rootId == d.to ? c.pid = d.to : c.pid = `balkan_dotted_${d.rootId}_balkan_id_${d.to}`, c.tags || (c.tags = []), c.tags.push("bft-dotted-connector"), d.tags) for (s = 0; s < d.tags.length; s++) c.tags.push(d.tags[s]); t.push(c); break } } return t } , FamilyTree.manager.__createNodes = function(e, t, i, r, a, n, o, l) { for (var s = i.nodes, d = [], c = {}, m = {}, h = 0; h < s.length; h++) { var p, f = s[h]; p = FamilyTree.STRING_TAGS ? f.tags ? f.tags.split(",") : [] : Array.isArray(f.tags) ? f.tags.slice(0) : [], l.filterUI.addFilterTag(f) && p.push("filter"); var u = l.searchUI.addMatchTag(f.id); !0 === u ? p.unshift("match") : !1 === u && p.unshift("no-match"), f.gender && p.push(f.gender); var y = FamilyTree._getTemplate(p, i.tags, i.template); f.templateName && (y = f.templateName); var g = new FamilyTree.node(f.id,f.pid,p,y); g.ftChildrenIds = [], g.rids = [], FamilyTree.isNEU(f.ppid) || (g.ppid = f.ppid), FamilyTree.isNEU(f.stpid) || (g.stpid = f.stpid), FamilyTree.isNEU(f.mid) || (g.mid = f.mid), FamilyTree.isNEU(f.fid) || (g.fid = f.fid), FamilyTree.isNEU(f.gender) || (g.gender = f.gender), Array.isArray(f.pids) ? g.pids = f.pids : g.pids = [], null != i.orderBy && (g.order = FamilyTree.manager._getOrderFieldValue(f, i.orderBy)), e[f.id] = g, FamilyTree.isNEU(g.stpid) ? (FamilyTree.isNEU(g.mid) || (c[g.mid] || (c[g.mid] = []), c[g.mid].push(g.id)), FamilyTree.isNEU(g.fid) || (c[g.fid] || (c[g.fid] = []), c[g.fid].push(g.id)), FamilyTree.isNEU(g.mid) && FamilyTree.isNEU(g.fid) && FamilyTree.isNEU(g.stpid) && (d.has(g.id) || d.push(g.id))) : (m[g.stpid] || (m[g.stpid] = []), m[g.stpid].push(g.id)) } if (null != i.orderBy && c) for (var v in c) c[v].sort((function(t, r) { var a = e[t].order , n = e[r].order; return "number" == typeof a || "number" == typeof n ? (null == a && (a = -1), null == n && (n = -1), i.orderBy.desc ? n - a : a - n) : "string" == typeof a || "string" == typeof n ? (null == a && (a = ""), null == n && (n = ""), i.orderBy.desc ? n.localeCompare(a) : a.localeCompare(n)) : void 0 } )); for (h = 0; h < d.length; h++) { var T = e[d[h]]; if (T) { var b = []; FamilyTree.manager._iterateSetRootIds(T.id, T.id, m, c, e, b), o.push(b) } } for (h = 0; h < o.length; h++) for (var F = 0; F < o.length; F++) if (F != h) { for (var x = o[h], _ = o[F], w = !1, k = 0; k < x.length; k++) if (_.has(x[k])) { w = !0; break } w && (o[h] = x.concat(_).unique(), o[F] = []) } for (h = o.length - 1; h >= 0; h--) o[h].length || o.splice(h, 1); if (!i.roots || !i.roots.length) { i.roots = []; for (h = o.length - 1; h >= 0; h--) i.roots.push(o[h][0]) } for (h = 0; h < i.roots.length; h++) FamilyTree.manager._iterateFT(i.roots[h], m, c, e, n, t, r, a, i) } , FamilyTree.manager._iterateSetRootIds = function(e, t, i, r, a, n) { var o = a[e]; if (o) { o.rids.has(t) || o.rids.push(t); for (var l = 0; l < o.rids.length; l++) n.has(o.rids[l]) || n.push(o.rids[l]); for (l = 0; l < o.pids.length; l++) { var s = a[o.pids[l]]; if (s) for (var d = 0; d < s.rids.length; d++) n.has(s.rids[d]) || n.push(s.rids[d]) } if (i[o.id]) for (l = 0; l < i[o.id].length; l++) FamilyTree.manager._iterateSetRootIds(i[o.id][l], t, i, r, a, n); if (r[o.id]) for (l = 0; l < r[o.id].length; l++) FamilyTree.manager._iterateSetRootIds(r[o.id][l], t, i, r, a, n) } } , FamilyTree.manager._iterateFT = function(e, t, i, r, a, n, o, l, s) { var d, c = r[e], m = a ? a[e] : null, h = r[c.stpid], p = r[c.mid], f = r[c.fid]; if (h || (c.stpid = null), p ? f && (p.tags.has("partner") || p.tags.has("left-partner") || p.tags.has("right-partner")) ? (c.pid = f.id, d = f, c.ppid = p.id) : (c.pid = p.id, d = p, f && (c.ppid = f.id)) : f ? p && (f.tags.has("partner") || f.tags.has("left-partner") || f.tags.has("right-partner")) ? (c.pid = p.id, d = p, c.ppid = f.id) : (c.pid = f.id, d = f, p && (c.ppid = p.id)) : c.pid, h) { var u = a ? a[h.id] : null; u && (h.min = u.min), h.stChildrenIds.push(c.id) } else p || f ? (m && (c.collapsed = m.collapsed, c.min = m.min), d && !d.childrenIds.has(c.id) && d.childrenIds.push(c.id), p && !p.ftChildrenIds.has(c.id) && p.ftChildrenIds.push(c.id), f && !f.ftChildrenIds.has(c.id) && f.ftChildrenIds.push(c.id)) : (m && (c.collapsed = m.collapsed, c.min = m.min), n.push(c)); o == FamilyTree.action.init && (c.min = FamilyTree._getMin(c, s)); for (var y = 0; y < c.pids.length; y++) { var g = r[c.pids[y]]; if (g) { g.pid = c.id; var v = a ? a[g.id] : null; if (v && (g.collapsed = v.collapsed, g.min = v.min), o == FamilyTree.action.init && (g.min = FamilyTree._getMin(g, s)), l && m && v && l.id == c.id ? v.hasPartners && 1 == m.isPartner ? g.tags.push("left-partner") : v.hasPartners && 2 == m.isPartner || 1 == m.isPartner ? g.tags.push("right-partner") : 2 == m.isPartner ? g.tags.push("left-partner") : g.tags.push("partner") : v && 2 == v.isPartner ? g.tags.push("left-partner") : v && 1 == v.isPartner ? g.tags.push("right-partner") : g.tags.push("partner"), !FamilyTree.isNEU(g) && i[g.id]) for (var T = 0; T < i[g.id].length; T++) { var b = r[i[g.id][T]]; b && (FamilyTree.isNEU(b.fid) || FamilyTree.isNEU(b.mid)) && FamilyTree.manager._iterateFT(i[g.id][T], t, i, r, a, n, o, l, s) } c.childrenIds.push(g.id) } } if (t[e]) for (T = 0; T < t[e].length; T++) FamilyTree.manager._iterateFT(t[e][T], t, i, r, a, n, o, l, s); if (i[e]) for (T = 0; T < i[e].length; T++) FamilyTree.manager._iterateFT(i[e][T], t, i, r, a, n, o, l, s) } , FamilyTree.manager.getAllFields = function(e) { var t = [FamilyTree.TAGS]; for (var i in e.nodeBinding) t.push(e.nodeBinding[i]); for (i = 0; i < e.nodes.length; i++) for (var r in e.nodes[i]) r !== FamilyTree.ID && r !== FamilyTree.TAGS && r !== FamilyTree.NODES && r !== FamilyTree.PID && r !== FamilyTree.STPID && "mid" !== r && "fid" !== r && "pids" !== r && (e.nodeBinding[r] || t.has(r) || t.push(r)); return t } , FamilyTree.templates = {}, FamilyTree.templates.base = { defs: `\n \n \n \n ${FamilyTree.icon.addUser(25, 25, "#fff", 0, 0)}\n \n \n \n ${FamilyTree.icon.close(25, 25, "#fff", 0, 0)}\n \n \n \n ${FamilyTree.icon.ft(20, 20, "#aeaeae", 5, 5)}\n \n `, size: [250, 120], linkAdjuster: { fromX: 0, fromY: 0, toX: 0, toY: 0 }, ripple: { radius: 0, color: "#e6e6e6", rect: null }, expandCollapseSize: 0, svg: '{content}', link: '', assistanseLink: '', pointer: '', node: '', menuButton: '



', padding: [50, 20, 35, 20], nodeMenuButton: ``, nodeTreeMenuButton: '', nodeTreeMenuCloseButton: '', up: '', img_0: '', link_field_0: '{val}' }, FamilyTree.templates.dot = Object.assign({}, FamilyTree.templates.base), FamilyTree.templates.dot.node = '', FamilyTree.templates.dot.size = [10, 10], FamilyTree.templates.dot.nodeMenuButton = "", FamilyTree.templates.dot.nodeTreeMenuButton = "", FamilyTree.templates.dot.nodeTreeMenuCloseButton = "", FamilyTree.templates.dot.up = "", FamilyTree.templates.john = Object.assign({}, FamilyTree.templates.base), FamilyTree.templates.john.nodeMenuButton = ``, FamilyTree.templates.john.defs = `\n \n ${FamilyTree.gradientCircleForDefs("circle", "#aeaeae", 60, 5)}\n ${FamilyTree.gradientCircleForDefs("male_circle", "#039BE5", 60, 5)}\n ${FamilyTree.gradientCircleForDefs("female_circle", "#F57C00", 60, 5)}`, FamilyTree.templates.john.field_0 = "{val}', FamilyTree.templates.john.field_1 = "{val}', FamilyTree.templates.john.node = '', FamilyTree.templates.john.img_0 = '', FamilyTree.templates.john.ripple = { radius: 60, color: "#e6e6e6", rect: null }, FamilyTree.templates.john.size = [120, 120], FamilyTree.templates.john_male = Object.assign({}, FamilyTree.templates.john), FamilyTree.templates.john_male.node += '', FamilyTree.templates.john_male.ripple = { radius: 60, color: "#039BE5", rect: null }, FamilyTree.templates.john_female = Object.assign({}, FamilyTree.templates.john), FamilyTree.templates.john_female.node += '', FamilyTree.templates.john_female.ripple = { radius: 60, color: "#F57C00", rect: null }, FamilyTree.templates.tommy = Object.assign({}, FamilyTree.templates.base), FamilyTree.templates.tommy.defs = "", FamilyTree.templates.tommy.field_0 = "{val}', FamilyTree.templates.tommy.field_1 = "{val}', FamilyTree.templates.tommy.node = '', FamilyTree.templates.tommy_male = Object.assign({}, FamilyTree.templates.tommy), FamilyTree.templates.tommy_male.node = '', FamilyTree.templates.tommy_female = Object.assign({}, FamilyTree.templates.tommy), FamilyTree.templates.tommy_female.node = '', FamilyTree.templates.hugo = Object.assign({}, FamilyTree.templates.base), FamilyTree.templates.hugo.up = '', FamilyTree.templates.hugo.nodeMenuButton = ``, FamilyTree.templates.hugo.defs = `\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ${FamilyTree.icon.ft(24, 24, "#fff", 0, 0)}\n \n \n `, FamilyTree.templates.hugo.img_0 = '', FamilyTree.templates.hugo.field_0 = "{val}', FamilyTree.templates.hugo.field_1 = "{val}', FamilyTree.templates.hugo.node = '', FamilyTree.templates.hugo_male = Object.assign({}, FamilyTree.templates.hugo), FamilyTree.templates.hugo_male.node = '', FamilyTree.templates.hugo_female = Object.assign({}, FamilyTree.templates.hugo), FamilyTree.templates.hugo_female.node = '', FamilyTree.templates.mother = Object.assign({}, FamilyTree.templates.base), FamilyTree.templates.mother.up = "", FamilyTree.templates.mother.node = 'Add mother' + FamilyTree.icon.mother(70, 70, "#F57C00", 10, 40), FamilyTree.templates.mother.field_0 = "", FamilyTree.templates.mother.field_1 = "", FamilyTree.templates.father = Object.assign({}, FamilyTree.templates.mother), FamilyTree.templates.father.node = 'Add father' + FamilyTree.icon.father(70, 70, "#039BE5", 10, 40), FamilyTree.templates.partner = Object.assign({}, FamilyTree.templates.mother), FamilyTree.templates.partner.node = 'Add partner', FamilyTree.templates.son = Object.assign({}, FamilyTree.templates.mother), FamilyTree.templates.son.node = 'Add son' + FamilyTree.icon.son(70, 70, "#039BE5", 10, 40), FamilyTree.templates.daughter = Object.assign({}, FamilyTree.templates.mother), FamilyTree.templates.daughter.node = 'Add daughter' + FamilyTree.icon.daughter(70, 70, "#F57C00", 10, 40), FamilyTree.templates.husband = Object.assign({}, FamilyTree.templates.mother), FamilyTree.templates.husband.node = 'Add husband' + FamilyTree.icon.husband(70, 70, "#039BE5", 10, 40), FamilyTree.templates.wife = Object.assign({}, FamilyTree.templates.mother), FamilyTree.templates.wife.node = 'Add wife' + FamilyTree.icon.wife(70, 70, "#F57C00", 10, 40), FamilyTree.templates.pet = Object.assign({}, FamilyTree.templates.mother), FamilyTree.templates.pet.node = 'Add pet' + FamilyTree.icon.teddy(70, 70, "#F57C00", 10, 40), FamilyTree.templates.cgroup = Object.assign({}, FamilyTree.templates.base), FamilyTree.templates.cgroup.defs = "", FamilyTree.templates.cgroup.size = [250, 120], FamilyTree.templates.cgroup.padding = [0, 0, 0, 0], FamilyTree.templates.cgroup.node = "", FamilyTree.templates.split = Object.assign({}, FamilyTree.templates.base), FamilyTree.templates.split.size = [10, 10], FamilyTree.templates.split.node = '', FamilyTree.templates.mirror = { linkAdjuster: {}, link: "", node: "", nodeMenuButton: "", size: [0, 0] }, FamilyTree.ui = { _defsIds: {}, defs: function(e) { var t = ""; for (var i in FamilyTree.templates) { var r = FamilyTree.templates[i]; r.defs && (FamilyTree.ui._defsIds[i] = FamilyTree.randomId(), t += r.defs.replaceAll("{randId}", FamilyTree.ui._defsIds[i])) } return "" + t + e + "" }, lonely: function(e) { return e.nodes && e.nodes.length ? "" : FamilyTree.IT_IS_LONELY_HERE.replace("{link}", FamilyTree.RES.IT_IS_LONELY_HERE_LINK) }, pointer: function(e, t, i) { return t === FamilyTree.action.exporting ? "" : FamilyTree.t(e.template, !1, i).pointer }, node: function(e, t, i, r, a, n, o, l, s, d) { var c = FamilyTree.t(e.templateName, e.min, s) , m = c.node.replaceAll("{w}", e.w).replaceAll("{h}", e.h); c.defs && (m = m.replaceAll("{randId}", FamilyTree.ui._defsIds[e.templateName])), null == o && (o = r.nodeBinding); var h = { node: e, data: t }; for (var p in o) { var f, u = o[p]; t && (f = t[u]); var y = FamilyTree._lblIsImg(r, p); if (h.value = f, h.element = c[p], h.name = u, h.field = p, !1 !== FamilyTree.events.publish("field", [d, h]) && null != h.value && null != h.value && null != h.element && (!y || y && !FamilyTree.isNEU(h.value))) { if (!y && "string" == typeof h.value) { var g = h.element; g && (g = g.replaceAll("{ew}", e.w - (e.padding ? e.padding[1] : 0)).replaceAll("{cw}", e.w / 2)), h.value = FamilyTree.wrapText(h.value, g) } var v = h.element.replace("{val}", h.value); m += v = v.replaceAll("{ew}", e.w - (e.padding ? e.padding[1] : 0)).replaceAll("{cw}", e.w / 2).replaceAll("{randId}", FamilyTree.randomId()).replaceAll("{randId2}", FamilyTree.randomId()) } } var T = FamilyTree._getPosition(i, e, a, n) , b = "node"; Array.isArray(e.tags) && e.tags.length && (b += " " + e.tags.join(" ")), e.layout && (b += " tree-layout"); var F = ""; e.lcn && (F = 'lcn="' + e.lcn + '"'); var x = FamilyTree.nodeOpenTag.replace("{lcn}", F).replace("{id}", e.id).replace("{class}", b).replace("{sl}", e.sl).replace("{level}", e.level).replace("{x}", T.x).replace("{y}", T.y) , _ = FamilyTree._getOpacity(i, e); return m = (x = x.replace("{opacity}", _)) + (m += FamilyTree.ui.nodeBtns(r, e, l, c, d)) + FamilyTree.grCloseTag }, nodeBtns: function(e, t, i, r, a) { var n = ""; return null == e.nodeMenu || t.isSplit || i === FamilyTree.action.exporting || (n += r.nodeMenuButton.replace("{id}", t.id).replace("{cw}", t.w / 2).replace("{ch}", t.h / 2).replace("{ew}", t.w - (t.padding ? t.padding[1] : 0)).replace("{eh}", t.h - (t.padding ? t.padding[2] : 0))), null == e.nodeCircleMenu || t.isSplit || i === FamilyTree.action.exporting || FamilyTree.isNEU(r.nodeCircleMenuButton) || (n += ''), n }, expandCollapseBtn: function(e, t, i, r, a) { var n = ""; if (r !== FamilyTree.action.exporting && !t.isSplit) { var o = i[t.lcn ? t.lcn : "base"] , l = 0 , s = 0 , d = FamilyTree.t(t.templateName, t.min, a); if (t.childrenIds.length > 0) { if (t.hasPartners) { for (var c = !1, m = 0; m < t.childrenIds.length; m++) { var h = e.getNode(t.childrenIds[m]); !h || h.parentPartner || h.isPartner || (c = !0) } if (!c) return "" } switch (o.orientation) { case FamilyTree.orientation.top: case FamilyTree.orientation.top_left: l = t.x + t.w / 2, s = t.y + t.h; break; case FamilyTree.orientation.bottom: case FamilyTree.orientation.bottom_left: l = t.x + t.w / 2, s = t.y; break; case FamilyTree.orientation.right: case FamilyTree.orientation.right_top: l = t.x, s = t.y + t.h / 2; break; case FamilyTree.orientation.left: case FamilyTree.orientation.left_top: l = t.x + t.w, s = t.y + t.h / 2 } if (l -= d.expandCollapseSize / 2, s -= d.expandCollapseSize / 2, e.getCollapsedIds(t).length ? (n += FamilyTree.expcollOpenTag.replace("{id}", t.id).replace("{x}", l).replace("{y}", s), n += d.plus, n += FamilyTree.grCloseTag) : (n += FamilyTree.expcollOpenTag.replace("{id}", t.id).replace("{x}", l).replace("{y}", s), n += d.minus, n += FamilyTree.grCloseTag), -1 != n.indexOf("{collapsed-children-count}")) { var p = FamilyTree.collapsedChildrenCount(e, t); n = n.replace("{collapsed-children-count}", p) } if (-1 != n.indexOf("{collapsed-children-total-count}")) { var f = FamilyTree.collapsedChildrenTotalCount(e, t); n = n.replace("{collapsed-children-total-count}", f) } if (-1 != n.indexOf("{children-count}")) { var u = FamilyTree.childrenCount(e, t); n = n.replace("{children-count}", u) } if (-1 != n.indexOf("{children-total-count}")) { var y = FamilyTree.childrenTotalCount(e, t); n = n.replace("{children-total-count}", y) } } e._nodeHasHiddenParent(t) && (n += FamilyTree.upOpenTag.replace("{id}", t.id).replace("{x}", t.x).replace("{y}", t.y), n += d.up, n += FamilyTree.grCloseTag) } var g = { html: n, node: t }; return FamilyTree.events.publish("renderbuttons", [e, g]), g.html }, link: function(e, t, i, r, a, n, o) { var l = e.lcn ? e.lcn : "base" , s = t._layoutConfigs[l] , d = FamilyTree.t(e.templateName, e.min, i) , c = [] , m = [] , h = s.levelSeparation / 2; e.layout > 0 && (h = s.mixedHierarchyNodesSeparation / 2); var p = 0 , f = FamilyTree.getRootOf(e).id , u = r[f][e.sl] , y = void 0; if (e.hasPartners) { y = { ids: [], indexes: {}, ppnodes: {}, lastLeft: null, firstRight: null, maxSidePartnersWithChildren: 0, rightIds: [], leftIds: [], partnerChildrenSplitSeparation: t.config.partnerChildrenSplitSeparation }; for (var g = 0; g < e.children.length; g++) { (T = e.children[g]).parentPartner ? (y.ppnodes[T.id] = T.parentPartner, y.ids.push(T.id), 1 == T.parentPartner.isPartner ? (-1 == y.rightIds.indexOf(T.parentPartner.id) && y.rightIds.push(T.parentPartner.id), y.indexes[T.id] = y.rightIds.indexOf(T.parentPartner.id), y.firstRight || (y.firstRight = T)) : 2 == T.parentPartner.isPartner && (-1 == y.leftIds.indexOf(T.parentPartner.id) && y.leftIds.push(T.parentPartner.id), y.indexes[T.id] = y.leftIds.indexOf(T.parentPartner.id), y.lastLeft = T)) : T.isPartner || (y.lastLeft = T, y.firstRight || (y.firstRight = T)) } y.maxSidePartnersWithChildren = Math.max(y.leftIds.length, y.rightIds.length), p = 0 == y.maxSidePartnersWithChildren ? t.config.minPartnerSeparation / 2 : t.config.minPartnerSeparation / 2 + y.partnerChildrenSplitSeparation * y.maxSidePartnersWithChildren + y.partnerChildrenSplitSeparation / 2 } for (g = 0; g < e.children.length; g++) { var v, T = e.children[g], b = r[f][T.sl], F = { xa: 0, ya: 0, xb: 0, yb: 0, xc: 0, yc: 0, xd: 0, yd: 0, x: 0, y: 0, rotate: 0 }, x = (d = FamilyTree.t(T.templateName, T.min, i)).link; if (T.isChildOfPartner) switch (s.orientation) { case FamilyTree.orientation.top: case FamilyTree.orientation.top_left: var _ = 1 == T.layout ? void 0 : b.minY - (b.minY - u.maxY) / 2; F = FamilyTree.ui._linkTopToBottom(T.parentPartner, T, d, h, _); break; case FamilyTree.orientation.bottom: case FamilyTree.orientation.bottom_left: _ = 1 == T.layout ? void 0 : b.maxY - (b.maxY - u.minY) / 2; F = FamilyTree.ui._linkBottomToTop(T.parentPartner, T, d, h, _); break; case FamilyTree.orientation.right: case FamilyTree.orientation.right_top: _ = 1 == T.layout ? void 0 : b.maxX - (b.maxX - u.minX) / 2; F = FamilyTree.ui._linkRightToLeft(T.parentPartner, T, d, h, _); break; case FamilyTree.orientation.left: case FamilyTree.orientation.left_top: _ = 1 == T.layout ? void 0 : b.minX - (b.minX - u.maxX) / 2; F = FamilyTree.ui._linkLeftToRight(T.parentPartner, T, d, h, _) } else if (y && -1 != y.ids.indexOf(T.id)) switch (s.orientation) { case FamilyTree.orientation.top: case FamilyTree.orientation.top_left: F = FamilyTree.ui._linkPpTop(y, e, T, b, u, d); break; case FamilyTree.orientation.bottom: case FamilyTree.orientation.bottom_left: F = FamilyTree.ui._linkPpBottom(y, e, T, b, u, d); break; case FamilyTree.orientation.right: case FamilyTree.orientation.right_top: F = FamilyTree.ui._linkPpRight(y, e, T, b, u, d); break; case FamilyTree.orientation.left: case FamilyTree.orientation.left_top: F = FamilyTree.ui._linkPpLeft(y, e, T, b, u, d) } else { var w = T.isAssistant && T.rightNeighbor && T.rightNeighbor.isAssistant && T.parent == T.rightNeighbor.parent , k = T.isAssistant && T.leftNeighbor && T.leftNeighbor.isAssistant && T.parent == T.leftNeighbor.parent; if ((w || T.layout > 1) && T.rightNeighbor && T.rightNeighbor.isSplit) switch (s.orientation) { case FamilyTree.orientation.top: case FamilyTree.orientation.top_left: case FamilyTree.orientation.bottom: case FamilyTree.orientation.bottom_left: F = FamilyTree.ui._linkRightToLeft(T.rightNeighbor, T, d, h); break; case FamilyTree.orientation.right: case FamilyTree.orientation.right_top: case FamilyTree.orientation.left: case FamilyTree.orientation.left_top: F = FamilyTree.ui._linkBottomToTop(T.rightNeighbor, T, d, h) } else if ((k || T.layout > 1) && T.leftNeighbor && T.leftNeighbor.isSplit) switch (s.orientation) { case FamilyTree.orientation.top: case FamilyTree.orientation.top_left: case FamilyTree.orientation.bottom: case FamilyTree.orientation.bottom_left: F = FamilyTree.ui._linkLeftToRight(T.leftNeighbor, T, d, h); break; case FamilyTree.orientation.right: case FamilyTree.orientation.right_top: case FamilyTree.orientation.left: case FamilyTree.orientation.left_top: F = FamilyTree.ui._linkTopToBottom(T.leftNeighbor, T, d, h) } else switch (s.orientation) { case FamilyTree.orientation.top: case FamilyTree.orientation.top_left: if (1 == T.isPartner) F = FamilyTree.ui._linkLeftToRight(e, T, d, p); else if (2 == T.isPartner) F = FamilyTree.ui._linkRightToLeft(e, T, d, p); else { _ = 1 == T.layout ? void 0 : b.minY - (b.minY - u.maxY) / 2; F = FamilyTree.ui._linkTopToBottom(e, T, d, h, _) } break; case FamilyTree.orientation.bottom: case FamilyTree.orientation.bottom_left: if (1 == T.isPartner) F = FamilyTree.ui._linkLeftToRight(e, T, d, p); else if (2 == T.isPartner) F = FamilyTree.ui._linkRightToLeft(e, T, d, p); else { _ = 1 == T.layout ? void 0 : b.maxY - (b.maxY - u.minY) / 2; F = FamilyTree.ui._linkBottomToTop(e, T, d, h, _) } break; case FamilyTree.orientation.right: case FamilyTree.orientation.right_top: if (1 == T.isPartner) F = FamilyTree.ui._linkTopToBottom(e, T, d, p); else if (2 == T.isPartner) F = FamilyTree.ui._linkBottomToTop(e, T, d, p); else { _ = 1 == T.layout ? void 0 : b.maxX - (b.maxX - u.minX) / 2; F = FamilyTree.ui._linkRightToLeft(e, T, d, h, _) } break; case FamilyTree.orientation.left: case FamilyTree.orientation.left_top: if (1 == T.isPartner) F = FamilyTree.ui._linkTopToBottom(e, T, d, p); else if (2 == T.isPartner) F = FamilyTree.ui._linkBottomToTop(e, T, d, p); else { _ = 1 == T.layout ? void 0 : b.minX - (b.minX - u.maxX) / 2; F = FamilyTree.ui._linkLeftToRight(e, T, d, h, _) } } } var S = FamilyTree.ui._draggableLinkPath(t, e, T, F, h, s.orientation); if (S) v = S, x = x.replaceAll("{rounded}", S).replaceAll("{edge}", S).replaceAll("{curve}", v); else if (-1 != x.indexOf("{rounded}")) if (F.xa == F.xb && F.xa == F.xc && F.xa == F.xd || F.ya == F.yb && F.ya == F.yc && F.ya == F.yd) v = "M" + F.xa + "," + F.ya + " L" + F.xd + "," + F.yd, x = x.replaceAll("{rounded}", v); else if (Math.abs(F.xa - F.xd) <= FamilyTree.LINK_ROUNDED_CORNERS && Math.abs(F.xa - F.xc) <= FamilyTree.LINK_ROUNDED_CORNERS && Math.abs(F.xa - F.xb) <= FamilyTree.LINK_ROUNDED_CORNERS) v = "M" + F.xa + "," + F.ya + " L" + F.xa + "," + F.yd, x = x.replaceAll("{rounded}", v); else if (Math.abs(F.ya - F.yd) <= FamilyTree.LINK_ROUNDED_CORNERS && Math.abs(F.ya - F.yc) <= FamilyTree.LINK_ROUNDED_CORNERS && Math.abs(F.ya - F.yb) <= FamilyTree.LINK_ROUNDED_CORNERS) v = "M" + F.xa + "," + F.ya + " L" + F.xd + "," + F.ya, x = x.replaceAll("{rounded}", v); else { var C = FamilyTree.ui._roundedEdge(F.xa, F.ya, F.xb, F.yb, F.xc, F.yc) , I = FamilyTree.ui._roundedEdge(F.xb, F.yb, F.xc, F.yc, F.xd, F.yd); v = "M" + C.x1 + "," + C.y1 + " " + C.x2 + "," + C.y2 + " Q" + C.qx1 + "," + C.qy1 + " " + C.qx2 + "," + C.qy2 + " L" + I.x2 + "," + I.y2 + " Q" + I.qx1 + "," + I.qy1 + " " + I.qx2 + "," + I.qy2 + " L" + I.x3 + "," + I.y3, x = x.replaceAll("{rounded}", v) } else -1 != x.indexOf("{edge}") ? (v = "M" + F.xa + "," + F.ya + " " + F.xb + "," + F.yb + " " + F.xc + "," + F.yc + " L" + F.xd + "," + F.yd, x = x.replaceAll("{edge}", v)) : -1 != x.indexOf("{curve}") ? (v = "M" + F.xa + "," + F.ya + " C" + F.xb + "," + F.yb + " " + F.xc + "," + F.yc + " " + F.xd + "," + F.yd, x = x.replaceAll("{curve}", v)) : (v = x.replaceAll("{xa}", F.xa).replaceAll("{ya}", F.ya).replaceAll("{xb}", F.xb).replaceAll("{yb}", F.yb).replaceAll("{xc}", F.xc).replaceAll("{yc}", F.yc).replaceAll("{xd}", F.xd).replaceAll("{yd}", F.yd), x = v); c.push(FamilyTree.linkOpenTag.replaceAll("{id}", e.id).replaceAll("{class}", "link " + T.tags.join(" ")).replaceAll("{child-id}", T.id)); var N = { node: e, cnode: T, p: F, html: x, action: n }; FamilyTree.events.publish("render-link", [t, N]), c.push(N.html), o && m.push({ id: e.id, childId: T.id, html: N.html }); var A = ""; for (var L in t.config.linkBinding) { var E = t.config.linkBinding[L] , M = t._get(T.id); if (M) { var O = M[E]; N.value = O, N.element = d[L], N.name = E, !1 !== FamilyTree.events.publish("label", [t, N]) && (FamilyTree.isNEU(N.value) || FamilyTree.isNEU(N.element) || (A += N.element.replace("{val}", N.value))) } } if ("" != A) { var U = F.x , B = F.y; null != T.movey && (B += T.movey), A = FamilyTree.linkFieldsOpenTag.replace("{x}", U).replace("{y}", B).replace("{rotate}", 0) + A + FamilyTree.grCloseTag, c.push(A) } c.push(FamilyTree.grCloseTag) } return o ? m : c.join("") }, svg: function(e, t, i, r, a, n) { return FamilyTree.t(r.template, !1, n).svg.replace("{w}", e).replace("{h}", t).replace("{viewBox}", i).replace("{randId}", FamilyTree.ui._defsIds[r.template]).replace("{mode}", r.mode).replace("{template}", r.template).replace("{content}", (function() { return a } )) }, menuButton: function(e) { return null == e.menu ? "" : FamilyTree.t(e.template, !1).menuButton.replaceAll("{p}", e.padding) }, _roundedEdge: function(e, t, i, r, a, n) { var o, l, s, d = FamilyTree.LINK_ROUNDED_CORNERS, c = 0; return e == i && e == a || t == r && t == n ? (o = s = i, l = c = r) : (e != a && i == a && (o = s = i, l = r, t < n ? c = r + d : t > n && (c = r - d)), e < a && i == a ? i -= d : e > a && i == a && (i += d), t != n && r == n && (o = i, l = c = r, e < a ? s = i + d : e > a && (s = i - d)), t < n && r == n ? r -= d : t > n && r == n && (r += d)), { x1: e, y1: t, x2: i, y2: r, x3: a, y3: n, qx1: o, qy1: l, qx2: s, qy2: c } }, _linkTopToBottom: function(e, t, i, r, a) { var n, o, l, s, d, c = 0; return n = e.x + e.w / 2 + i.linkAdjuster.toX, o = e.y + e.h + i.linkAdjuster.toY, s = l = t.x + t.w / 2 + i.linkAdjuster.fromX, d = t.y + i.linkAdjuster.fromY, { xa: n, ya: o, xb: n, yb: c = e.rightNeighbor && e.rightNeighbor.isAssistant && "split" == t.templateName ? e.rightNeighbor.y + e.rightNeighbor.h + r : "split" == e.templateName && (t.isAssistant || t.layout > 1) ? d : "split" == t.templateName ? o + r : null != a ? a : d - r, xc: l, yc: c, xd: s, yd: d, x: l, y: FamilyTree.isNEU(t.parentPartner) ? c + 16 : c, rotate: 0 } }, _linkBottomToTop: function(e, t, i, r, a) { var n, o, l, s, d, c = 0; return n = e.x + e.w / 2 + i.linkAdjuster.toX, o = e.y + i.linkAdjuster.toY, s = l = t.x + t.w / 2 + i.linkAdjuster.fromX, d = t.y + t.h + i.linkAdjuster.fromY, { xa: n, ya: o, xb: n, yb: c = e.rightNeighbor && e.rightNeighbor.isAssistant && "split" == t.templateName ? e.rightNeighbor.y - r : "split" == e.templateName && (t.isAssistant || t.layout > 1) ? d : "split" == t.templateName ? o - r : null != a ? a : d + r, xc: l, yc: c, xd: s, yd: d, x: l, y: c - 14, rotate: 0 } }, _linkRightToLeft: function(e, t, i, r, a) { var n, o, l, s, d, c, m = 0; return n = e.x + i.linkAdjuster.toX, o = e.y + e.h / 2 + i.linkAdjuster.toY, d = t.x + t.w + i.linkAdjuster.fromX, c = s = t.y + t.h / 2 + i.linkAdjuster.fromY, l = o, 90, { xa: n, ya: o, xb: m = e.rightNeighbor && e.rightNeighbor.isAssistant && "split" == t.templateName ? e.rightNeighbor.x - r : "split" == e.templateName && (t.isAssistant || t.layout > 1) ? d : "split" == t.templateName ? n - r : null != a ? a : d + r, yb: l, xc: m, yc: s, xd: d, yd: c, x: m - 16, y: s, rotate: 90 } }, _linkLeftToRight: function(e, t, i, r, a) { var n, o, l, s, d, c, m = 0; return n = e.x + e.w + i.linkAdjuster.toX, o = e.y + e.h / 2 + i.linkAdjuster.toY, d = t.x + i.linkAdjuster.fromX, c = s = t.y + t.h / 2 + i.linkAdjuster.fromY, l = o, 270, { xa: n, ya: o, xb: m = e.rightNeighbor && e.rightNeighbor.isAssistant && "split" == t.templateName ? e.rightNeighbor.x + e.rightNeighbor.w + r : "split" == e.templateName && (t.isAssistant || t.layout > 1) ? d : "split" == t.templateName ? n + r : null != a ? a : d - r, yb: l, xc: m, yc: s, xd: d, yd: c, x: m + 14, y: s, rotate: 270 } }, _linkPpTop: function(e, t, i, r, a, n) { var o = e.ppnodes[i.id] , l = o.y + o.h / 2 , s = r.minY - (r.minY - a.maxY) / 2 , d = (r.minY - a.maxY) / e.maxSidePartnersWithChildren / 4 , c = FamilyTree.ui.__linkPpBottomTop(e, t, i, s, d, o) , m = c.x; return s = c.mid, FamilyTree.ui._linkTopToBottom({ x: m, y: l, w: 0, h: 0 }, i, n, 0, s) }, _linkPpBottom: function(e, t, i, r, a, n) { var o = e.ppnodes[i.id] , l = o.y + o.h / 2 , s = r.maxY - (r.maxY - a.minY) / 2 , d = (r.maxY - a.minY) / e.maxSidePartnersWithChildren / 4 , c = FamilyTree.ui.__linkPpBottomTop(e, t, i, s, d, o) , m = c.x; return s = c.mid, FamilyTree.ui._linkBottomToTop({ x: m, y: l, w: 0, h: 0 }, i, n, 0, s) }, _linkPpLeft: function(e, t, i, r, a, n) { var o = e.ppnodes[i.id] , l = r.minX - (r.minX - a.maxX) / 2 , s = (r.minX - a.maxX) / e.maxSidePartnersWithChildren / 4 , d = o.x + o.w / 2 , c = FamilyTree.ui.__linkPpLeftRight(e, t, i, l, s, o) , m = c.y; return l = c.mid, FamilyTree.ui._linkLeftToRight({ x: d, y: m, w: 0, h: 0 }, i, n, 0, l) }, _linkPpRight: function(e, t, i, r, a, n) { var o = e.ppnodes[i.id] , l = r.maxX - (r.maxX - a.minX) / 2 , s = (r.maxX - a.minX) / e.maxSidePartnersWithChildren / 4 , d = o.x + o.w / 2 , c = FamilyTree.ui.__linkPpLeftRight(e, t, i, l, s, o) , m = c.y; return l = c.mid, FamilyTree.ui._linkRightToLeft({ x: d, y: m, w: 0, h: 0 }, i, n, 0, l) }, __linkPpBottomTop: function(e, t, i, r, a, n) { var o = 0; return 1 == n.isPartner ? (o = n.x - t.partnerSeparation / 2 + e.indexes[i.id] * e.partnerChildrenSplitSeparation - (e.rightIds.length - 1) * e.partnerChildrenSplitSeparation / 2, e.lastLeft && o < e.lastLeft.x + e.lastLeft.w / 2 ? o < i.x + i.w / 2 ? r -= (e.indexes[i.id] + 1) * a : r -= (e.rightIds.length - e.indexes[i.id]) * a : o < i.x + i.w / 2 ? r += (e.rightIds.length - e.indexes[i.id]) * a : r += (e.indexes[i.id] + 1) * a) : 2 == n.isPartner && (o = n.x + n.w + t.partnerSeparation / 2 + e.indexes[i.id] * e.partnerChildrenSplitSeparation - (e.leftIds.length - 1) * e.partnerChildrenSplitSeparation / 2, e.firstRight && o > e.firstRight.x + e.firstRight.w / 2 ? o < i.x + i.w / 2 ? r -= (e.indexes[i.id] + 1) * a : r -= (e.leftIds.length - e.indexes[i.id]) * a : o < i.x + i.w / 2 ? r += (e.leftIds.length - e.indexes[i.id]) * a : r += (e.indexes[i.id] + 1) * a), { x: o, mid: r } }, __linkPpLeftRight: function(e, t, i, r, a, n) { var o = 0; return 1 == n.isPartner ? (o = n.y - t.partnerSeparation / 2 + e.indexes[i.id] * e.partnerChildrenSplitSeparation - (e.rightIds.length - 1) * e.partnerChildrenSplitSeparation / 2, e.lastLeft && o < e.lastLeft.y + e.lastLeft.h / 2 ? o < i.y + i.h / 2 ? r -= (e.indexes[i.id] + 1) * a : r -= (e.rightIds.length - e.indexes[i.id]) * a : o < i.y + i.h / 2 ? r += (e.rightIds.length - e.indexes[i.id]) * a : r += (e.indexes[i.id] + 1) * a) : 2 == n.isPartner && (o = n.y + n.h + t.partnerSeparation / 2 + e.indexes[i.id] * e.partnerChildrenSplitSeparation - (e.leftIds.length - 1) * e.partnerChildrenSplitSeparation / 2, e.firstRight && o > e.firstRight.y + e.firstRight.h / 2 ? o < i.y + i.h / 2 ? r -= (e.indexes[i.id] + 1) * a : r -= (e.leftIds.length - e.indexes[i.id]) * a : o < i.y + i.h / 2 ? r += (e.leftIds.length - e.indexes[i.id]) * a : r += (e.indexes[i.id] + 1) * a), { y: o, mid: r } }, _draggableLinkPath: function(e, t, i, r, a, n) { if (i.isPartner) return null; if (i.isAssistant) return null; if (FamilyTree._isMoved(i) && !FamilyTree._isMoved(t)) { var o = []; switch (n) { case FamilyTree.orientation.top: case FamilyTree.orientation.top_left: if (r.yb + a / 2 < r.yd) return null; s = r.xa < r.xd ? i.x - a / 2 : i.x + i.w + a / 2, d = i.y - a / 2; break; case FamilyTree.orientation.bottom: case FamilyTree.orientation.bottom_left: if (r.yb - a / 2 > r.yd) return null; s = r.xa < r.xd ? i.x - a / 2 : i.x + i.w + a / 2, d = i.y + i.h + a / 2; break; case FamilyTree.orientation.right: case FamilyTree.orientation.right_top: if (r.xb - a / 2 > r.xd) return null; d = r.ya < r.yd ? i.y - a / 2 : i.y + i.h + a / 2, s = i.x + i.w + a / 2; break; case FamilyTree.orientation.left: case FamilyTree.orientation.left_top: if (r.xb + a / 2 < r.xd) return null; d = r.ya < r.yd ? i.y - a / 2 : i.y + i.h + a / 2, s = i.x - a / 2 } switch (n) { case FamilyTree.orientation.top: case FamilyTree.orientation.top_left: case FamilyTree.orientation.bottom: case FamilyTree.orientation.bottom_left: o.push(["M", r.xa, r.ya]), o.push(["L", r.xb, r.yb]), o.push(["L", s, r.yb]), o.push(["L", s, d]), o.push(["L", r.xd, d]), o.push(["L", r.xd, r.yd]); break; case FamilyTree.orientation.right: case FamilyTree.orientation.right_top: case FamilyTree.orientation.left: case FamilyTree.orientation.left_top: (o = []).push(["M", r.xa, r.ya]), o.push(["L", r.xb, r.yb]), o.push(["L", r.xb, d]), o.push(["L", s, d]), o.push(["L", s, r.yd]), o.push(["L", r.xd, r.yd]) } return FamilyTree.roundPathCorners(o, FamilyTree.LINK_ROUNDED_CORNERS, !1) } if (!FamilyTree._isMoved(i) && FamilyTree._isMoved(t)) { var l = !1; o = []; switch (n) { case FamilyTree.orientation.top: case FamilyTree.orientation.top_left: if (r.ya + a / 2 > r.yb) l = !0, s = r.xa < r.xd ? t.x + t.w + a / 2 : t.x - a / 2, d = t.y + t.h + a; else { if (r.yb + a / 2 < r.yd) return null; s = r.xa < r.xd ? i.x - a / 2 : i.x + i.w + a / 2, d = i.y - a / 2 } break; case FamilyTree.orientation.bottom: case FamilyTree.orientation.bottom_left: if (r.ya - a / 2 < r.yb) l = !0, s = r.xa < r.xd ? t.x + t.w + a / 2 : t.x - a / 2, d = t.y - a; else { if (r.yb - a / 2 > r.yd) return null; s = r.xa < r.xd ? i.x - a / 2 : i.x + i.w + a / 2, d = i.y + i.h + a / 2 } break; case FamilyTree.orientation.right: case FamilyTree.orientation.right_top: if (r.xa - a / 2 < r.xb) l = !0, d = r.ya < r.yd ? t.y + t.h + a / 2 : t.y - a / 2, s = t.x - a; else { if (r.xb - a / 2 > r.xd) return null; d = r.ya < r.yd ? i.y - a / 2 : i.y + i.h + a / 2, s = i.x + i.w + a / 2 } break; case FamilyTree.orientation.left: case FamilyTree.orientation.left_top: if (r.xa + a / 2 > r.xb) l = !0, d = r.ya < r.yd ? t.y + t.h + a / 2 : t.y - a / 2, s = t.x + t.w + a; else { if (r.xb + a / 2 < r.xd) return null; d = r.ya < r.yd ? i.y - a / 2 : i.y + i.h + a / 2, s = i.x - a / 2 } } if (l) switch (n) { case FamilyTree.orientation.top: case FamilyTree.orientation.top_left: case FamilyTree.orientation.bottom: case FamilyTree.orientation.bottom_left: o.push(["M", r.xa, r.ya]), o.push(["L", r.xa, d]), o.push(["L", s, d]), o.push(["L", s, r.yc]), o.push(["L", r.xc, r.yc]), o.push(["L", r.xd, r.yd]); break; case FamilyTree.orientation.right: case FamilyTree.orientation.right_top: case FamilyTree.orientation.left: case FamilyTree.orientation.left_top: o.push(["M", r.xa, r.ya]), o.push(["L", s, r.ya]), o.push(["L", s, d]), o.push(["L", r.xc, d]), o.push(["L", r.xc, r.yc]), o.push(["L", r.xd, r.yd]) } else switch (n) { case FamilyTree.orientation.top: case FamilyTree.orientation.top_left: case FamilyTree.orientation.bottom: case FamilyTree.orientation.bottom_left: o.push(["M", r.xa, r.ya]), o.push(["L", r.xb, r.yb]), o.push(["L", s, r.yb]), o.push(["L", s, d]), o.push(["L", r.xd, d]), o.push(["L", r.xd, r.yd]); break; case FamilyTree.orientation.right: case FamilyTree.orientation.right_top: case FamilyTree.orientation.left: case FamilyTree.orientation.left_top: o.push(["M", r.xa, r.ya]), o.push(["L", r.xb, r.yb]), o.push(["L", r.xb, d]), o.push(["L", s, d]), o.push(["L", s, r.yd]), o.push(["L", r.xd, r.yd]) } return FamilyTree.roundPathCorners(o, FamilyTree.LINK_ROUNDED_CORNERS, !1) } if (FamilyTree._isMoved(i) && FamilyTree._isMoved(t)) { o = []; switch (n) { case FamilyTree.orientation.top: case FamilyTree.orientation.top_left: if (r.ya + a > r.yd) { var s = r.xa < r.xd ? t.x + t.w + a / 2 : t.x - a / 2 , d = t.y + t.h + a , c = i.y - a; o.push(["M", r.xa, r.ya]), o.push(["L", r.xa, d]), o.push(["L", s, d]), o.push(["L", s, c]), o.push(["L", r.xc, c]), o.push(["L", r.xd, r.yd]) } else o.push(["M", r.xa, r.ya]), o.push(["L", r.xa, t.y + t.h + a]), o.push(["L", r.xc, t.y + t.h + a]), o.push(["L", r.xd, r.yd]); break; case FamilyTree.orientation.bottom: case FamilyTree.orientation.bottom_left: if (r.ya - a < r.yd) { s = r.xa < r.xd ? t.x + t.w + a / 2 : t.x - a / 2, d = t.y - a, c = i.y + i.h + a; o.push(["M", r.xa, r.ya]), o.push(["L", r.xa, d]), o.push(["L", s, d]), o.push(["L", s, c]), o.push(["L", r.xc, c]), o.push(["L", r.xd, r.yd]) } else o.push(["M", r.xa, r.ya]), o.push(["L", r.xa, t.y - a]), o.push(["L", r.xc, t.y - a]), o.push(["L", r.xd, r.yd]); break; case FamilyTree.orientation.right: case FamilyTree.orientation.right_top: if (r.xa - a < r.xd) { d = r.ya < r.yd ? t.y + t.h + a / 2 : t.y - a / 2, s = t.x - a; var m = i.x + i.w + a; o.push(["M", r.xa, r.ya]), o.push(["L", s, r.ya]), o.push(["L", s, d]), o.push(["L", m, d]), o.push(["L", m, r.yc]), o.push(["L", r.xd, r.yd]) } else o.push(["M", r.xa, r.ya]), o.push(["L", t.x - a, r.ya]), o.push(["L", t.x - a, r.yc]), o.push(["L", r.xd, r.yd]); break; case FamilyTree.orientation.left: case FamilyTree.orientation.left_top: if (r.xa + a > r.xd) { d = r.ya < r.yd ? t.y + t.h + a / 2 : t.y - a / 2, s = t.x + t.w + a, m = i.x - a; o.push(["M", r.xa, r.ya]), o.push(["L", s, r.ya]), o.push(["L", s, d]), o.push(["L", m, d]), o.push(["L", m, r.yc]), o.push(["L", r.xd, r.yd]) } else o.push(["M", r.xa, r.ya]), o.push(["L", t.x + t.w + a, r.ya]), o.push(["L", t.x + t.w + a, r.yc]), o.push(["L", r.xd, r.yd]) } return FamilyTree.roundPathCorners(o, FamilyTree.LINK_ROUNDED_CORNERS, !1) } return null } }, FamilyTree.ui._base_nodeBtns = FamilyTree.ui.nodeBtns, FamilyTree.ui.nodeBtns = function(e, t, i, r, a) { var n = ""; if (a._tree_menu_temp) !t.isSplit && i !== FamilyTree.action.exporting && r.nodeTreeMenuCloseButton && a._tree_menu_temp.id == t.id && (n += r.nodeTreeMenuCloseButton); else { n = FamilyTree.ui._base_nodeBtns(e, t, i, r, a); null != e.nodeTreeMenu && !t.isSplit && i !== FamilyTree.action.exporting && r.nodeTreeMenuButton && (n += r.nodeTreeMenuButton.replace("{id}", t.id)) } return n } , FamilyTree.ui._base_expandCollapseBtn = FamilyTree.ui.expandCollapseBtn, FamilyTree.ui.expandCollapseBtn = function(e, t, i, r, a) { return e._tree_menu_temp ? "" : FamilyTree.ui._base_expandCollapseBtn(e, t, i, r, a) } , FamilyTree.xScrollUI = function(e, t, i, r, a) { this.element = e, this.requestParams = i, this.config = t, this.onSetViewBoxCallback = r, this.onDrawCallback = a, this.position = 0, this.bar = null, this._event_id = FamilyTree._guid() } , FamilyTree.xScrollUI.prototype.addListener = function(e) { var t = this; if ((this.config.mouseScrool == FamilyTree.action.xScroll || this.config.mouseScrool == FamilyTree.action.scroll) && this.bar) { var i = -1 !== navigator.userAgent.indexOf("Mac OS") , r = FamilyTree._getScrollSensitivity(); !function(e, r, a) { var n = !1; function o() { n = !0; var e = (t.position - t.bar.scrollLeft) / a; if (e > 0) e++; else { if (0 == e) return void (n = !1); e-- } Math.ceil(t.bar.scrollLeft) == Math.ceil(t.position) ? n = !1 : (t.bar.scrollLeft += e, l(o)) } e.addEventListener("wheel", (function(e) { if (e.ctrlKey) return; var a = 0; if (t.config.mouseScrool == FamilyTree.action.xScroll) (a = e.deltaX || e.wheelDeltaX) || (a = e.deltaY || e.wheelDeltaY); else if (t.config.mouseScrool == FamilyTree.action.scroll && !(a = i || !e.shiftKey ? e.deltaX || e.wheelDeltaX : e.deltaY || e.wheelDeltaY)) return; a = -a, a = Math.max(-1, Math.min(1, a)), t.position += -a * r; var l = parseFloat(t.innerBar.clientWidth) - parseFloat(t.bar.clientWidth); t.position < 0 && (t.position = 0); t.position > l && (t.position = l); n || o() } ), { passive: !0 }); var l = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(e) { setTimeout(e, 20) } }(e, r.speed, r.smooth) } } , FamilyTree.xScrollUI.prototype.create = function(e) { if (this.config.showXScroll === FamilyTree.scroll.visible || this.config.mouseScrool === FamilyTree.action.scroll || this.config.mouseScrool === FamilyTree.action.xScroll) { var t = this; this.bar && this.bar.parentNode && this.bar.parentNode.removeChild(this.bar), this.bar = document.createElement("div"), this.innerBar = document.createElement("div"); this.requestParams(); this.innerBar.innerHTML = " ", Object.assign(this.bar.style, { position: "absolute", left: 0, bottom: 0, width: e + "px", "overflow-x": "scroll", height: "20px" }), this.element.appendChild(this.bar), this.bar.appendChild(this.innerBar), this.bar.addEventListener("scroll", (function() { if (this.ignore) this.ignore = !1; else { var e = t.requestParams() , i = (parseFloat(t.innerBar.clientWidth) - parseFloat(t.bar.clientWidth)) / 100 , r = this.scrollLeft / i , a = (e.boundary.right - e.boundary.left) / 100; e.viewBox[0] = r * a + e.boundary.left, t.onSetViewBoxCallback(e.viewBox), clearTimeout(this._timeout), this._timeout = setTimeout((function() { t.onDrawCallback() } ), 500) } } )) } } , FamilyTree.xScrollUI.prototype.setPosition = function() { if (this.bar) { var e = this.requestParams() , t = (Math.abs(e.boundary.maxX - e.boundary.minX) + 2 * this.config.padding) * e.scale; switch (this.config.orientation) { case FamilyTree.orientation.right: case FamilyTree.orientation.right_top: t = Math.abs(e.boundary.minX * e.scale) } this.innerBar.style.width = t + "px"; var i = (e.boundary.right - e.boundary.left) / 100 , r = (e.viewBox[0] - e.boundary.left) / i; r < 0 ? r = 0 : r > 100 && (r = 100); var a = (parseFloat(this.innerBar.clientWidth) - parseFloat(this.bar.clientWidth)) / 100 , n = r * a; this.bar.ignore = !0, this.bar.scrollLeft = n, this.position = this.bar.scrollLeft, this.bar.style.visibility = a <= 0 ? "hidden" : "", this.config.showXScroll !== FamilyTree.scroll.visible && (this.bar.style.visibility = "hidden"), FamilyTree.events.publish("change", [this, { isScrollBarVisible: "hidden" != this.bar.style.visibility }]) } } , FamilyTree.xScrollUI.prototype.on = function(e, t) { return FamilyTree.events.on(e, t, this._event_id), this } , FamilyTree.yScrollUI = function(e, t, i, r, a) { this.element = e, this.requestParams = i, this.config = t, this.onSetViewBoxCallback = r, this.onDrawCallback = a, this.position = 0, this.bar = null, this._event_id = FamilyTree._guid() } , FamilyTree.yScrollUI.prototype.addListener = function(e) { var t = this; if ((this.config.mouseScrool == FamilyTree.action.yScroll || this.config.mouseScrool == FamilyTree.action.scroll) && this.bar) { var i = -1 !== navigator.userAgent.indexOf("Mac OS") , r = FamilyTree._getScrollSensitivity(); !function(e, r, a) { var n = !1; function o() { n = !0; var e = (t.position - t.bar.scrollTop) / a; if (e > 0) e++; else { if (0 == e) return void (n = !1); e-- } Math.ceil(t.bar.scrollTop) == Math.ceil(t.position) ? n = !1 : (t.bar.scrollTop += e, l(o)) } e.addEventListener("wheel", (function(e) { if (e.ctrlKey) return; var a = 0; if (t.config.mouseScrool == FamilyTree.action.yScroll) (a = e.deltaY || e.wheelDeltaY) || (a = e.deltaX || e.wheelDeltaX); else if (t.config.mouseScrool == FamilyTree.action.scroll && !(a = i || !e.shiftKey ? e.deltaY || e.wheelDeltaY : e.deltaX || e.wheelDeltaX)) return; a = -a, a = Math.max(-1, Math.min(1, a)), t.position += -a * r; var l = parseFloat(t.innerBar.clientHeight) - parseFloat(t.bar.clientHeight); t.position < 0 && (t.position = 0); t.position > l && (t.position = l); n || o() } ), { passive: !0 }); var l = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(e) { setTimeout(e, 20) } }(e, r.speed, r.smooth) } } , FamilyTree.yScrollUI.prototype.create = function(e) { if (this.config.showYScroll === FamilyTree.scroll.visible || this.config.mouseScrool === FamilyTree.action.scroll || this.config.mouseScrool === FamilyTree.action.yScroll) { var t = this; this.bar && this.bar.parentNode && this.bar.parentNode.removeChild(this.bar), this.bar = document.createElement("div"), this.innerBar = document.createElement("div"), this.innerBar.innerHTML = " ", Object.assign(this.bar.style, { position: "absolute", right: 0, bottom: 0, height: e + "px", "overflow-y": "scroll", width: "20px" }), this.element.appendChild(this.bar), this.bar.appendChild(this.innerBar), this.bar.addEventListener("scroll", (function() { if (this.ignore) this.ignore = !1; else { var e = t.requestParams() , i = (parseFloat(t.innerBar.clientHeight) - parseFloat(t.bar.clientHeight)) / 100 , r = this.scrollTop / i , a = (e.boundary.bottom - e.boundary.top) / 100; e.viewBox[1] = r * a + e.boundary.top, t.onSetViewBoxCallback(e.viewBox), clearTimeout(this._timeout), this._timeout = setTimeout((function() { t.onDrawCallback() } ), 500) } } )) } } , FamilyTree.yScrollUI.prototype.setPosition = function() { if (this.bar) { var e = this.requestParams() , t = (Math.abs(e.boundary.maxY - e.boundary.minY) + 2 * this.config.padding) * e.scale; switch (this.config.orientation) { case FamilyTree.orientation.bottom: case FamilyTree.orientation.bottom_left: t = Math.abs(e.boundary.minY * e.scale) } this.innerBar.style.height = t + "px"; var i = (e.boundary.bottom - e.boundary.top) / 100 , r = (e.viewBox[1] - e.boundary.top) / Math.abs(i); r < 0 ? r = 0 : r > 100 && (r = 100); var a = (parseFloat(this.innerBar.clientHeight) - parseFloat(this.bar.clientHeight)) / 100 , n = r * a; this.bar.ignore = !0, this.bar.scrollTop = n, this.position = this.bar.scrollTop, this.bar.style.visibility = a <= 0 ? "hidden" : "", this.config.showYScroll !== FamilyTree.scroll.visible && (this.bar.style.visibility = "hidden"), FamilyTree.events.publish("change", [this, { isScrollBarVisible: "hidden" != this.bar.style.visibility }]) } } , FamilyTree.yScrollUI.prototype.on = function(e, t) { return FamilyTree.events.on(e, t, this._event_id), this } , FamilyTree.prototype.zoom = function(e, t, i, r) { var a = this.getViewBox().slice(0) , n = a , o = a[2] , l = a[3]; !0 === e ? (a[2] = a[2] / FamilyTree.SCALE_FACTOR, a[3] = a[3] / FamilyTree.SCALE_FACTOR) : !1 === e ? (a[2] = a[2] * FamilyTree.SCALE_FACTOR, a[3] = a[3] * FamilyTree.SCALE_FACTOR) : (a[2] = a[2] / e, a[3] = a[3] / e), t || (t = [50, 50]), a[0] = n[0] - (a[2] - o) / (100 / t[0]), a[1] = n[1] - (a[3] - l) / (100 / t[1]); var s = this.getScale(a); if (a[2] = this.width() / s, a[3] = this.height() / s, !0 === e && s < this.config.scaleMax || !1 === e && s > this.config.scaleMin || 0 != e && 1 != e && s < this.config.scaleMax && s > this.config.scaleMin) { this._hideBeforeAnimation(); var d = this; i ? (clearTimeout(d._timeout), FamilyTree.animate(this.getSvg(), { viewbox: this.getViewBox() }, { viewbox: a }, this.config.anim.duration, this.config.anim.func, (function() { clearTimeout(d._timeout), d._timeout = setTimeout((function() { d._draw(!0, FamilyTree.action.zoom, null, r) } ), 500) } ))) : (this.setViewBox(a), clearTimeout(d._timeout), d._timeout = setTimeout((function() { d._draw(!0, FamilyTree.action.zoom, null, r) } ), 500)) } } , FamilyTree.loading = {}, FamilyTree.loading.show = function(e) { var t = document.createElement("div"); t.id = "bft-loading", t.innerHTML = '
', e.element.appendChild(t) } , FamilyTree.loading.hide = function(e) { var t = e.element.querySelector("#bft-loading"); t && t.parentNode.removeChild(t) } , FamilyTree.pdfPrevUI = {}, FamilyTree.loc || (FamilyTree.loc = {}), FamilyTree.loc.ppdfCmdTitle = "PDF Preview", FamilyTree.loc.ppdfSave = "Save", FamilyTree.loc.ppdfCancel = "Cancel", FamilyTree.loc.ppdfFormat = "Format", FamilyTree.loc.ppdfFitToDrwaing = "Fit", FamilyTree.loc.ppdfA4 = "A4", FamilyTree.loc.ppdfA3 = "A3", FamilyTree.loc.ppdfA2 = "A2", FamilyTree.loc.ppdfA1 = "A1", FamilyTree.loc.ppdfLetter = "Letter", FamilyTree.loc.ppdfLegal = "Legal", FamilyTree.loc.ppdfLayout = "Layout", FamilyTree.loc.ppdfPortrait = "Portrait", FamilyTree.loc.ppdfLandscape = "Landscape", FamilyTree.loc.ppdfFittopagewidth = "Fit to page width", FamilyTree.loc.ppdfMargin = "Margin", FamilyTree.loc.ppdfHeader = "Header", FamilyTree.loc.ppdfFooter = "Footer", FamilyTree.loc.ppdfScale = "Scale", FamilyTree.pdfPrevUI.show = function(e, t) { FamilyTree.pdfPrevUI.hide(e), t = e._defaultExportOptions(t, "pdf"); var i = document.createElement("div"); i.classList.add(e.config.mode), i.id = "bft-ppdf-btns", Object.assign(i.style, { position: "absolute", top: 0, left: 0, "background-color": "#fff", "z-index": 5, margin: "0 0 0 -265px", "box-shadow": "0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19)", width: "265px", height: "100%", "font-family": "Roboto,Helvetica", color: "#757575", "text-align": "right", padding: "10px" }), e.element.appendChild(i), i.innerHTML = "

" + FamilyTree.loc.ppdfCmdTitle + '

 
'; var r = document.createElement("div"); r.id = "bft-ppdf-wrapper", Object.assign(r.style, { "overflow-y": "scroll", "z-index": 11, position: "absolute", top: 0, left: "285px", "background-color": "#eee", width: e.width() - 270 + "px", height: "100%" }), e.element.appendChild(r), r.innerHTML = '
'; var a, n, o, l = e.element.querySelector("#bft-ppdf-size"), s = e.element.querySelector("#bft-ppdf-layout"), d = e.element.querySelector("#bft-ppdf-scale"), c = e.element.querySelector("#bft-ppdf-margin"), m = e.element.querySelector("#bft-ppdf-header"), h = e.element.querySelector("#bft-ppdf-footer"); l.value = t.format, s.value = t.landscape, d.value = t.scale, c.value = t.margin, m.value = t.header, h.value = t.footer, FamilyTree.animate(e.element.querySelector("#bft-ppdf-btns"), { margin: [0, 0, 0, -250] }, { margin: [0, 0, 0, 0] }, 300, FamilyTree.anim.outSin, (function() { e.exportPDF(t, FamilyTree.pdfPrevUI._handler) } )), e.element.querySelector("#bft-prev-cancel").addEventListener("click", (function() { FamilyTree.pdfPrevUI.hide(e) } )), e.element.querySelector("#bft-prev-save").addEventListener("click", (function() { e.exportPDF(t), FamilyTree.pdfPrevUI.hide(e) } )), FamilyTree.pdfPrevUI._showHide(l, s, d), l.addEventListener("change", (function() { FamilyTree.animate(e.element.querySelector("#bft-ppdf-content"), { opacity: 1 }, { opacity: 0 }, 300, FamilyTree.anim.inSin, (function() { e.element.querySelector("#bft-ppdf-content").innerHTML = "", t.format = l.value, e.exportPDF(t, FamilyTree.pdfPrevUI._handler), FamilyTree.pdfPrevUI._showHide(l, s, d) } )) } )), s.addEventListener("change", (function() { FamilyTree.animate(e.element.querySelector("#bft-ppdf-content"), { opacity: 1 }, { opacity: 0 }, 300, FamilyTree.anim.inSin, (function() { e.element.querySelector("#bft-ppdf-content").innerHTML = "", t.landscape = "true" == s.value, e.exportPDF(t, FamilyTree.pdfPrevUI._handler), FamilyTree.pdfPrevUI._showHide(l, s, d) } )) } )), d.addEventListener("change", (function() { FamilyTree.animate(e.element.querySelector("#bft-ppdf-content"), { opacity: 1 }, { opacity: 0 }, 300, FamilyTree.anim.inSin, (function() { e.element.querySelector("#bft-ppdf-content").innerHTML = "", t.scale = d.value, e.exportPDF(t, FamilyTree.pdfPrevUI._handler), FamilyTree.pdfPrevUI._showHide(l, s, d) } )) } )), c.addEventListener("keyup", (function() { clearTimeout(a), a = setTimeout((function() { FamilyTree.animate(e.element.querySelector("#bft-ppdf-content"), { opacity: 1 }, { opacity: 0 }, 300, FamilyTree.anim.inSin, (function() { e.element.querySelector("#bft-ppdf-content").innerHTML = ""; var i = c.value.split(","); if (4 == i.length) { for (var r = 0; r < i.length; r++) i[r] = parseInt(i[r]); t.margin = i, e.exportPDF(t, FamilyTree.pdfPrevUI._handler) } } )) } ), 1e3) } )), m.addEventListener("keyup", (function() { clearTimeout(n), n = setTimeout((function() { FamilyTree.animate(e.element.querySelector("#bft-ppdf-content"), { opacity: 1 }, { opacity: 0 }, 300, FamilyTree.anim.inSin, (function() { e.element.querySelector("#bft-ppdf-content").innerHTML = "", t.header = m.value, e.exportPDF(t, FamilyTree.pdfPrevUI._handler) } )) } ), 1e3) } )), h.addEventListener("keyup", (function() { clearTimeout(o), o = setTimeout((function() { FamilyTree.animate(e.element.querySelector("#bft-ppdf-content"), { opacity: 1 }, { opacity: 0 }, 300, FamilyTree.anim.inSin, (function() { e.element.querySelector("#bft-ppdf-content").innerHTML = "", t.footer = h.value, e.exportPDF(t, FamilyTree.pdfPrevUI._handler) } )) } ), 1e3) } )) } , FamilyTree.pdfPrevUI._showHide = function(e, t, i) { "A4" == e.value || "A3" == e.value || "A2" == e.value || "A1" == e.value || "Letter" == e.value || "Legal" == e.value ? (t.parentNode.style.display = "block", i.parentNode.style.display = "block") : (t.parentNode.style.display = "none", i.parentNode.style.display = "none") } , FamilyTree.pdfPrevUI._handler = function(e, t, i) { var r = t.options , a = t.pages , n = r.margin[0] , o = r.margin[2] , l = document.createElement("div"); l.classList.add(e.config.mode), l.innerHTML = i.outerHTML, FamilyTree._browser().msie && (l.innerHTML = (new XMLSerializer).serializeToString(i)); for (var s = l.querySelector("svg"), d = e.element.querySelector("#bft-ppdf-content"), c = 0; c < a.length; c++) { var m = document.createElement("iframe"); Object.assign(m.style, { display: "block", margin: "10px auto", border: "1px solid #eeeeee", "box-shadow": "0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19)" }), d.appendChild(m), s && s.style.backgroundColor ? m.style.backgroundColor = s.style.backgroundColor : m.style.backgroundColor = "#fff"; var h = m.contentWindow.document; h.open(), m.style.width = a[c].size.w + "px", m.style.height = a[c].size.h + "px", m.style.margin = "10 auto", a[c].backgroundColor && (m.style.backgroundColor = a[c].backgroundColor); var p = r.header; a[c].header && (p = a[c].header), p && (p = p.replace("{current-page}", c + 1).replace("{total-pages}", a.length)); var f = r.footer; a[c].footer && (f = a[c].footer), f && (f = f.replace("{current-page}", c + 1).replace("{total-pages}", a.length)), a[c].html ? h.write(FamilyTree._exportHtml(a[c].html, t.styles, r, a[c].innerSize.w, a[c].innerSize.h, p, f, e.config.mode)) : (s.setAttribute("viewBox", a[c].vb), h.write(FamilyTree._exportHtml(l.innerHTML, t.styles, r, a[c].innerSize.w, a[c].innerSize.h, p, f, e.config.mode))); var u = h.getElementById("bft-header") , y = h.getElementById("bft-footer"); if (u) { var g = n - u.offsetHeight - 7; u.style.top = g + "px" } if (y) { var v = o - y.offsetHeight - 7; y.style.bottom = v + "px" } h.close() } var T = e.element.querySelector("#bft-ppdf-content"); FamilyTree.animate(T, { opacity: 0 }, { opacity: 1 }, 300, FamilyTree.anim.outSin) } , FamilyTree.pdfPrevUI._getViewBox = function(e) { var t = null; return e ? (t = (t = "[" + (t = e.getAttribute("viewBox")) + "]").replace(/\ /g, ","), t = JSON.parse(t)) : null } , FamilyTree._exportHtml = function(e, t, i, r, a, n, o, l) { for (var s = "", d = 0; d < i.margin.length; d++) s += i.margin[d] + "px "; var c = '' + t + '
'; return n && (c += '
' + n + "
"), c += e, o && (c += '"), c += "
", c += "" } , FamilyTree.pdfPrevUI.hide = function(e) { var t = e.element.querySelector("#bft-ppdf-wrapper"); if (t) { t.parentNode.removeChild(t), t.style.opacity = 0; var i = e.element.querySelector("#bft-ppdf-btns"); i.parentNode.removeChild(i) } } , void 0 === FamilyTree && (FamilyTree = {}), FamilyTree.events.on("renderdefs", (function(e, t) { for (var i = 0; i < e.config.clinks.length; i++) { var r = e.config.clinks[i].template; r || (r = "orange"); var a = FamilyTree.clinkTemplates[r]; t.defs += a.defs } } )), FamilyTree.events.on("prerender", (function(e, t) { FamilyTree.RENDER_CLINKS_BEFORE_NODES && e._clink(e, t) } )), FamilyTree.events.on("render", (function(e, t) { FamilyTree.RENDER_CLINKS_BEFORE_NODES || e._clink(e, t) } )), FamilyTree.events.on("drag", (function(e, t, i, r) { if (e instanceof FamilyTree && e.config.movable && r) for (var a = 0; a < r.length; a++) { for (var n = r[a], o = e.element.querySelectorAll(`[data-c-l-from="${n}"]`), l = e.element.querySelectorAll(`[data-c-l-to="${n}"]`), s = 0; s < o.length; s++) o[s].parentNode.removeChild(o[s]); for (s = 0; s < l.length; s++) l[s].parentNode.removeChild(l[s]) } } )), FamilyTree.prototype._clink = function(e, t) { for (var i = "", r = 0; r < this.config.clinks.length; r++) { var a = this.config.clinks[r] , n = e.getNode(a.from) , o = e.getNode(a.to); if (n && -1 != t.res.visibleNodeIds.indexOf(n.id) && (o && -1 != t.res.visibleNodeIds.indexOf(o.id))) { var l = n.x , s = n.y , d = o.x , c = o.y , m = {} , h = {} , p = l + n.w / 2 , f = d + o.w / 2 , u = s + n.h / 2 , y = c + o.h / 2 , g = 1; switch (this.config.orientation) { case FamilyTree.orientation.top: case FamilyTree.orientation.top_left: p <= f ? (g = 1, m.x = p + n.w / 10, h.x = f - o.w / 10) : (g = -1, m.x = p - n.w / 10, h.x = f + o.w / 10), s == c ? (g = 1, m.y = s, h.y = c) : s > c ? (m.y = s, h.y = c + o.h) : (m.y = s + n.h, h.y = c); break; case FamilyTree.orientation.bottom: case FamilyTree.orientation.bottom_left: p <= f ? (g = -1, m.x = p + n.w / 10, h.x = f + o.w / 10) : (g = 1, m.x = p - n.w / 10, h.x = f + o.w / 10), s == c ? (g = -1, m.y = s + n.h, h.y = c + o.h) : s > c ? (m.y = s, h.y = c + o.h) : (m.y = s + n.h, h.y = c); break; case FamilyTree.orientation.left: case FamilyTree.orientation.left_top: u <= y ? (g = -1, m.y = u + n.h / 5, h.y = y + o.h / 5) : (g = 1, m.y = u - n.h / 5, h.y = y + o.h / 5), l == d ? (g = -1, m.x = l, h.x = d) : l > d ? (m.x = l, h.x = d + o.w) : (m.x = l + n.w, h.x = d); break; case FamilyTree.orientation.right: case FamilyTree.orientation.right_top: u <= y ? (g = 1, m.y = u + n.h / 5, h.y = y + o.h / 5) : (g = -1, m.y = u - n.h / 5, h.y = y + o.h / 5), l == d ? (g = 1, m.x = l + n.w, h.x = d + o.w) : l > d ? (m.x = l, h.x = d + o.w) : (m.x = l + n.w, h.x = d) } var v = _(m, h, g) , T = a.template; T || (T = "orange"); var b = FamilyTree.clinkTemplates[T]; if (a.label) { var F = FamilyTree.clinkLabelPosition(a, m, h, v); i += b.label.replace("{x}", F.x).replace("{y}", F.y).replace("{val}", a.label) } var x = "M" + m.x + "," + m.y + "C" + m.x + "," + m.y + " " + v.x + "," + v.y + " " + h.x + "," + h.y; i += ("').replace("{from}", n.id).replace("{to}", o.id) + b.link.replaceAll("{d}", x) + '', i += FamilyTree.grCloseTag } function _(e, t, i) { null == i && (i = 1); var r = t.x - e.x , n = t.y - e.y , o = Math.sqrt(Math.pow(t.x - e.x, 2) + Math.pow(t.y - e.y, 2)) / 3; return o = o / (Math.sqrt(r * r + n * n) * i) * FamilyTree.clinkCurve(a), { x: e.x + r / 2 - n * o, y: e.y + n / 2 + r * o } } } t.content += i } , FamilyTree.clinkLabelPosition = function(e, t, i, r) { var a = (i.x - t.x) / 2 + t.x , n = (i.y - t.y) / 2 + t.y; return { x: (a - r.x) / 2 + r.x, y: (n - r.y) / 2 + r.y } } , FamilyTree.clinkCurve = function(e) { return FamilyTree.CLINK_CURVE } , FamilyTree.prototype.addClink = function(e, t, i, r) { this._putInUndoStack(), this.clearRedo(); for (var a = this.config.clinks.length - 1; a >= 0; a--) { var n = this.config.clinks[a]; n.from == e && n.to == t && this.config.clinks.splice(a, 1) } return this.config.clinks.push({ from: e, to: t, label: i, template: r }), FamilyTree.events.publish("updated", [this]), this } , FamilyTree.prototype.removeClink = function(e, t) { this._putInUndoStack(), this.clearRedo(); for (var i = this.config.clinks.length - 1; i >= 0; i--) { var r = this.config.clinks[i]; r.from == e && r.to == t && this.config.clinks.splice(i, 1) } return FamilyTree.events.publish("updated", [this]), this } , FamilyTree.clinkTemplates = {}, FamilyTree.clinkTemplates.orange = { defs: ' ', link: '', label: '{val}' }, FamilyTree.clinkTemplates.blue = { defs: ' ', link: '', label: '{val}' }, FamilyTree.clinkTemplates.yellow = { defs: ' ', link: '', label: '{val}' }, void 0 === FamilyTree && (FamilyTree = {}), FamilyTree.events.on("renderdefs", (function(e, t) { for (var i = 0; i < e.config.slinks.length; i++) { var r = e.config.slinks[i].template; r || (r = "orange"); var a = FamilyTree.slinkTemplates[r]; t.defs += a.defs } } )), FamilyTree.events.on("render", (function(e, t) { e._slinks(e, t) } )), FamilyTree.events.on("drag", (function(e, t, i, r) { if (e instanceof FamilyTree && e.config.movable && r) for (var a = 0; a < r.length; a++) { for (var n = r[a], o = e.element.querySelectorAll(`[data-s-l-from="${n}"]`), l = e.element.querySelectorAll(`[data-s-l-to="${n}"]`), s = 0; s < o.length; s++) o[s].parentNode.removeChild(o[s]); for (s = 0; s < l.length; s++) l[s].parentNode.removeChild(l[s]) } } )), FamilyTree.prototype._slinks = function(e, t) { var i = "" , r = this.getScale() , a = t.res.boundary; function n(t, n, o) { var s = [] , d = null , c = "left" , m = t.lcn ? t.lcn : "base" , h = e._layoutConfigs[m]; switch (h.orientation) { case FamilyTree.orientation.top: case FamilyTree.orientation.top_left: case FamilyTree.orientation.bottom: case FamilyTree.orientation.bottom_left: n.x > t.x && (c = "right"); break; case FamilyTree.orientation.left: case FamilyTree.orientation.left_top: case FamilyTree.orientation.right: case FamilyTree.orientation.right_top: c = "top", n.y > t.y && (c = "bottom") } var p = FamilyTree.t(t.templateName, t.min, r) , f = h.levelSeparation; t.parent && t.parent.layout && (f = h.mixedHierarchyNodesSeparation); var u = { p: t.x + t.w / 2 + p.expandCollapseSize, q: t.y, r: t.x + t.w / 2 + p.expandCollapseSize, s: a.minY + f }; if (t.sl == n.sl) switch (d = n, h.orientation) { case FamilyTree.orientation.top: case FamilyTree.orientation.top_left: s.push([u.p, u.q]), s.push([u.p, u.q - f / 3]), p = FamilyTree.t(d.templateName, d.min, r), s.push([d.x + d.w / 2 + p.expandCollapseSize, s[s.length - 1][1]]), s.push([s[s.length - 1][0], d.y]); break; case FamilyTree.orientation.bottom: case FamilyTree.orientation.bottom_left: u.q = t.y + t.h, u.s = a.maxY - f, s.push([u.p, u.q]), s.push([u.r, t.y + t.h + f / 3]), p = FamilyTree.t(d.templateName, d.min, r), s.push([d.x + d.w / 2 + p.expandCollapseSize, s[s.length - 1][1]]), s.push([s[s.length - 1][0], d.y + d.h]); break; case FamilyTree.orientation.left: case FamilyTree.orientation.left_top: u.p = t.x, u.q = t.y + t.h / 2 + p.expandCollapseSize, u.r = a.minX - f, u.s = t.y + t.h / 2 + p.expandCollapseSize, s.push([u.p, u.q]), s.push([t.x - f / 3, u.q]), p = FamilyTree.t(d.templateName, d.min, r), s.push([s[s.length - 1][0], d.y + d.h / 2 + p.expandCollapseSize]), s.push([d.x, s[s.length - 1][1]]); break; case FamilyTree.orientation.right: case FamilyTree.orientation.right_top: u.p = t.x + t.w, u.q = t.y + t.h / 2 + p.expandCollapseSize, u.r = a.maxX + f, u.s = t.y + t.h / 2 + p.expandCollapseSize, s.push([u.p, u.q]), s.push([t.x + t.w + f / 3, u.q]), p = FamilyTree.t(d.templateName, d.min, r), s.push([s[s.length - 1][0], d.y + d.h / 2 + p.expandCollapseSize]), s.push([d.x + d.w, s[s.length - 1][1]]) } else { switch (h.orientation) { case FamilyTree.orientation.top: case FamilyTree.orientation.top_left: s.push([u.p, u.q]), s.push([u.r, t.y - f / 3]); break; case FamilyTree.orientation.bottom: case FamilyTree.orientation.bottom_left: u.q = t.y + t.h, u.s = a.maxY - f, s.push([u.p, u.q]), s.push([u.r, t.y + t.h + f / 3]); break; case FamilyTree.orientation.left: case FamilyTree.orientation.left_top: u.p = t.x, u.q = t.y + t.h / 2 + p.expandCollapseSize, u.r = a.minX - f, u.s = t.y + t.h / 2 + p.expandCollapseSize, s.push([u.p, u.q]), s.push([t.x - f / 3, u.q]); break; case FamilyTree.orientation.right: case FamilyTree.orientation.right_top: u.p = t.x + t.w, u.q = t.y + t.h / 2 + p.expandCollapseSize, u.r = a.maxX + f, u.s = t.y + t.h / 2 + p.expandCollapseSize, s.push([u.p, u.q]), s.push([t.x + t.w + f / 3, u.q]) } for (var y = t, g = t; g.parent; ) g = g.parent; for (; null == d; ) { var v = !1 , T = y.parent , b = T.leftNeighbor , F = T.rightNeighbor; if (T.id == n.id ? d = T : FamilyTree._intersects(T, u, h) && (u = FamilyTree._addPoint(T, s, h, u, c), v = !0), T.id != n.id) { for (; b; ) { if (b.id == n.id) { d = b; break } FamilyTree._intersects(b, u, h) && (u = FamilyTree._addPoint(b, s, h, u, c), v = !0), b = b.leftNeighbor } for (; F; ) { if (F.id == n.id) { d = F; break } FamilyTree._intersects(F, u, h) && (u = FamilyTree._addPoint(F, s, h, u, c), v = !0), F = F.rightNeighbor } } if (!v) { var x = s[s.length - 1][0] , _ = 0; if (T.parent) { f = h.levelSeparation, T.parent.layout && (f = h.mixedHierarchyNodesSeparation); var w = e.manager.bordersByRootIdAndLevel[g.id][T.parent.sl]; switch (h.orientation) { case FamilyTree.orientation.top: case FamilyTree.orientation.top_left: _ = w.maxY + f * (2 / 3); break; case FamilyTree.orientation.bottom: case FamilyTree.orientation.bottom_left: _ = w.minY - f * (2 / 3); break; case FamilyTree.orientation.left: case FamilyTree.orientation.left_top: x = w.maxX + f * (2 / 3), _ = s[s.length - 1][1]; break; case FamilyTree.orientation.right: case FamilyTree.orientation.right_top: x = w.minX - f * (2 / 3), _ = s[s.length - 1][1] } } s.push([x, _]) } y = T } switch (p = FamilyTree.t(d.templateName, d.min, r), s.splice(s.length - 1, 1), h.orientation) { case FamilyTree.orientation.top: case FamilyTree.orientation.top_left: s.push([d.x + d.w / 2 + p.expandCollapseSize, s[s.length - 1][1]]), s.push([s[s.length - 1][0], d.y + d.h]); break; case FamilyTree.orientation.bottom: case FamilyTree.orientation.bottom_left: s.push([d.x + d.w / 2 + p.expandCollapseSize, s[s.length - 1][1]]), s.push([s[s.length - 1][0], d.y]); break; case FamilyTree.orientation.left: case FamilyTree.orientation.left_top: s.push([s[s.length - 1][0], d.y + d.h / 2 + p.expandCollapseSize]), s.push([d.x + d.w, s[s.length - 1][1]]); break; case FamilyTree.orientation.right: case FamilyTree.orientation.right_top: s.push([s[s.length - 1][0], d.y + d.h / 2 + p.expandCollapseSize]), s.push([d.x, s[s.length - 1][1]]) } } var k = l.template; k || (k = "orange"); var S, C, I = null; switch ((p = FamilyTree.slinkTemplates[k]).labelPosition) { case "start": I = { x: s[1][0], y: s[1][1] }; break; case "middle": var N = Math.ceil(s.length / 2); S = s[N], C = s[N - 1], I = { x: (S[0] + C[0]) / 2, y: (S[1] + C[1]) / 2 }; break; case "end": I = { x: s[s.length - 2][0], y: s[s.length - 2][1] } } o && (s = s.reverse()), s[0].unshift("M"); for (var A = 1; A < s.length; A++) s[A].unshift("L"); var L = FamilyTree.roundPathCorners(s, FamilyTree.LINK_ROUNDED_CORNERS, !1); if (l.label) { var E = p.label.replace("{x}", I.x).replace("{y}", I.y).replace("{val}", l.label) , M = FamilyTree._getLabelSize(E) , O = -M.height / 2; switch (h.orientation) { case FamilyTree.orientation.bottom: case FamilyTree.orientation.bottom_left: O = M.height } i += p.label.replace("{x}", I.x).replace("{y}", I.y + O).replace("{val}", l.label) } var U = t.id , B = n.id; o && (U = n.id, B = t.id), i += ("').replace("{from}", U).replace("{to}", B) + p.link.replaceAll("{d}", L) + '', i += FamilyTree.grCloseTag } for (var o = 0; o < this.config.slinks.length; o++) { var l = this.config.slinks[o] , s = e.getNode(l.from) , d = e.getNode(l.to); s && d && -1 != t.res.visibleNodeIds.indexOf(d.id) && -1 != t.res.visibleNodeIds.indexOf(s.id) && (s.sl >= d.sl ? n(s, d, !1) : n(d, s, !0)) } t.content += i } , FamilyTree.prototype.addSlink = function(e, t, i, r) { this._putInUndoStack(), this.clearRedo(); for (var a = this.config.slinks.length - 1; a >= 0; a--) { var n = this.config.slinks[a]; n.from == e && n.to == t && this.config.slinks.splice(a, 1) } return this.config.slinks.push({ from: e, to: t, label: i, template: r }), FamilyTree.events.publish("updated", [this]), this } , FamilyTree.prototype.removeSlink = function(e, t) { this._putInUndoStack(), this.clearRedo(); for (var i = this.config.slinks.length - 1; i >= 0; i--) { var r = this.config.slinks[i]; r.from == e && r.to == t && this.config.slinks.splice(i, 1) } return FamilyTree.events.publish("updated", [this]), this } , FamilyTree.slinkTemplates = {}, FamilyTree.slinkTemplates.orange = { defs: ' ', link: '', label: '{val}', labelPosition: "middle" }, FamilyTree.slinkTemplates.blue = { defs: ' ', link: '', label: '{val}', labelPosition: "middle" }, FamilyTree.slinkTemplates.yellow = { defs: ' ', link: '', label: '{val}', labelPosition: "middle" }, FamilyTree.events.on("renderbuttons", (function(e, t) { if (t.node && t.node.tags && t.node.tags.has("group-dotted-lines")) { var i = e.getScale() , r = FamilyTree.t(t.node.templateName, t.node.min, i) , a = ""; t.node.min ? (r.nodeGroupDottedOpenButton || console.error(`[${t.node.templateName}].nodeGroupDottedOpenButton is not defined`), a += ``, a += r.nodeGroupDottedOpenButton) : (r.nodeGroupDottedCloseButton || console.error(`[${t.node.templateName}].nodeGroupDottedCloseButton is not defined`), a += ``, a += r.nodeGroupDottedCloseButton), a = (a += "").replaceAll("{cw}", t.node.w / 2).replaceAll("{ch}", t.node.h / 2).replaceAll("{ew}", t.node.w - (t.node.padding ? t.node.padding[1] : 0)).replaceAll("{eh}", t.node.h - (t.node.padding ? t.node.padding[2] : 0)); var n = e.getNode(t.node.stChildrenIds[0]); if (-1 != a.indexOf("{collapsed-children-count}")) { var o = FamilyTree.collapsedChildrenCount(e, n); a = a.replace("{collapsed-children-count}", o) } if (-1 != a.indexOf("{collapsed-children-total-count}")) { var l = FamilyTree.collapsedChildrenTotalCount(e, n); a = a.replace("{collapsed-children-total-count}", l) } if (-1 != a.indexOf("{children-count}")) { var s = FamilyTree.childrenCount(e, n); a = a.replace("{children-count}", s) } if (-1 != a.indexOf("{children-total-count}")) { var d = FamilyTree.childrenTotalCount(e, n); a = a.replace("{children-total-count}", d) } t.html += a } } )), FamilyTree.events.on("redraw", (function(e, t) { if (e.config.groupDottedLines.length) { for (var i = e.element.querySelectorAll("[data-ctrl-n-dotted-close]"), r = 0; r < i.length; r++) i[r].addEventListener("click", (function() { var t = this.getAttribute("data-ctrl-n-dotted-close"); e.minimize(t) } )); var a = e.element.querySelectorAll("[data-ctrl-n-dotted-open]"); for (r = 0; r < a.length; r++) a[r].addEventListener("click", (function() { var t = this.getAttribute("data-ctrl-n-dotted-open"); e.maximize(t) } )) } } )), void 0 === FamilyTree && (FamilyTree = {}), FamilyTree.prototype.undo = function(e) { if (this.config.undoRedoStorageName) { var t = this.undoStepsCount(); if (0 != t) { this._putInRedoStack(); var i = `${this.config.undoRedoStorageName}_undo_` + (t - 1) , r = sessionStorage.getItem(i); sessionStorage.removeItem(i); var a = JSON.parse(r); this.config.nodes = a.nodes, this.config.clinks = a.clinks, this.config.slinks = a.slinks, this.config.groupDottedLines = a.groupDottedLines, this.config.dottedLines = a.dottedLines, FamilyTree.events.publish("updated", [this]), this.filterUI.update(), this.draw(FamilyTree.action.update, void 0, e), this.undoRedoUI.refresh() } } } , FamilyTree.prototype.redo = function(e) { if (this.config.undoRedoStorageName) { var t = this.redoStepsCount(); if (0 != t) { this._putInUndoStack(); var i = `${this.config.undoRedoStorageName}_redo_` + (t - 1) , r = sessionStorage.getItem(i); sessionStorage.removeItem(i); var a = JSON.parse(r); this.config.nodes = a.nodes, this.config.clinks = a.clinks, this.config.slinks = a.slinks, this.config.groupDottedLines = a.groupDottedLines, this.config.dottedLines = a.dottedLines, FamilyTree.events.publish("updated", [this]), this.filterUI.update(), this.draw(FamilyTree.action.update, void 0, e), this.undoRedoUI.refresh() } } } , FamilyTree.prototype.clearRedo = function() { if (this.config.undoRedoStorageName) { for (var e = `${this.config.undoRedoStorageName}_redo_`, t = Object.keys(sessionStorage), i = 0; -1 != t.indexOf(e + i); ) sessionStorage.removeItem(e + i), i++; this.undoRedoUI.refresh() } } , FamilyTree.prototype.clearUndo = function() { if (this.config.undoRedoStorageName) { for (var e = `${this.config.undoRedoStorageName}_undo_`, t = Object.keys(sessionStorage), i = 0; -1 != t.indexOf(e + i); ) sessionStorage.removeItem(e + i), i++; this.undoRedoUI.refresh() } } , FamilyTree.prototype.undoStepsCount = function() { for (var e = `${this.config.undoRedoStorageName}_undo_`, t = Object.keys(sessionStorage), i = 0; -1 != t.indexOf(e + i); ) i++; return i } , FamilyTree.prototype.redoStepsCount = function() { for (var e = `${this.config.undoRedoStorageName}_redo_`, t = Object.keys(sessionStorage), i = 0; -1 != t.indexOf(e + i); ) i++; return i } , FamilyTree.prototype._putInUndoStack = function() { if (this.config.undoRedoStorageName) { var e = `${this.config.undoRedoStorageName}_undo_` + this.undoStepsCount(); sessionStorage.setItem(e, JSON.stringify({ nodes: this.config.nodes, clinks: this.config.clinks, slinks: this.config.slinks, groupDottedLines: this.config.groupDottedLines, dottedLines: this.config.dottedLines })) } } , FamilyTree.prototype._putInRedoStack = function() { if (this.config.undoRedoStorageName) { var e = `${this.config.undoRedoStorageName}_redo_` + this.redoStepsCount(); sessionStorage.setItem(e, JSON.stringify({ nodes: this.config.nodes, clinks: this.config.clinks, slinks: this.config.slinks, groupDottedLines: this.config.groupDottedLines, dottedLines: this.config.dottedLines })) } } , void 0 === FamilyTree && (FamilyTree = {}), FamilyTree.undoRedoUI = function() { this.instance = null, this._event_id = FamilyTree._guid() } , FamilyTree.undoRedoUI.prototype.init = function(e) { e.config.undoRedoStorageName && (this.instance = e, this.refresh()) } , FamilyTree.undoRedoUI.prototype.refresh = function() { var e = this; if (this.instance.config.undoRedoStorageName) { var t = { undoStepsCount: this.instance.undoStepsCount(), redoStepsCount: this.instance.redoStepsCount() }; if (!1 !== FamilyTree.events.publish("change", [this, t])) { var i = this.instance.element.querySelector("[data-undo]") , r = this.instance.element.querySelector("[data-redo]"); if (!i || !r) { var a = document.createElement("div"); a.classList.add("bft-undo-redo"), a.innerHTML = `${FamilyTree.icon.undo(50, 50, "")}\n ${FamilyTree.icon.redo(50, 50, "")}`, this.instance.element.appendChild(a), i = this.instance.element.querySelector("[data-undo]"), r = this.instance.element.querySelector("[data-redo]"), i.addEventListener("click", (function() { e.instance.undo() } )), r.addEventListener("click", (function() { e.instance.redo() } )) } t.undoStepsCount > 0 ? (i.classList.add("bft-ur-clickable"), i.querySelector(".bft-undo-i").innerHTML = t.undoStepsCount, i.querySelector(".bft-undo-i").style.display = "inline-block") : (i.classList.remove("bft-ur-clickable"), i.querySelector(".bft-undo-i").style.display = "none"), t.redoStepsCount > 0 ? (r.classList.add("bft-ur-clickable"), r.querySelector(".bft-redo-i").innerHTML = t.redoStepsCount, r.querySelector(".bft-redo-i").style.display = "inline-block") : (r.classList.remove("bft-ur-clickable"), r.querySelector(".bft-redo-i").style.display = "none") } } } , FamilyTree.undoRedoUI.prototype.on = function(e, t) { return FamilyTree.events.on(e, t, this._event_id), this } , FamilyTree.undoRedoUI.prototype.onChange = function(e) { return this.on("change", (function(t, i) { return e.call(t, i) } )) } , FamilyTree.events.on("redraw", (function(e, t) { if (e.config.miniMap) { if (e.manager.action != FamilyTree.action.move) { FamilyTree.miniMap._settings._scale = Math.min(FamilyTree.miniMap.width / (e.response.boundary.maxX - e.response.boundary.minX), FamilyTree.miniMap.height / (e.response.boundary.maxY - e.response.boundary.minY)), FamilyTree.miniMap._settings._translateX = -e.response.boundary.minX * FamilyTree.miniMap._settings._scale + (FamilyTree.miniMap.width - (e.response.boundary.maxX - e.response.boundary.minX) * FamilyTree.miniMap._settings._scale) / 2, FamilyTree.miniMap._settings._translateY = -e.response.boundary.minY * FamilyTree.miniMap._settings._scale + (FamilyTree.miniMap.height - (e.response.boundary.maxY - e.response.boundary.minY) * FamilyTree.miniMap._settings._scale) / 2; var i = e.getViewBox(); FamilyTree.miniMap._init(e), FamilyTree.miniMap._drawMainCanvas(e), FamilyTree.miniMap._drawRectSelectorCanvas(e, i); var r, a, n, o, l = e.element.querySelector('[data-id="mini-map-focus"]'), s = !1, d = null; l.onmousedown = function(e) { var t, n, o, d = l.getBoundingClientRect(), c = d.left, m = d.top; if (r = parseInt(e.clientX - c), a = parseInt(e.clientY - m), t = a, n = (r - FamilyTree.miniMap._settings._translateX) / FamilyTree.miniMap._settings._scale, o = (t - FamilyTree.miniMap._settings._translateY) / FamilyTree.miniMap._settings._scale, n > i[0] && n < i[0] + i[2] && o > i[1] && o < i[1] + i[3]) return e.preventDefault(), e.stopPropagation(), void (s = !0) } , l.onmousemove = function(t) { if (s) { t.preventDefault(), t.stopPropagation(), FamilyTree.miniMap._mouseMove = !0; var c = l.getBoundingClientRect() , m = c.left , h = c.top; n = parseInt(t.clientX - m), o = parseInt(t.clientY - h); var p = (n - r) / FamilyTree.miniMap._settings._scale , f = (o - a) / FamilyTree.miniMap._settings._scale; i[0] = p + i[0], i[1] = f + i[1], e.setViewBox(i), d && (clearTimeout(d), d = null), d = setTimeout((function() { e._draw(!0, FamilyTree.action.move) } ), 300), FamilyTree.miniMap._drawRectSelectorCanvas(e, i), r = n, a = o } } , l.onmouseup = function(e) { s && (e.preventDefault(), e.stopPropagation(), s = !1) } , l.onmouseout = function(e) { s && (e.preventDefault(), e.stopPropagation(), s = !1, FamilyTree.miniMap._mouseMove = !1) } , l.onclick = function(t) { if (t.preventDefault(), t.stopPropagation(), FamilyTree.miniMap._mouseMove) FamilyTree.miniMap._mouseMove = !1; else { var r = l.getBoundingClientRect() , a = r.left , s = r.top; n = parseInt(t.clientX - a), o = parseInt(t.clientY - s); var c = n / FamilyTree.miniMap._settings._scale , m = o / FamilyTree.miniMap._settings._scale; i[0] = c - (i[0] + i[2] - i[0]) / 2 - FamilyTree.miniMap._settings._translateX / FamilyTree.miniMap._settings._scale, i[1] = m - (i[1] + i[3] - i[1]) / 2 - FamilyTree.miniMap._settings._translateY / FamilyTree.miniMap._settings._scale, e.setViewBox(i), d && (clearTimeout(d), d = null), d = setTimeout((function() { e._draw(!0, FamilyTree.action.move) } ), 300), FamilyTree.miniMap._drawRectSelectorCanvas(e, i) } } } } else { var c = e.element.querySelector('[data-id="mini-map"]'); c && c.parentNode.removeChild(c) } } )), FamilyTree.miniMap = {}, FamilyTree.miniMap._settings = { _translateX: 0, _translateY: 0, _scale: 1 }, FamilyTree.miniMap._drawMainCanvas = function(e) { var t = e.element.querySelector('[data-id="mini-map-main"]') , i = t.getContext("2d"); FamilyTree.miniMap._initCtx(e, t, 1); var r = 0 , a = []; !function e(t, n) { if (Array.isArray(n)) for (var o = 0; o < n.length; o++) e(t, n[o]); else { i.fillStyle = FamilyTree.miniMap.colors[3], i.beginPath(), i.lineWidth = "0.5", i.fillRect(n.x, n.y, n.w, n.h), i.strokeRect(n.x, n.y, n.w, n.h); for (o = 0; o < n.stChildrenIds.length; o++) r++, a.includes(n.id) || (1 == r ? i.fillStyle = FamilyTree.miniMap.colors[0] : 2 == r ? i.fillStyle = FamilyTree.miniMap.colors[1] : 3 == r && (i.fillStyle = FamilyTree.miniMap.colors[2]), i.beginPath(), i.fillRect(n.x, n.y, n.w, n.h), i.strokeRect(n.x, n.y, n.w, n.h), a.push(n.id)), e(t, t.getNode(n.stChildrenIds[o])), r--; for (o = 0; o < n.childrenIds.length; o++) e(t, t.getNode(n.childrenIds[o])) } }(e, e.roots) } , FamilyTree.miniMap._drawRectSelectorCanvas = function(e, t) { var i = e.element.querySelector('[data-id="mini-map-focus"]') , r = i.getContext("2d"); FamilyTree.miniMap._initCtx(e, i, FamilyTree.miniMap.opacity); var a = t[0] , n = t[1] , o = t[2] , l = t[3]; r.lineWidth = .5 / FamilyTree.miniMap._settings._scale, r.strokeStyle = FamilyTree.miniMap.focusStroke, r.globalAlpha = 1, r.clearRect(a, n, o, l), r.strokeRect(a, n, o, l) } , FamilyTree.miniMap._initCtx = function(e, t, i) { var r = t.getContext("2d"); t.width = t.width, t.height = t.height, r.clearRect(0, 0, FamilyTree.miniMap.width, FamilyTree.miniMap.height), r.globalAlpha = i, 1 != i && (r.fillStyle = FamilyTree.miniMap.selectorBackgroundColor, r.fillRect(0, 0, FamilyTree.miniMap.width, FamilyTree.miniMap.height)), r.translate(FamilyTree.miniMap._settings._translateX, FamilyTree.miniMap._settings._translateY), r.scale(FamilyTree.miniMap._settings._scale, FamilyTree.miniMap._settings._scale) } , FamilyTree.miniMap._init = function(e) { if (!e.element.querySelector('[data-id="mini-map"]')) { var t = document.createElement("canvas"); t.width = FamilyTree.miniMap.width, t.height = FamilyTree.miniMap.height, t.setAttribute("data-id", "mini-map-main"), t.style.display = "inline-block", t.style.backgroundColor = FamilyTree.miniMap.backgroundColor, t.style.position = "absolute", t.style.top = 0, t.style.left = 0; var i = document.createElement("canvas"); i.width = FamilyTree.miniMap.width, i.height = FamilyTree.miniMap.height, i.setAttribute("data-id", "mini-map-focus"), i.style.display = "inline-block", i.style.position = "absolute", i.style.top = 0, i.style.left = 0; var r = document.createElement("div"); r.setAttribute("data-id", "mini-map"), r.style.position = "absolute"; for (var a = ["top", "right", "left", "bottom"], n = 0; n < a.length; n++) { var o = a[n]; FamilyTree.isNEU(FamilyTree.miniMap.position[o]) || ("padding" == FamilyTree.miniMap.position[o] ? r.style[o] = e.config.padding + "px" : r.style[o] = FamilyTree.miniMap.position[o] + "px") } r.style.border = FamilyTree.miniMap.border, r.style.padding = FamilyTree.miniMap.padding + "px", r.style.backgroundColor = FamilyTree.miniMap.backgroundColor; var l = document.createElement("div"); l.style.position = "relative", l.style.width = FamilyTree.miniMap.width + "px", l.style.height = FamilyTree.miniMap.height + "px", l.appendChild(t), l.appendChild(i), r.appendChild(l), e.element.appendChild(r); var s = function(t, i) { e.__mouseScrollHandler(r, i) }; e._addEvent(r, "DOMMouseScroll", s), e._addEvent(r, "mousewheel", s); var d = 0 , c = 0 , m = function(e) { FamilyTree.miniMap._mouseMove = !0; var t = e.clientX - d , i = e.clientY - c; if (!FamilyTree.isNEU(r.style.left)) { var a = parseFloat(r.style.left) + t; r.style.left = `${a}px` } if (!FamilyTree.isNEU(r.style.right)) { var n = parseFloat(r.style.right) - t; r.style.right = `${n}px` } if (!FamilyTree.isNEU(r.style.bottom)) { var o = parseFloat(r.style.bottom) - i; r.style.bottom = `${o}px` } if (!FamilyTree.isNEU(r.style.top)) { var l = parseFloat(r.style.top) + i; r.style.top = `${l}px` } d = e.clientX, c = e.clientY } , h = function() { document.removeEventListener("mousemove", m), document.removeEventListener("mouseup", h) }; FamilyTree.miniMap.draggable && r.addEventListener("mousedown", (function(e) { d = e.clientX, c = e.clientY, document.addEventListener("mousemove", m), document.addEventListener("mouseup", h) } )) } } , FamilyTree.miniMap.colors = ["#E0E0E0", "#BDBDBD", "#9E9E9E", "#757575"], FamilyTree.miniMap.selectorBackgroundColor = "white", FamilyTree.miniMap.backgroundColor = "white", FamilyTree.miniMap.focusStroke = "#f57c00", FamilyTree.miniMap.opacity = .4, FamilyTree.miniMap.border = "1px solid #aeaeae", FamilyTree.miniMap.width = 250, FamilyTree.miniMap.height = 140, FamilyTree.miniMap.padding = 5, FamilyTree.miniMap.position = { top: void 0, left: "padding", right: void 0, bottom: "padding" }, FamilyTree.miniMap.draggable = !0, FamilyTree._search = {}, FamilyTree._search.search = function(e, t, i, r, a, n, o) { var l = [] , s = t.toLowerCase() , d = s.split(" "); if (o && d.length > 1) { var c = d[0]; o[c] && (i = [o[c]], d = (s = s.replace(c, "").trim()).split(" ")) } d = d.filter((function(e, t, i) { return i.indexOf(e) === t } )); for (var m = {}, h = 0; h < e.length; h++) for (var p = e[h], f = 0; f < i.length; f++) { var u = i[f]; if (!FamilyTree.isNEU(p[u])) { var y = p[u]; if (null != (t = FamilyTree._search.searchAndComputeScore(d, y, u, n))) { var g = p.id; if (m[g]) { if (m[g] && m[g] < t.__score) { m[g] = t.__score; for (var v = l.length - 1; v >= 0; v--) l[v].id == g && l.splice(v, 1); FamilyTree._search.addNodeToResult(l, r, p, t, u, a) } } else m[g] = t.__score, FamilyTree._search.addNodeToResult(l, r, p, t, u, a) } } } return l.sort((function(e, t) { return e.__score < t.__score ? 1 : e.__score > t.__score ? -1 : 0 } )), l } , FamilyTree._search.addNodeToResult = function(e, t, i, r, a, n) { var o = {}; o.id = i.id, FamilyTree.isNEU(i[n]) || (o[n] = i[n]); for (var l = 0; l < t.length; l++) { var s = t[l]; FamilyTree.isNEU(i[s]) || FamilyTree.isNEU(o[s]) && (o[s] = i[s]) } null != r && (FamilyTree.isNEU(o.__score) && (o.__score = r.__score), FamilyTree.isNEU(o.__searchField) && (o.__searchField = a), FamilyTree.isNEU(o.__searchMarks) && (o.__searchMarks = r.__searchMarks)), e.push(o) } , FamilyTree._search.searchAndComputeScore = function(e, t, i, r) { if (FamilyTree.isNEU(t)) return null; if (FamilyTree.isNEU(e)) return null; if (!e.length) return null; "string" != typeof t && (t = t.toString()); var a = t.toLowerCase() , n = FamilyTree._search.searchIndexesOf(a, e); if (!n.length) return null; for (var o = a.length / 100, l = 0, s = 0, d = l > 0 ? 100 : 0, c = 0, m = 0; m < e.length; m++) for (var h = e[m], p = 0; p < n.length; p++) if (-1 != h.indexOf(n[p].searchPhrase)) { c++; break } var f = 100 / (e.length / c); if (n.length) { s = n[0].start; for (p = 0; p < n.length; p++) if (l += n[p].length, n[p].start < s && (s = n[p].start), p >= 1 && n[p - 1].start > n[p].start) { d = 0; break } } var u = 0; 0 != l && (u = l / o); var y = l > 0 ? 100 : 0; 0 != s && (y = 100 - s / o); var g = 0; r && r[i] && (g = r[i]), f && (f = f / 100 * 50), u > 0 && (u = u / 100 * 10), y > 0 && (y = y / 100 * 10), d > 0 && (d = d / 100 * 10), g > 0 && (g = g / 100 * 20); var v = Math.round(1e4 * (f + u + y + d + g)); n.sort((function(e, t) { return e.start < t.start ? -1 : e.start > t.start ? 1 : 0 } )); for (p = n.length - 1; p >= 0; p--) for (m = 0; m < n.length; m++) m < p && n[m].start + n[m].length > n[p].start && n.splice(p, 1); var T = t; for (p = n.length - 1; p >= 0; p--) T = (T = T.insert(n[p].start + n[p].length, "")).insert(n[p].start, ""); return { __searchMarks: T, __score: v } } , FamilyTree._search.searchIndexesOf = function(e, t) { var i = []; if (!FamilyTree.isNEU(e)) for (var r = 0; r < t.length; r++) { var a = t[r]; if (!FamilyTree.isNEU(a)) for (var n = 0; (n = e.indexOf(a, n)) > -1; ) i.push({ length: a.length, start: n, searchPhrase: a }), n += a.length } return i.sort((function(e, t) { return e.length < t.length ? 1 : e.length > t.length || e.start < t.start ? -1 : e.start > t.start ? 1 : 0 } )), i = i.filter((function(e) { for (var t = !1, r = 0; r < i.length; r++) { var a = i[r].start , n = i[r].start + i[r].length - 1 , o = e.start , l = e.start + e.length - 1; if (a == o && n == l) { t = !1; break } if (a >= o && n <= l) { t = !0; break } if (a <= o && n >= l) { t = !0; break } } return !t } )) } , FamilyTree.events.on("redraw", (function(e, t) { if (e.config.state) { var i = [] , r = []; !function e(t) { if (Array.isArray(t)) for (var a = 0; a < t.length; a++) e(t[a]); else { ("string" != typeof t.id || "string" == typeof t.id && -1 == t.id.indexOf("split") && -1 == t.id.indexOf("mirror")) && (i.push(t.id), 1 == t.min && r.push(t.id)); for (a = 0; a < t.stChildren.length; a++) e(t.stChildren[a]); for (a = 0; a < t.children.length; a++) e(t.children[a]) } }(e.roots), FamilyTree.state._put(e.config.roots, e.width(), e.height(), e.response.viewBox, i, r, e.response.adjustify, e.config.state) } } )), FamilyTree.state = {}, FamilyTree.state._buildStateNames = function(e) { return { paramScale: e + "-scale", paramX: e + "-x", paramY: e + "-y", paramExp: e + "-exp", paramMin: e + "-min", paramRoots: e + "-roots", paramAdjustify: e + "-adjustify" } } , FamilyTree.state._put = function(e, t, i, r, a, n, o, l) { if (l && !FamilyTree.isNEU(a) && 0 != a.length) { var s = FamilyTree.state._buildStateNames(l.name) , d = { roots: e, scale: Math.min(t / r[2], i / r[3]), x: r[0], y: r[1], exp: a, min: n, adjustify: o }; if (l.writeToUrlParams) { var c = new URLSearchParams(window.location.search); c.has(s.paramScale) ? c.set(s.paramScale, d.scale) : c.append(s.paramScale, d.scale), c.has(s.paramX) ? c.set(s.paramX, d.x) : c.append(s.paramX, d.x), c.has(s.paramY) ? c.set(s.paramY, d.y) : c.append(s.paramY, d.y), c.has(s.paramExp) ? c.set(s.paramExp, d.exp.join("*")) : c.append(s.paramExp, d.exp.join("*")), c.has(s.paramRoots) && Array.isArray(d.roots) ? c.set(s.paramRoots, d.roots.join("*")) : Array.isArray(d.roots) && c.append(s.paramRoots, d.roots.join("*")), c.has(s.paramMin) ? c.set(s.paramMin, d.min.join("*")) : c.append(s.paramMin, d.min.join("*")), c.has(s.paramAdjustify) ? c.set(s.paramAdjustify, d.adjustify.x + "*" + d.adjustify.y) : c.append(s.paramAdjustify, d.adjustify.x + "*" + d.adjustify.y), window.history.replaceState(null, null, "?" + c) } l.writeToIndexedDB && (d.id = l.name, FamilyTree.idb.put(d, (function(e) { 0 == e && console.error("Cannot write row - " + l.name) } ))), l.writeToLocalStorage && FamilyTree.localStorage.setItem(l.name, JSON.stringify(d)) } } , FamilyTree.state._get = function(e, t, i, r) { if (e) { var a = FamilyTree.state._buildStateNames(e.name); if (e.readFromUrlParams) { var n = new URLSearchParams(window.location.search); if (n.has(a.paramScale) && n.has(a.paramX) && n.has(a.paramY) && n.has(a.paramExp) && n.has(a.paramMin) && n.has(a.paramAdjustify)) { var o = {} , l = parseFloat(n.get(a.paramScale)) , s = parseFloat(n.get(a.paramX)) , d = parseFloat(n.get(a.paramY)); (m = [])[0] = s, m[1] = d, m[2] = t / l, m[3] = i / l, o.vb = m, o.scale = l, o.x = s, o.y = d, o.roots = null, n.has(a.paramRoots) && (o.roots = n.get(a.paramRoots).split("*")), o.exp = n.get(a.paramExp).split("*"), o.min = n.get(a.paramMin).split("*"); var c = n.get(a.paramAdjustify).split("*"); return o.adjustify = { x: parseFloat(c[0]), y: parseFloat(c[1]) }, void r(o) } if (!e.readFromIndexedDB && !e.readFromLocalStorage) return void r(null) } if (e.readFromLocalStorage) { var m; if (null != (o = FamilyTree.localStorage.getItem(e.name))) return o = JSON.parse(o), (m = [])[0] = o.x, m[1] = o.y, m[2] = t / o.scale, m[3] = i / o.scale, o.vb = m, void r(o); if (!e.readFromIndexedDB) return void r(null) } e.readFromIndexedDB && FamilyTree.idb.read(e.name, (function(a, n) { if (0 == a) console.error("Cannot read from - " + e.name), r(null); else if (null == a) r(null); else { var o = []; o[0] = n.x, o[1] = n.y, o[2] = t / n.scale, o[3] = i / n.scale, n.vb = o, r(n) } } )) } else r(null) } , FamilyTree.state.clear = function(e) { if (!e) return !1; try { localStorage.removeItem(e); var t = FamilyTree.state._buildStateNames(e) , i = new URLSearchParams(window.location.search); i.has(t.paramScale) && i.delete(t.paramScale), i.has(t.paramX) && i.delete(t.paramX), i.has(t.paramY) && i.delete(t.paramY), i.has(t.paramExp) && i.delete(t.paramExp), i.has(t.paramRoots) && i.delete(t.paramRoots), i.has(t.paramMin) && i.delete(t.paramMin), i.has(t.paramAdjustify) && i.delete(t.paramAdjustify), window.history.replaceState(null, null, "?" + i), FamilyTree.idb.delete(e, (function(t) { 0 == t && console.error("Cannot delete row - " + e) } )) } catch {} } , FamilyTree._magnify = {}, FamilyTree.prototype.magnify = function(e, t, i, r, a) { r || (r = this.config.anim); var n = this.getNode(e) , o = this.getNodeElement(e); if (n || o) { var l = FamilyTree._magnify[e]; if (l && (null != l.timer && clearInterval(l.timer), null != l.timerBack && clearInterval(l.timerBack), o.setAttribute("transform", "matrix(" + l.transformStart.toString() + ")"), FamilyTree._magnify[e] = null), i) o = o.cloneNode(!0), this.getSvg().appendChild(o); var s = FamilyTree._getTransform(o) , d = JSON.parse(JSON.stringify(s)); d[0] = t, d[3] = t; var c = n.w + n.w * (t - 1) , m = n.h + n.h * (t - 1); d[4] += (n.w - c) / 2, d[5] += (n.h - m) / 2; var h = FamilyTree.animate(o, { transform: s }, { transform: d }, r.duration, r.func); FamilyTree._magnify[e] = { timer: h, transformStart: s, nodeElement: o, front: i }, a && a(o) } } , FamilyTree.prototype.magnifyBack = function(e, t, i) { t || (t = this.config.anim); var r = FamilyTree._magnify[e]; if (r) { null != r.timer && clearInterval(r.timer), null != r.timerBack && clearInterval(r.timerBack); var a = FamilyTree._getTransform(r.nodeElement); r.timerBack = FamilyTree.animate(r.nodeElement, { transform: a }, { transform: r.transformStart }, t.duration, t.func, (function(e) { var t = e[0].getAttribute(FamilyTree.attr.node_id); FamilyTree._magnify[t] && FamilyTree._magnify[t].front && (e[0].parentNode.removeChild(e[0]), FamilyTree._magnify[t] = null), i && i(e[0]) } )) } } , void 0 === FamilyTree && (FamilyTree = {}), FamilyTree.events.on("init", (function(e, t) { if (e.config.keyNavigation && (e._addEvent(window, "keydown", e._windowKeyDownHandler), FamilyTree.isNEU(e._keyNavigationActiveNodeId) && e.roots && e.roots.length)) { var i = e.roots[0].id; FamilyTree.isNEU(e.config.keyNavigation.focusId) || (i = e.config.keyNavigation.focusId), e._keyNavigationActiveNodeId = i, e.center(e._keyNavigationActiveNodeId) } } )), FamilyTree.prototype._windowKeyDownHandler = function(e, t) { for (var i = t.target, r = null; i && i != this.element; ) { if (i.hasAttribute && i.hasAttribute(FamilyTree.attr.node_id)) { r = i.getAttribute(FamilyTree.attr.node_id); break } i = i.parentNode } if (i) { var a = r ? this.getNode(r) : null , n = { node: a, data: r ? this.get(r) : null, event: t }; if (!1 !== FamilyTree.events.publish("key-down", [this, n]) && a) if ("KeyF" == t.code) this.searchUI.find(""); else if ("ArrowRight" == t.code || a.isAssistant && "ArrowDown" == t.code || a.isPartner && "ArrowDown" == t.code) { if (s = this.getNode(a.pid)) { var o = s.childrenIds.indexOf(a.id); if (++o < s.childrenIds.length) { var l = s.childrenIds[o]; this._keyNavigationActiveNodeId = l, this.center(l) } } } else if ("ArrowLeft" == t.code) { if (s = this.getNode(a.pid)) { o = s.childrenIds.indexOf(a.id); if (--o >= 0) { l = s.childrenIds[o]; this._keyNavigationActiveNodeId = l, this.center(l) } } } else if ("ArrowUp" == t.code) { var s; if (s = this.getNode(a.pid)) { l = s.id; if (a.isAssistant || s.hasAssistants || a.isPartner || s.hasPartners) { o = s.childrenIds.indexOf(a.id); --o >= 0 && (l = s.childrenIds[o]) } this._keyNavigationActiveNodeId = l, this.center(l) } } else if ("ArrowDown" == t.code) a.childrenIds.length && (this._keyNavigationActiveNodeId = a.childrenIds[0], this.center(a.childrenIds[0])); else if ("Space" == t.code) { var d = i.getAttribute(FamilyTree.attr.node_id); return void this.toggleExpandCollapse(d, t) } } } , FamilyTree.events.on("redraw", (function(e, t) { e.config.keyNavigation && FamilyTree._keyNavigation(e) } )), FamilyTree.events.on("click", (function(e, t) { e.config && e.config.keyNavigation && (e._keyNavigationActiveNodeId = t.node.id, e.center(t.node.id)) } )), FamilyTree._keyNavigation = function(e) { var t = e.element.querySelector(":focus"); if (t && t.parentElement && t.parentElement.hasAttribute(FamilyTree.attr.node_id)) { var i = t.parentElement; (a = (r = t).querySelector("title")) && a.parentNode.removeChild(a), r.removeAttribute("tabindex") } if (!FamilyTree.isNEU(e._keyNavigationActiveNodeId) && ((i = e.getNodeElement(e._keyNavigationActiveNodeId)) && i.children.length)) { var r; (r = i.children[0]).setAttribute("tabindex", 2); var a, n = { text: "", id: e._keyNavigationActiveNodeId }; if (FamilyTree.events.publish("screen-reader-text", [e, n]), !FamilyTree.isNEU(n.text)) (a = document.createElementNS("http://www.w3.org/2000/svg", "title")).innerHTML = n.text, r.appendChild(a); FamilyTree.SEARCH_CLOSE_RESULT_ON_ESCAPE_OR_CLICKOUTSIDE && e.searchUI.hide(), r.focus() } } , FamilyTree.elements = {}, FamilyTree.elements.textbox = function(e, t, i, r) { var a = FamilyTree.elements._vidrf(e, t, r); if (a.doNotRender) return { html: "" }; var n = ""; return t.btn && (n = `${t.btn}`), { html: `
\n
\n \n \n ${n}\n
\n
`, id: a.id, value: a.value } } , FamilyTree.elements.checkbox = function(e, t, i, r) { var a = FamilyTree.elements._vidrf(e, t, r); if (a.doNotRender) return { html: "" }; var n = a.value ? "checked" : "" , o = r ? 'onclick="return false;"' : ""; return { html: `
\n \n
`, id: a.id, value: n } } , FamilyTree.elements.select = function(e, t, i, r) { if (r) return FamilyTree.elements.textbox(e, t, i, r); var a = FamilyTree.elements._vidrf(e, t, r); return a.doNotRender ? { html: "" } : { html: `
\n
\n \n \n
\n
`, id: a.id, value: a.value } } , FamilyTree.elements.multiSelect = function(e, t, i, r) { if (r) return FamilyTree.elements.textbox(e, t, i, r); var a = FamilyTree.elements._vidrf(e, t, r); return a.doNotRender ? { html: "" } : { html: `
\n
\n \n \n
\n
`, id: a.id, value: a.value } } , FamilyTree.elements.date = function(e, t, i, r) { var a = FamilyTree.elements._vidrf(e, t, r); return a.doNotRender ? { html: "" } : { html: `
\n
\n \n \n
\n
`, id: a.id, value: a.value } } , FamilyTree.elements._vidrf = function(e, t, i) { var r = {}; if (t.binding || (t.binding = ""), t.label || (t.label = ""), "select" != t.type || Array.isArray(t.options) ? r.options = t.options : r.options = [], r.value = e && !FamilyTree.isNEU(e[t.binding]) ? e[t.binding] : "", i && r.options) for (var a = 0; a < r.options.length; a++) if (r.options[a].value == r.value) { r.value = r.options[a].text; break } if (r.id = FamilyTree.elements.generateId(), r.disabledAttribute = i ? "data-bft-input-disabled" : "", r.readOnlyAttribute = i ? "readonly" : "", r.id = r.id, i && FamilyTree.isNEU(r.value) && (r.doNotRender = !0), i && "photo" == t.binding && (r.id = null, r.doNotRender = !0), r.binding = t.binding, r.label = t.label, r.vlidators = "", t.vlidators) for (var n in t.vlidators) r.vlidators += `data-v-${n}="${t.vlidators[n]}" `; return r } , FamilyTree.elements.ids = [], FamilyTree.elements.generateId = function() { for (; ; ) { var e = "_" + ("0000" + (Math.random() * Math.pow(36, 4) | 0).toString(36)).slice(-4); if (!FamilyTree.elements.ids.has(e)) return FamilyTree.elements.ids.push(e), e } } , FamilyTree.input = {}, FamilyTree.input._timeout = null, FamilyTree.input.initWithTimeout = function() { FamilyTree.input._timeout && (clearTimeout(FamilyTree.input._timeout), FamilyTree.input._timeout = null), FamilyTree.input._timeout = setTimeout(FamilyTree.input.init, 200) } , FamilyTree.input.init = function(e) { var t; t = e ? e.querySelectorAll("[data-bft-input]") : document.querySelectorAll("[data-bft-input]"); for (var i = 0; i < t.length; i++) { var r = t[i] , a = null; r.type && "hidden" == r.type.toLowerCase() && (a = r), a || (a = r.querySelector("input")), a || (a = r.querySelector("select")); var n = r.querySelector("label"); n && (a.value || "select-one" == a.type && a.selectedOptions && a.selectedOptions.length && "" == a.selectedOptions[0].value && a.selectedOptions[0].innerHTML) && n.classList.add("hasval"), "checkbox" != a.type.toLowerCase() && a.addEventListener("focus", (function() { this.classList.remove("bft-validation-error"); var e = this.parentNode.querySelector("label"); e.classList.add("focused"); var t = e.querySelector(".bft-validation-error-message"); t && t.parentNode.removeChild(t) } )), "checkbox" != a.type.toLowerCase() && a.addEventListener("blur", (function() { FamilyTree.input.blurHandler(this) } )) } } , FamilyTree.input.blurHandler = function(e) { var t = e.parentNode.querySelector("label"); t.classList.remove("focused"), e.value || "date" == e.type ? t.classList.add("hasval") : t.classList.remove("hasval") } , FamilyTree.input.validate = function(e) { var t = null; e.type && "hidden" == e.type.toLowerCase() && (t = e), t || (t = e.querySelector("input")), t || (t = e.querySelector("select")); var i = e.querySelector("label"); if (t.classList.remove("bft-validation-error"), i) { var r = i.querySelector(".bft-validation-error-message"); r && r.parentNode.removeChild(r) } !t.selectedOptions && t.value && (t.value = t.value.trim()); var a = e.getAttribute("data-v-required") , n = e.getAttribute("data-v-password") , o = e.getAttribute("data-v-email") , l = e.getAttribute("data-v-emails"); return a && "" == t.value ? (i.innerHTML += ' ' + a + "", t.classList.add("bft-validation-error"), !1) : n && !FamilyTree.input.validatePassword(t.value) ? (i.innerHTML += ' ' + n + "", t.classList.add("bft-validation-error"), !1) : o && !FamilyTree.input.isValidEmail(t.value) ? (i.innerHTML += ' ' + o + "", t.classList.add("bft-validation-error"), !1) : !(l && !FamilyTree.input.isValidEmails(t.value)) || (i.innerHTML += ' ' + l + "", t.classList.add("bft-validation-error"), !1) } , FamilyTree.input.validateAndGetData = function(e) { for (var t = e.querySelectorAll("[data-bft-input]"), i = !0, r = 0; r < t.length; r++) { var a = t[r]; FamilyTree.input.validate(a) || (i = !1) } if (!i) return !1; var n = e.querySelectorAll("[data-binding]") , o = {}; for (r = 0; r < n.length; r++) { var l = n[r] , s = l.getAttribute("data-binding"); if ("checkbox" == l.type.toLowerCase()) o[s] = l.checked; else if (l.selectedOptions && l.hasAttribute("multiple")) { var d = l.selectedOptions; o[s] = Array.from(d).map((({value: e})=>e)) } else o[s] = l.value } return o } , FamilyTree.input.validatePassword = function(e) { return e && (e = e.trim()), !(e.length < 5) && (!(e.length > 18) && -1 == e.indexOf(" ")) } , FamilyTree.input.isValidEmails = function(e) { if (e) for (var t = e.split(","), i = 0; i < t.length; i++) { var r = t[i].trim(); if (!FamilyTree.input.isValidEmail(r)) return !1 } return !0 } , FamilyTree.input.isValidEmail = function(e) { e && (e = e.trim()); return /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(String(e).toLowerCase()) } , FamilyTree.prototype.hideTreeMenu = function(e, t) { if (this._tree_menu_temp) { var i = this._tree_menu_temp; if (this.manager.oldNodes = this.nodes, this.nodes = i.nodes, this.manager.maxX = i.maxX, this.manager.maxY = i.maxY, this.manager.minX = i.minX, this.manager.minY = i.minY, this.manager.roots = i.roots, this.manager.nodes = i.nodes, this.manager.rootList = i.rootList, this.manager.visibleNodeIds = i.visibleNodeIds, this.manager.bordersByRootIdAndLevel = i.bordersByRootIdAndLevel, this.config.roots = i.config.roots, this.config.nodes = i.config.nodes, this._tree_menu_temp = null, e) { var r = { id: i.id, animFromClickedNode: !1 }; this._draw(!0, FamilyTree.action.update, r, (function() { t && t() } )) } } } , FamilyTree.prototype.showTreeMenu = function(e) { this.editUI.hide(), null == e && console.error("Call addNode without id"); var t = this.getNode(e); t || console.error("Cannot get node id: " + e); var i = this.getNode(t.fid) , r = this.getNode(t.mid) , a = null , n = null , o = [] , l = []; i && (a = this.get(i.id)), r && (n = this.get(r.id)); for (var s = 0; s < t.pids.length; s++) { var d = this.get(t.pids[s]); d && o.push(d) } for (s = 0; s < t.ftChildrenIds.length; s++) l.push(this.get(t.ftChildrenIds[s])); var c = this.get(e); this._tree_menu_temp = { maxX: this.manager.maxX, maxY: this.manager.maxY, minX: this.manager.minX, minY: this.manager.minY, roots: this.manager.roots, nodes: this.manager.nodes, rootList: this.manager.rootList, visibleNodeIds: this.manager.visibleNodeIds, bordersByRootIdAndLevel: this.manager.bordersByRootIdAndLevel, id: e, config: { roots: this.config.roots, nodes: this.config.nodes } }, this.config.nodes = []; var m = []; if (n) m.push(n); else { var h = { id: "_ft_mother", templateName: "mother", _ft_method: "addParentNode", _ft_childId: e, _ft_type: "mid", _ft_data: { gender: "female" } }; c.mid = h.id, a ? (a.pids = [h.id], h.pids = [a.id], h._ft_data.pids = [a.id]) : h.pids = ["_ft_father"], m.push(h) } if (a) m.push(a); else { var p = { id: "_ft_father", templateName: "father", _ft_method: "addParentNode", _ft_childId: e, _ft_type: "fid", _ft_data: { gender: "male" } }; c.fid = p.id, n ? (n.pids = [p.id], p.pids = [n.id], p._ft_data.pids = [n.id]) : p.pids = ["_ft_mother"], m.push(p) } for (s = 0; s < o.length; s++) m.push(o[s]); c.pids || (c.pids = []); var f = { id: "_ft_partner", pids: [e], templateName: "partner", _ft_method: "addPartnerNode", _ft_data: { pids: [e] } }; if ("male" == c.gender ? (f.templateName = "wife", f._ft_data.gender = "female") : "female" == c.gender && (f.templateName = "husband", f._ft_data.gender = "male"), c.pids.push(f.id), m.push(f), c.pids) for (s = 0; s < c.pids.length; s++) { if (m.push({ id: "_ft_child_group_" + s, mid: e, fid: c.pids[s], tags: ["children-group"] }), "_ft_partner" == c.pids[s]) { var u = { id: "_ft_son_" + s, stpid: "_ft_child_group_" + s, templateName: "son", _ft_method: "addChildAndPartnerNodes", _ft_childData: { mid: t.id, fid: f.id, gender: "male" }, _ft_partnerData: { pids: [e] }, _ft_id: e } , y = { id: "_ft_daughter_" + s, stpid: "_ft_child_group_" + s, templateName: "daughter", _ft_method: "addChildAndPartnerNodes", _ft_childData: { mid: t.id, fid: f.id, gender: "female" }, _ft_partnerData: { pids: [e] }, _ft_id: e }; "male" == c.gender && "female" == f._ft_data.gender ? (u._ft_childData.mid = f.id, u._ft_childData.fid = c.id, u._ft_partnerData.gender = f._ft_data.gender, y._ft_childData.mid = f.id, y._ft_childData.fid = c.id, y._ft_partnerData.gender = f._ft_data.gender) : "female" == c.gender && "male" == f._ft_data.gender && (u._ft_childData.mid = c.id, u._ft_childData.fid = f.id, u._ft_partnerData.gender = f._ft_data.gender, y._ft_childData.mid = c.id, y._ft_childData.fid = f.id, y._ft_partnerData.gender = f._ft_data.gender), m.push(u), m.push(y) } else m.push({ id: "_ft_son_" + s, stpid: "_ft_child_group_" + s, templateName: "son", _ft_method: "addChildNode", _ft_data: { mid: e, fid: c.pids[s], gender: "male" } }), m.push({ id: "_ft_daughter_" + s, stpid: "_ft_child_group_" + s, templateName: "daughter", _ft_method: "addChildNode", _ft_data: { mid: e, fid: c.pids[s], gender: "female" } }); for (var g = 0; g < l.length; g++) l[g].mid != c.pids[s] && l[g].fid != c.pids[s] || (l[g].mid = void 0, l[g].fid = void 0, l[g].stpid = "_ft_child_group_" + s, m.push(l[g])) } var v = []; for (g = 0; g < l.length; g++) (l[g].fid == c.id && FamilyTree.isNEU(l[g].mid) || l[g].mid == c.id && FamilyTree.isNEU(l[g].fid)) && (l[g].fid == c.id ? l[g].mid = "_ft_partner_for_single_child" : l[g].mid == c.id && (l[g].fid = "_ft_partner_for_single_child"), m.push(l[g]), v.push(l[g].id)); if (v.length) { var T = { id: "_ft_partner_for_single_child", pids: [e], templateName: "partner", _ft_method: "addPartnerAndParentNodes", _ft_childIds: v, _ft_partnerData: { pids: [e] }, _ft_id: e }; "male" == c.gender ? (T.templateName = "wife", T._ft_partnerData.gender = "female") : "female" == c.gender && (T.templateName = "husband", T._ft_partnerData.gender = "male"), c.pids.push(T.id), m.push(T) } var b = { nodes: m, node: c }; FamilyTree.events.publish("node-tree-menu-show", [this, b]), b.nodes.push(b.node), this.config.nodes = b.nodes, c = this.get(e); var F = this; FamilyTree.isNEU(c.mid) ? FamilyTree.isNEU(c.fid) || (this.config.roots = [c.fid]) : this.config.roots = [c.mid]; var x = { id: e, treeMenuMode: !0 }; this._draw(!1, FamilyTree.action.update, x, (function() { FamilyTree._moveToBoundaryArea(F.getSvg(), F.getViewBox(), F.response.boundary) } )) } , FamilyTree.ui.css = function() { return '' } , FamilyTree.events.on("render", (function(e, t) { if (e.recentRoots || (e.recentRoots = []), e.config.roots) for (var i = 0; i < e.config.roots.length; i++) { var r = e.recentRoots.indexOf(e.config.roots[i]); -1 != r && e.recentRoots.splice(r, 1), e.recentRoots.unshift(e.config.roots[i]) } } )), FamilyTree.events.on("show", (function(e, t) { if (e instanceof FamilyTree.editUI && e.obj._tree_menu_temp) return !1 } )), FamilyTree.events.on("render-link", (function(e, t) { null != t.cnode.ppid && t.cnode.layout != FamilyTree.mixed && (t.html += '') } )), FamilyTree.events.on("click", (function(e, t) { if (e instanceof FamilyTree) { var i = e._get(t.node.id); if (i._ft_method) return "addParentNode" == i._ft_method ? e[i._ft_method](i._ft_childId, i._ft_type, i._ft_data, null, !0) : "addChildAndPartnerNodes" == i._ft_method ? e[i._ft_method](i._ft_id, i._ft_childData, i._ft_partnerData, null, !0) : "addPartnerAndParentNodes" == i._ft_method ? e[i._ft_method](i._ft_id, i._ft_childIds, i._ft_partnerData, null, !0) : e[i._ft_method](i._ft_data, null, !0), !1; for (var r = t.event.target; r; ) { if (r.getAttribute && (r.hasAttribute("data-ctrl-n-t-menu-id") || r.hasAttribute("data-ctrl-n-t-menu-c"))) { var a = r.getAttribute("data-ctrl-n-t-menu-id"); return FamilyTree.isNEU(a) ? e.hideTreeMenu(!0) : e.showTreeMenu(a), t.event.stopPropagation(), t.event.preventDefault(), !1 } r = r.parentNode } } } )), void 0 === FamilyTree && (FamilyTree = {}), FamilyTree.prototype.onField = function(e) { return this.on("field", (function(t, i) { return e.call(t, i) } )) } , FamilyTree.prototype.onInit = function(e) { return this.on("init", (function(t) { return e.call(t) } )) } , FamilyTree.prototype.onRedraw = function(e) { return this.on("redraw", (function(t) { return e.call(t) } )) } , FamilyTree.prototype.onUpdateNode = function(e) { return this.on("update", (function(t, i, r) { var a = { oldData: i, newData: r }; return e.call(t, a) } )) } , FamilyTree.prototype.onUpdated = function(e) { return this.on("updated", (function(t) { return e.call(t) } )) } , FamilyTree.prototype.onRemoveNode = function(e) { return this.on("remove", (function(t, i, r) { var a = { id: i, newPidsAndStpidsForIds: r }; return e.call(t, a) } )) } , FamilyTree.prototype.onAddNode = function(e) { return this.on("add", (function(t, i) { var r = { data: i }; return e.call(t, r) } )) } , FamilyTree.prototype.onDrop = function(e) { return this.on("drop", (function(t, i, r, a, n) { var o = { dragId: i, dropId: r, dragNodeElement: a, event: n }; return e.call(t, o) } )) } , FamilyTree.prototype.onDrag = function(e) { return this.on("drag", (function(t, i, r, a) { var n = { dragId: i, event: r, nodeIds: a }; return e.call(t, n) } )) } , FamilyTree.prototype.onExpandCollpaseButtonClick = function(e) { return this.on("expcollclick", (function(t, i, r, a) { var n = { collapsing: i, id: r, ids: a }; return e.call(t, n) } )) } , FamilyTree.prototype.onExportStart = function(e) { return this.on("exportstart", (function(t, i) { return e.call(t, i) } )) } , FamilyTree.prototype.onExportEnd = function(e) { return this.on("exportend", (function(t, i) { return e.call(t, i) } )) } , FamilyTree.prototype.onNodeClick = function(e) { return this.on("click", (function(t, i) { return e.call(t, i) } )) } , FamilyTree.prototype.onNodeDoubleClick = function(e) { return this.on("dbclick", (function(t, i) { var r = { data: i }; return e.call(t, r) } )) } , FamilyTree.prototype.onUpdateNode = function(e) { return this.on("update", (function(t, i) { return e.call(t, i) } )) } , FamilyTree.prototype.onNodeTreeMenuShow = function(e) { return this.on("node-tree-menu-show", (function(t, i) { return e.call(t, i) } )) } , FamilyTree.prototype.onRemoveNode = null, FamilyTree.prototype.onAddNode = null, FamilyTree.filterUI = function() {} , FamilyTree.filterUI.prototype.init = function(e) { this.instance = e, this.element = null, this.filterBy = null, this._event_id = FamilyTree._guid() } , FamilyTree.filterUI.prototype.addFilterTag = function(e) { if (!this.instance.config.filterBy) return !1; if (FamilyTree.isNEU(e)) return !1; if (null !== this.filterBy || "object" != typeof this.instance.config.filterBy || Array.isArray(this.instance.config.filterBy) || (this.filterBy = JSON.parse(JSON.stringify(this.instance.config.filterBy))), null != this.filterBy) for (var t in this.filterBy) { var i = e[t]; if (null != i) { var r = this.filterBy[t]; if (null != r) { var a = r[i]; if (null != a && !1 === a.checked) return !0 } } } return !1 } , FamilyTree.filterUI.prototype.show = function(e) { var t = this.element.querySelector('[data-filter-field="' + e + '"]'); t && t.click() } , FamilyTree.filterUI.prototype.hide = function() { var e = this.instance.element.querySelector("[data-filter-close]"); e && e.click() } , FamilyTree.filterUI.prototype.update = function() { if (this.instance.config.filterBy) { var e = {}; if ("all" == this.instance.config.filterBy) for (var t = FamilyTree.manager.getAllFields(this.instance.config), i = 0; i < t.length; i++) { var r = t[i]; "tags" != r && "id" != r && "pid" != r && "ppid" != r && "stpid" != r && (e[r] = {}) } else if (Array.isArray(this.instance.config.filterBy)) for (i = 0; i < this.instance.config.filterBy.length; i++) e[this.instance.config.filterBy[i]] = {}; else if ("object" == typeof this.instance.config.filterBy) for (var a in this.instance.config.filterBy) e[a] = {}; for (var n in e) { var o = e[n]; for (i = 0; i < this.instance.config.nodes.length; i++) { var l = this.instance.config.nodes[i][n]; null != l && (o[l] || (o[l] = { checked: !0, text: l })) } } if (null != this.filterBy) for (var s in e) if (this.filterBy[s]) for (var d in e[s]) this.filterBy[s][d] && (e[s][d] = this.filterBy[s][d]); if (FamilyTree.FILTER_ALPHABETICALLY) { var c = Object.keys(e).sort() , m = e; e = {}; for (i = 0; i < c.length; i++) { e[h = c[i]] = m[h] } for (var n in e) { o = e[n]; e[n] = {}; for (c = Object.keys(o).sort(), i = 0; i < c.length; i++) { var h = c[i]; e[n][h] = o[h] } } } this.filterBy = e; var p = this; this.element = this.instance.element.querySelector("[data-filter]"), this.element && this.element.parentNode.removeChild(this.element), this.element = document.createElement("div"), this.element.setAttribute("data-filter", ""), this.element.style.position = "absolute", this.element.setAttribute("class", "bft-filter"), this.instance.config.undoRedoStorageName ? (this.element.style.top = 0, this.element.style.left = "50%", this.element.style.transform = "translate(-50%)") : (this.element.style.top = this.instance.config.padding + "px", this.element.style.left = this.instance.config.padding + "px"); var f = ""; for (var s in this.filterBy) { var u = { name: s, html: `
${s}
` }; FamilyTree.events.publish("add-filter", [p, u]), f += u.html } this.element.innerHTML = `
${f}
`, this.element.addEventListener("click", (function(e) { if (e.target.hasAttribute("data-filter-close") || e.target.hasAttribute("data-filter-field")) { for (var t = e.target.getAttribute("data-filter-field"), i = p.instance.element.querySelectorAll("[data-filter-menu]"), r = 0; r < i.length; r++) i[r].style.display = "none"; var a = p.instance.element.querySelectorAll(".filter-field-selected"); for (r = 0; r < a.length; r++) a[r].classList.remove("filter-field-selected"); var n = p.instance.element.querySelector("[data-filter-close]"); if (n && n.parentNode.removeChild(n), e.target.hasAttribute("data-filter-close")) return; if (!e.target.hasAttribute("data-filter-field")) return; var o = p.instance.element.querySelector(`[data-filter-menu="${t}"]`); if (!o) { var l = { name: t, text: FamilyTree.filterUI.all, value: t, checked: !0, html: `
\n \n \n
` }; FamilyTree.events.publish("add-item", [p, l]); var s = l.html; for (var d in p.filterBy[t]) { var c = p.filterBy[t][d] , m = c.text; null == m && (m = d), l = { name: t, text: m, value: d, checked: c.checked, html: `
\n \n \n
` }, FamilyTree.events.publish("add-item", [p, l]), s += l.html } o = document.createElement("div"); var h = FamilyTree.filterUI.textFilterBy; o.innerHTML = `
\n ${h} ${t}:\n ${s}\n
`, o.setAttribute("data-filter-menu", t), o.classList.add("bft-filter-menu"), e.target.parentNode.parentNode.appendChild(o); var f = o.querySelectorAll("input"); for (r = 0; r < f.length; r++) f[r].addEventListener("change", (function(e) { for (var t = e.target; t && !t.hasAttribute("data-filter-menu"); ) t = t.parentNode; if (t) { var i = t.getAttribute("data-filter-menu"); if (e.target.hasAttribute("data-all")) { for (var r = e.target.parentNode.parentNode.querySelectorAll("input"), a = 0; a < r.length; a++) if (r[a] != e.target) for (var n in r[a].checked = e.target.checked, p.filterBy[i]) p.filterBy[i][n].checked = e.target.checked } else if (null != p.filterBy[i][this.name] && (p.filterBy[i][this.name].checked = this.checked), this.checked) for (var o = p.instance.config.nodes, l = 0; l < o.length; l++) if (o[l][i] == this.name) for (var s = o[l]; s; ) if (FamilyTree.isNEU(s.stpid)) s = FamilyTree.isNEU(s.pid) ? null : p.instance._get(s.pid); else if ((s = p.instance._get(s.stpid))[i]) { var d = e.target.parentNode.parentNode.querySelector('[name="' + s[i] + '"]'); d ? (d.checked = this.checked, p.filterBy[i][s[i]].checked = this.checked) : console.error('Cannot find element with selector: [name="' + s[i] + '"]') } p.instance.draw() } } )) } o.style.display = "block", e.target.classList.add("filter-field-selected"), (n = document.createElement("div")).classList.add("close"), n.innerHTML = "x", n.setAttribute("data-filter-close", ""), e.target.parentNode.appendChild(n), FamilyTree.events.publish("show-items", [p, { name: t }]) } } )), this.instance.element.appendChild(this.element), FamilyTree.events.publish("update", [this, {}]) } } , FamilyTree.filterUI.prototype.on = function(e, t) { return FamilyTree.events.on(e, t, this._event_id), this } , FamilyTree.filterUI.textFilterBy = "Filter by", FamilyTree.filterUI.all = "[All]", void 0 === FamilyTree && (FamilyTree = {}), void 0 === FamilyTree.remote && (FamilyTree.remote = {}), FamilyTree.LIMIT_NODES = !0, FamilyTree.remote._fromResDTO = function(e, t, i, r, a) { var n = t[e.id]; e.x = n.p[0], e.y = n.p[1], e.w = n.p[2], e.h = n.p[3], null != n.ln && (e.leftNeighbor = a[n.ln]), null != n.rn && (e.rightNeighbor = a[n.rn]); for (var o = 0; o < e.stChildren.length; o++) FamilyTree.remote._fromResDTO(e.stChildren[o], t, i, r, a); for (o = 0; o < e.children.length; o++) FamilyTree.remote._fromResDTO(e.children[o], t, i, r, a) } ; FamilyTree.remote._toReqDTO = function(e, t) { var i = { p: [e.id, null != e.parent ? e.parent.id : null, null != e.stParent ? e.stParent.id : null, e.w, e.h] }; e.children.length > 0 && (i.c = FamilyTree.remote._convertToIdArray(e.children)), e.stChildren.length > 0 && (i.v = FamilyTree.remote._convertToIdArray(e.stChildren)), null != e.layout && 0 != e.layout && (i.l = e.layout), e.isAssistant && (i.a = 1), e.isSplit && (i.s = e.isSplit), e.isMirror && (i.im = e.isMirror), e.padding && (i.q = e.padding), e.lcn && (i.k = e.lcn), e.stContainerNodes && (i.b = FamilyTree.remote._convertToIdArray(e.stContainerNodes)), e.isPartner && (i.i = e.isPartner), e.hasPartners && (i.g = e.hasPartners), e.partnerSeparation && (i.e = e.partnerSeparation), t.push(i); for (var r = 0; r < e.stChildren.length; r++) FamilyTree.remote._toReqDTO(e.stChildren[r], t); for (r = 0; r < e.children.length; r++) FamilyTree.remote._toReqDTO(e.children[r], t) } , FamilyTree.remote._toReqLayoutConfigsDTO = function(e) { var t = {}; for (var i in e) { var r = e[i]; t[i] || (t[i] = []), t[i][0] = r.orientation, t[i][1] = r.levelSeparation, t[i][2] = r.mixedHierarchyNodesSeparation, t[i][3] = r.subtreeSeparation, t[i][4] = r.siblingSeparation, t[i][5] = r.layout, t[i][6] = r.columns, t[i][7] = r.collapse, t[i][8] = r.assistantSeparation, t[i][9] = r.partnerNodeSeparation } return t } , FamilyTree.remote._convertToIdArray = function(e) { for (var t = [], i = 0; i < e.length; i++) t.push(e[i].id); return t } , FamilyTree.remote._setPositions = function(e, t, i, r) { for (var a = [], n = [], o = FamilyTree.remote._toReqLayoutConfigsDTO(t), l = 0; l < e.length; l++) n.push(e[l].id), FamilyTree.remote._toReqDTO(e[l], a); var s = { n: a, c: o, r: n, v: "8.14.00" }; if (FamilyTree.LIMIT_NODES || (s.l = !0), null != FamilyTree.remote._fromReqDTO) FamilyTree.remote._fromReqDTO(s.n, s.r, s.c, (function(t) { for (var a = 0; a < e.length; a++) FamilyTree.remote._fromResDTO(e[a], t, 0, e, r); i() } )); else { s = JSON.stringify(s); var d = FamilyTree.localStorage.getItem(s); d && (d = JSON.parse(d)), d && !d.limit ? FamilyTree.remote._proceed(e, d, r, i) : FamilyTree.remote._findRegion((function(t) { FamilyTree._ajax(t, "post", s, "json", (function(t) { t.error ? i(2) : (FamilyTree.remote._proceed(e, t, r, i), FamilyTree.localStorage.setItem(s, JSON.stringify(t))) } )) } )) } } , FamilyTree.remote._proceed = function(e, t, i, r) { if ("string" == typeof t && (t = JSON.parse(t)), t.limit && 1 == t.limit) r(t.limit); else { for (var a = 0; a < e.length; a++) FamilyTree.remote._fromResDTO(e[a], t, 0, e, i); r() } } , FamilyTree.remote._findRegion = function(e) { var t = FamilyTree.localStorage.getItem(FamilyTree.FUNC_URL_NAME); if (t) e(t); else { for (var i = ["defunc2", "cusfunc2", "bsfunc2", "acfunc2", "kcfunc2", "safunc2", "wifunc2"], r = [], a = 0; a < i.length; a++) r.push(new XMLHttpRequest); for (a = 0; a < i.length; a++) !function() { var t = "https://" + i[a] + FamilyTree.SERVER_PREFIX , n = r[a]; n.onreadystatechange = function() { if (4 == this.readyState && 200 == this.status) { FamilyTree.localStorage.setItem(FamilyTree.FUNC_URL_NAME, t), e(t); for (var i = 0; i < r.length; i++) r[i].abort() } } , n.open("GET", t, !0), n.send() }() } } ;