PageSourceSearch

https://app.truvle.com/_next/static/chunks/2054-1e628965be8a29f7.js

js truvle.com collected 2026-10-09 22:08:01 UTC 148,179 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2054],{92054:function(e,t,s){s.d(t,{Z:function(){return lG}});var l,a,n=s(52322),r=s(75189),o=s(19114),i=s(84307),d=s(752),c=s(2784),u=s(62592),x=s(5632),h=()=>{let e=(0,x.useRouter)(),t=async()=>{await e.push("/")};return(0,n.jsx)("div",{className:"flex h-full w-full items-center justify-center p-4",children:(0,n.jsxs)("div",{className:"max-w-md rounded-lg border border-gray-800 p-6 text-center shadow-md",children:[(0,n.jsx)("h2",{className:"font-medium text-white text-xl",children:"Project Not Found"}),(0,n.jsx)("p",{className:"my-3 text-gray-400 text-sm",children:"The project you're trying to access does not exist or may have been deleted. Please check the URL or return to the projects page."}),(0,n.jsx)(i.zxk,{onClick:t,children:"Back to Projects"})]})})},p=s(65472),m=s(7534),g=s(96036),f=s(52113),v=s(10940);s(2347);var j=s(1622),w=s(70142),b=s(97822),N=s(38367),y=s(24982),k=s(10231),O=s(85716),C=s(43648),S=s(6364),E=e=>{let{edges:t,targetEdgeId:s,reactFlowInstance:l,canUseAutoSpacing:a}=e,n=t.find(e=>e.id===s);if(!n)return t;let r=l.getNode(n.target),o=l.getNode(n.source);if(!o||!r)return t;let i={x:(null==o?void 0:o.position.x)||0,y:(null==o?void 0:o.position.y)||0,x:(0,k.KP)((null==o?void 0:o.position.x)||0,(null==r?void 0:r.position.x)||0),y:(0,k.KP)((null==o?void 0:o.position.y)||0,(null==r?void 0:r.position.y)||0)},d=(0,S.Z)(),c={...w.LR[b.$P.ACTION](d),position:i},u={id:(0,k.LH)(d,r.id,(0,S.Z)()),source:d,target:r.id,type:b.rP.TIME,animated:!1,data:{text:"",points:[]},markerEnd:w.lM,sourceHandle:n.sourceHandle,targetHandle:n.targetHandle},x={...n,target:d},h=t.filter(e=>e.id!==n.id),p=(0,j.mH)({rootNode:o,newNodePosition:i,nodes:[c,...l.getNodes()],edges:[...h,u,x]});return void 0!==a&&!0===a?l.setNodes(e=>{let t=p.nodes.find(e=>e.id===c.id);return e.map(e=>{let t=p.nodes.find(t=>t.id===e.id);return null!=t?t:e}).concat(null!=t?t:[])}):l.setNodes(e=>e.concat(c)),[...h,u,x]},I=e=>{let{edge:t,targetEdgeId:s,edgeData:l}=e;return t.id===s?{...t,data:{...t.data,...l}}:t};(l=a||(a={})).DATA="data",l.TYPE="type";var P=e=>{let{reactFlowInstance:t,edgeId:s,edgeData:l,canUseAutoSpacing:n}=e,r={edgeData:l,edgeId:s},o=[];r.edgeData&&o.push({func:I,parameters:{edgeData:r.edgeData,targetEdgeId:r.edgeId},type:a.DATA}),t.setEdges(e=>{let s=e.map(e=>o.reduce((e,t)=>t.type===a.DATA?t.func({edge:e,targetEdgeId:t.parameters.targetEdgeId,edgeData:t.parameters.edgeData}):e,e)||e);return l?s:E({edges:s,targetEdgeId:r.edgeId,reactFlowInstance:t,canUseAutoSpacing:n})||s})},T=(0,c.memo)(e=>{let{edgeId:t}=e,[s]=(0,d.Dv)(r.JE),[l]=(0,d.KO)(r.nf),a=(0,O._K)(),{toast:i}=(0,y.pm)();return s?(0,n.jsx)("div",{className:(0,o.cn)("flex w-full flex-row justify-center gap-2"),children:(0,n.jsx)(o.zxk,{className:"h-8 p-1 text-sm",onClick:()=>{s&&(a.fitView({duration:1e3,nodes:[s]}),i({title:"Error creating new node",description:"Fill all required fields in the existing nodes to continue",variant:"destructive"}))},variant:"ghost",children:(0,n.jsx)(o.PJP.Ban,{})})}):(0,n.jsx)("div",{className:(0,o.cn)("flex w-full flex-row justify-center gap-2"),children:(0,n.jsx)(o.zxk,{className:"h-8 p-1 text-sm",onClick:e=>{e.stopPropagation(),P({reactFlowInstance:a,edgeId:t,canUseAutoSpacing:l})},variant:"ghost",children:(0,n.jsx)(o.PJP.Plus,{})})})});let Z=e=>{let{id:t,index:s,x:l,y:a,active:r,setControlPoints:i,color:d="black"}=e,u=(0,O.oR)(e=>e.domNode),{screenToFlowPosition:x}=(0,O._K)(),[h,p]=(0,c.useState)(!1),m=(0,c.useRef)(null),g=(0,c.useCallback)(e=>{i(l=>r?l.map(s=>s.id===t?{...s,...e}:s):0!==s?l.flatMap((l,a)=>a===.5*s-1?[l,{...e,id:t,active:!0}]:l):[{...e,id:t,active:!0},...l])},[t,r,s,i]),f=(0,c.useCallback)(()=>{var e,s;i(e=>e.filter(e=>e.id!==t));let l=null===(s=m.current)||void 0===s?void 0:null===(e=s.previousElementSibling)||void 0===e?void 0:e.previousElementSibling;(null==l?void 0:l.tagName)==="circle"&&l.classList.contains("active")&&window.requestAnimationFrame(()=>{l.focus()})},[t,i]),v=(0,c.useCallback)(e=>{switch(e.key){case"Enter":case"Space":r||e.preventDefault(),g({x:l,y:a});break;case"Backspace":case"Delete":e.stopPropagation(),f();break;case"ArrowLeft":g({x:l-5,y:a});break;case"ArrowRight":g({x:l+5,y:a});break;case"ArrowUp":g({x:l,y:a-5});break;case"ArrowDown":g({x:l,y:a+5})}},[r,g,l,a,f]);return(0,c.useEffect)(()=>
1{if(!u||!r||!h)return;let e=e=>{g(x({x:e.clientX,y:e.clientY}))},t=t=>{u.removeEventListener("pointermove",e),r||t.preventDefault(),p(!1),g(x({x:t.clientX,y:t.clientY}))};return u.addEventListener("pointermove",e),u.addEventListener("pointerup",t,{once:!0}),u.addEventListener("pointerleave",t,{once:!0}),()=>{u.removeEventListener("pointermove",e),u.removeEventListener("pointerup",t),u.removeEventListener("pointerleave",t),p(!1)}},[t,u,h,r,x,i,g]),(0,n.jsx)("circle",{ref:m,tabIndex:0,id:t,className:(0,o.cn)("nopan nodrag".concat(r?" active":""),"focus:outline-none"),cx:l,cy:a,r:r?4:3,strokeOpacity:r?1:.3,stroke:d,fill:r?d:"white",style:{pointerEvents:"all"},onContextMenu:e=>{e.preventDefault(),r&&f()},onPointerDown:e=>{2!==e.button&&(g({x:l,y:a}),p(!0))},onKeyDown:v,onPointerUp:()=>p(!1)})};var A=s(59292),K=e=>{let t=(0,c.useRef)([]);return t.current.length===e.length?e.map((e,s)=>e.id?e:{...e,id:t.current[s]}):(t.current=[],e.map((e,s)=>{if(!e.id){let l=window.crypto.randomUUID();return t.current[s]=l,{...e,id:l}}return t.current[s]=e.id,e}))},z=s(30537),_=s(7562),L=s(86271),R=s(59937),D=s(66386),H=s(88883),F=s(63955),W=s(30195),G=s(30305),M=s(85897);let V=W.z.object({text:W.z.string().min(1,{message:"question is required"})});var J=(0,c.memo)(e=>{let{text:t,edgeId:s,setIsFilled:l,maxLengthField:a,enabled:i=!0}=e,u=(0,F.cI)({defaultValues:{text:null!=t?t:""},resolver:(0,H.F)(V)}),[x,h]=(0,c.useState)(t),p=u.watch("text"),m=(0,M.Z)(p,500),[g,f]=(0,c.useState)(m),v=(0,d.b9)(r.O0),j=(0,O._K)();return x!==t&&(h(t),u.setValue("text",t)),m!==g&&(f(m),v(!0),P({reactFlowInstance:j,edgeId:s,edgeData:{text:m.length>=1?m:""}})),(0,n.jsx)(o.l09,{...u,children:(0,n.jsx)("form",{onSubmit:e=>{e.preventDefault()},className:"flex h-fit w-full flex-row items-center justify-center",children:(0,n.jsx)(o.WiK,{control:u.control,name:"text",render:e=>{let{field:s}=e;return(0,n.jsxs)(o.xJW,{children:[(0,n.jsx)(o.NIc,{children:(0,n.jsx)(G.Z,{initialText:t,name:s.name,value:s.value,setValue:(e,t)=>{u.setValue(e,t)},setIsFilled:l,maxLength:a,countdown:a?a-s.value.length:0,textBoxSize:w.Q5.SM,maxVisibleCharacters:12,placeholder:w.u2.ANSWER,className:"min-w-[3rem] max-w-[7rem]",enabled:i})}),(0,n.jsx)(o.zGS,{})]})}})})})}),U=s(82876),Q=s(82558),$=(0,c.memo)(e=>{let{isVisibleAutoLayoutButton:t}=e,s=(0,U.usePathname)(),l=(0,U.useRouter)(),a="format"===(0,U.useSearchParams)().get("flow");return(0,n.jsxs)(O.s_,{position:"bottom-left",className:(0,o.cn)("flex w-fit flex-col items-start justify-end gap-8 rounded-lg",t?"h-44":"h-36"),children:[(0,n.jsx)(Q.Z,{position:a?"top-left":"bottom-left",isVisibleAutoLayoutButton:t}),a&&(0,n.jsx)(o.zxk,{variant:"ghost",onClick:()=>l.push("".concat(s,"?flow=capture")),className:"flex h-10 w-auto flex-row items-center justify-center justify-items-center gap-2 border border-accent-color-accent-alpha-8 border-solid bg-white drop-shadow-lg hover:bg-accent-color-accent-2 active:bg-accent-color-accent-2 dark:text-black",children:"Capture"})]})}),B=s(77298),q=s(9242),X=s(10644),Y=s(37092),ee=(0,c.memo)(e=>{var t,s,l,a,u;let{buttonStyles:x,nodeId:h,isNodeCompleted:p,savedNotes:m,onNoteOpenChange:g}=e,[f,v]=(0,c.useState)(null!==(t=null==m?void 0:m.value)&&void 0!==t?t:""),[j,w]=(0,c.useState)(!!((null==m?void 0:m.isOpen)&&(null==m?void 0:m.value)!=="")),[b,N]=(0,c.useState)(null===(s=null==m?void 0:m.isOpen)||void 0===s||s),[y,C]=(0,c.useState)(j),S=(0,M.Z)(f,500),E=(0,O._K)(),[,I]=(0,d.KO)(r.O0),[P]=(0,d.KO)(r.eU),[T,Z]=(0,c.useState)(null===(l=null==m?void 0:m.isOpen)||void 0===l||l),[A,K]=(0,c.useState)(f),[z,_]=(0,c.useState)(S),L=P&&""!==f?"":"opacity-0 hover:opacity-100";z!==S&&A!==f&&(I(!0),(0,k._V)({isNodeCompleted:p,nodeId:h,reactFlowInstance:E,nodeData:{notes:{value:S,isOpen:""!==S&&T}}}),K(f),_(S)),b!==(null==m?void 0:m.isOpen)&&(w(!!(null==m?void 0:m.isOpen)&&""!==f),Z(null===(a=null==m?void 0:m.isOpen)||void 0===a||a),I(!0),N(null===(u=null==m?void 0:m.isOpen)||void 0===u||u)),y!==j&&(null==g||g(j),C(j));let R=E.getNode(h);return(0,n.jsxs)(i.J2e,{open:j,onOpenChange:w,children:[(0,n.jsx)(i.xol,{asChild:!0,children:(0,n.jsxs)(i.zxk,{className:(0,o.cn)("grid h-full w-full grid-cols-3 items-center justify-items-center rounded-sm p-0 text-sm",L,x),variant:"outline",children:[P&&""!==f?(0,n.jsx)(o.PJP.Dot,{className:"col-span-3 col-start-1 row-span-full h-full w-full opacity-100 hover:opacity-0"}):null,""===f?(0,n.jsx)(o.PJP.Plus,{className:"col-span-3 col-end-4 row-span-full h-full w-full opacity-0 hover:opacity-100"}):(0,n.jsx)(o.PJP.StickyNote,{className:" col-span-3 col-end-4 row-span-full h-full w-full fill-white opacity-0 hover:opacity-100 dark:fill-slate-800"})]})}),(0,n.jsxs)(i.yky,{side:"top",align:"start",className:"flex h-40 w-40 flex-col rounded-none p-0",onEscapeKeyDown:e=>{e.preventDefault()},onPointerDownOutside:e=>{T&&e.preventDefault()},onFocusOutside:e=>{T&&e.preventDefault()},onInteractOutside:e=>{T&&e.preventDefault()},children:[(0,n.jsx)("div",{className:"flex h-4 w-full items-center justify-end bg-yellow-100 p-2",children:(0,n.jsx)(i.zxk,{variant:"outline",className:(0,o.cn)("h-3 w-3 rounded-sm border-none p-0 text-black","focus:ring-0 focus:ring-offset-0 dark:focus:ring-0 dark:focus:ring-offset-0","hover:bg-yellow-200 dark:hover:bg-yellow-200"),onClick:()=>{let e=!T;Z(e),w(e),I(!0),(0,k._V)({isNodeCompleted:p,nodeId:h,reactFlowInstance:E,nodeData:{notes:{value:S,isOpen:e}}}),e||null==g||g(!1)},children:T?(0,n.jsx)(o.PJP.PinOff,{className:"h-3 w-3 fill-gray-500 stroke-[1px] stroke-gray-500"}):(0,n.jsx)(o.PJP.Pin,{className:"h-3 w-3 fill-gray-500 stroke-[1px] stroke-gray-500"})})}),(0,n.jsx)(i.gxH,{id:"width",autoFocus:void 0!==R&&!0===R.selected,placeholder:"Take a note...",className:(0,o.cn)("nowheel h-full w-full rounded-none","focus:ring-0 focus:ring-offset-0 dark:focus:ring-0 dark:focus:ring-offset-0","border-none dark:border-none","text-black dark:text-black","nodrag resize-none","bg-yellow-200"),value:f,onFocus:e=>{e.currentTarget.setSelectionRange(0,e.currentTarget.value.length)},onChange:e=>{v(e.target.value)}})]})]})}),et=s(32034),es=(0,c.memo)(e=>{let{nodeId:t,isNodeCompleted:s,className:l,currentFocalPoint:a}
1=e,[u,x]=(0,c.useState)(a.count),h=(0,M.Z)(u,500),p=(0,O._K)(),[,m]=(0,d.KO)(r.O0),[g,f]=(0,c.useState)(!1),[v]=(0,d.KO)(r.WV),[j,b]=(0,c.useState)(h),[N,y]=(0,c.useState)(a),[C,S]=(0,c.useState)(u),E=(0,c.useCallback)(e=>{p&&(m(!0),(0,k._V)({isNodeCompleted:s,nodeId:t,reactFlowInstance:p,nodeData:{focalPoint:{count:h,backgroundColor:e}}}))},[h,s,t,p,m]);N.backgroundColor!==a.backgroundColor&&(E(a.backgroundColor),y(a)),j!==h&&C!==u&&(E(a.backgroundColor),b(h),S(u));let I=(0,c.useCallback)(()=>{E("bg-green-500")},[E]),P=(0,c.useCallback)(()=>{E("bg-red-500")},[E]),T=(0,c.useCallback)(()=>{x(w.np),E("bg-none")},[E]);return(0,n.jsxs)(i.J2e,{open:g,onOpenChange:f,children:[(0,n.jsx)(i.xol,{asChild:!0,children:(0,n.jsx)(i.IIB,{className:(0,o.cn)("h-full w-full rounded-full p-0 text-center outline-none","[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none","flex rounded-full border border-black dark:border-white","text-xs",g||v?"":"opacity-0 hover:opacity-100",(0,k.nJ)(u),a.backgroundColor,l),type:"number",min:w.np,max:w.AA,value:u,onChange:e=>{x(Number(e.target.value))},onFocus:e=>{e.target.select()},onBlur:e=>{if(Number(e.target.value)<w.np){x(w.np);return}if(Number(e.target.value)>w.AA){x(w.AA);return}x(Number(e.target.value))}})}),(0,n.jsxs)(i.yky,{side:"left",className:"z-[90] flex w-full flex-row justify-items-center gap-2 p-2",onOpenAutoFocus:e=>e.preventDefault(),children:[(0,n.jsx)(i.zxk,{variant:"ghost",className:"h-4 w-4 rounded-full bg-red-500 p-0 hover:bg-red-300 dark:hover:bg-red-300",onClick:P}),(0,n.jsx)(i.zxk,{variant:"ghost",className:"h-4 w-4 rounded-full bg-green-500 p-0 hover:bg-green-300 dark:hover:bg-green-300",onClick:I}),(0,n.jsx)(i.zxk,{variant:"ghost",className:"h-4 w-4 rounded-full p-[0.1rem]",onClick:T,children:(0,n.jsx)(o.PJP.RotateCcw,{})})]})]})}),el=s(7666);let ea=W.z.object({where:W.z.string().min(1,{message:"System is required"}).max(w.TO.WHERE,{message:"System must be less than ".concat(w.TO.WHERE," characters")}),what:W.z.string().min(1,{message:"Action is required"}).max(w.TO.WHAT,{message:"Action must be less than ".concat(w.TO.WHAT," characters")}),who:W.z.string().min(1,{message:"Role is required"}).max(w.TO.WHO,{message:"Role must be less than ".concat(w.TO.WHO," characters")})});var en=(0,c.memo)(e=>{var t,s,l;let{nodeId:a,data:o}=e,[u]=(0,d.KO)(r.rm),[x]=(0,d.KO)(r.hT),[h,p]=(0,c.useState)(o.what),[m,g]=(0,c.useState)(o.where),[f,v]=(0,c.useState)(o.who),j=(0,F.cI)({defaultValues:{who:null!==(t=o.who)&&void 0!==t?t:w.vP.WHO,what:null!==(s=o.what)&&void 0!==s?s:w.vP.WHAT,where:null!==(l=o.where)&&void 0!==l?l:w.vP.WHERE},resolver:(0,H.F)(ea)}),b=(0,d.b9)(r.O0),N=j.watch("where"),y=j.watch("what"),C=j.watch("who"),[S,E]=(0,c.useState)(N),[I,P]=(0,c.useState)(C),T=(0,M.Z)(y,500),[Z,A]=(0,c.useState)(T),K=(0,O._K)(),z=N.length>=1&&T.length>=1&&C.length>=1;return(h!==o.what||m!==o.where||f!==o.who)&&(p(o.what),g(o.where),v(o.who),j.setValue("what",o.what),j.setValue("where",o.where),j.setValue("who",o.who)),T!==Z&&(b(!0),(0,k._V)({isNodeCompleted:z,reactFlowInstance:K,nodeId:a,nodeData:{what:T,where:N,who:C}}),A(T)),S!==N&&(b(!0),(0,k._V)({isNodeCompleted:z,reactFlowInstance:K,nodeId:a,nodeData:{what:y,where:N.length>=1?N:w.vP.WHERE,who:C}}),E(N)),I!==C&&(b(!0),(0,k._V)({isNodeCompleted:z,reactFlowInstance:K,nodeId:a,nodeData:{what:y,where:N,who:C.length>=1?C:w.vP.WHO}}),P(C)),(0,n.jsx)(i.l09,{...j,children:(0,n.jsxs)("form",{onSubmit:e=>{e.preventDefault()},className:"flex h-fit w-fit flex-col items-center justify-center justify-items-center",children:[(0,n.jsx)(i.WiK,{control:j.control,name:"what",render:e=>{var t;let{field:s}=e;return(0,n.jsxs)(i.xJW,{children:[(0,n.jsx)(i.NIc,{children:(0,n.jsx)(G.Z,{initialText:null!==(t=o.what)&&void 0!==t?t:w.vP.WHAT,name:s.name,value:s.value,setValue:j.setValue,maxLength:w.TO.WHAT,countdown:w.TO.WHAT-s.value.length,textBoxSize:w.Q5.LG,placeholder:w.vP.WHAT,id:a,minStandardStyleCharacters:30,className:"w-[166px]"})}),(0,n.jsx)(i.zGS,{})]})}}),(0,n.jsx)(i.WiK,{control:j.control,name:"where",render:e=>{var t;let{field:s}=e;return(0,n.jsxs)(i.xJW,{className:"max-w-[14rem]",children:[(0,n.jsx)(i.NIc,{children:(0,n.jsx)(el.Z,{initialText:null!==(t=o.where)&&void 0!==t?t:w.vP.WHERE,name:s.name,value:s.value,setValue:j.setValue,maxLength:w.TO.WHERE,placeholder:w.vP.WHERE,autoCompleteOptions:x,maxVisibleCharacters:w.TO.WHERE+1,id:a})}),(0,n.jsx)(i.zGS,{})]})}}),(0,n.jsx)(i.WiK,{control:j.control,name:"who",render:e=>{var t;let{field:s}=e;return(0,n.jsxs)(i.xJW,{children:[(0,n.jsx)(i.NIc,{children:(0,n.jsx)(el.Z,{initialText:null!==(t=o.who)&&void 0!==t?t:w.vP.WHO,name:s.name,value:s.value,setValue:j.setValue,maxLength:w.TO.WHO,placeholder:w.vP.WHO,maxVisibleCharacters:w.TO.WHO+1,autoCompleteOptions:u,id:a})}),(0,n.jsx)(i.zGS,{})]})}})]})})}),er=s(98070),eo=s(19303),ei=s(3598),ed=s(52579),ec=s(65829),eu=s(13892);let ex=(0,c.memo)(e=>{let{nodeId:t}=e,s=(0,m.Z)("processId"),{subgroupsId:l,isErrorSubgroup:a,isLoadingSubgroup:r}=(0,eu.Z)({nodeId:t,enabled:""!==s}),{groups:i,isErrorGroups:d,isLoadingGroups:u}=(0,ec.Z)({processId:s,enabled:""!==s}),{handleAddNodesInSubgroup:x}=(0,ed.Z)({nodeId:t});return u||r?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(o.OgT,{className:"select-none font-bold text-base leading-6 tracking-[-0.32px]",inset:!0,children:"Groups"}),Array.from({length:3}).map((e,t)=>(0,n.jsx)(o.Naz,{children:(0,n.jsx)(o.OdW,{className:"h-4 w-full"})},"".concat(t,"-toolbar-menu-skeleton")))]}):d||a?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(o.OgT,{className:"select-none font-bold text-base leading-6 tracking-[-0.32px]",inset:!0,children:"Groups"}),(0,n.jsx)(o.Naz,{children:"Error loading groups"})]}):0===i.length?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(o.OgT,{className:"select-none font-bold text-base leading-6 tracking-[-0.32px]",inset:!0,children:"Groups"}
1),(0,n.jsx)(o.Naz,{children:"No groups found"}),(0,n.jsx)(o.yEP,{}),(0,n.jsx)(eo.Z,{kind:"single-node",nodeId:t,groupId:w.nb,children:(0,n.jsx)(o.Naz,{onSelect:e=>{e.preventDefault(),e.stopPropagation()},className:"font-medium leading-6 tracking-[-0.32px]",inset:!0,children:"Create new groups"})})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(o.OgT,{className:"select-none font-bold text-base leading-6 tracking-[-0.32px]",inset:!0,children:"Groups"}),i.map(e=>(0,n.jsxs)(c.Fragment,{children:[e.subgroups.filter(e=>!l.includes(e.id)).map(t=>(0,n.jsxs)(o.Naz,{inset:!0,className:"flex flex-row items-center gap-2",onClick:()=>{x({groupId:e.id,subgroupId:t.id,color:t.color})},children:[(0,n.jsx)("span",{className:"font-normal text-sm leading-5 tracking-[-0.28px]",children:(0,k.$G)(t.name,20)}),(0,n.jsx)("div",{className:"h-4 w-4 rounded-md border border-white",style:{backgroundColor:t.color}})]},t.id)),(0,n.jsx)(o.yEP,{}),(0,n.jsx)(eo.Z,{kind:"single-node",nodeId:t,groupId:e.id,children:(0,n.jsx)(o.Naz,{inset:!0,onClick:e=>{e.preventDefault(),e.stopPropagation()},className:"text-center font-medium leading-6 tracking-[-0.32px]",children:"Create new groups"})}),(0,n.jsx)(ei.Z,{groupId:e.id,nodeId:t,children:(0,n.jsx)(o.Naz,{inset:!0,onClick:e=>{e.preventDefault(),e.stopPropagation()},className:"text-center font-medium leading-6 tracking-[-0.32px] focus:bg-semantic-error-10 focus:text-white active:bg-semantic-error-10 active:text-white",children:"Remove from groups"})})]},e.id))]})});var eh=(0,c.memo)(e=>{let{nodeId:t,nodeType:s}=e,l=s===b.$P.ACTION,a=s===b.$P.QUESTION,{handleTurnActionIntoQuestion:r,handleTurnQuestionIntoAction:i,handleDeleteNode:d}=(0,ed.Z)({nodeId:t});return(0,n.jsx)(er.M,{className:"nodrag nowheel nopan flex flex-row gap-2 rounded-md bg-panel-solid p-1 drop-shadow-xl",offset:32,children:(0,n.jsxs)(o.nm8,{className:"h-11 p-0",children:[(0,n.jsxs)(o.QPk,{children:[(0,n.jsx)(o.rQE,{asChild:!0,children:(0,n.jsxs)(o.zxk,{variant:"ghost",className:"flex gap-1 rounded-sm py-0",children:[(0,n.jsx)(B.pOD,{className:"h-4 w-4"}),(0,n.jsx)("span",{children:"Groups"})]})}),(0,n.jsx)(o.uET,{children:(0,n.jsx)(ex,{nodeId:t})})]}),l&&(0,n.jsx)(o.QPk,{children:(0,n.jsx)(o.zxk,{variant:"ghost",className:"rounded-sm",onClick:r,children:"Turn into Question"})}),a&&(0,n.jsx)(o.QPk,{children:(0,n.jsx)(o.zxk,{variant:"ghost",className:"rounded-sm",onClick:i,children:"Turn into Action"})}),(0,n.jsx)(o.QPk,{children:(0,n.jsx)(o.zxk,{variant:"ghost",className:"rounded-sm",onClick:d,children:"Delete"})})]})})}),ep=s(85999),em=e=>{let{nodesIds:t}=e,{addNodesInSubgroups:s}=(0,ep.Z)(),l=(0,m.Z)("processId"),[,a]=(0,d.KO)(r.NR),[,n]=(0,d.KO)(r.$X),{toast:o}=(0,y.pm)();return{handleAddNodesInSubgroup:(0,c.useCallback)(e=>{let{groupId:r,subgroupId:i,color:d}=e;n({subgroupId:i,selectedNodesIds:t}),a(e=>{let s=t.filter(t=>e.every(e=>e.nodeId!==t)).map(e=>({nodeId:e,color:d}));return[...e.map(e=>t.includes(e.nodeId)?{nodeId:e.nodeId,color:d}:e),...s]}),s.mutate({processId:l,groupId:r,items:[{subgroupId:i,nodesIds:t}]},{onSuccess:()=>{o({title:"Subgroup",description:"Node added to subgroup",variant:"default"})},onError:()=>{o({title:"Subgroup",description:"Error adding node to subgroup",variant:"destructive"})}})},[s,l,t,a,n,o])}};let eg=(0,c.memo)(e=>{let{nodesIds:t}=e,s=(0,m.Z)("processId"),{groups:l,isErrorGroups:a,isLoadingGroups:r}=(0,ec.Z)({processId:s,enabled:""!==s}),{handleAddNodesInSubgroup:o}=em({nodesIds:t});return r?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(i.Juw,{inset:!0,children:"Groups"}),Array.from({length:3}).map(()=>(0,n.jsx)(i.Xiv,{children:(0,n.jsx)(i.OdW,{className:"h-4 w-full"})},Math.random()))]}):a?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(i.Juw,{inset:!0,children:"Groups"}),(0,n.jsx)(i.Xiv,{children:"Error loading groups"})]}):0===l.length?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(i.Juw,{inset:!0,children:"Groups"}),(0,n.jsx)(i.Xiv,{children:"No groups found"}),(0,n.jsx)(eo.Z,{kind:"multi-node",nodesIds:t,groupId:w.nb,children:(0,n.jsx)(i.Xiv,{onSelect:e=>{e.preventDefault(),e.stopPropagation()},className:"font-medium leading-6 tracking-[-0.32px]",inset:!0,children:"Create new groups"})})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(i.Juw,{inset:!0,className:"select-none font-bold text-base leading-6 tracking-[-0.32px]",children:"Groups"}),l.map(e=>(0,n.jsxs)(c.Fragment,{children:[e.subgroups.map(t=>(0,n.jsxs)(i.Xiv,{inset:!0,className:"flex flex-row items-center gap-2",onClick:()=>{o({groupId:e.id,subgroupId:t.id,color:t.color})},children:[(0,n.jsx)("span",{className:"font-normal text-sm leading-5 tracking-[-0.28px]",children:(0,k.$G)(t.name,20)}
1),(0,n.jsx)("div",{className:"h-4 w-4 rounded-md border border-white",style:{backgroundColor:t.color}})]},t.id)),(0,n.jsx)(eo.Z,{kind:"multi-node",nodesIds:t,groupId:e.id,children:(0,n.jsx)(i.Xiv,{inset:!0,onClick:e=>{e.preventDefault(),e.stopPropagation()},className:"text-center font-medium leading-6 tracking-[-0.32px]",children:"Create new groups"})})]},e.id))]})});var ef=(0,c.memo)(e=>{let{nodesIds:t,top:s,left:l,right:a,bottom:o}=e,[c,u]=(0,d.KO)(r.TH);return(0,n.jsx)("div",{className:"absolute z-50 flex h-1 w-1 flex-row items-center justify-center",children:(0,n.jsxs)(i.h_2,{modal:!1,open:c,defaultOpen:!0,onOpenChange:u,children:[(0,n.jsx)(i.$FS,{className:"bg-none"}),(0,n.jsx)(i.AWV,{style:{top:s,left:l,right:a,bottom:o},className:"relative h-fit w-64",children:(0,n.jsx)(eg,{nodesIds:t})})]})})}),ev=s(29500),ej=s(41814);let ew=W.z.object({question:W.z.string().min(1,{message:"question is required"}).max(w.kh.QUESTION,{message:"question must be less than ".concat(w.kh.QUESTION," characters")})});var eb=(0,c.memo)(e=>{var t;let{nodeId:s,data:l,className:a}=e,[u,x]=(0,c.useState)(l.question),h=(0,F.cI)({defaultValues:{question:null!==(t=l.question)&&void 0!==t?t:w.AH.QUESTION},resolver:(0,H.F)(ew)}),[,p]=(0,d.KO)(r.O0),m=(0,O._K)(),g=h.watch("question"),f=(0,M.Z)(g,500),[v,j]=(0,c.useState)(f);if(u!==l.question&&(x(l.question),h.setValue("question",l.question)),v!==f){p(!0);let e=f.length>=1;e?(0,k._V)({isNodeCompleted:e,nodeId:s,reactFlowInstance:m,nodeData:{question:f}}):(0,k._V)({isNodeCompleted:e,nodeId:s,reactFlowInstance:m,nodeData:{question:w.AH.QUESTION}}),j(f)}return(0,n.jsx)(i.l09,{...h,children:(0,n.jsx)("form",{onSubmit:e=>{e.preventDefault()},className:"flex flex-row items-center",children:(0,n.jsx)(i.WiK,{control:h.control,name:"question",render:e=>{var t;let{field:s}=e;return(0,n.jsxs)(i.xJW,{className:(0,o.cn)("bg-none",a),children:[(0,n.jsx)(i.NIc,{children:(0,n.jsx)(G.Z,{initialText:null!==(t=l.question)&&void 0!==t?t:w.AH.QUESTION,name:s.name,value:s.value,setValue:h.setValue,maxLength:w.kh.QUESTION,countdown:w.kh.QUESTION-s.value.length,textBoxSize:w.Q5.MD,placeholder:w.AH.QUESTION})}),(0,n.jsx)(i.zGS,{})]})}})})})});let eN=(0,c.memo)(e=>{let{nodesIds:t}=e,s=(0,m.Z)("processId"),{groups:l,isErrorGroups:a,isLoadingGroups:r}=(0,ec.Z)({processId:s,enabled:""!==s}),{handleAddNodesInSubgroup:o}=em({nodesIds:t});return r?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(i.OgT,{className:"select-none font-bold text-base leading-6 tracking-[-0.32px]",inset:!0,children:"Groups"}),Array.from({length:3}).map((e,t)=>(0,n.jsx)(i.Naz,{children:(0,n.jsx)(i.OdW,{className:"h-4 w-full"})},"".concat(t,"-toolbar-menu-skeleton")))]}):a?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(i.OgT,{className:"select-none font-bold text-base leading-6 tracking-[-0.32px]",inset:!0,children:"Groups"}),(0,n.jsx)(i.Naz,{children:"Error loading groups"})]}):0===l.length?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(i.OgT,{className:"select-none font-bold text-base leading-6 tracking-[-0.32px]",inset:!0,children:"Groups"}),(0,n.jsx)(i.Naz,{children:"No groups found"}),(0,n.jsx)(eo.Z,{kind:"multi-node",nodesIds:t,groupId:w.nb,children:(0,n.jsx)(i.Naz,{onSelect:e=>{e.preventDefault(),e.stopPropagation()},className:"font-medium leading-6 tracking-[-0.32px]",inset:!0,children:"Create new groups"})})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(i.OgT,{className:"select-none font-bold text-base leading-6 tracking-[-0.32px]",inset:!0,children:"Groups"}),l.map(e=>(0,n.jsxs)(c.Fragment,{children:[e.subgroups.map(t=>(0,n.jsxs)(i.Naz,{inset:!0,className:"flex flex-row items-center gap-2",onClick:()=>{o({groupId:e.id,subgroupId:t.id,color:t.color})},children:[(0,n.jsx)("span",{className:"font-normal text-sm leading-5 tracking-[-0.28px]",children:(0,k.$G)(t.name,20)}),(0,n.jsx)("div",{className:"h-4 w-4 rounded-md border border-white",style:{backgroundColor:t.color}})]},t.id)),(0,n.jsx)(i.yEP,{}),(0,n.jsx)(eo.Z,{kind:"multi-node",nodesIds:t,groupId:e.id,children:(0,n.jsx)(i.Naz,{inset:!0,onClick:e=>{e.preventDefault(),e.stopPropagation()},className:"text-center font-medium leading-6 tracking-[-0.32px]",children:"Create new groups"})})]},e.id))]})});var ey=(0,c.memo)(e=>{let{nodesIds:t,translate:s,rect:l}=e,{x:a,y:r,zoom:o}=(0,O.Sj)(),[d,u]=(0,c.useState)(a),[x,h]=(0,c.useState)(r),[p,m]=(0,c.useState)(o),[g,f]=(0,c.useState)(s);return(d!==a||x!==r||p!==o)&&(f(()=>(0,k.Lj)(l,{x:a,y:r,zoom:o},w.m6.position,w.m6.offset,w.m6.align)),u(a),h(r),m(o)),(0,n.jsx)("div",{className:"nodrag nowheel nopan absolute z-50 flex h-fit w-fit flex-row gap-2 rounded-md bg-panel-solid p-1 drop-shadow-xl",style:{transform:g},children:(0,n.jsx)(i.nm8,{className:"m-0 h-11 p-0",children:(0,n.jsxs)(i.QPk,{children:[(0,n.jsx)(i.rQE,{asChild:!0,children:(0,n.jsxs)(i.zxk,{variant:"ghost",className:"flex gap-1 rounded-sm py-0",children:[(0,n.jsx)(B.pOD,{className:"h-4 w-4"}),(0,n.jsx)("span",{children:"Groups"})]})}),(0,n.jsx)(i.uET,{children:(0,n.jsx)(eN,{nodesIds:t})})]})})})}),ek=s(76690),eO=()=>{let e=ek.S.useContext(),[,t]=(0,d.KO)(r.mi);return{addCanvasObject:ek.S.canvasObject.add.useMutation({onSuccess:async()=>
1{await e.canvasObject.all.invalidate(),await e.captureEvent.all.invalidate(),t(0)}}),editCanvasObject:ek.S.canvasObject.edit.useMutation({onSuccess:async()=>{await e.canvasObject.all.invalidate(),await e.captureEvent.all.invalidate()}})}},eC=s(74654),eS=s(8048),eE=()=>{let[e]=(0,d.KO)(r.lT),[t]=(0,d.KO)(r.B_),[,s]=(0,d.KO)(r.lf),{addCanvasObject:l}=eO(),[a,n]=(0,d.KO)(r.r5),[o]=(0,d.KO)(r.O0);return{save:(0,c.useCallback)(async()=>{if(!o)return;let r=t.nodes.filter(e=>!e.id.includes("ghost")).map(e=>({...e,selected:!1,dragging:!1})),i=t.edges.map(e=>({...e,selected:!1,dragging:!1})),d={nodes:r,edges:i};if(!await (0,eC.Z)(d,a)){let a=await (0,eS.L)(d);n(a),s(Date.now()),l.mutate({processId:e,hash:a,data:{nodes:r,edges:i,viewport:t.viewport},version:"v1"},{onSuccess:()=>{n(a),s(Date.now())}})}},[l,t,o,a,e,n,s])}},eI=s(32212),eP=s(24506),eT=s(48502),eZ=s(25457),eA=e=>{let{currentCaptureEdges:t,currentCaptureNodes:s}=e,[,l]=(0,d.KO)(r.Cf),[,a]=(0,d.KO)(r.s5),[,n]=(0,d.KO)(r.nW),[,o]=(0,d.KO)(r.y6),[i,u]=(0,c.useState)(s),[x,h]=(0,c.useState)(t);if(i!==s){let e=s.filter(e=>!e.id.includes("ghost"));l(e.every(e=>e.type===b.$P.QUESTION)),a(e.filter(e=>!!((0,k.JG)(e)&&(e.data.what===w.vP.WHAT||e.data.who===w.vP.WHO||e.data.where===w.vP.WHERE)||(0,k.hr)(e)&&e.data.question===w.vP.WHAT)).length>0),u(s)}if(x!==t){let e=s.filter(e=>!e.id.includes("ghost")),l=e.filter(e=>e.type===b.$P.QUESTION);if(l.length>0)try{let s=l.every(s=>{let l=(0,k.dk)(s,e,t).findIndex(e=>e.type===b.$P.ACTION);return -1!==l});n(s)}catch(e){n(!1)}h(t)}if(x!==t&&i!==s){let e=s.filter(e=>!e.id.includes("ghost")),l=e.filter(e=>e.type===b.$P.QUESTION);if(o(l.filter(e=>(0,O.my)([e],t).filter(t=>t.type===eZ.r.ANSWER&&e.id!==t.target).length<=1).map(e=>e.id)),l.length>0)try{let s=l.every(s=>{let l=(0,k.dk)(s,e,t).findIndex(e=>e.type===b.$P.ACTION);return -1!==l});n(s)}catch(e){n(!1)}u(s),h(t)}};function eK(e,t){let[s,l]=(0,c.useState)(!1),a=(0,O.Kr)(e,{actInsideInputWithModifier:!1});(0,c.useEffect)(()=>{a&&!s?(t(),l(!0)):l(a)},[a,s,t])}var ez=function(e){let t=(0,c.useRef)({x:0,y:0}),s=(0,O.oR)(e=>e.domNode),[l,a]=(0,d.KO)(r.iY),{getNodes:n,setNodes:o,getEdges:i,setEdges:u,screenToFlowPosition:x}=(0,O._K)(),[h,p]=(0,c.useState)([]),[m,g]=(0,c.useState)([]);(0,c.useEffect)(()=>{if(s){let e=e=>{t.current={x:e.clientX,y:e.clientY}};return s.addEventListener("mousemove",e),()=>{s.removeEventListener("mousemove",e)}}},[s]);let f=(0,c.useCallback)(()=>{let t=n().filter(e=>e.selected),s=(0,O.my)(t,i()).filter(e=>{let s=t.every(t=>t.id!==e.source),l=t.every(t=>t.id!==e.target);return!(s||l)});p(t),g(s),a({nodes:t,edges:s,currentProcessId:e})},[n,i,e,a]),v=(0,c.useCallback)(()=>{let t=n().filter(e=>e.selected),s=(0,O.my)(t,i()).filter(e=>{let s=t.every(t=>t.id!==e.source),l=t.every(t=>t.id!==e.target);return!(s||l)});p(t),g(s),a({nodes:t,edges:s,currentProcessId:e}),o(e=>e.filter(e=>!e.selected)),u(e=>e.filter(e=>!s.includes(e)))},[n,o,i,u,e,a]),j=(0,c.useCallback)(function(){let{x:s,y:a}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:x({x:t.current.x,y:t.current.y}),n=[],r=[];if(""!==l.currentProcessId&&l.currentProcessId!==e){let e=Math.min(...l.nodes.map(e=>e.position.x)),t=Math.min(...l.nodes.map(e=>e.position.y)),o=Date.now();n=l.nodes.map(l=>{let n="".concat(l.id,"-").concat(o),r=s+(l.position.x-e),i=a+(l.position.y-t);return{...l,id:n,position:{x:r,y:i}}}),r=l.edges.map(e=>{let t="".concat(e.id,"-").concat(o),s="".concat(e.source,"-").concat(o),l="".concat(e.target,"-").concat(o);return{...e,id:t,source:s,target:l}})}else{let e=Math.min(...h.map(e=>e.position.x)),t=Math.min(...h.map(e=>e.position.y)),l=Date.now();n=h.map(n=>{let r="".concat(n.id,"-").concat(l),o=s+(n.position.x-e),i=a+(n.position.y-t);return{...n,id:r,position:{x:o,y:i}}}),r=m.map(e=>{let t="".concat(e.id,"-").concat(l),s="".concat(e.source,"-").concat(l),a="".concat(e.target,"-").concat(l);return{...e,id:t,source:s,target:a}})}o(e=>[...e.map(e=>({...e,selected:!1})),...n]),u(e=>[...e.map(e=>({...e,selected:!1})),...r])},[h,m,x,o,u,l,e]);return eK(["Meta+x","Control+x"],v),eK(["Meta+c","Control+c"],f),eK(["Meta+v","Control+v"],j),{
1cut:v,copy:f,paste:j,bufferedNodes:h,bufferedEdges:m}},e_=s(72382),eL=s(734),eR=s(76473),eD=()=>{let e=ek.S.useContext();return{undoEvent:ek.S.captureEvent.undo.useMutation({onSuccess:async()=>{await e.canvasObject.findOne.invalidate(),await e.canvasObject.all.invalidate(),await e.group.all.invalidate(),await e.subgroup.all.invalidate(),await e.subgroup.findSubgroupsByNode.invalidate(),await e.subgroup.findCurrentSubgroup.invalidate(),await e.subgroup.findNodesBySubgroup.invalidate()}}),redoEvent:ek.S.captureEvent.redo.useMutation({onSuccess:async()=>{await e.canvasObject.findOne.invalidate(),await e.canvasObject.all.invalidate(),await e.group.all.invalidate(),await e.subgroup.all.invalidate(),await e.subgroup.findSubgroupsByNode.invalidate(),await e.subgroup.findCurrentSubgroup.invalidate(),await e.subgroup.findNodesBySubgroup.invalidate()}})}},eH=function(e){var t,s,l,a;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"desc",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,[o,i]=(0,c.useState)(0),{error:d,isError:u,isLoading:x,data:h,fetchNextPage:p,hasNextPage:m,isFetching:g}=ek.S.captureEvent.all.useInfiniteQuery({filters:{processId:e},order:n,limit:r},{getNextPageParam:e=>e.nextCursor,refetchOnWindowFocus:!1}),f=h&&null!==(l=null===(t=h.pages[o])||void 0===t?void 0:t.events)&&void 0!==l?l:null,v=async()=>{await p(),i(e=>e+1)},j=(0,c.useMemo)(()=>null==h?void 0:h.pages.flatMap(e=>e.events),[h]);return{wholeCaptureEvents:null!=j?j:null,batchCaptureEvents:null!=f?f:null,captureEventIsLoading:x,captureEventError:d,captureEventCount:null!==(a=null==h?void 0:null===(s=h.pages[0])||void 0===s?void 0:s.totalEventsCount)&&void 0!==a?a:0,isError:u,onNextPage:v,isFetching:g,hasNextPage:m,page:o}},eF=()=>{let[e]=(0,d.KO)(r.lT),[t,s]=(0,d.KO)(r.mi),[,l]=(0,d.KO)(r.NR),[,a]=(0,d.KO)(r.$X),[,n]=(0,d.KO)(r.O0),{toast:o}=(0,y.pm)(),{undoEvent:i,redoEvent:c}=eD(),{batchCaptureEvents:u,captureEventIsLoading:x,isError:h}=eH(e,"desc",20);(0,eR.y1)("mod+z",()=>{if(x)return;if(h){o({title:"Save point",description:"Error loading save points",variant:"destructive"});return}if(!u)return;if(t>=u.length-1){o({title:"Save point",description:"No more changes to undo",variant:"default"});return}n(!1);let e=u.at(t);e&&(s(t+1),o({title:"Undo",description:"Undoing changes"}),i.mutate({eventId:e.id},{onSuccess:()=>{l([{nodeId:"",color:""}]),a({subgroupId:"",selectedNodesIds:[""]}),o({title:"Undo",description:"Done",variant:"default"})},onError:()=>{o({title:"Undo",description:"Something went wrong",variant:"destructive"})}}))}),(0,eR.y1)("mod+shift+z",()=>{if(x)return;if(h){o({title:"Save point",description:"No more changes to redo",variant:"destructive"});return}if(!u)return;if(t<0){o({title:"Save point",description:"It is the latest save point",variant:"default"});return}n(!1);let e=t-1,r=u.at(e);r&&(s(e),o({title:"Redo",description:"Redoing changes"}),c.mutate({eventId:r.id},{onSuccess:()=>{l([{nodeId:"",color:""}]),a({subgroupId:"",selectedNodesIds:[""]}),o({title:"Redo",description:"Done",variant:"default"})},onError:()=>{o({title:"Redo",description:"Something went wrong",variant:"destructive"})}}))})},eW=s(61891),eG=s(72298),eM=(0,c.memo)(()=>{let[e]=(0,d.KO)(r.lf),[t,s]=(0,c.useState)((0,eW.U)(e,Date.now()));return(0,eG.Z)(()=>{s((0,eW.U)(e,Date.now()))},500),(0,n.jsx)(O.s_,{className:"flex h-10 w-52 flex-col items-center justify-center gap-4 roun
1ded-lg ",position:"bottom-right",children:(0,n.jsxs)("span",{className:"text-slate-600 text-sm dark:text-slate-500",children:["Last saved: ",t]})})});let eV={info:(0,n.jsx)(o.PJP.Info,{})};var eJ=(0,c.memo)(e=>{let{title:t,description:s,className:l,icon:a}=e;return(0,n.jsxs)(i.bZj,{className:(0,o.cn)("-translate-x-1/2 -translate-y-1/2 top-1/2 left-1/2 flex w-fit flex-row items-center justify-evenly gap-x-3",l),children:[(0,n.jsx)("div",{children:eV[a]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(i.CdC,{className:"w-fit",children:t}),(0,n.jsx)(i.XaZ,{className:"w-fit",children:s})]})]})}),eU=s(11050),eQ=s(41947),e$=s(77749),eB=s(55305),eq=s(91041),eX=(0,c.memo)(e=>{let{reactFlowWrapper:t}=e,{isFirefoxBrowser:s}=(0,eQ.Z)(),l=(0,O._K)(),{removeGhostNodes:a}=(0,eT.Z)(),{getClosestEdge:o}=(0,eU.Z)(),[,i]=(0,d.KO)(e$.O0),[u]=(0,d.KO)(r.Tz),[x,h]=(0,c.useState)({x:0,y:0}),p=(e,t)=>{e.dataTransfer.setData("application/reactflow",t),i(!1),a();let s=new Image;e.dataTransfer.setDragImage(s,0,0)},m=(0,c.useCallback)(e=>null===t.current?{x:0,y:0}:l.screenToFlowPosition({x:e.clientX,y:e.clientY}),[l,t]),g=(0,c.useCallback)(e=>{let t=o(e);i(!1),t&&("ghostQuestion"===t.source||"ghostAction"===t.source)||l.setEdges(e=>{let s=e.filter(e=>"temp"!==e.className);return s.find(e=>t&&e.id===t.id)||t&&!s.find(e=>e.source===t.source&&e.target===t.target)&&(t.className="temp",t.animated=!0,s.push(t)),s})},[o,l,i]),f=(0,c.useCallback)((e,t)=>{let n;if(!(n=s?u:m(e))){a();return}if(i(!1),x.x===n.x&&x.y===n.y)return;h(n),l.setNodes(e=>e.map(e=>e.id===t?{...e,position:n,hidden:!1}:e));let r=l.getNode(t);if(!r){a();return}g(r)},[g,u,m,s,x.x,x.y,l,a,i]);return(0,n.jsx)(O.s_,{className:"flex h-28 w-16 flex-col items-center justify-center gap-4 roun
1ded-lg border-2 border-gray-200 border-solid bg-white drop-shadow-lg",position:"top-left",id:"capture-panel",children:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eB.Z,{draggable:!0,onDrag:e=>f(e,"ghostAction"),onDragStart:e=>p(e,b.$P.ACTION),kind:b.n6.ENABLE}),(0,n.jsx)(eq.Z,{kind:b.n6.ENABLE,onDragStart:e=>p(e,b.$P.QUESTION),draggable:!0,onDrag:e=>f(e,"ghostQuestion")})]})})}),eY=()=>(0,n.jsx)(o.Cts,{className:"w-fit rounded-full border-green-700 bg-green-600 px-2 text-gray-100",children:"beta"}),e0=s(67507),e1=(0,c.memo)(()=>{let{toast:e}=(0,y.pm)(),t=(0,x.useRouter)(),{handle:s,memberCan:l}=(0,e0.Q)({capability:"FORMAT_FLOW",humanReadableAction:"Swimlane diagram"}),a=(0,d.b9)(r.oJ),u=(0,d.b9)(r.O0),[h]=(0,d.KO)(r.y5),[p]=(0,d.KO)(r.Cf),m=(0,d.b9)(r.J),[g]=(0,c.useState)(r.s5),[f]=(0,d.KO)(r.nW),[v]=(0,d.KO)(r.y6),j=(0,c.useMemo)(()=>v.length>0,[v.length]),w=async()=>{u(!1),m(!1);let s=(0,k.R0)(t.asPath);await t.push("".concat(s,"?flow=format")),a(!1),g&&e({title:"Swimlane diagram",description:"Each red field is a default value",variant:"default"})};return j?(0,n.jsx)(i.zxk,{variant:"ghost",className:"flex h-8 w-24 flex-col items-center justify-center justify-items-center border-2 border-gray-200 border-solid bg-white p-0 hover:bg-accent-color-accent-2 active:bg-accent-color-accent-2 dark:text-gray-500",onClick:()=>{e({title:"Swimlane diagram",description:"Create at least two answers per question to continue",variant:"destructive"}),m(!0),setTimeout(()=>{m(!1)},3e3)},children:(0,n.jsx)(o.PJP.Ban,{className:"stroke-gray-500"})}):p?(0,n.jsx)(i.zxk,{variant:"ghost",className:"flex h-8 w-24 flex-col items-center justify-center justify-items-center border-2 border-gray-200 border-solid bg-white p-0 hover:bg-accent-color-accent-2 active:bg-accent-color-accent-2 dark:text-gray-500",onClick:()=>{e({title:"Swimlane diagram",description:"Please create at least one action node to continue",variant:"destructive"})},children:(0,n.jsx)(o.PJP.Ban,{className:"stroke-gray-500"})}):f?h?(0,n.jsx)("button",{type:"button",onClick:s(w),id:"format-panel-button",children:(0,n.jsxs)(i.zxk,{variant:"ghost",disabled:!l,className:"flex h-10 w-auto flex-row items-center justify-center justify-items-center gap-2 border border-accent-color-accent-alpha-8 border-solid bg-white hover:bg-accent-color-accent-2 active:bg-accent-color-accent-2 dark:text-black",children:["Swimlane Diagram ",(0,n.jsx)(eY,{})]})}):(0,n.jsx)(i.zxk,{variant:"ghost",className:"flex h-8 w-24 flex-col items-center justify-center justify-items-center border-2 border-gray-200 border-solid bg-white p-0 hover:bg-accent-color-accent-2 active:bg-accent-color-accent-2 dark:text-gray-500",onClick:()=>{e({title:"Swimlane diagram",description:"Please fill every field in each node to continue",variant:"destructive"}),m(!0),setTimeout(()=>{m(!1)},3e3)},children:(0,n.jsx)(o.PJP.Ban,{className:"stroke-gray-500"})}):(0,n.jsx)(i.zxk,{variant:"ghost",className:"flex h-8 w-24 flex-col items-center justify-center justify-items-center border-2 border-gray-200 border-solid bg-white p-0 hover:bg-accent-color-accent-2 active:bg-accent-color-accent-2 dark:text-gray-500",onClick:()=>{e({title:"Swimlane diagram",description:"All questions must have at least an action ancestor",variant:"destructive"}),m(!0),setTimeout(()=>{m(!1)},3e3)},children:(0,n.jsx)(o.PJP.Ban,{className:"stroke-gray-500"})})}),e2=s(52365),e5=s(25933),e3=s(1197),e4=e=>{let{processId:t,documentType:s,enabled:l=!0}=e,a=ek.S.anthropic.generateDocument.useQuery({processId:t,documentType:s},{enabled:l,refetchOnWindowFocus:!1});return{answer:a.data,isLoading:a.isLoading,error:a.error,isError:a.isError}},e6=()=>ek.S.markdown.markdownConverter.useMutation();let e8={pdf:"application/pdf",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"},e9=e=>{let{enableApiCall:t,documentType:s,title:l,setIsOpen:a}=e,{toast:r}=(0,y.pm)(),i=(0,m.Z)("processId"),{mutate:d,isLoading:c}=e6(),{isLoading:u,isError:x,answer:h}=e4({processId:i,documentType:s,enabled:t});if(u)return(0,n.jsxs)("div",{className:"flex w-full flex-1 flex-col items-center justify-center gap-2",children:[(0,n.jsxs)("span",{className:"animate-bounce",children:["Generating ",l,"..."]}),Array.from({length:5}).map((e,t)=>(0,n.jsx)(o.OdW,{className:"h-8 w-80"},"".concat(t,"-ai-skeleton")))]});if(x||void 0===h)return(0,n.jsx)("div",{children:"Something went wrong"});let p=e=>{d({markdown:h,convertTo:e},{onSuccess:t=>{let s="data:".concat(e8[e],";base64,").concat(t),a=document.createElement("a");a.href=s,a.download=l,a.click()},onError:()=>{r({title:"AI Analysis",description:"Something went wrong trying to create your file",variant:"destructive"})}})};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(o.h9,{className:"h-6 w-fit self-end",textToCopy:h}),(0,n.jsx)(e5.U,{className:"prose w-full",remarkPlugins:[e3.Z],children:h}),(0,n.jsxs)("div",{className:"flex justify-end gap-3",children:[(0,n.jsxs)(o.h_2,{children:[(0,n.jsx)(o.$FS,{disabled:c,
1children:(0,n.jsx)(o.zxk,{variant:"outline",children:c?"Generating...":(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(o.PJP.ChevronDown,{className:"text-neutral-500"}),"Download as"]})})}),(0,n.jsxs)(o.AWV,{children:[(0,n.jsx)(o.Xiv,{onClick:()=>p("docx"),children:"DOCX"}),(0,n.jsx)(o.Xiv,{onClick:()=>p("pdf"),children:"PDF"})]})]}),(0,n.jsx)(o.zxk,{onClick:()=>a(!1),children:"Done"})]})]})};var e7=e=>{let{documentType:t,icon:s,title:l}=e,[a,r]=(0,c.useState)(!1);return(0,n.jsxs)(o.VqE,{open:a,onOpenChange:r,children:[(0,n.jsx)(o.hgM,{children:(0,n.jsx)("div",{className:"cursor-pointer rounded-md border p-4 transition-colors hover:border-teal-500 hover:bg-teal-50",children:(0,n.jsxs)("div",{className:"flex items-start",children:[(0,n.jsx)("div",{className:"mt-0.5 mr-3 text-teal-600",children:s}),(0,n.jsx)("div",{children:(0,n.jsx)("h3",{className:"font-medium",children:l})})]})})}),(0,n.jsxs)(o.cZJ,{className:"flex h-fit max-h-[75vh] min-h-[50vh] w-fit min-w-[30vw] max-w-[70vw] flex-col overflow-y-auto 2xl:max-h-[60vh] 2xl:max-w-[80vw]",children:[(0,n.jsx)(o.fKu,{children:(0,n.jsx)(o.$N8,{children:l})}),(0,n.jsx)(e9,{title:l,documentType:t,enableApiCall:a,setIsOpen:r})]})]})},te=()=>(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,n.jsx)(e7,{documentType:"PROCESS_AUTOMATION_ASSESSMENT",title:"Process Automation Assessment",icon:(0,n.jsx)(ej.P.Workflow,{className:"h-5 w-5"})}),(0,n.jsx)(e7,{documentType:"PROCESS_IMPROVEMENT_ANALYSIS",title:"Process Improvement Analysis",icon:(0,n.jsx)(ej.P.BarChart3,{className:"h-5 w-5"})}),(0,n.jsx)(e7,{documentType:"JOB_SUCCESS_PROFILE",title:"Job Success Profile",icon:(0,n.jsx)(ej.P.UserCheck,{className:"h-5 w-5"})}),(0,n.jsx)(e7,{documentType:"DOCUMENT_CHECKLIST",title:"Document Checklist",icon:(0,n.jsx)(ej.P.ClipboardList,{className:"h-5 w-5"})}),(0,n.jsx)(e7,{documentType:"ROLE_CARD",title:"Role Card",icon:(0,n.jsx)(ej.P.IdCard,{className:"h-5 w-5"})})]}),tt=s(63706),ts=()=>{let[e]=(0,d.KO)(r.lT),{process:t,processError:s,processIsLoading:l}=(0,v.Z)({processId:e});if(l)return(0,n.jsx)(O.s_,{className:(0,tt.cn)("flex h-8 w-60 flex-row p-0","rounded-lg","items-center justify-items-center"),position:"top-center",children:(0,n.jsx)("span",{className:"animate-pulse text-center text-2xl",children:"Loading..."})});if(s)return(0,n.jsx)(O.s_,{className:(0,tt.cn)("flex h-8 w-60 flex-row p-0","rounded-lg","items-center justify-items-center"),position:"top-center",children:(0,n.jsx)("span",{className:"text-center text-2xl",children:"Something went wrong"})});if(!t)return(0,n.jsx)(O.s_,{className:(0,tt.cn)("flex h-8 w-60 flex-row p-0","rounded-lg","items-center justify-items-center"),position:"top-center",children:(0,n.jsx)("span",{className:"text-center text-2xl",children:"No process found"})});let a=(0,k.JH)(t.title,50,{smallSize:"text-lg",regularSize:"text-2xl"});return(0,n.jsxs)(O.s_,{className:(0,tt.cn)("relative flex h-8 w-3/4 flex-col bg-white p-0 ","rounded-lg","items-start justify-items-center"),position:"top-center",children:[(0,n.jsx)("span",{className:(0,tt.cn)("z-10 line-clamp-3 w-full text-center",a),children:t.title}),(0,n.jsx)("div",{className:"-top-4 absolute h-full w-full bg-white"})]})},tl=s(22958),ta=e=>{let{className:t,isPanel:s=!1}=e,{zoomIn:l,zoomOut:a,fitView:r}=(0,O._K)(),d=()=>{l()},c=()=>{a()},u=()=>{r({padding:.2})};return s?(0,n.jsxs)(O.s_,{position:"bottom-left",className:(0,o.cn)("flex w-full max-w-[15rem] flex-row items-center justify-between gap-2 rounded-2xl border border-gray-400 p-1",t),children:[(0,n.jsx)("span",{className:"px-2 text-center text-sm",children:"Zoom"}),(0,n.jsxs)("div",{className:"flex flex-row items-center justify-items-center gap-1",children:[(0,n.jsx)(tl.Z,{text:"Zoom In",children:(0,n.jsx)(i.zxk,{onClick:d,variant:"soft",className:"h-10 w-10 p-1 text-2xl",children:"+"})}),(0,n.jsx)(tl.Z,{text:"Zoom Out",children:(0,n.jsx)(i.zxk,{onClick:c,variant:"soft",className:"h-10 w-10 p-1 text-2xl",children:"-"})}),(0,n.jsx)(tl.Z,{text:"Fit View",children:(0,n.jsx)(i.zxk,{onClick:u,variant:"soft",className:"h-10 w-10 p-1 text-xl",children:(0,n.jsx)(ej.P.Maximize,{className:"h-6 w-6"})})})]})]}):(0,n.jsxs)("div",{className:(0,o.cn)("flex w-full max-w-[15rem] flex-row items-center justify-between gap-2 rounded-2xl border border-gray-400 p-1",t),children:[(0,n.jsx)("span",{className:"px-2 text-center text-sm",children:"Zoom"}),(0,n.jsxs)("div",{className:"flex flex-row items-center justify-items-center gap-1",children:[(0,n.jsx)(tl.Z,{text:"Zoom In",children:(0,n.jsx)(i.zxk,{onClick:d,variant:"soft",className:"h-10 w-10 p-1 text-2xl",children:"+"})}),(0,n.jsx)(tl.Z,{text:"Zoom Out",children:(0,n.jsx)(i.zxk,{onClick:c,variant:"soft",className:"h-10 w-10 p-1 text-2xl",children:"-"})}),(0,n.jsx)(tl.Z,{text:"Fit View",children:(0,n.jsx)(i.zxk,{onClick:u,variant:"soft",className:"h-10 w-10 p-1 text-xl",children:(0,n.jsx)(ej.P.Maximize,{className:"h-6 w-6"})})})]})]})},tn=s(85779),tr=s(79236),to=s(45940),ti=()=>(0,n.jsx)(O.s_,{className:(0,o.cn)("flex h-16 w-20 flex-row p-0 ","rounded-lg","items-center justify-items-center"),position:"top-left",children:(0,n.jsx)(to.Z,{})}),td=s(52252),tc=s(21308),tu=s(14964),tx=()=>(0,n.jsx)("div",{className:"flex h-full w-1/3 max-w-2xl flex-col justify-between gap-4 overflow-y-hidden rounded-sm bg-accent-color-accent-1 p-4 md:p-2",children:(0,n.jsx)(tu.Z,{allowToDelete:!1})});let th={hideAttribution:!0},tp={[b.$P.ACTION]:td.Z,[b.$P.QUESTION]:tc.Z},tm={[b.rP.TIME]:tr.Z,[b.rP.ANSWER]:tn.Z};var tg=e=>{let[t]=(0,d.KO)(r.t_),[s]=(0,d.KO)(r.Kg),[l]=(0,d.KO)(r.lq),[a,i]=(0,c.useState)(s),[x,h]=(0,O.Rr)([]),[p,m]=(0,O.ll)([]),[g,f]=(0,c.useState)(!1),[v,j]=(0,c.useState)(!1),w=(0,O._K)(),b=(0,c.useCallback)(()=>{let e=s.map(e=>({...e,selected:!1}));h(e),m(l),f(!0),setTimeout(()=>{f(!0),j(0===e.length),w.fitView({padding:.2})},100)},[s,h,m,l,w]);if(a!==s){let e=s.map(e=>({...e,selected:!1}));h(e),m(l),j(0===e.length),i(s)}return(0,n.jsxs)("div",{className:(0,o.cn)("flex h-full w-full flex-row","rounded-lg border-2 border-gray-200 bg-white dark:border-gray-700 dark:bg-slate-900"),children:[g?null:(0,n.jsx)("div",{className:"absolute z-10 flex h-full w-full items-center justify-center bg-white dark:bg-slate-900",children:(0,n.jsx)(u.Z,{description:"Loading your group",textClassName:"text-center text-lg"})}),(0,n.jsxs)(O.x$,{nodes:x,edges:p,edgesUpdatable:!1,edgesFocusable:!1,nodesConnectable:!1,nodesDraggable:!1,nodesFocusable:!1,elementsSelectable:!1,disableKeyboardA11y:!0,nodeTypes:tp,edgeTypes:tm,onInit:b,proOptions:th,style:{opacity:g?1:0},deleteKeyCode:null,zoomOnPinch:!1,zoomOnDoubleClick:!1,panOnScroll:!1,panActivationKeyCode:null,multiSelectionKeyCode:null,selectionKeyCode:null,fitView:!0,fitViewOptions:{padding:.2},minZoom:0,nodeDragThreshold:10,nodeOrigin:[.5,.5],children:[(0,n.jsx)(ts,{}),(0,n.jsx)(ti,{}),"group"===e.kind?(0,n.jsx)(O.s_,{position:"bottom-right",children:(0,n.jsx)("span",{className:"p-4 font-bold text-base leading-6 tracking-[-0.32px]",children:"Groups"})}):null,v?(0,n.jsx)(eJ,{icon:"info",title:"Info Message",description:"No nodes found in this group"}):null,(0,n.jsx)(ta,{isPanel:!0})]}),t?(0,n.jsx)(tx,{}):null]})},tf=()=>{let[e,t]=(0,c.useState)(),[,s]=(0,d.KO)(r.Bx),[l]=(0,d.KO)(r.G$),[a]=(0,d.KO)(r.RB),o=l.filter(e=>e.isVisible);return((0,c.useEffect)(()=>{var t,l;e&&(s(null!==(l=null===(t=o[e.selectedScrollSnap()])||void 0===t?void 0:t.id)&&void 0!==l?l:""),e.on("select",()=>{var t,l;s(null!==(l=null===(t=o[e.selectedScrollSnap()])||void 0===t?void 0:t.id)&&void 0!==l?l:"")}
1))},[e,o,s]),a&&0!==o.length)?(0,n.jsxs)(i.lr9,{setApi:t,className:"max-w-[76rem]",children:[(0,n.jsx)(i.KIA,{children:o.map(e=>(0,n.jsx)(i.d$M,{children:(0,n.jsx)("div",{className:"h-[60vh] w-full p-1",children:(0,n.jsx)(O.tV,{children:(0,n.jsx)(tg,{kind:"group",groupName:e.name,groupId:e.id},e.id)})})},e.id))}),(0,n.jsx)(i.amd,{className:"left-3 h-12 w-12"}),(0,n.jsx)(i.PzL,{className:"right-7 h-12 w-12"})]}):(0,n.jsxs)(i.lr9,{setApi:t,className:"max-w-[76rem]",children:[(0,n.jsx)(i.KIA,{children:(0,n.jsx)(i.d$M,{children:(0,n.jsx)("div",{className:"h-[60vh] w-full p-1",children:(0,n.jsx)(O.tV,{children:(0,n.jsx)(tg,{kind:"whole-process"})})})})}),(0,n.jsx)(i.amd,{className:"left-3 h-12 w-12"}),(0,n.jsx)(i.PzL,{className:"right-7 h-12 w-12"})]})};let tv=(e,t)=>{var s;if(0===t.length)return!1;let l=t.find(t=>t.id===e);return null!==(s=null==l?void 0:l.isVisible)&&void 0!==s&&s},tj=(e,t)=>{var s;return null===(s=t.find(t=>t.id===e))||void 0===s?void 0:s.subgroups},tw=()=>(0,n.jsx)("div",{className:"flex w-full cursor-grab flex-row items-center justify-center gap-2 rounded-t-xl bg-neutral-neutral-4 px-4 py-2",children:(0,n.jsx)("span",{className:"select-none font-bold text-base leading-6 tracking-[-0.32px]",children:"Groups"})});var tb=e=>{let{className:t}=e,s=(0,m.Z)("processId"),[l,a]=(0,d.KO)(r.G$),[,u]=(0,d.KO)(r.RB),[,x]=(0,d.KO)(r.Bx),{groups:h,isErrorGroups:p,isLoadingGroups:g}=(0,ec.Z)({processId:s,enabled:""!==s}),f=(0,c.useCallback)(e=>{a(t=>t.map(t=>{var s,l;return void 0!==(null===(s=t.subgroups)||void 0===s?void 0:s.find(t=>t.id===e))?{...t,subgroups:null===(l=t.subgroups)||void 0===l?void 0:l.map(t=>t.id===e?{...t,isVisible:!t.isVisible}:t)}:t}))},[a]);return g?(0,n.jsxs)("div",{className:(0,o.cn)("flex h-fit w-full flex-col items-center rounded-2xl bg-white ","border border-accent-color-accent-alpha-4","pb-4",t),children:[(0,n.jsx)(tw,{}),(0,n.jsx)("div",{className:"w-full px-4 pb-4",children:Array.from({length:3}).map((e,t)=>(0,n.jsx)(i.OdW,{className:"h-7 w-full"},"".concat(t,"-skeleton-group-selector")))})]}):p?(0,n.jsxs)("div",{className:(0,o.cn)("flex h-fit w-full flex-col items-center rounded-2xl bg-white ","border border-accent-color-accent-alpha-4","pb-4",t),children:[(0,n.jsx)(tw,{}),(0,n.jsx)("span",{className:"p-4 font-bold text-base leading-6 tracking-[-0.32px]",children:"Something went wrong"})]}):0===h.length?(u(!1),x(""),(0,n.jsxs)("div",{className:(0,o.cn)("flex h-fit w-full flex-col items-center rounded-2xl bg-white ","border border-accent-color-accent-alpha-4","pb-4",t),children:[(0,n.jsx)(tw,{}),(0,n.jsx)("span",{className:"p-4 font-bold text-base leading-6 tracking-[-0.32px]",children:"No groups found"})]})):(0,n.jsxs)("div",{className:(0,o.cn)("flex h-fit max-h-[60vh] w-full flex-col items-center rounded-2xl bg-white","border border-accent-color-accent-alpha-4",t),children:[(0,n.jsx)(tw,{}),(0,n.jsx)("div",{className:"w-full overflow-y-auto overflow-x-hidden px-4 py-3",children:h.map(e=>(0,n.jsx)("div",{className:"flex flex-col gap-2",children:e.subgroups.map(t=>{var s;return(0,n.jsx)("div",{className:"flex w-full flex-row items-start justify-start gap-1",children:(0,n.jsxs)("div",{className:"flex w-full flex-row items-center justify-between gap-2",children:[(0,n.jsxs)("div",{className:"flex w-full flex-row items-center justify-start gap-2",children:[(0,n.jsx)("div",{className:"h-4 w-4 rounded-md",style:{backgroundColor:t.color}}),(0,n.jsx)("span",{className:"font-medium text-sm leading-5 tracking-[-0.28px]",children:(0,k.$G)(t.name,20)})]}),(0,n.jsx)("div",{className:"flex w-fit flex-row items-center justify-end gap-1",children:(0,n.jsx)(i.XZJ,{checked:tv(t.id,null!==(s=tj(e.id,l))&&void 0!==s?s:[]),onCheckedChange:()=>f(t.id)})})]})},t.id)})},e.id))})]})},tN=s(6427),ty=s(8730),tk=s(87577),tO=s(35978),tC=()=>{let{toast:e}=(0,y.pm)(),{editProject:t}=(0,ty.Z)(),{currentProjectId:s}=(0,tN.Z)(),l=(0,m.Z)("projectId"),a=s||l;return a?(0,n.jsx)(tk.C,{prefixFile:"organizationLogo/".concat(a),accept:tO.X.image,maxNumberOfFiles:1,onChange:s=>{let[l]=s;if(!l){e({title:"Upload client logo",description:"Something went wrong uploading the logo",variant:"destructive"});return}t.mutate({id:a,clientLogoUrl:l.fileUrl},{onSuccess:()=>{e({title:"Image uploaded",description:"The image was uploaded successfully.",variant:"default"})},onError:()=>{e({title:"Error uploading image",description:"It was not possible to upload the image.",variant:"destructive"})}})}}):(0,n.jsx)("p",{children:"Unable to find project id"})},tS=()=>({addRequest:ek.S.export.add.useMutation()}),tE=s(875),tI=function(){var e;let{onError:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[s,l]=(0,c.useState)(!1),[a,n]=(0,c.useState)(!1),{addRequest:r}=tS(),{data:o}=(0,tE.Z)({exportRequestId:null!==(e=r.data)&&void 0!==e?e:""},{enabled:!!r.data&&s,refetchInterval:300,onSuccess:e=>{e&&l(!1)},onError:()=>{n(!0),l(!1),null==t||t()}});return{isLoading:s,generate:e=>{l(!0),n(!1),r.mutate(e,{onError:()=>{l(!1),n(!0),null==t||t()}})},data:o,isError:a}},tP=e=>{let{exportType:t}=e,s=(0,y.pm)(),{addRequest:l}=tS(),{isLoading:a,generate:i,data:u}=tI({onError:()=>{s.toast({title:"Export as SVG",description:"Something went wrong",variant:"destructive"})}}),[x,h]=(0,c.useState)(u),p=(0,m.Z)("processId"),[g]=(0,d.KO)(r.RB),[f]=(0,d.KO)(r.eL),[v]=(0,d.KO)(r.t_),[j]=(0,d.KO)(r.G$),[w]=(0,d.KO)(r.MA);if(u&&u!==x){var b,N,k,O;h(u);let e=g?null==u?void 0:null===(b=u.pathFiles)||void 0===b?void 0:b.pngWithGroups:null==u?void 0:null===(N=u.pathFiles)||void 0===N?void 0:N.pngWithoutGroups,t=(g?null==u?void 0:null===(k=u.pathFiles)||void 0===k?void 0:k.svgWithGroups:null==u?void 0:null===(O=u.pathFiles)||void 0===O?void 0:O.svgWithoutGroups)||e;if(t){let e=document.createElement("a");e.href=t,e.click()}}return(0,n.jsxs)(o.zxk,{onClick:()=>
1{if("pdf"===t){l.mutate({processId:p,addGroups:g,addNodeNotes:f,addProcessNotes:v,addFocalPoints:w,visibleSubgroups:j.reduce((e,t)=>{var s,l,a;return[...e,...null!==(a=null===(l=t.subgroups)||void 0===l?void 0:null===(s=l.filter(e=>e.isVisible))||void 0===s?void 0:s.map(e=>e.id))&&void 0!==a?a:[]]},[])},{onSuccess:e=>{window.open("/export/".concat(e,"?processId=").concat(p),"_blank")},onError:()=>{s.toast({title:"Export as PDF",description:"Something went wrong",variant:"destructive"})}});return}i({asPNG:"png"===t,addGroups:g,addNodeNotes:f,addProcessNotes:v,addFocalPoints:w,visibleSubgroups:j.reduce((e,t)=>{var s,l,a;return[...e,...null!==(a=null===(l=t.subgroups)||void 0===l?void 0:null===(s=l.filter(e=>e.isVisible))||void 0===s?void 0:s.map(e=>e.id))&&void 0!==a?a:[]]},[]),processId:p})},className:"flex w-40 justify-center gap-2",disabled:l.isLoading||a,children:[(0,n.jsx)(o.PJP.Download,{})," ",l.isLoading||a?"Generating...":"Export"]})},tT=e=>{let{value:t,setValue:s}=e;return(0,n.jsxs)(o.Eep,{defaultValue:"pdf",value:t,onValueChange:s,className:"grid grid-cols-2 gap-3",children:[(0,n.jsxs)("div",{className:"flex items-center space-x-5",children:[(0,n.jsx)(o.mJs,{value:"pdf",id:"pdf-option"}),(0,n.jsx)(o.__J,{htmlFor:"pdf-option",children:"PDF"})]}),(0,n.jsxs)("div",{className:"flex items-center space-x-5",children:[(0,n.jsx)(o.mJs,{value:"svg",id:"svg-option"}),(0,n.jsxs)(o.__J,{htmlFor:"svg-option",children:["SVG ",(0,n.jsx)("small",{className:"text-neutral-500",children:"(High Resolution)"})]})]}),(0,n.jsxs)("div",{className:"flex items-center space-x-5",children:[(0,n.jsx)(o.mJs,{value:"png",id:"png-option"}),(0,n.jsxs)(o.__J,{htmlFor:"png-option",children:["PNG ",(0,n.jsx)("small",{className:"text-neutral-500",children:"(Low resolution)"})]})]})]})},tZ=()=>{let[e,t]=(0,d.KO)(r.MA);return(0,n.jsxs)("div",{className:"flex items-center gap-3 p-1",children:[(0,n.jsx)(i.rsf,{checked:e,onClick:()=>{t(e=>!e)}}),(0,n.jsx)("span",{children:"Focal Points"})]})},tA=()=>{let[e,t]=(0,d.KO)(r.eL);return(0,n.jsxs)("div",{className:"flex items-center gap-3 p-1",children:[(0,n.jsx)(i.rsf,{checked:e,onClick:()=>{t(e=>!e)}}),(0,n.jsx)("span",{children:"Node Notes"})]})},tK=()=>{let[e,t]=(0,d.KO)(r.t_),s=(0,O._K)();return(0,n.jsxs)("div",{className:"flex items-center gap-3 p-1",children:[(0,n.jsx)(i.rsf,{checked:e,onClick:()=>{t(e=>!e),setTimeout(()=>{s.fitView({padding:.2})},100)}}),(0,n.jsx)("span",{children:"Process Notes"})]})},tz=()=>{let[e,t]=(0,d.KO)(r.RB);return(0,n.jsxs)("div",{className:"flex items-center gap-3 p-1",children:[(0,n.jsx)(i.rsf,{checked:e,onClick:()=>{t(e=>!e)}}),(0,n.jsx)("span",{children:"Export with groups"})]})},t_=()=>{let[e,t]=(0,c.useState)("pdf");if(!(0,m.Z)("projectId"))return(0,n.jsx)("p",{children:"Unable to find project id"});let s="mb-2 font-medium";return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"grid grid-cols-2",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)(o.C0v,{className:s,children:"Customize what to include"}),(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-1",children:[(0,n.jsx)(tA,{}),(0,n.jsx)(tZ,{}),(0,n.jsx)(tK,{}),(0,n.jsx)(tz,{})]}),(0,n.jsx)(o.C0v,{className:s,children:"Choose the format that fits your needs"}),(0,n.jsx)(tT,{value:e,setValue:t})]}),(0,n.jsxs)("div",{className:"flex flex-col",children:[(0,n.jsx)(o.C0v,{className:s,children:"Upload your logo"}),(0,n.jsx)(tC,{})]})]}),(0,n.jsx)("div",{className:"flex justify-end",children:(0,n.jsx)(tP,{exportType:e})})]})},tL=()=>{let e=(0,d.Dv)(r.RB);return(0,n.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,n.jsxs)("div",{className:(0,o.cn)("grid",{"grid-cols-[3fr_1fr]":e}),children:[(0,n.jsx)(tf,{}),e&&(0,n.jsx)(tb,{})]}),(0,n.jsx)(t_,{})]})},tR=s(96655),tD=e=>{let{processId:t,enabled:s=!0}=e,{data:l,isLoading:a,error:n,isError:r}=ek.S.process.processCompanyMetadataDetails.useQuery({processId:t},{enabled:s});return{processCompanyDetails:void 0!==l?l:null,isLoading:!!s&&a,error:n,isError:r}};W.z.object({companyName:W.z.string().trim().min(1,"Company name is required").max(50,"Company name must be less than ".concat(500," characters")),companyOverview:W.z.string().trim().min(1,"Company overview is required").max(500,"Company overview must be less than ".concat(500," characters"))});var tH=()=>{var e,t;let s=(0,m.Z)("processId"),[,l]=(0,d.KO)(r.N5),{addProcessCompanyMetadata:a,editProcessCompanyMetadata:o}=(0,tR.Z)(),{toast:u}=(0,y.pm)(),{processCompanyDetails:x,isLoading:h,isError:p}=tD({processId:s,enabled:""!==s}),g=(0,F.cI)({defaultValues:{companyName:"",companyOverview:""},values:{companyName:null!==(e=null==x?void 0:x.companyName)&&void 0!==e?e:"",companyOverview:null!==(t=null==x?void 0:x.companyOverview)&&void 0!==t?t:""}}),f=(0,c.useCallback)(e=>{let{companyName:t,companyOverview:n}=e;if(""===t){g.setError("companyName",{message:"Company name is required"},{shouldFocus:!0});return}if(""===n){g.setError("companyOverview",{message:"Company overview is required"},{shouldFocus:!0});return}if(!h&&!p&&null!==x){o.mutate({processId:s,companyName:t,companyOverview:n},{onSuccess:()=>{u({title:"Company details",description:"Saved",variant:"default"}),l(1)},onError:()=>{u({title:"Company details",description:"Something went wrong",variant:"destructive"})}});return}a.mutate({processId:s,companyName:t,companyOverview:n},{onSuccess:()=>{u({title:"Company details",description:"Saved",variant:"default"}),l(1)},onError:()=>{u({title:"Company details",description:"Something went wrong",variant:"destructive"})}})},[a,o,g,p,h,x,s,l,u]);return(0,n.jsx)(i.l09,{...g,children:(0,n.jsxs)("form",{onSubmit:g.handleSubmit(f),className:"flex h-fit flex-col justify-start gap-3",children:[(0,n.jsx)(i.WiK,{control:g.control,name:"companyName",render:e=>{let{field:t}=e;return(0,n.jsxs)(i.xJW,{children:[(0,n.jsx)(i.NIc,{children:(0,n.jsx)(i.IIB,{className:"flex pl-2",placeholder:"Company name",maxLength:50,...t})}),(0,n.jsx)(i.zGS,{})]})}}),(0,n.jsx)(i.WiK,{control:g.control,name:"companyOverview",render:e=>{let{field:t}=e;return(0,n.jsxs)(i.xJW,{children:[(0,n.jsx)(i.NIc,{children:(0,n.jsx)(i.gxH,{placeholder:"Company overview",maxLength:500,className:"h-full min-h-[33vh] p-2",...t})}),(0,n.jsx)(i.zGS,{})]})}}),(0,n.jsx)(i.cNS,{children:(0,n.jsx)(i.zxk,{disabled:a.isLoading||o.isLoading,type:"submit",children:"Next"})})]})})},tF=()=>{let e=(0,d.b9)(r.oJ),t=(0,d.b9)(r.N5),s=(0,d.Dv)(r.Kx),l=(0,c.useCallback)(()=>{e(!1),t(0)},[t,e]);return null===s?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(e5.U,{className:"prose",remarkPlugins:[e3.Z],children:"## No user stories send to Jira"}),(0,n.jsx)("div",{className:"flex justify-end",children:(0,n.jsx)(i.zxk,{onClick:l,children:"Done"})})]}):(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"flex flex-col items-start justify-center gap-3",children:[(0,n.jsxs)("div",{className:"flex flex-row gap-2",children:[(0,n.jsx)("span",{children:" Jira Project Title: "}),(0,n.jsxs)("span",{children:[" ",s.projectTitle," "]})]}),(0,n.jsxs)("div",{className:"flex flex-row gap-2",children:[(0,n.jsx)("span",{children:" Amount of stories created in your project: "}
1),(0,n.jsxs)("span",{children:[" ",s.issueCount," "]})]}),(0,n.jsxs)("div",{className:"flex flex-row gap-1",children:[(0,n.jsx)("a",{href:s.projectUrl,target:"_blank",rel:"noreferrer",children:"Project link"}),(0,n.jsx)(o.h9,{className:"h-6 w-fit self-end",textToCopy:s.projectUrl})]})]}),(0,n.jsx)("div",{className:"flex justify-end",children:(0,n.jsx)(i.zxk,{onClick:l,children:"Done"})})]})},tW=s(66158),tG=e=>{let{processId:t,enabled:s=!0}=e,l=ek.S.openAi.generateUserStories.useQuery({processId:t},{enabled:s,refetchOnWindowFocus:!1});return{answer:l.data,isLoading:l.isLoading,error:l.error,isError:l.isError}};let tM=e=>{let{isLoading:t,isError:s,answer:l}=e;return t?(0,n.jsxs)("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2",children:[(0,n.jsx)("span",{className:"animate-bounce text-lg",children:"Generating user stories..."}),Array.from({length:5}).map((e,t)=>(0,n.jsx)(i.OdW,{className:"h-8 w-[28rem]"},"".concat(t,"-ai-skeleton")))]}):s||void 0===l?(0,n.jsx)("div",{children:"Something went wrong"}):(0,n.jsxs)("div",{className:"flex w-full flex-col gap-1",children:[(0,n.jsx)(o.h9,{className:"h-6 w-fit self-end",textToCopy:l.markdownUserStories}),(0,n.jsx)(e5.U,{className:"prose w-full",remarkPlugins:[e3.Z],children:l.markdownUserStories})]})};var tV=()=>{let e=(0,m.Z)("processId"),[t,s]=(0,d.KO)(r.N5),[,l]=(0,d.KO)(r.Kx),{isLoading:a,isError:o,answer:x}=tG({processId:e,enabled:1===t}),{generateProjectScaffolding:h}=(0,tW.Z)(),{toast:p}=(0,y.pm)(),g=(0,c.useCallback)(()=>{h.mutate({processId:e,jsonUserStories:a||o||void 0===x?[]:x.jsonUserStories},{onSuccess:e=>{l(e),s(2),p({title:"Jira integration",description:"Your stories are now in Jira",variant:"default"})},onError:()=>{p({title:"Jira integration",description:"Something went wrong",variant:"destructive"})}})},[x,h,o,a,e,s,l,p]);return(0,n.jsxs)(n.Fragment,{children:[h.isLoading?(0,n.jsx)("div",{className:"flex h-full w-full items-center justify-center bg-white",children:(0,n.jsx)(u.Z,{textClassName:"text-center text-xl",description:"Saving your stories in Jira..."})}):(0,n.jsx)(tM,{answer:x,isLoading:a,isError:o}),(0,n.jsxs)("div",{className:"flex justify-end gap-3",children:[(0,n.jsx)(i.zxk,{variant:"outline",onClick:()=>{s(0)},children:"Back"}),(0,n.jsx)(i.zxk,{disabled:a||h.isLoading,onClick:g,children:"Create in Jira"})]})]})},tJ=()=>{let e=(0,d.Dv)(r.N5);return(0,n.jsxs)(n.Fragment,{children:[0===e&&(0,n.jsx)(tH,{}),1===e&&(0,n.jsx)(tV,{}),2===e&&(0,n.jsx)(tF,{})]})},tU=()=>{let e=(0,d.b9)(r.N5),[t,s]=(0,d.KO)(r.oJ),[l,a]=(0,c.useState)(t),{isLoading:i,isAvailable:u}=(0,eL.Z)(w.ZA.JIRA_INTEGRATION),x=!i&&u;return t!==l&&(a(t),e(0)),(0,n.jsxs)(o.VqE,{open:t,onOpenChange:s,children:[(0,n.jsx)(o.hgM,{asChild:!0,children:(0,n.jsxs)(e2.Z,{id:"export-capture-button",children:[(0,n.jsx)(o.PJP.Download,{className:"h-full w-3"}),(0,n.jsx)("span",{children:"Export"})]})}),(0,n.jsx)(o.cZJ,{className:"w-[55%] max-w-5xl",children:(0,n.jsxs)(o.xrM,{className:"pr-3",style:{maxHeight:window.innerHeight-60},children:[(0,n.jsxs)(o.fKu,{className:"flex-row items-center justify-between",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)(o.$N8,{children:"Export Process"}),(0,n.jsx)(o.BeV,{children:"Preview and export your process in different formats"})]}),(0,n.jsx)(e1,{})]}),(0,n.jsxs)(o.mQc,{defaultValue:"download",children:[(0,n.jsxs)(o.drW,{children:[(0,n.jsx)(o.SPt,{value:"download",children:"Download"}),x&&(0,n.jsxs)(o.SPt,{value:"ai",className:"gap-2",children:["AI Analysis ",(0,n.jsx)(eY,{})]}),x&&(0,n.jsxs)(o.SPt,{value:"jira",className:"gap-2",children:["Export to Jira ",(0,n.jsx)(eY,{})]})]}),(0,n.jsx)(o.nUL,{value:"download",children:(0,n.jsx)(tL,{})}),(0,n.jsx)(o.nUL,{value:"ai",children:(0,n.jsx)(te,{})}),(0,n.jsx)(o.nUL,{value:"jira",children:(0,n.jsx)(tJ,{})})]})]})})]})},tQ=s(34718),t$=s(47086),tB=s(29411),tq=s(51669),tX=e=>{let{groupId:t,children:s}=e,[l,a]=(0,c.useState)(!1),[,o]=(0,d.KO)(r.Th),u=(0,c.useCallback)(e=>{a(e),o(e)},[o]),x=(0,c.useCallback)(()=>{u(!0)},[u]);return(0,n.jsxs)(i.VqE,{open:l,onOpenChange:u,children:[(0,n.jsx)(i.hgM,{asChild:!0,onClick:x,children:void 0!==s?s:(0,n.jsx)(i.zxk,{size:1,className:"w-full",variant:"outline",children:(0,n.jsx)("span",{children:"Add groups"})})}),(0,n.jsx)(tq.Z,{kind:"single-step",setIsOpen:u,groupId:t},t)]})},tY=s(53126);let t0="Delete Group";var t1=e=>{let{subgroupId:t}=e,{deleteSubgroup:s}=(0,ep.Z)(),{toast:l}=(0,y.pm)(),a=(0,m.Z)("processId");return(0,n.jsx)(tY.Z,{triggerId:"delete-subgroup-button",entityType:"Group",handleDeleteEntity:()=>{s.mutate({subgroupId:t,processId:a},{onSuccess:()=>{l({title:t0,description:"Done",variant:"default"})},onError:()=>{l({title:t0,description:"Something went wrong",variant:"destructive"})}})},message:"This action cannot be undone.",icon:"trash",iconStyles:"h-4 text-sx"})},t2=s(14648),t5=s(70824);let t3="Edit group",t4=W.z.object({name:W.z.string().min(1,{message:"Name is required"}).max(w.KK,{message:"Name must be less than ".concat(w.KK," characters")}).refine(e=>0!==e.trim().length,{message:"Name must not contain only spaces"}),color:W.z.string().min(1,{message:"Color is required"})});var t6=e=>{let{subgroupId:t,setIsOpen:s}=e,{toast:l}=(0,y.pm)(),a=(0,m.Z)("processId"),{editSubgroup:r}=(0,ep.Z)(),{subgroup:o}=(0,t5.Z)({subgroupId:t}),d=(0,F.cI)({defaultValues:{name:"",color:w.Xb},values:null===o?{name:"",color:w.Xb}:{name:o.name,color:o.color},resolver:(0,H.F)(t4)}),u=(0,c.useCallback)(e=>{let{color:n,name:o}=e;r.mutate({processId:a,subgroups:[{id:t,name:o,color:n}]},{onSuccess:()=>{l({title:t3,description:"Saved",variant:"default"}),s(!1),d.reset()},onError:()=>{l({title:t3,description:"Something went wrong",variant:"destructive"})}})},[a,r,d,s,t,l]);return(0,n.jsxs)(i.cZJ,{className:"max-h-[70vh] w-96 overflow-y-auto",children:[(0,n.jsx)(i.fKu,{children:(0,n.jsx)(i.$N8,{children:"Edit group"})}),(0,n.jsx)("div",{className:"h-full w-full",children:(0,n.jsx)(i.l09,{...d,children:(0,n.jsxs)("form",{onSubmit:d.handleSubmit(u),className:"flex flex-col gap-3",children:[(0,n.jsxs)("div",{className:"flex flex-row items-center gap-2",children:[(0,n.jsx)(i.WiK,{control:d.control,name:"name",render:e=>{let{field:t}=e;return(0,n.jsxs)(i.xJW,{className:"w-full",children:[(0,n.jsx)(i.NIc,{children:(0,n.jsx)(i.IIB,{className:"flex pl-2",placeholder:"Name",maxLength:w.KK,...t})}),(0,n.jsx)(i.zGS,{})]})}}),(0,n.jsx)(i.WiK,{control:d.control,name:"color",render:e=>{let{field:t}=e;return(0,n.jsxs)(i.xJW,{className:"w-fit",children:[(0,n.jsx)(i.NIc,{children:(0,n.jsxs)(i.J2e,{children:[(0,n.jsx)(i.xol,{asChild:!0,className:"flex cursor-pointer flex-col items-center justify-center rounded-md border border-neutral-neutral-alpha-5",children:(0,n.jsx)(i.__J,{ref:t.ref,className:"h-8 w-8 rounded-md",style:{backgroundColor:t.value}})}),(0,n.jsx)(i.yky,{children:(0,n.jsx)(t2.gW,{className:"h-40 w-full",color:t.value,...t})})]})}),(0,n.jsx)(i.zGS,{})]})}})]}),(0,n.jsx)(i.cNS,{children:(0,n.jsx)(i.zxk,{disabled:r.isLoading,type:"submit",children:"Save"})})]})})})]})},t8=e=>{let{subgroupId:t}=e,[s,l]=(0,c.useState)(!1),[,a]=(0,d.KO)(r.Th),o=(0,c.useCallback)(e=>{l(e),a(e)},[a]),u=(0,c.useCallback)(()=>{o(!0)},[o]);return(0,n.jsxs)(i.VqE,{open:s,onOpenChange:o,children:[(0,n.jsx)(tl.Z,{asChild:!0,text:"Edit Group",children:(0,n.jsx)(i.hgM,{asChild:!0,onClick:u,children:(0,n.jsx)(i.zxk,{className:"h-fit w-fit p-0",variant:"ghost",children:(0,n.jsx)(B.oqE,{className:"h-4 w-4"})})})}),(0,n.jsx)(t6,{setIsOpen:o,subgroupId:t},t)]})},t9=()=>{let e=(0,O._K)();return{selectNodes:(0,c.useCallback)(t=>{e.setNodes(e=>e.map(e=>t.includes(e.id)?{...e,selected:!0}:{...e,selected:!1}))},[e])}},t7=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:500,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.4,s=(0,O._K)();return{zoomToNodes:(0,c.useCallback)(l=>{let a=s.getNodes().filter(e=>l.includes(e.id));if(0===a.length)return;let n=(0,O.RX)(a);s.fitBounds(n,{duration:e,padding:1===a.length?2:t})},[e,t,s])}},se=s(67549);let st=e=>{let{count:t,isError:s}=e;return s?null:(0,n.jsx)("span",{className:"items-start justify-start px-1 py-0 text-left font-normal text-xs leading-4 tracking-[-0.24px]",children:1===t?"(1 node)":"(".concat(t," nodes)")})},ss=e=>{let{groupId:t,subgroup:s}=e,l=(0,m.Z)("processId"),{toast:a}=(0,y.pm)(),[,o]=(0,d.KO)(r.NR),{nodesIds:u,isLoading:x,isError:h}=(0,se.Z)({subgroupId:s.id}),{addCurrentSubgroup:p}=(0,ep.Z)(),{selectNodes:g}=t9(),{zoomToNodes:f}=t7(),v=Array.from(new Set(u)),j=(0,c.useCallback)(()=>{0!==v.length&&(g(v),f(v),o(e=>{let t=v.filter(t=>e.every(e=>e.nodeId!==t)).map(e=>({nodeId:e,color:s.color}));return[...e.map(e=>v.includes(e.nodeId)?{nodeId:e.nodeId,color:s.color}:e),...t]}),p.mutate({processId:l,groupId:t,nodesIds:v,subgroupId:s.id},{onSuccess:()=>{a({title:"".concat(s.name," was selected"),description:"Saved",variant:"default"})},onError:()=>{a({title:"Groups",description:"Something went wrong",variant:"destructive"})}}))},[p,l,t,g,o,s.color,s.id,s.name,a,v,f]);return x?(0,n.jsx)(i.zxk,{className:"h-fit w-full items-start justify-start px-1 py-0 text-left font-medium text-sm leading-5 tracking-[-0.28px]",variant:"ghost",disabled:!0,children:(0,n.jsx)(i.OdW,{className:"h-5 w-full"})}):h?(0,n.jsx)(tl.Z,{asChild:!0,text:"Error loading nodes in groups",children:(0,n.jsx)(i.zxk,{className:"h-fit w-full items-start justify-start px-1 py-0 text-left font-medium text-sm leading-5 tracking-[-0.28px]",variant:"ghost",disabled:!0,children:(0,k.$G)(s.name,15)})}):(0,n.jsxs)(i.zxk,{className:"flex h-fit w-full flex-row items-center justify-start gap-2 px-1 py-0 ",variant:"ghost",onClick:j,children:[(0,n.jsx)("span",{className:"text-left font-medium text-sm leading-5 tracking-[-0.28px]",children:(0,k.$G)(s.name,15)}),(0,n.jsx)(st,{count:v.length,isError:h})]})},sl=e=>{let{subgroupId:t}=e,[s,l]=(0,d.KO)(r.Qf),a=(0,c.useCallback)(()=>{l(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},[t,l]),o=(0,c.useMemo)(()=>!s.includes(t),[s,t]);return(0,n.jsx)(tl.Z,{asChild:!0,text:o?"Hide Group":"Show Group",children:(0,n.jsx)(i.zxk,{className:"h-fit w-fit p-0",variant:"ghost",onClick:a,children:o?(0,n.jsx)(B.hsE,{className:"h-4 w-4"}):(0,n.jsx)(B.L52,{className:"h-4 w-4"})})})},sa=e=>{let{isListVisible:t,setIsListVisible:s}=e,[l,a]=(0,d.KO)(r.Xo),u=ek.S.useContext(),[,x]=(0,d.KO)(r.NR),h=(0,c.useCallback)(async()=>{a(e=>
1!e),await u.group.all.invalidate(),await u.subgroup.all.invalidate(),await u.subgroup.findSubgroupsByNode.invalidate(),await u.subgroup.findCurrentSubgroup.invalidate(),x([{nodeId:"",color:""}])},[x,a,u.group.all,u.subgroup.all,u.subgroup.findCurrentSubgroup,u.subgroup.findSubgroupsByNode]);return(0,n.jsxs)("div",{className:(0,o.cn)("sticky bottom-0 z-10 flex w-full cursor-grab items-center justify-between gap-2",t?"w-72 rounded-t-md bg-neutral-neutral-4 p-4":"rounded-full border border-accent-color-accent-alpha-8 bg-white px-4 py-2"),children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(i.zxk,{className:"h-fit w-fit p-0",variant:"ghost",onClick:h,children:l?(0,n.jsx)(B.hsE,{className:"h-4 w-4"}):(0,n.jsx)(B.L52,{className:"h-4 w-4"})}),(0,n.jsx)("span",{className:(0,o.cn)("leading-5 tracking-[-0.28px]",t?"font-bold text-base":"font-medium text-sm"),children:"Groups"})]}),(0,n.jsx)("div",{className:"flex items-center gap-2",children:(0,n.jsx)("button",{type:"button",className:"cursor-pointer",onClick:()=>s(!t),children:t?(0,n.jsx)(B.V_R,{}):(0,n.jsx)(B.el1,{})})})]})};var sn=e=>{let{className:t}=e,[s]=(0,d.KO)(r.Xo),[,l]=(0,d.KO)(r.zI),[a]=(0,d.KO)(r.Th),[,u]=(0,d.KO)(r.G$),[{x,y:h},p]=(0,t$.q_)(()=>({x:0,y:0})),g=(0,tB.useDrag)(e=>{let{offset:[t,s],cancel:l}=e;if(a){l();return}p.start({x:t,y:s})}),f=(0,m.Z)("processId"),{groups:v,isErrorGroups:j,isLoadingGroups:b}=(0,ec.Z)({processId:f,enabled:""!==f}),[N,y]=(0,c.useState)(v),[k,O]=(0,c.useState)(!0);return b?(0,n.jsxs)(t$.q.div,{...g(),style:{x,y:h,touchAction:"none"},className:(0,o.cn)("flex flex-col items-center bg-white","shadow-[0px_12px_32px_-16px_rgba(12,49,43,0.20),_0px_12px_60px_0px_rgba(0,0,0,0.05)]","border border-accent-color-accent-alpha-4","pb-4",k?"w-72 rounded-md":"h-10 w-56 rounded-full",t),children:[(0,n.jsx)(sa,{isListVisible:k,setIsListVisible:O}),k&&(0,n.jsx)("div",{className:"flex w-full flex-col gap-2 px-4 py-3 pb-4",children:Array.from({length:3}).map((e,t)=>(0,n.jsx)(i.OdW,{className:"h-7 w-full"},"".concat(t,"-skeleton")))})]}):j?(0,n.jsxs)(t$.q.div,{...g(),style:{x,y:h,touchAction:"none"},className:(0,o.cn)("flex flex-col items-center bg-white","shadow-[0px_12px_32px_-16px_rgba(12,49,43,0.20),_0px_12px_60px_0px_rgba(0,0,0,0.05)]","border border-accent-color-accent-alpha-4","pb-4",k?"w-72 rounded-md":"h-10 w-56 rounded-full",t),children:[(0,n.jsx)(sa,{isListVisible:k,setIsListVisible:O}),k&&(0,n.jsx)("span",{className:"p-4 font-bold text-base leading-6 tracking-[-0.32px]",children:"Something went wrong"})]}):(N!==v&&(u(v.map(e=>({id:e.id,name:e.name,isVisible:!0,subgroups:e.subgroups.map(e=>({id:e.id,name:e.name,isVisible:!0}))}))),v.length>0&&l(s&&void 0!==v[0]?v[0].id:""),y(v)),(0,n.jsxs)(t$.q.div,{...g(),style:{x,y:h,touchAction:"none"},className:(0,o.cn)("flex flex-col items-center bg-white","shadow-[0px_12px_32px_-16px_rgba(12,49,43,0.20),_0px_12px_60px_0px_rgba(0,0,0,0.05)]","border border-accent-color-accent-alpha-4","pb-4",k?"w-72 rounded-md":"h-10 w-56 rounded-full",t),children:[(0,n.jsx)(sa,{isListVisible:k,setIsListVisible:O}),k&&(0,n.jsxs)("div",{className:"max-h-64 w-full overflow-y-auto overflow-x-hidden px-4 py-3",children:[v.map(e=>(0,n.jsxs)("div",{className:"flex flex-col gap-2",children:[e.subgroups.map(t=>(0,n.jsx)("div",{className:"flex w-full flex-row items-start justify-start gap-1",children:(0,n.jsxs)("div",{className:"flex w-full flex-row items-center justify-between gap-2",children:[(0,n.jsxs)("div",{className:"flex w-full flex-row items-center justify-start gap-1",children:[(0,n.jsx)("div",{className:"h-4 w-2 rounded-sm",style:{backgroundColor:t.color}}),(0,n.jsx)(ss,{groupId:e.id,subgroup:t})]}),(0,n.jsxs)("div",{className:"flex w-fit flex-row items-center justify-end gap-1",children:[(0,n.jsx)(sl,{subgroupId:t.id}),(0,n.jsx)(t8,{subgroupId:t.id}),(0,n.jsx)(t1,{subgroupId:t.id})]})]})},t.id)),(0,n.jsx)(tX,{groupId:e.id})]},e.id)),0===v.length?(0,n.jsx)(tX,{groupId:w.nb}):null]})]}))},sr=(0,c.memo)(()=>{let{isLoading:e,isAvailable:t}=(0,eL.Z)(w.ZA.EXPORT);
1return(0,n.jsx)(O.s_,{className:"h-8 w-fit rounded-lg p-0",position:"top-right",children:(0,n.jsxs)("div",{className:"relative flex h-8 flex-col items-end gap-2",id:"top-right-capture-panel",children:[(0,n.jsxs)("div",{className:(0,o.cn)("flex h-8 flex-row gap-2 p-0 ","rounded-lg","items-center justify-between","w-fit"),children:[(0,n.jsx)(tQ.Z,{}),!e&&t&&(0,n.jsx)(tU,{})]}),(0,n.jsx)(sn,{className:"absolute top-10 z-10"})]})})});let so={hideAttribution:!0},si={[b.$P.ACTION]:e=>{var t,s;let{id:l,data:a,selected:i}=e,u=(0,O.oR)(k.cQ),[x]=(0,d.KO)(r.J),[h,p]=(0,c.useState)(!!(null===(t=a.notes)||void 0===t?void 0:t.isOpen)&&""!==a.notes.value),[m]=(0,d.KO)(r.je),{currentColor:g}=(0,Y.Z)(l),f=(0,c.useRef)(null);(0,X.Z)(f,l,b.$P.ACTION);let v=u!==l;return(0,n.jsxs)(et.Z,{nodeId:l,type:b.$P.ACTION,disabled:m,children:[h?null:(0,n.jsx)(eh,{nodeType:b.$P.ACTION,nodeId:l}),(0,n.jsxs)("div",{ref:f,className:(0,o.cn)("h-44 w-44 ","grid grid-cols-3 items-center justify-items-center text-center","group",void 0!==a.isGhost&&!0===a.isGhost?"border-dotted":"","black"===g||"white"===g?"border-2":"border-[6px]",i?"bg-node-selection":"bg-white dark:bg-slate-900",{"hover:shadow-lg hover:shadow-slate-700 dark:active:shadow-gray-400 dark:hover:shadow-gray-300":a.isCompleted,"border-semantic-error-9 shadow-lg shadow-semantic-error-9":!a.isCompleted&&x,"shadow-lg shadow-slate-500 dark:shadow-gray-50 dark:shadow-lg":i&&a.isCompleted}),style:{borderColor:g},id:"action-node",children:[!1===a.isGhost||void 0===a.isGhost?(0,n.jsx)(es,{currentFocalPoint:null!==(s=a.focalPoint)&&void 0!==s?s:w.gd,isNodeCompleted:a.isCompleted,nodeId:l,className:"z-50 col-span-full row-span-1 row-start-1 translate-x-1 translate-y-1 self-start justify-self-start"}):null,!1===a.isGhost||void 0===a.isGhost?(0,n.jsx)(ee,{nodeId:l,buttonStyles:"z-50 col-span-full row-span-1 -translate-x-1 row-start-1 h-4 w-4 self-start justify-self-end translate-y-1",isNodeCompleted:a.isCompleted,savedNotes:a.notes,onNoteOpenChange:p},l):null,(0,n.jsx)(q.Z,{className:"-top-3 absolute left-0 z-50",nodeId:l}),!u&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(O.HH,{className:(0,o.cn)("z-10 h-[130%] w-[130%]","right-[-1.7rem]","rounded-none border-none bg-transparent","col-span-3 col-end-3 row-span-full"),isConnectable:!0,id:w.vH.SOURCE_X,position:O.Ly.Right,type:"source"}),(0,n.jsxs)("div",{className:"relative z-0 col-span-5 col-end-5 row-span-full h-[110%] w-[110%] bg-transparent text-accent-color-accent-9 ",children:[(0,n.jsx)(B.ZNd,{id:"action-node-chevron-up-handle",className:"-translate-x-1/2 absolute top-[-1.40rem] left-1/2 hidden h-8 w-8 transition-all ease-in-out group-hover:block group-hover:scale-150"}),(0,n.jsx)(B.ZNd,{id:"action-node-chevron-left-handle",className:"-translate-y-1/2 absolute top-1/2 left-[-1.40rem] hidden h-8 w-8 transition-all ease-in-out group-hover:block group-hover:scale-150"}),(0,n.jsx)(B.ZNd,{id:"action-node-chevron-right-handle",className:"-translate-y-1/2 absolute top-1/2 right-[-1.40rem] hidden h-8 w-8 transition-all ease-in-out group-hover:block group-hover:scale-150"}),(0,n.jsx)(B.ZNd,{id:"action-node-chevron-down-handle",className:"-translate-x-1/2 absolute bottom-[-1.40rem] left-1/2 hidden h-8 w-8 transition-all ease-in-out group-hover:block group-hover:scale-150"})]})]}),(0,n.jsx)(O.HH,{id:w.vH.TARGET_X,className:(0,o.cn)("h-[110%] w-[110%]","-left-2 p-0","rounded-none","border-none","bg-transparent","col-span-3 col-end-3 row-span-full"),position:O.Ly.Left,type:"target",isConnectable:!0,isConnectableEnd:v}),(0,n.jsx)("div",{className:(0,o.cn)("z-20 col-span-3 col-start-1 row-span-full","h-fit w-fit items-center justify-center justify-items-center"),children:(0,n.jsxs)("div",{className:"grid grid-cols-2 items-center justify-center justify-items-center",children:[(0,n.jsx)("div",{className:(0,o.cn)("h-44 w-44","col-span-3 col-start-1 row-span-full")}),(0,n.jsx)("div",{className:"col-span-2 col-end-3 row-span-full",children:!1===a.isGhost||void 0===a.isGhost?(0,n.jsx)(en,{nodeId:null!=l?l:"",data:a}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(A.Z,{maxLength:w.TO.WHAT,text:w.vP.WHAT}),(0,n.jsx)(A.Z,{id:"".concat(w.f1.GHOST_ACTION,"-target-").concat(l),maxLength:w.TO.WHERE,text:w.vP.WHERE,withHyphen:!1}),(0,n.jsx)(A.Z,{maxLength:w.TO.WHO,text:w.vP.WHO,withHyphen:!1})]})})]})})]})]})},[b.$P.QUESTION]:e=>{var t,s;let{id:l,selected:a,data:i}=e,u=(0,O.oR)(k.cQ),[x,h]=(0,c.useState)(!!(null===(t=i.notes)||void 0===t?void 0:t.isOpen)&&""!==i.notes.value),[p]=(0,d.KO)(r.je),[m]=(0,d.KO)(r.J),{currentColor:g}=(0,Y.Z)(l),f=(0,ev.Z)(l),v=(0,c.useRef)(null);(0,X.Z)(v,l,b.$P.QUESTION);let j=u!==l;return(0,n.jsxs)(et.Z,{nodeId:l,type:b.$P.QUESTION,disabled:p,children:[x?null:(0,n.jsx)(eh,{nodeType:b.$P.ACTION,nodeId:l}),(0,n.jsxs)("div",{ref:v,className:(0,o.cn)("grid grid-cols-2 items-center justify-center","group","h-40 w-full"),children:[!1===i.isGhost||void 0===i.isGhost?(0,n.jsx)(es,{currentFocalPoint:null!==(s=i.focalPoint)&&void 0!==s?s:w.gd,isNodeCompleted:i.isCompleted,nodeId:l,className:"z-50 col-span-full row-span-1 row-start-1 translate-x-3 translate-y-4 self-start justify-self-start"}):null,!1===i.isGhost||void 0===i.isGhost?(0,n.jsx)(ee,{nodeId:l,buttonStyles:"z-50 col-span-full row-span-2 row-start-1 h-4 w-4 self-start justify-self-end -translate-x-4 translate-y-3",isNodeCompleted:i.isCompleted,savedNotes:i.notes,onNoteOpenChange:h},l):null,(0,n.jsx)(q.Z,{className:"-top-2 absolute left-1 z-50",nodeId:l}
1),!u&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(O.HH,{className:(0,o.cn)("group","z-20 h-[130%] w-[120%]","-right-6","border-none bg-transparent","col-span-3 col-end-3 row-span-full","rounded-3xl"),isConnectable:!0,id:w.vH.SOURCE_X,position:O.Ly.Right,type:"source"}),(0,n.jsxs)("div",{className:"relative right-3 z-0 col-span-3 col-end-3 row-span-full h-[110%] w-[110%] bg-transparent text-accent-color-accent-9",children:[(0,n.jsx)(B.ZNd,{className:"-translate-x-1/2 absolute top-[-1.65rem] left-1/2 hidden h-8 w-8 translate-y-2 transition-all ease-in-out group-hover:block group-hover:scale-150"}),(0,n.jsx)(B.ZNd,{className:"-translate-y-1/2 absolute top-1/2 left-[-1.0rem] hidden h-8 w-8 transition-all ease-in-out group-hover:block group-hover:scale-150"}),(0,n.jsx)(B.ZNd,{className:"-translate-y-1/2 absolute top-1/2 right-[-1.0rem] hidden h-8 w-8 transition-all ease-in-out group-hover:block group-hover:scale-150"}),(0,n.jsx)(B.ZNd,{className:"-translate-y-2 absolute bottom-[-1.70rem] left-1/2 hidden h-8 w-8 translate-x-[-48%] transition-all ease-in-out group-hover:block group-hover:scale-150"})]})]}),(0,n.jsx)(O.HH,{id:w.vH.TARGET_X,className:(0,o.cn)("z-10 h-[110%] w-[110%]","-left-3 p-0","border-none bg-transparent","col-span-3 col-end-3 row-span-full","rounded-3xl"),position:O.Ly.Left,type:"target",isConnectable:!0,isConnectableEnd:j}
1),(0,n.jsx)("div",{className:"z-30 col-span-2 col-end-3 row-span-full self-center justify-self-center",children:(0,n.jsxs)("div",{className:"grid grid-cols-2 items-center justify-center justify-items-center",children:[(0,n.jsx)("div",{className:(0,o.cn)("h-[9.5rem] w-[15.5rem]","col-span-2 col-start-1 row-span-full","rounded-2xl")}),(0,n.jsx)("div",{className:"col-span-2 col-end-3 row-span-full",children:!1===i.isGhost||void 0===i.isGhost?(0,n.jsx)(eb,{className:"h-full w-40",nodeId:null!=l?l:"",data:i}):(0,n.jsx)(A.Z,{maxLength:w.kh.QUESTION,text:w.AH.QUESTION})})]})}),(0,n.jsx)(ej.P.Cloud,{className:(0,o.cn)("col-span-2 col-start-1 row-span-full h-full w-full justify-self-center","black"===g||"white"===g?"stroke-[3]":"stroke-[6]",a?"fill-node-selection":"fill-white  dark:fill-slate-900",{"stroke-red-600":f&&m,"stroke-semantic-error-9 drop-shadow-[0_5px_5px_hsl(var(--error-9))]":!i.isCompleted,"group-hover:drop-shadow-[0_5px_5px_rgba(51,65,85,0.5)] group-dark:hover:drop-shadow-[0_5px_5px_rgba(209,213,219,0.5)]":i.isCompleted,"active:drop-shadow-[0_5px_5px_rgba(15,23,42,0.5)] dark:active:drop-shadow-[0_5px_5px_rgba(156,163,175,0.5)]":i.isCompleted,"drop-shadow-[0_5px_5px_rgba(100,116,139,0.5)] dark:drop-shadow-[0_5px_5px_rgba(249,250,251,0.5)]":a&&i.isCompleted}),style:{stroke:g,strokeDasharray:void 0!==i.isGhost&&!0===i.isGhost?"5":""}})]})]})}},sd={[b.rP.TIME]:N.iy,[b.rP.ANSWER]:e=>{var t,s;let{id:l,style:a={strokeWidth:4,cursor:"pointer"},data:i,markerEnd:u,source:x,target:h,selected:p,...m}=e,{setEdges:g}=(0,O._K)(),f=(0,O.oR)(e=>{let t=e.nodeInternals.get(x),s=e.nodeInternals.get(h);return p||t.selected||s.selected}),[v]=(0,d.KO)(z.Es),[j]=(0,d.KO)(r.Y$),N="timeline"===j||"read-only"===j,y=(0,O.oR)((0,c.useCallback)(e=>e.nodeInternals.get(x),[x])),C=(0,O.oR)((0,c.useCallback)(e=>e.nodeInternals.get(h),[h])),[S,E]=(0,c.useState)(!1),I=(0,c.useCallback)(e=>{g(t=>t.map(t=>{var s,a;if(t.id!==l||void 0===t.data)return t;let n=null!==(a=null===(s=t.data)||void 0===s?void 0:s.points)&&void 0!==a?a:[],r={...t.data,points:e(n)};return{...t,data:r}}))},[l,g]),{sourceX:P,sourceY:H,targetX:F,targetY:W,sourcePosition:G,targetPosition:M}=(0,k.Ug)(y,C,null!==(t=null==i?void 0:i.points)&&void 0!==t?t:[]),V=v.find(e=>e.source===x&&e.target===h),U=V?v.find(e=>e.source===h&&e.target===x):null,{cyclicGapX:Q,cyclicGapY:$}=(0,L.Z)(x,h,G,v),B=(0,R.Z)(P,H,y),q=(0,R.Z)(F,W,C),X=(0,_.Z)(B.x,B.y,G).sourceX+Q,Y=(0,_.Z)(B.x,B.y,G).sourceY+$,ee=q.x+Q,et=q.y+$,es=[{x:X,y:Y},...void 0!==i&&void 0!==i.points?i.points:[],{x:ee,y:et}],el=(0,D.E)(es,!0,{fromSide:G,toSide:M}),ea=(0,D.Q)(es,!0,{fromSide:G,toSide:M}),en=K(el),er=document.createElementNS("http://www.w3.org/2000/svg","path");er.setAttribute("d",ea);let eo=er.getTotalLength(),ei=er.getPointAtLength(.38*eo),ed=ei.x,ec=ei.y;if((null==U?void 0:U.type)===b.rP.ANSWER){let e=document.getElementById("edgepath_".concat(l));if(e){let t=e.getTotalLength();if(0===t)ed=ei.x,ec=ei.y;else{let s=t<w.Eq?3:4,l=e.getPointAtLength(t/s);ed=l.x,ec=l.y}}}let eu=null!==(s=null==i?void 0:i.text)&&void 0!==s?s:"",ex=p||(null==y?void 0:y.selected)||(null==C?void 0:C.selected),eh=(0,c.useMemo)(()=>ex?"#B1B1B7":"transparent",[ex]),ep=(0,c.useCallback)(()=>{E(!0)},[]),em=(0,c.useCallback)(()=>{E(!1)},[]),eg=S||p?"":"hidden";return(0,n.jsxs)("g",{onMouseEnter:ep,onMouseLeave:em,children:[(0,n.jsx)(O.u5,{path:ea,...m,markerEnd:u,style:a,id:"edgepath_".concat(l)}),(0,n.jsx)("circle",{cx:X,cy:Y,r:4,fill:eh}),(0,n.jsx)(O.XQ,{children:(0,n.jsx)("div",{style:{transform:"translate(-50%, -50%) translate(".concat(ed,"px,").concat(ec,"px)")},className:(0,o.cn)("nodrag nopan group absolute flex h-auto w-auto select-none flex-row items-center justify-center justify-items-center px-1 will-change-transform [pointer-events:all] focus-within:z-[1000] hover:z-[1000]",{"z-[1000]":ex}),children:(0,n.jsxs)("div",{className:(0,o.cn)("group my-auto flex h-fit flex-row items-center justify-center rounded-md border border-gray-400 bg-white dark:border-white dark:bg-slate-900"),children:[N?(0,n.jsx)(A.Z,{text:eu,placeholder:w.u2.ANSWER,maxLength:w.LD.ANSWER}):(0,n.jsx)(J,{edgeId:l,text:eu,maxLengthField:w.LD.ANSWER}),(0,n.jsx)("div",{className:(0,o.cn)("border-white border-l",eg,"group-focus-within:block"),children:!!V||!N&&(0,n.jsx)(T,{edgeId:l})})]})})}),f&&en.map((e,t)=>(0,n.jsx)(Z,{index:t,setControlPoints:I,...e},e.id))]})}},sc=["Backspace","Delete"],su=!1,sx=[1,2],sh=()=>{var e,t;let{nodes:s,setNodes:l,edges:a,setEdges:i,onEdgesChange:x,isError:h,processId:p,canvasObject:m,isThereNoNodes:g,isFetching:f}=(0,eI.y)(),v=null!==(t=null==m?void 0:null===(e=m.data)||void 0===e?void 0:e.viewport)&&void 0!==t?t:null,[E,I]=(0,c.useState)(!1),P=(0,d.b9)(r.O0),T=(0,d.Dv)(r.B_),[Z,A]=(0,d.KO)(r.h2),[K,z]=(0,c.useState)(Z
1),[_,L]=(0,c.useState)(!1),{removeGhostNodes:R}=(0,eT.Z)(),{reactFlowWrapper:D,onDrop:H,onDragOver:F,onDragEnd:W}=(0,eP.Z)(),G=(0,c.useRef)(null),M=(0,c.useRef)(null),V=(0,O._K)(),{save:J}=eE();eF();let[U,Q]=(0,c.useState)(null),[B,q]=(0,c.useState)(null),[,X]=(0,d.KO)(r.TH);ez(p),eA({currentCaptureNodes:s,currentCaptureEdges:a});let{toast:Y}=(0,y.pm)(),{customApplyNodeChanges:ee,helperLineVertical:et,helperLineHorizontal:es}=(0,e_.Z)(),{isLoading:el,isAvailable:ea}=(0,eL.Z)(w.ZA.AUTO_SPACING);(0,c.useEffect)(()=>{!su&&v&&(su=!0,V.setViewport(v))},[V,v]),(0,c.useEffect)(()=>{J(),P(!1)},[T,J,P]),K!==Z&&(l(e=>e.map(e=>({...e,data:{...e.data,notes:{...e.data.notes,isOpen:Z}}}))),z(Z));let en=(0,c.useCallback)(e=>{var t;let l=s.find(t=>t.id===e.source),a={...e,type:(0,N.EO)(null!==(t=null==l?void 0:l.type)&&void 0!==t?t:b.$P.ACTION),data:{text:"",points:[]},markerEnd:w.lM};i(e=>(0,O.Z_)(a,e)),P(!0)},[s,i,P]),er=(0,c.useCallback)(()=>{P(!1),A(s.some(e=>{var t,s,l,a;return(null==e?void 0:null===(s=e.data)||void 0===s?void 0:null===(t=s.notes)||void 0===t?void 0:t.isOpen)&&(null==e?void 0:null===(a=e.data)||void 0===a?void 0:null===(l=a.notes)||void 0===l?void 0:l.value)!==""})),setTimeout(()=>{I(!0),v&&V.setViewport(v)},100)},[P,A,s,V,v]),eo=(0,c.useCallback)(e=>{i((Array.isArray(e)?e:[e]).reduce((e,t)=>{let l=(0,O.vG)(t,s,a),n=(0,O.xA)(t,s,a),r=(0,O.my)([t],a),o=r.find(e=>e.target===t.id);return[...e.filter(e=>!r.includes(e)),...l.flatMap(e=>{let t=e.id;return n.map(s=>{var l,a,n;let r=s.id;return{id:(0,k.LH)(t,r,(0,S.Z)()),source:t,target:r,type:(0,N.EO)(null!==(l=e.type)&&void 0!==l?l:b.$P.ACTION),data:{text:"",points:[]},markerEnd:w.lM,sourceHandle:null!==(a=null==o?void 0:o.sourceHandle)&&void 0!==a?a:w.vH.SOURCE_X,targetHandle:null!==(n=null==o?void 0:o.targetHandle)&&void 0!==n?n:w.vH.TARGET_Y}})})]},a)),P(!0)},[a,s,i,P]),ei=(0,c.useCallback)(e=>{x(e),e.some(e=>"select"===e.type)&&P(!0)},[x,P]),ed=(0,c.useCallback)(e=>{l(t=>ee(e,t)),P(!0),e.some(e=>"select"===e.type)&&P(!1)},[ee,P,l]),ec=(0,c.useCallback)(()=>{P(!1)},[P]),eu=(0,c.useCallback)(()=>{P(!1)},[P]),ex=(0,c.useCallback)(()=>{P(!0)},[P]),eh=(0,c.useCallback)(()=>{Q(null),X(!1),g&&(l(w.OV),Y({title:"Capture",description:"Initial node created",variant:"default"}))},[g,X,l,Y]),ep=(0,c.useCallback)((e,t)=>{let{nodeId:s,handleId:l}=t;G.current=s,M.current=l,L(!0),P(!1)},[P]),em=(0,c.useCallback)(e=>{L(!1),R(!1);let t=window.TouchEvent&&e instanceof TouchEvent,n=window.MouseEvent&&e instanceof MouseEvent;if(t||!e.target||!D.current||!G.current||!M.current){Y({title:"Capture",description:"It is not possible to create a new node",variant:"default"});return}let r=e.target,o=r.classList.contains("react-flow__pane"),d=null==r?void 0:r.id.includes("".concat(w.f1.GHOST_ACTION,"-target"));if(o||d){var c;let t;let r=(0,S.Z)();if(!n)return;let o={...w.LR[b.$P.ACTION](r),position:V.screenToFlowPosition({x:e.clientX,y:e.clientY})},d=s.find(e=>e.id===G.current),u=null!==(c=null==d?void 0:d.type)&&void 0!==c?c:b.$P.ACTION,x={[w.vH.SOURCE_X]:w.vH.TARGET_X,[w.vH.SOURCE_Y]:w.vH.TARGET_Y,[w.vH.TARGET_X]:w.vH.SOURCE_X,[w.vH.TARGET_Y]:w.vH.SOURCE_Y},h={type:(0,N.EO)(u),animated:!1,data:{text:"",points:[]},markerEnd:w.lM};if(t=M.current.includes("source")?{...h,id:(0,k.LH)(G.current,r,(0,S.Z)()),source:G.current,target:r,sourceHandle:M.current,targetHandle:x[M.current]}:{...h,id:(0,k.LH)(r,G.current,(0,S.Z)()),source:r,target:G.current,sourceHandle:x[M.current],targetHandle:M.current},!(!el&&ea)||!d){P(!0),l(e=>e.concat(o)),i(e=>e.concat(t));return}let p=(0,j.mH)({rootNode:d,newNodePosition:o.position,nodes:[o,...s],edges:[...a,t]});l(e=>{let t=p.nodes.find(e=>e.id===o.id);return e.map(e=>{let t=p.nodes.find(t=>t.id===e.id);return null!=t?t:e}).concat(null!=t?t:[])}),i(e=>e.concat(t)),P(!0)}},[a,ea,el,s,V,D,R,i,P,l,Y]),eg=(0,c.useCallback)(e=>{if(!_||void 0===e)return;P(!1);let t=V.screenToFlowPosition({x:e.clientX,y:e.clientY});V.setNodes(e=>e.map(e=>e.id===w.f1.GHOST_ACTION?{...e,position:t,hidden:!1}:e)),P(!1)},[_,V,P]),ev=(0,c.useCallback)(e=>e.target!==w.f1.GHOST_ACTION,[]),ej=(0,c.useCallback)(()=>{P(!0)},[P]),ew=(0,c.useCallback)((e,t)=>{var s;e.preventDefault();let l=null==D?void 0:null===(s=D.current)||void 0===s?void 0:s.getBoundingClientRect();l&&(X(!0),Q({nodesIds:t.map(e=>
1e.id),top:e.clientY<l.height?e.clientY-80:void 0,left:e.clientX<l.width?e.clientX-190:void 0,right:e.clientX>=l.width?l.width-e.clientX+190:void 0,bottom:e.clientY>=l.height?l.height-e.clientY+80:void 0}))},[D,X]),eb=(0,c.useCallback)(e=>{let{nodes:t}=e;if(t.length>1){let e=(0,O.RX)(t),s=(0,k.Lj)(e,V.getViewport(),w.m6.position,w.m6.offset,w.m6.align);q({nodesIds:t.map(e=>e.id),translate:s,rect:e})}else q(null)},[V]);return f?(0,n.jsx)("div",{className:"h-full w-full",children:(0,n.jsx)(u.Z,{})}):h?(Y({title:"Error fetching data",description:"its not possible to load the stored capture",variant:"destructive"}),(0,n.jsx)("div",{className:"flex h-full w-full items-center justify-center",children:"Something went wrong"})):(0,n.jsx)("div",{className:"h-full w-full",ref:D,id:"capture-flow-container-div",children:(0,n.jsxs)(O.x$,{nodes:s,edges:a,nodeTypes:si,edgeTypes:sd,onNodesChange:ed,onEdgesChange:ei,onConnect:en,onEdgesDelete:ej,onConnectStart:ep,onConnectEnd:em,onSelectionContextMenu:ew,onDropCapture:H,onNodesDelete:eo,onNodeDragStart:ec,onNodeDrag:eu,onNodeDragStop:ex,onInit:er,onDragEndCapture:W,onDragOverCapture:F,onPointerMove:eg,isValidConnection:ev,proOptions:so,style:{opacity:E?1:0},minZoom:.1,maxZoom:3,nodeOrigin:[.5,.5],connectionLineStyle:{strokeWidth:4},connectionLineType:O.t8.Bezier,snapGrid:[10,10],snapToGrid:!0,onPaneClick:eh,deleteKeyCode:sc,panOnDrag:sx,selectionOnDrag:!0,nodesFocusable:!1,onSelectionChange:eb,elevateEdgesOnSelect:!0,children:[(0,n.jsx)(o.PFK,{horizontal:es,vertical:et}),(0,n.jsx)(eX,{reactFlowWrapper:D}),(0,n.jsx)(C.A,{size:1,color:"#7777",gap:[10,10]}),(0,n.jsx)($,{isVisibleAutoLayoutButton:!0}),(0,n.jsx)(eM,{}),g&&(0,n.jsx)(eJ,{icon:"info",className:"fixed lg:translate-x-[-13%]",title:"Info Message",description:"Click anywhere to restart capturing."}),(0,n.jsx)(sr,{}),null!==U&&(0,n.jsx)(ef,{...U}),null!==B&&(0,n.jsx)(ey,{...B})]})})};var sp=()=>(0,n.jsx)(O.tV,{children:(0,n.jsx)(sh,{})}),sm=s(21685),sg=s(38617),sf=s(82339),sv=()=>{var e,t;let[s,l]=(0,c.useState)({x:0,y:0}),[a,r]=(0,c.useState)(!1),[,o]=(0,d.KO)(sf.r),{resolvedTheme:i}=(0,sg.F)(),u=(0,O._K)(),x=(0,c.useMemo)(()=>document.getElementsByClassName("react-flow__pane"),[a]);(0,c.useEffect)(()=>{let e=()=>{r(!1),o(!1)};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),(0,c.useEffect)(()=>{let e=e=>{l({x:e.clientX,y:e.clientY})};return window.addEventListener("mousemove",e),()=>window.removeEventListener("mousemove",e)},[]),(0,c.useEffect)(()=>{let e=e=>{"Escape"===e.key?(r(!1),o(!1)):"m"===e.key&&(e.altKey||e.ctrlKey)&&(e.preventDefault(),r(e=>!e),o(e=>!e))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]);let h=(0,c.useMemo)(()=>x[0]?x[0].getBoundingClientRect():{left:0,top:0},[x,a]),p=u.screenToFlowPosition(s),m=x?null===(e=x[0])||void 0===e?void 0:e.clientWidth:0,g=x?null===(t=x[0])||void 0===t?void 0:t.clientHeight:0,f=(0,c.useMemo)(()=>"light"===i?"black":"white",[i]);return(0,n.jsx)("div",{className:"h-full w-full",children:a&&(0,n.jsxs)("svg",{style:{width:"inherit",height:"inherit"},children:[(0,n.jsx)("line",{x1:"0",y1:s.y-h.top,x2:m,y2:s.y-h.top,stroke:f,strokeWidth:"1"}),(0,n.jsx)("line",{x1:s.x-h.left,y1:"0",x2:s.x-h.left,y2:g,stroke:f,strokeWidth:"1"}),(0,n.jsx)("text",{x:s.x-h.left+10,y:s.y-h.top+15,fill:f,fontSize:"12",children:"(".concat(p.x,", ").concat(p.y,")")})]})})},sj=()=>{let e=(0,O._K)().getEdges();return{getRelatedEdges:t=>e.filter(e=>e.source===t||e.target===t).map(e=>e.id)}},sw=s(3903),sb=s(32584),sN=s(28164),sy=e=>{var t,s;let{id:l,data:a,selected:i}=e,c=(0,O.oR)(k.cQ),[u]=(0,d.KO)(r.LI),[x,h]=(0,d.KO)(r.Fk),[p]=(0,d.KO)(sw.Zk),{getRelatedEdges:m}=sj(),g=!p&&(u.nodes.includes(l)||x.nodeId===l),{currentColor:f}=(0,Y.Z)(l),[v]=(0,d.KO)(r.iF),j="white"===f||"black"===f?"border-2":"border-4",b=!p&&i?"shadow-lg shadow-slate-500 dark:shadow-lg dark:shadow-gray-50":"",N=c!==l,y=()=>{if(!p){let e=m(l);h({nodeId:l,edges:e})}},C=()=>{p||h({nodeId:"",edges:[]})};return(0,n.jsxs)("div",{className:(0,o.cn)("h-44 w-44","hover:shadow-lg hover:shadow-slate-700 active:shadow-lg active:shadow-slate-900","dark:active:shadow-gray-400 dark:active:shadow-lg dark:hover:shadow-gray-300 dark:hover:shadow-lg","grid grid-cols-3 items-center justify-items-center text-center"),style:{borderColor:f},onContextMenu:e=>{e.preventDefault()},onMouseOver:y,onMouseLeave:C,onFocus:y,onBlur:C,children:[a.notes&&""!==a.notes.value?(0,n.jsx)(sN.Z,{buttonStyles:"z-50 col-span-full row-span-1 row-start-1 h-4 w-4 self-start justify-self-end -translate-x-2 translate-y-2",savedNotes:a.notes}):null,a.focalPoint?(0,n.jsx)(sb.Z,{currentFocalPoint:a.focalPoint,className:(0,o.cn)("z-50 col-span-full row-span-1 row-start-1 translate-x-1 translate-y-1 self-start justify-self-start",v?"":"opacity-0 hover:opacity-100")}
1):null,!c&&(0,n.jsx)(O.HH,{className:(0,o.cn)("z-10 h-full w-full","right-0 p-0","transition-all duration-300 ease-in-out","rounded-none bg-white dark:bg-slate-900","col-span-3 col-end-3 row-span-full",j,b,{"border-4 bg-[#BDD2B9] text-white dark:bg-green-300":g}),isConnectable:!1,id:w.vH.SOURCE_X,position:O.Ly.Right,type:"source",style:{borderColor:f}}),(0,n.jsx)(O.HH,{id:w.vH.TARGET_X,className:(0,o.cn)("h-full w-full","left-0 p-0","transition-all duration-300 ease-in-out","rounded-none bg-white p-2 text-center dark:bg-slate-900","col-span-3 col-end-3 row-span-full",j,b,{"border-4 bg-green-200 text-white dark:bg-green-300":g}),position:O.Ly.Left,type:"target",isConnectable:!1,isConnectableEnd:N,style:{borderColor:f}}),(0,n.jsxs)("div",{className:(0,o.cn)("flex h-fit w-fit grow flex-col items-center justify-center justify-items-stretch py-6","transition-all duration-300 ease-in-out","z-20 col-span-3 col-start-1 row-span-full","text-black dark:text-white",{"font-medium":g}),children:[(0,n.jsx)(A.Z,{text:null!==(t=a.where)&&void 0!==t?t:"",isDefaultValue:a.where===w.vP.WHERE,maxLength:w.TO.WHERE,withHyphen:!1}),(0,n.jsx)(A.Z,{text:null!==(s=a.what)&&void 0!==s?s:"",isDefaultValue:a.what===w.vP.WHAT,maxLength:w.TO.WHAT})]})]})},sk=e=>{var t;let{id:s,data:l,selected:a}=e,i=(0,O.oR)(k.cQ),[c]=(0,d.KO)(r.LI),[u,x]=(0,d.KO)(r.Fk),[h]=(0,d.KO)(sw.Zk),{getRelatedEdges:p}=sj(),m=!h&&(c.nodes.includes(s)||u.nodeId===s),{currentColor:g}=(0,Y.Z)(s),[f]=(0,d.KO)(r.iF),v=i!==s,j=()=>{if(!h){let e=p(s);x({nodeId:s,edges:e})}},b=()=>{h||x({nodeId:"",edges:[]})};return(0,n.jsxs)("div",{className:(0,o.cn)("grid grid-cols-2 justify-center","h-36 w-56"),onContextMenu:e=>e.preventDefault(),onMouseOver:j,onMouseLeave:b,onFocus:j,onBlur:b,children:[(0,n.jsx)("div",{className:(0,o.cn)("transition-all duration-300 ease-in-out","flex justify-center","z-30 col-span-2 col-end-3 row-span-full self-center",{"font-medium":m}),children:(0,n.jsx)(A.Z,{text:null!==(t=l.question)&&void 0!==t?t:"",className:"w-40",isDefaultValue:l.question===w.AH.QUESTION,maxLength:w.kh.QUESTION})}),(0,n.jsx)(o.PJP.Cloud,{className:(0,o.cn)("transition-all duration-300 ease-in-out","col-span-2 col-start-1 row-span-full h-full w-full self-center fill-white dark:fill-slate-900","hover:drop-shadow-[0_5px_5px_rgba(51,65,85,0.5)] active:drop-shadow-[0_5px_5px_rgba(15,23,42,0.5)]","dark:active:drop-shadow-[0_5px_5px_rgba(156,163,175,0.5)] dark:hover:drop-shadow-[0_5px_5px_rgba(209,213,219,0.5)]","white"===g||"black"===g?"stroke-[4]":"stroke-[6]",!h&&a?"drop-shadow-[0_5px_5px_rgba(100,116,139,0.5)] dark:drop-shadow-[0_5px_5px_rgba(249,250,251,0.5)] ":"",{"fill-[#BDD2B9] stroke-[6] dark:fill-green-300":m}),style:{stroke:g}}),l.focalPoint?(0,n.jsx)(sb.Z,{currentFocalPoint:l.focalPoint,className:(0,o.cn)("z-50 col-span-full row-span-1 row-start-1 translate-x-2 translate-y-3 self-start justify-self-start",f?"":"opacity-0 hover:opacity-100")}):null,l.notes&&""!==l.notes.value?(0,n.jsx)(sN.Z,{buttonStyles:"z-50 col-span-full row-span-2 row-start-1 h-4 w-4 self-start justify-self-end -translate-x-4 translate-y-3",savedNotes:l.notes}):null,!i&&(0,n.jsx)(O.HH,{className:(0,o.cn)("z-10 h-full w-full","right-0 p-0","border-none bg-transparent","col-span-3 col-end-3 row-span-full"),isConnectable:!1,id:w.vH.SOURCE_X,position:O.Ly.Right,type:"source"}),(0,n.jsx)(O.HH,{id:w.vH.TARGET_X,className:(0,o.cn)("h-full w-full","left-0 p-0","border-none bg-transparent","col-span-3 col-end-3 row-span-full"),position:O.Ly.Left,type:"target",isConnectable:!1,isConnectableEnd:v})]})},sO=e=>{var t,s;let{id:l,data:a,selected:i}=e,c=(0,O.oR)(k.cQ),[u]=(0,d.KO)(r.LI),[x,h]=(0,d.KO)(r.Fk),[p]=(0,d.KO)(sw.Zk),{getRelatedEdges:m}=sj(),g=!p&&(u.nodes.includes(l)||x.nodeId===l),{currentColor:f}=(0,Y.Z)(l),[v]=(0,d.KO)(r.iF),j="white"===f||"black"===f?"border-2":"border-4",b=!p&&i?"shadow-lg shadow-slate-500 dark:shadow-lg dark:shadow-gray-50":"",N=c!==l,y=()=>{if(!p){let e=m(l);h({nodeId:l,edges:e})}},C=()=>{p||h({nodeId:"",edges:[]})};return(0,n.jsxs)("div",{className:(0,o.cn)("h-44 w-44","items-center justify-center justify-items-center","bg-white p-2 text-center dark:bg-slate-900","rounded-[60px] border-2","hover:shadow-lg hover:shadow-slate-700 active:shadow-lg active:shadow-slate-900","dark:active:shadow-gray-400 dark:active:shadow-lg dark:hover:shadow-gray-300 dark:hover:shadow-lg","grid grid-cols-3",b),style:{borderColor:f},onContextMenu:e=>e.preventDefault(),onMouseOver:y,onMouseLeave:C,onFocus:y,onBlur:C,children:[a.focalPoint?(0,n.jsx)(sb.Z,{currentFocalPoint:a.focalPoint,className:(0,o.cn)("z-50 col-span-full row-span-1 row-start-1 translate-x-2 translate-y-2 self-start justify-self-start",v?"":"opacity-0 hover:opacity-100")}):null,a.notes&&""!==a.notes.value?(0,n.jsx)(sN.Z,{buttonStyles:"z-50 col-span-full row-span-1 row-start-1 h-4 w-4 self-start justify-self-end -translate-x-3 translate-y-3",savedNotes:a.notes}
1):null,!c&&(0,n.jsx)(O.HH,{className:(0,o.cn)("z-10 h-full w-full","right-0 p-0","transition-all duration-300 ease-in-out","rounded-[60px] bg-white dark:bg-slate-900","col-span-3 col-end-3 row-span-full",j,b,{"border-4 bg-[#BDD2B9] text-white dark:bg-green-300":g}),isConnectable:!1,id:w.vH.SOURCE_X,position:O.Ly.Right,type:"source",style:{borderColor:f}}),(0,n.jsx)(O.HH,{id:w.vH.TARGET_X,className:(0,o.cn)("h-full w-full","left-0 p-0","transition-all duration-300 ease-in-out","rounded-[60px] bg-white p-2 text-center dark:bg-slate-900","col-span-3 col-end-3 row-span-full",j,b,g?"border-4 bg-green-700/20 text-white dark:bg-green-800/40":""),position:O.Ly.Left,type:"target",isConnectable:!1,isConnectableEnd:N,style:{borderColor:f}}),(0,n.jsxs)("div",{className:(0,o.cn)("flex h-fit w-fit grow flex-col items-center justify-center justify-items-stretch py-6","transition-all duration-300 ease-in-out","z-20 col-span-3 col-start-1 row-span-full","text-black dark:text-white",g?"font-medium":""),children:[(0,n.jsx)(A.Z,{text:null!==(t=a.where)&&void 0!==t?t:"",isDefaultValue:a.where===w.vP.WHERE,maxLength:w.TO.WHERE,withHyphen:!1}),(0,n.jsx)(A.Z,{text:null!==(s=a.what)&&void 0!==s?s:"",isDefaultValue:a.what===w.vP.WHAT,maxLength:w.TO.WHAT})]})]})},sC=()=>{let e=ek.S.useContext();return{addCanvasObject:ek.S.canvasObjectFormat.add.useMutation({onSuccess:async()=>{await e.canvasObjectFormat.all.invalidate()}}),editCanvasObject:ek.S.canvasObjectFormat.edit.useMutation({onSuccess:async()=>{await e.canvasObjectFormat.all.invalidate()}})}},sS=()=>{let[e]=(0,d.KO)(r.lT),[t]=(0,d.KO)(r.dA),[,s]=(0,d.KO)(r.VY),{addCanvasObject:l}=sC(),[a,n]=(0,d.KO)(r.wm),[o]=(0,d.KO)(r.Kw),[i]=(0,d.KO)(r.FA);return{save:async()=>{if(!i||0===t.nodes.length)return;let r=t.nodes.filter(e=>!e.id.includes("ghost")).map(e=>({...e,selected:!1})),d=t.edges.map(e=>({...e,selected:!1})),c={nodes:r,edges:d};if(!await (0,eC.Z)(c,a)){let i=await (0,eS.L)(c);n(i),l.mutate({processId:e,hash:i,replaceLastCanvasObjectsQuantity:o,data:{nodes:r,edges:d,viewport:t.viewport},version:"v1"},{onSuccess:()=>{s(Date.now())},onError:()=>{n(a)}})}}}};let sE=()=>{var e,t;let[s]=(0,d.KO)(r.RC),[l]=(0,d.KO)(r.ak),[a]=(0,d.KO)(r.Kg),[n]=(0,d.KO)(r.lq),[o]=(0,d.KO)(r.mU),i=s.map(e=>{let t=a.find(t=>e.id===t.id);return void 0===t?e:(0,k.JG)(t)?0===(0,O.xA)(t,a,n).length?{...e,data:{...e.data,...t.data},parentNode:t.data.who,type:b.$P.TERMINAL}:{...e,data:{...e.data,...t.data},parentNode:t.data.who,type:b.$P.ACTION}:{...e,data:{...e.data,...t.data}}}),c=l.map(e=>{var t;let s=n.find(t=>e.id===t.id);return void 0===s?e:{...e,data:{...e.data,text:null===(t=s.data)||void 0===t?void 0:t.text}}}),u=c.filter(e=>n.find(t=>e.id===t.id)),x=s.filter(e=>(0,k.Qs)(e));if(1===x.length&&1===o.length&&o[0]!==(null===(e=x[0])||void 0===e?void 0:e.data.owner)){let e={...x[0],id:o[0],data:{...null===(t=x[0])||void 0===t?void 0:t.data,owner:o[0]}},s=i.filter(e=>!(0,k.Qs)(e)).map(t=>void 0!==t.parentNode?{...t,parentNode:e.id}:t);return{nodes:[e,...s],edges:u}}let h=x.filter(e=>(0,k.Qs)(e)&&!o.includes(e.data.owner)),p=i.filter(e=>!h.some(t=>t.id===e.id)).filter(e=>!(void 0!==e.parentNode&&!o.includes(e.parentNode))),m=o.filter(e=>!s.some(t=>(0,k.Qs)(t)&&t.data.owner===e));if(0===m.length){let e=Object.entries((0,k.Bo)(a,n)).reduce((e,t)=>{let[l,r]=t;return[...e,...r.filter(e=>!p.some(t=>t.id===e.id)).map((e,t)=>{let r=(0,O.xA)(e,a,n),o=(0,O.vG)(e,a,n),i={x:240*t+200,y:130};if(o.length>0){let e=s.find(e=>e.id===o[0].id);if(void 0!==e){var d,c,u,x;i={x:(null!==(u=null==e?void 0:null===(d=e.positionAbsolute)||void 0===d?void 0:d.x)&&void 0!==u?u:e.position.x)+200,y:null!==(x=null===(c=e.positionAbsolute)||void 0===c?void 0:c.y)&&void 0!==x?x:e.position.y}}}return 0===r.length?{...e,type:b.$P.TERMINAL,data:{...e.data},position:i,positionAbsolute:i,parentNode:l,extent:"parent"}:{...e,data:{...e.data},position:i,positionAbsolute:i,parentNode:l,extent:"parent"}})]},[]),t=n.filter(e=>!c.some(t=>t.id===e.id)).map(e=>({...e,data:{...e.data,points:[]},animated:!0})),l=p.filter(e=>(0,k.Qs)(e)),r=p.filter(e=>!(0,k.Qs)(e)),o=l[l.length-1];if(void 0===o)return{nodes:[...p,...e],edges:[...u,...t]};let i={...o,style:{border:w.eO}};return{nodes:[...r,...l.slice(0,-1),i,...e],edges:[...u,...t]}}let g=(0,k.Bo)(a,n),f=Object.entries(g).reduce((e,t)=>
1{let[l,r]=t;return[...e,...r.filter(e=>!p.some(t=>t.id===e.id)).map((e,t)=>{let r=(0,O.xA)(e,a,n),o=(0,O.vG)(e,a,n),i={x:240*t+200,y:130};if(o.length>0){let e=s.find(e=>e.id===o[0].id);if(void 0!==e){var d,c,u,x;i={x:(null!==(u=null==e?void 0:null===(d=e.positionAbsolute)||void 0===d?void 0:d.x)&&void 0!==u?u:e.position.x)+200,y:null!==(x=null===(c=e.positionAbsolute)||void 0===c?void 0:c.y)&&void 0!==x?x:e.position.y}}}return 0===r.length?{...e,type:b.$P.TERMINAL,data:{...e.data},position:i,positionAbsolute:i,parentNode:l,extent:"parent"}:{...e,data:{...e.data},position:i,positionAbsolute:i,parentNode:l,extent:"parent"}})]},[]),v=p.filter(e=>(0,k.Qs)(e));if(0===v.length){let e=x[x.length-1];if(void 0===e)return{nodes:i,edges:u};let t=e.position.y;return{nodes:[...m.map(s=>{var l;let a=t+2+((0,k.Qs)(e)&&null!==(l=e.data.height)&&void 0!==l?l:0);return t=a,{id:s,type:b.$P.SWIMLANE,position:{x:e.position.x,y:a},data:{owner:s,length:(0,k.Qs)(e)?e.data.length:1e3,height:(0,k.Qs)(e)?e.data.height:300},draggable:!1,selectable:!1,focusable:!1,style:{border:w.eO},zIndex:-1}}),...Object.entries(g).reduce((e,t)=>{let[s,l]=t;return m.includes(s)?[...e,...l.map((e,t)=>0===(0,O.xA)(e,a,n).length?{...e,type:b.$P.TERMINAL,data:{...e.data},position:{x:240*t+200,y:130},parentNode:s,extent:"parent"}:{...e,data:{...e.data},position:{x:240*t+200,y:130},parentNode:s,extent:"parent"})]:e},[])],edges:u.map(e=>({...e,data:{...e.data,points:[]},animated:!0}))}}let j=v[v.length-1];if(void 0===j)return{nodes:p,edges:u};let N=j.position.y,y=m.map(e=>{var t;let s=N+2+((0,k.Qs)(j)&&null!==(t=j.data.height)&&void 0!==t?t:0);return N=s,{id:e,type:b.$P.SWIMLANE,position:{x:j.position.x,y:s},data:{owner:e,length:(0,k.Qs)(j)?j.data.length:1e3,height:(0,k.Qs)(j)?j.data.height:300},draggable:!1,selectable:!1,focusable:!1,style:{border:w.eO},zIndex:-1}}),C=Object.entries(g).reduce((e,t)=>{let[s,l]=t;return m.includes(s)?[...e,...l.map((e,t)=>0===(0,O.xA)(e,a,n).length?{...e,type:b.$P.TERMINAL,data:{...e.data},position:{x:240*t+200,y:130},parentNode:s,extent:"parent"}:{...e,data:{...e.data},position:{x:240*t+200,y:130},parentNode:s,extent:"parent"})]:e},[]),S=n.filter(e=>!c.some(t=>t.id===e.id)).map(e=>({...e,data:{...e.data,points:[]},animated:!0}));return{nodes:[...p.reduce((e,t)=>t.id===j.id?[...e,{...t,style:{border:w.eO}},...y]:[...e,t],[]),...C,...f],edges:[...u,...S]}};var sI=()=>{let[e]=(0,d.KO)(r.Kg),[t]=(0,d.KO)(r.lq);return(0,k.WA)((0,k.FV)(sE()),{nodes:e,edges:t})},sP=(e,t)=>{var s;let l=ek.S.canvasObjectFormat.all.useQuery({filters:{...e},limit:1},t);return{canvasObject:l.data&&null!==(s=l.data.canvasObjectsList[0])&&void 0!==s?s:null,canvasObjectIsLoading:l.isLoading,canvasObjectError:l.error,isCanvasObjectError:l.isError}},sT=s(56859),sZ=()=>{let{isLoading:e,isError:t}=(0,sT.s)(),s=(0,m.Z)("processId"),{canvasObject:l,isCanvasObjectError:a,canvasObjectIsLoading:n}=sP({processId:s},{cacheTime:0,enabled:""!==s}),[o,i]=(0,c.useState)(),u=(0,d.b9)(r.wm),x=(0,d.b9)(r.VY),h=(0,d.b9)(r.jX),p=(0,d.b9)(r.u5);return o!==l&&(i(l),l?(x(e=>void 0!==l.updatedAt&&null!==l.updatedAt?l.updatedAt.getTime():e),u(l.hash),p(!0),h(l.data)):(u(""),p(!1),h({nodes:[],edges:[],viewport:w.Qu}))),{isLoading:n||e,isError:a||t,processId:s}},sA=function(e){var t,s,l,a;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"desc",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,[o,i]=(0,c.useState)(0),{isError:d,error:u,isLoading:x,data:h,fetchNextPage:p,hasNextPage:m,isFetching:g}=ek.S.canvasObjectFormat.all.useInfiniteQuery({filters:{processId:e},order:n,limit:r},{getNextPageParam:e=>e.nextCursor,refetchOnWindowFocus:!1}),f=h&&null!==(l=null===(t=h.pages[o])||void 0===t?void 0:t.canvasObjectsList)&&void 0!==l?l:null,v=async()=>{await p(),i(e=>e+1)},j=(0,c.useMemo)(()=>null==h?void 0:h.pages.flatMap(e=>e.canvasObjectsList),[h]);return{wholeCanvasObjects:null!=j?j:null,batchCanvasObjects:null!=f?f:null,canvasObjectIsLoading:x,canvasObjectError:u,canvasObjectsCount:null!==(a=null==h?void 0:null===(s=h.pages[0])||void 0===s?void 0:s.totalCanvasObjectCount)&&void 0!==a?a:0,onNextPage:v,isFetching:g,hasNextPage:m,page:o,isError:d}},sK=()=>{let e=(0,O._K)(),[t]=(0,d.KO)(r.u5),s=(0,m.Z)("processId"),[l,a]=(0,d.KO)(r.Kw),[,n]=(0,d.KO)(r.FA),[,o]=(0,d.KO)(r.lS),{toast:i}=(0,y.pm)(),{batchCanvasObjects:u,isError:x,canvasObjectIsLoading:h}=sA(s,"desc",10);(0,c.useEffect)(()=>{a(0)},[u,a]),(0,eR.y1)("mod+z",()=>{if(!t||h)return;if(x){i({title:"Format",description:"It is not possible to go backwards in time",variant:"destructive"});return}if(null==u||(null==u?void 0:u.length)===0)return;if(l>=u.length-1){i({title:"Format",description:"No more changes to undo",variant:"default"});return}let s=l+1,r=u.at(s);r&&(e.setNodes(r.data.nodes),e.setEdges(r.data.edges),a(s),n(!1),o(!0))}
1),(0,eR.y1)("mod+shift+z",()=>{if(h)return;if(x){i({title:"Format",description:"No more changes to redo",variant:"destructive"});return}if(!u)return;if(l<=0){i({title:"Format",description:"It is the latest save point",variant:"default"});return}let t=l-1,s=u.at(t);s&&(e.setNodes(s.data.nodes),e.setEdges(s.data.edges),a(t),n(!1),o(!0))})},sz=s(80481);let s_=W.z.array(W.z.object({pathString:W.z.string(),id:W.z.string()})),sL=W.z.object({data:W.z.object({pathStrings:s_}).nullable(),error:W.z.object({message:W.z.string()}).nullable()}),sR=async e=>{let{layoutedNodes:t,largeEdges:s,runPathPostProcessing:l}=e,a=(0,sz.J)(),n=await fetch("".concat(a,"/api/autolayout"),{method:"POST",body:JSON.stringify({layoutedNodes:t,largeEdges:s,runPathPostProcessing:l}),headers:{"Content-Type":"application/json"}}),r=sL.safeParse(await n.json());if(!r.success)throw Error("Invalid path strings");if(null!==r.data.error)throw Error(r.data.error.message);if(null===r.data.data)throw Error("Invalid path strings");return r.data.data.pathStrings};var sD=()=>{let[e]=(0,d.KO)(r.VY),[t,s]=(0,c.useState)((0,eW.U)(e,Date.now()));return(0,eG.Z)(()=>{s((0,eW.U)(e,Date.now()))},500),(0,n.jsx)(O.s_,{className:"flex h-10 w-52 flex-col items-center justify-center gap-4 roun
1ded-lg ",position:"bottom-right",children:(0,n.jsxs)("span",{className:"text-slate-600 text-sm dark:text-slate-500",children:["Last saved: ",t]})})},sH=()=>(0,n.jsx)("div",{id:"loading",className:"-translate-x-1/2 -translate-y-1/2 absolute top-1/2 left-1/2 z-10 h-fit w-fit items-center rounded-lg bg-gray-500 p-6",children:(0,n.jsxs)("div",{className:"flex items-center justify-center text-gray-200 dark:text-gray-50",children:[(0,n.jsx)(ej.P.Spinner,{className:"mr-2 h-6 w-6 animate-spin fill-green-700 text-gray-200 dark:text-gray-400"}),(0,n.jsx)("p",{children:"Downloading..."})]})}),sF=s(42401);let sW={hideAttribution:!0},sG={[b.$P.ACTION]:sy,[b.$P.QUESTION]:sk,[b.$P.SWIMLANE]:N.Ou,[b.$P.TERMINAL]:sO,[b.$P.CONTROL]:N.w6},sM={[b.rP.TIME]:N.XA,[b.rP.ANSWER]:N.tE};var sV=e=>{let{reactFlowWrapper:t}=e,[,s]=(0,d.KO)(r.$5),[l]=(0,d.KO)(r.nj),[a,i]=(0,O.Rr)([]),[u,x]=(0,O.ll)([]),[h,p]=(0,c.useState)(!1),m=(0,O._K)();(0,c.useEffect)(()=>{let e=l.edges.map(e=>({...e,animated:!1}));setTimeout(()=>{i(l.nodes)},100),x(e)},[l.edges,l.nodes,m,s,x,i]),(0,c.useEffect)(()=>{let e=a.filter(e=>e.type===b.$P.SWIMLANE);if(1===e.length){m.fitView({nodes:e,padding:.2}),m.zoomOut();return}m.fitView({padding:.2})},[a,u,m]);let g=(0,c.useCallback)(()=>{let e=l.edges.map(e=>({...e,animated:!1}));s(void 0),i(l.nodes),x(e),setTimeout(()=>{p(!0)},100)},[l.edges,l.nodes,x,i,s]);return(0,n.jsx)("div",{className:(0,o.cn)("h-full w-full md:max-w-screen-xl lg:max-w-screen-2xl","rounded-lg border-2 border-gray-200 bg-white dark:border-gray-700 dark:bg-slate-900"),ref:t,children:(0,n.jsxs)(O.x$,{nodes:a,edges:u,edgesUpdatable:!1,edgesFocusable:!1,nodesConnectable:!1,nodesDraggable:!1,nodesFocusable:!1,elementsSelectable:!1,disableKeyboardA11y:!0,nodeTypes:sG,edgeTypes:sM,onInit:g,proOptions:sW,style:{opacity:h?1:0},deleteKeyCode:null,panOnDrag:!1,zoomOnPinch:!1,zoomOnDoubleClick:!1,zoomOnScroll:!1,panOnScroll:!1,panActivationKeyCode:null,multiSelectionKeyCode:null,selectionKeyCode:null,fitView:!0,fitViewOptions:{padding:.2},minZoom:0,nodeDragThreshold:10,children:[(0,n.jsx)(ts,{}),(0,n.jsx)(ti,{})]})})},sJ=()=>{let[,e]=(0,d.KO)(r.iF);return(0,n.jsxs)("div",{className:"flex items-center justify-center gap-3 p-1",children:[(0,n.jsx)(i.rsf,{onClick:()=>{e(e=>!e)}}),(0,n.jsx)("span",{children:"Focal Points"})]})},sU=()=>{let[e]=(0,d.KO)(r.lT),{process:t,processError:s,processIsLoading:l}=(0,v.Z)({processId:e});return(0,c.useMemo)(()=>s||l||!t?(0,S.Z)():t.title,[s,l,t])},sQ=s(92642),s$=s(34002),sB=s(10477),sq=()=>{let{toast:e}=(0,y.pm)();return{htmlToImageConvert:t=>{let{reactFlowWrapper:s,setIsDownloading:l,fileName:a}=t;s&&s.current&&(l(!0),(0,s$.hi)(s.current,{filter:e=>{var t,s;return!((null==e?void 0:null===(t=e.classList)||void 0===t?void 0:t.contains("react-flow__minimap"))||(null==e?void 0:null===(s=e.classList)||void 0===s?void 0:s.contains("react-flow__controls"))||(null==e?void 0:e.id)==="loading")},pixelRatio:w.md}).then(e=>{let t=document.createElement("a");t.download="".concat(a,".jpg"),t.href=e,t.click(),l(!1)}).catch(t=>{l(!1),e({title:"Export",description:"It is not possible to export to jpg",variant:"destructive"}),sQ.Tb(t)}))},htmlToPdf:t=>{let{reactFlowWrapper:s,setIsDownloading:l,fileName:a}=t;s&&s.current&&(l(!0),(0,s$.hi)(s.current,{filter:e=>{var t,s;return!((null==e?void 0:null===(t=e.classList)||void 0===t?void 0:t.contains("react-flow__minimap"))||(null==e?void 0:null===(s=e.classList)||void 0===s?void 0:s.contains("react-flow__controls"))||(null==e?void 0:e.id)==="loading")},pixelRatio:w.md}).then(e=>{let t=new sB.kH({orientation:"landscape",format:[w.gv,w.uI],unit:"px",putOnlyUsedFonts:!0,floatPrecision:"smart"}),s=t.getImageProperties(e),n=s.height*w.gv/s.width;t.addPage([w.gv,n],"landscape"),t.addImage(e,"JPGE",0,0,w.gv,n),t.deletePage(1),t.save(a),l(!1)}).catch(t=>{l(!1),e({title:"Export",description:"It is not possible to export to PDF",variant:"destructive"}),sQ.Tb(t)}))}}},sX=e=>{let[t,s]=(0,c.useState)(!1),l=(0,c.useRef)(null),[,a]=(0,d.KO)(r.hw),[,n]=(0,d.KO)(r.LI),o=sU(),{htmlToPdf:i,htmlToImageConvert:u}=sq();return{handleOnClickPanel:t=>{t.stopPropagation(),n({nodes:[],edges:[]}),e(!0),a(!0)},handleOnClickDownloadJpg:()=>{u({fileName:o,reactFlowWrapper:l,setIsDownloading:s})},handleOnClickDownloadPdf:()=>{i({fileName:o,reactFlowWrapper:l,setIsDownloading:s})},isDownloading:t,reactFlowWrapper:l}},sY=()=>{let[e,t]=(0,c.useState)(!1),[,s]=(0,d.KO)(sw.Zk),[,l]=(0,d.KO)(r.iF),[,a]=(0,d.KO)(r.eL),[,u]=(0,d.KO)(r.hw),x=e=>{t(e),s(e),e||(l(!1),a(!1),u(!1))},{handleOnClickDownloadPdf:h,handleOnClickDownloadJpg:p,reactFlowWrapper:m,handleOnClickPanel:g,isDownloading:f}=sX(x);return(0,n.jsxs)(i.VqE,{open:e,onOpenChange:x,children:[(0,n.jsx)(i.hgM,{asChild:!0,onClick:g,children:(0,n.jsxs)(e2.Z,{id:"export-capture-button",children:[(0,n.jsx)("span",{children:"Export"}),(0,n.jsx)(o.PJP.Download,{className:"h-full w-3"})]})}),(0,n.jsxs)(i.cZJ,{className:"w-11/12",children:[(0,n.jsx)(i.fKu,{children:(0,n.jsx)(i.$N8,{className:"flex items-center gap-3",children:"Export Formatted Process Preview"})}),(0,n.jsxs)("div",{className:"flex flex-row items-start justify-items-start gap-2",children:[f?(0,n.jsx)(sH,{}):null,(0,n.jsx)("div",{className:"h-[60vh] w-full",children:(0,n.jsx)(O.tV,{children:(0,n.jsx)(sV,{reactFlowWrapper:m})})}),(0,n.jsx)("div",{className:"flex h-full min-w-[15rem] flex-col items-start justify-end",children:(0,n.jsxs)("div",{className:"flex w-full flex-col items-start justify-start gap-1",children:[(0,n.jsx)(sF.Z,{kind:"canvas-view"}),(0,n.jsx)(tA,{}),(0,n.jsx)(sJ,{})]})})]}),(0,n.jsx)(i.cNS,{children:(0,n.jsxs)("div",{id:"export-capture-footer",className:"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",children:[(0,n.jsx)(i.zxk,{disabled:f,onClick:p,children:"Export as JPG"}),(0,n.jsx)(i.zxk,{disabled:f,onClick:h,children:"Export as PDF"})]})})]})]})},s0=()=>{let[e,t]=(0,d.KO)(r.u5);return(0,n.jsxs)(e2.Z,{onClick:()=>{t(!e)},children:[(0,n.jsx)("span",{children:e?"Exit Manual breakout":"Manual breakout"}),e?(0,n.jsx)(o.PJP.PencilOff,{className:"h-full w-3"}):(0,n.jsx)(o.PJP.PencilRuler,{className:"h-full w-3"})]})},s1=()=>{let{isLoading:e,isAvailable:t}=(0,eL.Z)(w.ZA.MANUAL_BREAKOUT),[s]=(0,d.KO)(r.RC),l=!e&&t&&s.length<=0;return(0,n.jsxs)(O.s_,{position:"top-right",className:(0,tt.cn)("flex h-8 flex-row gap-2 p-0 ","rounded-lg","justify-between"),id:"format-top-right-panel",children:[l&&(0,n.jsx)(s0,{}),(0,n.jsx)(sY,{})]})};let s2={hideAttribution:!0},s5={[b.$P.ACTION]:sy,[b.$P.QUESTION]:sk,[b.$P.SWIMLANE]:N.Ou,[b.$P.TERMINAL]:sO,[b.$P.CONTROL]:N.w6},s3={[b.rP.TIME]:N.XA,[b.rP.ANSWER]:N.tE},s4={id:"visibility-graph",type:"control",position:{x:-100,y:-100},data:{text:""},dragging:!1,positionAbsolute:{x:-100,y:-100},selected:!1,hidden:!1},s6=[1,2],s8=()=>{let{isError:e,isLoading:t}=sZ(),[s,l]=(0,c.useState)(!1),[a]=(0,d.KO)(r.u5),[o]=(0,d.KO)(r.RC),{nodes:i,edges:x}
1=sI(),[,h]=(0,d.KO)(r.LI),{layoutResult:p}=(0,j.$Y)(),[m,g]=(0,O.Rr)([]),[f,v]=(0,c.useState)(m),[w,k,C]=(0,O.ll)([]),[E,I]=(0,c.useState)(w),[,P]=(0,d.KO)(r.He),[,T]=(0,d.KO)(r.Db),[,Z]=(0,d.KO)(r.AS),[,A]=(0,d.KO)(r.yh),[,K]=(0,d.KO)(r.nj),[,z]=(0,d.KO)(r.DS),[,_]=(0,d.KO)(r.FA),[,L]=(0,d.KO)(r.dA),[,R]=(0,d.KO)(r.ad),{save:D}=sS(),H=(0,O._K)(),{toast:F}=(0,y.pm)();sK();let{customApplyNodeChanges:W,helperLineVertical:G,helperLineHorizontal:M}=(0,e_.Z)(!0),V=(0,c.useRef)(null);(0,O.AQ)({onChange:e=>{let{nodes:t,edges:s}=e;if(!t.length&&!s.length){h({nodes:[],edges:[]});return}if(s.length&&h({nodes:[],edges:s.map(e=>e.id)}),t.length){if(t.some(e=>e.type===b.$P.SWIMLANE)){h({nodes:[],edges:[]});return}let e=t.flatMap(e=>w.filter(t=>t.source===e.id||t.target===e.id).map(e=>e.id));h({nodes:t.map(e=>e.id),edges:e})}}}),(0,c.useEffect)(()=>{K({nodes:m,edges:w})},[w,m,K]),f!==m&&E!==w?(v(m),I(w),L(H.toObject()),m.length>0&&(D(),_(!1))):f!==m?(v(m),L(H.toObject()),m.length>0&&(D(),_(!1))):E!==w&&(I(w),L(H.toObject()),w.length>0&&(D(),_(!1)));let J=(0,c.useCallback)(()=>{let e=async()=>{let e=await p;P(e.largeEdges),T(e.layoutedNodes),Z(e.layoutedEdges),A(e.layoutedEdgesPaths);let t=await sR({largeEdges:e.largeEdges,runPathPostProcessing:!1,layoutedNodes:e.layoutedNodes}).catch(e=>{e instanceof Error?F({title:"Error",description:e.message,variant:"destructive"}):F({title:"Error",description:"Error fetching path strings",variant:"destructive"}),R([])});l(!0),t&&R(t),g([...e.layoutedNodes,s4]),z(e.layoutedEdgesPaths),
1k(e.layoutedEdges.map(s=>{var l,a,n,r;let o=null===(l=e.layoutedEdgesPaths)||void 0===l?void 0:l.find(e=>e.id===s.id),i=null==t?void 0:t.find(e=>e.id===s.id),d=null!==(n=null!==(a=null==o?void 0:o.calculatedPath)&&void 0!==a?a:null==i?void 0:i.pathString)&&void 0!==n?n:"",c=(0,j.nL)(d).map(e=>({...e,active:!0,id:(0,S.Z)()}));return{...s,data:{text:"",...null!==(r=s.data)&&void 0!==r?r:{},points:c}}})),L(H.toObject()),_(!1)};o.length>0?(_(!1),g(i),k(x),l(!0)):e()},[o.length,p,P,T,Z,A,R,g,z,k,H,L,_,F,i,x]),U=(0,c.useCallback)(e=>{g(t=>W(e,t)),e.some(e=>"select"===e.type||"dimensions"===e.type&&!1!==e.resizing)?_(!1):_(!0)},[W,_,g]),Q=(0,c.useCallback)(()=>{_(!1)},[_]),B=(0,c.useCallback)(()=>{_(!1)},[_]),q=(0,c.useCallback)(()=>{_(!0)},[_]),X=(0,c.useCallback)(e=>{C(e),e.some(e=>"select"===e.type&&!1===e.selected)&&_(!0)},[C,_]);return t||e?(0,n.jsx)("div",{className:"h-full w-full",children:(0,n.jsx)(u.Z,{})}):(0,n.jsxs)("div",{id:"format-flow-container-div",className:"relative h-full w-full",ref:V,children:[s?null:(0,n.jsx)("div",{className:"absolute z-10 flex h-full w-full items-center justify-center bg-white dark:bg-slate-900",children:(0,n.jsx)(u.Z,{description:"Loading your process",textClassName:"text-center text-lg"})}),(0,n.jsx)("div",{className:"absolute inset-x-1/2 z-50 h-[1px] w-full translate-x-[-50%] border border-semantic-success-8 bg-semantic-success-8"}),(0,n.jsx)("div",{className:"absolute inset-x-1/2 z-50 flex w-max translate-x-[-50%] flex-col items-center rounded-b-lg bg-semantic-success-8 px-2 text-secondary-color-secondary-12",children:(0,n.jsx)("span",{className:"text-sm",children:"Format is in Beta, feedback is welcomed"})}),(0,n.jsxs)(O.x$,{nodes:m,edges:w,nodeTypes:s5,edgeTypes:s3,edgesFocusable:a,edgesUpdatable:a,nodesDraggable:a,nodesConnectable:!1,nodesFocusable:!1,onNodesChange:U,onNodeDragStart:Q,onNodeDrag:B,onNodeDragStop:q,onEdgesChange:X,onInit:J,elementsSelectable:!0,proOptions:s2,fitView:!0,style:{opacity:s?1:0},minZoom:.1,maxZoom:3,snapToGrid:!0,snapGrid:[5,5],nodeDragThreshold:5,selectionOnDrag:!0,deleteKeyCode:null,panOnDrag:s6,children:[(0,n.jsx)(N.PF,{horizontal:M,vertical:G}),(0,n.jsx)(sv,{}),(0,n.jsx)($,{isVisibleAutoLayoutButton:!1}),(0,n.jsx)(s1,{}),(0,n.jsx)(sD,{})]})]})};var s9=()=>(0,n.jsx)(O.tV,{children:(0,n.jsx)(s8,{})}),s7=()=>(0,n.jsx)(O.s_,{className:(0,tt.cn)("flex h-8 w-60 flex-row p-0 ","rounded-lg","items-center justify-items-center"),position:"top-center",children:(0,n.jsx)("span",{className:"animate-pulse text-center text-2xl",children:"Read only view"})}),le=s(50284);let lt=e=>{let{children:t}=e;return(0,n.jsxs)(O.s_,{position:"bottom-left",className:"flex h-36 w-fit flex-col items-start justify-end gap-8 rounded-lg",children:[t,(0,n.jsx)(le.Z,{showInteractive:!1,className:"ml-0",position:"top-left"})]})};var ls=()=>{let{toast:e}=(0,y.pm)(),{addCanvasObject:t}=eO(),{isLoading:s,canvasObject:l,isError:a,processId:i}=(0,sT.s)(),[,c]=(0,d.KO)(r.lf),u=(0,d.b9)(r.r5),h=(0,d.b9)(r.O0),p=(0,d.b9)(r.wA),m=(0,x.useRouter)(),g=async()=>{if(!l||a){e({title:"Save point",description:"Invalid current savepoint",variant:"destructive"});return}let s=await (0,eS.L)(l.data),n=(0,k.R0)(m.asPath);t.mutate({processId:i,hash:s,data:l.data,version:"v1"},{onSuccess:async()=>{h(!1),u(s),c(Date.now()),p(l.data),e({title:"Save point",description:"You are now working from the selected save point",variant:"default"}),await m.push("".concat(n,"?flow=capture"))},onError:()=>{e({title:"Save point",description:"It is not possible to continue from here",variant:"destructive"})}})};return s?(0,n.jsx)(lt,{children:(0,n.jsx)(o.zxk,{variant:"ghost",className:"flex h-8 w-auto flex-col border-2 border-gray-200 border-solid bg-white text-center drop-shadow-lg dark:text-black",disabled:!0,children:(0,n.jsx)(o.OdW,{className:"h-6 w-[15em]"})})}):(0,n.jsx)(lt,{children:(0,n.jsx)(o.zxk,{id:"continue-from-here-button",variant:"ghost",className:"flex h-8 w-auto flex-col border-2 border-gray-200 border-solid bg-white text-center drop-shadow-lg dark:text-black",onClick:g,children:"Continue from here"})})};let ll=[0,1,2],la={hideAttribution:!0},ln={[b.$P.ACTION]:td.Z,[b.$P.QUESTION]:tc.Z},lr={[b.rP.TIME]:N.iy,[b.rP.ANSWER]:tn.Z},lo=()=>{let{nodes:e,edges:t,isLoading:s,isError:l}=(0,eI.y)(),a=(0,c.useRef)(null);return s?(0,n.jsx)("div",{className:"h-full w-full",children:(0,n.jsx)(u.Z,{})}):l?(0,n.jsx)("div",{className:"flex h-full w-full items-center justify-center",children:"Something went wrong"}):(0,n.jsx)("div",{id:"timeline-flow-container-div",className:"h-full w-full",ref:a,children:(0,n.jsxs)(O.x$,{nodes:e,edges:t,edgesUpdatable:!1,edgesFocusable:!1,nodesConnectable:!1,nodesDraggable:!1,nodesFocusable:!1,disableKeyboardA11y:!0,nodeTypes:ln,edgeTypes:lr,proOptions:la,nodeOrigin:[.5,.5],c
1onnectionLineStyle:{strokeWidth:4},snapGrid:[10,10],snapToGrid:!0,deleteKeyCode:null,nodeDragThreshold:10,maxZoom:3,minZoom:.1,fitView:!0,panOnDrag:ll,children:[(0,n.jsx)(ls,{}),(0,n.jsx)(s7,{})]})})};var li=()=>(0,n.jsx)(O.tV,{children:(0,n.jsx)(lo,{})}),ld=()=>{let e=(0,d.b9)(r.Y$),t=(0,m.Z)("processId"),{process:s,processIsLoading:l}=(0,v.Z)({processId:t}),a=(0,p.Z)();return(e(null!=a?a:""),l||!s)?(0,n.jsx)("div",{className:"h-full w-full",children:(0,n.jsx)(u.Z,{})}):"read-only"!==a&&s.isCurrentUserOwner?"capture"===a?(0,n.jsx)(sp,{}):"timeline"===a?(0,n.jsx)(li,{}):"format"===a?(0,n.jsx)(s9,{}):(0,n.jsx)(sp,{}):(0,n.jsx)(sm.Z,{})},lc=e=>{var t,s,l,a;let{processId:n,order:r="desc",limit:o=10,enabled:i=!0}=e,[d,u]=(0,c.useState)(0),{error:x,isLoading:h,data:p,fetchNextPage:m,hasNextPage:g,isFetching:f}=ek.S.canvasObject.all.useInfiniteQuery({filters:{processId:n},order:r,limit:o},{getNextPageParam:e=>e.nextCursor,refetchOnWindowFocus:!1,enabled:i}),v=p&&null!==(l=null===(t=p.pages[d])||void 0===t?void 0:t.canvasObjectsList)&&void 0!==l?l:null,j=async()=>{await m(),u(e=>e+1)},w=(0,c.useMemo)(()=>null==p?void 0:p.pages.flatMap(e=>e.canvasObjectsList),[p]);return{wholeCanvasObjects:null!=w?w:null,batchCanvasObjects:null!=v?v:null,canvasObjectIsLoading:h,canvasObjectError:x,canvasObjectsCount:null!==(a=null==p?void 0:null===(s=p.pages[0])||void 0===s?void 0:s.totalCanvasObjectCount)&&void 0!==a?a:0,onNextPage:j,isFetching:f,hasNextPage:g,page:d}},lu=(0,c.memo)(e=>{let{canvasObject:t,isSelected:s,lastSavePoint:l}=e,a=(0,d.b9)(r.O0),c=(0,x.useRouter)(),u=async()=>{let e=(0,k.R0)(c.asPath);if(l){a(!1),await c.push("".concat(e,"?flow=capture"));return}await c.push("".concat(e,"?flow=timeline&canvasObjectId=").concat(t.id))};return(0,n.jsx)(tl.Z,{text:t.id,truncateText:!0,maxTextLength:8,copyToClipboard:!0,asChild:!0,children:(0,n.jsx)(i.zxk,{variant:"ghost",className:(0,o.cn)("h-8 w-8 skew-y-6 items-center justify-center border-2 border-gray-500 p-1 text-gray-500",s?"border-4 border-green-700":""),onClick:u,children:(0,n.jsx)(o.PJP.History,{className:"h-full w-full"})})})});let lx=(0,c.memo)(()=>(0,n.jsx)("div",{className:"-mx-4 bg-inherit",children:(0,n.jsx)(o.PJP.Dot,{className:"h-8 w-8 stroke-slate-500"})})),lh=(0,c.memo)(e=>{let{children:t}=e;return(0,n.jsxs)("div",{id:"timeline-slot",className:"relative h-16 w-[88%] max-w-[88%] overflow-visible rounded-lg",children:[(0,n.jsx)("h4",{className:"absolute top-[-8px] left-2 rounded-lg bg-white px-1 font-medium text-xs dark:bg-gray-900",children:"Process Timeline"}),t]})});var lp=(0,c.memo)(()=>{let{isAvailable:e}=(0,eL.Z)(w.ZA.PROCESS_TIMELINE),t=(0,d.Dv)(r.lT),s=(0,U.useSearchParams)().get("canvasObjectId"),l=(0,p.Z)(),{canvasObjectIsLoading:a,onNextPage:o,hasNextPage:u,isFetching:x,wholeCanvasObjects:h,page:m}=lc({processId:t,enabled:!!e}),g=(0,c.useRef)(null),f=(0,c.useRef)(),v=(0,c.useCallback)(e=>{!a&&(f.current&&f.current.disconnect(),f.current=new IntersectionObserver(async e=>{e[0]&&e[0].isIntersecting&&u&&!x&&await o()}),e&&f.current.observe(e))},[u,x,a,o]),j=(0,c.useMemo)(()=>null==h?void 0:h.reduceRight((e,t)=>[...e,t],[]),[h]);return((0,c.useEffect)(()=>{if(g.current){var e;let t=null===(e=g.current)||void 0===e?void 0:e.lastElementChild;null==t||t.scrollIntoView({behavior:"instant"})}},[m]),e)?a?(0,n.jsx)(lh,{children:(0,n.jsxs)("div",{className:"z-0 flex h-fit max-h-16 w-full justify-items-center gap-5 overflow-x-auto rounded-lg border-2 border-gray-200 px-4 py-2 lg:max-w-[88vw] 2xl:max-w-[90vw] dark:border-gray-700",children:[(0,n.jsx)(lx,{}),Array.from({length:5}).map(()=>(0,n.jsx)(i.OdW,{className:"h-8 w-8 rounded-full"},Math.random())),(0,n.jsx)(lx,{})]})}):(null==h?void 0:h.length)!==0&&h?(0,n.jsx)(lh,{children:(0,n.jsxs)("div",{ref:g,className:"z-0 flex h-fit max-h-16 w-full justify-items-center gap-5 overflow-x-auto rounded-lg border-2 border-gray-200 px-4 py-2 lg:max-w-[88vw] 2xl:max-w-[90vw] dark:border-gray-700",children:[(0,n.jsx)(lx,{}),null==j?void 0:j.map((e,t)=>t===j.length-1?(0,n.jsx)("div",{ref:null,children:(0,n.jsx)(lu,{lastSavePoint:!0,canvasObject:e,isSelected:"capture"===l})},e.id):(0,n.jsx)("div",{ref:0===t?v:null,children:(0,n.jsx)(lu,{canvasObject:e,isSelected:s===e.id})},e.id)),(0,n.jsx)(lx,{})]})}):(0,n.jsx)(lh,{children:(0,n.jsx)("div",{className:"flex h-fit max-h-16 flex-row justify-center justify-items-center gap-2 rounded-lg border-2 border-gray-200 px-4 py-2 text-slate-500 lg:max-w-[81vw] 2xl:max-w-[89vw] dark:border-gray-700 dark:text-slate-50",children:(0,n.jsx)(i.C0v,{children:"No save points, start capturing to show history."})})}):null}),lm=s(26837);let lg=e=>{let{children:t,className:s}=e;return(0,n.jsxs)("div",{className:(0,o.cn)("relative h-16 w-[12.5%] max-w-[12.5%] overflow-visible text-ellipsis rounded-lg",s
1),children:[(0,n.jsx)("h4",{className:(0,o.cn)("absolute top-[-8px] left-2 rounded-lg bg-white px-1 dark:bg-gray-900 ","truncate text-ellipsis whitespace-nowrap font-medium text-xs"),children:"Process Title"}),(0,n.jsx)("div",{className:"z-0 flex h-[3.25rem] max-h-16 w-full items-center justify-items-center gap-1 rounded-lg border-2 border-gray-200 px-4 py-2 dark:border-gray-700",children:t})]})};var lf=e=>{let{className:t}=e,s=(0,m.Z)("processId"),{process:l,processError:a,processIsLoading:r}=(0,v.Z)({processId:s});return a||!l?(0,n.jsx)(lg,{className:t,children:(0,n.jsx)(o.OPt,{children:" Error loading process "})}):r?(0,n.jsx)(lg,{className:t,children:(0,n.jsx)(o.OdW,{className:"h-7 w-full dark:bg-gray-400/25"})}):(0,n.jsx)(lg,{className:t,children:(0,n.jsx)(lm.Z,{asChild:!0,process:l,children:(0,n.jsx)("span",{className:"group block h-fit max-h-16 w-full max-w-[90%] truncate py-2 text-center font-medium text-sm 2xl:text-lg",children:l.title})})})},lv=()=>(0,n.jsxs)("div",{className:"flex w-screen flex-row items-center justify-between gap-2 px-2",children:[(0,n.jsx)(lf,{}),(0,n.jsx)(lp,{})]}),lj=s(39097),lw=s.n(lj),lb=s(77587),lN=s(22461),ly=s(44778),lk=s(7690);let lO=e=>{let{isPrivate:t,className:s,teamId:l}=e,{topResources:a,isError:r,isLoading:i}=(0,lb.Z)({enabled:null!=l});if(null===l||void 0===a||i||r)return t?(0,n.jsx)(tl.Z,{text:"This process is private, only you can see it",className:"text-start",children:(0,n.jsx)(o.PJP.User,{className:(0,o.cn)("h-5 w-5",s)})}):(0,n.jsx)(tl.Z,{text:"This process is public, anyone on your team can see it",className:"text-start",children:(0,n.jsx)(o.PJP.Users,{className:(0,o.cn)("h-5 w-5",s)})});let d=a.find(e=>e.id===l);return t?(0,n.jsx)(tl.Z,{text:"This project is private, only you can see it",className:"text-start",children:(0,n.jsx)(o.PJP.User,{className:(0,o.cn)("h-5 w-5",s)})}):(0,n.jsx)(tl.Z,{text:"This project is public, anyone on ".concat(void 0!==d?d.name:"your team"," can see it"),className:"text-start",children:(0,n.jsx)(o.PJP.Users,{className:(0,o.cn)("h-5 w-5",s)})})},lC=!1;var lS=()=>{var e;let[t,s]=(0,c.useState)(!1),{projects:l,isError:a,projectsLoading:i}=(0,lN.Z)(),u=(0,m.Z)("projectId"),[x,h]=(0,c.useState)(u),[,p]=(0,d.KO)(r.Ir);(0,c.useEffect)(()=>{lC||""===u||(p(u),lC=!0)},[u,p]);let g=e=>{h(e),p(e),s(!1)},f=(0,c.useCallback)(e=>u===e?"text-green-700 underline font-bold stroke-green-700 stroke-[0.2rem]":"",[u]);if(i)return(0,n.jsx)("div",{className:"flex flex-row gap-2",children:(0,n.jsx)(o.J2e,{open:t,children:(0,n.jsx)(tl.Z,{asChild:!0,text:"loading projects",children:(0,n.jsx)(o.xol,{asChild:!0,id:"project-selector-combobox",children:(0,n.jsxs)(o.zxk,{disabled:!0,variant:"soft",role:"combobox","aria-expanded":t,className:"flex h-fit min-h-[2.5rem] w-60 shrink-0 items-center justify-between gap-2 rounded-lg p-3",children:[(0,n.jsx)(o.OdW,{className:"h-12 w-full bg-neutral-neutral-7"}),(0,n.jsx)(o.PJP.ChevronsUpDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})})})})});if(a)return(0,n.jsx)("div",{className:"flex flex-row gap-2",children:(0,n.jsx)(o.J2e,{open:t,children:(0,n.jsx)(tl.Z,{asChild:!0,text:"Error loading projects",children:(0,n.jsx)(o.xol,{asChild:!0,id:"project-selector-combobox",children:(0,n.jsxs)(o.zxk,{disabled:!0,variant:"soft",role:"combobox","aria-expanded":t,className:"flex h-fit min-h-[2.5rem] w-60 shrink-0 items-center justify-between gap-2 rounded-lg p-3",children:[(0,n.jsx)("span",{className:"block text-start font-bold text-accent-color-accent-12 text-base leading-7 tracking-[-0.4px]",children:"Something went wrong"}),(0,n.jsx)(o.PJP.ChevronsUpDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})})})})});let v=l.find(e=>e.id===x),j=x&&v?(null===(e=l.find(e=>e.id===x))||void 0===e?void 0:e.name)||"":"Select Project",w=(null==v?void 0:v.teamId)===null,b=null==v?void 0:v.teamId;return(0,n.jsxs)("div",{className:"flex flex-row items-center gap-2",children:[(0,n.jsxs)(o.J2e,{open:t,onOpenChange:s,children:[(0,n.jsx)(tl.Z,{asChild:!0,text:j,children:(0,n.jsx)(o.xol,{asChild:!0,id:"project-selector-combobox",children:(0,n.jsxs)(o.zxk,{variant:"soft",role:"combobox","aria-expanded":t,className:"flex h-fit min-h-[2.5rem] w-60 shrink-0 items-center justify-between gap-2 rounded-lg p-3",children:[(0,n.jsxs)("span",{className:"flex flex-row justify-center gap-1 text-start font-bold text-accent-color-accent-12 text-xl leading-7 tracking-[-0.4px]",children:[(0,k.$G)(j,30),"Select project"!==j?(0,n.jsx)(lO,{isPrivate:w,teamId:b}):null]}),(0,n.jsx)(o.PJP.ChevronsUpDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})})}),(0,n.jsx)(o.yky,{className:"w-[400px] bg-white p-0 dark:bg-slate-800",children:(0,n.jsxs)(o.mYg,{children:[(0,n.jsx)(o.sZt,{placeholder:"Search project...",className:"h-9"}),(0,n.jsxs)(o.e8h,{children:[(0,n.jsx)(o.rb5,{children:"Create your first project to get started"}),(0,n.jsx)(o.fuJ,{className:l.length>4?"h-36 overflow-y-scroll":"",children:l.map(e=>(0,n.jsxs)(o.diK,{value:e.name,onSelect:()=>g(e.id),children:[(0,n.jsxs)("div",{className:(0,o.cn)("flex flex-row items-start justify-center gap-1",f(e.id)),children:[(0,n.jsx)(tl.Z,{text:e.name,children:(0,k.$G)(e.name,30)},e.id),(0,n.jsx)(lO,{isPrivate:null===e.teamId,teamId:e.teamId,className:"h-4 w-4"})]}),(0,n.jsx)(o.PJP.CheckIcon,{className:(0,o.cn)("ml-auto h-4 w-4",x===e.id?"opacity-100":"opacity-0")})]},e.id))})]})]})})]}),(0,n.jsxs)("div",{className:"flex flex-col items-center justify-between",children:[(0,n.jsx)(ly.Z,{}),(0,n.jsx)(lk.Z,{})]})]})},lE=s(94137),lI=s(60523),lP=s(8089),lT=s(74221),lZ=s(10929),lA=s(71621),lK=s(78962),lz=s(26072),l_=e=>{let{canvasObject:t,canvasObjectError:s}=(0,lK.Z)({processId:e},{cacheTime:0});if(s||!t)return{...w.B_,processId:e};let{data:{nodes:l,edges:a}}=t,n=l.reduce((e,t)=>
1{if((0,k.JG)(t)&&""!==t.data.who&&!t.id.includes("ghost")){let s=t.data.who.trim(),n=(0,O.xA)(t,l,a).filter(e=>e.type===lz.$.QUESTION);if(0===n.length)return e[s]?e[s]={...e[s],value:e[s].value+1}:e[s]={value:1},e;if(e[s]){if(void 0===e[s].visitedQuestions)return e[s]={...e[s],value:e[s].value+1+n.length,visitedQuestions:n.map(e=>e.id)},e;let t=n.filter(t=>{var l;return!(null===(l=e[s].visitedQuestions)||void 0===l?void 0:l.includes(t.id))});return 0===t.length?e[s]={...e[s],value:e[s].value+1}:e[s]={...e[s],value:e[s].value+1+t.length,visitedQuestions:[...e[s].visitedQuestions,...t.map(e=>e.id)]},e}if(0===n.length)return e[s]={value:1},e;e[s]={value:1+n.length,visitedQuestions:n.map(e=>e.id)}}return e},{}),r=Object.keys(n).reduce((e,t)=>{let s=n[t].value;return void 0===s||s>e.total&&(e.total=s,e.role=t),e},{role:"",total:0}),o=l.reduce((e,t)=>{if((0,k.JG)(t)&&""!==t.data.who){let s=t.data.who.trim(),l=a.filter(e=>e.source===t.id||e.target===t.id).length;e[s]?e[s]+=l:e[s]=l}return e},{}),i=Object.keys(o).reduce((e,t)=>{let s=o[t];return void 0===s||s>e.total&&(e.total=s,e.role=t),e},{role:"",total:0}),d=a.filter(e=>e.type===eZ.r.ANSWER).length,c=l.filter(e=>!e.id.includes("ghost")&&e.type===lz.$.ACTION).length,u=l.filter(e=>!e.id.includes("ghost")&&e.type===lz.$.QUESTION).length;return{processId:e,totalActionNodes:c,totalQuestionNodes:u,totalNodes:c+u,totalEdges:a.length,edgesLength:Math.floor(a.reduce((e,t)=>{let s=document.getElementById(t.id);return s?e+s.getTotalLength():e},0)),uniqueRoles:(0,k.rZ)(l.filter(e=>(0,k.JG)(e)&&e.data.who&&!e.id.includes("ghost")).map(e=>(0,k.JG)(e)&&""!==e.data.who?e.data.who.trim():"")),mostConnectedRole:i,mostPopulatedRole:r,totalAnswerEdges:d}},lL=s(37238),lR=e=>{let{canvasObject:t,canvasObjectError:s}=(0,lK.Z)({processId:e},{cacheTime:0}),[l]=(0,d.KO)(lL.k);if(s||!t)return{...w.Qg,processId:e};let{data:{nodes:a,edges:n}}=t,r=a.filter(e=>(0,k.JG)(e)&&e.data.who.trim()===l),o=r.reduce((e,t)=>{let s=(0,O.xA)(t,a,n).filter(e=>(0,k.hr)(e));if(0===s.length)return e;let l=s.filter(t=>e.every(e=>e.id!==t.id));return 0===l.length?e:e.concat(l)},[]),i=n.filter(e=>e.type===eZ.r.ANSWER&&o.some(t=>t.id===e.source)).length,c=n.filter(e=>e.type===eZ.r.TIME&&r.some(t=>t.id===e.source)).length,u=[...r,...o],x=r.length,h=o.length;return{processId:e,totalActionNodes:x,totalQuestionNodes:h,totalNodes:x+h,totalEdges:c+i,edgesLength:Math.floor(u.reduce((e,t)=>{let s=document.getElementById(t.id);return s?e+s.getTotalLength():e},0)),totalAnswerEdges:i}};let lD={id:"",name:"Select all"},lH=(0,lZ.j)("",{variants:{subtitlesSize:{sm:"min-w-[30%]",md:"min-w-[70%] 2xl:min-w-[75%]",lg:"min-w-[80%]"},size:{sm:"basis-32",md:"basis-64",lg:"basis-72"}},defaultVariants:{subtitlesSize:"sm",size:"md"}});var lF=e=>{var t;let{processId:s,subtitlesSize:l,includesUniqueRoles:a=!0,borderTitle:r=!1,size:o}=e,[u,x]=(0,c.useState)(!1),[h,m]=(0,d.KO)(lL.k),g=(0,p.Z)(),[f]=(0,d.KO)(sf.r),v=lR(s),{isLoading:j,isAvailable:b}=(0,eL.Z)(w.ZA.STATISTICS),N=l_(s);if(j||!b)return null;let y=N.uniqueRoles.map(e=>({name:e,id:e})),O=[lD,...y];return(0,n.jsxs)(lA.Z,{className:(0,tt.cn)("min-h-[10%]","my-4 h-auto",lH({size:o,subtitlesSize:null})),withTitle:r,title:"Statistics overview",children:[!r&&(0,n.jsx)("span",{className:"font-bold text-lg",children:"Statistics overview"}),(0,n.jsxs)("div",{className:"my-2 flex h-full w-full flex-col justify-center gap-1",children:[(0,n.jsxs)(i.J2e,{open:u,onOpenChange:x,children:[(0,n.jsx)(i.xol,{asChild:!0,children:(0,n.jsxs)(i.zxk,{variant:"soft",role:"combobox","aria-expanded":u,className:"w-full justify-between",children:[h?(null===(t=y.find(e=>e.id===h))||void 0===t?void 0:t.name)||"":"Select a role",(0,n.jsx)(ej.P.ChevronsUpDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),(0,n.jsx)(i.yky,{className:"w-full bg-white p-0 dark:bg-slate-800",children:(0,n.jsxs)(i.mYg,{children:[(0,n.jsx)(i.sZt,{placeholder:"Search a role",className:"h-9"}),(0,n.jsx)(i.rb5,{children:"No roles found."}),(0,n.jsx)(i.e8h,{children:(0,n.jsx)(i.fuJ,{className:O.length>4?"h-36 overflow-y-scroll":"",children:O.map(e=>{let{name:t,id:s}=e;return(0,n.jsxs)(i.diK,{onSelect:e=>{m(e===h?"":s),x(!1)},children:[(0,k.$G)(t,20),(0,n.jsx)(ej.P.CheckIcon,{className:(0,tt.cn)("ml-auto h-4 w-4",h===s?"opacity-100":"opacity-0")})]},s)})})})]})})]}),(0,n.jsxs)("div",{className:"mx-1 flex flex-row items-center justify-between",children:[(0,n.jsx)("span",{className:(0,tt.cn)("truncate font-bold text-sm",lH({subtitlesSize:l,size:null})),children:"Total Action Nodes:"}),(0,n.jsx)("span",{className:"mx-1 text-right",children:""===h?N.totalActionNodes:v.totalActionNodes})]}),(0,n.jsxs)("div",{className:"mx-1 flex flex-row items-center justify-between",children:[(0,n.jsx)("span",{className:(0,tt.cn)("truncate font-bold text-sm",lH({subtitlesSize:l,size:null})),children:"Total Question Nodes:"}),(0,n.jsx)("span",{className:"mx-1 text-right",children:""===h?N.totalQuestionNodes:v.totalQuestionNodes})]}),(0,n.jsxs)("div",{className:"mx-1 flex flex-row items-center justify-between",children:[(0,n.jsx)("span",{className:(0,tt.cn)("truncate font-bold text-sm",lH({subtitlesSize:l,size:null})),children:"Total Nodes:"}),(0,n.jsx)("span",{className:"mx-1 text-right",children:""===h?N.totalNodes:v.totalNodes})]}),(0,n.jsxs)("div",{className:"mx-1 flex flex-row items-center justify-between",children:[(0,n.jsx)("span",{className:(0,tt.cn)("truncate font-bold text-sm",lH({subtitlesSize:l,size:null})),children:"Connections:"}),(0,n.jsx)("span",{className:"mx-1 text-right",children:""===h?N.totalEdges:v.totalEdges})]}),(0,n.jsxs)("div",{className:"mx-1 flex flex-row items-center justify-between",children:[(0,n.jsx)("span",{className:(0,tt.cn)("truncate font-bold text-sm",lH({subtitlesSize:l,size:null})),children:"Total Answer connections:"}),(0,n.jsx)("span",{className:"mx-1 text-right",children:""===h?N.totalAnswerEdges:v.totalAnswerEdges})]}),""===h&&(0,n.jsxs)("div",{className:"mx-1 flex flex-row items-center justify-between",children:[(0,n.jsx)("span",{className:(0,tt.cn)("truncate font-bold text-sm",lH({subtitlesSize:l,size:null})),children:"Most connected role:"}),""!==N.mostConnectedRole.role?(0,n.jsx)("span",{className:"mx-1 ",children:(0,n.jsx)(tl.Z,{className:"text-center",text:"Role ".concat(N.mostConnectedRole.role," has the most connections in the process with a total of ").concat(N.mostConnectedRole.total," connections"),children:(0,n.jsxs)(i.Cts,{className:"m-[0.15rem] line-clamp-1 h-fit w-auto text-right",children:[N.mostConnectedRole.role,":",N.mostConnectedRole.total]})})}):null]}),""===h&&(0,n.jsxs)("div",{className:"mx-1 flex flex-row items-center justify-between",children:[(0,n.jsx)("span",{className:(0,tt.cn)("truncate font-bold text-sm",lH({subtitlesSize:l,size:null})),children:"Most populated role:"}),""!==N.mostPopulatedRole.role?(0,n.jsx)("span",{className:"mx-1 ",children:(0,n.jsx)(tl.Z,{className:"text-center",text:"Role ".concat(N.mostPopulatedRole.role," has the most amount of nodes in the process with a total of ").concat(N.mostPopulatedRole.total," nodes"),children:(0,n.jsxs)(i.Cts,{className:"m-[0.15rem] line-clamp-1 h-fit w-auto text-right",children:[N.mostPopulatedRole.role,":",N.mostPopulatedRole.total]})})}):null]}),"format"===g&&f?(0,n.jsxs)("div",{className:"mx-1 flex flex-row items-center justify-between",children:[(0,n.jsx)("span",{className:(0,tt.cn)("truncate font-bold text-sm",lH({subtitlesSize:l,size:null})),children:"Length:"}),(0,n.jsx)("span",{className:"mx-1 text-right",children:""===h?N.edgesLength:v.edgesLength})]}):null,a&&""===h?(0,n.jsxs)("div",{className:(0,tt.cn)("mx-1 flex flex-row items-start"),children:[(0,n.jsx)("span",{className:(0,tt.cn)("flex-1 truncate font-bold text-sm",lH({subtitlesSize:l,size:null})),children:"Unique Roles:"}),(0,n.jsx)("div",{className:"flex max-w-md flex-wrap justify-end 2xl:max-w-lg",children:N.uniqueRoles.map(e=>(0,n.jsx)(i.Cts,{className:"m-[0.15rem] line-clamp-1 h-fit w-auto px-1",children:e},e))})]}):null]})]})},lW=()=>{let e=(0,m.Z)("processId"),t=(0,p.Z)(),[s]=(0,d.KO)(r.Ir),[,l]=(0,d.KO)(r.$X),[,a]=(0,d.KO)(r.NR),[,i]=(0,d.KO)(r.mi),{teamId:u}=(0,lE.Z)(),{lastOpenedProject:x}=(0,ty.Z)(),{project:h}=(0,lP.Z)({projectId:s,enabled:""!==s}),{processes:g,processesLoading:f,isError:v}=(0,lI.Z)({projectId:s,teamId:null!=u?u:void 0,enabled:""!==s}),j=t=>e===t?"text-green-700 underline font-bold stroke-green-700 stroke-[0.2rem]":"",w=(0,c.useCallback)(()=>{a([]),l({subgroupId:"",selectedNodesIds:[""]}),i(0),""!==s&&x({id:s})},[s,x,a,i,l]),b=(0,c.useCallback)(e=>{let{processId:t,projectId:s,isOwner:l}=e,a=null==h?void 0:h.teamId;return a?"/team/".concat(a,"/projects/").concat(s,"/processes/").concat(t,"?flow=").concat(l?"capture":"read-only"," "):"/projects/".concat(s,"/processes/").concat(t,"?flow=").concat(l?"capture":"read-only"," ")},[h]);return f?(0,n.jsxs)("div",{className:"hidden h-full basis-64 flex-col justify-between gap-2 md:flex",children:[(0,n.jsxs)("div",{className:"flex h-full w-full flex-col gap-2 overflow-x-clip",children:[(0,n.jsx)(lS,{}),(0,n.jsxs)("ul",{className:"flex h-full max-h-[75vh] w-full flex-col gap-1 overflow-x-clip pl-3",children:[Array.from({length:5}).map((e,t)=>(0,n.jsx)(o.OdW,{className:"h-6 w-40"},"".concat(t,"-skeleton-sidebar"))),(0,n.jsx)(o.OdW,{className:"h-8 w-48 rounded-full"})]})]}),(0,n.jsx)("div",{className:"h-auto w-full",children:"format"===t?(0,n.jsx)(lf,{className:"mt-3 w-full max-w-full"}):null})]}):v?(0,n.jsxs)("div",{className:"hidden h-full basis-64 flex-col justify-between gap-2 md:flex",children:[(0,n.jsxs)("div",{className:"flex h-full w-full flex-col gap-2 overflow-x-clip",children:[(0,n.jsx)(lS,{}),(0,n.jsxs)("ul",{className:"flex h-full max-h-[75vh] w-full flex-col gap-1 overflow-x-clip pl-3",children:[(0,n.jsx)("span",{children:"Something went wrong"}),(0,n.jsx)(o.OdW,{className:"h-8 w-48 rounded-full"})]})]}),(0,n.jsx)("div",{className:"h-auto w-full",children:"format"===t?(0,n.jsx)(lf,{className:"mt-3 w-full max-w-full"}):null})]}):(0,n.jsxs)("div",{className:"hidden h-full basis-64 flex-col justify-between gap-2 md:flex",children:[(0,n.jsxs)("div",{className:"flex h-full w-full flex-col gap-2 overflow-x-clip overflow-y-scroll",children:[(0,n.jsx)(lS,{}),(0,n.jsxs)("ul",{className:"flex h-full max-h-[75vh] w-full flex-col gap-1 overflow-x-clip pl-3",children:[g.map(e=>(0,n.jsx)("li",{className:"flex list-none flex-row justify-items-center gap-2 font-medium",children:(0,n.jsx)(lw(),{href:b({projectId:e.projectId,processId:e.id,isOwner:e.isCurrentUserOwner}),className:"text-start",onClick:w,children:(0,n.jsx)(tl.Z,{text:e.title,children:(0,n.jsxs)("span",{className:(0,o.cn)("flex flex-row items-start gap-2 truncate","hover:cursor-pointer hover:text-green-700 hover:underline",j(e.id)),children:[(0,n.jsx)(o.PJP.CornerDownRight,{className:(0,o.cn)("h-4 w-4",j(e.id))}),e.title]})})})},e.id)),(0,n.jsx)(lT.Z,{})]})]}),(0,n.jsxs)("div",{className:"h-auto w-full",children:[(0,n.jsx)(lF,{processId:e,includesUniqueRoles:!1,subtitlesSize:"sm",borderTitle:!0,size:"sm"}),"format"===t?(0,n.jsx)(lf,{className:"mt-3 w-full max-w-full"}):null]})]})},lG=()=>{var e,t,s;let[l,a]=(0,c.useState)(!1),x=(0,m.Z)("projectId"),j=(0,c.useRef)(null),w=(0,p.Z)(),b=(0,m.Z)("processId"),[,N]=(0,d.KO)(r.lT),{process:y,processIsLoading:k,processError:O}=(0,v.Z)({processId:b}),[C,S]=(0,c.useState)(y),[,E]=(0,d.KO)(r.WV),[,I]=(0,d.KO)(r.eU);C!==y&&(S(y),I(null!==(e=null==y?void 0:y.showVisualIndicatorsForNotes)&&void 0!==e&&e),E(null!==(t=null==y?void 0:y.showAllFocalPoints)&&void 0!==t&&t));let P=(0,g.a)("(min-width: 768px)");return((0,f.Z)(),N(b),k)?(0,n.jsx)(u.Z,{}):y?O?(0,n.jsx)("span",{children:"Something went wrong"}):(P||null===(s=j.current)||void 0===s||s.collapse(),y.isSuperAdminAccess)?(0,n.jsx)("div",{className:"flex h-full flex-col",children:(0,n.jsx)(ld,{},b)}):(0,n.jsxs)("div",{className:"flex h-full flex-col",children:[(0,n.jsxs)(i.pOf,{direction:"horizontal",className:(0,o.cn)("flex h-full flex-row",l?"gap-1 py-3 pr-3":"gap-2 p-3"),children:[(0,n.jsx)(i.eeb,{defaultSize:12,maxSize:20,minSize:0,collapsible:!0,collapsedSize:0,onCollapse:()=>a(!0),onExpand:()=>a(!1),ref:j,children:(0,n.jsx)(lW,{},x)}),(0,n.jsx)(i.Dp3,{withHandle:!0,panelRef:j}),(0,n.jsx)(i.eeb,{className:"flex h-full flex-row rounded-lg border-2 border-gray-200 dark:border-gray-700",children:(0,n.jsx)(ld,{},b)})]}),(null==y?void 0:y.isCurrentUserOwner)===!0&&("capture"===w||"timeline"===w)?(0,n.jsx)(lv,{}):null]}):(0,n.jsx)(h,{})}},875:function(e,t,s){var l=s(76690);t.Z=(e,t)=>{let{isLoading:s,data:a,isError:n}=l.S.export.get.useQuery(e,t);return{isLoading:s,data:a,isError:n}}},66158:function(e,t,s){var l=s(76690);t.Z=()=>({generateProjectScaffolding:l.S.jiraIntegration.generateProjectScaffolding.useMutation(),handleJiraOauth:l.S.jiraIntegration.handleJiraOauth.useMutation()})}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.