@pickaxeproject/react 5.0.0 → 5.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{jsxs as e,jsx as s,Fragment as i}from"react/jsx-runtime";import{useMemo as t}from"react";import{usePickaxeContext as a}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as o}from"../../Addons/Auth/hooks/useAuthContext.js";import{useAuth as l}from"../../Addons/Auth/hooks/useAuth.js";import{useResponseContext as n}from"../../../../hooks/pickaxe/useResponseContext.js";import{useDimensionContext as r}from"../../../../hooks/pickaxe/useDimensionContext.js";import{useScrollContext as c}from"../../Addons/Scroll/hooks/useScrollContext.js";import{useStyleFontSize as m}from"../../../../hooks/studio/useStyleFontSize.js";import{useConversation as d}from"../../../../hooks/pickaxe/useConversation.js";import{useArtifactContext as p}from"../../Addons/Artifact/hooks/useArtifactContext.js";import{AnimatePresence as u,motion as h}from"framer-motion";import f from"../../../Icons/lock.svg.js";import g from"../../../Core/ErrorAlert.js";import x from"../../common/PickaxeHead.js";import j from"../../common/PickaxeEmbedHead.js";import b from"../../common/PickaxeUpgradeCard.js";import v from"../../common/PickaxeSkeleton.js";import y from"../../common/PickaxeHistoryButton.js";import k from"../../Addons/Scroll/ScrollLockView.js";import w from"../../Addons/Artifact/Renderer/index.js";import N from"./Message.js";import O from"./CustomMessage.js";import C from"../../Addons/IceBreaker/index.js";import S from"../../common/PickaxeBranding.js";import A from"../../../../common/cn.js";const P=({additionalScrollHeight:P,smitheryAuthData:I,isForceHideInfo:L,isInputFocused:H,onSubmit:R,resubmitPrompt:B})=>{var D,E,T,$,z;const{sessionId:F,deploymentType:M,pickaxe:W,translations:U,misc:V,isNewChat:_,isRtl:q,isEmbed:G,isEmailLogin:J,isShowIceBreaker:K,setSessionId:Q,setLastSessionId:X}=a(),{emailInput:Y,isLoggedOut:Z,isSending:ee,isResendDisabled:se,isSent:ie}=o(),{onSend:te}=l(),{scrollContainerRef:ae}=c(),{messages:oe,limitData:le,error:ne}=n(),{height:re,width:ce}=r(),{currentArtifact:me,chatPopupType:de,currentPopupType:pe}=p(),ue=d(),he=m(),fe=t((()=>(null==W?void 0:W.icebreakers)?W.icebreakers.slice(0,3):[]),[null==W?void 0:W.icebreakers]),ge=t((()=>{const e=!!ue.data&&ue.data.messages.length>1;return!L&&ue.isSuccess&&_&&!e}),[L,ue.isSuccess,_,ue.data]),xe=t((()=>!(null==W?void 0:W.chatflag)&&(null==W?void 0:W.enablechatresponses)&&oe.length>0),[W,oe]),je=t((()=>!!ue.data&&ue.data.messages.some((e=>"intromessage"===e.area))),[ue.data]),be="chat-input"===M&&J&&Z&&ie,ve=K&&!H&&!je&&ge&&ce>767,ye=K&&!H&&(je||ce<=767),ke=()=>{X(F),Q("")};return e("div",Object.assign({ref:ae,className:"flex w-full flex-col items-center overflow-y-auto mb-12 pb-4 scrollbar scrollbar-thin",style:{height:`calc(${re}px - 74px)`,paddingBottom:`${P+32}px`}},{children:[s(u,{children:!!me&&"inline"===pe&&s(h.div,Object.assign({className:A("absolute top-0 z-20 w-full px-4 py-2",de),style:{height:`calc(${re-P}px - 80px)`},initial:{opacity:0,y:-20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,ease:"easeOut"}},{children:s(w,{type:"inline",className:"pxe-artifact-inline h-full shadow",artifact:{id:me.id,version:me.version}})}))}),e("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px]"},{children:[ge&&G&&s("div",Object.assign({className:A("absolute right-4 top-3 flex items-center gap-2","popup"===M&&"right-12")},{children:s(y,{tip:(null==U?void 0:U["chat-history"])||"Chat History",onClick:ke})})),s(x,Object.assign({className:A("opacity-0 mt-[0%] transition-all duration-500 ease-in-out max-h-0 overflow-hidden max-w-[500px]",ge&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxDescriptionChars:500},!be&&{onIconClick:ke})),G&&!ue.isLoading&&s(j,Object.assign({className:A("opacity-0 transition-all duration-500 ease-in-out h-0 w-full sticky top-0 z-10",!ge&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",historyBtnTip:(null==U?void 0:U["chat-history"])||"Chat History"},!be&&{onIconClick:ke,onHistoryClick:ke})),e("div",Object.assign({className:A("flex flex-col flex-grow mt-6 transition-all duration-300 ease-in-out w-full px-4",G&&!ue.isLoading&&!ge&&"mt-0")},{children:[ve&&s("div",Object.assign({className:A("grid grid-cols-3 gap-4",2===fe.length&&"grid-cols-2",1===fe.length&&"grid-cols-1")},{children:s(C,{type:"center",data:fe,onSend:R})})),be?s("div",Object.assign({className:"flex flex-col w-full"},{children:e("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[s(O,Object.assign({chatRole:"user"},{children:e("div",Object.assign({className:"flex items-center gap-x-3"},{children:[s(f,{className:"h-6 w-6 shrink-0"}),s("p",Object.assign({className:"font-semilight"},{children:Y}))]}))})),s(O,Object.assign({chatRole:"assistant"},{children:e("p",Object.assign({className:"py-3 font-semilight"},{children:[`${null!==(T=null==U?void 0:U["we-sent-your-an-activation-link"])&&void 0!==T?T:"We sent you an activation link. Please be sure to check your spam folder too."} `,s("span",Object.assign({className:"underline underline-offset-2 cursor-pointer",onClick:()=>{se||ee||te(!0)}},{children:ee?null!==($=null==U?void 0:U.resending)&&void 0!==$?$:"Resending...":null!==(z=null==U?void 0:U.resend)&&void 0!==z?z:"Resend"}))]}))}))]}))})):s(i,{children:ue.isLoading&&!(null==W?void 0:W.enablechatresponses)?e("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[_&&e("div",Object.assign({className:"flex flex-col items-center w-full"},{children:[s(v,{className:"w-[72px] h-[72px]"}),s(v,{className:"h-[20px] mt-6 w-full"}),s(v,{className:"h-[20px] mt-2 w-full"}),s(v,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]})),s(v,{className:"h-10 w-[70%] animate-pulse justify-self-end rounded"}),s(v,{className:"h-[150px] w-[70%] animate-pulse rounded"}),s(v,{className:"h-10 w-[50%] animate-pulse justify-self-end rounded"})]})):ue.isError?s("div",Object.assign({className:"flex w-full justify-center"},{children:e("p",Object.assign({className:A(he.b2,"text-center font-semibold")},{children:["Something went wrong. Please try again, or"," ",s("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:"contact us"}))," ","for help."]}))})):ue.data||xe?e("div",Object.assign({className:"flex flex-col w-full flex-grow justify-between"},{children:[e("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[(null!==(E=null===(D=ue.data)||void 0===D?void 0:D.messages)&&void 0!==E?E:[]).map(((e,i)=>s(N,{index:i,message:e},i))),oe.map(((e,i)=>{var t,a;return s(N,{smitheryData:I,resubmitPrompt:B,index:(null!==(a=null===(t=ue.data)||void 0===t?void 0:t.messages.length)&&void 0!==a?a:0)+i,message:e,isLastMessage:i===oe.length-1},i)})),le?s("div",Object.assign({className:"flex max-w-[80%] items-center gap-x-3"},{children:s(b,{})})):ne?s("div",Object.assign({className:A("flex items-center gap-x-3",q?"justify-end":"justify-start")},{children:s(g,{error:ne})})):null]})),e("div",Object.assign({className:A("flex flex-col",!V.isWhiteLabel||ye&&"mt-4")},{children:[!V.isWhiteLabel&&s(S,{containerClassName:A("justify-end",ye&&"mb-2")}),ye&&s("div",Object.assign({className:"flex flex-col items-end gap-2"},{children:s(C,{type:"right",data:fe,onSend:R})})),s(k,{})]}))]})):null})]}))]}))]}))};export{P as default};
1
+ import{jsxs as e,jsx as s,Fragment as i}from"react/jsx-runtime";import{useMemo as t,useEffect as a}from"react";import{usePickaxeContext as o}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as n}from"../../Addons/Auth/hooks/useAuthContext.js";import{useAuth as l}from"../../Addons/Auth/hooks/useAuth.js";import{useResponseContext as r}from"../../../../hooks/pickaxe/useResponseContext.js";import{useDimensionContext as c}from"../../../../hooks/pickaxe/useDimensionContext.js";import{useScrollContext as m}from"../../Addons/Scroll/hooks/useScrollContext.js";import{useStyleFontSize as d}from"../../../../hooks/studio/useStyleFontSize.js";import{useConversation as p}from"../../../../hooks/pickaxe/useConversation.js";import{useArtifactContext as u}from"../../Addons/Artifact/hooks/useArtifactContext.js";import{AnimatePresence as h,motion as f}from"framer-motion";import g from"../../../Icons/lock.svg.js";import x from"../../../Core/ErrorAlert.js";import j from"../../common/PickaxeHead.js";import b from"../../common/PickaxeEmbedHead.js";import v from"../../common/PickaxeUpgradeCard.js";import y from"../../common/PickaxeSkeleton.js";import k from"../../common/PickaxeHistoryButton.js";import w from"../../Addons/Scroll/ScrollLockView.js";import N from"../../Addons/Artifact/Renderer/index.js";import O from"./Message.js";import C from"./CustomMessage.js";import S from"../../Addons/IceBreaker/index.js";import A from"../../common/PickaxeBranding.js";import P from"../../../../common/cn.js";const I=({additionalScrollHeight:I,smitheryAuthData:H,isForceHideInfo:L,isInputFocused:R,onSubmit:D,resubmitPrompt:B})=>{var E,T,F,z,M;const{sessionId:W,deploymentType:$,pickaxe:q,translations:U,misc:V,isNewChat:_,isRtl:G,isEmbed:J,isEmailLogin:K,isShowIceBreaker:Q,setSessionId:X,setLastSessionId:Y}=o(),{emailInput:Z,isLoggedOut:ee,isSending:se,isResendDisabled:ie,isSent:te}=n(),{onSend:ae}=l(),{scrollContainerRef:oe}=m(),{messages:ne,limitData:le,error:re}=r(),{height:ce,width:me}=c(),{currentArtifact:de,chatPopupType:pe,currentPopupType:ue}=u(),he=p(),fe=d(),ge=t((()=>(null==q?void 0:q.icebreakers)?q.icebreakers.slice(0,3):[]),[null==q?void 0:q.icebreakers]),xe=t((()=>{const e=!!he.data&&he.data.messages.length>1;return!L&&he.isSuccess&&_&&!e}),[L,he.isSuccess,_,he.data]),je=t((()=>!(null==q?void 0:q.chatflag)&&(null==q?void 0:q.enablechatresponses)&&ne.length>0),[q,ne]),be=t((()=>!!he.data&&he.data.messages.some((e=>"intromessage"===e.area))),[he.data]),ve="chat-input"===$&&K&&ee&&te,ye=Q&&!R&&!be&&xe&&me>767,ke=Q&&!R&&(be||me<=767),we=()=>{Y(W),X("")};return a((()=>{oe.current&&requestAnimationFrame((()=>{oe.current&&(oe.current.scrollTop=oe.current.scrollHeight)}))}),[I,oe]),e("div",Object.assign({ref:oe,className:"flex flex-1 w-full flex-col items-center overflow-y-auto pb-4 scrollbar scrollbar-thin min-h-0 mb-4"},{children:[s(h,{children:!!de&&"inline"===ue&&s(f.div,Object.assign({className:P("absolute top-0 z-20 w-full px-4 py-2",pe),style:{height:`calc(${ce-I}px - 80px)`},initial:{opacity:0,y:-20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,ease:"easeOut"}},{children:s(N,{type:"inline",className:"pxe-artifact-inline h-full shadow",artifact:{id:de.id,version:de.version}})}))}),e("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px]"},{children:[xe&&J&&s("div",Object.assign({className:P("absolute right-4 top-3 flex items-center gap-2","popup"===$&&"right-12")},{children:s(k,{tip:(null==U?void 0:U["chat-history"])||"Chat History",onClick:we})})),s(j,Object.assign({className:P("opacity-0 mt-[0%] transition-all duration-500 ease-in-out max-h-0 overflow-hidden max-w-[500px]",xe&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxDescriptionChars:500},!ve&&{onIconClick:we})),J&&!he.isLoading&&s(b,Object.assign({className:P("opacity-0 transition-all duration-500 ease-in-out h-0 w-full sticky top-0 z-10",!xe&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",historyBtnTip:(null==U?void 0:U["chat-history"])||"Chat History"},!ve&&{onIconClick:we,onHistoryClick:we})),e("div",Object.assign({className:P("flex flex-col flex-grow mt-6 transition-all duration-300 ease-in-out w-full px-4",J&&!he.isLoading&&!xe&&"mt-0")},{children:[ye&&s("div",Object.assign({className:P("grid grid-cols-3 gap-4",2===ge.length&&"grid-cols-2",1===ge.length&&"grid-cols-1")},{children:s(S,{type:"center",data:ge,onSend:D})})),ve?s("div",Object.assign({className:"flex flex-col w-full"},{children:e("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[s(C,Object.assign({chatRole:"user"},{children:e("div",Object.assign({className:"flex items-center gap-x-3"},{children:[s(g,{className:"h-6 w-6 shrink-0"}),s("p",Object.assign({className:"font-semilight"},{children:Z}))]}))})),s(C,Object.assign({chatRole:"assistant"},{children:e("p",Object.assign({className:"py-3 font-semilight"},{children:[`${null!==(F=null==U?void 0:U["we-sent-your-an-activation-link"])&&void 0!==F?F:"We sent you an activation link. Please be sure to check your spam folder too."} `,s("span",Object.assign({className:"underline underline-offset-2 cursor-pointer",onClick:()=>{ie||se||ae(!0)}},{children:se?null!==(z=null==U?void 0:U.resending)&&void 0!==z?z:"Resending...":null!==(M=null==U?void 0:U.resend)&&void 0!==M?M:"Resend"}))]}))}))]}))})):s(i,{children:he.isLoading&&!(null==q?void 0:q.enablechatresponses)?e("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[_&&e("div",Object.assign({className:"flex flex-col items-center w-full"},{children:[s(y,{className:"w-[72px] h-[72px]"}),s(y,{className:"h-[20px] mt-6 w-full"}),s(y,{className:"h-[20px] mt-2 w-full"}),s(y,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]})),s(y,{className:"h-10 w-[70%] animate-pulse justify-self-end rounded"}),s(y,{className:"h-[150px] w-[70%] animate-pulse rounded"}),s(y,{className:"h-10 w-[50%] animate-pulse justify-self-end rounded"})]})):he.isError?s("div",Object.assign({className:"flex w-full justify-center"},{children:e("p",Object.assign({className:P(fe.b2,"text-center font-semibold")},{children:["Something went wrong. Please try again, or"," ",s("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:"contact us"}))," ","for help."]}))})):he.data||je?e("div",Object.assign({className:"flex flex-col w-full flex-grow justify-between"},{children:[e("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[(null!==(T=null===(E=he.data)||void 0===E?void 0:E.messages)&&void 0!==T?T:[]).map(((e,i)=>s(O,{index:i,message:e},i))),ne.map(((e,i)=>{var t,a;return s(O,{smitheryData:H,resubmitPrompt:B,index:(null!==(a=null===(t=he.data)||void 0===t?void 0:t.messages.length)&&void 0!==a?a:0)+i,message:e,isLastMessage:i===ne.length-1},i)})),le?s("div",Object.assign({className:"flex max-w-[80%] items-center gap-x-3"},{children:s(v,{})})):re?s("div",Object.assign({className:P("flex items-center gap-x-3",G?"justify-end":"justify-start")},{children:s(x,{error:re})})):null]})),e("div",Object.assign({className:P("flex flex-col",!V.isWhiteLabel||ke&&"mt-4")},{children:[!V.isWhiteLabel&&s(A,{containerClassName:P("justify-end",ke&&"mb-2")}),ke&&s("div",Object.assign({className:"flex flex-col items-end gap-2"},{children:s(S,{type:"right",data:ge,onSend:D})})),s(w,{})]}))]})):null})]}))]}))]}))};export{I as default};
@@ -1 +1 @@
1
- import{__rest as e,__awaiter as t}from"../../../_virtual/_tslib.js";import{jsx as n,jsxs as s,Fragment as o}from"react/jsx-runtime";import{forwardRef as r,useState as i,useRef as a,useMemo as l,useImperativeHandle as c,useEffect as d}from"react";import"../../../node_modules/.pnpm/regenerator-runtime@0.14.1/node_modules/regenerator-runtime/runtime.js";import u,{useSpeechRecognition as m}from"react-speech-recognition";import{usePickaxeContext as p}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as f}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as g}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as h}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as v}from"../../../hooks/pickaxe/useConversation.js";import{useDimensionContext as b}from"../../../hooks/pickaxe/useDimensionContext.js";import{useAuthContext as y}from"../Addons/Auth/hooks/useAuthContext.js";import{useDocument as j}from"../Addons/Document/hooks/useDocument.js";import{useScroll as x}from"../Addons/Scroll/hooks/useScroll.js";import{useArtifactContext as O}from"../Addons/Artifact/hooks/useArtifactContext.js";import{useHover as w}from"../../../hooks/core/useHover.js";import{useMediaQuery as k}from"../../../hooks/core/useMediaQuery.js";import{allowedFileMimeTypes as S,allowedImageMimeTypes as C,additionalAllowedFileExtensions as N}from"../../../common/documents.js";import{createParser as I}from"eventsource-parser";import E from"../../Icons/attach-vertical.svg.js";import A from"../../Icons/arrow-right.svg.js";import T from"../../Icons/microphone.svg.js";import _ from"../../Icons/stop.svg.js";import P from"../Addons/Document/List.js";import D from"../../Core/Textarea.js";import R from"../../Core/ErrorAlert.js";import L from"../../../common/error.js";import $ from"../../../common/cn.js";const W=r((({resubmitPrompt:r,onFocus:W,onBlur:B,onInputHeightChange:H,initSmitheryAuthData:F},J)=>{var U,K,M;const{origin:X,pickaxeId:z,sessionId:V,sender:q,senderType:G,deploymentId:Q,deploymentType:Y,pickaxe:Z,styles:ee,colors:te,locale:ne,forceMobile:se,isNewChat:oe,isRtl:re,isEmailLogin:ie,isShowFeedbackMessage:ae,setIsNewChat:le,setIsShowIceBreaker:ce,onGenerateComplete:de}=p(),{token:ue,isLoggedOut:me,isSent:pe}=y(),{messages:fe,limits:ge,isGenerating:he,setMessages:ve,setStatus:be,setLimitData:ye,setError:je}=f(),{documents:xe,isUploading:Oe,documentError:we,onFileUpload:ke,setDocuments:Se,setDocumentError:Ce}=j(),{scrollStartSession:Ne,scrollEndSession:Ie,scrollToBottom:Ee}=x({auto:!0}),{artifacts:Ae,currentPopupType:Te,setArtifacts:_e,setCurrentArtifact:Pe}=O(),{height:De}=b(),Re=v(),[Le,$e]=i(""),[We,Be]=i(!1),[He,Fe]=i(!1),Je=a(null),Ue=a(""),Ke=a(null),Me=a(null),Xe=a(null),ze=a(null),Ve=a(null),qe=Math.max(.2*De,100),{transcript:Ge,listening:Qe,resetTranscript:Ye,browserSupportsSpeechRecognition:Ze}=m(),[et]=k("(max-width: 480px)"),tt=w(),{isHover:nt}=tt,st=e(tt,["isHover"]),ot=w(),{isHover:rt}=ot,it=e(ot,["isHover"]),at=w(),{isHover:lt}=at,ct=e(at,["isHover"]),[dt,ut]=i(!1),mt=h(),pt=g(),ft=null===(U=null==Z?void 0:Z.documentuploadtype)||void 0===U?void 0:U.startsWith("enduserupload"),gt=Ze&&(null==Z?void 0:Z.enablevoicetotext),ht="chat-input"===Y&&oe&&!pe,vt="chat-input"===Y&&ie&&me&&pe,bt=We||He,yt=l((()=>{var e,t,n;return!!oe&&(!!Z&&(!Re.isLoading&&(!((null!==(t=null===(e=Re.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(n=Z.icebreakers)||void 0===n?void 0:n.length)&&(!ae&&!ht)))))}),[Z,oe,ae,ht,Re.data,Re.isLoading]),jt=l((()=>{if(he||Oe)return!1;const e=xe.length>0&&xe.every((e=>"finished"===e.status));return!(!Le.trim()&&!e)&&xe.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[he,Oe,Le,xe]);c(J,(()=>({onSubmit:xt}))),d((()=>{ce(yt)}),[yt]),d((()=>{var e;if(r){const t=Array.from(fe),n=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;xt(n,!0)}}),[r]),d((()=>{if(!ze.current||!H)return;const e=new ResizeObserver((e=>{for(const t of e)H(t.contentRect.height)}));return e.observe(ze.current),()=>{e.disconnect()}}),[H]),d((()=>{if(!Qe)return;const e=Ue.current?`${Ue.current} `:"";$e(`${e}${Ge}`)}),[Ge,Qe]),d((()=>{if(!Me.current)return;(()=>{if(!Me.current)return;let e=Me.current.scrollHeight>52;Le.includes("\n")||xe.length?e=!0:Le.trim()||(e=!1),Be(e)})()}),[Le,xe]),d((()=>{const e=Me.current,t=Xe.current;if(!e||!t||We||Le.includes("\n"))return void Fe(!1);const n=window.getComputedStyle(e),s=`${n.fontStyle} ${n.fontVariant} ${n.fontWeight} ${n.fontSize} / ${n.lineHeight} ${n.fontFamily}`,o=document.createElement("span");Object.assign(o.style,{font:s,letterSpacing:n.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),o.textContent=Le,document.body.appendChild(o);const r=o.offsetWidth;o.remove();const i=parseFloat(n.paddingLeft)||0,a=parseFloat(n.paddingRight)||0,l=e.clientWidth-i-a-t.offsetWidth;Fe(r>l)}),[Le,We]);const xt=(e,n=!1)=>t(void 0,void 0,void 0,(function*(){var t,s,o;try{if(he||Oe)return;const r=xe.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)).map((e=>e.documentId)).filter(Boolean),i=r.length>0,a=null!=e?e:Le;if(!a&&!i)return;je(""),Ce(""),ye(null),$e(""),le(!1),be("fetching"),Ne(),Ee();const l=null!==(s=null===(t=null==Z?void 0:Z.documentuploadtype)||void 0===t?void 0:t.startsWith("enduserupload"))&&void 0!==s&&s&&r.length>0,c=[...n?Array.from(fe.slice(0,fe.length-1)):Array.from(fe),...n?[]:[{id:fe.length+1,role:"user",parts:[{type:"text",content:a,isVisible:!0}],documentIds:l?r:[]}],{id:fe.length+(n?0:2),role:"assistant",parts:[],documentIds:[]}];ve(c),Ee(),l&&Se([]);const d=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,{method:"POST",headers:Object.assign({"Content-Type":"application/json"},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}),body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign({origin:X,pickaxeId:z,sessionId:V,senderType:G,value:a},l&&{documentIds:r}),q&&{sender:q}),ue&&{studioSessionToken:ue}),Q&&{deploymentId:Q}))}),u=yield d.json();if(console.log("SubmitData: ",u),!u.success)throw new Error(u.error||"Failed to start generation");const m=u.submissionId;be("streaming"),Ve.current=new AbortController;const p=c.length-1,f=[];let g=[...null!=Ae?Ae:[]],h=0,v=!1,b="";for(;!v;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${m}?index=${h}`,{signal:null===(o=Ve.current)||void 0===o?void 0:o.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();Ke.current=t;const n=new TextDecoder,s=I({onEvent:e=>{var t,n;if(e.event&&"ping"!==e.event&&h++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data);return je(t.error||"Something went wrong."),void(v=!0)}if("delta"===e.event){const s=JSON.parse(e.data);if("data-error"===s.type&&F){const e=s.data.error;if("string"==typeof e){if(/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e)){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&n&&n[1]&&s&&s[1])throw v=!0,F({smitheryId:t[1],serverId:n[1],name:s[1]}),new Error("STOP_STREAM")}}else if("object"==typeof e&&null!==e){const t=e;if("unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name)throw v=!0,F({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===s.type)b="",f.push({type:"text",content:"",isVisible:null===(t=s.isVisible)||void 0===t||t});else if("text-delta"===s.type)b+=s.delta,f[f.length-1].content=b;else if("text-end"===s.type)b="";else if("reasoning-start"===s.type)b="",f.push({type:"reasoning",content:"",isVisible:null===(n=s.isVisible)||void 0===n||n});else if("reasoning-delta"===s.type)b+=s.delta,f[f.length-1].content=b;else if("reasoning-end"===s.type)b="";else if(s.type.startsWith("data-")){const e=s;f.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}ve([...c.slice(0,p),Object.assign(Object.assign({},c[c.length-1]),{id:fe.length+1,role:"assistant",parts:f})])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);g=g.filter((e=>!(e.id===t.id&&e.version===t.version))),g.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),_e([...g]),Te.startsWith("inline")||Pe({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);g=g.filter((e=>!(e.id===t.id&&e.version===t.version))),g.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),_e(g),Te.startsWith("inline")||Pe({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);g=g.filter((e=>!(e.id===t.id&&e.version===t.version))),g.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),_e(g),Te.startsWith("inline")||Pe({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),n=t.token.replace(/\u200B/g,"");g=g.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+n,status:"streaming"}):e)),_e(g)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);_e(g.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const t=JSON.parse(e.data);je(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(v=!0)}else v=!0}});for(;;){const{value:e,done:o}=yield t.read();if(o)break;s.feed(n.decode(e))}v||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||"AbortError"===e.name)return void(v=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==de||de(V)}catch(e){let t=L(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later.");const n=Object.entries(ge).find((([e])=>t.includes(e)));n?ye(n[1]):je(t)}finally{Ee(),be("idle"),Ie(),Ke.current=null}}));return vt?null:n("div",Object.assign({className:$("z-1 absolute bottom-0 left-0 flex w-full flex-col items-center",!ht&&"px-4 pb-8"),dir:re?"rtl":"ltr"},{children:s("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[s("div",Object.assign({ref:ze,className:$("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===ee.formFieldStyle&&"shadow"),style:Object.assign(Object.assign(Object.assign({},pt),dt&&{backgroundColor:"#EEEEEE"}),{maxHeight:`${qe}px`,overflowY:"auto"}),onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),ut(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),ut(!1)},onDragOver:e=>{e.preventDefault(),e.stopPropagation(),ut(!0)},onDrop:e=>t(void 0,void 0,void 0,(function*(){e.preventDefault(),e.stopPropagation(),ut(!1);const t=Array.from(e.dataTransfer.files||[]);t.length>0&&(le(!1),yield ke(t))}))},{children:[Qe&&s("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 select-none items-center gap-x-2"},{children:[n("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(K=te.accent)&&void 0!==K?K:"#ff0000"}}),n("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:te.text+"90"}},{children:"Listening..."}))]})),!he&&xe.length>0&&n(P,{className:"p-4 pb-0",isDisabled:he}),n(D,Object.assign({ref:Me,className:$(mt.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!Le.trim()&&!Le.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",re?"text-right":"text-left",bt&&"mb-12",Qe&&"text-transparent"),value:Le,placeholder:null!==(M=null==Z?void 0:Z.placeholdertext)&&void 0!==M?M:re?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",onChange:e=>{if($e(e),H){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void H(0);if(t>=11)return;let n=0;t>1&&(n=50),H(24*(t-1)+n)}},onKeyDown:e=>{se||et||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),Oe||he||xt()))},onPaste:e=>t(void 0,void 0,void 0,(function*(){const t=Array.from(e.clipboardData.files||[]);t.length>0&&(e.preventDefault(),le(!1),yield ke(t))}))},W&&{onFocus:W},B&&{onBlur:B},{dir:re?"rtl":"ltr"})),n("div",Object.assign({ref:Xe,className:$("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",bt?"mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!bt&&pt.backgroundColor&&{backgroundColor:pt.backgroundColor}),{borderTopRightRadius:ee.cornerRadius+"px",borderBottomRightRadius:ee.cornerRadius+"px"})},{children:he?n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{Ve.current&&(Ve.current.abort(),Ve.current=null),Ke.current&&(Ke.current.cancel(),Ke.current=null),be("idle")},style:{backgroundColor:te.accent,color:te.accentText}},{children:n(_,{className:"h-4 w-4 shrink-0"})})):Qe?n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:u.stopListening,style:{backgroundColor:te.accent,color:te.accentText}},{children:n(_,{className:"h-4 w-4 shrink-0"})})):s(o,{children:[ft&&s("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:rt?te.accent+"10":void 0,color:rt?te.accent:te.accent+"80"},disabled:Oe||he,onClick:()=>{var e;return null===(e=Je.current)||void 0===e?void 0:e.click()}},it,{children:[n("input",{id:"file-upload",ref:Je,type:"file",accept:[...S,...C,...N].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){le(!1),yield ke(Array.from(e.target.files||[])),e.target.value=""}))}),n(E,{className:"h-6 w-6 shrink-0"})]})),gt&&n("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:Qe?te.accent:lt?te.accent+"10":void 0,color:Qe?te.accentText:lt?te.accent:te.accent+"80"},disabled:Oe||he,onClick:()=>{Qe?u.stopListening():(Ue.current=Le,Ye(),u.startListening({continuous:!0,interimResults:!0,language:ne||"en-US"}))}},ct,{children:n(T,{className:"h-5 w-5 shrink-0"})})),n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:nt||jt?te.accent:te.accent+"10",color:nt||jt?te.accentText:te.accent+"80"},disabled:!jt,onClick:()=>xt()},st,{children:n(A,{className:$("h-6 w-6 shrink-0",re&&"scale-x-[-1] transform")})}))]})}))]})),we&&n(R,{error:we,className:"mt-3"})]}))}))}));W.displayName="Input";export{W as default};
1
+ import{__rest as e,__awaiter as t}from"../../../_virtual/_tslib.js";import{jsx as n,jsxs as s,Fragment as o}from"react/jsx-runtime";import{forwardRef as r,useState as i,useRef as a,useMemo as l,useImperativeHandle as c,useEffect as d}from"react";import"../../../node_modules/.pnpm/regenerator-runtime@0.14.1/node_modules/regenerator-runtime/runtime.js";import u,{useSpeechRecognition as m}from"react-speech-recognition";import{usePickaxeContext as p}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as f}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as h}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as g}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as v}from"../../../hooks/pickaxe/useConversation.js";import{useDimensionContext as b}from"../../../hooks/pickaxe/useDimensionContext.js";import{useAuthContext as y}from"../Addons/Auth/hooks/useAuthContext.js";import{useDocument as j}from"../Addons/Document/hooks/useDocument.js";import{useScroll as x}from"../Addons/Scroll/hooks/useScroll.js";import{useArtifactContext as O}from"../Addons/Artifact/hooks/useArtifactContext.js";import{useHover as w}from"../../../hooks/core/useHover.js";import{useMediaQuery as k}from"../../../hooks/core/useMediaQuery.js";import{allowedFileMimeTypes as S,allowedImageMimeTypes as C,additionalAllowedFileExtensions as N}from"../../../common/documents.js";import{createParser as I}from"eventsource-parser";import E from"../../Icons/attach-vertical.svg.js";import A from"../../Icons/arrow-right.svg.js";import T from"../../Icons/microphone.svg.js";import _ from"../../Icons/stop.svg.js";import P from"../Addons/Document/List.js";import D from"../../Core/Textarea.js";import R from"../../Core/ErrorAlert.js";import L from"../../../common/error.js";import $ from"../../../common/cn.js";const W=r((({resubmitPrompt:r,onFocus:W,onBlur:B,onInputHeightChange:H,initSmitheryAuthData:F},J)=>{var U,K,M;const{origin:X,pickaxeId:V,sessionId:z,sender:q,senderType:G,deploymentId:Q,deploymentType:Y,pickaxe:Z,styles:ee,colors:te,locale:ne,forceMobile:se,isNewChat:oe,isRtl:re,isEmailLogin:ie,isShowFeedbackMessage:ae,setIsNewChat:le,setIsShowIceBreaker:ce,onGenerateComplete:de}=p(),{token:ue,isLoggedOut:me,isSent:pe}=y(),{messages:fe,limits:he,isGenerating:ge,setMessages:ve,setStatus:be,setLimitData:ye,setError:je}=f(),{documents:xe,isUploading:Oe,documentError:we,onFileUpload:ke,setDocuments:Se,setDocumentError:Ce}=j(),{scrollStartSession:Ne,scrollEndSession:Ie,scrollToBottom:Ee}=x({auto:!0}),{artifacts:Ae,currentPopupType:Te,setArtifacts:_e,setCurrentArtifact:Pe}=O(),{height:De}=b(),Re=v(),[Le,$e]=i(""),[We,Be]=i(!1),[He,Fe]=i(!1),Je=a(null),Ue=a(""),Ke=a(null),Me=a(null),Xe=a(null),Ve=a(null),ze=a(null),qe=Math.max(.4*De,100),{transcript:Ge,listening:Qe,resetTranscript:Ye,browserSupportsSpeechRecognition:Ze}=m(),[et]=k("(max-width: 480px)"),tt=w(),{isHover:nt}=tt,st=e(tt,["isHover"]),ot=w(),{isHover:rt}=ot,it=e(ot,["isHover"]),at=w(),{isHover:lt}=at,ct=e(at,["isHover"]),[dt,ut]=i(!1),mt=g(),pt=h(),ft=null===(U=null==Z?void 0:Z.documentuploadtype)||void 0===U?void 0:U.startsWith("enduserupload"),ht=Ze&&(null==Z?void 0:Z.enablevoicetotext),gt="chat-input"===Y&&oe&&!pe,vt="chat-input"===Y&&ie&&me&&pe,bt=null!==(K=null==Z?void 0:Z.placeholdertext)&&void 0!==K?K:re?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",yt=We||He,jt=l((()=>{var e,t,n;return!!oe&&(!!Z&&(!Re.isLoading&&(!((null!==(t=null===(e=Re.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(n=Z.icebreakers)||void 0===n?void 0:n.length)&&(!ae&&!gt)))))}),[Z,oe,ae,gt,Re.data,Re.isLoading]),xt=l((()=>{if(ge||Oe)return!1;const e=xe.length>0&&xe.every((e=>"finished"===e.status));return!(!Le.trim()&&!e)&&xe.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[ge,Oe,Le,xe]);c(J,(()=>({onSubmit:Ot}))),d((()=>{ce(jt)}),[jt]),d((()=>{var e;if(r){const t=Array.from(fe),n=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;Ot(n,!0)}}),[r]),d((()=>{if(!Ve.current||!H)return;const e=new ResizeObserver((e=>{for(const t of e)H(t.contentRect.height)}));return e.observe(Ve.current),()=>{e.disconnect()}}),[H]),d((()=>{if(!Qe)return;const e=Ue.current?`${Ue.current} `:"";$e(`${e}${Ge}`)}),[Ge,Qe]),d((()=>{if(!Me.current)return;(()=>{if(!Me.current)return;let e=Me.current.scrollHeight>52;Le.includes("\n")||xe.length?e=!0:Le.trim()||(e=!1),Be(e)})()}),[Le,xe]),d((()=>{const e=Me.current,t=Xe.current;if(!e||!t||We||Le.includes("\n"))return void Fe(!1);const n=window.getComputedStyle(e),s=`${n.fontStyle} ${n.fontVariant} ${n.fontWeight} ${n.fontSize} / ${n.lineHeight} ${n.fontFamily}`,o=document.createElement("span");Object.assign(o.style,{font:s,letterSpacing:n.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),o.textContent=Le||bt,document.body.appendChild(o);const r=o.offsetWidth;o.remove();const i=parseFloat(n.paddingLeft)||0,a=parseFloat(n.paddingRight)||0,l=e.clientWidth-i-a-t.offsetWidth;Fe(r>l)}),[Le,We,bt]);const Ot=(e,n=!1)=>t(void 0,void 0,void 0,(function*(){var t,s,o;try{if(ge||Oe)return;const r=xe.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)).map((e=>e.documentId)).filter(Boolean),i=r.length>0,a=null!=e?e:Le;if(!a&&!i)return;je(""),Ce(""),ye(null),$e(""),le(!1),be("fetching"),Ne(),Ee();const l=null!==(s=null===(t=null==Z?void 0:Z.documentuploadtype)||void 0===t?void 0:t.startsWith("enduserupload"))&&void 0!==s&&s&&r.length>0,c=[...n?Array.from(fe.slice(0,fe.length-1)):Array.from(fe),...n?[]:[{id:fe.length+1,role:"user",parts:[{type:"text",content:a,isVisible:!0}],documentIds:l?r:[]}],{id:fe.length+(n?0:2),role:"assistant",parts:[],documentIds:[]}];ve(c),Ee(),l&&Se([]);const d=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,{method:"POST",headers:Object.assign({"Content-Type":"application/json"},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}),body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign({origin:X,pickaxeId:V,sessionId:z,senderType:G,value:a},l&&{documentIds:r}),q&&{sender:q}),ue&&{studioSessionToken:ue}),Q&&{deploymentId:Q}))}),u=yield d.json();if(console.log("SubmitData: ",u),!u.success)throw new Error(u.error||"Failed to start generation");const m=u.submissionId;be("streaming"),ze.current=new AbortController;const p=c.length-1,f=[];let h=[...null!=Ae?Ae:[]],g=0,v=!1,b="";for(;!v;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${m}?index=${g}`,{signal:null===(o=ze.current)||void 0===o?void 0:o.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();Ke.current=t;const n=new TextDecoder,s=I({onEvent:e=>{var t,n;if(e.event&&"ping"!==e.event&&g++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data);return je(t.error||"Something went wrong."),void(v=!0)}if("delta"===e.event){const s=JSON.parse(e.data);if("data-error"===s.type&&F){const e=s.data.error;if("string"==typeof e){if(/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e)){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&n&&n[1]&&s&&s[1])throw v=!0,F({smitheryId:t[1],serverId:n[1],name:s[1]}),new Error("STOP_STREAM")}}else if("object"==typeof e&&null!==e){const t=e;if("unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name)throw v=!0,F({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===s.type)b="",f.push({type:"text",content:"",isVisible:null===(t=s.isVisible)||void 0===t||t});else if("text-delta"===s.type)b+=s.delta,f[f.length-1].content=b;else if("text-end"===s.type)b="";else if("reasoning-start"===s.type)b="",f.push({type:"reasoning",content:"",isVisible:null===(n=s.isVisible)||void 0===n||n});else if("reasoning-delta"===s.type)b+=s.delta,f[f.length-1].content=b;else if("reasoning-end"===s.type)b="";else if(s.type.startsWith("data-")){const e=s;f.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}ve([...c.slice(0,p),Object.assign(Object.assign({},c[c.length-1]),{id:fe.length+1,role:"assistant",parts:f})])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);h=h.filter((e=>!(e.id===t.id&&e.version===t.version))),h.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),_e([...h]),Te.startsWith("inline")||Pe({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);h=h.filter((e=>!(e.id===t.id&&e.version===t.version))),h.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),_e(h),Te.startsWith("inline")||Pe({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);h=h.filter((e=>!(e.id===t.id&&e.version===t.version))),h.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),_e(h),Te.startsWith("inline")||Pe({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),n=t.token.replace(/\u200B/g,"");h=h.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+n,status:"streaming"}):e)),_e(h)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);_e(h.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const t=JSON.parse(e.data);je(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(v=!0)}else v=!0}});for(;;){const{value:e,done:o}=yield t.read();if(o)break;s.feed(n.decode(e))}v||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||"AbortError"===e.name)return void(v=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==de||de(z)}catch(e){let t=L(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later.");const n=Object.entries(he).find((([e])=>t.includes(e)));n?ye(n[1]):je(t)}finally{Ee(),be("idle"),Ie(),Ke.current=null}}));return vt?null:n("div",Object.assign({className:$("flex w-full flex-shrink-0 flex-col items-center",!gt&&"px-4 pb-8"),dir:re?"rtl":"ltr"},{children:s("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[s("div",Object.assign({ref:Ve,className:$("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===ee.formFieldStyle&&"shadow"),style:Object.assign(Object.assign(Object.assign({},pt),dt&&{backgroundColor:"#EEEEEE"}),{maxHeight:`${qe}px`,overflowY:"auto"}),onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),ut(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),ut(!1)},onDragOver:e=>{e.preventDefault(),e.stopPropagation(),ut(!0)},onDrop:e=>t(void 0,void 0,void 0,(function*(){e.preventDefault(),e.stopPropagation(),ut(!1);const t=Array.from(e.dataTransfer.files||[]);t.length>0&&(le(!1),yield ke(t))}))},{children:[Qe&&s("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 select-none items-center gap-x-2"},{children:[n("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(M=te.accent)&&void 0!==M?M:"#ff0000"}}),n("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:te.text+"90"}},{children:"Listening..."}))]})),!ge&&xe.length>0&&n(P,{className:"p-4 pb-0",isDisabled:ge}),n(D,Object.assign({ref:Me,className:$(mt.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!Le.trim()&&!Le.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",re?"text-right":"text-left",yt&&"mb-12",Qe&&"text-transparent"),value:Le,placeholder:bt,onChange:e=>{if($e(e),H){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void H(0);if(t>=11)return;let n=0;t>1&&(n=50),H(24*(t-1)+n)}},onKeyDown:e=>{se||et||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),Oe||ge||Ot()))},onPaste:e=>t(void 0,void 0,void 0,(function*(){const t=Array.from(e.clipboardData.files||[]);t.length>0&&(e.preventDefault(),le(!1),yield ke(t))}))},W&&{onFocus:W},B&&{onBlur:B},{dir:re?"rtl":"ltr"})),n("div",Object.assign({ref:Xe,className:$("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",yt?"mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!yt&&pt.backgroundColor&&{backgroundColor:pt.backgroundColor}),{borderTopRightRadius:ee.cornerRadius+"px",borderBottomRightRadius:ee.cornerRadius+"px"})},{children:ge?n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{ze.current&&(ze.current.abort(),ze.current=null),Ke.current&&(Ke.current.cancel(),Ke.current=null),be("idle")},style:{backgroundColor:te.accent,color:te.accentText}},{children:n(_,{className:"h-4 w-4 shrink-0"})})):Qe?n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:u.stopListening,style:{backgroundColor:te.accent,color:te.accentText}},{children:n(_,{className:"h-4 w-4 shrink-0"})})):s(o,{children:[ft&&s("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:rt?te.accent+"10":void 0,color:rt?te.accent:te.accent+"80"},disabled:Oe||ge,onClick:()=>{var e;return null===(e=Je.current)||void 0===e?void 0:e.click()}},it,{children:[n("input",{id:"file-upload",ref:Je,type:"file",accept:[...S,...C,...N].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){le(!1),yield ke(Array.from(e.target.files||[])),e.target.value=""}))}),n(E,{className:"h-6 w-6 shrink-0"})]})),ht&&n("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:Qe?te.accent:lt?te.accent+"10":void 0,color:Qe?te.accentText:lt?te.accent:te.accent+"80"},disabled:Oe||ge,onClick:()=>{Qe?u.stopListening():(Ue.current=Le,Ye(),u.startListening({continuous:!0,interimResults:!0,language:ne||"en-US"}))}},ct,{children:n(T,{className:"h-5 w-5 shrink-0"})})),n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:nt||xt?te.accent:te.accent+"10",color:nt||xt?te.accentText:te.accent+"80"},disabled:!xt,onClick:()=>Ot()},st,{children:n(A,{className:$("h-6 w-6 shrink-0",re&&"scale-x-[-1] transform")})}))]})}))]})),we&&n(R,{error:we,className:"mt-3"})]}))}))}));W.displayName="Input";export{W as default};
@@ -1 +1 @@
1
- import{__awaiter as t}from"../../../_virtual/_tslib.js";import{jsx as e,jsxs as o,Fragment as r}from"react/jsx-runtime";import{useState as n,useRef as i,useEffect as s}from"react";import{usePickaxeContext as u}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as m}from"../Addons/Auth/hooks/useAuthContext.js";import{useDimensionContext as c}from"../../../hooks/pickaxe/useDimensionContext.js";import{useDocument as l}from"../Addons/Document/hooks/useDocument.js";import a from"./History/index.js";import h from"./Input.js";const d=()=>{const{deploymentType:d,isNewChat:p}=u(),{isSent:f}=m(),{width:x,height:j,setDimension:b}=c(),{setDocuments:v}=l(),[g,k]=n(0),[D,A]=n(!1),I=i(null),w=i(null),[y,C]=n(null),[F,S]=n(!1),H="chat-input"===d&&p&&!f;return s((()=>()=>{v([])}),[]),s((()=>{if(!I.current)return;const t=new ResizeObserver((t=>{for(const e of t){const{width:t,height:o}=e.contentRect;b(parseInt(t.toFixed(0)),parseInt(o.toFixed(0)))}}));return t.observe(I.current),()=>{t.disconnect()}}),[I.current]),e("div",Object.assign({ref:I,className:"relative flex flex-grow flex-col items-center"},{children:H?e(h,{}):o(r,{children:[e(a,{additionalScrollHeight:g,isForceHideInfo:j<=545||x<=350||D,isInputFocused:D,onSubmit:e=>t(void 0,void 0,void 0,(function*(){w.current&&w.current.onSubmit(e)})),smitheryAuthData:y,resubmitPrompt:()=>{C(null),S(!0)}}),e(h,{ref:w,onFocus:()=>A(!0),onBlur:()=>A(!1),onInputHeightChange:k,initSmitheryAuthData:t=>C(t),resubmitPrompt:F})]})}))};export{d as default};
1
+ import{__awaiter as t}from"../../../_virtual/_tslib.js";import{jsx as e,jsxs as o,Fragment as r}from"react/jsx-runtime";import{useState as n,useRef as i,useEffect as s}from"react";import{usePickaxeContext as u}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as m}from"../Addons/Auth/hooks/useAuthContext.js";import{useDimensionContext as c}from"../../../hooks/pickaxe/useDimensionContext.js";import{useDocument as l}from"../Addons/Document/hooks/useDocument.js";import h from"./History/index.js";import a from"./Input.js";const d=()=>{const{deploymentType:d,isNewChat:p}=u(),{isSent:f}=m(),{width:x,height:j,setDimension:b}=c(),{setDocuments:v}=l(),[k,D]=n(0),[g,A]=n(!1),I=i(null),w=i(null),[y,C]=n(null),[F,S]=n(!1),H="chat-input"===d&&p&&!f;return s((()=>()=>{v([])}),[]),s((()=>{if(!I.current)return;const t=new ResizeObserver((t=>{for(const e of t){const{width:t,height:o}=e.contentRect;b(parseInt(t.toFixed(0)),parseInt(o.toFixed(0)))}}));return t.observe(I.current),()=>{t.disconnect()}}),[I.current]),e("div",Object.assign({ref:I,className:"relative flex h-full w-full flex-col items-center"},{children:H?e(a,{}):o(r,{children:[e(h,{additionalScrollHeight:k,isForceHideInfo:j<=545||x<=350||g,isInputFocused:g,onSubmit:e=>t(void 0,void 0,void 0,(function*(){w.current&&w.current.onSubmit(e)})),smitheryAuthData:y,resubmitPrompt:()=>{C(null),S(!0)}}),e(a,{ref:w,onFocus:()=>A(!0),onBlur:()=>A(!1),onInputHeightChange:D,initSmitheryAuthData:t=>C(t),resubmitPrompt:F})]})}))};export{d as default};
@@ -1 +1 @@
1
- import{jsx as t,Fragment as e,jsxs as o}from"react/jsx-runtime";import{usePickaxe as s}from"../../hooks/pickaxe/usePickaxe.js";import{useState as r,useEffect as a,useMemo as i}from"react";import{usePickaxeContext as n}from"../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as l}from"./Addons/Auth/hooks/useAuthContext.js";import{useResponseContext as m}from"../../hooks/pickaxe/useResponseContext.js";import{useDocumentContext as c}from"./Addons/Document/hooks/useDocumentContext.js";import{useArtifactContext as p}from"./Addons/Artifact/hooks/useArtifactContext.js";import{v4 as x}from"uuid";import{ScrollProvider as d}from"./Addons/Scroll/Provider.js";import u from"./common/PickaxeSkeleton.js";import f from"./Chat/index.js";import h from"./Form/index.js";import k from"./Addons/Auth/index.js";import j from"../../common/cn.js";const w=({pickaxeId:w,className:g})=>{const{sessionId:y,styles:A,colors:C,responsiveBy:N,deploymentType:b,isNewChat:v,isEmailLogin:P,opacity:S,setContextId:I,setPickaxeId:O,setSessionId:D,setPickaxe:L}=n(),{isLoggedOut:E,isSent:R}=l(),{setMessages:F,setResponse:M,setError:T,setLimitData:$,setIsSwitchedToChat:B}=m(),{setDocumentError:H}=c(),{setCurrentArtifact:W}=p(),[q,z]=r(!1),G=s(),J="chat-input"===b&&v&&!R,K="popup"===b&&y,Q="chat-input"!==b||!R,U="popup"===b&&!y&&P&&E;a((()=>{O(w)}),[w]),a((()=>{if(!G.data)return;const t=G.data.chatflag;D(t?x():""),I(x()),t?F([]):M(null),T(""),H(""),$(null),W(null),B(!1),L(G.data),z(!0)}),[G.data]),a((()=>{T(""),H(""),$(null),F([]),M(null),W(null)}),[y]);const V=i((()=>{const t=null!=S?S:1;if(!C.primary||!C.primary.startsWith("#")||t<0||t>1)return C.primary;const e=Math.round(255*t).toString(16).padStart(2,"0");return`${C.primary}${e}`}),[C.primary,S]);return G.data?t("div",Object.assign({className:j("relative @container/pickaxe-root flex flex-col flex-grow w-full",(!b||K||U)&&"h-full","dark"===A.theme&&"dark",g),style:Object.assign({backgroundColor:J?"transparent":V,color:C.text},A.font&&"Real Head Pro"!==A.font&&{fontFamily:A.font})},{children:P&&E&&Q?t(k,{}):t(e,{children:G.isLoading||!q?t("div",Object.assign({className:j("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===N?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:o("div",Object.assign({className:"flex w-full items-center max-w-[700px] flex-col"},{children:[t(u,{className:"w-[72px] h-[72px]"}),t(u,{className:"h-[20px] mt-6 w-full"}),t(u,{className:"h-[20px] mt-2 w-full"}),t(u,{className:"h-[20px] mt-2 w-full max-w-[400px]"}),t("div",Object.assign({className:"flex flex-col gap-y-8 w-full mt-6"},{children:t(u,{className:j("w-full min-h-[48px]","viewport"===N?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))})):t(e,{children:t(d,y?{children:t(f,{})}:{children:t(h,{})})})})})):null};export{w as Pickaxe};
1
+ import{jsx as t,Fragment as e,jsxs as o}from"react/jsx-runtime";import{usePickaxe as s}from"../../hooks/pickaxe/usePickaxe.js";import{useState as r,useEffect as a,useMemo as i}from"react";import{usePickaxeContext as n}from"../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as l}from"./Addons/Auth/hooks/useAuthContext.js";import{useResponseContext as m}from"../../hooks/pickaxe/useResponseContext.js";import{useDocumentContext as c}from"./Addons/Document/hooks/useDocumentContext.js";import{useArtifactContext as p}from"./Addons/Artifact/hooks/useArtifactContext.js";import{v4 as x}from"uuid";import{ScrollProvider as d}from"./Addons/Scroll/Provider.js";import f from"./common/PickaxeSkeleton.js";import u from"./Chat/index.js";import h from"./Form/index.js";import k from"./Addons/Auth/index.js";import j from"../../common/cn.js";const w=({pickaxeId:w,className:g})=>{const{sessionId:y,styles:A,colors:C,responsiveBy:N,deploymentType:b,isNewChat:v,isEmailLogin:P,opacity:S,setContextId:I,setPickaxeId:O,setSessionId:D,setPickaxe:L}=n(),{isLoggedOut:E,isSent:R}=l(),{setMessages:F,setResponse:M,setError:T,setLimitData:$,setIsSwitchedToChat:B}=m(),{setDocumentError:H}=c(),{setCurrentArtifact:W}=p(),[q,z]=r(!1),G=s(),J="chat-input"===b&&v&&!R,K="chat-input"!==b||!R;a((()=>{O(w)}),[w]),a((()=>{if(!G.data)return;const t=G.data.chatflag;D(t?x():""),I(x()),t?F([]):M(null),T(""),H(""),$(null),W(null),B(!1),L(G.data),z(!0)}),[G.data]),a((()=>{T(""),H(""),$(null),F([]),M(null),W(null)}),[y]);const Q=i((()=>{const t=null!=S?S:1;if(!C.primary||!C.primary.startsWith("#")||t<0||t>1)return C.primary;const e=Math.round(255*t).toString(16).padStart(2,"0");return`${C.primary}${e}`}),[C.primary,S]);return G.data?t("div",Object.assign({className:j("relative @container/pickaxe-root flex flex-col flex-grow w-full h-full","dark"===A.theme&&"dark",g),style:Object.assign({backgroundColor:J?"transparent":Q,color:C.text},A.font&&"Real Head Pro"!==A.font&&{fontFamily:A.font})},{children:P&&E&&K?t(k,{}):t(e,{children:G.isLoading||!q?t("div",Object.assign({className:j("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===N?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:o("div",Object.assign({className:"flex w-full items-center max-w-[700px] flex-col"},{children:[t(f,{className:"w-[72px] h-[72px]"}),t(f,{className:"h-[20px] mt-6 w-full"}),t(f,{className:"h-[20px] mt-2 w-full"}),t(f,{className:"h-[20px] mt-2 w-full max-w-[400px]"}),t("div",Object.assign({className:"flex flex-col gap-y-8 w-full mt-6"},{children:t(f,{className:j("w-full min-h-[48px]","viewport"===N?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))})):t(e,{children:t(d,y?{children:t(u,{})}:{children:t(h,{})})})})})):null};export{w as Pickaxe};
@@ -1 +1 @@
1
- import{commonjsGlobal as t}from"../../../../../_virtual/_commonjsHelpers.js";import{__module as e}from"../../../../../_virtual/cose-base2.js";import{__require as r}from"../../../layout-base@1.0.2/node_modules/layout-base/layout-base.js";var i;function o(){return i||(i=1,t=e,e.exports,o=function(t){return function(t){var e={};function r(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,i){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:i})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=7)}([function(e,r){e.exports=t},function(t,e,r){var i=r(0).FDLayoutConstants;function o(){}for(var n in i)o[n]=i[n];o.DEFAULT_USE_MULTI_LEVEL_SCALING=!1,o.DEFAULT_RADIAL_SEPARATION=i.DEFAULT_EDGE_LENGTH,o.DEFAULT_COMPONENT_SEPERATION=60,o.TILE=!0,o.TILING_PADDING_VERTICAL=10,o.TILING_PADDING_HORIZONTAL=10,o.TREE_REDUCTION_ON_INCREMENTAL=!1,t.exports=o},function(t,e,r){var i=r(0).FDLayoutEdge;function o(t,e,r){i.call(this,t,e,r)}for(var n in o.prototype=Object.create(i.prototype),i)o[n]=i[n];t.exports=o},function(t,e,r){var i=r(0).LGraph;function o(t,e,r){i.call(this,t,e,r)}for(var n in o.prototype=Object.create(i.prototype),i)o[n]=i[n];t.exports=o},function(t,e,r){var i=r(0).LGraphManager;function o(t){i.call(this,t)}for(var n in o.prototype=Object.create(i.prototype),i)o[n]=i[n];t.exports=o},function(t,e,r){var i=r(0).FDLayoutNode,o=r(0).IMath;function n(t,e,r,o){i.call(this,t,e,r,o)}for(var a in n.prototype=Object.create(i.prototype),i)n[a]=i[a];n.prototype.move=function(){var t=this.graphManager.getLayout();this.displacementX=t.coolingFactor*(this.springForceX+this.repulsionForceX+this.gravitationForceX)/this.noOfChildren,this.displacementY=t.coolingFactor*(this.springForceY+this.repulsionForceY+this.gravitationForceY)/this.noOfChildren,Math.abs(this.displacementX)>t.coolingFactor*t.maxNodeDisplacement&&(this.displacementX=t.coolingFactor*t.maxNodeDisplacement*o.sign(this.displacementX)),Math.abs(this.displacementY)>t.coolingFactor*t.maxNodeDisplacement&&(this.displacementY=t.coolingFactor*t.maxNodeDisplacement*o.sign(this.displacementY)),null==this.child||0==this.child.getNodes().length?this.moveBy(this.displacementX,this.displacementY):this.propogateDisplacementToChildren(this.displacementX,this.displacementY),t.totalDisplacement+=Math.abs(this.displacementX)+Math.abs(this.displacementY),this.springForceX=0,this.springForceY=0,this.repulsionForceX=0,this.repulsionForceY=0,this.gravitationForceX=0,this.gravitationForceY=0,this.displacementX=0,this.displacementY=0},n.prototype.propogateDisplacementToChildren=function(t,e){for(var r,i=this.getChild().getNodes(),o=0;o<i.length;o++)null==(r=i[o]).getChild()?(r.moveBy(t,e),r.displacementX+=t,r.displacementY+=e):r.propogateDisplacementToChildren(t,e)},n.prototype.setPred1=function(t){this.pred1=t},n.prototype.getPred1=function(){return pred1},n.prototype.getPred2=function(){return pred2},n.prototype.setNext=function(t){this.next=t},n.prototype.getNext=function(){return next},n.prototype.setProcessed=function(t){this.processed=t},n.prototype.isProcessed=function(){return processed},t.exports=n},function(t,e,r){var i=r(0).FDLayout,o=r(4),n=r(3),a=r(5),s=r(2),h=r(1),d=r(0).FDLayoutConstants,g=r(0).LayoutConstants,l=r(0).Point,p=r(0).PointD,c=r(0).Layout,u=r(0).Integer,f=r(0).IGeometry,v=r(0).LGraph,T=r(0).Transform;function E(){i.call(this),this.toBeTiled={}}for(var m in E.prototype=Object.create(i.prototype),i)E[m]=i[m];E.prototype.newGraphManager=function(){var t=new o(this);return this.graphManager=t,t},E.prototype.newGraph=function(t){return new n(null,this.graphManager,t)},E.prototype.newNode=function(t){return new a(this.graphManager,t)},E.prototype.newEdge=function(t){return new s(null,null,t)},E.prototype.initParameters=function(){i.prototype.initParameters.call(this,arguments),this.isSubLayout||(h.DEFAULT_EDGE_LENGTH<10?this.idealEdgeLength=10:this.idealEdgeLength=h.DEFAULT_EDGE_LENGTH,this.useSmartIdealEdgeLengthCalculation=h.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION,this.springConstant=d.DEFAULT_SPRING_STRENGTH,this.repulsionConstant=d.DEFAULT_REPULSION_STRENGTH,this.gravityConstant=d.DEFAULT_GRAVITY_STRENGTH,this.compoundGravityConstant=d.DEFAULT_COMPOUND_GRAVITY_STRENGTH,this.gravityRangeFactor=d.DEFAULT_GRAVITY_RANGE_FACTOR,this.compoundGravityRangeFactor=d.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR,this.prunedNodesAll=[],this.growTreeIterations=0,this.afterGrowthIterations=0,this.isTreeGrowing=!1,this.isGrowthFinished=!1,this.coolingCycle=0,this.maxCoolingCycle=this.maxIterations/d.CONVERGENCE_CHECK_PERIOD,this.finalTemperature=d.CONVERGENCE_CHECK_PERIOD/this.maxIterations,this.coolingAdjuster=1)},E.prototype.layout=function(){return g.DEFAULT_CREATE_BENDS_AS_NEEDED&&(this.createBendpoints(),this.graphManager.resetAllEdges()),this.level=0,this.classicLayout()},E.prototype.classicLayout=function(){if(this.nodesWithGravity=this.calculateNodesToApplyGravitationTo(),this.graphManager.setAllNodesToApplyGravitation(this.nodesWithGravity),this.calcNoOfChildrenForAllNodes(),this.graphManager.calcLowestCommonAncestors(),this.graphManager.calcInclusionTreeDepths(),this.graphManager.getRoot().calcEstimatedSize(),this.calcIdealEdgeLengths(),this.incremental)h.TREE_REDUCTION_ON_INCREMENTAL&&(this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation(),e=new Set(this.getAllNodes()),r=this.nodesWithGravity.filter((function(t){return e.has(t)})),this.graphManager.setAllNodesToApplyGravitation(r));else{var t=this.getFlatForest();if(t.length>0)this.positionNodesRadially(t);else{this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation();var e=new Set(this.getAllNodes()),r=this.nodesWithGravity.filter((function(t){return e.has(t)}));this.graphManager.setAllNodesToApplyGravitation(r),this.positionNodesRandomly()}}return this.initSpringEmbedder(),this.runSpringEmbedder(),!0},E.prototype.tick=function(){if(this.totalIterations++,this.totalIterations===this.maxIterations&&!this.isTreeGrowing&&!this.isGrowthFinished){if(!(this.prunedNodesAll.length>0))return!0;this.isTreeGrowing=!0}if(this.totalIterations%d.CONVERGENCE_CHECK_PERIOD==0&&!this.isTreeGrowing&&!this.isGrowthFinished){if(this.isConverged()){if(!(this.prunedNodesAll.length>0))return!0;this.isTreeGrowing=!0}this.coolingCycle++,0==this.layoutQuality?this.coolingAdjuster=this.coolingCycle:1==this.layoutQuality&&(this.coolingAdjuster=this.coolingCycle/3),this.coolingFactor=Math.max(this.initialCoolingFactor-Math.pow(this.coolingCycle,Math.log(100*(this.initialCoolingFactor-this.finalTemperature))/Math.log(this.maxCoolingCycle))/100*this.coolingAdjuster,this.finalTemperature),this.animationPeriod=Math.ceil(this.initialAnimationPeriod*Math.sqrt(this.coolingFactor))}if(this.isTreeGrowing){if(this.growTreeIterations%10==0)if(this.prunedNodesAll.length>0){this.graphManager.updateBounds(),this.updateGrid(),this.growTree(this.prunedNodesAll),this.graphManager.resetAllNodesToApplyGravitation();var t=new Set(this.getAllNodes()),e=this.nodesWithGravity.filter((function(e){return t.has(e)}));this.graphManager.setAllNodesToApplyGravitation(e),this.graphManager.updateBounds(),this.updateGrid(),this.coolingFactor=d.DEFAULT_COOLING_FACTOR_INCREMENTAL}else this.isTreeGrowing=!1,this.isGrowthFinished=!0;this.growTreeIterations++}if(this.isGrowthFinished){if(this.isConverged())return!0;this.afterGrowthIterations%10==0&&(this.graphManager.updateBounds(),this.updateGrid()),this.coolingFactor=d.DEFAULT_COOLING_FACTOR_INCREMENTAL*((100-this.afterGrowthIterations)/100),this.afterGrowthIterations++}var r=!this.isTreeGrowing&&!this.isGrowthFinished,i=this.growTreeIterations%10==1&&this.isTreeGrowing||this.afterGrowthIterations%10==1&&this.isGrowthFinished;return this.totalDisplacement=0,this.graphManager.updateBounds(),this.calcSpringForces(),this.calcRepulsionForces(r,i),this.calcGravitationalForces(),this.moveNodes(),this.animate(),!1},E.prototype.getPositionsData=function(){for(var t=this.graphManager.getAllNodes(),e={},r=0;r<t.length;r++){var i=t[r].rect,o=t[r].id;e[o]={id:o,x:i.getCenterX(),y:i.getCenterY(),w:i.width,h:i.height}}return e},E.prototype.runSpringEmbedder=function(){this.initialAnimationPeriod=25,this.animationPeriod=this.initialAnimationPeriod;var t=!1;if("during"===d.ANIMATE)this.emit("layoutstarted");else{for(;!t;)t=this.tick();this.graphManager.updateBounds()}},E.prototype.calculateNodesToApplyGravitationTo=function(){var t,e,r=[],i=this.graphManager.getGraphs(),o=i.length;for(e=0;e<o;e++)(t=i[e]).updateConnected(),t.isConnected||(r=r.concat(t.getNodes()));return r},E.prototype.createBendpoints=function(){var t=[];t=t.concat(this.graphManager.getAllEdges());var e,r=new Set;for(e=0;e<t.length;e++){var i=t[e];if(!r.has(i)){var o=i.getSource(),n=i.getTarget();if(o==n)i.getBendpoints().push(new p),i.getBendpoints().push(new p),this.createDummyNodesForBendpoints(i),r.add(i);else{var a=[];if(a=(a=a.concat(o.getEdgeListToNode(n))).concat(n.getEdgeListToNode(o)),!r.has(a[0])){var s;if(a.length>1)for(s=0;s<a.length;s++){var h=a[s];h.getBendpoints().push(new p),this.createDummyNodesForBendpoints(h)}a.forEach((function(t){r.add(t)}))}}}if(r.size==t.length)break}},E.prototype.positionNodesRadially=function(t){for(var e=new l(0,0),r=Math.ceil(Math.sqrt(t.length)),i=0,o=0,n=0,a=new p(0,0),s=0;s<t.length;s++){s%r==0&&(n=0,o=i,0!=s&&(o+=h.DEFAULT_COMPONENT_SEPERATION),i=0);var d=t[s],u=c.findCenterOfTree(d);e.x=n,e.y=o,(a=E.radialLayout(d,u,e)).y>i&&(i=Math.floor(a.y)),n=Math.floor(a.x+h.DEFAULT_COMPONENT_SEPERATION)}this.transform(new p(g.WORLD_CENTER_X-a.x/2,g.WORLD_CENTER_Y-a.y/2))},E.radialLayout=function(t,e,r){var i=Math.max(this.maxDiagonalInTree(t),h.DEFAULT_RADIAL_SEPARATION);E.branchRadialLayout(e,null,0,359,0,i);var o=v.calculateBounds(t),n=new T;n.setDeviceOrgX(o.getMinX()),n.setDeviceOrgY(o.getMinY()),n.setWorldOrgX(r.x),n.setWorldOrgY(r.y);for(var a=0;a<t.length;a++)t[a].transform(n);var s=new p(o.getMaxX(),o.getMaxY());return n.inverseTransformPoint(s)},E.branchRadialLayout=function(t,e,r,i,o,n){var a=(i-r+1)/2;a<0&&(a+=180);var s=(a+r)%360*f.TWO_PI/360,h=o*Math.cos(s),d=o*Math.sin(s);t.setCenter(h,d);var g=[],l=(g=g.concat(t.getEdges())).length;null!=e&&l--;for(var p,c=0,u=g.length,v=t.getEdgesBetween(e);v.length>1;){var T=v[0];v.splice(0,1);var m=g.indexOf(T);m>=0&&g.splice(m,1),u--,l--}p=null!=e?(g.indexOf(v[0])+1)%u:0;for(var y=Math.abs(i-r)/l,N=p;c!=l;N=++N%u){var w=g[N].getOtherEnd(t);if(w!=e){var A=(r+c*y)%360,C=(A+y)%360;E.branchRadialLayout(w,t,A,C,o+n,n),c++}}},E.maxDiagonalInTree=function(t){for(var e=u.MIN_VALUE,r=0;r<t.length;r++){var i=t[r].getDiagonal();i>e&&(e=i)}return e},E.prototype.calcRepulsionRange=function(){return 2*(this.level+1)*this.idealEdgeLength},E.prototype.groupZeroDegreeMembers=function(){var t=this,e={};this.memberGroups={},this.idToDummyNode={};for(var r=[],i=this.graphManager.getAllNodes(),o=0;o<i.length;o++){var n=(s=i[o]).getParent();0!==this.getNodeDegreeWithChildren(s)||null!=n.id&&this.getToBeTiled(n)||r.push(s)}for(o=0;o<r.length;o++){var s,h=(s=r[o]).getParent().id;void 0===e[h]&&(e[h]=[]),e[h]=e[h].concat(s)}Object.keys(e).forEach((function(r){if(e[r].length>1){var i="DummyCompound_"+r;t.memberGroups[i]=e[r];var o=e[r][0].getParent(),n=new a(t.graphManager);n.id=i,n.paddingLeft=o.paddingLeft||0,n.paddingRight=o.paddingRight||0,n.paddingBottom=o.paddingBottom||0,n.paddingTop=o.paddingTop||0,t.idToDummyNode[i]=n;var s=t.getGraphManager().add(t.newGraph(),n),h=o.getChild();h.add(n);for(var d=0;d<e[r].length;d++){var g=e[r][d];h.remove(g),s.add(g)}}}))},E.prototype.clearCompounds=function(){var t={},e={};this.performDFSOnCompounds();for(var r=0;r<this.compoundOrder.length;r++)e[this.compoundOrder[r].id]=this.compoundOrder[r],t[this.compoundOrder[r].id]=[].concat(this.compoundOrder[r].getChild().getNodes()),this.graphManager.remove(this.compoundOrder[r].getChild()),this.compoundOrder[r].child=null;this.graphManager.resetAllNodes(),this.tileCompoundMembers(t,e)},E.prototype.clearZeroDegreeMembers=function(){var t=this,e=this.tiledZeroDegreePack=[];Object.keys(this.memberGroups).forEach((function(r){var i=t.idToDummyNode[r];e[r]=t.tileNodes(t.memberGroups[r],i.paddingLeft+i.paddingRight),i.rect.width=e[r].width,i.rect.height=e[r].height}))},E.prototype.repopulateCompounds=function(){for(var t=this.compoundOrder.length-1;t>=0;t--){var e=this.compoundOrder[t],r=e.id,i=e.paddingLeft,o=e.paddingTop;this.adjustLocations(this.tiledMemberPack[r],e.rect.x,e.rect.y,i,o)}},E.prototype.repopulateZeroDegreeMembers=function(){var t=this,e=this.tiledZeroDegreePack;Object.keys(e).forEach((function(r){var i=t.idToDummyNode[r],o=i.paddingLeft,n=i.paddingTop;t.adjustLocations(e[r],i.rect.x,i.rect.y,o,n)}))},E.prototype.getToBeTiled=function(t){var e=t.id;if(null!=this.toBeTiled[e])return this.toBeTiled[e];var r=t.getChild();if(null==r)return this.toBeTiled[e]=!1,!1;for(var i=r.getNodes(),o=0;o<i.length;o++){var n=i[o];if(this.getNodeDegree(n)>0)return this.toBeTiled[e]=!1,!1;if(null!=n.getChild()){if(!this.getToBeTiled(n))return this.toBeTiled[e]=!1,!1}else this.toBeTiled[n.id]=!1}return this.toBeTiled[e]=!0,!0},E.prototype.getNodeDegree=function(t){t.id;for(var e=t.getEdges(),r=0,i=0;i<e.length;i++){var o=e[i];o.getSource().id!==o.getTarget().id&&(r+=1)}return r},E.prototype.getNodeDegreeWithChildren=function(t){var e=this.getNodeDegree(t);if(null==t.getChild())return e;for(var r=t.getChild().getNodes(),i=0;i<r.length;i++){var o=r[i];e+=this.getNodeDegreeWithChildren(o)}return e},E.prototype.performDFSOnCompounds=function(){this.compoundOrder=[],this.fillCompexOrderByDFS(this.graphManager.getRoot().getNodes())},E.prototype.fillCompexOrderByDFS=function(t){for(var e=0;e<t.length;e++){var r=t[e];null!=r.getChild()&&this.fillCompexOrderByDFS(r.getChild().getNodes()),this.getToBeTiled(r)&&this.compoundOrder.push(r)}},E.prototype.adjustLocations=function(t,e,r,i,o){r+=o;for(var n=e+=i,a=0;a<t.rows.length;a++){var s=t.rows[a];e=n;for(var h=0,d=0;d<s.length;d++){var g=s[d];g.rect.x=e,g.rect.y=r,e+=g.rect.width+t.horizontalPadding,g.rect.height>h&&(h=g.rect.height)}r+=h+t.verticalPadding}},E.prototype.tileCompoundMembers=function(t,e){var r=this;this.tiledMemberPack=[],Object.keys(t).forEach((function(i){var o=e[i];r.tiledMemberPack[i]=r.tileNodes(t[i],o.paddingLeft+o.paddingRight),o.rect.width=r.tiledMemberPack[i].width,o.rect.height=r.tiledMemberPack[i].height}))},E.prototype.tileNodes=function(t,e){var r={rows:[],rowWidth:[],rowHeight:[],width:0,height:e,verticalPadding:h.TILING_PADDING_VERTICAL,horizontalPadding:h.TILING_PADDING_HORIZONTAL};t.sort((function(t,e){return t.rect.width*t.rect.height>e.rect.width*e.rect.height?-1:t.rect.width*t.rect.height<e.rect.width*e.rect.height?1:0}));for(var i=0;i<t.length;i++){var o=t[i];0==r.rows.length?this.insertNodeToRow(r,o,0,e):this.canAddHorizontal(r,o.rect.width,o.rect.height)?this.insertNodeToRow(r,o,this.getShortestRowIndex(r),e):this.insertNodeToRow(r,o,r.rows.length,e),this.shiftToLastRow(r)}return r},E.prototype.insertNodeToRow=function(t,e,r,i){var o=i;r==t.rows.length&&(t.rows.push([]),t.rowWidth.push(o),t.rowHeight.push(0));var n=t.rowWidth[r]+e.rect.width;t.rows[r].length>0&&(n+=t.horizontalPadding),t.rowWidth[r]=n,t.width<n&&(t.width=n);var a=e.rect.height;r>0&&(a+=t.verticalPadding);var s=0;a>t.rowHeight[r]&&(s=t.rowHeight[r],t.rowHeight[r]=a,s=t.rowHeight[r]-s),t.height+=s,t.rows[r].push(e)},E.prototype.getShortestRowIndex=function(t){for(var e=-1,r=Number.MAX_VALUE,i=0;i<t.rows.length;i++)t.rowWidth[i]<r&&(e=i,r=t.rowWidth[i]);return e},E.prototype.getLongestRowIndex=function(t){for(var e=-1,r=Number.MIN_VALUE,i=0;i<t.rows.length;i++)t.rowWidth[i]>r&&(e=i,r=t.rowWidth[i]);return e},E.prototype.canAddHorizontal=function(t,e,r){var i=this.getShortestRowIndex(t);if(i<0)return!0;var o=t.rowWidth[i];if(o+t.horizontalPadding+e<=t.width)return!0;var n,a,s=0;return t.rowHeight[i]<r&&i>0&&(s=r+t.verticalPadding-t.rowHeight[i]),n=t.width-o>=e+t.horizontalPadding?(t.height+s)/(o+e+t.horizontalPadding):(t.height+s)/t.width,s=r+t.verticalPadding,(a=t.width<e?(t.height+s)/e:(t.height+s)/t.width)<1&&(a=1/a),n<1&&(n=1/n),n<a},E.prototype.shiftToLastRow=function(t){var e=this.getLongestRowIndex(t),r=t.rowWidth.length-1,i=t.rows[e],o=i[i.length-1],n=o.width+t.horizontalPadding;if(t.width-t.rowWidth[r]>n&&e!=r){i.splice(-1,1),t.rows[r].push(o),t.rowWidth[e]=t.rowWidth[e]-n,t.rowWidth[r]=t.rowWidth[r]+n,t.width=t.rowWidth[instance.getLongestRowIndex(t)];for(var a=Number.MIN_VALUE,s=0;s<i.length;s++)i[s].height>a&&(a=i[s].height);e>0&&(a+=t.verticalPadding);var h=t.rowHeight[e]+t.rowHeight[r];t.rowHeight[e]=a,t.rowHeight[r]<o.height+t.verticalPadding&&(t.rowHeight[r]=o.height+t.verticalPadding);var d=t.rowHeight[e]+t.rowHeight[r];t.height+=d-h,this.shiftToLastRow(t)}},E.prototype.tilingPreLayout=function(){h.TILE&&(this.groupZeroDegreeMembers(),this.clearCompounds(),this.clearZeroDegreeMembers())},E.prototype.tilingPostLayout=function(){h.TILE&&(this.repopulateZeroDegreeMembers(),this.repopulateCompounds())},E.prototype.reduceTrees=function(){for(var t,e=[],r=!0;r;){var i=this.graphManager.getAllNodes(),o=[];r=!1;for(var n=0;n<i.length;n++)1!=(t=i[n]).getEdges().length||t.getEdges()[0].isInterGraph||null!=t.getChild()||(o.push([t,t.getEdges()[0],t.getOwner()]),r=!0);if(1==r){for(var a=[],s=0;s<o.length;s++)1==o[s][0].getEdges().length&&(a.push(o[s]),o[s][0].getOwner().remove(o[s][0]));e.push(a),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()}}this.prunedNodesAll=e},E.prototype.growTree=function(t){for(var e,r=t[t.length-1],i=0;i<r.length;i++)e=r[i],this.findPlaceforPrunedNode(e),e[2].add(e[0]),e[2].add(e[1],e[1].source,e[1].target);t.splice(t.length-1,1),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()},E.prototype.findPlaceforPrunedNode=function(t){var e,r,i=t[0],o=(r=i==t[1].source?t[1].target:t[1].source).startX,n=r.finishX,a=r.startY,s=r.finishY,h=[0,0,0,0];if(a>0)for(var g=o;g<=n;g++)h[0]+=this.grid[g][a-1].length+this.grid[g][a].length-1;if(n<this.grid.length-1)for(g=a;g<=s;g++)h[1]+=this.grid[n+1][g].length+this.grid[n][g].length-1;if(s<this.grid[0].length-1)for(g=o;g<=n;g++)h[2]+=this.grid[g][s+1].length+this.grid[g][s].length-1;if(o>0)for(g=a;g<=s;g++)h[3]+=this.grid[o-1][g].length+this.grid[o][g].length-1;for(var l,p,c=u.MAX_VALUE,f=0;f<h.length;f++)h[f]<c?(c=h[f],l=1,p=f):h[f]==c&&l++;if(3==l&&0==c)0==h[0]&&0==h[1]&&0==h[2]?e=1:0==h[0]&&0==h[1]&&0==h[3]?e=0:0==h[0]&&0==h[2]&&0==h[3]?e=3:0==h[1]&&0==h[2]&&0==h[3]&&(e=2);else if(2==l&&0==c){var v=Math.floor(2*Math.random());e=0==h[0]&&0==h[1]?0==v?0:1:0==h[0]&&0==h[2]?0==v?0:2:0==h[0]&&0==h[3]?0==v?0:3:0==h[1]&&0==h[2]?0==v?1:2:0==h[1]&&0==h[3]?0==v?1:3:0==v?2:3}else e=4==l&&0==c?v=Math.floor(4*Math.random()):p;0==e?i.setCenter(r.getCenterX(),r.getCenterY()-r.getHeight()/2-d.DEFAULT_EDGE_LENGTH-i.getHeight()/2):1==e?i.setCenter(r.getCenterX()+r.getWidth()/2+d.DEFAULT_EDGE_LENGTH+i.getWidth()/2,r.getCenterY()):2==e?i.setCenter(r.getCenterX(),r.getCenterY()+r.getHeight()/2+d.DEFAULT_EDGE_LENGTH+i.getHeight()/2):i.setCenter(r.getCenterX()-r.getWidth()/2-d.DEFAULT_EDGE_LENGTH-i.getWidth()/2,r.getCenterY())},t.exports=E},function(t,e,r){var i={};i.layoutBase=r(0),i.CoSEConstants=r(1),i.CoSEEdge=r(2),i.CoSEGraph=r(3),i.CoSEGraphManager=r(4),i.CoSELayout=r(6),i.CoSENode=r(5),t.exports=i}])},t.exports=o(r())),e.exports;var t,o}e.exports;export{o as __require};
1
+ import{commonjsGlobal as t}from"../../../../../_virtual/_commonjsHelpers.js";import{__module as e}from"../../../../../_virtual/cose-base.js";import{__require as r}from"../../../layout-base@1.0.2/node_modules/layout-base/layout-base.js";var i;function o(){return i||(i=1,t=e,e.exports,o=function(t){return function(t){var e={};function r(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,i){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:i})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=7)}([function(e,r){e.exports=t},function(t,e,r){var i=r(0).FDLayoutConstants;function o(){}for(var n in i)o[n]=i[n];o.DEFAULT_USE_MULTI_LEVEL_SCALING=!1,o.DEFAULT_RADIAL_SEPARATION=i.DEFAULT_EDGE_LENGTH,o.DEFAULT_COMPONENT_SEPERATION=60,o.TILE=!0,o.TILING_PADDING_VERTICAL=10,o.TILING_PADDING_HORIZONTAL=10,o.TREE_REDUCTION_ON_INCREMENTAL=!1,t.exports=o},function(t,e,r){var i=r(0).FDLayoutEdge;function o(t,e,r){i.call(this,t,e,r)}for(var n in o.prototype=Object.create(i.prototype),i)o[n]=i[n];t.exports=o},function(t,e,r){var i=r(0).LGraph;function o(t,e,r){i.call(this,t,e,r)}for(var n in o.prototype=Object.create(i.prototype),i)o[n]=i[n];t.exports=o},function(t,e,r){var i=r(0).LGraphManager;function o(t){i.call(this,t)}for(var n in o.prototype=Object.create(i.prototype),i)o[n]=i[n];t.exports=o},function(t,e,r){var i=r(0).FDLayoutNode,o=r(0).IMath;function n(t,e,r,o){i.call(this,t,e,r,o)}for(var a in n.prototype=Object.create(i.prototype),i)n[a]=i[a];n.prototype.move=function(){var t=this.graphManager.getLayout();this.displacementX=t.coolingFactor*(this.springForceX+this.repulsionForceX+this.gravitationForceX)/this.noOfChildren,this.displacementY=t.coolingFactor*(this.springForceY+this.repulsionForceY+this.gravitationForceY)/this.noOfChildren,Math.abs(this.displacementX)>t.coolingFactor*t.maxNodeDisplacement&&(this.displacementX=t.coolingFactor*t.maxNodeDisplacement*o.sign(this.displacementX)),Math.abs(this.displacementY)>t.coolingFactor*t.maxNodeDisplacement&&(this.displacementY=t.coolingFactor*t.maxNodeDisplacement*o.sign(this.displacementY)),null==this.child||0==this.child.getNodes().length?this.moveBy(this.displacementX,this.displacementY):this.propogateDisplacementToChildren(this.displacementX,this.displacementY),t.totalDisplacement+=Math.abs(this.displacementX)+Math.abs(this.displacementY),this.springForceX=0,this.springForceY=0,this.repulsionForceX=0,this.repulsionForceY=0,this.gravitationForceX=0,this.gravitationForceY=0,this.displacementX=0,this.displacementY=0},n.prototype.propogateDisplacementToChildren=function(t,e){for(var r,i=this.getChild().getNodes(),o=0;o<i.length;o++)null==(r=i[o]).getChild()?(r.moveBy(t,e),r.displacementX+=t,r.displacementY+=e):r.propogateDisplacementToChildren(t,e)},n.prototype.setPred1=function(t){this.pred1=t},n.prototype.getPred1=function(){return pred1},n.prototype.getPred2=function(){return pred2},n.prototype.setNext=function(t){this.next=t},n.prototype.getNext=function(){return next},n.prototype.setProcessed=function(t){this.processed=t},n.prototype.isProcessed=function(){return processed},t.exports=n},function(t,e,r){var i=r(0).FDLayout,o=r(4),n=r(3),a=r(5),s=r(2),h=r(1),d=r(0).FDLayoutConstants,g=r(0).LayoutConstants,l=r(0).Point,p=r(0).PointD,c=r(0).Layout,u=r(0).Integer,f=r(0).IGeometry,v=r(0).LGraph,T=r(0).Transform;function E(){i.call(this),this.toBeTiled={}}for(var m in E.prototype=Object.create(i.prototype),i)E[m]=i[m];E.prototype.newGraphManager=function(){var t=new o(this);return this.graphManager=t,t},E.prototype.newGraph=function(t){return new n(null,this.graphManager,t)},E.prototype.newNode=function(t){return new a(this.graphManager,t)},E.prototype.newEdge=function(t){return new s(null,null,t)},E.prototype.initParameters=function(){i.prototype.initParameters.call(this,arguments),this.isSubLayout||(h.DEFAULT_EDGE_LENGTH<10?this.idealEdgeLength=10:this.idealEdgeLength=h.DEFAULT_EDGE_LENGTH,this.useSmartIdealEdgeLengthCalculation=h.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION,this.springConstant=d.DEFAULT_SPRING_STRENGTH,this.repulsionConstant=d.DEFAULT_REPULSION_STRENGTH,this.gravityConstant=d.DEFAULT_GRAVITY_STRENGTH,this.compoundGravityConstant=d.DEFAULT_COMPOUND_GRAVITY_STRENGTH,this.gravityRangeFactor=d.DEFAULT_GRAVITY_RANGE_FACTOR,this.compoundGravityRangeFactor=d.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR,this.prunedNodesAll=[],this.growTreeIterations=0,this.afterGrowthIterations=0,this.isTreeGrowing=!1,this.isGrowthFinished=!1,this.coolingCycle=0,this.maxCoolingCycle=this.maxIterations/d.CONVERGENCE_CHECK_PERIOD,this.finalTemperature=d.CONVERGENCE_CHECK_PERIOD/this.maxIterations,this.coolingAdjuster=1)},E.prototype.layout=function(){return g.DEFAULT_CREATE_BENDS_AS_NEEDED&&(this.createBendpoints(),this.graphManager.resetAllEdges()),this.level=0,this.classicLayout()},E.prototype.classicLayout=function(){if(this.nodesWithGravity=this.calculateNodesToApplyGravitationTo(),this.graphManager.setAllNodesToApplyGravitation(this.nodesWithGravity),this.calcNoOfChildrenForAllNodes(),this.graphManager.calcLowestCommonAncestors(),this.graphManager.calcInclusionTreeDepths(),this.graphManager.getRoot().calcEstimatedSize(),this.calcIdealEdgeLengths(),this.incremental)h.TREE_REDUCTION_ON_INCREMENTAL&&(this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation(),e=new Set(this.getAllNodes()),r=this.nodesWithGravity.filter((function(t){return e.has(t)})),this.graphManager.setAllNodesToApplyGravitation(r));else{var t=this.getFlatForest();if(t.length>0)this.positionNodesRadially(t);else{this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation();var e=new Set(this.getAllNodes()),r=this.nodesWithGravity.filter((function(t){return e.has(t)}));this.graphManager.setAllNodesToApplyGravitation(r),this.positionNodesRandomly()}}return this.initSpringEmbedder(),this.runSpringEmbedder(),!0},E.prototype.tick=function(){if(this.totalIterations++,this.totalIterations===this.maxIterations&&!this.isTreeGrowing&&!this.isGrowthFinished){if(!(this.prunedNodesAll.length>0))return!0;this.isTreeGrowing=!0}if(this.totalIterations%d.CONVERGENCE_CHECK_PERIOD==0&&!this.isTreeGrowing&&!this.isGrowthFinished){if(this.isConverged()){if(!(this.prunedNodesAll.length>0))return!0;this.isTreeGrowing=!0}this.coolingCycle++,0==this.layoutQuality?this.coolingAdjuster=this.coolingCycle:1==this.layoutQuality&&(this.coolingAdjuster=this.coolingCycle/3),this.coolingFactor=Math.max(this.initialCoolingFactor-Math.pow(this.coolingCycle,Math.log(100*(this.initialCoolingFactor-this.finalTemperature))/Math.log(this.maxCoolingCycle))/100*this.coolingAdjuster,this.finalTemperature),this.animationPeriod=Math.ceil(this.initialAnimationPeriod*Math.sqrt(this.coolingFactor))}if(this.isTreeGrowing){if(this.growTreeIterations%10==0)if(this.prunedNodesAll.length>0){this.graphManager.updateBounds(),this.updateGrid(),this.growTree(this.prunedNodesAll),this.graphManager.resetAllNodesToApplyGravitation();var t=new Set(this.getAllNodes()),e=this.nodesWithGravity.filter((function(e){return t.has(e)}));this.graphManager.setAllNodesToApplyGravitation(e),this.graphManager.updateBounds(),this.updateGrid(),this.coolingFactor=d.DEFAULT_COOLING_FACTOR_INCREMENTAL}else this.isTreeGrowing=!1,this.isGrowthFinished=!0;this.growTreeIterations++}if(this.isGrowthFinished){if(this.isConverged())return!0;this.afterGrowthIterations%10==0&&(this.graphManager.updateBounds(),this.updateGrid()),this.coolingFactor=d.DEFAULT_COOLING_FACTOR_INCREMENTAL*((100-this.afterGrowthIterations)/100),this.afterGrowthIterations++}var r=!this.isTreeGrowing&&!this.isGrowthFinished,i=this.growTreeIterations%10==1&&this.isTreeGrowing||this.afterGrowthIterations%10==1&&this.isGrowthFinished;return this.totalDisplacement=0,this.graphManager.updateBounds(),this.calcSpringForces(),this.calcRepulsionForces(r,i),this.calcGravitationalForces(),this.moveNodes(),this.animate(),!1},E.prototype.getPositionsData=function(){for(var t=this.graphManager.getAllNodes(),e={},r=0;r<t.length;r++){var i=t[r].rect,o=t[r].id;e[o]={id:o,x:i.getCenterX(),y:i.getCenterY(),w:i.width,h:i.height}}return e},E.prototype.runSpringEmbedder=function(){this.initialAnimationPeriod=25,this.animationPeriod=this.initialAnimationPeriod;var t=!1;if("during"===d.ANIMATE)this.emit("layoutstarted");else{for(;!t;)t=this.tick();this.graphManager.updateBounds()}},E.prototype.calculateNodesToApplyGravitationTo=function(){var t,e,r=[],i=this.graphManager.getGraphs(),o=i.length;for(e=0;e<o;e++)(t=i[e]).updateConnected(),t.isConnected||(r=r.concat(t.getNodes()));return r},E.prototype.createBendpoints=function(){var t=[];t=t.concat(this.graphManager.getAllEdges());var e,r=new Set;for(e=0;e<t.length;e++){var i=t[e];if(!r.has(i)){var o=i.getSource(),n=i.getTarget();if(o==n)i.getBendpoints().push(new p),i.getBendpoints().push(new p),this.createDummyNodesForBendpoints(i),r.add(i);else{var a=[];if(a=(a=a.concat(o.getEdgeListToNode(n))).concat(n.getEdgeListToNode(o)),!r.has(a[0])){var s;if(a.length>1)for(s=0;s<a.length;s++){var h=a[s];h.getBendpoints().push(new p),this.createDummyNodesForBendpoints(h)}a.forEach((function(t){r.add(t)}))}}}if(r.size==t.length)break}},E.prototype.positionNodesRadially=function(t){for(var e=new l(0,0),r=Math.ceil(Math.sqrt(t.length)),i=0,o=0,n=0,a=new p(0,0),s=0;s<t.length;s++){s%r==0&&(n=0,o=i,0!=s&&(o+=h.DEFAULT_COMPONENT_SEPERATION),i=0);var d=t[s],u=c.findCenterOfTree(d);e.x=n,e.y=o,(a=E.radialLayout(d,u,e)).y>i&&(i=Math.floor(a.y)),n=Math.floor(a.x+h.DEFAULT_COMPONENT_SEPERATION)}this.transform(new p(g.WORLD_CENTER_X-a.x/2,g.WORLD_CENTER_Y-a.y/2))},E.radialLayout=function(t,e,r){var i=Math.max(this.maxDiagonalInTree(t),h.DEFAULT_RADIAL_SEPARATION);E.branchRadialLayout(e,null,0,359,0,i);var o=v.calculateBounds(t),n=new T;n.setDeviceOrgX(o.getMinX()),n.setDeviceOrgY(o.getMinY()),n.setWorldOrgX(r.x),n.setWorldOrgY(r.y);for(var a=0;a<t.length;a++)t[a].transform(n);var s=new p(o.getMaxX(),o.getMaxY());return n.inverseTransformPoint(s)},E.branchRadialLayout=function(t,e,r,i,o,n){var a=(i-r+1)/2;a<0&&(a+=180);var s=(a+r)%360*f.TWO_PI/360,h=o*Math.cos(s),d=o*Math.sin(s);t.setCenter(h,d);var g=[],l=(g=g.concat(t.getEdges())).length;null!=e&&l--;for(var p,c=0,u=g.length,v=t.getEdgesBetween(e);v.length>1;){var T=v[0];v.splice(0,1);var m=g.indexOf(T);m>=0&&g.splice(m,1),u--,l--}p=null!=e?(g.indexOf(v[0])+1)%u:0;for(var y=Math.abs(i-r)/l,N=p;c!=l;N=++N%u){var w=g[N].getOtherEnd(t);if(w!=e){var A=(r+c*y)%360,C=(A+y)%360;E.branchRadialLayout(w,t,A,C,o+n,n),c++}}},E.maxDiagonalInTree=function(t){for(var e=u.MIN_VALUE,r=0;r<t.length;r++){var i=t[r].getDiagonal();i>e&&(e=i)}return e},E.prototype.calcRepulsionRange=function(){return 2*(this.level+1)*this.idealEdgeLength},E.prototype.groupZeroDegreeMembers=function(){var t=this,e={};this.memberGroups={},this.idToDummyNode={};for(var r=[],i=this.graphManager.getAllNodes(),o=0;o<i.length;o++){var n=(s=i[o]).getParent();0!==this.getNodeDegreeWithChildren(s)||null!=n.id&&this.getToBeTiled(n)||r.push(s)}for(o=0;o<r.length;o++){var s,h=(s=r[o]).getParent().id;void 0===e[h]&&(e[h]=[]),e[h]=e[h].concat(s)}Object.keys(e).forEach((function(r){if(e[r].length>1){var i="DummyCompound_"+r;t.memberGroups[i]=e[r];var o=e[r][0].getParent(),n=new a(t.graphManager);n.id=i,n.paddingLeft=o.paddingLeft||0,n.paddingRight=o.paddingRight||0,n.paddingBottom=o.paddingBottom||0,n.paddingTop=o.paddingTop||0,t.idToDummyNode[i]=n;var s=t.getGraphManager().add(t.newGraph(),n),h=o.getChild();h.add(n);for(var d=0;d<e[r].length;d++){var g=e[r][d];h.remove(g),s.add(g)}}}))},E.prototype.clearCompounds=function(){var t={},e={};this.performDFSOnCompounds();for(var r=0;r<this.compoundOrder.length;r++)e[this.compoundOrder[r].id]=this.compoundOrder[r],t[this.compoundOrder[r].id]=[].concat(this.compoundOrder[r].getChild().getNodes()),this.graphManager.remove(this.compoundOrder[r].getChild()),this.compoundOrder[r].child=null;this.graphManager.resetAllNodes(),this.tileCompoundMembers(t,e)},E.prototype.clearZeroDegreeMembers=function(){var t=this,e=this.tiledZeroDegreePack=[];Object.keys(this.memberGroups).forEach((function(r){var i=t.idToDummyNode[r];e[r]=t.tileNodes(t.memberGroups[r],i.paddingLeft+i.paddingRight),i.rect.width=e[r].width,i.rect.height=e[r].height}))},E.prototype.repopulateCompounds=function(){for(var t=this.compoundOrder.length-1;t>=0;t--){var e=this.compoundOrder[t],r=e.id,i=e.paddingLeft,o=e.paddingTop;this.adjustLocations(this.tiledMemberPack[r],e.rect.x,e.rect.y,i,o)}},E.prototype.repopulateZeroDegreeMembers=function(){var t=this,e=this.tiledZeroDegreePack;Object.keys(e).forEach((function(r){var i=t.idToDummyNode[r],o=i.paddingLeft,n=i.paddingTop;t.adjustLocations(e[r],i.rect.x,i.rect.y,o,n)}))},E.prototype.getToBeTiled=function(t){var e=t.id;if(null!=this.toBeTiled[e])return this.toBeTiled[e];var r=t.getChild();if(null==r)return this.toBeTiled[e]=!1,!1;for(var i=r.getNodes(),o=0;o<i.length;o++){var n=i[o];if(this.getNodeDegree(n)>0)return this.toBeTiled[e]=!1,!1;if(null!=n.getChild()){if(!this.getToBeTiled(n))return this.toBeTiled[e]=!1,!1}else this.toBeTiled[n.id]=!1}return this.toBeTiled[e]=!0,!0},E.prototype.getNodeDegree=function(t){t.id;for(var e=t.getEdges(),r=0,i=0;i<e.length;i++){var o=e[i];o.getSource().id!==o.getTarget().id&&(r+=1)}return r},E.prototype.getNodeDegreeWithChildren=function(t){var e=this.getNodeDegree(t);if(null==t.getChild())return e;for(var r=t.getChild().getNodes(),i=0;i<r.length;i++){var o=r[i];e+=this.getNodeDegreeWithChildren(o)}return e},E.prototype.performDFSOnCompounds=function(){this.compoundOrder=[],this.fillCompexOrderByDFS(this.graphManager.getRoot().getNodes())},E.prototype.fillCompexOrderByDFS=function(t){for(var e=0;e<t.length;e++){var r=t[e];null!=r.getChild()&&this.fillCompexOrderByDFS(r.getChild().getNodes()),this.getToBeTiled(r)&&this.compoundOrder.push(r)}},E.prototype.adjustLocations=function(t,e,r,i,o){r+=o;for(var n=e+=i,a=0;a<t.rows.length;a++){var s=t.rows[a];e=n;for(var h=0,d=0;d<s.length;d++){var g=s[d];g.rect.x=e,g.rect.y=r,e+=g.rect.width+t.horizontalPadding,g.rect.height>h&&(h=g.rect.height)}r+=h+t.verticalPadding}},E.prototype.tileCompoundMembers=function(t,e){var r=this;this.tiledMemberPack=[],Object.keys(t).forEach((function(i){var o=e[i];r.tiledMemberPack[i]=r.tileNodes(t[i],o.paddingLeft+o.paddingRight),o.rect.width=r.tiledMemberPack[i].width,o.rect.height=r.tiledMemberPack[i].height}))},E.prototype.tileNodes=function(t,e){var r={rows:[],rowWidth:[],rowHeight:[],width:0,height:e,verticalPadding:h.TILING_PADDING_VERTICAL,horizontalPadding:h.TILING_PADDING_HORIZONTAL};t.sort((function(t,e){return t.rect.width*t.rect.height>e.rect.width*e.rect.height?-1:t.rect.width*t.rect.height<e.rect.width*e.rect.height?1:0}));for(var i=0;i<t.length;i++){var o=t[i];0==r.rows.length?this.insertNodeToRow(r,o,0,e):this.canAddHorizontal(r,o.rect.width,o.rect.height)?this.insertNodeToRow(r,o,this.getShortestRowIndex(r),e):this.insertNodeToRow(r,o,r.rows.length,e),this.shiftToLastRow(r)}return r},E.prototype.insertNodeToRow=function(t,e,r,i){var o=i;r==t.rows.length&&(t.rows.push([]),t.rowWidth.push(o),t.rowHeight.push(0));var n=t.rowWidth[r]+e.rect.width;t.rows[r].length>0&&(n+=t.horizontalPadding),t.rowWidth[r]=n,t.width<n&&(t.width=n);var a=e.rect.height;r>0&&(a+=t.verticalPadding);var s=0;a>t.rowHeight[r]&&(s=t.rowHeight[r],t.rowHeight[r]=a,s=t.rowHeight[r]-s),t.height+=s,t.rows[r].push(e)},E.prototype.getShortestRowIndex=function(t){for(var e=-1,r=Number.MAX_VALUE,i=0;i<t.rows.length;i++)t.rowWidth[i]<r&&(e=i,r=t.rowWidth[i]);return e},E.prototype.getLongestRowIndex=function(t){for(var e=-1,r=Number.MIN_VALUE,i=0;i<t.rows.length;i++)t.rowWidth[i]>r&&(e=i,r=t.rowWidth[i]);return e},E.prototype.canAddHorizontal=function(t,e,r){var i=this.getShortestRowIndex(t);if(i<0)return!0;var o=t.rowWidth[i];if(o+t.horizontalPadding+e<=t.width)return!0;var n,a,s=0;return t.rowHeight[i]<r&&i>0&&(s=r+t.verticalPadding-t.rowHeight[i]),n=t.width-o>=e+t.horizontalPadding?(t.height+s)/(o+e+t.horizontalPadding):(t.height+s)/t.width,s=r+t.verticalPadding,(a=t.width<e?(t.height+s)/e:(t.height+s)/t.width)<1&&(a=1/a),n<1&&(n=1/n),n<a},E.prototype.shiftToLastRow=function(t){var e=this.getLongestRowIndex(t),r=t.rowWidth.length-1,i=t.rows[e],o=i[i.length-1],n=o.width+t.horizontalPadding;if(t.width-t.rowWidth[r]>n&&e!=r){i.splice(-1,1),t.rows[r].push(o),t.rowWidth[e]=t.rowWidth[e]-n,t.rowWidth[r]=t.rowWidth[r]+n,t.width=t.rowWidth[instance.getLongestRowIndex(t)];for(var a=Number.MIN_VALUE,s=0;s<i.length;s++)i[s].height>a&&(a=i[s].height);e>0&&(a+=t.verticalPadding);var h=t.rowHeight[e]+t.rowHeight[r];t.rowHeight[e]=a,t.rowHeight[r]<o.height+t.verticalPadding&&(t.rowHeight[r]=o.height+t.verticalPadding);var d=t.rowHeight[e]+t.rowHeight[r];t.height+=d-h,this.shiftToLastRow(t)}},E.prototype.tilingPreLayout=function(){h.TILE&&(this.groupZeroDegreeMembers(),this.clearCompounds(),this.clearZeroDegreeMembers())},E.prototype.tilingPostLayout=function(){h.TILE&&(this.repopulateZeroDegreeMembers(),this.repopulateCompounds())},E.prototype.reduceTrees=function(){for(var t,e=[],r=!0;r;){var i=this.graphManager.getAllNodes(),o=[];r=!1;for(var n=0;n<i.length;n++)1!=(t=i[n]).getEdges().length||t.getEdges()[0].isInterGraph||null!=t.getChild()||(o.push([t,t.getEdges()[0],t.getOwner()]),r=!0);if(1==r){for(var a=[],s=0;s<o.length;s++)1==o[s][0].getEdges().length&&(a.push(o[s]),o[s][0].getOwner().remove(o[s][0]));e.push(a),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()}}this.prunedNodesAll=e},E.prototype.growTree=function(t){for(var e,r=t[t.length-1],i=0;i<r.length;i++)e=r[i],this.findPlaceforPrunedNode(e),e[2].add(e[0]),e[2].add(e[1],e[1].source,e[1].target);t.splice(t.length-1,1),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()},E.prototype.findPlaceforPrunedNode=function(t){var e,r,i=t[0],o=(r=i==t[1].source?t[1].target:t[1].source).startX,n=r.finishX,a=r.startY,s=r.finishY,h=[0,0,0,0];if(a>0)for(var g=o;g<=n;g++)h[0]+=this.grid[g][a-1].length+this.grid[g][a].length-1;if(n<this.grid.length-1)for(g=a;g<=s;g++)h[1]+=this.grid[n+1][g].length+this.grid[n][g].length-1;if(s<this.grid[0].length-1)for(g=o;g<=n;g++)h[2]+=this.grid[g][s+1].length+this.grid[g][s].length-1;if(o>0)for(g=a;g<=s;g++)h[3]+=this.grid[o-1][g].length+this.grid[o][g].length-1;for(var l,p,c=u.MAX_VALUE,f=0;f<h.length;f++)h[f]<c?(c=h[f],l=1,p=f):h[f]==c&&l++;if(3==l&&0==c)0==h[0]&&0==h[1]&&0==h[2]?e=1:0==h[0]&&0==h[1]&&0==h[3]?e=0:0==h[0]&&0==h[2]&&0==h[3]?e=3:0==h[1]&&0==h[2]&&0==h[3]&&(e=2);else if(2==l&&0==c){var v=Math.floor(2*Math.random());e=0==h[0]&&0==h[1]?0==v?0:1:0==h[0]&&0==h[2]?0==v?0:2:0==h[0]&&0==h[3]?0==v?0:3:0==h[1]&&0==h[2]?0==v?1:2:0==h[1]&&0==h[3]?0==v?1:3:0==v?2:3}else e=4==l&&0==c?v=Math.floor(4*Math.random()):p;0==e?i.setCenter(r.getCenterX(),r.getCenterY()-r.getHeight()/2-d.DEFAULT_EDGE_LENGTH-i.getHeight()/2):1==e?i.setCenter(r.getCenterX()+r.getWidth()/2+d.DEFAULT_EDGE_LENGTH+i.getWidth()/2,r.getCenterY()):2==e?i.setCenter(r.getCenterX(),r.getCenterY()+r.getHeight()/2+d.DEFAULT_EDGE_LENGTH+i.getHeight()/2):i.setCenter(r.getCenterX()-r.getWidth()/2-d.DEFAULT_EDGE_LENGTH-i.getWidth()/2,r.getCenterY())},t.exports=E},function(t,e,r){var i={};i.layoutBase=r(0),i.CoSEConstants=r(1),i.CoSEEdge=r(2),i.CoSEGraph=r(3),i.CoSEGraphManager=r(4),i.CoSELayout=r(6),i.CoSENode=r(5),t.exports=i}])},t.exports=o(r())),e.exports;var t,o}e.exports;export{o as __require};
@@ -1 +1 @@
1
- import{commonjsGlobal as t}from"../../../../../_virtual/_commonjsHelpers.js";import{__module as e}from"../../../../../_virtual/cose-base.js";import{__require as i}from"../../../layout-base@2.0.1/node_modules/layout-base/layout-base.js";var o;function n(){return o||(o=1,t=e,e.exports,n=function(t){return e={45:(t,e,i)=>{var o={};o.layoutBase=i(551),o.CoSEConstants=i(806),o.CoSEEdge=i(767),o.CoSEGraph=i(880),o.CoSEGraphManager=i(578),o.CoSELayout=i(765),o.CoSENode=i(991),o.ConstraintHandler=i(902),t.exports=o},806:(t,e,i)=>{var o=i(551).FDLayoutConstants;function n(){}for(var r in o)n[r]=o[r];n.DEFAULT_USE_MULTI_LEVEL_SCALING=!1,n.DEFAULT_RADIAL_SEPARATION=o.DEFAULT_EDGE_LENGTH,n.DEFAULT_COMPONENT_SEPERATION=60,n.TILE=!0,n.TILING_PADDING_VERTICAL=10,n.TILING_PADDING_HORIZONTAL=10,n.TRANSFORM_ON_CONSTRAINT_HANDLING=!0,n.ENFORCE_CONSTRAINTS=!0,n.APPLY_LAYOUT=!0,n.RELAX_MOVEMENT_ON_CONSTRAINTS=!0,n.TREE_REDUCTION_ON_INCREMENTAL=!0,n.PURE_INCREMENTAL=n.DEFAULT_INCREMENTAL,t.exports=n},767:(t,e,i)=>{var o=i(551).FDLayoutEdge;function n(t,e,i){o.call(this,t,e,i)}for(var r in n.prototype=Object.create(o.prototype),o)n[r]=o[r];t.exports=n},880:(t,e,i)=>{var o=i(551).LGraph;function n(t,e,i){o.call(this,t,e,i)}for(var r in n.prototype=Object.create(o.prototype),o)n[r]=o[r];t.exports=n},578:(t,e,i)=>{var o=i(551).LGraphManager;function n(t){o.call(this,t)}for(var r in n.prototype=Object.create(o.prototype),o)n[r]=o[r];t.exports=n},765:(t,e,i)=>{var o=i(551).FDLayout,n=i(578),r=i(880),a=i(991),s=i(767),h=i(806),l=i(902),d=i(551).FDLayoutConstants,g=i(551).LayoutConstants,c=i(551).Point,p=i(551).PointD,f=i(551).DimensionD,u=i(551).Layout,m=i(551).Integer,v=i(551).IGeometry,T=i(551).LGraph,N=i(551).Transform,E=i(551).LinkedList;function y(){o.call(this),this.toBeTiled={},this.constraints={}}for(var C in y.prototype=Object.create(o.prototype),o)y[C]=o[C];y.prototype.newGraphManager=function(){var t=new n(this);return this.graphManager=t,t},y.prototype.newGraph=function(t){return new r(null,this.graphManager,t)},y.prototype.newNode=function(t){return new a(this.graphManager,t)},y.prototype.newEdge=function(t){return new s(null,null,t)},y.prototype.initParameters=function(){o.prototype.initParameters.call(this,arguments),this.isSubLayout||(h.DEFAULT_EDGE_LENGTH<10?this.idealEdgeLength=10:this.idealEdgeLength=h.DEFAULT_EDGE_LENGTH,this.useSmartIdealEdgeLengthCalculation=h.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION,this.gravityConstant=d.DEFAULT_GRAVITY_STRENGTH,this.compoundGravityConstant=d.DEFAULT_COMPOUND_GRAVITY_STRENGTH,this.gravityRangeFactor=d.DEFAULT_GRAVITY_RANGE_FACTOR,this.compoundGravityRangeFactor=d.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR,this.prunedNodesAll=[],this.growTreeIterations=0,this.afterGrowthIterations=0,this.isTreeGrowing=!1,this.isGrowthFinished=!1)},y.prototype.initSpringEmbedder=function(){o.prototype.initSpringEmbedder.call(this),this.coolingCycle=0,this.maxCoolingCycle=this.maxIterations/d.CONVERGENCE_CHECK_PERIOD,this.finalTemperature=.04,this.coolingAdjuster=1},y.prototype.layout=function(){return g.DEFAULT_CREATE_BENDS_AS_NEEDED&&(this.createBendpoints(),this.graphManager.resetAllEdges()),this.level=0,this.classicLayout()},y.prototype.classicLayout=function(){if(this.nodesWithGravity=this.calculateNodesToApplyGravitationTo(),this.graphManager.setAllNodesToApplyGravitation(this.nodesWithGravity),this.calcNoOfChildrenForAllNodes(),this.graphManager.calcLowestCommonAncestors(),this.graphManager.calcInclusionTreeDepths(),this.graphManager.getRoot().calcEstimatedSize(),this.calcIdealEdgeLengths(),this.incremental)h.TREE_REDUCTION_ON_INCREMENTAL&&(this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation(),e=new Set(this.getAllNodes()),i=this.nodesWithGravity.filter((function(t){return e.has(t)})),this.graphManager.setAllNodesToApplyGravitation(i));else{var t=this.getFlatForest();if(t.length>0)this.positionNodesRadially(t);else{this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation();var e=new Set(this.getAllNodes()),i=this.nodesWithGravity.filter((function(t){return e.has(t)}));this.graphManager.setAllNodesToApplyGravitation(i),this.positionNodesRandomly()}}return Object.keys(this.constraints).length>0&&(l.handleConstraints(this),this.initConstraintVariables()),this.initSpringEmbedder(),h.APPLY_LAYOUT&&this.runSpringEmbedder(),!0},y.prototype.tick=function(){if(this.totalIterations++,this.totalIterations===this.maxIterations&&!this.isTreeGrowing&&!this.isGrowthFinished){if(!(this.prunedNodesAll.length>0))return!0;this.isTreeGrowing=!0}if(this.totalIterations%d.CONVERGENCE_CHECK_PERIOD==0&&!this.isTreeGrowing&&!this.isGrowthFinished){if(this.isConverged()){if(!(this.prunedNodesAll.length>0))return!0;this.isTreeGrowing=!0}this.coolingCycle++,0==this.layoutQuality?this.coolingAdjuster=this.coolingCycle:1==this.layoutQuality&&(this.coolingAdjuster=this.coolingCycle/3),this.coolingFactor=Math.max(this.initialCoolingFactor-Math.pow(this.coolingCycle,Math.log(100*(this.initialCoolingFactor-this.finalTemperature))/Math.log(this.maxCoolingCycle))/100*this.coolingAdjuster,this.finalTemperature),this.animationPeriod=Math.ceil(this.initialAnimationPeriod*Math.sqrt(this.coolingFactor))}if(this.isTreeGrowing){if(this.growTreeIterations%10==0)if(this.prunedNodesAll.length>0){this.graphManager.updateBounds(),this.updateGrid(),this.growTree(this.prunedNodesAll),this.graphManager.resetAllNodesToApplyGravitation();var t=new Set(this.getAllNodes()),e=this.nodesWithGravity.filter((function(e){return t.has(e)}));this.graphManager.setAllNodesToApplyGravitation(e),this.graphManager.updateBounds(),this.updateGrid(),h.PURE_INCREMENTAL?this.coolingFactor=d.DEFAULT_COOLING_FACTOR_INCREMENTAL/2:this.coolingFactor=d.DEFAULT_COOLING_FACTOR_INCREMENTAL}else this.isTreeGrowing=!1,this.isGrowthFinished=!0;this.growTreeIterations++}if(this.isGrowthFinished){if(this.isConverged())return!0;this.afterGrowthIterations%10==0&&(this.graphManager.updateBounds(),this.updateGrid()),h.PURE_INCREMENTAL?this.coolingFactor=d.DEFAULT_COOLING_FACTOR_INCREMENTAL/2*((100-this.afterGrowthIterations)/100):this.coolingFactor=d.DEFAULT_COOLING_FACTOR_INCREMENTAL*((100-this.afterGrowthIterations)/100),this.afterGrowthIterations++}var i=!this.isTreeGrowing&&!this.isGrowthFinished,o=this.growTreeIterations%10==1&&this.isTreeGrowing||this.afterGrowthIterations%10==1&&this.isGrowthFinished;return this.totalDisplacement=0,this.graphManager.updateBounds(),this.calcSpringForces(),this.calcRepulsionForces(i,o),this.calcGravitationalForces(),this.moveNodes(),this.animate(),!1},y.prototype.getPositionsData=function(){for(var t=this.graphManager.getAllNodes(),e={},i=0;i<t.length;i++){var o=t[i].rect,n=t[i].id;e[n]={id:n,x:o.getCenterX(),y:o.getCenterY(),w:o.width,h:o.height}}return e},y.prototype.runSpringEmbedder=function(){this.initialAnimationPeriod=25,this.animationPeriod=this.initialAnimationPeriod;var t=!1;if("during"===d.ANIMATE)this.emit("layoutstarted");else{for(;!t;)t=this.tick();this.graphManager.updateBounds()}},y.prototype.moveNodes=function(){for(var t=this.getAllNodes(),e=0;e<t.length;e++)t[e].calculateDisplacement();for(Object.keys(this.constraints).length>0&&this.updateDisplacements(),e=0;e<t.length;e++)t[e].move()},y.prototype.initConstraintVariables=function(){var t=this;this.idToNodeMap=new Map,this.fixedNodeSet=new Set;for(var e=this.graphManager.getAllNodes(),i=0;i<e.length;i++){var o=e[i];this.idToNodeMap.set(o.id,o)}var n=function e(i){for(var o,n=i.getChild().getNodes(),r=0,a=0;a<n.length;a++)null==(o=n[a]).getChild()?t.fixedNodeSet.has(o.id)&&(r+=100):r+=e(o);return r};if(this.constraints.fixedNodeConstraint)for(this.constraints.fixedNodeConstraint.forEach((function(e){t.fixedNodeSet.add(e.nodeId)})),e=this.graphManager.getAllNodes(),i=0;i<e.length;i++)if(null!=(o=e[i]).getChild()){var r=n(o);r>0&&(o.fixedNodeWeight=r)}if(this.constraints.relativePlacementConstraint){var a=new Map,s=new Map;if(this.dummyToNodeForVerticalAlignment=new Map,this.dummyToNodeForHorizontalAlignment=new Map,this.fixedNodesOnHorizontal=new Set,this.fixedNodesOnVertical=new Set,this.fixedNodeSet.forEach((function(e){t.fixedNodesOnHorizontal.add(e),t.fixedNodesOnVertical.add(e)})),this.constraints.alignmentConstraint){if(this.constraints.alignmentConstraint.vertical){var l=this.constraints.alignmentConstraint.vertical;for(i=0;i<l.length;i++)this.dummyToNodeForVerticalAlignment.set("dummy"+i,[]),l[i].forEach((function(e){a.set(e,"dummy"+i),t.dummyToNodeForVerticalAlignment.get("dummy"+i).push(e),t.fixedNodeSet.has(e)&&t.fixedNodesOnHorizontal.add("dummy"+i)}))}if(this.constraints.alignmentConstraint.horizontal){var d=this.constraints.alignmentConstraint.horizontal;for(i=0;i<d.length;i++)this.dummyToNodeForHorizontalAlignment.set("dummy"+i,[]),d[i].forEach((function(e){s.set(e,"dummy"+i),t.dummyToNodeForHorizontalAlignment.get("dummy"+i).push(e),t.fixedNodeSet.has(e)&&t.fixedNodesOnVertical.add("dummy"+i)}))}}if(h.RELAX_MOVEMENT_ON_CONSTRAINTS)this.shuffle=function(t){var e,i,o;for(o=t.length-1;o>=2*t.length/3;o--)e=Math.floor(Math.random()*(o+1)),i=t[o],t[o]=t[e],t[e]=i;return t},this.nodesInRelativeHorizontal=[],this.nodesInRelativeVertical=[],this.nodeToRelativeConstraintMapHorizontal=new Map,this.nodeToRelativeConstraintMapVertical=new Map,this.nodeToTempPositionMapHorizontal=new Map,this.nodeToTempPositionMapVertical=new Map,this.constraints.relativePlacementConstraint.forEach((function(e){if(e.left){var i=a.has(e.left)?a.get(e.left):e.left,o=a.has(e.right)?a.get(e.right):e.right;t.nodesInRelativeHorizontal.includes(i)||(t.nodesInRelativeHorizontal.push(i),t.nodeToRelativeConstraintMapHorizontal.set(i,[]),t.dummyToNodeForVerticalAlignment.has(i)?t.nodeToTempPositionMapHorizontal.set(i,t.idToNodeMap.get(t.dummyToNodeForVerticalAlignment.get(i)[0]).getCenterX()):t.nodeToTempPositionMapHorizontal.set(i,t.idToNodeMap.get(i).getCenterX())),t.nodesInRelativeHorizontal.includes(o)||(t.nodesInRelativeHorizontal.push(o),t.nodeToRelativeConstraintMapHorizontal.set(o,[]),t.dummyToNodeForVerticalAlignment.has(o)?t.nodeToTempPositionMapHorizontal.set(o,t.idToNodeMap.get(t.dummyToNodeForVerticalAlignment.get(o)[0]).getCenterX()):t.nodeToTempPositionMapHorizontal.set(o,t.idToNodeMap.get(o).getCenterX())),t.nodeToRelativeConstraintMapHorizontal.get(i).push({right:o,gap:e.gap}),t.nodeToRelativeConstraintMapHorizontal.get(o).push({left:i,gap:e.gap})}else{var n=s.has(e.top)?s.get(e.top):e.top,r=s.has(e.bottom)?s.get(e.bottom):e.bottom;t.nodesInRelativeVertical.includes(n)||(t.nodesInRelativeVertical.push(n),t.nodeToRelativeConstraintMapVertical.set(n,[]),t.dummyToNodeForHorizontalAlignment.has(n)?t.nodeToTempPositionMapVertical.set(n,t.idToNodeMap.get(t.dummyToNodeForHorizontalAlignment.get(n)[0]).getCenterY()):t.nodeToTempPositionMapVertical.set(n,t.idToNodeMap.get(n).getCenterY())),t.nodesInRelativeVertical.includes(r)||(t.nodesInRelativeVertical.push(r),t.nodeToRelativeConstraintMapVertical.set(r,[]),t.dummyToNodeForHorizontalAlignment.has(r)?t.nodeToTempPositionMapVertical.set(r,t.idToNodeMap.get(t.dummyToNodeForHorizontalAlignment.get(r)[0]).getCenterY()):t.nodeToTempPositionMapVertical.set(r,t.idToNodeMap.get(r).getCenterY())),t.nodeToRelativeConstraintMapVertical.get(n).push({bottom:r,gap:e.gap}),t.nodeToRelativeConstraintMapVertical.get(r).push({top:n,gap:e.gap})}}));else{var g=new Map,c=new Map;this.constraints.relativePlacementConstraint.forEach((function(t){if(t.left){var e=a.has(t.left)?a.get(t.left):t.left,i=a.has(t.right)?a.get(t.right):t.right;g.has(e)?g.get(e).push(i):g.set(e,[i]),g.has(i)?g.get(i).push(e):g.set(i,[e])}else{var o=s.has(t.top)?s.get(t.top):t.top,n=s.has(t.bottom)?s.get(t.bottom):t.bottom;c.has(o)?c.get(o).push(n):c.set(o,[n]),c.has(n)?c.get(n).push(o):c.set(n,[o])}}));var p=function(t,e){var i=[],o=[],n=new E,r=new Set,a=0;return t.forEach((function(s,h){if(!r.has(h)){i[a]=[],o[a]=!1;var l=h;for(n.push(l),r.add(l),i[a].push(l);0!=n.length;)l=n.shift(),e.has(l)&&(o[a]=!0),t.get(l).forEach((function(t){r.has(t)||(n.push(t),r.add(t),i[a].push(t))}));a++}})),{components:i,isFixed:o}},f=p(g,t.fixedNodesOnHorizontal);this.componentsOnHorizontal=f.components,this.fixedComponentsOnHorizontal=f.isFixed;var u=p(c,t.fixedNodesOnVertical);this.componentsOnVertical=u.components,this.fixedComponentsOnVertical=u.isFixed}}},y.prototype.updateDisplacements=function(){var t=this;if(this.constraints.fixedNodeConstraint&&this.constraints.fixedNodeConstraint.forEach((function(e){var i=t.idToNodeMap.get(e.nodeId);i.displacementX=0,i.displacementY=0})),this.constraints.alignmentConstraint){if(this.constraints.alignmentConstraint.vertical)for(var e=this.constraints.alignmentConstraint.vertical,i=0;i<e.length;i++){for(var o=0,n=0;n<e[i].length;n++){if(this.fixedNodeSet.has(e[i][n])){o=0;break}o+=this.idToNodeMap.get(e[i][n]).displacementX}var r=o/e[i].length;for(n=0;n<e[i].length;n++)this.idToNodeMap.get(e[i][n]).displacementX=r}if(this.constraints.alignmentConstraint.horizontal){var a=this.constraints.alignmentConstraint.horizontal;for(i=0;i<a.length;i++){var s=0;for(n=0;n<a[i].length;n++){if(this.fixedNodeSet.has(a[i][n])){s=0;break}s+=this.idToNodeMap.get(a[i][n]).displacementY}var l=s/a[i].length;for(n=0;n<a[i].length;n++)this.idToNodeMap.get(a[i][n]).displacementY=l}}}if(this.constraints.relativePlacementConstraint)if(h.RELAX_MOVEMENT_ON_CONSTRAINTS)this.totalIterations%10==0&&(this.shuffle(this.nodesInRelativeHorizontal),this.shuffle(this.nodesInRelativeVertical)),this.nodesInRelativeHorizontal.forEach((function(e){if(!t.fixedNodesOnHorizontal.has(e)){var i=0;i=t.dummyToNodeForVerticalAlignment.has(e)?t.idToNodeMap.get(t.dummyToNodeForVerticalAlignment.get(e)[0]).displacementX:t.idToNodeMap.get(e).displacementX,t.nodeToRelativeConstraintMapHorizontal.get(e).forEach((function(o){var n;o.right?(n=t.nodeToTempPositionMapHorizontal.get(o.right)-t.nodeToTempPositionMapHorizontal.get(e)-i)<o.gap&&(i-=o.gap-n):(n=t.nodeToTempPositionMapHorizontal.get(e)-t.nodeToTempPositionMapHorizontal.get(o.left)+i)<o.gap&&(i+=o.gap-n)})),t.nodeToTempPositionMapHorizontal.set(e,t.nodeToTempPositionMapHorizontal.get(e)+i),t.dummyToNodeForVerticalAlignment.has(e)?t.dummyToNodeForVerticalAlignment.get(e).forEach((function(e){t.idToNodeMap.get(e).displacementX=i})):t.idToNodeMap.get(e).displacementX=i}})),this.nodesInRelativeVertical.forEach((function(e){if(!t.fixedNodesOnHorizontal.has(e)){var i=0;i=t.dummyToNodeForHorizontalAlignment.has(e)?t.idToNodeMap.get(t.dummyToNodeForHorizontalAlignment.get(e)[0]).displacementY:t.idToNodeMap.get(e).displacementY,t.nodeToRelativeConstraintMapVertical.get(e).forEach((function(o){var n;o.bottom?(n=t.nodeToTempPositionMapVertical.get(o.bottom)-t.nodeToTempPositionMapVertical.get(e)-i)<o.gap&&(i-=o.gap-n):(n=t.nodeToTempPositionMapVertical.get(e)-t.nodeToTempPositionMapVertical.get(o.top)+i)<o.gap&&(i+=o.gap-n)})),t.nodeToTempPositionMapVertical.set(e,t.nodeToTempPositionMapVertical.get(e)+i),t.dummyToNodeForHorizontalAlignment.has(e)?t.dummyToNodeForHorizontalAlignment.get(e).forEach((function(e){t.idToNodeMap.get(e).displacementY=i})):t.idToNodeMap.get(e).displacementY=i}}));else{for(i=0;i<this.componentsOnHorizontal.length;i++){var d=this.componentsOnHorizontal[i];if(this.fixedComponentsOnHorizontal[i])for(n=0;n<d.length;n++)this.dummyToNodeForVerticalAlignment.has(d[n])?this.dummyToNodeForVerticalAlignment.get(d[n]).forEach((function(e){t.idToNodeMap.get(e).displacementX=0})):this.idToNodeMap.get(d[n]).displacementX=0;else{var g=0,c=0;for(n=0;n<d.length;n++)this.dummyToNodeForVerticalAlignment.has(d[n])?(g+=(f=this.dummyToNodeForVerticalAlignment.get(d[n])).length*this.idToNodeMap.get(f[0]).displacementX,c+=f.length):(g+=this.idToNodeMap.get(d[n]).displacementX,c++);var p=g/c;for(n=0;n<d.length;n++)this.dummyToNodeForVerticalAlignment.has(d[n])?this.dummyToNodeForVerticalAlignment.get(d[n]).forEach((function(e){t.idToNodeMap.get(e).displacementX=p})):this.idToNodeMap.get(d[n]).displacementX=p}}for(i=0;i<this.componentsOnVertical.length;i++)if(d=this.componentsOnVertical[i],this.fixedComponentsOnVertical[i])for(n=0;n<d.length;n++)this.dummyToNodeForHorizontalAlignment.has(d[n])?this.dummyToNodeForHorizontalAlignment.get(d[n]).forEach((function(e){t.idToNodeMap.get(e).displacementY=0})):this.idToNodeMap.get(d[n]).displacementY=0;else{for(g=0,c=0,n=0;n<d.length;n++){var f;this.dummyToNodeForHorizontalAlignment.has(d[n])?(g+=(f=this.dummyToNodeForHorizontalAlignment.get(d[n])).length*this.idToNodeMap.get(f[0]).displacementY,c+=f.length):(g+=this.idToNodeMap.get(d[n]).displacementY,c++)}for(p=g/c,n=0;n<d.length;n++)this.dummyToNodeForHorizontalAlignment.has(d[n])?this.dummyToNodeForHorizontalAlignment.get(d[n]).forEach((function(e){t.idToNodeMap.get(e).displacementY=p})):this.idToNodeMap.get(d[n]).displacementY=p}}},y.prototype.calculateNodesToApplyGravitationTo=function(){var t,e,i=[],o=this.graphManager.getGraphs(),n=o.length;for(e=0;e<n;e++)(t=o[e]).updateConnected(),t.isConnected||(i=i.concat(t.getNodes()));return i},y.prototype.createBendpoints=function(){var t=[];t=t.concat(this.graphManager.getAllEdges());var e,i=new Set;for(e=0;e<t.length;e++){var o=t[e];if(!i.has(o)){var n=o.getSource(),r=o.getTarget();if(n==r)o.getBendpoints().push(new p),o.getBendpoints().push(new p),this.createDummyNodesForBendpoints(o),i.add(o);else{var a=[];if(a=(a=a.concat(n.getEdgeListToNode(r))).concat(r.getEdgeListToNode(n)),!i.has(a[0])){var s;if(a.length>1)for(s=0;s<a.length;s++){var h=a[s];h.getBendpoints().push(new p),this.createDummyNodesForBendpoints(h)}a.forEach((function(t){i.add(t)}))}}}if(i.size==t.length)break}},y.prototype.positionNodesRadially=function(t){for(var e=new c(0,0),i=Math.ceil(Math.sqrt(t.length)),o=0,n=0,r=0,a=new p(0,0),s=0;s<t.length;s++){s%i==0&&(r=0,n=o,0!=s&&(n+=h.DEFAULT_COMPONENT_SEPERATION),o=0);var l=t[s],d=u.findCenterOfTree(l);e.x=r,e.y=n,(a=y.radialLayout(l,d,e)).y>o&&(o=Math.floor(a.y)),r=Math.floor(a.x+h.DEFAULT_COMPONENT_SEPERATION)}this.transform(new p(g.WORLD_CENTER_X-a.x/2,g.WORLD_CENTER_Y-a.y/2))},y.radialLayout=function(t,e,i){var o=Math.max(this.maxDiagonalInTree(t),h.DEFAULT_RADIAL_SEPARATION);y.branchRadialLayout(e,null,0,359,0,o);var n=T.calculateBounds(t),r=new N;r.setDeviceOrgX(n.getMinX()),r.setDeviceOrgY(n.getMinY()),r.setWorldOrgX(i.x),r.setWorldOrgY(i.y);for(var a=0;a<t.length;a++)t[a].transform(r);var s=new p(n.getMaxX(),n.getMaxY());return r.inverseTransformPoint(s)},y.branchRadialLayout=function(t,e,i,o,n,r){var a=(o-i+1)/2;a<0&&(a+=180);var s=(a+i)%360*v.TWO_PI/360,h=n*Math.cos(s),l=n*Math.sin(s);t.setCenter(h,l);var d=[],g=(d=d.concat(t.getEdges())).length;null!=e&&g--;for(var c,p=0,f=d.length,u=t.getEdgesBetween(e);u.length>1;){var m=u[0];u.splice(0,1);var T=d.indexOf(m);T>=0&&d.splice(T,1),f--,g--}c=null!=e?(d.indexOf(u[0])+1)%f:0;for(var N=Math.abs(o-i)/g,E=c;p!=g;E=++E%f){var C=d[E].getOtherEnd(t);if(C!=e){var M=(i+p*N)%360,w=(M+N)%360;y.branchRadialLayout(C,t,M,w,n+r,r),p++}}},y.maxDiagonalInTree=function(t){for(var e=m.MIN_VALUE,i=0;i<t.length;i++){var o=t[i].getDiagonal();o>e&&(e=o)}return e},y.prototype.calcRepulsionRange=function(){return 2*(this.level+1)*this.idealEdgeLength},y.prototype.groupZeroDegreeMembers=function(){var t=this,e={};this.memberGroups={},this.idToDummyNode={};for(var i=[],o=this.graphManager.getAllNodes(),n=0;n<o.length;n++){var r=(s=o[n]).getParent();0!==this.getNodeDegreeWithChildren(s)||null!=r.id&&this.getToBeTiled(r)||i.push(s)}for(n=0;n<i.length;n++){var s,h=(s=i[n]).getParent().id;void 0===e[h]&&(e[h]=[]),e[h]=e[h].concat(s)}Object.keys(e).forEach((function(i){if(e[i].length>1){var o="DummyCompound_"+i;t.memberGroups[o]=e[i];var n=e[i][0].getParent(),r=new a(t.graphManager);r.id=o,r.paddingLeft=n.paddingLeft||0,r.paddingRight=n.paddingRight||0,r.paddingBottom=n.paddingBottom||0,r.paddingTop=n.paddingTop||0,t.idToDummyNode[o]=r;var s=t.getGraphManager().add(t.newGraph(),r),h=n.getChild();h.add(r);for(var l=0;l<e[i].length;l++){var d=e[i][l];h.remove(d),s.add(d)}}}))},y.prototype.clearCompounds=function(){var t={},e={};this.performDFSOnCompounds();for(var i=0;i<this.compoundOrder.length;i++)e[this.compoundOrder[i].id]=this.compoundOrder[i],t[this.compoundOrder[i].id]=[].concat(this.compoundOrder[i].getChild().getNodes()),this.graphManager.remove(this.compoundOrder[i].getChild()),this.compoundOrder[i].child=null;this.graphManager.resetAllNodes(),this.tileCompoundMembers(t,e)},y.prototype.clearZeroDegreeMembers=function(){var t=this,e=this.tiledZeroDegreePack=[];Object.keys(this.memberGroups).forEach((function(i){var o=t.idToDummyNode[i];if(e[i]=t.tileNodes(t.memberGroups[i],o.paddingLeft+o.paddingRight),o.rect.width=e[i].width,o.rect.height=e[i].height,o.setCenter(e[i].centerX,e[i].centerY),o.labelMarginLeft=0,o.labelMarginTop=0,h.NODE_DIMENSIONS_INCLUDE_LABELS){var n=o.rect.width,r=o.rect.height;o.labelWidth&&("left"==o.labelPosHorizontal?(o.rect.x-=o.labelWidth,o.setWidth(n+o.labelWidth),o.labelMarginLeft=o.labelWidth):"center"==o.labelPosHorizontal&&o.labelWidth>n?(o.rect.x-=(o.labelWidth-n)/2,o.setWidth(o.labelWidth),o.labelMarginLeft=(o.labelWidth-n)/2):"right"==o.labelPosHorizontal&&o.setWidth(n+o.labelWidth)),o.labelHeight&&("top"==o.labelPosVertical?(o.rect.y-=o.labelHeight,o.setHeight(r+o.labelHeight),o.labelMarginTop=o.labelHeight):"center"==o.labelPosVertical&&o.labelHeight>r?(o.rect.y-=(o.labelHeight-r)/2,o.setHeight(o.labelHeight),o.labelMarginTop=(o.labelHeight-r)/2):"bottom"==o.labelPosVertical&&o.setHeight(r+o.labelHeight))}}))},y.prototype.repopulateCompounds=function(){for(var t=this.compoundOrder.length-1;t>=0;t--){var e=this.compoundOrder[t],i=e.id,o=e.paddingLeft,n=e.paddingTop,r=e.labelMarginLeft,a=e.labelMarginTop;this.adjustLocations(this.tiledMemberPack[i],e.rect.x,e.rect.y,o,n,r,a)}},y.prototype.repopulateZeroDegreeMembers=function(){var t=this,e=this.tiledZeroDegreePack;Object.keys(e).forEach((function(i){var o=t.idToDummyNode[i],n=o.paddingLeft,r=o.paddingTop,a=o.labelMarginLeft,s=o.labelMarginTop;t.adjustLocations(e[i],o.rect.x,o.rect.y,n,r,a,s)}))},y.prototype.getToBeTiled=function(t){var e=t.id;if(null!=this.toBeTiled[e])return this.toBeTiled[e];var i=t.getChild();if(null==i)return this.toBeTiled[e]=!1,!1;for(var o=i.getNodes(),n=0;n<o.length;n++){var r=o[n];if(this.getNodeDegree(r)>0)return this.toBeTiled[e]=!1,!1;if(null!=r.getChild()){if(!this.getToBeTiled(r))return this.toBeTiled[e]=!1,!1}else this.toBeTiled[r.id]=!1}return this.toBeTiled[e]=!0,!0},y.prototype.getNodeDegree=function(t){t.id;for(var e=t.getEdges(),i=0,o=0;o<e.length;o++){var n=e[o];n.getSource().id!==n.getTarget().id&&(i+=1)}return i},y.prototype.getNodeDegreeWithChildren=function(t){var e=this.getNodeDegree(t);if(null==t.getChild())return e;for(var i=t.getChild().getNodes(),o=0;o<i.length;o++){var n=i[o];e+=this.getNodeDegreeWithChildren(n)}return e},y.prototype.performDFSOnCompounds=function(){this.compoundOrder=[],this.fillCompexOrderByDFS(this.graphManager.getRoot().getNodes())},y.prototype.fillCompexOrderByDFS=function(t){for(var e=0;e<t.length;e++){var i=t[e];null!=i.getChild()&&this.fillCompexOrderByDFS(i.getChild().getNodes()),this.getToBeTiled(i)&&this.compoundOrder.push(i)}},y.prototype.adjustLocations=function(t,e,i,o,n,r,a){i+=n+a;for(var s=e+=o+r,h=0;h<t.rows.length;h++){var l=t.rows[h];e=s;for(var d=0,g=0;g<l.length;g++){var c=l[g];c.rect.x=e,c.rect.y=i,e+=c.rect.width+t.horizontalPadding,c.rect.height>d&&(d=c.rect.height)}i+=d+t.verticalPadding}},y.prototype.tileCompoundMembers=function(t,e){var i=this;this.tiledMemberPack=[],Object.keys(t).forEach((function(o){var n=e[o];if(i.tiledMemberPack[o]=i.tileNodes(t[o],n.paddingLeft+n.paddingRight),n.rect.width=i.tiledMemberPack[o].width,n.rect.height=i.tiledMemberPack[o].height,n.setCenter(i.tiledMemberPack[o].centerX,i.tiledMemberPack[o].centerY),n.labelMarginLeft=0,n.labelMarginTop=0,h.NODE_DIMENSIONS_INCLUDE_LABELS){var r=n.rect.width,a=n.rect.height;n.labelWidth&&("left"==n.labelPosHorizontal?(n.rect.x-=n.labelWidth,n.setWidth(r+n.labelWidth),n.labelMarginLeft=n.labelWidth):"center"==n.labelPosHorizontal&&n.labelWidth>r?(n.rect.x-=(n.labelWidth-r)/2,n.setWidth(n.labelWidth),n.labelMarginLeft=(n.labelWidth-r)/2):"right"==n.labelPosHorizontal&&n.setWidth(r+n.labelWidth)),n.labelHeight&&("top"==n.labelPosVertical?(n.rect.y-=n.labelHeight,n.setHeight(a+n.labelHeight),n.labelMarginTop=n.labelHeight):"center"==n.labelPosVertical&&n.labelHeight>a?(n.rect.y-=(n.labelHeight-a)/2,n.setHeight(n.labelHeight),n.labelMarginTop=(n.labelHeight-a)/2):"bottom"==n.labelPosVertical&&n.setHeight(a+n.labelHeight))}}))},y.prototype.tileNodes=function(t,e){var i=this.tileNodesByFavoringDim(t,e,!0),o=this.tileNodesByFavoringDim(t,e,!1),n=this.getOrgRatio(i);return this.getOrgRatio(o)<n?o:i},y.prototype.getOrgRatio=function(t){var e=t.width/t.height;return e<1&&(e=1/e),e},y.prototype.calcIdealRowWidth=function(t,e){var i=h.TILING_PADDING_VERTICAL,o=h.TILING_PADDING_HORIZONTAL,n=t.length,r=0,a=0,s=0;t.forEach((function(t){r+=t.getWidth(),a+=t.getHeight(),t.getWidth()>s&&(s=t.getWidth())}));var l,d=r/n,g=a/n,c=Math.pow(i-o,2)+4*(d+o)*(g+i)*n,p=(o-i+Math.sqrt(c))/(2*(d+o));e?(l=Math.ceil(p))==p&&l++:l=Math.floor(p);var f=l*(d+o)-o;return s>f&&(f=s),f+=2*o},y.prototype.tileNodesByFavoringDim=function(t,e,i){var o=h.TILING_PADDING_VERTICAL,n=h.TILING_PADDING_HORIZONTAL,r=h.TILING_COMPARE_BY,a={rows:[],rowWidth:[],rowHeight:[],width:0,height:e,verticalPadding:o,horizontalPadding:n,centerX:0,centerY:0};r&&(a.idealRowWidth=this.calcIdealRowWidth(t,i));var s=function(t){return t.rect.width*t.rect.height},l=function(t,e){return s(e)-s(t)};t.sort((function(t,e){var i=l;return a.idealRowWidth?(i=r)(t.id,e.id):i(t,e)}));for(var d=0,g=0,c=0;c<t.length;c++)d+=(p=t[c]).getCenterX(),g+=p.getCenterY();for(a.centerX=d/t.length,a.centerY=g/t.length,c=0;c<t.length;c++){var p=t[c];if(0==a.rows.length)this.insertNodeToRow(a,p,0,e);else if(this.canAddHorizontal(a,p.rect.width,p.rect.height)){var f=a.rows.length-1;a.idealRowWidth||(f=this.getShortestRowIndex(a)),this.insertNodeToRow(a,p,f,e)}else this.insertNodeToRow(a,p,a.rows.length,e);this.shiftToLastRow(a)}return a},y.prototype.insertNodeToRow=function(t,e,i,o){var n=o;i==t.rows.length&&(t.rows.push([]),t.rowWidth.push(n),t.rowHeight.push(0));var r=t.rowWidth[i]+e.rect.width;t.rows[i].length>0&&(r+=t.horizontalPadding),t.rowWidth[i]=r,t.width<r&&(t.width=r);var a=e.rect.height;i>0&&(a+=t.verticalPadding);var s=0;a>t.rowHeight[i]&&(s=t.rowHeight[i],t.rowHeight[i]=a,s=t.rowHeight[i]-s),t.height+=s,t.rows[i].push(e)},y.prototype.getShortestRowIndex=function(t){for(var e=-1,i=Number.MAX_VALUE,o=0;o<t.rows.length;o++)t.rowWidth[o]<i&&(e=o,i=t.rowWidth[o]);return e},y.prototype.getLongestRowIndex=function(t){for(var e=-1,i=Number.MIN_VALUE,o=0;o<t.rows.length;o++)t.rowWidth[o]>i&&(e=o,i=t.rowWidth[o]);return e},y.prototype.canAddHorizontal=function(t,e,i){if(t.idealRowWidth){var o=t.rows.length-1;return t.rowWidth[o]+e+t.horizontalPadding<=t.idealRowWidth}var n=this.getShortestRowIndex(t);if(n<0)return!0;var r=t.rowWidth[n];if(r+t.horizontalPadding+e<=t.width)return!0;var a,s,h=0;return t.rowHeight[n]<i&&n>0&&(h=i+t.verticalPadding-t.rowHeight[n]),a=t.width-r>=e+t.horizontalPadding?(t.height+h)/(r+e+t.horizontalPadding):(t.height+h)/t.width,h=i+t.verticalPadding,(s=t.width<e?(t.height+h)/e:(t.height+h)/t.width)<1&&(s=1/s),a<1&&(a=1/a),a<s},y.prototype.shiftToLastRow=function(t){var e=this.getLongestRowIndex(t),i=t.rowWidth.length-1,o=t.rows[e],n=o[o.length-1],r=n.width+t.horizontalPadding;if(t.width-t.rowWidth[i]>r&&e!=i){o.splice(-1,1),t.rows[i].push(n),t.rowWidth[e]=t.rowWidth[e]-r,t.rowWidth[i]=t.rowWidth[i]+r,t.width=t.rowWidth[instance.getLongestRowIndex(t)];for(var a=Number.MIN_VALUE,s=0;s<o.length;s++)o[s].height>a&&(a=o[s].height);e>0&&(a+=t.verticalPadding);var h=t.rowHeight[e]+t.rowHeight[i];t.rowHeight[e]=a,t.rowHeight[i]<n.height+t.verticalPadding&&(t.rowHeight[i]=n.height+t.verticalPadding);var l=t.rowHeight[e]+t.rowHeight[i];t.height+=l-h,this.shiftToLastRow(t)}},y.prototype.tilingPreLayout=function(){h.TILE&&(this.groupZeroDegreeMembers(),this.clearCompounds(),this.clearZeroDegreeMembers())},y.prototype.tilingPostLayout=function(){h.TILE&&(this.repopulateZeroDegreeMembers(),this.repopulateCompounds())},y.prototype.reduceTrees=function(){for(var t,e=[],i=!0;i;){var o=this.graphManager.getAllNodes(),n=[];i=!1;for(var r=0;r<o.length;r++)if(1==(t=o[r]).getEdges().length&&!t.getEdges()[0].isInterGraph&&null==t.getChild()){if(h.PURE_INCREMENTAL){var a=t.getEdges()[0].getOtherEnd(t),s=new f(t.getCenterX()-a.getCenterX(),t.getCenterY()-a.getCenterY());n.push([t,t.getEdges()[0],t.getOwner(),s])}else n.push([t,t.getEdges()[0],t.getOwner()]);i=!0}if(1==i){for(var l=[],d=0;d<n.length;d++)1==n[d][0].getEdges().length&&(l.push(n[d]),n[d][0].getOwner().remove(n[d][0]));e.push(l),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()}}this.prunedNodesAll=e},y.prototype.growTree=function(t){for(var e,i=t[t.length-1],o=0;o<i.length;o++)e=i[o],this.findPlaceforPrunedNode(e),e[2].add(e[0]),e[2].add(e[1],e[1].source,e[1].target);t.splice(t.length-1,1),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()},y.prototype.findPlaceforPrunedNode=function(t){var e,i,o=t[0];if(i=o==t[1].source?t[1].target:t[1].source,h.PURE_INCREMENTAL)o.setCenter(i.getCenterX()+t[3].getWidth(),i.getCenterY()+t[3].getHeight());else{var n=i.startX,r=i.finishX,a=i.startY,s=i.finishY,l=[0,0,0,0];if(a>0)for(var g=n;g<=r;g++)l[0]+=this.grid[g][a-1].length+this.grid[g][a].length-1;if(r<this.grid.length-1)for(g=a;g<=s;g++)l[1]+=this.grid[r+1][g].length+this.grid[r][g].length-1;if(s<this.grid[0].length-1)for(g=n;g<=r;g++)l[2]+=this.grid[g][s+1].length+this.grid[g][s].length-1;if(n>0)for(g=a;g<=s;g++)l[3]+=this.grid[n-1][g].length+this.grid[n][g].length-1;for(var c,p,f=m.MAX_VALUE,u=0;u<l.length;u++)l[u]<f?(f=l[u],c=1,p=u):l[u]==f&&c++;if(3==c&&0==f)0==l[0]&&0==l[1]&&0==l[2]?e=1:0==l[0]&&0==l[1]&&0==l[3]?e=0:0==l[0]&&0==l[2]&&0==l[3]?e=3:0==l[1]&&0==l[2]&&0==l[3]&&(e=2);else if(2==c&&0==f){var v=Math.floor(2*Math.random());e=0==l[0]&&0==l[1]?0==v?0:1:0==l[0]&&0==l[2]?0==v?0:2:0==l[0]&&0==l[3]?0==v?0:3:0==l[1]&&0==l[2]?0==v?1:2:0==l[1]&&0==l[3]?0==v?1:3:0==v?2:3}else e=4==c&&0==f?v=Math.floor(4*Math.random()):p;0==e?o.setCenter(i.getCenterX(),i.getCenterY()-i.getHeight()/2-d.DEFAULT_EDGE_LENGTH-o.getHeight()/2):1==e?o.setCenter(i.getCenterX()+i.getWidth()/2+d.DEFAULT_EDGE_LENGTH+o.getWidth()/2,i.getCenterY()):2==e?o.setCenter(i.getCenterX(),i.getCenterY()+i.getHeight()/2+d.DEFAULT_EDGE_LENGTH+o.getHeight()/2):o.setCenter(i.getCenterX()-i.getWidth()/2-d.DEFAULT_EDGE_LENGTH-o.getWidth()/2,i.getCenterY())}},t.exports=y},991:(t,e,i)=>{var o=i(551).FDLayoutNode,n=i(551).IMath;function r(t,e,i,n){o.call(this,t,e,i,n)}for(var a in r.prototype=Object.create(o.prototype),o)r[a]=o[a];r.prototype.calculateDisplacement=function(){var t=this.graphManager.getLayout();null!=this.getChild()&&this.fixedNodeWeight?(this.displacementX+=t.coolingFactor*(this.springForceX+this.repulsionForceX+this.gravitationForceX)/this.fixedNodeWeight,this.displacementY+=t.coolingFactor*(this.springForceY+this.repulsionForceY+this.gravitationForceY)/this.fixedNodeWeight):(this.displacementX+=t.coolingFactor*(this.springForceX+this.repulsionForceX+this.gravitationForceX)/this.noOfChildren,this.displacementY+=t.coolingFactor*(this.springForceY+this.repulsionForceY+this.gravitationForceY)/this.noOfChildren),Math.abs(this.displacementX)>t.coolingFactor*t.maxNodeDisplacement&&(this.displacementX=t.coolingFactor*t.maxNodeDisplacement*n.sign(this.displacementX)),Math.abs(this.displacementY)>t.coolingFactor*t.maxNodeDisplacement&&(this.displacementY=t.coolingFactor*t.maxNodeDisplacement*n.sign(this.displacementY)),this.child&&this.child.getNodes().length>0&&this.propogateDisplacementToChildren(this.displacementX,this.displacementY)},r.prototype.propogateDisplacementToChildren=function(t,e){for(var i,o=this.getChild().getNodes(),n=0;n<o.length;n++)null==(i=o[n]).getChild()?(i.displacementX+=t,i.displacementY+=e):i.propogateDisplacementToChildren(t,e)},r.prototype.move=function(){var t=this.graphManager.getLayout();null!=this.child&&0!=this.child.getNodes().length||(this.moveBy(this.displacementX,this.displacementY),t.totalDisplacement+=Math.abs(this.displacementX)+Math.abs(this.displacementY)),this.springForceX=0,this.springForceY=0,this.repulsionForceX=0,this.repulsionForceY=0,this.gravitationForceX=0,this.gravitationForceY=0,this.displacementX=0,this.displacementY=0},r.prototype.setPred1=function(t){this.pred1=t},r.prototype.getPred1=function(){return pred1},r.prototype.getPred2=function(){return pred2},r.prototype.setNext=function(t){this.next=t},r.prototype.getNext=function(){return next},r.prototype.setProcessed=function(t){this.processed=t},r.prototype.isProcessed=function(){return processed},t.exports=r},902:(t,e,i)=>{function o(t){if(Array.isArray(t)){for(var e=0,i=Array(t.length);e<t.length;e++)i[e]=t[e];return i}return Array.from(t)}var n=i(806),r=i(551).LinkedList,a=i(551).Matrix,s=i(551).SVD;function h(){}h.handleConstraints=function(t){var e={};e.fixedNodeConstraint=t.constraints.fixedNodeConstraint,e.alignmentConstraint=t.constraints.alignmentConstraint,e.relativePlacementConstraint=t.constraints.relativePlacementConstraint;for(var i=new Map,h=new Map,l=[],d=[],g=t.getAllNodes(),c=0,p=0;p<g.length;p++){var f=g[p];null==f.getChild()&&(h.set(f.id,c++),l.push(f.getCenterX()),d.push(f.getCenterY()),i.set(f.id,f))}e.relativePlacementConstraint&&e.relativePlacementConstraint.forEach((function(t){t.gap||0==t.gap||(t.left?t.gap=n.DEFAULT_EDGE_LENGTH+i.get(t.left).getWidth()/2+i.get(t.right).getWidth()/2:t.gap=n.DEFAULT_EDGE_LENGTH+i.get(t.top).getHeight()/2+i.get(t.bottom).getHeight()/2)}));var u=function(t){var e=0,i=0;return t.forEach((function(t){e+=l[h.get(t)],i+=d[h.get(t)]})),{x:e/t.size,y:i/t.size}},m=function(t,e,i,n,a){var s=new Map;t.forEach((function(t,e){s.set(e,0)})),t.forEach((function(t,e){t.forEach((function(t){s.set(t.id,s.get(t.id)+1)}))}));var g=new Map,c=new Map,p=new r;s.forEach((function(t,o){0==t?(p.push(o),i||("horizontal"==e?g.set(o,h.has(o)?l[h.get(o)]:n.get(o)):g.set(o,h.has(o)?d[h.get(o)]:n.get(o)))):g.set(o,Number.NEGATIVE_INFINITY),i&&c.set(o,new Set([o]))})),i&&a.forEach((function(t){var o=[];if(t.forEach((function(t){i.has(t)&&o.push(t)})),o.length>0){var r=0;o.forEach((function(t){"horizontal"==e?(g.set(t,h.has(t)?l[h.get(t)]:n.get(t)),r+=g.get(t)):(g.set(t,h.has(t)?d[h.get(t)]:n.get(t)),r+=g.get(t))})),r/=o.length,t.forEach((function(t){i.has(t)||g.set(t,r)}))}else{var a=0;t.forEach((function(t){a+="horizontal"==e?h.has(t)?l[h.get(t)]:n.get(t):h.has(t)?d[h.get(t)]:n.get(t)})),a/=t.length,t.forEach((function(t){g.set(t,a)}))}}));for(var f=function(){var o=p.shift();t.get(o).forEach((function(t){if(g.get(t.id)<g.get(o)+t.gap)if(i&&i.has(t.id)){var r=void 0;if(r="horizontal"==e?h.has(t.id)?l[h.get(t.id)]:n.get(t.id):h.has(t.id)?d[h.get(t.id)]:n.get(t.id),g.set(t.id,r),r<g.get(o)+t.gap){var a=g.get(o)+t.gap-r;c.get(o).forEach((function(t){g.set(t,g.get(t)-a)}))}}else g.set(t.id,g.get(o)+t.gap);s.set(t.id,s.get(t.id)-1),0==s.get(t.id)&&p.push(t.id),i&&c.set(t.id,function(t,e){var i=new Set(t),o=!0,n=!1,r=void 0;try{for(var a,s=e[Symbol.iterator]();!(o=(a=s.next()).done);o=!0){var h=a.value;i.add(h)}}catch(t){n=!0,r=t}finally{try{!o&&s.return&&s.return()}finally{if(n)throw r}}return i}(c.get(o),c.get(t.id)))}))};0!=p.length;)f();if(i){var u=new Set;t.forEach((function(t,e){0==t.length&&u.add(e)}));var m=[];c.forEach((function(t,e){if(u.has(e)){var n=!1,r=!0,a=!1,s=void 0;try{for(var h,l=t[Symbol.iterator]();!(r=(h=l.next()).done);r=!0){var d=h.value;i.has(d)&&(n=!0)}}catch(t){a=!0,s=t}finally{try{!r&&l.return&&l.return()}finally{if(a)throw s}}if(!n){var g=!1,c=void 0;m.forEach((function(e,i){e.has([].concat(o(t))[0])&&(g=!0,c=i)})),g?t.forEach((function(t){m[c].add(t)})):m.push(new Set(t))}}})),m.forEach((function(t,i){var o=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,s=Number.NEGATIVE_INFINITY,c=!0,p=!1,f=void 0;try{for(var u,m=t[Symbol.iterator]();!(c=(u=m.next()).done);c=!0){var v=u.value,T=void 0;T="horizontal"==e?h.has(v)?l[h.get(v)]:n.get(v):h.has(v)?d[h.get(v)]:n.get(v);var N=g.get(v);T<o&&(o=T),T>a&&(a=T),N<r&&(r=N),N>s&&(s=N)}}catch(t){p=!0,f=t}finally{try{!c&&m.return&&m.return()}finally{if(p)throw f}}var E=(o+a)/2-(r+s)/2,y=!0,C=!1,M=void 0;try{for(var w,A=t[Symbol.iterator]();!(y=(w=A.next()).done);y=!0){var I=w.value;g.set(I,g.get(I)+E)}}catch(t){C=!0,M=t}finally{try{!y&&A.return&&A.return()}finally{if(C)throw M}}}))}return g},v=function(t){var e=0,i=0,o=0,n=0;if(t.forEach((function(t){t.left?l[h.get(t.left)]-l[h.get(t.right)]>=0?e++:i++:d[h.get(t.top)]-d[h.get(t.bottom)]>=0?o++:n++})),e>i&&o>n)for(var r=0;r<h.size;r++)l[r]=-1*l[r],d[r]=-1*d[r];else if(e>i)for(var a=0;a<h.size;a++)l[a]=-1*l[a];else if(o>n)for(var s=0;s<h.size;s++)d[s]=-1*d[s]},T=function(t){var e=[],i=new r,o=new Set,n=0;return t.forEach((function(r,a){if(!o.has(a)){e[n]=[];var s=a;for(i.push(s),o.add(s),e[n].push(s);0!=i.length;)s=i.shift(),t.get(s).forEach((function(t){o.has(t.id)||(i.push(t.id),o.add(t.id),e[n].push(t.id))}));n++}})),e},N=function(t){var e=new Map;return t.forEach((function(t,i){e.set(i,[])})),t.forEach((function(t,i){t.forEach((function(t){e.get(i).push(t),e.get(t.id).push({id:i,gap:t.gap,direction:t.direction})}))})),e},E=function(t){var e=new Map;return t.forEach((function(t,i){e.set(i,[])})),t.forEach((function(t,i){t.forEach((function(t){e.get(t.id).push({id:i,gap:t.gap,direction:t.direction})}))})),e},y=[],C=[],M=!1,w=!1,A=new Set,I=new Map,L=new Map,b=[];if(e.fixedNodeConstraint&&e.fixedNodeConstraint.forEach((function(t){A.add(t.nodeId)})),e.relativePlacementConstraint&&(e.relativePlacementConstraint.forEach((function(t){t.left?(I.has(t.left)?I.get(t.left).push({id:t.right,gap:t.gap,direction:"horizontal"}):I.set(t.left,[{id:t.right,gap:t.gap,direction:"horizontal"}]),I.has(t.right)||I.set(t.right,[])):(I.has(t.top)?I.get(t.top).push({id:t.bottom,gap:t.gap,direction:"vertical"}):I.set(t.top,[{id:t.bottom,gap:t.gap,direction:"vertical"}]),I.has(t.bottom)||I.set(t.bottom,[]))})),L=N(I),b=T(L)),n.TRANSFORM_ON_CONSTRAINT_HANDLING){if(e.fixedNodeConstraint&&e.fixedNodeConstraint.length>1)e.fixedNodeConstraint.forEach((function(t,e){y[e]=[t.position.x,t.position.y],C[e]=[l[h.get(t.nodeId)],d[h.get(t.nodeId)]]})),M=!0;else if(e.alignmentConstraint)!function(){var t=0;if(e.alignmentConstraint.vertical){for(var i=e.alignmentConstraint.vertical,n=function(e){var n=new Set;i[e].forEach((function(t){n.add(t)}));var r=new Set([].concat(o(n)).filter((function(t){return A.has(t)}))),a=void 0;a=r.size>0?l[h.get(r.values().next().value)]:u(n).x,i[e].forEach((function(e){y[t]=[a,d[h.get(e)]],C[t]=[l[h.get(e)],d[h.get(e)]],t++}))},r=0;r<i.length;r++)n(r);M=!0}if(e.alignmentConstraint.horizontal){for(var a=e.alignmentConstraint.horizontal,s=function(e){var i=new Set;a[e].forEach((function(t){i.add(t)}));var n=new Set([].concat(o(i)).filter((function(t){return A.has(t)}))),r=void 0;r=n.size>0?l[h.get(n.values().next().value)]:u(i).y,a[e].forEach((function(e){y[t]=[l[h.get(e)],r],C[t]=[l[h.get(e)],d[h.get(e)]],t++}))},g=0;g<a.length;g++)s(g);M=!0}e.relativePlacementConstraint&&(w=!0)}();else if(e.relativePlacementConstraint){for(var _=0,F=0,R=0;R<b.length;R++)b[R].length>_&&(_=b[R].length,F=R);if(_<L.size/2)v(e.relativePlacementConstraint),M=!1,w=!1;else{var O=new Map,P=new Map,x=[];b[F].forEach((function(t){I.get(t).forEach((function(e){"horizontal"==e.direction?(O.has(t)?O.get(t).push(e):O.set(t,[e]),O.has(e.id)||O.set(e.id,[]),x.push({left:t,right:e.id})):(P.has(t)?P.get(t).push(e):P.set(t,[e]),P.has(e.id)||P.set(e.id,[]),x.push({top:t,bottom:e.id}))}))})),v(x),w=!1;var D=m(O,"horizontal"),H=m(P,"vertical");b[F].forEach((function(t,e){C[e]=[l[h.get(t)],d[h.get(t)]],y[e]=[],D.has(t)?y[e][0]=D.get(t):y[e][0]=l[h.get(t)],H.has(t)?y[e][1]=H.get(t):y[e][1]=d[h.get(t)]})),M=!0}}if(M){for(var G,z=a.transpose(y),S=a.transpose(C),V=0;V<z.length;V++)z[V]=a.multGamma(z[V]),S[V]=a.multGamma(S[V]);var W=a.multMat(z,a.transpose(S)),Y=s.svd(W);G=a.multMat(Y.V,a.transpose(Y.U));for(var X=0;X<h.size;X++){var U=[l[X],d[X]],B=[G[0][0],G[1][0]],k=[G[0][1],G[1][1]];l[X]=a.dotProduct(U,B),d[X]=a.dotProduct(U,k)}w&&v(e.relativePlacementConstraint)}}if(n.ENFORCE_CONSTRAINTS){if(e.fixedNodeConstraint&&e.fixedNodeConstraint.length>0){var j={x:0,y:0};e.fixedNodeConstraint.forEach((function(t,e){var i,o,n={x:l[h.get(t.nodeId)],y:d[h.get(t.nodeId)]},r=t.position,a=(o=n,{x:(i=r).x-o.x,y:i.y-o.y});j.x+=a.x,j.y+=a.y})),j.x/=e.fixedNodeConstraint.length,j.y/=e.fixedNodeConstraint.length,l.forEach((function(t,e){l[e]+=j.x})),d.forEach((function(t,e){d[e]+=j.y})),e.fixedNodeConstraint.forEach((function(t){l[h.get(t.nodeId)]=t.position.x,d[h.get(t.nodeId)]=t.position.y}))}if(e.alignmentConstraint){if(e.alignmentConstraint.vertical)for(var Z=e.alignmentConstraint.vertical,q=function(t){var e=new Set;Z[t].forEach((function(t){e.add(t)}));var i=new Set([].concat(o(e)).filter((function(t){return A.has(t)}))),n=void 0;n=i.size>0?l[h.get(i.values().next().value)]:u(e).x,e.forEach((function(t){A.has(t)||(l[h.get(t)]=n)}))},K=0;K<Z.length;K++)q(K);if(e.alignmentConstraint.horizontal)for(var Q=e.alignmentConstraint.horizontal,J=function(t){var e=new Set;Q[t].forEach((function(t){e.add(t)}));var i=new Set([].concat(o(e)).filter((function(t){return A.has(t)}))),n=void 0;n=i.size>0?d[h.get(i.values().next().value)]:u(e).y,e.forEach((function(t){A.has(t)||(d[h.get(t)]=n)}))},$=0;$<Q.length;$++)J($)}e.relativePlacementConstraint&&function(){var t=new Map,i=new Map,o=new Map,n=new Map,r=new Map,a=new Map,s=new Set,g=new Set;if(A.forEach((function(t){s.add(t),g.add(t)})),e.alignmentConstraint){if(e.alignmentConstraint.vertical)for(var c=e.alignmentConstraint.vertical,p=function(e){o.set("dummy"+e,[]),c[e].forEach((function(i){t.set(i,"dummy"+e),o.get("dummy"+e).push(i),A.has(i)&&s.add("dummy"+e)})),r.set("dummy"+e,l[h.get(c[e][0])])},f=0;f<c.length;f++)p(f);if(e.alignmentConstraint.horizontal)for(var u=e.alignmentConstraint.horizontal,v=function(t){n.set("dummy"+t,[]),u[t].forEach((function(e){i.set(e,"dummy"+t),n.get("dummy"+t).push(e),A.has(e)&&g.add("dummy"+t)})),a.set("dummy"+t,d[h.get(u[t][0])])},y=0;y<u.length;y++)v(y)}var C=new Map,M=new Map,w=function(e){I.get(e).forEach((function(o){var n=void 0,r=void 0;"horizontal"==o.direction?(n=t.get(e)?t.get(e):e,r=t.get(o.id)?{id:t.get(o.id),gap:o.gap,direction:o.direction}:o,C.has(n)?C.get(n).push(r):C.set(n,[r]),C.has(r.id)||C.set(r.id,[])):(n=i.get(e)?i.get(e):e,r=i.get(o.id)?{id:i.get(o.id),gap:o.gap,direction:o.direction}:o,M.has(n)?M.get(n).push(r):M.set(n,[r]),M.has(r.id)||M.set(r.id,[]))}))},L=!0,b=!1,_=void 0;try{for(var F,R=I.keys()[Symbol.iterator]();!(L=(F=R.next()).done);L=!0)w(F.value)}catch(t){b=!0,_=t}finally{try{!L&&R.return&&R.return()}finally{if(b)throw _}}var O=N(C),P=N(M),x=T(O),D=T(P),H=E(C),G=E(M),z=[],S=[];x.forEach((function(t,e){z[e]=[],t.forEach((function(t){0==H.get(t).length&&z[e].push(t)}))})),D.forEach((function(t,e){S[e]=[],t.forEach((function(t){0==G.get(t).length&&S[e].push(t)}))}));var V=m(C,"horizontal",s,r,z),W=m(M,"vertical",g,a,S),Y=function(t){o.get(t)?o.get(t).forEach((function(e){l[h.get(e)]=V.get(t)})):l[h.get(t)]=V.get(t)},X=!0,U=!1,B=void 0;try{for(var k,j=V.keys()[Symbol.iterator]();!(X=(k=j.next()).done);X=!0)Y(k.value)}catch(t){U=!0,B=t}finally{try{!X&&j.return&&j.return()}finally{if(U)throw B}}var Z=function(t){n.get(t)?n.get(t).forEach((function(e){d[h.get(e)]=W.get(t)})):d[h.get(t)]=W.get(t)},q=!0,K=!1,Q=void 0;try{for(var J,$=W.keys()[Symbol.iterator]();!(q=(J=$.next()).done);q=!0)Z(J.value)}catch(t){K=!0,Q=t}finally{try{!q&&$.return&&$.return()}finally{if(K)throw Q}}}()}for(var tt=0;tt<g.length;tt++){var et=g[tt];null==et.getChild()&&et.setCenter(l[h.get(et.id)],d[h.get(et.id)])}},t.exports=h},551:e=>{e.exports=t}},i={},o=function t(o){var n=i[o];if(void 0!==n)return n.exports;var r=i[o]={exports:{}};return e[o](r,r.exports,t),r.exports}(45),o;var e,i,o},t.exports=n(i())),e.exports;var t,n}e.exports;export{n as __require};
1
+ import{commonjsGlobal as t}from"../../../../../_virtual/_commonjsHelpers.js";import{__module as e}from"../../../../../_virtual/cose-base2.js";import{__require as i}from"../../../layout-base@2.0.1/node_modules/layout-base/layout-base.js";var o;function n(){return o||(o=1,t=e,e.exports,n=function(t){return e={45:(t,e,i)=>{var o={};o.layoutBase=i(551),o.CoSEConstants=i(806),o.CoSEEdge=i(767),o.CoSEGraph=i(880),o.CoSEGraphManager=i(578),o.CoSELayout=i(765),o.CoSENode=i(991),o.ConstraintHandler=i(902),t.exports=o},806:(t,e,i)=>{var o=i(551).FDLayoutConstants;function n(){}for(var r in o)n[r]=o[r];n.DEFAULT_USE_MULTI_LEVEL_SCALING=!1,n.DEFAULT_RADIAL_SEPARATION=o.DEFAULT_EDGE_LENGTH,n.DEFAULT_COMPONENT_SEPERATION=60,n.TILE=!0,n.TILING_PADDING_VERTICAL=10,n.TILING_PADDING_HORIZONTAL=10,n.TRANSFORM_ON_CONSTRAINT_HANDLING=!0,n.ENFORCE_CONSTRAINTS=!0,n.APPLY_LAYOUT=!0,n.RELAX_MOVEMENT_ON_CONSTRAINTS=!0,n.TREE_REDUCTION_ON_INCREMENTAL=!0,n.PURE_INCREMENTAL=n.DEFAULT_INCREMENTAL,t.exports=n},767:(t,e,i)=>{var o=i(551).FDLayoutEdge;function n(t,e,i){o.call(this,t,e,i)}for(var r in n.prototype=Object.create(o.prototype),o)n[r]=o[r];t.exports=n},880:(t,e,i)=>{var o=i(551).LGraph;function n(t,e,i){o.call(this,t,e,i)}for(var r in n.prototype=Object.create(o.prototype),o)n[r]=o[r];t.exports=n},578:(t,e,i)=>{var o=i(551).LGraphManager;function n(t){o.call(this,t)}for(var r in n.prototype=Object.create(o.prototype),o)n[r]=o[r];t.exports=n},765:(t,e,i)=>{var o=i(551).FDLayout,n=i(578),r=i(880),a=i(991),s=i(767),h=i(806),l=i(902),d=i(551).FDLayoutConstants,g=i(551).LayoutConstants,c=i(551).Point,p=i(551).PointD,f=i(551).DimensionD,u=i(551).Layout,m=i(551).Integer,v=i(551).IGeometry,T=i(551).LGraph,N=i(551).Transform,E=i(551).LinkedList;function y(){o.call(this),this.toBeTiled={},this.constraints={}}for(var C in y.prototype=Object.create(o.prototype),o)y[C]=o[C];y.prototype.newGraphManager=function(){var t=new n(this);return this.graphManager=t,t},y.prototype.newGraph=function(t){return new r(null,this.graphManager,t)},y.prototype.newNode=function(t){return new a(this.graphManager,t)},y.prototype.newEdge=function(t){return new s(null,null,t)},y.prototype.initParameters=function(){o.prototype.initParameters.call(this,arguments),this.isSubLayout||(h.DEFAULT_EDGE_LENGTH<10?this.idealEdgeLength=10:this.idealEdgeLength=h.DEFAULT_EDGE_LENGTH,this.useSmartIdealEdgeLengthCalculation=h.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION,this.gravityConstant=d.DEFAULT_GRAVITY_STRENGTH,this.compoundGravityConstant=d.DEFAULT_COMPOUND_GRAVITY_STRENGTH,this.gravityRangeFactor=d.DEFAULT_GRAVITY_RANGE_FACTOR,this.compoundGravityRangeFactor=d.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR,this.prunedNodesAll=[],this.growTreeIterations=0,this.afterGrowthIterations=0,this.isTreeGrowing=!1,this.isGrowthFinished=!1)},y.prototype.initSpringEmbedder=function(){o.prototype.initSpringEmbedder.call(this),this.coolingCycle=0,this.maxCoolingCycle=this.maxIterations/d.CONVERGENCE_CHECK_PERIOD,this.finalTemperature=.04,this.coolingAdjuster=1},y.prototype.layout=function(){return g.DEFAULT_CREATE_BENDS_AS_NEEDED&&(this.createBendpoints(),this.graphManager.resetAllEdges()),this.level=0,this.classicLayout()},y.prototype.classicLayout=function(){if(this.nodesWithGravity=this.calculateNodesToApplyGravitationTo(),this.graphManager.setAllNodesToApplyGravitation(this.nodesWithGravity),this.calcNoOfChildrenForAllNodes(),this.graphManager.calcLowestCommonAncestors(),this.graphManager.calcInclusionTreeDepths(),this.graphManager.getRoot().calcEstimatedSize(),this.calcIdealEdgeLengths(),this.incremental)h.TREE_REDUCTION_ON_INCREMENTAL&&(this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation(),e=new Set(this.getAllNodes()),i=this.nodesWithGravity.filter((function(t){return e.has(t)})),this.graphManager.setAllNodesToApplyGravitation(i));else{var t=this.getFlatForest();if(t.length>0)this.positionNodesRadially(t);else{this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation();var e=new Set(this.getAllNodes()),i=this.nodesWithGravity.filter((function(t){return e.has(t)}));this.graphManager.setAllNodesToApplyGravitation(i),this.positionNodesRandomly()}}return Object.keys(this.constraints).length>0&&(l.handleConstraints(this),this.initConstraintVariables()),this.initSpringEmbedder(),h.APPLY_LAYOUT&&this.runSpringEmbedder(),!0},y.prototype.tick=function(){if(this.totalIterations++,this.totalIterations===this.maxIterations&&!this.isTreeGrowing&&!this.isGrowthFinished){if(!(this.prunedNodesAll.length>0))return!0;this.isTreeGrowing=!0}if(this.totalIterations%d.CONVERGENCE_CHECK_PERIOD==0&&!this.isTreeGrowing&&!this.isGrowthFinished){if(this.isConverged()){if(!(this.prunedNodesAll.length>0))return!0;this.isTreeGrowing=!0}this.coolingCycle++,0==this.layoutQuality?this.coolingAdjuster=this.coolingCycle:1==this.layoutQuality&&(this.coolingAdjuster=this.coolingCycle/3),this.coolingFactor=Math.max(this.initialCoolingFactor-Math.pow(this.coolingCycle,Math.log(100*(this.initialCoolingFactor-this.finalTemperature))/Math.log(this.maxCoolingCycle))/100*this.coolingAdjuster,this.finalTemperature),this.animationPeriod=Math.ceil(this.initialAnimationPeriod*Math.sqrt(this.coolingFactor))}if(this.isTreeGrowing){if(this.growTreeIterations%10==0)if(this.prunedNodesAll.length>0){this.graphManager.updateBounds(),this.updateGrid(),this.growTree(this.prunedNodesAll),this.graphManager.resetAllNodesToApplyGravitation();var t=new Set(this.getAllNodes()),e=this.nodesWithGravity.filter((function(e){return t.has(e)}));this.graphManager.setAllNodesToApplyGravitation(e),this.graphManager.updateBounds(),this.updateGrid(),h.PURE_INCREMENTAL?this.coolingFactor=d.DEFAULT_COOLING_FACTOR_INCREMENTAL/2:this.coolingFactor=d.DEFAULT_COOLING_FACTOR_INCREMENTAL}else this.isTreeGrowing=!1,this.isGrowthFinished=!0;this.growTreeIterations++}if(this.isGrowthFinished){if(this.isConverged())return!0;this.afterGrowthIterations%10==0&&(this.graphManager.updateBounds(),this.updateGrid()),h.PURE_INCREMENTAL?this.coolingFactor=d.DEFAULT_COOLING_FACTOR_INCREMENTAL/2*((100-this.afterGrowthIterations)/100):this.coolingFactor=d.DEFAULT_COOLING_FACTOR_INCREMENTAL*((100-this.afterGrowthIterations)/100),this.afterGrowthIterations++}var i=!this.isTreeGrowing&&!this.isGrowthFinished,o=this.growTreeIterations%10==1&&this.isTreeGrowing||this.afterGrowthIterations%10==1&&this.isGrowthFinished;return this.totalDisplacement=0,this.graphManager.updateBounds(),this.calcSpringForces(),this.calcRepulsionForces(i,o),this.calcGravitationalForces(),this.moveNodes(),this.animate(),!1},y.prototype.getPositionsData=function(){for(var t=this.graphManager.getAllNodes(),e={},i=0;i<t.length;i++){var o=t[i].rect,n=t[i].id;e[n]={id:n,x:o.getCenterX(),y:o.getCenterY(),w:o.width,h:o.height}}return e},y.prototype.runSpringEmbedder=function(){this.initialAnimationPeriod=25,this.animationPeriod=this.initialAnimationPeriod;var t=!1;if("during"===d.ANIMATE)this.emit("layoutstarted");else{for(;!t;)t=this.tick();this.graphManager.updateBounds()}},y.prototype.moveNodes=function(){for(var t=this.getAllNodes(),e=0;e<t.length;e++)t[e].calculateDisplacement();for(Object.keys(this.constraints).length>0&&this.updateDisplacements(),e=0;e<t.length;e++)t[e].move()},y.prototype.initConstraintVariables=function(){var t=this;this.idToNodeMap=new Map,this.fixedNodeSet=new Set;for(var e=this.graphManager.getAllNodes(),i=0;i<e.length;i++){var o=e[i];this.idToNodeMap.set(o.id,o)}var n=function e(i){for(var o,n=i.getChild().getNodes(),r=0,a=0;a<n.length;a++)null==(o=n[a]).getChild()?t.fixedNodeSet.has(o.id)&&(r+=100):r+=e(o);return r};if(this.constraints.fixedNodeConstraint)for(this.constraints.fixedNodeConstraint.forEach((function(e){t.fixedNodeSet.add(e.nodeId)})),e=this.graphManager.getAllNodes(),i=0;i<e.length;i++)if(null!=(o=e[i]).getChild()){var r=n(o);r>0&&(o.fixedNodeWeight=r)}if(this.constraints.relativePlacementConstraint){var a=new Map,s=new Map;if(this.dummyToNodeForVerticalAlignment=new Map,this.dummyToNodeForHorizontalAlignment=new Map,this.fixedNodesOnHorizontal=new Set,this.fixedNodesOnVertical=new Set,this.fixedNodeSet.forEach((function(e){t.fixedNodesOnHorizontal.add(e),t.fixedNodesOnVertical.add(e)})),this.constraints.alignmentConstraint){if(this.constraints.alignmentConstraint.vertical){var l=this.constraints.alignmentConstraint.vertical;for(i=0;i<l.length;i++)this.dummyToNodeForVerticalAlignment.set("dummy"+i,[]),l[i].forEach((function(e){a.set(e,"dummy"+i),t.dummyToNodeForVerticalAlignment.get("dummy"+i).push(e),t.fixedNodeSet.has(e)&&t.fixedNodesOnHorizontal.add("dummy"+i)}))}if(this.constraints.alignmentConstraint.horizontal){var d=this.constraints.alignmentConstraint.horizontal;for(i=0;i<d.length;i++)this.dummyToNodeForHorizontalAlignment.set("dummy"+i,[]),d[i].forEach((function(e){s.set(e,"dummy"+i),t.dummyToNodeForHorizontalAlignment.get("dummy"+i).push(e),t.fixedNodeSet.has(e)&&t.fixedNodesOnVertical.add("dummy"+i)}))}}if(h.RELAX_MOVEMENT_ON_CONSTRAINTS)this.shuffle=function(t){var e,i,o;for(o=t.length-1;o>=2*t.length/3;o--)e=Math.floor(Math.random()*(o+1)),i=t[o],t[o]=t[e],t[e]=i;return t},this.nodesInRelativeHorizontal=[],this.nodesInRelativeVertical=[],this.nodeToRelativeConstraintMapHorizontal=new Map,this.nodeToRelativeConstraintMapVertical=new Map,this.nodeToTempPositionMapHorizontal=new Map,this.nodeToTempPositionMapVertical=new Map,this.constraints.relativePlacementConstraint.forEach((function(e){if(e.left){var i=a.has(e.left)?a.get(e.left):e.left,o=a.has(e.right)?a.get(e.right):e.right;t.nodesInRelativeHorizontal.includes(i)||(t.nodesInRelativeHorizontal.push(i),t.nodeToRelativeConstraintMapHorizontal.set(i,[]),t.dummyToNodeForVerticalAlignment.has(i)?t.nodeToTempPositionMapHorizontal.set(i,t.idToNodeMap.get(t.dummyToNodeForVerticalAlignment.get(i)[0]).getCenterX()):t.nodeToTempPositionMapHorizontal.set(i,t.idToNodeMap.get(i).getCenterX())),t.nodesInRelativeHorizontal.includes(o)||(t.nodesInRelativeHorizontal.push(o),t.nodeToRelativeConstraintMapHorizontal.set(o,[]),t.dummyToNodeForVerticalAlignment.has(o)?t.nodeToTempPositionMapHorizontal.set(o,t.idToNodeMap.get(t.dummyToNodeForVerticalAlignment.get(o)[0]).getCenterX()):t.nodeToTempPositionMapHorizontal.set(o,t.idToNodeMap.get(o).getCenterX())),t.nodeToRelativeConstraintMapHorizontal.get(i).push({right:o,gap:e.gap}),t.nodeToRelativeConstraintMapHorizontal.get(o).push({left:i,gap:e.gap})}else{var n=s.has(e.top)?s.get(e.top):e.top,r=s.has(e.bottom)?s.get(e.bottom):e.bottom;t.nodesInRelativeVertical.includes(n)||(t.nodesInRelativeVertical.push(n),t.nodeToRelativeConstraintMapVertical.set(n,[]),t.dummyToNodeForHorizontalAlignment.has(n)?t.nodeToTempPositionMapVertical.set(n,t.idToNodeMap.get(t.dummyToNodeForHorizontalAlignment.get(n)[0]).getCenterY()):t.nodeToTempPositionMapVertical.set(n,t.idToNodeMap.get(n).getCenterY())),t.nodesInRelativeVertical.includes(r)||(t.nodesInRelativeVertical.push(r),t.nodeToRelativeConstraintMapVertical.set(r,[]),t.dummyToNodeForHorizontalAlignment.has(r)?t.nodeToTempPositionMapVertical.set(r,t.idToNodeMap.get(t.dummyToNodeForHorizontalAlignment.get(r)[0]).getCenterY()):t.nodeToTempPositionMapVertical.set(r,t.idToNodeMap.get(r).getCenterY())),t.nodeToRelativeConstraintMapVertical.get(n).push({bottom:r,gap:e.gap}),t.nodeToRelativeConstraintMapVertical.get(r).push({top:n,gap:e.gap})}}));else{var g=new Map,c=new Map;this.constraints.relativePlacementConstraint.forEach((function(t){if(t.left){var e=a.has(t.left)?a.get(t.left):t.left,i=a.has(t.right)?a.get(t.right):t.right;g.has(e)?g.get(e).push(i):g.set(e,[i]),g.has(i)?g.get(i).push(e):g.set(i,[e])}else{var o=s.has(t.top)?s.get(t.top):t.top,n=s.has(t.bottom)?s.get(t.bottom):t.bottom;c.has(o)?c.get(o).push(n):c.set(o,[n]),c.has(n)?c.get(n).push(o):c.set(n,[o])}}));var p=function(t,e){var i=[],o=[],n=new E,r=new Set,a=0;return t.forEach((function(s,h){if(!r.has(h)){i[a]=[],o[a]=!1;var l=h;for(n.push(l),r.add(l),i[a].push(l);0!=n.length;)l=n.shift(),e.has(l)&&(o[a]=!0),t.get(l).forEach((function(t){r.has(t)||(n.push(t),r.add(t),i[a].push(t))}));a++}})),{components:i,isFixed:o}},f=p(g,t.fixedNodesOnHorizontal);this.componentsOnHorizontal=f.components,this.fixedComponentsOnHorizontal=f.isFixed;var u=p(c,t.fixedNodesOnVertical);this.componentsOnVertical=u.components,this.fixedComponentsOnVertical=u.isFixed}}},y.prototype.updateDisplacements=function(){var t=this;if(this.constraints.fixedNodeConstraint&&this.constraints.fixedNodeConstraint.forEach((function(e){var i=t.idToNodeMap.get(e.nodeId);i.displacementX=0,i.displacementY=0})),this.constraints.alignmentConstraint){if(this.constraints.alignmentConstraint.vertical)for(var e=this.constraints.alignmentConstraint.vertical,i=0;i<e.length;i++){for(var o=0,n=0;n<e[i].length;n++){if(this.fixedNodeSet.has(e[i][n])){o=0;break}o+=this.idToNodeMap.get(e[i][n]).displacementX}var r=o/e[i].length;for(n=0;n<e[i].length;n++)this.idToNodeMap.get(e[i][n]).displacementX=r}if(this.constraints.alignmentConstraint.horizontal){var a=this.constraints.alignmentConstraint.horizontal;for(i=0;i<a.length;i++){var s=0;for(n=0;n<a[i].length;n++){if(this.fixedNodeSet.has(a[i][n])){s=0;break}s+=this.idToNodeMap.get(a[i][n]).displacementY}var l=s/a[i].length;for(n=0;n<a[i].length;n++)this.idToNodeMap.get(a[i][n]).displacementY=l}}}if(this.constraints.relativePlacementConstraint)if(h.RELAX_MOVEMENT_ON_CONSTRAINTS)this.totalIterations%10==0&&(this.shuffle(this.nodesInRelativeHorizontal),this.shuffle(this.nodesInRelativeVertical)),this.nodesInRelativeHorizontal.forEach((function(e){if(!t.fixedNodesOnHorizontal.has(e)){var i=0;i=t.dummyToNodeForVerticalAlignment.has(e)?t.idToNodeMap.get(t.dummyToNodeForVerticalAlignment.get(e)[0]).displacementX:t.idToNodeMap.get(e).displacementX,t.nodeToRelativeConstraintMapHorizontal.get(e).forEach((function(o){var n;o.right?(n=t.nodeToTempPositionMapHorizontal.get(o.right)-t.nodeToTempPositionMapHorizontal.get(e)-i)<o.gap&&(i-=o.gap-n):(n=t.nodeToTempPositionMapHorizontal.get(e)-t.nodeToTempPositionMapHorizontal.get(o.left)+i)<o.gap&&(i+=o.gap-n)})),t.nodeToTempPositionMapHorizontal.set(e,t.nodeToTempPositionMapHorizontal.get(e)+i),t.dummyToNodeForVerticalAlignment.has(e)?t.dummyToNodeForVerticalAlignment.get(e).forEach((function(e){t.idToNodeMap.get(e).displacementX=i})):t.idToNodeMap.get(e).displacementX=i}})),this.nodesInRelativeVertical.forEach((function(e){if(!t.fixedNodesOnHorizontal.has(e)){var i=0;i=t.dummyToNodeForHorizontalAlignment.has(e)?t.idToNodeMap.get(t.dummyToNodeForHorizontalAlignment.get(e)[0]).displacementY:t.idToNodeMap.get(e).displacementY,t.nodeToRelativeConstraintMapVertical.get(e).forEach((function(o){var n;o.bottom?(n=t.nodeToTempPositionMapVertical.get(o.bottom)-t.nodeToTempPositionMapVertical.get(e)-i)<o.gap&&(i-=o.gap-n):(n=t.nodeToTempPositionMapVertical.get(e)-t.nodeToTempPositionMapVertical.get(o.top)+i)<o.gap&&(i+=o.gap-n)})),t.nodeToTempPositionMapVertical.set(e,t.nodeToTempPositionMapVertical.get(e)+i),t.dummyToNodeForHorizontalAlignment.has(e)?t.dummyToNodeForHorizontalAlignment.get(e).forEach((function(e){t.idToNodeMap.get(e).displacementY=i})):t.idToNodeMap.get(e).displacementY=i}}));else{for(i=0;i<this.componentsOnHorizontal.length;i++){var d=this.componentsOnHorizontal[i];if(this.fixedComponentsOnHorizontal[i])for(n=0;n<d.length;n++)this.dummyToNodeForVerticalAlignment.has(d[n])?this.dummyToNodeForVerticalAlignment.get(d[n]).forEach((function(e){t.idToNodeMap.get(e).displacementX=0})):this.idToNodeMap.get(d[n]).displacementX=0;else{var g=0,c=0;for(n=0;n<d.length;n++)this.dummyToNodeForVerticalAlignment.has(d[n])?(g+=(f=this.dummyToNodeForVerticalAlignment.get(d[n])).length*this.idToNodeMap.get(f[0]).displacementX,c+=f.length):(g+=this.idToNodeMap.get(d[n]).displacementX,c++);var p=g/c;for(n=0;n<d.length;n++)this.dummyToNodeForVerticalAlignment.has(d[n])?this.dummyToNodeForVerticalAlignment.get(d[n]).forEach((function(e){t.idToNodeMap.get(e).displacementX=p})):this.idToNodeMap.get(d[n]).displacementX=p}}for(i=0;i<this.componentsOnVertical.length;i++)if(d=this.componentsOnVertical[i],this.fixedComponentsOnVertical[i])for(n=0;n<d.length;n++)this.dummyToNodeForHorizontalAlignment.has(d[n])?this.dummyToNodeForHorizontalAlignment.get(d[n]).forEach((function(e){t.idToNodeMap.get(e).displacementY=0})):this.idToNodeMap.get(d[n]).displacementY=0;else{for(g=0,c=0,n=0;n<d.length;n++){var f;this.dummyToNodeForHorizontalAlignment.has(d[n])?(g+=(f=this.dummyToNodeForHorizontalAlignment.get(d[n])).length*this.idToNodeMap.get(f[0]).displacementY,c+=f.length):(g+=this.idToNodeMap.get(d[n]).displacementY,c++)}for(p=g/c,n=0;n<d.length;n++)this.dummyToNodeForHorizontalAlignment.has(d[n])?this.dummyToNodeForHorizontalAlignment.get(d[n]).forEach((function(e){t.idToNodeMap.get(e).displacementY=p})):this.idToNodeMap.get(d[n]).displacementY=p}}},y.prototype.calculateNodesToApplyGravitationTo=function(){var t,e,i=[],o=this.graphManager.getGraphs(),n=o.length;for(e=0;e<n;e++)(t=o[e]).updateConnected(),t.isConnected||(i=i.concat(t.getNodes()));return i},y.prototype.createBendpoints=function(){var t=[];t=t.concat(this.graphManager.getAllEdges());var e,i=new Set;for(e=0;e<t.length;e++){var o=t[e];if(!i.has(o)){var n=o.getSource(),r=o.getTarget();if(n==r)o.getBendpoints().push(new p),o.getBendpoints().push(new p),this.createDummyNodesForBendpoints(o),i.add(o);else{var a=[];if(a=(a=a.concat(n.getEdgeListToNode(r))).concat(r.getEdgeListToNode(n)),!i.has(a[0])){var s;if(a.length>1)for(s=0;s<a.length;s++){var h=a[s];h.getBendpoints().push(new p),this.createDummyNodesForBendpoints(h)}a.forEach((function(t){i.add(t)}))}}}if(i.size==t.length)break}},y.prototype.positionNodesRadially=function(t){for(var e=new c(0,0),i=Math.ceil(Math.sqrt(t.length)),o=0,n=0,r=0,a=new p(0,0),s=0;s<t.length;s++){s%i==0&&(r=0,n=o,0!=s&&(n+=h.DEFAULT_COMPONENT_SEPERATION),o=0);var l=t[s],d=u.findCenterOfTree(l);e.x=r,e.y=n,(a=y.radialLayout(l,d,e)).y>o&&(o=Math.floor(a.y)),r=Math.floor(a.x+h.DEFAULT_COMPONENT_SEPERATION)}this.transform(new p(g.WORLD_CENTER_X-a.x/2,g.WORLD_CENTER_Y-a.y/2))},y.radialLayout=function(t,e,i){var o=Math.max(this.maxDiagonalInTree(t),h.DEFAULT_RADIAL_SEPARATION);y.branchRadialLayout(e,null,0,359,0,o);var n=T.calculateBounds(t),r=new N;r.setDeviceOrgX(n.getMinX()),r.setDeviceOrgY(n.getMinY()),r.setWorldOrgX(i.x),r.setWorldOrgY(i.y);for(var a=0;a<t.length;a++)t[a].transform(r);var s=new p(n.getMaxX(),n.getMaxY());return r.inverseTransformPoint(s)},y.branchRadialLayout=function(t,e,i,o,n,r){var a=(o-i+1)/2;a<0&&(a+=180);var s=(a+i)%360*v.TWO_PI/360,h=n*Math.cos(s),l=n*Math.sin(s);t.setCenter(h,l);var d=[],g=(d=d.concat(t.getEdges())).length;null!=e&&g--;for(var c,p=0,f=d.length,u=t.getEdgesBetween(e);u.length>1;){var m=u[0];u.splice(0,1);var T=d.indexOf(m);T>=0&&d.splice(T,1),f--,g--}c=null!=e?(d.indexOf(u[0])+1)%f:0;for(var N=Math.abs(o-i)/g,E=c;p!=g;E=++E%f){var C=d[E].getOtherEnd(t);if(C!=e){var M=(i+p*N)%360,w=(M+N)%360;y.branchRadialLayout(C,t,M,w,n+r,r),p++}}},y.maxDiagonalInTree=function(t){for(var e=m.MIN_VALUE,i=0;i<t.length;i++){var o=t[i].getDiagonal();o>e&&(e=o)}return e},y.prototype.calcRepulsionRange=function(){return 2*(this.level+1)*this.idealEdgeLength},y.prototype.groupZeroDegreeMembers=function(){var t=this,e={};this.memberGroups={},this.idToDummyNode={};for(var i=[],o=this.graphManager.getAllNodes(),n=0;n<o.length;n++){var r=(s=o[n]).getParent();0!==this.getNodeDegreeWithChildren(s)||null!=r.id&&this.getToBeTiled(r)||i.push(s)}for(n=0;n<i.length;n++){var s,h=(s=i[n]).getParent().id;void 0===e[h]&&(e[h]=[]),e[h]=e[h].concat(s)}Object.keys(e).forEach((function(i){if(e[i].length>1){var o="DummyCompound_"+i;t.memberGroups[o]=e[i];var n=e[i][0].getParent(),r=new a(t.graphManager);r.id=o,r.paddingLeft=n.paddingLeft||0,r.paddingRight=n.paddingRight||0,r.paddingBottom=n.paddingBottom||0,r.paddingTop=n.paddingTop||0,t.idToDummyNode[o]=r;var s=t.getGraphManager().add(t.newGraph(),r),h=n.getChild();h.add(r);for(var l=0;l<e[i].length;l++){var d=e[i][l];h.remove(d),s.add(d)}}}))},y.prototype.clearCompounds=function(){var t={},e={};this.performDFSOnCompounds();for(var i=0;i<this.compoundOrder.length;i++)e[this.compoundOrder[i].id]=this.compoundOrder[i],t[this.compoundOrder[i].id]=[].concat(this.compoundOrder[i].getChild().getNodes()),this.graphManager.remove(this.compoundOrder[i].getChild()),this.compoundOrder[i].child=null;this.graphManager.resetAllNodes(),this.tileCompoundMembers(t,e)},y.prototype.clearZeroDegreeMembers=function(){var t=this,e=this.tiledZeroDegreePack=[];Object.keys(this.memberGroups).forEach((function(i){var o=t.idToDummyNode[i];if(e[i]=t.tileNodes(t.memberGroups[i],o.paddingLeft+o.paddingRight),o.rect.width=e[i].width,o.rect.height=e[i].height,o.setCenter(e[i].centerX,e[i].centerY),o.labelMarginLeft=0,o.labelMarginTop=0,h.NODE_DIMENSIONS_INCLUDE_LABELS){var n=o.rect.width,r=o.rect.height;o.labelWidth&&("left"==o.labelPosHorizontal?(o.rect.x-=o.labelWidth,o.setWidth(n+o.labelWidth),o.labelMarginLeft=o.labelWidth):"center"==o.labelPosHorizontal&&o.labelWidth>n?(o.rect.x-=(o.labelWidth-n)/2,o.setWidth(o.labelWidth),o.labelMarginLeft=(o.labelWidth-n)/2):"right"==o.labelPosHorizontal&&o.setWidth(n+o.labelWidth)),o.labelHeight&&("top"==o.labelPosVertical?(o.rect.y-=o.labelHeight,o.setHeight(r+o.labelHeight),o.labelMarginTop=o.labelHeight):"center"==o.labelPosVertical&&o.labelHeight>r?(o.rect.y-=(o.labelHeight-r)/2,o.setHeight(o.labelHeight),o.labelMarginTop=(o.labelHeight-r)/2):"bottom"==o.labelPosVertical&&o.setHeight(r+o.labelHeight))}}))},y.prototype.repopulateCompounds=function(){for(var t=this.compoundOrder.length-1;t>=0;t--){var e=this.compoundOrder[t],i=e.id,o=e.paddingLeft,n=e.paddingTop,r=e.labelMarginLeft,a=e.labelMarginTop;this.adjustLocations(this.tiledMemberPack[i],e.rect.x,e.rect.y,o,n,r,a)}},y.prototype.repopulateZeroDegreeMembers=function(){var t=this,e=this.tiledZeroDegreePack;Object.keys(e).forEach((function(i){var o=t.idToDummyNode[i],n=o.paddingLeft,r=o.paddingTop,a=o.labelMarginLeft,s=o.labelMarginTop;t.adjustLocations(e[i],o.rect.x,o.rect.y,n,r,a,s)}))},y.prototype.getToBeTiled=function(t){var e=t.id;if(null!=this.toBeTiled[e])return this.toBeTiled[e];var i=t.getChild();if(null==i)return this.toBeTiled[e]=!1,!1;for(var o=i.getNodes(),n=0;n<o.length;n++){var r=o[n];if(this.getNodeDegree(r)>0)return this.toBeTiled[e]=!1,!1;if(null!=r.getChild()){if(!this.getToBeTiled(r))return this.toBeTiled[e]=!1,!1}else this.toBeTiled[r.id]=!1}return this.toBeTiled[e]=!0,!0},y.prototype.getNodeDegree=function(t){t.id;for(var e=t.getEdges(),i=0,o=0;o<e.length;o++){var n=e[o];n.getSource().id!==n.getTarget().id&&(i+=1)}return i},y.prototype.getNodeDegreeWithChildren=function(t){var e=this.getNodeDegree(t);if(null==t.getChild())return e;for(var i=t.getChild().getNodes(),o=0;o<i.length;o++){var n=i[o];e+=this.getNodeDegreeWithChildren(n)}return e},y.prototype.performDFSOnCompounds=function(){this.compoundOrder=[],this.fillCompexOrderByDFS(this.graphManager.getRoot().getNodes())},y.prototype.fillCompexOrderByDFS=function(t){for(var e=0;e<t.length;e++){var i=t[e];null!=i.getChild()&&this.fillCompexOrderByDFS(i.getChild().getNodes()),this.getToBeTiled(i)&&this.compoundOrder.push(i)}},y.prototype.adjustLocations=function(t,e,i,o,n,r,a){i+=n+a;for(var s=e+=o+r,h=0;h<t.rows.length;h++){var l=t.rows[h];e=s;for(var d=0,g=0;g<l.length;g++){var c=l[g];c.rect.x=e,c.rect.y=i,e+=c.rect.width+t.horizontalPadding,c.rect.height>d&&(d=c.rect.height)}i+=d+t.verticalPadding}},y.prototype.tileCompoundMembers=function(t,e){var i=this;this.tiledMemberPack=[],Object.keys(t).forEach((function(o){var n=e[o];if(i.tiledMemberPack[o]=i.tileNodes(t[o],n.paddingLeft+n.paddingRight),n.rect.width=i.tiledMemberPack[o].width,n.rect.height=i.tiledMemberPack[o].height,n.setCenter(i.tiledMemberPack[o].centerX,i.tiledMemberPack[o].centerY),n.labelMarginLeft=0,n.labelMarginTop=0,h.NODE_DIMENSIONS_INCLUDE_LABELS){var r=n.rect.width,a=n.rect.height;n.labelWidth&&("left"==n.labelPosHorizontal?(n.rect.x-=n.labelWidth,n.setWidth(r+n.labelWidth),n.labelMarginLeft=n.labelWidth):"center"==n.labelPosHorizontal&&n.labelWidth>r?(n.rect.x-=(n.labelWidth-r)/2,n.setWidth(n.labelWidth),n.labelMarginLeft=(n.labelWidth-r)/2):"right"==n.labelPosHorizontal&&n.setWidth(r+n.labelWidth)),n.labelHeight&&("top"==n.labelPosVertical?(n.rect.y-=n.labelHeight,n.setHeight(a+n.labelHeight),n.labelMarginTop=n.labelHeight):"center"==n.labelPosVertical&&n.labelHeight>a?(n.rect.y-=(n.labelHeight-a)/2,n.setHeight(n.labelHeight),n.labelMarginTop=(n.labelHeight-a)/2):"bottom"==n.labelPosVertical&&n.setHeight(a+n.labelHeight))}}))},y.prototype.tileNodes=function(t,e){var i=this.tileNodesByFavoringDim(t,e,!0),o=this.tileNodesByFavoringDim(t,e,!1),n=this.getOrgRatio(i);return this.getOrgRatio(o)<n?o:i},y.prototype.getOrgRatio=function(t){var e=t.width/t.height;return e<1&&(e=1/e),e},y.prototype.calcIdealRowWidth=function(t,e){var i=h.TILING_PADDING_VERTICAL,o=h.TILING_PADDING_HORIZONTAL,n=t.length,r=0,a=0,s=0;t.forEach((function(t){r+=t.getWidth(),a+=t.getHeight(),t.getWidth()>s&&(s=t.getWidth())}));var l,d=r/n,g=a/n,c=Math.pow(i-o,2)+4*(d+o)*(g+i)*n,p=(o-i+Math.sqrt(c))/(2*(d+o));e?(l=Math.ceil(p))==p&&l++:l=Math.floor(p);var f=l*(d+o)-o;return s>f&&(f=s),f+=2*o},y.prototype.tileNodesByFavoringDim=function(t,e,i){var o=h.TILING_PADDING_VERTICAL,n=h.TILING_PADDING_HORIZONTAL,r=h.TILING_COMPARE_BY,a={rows:[],rowWidth:[],rowHeight:[],width:0,height:e,verticalPadding:o,horizontalPadding:n,centerX:0,centerY:0};r&&(a.idealRowWidth=this.calcIdealRowWidth(t,i));var s=function(t){return t.rect.width*t.rect.height},l=function(t,e){return s(e)-s(t)};t.sort((function(t,e){var i=l;return a.idealRowWidth?(i=r)(t.id,e.id):i(t,e)}));for(var d=0,g=0,c=0;c<t.length;c++)d+=(p=t[c]).getCenterX(),g+=p.getCenterY();for(a.centerX=d/t.length,a.centerY=g/t.length,c=0;c<t.length;c++){var p=t[c];if(0==a.rows.length)this.insertNodeToRow(a,p,0,e);else if(this.canAddHorizontal(a,p.rect.width,p.rect.height)){var f=a.rows.length-1;a.idealRowWidth||(f=this.getShortestRowIndex(a)),this.insertNodeToRow(a,p,f,e)}else this.insertNodeToRow(a,p,a.rows.length,e);this.shiftToLastRow(a)}return a},y.prototype.insertNodeToRow=function(t,e,i,o){var n=o;i==t.rows.length&&(t.rows.push([]),t.rowWidth.push(n),t.rowHeight.push(0));var r=t.rowWidth[i]+e.rect.width;t.rows[i].length>0&&(r+=t.horizontalPadding),t.rowWidth[i]=r,t.width<r&&(t.width=r);var a=e.rect.height;i>0&&(a+=t.verticalPadding);var s=0;a>t.rowHeight[i]&&(s=t.rowHeight[i],t.rowHeight[i]=a,s=t.rowHeight[i]-s),t.height+=s,t.rows[i].push(e)},y.prototype.getShortestRowIndex=function(t){for(var e=-1,i=Number.MAX_VALUE,o=0;o<t.rows.length;o++)t.rowWidth[o]<i&&(e=o,i=t.rowWidth[o]);return e},y.prototype.getLongestRowIndex=function(t){for(var e=-1,i=Number.MIN_VALUE,o=0;o<t.rows.length;o++)t.rowWidth[o]>i&&(e=o,i=t.rowWidth[o]);return e},y.prototype.canAddHorizontal=function(t,e,i){if(t.idealRowWidth){var o=t.rows.length-1;return t.rowWidth[o]+e+t.horizontalPadding<=t.idealRowWidth}var n=this.getShortestRowIndex(t);if(n<0)return!0;var r=t.rowWidth[n];if(r+t.horizontalPadding+e<=t.width)return!0;var a,s,h=0;return t.rowHeight[n]<i&&n>0&&(h=i+t.verticalPadding-t.rowHeight[n]),a=t.width-r>=e+t.horizontalPadding?(t.height+h)/(r+e+t.horizontalPadding):(t.height+h)/t.width,h=i+t.verticalPadding,(s=t.width<e?(t.height+h)/e:(t.height+h)/t.width)<1&&(s=1/s),a<1&&(a=1/a),a<s},y.prototype.shiftToLastRow=function(t){var e=this.getLongestRowIndex(t),i=t.rowWidth.length-1,o=t.rows[e],n=o[o.length-1],r=n.width+t.horizontalPadding;if(t.width-t.rowWidth[i]>r&&e!=i){o.splice(-1,1),t.rows[i].push(n),t.rowWidth[e]=t.rowWidth[e]-r,t.rowWidth[i]=t.rowWidth[i]+r,t.width=t.rowWidth[instance.getLongestRowIndex(t)];for(var a=Number.MIN_VALUE,s=0;s<o.length;s++)o[s].height>a&&(a=o[s].height);e>0&&(a+=t.verticalPadding);var h=t.rowHeight[e]+t.rowHeight[i];t.rowHeight[e]=a,t.rowHeight[i]<n.height+t.verticalPadding&&(t.rowHeight[i]=n.height+t.verticalPadding);var l=t.rowHeight[e]+t.rowHeight[i];t.height+=l-h,this.shiftToLastRow(t)}},y.prototype.tilingPreLayout=function(){h.TILE&&(this.groupZeroDegreeMembers(),this.clearCompounds(),this.clearZeroDegreeMembers())},y.prototype.tilingPostLayout=function(){h.TILE&&(this.repopulateZeroDegreeMembers(),this.repopulateCompounds())},y.prototype.reduceTrees=function(){for(var t,e=[],i=!0;i;){var o=this.graphManager.getAllNodes(),n=[];i=!1;for(var r=0;r<o.length;r++)if(1==(t=o[r]).getEdges().length&&!t.getEdges()[0].isInterGraph&&null==t.getChild()){if(h.PURE_INCREMENTAL){var a=t.getEdges()[0].getOtherEnd(t),s=new f(t.getCenterX()-a.getCenterX(),t.getCenterY()-a.getCenterY());n.push([t,t.getEdges()[0],t.getOwner(),s])}else n.push([t,t.getEdges()[0],t.getOwner()]);i=!0}if(1==i){for(var l=[],d=0;d<n.length;d++)1==n[d][0].getEdges().length&&(l.push(n[d]),n[d][0].getOwner().remove(n[d][0]));e.push(l),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()}}this.prunedNodesAll=e},y.prototype.growTree=function(t){for(var e,i=t[t.length-1],o=0;o<i.length;o++)e=i[o],this.findPlaceforPrunedNode(e),e[2].add(e[0]),e[2].add(e[1],e[1].source,e[1].target);t.splice(t.length-1,1),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()},y.prototype.findPlaceforPrunedNode=function(t){var e,i,o=t[0];if(i=o==t[1].source?t[1].target:t[1].source,h.PURE_INCREMENTAL)o.setCenter(i.getCenterX()+t[3].getWidth(),i.getCenterY()+t[3].getHeight());else{var n=i.startX,r=i.finishX,a=i.startY,s=i.finishY,l=[0,0,0,0];if(a>0)for(var g=n;g<=r;g++)l[0]+=this.grid[g][a-1].length+this.grid[g][a].length-1;if(r<this.grid.length-1)for(g=a;g<=s;g++)l[1]+=this.grid[r+1][g].length+this.grid[r][g].length-1;if(s<this.grid[0].length-1)for(g=n;g<=r;g++)l[2]+=this.grid[g][s+1].length+this.grid[g][s].length-1;if(n>0)for(g=a;g<=s;g++)l[3]+=this.grid[n-1][g].length+this.grid[n][g].length-1;for(var c,p,f=m.MAX_VALUE,u=0;u<l.length;u++)l[u]<f?(f=l[u],c=1,p=u):l[u]==f&&c++;if(3==c&&0==f)0==l[0]&&0==l[1]&&0==l[2]?e=1:0==l[0]&&0==l[1]&&0==l[3]?e=0:0==l[0]&&0==l[2]&&0==l[3]?e=3:0==l[1]&&0==l[2]&&0==l[3]&&(e=2);else if(2==c&&0==f){var v=Math.floor(2*Math.random());e=0==l[0]&&0==l[1]?0==v?0:1:0==l[0]&&0==l[2]?0==v?0:2:0==l[0]&&0==l[3]?0==v?0:3:0==l[1]&&0==l[2]?0==v?1:2:0==l[1]&&0==l[3]?0==v?1:3:0==v?2:3}else e=4==c&&0==f?v=Math.floor(4*Math.random()):p;0==e?o.setCenter(i.getCenterX(),i.getCenterY()-i.getHeight()/2-d.DEFAULT_EDGE_LENGTH-o.getHeight()/2):1==e?o.setCenter(i.getCenterX()+i.getWidth()/2+d.DEFAULT_EDGE_LENGTH+o.getWidth()/2,i.getCenterY()):2==e?o.setCenter(i.getCenterX(),i.getCenterY()+i.getHeight()/2+d.DEFAULT_EDGE_LENGTH+o.getHeight()/2):o.setCenter(i.getCenterX()-i.getWidth()/2-d.DEFAULT_EDGE_LENGTH-o.getWidth()/2,i.getCenterY())}},t.exports=y},991:(t,e,i)=>{var o=i(551).FDLayoutNode,n=i(551).IMath;function r(t,e,i,n){o.call(this,t,e,i,n)}for(var a in r.prototype=Object.create(o.prototype),o)r[a]=o[a];r.prototype.calculateDisplacement=function(){var t=this.graphManager.getLayout();null!=this.getChild()&&this.fixedNodeWeight?(this.displacementX+=t.coolingFactor*(this.springForceX+this.repulsionForceX+this.gravitationForceX)/this.fixedNodeWeight,this.displacementY+=t.coolingFactor*(this.springForceY+this.repulsionForceY+this.gravitationForceY)/this.fixedNodeWeight):(this.displacementX+=t.coolingFactor*(this.springForceX+this.repulsionForceX+this.gravitationForceX)/this.noOfChildren,this.displacementY+=t.coolingFactor*(this.springForceY+this.repulsionForceY+this.gravitationForceY)/this.noOfChildren),Math.abs(this.displacementX)>t.coolingFactor*t.maxNodeDisplacement&&(this.displacementX=t.coolingFactor*t.maxNodeDisplacement*n.sign(this.displacementX)),Math.abs(this.displacementY)>t.coolingFactor*t.maxNodeDisplacement&&(this.displacementY=t.coolingFactor*t.maxNodeDisplacement*n.sign(this.displacementY)),this.child&&this.child.getNodes().length>0&&this.propogateDisplacementToChildren(this.displacementX,this.displacementY)},r.prototype.propogateDisplacementToChildren=function(t,e){for(var i,o=this.getChild().getNodes(),n=0;n<o.length;n++)null==(i=o[n]).getChild()?(i.displacementX+=t,i.displacementY+=e):i.propogateDisplacementToChildren(t,e)},r.prototype.move=function(){var t=this.graphManager.getLayout();null!=this.child&&0!=this.child.getNodes().length||(this.moveBy(this.displacementX,this.displacementY),t.totalDisplacement+=Math.abs(this.displacementX)+Math.abs(this.displacementY)),this.springForceX=0,this.springForceY=0,this.repulsionForceX=0,this.repulsionForceY=0,this.gravitationForceX=0,this.gravitationForceY=0,this.displacementX=0,this.displacementY=0},r.prototype.setPred1=function(t){this.pred1=t},r.prototype.getPred1=function(){return pred1},r.prototype.getPred2=function(){return pred2},r.prototype.setNext=function(t){this.next=t},r.prototype.getNext=function(){return next},r.prototype.setProcessed=function(t){this.processed=t},r.prototype.isProcessed=function(){return processed},t.exports=r},902:(t,e,i)=>{function o(t){if(Array.isArray(t)){for(var e=0,i=Array(t.length);e<t.length;e++)i[e]=t[e];return i}return Array.from(t)}var n=i(806),r=i(551).LinkedList,a=i(551).Matrix,s=i(551).SVD;function h(){}h.handleConstraints=function(t){var e={};e.fixedNodeConstraint=t.constraints.fixedNodeConstraint,e.alignmentConstraint=t.constraints.alignmentConstraint,e.relativePlacementConstraint=t.constraints.relativePlacementConstraint;for(var i=new Map,h=new Map,l=[],d=[],g=t.getAllNodes(),c=0,p=0;p<g.length;p++){var f=g[p];null==f.getChild()&&(h.set(f.id,c++),l.push(f.getCenterX()),d.push(f.getCenterY()),i.set(f.id,f))}e.relativePlacementConstraint&&e.relativePlacementConstraint.forEach((function(t){t.gap||0==t.gap||(t.left?t.gap=n.DEFAULT_EDGE_LENGTH+i.get(t.left).getWidth()/2+i.get(t.right).getWidth()/2:t.gap=n.DEFAULT_EDGE_LENGTH+i.get(t.top).getHeight()/2+i.get(t.bottom).getHeight()/2)}));var u=function(t){var e=0,i=0;return t.forEach((function(t){e+=l[h.get(t)],i+=d[h.get(t)]})),{x:e/t.size,y:i/t.size}},m=function(t,e,i,n,a){var s=new Map;t.forEach((function(t,e){s.set(e,0)})),t.forEach((function(t,e){t.forEach((function(t){s.set(t.id,s.get(t.id)+1)}))}));var g=new Map,c=new Map,p=new r;s.forEach((function(t,o){0==t?(p.push(o),i||("horizontal"==e?g.set(o,h.has(o)?l[h.get(o)]:n.get(o)):g.set(o,h.has(o)?d[h.get(o)]:n.get(o)))):g.set(o,Number.NEGATIVE_INFINITY),i&&c.set(o,new Set([o]))})),i&&a.forEach((function(t){var o=[];if(t.forEach((function(t){i.has(t)&&o.push(t)})),o.length>0){var r=0;o.forEach((function(t){"horizontal"==e?(g.set(t,h.has(t)?l[h.get(t)]:n.get(t)),r+=g.get(t)):(g.set(t,h.has(t)?d[h.get(t)]:n.get(t)),r+=g.get(t))})),r/=o.length,t.forEach((function(t){i.has(t)||g.set(t,r)}))}else{var a=0;t.forEach((function(t){a+="horizontal"==e?h.has(t)?l[h.get(t)]:n.get(t):h.has(t)?d[h.get(t)]:n.get(t)})),a/=t.length,t.forEach((function(t){g.set(t,a)}))}}));for(var f=function(){var o=p.shift();t.get(o).forEach((function(t){if(g.get(t.id)<g.get(o)+t.gap)if(i&&i.has(t.id)){var r=void 0;if(r="horizontal"==e?h.has(t.id)?l[h.get(t.id)]:n.get(t.id):h.has(t.id)?d[h.get(t.id)]:n.get(t.id),g.set(t.id,r),r<g.get(o)+t.gap){var a=g.get(o)+t.gap-r;c.get(o).forEach((function(t){g.set(t,g.get(t)-a)}))}}else g.set(t.id,g.get(o)+t.gap);s.set(t.id,s.get(t.id)-1),0==s.get(t.id)&&p.push(t.id),i&&c.set(t.id,function(t,e){var i=new Set(t),o=!0,n=!1,r=void 0;try{for(var a,s=e[Symbol.iterator]();!(o=(a=s.next()).done);o=!0){var h=a.value;i.add(h)}}catch(t){n=!0,r=t}finally{try{!o&&s.return&&s.return()}finally{if(n)throw r}}return i}(c.get(o),c.get(t.id)))}))};0!=p.length;)f();if(i){var u=new Set;t.forEach((function(t,e){0==t.length&&u.add(e)}));var m=[];c.forEach((function(t,e){if(u.has(e)){var n=!1,r=!0,a=!1,s=void 0;try{for(var h,l=t[Symbol.iterator]();!(r=(h=l.next()).done);r=!0){var d=h.value;i.has(d)&&(n=!0)}}catch(t){a=!0,s=t}finally{try{!r&&l.return&&l.return()}finally{if(a)throw s}}if(!n){var g=!1,c=void 0;m.forEach((function(e,i){e.has([].concat(o(t))[0])&&(g=!0,c=i)})),g?t.forEach((function(t){m[c].add(t)})):m.push(new Set(t))}}})),m.forEach((function(t,i){var o=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,s=Number.NEGATIVE_INFINITY,c=!0,p=!1,f=void 0;try{for(var u,m=t[Symbol.iterator]();!(c=(u=m.next()).done);c=!0){var v=u.value,T=void 0;T="horizontal"==e?h.has(v)?l[h.get(v)]:n.get(v):h.has(v)?d[h.get(v)]:n.get(v);var N=g.get(v);T<o&&(o=T),T>a&&(a=T),N<r&&(r=N),N>s&&(s=N)}}catch(t){p=!0,f=t}finally{try{!c&&m.return&&m.return()}finally{if(p)throw f}}var E=(o+a)/2-(r+s)/2,y=!0,C=!1,M=void 0;try{for(var w,A=t[Symbol.iterator]();!(y=(w=A.next()).done);y=!0){var I=w.value;g.set(I,g.get(I)+E)}}catch(t){C=!0,M=t}finally{try{!y&&A.return&&A.return()}finally{if(C)throw M}}}))}return g},v=function(t){var e=0,i=0,o=0,n=0;if(t.forEach((function(t){t.left?l[h.get(t.left)]-l[h.get(t.right)]>=0?e++:i++:d[h.get(t.top)]-d[h.get(t.bottom)]>=0?o++:n++})),e>i&&o>n)for(var r=0;r<h.size;r++)l[r]=-1*l[r],d[r]=-1*d[r];else if(e>i)for(var a=0;a<h.size;a++)l[a]=-1*l[a];else if(o>n)for(var s=0;s<h.size;s++)d[s]=-1*d[s]},T=function(t){var e=[],i=new r,o=new Set,n=0;return t.forEach((function(r,a){if(!o.has(a)){e[n]=[];var s=a;for(i.push(s),o.add(s),e[n].push(s);0!=i.length;)s=i.shift(),t.get(s).forEach((function(t){o.has(t.id)||(i.push(t.id),o.add(t.id),e[n].push(t.id))}));n++}})),e},N=function(t){var e=new Map;return t.forEach((function(t,i){e.set(i,[])})),t.forEach((function(t,i){t.forEach((function(t){e.get(i).push(t),e.get(t.id).push({id:i,gap:t.gap,direction:t.direction})}))})),e},E=function(t){var e=new Map;return t.forEach((function(t,i){e.set(i,[])})),t.forEach((function(t,i){t.forEach((function(t){e.get(t.id).push({id:i,gap:t.gap,direction:t.direction})}))})),e},y=[],C=[],M=!1,w=!1,A=new Set,I=new Map,L=new Map,b=[];if(e.fixedNodeConstraint&&e.fixedNodeConstraint.forEach((function(t){A.add(t.nodeId)})),e.relativePlacementConstraint&&(e.relativePlacementConstraint.forEach((function(t){t.left?(I.has(t.left)?I.get(t.left).push({id:t.right,gap:t.gap,direction:"horizontal"}):I.set(t.left,[{id:t.right,gap:t.gap,direction:"horizontal"}]),I.has(t.right)||I.set(t.right,[])):(I.has(t.top)?I.get(t.top).push({id:t.bottom,gap:t.gap,direction:"vertical"}):I.set(t.top,[{id:t.bottom,gap:t.gap,direction:"vertical"}]),I.has(t.bottom)||I.set(t.bottom,[]))})),L=N(I),b=T(L)),n.TRANSFORM_ON_CONSTRAINT_HANDLING){if(e.fixedNodeConstraint&&e.fixedNodeConstraint.length>1)e.fixedNodeConstraint.forEach((function(t,e){y[e]=[t.position.x,t.position.y],C[e]=[l[h.get(t.nodeId)],d[h.get(t.nodeId)]]})),M=!0;else if(e.alignmentConstraint)!function(){var t=0;if(e.alignmentConstraint.vertical){for(var i=e.alignmentConstraint.vertical,n=function(e){var n=new Set;i[e].forEach((function(t){n.add(t)}));var r=new Set([].concat(o(n)).filter((function(t){return A.has(t)}))),a=void 0;a=r.size>0?l[h.get(r.values().next().value)]:u(n).x,i[e].forEach((function(e){y[t]=[a,d[h.get(e)]],C[t]=[l[h.get(e)],d[h.get(e)]],t++}))},r=0;r<i.length;r++)n(r);M=!0}if(e.alignmentConstraint.horizontal){for(var a=e.alignmentConstraint.horizontal,s=function(e){var i=new Set;a[e].forEach((function(t){i.add(t)}));var n=new Set([].concat(o(i)).filter((function(t){return A.has(t)}))),r=void 0;r=n.size>0?l[h.get(n.values().next().value)]:u(i).y,a[e].forEach((function(e){y[t]=[l[h.get(e)],r],C[t]=[l[h.get(e)],d[h.get(e)]],t++}))},g=0;g<a.length;g++)s(g);M=!0}e.relativePlacementConstraint&&(w=!0)}();else if(e.relativePlacementConstraint){for(var _=0,F=0,R=0;R<b.length;R++)b[R].length>_&&(_=b[R].length,F=R);if(_<L.size/2)v(e.relativePlacementConstraint),M=!1,w=!1;else{var O=new Map,P=new Map,x=[];b[F].forEach((function(t){I.get(t).forEach((function(e){"horizontal"==e.direction?(O.has(t)?O.get(t).push(e):O.set(t,[e]),O.has(e.id)||O.set(e.id,[]),x.push({left:t,right:e.id})):(P.has(t)?P.get(t).push(e):P.set(t,[e]),P.has(e.id)||P.set(e.id,[]),x.push({top:t,bottom:e.id}))}))})),v(x),w=!1;var D=m(O,"horizontal"),H=m(P,"vertical");b[F].forEach((function(t,e){C[e]=[l[h.get(t)],d[h.get(t)]],y[e]=[],D.has(t)?y[e][0]=D.get(t):y[e][0]=l[h.get(t)],H.has(t)?y[e][1]=H.get(t):y[e][1]=d[h.get(t)]})),M=!0}}if(M){for(var G,z=a.transpose(y),S=a.transpose(C),V=0;V<z.length;V++)z[V]=a.multGamma(z[V]),S[V]=a.multGamma(S[V]);var W=a.multMat(z,a.transpose(S)),Y=s.svd(W);G=a.multMat(Y.V,a.transpose(Y.U));for(var X=0;X<h.size;X++){var U=[l[X],d[X]],B=[G[0][0],G[1][0]],k=[G[0][1],G[1][1]];l[X]=a.dotProduct(U,B),d[X]=a.dotProduct(U,k)}w&&v(e.relativePlacementConstraint)}}if(n.ENFORCE_CONSTRAINTS){if(e.fixedNodeConstraint&&e.fixedNodeConstraint.length>0){var j={x:0,y:0};e.fixedNodeConstraint.forEach((function(t,e){var i,o,n={x:l[h.get(t.nodeId)],y:d[h.get(t.nodeId)]},r=t.position,a=(o=n,{x:(i=r).x-o.x,y:i.y-o.y});j.x+=a.x,j.y+=a.y})),j.x/=e.fixedNodeConstraint.length,j.y/=e.fixedNodeConstraint.length,l.forEach((function(t,e){l[e]+=j.x})),d.forEach((function(t,e){d[e]+=j.y})),e.fixedNodeConstraint.forEach((function(t){l[h.get(t.nodeId)]=t.position.x,d[h.get(t.nodeId)]=t.position.y}))}if(e.alignmentConstraint){if(e.alignmentConstraint.vertical)for(var Z=e.alignmentConstraint.vertical,q=function(t){var e=new Set;Z[t].forEach((function(t){e.add(t)}));var i=new Set([].concat(o(e)).filter((function(t){return A.has(t)}))),n=void 0;n=i.size>0?l[h.get(i.values().next().value)]:u(e).x,e.forEach((function(t){A.has(t)||(l[h.get(t)]=n)}))},K=0;K<Z.length;K++)q(K);if(e.alignmentConstraint.horizontal)for(var Q=e.alignmentConstraint.horizontal,J=function(t){var e=new Set;Q[t].forEach((function(t){e.add(t)}));var i=new Set([].concat(o(e)).filter((function(t){return A.has(t)}))),n=void 0;n=i.size>0?d[h.get(i.values().next().value)]:u(e).y,e.forEach((function(t){A.has(t)||(d[h.get(t)]=n)}))},$=0;$<Q.length;$++)J($)}e.relativePlacementConstraint&&function(){var t=new Map,i=new Map,o=new Map,n=new Map,r=new Map,a=new Map,s=new Set,g=new Set;if(A.forEach((function(t){s.add(t),g.add(t)})),e.alignmentConstraint){if(e.alignmentConstraint.vertical)for(var c=e.alignmentConstraint.vertical,p=function(e){o.set("dummy"+e,[]),c[e].forEach((function(i){t.set(i,"dummy"+e),o.get("dummy"+e).push(i),A.has(i)&&s.add("dummy"+e)})),r.set("dummy"+e,l[h.get(c[e][0])])},f=0;f<c.length;f++)p(f);if(e.alignmentConstraint.horizontal)for(var u=e.alignmentConstraint.horizontal,v=function(t){n.set("dummy"+t,[]),u[t].forEach((function(e){i.set(e,"dummy"+t),n.get("dummy"+t).push(e),A.has(e)&&g.add("dummy"+t)})),a.set("dummy"+t,d[h.get(u[t][0])])},y=0;y<u.length;y++)v(y)}var C=new Map,M=new Map,w=function(e){I.get(e).forEach((function(o){var n=void 0,r=void 0;"horizontal"==o.direction?(n=t.get(e)?t.get(e):e,r=t.get(o.id)?{id:t.get(o.id),gap:o.gap,direction:o.direction}:o,C.has(n)?C.get(n).push(r):C.set(n,[r]),C.has(r.id)||C.set(r.id,[])):(n=i.get(e)?i.get(e):e,r=i.get(o.id)?{id:i.get(o.id),gap:o.gap,direction:o.direction}:o,M.has(n)?M.get(n).push(r):M.set(n,[r]),M.has(r.id)||M.set(r.id,[]))}))},L=!0,b=!1,_=void 0;try{for(var F,R=I.keys()[Symbol.iterator]();!(L=(F=R.next()).done);L=!0)w(F.value)}catch(t){b=!0,_=t}finally{try{!L&&R.return&&R.return()}finally{if(b)throw _}}var O=N(C),P=N(M),x=T(O),D=T(P),H=E(C),G=E(M),z=[],S=[];x.forEach((function(t,e){z[e]=[],t.forEach((function(t){0==H.get(t).length&&z[e].push(t)}))})),D.forEach((function(t,e){S[e]=[],t.forEach((function(t){0==G.get(t).length&&S[e].push(t)}))}));var V=m(C,"horizontal",s,r,z),W=m(M,"vertical",g,a,S),Y=function(t){o.get(t)?o.get(t).forEach((function(e){l[h.get(e)]=V.get(t)})):l[h.get(t)]=V.get(t)},X=!0,U=!1,B=void 0;try{for(var k,j=V.keys()[Symbol.iterator]();!(X=(k=j.next()).done);X=!0)Y(k.value)}catch(t){U=!0,B=t}finally{try{!X&&j.return&&j.return()}finally{if(U)throw B}}var Z=function(t){n.get(t)?n.get(t).forEach((function(e){d[h.get(e)]=W.get(t)})):d[h.get(t)]=W.get(t)},q=!0,K=!1,Q=void 0;try{for(var J,$=W.keys()[Symbol.iterator]();!(q=(J=$.next()).done);q=!0)Z(J.value)}catch(t){K=!0,Q=t}finally{try{!q&&$.return&&$.return()}finally{if(K)throw Q}}}()}for(var tt=0;tt<g.length;tt++){var et=g[tt];null==et.getChild()&&et.setCenter(l[h.get(et.id)],d[h.get(et.id)])}},t.exports=h},551:e=>{e.exports=t}},i={},o=function t(o){var n=i[o];if(void 0!==n)return n.exports;var r=i[o]={exports:{}};return e[o](r,r.exports,t),r.exports}(45),o;var e,i,o},t.exports=n(i())),e.exports;var t,n}e.exports;export{n as __require};