@squeed/flow-sdk 2.0.21 → 2.0.22

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.
package/dist/index.cjs CHANGED
@@ -206,7 +206,7 @@
206
206
  font-size: 14px;
207
207
  margin-top: 8px;
208
208
  }
209
- `;function Kl({request:e,property:t,config:r,value:n,disabled:i}){var se,ue,we,pe,qe;const{callbacks:o,structured:s,references:a}=_.useContext(Sr),{themeColor:c}=Fe(),{background:u}=Ze(),l=_.useId(),d=t.type.kind==="object"||t.type.kind==="array"||t.type.kind==="json",h=n===void 0?"":d?JSON.stringify(n,null,2):String(n),[p,y]=_.useState(h),[m,g]=_.useState(""),[b,x]=_.useState(0),v=_.useRef(null),w=_.useRef(),[C,S]=_.useState(!1),[j,I]=_.useState(!1),[P,O]=_.useState(),T=((se=r.$options)==null?void 0:se.$source)==="callback",E=o.resolveFormOptions,{data:R,address:k,nodeAddress:M,nodeId:$}=e;_.useEffect(()=>(S(!1),I(!1),()=>{var Q;(Q=w.current)==null||Q.abort(),w.current=void 0}),[k,M,$,i,h,r.$control,(ue=r.$upload)==null?void 0:ue.accept,(we=r.$upload)==null?void 0:we.maxSizeBytes]);const q=_.useRef(R);q.current=R;const W=JSON.stringify([k,$,(pe=r.$options)!=null&&pe.$dependsOn?r.$options.$dependsOn.map(Q=>ke(R,Q)):ke(R,M)]);_.useEffect(()=>{y(h),g("")},[h,k,$]),_.useEffect(()=>{if(!T)return;const Q=new AbortController;return Promise.resolve().then(()=>{if(!E)throw new Error("No options resolver configured");return E({address:k,nodeAddress:M,nodeId:$,data:jt(q.current),signal:Q.signal})}).then(he=>{if(!Array.isArray(he)||he.some(me=>!me||typeof me.label!="string"||!["string","number","boolean"].includes(typeof me.value)&&me.value!==null))throw new Error("Invalid options response");Q.signal.aborted||O({key:W,options:he})}).catch(he=>{Q.signal.aborted||O({key:W,options:[],error:he instanceof Error?he.message:"Options unavailable"})}),()=>Q.abort()},[T,E,W,k,M,$,b]);const ie=T&&(P==null?void 0:P.key)!==W,ee=T?(P==null?void 0:P.key)===W?P.options:[]:t.type.kind==="null"?[{label:"Null",value:null}]:t.type.kind==="boolean"?[{label:"Yes",value:!0},{label:"No",value:!1}]:Xt(t.type),Y=t.type.kind==="array",fe=(r.$control==="upload"?"upload":s&&d||r.$control==="checkbox"?"pills":r.$control)??(ee?Y||t.type.kind==="boolean"?"pills":"select":t.type.kind==="boolean"?"checkbox":d?"textarea":"input"),ce=!t.optional||!!r.$requiredWhen&&Nn(r.$requiredWhen,R),L=ce?"Required":"Optional",V=fe!=="upload"&&!!(a!=null&&a.length)&&typeof n=="string"&&n.includes("{{"),G=m||T&&(P==null?void 0:P.key)===W&&P.error||!V&&Pr(t.type,n,ce),N=Cr(r.$label??k.split(".").pop()),ae=Q=>{var he;if(!(i||Object.is(Q,n)))try{(he=o.onFormChange)==null||he.call(o,{...e,previousValue:n,value:Q}),g("")}catch(me){g(me instanceof Error?me.message:"Unable to update field")}},ge=_.useRef(ae);_.useLayoutEffect(()=>{ge.current=ae});const ve=()=>{if(d){try{const Re=p===""&&t.optional?void 0:JSON.parse(p),$e=Pr(t.type,Re,ce);if($e){g($e);return}ae(Re)}catch{g("Enter valid JSON")}return}const Q=t.type.kind==="number"||t.type.kind==="integer",he=p===""&&t.optional?void 0:Q&&p!==""?Number(p):p,me=Pr(t.type,he,ce);if(Q&&me&&p!==""){g(me);return}ae(he)},K=async Q=>{var me,Re,$e;if(i||w.current||!Q.length)return;const he=new AbortController;w.current=he,g(""),S(!0);try{if(t.type.kind!=="string"&&!(t.type.kind==="array"&&t.type.items.kind==="string"))throw new Error("Uploads require a string or string-array field.");if(!Y&&Q.length!==1)throw new Error("Choose one file for this field.");if(!o.uploadFormFile)throw new Error("No file upload handler configured.");const Ge=(Re=(me=r.$upload)==null?void 0:me.accept)==null?void 0:Re.split(",").map(Ae=>Ae.trim().toLowerCase()).filter(Boolean);for(const Ae of Q){if((($e=r.$upload)==null?void 0:$e.maxSizeBytes)!==void 0&&Ae.size>r.$upload.maxSizeBytes)throw new Error(`${Ae.name} exceeds the file size limit.`);if(Ge!=null&&Ge.length&&!Ge.some(ye=>ye.startsWith(".")?Ae.name.toLowerCase().endsWith(ye):ye.endsWith("/*")?Ae.type.toLowerCase().startsWith(ye.slice(0,-1)):Ae.type.toLowerCase()===ye))throw new Error(`${Ae.name} is not an accepted file type.`)}const Ye=await Promise.all(Q.map(async Ae=>{const ye=await o.uploadFormFile({...e,data:jt(R),file:Ae,signal:he.signal});if(typeof ye!="string")throw new Error("Upload handler must return an HTTP or HTTPS URL.");let Me;try{Me=new URL(ye)}catch{throw new Error("Upload handler must return an HTTP or HTTPS URL.")}if(!["http:","https:"].includes(Me.protocol)||Me.username||Me.password)throw new Error("Upload handler must return an HTTP or HTTPS URL.");return ye}));if(he.signal.aborted||w.current!==he)return;const tr=Y?[...Array.isArray(n)?n:[],...Ye]:Ye[0],sr=Pr(t.type,tr,ce);if(sr)throw new Error(sr);ge.current(tr)}catch(Ge){he.signal.aborted||g(Ge instanceof Error?Ge.message:"Unable to upload file."),he.abort()}finally{w.current===he&&(w.current=void 0,S(!1))}},te={id:l,disabled:i,"aria-label":N,"aria-required":ce,"aria-invalid":!!G,"aria-describedby":G?`${l}-error`:void 0},U=be(c);return f.jsxs("div",{"data-form-field":k,"data-flow-property":k.slice(M.length+1),children:[f.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[f.jsxs("label",{htmlFor:l,children:[N,ce?" *":""]}),t.optional&&n!==void 0&&f.jsx("button",{type:"button","aria-label":`Reset ${N}`,title:`Reset ${N}`,disabled:i||C,style:{width:24,height:24,padding:0,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:0,background:"transparent",color:"inherit"},onClick:()=>ae(void 0),children:f.jsx(J.PiArrowCounterClockwise,{size:14})})]}),!!(a!=null&&a.length)&&!d&&fe!=="upload"&&f.jsx(q0,{label:N,value:n,references:a,disabled:i,onChange:ae}),fe==="upload"?f.jsxs("div",{"data-form-upload":Y?"multiple":"single","aria-busy":C,style:{"--flow-upload-surface":be(u),outline:j?"2px dashed var(--flow-form-input-background)":void 0,borderRadius:"var(--flow-form-input-radius)"},onDragOver:Q=>{Q.preventDefault(),Q.stopPropagation(),!i&&!C&&(Q.dataTransfer.dropEffect="copy",I(!0))},onDragLeave:Q=>{Q.currentTarget.contains(Q.relatedTarget)||I(!1)},onDrop:Q=>{Q.preventDefault(),Q.stopPropagation(),I(!1),K(Array.from(Q.dataTransfer.files))},children:[f.jsx("input",{ref:v,type:"file",hidden:!0,"aria-label":`Upload ${N}`,accept:(qe=r.$upload)==null?void 0:qe.accept,multiple:Y,disabled:i||C,onChange:Q=>{const he=Array.from(Q.target.files??[]);Q.target.value="",K(he)}}),f.jsxs("div",{"data-upload-items":"",children:[(Y?Array.isArray(n)?n:[]:n?[n]:[]).map((Q,he)=>f.jsxs("div",{"data-upload-preview":"",children:[typeof Q=="string"&&Gr(Q)&&f.jsxs("a",{href:Q,target:"_blank",rel:"noopener noreferrer","aria-label":`${N} file ${he+1}`,children:[f.jsx(J.PiFile,{size:32,"aria-hidden":"true"}),f.jsx(Mr,{name:Q,size:120,onError:me=>{me.currentTarget.style.visibility="hidden"}})]}),f.jsxs("div",{"data-upload-actions":"",children:[!Y&&f.jsx(Se,{"aria-label":`Replace ${N}`,title:`Replace ${N}`,icon:f.jsx(J.PiUploadSimple,{}),size:"xs",variant:"ghost",disabled:i||C,onClick:()=>{var me;return(me=v.current)==null?void 0:me.click()}}),f.jsx(Se,{"aria-label":`Remove ${N} file ${he+1}`,title:"Remove file",icon:f.jsx(J.PiTrash,{}),size:"xs",variant:"ghost",disabled:i||C,onClick:()=>ae(Y&&Array.isArray(n)?n.filter((me,Re)=>Re!==he):"")})]})]},`${he}:${Q}`)),(Y||!n)&&f.jsx("button",{...te,type:"button","data-upload-drop":"",title:`Upload ${N}`,disabled:i||C,onClick:()=>{var Q;return(Q=v.current)==null?void 0:Q.click()},children:f.jsx(J.PiPlus,{size:28,"aria-hidden":"true"})})]}),C&&f.jsx("span",{role:"status",children:"Uploading..."})]}):V?null:fe==="select"?f.jsx("div",{"data-form-select":"",children:f.jsxs(mr,{...te,disabled:i||ie||!!(P!=null&&P.error),labelCase:"preserve",value:String((ee==null?void 0:ee.findIndex(Q=>Object.is(Q.value,n)))??-1),onValueChange:Q=>{const he=ee==null?void 0:ee[Number(Q)];he&&ae(he.value)},children:[f.jsx("option",{value:-1,disabled:!0,children:n!==void 0&&n!==""?String(n):L}),ee==null?void 0:ee.map((Q,he)=>f.jsx("option",{value:he,children:Cr(Q.label)||Q.label},he))]})}):fe==="pills"?f.jsxs("div",{id:l,role:"group","aria-label":N,"aria-describedby":te["aria-describedby"],style:{display:"flex",flexWrap:"wrap",gap:8},children:[ee==null?void 0:ee.map((Q,he)=>{const me=Y?Array.isArray(n)&&n.includes(Q.value):Object.is(n,Q.value);return f.jsx("button",{type:"button",disabled:i||ie,"aria-pressed":me,style:{padding:"8px 16px",borderRadius:24,border:0,color:me?U:"inherit",background:me?"color-mix(in srgb, currentColor 12%, transparent)":"color-mix(in srgb, currentColor 7%, transparent)"},onClick:()=>ae(Y?me?n.filter(Re=>Re!==Q.value):[...Array.isArray(n)?n:[],Q.value]:Q.value),children:Cr(Q.label)||Q.label},he)}),ie&&f.jsx("span",{role:"status",children:"Loading..."})]}):fe==="textarea"?f.jsx("textarea",{...te,placeholder:L,value:p,onChange:Q=>y(Q.target.value),onBlur:ve}):f.jsx("input",{...te,placeholder:L,type:t.type.kind==="number"||t.type.kind==="integer"?"number":"text",step:t.type.kind==="integer"?1:"any",value:p,onChange:Q=>y(Q.target.value),onBlur:ve,onKeyDown:Q=>{Q.key==="Enter"&&ve(),Q.key==="Escape"&&y(n===void 0?"":String(n))}}),G&&f.jsx("div",{role:"alert",id:`${l}-error`,children:G}),T&&(P==null?void 0:P.error)&&f.jsx("button",{type:"button",disabled:i,onClick:()=>{O(void 0),x(b+1)},children:"Retry"})]})}function km({nodeAddress:e,structured:t=!1}){return t?f.jsx(N0,{nodeAddress:e},e):f.jsx(Nu,{nodeAddress:e})}function N0({nodeAddress:e}){var d,h,p;const t=_.useContext(Sr),[r,n]=_.useState([]),i=((d=t.structured)==null?void 0:d.sourceSchema)??t.schema,o=((h=t.structured)==null?void 0:h.sourceBindings)??t.bindings,s=_.useMemo(()=>{if(!(!t.data||!i||!o))return Em(t.data,o,i,[{data:{id:e,type:"objectView"}}])},[t.data,o,i,e]);if(!s)return f.jsx(Nu,{nodeAddress:e});const a=r.findIndex(y=>!s.containers.has(y)),c=a<0?r:r.slice(0,a),u=c.at(-1)??e,l=(p=[...s.slots.values()].find(y=>y.nodeId===u))==null?void 0:p.label;return f.jsxs(Sr.Provider,{value:{...t,structured:s,schema:s.schema,bindings:s.bindings,renderForm:void 0,onFieldCreate:u===e?t.onFieldCreate:void 0},children:[!!c.length&&f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[f.jsx(Se,{"aria-label":"Back to parent fields",title:"Back to parent fields",icon:f.jsx(J.PiArrowLeft,{size:18}),size:"sm",variant:"ghost",onClick:()=>n(c.slice(0,-1))}),f.jsx("strong",{style:{minWidth:0,overflowWrap:"anywhere"},children:Cr(l)})]}),f.jsx(Nu,{nodeAddress:u,onOpen:y=>n([...c,y])},u)]})}function Nu({nodeAddress:e,onOpen:t}){var S,j;const{data:r,schema:n,callbacks:i,bindings:o,editable:s,renderForm:a,structured:c}=_.useContext(Sr),{readOnly:u,config:l,colorMode:d}=Fe(),h=a==null?void 0:a(e);if(h!==void 0)return f.jsx("fieldset",{"data-flow-form":e,disabled:u||l.editable===!1||!s,style:{border:0,margin:0,padding:0,minWidth:0},children:h});if(!r)return f.jsx(xn,{$colorMode:d,role:"alert",children:"Forms require a JSON document."});const p=o?dn(o,e,n):void 0,y=o?p:n&&Tt(r,e,n);if(!y)return f.jsx(xn,{$colorMode:d,role:"status",children:"Form schema unavailable."});const m=(p==null?void 0:p.address)??e,g=ke(r,m),b=(S=c==null?void 0:c.containers.get(e))==null?void 0:S.scalar;if(g===void 0||typeof g!="object"&&!b)return f.jsx(xn,{$colorMode:d,role:"alert",children:"Bound form state is unavailable."});const x=Object.entries(y.type.properties).filter(([I])=>{var P;return Nn((P=y.fields[I])==null?void 0:P.$visibleWhen,r)}),v=x.length>8||x.some(([I])=>{var P;return(P=y.fields[I])==null?void 0:P.$section}),w=new Map;for(const I of x){const[P,O]=I,T=v?Cr(((j=y.fields[P])==null?void 0:j.$section)??(O.type.kind==="object"||O.type.kind==="array"?P:O.optional?"Options":"General")):"";w.has(T)||w.set(T,[]),w.get(T).push(I)}const C=([I,P])=>f.jsx(Kl,{request:{data:r,address:b?m:`${m}.${I}`,nodeAddress:m,nodeId:typeof(g==null?void 0:g.id)=="string"?g.id:void 0},property:P,config:y.fields[I]??{},value:b?g:g==null?void 0:g[I],disabled:u||l.editable===!1||!(s??!!i.onJsonChange)},`${(g==null?void 0:g.id)??e}:${I}`);return f.jsxs(xn,{$colorMode:d,"data-flow-form":e,onClick:I=>I.stopPropagation(),onDoubleClick:I=>I.stopPropagation(),children:[c&&f.jsx($0,{nodeAddress:e,onOpen:t}),!c&&p&&y.type.additionalProperties&&x.length===0&&f.jsx(Kl,{request:{data:r,address:m,nodeAddress:m},property:{type:y.type,optional:!1},config:{$label:"Configuration",$control:"textarea"},value:g,disabled:u||l.editable===!1||!s}),[...w].map(([I,P])=>v&&P.length>1?f.jsxs("details",{open:!0,children:[f.jsxs("summary",{children:[f.jsx("span",{children:I}),f.jsx(J.PiCaretDown,{size:16,"aria-hidden":"true"})]}),P.map(C)]},I):P.map(C))]})}function Rm(e){const{viewData:t}=_.useContext(Sr),{nodeById:r,edgeById:n,parentIds:i}=Qr();if(t){const o=ke(t,e),s=o&&typeof o=="object"&&!Array.isArray(o)&&"$"in o?o.$:o;return Array.isArray(s)?s.length>0:!!s&&typeof s=="object"&&Object.entries(s).some(([a,c])=>!a.startsWith("$")&&c!==null&&typeof c=="object")}return i.has(e)?!0:[...n.values()].some(({data:o})=>{const s=o.isInverted?o.target:o.source,a=o.isInverted?o.source:o.target;return s===e&&a!==e&&r.has(a)})}function cn(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:t}function Rn(e,t,r,n){return{borderColor:t,borderWidth:cn(e==null?void 0:e.borderWidth,n),borderStyle:(e==null?void 0:e.borderStyle)??"solid",...Ly(t==="transparent"?"currentColor":t,r,".flow-sdk-node:hover &",!r)}}function Pm({label:e,value:t,options:r,onChange:n,disabled:i}){var o;return f.jsxs(mr,{"aria-label":e,title:`Animation: ${((o=r.find(s=>s.value===t))==null?void 0:o.label)??"Mixed"}`,value:t,style:{width:104},disabled:i,onValueChange:s=>{const a=r.find(c=>c.value===s);a&&n(a.value)},children:[t===""&&f.jsx("option",{value:"",disabled:!0,children:"Mixed"}),r.map(s=>f.jsx("option",{value:s.value,children:s.label},s.value))]})}function el({nodeId:e,edgeId:t,value:r,open:n,onOpenChange:i}){const{callbacks:o,readOnly:s,themeColor:a,colorMode:c}=Fe(),{background:u,backgroundSecondary:l,border:d,colorText:h,colorInactive:p}=Ze(),y=c==="dark"?Pt:be(p),m=_.useRef(null),g=_.useRef(null),b=_.useRef(0),[x,v]=_.useState(!1),[w,C]=_.useState("icons"),[S,j]=_.useState([]),[I,P]=_.useState("loading"),[O,T]=_.useState(""),[E,R]=_.useState(0),[k,M]=_.useState(""),[$,q]=_.useState(""),[W,ie]=_.useState(!1);_.useEffect(()=>()=>{b.current++},[]),_.useEffect(()=>{if(!x)return;let N=!0;return import("react-icons/pi").then(ae=>{N&&(j(Object.keys(ae).filter(ge=>ge.startsWith("Pi")).sort()),P("ready"))}).catch(()=>{N&&P("unavailable")}),()=>{N=!1}},[x]),_.useEffect(()=>{var N;s&&((N=m.current)==null||N.close())},[s]),_.useEffect(()=>{var N,ae,ge;if(n!==void 0){if(!n||s){(N=m.current)==null||N.close();return}(ae=m.current)!=null&&ae.open||(q(""),C(r==="PiFileSvg"||r&&Gr(r)?"custom":"icons"),M(r&&!r.startsWith(Qt)&&Gr(r)?r:""),v(!0),(ge=m.current)==null||ge.showModal())}},[n,s,r]);const ee=N=>{var ae,ge,ve;s||(t?(ae=o.onEdgeIconChange)==null||ae.call(o,t,N):e&&((ge=o.onNodeIconChange)==null||ge.call(o,e,N)),i==null||i(!1),(ve=m.current)==null||ve.close())},Y=S.filter(N=>N.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase().includes(O.trim().toLowerCase())),fe=36,ce=Math.max(1,Math.ceil(Y.length/fe)),L=Math.min(E,ce-1),V=Y.slice(L*fe,(L+1)*fe),G={width:"100%",padding:"8px 14px",background:"transparent",color:"inherit",border:`1px solid ${be(d)}`,borderRadius:30};return f.jsxs(f.Fragment,{children:[n===void 0&&f.jsx(Oe,{label:t?"Choose edge icon":"Choose node icon",children:f.jsx(Se,{"aria-label":t?"Choose edge icon":"Choose node icon",icon:f.jsx(J.PiShapes,{size:20}),size:"sm",variant:"ghost",color:be(a),disabled:s,onClick:()=>{var N;q(""),C(r&&Gr(r)?"custom":"icons"),M(r&&!r.startsWith(Qt)&&Gr(r)?r:""),v(!0),(N=m.current)==null||N.showModal()}})}),f.jsx(B.chakra.dialog,{ref:m,"aria-label":t?"Choose edge icon":"Choose node icon",css:Jr(be(u),be(d)),onClose:()=>{v(!1),i==null||i(!1),b.current++,ie(!1)},onClick:N=>{N.stopPropagation(),N.target===N.currentTarget&&N.currentTarget.close()},onKeyDown:N=>N.stopPropagation(),style:{margin:"auto",padding:12,width:336,maxWidth:"calc(100vw - 32px)",maxHeight:"calc(100vh - 32px)",overflowY:"auto",borderRadius:30,background:be(u),color:be(h)},children:x&&f.jsxs("div",{style:{display:"grid",gap:8},children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[f.jsx("strong",{children:t?"Edge icon":"Node icon"}),f.jsxs("div",{style:{display:"flex",alignItems:"center",marginLeft:"auto",gap:4},children:[r&&f.jsx(Oe,{label:"Remove icon",children:f.jsx(Se,{"aria-label":t?"Remove edge icon":"Remove node icon",icon:f.jsx(J.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:s||W,onClick:()=>ee("")})}),f.jsx(At,{"aria-label":"Close icon picker",onClick:()=>{var N;return(N=m.current)==null?void 0:N.close()}})]})]}),f.jsxs(B.Tabs.Root,{value:w,onValueChange:({value:N})=>{C(N),q("")},display:"contents",css:{"--indicator-thickness":"1px"},children:[f.jsx(B.Tabs.List,{"aria-label":"Icon source",width:"100%",borderBottomWidth:0,children:["icons","custom"].map(N=>f.jsx(B.Tabs.Trigger,{value:N,flex:1,minW:0,justifyContent:"center",px:3,py:2,fontSize:"13px",_selected:{color:a,borderColor:y,"--indicator-color":y},children:N==="icons"?"React icons":"Custom SVG"},N))}),f.jsx("input",{ref:g,type:"file",accept:".svg,image/svg+xml","aria-label":"Upload SVG icon",hidden:!0,disabled:W||s,onChange:async N=>{var ve;const ae=(ve=N.target.files)==null?void 0:ve[0];if(N.target.value="",!ae)return;const ge=++b.current;ie(!0),q("");try{const K=await k0(ae);ge===b.current&&ee(K)}catch(K){ge===b.current&&q(K instanceof Error?K.message:"Unable to read SVG.")}finally{ge===b.current&&ie(!1)}}}),f.jsx(B.Tabs.Content,{value:w,p:0,style:{display:"grid",gap:8},children:w==="icons"?f.jsxs(f.Fragment,{children:[f.jsx("input",{"aria-label":"Search icons",placeholder:"Search icons...",value:O,onChange:N=>{T(N.target.value),R(0)},style:G}),f.jsxs("div",{style:{height:244,overflowY:"auto",display:"grid",gridTemplateColumns:"repeat(6, minmax(0, 1fr))",gridAutoRows:36,gap:4},children:[V.map(N=>f.jsx("button",{type:"button","aria-label":`Choose ${N}`,"aria-pressed":r===N,title:N,onClick:()=>ee(N),style:{display:"grid",placeItems:"center",borderRadius:5,border:`${r===N?2:1}px solid ${be(r===N?a:d)}`,background:be(r===N?u:l),color:"inherit",cursor:"pointer"},children:f.jsx(Mr,{name:N,size:24})},N)),V.length===0&&f.jsx("span",{role:"status",style:{gridColumn:"1 / -1"},children:I==="loading"?"Loading icons...":I==="unavailable"?"React icons unavailable":"No icons found"})]}),f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[f.jsxs("span",{role:"status",style:{fontSize:12},children:[Y.length," icons · ",L+1," / ",ce]}),f.jsxs("div",{style:{display:"flex",gap:4},children:[f.jsx(Oe,{label:"Previous icons",children:f.jsx(Se,{"aria-label":"Previous icons",icon:f.jsx(J.PiCaretLeft,{size:18}),size:"sm",variant:"ghost",disabled:L===0,onClick:()=>R(L-1)})}),f.jsx(Oe,{label:"Next icons",children:f.jsx(Se,{"aria-label":"Next icons",icon:f.jsx(J.PiCaretRight,{size:18}),size:"sm",variant:"ghost",disabled:L+1>=ce,onClick:()=>R(L+1)})})]})]})]}):f.jsxs(f.Fragment,{children:[r&&Gr(r)&&f.jsx(Mr,{name:r,size:64}),f.jsxs("button",{type:"button",disabled:W||s,onClick:()=>{var N;return(N=g.current)==null?void 0:N.click()},style:{...G,display:"flex",justifyContent:"center",gap:8,alignItems:"center",cursor:"pointer"},children:[f.jsx(J.PiUploadSimple,{}),W?"Uploading...":"Upload SVG"]}),f.jsxs("form",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},onSubmit:N=>{N.preventDefault(),!(W||s)&&(!Gr(k.trim())||k.trim().startsWith(Qt)?q("Enter an HTTP or HTTPS image URL."):ee(k.trim()))},children:[f.jsx("input",{type:"url","aria-label":"SVG URL",placeholder:"https://example.com/icon.svg",value:k,disabled:W||s,onChange:N=>M(N.target.value),style:{...G,flex:1,minWidth:0}}),f.jsx(Oe,{label:"Apply URL",children:f.jsx(Se,{type:"submit","aria-label":"Apply URL",icon:f.jsx(J.PiArrowRight,{size:20}),size:"sm",variant:"ghost",disabled:W||s||!k.trim(),style:{flexShrink:0}})})]})]})})]}),$&&f.jsx("div",{role:"alert",style:{fontSize:13},children:$})]})})]})}const Pn=["white","blue.500","teal.500","green.500","yellow.500","orange.500","red.500","purple.500","pink.500","gray.500",Pt],Am=["gray.900",Pt,"gray.600","gray.200","white"];function Tm(){const{config:e}=Fe(),t=e.selectionToolbar||{},r=new Set(t.hide||[]);return{palette:t.palette||Pn,show:n=>!r.has(n)}}function gr(){const{border:e}=Ze();return f.jsx(B.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:e})}function ut({value:e,placeholder:t,ariaLabel:r,width:n="140px",type:i="text",min:o,onCommit:s}){const{colorText:a}=Ze(),[c,u]=_.useState(e),l=_.useRef(!1);_.useEffect(()=>u(e),[e]);const d=()=>{if(l.current)return;l.current=!0;const h=c.trim();if(i==="number"&&h!==""&&(!Number.isFinite(Number(h))||Number(h)<(o??0))){u(e);return}h!==e&&s(h)};return f.jsx(B.Input,{"aria-label":r,type:i,min:o,size:"xs",fontSize:"16px",w:n,value:c,placeholder:t,color:a,borderWidth:0,_focusVisible:{boxShadow:"none",outline:"none"},borderRadius:"8px",onFocus:()=>{l.current=!1},onChange:h=>u(h.target.value),onBlur:d,onKeyDown:h=>{h.key==="Enter"&&(d(),h.target.blur()),h.key==="Escape"&&(l.current=!0,u(e),h.target.blur())}})}function lt({colors:e,value:t,label:r,onPick:n,onReset:i,includeTransparent:o=!0}){const{colorInactive:s,colorText:a}=Ze(),[c,u]=_.useState(!1),l=_.useId(),d=_.useRef(null),h=t??e[0]??"transparent",p=On(f.jsx(lt,{colors:e,value:t,label:r,onPick:n,onReset:i,includeTransparent:o}));return f.jsx(Et.Provider,{value:null,children:f.jsxs(B.HStack,{gap:1,"aria-label":r,role:"group",onClickCapture:p,onKeyDown:y=>{var m;y.key==="Escape"&&(u(!1),(m=d.current)==null||m.focus())},children:[f.jsx(Oe,{label:`${r}: ${h}`,children:f.jsx(B.chakra.button,{ref:d,type:"button","aria-label":`${r} colors`,"aria-expanded":c,"aria-controls":l,w:4,h:4,flexShrink:0,borderRadius:"full",cursor:"pointer",style:{backgroundColor:be(h),...h==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:`2px solid ${be(a)}`,outlineOffset:"1px",onClick:()=>u(y=>!y)})}),c&&f.jsxs(B.HStack,{id:l,gap:1,children:[[...new Set([...e,...o?["transparent"]:[]])].map(y=>{const m=t===y;return f.jsx(Oe,{label:`${r}: ${y}`,children:f.jsx(B.Box,{as:"button","aria-label":`${r} ${y}`,"aria-pressed":m,w:4,h:4,borderRadius:"full",cursor:"pointer",style:{backgroundColor:be(y),...y==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:m?`2px solid ${be(a)}`:"none",outlineOffset:"1px",_hover:{transform:"scale(1.15)"},onClick:()=>n(y),onDoubleClick:g=>{var b;g.stopPropagation(),u(!1),(b=d.current)==null||b.focus()}})},y)}),i&&f.jsx(Oe,{label:`Reset ${r.toLowerCase()}`,children:f.jsx(Se,{"aria-label":`Reset ${r}`,icon:f.jsx(B.Icon,{as:J.PiEraser,boxSize:4}),size:"xs",variant:"ghost",color:s,onClick:()=>{var y;i(),u(!1),(y=d.current)==null||y.focus()}})})]})]})})}function Im({edgeId:e,onClose:t}){var p;const{callbacks:r,themeColor:n,config:i}=Fe(),{colorInactive:o}=Ze(),{edgeById:s}=Qr(),{palette:a,show:c}=Tm(),u=(p=s.get(e))==null?void 0:p.data,l=[...new Set(["rounded-orthogonal","orthogonal","straight","bezier",...Object.keys(i.customEdgeTypes??{}),...u!=null&&u.type?[u.type]:[]])],d=u!=null&&u.isEdgeAnimated?"animated":u!=null&&u.isEdgeDashed?"dashed":"solid",h=[{key:"solid",icon:J.PiLineSegment,label:"Solid"},{key:"dashed",icon:J.PiLineSegments,label:"Dashed"},{key:"animated",icon:J.PiFastForward,label:"Animated"}];return f.jsxs(f.Fragment,{children:[f.jsx(At,{onClick:t}),c("label")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(ut,{ariaLabel:"Edge label",placeholder:"Edge label",value:(u==null?void 0:u.label)||"",onCommit:y=>{var m;return(m=r.onEdgeLabelChange)==null?void 0:m.call(r,e,y)}})]}),c("style")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),h.map(y=>f.jsx(Oe,{label:y.label,children:f.jsx(Se,{"aria-label":`Edge style ${y.key}`,"aria-pressed":d===y.key,icon:f.jsx(B.Icon,{as:y.icon,boxSize:5}),size:"sm",variant:"ghost",color:d===y.key?n:o,onClick:()=>{var m;return(m=r.onEdgeStyleChange)==null?void 0:m.call(r,e,y.key)}})},y.key)),d==="animated"&&f.jsx(Pm,{label:"Edge animation",value:(u==null?void 0:u.edgeAnimationVariant)??"dashed",options:[{value:"dashed",label:"Dash"},{value:"traveling",label:"Trace"}],disabled:i.readOnly,onChange:y=>{var m;return(m=r.onEdgeAnimationVariantChange)==null?void 0:m.call(r,e,y)}}),f.jsxs(mr,{"aria-label":"Edge shape",title:`Edge shape: ${(u==null?void 0:u.type)??"Default"}`,icon:f.jsx(J.PiBezierCurve,{size:20}),style:{width:36},value:(u==null?void 0:u.type)??"",disabled:i.readOnly,onValueChange:y=>{var m;return(m=r.onEdgeTypeChange)==null?void 0:m.call(r,e,y||void 0)},children:[f.jsx("option",{value:"",children:"Default"}),l.map(y=>f.jsx("option",{value:y,children:y},y))]})]}),c("icon")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(el,{edgeId:e,value:u==null?void 0:u.icon},e),f.jsx(ut,{ariaLabel:"Edge icon",placeholder:"Icon name or SVG URL",value:(u==null?void 0:u.icon)??"",onCommit:y=>{var m;return(m=r.onEdgeIconChange)==null?void 0:m.call(r,e,y)}})]}),c("color")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(lt,{label:"Edge color",colors:a,value:u==null?void 0:u.color,onPick:y=>{var m;return(m=r.onEdgeColorChange)==null?void 0:m.call(r,e,y)},onReset:()=>{var y;return(y=r.onEdgeColorChange)==null?void 0:y.call(r,e,"")}})]}),c("delete")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(Oe,{label:"Delete edge",children:f.jsx(Se,{"aria-label":"Delete edge",icon:f.jsx(B.Icon,{as:J.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:"red.400",onClick:()=>{var y;(y=r.onEdgeDelete)==null||y.call(r,e,u),t()}})})]})]})}function Om({ids:e,showDivider:t=!0}){const{callbacks:r,config:n}=Fe(),{colorInactive:i}=Ze(),{nodeById:o}=Qr(),[s,a]=_.useState(!1),c=e.map(y=>{var m,g;return(g=(m=o.get(y))==null?void 0:m.data.viewProps)==null?void 0:g.borderRadius}),u=!c.every(y=>y===c[0]),l=u?"mixed":String(c[0]??""),d=["0","8","16","30","53","100"],h=s||!u&&l!==""&&!d.includes(l),p=y=>e.forEach(m=>{var g;return(g=r.onNodeBorderRadiusChange)==null?void 0:g.call(r,m,y)});return f.jsxs(f.Fragment,{children:[t&&f.jsx(gr,{}),f.jsx(B.Box,{position:"relative",w:"36px",h:"30px",display:"grid",placeItems:"center",children:f.jsxs(mr,{icon:f.jsx(B.Icon,{as:Rv.TbBorderRadius,boxSize:5,color:i,"aria-hidden":"true"}),"aria-label":"Node border radius",title:`Border radius: ${u?"Mixed":c[0]===void 0?"Default":`${c[0]}px`}`,style:{position:"absolute",inset:0,width:"100%",height:"100%",cursor:"pointer"},value:h?"custom":l,disabled:n.readOnly,onValueChange:y=>{a(y==="custom"),y!=="custom"&&p(y===""?void 0:Number(y))},children:[f.jsx("option",{value:"",children:"Default radius"}),u&&f.jsx("option",{value:"mixed",disabled:!0,children:"Mixed radii"}),d.map(y=>f.jsxs("option",{value:y,children:[y,"px radius"]},y)),f.jsx("option",{value:"custom",children:"Custom radius"})]})}),h&&f.jsx(ut,{ariaLabel:"Custom border radius",placeholder:u?"Mixed":"Auto",type:"number",min:0,width:"72px",value:u?"":l,onCommit:y=>p(y===""?void 0:Number(y))})]})}function Mm({ids:e,onClose:t}){var ce,L,V,G,N,ae,ge,ve;const{callbacks:r,colorMode:n,themeColor:i,config:o,setNodeViewMode:s}=Fe(),{colorText:a,colorInactive:c}=Ze(),{nodeById:u,parentIds:l}=Qr(),{palette:d,show:h}=Tm(),p=e.length===1,y=p?(ce=u.get(e[0]))==null?void 0:ce.data:void 0,m=e.map(K=>{var te,U;return((U=(te=u.get(K))==null?void 0:te.data.config)==null?void 0:U.typeView)??""}),g=m.some(K=>K!==m[0]),b=g?"mixed":m[0]??"",x=e.some(K=>{var U,se;const te=(U=u.get(K))==null?void 0:U.data;return te&&(l.has(K)||((se=te.config)==null?void 0:se.parentContainer)||Object.prototype.hasOwnProperty.call(o.customViews??{},te.type))}),v=(L=y==null?void 0:y.config)==null?void 0:L.collapsed,w=Rm(e[0]),C=K=>{var te,U,se;return(((U=(te=u.get(K))==null?void 0:te.data.viewProps)==null?void 0:U.outline)??(l.has(K)?(se=o.parentNodeStyle)==null?void 0:se.outline:!1))===!0},S=e.every(C),j=!S&&e.some(C),I=K=>{var te;return((te=u.get(K))==null?void 0:te.data.isNodeAnimated)===!0},P=e.every(I),O=!P&&e.some(I),T=e.map(K=>{var te;return((te=u.get(K))==null?void 0:te.data.nodeAnimationVariant)??"traveling"}),E=T.every(K=>K===T[0])?T[0]:"",R=K=>e.forEach(K),[k,M]=_.useState(!1),$=k&&h("color")&&h("borderColor"),q=K=>{var te,U,se;return(((U=(te=u.get(K))==null?void 0:te.data.viewProps)==null?void 0:U.borderStyle)??(l.has(K)?(se=o.parentNodeStyle)==null?void 0:se.borderStyle:"solid"))==="dashed"},W=e.every(q),ie=!W&&e.some(q),ee=e.map(K=>{var se,ue,we;const te=(se=u.get(K))==null?void 0:se.data,U=l.has(K)?cn((ue=o.parentNodeStyle)==null?void 0:ue.borderWidth,6):(te==null?void 0:te.type)==="objectView"?3:2;return cn((we=te==null?void 0:te.viewProps)==null?void 0:we.borderWidth,U)}),Y=ee.every(K=>K===ee[0])?String(ee[0]??""):"",fe=K=>R(te=>{var U,se;$?(U=r.onNodeBorderColorChange)==null||U.call(r,te,K):(se=r.onNodeColorChange)==null||se.call(r,te,"bg",K)});return f.jsxs(f.Fragment,{children:[f.jsx(At,{onClick:t}),f.jsx(gr,{}),p&&h("label")?f.jsx(ut,{ariaLabel:"Node label",placeholder:"Node label",value:(y==null?void 0:y.label)??(y==null?void 0:y.headerTitle)??"",onCommit:K=>{var te;return(te=r.onNodeLabelChange)==null?void 0:te.call(r,e[0],K)}}):f.jsxs(B.Text,{fontSize:"xs",color:a,whiteSpace:"nowrap",px:1,children:[e.length," selected"]}),h("typeView")&&f.jsxs(mr,{"aria-label":"Type view",title:x?"Type view is managed by the custom renderer or container":`Type view: ${b||"None (default)"}`,icon:f.jsx(J.PiImage,{size:20}),style:{width:36},value:b,disabled:o.readOnly||o.editable===!1||x,onValueChange:K=>{nn.includes(K)&&R(te=>{var U,se;(U=r.onNodeTypeViewChange)==null||U.call(r,te,K||void 0),s(te,"default"),(se=r.onNodeViewToggle)==null||se.call(r,te)})},children:[g&&f.jsx("option",{value:"mixed",disabled:!0,children:"Mixed"}),nn.map(K=>f.jsx("option",{value:K,children:K||"None"},K))]}),h("style")&&f.jsx(Om,{ids:e},e.join("\0")),h("outline")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(Oe,{label:S?"Restore node fill":"Remove node fill",children:f.jsx(Se,{"aria-label":"Toggle node outline","aria-pressed":j?"mixed":S,icon:f.jsx(B.Icon,{as:S?J.PiSquare:J.PiSquareFill,boxSize:5}),size:"sm",variant:"ghost",color:S?i:c,onClick:()=>R(K=>{var te;return(te=r.onNodeOutlineChange)==null?void 0:te.call(r,K,!S)})})})]}),h("color")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),h("borderColor")&&f.jsx(Oe,{label:$?"Edit node colors":"Edit node border",children:f.jsx(Se,{"aria-label":"Edit node border","aria-pressed":$,icon:f.jsx(B.Icon,{as:J.PiBoundingBox,boxSize:5}),size:"sm",variant:"ghost",color:$?i:c,bg:$?n==="dark"?"whiteAlpha.200":"blackAlpha.100":void 0,onClick:()=>M(K=>!K)})}),f.jsx(lt,{label:$?"Border color":"Background",colors:d,value:$?((V=y==null?void 0:y.viewProps)==null?void 0:V.borderColor)??(p&&l.has(e[0])?(G=o.parentNodeStyle)==null?void 0:G.borderColor:void 0):(N=y==null?void 0:y.viewProps)==null?void 0:N.bgColor,onPick:fe,onReset:()=>fe("")}),$&&h("style")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(Oe,{label:W?"Solid border":"Dashed border",children:f.jsx(Se,{"aria-label":"Toggle dashed border","aria-pressed":ie?"mixed":W,icon:f.jsx(B.Icon,{as:W?J.PiLineSegments:J.PiLineSegment,boxSize:5}),size:"sm",variant:"ghost",color:W?i:c,onClick:()=>R(K=>{var te;return(te=r.onNodeBorderStyleChange)==null?void 0:te.call(r,K,W?"solid":"dashed")})})}),f.jsx(ut,{ariaLabel:"Border thickness",placeholder:p?"Auto":"Mixed",width:"64px",type:"number",min:0,value:Y,onCommit:K=>R(te=>{var U;return(U=r.onNodeBorderWidthChange)==null?void 0:U.call(r,te,K===""?void 0:Number(K))})})]})]}),h("animation")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(Oe,{label:P?"Stop border animation":"Animate node border",children:f.jsx(Se,{"aria-label":"Toggle node animation","aria-pressed":O?"mixed":P,icon:f.jsx(B.Icon,{as:J.PiSpinnerGap,boxSize:5}),size:"sm",variant:"ghost",color:P?i:c,onClick:()=>R(K=>{var te;return(te=r.onNodeAnimationChange)==null?void 0:te.call(r,K,!P)})})}),(P||O)&&f.jsx(Pm,{label:"Node animation",value:E,options:[{value:"traveling",label:"Trace"},{value:"pulse",label:"Pulse"}],disabled:o.readOnly,onChange:K=>R(te=>{var U;return(U=r.onNodeAnimationVariantChange)==null?void 0:U.call(r,te,K)})})]}),!$&&h("textColor")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(lt,{label:"Text color",colors:Am,value:(ae=y==null?void 0:y.viewProps)==null?void 0:ae.textColor,onPick:K=>R(te=>{var U;return(U=r.onNodeColorChange)==null?void 0:U.call(r,te,"text",K)}),onReset:()=>R(K=>{var te;return(te=r.onNodeColorChange)==null?void 0:te.call(r,K,"text","")})})]}),p&&h("icon")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(el,{nodeId:e[0],value:(ge=y==null?void 0:y.config)==null?void 0:ge.icon},e[0]),f.jsx(ut,{ariaLabel:"Node icon",placeholder:"(e.g. PiGear)",width:"120px",value:((ve=y==null?void 0:y.config)==null?void 0:ve.icon)||"",onCommit:K=>{var te;return(te=r.onNodeIconChange)==null?void 0:te.call(r,e[0],K)}})]}),p&&w&&h("collapse")&&v!==void 0&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(Oe,{label:v?"Expand":"Collapse",children:f.jsx(Se,{"aria-label":v?"Expand node":"Collapse node",icon:f.jsx(B.Icon,{as:v?J.PiArrowsOutLineVertical:J.PiArrowsInLineVertical,boxSize:5}),size:"sm",variant:"ghost",color:c,onClick:()=>{var K;return(K=r.onNodeCollapse)==null?void 0:K.call(r,e[0],!v)}})})]}),h("delete")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(Oe,{label:p?"Delete node":`Delete ${e.length} nodes`,children:f.jsx(Se,{"aria-label":"Delete selected nodes",icon:f.jsx(B.Icon,{as:J.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:n==="dark"?"red.300":"red.500",onClick:()=>{R(K=>{var te,U;return(U=r.onNodeDelete)==null?void 0:U.call(r,K,((te=u.get(K))==null?void 0:te.data)||{id:K})}),t()}})})]})]})}async function qm(e){const{toSvg:t}=await Promise.resolve().then(()=>require("./index-sHQXTNv9.cjs"));await document.fonts.ready;const r=await t(e,{filter:i=>!(i instanceof Element)||!i.matches("button, iframe, [role=tooltip], .flow-sdk-handle, .flow-sdk-property-port, .flow-sdk-edge-hit, .flow-sdk-ghost, .flow-sdk-node-animation")}),n=new DOMParser().parseFromString(decodeURIComponent(r.slice(r.indexOf(",")+1)),"image/svg+xml");return n.querySelectorAll(".flow-sdk-edge-hit, .flow-sdk-handle, .flow-sdk-property-port, .flow-sdk-ghost").forEach(i=>i.remove()),n.querySelectorAll("[data-flow-preview-source]").forEach(i=>{i.setAttribute("style","display:block;white-space:pre-wrap;font:16px/1.5 monospace;overflow-wrap:anywhere")}),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(n))}`}async function $m(e,t="squeed.svg"){const r=document.createElement("a");r.href=await qm(e),r.download=t.endsWith(".svg")?t:`${t}.svg`,r.click()}function Nm(){const{themeColor:e}=Fe(),[t,r]=_.useState(!1),[n,i]=_.useState("");return f.jsxs(f.Fragment,{children:[f.jsx(Oe,{label:"Download SVG (current view)",children:f.jsx(Se,{"aria-label":"Download SVG",icon:f.jsx(J.PiDownloadSimpleFill,{size:20}),disabled:t,borderRadius:"30%",color:e,variant:"ghost",onClick:async o=>{var a;const s=(a=o.currentTarget.closest("[data-flow-diagram]"))==null?void 0:a.querySelector("[data-flow-background]");if(!s){i("Diagram not available for export.");return}r(!0),i("");try{await $m(s)}catch(c){i(c instanceof Error?c.message:"Unable to export SVG.")}finally{r(!1)}}})}),n&&f.jsx("span",{role:"alert",style:{fontSize:12,maxWidth:220},children:n})]})}function Lm({children:e,background:t,border:r,endElement:n}){const i=_.useRef(null),[o,s]=_.useState({left:!1,right:!1});_.useLayoutEffect(()=>{const c=i.current;let u=c.parentElement.offsetWidth;const l=()=>{const p=c.parentElement.offsetWidth;if(p>0&&p!==u){const g=u/p;u=p,g>0&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches&&c.parentElement.animate({transform:[`scaleX(${g})`,"scaleX(1)"],transformOrigin:[n?"right center":"left center",n?"right center":"left center"]},{duration:180,easing:"ease-out",id:"flow-toolbar-grow"})}const y=c.scrollLeft>1,m=c.scrollWidth-c.clientWidth-c.scrollLeft>1;s(g=>g.left===y&&g.right===m?g:{left:y,right:m})},d=p=>{if(p.defaultPrevented||p.ctrlKey||p.deltaX!==0||!p.deltaY||c.scrollWidth<=c.clientWidth)return;p.preventDefault();const y=p.deltaMode===WheelEvent.DOM_DELTA_LINE?16:p.deltaMode===WheelEvent.DOM_DELTA_PAGE?c.clientWidth:1;c.scrollLeft+=p.deltaY*y},h=new ResizeObserver(l);return h.observe(c),c.firstElementChild&&h.observe(c.firstElementChild),c.addEventListener("scroll",l,{passive:!0}),c.addEventListener("wheel",d,{passive:!1}),l(),()=>{h.disconnect(),c.removeEventListener("scroll",l),c.removeEventListener("wheel",d)}},[]);const a=`var(--chakra-colors-${t.replace(".","-")})`;return f.jsxs(B.Box,{position:"relative",bg:t,minW:0,maxW:"100%",flex:"0 1 auto",borderRadius:"30px",css:Jr(a,`var(--chakra-colors-${r.replace(".","-")})`),children:[f.jsx(B.Box,{ref:i,"data-flow-toolbar-scroll":"",h:50,minH:50,alignContent:"center",overflowX:"auto",overflowY:"hidden",mr:n?"44px":void 0,borderRadius:"inherit",css:{scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:e}),["left","right"].map(c=>f.jsx(B.Box,{"data-flow-toolbar-fade":c,"aria-hidden":"true",position:"absolute",top:0,bottom:0,w:"20px",pointerEvents:"none",borderRadius:c==="left"?"30px 0 0 30px":"0 30px 30px 0",style:{[c]:c==="right"&&n?44:0,opacity:o[c]?1:0,background:`linear-gradient(to ${c==="left"?"right":"left"}, ${a}, transparent)`}},c)),n&&f.jsx(B.Box,{position:"absolute",right:"6px",top:0,h:"50px",w:"32px",display:"flex",alignItems:"center",justifyContent:"center",children:n})]})}async function L0(e,t){const r=new Set,n=[],i=(a,c)=>{var l,d,h;if(!a||typeof a!="object")return;const u=a;n.push(c),typeof((l=u.$form)==null?void 0:l.$type)=="string"&&r.add(u.$form.$type),typeof((h=(d=u.$form)==null?void 0:d.$create)==null?void 0:h.$type)=="string"&&r.add(u.$form.$create.$type);for(const[p,y]of Object.entries(u))p==="$"?i(y,c):p.startsWith("$")||i(y,`${c}.${p}`)};if(i(t,"root"),!r.size)return{contract:await Sm(e)};const o=await Qu(e,[...r]);for(const a of r)if(!Object.prototype.hasOwnProperty.call(o,a))throw new Error(`Missing form type: ${a}`);const s={};for(const a of n){const c=Tt(t,a,o);c&&(s[a]={type:c.type,optional:!1})}return{schema:o,contract:{name:e.name,nodes:s}}}function Fm({message:e,onDismiss:t}){const{background:r,colorText:n,border:i}=Ze();return!e||typeof document>"u"?null:tn.createPortal(f.jsxs(B.chakra.div,{role:"alert","aria-atomic":"true",css:Jr(be(r),be(i)),onPointerDown:o=>o.stopPropagation(),onClick:o=>o.stopPropagation(),style:{position:"fixed",top:20,right:20,zIndex:1e4,width:360,maxWidth:"calc(100vw - 40px)",boxSizing:"border-box",display:"flex",alignItems:"flex-start",gap:10,padding:16,borderRadius:8,background:be(r),color:be(n),fontSize:14,lineHeight:1.5},children:[f.jsx(J.PiWarningCircle,{size:20,"aria-hidden":"true",style:{flexShrink:0,color:"#ef4444"}}),f.jsxs("div",{style:{flex:1,minWidth:0,overflowWrap:"anywhere"},children:[f.jsx("strong",{children:"Interface upload failed"}),f.jsx("div",{children:e})]}),f.jsx(At,{type:"button","aria-label":"Dismiss upload error",title:"Dismiss upload error",onClick:t,flexShrink:0,width:"24px",height:"24px",minWidth:"24px",padding:0})]}),document.body)}function rl({showDivider:e=!0,compact:t=!1}={}){const{edgeMode:r,setEdgeMode:n,workflowContract:i,setWorkflowContract:o,callbacks:s,readOnly:a,themeColor:c,colorMode:u}=Fe(),{edgeById:l}=Qr(),{data:d,schema:h,setSchema:p,bindings:y,structured:m}=_.useContext(Sr),g=(m==null?void 0:m.sourceBindings)??y,b=(m==null?void 0:m.sourceSchema)??h,{colorText:x}=Ze(),v=_.useRef(null),w=_.useRef(0),[C,S]=_.useState(!1),[j,I]=_.useState("");_.useEffect(()=>()=>{w.current++},[]),_.useEffect(()=>{w.current++,S(!1)},[a,d,g]);const P=i?[...l.values()].filter(E=>Xu(i,E.data)).length:0,O=i?`${i.name}: ${b?`${Object.keys(b).length} form types loaded; `:""}${P} invalid or unverified connections`:"",T=On(f.jsx(rl,{showDivider:!1,compact:!0}));return f.jsx(Et.Provider,{value:null,children:f.jsxs("span",{style:{display:"contents"},onClickCapture:T,children:[f.jsx(Fm,{message:j,onDismiss:()=>I("")}),e&&f.jsx(Ht,{}),f.jsxs(mr,{"aria-label":"Edge mode",title:r==="auto"?"Connections: Auto":r==="properties"?"Connections: Properties":"Connections: Nodes",icon:r==="auto"?f.jsx(J.PiGraph,{size:20}):r==="properties"?f.jsx(J.PiTable,{size:20}):f.jsx(J.PiTreeStructure,{size:20}),style:{width:36},value:r,disabled:a,footer:s.onWorkflowConfigurationOpen&&f.jsxs(f.Fragment,{children:[f.jsx("hr",{style:{border:0,borderTop:"1px solid currentColor",opacity:.2,margin:"8px 0"}}),f.jsxs(B.Button,{"data-flow-menu-action":"",variant:"ghost",width:"100%",justifyContent:"flex-start",color:"inherit",bg:"transparent",css:kn,_hover:{bg:u==="dark"?"whiteAlpha.100":"blackAlpha.50"},_focusVisible:{bg:u==="dark"?"whiteAlpha.100":"blackAlpha.50"},onClick:E=>{var R,k;(R=E.currentTarget.closest("[popover]"))==null||R.hidePopover(),(k=s.onWorkflowConfigurationOpen)==null||k.call(s)},children:[f.jsx(J.PiGear,{}),"Configuration"]})]}),onValueChange:E=>{var k;const R=E==="auto"?"auto":E==="properties"?"properties":"nodes";n(R),(k=s.onEdgeModeChange)==null||k.call(s,R)},children:[f.jsx("option",{value:"auto",children:"Auto"}),f.jsx("option",{value:"nodes",children:"Nodes"}),f.jsx("option",{value:"properties",children:"Properties"})]}),f.jsxs("span",{style:{display:r==="auto"||r==="properties"?"contents":"none"},children:[f.jsx(Oe,{label:i?`Replace ${i.name}`:"Upload workflow interface",children:f.jsx(Se,{"aria-label":"Upload workflow interface",icon:f.jsx(J.PiUploadSimple,{size:20}),color:be(c),size:"sm",variant:"ghost",disabled:C||a,onClick:()=>{var E;return(E=v.current)==null?void 0:E.click()}})}),f.jsx("input",{ref:v,type:"file",hidden:!0,accept:".ts,.json","aria-label":"Workflow interface file",disabled:a||C,onChange:async E=>{var M,$;const R=(M=E.target.files)==null?void 0:M[0];if(E.target.value="",!R)return;const k=++w.current;S(!0),I("");try{const q=g?await Qu(R,[...new Set(Object.values(g).map(ee=>ee.schemaType??ee.type))]):void 0;if(g&&q){for(const ee of Object.values(g))if(!Object.prototype.hasOwnProperty.call(q,ee.schemaType??ee.type))throw new Error(`Missing form type: ${ee.schemaType??ee.type}`)}const{contract:W,schema:ie}=g&&q?{schema:q,contract:{name:R.name,nodes:Object.fromEntries(Object.entries(g).map(([ee,Y])=>[ee,{type:q[Y.schemaType??Y.type],optional:!1}]))}}:await L0(R,d);if(k!==w.current)return;p==null||p(ie),o(W),($=s.onWorkflowContractChange)==null||$.call(s,W)}catch(q){k===w.current&&I(`${R.name}: ${q instanceof Error?q.message:"Unable to load interface."}`)}finally{k===w.current&&S(!1)}}}),!t&&(O||C)&&f.jsx("span",{role:"status",title:O,style:{color:be(x),fontSize:12,maxWidth:180,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:C?"Loading interface...":O}),!t&&i&&f.jsx(Oe,{label:"Remove workflow interface",children:f.jsx(Se,{"aria-label":"Remove workflow interface",icon:f.jsx(J.PiX,{size:16}),size:"sm",variant:"ghost",disabled:a||C,onClick:()=>{var E;p==null||p(void 0),o(void 0),(E=s.onWorkflowContractChange)==null||E.call(s,void 0),I("")}})})]})]})})}const F0=[{value:"BT",label:"Bottom to Up",icon:J.PiArrowUp,flowType:Bt.BOTTOM_UP},{value:"TB",label:"Top to Bottom",icon:J.PiArrowDown,flowType:Bt.TOP_DOWN},{value:"LR",label:"Left to Right",icon:J.PiArrowRight,flowType:Bt.LEFT_RIGHT},{value:"RL",label:"Right to Left",icon:J.PiArrowLeft,flowType:Bt.RIGHT_LEFT}],Bm=()=>{const{engineRef:e,themeColor:t,setThemeColor:r,edgeColor:n,setEdgeColor:i,backgroundSelected:o,setBackgroundSelected:s,direction:a,edgeMode:c,allNodesIconLabel:u,setAllNodesIconLabel:l,selectedNodeIds:d,setSelectedNodeIds:h,selectedEdgeId:p,setSelectedEdgeId:y,isZoomMode:m,setIsZoomMode:g,isMultiSelectMode:b,setIsMultiSelectMode:x,isDragMode:v,setIsDragMode:w,isEdgeHandlesEnabled:C,setIsEdgeHandlesEnabled:S,isArrayNodeMode:j,setIsArrayNodeMode:I,isPinned:P,setIsPinned:O,callbacks:T,config:E,readOnly:R}=Fe(),{nodeById:k,edgeById:M,parentIds:$}=Qr(),q=E.colorMode==="dark",{background:W,border:ie,colorInactive:ee,colorText:Y,colorActive:fe}=Ze(),ce=q?ie:"gray.300",L=`var(--chakra-colors-${W.replace(".","-")})`,V=`var(--chakra-colors-${(q?ie:"gray.300").replace(".","-")})`,[G,N]=_.useState(!1),[ae,ge]=_.useState(!0),ve=E.bottomBarCollapsed??ae,K=_.useRef(null),te=$y({edge:"bottom",enabled:!P,bounds:K,inside:[K]}),U=_.useCallback(ye=>{const Me=e.current;if(!Me)return;const nr=E.minZoom??.01,cr=E.maxZoom??1.5,Xe=.02;let xe=Me.zoom();switch(ye){case"increase":xe=Math.min(cr,xe+Xe),Me.zoom(xe),Me.center(!1);break;case"decrease":xe=Math.max(nr,xe-Xe),Me.zoom(xe),Me.center(!1);break;case"reset":Me.fit(50);break}},[e,E.minZoom,E.maxZoom]),se=E.renderSelectedNodeToolbar,ue=d.length>0&&!!se,we=_.useMemo(()=>ue?d.map(ye=>{var nr;return{...((nr=k.get(ye))==null?void 0:nr.data)??{id:ye},isParent:$.has(ye)}}):[],[ue,d,k,$]),pe=_.useCallback(()=>{var ye;h([]),(ye=T.onNodeDeselect)==null||ye.call(T)},[h,T]),qe=E.renderSelectedEdgeToolbar,Q=!!p&&!!qe,he=_.useMemo(()=>{var ye;return!Q||!p?null:((ye=M.get(p))==null?void 0:ye.data)??{id:p}},[Q,p,M]),me=_.useCallback(()=>{var ye;y(null),(ye=T.onEdgeDeselect)==null||ye.call(T)},[y,T]),Re=E.selectionToolbar!==!1&&!R,$e=Re&&!!p&&!qe,Ge=Re&&!$e&&d.length>0&&!se,Ye=$e||Ge,tr=P||te||G||Ye||E.bottomBarCollapsed===!1;_.useEffect(()=>{d.length||p?s(!1):R||(o&&O(!0),E.bottomBarCollapsed===void 0&&ge(!o))},[o,d.length,p,R,s,O,E.bottomBarCollapsed]);const sr=E.renderBottomBar,Ae=h0();return sr?f.jsxs(f.Fragment,{children:[ue&&f.jsx(B.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:se({selectedNodeIds:d,selectedNodeData:we,onDeselect:pe})}),Q&&he&&f.jsx(B.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:qe({edgeId:p,edgeData:he,onDeselect:me})}),f.jsx(B.Box,{position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",children:sr({zoomIn:()=>U("increase"),zoomOut:()=>U("decrease"),resetZoom:()=>U("reset"),direction:a,isZoomMode:m,setIsZoomMode:g,isMultiSelectMode:b,setIsMultiSelectMode:x,isDragMode:v,setIsDragMode:w,isEdgeHandlesEnabled:C,setIsEdgeHandlesEnabled:S,isArrayNodeMode:j,setIsArrayNodeMode:I,selectedNodeIds:d,selectedNodeData:we,selectedEdgeId:p,selectedEdgeData:he,onNodeDeselect:pe,onEdgeDeselect:me,callbacks:T})})]}):f.jsxs(Et.Provider,{value:Ae,children:[ue&&f.jsx(B.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:se({selectedNodeIds:d,selectedNodeData:we,onDeselect:pe})}),Q&&he&&f.jsx(B.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:qe({edgeId:p,edgeData:he,onDeselect:me})}),f.jsx(B.Box,{ref:K,role:"toolbar","aria-label":"Diagram controls",position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",transition:"opacity 0.3s ease-in, transform 0.3s ease",transform:tr?"translateY(0)":"translateY(100%)",pointerEvents:tr?"auto":"none",visibility:tr?"visible":"hidden",opacity:tr?1:0,css:{"@media (hover: none)":{visibility:"visible",opacity:1,transform:"none",pointerEvents:"auto"}},children:f.jsxs(B.Flex,{w:"100%",px:5,position:"absolute",bottom:"calc(20px + env(safe-area-inset-bottom, 0px))",flexDirection:"row",justifyContent:"space-between",alignItems:"center",gap:"24px",css:{"@media (min-width: 1024px)":{"& > :first-of-type":{maxWidth:"50vw"}}},children:[f.jsx(Lm,{background:W,border:q?ie:"gray.300",children:f.jsxs(B.HStack,{px:2,gap:1,flexWrap:"nowrap",w:"max-content",minW:"100%",h:"100%",css:{"& > *":{flexShrink:0}},children:[$e?f.jsx(Im,{edgeId:p,onClose:me}):Ge?f.jsx(Mm,{ids:d,onClose:pe}):null,f.jsxs("div",{style:{display:$e||Ge?"none":"contents"},children:[f.jsx(Oe,{label:P?"Unpin":"Pin",children:f.jsx(Se,{"aria-label":"Pin",icon:f.jsx(B.Icon,{as:P?J.PiPushPinFill:J.PiPushPin,boxSize:5}),size:"sm",variant:"ghost",color:P?t:ee,onClick:()=>{O(!P),N(!1)}})}),f.jsx(B.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:ce}),f.jsx(Oe,{label:"Zoom Out",children:f.jsx(Se,{"aria-label":"Zoom out",rememberAction:!1,icon:f.jsx(B.Icon,{as:J.PiMinus,boxSize:5}),size:"sm",variant:"ghost",color:Y,onClick:()=>U("decrease")})}),f.jsx(Oe,{label:"Zoom In",children:f.jsx(Se,{"aria-label":"Zoom in",rememberAction:!1,icon:f.jsx(B.Icon,{as:J.PiPlus,boxSize:5}),size:"sm",variant:"ghost",color:Y,onClick:()=>U("increase")})}),f.jsx(Oe,{label:"Reset Zoom",children:f.jsx(Se,{"aria-label":"Reset zoom",rememberAction:!1,icon:f.jsx(B.Icon,{as:J.PiArrowCounterClockwise,boxSize:5}),size:"sm",variant:"ghost",color:Y,onClick:()=>U("reset")})}),ve&&f.jsx(p0,{divider:f.jsx(B.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:ce,role:"separator","aria-orientation":"vertical"})}),f.jsxs("span",{style:{display:ve?"none":"contents"},children:[E.edgeHandles!==!1&&f.jsx(Oe,{label:C?"Draw Mode On (V)":"Draw Mode Off (V)",children:f.jsx(Se,{"aria-label":"Toggle draw mode","aria-keyshortcuts":"V","aria-pressed":C,icon:f.jsx(B.Icon,{as:J.PiPencilSimpleLine,boxSize:5}),size:"sm",variant:"ghost",color:C?t:ee,onClick:()=>S(!C)})}),f.jsx(B.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:ce}),f.jsx(Oe,{label:m?"Zoom Mode (z)":"Pan Mode (z)",children:f.jsx(Se,{"aria-label":"Toggle zoom mode",icon:f.jsx(B.Icon,{as:m?J.PiMagnifyingGlassPlus:J.PiArrowsOutCardinal,boxSize:5}),size:"sm",variant:"ghost",color:m?t:ee,onClick:()=>g(!m)})}),f.jsx(B.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:ce}),f.jsx(Oe,{label:b?"Multi-Select On (m)":"Multi-Select Off (m)",children:f.jsx(Se,{"aria-label":"Toggle multi-select",icon:f.jsx(B.Icon,{as:J.PiSelectionPlus,boxSize:5}),size:"sm",variant:"ghost",color:b?t:ee,onClick:()=>x(!b)})}),f.jsx(B.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:ce}),f.jsx(Oe,{label:v?"Drag Mode On (d)":"Drag Mode Off (d)",children:f.jsx(Se,{"aria-label":"Toggle drag mode",icon:f.jsx(B.Icon,{as:J.PiHandGrabbing,boxSize:5}),size:"sm",variant:"ghost",color:v?t:ee,onClick:()=>w(!v)})}),E.bottomBarExtra&&f.jsxs(f.Fragment,{children:[f.jsx(B.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:ce,role:"separator","aria-orientation":"vertical"}),E.bottomBarExtra]}),f.jsx(B.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:ce,role:"separator","aria-orientation":"vertical"}),f.jsx(lm,{}),f.jsx(B.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:ce,role:"separator","aria-orientation":"vertical"}),f.jsx(Wu,{label:"Collapse all",hideLabel:!0,checked:u,icon:f.jsx(B.Icon,{as:J.PiArrowsInLineVertical,boxSize:5}),onChange:l}),c!=="properties"&&f.jsxs(f.Fragment,{children:[f.jsx(B.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:ce}),f.jsx(Oe,{label:j?"Array Mode [ ]":"Set Mode { }",children:f.jsx(Se,{"aria-label":"Toggle array mode",icon:f.jsx(B.Icon,{as:j?J.PiBracketsSquare:J.PiBracketsCurly,boxSize:5}),size:"sm",variant:"ghost",color:j?t:ee,onClick:()=>{var Me;const ye=!j;I(ye),(Me=T.onArrayModeChange)==null||Me.call(T,ye)}})})]}),f.jsx(rl,{}),!R&&f.jsxs("span",{style:{display:o?"contents":"none"},children:[f.jsx(B.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:ce}),f.jsx(lt,{label:"Graph theme",colors:Pn,value:t,includeTransparent:!1,onPick:ye=>{var Me;r(ye),(Me=T.onThemeColorChange)==null||Me.call(T,ye)}})]}),!R&&f.jsxs(f.Fragment,{children:[f.jsx(B.Icon,{as:J.PiLineVerticalThin,boxSize:5,color:ce,role:"separator","aria-orientation":"vertical"}),f.jsx(lt,{label:"Graph edge color",colors:Pn,value:n||(q?"gray.500":Pt),onPick:i,onReset:()=>i("")}),f.jsx(B.Icon,{as:J.PiLineVerticalThin,boxSize:5,color:ce,role:"separator","aria-orientation":"vertical"})]}),f.jsx(fm,{})]}),f.jsx(B.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:ce}),f.jsx(Oe,{label:ve?"Expand toolbar":"Collapse toolbar",children:f.jsx(Se,{"aria-label":"Toggle toolbar collapse",rememberAction:!1,icon:f.jsx(B.Icon,{as:ve?J.PiCaretRight:J.PiCaretLeft,boxSize:5}),size:"sm",variant:"ghost",color:ee,onClick:()=>{var ye;E.bottomBarCollapsed===void 0&&ge(!ve),s(ve),(ye=T.onBottomBarCollapsedChange)==null||ye.call(T,!ve)}})}),!ve&&f.jsx(Nm,{})]})]})}),!Ye&&f.jsxs(B.Box,{position:"relative",ml:"auto",flexShrink:0,children:[f.jsx(B.Box,{"data-flow-direction-control":"",bg:W,borderRadius:"30px",h:50,css:Jr(L,V),px:3,cursor:"pointer",onClick:()=>N(!G),children:f.jsxs(B.Flex,{align:"center",h:"100%",children:[f.jsx(Oe,{label:"Flow Direction",children:f.jsx(Se,{"aria-label":"Direction",onClick:ye=>{ye.stopPropagation(),N(!G)},icon:f.jsx(B.Icon,{as:J.PiCaretUp,boxSize:5}),size:"sm",variant:"ghost",color:ee})}),f.jsx(B.Text,{fontSize:"xs",textTransform:"uppercase !important",color:q?"whiteAlpha.600":"blackAlpha.500",ml:1,children:a.toUpperCase()})]})}),G&&f.jsx(B.Box,{position:"absolute",bottom:"100%",right:0,pb:"24px",zIndex:200,children:f.jsxs(B.Box,{bg:W,borderRadius:"30px",p:2,minW:"180px",css:Jr(L,V),children:[F0.map(ye=>f.jsxs(B.Flex,{align:"center",gap:3,px:3,py:2,css:kn,cursor:"pointer",_hover:{bg:q?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var Me;(Me=T.onDirectionChange)==null||Me.call(T,ye.value),N(!1)},children:[f.jsx(B.Icon,{as:ye.icon,boxSize:5,color:Y}),f.jsx(B.Text,{fontSize:"sm",color:Y,flex:1,whiteSpace:"nowrap",children:ye.label}),a===ye.value&&f.jsx(B.Icon,{as:J.PiCheck,boxSize:4,color:fe})]},ye.value)),f.jsxs(B.Flex,{align:"center",gap:3,px:3,py:2,css:kn,cursor:"pointer",_hover:{bg:q?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var ye;(ye=T.onDirectionChange)==null||ye.call(T,"C"),N(!1)},children:[f.jsx(B.Icon,{as:J.PiAlignCenterHorizontal,boxSize:5,color:Y}),f.jsx(B.Text,{fontSize:"sm",color:Y,flex:1,whiteSpace:"nowrap",children:"Center"}),a==="C"&&f.jsx(B.Icon,{as:J.PiCheck,boxSize:4,color:fe})]})]})})]})]})})]})};Bm.displayName="BottomBar";const zm=_.memo(Bm);function B0({checked:e,onChange:t,disabled:r,label:n="Connected nodes"}){return f.jsx(Wu,{hideLabel:!0,label:n,helper:`${n}: isolate node and its connections`,checked:e,onChange:t,disabled:r,icon:f.jsx(B.Icon,{as:J.PiGraph,boxSize:5})})}const Jl={$bgColor:"bgColor",$textColor:"textColor",$borderColor:"borderColor"};function Dm(e,t){const r=new Map,n=(o,s)=>{if(Object.is(o,s))return!0;if(!o||!s||typeof o!="object"||typeof s!="object"||Array.isArray(o)!==Array.isArray(s))return!1;const a=Object.keys(o);return a.length===Object.keys(s).length&&a.every(c=>Object.prototype.hasOwnProperty.call(s,c)&&n(o[c],s[c]))},i=(o,s,a)=>{if(o===s)return!0;if(!o||!s||typeof o!="object"||typeof s!="object"||Array.isArray(o)!==Array.isArray(s))return!1;const c=new Set([...Object.keys(o),...Object.keys(s)]);for(const u of c)if(!n(o[u],s[u])){if(Object.prototype.hasOwnProperty.call(Jl,u)){if(typeof s[u]!="string"||!s[u])return!1;r.set(a,{...r.get(a),[Jl[u]]:s[u]})}else if(u.startsWith("$")&&u!=="$"||!i(o[u],s[u],u==="$"?a:`${a}.${u}`))return!1}return!0};if(i(e,t,"root"))return r}function z0(e,t){return Dm(e,t)!==void 0}function D0(e,t,r){if(e===t)return r;const n=Dm(e,t);if(!n)return;const i=new Set(r.nodes.map(o=>o.data.id));for(const o of n.keys())if(!i.has(o)||!ke(t,o))return;return{edges:r.edges,nodes:r.nodes.map(o=>{const s=n.get(o.data.id),a=ke(e,o.data.id),c=ke(t,o.data.id);return!s&&a===c?o:{...o,data:{...o.data,...typeof o.data.code=="string"?{code:JSON.stringify(c,null,2)}:{},...s?{viewProps:{...o.data.viewProps,...s},config:{...o.data.config,...s}}:{}}}})}}function Lu(e){return e.kind==="literal"?e.value:e.kind==="union"?Lu(e.types[0]):e.kind==="array"?[]:e.kind==="object"?Object.fromEntries(Object.entries(e.properties).filter(([,t])=>!t.optional).map(([t,r])=>[t,Lu(r.type)])):e.kind==="boolean"?!1:e.kind==="number"||e.kind==="integer"?0:e.kind==="null"?null:""}function Vm(e,t,r){var g,b,x;const n=(g=ke(e,t))==null?void 0:g.$form,i=n==null?void 0:n.$create;if(!i)return;const o=i.$address.split(".");if(o.shift()!=="root"||!o.length||o.some(v=>!/^[A-Za-z0-9_-]+$/.test(v)||["__proto__","constructor","prototype"].includes(v)))throw new Error("Invalid form creation address.");if(!r||!Object.prototype.hasOwnProperty.call(r,i.$type))throw new Error(`Load form type: ${i.$type}`);const s=o.pop(),a=["root",...o].join("."),c=Tt(e,a,r),u=(b=c==null?void 0:c.type.properties[s])==null?void 0:b.type;if((u==null?void 0:u.kind)!=="array"||u.items.kind!=="object")throw new Error("Form creation must target an object-array field.");const l=r[i.$type],d=i.$defaults??{};for(const[v,w]of Object.entries(d))if(!Object.prototype.hasOwnProperty.call(l.properties,v)||Pr(l.properties[v].type,w,!l.properties[v].optional))throw new Error(`Invalid creation default: ${v}`);const h={...Lu(l),...structuredClone(d)};((x=l.properties.id)==null?void 0:x.type.kind)==="string"&&(h.id=Gu());let p=e;const y=ke(e,i.$address);if(y===void 0)p=vr(e,a,v=>({...v,[s]:[]}));else if(!Array.isArray(y)&&!Array.isArray(y==null?void 0:y.$))throw new Error("Form creation destination is not an array.");const m=Ku(p,i.$address,{...h,$label:i.$label??i.$type,...i.$icon?{$icon:i.$icon}:{},$form:{$type:i.$type,$create:i}});return{address:m.address,json:Ju(m.json,t,{target:m.address,label:i.$edgeLabel})}}function V0(e,t){const r=i=>e&&typeof e=="object"&&i in e;let n=1;for(;r(`${t}_${n}`);)n++;return`${t}_${n}`}function Wm(e,t,r,n,i){const o=(a,c)=>{a!==e&&(e=a,n==null||n(a,c))},s=a=>{var u;const c=(u=t.find(l=>l.data.id===a))==null?void 0:u.data;return c&&{source:c.source,target:c.target,isInverted:c.isInverted,sourceProperty:c.sourceProperty,targetProperty:c.targetProperty,connection:c.connection}};return{...r,onFormChange:a=>{const c=ke(e,a.nodeAddress);if(!c||a.nodeId!==void 0&&c.id!==a.nodeId)throw new Error("This form node has moved. Retry the edit.");o(Ln(e,a,r.onFormChange),{type:"form",address:a.address,value:a.value})},onNodeLabelChange:(a,c)=>{var u;(u=r.onNodeLabelChange)==null||u.call(r,a,c),o(hr(e,a,"$label",c),{type:"nodeLabel",address:a,key:"$label",value:c})},onNodeContentChange:(a,c)=>{var u;(u=r.onNodeContentChange)==null||u.call(r,a,c),o(hr(e,a,"$content",c),{type:"nodeContent",address:a,key:"$content",value:c})},onNodeTypeViewChange:(a,c)=>{var u;c!==void 0&&!nn.includes(c)||((u=r.onNodeTypeViewChange)==null||u.call(r,a,c),o(hr(e,a,"$view",c),{type:"nodeStyle",address:a,key:"$view",value:c}))},onNodeColorChange:(a,c,u)=>{var d;(d=r.onNodeColorChange)==null||d.call(r,a,c,u);const l=c==="bg"?"$bgColor":"$textColor";o(hr(e,a,l,u),{type:"nodeColor",address:a,key:l,value:u})},onNodeBorderColorChange:(a,c)=>{var u;(u=r.onNodeBorderColorChange)==null||u.call(r,a,c),o(hr(e,a,"$borderColor",c),{type:"nodeColor",address:a,key:"$borderColor",value:c})},onNodeBorderStyleChange:(a,c)=>{var u;(u=r.onNodeBorderStyleChange)==null||u.call(r,a,c),o(hr(e,a,"$borderStyle",c),{type:"nodeStyle",address:a,key:"$borderStyle",value:c})},onNodeBorderWidthChange:(a,c)=>{var u;c!==void 0&&(!Number.isFinite(c)||c<0)||((u=r.onNodeBorderWidthChange)==null||u.call(r,a,c),o(hr(e,a,"$borderWidth",c),{type:"nodeStyle",address:a,key:"$borderWidth",value:c}))},onNodeBorderRadiusChange:(a,c)=>{var u;c!==void 0&&(!Number.isFinite(c)||c<0)||((u=r.onNodeBorderRadiusChange)==null||u.call(r,a,c),o(hr(e,a,"$borderRadius",c),{type:"nodeStyle",address:a,key:"$borderRadius",value:c}))},onNodeIconChange:(a,c)=>{var u;(u=r.onNodeIconChange)==null||u.call(r,a,c),o(hr(e,a,"$icon",c),{type:"nodeIcon",address:a,key:"$icon",value:c})},onNodeOutlineChange:(a,c)=>{var u;(u=r.onNodeOutlineChange)==null||u.call(r,a,c),o(hr(e,a,"$outline",c),{type:"nodeOutline",address:a,key:"$outline",value:c})},onNodeAnimationChange:(a,c)=>{var u;(u=r.onNodeAnimationChange)==null||u.call(r,a,c),o(hr(e,a,"$isNodeAnimated",c),{type:"nodeAnimation",address:a,key:"$isNodeAnimated",value:c})},onNodeAnimationVariantChange:(a,c)=>{var u;c!=="traveling"&&c!=="pulse"||((u=r.onNodeAnimationVariantChange)==null||u.call(r,a,c),o(hr(e,a,"$nodeAnimationVariant",c),{type:"nodeAnimation",address:a,key:"$nodeAnimationVariant",value:c}))},onNodeCollapse:(a,c)=>{var u;(u=r.onNodeCollapse)==null||u.call(r,a,c),o(mm(e,a,c),{type:"nodeCollapse",address:a,key:"$collapsed",value:c})},onNodeCreate:a=>{var y,m;const c=a.sourceNodeId&&Vm(e,a.sourceNodeId,i);if(c){(y=r.onNodeCreate)==null||y.call(r,a),o(c.json,{type:"nodeCreate",address:c.address,value:"form"});return}(m=r.onNodeCreate)==null||m.call(r,a);const u=a.sourceNodeId||"root",l=ke(e,u),d=V0(l,a.isArrayMode?"list":"node"),h=a.isArrayMode?{$bgColor:"gray.500",$:[]}:{$bgColor:"gray.500"},p=Ku(e,u,h,d);o(p.json,{type:"nodeCreate",address:p.address,value:a.isArrayMode?"array":"set"})},onNodeDelete:(a,c)=>{var u;(u=r.onNodeDelete)==null||u.call(r,a,c),o(vm(e,a),{type:"nodeDelete",address:a})},onEdgeCreate:(a,c,u)=>{var d;(d=r.onEdgeCreate)==null||d.call(r,a,c,u);const l=u&&(u.sourceProperty!==void 0||u.targetProperty!==void 0)?{...u,target:c}:void 0;o(l?Ju(e,a,l):xm(e,a,c),{type:"edgeCreate",address:a,key:l?"$connections":"$target",value:l??c})},onEdgeLabelChange:(a,c)=>{var l;(l=r.onEdgeLabelChange)==null||l.call(r,a,c);const u=s(a);u&&o(Hr(e,u,"$sourceLabel",c),{type:"edgeLabel",edge:u,key:u.connection?"$connections":"$sourceLabel",value:c})},onEdgeStyleChange:(a,c)=>{var l;(l=r.onEdgeStyleChange)==null||l.call(r,a,c);const u=s(a);u&&o(bm(e,u,c),{type:"edgeStyle",edge:u,value:c})},onEdgeAnimationVariantChange:(a,c)=>{var l;if(c!=="dashed"&&c!=="traveling")return;(l=r.onEdgeAnimationVariantChange)==null||l.call(r,a,c);const u=s(a);u&&o(Hr(e,u,"$edgeAnimationVariant",c),{type:"edgeStyle",edge:u,key:u.connection?"$connections":"$edgeAnimationVariant",value:c})},onEdgeTypeChange:(a,c)=>{var l;(l=r.onEdgeTypeChange)==null||l.call(r,a,c);const u=s(a);u&&o(Hr(e,u,"$edgeType",c),{type:"edgeStyle",edge:u,key:u.connection?"$connections":"$edgeType",value:c})},onEdgeIconChange:(a,c)=>{var l;(l=r.onEdgeIconChange)==null||l.call(r,a,c);const u=s(a);u&&o(Hr(e,u,"$edgeIcon",c||void 0),{type:"edgeStyle",edge:u,key:u.connection?"$connections":"$edgeIcon",value:c})},onEdgeColorChange:(a,c)=>{var l;(l=r.onEdgeColorChange)==null||l.call(r,a,c);const u=s(a);u&&o(Hr(e,u,"$edgeColor",c),{type:"edgeColor",edge:u,key:u.connection?"$connections":"$edgeColor",value:c})},onEdgeDelete:(a,c)=>{var d;(d=r.onEdgeDelete)==null||d.call(r,a,c);const u=s(a);if(!u)return;const l=wm(e,u);l.removed&&o(l.json,{type:"edgeDelete",edge:u,key:u.connection?"$connections":"$target"})}}}const W0=".flow-sdk-edge-trace{pointer-events:none;animation:flow-sdk-edge-trace 2.4s linear infinite}.flow-sdk-edge-trace-reverse{animation-direction:reverse}@keyframes flow-sdk-edge-trace{from{stroke-dashoffset:18}to{stroke-dashoffset:-100}}@media(prefers-reduced-motion:reduce){.flow-sdk-edge-trace,.flow-sdk-edge-anim{animation:none}}";function G0({path:e,color:t,width:r,reversed:n}){return f.jsx("path",{className:`flow-sdk-edge-trace${n?" flow-sdk-edge-trace-reverse":""}`,"data-animation-variant":"traveling","aria-hidden":"true",pointerEvents:"none",d:e,fill:"none",stroke:t,strokeWidth:r,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 100"})}const U0=".flow-sdk-edge-reveal{animation:flow-sdk-edge-reveal var(--flow-edge-reveal-duration,600ms) linear both;animation-play-state:var(--flow-edge-reveal-state,running)}.flow-sdk-edge-reveal-end{animation:flow-sdk-edge-reveal-end var(--flow-edge-reveal-duration,600ms) steps(1,end) both;animation-play-state:var(--flow-edge-reveal-state,running)}@keyframes flow-sdk-edge-reveal{from{stroke-dashoffset:var(--flow-edge-reveal-from,100)}to{stroke-dashoffset:0}}@keyframes flow-sdk-edge-reveal-end{from{opacity:0}to{opacity:1}}@media(prefers-reduced-motion:reduce){.flow-sdk-edge-reveal{animation:none;stroke-dashoffset:0}.flow-sdk-edge-reveal-end{animation:none;opacity:1}}";function H0({path:e,width:t,reversed:r,children:n,onComplete:i}){const o=`flow-edge-reveal-${_.useId().replace(/:/g,"")}`,s=_.useRef(null),[a,c]=_.useState({x:0,y:0,width:1,height:1});return _.useEffect(()=>{const u=matchMedia("(prefers-reduced-motion: reduce)"),l=()=>{u.matches&&(i==null||i())};return l(),u.addEventListener("change",l),()=>u.removeEventListener("change",l)},[i]),_.useLayoutEffect(()=>{var l;const u=(l=s.current)==null?void 0:l.getBBox();u&&c({x:u.x-t,y:u.y-t,width:u.width+t*2,height:u.height+t*2})},[e,t]),f.jsxs(f.Fragment,{children:[f.jsx("defs",{children:f.jsx("mask",{id:o,maskUnits:"userSpaceOnUse",...a,children:f.jsx("path",{ref:s,className:"flow-sdk-edge-reveal",onAnimationEnd:u=>{u.animationName==="flow-sdk-edge-reveal"&&(i==null||i())},"data-reveal-direction":r?"reverse":"forward",style:{"--flow-edge-reveal-from":r?-100:100},d:e,fill:"none",stroke:"white",strokeWidth:t,strokeLinecap:"butt",strokeLinejoin:"round",pathLength:100,strokeDasharray:"100 100"})})}),f.jsx("g",{mask:`url(#${o})`,children:n})]})}const K0=".flow-sdk-node-animation{position:absolute;inset:0;width:100%;height:100%;overflow:visible;pointer-events:none;z-index:1}.flow-sdk-node-border-animation{pointer-events:none;animation:flow-sdk-node-border 2.4s linear infinite}.flow-sdk-node-border-pulse{stroke-width:var(--flow-pulse-rest-width);animation:flow-sdk-node-pulse 1.8s ease-in-out infinite}@keyframes flow-sdk-node-border{from{stroke-dashoffset:0}to{stroke-dashoffset:-100}}@keyframes flow-sdk-node-pulse{0%,100%{stroke-width:var(--flow-pulse-rest-width)}50%{stroke-width:var(--flow-pulse-expanded-width)}}@media(prefers-reduced-motion:reduce){.flow-sdk-node-border-animation{animation:none}}";function Gm({x:e=0,y:t=0,width:r,height:n,radius:i,color:o,strokeWidth:s=8,path:a,variant:c="traveling"}){const u=_.useId(),l=`flow-sdk-node-border-animation${c==="pulse"?" flow-sdk-node-border-pulse":""}`;if(c==="pulse"){const d=a?"path":"rect",h=a?{d:a}:{x:e,y:t,width:Math.max(0,r),height:Math.max(0,n),rx:Math.max(0,Math.min(i,r/2,n/2))},p=s+36,y={x:e-p,y:t-p,width:r+2*p,height:n+2*p};return f.jsxs("g",{"aria-hidden":"true",pointerEvents:"none",children:[f.jsx("defs",{children:f.jsxs("mask",{id:u,maskUnits:"userSpaceOnUse",...y,style:{maskType:"luminance"},children:[f.jsx("rect",{...y,fill:"white"}),f.jsx(d,{...h,fill:"black",stroke:"black",strokeWidth:s,strokeLinejoin:"round"})]})}),f.jsx(d,{...h,className:l,"data-animation-variant":c,fill:"none",stroke:`color-mix(in srgb, ${o} 30%, transparent)`,strokeLinejoin:"round",mask:`url(#${u})`,style:{"--flow-pulse-rest-width":`${s+16}px`,"--flow-pulse-expanded-width":`${s+36}px`}})]})}return a?f.jsx("path",{className:l,"data-animation-variant":c,"aria-hidden":"true",pointerEvents:"none",d:a,fill:"none",stroke:o,strokeWidth:s,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"}):f.jsx("rect",{className:l,"data-animation-variant":c,"aria-hidden":"true",pointerEvents:"none",x:e,y:t,width:Math.max(0,r),height:Math.max(0,n),rx:Math.max(0,Math.min(i,r/2,n/2)),fill:"none",stroke:o,strokeWidth:s,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"})}const J0=e=>{const n=1/(Math.cbrt(e)*.8);let i=Math.round(650*n),o=Math.round(350*n);return i=Math.max(40,Math.min(450,i)),o=Math.max(30,Math.min(300,o)),{edgeSep:i,rankSep:o}};function Zl(e,t,r){const n=new Set([e]),i=[e];for(;i.length;){const o=i.pop();for(const s of t)(s.parent===o||s.id.startsWith(`${o}.`)||r.some(c=>(c.inverted?c.target:c.source)===o&&(c.inverted?c.source:c.target)===s.id))&&!n.has(s.id)&&(n.add(s.id),i.push(s.id))}return n}function Z0(e,t,r){const n=r==="downward"||r==="upward",i=new Map;for(const s of e){if(s.source===s.target||s.sourceProperty||s.targetProperty)continue;const a=t(s.source),c=t(s.target);if(!a||!c)continue;const u=n?c.y-a.y:c.x-a.x,l=Math.abs(u)-(n?a.h+c.h:a.w+c.w)/2;if(l<=320)continue;const d=JSON.stringify([s.source,Math.sign(u)]),h=i.get(d)??[];h.push({edge:s,gap:l,cross:n?c.x-a.x:c.y-a.y}),i.set(d,h)}const o=new Map;for(const s of i.values()){if(new Set(s.map(({edge:c})=>c.target)).size<2)continue;const a=new Map;for(const{edge:c}of s)a.set(c.target,(a.get(c.target)??0)+1);for(const c of[-1,0,1]){const u=s.filter(({cross:d})=>Math.sign(d)===c);u.sort((d,h)=>Math.abs(h.cross)-Math.abs(d.cross)||d.edge.id.localeCompare(h.edge.id));const l=Math.min(...u.map(({gap:d})=>d));u.forEach(({edge:d,gap:h,cross:p},y)=>{const m=u.length===1?l/2:120+(l-280)*y/(u.length-1),g=u.find(b=>Math.abs(b.cross)<Math.abs(p));o.set(d.id,{turn:m/h,labelAtTarget:a.get(d.target)===1,labelFraction:p?(p+((g==null?void 0:g.cross)??0))/(2*p):.5})})}}return o}const bt=e=>({x1:e.x-e.w/2,y1:e.y-e.h/2,x2:e.x+e.w/2,y2:e.y+e.h/2}),Y0=e=>({x:(e.x1+e.x2)/2,y:(e.y1+e.y2)/2,w:e.x2-e.x1,h:e.y2-e.y1});function yo(e){if(!e.length)return null;const t={...e[0]};for(let r=1;r<e.length;r++)t.x1=Math.min(t.x1,e[r].x1),t.y1=Math.min(t.y1,e[r].y1),t.x2=Math.max(t.x2,e[r].x2),t.y2=Math.max(t.y2,e[r].y2);return t}const X0=(e,t)=>e.x1<=t.x2&&e.x2>=t.x1&&e.y1<=t.y2&&e.y2>=t.y1,Yl=(e,t)=>e.x>=t.x1&&e.x<=t.x2&&e.y>=t.y1&&e.y<=t.y2,wr=e=>(Math.round(e*10)/10).toString(),Qe=e=>`${wr(e.x)} ${wr(e.y)}`,Q0=e=>e>0?1:e<0?-1:0,Xl=(e,t)=>e>0?Math.max(e-t,0):Math.min(e+t,0);function ew(e,t,r,n,i=10){const o=t.x-e.x,s=t.y-e.y,a=Xl(o,(e.w+t.w)/2),c=Xl(s,(e.h+t.h)/2),u=r==="downward"||r==="upward",l=u?c:a,d=u?s:o,h=Q0(d),p=n*l,y=x=>Math.abs(x)<i||Math.abs(x)>=Math.abs(l),m=y(p)||y(Math.abs(l)-Math.abs(p));let g;if(m)if(u)if(Math.abs(d)<=e.h/2){const x=(e.x+t.x)/2;g=[x,e.y,x,t.y]}else if(Math.abs(o)<=t.w/2){const x=(e.y+t.y)/2;g=[e.x,x,t.x,x]}else g=[e.x,t.y];else if(Math.abs(d)<=e.w/2){const x=(e.y+t.y)/2;g=[e.x,x,t.x,x]}else if(Math.abs(s)<=t.h/2){const x=(e.x+t.x)/2;g=[x,e.y,x,t.y]}else g=[t.x,e.y];else if(u){const x=e.y+p+e.h/2*h;g=[e.x,x,t.x,x]}else{const x=e.x+p+e.w/2*h;g=[x,e.y,x,t.y]}const b=[{x:e.x,y:e.y}];for(let x=0;x<g.length;x+=2)b.push({x:g[x],y:g[x+1]});return b.push({x:t.x,y:t.y}),b}function rw(e,t,r){const n=t.x-e.x,i=t.y-e.y,o=n>0?(r.x2-e.x)/n:n<0?(r.x1-e.x)/n:1/0,s=i>0?(r.y2-e.y)/i:i<0?(r.y1-e.y)/i:1/0,a=Math.min(o,s);return!Number.isFinite(a)||a>=1||a<0?null:{x:e.x+n*a,y:e.y+i*a}}function kt(e,t,r){var s;if(!((s=r.outline)!=null&&s.length))return rw(e,t,bt(r));const n=t.x-e.x,i=t.y-e.y;let o=1/0;return r.outline.forEach((a,c,u)=>{const l=u[(c+1)%u.length],d=l.x-a.x,h=l.y-a.y,p=n*h-i*d;if(Math.abs(p)<1e-9)return;const y=a.x-e.x,m=a.y-e.y,g=(y*h-m*d)/p,b=(y*i-m*n)/p;g>=0&&g<1&&b>=-1e-9&&b<=1+1e-9&&(o=Math.min(o,g))}),Number.isFinite(o)?{x:e.x+n*o,y:e.y+i*o}:null}function Um(e,t,r=.5){const n=Number.isFinite(r)?Math.max(0,Math.min(1,r)):.5,i=t==="top"||t==="bottom",o=t==="top"||t==="left"?-1:1,s={x:i?e.x-e.w/2+e.w*n:e.x,y:i?e.y:e.y-e.h/2+e.h*n},a=Math.max(e.w,e.h)*2+1;return{...kt(s,{x:s.x+(i?0:o*a),y:s.y+(i?o*a:0)},e)??{x:i?s.x:e.x+o*e.w/2,y:i?e.y+o*e.h/2:s.y},side:t}}function wt(e,t){return{x:e.x+(e.side==="right"?t:e.side==="left"?-t:0),y:e.y+(e.side==="bottom"?t:e.side==="top"?-t:0)}}function tw(e,t,r,n){const i=wt(e,r.srcDist),o=wt(t,r.tgtDist);if(n==="straight")return Km(i,o,r);const s=Math.max(80,Math.min(300,Math.hypot(o.x-i.x,o.y-i.y)/3)),a=e.side==="bottom"&&t.side==="top"?o.y-i.y:e.side==="top"&&t.side==="bottom"?i.y-o.y:e.side==="right"&&t.side==="left"?o.x-i.x:e.side==="left"&&t.side==="right"?i.x-o.x:void 0,c=a!==void 0&&a>0?Math.min(s,a/2):s,u=wt({...i,side:e.side},c),l=wt({...o,side:t.side},c),d=r.arrowAt==="source"?ar(i,u,r.arrowGap):i,h=r.arrowAt==="target"?ar(o,l,r.arrowGap):o,p=r.arrowAt==="source"?_r(i,u,r.arrowSize,r.headShape):r.arrowAt==="target"?_r(o,l,r.arrowSize,r.headShape):void 0;if(n==="bezier")return{d:`M${Qe(d)} C${Qe(u)} ${Qe(l)} ${Qe(h)}`,arrow:p,label:{x:(d.x+3*u.x+3*l.x+h.x)/8,y:(d.y+3*u.y+3*l.y+h.y)/8,angle:0}};const y=e.side==="left"||e.side==="right",m=t.side==="left"||t.side==="right";let g;if(y!==m){const x=y?{x:l.x,y:u.y}:{x:u.x,y:l.y},v=(x.x-u.x)*(u.x-i.x)+(x.y-u.y)*(u.y-i.y)>=0,w=(x.x-l.x)*(l.x-o.x)+(x.y-l.y)*(l.y-o.y)>=0;g=[v&&w?x:y?{x:u.x,y:l.y}:{x:l.x,y:u.y}]}else if(a!==void 0&&a<=0)if(y){const x=(u.y+l.y)/2;g=[{x:u.x,y:x},{x:l.x,y:x}]}else{const x=(u.x+l.x)/2;g=[{x,y:u.y},{x,y:l.y}]}else if(y){const x=e.side===t.side?e.side==="right"?Math.max(u.x,l.x):Math.min(u.x,l.x):(u.x+l.x)/2;g=[{x,y:u.y},{x,y:l.y}]}else{const x=e.side===t.side?e.side==="bottom"?Math.max(u.y,l.y):Math.min(u.y,l.y):(u.y+l.y)/2;g=[{x:u.x,y:x},{x:l.x,y:x}]}const b=[u,...g,l].filter((x,v,w)=>v===0||x.x!==w[v-1].x||x.y!==w[v-1].y);return Fn(d,b,h,p,n==="orthogonal"?0:r.radius)}function ar(e,t,r){const n=e.x-t.x,i=e.y-t.y,o=Math.hypot(n,i);if(!o)return e;let s=(o-r)/o;return s<0&&(s=1e-5),{x:t.x+s*n,y:t.y+s*i}}function _r(e,t,r,n="triangle"){const i=e.x-t.x,o=e.y-t.y,s=Math.hypot(i,o)||1,a=i/s,c=o/s,u=(n==="square"?.15:.3)*r,l=.15*r,d=e.x-a*u,h=e.y-c*u;if(n==="square")return`M${Qe(e)} L${wr(e.x-c*l)} ${wr(e.y+a*l)} L${wr(d-c*l)} ${wr(h+a*l)} L${wr(d+c*l)} ${wr(h-a*l)} L${wr(e.x+c*l)} ${wr(e.y-a*l)} Z`;const p=[e,{x:d-c*l,y:h+a*l},{x:d+c*l,y:h-a*l}];return p.map((m,g)=>{const b=p[(g+2)%3],x=p[(g+1)%3],v=Math.hypot(b.x-m.x,b.y-m.y),w=Math.hypot(x.x-m.x,x.y-m.y),C={x:(b.x-m.x)/v,y:(b.y-m.y)/v},S={x:(x.x-m.x)/w,y:(x.y-m.y)/w},j=Math.max(-1,Math.min(1,C.x*S.x+C.y*S.y)),I=Math.sqrt((1-j)/(1+j)),P=Math.min(1/I,v/2,w/2);return{start:{x:m.x+C.x*P,y:m.y+C.y*P},end:{x:m.x+S.x*P,y:m.y+S.y*P},radius:P*I}}).map((m,g)=>`${g?"L":"M"}${Qe(m.start)} A${wr(m.radius)} ${wr(m.radius)} 0 0 1 ${Qe(m.end)}`).join(" ")+" Z"}function Ur(e,t){let r=Math.atan(t/e);return e===0&&r<0&&(r=-r),Number.isFinite(r)||(r=0),r*180/Math.PI}function nw(e,t,r,n){const i={x:t.x-e.x,y:t.y-e.y},o={x:r.x-t.x,y:r.y-t.y},s=Math.hypot(i.x,i.y),a=Math.hypot(o.x,o.y),c=i.x*o.y-i.y*o.x;if(s<1e-6||a<1e-6||Math.abs(c)<1e-6)return{p1:t,b:t,p2:t,r:0};const u=Math.min(n,s/2,a/2);return{p1:{x:t.x-i.x/s*u,y:t.y-i.y/s*u},b:t,p2:{x:t.x+o.x/a*u,y:t.y+o.y/a*u},r:u}}function Hm(e,t,r,n){let i=-1,o=null;for(let y=0;y<e.length-1;y++){const m=kt(e[y],e[y+1],t);if(m){i=y,o=m;break}}let s=-1,a=null;for(let y=e.length-1;y>0;y--){const m=kt(e[y],e[y-1],r);if(m){s=y,a=m;break}}if(!o||!a||i>=s)return null;const c=e.slice(i+1,s),u=c[0]??a,l=c[c.length-1]??o;let d,h,p;if(n.arrowAt==="source"){const y=ar(o,u,n.srcDist);d=ar(o,u,n.srcDist+n.arrowGap),p=_r(y,u,n.arrowSize,n.headShape)}else d=ar(o,u,n.srcDist);if(n.arrowAt==="target"){const y=ar(a,l,n.tgtDist);h=ar(a,l,n.tgtDist+n.arrowGap),p=_r(y,l,n.arrowSize,n.headShape)}else h=ar(a,l,n.tgtDist);return Fn(d,c,h,p,n.radius,n.labelTargetLength,n.labelFraction)}function Fn(e,t,r,n,i,o,s){var h;const a=[e,...t,r],c=[];let u=`M${Qe(e)}`;for(let p=1;p<a.length-1;p++){const y=nw(a[p-1],a[p],a[p+1],i);c.push(y),y.r===0?u+=` L${Qe(y.b)}`:u+=` L${Qe(y.p1)} Q${Qe(y.b)} ${Qe(y.p2)}`}u+=` L${Qe(r)}`;let l;const d=t.length;if(d===0)l={x:(e.x+r.x)/2,y:(e.y+r.y)/2,angle:Ur(r.x-e.x,r.y-e.y)};else if(d%2===0){const p=t[d/2-1],y=t[d/2];l={x:(p.x+y.x)/2,y:(p.y+y.y)/2,angle:Ur(y.x-p.x,y.y-p.y)}}else{const p=c[(d-1)/2];if(p.r===0){const y=a[(d-1)/2+2];l={x:p.b.x,y:p.b.y,angle:Ur(y.x-p.b.x,y.y-p.b.y)}}else l={x:.25*p.p1.x+.5*p.b.x+.25*p.p2.x,y:.25*p.p1.y+.5*p.b.y+.25*p.p2.y,angle:Ur(p.p2.x-p.p1.x,p.p2.y-p.p1.y)}}if(o!==void 0){if(s!==void 0&&c.length===2){const g=c[0].p2,b=c[1].p1,x=Math.hypot(b.x-g.x,b.y-g.y),v=Math.min(.5,o/(2*x)),w=Math.max(v,Math.min(1-v,s));l={x:g.x+(b.x-g.x)*w,y:g.y+(b.y-g.y)*w,angle:Ur(b.x-g.x,b.y-g.y)}}const p=((h=c[c.length-1])==null?void 0:h.p2)??e,y=r.x-p.x,m=r.y-p.y;Math.hypot(y,m)>=o&&(l={x:(p.x+r.x)/2,y:(p.y+r.y)/2,angle:Ur(y,m)})}return{d:u,arrow:n,label:l}}function Ql(e,t,r,n,i,o,s){const a=r==="leftward"?-1:1,c={x:e.x+a*(e.w/2+s.srcDist),y:n??e.y},u={x:t.x-a*(t.w/2+s.tgtDist),y:i??t.y},l=Math.max(80,s.arrowGap+s.arrowSize*.3),d=c.x+a*l,h=u.x-a*l;let p;if(a*(h-d)>=0){const b=c.x+(u.x-c.x)*o,x=Math.max(Math.min(d,h),Math.min(Math.max(d,h),b));p=[{x,y:c.y},{x,y:u.y}]}else{const b=Math.min(e.y-e.h/2,t.y-t.h/2)-l*(1+o);p=[{x:d,y:c.y},{x:d,y:b},{x:h,y:b},{x:h,y:u.y}]}const y=s.arrowAt==="source"?ar(c,p[0],s.arrowGap):c,m=s.arrowAt==="target"?ar(u,p[p.length-1],s.arrowGap):u,g=s.arrowAt==="source"?_r(c,p[0],s.arrowSize,s.headShape):s.arrowAt==="target"?_r(u,p[p.length-1],s.arrowSize,s.headShape):void 0;return Fn(y,p,m,g,s.radius)}function ed(e,t,r,n,i){return Hm(ew(e,t,r,n),e,t,i)}function rd(e,t,r,n,i,o){const s=n===void 0&&i===void 0&&(r==="downward"||r==="upward"),a=r==="leftward"||s&&r==="upward"?-1:1,c=(u,l,d)=>{const h={x:u.x,y:l??u.y},p=Math.max(u.w,u.h)*2+1,y=kt(h,{x:h.x+(s?0:d*p),y:h.y+(s?d*p:0)},u);return y?{x:y.x+(s?0:d*o),y:y.y+(s?d*o:0)}:s?{x:u.x,y:u.y+d*(u.h/2+o)}:{x:u.x+d*(u.w/2+o),y:l??u.y}};return{sourcePoint:c(e,n,a),targetPoint:c(t,i,-a)}}function ow(e,t,r,n){const i=r==="downward"||r==="upward",o=r==="leftward"||r==="upward"?-1:1,s=Math.max(100,Math.abs(i?t.y-e.y:t.x-e.x)/2),a={x:e.x+(i?0:o*s),y:e.y+(i?o*s:0)},c={x:t.x-(i?0:o*s),y:t.y-(i?o*s:0)},u=n.arrowAt==="source"?ar(e,a,n.arrowGap):e,l=n.arrowAt==="target"?ar(t,c,n.arrowGap):t;return{d:`M${Qe(u)} C${Qe(a)} ${Qe(c)} ${Qe(l)}`,arrow:n.arrowAt==="source"?_r(e,a,n.arrowSize,n.headShape):n.arrowAt==="target"?_r(t,c,n.arrowSize,n.headShape):void 0,label:{x:(u.x+3*a.x+3*c.x+l.x)/8,y:(u.y+3*a.y+3*c.y+l.y)/8,angle:Ur(l.x+c.x-a.x-u.x,l.y+c.y-a.y-u.y)}}}function Km(e,t,r){const n=r.arrowAt==="source"?ar(e,t,r.arrowGap):e,i=r.arrowAt==="target"?ar(t,e,r.arrowGap):t,o=r.arrowAt==="source"?_r(e,t,r.arrowSize,r.headShape):r.arrowAt==="target"?_r(t,e,r.arrowSize,r.headShape):void 0;return Fn(n,[],i,o,0)}function iw(e,t,r,n=-90,i=-60,o=350){const s=n*Math.PI/180,a=i*Math.PI/180,c=s-Math.PI/2,u=c-a/2,l=c+a/2,d=1.4*o*(t/3+1),h={x:e.x+Math.cos(u)*d,y:e.y+Math.sin(u)*d},p={x:e.x+Math.cos(l)*d,y:e.y+Math.sin(l)*d},y={x:e.x,y:e.y},m=kt(y,h,e),g=kt(y,p,e);if(!m||!g)return null;const b={x:(h.x+p.x)/2,y:(h.y+p.y)/2};let x=ar(m,h,r.srcDist),v=ar(g,p,r.tgtDist),w;if(r.arrowAt==="target"){const S=v;v=ar(g,p,r.tgtDist+r.arrowGap),w=_r(S,p,r.arrowSize,r.headShape)}else if(r.arrowAt==="source"){const S=x;x=ar(m,h,r.srcDist+r.arrowGap),w=_r(S,h,r.arrowSize,r.headShape)}return{d:`M${Qe(x)} Q${Qe(h)} ${Qe(b)} Q${Qe(p)} ${Qe(v)}`,arrow:w,label:{x:b.x,y:b.y,angle:Ur(p.x-h.x,p.y-h.y)}}}const yt=e=>Math.round(e*1e3)/1e3;function Jm(e){const t=e.querySelector("[data-flow-node-surface]");if(!t)return;const r=e.getBoundingClientRect(),n=r.width/e.offsetWidth;if(!Number.isFinite(n)||n<=0)return;const i=t.getBoundingClientRect();if(!i.width||!i.height)return;const o=t,s=typeof o.getScreenCTM=="function"?o.getScreenCTM():null,a=typeof o.getTotalLength=="function"?o.getTotalLength():0,c=o.points,u=(c==null?void 0:c.numberOfItems)||128,l=s&&a>0?Array.from({length:u},(d,h)=>{const p=c!=null&&c.numberOfItems?c.getItem(h):o.getPointAtLength(a*h/u);return{x:yt((s.a*p.x+s.c*p.y+s.e-r.left)/n),y:yt((s.b*p.x+s.d*p.y+s.f-r.top)/n)}}):void 0;return{left:yt((i.left-r.left)/n),top:yt((i.top-r.top)/n),width:t instanceof HTMLElement?t.offsetWidth:yt(i.width/n),height:t instanceof HTMLElement?t.offsetHeight:yt(i.height/n),radius:parseFloat(getComputedStyle(t).borderTopLeftRadius)||0,...l?{outline:l}:{}}}function en(e,t){const r=e.x-e.w/2,n=e.y-e.h/2;return{x:r+t.left+t.width/2,y:n+t.top+t.height/2,w:t.width,h:t.height,...t.outline?{outline:t.outline.map(i=>({x:r+i.x,y:n+i.y}))}:{}}}function aw(e,t,r,n,i){var l;const o=i!=="TB"&&i!=="BT",s=o?"top":"left",a=o?"bottom":"right",c=new Map;for(const d of n)for(const[h,p,y]of[[d.source,d.sourceProperty,d.target],[d.target,d.targetProperty,d.source]]){const m=t.get(y);if(p===void 0||!m||y===h)continue;const g=r.get(y),b=JSON.stringify([h,p]),x=c.get(b)??[];x.push(g?en(m,g):m),c.set(b,x)}const u=new Map(e);for(const[d,h]of e){const p=t.get(d);if(!p||!h.some(v=>v.placement==="config"))continue;const y=r.get(d),m=y?en(p,y):p,g={x:p.w/2,y:p.h/2,w:p.w,h:p.h},b=y?en(g,y):g,x=new Map;for(const v of h){if(v.placement!=="config")continue;const C=(c.get(JSON.stringify([d,v.property]))??[]).reduce((j,I)=>j+(o?I.y-m.y:I.x-m.x),0),S=((l=v.anchor)==null?void 0:l.side)===a?a:s;x.set(v,C<-.001?s:C>.001?a:S)}u.set(d,h.map(v=>{const w=x.get(v);if(!w)return v;const C=h.filter(I=>x.get(I)===w),S=(C.indexOf(v)+1)/(C.length+1),j=Um(b,w,S);return{...v,anchor:j,top:j.y,height:0}}))}return u}function td(e,t,r){const n=new Set(t.map(a=>a.id));if(!n.has(e))return new Set;const i=new Set([e]);let o=!0;for(;o;){o=!1;for(const a of t)!i.has(a.id)&&(i.has(a.parent??"")||a.id.startsWith(`${e}.`))&&(i.add(a.id),o=!0)}const s=new Set(i);for(const a of r)i.has(a.source)&&n.has(a.target)&&s.add(a.target),i.has(a.target)&&n.has(a.source)&&s.add(a.source);return s}const Lr='"Helvetica Neue", Helvetica, sans-serif';let Ft;const wn=new Map;function un(e,t){const r=`${t}|${e}`,n=wn.get(r);if(n!==void 0)return n;Ft===void 0&&(Ft=typeof document<"u"?document.createElement("canvas").getContext("2d"):null);let i;return Ft?(Ft.font=t,i=Ft.measureText(e).width):i=e.length*(parseFloat(t)||16)*.55,wn.size>5e3&&wn.clear(),wn.set(r,i),i}function sw(e,t,r){const n=[];for(const i of String(e).split(`
209
+ `;function Kl({request:e,property:t,config:r,value:n,disabled:i}){var se,ue,we,pe,qe;const{callbacks:o,structured:s,references:a}=_.useContext(Sr),{themeColor:c}=Fe(),{background:u}=Ze(),l=_.useId(),d=t.type.kind==="object"||t.type.kind==="array"||t.type.kind==="json",h=n===void 0?"":d?JSON.stringify(n,null,2):String(n),[p,y]=_.useState(h),[m,g]=_.useState(""),[b,x]=_.useState(0),v=_.useRef(null),w=_.useRef(),[C,S]=_.useState(!1),[j,I]=_.useState(!1),[P,O]=_.useState(),T=((se=r.$options)==null?void 0:se.$source)==="callback",E=o.resolveFormOptions,{data:R,address:k,nodeAddress:M,nodeId:$}=e;_.useEffect(()=>(S(!1),I(!1),()=>{var Q;(Q=w.current)==null||Q.abort(),w.current=void 0}),[k,M,$,i,h,r.$control,(ue=r.$upload)==null?void 0:ue.accept,(we=r.$upload)==null?void 0:we.maxSizeBytes]);const q=_.useRef(R);q.current=R;const W=JSON.stringify([k,$,(pe=r.$options)!=null&&pe.$dependsOn?r.$options.$dependsOn.map(Q=>ke(R,Q)):ke(R,M)]);_.useEffect(()=>{y(h),g("")},[h,k,$]),_.useEffect(()=>{if(!T)return;const Q=new AbortController;return Promise.resolve().then(()=>{if(!E)throw new Error("No options resolver configured");return E({address:k,nodeAddress:M,nodeId:$,data:jt(q.current),signal:Q.signal})}).then(he=>{if(!Array.isArray(he)||he.some(me=>!me||typeof me.label!="string"||!["string","number","boolean"].includes(typeof me.value)&&me.value!==null))throw new Error("Invalid options response");Q.signal.aborted||O({key:W,options:he})}).catch(he=>{Q.signal.aborted||O({key:W,options:[],error:he instanceof Error?he.message:"Options unavailable"})}),()=>Q.abort()},[T,E,W,k,M,$,b]);const ie=T&&(P==null?void 0:P.key)!==W,ee=T?(P==null?void 0:P.key)===W?P.options:[]:t.type.kind==="null"?[{label:"Null",value:null}]:t.type.kind==="boolean"?[{label:"Yes",value:!0},{label:"No",value:!1}]:Xt(t.type),Y=t.type.kind==="array",fe=(r.$control==="upload"?"upload":s&&d||r.$control==="checkbox"?"pills":r.$control)??(ee?Y||t.type.kind==="boolean"?"pills":"select":t.type.kind==="boolean"?"checkbox":d?"textarea":"input"),ce=!t.optional||!!r.$requiredWhen&&Nn(r.$requiredWhen,R),L=ce?"Required":"Optional",V=fe!=="upload"&&!!(a!=null&&a.length)&&typeof n=="string"&&n.includes("{{"),G=m||T&&(P==null?void 0:P.key)===W&&P.error||!V&&Pr(t.type,n,ce),N=Cr(r.$label??k.split(".").pop()),ae=Q=>{var he;if(!(i||Object.is(Q,n)))try{(he=o.onFormChange)==null||he.call(o,{...e,previousValue:n,value:Q}),g("")}catch(me){g(me instanceof Error?me.message:"Unable to update field")}},ge=_.useRef(ae);_.useLayoutEffect(()=>{ge.current=ae});const ve=()=>{if(d){try{const Re=p===""&&t.optional?void 0:JSON.parse(p),$e=Pr(t.type,Re,ce);if($e){g($e);return}ae(Re)}catch{g("Enter valid JSON")}return}const Q=t.type.kind==="number"||t.type.kind==="integer",he=p===""&&t.optional?void 0:Q&&p!==""?Number(p):p,me=Pr(t.type,he,ce);if(Q&&me&&p!==""){g(me);return}ae(he)},K=async Q=>{var me,Re,$e;if(i||w.current||!Q.length)return;const he=new AbortController;w.current=he,g(""),S(!0);try{if(t.type.kind!=="string"&&!(t.type.kind==="array"&&t.type.items.kind==="string"))throw new Error("Uploads require a string or string-array field.");if(!Y&&Q.length!==1)throw new Error("Choose one file for this field.");if(!o.uploadFormFile)throw new Error("No file upload handler configured.");const Ge=(Re=(me=r.$upload)==null?void 0:me.accept)==null?void 0:Re.split(",").map(Ae=>Ae.trim().toLowerCase()).filter(Boolean);for(const Ae of Q){if((($e=r.$upload)==null?void 0:$e.maxSizeBytes)!==void 0&&Ae.size>r.$upload.maxSizeBytes)throw new Error(`${Ae.name} exceeds the file size limit.`);if(Ge!=null&&Ge.length&&!Ge.some(ye=>ye.startsWith(".")?Ae.name.toLowerCase().endsWith(ye):ye.endsWith("/*")?Ae.type.toLowerCase().startsWith(ye.slice(0,-1)):Ae.type.toLowerCase()===ye))throw new Error(`${Ae.name} is not an accepted file type.`)}const Ye=await Promise.all(Q.map(async Ae=>{const ye=await o.uploadFormFile({...e,data:jt(R),file:Ae,signal:he.signal});if(typeof ye!="string")throw new Error("Upload handler must return an HTTP or HTTPS URL.");let Me;try{Me=new URL(ye)}catch{throw new Error("Upload handler must return an HTTP or HTTPS URL.")}if(!["http:","https:"].includes(Me.protocol)||Me.username||Me.password)throw new Error("Upload handler must return an HTTP or HTTPS URL.");return ye}));if(he.signal.aborted||w.current!==he)return;const tr=Y?[...Array.isArray(n)?n:[],...Ye]:Ye[0],sr=Pr(t.type,tr,ce);if(sr)throw new Error(sr);ge.current(tr)}catch(Ge){he.signal.aborted||g(Ge instanceof Error?Ge.message:"Unable to upload file."),he.abort()}finally{w.current===he&&(w.current=void 0,S(!1))}},te={id:l,disabled:i,"aria-label":N,"aria-required":ce,"aria-invalid":!!G,"aria-describedby":G?`${l}-error`:void 0},U=be(c);return f.jsxs("div",{"data-form-field":k,"data-flow-property":k.slice(M.length+1),children:[f.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[f.jsxs("label",{htmlFor:l,children:[N,ce?" *":""]}),t.optional&&n!==void 0&&f.jsx("button",{type:"button","aria-label":`Reset ${N}`,title:`Reset ${N}`,disabled:i||C,style:{width:24,height:24,padding:0,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:0,background:"transparent",color:"inherit"},onClick:()=>ae(void 0),children:f.jsx(J.PiArrowCounterClockwise,{size:14})})]}),!!(a!=null&&a.length)&&!d&&fe!=="upload"&&f.jsx(q0,{label:N,value:n,references:a,disabled:i,onChange:ae}),fe==="upload"?f.jsxs("div",{"data-form-upload":Y?"multiple":"single","aria-busy":C,style:{"--flow-upload-surface":be(u),outline:j?"2px dashed var(--flow-form-input-background)":void 0,borderRadius:"var(--flow-form-input-radius)"},onDragOver:Q=>{Q.preventDefault(),Q.stopPropagation(),!i&&!C&&(Q.dataTransfer.dropEffect="copy",I(!0))},onDragLeave:Q=>{Q.currentTarget.contains(Q.relatedTarget)||I(!1)},onDrop:Q=>{Q.preventDefault(),Q.stopPropagation(),I(!1),K(Array.from(Q.dataTransfer.files))},children:[f.jsx("input",{ref:v,type:"file",hidden:!0,"aria-label":`Upload ${N}`,accept:(qe=r.$upload)==null?void 0:qe.accept,multiple:Y,disabled:i||C,onChange:Q=>{const he=Array.from(Q.target.files??[]);Q.target.value="",K(he)}}),f.jsxs("div",{"data-upload-items":"",children:[(Y?Array.isArray(n)?n:[]:n?[n]:[]).map((Q,he)=>f.jsxs("div",{"data-upload-preview":"",children:[typeof Q=="string"&&Gr(Q)&&f.jsxs("a",{href:Q,target:"_blank",rel:"noopener noreferrer","aria-label":`${N} file ${he+1}`,children:[f.jsx(J.PiFile,{size:32,"aria-hidden":"true"}),f.jsx(Mr,{name:Q,size:120,onError:me=>{me.currentTarget.style.visibility="hidden"}})]}),f.jsxs("div",{"data-upload-actions":"",children:[!Y&&f.jsx(Se,{"aria-label":`Replace ${N}`,title:`Replace ${N}`,icon:f.jsx(J.PiUploadSimple,{}),size:"xs",variant:"ghost",disabled:i||C,onClick:()=>{var me;return(me=v.current)==null?void 0:me.click()}}),f.jsx(Se,{"aria-label":`Remove ${N} file ${he+1}`,title:"Remove file",icon:f.jsx(J.PiTrash,{}),size:"xs",variant:"ghost",disabled:i||C,onClick:()=>ae(Y&&Array.isArray(n)?n.filter((me,Re)=>Re!==he):"")})]})]},`${he}:${Q}`)),(Y||!n)&&f.jsx("button",{...te,type:"button","data-upload-drop":"",title:`Upload ${N}`,disabled:i||C,onClick:()=>{var Q;return(Q=v.current)==null?void 0:Q.click()},children:f.jsx(J.PiPlus,{size:28,"aria-hidden":"true"})})]}),C&&f.jsx("span",{role:"status",children:"Uploading..."})]}):V?null:fe==="select"?f.jsx("div",{"data-form-select":"",children:f.jsxs(mr,{...te,disabled:i||ie||!!(P!=null&&P.error),labelCase:"preserve",value:String((ee==null?void 0:ee.findIndex(Q=>Object.is(Q.value,n)))??-1),onValueChange:Q=>{const he=ee==null?void 0:ee[Number(Q)];he&&ae(he.value)},children:[f.jsx("option",{value:-1,disabled:!0,children:n!==void 0&&n!==""?String(n):L}),ee==null?void 0:ee.map((Q,he)=>f.jsx("option",{value:he,children:Cr(Q.label)||Q.label},he))]})}):fe==="pills"?f.jsxs("div",{id:l,role:"group","aria-label":N,"aria-describedby":te["aria-describedby"],style:{display:"flex",flexWrap:"wrap",gap:8},children:[ee==null?void 0:ee.map((Q,he)=>{const me=Y?Array.isArray(n)&&n.includes(Q.value):Object.is(n,Q.value);return f.jsx("button",{type:"button",disabled:i||ie,"aria-pressed":me,style:{padding:"8px 16px",borderRadius:24,border:0,color:me?U:"inherit",background:me?"color-mix(in srgb, currentColor 12%, transparent)":"color-mix(in srgb, currentColor 7%, transparent)"},onClick:()=>ae(Y?me?n.filter(Re=>Re!==Q.value):[...Array.isArray(n)?n:[],Q.value]:Q.value),children:Cr(Q.label)||Q.label},he)}),ie&&f.jsx("span",{role:"status",children:"Loading..."})]}):fe==="textarea"?f.jsx("textarea",{...te,placeholder:L,value:p,onChange:Q=>y(Q.target.value),onBlur:ve}):f.jsx("input",{...te,placeholder:L,type:t.type.kind==="number"||t.type.kind==="integer"?"number":"text",step:t.type.kind==="integer"?1:"any",value:p,onChange:Q=>y(Q.target.value),onBlur:ve,onKeyDown:Q=>{Q.key==="Enter"&&ve(),Q.key==="Escape"&&y(n===void 0?"":String(n))}}),G&&f.jsx("div",{role:"alert",id:`${l}-error`,children:G}),T&&(P==null?void 0:P.error)&&f.jsx("button",{type:"button",disabled:i,onClick:()=>{O(void 0),x(b+1)},children:"Retry"})]})}function km({nodeAddress:e,structured:t=!1}){return t?f.jsx(N0,{nodeAddress:e},e):f.jsx(Nu,{nodeAddress:e})}function N0({nodeAddress:e}){var d,h,p;const t=_.useContext(Sr),[r,n]=_.useState([]),i=((d=t.structured)==null?void 0:d.sourceSchema)??t.schema,o=((h=t.structured)==null?void 0:h.sourceBindings)??t.bindings,s=_.useMemo(()=>{if(!(!t.data||!i||!o))return Em(t.data,o,i,[{data:{id:e,type:"objectView"}}])},[t.data,o,i,e]);if(!s)return f.jsx(Nu,{nodeAddress:e});const a=r.findIndex(y=>!s.containers.has(y)),c=a<0?r:r.slice(0,a),u=c.at(-1)??e,l=(p=[...s.slots.values()].find(y=>y.nodeId===u))==null?void 0:p.label;return f.jsxs(Sr.Provider,{value:{...t,structured:s,schema:s.schema,bindings:s.bindings,renderForm:void 0,onFieldCreate:u===e?t.onFieldCreate:void 0},children:[!!c.length&&f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[f.jsx(Se,{"aria-label":"Back to parent fields",title:"Back to parent fields",icon:f.jsx(J.PiArrowLeft,{size:18}),size:"sm",variant:"ghost",onClick:()=>n(c.slice(0,-1))}),f.jsx("strong",{style:{minWidth:0,overflowWrap:"anywhere"},children:Cr(l)})]}),f.jsx(Nu,{nodeAddress:u,onOpen:y=>n([...c,y])},u)]})}function Nu({nodeAddress:e,onOpen:t}){var S,j;const{data:r,schema:n,callbacks:i,bindings:o,editable:s,renderForm:a,structured:c}=_.useContext(Sr),{readOnly:u,config:l,colorMode:d}=Fe(),h=a==null?void 0:a(e);if(h!==void 0)return f.jsx("fieldset",{"data-flow-form":e,disabled:u||l.editable===!1||!s,style:{border:0,margin:0,padding:0,minWidth:0},children:h});if(!r)return f.jsx(xn,{$colorMode:d,role:"alert",children:"Forms require a JSON document."});const p=o?dn(o,e,n):void 0,y=o?p:n&&Tt(r,e,n);if(!y)return f.jsx(xn,{$colorMode:d,role:"status",children:"Form schema unavailable."});const m=(p==null?void 0:p.address)??e,g=ke(r,m),b=(S=c==null?void 0:c.containers.get(e))==null?void 0:S.scalar;if(g===void 0||typeof g!="object"&&!b)return f.jsx(xn,{$colorMode:d,role:"alert",children:"Bound form state is unavailable."});const x=Object.entries(y.type.properties).filter(([I])=>{var P;return Nn((P=y.fields[I])==null?void 0:P.$visibleWhen,r)}),v=x.length>8||x.some(([I])=>{var P;return(P=y.fields[I])==null?void 0:P.$section}),w=new Map;for(const I of x){const[P,O]=I,T=v?Cr(((j=y.fields[P])==null?void 0:j.$section)??(O.type.kind==="object"||O.type.kind==="array"?P:O.optional?"Options":"General")):"";w.has(T)||w.set(T,[]),w.get(T).push(I)}const C=([I,P])=>f.jsx(Kl,{request:{data:r,address:b?m:`${m}.${I}`,nodeAddress:m,nodeId:typeof(g==null?void 0:g.id)=="string"?g.id:void 0},property:P,config:y.fields[I]??{},value:b?g:g==null?void 0:g[I],disabled:u||l.editable===!1||!(s??!!i.onJsonChange)},`${(g==null?void 0:g.id)??e}:${I}`);return f.jsxs(xn,{$colorMode:d,"data-flow-form":e,onClick:I=>I.stopPropagation(),onDoubleClick:I=>I.stopPropagation(),children:[c&&f.jsx($0,{nodeAddress:e,onOpen:t}),!c&&p&&y.type.additionalProperties&&x.length===0&&f.jsx(Kl,{request:{data:r,address:m,nodeAddress:m},property:{type:y.type,optional:!1},config:{$label:"Configuration",$control:"textarea"},value:g,disabled:u||l.editable===!1||!s}),[...w].map(([I,P])=>v&&P.length>1?f.jsxs("details",{open:!0,children:[f.jsxs("summary",{children:[f.jsx("span",{children:I}),f.jsx(J.PiCaretDown,{size:16,"aria-hidden":"true"})]}),P.map(C)]},I):P.map(C))]})}function Rm(e){const{viewData:t}=_.useContext(Sr),{nodeById:r,edgeById:n,parentIds:i}=Qr();if(t){const o=ke(t,e),s=o&&typeof o=="object"&&!Array.isArray(o)&&"$"in o?o.$:o;return Array.isArray(s)?s.length>0:!!s&&typeof s=="object"&&Object.entries(s).some(([a,c])=>!a.startsWith("$")&&c!==null&&typeof c=="object")}return i.has(e)?!0:[...n.values()].some(({data:o})=>{const s=o.isInverted?o.target:o.source,a=o.isInverted?o.source:o.target;return s===e&&a!==e&&r.has(a)})}function cn(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:t}function Rn(e,t,r,n){return{borderColor:t,borderWidth:cn(e==null?void 0:e.borderWidth,n),borderStyle:(e==null?void 0:e.borderStyle)??"solid",...Ly(t==="transparent"?"currentColor":t,r,".flow-sdk-node:hover &",!r)}}function Pm({label:e,value:t,options:r,onChange:n,disabled:i}){var o;return f.jsxs(mr,{"aria-label":e,title:`Animation: ${((o=r.find(s=>s.value===t))==null?void 0:o.label)??"Mixed"}`,value:t,style:{width:104},disabled:i,onValueChange:s=>{const a=r.find(c=>c.value===s);a&&n(a.value)},children:[t===""&&f.jsx("option",{value:"",disabled:!0,children:"Mixed"}),r.map(s=>f.jsx("option",{value:s.value,children:s.label},s.value))]})}function el({nodeId:e,edgeId:t,value:r,open:n,onOpenChange:i}){const{callbacks:o,readOnly:s,themeColor:a,colorMode:c}=Fe(),{background:u,backgroundSecondary:l,border:d,colorText:h,colorInactive:p}=Ze(),y=c==="dark"?Pt:be(p),m=_.useRef(null),g=_.useRef(null),b=_.useRef(0),[x,v]=_.useState(!1),[w,C]=_.useState("icons"),[S,j]=_.useState([]),[I,P]=_.useState("loading"),[O,T]=_.useState(""),[E,R]=_.useState(0),[k,M]=_.useState(""),[$,q]=_.useState(""),[W,ie]=_.useState(!1);_.useEffect(()=>()=>{b.current++},[]),_.useEffect(()=>{if(!x)return;let N=!0;return import("react-icons/pi").then(ae=>{N&&(j(Object.keys(ae).filter(ge=>ge.startsWith("Pi")).sort()),P("ready"))}).catch(()=>{N&&P("unavailable")}),()=>{N=!1}},[x]),_.useEffect(()=>{var N;s&&((N=m.current)==null||N.close())},[s]),_.useEffect(()=>{var N,ae,ge;if(n!==void 0){if(!n||s){(N=m.current)==null||N.close();return}(ae=m.current)!=null&&ae.open||(q(""),C(r==="PiFileSvg"||r&&Gr(r)?"custom":"icons"),M(r&&!r.startsWith(Qt)&&Gr(r)?r:""),v(!0),(ge=m.current)==null||ge.showModal())}},[n,s,r]);const ee=N=>{var ae,ge,ve;s||(t?(ae=o.onEdgeIconChange)==null||ae.call(o,t,N):e&&((ge=o.onNodeIconChange)==null||ge.call(o,e,N)),i==null||i(!1),(ve=m.current)==null||ve.close())},Y=S.filter(N=>N.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase().includes(O.trim().toLowerCase())),fe=36,ce=Math.max(1,Math.ceil(Y.length/fe)),L=Math.min(E,ce-1),V=Y.slice(L*fe,(L+1)*fe),G={width:"100%",padding:"8px 14px",background:"transparent",color:"inherit",border:`1px solid ${be(d)}`,borderRadius:30};return f.jsxs(f.Fragment,{children:[n===void 0&&f.jsx(Oe,{label:t?"Choose edge icon":"Choose node icon",children:f.jsx(Se,{"aria-label":t?"Choose edge icon":"Choose node icon",icon:f.jsx(J.PiShapes,{size:20}),size:"sm",variant:"ghost",color:be(a),disabled:s,onClick:()=>{var N;q(""),C(r&&Gr(r)?"custom":"icons"),M(r&&!r.startsWith(Qt)&&Gr(r)?r:""),v(!0),(N=m.current)==null||N.showModal()}})}),f.jsx(B.chakra.dialog,{ref:m,"aria-label":t?"Choose edge icon":"Choose node icon",css:Jr(be(u),be(d)),onClose:()=>{v(!1),i==null||i(!1),b.current++,ie(!1)},onClick:N=>{N.stopPropagation(),N.target===N.currentTarget&&N.currentTarget.close()},onKeyDown:N=>N.stopPropagation(),style:{margin:"auto",padding:12,width:336,maxWidth:"calc(100vw - 32px)",maxHeight:"calc(100vh - 32px)",overflowY:"auto",borderRadius:30,background:be(u),color:be(h)},children:x&&f.jsxs("div",{style:{display:"grid",gap:8},children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[f.jsx("strong",{children:t?"Edge icon":"Node icon"}),f.jsxs("div",{style:{display:"flex",alignItems:"center",marginLeft:"auto",gap:4},children:[r&&f.jsx(Oe,{label:"Remove icon",children:f.jsx(Se,{"aria-label":t?"Remove edge icon":"Remove node icon",icon:f.jsx(J.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:s||W,onClick:()=>ee("")})}),f.jsx(At,{"aria-label":"Close icon picker",onClick:()=>{var N;return(N=m.current)==null?void 0:N.close()}})]})]}),f.jsxs(B.Tabs.Root,{value:w,onValueChange:({value:N})=>{C(N),q("")},display:"contents",css:{"--indicator-thickness":"1px"},children:[f.jsx(B.Tabs.List,{"aria-label":"Icon source",width:"100%",borderBottomWidth:0,children:["icons","custom"].map(N=>f.jsx(B.Tabs.Trigger,{value:N,flex:1,minW:0,justifyContent:"center",px:3,py:2,fontSize:"13px",_selected:{color:a,borderColor:y,"--indicator-color":y},children:N==="icons"?"React icons":"Custom SVG"},N))}),f.jsx("input",{ref:g,type:"file",accept:".svg,image/svg+xml","aria-label":"Upload SVG icon",hidden:!0,disabled:W||s,onChange:async N=>{var ve;const ae=(ve=N.target.files)==null?void 0:ve[0];if(N.target.value="",!ae)return;const ge=++b.current;ie(!0),q("");try{const K=await k0(ae);ge===b.current&&ee(K)}catch(K){ge===b.current&&q(K instanceof Error?K.message:"Unable to read SVG.")}finally{ge===b.current&&ie(!1)}}}),f.jsx(B.Tabs.Content,{value:w,p:0,style:{display:"grid",gap:8},children:w==="icons"?f.jsxs(f.Fragment,{children:[f.jsx("input",{"aria-label":"Search icons",placeholder:"Search icons...",value:O,onChange:N=>{T(N.target.value),R(0)},style:G}),f.jsxs("div",{style:{height:244,overflowY:"auto",display:"grid",gridTemplateColumns:"repeat(6, minmax(0, 1fr))",gridAutoRows:36,gap:4},children:[V.map(N=>f.jsx("button",{type:"button","aria-label":`Choose ${N}`,"aria-pressed":r===N,title:N,onClick:()=>ee(N),style:{display:"grid",placeItems:"center",borderRadius:5,border:`${r===N?2:1}px solid ${be(r===N?a:d)}`,background:be(r===N?u:l),color:"inherit",cursor:"pointer"},children:f.jsx(Mr,{name:N,size:24})},N)),V.length===0&&f.jsx("span",{role:"status",style:{gridColumn:"1 / -1"},children:I==="loading"?"Loading icons...":I==="unavailable"?"React icons unavailable":"No icons found"})]}),f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[f.jsxs("span",{role:"status",style:{fontSize:12},children:[Y.length," icons · ",L+1," / ",ce]}),f.jsxs("div",{style:{display:"flex",gap:4},children:[f.jsx(Oe,{label:"Previous icons",children:f.jsx(Se,{"aria-label":"Previous icons",icon:f.jsx(J.PiCaretLeft,{size:18}),size:"sm",variant:"ghost",disabled:L===0,onClick:()=>R(L-1)})}),f.jsx(Oe,{label:"Next icons",children:f.jsx(Se,{"aria-label":"Next icons",icon:f.jsx(J.PiCaretRight,{size:18}),size:"sm",variant:"ghost",disabled:L+1>=ce,onClick:()=>R(L+1)})})]})]})]}):f.jsxs(f.Fragment,{children:[r&&Gr(r)&&f.jsx(Mr,{name:r,size:64}),f.jsxs("button",{type:"button",disabled:W||s,onClick:()=>{var N;return(N=g.current)==null?void 0:N.click()},style:{...G,display:"flex",justifyContent:"center",gap:8,alignItems:"center",cursor:"pointer"},children:[f.jsx(J.PiUploadSimple,{}),W?"Uploading...":"Upload SVG"]}),f.jsxs("form",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},onSubmit:N=>{N.preventDefault(),!(W||s)&&(!Gr(k.trim())||k.trim().startsWith(Qt)?q("Enter an HTTP or HTTPS image URL."):ee(k.trim()))},children:[f.jsx("input",{type:"url","aria-label":"SVG URL",placeholder:"https://example.com/icon.svg",value:k,disabled:W||s,onChange:N=>M(N.target.value),style:{...G,flex:1,minWidth:0}}),f.jsx(Oe,{label:"Apply URL",children:f.jsx(Se,{type:"submit","aria-label":"Apply URL",icon:f.jsx(J.PiArrowRight,{size:20}),size:"sm",variant:"ghost",disabled:W||s||!k.trim(),style:{flexShrink:0}})})]})]})})]}),$&&f.jsx("div",{role:"alert",style:{fontSize:13},children:$})]})})]})}const Pn=["white","blue.500","teal.500","green.500","yellow.500","orange.500","red.500","purple.500","pink.500","gray.500",Pt],Am=["gray.900",Pt,"gray.600","gray.200","white"];function Tm(){const{config:e}=Fe(),t=e.selectionToolbar||{},r=new Set(t.hide||[]);return{palette:t.palette||Pn,show:n=>!r.has(n)}}function gr(){const{border:e}=Ze();return f.jsx(B.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:e})}function ut({value:e,placeholder:t,ariaLabel:r,width:n="140px",type:i="text",min:o,onCommit:s}){const{colorText:a}=Ze(),[c,u]=_.useState(e),l=_.useRef(!1);_.useEffect(()=>u(e),[e]);const d=()=>{if(l.current)return;l.current=!0;const h=c.trim();if(i==="number"&&h!==""&&(!Number.isFinite(Number(h))||Number(h)<(o??0))){u(e);return}h!==e&&s(h)};return f.jsx(B.Input,{"aria-label":r,type:i,min:o,size:"xs",fontSize:"16px",w:n,value:c,placeholder:t,color:a,borderWidth:0,_focusVisible:{boxShadow:"none",outline:"none"},borderRadius:"8px",onFocus:()=>{l.current=!1},onChange:h=>u(h.target.value),onBlur:d,onKeyDown:h=>{h.key==="Enter"&&(d(),h.target.blur()),h.key==="Escape"&&(l.current=!0,u(e),h.target.blur())}})}function lt({colors:e,value:t,label:r,onPick:n,onReset:i,includeTransparent:o=!0}){const{colorInactive:s,colorText:a}=Ze(),[c,u]=_.useState(!1),l=_.useId(),d=_.useRef(null),h=t??e[0]??"transparent",p=On(f.jsx(lt,{colors:e,value:t,label:r,onPick:n,onReset:i,includeTransparent:o}));return f.jsx(Et.Provider,{value:null,children:f.jsxs(B.HStack,{gap:1,"aria-label":r,role:"group",onClickCapture:p,onKeyDown:y=>{var m;y.key==="Escape"&&(u(!1),(m=d.current)==null||m.focus())},children:[f.jsx(Oe,{label:`${r}: ${h}`,children:f.jsx(B.chakra.button,{ref:d,type:"button","aria-label":`${r} colors`,"aria-expanded":c,"aria-controls":l,w:4,h:4,flexShrink:0,borderRadius:"full",cursor:"pointer",style:{backgroundColor:be(h),...h==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:`2px solid ${be(a)}`,outlineOffset:"1px",onClick:()=>u(y=>!y)})}),c&&f.jsxs(B.HStack,{id:l,gap:1,children:[[...new Set([...e,...o?["transparent"]:[]])].map(y=>{const m=t===y;return f.jsx(Oe,{label:`${r}: ${y}`,children:f.jsx(B.Box,{as:"button","aria-label":`${r} ${y}`,"aria-pressed":m,w:4,h:4,borderRadius:"full",cursor:"pointer",style:{backgroundColor:be(y),...y==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:m?`2px solid ${be(a)}`:"none",outlineOffset:"1px",_hover:{transform:"scale(1.15)"},onClick:()=>n(y),onDoubleClick:g=>{var b;g.stopPropagation(),u(!1),(b=d.current)==null||b.focus()}})},y)}),i&&f.jsx(Oe,{label:`Reset ${r.toLowerCase()}`,children:f.jsx(Se,{"aria-label":`Reset ${r}`,icon:f.jsx(B.Icon,{as:J.PiEraser,boxSize:4}),size:"xs",variant:"ghost",color:s,onClick:()=>{var y;i(),u(!1),(y=d.current)==null||y.focus()}})})]})]})})}function Im({edgeId:e,onClose:t}){var p;const{callbacks:r,themeColor:n,config:i}=Fe(),{colorInactive:o}=Ze(),{edgeById:s}=Qr(),{palette:a,show:c}=Tm(),u=(p=s.get(e))==null?void 0:p.data,l=[...new Set(["rounded-orthogonal","orthogonal","straight","bezier",...Object.keys(i.customEdgeTypes??{}),...u!=null&&u.type?[u.type]:[]])],d=u!=null&&u.isEdgeAnimated?"animated":u!=null&&u.isEdgeDashed?"dashed":"solid",h=[{key:"solid",icon:J.PiLineSegment,label:"Solid"},{key:"dashed",icon:J.PiLineSegments,label:"Dashed"},{key:"animated",icon:J.PiFastForward,label:"Animated"}];return f.jsxs(f.Fragment,{children:[f.jsx(At,{onClick:t}),c("label")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(ut,{ariaLabel:"Edge label",placeholder:"Edge label",value:(u==null?void 0:u.label)||"",onCommit:y=>{var m;return(m=r.onEdgeLabelChange)==null?void 0:m.call(r,e,y)}})]}),c("style")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),h.map(y=>f.jsx(Oe,{label:y.label,children:f.jsx(Se,{"aria-label":`Edge style ${y.key}`,"aria-pressed":d===y.key,icon:f.jsx(B.Icon,{as:y.icon,boxSize:5}),size:"sm",variant:"ghost",color:d===y.key?n:o,onClick:()=>{var m;return(m=r.onEdgeStyleChange)==null?void 0:m.call(r,e,y.key)}})},y.key)),d==="animated"&&f.jsx(Pm,{label:"Edge animation",value:(u==null?void 0:u.edgeAnimationVariant)??"dashed",options:[{value:"dashed",label:"Dash"},{value:"traveling",label:"Trace"}],disabled:i.readOnly,onChange:y=>{var m;return(m=r.onEdgeAnimationVariantChange)==null?void 0:m.call(r,e,y)}}),f.jsxs(mr,{"aria-label":"Edge shape",title:`Edge shape: ${(u==null?void 0:u.type)??"Default"}`,icon:f.jsx(J.PiBezierCurve,{size:20}),style:{width:36},value:(u==null?void 0:u.type)??"",disabled:i.readOnly,onValueChange:y=>{var m;return(m=r.onEdgeTypeChange)==null?void 0:m.call(r,e,y||void 0)},children:[f.jsx("option",{value:"",children:"Default"}),l.map(y=>f.jsx("option",{value:y,children:y},y))]})]}),c("icon")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(el,{edgeId:e,value:u==null?void 0:u.icon},e),f.jsx(ut,{ariaLabel:"Edge icon",placeholder:"Icon name or SVG URL",value:(u==null?void 0:u.icon)??"",onCommit:y=>{var m;return(m=r.onEdgeIconChange)==null?void 0:m.call(r,e,y)}})]}),c("color")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(lt,{label:"Edge color",colors:a,value:u==null?void 0:u.color,onPick:y=>{var m;return(m=r.onEdgeColorChange)==null?void 0:m.call(r,e,y)},onReset:()=>{var y;return(y=r.onEdgeColorChange)==null?void 0:y.call(r,e,"")}})]}),c("delete")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(Oe,{label:"Delete edge",children:f.jsx(Se,{"aria-label":"Delete edge",icon:f.jsx(B.Icon,{as:J.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:"red.400",onClick:()=>{var y;(y=r.onEdgeDelete)==null||y.call(r,e,u),t()}})})]})]})}function Om({ids:e,showDivider:t=!0}){const{callbacks:r,config:n}=Fe(),{colorInactive:i}=Ze(),{nodeById:o}=Qr(),[s,a]=_.useState(!1),c=e.map(y=>{var m,g;return(g=(m=o.get(y))==null?void 0:m.data.viewProps)==null?void 0:g.borderRadius}),u=!c.every(y=>y===c[0]),l=u?"mixed":String(c[0]??""),d=["0","8","16","30","53","100"],h=s||!u&&l!==""&&!d.includes(l),p=y=>e.forEach(m=>{var g;return(g=r.onNodeBorderRadiusChange)==null?void 0:g.call(r,m,y)});return f.jsxs(f.Fragment,{children:[t&&f.jsx(gr,{}),f.jsx(B.Box,{position:"relative",w:"36px",h:"30px",display:"grid",placeItems:"center",children:f.jsxs(mr,{icon:f.jsx(B.Icon,{as:Rv.TbBorderRadius,boxSize:5,color:i,"aria-hidden":"true"}),"aria-label":"Node border radius",title:`Border radius: ${u?"Mixed":c[0]===void 0?"Default":`${c[0]}px`}`,style:{position:"absolute",inset:0,width:"100%",height:"100%",cursor:"pointer"},value:h?"custom":l,disabled:n.readOnly,onValueChange:y=>{a(y==="custom"),y!=="custom"&&p(y===""?void 0:Number(y))},children:[f.jsx("option",{value:"",children:"Default radius"}),u&&f.jsx("option",{value:"mixed",disabled:!0,children:"Mixed radii"}),d.map(y=>f.jsxs("option",{value:y,children:[y,"px radius"]},y)),f.jsx("option",{value:"custom",children:"Custom radius"})]})}),h&&f.jsx(ut,{ariaLabel:"Custom border radius",placeholder:u?"Mixed":"Auto",type:"number",min:0,width:"72px",value:u?"":l,onCommit:y=>p(y===""?void 0:Number(y))})]})}function Mm({ids:e,onClose:t}){var ce,L,V,G,N,ae,ge,ve;const{callbacks:r,colorMode:n,themeColor:i,config:o,setNodeViewMode:s}=Fe(),{colorText:a,colorInactive:c}=Ze(),{nodeById:u,parentIds:l}=Qr(),{palette:d,show:h}=Tm(),p=e.length===1,y=p?(ce=u.get(e[0]))==null?void 0:ce.data:void 0,m=e.map(K=>{var te,U;return((U=(te=u.get(K))==null?void 0:te.data.config)==null?void 0:U.typeView)??""}),g=m.some(K=>K!==m[0]),b=g?"mixed":m[0]??"",x=e.some(K=>{var U,se;const te=(U=u.get(K))==null?void 0:U.data;return te&&(l.has(K)||((se=te.config)==null?void 0:se.parentContainer)||Object.prototype.hasOwnProperty.call(o.customViews??{},te.type))}),v=(L=y==null?void 0:y.config)==null?void 0:L.collapsed,w=Rm(e[0]),C=K=>{var te,U,se;return(((U=(te=u.get(K))==null?void 0:te.data.viewProps)==null?void 0:U.outline)??(l.has(K)?(se=o.parentNodeStyle)==null?void 0:se.outline:!1))===!0},S=e.every(C),j=!S&&e.some(C),I=K=>{var te;return((te=u.get(K))==null?void 0:te.data.isNodeAnimated)===!0},P=e.every(I),O=!P&&e.some(I),T=e.map(K=>{var te;return((te=u.get(K))==null?void 0:te.data.nodeAnimationVariant)??"traveling"}),E=T.every(K=>K===T[0])?T[0]:"",R=K=>e.forEach(K),[k,M]=_.useState(!1),$=k&&h("color")&&h("borderColor"),q=K=>{var te,U,se;return(((U=(te=u.get(K))==null?void 0:te.data.viewProps)==null?void 0:U.borderStyle)??(l.has(K)?(se=o.parentNodeStyle)==null?void 0:se.borderStyle:"solid"))==="dashed"},W=e.every(q),ie=!W&&e.some(q),ee=e.map(K=>{var se,ue,we;const te=(se=u.get(K))==null?void 0:se.data,U=l.has(K)?cn((ue=o.parentNodeStyle)==null?void 0:ue.borderWidth,6):(te==null?void 0:te.type)==="objectView"?3:2;return cn((we=te==null?void 0:te.viewProps)==null?void 0:we.borderWidth,U)}),Y=ee.every(K=>K===ee[0])?String(ee[0]??""):"",fe=K=>R(te=>{var U,se;$?(U=r.onNodeBorderColorChange)==null||U.call(r,te,K):(se=r.onNodeColorChange)==null||se.call(r,te,"bg",K)});return f.jsxs(f.Fragment,{children:[f.jsx(At,{onClick:t}),f.jsx(gr,{}),p&&h("label")?f.jsx(ut,{ariaLabel:"Node label",placeholder:"Node label",value:(y==null?void 0:y.label)??(y==null?void 0:y.headerTitle)??"",onCommit:K=>{var te;return(te=r.onNodeLabelChange)==null?void 0:te.call(r,e[0],K)}}):f.jsxs(B.Text,{fontSize:"xs",color:a,whiteSpace:"nowrap",px:1,children:[e.length," selected"]}),h("typeView")&&f.jsxs(mr,{"aria-label":"Type view",title:x?"Type view is managed by the custom renderer or container":`Type view: ${b||"None (default)"}`,icon:f.jsx(J.PiCards,{size:20}),style:{width:36},value:b,disabled:o.readOnly||o.editable===!1||x,onValueChange:K=>{nn.includes(K)&&R(te=>{var U,se;(U=r.onNodeTypeViewChange)==null||U.call(r,te,K||void 0),s(te,"default"),(se=r.onNodeViewToggle)==null||se.call(r,te)})},children:[g&&f.jsx("option",{value:"mixed",disabled:!0,children:"Mixed"}),nn.map(K=>f.jsx("option",{value:K,children:K||"None"},K))]}),h("style")&&f.jsx(Om,{ids:e},e.join("\0")),h("outline")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(Oe,{label:S?"Restore node fill":"Remove node fill",children:f.jsx(Se,{"aria-label":"Toggle node outline","aria-pressed":j?"mixed":S,icon:f.jsx(B.Icon,{as:S?J.PiSquare:J.PiSquareFill,boxSize:5}),size:"sm",variant:"ghost",color:S?i:c,onClick:()=>R(K=>{var te;return(te=r.onNodeOutlineChange)==null?void 0:te.call(r,K,!S)})})})]}),h("color")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),h("borderColor")&&f.jsx(Oe,{label:$?"Edit node colors":"Edit node border",children:f.jsx(Se,{"aria-label":"Edit node border","aria-pressed":$,icon:f.jsx(B.Icon,{as:J.PiBoundingBox,boxSize:5}),size:"sm",variant:"ghost",color:$?i:c,bg:$?n==="dark"?"whiteAlpha.200":"blackAlpha.100":void 0,onClick:()=>M(K=>!K)})}),f.jsx(lt,{label:$?"Border color":"Background",colors:d,value:$?((V=y==null?void 0:y.viewProps)==null?void 0:V.borderColor)??(p&&l.has(e[0])?(G=o.parentNodeStyle)==null?void 0:G.borderColor:void 0):(N=y==null?void 0:y.viewProps)==null?void 0:N.bgColor,onPick:fe,onReset:()=>fe("")}),$&&h("style")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(Oe,{label:W?"Solid border":"Dashed border",children:f.jsx(Se,{"aria-label":"Toggle dashed border","aria-pressed":ie?"mixed":W,icon:f.jsx(B.Icon,{as:W?J.PiLineSegments:J.PiLineSegment,boxSize:5}),size:"sm",variant:"ghost",color:W?i:c,onClick:()=>R(K=>{var te;return(te=r.onNodeBorderStyleChange)==null?void 0:te.call(r,K,W?"solid":"dashed")})})}),f.jsx(ut,{ariaLabel:"Border thickness",placeholder:p?"Auto":"Mixed",width:"64px",type:"number",min:0,value:Y,onCommit:K=>R(te=>{var U;return(U=r.onNodeBorderWidthChange)==null?void 0:U.call(r,te,K===""?void 0:Number(K))})})]})]}),h("animation")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(Oe,{label:P?"Stop border animation":"Animate node border",children:f.jsx(Se,{"aria-label":"Toggle node animation","aria-pressed":O?"mixed":P,icon:f.jsx(B.Icon,{as:J.PiSpinnerGap,boxSize:5}),size:"sm",variant:"ghost",color:P?i:c,onClick:()=>R(K=>{var te;return(te=r.onNodeAnimationChange)==null?void 0:te.call(r,K,!P)})})}),(P||O)&&f.jsx(Pm,{label:"Node animation",value:E,options:[{value:"traveling",label:"Trace"},{value:"pulse",label:"Pulse"}],disabled:o.readOnly,onChange:K=>R(te=>{var U;return(U=r.onNodeAnimationVariantChange)==null?void 0:U.call(r,te,K)})})]}),!$&&h("textColor")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(lt,{label:"Text color",colors:Am,value:(ae=y==null?void 0:y.viewProps)==null?void 0:ae.textColor,onPick:K=>R(te=>{var U;return(U=r.onNodeColorChange)==null?void 0:U.call(r,te,"text",K)}),onReset:()=>R(K=>{var te;return(te=r.onNodeColorChange)==null?void 0:te.call(r,K,"text","")})})]}),p&&h("icon")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(el,{nodeId:e[0],value:(ge=y==null?void 0:y.config)==null?void 0:ge.icon},e[0]),f.jsx(ut,{ariaLabel:"Node icon",placeholder:"(e.g. PiGear)",width:"120px",value:((ve=y==null?void 0:y.config)==null?void 0:ve.icon)||"",onCommit:K=>{var te;return(te=r.onNodeIconChange)==null?void 0:te.call(r,e[0],K)}})]}),p&&w&&h("collapse")&&v!==void 0&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(Oe,{label:v?"Expand":"Collapse",children:f.jsx(Se,{"aria-label":v?"Expand node":"Collapse node",icon:f.jsx(B.Icon,{as:v?J.PiArrowsOutLineVertical:J.PiArrowsInLineVertical,boxSize:5}),size:"sm",variant:"ghost",color:c,onClick:()=>{var K;return(K=r.onNodeCollapse)==null?void 0:K.call(r,e[0],!v)}})})]}),h("delete")&&f.jsxs(f.Fragment,{children:[f.jsx(gr,{}),f.jsx(Oe,{label:p?"Delete node":`Delete ${e.length} nodes`,children:f.jsx(Se,{"aria-label":"Delete selected nodes",icon:f.jsx(B.Icon,{as:J.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:n==="dark"?"red.300":"red.500",onClick:()=>{R(K=>{var te,U;return(U=r.onNodeDelete)==null?void 0:U.call(r,K,((te=u.get(K))==null?void 0:te.data)||{id:K})}),t()}})})]})]})}async function qm(e){const{toSvg:t}=await Promise.resolve().then(()=>require("./index-sHQXTNv9.cjs"));await document.fonts.ready;const r=await t(e,{filter:i=>!(i instanceof Element)||!i.matches("button, iframe, [role=tooltip], .flow-sdk-handle, .flow-sdk-property-port, .flow-sdk-edge-hit, .flow-sdk-ghost, .flow-sdk-node-animation")}),n=new DOMParser().parseFromString(decodeURIComponent(r.slice(r.indexOf(",")+1)),"image/svg+xml");return n.querySelectorAll(".flow-sdk-edge-hit, .flow-sdk-handle, .flow-sdk-property-port, .flow-sdk-ghost").forEach(i=>i.remove()),n.querySelectorAll("[data-flow-preview-source]").forEach(i=>{i.setAttribute("style","display:block;white-space:pre-wrap;font:16px/1.5 monospace;overflow-wrap:anywhere")}),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(n))}`}async function $m(e,t="squeed.svg"){const r=document.createElement("a");r.href=await qm(e),r.download=t.endsWith(".svg")?t:`${t}.svg`,r.click()}function Nm(){const{themeColor:e}=Fe(),[t,r]=_.useState(!1),[n,i]=_.useState("");return f.jsxs(f.Fragment,{children:[f.jsx(Oe,{label:"Download SVG (current view)",children:f.jsx(Se,{"aria-label":"Download SVG",icon:f.jsx(J.PiDownloadSimpleFill,{size:20}),disabled:t,borderRadius:"30%",color:e,variant:"ghost",onClick:async o=>{var a;const s=(a=o.currentTarget.closest("[data-flow-diagram]"))==null?void 0:a.querySelector("[data-flow-background]");if(!s){i("Diagram not available for export.");return}r(!0),i("");try{await $m(s)}catch(c){i(c instanceof Error?c.message:"Unable to export SVG.")}finally{r(!1)}}})}),n&&f.jsx("span",{role:"alert",style:{fontSize:12,maxWidth:220},children:n})]})}function Lm({children:e,background:t,border:r,endElement:n}){const i=_.useRef(null),[o,s]=_.useState({left:!1,right:!1});_.useLayoutEffect(()=>{const c=i.current;let u=c.parentElement.offsetWidth;const l=()=>{const p=c.parentElement.offsetWidth;if(p>0&&p!==u){const g=u/p;u=p,g>0&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches&&c.parentElement.animate({transform:[`scaleX(${g})`,"scaleX(1)"],transformOrigin:[n?"right center":"left center",n?"right center":"left center"]},{duration:180,easing:"ease-out",id:"flow-toolbar-grow"})}const y=c.scrollLeft>1,m=c.scrollWidth-c.clientWidth-c.scrollLeft>1;s(g=>g.left===y&&g.right===m?g:{left:y,right:m})},d=p=>{if(p.defaultPrevented||p.ctrlKey||p.deltaX!==0||!p.deltaY||c.scrollWidth<=c.clientWidth)return;p.preventDefault();const y=p.deltaMode===WheelEvent.DOM_DELTA_LINE?16:p.deltaMode===WheelEvent.DOM_DELTA_PAGE?c.clientWidth:1;c.scrollLeft+=p.deltaY*y},h=new ResizeObserver(l);return h.observe(c),c.firstElementChild&&h.observe(c.firstElementChild),c.addEventListener("scroll",l,{passive:!0}),c.addEventListener("wheel",d,{passive:!1}),l(),()=>{h.disconnect(),c.removeEventListener("scroll",l),c.removeEventListener("wheel",d)}},[]);const a=`var(--chakra-colors-${t.replace(".","-")})`;return f.jsxs(B.Box,{position:"relative",bg:t,minW:0,maxW:"100%",flex:"0 1 auto",borderRadius:"30px",css:Jr(a,`var(--chakra-colors-${r.replace(".","-")})`),children:[f.jsx(B.Box,{ref:i,"data-flow-toolbar-scroll":"",h:50,minH:50,alignContent:"center",overflowX:"auto",overflowY:"hidden",mr:n?"44px":void 0,borderRadius:"inherit",css:{scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:e}),["left","right"].map(c=>f.jsx(B.Box,{"data-flow-toolbar-fade":c,"aria-hidden":"true",position:"absolute",top:0,bottom:0,w:"20px",pointerEvents:"none",borderRadius:c==="left"?"30px 0 0 30px":"0 30px 30px 0",style:{[c]:c==="right"&&n?44:0,opacity:o[c]?1:0,background:`linear-gradient(to ${c==="left"?"right":"left"}, ${a}, transparent)`}},c)),n&&f.jsx(B.Box,{position:"absolute",right:"6px",top:0,h:"50px",w:"32px",display:"flex",alignItems:"center",justifyContent:"center",children:n})]})}async function L0(e,t){const r=new Set,n=[],i=(a,c)=>{var l,d,h;if(!a||typeof a!="object")return;const u=a;n.push(c),typeof((l=u.$form)==null?void 0:l.$type)=="string"&&r.add(u.$form.$type),typeof((h=(d=u.$form)==null?void 0:d.$create)==null?void 0:h.$type)=="string"&&r.add(u.$form.$create.$type);for(const[p,y]of Object.entries(u))p==="$"?i(y,c):p.startsWith("$")||i(y,`${c}.${p}`)};if(i(t,"root"),!r.size)return{contract:await Sm(e)};const o=await Qu(e,[...r]);for(const a of r)if(!Object.prototype.hasOwnProperty.call(o,a))throw new Error(`Missing form type: ${a}`);const s={};for(const a of n){const c=Tt(t,a,o);c&&(s[a]={type:c.type,optional:!1})}return{schema:o,contract:{name:e.name,nodes:s}}}function Fm({message:e,onDismiss:t}){const{background:r,colorText:n,border:i}=Ze();return!e||typeof document>"u"?null:tn.createPortal(f.jsxs(B.chakra.div,{role:"alert","aria-atomic":"true",css:Jr(be(r),be(i)),onPointerDown:o=>o.stopPropagation(),onClick:o=>o.stopPropagation(),style:{position:"fixed",top:20,right:20,zIndex:1e4,width:360,maxWidth:"calc(100vw - 40px)",boxSizing:"border-box",display:"flex",alignItems:"flex-start",gap:10,padding:16,borderRadius:8,background:be(r),color:be(n),fontSize:14,lineHeight:1.5},children:[f.jsx(J.PiWarningCircle,{size:20,"aria-hidden":"true",style:{flexShrink:0,color:"#ef4444"}}),f.jsxs("div",{style:{flex:1,minWidth:0,overflowWrap:"anywhere"},children:[f.jsx("strong",{children:"Interface upload failed"}),f.jsx("div",{children:e})]}),f.jsx(At,{type:"button","aria-label":"Dismiss upload error",title:"Dismiss upload error",onClick:t,flexShrink:0,width:"24px",height:"24px",minWidth:"24px",padding:0})]}),document.body)}function rl({showDivider:e=!0,compact:t=!1}={}){const{edgeMode:r,setEdgeMode:n,workflowContract:i,setWorkflowContract:o,callbacks:s,readOnly:a,themeColor:c,colorMode:u}=Fe(),{edgeById:l}=Qr(),{data:d,schema:h,setSchema:p,bindings:y,structured:m}=_.useContext(Sr),g=(m==null?void 0:m.sourceBindings)??y,b=(m==null?void 0:m.sourceSchema)??h,{colorText:x}=Ze(),v=_.useRef(null),w=_.useRef(0),[C,S]=_.useState(!1),[j,I]=_.useState("");_.useEffect(()=>()=>{w.current++},[]),_.useEffect(()=>{w.current++,S(!1)},[a,d,g]);const P=i?[...l.values()].filter(E=>Xu(i,E.data)).length:0,O=i?`${i.name}: ${b?`${Object.keys(b).length} form types loaded; `:""}${P} invalid or unverified connections`:"",T=On(f.jsx(rl,{showDivider:!1,compact:!0}));return f.jsx(Et.Provider,{value:null,children:f.jsxs("span",{style:{display:"contents"},onClickCapture:T,children:[f.jsx(Fm,{message:j,onDismiss:()=>I("")}),e&&f.jsx(Ht,{}),f.jsxs(mr,{"aria-label":"Edge mode",title:r==="auto"?"Connections: Auto":r==="properties"?"Connections: Properties":"Connections: Nodes",icon:r==="auto"?f.jsx(J.PiGraph,{size:20}):r==="properties"?f.jsx(J.PiTable,{size:20}):f.jsx(J.PiTreeStructure,{size:20}),style:{width:36},value:r,disabled:a,footer:s.onWorkflowConfigurationOpen&&f.jsxs(f.Fragment,{children:[f.jsx("hr",{style:{border:0,borderTop:"1px solid currentColor",opacity:.2,margin:"8px 0"}}),f.jsxs(B.Button,{"data-flow-menu-action":"",variant:"ghost",width:"100%",justifyContent:"flex-start",color:"inherit",bg:"transparent",css:kn,_hover:{bg:u==="dark"?"whiteAlpha.100":"blackAlpha.50"},_focusVisible:{bg:u==="dark"?"whiteAlpha.100":"blackAlpha.50"},onClick:E=>{var R,k;(R=E.currentTarget.closest("[popover]"))==null||R.hidePopover(),(k=s.onWorkflowConfigurationOpen)==null||k.call(s)},children:[f.jsx(J.PiGear,{}),"Configuration"]})]}),onValueChange:E=>{var k;const R=E==="auto"?"auto":E==="properties"?"properties":"nodes";n(R),(k=s.onEdgeModeChange)==null||k.call(s,R)},children:[f.jsx("option",{value:"auto",children:"Auto"}),f.jsx("option",{value:"nodes",children:"Nodes"}),f.jsx("option",{value:"properties",children:"Properties"})]}),f.jsxs("span",{style:{display:r==="auto"||r==="properties"?"contents":"none"},children:[f.jsx(Oe,{label:i?`Replace ${i.name}`:"Upload workflow interface",children:f.jsx(Se,{"aria-label":"Upload workflow interface",icon:f.jsx(J.PiUploadSimple,{size:20}),color:be(c),size:"sm",variant:"ghost",disabled:C||a,onClick:()=>{var E;return(E=v.current)==null?void 0:E.click()}})}),f.jsx("input",{ref:v,type:"file",hidden:!0,accept:".ts,.json","aria-label":"Workflow interface file",disabled:a||C,onChange:async E=>{var M,$;const R=(M=E.target.files)==null?void 0:M[0];if(E.target.value="",!R)return;const k=++w.current;S(!0),I("");try{const q=g?await Qu(R,[...new Set(Object.values(g).map(ee=>ee.schemaType??ee.type))]):void 0;if(g&&q){for(const ee of Object.values(g))if(!Object.prototype.hasOwnProperty.call(q,ee.schemaType??ee.type))throw new Error(`Missing form type: ${ee.schemaType??ee.type}`)}const{contract:W,schema:ie}=g&&q?{schema:q,contract:{name:R.name,nodes:Object.fromEntries(Object.entries(g).map(([ee,Y])=>[ee,{type:q[Y.schemaType??Y.type],optional:!1}]))}}:await L0(R,d);if(k!==w.current)return;p==null||p(ie),o(W),($=s.onWorkflowContractChange)==null||$.call(s,W)}catch(q){k===w.current&&I(`${R.name}: ${q instanceof Error?q.message:"Unable to load interface."}`)}finally{k===w.current&&S(!1)}}}),!t&&(O||C)&&f.jsx("span",{role:"status",title:O,style:{color:be(x),fontSize:12,maxWidth:180,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:C?"Loading interface...":O}),!t&&i&&f.jsx(Oe,{label:"Remove workflow interface",children:f.jsx(Se,{"aria-label":"Remove workflow interface",icon:f.jsx(J.PiX,{size:16}),size:"sm",variant:"ghost",disabled:a||C,onClick:()=>{var E;p==null||p(void 0),o(void 0),(E=s.onWorkflowContractChange)==null||E.call(s,void 0),I("")}})})]})]})})}const F0=[{value:"BT",label:"Bottom to Up",icon:J.PiArrowUp,flowType:Bt.BOTTOM_UP},{value:"TB",label:"Top to Bottom",icon:J.PiArrowDown,flowType:Bt.TOP_DOWN},{value:"LR",label:"Left to Right",icon:J.PiArrowRight,flowType:Bt.LEFT_RIGHT},{value:"RL",label:"Right to Left",icon:J.PiArrowLeft,flowType:Bt.RIGHT_LEFT}],Bm=()=>{const{engineRef:e,themeColor:t,setThemeColor:r,edgeColor:n,setEdgeColor:i,backgroundSelected:o,setBackgroundSelected:s,direction:a,edgeMode:c,allNodesIconLabel:u,setAllNodesIconLabel:l,selectedNodeIds:d,setSelectedNodeIds:h,selectedEdgeId:p,setSelectedEdgeId:y,isZoomMode:m,setIsZoomMode:g,isMultiSelectMode:b,setIsMultiSelectMode:x,isDragMode:v,setIsDragMode:w,isEdgeHandlesEnabled:C,setIsEdgeHandlesEnabled:S,isArrayNodeMode:j,setIsArrayNodeMode:I,isPinned:P,setIsPinned:O,callbacks:T,config:E,readOnly:R}=Fe(),{nodeById:k,edgeById:M,parentIds:$}=Qr(),q=E.colorMode==="dark",{background:W,border:ie,colorInactive:ee,colorText:Y,colorActive:fe}=Ze(),ce=q?ie:"gray.300",L=`var(--chakra-colors-${W.replace(".","-")})`,V=`var(--chakra-colors-${(q?ie:"gray.300").replace(".","-")})`,[G,N]=_.useState(!1),[ae,ge]=_.useState(!0),ve=E.bottomBarCollapsed??ae,K=_.useRef(null),te=$y({edge:"bottom",enabled:!P,bounds:K,inside:[K]}),U=_.useCallback(ye=>{const Me=e.current;if(!Me)return;const nr=E.minZoom??.01,cr=E.maxZoom??1.5,Xe=.02;let xe=Me.zoom();switch(ye){case"increase":xe=Math.min(cr,xe+Xe),Me.zoom(xe),Me.center(!1);break;case"decrease":xe=Math.max(nr,xe-Xe),Me.zoom(xe),Me.center(!1);break;case"reset":Me.fit(50);break}},[e,E.minZoom,E.maxZoom]),se=E.renderSelectedNodeToolbar,ue=d.length>0&&!!se,we=_.useMemo(()=>ue?d.map(ye=>{var nr;return{...((nr=k.get(ye))==null?void 0:nr.data)??{id:ye},isParent:$.has(ye)}}):[],[ue,d,k,$]),pe=_.useCallback(()=>{var ye;h([]),(ye=T.onNodeDeselect)==null||ye.call(T)},[h,T]),qe=E.renderSelectedEdgeToolbar,Q=!!p&&!!qe,he=_.useMemo(()=>{var ye;return!Q||!p?null:((ye=M.get(p))==null?void 0:ye.data)??{id:p}},[Q,p,M]),me=_.useCallback(()=>{var ye;y(null),(ye=T.onEdgeDeselect)==null||ye.call(T)},[y,T]),Re=E.selectionToolbar!==!1&&!R,$e=Re&&!!p&&!qe,Ge=Re&&!$e&&d.length>0&&!se,Ye=$e||Ge,tr=P||te||G||Ye||E.bottomBarCollapsed===!1;_.useEffect(()=>{d.length||p?s(!1):R||(o&&O(!0),E.bottomBarCollapsed===void 0&&ge(!o))},[o,d.length,p,R,s,O,E.bottomBarCollapsed]);const sr=E.renderBottomBar,Ae=h0();return sr?f.jsxs(f.Fragment,{children:[ue&&f.jsx(B.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:se({selectedNodeIds:d,selectedNodeData:we,onDeselect:pe})}),Q&&he&&f.jsx(B.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:qe({edgeId:p,edgeData:he,onDeselect:me})}),f.jsx(B.Box,{position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",children:sr({zoomIn:()=>U("increase"),zoomOut:()=>U("decrease"),resetZoom:()=>U("reset"),direction:a,isZoomMode:m,setIsZoomMode:g,isMultiSelectMode:b,setIsMultiSelectMode:x,isDragMode:v,setIsDragMode:w,isEdgeHandlesEnabled:C,setIsEdgeHandlesEnabled:S,isArrayNodeMode:j,setIsArrayNodeMode:I,selectedNodeIds:d,selectedNodeData:we,selectedEdgeId:p,selectedEdgeData:he,onNodeDeselect:pe,onEdgeDeselect:me,callbacks:T})})]}):f.jsxs(Et.Provider,{value:Ae,children:[ue&&f.jsx(B.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:se({selectedNodeIds:d,selectedNodeData:we,onDeselect:pe})}),Q&&he&&f.jsx(B.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:qe({edgeId:p,edgeData:he,onDeselect:me})}),f.jsx(B.Box,{ref:K,role:"toolbar","aria-label":"Diagram controls",position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",transition:"opacity 0.3s ease-in, transform 0.3s ease",transform:tr?"translateY(0)":"translateY(100%)",pointerEvents:tr?"auto":"none",visibility:tr?"visible":"hidden",opacity:tr?1:0,css:{"@media (hover: none)":{visibility:"visible",opacity:1,transform:"none",pointerEvents:"auto"}},children:f.jsxs(B.Flex,{w:"100%",px:5,position:"absolute",bottom:"calc(20px + env(safe-area-inset-bottom, 0px))",flexDirection:"row",justifyContent:"space-between",alignItems:"center",gap:"24px",css:{"@media (min-width: 1024px)":{"& > :first-of-type":{maxWidth:"50vw"}}},children:[f.jsx(Lm,{background:W,border:q?ie:"gray.300",children:f.jsxs(B.HStack,{px:2,gap:1,flexWrap:"nowrap",w:"max-content",minW:"100%",h:"100%",css:{"& > *":{flexShrink:0}},children:[$e?f.jsx(Im,{edgeId:p,onClose:me}):Ge?f.jsx(Mm,{ids:d,onClose:pe}):null,f.jsxs("div",{style:{display:$e||Ge?"none":"contents"},children:[f.jsx(Oe,{label:P?"Unpin":"Pin",children:f.jsx(Se,{"aria-label":"Pin",icon:f.jsx(B.Icon,{as:P?J.PiPushPinFill:J.PiPushPin,boxSize:5}),size:"sm",variant:"ghost",color:P?t:ee,onClick:()=>{O(!P),N(!1)}})}),f.jsx(B.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:ce}),f.jsx(Oe,{label:"Zoom Out",children:f.jsx(Se,{"aria-label":"Zoom out",rememberAction:!1,icon:f.jsx(B.Icon,{as:J.PiMinus,boxSize:5}),size:"sm",variant:"ghost",color:Y,onClick:()=>U("decrease")})}),f.jsx(Oe,{label:"Zoom In",children:f.jsx(Se,{"aria-label":"Zoom in",rememberAction:!1,icon:f.jsx(B.Icon,{as:J.PiPlus,boxSize:5}),size:"sm",variant:"ghost",color:Y,onClick:()=>U("increase")})}),f.jsx(Oe,{label:"Reset Zoom",children:f.jsx(Se,{"aria-label":"Reset zoom",rememberAction:!1,icon:f.jsx(B.Icon,{as:J.PiArrowCounterClockwise,boxSize:5}),size:"sm",variant:"ghost",color:Y,onClick:()=>U("reset")})}),ve&&f.jsx(p0,{divider:f.jsx(B.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:ce,role:"separator","aria-orientation":"vertical"})}),f.jsxs("span",{style:{display:ve?"none":"contents"},children:[E.edgeHandles!==!1&&f.jsx(Oe,{label:C?"Draw Mode On (V)":"Draw Mode Off (V)",children:f.jsx(Se,{"aria-label":"Toggle draw mode","aria-keyshortcuts":"V","aria-pressed":C,icon:f.jsx(B.Icon,{as:J.PiPencilSimpleLine,boxSize:5}),size:"sm",variant:"ghost",color:C?t:ee,onClick:()=>S(!C)})}),f.jsx(B.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:ce}),f.jsx(Oe,{label:m?"Zoom Mode (z)":"Pan Mode (z)",children:f.jsx(Se,{"aria-label":"Toggle zoom mode",icon:f.jsx(B.Icon,{as:m?J.PiMagnifyingGlassPlus:J.PiArrowsOutCardinal,boxSize:5}),size:"sm",variant:"ghost",color:m?t:ee,onClick:()=>g(!m)})}),f.jsx(B.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:ce}),f.jsx(Oe,{label:b?"Multi-Select On (m)":"Multi-Select Off (m)",children:f.jsx(Se,{"aria-label":"Toggle multi-select",icon:f.jsx(B.Icon,{as:J.PiSelectionPlus,boxSize:5}),size:"sm",variant:"ghost",color:b?t:ee,onClick:()=>x(!b)})}),f.jsx(B.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:ce}),f.jsx(Oe,{label:v?"Drag Mode On (d)":"Drag Mode Off (d)",children:f.jsx(Se,{"aria-label":"Toggle drag mode",icon:f.jsx(B.Icon,{as:J.PiHandGrabbing,boxSize:5}),size:"sm",variant:"ghost",color:v?t:ee,onClick:()=>w(!v)})}),E.bottomBarExtra&&f.jsxs(f.Fragment,{children:[f.jsx(B.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:ce,role:"separator","aria-orientation":"vertical"}),E.bottomBarExtra]}),f.jsx(B.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:ce,role:"separator","aria-orientation":"vertical"}),f.jsx(lm,{}),f.jsx(B.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:ce,role:"separator","aria-orientation":"vertical"}),f.jsx(Wu,{label:"Collapse all",hideLabel:!0,checked:u,icon:f.jsx(B.Icon,{as:J.PiArrowsInLineVertical,boxSize:5}),onChange:l}),c!=="properties"&&f.jsxs(f.Fragment,{children:[f.jsx(B.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:ce}),f.jsx(Oe,{label:j?"Array Mode [ ]":"Set Mode { }",children:f.jsx(Se,{"aria-label":"Toggle array mode",icon:f.jsx(B.Icon,{as:j?J.PiBracketsSquare:J.PiBracketsCurly,boxSize:5}),size:"sm",variant:"ghost",color:j?t:ee,onClick:()=>{var Me;const ye=!j;I(ye),(Me=T.onArrayModeChange)==null||Me.call(T,ye)}})})]}),f.jsx(rl,{}),!R&&f.jsxs("span",{style:{display:o?"contents":"none"},children:[f.jsx(B.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:ce}),f.jsx(lt,{label:"Graph theme",colors:Pn,value:t,includeTransparent:!1,onPick:ye=>{var Me;r(ye),(Me=T.onThemeColorChange)==null||Me.call(T,ye)}})]}),!R&&f.jsxs(f.Fragment,{children:[f.jsx(B.Icon,{as:J.PiLineVerticalThin,boxSize:5,color:ce,role:"separator","aria-orientation":"vertical"}),f.jsx(lt,{label:"Graph edge color",colors:Pn,value:n||(q?"gray.500":Pt),onPick:i,onReset:()=>i("")}),f.jsx(B.Icon,{as:J.PiLineVerticalThin,boxSize:5,color:ce,role:"separator","aria-orientation":"vertical"})]}),f.jsx(fm,{})]}),f.jsx(B.Icon,{mx:-1,as:J.PiLineVerticalThin,boxSize:5,color:ce}),f.jsx(Oe,{label:ve?"Expand toolbar":"Collapse toolbar",children:f.jsx(Se,{"aria-label":"Toggle toolbar collapse",rememberAction:!1,icon:f.jsx(B.Icon,{as:ve?J.PiCaretRight:J.PiCaretLeft,boxSize:5}),size:"sm",variant:"ghost",color:ee,onClick:()=>{var ye;E.bottomBarCollapsed===void 0&&ge(!ve),s(ve),(ye=T.onBottomBarCollapsedChange)==null||ye.call(T,!ve)}})}),!ve&&f.jsx(Nm,{})]})]})}),!Ye&&f.jsxs(B.Box,{position:"relative",ml:"auto",flexShrink:0,children:[f.jsx(B.Box,{"data-flow-direction-control":"",bg:W,borderRadius:"30px",h:50,css:Jr(L,V),px:3,cursor:"pointer",onClick:()=>N(!G),children:f.jsxs(B.Flex,{align:"center",h:"100%",children:[f.jsx(Oe,{label:"Flow Direction",children:f.jsx(Se,{"aria-label":"Direction",onClick:ye=>{ye.stopPropagation(),N(!G)},icon:f.jsx(B.Icon,{as:J.PiCaretUp,boxSize:5}),size:"sm",variant:"ghost",color:ee})}),f.jsx(B.Text,{fontSize:"xs",textTransform:"uppercase !important",color:q?"whiteAlpha.600":"blackAlpha.500",ml:1,children:a.toUpperCase()})]})}),G&&f.jsx(B.Box,{position:"absolute",bottom:"100%",right:0,pb:"24px",zIndex:200,children:f.jsxs(B.Box,{bg:W,borderRadius:"30px",p:2,minW:"180px",css:Jr(L,V),children:[F0.map(ye=>f.jsxs(B.Flex,{align:"center",gap:3,px:3,py:2,css:kn,cursor:"pointer",_hover:{bg:q?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var Me;(Me=T.onDirectionChange)==null||Me.call(T,ye.value),N(!1)},children:[f.jsx(B.Icon,{as:ye.icon,boxSize:5,color:Y}),f.jsx(B.Text,{fontSize:"sm",color:Y,flex:1,whiteSpace:"nowrap",children:ye.label}),a===ye.value&&f.jsx(B.Icon,{as:J.PiCheck,boxSize:4,color:fe})]},ye.value)),f.jsxs(B.Flex,{align:"center",gap:3,px:3,py:2,css:kn,cursor:"pointer",_hover:{bg:q?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var ye;(ye=T.onDirectionChange)==null||ye.call(T,"C"),N(!1)},children:[f.jsx(B.Icon,{as:J.PiAlignCenterHorizontal,boxSize:5,color:Y}),f.jsx(B.Text,{fontSize:"sm",color:Y,flex:1,whiteSpace:"nowrap",children:"Center"}),a==="C"&&f.jsx(B.Icon,{as:J.PiCheck,boxSize:4,color:fe})]})]})})]})]})})]})};Bm.displayName="BottomBar";const zm=_.memo(Bm);function B0({checked:e,onChange:t,disabled:r,label:n="Connected nodes"}){return f.jsx(Wu,{hideLabel:!0,label:n,helper:`${n}: isolate node and its connections`,checked:e,onChange:t,disabled:r,icon:f.jsx(B.Icon,{as:J.PiGraph,boxSize:5})})}const Jl={$bgColor:"bgColor",$textColor:"textColor",$borderColor:"borderColor"};function Dm(e,t){const r=new Map,n=(o,s)=>{if(Object.is(o,s))return!0;if(!o||!s||typeof o!="object"||typeof s!="object"||Array.isArray(o)!==Array.isArray(s))return!1;const a=Object.keys(o);return a.length===Object.keys(s).length&&a.every(c=>Object.prototype.hasOwnProperty.call(s,c)&&n(o[c],s[c]))},i=(o,s,a)=>{if(o===s)return!0;if(!o||!s||typeof o!="object"||typeof s!="object"||Array.isArray(o)!==Array.isArray(s))return!1;const c=new Set([...Object.keys(o),...Object.keys(s)]);for(const u of c)if(!n(o[u],s[u])){if(Object.prototype.hasOwnProperty.call(Jl,u)){if(typeof s[u]!="string"||!s[u])return!1;r.set(a,{...r.get(a),[Jl[u]]:s[u]})}else if(u.startsWith("$")&&u!=="$"||!i(o[u],s[u],u==="$"?a:`${a}.${u}`))return!1}return!0};if(i(e,t,"root"))return r}function z0(e,t){return Dm(e,t)!==void 0}function D0(e,t,r){if(e===t)return r;const n=Dm(e,t);if(!n)return;const i=new Set(r.nodes.map(o=>o.data.id));for(const o of n.keys())if(!i.has(o)||!ke(t,o))return;return{edges:r.edges,nodes:r.nodes.map(o=>{const s=n.get(o.data.id),a=ke(e,o.data.id),c=ke(t,o.data.id);return!s&&a===c?o:{...o,data:{...o.data,...typeof o.data.code=="string"?{code:JSON.stringify(c,null,2)}:{},...s?{viewProps:{...o.data.viewProps,...s},config:{...o.data.config,...s}}:{}}}})}}function Lu(e){return e.kind==="literal"?e.value:e.kind==="union"?Lu(e.types[0]):e.kind==="array"?[]:e.kind==="object"?Object.fromEntries(Object.entries(e.properties).filter(([,t])=>!t.optional).map(([t,r])=>[t,Lu(r.type)])):e.kind==="boolean"?!1:e.kind==="number"||e.kind==="integer"?0:e.kind==="null"?null:""}function Vm(e,t,r){var g,b,x;const n=(g=ke(e,t))==null?void 0:g.$form,i=n==null?void 0:n.$create;if(!i)return;const o=i.$address.split(".");if(o.shift()!=="root"||!o.length||o.some(v=>!/^[A-Za-z0-9_-]+$/.test(v)||["__proto__","constructor","prototype"].includes(v)))throw new Error("Invalid form creation address.");if(!r||!Object.prototype.hasOwnProperty.call(r,i.$type))throw new Error(`Load form type: ${i.$type}`);const s=o.pop(),a=["root",...o].join("."),c=Tt(e,a,r),u=(b=c==null?void 0:c.type.properties[s])==null?void 0:b.type;if((u==null?void 0:u.kind)!=="array"||u.items.kind!=="object")throw new Error("Form creation must target an object-array field.");const l=r[i.$type],d=i.$defaults??{};for(const[v,w]of Object.entries(d))if(!Object.prototype.hasOwnProperty.call(l.properties,v)||Pr(l.properties[v].type,w,!l.properties[v].optional))throw new Error(`Invalid creation default: ${v}`);const h={...Lu(l),...structuredClone(d)};((x=l.properties.id)==null?void 0:x.type.kind)==="string"&&(h.id=Gu());let p=e;const y=ke(e,i.$address);if(y===void 0)p=vr(e,a,v=>({...v,[s]:[]}));else if(!Array.isArray(y)&&!Array.isArray(y==null?void 0:y.$))throw new Error("Form creation destination is not an array.");const m=Ku(p,i.$address,{...h,$label:i.$label??i.$type,...i.$icon?{$icon:i.$icon}:{},$form:{$type:i.$type,$create:i}});return{address:m.address,json:Ju(m.json,t,{target:m.address,label:i.$edgeLabel})}}function V0(e,t){const r=i=>e&&typeof e=="object"&&i in e;let n=1;for(;r(`${t}_${n}`);)n++;return`${t}_${n}`}function Wm(e,t,r,n,i){const o=(a,c)=>{a!==e&&(e=a,n==null||n(a,c))},s=a=>{var u;const c=(u=t.find(l=>l.data.id===a))==null?void 0:u.data;return c&&{source:c.source,target:c.target,isInverted:c.isInverted,sourceProperty:c.sourceProperty,targetProperty:c.targetProperty,connection:c.connection}};return{...r,onFormChange:a=>{const c=ke(e,a.nodeAddress);if(!c||a.nodeId!==void 0&&c.id!==a.nodeId)throw new Error("This form node has moved. Retry the edit.");o(Ln(e,a,r.onFormChange),{type:"form",address:a.address,value:a.value})},onNodeLabelChange:(a,c)=>{var u;(u=r.onNodeLabelChange)==null||u.call(r,a,c),o(hr(e,a,"$label",c),{type:"nodeLabel",address:a,key:"$label",value:c})},onNodeContentChange:(a,c)=>{var u;(u=r.onNodeContentChange)==null||u.call(r,a,c),o(hr(e,a,"$content",c),{type:"nodeContent",address:a,key:"$content",value:c})},onNodeTypeViewChange:(a,c)=>{var u;c!==void 0&&!nn.includes(c)||((u=r.onNodeTypeViewChange)==null||u.call(r,a,c),o(hr(e,a,"$view",c),{type:"nodeStyle",address:a,key:"$view",value:c}))},onNodeColorChange:(a,c,u)=>{var d;(d=r.onNodeColorChange)==null||d.call(r,a,c,u);const l=c==="bg"?"$bgColor":"$textColor";o(hr(e,a,l,u),{type:"nodeColor",address:a,key:l,value:u})},onNodeBorderColorChange:(a,c)=>{var u;(u=r.onNodeBorderColorChange)==null||u.call(r,a,c),o(hr(e,a,"$borderColor",c),{type:"nodeColor",address:a,key:"$borderColor",value:c})},onNodeBorderStyleChange:(a,c)=>{var u;(u=r.onNodeBorderStyleChange)==null||u.call(r,a,c),o(hr(e,a,"$borderStyle",c),{type:"nodeStyle",address:a,key:"$borderStyle",value:c})},onNodeBorderWidthChange:(a,c)=>{var u;c!==void 0&&(!Number.isFinite(c)||c<0)||((u=r.onNodeBorderWidthChange)==null||u.call(r,a,c),o(hr(e,a,"$borderWidth",c),{type:"nodeStyle",address:a,key:"$borderWidth",value:c}))},onNodeBorderRadiusChange:(a,c)=>{var u;c!==void 0&&(!Number.isFinite(c)||c<0)||((u=r.onNodeBorderRadiusChange)==null||u.call(r,a,c),o(hr(e,a,"$borderRadius",c),{type:"nodeStyle",address:a,key:"$borderRadius",value:c}))},onNodeIconChange:(a,c)=>{var u;(u=r.onNodeIconChange)==null||u.call(r,a,c),o(hr(e,a,"$icon",c),{type:"nodeIcon",address:a,key:"$icon",value:c})},onNodeOutlineChange:(a,c)=>{var u;(u=r.onNodeOutlineChange)==null||u.call(r,a,c),o(hr(e,a,"$outline",c),{type:"nodeOutline",address:a,key:"$outline",value:c})},onNodeAnimationChange:(a,c)=>{var u;(u=r.onNodeAnimationChange)==null||u.call(r,a,c),o(hr(e,a,"$isNodeAnimated",c),{type:"nodeAnimation",address:a,key:"$isNodeAnimated",value:c})},onNodeAnimationVariantChange:(a,c)=>{var u;c!=="traveling"&&c!=="pulse"||((u=r.onNodeAnimationVariantChange)==null||u.call(r,a,c),o(hr(e,a,"$nodeAnimationVariant",c),{type:"nodeAnimation",address:a,key:"$nodeAnimationVariant",value:c}))},onNodeCollapse:(a,c)=>{var u;(u=r.onNodeCollapse)==null||u.call(r,a,c),o(mm(e,a,c),{type:"nodeCollapse",address:a,key:"$collapsed",value:c})},onNodeCreate:a=>{var y,m;const c=a.sourceNodeId&&Vm(e,a.sourceNodeId,i);if(c){(y=r.onNodeCreate)==null||y.call(r,a),o(c.json,{type:"nodeCreate",address:c.address,value:"form"});return}(m=r.onNodeCreate)==null||m.call(r,a);const u=a.sourceNodeId||"root",l=ke(e,u),d=V0(l,a.isArrayMode?"list":"node"),h=a.isArrayMode?{$bgColor:"gray.500",$:[]}:{$bgColor:"gray.500"},p=Ku(e,u,h,d);o(p.json,{type:"nodeCreate",address:p.address,value:a.isArrayMode?"array":"set"})},onNodeDelete:(a,c)=>{var u;(u=r.onNodeDelete)==null||u.call(r,a,c),o(vm(e,a),{type:"nodeDelete",address:a})},onEdgeCreate:(a,c,u)=>{var d;(d=r.onEdgeCreate)==null||d.call(r,a,c,u);const l=u&&(u.sourceProperty!==void 0||u.targetProperty!==void 0)?{...u,target:c}:void 0;o(l?Ju(e,a,l):xm(e,a,c),{type:"edgeCreate",address:a,key:l?"$connections":"$target",value:l??c})},onEdgeLabelChange:(a,c)=>{var l;(l=r.onEdgeLabelChange)==null||l.call(r,a,c);const u=s(a);u&&o(Hr(e,u,"$sourceLabel",c),{type:"edgeLabel",edge:u,key:u.connection?"$connections":"$sourceLabel",value:c})},onEdgeStyleChange:(a,c)=>{var l;(l=r.onEdgeStyleChange)==null||l.call(r,a,c);const u=s(a);u&&o(bm(e,u,c),{type:"edgeStyle",edge:u,value:c})},onEdgeAnimationVariantChange:(a,c)=>{var l;if(c!=="dashed"&&c!=="traveling")return;(l=r.onEdgeAnimationVariantChange)==null||l.call(r,a,c);const u=s(a);u&&o(Hr(e,u,"$edgeAnimationVariant",c),{type:"edgeStyle",edge:u,key:u.connection?"$connections":"$edgeAnimationVariant",value:c})},onEdgeTypeChange:(a,c)=>{var l;(l=r.onEdgeTypeChange)==null||l.call(r,a,c);const u=s(a);u&&o(Hr(e,u,"$edgeType",c),{type:"edgeStyle",edge:u,key:u.connection?"$connections":"$edgeType",value:c})},onEdgeIconChange:(a,c)=>{var l;(l=r.onEdgeIconChange)==null||l.call(r,a,c);const u=s(a);u&&o(Hr(e,u,"$edgeIcon",c||void 0),{type:"edgeStyle",edge:u,key:u.connection?"$connections":"$edgeIcon",value:c})},onEdgeColorChange:(a,c)=>{var l;(l=r.onEdgeColorChange)==null||l.call(r,a,c);const u=s(a);u&&o(Hr(e,u,"$edgeColor",c),{type:"edgeColor",edge:u,key:u.connection?"$connections":"$edgeColor",value:c})},onEdgeDelete:(a,c)=>{var d;(d=r.onEdgeDelete)==null||d.call(r,a,c);const u=s(a);if(!u)return;const l=wm(e,u);l.removed&&o(l.json,{type:"edgeDelete",edge:u,key:u.connection?"$connections":"$target"})}}}const W0=".flow-sdk-edge-trace{pointer-events:none;animation:flow-sdk-edge-trace 2.4s linear infinite}.flow-sdk-edge-trace-reverse{animation-direction:reverse}@keyframes flow-sdk-edge-trace{from{stroke-dashoffset:18}to{stroke-dashoffset:-100}}@media(prefers-reduced-motion:reduce){.flow-sdk-edge-trace,.flow-sdk-edge-anim{animation:none}}";function G0({path:e,color:t,width:r,reversed:n}){return f.jsx("path",{className:`flow-sdk-edge-trace${n?" flow-sdk-edge-trace-reverse":""}`,"data-animation-variant":"traveling","aria-hidden":"true",pointerEvents:"none",d:e,fill:"none",stroke:t,strokeWidth:r,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 100"})}const U0=".flow-sdk-edge-reveal{animation:flow-sdk-edge-reveal var(--flow-edge-reveal-duration,600ms) linear both;animation-play-state:var(--flow-edge-reveal-state,running)}.flow-sdk-edge-reveal-end{animation:flow-sdk-edge-reveal-end var(--flow-edge-reveal-duration,600ms) steps(1,end) both;animation-play-state:var(--flow-edge-reveal-state,running)}@keyframes flow-sdk-edge-reveal{from{stroke-dashoffset:var(--flow-edge-reveal-from,100)}to{stroke-dashoffset:0}}@keyframes flow-sdk-edge-reveal-end{from{opacity:0}to{opacity:1}}@media(prefers-reduced-motion:reduce){.flow-sdk-edge-reveal{animation:none;stroke-dashoffset:0}.flow-sdk-edge-reveal-end{animation:none;opacity:1}}";function H0({path:e,width:t,reversed:r,children:n,onComplete:i}){const o=`flow-edge-reveal-${_.useId().replace(/:/g,"")}`,s=_.useRef(null),[a,c]=_.useState({x:0,y:0,width:1,height:1});return _.useEffect(()=>{const u=matchMedia("(prefers-reduced-motion: reduce)"),l=()=>{u.matches&&(i==null||i())};return l(),u.addEventListener("change",l),()=>u.removeEventListener("change",l)},[i]),_.useLayoutEffect(()=>{var l;const u=(l=s.current)==null?void 0:l.getBBox();u&&c({x:u.x-t,y:u.y-t,width:u.width+t*2,height:u.height+t*2})},[e,t]),f.jsxs(f.Fragment,{children:[f.jsx("defs",{children:f.jsx("mask",{id:o,maskUnits:"userSpaceOnUse",...a,children:f.jsx("path",{ref:s,className:"flow-sdk-edge-reveal",onAnimationEnd:u=>{u.animationName==="flow-sdk-edge-reveal"&&(i==null||i())},"data-reveal-direction":r?"reverse":"forward",style:{"--flow-edge-reveal-from":r?-100:100},d:e,fill:"none",stroke:"white",strokeWidth:t,strokeLinecap:"butt",strokeLinejoin:"round",pathLength:100,strokeDasharray:"100 100"})})}),f.jsx("g",{mask:`url(#${o})`,children:n})]})}const K0=".flow-sdk-node-animation{position:absolute;inset:0;width:100%;height:100%;overflow:visible;pointer-events:none;z-index:1}.flow-sdk-node-border-animation{pointer-events:none;animation:flow-sdk-node-border 2.4s linear infinite}.flow-sdk-node-border-pulse{stroke-width:var(--flow-pulse-rest-width);animation:flow-sdk-node-pulse 1.8s ease-in-out infinite}@keyframes flow-sdk-node-border{from{stroke-dashoffset:0}to{stroke-dashoffset:-100}}@keyframes flow-sdk-node-pulse{0%,100%{stroke-width:var(--flow-pulse-rest-width)}50%{stroke-width:var(--flow-pulse-expanded-width)}}@media(prefers-reduced-motion:reduce){.flow-sdk-node-border-animation{animation:none}}";function Gm({x:e=0,y:t=0,width:r,height:n,radius:i,color:o,strokeWidth:s=8,path:a,variant:c="traveling"}){const u=_.useId(),l=`flow-sdk-node-border-animation${c==="pulse"?" flow-sdk-node-border-pulse":""}`;if(c==="pulse"){const d=a?"path":"rect",h=a?{d:a}:{x:e,y:t,width:Math.max(0,r),height:Math.max(0,n),rx:Math.max(0,Math.min(i,r/2,n/2))},p=s+36,y={x:e-p,y:t-p,width:r+2*p,height:n+2*p};return f.jsxs("g",{"aria-hidden":"true",pointerEvents:"none",children:[f.jsx("defs",{children:f.jsxs("mask",{id:u,maskUnits:"userSpaceOnUse",...y,style:{maskType:"luminance"},children:[f.jsx("rect",{...y,fill:"white"}),f.jsx(d,{...h,fill:"black",stroke:"black",strokeWidth:s,strokeLinejoin:"round"})]})}),f.jsx(d,{...h,className:l,"data-animation-variant":c,fill:"none",stroke:`color-mix(in srgb, ${o} 30%, transparent)`,strokeLinejoin:"round",mask:`url(#${u})`,style:{"--flow-pulse-rest-width":`${s+16}px`,"--flow-pulse-expanded-width":`${s+36}px`}})]})}return a?f.jsx("path",{className:l,"data-animation-variant":c,"aria-hidden":"true",pointerEvents:"none",d:a,fill:"none",stroke:o,strokeWidth:s,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"}):f.jsx("rect",{className:l,"data-animation-variant":c,"aria-hidden":"true",pointerEvents:"none",x:e,y:t,width:Math.max(0,r),height:Math.max(0,n),rx:Math.max(0,Math.min(i,r/2,n/2)),fill:"none",stroke:o,strokeWidth:s,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"})}const J0=e=>{const n=1/(Math.cbrt(e)*.8);let i=Math.round(650*n),o=Math.round(350*n);return i=Math.max(40,Math.min(450,i)),o=Math.max(30,Math.min(300,o)),{edgeSep:i,rankSep:o}};function Zl(e,t,r){const n=new Set([e]),i=[e];for(;i.length;){const o=i.pop();for(const s of t)(s.parent===o||s.id.startsWith(`${o}.`)||r.some(c=>(c.inverted?c.target:c.source)===o&&(c.inverted?c.source:c.target)===s.id))&&!n.has(s.id)&&(n.add(s.id),i.push(s.id))}return n}function Z0(e,t,r){const n=r==="downward"||r==="upward",i=new Map;for(const s of e){if(s.source===s.target||s.sourceProperty||s.targetProperty)continue;const a=t(s.source),c=t(s.target);if(!a||!c)continue;const u=n?c.y-a.y:c.x-a.x,l=Math.abs(u)-(n?a.h+c.h:a.w+c.w)/2;if(l<=320)continue;const d=JSON.stringify([s.source,Math.sign(u)]),h=i.get(d)??[];h.push({edge:s,gap:l,cross:n?c.x-a.x:c.y-a.y}),i.set(d,h)}const o=new Map;for(const s of i.values()){if(new Set(s.map(({edge:c})=>c.target)).size<2)continue;const a=new Map;for(const{edge:c}of s)a.set(c.target,(a.get(c.target)??0)+1);for(const c of[-1,0,1]){const u=s.filter(({cross:d})=>Math.sign(d)===c);u.sort((d,h)=>Math.abs(h.cross)-Math.abs(d.cross)||d.edge.id.localeCompare(h.edge.id));const l=Math.min(...u.map(({gap:d})=>d));u.forEach(({edge:d,gap:h,cross:p},y)=>{const m=u.length===1?l/2:120+(l-280)*y/(u.length-1),g=u.find(b=>Math.abs(b.cross)<Math.abs(p));o.set(d.id,{turn:m/h,labelAtTarget:a.get(d.target)===1,labelFraction:p?(p+((g==null?void 0:g.cross)??0))/(2*p):.5})})}}return o}const bt=e=>({x1:e.x-e.w/2,y1:e.y-e.h/2,x2:e.x+e.w/2,y2:e.y+e.h/2}),Y0=e=>({x:(e.x1+e.x2)/2,y:(e.y1+e.y2)/2,w:e.x2-e.x1,h:e.y2-e.y1});function yo(e){if(!e.length)return null;const t={...e[0]};for(let r=1;r<e.length;r++)t.x1=Math.min(t.x1,e[r].x1),t.y1=Math.min(t.y1,e[r].y1),t.x2=Math.max(t.x2,e[r].x2),t.y2=Math.max(t.y2,e[r].y2);return t}const X0=(e,t)=>e.x1<=t.x2&&e.x2>=t.x1&&e.y1<=t.y2&&e.y2>=t.y1,Yl=(e,t)=>e.x>=t.x1&&e.x<=t.x2&&e.y>=t.y1&&e.y<=t.y2,wr=e=>(Math.round(e*10)/10).toString(),Qe=e=>`${wr(e.x)} ${wr(e.y)}`,Q0=e=>e>0?1:e<0?-1:0,Xl=(e,t)=>e>0?Math.max(e-t,0):Math.min(e+t,0);function ew(e,t,r,n,i=10){const o=t.x-e.x,s=t.y-e.y,a=Xl(o,(e.w+t.w)/2),c=Xl(s,(e.h+t.h)/2),u=r==="downward"||r==="upward",l=u?c:a,d=u?s:o,h=Q0(d),p=n*l,y=x=>Math.abs(x)<i||Math.abs(x)>=Math.abs(l),m=y(p)||y(Math.abs(l)-Math.abs(p));let g;if(m)if(u)if(Math.abs(d)<=e.h/2){const x=(e.x+t.x)/2;g=[x,e.y,x,t.y]}else if(Math.abs(o)<=t.w/2){const x=(e.y+t.y)/2;g=[e.x,x,t.x,x]}else g=[e.x,t.y];else if(Math.abs(d)<=e.w/2){const x=(e.y+t.y)/2;g=[e.x,x,t.x,x]}else if(Math.abs(s)<=t.h/2){const x=(e.x+t.x)/2;g=[x,e.y,x,t.y]}else g=[t.x,e.y];else if(u){const x=e.y+p+e.h/2*h;g=[e.x,x,t.x,x]}else{const x=e.x+p+e.w/2*h;g=[x,e.y,x,t.y]}const b=[{x:e.x,y:e.y}];for(let x=0;x<g.length;x+=2)b.push({x:g[x],y:g[x+1]});return b.push({x:t.x,y:t.y}),b}function rw(e,t,r){const n=t.x-e.x,i=t.y-e.y,o=n>0?(r.x2-e.x)/n:n<0?(r.x1-e.x)/n:1/0,s=i>0?(r.y2-e.y)/i:i<0?(r.y1-e.y)/i:1/0,a=Math.min(o,s);return!Number.isFinite(a)||a>=1||a<0?null:{x:e.x+n*a,y:e.y+i*a}}function kt(e,t,r){var s;if(!((s=r.outline)!=null&&s.length))return rw(e,t,bt(r));const n=t.x-e.x,i=t.y-e.y;let o=1/0;return r.outline.forEach((a,c,u)=>{const l=u[(c+1)%u.length],d=l.x-a.x,h=l.y-a.y,p=n*h-i*d;if(Math.abs(p)<1e-9)return;const y=a.x-e.x,m=a.y-e.y,g=(y*h-m*d)/p,b=(y*i-m*n)/p;g>=0&&g<1&&b>=-1e-9&&b<=1+1e-9&&(o=Math.min(o,g))}),Number.isFinite(o)?{x:e.x+n*o,y:e.y+i*o}:null}function Um(e,t,r=.5){const n=Number.isFinite(r)?Math.max(0,Math.min(1,r)):.5,i=t==="top"||t==="bottom",o=t==="top"||t==="left"?-1:1,s={x:i?e.x-e.w/2+e.w*n:e.x,y:i?e.y:e.y-e.h/2+e.h*n},a=Math.max(e.w,e.h)*2+1;return{...kt(s,{x:s.x+(i?0:o*a),y:s.y+(i?o*a:0)},e)??{x:i?s.x:e.x+o*e.w/2,y:i?e.y+o*e.h/2:s.y},side:t}}function wt(e,t){return{x:e.x+(e.side==="right"?t:e.side==="left"?-t:0),y:e.y+(e.side==="bottom"?t:e.side==="top"?-t:0)}}function tw(e,t,r,n){const i=wt(e,r.srcDist),o=wt(t,r.tgtDist);if(n==="straight")return Km(i,o,r);const s=Math.max(80,Math.min(300,Math.hypot(o.x-i.x,o.y-i.y)/3)),a=e.side==="bottom"&&t.side==="top"?o.y-i.y:e.side==="top"&&t.side==="bottom"?i.y-o.y:e.side==="right"&&t.side==="left"?o.x-i.x:e.side==="left"&&t.side==="right"?i.x-o.x:void 0,c=a!==void 0&&a>0?Math.min(s,a/2):s,u=wt({...i,side:e.side},c),l=wt({...o,side:t.side},c),d=r.arrowAt==="source"?ar(i,u,r.arrowGap):i,h=r.arrowAt==="target"?ar(o,l,r.arrowGap):o,p=r.arrowAt==="source"?_r(i,u,r.arrowSize,r.headShape):r.arrowAt==="target"?_r(o,l,r.arrowSize,r.headShape):void 0;if(n==="bezier")return{d:`M${Qe(d)} C${Qe(u)} ${Qe(l)} ${Qe(h)}`,arrow:p,label:{x:(d.x+3*u.x+3*l.x+h.x)/8,y:(d.y+3*u.y+3*l.y+h.y)/8,angle:0}};const y=e.side==="left"||e.side==="right",m=t.side==="left"||t.side==="right";let g;if(y!==m){const x=y?{x:l.x,y:u.y}:{x:u.x,y:l.y},v=(x.x-u.x)*(u.x-i.x)+(x.y-u.y)*(u.y-i.y)>=0,w=(x.x-l.x)*(l.x-o.x)+(x.y-l.y)*(l.y-o.y)>=0;g=[v&&w?x:y?{x:u.x,y:l.y}:{x:l.x,y:u.y}]}else if(a!==void 0&&a<=0)if(y){const x=(u.y+l.y)/2;g=[{x:u.x,y:x},{x:l.x,y:x}]}else{const x=(u.x+l.x)/2;g=[{x,y:u.y},{x,y:l.y}]}else if(y){const x=e.side===t.side?e.side==="right"?Math.max(u.x,l.x):Math.min(u.x,l.x):(u.x+l.x)/2;g=[{x,y:u.y},{x,y:l.y}]}else{const x=e.side===t.side?e.side==="bottom"?Math.max(u.y,l.y):Math.min(u.y,l.y):(u.y+l.y)/2;g=[{x:u.x,y:x},{x:l.x,y:x}]}const b=[u,...g,l].filter((x,v,w)=>v===0||x.x!==w[v-1].x||x.y!==w[v-1].y);return Fn(d,b,h,p,n==="orthogonal"?0:r.radius)}function ar(e,t,r){const n=e.x-t.x,i=e.y-t.y,o=Math.hypot(n,i);if(!o)return e;let s=(o-r)/o;return s<0&&(s=1e-5),{x:t.x+s*n,y:t.y+s*i}}function _r(e,t,r,n="triangle"){const i=e.x-t.x,o=e.y-t.y,s=Math.hypot(i,o)||1,a=i/s,c=o/s,u=(n==="square"?.15:.3)*r,l=.15*r,d=e.x-a*u,h=e.y-c*u;if(n==="square")return`M${Qe(e)} L${wr(e.x-c*l)} ${wr(e.y+a*l)} L${wr(d-c*l)} ${wr(h+a*l)} L${wr(d+c*l)} ${wr(h-a*l)} L${wr(e.x+c*l)} ${wr(e.y-a*l)} Z`;const p=[e,{x:d-c*l,y:h+a*l},{x:d+c*l,y:h-a*l}];return p.map((m,g)=>{const b=p[(g+2)%3],x=p[(g+1)%3],v=Math.hypot(b.x-m.x,b.y-m.y),w=Math.hypot(x.x-m.x,x.y-m.y),C={x:(b.x-m.x)/v,y:(b.y-m.y)/v},S={x:(x.x-m.x)/w,y:(x.y-m.y)/w},j=Math.max(-1,Math.min(1,C.x*S.x+C.y*S.y)),I=Math.sqrt((1-j)/(1+j)),P=Math.min(1/I,v/2,w/2);return{start:{x:m.x+C.x*P,y:m.y+C.y*P},end:{x:m.x+S.x*P,y:m.y+S.y*P},radius:P*I}}).map((m,g)=>`${g?"L":"M"}${Qe(m.start)} A${wr(m.radius)} ${wr(m.radius)} 0 0 1 ${Qe(m.end)}`).join(" ")+" Z"}function Ur(e,t){let r=Math.atan(t/e);return e===0&&r<0&&(r=-r),Number.isFinite(r)||(r=0),r*180/Math.PI}function nw(e,t,r,n){const i={x:t.x-e.x,y:t.y-e.y},o={x:r.x-t.x,y:r.y-t.y},s=Math.hypot(i.x,i.y),a=Math.hypot(o.x,o.y),c=i.x*o.y-i.y*o.x;if(s<1e-6||a<1e-6||Math.abs(c)<1e-6)return{p1:t,b:t,p2:t,r:0};const u=Math.min(n,s/2,a/2);return{p1:{x:t.x-i.x/s*u,y:t.y-i.y/s*u},b:t,p2:{x:t.x+o.x/a*u,y:t.y+o.y/a*u},r:u}}function Hm(e,t,r,n){let i=-1,o=null;for(let y=0;y<e.length-1;y++){const m=kt(e[y],e[y+1],t);if(m){i=y,o=m;break}}let s=-1,a=null;for(let y=e.length-1;y>0;y--){const m=kt(e[y],e[y-1],r);if(m){s=y,a=m;break}}if(!o||!a||i>=s)return null;const c=e.slice(i+1,s),u=c[0]??a,l=c[c.length-1]??o;let d,h,p;if(n.arrowAt==="source"){const y=ar(o,u,n.srcDist);d=ar(o,u,n.srcDist+n.arrowGap),p=_r(y,u,n.arrowSize,n.headShape)}else d=ar(o,u,n.srcDist);if(n.arrowAt==="target"){const y=ar(a,l,n.tgtDist);h=ar(a,l,n.tgtDist+n.arrowGap),p=_r(y,l,n.arrowSize,n.headShape)}else h=ar(a,l,n.tgtDist);return Fn(d,c,h,p,n.radius,n.labelTargetLength,n.labelFraction)}function Fn(e,t,r,n,i,o,s){var h;const a=[e,...t,r],c=[];let u=`M${Qe(e)}`;for(let p=1;p<a.length-1;p++){const y=nw(a[p-1],a[p],a[p+1],i);c.push(y),y.r===0?u+=` L${Qe(y.b)}`:u+=` L${Qe(y.p1)} Q${Qe(y.b)} ${Qe(y.p2)}`}u+=` L${Qe(r)}`;let l;const d=t.length;if(d===0)l={x:(e.x+r.x)/2,y:(e.y+r.y)/2,angle:Ur(r.x-e.x,r.y-e.y)};else if(d%2===0){const p=t[d/2-1],y=t[d/2];l={x:(p.x+y.x)/2,y:(p.y+y.y)/2,angle:Ur(y.x-p.x,y.y-p.y)}}else{const p=c[(d-1)/2];if(p.r===0){const y=a[(d-1)/2+2];l={x:p.b.x,y:p.b.y,angle:Ur(y.x-p.b.x,y.y-p.b.y)}}else l={x:.25*p.p1.x+.5*p.b.x+.25*p.p2.x,y:.25*p.p1.y+.5*p.b.y+.25*p.p2.y,angle:Ur(p.p2.x-p.p1.x,p.p2.y-p.p1.y)}}if(o!==void 0){if(s!==void 0&&c.length===2){const g=c[0].p2,b=c[1].p1,x=Math.hypot(b.x-g.x,b.y-g.y),v=Math.min(.5,o/(2*x)),w=Math.max(v,Math.min(1-v,s));l={x:g.x+(b.x-g.x)*w,y:g.y+(b.y-g.y)*w,angle:Ur(b.x-g.x,b.y-g.y)}}const p=((h=c[c.length-1])==null?void 0:h.p2)??e,y=r.x-p.x,m=r.y-p.y;Math.hypot(y,m)>=o&&(l={x:(p.x+r.x)/2,y:(p.y+r.y)/2,angle:Ur(y,m)})}return{d:u,arrow:n,label:l}}function Ql(e,t,r,n,i,o,s){const a=r==="leftward"?-1:1,c={x:e.x+a*(e.w/2+s.srcDist),y:n??e.y},u={x:t.x-a*(t.w/2+s.tgtDist),y:i??t.y},l=Math.max(80,s.arrowGap+s.arrowSize*.3),d=c.x+a*l,h=u.x-a*l;let p;if(a*(h-d)>=0){const b=c.x+(u.x-c.x)*o,x=Math.max(Math.min(d,h),Math.min(Math.max(d,h),b));p=[{x,y:c.y},{x,y:u.y}]}else{const b=Math.min(e.y-e.h/2,t.y-t.h/2)-l*(1+o);p=[{x:d,y:c.y},{x:d,y:b},{x:h,y:b},{x:h,y:u.y}]}const y=s.arrowAt==="source"?ar(c,p[0],s.arrowGap):c,m=s.arrowAt==="target"?ar(u,p[p.length-1],s.arrowGap):u,g=s.arrowAt==="source"?_r(c,p[0],s.arrowSize,s.headShape):s.arrowAt==="target"?_r(u,p[p.length-1],s.arrowSize,s.headShape):void 0;return Fn(y,p,m,g,s.radius)}function ed(e,t,r,n,i){return Hm(ew(e,t,r,n),e,t,i)}function rd(e,t,r,n,i,o){const s=n===void 0&&i===void 0&&(r==="downward"||r==="upward"),a=r==="leftward"||s&&r==="upward"?-1:1,c=(u,l,d)=>{const h={x:u.x,y:l??u.y},p=Math.max(u.w,u.h)*2+1,y=kt(h,{x:h.x+(s?0:d*p),y:h.y+(s?d*p:0)},u);return y?{x:y.x+(s?0:d*o),y:y.y+(s?d*o:0)}:s?{x:u.x,y:u.y+d*(u.h/2+o)}:{x:u.x+d*(u.w/2+o),y:l??u.y}};return{sourcePoint:c(e,n,a),targetPoint:c(t,i,-a)}}function ow(e,t,r,n){const i=r==="downward"||r==="upward",o=r==="leftward"||r==="upward"?-1:1,s=Math.max(100,Math.abs(i?t.y-e.y:t.x-e.x)/2),a={x:e.x+(i?0:o*s),y:e.y+(i?o*s:0)},c={x:t.x-(i?0:o*s),y:t.y-(i?o*s:0)},u=n.arrowAt==="source"?ar(e,a,n.arrowGap):e,l=n.arrowAt==="target"?ar(t,c,n.arrowGap):t;return{d:`M${Qe(u)} C${Qe(a)} ${Qe(c)} ${Qe(l)}`,arrow:n.arrowAt==="source"?_r(e,a,n.arrowSize,n.headShape):n.arrowAt==="target"?_r(t,c,n.arrowSize,n.headShape):void 0,label:{x:(u.x+3*a.x+3*c.x+l.x)/8,y:(u.y+3*a.y+3*c.y+l.y)/8,angle:Ur(l.x+c.x-a.x-u.x,l.y+c.y-a.y-u.y)}}}function Km(e,t,r){const n=r.arrowAt==="source"?ar(e,t,r.arrowGap):e,i=r.arrowAt==="target"?ar(t,e,r.arrowGap):t,o=r.arrowAt==="source"?_r(e,t,r.arrowSize,r.headShape):r.arrowAt==="target"?_r(t,e,r.arrowSize,r.headShape):void 0;return Fn(n,[],i,o,0)}function iw(e,t,r,n=-90,i=-60,o=350){const s=n*Math.PI/180,a=i*Math.PI/180,c=s-Math.PI/2,u=c-a/2,l=c+a/2,d=1.4*o*(t/3+1),h={x:e.x+Math.cos(u)*d,y:e.y+Math.sin(u)*d},p={x:e.x+Math.cos(l)*d,y:e.y+Math.sin(l)*d},y={x:e.x,y:e.y},m=kt(y,h,e),g=kt(y,p,e);if(!m||!g)return null;const b={x:(h.x+p.x)/2,y:(h.y+p.y)/2};let x=ar(m,h,r.srcDist),v=ar(g,p,r.tgtDist),w;if(r.arrowAt==="target"){const S=v;v=ar(g,p,r.tgtDist+r.arrowGap),w=_r(S,p,r.arrowSize,r.headShape)}else if(r.arrowAt==="source"){const S=x;x=ar(m,h,r.srcDist+r.arrowGap),w=_r(S,h,r.arrowSize,r.headShape)}return{d:`M${Qe(x)} Q${Qe(h)} ${Qe(b)} Q${Qe(p)} ${Qe(v)}`,arrow:w,label:{x:b.x,y:b.y,angle:Ur(p.x-h.x,p.y-h.y)}}}const yt=e=>Math.round(e*1e3)/1e3;function Jm(e){const t=e.querySelector("[data-flow-node-surface]");if(!t)return;const r=e.getBoundingClientRect(),n=r.width/e.offsetWidth;if(!Number.isFinite(n)||n<=0)return;const i=t.getBoundingClientRect();if(!i.width||!i.height)return;const o=t,s=typeof o.getScreenCTM=="function"?o.getScreenCTM():null,a=typeof o.getTotalLength=="function"?o.getTotalLength():0,c=o.points,u=(c==null?void 0:c.numberOfItems)||128,l=s&&a>0?Array.from({length:u},(d,h)=>{const p=c!=null&&c.numberOfItems?c.getItem(h):o.getPointAtLength(a*h/u);return{x:yt((s.a*p.x+s.c*p.y+s.e-r.left)/n),y:yt((s.b*p.x+s.d*p.y+s.f-r.top)/n)}}):void 0;return{left:yt((i.left-r.left)/n),top:yt((i.top-r.top)/n),width:t instanceof HTMLElement?t.offsetWidth:yt(i.width/n),height:t instanceof HTMLElement?t.offsetHeight:yt(i.height/n),radius:parseFloat(getComputedStyle(t).borderTopLeftRadius)||0,...l?{outline:l}:{}}}function en(e,t){const r=e.x-e.w/2,n=e.y-e.h/2;return{x:r+t.left+t.width/2,y:n+t.top+t.height/2,w:t.width,h:t.height,...t.outline?{outline:t.outline.map(i=>({x:r+i.x,y:n+i.y}))}:{}}}function aw(e,t,r,n,i){var l;const o=i!=="TB"&&i!=="BT",s=o?"top":"left",a=o?"bottom":"right",c=new Map;for(const d of n)for(const[h,p,y]of[[d.source,d.sourceProperty,d.target],[d.target,d.targetProperty,d.source]]){const m=t.get(y);if(p===void 0||!m||y===h)continue;const g=r.get(y),b=JSON.stringify([h,p]),x=c.get(b)??[];x.push(g?en(m,g):m),c.set(b,x)}const u=new Map(e);for(const[d,h]of e){const p=t.get(d);if(!p||!h.some(v=>v.placement==="config"))continue;const y=r.get(d),m=y?en(p,y):p,g={x:p.w/2,y:p.h/2,w:p.w,h:p.h},b=y?en(g,y):g,x=new Map;for(const v of h){if(v.placement!=="config")continue;const C=(c.get(JSON.stringify([d,v.property]))??[]).reduce((j,I)=>j+(o?I.y-m.y:I.x-m.x),0),S=((l=v.anchor)==null?void 0:l.side)===a?a:s;x.set(v,C<-.001?s:C>.001?a:S)}u.set(d,h.map(v=>{const w=x.get(v);if(!w)return v;const C=h.filter(I=>x.get(I)===w),S=(C.indexOf(v)+1)/(C.length+1),j=Um(b,w,S);return{...v,anchor:j,top:j.y,height:0}}))}return u}function td(e,t,r){const n=new Set(t.map(a=>a.id));if(!n.has(e))return new Set;const i=new Set([e]);let o=!0;for(;o;){o=!1;for(const a of t)!i.has(a.id)&&(i.has(a.parent??"")||a.id.startsWith(`${e}.`))&&(i.add(a.id),o=!0)}const s=new Set(i);for(const a of r)i.has(a.source)&&n.has(a.target)&&s.add(a.target),i.has(a.target)&&n.has(a.source)&&s.add(a.source);return s}const Lr='"Helvetica Neue", Helvetica, sans-serif';let Ft;const wn=new Map;function un(e,t){const r=`${t}|${e}`,n=wn.get(r);if(n!==void 0)return n;Ft===void 0&&(Ft=typeof document<"u"?document.createElement("canvas").getContext("2d"):null);let i;return Ft?(Ft.font=t,i=Ft.measureText(e).width):i=e.length*(parseFloat(t)||16)*.55,wn.size>5e3&&wn.clear(),wn.set(r,i),i}function sw(e,t,r){const n=[];for(const i of String(e).split(`
210
210
  `)){const o=i.split(/\s+/).filter(Boolean);if(!o.length){n.push("");continue}let s="";for(const a of o){const c=s?`${s} ${a}`:a;!s||un(c,t)<=r?s=c:(n.push(s),s=a)}n.push(s)}return n}const nd=e=>e.stopPropagation();function cw({id:e,rect:t,label:r,labelLayer:n,labelContent:i,style:o,onSelect:s,onCollapse:a,selected:c=!1}){const u=t.x2-t.x1,l=t.y2-t.y1,d=o.borderWidth,h=o.borderStyle==="dashed"?`${d*4} ${d*2}`:o.borderStyle==="dotted"?`${d} ${d}`:void 0,p=t.x1+u/2,y=o.labelPosition==="top"?t.y1+o.labelMargin-o.fontSize/2:o.labelPosition==="bottom"?t.y2-o.labelMargin+o.fontSize/2:t.y1+l/2,m=r?un(r,`bold ${o.fontSize}px ${Lr}`):0,g=o.fontSize/5,b=r||c&&a?f.jsxs("g",{className:"flow-sdk-container-label","data-node-id":e,children:[c&&a&&f.jsx("foreignObject",{x:p+m/2+g+8,y:y-24,width:48,height:48,"data-flow-content-toggle":"",style:{pointerEvents:"auto"},children:f.jsx(Oe,{label:"Show icon",children:f.jsx(Se,{"aria-label":"Show icon",icon:f.jsx(J.PiCircleFill,{}),variant:"ghost",style:{width:48,height:48,color:o.textColor},onClick:x=>{x.stopPropagation(),a(e)}})})}),i?f.jsx("foreignObject",{x:p-m/2-g,y:y-o.fontSize/2-g,width:m+2*g,height:o.fontSize+2*g,style:{overflow:"visible"},onClick:nd,children:i}):r&&f.jsxs(f.Fragment,{children:[f.jsx("rect",{x:p-m/2-g,y:y-o.fontSize/2-g,width:m+2*g,height:o.fontSize+2*g,fill:o.textColor==="transparent"?"transparent":o.labelBg}),f.jsx("text",{x:p,y,fill:o.textColor,fontSize:o.fontSize,fontWeight:"bold",fontFamily:Lr,style:{fontSize:o.fontSize,fontWeight:"bold",fontFamily:Lr},textAnchor:"middle",dominantBaseline:"central",children:r})]})]}):null;return f.jsxs("g",{className:"flow-sdk-container","data-node-id":e,onPointerDown:nd,onClick:x=>{x.stopPropagation(),s==null||s(e,{shiftKey:x.shiftKey,ctrlKey:x.ctrlKey,metaKey:x.metaKey,altKey:x.altKey})},children:[f.jsx("rect",{x:t.x1,y:t.y1,width:u,height:l,rx:o.borderRadius,ry:o.borderRadius,fill:o.bgColor,fillOpacity:o.bgOpacity,stroke:o.borderColor,strokeWidth:o.borderStyle==="double"?d/3:d,strokeDasharray:h}),o.borderStyle==="double"&&f.jsx("rect",{x:t.x1+d*2/3,y:t.y1+d*2/3,width:Math.max(0,u-d*4/3),height:Math.max(0,l-d*4/3),rx:Math.max(0,o.borderRadius-d*2/3),ry:Math.max(0,o.borderRadius-d*2/3),fill:"none",stroke:o.borderColor,strokeWidth:d/3}),o.animated&&d>0&&f.jsx(Gm,{variant:o.animationVariant,x:t.x1,y:t.y1,width:u,height:l,radius:o.borderRadius,color:o.animationColor||o.borderColor,strokeWidth:Math.max(8,d*1.6)}),n&&b?tn.createPortal(b,n):b]})}const uw=_.memo(cw),An=45,Zm=70,ot=15,Ym=50;function Xm(e,t,r=An){const n=`${r}px ${Lr}`,i=e?sw(e,n,200*r/An):[],o=t?48+(i.length?12:0):0,s=o+Math.max(0,...i.map(u=>un(u,n))),a=Math.max(i.length*r,t?48:0),c=i.length||t?2*ot:0;return{lines:i,iconWidth:o,contentWidth:s,contentHeight:a,width:s+c,height:a+c}}const rn=6,Qm=3,tl=.3,lw=8,nl=Math.max(Math.pow(rn*13.37,.9),29)*Qm-lw/tl,eb=rn*Qm*2,_n=80,dw=2*_n+nl*tl+100,fw=36+2*Math.max(80,eb+nl*tl);function Fu(e){return e.sourceProperty!==void 0||e.targetProperty!==void 0}function Bu(e,t){return t==="auto"||(t==="properties"?Fu(e):!Fu(e))}function vt(e,t,r){return r!=="properties"||e!=="root"||t.some(n=>(n.source===e||n.target===e)&&Fu(n))}function hw(e,t,r,n=!1,i){if(!n)return{nodes:e,edges:t};const o=e.filter(a=>vt(a.id,t,r)&&(!i||i.has(a.id))),s=new Set(o.map(a=>a.id));return{nodes:o,edges:t.filter(a=>Bu(a,r)&&s.has(a.source)&&s.has(a.target))}}const pw=500,gw="32 18",yw=e=>e.stopPropagation();function mw({id:e,reveal:t,onRevealComplete:r,edgeData:n,validationIssue:i,edgeType:o="rounded-orthogonal",edgeRadius:s,customEdgeTypes:a,source:c,target:u,sourceProperty:l,targetProperty:d,sourceY:h,targetY:p,sourcePort:y,targetPort:m,propertyMode:g=!1,dir:b,turn:x,labelAtTarget:v,labelFraction:w,color:C,connectorColor:S,labelBg:j,labelLayer:I,label:P,dashed:O,animated:T,inverted:E,loopIndex:R=0,onSelect:k}){const M=n==null?void 0:n.icon,$=g?An:Zm,{lines:q,iconWidth:W,contentWidth:ie,contentHeight:ee}=_.useMemo(()=>Xm(P,M,$),[P,M,$]),Y=_.useMemo(()=>{const U={srcDist:_n,tgtDist:_n,arrowGap:eb,arrowSize:nl,headShape:g&&(E?h!==void 0||y:p!==void 0||m)?"square":"triangle",radius:s??(v?40:pw),arrowAt:E?"source":"target",labelTargetLength:v?ie+2*ot:void 0,labelFraction:v?w:void 0},se=h!==void 0||p!==void 0||!!y||!!m,ue=rd(c,u,b,h,p,0),we=h===void 0&&p===void 0&&(b==="downward"||b==="upward"),pe=y??{...ue.sourcePoint,side:we?b==="upward"?"top":"bottom":b==="leftward"?"left":"right"},qe=m??{...ue.targetPoint,side:we?b==="upward"?"bottom":"top":b==="leftward"?"right":"left"},Q=c.x===u.x&&c.y===u.y,he=y||m?tw(pe,qe,{...U,srcDist:18,tgtDist:18},o):se?Ql(c,u,b,h,p,x,{...U,srcDist:18,tgtDist:18,radius:s??Math.min(U.radius,40)}):Q?iw(c,R,{...U,srcDist:0,tgtDist:0}):ed(c,u,b,x,U);if(!he)return null;const me=rd(c,u,b,h,p,se?18:_n);y&&(me.sourcePoint=wt(y,18)),m&&(me.targetPoint=wt(m,18));const Re=Object.prototype.hasOwnProperty.call(a??{},o)?a==null?void 0:a[o]:void 0;if(Re){const $e={rightward:"LR",leftward:"RL",downward:"TB",upward:"BT"};return Re({edge:n??{id:e,source:"",target:""},source:{...c},target:{...u},...me,direction:$e[b],sourceY:h,targetY:p,inverted:!!E,defaultGeometry:he})??he}return Q||y||m?he:o==="straight"?se?Km(me.sourcePoint,me.targetPoint,U):Hm([c,u],c,u,U):o==="bezier"?ow(me.sourcePoint,me.targetPoint,se?b==="leftward"?"leftward":"rightward":b,U):o==="orthogonal"?se?Ql(c,u,b,h,p,x,{...U,srcDist:18,tgtDist:18,radius:0}):ed(c,u,b,x,{...U,radius:0}):he},[c,e,n,o,s,a,u,g,h,p,y,m,b,x,E,R,v,w,ie]);if(!Y)return null;const fe=(b==="rightward"||b==="leftward")&&!Object.prototype.hasOwnProperty.call(a??{},o)&&!(g&&(h!==void 0||p!==void 0||y||m)),ce=fe?`translate(${Y.label.x} ${Y.label.y-ee/2-2*ot})`:`translate(${Y.label.x} ${Y.label.y}) rotate(${Y.label.angle}) translate(${b==="downward"||b==="upward"||v||Object.prototype.hasOwnProperty.call(a??{},o)?0:Ym} 0)`,L=i!=null&&i.startsWith("Unverified:")?"#b45309":"#dc2626",V=i?L:C,G=i?f.jsxs("g",{className:"flow-sdk-edge-validation",role:"img","aria-label":i,transform:`translate(${Y.label.x} ${Y.label.y-q.length*$/2-55})`,children:[f.jsx("title",{children:i}),f.jsx(Mr,{name:"PiWarningCircleFill",svg:!0,size:48,x:-24,y:-24,color:L})]}):null,N=T&&(n==null?void 0:n.edgeAnimationVariant)==="traveling",ae=!N&&(O||T)?gw:void 0,ge=T&&!N?`flow-sdk-edge-anim${E?" flow-sdk-edge-anim-rev":""}`:void 0;let ve=null;const K=t?{"--flow-edge-reveal-duration":`${t.durationMs??600}ms`,"--flow-edge-reveal-state":t.paused?"paused":"running"}:void 0;if(q.length||M){const U=ie,se=ee;ve=f.jsxs("g",{className:`flow-sdk-edge-label${t?" flow-sdk-edge-reveal-end":""}`,style:K,"data-label-transform":ce,"data-label-horizontal":fe||void 0,"data-edge-id":e,"data-source-property":l,"data-target-property":d,transform:ce,children:[f.jsx("rect",{x:-U/2-ot,y:-se/2-ot,width:U+2*ot,height:se+2*ot,fill:C==="transparent"?"transparent":j}),f.jsx("text",{fill:C,fontSize:$,style:{fontSize:$,fontFamily:Lr},fontFamily:Lr,textAnchor:"middle",dominantBaseline:"central",children:q.map((ue,we)=>f.jsx("tspan",{x:W/2,y:(we-(q.length-1)/2)*$,children:ue},we))}),M&&f.jsxs("g",{className:"flow-sdk-edge-icon",opacity:C==="transparent"?0:1,children:[f.jsx("title",{children:P?`Edge icon: ${P}`:"Edge icon"}),f.jsx("rect",{x:-U/2,y:-24,width:48,height:48,fill:"transparent"}),f.jsx(Mr,{name:M,svg:!0,size:48,x:-U/2,y:-24,color:C})]})]})}const te=f.jsxs(f.Fragment,{children:[f.jsx("path",{d:Y.d,fill:"none",stroke:V,strokeWidth:rn,strokeOpacity:N?.35:void 0,strokeDasharray:ae,className:ge}),N&&f.jsx(G0,{path:Y.d,color:V,width:rn*1.6,reversed:E})]});return f.jsxs("g",{className:"flow-sdk-edge",style:K,"data-edge-id":e,"data-source-property":l,"data-target-property":d,"data-validation":i?i.startsWith("Unverified:")?"unverified":"invalid":void 0,"aria-label":i,onPointerDown:yw,onClick:U=>{U.stopPropagation(),k==null||k(e)},children:[t?f.jsx(H0,{path:Y.d,width:rn*4,reversed:E,onComplete:()=>r==null?void 0:r(e),children:te}):te,Y.arrow&&f.jsx("path",{className:t?"flow-sdk-edge-reveal-end":void 0,d:Y.arrow,fill:i?L:S??V}),I&&ve?tn.createPortal(ve,I):ve,I&&G?tn.createPortal(G,I):G,f.jsx("path",{className:"flow-sdk-edge-hit",d:Y.d,fill:"none",stroke:"transparent"})]})}const od=_.memo(mw),id=(e,t)=>e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top;function bw(e){const t=e.querySelector(".flow-sdk-labels"),r=t==null?void 0:t.getScreenCTM();if(!t||!r)return;const n=r.inverse(),i=(u,l=0)=>{const d=u.getBoundingClientRect(),h=new DOMPoint(d.left,d.top).matrixTransform(n),p=new DOMPoint(d.right,d.bottom).matrixTransform(n);return{left:h.x-l,right:p.x+l,top:h.y-l,bottom:p.y+l}},o=[...e.querySelectorAll(".flow-sdk-node, .flow-sdk-node button")].filter(u=>{const l=u.getBoundingClientRect(),d=getComputedStyle(u);return l.width>0&&l.height>0&&d.visibility!=="hidden"&&d.opacity!=="0"}).map(u=>i(u,24));for(const u of t.querySelectorAll(".flow-sdk-container-label"))o.push(i(u,12));const s=[...t.querySelectorAll(".flow-sdk-edge-label")];for(const u of s)u.setAttribute("transform",u.dataset.labelTransform??"");const a=new Map(s.map(u=>[u,i(u,8)])),c=new Map([...e.querySelectorAll(".flow-sdk-edge")].map(u=>[u.dataset.edgeId,u.querySelector("path")]));for(const u of s){const l=u.dataset.labelHorizontal==="true",d=a.get(u);a.delete(u);const h=j=>o.some(I=>id(j,I))||[...a.values()].some(I=>id(j,I));if(!l&&!h(d)){a.set(u,d);continue}const p=c.get(u.dataset.edgeId),y=u.querySelector("rect");if(!p||!y)continue;const m=y.getBBox(),g=p.getTotalLength();if(!Number.isFinite(g)||g<=0)continue;const b=(d.left+d.right)/2,x=(d.top+d.bottom)/2,v=Math.min(256,Math.max(16,Math.ceil(g/24))),w=Array.from({length:v+1},(j,I)=>p.getPointAtLength(g*I/v)),S=Array.from({length:v+1},(j,I)=>{const P=g*I/v,O=w[I],T=l?{x:O.x,y:O.y-m.height/2-15}:O,E=p.getPointAtLength(Math.max(0,P-2)),R=p.getPointAtLength(Math.min(g,P+2));let k=Math.atan2(R.y-E.y,R.x-E.x)*180/Math.PI;k>90&&(k-=180),k<-90&&(k+=180);const M=Math.abs(k)<1;l&&(k=0);const $=k*Math.PI/180,q=Math.abs(Math.cos($))*m.width+Math.abs(Math.sin($))*m.height,W=Math.abs(Math.sin($))*m.width+Math.abs(Math.cos($))*m.height;return{point:T,angle:k,straight:M,score:Math.hypot(T.x-b,T.y-x),bounds:{left:T.x-q/2-8,right:T.x+q/2+8,top:T.y-W/2-8,bottom:T.y+W/2+8}}}).sort((j,I)=>j.score-I.score).find(j=>!h(j.bounds)&&(!l||j.straight&&!w.some(I=>I.x>j.bounds.left&&I.x<j.bounds.right&&I.y>j.bounds.top&&I.y<j.bounds.bottom)));S?(u.setAttribute("transform",`translate(${S.point.x} ${S.point.y}) rotate(${S.angle})`),a.set(u,S.bounds)):a.set(u,d)}}var Cn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function vw(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function ol(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var mo,ad;function xw(){if(ad)return mo;ad=1;function e(){this.__data__=[],this.size=0}return mo=e,mo}var bo,sd;function It(){if(sd)return bo;sd=1;function e(t,r){return t===r||t!==t&&r!==r}return bo=e,bo}var vo,cd;function Bn(){if(cd)return vo;cd=1;var e=It();function t(r,n){for(var i=r.length;i--;)if(e(r[i][0],n))return i;return-1}return vo=t,vo}var xo,ud;function ww(){if(ud)return xo;ud=1;var e=Bn(),t=Array.prototype,r=t.splice;function n(i){var o=this.__data__,s=e(o,i);if(s<0)return!1;var a=o.length-1;return s==a?o.pop():r.call(o,s,1),--this.size,!0}return xo=n,xo}var wo,ld;function Cw(){if(ld)return wo;ld=1;var e=Bn();function t(r){var n=this.__data__,i=e(n,r);return i<0?void 0:n[i][1]}return wo=t,wo}var Co,dd;function Sw(){if(dd)return Co;dd=1;var e=Bn();function t(r){return e(this.__data__,r)>-1}return Co=t,Co}var So,fd;function _w(){if(fd)return So;fd=1;var e=Bn();function t(r,n){var i=this.__data__,o=e(i,r);return o<0?(++this.size,i.push([r,n])):i[o][1]=n,this}return So=t,So}var _o,hd;function zn(){if(hd)return _o;hd=1;var e=xw(),t=ww(),r=Cw(),n=Sw(),i=_w();function o(s){var a=-1,c=s==null?0:s.length;for(this.clear();++a<c;){var u=s[a];this.set(u[0],u[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=r,o.prototype.has=n,o.prototype.set=i,_o=o,_o}var Eo,pd;function Ew(){if(pd)return Eo;pd=1;var e=zn();function t(){this.__data__=new e,this.size=0}return Eo=t,Eo}var jo,gd;function jw(){if(gd)return jo;gd=1;function e(t){var r=this.__data__,n=r.delete(t);return this.size=r.size,n}return jo=e,jo}var ko,yd;function kw(){if(yd)return ko;yd=1;function e(t){return this.__data__.get(t)}return ko=e,ko}var Ro,md;function Rw(){if(md)return Ro;md=1;function e(t){return this.__data__.has(t)}return Ro=e,Ro}var Po,bd;function rb(){if(bd)return Po;bd=1;var e=typeof Cn=="object"&&Cn&&Cn.Object===Object&&Cn;return Po=e,Po}var Ao,vd;function Tr(){if(vd)return Ao;vd=1;var e=rb(),t=typeof self=="object"&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return Ao=r,Ao}var To,xd;function Ot(){if(xd)return To;xd=1;var e=Tr(),t=e.Symbol;return To=t,To}var Io,wd;function Pw(){if(wd)return Io;wd=1;var e=Ot(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,i=e?e.toStringTag:void 0;function o(s){var a=r.call(s,i),c=s[i];try{s[i]=void 0;var u=!0}catch{}var l=n.call(s);return u&&(a?s[i]=c:delete s[i]),l}return Io=o,Io}var Oo,Cd;function Aw(){if(Cd)return Oo;Cd=1;var e=Object.prototype,t=e.toString;function r(n){return t.call(n)}return Oo=r,Oo}var Mo,Sd;function dt(){if(Sd)return Mo;Sd=1;var e=Ot(),t=Pw(),r=Aw(),n="[object Null]",i="[object Undefined]",o=e?e.toStringTag:void 0;function s(a){return a==null?a===void 0?i:n:o&&o in Object(a)?t(a):r(a)}return Mo=s,Mo}var qo,_d;function Er(){if(_d)return qo;_d=1;function e(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}return qo=e,qo}var $o,Ed;function fn(){if(Ed)return $o;Ed=1;var e=dt(),t=Er(),r="[object AsyncFunction]",n="[object Function]",i="[object GeneratorFunction]",o="[object Proxy]";function s(a){if(!t(a))return!1;var c=e(a);return c==n||c==i||c==r||c==o}return $o=s,$o}var No,jd;function Tw(){if(jd)return No;jd=1;var e=Tr(),t=e["__core-js_shared__"];return No=t,No}var Lo,kd;function Iw(){if(kd)return Lo;kd=1;var e=Tw(),t=(function(){var n=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function r(n){return!!t&&t in n}return Lo=r,Lo}var Fo,Rd;function tb(){if(Rd)return Fo;Rd=1;var e=Function.prototype,t=e.toString;function r(n){if(n!=null){try{return t.call(n)}catch{}try{return n+""}catch{}}return""}return Fo=r,Fo}var Bo,Pd;function Ow(){if(Pd)return Bo;Pd=1;var e=fn(),t=Iw(),r=Er(),n=tb(),i=/[\\^$.*+?()[\]{}|]/g,o=/^\[object .+?Constructor\]$/,s=Function.prototype,a=Object.prototype,c=s.toString,u=a.hasOwnProperty,l=RegExp("^"+c.call(u).replace(i,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function d(h){if(!r(h)||t(h))return!1;var p=e(h)?l:o;return p.test(n(h))}return Bo=d,Bo}var zo,Ad;function Mw(){if(Ad)return zo;Ad=1;function e(t,r){return t==null?void 0:t[r]}return zo=e,zo}var Do,Td;function ft(){if(Td)return Do;Td=1;var e=Ow(),t=Mw();function r(n,i){var o=t(n,i);return e(o)?o:void 0}return Do=r,Do}var Vo,Id;function il(){if(Id)return Vo;Id=1;var e=ft(),t=Tr(),r=e(t,"Map");return Vo=r,Vo}var Wo,Od;function Dn(){if(Od)return Wo;Od=1;var e=ft(),t=e(Object,"create");return Wo=t,Wo}var Go,Md;function qw(){if(Md)return Go;Md=1;var e=Dn();function t(){this.__data__=e?e(null):{},this.size=0}return Go=t,Go}var Uo,qd;function $w(){if(qd)return Uo;qd=1;function e(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}return Uo=e,Uo}var Ho,$d;function Nw(){if($d)return Ho;$d=1;var e=Dn(),t="__lodash_hash_undefined__",r=Object.prototype,n=r.hasOwnProperty;function i(o){var s=this.__data__;if(e){var a=s[o];return a===t?void 0:a}return n.call(s,o)?s[o]:void 0}return Ho=i,Ho}var Ko,Nd;function Lw(){if(Nd)return Ko;Nd=1;var e=Dn(),t=Object.prototype,r=t.hasOwnProperty;function n(i){var o=this.__data__;return e?o[i]!==void 0:r.call(o,i)}return Ko=n,Ko}var Jo,Ld;function Fw(){if(Ld)return Jo;Ld=1;var e=Dn(),t="__lodash_hash_undefined__";function r(n,i){var o=this.__data__;return this.size+=this.has(n)?0:1,o[n]=e&&i===void 0?t:i,this}return Jo=r,Jo}var Zo,Fd;function Bw(){if(Fd)return Zo;Fd=1;var e=qw(),t=$w(),r=Nw(),n=Lw(),i=Fw();function o(s){var a=-1,c=s==null?0:s.length;for(this.clear();++a<c;){var u=s[a];this.set(u[0],u[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=r,o.prototype.has=n,o.prototype.set=i,Zo=o,Zo}var Yo,Bd;function zw(){if(Bd)return Yo;Bd=1;var e=Bw(),t=zn(),r=il();function n(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}return Yo=n,Yo}var Xo,zd;function Dw(){if(zd)return Xo;zd=1;function e(t){var r=typeof t;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?t!=="__proto__":t===null}return Xo=e,Xo}var Qo,Dd;function Vn(){if(Dd)return Qo;Dd=1;var e=Dw();function t(r,n){var i=r.__data__;return e(n)?i[typeof n=="string"?"string":"hash"]:i.map}return Qo=t,Qo}var ei,Vd;function Vw(){if(Vd)return ei;Vd=1;var e=Vn();function t(r){var n=e(this,r).delete(r);return this.size-=n?1:0,n}return ei=t,ei}var ri,Wd;function Ww(){if(Wd)return ri;Wd=1;var e=Vn();function t(r){return e(this,r).get(r)}return ri=t,ri}var ti,Gd;function Gw(){if(Gd)return ti;Gd=1;var e=Vn();function t(r){return e(this,r).has(r)}return ti=t,ti}var ni,Ud;function Uw(){if(Ud)return ni;Ud=1;var e=Vn();function t(r,n){var i=e(this,r),o=i.size;return i.set(r,n),this.size+=i.size==o?0:1,this}return ni=t,ni}var oi,Hd;function al(){if(Hd)return oi;Hd=1;var e=zw(),t=Vw(),r=Ww(),n=Gw(),i=Uw();function o(s){var a=-1,c=s==null?0:s.length;for(this.clear();++a<c;){var u=s[a];this.set(u[0],u[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=r,o.prototype.has=n,o.prototype.set=i,oi=o,oi}var ii,Kd;function Hw(){if(Kd)return ii;Kd=1;var e=zn(),t=il(),r=al(),n=200;function i(o,s){var a=this.__data__;if(a instanceof e){var c=a.__data__;if(!t||c.length<n-1)return c.push([o,s]),this.size=++a.size,this;a=this.__data__=new r(c)}return a.set(o,s),this.size=a.size,this}return ii=i,ii}var ai,Jd;function Wn(){if(Jd)return ai;Jd=1;var e=zn(),t=Ew(),r=jw(),n=kw(),i=Rw(),o=Hw();function s(a){var c=this.__data__=new e(a);this.size=c.size}return s.prototype.clear=t,s.prototype.delete=r,s.prototype.get=n,s.prototype.has=i,s.prototype.set=o,ai=s,ai}var si,Zd;function sl(){if(Zd)return si;Zd=1;function e(t,r){for(var n=-1,i=t==null?0:t.length;++n<i&&r(t[n],n,t)!==!1;);return t}return si=e,si}var ci,Yd;function nb(){if(Yd)return ci;Yd=1;var e=ft(),t=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return ci=t,ci}var ui,Xd;function Gn(){if(Xd)return ui;Xd=1;var e=nb();function t(r,n,i){n=="__proto__"&&e?e(r,n,{configurable:!0,enumerable:!0,value:i,writable:!0}):r[n]=i}return ui=t,ui}var li,Qd;function Un(){if(Qd)return li;Qd=1;var e=Gn(),t=It(),r=Object.prototype,n=r.hasOwnProperty;function i(o,s,a){var c=o[s];(!(n.call(o,s)&&t(c,a))||a===void 0&&!(s in o))&&e(o,s,a)}return li=i,li}var di,ef;function hn(){if(ef)return di;ef=1;var e=Un(),t=Gn();function r(n,i,o,s){var a=!o;o||(o={});for(var c=-1,u=i.length;++c<u;){var l=i[c],d=s?s(o[l],n[l],l,o,n):void 0;d===void 0&&(d=n[l]),a?t(o,l,d):e(o,l,d)}return o}return di=r,di}var fi,rf;function Kw(){if(rf)return fi;rf=1;function e(t,r){for(var n=-1,i=Array(t);++n<t;)i[n]=r(n);return i}return fi=e,fi}var hi,tf;function qr(){if(tf)return hi;tf=1;function e(t){return t!=null&&typeof t=="object"}return hi=e,hi}var pi,nf;function Jw(){if(nf)return pi;nf=1;var e=dt(),t=qr(),r="[object Arguments]";function n(i){return t(i)&&e(i)==r}return pi=n,pi}var gi,of;function pn(){if(of)return gi;of=1;var e=Jw(),t=qr(),r=Object.prototype,n=r.hasOwnProperty,i=r.propertyIsEnumerable,o=e((function(){return arguments})())?e:function(s){return t(s)&&n.call(s,"callee")&&!i.call(s,"callee")};return gi=o,gi}var yi,af;function rr(){if(af)return yi;af=1;var e=Array.isArray;return yi=e,yi}var Wt={exports:{}},mi,sf;function Zw(){if(sf)return mi;sf=1;function e(){return!1}return mi=e,mi}Wt.exports;var cf;function Mt(){return cf||(cf=1,(function(e,t){var r=Tr(),n=Zw(),i=t&&!t.nodeType&&t,o=i&&!0&&e&&!e.nodeType&&e,s=o&&o.exports===i,a=s?r.Buffer:void 0,c=a?a.isBuffer:void 0,u=c||n;e.exports=u})(Wt,Wt.exports)),Wt.exports}var bi,uf;function Hn(){if(uf)return bi;uf=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function r(n,i){var o=typeof n;return i=i??e,!!i&&(o=="number"||o!="symbol"&&t.test(n))&&n>-1&&n%1==0&&n<i}return bi=r,bi}var vi,lf;function cl(){if(lf)return vi;lf=1;var e=9007199254740991;function t(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return vi=t,vi}var xi,df;function Yw(){if(df)return xi;df=1;var e=dt(),t=cl(),r=qr(),n="[object Arguments]",i="[object Array]",o="[object Boolean]",s="[object Date]",a="[object Error]",c="[object Function]",u="[object Map]",l="[object Number]",d="[object Object]",h="[object RegExp]",p="[object Set]",y="[object String]",m="[object WeakMap]",g="[object ArrayBuffer]",b="[object DataView]",x="[object Float32Array]",v="[object Float64Array]",w="[object Int8Array]",C="[object Int16Array]",S="[object Int32Array]",j="[object Uint8Array]",I="[object Uint8ClampedArray]",P="[object Uint16Array]",O="[object Uint32Array]",T={};T[x]=T[v]=T[w]=T[C]=T[S]=T[j]=T[I]=T[P]=T[O]=!0,T[n]=T[i]=T[g]=T[o]=T[b]=T[s]=T[a]=T[c]=T[u]=T[l]=T[d]=T[h]=T[p]=T[y]=T[m]=!1;function E(R){return r(R)&&t(R.length)&&!!T[e(R)]}return xi=E,xi}var wi,ff;function Kn(){if(ff)return wi;ff=1;function e(t){return function(r){return t(r)}}return wi=e,wi}var Gt={exports:{}};Gt.exports;var hf;function ul(){return hf||(hf=1,(function(e,t){var r=rb(),n=t&&!t.nodeType&&t,i=n&&!0&&e&&!e.nodeType&&e,o=i&&i.exports===n,s=o&&r.process,a=(function(){try{var c=i&&i.require&&i.require("util").types;return c||s&&s.binding&&s.binding("util")}catch{}})();e.exports=a})(Gt,Gt.exports)),Gt.exports}var Ci,pf;function gn(){if(pf)return Ci;pf=1;var e=Yw(),t=Kn(),r=ul(),n=r&&r.isTypedArray,i=n?t(n):e;return Ci=i,Ci}var Si,gf;function ob(){if(gf)return Si;gf=1;var e=Kw(),t=pn(),r=rr(),n=Mt(),i=Hn(),o=gn(),s=Object.prototype,a=s.hasOwnProperty;function c(u,l){var d=r(u),h=!d&&t(u),p=!d&&!h&&n(u),y=!d&&!h&&!p&&o(u),m=d||h||p||y,g=m?e(u.length,String):[],b=g.length;for(var x in u)(l||a.call(u,x))&&!(m&&(x=="length"||p&&(x=="offset"||x=="parent")||y&&(x=="buffer"||x=="byteLength"||x=="byteOffset")||i(x,b)))&&g.push(x);return g}return Si=c,Si}var _i,yf;function Jn(){if(yf)return _i;yf=1;var e=Object.prototype;function t(r){var n=r&&r.constructor,i=typeof n=="function"&&n.prototype||e;return r===i}return _i=t,_i}var Ei,mf;function ib(){if(mf)return Ei;mf=1;function e(t,r){return function(n){return t(r(n))}}return Ei=e,Ei}var ji,bf;function Xw(){if(bf)return ji;bf=1;var e=ib(),t=e(Object.keys,Object);return ji=t,ji}var ki,vf;function ll(){if(vf)return ki;vf=1;var e=Jn(),t=Xw(),r=Object.prototype,n=r.hasOwnProperty;function i(o){if(!e(o))return t(o);var s=[];for(var a in Object(o))n.call(o,a)&&a!="constructor"&&s.push(a);return s}return ki=i,ki}var Ri,xf;function Fr(){if(xf)return Ri;xf=1;var e=fn(),t=cl();function r(n){return n!=null&&t(n.length)&&!e(n)}return Ri=r,Ri}var Pi,wf;function et(){if(wf)return Pi;wf=1;var e=ob(),t=ll(),r=Fr();function n(i){return r(i)?e(i):t(i)}return Pi=n,Pi}var Ai,Cf;function Qw(){if(Cf)return Ai;Cf=1;var e=hn(),t=et();function r(n,i){return n&&e(i,t(i),n)}return Ai=r,Ai}var Ti,Sf;function e1(){if(Sf)return Ti;Sf=1;function e(t){var r=[];if(t!=null)for(var n in Object(t))r.push(n);return r}return Ti=e,Ti}var Ii,_f;function r1(){if(_f)return Ii;_f=1;var e=Er(),t=Jn(),r=e1(),n=Object.prototype,i=n.hasOwnProperty;function o(s){if(!e(s))return r(s);var a=t(s),c=[];for(var u in s)u=="constructor"&&(a||!i.call(s,u))||c.push(u);return c}return Ii=o,Ii}var Oi,Ef;function ht(){if(Ef)return Oi;Ef=1;var e=ob(),t=r1(),r=Fr();function n(i){return r(i)?e(i,!0):t(i)}return Oi=n,Oi}var Mi,jf;function t1(){if(jf)return Mi;jf=1;var e=hn(),t=ht();function r(n,i){return n&&e(i,t(i),n)}return Mi=r,Mi}var Ut={exports:{}};Ut.exports;var kf;function ab(){return kf||(kf=1,(function(e,t){var r=Tr(),n=t&&!t.nodeType&&t,i=n&&!0&&e&&!e.nodeType&&e,o=i&&i.exports===n,s=o?r.Buffer:void 0,a=s?s.allocUnsafe:void 0;function c(u,l){if(l)return u.slice();var d=u.length,h=a?a(d):new u.constructor(d);return u.copy(h),h}e.exports=c})(Ut,Ut.exports)),Ut.exports}var qi,Rf;function sb(){if(Rf)return qi;Rf=1;function e(t,r){var n=-1,i=t.length;for(r||(r=Array(i));++n<i;)r[n]=t[n];return r}return qi=e,qi}var $i,Pf;function cb(){if(Pf)return $i;Pf=1;function e(t,r){for(var n=-1,i=t==null?0:t.length,o=0,s=[];++n<i;){var a=t[n];r(a,n,t)&&(s[o++]=a)}return s}return $i=e,$i}var Ni,Af;function ub(){if(Af)return Ni;Af=1;function e(){return[]}return Ni=e,Ni}var Li,Tf;function dl(){if(Tf)return Li;Tf=1;var e=cb(),t=ub(),r=Object.prototype,n=r.propertyIsEnumerable,i=Object.getOwnPropertySymbols,o=i?function(s){return s==null?[]:(s=Object(s),e(i(s),function(a){return n.call(s,a)}))}:t;return Li=o,Li}var Fi,If;function n1(){if(If)return Fi;If=1;var e=hn(),t=dl();function r(n,i){return e(n,t(n),i)}return Fi=r,Fi}var Bi,Of;function fl(){if(Of)return Bi;Of=1;function e(t,r){for(var n=-1,i=r.length,o=t.length;++n<i;)t[o+n]=r[n];return t}return Bi=e,Bi}var zi,Mf;function Zn(){if(Mf)return zi;Mf=1;var e=ib(),t=e(Object.getPrototypeOf,Object);return zi=t,zi}var Di,qf;function lb(){if(qf)return Di;qf=1;var e=fl(),t=Zn(),r=dl(),n=ub(),i=Object.getOwnPropertySymbols,o=i?function(s){for(var a=[];s;)e(a,r(s)),s=t(s);return a}:n;return Di=o,Di}var Vi,$f;function o1(){if($f)return Vi;$f=1;var e=hn(),t=lb();function r(n,i){return e(n,t(n),i)}return Vi=r,Vi}var Wi,Nf;function db(){if(Nf)return Wi;Nf=1;var e=fl(),t=rr();function r(n,i,o){var s=i(n);return t(n)?s:e(s,o(n))}return Wi=r,Wi}var Gi,Lf;function fb(){if(Lf)return Gi;Lf=1;var e=db(),t=dl(),r=et();function n(i){return e(i,r,t)}return Gi=n,Gi}var Ui,Ff;function i1(){if(Ff)return Ui;Ff=1;var e=db(),t=lb(),r=ht();function n(i){return e(i,r,t)}return Ui=n,Ui}var Hi,Bf;function a1(){if(Bf)return Hi;Bf=1;var e=ft(),t=Tr(),r=e(t,"DataView");return Hi=r,Hi}var Ki,zf;function s1(){if(zf)return Ki;zf=1;var e=ft(),t=Tr(),r=e(t,"Promise");return Ki=r,Ki}var Ji,Df;function hb(){if(Df)return Ji;Df=1;var e=ft(),t=Tr(),r=e(t,"Set");return Ji=r,Ji}var Zi,Vf;function c1(){if(Vf)return Zi;Vf=1;var e=ft(),t=Tr(),r=e(t,"WeakMap");return Zi=r,Zi}var Yi,Wf;function qt(){if(Wf)return Yi;Wf=1;var e=a1(),t=il(),r=s1(),n=hb(),i=c1(),o=dt(),s=tb(),a="[object Map]",c="[object Object]",u="[object Promise]",l="[object Set]",d="[object WeakMap]",h="[object DataView]",p=s(e),y=s(t),m=s(r),g=s(n),b=s(i),x=o;return(e&&x(new e(new ArrayBuffer(1)))!=h||t&&x(new t)!=a||r&&x(r.resolve())!=u||n&&x(new n)!=l||i&&x(new i)!=d)&&(x=function(v){var w=o(v),C=w==c?v.constructor:void 0,S=C?s(C):"";if(S)switch(S){case p:return h;case y:return a;case m:return u;case g:return l;case b:return d}return w}),Yi=x,Yi}var Xi,Gf;function u1(){if(Gf)return Xi;Gf=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n){var i=n.length,o=new n.constructor(i);return i&&typeof n[0]=="string"&&t.call(n,"index")&&(o.index=n.index,o.input=n.input),o}return Xi=r,Xi}var Qi,Uf;function pb(){if(Uf)return Qi;Uf=1;var e=Tr(),t=e.Uint8Array;return Qi=t,Qi}var ea,Hf;function hl(){if(Hf)return ea;Hf=1;var e=pb();function t(r){var n=new r.constructor(r.byteLength);return new e(n).set(new e(r)),n}return ea=t,ea}var ra,Kf;function l1(){if(Kf)return ra;Kf=1;var e=hl();function t(r,n){var i=n?e(r.buffer):r.buffer;return new r.constructor(i,r.byteOffset,r.byteLength)}return ra=t,ra}var ta,Jf;function d1(){if(Jf)return ta;Jf=1;var e=/\w*$/;function t(r){var n=new r.constructor(r.source,e.exec(r));return n.lastIndex=r.lastIndex,n}return ta=t,ta}var na,Zf;function f1(){if(Zf)return na;Zf=1;var e=Ot(),t=e?e.prototype:void 0,r=t?t.valueOf:void 0;function n(i){return r?Object(r.call(i)):{}}return na=n,na}var oa,Yf;function gb(){if(Yf)return oa;Yf=1;var e=hl();function t(r,n){var i=n?e(r.buffer):r.buffer;return new r.constructor(i,r.byteOffset,r.length)}return oa=t,oa}var ia,Xf;function h1(){if(Xf)return ia;Xf=1;var e=hl(),t=l1(),r=d1(),n=f1(),i=gb(),o="[object Boolean]",s="[object Date]",a="[object Map]",c="[object Number]",u="[object RegExp]",l="[object Set]",d="[object String]",h="[object Symbol]",p="[object ArrayBuffer]",y="[object DataView]",m="[object Float32Array]",g="[object Float64Array]",b="[object Int8Array]",x="[object Int16Array]",v="[object Int32Array]",w="[object Uint8Array]",C="[object Uint8ClampedArray]",S="[object Uint16Array]",j="[object Uint32Array]";function I(P,O,T){var E=P.constructor;switch(O){case p:return e(P);case o:case s:return new E(+P);case y:return t(P,T);case m:case g:case b:case x:case v:case w:case C:case S:case j:return i(P,T);case a:return new E;case c:case d:return new E(P);case u:return r(P);case l:return new E;case h:return n(P)}}return ia=I,ia}var aa,Qf;function yb(){if(Qf)return aa;Qf=1;var e=Er(),t=Object.create,r=(function(){function n(){}return function(i){if(!e(i))return{};if(t)return t(i);n.prototype=i;var o=new n;return n.prototype=void 0,o}})();return aa=r,aa}var sa,eh;function mb(){if(eh)return sa;eh=1;var e=yb(),t=Zn(),r=Jn();function n(i){return typeof i.constructor=="function"&&!r(i)?e(t(i)):{}}return sa=n,sa}var ca,rh;function p1(){if(rh)return ca;rh=1;var e=qt(),t=qr(),r="[object Map]";function n(i){return t(i)&&e(i)==r}return ca=n,ca}var ua,th;function g1(){if(th)return ua;th=1;var e=p1(),t=Kn(),r=ul(),n=r&&r.isMap,i=n?t(n):e;return ua=i,ua}var la,nh;function y1(){if(nh)return la;nh=1;var e=qt(),t=qr(),r="[object Set]";function n(i){return t(i)&&e(i)==r}return la=n,la}var da,oh;function m1(){if(oh)return da;oh=1;var e=y1(),t=Kn(),r=ul(),n=r&&r.isSet,i=n?t(n):e;return da=i,da}var fa,ih;function bb(){if(ih)return fa;ih=1;var e=Wn(),t=sl(),r=Un(),n=Qw(),i=t1(),o=ab(),s=sb(),a=n1(),c=o1(),u=fb(),l=i1(),d=qt(),h=u1(),p=h1(),y=mb(),m=rr(),g=Mt(),b=g1(),x=Er(),v=m1(),w=et(),C=ht(),S=1,j=2,I=4,P="[object Arguments]",O="[object Array]",T="[object Boolean]",E="[object Date]",R="[object Error]",k="[object Function]",M="[object GeneratorFunction]",$="[object Map]",q="[object Number]",W="[object Object]",ie="[object RegExp]",ee="[object Set]",Y="[object String]",fe="[object Symbol]",ce="[object WeakMap]",L="[object ArrayBuffer]",V="[object DataView]",G="[object Float32Array]",N="[object Float64Array]",ae="[object Int8Array]",ge="[object Int16Array]",ve="[object Int32Array]",K="[object Uint8Array]",te="[object Uint8ClampedArray]",U="[object Uint16Array]",se="[object Uint32Array]",ue={};ue[P]=ue[O]=ue[L]=ue[V]=ue[T]=ue[E]=ue[G]=ue[N]=ue[ae]=ue[ge]=ue[ve]=ue[$]=ue[q]=ue[W]=ue[ie]=ue[ee]=ue[Y]=ue[fe]=ue[K]=ue[te]=ue[U]=ue[se]=!0,ue[R]=ue[k]=ue[ce]=!1;function we(pe,qe,Q,he,me,Re){var $e,Ge=qe&S,Ye=qe&j,tr=qe&I;if(Q&&($e=me?Q(pe,he,me,Re):Q(pe)),$e!==void 0)return $e;if(!x(pe))return pe;var sr=m(pe);if(sr){if($e=h(pe),!Ge)return s(pe,$e)}else{var Ae=d(pe),ye=Ae==k||Ae==M;if(g(pe))return o(pe,Ge);if(Ae==W||Ae==P||ye&&!me){if($e=Ye||ye?{}:y(pe),!Ge)return Ye?c(pe,i($e,pe)):a(pe,n($e,pe))}else{if(!ue[Ae])return me?pe:{};$e=p(pe,Ae,Ge)}}Re||(Re=new e);var Me=Re.get(pe);if(Me)return Me;Re.set(pe,$e),v(pe)?pe.forEach(function(Xe){$e.add(we(Xe,qe,Q,Xe,pe,Re))}):b(pe)&&pe.forEach(function(Xe,xe){$e.set(xe,we(Xe,qe,Q,xe,pe,Re))});var nr=tr?Ye?l:u:Ye?C:w,cr=sr?void 0:nr(pe);return t(cr||pe,function(Xe,xe){cr&&(xe=Xe,Xe=pe[xe]),r($e,xe,we(Xe,qe,Q,xe,pe,Re))}),$e}return fa=we,fa}var ha,ah;function b1(){if(ah)return ha;ah=1;var e=bb(),t=4;function r(n){return e(n,t)}return ha=r,ha}var pa,sh;function pl(){if(sh)return pa;sh=1;function e(t){return function(){return t}}return pa=e,pa}var ga,ch;function v1(){if(ch)return ga;ch=1;function e(t){return function(r,n,i){for(var o=-1,s=Object(r),a=i(r),c=a.length;c--;){var u=a[t?c:++o];if(n(s[u],u,s)===!1)break}return r}}return ga=e,ga}var ya,uh;function gl(){if(uh)return ya;uh=1;var e=v1(),t=e();return ya=t,ya}var ma,lh;function yl(){if(lh)return ma;lh=1;var e=gl(),t=et();function r(n,i){return n&&e(n,i,t)}return ma=r,ma}var ba,dh;function x1(){if(dh)return ba;dh=1;var e=Fr();function t(r,n){return function(i,o){if(i==null)return i;if(!e(i))return r(i,o);for(var s=i.length,a=n?s:-1,c=Object(i);(n?a--:++a<s)&&o(c[a],a,c)!==!1;);return i}}return ba=t,ba}var va,fh;function Yn(){if(fh)return va;fh=1;var e=yl(),t=x1(),r=t(e);return va=r,va}var xa,hh;function pt(){if(hh)return xa;hh=1;function e(t){return t}return xa=e,xa}var wa,ph;function vb(){if(ph)return wa;ph=1;var e=pt();function t(r){return typeof r=="function"?r:e}return wa=t,wa}var Ca,gh;function xb(){if(gh)return Ca;gh=1;var e=sl(),t=Yn(),r=vb(),n=rr();function i(o,s){var a=n(o)?e:t;return a(o,r(s))}return Ca=i,Ca}var Sa,yh;function wb(){return yh||(yh=1,Sa=xb()),Sa}var _a,mh;function w1(){if(mh)return _a;mh=1;var e=Yn();function t(r,n){var i=[];return e(r,function(o,s,a){n(o,s,a)&&i.push(o)}),i}return _a=t,_a}var Ea,bh;function C1(){if(bh)return Ea;bh=1;var e="__lodash_hash_undefined__";function t(r){return this.__data__.set(r,e),this}return Ea=t,Ea}var ja,vh;function S1(){if(vh)return ja;vh=1;function e(t){return this.__data__.has(t)}return ja=e,ja}var ka,xh;function Cb(){if(xh)return ka;xh=1;var e=al(),t=C1(),r=S1();function n(i){var o=-1,s=i==null?0:i.length;for(this.__data__=new e;++o<s;)this.add(i[o])}return n.prototype.add=n.prototype.push=t,n.prototype.has=r,ka=n,ka}var Ra,wh;function _1(){if(wh)return Ra;wh=1;function e(t,r){for(var n=-1,i=t==null?0:t.length;++n<i;)if(r(t[n],n,t))return!0;return!1}return Ra=e,Ra}var Pa,Ch;function Sb(){if(Ch)return Pa;Ch=1;function e(t,r){return t.has(r)}return Pa=e,Pa}var Aa,Sh;function _b(){if(Sh)return Aa;Sh=1;var e=Cb(),t=_1(),r=Sb(),n=1,i=2;function o(s,a,c,u,l,d){var h=c&n,p=s.length,y=a.length;if(p!=y&&!(h&&y>p))return!1;var m=d.get(s),g=d.get(a);if(m&&g)return m==a&&g==s;var b=-1,x=!0,v=c&i?new e:void 0;for(d.set(s,a),d.set(a,s);++b<p;){var w=s[b],C=a[b];if(u)var S=h?u(C,w,b,a,s,d):u(w,C,b,s,a,d);if(S!==void 0){if(S)continue;x=!1;break}if(v){if(!t(a,function(j,I){if(!r(v,I)&&(w===j||l(w,j,c,u,d)))return v.push(I)})){x=!1;break}}else if(!(w===C||l(w,C,c,u,d))){x=!1;break}}return d.delete(s),d.delete(a),x}return Aa=o,Aa}var Ta,_h;function E1(){if(_h)return Ta;_h=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(i,o){n[++r]=[o,i]}),n}return Ta=e,Ta}var Ia,Eh;function ml(){if(Eh)return Ia;Eh=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(i){n[++r]=i}),n}return Ia=e,Ia}var Oa,jh;function j1(){if(jh)return Oa;jh=1;var e=Ot(),t=pb(),r=It(),n=_b(),i=E1(),o=ml(),s=1,a=2,c="[object Boolean]",u="[object Date]",l="[object Error]",d="[object Map]",h="[object Number]",p="[object RegExp]",y="[object Set]",m="[object String]",g="[object Symbol]",b="[object ArrayBuffer]",x="[object DataView]",v=e?e.prototype:void 0,w=v?v.valueOf:void 0;function C(S,j,I,P,O,T,E){switch(I){case x:if(S.byteLength!=j.byteLength||S.byteOffset!=j.byteOffset)return!1;S=S.buffer,j=j.buffer;case b:return!(S.byteLength!=j.byteLength||!T(new t(S),new t(j)));case c:case u:case h:return r(+S,+j);case l:return S.name==j.name&&S.message==j.message;case p:case m:return S==j+"";case d:var R=i;case y:var k=P&s;if(R||(R=o),S.size!=j.size&&!k)return!1;var M=E.get(S);if(M)return M==j;P|=a,E.set(S,j);var $=n(R(S),R(j),P,O,T,E);return E.delete(S),$;case g:if(w)return w.call(S)==w.call(j)}return!1}return Oa=C,Oa}var Ma,kh;function k1(){if(kh)return Ma;kh=1;var e=fb(),t=1,r=Object.prototype,n=r.hasOwnProperty;function i(o,s,a,c,u,l){var d=a&t,h=e(o),p=h.length,y=e(s),m=y.length;if(p!=m&&!d)return!1;for(var g=p;g--;){var b=h[g];if(!(d?b in s:n.call(s,b)))return!1}var x=l.get(o),v=l.get(s);if(x&&v)return x==s&&v==o;var w=!0;l.set(o,s),l.set(s,o);for(var C=d;++g<p;){b=h[g];var S=o[b],j=s[b];if(c)var I=d?c(j,S,b,s,o,l):c(S,j,b,o,s,l);if(!(I===void 0?S===j||u(S,j,a,c,l):I)){w=!1;break}C||(C=b=="constructor")}if(w&&!C){var P=o.constructor,O=s.constructor;P!=O&&"constructor"in o&&"constructor"in s&&!(typeof P=="function"&&P instanceof P&&typeof O=="function"&&O instanceof O)&&(w=!1)}return l.delete(o),l.delete(s),w}return Ma=i,Ma}var qa,Rh;function R1(){if(Rh)return qa;Rh=1;var e=Wn(),t=_b(),r=j1(),n=k1(),i=qt(),o=rr(),s=Mt(),a=gn(),c=1,u="[object Arguments]",l="[object Array]",d="[object Object]",h=Object.prototype,p=h.hasOwnProperty;function y(m,g,b,x,v,w){var C=o(m),S=o(g),j=C?l:i(m),I=S?l:i(g);j=j==u?d:j,I=I==u?d:I;var P=j==d,O=I==d,T=j==I;if(T&&s(m)){if(!s(g))return!1;C=!0,P=!1}if(T&&!P)return w||(w=new e),C||a(m)?t(m,g,b,x,v,w):r(m,g,j,b,x,v,w);if(!(b&c)){var E=P&&p.call(m,"__wrapped__"),R=O&&p.call(g,"__wrapped__");if(E||R){var k=E?m.value():m,M=R?g.value():g;return w||(w=new e),v(k,M,b,x,w)}}return T?(w||(w=new e),n(m,g,b,x,v,w)):!1}return qa=y,qa}var $a,Ph;function Eb(){if(Ph)return $a;Ph=1;var e=R1(),t=qr();function r(n,i,o,s,a){return n===i?!0:n==null||i==null||!t(n)&&!t(i)?n!==n&&i!==i:e(n,i,o,s,r,a)}return $a=r,$a}var Na,Ah;function P1(){if(Ah)return Na;Ah=1;var e=Wn(),t=Eb(),r=1,n=2;function i(o,s,a,c){var u=a.length,l=u,d=!c;if(o==null)return!l;for(o=Object(o);u--;){var h=a[u];if(d&&h[2]?h[1]!==o[h[0]]:!(h[0]in o))return!1}for(;++u<l;){h=a[u];var p=h[0],y=o[p],m=h[1];if(d&&h[2]){if(y===void 0&&!(p in o))return!1}else{var g=new e;if(c)var b=c(y,m,p,o,s,g);if(!(b===void 0?t(m,y,r|n,c,g):b))return!1}}return!0}return Na=i,Na}var La,Th;function jb(){if(Th)return La;Th=1;var e=Er();function t(r){return r===r&&!e(r)}return La=t,La}var Fa,Ih;function A1(){if(Ih)return Fa;Ih=1;var e=jb(),t=et();function r(n){for(var i=t(n),o=i.length;o--;){var s=i[o],a=n[s];i[o]=[s,a,e(a)]}return i}return Fa=r,Fa}var Ba,Oh;function kb(){if(Oh)return Ba;Oh=1;function e(t,r){return function(n){return n==null?!1:n[t]===r&&(r!==void 0||t in Object(n))}}return Ba=e,Ba}var za,Mh;function T1(){if(Mh)return za;Mh=1;var e=P1(),t=A1(),r=kb();function n(i){var o=t(i);return o.length==1&&o[0][2]?r(o[0][0],o[0][1]):function(s){return s===i||e(s,i,o)}}return za=n,za}var Da,qh;function $t(){if(qh)return Da;qh=1;var e=dt(),t=qr(),r="[object Symbol]";function n(i){return typeof i=="symbol"||t(i)&&e(i)==r}return Da=n,Da}var Va,$h;function bl(){if($h)return Va;$h=1;var e=rr(),t=$t(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function i(o,s){if(e(o))return!1;var a=typeof o;return a=="number"||a=="symbol"||a=="boolean"||o==null||t(o)?!0:n.test(o)||!r.test(o)||s!=null&&o in Object(s)}return Va=i,Va}var Wa,Nh;function I1(){if(Nh)return Wa;Nh=1;var e=al(),t="Expected a function";function r(n,i){if(typeof n!="function"||i!=null&&typeof i!="function")throw new TypeError(t);var o=function(){var s=arguments,a=i?i.apply(this,s):s[0],c=o.cache;if(c.has(a))return c.get(a);var u=n.apply(this,s);return o.cache=c.set(a,u)||c,u};return o.cache=new(r.Cache||e),o}return r.Cache=e,Wa=r,Wa}var Ga,Lh;function O1(){if(Lh)return Ga;Lh=1;var e=I1(),t=500;function r(n){var i=e(n,function(s){return o.size===t&&o.clear(),s}),o=i.cache;return i}return Ga=r,Ga}var Ua,Fh;function M1(){if(Fh)return Ua;Fh=1;var e=O1(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=e(function(i){var o=[];return i.charCodeAt(0)===46&&o.push(""),i.replace(t,function(s,a,c,u){o.push(c?u.replace(r,"$1"):a||s)}),o});return Ua=n,Ua}var Ha,Bh;function Xn(){if(Bh)return Ha;Bh=1;function e(t,r){for(var n=-1,i=t==null?0:t.length,o=Array(i);++n<i;)o[n]=r(t[n],n,t);return o}return Ha=e,Ha}var Ka,zh;function q1(){if(zh)return Ka;zh=1;var e=Ot(),t=Xn(),r=rr(),n=$t(),i=e?e.prototype:void 0,o=i?i.toString:void 0;function s(a){if(typeof a=="string")return a;if(r(a))return t(a,s)+"";if(n(a))return o?o.call(a):"";var c=a+"";return c=="0"&&1/a==-1/0?"-0":c}return Ka=s,Ka}var Ja,Dh;function Rb(){if(Dh)return Ja;Dh=1;var e=q1();function t(r){return r==null?"":e(r)}return Ja=t,Ja}var Za,Vh;function Qn(){if(Vh)return Za;Vh=1;var e=rr(),t=bl(),r=M1(),n=Rb();function i(o,s){return e(o)?o:t(o,s)?[o]:r(n(o))}return Za=i,Za}var Ya,Wh;function yn(){if(Wh)return Ya;Wh=1;var e=$t();function t(r){if(typeof r=="string"||e(r))return r;var n=r+"";return n=="0"&&1/r==-1/0?"-0":n}return Ya=t,Ya}var Xa,Gh;function eo(){if(Gh)return Xa;Gh=1;var e=Qn(),t=yn();function r(n,i){i=e(i,n);for(var o=0,s=i.length;n!=null&&o<s;)n=n[t(i[o++])];return o&&o==s?n:void 0}return Xa=r,Xa}var Qa,Uh;function $1(){if(Uh)return Qa;Uh=1;var e=eo();function t(r,n,i){var o=r==null?void 0:e(r,n);return o===void 0?i:o}return Qa=t,Qa}var es,Hh;function N1(){if(Hh)return es;Hh=1;function e(t,r){return t!=null&&r in Object(t)}return es=e,es}var rs,Kh;function Pb(){if(Kh)return rs;Kh=1;var e=Qn(),t=pn(),r=rr(),n=Hn(),i=cl(),o=yn();function s(a,c,u){c=e(c,a);for(var l=-1,d=c.length,h=!1;++l<d;){var p=o(c[l]);if(!(h=a!=null&&u(a,p)))break;a=a[p]}return h||++l!=d?h:(d=a==null?0:a.length,!!d&&i(d)&&n(p,d)&&(r(a)||t(a)))}return rs=s,rs}var ts,Jh;function Ab(){if(Jh)return ts;Jh=1;var e=N1(),t=Pb();function r(n,i){return n!=null&&t(n,i,e)}return ts=r,ts}var ns,Zh;function L1(){if(Zh)return ns;Zh=1;var e=Eb(),t=$1(),r=Ab(),n=bl(),i=jb(),o=kb(),s=yn(),a=1,c=2;function u(l,d){return n(l)&&i(d)?o(s(l),d):function(h){var p=t(h,l);return p===void 0&&p===d?r(h,l):e(d,p,a|c)}}return ns=u,ns}var os,Yh;function Tb(){if(Yh)return os;Yh=1;function e(t){return function(r){return r==null?void 0:r[t]}}return os=e,os}var is,Xh;function F1(){if(Xh)return is;Xh=1;var e=eo();function t(r){return function(n){return e(n,r)}}return is=t,is}var as,Qh;function B1(){if(Qh)return as;Qh=1;var e=Tb(),t=F1(),r=bl(),n=yn();function i(o){return r(o)?e(n(o)):t(o)}return as=i,as}var ss,ep;function Br(){if(ep)return ss;ep=1;var e=T1(),t=L1(),r=pt(),n=rr(),i=B1();function o(s){return typeof s=="function"?s:s==null?r:typeof s=="object"?n(s)?t(s[0],s[1]):e(s):i(s)}return ss=o,ss}var cs,rp;function Ib(){if(rp)return cs;rp=1;var e=cb(),t=w1(),r=Br(),n=rr();function i(o,s){var a=n(o)?e:t;return a(o,r(s,3))}return cs=i,cs}var us,tp;function z1(){if(tp)return us;tp=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n,i){return n!=null&&t.call(n,i)}return us=r,us}var ls,np;function Ob(){if(np)return ls;np=1;var e=z1(),t=Pb();function r(n,i){return n!=null&&t(n,i,e)}return ls=r,ls}var ds,op;function D1(){if(op)return ds;op=1;var e=ll(),t=qt(),r=pn(),n=rr(),i=Fr(),o=Mt(),s=Jn(),a=gn(),c="[object Map]",u="[object Set]",l=Object.prototype,d=l.hasOwnProperty;function h(p){if(p==null)return!0;if(i(p)&&(n(p)||typeof p=="string"||typeof p.splice=="function"||o(p)||a(p)||r(p)))return!p.length;var y=t(p);if(y==c||y==u)return!p.size;if(s(p))return!e(p).length;for(var m in p)if(d.call(p,m))return!1;return!0}return ds=h,ds}var fs,ip;function Mb(){if(ip)return fs;ip=1;function e(t){return t===void 0}return fs=e,fs}var hs,ap;function qb(){if(ap)return hs;ap=1;var e=Yn(),t=Fr();function r(n,i){var o=-1,s=t(n)?Array(n.length):[];return e(n,function(a,c,u){s[++o]=i(a,c,u)}),s}return hs=r,hs}var ps,sp;function $b(){if(sp)return ps;sp=1;var e=Xn(),t=Br(),r=qb(),n=rr();function i(o,s){var a=n(o)?e:r;return a(o,t(s,3))}return ps=i,ps}var gs,cp;function V1(){if(cp)return gs;cp=1;function e(t,r,n,i){var o=-1,s=t==null?0:t.length;for(i&&s&&(n=t[++o]);++o<s;)n=r(n,t[o],o,t);return n}return gs=e,gs}var ys,up;function W1(){if(up)return ys;up=1;function e(t,r,n,i,o){return o(t,function(s,a,c){n=i?(i=!1,s):r(n,s,a,c)}),n}return ys=e,ys}var ms,lp;function Nb(){if(lp)return ms;lp=1;var e=V1(),t=Yn(),r=Br(),n=W1(),i=rr();function o(s,a,c){var u=i(s)?e:n,l=arguments.length<3;return u(s,r(a,4),c,l,t)}return ms=o,ms}var bs,dp;function G1(){if(dp)return bs;dp=1;var e=dt(),t=rr(),r=qr(),n="[object String]";function i(o){return typeof o=="string"||!t(o)&&r(o)&&e(o)==n}return bs=i,bs}var vs,fp;function U1(){if(fp)return vs;fp=1;var e=Tb(),t=e("length");return vs=t,vs}var xs,hp;function H1(){if(hp)return xs;hp=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",i=t+r+n,o="\\ufe0e\\ufe0f",s="\\u200d",a=RegExp("["+s+e+i+o+"]");function c(u){return a.test(u)}return xs=c,xs}var ws,pp;function K1(){if(pp)return ws;pp=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",i=t+r+n,o="\\ufe0e\\ufe0f",s="["+e+"]",a="["+i+"]",c="\\ud83c[\\udffb-\\udfff]",u="(?:"+a+"|"+c+")",l="[^"+e+"]",d="(?:\\ud83c[\\udde6-\\uddff]){2}",h="[\\ud800-\\udbff][\\udc00-\\udfff]",p="\\u200d",y=u+"?",m="["+o+"]?",g="(?:"+p+"(?:"+[l,d,h].join("|")+")"+m+y+")*",b=m+y+g,x="(?:"+[l+a+"?",a,d,h,s].join("|")+")",v=RegExp(c+"(?="+c+")|"+x+b,"g");function w(C){for(var S=v.lastIndex=0;v.test(C);)++S;return S}return ws=w,ws}var Cs,gp;function J1(){if(gp)return Cs;gp=1;var e=U1(),t=H1(),r=K1();function n(i){return t(i)?r(i):e(i)}return Cs=n,Cs}var Ss,yp;function Z1(){if(yp)return Ss;yp=1;var e=ll(),t=qt(),r=Fr(),n=G1(),i=J1(),o="[object Map]",s="[object Set]";function a(c){if(c==null)return 0;if(r(c))return n(c)?i(c):c.length;var u=t(c);return u==o||u==s?c.size:e(c).length}return Ss=a,Ss}var _s,mp;function Y1(){if(mp)return _s;mp=1;var e=sl(),t=yb(),r=yl(),n=Br(),i=Zn(),o=rr(),s=Mt(),a=fn(),c=Er(),u=gn();function l(d,h,p){var y=o(d),m=y||s(d)||u(d);if(h=n(h,4),p==null){var g=d&&d.constructor;m?p=y?new g:[]:c(d)?p=a(g)?t(i(d)):{}:p={}}return(m?e:r)(d,function(b,x,v){return h(p,b,x,v)}),p}return _s=l,_s}var Es,bp;function X1(){if(bp)return Es;bp=1;var e=Ot(),t=pn(),r=rr(),n=e?e.isConcatSpreadable:void 0;function i(o){return r(o)||t(o)||!!(n&&o&&o[n])}return Es=i,Es}var js,vp;function vl(){if(vp)return js;vp=1;var e=fl(),t=X1();function r(n,i,o,s,a){var c=-1,u=n.length;for(o||(o=t),a||(a=[]);++c<u;){var l=n[c];i>0&&o(l)?i>1?r(l,i-1,o,s,a):e(a,l):s||(a[a.length]=l)}return a}return js=r,js}var ks,xp;function Q1(){if(xp)return ks;xp=1;function e(t,r,n){switch(n.length){case 0:return t.call(r);case 1:return t.call(r,n[0]);case 2:return t.call(r,n[0],n[1]);case 3:return t.call(r,n[0],n[1],n[2])}return t.apply(r,n)}return ks=e,ks}var Rs,wp;function Lb(){if(wp)return Rs;wp=1;var e=Q1(),t=Math.max;function r(n,i,o){return i=t(i===void 0?n.length-1:i,0),function(){for(var s=arguments,a=-1,c=t(s.length-i,0),u=Array(c);++a<c;)u[a]=s[i+a];a=-1;for(var l=Array(i+1);++a<i;)l[a]=s[a];return l[i]=o(u),e(n,this,l)}}return Rs=r,Rs}var Ps,Cp;function eC(){if(Cp)return Ps;Cp=1;var e=pl(),t=nb(),r=pt(),n=t?function(i,o){return t(i,"toString",{configurable:!0,enumerable:!1,value:e(o),writable:!0})}:r;return Ps=n,Ps}var As,Sp;function rC(){if(Sp)return As;Sp=1;var e=800,t=16,r=Date.now;function n(i){var o=0,s=0;return function(){var a=r(),c=t-(a-s);if(s=a,c>0){if(++o>=e)return arguments[0]}else o=0;return i.apply(void 0,arguments)}}return As=n,As}var Ts,_p;function Fb(){if(_p)return Ts;_p=1;var e=eC(),t=rC(),r=t(e);return Ts=r,Ts}var Is,Ep;function ro(){if(Ep)return Is;Ep=1;var e=pt(),t=Lb(),r=Fb();function n(i,o){return r(t(i,o,e),i+"")}return Is=n,Is}var Os,jp;function Bb(){if(jp)return Os;jp=1;function e(t,r,n,i){for(var o=t.length,s=n+(i?1:-1);i?s--:++s<o;)if(r(t[s],s,t))return s;return-1}return Os=e,Os}var Ms,kp;function tC(){if(kp)return Ms;kp=1;function e(t){return t!==t}return Ms=e,Ms}var qs,Rp;function nC(){if(Rp)return qs;Rp=1;function e(t,r,n){for(var i=n-1,o=t.length;++i<o;)if(t[i]===r)return i;return-1}return qs=e,qs}var $s,Pp;function oC(){if(Pp)return $s;Pp=1;var e=Bb(),t=tC(),r=nC();function n(i,o,s){return o===o?r(i,o,s):e(i,t,s)}return $s=n,$s}var Ns,Ap;function iC(){if(Ap)return Ns;Ap=1;var e=oC();function t(r,n){var i=r==null?0:r.length;return!!i&&e(r,n,0)>-1}return Ns=t,Ns}var Ls,Tp;function aC(){if(Tp)return Ls;Tp=1;function e(t,r,n){for(var i=-1,o=t==null?0:t.length;++i<o;)if(n(r,t[i]))return!0;return!1}return Ls=e,Ls}var Fs,Ip;function sC(){if(Ip)return Fs;Ip=1;function e(){}return Fs=e,Fs}var Bs,Op;function cC(){if(Op)return Bs;Op=1;var e=hb(),t=sC(),r=ml(),n=1/0,i=e&&1/r(new e([,-0]))[1]==n?function(o){return new e(o)}:t;return Bs=i,Bs}var zs,Mp;function uC(){if(Mp)return zs;Mp=1;var e=Cb(),t=iC(),r=aC(),n=Sb(),i=cC(),o=ml(),s=200;function a(c,u,l){var d=-1,h=t,p=c.length,y=!0,m=[],g=m;if(l)y=!1,h=r;else if(p>=s){var b=u?null:i(c);if(b)return o(b);y=!1,h=n,g=new e}else g=u?[]:m;e:for(;++d<p;){var x=c[d],v=u?u(x):x;if(x=l||x!==0?x:0,y&&v===v){for(var w=g.length;w--;)if(g[w]===v)continue e;u&&g.push(v),m.push(x)}else h(g,v,l)||(g!==m&&g.push(v),m.push(x))}return m}return zs=a,zs}var Ds,qp;function zb(){if(qp)return Ds;qp=1;var e=Fr(),t=qr();function r(n){return t(n)&&e(n)}return Ds=r,Ds}var Vs,$p;function lC(){if($p)return Vs;$p=1;var e=vl(),t=ro(),r=uC(),n=zb(),i=t(function(o){return r(e(o,1,n,!0))});return Vs=i,Vs}var Ws,Np;function dC(){if(Np)return Ws;Np=1;var e=Xn();function t(r,n){return e(n,function(i){return r[i]})}return Ws=t,Ws}var Gs,Lp;function Db(){if(Lp)return Gs;Lp=1;var e=dC(),t=et();function r(n){return n==null?[]:e(n,t(n))}return Gs=r,Gs}var Us,Fp;function jr(){if(Fp)return Us;Fp=1;var e;if(typeof ol=="function")try{e={clone:b1(),constant:pl(),each:wb(),filter:Ib(),has:Ob(),isArray:rr(),isEmpty:D1(),isFunction:fn(),isUndefined:Mb(),keys:et(),map:$b(),reduce:Nb(),size:Z1(),transform:Y1(),union:lC(),values:Db()}}catch{}return e||(e=window._),Us=e,Us}var Hs,Bp;function xl(){if(Bp)return Hs;Bp=1;var e=jr();Hs=i;var t="\0",r="\0",n="";function i(l){this._isDirected=e.has(l,"directed")?l.directed:!0,this._isMultigraph=e.has(l,"multigraph")?l.multigraph:!1,this._isCompound=e.has(l,"compound")?l.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[r]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}i.prototype._nodeCount=0,i.prototype._edgeCount=0,i.prototype.isDirected=function(){return this._isDirected},i.prototype.isMultigraph=function(){return this._isMultigraph},i.prototype.isCompound=function(){return this._isCompound},i.prototype.setGraph=function(l){return this._label=l,this},i.prototype.graph=function(){return this._label},i.prototype.setDefaultNodeLabel=function(l){return e.isFunction(l)||(l=e.constant(l)),this._defaultNodeLabelFn=l,this},i.prototype.nodeCount=function(){return this._nodeCount},i.prototype.nodes=function(){return e.keys(this._nodes)},i.prototype.sources=function(){var l=this;return e.filter(this.nodes(),function(d){return e.isEmpty(l._in[d])})},i.prototype.sinks=function(){var l=this;return e.filter(this.nodes(),function(d){return e.isEmpty(l._out[d])})},i.prototype.setNodes=function(l,d){var h=arguments,p=this;return e.each(l,function(y){h.length>1?p.setNode(y,d):p.setNode(y)}),this},i.prototype.setNode=function(l,d){return e.has(this._nodes,l)?(arguments.length>1&&(this._nodes[l]=d),this):(this._nodes[l]=arguments.length>1?d:this._defaultNodeLabelFn(l),this._isCompound&&(this._parent[l]=r,this._children[l]={},this._children[r][l]=!0),this._in[l]={},this._preds[l]={},this._out[l]={},this._sucs[l]={},++this._nodeCount,this)},i.prototype.node=function(l){return this._nodes[l]},i.prototype.hasNode=function(l){return e.has(this._nodes,l)},i.prototype.removeNode=function(l){var d=this;if(e.has(this._nodes,l)){var h=function(p){d.removeEdge(d._edgeObjs[p])};delete this._nodes[l],this._isCompound&&(this._removeFromParentsChildList(l),delete this._parent[l],e.each(this.children(l),function(p){d.setParent(p)}),delete this._children[l]),e.each(e.keys(this._in[l]),h),delete this._in[l],delete this._preds[l],e.each(e.keys(this._out[l]),h),delete this._out[l],delete this._sucs[l],--this._nodeCount}return this},i.prototype.setParent=function(l,d){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(d))d=r;else{d+="";for(var h=d;!e.isUndefined(h);h=this.parent(h))if(h===l)throw new Error("Setting "+d+" as parent of "+l+" would create a cycle");this.setNode(d)}return this.setNode(l),this._removeFromParentsChildList(l),this._parent[l]=d,this._children[d][l]=!0,this},i.prototype._removeFromParentsChildList=function(l){delete this._children[this._parent[l]][l]},i.prototype.parent=function(l){if(this._isCompound){var d=this._parent[l];if(d!==r)return d}},i.prototype.children=function(l){if(e.isUndefined(l)&&(l=r),this._isCompound){var d=this._children[l];if(d)return e.keys(d)}else{if(l===r)return this.nodes();if(this.hasNode(l))return[]}},i.prototype.predecessors=function(l){var d=this._preds[l];if(d)return e.keys(d)},i.prototype.successors=function(l){var d=this._sucs[l];if(d)return e.keys(d)},i.prototype.neighbors=function(l){var d=this.predecessors(l);if(d)return e.union(d,this.successors(l))},i.prototype.isLeaf=function(l){var d;return this.isDirected()?d=this.successors(l):d=this.neighbors(l),d.length===0},i.prototype.filterNodes=function(l){var d=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});d.setGraph(this.graph());var h=this;e.each(this._nodes,function(m,g){l(g)&&d.setNode(g,m)}),e.each(this._edgeObjs,function(m){d.hasNode(m.v)&&d.hasNode(m.w)&&d.setEdge(m,h.edge(m))});var p={};function y(m){var g=h.parent(m);return g===void 0||d.hasNode(g)?(p[m]=g,g):g in p?p[g]:y(g)}return this._isCompound&&e.each(d.nodes(),function(m){d.setParent(m,y(m))}),d},i.prototype.setDefaultEdgeLabel=function(l){return e.isFunction(l)||(l=e.constant(l)),this._defaultEdgeLabelFn=l,this},i.prototype.edgeCount=function(){return this._edgeCount},i.prototype.edges=function(){return e.values(this._edgeObjs)},i.prototype.setPath=function(l,d){var h=this,p=arguments;return e.reduce(l,function(y,m){return p.length>1?h.setEdge(y,m,d):h.setEdge(y,m),m}),this},i.prototype.setEdge=function(){var l,d,h,p,y=!1,m=arguments[0];typeof m=="object"&&m!==null&&"v"in m?(l=m.v,d=m.w,h=m.name,arguments.length===2&&(p=arguments[1],y=!0)):(l=m,d=arguments[1],h=arguments[3],arguments.length>2&&(p=arguments[2],y=!0)),l=""+l,d=""+d,e.isUndefined(h)||(h=""+h);var g=a(this._isDirected,l,d,h);if(e.has(this._edgeLabels,g))return y&&(this._edgeLabels[g]=p),this;if(!e.isUndefined(h)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(l),this.setNode(d),this._edgeLabels[g]=y?p:this._defaultEdgeLabelFn(l,d,h);var b=c(this._isDirected,l,d,h);return l=b.v,d=b.w,Object.freeze(b),this._edgeObjs[g]=b,o(this._preds[d],l),o(this._sucs[l],d),this._in[d][g]=b,this._out[l][g]=b,this._edgeCount++,this},i.prototype.edge=function(l,d,h){var p=arguments.length===1?u(this._isDirected,arguments[0]):a(this._isDirected,l,d,h);return this._edgeLabels[p]},i.prototype.hasEdge=function(l,d,h){var p=arguments.length===1?u(this._isDirected,arguments[0]):a(this._isDirected,l,d,h);return e.has(this._edgeLabels,p)},i.prototype.removeEdge=function(l,d,h){var p=arguments.length===1?u(this._isDirected,arguments[0]):a(this._isDirected,l,d,h),y=this._edgeObjs[p];return y&&(l=y.v,d=y.w,delete this._edgeLabels[p],delete this._edgeObjs[p],s(this._preds[d],l),s(this._sucs[l],d),delete this._in[d][p],delete this._out[l][p],this._edgeCount--),this},i.prototype.inEdges=function(l,d){var h=this._in[l];if(h){var p=e.values(h);return d?e.filter(p,function(y){return y.v===d}):p}},i.prototype.outEdges=function(l,d){var h=this._out[l];if(h){var p=e.values(h);return d?e.filter(p,function(y){return y.w===d}):p}},i.prototype.nodeEdges=function(l,d){var h=this.inEdges(l,d);if(h)return h.concat(this.outEdges(l,d))};function o(l,d){l[d]?l[d]++:l[d]=1}function s(l,d){--l[d]||delete l[d]}function a(l,d,h,p){var y=""+d,m=""+h;if(!l&&y>m){var g=y;y=m,m=g}return y+n+m+n+(e.isUndefined(p)?t:p)}function c(l,d,h,p){var y=""+d,m=""+h;if(!l&&y>m){var g=y;y=m,m=g}var b={v:y,w:m};return p&&(b.name=p),b}function u(l,d){return a(l,d.v,d.w,d.name)}return Hs}var Ks,zp;function fC(){return zp||(zp=1,Ks="2.1.8"),Ks}var Js,Dp;function hC(){return Dp||(Dp=1,Js={Graph:xl(),version:fC()}),Js}var Zs,Vp;function pC(){if(Vp)return Zs;Vp=1;var e=jr(),t=xl();Zs={write:r,read:o};function r(s){var a={options:{directed:s.isDirected(),multigraph:s.isMultigraph(),compound:s.isCompound()},nodes:n(s),edges:i(s)};return e.isUndefined(s.graph())||(a.value=e.clone(s.graph())),a}function n(s){return e.map(s.nodes(),function(a){var c=s.node(a),u=s.parent(a),l={v:a};return e.isUndefined(c)||(l.value=c),e.isUndefined(u)||(l.parent=u),l})}function i(s){return e.map(s.edges(),function(a){var c=s.edge(a),u={v:a.v,w:a.w};return e.isUndefined(a.name)||(u.name=a.name),e.isUndefined(c)||(u.value=c),u})}function o(s){var a=new t(s.options).setGraph(s.value);return e.each(s.nodes,function(c){a.setNode(c.v,c.value),c.parent&&a.setParent(c.v,c.parent)}),e.each(s.edges,function(c){a.setEdge({v:c.v,w:c.w,name:c.name},c.value)}),a}return Zs}var Ys,Wp;function gC(){if(Wp)return Ys;Wp=1;var e=jr();Ys=t;function t(r){var n={},i=[],o;function s(a){e.has(n,a)||(n[a]=!0,o.push(a),e.each(r.successors(a),s),e.each(r.predecessors(a),s))}return e.each(r.nodes(),function(a){o=[],s(a),o.length&&i.push(o)}),i}return Ys}var Xs,Gp;function Vb(){if(Gp)return Xs;Gp=1;var e=jr();Xs=t;function t(){this._arr=[],this._keyIndices={}}return t.prototype.size=function(){return this._arr.length},t.prototype.keys=function(){return this._arr.map(function(r){return r.key})},t.prototype.has=function(r){return e.has(this._keyIndices,r)},t.prototype.priority=function(r){var n=this._keyIndices[r];if(n!==void 0)return this._arr[n].priority},t.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},t.prototype.add=function(r,n){var i=this._keyIndices;if(r=String(r),!e.has(i,r)){var o=this._arr,s=o.length;return i[r]=s,o.push({key:r,priority:n}),this._decrease(s),!0}return!1},t.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var r=this._arr.pop();return delete this._keyIndices[r.key],this._heapify(0),r.key},t.prototype.decrease=function(r,n){var i=this._keyIndices[r];if(n>this._arr[i].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[i].priority+" New: "+n);this._arr[i].priority=n,this._decrease(i)},t.prototype._heapify=function(r){var n=this._arr,i=2*r,o=i+1,s=r;i<n.length&&(s=n[i].priority<n[s].priority?i:s,o<n.length&&(s=n[o].priority<n[s].priority?o:s),s!==r&&(this._swap(r,s),this._heapify(s)))},t.prototype._decrease=function(r){for(var n=this._arr,i=n[r].priority,o;r!==0&&(o=r>>1,!(n[o].priority<i));)this._swap(r,o),r=o},t.prototype._swap=function(r,n){var i=this._arr,o=this._keyIndices,s=i[r],a=i[n];i[r]=a,i[n]=s,o[a.key]=r,o[s.key]=n},Xs}var Qs,Up;function Wb(){if(Up)return Qs;Up=1;var e=jr(),t=Vb();Qs=n;var r=e.constant(1);function n(o,s,a,c){return i(o,String(s),a||r,c||function(u){return o.outEdges(u)})}function i(o,s,a,c){var u={},l=new t,d,h,p=function(y){var m=y.v!==d?y.v:y.w,g=u[m],b=a(y),x=h.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+y+" Weight: "+b);x<g.distance&&(g.distance=x,g.predecessor=d,l.decrease(m,x))};for(o.nodes().forEach(function(y){var m=y===s?0:Number.POSITIVE_INFINITY;u[y]={distance:m},l.add(y,m)});l.size()>0&&(d=l.removeMin(),h=u[d],h.distance!==Number.POSITIVE_INFINITY);)c(d).forEach(p);return u}return Qs}var ec,Hp;function yC(){if(Hp)return ec;Hp=1;var e=Wb(),t=jr();ec=r;function r(n,i,o){return t.transform(n.nodes(),function(s,a){s[a]=e(n,a,i,o)},{})}return ec}var rc,Kp;function Gb(){if(Kp)return rc;Kp=1;var e=jr();rc=t;function t(r){var n=0,i=[],o={},s=[];function a(c){var u=o[c]={onStack:!0,lowlink:n,index:n++};if(i.push(c),r.successors(c).forEach(function(h){e.has(o,h)?o[h].onStack&&(u.lowlink=Math.min(u.lowlink,o[h].index)):(a(h),u.lowlink=Math.min(u.lowlink,o[h].lowlink))}),u.lowlink===u.index){var l=[],d;do d=i.pop(),o[d].onStack=!1,l.push(d);while(c!==d);s.push(l)}}return r.nodes().forEach(function(c){e.has(o,c)||a(c)}),s}return rc}var tc,Jp;function mC(){if(Jp)return tc;Jp=1;var e=jr(),t=Gb();tc=r;function r(n){return e.filter(t(n),function(i){return i.length>1||i.length===1&&n.hasEdge(i[0],i[0])})}return tc}var nc,Zp;function bC(){if(Zp)return nc;Zp=1;var e=jr();nc=r;var t=e.constant(1);function r(i,o,s){return n(i,o||t,s||function(a){return i.outEdges(a)})}function n(i,o,s){var a={},c=i.nodes();return c.forEach(function(u){a[u]={},a[u][u]={distance:0},c.forEach(function(l){u!==l&&(a[u][l]={distance:Number.POSITIVE_INFINITY})}),s(u).forEach(function(l){var d=l.v===u?l.w:l.v,h=o(l);a[u][d]={distance:h,predecessor:u}})}),c.forEach(function(u){var l=a[u];c.forEach(function(d){var h=a[d];c.forEach(function(p){var y=h[u],m=l[p],g=h[p],b=y.distance+m.distance;b<g.distance&&(g.distance=b,g.predecessor=m.predecessor)})})}),a}return nc}var oc,Yp;function Ub(){if(Yp)return oc;Yp=1;var e=jr();oc=t,t.CycleException=r;function t(n){var i={},o={},s=[];function a(c){if(e.has(o,c))throw new r;e.has(i,c)||(o[c]=!0,i[c]=!0,e.each(n.predecessors(c),a),delete o[c],s.push(c))}if(e.each(n.sinks(),a),e.size(i)!==n.nodeCount())throw new r;return s}function r(){}return r.prototype=new Error,oc}var ic,Xp;function vC(){if(Xp)return ic;Xp=1;var e=Ub();ic=t;function t(r){try{e(r)}catch(n){if(n instanceof e.CycleException)return!1;throw n}return!0}return ic}var ac,Qp;function Hb(){if(Qp)return ac;Qp=1;var e=jr();ac=t;function t(n,i,o){e.isArray(i)||(i=[i]);var s=(n.isDirected()?n.successors:n.neighbors).bind(n),a=[],c={};return e.each(i,function(u){if(!n.hasNode(u))throw new Error("Graph does not have node: "+u);r(n,u,o==="post",c,s,a)}),a}function r(n,i,o,s,a,c){e.has(s,i)||(s[i]=!0,o||c.push(i),e.each(a(i),function(u){r(n,u,o,s,a,c)}),o&&c.push(i))}return ac}var sc,eg;function xC(){if(eg)return sc;eg=1;var e=Hb();sc=t;function t(r,n){return e(r,n,"post")}return sc}var cc,rg;function wC(){if(rg)return cc;rg=1;var e=Hb();cc=t;function t(r,n){return e(r,n,"pre")}return cc}var uc,tg;function CC(){if(tg)return uc;tg=1;var e=jr(),t=xl(),r=Vb();uc=n;function n(i,o){var s=new t,a={},c=new r,u;function l(h){var p=h.v===u?h.w:h.v,y=c.priority(p);if(y!==void 0){var m=o(h);m<y&&(a[p]=u,c.decrease(p,m))}}if(i.nodeCount()===0)return s;e.each(i.nodes(),function(h){c.add(h,Number.POSITIVE_INFINITY),s.setNode(h)}),c.decrease(i.nodes()[0],0);for(var d=!1;c.size()>0;){if(u=c.removeMin(),e.has(a,u))s.setEdge(u,a[u]);else{if(d)throw new Error("Input graph is not connected: "+i);d=!0}i.nodeEdges(u).forEach(l)}return s}return uc}var lc,ng;function SC(){return ng||(ng=1,lc={components:gC(),dijkstra:Wb(),dijkstraAll:yC(),findCycles:mC(),floydWarshall:bC(),isAcyclic:vC(),postorder:xC(),preorder:wC(),prim:CC(),tarjan:Gb(),topsort:Ub()}),lc}var dc,og;function _C(){if(og)return dc;og=1;var e=hC();return dc={Graph:e.Graph,json:pC(),alg:SC(),version:e.version},dc}var fc,ig;function Ar(){if(ig)return fc;ig=1;var e;if(typeof ol=="function")try{e=_C()}catch{}return e||(e=window.graphlib),fc=e,fc}var hc,ag;function EC(){if(ag)return hc;ag=1;var e=bb(),t=1,r=4;function n(i){return e(i,t|r)}return hc=n,hc}var pc,sg;function to(){if(sg)return pc;sg=1;var e=It(),t=Fr(),r=Hn(),n=Er();function i(o,s,a){if(!n(a))return!1;var c=typeof s;return(c=="number"?t(a)&&r(s,a.length):c=="string"&&s in a)?e(a[s],o):!1}return pc=i,pc}var gc,cg;function jC(){if(cg)return gc;cg=1;var e=ro(),t=It(),r=to(),n=ht(),i=Object.prototype,o=i.hasOwnProperty,s=e(function(a,c){a=Object(a);var u=-1,l=c.length,d=l>2?c[2]:void 0;for(d&&r(c[0],c[1],d)&&(l=1);++u<l;)for(var h=c[u],p=n(h),y=-1,m=p.length;++y<m;){var g=p[y],b=a[g];(b===void 0||t(b,i[g])&&!o.call(a,g))&&(a[g]=h[g])}return a});return gc=s,gc}var yc,ug;function kC(){if(ug)return yc;ug=1;var e=Br(),t=Fr(),r=et();function n(i){return function(o,s,a){var c=Object(o);if(!t(o)){var u=e(s,3);o=r(o),s=function(d){return u(c[d],d,c)}}var l=i(o,s,a);return l>-1?c[u?o[l]:l]:void 0}}return yc=n,yc}var mc,lg;function RC(){if(lg)return mc;lg=1;var e=/\s/;function t(r){for(var n=r.length;n--&&e.test(r.charAt(n)););return n}return mc=t,mc}var bc,dg;function PC(){if(dg)return bc;dg=1;var e=RC(),t=/^\s+/;function r(n){return n&&n.slice(0,e(n)+1).replace(t,"")}return bc=r,bc}var vc,fg;function AC(){if(fg)return vc;fg=1;var e=PC(),t=Er(),r=$t(),n=NaN,i=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,s=/^0o[0-7]+$/i,a=parseInt;function c(u){if(typeof u=="number")return u;if(r(u))return n;if(t(u)){var l=typeof u.valueOf=="function"?u.valueOf():u;u=t(l)?l+"":l}if(typeof u!="string")return u===0?u:+u;u=e(u);var d=o.test(u);return d||s.test(u)?a(u.slice(2),d?2:8):i.test(u)?n:+u}return vc=c,vc}var xc,hg;function Kb(){if(hg)return xc;hg=1;var e=AC(),t=1/0,r=17976931348623157e292;function n(i){if(!i)return i===0?i:0;if(i=e(i),i===t||i===-t){var o=i<0?-1:1;return o*r}return i===i?i:0}return xc=n,xc}var wc,pg;function TC(){if(pg)return wc;pg=1;var e=Kb();function t(r){var n=e(r),i=n%1;return n===n?i?n-i:n:0}return wc=t,wc}var Cc,gg;function IC(){if(gg)return Cc;gg=1;var e=Bb(),t=Br(),r=TC(),n=Math.max;function i(o,s,a){var c=o==null?0:o.length;if(!c)return-1;var u=a==null?0:r(a);return u<0&&(u=n(c+u,0)),e(o,t(s,3),u)}return Cc=i,Cc}var Sc,yg;function OC(){if(yg)return Sc;yg=1;var e=kC(),t=IC(),r=e(t);return Sc=r,Sc}var _c,mg;function Jb(){if(mg)return _c;mg=1;var e=vl();function t(r){var n=r==null?0:r.length;return n?e(r,1):[]}return _c=t,_c}var Ec,bg;function MC(){if(bg)return Ec;bg=1;var e=gl(),t=vb(),r=ht();function n(i,o){return i==null?i:e(i,t(o),r)}return Ec=n,Ec}var jc,vg;function qC(){if(vg)return jc;vg=1;function e(t){var r=t==null?0:t.length;return r?t[r-1]:void 0}return jc=e,jc}var kc,xg;function $C(){if(xg)return kc;xg=1;var e=Gn(),t=yl(),r=Br();function n(i,o){var s={};return o=r(o,3),t(i,function(a,c,u){e(s,c,o(a,c,u))}),s}return kc=n,kc}var Rc,wg;function wl(){if(wg)return Rc;wg=1;var e=$t();function t(r,n,i){for(var o=-1,s=r.length;++o<s;){var a=r[o],c=n(a);if(c!=null&&(u===void 0?c===c&&!e(c):i(c,u)))var u=c,l=a}return l}return Rc=t,Rc}var Pc,Cg;function NC(){if(Cg)return Pc;Cg=1;function e(t,r){return t>r}return Pc=e,Pc}var Ac,Sg;function LC(){if(Sg)return Ac;Sg=1;var e=wl(),t=NC(),r=pt();function n(i){return i&&i.length?e(i,r,t):void 0}return Ac=n,Ac}var Tc,_g;function Zb(){if(_g)return Tc;_g=1;var e=Gn(),t=It();function r(n,i,o){(o!==void 0&&!t(n[i],o)||o===void 0&&!(i in n))&&e(n,i,o)}return Tc=r,Tc}var Ic,Eg;function FC(){if(Eg)return Ic;Eg=1;var e=dt(),t=Zn(),r=qr(),n="[object Object]",i=Function.prototype,o=Object.prototype,s=i.toString,a=o.hasOwnProperty,c=s.call(Object);function u(l){if(!r(l)||e(l)!=n)return!1;var d=t(l);if(d===null)return!0;var h=a.call(d,"constructor")&&d.constructor;return typeof h=="function"&&h instanceof h&&s.call(h)==c}return Ic=u,Ic}var Oc,jg;function Yb(){if(jg)return Oc;jg=1;function e(t,r){if(!(r==="constructor"&&typeof t[r]=="function")&&r!="__proto__")return t[r]}return Oc=e,Oc}var Mc,kg;function BC(){if(kg)return Mc;kg=1;var e=hn(),t=ht();function r(n){return e(n,t(n))}return Mc=r,Mc}var qc,Rg;function zC(){if(Rg)return qc;Rg=1;var e=Zb(),t=ab(),r=gb(),n=sb(),i=mb(),o=pn(),s=rr(),a=zb(),c=Mt(),u=fn(),l=Er(),d=FC(),h=gn(),p=Yb(),y=BC();function m(g,b,x,v,w,C,S){var j=p(g,x),I=p(b,x),P=S.get(I);if(P){e(g,x,P);return}var O=C?C(j,I,x+"",g,b,S):void 0,T=O===void 0;if(T){var E=s(I),R=!E&&c(I),k=!E&&!R&&h(I);O=I,E||R||k?s(j)?O=j:a(j)?O=n(j):R?(T=!1,O=t(I,!0)):k?(T=!1,O=r(I,!0)):O=[]:d(I)||o(I)?(O=j,o(j)?O=y(j):(!l(j)||u(j))&&(O=i(I))):T=!1}T&&(S.set(I,O),w(O,I,v,C,S),S.delete(I)),e(g,x,O)}return qc=m,qc}var $c,Pg;function DC(){if(Pg)return $c;Pg=1;var e=Wn(),t=Zb(),r=gl(),n=zC(),i=Er(),o=ht(),s=Yb();function a(c,u,l,d,h){c!==u&&r(u,function(p,y){if(h||(h=new e),i(p))n(c,u,y,l,a,d,h);else{var m=d?d(s(c,y),p,y+"",c,u,h):void 0;m===void 0&&(m=p),t(c,y,m)}},o)}return $c=a,$c}var Nc,Ag;function VC(){if(Ag)return Nc;Ag=1;var e=ro(),t=to();function r(n){return e(function(i,o){var s=-1,a=o.length,c=a>1?o[a-1]:void 0,u=a>2?o[2]:void 0;for(c=n.length>3&&typeof c=="function"?(a--,c):void 0,u&&t(o[0],o[1],u)&&(c=a<3?void 0:c,a=1),i=Object(i);++s<a;){var l=o[s];l&&n(i,l,s,c)}return i})}return Nc=r,Nc}var Lc,Tg;function WC(){if(Tg)return Lc;Tg=1;var e=DC(),t=VC(),r=t(function(n,i,o){e(n,i,o)});return Lc=r,Lc}var Fc,Ig;function Xb(){if(Ig)return Fc;Ig=1;function e(t,r){return t<r}return Fc=e,Fc}var Bc,Og;function GC(){if(Og)return Bc;Og=1;var e=wl(),t=Xb(),r=pt();function n(i){return i&&i.length?e(i,r,t):void 0}return Bc=n,Bc}var zc,Mg;function UC(){if(Mg)return zc;Mg=1;var e=wl(),t=Br(),r=Xb();function n(i,o){return i&&i.length?e(i,t(o,2),r):void 0}return zc=n,zc}var Dc,qg;function HC(){if(qg)return Dc;qg=1;var e=Tr(),t=function(){return e.Date.now()};return Dc=t,Dc}var Vc,$g;function KC(){if($g)return Vc;$g=1;var e=Un(),t=Qn(),r=Hn(),n=Er(),i=yn();function o(s,a,c,u){if(!n(s))return s;a=t(a,s);for(var l=-1,d=a.length,h=d-1,p=s;p!=null&&++l<d;){var y=i(a[l]),m=c;if(y==="__proto__"||y==="constructor"||y==="prototype")return s;if(l!=h){var g=p[y];m=u?u(g,y,p):void 0,m===void 0&&(m=n(g)?g:r(a[l+1])?[]:{})}e(p,y,m),p=p[y]}return s}return Vc=o,Vc}var Wc,Ng;function JC(){if(Ng)return Wc;Ng=1;var e=eo(),t=KC(),r=Qn();function n(i,o,s){for(var a=-1,c=o.length,u={};++a<c;){var l=o[a],d=e(i,l);s(d,l)&&t(u,r(l,i),d)}return u}return Wc=n,Wc}var Gc,Lg;function ZC(){if(Lg)return Gc;Lg=1;var e=JC(),t=Ab();function r(n,i){return e(n,i,function(o,s){return t(n,s)})}return Gc=r,Gc}var Uc,Fg;function YC(){if(Fg)return Uc;Fg=1;var e=Jb(),t=Lb(),r=Fb();function n(i){return r(t(i,void 0,e),i+"")}return Uc=n,Uc}var Hc,Bg;function XC(){if(Bg)return Hc;Bg=1;var e=ZC(),t=YC(),r=t(function(n,i){return n==null?{}:e(n,i)});return Hc=r,Hc}var Kc,zg;function QC(){if(zg)return Kc;zg=1;var e=Math.ceil,t=Math.max;function r(n,i,o,s){for(var a=-1,c=t(e((i-n)/(o||1)),0),u=Array(c);c--;)u[s?c:++a]=n,n+=o;return u}return Kc=r,Kc}var Jc,Dg;function eS(){if(Dg)return Jc;Dg=1;var e=QC(),t=to(),r=Kb();function n(i){return function(o,s,a){return a&&typeof a!="number"&&t(o,s,a)&&(s=a=void 0),o=r(o),s===void 0?(s=o,o=0):s=r(s),a=a===void 0?o<s?1:-1:r(a),e(o,s,a,i)}}return Jc=n,Jc}var Zc,Vg;function rS(){if(Vg)return Zc;Vg=1;var e=eS(),t=e();return Zc=t,Zc}var Yc,Wg;function tS(){if(Wg)return Yc;Wg=1;function e(t,r){var n=t.length;for(t.sort(r);n--;)t[n]=t[n].value;return t}return Yc=e,Yc}var Xc,Gg;function nS(){if(Gg)return Xc;Gg=1;var e=$t();function t(r,n){if(r!==n){var i=r!==void 0,o=r===null,s=r===r,a=e(r),c=n!==void 0,u=n===null,l=n===n,d=e(n);if(!u&&!d&&!a&&r>n||a&&c&&l&&!u&&!d||o&&c&&l||!i&&l||!s)return 1;if(!o&&!a&&!d&&r<n||d&&i&&s&&!o&&!a||u&&i&&s||!c&&s||!l)return-1}return 0}return Xc=t,Xc}var Qc,Ug;function oS(){if(Ug)return Qc;Ug=1;var e=nS();function t(r,n,i){for(var o=-1,s=r.criteria,a=n.criteria,c=s.length,u=i.length;++o<c;){var l=e(s[o],a[o]);if(l){if(o>=u)return l;var d=i[o];return l*(d=="desc"?-1:1)}}return r.index-n.index}return Qc=t,Qc}var eu,Hg;function iS(){if(Hg)return eu;Hg=1;var e=Xn(),t=eo(),r=Br(),n=qb(),i=tS(),o=Kn(),s=oS(),a=pt(),c=rr();function u(l,d,h){d.length?d=e(d,function(m){return c(m)?function(g){return t(g,m.length===1?m[0]:m)}:m}):d=[a];var p=-1;d=e(d,o(r));var y=n(l,function(m,g,b){var x=e(d,function(v){return v(m)});return{criteria:x,index:++p,value:m}});return i(y,function(m,g){return s(m,g,h)})}return eu=u,eu}var ru,Kg;function aS(){if(Kg)return ru;Kg=1;var e=vl(),t=iS(),r=ro(),n=to(),i=r(function(o,s){if(o==null)return[];var a=s.length;return a>1&&n(o,s[0],s[1])?s=[]:a>2&&n(s[0],s[1],s[2])&&(s=[s[0]]),t(o,e(s,1),[])});return ru=i,ru}var tu,Jg;function sS(){if(Jg)return tu;Jg=1;var e=Rb(),t=0;function r(n){var i=++t;return e(n)+i}return tu=r,tu}var nu,Zg;function cS(){if(Zg)return nu;Zg=1;function e(t,r,n){for(var i=-1,o=t.length,s=r.length,a={};++i<o;){var c=i<s?r[i]:void 0;n(a,t[i],c)}return a}return nu=e,nu}var ou,Yg;function uS(){if(Yg)return ou;Yg=1;var e=Un(),t=cS();function r(n,i){return t(n||[],i||[],e)}return ou=r,ou}var iu,Xg;function Je(){if(Xg)return iu;Xg=1;var e;if(typeof ol=="function")try{e={cloneDeep:EC(),constant:pl(),defaults:jC(),each:wb(),filter:Ib(),find:OC(),flatten:Jb(),forEach:xb(),forIn:MC(),has:Ob(),isUndefined:Mb(),last:qC(),map:$b(),mapValues:$C(),max:LC(),merge:WC(),min:GC(),minBy:UC(),now:HC(),pick:XC(),range:rS(),reduce:Nb(),sortBy:aS(),uniqueId:sS(),values:Db(),zipObject:uS()}}catch{}return e||(e=window._),iu=e,iu}var au,Qg;function lS(){if(Qg)return au;Qg=1,au=e;function e(){var n={};n._next=n._prev=n,this._sentinel=n}e.prototype.dequeue=function(){var n=this._sentinel,i=n._prev;if(i!==n)return t(i),i},e.prototype.enqueue=function(n){var i=this._sentinel;n._prev&&n._next&&t(n),n._next=i._next,i._next._prev=n,i._next=n,n._prev=i},e.prototype.toString=function(){for(var n=[],i=this._sentinel,o=i._prev;o!==i;)n.push(JSON.stringify(o,r)),o=o._prev;return"["+n.join(", ")+"]"};function t(n){n._prev._next=n._next,n._next._prev=n._prev,delete n._next,delete n._prev}function r(n,i){if(n!=="_next"&&n!=="_prev")return i}return au}var su,ey;function dS(){if(ey)return su;ey=1;var e=Je(),t=Ar().Graph,r=lS();su=i;var n=e.constant(1);function i(u,l){if(u.nodeCount()<=1)return[];var d=a(u,l||n),h=o(d.graph,d.buckets,d.zeroIdx);return e.flatten(e.map(h,function(p){return u.outEdges(p.v,p.w)}),!0)}function o(u,l,d){for(var h=[],p=l[l.length-1],y=l[0],m;u.nodeCount();){for(;m=y.dequeue();)s(u,l,d,m);for(;m=p.dequeue();)s(u,l,d,m);if(u.nodeCount()){for(var g=l.length-2;g>0;--g)if(m=l[g].dequeue(),m){h=h.concat(s(u,l,d,m,!0));break}}}return h}function s(u,l,d,h,p){var y=p?[]:void 0;return e.forEach(u.inEdges(h.v),function(m){var g=u.edge(m),b=u.node(m.v);p&&y.push({v:m.v,w:m.w}),b.out-=g,c(l,d,b)}),e.forEach(u.outEdges(h.v),function(m){var g=u.edge(m),b=m.w,x=u.node(b);x.in-=g,c(l,d,x)}),u.removeNode(h.v),y}function a(u,l){var d=new t,h=0,p=0;e.forEach(u.nodes(),function(g){d.setNode(g,{v:g,in:0,out:0})}),e.forEach(u.edges(),function(g){var b=d.edge(g.v,g.w)||0,x=l(g),v=b+x;d.setEdge(g.v,g.w,v),p=Math.max(p,d.node(g.v).out+=x),h=Math.max(h,d.node(g.w).in+=x)});var y=e.range(p+h+3).map(function(){return new r}),m=h+1;return e.forEach(d.nodes(),function(g){c(y,m,d.node(g))}),{graph:d,buckets:y,zeroIdx:m}}function c(u,l,d){d.out?d.in?u[d.out-d.in+l].enqueue(d):u[u.length-1].enqueue(d):u[0].enqueue(d)}return su}var cu,ry;function fS(){if(ry)return cu;ry=1;var e=Je(),t=dS();cu={run:r,undo:i};function r(o){var s=o.graph().acyclicer==="greedy"?t(o,a(o)):n(o);e.forEach(s,function(c){var u=o.edge(c);o.removeEdge(c),u.forwardName=c.name,u.reversed=!0,o.setEdge(c.w,c.v,u,e.uniqueId("rev"))});function a(c){return function(u){return c.edge(u).weight}}}function n(o){var s=[],a={},c={};function u(l){e.has(c,l)||(c[l]=!0,a[l]=!0,e.forEach(o.outEdges(l),function(d){e.has(a,d.w)?s.push(d):u(d.w)}),delete a[l])}return e.forEach(o.nodes(),u),s}function i(o){e.forEach(o.edges(),function(s){var a=o.edge(s);if(a.reversed){o.removeEdge(s);var c=a.forwardName;delete a.reversed,delete a.forwardName,o.setEdge(s.w,s.v,a,c)}})}return cu}var uu,ty;function yr(){if(ty)return uu;ty=1;var e=Je(),t=Ar().Graph;uu={addDummyNode:r,simplify:n,asNonCompoundGraph:i,successorWeights:o,predecessorWeights:s,intersectRect:a,buildLayerMatrix:c,normalizeRanks:u,removeEmptyRanks:l,addBorderNode:d,maxRank:h,partition:p,time:y,notime:m};function r(g,b,x,v){var w;do w=e.uniqueId(v);while(g.hasNode(w));return x.dummy=b,g.setNode(w,x),w}function n(g){var b=new t().setGraph(g.graph());return e.forEach(g.nodes(),function(x){b.setNode(x,g.node(x))}),e.forEach(g.edges(),function(x){var v=b.edge(x.v,x.w)||{weight:0,minlen:1},w=g.edge(x);b.setEdge(x.v,x.w,{weight:v.weight+w.weight,minlen:Math.max(v.minlen,w.minlen)})}),b}function i(g){var b=new t({multigraph:g.isMultigraph()}).setGraph(g.graph());return e.forEach(g.nodes(),function(x){g.children(x).length||b.setNode(x,g.node(x))}),e.forEach(g.edges(),function(x){b.setEdge(x,g.edge(x))}),b}function o(g){var b=e.map(g.nodes(),function(x){var v={};return e.forEach(g.outEdges(x),function(w){v[w.w]=(v[w.w]||0)+g.edge(w).weight}),v});return e.zipObject(g.nodes(),b)}function s(g){var b=e.map(g.nodes(),function(x){var v={};return e.forEach(g.inEdges(x),function(w){v[w.v]=(v[w.v]||0)+g.edge(w).weight}),v});return e.zipObject(g.nodes(),b)}function a(g,b){var x=g.x,v=g.y,w=b.x-x,C=b.y-v,S=g.width/2,j=g.height/2;if(!w&&!C)throw new Error("Not possible to find intersection inside of the rectangle");var I,P;return Math.abs(C)*S>Math.abs(w)*j?(C<0&&(j=-j),I=j*w/C,P=j):(w<0&&(S=-S),I=S,P=S*C/w),{x:x+I,y:v+P}}function c(g){var b=e.map(e.range(h(g)+1),function(){return[]});return e.forEach(g.nodes(),function(x){var v=g.node(x),w=v.rank;e.isUndefined(w)||(b[w][v.order]=x)}),b}function u(g){var b=e.min(e.map(g.nodes(),function(x){return g.node(x).rank}));e.forEach(g.nodes(),function(x){var v=g.node(x);e.has(v,"rank")&&(v.rank-=b)})}function l(g){var b=e.min(e.map(g.nodes(),function(C){return g.node(C).rank})),x=[];e.forEach(g.nodes(),function(C){var S=g.node(C).rank-b;x[S]||(x[S]=[]),x[S].push(C)});var v=0,w=g.graph().nodeRankFactor;e.forEach(x,function(C,S){e.isUndefined(C)&&S%w!==0?--v:v&&e.forEach(C,function(j){g.node(j).rank+=v})})}function d(g,b,x,v){var w={width:0,height:0};return arguments.length>=4&&(w.rank=x,w.order=v),r(g,"border",w,b)}function h(g){return e.max(e.map(g.nodes(),function(b){var x=g.node(b).rank;if(!e.isUndefined(x))return x}))}function p(g,b){var x={lhs:[],rhs:[]};return e.forEach(g,function(v){b(v)?x.lhs.push(v):x.rhs.push(v)}),x}function y(g,b){var x=e.now();try{return b()}finally{console.log(g+" time: "+(e.now()-x)+"ms")}}function m(g,b){return b()}return uu}var lu,ny;function hS(){if(ny)return lu;ny=1;var e=Je(),t=yr();lu={run:r,undo:i};function r(o){o.graph().dummyChains=[],e.forEach(o.edges(),function(s){n(o,s)})}function n(o,s){var a=s.v,c=o.node(a).rank,u=s.w,l=o.node(u).rank,d=s.name,h=o.edge(s),p=h.labelRank;if(l!==c+1){o.removeEdge(s);var y,m,g;for(g=0,++c;c<l;++g,++c)h.points=[],m={width:0,height:0,edgeLabel:h,edgeObj:s,rank:c},y=t.addDummyNode(o,"edge",m,"_d"),c===p&&(m.width=h.width,m.height=h.height,m.dummy="edge-label",m.labelpos=h.labelpos),o.setEdge(a,y,{weight:h.weight},d),g===0&&o.graph().dummyChains.push(y),a=y;o.setEdge(a,u,{weight:h.weight},d)}}function i(o){e.forEach(o.graph().dummyChains,function(s){var a=o.node(s),c=a.edgeLabel,u;for(o.setEdge(a.edgeObj,c);a.dummy;)u=o.successors(s)[0],o.removeNode(s),c.points.push({x:a.x,y:a.y}),a.dummy==="edge-label"&&(c.x=a.x,c.y=a.y,c.width=a.width,c.height=a.height),s=u,a=o.node(s)})}return lu}var du,oy;function Tn(){if(oy)return du;oy=1;var e=Je();du={longestPath:t,slack:r};function t(n){var i={};function o(s){var a=n.node(s);if(e.has(i,s))return a.rank;i[s]=!0;var c=e.min(e.map(n.outEdges(s),function(u){return o(u.w)-n.edge(u).minlen}));return(c===Number.POSITIVE_INFINITY||c===void 0||c===null)&&(c=0),a.rank=c}e.forEach(n.sources(),o)}function r(n,i){return n.node(i.w).rank-n.node(i.v).rank-n.edge(i).minlen}return du}var fu,iy;function Qb(){if(iy)return fu;iy=1;var e=Je(),t=Ar().Graph,r=Tn().slack;fu=n;function n(a){var c=new t({directed:!1}),u=a.nodes()[0],l=a.nodeCount();c.setNode(u,{});for(var d,h;i(c,a)<l;)d=o(c,a),h=c.hasNode(d.v)?r(a,d):-r(a,d),s(c,a,h);return c}function i(a,c){function u(l){e.forEach(c.nodeEdges(l),function(d){var h=d.v,p=l===h?d.w:h;!a.hasNode(p)&&!r(c,d)&&(a.setNode(p,{}),a.setEdge(l,p,{}),u(p))})}return e.forEach(a.nodes(),u),a.nodeCount()}function o(a,c){return e.minBy(c.edges(),function(u){if(a.hasNode(u.v)!==a.hasNode(u.w))return r(c,u)})}function s(a,c,u){e.forEach(a.nodes(),function(l){c.node(l).rank+=u})}return fu}var hu,ay;function pS(){if(ay)return hu;ay=1;var e=Je(),t=Qb(),r=Tn().slack,n=Tn().longestPath,i=Ar().alg.preorder,o=Ar().alg.postorder,s=yr().simplify;hu=a,a.initLowLimValues=d,a.initCutValues=c,a.calcCutValue=l,a.leaveEdge=p,a.enterEdge=y,a.exchangeEdges=m;function a(v){v=s(v),n(v);var w=t(v);d(w),c(w,v);for(var C,S;C=p(w);)S=y(w,v,C),m(w,v,C,S)}function c(v,w){var C=o(v,v.nodes());C=C.slice(0,C.length-1),e.forEach(C,function(S){u(v,w,S)})}function u(v,w,C){var S=v.node(C),j=S.parent;v.edge(C,j).cutvalue=l(v,w,C)}function l(v,w,C){var S=v.node(C),j=S.parent,I=!0,P=w.edge(C,j),O=0;return P||(I=!1,P=w.edge(j,C)),O=P.weight,e.forEach(w.nodeEdges(C),function(T){var E=T.v===C,R=E?T.w:T.v;if(R!==j){var k=E===I,M=w.edge(T).weight;if(O+=k?M:-M,b(v,C,R)){var $=v.edge(C,R).cutvalue;O+=k?-$:$}}}),O}function d(v,w){arguments.length<2&&(w=v.nodes()[0]),h(v,{},1,w)}function h(v,w,C,S,j){var I=C,P=v.node(S);return w[S]=!0,e.forEach(v.neighbors(S),function(O){e.has(w,O)||(C=h(v,w,C,O,S))}),P.low=I,P.lim=C++,j?P.parent=j:delete P.parent,C}function p(v){return e.find(v.edges(),function(w){return v.edge(w).cutvalue<0})}function y(v,w,C){var S=C.v,j=C.w;w.hasEdge(S,j)||(S=C.w,j=C.v);var I=v.node(S),P=v.node(j),O=I,T=!1;I.lim>P.lim&&(O=P,T=!0);var E=e.filter(w.edges(),function(R){return T===x(v,v.node(R.v),O)&&T!==x(v,v.node(R.w),O)});return e.minBy(E,function(R){return r(w,R)})}function m(v,w,C,S){var j=C.v,I=C.w;v.removeEdge(j,I),v.setEdge(S.v,S.w,{}),d(v),c(v,w),g(v,w)}function g(v,w){var C=e.find(v.nodes(),function(j){return!w.node(j).parent}),S=i(v,C);S=S.slice(1),e.forEach(S,function(j){var I=v.node(j).parent,P=w.edge(j,I),O=!1;P||(P=w.edge(I,j),O=!0),w.node(j).rank=w.node(I).rank+(O?P.minlen:-P.minlen)})}function b(v,w,C){return v.hasEdge(w,C)}function x(v,w,C){return C.low<=w.lim&&w.lim<=C.lim}return hu}var pu,sy;function gS(){if(sy)return pu;sy=1;var e=Tn(),t=e.longestPath,r=Qb(),n=pS();pu=i;function i(c){switch(c.graph().ranker){case"network-simplex":a(c);break;case"tight-tree":s(c);break;case"longest-path":o(c);break;default:a(c)}}var o=t;function s(c){t(c),r(c)}function a(c){n(c)}return pu}var gu,cy;function yS(){if(cy)return gu;cy=1;var e=Je();gu=t;function t(i){var o=n(i);e.forEach(i.graph().dummyChains,function(s){for(var a=i.node(s),c=a.edgeObj,u=r(i,o,c.v,c.w),l=u.path,d=u.lca,h=0,p=l[h],y=!0;s!==c.w;){if(a=i.node(s),y){for(;(p=l[h])!==d&&i.node(p).maxRank<a.rank;)h++;p===d&&(y=!1)}if(!y){for(;h<l.length-1&&i.node(p=l[h+1]).minRank<=a.rank;)h++;p=l[h]}i.setParent(s,p),s=i.successors(s)[0]}})}function r(i,o,s,a){var c=[],u=[],l=Math.min(o[s].low,o[a].low),d=Math.max(o[s].lim,o[a].lim),h,p;h=s;do h=i.parent(h),c.push(h);while(h&&(o[h].low>l||d>o[h].lim));for(p=h,h=a;(h=i.parent(h))!==p;)u.push(h);return{path:c.concat(u.reverse()),lca:p}}function n(i){var o={},s=0;function a(c){var u=s;e.forEach(i.children(c),a),o[c]={low:u,lim:s++}}return e.forEach(i.children(),a),o}return gu}var yu,uy;function mS(){if(uy)return yu;uy=1;var e=Je(),t=yr();yu={run:r,cleanup:s};function r(a){var c=t.addDummyNode(a,"root",{},"_root"),u=i(a),l=e.max(e.values(u))-1,d=2*l+1;a.graph().nestingRoot=c,e.forEach(a.edges(),function(p){a.edge(p).minlen*=d});var h=o(a)+1;e.forEach(a.children(),function(p){n(a,c,d,h,l,u,p)}),a.graph().nodeRankFactor=d}function n(a,c,u,l,d,h,p){var y=a.children(p);if(!y.length){p!==c&&a.setEdge(c,p,{weight:0,minlen:u});return}var m=t.addBorderNode(a,"_bt"),g=t.addBorderNode(a,"_bb"),b=a.node(p);a.setParent(m,p),b.borderTop=m,a.setParent(g,p),b.borderBottom=g,e.forEach(y,function(x){n(a,c,u,l,d,h,x);var v=a.node(x),w=v.borderTop?v.borderTop:x,C=v.borderBottom?v.borderBottom:x,S=v.borderTop?l:2*l,j=w!==C?1:d-h[p]+1;a.setEdge(m,w,{weight:S,minlen:j,nestingEdge:!0}),a.setEdge(C,g,{weight:S,minlen:j,nestingEdge:!0})}),a.parent(p)||a.setEdge(c,m,{weight:0,minlen:d+h[p]})}function i(a){var c={};function u(l,d){var h=a.children(l);h&&h.length&&e.forEach(h,function(p){u(p,d+1)}),c[l]=d}return e.forEach(a.children(),function(l){u(l,1)}),c}function o(a){return e.reduce(a.edges(),function(c,u){return c+a.edge(u).weight},0)}function s(a){var c=a.graph();a.removeNode(c.nestingRoot),delete c.nestingRoot,e.forEach(a.edges(),function(u){var l=a.edge(u);l.nestingEdge&&a.removeEdge(u)})}return yu}var mu,ly;function bS(){if(ly)return mu;ly=1;var e=Je(),t=yr();mu=r;function r(i){function o(s){var a=i.children(s),c=i.node(s);if(a.length&&e.forEach(a,o),e.has(c,"minRank")){c.borderLeft=[],c.borderRight=[];for(var u=c.minRank,l=c.maxRank+1;u<l;++u)n(i,"borderLeft","_bl",s,c,u),n(i,"borderRight","_br",s,c,u)}}e.forEach(i.children(),o)}function n(i,o,s,a,c,u){var l={width:0,height:0,rank:u,borderType:o},d=c[o][u-1],h=t.addDummyNode(i,"border",l,s);c[o][u]=h,i.setParent(h,a),d&&i.setEdge(d,h,{weight:1})}return mu}var bu,dy;function vS(){if(dy)return bu;dy=1;var e=Je();bu={adjust:t,undo:r};function t(u){var l=u.graph().rankdir.toLowerCase();(l==="lr"||l==="rl")&&n(u)}function r(u){var l=u.graph().rankdir.toLowerCase();(l==="bt"||l==="rl")&&o(u),(l==="lr"||l==="rl")&&(a(u),n(u))}function n(u){e.forEach(u.nodes(),function(l){i(u.node(l))}),e.forEach(u.edges(),function(l){i(u.edge(l))})}function i(u){var l=u.width;u.width=u.height,u.height=l}function o(u){e.forEach(u.nodes(),function(l){s(u.node(l))}),e.forEach(u.edges(),function(l){var d=u.edge(l);e.forEach(d.points,s),e.has(d,"y")&&s(d)})}function s(u){u.y=-u.y}function a(u){e.forEach(u.nodes(),function(l){c(u.node(l))}),e.forEach(u.edges(),function(l){var d=u.edge(l);e.forEach(d.points,c),e.has(d,"x")&&c(d)})}function c(u){var l=u.x;u.x=u.y,u.y=l}return bu}var vu,fy;function xS(){if(fy)return vu;fy=1;var e=Je();vu=t;function t(r){var n={},i=e.filter(r.nodes(),function(u){return!r.children(u).length}),o=e.max(e.map(i,function(u){return r.node(u).rank})),s=e.map(e.range(o+1),function(){return[]});function a(u){if(!e.has(n,u)){n[u]=!0;var l=r.node(u);s[l.rank].push(u),e.forEach(r.successors(u),a)}}var c=e.sortBy(i,function(u){return r.node(u).rank});return e.forEach(c,a),s}return vu}var xu,hy;function wS(){if(hy)return xu;hy=1;var e=Je();xu=t;function t(n,i){for(var o=0,s=1;s<i.length;++s)o+=r(n,i[s-1],i[s]);return o}function r(n,i,o){for(var s=e.zipObject(o,e.map(o,function(h,p){return p})),a=e.flatten(e.map(i,function(h){return e.sortBy(e.map(n.outEdges(h),function(p){return{pos:s[p.w],weight:n.edge(p).weight}}),"pos")}),!0),c=1;c<o.length;)c<<=1;var u=2*c-1;c-=1;var l=e.map(new Array(u),function(){return 0}),d=0;return e.forEach(a.forEach(function(h){var p=h.pos+c;l[p]+=h.weight;for(var y=0;p>0;)p%2&&(y+=l[p+1]),p=p-1>>1,l[p]+=h.weight;d+=h.weight*y})),d}return xu}var wu,py;function CS(){if(py)return wu;py=1;var e=Je();wu=t;function t(r,n){return e.map(n,function(i){var o=r.inEdges(i);if(o.length){var s=e.reduce(o,function(a,c){var u=r.edge(c),l=r.node(c.v);return{sum:a.sum+u.weight*l.order,weight:a.weight+u.weight}},{sum:0,weight:0});return{v:i,barycenter:s.sum/s.weight,weight:s.weight}}else return{v:i}})}return wu}var Cu,gy;function SS(){if(gy)return Cu;gy=1;var e=Je();Cu=t;function t(i,o){var s={};e.forEach(i,function(c,u){var l=s[c.v]={indegree:0,in:[],out:[],vs:[c.v],i:u};e.isUndefined(c.barycenter)||(l.barycenter=c.barycenter,l.weight=c.weight)}),e.forEach(o.edges(),function(c){var u=s[c.v],l=s[c.w];!e.isUndefined(u)&&!e.isUndefined(l)&&(l.indegree++,u.out.push(s[c.w]))});var a=e.filter(s,function(c){return!c.indegree});return r(a)}function r(i){var o=[];function s(u){return function(l){l.merged||(e.isUndefined(l.barycenter)||e.isUndefined(u.barycenter)||l.barycenter>=u.barycenter)&&n(u,l)}}function a(u){return function(l){l.in.push(u),--l.indegree===0&&i.push(l)}}for(;i.length;){var c=i.pop();o.push(c),e.forEach(c.in.reverse(),s(c)),e.forEach(c.out,a(c))}return e.map(e.filter(o,function(u){return!u.merged}),function(u){return e.pick(u,["vs","i","barycenter","weight"])})}function n(i,o){var s=0,a=0;i.weight&&(s+=i.barycenter*i.weight,a+=i.weight),o.weight&&(s+=o.barycenter*o.weight,a+=o.weight),i.vs=o.vs.concat(i.vs),i.barycenter=s/a,i.weight=a,i.i=Math.min(o.i,i.i),o.merged=!0}return Cu}var Su,yy;function _S(){if(yy)return Su;yy=1;var e=Je(),t=yr();Su=r;function r(o,s){var a=t.partition(o,function(m){return e.has(m,"barycenter")}),c=a.lhs,u=e.sortBy(a.rhs,function(m){return-m.i}),l=[],d=0,h=0,p=0;c.sort(i(!!s)),p=n(l,u,p),e.forEach(c,function(m){p+=m.vs.length,l.push(m.vs),d+=m.barycenter*m.weight,h+=m.weight,p=n(l,u,p)});var y={vs:e.flatten(l,!0)};return h&&(y.barycenter=d/h,y.weight=h),y}function n(o,s,a){for(var c;s.length&&(c=e.last(s)).i<=a;)s.pop(),o.push(c.vs),a++;return a}function i(o){return function(s,a){return s.barycenter<a.barycenter?-1:s.barycenter>a.barycenter?1:o?a.i-s.i:s.i-a.i}}return Su}var _u,my;function ES(){if(my)return _u;my=1;var e=Je(),t=CS(),r=SS(),n=_S();_u=i;function i(a,c,u,l){var d=a.children(c),h=a.node(c),p=h?h.borderLeft:void 0,y=h?h.borderRight:void 0,m={};p&&(d=e.filter(d,function(C){return C!==p&&C!==y}));var g=t(a,d);e.forEach(g,function(C){if(a.children(C.v).length){var S=i(a,C.v,u,l);m[C.v]=S,e.has(S,"barycenter")&&s(C,S)}});var b=r(g,u);o(b,m);var x=n(b,l);if(p&&(x.vs=e.flatten([p,x.vs,y],!0),a.predecessors(p).length)){var v=a.node(a.predecessors(p)[0]),w=a.node(a.predecessors(y)[0]);e.has(x,"barycenter")||(x.barycenter=0,x.weight=0),x.barycenter=(x.barycenter*x.weight+v.order+w.order)/(x.weight+2),x.weight+=2}return x}function o(a,c){e.forEach(a,function(u){u.vs=e.flatten(u.vs.map(function(l){return c[l]?c[l].vs:l}),!0)})}function s(a,c){e.isUndefined(a.barycenter)?(a.barycenter=c.barycenter,a.weight=c.weight):(a.barycenter=(a.barycenter*a.weight+c.barycenter*c.weight)/(a.weight+c.weight),a.weight+=c.weight)}return _u}var Eu,by;function jS(){if(by)return Eu;by=1;var e=Je(),t=Ar().Graph;Eu=r;function r(i,o,s){var a=n(i),c=new t({compound:!0}).setGraph({root:a}).setDefaultNodeLabel(function(u){return i.node(u)});return e.forEach(i.nodes(),function(u){var l=i.node(u),d=i.parent(u);(l.rank===o||l.minRank<=o&&o<=l.maxRank)&&(c.setNode(u),c.setParent(u,d||a),e.forEach(i[s](u),function(h){var p=h.v===u?h.w:h.v,y=c.edge(p,u),m=e.isUndefined(y)?0:y.weight;c.setEdge(p,u,{weight:i.edge(h).weight+m})}),e.has(l,"minRank")&&c.setNode(u,{borderLeft:l.borderLeft[o],borderRight:l.borderRight[o]}))}),c}function n(i){for(var o;i.hasNode(o=e.uniqueId("_root")););return o}return Eu}var ju,vy;function kS(){if(vy)return ju;vy=1;var e=Je();ju=t;function t(r,n,i){var o={},s;e.forEach(i,function(a){for(var c=r.parent(a),u,l;c;){if(u=r.parent(c),u?(l=o[u],o[u]=c):(l=s,s=c),l&&l!==c){n.setEdge(l,c);return}c=u}})}return ju}var ku,xy;function RS(){if(xy)return ku;xy=1;var e=Je(),t=xS(),r=wS(),n=ES(),i=jS(),o=kS(),s=Ar().Graph,a=yr();ku=c;function c(h){var p=a.maxRank(h),y=u(h,e.range(1,p+1),"inEdges"),m=u(h,e.range(p-1,-1,-1),"outEdges"),g=t(h);d(h,g);for(var b=Number.POSITIVE_INFINITY,x,v=0,w=0;w<4;++v,++w){l(v%2?y:m,v%4>=2),g=a.buildLayerMatrix(h);var C=r(h,g);C<b&&(w=0,x=e.cloneDeep(g),b=C)}d(h,x)}function u(h,p,y){return e.map(p,function(m){return i(h,m,y)})}function l(h,p){var y=new s;e.forEach(h,function(m){var g=m.graph().root,b=n(m,g,y,p);e.forEach(b.vs,function(x,v){m.node(x).order=v}),o(m,y,b.vs)})}function d(h,p){e.forEach(p,function(y){e.forEach(y,function(m,g){h.node(m).order=g})})}return ku}var Ru,wy;function PS(){if(wy)return Ru;wy=1;var e=Je(),t=Ar().Graph,r=yr();Ru={positionX:y,findType1Conflicts:n,findType2Conflicts:i,addConflict:s,hasConflict:a,verticalAlignment:c,horizontalCompaction:u,alignCoordinates:h,findSmallestWidthAlignment:d,balance:p};function n(b,x){var v={};function w(C,S){var j=0,I=0,P=C.length,O=e.last(S);return e.forEach(S,function(T,E){var R=o(b,T),k=R?b.node(R).order:P;(R||T===O)&&(e.forEach(S.slice(I,E+1),function(M){e.forEach(b.predecessors(M),function($){var q=b.node($),W=q.order;(W<j||k<W)&&!(q.dummy&&b.node(M).dummy)&&s(v,$,M)})}),I=E+1,j=k)}),S}return e.reduce(x,w),v}function i(b,x){var v={};function w(S,j,I,P,O){var T;e.forEach(e.range(j,I),function(E){T=S[E],b.node(T).dummy&&e.forEach(b.predecessors(T),function(R){var k=b.node(R);k.dummy&&(k.order<P||k.order>O)&&s(v,R,T)})})}function C(S,j){var I=-1,P,O=0;return e.forEach(j,function(T,E){if(b.node(T).dummy==="border"){var R=b.predecessors(T);R.length&&(P=b.node(R[0]).order,w(j,O,E,I,P),O=E,I=P)}w(j,O,j.length,P,S.length)}),j}return e.reduce(x,C),v}function o(b,x){if(b.node(x).dummy)return e.find(b.predecessors(x),function(v){return b.node(v).dummy})}function s(b,x,v){if(x>v){var w=x;x=v,v=w}var C=b[x];C||(b[x]=C={}),C[v]=!0}function a(b,x,v){if(x>v){var w=x;x=v,v=w}return e.has(b[x],v)}function c(b,x,v,w){var C={},S={},j={};return e.forEach(x,function(I){e.forEach(I,function(P,O){C[P]=P,S[P]=P,j[P]=O})}),e.forEach(x,function(I){var P=-1;e.forEach(I,function(O){var T=w(O);if(T.length){T=e.sortBy(T,function($){return j[$]});for(var E=(T.length-1)/2,R=Math.floor(E),k=Math.ceil(E);R<=k;++R){var M=T[R];S[O]===O&&P<j[M]&&!a(v,O,M)&&(S[M]=O,S[O]=C[O]=C[M],P=j[M])}}})}),{root:C,align:S}}function u(b,x,v,w,C){var S={},j=l(b,x,v,C),I=C?"borderLeft":"borderRight";function P(E,R){for(var k=j.nodes(),M=k.pop(),$={};M;)$[M]?E(M):($[M]=!0,k.push(M),k=k.concat(R(M))),M=k.pop()}function O(E){S[E]=j.inEdges(E).reduce(function(R,k){return Math.max(R,S[k.v]+j.edge(k))},0)}function T(E){var R=j.outEdges(E).reduce(function(M,$){return Math.min(M,S[$.w]-j.edge($))},Number.POSITIVE_INFINITY),k=b.node(E);R!==Number.POSITIVE_INFINITY&&k.borderType!==I&&(S[E]=Math.max(S[E],R))}return P(O,j.predecessors.bind(j)),P(T,j.successors.bind(j)),e.forEach(w,function(E){S[E]=S[v[E]]}),S}function l(b,x,v,w){var C=new t,S=b.graph(),j=m(S.nodesep,S.edgesep,w);return e.forEach(x,function(I){var P;e.forEach(I,function(O){var T=v[O];if(C.setNode(T),P){var E=v[P],R=C.edge(E,T);C.setEdge(E,T,Math.max(j(b,O,P),R||0))}P=O})}),C}function d(b,x){return e.minBy(e.values(x),function(v){var w=Number.NEGATIVE_INFINITY,C=Number.POSITIVE_INFINITY;return e.forIn(v,function(S,j){var I=g(b,j)/2;w=Math.max(S+I,w),C=Math.min(S-I,C)}),w-C})}function h(b,x){var v=e.values(x),w=e.min(v),C=e.max(v);e.forEach(["u","d"],function(S){e.forEach(["l","r"],function(j){var I=S+j,P=b[I],O;if(P!==x){var T=e.values(P);O=j==="l"?w-e.min(T):C-e.max(T),O&&(b[I]=e.mapValues(P,function(E){return E+O}))}})})}function p(b,x){return e.mapValues(b.ul,function(v,w){if(x)return b[x.toLowerCase()][w];var C=e.sortBy(e.map(b,w));return(C[1]+C[2])/2})}function y(b){var x=r.buildLayerMatrix(b),v=e.merge(n(b,x),i(b,x)),w={},C;e.forEach(["u","d"],function(j){C=j==="u"?x:e.values(x).reverse(),e.forEach(["l","r"],function(I){I==="r"&&(C=e.map(C,function(E){return e.values(E).reverse()}));var P=(j==="u"?b.predecessors:b.successors).bind(b),O=c(b,C,v,P),T=u(b,C,O.root,O.align,I==="r");I==="r"&&(T=e.mapValues(T,function(E){return-E})),w[j+I]=T})});var S=d(b,w);return h(w,S),p(w,b.graph().align)}function m(b,x,v){return function(w,C,S){var j=w.node(C),I=w.node(S),P=0,O;if(P+=j.width/2,e.has(j,"labelpos"))switch(j.labelpos.toLowerCase()){case"l":O=-j.width/2;break;case"r":O=j.width/2;break}if(O&&(P+=v?O:-O),O=0,P+=(j.dummy?x:b)/2,P+=(I.dummy?x:b)/2,P+=I.width/2,e.has(I,"labelpos"))switch(I.labelpos.toLowerCase()){case"l":O=I.width/2;break;case"r":O=-I.width/2;break}return O&&(P+=v?O:-O),O=0,P}}function g(b,x){return b.node(x).width}return Ru}var Pu,Cy;function AS(){if(Cy)return Pu;Cy=1;var e=Je(),t=yr(),r=PS().positionX;Pu=n;function n(o){o=t.asNonCompoundGraph(o),i(o),e.forEach(r(o),function(s,a){o.node(a).x=s})}function i(o){var s=t.buildLayerMatrix(o),a=o.graph().ranksep,c=0;e.forEach(s,function(u){var l=e.max(e.map(u,function(d){return o.node(d).height}));e.forEach(u,function(d){o.node(d).y=c+l/2}),c+=l+a})}return Pu}var Au,Sy;function TS(){if(Sy)return Au;Sy=1;var e=Je(),t=fS(),r=hS(),n=gS(),i=yr().normalizeRanks,o=yS(),s=yr().removeEmptyRanks,a=mS(),c=bS(),u=vS(),l=RS(),d=AS(),h=yr(),p=Ar().Graph;Au=y;function y(L,V){var G=V&&V.debugTiming?h.time:h.notime;G("layout",function(){var N=G(" buildLayoutGraph",function(){return P(L)});G(" runLayout",function(){m(N,G)}),G(" updateInputGraph",function(){g(L,N)})})}function m(L,V){V(" makeSpaceForEdgeLabels",function(){O(L)}),V(" removeSelfEdges",function(){ie(L)}),V(" acyclic",function(){t.run(L)}),V(" nestingGraph.run",function(){a.run(L)}),V(" rank",function(){n(h.asNonCompoundGraph(L))}),V(" injectEdgeLabelProxies",function(){T(L)}),V(" removeEmptyRanks",function(){s(L)}),V(" nestingGraph.cleanup",function(){a.cleanup(L)}),V(" normalizeRanks",function(){i(L)}),V(" assignRankMinMax",function(){E(L)}),V(" removeEdgeLabelProxies",function(){R(L)}),V(" normalize.run",function(){r.run(L)}),V(" parentDummyChains",function(){o(L)}),V(" addBorderSegments",function(){c(L)}),V(" order",function(){l(L)}),V(" insertSelfEdges",function(){ee(L)}),V(" adjustCoordinateSystem",function(){u.adjust(L)}),V(" position",function(){d(L)}),V(" positionSelfEdges",function(){Y(L)}),V(" removeBorderNodes",function(){W(L)}),V(" normalize.undo",function(){r.undo(L)}),V(" fixupEdgeLabelCoords",function(){$(L)}),V(" undoCoordinateSystem",function(){u.undo(L)}),V(" translateGraph",function(){k(L)}),V(" assignNodeIntersects",function(){M(L)}),V(" reversePoints",function(){q(L)}),V(" acyclic.undo",function(){t.undo(L)})}function g(L,V){e.forEach(L.nodes(),function(G){var N=L.node(G),ae=V.node(G);N&&(N.x=ae.x,N.y=ae.y,V.children(G).length&&(N.width=ae.width,N.height=ae.height))}),e.forEach(L.edges(),function(G){var N=L.edge(G),ae=V.edge(G);N.points=ae.points,e.has(ae,"x")&&(N.x=ae.x,N.y=ae.y)}),L.graph().width=V.graph().width,L.graph().height=V.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],x={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},v=["acyclicer","ranker","rankdir","align"],w=["width","height"],C={width:0,height:0},S=["minlen","weight","width","height","labeloffset"],j={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},I=["labelpos"];function P(L){var V=new p({multigraph:!0,compound:!0}),G=ce(L.graph());return V.setGraph(e.merge({},x,fe(G,b),e.pick(G,v))),e.forEach(L.nodes(),function(N){var ae=ce(L.node(N));V.setNode(N,e.defaults(fe(ae,w),C)),V.setParent(N,L.parent(N))}),e.forEach(L.edges(),function(N){var ae=ce(L.edge(N));V.setEdge(N,e.merge({},j,fe(ae,S),e.pick(ae,I)))}),V}function O(L){var V=L.graph();V.ranksep/=2,e.forEach(L.edges(),function(G){var N=L.edge(G);N.minlen*=2,N.labelpos.toLowerCase()!=="c"&&(V.rankdir==="TB"||V.rankdir==="BT"?N.width+=N.labeloffset:N.height+=N.labeloffset)})}function T(L){e.forEach(L.edges(),function(V){var G=L.edge(V);if(G.width&&G.height){var N=L.node(V.v),ae=L.node(V.w),ge={rank:(ae.rank-N.rank)/2+N.rank,e:V};h.addDummyNode(L,"edge-proxy",ge,"_ep")}})}function E(L){var V=0;e.forEach(L.nodes(),function(G){var N=L.node(G);N.borderTop&&(N.minRank=L.node(N.borderTop).rank,N.maxRank=L.node(N.borderBottom).rank,V=e.max(V,N.maxRank))}),L.graph().maxRank=V}function R(L){e.forEach(L.nodes(),function(V){var G=L.node(V);G.dummy==="edge-proxy"&&(L.edge(G.e).labelRank=G.rank,L.removeNode(V))})}function k(L){var V=Number.POSITIVE_INFINITY,G=0,N=Number.POSITIVE_INFINITY,ae=0,ge=L.graph(),ve=ge.marginx||0,K=ge.marginy||0;function te(U){var se=U.x,ue=U.y,we=U.width,pe=U.height;V=Math.min(V,se-we/2),G=Math.max(G,se+we/2),N=Math.min(N,ue-pe/2),ae=Math.max(ae,ue+pe/2)}e.forEach(L.nodes(),function(U){te(L.node(U))}),e.forEach(L.edges(),function(U){var se=L.edge(U);e.has(se,"x")&&te(se)}),V-=ve,N-=K,e.forEach(L.nodes(),function(U){var se=L.node(U);se.x-=V,se.y-=N}),e.forEach(L.edges(),function(U){var se=L.edge(U);e.forEach(se.points,function(ue){ue.x-=V,ue.y-=N}),e.has(se,"x")&&(se.x-=V),e.has(se,"y")&&(se.y-=N)}),ge.width=G-V+ve,ge.height=ae-N+K}function M(L){e.forEach(L.edges(),function(V){var G=L.edge(V),N=L.node(V.v),ae=L.node(V.w),ge,ve;G.points?(ge=G.points[0],ve=G.points[G.points.length-1]):(G.points=[],ge=ae,ve=N),G.points.unshift(h.intersectRect(N,ge)),G.points.push(h.intersectRect(ae,ve))})}function $(L){e.forEach(L.edges(),function(V){var G=L.edge(V);if(e.has(G,"x"))switch((G.labelpos==="l"||G.labelpos==="r")&&(G.width-=G.labeloffset),G.labelpos){case"l":G.x-=G.width/2+G.labeloffset;break;case"r":G.x+=G.width/2+G.labeloffset;break}})}function q(L){e.forEach(L.edges(),function(V){var G=L.edge(V);G.reversed&&G.points.reverse()})}function W(L){e.forEach(L.nodes(),function(V){if(L.children(V).length){var G=L.node(V),N=L.node(G.borderTop),ae=L.node(G.borderBottom),ge=L.node(e.last(G.borderLeft)),ve=L.node(e.last(G.borderRight));G.width=Math.abs(ve.x-ge.x),G.height=Math.abs(ae.y-N.y),G.x=ge.x+G.width/2,G.y=N.y+G.height/2}}),e.forEach(L.nodes(),function(V){L.node(V).dummy==="border"&&L.removeNode(V)})}function ie(L){e.forEach(L.edges(),function(V){if(V.v===V.w){var G=L.node(V.v);G.selfEdges||(G.selfEdges=[]),G.selfEdges.push({e:V,label:L.edge(V)}),L.removeEdge(V)}})}function ee(L){var V=h.buildLayerMatrix(L);e.forEach(V,function(G){var N=0;e.forEach(G,function(ae,ge){var ve=L.node(ae);ve.order=ge+N,e.forEach(ve.selfEdges,function(K){h.addDummyNode(L,"selfedge",{width:K.label.width,height:K.label.height,rank:ve.rank,order:ge+ ++N,e:K.e,label:K.label},"_se")}),delete ve.selfEdges})})}function Y(L){e.forEach(L.nodes(),function(V){var G=L.node(V);if(G.dummy==="selfedge"){var N=L.node(G.e.v),ae=N.x+N.width/2,ge=N.y,ve=G.x-ae,K=N.height/2;L.setEdge(G.e,G.label),L.removeNode(V),G.label.points=[{x:ae+2*ve/3,y:ge-K},{x:ae+5*ve/6,y:ge-K},{x:ae+ve,y:ge},{x:ae+5*ve/6,y:ge+K},{x:ae+2*ve/3,y:ge+K}],G.label.x=G.x,G.label.y=G.y}})}function fe(L,V){return e.mapValues(e.pick(L,V),Number)}function ce(L){var V={};return e.forEach(L,function(G,N){V[N.toLowerCase()]=G}),V}return Au}var Tu,_y;function IS(){if(_y)return Tu;_y=1;var e=Je(),t=yr(),r=Ar().Graph;Tu={debugOrdering:n};function n(i){var o=t.buildLayerMatrix(i),s=new r({compound:!0,multigraph:!0}).setGraph({});return e.forEach(i.nodes(),function(a){s.setNode(a,{label:a}),s.setParent(a,"layer"+i.node(a).rank)}),e.forEach(i.edges(),function(a){s.setEdge(a.v,a.w,{},a.name)}),e.forEach(o,function(a,c){var u="layer"+c;s.setNode(u,{rank:"same"}),e.reduce(a,function(l,d){return s.setEdge(l,d,{style:"invis"}),d})}),s}return Tu}var Iu,Ey;function OS(){return Ey||(Ey=1,Iu="0.8.5"),Iu}var Ou,jy;function MS(){return jy||(jy=1,Ou={graphlib:Ar(),layout:TS(),debug:IS(),util:{time:yr().time,notime:yr().notime},version:OS()}),Ou}var qS=MS();const ky=vw(qS);function $S(e,t,r){var l;const n=new Set(e.map(d=>d.id)),i=new Set;for(const d of e)d.parent&&n.has(d.parent)&&i.add(d.parent);const o=new ky.graphlib.Graph({multigraph:!0,compound:!0}),s=r.compactSpacingScale??(r.spacingFactor>0?r.spacingFactor/1.3:1);o.setGraph({rankdir:r.rankDir,nodesep:r.compact?Math.max(r.nodeSep,24*s):r.nodeSep,edgesep:r.compact?Math.min(r.edgeSep,24*s):r.edgeSep,ranksep:r.compact?Math.min(r.rankSep,80*s):r.rankSep,ranker:"network-simplex"}),o.setDefaultEdgeLabel(()=>({})),o.setDefaultNodeLabel(()=>({}));for(const d of e)o.setNode(d.id,{width:d.width+2,height:d.height+2});for(const d of e)d.parent&&n.has(d.parent)&&o.setParent(d.id,d.parent);for(const d of t){if(!n.has(d.source)||!n.has(d.target)||i.has(d.source)||i.has(d.target))continue;const h=Xm(d.label,d.icon??((l=d.data)==null?void 0:l.icon),r.edgeLabelFontSize),p=r.rankDir==="LR"||r.rankDir==="RL",y=(h.width?h.width+2*Ym:0)+(d.connectorClearance??0);o.setEdge(d.source,d.target,{minlen:1,weight:1,...y?{width:p?y:Math.max(1,h.height),height:p?Math.max(1,h.height):y,labelpos:"c"}:{}},d.id)}ky.layout(o);const a=new Map;for(const d of e){if(i.has(d.id))continue;const h=o.node(d.id);h&&Number.isFinite(h.x)&&Number.isFinite(h.y)&&a.set(d.id,{x:h.x,y:h.y})}const c=r.compact?1:r.spacingFactor;if(c&&c!==1&&a.size){let d=1/0,h=1/0,p=-1/0,y=-1/0;a.forEach(b=>{d=Math.min(d,b.x),h=Math.min(h,b.y),p=Math.max(p,b.x),y=Math.max(y,b.y)});const m=(d+p)/2,g=(h+y)/2;a.forEach((b,x)=>a.set(x,{x:m+(b.x-m)*c,y:g+(b.y-g)*c}))}const u=r.nodeAlignment??"center";if(u!=="center"){const d=r.rankDir==="LR"||r.rankDir==="RL",h=d?"x":"y",p=d?"width":"height",y=r.rankDir==="RL"||r.rankDir==="BT"?-1:1,m=u==="leading"?-y:y,g=new Map;for(const b of e){const x=a.get(b.id);if(!x)continue;const v=x[h];g.set(v,Math.max(g.get(v)??0,b[p]))}for(const b of e){const x=a.get(b.id);if(!x)continue;const v=x[h],w=(g.get(v)-b[p])/2;a.set(b.id,{...x,[h]:v+m*w})}}return a}function Ry(e,t,r,n,i){const o=new Map,s=new Map(e.map(l=>[l.id,l]));for(const l of e){if(!l.parent||!s.has(l.parent))continue;const d=o.get(l.parent);d?d.push(l.id):o.set(l.parent,[l.id])}const a=(l,d=new Set)=>{var p;const h=(p=s.get(l))==null?void 0:p.parent;return!h||!s.has(h)||d.has(l)?0:(d.add(l),1+a(h,d))},c=[...o.keys()].sort((l,d)=>a(d)-a(l)),u=new Map;for(const l of c){let d=null;for(const y of o.get(l)||[]){let m=u.get(y);if(!m){const g=t.get(y);if(!g)continue;const b=r.get(y)||{w:60,h:60};m={x1:g.x-b.w/2,y1:g.y-b.h/2,x2:g.x+b.w/2,y2:g.y+b.h/2}}d=d?{x1:Math.min(d.x1,m.x1),y1:Math.min(d.y1,m.y1),x2:Math.max(d.x2,m.x2),y2:Math.max(d.y2,m.y2)}:{...m}}if(!d)continue;const h=n(l);d={x1:d.x1-h,y1:d.y1-h,x2:d.x2+h,y2:d.y2+h};const p=i(l);if(p){const y=d.x2-d.x1,m=d.y2-d.y1;if(p.w>y){const g=(p.w-y)/2;d.x1-=g,d.x2+=g}if(p.h>m){const g=(p.h-m)/2;d.y1-=g,d.y2+=g}}u.set(l,d)}return u}function NS(e){const t=e.getBoundingClientRect(),r=t.height/e.offsetHeight;if(!Number.isFinite(r)||r<=0)return[];const n=Jm(e),i={x:e.offsetWidth/2,y:e.offsetHeight/2,w:e.offsetWidth,h:e.offsetHeight},o=[...e.querySelectorAll("[data-flow-property]")],s=new Set(o.filter(a=>a.hasAttribute("data-flow-inspection-row")&&a.getBoundingClientRect().height>0).map(a=>a.dataset.flowProperty));return o.flatMap(a=>{if(a.closest(".flow-sdk-node")!==e)return[];if(s.has(a.dataset.flowProperty)&&!a.hasAttribute("data-flow-inspection-row"))return[];const c=a.dataset.flowPortSide;if(c&&["top","right","bottom","left"].includes(c)){const l=Um(n?en(i,n):i,c,Number(a.dataset.flowPortPosition??.5));return[{property:a.getAttribute("data-flow-property"),top:l.y,height:0,anchor:l,...a.dataset.flowPortPlacement==="config"?{placement:"config"}:{},...a.dataset.flowPortRole==="source"||a.dataset.flowPortRole==="target"?{role:a.dataset.flowPortRole}:{}}]}const u=a.getBoundingClientRect();return!u.width||!u.height?[]:[{property:a.getAttribute("data-flow-property"),top:Math.round((u.top-t.top)/r*1e3)/1e3,height:Math.round(u.height/r*1e3)/1e3,...a.dataset.flowPortRole==="source"||a.dataset.flowPortRole==="target"?{role:a.dataset.flowPortRole}:{}}]})}function LS({id:e,x:t,y:r,placed:n,hidden:i,onMount:o,drawHandles:s,drawMode:a,connectedPorts:c,resolvedRows:u,hasCollapseControl:l,handleColor:d,animated:h,animationColor:p,animationWidth:y=8,animationVariant:m,width:g=0,height:b=0,propertyMode:x,reversePorts:v,direction:w="LR",onPropertyRows:C,onSurface:S,children:j}){const I=_.useRef(null),[P,O]=_.useState([]),T=u??P,[E,R]=_.useState();return _.useLayoutEffect(()=>{const k=I.current;if(!k)return;const M=()=>{const W=Jm(k);R(ie=>JSON.stringify(ie)===JSON.stringify(W)?ie:W),S==null||S(e,W)};M();const $=new ResizeObserver(M);$.observe(k);const q=k.querySelector("[data-flow-node-surface]");return q&&$.observe(q),()=>$.disconnect()},[e,j,S]),_.useLayoutEffect(()=>(o(e,I.current),()=>{o(e,null),S==null||S(e,void 0)}),[e,o,S]),_.useLayoutEffect(()=>{const k=I.current;if(!k)return;let M="";const $=()=>{const ee=NS(k),Y=x?ee:ee.filter(ce=>ce.anchor),fe=JSON.stringify(Y);fe!==M&&(M=fe,O(Y),C==null||C(e,Y))};if($(),!x&&!k.querySelector("[data-flow-port-side]"))return;const q=new ResizeObserver($),W=()=>{q.disconnect(),q.observe(k),k.querySelectorAll("[data-flow-property]").forEach(ee=>q.observe(ee)),$()};W();const ie=new MutationObserver(W);return ie.observe(k,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["data-flow-property","data-flow-port-role","data-flow-port-side","data-flow-port-position","data-flow-port-placement"]}),k.addEventListener("scroll",$,!0),()=>{q.disconnect(),ie.disconnect(),k.removeEventListener("scroll",$,!0)}},[e,x,C,j]),f.jsxs("div",{ref:I,className:"flow-sdk-node","data-node-id":e,style:{transform:`translate(-50%, -50%) translate3d(${t.toFixed(2)}px, ${r.toFixed(2)}px, 0)`,visibility:n&&!i?void 0:"hidden"},children:[j,h&&y>0&&g>0&&b>0&&f.jsx("svg",{className:"flow-sdk-node-animation","aria-hidden":"true",pointerEvents:"none",children:f.jsx(Gm,{variant:m,x:((E==null?void 0:E.left)??0)+y/2,y:((E==null?void 0:E.top)??0)+y/2,width:((E==null?void 0:E.width)??g)-y,height:((E==null?void 0:E.height)??b)-y,radius:((E==null?void 0:E.radius)??0)-y/2,path:E!=null&&E.outline?`M${E.outline.map(k=>`${k.x} ${k.y}`).join(" L")} Z`:void 0,color:p||d||"currentColor",strokeWidth:y})}),s&&x&&T.map(k=>["source","target"].filter(M=>!k.role||k.role===M).filter(M=>a||(c==null?void 0:c.has(`${M}:${k.property}`))).map(M=>{var $;return f.jsx("button",{type:"button",className:"flow-sdk-property-port","data-property":k.property,"data-port-role":M,"data-port-side":($=k.anchor)==null?void 0:$.side,"aria-label":`${M==="source"?"Connect":"Input"} ${k.property}`,title:`${M==="source"?"Connect":"Input"} ${k.property}`,style:{color:d,...k.anchor?{top:k.anchor.y,left:k.anchor.x-16}:{top:k.top+k.height/2,[M==="source"!=!!v?"right":"left"]:-16}},onClick:q=>q.stopPropagation()},`${k.property}:${M}`)})),s&&!l&&(!x||!T.length)&&(!x||!T.some(k=>k.anchor))&&f.jsx("button",{type:"button",className:"flow-sdk-handle","aria-label":"Draw edge",title:"Draw edge",style:{color:d,left:((E==null?void 0:E.left)??0)+(w==="RL"?-36:w==="LR"?(E==null?void 0:E.width)??g:((E==null?void 0:E.width)??g)/2),top:((E==null?void 0:E.top)??0)+(w==="BT"?-36:w==="TB"?(E==null?void 0:E.height)??b:((E==null?void 0:E.height)??b)/2),transform:w==="BT"||w==="TB"?"translateX(-50%)":"translateY(-50%)"},onClick:k=>k.stopPropagation(),children:f.jsx(J.PiPlusBold,{size:24})})]})}const FS=_.memo(LS);function BS(e,t,r){const[n,i]=_.useState(()=>({nodes:new Set,edges:new Set})),o=_.useMemo(()=>{const a=new Set(e.map(p=>p.id)),c=t.filter(p=>a.has(p.source)&&a.has(p.target)).map(p=>({id:p.id,source:p.inverted?p.target:p.source,target:p.inverted?p.source:p.target})),u=new Set(c.map(p=>p.id)),l=new Set([...n.nodes].filter(p=>a.has(p))),d=new Set([...n.edges].filter(p=>u.has(p)));if(!r)return{nodes:a,edges:u,ready:u};for(const p of e)c.filter(m=>m.target===p.id&&m.source!==m.target).every(m=>d.has(m.id))&&l.add(p.id);let h=new Set(c.filter(p=>l.has(p.source)).map(p=>p.id));if(l.size<a.size&&!c.some(p=>h.has(p.id)&&!d.has(p.id))){const p=e.find(y=>!l.has(y.id));p&&l.add(p.id),h=new Set(c.filter(y=>l.has(y.source)).map(y=>y.id))}return{nodes:l,edges:d,ready:h}},[e,t,r,n]);_.useLayoutEffect(()=>{i(a=>{const c=r?o:{nodes:new Set,edges:new Set},u=(l,d)=>l.size===d.size&&[...l].every(h=>d.has(h));return u(a.nodes,c.nodes)&&u(a.edges,c.edges)?a:{nodes:c.nodes,edges:c.edges}})},[o,r]);const s=_.useCallback(a=>{i(c=>c.edges.has(a)?c:{...c,edges:new Set([...c.edges,a])})},[]);return{shown:o.nodes,ready:o.ready,complete:s}}function ev(e,t=!1){return e&&!t&&typeof requestAnimationFrame<"u"&&!(typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches)}function rv(e,t,r=()=>{},n=300){let i,o,s=!1;const a=()=>{s=!0,i!==void 0&&cancelAnimationFrame(i),clearTimeout(o)},c=()=>{s||(a(),t(1),r())};if(!ev(e))return c(),a;const u=performance.now(),l=d=>{if(s)return;const h=Math.max(0,Math.min(1,(d-u)/n));if(h>=1)return c();t(h<.5?4*h**3:1-(-2*h+2)**3/2),s||(i=requestAnimationFrame(l))};return i=requestAnimationFrame(l),o=setTimeout(c,n+100),a}class zS{constructor(t,r,n){xr(this,"_pan");xr(this,"_zoom");xr(this,"minZoom");xr(this,"maxZoom");xr(this,"size",{w:0,h:0});xr(this,"listeners",new Set);xr(this,"cancelTransition");xr(this,"animationVersion",0);xr(this,"captureTransition");xr(this,"animationsDisabled",!1);xr(this,"finishTransition");this.minZoom=r,this.maxZoom=n,this._pan={...t.pan},this._zoom=this.clamp(t.zoom)}setAnimationsDisabled(t){var r;t!==this.animationsDisabled&&(this.animationsDisabled=t,t&&((r=this.finishTransition)==null||r.call(this),this.cancelAnimation()))}cancelAnimation(){var t;(t=this.cancelTransition)==null||t.call(this),this.cancelTransition=void 0,this.finishTransition=void 0,this.animationVersion++}coordinate(t){let r;this.captureTransition=n=>{r=n};try{t()}finally{this.captureTransition=void 0}return r}transition(t,r=!1){this.cancelAnimation();const n=this.state,i={pan:{...t.pan},zoom:this.clamp(t.zoom)},o=this.animationVersion,s=ev(r,this.animationsDisabled),a=c=>{if(o!==this.animationVersion)return;const u=s?c:1;this.apply({x:n.pan.x+(i.pan.x-n.pan.x)*u,y:n.pan.y+(i.pan.y-n.pan.y)*u},n.zoom+(i.zoom-n.zoom)*u)};this.finishTransition=()=>a(1),this.captureTransition?this.captureTransition(a):this.cancelTransition=rv(s,a,void 0,300/1.4)}get pan(){return{...this._pan}}get zoom(){return this._zoom}get state(){return{pan:this.pan,zoom:this._zoom}}clamp(t){return Number.isFinite(t)?Math.max(this.minZoom,Math.min(this.maxZoom,t)):this.minZoom}set(t,r){this.cancelAnimation(),this.apply(t,r)}apply(t,r){let n=!1;if(t&&(t.x!==this._pan.x||t.y!==this._pan.y)&&(this._pan={x:t.x,y:t.y},n=!0),r!==void 0){const i=this.clamp(r);i!==this._zoom&&(this._zoom=i,n=!0)}n&&this.emit()}zoomAt(t,r){const n=this.clamp(t),i=this._zoom;if(n===i)return;const o=n/i;this.set({x:r.x-(r.x-this._pan.x)*o,y:r.y-(r.y-this._pan.y)*o},n)}fit(t,r=0,n=!1,i=1){const o=t.x2-t.x1,s=t.y2-t.y1;if(!(o>0)||!(s>0)||!this.size.w||!this.size.h)return;const a=this.clamp(this.clamp(Math.min((this.size.w-2*r)/o,(this.size.h-2*r)/s))*i);this.transition({pan:{x:(this.size.w-a*(t.x1+t.x2))/2,y:(this.size.h-a*(t.y1+t.y2))/2},zoom:a},n)}center(t,r=!1){if(!this.size.w||!this.size.h)return;const n=this._zoom;this.transition({pan:{x:(this.size.w-n*(t.x1+t.x2))/2,y:(this.size.h-n*(t.y1+t.y2))/2},zoom:n},r)}renderedToModel(t){return{x:(t.x-this._pan.x)/this._zoom,y:(t.y-this._pan.y)/this._zoom}}modelToRendered(t){return{x:t.x*this._zoom+this._pan.x,y:t.y*this._zoom+this._pan.y}}onChange(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}emit(){const t=this.state;this.listeners.forEach(r=>r(t))}}const DS={LR:"rightward",RL:"leftward",TB:"downward",BT:"upward"},Sn={w:60,h:60},Py=4,VS=30,WS=500,Ay=45;function Ty(e){const[t,r]=[...e.values()];return!t||!r?null:{center:{x:(t.x+r.x)/2,y:(t.y+r.y)/2},distance:Math.max(1,Math.hypot(r.x-t.x,r.y-t.y))}}function GS(e){var kl;const{nodes:t,edges:r,direction:n,nodeAlignment:i="center",edgeMode:o="auto",compactPropertyLayout:s=!1,rankSep:a,edgeSep:c,spacingFactor:u=1.3,compactSpacingScale:l,minZoom:d,maxZoom:h,initialViewport:p,containerStyle:y,lineColor:m,drawMode:g,dragMode:b,multiSelect:x,isPerformanceMode:v,disableAnimations:w=!1}=e,[C,S]=_.useState(null),j=_.useMemo(()=>C?(C.mode==="connections"?td:Zl)(C.id,t,r):null,[C,t,r]),I=o==="auto"||o==="properties",P=_.useMemo(()=>r.filter(A=>Bu(A,o)&&(!j||j.has(A.source)&&j.has(A.target))),[r,o,j]),O=_.useMemo(()=>hw(t,r,o,s,j),[t,r,o,s,j]),T=_.useRef(O);T.current=O;const E=_.useRef(e);E.current=e;const R=_.useRef(null),k=_.useRef(null),M=_.useRef(null),$=_.useRef(null),q=_.useMemo(()=>new zS(p,d,h),[]);_.useEffect(()=>{q.minZoom=d,q.maxZoom=h},[q,d,h]),_.useLayoutEffect(()=>{q.setAnimationsDisabled(w)},[q,w]);const W=_.useRef(new Map),ie=_.useRef(new Map),ee=_.useRef(new Map),Y=_.useRef(null),[fe,ce]=_.useState(new Map),L=_.useCallback((A,F)=>{ce(D=>{if(JSON.stringify(D.get(A))===JSON.stringify(F))return D;const H=new Map(D);return F?H.set(A,F):H.delete(A),H})},[]),[V,G]=_.useState(new Map),N=_.useRef(V),ae=_.useCallback((A,F)=>{G(D=>{if(JSON.stringify(D.get(A)??[])===JSON.stringify(F))return D;const H=new Map(D);return F.length?H.set(A,F):H.delete(A),H})},[]),[ge,ve]=_.useState(()=>new Map),K=_.useRef(ge);K.current=ge;const te=_.useRef(new Map),U=_.useRef(null),se=_.useRef(!1),[ue,we]=_.useState(0),pe=_.useRef(),qe=_.useRef(),Q=_.useRef(null),he=_.useRef(!1),me=_.useRef(null),Re=_.useRef(null),$e=_.useRef(u),Ge=s,Ye=_.useRef(Ge),[tr,sr]=_.useState(!0),Ae=_.useRef(null);Ae.current=j;const ye=_.useRef(1);ye.current=(C==null?void 0:C.mode)==="connections"?1.25:1;const Me=_.useRef(null),nr=_.useRef(t),cr=_.useRef([]),Xe=_.useRef(!1),xe=()=>{var A;(A=Q.current)==null||A.call(Q),Q.current=null},gt=()=>{Re.current=null,cr.current.length&&(Xe.current=!0),!se.current&&E.current.fitOnInit!==!1&&(he.current=!0),clearTimeout(qe.current),qe.current=setTimeout(()=>{se.current=K.current.size>0,we(A=>A+1)},WS)},zr=(A,F,D)=>{xe();const H=new Map(K.current);Q.current=rv(F,ne=>{const Ce=new Map;A.forEach((Le,ze)=>{const Ee=H.get(ze);Ce.set(ze,Ee?{x:Ee.x+(Le.x-Ee.x)*ne,y:Ee.y+(Le.y-Ee.y)*ne}:Le)}),K.current=Ce,ve(Ce),D==null||D(ne)},gt)},rt=()=>{clearTimeout(pe.current);const A=E.current,F=ye.current,D=T.current,H=D.nodes.map(Ee=>{const X=ie.current.get(Ee.id);X&&(X.offsetWidth||X.offsetHeight)&&W.current.set(Ee.id,{w:X.offsetWidth,h:X.offsetHeight});const le=W.current.get(Ee.id)||Sn;return{id:Ee.id,parent:Ee.parent,width:le.w,height:le.h}});let ne;try{const Ee=A.compactPropertyLayout,X=A.edgeMode!=="nodes"&&A.edgeMode!=="workflow",le=D.edges.map(de=>({...de,connectorClearance:Ee?X&&(de.sourceProperty!==void 0||de.targetProperty!==void 0)?fw:dw:0}));ne=$S(H,le,{edgeLabelFontSize:A.edgeMode==="nodes"||A.edgeMode==="workflow"?Zm:An,rankDir:A.direction,compact:Ee,nodeAlignment:A.nodeAlignment,rankSep:A.rankSep*F,edgeSep:A.edgeSep*F,nodeSep:5*F,spacingFactor:A.spacingFactor??1.3,compactSpacingScale:(A.compactSpacingScale??(A.spacingFactor??1.3)/1.3)*F})}catch(Ee){console.warn("[flow-sdk] layout failed",Ee);return}const Ce=U.current;U.current=null;const Le=Ce&&ne.get(Ce.id);if(Ce&&Le){const Ee={x:Ce.position.x-Le.x,y:Ce.position.y-Le.y};ne=new Map([...ne].map(([X,le])=>[X,{x:le.x+Ee.x,y:le.y+Ee.y}]))}for(const[Ee,X]of te.current)ne.has(Ee)?ne.set(Ee,X):A.nodes.some(le=>le.id===Ee)||te.current.delete(Ee);const ze=q.coordinate(()=>{var Ee;return(Ee=Re.current)==null?void 0:Ee.call(Re,ne)});zr(ne,se.current&&!A.isPerformanceMode&&!A.disableAnimations,ze)},oe=_.useCallback(()=>{clearTimeout(qe.current),clearTimeout(pe.current),pe.current=setTimeout(rt,E.current.layoutDebounce)},[]);_.useLayoutEffect(()=>{const A=new Map(nr.current.map(F=>[F.id,F]));t.some(F=>{var D;return((D=A.get(F.id))==null?void 0:D.collapsed)===!0&&!F.collapsed})&&(cr.current=t.filter(F=>!A.has(F.id)).map(F=>F.id)),nr.current=t,$e.current!==u&&K.current.size>0&&(se.current=!0,he.current=!1,clearTimeout(qe.current)),$e.current=u,Ye.current!==Ge&&(he.current=!me.current),Ye.current=Ge,Re.current&&!me.current?(clearTimeout(pe.current),rt()):oe()},[t,r,O.nodes,O.edges,Ge,n,i,a,c,oe,u,l,w]),_.useEffect(()=>()=>{clearTimeout(pe.current),clearTimeout(qe.current),xe()},[]);const We=_.useCallback((A,F)=>{var D,H;if(!Y.current&&typeof ResizeObserver<"u"&&(Y.current=new ResizeObserver(ne=>{let Ce=!1;for(const Le of ne){const ze=ee.current.get(Le.target);if(!ze)continue;const Ee=Le.target,X=Ee.offsetWidth,le=Ee.offsetHeight;if(!X&&!le)continue;const de=W.current.get(ze);if(de&&de.w===X&&de.h===le)continue;const Ie=K.current.get(ze);de&&Ie&&se.current&&!U.current&&(U.current={id:ze,position:{...Ie}}),W.current.set(ze,{w:X,h:le}),Ce=!0}Ce&&(Re.current&&!me.current?rt():oe())})),F){ie.current.set(A,F),ee.current.set(F,A),(D=Y.current)==null||D.observe(F);const ne=F.offsetWidth,Ce=F.offsetHeight;(ne||Ce)&&W.current.set(A,{w:ne,h:Ce})}else{const ne=ie.current.get(A);ne&&((H=Y.current)==null||H.unobserve(ne),ee.current.delete(ne)),ie.current.delete(A),W.current.delete(A),N.current.has(A)&&ae(A,[])}oe()},[oe,ae]);_.useEffect(()=>()=>{var A;return(A=Y.current)==null?void 0:A.disconnect()},[]);const or=_.useMemo(()=>{const A=new Map;for(const F of t)F.label&&A.set(F.id,F.label);return A},[t]),Ue=_.useMemo(()=>Ry(O.nodes,ge,W.current,A=>y(A).padding,A=>{const F=or.get(A);if(!F)return;const D=y(A);return{w:un(F,`bold ${D.fontSize}px ${Lr}`)+2*Ay,h:0}}),[O.nodes,ge,y,or]),ir=_.useRef(Ue);ir.current=Ue;const er=_.useCallback(A=>{const F=ir.current.get(A);if(F)return Y0(F);const D=K.current.get(A);if(!D)return;const H=W.current.get(A)||Sn;return{x:D.x,y:D.y,w:H.w,h:H.h}},[]),Z=_.useMemo(()=>{const A=new Map;for(const F of t){const D=er(F.id);D&&A.set(F.id,D)}return aw(V,A,fe,r,n)},[V,t,ge,Ue,fe,r,n,er]);N.current=Z;const z=(A,F)=>{var ne;if(!I||F===void 0)return;const D=(ne=Z.get(A))==null?void 0:ne.find(Ce=>Ce.property===F),H=er(A);return D&&!D.anchor&&H?H.y-H.h/2+D.top+D.height/2:void 0},re=(A,F)=>{var ne,Ce;if(F===void 0)return;const D=(Ce=(ne=Z.get(A))==null?void 0:ne.find(Le=>Le.property===F))==null?void 0:Ce.anchor,H=er(A);return D&&H?{x:H.x-H.w/2+D.x,y:H.y-H.h/2+D.y,side:D.side}:void 0},_e=(A,F)=>{const D=er(A),H=fe.get(A);return D&&H&&!Ue.has(A)&&z(A,F)===void 0?en(D,H):D},Te=()=>{const A=[];K.current.forEach((F,D)=>{if(ir.current.has(D))return;const H=W.current.get(D)||Sn;A.push(bt({x:F.x,y:F.y,w:H.w,h:H.h}))}),ir.current.forEach(F=>A.push(F));try{for(const F of[k.current,M.current]){const D=F==null?void 0:F.getBBox();D&&D.width>0&&D.height>0&&A.push({x1:D.x,y1:D.y,x2:D.x+D.width,y2:D.y+D.height})}}catch{}return yo(A)},Pe=()=>{var D,H;const{pan:A,zoom:F}=q;$.current&&($.current.style.transform=`translate3d(${A.x}px, ${A.y}px, 0) scale(${F})`),(D=k.current)==null||D.setAttribute("transform",`translate(${A.x} ${A.y}) scale(${F})`),(H=M.current)==null||H.setAttribute("transform",`translate(${A.x} ${A.y}) scale(${F})`)};_.useEffect(()=>{Pe();let A=null,F;const D=q.onChange(()=>{Pe();const H=R.current;H&&(H.classList.add("flow-sdk-busy"),clearTimeout(F),F=setTimeout(()=>H.classList.remove("flow-sdk-busy"),150)),A===null&&(A=requestAnimationFrame(()=>{var ne,Ce;A=null,(Ce=(ne=E.current).onViewportChange)==null||Ce.call(ne,q.state)}))});return()=>{D(),clearTimeout(F),A!==null&&cancelAnimationFrame(A)}},[]),_.useLayoutEffect(()=>{const A=R.current;if(!A)return;const F=()=>{let H=A.clientWidth,ne=A.clientHeight;ne||(ne=Math.max(0,window.innerHeight-A.getBoundingClientRect().top-100),ne&&(A.style.height=`${ne}px`)),H||(H=window.innerWidth,H&&(A.style.width=`${H}px`)),q.size={w:H,h:ne},!se.current&&!K.current.size&&E.current.fitOnInit!==!1&&(q.set({x:H/2,y:ne/2}),Pe())};if(F(),typeof ResizeObserver>"u")return;const D=new ResizeObserver(F);return D.observe(A),()=>D.disconnect()},[q]),_.useLayoutEffect(()=>{if(Xe.current){Xe.current=!1;const F=cr.current.flatMap(H=>{const ne=er(H);return ne?[bt(ne)]:[]});cr.current=[];const D=yo(F);if(D){he.current=!1,q.center(D,E.current.animateViewport);return}}if(!he.current)return;he.current=!1;const A=Te();A&&(q.fit(A,50,se.current&&E.current.animateViewport),se.current||Pe())},[ge]);const He=_.useMemo(()=>{const A=X=>Zl(X,E.current.nodes,E.current.edges),F=(X,le=50,de=E.current.animateViewport,Ie=1,kr=!1)=>{const Vr=Wr=>{const lo=T.current,bv=X??new Set(lo.nodes.map(pr=>pr.id)),vv=new Set(lo.nodes.map(pr=>pr.parent).filter(Boolean));if(!Wr&&(!X||[...X].some(pr=>vv.has(pr))))return;const fo=Wr&&Ry(lo.nodes,Wr,W.current,pr=>E.current.containerStyle(pr).padding,pr=>{var bn;const Nt=(bn=E.current.nodes.find(vn=>vn.id===pr))==null?void 0:bn.label;if(!Nt)return;const mn=E.current.containerStyle(pr);return{w:un(Nt,`bold ${mn.fontSize}px ${Lr}`)+2*Ay,h:0}}),Rl=yo([...bv].flatMap(pr=>{const Nt=fo==null?void 0:fo.get(pr);if(Nt)return[Nt];const mn=Wr==null?void 0:Wr.get(pr),bn=W.current.get(pr)||Sn,vn=mn?{...mn,...bn}:er(pr);return vn?[bt(vn)]:[]}));Rl&&(he.current=!1,cr.current=[],Xe.current=!1,q.fit(Rl,Number.isFinite(le)?Math.max(0,le):50,de,Ie))};Re.current=kr?Vr:null,kr||Vr(K.current)},D=(X,le,de,Ie)=>{var Vr;if(!er(X))return;const kr=le==="connections"?ne(X):A(X);if(le==="connections"&&ye.current===1.25&&((Vr=Ae.current)==null?void 0:Vr.size)===kr.size&&[...kr].every(Wr=>Ae.current.has(Wr))){S({id:X,mode:le});return}Me.current||(Me.current={pan:{...q.pan},zoom:q.zoom}),Ae.current=kr,E.current.compactPropertyLayout&&(he.current=!1,me.current=()=>F(Ae.current??kr,de,Ie)),S({id:X,mode:le}),E.current.compactPropertyLayout||F(kr,de,Ie)},H=X=>{me.current?me.current=X:X()},ne=X=>td(X,E.current.nodes,E.current.edges),Ce=(X=>{if(X===void 0)return q.zoom;Re.current=null,q.set(void 0,X)}),Le=(X=>{if(X===void 0)return q.pan;Re.current=null,q.set(X)}),ze=(X,le)=>{var Ie;const de=(Ie=R.current)==null?void 0:Ie.getBoundingClientRect();return{x:X-((de==null?void 0:de.left)??0),y:le-((de==null?void 0:de.top)??0)}},Ee=(X=0,le=E.current.animateViewport,de=!1)=>{if(de){F(void 0,X,le,1,!0);return}Re.current=null,H(()=>{const Ie=Te();Ie&&q.fit(Ie,X,le)})};return{zoom:Ce,pan:Le,setEdgesVisible:sr,focusNode:(X,le,de,Ie)=>H(()=>F(new Set([X]),le,de,.6,Ie)),focusBranch:(X,le,de)=>H(()=>F(A(X),le,de)),focusConnections:(X,le,de,Ie)=>H(()=>F(ne(X),le,de,1,Ie)),isolateConnections:(X,le,de)=>D(X,"connections",le,de),isolateBranch:(X,le,de)=>D(X,"branch",le,de),restoreView:(X=E.current.animateViewport,le)=>{Re.current=null;const de=E.current.compactPropertyLayout&&!!Ae.current;Ae.current=null,S(null);const Ie=le??Me.current;Me.current=null,de?me.current=()=>{Ie&&q.transition(Ie,X)}:Ie&&H(()=>q.transition(Ie,X))},zoomAt:(X,le)=>{Re.current=null,q.zoomAt(X,le)},fit:Ee,centerAndFit:Ee,center:(X=E.current.animateViewport)=>{Re.current=null;const le=Te();le&&q.center(le,X)},clientToModel:(X,le)=>q.renderedToModel(ze(X,le)),modelToClient:X=>{var Ie;const le=(Ie=R.current)==null?void 0:Ie.getBoundingClientRect(),de=q.modelToRendered(X);return{x:de.x+((le==null?void 0:le.left)??0),y:de.y+((le==null?void 0:le.top)??0)}},getNodeBox:X=>er(X),setNodePosition:(X,le,de)=>{if(!K.current.has(X)||le&&(!Number.isFinite(le.x)||!Number.isFinite(le.y)))return!1;if(xe(),!le)return te.current.delete(X),oe(),!0;const Ie=new Map(K.current);return Ie.set(X,{...le}),(de==null?void 0:de.persist)===!1?te.current.delete(X):te.current.set(X,{...le}),K.current=Ie,ve(Ie),(de==null?void 0:de.persist)===!1&&oe(),!0},onViewportChange:X=>q.onChange(X)}},[]);_.useEffect(()=>{var A,F;return(F=(A=E.current).onInit)==null||F.call(A,He),()=>q.cancelAnimation()},[He]),_.useEffect(()=>{var A,F;if(ue>0){const D=me.current;me.current=null,D==null||D(),(F=(A=E.current).onLayoutComplete)==null||F.call(A,He)}},[He,ue]);const je=_.useRef(null),De=_.useRef(new Map),Ke=_.useRef(!1),[dr,fr]=_.useState(null),[Ne,Ir]=_.useState(null),$r=A=>{const F=R.current.getBoundingClientRect();return{x:A.clientX-F.left,y:A.clientY-F.top}},Dr=(A,F)=>{const D=E.current.nodes;for(let H=D.length-1;H>=0;H--){const ne=D[H].id;if(!vt(ne,E.current.edges,E.current.edgeMode)||Ae.current&&!Ae.current.has(ne)||ne===F||ir.current.has(ne))continue;const Ce=er(ne);if(Ce&&Yl(A,bt(Ce)))return ne}for(const[H,ne]of ir.current)if(vt(H,E.current.edges,E.current.edgeMode)&&!(Ae.current&&!Ae.current.has(H))&&H!==F&&Yl(A,ne))return H;return null},io=(A,F)=>{if(E.current.edgeMode==="nodes"||E.current.edgeMode==="workflow")return null;const D=E.current.direction==="RL",H=Math.max(16,6/q.zoom);let ne=null;for(const Ce of[...E.current.nodes].reverse()){if(!vt(Ce.id,E.current.edges,E.current.edgeMode)||Ae.current&&!Ae.current.has(Ce.id))continue;const Le=er(Ce.id),ze=N.current.get(Ce.id);if(!Le||!ze||ir.current.has(Ce.id))continue;const Ee=Le.x+(F==="source"!==D?1:-1)*Le.w/2;for(const X of ze){if(X.role&&X.role!==F)continue;const le=Le.y-Le.h/2+X.top,de=Math.hypot(A.x-(X.anchor?Le.x-Le.w/2+X.anchor.x:Ee),A.y-le-X.height/2);if(!X.anchor&&A.x>=Le.x-Le.w/2&&A.x<=Le.x+Le.w/2&&A.y>=le&&A.y<=le+X.height)return{nodeId:Ce.id,property:X.property};de<=H&&(!ne||de<ne.distance)&&(ne={nodeId:Ce.id,property:X.property,distance:de})}}return ne},dv=A=>{var Le;if(!A.currentTarget.contains(A.target)||A.button!==0||E.current.readOnly)return;je.current||(Ke.current=!1);const F=A.target;if(F.closest('input, textarea, select, [contenteditable="true"], [data-flow-content-toggle]'))return;const D=E.current,H=$r(A);if(A.pointerType==="touch"){De.current.set(A.pointerId,H);const ze=Ty(De.current);if(ze){je.current={kind:"pinch",distance:ze.distance,zoom:q.zoom,anchor:q.renderedToModel(ze.center)},Ir(null),fr(null),Ke.current=!0;for(const Ee of De.current.keys())A.currentTarget.setPointerCapture(Ee);return}}if(je.current)return;const ne=D.drawHandles&&F.closest(".flow-sdk-handle"),Ce=D.drawHandles&&F.closest(".flow-sdk-property-port");if(D.drawMode||ne||Ce){const ze=q.renderedToModel(H),Ee=D.drawMode?io(ze,"source"):null,X=Ce||ne,le=X?(Le=X.closest("[data-node-id]"))==null?void 0:Le.dataset.nodeId:(Ee==null?void 0:Ee.nodeId)??Dr(ze),de=Ce?Ce.dataset.property:Ee==null?void 0:Ee.property;if(le){je.current={kind:"draw",pointerId:A.pointerId,source:le,sourceProperty:de,reverse:(Ce==null?void 0:Ce.dataset.portRole)==="target",startClient:{x:A.clientX,y:A.clientY}},Ke.current=!0,Ir({source:le,sourceProperty:de,point:ze,target:null}),A.currentTarget.setPointerCapture(A.pointerId);return}}F.closest(".flow-sdk-node, .flow-sdk-container, .flow-sdk-edge, .flow-sdk-edge-label, .flow-sdk-container-label")||(Re.current=null,D.multiSelect?je.current={kind:"box",pointerId:A.pointerId,start:H,current:H}:D.dragMode?je.current={kind:"pan",pointerId:A.pointerId,start:H,pan0:q.pan,moved:!1}:je.current={kind:"tap",pointerId:A.pointerId,start:H,moved:!1},A.currentTarget.setPointerCapture(A.pointerId))},fv=A=>{const F=je.current;if(!F||E.current.readOnly)return;const D=$r(A);if(De.current.has(A.pointerId)&&De.current.set(A.pointerId,D),F.kind==="pinch"){const H=Ty(De.current);if(!H)return;const ne=Math.max(q.minZoom,Math.min(q.maxZoom,F.zoom*H.distance/F.distance));q.set({x:H.center.x-F.anchor.x*ne,y:H.center.y-F.anchor.y*ne},ne);return}if(F.pointerId===A.pointerId)switch(F.kind){case"pan":{const H=D.x-F.start.x,ne=D.y-F.start.y;if(!F.moved&&Math.hypot(H,ne)<=Py)return;F.moved=!0,Ke.current=!0,q.set({x:F.pan0.x+H,y:F.pan0.y+ne});break}case"tap":{Math.hypot(D.x-F.start.x,D.y-F.start.y)>Py&&(F.moved=!0);break}case"box":{Ke.current=!0,F.current=D,fr({x1:Math.min(F.start.x,D.x),y1:Math.min(F.start.y,D.y),x2:Math.max(F.start.x,D.x),y2:Math.max(F.start.y,D.y)});break}case"draw":{const H=q.renderedToModel(D),ne=io(H,F.reverse?"source":"target");Ir(F.reverse&&ne?{source:ne.nodeId,sourceProperty:ne.property,point:H,target:F.source,targetProperty:F.sourceProperty}:{source:F.source,sourceProperty:F.sourceProperty,point:H,target:(ne==null?void 0:ne.nodeId)??Dr(H,F.source),targetProperty:ne==null?void 0:ne.property});break}}},_l=(A,F)=>{var ne,Ce,Le,ze,Ee;De.current.delete(A.pointerId);const D=je.current;if(!D)return;if(D.kind==="pinch"){const X=[...De.current][0];je.current=X&&E.current.dragMode&&!F?{kind:"pan",pointerId:X[0],start:X[1],pan0:q.pan,moved:!0}:null;return}if(D.pointerId!==A.pointerId)return;je.current=null;try{A.currentTarget.releasePointerCapture(A.pointerId)}catch{}const H=E.current;switch(F=F||!!H.readOnly,D.kind){case"pan":case"tap":!F&&!D.moved&&((ne=H.onBackgroundTap)==null||ne.call(H));break;case"box":{if(fr(null),F)break;const X=q.renderedToModel(D.start),le=q.renderedToModel(D.current),de={x1:Math.min(X.x,le.x),y1:Math.min(X.y,le.y),x2:Math.max(X.x,le.x),y2:Math.max(X.y,le.y)};if(de.x2-de.x1<1&&de.y2-de.y1<1){(Ce=H.onBackgroundTap)==null||Ce.call(H);break}const Ie=[];for(const kr of H.nodes){const Vr=er(kr.id);Vr&&X0(bt(Vr),de)&&Ie.push(kr.id)}Ie.length&&((Le=H.onBoxSelect)==null||Le.call(H,Ie));break}case"draw":{if(Ir(null),F)break;const X=$r(A),le=q.renderedToModel(X),de=io(le,D.reverse?"source":"target"),Ie=(de==null?void 0:de.nodeId)??Dr(le);if(Ie===D.source&&(D.sourceProperty===void 0||(de==null?void 0:de.property)===void 0||de.property===D.sourceProperty))break;Ie?(ze=H.onEdgeDraw)==null||ze.call(H,D.reverse?Ie:D.source,D.reverse?D.source:Ie,D.sourceProperty!==void 0||(de==null?void 0:de.property)!==void 0?{sourceProperty:D.reverse?de==null?void 0:de.property:D.sourceProperty,targetProperty:D.reverse?D.sourceProperty:de==null?void 0:de.property}:void 0):Math.max(Math.abs(A.clientX-D.startClient.x),Math.abs(A.clientY-D.startClient.y))>VS&&((Ee=H.onDrawIntoSpace)==null||Ee.call(H,D.source,le,D.sourceProperty,D.reverse));break}}},tt=_.useCallback(()=>{var D;const A=je.current,F=[...De.current.keys()];A&&A.kind!=="pinch"&&F.push(A.pointerId),je.current=null,De.current.clear(),Ir(null),fr(null);for(const H of F)(D=R.current)!=null&&D.hasPointerCapture(H)&&R.current.releasePointerCapture(H)},[]);_.useEffect(()=>{const A=F=>{F.key==="Escape"&&tt()};return window.addEventListener("keydown",A),window.addEventListener("blur",tt),()=>{window.removeEventListener("keydown",A),window.removeEventListener("blur",tt),je.current=null,De.current.clear()}},[tt]),_.useEffect(()=>{tt()},[g,b,x,o,n,e.drawHandles,e.readOnly,tt]);const hv=_.useMemo(()=>{const A=new Map,F=new Map;for(const D of P){if(D.source!==D.target)continue;const H=A.get(D.source)??0;A.set(D.source,H+1),F.set(D.id,H)}return F},[P]),ao=DS[n],[so,pv]=_.useState(null),co=BS(t,P,!!((kl=e.edgeReveal)!=null&&kl.revealNodes));_.useLayoutEffect(()=>{R.current&&so&&bw(R.current)});const uo=Z0(P,_e,ao),gv=e.onEdgeSelect,yv=e.onContainerSelect,El=Ne?Ne.target&&_e(Ne.target,Ne.targetProperty)||{x:Ne.point.x,y:Ne.point.y,w:1,h:1}:null,jl=Ne?_e(Ne.source,Ne.sourceProperty):null,mv=["flow-sdk-canvas",g?"flow-sdk-draw":"",v?"flow-sdk-perf":""].filter(Boolean).join(" ");return f.jsxs("div",{ref:R,className:mv,"data-edge-mode":o,onPointerDownCapture:dv,onPointerMove:fv,onPointerUp:A=>_l(A,!1),onPointerCancel:A=>_l(A,!0),onLostPointerCapture:A=>{const F=je.current;F&&(F.kind==="pinch"||F.pointerId===A.pointerId)&&tt()},onClickCapture:A=>{if(!A.currentTarget.contains(A.target))return;const F=A.target instanceof Element&&A.target.closest("button[data-flow-fullscreen]");(Ke.current||e.readOnly&&!F)&&(A.preventDefault(),A.stopPropagation())},children:[f.jsx("svg",{className:"flow-sdk-svg",children:f.jsxs("g",{ref:k,children:[f.jsx("g",{className:"flow-sdk-containers",children:[...Ue].filter(([A])=>vt(A,r,o)).filter(([A])=>!j||j.has(A)).map(([A,F])=>{var D,H;return f.jsx(uw,{id:A,rect:F,label:or.get(A),labelLayer:so,labelContent:(D=t.find(ne=>ne.id===A&&ne.label!==void 0))==null?void 0:D.element,style:y(A),onSelect:yv,onCollapse:e.readOnly?void 0:e.onContainerCollapse,selected:(H=e.selectedNodeIds)==null?void 0:H.includes(A)},A)})}),f.jsx("g",{className:"flow-sdk-edges",children:tr&&P.map(A=>{var H,ne,Ce;if(!co.ready.has(A.id)||j&&(!j.has(A.source)||!j.has(A.target)))return null;const F=_e(A.source,A.sourceProperty),D=_e(A.target,A.targetProperty);return!F||!D?null:f.jsx(od,{id:A.id,edgeData:A.data,validationIssue:A.validationIssue,edgeType:A.type,edgeRadius:e.edgeRadius,propertyMode:I,customEdgeTypes:e.customEdgeTypes,reveal:e.edgeReveal,onRevealComplete:co.complete,source:F,target:D,sourceProperty:A.sourceProperty,targetProperty:A.targetProperty,sourceY:z(A.source,A.sourceProperty),targetY:z(A.target,A.targetProperty),sourcePort:re(A.source,A.sourceProperty),targetPort:re(A.target,A.targetProperty),dir:ao,turn:((H=uo.get(A.id))==null?void 0:H.turn)??A.turn,labelAtTarget:(ne=uo.get(A.id))==null?void 0:ne.labelAtTarget,labelFraction:(Ce=uo.get(A.id))==null?void 0:Ce.labelFraction,color:A.color,connectorColor:A.connectorColor,labelBg:A.labelBg,label:A.label,labelLayer:so,dashed:A.dashed,animated:A.animated&&!v,inverted:A.inverted,loopIndex:hv.get(A.id)??0,onSelect:gv},A.id)})}),tr&&Ne&&Bu(Ne,o)&&jl&&El&&f.jsx("g",{className:"flow-sdk-ghost",pointerEvents:"none",children:f.jsx(od,{id:"__flow-sdk-ghost",edgeData:{id:"__flow-sdk-ghost",source:Ne.source,target:Ne.target??"",sourceProperty:Ne.sourceProperty,targetProperty:Ne.targetProperty},edgeType:e.edgeType,edgeRadius:e.edgeRadius,propertyMode:I,customEdgeTypes:e.customEdgeTypes,source:jl,target:El,sourceProperty:Ne.sourceProperty,targetProperty:Ne.targetProperty,sourceY:z(Ne.source,Ne.sourceProperty),sourcePort:re(Ne.source,Ne.sourceProperty),targetPort:Ne.target?re(Ne.target,Ne.targetProperty):void 0,targetY:Ne.target?z(Ne.target,Ne.targetProperty):void 0,dir:ao,turn:.5,color:m,labelBg:m})})]})}),f.jsx("div",{ref:$,className:"flow-sdk-nodes",children:t.map(A=>{var Ce,Le;const F=ge.get(A.id),D=Ue.get(A.id);if(D&&A.label!==void 0)return null;const H=(F==null?void 0:F.x)??(D?(D.x1+D.x2)/2:0),ne=(F==null?void 0:F.y)??(D?(D.y1+D.y2)/2:0);return f.jsx(FS,{id:A.id,x:H,y:ne,placed:!!F||!!D,hidden:!co.shown.has(A.id)||!vt(A.id,r,o)||!!j&&!j.has(A.id),onMount:We,drawHandles:e.drawHandles&&!e.readOnly,drawMode:g,connectedPorts:new Set(P.flatMap(ze=>[...ze.source===A.id&&ze.sourceProperty!==void 0?[`source:${ze.sourceProperty}`]:[],...ze.target===A.id&&ze.targetProperty!==void 0?[`target:${ze.targetProperty}`]:[]])),hasCollapseControl:A.hasCollapseControl,handleColor:m,animated:A.animated&&!D&&!v,animationColor:A.animationColor,animationWidth:A.animationWidth,animationVariant:A.animationVariant,width:(Ce=W.current.get(A.id))==null?void 0:Ce.w,height:(Le=W.current.get(A.id))==null?void 0:Le.h,propertyMode:I,resolvedRows:Z.get(A.id),reversePorts:n==="RL",direction:n,onPropertyRows:ae,onSurface:L,children:A.element},A.id)})}),dr&&f.jsx("div",{className:"flow-sdk-box",style:{left:dr.x1,top:dr.y1,width:dr.x2-dr.x1,height:dr.y2-dr.y1}}),f.jsx("svg",{className:"flow-sdk-svg flow-sdk-label-overlay",style:{zIndex:11,pointerEvents:"none"},children:f.jsx("g",{ref:M,transform:`translate(${q.pan.x} ${q.pan.y}) scale(${q.zoom})`,children:f.jsx("g",{ref:pv,className:"flow-sdk-labels",style:{pointerEvents:g?"none":"visiblePainted",outline:"none"}})})})]})}const US=_.memo(GS);function Cl(e=!0){const t=_.useRef(null);return _.useEffect(()=>{if(!e||!t.current)return;const r=o=>{o.stopPropagation()},n=t.current,i=["mousedown","mouseup","click","dblclick","pointerdown","pointerup","wheel"];return i.forEach(o=>n.addEventListener(o,r)),()=>{i.forEach(o=>n.removeEventListener(o,r))}},[e]),t}const Rt=({nodeId:e,label:t,color:r,fontWeight:n="bold",fontSize:i="5xl",wrap:o=!1,isEditing:s,onEditStart:a,onEditEnd:c})=>{const{callbacks:u,config:l,readOnly:d}=Fe(),h=l.editable&&!d,[p,y]=_.useState(t),[m,g]=_.useState(),b=_.useRef(null),x=_.useRef(!1),v=Cl(s);_.useEffect(()=>{if(s&&(x.current=!1,b.current)){b.current.focus();const C=b.current.value.length;b.current.setSelectionRange(C,C)}},[s]);const w=()=>{var S;if(x.current)return;x.current=!0;const C=p.trim();C&&C!==t&&((S=u.onNodeLabelChange)==null||S.call(u,e,C)),c()};return!h||!s?f.jsx(B.Text,{color:r,fontWeight:n,fontSize:i,minW:0,maxW:"100%",whiteSpace:o?"normal":"nowrap",overflowWrap:o?"anywhere":void 0,overflow:"hidden",textOverflow:"ellipsis",title:t,onDoubleClick:h?C=>{C.stopPropagation(),g({width:C.currentTarget.offsetWidth,height:C.currentTarget.offsetHeight}),y(t),a()}:void 0,cursor:h?"text":void 0,children:t}):f.jsxs("div",{ref:v,style:{position:"relative",width:"max-content",minWidth:m==null?void 0:m.width,maxWidth:900,height:m==null?void 0:m.height},children:[f.jsx(B.Text,{as:"span","aria-hidden":"true",display:"block",visibility:"hidden",fontWeight:n,fontSize:i,lineHeight:"normal",whiteSpace:"pre",overflow:"hidden",children:p||" "}),f.jsx(B.Input,{ref:b,value:p,onChange:C=>y(C.target.value),onBlur:w,onKeyDown:C=>{C.key==="Enter"&&w(),C.key==="Escape"&&(x.current=!0,c())},color:r,fontWeight:n,fontSize:i,bg:"transparent",borderWidth:0,_focus:{outline:"none",boxShadow:"none"},_focusVisible:{outline:"none",boxShadow:"none"},p:0,display:"block",position:"absolute",top:0,left:0,w:"100%",h:"100%",minW:0,minH:0,lineHeight:"normal"})]})};function tv({id:e,label:t,role:r,side:n,position:i=.5,placement:o,children:s,style:a}){return f.jsx("div",{"data-flow-property":e,"data-flow-port-role":r,"data-flow-port-side":n,"data-flow-port-position":n?i:void 0,"data-flow-port-placement":o,style:{minHeight:32,display:"flex",alignItems:"center",justifyContent:r==="source"?"flex-end":"flex-start",...a,...n?{display:"none"}:{}},children:s??t??e})}const HS=In.default.dialog`
211
211
  ${e=>Jr(e.$surface,e.$border)}
212
212
  &,