"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6227],{16227:function(t,e,n){n.r(e),n.d(e,{default:function(){return m}});var a=n(29362),o=n(11029),r=n(76065),i=n(87683),s=n(40929),c=n(20903),u=n(99886),d=n(23554),l=n(78535),g=n(85591),p=n(35019),h=n(79933);let v=(t,e)=>{let n=[];return t.filter(t=>t.sourceHandle===e).forEach(t=>{var e,a,o,r;(null===(a=t.data)||void 0===a?void 0:null===(e=a.conditions)||void 0===e?void 0:e.length)?null===(r=t.data)||void 0===r||null===(o=r.conditions)||void 0===o||o.forEach(e=>{n.push({source:t.source,condition:e.condition,target:t.target,target_inputs:e.target_inputs})}):n.push({source:t.source,condition:"",target:t.target,target_inputs:{}})}),n},f=t=>{let{edges:e,values:n,sourceHandle:a}=t,o={},r=[],i=[],s=[],c=new Map;return e.forEach(t=>{t.sourceHandle===a&&c.set(t.target,t)}),n.forEach(t=>{var e,n;let i="".concat(a,"-").concat(t.target);o[i]&&(null===(e=o[i])||void 0===e?void 0:e.conditions)||(o[i]={conditions:[]}),null===(n=o[i].conditions)||void 0===n||n.push(t.condition);let u=c.get(t.target);u?JSON.stringify(u.data)!==JSON.stringify(t)&&s.push({edge:u,newData:t}):r.push(t)}),c.forEach((t,e)=>{n.some(t=>t.target===e)||i.push(t)}),{edgesToAdd:r,edgesToDelete:i,edgesToModify:s}};var m=(0,s.memo)(()=>{let t=(0,i.useInjection)(d.i),{edges:e,onConnect:n,setEdges:m}=(0,o.Xg)(t=>({edges:t.edges,onConnect:t.onConnect,setEdges:t.setEdges})),{sourceHandle:_,source:y,currentEdegData:E,transitionSheetOpen:k,setTransitionSheetOpen:w,runDrawerWidth:x}=(0,l.m)(t=>({sourceHandle:t.currentTransitionSourceHandle,source:t.currentTransitionSource,transitionSheetOpen:t.transitionSheetOpen,setTransitionSheetOpen:t.setTransitionSheetOpen,currentEdegData:t.currentEdegData,runDrawerWidth:t.runDrawerWidth})),C=(0,s.useCallback)(()=>{w({open:!1,source:"",sourceHandle:""})},[w]),O=(0,s.useCallback)(t=>{let{edgesToAdd:a,edgesToDelete:r,edgesToModify:i}=f({edges:e,values:((null==t?void 0:t.transitions)||[]).map(t=>({...t,target_inputs:t.target_inputs||{}})),sourceHandle:_});a.forEach(t=>{n({connect:{target:t.target,source:t.source,sourceHandle:_,targetHandle:t.target},edge:{type:c.m8.custom,data:{id:(0,h.DO)(),custom:!0,event_key:E.event_key,type:E.type,source:t.source,target:t.target,conditions:[{condition:t.condition,target_inputs:t.target_inputs}]},style:{stroke:"custom_".concat(y)===_?"#B6BABF":(0,o.Lq)(_)}}})}),m(t=>t.filter(t=>!r.some(e=>e.id===t.id))),m(t=>t.map(t=>{let e=i.find(e=>e.edge.id===t.id);return e?{...t,data:{...t.data,conditions:[{condition:e.newData.condition,target_inputs:e.newData.target_inputs}]}}:t}))},[e,n,m,_]),D=(0,s.useMemo)(()=>({transitions:v(e,_)}),[e,_]);return(0,a.jsx)(r.d,{style:{transform:"translateX(".concat(t.runOpen?"-".concat(x+24,"px"):"-12px",") translateY(12px)"),height:"calc(100% - 24px)"},className:"rounded-lg translate-x-[-12px] translate-y-3",width:375,placement:"right",mask:!1,getContainer:!1,title:"Edit Transition",open:k,autoFocus:!1,keyboard:!1,onClose:C,push:!1,children:(0,a.jsx)(p.O,{id:y,eventKey:null==E?void 0:E.event_key,children:(0,a.jsx)(u.Z,{schema:g.q8,values:D,onChange:O},_)})})},()=>!0)}}]);