{"version":3,"file":"js/decidim_assemblies.js","mappings":";;;;;;;;;;;;;;AAAA;AACA;;AAEA;AACA;;;;;;;;;;ACJA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;ACbA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AAAA;AAAA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAQA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AAAA;AAAA;AAAA;AAGA;;AAEA;AACA;AAAA;AAAA;AAAA;;AAGA;;AAEA;AACA;AAAA;AAAA;AAAA;;AAEA;AACA;AAAA;AAAA;AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AAAA;AACA;AAAA;AAEA;AACA;AAAA;AACA;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AAAA;AACA;AAEA;;AAKA;AACA;AACA;AAAA;AACA;AAEA;;AAIA;AACA;;AAMA;AACA;AAKA;AAEA;AAAA;AAEA;AACA;AACA;AAEA;AACA;AAAA;AACA;AAAA;AACA;AAAA;AACA;AAAA;;AAEA;AACA;AAEA;AAAA;AAGA;AAAA;AACA;AAAA;AAEA;AAEA;AAAA;AAEA;AAAA;AAEA;AAAA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AAAA;AAAA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AACA;AACA;AAAA;AACA;AAAA;AACA;AAAA;AACA;AAAA;;AAEA;AACA;AACA;AAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AAAA;;AAGA;AACA;AACA;AACA;;AAEA;AACA;AAAA;AAAA;;AAEA;AACA;AAAA;AAAA;AAAA;AAAA;;AAEA;AACA;AACA;AAAA;;AAGA;AACA;;AAGA;AACA;AACA;AAAA;AAEA;;AAEA;AACA;AACA;AACA;AAEA;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAGA;AACA;;AAEA;AACA;AACA;AACA;AAEA;AAAA;AACA;AACA;AACA;AAAA;AAAA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AAAA;AACA;AACA;AACA;AAAA;AAAA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AAAA;AAEA;AAAA;AACA;AAAA;AAAA;AAAA;AACA;AAAA;AACA;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;;AAEA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AAAA;AAAA;AACA;AAEA;AACA;AAEA;AACA;;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAMA;AACA;AAGA;AACA;;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;AC5rBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;ACtBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AC1BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AC7BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;ACPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;ACPA;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;ACNA;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AElDA;AACA;AACA;AACA;AACA","sources":["webpack://decidim-app/../usr/local/bundle/gems/decidim-assemblies-0.27.2/app/packs/entrypoints/decidim_assemblies.js","webpack://decidim-app/../usr/local/bundle/gems/decidim-assemblies-0.27.2/app/packs/src/decidim/assemblies/assemblies.js","webpack://decidim-app/../usr/local/bundle/gems/decidim-assemblies-0.27.2/app/packs/src/decidim/assemblies/orgchart.js","webpack://decidim-app/../usr/local/bundle/gems/decidim-assemblies-0.27.2/app/packs/images/ sync ^\\.\\/.*$","webpack://decidim-app/webpack/bootstrap","webpack://decidim-app/webpack/runtime/chunk loaded","webpack://decidim-app/webpack/runtime/compat get default export","webpack://decidim-app/webpack/runtime/define property getters","webpack://decidim-app/webpack/runtime/hasOwnProperty shorthand","webpack://decidim-app/webpack/runtime/make namespace object","webpack://decidim-app/webpack/runtime/publicPath","webpack://decidim-app/webpack/runtime/jsonp chunk loading","webpack://decidim-app/webpack/before-startup","webpack://decidim-app/webpack/startup","webpack://decidim-app/webpack/after-startup"],"sourcesContent":["import \"src/decidim/assemblies/assemblies\"\nimport \"src/decidim/assemblies/orgchart\"\n\n// Images\nrequire.context(\"../images\", true)\n","$(() => {\n $(\".show-more\").on(\"click\", function() {\n /* eslint-disable no-invalid-this */\n $(this).hide();\n $(\".show-more-panel\").removeClass(\"hide\");\n $(\".hide-more\").show();\n });\n\n $(\".hide-more\").on(\"click\", function() {\n $(this).hide();\n $(\".show-more-panel\").addClass(\"hide\");\n $(\".show-more\").show();\n });\n})\n","/* eslint-disable require-jsdoc, max-lines, no-return-assign, func-style, id-length, no-plusplus, no-use-before-define, no-negated-condition, init-declarations, no-invalid-this, no-param-reassign, no-ternary, multiline-ternary, no-nested-ternary, no-eval, no-extend-native, prefer-reflect */\n/* eslint dot-location: [\"error\", \"property\"], no-negated-condition: \"error\" */\n/* eslint no-unused-expressions: [\"error\", { \"allowTernary\": true }] */\n/* eslint no-unused-vars: 0 */\n\nimport { select, selectAll, event } from \"d3-selection\";\nimport { max } from \"d3-array\";\nimport { hierarchy } from \"d3-hierarchy\";\nimport { forceManyBody, forceCollide, forceCenter, forceX, forceY, forceSimulation, forceLink } from \"d3-force\";\nimport { drag } from \"d3-drag\";\nimport { json } from \"d3-fetch\";\n\n// lib\nconst renderOrgCharts = () => {\n const $orgChartContainer = $(\".js-orgchart\")\n const $btnReset = $(\".js-reset-orgchart\")\n\n let dataDepicted = null\n let fake = false\n let orgchart = {}\n\n // lib - https://bl.ocks.org/bumbeishvili/b96ba47ea21d14dfce6ebb859b002d3a\n const renderChartCollapsibleNetwork = (params) => {\n\n // exposed variables\n let attrs = {\n id: `id${Math.floor(Math.random() * 1000000)}`,\n svgWidth: 960,\n svgHeight: 600,\n marginTop: 0,\n marginBottom: 5,\n marginRight: 0,\n marginLeft: 30,\n container: \"body\",\n distance: 150,\n hiddenChildLevel: 1,\n hoverOpacity: 0.2,\n maxTextDisplayZoomLevel: 1,\n lineStrokeWidth: 1.5,\n fakeRoot: false,\n nodeGutter: { x: 16, y: 8 },\n childrenIndicatorRadius: 15,\n fakeBorderWidth: 32,\n data: null\n }\n\n /* ############### IF EXISTS OVERWRITE ATTRIBUTES FROM PASSED PARAM ####### */\n\n let attrKeys = Object.keys(attrs)\n attrKeys.forEach(function (key) {\n if (params && params[key]) {\n attrs[key] = params[key]\n }\n })\n\n // innerFunctions which will update visuals\n let updateData\n let collapse, expand\n let filter\n let _hierarchy = {}\n\n // main chart object\n let main = function (_selection) {\n _selection.each(function scope() {\n\n // calculated properties\n let calc = {}\n calc.chartLeftMargin = attrs.marginLeft\n calc.chartTopMargin = attrs.marginTop\n calc.chartWidth = attrs.svgWidth - attrs.marginRight - calc.chartLeftMargin\n calc.chartHeight = attrs.svgHeight - attrs.marginBottom - calc.chartTopMargin\n\n // ########################## HIERARCHY STUFF #########################\n _hierarchy.root = hierarchy(attrs.data.root)\n\n // ########################### BEHAVIORS #########################\n let behaviors = {}\n // behaviors.zoom = zoom().scaleExtent([0.75, 100, 8]).on(\"zoom\", zoomed)\n behaviors.drag = drag().on(\"start\", dragstarted).on(\"drag\", dragged).on(\"end\", dragended)\n\n // ########################### LAYOUTS #########################\n let layouts = {}\n\n // custom radial layout\n layouts.radial = radial()\n\n // ########################### FORCE STUFF #########################\n let force = {}\n force.link = forceLink().id((d) => d.id)\n force.charge = forceManyBody().strength(-240)\n force.center = forceCenter(calc.chartWidth / 2, calc.chartHeight / 2)\n\n // prevent collide\n force.collide = forceCollide().radius((d) => {\n // Creates an invented radius based on element measures: diagonal = 2 * radius = sqrt(width^2, height^2)\n let base = (d.bbox || {}).width + (attrs.nodeGutter.x * 2)\n let height = (d.bbox || {}).height + (attrs.nodeGutter.y * 2)\n let diagonal = Math.sqrt(Math.pow(base, 2) + Math.pow(height, 2))\n let fakeRadius = (diagonal / 2)\n\n // return max([attrs.nodeDistance * 3, fakeRadius])\n return fakeRadius * 1.5\n })\n\n // manually set x positions (which is calculated using custom radial layout)\n force.x = forceX()\n .strength(0.5)\n .x(function (d) {\n\n // if node does not have children and is channel (depth=2) , then position it on parent's coordinate\n if (!d.children && d.depth > 2) {\n if (d.parent) {\n d = d.parent\n }\n }\n\n // custom circle projection - radius will be - (d.depth - 1) * 150\n return projectCircle(d.proportion, (d.depth - 1) * attrs.distance)[0]\n })\n\n // manually set y positions (which is calculated using cluster)\n force.y = forceY()\n .strength(0.5)\n .y(function (d) {\n\n // if node does not have children and is channel (depth=2) , then position it on parent's coordinate\n if (!d.children && d.depth > 2) {\n if (d.parent) {\n d = d.parent\n }\n }\n\n // custom circle projection - radius will be - (d.depth - 1) * 150\n return projectCircle(d.proportion, (d.depth - 1) * attrs.distance)[1]\n })\n\n // --------------------------------- INITIALISE FORCE SIMULATION ----------------------------\n\n // get based on top parameter simulation\n force.simulation = forceSimulation()\n .force(\"link\", force.link)\n .force(\"charge\", force.charge)\n .force(\"center\", force.center)\n .force(\"collide\", force.collide)\n .force(\"x\", force.x)\n .force(\"y\", force.y)\n\n // ########################### HIERARCHY STUFF #########################\n\n // flatten root\n let arr = flatten(_hierarchy.root)\n\n // hide members based on their depth\n arr.forEach((d) => {\n // Hide fake root node\n if ((attrs.fakeRoot) && (d.depth === 1)) {\n d.hidden = true\n }\n\n if (d.depth > attrs.hiddenChildLevel) {\n d._children = d.children\n d.children = null\n }\n })\n\n // #################################### DRAWINGS #######################\n\n // drawing containers\n let container = select(this)\n\n // add svg\n let svg = patternify(container, { tag: \"svg\", selector: \"svg-chart-container\" })\n .attr(\"width\", attrs.svgWidth)\n .attr(\"height\", attrs.svgHeight)\n // .call(behaviors.zoom)\n\n // add container g element\n let chart = patternify(svg, { tag: \"g\", selector: \"chart\" })\n .attr(\"transform\", `translate(${calc.chartLeftMargin},${calc.chartTopMargin})`)\n\n // ################################ Chart Content Drawing ##################################\n\n // link wrapper\n let linksWrapper = patternify(chart, { tag: \"g\", selector: \"links-wrapper\" })\n\n // node wrapper\n let nodesWrapper = patternify(chart, { tag: \"g\", selector: \"nodes-wrapper\" })\n let links, nodes\n\n // reusable function which updates visual based on data change\n update()\n\n // update visual based on data change\n function update(clickedNode) {\n\n // Show/hide reset button\n (clickedNode) ? $btnReset.removeClass(\"invisible\") : $btnReset.addClass(\"invisible\")\n\n // set xy and proportion properties with custom radial layout\n layouts.radial(_hierarchy.root)\n\n // nodes and links array\n let nodesArr = flatten(_hierarchy.root, true)\n .orderBy((d) => d.depth)\n .filter((d) => !d.hidden)\n\n let linksArr = _hierarchy.root.links()\n .filter((d) => !d.source.hidden)\n .filter((d) => !d.target.hidden)\n\n // make new nodes to appear near the parents\n nodesArr.forEach(function (d) {\n if (clickedNode && clickedNode.id === (d.parent && d.parent.id)) {\n d.x = d.parent.x\n d.y = d.parent.y\n }\n })\n\n // links\n links = linksWrapper.selectAll(\".link\")\n .data(linksArr, (d) => d.target.id)\n links.exit().remove()\n\n links = links.enter()\n .append(\"line\")\n .attr(\"class\", \"link\")\n .merge(links)\n\n // node groups\n nodes = nodesWrapper.selectAll(\".node\")\n .data(nodesArr, (d) => d.id)\n nodes.exit().remove()\n\n let enteredNodes = nodes.enter()\n .append(\"g\")\n .attr(\"class\", \"node\")\n\n // bind event handlers\n enteredNodes\n .on(\"click\", nodeClick)\n .on(\"mouseenter\", nodeMouseEnter)\n .on(\"mouseleave\", nodeMouseLeave)\n .call(behaviors.drag)\n\n // channels grandchildren\n enteredNodes.append(\"rect\")\n .attr(\"class\", \"as-card\")\n .attr(\"rx\", 4)\n .attr(\"ry\", 4)\n\n enteredNodes.append(\"text\")\n .attr(\"class\", \"as-text\")\n .text((d) => d.data.name)\n\n enteredNodes.selectAll(\"text\").each(function(d) {\n d.bbox = this.getBBox()\n })\n\n enteredNodes.selectAll(\"rect\")\n .attr(\"x\", (d) => d.bbox.x - attrs.nodeGutter.x)\n .attr(\"y\", (d) => d.bbox.y - attrs.nodeGutter.y)\n .attr(\"width\", (d) => d.bbox.width + (2 * attrs.nodeGutter.x))\n .attr(\"height\", (d) => d.bbox.height + (2 * attrs.nodeGutter.y))\n\n // append circle & text only when there are children\n enteredNodes\n .append(\"circle\")\n .filter((d) => Boolean(d.children) || Boolean(d._children))\n .attr(\"class\", \"as-circle\")\n .attr(\"r\", attrs.childrenIndicatorRadius)\n .attr(\"cx\", (d) => d.bbox.x + d.bbox.width + attrs.nodeGutter.x)\n .attr(\"cy\", (d) => d.bbox.y + d.bbox.height + attrs.nodeGutter.y)\n\n enteredNodes\n .append(\"text\")\n .filter((d) => Boolean(d.children) || Boolean(d._children))\n .attr(\"class\", \"as-text\")\n .attr(\"dx\", (d) => d.bbox.x + d.bbox.width + attrs.nodeGutter.x)\n .attr(\"dy\", attrs.childrenIndicatorRadius + 3)\n .text((d) => max([(d.children || {}).length, (d._children || {}).length]))\n\n // merge node groups and style it\n nodes = enteredNodes.merge(nodes)\n\n // force simulation\n force.simulation.nodes(nodesArr).on(\"tick\", ticked)\n\n // links simulation\n force.simulation.force(\"link\").links(links).id((d) => d.id).distance(attrs.distance * 2).strength(2)\n }\n\n // ####################################### EVENT HANDLERS ########################\n\n // zoom handler\n // function zoomed() {\n // // get transform event\n // let transform = event.transform\n // attrs.lastTransform = transform\n //\n // // apply transform event props to the wrapper\n // chart.attr(\"transform\", transform)\n //\n // svg.selectAll(\".node\").attr(\"transform\", (d) => `translate(${d.x},${d.y}) scale(${1 / (attrs.lastTransform ? attrs.lastTransform.k : 1)})`)\n // svg.selectAll(\".link\").attr(\"stroke-width\", attrs.lineStrokeWidth / (attrs.lastTransform ? attrs.lastTransform.k : 1))\n // }\n\n // tick handler\n function ticked() {\n const fakeBorderWidth = attrs.fakeBorderWidth\n const maxXValueAvailable = (value) => Math.max(Math.min(calc.chartWidth - fakeBorderWidth, value), fakeBorderWidth)\n const maxYValueAvailable = (value) => Math.max(Math.min(calc.chartHeight - fakeBorderWidth, value), fakeBorderWidth)\n // set links position\n links\n .attr(\"x1\", (d) => maxXValueAvailable(d.source.x))\n .attr(\"y1\", (d) => maxYValueAvailable(d.source.y))\n .attr(\"x2\", (d) => maxXValueAvailable(d.target.x))\n .attr(\"y2\", (d) => maxYValueAvailable(d.target.y))\n\n // set nodes position\n svg.selectAll(\".node\")\n .attr(\"transform\", (d) => `translate(${maxXValueAvailable(d.x)},${maxYValueAvailable(d.y)})`)\n }\n\n // handler drag start event\n function dragstarted() {\n // disable node fixing\n nodes.each((d) => {\n d.fx = null\n d.fy = null\n })\n }\n\n // handle dragging event\n function dragged(d) {\n // make dragged node fixed\n d.fx = event.x\n d.fy = event.y\n }\n\n // -------------------- handle drag end event ---------------\n function dragended() {\n // we are doing nothing, here , aren't we?\n }\n\n // -------------------------- node mouse hover handler ---------------\n function nodeMouseEnter(d) {\n // get links\n let _links = _hierarchy.root.links()\n\n // get hovered node connected links\n let connectedLinks = _links.filter((l) => l.source.id === d.id || l.target.id === d.id)\n\n // get hovered node linked nodes\n let linkedNodes = connectedLinks.map((s) => s.source.id).concat(connectedLinks.map((c) => c.target.id))\n\n // reduce all other nodes opacity\n nodesWrapper.selectAll(\".node\")\n .filter((n) => linkedNodes.indexOf(n.id) === -1)\n .attr(\"opacity\", attrs.hoverOpacity)\n\n // reduce all other links opacity\n linksWrapper.selectAll(\".link\")\n .attr(\"opacity\", attrs.hoverOpacity)\n\n // highlight hovered nodes connections\n linksWrapper.selectAll(\".link\")\n .filter((l) => l.source.id === d.id || l.target.id === d.id)\n .attr(\"opacity\", 1)\n }\n\n // --------------- handle mouseleave event ---------------\n function nodeMouseLeave() {\n // return things back to normal\n nodesWrapper.selectAll(\".node\")\n .attr(\"opacity\", 1)\n linksWrapper.selectAll(\".link\")\n .attr(\"opacity\", 1)\n }\n\n // --------------- handle node click event ---------------\n function nodeClick(d) {\n // free fixed nodes\n nodes.each((di) => {\n di.fx = null\n di.fy = null\n })\n\n // collapse or expand node\n if (d.children) {\n collapse(d)\n } else if (d._children) {\n expand(d)\n } else {\n // nothing is to collapse or expand\n }\n\n freeNodes()\n }\n\n // ######################################### UTIL FUNCS ##################################\n updateData = function () {\n main.run()\n }\n\n collapse = function (d, deep = false) {\n if (d.children) {\n if (deep) {\n d.children.forEach((e) => collapse(e, true))\n }\n\n d._children = d.children\n d.children = null\n }\n\n update(d)\n force.simulation.restart()\n force.simulation.alphaTarget(0.15)\n }\n\n expand = function (d, deep = false) {\n if (d._children) {\n if (deep) {\n d._children.forEach((e) => expand(e, true))\n }\n\n d.children = d._children\n d._children = null\n }\n\n update(d)\n force.simulation.restart()\n force.simulation.alphaTarget(0.15)\n }\n\n // function slowDownNodes() {\n // force.simulation.alphaTarget(0.05)\n // }\n\n // function speedUpNodes() {\n // force.simulation.alphaTarget(0.45)\n // }\n\n function freeNodes() {\n selectAll(\".node\").each((n) => {\n n.fx = null\n n.fy = null\n })\n }\n\n function projectCircle(value, radius) {\n let r = radius || 0\n let corner = value * 2 * Math.PI\n return [Math.sin(corner) * r, -Math.cos(corner) * r]\n }\n\n // recursively loop on children and extract nodes as an array\n function flatten(root, clustered) {\n let nodesArray = []\n let i = 0\n function recurse(node, depth) {\n if (node.children) {\n node.children.forEach(function (child) {\n recurse(child, depth + 1)\n })\n }\n\n if (!node.id) {\n node.id = ++i\n } else {\n ++i\n }\n\n node.depth = depth\n if (clustered) {\n if (!node.cluster) {\n // if cluster coordinates are not set, set it\n node.cluster = { x: node.x, y: node.y }\n }\n }\n nodesArray.push(node)\n }\n recurse(root, 1)\n return nodesArray\n }\n\n function debug() {\n if (attrs.isDebug) {\n // stringify func\n let stringified = String(scope)\n\n // parse variable names\n let groupVariables = stringified\n // match var x-xx= {}\n .match(/var\\s+([\\w])+\\s*=\\s*{\\s*}/gi)\n // match xxx\n .map((d) => d.match(/\\s+\\w*/gi).filter((s) => s.trim()))\n // get xxx\n .map((v) => v[0].trim())\n\n // assign local variables to the scope\n groupVariables.forEach((v) => {\n main[`P_${v}`] = eval(v)\n })\n }\n }\n\n debug()\n\n })\n }\n\n // ----------- PROTOTYEPE FUNCTIONS ----------------------\n function patternify(node, _params) {\n let selector = _params.selector\n let elementTag = _params.tag\n let _data = _params.data || [selector]\n\n // pattern in action\n let _selection = node.selectAll(`.${selector}`).data(_data)\n _selection.exit().remove()\n _selection = _selection.enter().append(elementTag).merge(_selection)\n _selection.attr(\"class\", selector)\n\n return _selection\n }\n\n // custom radial layout\n function radial() {\n return function (root) {\n\n recurse(root, 0, 1)\n\n function recurse(node, min, _max) {\n node.proportion = (_max + min) / 2\n if (!node.x) {\n\n // if node has parent, match entered node positions to it's parent\n if (node.parent) {\n node.x = node.parent.x\n } else {\n node.x = 0\n }\n }\n\n // if node had parent, match entered node positions to it's parent\n if (!node.y) {\n if (node.parent) {\n node.y = node.parent.y\n } else {\n node.y = 0\n }\n }\n\n // recursively do the same for children\n if (node.children) {\n let offset = (_max - min) / node.children.length\n node.children.forEach(function (child, i) {\n let newMin = min + (offset * i)\n let newMax = newMin + offset\n\n recurse(child, newMin, newMax)\n })\n }\n }\n }\n }\n\n // https://github.com/bumbeishvili/d3js-boilerplates#orderby\n Array.prototype.orderBy = function (func) {\n this.sort((_a, _b) => {\n let a = func(_a)\n let b = func(_b)\n if (typeof a === \"string\" || a instanceof String) {\n return a.localeCompare(b)\n }\n return a - b\n })\n\n return this\n }\n\n // ########################## BOILEPLATE STUFF ################\n\n // dinamic keys functions\n Object.keys(attrs).forEach((key) => {\n // Attach variables to main function\n return main[key] = function (_) {\n let string = `attrs['${key}'] = _`\n\n if (!arguments.length) {\n return eval(` attrs['${key}'];`)\n }\n\n eval(string)\n\n return main\n }\n })\n\n // set attrs as property\n main.attrs = attrs\n\n // debugging visuals\n main.debug = function (isDebug) {\n attrs.isDebug = isDebug\n if (isDebug) {\n if (!window.charts) {\n window.charts = []\n }\n window.charts.push(main)\n }\n return main\n }\n\n // exposed update functions\n main.data = function (value) {\n if (!arguments.length) {\n return attrs.data\n }\n\n attrs.data = value\n if (typeof updateData === \"function\") {\n updateData()\n }\n return main\n }\n\n // run visual\n main.run = function () {\n selectAll(attrs.container)\n .call(main)\n return main\n }\n\n main.filter = function (filterParams) {\n if (!arguments.length) {\n return attrs.filterParams\n }\n\n attrs.filterParams = filterParams\n if (typeof filter === \"function\") {\n filter()\n }\n return main\n }\n\n main.reset = function () {\n\n _hierarchy.root.children.forEach((e) => collapse(e, true))\n main.run()\n\n return main\n }\n\n return main\n }\n\n // initialization\n $orgChartContainer.each((i, container) => {\n\n let $container = $(container)\n let width = $container.width()\n let height = width / (16 / 9)\n\n json($container.data(\"url\")).then((data) => {\n // Make a fake previous node if the data entry is not hierarchical\n if (data instanceof Array) {\n fake = true\n dataDepicted = {\n name: null,\n children: data\n }\n } else {\n dataDepicted = data\n }\n\n orgchart = renderChartCollapsibleNetwork()\n .svgHeight(height)\n .svgWidth(width)\n .fakeRoot(fake)\n .container(`#${container.id}`)\n .data({\n root: dataDepicted\n })\n .debug(true)\n .run()\n })\n })\n\n // reset\n $btnReset.click(function() {\n orgchart.reset()\n })\n}\n\n$(() => {\n renderOrgCharts()\n $(document).on(\"change.zf.tabs\", () => {\n renderOrgCharts()\n });\n})\n","var map = {\n\t\"./decidim/assemblies/decidim_assemblies.svg\": \"../usr/local/bundle/gems/decidim-assemblies-0.27.2/app/packs/images/decidim/assemblies/decidim_assemblies.svg\"\n};\n\n\nfunction webpackContext(req) {\n\tvar id = webpackContextResolve(req);\n\treturn __webpack_require__(id);\n}\nfunction webpackContextResolve(req) {\n\tif(!__webpack_require__.o(map, req)) {\n\t\tvar e = new Error(\"Cannot find module '\" + req + \"'\");\n\t\te.code = 'MODULE_NOT_FOUND';\n\t\tthrow e;\n\t}\n\treturn map[req];\n}\nwebpackContext.keys = function webpackContextKeys() {\n\treturn Object.keys(map);\n};\nwebpackContext.resolve = webpackContextResolve;\nmodule.exports = webpackContext;\nwebpackContext.id = \"../usr/local/bundle/gems/decidim-assemblies-0.27.2/app/packs/images sync recursive ^\\\\.\\\\/.*$\";","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n// expose the modules object (__webpack_modules__)\n__webpack_require__.m = __webpack_modules__;\n\n","var deferred = [];\n__webpack_require__.O = function(result, chunkIds, fn, priority) {\n\tif(chunkIds) {\n\t\tpriority = priority || 0;\n\t\tfor(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];\n\t\tdeferred[i] = [chunkIds, fn, priority];\n\t\treturn;\n\t}\n\tvar notFulfilled = Infinity;\n\tfor (var i = 0; i < deferred.length; i++) {\n\t\tvar chunkIds = deferred[i][0];\n\t\tvar fn = deferred[i][1];\n\t\tvar priority = deferred[i][2];\n\t\tvar fulfilled = true;\n\t\tfor (var j = 0; j < chunkIds.length; j++) {\n\t\t\tif ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every(function(key) { return __webpack_require__.O[key](chunkIds[j]); })) {\n\t\t\t\tchunkIds.splice(j--, 1);\n\t\t\t} else {\n\t\t\t\tfulfilled = false;\n\t\t\t\tif(priority < notFulfilled) notFulfilled = priority;\n\t\t\t}\n\t\t}\n\t\tif(fulfilled) {\n\t\t\tdeferred.splice(i--, 1)\n\t\t\tvar r = fn();\n\t\t\tif (r !== undefined) result = r;\n\t\t}\n\t}\n\treturn result;\n};","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = function(module) {\n\tvar getter = module && module.__esModule ?\n\t\tfunction() { return module['default']; } :\n\t\tfunction() { return module; };\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = function(exports, definition) {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }","// define __esModule on exports\n__webpack_require__.r = function(exports) {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","__webpack_require__.p = \"/decidim-packs/\";","// no baseURI\n\n// object to store loaded and loading chunks\n// undefined = chunk not loaded, null = chunk preloaded/prefetched\n// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded\nvar installedChunks = {\n\t\"decidim_assemblies\": 0\n};\n\n// no chunk on demand loading\n\n// no prefetching\n\n// no preloaded\n\n// no HMR\n\n// no HMR manifest\n\n__webpack_require__.O.j = function(chunkId) { return installedChunks[chunkId] === 0; };\n\n// install a JSONP callback for chunk loading\nvar webpackJsonpCallback = function(parentChunkLoadingFunction, data) {\n\tvar chunkIds = data[0];\n\tvar moreModules = data[1];\n\tvar runtime = data[2];\n\t// add \"moreModules\" to the modules object,\n\t// then flag all \"chunkIds\" as loaded and fire callback\n\tvar moduleId, chunkId, i = 0;\n\tif(chunkIds.some(function(id) { return installedChunks[id] !== 0; })) {\n\t\tfor(moduleId in moreModules) {\n\t\t\tif(__webpack_require__.o(moreModules, moduleId)) {\n\t\t\t\t__webpack_require__.m[moduleId] = moreModules[moduleId];\n\t\t\t}\n\t\t}\n\t\tif(runtime) var result = runtime(__webpack_require__);\n\t}\n\tif(parentChunkLoadingFunction) parentChunkLoadingFunction(data);\n\tfor(;i < chunkIds.length; i++) {\n\t\tchunkId = chunkIds[i];\n\t\tif(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {\n\t\t\tinstalledChunks[chunkId][0]();\n\t\t}\n\t\tinstalledChunks[chunkId] = 0;\n\t}\n\treturn __webpack_require__.O(result);\n}\n\nvar chunkLoadingGlobal = self[\"webpackChunkdecidim_app\"] = self[\"webpackChunkdecidim_app\"] || [];\nchunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));\nchunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));","","// startup\n// Load entry module and return exports\n// This entry module depends on other loaded chunks and execution need to be delayed\nvar __webpack_exports__ = __webpack_require__.O(undefined, [\"vendors-node_modules_d3-array_src_index_js-node_modules_d3-collection_src_index_js-node_modul-f618e0\",\"vendors-node_modules_d3-drag_src_drag_js-node_modules_d3-fetch_src_json_js-node_modules_d3-fo-5cde09\"], function() { return __webpack_require__(\"../usr/local/bundle/gems/decidim-assemblies-0.27.2/app/packs/entrypoints/decidim_assemblies.js\"); })\n__webpack_exports__ = __webpack_require__.O(__webpack_exports__);\n",""],"names":[],"sourceRoot":""}