@squeed/flow-sdk 2.0.1 → 2.0.3
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/README.md +701 -57
- package/THIRD_PARTY_NOTICES.txt +3 -2
- package/dist/index-CPKLNAh1.js +461 -0
- package/dist/index-CPKLNAh1.js.map +1 -0
- package/dist/index-sHQXTNv9.cjs +3 -0
- package/dist/index-sHQXTNv9.cjs.map +1 -0
- package/dist/index.cjs +185 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +739 -17
- package/dist/index.d.ts +739 -17
- package/dist/index.js +14297 -7010
- package/dist/index.js.map +1 -1
- package/package.json +18 -5
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,186 @@
|
|
|
1
|
-
"use strict";var Dg=Object.create;var Mt=Object.defineProperty;var Bg=Object.getOwnPropertyDescriptor;var zg=Object.getOwnPropertyNames;var $g=Object.getPrototypeOf,Gg=Object.prototype.hasOwnProperty;var Wg=(e,t,r)=>t in e?Mt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Hg=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of zg(t))!Gg.call(e,o)&&o!==r&&Mt(e,o,{get:()=>t[o],enumerable:!(n=Bg(t,o))||n.enumerable});return e};var _e=(e,t,r)=>(r=e!=null?Dg($g(e)):{},Hg(t||!e||!e.__esModule?Mt(r,"default",{value:e,enumerable:!0}):r,e));var hr=(e,t,r)=>Wg(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),N=require("@chakra-ui/react"),q=require("react"),Q=require("react-icons/pi"),Oe=[];for(let e=0;e<256;++e)Oe.push((e+256).toString(16).slice(1));function Vg(e,t=0){return(Oe[e[t+0]]+Oe[e[t+1]]+Oe[e[t+2]]+Oe[e[t+3]]+"-"+Oe[e[t+4]]+Oe[e[t+5]]+"-"+Oe[e[t+6]]+Oe[e[t+7]]+"-"+Oe[e[t+8]]+Oe[e[t+9]]+"-"+Oe[e[t+10]]+Oe[e[t+11]]+Oe[e[t+12]]+Oe[e[t+13]]+Oe[e[t+14]]+Oe[e[t+15]]).toLowerCase()}let Pt;const Ug=new Uint8Array(16);function Kg(){if(!Pt){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Pt=crypto.getRandomValues.bind(crypto)}return Pt(Ug)}const Zg=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Iu={randomUUID:Zg};function dp(e,t,r){var o;if(Iu.randomUUID&&!e)return Iu.randomUUID();e=e||{};const n=e.random??((o=e.rng)==null?void 0:o.call(e))??Kg();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,Vg(n)}var de=Array.isArray;const st={label:"Untitled",description:"",isTask:!1,isLocked:!1},tu={id:null,type:"text",data:{...st,viewProps:{width:"max-content !important",maxWidth:700,height:"100%",borderColor:"transparent",borderRadius:25,borderWidth:0,boxShadow:"none",textOverflow:"ellipsis",fontWeight:"bold",textColor:"gray.800",textAlign:"center"}}},Tu={id:null,type:"objectView",data:{...st,headerTitle:null,viewProps:{width:"100%",borderWidth:2,borderRadius:25,height:"100%",justifyContent:"space-between",flexDirection:"row",textColor:"gray.900"}}},Yg={id:null,type:"arrayView",data:{...st,viewProps:{width:"max-content !important",maxWidth:700,height:"100%",textAlign:"center",borderRadius:25,fontSize:"5xl",borderWidth:2,textOverflow:"ellipsis",wordBreak:"keep-all",fontWeight:"bold",textColor:"gray.900",placeholder:"Start Typing"}}},Au={id:null,type:"workflowStep",data:{...st,viewProps:{width:"max-content !important",maxWidth:350,minWidth:280,height:"100%",borderRadius:15,borderWidth:3}}},Ne=e=>typeof e=="object",fp=e=>Array.isArray(e),Xg=["order","position","selected","locked","grabbed","grabbable","scratch"],ar=e=>Object.entries(e).reduce((t,[r,n])=>(!Ne(n)&&!r.startsWith("$")&&(t[r]=n),t),{}),nu=(e,t)=>typeof e=="string"&&e.startsWith("$")?Ot(e,t):Ne(e)&&!fp(e)?Object.entries(e).reduce((r,[n,o])=>(typeof o=="string"&&o.startsWith("$")&&n==="..."?(delete r["..."],r[n]={...Ot(o,t),...e}):typeof o=="string"&&o.startsWith("$")?r[n]=Ot(o,t):r[n]=o,r),{}):e,sr=e=>Object.entries(e).reduce((t,[r,n])=>(Ne(n)&&r&&n&&!r.startsWith("$")&&(Xg.includes(r)&&(r=r+"#"),t[r]=n),t),{}),gr=(e,t,{label:r,parent:n=void 0},o,i=null)=>(i!==null&&(Ne(i)||fp(i))&&(i=JSON.stringify(i,null,2)),{data:{parent:n,...e.data,id:t,text:r||"",label:r,code:i||null,type:e.type,description:o}}),or=(e,t,r=null,n=null,o=null,i=!1,a=null)=>({data:{id:dp(),source:o?t:e,target:o?e:t,label:n||"",isInverted:o,isEdgeAnimated:i,parent:a}}),ur=(e,t=[])=>{const r={},n={};let o=[];if(e)for(const[i,a]of Object.entries(e))i.startsWith("$")&&i!=="$"?r[i.slice(1)]=a:i!=="$"?n[i]=a:i==="$"&&(o=a);return{newConfig:r,updatedObject:n,arrayObject:o}},wr=(e,t)=>{let r=Tu;const{view:n,borderColor:o,borderRadius:i,bgColor:a,textColor:s,fontSize:l,stepType:u}=t;e=n||e,u?r={...Au}:e==="object"?r=Tu:e==="text"?r=tu:e==="array"?r=Yg:e==="workflowStep"&&(r={...Au});const c=r.data.viewProps;return r.data.viewProps={...c,borderRadius:i||(u?15:53),bgColor:a,borderColor:o,textColor:s,fontSize:l},r.data.config=t,{config:r}},Wr=(e,t)=>(e=t.find(n=>n.data.id===e)?`${e}.#`:e,e),Ot=(e,{ids:t,jsnObjct:r})=>{if(typeof e=="string"&&(e!=null&&e.startsWith("$"))){const n=e.replace("$","").replace("*","");e==null||e.endsWith("*");const o=t.find(s=>s.split(".").slice(-1)[0]===n||n===s);if(!o)return e;const i=Jg(o,r);return JSON.stringify(i).includes(e)?e:i||e}return e},Jg=(e,t)=>{let r=e.split(".").splice(1);return r=r[r.length-1]==="#"||r[r.length-1].includes("{")?r.slice(0,-2):r,(i=>r.reduce((a,s)=>{s=s.replace("[","").replace("]","");const{arrayObject:l}=ur(a);return a=l.length?l:a,a[s]},i))(t)};function Er(e,t="root",r=[]){try{const{arrayObject:n}=ur(e);n.length&&(e=n);const o=ar(e),i=sr(e);return Ne(e)?(de(e)||de(e)&&t==="root"||!de(e)&&Object.keys(o).length||t==="root")&&r.push(t):r.push(t),Object.keys(i).length&&!de(e)?zr({chldPth:null,itrblObjct:i,nodes:r,path:t}):de(e)&&e.forEach((a,s)=>{const l=ar(a),u=sr(a),{newConfig:c,arrayObject:d}=ur(a);let f=`${t}.${s}`;Ne(a)?Object.keys(l).length?(Er(l,f,r),Object.keys(u).length&&!de(a)&&zr({chldPth:f,itrblObjct:u,nodes:r,path:t})):Object.keys(u).length&&!de(a)?zr({chldPth:f,itrblObjct:u,nodes:r,path:t}):de(a)&&hp({chldPth:f,item:a,nodes:r,path:t}):r.push(f)}),{nodes:r}}catch{return{nodes:r}}}const zr=({chldPth:e,itrblObjct:t,nodes:r,path:n})=>Object.entries(t).forEach(([o,i],a)=>{const s=ar(i),l=sr(i),{newConfig:u,arrayObject:c}=ur(i);c.length&&(i=c),n.split(".").slice(0,2).join(".");let d=e?`${e}.${o}`:`${n}.${o}`;if(Ne(i)&&!de(i)){const f=Object.keys(s).length===0;if(f&&(wr("array",u),r.push(d)),Object.keys(s).length){const p=de(i)?`${i.length||""}`:`{${Object.keys(i).length||""}}`;let x=d;f&&(x=`${d}.${p}`),Er(i,x,r)}else Object.keys(l).length&&!de(i)?zr({chldPth:d,itrblObjct:l,path:d,nodes:r}):Er(i,d,r)}else de(i)&&Er(i,d,r)}),hp=({chldPth:e,item:t,nodes:r,path:n})=>t.forEach((o,i)=>{let a=`${e}.${i}`;const s=sr(o),l=ar(o);Ne(o)?!de(o)&&Object.keys(l).length?Er(o,a,r):Object.keys(s).length&&!de(o)?zr({chldPth:a,itrblObjct:s,path:n,nodes:r}):de(o)&&hp({chldPth:a,item:o,nodes:r,path:n}):r.push(a)}),nt=[];let $r;function vr(e,t="root",r=[],n=[],o="untitled",i={hideDefaultObject:!1,sprtObjctKy:!1,isCntr:!1},a={}){if(!e||typeof e!="object")return console.error("Invalid object passed",e),{nodes:r,edges:n};const s=e;if(!$r){const{nodes:c}=Er(e);$r={ids:c,jsnObjct:e}}let{hideDefaultObject:l,sprtObjctKy:u}=i;try{t=Wr(t,r);const{newConfig:c,arrayObject:d}=ur(e),f=Object.keys(a).length>0?a:c;d.length&&(e=d);const p=ar(e),x=sr(e),{label:y,collapsed:g,parent:v}=f;if(!Ne(e))r.push(gr(tu,t,{label:y||t,parent:v},e,s));else if(de(e)||de(e)&&t==="root"){const{config:h}=wr("array",f),b=de(e)?`${e.length||""}`:`{${Object.keys(e).length||""}}`,_=t==="root"?o:`${o} ${b}`;r.push(gr(h,t,{label:y||_,parent:v},e,de(s)?{[o]:s}:s))}else if(!de(e)&&Object.keys(p).length||t==="root"){const{config:h}=wr(null,f),b=de(e)?`${e.length||""}`:`{${Object.keys(e).length||""}}`,_=t.split("."),w=_[_.length-1];let E=isNaN(Number(w))?null:Number(w)+1;const R=isNaN(Number(w))?w:_[_.length-2]+" "+E,I=t==="root"?o:R;let A=!1;Number.isNaN(Number(o))||(A=!0);const k=e;if(y){const{config:M}=wr("object",f);r.push(gr(M,t,{label:y||`${y} ${b}`,parent:v},p,k))}else h.data.headerTitle=I,r.push(gr(h,t,{label:y,parent:v},p,k))}return g||(Object.keys(x).length&&!de(e)?Gr({flowConfig:i,chldPth:null,edges:n,isInverted:null,itrblObjct:x,nodes:r,path:t,newConfig:f}):de(e)&&e.forEach((h,b)=>{h=nu(h,$r);const _=h,w=ar(h),E=sr(h),{newConfig:R,arrayObject:I}=ur(h);I.length&&(h=I);const{config:A}=wr(typeof h=="string"?"text":"array",R),{hideConfig:k,sourceLabel:M,label:z,isEdgeAnimated:G,parent:U}=R;l=l||k;const V=t==="root"&&i.isCntr,X=t.split(".").slice(0,2).join("."),he=nt.includes(X),ee=i.isCntr&&he||b%2===0&&V;let Y=`${t}.${b}`;Y=Wr(Y,r),ee&&nt.push(Y),Ne(h)?Object.keys(w).length&&!de(h)?(n.push(or(t,Y,null,M,ee,G)),vr(h,Y,r,n,z||b,i,R)):Object.keys(E).length&&!de(h)?Gr({flowConfig:i,chldPth:Y,isInverted:ee,edges:n,itrblObjct:E,nodes:r,path:t,newConfig:R,forceIsInverted:!0}):de(h)?pp({flowConfig:i,chldPth:Y,edges:n,isInverted:ee,item:h,nodes:r,path:t}):Ne(h)&&Gr({flowConfig:i,chldPth:Y,isInverted:ee,edges:n,itrblObjct:[h],nodes:r,path:t,newConfig:R}):(n.push(or(t,Y,null,M,ee,G)),r.push(gr(A,Y,{label:z||String(h),parent:U},h,_)))})),{nodes:r,edges:n}}catch{return{nodes:r,edges:n}}}const Gr=({chldPth:e,flowConfig:t,edges:r,itrblObjct:n,nodes:o,isInverted:i,path:a,newConfig:s,forceIsInverted:l=!1})=>{let{hideDefaultObject:u,sprtObjctKy:c}=t;return Object.entries(n).forEach(([d,f],p)=>{f=nu(f,$r);const x=f,y=ar(f),g=sr(f),{newConfig:v,arrayObject:h}=ur(f);h.length&&(f=h);const{hideConfig:b,sourceLabel:_,label:w,content:E,target:R,targetLabel:I,collapsed:A,isEdgeAnimated:k,parent:M}=v;u=u||b;const z=a==="root"&&t.isCntr,G=a.split(".").slice(0,2).join("."),U=nt.includes(G);l||(i=t.isCntr&&U||p%2===0&&z);let V=e?`${e}.${d}`:`${a}.${d}`;if(V=Wr(V,o),i&&nt.push(V),R&&r.push(or(V,R,null,I,i,k)),Ne(f)&&!de(f)){r.push(or(a,V,null,_,i,k));const X=c||Object.keys(y).length===0;if(X){const he=E?"object":"array",{config:ee}=wr(he,v);ee.data.headerTitle=E?w:null,o.push(gr(ee,V,{label:w||d,parent:M},f,x))}if(Object.keys(y).length&&!u){const he=de(f)?` ${f.length||""}`:`{${Object.keys(f).length||""}}`;let ee=V;X&&(ee=`${V}.${he}`,ee=Wr(ee,o),r.push(or(V,ee,null,_,i,k))),vr(f,ee,o,r,w||d,t,v)}else Object.keys(g).length&&!de(f)?Gr({chldPth:V,flowConfig:t,itrblObjct:g,path:V,edges:r,nodes:o,newConfig:v,isInverted:i}):vr(f,V,o,r,d,t,v)}else de(f)&&(r.push(or(a,V,null,_,i,k)),vr(f,V,o,r,d,t,v))})},pp=({flowConfig:e,chldPth:t,edges:r,isInverted:n,item:o,nodes:i,path:a})=>o.forEach((s,l)=>{let u=`${t}.${l}`;u=Wr(u,i);const c=s;s=nu(s,$r);const d=sr(s),f=ar(s),{newConfig:p}=ur(s),{collapsed:x,label:y,parent:g,sourceLabel:v,isEdgeAnimated:h,content:b}=p;Ne(s)?!de(s)&&Object.keys(f).length?(r.push(or(a,u,null,v,n,h)),vr(s,u,i,r,l,e,p)):Object.keys(d).length&&!de(s)&&!x?Gr({chldPth:u,flowConfig:e,itrblObjct:d,path:a,edges:r,nodes:i,isInverted:n,newConfig:p}):de(s)&&pp({flowConfig:e,chldPth:u,edges:r,isInverted:n,item:s,nodes:i,path:a}):(r.push(or(a,u,null,v,n,h)),i.push(gr(tu,u,{label:y||String(s),parent:g},s,c)))});function ut(e){if(!Array.isArray(e==null?void 0:e.$connections))return[];const t=new Map;return e.$connections.flatMap((r,n)=>{if(!r||typeof r!="object")return[];const o=r;if(typeof o.target!="string"||!/^root(?:\.|$)/.test(o.target))return[];if(o.sourceProperty!==void 0&&typeof o.sourceProperty!="string")return[];if(o.targetProperty!==void 0&&typeof o.targetProperty!="string")return[];const i=typeof o.id=="string"&&o.id?JSON.stringify(["id",o.id]):JSON.stringify(["ports",o.target,o.sourceProperty??null,o.targetProperty??null]),a=t.get(i)??0;return t.set(i,a+1),[{value:o,key:`${i}#${a}`,index:n}]})}function gp(e,t,r){const n=ut(e).find(l=>l.key===t);if(!n)return e;const o=r(n.value),i=e.$connections.flatMap((l,u)=>u===n.index?o?[o]:[]:[l]);if(i.length)return{...e,$connections:i};const{$connections:a,...s}=e;return s}function Qg(e){const t=[],r=(n,o)=>{if(!n||typeof n!="object")return n;if(Array.isArray(n))return n.map((i,a)=>r(i,`${o}.${a}`));for(const i of ut(n)){const a=i.value;t.push({data:{id:`connection:${JSON.stringify([o,i.key])}`,source:o,target:a.target,sourceProperty:a.sourceProperty,targetProperty:a.targetProperty,label:typeof a.label=="string"?a.label:void 0,color:typeof a.color=="string"?a.color:void 0,isEdgeDashed:a.style==="dashed",isEdgeAnimated:a.style==="animated",connection:{address:o,key:i.key}}})}return Object.fromEntries(Object.entries(n).filter(([i])=>i!=="$connections").map(([i,a])=>[i,i==="$"?r(a,o):i.startsWith("$")?a:r(a,`${o}.${i}`)]))};return{json:r(e,"root"),edges:t}}const ct="root",Mu=e=>e==="#"||e.startsWith("{")||/^\s\d*$/.test(e);function er(e){const t=e.split(".");for(t[0]===ct&&t.shift();t.length&&Mu(t[t.length-1]);)t.pop();return t.filter(r=>!Mu(r))}function lt(e){return e==null||typeof e!="object"?e:Array.isArray(e.$)?e.$:e}function ir(e,t){return er(t).reduce((r,n)=>{var o;if(r!=null)return(o=lt(r))==null?void 0:o[n]},e)}function ev(e){return Array.isArray(e)?[...e]:{...e}}function Je(e,t,r){const n=er(t),o=(i,a)=>{if(a===n.length)return r(i);const s=n[a],l=lt(i);if(l==null||typeof l!="object")return i;const u=o(l[s],a+1);if(Object.is(u,l[s]))return i;const c=ev(l);return c[s]=u,l!==i?{...i,$:c}:c};return o(e,0)}function Rr(e,t,r){const n=r===""||r===void 0||r===null;if(Array.isArray(e))return n?e:{[t]:r,$:[...e]};const o=e!=null&&typeof e=="object"?{...e}:{};return e!=null&&typeof e!="object"&&(o.$label=String(e)),n?delete o[t]:o[t]=r,o}function Sr(e,t,r,n){return Je(e,t,o=>r==="$label"&&typeof o=="string"&&typeof n=="string"&&n!==""?n:Rr(o,r,n))}const vp=(e,t,r)=>Sr(e,t,"$collapsed",r);function dt(e){if(e.connection)return{address:e.connection.address,kind:"connection"};const t=e.isInverted?e.target:e.source,r=e.isInverted?e.source:e.target,n=er(t).join("."),o=er(r).join(".");return o.startsWith(n?n+".":"")&&o!==n?{address:r,kind:"hierarchy"}:n.startsWith(o?o+".":"")&&n!==o?{address:t,kind:"hierarchy"}:{address:t,kind:"target"}}function Hr(e,t,r,n){if(t.connection){const s=t.connection;return Je(e,s.address,l=>gp(l,s.key,u=>{if(r==="$sourceLabel"||r==="$edgeColor")return Rr(u,r==="$sourceLabel"?"label":"color",n);const c=r==="$isEdgeAnimated"?"animated":"dashed";return n?{...u,style:c}:u.style===c?Rr(u,"style",void 0):u}))}const{address:o,kind:i}=dt(t),a=i==="target"&&r==="$sourceLabel"?"$targetLabel":r;return Je(e,o,s=>Rr(s,a,n))}const yp=(e,t,r)=>Hr(Hr(e,t,"$isEdgeAnimated",r==="animated"||void 0),t,"$isEdgeDashed",r==="dashed"||void 0);function bp(e,t,r,n){let o=n||"";const i=Je(e,t,s=>{const l=lt(s);if(Array.isArray(l)){o=String(l.length);const c=[...l,r];return l===s?c:{...s,$:c}}const u=s!=null&&typeof s=="object"&&!Array.isArray(s)?{...s}:s!=null&&typeof s!="object"?{$label:String(s)}:{};if(!o){let c=1;for(;`node_${c}`in u;)c++;o=`node_${c}`}return u[o]=r,u}),a=er(t);return{json:i,address:[ct,...a,o].join(".")}}function mp(e,t){const r=er(t);if(!r.length)return e;const n=r[r.length-1],o=[ct,...r.slice(0,-1)].join(".");return Je(e,o,i=>{const a=lt(i);if(a==null||typeof a!="object"||!Object.prototype.hasOwnProperty.call(a,n))return i;if(Array.isArray(a)){const u=a.filter((c,d)=>String(d)!==n);return a===i?u:{...i,$:u}}const{[n]:s,...l}=i;return l})}const xp=(e,t,r,n)=>Sr(n?Je(e,t,o=>Rr(o,"$targetLabel",n)):e,t,"$target",r);function _p(e,t,r){const n=ir(e,t);return ut(n).some(({value:i})=>i.target===r.target&&i.sourceProperty===r.sourceProperty&&i.targetProperty===r.targetProperty)?e:Je(e,t,i=>Rr(i,"$connections",[...Array.isArray(i==null?void 0:i.$connections)?i.$connections:[],{...r,id:r.id||dp()}]))}function wp(e,t){if(t.connection){const i=t.connection;return ut(ir(e,i.address)).some(a=>a.key===i.key)?{json:Je(e,i.address,a=>gp(a,i.key,()=>null)),removed:!0}:{json:e,removed:!1}}const{address:r,kind:n}=dt(t);return n!=="target"?{json:e,removed:!1}:{json:Je(e,r,i=>{const{$target:a,$targetLabel:s,...l}=i||{};return l}),removed:!0}}function Cp(e,t={}){const r=Qg(e),{nodes:n,edges:o}=vr(r.json,ct,[],[],t.title||"untitled",{hideDefaultObject:!!t.hideDefaultObject,sprtObjctKy:!!t.separateObjectKeys,isCntr:!!t.isCenter}),i=new Set(n.map(y=>y.data.id)),a=new Map;for(const y of n){const g=y.data.id;if(!g.endsWith(".0")||ir(e,g)!==void 0)continue;const v=g.slice(0,-2),h=ir(e,v);!i.has(v)&&h&&typeof h=="object"&&!Array.isArray(h)&&typeof h.$label=="string"&&Object.keys(h).every(b=>b.startsWith("$")&&b!=="$")&&a.set(g,v)}const s=y=>a.get(y)??y,l=n.map(y=>{var b;const g=s(y.data.id),v=ir(e,g);if(!v||typeof v!="object"||Array.isArray(v))return y;const h={...y.data,id:g};return h.parent&&(h.parent=s(h.parent)),typeof v.$label=="string"&&(h.label=v.$label,h.headerTitle=v.$label),(((b=h.config)==null?void 0:b.collapsed)!==void 0||v.$collapsed!==void 0||v.$icon!==void 0)&&(h.config={...h.config||{}},(v.$collapsed!==void 0||h.config.collapsed!==void 0)&&(h.config.collapsed=!!v.$collapsed),v.$icon!==void 0&&(h.config.icon=v.$icon)),{data:h}}),u=new Map,c=o.map(y=>{const g=s(y.data.source),v=s(y.data.target),h=`${g}->${v}`,b=u.get(h)??0;u.set(h,b+1);const _={...y.data,id:b?`${h}#${b}`:h,source:g,target:v},w=ir(e,dt(_).address);return w&&typeof w=="object"&&(w.$isEdgeAnimated!==void 0&&(_.isEdgeAnimated=!!w.$isEdgeAnimated),w.$isEdgeDashed!==void 0&&(_.isEdgeDashed=!!w.$isEdgeDashed),w.$edgeColor&&(_.color=w.$edgeColor)),{data:_}}),d=new Set(l.map(y=>y.data.id));c.push(...r.edges.filter(y=>d.has(y.data.source)&&d.has(y.data.target)));const f=l.filter(y=>{var g;return(g=y.data.config)==null?void 0:g.collapsed}).map(y=>er(y.data.id));if(!f.length)return{nodes:l,edges:c};const p=l.filter(y=>{const g=er(y.data.id);return!f.some(v=>v.length<g.length&&v.every((h,b)=>h===g[b]))}),x=new Set(p.map(y=>y.data.id));return{nodes:p,edges:c.filter(y=>x.has(y.data.source)&&x.has(y.data.target))}}function rv(e,t){const r=new Set(e.filter(i=>{var a,s;return(s=(a=i.data)==null?void 0:a.config)==null?void 0:s.collapsed}).map(i=>i.data.id));if(!r.size)return{nodes:e,edges:t};const n=new Map;for(const i of t){const a=i.data.isInverted?i.data.target:i.data.source,s=i.data.isInverted?i.data.source:i.data.target;(n.get(a)??n.set(a,[]).get(a)).push(s)}const o=new Set;for(const i of r){const a=[...n.get(i)||[]];for(;a.length;){const s=a.pop();r.has(s)||o.has(s)||(o.add(s),a.push(...n.get(s)||[]))}}return{nodes:e.filter(i=>!o.has(i.data.id)),edges:t.filter(i=>!o.has(i.data.source)&&!o.has(i.data.target))}}function tv(e,t){const r=o=>e&&typeof e=="object"&&o in e;let n=1;for(;r(`${t}_${n}`);)n++;return`${t}_${n}`}function Ep(e,t,r,n){const o=(a,s)=>{a!==e&&(e=a,n==null||n(a,s))},i=a=>{var l;const s=(l=t.find(u=>u.data.id===a))==null?void 0:l.data;return s&&{source:s.source,target:s.target,isInverted:s.isInverted,sourceProperty:s.sourceProperty,targetProperty:s.targetProperty,connection:s.connection}};return{...r,onNodeLabelChange:(a,s)=>{var l;(l=r.onNodeLabelChange)==null||l.call(r,a,s),o(Sr(e,a,"$label",s),{type:"nodeLabel",address:a,key:"$label",value:s})},onNodeColorChange:(a,s,l)=>{var c;(c=r.onNodeColorChange)==null||c.call(r,a,s,l);const u=s==="bg"?"$bgColor":"$textColor";o(Sr(e,a,u,l),{type:"nodeColor",address:a,key:u,value:l})},onNodeIconChange:(a,s)=>{var l;(l=r.onNodeIconChange)==null||l.call(r,a,s),o(Sr(e,a,"$icon",s),{type:"nodeIcon",address:a,key:"$icon",value:s})},onNodeCollapse:(a,s)=>{var l;(l=r.onNodeCollapse)==null||l.call(r,a,s),o(vp(e,a,s),{type:"nodeCollapse",address:a,key:"$collapsed",value:s})},onNodeCreate:a=>{var d;(d=r.onNodeCreate)==null||d.call(r,a);const s=a.sourceNodeId||"root",l=ir(e,s),u=tv(l,a.isArrayMode?"list":"node"),c=bp(e,s,a.isArrayMode?[]:{},u);o(c.json,{type:"nodeCreate",address:c.address,value:a.isArrayMode?"array":"set"})},onNodeDelete:(a,s)=>{var l;(l=r.onNodeDelete)==null||l.call(r,a,s),o(mp(e,a),{type:"nodeDelete",address:a})},onEdgeCreate:(a,s,l)=>{var c;(c=r.onEdgeCreate)==null||c.call(r,a,s,l);const u=l&&(l.sourceProperty!==void 0||l.targetProperty!==void 0)?{...l,target:s}:void 0;o(u?_p(e,a,u):xp(e,a,s),{type:"edgeCreate",address:a,key:u?"$connections":"$target",value:u??s})},onEdgeLabelChange:(a,s)=>{var u;(u=r.onEdgeLabelChange)==null||u.call(r,a,s);const l=i(a);l&&o(Hr(e,l,"$sourceLabel",s),{type:"edgeLabel",edge:l,key:l.connection?"$connections":"$sourceLabel",value:s})},onEdgeStyleChange:(a,s)=>{var u;(u=r.onEdgeStyleChange)==null||u.call(r,a,s);const l=i(a);l&&o(yp(e,l,s),{type:"edgeStyle",edge:l,value:s})},onEdgeColorChange:(a,s)=>{var u;(u=r.onEdgeColorChange)==null||u.call(r,a,s);const l=i(a);l&&o(Hr(e,l,"$edgeColor",s),{type:"edgeColor",edge:l,key:l.connection?"$connections":"$edgeColor",value:s})},onEdgeDelete:(a,s)=>{var c;(c=r.onEdgeDelete)==null||c.call(r,a,s);const l=i(a);if(!l)return;const u=wp(e,l);u.removed&&o(u.json,{type:"edgeDelete",edge:l,key:l.connection?"$connections":"$target"})}}}const Rp=q.createContext(null),Sp=q.createContext({nodeById:new Map,edgeById:new Map,parentIds:new Set});function ou(){return q.useContext(Sp)}function Le(){const e=q.useContext(Rp);if(!e)throw new Error("useFlowDiagramContext must be used within FlowDiagram");return e}function nv({config:e,callbacks:t,nodes:r=[],edges:n=[],children:o}){const i=q.useMemo(()=>{var re,ue,Ce;const F=new Map;for(const ie of r)(re=ie.data)!=null&&re.id&&F.set(ie.data.id,ie);const Z=new Map;for(const ie of n)(ue=ie.data)!=null&&ue.id&&Z.set(ie.data.id,ie);const ne=new Set;for(const ie of r)(Ce=ie.data)!=null&&Ce.parent&&ne.add(ie.data.parent);return{nodeById:F,edgeById:Z,parentIds:ne}},[r,n]),a=q.useRef(null),[s,l]=q.useState([]),[u,c]=q.useState(null),[d,f]=q.useState(!0),[p,x]=q.useState(!1),[y,g]=q.useState(!0),[v,h]=q.useState(e.edgeHandles===!0),[b,_]=q.useState(!1),[w,E]=q.useState(!0),[R,I]=q.useState(!1),A=q.useRef(t);A.current=t;const k=q.useMemo(()=>{const F=Z=>(...ne)=>{var re,ue;return(ue=(re=A.current)==null?void 0:re[Z])==null?void 0:ue.call(re,...ne)};return{onNodeSelect:F("onNodeSelect"),onNodeDeselect:F("onNodeDeselect"),onNodeDoubleClick:F("onNodeDoubleClick"),onNodeCreate:F("onNodeCreate"),onNodeDelete:F("onNodeDelete"),onNodeLabelChange:F("onNodeLabelChange"),onNodeCollapse:F("onNodeCollapse"),onNodeColorChange:F("onNodeColorChange"),onNodeIconChange:F("onNodeIconChange"),onNodeHoverAction:F("onNodeHoverAction"),onEdgeCreate:F("onEdgeCreate"),onEdgeSelect:F("onEdgeSelect"),onEdgeDeselect:F("onEdgeDeselect"),onEdgeRemove:F("onEdgeRemove"),onEdgeDelete:F("onEdgeDelete"),onEdgeColorChange:F("onEdgeColorChange"),onEdgeLabelChange:F("onEdgeLabelChange"),onEdgeStyleChange:F("onEdgeStyleChange"),onViewportChange:F("onViewportChange"),onDirectionChange:F("onDirectionChange"),onArrayModeChange:F("onArrayModeChange"),onInit:F("onInit"),onJsonChange:F("onJsonChange")}},[]),M=e.themeColor||"blue.500",z=e.edgeColor||"",G=e.colorMode||"light",U=e.direction||"LR",V=e.nodeAlignment??"center",X=e.edgeMode??"workflow",he=e.readOnly??!1,ee=JSON.stringify(e.parentNodeStyle??null),Y=q.useMemo(()=>e.parentNodeStyle,[ee]),oe=e.isZoomMode!==void 0?e.isZoomMode:d,pe=e.isMultiSelectMode!==void 0?e.isMultiSelectMode:p,fe=e.isEdgeHandlesEnabled!==void 0?e.isEdgeHandlesEnabled:v,ge=e.isDragMode!==void 0?e.isDragMode:y,S=q.useRef(e);S.current=e;const O=q.useMemo(()=>({get direction(){return S.current.direction},get nodeAlignment(){return S.current.nodeAlignment},get edgeMode(){return S.current.edgeMode},get themeColor(){return S.current.themeColor},get colorMode(){return S.current.colorMode},get readOnly(){return S.current.readOnly},get editable(){return S.current.editable},get minZoom(){return S.current.minZoom},get maxZoom(){return S.current.maxZoom},get backgroundPattern(){return S.current.backgroundPattern},get edgeColor(){return S.current.edgeColor},get parentNodeStyle(){return S.current.parentNodeStyle},get backgroundColor(){return S.current.backgroundColor},get edgeHandles(){return S.current.edgeHandles},get initialViewport(){return S.current.initialViewport},get nodeOverlayActions(){return S.current.nodeOverlayActions},get renderNodeOverlay(){return S.current.renderNodeOverlay},get renderSelectedNodeToolbar(){return S.current.renderSelectedNodeToolbar},get renderSelectedEdgeToolbar(){return S.current.renderSelectedEdgeToolbar},get renderBottomBar(){return S.current.renderBottomBar},get selectionToolbar(){return S.current.selectionToolbar},get customViews(){return S.current.customViews},get disableKeyboardShortcuts(){return S.current.disableKeyboardShortcuts},get isZoomMode(){return S.current.isZoomMode},get isMultiSelectMode(){return S.current.isMultiSelectMode},get isEdgeHandlesEnabled(){return S.current.isEdgeHandlesEnabled},get isDragMode(){return S.current.isDragMode}}),[]),D=q.useMemo(()=>({themeColor:M,edgeColor:z,colorMode:G,direction:U,nodeAlignment:V,edgeMode:X,parentNodeStyle:Y,selectedNodeIds:s,setSelectedNodeIds:l,selectedEdgeId:u,setSelectedEdgeId:c,isZoomMode:oe,setIsZoomMode:f,isMultiSelectMode:pe,setIsMultiSelectMode:x,isDragMode:ge,setIsDragMode:g,isEdgeHandlesEnabled:fe,setIsEdgeHandlesEnabled:h,isArrayNodeMode:b,setIsArrayNodeMode:_,isPinned:w,setIsPinned:E,isPerformanceMode:R,setIsPerformanceMode:I,engineRef:a,callbacks:k,config:O,readOnly:he}),[M,z,G,U,V,X,Y,s,u,oe,pe,ge,fe,b,w,R,he,e.edgeHandles,k,O]);return m.jsx(Rp.Provider,{value:D,children:m.jsx(Sp.Provider,{value:i,children:o})})}function ot(e,t=.2){const r=e.replace(/^#/,""),n=parseInt(r,16);let o=n>>16&255,i=n>>8&255,a=n&255;return o=Math.max(0,Math.floor(o*(1-t))),i=Math.max(0,Math.floor(i*(1-t))),a=Math.max(0,Math.floor(a*(1-t))),"#"+((1<<24)+(o<<16)+(i<<8)+a).toString(16).slice(1).toUpperCase()}function ov(e,t,r){const n=s=>{const l=/^#?([0-9a-f]{6})$/i.exec((s==null?void 0:s.trim())??"");return l?parseInt(l[1],16):null},o=n(e),i=n(t);if(o===null||i===null)return null;const a=s=>Math.round((o>>s&255)*(1-r)+(i>>s&255)*r);return"#"+((1<<24)+(a(16)<<16)+(a(8)<<8)+a(0)).toString(16).slice(1).toUpperCase()}const Ye=e=>e!=null&&e.startsWith("#")?{background:e,highlight:ot(e,.1),border:ot(e,.5),property:"gray.900",boolean:"green.200",string:"gray.900",number:"orange.800"}:e==="gray"?{background:"gray.950",highlight:"gray.800",border:"gray.700",property:"gray.200",boolean:"green.400",string:"gray.200",number:"orange.600"}:e==="white"?{background:"white",highlight:"gray.200",border:"gray.400",property:"gray.900",boolean:"green.400",string:"gray.900",number:"orange.600"}:{background:e+".100",highlight:e+".200",border:e+".700",property:"gray.900",boolean:"green.800",string:"gray.900",number:"orange.800"},qp=e=>{let t=e;if(t!=null&&t.startsWith("#"))return{secondary:ot(e)};let r=String(Number(e.slice(-3))+200);r=e.slice(0,-3).concat(r);let n=String(Number(e.slice(-3))-100);return n=e.slice(0,-3).concat(n),{primary:t,secondary:r,light:n}},Pu={red:{50:"#FFF5F5",100:"#FED7D7",200:"#FEB2B2",300:"#FC8181",400:"#F56565",500:"#E53E3E",600:"#C53030",700:"#9B2C2C",800:"#822727",900:"#63171B"},orange:{50:"#FFFAF0",100:"#FEEBC8",200:"#FBD38D",300:"#F6AD55",400:"#ED8936",500:"#DD6B20",600:"#C05621",700:"#9C4221",800:"#7B341E",900:"#652B19"},yellow:{50:"#FFFFF0",100:"#FEFCBF",200:"#FAF089",300:"#F6E05E",400:"#ECC94B",500:"#D69E2E",600:"#B7791F",700:"#975A16",800:"#744210",900:"#5F370E"},green:{50:"#F0FFF4",100:"#C6F6D5",200:"#9AE6B4",300:"#68D391",400:"#48BB78",500:"#38A169",600:"#2F855A",700:"#276749",800:"#22543D",900:"#1C4532"},teal:{50:"#E6FFFA",100:"#B2F5EA",200:"#81E6D9",300:"#4FD1C5",400:"#38B2AC",500:"#319795",600:"#2C7A7B",700:"#285E61",800:"#234E52",900:"#1D4044"},blue:{50:"#EBF8FF",100:"#BEE3F8",200:"#90CDF4",300:"#63B3ED",400:"#4299E1",500:"#3182CE",600:"#2B6CB0",700:"#2C5282",800:"#2A4365",900:"#1A365D"},cyan:{50:"#EDFDFD",100:"#C4F1F9",200:"#9DECF9",300:"#76E4F7",400:"#0BC5EA",500:"#00B5D8",600:"#00A3C4",700:"#0987A0",800:"#086F83",900:"#065666"},purple:{50:"#FAF5FF",100:"#E9D8FD",200:"#D6BCFA",300:"#B794F4",400:"#9F7AEA",500:"#805AD5",600:"#6B46C1",700:"#553C9A",800:"#44337A",900:"#322659"},pink:{50:"#FFF5F7",100:"#FED7E2",200:"#FBB6CE",300:"#F687B3",400:"#ED64A6",500:"#D53F8C",600:"#B83280",700:"#97266D",800:"#702459",900:"#521B41"},gray:{50:"#F7FAFC",100:"#EDF2F7",200:"#E2E8F0",300:"#CBD5E0",400:"#A0AEC0",500:"#718096",600:"#4A5568",700:"#2D3748",800:"#1A202C",900:"#171923",950:"#0d1117"}},Se=(e,t)=>{var i;if(e!=null&&e.startsWith("#"))return e;if(!e)return"whitesmoke";const r=e.replace(/\./g,"-");try{const s=getComputedStyle(document.documentElement).getPropertyValue(`--chakra-colors-${r}`).trim();if(s&&s!=="")return s}catch{}const[n,o]=e.split(".");return n&&o&&((i=Pu[n])!=null&&i[Number(o)])?Pu[n][Number(o)]:`var(--chakra-colors-${r})`};function Pe(e,t,r){return e?r:t}function Vr(e){const[t]=(e==null?void 0:e.split("."))||[],{secondary:r}=qp(e),n=Ye(t).background,o=Ye(t).highlight,i=Ye(t).border,a=Ye(t).property,s=Ye(t).property;let l=Ye(t).background,u=Ye(t).highlight;return l=Se(l)+50,u=Se(u)+20,{bgColor:n,highlightColor:o,borderColor:i,textColor:a,propertyColor:s,secondary:r,bgColorFaint:l,highlightColorFaint:u}}function $e(e=null){const{colorMode:t}=Le(),r=e==null?void 0:e.includes("gray"),n=t==="dark",o=Pe(n,"white","gray.900"),i=Pe(n,"gray.100","gray.800"),a=Pe(n,"gray.200","blackAlpha.400"),s=Pe(n,"gray.200","blackAlpha.600"),l=Pe(n,"gray.500","gray.700"),u=Pe(n,"gray.700","gray.700"),c=Pe(n,"gray.900","gray.900"),d=Pe(n,"gray.400","gray.500"),f=Pe(n,"gray.400","gray.700"),p=Pe(n,"gray.900","gray.200"),x=Pe(n,r?"gray.900":"gray.200",r?"gray.200":"gray.900"),y=Pe(n,"gray.900","gray.200"),g=Pe(n,e&&"#000000",e||"#ffffff"),v=Pe(n,e||"#ffffff",e?"#000000":"#ffffff"),h=u,b=Pe(n,"gray.300","gray.800"),_=Pe(n,"white","blackAlpha.400"),w=Pe(n,"green.100","green.700");return{canvas:o,background:i,backgroundSecondary:a,darkBackgroundSecondary:s,border:l,darkColor:c,backgroundWhiteColor:_,borderSecondary:u,colorActive:d,colorInactive:f,iconColor:y,moreIconColor:h,colorText:p,themedColorText:x,logoColor:g,logoColorSecondary:v,darkColorActive:b,greenColor:w}}var Nr=(e=>(e.TOP_DOWN="TB",e.BOTTOM_UP="BT",e.LEFT_RIGHT="LR",e.RIGHT_LEFT="RL",e.CENTER="C",e))(Nr||{});function Me({label:e,children:t}){if(!N.Tooltip.Root){const r=N.Tooltip;return m.jsx(r,{label:e,placement:"top",fontSize:"xs",children:t})}return m.jsxs(N.Tooltip.Root,{positioning:{placement:"top"},children:[m.jsx(N.Tooltip.Trigger,{asChild:!0,children:t}),m.jsx(N.Tooltip.Positioner,{children:m.jsx(N.Tooltip.Content,{fontSize:"xs",children:e})})]})}function je({icon:e,...t}){return m.jsx(N.IconButton,{...t,children:e})}const iv=["blue.500","teal.500","green.500","yellow.500","orange.500","red.500","purple.500","pink.500","gray.500"],av=["gray.900","gray.600","gray.200","white"];function Ip(){const{config:e}=Le(),t=e.selectionToolbar||{},r=new Set(t.hide||[]);return{palette:t.palette||iv,show:n=>!r.has(n)}}function Xe(){const{border:e}=$e();return m.jsx(N.Icon,{mx:-1,as:Q.PiLineVerticalThin,boxSize:5,color:e})}function Tp({onClick:e}){const{colorText:t}=$e();return m.jsx(Me,{label:"Close",children:m.jsx(je,{"aria-label":"Close selection tools",icon:m.jsx(N.Icon,{as:Q.PiX,boxSize:5}),size:"sm",variant:"ghost",color:t,onClick:e})})}function eu({value:e,placeholder:t,ariaLabel:r,width:n="140px",onCommit:o}){const{colorText:i}=$e(),[a,s]=q.useState(e),l=q.useRef(!1);q.useEffect(()=>s(e),[e]);const u=()=>{if(l.current)return;l.current=!0;const c=a.trim();c!==e&&o(c)};return m.jsx(N.Input,{"aria-label":r,size:"xs",w:n,value:a,placeholder:t,color:i,borderWidth:0,_focusVisible:{boxShadow:"none",outline:"none"},borderRadius:"8px",onFocus:()=>{l.current=!1},onChange:c=>s(c.target.value),onBlur:u,onKeyDown:c=>{c.key==="Enter"&&(u(),c.target.blur()),c.key==="Escape"&&(l.current=!0,s(e),c.target.blur())}})}function ru({colors:e,value:t,label:r,onPick:n,onReset:o}){const{colorInactive:i}=$e();return m.jsxs(N.HStack,{gap:1,"aria-label":r,role:"group",children:[e.map(a=>{const s=t===a;return m.jsx(Me,{label:`${r}: ${a}`,children:m.jsx(N.Box,{as:"button","aria-label":`${r} ${a}`,"aria-pressed":s,w:4,h:4,borderRadius:"full",cursor:"pointer",style:{backgroundColor:Se(a)},outline:s?"2px solid white":"none",outlineOffset:"1px",_hover:{transform:"scale(1.15)"},onClick:()=>n(a)})},a)}),o&&m.jsx(Me,{label:`Reset ${r.toLowerCase()}`,children:m.jsx(je,{"aria-label":`Reset ${r}`,icon:m.jsx(N.Icon,{as:Q.PiEraser,boxSize:4}),size:"xs",variant:"ghost",color:i,onClick:o})})]})}function sv({edgeId:e,onClose:t}){var d;const{callbacks:r,themeColor:n}=Le(),{colorInactive:o}=$e(),{edgeById:i}=ou(),{palette:a,show:s}=Ip(),l=(d=i.get(e))==null?void 0:d.data,u=l!=null&&l.isEdgeAnimated?"animated":l!=null&&l.isEdgeDashed?"dashed":"solid",c=[{key:"solid",icon:Q.PiLineSegment,label:"Solid"},{key:"dashed",icon:Q.PiLineSegments,label:"Dashed"},{key:"animated",icon:Q.PiFastForward,label:"Animated"}];return m.jsxs(m.Fragment,{children:[m.jsx(Tp,{onClick:t}),s("label")&&m.jsxs(m.Fragment,{children:[m.jsx(Xe,{}),m.jsx(eu,{ariaLabel:"Edge label",placeholder:"Edge label",value:(l==null?void 0:l.label)||"",onCommit:f=>{var p;return(p=r.onEdgeLabelChange)==null?void 0:p.call(r,e,f)}})]}),s("style")&&m.jsxs(m.Fragment,{children:[m.jsx(Xe,{}),c.map(f=>m.jsx(Me,{label:f.label,children:m.jsx(je,{"aria-label":`Edge style ${f.key}`,"aria-pressed":u===f.key,icon:m.jsx(N.Icon,{as:f.icon,boxSize:5}),size:"sm",variant:"ghost",color:u===f.key?n:o,onClick:()=>{var p;return(p=r.onEdgeStyleChange)==null?void 0:p.call(r,e,f.key)}})},f.key))]}),s("color")&&m.jsxs(m.Fragment,{children:[m.jsx(Xe,{}),m.jsx(ru,{label:"Edge color",colors:a,value:l==null?void 0:l.color,onPick:f=>{var p;return(p=r.onEdgeColorChange)==null?void 0:p.call(r,e,f)},onReset:()=>{var f;return(f=r.onEdgeColorChange)==null?void 0:f.call(r,e,"")}})]}),s("delete")&&m.jsxs(m.Fragment,{children:[m.jsx(Xe,{}),m.jsx(Me,{label:"Delete edge",children:m.jsx(je,{"aria-label":"Delete edge",icon:m.jsx(N.Icon,{as:Q.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:"red.400",onClick:()=>{var f;(f=r.onEdgeDelete)==null||f.call(r,e,l),t()}})})]})]})}function uv({ids:e,onClose:t}){var p,x,y,g,v;const{callbacks:r,colorMode:n}=Le(),{colorText:o,colorInactive:i}=$e(),{nodeById:a}=ou(),{palette:s,show:l}=Ip(),u=e.length===1,c=u?(p=a.get(e[0]))==null?void 0:p.data:void 0,d=(x=c==null?void 0:c.config)==null?void 0:x.collapsed,f=h=>e.forEach(h);return m.jsxs(m.Fragment,{children:[m.jsx(Tp,{onClick:t}),m.jsx(Xe,{}),u&&l("label")?m.jsx(eu,{ariaLabel:"Node label",placeholder:"Node label",value:(c==null?void 0:c.label)??(c==null?void 0:c.headerTitle)??"",onCommit:h=>{var b;return(b=r.onNodeLabelChange)==null?void 0:b.call(r,e[0],h)}}):m.jsxs(N.Text,{fontSize:"xs",color:o,whiteSpace:"nowrap",px:1,children:[e.length," selected"]}),l("color")&&m.jsxs(m.Fragment,{children:[m.jsx(Xe,{}),m.jsx(ru,{label:"Background",colors:s,value:(y=c==null?void 0:c.viewProps)==null?void 0:y.bgColor,onPick:h=>f(b=>{var _;return(_=r.onNodeColorChange)==null?void 0:_.call(r,b,"bg",h)}),onReset:()=>f(h=>{var b;return(b=r.onNodeColorChange)==null?void 0:b.call(r,h,"bg","")})})]}),l("textColor")&&m.jsxs(m.Fragment,{children:[m.jsx(Xe,{}),m.jsx(ru,{label:"Text color",colors:av,value:(g=c==null?void 0:c.viewProps)==null?void 0:g.textColor,onPick:h=>f(b=>{var _;return(_=r.onNodeColorChange)==null?void 0:_.call(r,b,"text",h)}),onReset:()=>f(h=>{var b;return(b=r.onNodeColorChange)==null?void 0:b.call(r,h,"text","")})})]}),u&&l("icon")&&m.jsxs(m.Fragment,{children:[m.jsx(Xe,{}),m.jsx(eu,{ariaLabel:"Node icon",placeholder:"Icon (e.g. PiGear)",width:"120px",value:((v=c==null?void 0:c.config)==null?void 0:v.icon)||"",onCommit:h=>{var b;return(b=r.onNodeIconChange)==null?void 0:b.call(r,e[0],h)}})]}),u&&l("collapse")&&d!==void 0&&m.jsxs(m.Fragment,{children:[m.jsx(Xe,{}),m.jsx(Me,{label:d?"Expand":"Collapse",children:m.jsx(je,{"aria-label":d?"Expand node":"Collapse node",icon:m.jsx(N.Icon,{as:d?Q.PiArrowsOutLineVertical:Q.PiArrowsInLineVertical,boxSize:5}),size:"sm",variant:"ghost",color:i,onClick:()=>{var h;return(h=r.onNodeCollapse)==null?void 0:h.call(r,e[0],!d)}})})]}),l("delete")&&m.jsxs(m.Fragment,{children:[m.jsx(Xe,{}),m.jsx(Me,{label:u?"Delete node":`Delete ${e.length} nodes`,children:m.jsx(je,{"aria-label":"Delete selected nodes",icon:m.jsx(N.Icon,{as:Q.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:n==="dark"?"red.300":"red.500",onClick:()=>{f(h=>{var b,_;return(_=r.onNodeDelete)==null?void 0:_.call(r,h,((b=a.get(h))==null?void 0:b.data)||{id:h})}),t()}})})]})]})}const cv=[{value:"BT",label:"Bottom to Up",icon:Q.PiArrowUp,flowType:Nr.BOTTOM_UP},{value:"TB",label:"Top to Bottom",icon:Q.PiArrowDown,flowType:Nr.TOP_DOWN},{value:"LR",label:"Left to Right",icon:Q.PiArrowRight,flowType:Nr.LEFT_RIGHT},{value:"RL",label:"Right to Left",icon:Q.PiArrowLeft,flowType:Nr.RIGHT_LEFT}],Ap=()=>{const{engineRef:e,themeColor:t,direction:r,selectedNodeIds:n,setSelectedNodeIds:o,selectedEdgeId:i,setSelectedEdgeId:a,isZoomMode:s,setIsZoomMode:l,isMultiSelectMode:u,setIsMultiSelectMode:c,isDragMode:d,setIsDragMode:f,isEdgeHandlesEnabled:p,setIsEdgeHandlesEnabled:x,isArrayNodeMode:y,setIsArrayNodeMode:g,isPinned:v,setIsPinned:h,callbacks:b,config:_,readOnly:w}=Le(),{nodeById:E,edgeById:R,parentIds:I}=ou(),A=_.colorMode==="dark",{background:k,border:M,colorInactive:z,colorText:G,colorActive:U,darkBackgroundSecondary:V}=$e(),[X,he]=q.useState(!1),[ee,Y]=q.useState(!0),oe=q.useCallback(W=>{const ye=e.current;if(!ye)return;const K=_.minZoom??.01,we=_.maxZoom??1.5,Ae=.02;let Ie=ye.zoom();switch(W){case"increase":Ie=Math.min(we,Ie+Ae),ye.zoom(Ie),ye.center();break;case"decrease":Ie=Math.max(K,Ie-Ae),ye.zoom(Ie),ye.center();break;case"reset":ye.fit(50);break}},[e,_.minZoom,_.maxZoom]),pe=_.renderSelectedNodeToolbar,fe=n.length>0&&!!pe,ge=q.useMemo(()=>fe?n.map(W=>{var K;return{...((K=E.get(W))==null?void 0:K.data)??{id:W},isParent:I.has(W)}}):[],[fe,n,E,I]),S=q.useCallback(()=>{var W;o([]),(W=b.onNodeDeselect)==null||W.call(b)},[o,b]),O=_.renderSelectedEdgeToolbar,D=!!i&&!!O,F=q.useMemo(()=>{var W;return!D||!i?null:((W=R.get(i))==null?void 0:W.data)??{id:i}},[D,i,R]),Z=q.useCallback(()=>{var W;a(null),(W=b.onEdgeDeselect)==null||W.call(b)},[a,b]),ne=_.selectionToolbar!==!1&&!w,re=ne&&!!i&&!O,ue=ne&&!re&&n.length>0&&!pe,Ce=re||ue;q.useEffect(()=>{Ce&&h(!0)},[Ce,h]);const ie=v||X||Ce,ve=_.renderBottomBar;return ve?m.jsxs(m.Fragment,{children:[fe&&m.jsx(N.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:pe({selectedNodeIds:n,selectedNodeData:ge,onDeselect:S})}),D&&F&&m.jsx(N.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:O({edgeId:i,edgeData:F,onDeselect:Z})}),m.jsx(N.Box,{position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",children:ve({zoomIn:()=>oe("increase"),zoomOut:()=>oe("decrease"),resetZoom:()=>oe("reset"),direction:r,isZoomMode:s,setIsZoomMode:l,isMultiSelectMode:u,setIsMultiSelectMode:c,isDragMode:d,setIsDragMode:f,isEdgeHandlesEnabled:p,setIsEdgeHandlesEnabled:x,isArrayNodeMode:y,setIsArrayNodeMode:g,selectedNodeIds:n,selectedNodeData:ge,selectedEdgeId:i,selectedEdgeData:F,onNodeDeselect:S,onEdgeDeselect:Z,callbacks:b})})]}):m.jsxs(m.Fragment,{children:[fe&&m.jsx(N.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:pe({selectedNodeIds:n,selectedNodeData:ge,onDeselect:S})}),D&&F&&m.jsx(N.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:O({edgeId:i,edgeData:F,onDeselect:Z})}),!v&&m.jsx(N.Box,{position:"absolute",bottom:5,left:0,zIndex:101,w:3,children:m.jsx(Me,{label:"Show Bottom Bar",children:m.jsx(N.chakra.button,{type:"button","aria-label":"Show Bottom Bar",display:"flex",alignItems:"center",bg:k,borderColor:M,borderWidth:1,py:6,px:0,w:4,h:50,borderRadius:"15px",borderLeftRadius:0,onMouseEnter:()=>h(!0),onClick:()=>h(!0),_hover:{bg:V},children:m.jsx(N.Icon,{ml:-1,as:Q.PiLineVerticalBold,boxSize:5,color:M})})})}),m.jsx(N.Box,{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:ie?"translateY(0)":"translateY(100%)",pointerEvents:ie?"auto":"none",visibility:ie?"visible":"hidden",opacity:ie?1:0,children:m.jsxs(N.Flex,{w:"100%",px:5,position:"absolute",bottom:5,flexDirection:"row",justifyContent:"space-between",alignItems:"center",children:[m.jsx(N.Box,{bg:k,alignContent:"center",h:50,borderColor:M,borderWidth:1,borderRadius:"15px",children:m.jsx(N.HStack,{px:2,gap:1,children:re?m.jsx(sv,{edgeId:i,onClose:Z}):ue?m.jsx(uv,{ids:n,onClose:S}):m.jsxs(m.Fragment,{children:[m.jsx(Me,{label:v?"Unpin":"Pin",children:m.jsx(je,{"aria-label":"Pin",icon:m.jsx(N.Icon,{as:v?Q.PiPushPinFill:Q.PiPushPin,boxSize:5}),size:"sm",variant:"ghost",color:v?t:z,onClick:()=>{h(!v),he(!1)}})}),m.jsx(N.Icon,{mx:-1,as:Q.PiLineVerticalThin,boxSize:5,color:M}),m.jsx(Me,{label:"Zoom Out",children:m.jsx(je,{"aria-label":"Zoom out",icon:m.jsx(N.Icon,{as:Q.PiMinus,boxSize:5}),size:"sm",variant:"ghost",color:G,onClick:()=>oe("decrease")})}),m.jsx(Me,{label:"Zoom In",children:m.jsx(je,{"aria-label":"Zoom in",icon:m.jsx(N.Icon,{as:Q.PiPlus,boxSize:5}),size:"sm",variant:"ghost",color:G,onClick:()=>oe("increase")})}),m.jsx(Me,{label:"Reset Zoom",children:m.jsx(je,{"aria-label":"Reset zoom",icon:m.jsx(N.Icon,{as:Q.PiArrowCounterClockwise,boxSize:5}),size:"sm",variant:"ghost",color:G,onClick:()=>oe("reset")})}),!ee&&m.jsxs(m.Fragment,{children:[m.jsx(N.Icon,{mx:-1,as:Q.PiLineVerticalThin,boxSize:5,color:M}),m.jsx(Me,{label:s?"Zoom Mode (z)":"Pan Mode (z)",children:m.jsx(je,{"aria-label":"Toggle zoom mode",icon:m.jsx(N.Icon,{as:s?Q.PiMagnifyingGlassPlus:Q.PiArrowsOutCardinal,boxSize:5}),size:"sm",variant:"ghost",color:s?t:z,onClick:()=>l(!s)})}),m.jsx(N.Icon,{mx:-1,as:Q.PiLineVerticalThin,boxSize:5,color:M}),m.jsx(Me,{label:u?"Multi-Select On (m)":"Multi-Select Off (m)",children:m.jsx(je,{"aria-label":"Toggle multi-select",icon:m.jsx(N.Icon,{as:Q.PiSelectionPlus,boxSize:5}),size:"sm",variant:"ghost",color:u?t:z,onClick:()=>c(!u)})}),m.jsx(N.Icon,{mx:-1,as:Q.PiLineVerticalThin,boxSize:5,color:M}),m.jsx(Me,{label:d?"Drag Mode On (d)":"Drag Mode Off (d)",children:m.jsx(je,{"aria-label":"Toggle drag mode",icon:m.jsx(N.Icon,{as:Q.PiHandGrabbing,boxSize:5}),size:"sm",variant:"ghost",color:d?t:z,onClick:()=>f(!d)})}),_.edgeHandles!==!1&&m.jsxs(m.Fragment,{children:[m.jsx(N.Icon,{mx:-1,as:Q.PiLineVerticalThin,boxSize:5,color:M}),m.jsx(Me,{label:p?"Draw Mode On":"Draw Mode Off",children:m.jsx(je,{"aria-label":"Toggle draw mode",icon:m.jsx(N.Icon,{as:Q.PiPencilSimpleLine,boxSize:5}),size:"sm",variant:"ghost",color:p?t:z,onClick:()=>x(!p)})})]}),m.jsx(N.Icon,{mx:-1,as:Q.PiLineVerticalThin,boxSize:5,color:M}),m.jsx(Me,{label:y?"Array Mode [ ]":"Set Mode { }",children:m.jsx(je,{"aria-label":"Toggle array mode",icon:m.jsx(N.Icon,{as:y?Q.PiBracketsSquare:Q.PiBracketsCurly,boxSize:5}),size:"sm",variant:"ghost",color:y?t:z,onClick:()=>{var ye;const W=!y;g(W),(ye=b.onArrayModeChange)==null||ye.call(b,W)}})})]}),m.jsx(N.Icon,{mx:-1,as:Q.PiLineVerticalThin,boxSize:5,color:M}),m.jsx(Me,{label:ee?"Expand toolbar":"Collapse toolbar",children:m.jsx(je,{"aria-label":"Toggle toolbar collapse",icon:m.jsx(N.Icon,{as:ee?Q.PiCaretRight:Q.PiCaretLeft,boxSize:5}),size:"sm",variant:"ghost",color:z,onClick:()=>Y(!ee)})})]})})}),!Ce&&m.jsxs(N.Box,{position:"relative",ml:"auto",children:[m.jsx(N.Box,{bg:k,borderWidth:1,borderColor:M,borderRadius:"15px",h:50,px:3,cursor:"pointer",onClick:()=>he(!X),children:m.jsxs(N.Flex,{align:"center",h:"100%",children:[m.jsx(Me,{label:"Flow Direction",children:m.jsx(je,{"aria-label":"Direction",icon:m.jsx(N.Icon,{as:Q.PiCaretUp,boxSize:5}),size:"sm",variant:"ghost",color:z})}),m.jsx(N.Text,{fontSize:"xs",color:A?"whiteAlpha.600":"blackAlpha.500",ml:1,children:r})]})}),X&&m.jsx(N.Box,{position:"absolute",bottom:"100%",right:0,pb:"10px",zIndex:200,children:m.jsxs(N.Box,{bg:k,borderWidth:1,borderColor:M,borderRadius:"15px",p:2,minW:"180px",shadow:"lg",children:[cv.map(W=>m.jsxs(N.Flex,{align:"center",gap:3,px:3,py:2,borderRadius:"10px",cursor:"pointer",_hover:{bg:A?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var ye;(ye=b.onDirectionChange)==null||ye.call(b,W.value),he(!1)},children:[m.jsx(N.Icon,{as:W.icon,boxSize:5,color:G}),m.jsx(N.Text,{fontSize:"sm",color:G,flex:1,whiteSpace:"nowrap",children:W.label}),r===W.value&&m.jsx(N.Icon,{as:Q.PiCheck,boxSize:4,color:U})]},W.value)),m.jsxs(N.Flex,{align:"center",gap:3,px:3,py:2,borderRadius:"10px",cursor:"pointer",_hover:{bg:A?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var W;(W=b.onDirectionChange)==null||W.call(b,"C"),he(!1)},children:[m.jsx(N.Icon,{as:Q.PiAlignCenterHorizontal,boxSize:5,color:G}),m.jsx(N.Text,{fontSize:"sm",color:G,flex:1,whiteSpace:"nowrap",children:"Center"}),r==="C"&&m.jsx(N.Icon,{as:Q.PiCheck,boxSize:4,color:U})]})]})})]})]})})]})};Ap.displayName="BottomBar";const lv=q.memo(Ap),dv=e=>{const n=1/(Math.cbrt(e)*.8);let o=Math.round(650*n),i=Math.round(350*n);return o=Math.max(40,Math.min(450,o)),i=Math.max(30,Math.min(300,i)),{edgeSep:o,rankSep:i}},ft='"Helvetica Neue", Helvetica, sans-serif';let kr;const Qr=new Map;function iu(e,t){const r=`${t}|${e}`,n=Qr.get(r);if(n!==void 0)return n;kr===void 0&&(kr=typeof document<"u"?document.createElement("canvas").getContext("2d"):null);let o;return kr?(kr.font=t,o=kr.measureText(e).width):o=e.length*(parseFloat(t)||16)*.55,Qr.size>5e3&&Qr.clear(),Qr.set(r,o),o}function fv(e,t,r){const n=[];for(const o of String(e).split(`
|
|
2
|
-
`)){const i=o.split(/\s+/).filter(Boolean);if(!i.length){n.push("");continue}let a="";for(const s of i){const l=a?`${a} ${s}`:s;!a||iu(l,t)<=r?a=l:(n.push(a),a=s)}n.push(a)}return n}const hv=e=>e.stopPropagation();function pv({id:e,rect:t,label:r,style:n,onSelect:o}){const i=t.x2-t.x1,a=t.y2-t.y1,s=n.borderWidth,l=n.borderStyle==="dashed"?`${s*4} ${s*2}`:n.borderStyle==="dotted"?`${s} ${s}`:void 0,u=t.x1+i/2,c=n.labelPosition==="top"?t.y1+n.labelMargin-n.fontSize/2:n.labelPosition==="bottom"?t.y2-n.labelMargin+n.fontSize/2:t.y1+a/2;return m.jsxs("g",{className:"flow-sdk-container","data-node-id":e,onPointerDown:hv,onClick:d=>{d.stopPropagation(),o==null||o(e)},children:[m.jsx("rect",{x:t.x1,y:t.y1,width:i,height:a,rx:n.borderRadius,ry:n.borderRadius,fill:n.bgColor,fillOpacity:n.bgOpacity,stroke:n.borderColor,strokeWidth:n.borderStyle==="double"?s/3:s,strokeDasharray:l}),n.borderStyle==="double"&&m.jsx("rect",{x:t.x1+s*2/3,y:t.y1+s*2/3,width:Math.max(0,i-s*4/3),height:Math.max(0,a-s*4/3),rx:Math.max(0,n.borderRadius-s*2/3),ry:Math.max(0,n.borderRadius-s*2/3),fill:"none",stroke:n.borderColor,strokeWidth:s/3}),r&&m.jsx("text",{x:u,y:c,fill:n.textColor,fontSize:n.fontSize,fontWeight:"bold",fontFamily:ft,textAnchor:"middle",dominantBaseline:"central",children:r})]})}const gv=q.memo(pv),qr=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}),vv=e=>({x:(e.x1+e.x2)/2,y:(e.y1+e.y2)/2,w:e.x2-e.x1,h:e.y2-e.y1});function yv(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 bv=(e,t)=>e.x1<=t.x2&&e.x2>=t.x1&&e.y1<=t.y2&&e.y2>=t.y1,Ou=(e,t)=>e.x>=t.x1&&e.x<=t.x2&&e.y>=t.y1&&e.y<=t.y2,Cr=e=>(Math.round(e*10)/10).toString(),Be=e=>`${Cr(e.x)} ${Cr(e.y)}`,mv=e=>e>0?1:e<0?-1:0,ju=(e,t)=>e>0?Math.max(e-t,0):Math.min(e+t,0);function xv(e,t,r,n,o=10){const i=t.x-e.x,a=t.y-e.y,s=ju(i,(e.w+t.w)/2),l=ju(a,(e.h+t.h)/2),u=r==="downward"||r==="upward",c=u?l:s,d=u?a:i,f=mv(d),p=n*c,x=h=>Math.abs(h)<o||Math.abs(h)>=Math.abs(c),y=x(p)||x(Math.abs(c)-Math.abs(p));let g;if(y)if(u)if(Math.abs(d)<=e.h/2){const h=(e.x+t.x)/2;g=[h,e.y,h,t.y]}else if(Math.abs(i)<=t.w/2){const h=(e.y+t.y)/2;g=[e.x,h,t.x,h]}else g=[e.x,t.y];else if(Math.abs(d)<=e.w/2){const h=(e.y+t.y)/2;g=[e.x,h,t.x,h]}else if(Math.abs(a)<=t.h/2){const h=(e.x+t.x)/2;g=[h,e.y,h,t.y]}else g=[t.x,e.y];else if(u){const h=e.y+p+e.h/2*f;g=[e.x,h,t.x,h]}else{const h=e.x+p+e.w/2*f;g=[h,e.y,h,t.y]}const v=[{x:e.x,y:e.y}];for(let h=0;h<g.length;h+=2)v.push({x:g[h],y:g[h+1]});return v.push({x:t.x,y:t.y}),v}function it(e,t,r){const n=t.x-e.x,o=t.y-e.y,i=n>0?(r.x2-e.x)/n:n<0?(r.x1-e.x)/n:1/0,a=o>0?(r.y2-e.y)/o:o<0?(r.y1-e.y)/o:1/0,s=Math.min(i,a);return!Number.isFinite(s)||s>=1||s<0?null:{x:e.x+n*s,y:e.y+o*s}}function ze(e,t,r){const n=e.x-t.x,o=e.y-t.y,i=Math.hypot(n,o);if(!i)return e;let a=(i-r)/i;return a<0&&(a=1e-5),{x:t.x+a*n,y:t.y+a*o}}function Ir(e,t,r){const n=e.x-t.x,o=e.y-t.y,i=Math.hypot(n,o)||1,a=n/i,s=o/i,l=.3*r,u=.15*r,c=e.x-a*l,d=e.y-s*l;return`M${Be(e)} L${Cr(c-s*u)} ${Cr(d+a*u)} L${Cr(c+s*u)} ${Cr(d-a*u)} Z`}function Lr(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 _v(e,t,r,n){const o={x:t.x-e.x,y:t.y-e.y},i={x:r.x-t.x,y:r.y-t.y},a=Math.hypot(o.x,o.y),s=Math.hypot(i.x,i.y),l=o.x*i.y-o.y*i.x;if(a<1e-6||s<1e-6||Math.abs(l)<1e-6)return{p1:t,b:t,p2:t,r:0};const u=Math.min(n,a/2,s/2);return{p1:{x:t.x-o.x/a*u,y:t.y-o.y/a*u},b:t,p2:{x:t.x+i.x/s*u,y:t.y+i.y/s*u},r:u}}function wv(e,t,r,n){const o=qr(t),i=qr(r);let a=-1,s=null;for(let g=0;g<e.length-1;g++){const v=it(e[g],e[g+1],o);if(v){a=g,s=v;break}}let l=-1,u=null;for(let g=e.length-1;g>0;g--){const v=it(e[g],e[g-1],i);if(v){l=g,u=v;break}}if(!s||!u||a>=l)return null;const c=e.slice(a+1,l),d=c[0]??u,f=c[c.length-1]??s;let p,x,y;if(n.arrowAt==="source"){const g=ze(s,d,n.srcDist);p=ze(s,d,n.srcDist+n.arrowGap),y=Ir(g,d,n.arrowSize)}else p=ze(s,d,n.srcDist);if(n.arrowAt==="target"){const g=ze(u,f,n.tgtDist);x=ze(u,f,n.tgtDist+n.arrowGap),y=Ir(g,f,n.arrowSize)}else x=ze(u,f,n.tgtDist);return Mp(p,c,x,y,n.radius)}function Mp(e,t,r,n,o){const i=[e,...t,r],a=[];let s=`M${Be(e)}`;for(let c=1;c<i.length-1;c++){const d=_v(i[c-1],i[c],i[c+1],o);a.push(d),d.r===0?s+=` L${Be(d.b)}`:s+=` L${Be(d.p1)} Q${Be(d.b)} ${Be(d.p2)}`}s+=` L${Be(r)}`;let l;const u=t.length;if(u===0)l={x:(e.x+r.x)/2,y:(e.y+r.y)/2,angle:Lr(r.x-e.x,r.y-e.y)};else if(u%2===0){const c=t[u/2-1],d=t[u/2];l={x:(c.x+d.x)/2,y:(c.y+d.y)/2,angle:Lr(d.x-c.x,d.y-c.y)}}else{const c=a[(u-1)/2];if(c.r===0){const d=i[(u-1)/2+2];l={x:c.b.x,y:c.b.y,angle:Lr(d.x-c.b.x,d.y-c.b.y)}}else l={x:.25*c.p1.x+.5*c.b.x+.25*c.p2.x,y:.25*c.p1.y+.5*c.b.y+.25*c.p2.y,angle:Lr(c.p2.x-c.p1.x,c.p2.y-c.p1.y)}}return{d:s,arrow:n,label:l}}function Cv(e,t,r,n,o,i,a){const s=r==="leftward"?-1:1,l={x:e.x+s*(e.w/2+a.srcDist),y:n??e.y},u={x:t.x-s*(t.w/2+a.tgtDist),y:o??t.y},c=Math.max(80,a.arrowGap+a.arrowSize*.3),d=l.x+s*c,f=u.x-s*c;let p;if(s*(f-d)>=0){const v=l.x+(u.x-l.x)*i,h=Math.max(Math.min(d,f),Math.min(Math.max(d,f),v));p=[{x:h,y:l.y},{x:h,y:u.y}]}else{const v=Math.min(e.y-e.h/2,t.y-t.h/2)-c*(1+i);p=[{x:d,y:l.y},{x:d,y:v},{x:f,y:v},{x:f,y:u.y}]}const x=a.arrowAt==="source"?ze(l,p[0],a.arrowGap):l,y=a.arrowAt==="target"?ze(u,p[p.length-1],a.arrowGap):u,g=a.arrowAt==="source"?Ir(l,p[0],a.arrowSize):a.arrowAt==="target"?Ir(u,p[p.length-1],a.arrowSize):void 0;return Mp(x,p,y,g,Math.min(a.radius,40))}function Ev(e,t,r,n,o){return wv(xv(e,t,r,n),e,t,o)}function Rv(e,t,r,n=-90,o=-60,i=350){const a=n*Math.PI/180,s=o*Math.PI/180,l=a-Math.PI/2,u=l-s/2,c=l+s/2,d=1.4*i*(t/3+1),f={x:e.x+Math.cos(u)*d,y:e.y+Math.sin(u)*d},p={x:e.x+Math.cos(c)*d,y:e.y+Math.sin(c)*d},x=qr(e),y={x:e.x,y:e.y},g=it(y,f,x),v=it(y,p,x);if(!g||!v)return null;const h={x:(f.x+p.x)/2,y:(f.y+p.y)/2};let b=ze(g,f,r.srcDist),_=ze(v,p,r.tgtDist),w;if(r.arrowAt==="target"){const R=_;_=ze(v,p,r.tgtDist+r.arrowGap),w=Ir(R,p,r.arrowSize)}else if(r.arrowAt==="source"){const R=b;b=ze(g,f,r.srcDist+r.arrowGap),w=Ir(R,f,r.arrowSize)}return{d:`M${Be(b)} Q${Be(f)} ${Be(h)} Q${Be(p)} ${Be(_)}`,arrow:w,label:{x:h.x,y:h.y,angle:Lr(p.x-f.x,p.y-f.y)}}}const au=6,Pp=3,Sv=Math.max(Math.pow(au*13.37,.9),29)*Pp,qv=au*Pp*2,ku=80,Iv=500,tt=45,Tv=200,et=15,Av=50,Nu=`${tt}px ${ft}`,Mv="32 18",Pv=e=>e.stopPropagation();function Ov({id:e,source:t,target:r,sourceProperty:n,targetProperty:o,sourceY:i,targetY:a,dir:s,turn:l,color:u,labelBg:c,label:d,dashed:f,animated:p,inverted:x,loopIndex:y=0,onSelect:g}){const v=q.useMemo(()=>{const E={srcDist:ku,tgtDist:ku,arrowGap:qv,arrowSize:Sv,radius:Iv,arrowAt:x?"source":"target"};return i!==void 0||a!==void 0?Cv(t,r,s,i,a,l,{...E,srcDist:18,tgtDist:18}):t.x===r.x&&t.y===r.y?Rv(t,y,{...E,srcDist:0,tgtDist:0}):Ev(t,r,s,l,E)},[t,r,i,a,s,l,x,y]),h=q.useMemo(()=>d?fv(d,Nu,Tv):[],[d]);if(!v)return null;const b=f||p?Mv:void 0,_=p?`flow-sdk-edge-anim${x?" flow-sdk-edge-anim-rev":""}`:void 0;let w=null;if(h.length){const E=Math.max(...h.map(I=>iu(I,Nu))),R=h.length*tt;w=m.jsxs("g",{className:"flow-sdk-edge-label",transform:`translate(${v.label.x} ${v.label.y}) rotate(${v.label.angle}) translate(${Av} 0)`,children:[m.jsx("rect",{x:-E/2-et,y:-R/2-et,width:E+2*et,height:R+2*et,fill:c}),m.jsx("text",{fill:u,fontSize:tt,fontFamily:ft,textAnchor:"middle",dominantBaseline:"central",children:h.map((I,A)=>m.jsx("tspan",{x:0,y:(A-(h.length-1)/2)*tt,children:I},A))})]})}return m.jsxs("g",{className:"flow-sdk-edge","data-edge-id":e,"data-source-property":n,"data-target-property":o,onPointerDown:Pv,onClick:E=>{E.stopPropagation(),g==null||g(e)},children:[m.jsx("path",{d:v.d,fill:"none",stroke:u,strokeWidth:au,strokeDasharray:b,className:_}),v.arrow&&m.jsx("path",{d:v.arrow,fill:u}),w,m.jsx("path",{className:"flow-sdk-edge-hit",d:v.d})]})}const Lu=q.memo(Ov);var rt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function jv(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function su(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 jt,Fu;function kv(){if(Fu)return jt;Fu=1;function e(){this.__data__=[],this.size=0}return jt=e,jt}var kt,Du;function Tr(){if(Du)return kt;Du=1;function e(t,r){return t===r||t!==t&&r!==r}return kt=e,kt}var Nt,Bu;function ht(){if(Bu)return Nt;Bu=1;var e=Tr();function t(r,n){for(var o=r.length;o--;)if(e(r[o][0],n))return o;return-1}return Nt=t,Nt}var Lt,zu;function Nv(){if(zu)return Lt;zu=1;var e=ht(),t=Array.prototype,r=t.splice;function n(o){var i=this.__data__,a=e(i,o);if(a<0)return!1;var s=i.length-1;return a==s?i.pop():r.call(i,a,1),--this.size,!0}return Lt=n,Lt}var Ft,$u;function Lv(){if($u)return Ft;$u=1;var e=ht();function t(r){var n=this.__data__,o=e(n,r);return o<0?void 0:n[o][1]}return Ft=t,Ft}var Dt,Gu;function Fv(){if(Gu)return Dt;Gu=1;var e=ht();function t(r){return e(this.__data__,r)>-1}return Dt=t,Dt}var Bt,Wu;function Dv(){if(Wu)return Bt;Wu=1;var e=ht();function t(r,n){var o=this.__data__,i=e(o,r);return i<0?(++this.size,o.push([r,n])):o[i][1]=n,this}return Bt=t,Bt}var zt,Hu;function pt(){if(Hu)return zt;Hu=1;var e=kv(),t=Nv(),r=Lv(),n=Fv(),o=Dv();function i(a){var s=-1,l=a==null?0:a.length;for(this.clear();++s<l;){var u=a[s];this.set(u[0],u[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,zt=i,zt}var $t,Vu;function Bv(){if(Vu)return $t;Vu=1;var e=pt();function t(){this.__data__=new e,this.size=0}return $t=t,$t}var Gt,Uu;function zv(){if(Uu)return Gt;Uu=1;function e(t){var r=this.__data__,n=r.delete(t);return this.size=r.size,n}return Gt=e,Gt}var Wt,Ku;function $v(){if(Ku)return Wt;Ku=1;function e(t){return this.__data__.get(t)}return Wt=e,Wt}var Ht,Zu;function Gv(){if(Zu)return Ht;Zu=1;function e(t){return this.__data__.has(t)}return Ht=e,Ht}var Vt,Yu;function Op(){if(Yu)return Vt;Yu=1;var e=typeof rt=="object"&&rt&&rt.Object===Object&&rt;return Vt=e,Vt}var Ut,Xu;function Ve(){if(Xu)return Ut;Xu=1;var e=Op(),t=typeof self=="object"&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return Ut=r,Ut}var Kt,Ju;function Ar(){if(Ju)return Kt;Ju=1;var e=Ve(),t=e.Symbol;return Kt=t,Kt}var Zt,Qu;function Wv(){if(Qu)return Zt;Qu=1;var e=Ar(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,o=e?e.toStringTag:void 0;function i(a){var s=r.call(a,o),l=a[o];try{a[o]=void 0;var u=!0}catch{}var c=n.call(a);return u&&(s?a[o]=l:delete a[o]),c}return Zt=i,Zt}var Yt,ec;function Hv(){if(ec)return Yt;ec=1;var e=Object.prototype,t=e.toString;function r(n){return t.call(n)}return Yt=r,Yt}var Xt,rc;function yr(){if(rc)return Xt;rc=1;var e=Ar(),t=Wv(),r=Hv(),n="[object Null]",o="[object Undefined]",i=e?e.toStringTag:void 0;function a(s){return s==null?s===void 0?o:n:i&&i in Object(s)?t(s):r(s)}return Xt=a,Xt}var Jt,tc;function Ge(){if(tc)return Jt;tc=1;function e(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}return Jt=e,Jt}var Qt,nc;function Ur(){if(nc)return Qt;nc=1;var e=yr(),t=Ge(),r="[object AsyncFunction]",n="[object Function]",o="[object GeneratorFunction]",i="[object Proxy]";function a(s){if(!t(s))return!1;var l=e(s);return l==n||l==o||l==r||l==i}return Qt=a,Qt}var en,oc;function Vv(){if(oc)return en;oc=1;var e=Ve(),t=e["__core-js_shared__"];return en=t,en}var rn,ic;function Uv(){if(ic)return rn;ic=1;var e=Vv(),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 rn=r,rn}var tn,ac;function jp(){if(ac)return tn;ac=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 tn=r,tn}var nn,sc;function Kv(){if(sc)return nn;sc=1;var e=Ur(),t=Uv(),r=Ge(),n=jp(),o=/[\\^$.*+?()[\]{}|]/g,i=/^\[object .+?Constructor\]$/,a=Function.prototype,s=Object.prototype,l=a.toString,u=s.hasOwnProperty,c=RegExp("^"+l.call(u).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function d(f){if(!r(f)||t(f))return!1;var p=e(f)?c:i;return p.test(n(f))}return nn=d,nn}var on,uc;function Zv(){if(uc)return on;uc=1;function e(t,r){return t==null?void 0:t[r]}return on=e,on}var an,cc;function br(){if(cc)return an;cc=1;var e=Kv(),t=Zv();function r(n,o){var i=t(n,o);return e(i)?i:void 0}return an=r,an}var sn,lc;function uu(){if(lc)return sn;lc=1;var e=br(),t=Ve(),r=e(t,"Map");return sn=r,sn}var un,dc;function gt(){if(dc)return un;dc=1;var e=br(),t=e(Object,"create");return un=t,un}var cn,fc;function Yv(){if(fc)return cn;fc=1;var e=gt();function t(){this.__data__=e?e(null):{},this.size=0}return cn=t,cn}var ln,hc;function Xv(){if(hc)return ln;hc=1;function e(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}return ln=e,ln}var dn,pc;function Jv(){if(pc)return dn;pc=1;var e=gt(),t="__lodash_hash_undefined__",r=Object.prototype,n=r.hasOwnProperty;function o(i){var a=this.__data__;if(e){var s=a[i];return s===t?void 0:s}return n.call(a,i)?a[i]:void 0}return dn=o,dn}var fn,gc;function Qv(){if(gc)return fn;gc=1;var e=gt(),t=Object.prototype,r=t.hasOwnProperty;function n(o){var i=this.__data__;return e?i[o]!==void 0:r.call(i,o)}return fn=n,fn}var hn,vc;function ey(){if(vc)return hn;vc=1;var e=gt(),t="__lodash_hash_undefined__";function r(n,o){var i=this.__data__;return this.size+=this.has(n)?0:1,i[n]=e&&o===void 0?t:o,this}return hn=r,hn}var pn,yc;function ry(){if(yc)return pn;yc=1;var e=Yv(),t=Xv(),r=Jv(),n=Qv(),o=ey();function i(a){var s=-1,l=a==null?0:a.length;for(this.clear();++s<l;){var u=a[s];this.set(u[0],u[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,pn=i,pn}var gn,bc;function ty(){if(bc)return gn;bc=1;var e=ry(),t=pt(),r=uu();function n(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}return gn=n,gn}var vn,mc;function ny(){if(mc)return vn;mc=1;function e(t){var r=typeof t;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?t!=="__proto__":t===null}return vn=e,vn}var yn,xc;function vt(){if(xc)return yn;xc=1;var e=ny();function t(r,n){var o=r.__data__;return e(n)?o[typeof n=="string"?"string":"hash"]:o.map}return yn=t,yn}var bn,_c;function oy(){if(_c)return bn;_c=1;var e=vt();function t(r){var n=e(this,r).delete(r);return this.size-=n?1:0,n}return bn=t,bn}var mn,wc;function iy(){if(wc)return mn;wc=1;var e=vt();function t(r){return e(this,r).get(r)}return mn=t,mn}var xn,Cc;function ay(){if(Cc)return xn;Cc=1;var e=vt();function t(r){return e(this,r).has(r)}return xn=t,xn}var _n,Ec;function sy(){if(Ec)return _n;Ec=1;var e=vt();function t(r,n){var o=e(this,r),i=o.size;return o.set(r,n),this.size+=o.size==i?0:1,this}return _n=t,_n}var wn,Rc;function cu(){if(Rc)return wn;Rc=1;var e=ty(),t=oy(),r=iy(),n=ay(),o=sy();function i(a){var s=-1,l=a==null?0:a.length;for(this.clear();++s<l;){var u=a[s];this.set(u[0],u[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,wn=i,wn}var Cn,Sc;function uy(){if(Sc)return Cn;Sc=1;var e=pt(),t=uu(),r=cu(),n=200;function o(i,a){var s=this.__data__;if(s instanceof e){var l=s.__data__;if(!t||l.length<n-1)return l.push([i,a]),this.size=++s.size,this;s=this.__data__=new r(l)}return s.set(i,a),this.size=s.size,this}return Cn=o,Cn}var En,qc;function yt(){if(qc)return En;qc=1;var e=pt(),t=Bv(),r=zv(),n=$v(),o=Gv(),i=uy();function a(s){var l=this.__data__=new e(s);this.size=l.size}return a.prototype.clear=t,a.prototype.delete=r,a.prototype.get=n,a.prototype.has=o,a.prototype.set=i,En=a,En}var Rn,Ic;function lu(){if(Ic)return Rn;Ic=1;function e(t,r){for(var n=-1,o=t==null?0:t.length;++n<o&&r(t[n],n,t)!==!1;);return t}return Rn=e,Rn}var Sn,Tc;function kp(){if(Tc)return Sn;Tc=1;var e=br(),t=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return Sn=t,Sn}var qn,Ac;function bt(){if(Ac)return qn;Ac=1;var e=kp();function t(r,n,o){n=="__proto__"&&e?e(r,n,{configurable:!0,enumerable:!0,value:o,writable:!0}):r[n]=o}return qn=t,qn}var In,Mc;function mt(){if(Mc)return In;Mc=1;var e=bt(),t=Tr(),r=Object.prototype,n=r.hasOwnProperty;function o(i,a,s){var l=i[a];(!(n.call(i,a)&&t(l,s))||s===void 0&&!(a in i))&&e(i,a,s)}return In=o,In}var Tn,Pc;function Kr(){if(Pc)return Tn;Pc=1;var e=mt(),t=bt();function r(n,o,i,a){var s=!i;i||(i={});for(var l=-1,u=o.length;++l<u;){var c=o[l],d=a?a(i[c],n[c],c,i,n):void 0;d===void 0&&(d=n[c]),s?t(i,c,d):e(i,c,d)}return i}return Tn=r,Tn}var An,Oc;function cy(){if(Oc)return An;Oc=1;function e(t,r){for(var n=-1,o=Array(t);++n<t;)o[n]=r(n);return o}return An=e,An}var Mn,jc;function Qe(){if(jc)return Mn;jc=1;function e(t){return t!=null&&typeof t=="object"}return Mn=e,Mn}var Pn,kc;function ly(){if(kc)return Pn;kc=1;var e=yr(),t=Qe(),r="[object Arguments]";function n(o){return t(o)&&e(o)==r}return Pn=n,Pn}var On,Nc;function Zr(){if(Nc)return On;Nc=1;var e=ly(),t=Qe(),r=Object.prototype,n=r.hasOwnProperty,o=r.propertyIsEnumerable,i=e((function(){return arguments})())?e:function(a){return t(a)&&n.call(a,"callee")&&!o.call(a,"callee")};return On=i,On}var jn,Lc;function Te(){if(Lc)return jn;Lc=1;var e=Array.isArray;return jn=e,jn}var Fr={exports:{}},kn,Fc;function dy(){if(Fc)return kn;Fc=1;function e(){return!1}return kn=e,kn}Fr.exports;var Dc;function Mr(){return Dc||(Dc=1,(function(e,t){var r=Ve(),n=dy(),o=t&&!t.nodeType&&t,i=o&&!0&&e&&!e.nodeType&&e,a=i&&i.exports===o,s=a?r.Buffer:void 0,l=s?s.isBuffer:void 0,u=l||n;e.exports=u})(Fr,Fr.exports)),Fr.exports}var Nn,Bc;function xt(){if(Bc)return Nn;Bc=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function r(n,o){var i=typeof n;return o=o??e,!!o&&(i=="number"||i!="symbol"&&t.test(n))&&n>-1&&n%1==0&&n<o}return Nn=r,Nn}var Ln,zc;function du(){if(zc)return Ln;zc=1;var e=9007199254740991;function t(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return Ln=t,Ln}var Fn,$c;function fy(){if($c)return Fn;$c=1;var e=yr(),t=du(),r=Qe(),n="[object Arguments]",o="[object Array]",i="[object Boolean]",a="[object Date]",s="[object Error]",l="[object Function]",u="[object Map]",c="[object Number]",d="[object Object]",f="[object RegExp]",p="[object Set]",x="[object String]",y="[object WeakMap]",g="[object ArrayBuffer]",v="[object DataView]",h="[object Float32Array]",b="[object Float64Array]",_="[object Int8Array]",w="[object Int16Array]",E="[object Int32Array]",R="[object Uint8Array]",I="[object Uint8ClampedArray]",A="[object Uint16Array]",k="[object Uint32Array]",M={};M[h]=M[b]=M[_]=M[w]=M[E]=M[R]=M[I]=M[A]=M[k]=!0,M[n]=M[o]=M[g]=M[i]=M[v]=M[a]=M[s]=M[l]=M[u]=M[c]=M[d]=M[f]=M[p]=M[x]=M[y]=!1;function z(G){return r(G)&&t(G.length)&&!!M[e(G)]}return Fn=z,Fn}var Dn,Gc;function _t(){if(Gc)return Dn;Gc=1;function e(t){return function(r){return t(r)}}return Dn=e,Dn}var Dr={exports:{}};Dr.exports;var Wc;function fu(){return Wc||(Wc=1,(function(e,t){var r=Op(),n=t&&!t.nodeType&&t,o=n&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===n,a=i&&r.process,s=(function(){try{var l=o&&o.require&&o.require("util").types;return l||a&&a.binding&&a.binding("util")}catch{}})();e.exports=s})(Dr,Dr.exports)),Dr.exports}var Bn,Hc;function Yr(){if(Hc)return Bn;Hc=1;var e=fy(),t=_t(),r=fu(),n=r&&r.isTypedArray,o=n?t(n):e;return Bn=o,Bn}var zn,Vc;function Np(){if(Vc)return zn;Vc=1;var e=cy(),t=Zr(),r=Te(),n=Mr(),o=xt(),i=Yr(),a=Object.prototype,s=a.hasOwnProperty;function l(u,c){var d=r(u),f=!d&&t(u),p=!d&&!f&&n(u),x=!d&&!f&&!p&&i(u),y=d||f||p||x,g=y?e(u.length,String):[],v=g.length;for(var h in u)(c||s.call(u,h))&&!(y&&(h=="length"||p&&(h=="offset"||h=="parent")||x&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||o(h,v)))&&g.push(h);return g}return zn=l,zn}var $n,Uc;function wt(){if(Uc)return $n;Uc=1;var e=Object.prototype;function t(r){var n=r&&r.constructor,o=typeof n=="function"&&n.prototype||e;return r===o}return $n=t,$n}var Gn,Kc;function Lp(){if(Kc)return Gn;Kc=1;function e(t,r){return function(n){return t(r(n))}}return Gn=e,Gn}var Wn,Zc;function hy(){if(Zc)return Wn;Zc=1;var e=Lp(),t=e(Object.keys,Object);return Wn=t,Wn}var Hn,Yc;function hu(){if(Yc)return Hn;Yc=1;var e=wt(),t=hy(),r=Object.prototype,n=r.hasOwnProperty;function o(i){if(!e(i))return t(i);var a=[];for(var s in Object(i))n.call(i,s)&&s!="constructor"&&a.push(s);return a}return Hn=o,Hn}var Vn,Xc;function rr(){if(Xc)return Vn;Xc=1;var e=Ur(),t=du();function r(n){return n!=null&&t(n.length)&&!e(n)}return Vn=r,Vn}var Un,Jc;function cr(){if(Jc)return Un;Jc=1;var e=Np(),t=hu(),r=rr();function n(o){return r(o)?e(o):t(o)}return Un=n,Un}var Kn,Qc;function py(){if(Qc)return Kn;Qc=1;var e=Kr(),t=cr();function r(n,o){return n&&e(o,t(o),n)}return Kn=r,Kn}var Zn,el;function gy(){if(el)return Zn;el=1;function e(t){var r=[];if(t!=null)for(var n in Object(t))r.push(n);return r}return Zn=e,Zn}var Yn,rl;function vy(){if(rl)return Yn;rl=1;var e=Ge(),t=wt(),r=gy(),n=Object.prototype,o=n.hasOwnProperty;function i(a){if(!e(a))return r(a);var s=t(a),l=[];for(var u in a)u=="constructor"&&(s||!o.call(a,u))||l.push(u);return l}return Yn=i,Yn}var Xn,tl;function mr(){if(tl)return Xn;tl=1;var e=Np(),t=vy(),r=rr();function n(o){return r(o)?e(o,!0):t(o)}return Xn=n,Xn}var Jn,nl;function yy(){if(nl)return Jn;nl=1;var e=Kr(),t=mr();function r(n,o){return n&&e(o,t(o),n)}return Jn=r,Jn}var Br={exports:{}};Br.exports;var ol;function Fp(){return ol||(ol=1,(function(e,t){var r=Ve(),n=t&&!t.nodeType&&t,o=n&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===n,a=i?r.Buffer:void 0,s=a?a.allocUnsafe:void 0;function l(u,c){if(c)return u.slice();var d=u.length,f=s?s(d):new u.constructor(d);return u.copy(f),f}e.exports=l})(Br,Br.exports)),Br.exports}var Qn,il;function Dp(){if(il)return Qn;il=1;function e(t,r){var n=-1,o=t.length;for(r||(r=Array(o));++n<o;)r[n]=t[n];return r}return Qn=e,Qn}var eo,al;function Bp(){if(al)return eo;al=1;function e(t,r){for(var n=-1,o=t==null?0:t.length,i=0,a=[];++n<o;){var s=t[n];r(s,n,t)&&(a[i++]=s)}return a}return eo=e,eo}var ro,sl;function zp(){if(sl)return ro;sl=1;function e(){return[]}return ro=e,ro}var to,ul;function pu(){if(ul)return to;ul=1;var e=Bp(),t=zp(),r=Object.prototype,n=r.propertyIsEnumerable,o=Object.getOwnPropertySymbols,i=o?function(a){return a==null?[]:(a=Object(a),e(o(a),function(s){return n.call(a,s)}))}:t;return to=i,to}var no,cl;function by(){if(cl)return no;cl=1;var e=Kr(),t=pu();function r(n,o){return e(n,t(n),o)}return no=r,no}var oo,ll;function gu(){if(ll)return oo;ll=1;function e(t,r){for(var n=-1,o=r.length,i=t.length;++n<o;)t[i+n]=r[n];return t}return oo=e,oo}var io,dl;function Ct(){if(dl)return io;dl=1;var e=Lp(),t=e(Object.getPrototypeOf,Object);return io=t,io}var ao,fl;function $p(){if(fl)return ao;fl=1;var e=gu(),t=Ct(),r=pu(),n=zp(),o=Object.getOwnPropertySymbols,i=o?function(a){for(var s=[];a;)e(s,r(a)),a=t(a);return s}:n;return ao=i,ao}var so,hl;function my(){if(hl)return so;hl=1;var e=Kr(),t=$p();function r(n,o){return e(n,t(n),o)}return so=r,so}var uo,pl;function Gp(){if(pl)return uo;pl=1;var e=gu(),t=Te();function r(n,o,i){var a=o(n);return t(n)?a:e(a,i(n))}return uo=r,uo}var co,gl;function Wp(){if(gl)return co;gl=1;var e=Gp(),t=pu(),r=cr();function n(o){return e(o,r,t)}return co=n,co}var lo,vl;function xy(){if(vl)return lo;vl=1;var e=Gp(),t=$p(),r=mr();function n(o){return e(o,r,t)}return lo=n,lo}var fo,yl;function _y(){if(yl)return fo;yl=1;var e=br(),t=Ve(),r=e(t,"DataView");return fo=r,fo}var ho,bl;function wy(){if(bl)return ho;bl=1;var e=br(),t=Ve(),r=e(t,"Promise");return ho=r,ho}var po,ml;function Hp(){if(ml)return po;ml=1;var e=br(),t=Ve(),r=e(t,"Set");return po=r,po}var go,xl;function Cy(){if(xl)return go;xl=1;var e=br(),t=Ve(),r=e(t,"WeakMap");return go=r,go}var vo,_l;function Pr(){if(_l)return vo;_l=1;var e=_y(),t=uu(),r=wy(),n=Hp(),o=Cy(),i=yr(),a=jp(),s="[object Map]",l="[object Object]",u="[object Promise]",c="[object Set]",d="[object WeakMap]",f="[object DataView]",p=a(e),x=a(t),y=a(r),g=a(n),v=a(o),h=i;return(e&&h(new e(new ArrayBuffer(1)))!=f||t&&h(new t)!=s||r&&h(r.resolve())!=u||n&&h(new n)!=c||o&&h(new o)!=d)&&(h=function(b){var _=i(b),w=_==l?b.constructor:void 0,E=w?a(w):"";if(E)switch(E){case p:return f;case x:return s;case y:return u;case g:return c;case v:return d}return _}),vo=h,vo}var yo,wl;function Ey(){if(wl)return yo;wl=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n){var o=n.length,i=new n.constructor(o);return o&&typeof n[0]=="string"&&t.call(n,"index")&&(i.index=n.index,i.input=n.input),i}return yo=r,yo}var bo,Cl;function Vp(){if(Cl)return bo;Cl=1;var e=Ve(),t=e.Uint8Array;return bo=t,bo}var mo,El;function vu(){if(El)return mo;El=1;var e=Vp();function t(r){var n=new r.constructor(r.byteLength);return new e(n).set(new e(r)),n}return mo=t,mo}var xo,Rl;function Ry(){if(Rl)return xo;Rl=1;var e=vu();function t(r,n){var o=n?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.byteLength)}return xo=t,xo}var _o,Sl;function Sy(){if(Sl)return _o;Sl=1;var e=/\w*$/;function t(r){var n=new r.constructor(r.source,e.exec(r));return n.lastIndex=r.lastIndex,n}return _o=t,_o}var wo,ql;function qy(){if(ql)return wo;ql=1;var e=Ar(),t=e?e.prototype:void 0,r=t?t.valueOf:void 0;function n(o){return r?Object(r.call(o)):{}}return wo=n,wo}var Co,Il;function Up(){if(Il)return Co;Il=1;var e=vu();function t(r,n){var o=n?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.length)}return Co=t,Co}var Eo,Tl;function Iy(){if(Tl)return Eo;Tl=1;var e=vu(),t=Ry(),r=Sy(),n=qy(),o=Up(),i="[object Boolean]",a="[object Date]",s="[object Map]",l="[object Number]",u="[object RegExp]",c="[object Set]",d="[object String]",f="[object Symbol]",p="[object ArrayBuffer]",x="[object DataView]",y="[object Float32Array]",g="[object Float64Array]",v="[object Int8Array]",h="[object Int16Array]",b="[object Int32Array]",_="[object Uint8Array]",w="[object Uint8ClampedArray]",E="[object Uint16Array]",R="[object Uint32Array]";function I(A,k,M){var z=A.constructor;switch(k){case p:return e(A);case i:case a:return new z(+A);case x:return t(A,M);case y:case g:case v:case h:case b:case _:case w:case E:case R:return o(A,M);case s:return new z;case l:case d:return new z(A);case u:return r(A);case c:return new z;case f:return n(A)}}return Eo=I,Eo}var Ro,Al;function Kp(){if(Al)return Ro;Al=1;var e=Ge(),t=Object.create,r=(function(){function n(){}return function(o){if(!e(o))return{};if(t)return t(o);n.prototype=o;var i=new n;return n.prototype=void 0,i}})();return Ro=r,Ro}var So,Ml;function Zp(){if(Ml)return So;Ml=1;var e=Kp(),t=Ct(),r=wt();function n(o){return typeof o.constructor=="function"&&!r(o)?e(t(o)):{}}return So=n,So}var qo,Pl;function Ty(){if(Pl)return qo;Pl=1;var e=Pr(),t=Qe(),r="[object Map]";function n(o){return t(o)&&e(o)==r}return qo=n,qo}var Io,Ol;function Ay(){if(Ol)return Io;Ol=1;var e=Ty(),t=_t(),r=fu(),n=r&&r.isMap,o=n?t(n):e;return Io=o,Io}var To,jl;function My(){if(jl)return To;jl=1;var e=Pr(),t=Qe(),r="[object Set]";function n(o){return t(o)&&e(o)==r}return To=n,To}var Ao,kl;function Py(){if(kl)return Ao;kl=1;var e=My(),t=_t(),r=fu(),n=r&&r.isSet,o=n?t(n):e;return Ao=o,Ao}var Mo,Nl;function Yp(){if(Nl)return Mo;Nl=1;var e=yt(),t=lu(),r=mt(),n=py(),o=yy(),i=Fp(),a=Dp(),s=by(),l=my(),u=Wp(),c=xy(),d=Pr(),f=Ey(),p=Iy(),x=Zp(),y=Te(),g=Mr(),v=Ay(),h=Ge(),b=Py(),_=cr(),w=mr(),E=1,R=2,I=4,A="[object Arguments]",k="[object Array]",M="[object Boolean]",z="[object Date]",G="[object Error]",U="[object Function]",V="[object GeneratorFunction]",X="[object Map]",he="[object Number]",ee="[object Object]",Y="[object RegExp]",oe="[object Set]",pe="[object String]",fe="[object Symbol]",ge="[object WeakMap]",S="[object ArrayBuffer]",O="[object DataView]",D="[object Float32Array]",F="[object Float64Array]",Z="[object Int8Array]",ne="[object Int16Array]",re="[object Int32Array]",ue="[object Uint8Array]",Ce="[object Uint8ClampedArray]",ie="[object Uint16Array]",ve="[object Uint32Array]",W={};W[A]=W[k]=W[S]=W[O]=W[M]=W[z]=W[D]=W[F]=W[Z]=W[ne]=W[re]=W[X]=W[he]=W[ee]=W[Y]=W[oe]=W[pe]=W[fe]=W[ue]=W[Ce]=W[ie]=W[ve]=!0,W[G]=W[U]=W[ge]=!1;function ye(K,we,Ae,Ie,Fe,xe){var qe,Ue=we&E,Ke=we&R,lr=we&I;if(Ae&&(qe=Fe?Ae(K,Ie,Fe,xe):Ae(K)),qe!==void 0)return qe;if(!h(K))return K;var _r=y(K);if(_r){if(qe=f(K),!Ue)return a(K,qe)}else{var Ze=d(K),dr=Ze==U||Ze==V;if(g(K))return i(K,Ue);if(Ze==ee||Ze==A||dr&&!Fe){if(qe=Ke||dr?{}:x(K),!Ue)return Ke?l(K,o(qe,K)):s(K,n(qe,K))}else{if(!W[Ze])return Fe?K:{};qe=p(K,Ze,Ue)}}xe||(xe=new e);var De=xe.get(K);if(De)return De;xe.set(K,qe),b(K)?K.forEach(function($){qe.add(ye($,we,Ae,$,K,xe))}):v(K)&&K.forEach(function($,L){qe.set(L,ye($,we,Ae,L,K,xe))});var jr=lr?Ke?c:u:Ke?w:_,fr=_r?void 0:jr(K);return t(fr||K,function($,L){fr&&(L=$,$=K[L]),r(qe,L,ye($,we,Ae,L,K,xe))}),qe}return Mo=ye,Mo}var Po,Ll;function Oy(){if(Ll)return Po;Ll=1;var e=Yp(),t=4;function r(n){return e(n,t)}return Po=r,Po}var Oo,Fl;function yu(){if(Fl)return Oo;Fl=1;function e(t){return function(){return t}}return Oo=e,Oo}var jo,Dl;function jy(){if(Dl)return jo;Dl=1;function e(t){return function(r,n,o){for(var i=-1,a=Object(r),s=o(r),l=s.length;l--;){var u=s[t?l:++i];if(n(a[u],u,a)===!1)break}return r}}return jo=e,jo}var ko,Bl;function bu(){if(Bl)return ko;Bl=1;var e=jy(),t=e();return ko=t,ko}var No,zl;function mu(){if(zl)return No;zl=1;var e=bu(),t=cr();function r(n,o){return n&&e(n,o,t)}return No=r,No}var Lo,$l;function ky(){if($l)return Lo;$l=1;var e=rr();function t(r,n){return function(o,i){if(o==null)return o;if(!e(o))return r(o,i);for(var a=o.length,s=n?a:-1,l=Object(o);(n?s--:++s<a)&&i(l[s],s,l)!==!1;);return o}}return Lo=t,Lo}var Fo,Gl;function Et(){if(Gl)return Fo;Gl=1;var e=mu(),t=ky(),r=t(e);return Fo=r,Fo}var Do,Wl;function xr(){if(Wl)return Do;Wl=1;function e(t){return t}return Do=e,Do}var Bo,Hl;function Xp(){if(Hl)return Bo;Hl=1;var e=xr();function t(r){return typeof r=="function"?r:e}return Bo=t,Bo}var zo,Vl;function Jp(){if(Vl)return zo;Vl=1;var e=lu(),t=Et(),r=Xp(),n=Te();function o(i,a){var s=n(i)?e:t;return s(i,r(a))}return zo=o,zo}var $o,Ul;function Qp(){return Ul||(Ul=1,$o=Jp()),$o}var Go,Kl;function Ny(){if(Kl)return Go;Kl=1;var e=Et();function t(r,n){var o=[];return e(r,function(i,a,s){n(i,a,s)&&o.push(i)}),o}return Go=t,Go}var Wo,Zl;function Ly(){if(Zl)return Wo;Zl=1;var e="__lodash_hash_undefined__";function t(r){return this.__data__.set(r,e),this}return Wo=t,Wo}var Ho,Yl;function Fy(){if(Yl)return Ho;Yl=1;function e(t){return this.__data__.has(t)}return Ho=e,Ho}var Vo,Xl;function eg(){if(Xl)return Vo;Xl=1;var e=cu(),t=Ly(),r=Fy();function n(o){var i=-1,a=o==null?0:o.length;for(this.__data__=new e;++i<a;)this.add(o[i])}return n.prototype.add=n.prototype.push=t,n.prototype.has=r,Vo=n,Vo}var Uo,Jl;function Dy(){if(Jl)return Uo;Jl=1;function e(t,r){for(var n=-1,o=t==null?0:t.length;++n<o;)if(r(t[n],n,t))return!0;return!1}return Uo=e,Uo}var Ko,Ql;function rg(){if(Ql)return Ko;Ql=1;function e(t,r){return t.has(r)}return Ko=e,Ko}var Zo,ed;function tg(){if(ed)return Zo;ed=1;var e=eg(),t=Dy(),r=rg(),n=1,o=2;function i(a,s,l,u,c,d){var f=l&n,p=a.length,x=s.length;if(p!=x&&!(f&&x>p))return!1;var y=d.get(a),g=d.get(s);if(y&&g)return y==s&&g==a;var v=-1,h=!0,b=l&o?new e:void 0;for(d.set(a,s),d.set(s,a);++v<p;){var _=a[v],w=s[v];if(u)var E=f?u(w,_,v,s,a,d):u(_,w,v,a,s,d);if(E!==void 0){if(E)continue;h=!1;break}if(b){if(!t(s,function(R,I){if(!r(b,I)&&(_===R||c(_,R,l,u,d)))return b.push(I)})){h=!1;break}}else if(!(_===w||c(_,w,l,u,d))){h=!1;break}}return d.delete(a),d.delete(s),h}return Zo=i,Zo}var Yo,rd;function By(){if(rd)return Yo;rd=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(o,i){n[++r]=[i,o]}),n}return Yo=e,Yo}var Xo,td;function xu(){if(td)return Xo;td=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(o){n[++r]=o}),n}return Xo=e,Xo}var Jo,nd;function zy(){if(nd)return Jo;nd=1;var e=Ar(),t=Vp(),r=Tr(),n=tg(),o=By(),i=xu(),a=1,s=2,l="[object Boolean]",u="[object Date]",c="[object Error]",d="[object Map]",f="[object Number]",p="[object RegExp]",x="[object Set]",y="[object String]",g="[object Symbol]",v="[object ArrayBuffer]",h="[object DataView]",b=e?e.prototype:void 0,_=b?b.valueOf:void 0;function w(E,R,I,A,k,M,z){switch(I){case h:if(E.byteLength!=R.byteLength||E.byteOffset!=R.byteOffset)return!1;E=E.buffer,R=R.buffer;case v:return!(E.byteLength!=R.byteLength||!M(new t(E),new t(R)));case l:case u:case f:return r(+E,+R);case c:return E.name==R.name&&E.message==R.message;case p:case y:return E==R+"";case d:var G=o;case x:var U=A&a;if(G||(G=i),E.size!=R.size&&!U)return!1;var V=z.get(E);if(V)return V==R;A|=s,z.set(E,R);var X=n(G(E),G(R),A,k,M,z);return z.delete(E),X;case g:if(_)return _.call(E)==_.call(R)}return!1}return Jo=w,Jo}var Qo,od;function $y(){if(od)return Qo;od=1;var e=Wp(),t=1,r=Object.prototype,n=r.hasOwnProperty;function o(i,a,s,l,u,c){var d=s&t,f=e(i),p=f.length,x=e(a),y=x.length;if(p!=y&&!d)return!1;for(var g=p;g--;){var v=f[g];if(!(d?v in a:n.call(a,v)))return!1}var h=c.get(i),b=c.get(a);if(h&&b)return h==a&&b==i;var _=!0;c.set(i,a),c.set(a,i);for(var w=d;++g<p;){v=f[g];var E=i[v],R=a[v];if(l)var I=d?l(R,E,v,a,i,c):l(E,R,v,i,a,c);if(!(I===void 0?E===R||u(E,R,s,l,c):I)){_=!1;break}w||(w=v=="constructor")}if(_&&!w){var A=i.constructor,k=a.constructor;A!=k&&"constructor"in i&&"constructor"in a&&!(typeof A=="function"&&A instanceof A&&typeof k=="function"&&k instanceof k)&&(_=!1)}return c.delete(i),c.delete(a),_}return Qo=o,Qo}var ei,id;function Gy(){if(id)return ei;id=1;var e=yt(),t=tg(),r=zy(),n=$y(),o=Pr(),i=Te(),a=Mr(),s=Yr(),l=1,u="[object Arguments]",c="[object Array]",d="[object Object]",f=Object.prototype,p=f.hasOwnProperty;function x(y,g,v,h,b,_){var w=i(y),E=i(g),R=w?c:o(y),I=E?c:o(g);R=R==u?d:R,I=I==u?d:I;var A=R==d,k=I==d,M=R==I;if(M&&a(y)){if(!a(g))return!1;w=!0,A=!1}if(M&&!A)return _||(_=new e),w||s(y)?t(y,g,v,h,b,_):r(y,g,R,v,h,b,_);if(!(v&l)){var z=A&&p.call(y,"__wrapped__"),G=k&&p.call(g,"__wrapped__");if(z||G){var U=z?y.value():y,V=G?g.value():g;return _||(_=new e),b(U,V,v,h,_)}}return M?(_||(_=new e),n(y,g,v,h,b,_)):!1}return ei=x,ei}var ri,ad;function ng(){if(ad)return ri;ad=1;var e=Gy(),t=Qe();function r(n,o,i,a,s){return n===o?!0:n==null||o==null||!t(n)&&!t(o)?n!==n&&o!==o:e(n,o,i,a,r,s)}return ri=r,ri}var ti,sd;function Wy(){if(sd)return ti;sd=1;var e=yt(),t=ng(),r=1,n=2;function o(i,a,s,l){var u=s.length,c=u,d=!l;if(i==null)return!c;for(i=Object(i);u--;){var f=s[u];if(d&&f[2]?f[1]!==i[f[0]]:!(f[0]in i))return!1}for(;++u<c;){f=s[u];var p=f[0],x=i[p],y=f[1];if(d&&f[2]){if(x===void 0&&!(p in i))return!1}else{var g=new e;if(l)var v=l(x,y,p,i,a,g);if(!(v===void 0?t(y,x,r|n,l,g):v))return!1}}return!0}return ti=o,ti}var ni,ud;function og(){if(ud)return ni;ud=1;var e=Ge();function t(r){return r===r&&!e(r)}return ni=t,ni}var oi,cd;function Hy(){if(cd)return oi;cd=1;var e=og(),t=cr();function r(n){for(var o=t(n),i=o.length;i--;){var a=o[i],s=n[a];o[i]=[a,s,e(s)]}return o}return oi=r,oi}var ii,ld;function ig(){if(ld)return ii;ld=1;function e(t,r){return function(n){return n==null?!1:n[t]===r&&(r!==void 0||t in Object(n))}}return ii=e,ii}var ai,dd;function Vy(){if(dd)return ai;dd=1;var e=Wy(),t=Hy(),r=ig();function n(o){var i=t(o);return i.length==1&&i[0][2]?r(i[0][0],i[0][1]):function(a){return a===o||e(a,o,i)}}return ai=n,ai}var si,fd;function Or(){if(fd)return si;fd=1;var e=yr(),t=Qe(),r="[object Symbol]";function n(o){return typeof o=="symbol"||t(o)&&e(o)==r}return si=n,si}var ui,hd;function _u(){if(hd)return ui;hd=1;var e=Te(),t=Or(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function o(i,a){if(e(i))return!1;var s=typeof i;return s=="number"||s=="symbol"||s=="boolean"||i==null||t(i)?!0:n.test(i)||!r.test(i)||a!=null&&i in Object(a)}return ui=o,ui}var ci,pd;function Uy(){if(pd)return ci;pd=1;var e=cu(),t="Expected a function";function r(n,o){if(typeof n!="function"||o!=null&&typeof o!="function")throw new TypeError(t);var i=function(){var a=arguments,s=o?o.apply(this,a):a[0],l=i.cache;if(l.has(s))return l.get(s);var u=n.apply(this,a);return i.cache=l.set(s,u)||l,u};return i.cache=new(r.Cache||e),i}return r.Cache=e,ci=r,ci}var li,gd;function Ky(){if(gd)return li;gd=1;var e=Uy(),t=500;function r(n){var o=e(n,function(a){return i.size===t&&i.clear(),a}),i=o.cache;return o}return li=r,li}var di,vd;function Zy(){if(vd)return di;vd=1;var e=Ky(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=e(function(o){var i=[];return o.charCodeAt(0)===46&&i.push(""),o.replace(t,function(a,s,l,u){i.push(l?u.replace(r,"$1"):s||a)}),i});return di=n,di}var fi,yd;function Rt(){if(yd)return fi;yd=1;function e(t,r){for(var n=-1,o=t==null?0:t.length,i=Array(o);++n<o;)i[n]=r(t[n],n,t);return i}return fi=e,fi}var hi,bd;function Yy(){if(bd)return hi;bd=1;var e=Ar(),t=Rt(),r=Te(),n=Or(),o=e?e.prototype:void 0,i=o?o.toString:void 0;function a(s){if(typeof s=="string")return s;if(r(s))return t(s,a)+"";if(n(s))return i?i.call(s):"";var l=s+"";return l=="0"&&1/s==-1/0?"-0":l}return hi=a,hi}var pi,md;function ag(){if(md)return pi;md=1;var e=Yy();function t(r){return r==null?"":e(r)}return pi=t,pi}var gi,xd;function St(){if(xd)return gi;xd=1;var e=Te(),t=_u(),r=Zy(),n=ag();function o(i,a){return e(i)?i:t(i,a)?[i]:r(n(i))}return gi=o,gi}var vi,_d;function Xr(){if(_d)return vi;_d=1;var e=Or();function t(r){if(typeof r=="string"||e(r))return r;var n=r+"";return n=="0"&&1/r==-1/0?"-0":n}return vi=t,vi}var yi,wd;function qt(){if(wd)return yi;wd=1;var e=St(),t=Xr();function r(n,o){o=e(o,n);for(var i=0,a=o.length;n!=null&&i<a;)n=n[t(o[i++])];return i&&i==a?n:void 0}return yi=r,yi}var bi,Cd;function Xy(){if(Cd)return bi;Cd=1;var e=qt();function t(r,n,o){var i=r==null?void 0:e(r,n);return i===void 0?o:i}return bi=t,bi}var mi,Ed;function Jy(){if(Ed)return mi;Ed=1;function e(t,r){return t!=null&&r in Object(t)}return mi=e,mi}var xi,Rd;function sg(){if(Rd)return xi;Rd=1;var e=St(),t=Zr(),r=Te(),n=xt(),o=du(),i=Xr();function a(s,l,u){l=e(l,s);for(var c=-1,d=l.length,f=!1;++c<d;){var p=i(l[c]);if(!(f=s!=null&&u(s,p)))break;s=s[p]}return f||++c!=d?f:(d=s==null?0:s.length,!!d&&o(d)&&n(p,d)&&(r(s)||t(s)))}return xi=a,xi}var _i,Sd;function ug(){if(Sd)return _i;Sd=1;var e=Jy(),t=sg();function r(n,o){return n!=null&&t(n,o,e)}return _i=r,_i}var wi,qd;function Qy(){if(qd)return wi;qd=1;var e=ng(),t=Xy(),r=ug(),n=_u(),o=og(),i=ig(),a=Xr(),s=1,l=2;function u(c,d){return n(c)&&o(d)?i(a(c),d):function(f){var p=t(f,c);return p===void 0&&p===d?r(f,c):e(d,p,s|l)}}return wi=u,wi}var Ci,Id;function cg(){if(Id)return Ci;Id=1;function e(t){return function(r){return r==null?void 0:r[t]}}return Ci=e,Ci}var Ei,Td;function eb(){if(Td)return Ei;Td=1;var e=qt();function t(r){return function(n){return e(n,r)}}return Ei=t,Ei}var Ri,Ad;function rb(){if(Ad)return Ri;Ad=1;var e=cg(),t=eb(),r=_u(),n=Xr();function o(i){return r(i)?e(n(i)):t(i)}return Ri=o,Ri}var Si,Md;function tr(){if(Md)return Si;Md=1;var e=Vy(),t=Qy(),r=xr(),n=Te(),o=rb();function i(a){return typeof a=="function"?a:a==null?r:typeof a=="object"?n(a)?t(a[0],a[1]):e(a):o(a)}return Si=i,Si}var qi,Pd;function lg(){if(Pd)return qi;Pd=1;var e=Bp(),t=Ny(),r=tr(),n=Te();function o(i,a){var s=n(i)?e:t;return s(i,r(a,3))}return qi=o,qi}var Ii,Od;function tb(){if(Od)return Ii;Od=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n,o){return n!=null&&t.call(n,o)}return Ii=r,Ii}var Ti,jd;function dg(){if(jd)return Ti;jd=1;var e=tb(),t=sg();function r(n,o){return n!=null&&t(n,o,e)}return Ti=r,Ti}var Ai,kd;function nb(){if(kd)return Ai;kd=1;var e=hu(),t=Pr(),r=Zr(),n=Te(),o=rr(),i=Mr(),a=wt(),s=Yr(),l="[object Map]",u="[object Set]",c=Object.prototype,d=c.hasOwnProperty;function f(p){if(p==null)return!0;if(o(p)&&(n(p)||typeof p=="string"||typeof p.splice=="function"||i(p)||s(p)||r(p)))return!p.length;var x=t(p);if(x==l||x==u)return!p.size;if(a(p))return!e(p).length;for(var y in p)if(d.call(p,y))return!1;return!0}return Ai=f,Ai}var Mi,Nd;function fg(){if(Nd)return Mi;Nd=1;function e(t){return t===void 0}return Mi=e,Mi}var Pi,Ld;function hg(){if(Ld)return Pi;Ld=1;var e=Et(),t=rr();function r(n,o){var i=-1,a=t(n)?Array(n.length):[];return e(n,function(s,l,u){a[++i]=o(s,l,u)}),a}return Pi=r,Pi}var Oi,Fd;function pg(){if(Fd)return Oi;Fd=1;var e=Rt(),t=tr(),r=hg(),n=Te();function o(i,a){var s=n(i)?e:r;return s(i,t(a,3))}return Oi=o,Oi}var ji,Dd;function ob(){if(Dd)return ji;Dd=1;function e(t,r,n,o){var i=-1,a=t==null?0:t.length;for(o&&a&&(n=t[++i]);++i<a;)n=r(n,t[i],i,t);return n}return ji=e,ji}var ki,Bd;function ib(){if(Bd)return ki;Bd=1;function e(t,r,n,o,i){return i(t,function(a,s,l){n=o?(o=!1,a):r(n,a,s,l)}),n}return ki=e,ki}var Ni,zd;function gg(){if(zd)return Ni;zd=1;var e=ob(),t=Et(),r=tr(),n=ib(),o=Te();function i(a,s,l){var u=o(a)?e:n,c=arguments.length<3;return u(a,r(s,4),l,c,t)}return Ni=i,Ni}var Li,$d;function ab(){if($d)return Li;$d=1;var e=yr(),t=Te(),r=Qe(),n="[object String]";function o(i){return typeof i=="string"||!t(i)&&r(i)&&e(i)==n}return Li=o,Li}var Fi,Gd;function sb(){if(Gd)return Fi;Gd=1;var e=cg(),t=e("length");return Fi=t,Fi}var Di,Wd;function ub(){if(Wd)return Di;Wd=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",o=t+r+n,i="\\ufe0e\\ufe0f",a="\\u200d",s=RegExp("["+a+e+o+i+"]");function l(u){return s.test(u)}return Di=l,Di}var Bi,Hd;function cb(){if(Hd)return Bi;Hd=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",o=t+r+n,i="\\ufe0e\\ufe0f",a="["+e+"]",s="["+o+"]",l="\\ud83c[\\udffb-\\udfff]",u="(?:"+s+"|"+l+")",c="[^"+e+"]",d="(?:\\ud83c[\\udde6-\\uddff]){2}",f="[\\ud800-\\udbff][\\udc00-\\udfff]",p="\\u200d",x=u+"?",y="["+i+"]?",g="(?:"+p+"(?:"+[c,d,f].join("|")+")"+y+x+")*",v=y+x+g,h="(?:"+[c+s+"?",s,d,f,a].join("|")+")",b=RegExp(l+"(?="+l+")|"+h+v,"g");function _(w){for(var E=b.lastIndex=0;b.test(w);)++E;return E}return Bi=_,Bi}var zi,Vd;function lb(){if(Vd)return zi;Vd=1;var e=sb(),t=ub(),r=cb();function n(o){return t(o)?r(o):e(o)}return zi=n,zi}var $i,Ud;function db(){if(Ud)return $i;Ud=1;var e=hu(),t=Pr(),r=rr(),n=ab(),o=lb(),i="[object Map]",a="[object Set]";function s(l){if(l==null)return 0;if(r(l))return n(l)?o(l):l.length;var u=t(l);return u==i||u==a?l.size:e(l).length}return $i=s,$i}var Gi,Kd;function fb(){if(Kd)return Gi;Kd=1;var e=lu(),t=Kp(),r=mu(),n=tr(),o=Ct(),i=Te(),a=Mr(),s=Ur(),l=Ge(),u=Yr();function c(d,f,p){var x=i(d),y=x||a(d)||u(d);if(f=n(f,4),p==null){var g=d&&d.constructor;y?p=x?new g:[]:l(d)?p=s(g)?t(o(d)):{}:p={}}return(y?e:r)(d,function(v,h,b){return f(p,v,h,b)}),p}return Gi=c,Gi}var Wi,Zd;function hb(){if(Zd)return Wi;Zd=1;var e=Ar(),t=Zr(),r=Te(),n=e?e.isConcatSpreadable:void 0;function o(i){return r(i)||t(i)||!!(n&&i&&i[n])}return Wi=o,Wi}var Hi,Yd;function wu(){if(Yd)return Hi;Yd=1;var e=gu(),t=hb();function r(n,o,i,a,s){var l=-1,u=n.length;for(i||(i=t),s||(s=[]);++l<u;){var c=n[l];o>0&&i(c)?o>1?r(c,o-1,i,a,s):e(s,c):a||(s[s.length]=c)}return s}return Hi=r,Hi}var Vi,Xd;function pb(){if(Xd)return Vi;Xd=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 Vi=e,Vi}var Ui,Jd;function vg(){if(Jd)return Ui;Jd=1;var e=pb(),t=Math.max;function r(n,o,i){return o=t(o===void 0?n.length-1:o,0),function(){for(var a=arguments,s=-1,l=t(a.length-o,0),u=Array(l);++s<l;)u[s]=a[o+s];s=-1;for(var c=Array(o+1);++s<o;)c[s]=a[s];return c[o]=i(u),e(n,this,c)}}return Ui=r,Ui}var Ki,Qd;function gb(){if(Qd)return Ki;Qd=1;var e=yu(),t=kp(),r=xr(),n=t?function(o,i){return t(o,"toString",{configurable:!0,enumerable:!1,value:e(i),writable:!0})}:r;return Ki=n,Ki}var Zi,ef;function vb(){if(ef)return Zi;ef=1;var e=800,t=16,r=Date.now;function n(o){var i=0,a=0;return function(){var s=r(),l=t-(s-a);if(a=s,l>0){if(++i>=e)return arguments[0]}else i=0;return o.apply(void 0,arguments)}}return Zi=n,Zi}var Yi,rf;function yg(){if(rf)return Yi;rf=1;var e=gb(),t=vb(),r=t(e);return Yi=r,Yi}var Xi,tf;function It(){if(tf)return Xi;tf=1;var e=xr(),t=vg(),r=yg();function n(o,i){return r(t(o,i,e),o+"")}return Xi=n,Xi}var Ji,nf;function bg(){if(nf)return Ji;nf=1;function e(t,r,n,o){for(var i=t.length,a=n+(o?1:-1);o?a--:++a<i;)if(r(t[a],a,t))return a;return-1}return Ji=e,Ji}var Qi,of;function yb(){if(of)return Qi;of=1;function e(t){return t!==t}return Qi=e,Qi}var ea,af;function bb(){if(af)return ea;af=1;function e(t,r,n){for(var o=n-1,i=t.length;++o<i;)if(t[o]===r)return o;return-1}return ea=e,ea}var ra,sf;function mb(){if(sf)return ra;sf=1;var e=bg(),t=yb(),r=bb();function n(o,i,a){return i===i?r(o,i,a):e(o,t,a)}return ra=n,ra}var ta,uf;function xb(){if(uf)return ta;uf=1;var e=mb();function t(r,n){var o=r==null?0:r.length;return!!o&&e(r,n,0)>-1}return ta=t,ta}var na,cf;function _b(){if(cf)return na;cf=1;function e(t,r,n){for(var o=-1,i=t==null?0:t.length;++o<i;)if(n(r,t[o]))return!0;return!1}return na=e,na}var oa,lf;function wb(){if(lf)return oa;lf=1;function e(){}return oa=e,oa}var ia,df;function Cb(){if(df)return ia;df=1;var e=Hp(),t=wb(),r=xu(),n=1/0,o=e&&1/r(new e([,-0]))[1]==n?function(i){return new e(i)}:t;return ia=o,ia}var aa,ff;function Eb(){if(ff)return aa;ff=1;var e=eg(),t=xb(),r=_b(),n=rg(),o=Cb(),i=xu(),a=200;function s(l,u,c){var d=-1,f=t,p=l.length,x=!0,y=[],g=y;if(c)x=!1,f=r;else if(p>=a){var v=u?null:o(l);if(v)return i(v);x=!1,f=n,g=new e}else g=u?[]:y;e:for(;++d<p;){var h=l[d],b=u?u(h):h;if(h=c||h!==0?h:0,x&&b===b){for(var _=g.length;_--;)if(g[_]===b)continue e;u&&g.push(b),y.push(h)}else f(g,b,c)||(g!==y&&g.push(b),y.push(h))}return y}return aa=s,aa}var sa,hf;function mg(){if(hf)return sa;hf=1;var e=rr(),t=Qe();function r(n){return t(n)&&e(n)}return sa=r,sa}var ua,pf;function Rb(){if(pf)return ua;pf=1;var e=wu(),t=It(),r=Eb(),n=mg(),o=t(function(i){return r(e(i,1,n,!0))});return ua=o,ua}var ca,gf;function Sb(){if(gf)return ca;gf=1;var e=Rt();function t(r,n){return e(n,function(o){return r[o]})}return ca=t,ca}var la,vf;function xg(){if(vf)return la;vf=1;var e=Sb(),t=cr();function r(n){return n==null?[]:e(n,t(n))}return la=r,la}var da,yf;function We(){if(yf)return da;yf=1;var e;if(typeof su=="function")try{e={clone:Oy(),constant:yu(),each:Qp(),filter:lg(),has:dg(),isArray:Te(),isEmpty:nb(),isFunction:Ur(),isUndefined:fg(),keys:cr(),map:pg(),reduce:gg(),size:db(),transform:fb(),union:Rb(),values:xg()}}catch{}return e||(e=window._),da=e,da}var fa,bf;function Cu(){if(bf)return fa;bf=1;var e=We();fa=o;var t="\0",r="\0",n="";function o(c){this._isDirected=e.has(c,"directed")?c.directed:!0,this._isMultigraph=e.has(c,"multigraph")?c.multigraph:!1,this._isCompound=e.has(c,"compound")?c.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={}}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(c){return this._label=c,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(c){return e.isFunction(c)||(c=e.constant(c)),this._defaultNodeLabelFn=c,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var c=this;return e.filter(this.nodes(),function(d){return e.isEmpty(c._in[d])})},o.prototype.sinks=function(){var c=this;return e.filter(this.nodes(),function(d){return e.isEmpty(c._out[d])})},o.prototype.setNodes=function(c,d){var f=arguments,p=this;return e.each(c,function(x){f.length>1?p.setNode(x,d):p.setNode(x)}),this},o.prototype.setNode=function(c,d){return e.has(this._nodes,c)?(arguments.length>1&&(this._nodes[c]=d),this):(this._nodes[c]=arguments.length>1?d:this._defaultNodeLabelFn(c),this._isCompound&&(this._parent[c]=r,this._children[c]={},this._children[r][c]=!0),this._in[c]={},this._preds[c]={},this._out[c]={},this._sucs[c]={},++this._nodeCount,this)},o.prototype.node=function(c){return this._nodes[c]},o.prototype.hasNode=function(c){return e.has(this._nodes,c)},o.prototype.removeNode=function(c){var d=this;if(e.has(this._nodes,c)){var f=function(p){d.removeEdge(d._edgeObjs[p])};delete this._nodes[c],this._isCompound&&(this._removeFromParentsChildList(c),delete this._parent[c],e.each(this.children(c),function(p){d.setParent(p)}),delete this._children[c]),e.each(e.keys(this._in[c]),f),delete this._in[c],delete this._preds[c],e.each(e.keys(this._out[c]),f),delete this._out[c],delete this._sucs[c],--this._nodeCount}return this},o.prototype.setParent=function(c,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 f=d;!e.isUndefined(f);f=this.parent(f))if(f===c)throw new Error("Setting "+d+" as parent of "+c+" would create a cycle");this.setNode(d)}return this.setNode(c),this._removeFromParentsChildList(c),this._parent[c]=d,this._children[d][c]=!0,this},o.prototype._removeFromParentsChildList=function(c){delete this._children[this._parent[c]][c]},o.prototype.parent=function(c){if(this._isCompound){var d=this._parent[c];if(d!==r)return d}},o.prototype.children=function(c){if(e.isUndefined(c)&&(c=r),this._isCompound){var d=this._children[c];if(d)return e.keys(d)}else{if(c===r)return this.nodes();if(this.hasNode(c))return[]}},o.prototype.predecessors=function(c){var d=this._preds[c];if(d)return e.keys(d)},o.prototype.successors=function(c){var d=this._sucs[c];if(d)return e.keys(d)},o.prototype.neighbors=function(c){var d=this.predecessors(c);if(d)return e.union(d,this.successors(c))},o.prototype.isLeaf=function(c){var d;return this.isDirected()?d=this.successors(c):d=this.neighbors(c),d.length===0},o.prototype.filterNodes=function(c){var d=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});d.setGraph(this.graph());var f=this;e.each(this._nodes,function(y,g){c(g)&&d.setNode(g,y)}),e.each(this._edgeObjs,function(y){d.hasNode(y.v)&&d.hasNode(y.w)&&d.setEdge(y,f.edge(y))});var p={};function x(y){var g=f.parent(y);return g===void 0||d.hasNode(g)?(p[y]=g,g):g in p?p[g]:x(g)}return this._isCompound&&e.each(d.nodes(),function(y){d.setParent(y,x(y))}),d},o.prototype.setDefaultEdgeLabel=function(c){return e.isFunction(c)||(c=e.constant(c)),this._defaultEdgeLabelFn=c,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(c,d){var f=this,p=arguments;return e.reduce(c,function(x,y){return p.length>1?f.setEdge(x,y,d):f.setEdge(x,y),y}),this},o.prototype.setEdge=function(){var c,d,f,p,x=!1,y=arguments[0];typeof y=="object"&&y!==null&&"v"in y?(c=y.v,d=y.w,f=y.name,arguments.length===2&&(p=arguments[1],x=!0)):(c=y,d=arguments[1],f=arguments[3],arguments.length>2&&(p=arguments[2],x=!0)),c=""+c,d=""+d,e.isUndefined(f)||(f=""+f);var g=s(this._isDirected,c,d,f);if(e.has(this._edgeLabels,g))return x&&(this._edgeLabels[g]=p),this;if(!e.isUndefined(f)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(c),this.setNode(d),this._edgeLabels[g]=x?p:this._defaultEdgeLabelFn(c,d,f);var v=l(this._isDirected,c,d,f);return c=v.v,d=v.w,Object.freeze(v),this._edgeObjs[g]=v,i(this._preds[d],c),i(this._sucs[c],d),this._in[d][g]=v,this._out[c][g]=v,this._edgeCount++,this},o.prototype.edge=function(c,d,f){var p=arguments.length===1?u(this._isDirected,arguments[0]):s(this._isDirected,c,d,f);return this._edgeLabels[p]},o.prototype.hasEdge=function(c,d,f){var p=arguments.length===1?u(this._isDirected,arguments[0]):s(this._isDirected,c,d,f);return e.has(this._edgeLabels,p)},o.prototype.removeEdge=function(c,d,f){var p=arguments.length===1?u(this._isDirected,arguments[0]):s(this._isDirected,c,d,f),x=this._edgeObjs[p];return x&&(c=x.v,d=x.w,delete this._edgeLabels[p],delete this._edgeObjs[p],a(this._preds[d],c),a(this._sucs[c],d),delete this._in[d][p],delete this._out[c][p],this._edgeCount--),this},o.prototype.inEdges=function(c,d){var f=this._in[c];if(f){var p=e.values(f);return d?e.filter(p,function(x){return x.v===d}):p}},o.prototype.outEdges=function(c,d){var f=this._out[c];if(f){var p=e.values(f);return d?e.filter(p,function(x){return x.w===d}):p}},o.prototype.nodeEdges=function(c,d){var f=this.inEdges(c,d);if(f)return f.concat(this.outEdges(c,d))};function i(c,d){c[d]?c[d]++:c[d]=1}function a(c,d){--c[d]||delete c[d]}function s(c,d,f,p){var x=""+d,y=""+f;if(!c&&x>y){var g=x;x=y,y=g}return x+n+y+n+(e.isUndefined(p)?t:p)}function l(c,d,f,p){var x=""+d,y=""+f;if(!c&&x>y){var g=x;x=y,y=g}var v={v:x,w:y};return p&&(v.name=p),v}function u(c,d){return s(c,d.v,d.w,d.name)}return fa}var ha,mf;function qb(){return mf||(mf=1,ha="2.1.8"),ha}var pa,xf;function Ib(){return xf||(xf=1,pa={Graph:Cu(),version:qb()}),pa}var ga,_f;function Tb(){if(_f)return ga;_f=1;var e=We(),t=Cu();ga={write:r,read:i};function r(a){var s={options:{directed:a.isDirected(),multigraph:a.isMultigraph(),compound:a.isCompound()},nodes:n(a),edges:o(a)};return e.isUndefined(a.graph())||(s.value=e.clone(a.graph())),s}function n(a){return e.map(a.nodes(),function(s){var l=a.node(s),u=a.parent(s),c={v:s};return e.isUndefined(l)||(c.value=l),e.isUndefined(u)||(c.parent=u),c})}function o(a){return e.map(a.edges(),function(s){var l=a.edge(s),u={v:s.v,w:s.w};return e.isUndefined(s.name)||(u.name=s.name),e.isUndefined(l)||(u.value=l),u})}function i(a){var s=new t(a.options).setGraph(a.value);return e.each(a.nodes,function(l){s.setNode(l.v,l.value),l.parent&&s.setParent(l.v,l.parent)}),e.each(a.edges,function(l){s.setEdge({v:l.v,w:l.w,name:l.name},l.value)}),s}return ga}var va,wf;function Ab(){if(wf)return va;wf=1;var e=We();va=t;function t(r){var n={},o=[],i;function a(s){e.has(n,s)||(n[s]=!0,i.push(s),e.each(r.successors(s),a),e.each(r.predecessors(s),a))}return e.each(r.nodes(),function(s){i=[],a(s),i.length&&o.push(i)}),o}return va}var ya,Cf;function _g(){if(Cf)return ya;Cf=1;var e=We();ya=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 o=this._keyIndices;if(r=String(r),!e.has(o,r)){var i=this._arr,a=i.length;return o[r]=a,i.push({key:r,priority:n}),this._decrease(a),!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 o=this._keyIndices[r];if(n>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[o].priority+" New: "+n);this._arr[o].priority=n,this._decrease(o)},t.prototype._heapify=function(r){var n=this._arr,o=2*r,i=o+1,a=r;o<n.length&&(a=n[o].priority<n[a].priority?o:a,i<n.length&&(a=n[i].priority<n[a].priority?i:a),a!==r&&(this._swap(r,a),this._heapify(a)))},t.prototype._decrease=function(r){for(var n=this._arr,o=n[r].priority,i;r!==0&&(i=r>>1,!(n[i].priority<o));)this._swap(r,i),r=i},t.prototype._swap=function(r,n){var o=this._arr,i=this._keyIndices,a=o[r],s=o[n];o[r]=s,o[n]=a,i[s.key]=r,i[a.key]=n},ya}var ba,Ef;function wg(){if(Ef)return ba;Ef=1;var e=We(),t=_g();ba=n;var r=e.constant(1);function n(i,a,s,l){return o(i,String(a),s||r,l||function(u){return i.outEdges(u)})}function o(i,a,s,l){var u={},c=new t,d,f,p=function(x){var y=x.v!==d?x.v:x.w,g=u[y],v=s(x),h=f.distance+v;if(v<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+x+" Weight: "+v);h<g.distance&&(g.distance=h,g.predecessor=d,c.decrease(y,h))};for(i.nodes().forEach(function(x){var y=x===a?0:Number.POSITIVE_INFINITY;u[x]={distance:y},c.add(x,y)});c.size()>0&&(d=c.removeMin(),f=u[d],f.distance!==Number.POSITIVE_INFINITY);)l(d).forEach(p);return u}return ba}var ma,Rf;function Mb(){if(Rf)return ma;Rf=1;var e=wg(),t=We();ma=r;function r(n,o,i){return t.transform(n.nodes(),function(a,s){a[s]=e(n,s,o,i)},{})}return ma}var xa,Sf;function Cg(){if(Sf)return xa;Sf=1;var e=We();xa=t;function t(r){var n=0,o=[],i={},a=[];function s(l){var u=i[l]={onStack:!0,lowlink:n,index:n++};if(o.push(l),r.successors(l).forEach(function(f){e.has(i,f)?i[f].onStack&&(u.lowlink=Math.min(u.lowlink,i[f].index)):(s(f),u.lowlink=Math.min(u.lowlink,i[f].lowlink))}),u.lowlink===u.index){var c=[],d;do d=o.pop(),i[d].onStack=!1,c.push(d);while(l!==d);a.push(c)}}return r.nodes().forEach(function(l){e.has(i,l)||s(l)}),a}return xa}var _a,qf;function Pb(){if(qf)return _a;qf=1;var e=We(),t=Cg();_a=r;function r(n){return e.filter(t(n),function(o){return o.length>1||o.length===1&&n.hasEdge(o[0],o[0])})}return _a}var wa,If;function Ob(){if(If)return wa;If=1;var e=We();wa=r;var t=e.constant(1);function r(o,i,a){return n(o,i||t,a||function(s){return o.outEdges(s)})}function n(o,i,a){var s={},l=o.nodes();return l.forEach(function(u){s[u]={},s[u][u]={distance:0},l.forEach(function(c){u!==c&&(s[u][c]={distance:Number.POSITIVE_INFINITY})}),a(u).forEach(function(c){var d=c.v===u?c.w:c.v,f=i(c);s[u][d]={distance:f,predecessor:u}})}),l.forEach(function(u){var c=s[u];l.forEach(function(d){var f=s[d];l.forEach(function(p){var x=f[u],y=c[p],g=f[p],v=x.distance+y.distance;v<g.distance&&(g.distance=v,g.predecessor=y.predecessor)})})}),s}return wa}var Ca,Tf;function Eg(){if(Tf)return Ca;Tf=1;var e=We();Ca=t,t.CycleException=r;function t(n){var o={},i={},a=[];function s(l){if(e.has(i,l))throw new r;e.has(o,l)||(i[l]=!0,o[l]=!0,e.each(n.predecessors(l),s),delete i[l],a.push(l))}if(e.each(n.sinks(),s),e.size(o)!==n.nodeCount())throw new r;return a}function r(){}return r.prototype=new Error,Ca}var Ea,Af;function jb(){if(Af)return Ea;Af=1;var e=Eg();Ea=t;function t(r){try{e(r)}catch(n){if(n instanceof e.CycleException)return!1;throw n}return!0}return Ea}var Ra,Mf;function Rg(){if(Mf)return Ra;Mf=1;var e=We();Ra=t;function t(n,o,i){e.isArray(o)||(o=[o]);var a=(n.isDirected()?n.successors:n.neighbors).bind(n),s=[],l={};return e.each(o,function(u){if(!n.hasNode(u))throw new Error("Graph does not have node: "+u);r(n,u,i==="post",l,a,s)}),s}function r(n,o,i,a,s,l){e.has(a,o)||(a[o]=!0,i||l.push(o),e.each(s(o),function(u){r(n,u,i,a,s,l)}),i&&l.push(o))}return Ra}var Sa,Pf;function kb(){if(Pf)return Sa;Pf=1;var e=Rg();Sa=t;function t(r,n){return e(r,n,"post")}return Sa}var qa,Of;function Nb(){if(Of)return qa;Of=1;var e=Rg();qa=t;function t(r,n){return e(r,n,"pre")}return qa}var Ia,jf;function Lb(){if(jf)return Ia;jf=1;var e=We(),t=Cu(),r=_g();Ia=n;function n(o,i){var a=new t,s={},l=new r,u;function c(f){var p=f.v===u?f.w:f.v,x=l.priority(p);if(x!==void 0){var y=i(f);y<x&&(s[p]=u,l.decrease(p,y))}}if(o.nodeCount()===0)return a;e.each(o.nodes(),function(f){l.add(f,Number.POSITIVE_INFINITY),a.setNode(f)}),l.decrease(o.nodes()[0],0);for(var d=!1;l.size()>0;){if(u=l.removeMin(),e.has(s,u))a.setEdge(u,s[u]);else{if(d)throw new Error("Input graph is not connected: "+o);d=!0}o.nodeEdges(u).forEach(c)}return a}return Ia}var Ta,kf;function Fb(){return kf||(kf=1,Ta={components:Ab(),dijkstra:wg(),dijkstraAll:Mb(),findCycles:Pb(),floydWarshall:Ob(),isAcyclic:jb(),postorder:kb(),preorder:Nb(),prim:Lb(),tarjan:Cg(),topsort:Eg()}),Ta}var Aa,Nf;function Db(){if(Nf)return Aa;Nf=1;var e=Ib();return Aa={Graph:e.Graph,json:Tb(),alg:Fb(),version:e.version},Aa}var Ma,Lf;function He(){if(Lf)return Ma;Lf=1;var e;if(typeof su=="function")try{e=Db()}catch{}return e||(e=window.graphlib),Ma=e,Ma}var Pa,Ff;function Bb(){if(Ff)return Pa;Ff=1;var e=Yp(),t=1,r=4;function n(o){return e(o,t|r)}return Pa=n,Pa}var Oa,Df;function Tt(){if(Df)return Oa;Df=1;var e=Tr(),t=rr(),r=xt(),n=Ge();function o(i,a,s){if(!n(s))return!1;var l=typeof a;return(l=="number"?t(s)&&r(a,s.length):l=="string"&&a in s)?e(s[a],i):!1}return Oa=o,Oa}var ja,Bf;function zb(){if(Bf)return ja;Bf=1;var e=It(),t=Tr(),r=Tt(),n=mr(),o=Object.prototype,i=o.hasOwnProperty,a=e(function(s,l){s=Object(s);var u=-1,c=l.length,d=c>2?l[2]:void 0;for(d&&r(l[0],l[1],d)&&(c=1);++u<c;)for(var f=l[u],p=n(f),x=-1,y=p.length;++x<y;){var g=p[x],v=s[g];(v===void 0||t(v,o[g])&&!i.call(s,g))&&(s[g]=f[g])}return s});return ja=a,ja}var ka,zf;function $b(){if(zf)return ka;zf=1;var e=tr(),t=rr(),r=cr();function n(o){return function(i,a,s){var l=Object(i);if(!t(i)){var u=e(a,3);i=r(i),a=function(d){return u(l[d],d,l)}}var c=o(i,a,s);return c>-1?l[u?i[c]:c]:void 0}}return ka=n,ka}var Na,$f;function Gb(){if($f)return Na;$f=1;var e=/\s/;function t(r){for(var n=r.length;n--&&e.test(r.charAt(n)););return n}return Na=t,Na}var La,Gf;function Wb(){if(Gf)return La;Gf=1;var e=Gb(),t=/^\s+/;function r(n){return n&&n.slice(0,e(n)+1).replace(t,"")}return La=r,La}var Fa,Wf;function Hb(){if(Wf)return Fa;Wf=1;var e=Wb(),t=Ge(),r=Or(),n=NaN,o=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,a=/^0o[0-7]+$/i,s=parseInt;function l(u){if(typeof u=="number")return u;if(r(u))return n;if(t(u)){var c=typeof u.valueOf=="function"?u.valueOf():u;u=t(c)?c+"":c}if(typeof u!="string")return u===0?u:+u;u=e(u);var d=i.test(u);return d||a.test(u)?s(u.slice(2),d?2:8):o.test(u)?n:+u}return Fa=l,Fa}var Da,Hf;function Sg(){if(Hf)return Da;Hf=1;var e=Hb(),t=1/0,r=17976931348623157e292;function n(o){if(!o)return o===0?o:0;if(o=e(o),o===t||o===-t){var i=o<0?-1:1;return i*r}return o===o?o:0}return Da=n,Da}var Ba,Vf;function Vb(){if(Vf)return Ba;Vf=1;var e=Sg();function t(r){var n=e(r),o=n%1;return n===n?o?n-o:n:0}return Ba=t,Ba}var za,Uf;function Ub(){if(Uf)return za;Uf=1;var e=bg(),t=tr(),r=Vb(),n=Math.max;function o(i,a,s){var l=i==null?0:i.length;if(!l)return-1;var u=s==null?0:r(s);return u<0&&(u=n(l+u,0)),e(i,t(a,3),u)}return za=o,za}var $a,Kf;function Kb(){if(Kf)return $a;Kf=1;var e=$b(),t=Ub(),r=e(t);return $a=r,$a}var Ga,Zf;function qg(){if(Zf)return Ga;Zf=1;var e=wu();function t(r){var n=r==null?0:r.length;return n?e(r,1):[]}return Ga=t,Ga}var Wa,Yf;function Zb(){if(Yf)return Wa;Yf=1;var e=bu(),t=Xp(),r=mr();function n(o,i){return o==null?o:e(o,t(i),r)}return Wa=n,Wa}var Ha,Xf;function Yb(){if(Xf)return Ha;Xf=1;function e(t){var r=t==null?0:t.length;return r?t[r-1]:void 0}return Ha=e,Ha}var Va,Jf;function Xb(){if(Jf)return Va;Jf=1;var e=bt(),t=mu(),r=tr();function n(o,i){var a={};return i=r(i,3),t(o,function(s,l,u){e(a,l,i(s,l,u))}),a}return Va=n,Va}var Ua,Qf;function Eu(){if(Qf)return Ua;Qf=1;var e=Or();function t(r,n,o){for(var i=-1,a=r.length;++i<a;){var s=r[i],l=n(s);if(l!=null&&(u===void 0?l===l&&!e(l):o(l,u)))var u=l,c=s}return c}return Ua=t,Ua}var Ka,eh;function Jb(){if(eh)return Ka;eh=1;function e(t,r){return t>r}return Ka=e,Ka}var Za,rh;function Qb(){if(rh)return Za;rh=1;var e=Eu(),t=Jb(),r=xr();function n(o){return o&&o.length?e(o,r,t):void 0}return Za=n,Za}var Ya,th;function Ig(){if(th)return Ya;th=1;var e=bt(),t=Tr();function r(n,o,i){(i!==void 0&&!t(n[o],i)||i===void 0&&!(o in n))&&e(n,o,i)}return Ya=r,Ya}var Xa,nh;function em(){if(nh)return Xa;nh=1;var e=yr(),t=Ct(),r=Qe(),n="[object Object]",o=Function.prototype,i=Object.prototype,a=o.toString,s=i.hasOwnProperty,l=a.call(Object);function u(c){if(!r(c)||e(c)!=n)return!1;var d=t(c);if(d===null)return!0;var f=s.call(d,"constructor")&&d.constructor;return typeof f=="function"&&f instanceof f&&a.call(f)==l}return Xa=u,Xa}var Ja,oh;function Tg(){if(oh)return Ja;oh=1;function e(t,r){if(!(r==="constructor"&&typeof t[r]=="function")&&r!="__proto__")return t[r]}return Ja=e,Ja}var Qa,ih;function rm(){if(ih)return Qa;ih=1;var e=Kr(),t=mr();function r(n){return e(n,t(n))}return Qa=r,Qa}var es,ah;function tm(){if(ah)return es;ah=1;var e=Ig(),t=Fp(),r=Up(),n=Dp(),o=Zp(),i=Zr(),a=Te(),s=mg(),l=Mr(),u=Ur(),c=Ge(),d=em(),f=Yr(),p=Tg(),x=rm();function y(g,v,h,b,_,w,E){var R=p(g,h),I=p(v,h),A=E.get(I);if(A){e(g,h,A);return}var k=w?w(R,I,h+"",g,v,E):void 0,M=k===void 0;if(M){var z=a(I),G=!z&&l(I),U=!z&&!G&&f(I);k=I,z||G||U?a(R)?k=R:s(R)?k=n(R):G?(M=!1,k=t(I,!0)):U?(M=!1,k=r(I,!0)):k=[]:d(I)||i(I)?(k=R,i(R)?k=x(R):(!c(R)||u(R))&&(k=o(I))):M=!1}M&&(E.set(I,k),_(k,I,b,w,E),E.delete(I)),e(g,h,k)}return es=y,es}var rs,sh;function nm(){if(sh)return rs;sh=1;var e=yt(),t=Ig(),r=bu(),n=tm(),o=Ge(),i=mr(),a=Tg();function s(l,u,c,d,f){l!==u&&r(u,function(p,x){if(f||(f=new e),o(p))n(l,u,x,c,s,d,f);else{var y=d?d(a(l,x),p,x+"",l,u,f):void 0;y===void 0&&(y=p),t(l,x,y)}},i)}return rs=s,rs}var ts,uh;function om(){if(uh)return ts;uh=1;var e=It(),t=Tt();function r(n){return e(function(o,i){var a=-1,s=i.length,l=s>1?i[s-1]:void 0,u=s>2?i[2]:void 0;for(l=n.length>3&&typeof l=="function"?(s--,l):void 0,u&&t(i[0],i[1],u)&&(l=s<3?void 0:l,s=1),o=Object(o);++a<s;){var c=i[a];c&&n(o,c,a,l)}return o})}return ts=r,ts}var ns,ch;function im(){if(ch)return ns;ch=1;var e=nm(),t=om(),r=t(function(n,o,i){e(n,o,i)});return ns=r,ns}var os,lh;function Ag(){if(lh)return os;lh=1;function e(t,r){return t<r}return os=e,os}var is,dh;function am(){if(dh)return is;dh=1;var e=Eu(),t=Ag(),r=xr();function n(o){return o&&o.length?e(o,r,t):void 0}return is=n,is}var as,fh;function sm(){if(fh)return as;fh=1;var e=Eu(),t=tr(),r=Ag();function n(o,i){return o&&o.length?e(o,t(i,2),r):void 0}return as=n,as}var ss,hh;function um(){if(hh)return ss;hh=1;var e=Ve(),t=function(){return e.Date.now()};return ss=t,ss}var us,ph;function cm(){if(ph)return us;ph=1;var e=mt(),t=St(),r=xt(),n=Ge(),o=Xr();function i(a,s,l,u){if(!n(a))return a;s=t(s,a);for(var c=-1,d=s.length,f=d-1,p=a;p!=null&&++c<d;){var x=o(s[c]),y=l;if(x==="__proto__"||x==="constructor"||x==="prototype")return a;if(c!=f){var g=p[x];y=u?u(g,x,p):void 0,y===void 0&&(y=n(g)?g:r(s[c+1])?[]:{})}e(p,x,y),p=p[x]}return a}return us=i,us}var cs,gh;function lm(){if(gh)return cs;gh=1;var e=qt(),t=cm(),r=St();function n(o,i,a){for(var s=-1,l=i.length,u={};++s<l;){var c=i[s],d=e(o,c);a(d,c)&&t(u,r(c,o),d)}return u}return cs=n,cs}var ls,vh;function dm(){if(vh)return ls;vh=1;var e=lm(),t=ug();function r(n,o){return e(n,o,function(i,a){return t(n,a)})}return ls=r,ls}var ds,yh;function fm(){if(yh)return ds;yh=1;var e=qg(),t=vg(),r=yg();function n(o){return r(t(o,void 0,e),o+"")}return ds=n,ds}var fs,bh;function hm(){if(bh)return fs;bh=1;var e=dm(),t=fm(),r=t(function(n,o){return n==null?{}:e(n,o)});return fs=r,fs}var hs,mh;function pm(){if(mh)return hs;mh=1;var e=Math.ceil,t=Math.max;function r(n,o,i,a){for(var s=-1,l=t(e((o-n)/(i||1)),0),u=Array(l);l--;)u[a?l:++s]=n,n+=i;return u}return hs=r,hs}var ps,xh;function gm(){if(xh)return ps;xh=1;var e=pm(),t=Tt(),r=Sg();function n(o){return function(i,a,s){return s&&typeof s!="number"&&t(i,a,s)&&(a=s=void 0),i=r(i),a===void 0?(a=i,i=0):a=r(a),s=s===void 0?i<a?1:-1:r(s),e(i,a,s,o)}}return ps=n,ps}var gs,_h;function vm(){if(_h)return gs;_h=1;var e=gm(),t=e();return gs=t,gs}var vs,wh;function ym(){if(wh)return vs;wh=1;function e(t,r){var n=t.length;for(t.sort(r);n--;)t[n]=t[n].value;return t}return vs=e,vs}var ys,Ch;function bm(){if(Ch)return ys;Ch=1;var e=Or();function t(r,n){if(r!==n){var o=r!==void 0,i=r===null,a=r===r,s=e(r),l=n!==void 0,u=n===null,c=n===n,d=e(n);if(!u&&!d&&!s&&r>n||s&&l&&c&&!u&&!d||i&&l&&c||!o&&c||!a)return 1;if(!i&&!s&&!d&&r<n||d&&o&&a&&!i&&!s||u&&o&&a||!l&&a||!c)return-1}return 0}return ys=t,ys}var bs,Eh;function mm(){if(Eh)return bs;Eh=1;var e=bm();function t(r,n,o){for(var i=-1,a=r.criteria,s=n.criteria,l=a.length,u=o.length;++i<l;){var c=e(a[i],s[i]);if(c){if(i>=u)return c;var d=o[i];return c*(d=="desc"?-1:1)}}return r.index-n.index}return bs=t,bs}var ms,Rh;function xm(){if(Rh)return ms;Rh=1;var e=Rt(),t=qt(),r=tr(),n=hg(),o=ym(),i=_t(),a=mm(),s=xr(),l=Te();function u(c,d,f){d.length?d=e(d,function(y){return l(y)?function(g){return t(g,y.length===1?y[0]:y)}:y}):d=[s];var p=-1;d=e(d,i(r));var x=n(c,function(y,g,v){var h=e(d,function(b){return b(y)});return{criteria:h,index:++p,value:y}});return o(x,function(y,g){return a(y,g,f)})}return ms=u,ms}var xs,Sh;function _m(){if(Sh)return xs;Sh=1;var e=wu(),t=xm(),r=It(),n=Tt(),o=r(function(i,a){if(i==null)return[];var s=a.length;return s>1&&n(i,a[0],a[1])?a=[]:s>2&&n(a[0],a[1],a[2])&&(a=[a[0]]),t(i,e(a,1),[])});return xs=o,xs}var _s,qh;function wm(){if(qh)return _s;qh=1;var e=ag(),t=0;function r(n){var o=++t;return e(n)+o}return _s=r,_s}var ws,Ih;function Cm(){if(Ih)return ws;Ih=1;function e(t,r,n){for(var o=-1,i=t.length,a=r.length,s={};++o<i;){var l=o<a?r[o]:void 0;n(s,t[o],l)}return s}return ws=e,ws}var Cs,Th;function Em(){if(Th)return Cs;Th=1;var e=mt(),t=Cm();function r(n,o){return t(n||[],o||[],e)}return Cs=r,Cs}var Es,Ah;function Re(){if(Ah)return Es;Ah=1;var e;if(typeof su=="function")try{e={cloneDeep:Bb(),constant:yu(),defaults:zb(),each:Qp(),filter:lg(),find:Kb(),flatten:qg(),forEach:Jp(),forIn:Zb(),has:dg(),isUndefined:fg(),last:Yb(),map:pg(),mapValues:Xb(),max:Qb(),merge:im(),min:am(),minBy:sm(),now:um(),pick:hm(),range:vm(),reduce:gg(),sortBy:_m(),uniqueId:wm(),values:xg(),zipObject:Em()}}catch{}return e||(e=window._),Es=e,Es}var Rs,Mh;function Rm(){if(Mh)return Rs;Mh=1,Rs=e;function e(){var n={};n._next=n._prev=n,this._sentinel=n}e.prototype.dequeue=function(){var n=this._sentinel,o=n._prev;if(o!==n)return t(o),o},e.prototype.enqueue=function(n){var o=this._sentinel;n._prev&&n._next&&t(n),n._next=o._next,o._next._prev=n,o._next=n,n._prev=o},e.prototype.toString=function(){for(var n=[],o=this._sentinel,i=o._prev;i!==o;)n.push(JSON.stringify(i,r)),i=i._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,o){if(n!=="_next"&&n!=="_prev")return o}return Rs}var Ss,Ph;function Sm(){if(Ph)return Ss;Ph=1;var e=Re(),t=He().Graph,r=Rm();Ss=o;var n=e.constant(1);function o(u,c){if(u.nodeCount()<=1)return[];var d=s(u,c||n),f=i(d.graph,d.buckets,d.zeroIdx);return e.flatten(e.map(f,function(p){return u.outEdges(p.v,p.w)}),!0)}function i(u,c,d){for(var f=[],p=c[c.length-1],x=c[0],y;u.nodeCount();){for(;y=x.dequeue();)a(u,c,d,y);for(;y=p.dequeue();)a(u,c,d,y);if(u.nodeCount()){for(var g=c.length-2;g>0;--g)if(y=c[g].dequeue(),y){f=f.concat(a(u,c,d,y,!0));break}}}return f}function a(u,c,d,f,p){var x=p?[]:void 0;return e.forEach(u.inEdges(f.v),function(y){var g=u.edge(y),v=u.node(y.v);p&&x.push({v:y.v,w:y.w}),v.out-=g,l(c,d,v)}),e.forEach(u.outEdges(f.v),function(y){var g=u.edge(y),v=y.w,h=u.node(v);h.in-=g,l(c,d,h)}),u.removeNode(f.v),x}function s(u,c){var d=new t,f=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 v=d.edge(g.v,g.w)||0,h=c(g),b=v+h;d.setEdge(g.v,g.w,b),p=Math.max(p,d.node(g.v).out+=h),f=Math.max(f,d.node(g.w).in+=h)});var x=e.range(p+f+3).map(function(){return new r}),y=f+1;return e.forEach(d.nodes(),function(g){l(x,y,d.node(g))}),{graph:d,buckets:x,zeroIdx:y}}function l(u,c,d){d.out?d.in?u[d.out-d.in+c].enqueue(d):u[u.length-1].enqueue(d):u[0].enqueue(d)}return Ss}var qs,Oh;function qm(){if(Oh)return qs;Oh=1;var e=Re(),t=Sm();qs={run:r,undo:o};function r(i){var a=i.graph().acyclicer==="greedy"?t(i,s(i)):n(i);e.forEach(a,function(l){var u=i.edge(l);i.removeEdge(l),u.forwardName=l.name,u.reversed=!0,i.setEdge(l.w,l.v,u,e.uniqueId("rev"))});function s(l){return function(u){return l.edge(u).weight}}}function n(i){var a=[],s={},l={};function u(c){e.has(l,c)||(l[c]=!0,s[c]=!0,e.forEach(i.outEdges(c),function(d){e.has(s,d.w)?a.push(d):u(d.w)}),delete s[c])}return e.forEach(i.nodes(),u),a}function o(i){e.forEach(i.edges(),function(a){var s=i.edge(a);if(s.reversed){i.removeEdge(a);var l=s.forwardName;delete s.reversed,delete s.forwardName,i.setEdge(a.w,a.v,s,l)}})}return qs}var Is,jh;function ke(){if(jh)return Is;jh=1;var e=Re(),t=He().Graph;Is={addDummyNode:r,simplify:n,asNonCompoundGraph:o,successorWeights:i,predecessorWeights:a,intersectRect:s,buildLayerMatrix:l,normalizeRanks:u,removeEmptyRanks:c,addBorderNode:d,maxRank:f,partition:p,time:x,notime:y};function r(g,v,h,b){var _;do _=e.uniqueId(b);while(g.hasNode(_));return h.dummy=v,g.setNode(_,h),_}function n(g){var v=new t().setGraph(g.graph());return e.forEach(g.nodes(),function(h){v.setNode(h,g.node(h))}),e.forEach(g.edges(),function(h){var b=v.edge(h.v,h.w)||{weight:0,minlen:1},_=g.edge(h);v.setEdge(h.v,h.w,{weight:b.weight+_.weight,minlen:Math.max(b.minlen,_.minlen)})}),v}function o(g){var v=new t({multigraph:g.isMultigraph()}).setGraph(g.graph());return e.forEach(g.nodes(),function(h){g.children(h).length||v.setNode(h,g.node(h))}),e.forEach(g.edges(),function(h){v.setEdge(h,g.edge(h))}),v}function i(g){var v=e.map(g.nodes(),function(h){var b={};return e.forEach(g.outEdges(h),function(_){b[_.w]=(b[_.w]||0)+g.edge(_).weight}),b});return e.zipObject(g.nodes(),v)}function a(g){var v=e.map(g.nodes(),function(h){var b={};return e.forEach(g.inEdges(h),function(_){b[_.v]=(b[_.v]||0)+g.edge(_).weight}),b});return e.zipObject(g.nodes(),v)}function s(g,v){var h=g.x,b=g.y,_=v.x-h,w=v.y-b,E=g.width/2,R=g.height/2;if(!_&&!w)throw new Error("Not possible to find intersection inside of the rectangle");var I,A;return Math.abs(w)*E>Math.abs(_)*R?(w<0&&(R=-R),I=R*_/w,A=R):(_<0&&(E=-E),I=E,A=E*w/_),{x:h+I,y:b+A}}function l(g){var v=e.map(e.range(f(g)+1),function(){return[]});return e.forEach(g.nodes(),function(h){var b=g.node(h),_=b.rank;e.isUndefined(_)||(v[_][b.order]=h)}),v}function u(g){var v=e.min(e.map(g.nodes(),function(h){return g.node(h).rank}));e.forEach(g.nodes(),function(h){var b=g.node(h);e.has(b,"rank")&&(b.rank-=v)})}function c(g){var v=e.min(e.map(g.nodes(),function(w){return g.node(w).rank})),h=[];e.forEach(g.nodes(),function(w){var E=g.node(w).rank-v;h[E]||(h[E]=[]),h[E].push(w)});var b=0,_=g.graph().nodeRankFactor;e.forEach(h,function(w,E){e.isUndefined(w)&&E%_!==0?--b:b&&e.forEach(w,function(R){g.node(R).rank+=b})})}function d(g,v,h,b){var _={width:0,height:0};return arguments.length>=4&&(_.rank=h,_.order=b),r(g,"border",_,v)}function f(g){return e.max(e.map(g.nodes(),function(v){var h=g.node(v).rank;if(!e.isUndefined(h))return h}))}function p(g,v){var h={lhs:[],rhs:[]};return e.forEach(g,function(b){v(b)?h.lhs.push(b):h.rhs.push(b)}),h}function x(g,v){var h=e.now();try{return v()}finally{console.log(g+" time: "+(e.now()-h)+"ms")}}function y(g,v){return v()}return Is}var Ts,kh;function Im(){if(kh)return Ts;kh=1;var e=Re(),t=ke();Ts={run:r,undo:o};function r(i){i.graph().dummyChains=[],e.forEach(i.edges(),function(a){n(i,a)})}function n(i,a){var s=a.v,l=i.node(s).rank,u=a.w,c=i.node(u).rank,d=a.name,f=i.edge(a),p=f.labelRank;if(c!==l+1){i.removeEdge(a);var x,y,g;for(g=0,++l;l<c;++g,++l)f.points=[],y={width:0,height:0,edgeLabel:f,edgeObj:a,rank:l},x=t.addDummyNode(i,"edge",y,"_d"),l===p&&(y.width=f.width,y.height=f.height,y.dummy="edge-label",y.labelpos=f.labelpos),i.setEdge(s,x,{weight:f.weight},d),g===0&&i.graph().dummyChains.push(x),s=x;i.setEdge(s,u,{weight:f.weight},d)}}function o(i){e.forEach(i.graph().dummyChains,function(a){var s=i.node(a),l=s.edgeLabel,u;for(i.setEdge(s.edgeObj,l);s.dummy;)u=i.successors(a)[0],i.removeNode(a),l.points.push({x:s.x,y:s.y}),s.dummy==="edge-label"&&(l.x=s.x,l.y=s.y,l.width=s.width,l.height=s.height),a=u,s=i.node(a)})}return Ts}var As,Nh;function at(){if(Nh)return As;Nh=1;var e=Re();As={longestPath:t,slack:r};function t(n){var o={};function i(a){var s=n.node(a);if(e.has(o,a))return s.rank;o[a]=!0;var l=e.min(e.map(n.outEdges(a),function(u){return i(u.w)-n.edge(u).minlen}));return(l===Number.POSITIVE_INFINITY||l===void 0||l===null)&&(l=0),s.rank=l}e.forEach(n.sources(),i)}function r(n,o){return n.node(o.w).rank-n.node(o.v).rank-n.edge(o).minlen}return As}var Ms,Lh;function Mg(){if(Lh)return Ms;Lh=1;var e=Re(),t=He().Graph,r=at().slack;Ms=n;function n(s){var l=new t({directed:!1}),u=s.nodes()[0],c=s.nodeCount();l.setNode(u,{});for(var d,f;o(l,s)<c;)d=i(l,s),f=l.hasNode(d.v)?r(s,d):-r(s,d),a(l,s,f);return l}function o(s,l){function u(c){e.forEach(l.nodeEdges(c),function(d){var f=d.v,p=c===f?d.w:f;!s.hasNode(p)&&!r(l,d)&&(s.setNode(p,{}),s.setEdge(c,p,{}),u(p))})}return e.forEach(s.nodes(),u),s.nodeCount()}function i(s,l){return e.minBy(l.edges(),function(u){if(s.hasNode(u.v)!==s.hasNode(u.w))return r(l,u)})}function a(s,l,u){e.forEach(s.nodes(),function(c){l.node(c).rank+=u})}return Ms}var Ps,Fh;function Tm(){if(Fh)return Ps;Fh=1;var e=Re(),t=Mg(),r=at().slack,n=at().longestPath,o=He().alg.preorder,i=He().alg.postorder,a=ke().simplify;Ps=s,s.initLowLimValues=d,s.initCutValues=l,s.calcCutValue=c,s.leaveEdge=p,s.enterEdge=x,s.exchangeEdges=y;function s(b){b=a(b),n(b);var _=t(b);d(_),l(_,b);for(var w,E;w=p(_);)E=x(_,b,w),y(_,b,w,E)}function l(b,_){var w=i(b,b.nodes());w=w.slice(0,w.length-1),e.forEach(w,function(E){u(b,_,E)})}function u(b,_,w){var E=b.node(w),R=E.parent;b.edge(w,R).cutvalue=c(b,_,w)}function c(b,_,w){var E=b.node(w),R=E.parent,I=!0,A=_.edge(w,R),k=0;return A||(I=!1,A=_.edge(R,w)),k=A.weight,e.forEach(_.nodeEdges(w),function(M){var z=M.v===w,G=z?M.w:M.v;if(G!==R){var U=z===I,V=_.edge(M).weight;if(k+=U?V:-V,v(b,w,G)){var X=b.edge(w,G).cutvalue;k+=U?-X:X}}}),k}function d(b,_){arguments.length<2&&(_=b.nodes()[0]),f(b,{},1,_)}function f(b,_,w,E,R){var I=w,A=b.node(E);return _[E]=!0,e.forEach(b.neighbors(E),function(k){e.has(_,k)||(w=f(b,_,w,k,E))}),A.low=I,A.lim=w++,R?A.parent=R:delete A.parent,w}function p(b){return e.find(b.edges(),function(_){return b.edge(_).cutvalue<0})}function x(b,_,w){var E=w.v,R=w.w;_.hasEdge(E,R)||(E=w.w,R=w.v);var I=b.node(E),A=b.node(R),k=I,M=!1;I.lim>A.lim&&(k=A,M=!0);var z=e.filter(_.edges(),function(G){return M===h(b,b.node(G.v),k)&&M!==h(b,b.node(G.w),k)});return e.minBy(z,function(G){return r(_,G)})}function y(b,_,w,E){var R=w.v,I=w.w;b.removeEdge(R,I),b.setEdge(E.v,E.w,{}),d(b),l(b,_),g(b,_)}function g(b,_){var w=e.find(b.nodes(),function(R){return!_.node(R).parent}),E=o(b,w);E=E.slice(1),e.forEach(E,function(R){var I=b.node(R).parent,A=_.edge(R,I),k=!1;A||(A=_.edge(I,R),k=!0),_.node(R).rank=_.node(I).rank+(k?A.minlen:-A.minlen)})}function v(b,_,w){return b.hasEdge(_,w)}function h(b,_,w){return w.low<=_.lim&&_.lim<=w.lim}return Ps}var Os,Dh;function Am(){if(Dh)return Os;Dh=1;var e=at(),t=e.longestPath,r=Mg(),n=Tm();Os=o;function o(l){switch(l.graph().ranker){case"network-simplex":s(l);break;case"tight-tree":a(l);break;case"longest-path":i(l);break;default:s(l)}}var i=t;function a(l){t(l),r(l)}function s(l){n(l)}return Os}var js,Bh;function Mm(){if(Bh)return js;Bh=1;var e=Re();js=t;function t(o){var i=n(o);e.forEach(o.graph().dummyChains,function(a){for(var s=o.node(a),l=s.edgeObj,u=r(o,i,l.v,l.w),c=u.path,d=u.lca,f=0,p=c[f],x=!0;a!==l.w;){if(s=o.node(a),x){for(;(p=c[f])!==d&&o.node(p).maxRank<s.rank;)f++;p===d&&(x=!1)}if(!x){for(;f<c.length-1&&o.node(p=c[f+1]).minRank<=s.rank;)f++;p=c[f]}o.setParent(a,p),a=o.successors(a)[0]}})}function r(o,i,a,s){var l=[],u=[],c=Math.min(i[a].low,i[s].low),d=Math.max(i[a].lim,i[s].lim),f,p;f=a;do f=o.parent(f),l.push(f);while(f&&(i[f].low>c||d>i[f].lim));for(p=f,f=s;(f=o.parent(f))!==p;)u.push(f);return{path:l.concat(u.reverse()),lca:p}}function n(o){var i={},a=0;function s(l){var u=a;e.forEach(o.children(l),s),i[l]={low:u,lim:a++}}return e.forEach(o.children(),s),i}return js}var ks,zh;function Pm(){if(zh)return ks;zh=1;var e=Re(),t=ke();ks={run:r,cleanup:a};function r(s){var l=t.addDummyNode(s,"root",{},"_root"),u=o(s),c=e.max(e.values(u))-1,d=2*c+1;s.graph().nestingRoot=l,e.forEach(s.edges(),function(p){s.edge(p).minlen*=d});var f=i(s)+1;e.forEach(s.children(),function(p){n(s,l,d,f,c,u,p)}),s.graph().nodeRankFactor=d}function n(s,l,u,c,d,f,p){var x=s.children(p);if(!x.length){p!==l&&s.setEdge(l,p,{weight:0,minlen:u});return}var y=t.addBorderNode(s,"_bt"),g=t.addBorderNode(s,"_bb"),v=s.node(p);s.setParent(y,p),v.borderTop=y,s.setParent(g,p),v.borderBottom=g,e.forEach(x,function(h){n(s,l,u,c,d,f,h);var b=s.node(h),_=b.borderTop?b.borderTop:h,w=b.borderBottom?b.borderBottom:h,E=b.borderTop?c:2*c,R=_!==w?1:d-f[p]+1;s.setEdge(y,_,{weight:E,minlen:R,nestingEdge:!0}),s.setEdge(w,g,{weight:E,minlen:R,nestingEdge:!0})}),s.parent(p)||s.setEdge(l,y,{weight:0,minlen:d+f[p]})}function o(s){var l={};function u(c,d){var f=s.children(c);f&&f.length&&e.forEach(f,function(p){u(p,d+1)}),l[c]=d}return e.forEach(s.children(),function(c){u(c,1)}),l}function i(s){return e.reduce(s.edges(),function(l,u){return l+s.edge(u).weight},0)}function a(s){var l=s.graph();s.removeNode(l.nestingRoot),delete l.nestingRoot,e.forEach(s.edges(),function(u){var c=s.edge(u);c.nestingEdge&&s.removeEdge(u)})}return ks}var Ns,$h;function Om(){if($h)return Ns;$h=1;var e=Re(),t=ke();Ns=r;function r(o){function i(a){var s=o.children(a),l=o.node(a);if(s.length&&e.forEach(s,i),e.has(l,"minRank")){l.borderLeft=[],l.borderRight=[];for(var u=l.minRank,c=l.maxRank+1;u<c;++u)n(o,"borderLeft","_bl",a,l,u),n(o,"borderRight","_br",a,l,u)}}e.forEach(o.children(),i)}function n(o,i,a,s,l,u){var c={width:0,height:0,rank:u,borderType:i},d=l[i][u-1],f=t.addDummyNode(o,"border",c,a);l[i][u]=f,o.setParent(f,s),d&&o.setEdge(d,f,{weight:1})}return Ns}var Ls,Gh;function jm(){if(Gh)return Ls;Gh=1;var e=Re();Ls={adjust:t,undo:r};function t(u){var c=u.graph().rankdir.toLowerCase();(c==="lr"||c==="rl")&&n(u)}function r(u){var c=u.graph().rankdir.toLowerCase();(c==="bt"||c==="rl")&&i(u),(c==="lr"||c==="rl")&&(s(u),n(u))}function n(u){e.forEach(u.nodes(),function(c){o(u.node(c))}),e.forEach(u.edges(),function(c){o(u.edge(c))})}function o(u){var c=u.width;u.width=u.height,u.height=c}function i(u){e.forEach(u.nodes(),function(c){a(u.node(c))}),e.forEach(u.edges(),function(c){var d=u.edge(c);e.forEach(d.points,a),e.has(d,"y")&&a(d)})}function a(u){u.y=-u.y}function s(u){e.forEach(u.nodes(),function(c){l(u.node(c))}),e.forEach(u.edges(),function(c){var d=u.edge(c);e.forEach(d.points,l),e.has(d,"x")&&l(d)})}function l(u){var c=u.x;u.x=u.y,u.y=c}return Ls}var Fs,Wh;function km(){if(Wh)return Fs;Wh=1;var e=Re();Fs=t;function t(r){var n={},o=e.filter(r.nodes(),function(u){return!r.children(u).length}),i=e.max(e.map(o,function(u){return r.node(u).rank})),a=e.map(e.range(i+1),function(){return[]});function s(u){if(!e.has(n,u)){n[u]=!0;var c=r.node(u);a[c.rank].push(u),e.forEach(r.successors(u),s)}}var l=e.sortBy(o,function(u){return r.node(u).rank});return e.forEach(l,s),a}return Fs}var Ds,Hh;function Nm(){if(Hh)return Ds;Hh=1;var e=Re();Ds=t;function t(n,o){for(var i=0,a=1;a<o.length;++a)i+=r(n,o[a-1],o[a]);return i}function r(n,o,i){for(var a=e.zipObject(i,e.map(i,function(f,p){return p})),s=e.flatten(e.map(o,function(f){return e.sortBy(e.map(n.outEdges(f),function(p){return{pos:a[p.w],weight:n.edge(p).weight}}),"pos")}),!0),l=1;l<i.length;)l<<=1;var u=2*l-1;l-=1;var c=e.map(new Array(u),function(){return 0}),d=0;return e.forEach(s.forEach(function(f){var p=f.pos+l;c[p]+=f.weight;for(var x=0;p>0;)p%2&&(x+=c[p+1]),p=p-1>>1,c[p]+=f.weight;d+=f.weight*x})),d}return Ds}var Bs,Vh;function Lm(){if(Vh)return Bs;Vh=1;var e=Re();Bs=t;function t(r,n){return e.map(n,function(o){var i=r.inEdges(o);if(i.length){var a=e.reduce(i,function(s,l){var u=r.edge(l),c=r.node(l.v);return{sum:s.sum+u.weight*c.order,weight:s.weight+u.weight}},{sum:0,weight:0});return{v:o,barycenter:a.sum/a.weight,weight:a.weight}}else return{v:o}})}return Bs}var zs,Uh;function Fm(){if(Uh)return zs;Uh=1;var e=Re();zs=t;function t(o,i){var a={};e.forEach(o,function(l,u){var c=a[l.v]={indegree:0,in:[],out:[],vs:[l.v],i:u};e.isUndefined(l.barycenter)||(c.barycenter=l.barycenter,c.weight=l.weight)}),e.forEach(i.edges(),function(l){var u=a[l.v],c=a[l.w];!e.isUndefined(u)&&!e.isUndefined(c)&&(c.indegree++,u.out.push(a[l.w]))});var s=e.filter(a,function(l){return!l.indegree});return r(s)}function r(o){var i=[];function a(u){return function(c){c.merged||(e.isUndefined(c.barycenter)||e.isUndefined(u.barycenter)||c.barycenter>=u.barycenter)&&n(u,c)}}function s(u){return function(c){c.in.push(u),--c.indegree===0&&o.push(c)}}for(;o.length;){var l=o.pop();i.push(l),e.forEach(l.in.reverse(),a(l)),e.forEach(l.out,s(l))}return e.map(e.filter(i,function(u){return!u.merged}),function(u){return e.pick(u,["vs","i","barycenter","weight"])})}function n(o,i){var a=0,s=0;o.weight&&(a+=o.barycenter*o.weight,s+=o.weight),i.weight&&(a+=i.barycenter*i.weight,s+=i.weight),o.vs=i.vs.concat(o.vs),o.barycenter=a/s,o.weight=s,o.i=Math.min(i.i,o.i),i.merged=!0}return zs}var $s,Kh;function Dm(){if(Kh)return $s;Kh=1;var e=Re(),t=ke();$s=r;function r(i,a){var s=t.partition(i,function(y){return e.has(y,"barycenter")}),l=s.lhs,u=e.sortBy(s.rhs,function(y){return-y.i}),c=[],d=0,f=0,p=0;l.sort(o(!!a)),p=n(c,u,p),e.forEach(l,function(y){p+=y.vs.length,c.push(y.vs),d+=y.barycenter*y.weight,f+=y.weight,p=n(c,u,p)});var x={vs:e.flatten(c,!0)};return f&&(x.barycenter=d/f,x.weight=f),x}function n(i,a,s){for(var l;a.length&&(l=e.last(a)).i<=s;)a.pop(),i.push(l.vs),s++;return s}function o(i){return function(a,s){return a.barycenter<s.barycenter?-1:a.barycenter>s.barycenter?1:i?s.i-a.i:a.i-s.i}}return $s}var Gs,Zh;function Bm(){if(Zh)return Gs;Zh=1;var e=Re(),t=Lm(),r=Fm(),n=Dm();Gs=o;function o(s,l,u,c){var d=s.children(l),f=s.node(l),p=f?f.borderLeft:void 0,x=f?f.borderRight:void 0,y={};p&&(d=e.filter(d,function(w){return w!==p&&w!==x}));var g=t(s,d);e.forEach(g,function(w){if(s.children(w.v).length){var E=o(s,w.v,u,c);y[w.v]=E,e.has(E,"barycenter")&&a(w,E)}});var v=r(g,u);i(v,y);var h=n(v,c);if(p&&(h.vs=e.flatten([p,h.vs,x],!0),s.predecessors(p).length)){var b=s.node(s.predecessors(p)[0]),_=s.node(s.predecessors(x)[0]);e.has(h,"barycenter")||(h.barycenter=0,h.weight=0),h.barycenter=(h.barycenter*h.weight+b.order+_.order)/(h.weight+2),h.weight+=2}return h}function i(s,l){e.forEach(s,function(u){u.vs=e.flatten(u.vs.map(function(c){return l[c]?l[c].vs:c}),!0)})}function a(s,l){e.isUndefined(s.barycenter)?(s.barycenter=l.barycenter,s.weight=l.weight):(s.barycenter=(s.barycenter*s.weight+l.barycenter*l.weight)/(s.weight+l.weight),s.weight+=l.weight)}return Gs}var Ws,Yh;function zm(){if(Yh)return Ws;Yh=1;var e=Re(),t=He().Graph;Ws=r;function r(o,i,a){var s=n(o),l=new t({compound:!0}).setGraph({root:s}).setDefaultNodeLabel(function(u){return o.node(u)});return e.forEach(o.nodes(),function(u){var c=o.node(u),d=o.parent(u);(c.rank===i||c.minRank<=i&&i<=c.maxRank)&&(l.setNode(u),l.setParent(u,d||s),e.forEach(o[a](u),function(f){var p=f.v===u?f.w:f.v,x=l.edge(p,u),y=e.isUndefined(x)?0:x.weight;l.setEdge(p,u,{weight:o.edge(f).weight+y})}),e.has(c,"minRank")&&l.setNode(u,{borderLeft:c.borderLeft[i],borderRight:c.borderRight[i]}))}),l}function n(o){for(var i;o.hasNode(i=e.uniqueId("_root")););return i}return Ws}var Hs,Xh;function $m(){if(Xh)return Hs;Xh=1;var e=Re();Hs=t;function t(r,n,o){var i={},a;e.forEach(o,function(s){for(var l=r.parent(s),u,c;l;){if(u=r.parent(l),u?(c=i[u],i[u]=l):(c=a,a=l),c&&c!==l){n.setEdge(c,l);return}l=u}})}return Hs}var Vs,Jh;function Gm(){if(Jh)return Vs;Jh=1;var e=Re(),t=km(),r=Nm(),n=Bm(),o=zm(),i=$m(),a=He().Graph,s=ke();Vs=l;function l(f){var p=s.maxRank(f),x=u(f,e.range(1,p+1),"inEdges"),y=u(f,e.range(p-1,-1,-1),"outEdges"),g=t(f);d(f,g);for(var v=Number.POSITIVE_INFINITY,h,b=0,_=0;_<4;++b,++_){c(b%2?x:y,b%4>=2),g=s.buildLayerMatrix(f);var w=r(f,g);w<v&&(_=0,h=e.cloneDeep(g),v=w)}d(f,h)}function u(f,p,x){return e.map(p,function(y){return o(f,y,x)})}function c(f,p){var x=new a;e.forEach(f,function(y){var g=y.graph().root,v=n(y,g,x,p);e.forEach(v.vs,function(h,b){y.node(h).order=b}),i(y,x,v.vs)})}function d(f,p){e.forEach(p,function(x){e.forEach(x,function(y,g){f.node(y).order=g})})}return Vs}var Us,Qh;function Wm(){if(Qh)return Us;Qh=1;var e=Re(),t=He().Graph,r=ke();Us={positionX:x,findType1Conflicts:n,findType2Conflicts:o,addConflict:a,hasConflict:s,verticalAlignment:l,horizontalCompaction:u,alignCoordinates:f,findSmallestWidthAlignment:d,balance:p};function n(v,h){var b={};function _(w,E){var R=0,I=0,A=w.length,k=e.last(E);return e.forEach(E,function(M,z){var G=i(v,M),U=G?v.node(G).order:A;(G||M===k)&&(e.forEach(E.slice(I,z+1),function(V){e.forEach(v.predecessors(V),function(X){var he=v.node(X),ee=he.order;(ee<R||U<ee)&&!(he.dummy&&v.node(V).dummy)&&a(b,X,V)})}),I=z+1,R=U)}),E}return e.reduce(h,_),b}function o(v,h){var b={};function _(E,R,I,A,k){var M;e.forEach(e.range(R,I),function(z){M=E[z],v.node(M).dummy&&e.forEach(v.predecessors(M),function(G){var U=v.node(G);U.dummy&&(U.order<A||U.order>k)&&a(b,G,M)})})}function w(E,R){var I=-1,A,k=0;return e.forEach(R,function(M,z){if(v.node(M).dummy==="border"){var G=v.predecessors(M);G.length&&(A=v.node(G[0]).order,_(R,k,z,I,A),k=z,I=A)}_(R,k,R.length,A,E.length)}),R}return e.reduce(h,w),b}function i(v,h){if(v.node(h).dummy)return e.find(v.predecessors(h),function(b){return v.node(b).dummy})}function a(v,h,b){if(h>b){var _=h;h=b,b=_}var w=v[h];w||(v[h]=w={}),w[b]=!0}function s(v,h,b){if(h>b){var _=h;h=b,b=_}return e.has(v[h],b)}function l(v,h,b,_){var w={},E={},R={};return e.forEach(h,function(I){e.forEach(I,function(A,k){w[A]=A,E[A]=A,R[A]=k})}),e.forEach(h,function(I){var A=-1;e.forEach(I,function(k){var M=_(k);if(M.length){M=e.sortBy(M,function(X){return R[X]});for(var z=(M.length-1)/2,G=Math.floor(z),U=Math.ceil(z);G<=U;++G){var V=M[G];E[k]===k&&A<R[V]&&!s(b,k,V)&&(E[V]=k,E[k]=w[k]=w[V],A=R[V])}}})}),{root:w,align:E}}function u(v,h,b,_,w){var E={},R=c(v,h,b,w),I=w?"borderLeft":"borderRight";function A(z,G){for(var U=R.nodes(),V=U.pop(),X={};V;)X[V]?z(V):(X[V]=!0,U.push(V),U=U.concat(G(V))),V=U.pop()}function k(z){E[z]=R.inEdges(z).reduce(function(G,U){return Math.max(G,E[U.v]+R.edge(U))},0)}function M(z){var G=R.outEdges(z).reduce(function(V,X){return Math.min(V,E[X.w]-R.edge(X))},Number.POSITIVE_INFINITY),U=v.node(z);G!==Number.POSITIVE_INFINITY&&U.borderType!==I&&(E[z]=Math.max(E[z],G))}return A(k,R.predecessors.bind(R)),A(M,R.successors.bind(R)),e.forEach(_,function(z){E[z]=E[b[z]]}),E}function c(v,h,b,_){var w=new t,E=v.graph(),R=y(E.nodesep,E.edgesep,_);return e.forEach(h,function(I){var A;e.forEach(I,function(k){var M=b[k];if(w.setNode(M),A){var z=b[A],G=w.edge(z,M);w.setEdge(z,M,Math.max(R(v,k,A),G||0))}A=k})}),w}function d(v,h){return e.minBy(e.values(h),function(b){var _=Number.NEGATIVE_INFINITY,w=Number.POSITIVE_INFINITY;return e.forIn(b,function(E,R){var I=g(v,R)/2;_=Math.max(E+I,_),w=Math.min(E-I,w)}),_-w})}function f(v,h){var b=e.values(h),_=e.min(b),w=e.max(b);e.forEach(["u","d"],function(E){e.forEach(["l","r"],function(R){var I=E+R,A=v[I],k;if(A!==h){var M=e.values(A);k=R==="l"?_-e.min(M):w-e.max(M),k&&(v[I]=e.mapValues(A,function(z){return z+k}))}})})}function p(v,h){return e.mapValues(v.ul,function(b,_){if(h)return v[h.toLowerCase()][_];var w=e.sortBy(e.map(v,_));return(w[1]+w[2])/2})}function x(v){var h=r.buildLayerMatrix(v),b=e.merge(n(v,h),o(v,h)),_={},w;e.forEach(["u","d"],function(R){w=R==="u"?h:e.values(h).reverse(),e.forEach(["l","r"],function(I){I==="r"&&(w=e.map(w,function(z){return e.values(z).reverse()}));var A=(R==="u"?v.predecessors:v.successors).bind(v),k=l(v,w,b,A),M=u(v,w,k.root,k.align,I==="r");I==="r"&&(M=e.mapValues(M,function(z){return-z})),_[R+I]=M})});var E=d(v,_);return f(_,E),p(_,v.graph().align)}function y(v,h,b){return function(_,w,E){var R=_.node(w),I=_.node(E),A=0,k;if(A+=R.width/2,e.has(R,"labelpos"))switch(R.labelpos.toLowerCase()){case"l":k=-R.width/2;break;case"r":k=R.width/2;break}if(k&&(A+=b?k:-k),k=0,A+=(R.dummy?h:v)/2,A+=(I.dummy?h:v)/2,A+=I.width/2,e.has(I,"labelpos"))switch(I.labelpos.toLowerCase()){case"l":k=I.width/2;break;case"r":k=-I.width/2;break}return k&&(A+=b?k:-k),k=0,A}}function g(v,h){return v.node(h).width}return Us}var Ks,ep;function Hm(){if(ep)return Ks;ep=1;var e=Re(),t=ke(),r=Wm().positionX;Ks=n;function n(i){i=t.asNonCompoundGraph(i),o(i),e.forEach(r(i),function(a,s){i.node(s).x=a})}function o(i){var a=t.buildLayerMatrix(i),s=i.graph().ranksep,l=0;e.forEach(a,function(u){var c=e.max(e.map(u,function(d){return i.node(d).height}));e.forEach(u,function(d){i.node(d).y=l+c/2}),l+=c+s})}return Ks}var Zs,rp;function Vm(){if(rp)return Zs;rp=1;var e=Re(),t=qm(),r=Im(),n=Am(),o=ke().normalizeRanks,i=Mm(),a=ke().removeEmptyRanks,s=Pm(),l=Om(),u=jm(),c=Gm(),d=Hm(),f=ke(),p=He().Graph;Zs=x;function x(S,O){var D=O&&O.debugTiming?f.time:f.notime;D("layout",function(){var F=D(" buildLayoutGraph",function(){return A(S)});D(" runLayout",function(){y(F,D)}),D(" updateInputGraph",function(){g(S,F)})})}function y(S,O){O(" makeSpaceForEdgeLabels",function(){k(S)}),O(" removeSelfEdges",function(){Y(S)}),O(" acyclic",function(){t.run(S)}),O(" nestingGraph.run",function(){s.run(S)}),O(" rank",function(){n(f.asNonCompoundGraph(S))}),O(" injectEdgeLabelProxies",function(){M(S)}),O(" removeEmptyRanks",function(){a(S)}),O(" nestingGraph.cleanup",function(){s.cleanup(S)}),O(" normalizeRanks",function(){o(S)}),O(" assignRankMinMax",function(){z(S)}),O(" removeEdgeLabelProxies",function(){G(S)}),O(" normalize.run",function(){r.run(S)}),O(" parentDummyChains",function(){i(S)}),O(" addBorderSegments",function(){l(S)}),O(" order",function(){c(S)}),O(" insertSelfEdges",function(){oe(S)}),O(" adjustCoordinateSystem",function(){u.adjust(S)}),O(" position",function(){d(S)}),O(" positionSelfEdges",function(){pe(S)}),O(" removeBorderNodes",function(){ee(S)}),O(" normalize.undo",function(){r.undo(S)}),O(" fixupEdgeLabelCoords",function(){X(S)}),O(" undoCoordinateSystem",function(){u.undo(S)}),O(" translateGraph",function(){U(S)}),O(" assignNodeIntersects",function(){V(S)}),O(" reversePoints",function(){he(S)}),O(" acyclic.undo",function(){t.undo(S)})}function g(S,O){e.forEach(S.nodes(),function(D){var F=S.node(D),Z=O.node(D);F&&(F.x=Z.x,F.y=Z.y,O.children(D).length&&(F.width=Z.width,F.height=Z.height))}),e.forEach(S.edges(),function(D){var F=S.edge(D),Z=O.edge(D);F.points=Z.points,e.has(Z,"x")&&(F.x=Z.x,F.y=Z.y)}),S.graph().width=O.graph().width,S.graph().height=O.graph().height}var v=["nodesep","edgesep","ranksep","marginx","marginy"],h={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},b=["acyclicer","ranker","rankdir","align"],_=["width","height"],w={width:0,height:0},E=["minlen","weight","width","height","labeloffset"],R={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},I=["labelpos"];function A(S){var O=new p({multigraph:!0,compound:!0}),D=ge(S.graph());return O.setGraph(e.merge({},h,fe(D,v),e.pick(D,b))),e.forEach(S.nodes(),function(F){var Z=ge(S.node(F));O.setNode(F,e.defaults(fe(Z,_),w)),O.setParent(F,S.parent(F))}),e.forEach(S.edges(),function(F){var Z=ge(S.edge(F));O.setEdge(F,e.merge({},R,fe(Z,E),e.pick(Z,I)))}),O}function k(S){var O=S.graph();O.ranksep/=2,e.forEach(S.edges(),function(D){var F=S.edge(D);F.minlen*=2,F.labelpos.toLowerCase()!=="c"&&(O.rankdir==="TB"||O.rankdir==="BT"?F.width+=F.labeloffset:F.height+=F.labeloffset)})}function M(S){e.forEach(S.edges(),function(O){var D=S.edge(O);if(D.width&&D.height){var F=S.node(O.v),Z=S.node(O.w),ne={rank:(Z.rank-F.rank)/2+F.rank,e:O};f.addDummyNode(S,"edge-proxy",ne,"_ep")}})}function z(S){var O=0;e.forEach(S.nodes(),function(D){var F=S.node(D);F.borderTop&&(F.minRank=S.node(F.borderTop).rank,F.maxRank=S.node(F.borderBottom).rank,O=e.max(O,F.maxRank))}),S.graph().maxRank=O}function G(S){e.forEach(S.nodes(),function(O){var D=S.node(O);D.dummy==="edge-proxy"&&(S.edge(D.e).labelRank=D.rank,S.removeNode(O))})}function U(S){var O=Number.POSITIVE_INFINITY,D=0,F=Number.POSITIVE_INFINITY,Z=0,ne=S.graph(),re=ne.marginx||0,ue=ne.marginy||0;function Ce(ie){var ve=ie.x,W=ie.y,ye=ie.width,K=ie.height;O=Math.min(O,ve-ye/2),D=Math.max(D,ve+ye/2),F=Math.min(F,W-K/2),Z=Math.max(Z,W+K/2)}e.forEach(S.nodes(),function(ie){Ce(S.node(ie))}),e.forEach(S.edges(),function(ie){var ve=S.edge(ie);e.has(ve,"x")&&Ce(ve)}),O-=re,F-=ue,e.forEach(S.nodes(),function(ie){var ve=S.node(ie);ve.x-=O,ve.y-=F}),e.forEach(S.edges(),function(ie){var ve=S.edge(ie);e.forEach(ve.points,function(W){W.x-=O,W.y-=F}),e.has(ve,"x")&&(ve.x-=O),e.has(ve,"y")&&(ve.y-=F)}),ne.width=D-O+re,ne.height=Z-F+ue}function V(S){e.forEach(S.edges(),function(O){var D=S.edge(O),F=S.node(O.v),Z=S.node(O.w),ne,re;D.points?(ne=D.points[0],re=D.points[D.points.length-1]):(D.points=[],ne=Z,re=F),D.points.unshift(f.intersectRect(F,ne)),D.points.push(f.intersectRect(Z,re))})}function X(S){e.forEach(S.edges(),function(O){var D=S.edge(O);if(e.has(D,"x"))switch((D.labelpos==="l"||D.labelpos==="r")&&(D.width-=D.labeloffset),D.labelpos){case"l":D.x-=D.width/2+D.labeloffset;break;case"r":D.x+=D.width/2+D.labeloffset;break}})}function he(S){e.forEach(S.edges(),function(O){var D=S.edge(O);D.reversed&&D.points.reverse()})}function ee(S){e.forEach(S.nodes(),function(O){if(S.children(O).length){var D=S.node(O),F=S.node(D.borderTop),Z=S.node(D.borderBottom),ne=S.node(e.last(D.borderLeft)),re=S.node(e.last(D.borderRight));D.width=Math.abs(re.x-ne.x),D.height=Math.abs(Z.y-F.y),D.x=ne.x+D.width/2,D.y=F.y+D.height/2}}),e.forEach(S.nodes(),function(O){S.node(O).dummy==="border"&&S.removeNode(O)})}function Y(S){e.forEach(S.edges(),function(O){if(O.v===O.w){var D=S.node(O.v);D.selfEdges||(D.selfEdges=[]),D.selfEdges.push({e:O,label:S.edge(O)}),S.removeEdge(O)}})}function oe(S){var O=f.buildLayerMatrix(S);e.forEach(O,function(D){var F=0;e.forEach(D,function(Z,ne){var re=S.node(Z);re.order=ne+F,e.forEach(re.selfEdges,function(ue){f.addDummyNode(S,"selfedge",{width:ue.label.width,height:ue.label.height,rank:re.rank,order:ne+ ++F,e:ue.e,label:ue.label},"_se")}),delete re.selfEdges})})}function pe(S){e.forEach(S.nodes(),function(O){var D=S.node(O);if(D.dummy==="selfedge"){var F=S.node(D.e.v),Z=F.x+F.width/2,ne=F.y,re=D.x-Z,ue=F.height/2;S.setEdge(D.e,D.label),S.removeNode(O),D.label.points=[{x:Z+2*re/3,y:ne-ue},{x:Z+5*re/6,y:ne-ue},{x:Z+re,y:ne},{x:Z+5*re/6,y:ne+ue},{x:Z+2*re/3,y:ne+ue}],D.label.x=D.x,D.label.y=D.y}})}function fe(S,O){return e.mapValues(e.pick(S,O),Number)}function ge(S){var O={};return e.forEach(S,function(D,F){O[F.toLowerCase()]=D}),O}return Zs}var Ys,tp;function Um(){if(tp)return Ys;tp=1;var e=Re(),t=ke(),r=He().Graph;Ys={debugOrdering:n};function n(o){var i=t.buildLayerMatrix(o),a=new r({compound:!0,multigraph:!0}).setGraph({});return e.forEach(o.nodes(),function(s){a.setNode(s,{label:s}),a.setParent(s,"layer"+o.node(s).rank)}),e.forEach(o.edges(),function(s){a.setEdge(s.v,s.w,{},s.name)}),e.forEach(i,function(s,l){var u="layer"+l;a.setNode(u,{rank:"same"}),e.reduce(s,function(c,d){return a.setEdge(c,d,{style:"invis"}),d})}),a}return Ys}var Xs,np;function Km(){return np||(np=1,Xs="0.8.5"),Xs}var Js,op;function Zm(){return op||(op=1,Js={graphlib:He(),layout:Vm(),debug:Um(),util:{time:ke().time,notime:ke().notime},version:Km()}),Js}var Ym=Zm();const ip=jv(Ym);function Xm(e,t,r){const n=new Set(e.map(u=>u.id)),o=new Set;for(const u of e)u.parent&&n.has(u.parent)&&o.add(u.parent);const i=new ip.graphlib.Graph({multigraph:!0,compound:!0});i.setGraph({rankdir:r.rankDir,nodesep:r.nodeSep,edgesep:r.edgeSep,ranksep:r.rankSep,ranker:"network-simplex"}),i.setDefaultEdgeLabel(()=>({})),i.setDefaultNodeLabel(()=>({}));for(const u of e)i.setNode(u.id,{width:u.width+2,height:u.height+2});for(const u of e)u.parent&&n.has(u.parent)&&i.setParent(u.id,u.parent);for(const u of t)!n.has(u.source)||!n.has(u.target)||o.has(u.source)||o.has(u.target)||i.setEdge(u.source,u.target,{minlen:1,weight:1},u.id);ip.layout(i);const a=new Map;for(const u of e){if(o.has(u.id))continue;const c=i.node(u.id);c&&Number.isFinite(c.x)&&Number.isFinite(c.y)&&a.set(u.id,{x:c.x,y:c.y})}const s=r.spacingFactor;if(a.size){let u=1/0,c=1/0,d=-1/0,f=-1/0;a.forEach(y=>{u=Math.min(u,y.x),c=Math.min(c,y.y),d=Math.max(d,y.x),f=Math.max(f,y.y)});const p=(u+d)/2,x=(c+f)/2;a.forEach((y,g)=>a.set(g,{x:p+(y.x-p)*s,y:x+(y.y-x)*s}))}const l=r.nodeAlignment??"center";if(l!=="center"){const u=r.rankDir==="LR"||r.rankDir==="RL",c=u?"x":"y",d=u?"width":"height",f=r.rankDir==="RL"||r.rankDir==="BT"?-1:1,p=l==="leading"?-f:f,x=new Map;for(const y of e){const g=a.get(y.id);if(!g)continue;const v=g[c];x.set(v,Math.max(x.get(v)??0,y[d]))}for(const y of e){const g=a.get(y.id);if(!g)continue;const v=g[c],h=(x.get(v)-y[d])/2;a.set(y.id,{...g,[c]:v+p*h})}}return a}function Jm(e,t,r,n,o){const i=new Map,a=new Map(e.map(c=>[c.id,c]));for(const c of e){if(!c.parent||!a.has(c.parent))continue;const d=i.get(c.parent);d?d.push(c.id):i.set(c.parent,[c.id])}const s=(c,d=new Set)=>{var p;const f=(p=a.get(c))==null?void 0:p.parent;return!f||!a.has(f)||d.has(c)?0:(d.add(c),1+s(f,d))},l=[...i.keys()].sort((c,d)=>s(d)-s(c)),u=new Map;for(const c of l){let d=null;for(const x of i.get(c)||[]){let y=u.get(x);if(!y){const g=t.get(x);if(!g)continue;const v=r.get(x)||{w:60,h:60};y={x1:g.x-v.w/2,y1:g.y-v.h/2,x2:g.x+v.w/2,y2:g.y+v.h/2}}d=d?{x1:Math.min(d.x1,y.x1),y1:Math.min(d.y1,y.y1),x2:Math.max(d.x2,y.x2),y2:Math.max(d.y2,y.y2)}:{...y}}if(!d)continue;const f=n(c);d={x1:d.x1-f,y1:d.y1-f,x2:d.x2+f,y2:d.y2+f};const p=o(c);if(p){const x=d.x2-d.x1,y=d.y2-d.y1;if(p.w>x){const g=(p.w-x)/2;d.x1-=g,d.x2+=g}if(p.h>y){const g=(p.h-y)/2;d.y1-=g,d.y2+=g}}u.set(c,d)}return u}function Qm(e){const t=e.getBoundingClientRect(),r=t.height/e.offsetHeight;return!Number.isFinite(r)||r<=0?[]:[...e.querySelectorAll("[data-flow-property]")].flatMap(n=>{if(n.closest(".flow-sdk-node")!==e)return[];const o=n.getBoundingClientRect();return!o.width||!o.height?[]:[{property:n.getAttribute("data-flow-property"),top:Math.round((o.top-t.top)/r*1e3)/1e3,height:Math.round(o.height/r*1e3)/1e3}]})}function ex({id:e,x:t,y:r,placed:n,onMount:o,drawHandles:i,handleColor:a,propertyMode:s,reversePorts:l,onPropertyRows:u,children:c}){const d=q.useRef(null),[f,p]=q.useState([]);return q.useLayoutEffect(()=>(o(e,d.current),()=>o(e,null)),[e,o]),q.useLayoutEffect(()=>{const x=d.current;if(!x)return;let y="";const g=()=>{const _=s?Qm(x):[],w=JSON.stringify(_);w!==y&&(y=w,p(_),u==null||u(e,_))};if(g(),!s)return;const v=new ResizeObserver(g),h=()=>{v.disconnect(),v.observe(x),x.querySelectorAll("[data-flow-property]").forEach(_=>v.observe(_)),g()};h();const b=new MutationObserver(h);return b.observe(x,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["data-flow-property"]}),x.addEventListener("scroll",g,!0),()=>{v.disconnect(),b.disconnect(),x.removeEventListener("scroll",g,!0)}},[e,s,u]),m.jsxs("div",{ref:d,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?void 0:"hidden"},children:[c,i&&s&&f.map(x=>["source","target"].map(y=>m.jsx("button",{type:"button",className:"flow-sdk-property-port","data-property":x.property,"data-port-role":y,"aria-label":`${y==="source"?"Connect":"Input"} ${x.property}`,title:`${y==="source"?"Connect":"Input"} ${x.property}`,style:{color:a,top:x.top+x.height/2,[y==="source"!=!!l?"right":"left"]:-16},onClick:g=>g.stopPropagation()},`${x.property}:${y}`))),i&&(!s||!f.length)&&m.jsx("button",{type:"button",className:"flow-sdk-handle","aria-label":"Draw edge",title:"Draw edge",style:{color:a},onClick:x=>x.stopPropagation(),children:m.jsx(Q.PiPlusBold,{size:24})})]})}const rx=q.memo(ex);class tx{constructor(t,r,n){hr(this,"_pan");hr(this,"_zoom");hr(this,"minZoom");hr(this,"maxZoom");hr(this,"size",{w:0,h:0});hr(this,"listeners",new Set);this.minZoom=r,this.maxZoom=n,this._pan={...t.pan},this._zoom=this.clamp(t.zoom)}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){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 o=this.clamp(r);o!==this._zoom&&(this._zoom=o,n=!0)}n&&this.emit()}zoomAt(t,r){const n=this.clamp(t),o=this._zoom;if(n===o)return;const i=n/o;this.set({x:r.x-(r.x-this._pan.x)*i,y:r.y-(r.y-this._pan.y)*i},n)}fit(t,r=0){const n=t.x2-t.x1,o=t.y2-t.y1;if(!(n>0)||!(o>0)||!this.size.w||!this.size.h)return;const i=this.clamp(Math.min((this.size.w-2*r)/n,(this.size.h-2*r)/o));this.set({x:(this.size.w-i*(t.x1+t.x2))/2,y:(this.size.h-i*(t.y1+t.y2))/2},i)}center(t){if(!this.size.w||!this.size.h)return;const r=this._zoom;this.set({x:(this.size.w-r*(t.x1+t.x2))/2,y:(this.size.h-r*(t.y1+t.y2))/2})}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 nx={LR:"rightward",RL:"leftward",TB:"downward",BT:"upward"},Qs={w:60,h:60},ap=4,ox=30,sp=300,ix=500,ax=45,sx=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2;function up(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 ux(e){const{nodes:t,edges:r,direction:n,nodeAlignment:o="center",edgeMode:i="workflow",rankSep:a,edgeSep:s,minZoom:l,maxZoom:u,initialViewport:c,containerStyle:d,lineColor:f,drawMode:p,dragMode:x,multiSelect:y,isPerformanceMode:g}=e,v=q.useRef(e);v.current=e;const h=q.useRef(null),b=q.useRef(null),_=q.useRef(null),w=q.useMemo(()=>new tx(c,l,u),[]);q.useEffect(()=>{w.minZoom=l,w.maxZoom=u},[w,l,u]);const E=q.useRef(new Map),R=q.useRef(new Map),I=q.useRef(new Map),A=q.useRef(null),[k,M]=q.useState(new Map),z=q.useRef(k);z.current=k;const G=q.useCallback((C,T)=>{M(j=>{if(JSON.stringify(j.get(C)??[])===JSON.stringify(T))return j;const P=new Map(j);return T.length?P.set(C,T):P.delete(C),P})},[]),[U,V]=q.useState(()=>new Map),X=q.useRef(U);X.current=U;const he=q.useRef(!1),ee=q.useRef(),Y=q.useRef(),oe=q.useRef(null),pe=q.useRef(),fe=q.useRef(!1),ge=()=>{oe.current!==null&&cancelAnimationFrame(oe.current),oe.current=null,clearTimeout(pe.current)},S=()=>{!he.current&&v.current.fitOnInit!==!1&&(fe.current=!0),clearTimeout(Y.current),Y.current=setTimeout(()=>{he.current=!0},ix)},O=C=>{ge();const T=new Map(X.current),j=performance.now(),P=()=>{ge(),V(C),S()},B=J=>{const te=Math.min(1,(J-j)/sp);if(te>=1)return P();const be=sx(te),Ee=new Map;C.forEach((le,me)=>{const ae=T.get(me);Ee.set(me,ae?{x:ae.x+(le.x-ae.x)*be,y:ae.y+(le.y-ae.y)*be}:le)}),V(Ee),oe.current=requestAnimationFrame(B)};oe.current=requestAnimationFrame(B),pe.current=setTimeout(P,sp+100)},D=()=>{const C=v.current,T=C.nodes.map(P=>{const B=E.current.get(P.id)||Qs;return{id:P.id,parent:P.parent,width:B.w,height:B.h}});let j;try{j=Xm(T,C.edges,{rankDir:C.direction,nodeAlignment:C.nodeAlignment,rankSep:C.rankSep,edgeSep:C.edgeSep,nodeSep:5,spacingFactor:1.3})}catch(P){console.warn("[flow-sdk] layout failed",P);return}he.current&&!C.isPerformanceMode?O(j):(ge(),V(j),S())},F=q.useCallback(()=>{clearTimeout(ee.current),ee.current=setTimeout(D,v.current.layoutDebounce)},[]);q.useEffect(()=>{F()},[t,r,n,o,a,s,F]),q.useEffect(()=>()=>{clearTimeout(ee.current),clearTimeout(Y.current),ge()},[]);const Z=q.useCallback((C,T)=>{var j,P;if(!A.current&&typeof ResizeObserver<"u"&&(A.current=new ResizeObserver(B=>{let J=!1;for(const te of B){const be=I.current.get(te.target);if(!be)continue;const Ee=te.target,le=Ee.offsetWidth,me=Ee.offsetHeight;if(!le&&!me)continue;const ae=E.current.get(be);ae&&ae.w===le&&ae.h===me||(E.current.set(be,{w:le,h:me}),J=!0)}J&&F()})),T){R.current.set(C,T),I.current.set(T,C),(j=A.current)==null||j.observe(T);const B=T.offsetWidth,J=T.offsetHeight;(B||J)&&E.current.set(C,{w:B,h:J})}else{const B=R.current.get(C);B&&((P=A.current)==null||P.unobserve(B),I.current.delete(B)),R.current.delete(C),E.current.delete(C),z.current.has(C)&&G(C,[])}F()},[F,G]);q.useEffect(()=>()=>{var C;return(C=A.current)==null?void 0:C.disconnect()},[]);const ne=q.useMemo(()=>{const C=new Map;for(const T of t)T.label&&C.set(T.id,T.label);return C},[t]),re=q.useMemo(()=>Jm(t,U,E.current,C=>d(C).padding,C=>{const T=ne.get(C);if(!T)return;const j=d(C);return{w:iu(T,`bold ${j.fontSize}px ${ft}`)+2*ax,h:0}}),[t,U,d,ne]),ue=q.useRef(re);ue.current=re;const Ce=q.useCallback(C=>{const T=ue.current.get(C);if(T)return vv(T);const j=X.current.get(C);if(!j)return;const P=E.current.get(C)||Qs;return{x:j.x,y:j.y,w:P.w,h:P.h}},[]),ie=(C,T)=>{var B;if(i!=="properties"||T===void 0)return;const j=(B=k.get(C))==null?void 0:B.find(J=>J.property===T),P=Ce(C);return j&&P?P.y-P.h/2+j.top+j.height/2:void 0},ve=()=>{var T;const C=[];X.current.forEach((j,P)=>{if(ue.current.has(P))return;const B=E.current.get(P)||Qs;C.push(qr({x:j.x,y:j.y,w:B.w,h:B.h}))}),ue.current.forEach(j=>C.push(j));try{const j=(T=b.current)==null?void 0:T.getBBox();j&&j.width>0&&j.height>0&&C.push({x1:j.x,y1:j.y,x2:j.x+j.width,y2:j.y+j.height})}catch{}return yv(C)},W=()=>{var j;const{pan:C,zoom:T}=w;_.current&&(_.current.style.transform=`translate3d(${C.x}px, ${C.y}px, 0) scale(${T})`),(j=b.current)==null||j.setAttribute("transform",`translate(${C.x} ${C.y}) scale(${T})`)};q.useEffect(()=>{W();let C=null,T;const j=w.onChange(()=>{W();const P=h.current;P&&(P.classList.add("flow-sdk-busy"),clearTimeout(T),T=setTimeout(()=>P.classList.remove("flow-sdk-busy"),150)),C===null&&(C=requestAnimationFrame(()=>{var B,J;C=null,(J=(B=v.current).onViewportChange)==null||J.call(B,w.state)}))});return()=>{j(),clearTimeout(T),C!==null&&cancelAnimationFrame(C)}},[]),q.useLayoutEffect(()=>{const C=h.current;if(!C)return;const T=()=>{let P=C.clientWidth,B=C.clientHeight;B||(B=Math.max(0,window.innerHeight-C.getBoundingClientRect().top-100),B&&(C.style.height=`${B}px`)),P||(P=window.innerWidth,P&&(C.style.width=`${P}px`)),w.size={w:P,h:B}};if(T(),typeof ResizeObserver>"u")return;const j=new ResizeObserver(T);return j.observe(C),()=>j.disconnect()},[w]),q.useEffect(()=>{if(!fe.current)return;fe.current=!1;const C=ve();C&&w.fit(C,50)},[U]);const ye=q.useMemo(()=>{const C=(P=>{if(P===void 0)return w.zoom;w.set(void 0,P)}),T=(P=>{if(P===void 0)return w.pan;w.set(P)}),j=(P,B)=>{var te;const J=(te=h.current)==null?void 0:te.getBoundingClientRect();return{x:P-((J==null?void 0:J.left)??0),y:B-((J==null?void 0:J.top)??0)}};return{zoom:C,pan:T,zoomAt:(P,B)=>w.zoomAt(P,B),fit:(P=0)=>{const B=ve();B&&w.fit(B,P)},center:()=>{const P=ve();P&&w.center(P)},clientToModel:(P,B)=>w.renderedToModel(j(P,B)),modelToClient:P=>{var te;const B=(te=h.current)==null?void 0:te.getBoundingClientRect(),J=w.modelToRendered(P);return{x:J.x+((B==null?void 0:B.left)??0),y:J.y+((B==null?void 0:B.top)??0)}},getNodeBox:P=>Ce(P),onViewportChange:P=>w.onChange(P)}},[]);q.useEffect(()=>{var C,T;(T=(C=v.current).onInit)==null||T.call(C,ye)},[ye]);const K=q.useRef(null),we=q.useRef(new Map),Ae=q.useRef(!1),[Ie,Fe]=q.useState(null),[xe,qe]=q.useState(null),Ue=C=>{const T=h.current.getBoundingClientRect();return{x:C.clientX-T.left,y:C.clientY-T.top}},Ke=(C,T)=>{const j=v.current.nodes;for(let P=j.length-1;P>=0;P--){const B=j[P].id;if(B===T||ue.current.has(B))continue;const J=Ce(B);if(J&&Ou(C,qr(J)))return B}for(const[P,B]of ue.current)if(P!==T&&Ou(C,B))return P;return null},lr=(C,T)=>{if(v.current.edgeMode!=="properties")return null;const j=v.current.direction==="RL",P=Math.max(16,6/w.zoom);let B=null;for(const J of[...v.current.nodes].reverse()){const te=Ce(J.id),be=z.current.get(J.id);if(!te||!be||ue.current.has(J.id))continue;const Ee=te.x+(T==="source"!==j?1:-1)*te.w/2;for(const le of be){const me=te.y-te.h/2+le.top,ae=Math.hypot(C.x-Ee,C.y-me-le.height/2);if(C.x>=te.x-te.w/2&&C.x<=te.x+te.w/2&&C.y>=me&&C.y<=me+le.height)return{nodeId:J.id,property:le.property};ae<=P&&(!B||ae<B.distance)&&(B={nodeId:J.id,property:le.property,distance:ae})}}return B},_r=C=>{var te;if(C.button!==0||v.current.readOnly)return;const T=C.target;if(T.closest('input, textarea, select, [contenteditable="true"]'))return;const j=v.current,P=Ue(C);if(C.pointerType==="touch"){we.current.set(C.pointerId,P);const be=up(we.current);if(be){K.current={kind:"pinch",distance:be.distance,zoom:w.zoom,anchor:w.renderedToModel(be.center)},qe(null),Fe(null),Ae.current=!0;for(const Ee of we.current.keys())C.currentTarget.setPointerCapture(Ee);return}}if(K.current)return;Ae.current=!1;const B=j.drawHandles&&T.closest(".flow-sdk-handle"),J=j.edgeMode==="properties"&&j.drawHandles&&T.closest(".flow-sdk-property-port");if(!(J&&J.dataset.portRole!=="source")){if(j.drawMode||B||J){const be=w.renderedToModel(P),Ee=j.drawMode?lr(be,"source"):null,le=J||B,me=le?(te=le.closest("[data-node-id]"))==null?void 0:te.dataset.nodeId:(Ee==null?void 0:Ee.nodeId)??Ke(be),ae=J?J.dataset.property:Ee==null?void 0:Ee.property;if(me){K.current={kind:"draw",pointerId:C.pointerId,source:me,sourceProperty:ae,startClient:{x:C.clientX,y:C.clientY}},Ae.current=!0,qe({source:me,sourceProperty:ae,point:be,target:null}),C.currentTarget.setPointerCapture(C.pointerId);return}}T.closest(".flow-sdk-node, .flow-sdk-container, .flow-sdk-edge")||(j.multiSelect?K.current={kind:"box",pointerId:C.pointerId,start:P,current:P}:j.dragMode?K.current={kind:"pan",pointerId:C.pointerId,start:P,pan0:w.pan,moved:!1}:K.current={kind:"tap",pointerId:C.pointerId,start:P,moved:!1},C.currentTarget.setPointerCapture(C.pointerId))}},Ze=C=>{const T=K.current;if(!T||v.current.readOnly)return;const j=Ue(C);if(we.current.has(C.pointerId)&&we.current.set(C.pointerId,j),T.kind==="pinch"){const P=up(we.current);if(!P)return;const B=Math.max(w.minZoom,Math.min(w.maxZoom,T.zoom*P.distance/T.distance));w.set({x:P.center.x-T.anchor.x*B,y:P.center.y-T.anchor.y*B},B);return}if(T.pointerId===C.pointerId)switch(T.kind){case"pan":{const P=j.x-T.start.x,B=j.y-T.start.y;if(!T.moved&&Math.hypot(P,B)<=ap)return;T.moved=!0,Ae.current=!0,w.set({x:T.pan0.x+P,y:T.pan0.y+B});break}case"tap":{Math.hypot(j.x-T.start.x,j.y-T.start.y)>ap&&(T.moved=!0);break}case"box":{Ae.current=!0,T.current=j,Fe({x1:Math.min(T.start.x,j.x),y1:Math.min(T.start.y,j.y),x2:Math.max(T.start.x,j.x),y2:Math.max(T.start.y,j.y)});break}case"draw":{const P=w.renderedToModel(j),B=lr(P,"target");qe({source:T.source,sourceProperty:T.sourceProperty,point:P,target:(B==null?void 0:B.nodeId)??Ke(P,T.source),targetProperty:B==null?void 0:B.property});break}}},dr=(C,T)=>{var B,J,te,be,Ee;we.current.delete(C.pointerId);const j=K.current;if(!j)return;if(j.kind==="pinch"){const le=[...we.current][0];K.current=le&&v.current.dragMode&&!T?{kind:"pan",pointerId:le[0],start:le[1],pan0:w.pan,moved:!0}:null;return}if(j.pointerId!==C.pointerId)return;K.current=null;try{C.currentTarget.releasePointerCapture(C.pointerId)}catch{}const P=v.current;switch(T=T||!!P.readOnly,j.kind){case"pan":case"tap":!T&&!j.moved&&((B=P.onBackgroundTap)==null||B.call(P));break;case"box":{if(Fe(null),T)break;const le=w.renderedToModel(j.start),me=w.renderedToModel(j.current),ae={x1:Math.min(le.x,me.x),y1:Math.min(le.y,me.y),x2:Math.max(le.x,me.x),y2:Math.max(le.y,me.y)};if(ae.x2-ae.x1<1&&ae.y2-ae.y1<1){(J=P.onBackgroundTap)==null||J.call(P);break}const nr=[];for(const Su of P.nodes){const qu=Ce(Su.id);qu&&bv(qr(qu),ae)&&nr.push(Su.id)}nr.length&&((te=P.onBoxSelect)==null||te.call(P,nr));break}case"draw":{if(qe(null),T)break;const le=Ue(C),me=w.renderedToModel(le),ae=lr(me,"target"),nr=(ae==null?void 0:ae.nodeId)??Ke(me);if(nr===j.source&&(j.sourceProperty===void 0||(ae==null?void 0:ae.property)===void 0||ae.property===j.sourceProperty))break;nr?(be=P.onEdgeDraw)==null||be.call(P,j.source,nr,j.sourceProperty!==void 0||(ae==null?void 0:ae.property)!==void 0?{sourceProperty:j.sourceProperty,targetProperty:ae==null?void 0:ae.property}:void 0):j.sourceProperty===void 0&&Math.max(Math.abs(C.clientX-j.startClient.x),Math.abs(C.clientY-j.startClient.y))>ox&&((Ee=P.onDrawIntoSpace)==null||Ee.call(P,j.source,me));break}}},De=q.useCallback(()=>{var j;const C=K.current,T=[...we.current.keys()];C&&C.kind!=="pinch"&&T.push(C.pointerId),K.current=null,we.current.clear(),qe(null),Fe(null);for(const P of T)(j=h.current)!=null&&j.hasPointerCapture(P)&&h.current.releasePointerCapture(P)},[]);q.useEffect(()=>{const C=T=>{T.key==="Escape"&&De()};return window.addEventListener("keydown",C),window.addEventListener("blur",De),()=>{window.removeEventListener("keydown",C),window.removeEventListener("blur",De),K.current=null,we.current.clear()}},[De]),q.useEffect(()=>{De()},[p,x,y,i,n,e.drawHandles,e.readOnly,De]);const jr=q.useMemo(()=>{const C=new Map,T=new Map;for(const j of r){if(j.source!==j.target)continue;const P=C.get(j.source)??0;C.set(j.source,P+1),T.set(j.id,P)}return T},[r]),fr=nx[n],$=e.onEdgeSelect,L=e.onContainerSelect,H=xe?xe.target&&Ce(xe.target)||{x:xe.point.x,y:xe.point.y,w:1,h:1}:null,ce=xe?Ce(xe.source):null,se=["flow-sdk-canvas",p?"flow-sdk-draw":"",g?"flow-sdk-perf":""].filter(Boolean).join(" ");return m.jsxs("div",{ref:h,className:se,onPointerDownCapture:_r,onPointerMove:Ze,onPointerUp:C=>dr(C,!1),onPointerCancel:C=>dr(C,!0),onLostPointerCapture:C=>{const T=K.current;T&&(T.kind==="pinch"||T.pointerId===C.pointerId)&&De()},onClickCapture:C=>{(Ae.current||e.readOnly)&&(C.preventDefault(),C.stopPropagation())},children:[m.jsx("svg",{className:"flow-sdk-svg",children:m.jsxs("g",{ref:b,children:[m.jsx("g",{className:"flow-sdk-containers",children:[...re].map(([C,T])=>m.jsx(gv,{id:C,rect:T,label:ne.get(C),style:d(C),onSelect:L},C))}),m.jsx("g",{className:"flow-sdk-edges",children:r.map(C=>{const T=Ce(C.source),j=Ce(C.target);return!T||!j?null:m.jsx(Lu,{id:C.id,source:T,target:j,sourceProperty:C.sourceProperty,targetProperty:C.targetProperty,sourceY:ie(C.source,C.sourceProperty),targetY:ie(C.target,C.targetProperty),dir:fr,turn:C.turn,color:C.color,labelBg:C.labelBg,label:C.label,dashed:C.dashed,animated:C.animated&&!g,inverted:C.inverted,loopIndex:jr.get(C.id)??0,onSelect:$},C.id)})}),xe&&ce&&H&&m.jsx("g",{className:"flow-sdk-ghost",pointerEvents:"none",children:m.jsx(Lu,{id:"__flow-sdk-ghost",source:ce,target:H,sourceProperty:xe.sourceProperty,targetProperty:xe.targetProperty,sourceY:ie(xe.source,xe.sourceProperty),targetY:xe.target?ie(xe.target,xe.targetProperty):void 0,dir:fr,turn:.5,color:f,labelBg:f})})]})}),m.jsx("div",{ref:_,className:"flow-sdk-nodes",children:t.map(C=>{const T=U.get(C.id),j=re.get(C.id),P=(T==null?void 0:T.x)??(j?(j.x1+j.x2)/2:0),B=(T==null?void 0:T.y)??(j?(j.y1+j.y2)/2:0);return m.jsx(rx,{id:C.id,x:P,y:B,placed:!!T||!!j,onMount:Z,drawHandles:e.drawHandles&&!e.readOnly,handleColor:f,propertyMode:i==="properties",reversePorts:n==="RL",onPropertyRows:G,children:C.element},C.id)})}),Ie&&m.jsx("div",{className:"flow-sdk-box",style:{left:Ie.x1,top:Ie.y1,width:Ie.x2-Ie.x1,height:Ie.y2-Ie.y1}})]})}const cx=q.memo(ux),Jr=({name:e,...t})=>{const[r,n]=q.useState(null),[o,i]=q.useState(!0),[a,s]=q.useState(!1);return q.useEffect(()=>{if(!e||e.length<2){n(null),i(!1);return}i(!0),s(!1),(async()=>{try{let u;if(e.startsWith("Md"))u="md";else if(e.startsWith("Fa"))u="fa6";else if(e.startsWith("Io5"))u="io5";else if(e.startsWith("Io"))u="io";else if(e.startsWith("Ti"))u="ti";else if(e.startsWith("Go"))u="go";else if(e.startsWith("Fi"))u="fi";else if(e.startsWith("Di"))u="di";else if(e.startsWith("Ai"))u="ai";else if(e.startsWith("Bs"))u="bs";else if(e.startsWith("Ri"))u="ri";else if(e.startsWith("Fc"))u="fc";else if(e.startsWith("Gi"))u="gi";else if(e.startsWith("Hi2"))u="hi2";else if(e.startsWith("Hi"))u="hi";else if(e.startsWith("Si"))u="si";else if(e.startsWith("Sl"))u="sl";else if(e.startsWith("Im"))u="im";else if(e.startsWith("Bi"))u="bi";else if(e.startsWith("Pi"))u="pi";else if(e.startsWith("Vsc"))u="vsc";else if(e.startsWith("Tb"))u="tb";else if(e.startsWith("Tfi"))u="tfi";else if(e.startsWith("Cg"))u="cg";else if(e.startsWith("Lia"))u="lia";else if(e.startsWith("Lu"))u="lu";else throw new Error(`Unknown library prefix for icon: ${e}`);let c;switch(u){case"md":c=await import("react-icons/md");break;case"fa6":c=await import("react-icons/fa6");break;case"io5":c=await import("react-icons/io5");break;case"io":c=await import("react-icons/io");break;case"ti":c=await import("react-icons/ti");break;case"go":c=await import("react-icons/go");break;case"fi":c=await import("react-icons/fi");break;case"di":c=await import("react-icons/di");break;case"ai":c=await import("react-icons/ai");break;case"bs":c=await import("react-icons/bs");break;case"ri":c=await import("react-icons/ri");break;case"fc":c=await import("react-icons/fc");break;case"gi":c=await import("react-icons/gi");break;case"hi2":c=await import("react-icons/hi2");break;case"hi":c=await import("react-icons/hi");break;case"si":c=await import("react-icons/si");break;case"sl":c=await import("react-icons/sl");break;case"im":c=await import("react-icons/im");break;case"bi":c=await import("react-icons/bi");break;case"pi":c=await import("react-icons/pi");break;case"vsc":c=await import("react-icons/vsc");break;case"tb":c=await import("react-icons/tb");break;case"tfi":c=await import("react-icons/tfi");break;case"cg":c=await import("react-icons/cg");break;case"lia":c=await import("react-icons/lia");break;case"lu":c=await import("react-icons/lu");break;default:throw new Error(`Unsupported library: ${u}`)}const d=c[e];if(!d)throw new Error(`Icon ${e} not found in library ${u}`);n(()=>d)}catch(u){console.warn(`Failed to load icon ${e}:`,u.message),s(!0),n(null)}finally{i(!1)}})()},[e]),o||!r?null:m.jsx(r,{...t})};function Pg(e=!0){const t=q.useRef(null);return q.useEffect(()=>{if(!e||!t.current)return;const r=i=>{i.stopPropagation()},n=t.current,o=["mousedown","mouseup","click","dblclick","pointerdown","pointerup","wheel"];return o.forEach(i=>n.addEventListener(i,r)),()=>{o.forEach(i=>n.removeEventListener(i,r))}},[e]),t}const Ru=({nodeId:e,label:t,color:r,fontWeight:n="bold",fontSize:o="5xl",isEditing:i,onEditStart:a,onEditEnd:s})=>{const{callbacks:l,config:u,readOnly:c}=Le(),d=u.editable&&!c,[f,p]=q.useState(t),[x,y]=q.useState(),g=q.useRef(null),v=q.useRef(!1),h=Pg(i);q.useEffect(()=>{i&&(v.current=!1,g.current&&(g.current.focus(),g.current.select()))},[i]);const b=()=>{var w;if(v.current)return;v.current=!0;const _=f.trim();_&&_!==t&&((w=l.onNodeLabelChange)==null||w.call(l,e,_)),s()};return!d||!i?m.jsx(N.Text,{color:r,fontWeight:n,fontSize:o,minW:0,maxW:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",title:t,onDoubleClick:d?_=>{_.stopPropagation(),y({width:_.currentTarget.offsetWidth,height:_.currentTarget.offsetHeight}),p(t),a()}:void 0,cursor:d?"text":void 0,children:t}):m.jsx("div",{ref:h,style:x,children:m.jsx(N.Input,{ref:g,value:f,onChange:_=>p(_.target.value),onBlur:b,onKeyDown:_=>{_.key==="Enter"&&b(),_.key==="Escape"&&(v.current=!0,s())},color:r,fontWeight:n,fontSize:o,bg:"transparent",borderWidth:0,p:0,display:"block",w:"100%",h:"100%",minW:0,minH:0,lineHeight:"normal"})})},cp=({icon:e,label:t,onClick:r,color:n,boxSize:o=6,...i})=>{const{background:a,border:s,colorText:l}=$e();return m.jsxs(N.Tooltip.Root,{positioning:{placement:i.placement||"top"},children:[m.jsx(N.Tooltip.Trigger,{asChild:!0,children:m.jsx(N.Flex,{children:m.jsx(N.Icon,{as:e,boxSize:o,color:n,cursor:r?"pointer":void 0,onClick:r})})}),m.jsx(N.Tooltip.Positioner,{children:m.jsx(N.Tooltip.Content,{bgColor:i.bgColor||a,borderColor:i.borderColor||s,borderWidth:1,color:i.textColor||l,borderRadius:15,fontWeight:300,fontSize:"sm",p:2,px:4,shadow:"none",children:t})})]})},lx=({data:e,children:t,isInverted:r,isParent:n})=>{var he,ee;const{selectedNodeIds:o,setSelectedNodeIds:i,selectedEdgeId:a,setSelectedEdgeId:s,isMultiSelectMode:l,isPerformanceMode:u,engineRef:c,callbacks:d,config:f,themeColor:p,direction:x}=Le(),{background:y,border:g,colorText:v}=$e(),h=q.useRef(null),b=q.useRef(null),[_,w]=q.useState(!1),[E,R]=q.useState(!1),I=e==null?void 0:e.id,A=o.includes(I),k=f.nodeOverlayActions,M=f.renderNodeOverlay,z=(()=>{var Y;try{const oe=(Y=c.current)==null?void 0:Y.zoom();return oe!==void 0&&oe<.08}catch{return!1}})(),G=q.useCallback(()=>{var Y,oe,pe,fe;if(!(E||f.readOnly))if(a&&(s(null),(Y=d.onEdgeDeselect)==null||Y.call(d)),l){const ge=o.includes(I),S=ge?o.filter(O=>O!==I):[...o,I];i(S),ge?(oe=d.onNodeDeselect)==null||oe.call(d):(pe=d.onNodeSelect)==null||pe.call(d,I,e)}else i([I]),(fe=d.onNodeSelect)==null||fe.call(d,I,e)},[I,e,o,a,l,E,i,s,d,f]),U=q.useCallback(()=>{var Y;E||f.readOnly||(Y=d.onNodeDoubleClick)==null||Y.call(d,I,e)},[I,e,E,d,f]),V=q.useCallback(()=>{b.current&&clearTimeout(b.current),b.current=setTimeout(()=>w(!0),100)},[]),X=q.useCallback(()=>{b.current&&clearTimeout(b.current),w(!1)},[]);return n?m.jsxs(N.Box,{ref:h,onClick:G,onDoubleClick:U,onMouseEnter:V,onMouseLeave:X,cursor:"pointer",position:"relative",children:[!u&&(M||k&&k.length>0)&&_&&!z&&m.jsxs(m.Fragment,{children:[m.jsx(N.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>w(!0),onMouseLeave:X}),M?m.jsx(N.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",onMouseEnter:()=>w(!0),onMouseLeave:X,willChange:"transform",children:M({nodeId:I,nodeData:e,isRoot:I==="root",isParent:!0,isHovered:_,setIsHovered:w})}):m.jsx(N.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",bg:y,p:3,borderColor:g,borderWidth:1,borderRadius:15,pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",boxShadow:"lg",onMouseEnter:()=>w(!0),onMouseLeave:X,willChange:"transform",children:m.jsx(N.HStack,{px:2,gap:2,children:k.map((Y,oe)=>m.jsxs(N.Box,{display:"contents",children:[oe>0&&m.jsx(N.Box,{borderColor:g,height:5,borderRightWidth:1}),m.jsx(cp,{icon:Y.icon,label:Y.label,color:v,bgColor:y,borderColor:g,textColor:v,boxSize:5,onClick:pe=>{var fe;pe.stopPropagation(),(fe=d.onNodeHoverAction)==null||fe.call(d,Y.id,I,e)}})]},Y.id))})})]}),t({id:I,data:e,isActive:A,isLowZoom:z,isEditing:E,onEditStart:()=>R(!0),onEditEnd:()=>R(!1)}),((he=e==null?void 0:e.config)==null?void 0:he.collapsed)!==void 0&&(()=>{var pe;const Y=x==="TB"||x==="BT",oe=r||x==="RL";return m.jsx(N.IconButton,{position:"absolute",...Y?{[x==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:oe?void 0:"-75px",left:oe?"-75px":void 0,top:"50%",transform:"translateY(-50%)"},"aria-label":e.config.collapsed?"Expand":"Collapse",disabled:f.readOnly,onClick:fe=>{var ge;fe.stopPropagation(),(ge=d.onNodeCollapse)==null||ge.call(d,I,!e.config.collapsed)},bgColor:Se(((pe=e==null?void 0:e.viewProps)==null?void 0:pe.bgColor)||p),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:e.config.collapsed?m.jsx(Q.PiPlusBold,{size:30,color:"gray.800"}):m.jsx(Q.PiMinusBold,{size:30,color:"gray.800"})})})()]}):m.jsxs(N.Box,{ref:h,onClick:G,onDoubleClick:U,onMouseEnter:V,onMouseLeave:X,cursor:"pointer",transition:"transform 0.1s ease",position:"relative",children:[!u&&(M||k&&k.length>0)&&_&&!z&&m.jsxs(m.Fragment,{children:[m.jsx(N.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>w(!0),onMouseLeave:X}),M?m.jsx(N.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",onMouseEnter:()=>w(!0),onMouseLeave:X,willChange:"transform",children:M({nodeId:I,nodeData:e,isRoot:I==="root",isParent:!!n,isHovered:_,setIsHovered:w})}):m.jsx(N.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",bg:y,p:3,borderColor:g,borderWidth:1,borderRadius:15,pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",boxShadow:"lg",onMouseEnter:()=>w(!0),onMouseLeave:X,willChange:"transform",children:m.jsx(N.HStack,{px:2,gap:2,children:k.map((Y,oe)=>m.jsxs(N.Box,{display:"contents",children:[oe>0&&m.jsx(N.Box,{borderColor:g,height:5,borderRightWidth:1}),m.jsx(cp,{icon:Y.icon,label:Y.label,color:v,bgColor:y,borderColor:g,textColor:v,boxSize:5,onClick:pe=>{var fe;pe.stopPropagation(),(fe=d.onNodeHoverAction)==null||fe.call(d,Y.id,I,e)}})]},Y.id))})})]}),m.jsxs(N.Box,{position:"relative",display:"flex",h:"100%",w:"100%",children:[((ee=e==null?void 0:e.config)==null?void 0:ee.collapsed)!==void 0&&!n&&(()=>{var pe;const Y=x==="TB"||x==="BT",oe=r||x==="RL";return m.jsx(N.IconButton,{position:"absolute",...Y?{[x==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:oe?void 0:"-75px",left:oe?"-75px":void 0,alignSelf:"center"},"aria-label":e.config.collapsed?"Expand":"Collapse",disabled:f.readOnly,onClick:fe=>{var ge;fe.stopPropagation(),(ge=d.onNodeCollapse)==null||ge.call(d,I,!e.config.collapsed)},bgColor:Se(((pe=e==null?void 0:e.viewProps)==null?void 0:pe.bgColor)||p),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:e.config.collapsed?m.jsx(Q.PiPlusBold,{size:30,color:"gray.800"}):m.jsx(Q.PiMinusBold,{size:30,color:"gray.800"})})})(),t({id:I,data:e,isActive:A,isLowZoom:z,isEditing:E,onEditStart:()=>R(!0),onEditEnd:()=>R(!1)})]})]})},At=q.memo(lx),dx=({id:e,data:t,isActive:r,isEditing:n,onEditStart:o,onEditEnd:i})=>{var d,f,p,x;const{themeColor:a}=Le(),{bgColor:s,borderColor:l,textColor:u}=Vr(((d=t==null?void 0:t.viewProps)==null?void 0:d.bgColor)||a),c=Se(((f=t==null?void 0:t.viewProps)==null?void 0:f.textColor)||u);return m.jsx(N.Box,{borderRadius:(p=t==null?void 0:t.viewProps)==null?void 0:p.borderRadius,bgColor:s,borderColor:r?"white":l,_hover:{borderColor:"white"},borderWidth:2,py:14,px:20,whiteSpace:"nowrap",w:"fit-content",children:m.jsxs(N.Flex,{justifyContent:"start",alignItems:"center",gap:8,w:"fit-content",maxW:900,minW:0,fontSize:"5xl",lineHeight:"normal",children:[((x=t==null?void 0:t.config)==null?void 0:x.icon)&&m.jsx(N.Box,{flexShrink:0,children:m.jsx(Jr,{name:t.config.icon,size:80,color:c})}),m.jsx(Ru,{nodeId:e,label:(t==null?void 0:t.label)||(t==null?void 0:t.text)||"",color:c,isEditing:n,onEditStart:o,onEditEnd:i})]})})},fx=({id:e,isActive:t,data:r,isEditing:n,onEditStart:o,onEditEnd:i})=>{var h,b,_,w,E,R,I,A;const{themeColor:a}=Le(),{colorText:s}=$e(),l=((h=r==null?void 0:r.viewProps)==null?void 0:h.bgColor)==="transparent",u=!l&&((b=r==null?void 0:r.viewProps)==null?void 0:b.bgColor)||a,{borderColor:c,highlightColor:d,textColor:f}=Vr(u),p=Se(((_=r==null?void 0:r.viewProps)==null?void 0:_.textColor)||(l?s:f)),x=l&&!((w=r==null?void 0:r.viewProps)!=null&&w.borderColor)?"transparent":Se(((E=r==null?void 0:r.viewProps)==null?void 0:E.borderColor)||c),y=l?"transparent":u!=null&&u.startsWith("#")?u:Se(d),g=(R=r==null?void 0:r.config)==null?void 0:R.icon,v=(r==null?void 0:r.label)??(r==null?void 0:r.text)??"";return m.jsxs(N.Flex,{align:"center",borderRadius:(I=r==null?void 0:r.viewProps)==null?void 0:I.borderRadius,bgColor:y,style:{backgroundColor:y},textTransform:"capitalize",borderColor:t?"white":x,_hover:{borderColor:"white"},borderWidth:2,px:50,w:"fit-content",whiteSpace:"nowrap",children:[!!g&&m.jsx(N.Flex,{align:"center",py:14,mr:v?8:0,flexShrink:0,children:m.jsx(Jr,{name:g,size:(((A=r==null?void 0:r.viewProps)==null?void 0:A.fontSize)||1)*100,color:p},p)}),(v||!g)&&m.jsx(N.Flex,{justifyContent:"start",py:14,fontSize:"5xl",lineHeight:"normal",w:"fit-content",maxW:900,minW:0,children:m.jsx(Ru,{nodeId:e,label:v,color:p,isEditing:n,onEditStart:o,onEditEnd:i})})]})},Og=(e,t)=>{var l,u,c;const r=((l=e==null?void 0:e.viewProps)==null?void 0:l.bgColor)||t,[n]=r.split("."),o=Vr(r),i=r!=null&&r.startsWith("#")?Se(r):Se(o.bgColor),a=Se(((u=e==null?void 0:e.viewProps)==null?void 0:u.textColor)||o.textColor),s=Se(((c=e==null?void 0:e.viewProps)==null?void 0:c.borderColor)||o.borderColor);return{...o,bg:r,wordBeforeDot:n,hexbgColor:i,hextextColor:a,hexborderColor:s}},hx=(e,t=350)=>`${String(e).substring(0,t)}${String(e).length>t?"...":""}`,jg=e=>e!=null&&e.includes("root")?e.replace("root","untitled"):e,px=e=>{const t=Math.max(...Object.keys(e||{}).map(n=>n.length),0);return Math.max(t*28+30,200)},kg=e=>m.jsx(At,{...e,children:t=>m.jsx(dx,{...t})}),Ng=e=>m.jsx(At,{...e,children:t=>m.jsx(fx,{...t})}),Lg=e=>{const{themeColor:t}=Le(),[r,n]=q.useState(!1);return m.jsx(At,{...e,children:({id:o,data:i,isActive:a,isEditing:s,onEditStart:l,onEditEnd:u})=>{var g,v,h,b,_,w,E,R;const c=Og(i,t),d=i.label??i.headerTitle,f=Object.entries(i.description||{}).length>0,p=px(i.description),x=(v=(g=e.data)==null?void 0:g.config)==null?void 0:v.icon,y=(b=(h=e.data)==null?void 0:h.config)==null?void 0:b.content;return m.jsx(N.Flex,{justifyContent:"space-between",...i==null?void 0:i.viewProps,direction:"column",p:0,borderRadius:(_=i==null?void 0:i.viewProps)==null?void 0:_.borderRadius,overflow:"hidden",alignItems:"center",style:{backgroundColor:c.hexbgColor,transition:"border-color 0.2s ease-in-out"},width:"100%",borderColor:a?"white":c.hexborderColor,_hover:{borderColor:"white"},borderWidth:3,children:m.jsxs(N.Flex,{width:"100%",direction:"column",borderRadius:(w=i==null?void 0:i.viewProps)==null?void 0:w.borderRadius,borderColor:c.hexborderColor,borderWidth:0,overflow:"hidden",children:[d&&m.jsxs(N.Flex,{justify:"flex-start",direction:"row",p:Object.entries(i.description||{}).length?8:20,borderBottomWidth:1,minWidth:"max-content !important",width:"100%",textTransform:"capitalize",align:y?"left":"center",textOverflow:"ellipsis",alignItems:"center",fontWeight:"bold",color:c.propertyColor,bgColor:c.highlightColor,borderBottomColor:!f&&!y?"transparent":c.hexborderColor,children:[!!x&&m.jsx(N.Flex,{mr:6,alignItems:"center",flexShrink:0,children:m.jsx(Jr,{name:x,size:64,color:c.hextextColor},c.hextextColor)}),m.jsx(Ru,{nodeId:o,label:jg(d),color:((E=i==null?void 0:i.viewProps)==null?void 0:E.textColor)||c.propertyColor,isEditing:s,onEditStart:l,onEditEnd:u}),!!y&&m.jsx(N.Box,{ml:10,onClick:()=>n(!r),children:r?m.jsx(Q.PiGear,{size:30,style:{cursor:"pointer"}}):m.jsx(Q.PiNotepad,{size:30,style:{cursor:"pointer"}})})]}),y&&!r?m.jsx(N.Flex,{w:"100%",overflow:"auto",justifyContent:"start",background:c.highlightColor,p:10,fontSize:"5xl",lineHeight:"normal",cursor:"text",children:m.jsx(N.Text,{whiteSpace:"pre-wrap",overflow:"hidden",textOverflow:"ellipsis",color:(R=i==null?void 0:i.viewProps)==null?void 0:R.textColor,children:y})}):m.jsx(N.Box,{children:Object.entries(i.description||{}).map(([I,A],k)=>{var G,U;const M=Ye(c.wordBeforeDot)[typeof A],z=Ye(c.wordBeforeDot).property;return m.jsxs(N.Box,{"data-flow-property":I,children:[m.jsxs(N.Flex,{flexWrap:"nowrap",overflow:"hidden",children:[m.jsx(N.Flex,{justifyContent:"start",align:"center",background:c.highlightColor,width:`${p}px`,minWidth:`${p}px`,borderRightColor:c.hexborderColor,borderRightWidth:1,children:m.jsx(N.Text,{py:5,px:10,w:"100%",whiteSpace:"nowrap",fontWeight:"bold",fontSize:"4xl",color:((G=i==null?void 0:i.viewProps)==null?void 0:G.textColor)||z,children:I})}),m.jsx(N.Flex,{flex:1,justifyContent:"start",overflow:"hidden",p:4,background:c.hexbgColor,w:600,maxH:200,children:m.jsx(N.Text,{overflow:"hidden",py:3,px:4,whiteSpace:"normal",textOverflow:"ellipsis",fontSize:"4xl",color:((U=i==null?void 0:i.viewProps)==null?void 0:U.textColor)||M,fontWeight:400,children:hx(A)})})]}),k!==Object.entries(i.description||{}).length-1&&m.jsx(N.Box,{borderTopWidth:1,my:0,borderColor:c.hexborderColor})]},I)})})]})})}})},Fg=e=>{const{themeColor:t}=Le();return m.jsx(At,{...e,children:({data:r,isActive:n})=>{var a,s,l,u;const o=Og(r,t),i=(s=(a=e.data)==null?void 0:a.config)==null?void 0:s.icon;return m.jsx(N.Flex,{justifyContent:"space-between",...r==null?void 0:r.viewProps,direction:"column",p:0,borderRadius:((l=r==null?void 0:r.viewProps)==null?void 0:l.borderRadius)||15,overflow:"hidden",bgColor:o.bgColor,position:"absolute",top:0,left:0,right:0,bottom:0,alignItems:"center",style:{backgroundColor:o.hexbgColor,transition:"border-color 0.2s ease-in-out"},borderColor:n?"white":o.hexborderColor,_hover:{borderColor:"white"},borderWidth:3,children:r.headerTitle&&m.jsxs(N.Flex,{justify:"flex-start",direction:"row",p:20,borderBottomWidth:1,minWidth:"max-content !important",width:"100%",textTransform:"capitalize",align:"center",alignItems:"center",fontWeight:"bold",color:o.propertyColor,bgColor:o.highlightColor,borderBottomColor:o.hexborderColor,children:[!!i&&m.jsx(N.Box,{mr:8,justifyContent:"flex-start",height:"100%",w:50,alignItems:"center",rounded:"full",children:m.jsx(Jr,{name:i,size:80,color:o.hextextColor},o.hextextColor)}),m.jsx(N.Text,{fontSize:"5xl",lineClamp:2,textOverflow:"ellipsis",whiteSpace:"nowrap",color:(u=r==null?void 0:r.viewProps)==null?void 0:u.textColor,children:jg(r.headerTitle)})]})})}})};kg.displayName="text";Ng.displayName="arrayView";Lg.displayName="NodeJsonObjectView";Fg.displayName="ParentContainerView";const gx={objectView:Lg,arrayView:Ng,text:kg,parentContainer:Fg},vx=({children:e,pattern:t="dot",backgroundColor:r})=>{const{colorMode:n}=Le(),o=n==="dark",i=o?"--chakra-colors-gray-700":"--chakra-colors-gray-500",a=o?"--chakra-colors-gray-700":"--chakra-colors-gray-800";return t==="none"?m.jsx(N.Box,{width:"100%",height:"100%",padding:0,bg:r,children:e}):m.jsxs(N.Box,{position:"relative",width:"100%",height:"100%",padding:0,bg:r,children:[m.jsx(N.Box,{position:"absolute",top:0,left:0,right:0,bottom:0,width:"100%",height:"100%",zIndex:0,pointerEvents:"none",style:{backgroundImage:t==="dot"?`radial-gradient(var(${i}) 8%, transparent 8%)`:t==="steel"?`repeating-linear-gradient(45deg, var(${a}) 0, var(${a}) 1px, transparent 1px, transparent 20px)`:`linear-gradient(var(${a}) 1px, transparent 1px), linear-gradient(90deg, var(${a}) 1px, transparent 1px)`,backgroundSize:"20px 20px",opacity:.3}}),m.jsx(N.Box,{position:"relative",width:"100%",height:"100%",zIndex:1,padding:0,children:e})]})},yx=.4,pr={borderWidth:6,borderStyle:"solid",borderRadius:50,fontSize:70,padding:120,labelPosition:"top",labelMargin:90},bx=({nodes:e,edges:t})=>{const{themeColor:r,edgeColor:n,direction:o,nodeAlignment:i,edgeMode:a,parentNodeStyle:s,engineRef:l,callbacks:u,config:c,selectedNodeIds:d,setSelectedNodeIds:f,selectedEdgeId:p,setSelectedEdgeId:x,setIsPerformanceMode:y,isZoomMode:g,setIsZoomMode:v,isMultiSelectMode:h,setIsMultiSelectMode:b,isDragMode:_,setIsDragMode:w,isEdgeHandlesEnabled:E,isArrayNodeMode:R}=Le(),I=q.useRef(null),[A,k]=q.useState(null),M=e.length>200;q.useEffect(()=>{y(M)},[M,y]);const{edgeSep:z,rankSep:G}=q.useMemo(()=>dv(e.length),[e.length]),{bgColor:U}=Vr(r),{canvas:V,borderSecondary:X}=$e(),he=c.backgroundColor||V,ee=q.useCallback($=>{if($!=null&&$.includes("gray"))return"whitesmoke";if(!$)return Se(r);switch($){case"dark":return Se(he);case"light":return Se(X);default:return Se($)}},[r,he,X]),Y=c.colorMode==="dark",oe=q.useMemo(()=>ee(Y?U:"light"),[Y,U,ee]),pe=n?ee(n):oe,fe=q.useMemo(()=>c.initialViewport||{pan:{x:0,y:0},zoom:.01},[]),ge=o==="C"?"LR":o,S=q.useCallback($=>{const L={...s,...$};return{...L,bgColor:L.bgColor||r,bgOpacity:L.bgOpacity??yx}},[s,r]),O=q.useMemo(()=>{var L;const $=new Map;for(const H of e)(L=H.data)!=null&&L.id&&$.set(H.data.id,H);return $},[e]),D=q.useMemo(()=>{var L;const $=new Map;for(const H of t)(L=H.data)!=null&&L.id&&$.set(H.data.id,H);return $},[t]),F=q.useCallback($=>{var ce,se;const L=S((se=(ce=O.get($))==null?void 0:ce.data)==null?void 0:se.viewProps),H=Se(L.bgColor);return{bgColor:H,bgOpacity:L.bgOpacity,borderColor:L.borderColor?Se(L.borderColor):H,borderWidth:L.borderWidth??pr.borderWidth,borderStyle:L.borderStyle??pr.borderStyle,borderRadius:L.borderRadius??pr.borderRadius,textColor:L.textColor?Se(L.textColor):H,fontSize:L.fontSize??pr.fontSize,labelPosition:L.labelPosition??pr.labelPosition,labelMargin:pr.labelMargin,padding:L.padding??pr.padding}},[S,O]),Z=q.useMemo(()=>{var H,ce;const $=new Map;for(const se of t){const C=(H=se.data)==null?void 0:H.source,T=(ce=se.data)==null?void 0:ce.target;if(!C||!T||C===T)continue;const j=C<T?`${C}|${T}`:`${T}|${C}`,P=$.get(j);P?P.push({id:se.data.id,source:C}):$.set(j,[{id:se.data.id,source:C}])}const L=new Map;for(const[se,C]of $){if(C.length<2)continue;const T=se.split("|")[0],j=Math.min(20,70/C.length);C.forEach(({id:P,source:B},J)=>{const te=50+(J-(C.length-1)/2)*j;L.set(P,(B===T?te:100-te)/100)})}return L},[t]),ne=q.useMemo(()=>{const $=ee("dark");return t.filter(L=>{var H;return((H=L.data)==null?void 0:H.id)&&L.data.source&&L.data.target}).map(({data:L})=>{var C,T,j,P,B,J;let H=$;const ce=(T=(C=O.get(L.source))==null?void 0:C.data)==null?void 0:T.parent,se=(P=(j=O.get(L.target))==null?void 0:j.data)==null?void 0:P.parent;if(ce&&ce===se){const te=S((J=(B=O.get(ce))==null?void 0:B.data)==null?void 0:J.viewProps),be=ov($,Se(te.bgColor),te.bgOpacity);be&&(H=be)}return{id:L.id,source:L.source,target:L.target,sourceProperty:L.sourceProperty,targetProperty:L.targetProperty,label:L.label,color:L.color?Se(L.color):pe,labelBg:H,dashed:!!L.isEdgeDashed,animated:!!L.isEdgeAnimated,inverted:!!L.isInverted,turn:Z.get(L.id)??.5}})},[t,pe,Z,O,S,ee]),re=q.useMemo(()=>{var L;const $=new Set;for(const H of e)(L=H.data)!=null&&L.parent&&$.add(H.data.parent);return $},[e]),ue=q.useMemo(()=>{var L;const $=new Map;for(const H of t)(L=H.data)!=null&&L.source&&!$.has(H.data.source)&&$.set(H.data.source,H.data);return $},[t]),Ce=q.useMemo(()=>{const $=c.customViews||gx;return e.filter(L=>{var H;return(H=L.data)==null?void 0:H.id}).map(L=>{const H=re.has(L.data.id)&&!L.data.parent,ce=H?L.data.label||L.data.headerTitle||"Container":void 0,se=H?$.parentContainer:$[L.data.type]||$.text,C=ue.get(L.data.id);return{id:L.data.id,parent:L.data.parent,label:ce,element:q.createElement(se,{...L,isInverted:C==null?void 0:C.isInverted,isParent:H,key:`${L.data.id}-${r}`})}})},[e,re,ue,r,c.customViews]),ie=q.useMemo(()=>M?300:e.length>50?150:e.length>20?100:50,[e.length,M]),ve=q.useRef(c);ve.current=c;const W=q.useRef(g);W.current=g;const ye=q.useRef(R);ye.current=R;const K=q.useRef(d);K.current=d;const we=q.useRef(p);we.current=p;const Ae=q.useRef(h);Ae.current=h;const Ie=q.useRef(O);Ie.current=O;const Fe=q.useRef(D);Fe.current=D;const xe=q.useRef(new Map);q.useEffect(()=>{var H,ce;const $=new Map([...D].filter(([,se])=>O.has(se.data.source)&&O.has(se.data.target))),L=xe.current;xe.current=$;for(const[se,C]of L)$.has(se)||(we.current===se&&(x(null),(H=u.onEdgeDeselect)==null||H.call(u)),(ce=u.onEdgeRemove)==null||ce.call(u,se,C.data))},[D,O,u,x]),q.useEffect(()=>{const $=I.current;if(!A||!$)return;let L=null,H=null,ce=0,se=0,C=0,T=0,j=0;const P=B=>{if(ve.current.readOnly)return;B.preventDefault(),B.stopPropagation(),W.current||B.metaKey||B.ctrlKey?(C+=B.deltaY,T=B.clientX,j=B.clientY,H===null&&(H=requestAnimationFrame(()=>{H=null;const te=ve.current,be=A.zoom(),Ee=C;C=0;let le=be-Ee*.05/100;le=Math.max(te.minZoom??.01,Math.min(te.maxZoom??1.5,le));const me=$.getBoundingClientRect();A.zoomAt(le,{x:T-me.left,y:j-me.top})}))):(ce+=B.deltaX,se+=B.deltaY,L===null&&(L=requestAnimationFrame(()=>{L=null;const te=A.pan(),be=A.zoom(),Ee=.35,le=ce,me=se;ce=0,se=0,A.pan({x:te.x+-le*Ee/be,y:te.y+-me*Ee/be})})))};return $.addEventListener("wheel",P,{passive:!1}),()=>{$.removeEventListener("wheel",P),L!==null&&cancelAnimationFrame(L),H!==null&&cancelAnimationFrame(H)}},[A]),q.useEffect(()=>{if(c.disableKeyboardShortcuts)return;const $=L=>{var ce,se;if(ve.current.readOnly)return;const H=L.target;if(!(H.tagName==="INPUT"||H.tagName==="TEXTAREA"||H.isContentEditable)&&((L.key==="z"||L.key==="Z")&&v(!W.current),(L.key==="m"||L.key==="M")&&b(!h),(L.key==="d"||L.key==="D")&&w(!_),(L.key==="Delete"||L.key==="Backspace")&&K.current.length>0)){L.preventDefault();const C=K.current.filter(T=>T!=="root");if(C.length===0)return;for(const T of C){const j=(ce=Ie.current.get(T))==null?void 0:ce.data;(se=u.onNodeDelete)==null||se.call(u,T,j||{})}f([])}};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[h,_,v,b,w,c.disableKeyboardShortcuts,u,f]);const qe=q.useCallback($=>{var L;l.current=$,k($),(L=u.onInit)==null||L.call(u,$)},[l,u]),Ue=q.useCallback($=>{var L;return(L=u.onViewportChange)==null?void 0:L.call(u,$)},[u]),Ke=q.useCallback($=>{var H,ce,se;const L=((H=Fe.current.get($))==null?void 0:H.data)??{id:$};if(we.current===$&&Ae.current){x(null),(ce=u.onEdgeDeselect)==null||ce.call(u);return}K.current.length&&f([]),x($),(se=u.onEdgeSelect)==null||se.call(u,$,L)},[u,x,f]),lr=q.useCallback(()=>{var $,L;K.current.length&&(f([]),($=u.onNodeDeselect)==null||$.call(u)),we.current&&(x(null),(L=u.onEdgeDeselect)==null||L.call(u))},[u,f,x]),_r=q.useCallback($=>{var ce,se;const L=K.current,H=$.filter(C=>!L.includes(C));if(H.length){f([...L,...H]);for(const C of H)(se=u.onNodeSelect)==null||se.call(u,C,((ce=Ie.current.get(C))==null?void 0:ce.data)??{id:C})}},[u,f]),Ze=q.useCallback($=>{var L,H;f([$]),(H=u.onNodeSelect)==null||H.call(u,$,((L=Ie.current.get($))==null?void 0:L.data)??{id:$})},[u,f]),dr=q.useCallback(($,L,H)=>{var ce;return(ce=u.onEdgeCreate)==null?void 0:ce.call(u,$,L,H)},[u]),De=q.useCallback(($,L)=>{var H;(H=u.onNodeCreate)==null||H.call(u,{type:"text",sourceNodeId:$,position:L,isArrayMode:ye.current})},[u]),jr=!c.readOnly&&E&&c.edgeHandles!==!1,fr=c.backgroundPattern||"dot";return m.jsx(vx,{pattern:fr,backgroundColor:he,children:m.jsx(N.Box,{ref:I,padding:0,width:"100%",height:"100%",flex:1,position:"relative",children:m.jsx(cx,{nodes:Ce,edges:ne,direction:ge,nodeAlignment:i,edgeMode:a,rankSep:G,edgeSep:z,layoutDebounce:ie,isPerformanceMode:M,minZoom:c.minZoom??.01,maxZoom:c.maxZoom??1.5,initialViewport:fe,fitOnInit:!c.initialViewport,readOnly:!!c.readOnly,containerStyle:F,lineColor:pe,drawMode:jr,drawHandles:!c.readOnly&&c.edgeHandles!==!1,dragMode:_,multiSelect:!!h,onInit:qe,onViewportChange:Ue,onBackgroundTap:lr,onBoxSelect:_r,onEdgeSelect:Ke,onContainerSelect:Ze,onEdgeDraw:dr,onDrawIntoSpace:De})})})},mx=q.memo(bx),xx=".flow-sdk-canvas{position:relative;width:100%;height:100%;overflow:hidden;user-select:none;-webkit-user-select:none;touch-action:none}.flow-sdk-svg{position:absolute;top:0;left:0;width:100%;height:100%;overflow:visible;display:block}.flow-sdk-nodes{position:absolute;top:0;left:0;transform-origin:0 0;pointer-events:none;will-change:transform;backface-visibility:hidden;z-index:10}.flow-sdk-node{position:absolute;top:0;left:0;transform-origin:0 0;pointer-events:auto;will-change:transform;backface-visibility:hidden;z-index:10}.flow-sdk-node input,.flow-sdk-node textarea{pointer-events:auto;user-select:text;-webkit-user-select:text;cursor:text}.flow-sdk-edge-hit{fill:none;stroke:transparent;stroke-width:24px;vector-effect:non-scaling-stroke;pointer-events:stroke;cursor:pointer}.flow-sdk-container{cursor:pointer}.flow-sdk-edge-anim{animation:flow-sdk-dash .5s linear infinite}.flow-sdk-edge-anim-rev{animation-direction:reverse}@keyframes flow-sdk-dash{to{stroke-dashoffset:-50}}.flow-sdk-draw{cursor:crosshair}.flow-sdk-draw .flow-sdk-node,.flow-sdk-draw .flow-sdk-node input,.flow-sdk-draw .flow-sdk-node textarea,.flow-sdk-draw .flow-sdk-edge,.flow-sdk-draw .flow-sdk-container{pointer-events:none}.flow-sdk-perf.flow-sdk-busy .flow-sdk-edges{display:none}.flow-sdk-box{position:absolute;border:1px solid rgba(170,170,170,.9);background:rgba(221,221,221,.25);pointer-events:none;z-index:20}";let lp=!1;function _x(){if(lp||typeof document>"u")return;const e=document.createElement("style");e.setAttribute("data-flow-sdk",""),e.textContent=xx+".flow-sdk-handle{position:absolute;left:-36px;top:50%;transform:translateY(-50%);width:36px;height:36px;display:grid;place-items:center;border:2px solid currentColor;border-radius:50%;background:white;cursor:crosshair;opacity:0;pointer-events:none}.flow-sdk-node:hover>.flow-sdk-handle,.flow-sdk-handle:focus-visible{opacity:1;pointer-events:auto}.flow-sdk-draw .flow-sdk-node *,.flow-sdk-draw .flow-sdk-edge *,.flow-sdk-draw .flow-sdk-container *,.flow-sdk-ghost *{pointer-events:none}",document.head.appendChild(e),e.textContent+='.flow-sdk-property-port{position:absolute;transform:translateY(-50%);width:32px;height:32px;margin:0;padding:0;border:3px solid currentColor;border-radius:50%;background:white;cursor:crosshair;pointer-events:auto;z-index:20}.flow-sdk-property-port[data-port-role="source"]{background:currentColor}.flow-sdk-property-port:hover{outline:3px solid currentColor;outline-offset:3px}.flow-sdk-draw .flow-sdk-node .flow-sdk-property-port{pointer-events:auto}',lp=!0}function wx({title:e="untitled",json:t,nodes:r,edges:n,config:o={},callbacks:i={},className:a,style:s,showBottomBar:l=!0}){_x();const u=o.direction==="C",c=q.useMemo(()=>t?Cp(t,{title:e,isCenter:u}):null,[t,e,u]),d=(c==null?void 0:c.nodes)??r??[],f=(c==null?void 0:c.edges)??n??[],p=q.useMemo(()=>t&&c?Ep(t,c.edges,i,i.onJsonChange):i,[t,c,i]);return m.jsx(nv,{config:o,callbacks:p,nodes:d,edges:f,children:m.jsxs(N.Box,{className:a,style:s,width:"100%",height:"100%",position:"relative",overflow:"hidden",children:[m.jsx(mx,{nodes:d,edges:f}),l&&m.jsx(lv,{})]})})}exports.DynamicIcon=Jr;exports.FlowDiagram=wx;exports.addChild=bp;exports.addConnection=_p;exports.addTargetEdge=xp;exports.addressToPath=er;exports.applyCollapsed=rv;exports.bindSqueedCallbacks=Ep;exports.compileSqueed=Cp;exports.contentObjTheme=Ye;exports.createFlowDiagram=vr;exports.getChakraColorHex=Se;exports.getColorVariant=qp;exports.getDarkerHexColor=ot;exports.getNode=ir;exports.removeEdge=wp;exports.removeNode=mp;exports.resolveEdgeOwner=dt;exports.setCollapsed=vp;exports.setEdgeProp=Hr;exports.setEdgeStyle=yp;exports.setNodeProp=Sr;exports.updateNode=Je;exports.useCustomColors=$e;exports.useStopPropagation=Pg;exports.useThemeContentColors=Vr;
|
|
1
|
+
"use strict";var Kb=Object.create;var Kn=Object.defineProperty;var Zb=Object.getOwnPropertyDescriptor;var Jb=Object.getOwnPropertyNames;var Yb=Object.getPrototypeOf,Xb=Object.prototype.hasOwnProperty;var Qb=(e,t,r)=>t in e?Kn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var ev=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Jb(t))!Xb.call(e,o)&&o!==r&&Kn(e,o,{get:()=>t[o],enumerable:!(n=Zb(t,o))||n.enumerable});return e};var qe=(e,t,r)=>(r=e!=null?Kb(Yb(e)):{},ev(t||!e||!e.__esModule?Kn(r,"default",{value:e,enumerable:!0}):r,e));var Ar=(e,t,r)=>Qb(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),F=require("@chakra-ui/react"),j=require("react"),Z=require("react-icons/pi"),dy=require("@emotion/react"),rv=require("@emotion/styled"),tv=require("react-icons/tb"),Ft=require("react-dom"),nv=require("markdown-to-jsx/react"),fy=e=>e&&e.__esModule?e:{default:e},yn=fy(rv),ov=fy(nv);function hy({edge:e,enabled:t,bounds:r,inside:n=[],threshold:o=80}){const[i,a]=j.useState(!1),s=j.useRef(n);return s.current=n,j.useEffect(()=>{const u=l=>{var b;const d=(b=r.current)==null?void 0:b.getBoundingClientRect();if(!d)return;const f=l.target instanceof Node?l.target:null,p=!!f&&s.current.some(v=>{var g;return(g=v.current)==null?void 0:g.contains(f)}),m=e==="bottom"?d.bottom-l.clientY:l.clientY-d.top,y=l.clientX>=d.left&&l.clientX<=d.right&&m>=0&&m<=o;a(p||y)},c=()=>a(!1);return document.addEventListener("pointermove",u,!0),document.addEventListener("pointerdown",u,!0),document.documentElement.addEventListener("pointerleave",c),()=>{document.removeEventListener("pointermove",u,!0),document.removeEventListener("pointerdown",u,!0),document.documentElement.removeEventListener("pointerleave",c)}},[e,r,o]),t&&i}const iv=dy.keyframes`
|
|
2
|
+
0%, 100% { box-shadow: var(--flow-rest-shadow); }
|
|
3
|
+
25%, 50% { box-shadow: var(--flow-hover-shadow); }
|
|
4
|
+
`,av=dy.keyframes`
|
|
5
|
+
from { box-shadow: var(--flow-start-shadow); }
|
|
6
|
+
to { box-shadow: var(--flow-rest-shadow); }
|
|
7
|
+
`;function py(e,t=!0,r="&:hover",n=!0){const o=`color-mix(in srgb, ${e} 60%, transparent)`,a=`0 0 0 ${t?8:0}px ${o}`,s=`0 0 0 8px ${o}`;return{boxShadow:a,css:{"--flow-rest-shadow":s,"--flow-hover-shadow":`0 0 0 18px ${o}`,"@media (hover: hover)":{[r]:{boxShadow:s,"@media (prefers-reduced-motion: no-preference)":{animation:n?`${iv} 1200ms steps(10, end) 600ms`:"none"}}}}}}function Dr(e,t){const{boxShadow:r,css:n}=py(e,!1),o=n["@media (hover: hover)"]["&:hover"];return{borderWidth:"1px",borderStyle:"solid",borderColor:"transparent",boxShadow:r,...n,"--flow-start-shadow":r,"@media (hover: hover)":{"&:hover":{...o,borderColor:t,"@media (prefers-reduced-motion: no-preference)":{animation:`${av} 600ms steps(5, end)`}}}}}const gy=j.createContext(null),yy=j.createContext({nodeById:new Map,edgeById:new Map,parentIds:new Set});function Gr(){return j.useContext(yy)}function Ie(){const e=j.useContext(gy);if(!e)throw new Error("useFlowDiagramContext must be used within FlowDiagram");return e}function my({config:e,callbacks:t,nodes:r=[],edges:n=[],children:o}){const i=j.useMemo(()=>{var $e,er,Y;const ne=new Map;for(const B of r)($e=B.data)!=null&&$e.id&&ne.set(B.data.id,B);const Be=new Map;for(const B of n)(er=B.data)!=null&&er.id&&Be.set(B.data.id,B);const Je=new Set;for(const B of r)(Y=B.data)!=null&&Y.parent&&Je.add(B.data.parent);return{nodeById:ne,edgeById:Be,parentIds:Je}},[r,n]),a=j.useRef(null),[s,u]=j.useState([]),[c,l]=j.useState(null),[d,f]=j.useState(!0),[p,m]=j.useState(!1),[y,b]=j.useState(!0),[v,g]=j.useState(!1),[w,x]=j.useState(!1),[_,C]=j.useState(!0),[S,T]=j.useState(!1),[k,E]=j.useState("auto"),[P,R]=j.useState(!1),I=e.compactPropertyLayout??P,[O,M]=j.useState({}),q=e.nodeViewModes??O,K=[...i.nodeById.values()].filter(ne=>{var Be;return i.parentIds.has(ne.data.id)||((Be=ne.data.config)==null?void 0:Be.parentContainer)||ne.data.type==="objectView"||ne.data.type==="arrayView"}),V=!!K.length&&K.every(ne=>{var Be,Je,$e;return i.parentIds.has(ne.data.id)||(Be=ne.data.config)!=null&&Be.parentContainer?!!((Je=ne.data.config)!=null&&Je.collapsed):q[ne.data.id]==="icon-label"||(($e=ne.data.config)==null?void 0:$e.labelBelow)&&q[ne.data.id]!=="properties"}),[re,ce]=j.useState("normal"),[he,me]=j.useState(),H=e.edgeRadius??he,N=H!==void 0&&Number.isFinite(H)?Math.min(500,Math.max(0,H)):void 0,[D,W]=j.useState(),z=e.spacing??re,X=typeof z=="number"?Number.isFinite(z)?Math.min(2,Math.max(.5,z)):1:z==="compact"?.5:z==="spacious"?2:1,se=e.backgroundVariant??D??(e.backgroundPattern==="none"&&e.backgroundColor==="transparent"?"transparent":e.backgroundPattern??"dot"),[Q,G]=j.useState(),J=Object.prototype.hasOwnProperty.call(e,"workflowContract")?e.workflowContract:Q,[te,le]=j.useState("blue.500"),[de,Re]=j.useState(!1),ge=j.useRef(t);ge.current=t;const ze=j.useMemo(()=>{const ne=Be=>(...Je)=>{var $e,er;return(er=($e=ge.current)==null?void 0:$e[Be])==null?void 0:er.call($e,...Je)};return{onNodeSelect:ne("onNodeSelect"),onBackgroundClick:ne("onBackgroundClick"),onNodeDeselect:ne("onNodeDeselect"),onNodeDoubleClick:ne("onNodeDoubleClick"),onNodeViewToggle:ne("onNodeViewToggle"),onNodeTypeViewChange:ne("onNodeTypeViewChange"),onNodeCreate:ne("onNodeCreate"),onNodeCreateRequest:ne("onNodeCreateRequest"),onNodeDelete:ne("onNodeDelete"),onNodeLabelChange:ne("onNodeLabelChange"),onNodeContentChange:ne("onNodeContentChange"),onNodeCollapse:ne("onNodeCollapse"),onNodeColorChange:ne("onNodeColorChange"),onNodeBorderColorChange:ne("onNodeBorderColorChange"),onNodeBorderStyleChange:ne("onNodeBorderStyleChange"),onNodeBorderWidthChange:ne("onNodeBorderWidthChange"),onNodeBorderRadiusChange:ne("onNodeBorderRadiusChange"),onNodeIconChange:ne("onNodeIconChange"),onNodeOutlineChange:ne("onNodeOutlineChange"),onNodeAnimationChange:ne("onNodeAnimationChange"),onNodeAnimationVariantChange:ne("onNodeAnimationVariantChange"),onEdgeAnimationVariantChange:ne("onEdgeAnimationVariantChange"),onNodeHoverAction:ne("onNodeHoverAction"),onEdgeCreate:ne("onEdgeCreate"),onEdgeSelect:ne("onEdgeSelect"),onEdgeDeselect:ne("onEdgeDeselect"),onEdgeRemove:ne("onEdgeRemove"),onEdgeDelete:ne("onEdgeDelete"),onEdgeColorChange:ne("onEdgeColorChange"),onEdgeTypeChange:ne("onEdgeTypeChange"),onEdgeIconChange:ne("onEdgeIconChange"),onEdgeLabelChange:ne("onEdgeLabelChange"),onEdgeStyleChange:ne("onEdgeStyleChange"),onViewportChange:ne("onViewportChange"),onDirectionChange:ne("onDirectionChange"),onThemeColorChange:ne("onThemeColorChange"),onSpacingChange:ne("onSpacingChange"),onEdgeRadiusChange:ne("onEdgeRadiusChange"),onBackgroundVariantChange:ne("onBackgroundVariantChange"),onEdgeModeChange:ne("onEdgeModeChange"),onCompactPropertyLayoutChange:ne("onCompactPropertyLayoutChange"),onWorkflowContractChange:ne("onWorkflowContractChange"),onArrayModeChange:ne("onArrayModeChange"),onInit:ne("onInit"),onLayoutComplete:ne("onLayoutComplete"),onJsonChange:ne("onJsonChange")}},[]),Fe=e.themeColor||te,He=e.edgeColor||"",ar=e.colorMode||"light",be=e.direction||"LR",_e=e.nodeAlignment??"center",Xe=e.edgeMode==="workflow"?"nodes":e.edgeMode??k,Ke=e.readOnly??!1,Ne=JSON.stringify(e.parentNodeStyle??null),Qe=j.useMemo(()=>e.parentNodeStyle,[Ne]),Ze=e.isZoomMode!==void 0?e.isZoomMode:d,gr=e.isMultiSelectMode!==void 0?e.isMultiSelectMode:p,fr=e.isEdgeHandlesEnabled!==void 0?e.isEdgeHandlesEnabled:v,Er=e.isDragMode!==void 0?e.isDragMode:y,we=j.useRef(e);we.current=e;const or=j.useMemo(()=>({get direction(){return we.current.direction},get nodeAlignment(){return we.current.nodeAlignment},get edgeMode(){return we.current.edgeMode},get compactPropertyLayout(){return we.current.compactPropertyLayout},get edgeType(){return we.current.edgeType},get customEdgeTypes(){return we.current.customEdgeTypes},get themeColor(){return we.current.themeColor},get colorMode(){return we.current.colorMode},get readOnly(){return we.current.readOnly},get editable(){return we.current.editable},get minZoom(){return we.current.minZoom},get maxZoom(){return we.current.maxZoom},get backgroundPattern(){return we.current.backgroundPattern},get edgeColor(){return we.current.edgeColor},get parentNodeStyle(){return we.current.parentNodeStyle},get backgroundColor(){return we.current.backgroundColor},get edgeHandles(){return we.current.edgeHandles},get initialViewport(){return we.current.initialViewport},get nodeOverlayActions(){return we.current.nodeOverlayActions},get renderNodeOverlay(){return we.current.renderNodeOverlay},get renderSelectedNodeToolbar(){return we.current.renderSelectedNodeToolbar},get renderSelectedEdgeToolbar(){return we.current.renderSelectedEdgeToolbar},get renderBottomBar(){return we.current.renderBottomBar},get bottomBarExtra(){return we.current.bottomBarExtra},get selectionToolbar(){return we.current.selectionToolbar},get customViews(){return we.current.customViews},get disableKeyboardShortcuts(){return we.current.disableKeyboardShortcuts},get isZoomMode(){return we.current.isZoomMode},get isMultiSelectMode(){return we.current.isMultiSelectMode},get isEdgeHandlesEnabled(){return we.current.isEdgeHandlesEnabled},get isDragMode(){return we.current.isDragMode}}),[]),sr=j.useCallback((ne,Be)=>{var Je;if(Be!=="default"&&Be!=="properties"&&Be!=="icon-label")throw new Error("Unknown node view mode.");M($e=>$e[ne]===Be?$e:{...$e,[ne]:Be}),(Je=t.onNodeViewModeChange)==null||Je.call(t,ne,Be)},[t.onNodeViewModeChange]),wt=j.useMemo(()=>({allNodesIconLabel:V,setAllNodesIconLabel:ne=>{var Be,Je,$e,er;for(const Y of K)i.parentIds.has(Y.data.id)||(Be=Y.data.config)!=null&&Be.parentContainer?!Ke&&!!((Je=Y.data.config)!=null&&Je.collapsed)!==ne&&(($e=t.onNodeCollapse)==null||$e.call(t,Y.data.id,ne)):sr(Y.data.id,ne?"icon-label":"default");(er=t.onAllNodesIconLabelChange)==null||er.call(t,ne)},nodeViewModes:q,setNodeViewMode:sr,spacing:X,setSpacing:ce,edgeRadius:N,setEdgeRadius:me,backgroundVariant:se,setBackgroundVariant:W,themeColor:Fe,setThemeColor:le,backgroundSelected:de,setBackgroundSelected:Re,edgeColor:He,colorMode:ar,direction:be,nodeAlignment:_e,edgeMode:Xe,setEdgeMode:E,compactPropertyLayout:I,setCompactPropertyLayout:R,workflowContract:J,setWorkflowContract:G,parentNodeStyle:Qe,selectedNodeIds:s,setSelectedNodeIds:u,selectedEdgeId:c,setSelectedEdgeId:l,isZoomMode:Ze,setIsZoomMode:f,isMultiSelectMode:gr,setIsMultiSelectMode:m,isDragMode:Er,setIsDragMode:b,isEdgeHandlesEnabled:fr,setIsEdgeHandlesEnabled:g,isArrayNodeMode:w,setIsArrayNodeMode:x,isPinned:_,setIsPinned:C,isPerformanceMode:S,setIsPerformanceMode:T,engineRef:a,callbacks:ze,config:or,readOnly:Ke}),[V,i,sr,t.onNodeCollapse,t.onAllNodesIconLabelChange,q,t.onNodeViewModeChange,Fe,X,se,N,e.backgroundColor,de,He,ar,be,_e,Xe,J,Qe,s,c,Ze,gr,Er,fr,w,_,S,Ke,e.edgeHandles,e.edgeType,e.customEdgeTypes,e.selectionToolbar,e.bottomBarExtra,e.compactPropertyLayout,I,ze,or]);return h.jsx(gy.Provider,{value:wt,children:h.jsx(yy.Provider,{value:i,children:o})})}function un(e,t=.2){const r=e.replace(/^#/,""),n=parseInt(r,16);let o=n>>16&255,i=n>>8&255,a=n&255;return o=Math.max(0,Math.floor(o*(1-t))),i=Math.max(0,Math.floor(i*(1-t))),a=Math.max(0,Math.floor(a*(1-t))),"#"+((1<<24)+(o<<16)+(i<<8)+a).toString(16).slice(1).toUpperCase()}function cl(e,t,r){const n=s=>{const u=/^#?([0-9a-f]{6})$/i.exec((s==null?void 0:s.trim())??"");return u?parseInt(u[1],16):null},o=n(e),i=n(t);if(o===null||i===null)return null;const a=s=>Math.round((o>>s&255)*(1-r)+(i>>s&255)*r);return"#"+((1<<24)+(a(16)<<16)+(a(8)<<8)+a(0)).toString(16).slice(1).toUpperCase()}const jr=e=>e==="transparent"?{background:"transparent",highlight:"transparent",border:"transparent",property:"gray.900",boolean:"green.800",string:"gray.900",number:"orange.800"}:e!=null&&e.startsWith("#")?{background:e,highlight:un(e,.1),border:un(e,.5),property:"gray.900",boolean:"green.200",string:"gray.900",number:"orange.800"}:e==="gray"?{background:"gray.950",highlight:"gray.800",border:"gray.700",property:"gray.200",boolean:"green.400",string:"gray.200",number:"orange.600"}:e==="white"?{background:"white",highlight:"gray.200",border:"gray.400",property:"gray.900",boolean:"green.400",string:"gray.900",number:"orange.600"}:{background:e+".100",highlight:e+".200",border:e+".700",property:"gray.900",boolean:"green.800",string:"gray.900",number:"orange.800"},by=e=>{if(e==="transparent")return{primary:e,secondary:e,light:e};let t=e;if(t!=null&&t.startsWith("#"))return{secondary:un(e)};let r=String(Number(e.slice(-3))+200);r=e.slice(0,-3).concat(r);let n=String(Number(e.slice(-3))-100);return n=e.slice(0,-3).concat(n),{primary:t,secondary:r,light:n}},ul={red:{50:"#FFF5F5",100:"#FED7D7",200:"#FEB2B2",300:"#FC8181",400:"#F56565",500:"#E53E3E",600:"#C53030",700:"#9B2C2C",800:"#822727",900:"#63171B"},orange:{50:"#FFFAF0",100:"#FEEBC8",200:"#FBD38D",300:"#F6AD55",400:"#ED8936",500:"#DD6B20",600:"#C05621",700:"#9C4221",800:"#7B341E",900:"#652B19"},yellow:{50:"#FFFFF0",100:"#FEFCBF",200:"#FAF089",300:"#F6E05E",400:"#ECC94B",500:"#D69E2E",600:"#B7791F",700:"#975A16",800:"#744210",900:"#5F370E"},green:{50:"#F0FFF4",100:"#C6F6D5",200:"#9AE6B4",300:"#68D391",400:"#48BB78",500:"#38A169",600:"#2F855A",700:"#276749",800:"#22543D",900:"#1C4532"},teal:{50:"#E6FFFA",100:"#B2F5EA",200:"#81E6D9",300:"#4FD1C5",400:"#38B2AC",500:"#319795",600:"#2C7A7B",700:"#285E61",800:"#234E52",900:"#1D4044"},blue:{50:"#EBF8FF",100:"#BEE3F8",200:"#90CDF4",300:"#63B3ED",400:"#4299E1",500:"#3182CE",600:"#2B6CB0",700:"#2C5282",800:"#2A4365",900:"#1A365D"},cyan:{50:"#EDFDFD",100:"#C4F1F9",200:"#9DECF9",300:"#76E4F7",400:"#0BC5EA",500:"#00B5D8",600:"#00A3C4",700:"#0987A0",800:"#086F83",900:"#065666"},purple:{50:"#FAF5FF",100:"#E9D8FD",200:"#D6BCFA",300:"#B794F4",400:"#9F7AEA",500:"#805AD5",600:"#6B46C1",700:"#553C9A",800:"#44337A",900:"#322659"},pink:{50:"#FFF5F7",100:"#FED7E2",200:"#FBB6CE",300:"#F687B3",400:"#ED64A6",500:"#D53F8C",600:"#B83280",700:"#97266D",800:"#702459",900:"#521B41"},gray:{50:"#F7FAFC",100:"#EDF2F7",200:"#E2E8F0",300:"#CBD5E0",400:"#A0AEC0",500:"#718096",600:"#4A5568",700:"#2D3748",800:"#1A202C",900:"#171923",950:"#0d1117"}},fe=(e,t)=>{var i;if(e==="transparent"||e!=null&&e.startsWith("#"))return e;if(!e)return"whitesmoke";const r=e.replace(/\./g,"-");try{const s=getComputedStyle(document.documentElement).getPropertyValue(`--chakra-colors-${r}`).trim();if(s&&s!=="")return s}catch{}const[n,o]=e.split(".");return n&&o&&((i=ul[n])!=null&&i[Number(o)])?ul[n][Number(o)]:`var(--chakra-colors-${r})`};function tr(e,t,r){return e?r:t}function Jt(e){const[t]=(e==null?void 0:e.split("."))||[],{secondary:r}=by(e),n=jr(t).background,o=jr(t).highlight,i=jr(t).border,a=jr(t).property,s=jr(t).property;let u=jr(t).background,c=jr(t).highlight;return u=e==="transparent"?e:fe(u)+50,c=e==="transparent"?e:fe(c)+20,{bgColor:n,highlightColor:o,borderColor:i,textColor:a,propertyColor:s,secondary:r,bgColorFaint:u,highlightColorFaint:c}}function Ve(e=null){const{colorMode:t}=Ie(),r=e==null?void 0:e.includes("gray"),n=t==="dark",o=tr(n,"white","gray.900"),i=tr(n,"gray.100","gray.800"),a=tr(n,"gray.200","blackAlpha.400"),s=tr(n,"gray.200","blackAlpha.600"),u=tr(n,"gray.500","gray.700"),c=tr(n,"gray.700","gray.700"),l=tr(n,"gray.900","gray.900"),d=tr(n,"gray.400","gray.500"),f=tr(n,"gray.400","gray.500"),p=tr(n,"gray.900","gray.200"),m=tr(n,r?"gray.900":"gray.200",r?"gray.200":"gray.900"),y=tr(n,"gray.900","gray.200"),b=tr(n,e&&"#000000",e||"#ffffff"),v=tr(n,e||"#ffffff",e?"#000000":"#ffffff"),g=c,w=tr(n,"gray.300","gray.800"),x=tr(n,"white","blackAlpha.400"),_=tr(n,"green.100","green.700");return{canvas:o,background:i,backgroundSecondary:a,darkBackgroundSecondary:s,border:u,darkColor:l,backgroundWhiteColor:x,borderSecondary:c,colorActive:d,colorInactive:f,iconColor:y,moreIconColor:g,colorText:p,themedColorText:m,logoColor:b,logoColorSecondary:v,darkColorActive:w,greenColor:_}}var Et=(e=>(e.TOP_DOWN="TB",e.BOTTOM_UP="BT",e.LEFT_RIGHT="LR",e.RIGHT_LEFT="RL",e.CENTER="C",e))(Et||{});const Bt=["","icon-label","object","text"];var sv=typeof global=="object"&&global&&global.Object===Object&&global,cv=typeof self=="object"&&self&&self.Object===Object&&self,uv=sv||cv||Function("return this")(),ft=uv.Symbol,vy=Object.prototype,lv=vy.hasOwnProperty,dv=vy.toString,_t=ft?ft.toStringTag:void 0;function fv(e){var t=lv.call(e,_t),r=e[_t];try{e[_t]=void 0;var n=!0}catch{}var o=dv.call(e);return n&&(t?e[_t]=r:delete e[_t]),o}var hv=Object.prototype,pv=hv.toString;function gv(e){return pv.call(e)}var yv="[object Null]",mv="[object Undefined]",ll=ft?ft.toStringTag:void 0;function bv(e){return e==null?e===void 0?mv:yv:ll&&ll in Object(e)?fv(e):gv(e)}function vv(e){return e!=null&&typeof e=="object"}var xv="[object Symbol]";function wv(e){return typeof e=="symbol"||vv(e)&&bv(e)==xv}function Cv(e,t){for(var r=-1,n=e==null?0:e.length,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o}var Ae=Array.isArray,dl=ft?ft.prototype:void 0,fl=dl?dl.toString:void 0;function xy(e){if(typeof e=="string")return e;if(Ae(e))return Cv(e,xy)+"";if(wv(e))return fl?fl.call(e):"";var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function Eu(e){return e==null?"":xy(e)}function _v(e,t,r){var n=-1,o=e.length;t<0&&(t=-t>o?0:o+t),r=r>o?o:r,r<0&&(r+=o),o=t>r?0:r-t>>>0,t>>>=0;for(var i=Array(o);++n<o;)i[n]=e[n+t];return i}function Sv(e,t,r){var n=e.length;return r=r===void 0?n:r,!t&&r>=n?e:_v(e,t,r)}var Ev="\\ud800-\\udfff",jv="\\u0300-\\u036f",Rv="\\ufe20-\\ufe2f",kv="\\u20d0-\\u20ff",Pv=jv+Rv+kv,Av="\\ufe0e\\ufe0f",Tv="\\u200d",Ov=RegExp("["+Tv+Ev+Pv+Av+"]");function wy(e){return Ov.test(e)}function Iv(e){return e.split("")}var Cy="\\ud800-\\udfff",Mv="\\u0300-\\u036f",qv="\\ufe20-\\ufe2f",Nv="\\u20d0-\\u20ff",$v=Mv+qv+Nv,Lv="\\ufe0e\\ufe0f",Fv="["+Cy+"]",mu="["+$v+"]",bu="\\ud83c[\\udffb-\\udfff]",Bv="(?:"+mu+"|"+bu+")",_y="[^"+Cy+"]",Sy="(?:\\ud83c[\\udde6-\\uddff]){2}",Ey="[\\ud800-\\udbff][\\udc00-\\udfff]",Dv="\\u200d",jy=Bv+"?",Ry="["+Lv+"]?",zv="(?:"+Dv+"(?:"+[_y,Sy,Ey].join("|")+")"+Ry+jy+")*",Vv=Ry+jy+zv,Wv="(?:"+[_y+mu+"?",mu,Sy,Ey,Fv].join("|")+")",Gv=RegExp(bu+"(?="+bu+")|"+Wv+Vv,"g");function Uv(e){return e.match(Gv)||[]}function Hv(e){return wy(e)?Uv(e):Iv(e)}function Kv(e){return function(t){t=Eu(t);var r=wy(t)?Hv(t):void 0,n=r?r[0]:t.charAt(0),o=r?Sv(r,1).join(""):t.slice(1);return n[e]()+o}}var Zv=Kv("toUpperCase");function Jv(e,t,r,n){for(var o=-1,i=e==null?0:e.length;++o<i;)r=t(r,e[o],o,e);return r}function Yv(e){return function(t){return e==null?void 0:e[t]}}var Xv={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},Qv=Yv(Xv),ex=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,rx="\\u0300-\\u036f",tx="\\ufe20-\\ufe2f",nx="\\u20d0-\\u20ff",ox=rx+tx+nx,ix="["+ox+"]",ax=RegExp(ix,"g");function sx(e){return e=Eu(e),e&&e.replace(ex,Qv).replace(ax,"")}var cx=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function ux(e){return e.match(cx)||[]}var lx=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function dx(e){return lx.test(e)}var ky="\\ud800-\\udfff",fx="\\u0300-\\u036f",hx="\\ufe20-\\ufe2f",px="\\u20d0-\\u20ff",gx=fx+hx+px,Py="\\u2700-\\u27bf",Ay="a-z\\xdf-\\xf6\\xf8-\\xff",yx="\\xac\\xb1\\xd7\\xf7",mx="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",bx="\\u2000-\\u206f",vx=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Ty="A-Z\\xc0-\\xd6\\xd8-\\xde",xx="\\ufe0e\\ufe0f",Oy=yx+mx+bx+vx,Iy="['’]",hl="["+Oy+"]",wx="["+gx+"]",My="\\d+",Cx="["+Py+"]",qy="["+Ay+"]",Ny="[^"+ky+Oy+My+Py+Ay+Ty+"]",_x="\\ud83c[\\udffb-\\udfff]",Sx="(?:"+wx+"|"+_x+")",Ex="[^"+ky+"]",$y="(?:\\ud83c[\\udde6-\\uddff]){2}",Ly="[\\ud800-\\udbff][\\udc00-\\udfff]",at="["+Ty+"]",jx="\\u200d",pl="(?:"+qy+"|"+Ny+")",Rx="(?:"+at+"|"+Ny+")",gl="(?:"+Iy+"(?:d|ll|m|re|s|t|ve))?",yl="(?:"+Iy+"(?:D|LL|M|RE|S|T|VE))?",Fy=Sx+"?",By="["+xx+"]?",kx="(?:"+jx+"(?:"+[Ex,$y,Ly].join("|")+")"+By+Fy+")*",Px="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ax="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Tx=By+Fy+kx,Ox="(?:"+[Cx,$y,Ly].join("|")+")"+Tx,Ix=RegExp([at+"?"+qy+"+"+gl+"(?="+[hl,at,"$"].join("|")+")",Rx+"+"+yl+"(?="+[hl,at+pl,"$"].join("|")+")",at+"?"+pl+"+"+gl,at+"+"+yl,Ax,Px,My,Ox].join("|"),"g");function Mx(e){return e.match(Ix)||[]}function qx(e,t,r){return e=Eu(e),t=t,t===void 0?dx(e)?Mx(e):ux(e):e.match(t)||[]}var Nx="['’]",$x=RegExp(Nx,"g");function Lx(e){return function(t){return Jv(qx(sx(t).replace($x,"")),e,"")}}var Cr=Lx(function(e,t,r){return e+(r?" ":"")+Zv(t)});function je({label:e,children:t}){const r=j.cloneElement(t,{title:t.props.title??e});if(!F.Tooltip.Root){const n=F.Tooltip;return h.jsx(n,{label:e,placement:"top",fontSize:"xs",borderRadius:"15px",children:r})}return h.jsxs(F.Tooltip.Root,{positioning:{placement:"top"},children:[h.jsx(F.Tooltip.Trigger,{asChild:!0,children:r}),h.jsx(F.Portal,{children:h.jsx(F.Tooltip.Positioner,{children:h.jsx(F.Tooltip.Content,{fontSize:"xs",borderRadius:"15px",children:e})})})]})}function It(){const{border:e}=Ve();return h.jsx(F.chakra.span,{role:"separator","aria-orientation":"vertical",display:"block",flexShrink:0,w:"1px",h:"20px",mx:"4px",bg:e})}function Or({children:e,value:t,onValueChange:r,disabled:n,style:o,title:i,icon:a,popupContent:s,labelCase:u="title","aria-label":c}){var P;const{colorMode:l}=Ie(),{background:d,border:f,colorText:p,colorActive:m,colorInactive:y}=Ve(),b=l==="dark",v=j.useId(),g=j.useRef(null),w=j.useRef(null),[x,_]=j.useState(!1);j.useEffect(()=>{const R=w.current;R.setAttribute("popover","auto");const I=O=>_(O.newState==="open");return R.addEventListener("toggle",I),()=>R.removeEventListener("toggle",I)},[]);const C=j.Children.toArray(e).filter(j.isValidElement).map(R=>{const I=R.props;return{value:String(I.value),label:typeof I.children=="string"&&u==="title"?Cr(I.children):I.children,disabled:I.disabled}}),S=()=>{var R;return(R=w.current)==null?void 0:R.hidePopover()},T=()=>{var K,V,re,ce;const R=(K=g.current)==null?void 0:K.getBoundingClientRect(),I=w.current;if(!R||!I)return;const M=((ce=(re=(V=g.current)==null?void 0:V.closest("[data-flow-toolbar-scroll]"))==null?void 0:re.parentElement)==null?void 0:ce.getBoundingClientRect())??R;I.style.maxHeight=`${Math.max(60,Math.max(M.top-40,window.innerHeight-M.bottom-40))}px`;const q=I.getBoundingClientRect();I.style.left=`${Math.max(12,Math.min(R.right-q.width,window.innerWidth-q.width-12))}px`,I.style.top=`${Math.max(12,M.top>=q.height+36?M.top-q.height-24:Math.min(M.bottom+24,window.innerHeight-q.height-12))}px`},k=()=>{var O,M,q,K,V,re;if(n)return;if((O=w.current)==null||O.showPopover(),T(),s){(q=(M=w.current)==null?void 0:M.querySelector("input"))==null||q.focus({preventScroll:!0});return}const R=(K=w.current)==null?void 0:K.querySelectorAll('[role="option"]:not(:disabled)');(re=((V=w.current)==null?void 0:V.querySelector('[aria-selected="true"]:not(:disabled)'))??(R==null?void 0:R[0]))==null||re.focus()};j.useEffect(()=>{if(x){if(n){S();return}return window.addEventListener("resize",T),window.addEventListener("scroll",T,!0),()=>{window.removeEventListener("resize",T),window.removeEventListener("scroll",T,!0)}}},[x,n]);const E=`var(--chakra-colors-${d.replace(".","-")})`;return h.jsxs(h.Fragment,{children:[h.jsx(je,{label:i??c,children:h.jsx(F.chakra.button,{ref:g,type:"button",role:"combobox","data-flow-select-icon":a?"":void 0,"aria-label":c,title:i??c,"aria-haspopup":s?"dialog":"listbox","aria-expanded":x,"aria-controls":v,disabled:n,h:"30px",w:"160px",px:"6px",fontSize:"12px",border:"none",borderRadius:"4px",bg:"transparent",color:a?y:p,display:"flex",alignItems:"center",justifyContent:a?"center":"space-between",gap:2,style:o,onClick:()=>x?S():k(),onKeyDown:R=>{["ArrowDown","ArrowUp"].includes(R.key)&&(R.preventDefault(),k())},children:a??h.jsxs(h.Fragment,{children:[h.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:((P=C.find(R=>R.value===t))==null?void 0:P.label)??t}),h.jsx(Z.PiCaretUp,{size:16,style:{flexShrink:0}})]})})}),h.jsx(F.chakra.div,{ref:w,id:v,role:s?"dialog":"listbox","aria-label":c,position:"fixed",m:0,p:2,minW:"180px",maxW:"calc(100vw - 24px)",overflowY:"auto",bg:d,color:p,borderRadius:"30px",css:{scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"},...Dr(E,`var(--chakra-colors-${(b?f:"gray.300").replace(".","-")})`)},onKeyDown:R=>{var M,q,K;if(s&&!["Escape","Tab"].includes(R.key))return;const I=[...R.currentTarget.querySelectorAll('[role="option"]:not(:disabled)')],O=I.indexOf(document.activeElement);if(["ArrowDown","ArrowUp","Home","End"].includes(R.key)){R.preventDefault();const V=R.key==="Home"?0:R.key==="End"?I.length-1:(O+(R.key==="ArrowDown"?1:-1)+I.length)%I.length;(M=I[V])==null||M.focus()}else R.key==="Escape"||R.key==="Tab"?(R.key==="Escape"&&(R.preventDefault(),R.stopPropagation()),S(),(q=g.current)==null||q.focus()):R.key.length===1&&R.key!==" "&&((K=I.find((V,re)=>{var ce;return re>O&&((ce=V.textContent)==null?void 0:ce.toLowerCase().startsWith(R.key.toLowerCase()))}))==null||K.focus())},children:s??C.map(R=>h.jsxs(F.chakra.button,{type:"button",role:"option","aria-selected":R.value===t,disabled:R.disabled,tabIndex:-1,display:"flex",alignItems:"center",gap:3,px:3,py:2,w:"100%",borderRadius:"30px",fontSize:"sm",textAlign:"left",bg:"transparent",color:p,_hover:{bg:b?"whiteAlpha.100":"blackAlpha.50"},_focusVisible:{bg:b?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var I;S(),(I=g.current)==null||I.focus(),r(R.value)},children:[h.jsx("span",{style:{flex:1},children:R.label}),h.jsx(Z.PiCheck,{size:16,color:`var(--chakra-colors-${m.replace(".","-")})`,"aria-hidden":"true",style:{flexShrink:0,visibility:R.value===t?"visible":"hidden"}})]},R.value))})]})}const ve=j.forwardRef(function({icon:t,...r},n){const{colorMode:o}=Ie();return h.jsx(F.IconButton,{ref:n,_hover:{bg:o==="dark"?"whiteAlpha.100":"blackAlpha.50"},title:r.title??r["aria-label"],...r,children:t})}),pt=j.forwardRef(function(t,r){const{themeColor:n}=Ie();return h.jsx(je,{label:"Close",children:h.jsx(ve,{ref:r,size:"sm",variant:"ghost",color:n,focusRingColor:n,...t,"aria-label":t["aria-label"]??"Close selection tools",icon:h.jsx(Z.PiXLight,{size:20,"aria-hidden":"true"})})})});function Dy({label:e,icon:t,checked:r,onChange:n,disabled:o}){const{themeColor:i,readOnly:a}=Ie(),{colorInactive:s}=Ve();return h.jsx(je,{label:e,children:h.jsx(ve,{"aria-label":e,"aria-pressed":r,icon:h.jsxs(h.Fragment,{children:[t,h.jsx(F.Text,{as:"span",fontSize:"xs",fontWeight:"normal",whiteSpace:"nowrap",children:e})]}),size:"sm",variant:"ghost",width:"auto",px:2,gap:2,color:r?i:s,disabled:o||a,onClick:()=>n(!r)})})}function zy({label:e="Compact layout"}={}){const{compactPropertyLayout:t,setCompactPropertyLayout:r,callbacks:n}=Ie();return h.jsx(Dy,{label:e,checked:t,icon:h.jsx(F.Icon,{as:Z.PiArrowsIn,boxSize:5}),onChange:o=>{var i;r(o),(i=n.onCompactPropertyLayoutChange)==null||i.call(n,o)}})}const Vy=yn.default.input`
|
|
8
|
+
appearance: none;
|
|
9
|
+
width: 100%;
|
|
10
|
+
height: 24px;
|
|
11
|
+
margin: 0;
|
|
12
|
+
padding: 0;
|
|
13
|
+
border: 0;
|
|
14
|
+
box-shadow: none;
|
|
15
|
+
background-color: transparent;
|
|
16
|
+
background-size: 100% 6px;
|
|
17
|
+
background-position: center;
|
|
18
|
+
background-repeat: no-repeat;
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
&::-webkit-slider-runnable-track {
|
|
21
|
+
height: 6px;
|
|
22
|
+
background: transparent;
|
|
23
|
+
border: 0;
|
|
24
|
+
box-shadow: none;
|
|
25
|
+
}
|
|
26
|
+
&::-moz-range-track {
|
|
27
|
+
height: 6px;
|
|
28
|
+
background: transparent;
|
|
29
|
+
border: 0;
|
|
30
|
+
box-shadow: none;
|
|
31
|
+
}
|
|
32
|
+
&::-webkit-slider-thumb {
|
|
33
|
+
appearance: none;
|
|
34
|
+
width: 16px;
|
|
35
|
+
height: 16px;
|
|
36
|
+
margin-top: -5px;
|
|
37
|
+
border: 0;
|
|
38
|
+
border-radius: 50%;
|
|
39
|
+
background: currentColor;
|
|
40
|
+
box-shadow: none;
|
|
41
|
+
}
|
|
42
|
+
&::-moz-range-thumb {
|
|
43
|
+
width: 16px;
|
|
44
|
+
height: 16px;
|
|
45
|
+
border: 0;
|
|
46
|
+
border-radius: 50%;
|
|
47
|
+
background: currentColor;
|
|
48
|
+
box-shadow: none;
|
|
49
|
+
}
|
|
50
|
+
&:disabled {
|
|
51
|
+
cursor: default;
|
|
52
|
+
opacity: 0.5;
|
|
53
|
+
}
|
|
54
|
+
`;function ml({label:e,inputLabel:t,value:r,displayValue:n,min:o,max:i,onChange:a}){const s=j.useId(),{readOnly:u,themeColor:c}=Ie(),{colorInactive:l}=Ve(),d=(r-o)/(i-o)*100,f=c.includes(".")?`var(--chakra-colors-${c.replace(".","-")})`:c;return h.jsxs("div",{style:{width:224,maxWidth:"calc(100vw - 64px)",padding:12},children:[h.jsxs("label",{htmlFor:s,style:{display:"flex",justifyContent:"space-between",fontSize:14,marginBottom:12},children:[e," ",h.jsx("span",{children:n})]}),h.jsx(Vy,{id:s,"aria-label":t,type:"range",min:o,max:i,step:5,value:r,disabled:u,style:{color:f,accentColor:f,backgroundImage:`linear-gradient(to right, currentColor ${d}%, var(--chakra-colors-${l.replace(".","-")}) ${d}%)`},onChange:p=>a(Number(p.target.value))})]})}const bl={dot:{label:"Dots",icon:Z.PiDotsNine},grid:{label:"Grid",icon:Z.PiGridFour},steel:{label:"Steel",icon:Z.PiLineSegments},none:{label:"Solid",icon:Z.PiSquareFill},transparent:{label:"Transparent",icon:Z.PiSelection}};function Wy(){const{spacing:e,setSpacing:t,edgeRadius:r,setEdgeRadius:n,backgroundVariant:o,setBackgroundVariant:i,callbacks:a,readOnly:s}=Ie(),u=bl[o].icon;return h.jsxs(h.Fragment,{children:[h.jsx(It,{}),h.jsx(Or,{"aria-label":"Node spacing",title:`Spacing: ${Math.round(e*100)}%`,icon:h.jsx(Z.PiArrowsOutCardinal,{size:20}),style:{width:36},value:"spacing",disabled:s,onValueChange:()=>{},popupContent:h.jsx(ml,{label:"Spacing",inputLabel:"Node spacing percentage",min:50,max:200,value:Math.round(e*100),displayValue:`${Math.round(e*100)}%`,onChange:c=>{var l;t(c/100),(l=a.onSpacingChange)==null||l.call(a,c/100)}}),children:h.jsx("option",{value:"spacing",children:"Spacing"})}),h.jsx(It,{}),h.jsx(Or,{"aria-label":"Edge radius",title:`Edge radius: ${r??"Default"}`,icon:h.jsx(Z.PiBezierCurve,{size:20}),style:{width:36},value:"radius",disabled:s,onValueChange:()=>{},popupContent:h.jsx(ml,{label:"Edge radius",inputLabel:"Edge corner radius",min:0,max:500,value:r??500,displayValue:r??"Default",onChange:c=>{var l;n(c),(l=a.onEdgeRadiusChange)==null||l.call(a,c)}}),children:h.jsx("option",{value:"radius",children:"Edge radius"})}),h.jsx(It,{}),h.jsxs(Or,{"aria-label":"Background variant",title:`Background: ${bl[o].label}`,icon:h.jsx(u,{size:20,"data-background-icon":o}),style:{width:36},value:o,disabled:s,onValueChange:c=>{var l;i(c),(l=a.onBackgroundVariantChange)==null||l.call(a,c)},children:[h.jsx("option",{value:"dot",children:"Dots"}),h.jsx("option",{value:"grid",children:"Grid"}),h.jsx("option",{value:"steel",children:"Steel"}),h.jsx("option",{value:"none",children:"Solid"}),h.jsx("option",{value:"transparent",children:"Transparent"})]})]})}const nr=[];for(let e=0;e<256;++e)nr.push((e+256).toString(16).slice(1));function Fx(e,t=0){return(nr[e[t+0]]+nr[e[t+1]]+nr[e[t+2]]+nr[e[t+3]]+"-"+nr[e[t+4]]+nr[e[t+5]]+"-"+nr[e[t+6]]+nr[e[t+7]]+"-"+nr[e[t+8]]+nr[e[t+9]]+"-"+nr[e[t+10]]+nr[e[t+11]]+nr[e[t+12]]+nr[e[t+13]]+nr[e[t+14]]+nr[e[t+15]]).toLowerCase()}let Zn;const Bx=new Uint8Array(16);function Dx(){if(!Zn){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Zn=crypto.getRandomValues.bind(crypto)}return Zn(Bx)}const zx=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),vl={randomUUID:zx};function ju(e,t,r){var o;if(vl.randomUUID&&!e)return vl.randomUUID();e=e||{};const n=e.random??((o=e.rng)==null?void 0:o.call(e))??Dx();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,Fx(n)}const mn={label:"Untitled",description:"",isTask:!1,isLocked:!1},Ru={id:null,type:"text",data:{...mn,viewProps:{width:"max-content !important",maxWidth:700,height:"100%",borderColor:"transparent",borderRadius:25,borderWidth:0,boxShadow:"none",textOverflow:"ellipsis",fontWeight:"bold",textColor:"gray.800",textAlign:"center"}}},xl={id:null,type:"objectView",data:{...mn,headerTitle:null,viewProps:{width:"100%",borderWidth:2,borderRadius:53,height:"100%",justifyContent:"space-between",flexDirection:"row",textColor:"gray.900"}}},Vx={id:null,type:"arrayView",data:{...mn,viewProps:{width:"max-content !important",maxWidth:700,height:"100%",textAlign:"center",borderRadius:25,fontSize:"5xl",borderWidth:2,textOverflow:"ellipsis",wordBreak:"keep-all",fontWeight:"bold",textColor:"gray.900",placeholder:"Start Typing"}}},wl={id:null,type:"workflowStep",data:{...mn,viewProps:{width:"max-content !important",maxWidth:350,minWidth:280,height:"100%",borderRadius:15,borderWidth:3}}},hr=e=>typeof e=="object",Gy=e=>Array.isArray(e),Wx=["order","position","selected","locked","grabbed","grabbable","scratch"],zr=e=>Object.entries(e).reduce((t,[r,n])=>(!hr(n)&&!r.startsWith("$")&&(t[r]=n),t),{}),ku=(e,t)=>typeof e=="string"&&e.startsWith("$")?Jn(e,t):hr(e)&&!Gy(e)?Object.entries(e).reduce((r,[n,o])=>(typeof o=="string"&&o.startsWith("$")&&n==="..."?(delete r["..."],r[n]={...Jn(o,t),...e}):typeof o=="string"&&o.startsWith("$")?r[n]=Jn(o,t):r[n]=o,r),{}):e,Vr=e=>Object.entries(e).reduce((t,[r,n])=>(hr(n)&&r&&n&&!r.startsWith("$")&&(Wx.includes(r)&&(r=r+"#"),t[r]=n),t),{}),Jr=(e,t,{label:r,parent:n=void 0},o,i=null)=>(i!==null&&(hr(i)||Gy(i))&&(i=JSON.stringify(i,null,2)),{data:{parent:n,...e.data,id:t,text:r||"",label:r,code:i||null,type:e.type,description:o}}),Br=(e,t,r=null,n=null,o=null,i=!1,a=null)=>({data:{id:ju(),source:o?t:e,target:o?e:t,label:n||"",isInverted:o,isEdgeAnimated:i,parent:a}}),Wr=(e,t=[])=>{const r={},n={};let o=[];if(e)for(const[i,a]of Object.entries(e))i.startsWith("$")&&i!=="$"?r[i.slice(1)]=a:i!=="$"?n[i]=a:i==="$"&&(o=a);return{newConfig:r,updatedObject:n,arrayObject:o}},ut=(e,t)=>{let r=xl;const{view:n,borderColor:o,borderRadius:i,bgColor:a,textColor:s,fontSize:u,stepType:c}=t;e=n||e,c?r={...wl}:e==="object"?r=xl:e==="text"?r=Ru:e==="array"?r=Vx:e==="workflowStep"&&(r={...wl});const l=r.data.viewProps;return r.data.viewProps={...l,borderRadius:i||(c?15:53),bgColor:a,borderColor:o,textColor:s,fontSize:u},r.data.config=t,{config:r}},Dt=(e,t)=>(e=t.find(n=>n.data.id===e)?`${e}.#`:e,e),Jn=(e,{ids:t,jsnObjct:r})=>{if(typeof e=="string"&&(e!=null&&e.startsWith("$"))){const n=e.replace("$","").replace("*","");e==null||e.endsWith("*");const o=t.find(s=>s.split(".").slice(-1)[0]===n||n===s);if(!o)return e;const i=Gx(o,r);return JSON.stringify(i).includes(e)?e:i||e}return e},Gx=(e,t)=>{let r=e.split(".").splice(1);return r=r[r.length-1]==="#"||r[r.length-1].includes("{")?r.slice(0,-2):r,(i=>r.reduce((a,s)=>{s=s.replace("[","").replace("]","");const{arrayObject:u}=Wr(a);return a=u.length?u:a,a[s]},i))(t)};function dt(e,t="root",r=[]){try{const{arrayObject:n}=Wr(e);n.length&&(e=n);const o=zr(e),i=Vr(e);return hr(e)?(Ae(e)||Ae(e)&&t==="root"||!Ae(e)&&Object.keys(o).length||t==="root")&&r.push(t):r.push(t),Object.keys(i).length&&!Ae(e)?Mt({chldPth:null,itrblObjct:i,nodes:r,path:t}):Ae(e)&&e.forEach((a,s)=>{const u=zr(a),c=Vr(a),{newConfig:l,arrayObject:d}=Wr(a);let f=`${t}.${s}`;hr(a)?Object.keys(u).length?(dt(u,f,r),Object.keys(c).length&&!Ae(a)&&Mt({chldPth:f,itrblObjct:c,nodes:r,path:t})):Object.keys(c).length&&!Ae(a)?Mt({chldPth:f,itrblObjct:c,nodes:r,path:t}):Ae(a)&&Uy({chldPth:f,item:a,nodes:r,path:t}):r.push(f)}),{nodes:r}}catch{return{nodes:r}}}const Mt=({chldPth:e,itrblObjct:t,nodes:r,path:n})=>Object.entries(t).forEach(([o,i],a)=>{const s=zr(i),u=Vr(i),{newConfig:c,arrayObject:l}=Wr(i);l.length&&(i=l),n.split(".").slice(0,2).join(".");let d=e?`${e}.${o}`:`${n}.${o}`;if(hr(i)&&!Ae(i)){const f=Object.keys(s).length===0;if(f&&(ut("array",c),r.push(d)),Object.keys(s).length){const p=Ae(i)?`${i.length||""}`:`{${Object.keys(i).length||""}}`;let m=d;f&&(m=`${d}.${p}`),dt(i,m,r)}else Object.keys(u).length&&!Ae(i)?Mt({chldPth:d,itrblObjct:u,path:d,nodes:r}):dt(i,d,r)}else Ae(i)&&dt(i,d,r)}),Uy=({chldPth:e,item:t,nodes:r,path:n})=>t.forEach((o,i)=>{let a=`${e}.${i}`;const s=Vr(o),u=zr(o);hr(o)?!Ae(o)&&Object.keys(u).length?dt(o,a,r):Object.keys(s).length&&!Ae(o)?Mt({chldPth:a,itrblObjct:s,path:n,nodes:r}):Ae(o)&&Uy({chldPth:a,item:o,nodes:r,path:n}):r.push(a)}),ln=[];let qt;function Xr(e,t="root",r=[],n=[],o="untitled",i={hideDefaultObject:!1,sprtObjctKy:!1,isCntr:!1},a={}){if(!e||typeof e!="object")return console.error("Invalid object passed",e),{nodes:r,edges:n};const s=e;if(!qt){const{nodes:l}=dt(e);qt={ids:l,jsnObjct:e}}let{hideDefaultObject:u,sprtObjctKy:c}=i;try{t=Dt(t,r);const{newConfig:l,arrayObject:d}=Wr(e),f=Object.keys(a).length>0?a:l;d.length&&(e=d);const p=zr(e),m=Vr(e),{label:y,collapsed:b,parent:v}=f;if(!hr(e))r.push(Jr(Ru,t,{label:y||t,parent:v},e,s));else if(Ae(e)||Ae(e)&&t==="root"){const{config:g}=ut("array",f),w=Ae(e)?`${e.length||""}`:`{${Object.keys(e).length||""}}`,x=t==="root"?o:`${o} ${w}`;r.push(Jr(g,t,{label:y||x,parent:v},e,Ae(s)?{[o]:s}:s))}else if(!Ae(e)&&Object.keys(p).length||t==="root"){const{config:g}=ut(null,f),w=Ae(e)?`${e.length||""}`:`{${Object.keys(e).length||""}}`,x=t.split("."),_=x[x.length-1];let C=isNaN(Number(_))?null:Number(_)+1;const S=isNaN(Number(_))?_:x[x.length-2]+" "+C,T=t==="root"?o:S;let k=!1;Number.isNaN(Number(o))||(k=!0);const E=e;if(y){const{config:P}=ut("object",f);r.push(Jr(P,t,{label:y||`${y} ${w}`,parent:v},p,E))}else g.data.headerTitle=T,r.push(Jr(g,t,{label:y,parent:v},p,E))}return b||(Object.keys(m).length&&!Ae(e)?Nt({flowConfig:i,chldPth:null,edges:n,isInverted:null,itrblObjct:m,nodes:r,path:t,newConfig:f}):Ae(e)&&e.forEach((g,w)=>{g=ku(g,qt);const x=g,_=zr(g),C=Vr(g),{newConfig:S,arrayObject:T}=Wr(g);T.length&&(g=T);const{config:k}=ut(typeof g=="string"?"text":"array",S),{hideConfig:E,sourceLabel:P,label:R,isEdgeAnimated:I,parent:O}=S;u=u||E;const M=t==="root"&&i.isCntr,q=t.split(".").slice(0,2).join("."),K=ln.includes(q),V=i.isCntr&&K||w%2===0&&M;let re=`${t}.${w}`;re=Dt(re,r),V&&ln.push(re),hr(g)?Object.keys(_).length&&!Ae(g)?(n.push(Br(t,re,null,P,V,I)),Xr(g,re,r,n,R||w,i,S)):Object.keys(C).length&&!Ae(g)?Nt({flowConfig:i,chldPth:re,isInverted:V,edges:n,itrblObjct:C,nodes:r,path:t,newConfig:S,forceIsInverted:!0}):Ae(g)?Hy({flowConfig:i,chldPth:re,edges:n,isInverted:V,item:g,nodes:r,path:t}):hr(g)&&Nt({flowConfig:i,chldPth:re,isInverted:V,edges:n,itrblObjct:[g],nodes:r,path:t,newConfig:S}):(n.push(Br(t,re,null,P,V,I)),r.push(Jr(k,re,{label:R||String(g),parent:O},g,x)))})),{nodes:r,edges:n}}catch{return{nodes:r,edges:n}}}const Nt=({chldPth:e,flowConfig:t,edges:r,itrblObjct:n,nodes:o,isInverted:i,path:a,newConfig:s,forceIsInverted:u=!1})=>{let{hideDefaultObject:c,sprtObjctKy:l}=t;return Object.entries(n).forEach(([d,f],p)=>{f=ku(f,qt);const m=f,y=zr(f),b=Vr(f),{newConfig:v,arrayObject:g}=Wr(f);g.length&&(f=g);const{hideConfig:w,sourceLabel:x,label:_,content:C,target:S,targetLabel:T,collapsed:k,isEdgeAnimated:E,parent:P}=v;c=c||w;const R=a==="root"&&t.isCntr,I=a.split(".").slice(0,2).join("."),O=ln.includes(I);u||(i=t.isCntr&&O||p%2===0&&R);let M=e?`${e}.${d}`:`${a}.${d}`;if(M=Dt(M,o),i&&ln.push(M),S&&r.push(Br(M,S,null,T,i,E)),hr(f)&&!Ae(f)){r.push(Br(a,M,null,x,i,E));const q=l||Object.keys(y).length===0;if(q){const K=C?"object":"array",{config:V}=ut(K,v);V.data.headerTitle=C?_:null,o.push(Jr(V,M,{label:_||d,parent:P},f,m))}if(Object.keys(y).length&&!c){const K=Ae(f)?` ${f.length||""}`:`{${Object.keys(f).length||""}}`;let V=M;q&&(V=`${M}.${K}`,V=Dt(V,o),r.push(Br(M,V,null,x,i,E))),Xr(f,V,o,r,_||d,t,v)}else Object.keys(b).length&&!Ae(f)?Nt({chldPth:M,flowConfig:t,itrblObjct:b,path:M,edges:r,nodes:o,newConfig:v,isInverted:i}):Xr(f,M,o,r,d,t,v)}else Ae(f)&&(r.push(Br(a,M,null,x,i,E)),Xr(f,M,o,r,d,t,v))})},Hy=({flowConfig:e,chldPth:t,edges:r,isInverted:n,item:o,nodes:i,path:a})=>o.forEach((s,u)=>{let c=`${t}.${u}`;c=Dt(c,i);const l=s;s=ku(s,qt);const d=Vr(s),f=zr(s),{newConfig:p}=Wr(s),{collapsed:m,label:y,parent:b,sourceLabel:v,isEdgeAnimated:g,content:w}=p;hr(s)?!Ae(s)&&Object.keys(f).length?(r.push(Br(a,c,null,v,n,g)),Xr(s,c,i,r,u,e,p)):Object.keys(d).length&&!Ae(s)&&!m?Nt({chldPth:c,flowConfig:e,itrblObjct:d,path:a,edges:r,nodes:i,isInverted:n,newConfig:p}):Ae(s)&&Hy({flowConfig:e,chldPth:c,edges:r,isInverted:n,item:s,nodes:i,path:a}):(r.push(Br(a,c,null,v,n,g)),i.push(Jr(Ru,c,{label:y||String(s),parent:b},s,l)))});function Ux(e,t){const r=new Set,n=c=>{if(!(!c||typeof c!="object")){typeof c.$parent=="string"&&r.add(c.$parent);for(const[l,d]of Object.entries(c))(!l.startsWith("$")||l==="$")&&n(d)}};if(n(e),!r.size)return t;const o=new Map(t.nodes.map(c=>[c.data.id,c])),i=c=>{var p,m;let l=c.data.id;const d=new Set([c.data.id]);let f=c.data.parent;for(;f&&!d.has(f);)r.has(f)&&o.has(f)&&((p=xe(e,f))!=null&&p.$collapsed)&&(l=f),d.add(f),f=(m=o.get(f))==null?void 0:m.data.parent;return l},a=new Map(t.nodes.map(c=>[c.data.id,i(c)])),s=t.nodes.filter(c=>a.get(c.data.id)===c.data.id).map(c=>{if(!r.has(c.data.id))return c;const l=xe(e,c.data.id),d=!!(l!=null&&l.$collapsed);return{...c,data:{...c.data,...d?{type:"arrayView"}:{},config:{...c.data.config,parentContainer:!0,collapsed:d,...d?{labelBelow:!0,icon:(l==null?void 0:l.$icon)||"PiStack"}:{}}}}}),u=new Set(s.map(c=>c.data.id));return{nodes:s,edges:t.edges.flatMap(c=>{const l=a.get(c.data.source),d=a.get(c.data.target);return!l||!d||!u.has(l)||!u.has(d)?[]:l===c.data.source&&d===c.data.target?[c]:l===d?[]:[{...c,data:{...c.data,source:l,target:d,collapsedEndpoints:c.data.collapsedEndpoints??{source:c.data.source,target:c.data.target}}}]})}}function bn(e){if(!Array.isArray(e==null?void 0:e.$connections))return[];const t=new Map;return e.$connections.flatMap((r,n)=>{if(!r||typeof r!="object")return[];const o=r;if(typeof o.target!="string"||!/^root(?:\.|$)/.test(o.target))return[];if(o.sourceProperty!==void 0&&typeof o.sourceProperty!="string")return[];if(o.targetProperty!==void 0&&typeof o.targetProperty!="string")return[];const i=typeof o.id=="string"&&o.id?JSON.stringify(["id",o.id]):JSON.stringify(["ports",o.target,o.sourceProperty??null,o.targetProperty??null]),a=t.get(i)??0;return t.set(i,a+1),[{value:o,key:`${i}#${a}`,index:n}]})}function Ky(e,t,r){const n=bn(e).find(u=>u.key===t);if(!n)return e;const o=r(n.value),i=e.$connections.flatMap((u,c)=>c===n.index?o?[o]:[]:[u]);if(i.length)return{...e,$connections:i};const{$connections:a,...s}=e;return s}function Hx(e){const t=[],r=(n,o)=>{if(!n||typeof n!="object")return n;if(Array.isArray(n))return n.map((i,a)=>r(i,`${o}.${a}`));for(const i of bn(n)){const a=i.value;t.push({data:{id:`connection:${JSON.stringify([o,i.key])}`,source:o,target:a.target,type:typeof a.type=="string"?a.type:void 0,sourceProperty:a.sourceProperty,targetProperty:a.targetProperty,icon:typeof a.icon=="string"?a.icon:void 0,label:typeof a.label=="string"?a.label:void 0,color:typeof a.color=="string"?a.color:void 0,isEdgeDashed:a.style==="dashed",isEdgeAnimated:a.style==="animated",...["dashed","traveling"].includes(a.animationVariant)?{edgeAnimationVariant:a.animationVariant}:{},connection:{address:o,key:i.key}}})}return Object.fromEntries(Object.entries(n).filter(([i])=>i!=="$connections").map(([i,a])=>[i,i==="$"?r(a,o):i.startsWith("$")?a:r(a,`${o}.${i}`)]))};return{json:r(e,"root"),edges:t}}const zt="root",Cl=e=>e==="#"||e.startsWith("{")||/^\s\d*$/.test(e);function Ir(e){const t=e.split(".");for(t[0]===zt&&t.shift();t.length&&Cl(t[t.length-1]);)t.pop();return t.filter(r=>!Cl(r))}function vn(e){return e==null||typeof e!="object"?e:Array.isArray(e.$)?e.$:e}function xe(e,t){return Ir(t).reduce((r,n)=>{var o;if(r!=null)return(o=vn(r))==null?void 0:o[n]},e)}function Kx(e){return Array.isArray(e)?[...e]:{...e}}function pr(e,t,r){const n=Ir(t),o=(i,a)=>{if(a===n.length)return r(i);const s=n[a],u=vn(i);if(u==null||typeof u!="object")return i;const c=o(u[s],a+1);if(Object.is(c,u[s]))return i;const l=Kx(u);return l[s]=c,u!==i?{...i,$:l}:l};return o(e,0)}function Tr(e,t,r){const n=r===""&&t!=="$content"||r===void 0||r===null;if(Array.isArray(e))return n?e:{[t]:r,$:[...e]};const o=e!=null&&typeof e=="object"?{...e}:{};return e!=null&&typeof e!="object"&&(o.$label=String(e)),n?delete o[t]:o[t]=r,o}function ir(e,t,r,n){return pr(e,t,o=>r==="$label"&&typeof o=="string"&&typeof n=="string"&&n!==""?n:Tr(o,r,n))}const Zy=(e,t,r)=>ir(e,t,"$collapsed",r);function Vt(e){if(e.connection)return{address:e.connection.address,kind:"connection"};const t=e.collapsedEndpoints??e,r=e.isInverted?t.target:t.source,n=e.isInverted?t.source:t.target,o=Ir(r).join("."),i=Ir(n).join(".");return i.startsWith(o?o+".":"")&&i!==o?{address:n,kind:"hierarchy"}:o.startsWith(i?i+".":"")&&o!==i?{address:r,kind:"hierarchy"}:{address:r,kind:"target"}}function Fr(e,t,r,n){if(t.connection){const s=t.connection;return pr(e,s.address,u=>Ky(u,s.key,c=>{if(r==="$edgeIcon")return Tr(c,"icon",n);if(r==="$edgeType")return Tr(c,"type",n);if(r==="$edgeAnimationVariant")return Tr(c,"animationVariant",n);if(r==="$sourceLabel"||r==="$edgeColor")return Tr(c,r==="$sourceLabel"?"label":"color",n);const l=r==="$isEdgeAnimated"?"animated":"dashed";return n?{...c,style:l}:c.style===l?Tr(c,"style",void 0):c}))}const{address:o,kind:i}=Vt(t),a=i==="target"&&r==="$sourceLabel"?"$targetLabel":i==="target"&&r==="$edgeType"?"$targetEdgeType":i==="target"&&r==="$edgeIcon"?"$targetIcon":i==="target"&&r==="$edgeAnimationVariant"?"$targetAnimationVariant":r;return pr(e,o,s=>Tr(s,a,n))}const Jy=(e,t,r)=>Fr(Fr(e,t,"$isEdgeAnimated",r==="animated"||void 0),t,"$isEdgeDashed",r==="dashed"||void 0);function Pu(e,t,r,n){let o=n||"";const i=pr(e,t,s=>{const u=vn(s);if(Array.isArray(u)){o=String(u.length);const l=[...u,r];return u===s?l:{...s,$:l}}const c=s!=null&&typeof s=="object"&&!Array.isArray(s)?{...s}:s!=null&&typeof s!="object"?{$label:String(s)}:{};if(!o){let l=1;for(;`node_${l}`in c;)l++;o=`node_${l}`}return c[o]=r,c}),a=Ir(t);return{json:i,address:[zt,...a,o].join(".")}}function Yy(e,t){const r=Ir(t);if(!r.length)return e;const n=r[r.length-1],o=[zt,...r.slice(0,-1)].join(".");return pr(e,o,i=>{const a=vn(i);if(a==null||typeof a!="object"||!Object.prototype.hasOwnProperty.call(a,n))return i;if(Array.isArray(a)){const c=a.filter((l,d)=>String(d)!==n);return a===i?c:{...i,$:c}}const{[n]:s,...u}=i;return u})}const Xy=(e,t,r,n)=>ir(n?pr(e,t,o=>Tr(o,"$targetLabel",n)):e,t,"$target",r);function Au(e,t,r){const n=xe(e,t);return bn(n).some(({value:i})=>i.target===r.target&&i.sourceProperty===r.sourceProperty&&i.targetProperty===r.targetProperty)?e:pr(e,t,i=>Tr(i,"$connections",[...Array.isArray(i==null?void 0:i.$connections)?i.$connections:[],{...r,id:r.id||ju()}]))}function Qy(e,t){if(t.connection){const i=t.connection;return bn(xe(e,i.address)).some(a=>a.key===i.key)?{json:pr(e,i.address,a=>Ky(a,i.key,()=>null)),removed:!0}:{json:e,removed:!1}}const{address:r,kind:n}=Vt(t);return n==="hierarchy"?xe(e,r)===void 0?{json:e,removed:!1}:{json:pr(e,r,i=>({...i,$hideParentEdge:!0})),removed:!0}:n!=="target"?{json:e,removed:!1}:{json:pr(e,r,i=>{const{$target:a,$targetLabel:s,...u}=i||{};return u}),removed:!0}}function vu(e,t={}){var v;const r=Hx(e),{nodes:n,edges:o}=Xr(r.json,zt,[],[],t.title||"untitled",{hideDefaultObject:!!t.hideDefaultObject,sprtObjctKy:!!t.separateObjectKeys,isCntr:!!t.isCenter}),i=new Set(n.map(g=>g.data.id)),a=new Map;for(const g of n){const w=g.data.id;if(!w.endsWith(".0")||xe(e,w)!==void 0)continue;const x=w.slice(0,-2),_=xe(e,x);!i.has(x)&&_&&typeof _=="object"&&!Array.isArray(_)&&typeof _.$label=="string"&&Object.keys(_).every(C=>C.startsWith("$")&&C!=="$")&&a.set(w,x)}const s=g=>a.get(g)??g,u=new Set(n.flatMap(g=>g.data.parent?[s(g.data.parent)]:[])),c=n.map(g=>{var T;const w=s(g.data.id),x=xe(e,w),_={...g.data,id:w},C=x&&typeof x=="object"&&!Array.isArray(x)&&"$"in x?x.$:x;if((Array.isArray(C)?C.length>0:C&&typeof C=="object"&&Object.keys(C).some(k=>!k.startsWith("$")))&&(_.config={..._.config,collapsed:!!x.$collapsed}),u.has(w)||(_.viewProps={..._.viewProps},delete _.viewProps.borderWidth),!x||typeof x!="object"||Array.isArray(x))return{data:_};if(x.$form&&typeof x.$form=="object"&&(_.config={..._.config,form:x.$form},_.type="objectView"),Array.isArray(x.$ports)){const k=x.$ports.filter(E=>E&&typeof E.id=="string"&&["source","target"].includes(E.role)&&["top","right","bottom","left"].includes(E.side));_.config={..._.config,ports:k}}return _.parent&&(_.parent=s(_.parent)),typeof x.$label=="string"&&(_.label=x.$label,_.headerTitle=x.$label),typeof x.$subtitle=="string"&&(_.config={..._.config,subtitle:x.$subtitle}),typeof x.$outline=="boolean"&&(_.viewProps={..._.viewProps,outline:x.$outline}),["solid","dashed","dotted","double"].includes(x.$borderStyle)&&(_.viewProps={..._.viewProps,borderStyle:x.$borderStyle}),Number.isFinite(x.$borderWidth)&&x.$borderWidth>=0&&(_.viewProps={..._.viewProps,borderWidth:x.$borderWidth}),Number.isFinite(x.$borderRadius)&&x.$borderRadius>=0&&(_.viewProps={..._.viewProps,borderRadius:x.$borderRadius}),typeof x.$isNodeAnimated=="boolean"&&(_.isNodeAnimated=x.$isNodeAnimated),["traveling","pulse"].includes(x.$nodeAnimationVariant)&&(_.nodeAnimationVariant=x.$nodeAnimationVariant),typeof x.$content=="string"&&(_.config={..._.config,content:x.$content},x.$view||(_.type="objectView")),(((T=_.config)==null?void 0:T.collapsed)!==void 0||x.$collapsed!==void 0||x.$icon!==void 0)&&(_.config={..._.config||{}},(x.$collapsed!==void 0||_.config.collapsed!==void 0)&&(_.config.collapsed=!!x.$collapsed),x.$icon!==void 0&&(_.config.icon=x.$icon)),{data:_}}),l=new Map,d=o.map(g=>{const w=s(g.data.source),x=s(g.data.target),_=`${w}->${x}`,C=l.get(_)??0;l.set(_,C+1);const S={...g.data,id:C?`${_}#${C}`:_,source:w,target:x},T=Vt(S),k=xe(e,T.address);if(k&&typeof k=="object"){const E=k[T.kind==="target"?"$targetEdgeType":"$edgeType"];typeof E=="string"&&(S.type=E);const P=k[T.kind==="target"?"$targetIcon":"$edgeIcon"];typeof P=="string"&&(S.icon=P),k.$isEdgeAnimated!==void 0&&(S.isEdgeAnimated=!!k.$isEdgeAnimated);const R=k[T.kind==="target"?"$targetAnimationVariant":"$edgeAnimationVariant"];["dashed","traveling"].includes(R)&&(S.edgeAnimationVariant=R),k.$isEdgeDashed!==void 0&&(S.isEdgeDashed=!!k.$isEdgeDashed),k.$edgeColor&&(S.color=k.$edgeColor)}return{data:S}});if(!Array.isArray(e)&&(e==null?void 0:e.$hideRoot)===!0){const g=c.findIndex(w=>w.data.id===zt);g!==-1&&c.splice(g,1)}const f=new Set(c.map(g=>g.data.id));for(let g=d.length-1;g>=0;g--){const w=d[g].data,x=Vt(w);(!f.has(w.source)||!f.has(w.target)||x.kind==="hierarchy"&&((v=xe(e,x.address))==null?void 0:v.$hideParentEdge)===!0)&&d.splice(g,1)}d.push(...r.edges.filter(g=>f.has(g.data.source)&&f.has(g.data.target)));const p=Ux(e,{nodes:c,edges:d}),m=p.nodes.filter(g=>{var w;return(w=g.data.config)==null?void 0:w.collapsed}).map(g=>Ir(g.data.id));if(!m.length)return p;const y=p.nodes.filter(g=>{const w=Ir(g.data.id);return!m.some(x=>x.length<w.length&&x.every((_,C)=>_===w[C]))}),b=new Set(y.map(g=>g.data.id));return{nodes:y,edges:p.edges.filter(g=>b.has(g.data.source)&&b.has(g.data.target))}}function Zx(e,t){const r=new Set(e.filter(u=>{var c,l;return(l=(c=u.data)==null?void 0:c.config)==null?void 0:l.collapsed}).map(u=>u.data.id));if(!r.size)return{nodes:e,edges:t};const n=new Map(e.map(u=>[u.data.id,u])),o=new Set(e.map(u=>u.data.parent).filter(Boolean)),i=new Map(e.map(u=>{var f;let c=u.data.id,l=u.data.parent;const d=new Set([c]);for(;l&&!d.has(l);)r.has(l)&&(c=l),d.add(l),l=(f=n.get(l))==null?void 0:f.data.parent;return[u.data.id,c]})),a=new Map;for(const u of t){const c=u.data.isInverted?u.data.target:u.data.source,l=u.data.isInverted?u.data.source:u.data.target;(a.get(c)??a.set(c,[]).get(c)).push(l)}const s=new Set(e.filter(u=>i.get(u.data.id)!==u.data.id).map(u=>u.data.id));for(const u of r){if(o.has(u))continue;const c=[...a.get(u)||[]];for(;c.length;){const l=c.pop();r.has(l)||s.has(l)||(s.add(l),c.push(...a.get(l)||[]))}}return{nodes:e.filter(u=>!s.has(u.data.id)).map(u=>{var c;return r.has(u.data.id)&&o.has(u.data.id)?{...u,data:{...u.data,type:"arrayView",label:u.data.label??u.data.headerTitle,config:{...u.data.config,parentContainer:!0,labelBelow:!0,icon:((c=u.data.config)==null?void 0:c.icon)||"PiStack"}}}:u}),edges:t.flatMap(u=>{const c=i.get(u.data.source)??u.data.source,l=i.get(u.data.target)??u.data.target;return s.has(c)||s.has(l)?[]:c===u.data.source&&l===u.data.target?[u]:c===l?[]:[{...u,data:{...u.data,source:c,target:l,collapsedEndpoints:u.data.collapsedEndpoints??{source:u.data.source,target:u.data.target}}}]})}}function Tu(e,t){const r=JSON.parse(e);let n=512;const o=(a,s=[])=>{if(--n<0)throw new Error("Interface exceeds the 512-type expansion limit.");if(!a||typeof a!="object"||Array.isArray(a))throw new Error("Expected a JSON Schema object.");const u=new Set(["$schema","$id","$defs","definitions","$ref","title","description","default","examples","type","properties","required","items","enum","const","anyOf","additionalProperties"]);for(const l of Object.keys(a))if(!u.has(l))throw new Error(`Unsupported JSON Schema keyword: ${l}`);const c=["$schema","$id","$defs","definitions","title","description","default","examples"];if(a.$ref){if(Object.keys(a).some(d=>!["$ref","title","description"].includes(d)))throw new Error("Use $ref without sibling constraints.");if(typeof a.$ref!="string"||!a.$ref.startsWith("#/")||s.includes(a.$ref))throw new Error("Only nonrecursive local $ref references are supported.");let l=r;for(const d of a.$ref.slice(2).split("/")){const f=d.replace(/~1/g,"/").replace(/~0/g,"~");if(!l||!Object.prototype.hasOwnProperty.call(l,f))throw new Error(`Unresolved reference: ${a.$ref}`);l=l[f]}return o(l,[...s,a.$ref])}if(a.anyOf){if(!Array.isArray(a.anyOf)||!a.anyOf.length||Object.keys(a).some(l=>l!=="anyOf"&&!c.includes(l)))throw new Error("Use a nonempty anyOf without sibling type constraints.");return{kind:"union",types:a.anyOf.map(l=>o(l,s))}}if(Object.prototype.hasOwnProperty.call(a,"const")||a.enum){if(Object.keys(a).some(f=>![...c,"const","enum","type"].includes(f))||a.enum&&Object.prototype.hasOwnProperty.call(a,"const"))throw new Error("Use enum or const without sibling constraints other than type.");const l=Object.prototype.hasOwnProperty.call(a,"const")?[a.const]:a.enum;if(!Array.isArray(l)||!l.length)throw new Error("Expected a nonempty enum.");return{kind:"union",types:l.map(f=>{if(f!==null&&!["string","number","boolean"].includes(typeof f))throw new Error("Only primitive literals are supported.");const p=f===null?"null":typeof f;if(a.type&&!(Array.isArray(a.type)?a.type:[a.type]).some(m=>m===p||m==="integer"&&Number.isInteger(f)))throw new Error("Literal does not match its declared type.");return{kind:"literal",value:f}})}}if(Array.isArray(a.type)){if(!a.type.length||a.type.some(l=>typeof l!="string"))throw new Error("Expected a nonempty list of primitive types.");if(Object.keys(a).some(l=>l!=="type"&&!c.includes(l)))throw new Error("Use anyOf for unions with object or array constraints.");return{kind:"union",types:a.type.map(l=>o({type:l},s))}}if((a.properties||a.required||a.additionalProperties!==void 0)&&a.type!=="object"&&a.type!==void 0)throw new Error("Object constraints require an object type.");if(a.items&&a.type!=="array")throw new Error("items requires an array type.");if(a.type==="object"||a.properties){if(a.additionalProperties!==void 0&&a.additionalProperties!==!0)throw new Error("Closed objects and typed additionalProperties are not supported.");if(!a.properties||typeof a.properties!="object"||Array.isArray(a.properties))throw new Error("Object schemas must declare properties.");if(a.required!==void 0&&(!Array.isArray(a.required)||a.required.some(d=>typeof d!="string"||!Object.prototype.hasOwnProperty.call(a.properties,d))))throw new Error("required must list declared property names.");return{kind:"object",properties:Object.fromEntries(Object.entries(a.properties).map(([d,f])=>[d,{type:o(f,s),optional:!(a.required??[]).includes(d)}]))}}if(a.type==="array")return{kind:"array",items:o(a.items,s)};if(["string","number","integer","boolean","null"].includes(a.type))return{kind:a.type};throw new Error("Every property must declare a supported type.")},i=o(r);if(i.kind!=="object")throw new Error("The root schema must be an object keyed by node ID.");if(Object.values(i.properties).some(a=>a.type.kind!=="object"))throw new Error("Each node must declare an object of property types.");return{name:t,nodes:i.properties}}async function Ou(e,t,r,n={}){var m;let o=512;const i=await import("typescript"),a=i.createSourceFile(t,e,i.ScriptTarget.Latest,!0,i.ScriptKind.TS),s=a.parseDiagnostics;if(s!=null&&s.length)throw new Error("Invalid TypeScript syntax.");const u=new Map;for(const y of a.statements){if(!i.isInterfaceDeclaration(y)&&!i.isTypeAliasDeclaration(y))throw new Error("Upload interfaces/type aliases only; imports and executable code are not supported.");if((m=y.typeParameters)!=null&&m.length||u.has(y.name.text))throw new Error("Generics and duplicate declarations are not supported.");u.set(y.name.text,y)}const c=(y,b)=>{var _;const v={},g=y.find(C=>i.isIndexSignatureDeclaration(C));let w;if(g&&n.allowJson&&i.isIndexSignatureDeclaration(g)){if(y.filter(C=>i.isIndexSignatureDeclaration(C)).length!==1||g.parameters.length!==1||((_=g.parameters[0].type)==null?void 0:_.kind)!==i.SyntaxKind.StringKeyword||!g.type)throw new Error("Only one string-keyed index signature is supported for forms.");w=d(g.type,b)}return{kind:"object",properties:Object.fromEntries(y.filter(C=>C!==g||!w).map(C=>{if(!i.isPropertySignature(C)||!C.type||!C.name||!i.isIdentifier(C.name)&&!i.isStringLiteral(C.name))throw new Error("Only explicitly typed named properties are supported.");const S=d(C.type,b),T=n.allowJson?i.getJSDocTags(C).filter(k=>k.tagName.text==="port"):[];if(T.length>1)throw new Error(`Duplicate port declaration: ${C.name.text}`);if(T.length){const[k,E,P]=String(T[0].comment??"").trim().split(/\s+/);if(k!=="config"||!E||P||!u.has(E))throw new Error(`Config port ${C.name.text} requires @port config ResourceType`);const R=S.kind==="array";if((S.kind==="array"?S.items.kind:S.kind)!=="string")throw new Error(`Config port ${C.name.text} must be a string or string array reference`);v[C.name.text]={kind:"config",resourceType:E,multiple:R}}return[C.name.text,{type:S,optional:!!C.questionToken}]})),...w?{additionalProperties:w}:{},...Object.keys(v).length?{ports:v}:{}}},l=(y,b)=>{var _;if(b.includes(y))throw new Error("Recursive types are not supported.");const v=u.get(y);if(!v)throw new Error(`Unknown type: ${y}`);let g;if(i.isInterfaceDeclaration(v)){if((_=v.heritageClauses)!=null&&_.length)throw new Error("Interface inheritance is not supported; declare properties explicitly.");g=c(v.members,[...b,y])}else g=d(v.type,[...b,y]);const w=n.allowJson?i.getJSDocTags(v).filter(C=>C.tagName.text==="port"):[];if(!w.length)return g;if(g.kind!=="object")throw new Error("Node ports require an object interface");const x={...g.ports};for(const C of w){const[S,T,k]=String(C.comment??"").trim().split(/\s+/);if(!["input","output","error"].includes(S)||!/^[A-Za-z][\w-]*$/.test(T??"")||k)throw new Error("Node ports require @port input|output|error Name");if(Object.prototype.hasOwnProperty.call(x,T))throw new Error(`Duplicate port declaration: ${T}`);x[T]={kind:S}}return{...g,ports:x}},d=(y,b)=>{var v,g,w;if(--o<0)throw new Error("Interface exceeds the 512-type expansion limit.");if(y.kind===i.SyntaxKind.StringKeyword)return{kind:"string"};if(y.kind===i.SyntaxKind.NumberKeyword)return{kind:"number"};if(y.kind===i.SyntaxKind.BooleanKeyword)return{kind:"boolean"};if(n.allowJson&&[i.SyntaxKind.AnyKeyword,i.SyntaxKind.UnknownKeyword].includes(y.kind))return{kind:"json"};if(i.isParenthesizedTypeNode(y))return d(y.type,b);if(i.isUnionTypeNode(y))return{kind:"union",types:y.types.map(x=>d(x,b))};if(i.isArrayTypeNode(y))return{kind:"array",items:d(y.elementType,b)};if(i.isTypeLiteralNode(y))return c(y.members,b);if(i.isLiteralTypeNode(y)){const x=y.literal;if(i.isStringLiteral(x))return{kind:"literal",value:x.text};if(i.isNumericLiteral(x))return{kind:"literal",value:Number(x.text)};if(x.kind===i.SyntaxKind.NullKeyword)return{kind:"null"};if(x.kind===i.SyntaxKind.TrueKeyword||x.kind===i.SyntaxKind.FalseKeyword)return{kind:"literal",value:x.kind===i.SyntaxKind.TrueKeyword}}if(i.isTypeReferenceNode(y)&&i.isIdentifier(y.typeName)){if(n.allowJson&&y.typeName.text==="Record"&&!u.has("Record")&&((v=y.typeArguments)==null?void 0:v.length)===2&&y.typeArguments[0].kind===i.SyntaxKind.StringKeyword)return{kind:"object",properties:{},additionalProperties:d(y.typeArguments[1],b)};if(y.typeName.text==="Array"&&((g=y.typeArguments)==null?void 0:g.length)===1)return{kind:"array",items:d(y.typeArguments[0],b)};if(!((w=y.typeArguments)!=null&&w.length))return l(y.typeName.text,b)}throw new Error(`Unsupported TypeScript type: ${y.getText(a)}`)},f=r??(u.has("Graph")?"Graph":u.size===1?[...u.keys()][0]:void 0);if(!f)throw new Error("Declare an interface Graph keyed by node ID.");const p=l(f,[]);if(p.kind!=="object")throw new Error("Graph must be an object keyed by node ID.");return p}async function em(e,t){const r=await Ou(e,t);if(Object.values(r.properties).some(n=>n.type.kind!=="object"))throw new Error("Each node must declare an object of property types.");return{name:t,nodes:r.properties}}function jt(e,t){if(e.kind==="json"||t.kind==="json"||e.kind==="object"&&e.additionalProperties||t.kind==="object"&&t.additionalProperties)return!1;if(e.kind==="union")return e.types.every(r=>jt(r,t));if(t.kind==="union")return t.types.some(r=>jt(e,r));if(e.kind==="literal"){if(t.kind==="literal")return e.value===t.value;const r=e.value===null?"null":typeof e.value;return t.kind===r||t.kind==="integer"&&typeof e.value=="number"&&Number.isInteger(e.value)}return e.kind==="integer"&&t.kind==="number"?!0:e.kind==="array"&&t.kind==="array"?jt(e.items,t.items):e.kind==="object"&&t.kind==="object"?Object.entries(t.properties).every(([r,n])=>{const o=Object.prototype.hasOwnProperty.call(e.properties,r)?e.properties[r]:void 0;return o?(n.optional||!o.optional)&&jt(o.type,n.type):n.optional}):e.kind===t.kind}function Iu(e,t){if(!t.sourceProperty&&!t.targetProperty)return;const r=(a,s)=>{var l;const u=Object.prototype.hasOwnProperty.call(e.nodes,a)?a:a.replace(/^root\./,""),c=Object.prototype.hasOwnProperty.call(e.nodes,u)?(l=e.nodes[u])==null?void 0:l.type:void 0;return s&&(c==null?void 0:c.kind)==="object"&&Object.prototype.hasOwnProperty.call(c.properties,s)?c.properties[s]:void 0},n=r(t.source,t.sourceProperty),o=r(t.target,t.targetProperty);if(!n||!o)return"Unverified: source or target property is missing from the interface.";const i=a=>a.kind==="json"||a.kind==="object"&&(!!a.additionalProperties||Object.values(a.properties).some(s=>i(s.type)))||a.kind==="array"&&i(a.items)||a.kind==="union"&&a.types.some(i);if(i(n.type)||i(o.type))return"Unverified: arbitrary JSON or dictionary fields require runtime validation.";if(n.optional&&!o.optional)return"Optional source cannot supply a required target property.";if(!jt(n.type,o.type))return`Incompatible property types: ${t.sourceProperty} -> ${t.targetProperty}.`}async function rm(e){if(e.size>256*1024)throw new Error("Interface must be 256 KB or smaller.");const t=await e.text();if(/\.json$/i.test(e.name))return Tu(t,e.name);if(/\.ts$/i.test(e.name))return em(t,e.name);throw new Error("Choose a .ts interface or .json JSON Schema file.")}const _l=new WeakMap;function Wt(e){if(!e||typeof e!="object")return e;const t=_l.get(e);if(t)return t;const r=()=>{throw new Error("Form callback data is read-only. Return edits instead.")},n=new Proxy(Array.isArray(e)?[]:{},{get:(o,i)=>Wt(Reflect.get(e,i)),has:(o,i)=>Reflect.has(e,i),ownKeys:()=>Reflect.ownKeys(e),getOwnPropertyDescriptor:(o,i)=>{const a=Reflect.getOwnPropertyDescriptor(e,i);return a&&{...a,value:Wt(Reflect.get(e,i)),configurable:i!=="length"||!Array.isArray(e)}},set:r,deleteProperty:r,defineProperty:r,setPrototypeOf:r,preventExtensions:r});return _l.set(e,n),n}function gt(e,t,r){var o;const n=t.split(".");for(let i=n.length;i>0;i--){const a=n.slice(0,i).join("."),s=(o=xe(e,a))==null?void 0:o.$form;if(!(s!=null&&s.$type))continue;let u=Object.prototype.hasOwnProperty.call(r,s.$type)?r[s.$type]:void 0;for(const d of n.slice(i))(u==null?void 0:u.kind)==="array"&&/^\d+$/.test(d)?u=u.items:(u==null?void 0:u.kind)==="object"?u=Object.prototype.hasOwnProperty.call(u.properties,d)?u.properties[d].type:void 0:u=void 0;if((u==null?void 0:u.kind)!=="object")return;const c=n.slice(i).join("."),l=Object.fromEntries(Object.entries(s.$fields??{}).filter(([d])=>!c||d.startsWith(`${c}.`)).map(([d,f])=>[c?d.slice(c.length+1):d,f]));return{type:u,fields:l,binding:s}}}async function Mu(e,t){if(e.size>256*1024)throw new Error("Form schema exceeds 256 KB.");const r=await e.text();if(e.name.endsWith(".ts")){if(!t.length||t.length>32)throw new Error("Choose between 1 and 32 form interface names.");const o=[],i=new Set(t);for(const a of i){if(i.size>32)throw new Error("Choose between 1 and 32 form interface names.");const s=await Ou(r,e.name,a,{allowJson:!0});o.push([a,s]);for(const u of Object.values(s.ports??{}))u.resourceType&&i.add(u.resourceType)}return Object.fromEntries(o)}if(!e.name.endsWith(".json"))throw new Error("Choose a .ts interface or .json schema file.");const n=Tu(r,e.name);return Object.fromEntries(Object.entries(n.nodes).map(([o,i])=>[o,i.type]))}function xn(e,t){return!e||("$in"in e?e.$in.includes(xe(t,e.$address)):xe(t,e.$address)===e.$equals)}function $t(e){const t=e.kind==="array"?e.items:e,r=t.kind==="union"?t.types:[t];if(r.every(n=>n.kind==="literal"))return r.map(n=>({label:String(n.value),value:n.value}))}function Rr(e,t,r){if(t===void 0||t==="")return r?"Required":void 0;if(e.kind==="json"){const n=new Set,o=i=>{if(i===null||typeof i=="string"||typeof i=="boolean")return!0;if(typeof i=="number")return Number.isFinite(i);if(!i||typeof i!="object"||n.has(i)||!Array.isArray(i)&&![Object.prototype,null].includes(Object.getPrototypeOf(i)))return!1;n.add(i);const a=Object.values(i).every(o);return n.delete(i),a};return o(t)?void 0:"Expected a JSON value"}if(e.kind==="union")return e.types.some(n=>!Rr(n,t,!0))?void 0:"Choose a valid value";if(e.kind==="literal")return t===e.value?void 0:"Choose a valid value";if(e.kind==="array")return Array.isArray(t)&&t.every(n=>!Rr(e.items,n,!0))?void 0:"Invalid list value";if(e.kind==="object")return!t||typeof t!="object"||Array.isArray(t)?"Expected an object":e.additionalProperties&&Object.entries(t).some(([n,o])=>!Object.prototype.hasOwnProperty.call(e.properties,n)&&Rr(e.additionalProperties,o,!0))?"Invalid dictionary value":Object.entries(e.properties).some(([n,o])=>Rr(o.type,t[n],!o.optional))?"Invalid object fields":void 0;if(e.kind==="null")return t===null?void 0:"Expected null";if(e.kind==="integer")return Number.isInteger(t)?void 0:"Expected a whole number";if(typeof t!==e.kind||typeof t=="number"&&!Number.isFinite(t))return`Expected ${e.kind}`}function Sl(e,t){const r=t.address.split(".");if(r.shift()!=="root"||!r.length||r.some(s=>!s||["__proto__","prototype","constructor","#"].includes(s)))throw new Error("Invalid form field address.");const n=r.pop(),o=n==="$bgColor"||n==="$textColor"||n==="$borderColor";if(r.some(s=>s.startsWith("$"))||n.startsWith("$")&&!o)throw new Error("Unsupported form metadata address.");const i=["root",...r].join("."),a=xe(e,i);if(!a||typeof a!="object")throw new Error(`Missing form parent: ${i}`);if(o){if(t.op==="set"&&typeof t.value!="string")throw new Error("Node colors must be strings.");return ir(e,i,n,t.op==="remove"?void 0:t.value)}return pr(e,i,s=>{const u=Array.isArray(s.$)?s.$:s;if(t.op==="remove"&&!Object.prototype.hasOwnProperty.call(u,n)||t.op==="set"&&Object.is(u[n],t.value))return s;const c=Array.isArray(u)?[...u]:{...u};if(Array.isArray(c)&&(!/^(0|[1-9]\d*)$/.test(n)||Number(n)>=c.length))throw new Error("Invalid array address.");return t.op==="remove"?Array.isArray(c)?c.splice(Number(n),1):delete c[n]:Object.defineProperty(c,n,{value:structuredClone(t.value),enumerable:!0,writable:!0,configurable:!0}),u===s?c:{...s,$:c}})}function wn(e,t,r){let n=Sl(e,t.value===void 0?{op:"remove",address:t.address}:{op:"set",address:t.address,value:t.value});const o=r==null?void 0:r({...t,previousValue:Wt(xe(e,t.address)),data:Wt(n)});if(o&&!Array.isArray(o))throw new Error("Form change handlers must return edits synchronously.");for(const i of Array.isArray(o)?o:[]){if(i.op!=="set"&&i.op!=="remove")throw new Error("Unsupported form edit.");n=Sl(n,i)}return n}function Jx(e,t){let r=e;for(const n of t){if(n.op!=="set"&&n.op!=="remove")throw new Error("Unsupported state edit.");const o=n.address.split(".");if(o.some(a=>a.startsWith("$")||["__proto__","prototype","constructor"].includes(a)))throw new Error("State edits cannot target view metadata or unsafe keys.");const i=n.op==="remove"?void 0:n.value;Gt(i),r=wn(r,{address:n.address,nodeAddress:o.slice(0,-1).join("."),value:i})}return Gt(r),r}function Yt(e,t,r){const n=Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;if(!(!n||!r||!Object.prototype.hasOwnProperty.call(r,n.type)))return{address:n.address,type:r[n.type],fields:n.fields??{}}}function Gt(e){if(!(!e||typeof e!="object"))for(const[t,r]of Object.entries(e)){if(t.startsWith("$")||["__proto__","prototype","constructor"].includes(t))throw new Error(`Form state cannot contain view metadata or unsafe keys: ${t}`);Gt(r)}}function Yx(e,t,r){Gt(t.value);const n=wn(e,t,r);return Gt(n),n}function tm(e,t){const r=(n,o="")=>{if(!n||typeof n!="object")return n;if(["$label","$subtitle","$content","$icon","$bgColor","$textColor","$borderColor"].includes(o)&&typeof n.$state=="string"){const a=xe(t,n.$state);return a==null?"":typeof a=="object"?JSON.stringify(a,null,2):String(a)}let i=n;for(const[a,s]of Object.entries(n)){const u=r(s,a);u!==s&&(i===n&&(i=Array.isArray(n)?[...n]:{...n}),Object.defineProperty(i,a,{value:u,enumerable:!0,writable:!0,configurable:!0}))}return i};return r(e)}const Yr=(e="reference")=>({kind:e,text:"",paths:[""]}),nm=e=>/^[A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*|\.\d+)+$/.test(e)&&!e.split(".").some(t=>["__proto__","constructor","prototype"].includes(t));function Xx(e,t){const r=new Set(t.map(a=>a.path)),n=a=>{if(!a.paths.length||a.paths.some(s=>!nm(s)||!r.has(s)))throw new Error("Choose an available reference.");return[...a.paths,...a.fallback===void 0?[]:[JSON.stringify(a.fallback)]].join(" || ")},o=a=>{if(a.includes("{{")||a.includes("}}"))throw new Error("Use a reference part for dynamic values.");return a},i=a=>a.map(s=>{if(s.kind==="text")return o(s.text);if(s.kind==="conditional"){if(s.paths.length!==1||s.fallback!==void 0)throw new Error("Choose one condition reference.");return`{{#if ${n(s)}}}${o(s.text)}{{/if}}`}return`{{${n(s)}}}`}).join("");if(e.mode==="reference"||e.mode==="condition"){if(e.parts.length!==1||e.parts[0].kind!=="reference")throw new Error("Choose one reference binding.");const a=i(e.parts);return e.mode==="condition"?`${a} == ${JSON.stringify(e.comparison)}`:a}if(e.mode==="json"){const a=e.fields.map(s=>s.key);if(!a.length||new Set(a).size!==a.length||a.some(s=>!s||["__proto__","constructor","prototype"].includes(s)))throw new Error("Output field names must be unique and nonempty.");return JSON.stringify(Object.fromEntries(e.fields.map(s=>[s.key,i(s.parts)])))}return i(e.parts)}async function Qx(e){const t=await import("typescript"),r=a=>{const s=t.createSourceFile("binding.ts",`(${a})`,t.ScriptTarget.Latest,!0,t.ScriptKind.TS);if(s.parseDiagnostics.length)throw new Error("Unsupported reference expression.");const u=s.statements[0];if(!u||!t.isExpressionStatement(u))throw new Error("Unsupported reference expression.");const c=Yr();c.paths=[];const l=d=>{if(t.isParenthesizedExpression(d))return l(d.expression);if(t.isBinaryExpression(d)&&d.operatorToken.kind===t.SyntaxKind.BarBarToken){l(d.left),l(d.right);return}if(t.isStringLiteral(d)){if(c.fallback!==void 0)throw new Error("Multiple fallback values.");c.fallback=d.text;return}const f=d.getText(s);if(!nm(f)||c.fallback!==void 0)throw new Error("Unsupported reference expression.");c.paths.push(f)};if(l(u.expression),!c.paths.length)throw new Error("A binding needs a reference.");return c},n=a=>{const s=[];let u=0;const c=/\{\{([\s\S]*?)\}\}/g;for(const l of a.matchAll(c)){const d=l.index;if(d<u)continue;d>u&&s.push({...Yr("text"),text:a.slice(u,d)});const f=l[1].trim();if(f.startsWith("#if ")){const p=a.indexOf("{{/if}}",d+l[0].length);if(p<0)throw new Error("Unclosed condition.");s.push({...r(f.slice(4)),kind:"conditional",text:a.slice(d+l[0].length,p)}),u=p+7}else s.push(r(f)),u=d+l[0].length}return u<a.length&&s.push({...Yr("text"),text:a.slice(u)}),s},o={mode:"reference",parts:[Yr()],comparison:"",fields:[]};if(!e)return o;if(e.trim().startsWith("{"))try{const a=JSON.parse(e);if(a&&typeof a=="object"&&!Array.isArray(a)&&Object.values(a).every(s=>typeof s=="string"))return{...o,mode:"json",fields:Object.entries(a).map(([s,u])=>({key:s,parts:n(u)}))}}catch{}const i=n(e);if(i.length===2&&i[0].kind==="reference"&&i[1].kind==="text"){const a=t.createSourceFile("condition.ts",`value ${i[1].text}`,t.ScriptTarget.Latest,!0,t.ScriptKind.TS),s=a.statements[0];if(a.statements.length===1&&t.isExpressionStatement(s)&&t.isBinaryExpression(s.expression)&&s.expression.operatorToken.kind===t.SyntaxKind.EqualsEqualsToken&&t.isStringLiteral(s.expression.right))return{...o,mode:"condition",parts:[i[0]],comparison:s.expression.right.text}}return{...o,mode:i.length===1&&i[0].kind==="reference"?"reference":"template",parts:i}}function El({parts:e,references:t,onChange:r,disabled:n}){const o=(i,a)=>r(e.map((s,u)=>u===i?{...s,...a}:s));return h.jsxs("div",{style:{display:"grid",gap:12},children:[e.map((i,a)=>h.jsxs("fieldset",{"data-binding-part":a,style:{border:0,padding:0,margin:0,minWidth:0},children:[h.jsxs("legend",{children:["Part ",a+1]}),h.jsxs("div",{style:{display:"flex",gap:8},children:[h.jsxs("span",{"data-form-select":"",style:{flex:1},children:[h.jsxs("select",{"aria-label":"Part type",disabled:n,value:i.kind,onChange:s=>o(a,{kind:s.target.value}),children:[h.jsx("option",{value:"reference",children:"Reference"}),h.jsx("option",{value:"text",children:"Text"}),h.jsx("option",{value:"conditional",children:"Conditional text"})]}),h.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]}),h.jsx(ve,{"aria-label":`Remove part ${a+1}`,title:"Remove part",icon:h.jsx(Z.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>r(e.filter((s,u)=>u!==a))})]}),i.kind!=="text"&&h.jsxs(h.Fragment,{children:[i.paths.map((s,u)=>h.jsxs("label",{children:["Reference ",u+1,h.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[h.jsxs("select",{"aria-label":`Reference ${u+1}`,disabled:n,value:s,onChange:c=>o(a,{paths:i.paths.map((l,d)=>d===u?c.target.value:l)}),children:[h.jsx("option",{value:"",children:"Select reference"}),t.map(c=>h.jsx("option",{value:c.path,children:c.label},c.path))]}),h.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]})]},u)),i.kind==="reference"&&h.jsxs(h.Fragment,{children:[h.jsx(ve,{"aria-label":"Add fallback reference",title:"Add fallback reference",icon:h.jsx(Z.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>o(a,{paths:[...i.paths,""]})}),h.jsxs("label",{style:{display:"flex",gap:8,alignItems:"center"},children:[h.jsx("input",{type:"checkbox","aria-label":"Default value enabled",disabled:n,checked:i.fallback!==void 0,onChange:s=>o(a,{fallback:s.target.checked?"":void 0})}),"Default value"]}),i.fallback!==void 0&&h.jsx("input",{"aria-label":"Default value",disabled:n,value:i.fallback,onChange:s=>o(a,{fallback:s.target.value})})]})]}),i.kind!=="reference"&&h.jsxs("label",{children:["Text",h.jsx("textarea",{"aria-label":"Part text",disabled:n,value:i.text,onChange:s=>o(a,{text:s.target.value})})]})]},a)),h.jsx(ve,{"aria-label":"Add part",title:"Add part",icon:h.jsx(Z.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>r([...e,Yr()])})]})}function e0({label:e,value:t,references:r,disabled:n,onChange:o}){const[i,a]=j.useState(),[s,u]=j.useState(""),[c,l]=j.useState(!1),d=async()=>{l(!0),u("");try{a(await Qx(typeof t=="string"?t:""))}catch(f){u(f instanceof Error?f.message:"Unable to read binding.")}finally{l(!1)}};return h.jsxs("div",{"data-runtime-binding":e,style:{marginBottom:8},children:[h.jsx(ve,{"aria-label":`Bind ${e}`,title:`Bind ${e}`,icon:h.jsx(Z.PiLink,{size:18}),size:"sm",variant:"ghost",disabled:n||c,onClick:d}),typeof t=="string"&&t.includes("{{")&&h.jsx("span",{children:"Bound value"}),i&&h.jsxs("fieldset",{disabled:n,style:{border:0,margin:0,padding:"8px 0",minWidth:0},children:[h.jsxs("label",{children:["Binding mode",h.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[h.jsxs("select",{"aria-label":"Binding mode",value:i.mode,onChange:f=>a({...i,mode:f.target.value,parts:[Yr()]}),children:[h.jsx("option",{value:"reference",children:"Reference"}),h.jsx("option",{value:"condition",children:"Equals"}),h.jsx("option",{value:"template",children:"Text template"}),h.jsx("option",{value:"json",children:"JSON output"})]}),h.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]})]}),i.mode==="json"?h.jsxs(h.Fragment,{children:[i.fields.map((f,p)=>h.jsxs("fieldset",{"data-output-field":p,style:{border:0,margin:0,padding:"8px 0",minWidth:0},children:[h.jsxs("label",{children:["Output field name",h.jsx("input",{"aria-label":"Output field name",value:f.key,onChange:m=>a({...i,fields:i.fields.map((y,b)=>b===p?{...y,key:m.target.value}:y)})})]}),h.jsx(El,{parts:f.parts,references:r,disabled:n,onChange:m=>a({...i,fields:i.fields.map((y,b)=>b===p?{...y,parts:m}:y)})}),h.jsx(ve,{"aria-label":"Remove output field",title:"Remove output field",icon:h.jsx(Z.PiTrash,{size:18}),size:"sm",variant:"ghost",onClick:()=>a({...i,fields:i.fields.filter((m,y)=>y!==p)})})]},p)),h.jsx(ve,{"aria-label":"Add output field",title:"Add output field",icon:h.jsx(Z.PiPlus,{size:18}),size:"sm",variant:"ghost",onClick:()=>a({...i,fields:[...i.fields,{key:"",parts:[Yr()]}]})})]}):h.jsx(El,{parts:i.parts,references:r,disabled:n,onChange:f=>a({...i,parts:f})}),i.mode==="condition"&&h.jsxs("label",{children:["Equals",h.jsx("input",{"aria-label":"Comparison value",value:i.comparison,onChange:f=>a({...i,comparison:f.target.value})})]}),h.jsxs("div",{style:{display:"flex",gap:8,marginTop:12},children:[h.jsx(ve,{"aria-label":"Apply binding",title:"Apply binding",icon:h.jsx(Z.PiCheck,{size:20}),size:"sm",variant:"ghost",onClick:()=>{try{o(Xx(i,r)),a(void 0),u("")}catch(f){u(f instanceof Error?f.message:"Unable to apply binding.")}}}),h.jsx(ve,{"aria-label":"Cancel binding",title:"Cancel binding",icon:h.jsx(Z.PiX,{size:20}),size:"sm",variant:"ghost",onClick:()=>{a(void 0),u("")}})]})]}),s&&h.jsx("p",{role:"alert",children:s})]})}const r0=e=>!!e&&!e.includes(".")&&!e.startsWith("$")&&!["__proto__","constructor","prototype"].includes(e),t0=e=>`root.__form_${encodeURIComponent(e).replace(/\./g,"%2E")}`,Rt=(e,t)=>JSON.stringify([e,t]);function Ut(e,t){if(e.kind==="union"){const r=e.types.find(n=>n.kind===(Array.isArray(t)?"array":t===null?"null":typeof t)||n.kind==="literal"&&Object.is(n.value,t));return Ut(r??e.types.find(n=>n.kind!=="null")??e.types[0]??{kind:"json"},t)}return e.kind!=="json"?e:Array.isArray(t)?{kind:"array",items:{kind:"json"}}:t!==null&&typeof t=="object"||t===void 0?{kind:"object",properties:{},additionalProperties:{kind:"json"}}:{kind:t===null?"null":typeof t}}function kt(e){const t=Ut(e,void 0);return t.kind==="object"?{}:t.kind==="array"?[]:t.kind==="literal"?t.value:t.kind==="number"||t.kind==="integer"?0:t.kind==="boolean"?!1:t.kind==="null"?null:""}function jl(e){return e.kind==="json"?[{kind:"string"},{kind:"number"},{kind:"boolean"},{kind:"null"},{kind:"object",properties:{},additionalProperties:{kind:"json"}},{kind:"array",items:{kind:"json"}}]:e.kind==="union"&&!$t(e)?e.types:[e]}function n0(e,t,r){if(t.address===r.address)return;const n=xe(e,t.address),o=(i,a)=>a===void 0?!1:i.kind==="union"?i.types.some(s=>o(s,a)):i.kind==="array"?Array.isArray(a)&&a.every(s=>o(i.items,s)):i.kind==="object"?!!a&&typeof a=="object"&&!Array.isArray(a)&&Object.entries(i.properties).every(([s,u])=>u.optional&&a[s]===void 0||o(u.type,a[s]))&&Object.entries(a).every(([s,u])=>Object.prototype.hasOwnProperty.call(i.properties,s)||!i.additionalProperties||o(i.additionalProperties,u)):a===""?i.kind==="string"||i.kind==="json"||i.kind==="literal"&&i.value==="":!Rr(i,a,!0);if(o(r.type,n))return structuredClone(n)}function o0(e,t,r,n){var u;const o={sourceSchema:r,sourceBindings:t,nodes:[],edges:[],schema:{...r},bindings:{...t},slots:new Map,containers:new Map},i=new Set(n.map(c=>c.data.id)),a=new Map(n.flatMap(c=>{const l=t[c.data.id];return l&&r[l.type]?[[l.address,c.data.id]]:[]})),s=(c,l,d,f,p,m=!1)=>{var C,S,T;if(p>24||o.containers.size>512)throw new Error("Structured form exceeds the flow node limit.");const y=xe(e,l),b=Ut(d,y),v=b.kind!=="object"&&b.kind!=="array";o.containers.set(c,{address:l,type:b,declared:d,scalar:v});const g=`__form:${c}`,w={...(C=o.bindings[c])==null?void 0:C.fields},x={kind:"object",properties:{},ports:{...b.kind==="object"?b.ports:{},...m?{resource:{kind:"output"}}:{}}},_=b.kind==="object"?{...b.properties,...Object.fromEntries(Object.keys(y??{}).filter(k=>!Object.prototype.hasOwnProperty.call(b.properties,k)&&b.additionalProperties).map(k=>[k,{type:b.additionalProperties,optional:!0}]))}:b.kind==="array"?Object.fromEntries((Array.isArray(y)?y:[]).map((k,E)=>[String(E),{type:b.items,optional:!0}])):{value:{type:$t(d)?d:b,optional:!1}};for(const[k,E]of Object.entries(_)){if(!r0(k))throw new Error(`Unsupported structured property key: ${k}`);const P=v?l:`${l}.${k}`,R=xe(e,P),I=Ut(E.type,R),O=I.kind==="object"||I.kind==="array",M=(S=x.ports)==null?void 0:S[k],q=(M==null?void 0:M.kind)==="config"&&(((T=w[k])==null?void 0:T.$options)||$t(E.type)),K=E.type.kind==="json"||E.type.kind==="union"&&!$t(E.type);if(!O&&b.kind!=="array"&&(!K||v)||q){x.properties[k]={...E,type:E.type.kind==="json"?I:E.type};continue}const V=a.get(P)??t0(P),re=b.kind==="array"?`Item ${Number(k)+1}`:k,ce={address:P,owner:c,field:k,type:E.type,label:re,nodeId:V,present:R!==void 0};if(o.slots.set(Rt(c,k),ce),x.ports[k]={kind:"config",resourceType:`__form:${V}`},R===void 0||(o.edges.push({data:{id:`__form-edge:${c}:${k}`,source:V,target:c,sourceProperty:"output:resource",targetProperty:`config:${k}`,isEdgeDashed:!0}}),o.containers.has(V)||a.has(P)))continue;if(i.has(V))throw new Error(`Structured node identity conflict: ${V}`);i.add(V);const he={data:{id:V,type:"objectView",label:re,headerTitle:re,description:{},config:{form:!0,icon:I.kind==="array"?"PiListNumbers":O?"PiBracketsCurly":"PiTextT"},viewProps:{bgColor:f}}};o.nodes.push(he),s(V,P,E.type,f,p+1,!0);const me=o.schema[`__form:${V}`];he.data.description=Object.fromEntries(Object.keys(me.properties).map(H=>[H,xe(e,I.kind==="array"||I.kind==="object"?`${P}.${H}`:P)]).filter(([,H])=>H!==void 0))}o.schema[g]=x,o.bindings[c]={...o.bindings[c],address:l,type:g,fields:w}};for(const c of n){const l=t[c.data.id],d=l&&r[l.type];!l||!d||xe(e,l.address)===void 0||s(c.data.id,l.address,d,(u=c.data.viewProps)==null?void 0:u.bgColor,0,o.edges.some(f=>f.data.source===c.data.id))}for(const c of o.edges){const l=o.bindings[c.data.source];o.schema[l.type].ports.resource={kind:"output"}}return o}function i0({nodeAddress:e}){const{structured:t,data:r,callbacks:n,editable:o}=j.useContext(kr),i=Ie(),[a,s]=j.useState(""),[u,c]=j.useState("0"),[l,d]=j.useState(""),f=t==null?void 0:t.containers.get(e);if(!f||!r||!t)return null;const p=i.readOnly||i.config.editable===!1||!o,m=xe(r,f.address),y=jl(f.declared),b=f.type.kind==="array"?f.type.items:f.type.kind==="object"?f.type.additionalProperties:void 0,v=b?jl(b):[],g=E=>E.kind==="literal"?String(E.value):E.kind==="string"?"Text":Cr(E.kind),w=[...t.slots.values()].filter(E=>E.owner===e),x=(E,P)=>{var R;return(R=n.onFormChange)==null?void 0:R.call(n,{data:r,nodeAddress:f.address,address:E,previousValue:xe(r,E),value:P})},_=E=>{var P;i.setSelectedNodeIds([E]),(P=i.engineRef.current)==null||P.focusNode(E,90,!1)},C=(E,P)=>{if(!Array.isArray(m))return;const R=[...m];[R[E],R[E+P]]=[R[E+P],R[E]],x(f.address,R)},S=()=>{const E=v[Number(u)]??v[0];if(E)if(f.type.kind==="array")x(f.address,[...Array.isArray(m)?m:[],kt(E)]);else{if(!a||a.includes(".")||a.startsWith("$")||["__proto__","constructor","prototype"].includes(a)){d("Choose a property name without dots or reserved prefixes.");return}if(Object.prototype.hasOwnProperty.call(m,a)){d("Property already exists.");return}x(`${f.address}.${a}`,kt(E)),s(""),d("")}},T=f.type.kind==="object"&&!!f.type.additionalProperties,k=f.type.kind==="array";return h.jsxs("div",{"data-structured-controls":"",style:{display:"grid",gap:8,minWidth:0},children:[y.length>1&&h.jsxs("label",{children:["Value type",h.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[h.jsx("select",{"aria-label":"Value type",disabled:p,value:y.findIndex(E=>Ut(E,m).kind===f.type.kind),onChange:E=>x(f.address,kt(y[Number(E.target.value)])),children:y.map((E,P)=>h.jsx("option",{value:P,children:g(E)},P))}),h.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]})]}),w.map((E,P)=>h.jsxs("div",{"data-structured-slot":E.address,style:{display:"flex",gap:6,alignItems:"center",minWidth:0},children:[E.type.kind==="array"?h.jsx(Z.PiListNumbers,{size:20}):h.jsx(Z.PiBracketsCurly,{size:20}),h.jsx("span",{style:{flex:1,overflowWrap:"anywhere"},children:Cr(E.label)}),h.jsx(ve,{"aria-label":`${E.present?"Focus":"Create"} ${Cr(E.label)}`,title:`${E.present?"Focus":"Create"} ${Cr(E.label)}`,icon:E.present?h.jsx(Z.PiMagnifyingGlass,{size:18}):h.jsx(Z.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:p&&!E.present,onClick:R=>{var I;E.present?((I=R.currentTarget.closest("dialog"))==null||I.close(),_(E.nodeId)):x(E.address,kt(E.type))}}),k&&h.jsxs(h.Fragment,{children:[h.jsx(ve,{"aria-label":`Move item ${P+1} up`,icon:h.jsx(Z.PiArrowUp,{size:18}),size:"sm",variant:"ghost",disabled:p||P===0,onClick:()=>C(P,-1)}),h.jsx(ve,{"aria-label":`Move item ${P+1} down`,icon:h.jsx(Z.PiArrowDown,{size:18}),size:"sm",variant:"ghost",disabled:p||P===w.length-1,onClick:()=>C(P,1)})]}),E.present&&h.jsx(ve,{"aria-label":`Remove ${Cr(E.label)}`,icon:h.jsx(Z.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:p,onClick:()=>k?x(f.address,m.filter((R,I)=>I!==P)):x(E.address,void 0)})]},E.address)),(k||T)&&h.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"end"},children:[T&&h.jsxs("label",{style:{flex:"1 1 120px",minWidth:0},children:["Property name",h.jsx("input",{"aria-label":"Property name",value:a,disabled:p,onChange:E=>s(E.target.value)})]}),v.length>1&&h.jsxs("label",{style:{flex:"1 1 100px"},children:["New value type",h.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[h.jsx("select",{"aria-label":"New value type",value:u,disabled:p,onChange:E=>c(E.target.value),children:v.map((E,P)=>h.jsx("option",{value:P,children:g(E)},P))}),h.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]})]}),h.jsx("span",{style:{display:"flex",alignItems:"center",flexShrink:0,...T||v.length>1?{height:"calc(1.4em + 20px)",fontSize:15,marginBottom:6}:{}},children:h.jsx(ve,{"aria-label":k?"Add item":"Add property",icon:h.jsx(Z.PiPlus,{size:20}),size:"sm",variant:"ghost",disabled:p,onClick:S})})]}),l&&h.jsx("p",{role:"alert",children:l})]})}const kr=j.createContext({callbacks:{}}),nn=yn.default.div`
|
|
55
|
+
padding: 0;
|
|
56
|
+
font-size: 16px;
|
|
57
|
+
line-height: 1.4;
|
|
58
|
+
width: 100%;
|
|
59
|
+
box-sizing: border-box;
|
|
60
|
+
& [data-form-field] {
|
|
61
|
+
padding: 8px 0;
|
|
62
|
+
min-width: 0;
|
|
63
|
+
}
|
|
64
|
+
& label {
|
|
65
|
+
display: block;
|
|
66
|
+
margin-bottom: 6px;
|
|
67
|
+
font-size: 15px;
|
|
68
|
+
}
|
|
69
|
+
& input:not([type="checkbox"]),
|
|
70
|
+
& textarea,
|
|
71
|
+
& select {
|
|
72
|
+
width: 100%;
|
|
73
|
+
min-width: 0;
|
|
74
|
+
box-sizing: border-box;
|
|
75
|
+
font: inherit;
|
|
76
|
+
color: inherit;
|
|
77
|
+
padding: 10px 14px;
|
|
78
|
+
border: 0;
|
|
79
|
+
border-radius: 16px;
|
|
80
|
+
background: color-mix(in srgb, currentColor 7%, transparent);
|
|
81
|
+
outline: none;
|
|
82
|
+
box-shadow: none;
|
|
83
|
+
}
|
|
84
|
+
& textarea {
|
|
85
|
+
min-height: 98px;
|
|
86
|
+
resize: vertical;
|
|
87
|
+
}
|
|
88
|
+
& [data-form-select] {
|
|
89
|
+
position: relative;
|
|
90
|
+
}
|
|
91
|
+
& [data-form-select] select {
|
|
92
|
+
appearance: none;
|
|
93
|
+
padding-right: 40px;
|
|
94
|
+
}
|
|
95
|
+
& [data-form-select] > svg {
|
|
96
|
+
position: absolute;
|
|
97
|
+
right: 12px;
|
|
98
|
+
top: 50%;
|
|
99
|
+
transform: translateY(-50%);
|
|
100
|
+
pointer-events: none;
|
|
101
|
+
}
|
|
102
|
+
& [data-form-select] select:disabled + svg {
|
|
103
|
+
opacity: 0.55;
|
|
104
|
+
}
|
|
105
|
+
& details {
|
|
106
|
+
border-bottom: 1px solid color-mix(in srgb, currentColor 12%, transparent);
|
|
107
|
+
}
|
|
108
|
+
& summary {
|
|
109
|
+
display: flex;
|
|
110
|
+
align-items: center;
|
|
111
|
+
justify-content: space-between;
|
|
112
|
+
gap: 12px;
|
|
113
|
+
padding: 12px 0;
|
|
114
|
+
cursor: pointer;
|
|
115
|
+
font-weight: 600;
|
|
116
|
+
list-style: none;
|
|
117
|
+
}
|
|
118
|
+
& summary::-webkit-details-marker {
|
|
119
|
+
display: none;
|
|
120
|
+
}
|
|
121
|
+
& summary > span {
|
|
122
|
+
min-width: 0;
|
|
123
|
+
overflow-wrap: anywhere;
|
|
124
|
+
}
|
|
125
|
+
& summary > svg {
|
|
126
|
+
flex-shrink: 0;
|
|
127
|
+
transform: rotate(-90deg);
|
|
128
|
+
}
|
|
129
|
+
& details[open] > summary > svg {
|
|
130
|
+
transform: rotate(0deg);
|
|
131
|
+
}
|
|
132
|
+
& input[type="checkbox"] {
|
|
133
|
+
width: 20px;
|
|
134
|
+
height: 20px;
|
|
135
|
+
}
|
|
136
|
+
& button {
|
|
137
|
+
font: inherit;
|
|
138
|
+
cursor: pointer;
|
|
139
|
+
}
|
|
140
|
+
& button:disabled,
|
|
141
|
+
& input:disabled,
|
|
142
|
+
& select:disabled,
|
|
143
|
+
& textarea:disabled {
|
|
144
|
+
cursor: default;
|
|
145
|
+
opacity: 0.55;
|
|
146
|
+
}
|
|
147
|
+
& [role="alert"] {
|
|
148
|
+
color: #dc2626;
|
|
149
|
+
font-size: 14px;
|
|
150
|
+
margin-top: 8px;
|
|
151
|
+
}
|
|
152
|
+
`;function Rl({request:e,property:t,config:r,value:n,disabled:o}){var D,W;const{callbacks:i,structured:a,references:s}=j.useContext(kr),{themeColor:u}=Ie(),{background:c}=Ve(),l=j.useId(),d=t.type.kind==="object"||t.type.kind==="array"||t.type.kind==="json",f=n===void 0?"":d?JSON.stringify(n,null,2):String(n),[p,m]=j.useState(f),[y,b]=j.useState(""),[v,g]=j.useState(0),[w,x]=j.useState(),_=((D=r.$options)==null?void 0:D.$source)==="callback",C=i.resolveFormOptions,{data:S,address:T,nodeAddress:k,nodeId:E}=e,P=j.useRef(S);P.current=S;const R=JSON.stringify([T,E,(W=r.$options)!=null&&W.$dependsOn?r.$options.$dependsOn.map(z=>xe(S,z)):xe(S,k)]);j.useEffect(()=>{m(f),b("")},[f,T,E]),j.useEffect(()=>{if(!_)return;const z=new AbortController;return Promise.resolve().then(()=>{if(!C)throw new Error("No options resolver configured");return C({address:T,nodeAddress:k,nodeId:E,data:Wt(P.current),signal:z.signal})}).then(X=>{if(!Array.isArray(X)||X.some(se=>!se||typeof se.label!="string"||!["string","number","boolean"].includes(typeof se.value)&&se.value!==null))throw new Error("Invalid options response");z.signal.aborted||x({key:R,options:X})}).catch(X=>{z.signal.aborted||x({key:R,options:[],error:X instanceof Error?X.message:"Options unavailable"})}),()=>z.abort()},[_,C,R,T,k,E,v]);const I=_&&(w==null?void 0:w.key)!==R,O=_?(w==null?void 0:w.key)===R?w.options:[]:t.type.kind==="null"?[{label:"Null",value:null}]:t.type.kind==="boolean"?[{label:"Yes",value:!0},{label:"No",value:!1}]:$t(t.type),M=t.type.kind==="array",q=(a&&d||r.$control==="checkbox"?"pills":r.$control)??(O?M||t.type.kind==="boolean"?"pills":"select":t.type.kind==="boolean"?"checkbox":d?"textarea":"input"),K=!t.optional||!!r.$requiredWhen&&xn(r.$requiredWhen,S),V=!!(s!=null&&s.length)&&typeof n=="string"&&n.includes("{{"),re=y||_&&(w==null?void 0:w.key)===R&&w.error||!V&&Rr(t.type,n,K),ce=Cr(r.$label??T.split(".").pop()),he=z=>{var X;if(!(o||Object.is(z,n)))try{(X=i.onFormChange)==null||X.call(i,{...e,previousValue:n,value:z}),b("")}catch(se){b(se instanceof Error?se.message:"Unable to update field")}},me=()=>{if(d){try{const Q=p===""&&t.optional?void 0:JSON.parse(p),G=Rr(t.type,Q,K);if(G){b(G);return}he(Q)}catch{b("Enter valid JSON")}return}const z=t.type.kind==="number"||t.type.kind==="integer",X=p===""&&t.optional?void 0:z&&p!==""?Number(p):p,se=Rr(t.type,X,K);if(z&&se&&p!==""){b(se);return}he(X)},H={id:l,disabled:o,"aria-label":ce,"aria-required":K,"aria-invalid":!!re,"aria-describedby":re?`${l}-error`:void 0},N=fe(u);return h.jsxs("div",{"data-form-field":T,"data-flow-property":T.slice(k.length+1),children:[h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[h.jsxs("label",{htmlFor:l,children:[ce,K?" *":""]}),t.optional&&n!==void 0&&h.jsx("button",{type:"button","aria-label":`Reset ${ce}`,title:`Reset ${ce}`,disabled:o,style:{width:24,height:24,padding:0,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:0,background:"transparent",color:"inherit"},onClick:()=>he(void 0),children:h.jsx(Z.PiArrowCounterClockwise,{size:14})})]}),!!(s!=null&&s.length)&&!d&&h.jsx(e0,{label:ce,value:n,references:s,disabled:o,onChange:he}),V?null:q==="select"?h.jsxs("div",{"data-form-select":"",children:[h.jsxs("select",{...H,disabled:o||I||!!(w!=null&&w.error),value:(O==null?void 0:O.findIndex(z=>Object.is(z.value,n)))??-1,onChange:z=>{const X=O==null?void 0:O[Number(z.target.value)];X&&he(X.value)},children:[h.jsx("option",{value:-1,disabled:!0,children:n!==void 0?String(n):""}),O==null?void 0:O.map((z,X)=>h.jsx("option",{value:X,style:{background:fe(c)},children:Cr(z.label)||z.label},X))]}),h.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]}):q==="pills"?h.jsxs("div",{id:l,role:"group","aria-label":ce,"aria-describedby":H["aria-describedby"],style:{display:"flex",flexWrap:"wrap",gap:8},children:[O==null?void 0:O.map((z,X)=>{const se=M?Array.isArray(n)&&n.includes(z.value):Object.is(n,z.value);return h.jsx("button",{type:"button",disabled:o||I,"aria-pressed":se,style:{padding:"8px 16px",borderRadius:24,border:0,color:se?N:"inherit",background:se?"color-mix(in srgb, currentColor 12%, transparent)":"color-mix(in srgb, currentColor 7%, transparent)"},onClick:()=>he(M?se?n.filter(Q=>Q!==z.value):[...Array.isArray(n)?n:[],z.value]:z.value),children:Cr(z.label)||z.label},X)}),I&&h.jsx("span",{role:"status",children:"Loading..."})]}):q==="textarea"?h.jsx("textarea",{...H,value:p,onChange:z=>m(z.target.value),onBlur:me}):h.jsx("input",{...H,type:t.type.kind==="number"||t.type.kind==="integer"?"number":"text",step:t.type.kind==="integer"?1:"any",value:p,onChange:z=>m(z.target.value),onBlur:me,onKeyDown:z=>{z.key==="Enter"&&me(),z.key==="Escape"&&m(n===void 0?"":String(n))}}),re&&h.jsx("div",{role:"alert",id:`${l}-error`,children:re}),_&&(w==null?void 0:w.error)&&h.jsx("button",{type:"button",disabled:o,onClick:()=>{x(void 0),g(v+1)},children:"Retry"})]})}function om({nodeAddress:e}){var x,_;const{data:t,schema:r,callbacks:n,bindings:o,editable:i,renderForm:a,structured:s}=j.useContext(kr),{readOnly:u,config:c}=Ie(),l=a==null?void 0:a(e);if(l!==void 0)return h.jsx("fieldset",{"data-flow-form":e,disabled:u||c.editable===!1||!i,style:{border:0,margin:0,padding:0,minWidth:0},children:l});if(!t)return h.jsx(nn,{role:"alert",children:"Forms require a JSON document."});const d=o?Yt(o,e,r):void 0,f=o?d:r&>(t,e,r);if(!f)return h.jsx(nn,{role:"status",children:"Form schema unavailable."});const p=(d==null?void 0:d.address)??e,m=xe(t,p),y=(x=s==null?void 0:s.containers.get(e))==null?void 0:x.scalar;if(m===void 0||typeof m!="object"&&!y)return h.jsx(nn,{role:"alert",children:"Bound form state is unavailable."});const b=Object.entries(f.type.properties).filter(([C])=>{var S;return xn((S=f.fields[C])==null?void 0:S.$visibleWhen,t)}),v=b.length>8||b.some(([C])=>{var S;return(S=f.fields[C])==null?void 0:S.$section}),g=new Map;for(const C of b){const[S,T]=C,k=v?Cr(((_=f.fields[S])==null?void 0:_.$section)??(T.type.kind==="object"||T.type.kind==="array"?S:T.optional?"Options":"General")):"";g.has(k)||g.set(k,[]),g.get(k).push(C)}const w=([C,S])=>h.jsx(Rl,{request:{data:t,address:y?p:`${p}.${C}`,nodeAddress:p,nodeId:typeof(m==null?void 0:m.id)=="string"?m.id:void 0},property:S,config:f.fields[C]??{},value:y?m:m==null?void 0:m[C],disabled:u||c.editable===!1||!(i??!!n.onJsonChange)},`${(m==null?void 0:m.id)??e}:${C}`);return h.jsxs(nn,{"data-flow-form":e,onClick:C=>C.stopPropagation(),onDoubleClick:C=>C.stopPropagation(),children:[s&&h.jsx(i0,{nodeAddress:e}),d&&f.type.additionalProperties&&b.length===0&&h.jsx(Rl,{request:{data:t,address:p,nodeAddress:p},property:{type:f.type,optional:!1},config:{$label:"Configuration",$control:"textarea"},value:m,disabled:u||c.editable===!1||!i}),[...g].map(([C,S])=>v&&S.length>1?h.jsxs("details",{open:!0,children:[h.jsxs("summary",{children:[h.jsx("span",{children:C}),h.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]}),S.map(w)]},C):S.map(w))]})}function im(e){const{viewData:t}=j.useContext(kr),{nodeById:r,edgeById:n,parentIds:o}=Gr();if(t){const i=xe(t,e),a=i&&typeof i=="object"&&!Array.isArray(i)&&"$"in i?i.$:i;return Array.isArray(a)?a.length>0:!!a&&typeof a=="object"&&Object.entries(a).some(([s,u])=>!s.startsWith("$")&&u!==null&&typeof u=="object")}return o.has(e)?!0:[...n.values()].some(({data:i})=>{const a=i.isInverted?i.target:i.source,s=i.isInverted?i.source:i.target;return a===e&&s!==e&&r.has(s)})}function Ht(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:t}function dn(e,t,r,n){return{borderColor:t,borderWidth:Ht(e==null?void 0:e.borderWidth,n),borderStyle:(e==null?void 0:e.borderStyle)??"solid",...py(t==="transparent"?"currentColor":t,r,".flow-sdk-node:hover &",!r)}}function am({label:e,value:t,options:r,onChange:n,disabled:o}){var i;return h.jsxs(Or,{"aria-label":e,title:`Animation: ${((i=r.find(a=>a.value===t))==null?void 0:i.label)??"Mixed"}`,value:t,style:{width:104},disabled:o,onValueChange:a=>{const s=r.find(u=>u.value===a);s&&n(s.value)},children:[t===""&&h.jsx("option",{value:"",disabled:!0,children:"Mixed"}),r.map(a=>h.jsx("option",{value:a.value,children:a.label},a.value))]})}const fn="data:image/svg+xml;base64,";function Pt(e){if(e.startsWith(fn))return!0;try{const t=new URL(e);return(t.protocol==="https:"||t.protocol==="http:")&&!t.username&&!t.password}catch{return!1}}async function a0(e){if(e.size>256*1024)throw new Error("SVG must be 256 KB or smaller.");const t=await e.text(),r=new DOMParser().parseFromString(t,"image/svg+xml");if(r.doctype||r.querySelector("parsererror")||r.documentElement.localName!=="svg"||r.documentElement.namespaceURI!=="http://www.w3.org/2000/svg")throw new Error("Choose a valid SVG file.");if(r.querySelector("script, foreignObject")||[...r.querySelectorAll("*")].some(i=>[...i.attributes].some(a=>/^on/i.test(a.name))))throw new Error("SVG scripts and event handlers are not allowed.");const n=new TextEncoder().encode(t);let o="";for(const i of n)o+=String.fromCharCode(i);return fn+btoa(o)}const Mr=({name:e,svg:t=!1,...r})=>{const[n,o]=j.useState(null),[i,a]=j.useState(!0),[s,u]=j.useState(!1),c=typeof e=="string"&&Pt(e);if(j.useEffect(()=>{if(c||!e||e.length<2){o(null),a(!1);return}a(!0),u(!1),(async()=>{try{let d;if(e.startsWith("Md"))d="md";else if(e.startsWith("Fa"))d="fa6";else if(e.startsWith("Io5"))d="io5";else if(e.startsWith("Io"))d="io";else if(e.startsWith("Ti"))d="ti";else if(e.startsWith("Go"))d="go";else if(e.startsWith("Fi"))d="fi";else if(e.startsWith("Di"))d="di";else if(e.startsWith("Ai"))d="ai";else if(e.startsWith("Bs"))d="bs";else if(e.startsWith("Ri"))d="ri";else if(e.startsWith("Fc"))d="fc";else if(e.startsWith("Gi"))d="gi";else if(e.startsWith("Hi2"))d="hi2";else if(e.startsWith("Hi"))d="hi";else if(e.startsWith("Si"))d="si";else if(e.startsWith("Sl"))d="sl";else if(e.startsWith("Im"))d="im";else if(e.startsWith("Bi"))d="bi";else if(e.startsWith("Pi"))d="pi";else if(e.startsWith("Vsc"))d="vsc";else if(e.startsWith("Tb"))d="tb";else if(e.startsWith("Tfi"))d="tfi";else if(e.startsWith("Cg"))d="cg";else if(e.startsWith("Lia"))d="lia";else if(e.startsWith("Lu"))d="lu";else throw new Error(`Unknown library prefix for icon: ${e}`);let f;switch(d){case"md":f=await import("react-icons/md");break;case"fa6":f=await import("react-icons/fa6");break;case"io5":f=await import("react-icons/io5");break;case"io":f=await import("react-icons/io");break;case"ti":f=await import("react-icons/ti");break;case"go":f=await import("react-icons/go");break;case"fi":f=await import("react-icons/fi");break;case"di":f=await import("react-icons/di");break;case"ai":f=await import("react-icons/ai");break;case"bs":f=await import("react-icons/bs");break;case"ri":f=await import("react-icons/ri");break;case"fc":f=await import("react-icons/fc");break;case"gi":f=await import("react-icons/gi");break;case"hi2":f=await import("react-icons/hi2");break;case"hi":f=await import("react-icons/hi");break;case"si":f=await import("react-icons/si");break;case"sl":f=await import("react-icons/sl");break;case"im":f=await import("react-icons/im");break;case"bi":f=await import("react-icons/bi");break;case"pi":f=await import("react-icons/pi");break;case"vsc":f=await import("react-icons/vsc");break;case"tb":f=await import("react-icons/tb");break;case"tfi":f=await import("react-icons/tfi");break;case"cg":f=await import("react-icons/cg");break;case"lia":f=await import("react-icons/lia");break;case"lu":f=await import("react-icons/lu");break;default:throw new Error(`Unsupported library: ${d}`)}const p=f[e];if(!p)throw new Error(`Icon ${e} not found in library ${d}`);o(()=>p)}catch(d){console.warn(`Failed to load icon ${e}:`,d.message),u(!0),o(null)}finally{a(!1)}})()},[e,c]),c){const{size:l=80,style:d,...f}=r;return t?h.jsx("image",{...f,href:e,width:l,height:l,preserveAspectRatio:"xMidYMid meet",style:d}):h.jsx("img",{...f,src:e,alt:"",width:l,height:l,referrerPolicy:"no-referrer",style:{objectFit:"contain",...d}})}return i||!n?null:h.jsx(n,{...r})};function qu({nodeId:e,edgeId:t,value:r}){const{callbacks:n,readOnly:o,themeColor:i}=Ie(),{background:a,backgroundSecondary:s,border:u,colorText:c}=Ve(),l=j.useRef(null),d=j.useId(),f=j.useRef(null),p=j.useRef(0),[m,y]=j.useState(!1),[b,v]=j.useState("icons"),[g,w]=j.useState([]),[x,_]=j.useState("loading"),[C,S]=j.useState(""),[T,k]=j.useState(0),[E,P]=j.useState(""),[R,I]=j.useState(""),[O,M]=j.useState(!1);j.useEffect(()=>()=>{p.current++},[]),j.useEffect(()=>{if(!m)return;let H=!0;return import("react-icons/pi").then(N=>{H&&(w(Object.keys(N).filter(D=>D.startsWith("Pi")).sort()),_("ready"))}).catch(()=>{H&&_("unavailable")}),()=>{H=!1}},[m]),j.useEffect(()=>{var H;o&&((H=l.current)==null||H.close())},[o]);const q=H=>{var N,D,W;o||(t?(N=n.onEdgeIconChange)==null||N.call(n,t,H):e&&((D=n.onNodeIconChange)==null||D.call(n,e,H)),(W=l.current)==null||W.close())},K=g.filter(H=>H.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase().includes(C.trim().toLowerCase())),V=36,re=Math.max(1,Math.ceil(K.length/V)),ce=Math.min(T,re-1),he=K.slice(ce*V,(ce+1)*V),me={width:"100%",padding:"8px 14px",background:"transparent",color:"inherit",border:`1px solid ${fe(u)}`,borderRadius:30};return h.jsxs(h.Fragment,{children:[h.jsx(je,{label:t?"Choose edge icon":"Choose node icon",children:h.jsx(ve,{"aria-label":t?"Choose edge icon":"Choose node icon",icon:h.jsx(Z.PiShapes,{size:20}),size:"sm",variant:"ghost",color:fe(i),disabled:o,onClick:()=>{var H;I(""),v(r&&Pt(r)?"custom":"icons"),P(r&&!r.startsWith(fn)&&Pt(r)?r:""),y(!0),(H=l.current)==null||H.showModal()}})}),h.jsx(F.chakra.dialog,{ref:l,"aria-label":t?"Choose edge icon":"Choose node icon",css:Dr(fe(a),fe(u)),onClose:()=>{y(!1),p.current++,M(!1)},onClick:H=>{H.stopPropagation(),H.target===H.currentTarget&&H.currentTarget.close()},onKeyDown:H=>H.stopPropagation(),style:{margin:"auto",padding:12,width:336,maxWidth:"calc(100vw - 32px)",maxHeight:"calc(100vh - 32px)",overflowY:"auto",borderRadius:30,background:fe(a),color:fe(c)},children:m&&h.jsxs("div",{style:{display:"grid",gap:8},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[h.jsx("strong",{children:t?"Edge icon":"Node icon"}),h.jsxs("div",{style:{display:"flex",alignItems:"center",marginLeft:"auto",gap:4},children:[r&&h.jsx(je,{label:"Remove icon",children:h.jsx(ve,{"aria-label":t?"Remove edge icon":"Remove node icon",icon:h.jsx(Z.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:o||O,onClick:()=>q("")})}),h.jsx(pt,{"aria-label":"Close icon picker",onClick:()=>{var H;return(H=l.current)==null?void 0:H.close()}})]})]}),h.jsx("div",{role:"tablist","aria-label":"Icon source",style:{display:"flex",borderBottom:`1px solid ${fe(u)}`},children:["icons","custom"].map(H=>h.jsx("button",{id:`${d}-${H}`,type:"button",role:"tab","aria-selected":b===H,"aria-controls":`${d}-panel`,tabIndex:b===H?0:-1,onClick:()=>{v(H),I("")},onKeyDown:N=>{var W;if(!["ArrowLeft","ArrowRight","Home","End"].includes(N.key))return;N.preventDefault();const D=N.key==="Home"?"icons":N.key==="End"||H==="icons"?"custom":"icons";v(D),I(""),(W=document.getElementById(`${d}-${D}`))==null||W.focus()},style:{flex:1,padding:"8px 12px",background:"transparent",border:0,borderBottom:`2px solid ${b===H?fe(i):"transparent"}`,color:b===H?fe(i):"inherit",cursor:"pointer",fontSize:13},children:H==="icons"?"React icons":"Custom SVG"},H))}),h.jsx("input",{ref:f,type:"file",accept:".svg,image/svg+xml","aria-label":"Upload SVG icon",hidden:!0,disabled:O||o,onChange:async H=>{var W;const N=(W=H.target.files)==null?void 0:W[0];if(H.target.value="",!N)return;const D=++p.current;M(!0),I("");try{const z=await a0(N);D===p.current&&q(z)}catch(z){D===p.current&&I(z instanceof Error?z.message:"Unable to read SVG.")}finally{D===p.current&&M(!1)}}}),h.jsx("div",{id:`${d}-panel`,role:"tabpanel","aria-labelledby":`${d}-${b}`,style:{display:"grid",gap:8},children:b==="icons"?h.jsxs(h.Fragment,{children:[h.jsx("input",{"aria-label":"Search icons",placeholder:"Search icons...",value:C,onChange:H=>{S(H.target.value),k(0)},style:me}),h.jsxs("div",{style:{height:244,overflowY:"auto",display:"grid",gridTemplateColumns:"repeat(6, minmax(0, 1fr))",gridAutoRows:36,gap:4},children:[he.map(H=>h.jsx("button",{type:"button","aria-label":`Choose ${H}`,"aria-pressed":r===H,title:H,onClick:()=>q(H),style:{display:"grid",placeItems:"center",borderRadius:5,border:`${r===H?2:1}px solid ${fe(r===H?i:u)}`,background:fe(r===H?a:s),color:"inherit",cursor:"pointer"},children:h.jsx(Mr,{name:H,size:24})},H)),he.length===0&&h.jsx("span",{role:"status",style:{gridColumn:"1 / -1"},children:x==="loading"?"Loading icons...":x==="unavailable"?"React icons unavailable":"No icons found"})]}),h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[h.jsxs("span",{role:"status",style:{fontSize:12},children:[K.length," icons · ",ce+1," / ",re]}),h.jsxs("div",{style:{display:"flex",gap:4},children:[h.jsx(je,{label:"Previous icons",children:h.jsx(ve,{"aria-label":"Previous icons",icon:h.jsx(Z.PiCaretLeft,{size:18}),size:"sm",variant:"ghost",disabled:ce===0,onClick:()=>k(ce-1)})}),h.jsx(je,{label:"Next icons",children:h.jsx(ve,{"aria-label":"Next icons",icon:h.jsx(Z.PiCaretRight,{size:18}),size:"sm",variant:"ghost",disabled:ce+1>=re,onClick:()=>k(ce+1)})})]})]})]}):h.jsxs(h.Fragment,{children:[r&&Pt(r)&&h.jsx(Mr,{name:r,size:64}),h.jsxs("button",{type:"button",disabled:O||o,onClick:()=>{var H;return(H=f.current)==null?void 0:H.click()},style:{...me,display:"flex",justifyContent:"center",gap:8,alignItems:"center",cursor:"pointer"},children:[h.jsx(Z.PiUploadSimple,{}),O?"Uploading...":"Upload SVG"]}),h.jsxs("form",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},onSubmit:H=>{H.preventDefault(),!(O||o)&&(!Pt(E.trim())||E.trim().startsWith(fn)?I("Enter an HTTP or HTTPS image URL."):q(E.trim()))},children:[h.jsx("input",{type:"url","aria-label":"SVG URL",placeholder:"https://example.com/icon.svg",value:E,disabled:O||o,onChange:H=>P(H.target.value),style:{...me,flex:1,minWidth:0}}),h.jsx(je,{label:"Apply URL",children:h.jsx(ve,{type:"submit","aria-label":"Apply URL",icon:h.jsx(Z.PiArrowRight,{size:20}),size:"sm",variant:"ghost",disabled:O||o||!E.trim(),style:{flexShrink:0}})})]})]})}),R&&h.jsx("div",{role:"alert",style:{fontSize:13},children:R})]})})]})}const Nu=["white","blue.500","teal.500","green.500","yellow.500","orange.500","red.500","purple.500","pink.500","gray.500"],sm=["gray.900","gray.600","gray.200","white"];function cm(){const{config:e}=Ie(),t=e.selectionToolbar||{},r=new Set(t.hide||[]);return{palette:t.palette||Nu,show:n=>!r.has(n)}}function ur(){const{border:e}=Ve();return h.jsx(F.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:e})}function Qr({value:e,placeholder:t,ariaLabel:r,width:n="140px",type:o="text",min:i,onCommit:a}){const{colorText:s}=Ve(),[u,c]=j.useState(e),l=j.useRef(!1);j.useEffect(()=>c(e),[e]);const d=()=>{if(l.current)return;l.current=!0;const f=u.trim();if(o==="number"&&f!==""&&(!Number.isFinite(Number(f))||Number(f)<(i??0))){c(e);return}f!==e&&a(f)};return h.jsx(F.Input,{"aria-label":r,type:o,min:i,size:"xs",w:n,value:u,placeholder:t,color:s,borderWidth:0,_focusVisible:{boxShadow:"none",outline:"none"},borderRadius:"8px",onFocus:()=>{l.current=!1},onChange:f=>c(f.target.value),onBlur:d,onKeyDown:f=>{f.key==="Enter"&&(d(),f.target.blur()),f.key==="Escape"&&(l.current=!0,c(e),f.target.blur())}})}function Kt({colors:e,value:t,label:r,onPick:n,onReset:o,includeTransparent:i=!0}){const{colorInactive:a,colorText:s}=Ve(),[u,c]=j.useState(!1),l=j.useId(),d=j.useRef(null),f=t??e[0]??"transparent";return h.jsxs(F.HStack,{gap:1,"aria-label":r,role:"group",onKeyDown:p=>{var m;p.key==="Escape"&&(c(!1),(m=d.current)==null||m.focus())},children:[h.jsx(je,{label:`${r}: ${f}`,children:h.jsx(F.chakra.button,{ref:d,type:"button","aria-label":`${r} colors`,"aria-expanded":u,"aria-controls":l,w:4,h:4,flexShrink:0,borderRadius:"full",cursor:"pointer",style:{backgroundColor:fe(f),...f==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:`2px solid ${fe(s)}`,outlineOffset:"1px",onClick:()=>c(p=>!p)})}),u&&h.jsxs(F.HStack,{id:l,gap:1,children:[[...new Set([...e,...i?["transparent"]:[]])].map(p=>{const m=t===p;return h.jsx(je,{label:`${r}: ${p}`,children:h.jsx(F.Box,{as:"button","aria-label":`${r} ${p}`,"aria-pressed":m,w:4,h:4,borderRadius:"full",cursor:"pointer",style:{backgroundColor:fe(p),...p==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:m?`2px solid ${fe(s)}`:"none",outlineOffset:"1px",_hover:{transform:"scale(1.15)"},onClick:()=>{var y;n(p),c(!1),(y=d.current)==null||y.focus()}})},p)}),o&&h.jsx(je,{label:`Reset ${r.toLowerCase()}`,children:h.jsx(ve,{"aria-label":`Reset ${r}`,icon:h.jsx(F.Icon,{as:Z.PiEraser,boxSize:4}),size:"xs",variant:"ghost",color:a,onClick:()=>{var p;o(),c(!1),(p=d.current)==null||p.focus()}})})]})]})}function um({edgeId:e,onClose:t}){var p;const{callbacks:r,themeColor:n,config:o}=Ie(),{colorInactive:i}=Ve(),{edgeById:a}=Gr(),{palette:s,show:u}=cm(),c=(p=a.get(e))==null?void 0:p.data,l=[...new Set(["rounded-orthogonal","orthogonal","straight","bezier",...Object.keys(o.customEdgeTypes??{}),...c!=null&&c.type?[c.type]:[]])],d=c!=null&&c.isEdgeAnimated?"animated":c!=null&&c.isEdgeDashed?"dashed":"solid",f=[{key:"solid",icon:Z.PiLineSegment,label:"Solid"},{key:"dashed",icon:Z.PiLineSegments,label:"Dashed"},{key:"animated",icon:Z.PiFastForward,label:"Animated"}];return h.jsxs(h.Fragment,{children:[h.jsx(pt,{onClick:t}),u("label")&&h.jsxs(h.Fragment,{children:[h.jsx(ur,{}),h.jsx(Qr,{ariaLabel:"Edge label",placeholder:"Edge label",value:(c==null?void 0:c.label)||"",onCommit:m=>{var y;return(y=r.onEdgeLabelChange)==null?void 0:y.call(r,e,m)}})]}),u("style")&&h.jsxs(h.Fragment,{children:[h.jsx(ur,{}),f.map(m=>h.jsx(je,{label:m.label,children:h.jsx(ve,{"aria-label":`Edge style ${m.key}`,"aria-pressed":d===m.key,icon:h.jsx(F.Icon,{as:m.icon,boxSize:5}),size:"sm",variant:"ghost",color:d===m.key?n:i,onClick:()=>{var y;return(y=r.onEdgeStyleChange)==null?void 0:y.call(r,e,m.key)}})},m.key)),d==="animated"&&h.jsx(am,{label:"Edge animation",value:(c==null?void 0:c.edgeAnimationVariant)??"dashed",options:[{value:"dashed",label:"Dash"},{value:"traveling",label:"Trace"}],disabled:o.readOnly,onChange:m=>{var y;return(y=r.onEdgeAnimationVariantChange)==null?void 0:y.call(r,e,m)}}),h.jsxs(Or,{"aria-label":"Edge shape",title:`Edge shape: ${(c==null?void 0:c.type)??"Default"}`,icon:h.jsx(Z.PiBezierCurve,{size:20}),style:{width:36},value:(c==null?void 0:c.type)??"",disabled:o.readOnly,onValueChange:m=>{var y;return(y=r.onEdgeTypeChange)==null?void 0:y.call(r,e,m||void 0)},children:[h.jsx("option",{value:"",children:"Default"}),l.map(m=>h.jsx("option",{value:m,children:m},m))]})]}),u("icon")&&h.jsxs(h.Fragment,{children:[h.jsx(ur,{}),h.jsx(qu,{edgeId:e,value:c==null?void 0:c.icon},e),h.jsx(Qr,{ariaLabel:"Edge icon",placeholder:"Icon name or SVG URL",value:(c==null?void 0:c.icon)??"",onCommit:m=>{var y;return(y=r.onEdgeIconChange)==null?void 0:y.call(r,e,m)}})]}),u("color")&&h.jsxs(h.Fragment,{children:[h.jsx(ur,{}),h.jsx(Kt,{label:"Edge color",colors:s,value:c==null?void 0:c.color,onPick:m=>{var y;return(y=r.onEdgeColorChange)==null?void 0:y.call(r,e,m)},onReset:()=>{var m;return(m=r.onEdgeColorChange)==null?void 0:m.call(r,e,"")}})]}),u("delete")&&h.jsxs(h.Fragment,{children:[h.jsx(ur,{}),h.jsx(je,{label:"Delete edge",children:h.jsx(ve,{"aria-label":"Delete edge",icon:h.jsx(F.Icon,{as:Z.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:"red.400",onClick:()=>{var m;(m=r.onEdgeDelete)==null||m.call(r,e,c),t()}})})]})]})}function lm({ids:e,showDivider:t=!0}){const{callbacks:r,config:n}=Ie(),{colorInactive:o}=Ve(),{nodeById:i}=Gr(),[a,s]=j.useState(!1),u=e.map(m=>{var y,b;return(b=(y=i.get(m))==null?void 0:y.data.viewProps)==null?void 0:b.borderRadius}),c=!u.every(m=>m===u[0]),l=c?"mixed":String(u[0]??""),d=["0","8","16","30","53","100"],f=a||!c&&l!==""&&!d.includes(l),p=m=>e.forEach(y=>{var b;return(b=r.onNodeBorderRadiusChange)==null?void 0:b.call(r,y,m)});return h.jsxs(h.Fragment,{children:[t&&h.jsx(ur,{}),h.jsx(F.Box,{position:"relative",w:"36px",h:"30px",display:"grid",placeItems:"center",children:h.jsxs(Or,{icon:h.jsx(F.Icon,{as:tv.TbBorderRadius,boxSize:5,color:o,"aria-hidden":"true"}),"aria-label":"Node border radius",title:`Border radius: ${c?"Mixed":u[0]===void 0?"Default":`${u[0]}px`}`,style:{position:"absolute",inset:0,width:"100%",height:"100%",cursor:"pointer"},value:f?"custom":l,disabled:n.readOnly,onValueChange:m=>{s(m==="custom"),m!=="custom"&&p(m===""?void 0:Number(m))},children:[h.jsx("option",{value:"",children:"Default radius"}),c&&h.jsx("option",{value:"mixed",disabled:!0,children:"Mixed radii"}),d.map(m=>h.jsxs("option",{value:m,children:[m,"px radius"]},m)),h.jsx("option",{value:"custom",children:"Custom radius"})]})}),f&&h.jsx(Qr,{ariaLabel:"Custom border radius",placeholder:c?"Mixed":"Auto",type:"number",min:0,width:"72px",value:c?"":l,onCommit:m=>p(m===""?void 0:Number(m))})]})}function dm({ids:e,onClose:t}){var H,N,D,W,z,X,se,Q;const{callbacks:r,colorMode:n,themeColor:o,config:i,setNodeViewMode:a}=Ie(),{colorText:s,colorInactive:u}=Ve(),{nodeById:c,parentIds:l}=Gr(),{palette:d,show:f}=cm(),p=e.length===1,m=p?(H=c.get(e[0]))==null?void 0:H.data:void 0,y=e.map(G=>{var J,te;return((te=(J=c.get(G))==null?void 0:J.data.config)==null?void 0:te.typeView)??""}),b=y.some(G=>G!==y[0]),v=b?"mixed":y[0]??"",g=e.some(G=>{var te,le;const J=(te=c.get(G))==null?void 0:te.data;return J&&(l.has(G)||((le=J.config)==null?void 0:le.parentContainer)||Object.prototype.hasOwnProperty.call(i.customViews??{},J.type))}),w=(N=m==null?void 0:m.config)==null?void 0:N.collapsed,x=im(e[0]),_=G=>{var J,te,le;return(((te=(J=c.get(G))==null?void 0:J.data.viewProps)==null?void 0:te.outline)??(l.has(G)?(le=i.parentNodeStyle)==null?void 0:le.outline:!1))===!0},C=e.every(_),S=!C&&e.some(_),T=G=>{var J;return((J=c.get(G))==null?void 0:J.data.isNodeAnimated)===!0},k=e.every(T),E=!k&&e.some(T),P=e.map(G=>{var J;return((J=c.get(G))==null?void 0:J.data.nodeAnimationVariant)??"traveling"}),R=P.every(G=>G===P[0])?P[0]:"",I=G=>e.forEach(G),[O,M]=j.useState(!1),q=O&&f("color")&&f("borderColor"),K=G=>{var J,te,le;return(((te=(J=c.get(G))==null?void 0:J.data.viewProps)==null?void 0:te.borderStyle)??(l.has(G)?(le=i.parentNodeStyle)==null?void 0:le.borderStyle:"solid"))==="dashed"},V=e.every(K),re=!V&&e.some(K),ce=e.map(G=>{var le,de,Re;const J=(le=c.get(G))==null?void 0:le.data,te=l.has(G)?Ht((de=i.parentNodeStyle)==null?void 0:de.borderWidth,6):(J==null?void 0:J.type)==="objectView"?3:2;return Ht((Re=J==null?void 0:J.viewProps)==null?void 0:Re.borderWidth,te)}),he=ce.every(G=>G===ce[0])?String(ce[0]??""):"",me=G=>I(J=>{var te,le;q?(te=r.onNodeBorderColorChange)==null||te.call(r,J,G):(le=r.onNodeColorChange)==null||le.call(r,J,"bg",G)});return h.jsxs(h.Fragment,{children:[h.jsx(pt,{onClick:t}),h.jsx(ur,{}),p&&f("label")?h.jsx(Qr,{ariaLabel:"Node label",placeholder:"Node label",value:(m==null?void 0:m.label)??(m==null?void 0:m.headerTitle)??"",onCommit:G=>{var J;return(J=r.onNodeLabelChange)==null?void 0:J.call(r,e[0],G)}}):h.jsxs(F.Text,{fontSize:"xs",color:s,whiteSpace:"nowrap",px:1,children:[e.length," selected"]}),f("typeView")&&h.jsxs(Or,{"aria-label":"Type view",title:g?"Type view is managed by the custom renderer or container":`Type view: ${v||"None (default)"}`,icon:h.jsx(Z.PiImage,{size:20}),style:{width:36},value:v,disabled:i.readOnly||i.editable===!1||g,onValueChange:G=>{Bt.includes(G)&&I(J=>{var te,le;(te=r.onNodeTypeViewChange)==null||te.call(r,J,G||void 0),a(J,"default"),(le=r.onNodeViewToggle)==null||le.call(r,J)})},children:[b&&h.jsx("option",{value:"mixed",disabled:!0,children:"Mixed"}),Bt.map(G=>h.jsx("option",{value:G,children:G||"None"},G))]}),f("style")&&h.jsx(lm,{ids:e},e.join("\0")),f("outline")&&h.jsxs(h.Fragment,{children:[h.jsx(ur,{}),h.jsx(je,{label:C?"Restore node fill":"Remove node fill",children:h.jsx(ve,{"aria-label":"Toggle node outline","aria-pressed":S?"mixed":C,icon:h.jsx(F.Icon,{as:C?Z.PiSquare:Z.PiSquareFill,boxSize:5}),size:"sm",variant:"ghost",color:C?o:u,onClick:()=>I(G=>{var J;return(J=r.onNodeOutlineChange)==null?void 0:J.call(r,G,!C)})})})]}),f("color")&&h.jsxs(h.Fragment,{children:[h.jsx(ur,{}),f("borderColor")&&h.jsx(je,{label:q?"Edit node colors":"Edit node border",children:h.jsx(ve,{"aria-label":"Edit node border","aria-pressed":q,icon:h.jsx(F.Icon,{as:Z.PiBoundingBox,boxSize:5}),size:"sm",variant:"ghost",color:q?o:u,bg:q?n==="dark"?"whiteAlpha.200":"blackAlpha.100":void 0,onClick:()=>M(G=>!G)})}),h.jsx(Kt,{label:q?"Border color":"Background",colors:d,value:q?((D=m==null?void 0:m.viewProps)==null?void 0:D.borderColor)??(p&&l.has(e[0])?(W=i.parentNodeStyle)==null?void 0:W.borderColor:void 0):(z=m==null?void 0:m.viewProps)==null?void 0:z.bgColor,onPick:me,onReset:()=>me("")}),q&&f("style")&&h.jsxs(h.Fragment,{children:[h.jsx(ur,{}),h.jsx(je,{label:V?"Solid border":"Dashed border",children:h.jsx(ve,{"aria-label":"Toggle dashed border","aria-pressed":re?"mixed":V,icon:h.jsx(F.Icon,{as:V?Z.PiLineSegments:Z.PiLineSegment,boxSize:5}),size:"sm",variant:"ghost",color:V?o:u,onClick:()=>I(G=>{var J;return(J=r.onNodeBorderStyleChange)==null?void 0:J.call(r,G,V?"solid":"dashed")})})}),h.jsx(Qr,{ariaLabel:"Border thickness",placeholder:p?"Auto":"Mixed",width:"64px",type:"number",min:0,value:he,onCommit:G=>I(J=>{var te;return(te=r.onNodeBorderWidthChange)==null?void 0:te.call(r,J,G===""?void 0:Number(G))})})]})]}),f("animation")&&h.jsxs(h.Fragment,{children:[h.jsx(ur,{}),h.jsx(je,{label:k?"Stop border animation":"Animate node border",children:h.jsx(ve,{"aria-label":"Toggle node animation","aria-pressed":E?"mixed":k,icon:h.jsx(F.Icon,{as:Z.PiSpinnerGap,boxSize:5}),size:"sm",variant:"ghost",color:k?o:u,onClick:()=>I(G=>{var J;return(J=r.onNodeAnimationChange)==null?void 0:J.call(r,G,!k)})})}),(k||E)&&h.jsx(am,{label:"Node animation",value:R,options:[{value:"traveling",label:"Trace"},{value:"pulse",label:"Pulse"}],disabled:i.readOnly,onChange:G=>I(J=>{var te;return(te=r.onNodeAnimationVariantChange)==null?void 0:te.call(r,J,G)})})]}),!q&&f("textColor")&&h.jsxs(h.Fragment,{children:[h.jsx(ur,{}),h.jsx(Kt,{label:"Text color",colors:sm,value:(X=m==null?void 0:m.viewProps)==null?void 0:X.textColor,onPick:G=>I(J=>{var te;return(te=r.onNodeColorChange)==null?void 0:te.call(r,J,"text",G)}),onReset:()=>I(G=>{var J;return(J=r.onNodeColorChange)==null?void 0:J.call(r,G,"text","")})})]}),p&&f("icon")&&h.jsxs(h.Fragment,{children:[h.jsx(ur,{}),h.jsx(qu,{nodeId:e[0],value:(se=m==null?void 0:m.config)==null?void 0:se.icon},e[0]),h.jsx(Qr,{ariaLabel:"Node icon",placeholder:"(e.g. PiGear)",width:"120px",value:((Q=m==null?void 0:m.config)==null?void 0:Q.icon)||"",onCommit:G=>{var J;return(J=r.onNodeIconChange)==null?void 0:J.call(r,e[0],G)}})]}),p&&x&&f("collapse")&&w!==void 0&&h.jsxs(h.Fragment,{children:[h.jsx(ur,{}),h.jsx(je,{label:w?"Expand":"Collapse",children:h.jsx(ve,{"aria-label":w?"Expand node":"Collapse node",icon:h.jsx(F.Icon,{as:w?Z.PiArrowsOutLineVertical:Z.PiArrowsInLineVertical,boxSize:5}),size:"sm",variant:"ghost",color:u,onClick:()=>{var G;return(G=r.onNodeCollapse)==null?void 0:G.call(r,e[0],!w)}})})]}),f("delete")&&h.jsxs(h.Fragment,{children:[h.jsx(ur,{}),h.jsx(je,{label:p?"Delete node":`Delete ${e.length} nodes`,children:h.jsx(ve,{"aria-label":"Delete selected nodes",icon:h.jsx(F.Icon,{as:Z.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:n==="dark"?"red.300":"red.500",onClick:()=>{I(G=>{var J,te;return(te=r.onNodeDelete)==null?void 0:te.call(r,G,((J=c.get(G))==null?void 0:J.data)||{id:G})}),t()}})})]})]})}async function fm(e){const{toSvg:t}=await Promise.resolve().then(()=>require("./index-sHQXTNv9.cjs"));await document.fonts.ready;const r=await t(e,{filter:o=>!(o instanceof Element)||!o.matches("button, [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(o=>o.remove()),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(n))}`}async function hm(e,t="squeed.svg"){const r=document.createElement("a");r.href=await fm(e),r.download=t.endsWith(".svg")?t:`${t}.svg`,r.click()}function pm(){const{themeColor:e}=Ie(),[t,r]=j.useState(!1),[n,o]=j.useState("");return h.jsxs(h.Fragment,{children:[h.jsx(je,{label:"Download SVG (current view)",children:h.jsx(ve,{"aria-label":"Download SVG",icon:h.jsx(Z.PiDownloadSimpleFill,{size:20}),disabled:t,borderRadius:"30%",color:e,variant:"ghost",onClick:async i=>{var s;const a=(s=i.currentTarget.closest("[data-flow-diagram]"))==null?void 0:s.querySelector("[data-flow-background]");if(!a){o("Diagram not available for export.");return}r(!0),o("");try{await hm(a)}catch(u){o(u instanceof Error?u.message:"Unable to export SVG.")}finally{r(!1)}}})}),n&&h.jsx("span",{role:"alert",style:{fontSize:12,maxWidth:220},children:n})]})}function gm({children:e,background:t,border:r}){const n=j.useRef(null),[o,i]=j.useState({left:!1,right:!1});j.useLayoutEffect(()=>{const s=n.current,u=()=>{const l=s.scrollLeft>1,d=s.scrollWidth-s.clientWidth-s.scrollLeft>1;i(f=>f.left===l&&f.right===d?f:{left:l,right:d})},c=new ResizeObserver(u);return c.observe(s),s.firstElementChild&&c.observe(s.firstElementChild),s.addEventListener("scroll",u,{passive:!0}),u(),()=>{c.disconnect(),s.removeEventListener("scroll",u)}},[]);const a=`var(--chakra-colors-${t.replace(".","-")})`;return h.jsxs(F.Box,{position:"relative",bg:t,minW:0,maxW:"100%",flex:"0 1 auto",borderRadius:"30px",css:Dr(a,`var(--chakra-colors-${r.replace(".","-")})`),children:[h.jsx(F.Box,{ref:n,"data-flow-toolbar-scroll":"",h:50,minH:50,alignContent:"center",overflowX:"auto",overflowY:"hidden",borderRadius:"inherit",css:{scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:e}),["left","right"].map(s=>h.jsx(F.Box,{"data-flow-toolbar-fade":s,"aria-hidden":"true",position:"absolute",top:0,bottom:0,w:"20px",pointerEvents:"none",borderRadius:s==="left"?"30px 0 0 30px":"0 30px 30px 0",style:{[s]:0,opacity:o[s]?1:0,background:`linear-gradient(to ${s==="left"?"right":"left"}, ${a}, transparent)`}},s))]})}async function s0(e,t){const r=new Set,n=[],o=(s,u)=>{var l,d,f;if(!s||typeof s!="object")return;const c=s;n.push(u),typeof((l=c.$form)==null?void 0:l.$type)=="string"&&r.add(c.$form.$type),typeof((f=(d=c.$form)==null?void 0:d.$create)==null?void 0:f.$type)=="string"&&r.add(c.$form.$create.$type);for(const[p,m]of Object.entries(c))p==="$"?o(m,u):p.startsWith("$")||o(m,`${u}.${p}`)};if(o(t,"root"),!r.size)return{contract:await rm(e)};const i=await Mu(e,[...r]);for(const s of r)if(!Object.prototype.hasOwnProperty.call(i,s))throw new Error(`Missing form type: ${s}`);const a={};for(const s of n){const u=gt(t,s,i);u&&(a[s]={type:u.type,optional:!1})}return{schema:i,contract:{name:e.name,nodes:a}}}function ym({message:e,onDismiss:t}){const{background:r,colorText:n,border:o}=Ve();return!e||typeof document>"u"?null:Ft.createPortal(h.jsxs(F.chakra.div,{role:"alert","aria-atomic":"true",css:Dr(fe(r),fe(o)),onPointerDown:i=>i.stopPropagation(),onClick:i=>i.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:fe(r),color:fe(n),fontSize:14,lineHeight:1.5},children:[h.jsx(Z.PiWarningCircle,{size:20,"aria-hidden":"true",style:{flexShrink:0,color:"#ef4444"}}),h.jsxs("div",{style:{flex:1,minWidth:0,overflowWrap:"anywhere"},children:[h.jsx("strong",{children:"Interface upload failed"}),h.jsx("div",{children:e})]}),h.jsx(pt,{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 mm({showDivider:e=!0,compact:t=!1}={}){const{edgeMode:r,setEdgeMode:n,workflowContract:o,setWorkflowContract:i,callbacks:a,readOnly:s,themeColor:u}=Ie(),{edgeById:c}=Gr(),{data:l,schema:d,setSchema:f,bindings:p,structured:m}=j.useContext(kr),y=(m==null?void 0:m.sourceBindings)??p,b=(m==null?void 0:m.sourceSchema)??d,{colorText:v}=Ve(),g=j.useRef(null),w=j.useRef(0),[x,_]=j.useState(!1),[C,S]=j.useState("");j.useEffect(()=>()=>{w.current++},[]),j.useEffect(()=>{w.current++,_(!1)},[s,l,y]);const T=o?[...c.values()].filter(E=>Iu(o,E.data)).length:0,k=o?`${o.name}: ${b?`${Object.keys(b).length} form types loaded; `:""}${T} invalid or unverified connections`:"";return h.jsxs(h.Fragment,{children:[h.jsx(ym,{message:C,onDismiss:()=>S("")}),e&&h.jsx(It,{}),h.jsxs(Or,{"aria-label":"Edge mode",title:r==="auto"?"Connections: Auto":r==="properties"?"Connections: Properties":"Connections: Nodes",icon:r==="auto"?h.jsx(Z.PiGraph,{size:20}):r==="properties"?h.jsx(Z.PiTable,{size:20}):h.jsx(Z.PiTreeStructure,{size:20}),style:{width:36},value:r,disabled:s,onValueChange:E=>{var R;const P=E==="auto"?"auto":E==="properties"?"properties":"nodes";n(P),(R=a.onEdgeModeChange)==null||R.call(a,P)},children:[h.jsx("option",{value:"auto",children:"Auto"}),h.jsx("option",{value:"nodes",children:"Nodes"}),h.jsx("option",{value:"properties",children:"Properties"})]}),h.jsxs("span",{style:{display:r==="auto"||r==="properties"?"contents":"none"},children:[h.jsx(je,{label:o?`Replace ${o.name}`:"Upload workflow interface",children:h.jsx(ve,{"aria-label":"Upload workflow interface",icon:h.jsx(Z.PiUploadSimple,{size:20}),color:fe(u),size:"sm",variant:"ghost",disabled:x||s,onClick:()=>{var E;return(E=g.current)==null?void 0:E.click()}})}),h.jsx("input",{ref:g,type:"file",hidden:!0,accept:".ts,.json","aria-label":"Workflow interface file",disabled:s||x,onChange:async E=>{var I,O;const P=(I=E.target.files)==null?void 0:I[0];if(E.target.value="",!P)return;const R=++w.current;_(!0),S("");try{const M=y?await Mu(P,[...new Set(Object.values(y).map(V=>V.schemaType??V.type))]):void 0;if(y&&M){for(const V of Object.values(y))if(!Object.prototype.hasOwnProperty.call(M,V.schemaType??V.type))throw new Error(`Missing form type: ${V.schemaType??V.type}`)}const{contract:q,schema:K}=y&&M?{schema:M,contract:{name:P.name,nodes:Object.fromEntries(Object.entries(y).map(([V,re])=>[V,{type:M[re.schemaType??re.type],optional:!1}]))}}:await s0(P,l);if(R!==w.current)return;f==null||f(K),i(q),(O=a.onWorkflowContractChange)==null||O.call(a,q)}catch(M){R===w.current&&S(`${P.name}: ${M instanceof Error?M.message:"Unable to load interface."}`)}finally{R===w.current&&_(!1)}}}),!t&&(k||x)&&h.jsx("span",{role:"status",title:k,style:{color:fe(v),fontSize:12,maxWidth:180,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:x?"Loading interface...":k}),!t&&o&&h.jsx(je,{label:"Remove workflow interface",children:h.jsx(ve,{"aria-label":"Remove workflow interface",icon:h.jsx(Z.PiX,{size:16}),size:"sm",variant:"ghost",disabled:s||x,onClick:()=>{var E;f==null||f(void 0),i(void 0),(E=a.onWorkflowContractChange)==null||E.call(a,void 0),S("")}})})]})]})}const c0=[{value:"BT",label:"Bottom to Up",icon:Z.PiArrowUp,flowType:Et.BOTTOM_UP},{value:"TB",label:"Top to Bottom",icon:Z.PiArrowDown,flowType:Et.TOP_DOWN},{value:"LR",label:"Left to Right",icon:Z.PiArrowRight,flowType:Et.LEFT_RIGHT},{value:"RL",label:"Right to Left",icon:Z.PiArrowLeft,flowType:Et.RIGHT_LEFT}],bm=()=>{const{engineRef:e,themeColor:t,setThemeColor:r,backgroundSelected:n,setBackgroundSelected:o,direction:i,edgeMode:a,selectedNodeIds:s,setSelectedNodeIds:u,selectedEdgeId:c,setSelectedEdgeId:l,isZoomMode:d,setIsZoomMode:f,isMultiSelectMode:p,setIsMultiSelectMode:m,isDragMode:y,setIsDragMode:b,isEdgeHandlesEnabled:v,setIsEdgeHandlesEnabled:g,isArrayNodeMode:w,setIsArrayNodeMode:x,isPinned:_,setIsPinned:C,callbacks:S,config:T,readOnly:k}=Ie(),{nodeById:E,edgeById:P,parentIds:R}=Gr(),I=T.colorMode==="dark",{background:O,border:M,colorInactive:q,colorText:K,colorActive:V}=Ve(),re=`var(--chakra-colors-${O.replace(".","-")})`,ce=`var(--chakra-colors-${(I?M:"gray.300").replace(".","-")})`,[he,me]=j.useState(!1),[H,N]=j.useState(!0),D=j.useRef(null),W=hy({edge:"bottom",enabled:!_,bounds:D,inside:[D]}),z=j.useCallback(be=>{const _e=e.current;if(!_e)return;const Xe=T.minZoom??.01,Ke=T.maxZoom??1.5,Ne=.02;let Qe=_e.zoom();switch(be){case"increase":Qe=Math.min(Ke,Qe+Ne),_e.zoom(Qe),_e.center();break;case"decrease":Qe=Math.max(Xe,Qe-Ne),_e.zoom(Qe),_e.center();break;case"reset":_e.fit(50);break}},[e,T.minZoom,T.maxZoom]),X=T.renderSelectedNodeToolbar,se=s.length>0&&!!X,Q=j.useMemo(()=>se?s.map(be=>{var Xe;return{...((Xe=E.get(be))==null?void 0:Xe.data)??{id:be},isParent:R.has(be)}}):[],[se,s,E,R]),G=j.useCallback(()=>{var be;u([]),(be=S.onNodeDeselect)==null||be.call(S)},[u,S]),J=T.renderSelectedEdgeToolbar,te=!!c&&!!J,le=j.useMemo(()=>{var be;return!te||!c?null:((be=P.get(c))==null?void 0:be.data)??{id:c}},[te,c,P]),de=j.useCallback(()=>{var be;l(null),(be=S.onEdgeDeselect)==null||be.call(S)},[l,S]),Re=T.selectionToolbar!==!1&&!k,ge=Re&&!!c&&!J,ze=Re&&!ge&&s.length>0&&!X,Fe=ge||ze,He=_||W||he||Fe;j.useEffect(()=>{s.length||c?o(!1):n&&!k&&(C(!0),N(!1))},[n,s.length,c,k,o,C]);const ar=T.renderBottomBar;return ar?h.jsxs(h.Fragment,{children:[se&&h.jsx(F.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:X({selectedNodeIds:s,selectedNodeData:Q,onDeselect:G})}),te&&le&&h.jsx(F.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:J({edgeId:c,edgeData:le,onDeselect:de})}),h.jsx(F.Box,{position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",children:ar({zoomIn:()=>z("increase"),zoomOut:()=>z("decrease"),resetZoom:()=>z("reset"),direction:i,isZoomMode:d,setIsZoomMode:f,isMultiSelectMode:p,setIsMultiSelectMode:m,isDragMode:y,setIsDragMode:b,isEdgeHandlesEnabled:v,setIsEdgeHandlesEnabled:g,isArrayNodeMode:w,setIsArrayNodeMode:x,selectedNodeIds:s,selectedNodeData:Q,selectedEdgeId:c,selectedEdgeData:le,onNodeDeselect:G,onEdgeDeselect:de,callbacks:S})})]}):h.jsxs(h.Fragment,{children:[se&&h.jsx(F.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:X({selectedNodeIds:s,selectedNodeData:Q,onDeselect:G})}),te&&le&&h.jsx(F.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:J({edgeId:c,edgeData:le,onDeselect:de})}),h.jsx(F.Box,{ref:D,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:He?"translateY(0)":"translateY(100%)",pointerEvents:He?"auto":"none",visibility:He?"visible":"hidden",opacity:He?1:0,children:h.jsxs(F.Flex,{w:"100%",px:5,position:"absolute",bottom:5,flexDirection:"row",justifyContent:"space-between",alignItems:"center",gap:"24px",children:[h.jsx(gm,{background:O,border:I?M:"gray.300",children:h.jsxs(F.HStack,{px:2,gap:1,flexWrap:"nowrap",w:"max-content",minW:"100%",h:"100%",css:{"& > *":{flexShrink:0}},children:[ge?h.jsx(um,{edgeId:c,onClose:de}):ze?h.jsx(dm,{ids:s,onClose:G}):null,h.jsxs("div",{style:{display:ge||ze?"none":"contents"},children:[h.jsx(je,{label:_?"Unpin":"Pin",children:h.jsx(ve,{"aria-label":"Pin",icon:h.jsx(F.Icon,{as:_?Z.PiPushPinFill:Z.PiPushPin,boxSize:5}),size:"sm",variant:"ghost",color:_?t:q,onClick:()=>{C(!_),me(!1)}})}),h.jsx(F.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:M}),h.jsx(je,{label:"Zoom Out",children:h.jsx(ve,{"aria-label":"Zoom out",icon:h.jsx(F.Icon,{as:Z.PiMinus,boxSize:5}),size:"sm",variant:"ghost",color:K,onClick:()=>z("decrease")})}),h.jsx(je,{label:"Zoom In",children:h.jsx(ve,{"aria-label":"Zoom in",icon:h.jsx(F.Icon,{as:Z.PiPlus,boxSize:5}),size:"sm",variant:"ghost",color:K,onClick:()=>z("increase")})}),h.jsx(je,{label:"Reset Zoom",children:h.jsx(ve,{"aria-label":"Reset zoom",icon:h.jsx(F.Icon,{as:Z.PiArrowCounterClockwise,boxSize:5}),size:"sm",variant:"ghost",color:K,onClick:()=>z("reset")})}),!H&&h.jsxs(h.Fragment,{children:[h.jsx(F.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:M}),h.jsx(je,{label:d?"Zoom Mode (z)":"Pan Mode (z)",children:h.jsx(ve,{"aria-label":"Toggle zoom mode",icon:h.jsx(F.Icon,{as:d?Z.PiMagnifyingGlassPlus:Z.PiArrowsOutCardinal,boxSize:5}),size:"sm",variant:"ghost",color:d?t:q,onClick:()=>f(!d)})}),h.jsx(F.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:M}),h.jsx(je,{label:p?"Multi-Select On (m)":"Multi-Select Off (m)",children:h.jsx(ve,{"aria-label":"Toggle multi-select",icon:h.jsx(F.Icon,{as:Z.PiSelectionPlus,boxSize:5}),size:"sm",variant:"ghost",color:p?t:q,onClick:()=>m(!p)})}),h.jsx(F.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:M}),h.jsx(je,{label:y?"Drag Mode On (d)":"Drag Mode Off (d)",children:h.jsx(ve,{"aria-label":"Toggle drag mode",icon:h.jsx(F.Icon,{as:Z.PiHandGrabbing,boxSize:5}),size:"sm",variant:"ghost",color:y?t:q,onClick:()=>b(!y)})}),T.edgeHandles!==!1&&h.jsxs(h.Fragment,{children:[h.jsx(F.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:M}),h.jsx(je,{label:v?"Draw Mode On":"Draw Mode Off",children:h.jsx(ve,{"aria-label":"Toggle draw mode",icon:h.jsx(F.Icon,{as:Z.PiPencilSimpleLine,boxSize:5}),size:"sm",variant:"ghost",color:v?t:q,onClick:()=>g(!v)})})]}),T.bottomBarExtra&&h.jsxs(h.Fragment,{children:[h.jsx(F.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:M,role:"separator","aria-orientation":"vertical"}),T.bottomBarExtra]}),h.jsx(F.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:M,role:"separator","aria-orientation":"vertical"}),h.jsx(zy,{}),a!=="properties"&&h.jsxs(h.Fragment,{children:[h.jsx(F.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:M}),h.jsx(je,{label:w?"Array Mode [ ]":"Set Mode { }",children:h.jsx(ve,{"aria-label":"Toggle array mode",icon:h.jsx(F.Icon,{as:w?Z.PiBracketsSquare:Z.PiBracketsCurly,boxSize:5}),size:"sm",variant:"ghost",color:w?t:q,onClick:()=>{var _e;const be=!w;x(be),(_e=S.onArrayModeChange)==null||_e.call(S,be)}})})]}),n&&!k&&h.jsxs(h.Fragment,{children:[h.jsx(F.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:M}),h.jsx(Kt,{label:"Graph theme",colors:Nu,value:t,includeTransparent:!1,onPick:be=>{var _e;r(be),(_e=S.onThemeColorChange)==null||_e.call(S,be)}})]}),h.jsx(mm,{}),h.jsx(Wy,{})]}),h.jsx(F.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:M}),h.jsx(je,{label:H?"Expand toolbar":"Collapse toolbar",children:h.jsx(ve,{"aria-label":"Toggle toolbar collapse",icon:h.jsx(F.Icon,{as:H?Z.PiCaretRight:Z.PiCaretLeft,boxSize:5}),size:"sm",variant:"ghost",color:q,onClick:()=>N(!H)})}),!H&&h.jsx(pm,{})]})]})}),!Fe&&h.jsxs(F.Box,{position:"relative",ml:"auto",flexShrink:0,children:[h.jsx(F.Box,{"data-flow-direction-control":"",bg:O,borderRadius:"30px",h:50,css:Dr(re,ce),px:3,cursor:"pointer",onClick:()=>me(!he),children:h.jsxs(F.Flex,{align:"center",h:"100%",children:[h.jsx(je,{label:"Flow Direction",children:h.jsx(ve,{"aria-label":"Direction",icon:h.jsx(F.Icon,{as:Z.PiCaretUp,boxSize:5}),size:"sm",variant:"ghost",color:q})}),h.jsx(F.Text,{fontSize:"xs",color:I?"whiteAlpha.600":"blackAlpha.500",ml:1,children:i})]})}),he&&h.jsx(F.Box,{position:"absolute",bottom:"100%",right:0,pb:"24px",zIndex:200,children:h.jsxs(F.Box,{bg:O,borderRadius:"30px",p:2,minW:"180px",css:Dr(re,ce),children:[c0.map(be=>h.jsxs(F.Flex,{align:"center",gap:3,px:3,py:2,borderRadius:"30px",cursor:"pointer",_hover:{bg:I?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var _e;(_e=S.onDirectionChange)==null||_e.call(S,be.value),me(!1)},children:[h.jsx(F.Icon,{as:be.icon,boxSize:5,color:K}),h.jsx(F.Text,{fontSize:"sm",color:K,flex:1,whiteSpace:"nowrap",children:be.label}),i===be.value&&h.jsx(F.Icon,{as:Z.PiCheck,boxSize:4,color:V})]},be.value)),h.jsxs(F.Flex,{align:"center",gap:3,px:3,py:2,borderRadius:"10px",cursor:"pointer",_hover:{bg:I?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var be;(be=S.onDirectionChange)==null||be.call(S,"C"),me(!1)},children:[h.jsx(F.Icon,{as:Z.PiAlignCenterHorizontal,boxSize:5,color:K}),h.jsx(F.Text,{fontSize:"sm",color:K,flex:1,whiteSpace:"nowrap",children:"Center"}),i==="C"&&h.jsx(F.Icon,{as:Z.PiCheck,boxSize:4,color:V})]})]})})]})]})})]})};bm.displayName="BottomBar";const vm=j.memo(bm);function u0({checked:e,onChange:t,disabled:r,label:n="Connected nodes"}){return h.jsx(Dy,{label:n,checked:e,onChange:t,disabled:r,icon:h.jsx(F.Icon,{as:Z.PiGraph,boxSize:5})})}const kl={$bgColor:"bgColor",$textColor:"textColor",$borderColor:"borderColor"};function xm(e,t){const r=new Map,n=(i,a)=>{if(Object.is(i,a))return!0;if(!i||!a||typeof i!="object"||typeof a!="object"||Array.isArray(i)!==Array.isArray(a))return!1;const s=Object.keys(i);return s.length===Object.keys(a).length&&s.every(u=>Object.prototype.hasOwnProperty.call(a,u)&&n(i[u],a[u]))},o=(i,a,s)=>{if(i===a)return!0;if(!i||!a||typeof i!="object"||typeof a!="object"||Array.isArray(i)!==Array.isArray(a))return!1;const u=new Set([...Object.keys(i),...Object.keys(a)]);for(const c of u)if(!n(i[c],a[c])){if(Object.prototype.hasOwnProperty.call(kl,c)){if(typeof a[c]!="string"||!a[c])return!1;r.set(s,{...r.get(s),[kl[c]]:a[c]})}else if(c.startsWith("$")&&c!=="$"||!o(i[c],a[c],c==="$"?s:`${s}.${c}`))return!1}return!0};if(o(e,t,"root"))return r}function l0(e,t){return xm(e,t)!==void 0}function d0(e,t,r){if(e===t)return r;const n=xm(e,t);if(!n)return;const o=new Set(r.nodes.map(i=>i.data.id));for(const i of n.keys())if(!o.has(i)||!xe(t,i))return;return{edges:r.edges,nodes:r.nodes.map(i=>{const a=n.get(i.data.id),s=xe(e,i.data.id),u=xe(t,i.data.id);return!a&&s===u?i:{...i,data:{...i.data,...typeof i.data.code=="string"?{code:JSON.stringify(u,null,2)}:{},...a?{viewProps:{...i.data.viewProps,...a},config:{...i.data.config,...a}}:{}}}})}}function xu(e){return e.kind==="literal"?e.value:e.kind==="union"?xu(e.types[0]):e.kind==="array"?[]:e.kind==="object"?Object.fromEntries(Object.entries(e.properties).filter(([,t])=>!t.optional).map(([t,r])=>[t,xu(r.type)])):e.kind==="boolean"?!1:e.kind==="number"||e.kind==="integer"?0:e.kind==="null"?null:""}function wm(e,t,r){var b,v,g;const n=(b=xe(e,t))==null?void 0:b.$form,o=n==null?void 0:n.$create;if(!o)return;const i=o.$address.split(".");if(i.shift()!=="root"||!i.length||i.some(w=>!/^[A-Za-z0-9_-]+$/.test(w)||["__proto__","constructor","prototype"].includes(w)))throw new Error("Invalid form creation address.");if(!r||!Object.prototype.hasOwnProperty.call(r,o.$type))throw new Error(`Load form type: ${o.$type}`);const a=i.pop(),s=["root",...i].join("."),u=gt(e,s,r),c=(v=u==null?void 0:u.type.properties[a])==null?void 0:v.type;if((c==null?void 0:c.kind)!=="array"||c.items.kind!=="object")throw new Error("Form creation must target an object-array field.");const l=r[o.$type],d=o.$defaults??{};for(const[w,x]of Object.entries(d))if(!Object.prototype.hasOwnProperty.call(l.properties,w)||Rr(l.properties[w].type,x,!l.properties[w].optional))throw new Error(`Invalid creation default: ${w}`);const f={...xu(l),...structuredClone(d)};((g=l.properties.id)==null?void 0:g.type.kind)==="string"&&(f.id=ju());let p=e;const m=xe(e,o.$address);if(m===void 0)p=pr(e,s,w=>({...w,[a]:[]}));else if(!Array.isArray(m)&&!Array.isArray(m==null?void 0:m.$))throw new Error("Form creation destination is not an array.");const y=Pu(p,o.$address,{...f,$label:o.$label??o.$type,...o.$icon?{$icon:o.$icon}:{},$form:{$type:o.$type,$create:o}});return{address:y.address,json:Au(y.json,t,{target:y.address,label:o.$edgeLabel})}}function f0(e,t){const r=o=>e&&typeof e=="object"&&o in e;let n=1;for(;r(`${t}_${n}`);)n++;return`${t}_${n}`}function Cm(e,t,r,n,o){const i=(s,u)=>{s!==e&&(e=s,n==null||n(s,u))},a=s=>{var c;const u=(c=t.find(l=>l.data.id===s))==null?void 0:c.data;return u&&{source:u.source,target:u.target,isInverted:u.isInverted,sourceProperty:u.sourceProperty,targetProperty:u.targetProperty,connection:u.connection}};return{...r,onFormChange:s=>{const u=xe(e,s.nodeAddress);if(!u||s.nodeId!==void 0&&u.id!==s.nodeId)throw new Error("This form node has moved. Retry the edit.");i(wn(e,s,r.onFormChange),{type:"form",address:s.address,value:s.value})},onNodeLabelChange:(s,u)=>{var c;(c=r.onNodeLabelChange)==null||c.call(r,s,u),i(ir(e,s,"$label",u),{type:"nodeLabel",address:s,key:"$label",value:u})},onNodeContentChange:(s,u)=>{var c;(c=r.onNodeContentChange)==null||c.call(r,s,u),i(ir(e,s,"$content",u),{type:"nodeContent",address:s,key:"$content",value:u})},onNodeTypeViewChange:(s,u)=>{var c;u!==void 0&&!Bt.includes(u)||((c=r.onNodeTypeViewChange)==null||c.call(r,s,u),i(ir(e,s,"$view",u),{type:"nodeStyle",address:s,key:"$view",value:u}))},onNodeColorChange:(s,u,c)=>{var d;(d=r.onNodeColorChange)==null||d.call(r,s,u,c);const l=u==="bg"?"$bgColor":"$textColor";i(ir(e,s,l,c),{type:"nodeColor",address:s,key:l,value:c})},onNodeBorderColorChange:(s,u)=>{var c;(c=r.onNodeBorderColorChange)==null||c.call(r,s,u),i(ir(e,s,"$borderColor",u),{type:"nodeColor",address:s,key:"$borderColor",value:u})},onNodeBorderStyleChange:(s,u)=>{var c;(c=r.onNodeBorderStyleChange)==null||c.call(r,s,u),i(ir(e,s,"$borderStyle",u),{type:"nodeStyle",address:s,key:"$borderStyle",value:u})},onNodeBorderWidthChange:(s,u)=>{var c;u!==void 0&&(!Number.isFinite(u)||u<0)||((c=r.onNodeBorderWidthChange)==null||c.call(r,s,u),i(ir(e,s,"$borderWidth",u),{type:"nodeStyle",address:s,key:"$borderWidth",value:u}))},onNodeBorderRadiusChange:(s,u)=>{var c;u!==void 0&&(!Number.isFinite(u)||u<0)||((c=r.onNodeBorderRadiusChange)==null||c.call(r,s,u),i(ir(e,s,"$borderRadius",u),{type:"nodeStyle",address:s,key:"$borderRadius",value:u}))},onNodeIconChange:(s,u)=>{var c;(c=r.onNodeIconChange)==null||c.call(r,s,u),i(ir(e,s,"$icon",u),{type:"nodeIcon",address:s,key:"$icon",value:u})},onNodeOutlineChange:(s,u)=>{var c;(c=r.onNodeOutlineChange)==null||c.call(r,s,u),i(ir(e,s,"$outline",u),{type:"nodeOutline",address:s,key:"$outline",value:u})},onNodeAnimationChange:(s,u)=>{var c;(c=r.onNodeAnimationChange)==null||c.call(r,s,u),i(ir(e,s,"$isNodeAnimated",u),{type:"nodeAnimation",address:s,key:"$isNodeAnimated",value:u})},onNodeAnimationVariantChange:(s,u)=>{var c;u!=="traveling"&&u!=="pulse"||((c=r.onNodeAnimationVariantChange)==null||c.call(r,s,u),i(ir(e,s,"$nodeAnimationVariant",u),{type:"nodeAnimation",address:s,key:"$nodeAnimationVariant",value:u}))},onNodeCollapse:(s,u)=>{var c;(c=r.onNodeCollapse)==null||c.call(r,s,u),i(Zy(e,s,u),{type:"nodeCollapse",address:s,key:"$collapsed",value:u})},onNodeCreate:s=>{var p,m;const u=s.sourceNodeId&&wm(e,s.sourceNodeId,o);if(u){(p=r.onNodeCreate)==null||p.call(r,s),i(u.json,{type:"nodeCreate",address:u.address,value:"form"});return}(m=r.onNodeCreate)==null||m.call(r,s);const c=s.sourceNodeId||"root",l=xe(e,c),d=f0(l,s.isArrayMode?"list":"node"),f=Pu(e,c,s.isArrayMode?[]:{},d);i(f.json,{type:"nodeCreate",address:f.address,value:s.isArrayMode?"array":"set"})},onNodeDelete:(s,u)=>{var c;(c=r.onNodeDelete)==null||c.call(r,s,u),i(Yy(e,s),{type:"nodeDelete",address:s})},onEdgeCreate:(s,u,c)=>{var d;(d=r.onEdgeCreate)==null||d.call(r,s,u,c);const l=c&&(c.sourceProperty!==void 0||c.targetProperty!==void 0)?{...c,target:u}:void 0;i(l?Au(e,s,l):Xy(e,s,u),{type:"edgeCreate",address:s,key:l?"$connections":"$target",value:l??u})},onEdgeLabelChange:(s,u)=>{var l;(l=r.onEdgeLabelChange)==null||l.call(r,s,u);const c=a(s);c&&i(Fr(e,c,"$sourceLabel",u),{type:"edgeLabel",edge:c,key:c.connection?"$connections":"$sourceLabel",value:u})},onEdgeStyleChange:(s,u)=>{var l;(l=r.onEdgeStyleChange)==null||l.call(r,s,u);const c=a(s);c&&i(Jy(e,c,u),{type:"edgeStyle",edge:c,value:u})},onEdgeAnimationVariantChange:(s,u)=>{var l;if(u!=="dashed"&&u!=="traveling")return;(l=r.onEdgeAnimationVariantChange)==null||l.call(r,s,u);const c=a(s);c&&i(Fr(e,c,"$edgeAnimationVariant",u),{type:"edgeStyle",edge:c,key:c.connection?"$connections":"$edgeAnimationVariant",value:u})},onEdgeTypeChange:(s,u)=>{var l;(l=r.onEdgeTypeChange)==null||l.call(r,s,u);const c=a(s);c&&i(Fr(e,c,"$edgeType",u),{type:"edgeStyle",edge:c,key:c.connection?"$connections":"$edgeType",value:u})},onEdgeIconChange:(s,u)=>{var l;(l=r.onEdgeIconChange)==null||l.call(r,s,u);const c=a(s);c&&i(Fr(e,c,"$edgeIcon",u||void 0),{type:"edgeStyle",edge:c,key:c.connection?"$connections":"$edgeIcon",value:u})},onEdgeColorChange:(s,u)=>{var l;(l=r.onEdgeColorChange)==null||l.call(r,s,u);const c=a(s);c&&i(Fr(e,c,"$edgeColor",u),{type:"edgeColor",edge:c,key:c.connection?"$connections":"$edgeColor",value:u})},onEdgeDelete:(s,u)=>{var d;(d=r.onEdgeDelete)==null||d.call(r,s,u);const c=a(s);if(!c)return;const l=Qy(e,c);l.removed&&i(l.json,{type:"edgeDelete",edge:c,key:c.connection?"$connections":"$target"})}}}const h0=".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 p0({path:e,color:t,width:r,reversed:n}){return h.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 g0=".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 _m({x:e=0,y:t=0,width:r,height:n,radius:o,color:i,strokeWidth:a=8,path:s,variant:u="traveling"}){const c=j.useId(),l=`flow-sdk-node-border-animation${u==="pulse"?" flow-sdk-node-border-pulse":""}`;if(u==="pulse"){const d=s?"path":"rect",f=s?{d:s}:{x:e,y:t,width:Math.max(0,r),height:Math.max(0,n),rx:Math.max(0,Math.min(o,r/2,n/2))},p=a+36,m={x:e-p,y:t-p,width:r+2*p,height:n+2*p};return h.jsxs("g",{"aria-hidden":"true",pointerEvents:"none",children:[h.jsx("defs",{children:h.jsxs("mask",{id:c,maskUnits:"userSpaceOnUse",...m,style:{maskType:"luminance"},children:[h.jsx("rect",{...m,fill:"white"}),h.jsx(d,{...f,fill:"black",stroke:"black",strokeWidth:a,strokeLinejoin:"round"})]})}),h.jsx(d,{...f,className:l,"data-animation-variant":u,fill:"none",stroke:`color-mix(in srgb, ${i} 60%, transparent)`,strokeLinejoin:"round",mask:`url(#${c})`,style:{"--flow-pulse-rest-width":`${a+16}px`,"--flow-pulse-expanded-width":`${a+36}px`}})]})}return s?h.jsx("path",{className:l,"data-animation-variant":u,"aria-hidden":"true",pointerEvents:"none",d:s,fill:"none",stroke:i,strokeWidth:a,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"}):h.jsx("rect",{className:l,"data-animation-variant":u,"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(o,r/2,n/2)),fill:"none",stroke:i,strokeWidth:a,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"})}const y0=e=>{const n=1/(Math.cbrt(e)*.8);let o=Math.round(650*n),i=Math.round(350*n);return o=Math.max(40,Math.min(450,o)),i=Math.max(30,Math.min(300,i)),{edgeSep:o,rankSep:i}};function Pl(e,t,r){const n=new Set([e]),o=[e];for(;o.length;){const i=o.pop();for(const a of t)(a.parent===i||a.id.startsWith(`${i}.`)||r.some(u=>(u.inverted?u.target:u.source)===i&&(u.inverted?u.source:u.target)===a.id))&&!n.has(a.id)&&(n.add(a.id),o.push(a.id))}return n}function m0(e,t,r){const n=r==="downward"||r==="upward",o=new Map;for(const a of e){if(a.source===a.target||a.sourceProperty||a.targetProperty)continue;const s=t(a.source),u=t(a.target);if(!s||!u)continue;const c=n?u.y-s.y:u.x-s.x,l=Math.abs(c)-(n?s.h+u.h:s.w+u.w)/2;if(l<=320)continue;const d=JSON.stringify([a.source,Math.sign(c)]),f=o.get(d)??[];f.push({edge:a,gap:l,cross:n?u.x-s.x:u.y-s.y}),o.set(d,f)}const i=new Map;for(const a of o.values()){if(new Set(a.map(({edge:u})=>u.target)).size<2)continue;const s=new Map;for(const{edge:u}of a)s.set(u.target,(s.get(u.target)??0)+1);for(const u of[-1,0,1]){const c=a.filter(({cross:d})=>Math.sign(d)===u);c.sort((d,f)=>Math.abs(f.cross)-Math.abs(d.cross)||d.edge.id.localeCompare(f.edge.id));const l=Math.min(...c.map(({gap:d})=>d));c.forEach(({edge:d,gap:f,cross:p},m)=>{const y=c.length===1?l/2:120+(l-280)*m/(c.length-1),b=c.find(v=>Math.abs(v.cross)<Math.abs(p));i.set(d.id,{turn:y/f,labelAtTarget:s.get(d.target)===1,labelFraction:p?(p+((b==null?void 0:b.cross)??0))/(2*p):.5})})}}return i}const st=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}),b0=e=>({x:(e.x1+e.x2)/2,y:(e.y1+e.y2)/2,w:e.x2-e.x1,h:e.y2-e.y1});function Yn(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 v0=(e,t)=>e.x1<=t.x2&&e.x2>=t.x1&&e.y1<=t.y2&&e.y2>=t.y1,Al=(e,t)=>e.x>=t.x1&&e.x<=t.x2&&e.y>=t.y1&&e.y<=t.y2,lr=e=>(Math.round(e*10)/10).toString(),Ge=e=>`${lr(e.x)} ${lr(e.y)}`,x0=e=>e>0?1:e<0?-1:0,Tl=(e,t)=>e>0?Math.max(e-t,0):Math.min(e+t,0);function w0(e,t,r,n,o=10){const i=t.x-e.x,a=t.y-e.y,s=Tl(i,(e.w+t.w)/2),u=Tl(a,(e.h+t.h)/2),c=r==="downward"||r==="upward",l=c?u:s,d=c?a:i,f=x0(d),p=n*l,m=g=>Math.abs(g)<o||Math.abs(g)>=Math.abs(l),y=m(p)||m(Math.abs(l)-Math.abs(p));let b;if(y)if(c)if(Math.abs(d)<=e.h/2){const g=(e.x+t.x)/2;b=[g,e.y,g,t.y]}else if(Math.abs(i)<=t.w/2){const g=(e.y+t.y)/2;b=[e.x,g,t.x,g]}else b=[e.x,t.y];else if(Math.abs(d)<=e.w/2){const g=(e.y+t.y)/2;b=[e.x,g,t.x,g]}else if(Math.abs(a)<=t.h/2){const g=(e.x+t.x)/2;b=[g,e.y,g,t.y]}else b=[t.x,e.y];else if(c){const g=e.y+p+e.h/2*f;b=[e.x,g,t.x,g]}else{const g=e.x+p+e.w/2*f;b=[g,e.y,g,t.y]}const v=[{x:e.x,y:e.y}];for(let g=0;g<b.length;g+=2)v.push({x:b[g],y:b[g+1]});return v.push({x:t.x,y:t.y}),v}function C0(e,t,r){const n=t.x-e.x,o=t.y-e.y,i=n>0?(r.x2-e.x)/n:n<0?(r.x1-e.x)/n:1/0,a=o>0?(r.y2-e.y)/o:o<0?(r.y1-e.y)/o:1/0,s=Math.min(i,a);return!Number.isFinite(s)||s>=1||s<0?null:{x:e.x+n*s,y:e.y+o*s}}function ht(e,t,r){var a;if(!((a=r.outline)!=null&&a.length))return C0(e,t,st(r));const n=t.x-e.x,o=t.y-e.y;let i=1/0;return r.outline.forEach((s,u,c)=>{const l=c[(u+1)%c.length],d=l.x-s.x,f=l.y-s.y,p=n*f-o*d;if(Math.abs(p)<1e-9)return;const m=s.x-e.x,y=s.y-e.y,b=(m*f-y*d)/p,v=(m*o-y*n)/p;b>=0&&b<1&&v>=-1e-9&&v<=1+1e-9&&(i=Math.min(i,b))}),Number.isFinite(i)?{x:e.x+n*i,y:e.y+o*i}:null}function Sm(e,t,r=.5){const n=Number.isFinite(r)?Math.max(0,Math.min(1,r)):.5,o=t==="top"||t==="bottom",i=t==="top"||t==="left"?-1:1,a={x:o?e.x-e.w/2+e.w*n:e.x,y:o?e.y:e.y-e.h/2+e.h*n},s=Math.max(e.w,e.h)*2+1;return{...ht(a,{x:a.x+(o?0:i*s),y:a.y+(o?i*s:0)},e)??{x:o?a.x:e.x+i*e.w/2,y:o?e.y+i*e.h/2:a.y},side:t}}function lt(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 _0(e,t,r,n){const o=lt(e,r.srcDist),i=lt(t,r.tgtDist);if(n==="straight")return jm(o,i,r);const a=Math.max(80,Math.min(300,Math.hypot(i.x-o.x,i.y-o.y)/3)),s=e.side==="bottom"&&t.side==="top"?i.y-o.y:e.side==="top"&&t.side==="bottom"?o.y-i.y:e.side==="right"&&t.side==="left"?i.x-o.x:e.side==="left"&&t.side==="right"?o.x-i.x:void 0,u=s!==void 0&&s>0?Math.min(a,s/2):a,c=lt({...o,side:e.side},u),l=lt({...i,side:t.side},u),d=r.arrowAt==="source"?rr(o,c,r.arrowGap):o,f=r.arrowAt==="target"?rr(i,l,r.arrowGap):i,p=r.arrowAt==="source"?br(o,c,r.arrowSize,r.headShape):r.arrowAt==="target"?br(i,l,r.arrowSize,r.headShape):void 0;if(n==="bezier")return{d:`M${Ge(d)} C${Ge(c)} ${Ge(l)} ${Ge(f)}`,arrow:p,label:{x:(d.x+3*c.x+3*l.x+f.x)/8,y:(d.y+3*c.y+3*l.y+f.y)/8,angle:0}};const m=e.side==="left"||e.side==="right",y=t.side==="left"||t.side==="right";let b;if(m!==y){const g=m?{x:l.x,y:c.y}:{x:c.x,y:l.y},w=(g.x-c.x)*(c.x-o.x)+(g.y-c.y)*(c.y-o.y)>=0,x=(g.x-l.x)*(l.x-i.x)+(g.y-l.y)*(l.y-i.y)>=0;b=[w&&x?g:m?{x:c.x,y:l.y}:{x:l.x,y:c.y}]}else if(s!==void 0&&s<=0)if(m){const g=(c.y+l.y)/2;b=[{x:c.x,y:g},{x:l.x,y:g}]}else{const g=(c.x+l.x)/2;b=[{x:g,y:c.y},{x:g,y:l.y}]}else if(m){const g=e.side===t.side?e.side==="right"?Math.max(c.x,l.x):Math.min(c.x,l.x):(c.x+l.x)/2;b=[{x:g,y:c.y},{x:g,y:l.y}]}else{const g=e.side===t.side?e.side==="bottom"?Math.max(c.y,l.y):Math.min(c.y,l.y):(c.y+l.y)/2;b=[{x:c.x,y:g},{x:l.x,y:g}]}const v=[c,...b,l].filter((g,w,x)=>w===0||g.x!==x[w-1].x||g.y!==x[w-1].y);return Cn(d,v,f,p,n==="orthogonal"?0:r.radius)}function rr(e,t,r){const n=e.x-t.x,o=e.y-t.y,i=Math.hypot(n,o);if(!i)return e;let a=(i-r)/i;return a<0&&(a=1e-5),{x:t.x+a*n,y:t.y+a*o}}function br(e,t,r,n="triangle"){const o=e.x-t.x,i=e.y-t.y,a=Math.hypot(o,i)||1,s=o/a,u=i/a,c=(n==="square"?.15:.3)*r,l=.15*r,d=e.x-s*c,f=e.y-u*c;return n==="square"?`M${Ge(e)} L${lr(e.x-u*l)} ${lr(e.y+s*l)} L${lr(d-u*l)} ${lr(f+s*l)} L${lr(d+u*l)} ${lr(f-s*l)} L${lr(e.x+u*l)} ${lr(e.y-s*l)} Z`:`M${Ge(e)} L${lr(d-u*l)} ${lr(f+s*l)} L${lr(d+u*l)} ${lr(f-s*l)} Z`}function Lr(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 S0(e,t,r,n){const o={x:t.x-e.x,y:t.y-e.y},i={x:r.x-t.x,y:r.y-t.y},a=Math.hypot(o.x,o.y),s=Math.hypot(i.x,i.y),u=o.x*i.y-o.y*i.x;if(a<1e-6||s<1e-6||Math.abs(u)<1e-6)return{p1:t,b:t,p2:t,r:0};const c=Math.min(n,a/2,s/2);return{p1:{x:t.x-o.x/a*c,y:t.y-o.y/a*c},b:t,p2:{x:t.x+i.x/s*c,y:t.y+i.y/s*c},r:c}}function Em(e,t,r,n){let o=-1,i=null;for(let m=0;m<e.length-1;m++){const y=ht(e[m],e[m+1],t);if(y){o=m,i=y;break}}let a=-1,s=null;for(let m=e.length-1;m>0;m--){const y=ht(e[m],e[m-1],r);if(y){a=m,s=y;break}}if(!i||!s||o>=a)return null;const u=e.slice(o+1,a),c=u[0]??s,l=u[u.length-1]??i;let d,f,p;if(n.arrowAt==="source"){const m=rr(i,c,n.srcDist);d=rr(i,c,n.srcDist+n.arrowGap),p=br(m,c,n.arrowSize,n.headShape)}else d=rr(i,c,n.srcDist);if(n.arrowAt==="target"){const m=rr(s,l,n.tgtDist);f=rr(s,l,n.tgtDist+n.arrowGap),p=br(m,l,n.arrowSize,n.headShape)}else f=rr(s,l,n.tgtDist);return Cn(d,u,f,p,n.radius,n.labelTargetLength,n.labelFraction)}function Cn(e,t,r,n,o,i,a){var f;const s=[e,...t,r],u=[];let c=`M${Ge(e)}`;for(let p=1;p<s.length-1;p++){const m=S0(s[p-1],s[p],s[p+1],o);u.push(m),m.r===0?c+=` L${Ge(m.b)}`:c+=` L${Ge(m.p1)} Q${Ge(m.b)} ${Ge(m.p2)}`}c+=` L${Ge(r)}`;let l;const d=t.length;if(d===0)l={x:(e.x+r.x)/2,y:(e.y+r.y)/2,angle:Lr(r.x-e.x,r.y-e.y)};else if(d%2===0){const p=t[d/2-1],m=t[d/2];l={x:(p.x+m.x)/2,y:(p.y+m.y)/2,angle:Lr(m.x-p.x,m.y-p.y)}}else{const p=u[(d-1)/2];if(p.r===0){const m=s[(d-1)/2+2];l={x:p.b.x,y:p.b.y,angle:Lr(m.x-p.b.x,m.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:Lr(p.p2.x-p.p1.x,p.p2.y-p.p1.y)}}if(i!==void 0){if(a!==void 0&&u.length===2){const b=u[0].p2,v=u[1].p1,g=Math.hypot(v.x-b.x,v.y-b.y),w=Math.min(.5,i/(2*g)),x=Math.max(w,Math.min(1-w,a));l={x:b.x+(v.x-b.x)*x,y:b.y+(v.y-b.y)*x,angle:Lr(v.x-b.x,v.y-b.y)}}const p=((f=u[u.length-1])==null?void 0:f.p2)??e,m=r.x-p.x,y=r.y-p.y;Math.hypot(m,y)>=i&&(l={x:(p.x+r.x)/2,y:(p.y+r.y)/2,angle:Lr(m,y)})}return{d:c,arrow:n,label:l}}function Ol(e,t,r,n,o,i,a){const s=r==="leftward"?-1:1,u={x:e.x+s*(e.w/2+a.srcDist),y:n??e.y},c={x:t.x-s*(t.w/2+a.tgtDist),y:o??t.y},l=Math.max(80,a.arrowGap+a.arrowSize*.3),d=u.x+s*l,f=c.x-s*l;let p;if(s*(f-d)>=0){const v=u.x+(c.x-u.x)*i,g=Math.max(Math.min(d,f),Math.min(Math.max(d,f),v));p=[{x:g,y:u.y},{x:g,y:c.y}]}else{const v=Math.min(e.y-e.h/2,t.y-t.h/2)-l*(1+i);p=[{x:d,y:u.y},{x:d,y:v},{x:f,y:v},{x:f,y:c.y}]}const m=a.arrowAt==="source"?rr(u,p[0],a.arrowGap):u,y=a.arrowAt==="target"?rr(c,p[p.length-1],a.arrowGap):c,b=a.arrowAt==="source"?br(u,p[0],a.arrowSize,a.headShape):a.arrowAt==="target"?br(c,p[p.length-1],a.arrowSize,a.headShape):void 0;return Cn(m,p,y,b,a.radius)}function Il(e,t,r,n,o){return Em(w0(e,t,r,n),e,t,o)}function Ml(e,t,r,n,o,i){const a=n===void 0&&o===void 0&&(r==="downward"||r==="upward"),s=r==="leftward"||a&&r==="upward"?-1:1,u=(c,l,d)=>{const f={x:c.x,y:l??c.y},p=Math.max(c.w,c.h)*2+1,m=ht(f,{x:f.x+(a?0:d*p),y:f.y+(a?d*p:0)},c);return m?{x:m.x+(a?0:d*i),y:m.y+(a?d*i:0)}:a?{x:c.x,y:c.y+d*(c.h/2+i)}:{x:c.x+d*(c.w/2+i),y:l??c.y}};return{sourcePoint:u(e,n,s),targetPoint:u(t,o,-s)}}function E0(e,t,r,n){const o=r==="downward"||r==="upward",i=r==="leftward"||r==="upward"?-1:1,a=Math.max(100,Math.abs(o?t.y-e.y:t.x-e.x)/2),s={x:e.x+(o?0:i*a),y:e.y+(o?i*a:0)},u={x:t.x-(o?0:i*a),y:t.y-(o?i*a:0)},c=n.arrowAt==="source"?rr(e,s,n.arrowGap):e,l=n.arrowAt==="target"?rr(t,u,n.arrowGap):t;return{d:`M${Ge(c)} C${Ge(s)} ${Ge(u)} ${Ge(l)}`,arrow:n.arrowAt==="source"?br(e,s,n.arrowSize,n.headShape):n.arrowAt==="target"?br(t,u,n.arrowSize,n.headShape):void 0,label:{x:(c.x+3*s.x+3*u.x+l.x)/8,y:(c.y+3*s.y+3*u.y+l.y)/8,angle:Lr(l.x+u.x-s.x-c.x,l.y+u.y-s.y-c.y)}}}function jm(e,t,r){const n=r.arrowAt==="source"?rr(e,t,r.arrowGap):e,o=r.arrowAt==="target"?rr(t,e,r.arrowGap):t,i=r.arrowAt==="source"?br(e,t,r.arrowSize,r.headShape):r.arrowAt==="target"?br(t,e,r.arrowSize,r.headShape):void 0;return Cn(n,[],o,i,0)}function j0(e,t,r,n=-90,o=-60,i=350){const a=n*Math.PI/180,s=o*Math.PI/180,u=a-Math.PI/2,c=u-s/2,l=u+s/2,d=1.4*i*(t/3+1),f={x:e.x+Math.cos(c)*d,y:e.y+Math.sin(c)*d},p={x:e.x+Math.cos(l)*d,y:e.y+Math.sin(l)*d},m={x:e.x,y:e.y},y=ht(m,f,e),b=ht(m,p,e);if(!y||!b)return null;const v={x:(f.x+p.x)/2,y:(f.y+p.y)/2};let g=rr(y,f,r.srcDist),w=rr(b,p,r.tgtDist),x;if(r.arrowAt==="target"){const C=w;w=rr(b,p,r.tgtDist+r.arrowGap),x=br(C,p,r.arrowSize,r.headShape)}else if(r.arrowAt==="source"){const C=g;g=rr(y,f,r.srcDist+r.arrowGap),x=br(C,f,r.arrowSize,r.headShape)}return{d:`M${Ge(g)} Q${Ge(f)} ${Ge(v)} Q${Ge(p)} ${Ge(w)}`,arrow:x,label:{x:v.x,y:v.y,angle:Lr(p.x-f.x,p.y-f.y)}}}const it=e=>Math.round(e*1e3)/1e3;function Rm(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 o=t.getBoundingClientRect();if(!o.width||!o.height)return;const i=t,a=typeof i.getScreenCTM=="function"?i.getScreenCTM():null,s=typeof i.getTotalLength=="function"?i.getTotalLength():0,u=i.points,c=(u==null?void 0:u.numberOfItems)||128,l=a&&s>0?Array.from({length:c},(d,f)=>{const p=u!=null&&u.numberOfItems?u.getItem(f):i.getPointAtLength(s*f/c);return{x:it((a.a*p.x+a.c*p.y+a.e-r.left)/n),y:it((a.b*p.x+a.d*p.y+a.f-r.top)/n)}}):void 0;return{left:it((o.left-r.left)/n),top:it((o.top-r.top)/n),width:t instanceof HTMLElement?t.offsetWidth:it(o.width/n),height:t instanceof HTMLElement?t.offsetHeight:it(o.height/n),radius:parseFloat(getComputedStyle(t).borderTopLeftRadius)||0,...l?{outline:l}:{}}}function Lt(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(o=>({x:r+o.x,y:n+o.y}))}:{}}}function R0(e,t,r,n,o){var l;const i=o!=="TB"&&o!=="BT",a=i?"top":"left",s=i?"bottom":"right",u=new Map;for(const d of n)for(const[f,p,m]of[[d.source,d.sourceProperty,d.target],[d.target,d.targetProperty,d.source]]){const y=t.get(m);if(p===void 0||!y||m===f)continue;const b=r.get(m),v=JSON.stringify([f,p]),g=u.get(v)??[];g.push(b?Lt(y,b):y),u.set(v,g)}const c=new Map(e);for(const[d,f]of e){const p=t.get(d);if(!p||!f.some(w=>w.placement==="config"))continue;const m=r.get(d),y=m?Lt(p,m):p,b={x:p.w/2,y:p.h/2,w:p.w,h:p.h},v=m?Lt(b,m):b,g=new Map;for(const w of f){if(w.placement!=="config")continue;const _=(u.get(JSON.stringify([d,w.property]))??[]).reduce((S,T)=>S+(i?T.y-y.y:T.x-y.x),0),C=((l=w.anchor)==null?void 0:l.side)===s?s:a;g.set(w,_<-.001?a:_>.001?s:C)}c.set(d,f.map(w=>{const x=g.get(w);if(!x)return w;const _=f.filter(T=>g.get(T)===x),C=(_.indexOf(w)+1)/(_.length+1),S=Sm(v,x,C);return{...w,anchor:S,top:S.y,height:0}}))}return c}function ql(e,t,r){const n=new Set(t.map(s=>s.id));if(!n.has(e))return new Set;const o=new Set([e]);let i=!0;for(;i;){i=!1;for(const s of t)!o.has(s.id)&&(o.has(s.parent??"")||s.id.startsWith(`${e}.`))&&(o.add(s.id),i=!0)}const a=new Set(o);for(const s of r)o.has(s.source)&&n.has(s.target)&&a.add(s.target),o.has(s.target)&&n.has(s.source)&&a.add(s.source);return a}const et='"Helvetica Neue", Helvetica, sans-serif';let St;const on=new Map;function _n(e,t){const r=`${t}|${e}`,n=on.get(r);if(n!==void 0)return n;St===void 0&&(St=typeof document<"u"?document.createElement("canvas").getContext("2d"):null);let o;return St?(St.font=t,o=St.measureText(e).width):o=e.length*(parseFloat(t)||16)*.55,on.size>5e3&&on.clear(),on.set(r,o),o}function k0(e,t,r){const n=[];for(const o of String(e).split(`
|
|
153
|
+
`)){const i=o.split(/\s+/).filter(Boolean);if(!i.length){n.push("");continue}let a="";for(const s of i){const u=a?`${a} ${s}`:s;!a||_n(u,t)<=r?a=u:(n.push(a),a=s)}n.push(a)}return n}const P0=e=>e.stopPropagation();function A0({id:e,rect:t,label:r,labelLayer:n,style:o,onSelect:i,onCollapse:a,selected:s=!1}){const u=t.x2-t.x1,c=t.y2-t.y1,l=o.borderWidth,d=o.borderStyle==="dashed"?`${l*4} ${l*2}`:o.borderStyle==="dotted"?`${l} ${l}`:void 0,f=t.x1+u/2,p=o.labelPosition==="top"?t.y1+o.labelMargin-o.fontSize/2:o.labelPosition==="bottom"?t.y2-o.labelMargin+o.fontSize/2:t.y1+c/2,m=r?_n(r,`bold ${o.fontSize}px ${et}`):0,y=o.fontSize/5,b=r||s&&a?h.jsxs("g",{className:"flow-sdk-container-label","data-node-id":e,children:[s&&a&&h.jsx("foreignObject",{x:f+m/2+y+8,y:p-24,width:48,height:48,"data-flow-content-toggle":"",style:{pointerEvents:"auto"},children:h.jsx(je,{label:"Show icon",children:h.jsx(ve,{"aria-label":"Show icon",icon:h.jsx(Z.PiCircleFill,{}),variant:"ghost",style:{width:48,height:48,color:o.textColor},onClick:v=>{v.stopPropagation(),a(e)}})})}),r&&h.jsxs(h.Fragment,{children:[h.jsx("rect",{x:f-m/2-y,y:p-o.fontSize/2-y,width:m+2*y,height:o.fontSize+2*y,fill:o.textColor==="transparent"?"transparent":o.labelBg}),h.jsx("text",{x:f,y:p,fill:o.textColor,fontSize:o.fontSize,fontWeight:"bold",fontFamily:et,style:{fontSize:o.fontSize,fontWeight:"bold",fontFamily:et},textAnchor:"middle",dominantBaseline:"central",children:r})]})]}):null;return h.jsxs("g",{className:"flow-sdk-container","data-node-id":e,onPointerDown:P0,onClick:v=>{v.stopPropagation(),i==null||i(e,{shiftKey:v.shiftKey,ctrlKey:v.ctrlKey,metaKey:v.metaKey,altKey:v.altKey})},children:[h.jsx("rect",{x:t.x1,y:t.y1,width:u,height:c,rx:o.borderRadius,ry:o.borderRadius,fill:o.bgColor,fillOpacity:o.bgOpacity,stroke:o.borderColor,strokeWidth:o.borderStyle==="double"?l/3:l,strokeDasharray:d}),o.borderStyle==="double"&&h.jsx("rect",{x:t.x1+l*2/3,y:t.y1+l*2/3,width:Math.max(0,u-l*4/3),height:Math.max(0,c-l*4/3),rx:Math.max(0,o.borderRadius-l*2/3),ry:Math.max(0,o.borderRadius-l*2/3),fill:"none",stroke:o.borderColor,strokeWidth:l/3}),o.animated&&l>0&&h.jsx(_m,{variant:o.animationVariant,x:t.x1,y:t.y1,width:u,height:c,radius:o.borderRadius,color:o.animationColor||o.borderColor,strokeWidth:Math.max(8,l*1.6)}),n&&b?Ft.createPortal(b,n):b]})}const T0=j.memo(A0),hn=45,km=70,Zr=15,Pm=50;function Am(e,t,r=hn){const n=`${r}px ${et}`,o=e?k0(e,n,200*r/hn):[],i=t?48+(o.length?12:0):0,a=i+Math.max(0,...o.map(c=>_n(c,n))),s=Math.max(o.length*r,t?48:0),u=o.length||t?2*Zr:0;return{lines:o,iconWidth:i,contentWidth:a,contentHeight:s,width:a+u,height:s+u}}const pn=6,Tm=3,$u=Math.max(Math.pow(pn*13.37,.9),29)*Tm,Om=pn*Tm*2,sn=80,O0=2*sn+$u*.3+100,I0=36+2*Math.max(80,Om+$u*.3);function wu(e){return e.sourceProperty!==void 0||e.targetProperty!==void 0}function Cu(e,t){return t==="auto"||(t==="properties"?wu(e):!wu(e))}function ct(e,t,r){return r!=="properties"||e!=="root"||t.some(n=>(n.source===e||n.target===e)&&wu(n))}function M0(e,t,r,n=!1,o){if(!n||r!=="properties"&&!o)return{nodes:e,edges:t};const i=e.filter(s=>ct(s.id,t,r)&&(!o||o.has(s.id))),a=new Set(i.map(s=>s.id));return{nodes:i,edges:t.filter(s=>Cu(s,r)&&a.has(s.source)&&a.has(s.target))}}const q0=500,N0="32 18",$0=e=>e.stopPropagation();function L0({id:e,edgeData:t,validationIssue:r,edgeType:n="rounded-orthogonal",edgeRadius:o,customEdgeTypes:i,source:a,target:s,sourceProperty:u,targetProperty:c,sourceY:l,targetY:d,sourcePort:f,targetPort:p,propertyMode:m=!1,dir:y,turn:b,labelAtTarget:v,labelFraction:g,color:w,labelBg:x,labelLayer:_,label:C,dashed:S,animated:T,inverted:k,loopIndex:E=0,onSelect:P}){const R=t==null?void 0:t.icon,I=m?hn:km,{lines:O,iconWidth:M,contentWidth:q,contentHeight:K}=j.useMemo(()=>Am(C,R,I),[C,R,I]),V=j.useMemo(()=>{const X={srcDist:sn,tgtDist:sn,arrowGap:Om,arrowSize:$u,headShape:m&&(k?l!==void 0||f:d!==void 0||p)?"square":"triangle",radius:o??(v?40:q0),arrowAt:k?"source":"target",labelTargetLength:v?q+2*Zr:void 0,labelFraction:v?g:void 0},se=l!==void 0||d!==void 0||!!f||!!p,Q=Ml(a,s,y,l,d,0),G=l===void 0&&d===void 0&&(y==="downward"||y==="upward"),J=f??{...Q.sourcePoint,side:G?y==="upward"?"top":"bottom":y==="leftward"?"left":"right"},te=p??{...Q.targetPoint,side:G?y==="upward"?"bottom":"top":y==="leftward"?"right":"left"},le=a.x===s.x&&a.y===s.y,de=f||p?_0(J,te,{...X,srcDist:18,tgtDist:18},n):se?Ol(a,s,y,l,d,b,{...X,srcDist:18,tgtDist:18,radius:o??Math.min(X.radius,40)}):le?j0(a,E,{...X,srcDist:0,tgtDist:0}):Il(a,s,y,b,X);if(!de)return null;const Re=Ml(a,s,y,l,d,se?18:sn);f&&(Re.sourcePoint=lt(f,18)),p&&(Re.targetPoint=lt(p,18));const ge=Object.prototype.hasOwnProperty.call(i??{},n)?i==null?void 0:i[n]:void 0;if(ge){const ze={rightward:"LR",leftward:"RL",downward:"TB",upward:"BT"};return ge({edge:t??{id:e,source:"",target:""},source:{...a},target:{...s},...Re,direction:ze[y],sourceY:l,targetY:d,inverted:!!k,defaultGeometry:de})??de}return le||f||p?de:n==="straight"?se?jm(Re.sourcePoint,Re.targetPoint,X):Em([a,s],a,s,X):n==="bezier"?E0(Re.sourcePoint,Re.targetPoint,se?y==="leftward"?"leftward":"rightward":y,X):n==="orthogonal"?se?Ol(a,s,y,l,d,b,{...X,srcDist:18,tgtDist:18,radius:0}):Il(a,s,y,b,{...X,radius:0}):de},[a,e,t,n,o,i,s,m,l,d,f,p,y,b,k,E,v,g,q]);if(!V)return null;const re=(y==="rightward"||y==="leftward")&&!Object.prototype.hasOwnProperty.call(i??{},n)&&!(m&&(l!==void 0||d!==void 0||f||p)),ce=re?`translate(${V.label.x} ${V.label.y-K/2-2*Zr})`:`translate(${V.label.x} ${V.label.y}) rotate(${V.label.angle}) translate(${v||Object.prototype.hasOwnProperty.call(i??{},n)?0:Pm} 0)`,he=r!=null&&r.startsWith("Unverified:")?"#b45309":"#dc2626",me=r?he:w,H=r?h.jsxs("g",{className:"flow-sdk-edge-validation",role:"img","aria-label":r,transform:`translate(${V.label.x} ${V.label.y-O.length*I/2-55})`,children:[h.jsx("title",{children:r}),h.jsx(Mr,{name:"PiWarningCircleFill",svg:!0,size:48,x:-24,y:-24,color:he})]}):null,N=T&&(t==null?void 0:t.edgeAnimationVariant)==="traveling",D=!N&&(S||T)?N0:void 0,W=T&&!N?`flow-sdk-edge-anim${k?" flow-sdk-edge-anim-rev":""}`:void 0;let z=null;if(O.length||R){const X=q,se=K;z=h.jsxs("g",{className:"flow-sdk-edge-label","data-label-transform":ce,"data-label-horizontal":re||void 0,"data-edge-id":e,"data-source-property":u,"data-target-property":c,transform:ce,children:[h.jsx("rect",{x:-X/2-Zr,y:-se/2-Zr,width:X+2*Zr,height:se+2*Zr,fill:w==="transparent"?"transparent":x}),h.jsx("text",{fill:w,fontSize:I,style:{fontSize:I,fontFamily:et},fontFamily:et,textAnchor:"middle",dominantBaseline:"central",children:O.map((Q,G)=>h.jsx("tspan",{x:M/2,y:(G-(O.length-1)/2)*I,children:Q},G))}),R&&h.jsxs("g",{className:"flow-sdk-edge-icon",opacity:w==="transparent"?0:1,children:[h.jsx("title",{children:C?`Edge icon: ${C}`:"Edge icon"}),h.jsx("rect",{x:-X/2,y:-24,width:48,height:48,fill:"transparent"}),h.jsx(Mr,{name:R,svg:!0,size:48,x:-X/2,y:-24,color:w})]})]})}return h.jsxs("g",{className:"flow-sdk-edge","data-edge-id":e,"data-source-property":u,"data-target-property":c,"data-validation":r?r.startsWith("Unverified:")?"unverified":"invalid":void 0,"aria-label":r,onPointerDown:$0,onClick:X=>{X.stopPropagation(),P==null||P(e)},children:[h.jsx("path",{d:V.d,fill:"none",stroke:me,strokeWidth:pn,strokeOpacity:N?.35:void 0,strokeDasharray:D,className:W}),N&&h.jsx(p0,{path:V.d,color:me,width:pn*1.6,reversed:k}),V.arrow&&h.jsx("path",{d:V.arrow,fill:me}),_&&z?Ft.createPortal(z,_):z,_&&H?Ft.createPortal(H,_):H,h.jsx("path",{className:"flow-sdk-edge-hit",d:V.d,fill:"none",stroke:"transparent"})]})}const Nl=j.memo(L0),$l=(e,t)=>e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top;function F0(e){const t=e.querySelector(".flow-sdk-labels"),r=t==null?void 0:t.getScreenCTM();if(!t||!r)return;const n=r.inverse(),o=(c,l=0)=>{const d=c.getBoundingClientRect(),f=new DOMPoint(d.left,d.top).matrixTransform(n),p=new DOMPoint(d.right,d.bottom).matrixTransform(n);return{left:f.x-l,right:p.x+l,top:f.y-l,bottom:p.y+l}},i=[...e.querySelectorAll(".flow-sdk-node, .flow-sdk-node button")].filter(c=>{const l=c.getBoundingClientRect(),d=getComputedStyle(c);return l.width>0&&l.height>0&&d.visibility!=="hidden"&&d.opacity!=="0"}).map(c=>o(c,24));for(const c of t.querySelectorAll(".flow-sdk-container-label"))i.push(o(c,12));const a=[...t.querySelectorAll(".flow-sdk-edge-label")];for(const c of a)c.setAttribute("transform",c.dataset.labelTransform??"");const s=new Map(a.map(c=>[c,o(c,8)])),u=new Map([...e.querySelectorAll(".flow-sdk-edge")].map(c=>[c.dataset.edgeId,c.querySelector("path")]));for(const c of a){const l=c.dataset.labelHorizontal==="true",d=s.get(c);s.delete(c);const f=S=>i.some(T=>$l(S,T))||[...s.values()].some(T=>$l(S,T));if(!l&&!f(d)){s.set(c,d);continue}const p=u.get(c.dataset.edgeId),m=c.querySelector("rect");if(!p||!m)continue;const y=m.getBBox(),b=p.getTotalLength();if(!Number.isFinite(b)||b<=0)continue;const v=(d.left+d.right)/2,g=(d.top+d.bottom)/2,w=Math.min(256,Math.max(16,Math.ceil(b/24))),x=Array.from({length:w+1},(S,T)=>p.getPointAtLength(b*T/w)),C=Array.from({length:w+1},(S,T)=>{const k=b*T/w,E=x[T],P=l?{x:E.x,y:E.y-y.height/2-15}:E,R=p.getPointAtLength(Math.max(0,k-2)),I=p.getPointAtLength(Math.min(b,k+2));let O=Math.atan2(I.y-R.y,I.x-R.x)*180/Math.PI;O>90&&(O-=180),O<-90&&(O+=180);const M=Math.abs(O)<1;l&&(O=0);const q=O*Math.PI/180,K=Math.abs(Math.cos(q))*y.width+Math.abs(Math.sin(q))*y.height,V=Math.abs(Math.sin(q))*y.width+Math.abs(Math.cos(q))*y.height;return{point:P,angle:O,straight:M,score:Math.hypot(P.x-v,P.y-g),bounds:{left:P.x-K/2-8,right:P.x+K/2+8,top:P.y-V/2-8,bottom:P.y+V/2+8}}}).sort((S,T)=>S.score-T.score).find(S=>!f(S.bounds)&&(!l||S.straight&&!x.some(T=>T.x>S.bounds.left&&T.x<S.bounds.right&&T.y>S.bounds.top&&T.y<S.bounds.bottom)));C?(c.setAttribute("transform",`translate(${C.point.x} ${C.point.y}) rotate(${C.angle})`),s.set(c,C.bounds)):s.set(c,d)}}var an=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function B0(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Lu(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 Xn,Ll;function D0(){if(Ll)return Xn;Ll=1;function e(){this.__data__=[],this.size=0}return Xn=e,Xn}var Qn,Fl;function yt(){if(Fl)return Qn;Fl=1;function e(t,r){return t===r||t!==t&&r!==r}return Qn=e,Qn}var eo,Bl;function Sn(){if(Bl)return eo;Bl=1;var e=yt();function t(r,n){for(var o=r.length;o--;)if(e(r[o][0],n))return o;return-1}return eo=t,eo}var ro,Dl;function z0(){if(Dl)return ro;Dl=1;var e=Sn(),t=Array.prototype,r=t.splice;function n(o){var i=this.__data__,a=e(i,o);if(a<0)return!1;var s=i.length-1;return a==s?i.pop():r.call(i,a,1),--this.size,!0}return ro=n,ro}var to,zl;function V0(){if(zl)return to;zl=1;var e=Sn();function t(r){var n=this.__data__,o=e(n,r);return o<0?void 0:n[o][1]}return to=t,to}var no,Vl;function W0(){if(Vl)return no;Vl=1;var e=Sn();function t(r){return e(this.__data__,r)>-1}return no=t,no}var oo,Wl;function G0(){if(Wl)return oo;Wl=1;var e=Sn();function t(r,n){var o=this.__data__,i=e(o,r);return i<0?(++this.size,o.push([r,n])):o[i][1]=n,this}return oo=t,oo}var io,Gl;function En(){if(Gl)return io;Gl=1;var e=D0(),t=z0(),r=V0(),n=W0(),o=G0();function i(a){var s=-1,u=a==null?0:a.length;for(this.clear();++s<u;){var c=a[s];this.set(c[0],c[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,io=i,io}var ao,Ul;function U0(){if(Ul)return ao;Ul=1;var e=En();function t(){this.__data__=new e,this.size=0}return ao=t,ao}var so,Hl;function H0(){if(Hl)return so;Hl=1;function e(t){var r=this.__data__,n=r.delete(t);return this.size=r.size,n}return so=e,so}var co,Kl;function K0(){if(Kl)return co;Kl=1;function e(t){return this.__data__.get(t)}return co=e,co}var uo,Zl;function Z0(){if(Zl)return uo;Zl=1;function e(t){return this.__data__.has(t)}return uo=e,uo}var lo,Jl;function Im(){if(Jl)return lo;Jl=1;var e=typeof an=="object"&&an&&an.Object===Object&&an;return lo=e,lo}var fo,Yl;function Sr(){if(Yl)return fo;Yl=1;var e=Im(),t=typeof self=="object"&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return fo=r,fo}var ho,Xl;function mt(){if(Xl)return ho;Xl=1;var e=Sr(),t=e.Symbol;return ho=t,ho}var po,Ql;function J0(){if(Ql)return po;Ql=1;var e=mt(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,o=e?e.toStringTag:void 0;function i(a){var s=r.call(a,o),u=a[o];try{a[o]=void 0;var c=!0}catch{}var l=n.call(a);return c&&(s?a[o]=u:delete a[o]),l}return po=i,po}var go,ed;function Y0(){if(ed)return go;ed=1;var e=Object.prototype,t=e.toString;function r(n){return t.call(n)}return go=r,go}var yo,rd;function rt(){if(rd)return yo;rd=1;var e=mt(),t=J0(),r=Y0(),n="[object Null]",o="[object Undefined]",i=e?e.toStringTag:void 0;function a(s){return s==null?s===void 0?o:n:i&&i in Object(s)?t(s):r(s)}return yo=a,yo}var mo,td;function vr(){if(td)return mo;td=1;function e(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}return mo=e,mo}var bo,nd;function Xt(){if(nd)return bo;nd=1;var e=rt(),t=vr(),r="[object AsyncFunction]",n="[object Function]",o="[object GeneratorFunction]",i="[object Proxy]";function a(s){if(!t(s))return!1;var u=e(s);return u==n||u==o||u==r||u==i}return bo=a,bo}var vo,od;function X0(){if(od)return vo;od=1;var e=Sr(),t=e["__core-js_shared__"];return vo=t,vo}var xo,id;function Q0(){if(id)return xo;id=1;var e=X0(),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 xo=r,xo}var wo,ad;function Mm(){if(ad)return wo;ad=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 wo=r,wo}var Co,sd;function ew(){if(sd)return Co;sd=1;var e=Xt(),t=Q0(),r=vr(),n=Mm(),o=/[\\^$.*+?()[\]{}|]/g,i=/^\[object .+?Constructor\]$/,a=Function.prototype,s=Object.prototype,u=a.toString,c=s.hasOwnProperty,l=RegExp("^"+u.call(c).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function d(f){if(!r(f)||t(f))return!1;var p=e(f)?l:i;return p.test(n(f))}return Co=d,Co}var _o,cd;function rw(){if(cd)return _o;cd=1;function e(t,r){return t==null?void 0:t[r]}return _o=e,_o}var So,ud;function tt(){if(ud)return So;ud=1;var e=ew(),t=rw();function r(n,o){var i=t(n,o);return e(i)?i:void 0}return So=r,So}var Eo,ld;function Fu(){if(ld)return Eo;ld=1;var e=tt(),t=Sr(),r=e(t,"Map");return Eo=r,Eo}var jo,dd;function jn(){if(dd)return jo;dd=1;var e=tt(),t=e(Object,"create");return jo=t,jo}var Ro,fd;function tw(){if(fd)return Ro;fd=1;var e=jn();function t(){this.__data__=e?e(null):{},this.size=0}return Ro=t,Ro}var ko,hd;function nw(){if(hd)return ko;hd=1;function e(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}return ko=e,ko}var Po,pd;function ow(){if(pd)return Po;pd=1;var e=jn(),t="__lodash_hash_undefined__",r=Object.prototype,n=r.hasOwnProperty;function o(i){var a=this.__data__;if(e){var s=a[i];return s===t?void 0:s}return n.call(a,i)?a[i]:void 0}return Po=o,Po}var Ao,gd;function iw(){if(gd)return Ao;gd=1;var e=jn(),t=Object.prototype,r=t.hasOwnProperty;function n(o){var i=this.__data__;return e?i[o]!==void 0:r.call(i,o)}return Ao=n,Ao}var To,yd;function aw(){if(yd)return To;yd=1;var e=jn(),t="__lodash_hash_undefined__";function r(n,o){var i=this.__data__;return this.size+=this.has(n)?0:1,i[n]=e&&o===void 0?t:o,this}return To=r,To}var Oo,md;function sw(){if(md)return Oo;md=1;var e=tw(),t=nw(),r=ow(),n=iw(),o=aw();function i(a){var s=-1,u=a==null?0:a.length;for(this.clear();++s<u;){var c=a[s];this.set(c[0],c[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,Oo=i,Oo}var Io,bd;function cw(){if(bd)return Io;bd=1;var e=sw(),t=En(),r=Fu();function n(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}return Io=n,Io}var Mo,vd;function uw(){if(vd)return Mo;vd=1;function e(t){var r=typeof t;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?t!=="__proto__":t===null}return Mo=e,Mo}var qo,xd;function Rn(){if(xd)return qo;xd=1;var e=uw();function t(r,n){var o=r.__data__;return e(n)?o[typeof n=="string"?"string":"hash"]:o.map}return qo=t,qo}var No,wd;function lw(){if(wd)return No;wd=1;var e=Rn();function t(r){var n=e(this,r).delete(r);return this.size-=n?1:0,n}return No=t,No}var $o,Cd;function dw(){if(Cd)return $o;Cd=1;var e=Rn();function t(r){return e(this,r).get(r)}return $o=t,$o}var Lo,_d;function fw(){if(_d)return Lo;_d=1;var e=Rn();function t(r){return e(this,r).has(r)}return Lo=t,Lo}var Fo,Sd;function hw(){if(Sd)return Fo;Sd=1;var e=Rn();function t(r,n){var o=e(this,r),i=o.size;return o.set(r,n),this.size+=o.size==i?0:1,this}return Fo=t,Fo}var Bo,Ed;function Bu(){if(Ed)return Bo;Ed=1;var e=cw(),t=lw(),r=dw(),n=fw(),o=hw();function i(a){var s=-1,u=a==null?0:a.length;for(this.clear();++s<u;){var c=a[s];this.set(c[0],c[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,Bo=i,Bo}var Do,jd;function pw(){if(jd)return Do;jd=1;var e=En(),t=Fu(),r=Bu(),n=200;function o(i,a){var s=this.__data__;if(s instanceof e){var u=s.__data__;if(!t||u.length<n-1)return u.push([i,a]),this.size=++s.size,this;s=this.__data__=new r(u)}return s.set(i,a),this.size=s.size,this}return Do=o,Do}var zo,Rd;function kn(){if(Rd)return zo;Rd=1;var e=En(),t=U0(),r=H0(),n=K0(),o=Z0(),i=pw();function a(s){var u=this.__data__=new e(s);this.size=u.size}return a.prototype.clear=t,a.prototype.delete=r,a.prototype.get=n,a.prototype.has=o,a.prototype.set=i,zo=a,zo}var Vo,kd;function Du(){if(kd)return Vo;kd=1;function e(t,r){for(var n=-1,o=t==null?0:t.length;++n<o&&r(t[n],n,t)!==!1;);return t}return Vo=e,Vo}var Wo,Pd;function qm(){if(Pd)return Wo;Pd=1;var e=tt(),t=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return Wo=t,Wo}var Go,Ad;function Pn(){if(Ad)return Go;Ad=1;var e=qm();function t(r,n,o){n=="__proto__"&&e?e(r,n,{configurable:!0,enumerable:!0,value:o,writable:!0}):r[n]=o}return Go=t,Go}var Uo,Td;function An(){if(Td)return Uo;Td=1;var e=Pn(),t=yt(),r=Object.prototype,n=r.hasOwnProperty;function o(i,a,s){var u=i[a];(!(n.call(i,a)&&t(u,s))||s===void 0&&!(a in i))&&e(i,a,s)}return Uo=o,Uo}var Ho,Od;function Qt(){if(Od)return Ho;Od=1;var e=An(),t=Pn();function r(n,o,i,a){var s=!i;i||(i={});for(var u=-1,c=o.length;++u<c;){var l=o[u],d=a?a(i[l],n[l],l,i,n):void 0;d===void 0&&(d=n[l]),s?t(i,l,d):e(i,l,d)}return i}return Ho=r,Ho}var Ko,Id;function gw(){if(Id)return Ko;Id=1;function e(t,r){for(var n=-1,o=Array(t);++n<t;)o[n]=r(n);return o}return Ko=e,Ko}var Zo,Md;function Pr(){if(Md)return Zo;Md=1;function e(t){return t!=null&&typeof t=="object"}return Zo=e,Zo}var Jo,qd;function yw(){if(qd)return Jo;qd=1;var e=rt(),t=Pr(),r="[object Arguments]";function n(o){return t(o)&&e(o)==r}return Jo=n,Jo}var Yo,Nd;function en(){if(Nd)return Yo;Nd=1;var e=yw(),t=Pr(),r=Object.prototype,n=r.hasOwnProperty,o=r.propertyIsEnumerable,i=e((function(){return arguments})())?e:function(a){return t(a)&&n.call(a,"callee")&&!o.call(a,"callee")};return Yo=i,Yo}var Xo,$d;function Ue(){if($d)return Xo;$d=1;var e=Array.isArray;return Xo=e,Xo}var At={exports:{}},Qo,Ld;function mw(){if(Ld)return Qo;Ld=1;function e(){return!1}return Qo=e,Qo}At.exports;var Fd;function bt(){return Fd||(Fd=1,(function(e,t){var r=Sr(),n=mw(),o=t&&!t.nodeType&&t,i=o&&!0&&e&&!e.nodeType&&e,a=i&&i.exports===o,s=a?r.Buffer:void 0,u=s?s.isBuffer:void 0,c=u||n;e.exports=c})(At,At.exports)),At.exports}var ei,Bd;function Tn(){if(Bd)return ei;Bd=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function r(n,o){var i=typeof n;return o=o??e,!!o&&(i=="number"||i!="symbol"&&t.test(n))&&n>-1&&n%1==0&&n<o}return ei=r,ei}var ri,Dd;function zu(){if(Dd)return ri;Dd=1;var e=9007199254740991;function t(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return ri=t,ri}var ti,zd;function bw(){if(zd)return ti;zd=1;var e=rt(),t=zu(),r=Pr(),n="[object Arguments]",o="[object Array]",i="[object Boolean]",a="[object Date]",s="[object Error]",u="[object Function]",c="[object Map]",l="[object Number]",d="[object Object]",f="[object RegExp]",p="[object Set]",m="[object String]",y="[object WeakMap]",b="[object ArrayBuffer]",v="[object DataView]",g="[object Float32Array]",w="[object Float64Array]",x="[object Int8Array]",_="[object Int16Array]",C="[object Int32Array]",S="[object Uint8Array]",T="[object Uint8ClampedArray]",k="[object Uint16Array]",E="[object Uint32Array]",P={};P[g]=P[w]=P[x]=P[_]=P[C]=P[S]=P[T]=P[k]=P[E]=!0,P[n]=P[o]=P[b]=P[i]=P[v]=P[a]=P[s]=P[u]=P[c]=P[l]=P[d]=P[f]=P[p]=P[m]=P[y]=!1;function R(I){return r(I)&&t(I.length)&&!!P[e(I)]}return ti=R,ti}var ni,Vd;function On(){if(Vd)return ni;Vd=1;function e(t){return function(r){return t(r)}}return ni=e,ni}var Tt={exports:{}};Tt.exports;var Wd;function Vu(){return Wd||(Wd=1,(function(e,t){var r=Im(),n=t&&!t.nodeType&&t,o=n&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===n,a=i&&r.process,s=(function(){try{var u=o&&o.require&&o.require("util").types;return u||a&&a.binding&&a.binding("util")}catch{}})();e.exports=s})(Tt,Tt.exports)),Tt.exports}var oi,Gd;function rn(){if(Gd)return oi;Gd=1;var e=bw(),t=On(),r=Vu(),n=r&&r.isTypedArray,o=n?t(n):e;return oi=o,oi}var ii,Ud;function Nm(){if(Ud)return ii;Ud=1;var e=gw(),t=en(),r=Ue(),n=bt(),o=Tn(),i=rn(),a=Object.prototype,s=a.hasOwnProperty;function u(c,l){var d=r(c),f=!d&&t(c),p=!d&&!f&&n(c),m=!d&&!f&&!p&&i(c),y=d||f||p||m,b=y?e(c.length,String):[],v=b.length;for(var g in c)(l||s.call(c,g))&&!(y&&(g=="length"||p&&(g=="offset"||g=="parent")||m&&(g=="buffer"||g=="byteLength"||g=="byteOffset")||o(g,v)))&&b.push(g);return b}return ii=u,ii}var ai,Hd;function In(){if(Hd)return ai;Hd=1;var e=Object.prototype;function t(r){var n=r&&r.constructor,o=typeof n=="function"&&n.prototype||e;return r===o}return ai=t,ai}var si,Kd;function $m(){if(Kd)return si;Kd=1;function e(t,r){return function(n){return t(r(n))}}return si=e,si}var ci,Zd;function vw(){if(Zd)return ci;Zd=1;var e=$m(),t=e(Object.keys,Object);return ci=t,ci}var ui,Jd;function Wu(){if(Jd)return ui;Jd=1;var e=In(),t=vw(),r=Object.prototype,n=r.hasOwnProperty;function o(i){if(!e(i))return t(i);var a=[];for(var s in Object(i))n.call(i,s)&&s!="constructor"&&a.push(s);return a}return ui=o,ui}var li,Yd;function qr(){if(Yd)return li;Yd=1;var e=Xt(),t=zu();function r(n){return n!=null&&t(n.length)&&!e(n)}return li=r,li}var di,Xd;function Ur(){if(Xd)return di;Xd=1;var e=Nm(),t=Wu(),r=qr();function n(o){return r(o)?e(o):t(o)}return di=n,di}var fi,Qd;function xw(){if(Qd)return fi;Qd=1;var e=Qt(),t=Ur();function r(n,o){return n&&e(o,t(o),n)}return fi=r,fi}var hi,ef;function ww(){if(ef)return hi;ef=1;function e(t){var r=[];if(t!=null)for(var n in Object(t))r.push(n);return r}return hi=e,hi}var pi,rf;function Cw(){if(rf)return pi;rf=1;var e=vr(),t=In(),r=ww(),n=Object.prototype,o=n.hasOwnProperty;function i(a){if(!e(a))return r(a);var s=t(a),u=[];for(var c in a)c=="constructor"&&(s||!o.call(a,c))||u.push(c);return u}return pi=i,pi}var gi,tf;function nt(){if(tf)return gi;tf=1;var e=Nm(),t=Cw(),r=qr();function n(o){return r(o)?e(o,!0):t(o)}return gi=n,gi}var yi,nf;function _w(){if(nf)return yi;nf=1;var e=Qt(),t=nt();function r(n,o){return n&&e(o,t(o),n)}return yi=r,yi}var Ot={exports:{}};Ot.exports;var of;function Lm(){return of||(of=1,(function(e,t){var r=Sr(),n=t&&!t.nodeType&&t,o=n&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===n,a=i?r.Buffer:void 0,s=a?a.allocUnsafe:void 0;function u(c,l){if(l)return c.slice();var d=c.length,f=s?s(d):new c.constructor(d);return c.copy(f),f}e.exports=u})(Ot,Ot.exports)),Ot.exports}var mi,af;function Fm(){if(af)return mi;af=1;function e(t,r){var n=-1,o=t.length;for(r||(r=Array(o));++n<o;)r[n]=t[n];return r}return mi=e,mi}var bi,sf;function Bm(){if(sf)return bi;sf=1;function e(t,r){for(var n=-1,o=t==null?0:t.length,i=0,a=[];++n<o;){var s=t[n];r(s,n,t)&&(a[i++]=s)}return a}return bi=e,bi}var vi,cf;function Dm(){if(cf)return vi;cf=1;function e(){return[]}return vi=e,vi}var xi,uf;function Gu(){if(uf)return xi;uf=1;var e=Bm(),t=Dm(),r=Object.prototype,n=r.propertyIsEnumerable,o=Object.getOwnPropertySymbols,i=o?function(a){return a==null?[]:(a=Object(a),e(o(a),function(s){return n.call(a,s)}))}:t;return xi=i,xi}var wi,lf;function Sw(){if(lf)return wi;lf=1;var e=Qt(),t=Gu();function r(n,o){return e(n,t(n),o)}return wi=r,wi}var Ci,df;function Uu(){if(df)return Ci;df=1;function e(t,r){for(var n=-1,o=r.length,i=t.length;++n<o;)t[i+n]=r[n];return t}return Ci=e,Ci}var _i,ff;function Mn(){if(ff)return _i;ff=1;var e=$m(),t=e(Object.getPrototypeOf,Object);return _i=t,_i}var Si,hf;function zm(){if(hf)return Si;hf=1;var e=Uu(),t=Mn(),r=Gu(),n=Dm(),o=Object.getOwnPropertySymbols,i=o?function(a){for(var s=[];a;)e(s,r(a)),a=t(a);return s}:n;return Si=i,Si}var Ei,pf;function Ew(){if(pf)return Ei;pf=1;var e=Qt(),t=zm();function r(n,o){return e(n,t(n),o)}return Ei=r,Ei}var ji,gf;function Vm(){if(gf)return ji;gf=1;var e=Uu(),t=Ue();function r(n,o,i){var a=o(n);return t(n)?a:e(a,i(n))}return ji=r,ji}var Ri,yf;function Wm(){if(yf)return Ri;yf=1;var e=Vm(),t=Gu(),r=Ur();function n(o){return e(o,r,t)}return Ri=n,Ri}var ki,mf;function jw(){if(mf)return ki;mf=1;var e=Vm(),t=zm(),r=nt();function n(o){return e(o,r,t)}return ki=n,ki}var Pi,bf;function Rw(){if(bf)return Pi;bf=1;var e=tt(),t=Sr(),r=e(t,"DataView");return Pi=r,Pi}var Ai,vf;function kw(){if(vf)return Ai;vf=1;var e=tt(),t=Sr(),r=e(t,"Promise");return Ai=r,Ai}var Ti,xf;function Gm(){if(xf)return Ti;xf=1;var e=tt(),t=Sr(),r=e(t,"Set");return Ti=r,Ti}var Oi,wf;function Pw(){if(wf)return Oi;wf=1;var e=tt(),t=Sr(),r=e(t,"WeakMap");return Oi=r,Oi}var Ii,Cf;function vt(){if(Cf)return Ii;Cf=1;var e=Rw(),t=Fu(),r=kw(),n=Gm(),o=Pw(),i=rt(),a=Mm(),s="[object Map]",u="[object Object]",c="[object Promise]",l="[object Set]",d="[object WeakMap]",f="[object DataView]",p=a(e),m=a(t),y=a(r),b=a(n),v=a(o),g=i;return(e&&g(new e(new ArrayBuffer(1)))!=f||t&&g(new t)!=s||r&&g(r.resolve())!=c||n&&g(new n)!=l||o&&g(new o)!=d)&&(g=function(w){var x=i(w),_=x==u?w.constructor:void 0,C=_?a(_):"";if(C)switch(C){case p:return f;case m:return s;case y:return c;case b:return l;case v:return d}return x}),Ii=g,Ii}var Mi,_f;function Aw(){if(_f)return Mi;_f=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n){var o=n.length,i=new n.constructor(o);return o&&typeof n[0]=="string"&&t.call(n,"index")&&(i.index=n.index,i.input=n.input),i}return Mi=r,Mi}var qi,Sf;function Um(){if(Sf)return qi;Sf=1;var e=Sr(),t=e.Uint8Array;return qi=t,qi}var Ni,Ef;function Hu(){if(Ef)return Ni;Ef=1;var e=Um();function t(r){var n=new r.constructor(r.byteLength);return new e(n).set(new e(r)),n}return Ni=t,Ni}var $i,jf;function Tw(){if(jf)return $i;jf=1;var e=Hu();function t(r,n){var o=n?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.byteLength)}return $i=t,$i}var Li,Rf;function Ow(){if(Rf)return Li;Rf=1;var e=/\w*$/;function t(r){var n=new r.constructor(r.source,e.exec(r));return n.lastIndex=r.lastIndex,n}return Li=t,Li}var Fi,kf;function Iw(){if(kf)return Fi;kf=1;var e=mt(),t=e?e.prototype:void 0,r=t?t.valueOf:void 0;function n(o){return r?Object(r.call(o)):{}}return Fi=n,Fi}var Bi,Pf;function Hm(){if(Pf)return Bi;Pf=1;var e=Hu();function t(r,n){var o=n?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.length)}return Bi=t,Bi}var Di,Af;function Mw(){if(Af)return Di;Af=1;var e=Hu(),t=Tw(),r=Ow(),n=Iw(),o=Hm(),i="[object Boolean]",a="[object Date]",s="[object Map]",u="[object Number]",c="[object RegExp]",l="[object Set]",d="[object String]",f="[object Symbol]",p="[object ArrayBuffer]",m="[object DataView]",y="[object Float32Array]",b="[object Float64Array]",v="[object Int8Array]",g="[object Int16Array]",w="[object Int32Array]",x="[object Uint8Array]",_="[object Uint8ClampedArray]",C="[object Uint16Array]",S="[object Uint32Array]";function T(k,E,P){var R=k.constructor;switch(E){case p:return e(k);case i:case a:return new R(+k);case m:return t(k,P);case y:case b:case v:case g:case w:case x:case _:case C:case S:return o(k,P);case s:return new R;case u:case d:return new R(k);case c:return r(k);case l:return new R;case f:return n(k)}}return Di=T,Di}var zi,Tf;function Km(){if(Tf)return zi;Tf=1;var e=vr(),t=Object.create,r=(function(){function n(){}return function(o){if(!e(o))return{};if(t)return t(o);n.prototype=o;var i=new n;return n.prototype=void 0,i}})();return zi=r,zi}var Vi,Of;function Zm(){if(Of)return Vi;Of=1;var e=Km(),t=Mn(),r=In();function n(o){return typeof o.constructor=="function"&&!r(o)?e(t(o)):{}}return Vi=n,Vi}var Wi,If;function qw(){if(If)return Wi;If=1;var e=vt(),t=Pr(),r="[object Map]";function n(o){return t(o)&&e(o)==r}return Wi=n,Wi}var Gi,Mf;function Nw(){if(Mf)return Gi;Mf=1;var e=qw(),t=On(),r=Vu(),n=r&&r.isMap,o=n?t(n):e;return Gi=o,Gi}var Ui,qf;function $w(){if(qf)return Ui;qf=1;var e=vt(),t=Pr(),r="[object Set]";function n(o){return t(o)&&e(o)==r}return Ui=n,Ui}var Hi,Nf;function Lw(){if(Nf)return Hi;Nf=1;var e=$w(),t=On(),r=Vu(),n=r&&r.isSet,o=n?t(n):e;return Hi=o,Hi}var Ki,$f;function Jm(){if($f)return Ki;$f=1;var e=kn(),t=Du(),r=An(),n=xw(),o=_w(),i=Lm(),a=Fm(),s=Sw(),u=Ew(),c=Wm(),l=jw(),d=vt(),f=Aw(),p=Mw(),m=Zm(),y=Ue(),b=bt(),v=Nw(),g=vr(),w=Lw(),x=Ur(),_=nt(),C=1,S=2,T=4,k="[object Arguments]",E="[object Array]",P="[object Boolean]",R="[object Date]",I="[object Error]",O="[object Function]",M="[object GeneratorFunction]",q="[object Map]",K="[object Number]",V="[object Object]",re="[object RegExp]",ce="[object Set]",he="[object String]",me="[object Symbol]",H="[object WeakMap]",N="[object ArrayBuffer]",D="[object DataView]",W="[object Float32Array]",z="[object Float64Array]",X="[object Int8Array]",se="[object Int16Array]",Q="[object Int32Array]",G="[object Uint8Array]",J="[object Uint8ClampedArray]",te="[object Uint16Array]",le="[object Uint32Array]",de={};de[k]=de[E]=de[N]=de[D]=de[P]=de[R]=de[W]=de[z]=de[X]=de[se]=de[Q]=de[q]=de[K]=de[V]=de[re]=de[ce]=de[he]=de[me]=de[G]=de[J]=de[te]=de[le]=!0,de[I]=de[O]=de[H]=!1;function Re(ge,ze,Fe,He,ar,be){var _e,Xe=ze&C,Ke=ze&S,Ne=ze&T;if(Fe&&(_e=ar?Fe(ge,He,ar,be):Fe(ge)),_e!==void 0)return _e;if(!g(ge))return ge;var Qe=y(ge);if(Qe){if(_e=f(ge),!Xe)return a(ge,_e)}else{var Ze=d(ge),gr=Ze==O||Ze==M;if(b(ge))return i(ge,Xe);if(Ze==V||Ze==k||gr&&!ar){if(_e=Ke||gr?{}:m(ge),!Xe)return Ke?u(ge,o(_e,ge)):s(ge,n(_e,ge))}else{if(!de[Ze])return ar?ge:{};_e=p(ge,Ze,Xe)}}be||(be=new e);var fr=be.get(ge);if(fr)return fr;be.set(ge,_e),w(ge)?ge.forEach(function(or){_e.add(Re(or,ze,Fe,or,ge,be))}):v(ge)&&ge.forEach(function(or,sr){_e.set(sr,Re(or,ze,Fe,sr,ge,be))});var Er=Ne?Ke?l:c:Ke?_:x,we=Qe?void 0:Er(ge);return t(we||ge,function(or,sr){we&&(sr=or,or=ge[sr]),r(_e,sr,Re(or,ze,Fe,sr,ge,be))}),_e}return Ki=Re,Ki}var Zi,Lf;function Fw(){if(Lf)return Zi;Lf=1;var e=Jm(),t=4;function r(n){return e(n,t)}return Zi=r,Zi}var Ji,Ff;function Ku(){if(Ff)return Ji;Ff=1;function e(t){return function(){return t}}return Ji=e,Ji}var Yi,Bf;function Bw(){if(Bf)return Yi;Bf=1;function e(t){return function(r,n,o){for(var i=-1,a=Object(r),s=o(r),u=s.length;u--;){var c=s[t?u:++i];if(n(a[c],c,a)===!1)break}return r}}return Yi=e,Yi}var Xi,Df;function Zu(){if(Df)return Xi;Df=1;var e=Bw(),t=e();return Xi=t,Xi}var Qi,zf;function Ju(){if(zf)return Qi;zf=1;var e=Zu(),t=Ur();function r(n,o){return n&&e(n,o,t)}return Qi=r,Qi}var ea,Vf;function Dw(){if(Vf)return ea;Vf=1;var e=qr();function t(r,n){return function(o,i){if(o==null)return o;if(!e(o))return r(o,i);for(var a=o.length,s=n?a:-1,u=Object(o);(n?s--:++s<a)&&i(u[s],s,u)!==!1;);return o}}return ea=t,ea}var ra,Wf;function qn(){if(Wf)return ra;Wf=1;var e=Ju(),t=Dw(),r=t(e);return ra=r,ra}var ta,Gf;function ot(){if(Gf)return ta;Gf=1;function e(t){return t}return ta=e,ta}var na,Uf;function Ym(){if(Uf)return na;Uf=1;var e=ot();function t(r){return typeof r=="function"?r:e}return na=t,na}var oa,Hf;function Xm(){if(Hf)return oa;Hf=1;var e=Du(),t=qn(),r=Ym(),n=Ue();function o(i,a){var s=n(i)?e:t;return s(i,r(a))}return oa=o,oa}var ia,Kf;function Qm(){return Kf||(Kf=1,ia=Xm()),ia}var aa,Zf;function zw(){if(Zf)return aa;Zf=1;var e=qn();function t(r,n){var o=[];return e(r,function(i,a,s){n(i,a,s)&&o.push(i)}),o}return aa=t,aa}var sa,Jf;function Vw(){if(Jf)return sa;Jf=1;var e="__lodash_hash_undefined__";function t(r){return this.__data__.set(r,e),this}return sa=t,sa}var ca,Yf;function Ww(){if(Yf)return ca;Yf=1;function e(t){return this.__data__.has(t)}return ca=e,ca}var ua,Xf;function eb(){if(Xf)return ua;Xf=1;var e=Bu(),t=Vw(),r=Ww();function n(o){var i=-1,a=o==null?0:o.length;for(this.__data__=new e;++i<a;)this.add(o[i])}return n.prototype.add=n.prototype.push=t,n.prototype.has=r,ua=n,ua}var la,Qf;function Gw(){if(Qf)return la;Qf=1;function e(t,r){for(var n=-1,o=t==null?0:t.length;++n<o;)if(r(t[n],n,t))return!0;return!1}return la=e,la}var da,eh;function rb(){if(eh)return da;eh=1;function e(t,r){return t.has(r)}return da=e,da}var fa,rh;function tb(){if(rh)return fa;rh=1;var e=eb(),t=Gw(),r=rb(),n=1,o=2;function i(a,s,u,c,l,d){var f=u&n,p=a.length,m=s.length;if(p!=m&&!(f&&m>p))return!1;var y=d.get(a),b=d.get(s);if(y&&b)return y==s&&b==a;var v=-1,g=!0,w=u&o?new e:void 0;for(d.set(a,s),d.set(s,a);++v<p;){var x=a[v],_=s[v];if(c)var C=f?c(_,x,v,s,a,d):c(x,_,v,a,s,d);if(C!==void 0){if(C)continue;g=!1;break}if(w){if(!t(s,function(S,T){if(!r(w,T)&&(x===S||l(x,S,u,c,d)))return w.push(T)})){g=!1;break}}else if(!(x===_||l(x,_,u,c,d))){g=!1;break}}return d.delete(a),d.delete(s),g}return fa=i,fa}var ha,th;function Uw(){if(th)return ha;th=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(o,i){n[++r]=[i,o]}),n}return ha=e,ha}var pa,nh;function Yu(){if(nh)return pa;nh=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(o){n[++r]=o}),n}return pa=e,pa}var ga,oh;function Hw(){if(oh)return ga;oh=1;var e=mt(),t=Um(),r=yt(),n=tb(),o=Uw(),i=Yu(),a=1,s=2,u="[object Boolean]",c="[object Date]",l="[object Error]",d="[object Map]",f="[object Number]",p="[object RegExp]",m="[object Set]",y="[object String]",b="[object Symbol]",v="[object ArrayBuffer]",g="[object DataView]",w=e?e.prototype:void 0,x=w?w.valueOf:void 0;function _(C,S,T,k,E,P,R){switch(T){case g:if(C.byteLength!=S.byteLength||C.byteOffset!=S.byteOffset)return!1;C=C.buffer,S=S.buffer;case v:return!(C.byteLength!=S.byteLength||!P(new t(C),new t(S)));case u:case c:case f:return r(+C,+S);case l:return C.name==S.name&&C.message==S.message;case p:case y:return C==S+"";case d:var I=o;case m:var O=k&a;if(I||(I=i),C.size!=S.size&&!O)return!1;var M=R.get(C);if(M)return M==S;k|=s,R.set(C,S);var q=n(I(C),I(S),k,E,P,R);return R.delete(C),q;case b:if(x)return x.call(C)==x.call(S)}return!1}return ga=_,ga}var ya,ih;function Kw(){if(ih)return ya;ih=1;var e=Wm(),t=1,r=Object.prototype,n=r.hasOwnProperty;function o(i,a,s,u,c,l){var d=s&t,f=e(i),p=f.length,m=e(a),y=m.length;if(p!=y&&!d)return!1;for(var b=p;b--;){var v=f[b];if(!(d?v in a:n.call(a,v)))return!1}var g=l.get(i),w=l.get(a);if(g&&w)return g==a&&w==i;var x=!0;l.set(i,a),l.set(a,i);for(var _=d;++b<p;){v=f[b];var C=i[v],S=a[v];if(u)var T=d?u(S,C,v,a,i,l):u(C,S,v,i,a,l);if(!(T===void 0?C===S||c(C,S,s,u,l):T)){x=!1;break}_||(_=v=="constructor")}if(x&&!_){var k=i.constructor,E=a.constructor;k!=E&&"constructor"in i&&"constructor"in a&&!(typeof k=="function"&&k instanceof k&&typeof E=="function"&&E instanceof E)&&(x=!1)}return l.delete(i),l.delete(a),x}return ya=o,ya}var ma,ah;function Zw(){if(ah)return ma;ah=1;var e=kn(),t=tb(),r=Hw(),n=Kw(),o=vt(),i=Ue(),a=bt(),s=rn(),u=1,c="[object Arguments]",l="[object Array]",d="[object Object]",f=Object.prototype,p=f.hasOwnProperty;function m(y,b,v,g,w,x){var _=i(y),C=i(b),S=_?l:o(y),T=C?l:o(b);S=S==c?d:S,T=T==c?d:T;var k=S==d,E=T==d,P=S==T;if(P&&a(y)){if(!a(b))return!1;_=!0,k=!1}if(P&&!k)return x||(x=new e),_||s(y)?t(y,b,v,g,w,x):r(y,b,S,v,g,w,x);if(!(v&u)){var R=k&&p.call(y,"__wrapped__"),I=E&&p.call(b,"__wrapped__");if(R||I){var O=R?y.value():y,M=I?b.value():b;return x||(x=new e),w(O,M,v,g,x)}}return P?(x||(x=new e),n(y,b,v,g,w,x)):!1}return ma=m,ma}var ba,sh;function nb(){if(sh)return ba;sh=1;var e=Zw(),t=Pr();function r(n,o,i,a,s){return n===o?!0:n==null||o==null||!t(n)&&!t(o)?n!==n&&o!==o:e(n,o,i,a,r,s)}return ba=r,ba}var va,ch;function Jw(){if(ch)return va;ch=1;var e=kn(),t=nb(),r=1,n=2;function o(i,a,s,u){var c=s.length,l=c,d=!u;if(i==null)return!l;for(i=Object(i);c--;){var f=s[c];if(d&&f[2]?f[1]!==i[f[0]]:!(f[0]in i))return!1}for(;++c<l;){f=s[c];var p=f[0],m=i[p],y=f[1];if(d&&f[2]){if(m===void 0&&!(p in i))return!1}else{var b=new e;if(u)var v=u(m,y,p,i,a,b);if(!(v===void 0?t(y,m,r|n,u,b):v))return!1}}return!0}return va=o,va}var xa,uh;function ob(){if(uh)return xa;uh=1;var e=vr();function t(r){return r===r&&!e(r)}return xa=t,xa}var wa,lh;function Yw(){if(lh)return wa;lh=1;var e=ob(),t=Ur();function r(n){for(var o=t(n),i=o.length;i--;){var a=o[i],s=n[a];o[i]=[a,s,e(s)]}return o}return wa=r,wa}var Ca,dh;function ib(){if(dh)return Ca;dh=1;function e(t,r){return function(n){return n==null?!1:n[t]===r&&(r!==void 0||t in Object(n))}}return Ca=e,Ca}var _a,fh;function Xw(){if(fh)return _a;fh=1;var e=Jw(),t=Yw(),r=ib();function n(o){var i=t(o);return i.length==1&&i[0][2]?r(i[0][0],i[0][1]):function(a){return a===o||e(a,o,i)}}return _a=n,_a}var Sa,hh;function xt(){if(hh)return Sa;hh=1;var e=rt(),t=Pr(),r="[object Symbol]";function n(o){return typeof o=="symbol"||t(o)&&e(o)==r}return Sa=n,Sa}var Ea,ph;function Xu(){if(ph)return Ea;ph=1;var e=Ue(),t=xt(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function o(i,a){if(e(i))return!1;var s=typeof i;return s=="number"||s=="symbol"||s=="boolean"||i==null||t(i)?!0:n.test(i)||!r.test(i)||a!=null&&i in Object(a)}return Ea=o,Ea}var ja,gh;function Qw(){if(gh)return ja;gh=1;var e=Bu(),t="Expected a function";function r(n,o){if(typeof n!="function"||o!=null&&typeof o!="function")throw new TypeError(t);var i=function(){var a=arguments,s=o?o.apply(this,a):a[0],u=i.cache;if(u.has(s))return u.get(s);var c=n.apply(this,a);return i.cache=u.set(s,c)||u,c};return i.cache=new(r.Cache||e),i}return r.Cache=e,ja=r,ja}var Ra,yh;function e1(){if(yh)return Ra;yh=1;var e=Qw(),t=500;function r(n){var o=e(n,function(a){return i.size===t&&i.clear(),a}),i=o.cache;return o}return Ra=r,Ra}var ka,mh;function r1(){if(mh)return ka;mh=1;var e=e1(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=e(function(o){var i=[];return o.charCodeAt(0)===46&&i.push(""),o.replace(t,function(a,s,u,c){i.push(u?c.replace(r,"$1"):s||a)}),i});return ka=n,ka}var Pa,bh;function Nn(){if(bh)return Pa;bh=1;function e(t,r){for(var n=-1,o=t==null?0:t.length,i=Array(o);++n<o;)i[n]=r(t[n],n,t);return i}return Pa=e,Pa}var Aa,vh;function t1(){if(vh)return Aa;vh=1;var e=mt(),t=Nn(),r=Ue(),n=xt(),o=e?e.prototype:void 0,i=o?o.toString:void 0;function a(s){if(typeof s=="string")return s;if(r(s))return t(s,a)+"";if(n(s))return i?i.call(s):"";var u=s+"";return u=="0"&&1/s==-1/0?"-0":u}return Aa=a,Aa}var Ta,xh;function ab(){if(xh)return Ta;xh=1;var e=t1();function t(r){return r==null?"":e(r)}return Ta=t,Ta}var Oa,wh;function $n(){if(wh)return Oa;wh=1;var e=Ue(),t=Xu(),r=r1(),n=ab();function o(i,a){return e(i)?i:t(i,a)?[i]:r(n(i))}return Oa=o,Oa}var Ia,Ch;function tn(){if(Ch)return Ia;Ch=1;var e=xt();function t(r){if(typeof r=="string"||e(r))return r;var n=r+"";return n=="0"&&1/r==-1/0?"-0":n}return Ia=t,Ia}var Ma,_h;function Ln(){if(_h)return Ma;_h=1;var e=$n(),t=tn();function r(n,o){o=e(o,n);for(var i=0,a=o.length;n!=null&&i<a;)n=n[t(o[i++])];return i&&i==a?n:void 0}return Ma=r,Ma}var qa,Sh;function n1(){if(Sh)return qa;Sh=1;var e=Ln();function t(r,n,o){var i=r==null?void 0:e(r,n);return i===void 0?o:i}return qa=t,qa}var Na,Eh;function o1(){if(Eh)return Na;Eh=1;function e(t,r){return t!=null&&r in Object(t)}return Na=e,Na}var $a,jh;function sb(){if(jh)return $a;jh=1;var e=$n(),t=en(),r=Ue(),n=Tn(),o=zu(),i=tn();function a(s,u,c){u=e(u,s);for(var l=-1,d=u.length,f=!1;++l<d;){var p=i(u[l]);if(!(f=s!=null&&c(s,p)))break;s=s[p]}return f||++l!=d?f:(d=s==null?0:s.length,!!d&&o(d)&&n(p,d)&&(r(s)||t(s)))}return $a=a,$a}var La,Rh;function cb(){if(Rh)return La;Rh=1;var e=o1(),t=sb();function r(n,o){return n!=null&&t(n,o,e)}return La=r,La}var Fa,kh;function i1(){if(kh)return Fa;kh=1;var e=nb(),t=n1(),r=cb(),n=Xu(),o=ob(),i=ib(),a=tn(),s=1,u=2;function c(l,d){return n(l)&&o(d)?i(a(l),d):function(f){var p=t(f,l);return p===void 0&&p===d?r(f,l):e(d,p,s|u)}}return Fa=c,Fa}var Ba,Ph;function ub(){if(Ph)return Ba;Ph=1;function e(t){return function(r){return r==null?void 0:r[t]}}return Ba=e,Ba}var Da,Ah;function a1(){if(Ah)return Da;Ah=1;var e=Ln();function t(r){return function(n){return e(n,r)}}return Da=t,Da}var za,Th;function s1(){if(Th)return za;Th=1;var e=ub(),t=a1(),r=Xu(),n=tn();function o(i){return r(i)?e(n(i)):t(i)}return za=o,za}var Va,Oh;function Nr(){if(Oh)return Va;Oh=1;var e=Xw(),t=i1(),r=ot(),n=Ue(),o=s1();function i(a){return typeof a=="function"?a:a==null?r:typeof a=="object"?n(a)?t(a[0],a[1]):e(a):o(a)}return Va=i,Va}var Wa,Ih;function lb(){if(Ih)return Wa;Ih=1;var e=Bm(),t=zw(),r=Nr(),n=Ue();function o(i,a){var s=n(i)?e:t;return s(i,r(a,3))}return Wa=o,Wa}var Ga,Mh;function c1(){if(Mh)return Ga;Mh=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n,o){return n!=null&&t.call(n,o)}return Ga=r,Ga}var Ua,qh;function db(){if(qh)return Ua;qh=1;var e=c1(),t=sb();function r(n,o){return n!=null&&t(n,o,e)}return Ua=r,Ua}var Ha,Nh;function u1(){if(Nh)return Ha;Nh=1;var e=Wu(),t=vt(),r=en(),n=Ue(),o=qr(),i=bt(),a=In(),s=rn(),u="[object Map]",c="[object Set]",l=Object.prototype,d=l.hasOwnProperty;function f(p){if(p==null)return!0;if(o(p)&&(n(p)||typeof p=="string"||typeof p.splice=="function"||i(p)||s(p)||r(p)))return!p.length;var m=t(p);if(m==u||m==c)return!p.size;if(a(p))return!e(p).length;for(var y in p)if(d.call(p,y))return!1;return!0}return Ha=f,Ha}var Ka,$h;function fb(){if($h)return Ka;$h=1;function e(t){return t===void 0}return Ka=e,Ka}var Za,Lh;function hb(){if(Lh)return Za;Lh=1;var e=qn(),t=qr();function r(n,o){var i=-1,a=t(n)?Array(n.length):[];return e(n,function(s,u,c){a[++i]=o(s,u,c)}),a}return Za=r,Za}var Ja,Fh;function pb(){if(Fh)return Ja;Fh=1;var e=Nn(),t=Nr(),r=hb(),n=Ue();function o(i,a){var s=n(i)?e:r;return s(i,t(a,3))}return Ja=o,Ja}var Ya,Bh;function l1(){if(Bh)return Ya;Bh=1;function e(t,r,n,o){var i=-1,a=t==null?0:t.length;for(o&&a&&(n=t[++i]);++i<a;)n=r(n,t[i],i,t);return n}return Ya=e,Ya}var Xa,Dh;function d1(){if(Dh)return Xa;Dh=1;function e(t,r,n,o,i){return i(t,function(a,s,u){n=o?(o=!1,a):r(n,a,s,u)}),n}return Xa=e,Xa}var Qa,zh;function gb(){if(zh)return Qa;zh=1;var e=l1(),t=qn(),r=Nr(),n=d1(),o=Ue();function i(a,s,u){var c=o(a)?e:n,l=arguments.length<3;return c(a,r(s,4),u,l,t)}return Qa=i,Qa}var es,Vh;function f1(){if(Vh)return es;Vh=1;var e=rt(),t=Ue(),r=Pr(),n="[object String]";function o(i){return typeof i=="string"||!t(i)&&r(i)&&e(i)==n}return es=o,es}var rs,Wh;function h1(){if(Wh)return rs;Wh=1;var e=ub(),t=e("length");return rs=t,rs}var ts,Gh;function p1(){if(Gh)return ts;Gh=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",o=t+r+n,i="\\ufe0e\\ufe0f",a="\\u200d",s=RegExp("["+a+e+o+i+"]");function u(c){return s.test(c)}return ts=u,ts}var ns,Uh;function g1(){if(Uh)return ns;Uh=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",o=t+r+n,i="\\ufe0e\\ufe0f",a="["+e+"]",s="["+o+"]",u="\\ud83c[\\udffb-\\udfff]",c="(?:"+s+"|"+u+")",l="[^"+e+"]",d="(?:\\ud83c[\\udde6-\\uddff]){2}",f="[\\ud800-\\udbff][\\udc00-\\udfff]",p="\\u200d",m=c+"?",y="["+i+"]?",b="(?:"+p+"(?:"+[l,d,f].join("|")+")"+y+m+")*",v=y+m+b,g="(?:"+[l+s+"?",s,d,f,a].join("|")+")",w=RegExp(u+"(?="+u+")|"+g+v,"g");function x(_){for(var C=w.lastIndex=0;w.test(_);)++C;return C}return ns=x,ns}var os,Hh;function y1(){if(Hh)return os;Hh=1;var e=h1(),t=p1(),r=g1();function n(o){return t(o)?r(o):e(o)}return os=n,os}var is,Kh;function m1(){if(Kh)return is;Kh=1;var e=Wu(),t=vt(),r=qr(),n=f1(),o=y1(),i="[object Map]",a="[object Set]";function s(u){if(u==null)return 0;if(r(u))return n(u)?o(u):u.length;var c=t(u);return c==i||c==a?u.size:e(u).length}return is=s,is}var as,Zh;function b1(){if(Zh)return as;Zh=1;var e=Du(),t=Km(),r=Ju(),n=Nr(),o=Mn(),i=Ue(),a=bt(),s=Xt(),u=vr(),c=rn();function l(d,f,p){var m=i(d),y=m||a(d)||c(d);if(f=n(f,4),p==null){var b=d&&d.constructor;y?p=m?new b:[]:u(d)?p=s(b)?t(o(d)):{}:p={}}return(y?e:r)(d,function(v,g,w){return f(p,v,g,w)}),p}return as=l,as}var ss,Jh;function v1(){if(Jh)return ss;Jh=1;var e=mt(),t=en(),r=Ue(),n=e?e.isConcatSpreadable:void 0;function o(i){return r(i)||t(i)||!!(n&&i&&i[n])}return ss=o,ss}var cs,Yh;function Qu(){if(Yh)return cs;Yh=1;var e=Uu(),t=v1();function r(n,o,i,a,s){var u=-1,c=n.length;for(i||(i=t),s||(s=[]);++u<c;){var l=n[u];o>0&&i(l)?o>1?r(l,o-1,i,a,s):e(s,l):a||(s[s.length]=l)}return s}return cs=r,cs}var us,Xh;function x1(){if(Xh)return us;Xh=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 us=e,us}var ls,Qh;function yb(){if(Qh)return ls;Qh=1;var e=x1(),t=Math.max;function r(n,o,i){return o=t(o===void 0?n.length-1:o,0),function(){for(var a=arguments,s=-1,u=t(a.length-o,0),c=Array(u);++s<u;)c[s]=a[o+s];s=-1;for(var l=Array(o+1);++s<o;)l[s]=a[s];return l[o]=i(c),e(n,this,l)}}return ls=r,ls}var ds,ep;function w1(){if(ep)return ds;ep=1;var e=Ku(),t=qm(),r=ot(),n=t?function(o,i){return t(o,"toString",{configurable:!0,enumerable:!1,value:e(i),writable:!0})}:r;return ds=n,ds}var fs,rp;function C1(){if(rp)return fs;rp=1;var e=800,t=16,r=Date.now;function n(o){var i=0,a=0;return function(){var s=r(),u=t-(s-a);if(a=s,u>0){if(++i>=e)return arguments[0]}else i=0;return o.apply(void 0,arguments)}}return fs=n,fs}var hs,tp;function mb(){if(tp)return hs;tp=1;var e=w1(),t=C1(),r=t(e);return hs=r,hs}var ps,np;function Fn(){if(np)return ps;np=1;var e=ot(),t=yb(),r=mb();function n(o,i){return r(t(o,i,e),o+"")}return ps=n,ps}var gs,op;function bb(){if(op)return gs;op=1;function e(t,r,n,o){for(var i=t.length,a=n+(o?1:-1);o?a--:++a<i;)if(r(t[a],a,t))return a;return-1}return gs=e,gs}var ys,ip;function _1(){if(ip)return ys;ip=1;function e(t){return t!==t}return ys=e,ys}var ms,ap;function S1(){if(ap)return ms;ap=1;function e(t,r,n){for(var o=n-1,i=t.length;++o<i;)if(t[o]===r)return o;return-1}return ms=e,ms}var bs,sp;function E1(){if(sp)return bs;sp=1;var e=bb(),t=_1(),r=S1();function n(o,i,a){return i===i?r(o,i,a):e(o,t,a)}return bs=n,bs}var vs,cp;function j1(){if(cp)return vs;cp=1;var e=E1();function t(r,n){var o=r==null?0:r.length;return!!o&&e(r,n,0)>-1}return vs=t,vs}var xs,up;function R1(){if(up)return xs;up=1;function e(t,r,n){for(var o=-1,i=t==null?0:t.length;++o<i;)if(n(r,t[o]))return!0;return!1}return xs=e,xs}var ws,lp;function k1(){if(lp)return ws;lp=1;function e(){}return ws=e,ws}var Cs,dp;function P1(){if(dp)return Cs;dp=1;var e=Gm(),t=k1(),r=Yu(),n=1/0,o=e&&1/r(new e([,-0]))[1]==n?function(i){return new e(i)}:t;return Cs=o,Cs}var _s,fp;function A1(){if(fp)return _s;fp=1;var e=eb(),t=j1(),r=R1(),n=rb(),o=P1(),i=Yu(),a=200;function s(u,c,l){var d=-1,f=t,p=u.length,m=!0,y=[],b=y;if(l)m=!1,f=r;else if(p>=a){var v=c?null:o(u);if(v)return i(v);m=!1,f=n,b=new e}else b=c?[]:y;e:for(;++d<p;){var g=u[d],w=c?c(g):g;if(g=l||g!==0?g:0,m&&w===w){for(var x=b.length;x--;)if(b[x]===w)continue e;c&&b.push(w),y.push(g)}else f(b,w,l)||(b!==y&&b.push(w),y.push(g))}return y}return _s=s,_s}var Ss,hp;function vb(){if(hp)return Ss;hp=1;var e=qr(),t=Pr();function r(n){return t(n)&&e(n)}return Ss=r,Ss}var Es,pp;function T1(){if(pp)return Es;pp=1;var e=Qu(),t=Fn(),r=A1(),n=vb(),o=t(function(i){return r(e(i,1,n,!0))});return Es=o,Es}var js,gp;function O1(){if(gp)return js;gp=1;var e=Nn();function t(r,n){return e(n,function(o){return r[o]})}return js=t,js}var Rs,yp;function xb(){if(yp)return Rs;yp=1;var e=O1(),t=Ur();function r(n){return n==null?[]:e(n,t(n))}return Rs=r,Rs}var ks,mp;function xr(){if(mp)return ks;mp=1;var e;if(typeof Lu=="function")try{e={clone:Fw(),constant:Ku(),each:Qm(),filter:lb(),has:db(),isArray:Ue(),isEmpty:u1(),isFunction:Xt(),isUndefined:fb(),keys:Ur(),map:pb(),reduce:gb(),size:m1(),transform:b1(),union:T1(),values:xb()}}catch{}return e||(e=window._),ks=e,ks}var Ps,bp;function el(){if(bp)return Ps;bp=1;var e=xr();Ps=o;var t="\0",r="\0",n="";function o(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={}}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(l){return this._label=l,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(l){return e.isFunction(l)||(l=e.constant(l)),this._defaultNodeLabelFn=l,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var l=this;return e.filter(this.nodes(),function(d){return e.isEmpty(l._in[d])})},o.prototype.sinks=function(){var l=this;return e.filter(this.nodes(),function(d){return e.isEmpty(l._out[d])})},o.prototype.setNodes=function(l,d){var f=arguments,p=this;return e.each(l,function(m){f.length>1?p.setNode(m,d):p.setNode(m)}),this},o.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)},o.prototype.node=function(l){return this._nodes[l]},o.prototype.hasNode=function(l){return e.has(this._nodes,l)},o.prototype.removeNode=function(l){var d=this;if(e.has(this._nodes,l)){var f=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]),f),delete this._in[l],delete this._preds[l],e.each(e.keys(this._out[l]),f),delete this._out[l],delete this._sucs[l],--this._nodeCount}return this},o.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 f=d;!e.isUndefined(f);f=this.parent(f))if(f===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},o.prototype._removeFromParentsChildList=function(l){delete this._children[this._parent[l]][l]},o.prototype.parent=function(l){if(this._isCompound){var d=this._parent[l];if(d!==r)return d}},o.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[]}},o.prototype.predecessors=function(l){var d=this._preds[l];if(d)return e.keys(d)},o.prototype.successors=function(l){var d=this._sucs[l];if(d)return e.keys(d)},o.prototype.neighbors=function(l){var d=this.predecessors(l);if(d)return e.union(d,this.successors(l))},o.prototype.isLeaf=function(l){var d;return this.isDirected()?d=this.successors(l):d=this.neighbors(l),d.length===0},o.prototype.filterNodes=function(l){var d=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});d.setGraph(this.graph());var f=this;e.each(this._nodes,function(y,b){l(b)&&d.setNode(b,y)}),e.each(this._edgeObjs,function(y){d.hasNode(y.v)&&d.hasNode(y.w)&&d.setEdge(y,f.edge(y))});var p={};function m(y){var b=f.parent(y);return b===void 0||d.hasNode(b)?(p[y]=b,b):b in p?p[b]:m(b)}return this._isCompound&&e.each(d.nodes(),function(y){d.setParent(y,m(y))}),d},o.prototype.setDefaultEdgeLabel=function(l){return e.isFunction(l)||(l=e.constant(l)),this._defaultEdgeLabelFn=l,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(l,d){var f=this,p=arguments;return e.reduce(l,function(m,y){return p.length>1?f.setEdge(m,y,d):f.setEdge(m,y),y}),this},o.prototype.setEdge=function(){var l,d,f,p,m=!1,y=arguments[0];typeof y=="object"&&y!==null&&"v"in y?(l=y.v,d=y.w,f=y.name,arguments.length===2&&(p=arguments[1],m=!0)):(l=y,d=arguments[1],f=arguments[3],arguments.length>2&&(p=arguments[2],m=!0)),l=""+l,d=""+d,e.isUndefined(f)||(f=""+f);var b=s(this._isDirected,l,d,f);if(e.has(this._edgeLabels,b))return m&&(this._edgeLabels[b]=p),this;if(!e.isUndefined(f)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(l),this.setNode(d),this._edgeLabels[b]=m?p:this._defaultEdgeLabelFn(l,d,f);var v=u(this._isDirected,l,d,f);return l=v.v,d=v.w,Object.freeze(v),this._edgeObjs[b]=v,i(this._preds[d],l),i(this._sucs[l],d),this._in[d][b]=v,this._out[l][b]=v,this._edgeCount++,this},o.prototype.edge=function(l,d,f){var p=arguments.length===1?c(this._isDirected,arguments[0]):s(this._isDirected,l,d,f);return this._edgeLabels[p]},o.prototype.hasEdge=function(l,d,f){var p=arguments.length===1?c(this._isDirected,arguments[0]):s(this._isDirected,l,d,f);return e.has(this._edgeLabels,p)},o.prototype.removeEdge=function(l,d,f){var p=arguments.length===1?c(this._isDirected,arguments[0]):s(this._isDirected,l,d,f),m=this._edgeObjs[p];return m&&(l=m.v,d=m.w,delete this._edgeLabels[p],delete this._edgeObjs[p],a(this._preds[d],l),a(this._sucs[l],d),delete this._in[d][p],delete this._out[l][p],this._edgeCount--),this},o.prototype.inEdges=function(l,d){var f=this._in[l];if(f){var p=e.values(f);return d?e.filter(p,function(m){return m.v===d}):p}},o.prototype.outEdges=function(l,d){var f=this._out[l];if(f){var p=e.values(f);return d?e.filter(p,function(m){return m.w===d}):p}},o.prototype.nodeEdges=function(l,d){var f=this.inEdges(l,d);if(f)return f.concat(this.outEdges(l,d))};function i(l,d){l[d]?l[d]++:l[d]=1}function a(l,d){--l[d]||delete l[d]}function s(l,d,f,p){var m=""+d,y=""+f;if(!l&&m>y){var b=m;m=y,y=b}return m+n+y+n+(e.isUndefined(p)?t:p)}function u(l,d,f,p){var m=""+d,y=""+f;if(!l&&m>y){var b=m;m=y,y=b}var v={v:m,w:y};return p&&(v.name=p),v}function c(l,d){return s(l,d.v,d.w,d.name)}return Ps}var As,vp;function I1(){return vp||(vp=1,As="2.1.8"),As}var Ts,xp;function M1(){return xp||(xp=1,Ts={Graph:el(),version:I1()}),Ts}var Os,wp;function q1(){if(wp)return Os;wp=1;var e=xr(),t=el();Os={write:r,read:i};function r(a){var s={options:{directed:a.isDirected(),multigraph:a.isMultigraph(),compound:a.isCompound()},nodes:n(a),edges:o(a)};return e.isUndefined(a.graph())||(s.value=e.clone(a.graph())),s}function n(a){return e.map(a.nodes(),function(s){var u=a.node(s),c=a.parent(s),l={v:s};return e.isUndefined(u)||(l.value=u),e.isUndefined(c)||(l.parent=c),l})}function o(a){return e.map(a.edges(),function(s){var u=a.edge(s),c={v:s.v,w:s.w};return e.isUndefined(s.name)||(c.name=s.name),e.isUndefined(u)||(c.value=u),c})}function i(a){var s=new t(a.options).setGraph(a.value);return e.each(a.nodes,function(u){s.setNode(u.v,u.value),u.parent&&s.setParent(u.v,u.parent)}),e.each(a.edges,function(u){s.setEdge({v:u.v,w:u.w,name:u.name},u.value)}),s}return Os}var Is,Cp;function N1(){if(Cp)return Is;Cp=1;var e=xr();Is=t;function t(r){var n={},o=[],i;function a(s){e.has(n,s)||(n[s]=!0,i.push(s),e.each(r.successors(s),a),e.each(r.predecessors(s),a))}return e.each(r.nodes(),function(s){i=[],a(s),i.length&&o.push(i)}),o}return Is}var Ms,_p;function wb(){if(_p)return Ms;_p=1;var e=xr();Ms=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 o=this._keyIndices;if(r=String(r),!e.has(o,r)){var i=this._arr,a=i.length;return o[r]=a,i.push({key:r,priority:n}),this._decrease(a),!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 o=this._keyIndices[r];if(n>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[o].priority+" New: "+n);this._arr[o].priority=n,this._decrease(o)},t.prototype._heapify=function(r){var n=this._arr,o=2*r,i=o+1,a=r;o<n.length&&(a=n[o].priority<n[a].priority?o:a,i<n.length&&(a=n[i].priority<n[a].priority?i:a),a!==r&&(this._swap(r,a),this._heapify(a)))},t.prototype._decrease=function(r){for(var n=this._arr,o=n[r].priority,i;r!==0&&(i=r>>1,!(n[i].priority<o));)this._swap(r,i),r=i},t.prototype._swap=function(r,n){var o=this._arr,i=this._keyIndices,a=o[r],s=o[n];o[r]=s,o[n]=a,i[s.key]=r,i[a.key]=n},Ms}var qs,Sp;function Cb(){if(Sp)return qs;Sp=1;var e=xr(),t=wb();qs=n;var r=e.constant(1);function n(i,a,s,u){return o(i,String(a),s||r,u||function(c){return i.outEdges(c)})}function o(i,a,s,u){var c={},l=new t,d,f,p=function(m){var y=m.v!==d?m.v:m.w,b=c[y],v=s(m),g=f.distance+v;if(v<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+m+" Weight: "+v);g<b.distance&&(b.distance=g,b.predecessor=d,l.decrease(y,g))};for(i.nodes().forEach(function(m){var y=m===a?0:Number.POSITIVE_INFINITY;c[m]={distance:y},l.add(m,y)});l.size()>0&&(d=l.removeMin(),f=c[d],f.distance!==Number.POSITIVE_INFINITY);)u(d).forEach(p);return c}return qs}var Ns,Ep;function $1(){if(Ep)return Ns;Ep=1;var e=Cb(),t=xr();Ns=r;function r(n,o,i){return t.transform(n.nodes(),function(a,s){a[s]=e(n,s,o,i)},{})}return Ns}var $s,jp;function _b(){if(jp)return $s;jp=1;var e=xr();$s=t;function t(r){var n=0,o=[],i={},a=[];function s(u){var c=i[u]={onStack:!0,lowlink:n,index:n++};if(o.push(u),r.successors(u).forEach(function(f){e.has(i,f)?i[f].onStack&&(c.lowlink=Math.min(c.lowlink,i[f].index)):(s(f),c.lowlink=Math.min(c.lowlink,i[f].lowlink))}),c.lowlink===c.index){var l=[],d;do d=o.pop(),i[d].onStack=!1,l.push(d);while(u!==d);a.push(l)}}return r.nodes().forEach(function(u){e.has(i,u)||s(u)}),a}return $s}var Ls,Rp;function L1(){if(Rp)return Ls;Rp=1;var e=xr(),t=_b();Ls=r;function r(n){return e.filter(t(n),function(o){return o.length>1||o.length===1&&n.hasEdge(o[0],o[0])})}return Ls}var Fs,kp;function F1(){if(kp)return Fs;kp=1;var e=xr();Fs=r;var t=e.constant(1);function r(o,i,a){return n(o,i||t,a||function(s){return o.outEdges(s)})}function n(o,i,a){var s={},u=o.nodes();return u.forEach(function(c){s[c]={},s[c][c]={distance:0},u.forEach(function(l){c!==l&&(s[c][l]={distance:Number.POSITIVE_INFINITY})}),a(c).forEach(function(l){var d=l.v===c?l.w:l.v,f=i(l);s[c][d]={distance:f,predecessor:c}})}),u.forEach(function(c){var l=s[c];u.forEach(function(d){var f=s[d];u.forEach(function(p){var m=f[c],y=l[p],b=f[p],v=m.distance+y.distance;v<b.distance&&(b.distance=v,b.predecessor=y.predecessor)})})}),s}return Fs}var Bs,Pp;function Sb(){if(Pp)return Bs;Pp=1;var e=xr();Bs=t,t.CycleException=r;function t(n){var o={},i={},a=[];function s(u){if(e.has(i,u))throw new r;e.has(o,u)||(i[u]=!0,o[u]=!0,e.each(n.predecessors(u),s),delete i[u],a.push(u))}if(e.each(n.sinks(),s),e.size(o)!==n.nodeCount())throw new r;return a}function r(){}return r.prototype=new Error,Bs}var Ds,Ap;function B1(){if(Ap)return Ds;Ap=1;var e=Sb();Ds=t;function t(r){try{e(r)}catch(n){if(n instanceof e.CycleException)return!1;throw n}return!0}return Ds}var zs,Tp;function Eb(){if(Tp)return zs;Tp=1;var e=xr();zs=t;function t(n,o,i){e.isArray(o)||(o=[o]);var a=(n.isDirected()?n.successors:n.neighbors).bind(n),s=[],u={};return e.each(o,function(c){if(!n.hasNode(c))throw new Error("Graph does not have node: "+c);r(n,c,i==="post",u,a,s)}),s}function r(n,o,i,a,s,u){e.has(a,o)||(a[o]=!0,i||u.push(o),e.each(s(o),function(c){r(n,c,i,a,s,u)}),i&&u.push(o))}return zs}var Vs,Op;function D1(){if(Op)return Vs;Op=1;var e=Eb();Vs=t;function t(r,n){return e(r,n,"post")}return Vs}var Ws,Ip;function z1(){if(Ip)return Ws;Ip=1;var e=Eb();Ws=t;function t(r,n){return e(r,n,"pre")}return Ws}var Gs,Mp;function V1(){if(Mp)return Gs;Mp=1;var e=xr(),t=el(),r=wb();Gs=n;function n(o,i){var a=new t,s={},u=new r,c;function l(f){var p=f.v===c?f.w:f.v,m=u.priority(p);if(m!==void 0){var y=i(f);y<m&&(s[p]=c,u.decrease(p,y))}}if(o.nodeCount()===0)return a;e.each(o.nodes(),function(f){u.add(f,Number.POSITIVE_INFINITY),a.setNode(f)}),u.decrease(o.nodes()[0],0);for(var d=!1;u.size()>0;){if(c=u.removeMin(),e.has(s,c))a.setEdge(c,s[c]);else{if(d)throw new Error("Input graph is not connected: "+o);d=!0}o.nodeEdges(c).forEach(l)}return a}return Gs}var Us,qp;function W1(){return qp||(qp=1,Us={components:N1(),dijkstra:Cb(),dijkstraAll:$1(),findCycles:L1(),floydWarshall:F1(),isAcyclic:B1(),postorder:D1(),preorder:z1(),prim:V1(),tarjan:_b(),topsort:Sb()}),Us}var Hs,Np;function G1(){if(Np)return Hs;Np=1;var e=M1();return Hs={Graph:e.Graph,json:q1(),alg:W1(),version:e.version},Hs}var Ks,$p;function _r(){if($p)return Ks;$p=1;var e;if(typeof Lu=="function")try{e=G1()}catch{}return e||(e=window.graphlib),Ks=e,Ks}var Zs,Lp;function U1(){if(Lp)return Zs;Lp=1;var e=Jm(),t=1,r=4;function n(o){return e(o,t|r)}return Zs=n,Zs}var Js,Fp;function Bn(){if(Fp)return Js;Fp=1;var e=yt(),t=qr(),r=Tn(),n=vr();function o(i,a,s){if(!n(s))return!1;var u=typeof a;return(u=="number"?t(s)&&r(a,s.length):u=="string"&&a in s)?e(s[a],i):!1}return Js=o,Js}var Ys,Bp;function H1(){if(Bp)return Ys;Bp=1;var e=Fn(),t=yt(),r=Bn(),n=nt(),o=Object.prototype,i=o.hasOwnProperty,a=e(function(s,u){s=Object(s);var c=-1,l=u.length,d=l>2?u[2]:void 0;for(d&&r(u[0],u[1],d)&&(l=1);++c<l;)for(var f=u[c],p=n(f),m=-1,y=p.length;++m<y;){var b=p[m],v=s[b];(v===void 0||t(v,o[b])&&!i.call(s,b))&&(s[b]=f[b])}return s});return Ys=a,Ys}var Xs,Dp;function K1(){if(Dp)return Xs;Dp=1;var e=Nr(),t=qr(),r=Ur();function n(o){return function(i,a,s){var u=Object(i);if(!t(i)){var c=e(a,3);i=r(i),a=function(d){return c(u[d],d,u)}}var l=o(i,a,s);return l>-1?u[c?i[l]:l]:void 0}}return Xs=n,Xs}var Qs,zp;function Z1(){if(zp)return Qs;zp=1;var e=/\s/;function t(r){for(var n=r.length;n--&&e.test(r.charAt(n)););return n}return Qs=t,Qs}var ec,Vp;function J1(){if(Vp)return ec;Vp=1;var e=Z1(),t=/^\s+/;function r(n){return n&&n.slice(0,e(n)+1).replace(t,"")}return ec=r,ec}var rc,Wp;function Y1(){if(Wp)return rc;Wp=1;var e=J1(),t=vr(),r=xt(),n=NaN,o=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,a=/^0o[0-7]+$/i,s=parseInt;function u(c){if(typeof c=="number")return c;if(r(c))return n;if(t(c)){var l=typeof c.valueOf=="function"?c.valueOf():c;c=t(l)?l+"":l}if(typeof c!="string")return c===0?c:+c;c=e(c);var d=i.test(c);return d||a.test(c)?s(c.slice(2),d?2:8):o.test(c)?n:+c}return rc=u,rc}var tc,Gp;function jb(){if(Gp)return tc;Gp=1;var e=Y1(),t=1/0,r=17976931348623157e292;function n(o){if(!o)return o===0?o:0;if(o=e(o),o===t||o===-t){var i=o<0?-1:1;return i*r}return o===o?o:0}return tc=n,tc}var nc,Up;function X1(){if(Up)return nc;Up=1;var e=jb();function t(r){var n=e(r),o=n%1;return n===n?o?n-o:n:0}return nc=t,nc}var oc,Hp;function Q1(){if(Hp)return oc;Hp=1;var e=bb(),t=Nr(),r=X1(),n=Math.max;function o(i,a,s){var u=i==null?0:i.length;if(!u)return-1;var c=s==null?0:r(s);return c<0&&(c=n(u+c,0)),e(i,t(a,3),c)}return oc=o,oc}var ic,Kp;function eC(){if(Kp)return ic;Kp=1;var e=K1(),t=Q1(),r=e(t);return ic=r,ic}var ac,Zp;function Rb(){if(Zp)return ac;Zp=1;var e=Qu();function t(r){var n=r==null?0:r.length;return n?e(r,1):[]}return ac=t,ac}var sc,Jp;function rC(){if(Jp)return sc;Jp=1;var e=Zu(),t=Ym(),r=nt();function n(o,i){return o==null?o:e(o,t(i),r)}return sc=n,sc}var cc,Yp;function tC(){if(Yp)return cc;Yp=1;function e(t){var r=t==null?0:t.length;return r?t[r-1]:void 0}return cc=e,cc}var uc,Xp;function nC(){if(Xp)return uc;Xp=1;var e=Pn(),t=Ju(),r=Nr();function n(o,i){var a={};return i=r(i,3),t(o,function(s,u,c){e(a,u,i(s,u,c))}),a}return uc=n,uc}var lc,Qp;function rl(){if(Qp)return lc;Qp=1;var e=xt();function t(r,n,o){for(var i=-1,a=r.length;++i<a;){var s=r[i],u=n(s);if(u!=null&&(c===void 0?u===u&&!e(u):o(u,c)))var c=u,l=s}return l}return lc=t,lc}var dc,eg;function oC(){if(eg)return dc;eg=1;function e(t,r){return t>r}return dc=e,dc}var fc,rg;function iC(){if(rg)return fc;rg=1;var e=rl(),t=oC(),r=ot();function n(o){return o&&o.length?e(o,r,t):void 0}return fc=n,fc}var hc,tg;function kb(){if(tg)return hc;tg=1;var e=Pn(),t=yt();function r(n,o,i){(i!==void 0&&!t(n[o],i)||i===void 0&&!(o in n))&&e(n,o,i)}return hc=r,hc}var pc,ng;function aC(){if(ng)return pc;ng=1;var e=rt(),t=Mn(),r=Pr(),n="[object Object]",o=Function.prototype,i=Object.prototype,a=o.toString,s=i.hasOwnProperty,u=a.call(Object);function c(l){if(!r(l)||e(l)!=n)return!1;var d=t(l);if(d===null)return!0;var f=s.call(d,"constructor")&&d.constructor;return typeof f=="function"&&f instanceof f&&a.call(f)==u}return pc=c,pc}var gc,og;function Pb(){if(og)return gc;og=1;function e(t,r){if(!(r==="constructor"&&typeof t[r]=="function")&&r!="__proto__")return t[r]}return gc=e,gc}var yc,ig;function sC(){if(ig)return yc;ig=1;var e=Qt(),t=nt();function r(n){return e(n,t(n))}return yc=r,yc}var mc,ag;function cC(){if(ag)return mc;ag=1;var e=kb(),t=Lm(),r=Hm(),n=Fm(),o=Zm(),i=en(),a=Ue(),s=vb(),u=bt(),c=Xt(),l=vr(),d=aC(),f=rn(),p=Pb(),m=sC();function y(b,v,g,w,x,_,C){var S=p(b,g),T=p(v,g),k=C.get(T);if(k){e(b,g,k);return}var E=_?_(S,T,g+"",b,v,C):void 0,P=E===void 0;if(P){var R=a(T),I=!R&&u(T),O=!R&&!I&&f(T);E=T,R||I||O?a(S)?E=S:s(S)?E=n(S):I?(P=!1,E=t(T,!0)):O?(P=!1,E=r(T,!0)):E=[]:d(T)||i(T)?(E=S,i(S)?E=m(S):(!l(S)||c(S))&&(E=o(T))):P=!1}P&&(C.set(T,E),x(E,T,w,_,C),C.delete(T)),e(b,g,E)}return mc=y,mc}var bc,sg;function uC(){if(sg)return bc;sg=1;var e=kn(),t=kb(),r=Zu(),n=cC(),o=vr(),i=nt(),a=Pb();function s(u,c,l,d,f){u!==c&&r(c,function(p,m){if(f||(f=new e),o(p))n(u,c,m,l,s,d,f);else{var y=d?d(a(u,m),p,m+"",u,c,f):void 0;y===void 0&&(y=p),t(u,m,y)}},i)}return bc=s,bc}var vc,cg;function lC(){if(cg)return vc;cg=1;var e=Fn(),t=Bn();function r(n){return e(function(o,i){var a=-1,s=i.length,u=s>1?i[s-1]:void 0,c=s>2?i[2]:void 0;for(u=n.length>3&&typeof u=="function"?(s--,u):void 0,c&&t(i[0],i[1],c)&&(u=s<3?void 0:u,s=1),o=Object(o);++a<s;){var l=i[a];l&&n(o,l,a,u)}return o})}return vc=r,vc}var xc,ug;function dC(){if(ug)return xc;ug=1;var e=uC(),t=lC(),r=t(function(n,o,i){e(n,o,i)});return xc=r,xc}var wc,lg;function Ab(){if(lg)return wc;lg=1;function e(t,r){return t<r}return wc=e,wc}var Cc,dg;function fC(){if(dg)return Cc;dg=1;var e=rl(),t=Ab(),r=ot();function n(o){return o&&o.length?e(o,r,t):void 0}return Cc=n,Cc}var _c,fg;function hC(){if(fg)return _c;fg=1;var e=rl(),t=Nr(),r=Ab();function n(o,i){return o&&o.length?e(o,t(i,2),r):void 0}return _c=n,_c}var Sc,hg;function pC(){if(hg)return Sc;hg=1;var e=Sr(),t=function(){return e.Date.now()};return Sc=t,Sc}var Ec,pg;function gC(){if(pg)return Ec;pg=1;var e=An(),t=$n(),r=Tn(),n=vr(),o=tn();function i(a,s,u,c){if(!n(a))return a;s=t(s,a);for(var l=-1,d=s.length,f=d-1,p=a;p!=null&&++l<d;){var m=o(s[l]),y=u;if(m==="__proto__"||m==="constructor"||m==="prototype")return a;if(l!=f){var b=p[m];y=c?c(b,m,p):void 0,y===void 0&&(y=n(b)?b:r(s[l+1])?[]:{})}e(p,m,y),p=p[m]}return a}return Ec=i,Ec}var jc,gg;function yC(){if(gg)return jc;gg=1;var e=Ln(),t=gC(),r=$n();function n(o,i,a){for(var s=-1,u=i.length,c={};++s<u;){var l=i[s],d=e(o,l);a(d,l)&&t(c,r(l,o),d)}return c}return jc=n,jc}var Rc,yg;function mC(){if(yg)return Rc;yg=1;var e=yC(),t=cb();function r(n,o){return e(n,o,function(i,a){return t(n,a)})}return Rc=r,Rc}var kc,mg;function bC(){if(mg)return kc;mg=1;var e=Rb(),t=yb(),r=mb();function n(o){return r(t(o,void 0,e),o+"")}return kc=n,kc}var Pc,bg;function vC(){if(bg)return Pc;bg=1;var e=mC(),t=bC(),r=t(function(n,o){return n==null?{}:e(n,o)});return Pc=r,Pc}var Ac,vg;function xC(){if(vg)return Ac;vg=1;var e=Math.ceil,t=Math.max;function r(n,o,i,a){for(var s=-1,u=t(e((o-n)/(i||1)),0),c=Array(u);u--;)c[a?u:++s]=n,n+=i;return c}return Ac=r,Ac}var Tc,xg;function wC(){if(xg)return Tc;xg=1;var e=xC(),t=Bn(),r=jb();function n(o){return function(i,a,s){return s&&typeof s!="number"&&t(i,a,s)&&(a=s=void 0),i=r(i),a===void 0?(a=i,i=0):a=r(a),s=s===void 0?i<a?1:-1:r(s),e(i,a,s,o)}}return Tc=n,Tc}var Oc,wg;function CC(){if(wg)return Oc;wg=1;var e=wC(),t=e();return Oc=t,Oc}var Ic,Cg;function _C(){if(Cg)return Ic;Cg=1;function e(t,r){var n=t.length;for(t.sort(r);n--;)t[n]=t[n].value;return t}return Ic=e,Ic}var Mc,_g;function SC(){if(_g)return Mc;_g=1;var e=xt();function t(r,n){if(r!==n){var o=r!==void 0,i=r===null,a=r===r,s=e(r),u=n!==void 0,c=n===null,l=n===n,d=e(n);if(!c&&!d&&!s&&r>n||s&&u&&l&&!c&&!d||i&&u&&l||!o&&l||!a)return 1;if(!i&&!s&&!d&&r<n||d&&o&&a&&!i&&!s||c&&o&&a||!u&&a||!l)return-1}return 0}return Mc=t,Mc}var qc,Sg;function EC(){if(Sg)return qc;Sg=1;var e=SC();function t(r,n,o){for(var i=-1,a=r.criteria,s=n.criteria,u=a.length,c=o.length;++i<u;){var l=e(a[i],s[i]);if(l){if(i>=c)return l;var d=o[i];return l*(d=="desc"?-1:1)}}return r.index-n.index}return qc=t,qc}var Nc,Eg;function jC(){if(Eg)return Nc;Eg=1;var e=Nn(),t=Ln(),r=Nr(),n=hb(),o=_C(),i=On(),a=EC(),s=ot(),u=Ue();function c(l,d,f){d.length?d=e(d,function(y){return u(y)?function(b){return t(b,y.length===1?y[0]:y)}:y}):d=[s];var p=-1;d=e(d,i(r));var m=n(l,function(y,b,v){var g=e(d,function(w){return w(y)});return{criteria:g,index:++p,value:y}});return o(m,function(y,b){return a(y,b,f)})}return Nc=c,Nc}var $c,jg;function RC(){if(jg)return $c;jg=1;var e=Qu(),t=jC(),r=Fn(),n=Bn(),o=r(function(i,a){if(i==null)return[];var s=a.length;return s>1&&n(i,a[0],a[1])?a=[]:s>2&&n(a[0],a[1],a[2])&&(a=[a[0]]),t(i,e(a,1),[])});return $c=o,$c}var Lc,Rg;function kC(){if(Rg)return Lc;Rg=1;var e=ab(),t=0;function r(n){var o=++t;return e(n)+o}return Lc=r,Lc}var Fc,kg;function PC(){if(kg)return Fc;kg=1;function e(t,r,n){for(var o=-1,i=t.length,a=r.length,s={};++o<i;){var u=o<a?r[o]:void 0;n(s,t[o],u)}return s}return Fc=e,Fc}var Bc,Pg;function AC(){if(Pg)return Bc;Pg=1;var e=An(),t=PC();function r(n,o){return t(n||[],o||[],e)}return Bc=r,Bc}var Dc,Ag;function De(){if(Ag)return Dc;Ag=1;var e;if(typeof Lu=="function")try{e={cloneDeep:U1(),constant:Ku(),defaults:H1(),each:Qm(),filter:lb(),find:eC(),flatten:Rb(),forEach:Xm(),forIn:rC(),has:db(),isUndefined:fb(),last:tC(),map:pb(),mapValues:nC(),max:iC(),merge:dC(),min:fC(),minBy:hC(),now:pC(),pick:vC(),range:CC(),reduce:gb(),sortBy:RC(),uniqueId:kC(),values:xb(),zipObject:AC()}}catch{}return e||(e=window._),Dc=e,Dc}var zc,Tg;function TC(){if(Tg)return zc;Tg=1,zc=e;function e(){var n={};n._next=n._prev=n,this._sentinel=n}e.prototype.dequeue=function(){var n=this._sentinel,o=n._prev;if(o!==n)return t(o),o},e.prototype.enqueue=function(n){var o=this._sentinel;n._prev&&n._next&&t(n),n._next=o._next,o._next._prev=n,o._next=n,n._prev=o},e.prototype.toString=function(){for(var n=[],o=this._sentinel,i=o._prev;i!==o;)n.push(JSON.stringify(i,r)),i=i._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,o){if(n!=="_next"&&n!=="_prev")return o}return zc}var Vc,Og;function OC(){if(Og)return Vc;Og=1;var e=De(),t=_r().Graph,r=TC();Vc=o;var n=e.constant(1);function o(c,l){if(c.nodeCount()<=1)return[];var d=s(c,l||n),f=i(d.graph,d.buckets,d.zeroIdx);return e.flatten(e.map(f,function(p){return c.outEdges(p.v,p.w)}),!0)}function i(c,l,d){for(var f=[],p=l[l.length-1],m=l[0],y;c.nodeCount();){for(;y=m.dequeue();)a(c,l,d,y);for(;y=p.dequeue();)a(c,l,d,y);if(c.nodeCount()){for(var b=l.length-2;b>0;--b)if(y=l[b].dequeue(),y){f=f.concat(a(c,l,d,y,!0));break}}}return f}function a(c,l,d,f,p){var m=p?[]:void 0;return e.forEach(c.inEdges(f.v),function(y){var b=c.edge(y),v=c.node(y.v);p&&m.push({v:y.v,w:y.w}),v.out-=b,u(l,d,v)}),e.forEach(c.outEdges(f.v),function(y){var b=c.edge(y),v=y.w,g=c.node(v);g.in-=b,u(l,d,g)}),c.removeNode(f.v),m}function s(c,l){var d=new t,f=0,p=0;e.forEach(c.nodes(),function(b){d.setNode(b,{v:b,in:0,out:0})}),e.forEach(c.edges(),function(b){var v=d.edge(b.v,b.w)||0,g=l(b),w=v+g;d.setEdge(b.v,b.w,w),p=Math.max(p,d.node(b.v).out+=g),f=Math.max(f,d.node(b.w).in+=g)});var m=e.range(p+f+3).map(function(){return new r}),y=f+1;return e.forEach(d.nodes(),function(b){u(m,y,d.node(b))}),{graph:d,buckets:m,zeroIdx:y}}function u(c,l,d){d.out?d.in?c[d.out-d.in+l].enqueue(d):c[c.length-1].enqueue(d):c[0].enqueue(d)}return Vc}var Wc,Ig;function IC(){if(Ig)return Wc;Ig=1;var e=De(),t=OC();Wc={run:r,undo:o};function r(i){var a=i.graph().acyclicer==="greedy"?t(i,s(i)):n(i);e.forEach(a,function(u){var c=i.edge(u);i.removeEdge(u),c.forwardName=u.name,c.reversed=!0,i.setEdge(u.w,u.v,c,e.uniqueId("rev"))});function s(u){return function(c){return u.edge(c).weight}}}function n(i){var a=[],s={},u={};function c(l){e.has(u,l)||(u[l]=!0,s[l]=!0,e.forEach(i.outEdges(l),function(d){e.has(s,d.w)?a.push(d):c(d.w)}),delete s[l])}return e.forEach(i.nodes(),c),a}function o(i){e.forEach(i.edges(),function(a){var s=i.edge(a);if(s.reversed){i.removeEdge(a);var u=s.forwardName;delete s.reversed,delete s.forwardName,i.setEdge(a.w,a.v,s,u)}})}return Wc}var Gc,Mg;function dr(){if(Mg)return Gc;Mg=1;var e=De(),t=_r().Graph;Gc={addDummyNode:r,simplify:n,asNonCompoundGraph:o,successorWeights:i,predecessorWeights:a,intersectRect:s,buildLayerMatrix:u,normalizeRanks:c,removeEmptyRanks:l,addBorderNode:d,maxRank:f,partition:p,time:m,notime:y};function r(b,v,g,w){var x;do x=e.uniqueId(w);while(b.hasNode(x));return g.dummy=v,b.setNode(x,g),x}function n(b){var v=new t().setGraph(b.graph());return e.forEach(b.nodes(),function(g){v.setNode(g,b.node(g))}),e.forEach(b.edges(),function(g){var w=v.edge(g.v,g.w)||{weight:0,minlen:1},x=b.edge(g);v.setEdge(g.v,g.w,{weight:w.weight+x.weight,minlen:Math.max(w.minlen,x.minlen)})}),v}function o(b){var v=new t({multigraph:b.isMultigraph()}).setGraph(b.graph());return e.forEach(b.nodes(),function(g){b.children(g).length||v.setNode(g,b.node(g))}),e.forEach(b.edges(),function(g){v.setEdge(g,b.edge(g))}),v}function i(b){var v=e.map(b.nodes(),function(g){var w={};return e.forEach(b.outEdges(g),function(x){w[x.w]=(w[x.w]||0)+b.edge(x).weight}),w});return e.zipObject(b.nodes(),v)}function a(b){var v=e.map(b.nodes(),function(g){var w={};return e.forEach(b.inEdges(g),function(x){w[x.v]=(w[x.v]||0)+b.edge(x).weight}),w});return e.zipObject(b.nodes(),v)}function s(b,v){var g=b.x,w=b.y,x=v.x-g,_=v.y-w,C=b.width/2,S=b.height/2;if(!x&&!_)throw new Error("Not possible to find intersection inside of the rectangle");var T,k;return Math.abs(_)*C>Math.abs(x)*S?(_<0&&(S=-S),T=S*x/_,k=S):(x<0&&(C=-C),T=C,k=C*_/x),{x:g+T,y:w+k}}function u(b){var v=e.map(e.range(f(b)+1),function(){return[]});return e.forEach(b.nodes(),function(g){var w=b.node(g),x=w.rank;e.isUndefined(x)||(v[x][w.order]=g)}),v}function c(b){var v=e.min(e.map(b.nodes(),function(g){return b.node(g).rank}));e.forEach(b.nodes(),function(g){var w=b.node(g);e.has(w,"rank")&&(w.rank-=v)})}function l(b){var v=e.min(e.map(b.nodes(),function(_){return b.node(_).rank})),g=[];e.forEach(b.nodes(),function(_){var C=b.node(_).rank-v;g[C]||(g[C]=[]),g[C].push(_)});var w=0,x=b.graph().nodeRankFactor;e.forEach(g,function(_,C){e.isUndefined(_)&&C%x!==0?--w:w&&e.forEach(_,function(S){b.node(S).rank+=w})})}function d(b,v,g,w){var x={width:0,height:0};return arguments.length>=4&&(x.rank=g,x.order=w),r(b,"border",x,v)}function f(b){return e.max(e.map(b.nodes(),function(v){var g=b.node(v).rank;if(!e.isUndefined(g))return g}))}function p(b,v){var g={lhs:[],rhs:[]};return e.forEach(b,function(w){v(w)?g.lhs.push(w):g.rhs.push(w)}),g}function m(b,v){var g=e.now();try{return v()}finally{console.log(b+" time: "+(e.now()-g)+"ms")}}function y(b,v){return v()}return Gc}var Uc,qg;function MC(){if(qg)return Uc;qg=1;var e=De(),t=dr();Uc={run:r,undo:o};function r(i){i.graph().dummyChains=[],e.forEach(i.edges(),function(a){n(i,a)})}function n(i,a){var s=a.v,u=i.node(s).rank,c=a.w,l=i.node(c).rank,d=a.name,f=i.edge(a),p=f.labelRank;if(l!==u+1){i.removeEdge(a);var m,y,b;for(b=0,++u;u<l;++b,++u)f.points=[],y={width:0,height:0,edgeLabel:f,edgeObj:a,rank:u},m=t.addDummyNode(i,"edge",y,"_d"),u===p&&(y.width=f.width,y.height=f.height,y.dummy="edge-label",y.labelpos=f.labelpos),i.setEdge(s,m,{weight:f.weight},d),b===0&&i.graph().dummyChains.push(m),s=m;i.setEdge(s,c,{weight:f.weight},d)}}function o(i){e.forEach(i.graph().dummyChains,function(a){var s=i.node(a),u=s.edgeLabel,c;for(i.setEdge(s.edgeObj,u);s.dummy;)c=i.successors(a)[0],i.removeNode(a),u.points.push({x:s.x,y:s.y}),s.dummy==="edge-label"&&(u.x=s.x,u.y=s.y,u.width=s.width,u.height=s.height),a=c,s=i.node(a)})}return Uc}var Hc,Ng;function gn(){if(Ng)return Hc;Ng=1;var e=De();Hc={longestPath:t,slack:r};function t(n){var o={};function i(a){var s=n.node(a);if(e.has(o,a))return s.rank;o[a]=!0;var u=e.min(e.map(n.outEdges(a),function(c){return i(c.w)-n.edge(c).minlen}));return(u===Number.POSITIVE_INFINITY||u===void 0||u===null)&&(u=0),s.rank=u}e.forEach(n.sources(),i)}function r(n,o){return n.node(o.w).rank-n.node(o.v).rank-n.edge(o).minlen}return Hc}var Kc,$g;function Tb(){if($g)return Kc;$g=1;var e=De(),t=_r().Graph,r=gn().slack;Kc=n;function n(s){var u=new t({directed:!1}),c=s.nodes()[0],l=s.nodeCount();u.setNode(c,{});for(var d,f;o(u,s)<l;)d=i(u,s),f=u.hasNode(d.v)?r(s,d):-r(s,d),a(u,s,f);return u}function o(s,u){function c(l){e.forEach(u.nodeEdges(l),function(d){var f=d.v,p=l===f?d.w:f;!s.hasNode(p)&&!r(u,d)&&(s.setNode(p,{}),s.setEdge(l,p,{}),c(p))})}return e.forEach(s.nodes(),c),s.nodeCount()}function i(s,u){return e.minBy(u.edges(),function(c){if(s.hasNode(c.v)!==s.hasNode(c.w))return r(u,c)})}function a(s,u,c){e.forEach(s.nodes(),function(l){u.node(l).rank+=c})}return Kc}var Zc,Lg;function qC(){if(Lg)return Zc;Lg=1;var e=De(),t=Tb(),r=gn().slack,n=gn().longestPath,o=_r().alg.preorder,i=_r().alg.postorder,a=dr().simplify;Zc=s,s.initLowLimValues=d,s.initCutValues=u,s.calcCutValue=l,s.leaveEdge=p,s.enterEdge=m,s.exchangeEdges=y;function s(w){w=a(w),n(w);var x=t(w);d(x),u(x,w);for(var _,C;_=p(x);)C=m(x,w,_),y(x,w,_,C)}function u(w,x){var _=i(w,w.nodes());_=_.slice(0,_.length-1),e.forEach(_,function(C){c(w,x,C)})}function c(w,x,_){var C=w.node(_),S=C.parent;w.edge(_,S).cutvalue=l(w,x,_)}function l(w,x,_){var C=w.node(_),S=C.parent,T=!0,k=x.edge(_,S),E=0;return k||(T=!1,k=x.edge(S,_)),E=k.weight,e.forEach(x.nodeEdges(_),function(P){var R=P.v===_,I=R?P.w:P.v;if(I!==S){var O=R===T,M=x.edge(P).weight;if(E+=O?M:-M,v(w,_,I)){var q=w.edge(_,I).cutvalue;E+=O?-q:q}}}),E}function d(w,x){arguments.length<2&&(x=w.nodes()[0]),f(w,{},1,x)}function f(w,x,_,C,S){var T=_,k=w.node(C);return x[C]=!0,e.forEach(w.neighbors(C),function(E){e.has(x,E)||(_=f(w,x,_,E,C))}),k.low=T,k.lim=_++,S?k.parent=S:delete k.parent,_}function p(w){return e.find(w.edges(),function(x){return w.edge(x).cutvalue<0})}function m(w,x,_){var C=_.v,S=_.w;x.hasEdge(C,S)||(C=_.w,S=_.v);var T=w.node(C),k=w.node(S),E=T,P=!1;T.lim>k.lim&&(E=k,P=!0);var R=e.filter(x.edges(),function(I){return P===g(w,w.node(I.v),E)&&P!==g(w,w.node(I.w),E)});return e.minBy(R,function(I){return r(x,I)})}function y(w,x,_,C){var S=_.v,T=_.w;w.removeEdge(S,T),w.setEdge(C.v,C.w,{}),d(w),u(w,x),b(w,x)}function b(w,x){var _=e.find(w.nodes(),function(S){return!x.node(S).parent}),C=o(w,_);C=C.slice(1),e.forEach(C,function(S){var T=w.node(S).parent,k=x.edge(S,T),E=!1;k||(k=x.edge(T,S),E=!0),x.node(S).rank=x.node(T).rank+(E?k.minlen:-k.minlen)})}function v(w,x,_){return w.hasEdge(x,_)}function g(w,x,_){return _.low<=x.lim&&x.lim<=_.lim}return Zc}var Jc,Fg;function NC(){if(Fg)return Jc;Fg=1;var e=gn(),t=e.longestPath,r=Tb(),n=qC();Jc=o;function o(u){switch(u.graph().ranker){case"network-simplex":s(u);break;case"tight-tree":a(u);break;case"longest-path":i(u);break;default:s(u)}}var i=t;function a(u){t(u),r(u)}function s(u){n(u)}return Jc}var Yc,Bg;function $C(){if(Bg)return Yc;Bg=1;var e=De();Yc=t;function t(o){var i=n(o);e.forEach(o.graph().dummyChains,function(a){for(var s=o.node(a),u=s.edgeObj,c=r(o,i,u.v,u.w),l=c.path,d=c.lca,f=0,p=l[f],m=!0;a!==u.w;){if(s=o.node(a),m){for(;(p=l[f])!==d&&o.node(p).maxRank<s.rank;)f++;p===d&&(m=!1)}if(!m){for(;f<l.length-1&&o.node(p=l[f+1]).minRank<=s.rank;)f++;p=l[f]}o.setParent(a,p),a=o.successors(a)[0]}})}function r(o,i,a,s){var u=[],c=[],l=Math.min(i[a].low,i[s].low),d=Math.max(i[a].lim,i[s].lim),f,p;f=a;do f=o.parent(f),u.push(f);while(f&&(i[f].low>l||d>i[f].lim));for(p=f,f=s;(f=o.parent(f))!==p;)c.push(f);return{path:u.concat(c.reverse()),lca:p}}function n(o){var i={},a=0;function s(u){var c=a;e.forEach(o.children(u),s),i[u]={low:c,lim:a++}}return e.forEach(o.children(),s),i}return Yc}var Xc,Dg;function LC(){if(Dg)return Xc;Dg=1;var e=De(),t=dr();Xc={run:r,cleanup:a};function r(s){var u=t.addDummyNode(s,"root",{},"_root"),c=o(s),l=e.max(e.values(c))-1,d=2*l+1;s.graph().nestingRoot=u,e.forEach(s.edges(),function(p){s.edge(p).minlen*=d});var f=i(s)+1;e.forEach(s.children(),function(p){n(s,u,d,f,l,c,p)}),s.graph().nodeRankFactor=d}function n(s,u,c,l,d,f,p){var m=s.children(p);if(!m.length){p!==u&&s.setEdge(u,p,{weight:0,minlen:c});return}var y=t.addBorderNode(s,"_bt"),b=t.addBorderNode(s,"_bb"),v=s.node(p);s.setParent(y,p),v.borderTop=y,s.setParent(b,p),v.borderBottom=b,e.forEach(m,function(g){n(s,u,c,l,d,f,g);var w=s.node(g),x=w.borderTop?w.borderTop:g,_=w.borderBottom?w.borderBottom:g,C=w.borderTop?l:2*l,S=x!==_?1:d-f[p]+1;s.setEdge(y,x,{weight:C,minlen:S,nestingEdge:!0}),s.setEdge(_,b,{weight:C,minlen:S,nestingEdge:!0})}),s.parent(p)||s.setEdge(u,y,{weight:0,minlen:d+f[p]})}function o(s){var u={};function c(l,d){var f=s.children(l);f&&f.length&&e.forEach(f,function(p){c(p,d+1)}),u[l]=d}return e.forEach(s.children(),function(l){c(l,1)}),u}function i(s){return e.reduce(s.edges(),function(u,c){return u+s.edge(c).weight},0)}function a(s){var u=s.graph();s.removeNode(u.nestingRoot),delete u.nestingRoot,e.forEach(s.edges(),function(c){var l=s.edge(c);l.nestingEdge&&s.removeEdge(c)})}return Xc}var Qc,zg;function FC(){if(zg)return Qc;zg=1;var e=De(),t=dr();Qc=r;function r(o){function i(a){var s=o.children(a),u=o.node(a);if(s.length&&e.forEach(s,i),e.has(u,"minRank")){u.borderLeft=[],u.borderRight=[];for(var c=u.minRank,l=u.maxRank+1;c<l;++c)n(o,"borderLeft","_bl",a,u,c),n(o,"borderRight","_br",a,u,c)}}e.forEach(o.children(),i)}function n(o,i,a,s,u,c){var l={width:0,height:0,rank:c,borderType:i},d=u[i][c-1],f=t.addDummyNode(o,"border",l,a);u[i][c]=f,o.setParent(f,s),d&&o.setEdge(d,f,{weight:1})}return Qc}var eu,Vg;function BC(){if(Vg)return eu;Vg=1;var e=De();eu={adjust:t,undo:r};function t(c){var l=c.graph().rankdir.toLowerCase();(l==="lr"||l==="rl")&&n(c)}function r(c){var l=c.graph().rankdir.toLowerCase();(l==="bt"||l==="rl")&&i(c),(l==="lr"||l==="rl")&&(s(c),n(c))}function n(c){e.forEach(c.nodes(),function(l){o(c.node(l))}),e.forEach(c.edges(),function(l){o(c.edge(l))})}function o(c){var l=c.width;c.width=c.height,c.height=l}function i(c){e.forEach(c.nodes(),function(l){a(c.node(l))}),e.forEach(c.edges(),function(l){var d=c.edge(l);e.forEach(d.points,a),e.has(d,"y")&&a(d)})}function a(c){c.y=-c.y}function s(c){e.forEach(c.nodes(),function(l){u(c.node(l))}),e.forEach(c.edges(),function(l){var d=c.edge(l);e.forEach(d.points,u),e.has(d,"x")&&u(d)})}function u(c){var l=c.x;c.x=c.y,c.y=l}return eu}var ru,Wg;function DC(){if(Wg)return ru;Wg=1;var e=De();ru=t;function t(r){var n={},o=e.filter(r.nodes(),function(c){return!r.children(c).length}),i=e.max(e.map(o,function(c){return r.node(c).rank})),a=e.map(e.range(i+1),function(){return[]});function s(c){if(!e.has(n,c)){n[c]=!0;var l=r.node(c);a[l.rank].push(c),e.forEach(r.successors(c),s)}}var u=e.sortBy(o,function(c){return r.node(c).rank});return e.forEach(u,s),a}return ru}var tu,Gg;function zC(){if(Gg)return tu;Gg=1;var e=De();tu=t;function t(n,o){for(var i=0,a=1;a<o.length;++a)i+=r(n,o[a-1],o[a]);return i}function r(n,o,i){for(var a=e.zipObject(i,e.map(i,function(f,p){return p})),s=e.flatten(e.map(o,function(f){return e.sortBy(e.map(n.outEdges(f),function(p){return{pos:a[p.w],weight:n.edge(p).weight}}),"pos")}),!0),u=1;u<i.length;)u<<=1;var c=2*u-1;u-=1;var l=e.map(new Array(c),function(){return 0}),d=0;return e.forEach(s.forEach(function(f){var p=f.pos+u;l[p]+=f.weight;for(var m=0;p>0;)p%2&&(m+=l[p+1]),p=p-1>>1,l[p]+=f.weight;d+=f.weight*m})),d}return tu}var nu,Ug;function VC(){if(Ug)return nu;Ug=1;var e=De();nu=t;function t(r,n){return e.map(n,function(o){var i=r.inEdges(o);if(i.length){var a=e.reduce(i,function(s,u){var c=r.edge(u),l=r.node(u.v);return{sum:s.sum+c.weight*l.order,weight:s.weight+c.weight}},{sum:0,weight:0});return{v:o,barycenter:a.sum/a.weight,weight:a.weight}}else return{v:o}})}return nu}var ou,Hg;function WC(){if(Hg)return ou;Hg=1;var e=De();ou=t;function t(o,i){var a={};e.forEach(o,function(u,c){var l=a[u.v]={indegree:0,in:[],out:[],vs:[u.v],i:c};e.isUndefined(u.barycenter)||(l.barycenter=u.barycenter,l.weight=u.weight)}),e.forEach(i.edges(),function(u){var c=a[u.v],l=a[u.w];!e.isUndefined(c)&&!e.isUndefined(l)&&(l.indegree++,c.out.push(a[u.w]))});var s=e.filter(a,function(u){return!u.indegree});return r(s)}function r(o){var i=[];function a(c){return function(l){l.merged||(e.isUndefined(l.barycenter)||e.isUndefined(c.barycenter)||l.barycenter>=c.barycenter)&&n(c,l)}}function s(c){return function(l){l.in.push(c),--l.indegree===0&&o.push(l)}}for(;o.length;){var u=o.pop();i.push(u),e.forEach(u.in.reverse(),a(u)),e.forEach(u.out,s(u))}return e.map(e.filter(i,function(c){return!c.merged}),function(c){return e.pick(c,["vs","i","barycenter","weight"])})}function n(o,i){var a=0,s=0;o.weight&&(a+=o.barycenter*o.weight,s+=o.weight),i.weight&&(a+=i.barycenter*i.weight,s+=i.weight),o.vs=i.vs.concat(o.vs),o.barycenter=a/s,o.weight=s,o.i=Math.min(i.i,o.i),i.merged=!0}return ou}var iu,Kg;function GC(){if(Kg)return iu;Kg=1;var e=De(),t=dr();iu=r;function r(i,a){var s=t.partition(i,function(y){return e.has(y,"barycenter")}),u=s.lhs,c=e.sortBy(s.rhs,function(y){return-y.i}),l=[],d=0,f=0,p=0;u.sort(o(!!a)),p=n(l,c,p),e.forEach(u,function(y){p+=y.vs.length,l.push(y.vs),d+=y.barycenter*y.weight,f+=y.weight,p=n(l,c,p)});var m={vs:e.flatten(l,!0)};return f&&(m.barycenter=d/f,m.weight=f),m}function n(i,a,s){for(var u;a.length&&(u=e.last(a)).i<=s;)a.pop(),i.push(u.vs),s++;return s}function o(i){return function(a,s){return a.barycenter<s.barycenter?-1:a.barycenter>s.barycenter?1:i?s.i-a.i:a.i-s.i}}return iu}var au,Zg;function UC(){if(Zg)return au;Zg=1;var e=De(),t=VC(),r=WC(),n=GC();au=o;function o(s,u,c,l){var d=s.children(u),f=s.node(u),p=f?f.borderLeft:void 0,m=f?f.borderRight:void 0,y={};p&&(d=e.filter(d,function(_){return _!==p&&_!==m}));var b=t(s,d);e.forEach(b,function(_){if(s.children(_.v).length){var C=o(s,_.v,c,l);y[_.v]=C,e.has(C,"barycenter")&&a(_,C)}});var v=r(b,c);i(v,y);var g=n(v,l);if(p&&(g.vs=e.flatten([p,g.vs,m],!0),s.predecessors(p).length)){var w=s.node(s.predecessors(p)[0]),x=s.node(s.predecessors(m)[0]);e.has(g,"barycenter")||(g.barycenter=0,g.weight=0),g.barycenter=(g.barycenter*g.weight+w.order+x.order)/(g.weight+2),g.weight+=2}return g}function i(s,u){e.forEach(s,function(c){c.vs=e.flatten(c.vs.map(function(l){return u[l]?u[l].vs:l}),!0)})}function a(s,u){e.isUndefined(s.barycenter)?(s.barycenter=u.barycenter,s.weight=u.weight):(s.barycenter=(s.barycenter*s.weight+u.barycenter*u.weight)/(s.weight+u.weight),s.weight+=u.weight)}return au}var su,Jg;function HC(){if(Jg)return su;Jg=1;var e=De(),t=_r().Graph;su=r;function r(o,i,a){var s=n(o),u=new t({compound:!0}).setGraph({root:s}).setDefaultNodeLabel(function(c){return o.node(c)});return e.forEach(o.nodes(),function(c){var l=o.node(c),d=o.parent(c);(l.rank===i||l.minRank<=i&&i<=l.maxRank)&&(u.setNode(c),u.setParent(c,d||s),e.forEach(o[a](c),function(f){var p=f.v===c?f.w:f.v,m=u.edge(p,c),y=e.isUndefined(m)?0:m.weight;u.setEdge(p,c,{weight:o.edge(f).weight+y})}),e.has(l,"minRank")&&u.setNode(c,{borderLeft:l.borderLeft[i],borderRight:l.borderRight[i]}))}),u}function n(o){for(var i;o.hasNode(i=e.uniqueId("_root")););return i}return su}var cu,Yg;function KC(){if(Yg)return cu;Yg=1;var e=De();cu=t;function t(r,n,o){var i={},a;e.forEach(o,function(s){for(var u=r.parent(s),c,l;u;){if(c=r.parent(u),c?(l=i[c],i[c]=u):(l=a,a=u),l&&l!==u){n.setEdge(l,u);return}u=c}})}return cu}var uu,Xg;function ZC(){if(Xg)return uu;Xg=1;var e=De(),t=DC(),r=zC(),n=UC(),o=HC(),i=KC(),a=_r().Graph,s=dr();uu=u;function u(f){var p=s.maxRank(f),m=c(f,e.range(1,p+1),"inEdges"),y=c(f,e.range(p-1,-1,-1),"outEdges"),b=t(f);d(f,b);for(var v=Number.POSITIVE_INFINITY,g,w=0,x=0;x<4;++w,++x){l(w%2?m:y,w%4>=2),b=s.buildLayerMatrix(f);var _=r(f,b);_<v&&(x=0,g=e.cloneDeep(b),v=_)}d(f,g)}function c(f,p,m){return e.map(p,function(y){return o(f,y,m)})}function l(f,p){var m=new a;e.forEach(f,function(y){var b=y.graph().root,v=n(y,b,m,p);e.forEach(v.vs,function(g,w){y.node(g).order=w}),i(y,m,v.vs)})}function d(f,p){e.forEach(p,function(m){e.forEach(m,function(y,b){f.node(y).order=b})})}return uu}var lu,Qg;function JC(){if(Qg)return lu;Qg=1;var e=De(),t=_r().Graph,r=dr();lu={positionX:m,findType1Conflicts:n,findType2Conflicts:o,addConflict:a,hasConflict:s,verticalAlignment:u,horizontalCompaction:c,alignCoordinates:f,findSmallestWidthAlignment:d,balance:p};function n(v,g){var w={};function x(_,C){var S=0,T=0,k=_.length,E=e.last(C);return e.forEach(C,function(P,R){var I=i(v,P),O=I?v.node(I).order:k;(I||P===E)&&(e.forEach(C.slice(T,R+1),function(M){e.forEach(v.predecessors(M),function(q){var K=v.node(q),V=K.order;(V<S||O<V)&&!(K.dummy&&v.node(M).dummy)&&a(w,q,M)})}),T=R+1,S=O)}),C}return e.reduce(g,x),w}function o(v,g){var w={};function x(C,S,T,k,E){var P;e.forEach(e.range(S,T),function(R){P=C[R],v.node(P).dummy&&e.forEach(v.predecessors(P),function(I){var O=v.node(I);O.dummy&&(O.order<k||O.order>E)&&a(w,I,P)})})}function _(C,S){var T=-1,k,E=0;return e.forEach(S,function(P,R){if(v.node(P).dummy==="border"){var I=v.predecessors(P);I.length&&(k=v.node(I[0]).order,x(S,E,R,T,k),E=R,T=k)}x(S,E,S.length,k,C.length)}),S}return e.reduce(g,_),w}function i(v,g){if(v.node(g).dummy)return e.find(v.predecessors(g),function(w){return v.node(w).dummy})}function a(v,g,w){if(g>w){var x=g;g=w,w=x}var _=v[g];_||(v[g]=_={}),_[w]=!0}function s(v,g,w){if(g>w){var x=g;g=w,w=x}return e.has(v[g],w)}function u(v,g,w,x){var _={},C={},S={};return e.forEach(g,function(T){e.forEach(T,function(k,E){_[k]=k,C[k]=k,S[k]=E})}),e.forEach(g,function(T){var k=-1;e.forEach(T,function(E){var P=x(E);if(P.length){P=e.sortBy(P,function(q){return S[q]});for(var R=(P.length-1)/2,I=Math.floor(R),O=Math.ceil(R);I<=O;++I){var M=P[I];C[E]===E&&k<S[M]&&!s(w,E,M)&&(C[M]=E,C[E]=_[E]=_[M],k=S[M])}}})}),{root:_,align:C}}function c(v,g,w,x,_){var C={},S=l(v,g,w,_),T=_?"borderLeft":"borderRight";function k(R,I){for(var O=S.nodes(),M=O.pop(),q={};M;)q[M]?R(M):(q[M]=!0,O.push(M),O=O.concat(I(M))),M=O.pop()}function E(R){C[R]=S.inEdges(R).reduce(function(I,O){return Math.max(I,C[O.v]+S.edge(O))},0)}function P(R){var I=S.outEdges(R).reduce(function(M,q){return Math.min(M,C[q.w]-S.edge(q))},Number.POSITIVE_INFINITY),O=v.node(R);I!==Number.POSITIVE_INFINITY&&O.borderType!==T&&(C[R]=Math.max(C[R],I))}return k(E,S.predecessors.bind(S)),k(P,S.successors.bind(S)),e.forEach(x,function(R){C[R]=C[w[R]]}),C}function l(v,g,w,x){var _=new t,C=v.graph(),S=y(C.nodesep,C.edgesep,x);return e.forEach(g,function(T){var k;e.forEach(T,function(E){var P=w[E];if(_.setNode(P),k){var R=w[k],I=_.edge(R,P);_.setEdge(R,P,Math.max(S(v,E,k),I||0))}k=E})}),_}function d(v,g){return e.minBy(e.values(g),function(w){var x=Number.NEGATIVE_INFINITY,_=Number.POSITIVE_INFINITY;return e.forIn(w,function(C,S){var T=b(v,S)/2;x=Math.max(C+T,x),_=Math.min(C-T,_)}),x-_})}function f(v,g){var w=e.values(g),x=e.min(w),_=e.max(w);e.forEach(["u","d"],function(C){e.forEach(["l","r"],function(S){var T=C+S,k=v[T],E;if(k!==g){var P=e.values(k);E=S==="l"?x-e.min(P):_-e.max(P),E&&(v[T]=e.mapValues(k,function(R){return R+E}))}})})}function p(v,g){return e.mapValues(v.ul,function(w,x){if(g)return v[g.toLowerCase()][x];var _=e.sortBy(e.map(v,x));return(_[1]+_[2])/2})}function m(v){var g=r.buildLayerMatrix(v),w=e.merge(n(v,g),o(v,g)),x={},_;e.forEach(["u","d"],function(S){_=S==="u"?g:e.values(g).reverse(),e.forEach(["l","r"],function(T){T==="r"&&(_=e.map(_,function(R){return e.values(R).reverse()}));var k=(S==="u"?v.predecessors:v.successors).bind(v),E=u(v,_,w,k),P=c(v,_,E.root,E.align,T==="r");T==="r"&&(P=e.mapValues(P,function(R){return-R})),x[S+T]=P})});var C=d(v,x);return f(x,C),p(x,v.graph().align)}function y(v,g,w){return function(x,_,C){var S=x.node(_),T=x.node(C),k=0,E;if(k+=S.width/2,e.has(S,"labelpos"))switch(S.labelpos.toLowerCase()){case"l":E=-S.width/2;break;case"r":E=S.width/2;break}if(E&&(k+=w?E:-E),E=0,k+=(S.dummy?g:v)/2,k+=(T.dummy?g:v)/2,k+=T.width/2,e.has(T,"labelpos"))switch(T.labelpos.toLowerCase()){case"l":E=T.width/2;break;case"r":E=-T.width/2;break}return E&&(k+=w?E:-E),E=0,k}}function b(v,g){return v.node(g).width}return lu}var du,ey;function YC(){if(ey)return du;ey=1;var e=De(),t=dr(),r=JC().positionX;du=n;function n(i){i=t.asNonCompoundGraph(i),o(i),e.forEach(r(i),function(a,s){i.node(s).x=a})}function o(i){var a=t.buildLayerMatrix(i),s=i.graph().ranksep,u=0;e.forEach(a,function(c){var l=e.max(e.map(c,function(d){return i.node(d).height}));e.forEach(c,function(d){i.node(d).y=u+l/2}),u+=l+s})}return du}var fu,ry;function XC(){if(ry)return fu;ry=1;var e=De(),t=IC(),r=MC(),n=NC(),o=dr().normalizeRanks,i=$C(),a=dr().removeEmptyRanks,s=LC(),u=FC(),c=BC(),l=ZC(),d=YC(),f=dr(),p=_r().Graph;fu=m;function m(N,D){var W=D&&D.debugTiming?f.time:f.notime;W("layout",function(){var z=W(" buildLayoutGraph",function(){return k(N)});W(" runLayout",function(){y(z,W)}),W(" updateInputGraph",function(){b(N,z)})})}function y(N,D){D(" makeSpaceForEdgeLabels",function(){E(N)}),D(" removeSelfEdges",function(){re(N)}),D(" acyclic",function(){t.run(N)}),D(" nestingGraph.run",function(){s.run(N)}),D(" rank",function(){n(f.asNonCompoundGraph(N))}),D(" injectEdgeLabelProxies",function(){P(N)}),D(" removeEmptyRanks",function(){a(N)}),D(" nestingGraph.cleanup",function(){s.cleanup(N)}),D(" normalizeRanks",function(){o(N)}),D(" assignRankMinMax",function(){R(N)}),D(" removeEdgeLabelProxies",function(){I(N)}),D(" normalize.run",function(){r.run(N)}),D(" parentDummyChains",function(){i(N)}),D(" addBorderSegments",function(){u(N)}),D(" order",function(){l(N)}),D(" insertSelfEdges",function(){ce(N)}),D(" adjustCoordinateSystem",function(){c.adjust(N)}),D(" position",function(){d(N)}),D(" positionSelfEdges",function(){he(N)}),D(" removeBorderNodes",function(){V(N)}),D(" normalize.undo",function(){r.undo(N)}),D(" fixupEdgeLabelCoords",function(){q(N)}),D(" undoCoordinateSystem",function(){c.undo(N)}),D(" translateGraph",function(){O(N)}),D(" assignNodeIntersects",function(){M(N)}),D(" reversePoints",function(){K(N)}),D(" acyclic.undo",function(){t.undo(N)})}function b(N,D){e.forEach(N.nodes(),function(W){var z=N.node(W),X=D.node(W);z&&(z.x=X.x,z.y=X.y,D.children(W).length&&(z.width=X.width,z.height=X.height))}),e.forEach(N.edges(),function(W){var z=N.edge(W),X=D.edge(W);z.points=X.points,e.has(X,"x")&&(z.x=X.x,z.y=X.y)}),N.graph().width=D.graph().width,N.graph().height=D.graph().height}var v=["nodesep","edgesep","ranksep","marginx","marginy"],g={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},w=["acyclicer","ranker","rankdir","align"],x=["width","height"],_={width:0,height:0},C=["minlen","weight","width","height","labeloffset"],S={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},T=["labelpos"];function k(N){var D=new p({multigraph:!0,compound:!0}),W=H(N.graph());return D.setGraph(e.merge({},g,me(W,v),e.pick(W,w))),e.forEach(N.nodes(),function(z){var X=H(N.node(z));D.setNode(z,e.defaults(me(X,x),_)),D.setParent(z,N.parent(z))}),e.forEach(N.edges(),function(z){var X=H(N.edge(z));D.setEdge(z,e.merge({},S,me(X,C),e.pick(X,T)))}),D}function E(N){var D=N.graph();D.ranksep/=2,e.forEach(N.edges(),function(W){var z=N.edge(W);z.minlen*=2,z.labelpos.toLowerCase()!=="c"&&(D.rankdir==="TB"||D.rankdir==="BT"?z.width+=z.labeloffset:z.height+=z.labeloffset)})}function P(N){e.forEach(N.edges(),function(D){var W=N.edge(D);if(W.width&&W.height){var z=N.node(D.v),X=N.node(D.w),se={rank:(X.rank-z.rank)/2+z.rank,e:D};f.addDummyNode(N,"edge-proxy",se,"_ep")}})}function R(N){var D=0;e.forEach(N.nodes(),function(W){var z=N.node(W);z.borderTop&&(z.minRank=N.node(z.borderTop).rank,z.maxRank=N.node(z.borderBottom).rank,D=e.max(D,z.maxRank))}),N.graph().maxRank=D}function I(N){e.forEach(N.nodes(),function(D){var W=N.node(D);W.dummy==="edge-proxy"&&(N.edge(W.e).labelRank=W.rank,N.removeNode(D))})}function O(N){var D=Number.POSITIVE_INFINITY,W=0,z=Number.POSITIVE_INFINITY,X=0,se=N.graph(),Q=se.marginx||0,G=se.marginy||0;function J(te){var le=te.x,de=te.y,Re=te.width,ge=te.height;D=Math.min(D,le-Re/2),W=Math.max(W,le+Re/2),z=Math.min(z,de-ge/2),X=Math.max(X,de+ge/2)}e.forEach(N.nodes(),function(te){J(N.node(te))}),e.forEach(N.edges(),function(te){var le=N.edge(te);e.has(le,"x")&&J(le)}),D-=Q,z-=G,e.forEach(N.nodes(),function(te){var le=N.node(te);le.x-=D,le.y-=z}),e.forEach(N.edges(),function(te){var le=N.edge(te);e.forEach(le.points,function(de){de.x-=D,de.y-=z}),e.has(le,"x")&&(le.x-=D),e.has(le,"y")&&(le.y-=z)}),se.width=W-D+Q,se.height=X-z+G}function M(N){e.forEach(N.edges(),function(D){var W=N.edge(D),z=N.node(D.v),X=N.node(D.w),se,Q;W.points?(se=W.points[0],Q=W.points[W.points.length-1]):(W.points=[],se=X,Q=z),W.points.unshift(f.intersectRect(z,se)),W.points.push(f.intersectRect(X,Q))})}function q(N){e.forEach(N.edges(),function(D){var W=N.edge(D);if(e.has(W,"x"))switch((W.labelpos==="l"||W.labelpos==="r")&&(W.width-=W.labeloffset),W.labelpos){case"l":W.x-=W.width/2+W.labeloffset;break;case"r":W.x+=W.width/2+W.labeloffset;break}})}function K(N){e.forEach(N.edges(),function(D){var W=N.edge(D);W.reversed&&W.points.reverse()})}function V(N){e.forEach(N.nodes(),function(D){if(N.children(D).length){var W=N.node(D),z=N.node(W.borderTop),X=N.node(W.borderBottom),se=N.node(e.last(W.borderLeft)),Q=N.node(e.last(W.borderRight));W.width=Math.abs(Q.x-se.x),W.height=Math.abs(X.y-z.y),W.x=se.x+W.width/2,W.y=z.y+W.height/2}}),e.forEach(N.nodes(),function(D){N.node(D).dummy==="border"&&N.removeNode(D)})}function re(N){e.forEach(N.edges(),function(D){if(D.v===D.w){var W=N.node(D.v);W.selfEdges||(W.selfEdges=[]),W.selfEdges.push({e:D,label:N.edge(D)}),N.removeEdge(D)}})}function ce(N){var D=f.buildLayerMatrix(N);e.forEach(D,function(W){var z=0;e.forEach(W,function(X,se){var Q=N.node(X);Q.order=se+z,e.forEach(Q.selfEdges,function(G){f.addDummyNode(N,"selfedge",{width:G.label.width,height:G.label.height,rank:Q.rank,order:se+ ++z,e:G.e,label:G.label},"_se")}),delete Q.selfEdges})})}function he(N){e.forEach(N.nodes(),function(D){var W=N.node(D);if(W.dummy==="selfedge"){var z=N.node(W.e.v),X=z.x+z.width/2,se=z.y,Q=W.x-X,G=z.height/2;N.setEdge(W.e,W.label),N.removeNode(D),W.label.points=[{x:X+2*Q/3,y:se-G},{x:X+5*Q/6,y:se-G},{x:X+Q,y:se},{x:X+5*Q/6,y:se+G},{x:X+2*Q/3,y:se+G}],W.label.x=W.x,W.label.y=W.y}})}function me(N,D){return e.mapValues(e.pick(N,D),Number)}function H(N){var D={};return e.forEach(N,function(W,z){D[z.toLowerCase()]=W}),D}return fu}var hu,ty;function QC(){if(ty)return hu;ty=1;var e=De(),t=dr(),r=_r().Graph;hu={debugOrdering:n};function n(o){var i=t.buildLayerMatrix(o),a=new r({compound:!0,multigraph:!0}).setGraph({});return e.forEach(o.nodes(),function(s){a.setNode(s,{label:s}),a.setParent(s,"layer"+o.node(s).rank)}),e.forEach(o.edges(),function(s){a.setEdge(s.v,s.w,{},s.name)}),e.forEach(i,function(s,u){var c="layer"+u;a.setNode(c,{rank:"same"}),e.reduce(s,function(l,d){return a.setEdge(l,d,{style:"invis"}),d})}),a}return hu}var pu,ny;function e_(){return ny||(ny=1,pu="0.8.5"),pu}var gu,oy;function r_(){return oy||(oy=1,gu={graphlib:_r(),layout:XC(),debug:QC(),util:{time:dr().time,notime:dr().notime},version:e_()}),gu}var t_=r_();const iy=B0(t_);function n_(e,t,r){var l;const n=new Set(e.map(d=>d.id)),o=new Set;for(const d of e)d.parent&&n.has(d.parent)&&o.add(d.parent);const i=new iy.graphlib.Graph({multigraph:!0,compound:!0}),a=r.compactSpacingScale??(r.spacingFactor>0?r.spacingFactor/1.3:1);i.setGraph({rankdir:r.rankDir,nodesep:r.compact?Math.max(r.nodeSep,24*a):r.nodeSep,edgesep:r.compact?Math.min(r.edgeSep,24*a):r.edgeSep,ranksep:r.compact?Math.min(r.rankSep,80*a):r.rankSep,ranker:"network-simplex"}),i.setDefaultEdgeLabel(()=>({})),i.setDefaultNodeLabel(()=>({}));for(const d of e)i.setNode(d.id,{width:d.width+2,height:d.height+2});for(const d of e)d.parent&&n.has(d.parent)&&i.setParent(d.id,d.parent);for(const d of t){if(!n.has(d.source)||!n.has(d.target)||o.has(d.source)||o.has(d.target))continue;const f=Am(d.label,d.icon??((l=d.data)==null?void 0:l.icon),r.edgeLabelFontSize),p=r.rankDir==="LR"||r.rankDir==="RL",m=(f.width?f.width+2*Pm:0)+(d.connectorClearance??0);i.setEdge(d.source,d.target,{minlen:1,weight:1,...m?{width:p?m:Math.max(1,f.height),height:p?Math.max(1,f.height):m,labelpos:"c"}:{}},d.id)}iy.layout(i);const s=new Map;for(const d of e){if(o.has(d.id))continue;const f=i.node(d.id);f&&Number.isFinite(f.x)&&Number.isFinite(f.y)&&s.set(d.id,{x:f.x,y:f.y})}const u=r.compact?1:r.spacingFactor;if(u&&u!==1&&s.size){let d=1/0,f=1/0,p=-1/0,m=-1/0;s.forEach(v=>{d=Math.min(d,v.x),f=Math.min(f,v.y),p=Math.max(p,v.x),m=Math.max(m,v.y)});const y=(d+p)/2,b=(f+m)/2;s.forEach((v,g)=>s.set(g,{x:y+(v.x-y)*u,y:b+(v.y-b)*u}))}const c=r.nodeAlignment??"center";if(c!=="center"){const d=r.rankDir==="LR"||r.rankDir==="RL",f=d?"x":"y",p=d?"width":"height",m=r.rankDir==="RL"||r.rankDir==="BT"?-1:1,y=c==="leading"?-m:m,b=new Map;for(const v of e){const g=s.get(v.id);if(!g)continue;const w=g[f];b.set(w,Math.max(b.get(w)??0,v[p]))}for(const v of e){const g=s.get(v.id);if(!g)continue;const w=g[f],x=(b.get(w)-v[p])/2;s.set(v.id,{...g,[f]:w+y*x})}}return s}function o_(e,t,r,n,o){const i=new Map,a=new Map(e.map(l=>[l.id,l]));for(const l of e){if(!l.parent||!a.has(l.parent))continue;const d=i.get(l.parent);d?d.push(l.id):i.set(l.parent,[l.id])}const s=(l,d=new Set)=>{var p;const f=(p=a.get(l))==null?void 0:p.parent;return!f||!a.has(f)||d.has(l)?0:(d.add(l),1+s(f,d))},u=[...i.keys()].sort((l,d)=>s(d)-s(l)),c=new Map;for(const l of u){let d=null;for(const m of i.get(l)||[]){let y=c.get(m);if(!y){const b=t.get(m);if(!b)continue;const v=r.get(m)||{w:60,h:60};y={x1:b.x-v.w/2,y1:b.y-v.h/2,x2:b.x+v.w/2,y2:b.y+v.h/2}}d=d?{x1:Math.min(d.x1,y.x1),y1:Math.min(d.y1,y.y1),x2:Math.max(d.x2,y.x2),y2:Math.max(d.y2,y.y2)}:{...y}}if(!d)continue;const f=n(l);d={x1:d.x1-f,y1:d.y1-f,x2:d.x2+f,y2:d.y2+f};const p=o(l);if(p){const m=d.x2-d.x1,y=d.y2-d.y1;if(p.w>m){const b=(p.w-m)/2;d.x1-=b,d.x2+=b}if(p.h>y){const b=(p.h-y)/2;d.y1-=b,d.y2+=b}}c.set(l,d)}return c}function i_(e){const t=e.getBoundingClientRect(),r=t.height/e.offsetHeight;if(!Number.isFinite(r)||r<=0)return[];const n=Rm(e),o={x:e.offsetWidth/2,y:e.offsetHeight/2,w:e.offsetWidth,h:e.offsetHeight},i=[...e.querySelectorAll("[data-flow-property]")],a=new Set(i.filter(s=>s.hasAttribute("data-flow-inspection-row")&&s.getBoundingClientRect().height>0).map(s=>s.dataset.flowProperty));return i.flatMap(s=>{if(s.closest(".flow-sdk-node")!==e)return[];if(a.has(s.dataset.flowProperty)&&!s.hasAttribute("data-flow-inspection-row"))return[];const u=s.dataset.flowPortSide;if(u&&["top","right","bottom","left"].includes(u)){const l=Sm(n?Lt(o,n):o,u,Number(s.dataset.flowPortPosition??.5));return[{property:s.getAttribute("data-flow-property"),top:l.y,height:0,anchor:l,...s.dataset.flowPortPlacement==="config"?{placement:"config"}:{},...s.dataset.flowPortRole==="source"||s.dataset.flowPortRole==="target"?{role:s.dataset.flowPortRole}:{}}]}const c=s.getBoundingClientRect();return!c.width||!c.height?[]:[{property:s.getAttribute("data-flow-property"),top:Math.round((c.top-t.top)/r*1e3)/1e3,height:Math.round(c.height/r*1e3)/1e3,...s.dataset.flowPortRole==="source"||s.dataset.flowPortRole==="target"?{role:s.dataset.flowPortRole}:{}}]})}function a_({id:e,x:t,y:r,placed:n,hidden:o,onMount:i,drawHandles:a,drawMode:s,connectedPorts:u,resolvedRows:c,hasCollapseControl:l,handleColor:d,animated:f,animationColor:p,animationWidth:m=8,animationVariant:y,width:b=0,height:v=0,propertyMode:g,reversePorts:w,direction:x="LR",onPropertyRows:_,onSurface:C,children:S}){const T=j.useRef(null),[k,E]=j.useState([]),P=c??k,[R,I]=j.useState();return j.useLayoutEffect(()=>{const O=T.current;if(!O)return;const M=()=>{const V=Rm(O);I(re=>JSON.stringify(re)===JSON.stringify(V)?re:V),C==null||C(e,V)};M();const q=new ResizeObserver(M);q.observe(O);const K=O.querySelector("[data-flow-node-surface]");return K&&q.observe(K),()=>q.disconnect()},[e,S,C]),j.useLayoutEffect(()=>(i(e,T.current),()=>{i(e,null),C==null||C(e,void 0)}),[e,i,C]),j.useLayoutEffect(()=>{const O=T.current;if(!O)return;let M="";const q=()=>{const ce=i_(O),he=g?ce:ce.filter(H=>H.anchor),me=JSON.stringify(he);me!==M&&(M=me,E(he),_==null||_(e,he))};if(q(),!g&&!O.querySelector("[data-flow-port-side]"))return;const K=new ResizeObserver(q),V=()=>{K.disconnect(),K.observe(O),O.querySelectorAll("[data-flow-property]").forEach(ce=>K.observe(ce)),q()};V();const re=new MutationObserver(V);return re.observe(O,{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"]}),O.addEventListener("scroll",q,!0),()=>{K.disconnect(),re.disconnect(),O.removeEventListener("scroll",q,!0)}},[e,g,_,S]),h.jsxs("div",{ref:T,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&&!o?void 0:"hidden"},children:[S,f&&m>0&&b>0&&v>0&&h.jsx("svg",{className:"flow-sdk-node-animation","aria-hidden":"true",pointerEvents:"none",children:h.jsx(_m,{variant:y,x:((R==null?void 0:R.left)??0)+m/2,y:((R==null?void 0:R.top)??0)+m/2,width:((R==null?void 0:R.width)??b)-m,height:((R==null?void 0:R.height)??v)-m,radius:((R==null?void 0:R.radius)??0)-m/2,path:R!=null&&R.outline?`M${R.outline.map(O=>`${O.x} ${O.y}`).join(" L")} Z`:void 0,color:p||d||"currentColor",strokeWidth:m})}),a&&g&&P.map(O=>["source","target"].filter(M=>!O.role||O.role===M).filter(M=>s||(u==null?void 0:u.has(`${M}:${O.property}`))).map(M=>{var q;return h.jsx("button",{type:"button",className:"flow-sdk-property-port","data-property":O.property,"data-port-role":M,"data-port-side":(q=O.anchor)==null?void 0:q.side,"aria-label":`${M==="source"?"Connect":"Input"} ${O.property}`,title:`${M==="source"?"Connect":"Input"} ${O.property}`,style:{color:d,...O.anchor?{top:O.anchor.y,left:O.anchor.x-16}:{top:O.top+O.height/2,[M==="source"!=!!w?"right":"left"]:-16}},onClick:K=>K.stopPropagation()},`${O.property}:${M}`)})),a&&!l&&(!g||!P.length)&&(!g||!P.some(O=>O.anchor))&&h.jsx("button",{type:"button",className:"flow-sdk-handle","aria-label":"Draw edge",title:"Draw edge",style:{color:d,left:((R==null?void 0:R.left)??0)+(x==="RL"?-36:x==="LR"?(R==null?void 0:R.width)??b:((R==null?void 0:R.width)??b)/2),top:((R==null?void 0:R.top)??0)+(x==="BT"?-36:x==="TB"?(R==null?void 0:R.height)??v:((R==null?void 0:R.height)??v)/2),transform:x==="BT"||x==="TB"?"translateX(-50%)":"translateY(-50%)"},onClick:O=>O.stopPropagation(),children:h.jsx(Z.PiPlusBold,{size:24})})]})}const s_=j.memo(a_);class c_{constructor(t,r,n){Ar(this,"_pan");Ar(this,"_zoom");Ar(this,"minZoom");Ar(this,"maxZoom");Ar(this,"size",{w:0,h:0});Ar(this,"listeners",new Set);Ar(this,"animationFrame");Ar(this,"animationTimer");this.minZoom=r,this.maxZoom=n,this._pan={...t.pan},this._zoom=this.clamp(t.zoom)}cancelAnimation(){this.animationFrame!==void 0&&cancelAnimationFrame(this.animationFrame),clearTimeout(this.animationTimer),this.animationFrame=void 0,this.animationTimer=void 0}transition(t,r=!1){if(this.cancelAnimation(),!r||typeof requestAnimationFrame>"u"||typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches){this.set(t.pan,t.zoom);return}const n=this.state,o={pan:{...t.pan},zoom:this.clamp(t.zoom)},i=performance.now(),a=()=>{this.cancelAnimation(),this.set(o.pan,o.zoom)},s=u=>{const c=Math.min(1,(u-i)/300);if(c>=1){a();return}const l=c*c*(3-2*c);this.apply({x:n.pan.x+(o.pan.x-n.pan.x)*l,y:n.pan.y+(o.pan.y-n.pan.y)*l},n.zoom+(o.zoom-n.zoom)*l),this.animationFrame=requestAnimationFrame(s)};this.animationFrame=requestAnimationFrame(s),this.animationTimer=setTimeout(a,400)}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 o=this.clamp(r);o!==this._zoom&&(this._zoom=o,n=!0)}n&&this.emit()}zoomAt(t,r){const n=this.clamp(t),o=this._zoom;if(n===o)return;const i=n/o;this.set({x:r.x-(r.x-this._pan.x)*i,y:r.y-(r.y-this._pan.y)*i},n)}fit(t,r=0,n=!1){const o=t.x2-t.x1,i=t.y2-t.y1;if(!(o>0)||!(i>0)||!this.size.w||!this.size.h)return;const a=this.clamp(Math.min((this.size.w-2*r)/o,(this.size.h-2*r)/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 u_={LR:"rightward",RL:"leftward",TB:"downward",BT:"upward"},yu={w:60,h:60},ay=4,l_=30,sy=300,d_=500,f_=45,h_=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2;function cy(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 p_(e){const{nodes:t,edges:r,direction:n,nodeAlignment:o="center",edgeMode:i="auto",compactPropertyLayout:a=!1,rankSep:s,edgeSep:u,spacingFactor:c=1.3,compactSpacingScale:l,minZoom:d,maxZoom:f,initialViewport:p,containerStyle:m,lineColor:y,drawMode:b,dragMode:v,multiSelect:g,isPerformanceMode:w}=e,[x,_]=j.useState(null),C=j.useMemo(()=>x?(x.mode==="connections"?ql:Pl)(x.id,t,r):null,[x,t,r]),S=i==="auto"||i==="properties",T=j.useMemo(()=>r.filter(A=>Cu(A,i)&&(!C||C.has(A.source)&&C.has(A.target))),[r,i,C]),k=j.useMemo(()=>M0(t,r,i,a,C),[t,r,i,a,C]),E=j.useRef(k);E.current=k;const P=j.useRef(e);P.current=e;const R=j.useRef(null),I=j.useRef(null),O=j.useRef(null),M=j.useRef(null),q=j.useMemo(()=>new c_(p,d,f),[]);j.useEffect(()=>{q.minZoom=d,q.maxZoom=f},[q,d,f]);const K=j.useRef(new Map),V=j.useRef(new Map),re=j.useRef(new Map),ce=j.useRef(null),[he,me]=j.useState(new Map),H=j.useCallback((A,$)=>{me(L=>{if(JSON.stringify(L.get(A))===JSON.stringify($))return L;const U=new Map(L);return $?U.set(A,$):U.delete(A),U})},[]),[N,D]=j.useState(new Map),W=j.useRef(N),z=j.useCallback((A,$)=>{D(L=>{if(JSON.stringify(L.get(A)??[])===JSON.stringify($))return L;const U=new Map(L);return $.length?U.set(A,$):U.delete(A),U})},[]),[X,se]=j.useState(()=>new Map),Q=j.useRef(X);Q.current=X;const G=j.useRef(new Map),J=j.useRef(!1),[te,le]=j.useState(0),de=j.useRef(),Re=j.useRef(),ge=j.useRef(null),ze=j.useRef(),Fe=j.useRef(!1),He=j.useRef(null),ar=j.useRef(c),be=a&&(i==="properties"||!!C),_e=j.useRef(be),[Xe,Ke]=j.useState(!0),Ne=j.useRef(null);Ne.current=C;const Qe=j.useRef(1);Qe.current=(x==null?void 0:x.mode)==="connections"?1.25:1;const Ze=j.useRef(null),gr=j.useRef(t),fr=j.useRef([]),Er=j.useRef(!1),we=()=>{ge.current!==null&&cancelAnimationFrame(ge.current),ge.current=null,clearTimeout(ze.current)},or=()=>{fr.current.length&&(Er.current=!0),!J.current&&P.current.fitOnInit!==!1&&(Fe.current=!0),clearTimeout(Re.current),Re.current=setTimeout(()=>{J.current=!0,le(A=>A+1)},d_)},sr=A=>{we();const $=new Map(Q.current),L=performance.now(),U=()=>{we(),se(A),or()},oe=pe=>{const ke=Math.min(1,(pe-L)/sy);if(ke>=1)return U();const Te=h_(ke),ie=new Map;A.forEach((ae,ue)=>{const ye=$.get(ue);ie.set(ue,ye?{x:ye.x+(ae.x-ye.x)*Te,y:ye.y+(ae.y-ye.y)*Te}:ae)}),se(ie),ge.current=requestAnimationFrame(oe)};ge.current=requestAnimationFrame(oe),ze.current=setTimeout(U,sy+100)},wt=()=>{const A=P.current,$=Qe.current,L=E.current,U=L.nodes.map(pe=>{const ke=K.current.get(pe.id)||yu;return{id:pe.id,parent:pe.parent,width:ke.w,height:ke.h}});let oe;try{const pe=A.compactPropertyLayout&&(A.edgeMode==="properties"||!!Ne.current),ke=A.edgeMode!=="nodes"&&A.edgeMode!=="workflow",Te=L.edges.map(ie=>({...ie,connectorClearance:pe?ke&&(ie.sourceProperty!==void 0||ie.targetProperty!==void 0)?I0:O0:0}));oe=n_(U,Te,{edgeLabelFontSize:A.edgeMode==="nodes"||A.edgeMode==="workflow"?km:hn,rankDir:A.direction,compact:pe,nodeAlignment:A.nodeAlignment,rankSep:A.rankSep*$,edgeSep:A.edgeSep*$,nodeSep:5*$,spacingFactor:A.spacingFactor??1.3,compactSpacingScale:(A.compactSpacingScale??(A.spacingFactor??1.3)/1.3)*$})}catch(pe){console.warn("[flow-sdk] layout failed",pe);return}for(const[pe,ke]of G.current)oe.has(pe)?oe.set(pe,ke):A.nodes.some(Te=>Te.id===pe)||G.current.delete(pe);J.current&&!A.isPerformanceMode?sr(oe):(we(),se(oe),or())},ne=j.useCallback(()=>{clearTimeout(Re.current),clearTimeout(de.current),de.current=setTimeout(wt,P.current.layoutDebounce)},[]);j.useEffect(()=>{const A=new Map(gr.current.map($=>[$.id,$]));t.some($=>{var L;return((L=A.get($.id))==null?void 0:L.collapsed)===!0&&!$.collapsed})&&(fr.current=t.filter($=>!A.has($.id)).map($=>$.id)),gr.current=t,ar.current!==c&&Q.current.size>0&&(J.current=!0,Fe.current=!1,clearTimeout(Re.current)),ar.current=c,_e.current!==be&&(Fe.current=!He.current),_e.current=be,ne()},[t,r,k.nodes,k.edges,be,n,o,s,u,ne,c,l]),j.useEffect(()=>()=>{clearTimeout(de.current),clearTimeout(Re.current),we()},[]);const Be=j.useCallback((A,$)=>{var L,U;if(!ce.current&&typeof ResizeObserver<"u"&&(ce.current=new ResizeObserver(oe=>{let pe=!1;for(const ke of oe){const Te=re.current.get(ke.target);if(!Te)continue;const ie=ke.target,ae=ie.offsetWidth,ue=ie.offsetHeight;if(!ae&&!ue)continue;const ye=K.current.get(Te);ye&&ye.w===ae&&ye.h===ue||(K.current.set(Te,{w:ae,h:ue}),pe=!0)}pe&&ne()})),$){V.current.set(A,$),re.current.set($,A),(L=ce.current)==null||L.observe($);const oe=$.offsetWidth,pe=$.offsetHeight;(oe||pe)&&K.current.set(A,{w:oe,h:pe})}else{const oe=V.current.get(A);oe&&((U=ce.current)==null||U.unobserve(oe),re.current.delete(oe)),V.current.delete(A),K.current.delete(A),W.current.has(A)&&z(A,[])}ne()},[ne,z]);j.useEffect(()=>()=>{var A;return(A=ce.current)==null?void 0:A.disconnect()},[]);const Je=j.useMemo(()=>{const A=new Map;for(const $ of t)$.label&&A.set($.id,$.label);return A},[t]),$e=j.useMemo(()=>o_(k.nodes,X,K.current,A=>m(A).padding,A=>{const $=Je.get(A);if(!$)return;const L=m(A);return{w:_n($,`bold ${L.fontSize}px ${et}`)+2*f_,h:0}}),[k.nodes,X,m,Je]),er=j.useRef($e);er.current=$e;const Y=j.useCallback(A=>{const $=er.current.get(A);if($)return b0($);const L=Q.current.get(A);if(!L)return;const U=K.current.get(A)||yu;return{x:L.x,y:L.y,w:U.w,h:U.h}},[]),B=j.useMemo(()=>{const A=new Map;for(const $ of t){const L=Y($.id);L&&A.set($.id,L)}return R0(N,A,he,r,n)},[N,t,X,$e,he,r,n,Y]);W.current=B;const ee=(A,$)=>{var oe;if(!S||$===void 0)return;const L=(oe=B.get(A))==null?void 0:oe.find(pe=>pe.property===$),U=Y(A);return L&&!L.anchor&&U?U.y-U.h/2+L.top+L.height/2:void 0},Ce=(A,$)=>{var oe,pe;if($===void 0)return;const L=(pe=(oe=B.get(A))==null?void 0:oe.find(ke=>ke.property===$))==null?void 0:pe.anchor,U=Y(A);return L&&U?{x:U.x-U.w/2+L.x,y:U.y-U.h/2+L.y,side:L.side}:void 0},Se=(A,$)=>{const L=Y(A),U=he.get(A);return L&&U&&!$e.has(A)&&ee(A,$)===void 0?Lt(L,U):L},Ee=()=>{const A=[];Q.current.forEach(($,L)=>{if(er.current.has(L))return;const U=K.current.get(L)||yu;A.push(st({x:$.x,y:$.y,w:U.w,h:U.h}))}),er.current.forEach($=>A.push($));try{for(const $ of[I.current,O.current]){const L=$==null?void 0:$.getBBox();L&&L.width>0&&L.height>0&&A.push({x1:L.x,y1:L.y,x2:L.x+L.width,y2:L.y+L.height})}}catch{}return Yn(A)},We=()=>{var L,U;const{pan:A,zoom:$}=q;M.current&&(M.current.style.transform=`translate3d(${A.x}px, ${A.y}px, 0) scale(${$})`),(L=I.current)==null||L.setAttribute("transform",`translate(${A.x} ${A.y}) scale(${$})`),(U=O.current)==null||U.setAttribute("transform",`translate(${A.x} ${A.y}) scale(${$})`)};j.useEffect(()=>{We();let A=null,$;const L=q.onChange(()=>{We();const U=R.current;U&&(U.classList.add("flow-sdk-busy"),clearTimeout($),$=setTimeout(()=>U.classList.remove("flow-sdk-busy"),150)),A===null&&(A=requestAnimationFrame(()=>{var oe,pe;A=null,(pe=(oe=P.current).onViewportChange)==null||pe.call(oe,q.state)}))});return()=>{L(),clearTimeout($),A!==null&&cancelAnimationFrame(A)}},[]),j.useLayoutEffect(()=>{const A=R.current;if(!A)return;const $=()=>{let U=A.clientWidth,oe=A.clientHeight;oe||(oe=Math.max(0,window.innerHeight-A.getBoundingClientRect().top-100),oe&&(A.style.height=`${oe}px`)),U||(U=window.innerWidth,U&&(A.style.width=`${U}px`)),q.size={w:U,h:oe}};if($(),typeof ResizeObserver>"u")return;const L=new ResizeObserver($);return L.observe(A),()=>L.disconnect()},[q]),j.useEffect(()=>{if(Er.current){Er.current=!1;const $=fr.current.flatMap(U=>{const oe=Y(U);return oe?[st(oe)]:[]});fr.current=[];const L=Yn($);if(L){Fe.current=!1,q.center(L,P.current.animateViewport);return}}if(!Fe.current)return;Fe.current=!1;const A=Ee();A&&q.fit(A,50,P.current.animateViewport)},[X]);const Le=j.useMemo(()=>{const A=ie=>Pl(ie,P.current.nodes,P.current.edges),$=(ie,ae=50,ue=P.current.animateViewport)=>{const ye=Yn([...ie].flatMap(cr=>{const Ct=Y(cr);return Ct?[st(Ct)]:[]}));ye&&(Fe.current=!1,q.fit(ye,Number.isFinite(ae)?Math.max(0,ae):50,ue))},L=(ie,ae,ue,ye)=>{if(!Y(ie))return;const cr=ae==="connections"?oe(ie):A(ie);Ze.current||(Ze.current={pan:{...q.pan},zoom:q.zoom}),Ne.current=cr,P.current.compactPropertyLayout&&(Fe.current=!1,He.current=()=>$(Ne.current??cr,ue,ye)),_({id:ie,mode:ae}),P.current.compactPropertyLayout||$(cr,ue,ye)},U=ie=>{He.current?He.current=ie:ie()},oe=ie=>ql(ie,P.current.nodes,P.current.edges),pe=(ie=>{if(ie===void 0)return q.zoom;q.set(void 0,ie)}),ke=(ie=>{if(ie===void 0)return q.pan;q.set(ie)}),Te=(ie,ae)=>{var ye;const ue=(ye=R.current)==null?void 0:ye.getBoundingClientRect();return{x:ie-((ue==null?void 0:ue.left)??0),y:ae-((ue==null?void 0:ue.top)??0)}};return{zoom:pe,pan:ke,setEdgesVisible:Ke,focusNode:(ie,ae,ue)=>U(()=>$(new Set([ie]),ae,ue)),focusBranch:(ie,ae,ue)=>U(()=>$(A(ie),ae,ue)),focusConnections:(ie,ae,ue)=>U(()=>$(oe(ie),ae,ue)),isolateConnections:(ie,ae,ue)=>L(ie,"connections",ae,ue),isolateBranch:(ie,ae,ue)=>L(ie,"branch",ae,ue),restoreView:(ie=P.current.animateViewport)=>{const ae=P.current.compactPropertyLayout&&!!Ne.current;Ne.current=null,_(null);const ue=Ze.current;Ze.current=null,ae?He.current=()=>{ue&&q.transition(ue,ie)}:ue&&U(()=>q.transition(ue,ie))},zoomAt:(ie,ae)=>q.zoomAt(ie,ae),fit:(ie=0,ae=P.current.animateViewport)=>{U(()=>{const ue=Ee();ue&&q.fit(ue,ie,ae)})},centerAndFit:(ie=0,ae=P.current.animateViewport)=>{U(()=>{const ue=Ee();ue&&q.fit(ue,ie,ae)})},center:(ie=P.current.animateViewport)=>{const ae=Ee();ae&&q.center(ae,ie)},clientToModel:(ie,ae)=>q.renderedToModel(Te(ie,ae)),modelToClient:ie=>{var ye;const ae=(ye=R.current)==null?void 0:ye.getBoundingClientRect(),ue=q.modelToRendered(ie);return{x:ue.x+((ae==null?void 0:ae.left)??0),y:ue.y+((ae==null?void 0:ae.top)??0)}},getNodeBox:ie=>Y(ie),setNodePosition:(ie,ae,ue)=>{if(!Q.current.has(ie)||ae&&(!Number.isFinite(ae.x)||!Number.isFinite(ae.y)))return!1;if(we(),!ae)return G.current.delete(ie),ne(),!0;const ye=new Map(Q.current);return ye.set(ie,{...ae}),(ue==null?void 0:ue.persist)===!1?G.current.delete(ie):G.current.set(ie,{...ae}),Q.current=ye,se(ye),(ue==null?void 0:ue.persist)===!1&&ne(),!0},onViewportChange:ie=>q.onChange(ie)}},[]);j.useEffect(()=>{var A,$;return($=(A=P.current).onInit)==null||$.call(A,Le),()=>q.cancelAnimation()},[Le]),j.useEffect(()=>{var A,$;if(te>0){const L=He.current;He.current=null,L==null||L(),($=(A=P.current).onLayoutComplete)==null||$.call(A,Le)}},[Le,te]);const Pe=j.useRef(null),Me=j.useRef(new Map),yr=j.useRef(!1),[Ye,mr]=j.useState(null),[Oe,wr]=j.useState(null),$r=A=>{const $=R.current.getBoundingClientRect();return{x:A.clientX-$.left,y:A.clientY-$.top}},Vn=(A,$)=>{const L=P.current.nodes;for(let U=L.length-1;U>=0;U--){const oe=L[U].id;if(!ct(oe,P.current.edges,P.current.edgeMode)||Ne.current&&!Ne.current.has(oe)||oe===$||er.current.has(oe))continue;const pe=Y(oe);if(pe&&Al(A,st(pe)))return oe}for(const[U,oe]of er.current)if(ct(U,P.current.edges,P.current.edgeMode)&&!(Ne.current&&!Ne.current.has(U))&&U!==$&&Al(A,oe))return U;return null},Wn=(A,$)=>{if(P.current.edgeMode==="nodes"||P.current.edgeMode==="workflow")return null;const L=P.current.direction==="RL",U=Math.max(16,6/q.zoom);let oe=null;for(const pe of[...P.current.nodes].reverse()){if(!ct(pe.id,P.current.edges,P.current.edgeMode)||Ne.current&&!Ne.current.has(pe.id))continue;const ke=Y(pe.id),Te=W.current.get(pe.id);if(!ke||!Te||er.current.has(pe.id))continue;const ie=ke.x+($==="source"!==L?1:-1)*ke.w/2;for(const ae of Te){if(ae.role&&ae.role!==$)continue;const ue=ke.y-ke.h/2+ae.top,ye=Math.hypot(A.x-(ae.anchor?ke.x-ke.w/2+ae.anchor.x:ie),A.y-ue-ae.height/2);if(!ae.anchor&&A.x>=ke.x-ke.w/2&&A.x<=ke.x+ke.w/2&&A.y>=ue&&A.y<=ue+ae.height)return{nodeId:pe.id,property:ae.property};ye<=U&&(!oe||ye<oe.distance)&&(oe={nodeId:pe.id,property:ae.property,distance:ye})}}return oe},Db=A=>{var ke;if(!A.currentTarget.contains(A.target)||A.button!==0||P.current.readOnly)return;Pe.current||(yr.current=!1);const $=A.target;if($.closest('input, textarea, select, [contenteditable="true"], [data-flow-content-toggle]'))return;const L=P.current,U=$r(A);if(A.pointerType==="touch"){Me.current.set(A.pointerId,U);const Te=cy(Me.current);if(Te){Pe.current={kind:"pinch",distance:Te.distance,zoom:q.zoom,anchor:q.renderedToModel(Te.center)},wr(null),mr(null),yr.current=!0;for(const ie of Me.current.keys())A.currentTarget.setPointerCapture(ie);return}}if(Pe.current)return;const oe=L.drawHandles&&$.closest(".flow-sdk-handle"),pe=L.drawHandles&&$.closest(".flow-sdk-property-port");if(L.drawMode||oe||pe){const Te=q.renderedToModel(U),ie=L.drawMode?Wn(Te,"source"):null,ae=pe||oe,ue=ae?(ke=ae.closest("[data-node-id]"))==null?void 0:ke.dataset.nodeId:(ie==null?void 0:ie.nodeId)??Vn(Te),ye=pe?pe.dataset.property:ie==null?void 0:ie.property;if(ue){Pe.current={kind:"draw",pointerId:A.pointerId,source:ue,sourceProperty:ye,reverse:(pe==null?void 0:pe.dataset.portRole)==="target",startClient:{x:A.clientX,y:A.clientY}},yr.current=!0,wr({source:ue,sourceProperty:ye,point:Te,target:null}),A.currentTarget.setPointerCapture(A.pointerId);return}}$.closest(".flow-sdk-node, .flow-sdk-container, .flow-sdk-edge, .flow-sdk-edge-label, .flow-sdk-container-label")||(L.multiSelect?Pe.current={kind:"box",pointerId:A.pointerId,start:U,current:U}:L.dragMode?Pe.current={kind:"pan",pointerId:A.pointerId,start:U,pan0:q.pan,moved:!1}:Pe.current={kind:"tap",pointerId:A.pointerId,start:U,moved:!1},A.currentTarget.setPointerCapture(A.pointerId))},zb=A=>{const $=Pe.current;if(!$||P.current.readOnly)return;const L=$r(A);if(Me.current.has(A.pointerId)&&Me.current.set(A.pointerId,L),$.kind==="pinch"){const U=cy(Me.current);if(!U)return;const oe=Math.max(q.minZoom,Math.min(q.maxZoom,$.zoom*U.distance/$.distance));q.set({x:U.center.x-$.anchor.x*oe,y:U.center.y-$.anchor.y*oe},oe);return}if($.pointerId===A.pointerId)switch($.kind){case"pan":{const U=L.x-$.start.x,oe=L.y-$.start.y;if(!$.moved&&Math.hypot(U,oe)<=ay)return;$.moved=!0,yr.current=!0,q.set({x:$.pan0.x+U,y:$.pan0.y+oe});break}case"tap":{Math.hypot(L.x-$.start.x,L.y-$.start.y)>ay&&($.moved=!0);break}case"box":{yr.current=!0,$.current=L,mr({x1:Math.min($.start.x,L.x),y1:Math.min($.start.y,L.y),x2:Math.max($.start.x,L.x),y2:Math.max($.start.y,L.y)});break}case"draw":{const U=q.renderedToModel(L),oe=Wn(U,$.reverse?"source":"target");wr($.reverse&&oe?{source:oe.nodeId,sourceProperty:oe.property,point:U,target:$.source,targetProperty:$.sourceProperty}:{source:$.source,sourceProperty:$.sourceProperty,point:U,target:(oe==null?void 0:oe.nodeId)??Vn(U,$.source),targetProperty:oe==null?void 0:oe.property});break}}},ol=(A,$)=>{var oe,pe,ke,Te,ie;Me.current.delete(A.pointerId);const L=Pe.current;if(!L)return;if(L.kind==="pinch"){const ae=[...Me.current][0];Pe.current=ae&&P.current.dragMode&&!$?{kind:"pan",pointerId:ae[0],start:ae[1],pan0:q.pan,moved:!0}:null;return}if(L.pointerId!==A.pointerId)return;Pe.current=null;try{A.currentTarget.releasePointerCapture(A.pointerId)}catch{}const U=P.current;switch($=$||!!U.readOnly,L.kind){case"pan":case"tap":!$&&!L.moved&&((oe=U.onBackgroundTap)==null||oe.call(U));break;case"box":{if(mr(null),$)break;const ae=q.renderedToModel(L.start),ue=q.renderedToModel(L.current),ye={x1:Math.min(ae.x,ue.x),y1:Math.min(ae.y,ue.y),x2:Math.max(ae.x,ue.x),y2:Math.max(ae.y,ue.y)};if(ye.x2-ye.x1<1&&ye.y2-ye.y1<1){(pe=U.onBackgroundTap)==null||pe.call(U);break}const cr=[];for(const Ct of U.nodes){const sl=Y(Ct.id);sl&&v0(st(sl),ye)&&cr.push(Ct.id)}cr.length&&((ke=U.onBoxSelect)==null||ke.call(U,cr));break}case"draw":{if(wr(null),$)break;const ae=$r(A),ue=q.renderedToModel(ae),ye=Wn(ue,L.reverse?"source":"target"),cr=(ye==null?void 0:ye.nodeId)??Vn(ue);if(cr===L.source&&(L.sourceProperty===void 0||(ye==null?void 0:ye.property)===void 0||ye.property===L.sourceProperty))break;cr?(Te=U.onEdgeDraw)==null||Te.call(U,L.reverse?cr:L.source,L.reverse?L.source:cr,L.sourceProperty!==void 0||(ye==null?void 0:ye.property)!==void 0?{sourceProperty:L.reverse?ye==null?void 0:ye.property:L.sourceProperty,targetProperty:L.reverse?L.sourceProperty:ye==null?void 0:ye.property}:void 0):Math.max(Math.abs(A.clientX-L.startClient.x),Math.abs(A.clientY-L.startClient.y))>l_&&((ie=U.onDrawIntoSpace)==null||ie.call(U,L.source,ue,L.sourceProperty,L.reverse));break}}},Hr=j.useCallback(()=>{var L;const A=Pe.current,$=[...Me.current.keys()];A&&A.kind!=="pinch"&&$.push(A.pointerId),Pe.current=null,Me.current.clear(),wr(null),mr(null);for(const U of $)(L=R.current)!=null&&L.hasPointerCapture(U)&&R.current.releasePointerCapture(U)},[]);j.useEffect(()=>{const A=$=>{$.key==="Escape"&&Hr()};return window.addEventListener("keydown",A),window.addEventListener("blur",Hr),()=>{window.removeEventListener("keydown",A),window.removeEventListener("blur",Hr),Pe.current=null,Me.current.clear()}},[Hr]),j.useEffect(()=>{Hr()},[b,v,g,i,n,e.drawHandles,e.readOnly,Hr]);const Vb=j.useMemo(()=>{const A=new Map,$=new Map;for(const L of T){if(L.source!==L.target)continue;const U=A.get(L.source)??0;A.set(L.source,U+1),$.set(L.id,U)}return $},[T]),Gn=u_[n],[Un,Wb]=j.useState(null);j.useLayoutEffect(()=>{R.current&&Un&&F0(R.current)});const Hn=m0(T,Se,Gn),Gb=e.onEdgeSelect,Ub=e.onContainerSelect,il=Oe?Oe.target&&Se(Oe.target,Oe.targetProperty)||{x:Oe.point.x,y:Oe.point.y,w:1,h:1}:null,al=Oe?Se(Oe.source,Oe.sourceProperty):null,Hb=["flow-sdk-canvas",b?"flow-sdk-draw":"",w?"flow-sdk-perf":""].filter(Boolean).join(" ");return h.jsxs("div",{ref:R,className:Hb,"data-edge-mode":i,onPointerDownCapture:Db,onPointerMove:zb,onPointerUp:A=>ol(A,!1),onPointerCancel:A=>ol(A,!0),onLostPointerCapture:A=>{const $=Pe.current;$&&($.kind==="pinch"||$.pointerId===A.pointerId)&&Hr()},onClickCapture:A=>{A.currentTarget.contains(A.target)&&(yr.current||e.readOnly)&&(A.preventDefault(),A.stopPropagation())},children:[h.jsx("svg",{className:"flow-sdk-svg",children:h.jsxs("g",{ref:I,children:[h.jsx("g",{className:"flow-sdk-containers",children:[...$e].filter(([A])=>ct(A,r,i)).filter(([A])=>!C||C.has(A)).map(([A,$])=>{var L;return h.jsx(T0,{id:A,rect:$,label:Je.get(A),labelLayer:Un,style:m(A),onSelect:Ub,onCollapse:e.readOnly?void 0:e.onContainerCollapse,selected:(L=e.selectedNodeIds)==null?void 0:L.includes(A)},A)})}),h.jsx("g",{className:"flow-sdk-edges",children:Xe&&T.map(A=>{var U,oe,pe;if(C&&(!C.has(A.source)||!C.has(A.target)))return null;const $=Se(A.source,A.sourceProperty),L=Se(A.target,A.targetProperty);return!$||!L?null:h.jsx(Nl,{id:A.id,edgeData:A.data,validationIssue:A.validationIssue,edgeType:A.type,edgeRadius:e.edgeRadius,propertyMode:S,customEdgeTypes:e.customEdgeTypes,source:$,target:L,sourceProperty:A.sourceProperty,targetProperty:A.targetProperty,sourceY:ee(A.source,A.sourceProperty),targetY:ee(A.target,A.targetProperty),sourcePort:Ce(A.source,A.sourceProperty),targetPort:Ce(A.target,A.targetProperty),dir:Gn,turn:((U=Hn.get(A.id))==null?void 0:U.turn)??A.turn,labelAtTarget:(oe=Hn.get(A.id))==null?void 0:oe.labelAtTarget,labelFraction:(pe=Hn.get(A.id))==null?void 0:pe.labelFraction,color:A.color,labelBg:A.labelBg,label:A.label,labelLayer:Un,dashed:A.dashed,animated:A.animated&&!w,inverted:A.inverted,loopIndex:Vb.get(A.id)??0,onSelect:Gb},A.id)})}),Xe&&Oe&&Cu(Oe,i)&&al&&il&&h.jsx("g",{className:"flow-sdk-ghost",pointerEvents:"none",children:h.jsx(Nl,{id:"__flow-sdk-ghost",edgeData:{id:"__flow-sdk-ghost",source:Oe.source,target:Oe.target??"",sourceProperty:Oe.sourceProperty,targetProperty:Oe.targetProperty},edgeType:e.edgeType,edgeRadius:e.edgeRadius,propertyMode:S,customEdgeTypes:e.customEdgeTypes,source:al,target:il,sourceProperty:Oe.sourceProperty,targetProperty:Oe.targetProperty,sourceY:ee(Oe.source,Oe.sourceProperty),sourcePort:Ce(Oe.source,Oe.sourceProperty),targetPort:Oe.target?Ce(Oe.target,Oe.targetProperty):void 0,targetY:Oe.target?ee(Oe.target,Oe.targetProperty):void 0,dir:Gn,turn:.5,color:y,labelBg:y})})]})}),h.jsx("div",{ref:M,className:"flow-sdk-nodes",children:t.map(A=>{var pe,ke;const $=X.get(A.id),L=$e.get(A.id),U=($==null?void 0:$.x)??(L?(L.x1+L.x2)/2:0),oe=($==null?void 0:$.y)??(L?(L.y1+L.y2)/2:0);return h.jsx(s_,{id:A.id,x:U,y:oe,placed:!!$||!!L,hidden:!ct(A.id,r,i)||!!C&&!C.has(A.id),onMount:Be,drawHandles:e.drawHandles&&!e.readOnly,drawMode:b,connectedPorts:new Set(T.flatMap(Te=>[...Te.source===A.id&&Te.sourceProperty!==void 0?[`source:${Te.sourceProperty}`]:[],...Te.target===A.id&&Te.targetProperty!==void 0?[`target:${Te.targetProperty}`]:[]])),hasCollapseControl:A.hasCollapseControl,handleColor:y,animated:A.animated&&!L&&!w,animationColor:A.animationColor,animationWidth:A.animationWidth,animationVariant:A.animationVariant,width:(pe=K.current.get(A.id))==null?void 0:pe.w,height:(ke=K.current.get(A.id))==null?void 0:ke.h,propertyMode:S,resolvedRows:B.get(A.id),reversePorts:n==="RL",direction:n,onPropertyRows:z,onSurface:H,children:A.element},A.id)})}),Ye&&h.jsx("div",{className:"flow-sdk-box",style:{left:Ye.x1,top:Ye.y1,width:Ye.x2-Ye.x1,height:Ye.y2-Ye.y1}}),h.jsx("svg",{className:"flow-sdk-svg flow-sdk-label-overlay",style:{zIndex:11,pointerEvents:"none"},children:h.jsx("g",{ref:O,transform:`translate(${q.pan.x} ${q.pan.y}) scale(${q.zoom})`,children:h.jsx("g",{ref:Wb,className:"flow-sdk-labels",style:{pointerEvents:b?"none":"visiblePainted",outline:"none"}})})})]})}const g_=j.memo(p_);function Ob({id:e,role:t,side:r,position:n=.5,placement:o,children:i,style:a}){return h.jsx("div",{"data-flow-property":e,"data-flow-port-role":t,"data-flow-port-side":r,"data-flow-port-position":r?n:void 0,"data-flow-port-placement":o,style:{minHeight:32,display:"flex",alignItems:"center",justifyContent:t==="source"?"flex-end":"flex-start",...a,...r?{display:"none"}:{}},children:i??e})}const y_=yn.default.dialog`
|
|
154
|
+
${e=>Dr(e.$surface,e.$border)}
|
|
155
|
+
&[open] {
|
|
156
|
+
display: flex;
|
|
157
|
+
flex-direction: column;
|
|
158
|
+
}
|
|
159
|
+
&,
|
|
160
|
+
& * {
|
|
161
|
+
scrollbar-width: none;
|
|
162
|
+
}
|
|
163
|
+
&::-webkit-scrollbar,
|
|
164
|
+
& *::-webkit-scrollbar {
|
|
165
|
+
display: none;
|
|
166
|
+
}
|
|
167
|
+
`,m_=yn.default.div`
|
|
168
|
+
min-height: 0;
|
|
169
|
+
overflow: auto;
|
|
170
|
+
padding: 32px 0;
|
|
171
|
+
mask-image: linear-gradient(
|
|
172
|
+
to bottom,
|
|
173
|
+
transparent,
|
|
174
|
+
black 32px,
|
|
175
|
+
black calc(100% - 32px),
|
|
176
|
+
transparent
|
|
177
|
+
);
|
|
178
|
+
-webkit-mask-image: linear-gradient(
|
|
179
|
+
to bottom,
|
|
180
|
+
transparent,
|
|
181
|
+
black 32px,
|
|
182
|
+
black calc(100% - 32px),
|
|
183
|
+
transparent
|
|
184
|
+
);
|
|
185
|
+
`;function Ib({nodeAddress:e,active:t,label:r,open:n=!1,onClose:o,children:i,filter:a,height:s}){const{background:u,border:c,colorText:l}=Ve(),d=j.useRef(null),f=j.useId(),{data:p,schema:m,bindings:y}=j.useContext(kr),b=i!==void 0||!!(p&&m&&(y?Yt(y,e,m):gt(p,e,m)));j.useEffect(()=>{var g,w,x,_,C;!t||!b||!n?(g=d.current)==null||g.close():(w=d.current)!=null&&w.open||((x=d.current)==null||x.showModal(),(C=(_=d.current)==null?void 0:_.querySelector("[data-form-filter] input"))==null||C.focus())},[t,b,n]);const v=fe(u);return b?h.jsx(h.Fragment,{children:typeof document<"u"&&Ft.createPortal(h.jsx(y_,{ref:d,id:f,$surface:v,$border:fe(c),"aria-label":`Configure ${r}`,onClose:o,onPointerDown:g=>g.stopPropagation(),onWheel:g=>g.stopPropagation(),onKeyDown:g=>g.stopPropagation(),onClick:g=>{var w;g.stopPropagation(),g.target===g.currentTarget&&((w=d.current)==null||w.close())},style:{margin:"auto",padding:20,width:380,boxSizing:"border-box",maxWidth:"calc(100vw - 32px)",maxHeight:"calc(100dvh - 32px)",height:s,overflow:"hidden",borderRadius:30,background:v,color:fe(l),fontSize:16,textTransform:"none"},children:n&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,flexShrink:0},children:[h.jsx("strong",{style:{overflowWrap:"anywhere",minWidth:0},children:r}),h.jsx("form",{method:"dialog",style:{margin:0},onSubmit:g=>g.stopPropagation(),children:h.jsx(pt,{type:"submit","aria-label":"Close node configuration"})})]}),a&&h.jsx("div",{"data-form-filter":"",style:{flexShrink:0},children:a}),h.jsx(m_,{"data-form-scroll":"",style:s?{flex:1}:void 0,children:i??h.jsx(om,{nodeAddress:e})})]})}),document.body)}):null}const _u=({icon:e,label:t,onClick:r,color:n,boxSize:o=6,...i})=>{const{background:a,border:s,colorText:u}=Ve();return h.jsx(je,{label:t,children:h.jsx(F.Flex,{children:h.jsx(F.Icon,{as:e,boxSize:o,color:n,cursor:r?"pointer":void 0,onClick:r})})})},b_=({data:e,children:t,isInverted:r,isParent:n})=>{var N,D,W,z,X,se;const{selectedNodeIds:o,setSelectedNodeIds:i,selectedEdgeId:a,setSelectedEdgeId:s,isMultiSelectMode:u,isPerformanceMode:c,engineRef:l,callbacks:d,config:f,themeColor:p,direction:m}=Ie(),{background:y,border:b,colorText:v}=Ve(),g=j.useRef(null),w=j.useRef(null),[x,_]=j.useState(!1),[C,S]=j.useState(!1),[T,k]=j.useState(!1),E=e==null?void 0:e.id,P=im(E),R=o.includes(E),I=f.nodeOverlayActions,O=f.renderNodeOverlay,M=(()=>{var Q;try{const G=(Q=l.current)==null?void 0:Q.zoom();return G!==void 0&&G<.08}catch{return!1}})(),q=j.useCallback(Q=>{var J,te,le,de;if(C||f.readOnly)return;const G={shiftKey:Q.shiftKey,ctrlKey:Q.ctrlKey,metaKey:Q.metaKey,altKey:Q.altKey};if(a&&(s(null),(J=d.onEdgeDeselect)==null||J.call(d)),u){const Re=o.includes(E),ge=Re?o.filter(ze=>ze!==E):[...o,E];i(ge),Re?(te=d.onNodeDeselect)==null||te.call(d):(le=d.onNodeSelect)==null||le.call(d,E,e,G)}else i([E]),(de=d.onNodeSelect)==null||de.call(d,E,e,G)},[E,e,o,a,u,C,i,s,d,f]),K=j.useCallback(()=>{var Q;C||f.readOnly||(Q=d.onNodeDoubleClick)==null||Q.call(d,E,e)},[E,e,C,d,f]),V=j.useCallback(()=>{w.current&&clearTimeout(w.current),w.current=setTimeout(()=>_(!0),100)},[]),re=j.useCallback(()=>{w.current&&clearTimeout(w.current),_(!1)},[]),ce=!!((N=e==null?void 0:e.config)!=null&&N.form),he={tabIndex:ce?0:void 0,"aria-haspopup":ce?"dialog":void 0,"aria-expanded":ce?T:void 0,onDoubleClickCapture:Q=>{var G;!ce||f.readOnly||C||!Q.currentTarget.contains(Q.target)||Q.target instanceof Element&&Q.target.closest("button, input, textarea, select, a, [contenteditable=true]")||(Q.preventDefault(),Q.stopPropagation(),i([E]),k(!0),(G=d.onNodeDoubleClick)==null||G.call(d,E,e))},onKeyDown:Q=>{!ce||f.readOnly||Q.target!==Q.currentTarget||Q.key!=="Enter"||(Q.preventDefault(),Q.stopPropagation(),i([E]),k(!0))}},me=ce&&h.jsx(Ib,{nodeAddress:E,active:R,label:e.label||e.headerTitle||"Node",open:T,onClose:()=>{var Q;k(!1),R&&((Q=g.current)==null||Q.focus({preventScroll:!0}))}}),H=Array.isArray((D=e==null?void 0:e.config)==null?void 0:D.ports)?e.config.ports.map(Q=>h.jsx(Ob,{...Q},`${Q.id}:${Q.role}`)):null;return n?h.jsxs(F.Box,{ref:g,...he,onClick:q,onDoubleClick:K,onMouseEnter:V,onMouseLeave:re,cursor:"pointer",position:"relative",children:[me,!c&&(O||I&&I.length>0)&&x&&!M&&h.jsxs(h.Fragment,{children:[h.jsx(F.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>_(!0),onMouseLeave:re}),O?h.jsx(F.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",onMouseEnter:()=>_(!0),onMouseLeave:re,willChange:"transform",children:O({nodeId:E,nodeData:e,isRoot:E==="root",isParent:!0,isHovered:x,setIsHovered:_})}):h.jsx(F.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",bg:y,p:3,borderColor:b,borderWidth:1,borderRadius:15,pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",boxShadow:"lg",onMouseEnter:()=>_(!0),onMouseLeave:re,willChange:"transform",children:h.jsx(F.HStack,{px:2,gap:2,children:I.map((Q,G)=>h.jsxs(F.Box,{display:"contents",children:[G>0&&h.jsx(F.Box,{borderColor:b,height:5,borderRightWidth:1}),h.jsx(_u,{icon:Q.icon,label:Q.label,color:v,bgColor:y,borderColor:b,textColor:v,boxSize:5,onClick:J=>{var te;J.stopPropagation(),(te=d.onNodeHoverAction)==null||te.call(d,Q.id,E,e)}})]},Q.id))})})]}),t({id:E,data:e,isActive:R,isLowZoom:M,isEditing:C,onEditStart:()=>S(!0),onEditEnd:()=>S(!1)}),P&&!((W=e==null?void 0:e.config)!=null&&W.parentContainer)&&((z=e==null?void 0:e.config)==null?void 0:z.collapsed)!==void 0&&(()=>{var J;const Q=m==="TB"||m==="BT",G=r||m==="RL";return h.jsx(F.IconButton,{position:"absolute",...Q?{[m==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:G?void 0:"-75px",left:G?"-75px":void 0,top:"50%",transform:"translateY(-50%)"},"aria-label":e.config.collapsed?"Expand":"Collapse",disabled:f.readOnly,onClick:te=>{var le;te.stopPropagation(),(le=d.onNodeCollapse)==null||le.call(d,E,!e.config.collapsed)},bgColor:fe(((J=e==null?void 0:e.viewProps)==null?void 0:J.bgColor)||p),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:e.config.collapsed?h.jsx(Z.PiPlusBold,{size:30,color:fe("gray.800")}):h.jsx(Z.PiMinusBold,{size:30,color:fe("gray.800")})})})()]}):h.jsxs(F.Box,{ref:g,...he,onClick:q,onDoubleClick:K,onMouseEnter:V,onMouseLeave:re,cursor:"pointer",transition:"transform 0.1s ease",position:"relative",children:[me,H,!c&&(O||I&&I.length>0)&&x&&!M&&h.jsxs(h.Fragment,{children:[h.jsx(F.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>_(!0),onMouseLeave:re}),O?h.jsx(F.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",onMouseEnter:()=>_(!0),onMouseLeave:re,willChange:"transform",children:O({nodeId:E,nodeData:e,isRoot:E==="root",isParent:!!n,isHovered:x,setIsHovered:_})}):h.jsx(F.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",bg:y,p:3,borderColor:b,borderWidth:1,borderRadius:15,pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",boxShadow:"lg",onMouseEnter:()=>_(!0),onMouseLeave:re,willChange:"transform",children:h.jsx(F.HStack,{px:2,gap:2,children:I.map((Q,G)=>h.jsxs(F.Box,{display:"contents",children:[G>0&&h.jsx(F.Box,{borderColor:b,height:5,borderRightWidth:1}),h.jsx(_u,{icon:Q.icon,label:Q.label,color:v,bgColor:y,borderColor:b,textColor:v,boxSize:5,onClick:J=>{var te;J.stopPropagation(),(te=d.onNodeHoverAction)==null||te.call(d,Q.id,E,e)}})]},Q.id))})})]}),h.jsxs(F.Box,{position:"relative",display:"flex",h:"100%",w:"100%",children:[P&&!((X=e==null?void 0:e.config)!=null&&X.parentContainer)&&((se=e==null?void 0:e.config)==null?void 0:se.collapsed)!==void 0&&!n&&(()=>{var te,le,de;const Q=m==="TB"||m==="BT",G=r||m==="RL",J=(te=e==null?void 0:e.config)!=null&&te.labelBelow?((((le=e==null?void 0:e.viewProps)==null?void 0:le.fontSize)||1)*100+100)/2:void 0;return h.jsx(F.IconButton,{position:"absolute",...Q?{[m==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:G?void 0:J===void 0?"-75px":`calc(50% - ${J+75}px)`,left:G?J===void 0?"-75px":`calc(50% - ${J+75}px)`:void 0,alignSelf:J===void 0?"center":void 0,top:J===void 0?void 0:`${J}px`,transform:J===void 0?void 0:"translateY(-50%)",zIndex:J===void 0?void 0:1},"aria-label":e.config.collapsed?"Expand":"Collapse",disabled:f.readOnly,onClick:Re=>{var ge;Re.stopPropagation(),(ge=d.onNodeCollapse)==null||ge.call(d,E,!e.config.collapsed)},bgColor:fe(((de=e==null?void 0:e.viewProps)==null?void 0:de.bgColor)||p),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:e.config.collapsed?h.jsx(Z.PiPlusBold,{size:30,color:fe("gray.800")}):h.jsx(Z.PiMinusBold,{size:30,color:fe("gray.800")})})})(),t({id:E,data:e,isActive:R,isLowZoom:M,isEditing:C,onEditStart:()=>S(!0),onEditEnd:()=>S(!1)})]})]})},Dn=j.memo(b_);function tl(e=!0){const t=j.useRef(null);return j.useEffect(()=>{if(!e||!t.current)return;const r=i=>{i.stopPropagation()},n=t.current,o=["mousedown","mouseup","click","dblclick","pointerdown","pointerup","wheel"];return o.forEach(i=>n.addEventListener(i,r)),()=>{o.forEach(i=>n.removeEventListener(i,r))}},[e]),t}const Zt=({nodeId:e,label:t,color:r,fontWeight:n="bold",fontSize:o="5xl",wrap:i=!1,isEditing:a,onEditStart:s,onEditEnd:u})=>{const{callbacks:c,config:l,readOnly:d}=Ie(),f=l.editable&&!d,[p,m]=j.useState(t),[y,b]=j.useState(),v=j.useRef(null),g=j.useRef(!1),w=tl(a);j.useEffect(()=>{a&&(g.current=!1,v.current&&(v.current.focus(),v.current.select()))},[a]);const x=()=>{var C;if(g.current)return;g.current=!0;const _=p.trim();_&&_!==t&&((C=c.onNodeLabelChange)==null||C.call(c,e,_)),u()};return!f||!a?h.jsx(F.Text,{color:r,fontWeight:n,fontSize:o,minW:0,maxW:"100%",whiteSpace:i?"normal":"nowrap",overflowWrap:i?"anywhere":void 0,overflow:"hidden",textOverflow:"ellipsis",title:t,onDoubleClick:f?_=>{_.stopPropagation(),b({width:_.currentTarget.offsetWidth,height:_.currentTarget.offsetHeight}),m(t),s()}:void 0,cursor:f?"text":void 0,children:t}):h.jsxs("div",{ref:w,style:{position:"relative",width:"max-content",minWidth:y==null?void 0:y.width,maxWidth:900,height:y==null?void 0:y.height},children:[h.jsx(F.Text,{as:"span","aria-hidden":"true",display:"block",visibility:"hidden",fontWeight:n,fontSize:o,lineHeight:"normal",whiteSpace:"pre",overflow:"hidden",children:p||" "}),h.jsx(F.Input,{ref:v,value:p,onChange:_=>m(_.target.value),onBlur:x,onKeyDown:_=>{_.key==="Enter"&&x(),_.key==="Escape"&&(g.current=!0,u())},color:r,fontWeight:n,fontSize:o,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"})]})},v_=({id:e,data:t,isActive:r,isEditing:n,onEditStart:o,onEditEnd:i})=>{var y,b,v,g,w,x,_,C;const{themeColor:a}=Ie(),{colorText:s}=Ve(),u=((y=t==null?void 0:t.viewProps)==null?void 0:y.bgColor)==="transparent",c=((b=t==null?void 0:t.viewProps)==null?void 0:b.outline)===!0,{bgColor:l,borderColor:d,textColor:f}=Jt(((v=t==null?void 0:t.viewProps)==null?void 0:v.bgColor)||a),p=fe(((g=t==null?void 0:t.viewProps)==null?void 0:g.textColor)||(u||c?s:f)),m=((w=t==null?void 0:t.viewProps)==null?void 0:w.borderColor)||(c?!u&&((x=t==null?void 0:t.viewProps)==null?void 0:x.bgColor)||a:d);return h.jsx(F.Box,{"data-flow-node-surface":"",borderRadius:(_=t==null?void 0:t.viewProps)==null?void 0:_.borderRadius,bgColor:c?"transparent":l,...dn(t==null?void 0:t.viewProps,m,r,2),py:14,px:20,whiteSpace:"nowrap",w:"fit-content",children:h.jsxs(F.Flex,{justifyContent:"start",alignItems:"center",gap:8,w:"fit-content",maxW:900,minW:0,fontSize:"5xl",lineHeight:"normal",children:[((C=t==null?void 0:t.config)==null?void 0:C.icon)&&h.jsx(F.Box,{flexShrink:0,children:h.jsx(Mr,{name:t.config.icon,size:80,color:p})}),h.jsx(Zt,{nodeId:e,label:(t==null?void 0:t.label)||(t==null?void 0:t.text)||"",color:p,isEditing:n,onEditStart:o,onEditEnd:i})]})})};function zn(){const{nodeViewModes:e,setNodeViewMode:t,allNodesIconLabel:r,setAllNodesIconLabel:n}=Ie();return{allNodesIconLabel:r,setAllNodesIconLabel:n,getNodeViewMode:o=>e[o]??"default",showNodeProperties:o=>t(o,"properties"),restoreNodeView:o=>t(o,"default"),toggleNodeView:o=>t(o,e[o]==="properties"?"default":"properties"),setNodeViewMode:t}}const x_=({id:e,isActive:t,data:r,isEditing:n,onEditStart:o,onEditEnd:i})=>{var w,x,_,C,S,T,k,E,P,R,I,O,M,q,K;const{themeColor:a}=Ie(),{colorText:s}=Ve(),u=((w=r==null?void 0:r.viewProps)==null?void 0:w.bgColor)==="transparent",c=((x=r==null?void 0:r.viewProps)==null?void 0:x.outline)===!0,l=!u&&((_=r==null?void 0:r.viewProps)==null?void 0:_.bgColor)||a,{borderColor:d,highlightColor:f,textColor:p}=Jt(l),m=fe(((C=r==null?void 0:r.viewProps)==null?void 0:C.textColor)||(u||c?s:p)),y=u&&!c&&!((S=r==null?void 0:r.viewProps)!=null&&S.borderColor)?"transparent":fe(((T=r==null?void 0:r.viewProps)==null?void 0:T.borderColor)||(c?l:d)),b=u||c?"transparent":l!=null&&l.startsWith("#")?l:fe(f),v=(k=r==null?void 0:r.config)==null?void 0:k.icon,g=(r==null?void 0:r.label)??(r==null?void 0:r.text)??"";if((E=r==null?void 0:r.config)!=null&&E.labelBelow){const V=(((P=r==null?void 0:r.viewProps)==null?void 0:P.fontSize)||1)*100;return h.jsxs(F.Flex,{"data-flow-icon-label":"",direction:"column",align:"center",gap:"24px",width:`${Math.max(V+200,360)}px`,position:"relative",children:[h.jsx(F.Flex,{"data-flow-node-surface":"",align:"center",justify:"center",width:`${V+100}px`,height:`${V+100}px`,flexShrink:0,borderRadius:(R=r==null?void 0:r.viewProps)==null?void 0:R.borderRadius,backgroundColor:b,...dn(r==null?void 0:r.viewProps,y,t,2),children:!!v&&h.jsx(Mr,{name:v,size:V,color:m})}),h.jsxs(F.Flex,{"data-flow-icon-caption":"",direction:"column",align:"center",gap:"8px",justify:"center",width:"100%",minW:0,textAlign:"center",children:[h.jsx(Zt,{nodeId:e,label:g,color:fe(((I=r==null?void 0:r.viewProps)==null?void 0:I.textColor)||s),isEditing:n,onEditStart:o,onEditEnd:i,wrap:!0}),typeof((O=r.config)==null?void 0:O.subtitle)=="string"&&r.config.subtitle!==""&&h.jsx(F.Text,{"data-flow-node-subtitle":"",color:fe(((M=r==null?void 0:r.viewProps)==null?void 0:M.textColor)||s),opacity:.65,fontSize:"32px",fontWeight:"normal",lineHeight:1.3,width:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",title:r.config.subtitle,children:r.config.subtitle})]})]})}return h.jsxs(F.Flex,{"data-flow-node-surface":"",align:"center",borderRadius:(q=r==null?void 0:r.viewProps)==null?void 0:q.borderRadius,bgColor:b,style:{backgroundColor:b},textTransform:"capitalize",...dn(r==null?void 0:r.viewProps,y,t,2),px:50,w:"fit-content",whiteSpace:"nowrap",children:[!!v&&h.jsx(F.Flex,{align:"center",py:14,mr:g?8:0,flexShrink:0,children:h.jsx(Mr,{name:v,size:(((K=r==null?void 0:r.viewProps)==null?void 0:K.fontSize)||1)*100,color:m},m)}),(g||!v)&&h.jsx(F.Flex,{justifyContent:"start",py:14,fontSize:"5xl",lineHeight:"normal",w:"fit-content",maxW:900,minW:0,children:h.jsx(Zt,{nodeId:e,label:g,color:m,isEditing:n,onEditStart:o,onEditEnd:i})})]})};function Mb({onExpand:e,toggleLabel:t="Show properties",toggleDisabled:r=!1,renderCompact:n=x_,...o}){const{colorMode:i,callbacks:a}=Ie();return h.jsx(Dn,{...o,children:s=>h.jsxs(F.Box,{position:"relative",children:[h.jsx(n,{...s}),e&&s.isActive&&h.jsx(F.Box,{position:"absolute",top:"-24px",right:"-48px","data-flow-content-toggle":"",children:h.jsx(je,{label:t,children:h.jsx(ve,{"aria-label":t,icon:h.jsx(F.Icon,{as:Z.PiCircleFill,boxSize:4}),variant:"ghost",w:12,h:12,minW:12,color:i==="dark"?"gray.100":"gray.800",disabled:r,onClick:u=>{var c;u.stopPropagation(),e(),(c=a.onNodeViewToggle)==null||c.call(a,o.data.id)}})})})]})})}const uy=1.55;function w_({nodeId:e,content:t,color:r}){const{callbacks:n,config:o,readOnly:i}=Ie(),a=!!o.editable&&!i,[s,u]=j.useState(!1),[c,l]=j.useState(t),[d,f]=j.useState(),p=j.useRef(null),m=j.useRef(!1),y=tl(s);j.useLayoutEffect(()=>{const g=p.current;!s||!g||(g.style.height="auto",g.style.height=`${Math.max((d==null?void 0:d.height)??0,g.scrollHeight)}px`)},[c,s,d]),j.useEffect(()=>{var g;a?s&&(m.current=!1,(g=p.current)==null||g.focus()):u(!1)},[s,a]);const b=g=>{a&&(f({width:g.offsetWidth,height:g.offsetHeight}),l(t),u(!0))},v=()=>{var g;m.current||!a||(m.current=!0,c!==t&&((g=n.onNodeContentChange)==null||g.call(n,e,c)),u(!1))};return!s||!a?h.jsx(F.Box,{"data-flow-content":"",color:r,w:"100%",minH:"1.2em",whiteSpace:"normal",lineHeight:uy,overflowWrap:"anywhere",css:{"& > :first-of-type":{marginTop:0},"& > :last-of-type":{marginBottom:0},"& h1, & h2, & h3, & h4, & h5, & h6":{fontWeight:700,lineHeight:1.2,margin:"1em 0 0.45em"},"& h1":{fontSize:"1.5em"},"& h2":{fontSize:"1.3em"},"& h3":{fontSize:"1.1em"},"& p":{margin:"0.65em 0",whiteSpace:"pre-wrap"},"& ul, & ol":{margin:"0.65em 0",paddingInlineStart:"1.6em"},"& ul":{listStyleType:"disc"},"& ol":{listStyleType:"decimal"},"& li":{display:"list-item",margin:"0.3em 0",paddingInlineStart:"0.15em"},"& li > ul, & li > ol":{margin:"0.25em 0"},"& li > p":{margin:0},"& a":{color:"inherit",textDecoration:"underline"},"& code":{fontFamily:"monospace",fontSize:"0.85em"},"& :not(pre) > code":{background:"color-mix(in srgb, currentColor 10%, transparent)",padding:"0.1em 0.25em",borderRadius:"0.2em"},"& pre":{margin:"0.75em 0",padding:"0.75em",background:"color-mix(in srgb, currentColor 8%, transparent)",border:0,borderRadius:"6px",maxWidth:"100%",overflowX:"auto",whiteSpace:"pre",overflowWrap:"normal",lineHeight:1.5},"& pre code":{background:"transparent",padding:0,whiteSpace:"inherit"},"& strong":{fontWeight:700},"& em":{fontStyle:"italic"},"& blockquote":{margin:"0.4em 0",borderInlineStart:"0.1em solid currentColor",paddingInlineStart:"0.6em"},"& table":{width:"100%",tableLayout:"fixed",borderCollapse:"collapse",margin:"0.4em 0"},"& th, & td":{border:"1px solid currentColor",padding:"0.2em 0.3em",textAlign:"left"},"& th":{fontWeight:700},"& img":{maxWidth:"100%",height:"auto"}},cursor:a?"text":void 0,tabIndex:a?0:void 0,onDoubleClick:g=>{g.stopPropagation(),b(g.currentTarget)},onKeyDown:g=>{a&&g.key==="Enter"&&g.target===g.currentTarget&&(g.preventDefault(),g.stopPropagation(),b(g.currentTarget))},children:h.jsx(ov.default,{options:{forceBlock:!0,wrapper:j.Fragment,disableParsingRawHTML:!0,overrides:{a:{props:{target:"_blank",rel:"noopener noreferrer"}},img:{props:{loading:"lazy",referrerPolicy:"no-referrer"}}}},children:t})}):h.jsx("div",{ref:y,style:{width:d==null?void 0:d.width,minHeight:d==null?void 0:d.height,maxWidth:"100%"},children:h.jsx(F.Textarea,{ref:p,"aria-label":"Node content",value:c,onChange:g=>l(g.target.value),onBlur:v,onKeyDown:g=>{g.stopPropagation(),!g.nativeEvent.isComposing&&(g.key==="Enter"&&(g.ctrlKey||g.metaKey)&&(g.preventDefault(),v()),g.key==="Escape"&&(m.current=!0,u(!1)))},color:r,fontFamily:"inherit",fontSize:"inherit",lineHeight:uy,overflowWrap:"anywhere",whiteSpace:"pre-wrap",rows:1,bg:"transparent",display:"block",style:{border:0,outline:"none",boxShadow:"none"},p:0,w:"100%",h:"100%",minW:0,minH:0,resize:"none"})})}const C_=(e,t,r)=>{var f,p,m,y;const n=((f=e==null?void 0:e.viewProps)==null?void 0:f.bgColor)||t,[o]=n.split("."),i=Jt(n),a=((p=e==null?void 0:e.viewProps)==null?void 0:p.outline)===!0,s=n==="transparent"||a,u=r==="dark"?"gray.200":"gray.900",c=s?"transparent":n!=null&&n.startsWith("#")?fe(n):fe(i.bgColor),l=fe(((m=e==null?void 0:e.viewProps)==null?void 0:m.textColor)||(s?u:i.textColor)),d=fe(((y=e==null?void 0:e.viewProps)==null?void 0:y.borderColor)||(a?n==="transparent"?t:n:i.borderColor));return{...i,bgColor:s?"transparent":i.bgColor,highlightColor:s?"transparent":i.highlightColor,isTransparent:s,propertyColor:s?u:i.propertyColor,bg:n,wordBeforeDot:o,hexbgColor:c,hextextColor:l,hexborderColor:d}},__=(e,t=350)=>`${String(e).substring(0,t)}${String(e).length>t?"...":""}`,S_=e=>e!=null&&e.includes("root")?e.replace("root","untitled"):e,qb=600,E_=3,j_=e=>{const t=Math.max(...Object.keys(e||{}).map(n=>n.length),0);return Math.max(t*28+30,200)};function R_({headerTitle:e,hasContent:t,data:r,icon:n,colors:o,hasConfig:i,id:a,isActive:s,isEditing:u,onEditStart:c,onEditEnd:l,props:d,objVisible:f,setObjVisible:p,onShowNativeIcon:m}){var g,w;const{callbacks:y}=Ie(),b=d.onShowIcon??m,v=b?"Show icon":f?"Show content":"Show properties";return h.jsx(h.Fragment,{children:(e||t||((g=r.config)==null?void 0:g.form)||s&&m)&&h.jsxs(F.Flex,{justify:"flex-start",direction:"row",p:Object.entries(r.description||{}).length?8:20,borderBottomWidth:1,minWidth:"max-content !important",width:"100%",textTransform:"capitalize",align:"center",textOverflow:"ellipsis",alignItems:"center",fontWeight:"bold",color:o.propertyColor,bgColor:o.highlightColor,borderBottomColor:!i&&!t?"transparent":o.hexborderColor,children:[!!n&&h.jsx(F.Flex,{mr:6,alignItems:"center",flexShrink:0,children:h.jsx(Mr,{name:n,size:64,color:o.hextextColor},o.hextextColor)}),h.jsx(Zt,{nodeId:a,label:S_(e),color:((w=r==null?void 0:r.viewProps)==null?void 0:w.textColor)||o.propertyColor,isEditing:u,onEditStart:c,onEditEnd:l}),s&&(t||b)&&h.jsx(F.Box,{ml:"auto",pl:6,flexShrink:0,"data-flow-content-toggle":"",children:h.jsx(je,{label:v,children:h.jsx(ve,{"aria-label":v,icon:h.jsx(F.Icon,{as:Z.PiCircleFill,boxSize:4}),variant:"ghost",w:12,h:12,minW:12,color:o.hextextColor,onClick:x=>{var _;x.stopPropagation(),b?b():p(!f),(_=y.onNodeViewToggle)==null||_.call(y,a)}})})})]})})}function k_({data:e,resourcePorts:t,inspecting:r,form:n,inspectionPorts:o,extraPorts:i,colors:a,direction:s,uniformKeyWidth:u}){const{edgeById:c}=Gr(),l=new Set;for(const{data:d}of c.values())d.source===e.id&&d.sourceProperty!==void 0&&l.add(`source:${d.sourceProperty}`),d.target===e.id&&d.targetProperty!==void 0&&l.add(`target:${d.targetProperty}`);return h.jsx(F.Box,{children:Object.entries(e.description||{}).map(([d,f],p)=>{var I,O,M;const m=t&&Object.keys(t).find(q=>q.slice(q.indexOf(":")+1)===d),y=r&&((I=n==null?void 0:n.type.ports)==null?void 0:I[d]),b=m??(y?`${y.kind}:${d}`:d),v=o.find(q=>q.id===b),g=m?"source":v==null?void 0:v.role,w=l.has(`source:${b}`),x=l.has(`target:${b}`),_=i.some(q=>q.id===d),C=f===""&&(_||(g?l.has(`${g}:${b}`):w||x)),S=g??(w!==x?w?"source":"target":void 0),T=(v==null?void 0:v.side)??(S?S==="source"!=(s==="RL")?"right":"left":void 0),k=C&&T==="right"?"right":"left",E=_?d.replace(/^(template|input|output|config|error):/,""):d,P=jr(a.wordBeforeDot)[typeof f],R=jr(a.wordBeforeDot).property;return h.jsxs(F.Box,{"data-flow-property":m&&(s==="TB"||s==="BT")?void 0:b,"data-flow-port-role":g,"data-flow-inspection-row":r?"":void 0,children:[h.jsxs(F.Flex,{flexWrap:"nowrap",overflow:"hidden",children:[h.jsx(F.Flex,{justifyContent:"start",align:"center",background:a.highlightColor,width:C?"100%":`${u}px`,minWidth:`${u}px`,borderRightColor:a.hexborderColor,borderRightWidth:C?0:1,children:h.jsx(F.Text,{py:5,px:10,w:"100%",textAlign:k,whiteSpace:"nowrap",fontWeight:"bold",fontSize:"4xl",color:((O=e==null?void 0:e.viewProps)==null?void 0:O.textColor)||(a.isTransparent?a.hextextColor:R),children:E})}),!C&&h.jsx(F.Flex,{flex:1,justifyContent:"start",overflow:"hidden",p:4,background:a.hexbgColor,w:qb,maxH:200,children:h.jsx(F.Text,{overflow:"hidden",py:3,px:4,whiteSpace:"normal",textOverflow:"ellipsis",fontSize:"4xl",color:((M=e==null?void 0:e.viewProps)==null?void 0:M.textColor)||(a.isTransparent?a.hextextColor:P),fontWeight:400,children:__(f)})})]}),p!==Object.entries(e.description||{}).length-1&&h.jsx(F.Box,{borderTopWidth:1,my:0,borderColor:a.hexborderColor})]},d)})})}function P_(e){var w,x,_;const{themeColor:t,colorMode:r,direction:n}=Ie(),o=zn(),i=o.getNodeViewMode(e.data.id)==="properties",a=C=>o.setNodeViewMode(e.data.id,C?"properties":"default"),s=!!e.onShowIcon||i||typeof((w=e.data.config)==null?void 0:w.content)!="string",{bindings:u,data:c,schema:l}=j.useContext(kr),d=(x=u==null?void 0:u[e.data.id])==null?void 0:x.portResources,f=u?Yt(u,e.data.id,l):c&&l?gt(c,e.data.id,l):void 0,p=f&&xe(c,"address"in f?f.address:e.data.id),m=p&&typeof p=="object"&&f?Object.fromEntries(Object.keys(f.type.properties).filter(C=>{var S;return Object.prototype.hasOwnProperty.call(p,C)&&xn((S=f.fields[C])==null?void 0:S.$visibleWhen,c)}).map(C=>[C,p[C]!==null&&typeof p[C]=="object"?JSON.stringify(p[C],null,2):p[C]===null?"null":p[C]])):{},y=d?Object.fromEntries(Object.entries(d).map(([C,S])=>{var T;return[C.slice(C.indexOf(":")+1),((T=xe(c,S))==null?void 0:T.name)??S.split(".").at(-1)]})):Object.keys(e.data.description??{}).length?e.data.description:m,b=s&&!d?((_=e.data.config)==null?void 0:_.ports)??[]:[],v=b.filter(C=>!Object.prototype.hasOwnProperty.call(y,C.id)&&!Object.entries((f==null?void 0:f.type.ports)??{}).some(([S,T])=>`${T.kind}:${S}`===C.id&&Object.prototype.hasOwnProperty.call(y,S))),g={...y,...Object.fromEntries(v.map(C=>[C.id,""]))};return{themeColor:t,colorMode:r,direction:n,objVisible:i,setObjVisible:a,inspecting:s,resourcePorts:d,form:f,description:g,inspectionPorts:b,extraPorts:v}}const nl=e=>{var b,v,g;const{themeColor:t,colorMode:r,direction:n,objVisible:o,setObjVisible:i,inspecting:a,resourcePorts:s,form:u,description:c,inspectionPorts:l,extraPorts:d}=P_(e),f=zn(),p=f.getNodeViewMode(e.data.id)==="icon-label",y=!e.onShowIcon&&!((b=e.data.config)!=null&&b.parentContainer)&&typeof((v=e.data.config)==null?void 0:v.content)!="string"?()=>f.setNodeViewMode(e.data.id,"icon-label"):void 0;return!e.onShowIcon&&p?h.jsx(Mb,{...e,data:{...e.data,label:e.data.label??e.data.headerTitle,config:{...e.data.config,labelBelow:!0,icon:((g=e.data.config)==null?void 0:g.icon)||"PiBracketsCurly"}},onExpand:()=>f.restoreNodeView(e.data.id)}):h.jsx(Dn,{...e,data:{...e.data,description:c},children:({id:w,data:x,isActive:_,isEditing:C,onEditStart:S,onEditEnd:T})=>{var V,re,ce,he,me,H;const k=C_(x,t,r),E=x.label??x.headerTitle,P=Object.entries(x.description||{}).length>0,R=j_(x.description),I=(re=(V=e.data)==null?void 0:V.config)==null?void 0:re.icon,O=(he=(ce=e.data)==null?void 0:ce.config)==null?void 0:he.content,M=typeof O=="string"&&!e.onShowIcon,q=((me=x==null?void 0:x.viewProps)==null?void 0:me.borderRadius)??"53px",K=dn(x==null?void 0:x.viewProps,k.hexborderColor,_,E_);return h.jsx(F.Flex,{justifyContent:"space-between",...x==null?void 0:x.viewProps,"data-flow-node-surface":"",direction:"column",p:0,borderRadius:q,overflow:"hidden",alignItems:"center",style:{backgroundColor:k.hexbgColor,transition:"border-color 0.2s ease-in-out"},width:"100%",minW:M||e.onShowIcon?R+qb+K.borderWidth*2:void 0,...K,children:h.jsxs(F.Flex,{width:"100%",direction:"column",borderRadius:q,borderColor:k.hexborderColor,borderWidth:0,overflow:"hidden",children:[h.jsx(R_,{headerTitle:E,hasContent:M,data:x,icon:I,colors:k,hasConfig:P,id:w,isActive:_,isEditing:C,onEditStart:S,onEditEnd:T,props:e,objVisible:o,setObjVisible:i,onShowNativeIcon:y}),M&&!o?h.jsx(F.Flex,{w:"100%",overflow:"auto",justifyContent:"start",background:k.highlightColor,p:12,fontSize:"5xl",lineHeight:"normal",children:h.jsx(w_,{nodeId:w,content:O,color:((H=x==null?void 0:x.viewProps)==null?void 0:H.textColor)||k.hextextColor})}):h.jsx(k_,{data:x,resourcePorts:s,inspecting:a,form:u,inspectionPorts:l,extraPorts:d,colors:k,direction:n,uniformKeyWidth:R})]})})}})};nl.displayName="NodeJsonObjectView";const Nb=e=>{var c,l,d,f,p,m,y;const t=zn(),r=t.getNodeViewMode(e.data.id)==="properties",n=b=>t.setNodeViewMode(e.data.id,b?"properties":"default"),{callbacks:o,readOnly:i}=Ie(),a=(l=(c=e.data)==null?void 0:c.config)==null?void 0:l.parentContainer,s=a?"Show parent":"Show properties",u=a||((f=(d=e.data)==null?void 0:d.config)==null?void 0:f.form)||((y=(m=(p=e.data)==null?void 0:p.config)==null?void 0:m.ports)==null?void 0:y.length);return!a&&u&&r?h.jsx(nl,{...e,onShowIcon:()=>n(!1)}):h.jsx(Mb,{...e,toggleLabel:s,toggleDisabled:a&&i,onExpand:u?()=>{var b;a?(b=o.onNodeCollapse)==null||b.call(o,e.data.id,!1):n(!0)}:void 0})},$b=e=>h.jsx(Nb,{...e,renderCompact:v_}),Lb=e=>h.jsx(Nb,{...e}),Fb=e=>h.jsx(Dn,{...e,children:()=>null});$b.displayName="text";Lb.displayName="arrayView";Fb.displayName="ParentContainerView";const A_={objectView:nl,arrayView:Lb,text:$b,parentContainer:Fb},T_=({children:e,pattern:t="dot",backgroundColor:r})=>{const{colorMode:n}=Ie(),o=n==="dark",i=o?"--chakra-colors-gray-700":"--chakra-colors-gray-500",a=o?"--chakra-colors-gray-700":"--chakra-colors-gray-800";return t==="none"?h.jsx(F.Box,{"data-flow-background":"none",width:"100%",height:"100%",padding:0,bg:r,children:e}):h.jsxs(F.Box,{"data-flow-background":t,position:"relative",width:"100%",height:"100%",padding:0,bg:r,children:[h.jsx(F.Box,{position:"absolute",top:0,left:0,right:0,bottom:0,width:"100%",height:"100%",zIndex:0,pointerEvents:"none",style:{backgroundImage:t==="dot"?`radial-gradient(var(${i}) 8%, transparent 8%)`:t==="steel"?`repeating-linear-gradient(45deg, var(${a}) 0, var(${a}) 1px, transparent 1px, transparent 20px)`:`linear-gradient(var(${a}) 1px, transparent 1px), linear-gradient(90deg, var(${a}) 1px, transparent 1px)`,backgroundSize:"20px 20px",opacity:.3}}),h.jsx(F.Box,{position:"relative",width:"100%",height:"100%",zIndex:1,padding:0,children:e})]})},O_=.4,Kr={borderWidth:6,borderStyle:"solid",borderRadius:50,fontSize:70,padding:120,labelPosition:"top",labelMargin:90},I_=({nodes:e,edges:t})=>{const{themeColor:r,spacing:n,edgeRadius:o,backgroundVariant:i,setBackgroundSelected:a,edgeColor:s,direction:u,nodeAlignment:c,edgeMode:l,compactPropertyLayout:d,workflowContract:f,parentNodeStyle:p,engineRef:m,callbacks:y,config:b,selectedNodeIds:v,setSelectedNodeIds:g,selectedEdgeId:w,setSelectedEdgeId:x,setIsPerformanceMode:_,isZoomMode:C,setIsZoomMode:S,isMultiSelectMode:T,setIsMultiSelectMode:k,isDragMode:E,setIsDragMode:P,isEdgeHandlesEnabled:R,isArrayNodeMode:I}=Ie(),O=j.useRef(null),[M,q]=j.useState(null),K=e.length>200;j.useEffect(()=>{_(K)},[K,_]);const{edgeSep:V,rankSep:re,spacingFactor:ce}=j.useMemo(()=>{const Y=y0(e.length),B=n<1?.3+.7*n:.5+.5*n;return{edgeSep:Y.edgeSep*B,rankSep:Y.rankSep*B,spacingFactor:1.3+(n-1)*(n<1?.4:.3)}},[e.length,n]),{bgColor:he}=Jt(r),{canvas:me,borderSecondary:H,colorText:N}=Ve(),D=i==="transparent"?"transparent":b.backgroundColor||me,W=j.useCallback(Y=>{if(Y!=null&&Y.includes("gray"))return"whitesmoke";if(!Y)return fe(r);switch(Y){case"dark":return fe(D);case"light":return fe(H);default:return fe(Y)}},[r,D,H]),z=b.colorMode==="dark",X=j.useMemo(()=>W(z?he:"light"),[z,he,W]),se=s?W(s):X,Q=j.useMemo(()=>b.initialViewport||{pan:{x:0,y:0},zoom:.01},[]),G=u==="C"?"LR":u,J=j.useCallback(Y=>{const B={...p,...Y};return{...B,bgColor:B.bgColor||r,bgOpacity:B.outline?0:B.bgOpacity??O_}},[p,r]),te=j.useMemo(()=>{var B;const Y=new Map;for(const ee of e)(B=ee.data)!=null&&B.id&&Y.set(ee.data.id,ee);return Y},[e]),le=j.useMemo(()=>{var B;const Y=new Map;for(const ee of t)(B=ee.data)!=null&&B.id&&Y.set(ee.data.id,ee);return Y},[t]),de=j.useCallback(Y=>{var Se;const B=(Se=te.get(Y))==null?void 0:Se.data,ee=J(B==null?void 0:B.viewProps),Ce=fe(ee.bgColor);return{animated:!!(B!=null&&B.isNodeAnimated)&&!K,animationVariant:B==null?void 0:B.nodeAnimationVariant,animationColor:fe(ee.borderColor||r),bgColor:ee.outline?"transparent":Ce,bgOpacity:ee.bgOpacity,borderColor:ee.borderColor?fe(ee.borderColor):ee.outline&&ee.bgColor==="transparent"?fe(r):Ce,borderWidth:Ht(ee.borderWidth,Kr.borderWidth),borderStyle:ee.borderStyle??Kr.borderStyle,borderRadius:ee.borderRadius??Kr.borderRadius,textColor:ee.textColor?fe(ee.textColor):ee.outline||ee.bgColor==="transparent"?fe(N):Ce,fontSize:ee.fontSize??Kr.fontSize,labelPosition:ee.labelPosition??Kr.labelPosition,labelMargin:Kr.labelMargin,labelBg:cl(W("dark"),Ce,ee.bgOpacity)??W("dark"),padding:ee.padding??Kr.padding}},[J,te,N,r,K,W]),Re=j.useMemo(()=>{var ee,Ce;const Y=new Map;for(const Se of t){const Ee=(ee=Se.data)==null?void 0:ee.source,We=(Ce=Se.data)==null?void 0:Ce.target;if(!Ee||!We||Ee===We)continue;const Le=Ee<We?`${Ee}|${We}`:`${We}|${Ee}`,Pe=Y.get(Le);Pe?Pe.push({id:Se.data.id,source:Ee}):Y.set(Le,[{id:Se.data.id,source:Ee}])}const B=new Map;for(const[Se,Ee]of Y){if(Ee.length<2)continue;const We=Se.split("|")[0],Le=Math.min(20,70/Ee.length);Ee.forEach(({id:Pe,source:Me},yr)=>{const Ye=50+(yr-(Ee.length-1)/2)*Le;B.set(Pe,(Me===We?Ye:100-Ye)/100)})}return B},[t]),ge=j.useMemo(()=>{const Y=W("dark");return t.filter(B=>{var ee;return((ee=B.data)==null?void 0:ee.id)&&B.data.source&&B.data.target}).map(({data:B})=>{var Ee,We,Le,Pe,Me,yr;let ee=Y;const Ce=(We=(Ee=te.get(B.source))==null?void 0:Ee.data)==null?void 0:We.parent,Se=(Pe=(Le=te.get(B.target))==null?void 0:Le.data)==null?void 0:Pe.parent;if(Ce&&Ce===Se){const Ye=J((yr=(Me=te.get(Ce))==null?void 0:Me.data)==null?void 0:yr.viewProps),mr=cl(Y,fe(Ye.bgColor),Ye.bgOpacity);mr&&(ee=mr)}return{id:B.id,data:B,type:B.type??b.edgeType??"rounded-orthogonal",source:B.source,target:B.target,sourceProperty:B.sourceProperty,targetProperty:B.targetProperty,label:B.label,validationIssue:(l==="auto"||l==="properties")&&(B.sourceProperty!==void 0||B.targetProperty!==void 0)&&f?Iu(f,B):void 0,color:B.color?fe(B.color):se,labelBg:ee,dashed:!!B.isEdgeDashed,animated:!!B.isEdgeAnimated,inverted:!!B.isInverted,turn:Re.get(B.id)??.5}})},[t,se,Re,b.edgeType,l,f,te,J,W]),ze=j.useMemo(()=>{var B;const Y=new Set;for(const ee of e)(B=ee.data)!=null&&B.parent&&Y.add(ee.data.parent);return Y},[e]),Fe=j.useMemo(()=>{var B;const Y=new Map;for(const ee of t)(B=ee.data)!=null&&B.source&&!Y.has(ee.data.source)&&Y.set(ee.data.source,ee.data);return Y},[t]),He=j.useMemo(()=>{const Y={...A_,...b.customViews};return e.filter(B=>{var ee;return(ee=B.data)==null?void 0:ee.id}).map(B=>{var We,Le,Pe,Me;const ee=ze.has(B.data.id)&&!B.data.parent,Ce=ee?B.data.label??B.data.headerTitle??"Container":void 0,Se=ee?Y.parentContainer:Y[B.data.type]||Y.text,Ee=Fe.get(B.data.id);return{id:B.data.id,collapsed:(We=B.data.config)==null?void 0:We.collapsed,parent:B.data.parent,label:Ce,animated:!!B.data.isNodeAnimated,animationVariant:B.data.nodeAnimationVariant,hasCollapseControl:((Le=B.data.config)==null?void 0:Le.collapsed)!==void 0,animationColor:fe(((Pe=B.data.viewProps)==null?void 0:Pe.borderColor)||r),animationWidth:Ht((Me=B.data.viewProps)==null?void 0:Me.borderWidth,8),element:j.createElement(Se,{...B,isInverted:Ee==null?void 0:Ee.isInverted,isParent:ee,key:`${B.data.id}-${r}`})}})},[e,ze,Fe,r,b.customViews]),ar=j.useMemo(()=>K?300:e.length>50?150:e.length>20?100:50,[e.length,K]),be=j.useRef(b);be.current=b;const _e=j.useRef(C);_e.current=C;const Xe=j.useRef(I);Xe.current=I;const Ke=j.useRef(v);Ke.current=v;const Ne=j.useRef(w);Ne.current=w;const Qe=j.useRef(T);Qe.current=T;const Ze=j.useRef(te);Ze.current=te;const gr=j.useRef(le);gr.current=le;const fr=j.useRef(new Map);j.useEffect(()=>{var ee,Ce;const Y=new Map([...le].filter(([,Se])=>te.has(Se.data.source)&&te.has(Se.data.target))),B=fr.current;fr.current=Y;for(const[Se,Ee]of B)Y.has(Se)||(Ne.current===Se&&(x(null),(ee=y.onEdgeDeselect)==null||ee.call(y)),(Ce=y.onEdgeRemove)==null||Ce.call(y,Se,Ee.data))},[le,te,y,x]),j.useEffect(()=>{const Y=O.current;if(!M||!Y)return;let B=null,ee=null,Ce=0,Se=0,Ee=0,We=0,Le=0;const Pe=Me=>{if(be.current.readOnly)return;Me.preventDefault(),Me.stopPropagation(),_e.current||Me.metaKey||Me.ctrlKey?(Ee+=Me.deltaY,We=Me.clientX,Le=Me.clientY,ee===null&&(ee=requestAnimationFrame(()=>{ee=null;const Ye=be.current,mr=M.zoom(),Oe=Ee;Ee=0;let wr=mr-Oe*.05/100;wr=Math.max(Ye.minZoom??.01,Math.min(Ye.maxZoom??1.5,wr));const $r=Y.getBoundingClientRect();M.zoomAt(wr,{x:We-$r.left,y:Le-$r.top})}))):(Ce+=Me.deltaX,Se+=Me.deltaY,B===null&&(B=requestAnimationFrame(()=>{B=null;const Ye=M.pan(),mr=M.zoom(),Oe=.35,wr=Ce,$r=Se;Ce=0,Se=0,M.pan({x:Ye.x+-wr*Oe/mr,y:Ye.y+-$r*Oe/mr})})))};return Y.addEventListener("wheel",Pe,{passive:!1}),()=>{Y.removeEventListener("wheel",Pe),B!==null&&cancelAnimationFrame(B),ee!==null&&cancelAnimationFrame(ee)}},[M]),j.useEffect(()=>{if(b.disableKeyboardShortcuts)return;const Y=B=>{var Ce,Se,Ee,We;if(be.current.readOnly)return;const ee=B.target;if(!(ee.tagName==="INPUT"||ee.tagName==="TEXTAREA"||ee.isContentEditable)){if((B.key==="z"||B.key==="Z")&&S(!_e.current),(B.key==="m"||B.key==="M")&&k(!T),(B.key==="d"||B.key==="D")&&P(!E),(B.key==="Delete"||B.key==="Backspace")&&Ne.current){B.preventDefault();const Le=Ne.current;(Se=y.onEdgeDelete)==null||Se.call(y,Le,((Ce=gr.current.get(Le))==null?void 0:Ce.data)??{id:Le}),x(null);return}if((B.key==="Delete"||B.key==="Backspace")&&Ke.current.length>0){B.preventDefault();const Le=Ke.current.filter(Pe=>Pe!=="root");if(Le.length===0)return;for(const Pe of Le){const Me=(Ee=Ze.current.get(Pe))==null?void 0:Ee.data;(We=y.onNodeDelete)==null||We.call(y,Pe,Me||{})}g([])}}};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[T,E,S,k,P,b.disableKeyboardShortcuts,y,g,x]);const Er=j.useCallback(Y=>{var B;m.current=Y,q(Y),(B=y.onInit)==null||B.call(y,Y)},[m,y]),we=j.useCallback(Y=>{var B;return(B=y.onViewportChange)==null?void 0:B.call(y,Y)},[y]),or=j.useCallback(Y=>{var ee,Ce,Se;const B=((ee=gr.current.get(Y))==null?void 0:ee.data)??{id:Y};if(Ne.current===Y&&Qe.current){x(null),(Ce=y.onEdgeDeselect)==null||Ce.call(y);return}Ke.current.length&&g([]),x(Y),(Se=y.onEdgeSelect)==null||Se.call(y,Y,B)},[y,x,g]),sr=j.useCallback(()=>{var Y,B,ee;a(!0),(Y=y.onBackgroundClick)==null||Y.call(y),Ke.current.length&&(g([]),(B=y.onNodeDeselect)==null||B.call(y)),Ne.current&&(x(null),(ee=y.onEdgeDeselect)==null||ee.call(y))},[y,g,x,a]),wt=j.useCallback(Y=>{var Ce,Se;const B=Ke.current,ee=Y.filter(Ee=>!B.includes(Ee));if(ee.length){g([...B,...ee]);for(const Ee of ee)(Se=y.onNodeSelect)==null||Se.call(y,Ee,((Ce=Ze.current.get(Ee))==null?void 0:Ce.data)??{id:Ee})}},[y,g]),ne=j.useCallback((Y,B)=>{var ee,Ce;g([Y]),(Ce=y.onNodeSelect)==null||Ce.call(y,Y,((ee=Ze.current.get(Y))==null?void 0:ee.data)??{id:Y},B)},[y,g]),Be=j.useCallback((Y,B,ee)=>{var Ce;return(Ce=y.onEdgeCreate)==null?void 0:Ce.call(y,Y,B,ee)},[y]),Je=j.useCallback((Y,B,ee,Ce=!1)=>{var Se,Ee;l==="properties"&&((Se=y.onNodeCreateRequest)==null?void 0:Se.call(y,{sourceNodeId:Y,position:B,sourceProperty:ee,reverse:Ce}))===!0||ee!==void 0||Ce||(Ee=y.onNodeCreate)==null||Ee.call(y,{type:"text",sourceNodeId:Y,position:B,isArrayMode:Xe.current})},[y,l]),$e=!b.readOnly&&R&&b.edgeHandles!==!1,er=i==="transparent"?"none":i;return h.jsx(T_,{pattern:er,backgroundColor:D,children:h.jsx(F.Box,{ref:O,padding:0,width:"100%",height:"100%",flex:1,position:"relative",children:h.jsx(g_,{nodes:He,edges:ge,direction:G,nodeAlignment:c,onContainerCollapse:Y=>{var B,ee;(B=y.onNodeCollapse)==null||B.call(y,Y,!0),(ee=y.onNodeViewToggle)==null||ee.call(y,Y)},selectedNodeIds:v,edgeMode:l,compactPropertyLayout:d,edgeType:b.edgeType,edgeRadius:o,customEdgeTypes:b.customEdgeTypes,rankSep:re,edgeSep:V,spacingFactor:ce,compactSpacingScale:n,layoutDebounce:ar,isPerformanceMode:K,minZoom:b.minZoom??.01,maxZoom:b.maxZoom??1.5,initialViewport:Q,fitOnInit:!b.initialViewport,readOnly:!!b.readOnly,containerStyle:de,lineColor:se,drawMode:$e,drawHandles:!b.readOnly&&b.edgeHandles!==!1,dragMode:E,multiSelect:!!T,onInit:Er,onLayoutComplete:y.onLayoutComplete,animateViewport:b.animateViewport,onViewportChange:we,onBackgroundTap:sr,onBoxSelect:wt,onEdgeSelect:or,onContainerSelect:ne,onEdgeDraw:Be,onDrawIntoSpace:Je})})})},Bb=j.memo(I_),M_=".flow-sdk-canvas{position:relative;width:100%;height:100%;overflow:clip;user-select:none;-webkit-user-select:none;touch-action:none}.flow-sdk-svg{position:absolute;top:0;left:0;width:100%;height:100%;overflow:visible;display:block}.flow-sdk-nodes{position:absolute;top:0;left:0;transform-origin:0 0;pointer-events:none;will-change:transform;backface-visibility:hidden;z-index:10}.flow-sdk-node{position:absolute;top:0;left:0;transform-origin:0 0;pointer-events:auto;will-change:transform;backface-visibility:hidden;z-index:10}.flow-sdk-node input,.flow-sdk-node textarea{pointer-events:auto;user-select:text;-webkit-user-select:text;cursor:text}.flow-sdk-edge-hit{fill:none;stroke:transparent;stroke-width:24px;vector-effect:non-scaling-stroke;pointer-events:stroke;cursor:pointer}.flow-sdk-container{cursor:pointer}.flow-sdk-edge-anim{animation:flow-sdk-dash .5s linear infinite}.flow-sdk-edge-anim-rev{animation-direction:reverse}@keyframes flow-sdk-dash{to{stroke-dashoffset:-50}}.flow-sdk-draw{cursor:crosshair}.flow-sdk-draw .flow-sdk-node,.flow-sdk-draw .flow-sdk-node input,.flow-sdk-draw .flow-sdk-node textarea,.flow-sdk-draw .flow-sdk-edge,.flow-sdk-draw .flow-sdk-container{pointer-events:none}.flow-sdk-perf.flow-sdk-busy .flow-sdk-edges{display:none}.flow-sdk-box{position:absolute;border:1px solid rgba(170,170,170,.9);background:rgba(221,221,221,.25);pointer-events:none;z-index:20}";let ly=!1;function q_(){if(ly||typeof document>"u")return;const e=document.createElement("style");e.setAttribute("data-flow-sdk",""),e.textContent=M_+g0+h0+".flow-sdk-handle{position:absolute;left:-36px;top:50%;transform:translateY(-50%);width:36px;height:36px;display:grid;place-items:center;border:2px solid currentColor;border-radius:50%;background:white;cursor:crosshair;opacity:0;pointer-events:none}.flow-sdk-node:hover>.flow-sdk-handle,.flow-sdk-handle:focus-visible{opacity:1;pointer-events:auto}.flow-sdk-draw .flow-sdk-node *,.flow-sdk-draw .flow-sdk-edge *,.flow-sdk-draw .flow-sdk-container *,.flow-sdk-ghost *{pointer-events:none}",document.head.appendChild(e),e.textContent+=".flow-sdk-draw .flow-sdk-node{pointer-events:auto}.flow-sdk-draw .flow-sdk-node>.flow-sdk-handle{opacity:0;pointer-events:none}.flow-sdk-draw .flow-sdk-node:hover>.flow-sdk-handle,.flow-sdk-draw .flow-sdk-node>.flow-sdk-handle:focus-visible{opacity:1;pointer-events:auto}",e.textContent+='.flow-sdk-property-port{position:absolute;transform:translateY(-50%);width:32px;height:32px;margin:0;padding:0;border:3px solid currentColor;border-radius:50%;background:white;cursor:crosshair;pointer-events:auto;z-index:20}.flow-sdk-property-port[data-port-role="source"]{background:currentColor}.flow-sdk-property-port:hover{outline:3px solid currentColor;outline-offset:3px}.flow-sdk-draw .flow-sdk-node .flow-sdk-property-port{pointer-events:auto}',ly=!0}function N_({loading:e=!1,loader:t,...r}){var u,c;const[n,o]=j.useState(null),i=j.useMemo(()=>!!(n!=null&&n.json)&&!!r.json&&l0(n.json,r.json),[n==null?void 0:n.json,r.json]),a=n===null||n.json!==r.json&&!i,s=e||a;return j.useEffect(()=>{!e&&i&&(n==null?void 0:n.json)!==r.json&&o(r)},[e,i,n==null?void 0:n.json,r.json]),j.useEffect(()=>{if(e||!a)return;let l;const d=requestAnimationFrame(()=>{l=requestAnimationFrame(()=>o(r))});return()=>{cancelAnimationFrame(d),l!==void 0&&cancelAnimationFrame(l)}},[e,a,r.json]),h.jsxs(F.Box,{className:r.className,style:r.style,width:"100%",height:"100%",position:"relative","aria-busy":s,children:[h.jsx("div",{style:{width:"100%",height:"100%"},ref:l=>{s?l==null||l.setAttribute("inert",""):l==null||l.removeAttribute("inert")},children:n&&h.jsx($_,{...a?n:r,className:void 0,style:void 0})}),s&&h.jsx(F.Box,{"data-flow-loader":"",role:"status","aria-label":"Loading diagram",position:"absolute",inset:0,zIndex:1e3,display:"grid",placeItems:"center",background:((u=r.config)==null?void 0:u.colorMode)==="dark"?"gray.800":"gray.100",color:((c=r.config)==null?void 0:c.colorMode)==="dark"?"whiteAlpha.800":"blackAlpha.800",children:t===void 0?h.jsx("span",{children:"Loading diagram..."}):t})]})}function $_({title:e="untitled",json:t,forms:r,nodes:n,edges:o,config:i={},callbacks:a={},className:s,style:u,showBottomBar:c=!0,children:l}){q_();const[d,f]=j.useState(),p=i.formSchema??d,m=j.useMemo(()=>t&&r?tm(t,r.state):t,[t,r==null?void 0:r.state]),y=i.direction==="C",b=j.useMemo(()=>{let k,E;return P=>(E=k&&E?d0(k,P,E)??vu(P,{title:e,isCenter:y}):vu(P,{title:e,isCenter:y}),k=P,E)},[e,y]),v=j.useMemo(()=>m?b(m):null,[m,b]),g=j.useMemo(()=>r!=null&&r.structured&&p?o0(r.state,r.bindings,p,(v==null?void 0:v.nodes)??n??[]):void 0,[r==null?void 0:r.structured,r==null?void 0:r.state,r==null?void 0:r.bindings,p,v,n]),w=(g==null?void 0:g.schema)??p,x=(g==null?void 0:g.bindings)??(r==null?void 0:r.bindings),_=j.useMemo(()=>[...(v==null?void 0:v.nodes)??n??[],...(g==null?void 0:g.nodes)??[]].map(E=>{var K,V,re,ce;const P=t?(K=xe(t,E.data.id))==null?void 0:K.$view:(V=E.data.config)==null?void 0:V.typeView,R=P&&Bt.includes(P)?P:void 0,I=R?R==="icon-label":(re=E.data.config)==null?void 0:re.labelBelow,O=R==="object"?"objectView":R==="text"?"text":I?"arrayView":E.data.type,M=w&&(r?Yt(x,E.data.id,w):t&>(t,E.data.id,w)),q=(((ce=E.data.config)==null?void 0:ce.ports)??[]).map(he=>({...he}));if(g&&M){const he=i.direction==="RL"?{input:"right",output:"left",config:"bottom",error:"top"}:i.direction==="TB"?{input:"top",output:"bottom",config:"right",error:"left"}:i.direction==="BT"?{input:"bottom",output:"top",config:"left",error:"right"}:{input:"left",output:"right",config:"top",error:"bottom"};for(const[me,H]of Object.entries(M.type.ports??{})){const N=`${H.kind}:${me}`;q.some(D=>D.id===N)||q.push({id:N,role:H.kind==="input"||H.kind==="config"?"target":"source",side:he[H.kind],...H.kind==="config"?{placement:"config"}:{}})}for(const me of q){const H=q.filter(N=>N.side===me.side);me.position=(H.indexOf(me)+1)/(H.length+1)}}return M||I||R?{...E,data:{...E.data,type:O,...r?{description:Object.fromEntries(Object.entries(E.data.description??{}).filter(([he])=>!he.startsWith("$")&&!(g!=null&&g.slots.has(Rt(E.data.id,he)))))}:{},config:{...E.data.config,...g&&M?{ports:q}:{},...M?{form:!0}:{},...R?{typeView:R,labelBelow:!!I}:I?{labelBelow:!0}:{}}}}:E}),[v,n,t,w,x,g,i.direction]),C=[...(v==null?void 0:v.edges)??o??[],...(g==null?void 0:g.edges)??[]],S=j.useMemo(()=>{const k=t&&v?Cm(t,v.edges,a,a.onJsonChange,p):{...a};if(g){const E=new Set([...g.nodes.map(P=>P.data.id),...g.edges.map(P=>P.data.id)]);for(const P of Object.keys(k)){if(!/^on(?:Node|Edge).*(?:Change|Collapse)$/.test(P))continue;const R=k[P];k[P]=(I,...O)=>{if(!E.has(I))return R==null?void 0:R(I,...O)}}}return k},[t,v,a,p,g]),T=j.useMemo(()=>{if(!r)return S;let k=r.state;const E=R=>{if(i.readOnly||i.editable===!1)return;const I=r.onStateChange??r.onChange;if(!I)return;const O=Yx(k,R,a.onFormChange);O!==k&&(k=O,I(O,{...R,data:O}))},P=(R,I,O)=>{var q;const M=t&&((q=xe(t,R))==null?void 0:q[I]);return!M||typeof M.$state!="string"?!1:(E({address:M.$state,nodeAddress:R,previousValue:xe(k,M.$state),value:O,data:k}),!0)};return{...S,onFormChange:E,onNodeCreateRequest:R=>{var M,q;const I=(M=R.sourceProperty)!=null&&M.startsWith("config:")?R.sourceProperty.slice(7):void 0,O=I!==void 0&&(g==null?void 0:g.slots.get(Rt(R.sourceNodeId,I)));return O?(O.present||E({data:k,nodeAddress:O.address.split(".").slice(0,-1).join("."),address:O.address,value:kt(O.type),previousValue:void 0}),!0):((q=S.onNodeCreateRequest)==null?void 0:q.call(S,R))??!1},onNodeDelete:(R,I)=>{var re,ce;if(!(g!=null&&g.nodes.some(he=>he.data.id===R)))return(re=S.onNodeDelete)==null?void 0:re.call(S,R,I);const O=g&&[...g.slots.values()].find(he=>he.nodeId===R);if(!O)return(ce=S.onNodeDelete)==null?void 0:ce.call(S,R,I);const M=O.address.split("."),q=M.pop(),K=M.join("."),V=xe(k,K);E(Array.isArray(V)?{data:k,nodeAddress:K,address:K,previousValue:V,value:V.filter((he,me)=>String(me)!==q)}:{data:k,nodeAddress:K,address:O.address,previousValue:xe(k,O.address),value:void 0})},onEdgeCreate:(R,I,O)=>{var K,V;const M=((K=O==null?void 0:O.targetProperty)==null?void 0:K.startsWith("config:"))&&(g==null?void 0:g.slots.get(Rt(I,O.targetProperty.slice(7)))),q=g==null?void 0:g.containers.get(R);if(M&&q&&(O==null?void 0:O.sourceProperty)==="output:resource"){const re=n0(k,q,M);re!==void 0&&E({data:k,nodeAddress:M.address.split(".").slice(0,-1).join("."),address:M.address,previousValue:xe(k,M.address),value:re});return}M||g!=null&&g.nodes.some(re=>re.data.id===R||re.data.id===I)||(V=S.onEdgeCreate)==null||V.call(S,R,I,O)},onEdgeDelete:(R,I)=>{var ce;const O=g==null?void 0:g.edges.find(he=>he.data.id===R);if(!O)return(ce=S.onEdgeDelete)==null?void 0:ce.call(S,R,I);const M=g.slots.get(Rt(O.data.target,O.data.targetProperty.slice(7))),q=M.address.split("."),K=q.pop(),V=q.join("."),re=xe(k,V);E(Array.isArray(re)?{data:k,nodeAddress:V,address:V,previousValue:re,value:re.filter((he,me)=>String(me)!==K)}:{data:k,nodeAddress:V,address:M.address,previousValue:xe(k,M.address),value:void 0})},onNodeContentChange:(R,I)=>{var O,M;P(R,"$content",I)?(O=a.onNodeContentChange)==null||O.call(a,R,I):(M=S.onNodeContentChange)==null||M.call(S,R,I)},onNodeLabelChange:(R,I)=>{var O,M;P(R,"$label",I)?(O=a.onNodeLabelChange)==null||O.call(a,R,I):(M=S.onNodeLabelChange)==null||M.call(S,R,I)}}},[S,r,t,a,g,i.readOnly,i.editable]);return h.jsx(kr.Provider,{value:{data:(r==null?void 0:r.state)??t,viewData:t,bindings:x,references:r==null?void 0:r.references,structured:g,renderForm:r==null?void 0:r.renderForm,editable:r?!!(r.onStateChange??r.onChange):!!a.onJsonChange,schema:w,setSchema:k=>{var E;f(k),(E=a.onFormSchemaChange)==null||E.call(a,k)},callbacks:T},children:h.jsx(my,{config:g?{...i,formSchema:w}:i,callbacks:T,nodes:_,edges:C,children:h.jsxs(F.Box,{className:s,"data-flow-diagram":"",style:u,width:"100%",height:"100%",position:"relative",overflow:"hidden",css:{"& input, & textarea, & select":{outline:"none !important",boxShadow:"none !important"}},children:[h.jsx(Bb,{nodes:_,edges:C}),c&&h.jsx(vm,{}),l]})})})}function L_(e){return Su(JSON.parse(e))}function Su(e){if(!e||typeof e!="object")throw new Error("Expected a JSON object or array.");const t=new Set,r=n=>{if(!(n===null||typeof n=="string"||typeof n=="boolean")&&!(typeof n=="number"&&Number.isFinite(n))){if(!n||typeof n!="object"||t.has(n)||!Array.isArray(n)&&![Object.prototype,null].includes(Object.getPrototypeOf(n)))throw new Error("Document must contain only finite, acyclic JSON values.");t.add(n);for(const[o,i]of Object.entries(n)){if(["__proto__","prototype","constructor"].includes(o))throw new Error(`Unsafe document key: ${o}`);r(i)}t.delete(n)}};return r(e),structuredClone(e)}function F_(e){return{replaceJson(t){if(e.readOnly||!e.onJsonChange)throw new Error("JSON document is read-only.");const r=Su(t);return e.onJsonChange(r,{type:"documentReplace",address:"root"}),r},replaceState(t){if(e.readOnly||!e.onStateChange)throw new Error("Form state is read-only.");const r=Su(t);return e.onStateChange(r,{address:"root",nodeAddress:"root",previousValue:e.state,value:r,data:r}),r}}}function B_(e,t){const r=(n,o)=>{if(n===null||typeof n!="object")return typeof n==typeof o?n:void 0;if(!(!o||typeof o!="object"))return Array.isArray(n)?Array.isArray(o)?n.map((i,a)=>r(i,o[a])).filter(i=>i!==void 0):void 0:Object.fromEntries(Object.entries(n).flatMap(([i,a])=>{if(!Object.prototype.hasOwnProperty.call(o,i))return[];if(i.startsWith("$")&&i!=="$")return JSON.stringify(a)===JSON.stringify(o[i])?[[i,a]]:[];const s=r(a,o[i]);return s===void 0?[]:[[i,s]]}))};return r(e,t)??{}}function cn(e){let t="",r=!1,n="",o;const i=()=>{clearTimeout(o),o=void 0},a=()=>{if(i(),!(r||!t.trim()))try{const u=e.parse(e.repair(t)),c=JSON.stringify(u);if(c===n)return;e.preview(u),n=c}catch{}},s=u=>{if(!r){if(new TextEncoder().encode(u).byteLength>(e.maxBytes??1024*1024))throw r=!0,i(),new Error("JSON stream exceeds the size limit.");t=u,o||(o=setTimeout(a,e.intervalMs??150))}};return{snapshot:s,append(u){s(t+u)},flush:a,finish(){if(r)throw new Error("JSON stream is closed.");r=!0,i();const u=e.parse(t);return e.commit(u),u},cancel(){r=!0,i(),t=""}}}function D_(e){const{source:t}=e,r=e.tickMs??50,n=e.durationMs??8e3;if(!Number.isFinite(r)||r<=0||!Number.isFinite(n)||n<=0)throw new Error("Playback timing must be positive.");if(new TextEncoder().encode(t).byteLength>(e.maxBytes??1024*1024))throw new Error("JSON stream exceeds the size limit.");e.parse(t);let o=cn(e),i=0,a=!1,s=!1,u;const c=Math.max(1,Math.ceil(t.length*r/n)),l=()=>e.onChange({position:i,total:t.length,playing:a}),d=()=>{clearTimeout(u),u=void 0},f=(y=!1)=>{o.snapshot(t.slice(0,i)),i===t.length?(a=!1,d(),o.finish()):y&&o.flush()},p=y=>{a=!1,d(),o.cancel(),l(),e.onError(y)},m=()=>{if(u=void 0,!(!a||s)){i=Math.min(t.length,i+c);try{f()}catch(y){p(y);return}l(),a&&(u=setTimeout(m,r))}};return{play(){s||a||(i===t.length&&(o.cancel(),o=cn(e),i=0),a=!0,l(),u=setTimeout(m,r))},pause(){s||(a=!1,d(),o.flush(),l())},seek(y){if(!s){if(!Number.isFinite(y))throw new Error("Playback position must be finite.");d(),i=Math.max(0,Math.min(t.length,Math.round(y))),o.cancel(),o=cn(e);try{f(!0)}catch(b){p(b);return}l(),a&&(u=setTimeout(m,r))}},dispose(){s=!0,a=!1,d(),o.cancel()}}}function z_({nodeAddress:e,expanded:t=!1}){var c;const{data:r,schema:n,bindings:o}=j.useContext(kr),{colorText:i,background:a}=Ve();if((c=o==null?void 0:o[e])!=null&&c.portResources)return null;const s=o&&Yt(o,e,n);if(!r||!s)return null;const u=xe(r,s.address);return!u||typeof u!="object"?null:h.jsx("div",{"data-flow-config-summary":"",style:{width:"100%",minWidth:0,color:fe(i),background:fe(a),fontSize:24,lineHeight:1.4,textTransform:"none"},children:Object.keys(s.type.properties).map(l=>{const d=s.fields[l]??{};if(!xn(d.$visibleWhen,r))return null;const f=u[l],p=f==null?"":typeof f=="object"?JSON.stringify(f):String(f);return h.jsxs("div",{"data-flow-property":l,style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(0, 1fr)",gap:12,padding:"10px 16px",borderTop:"1px solid color-mix(in srgb, currentColor 12%, transparent)"},children:[h.jsx("span",{style:{overflowWrap:"anywhere"},children:Cr(d.$label??l)}),h.jsx("span",{title:p,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:t?"pre-wrap":"nowrap",overflowWrap:t?"anywhere":void 0},children:p})]},l)})})}exports.BottomBar=vm;exports.CompactPropertyLayoutToggle=zy;exports.ConnectionsOnlyToggle=u0;exports.DEFAULT_PALETTE=Nu;exports.DiagramAppearanceControls=Wy;exports.DynamicIcon=Mr;exports.EdgeTools=um;exports.EditableLabel=Zt;exports.ErrorToast=ym;exports.FlowDiagram=N_;exports.FlowDiagramProvider=my;exports.FlowPort=Ob;exports.FlowView=Bb;exports.FormDocumentContext=kr;exports.NODE_TYPE_VIEWS=Bt;exports.NodeBorderRadiusControl=lm;exports.NodeConfigSummary=z_;exports.NodeForm=om;exports.NodeFormPopover=Ib;exports.NodeIconPicker=qu;exports.NodeTools=dm;exports.NodeView=Dn;exports.SvgExportButton=pm;exports.Swatches=Kt;exports.TEXT_PALETTE=sm;exports.ToolbarCloseButton=pt;exports.ToolbarCommitInput=Qr;exports.ToolbarDivider=It;exports.ToolbarIconButton=ve;exports.ToolbarRangeInput=Vy;exports.ToolbarScrollContainer=gm;exports.ToolbarSelect=Or;exports.ToolbarTooltip=je;exports.TooltipIconButton=_u;exports.WorkflowControls=mm;exports.addChild=Pu;exports.addConnection=Au;exports.addTargetEdge=Xy;exports.addressToPath=Ir;exports.applyCollapsed=Zx;exports.applyFormChange=wn;exports.applyStateEdits=Jx;exports.bindSqueedCallbacks=Cm;exports.compileSqueed=vu;exports.connectionIssue=Iu;exports.contentObjTheme=jr;exports.createFlowDiagram=Xr;exports.createFlowDocumentActions=F_;exports.createFormNode=wm;exports.createJsonPlayback=D_;exports.createJsonStream=cn;exports.downloadSvg=hm;exports.exportSvg=fm;exports.formValueError=Rr;exports.getChakraColorHex=fe;exports.getColorVariant=by;exports.getDarkerHexColor=un;exports.getInteractionSurface=Dr;exports.getNode=xe;exports.parseFlowDocument=L_;exports.parseJsonContract=Tu;exports.parseTypeScriptContract=em;exports.parseTypeScriptForm=Ou;exports.projectJsonPlaybackPreview=B_;exports.readFormSchema=Mu;exports.readWorkflowContract=rm;exports.removeEdge=Qy;exports.removeNode=Yy;exports.resolveEdgeOwner=Vt;exports.resolveStateView=tm;exports.setCollapsed=Zy;exports.setEdgeProp=Fr;exports.setEdgeStyle=Jy;exports.setNodeProp=ir;exports.updateNode=pr;exports.useCustomColors=Ve;exports.useEdgeProximity=hy;exports.useFlowData=Gr;exports.useFlowDiagramContext=Ie;exports.useNodeViewActions=zn;exports.useStopPropagation=tl;exports.useThemeContentColors=Jt;
|
|
3
186
|
//# sourceMappingURL=index.cjs.map
|