Liferay.Loader.define("commerce-organization-web@5.0.44/js/utils/paint",["module","exports","require","frontend-taglib-chart$d3","./constants","./index"],(function(t,a,e){window;{Object.defineProperty(a,"__esModule",{value:!0}),a.appendIcon=appendIcon,a.appendCircle=appendCircle,a.createAddActionButton=createAddActionButton,a.fillAddButtons=function fillAddButtons(t,a,e){const n=t.append("g").attr("class","actions-wrapper"),r=n.append("g").attr("class","open-actions-wrapper").on("mousedown",(t=>{"account"===t.parent.data.type?e(t.parent.data,"user"):n.node().classList.toggle("menu-open")}));appendCircle(r,36,"action-circle"),appendIcon(r,"".concat(a,"#plus"),18,"action-icon"),createAddActionButton(n,"account",e,a),createAddActionButton(n,"organization",e,a),createAddActionButton(n,"user",e,a)},a.printDescription=printDescription,a.fillEntityNode=function fillEntityNode(t,a,e){t.append("rect").attr("width",(t=>r.RECT_SIZES[t.data.type].width)).attr("height",(t=>r.RECT_SIZES[t.data.type].height)).attr("transform",(t=>"translate(0, ".concat(-.5*r.RECT_SIZES[t.data.type].height,")"))).attr("rx",(t=>r.RECT_SIZES[t.data.type].height/2)).attr("class","chart-rect");const o=t.append("g").attr("class","icon-wrapper");o.append("circle").attr("class","icon-circle"),appendIcon(o,(t=>"".concat(a,"#").concat(r.SYMBOLS_MAP[t.data.type])),16,"node-type-icon");const i=t.append("g").attr("class","chart-item-info");i.append("text").attr("class","node-title").text(c.formatItemName),i.each(((t,e,n)=>printDescription(t,n[e],a)));const d=t.filter((t=>!(!t.parent||"fakeRoot"===t.parent.data.type)&&(0,c.hasPermissions)(t.data,[r.ACTION_KEYS[t.data.type].REMOVE,r.ACTION_KEYS[t.data.type].DELETE]))).append("g").attr("class","node-menu-wrapper").attr("transform",(t=>{const a=r.RECT_SIZES[t.data.type].width-r.NODE_BUTTON_WIDTH-r.NODE_PADDING;return"translate(".concat(a,", -14)")})).on("mousedown",(t=>{var a;n.event.stopPropagation(),e(n.event.currentTarget,t.data,null===(a=t.parent)||void 0===a?void 0:a.data)}));d.append("rect").attr("class","node-menu-btn"),appendIcon(d,"".concat(a,"#ellipsis-v"),16,"node-menu-icon")},a.getLinkDiagonal=void 0;var n=e("frontend-taglib-chart$d3"),r=e("./constants"),c=e("./index");function appendIcon(t,a,e,n){return t.append("use").attr("class",n).attr("width",e).attr("height",e).attr("href",a)}const t=(0,n.linkHorizontal)().source((({source:t},a,e)=>{let n=a.data.type?r.RECT_SIZES[a.data.type].width:0;switch(e){case"enter":return[n+a.y0,a.x0];case"exit":return[n+a.y,a.x];default:return n=t.data.type?r.RECT_SIZES[t.data.type].width:0,[n+t.y,t.x]}})).target((({target:t},a,e)=>{const n=a.data.type?r.RECT_SIZES[a.data.type].width:0;switch(e){case"enter":return[n+a.y0,a.x0];case"exit":return[n+a.y,a.x];default:return[t.y,t.x]}}));function appendCircle(t,a,e){return t.append("circle").attr("r",a).attr("class",e)}function createAddActionButton(t,a,e,n){const c=t.append("g").attr("class","add-action-wrapper ".concat(a)).on("mousedown",(t=>{e(t.parent.data,a)}));appendCircle(c,16,"action-circle"),appendIcon(c,"".concat(n,"#").concat(r.SYMBOLS_MAP[a]),16,"action-icon")}function printDescription(t,a,e){const o=(0,n.select)(a).append("g").attr("class","node-description");if("user"===t.data.type)return void o.append("text").attr("class","node-description-content").text(c.formatUserDescription);("organization"===t.data.type?["organization","account","user"]:["user"]).reduce(((a,n)=>{const c=o.append("g").attr("class","".concat(n,"-wrapper")).attr("transform","translate(".concat(a,", 5)"));appendIcon(c,"".concat(e,"#").concat(r.SYMBOLS_MAP[n]),12,"entity-icon");const i=c.append("text").attr("class","entity-description").attr("x",18).attr("y",10).text(t.data[r.COUNTER_KEYS_MAP[n]]);"organization"!==n&&"account"!==t.data.type&&c.append("line").attr("class","entity-divider").attr("x1",-7).attr("x2",-7).attr("y1",-2).attr("y2",12);const d=i.node();let p=0;return d.getBBox&&(p=d.getBBox().width),a+p+32}),64)}a.getLinkDiagonal=t}}));
//# sourceMappingURL=paint.js.map