Liferay.Loader.define("portal-workflow-kaleo-designer-web@5.0.83/designer/js/definition-builder/diagram-builder/components/transitions/Edge",["module","exports","require","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","portal-workflow-kaleo-designer-web$react-flow-renderer","../../../DefinitionBuilderContext","../../../constants","../../DiagramBuilderContext","../../util/getBezierEdgeCenter","./MarkerEndDefinition","./utils"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;g(r("liferay!frontend-js-react-web$prop-types"));var n=f(r("liferay!frontend-js-react-web$react")),o=r("portal-workflow-kaleo-designer-web$react-flow-renderer"),a=r("../../../DefinitionBuilderContext"),i=r("../../../constants"),l=r("../../DiagramBuilderContext"),u=g(r("../../util/getBezierEdgeCenter")),d=f(r("./MarkerEndDefinition")),s=r("./utils");function c(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return c=function(){return e},e}function f(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=c();if(t&&t.has(e))return t.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=n?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}return r.default=e,t&&t.set(e,r),r}function g(e){return e&&e.__esModule?e:{default:e}}function p(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function b(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?p(Object(r),!0).forEach((function(t){y(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):p(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function y(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var w={transition:function(e){var t;const{data:{defaultEdge:r=!0,label:c},id:f,source:g,style:p={},target:y}=e,{elements:w,selectedLanguageId:O}=(0,n.useContext)(a.DefinitionBuilderContext),{selectedItem:m,setSelectedItem:j}=(0,n.useContext)(l.DiagramBuilderContext);let P=c;P&&P[i.defaultLanguageId]||(P={[i.defaultLanguageId]:Liferay.Language.get("task")});let k=P[i.defaultLanguageId];O&&P[O]&&(k=P[O]);const v=(0,o.useStoreState)((e=>e.nodes)),x=(0,n.useMemo)((()=>v.find((e=>e.id===g))),[g,v]),B=(0,n.useMemo)((()=>v.find((e=>e.id===y))),[y,v]),{sourcePos:E,sx:D,sy:h,targetPos:C,tx:_,ty:I}=(0,s.getEdgeParams)(x,B),M=w.filter((e=>e.source===y&&e.target===g)).length,F=w.findIndex((e=>e.source===y&&e.target===g)),L=w.findIndex((e=>e.id===f));let S=D,$=_;M&&(S=L>F?S+40:S-40,$=L>F?$+40:$-40);const W=(0,o.getBezierPath)({sourcePosition:E,sourceX:S,sourceY:h,targetPosition:C,targetX:$,targetY:I});let[X,Y]=(0,u.default)({curvature:.25,sourcePosition:E,sourceX:S,sourceY:h,targetPosition:C,targetX:$,targetY:I});M&&(Y=L>F?Y+21:Y-21);const[z,A]=(null==m?void 0:m.id)===f?["#80ACFF","#0B5FFF"]:["#A7A9BC","#6B6C7E"],N=b(b({},p),{},{stroke:z,strokeDasharray:0,strokeWidth:2});return r||(N.strokeDasharray=5),n.default.createElement("g",{className:"react-flow__connection"},n.default.createElement(d.default,{color:z}),n.default.createElement("path",{className:"react-flow__edge-path",d:W,id:f,markerEnd:"url(#".concat(d.markerEndId,")"),style:N}),n.default.createElement(o.EdgeText,{className:"react-flow-__edge-text",label:null===(t=k)||void 0===t?void 0:t.toUpperCase(),labelBgBorderRadius:"13px",labelBgPadding:[8,4],labelBgStyle:{fill:A},labelShowBg:!0,labelStyle:{fill:"#FFF",fontWeight:600},onClick:()=>j(e),x:X,y:Y}))}};t.default=w}}));
//# sourceMappingURL=Edge.js.map