@squeed/flow-sdk 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,3 +1,182 @@
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 Gm=Object.create;var Hn=Object.defineProperty;var Um=Object.getOwnPropertyDescriptor;var Hm=Object.getOwnPropertyNames;var Km=Object.getPrototypeOf,Zm=Object.prototype.hasOwnProperty;var Jm=(e,t,r)=>t in e?Hn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Ym=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Hm(t))!Zm.call(e,o)&&o!==r&&Hn(e,o,{get:()=>t[o],enumerable:!(n=Um(t,o))||n.enumerable});return e};var qe=(e,t,r)=>(r=e!=null?Gm(Km(e)):{},Ym(t||!e||!e.__esModule?Hn(r,"default",{value:e,enumerable:!0}):r,e));var Ar=(e,t,r)=>Jm(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"),E=require("react"),Z=require("react-icons/pi"),Xm=require("@emotion/react"),Qm=require("@emotion/styled"),ev=require("react-icons/tb"),Lt=require("react-dom"),rv=require("markdown-to-jsx/react"),dy=e=>e&&e.__esModule?e:{default:e},gn=dy(Qm),tv=dy(rv),fy=E.createContext(null),hy=E.createContext({nodeById:new Map,edgeById:new Map,parentIds:new Set});function Wr(){return E.useContext(hy)}function Ie(){const e=E.useContext(fy);if(!e)throw new Error("useFlowDiagramContext must be used within FlowDiagram");return e}function py({config:e,callbacks:t,nodes:r=[],edges:n=[],children:o}){const i=E.useMemo(()=>{var $e,Xe,Y;const ne=new Map;for(const D of r)($e=D.data)!=null&&$e.id&&ne.set(D.data.id,D);const Fe=new Map;for(const D of n)(Xe=D.data)!=null&&Xe.id&&Fe.set(D.data.id,D);const Je=new Set;for(const D of r)(Y=D.data)!=null&&Y.parent&&Je.add(D.data.parent);return{nodeById:ne,edgeById:Fe,parentIds:Je}},[r,n]),a=E.useRef(null),[s,u]=E.useState([]),[c,l]=E.useState(null),[d,f]=E.useState(!0),[p,b]=E.useState(!1),[y,m]=E.useState(!0),[x,g]=E.useState(!1),[w,v]=E.useState(!1),[_,C]=E.useState(!0),[S,T]=E.useState(!1),[k,j]=E.useState("auto"),[P,R]=E.useState(!1),I=e.compactPropertyLayout??P,[O,M]=E.useState({}),q=e.nodeViewModes??O,H=[...i.nodeById.values()].filter(ne=>{var Fe;return i.parentIds.has(ne.data.id)||((Fe=ne.data.config)==null?void 0:Fe.parentContainer)||ne.data.type==="objectView"||ne.data.type==="arrayView"}),V=!!H.length&&H.every(ne=>{var Fe,Je,$e;return i.parentIds.has(ne.data.id)||(Fe=ne.data.config)!=null&&Fe.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]=E.useState("normal"),[le,be]=E.useState(),K=e.edgeRadius??le,N=K!==void 0&&Number.isFinite(K)?Math.min(500,Math.max(0,K)):void 0,[B,W]=E.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??B??(e.backgroundPattern==="none"&&e.backgroundColor==="transparent"?"transparent":e.backgroundPattern??"dot"),[Q,G]=E.useState(),J=Object.prototype.hasOwnProperty.call(e,"workflowContract")?e.workflowContract:Q,[te,de]=E.useState("blue.500"),[fe,Ee]=E.useState(!1),ge=E.useRef(t);ge.current=t;const We=E.useMemo(()=>{const ne=Fe=>(...Je)=>{var $e,Xe;return(Xe=($e=ge.current)==null?void 0:$e[Fe])==null?void 0:Xe.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")}},[]),me=e.themeColor||te,Te=e.edgeColor||"",er=e.colorMode||"light",De=e.direction||"LR",Ne=e.nodeAlignment??"center",He=e.edgeMode==="workflow"?"nodes":e.edgeMode??k,rr=e.readOnly??!1,ze=JSON.stringify(e.parentNodeStyle??null),xr=E.useMemo(()=>e.parentNodeStyle,[ze]),Ze=e.isZoomMode!==void 0?e.isZoomMode:d,pr=e.isMultiSelectMode!==void 0?e.isMultiSelectMode:p,dr=e.isEdgeHandlesEnabled!==void 0?e.isEdgeHandlesEnabled:x,jr=e.isDragMode!==void 0?e.isDragMode:y,we=E.useRef(e);we.current=e;const or=E.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}}),[]),ar=E.useCallback((ne,Fe)=>{var Je;if(Fe!=="default"&&Fe!=="properties"&&Fe!=="icon-label")throw new Error("Unknown node view mode.");M($e=>$e[ne]===Fe?$e:{...$e,[ne]:Fe}),(Je=t.onNodeViewModeChange)==null||Je.call(t,ne,Fe)},[t.onNodeViewModeChange]),xt=E.useMemo(()=>({allNodesIconLabel:V,setAllNodesIconLabel:ne=>{var Fe,Je,$e,Xe;for(const Y of H)i.parentIds.has(Y.data.id)||(Fe=Y.data.config)!=null&&Fe.parentContainer?!rr&&!!((Je=Y.data.config)!=null&&Je.collapsed)!==ne&&(($e=t.onNodeCollapse)==null||$e.call(t,Y.data.id,ne)):ar(Y.data.id,ne?"icon-label":"default");(Xe=t.onAllNodesIconLabelChange)==null||Xe.call(t,ne)},nodeViewModes:q,setNodeViewMode:ar,spacing:X,setSpacing:ce,edgeRadius:N,setEdgeRadius:be,backgroundVariant:se,setBackgroundVariant:W,themeColor:me,setThemeColor:de,backgroundSelected:fe,setBackgroundSelected:Ee,edgeColor:Te,colorMode:er,direction:De,nodeAlignment:Ne,edgeMode:He,setEdgeMode:j,compactPropertyLayout:I,setCompactPropertyLayout:R,workflowContract:J,setWorkflowContract:G,parentNodeStyle:xr,selectedNodeIds:s,setSelectedNodeIds:u,selectedEdgeId:c,setSelectedEdgeId:l,isZoomMode:Ze,setIsZoomMode:f,isMultiSelectMode:pr,setIsMultiSelectMode:b,isDragMode:jr,setIsDragMode:m,isEdgeHandlesEnabled:dr,setIsEdgeHandlesEnabled:g,isArrayNodeMode:w,setIsArrayNodeMode:v,isPinned:_,setIsPinned:C,isPerformanceMode:S,setIsPerformanceMode:T,engineRef:a,callbacks:We,config:or,readOnly:rr}),[V,i,ar,t.onNodeCollapse,t.onAllNodesIconLabelChange,q,t.onNodeViewModeChange,me,X,se,N,e.backgroundColor,fe,Te,er,De,Ne,He,J,xr,s,c,Ze,pr,jr,dr,w,_,S,rr,e.edgeHandles,e.edgeType,e.customEdgeTypes,e.selectionToolbar,e.bottomBarExtra,e.compactPropertyLayout,I,We,or]);return h.jsx(fy.Provider,{value:xt,children:h.jsx(hy.Provider,{value:i,children:o})})}function cn(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 Er=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:cn(e,.1),border:cn(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"},gy=e=>{if(e==="transparent")return{primary:e,secondary:e,light:e};let t=e;if(t!=null&&t.startsWith("#"))return{secondary:cn(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"}},pe=(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 Zt(e){const[t]=(e==null?void 0:e.split("."))||[],{secondary:r}=gy(e),n=Er(t).background,o=Er(t).highlight,i=Er(t).border,a=Er(t).property,s=Er(t).property;let u=Er(t).background,c=Er(t).highlight;return u=e==="transparent"?e:pe(u)+50,c=e==="transparent"?e:pe(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"),b=tr(n,r?"gray.900":"gray.200",r?"gray.200":"gray.900"),y=tr(n,"gray.900","gray.200"),m=tr(n,e&&"#000000",e||"#ffffff"),x=tr(n,e||"#ffffff",e?"#000000":"#ffffff"),g=c,w=tr(n,"gray.300","gray.800"),v=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:v,borderSecondary:c,colorActive:d,colorInactive:f,iconColor:y,moreIconColor:g,colorText:p,themedColorText:b,logoColor:m,logoColorSecondary:x,darkColorActive:w,greenColor:_}}const nv=Xm.keyframes`
2
+ 0%, 100% { box-shadow: var(--flow-rest-shadow); }
3
+ 25%, 50% { box-shadow: var(--flow-hover-shadow); }
4
+ `;function Su(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?`${nv} 1200ms steps(10, end) 600ms`:"none"}}}}}}var St=(e=>(e.TOP_DOWN="TB",e.BOTTOM_UP="BT",e.LEFT_RIGHT="LR",e.RIGHT_LEFT="RL",e.CENTER="C",e))(St||{});const Ft=["","icon-label","object","text"];var ov=typeof global=="object"&&global&&global.Object===Object&&global,iv=typeof self=="object"&&self&&self.Object===Object&&self,av=ov||iv||Function("return this")(),dt=av.Symbol,yy=Object.prototype,sv=yy.hasOwnProperty,cv=yy.toString,Ct=dt?dt.toStringTag:void 0;function uv(e){var t=sv.call(e,Ct),r=e[Ct];try{e[Ct]=void 0;var n=!0}catch{}var o=cv.call(e);return n&&(t?e[Ct]=r:delete e[Ct]),o}var lv=Object.prototype,dv=lv.toString;function fv(e){return dv.call(e)}var hv="[object Null]",pv="[object Undefined]",ll=dt?dt.toStringTag:void 0;function gv(e){return e==null?e===void 0?pv:hv:ll&&ll in Object(e)?uv(e):fv(e)}function yv(e){return e!=null&&typeof e=="object"}var bv="[object Symbol]";function mv(e){return typeof e=="symbol"||yv(e)&&gv(e)==bv}function vv(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 Pe=Array.isArray,dl=dt?dt.prototype:void 0,fl=dl?dl.toString:void 0;function by(e){if(typeof e=="string")return e;if(Pe(e))return vv(e,by)+"";if(mv(e))return fl?fl.call(e):"";var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function ju(e){return e==null?"":by(e)}function xv(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 wv(e,t,r){var n=e.length;return r=r===void 0?n:r,!t&&r>=n?e:xv(e,t,r)}var Cv="\\ud800-\\udfff",_v="\\u0300-\\u036f",Sv="\\ufe20-\\ufe2f",jv="\\u20d0-\\u20ff",Ev=_v+Sv+jv,Rv="\\ufe0e\\ufe0f",kv="\\u200d",Pv=RegExp("["+kv+Cv+Ev+Rv+"]");function my(e){return Pv.test(e)}function Av(e){return e.split("")}var vy="\\ud800-\\udfff",Tv="\\u0300-\\u036f",Ov="\\ufe20-\\ufe2f",Iv="\\u20d0-\\u20ff",Mv=Tv+Ov+Iv,qv="\\ufe0e\\ufe0f",Nv="["+vy+"]",yu="["+Mv+"]",bu="\\ud83c[\\udffb-\\udfff]",$v="(?:"+yu+"|"+bu+")",xy="[^"+vy+"]",wy="(?:\\ud83c[\\udde6-\\uddff]){2}",Cy="[\\ud800-\\udbff][\\udc00-\\udfff]",Lv="\\u200d",_y=$v+"?",Sy="["+qv+"]?",Fv="(?:"+Lv+"(?:"+[xy,wy,Cy].join("|")+")"+Sy+_y+")*",Bv=Sy+_y+Fv,Dv="(?:"+[xy+yu+"?",yu,wy,Cy,Nv].join("|")+")",zv=RegExp(bu+"(?="+bu+")|"+Dv+Bv,"g");function Vv(e){return e.match(zv)||[]}function Wv(e){return my(e)?Vv(e):Av(e)}function Gv(e){return function(t){t=ju(t);var r=my(t)?Wv(t):void 0,n=r?r[0]:t.charAt(0),o=r?wv(r,1).join(""):t.slice(1);return n[e]()+o}}var Uv=Gv("toUpperCase");function Hv(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 Kv(e){return function(t){return e==null?void 0:e[t]}}var Zv={À:"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"},Jv=Kv(Zv),Yv=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Xv="\\u0300-\\u036f",Qv="\\ufe20-\\ufe2f",ex="\\u20d0-\\u20ff",rx=Xv+Qv+ex,tx="["+rx+"]",nx=RegExp(tx,"g");function ox(e){return e=ju(e),e&&e.replace(Yv,Jv).replace(nx,"")}var ix=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function ax(e){return e.match(ix)||[]}var sx=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function cx(e){return sx.test(e)}var jy="\\ud800-\\udfff",ux="\\u0300-\\u036f",lx="\\ufe20-\\ufe2f",dx="\\u20d0-\\u20ff",fx=ux+lx+dx,Ey="\\u2700-\\u27bf",Ry="a-z\\xdf-\\xf6\\xf8-\\xff",hx="\\xac\\xb1\\xd7\\xf7",px="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",gx="\\u2000-\\u206f",yx=" \\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",ky="A-Z\\xc0-\\xd6\\xd8-\\xde",bx="\\ufe0e\\ufe0f",Py=hx+px+gx+yx,Ay="['’]",hl="["+Py+"]",mx="["+fx+"]",Ty="\\d+",vx="["+Ey+"]",Oy="["+Ry+"]",Iy="[^"+jy+Py+Ty+Ey+Ry+ky+"]",xx="\\ud83c[\\udffb-\\udfff]",wx="(?:"+mx+"|"+xx+")",Cx="[^"+jy+"]",My="(?:\\ud83c[\\udde6-\\uddff]){2}",qy="[\\ud800-\\udbff][\\udc00-\\udfff]",it="["+ky+"]",_x="\\u200d",pl="(?:"+Oy+"|"+Iy+")",Sx="(?:"+it+"|"+Iy+")",gl="(?:"+Ay+"(?:d|ll|m|re|s|t|ve))?",yl="(?:"+Ay+"(?:D|LL|M|RE|S|T|VE))?",Ny=wx+"?",$y="["+bx+"]?",jx="(?:"+_x+"(?:"+[Cx,My,qy].join("|")+")"+$y+Ny+")*",Ex="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Rx="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",kx=$y+Ny+jx,Px="(?:"+[vx,My,qy].join("|")+")"+kx,Ax=RegExp([it+"?"+Oy+"+"+gl+"(?="+[hl,it,"$"].join("|")+")",Sx+"+"+yl+"(?="+[hl,it+pl,"$"].join("|")+")",it+"?"+pl+"+"+gl,it+"+"+yl,Rx,Ex,Ty,Px].join("|"),"g");function Tx(e){return e.match(Ax)||[]}function Ox(e,t,r){return e=ju(e),t=t,t===void 0?cx(e)?Tx(e):ax(e):e.match(t)||[]}var Ix="['’]",Mx=RegExp(Ix,"g");function qx(e){return function(t){return Hv(Ox(ox(t).replace(Mx,"")),e,"")}}var Cr=qx(function(e,t,r){return e+(r?" ":"")+Uv(t)});function je({label:e,children:t}){const r=E.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 Ot(){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:b,colorInactive:y}=Ve(),m=l==="dark",x=E.useId(),g=E.useRef(null),w=E.useRef(null),[v,_]=E.useState(!1);E.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=E.Children.toArray(e).filter(E.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 H,V,re,ce;const R=(H=g.current)==null?void 0:H.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,H,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=(H=w.current)==null?void 0:H.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()};E.useEffect(()=>{if(v){if(n){S();return}return window.addEventListener("resize",T),window.addEventListener("scroll",T,!0),()=>{window.removeEventListener("resize",T),window.removeEventListener("scroll",T,!0)}}},[v,n]);const j=`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":v,"aria-controls":x,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:()=>v?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:x,role:s?"dialog":"listbox","aria-label":c,position:"fixed",m:0,p:2,minW:"180px",maxW:"calc(100vw - 24px)",overflowY:"auto",css:{scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},bg:d,color:p,borderWidth:1,borderColor:m?f:"gray.300",borderRadius:"30px",boxShadow:`0 0 0 8px color-mix(in srgb, ${j} 40%, transparent), var(--chakra-shadows-lg)`,onKeyDown:R=>{var M,q,H;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!==" "&&((H=I.find((V,re)=>{var ce;return re>O&&((ce=V.textContent)==null?void 0:ce.toLowerCase().startsWith(R.key.toLowerCase()))}))==null||H.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:m?"whiteAlpha.100":"blackAlpha.50"},_focusVisible:{bg:m?"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-${b.replace(".","-")})`,"aria-hidden":"true",style:{flexShrink:0,visibility:R.value===t?"visible":"hidden"}})]},R.value))})]})}const ve=E.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})}),ht=E.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"})})})}),Ly=gn.default.input`
5
+ appearance: none;
6
+ width: 100%;
7
+ height: 24px;
8
+ margin: 0;
9
+ padding: 0;
10
+ border: 0;
11
+ box-shadow: none;
12
+ background-color: transparent;
13
+ background-size: 100% 6px;
14
+ background-position: center;
15
+ background-repeat: no-repeat;
16
+ cursor: pointer;
17
+ &::-webkit-slider-runnable-track {
18
+ height: 6px;
19
+ background: transparent;
20
+ border: 0;
21
+ box-shadow: none;
22
+ }
23
+ &::-moz-range-track {
24
+ height: 6px;
25
+ background: transparent;
26
+ border: 0;
27
+ box-shadow: none;
28
+ }
29
+ &::-webkit-slider-thumb {
30
+ appearance: none;
31
+ width: 16px;
32
+ height: 16px;
33
+ margin-top: -5px;
34
+ border: 0;
35
+ border-radius: 50%;
36
+ background: currentColor;
37
+ box-shadow: none;
38
+ }
39
+ &::-moz-range-thumb {
40
+ width: 16px;
41
+ height: 16px;
42
+ border: 0;
43
+ border-radius: 50%;
44
+ background: currentColor;
45
+ box-shadow: none;
46
+ }
47
+ &:disabled {
48
+ cursor: default;
49
+ opacity: 0.5;
50
+ }
51
+ `;function bl({label:e,inputLabel:t,value:r,displayValue:n,min:o,max:i,onChange:a}){const s=E.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(Ly,{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 ml={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 Fy(){const{spacing:e,setSpacing:t,edgeRadius:r,setEdgeRadius:n,backgroundVariant:o,setBackgroundVariant:i,callbacks:a,readOnly:s}=Ie(),u=ml[o].icon;return h.jsxs(h.Fragment,{children:[h.jsx(Ot,{}),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(bl,{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(Ot,{}),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(bl,{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(Ot,{}),h.jsxs(Or,{"aria-label":"Background variant",title:`Background: ${ml[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"})]})]})}function By({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 Dy({label:e="Compact layout"}={}){const{compactPropertyLayout:t,setCompactPropertyLayout:r,callbacks:n}=Ie();return h.jsx(By,{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 nr=[];for(let e=0;e<256;++e)nr.push((e+256).toString(16).slice(1));function Nx(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 Kn;const $x=new Uint8Array(16);function Lx(){if(!Kn){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Kn=crypto.getRandomValues.bind(crypto)}return Kn($x)}const Fx=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),vl={randomUUID:Fx};function Eu(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))??Lx();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,Nx(n)}const yn={label:"Untitled",description:"",isTask:!1,isLocked:!1},Ru={id:null,type:"text",data:{...yn,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:{...yn,headerTitle:null,viewProps:{width:"100%",borderWidth:2,borderRadius:53,height:"100%",justifyContent:"space-between",flexDirection:"row",textColor:"gray.900"}}},Bx={id:null,type:"arrayView",data:{...yn,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:{...yn,viewProps:{width:"max-content !important",maxWidth:350,minWidth:280,height:"100%",borderRadius:15,borderWidth:3}}},fr=e=>typeof e=="object",zy=e=>Array.isArray(e),Dx=["order","position","selected","locked","grabbed","grabbable","scratch"],Dr=e=>Object.entries(e).reduce((t,[r,n])=>(!fr(n)&&!r.startsWith("$")&&(t[r]=n),t),{}),ku=(e,t)=>typeof e=="string"&&e.startsWith("$")?Zn(e,t):fr(e)&&!zy(e)?Object.entries(e).reduce((r,[n,o])=>(typeof o=="string"&&o.startsWith("$")&&n==="..."?(delete r["..."],r[n]={...Zn(o,t),...e}):typeof o=="string"&&o.startsWith("$")?r[n]=Zn(o,t):r[n]=o,r),{}):e,zr=e=>Object.entries(e).reduce((t,[r,n])=>(fr(n)&&r&&n&&!r.startsWith("$")&&(Dx.includes(r)&&(r=r+"#"),t[r]=n),t),{}),Zr=(e,t,{label:r,parent:n=void 0},o,i=null)=>(i!==null&&(fr(i)||zy(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:Eu(),source:o?t:e,target:o?e:t,label:n||"",isInverted:o,isEdgeAnimated:i,parent:a}}),Vr=(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}},ct=(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=Bx: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}},Bt=(e,t)=>(e=t.find(n=>n.data.id===e)?`${e}.#`:e,e),Zn=(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=zx(o,r);return JSON.stringify(i).includes(e)?e:i||e}return e},zx=(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}=Vr(a);return a=u.length?u:a,a[s]},i))(t)};function lt(e,t="root",r=[]){try{const{arrayObject:n}=Vr(e);n.length&&(e=n);const o=Dr(e),i=zr(e);return fr(e)?(Pe(e)||Pe(e)&&t==="root"||!Pe(e)&&Object.keys(o).length||t==="root")&&r.push(t):r.push(t),Object.keys(i).length&&!Pe(e)?It({chldPth:null,itrblObjct:i,nodes:r,path:t}):Pe(e)&&e.forEach((a,s)=>{const u=Dr(a),c=zr(a),{newConfig:l,arrayObject:d}=Vr(a);let f=`${t}.${s}`;fr(a)?Object.keys(u).length?(lt(u,f,r),Object.keys(c).length&&!Pe(a)&&It({chldPth:f,itrblObjct:c,nodes:r,path:t})):Object.keys(c).length&&!Pe(a)?It({chldPth:f,itrblObjct:c,nodes:r,path:t}):Pe(a)&&Vy({chldPth:f,item:a,nodes:r,path:t}):r.push(f)}),{nodes:r}}catch{return{nodes:r}}}const It=({chldPth:e,itrblObjct:t,nodes:r,path:n})=>Object.entries(t).forEach(([o,i],a)=>{const s=Dr(i),u=zr(i),{newConfig:c,arrayObject:l}=Vr(i);l.length&&(i=l),n.split(".").slice(0,2).join(".");let d=e?`${e}.${o}`:`${n}.${o}`;if(fr(i)&&!Pe(i)){const f=Object.keys(s).length===0;if(f&&(ct("array",c),r.push(d)),Object.keys(s).length){const p=Pe(i)?`${i.length||""}`:`{${Object.keys(i).length||""}}`;let b=d;f&&(b=`${d}.${p}`),lt(i,b,r)}else Object.keys(u).length&&!Pe(i)?It({chldPth:d,itrblObjct:u,path:d,nodes:r}):lt(i,d,r)}else Pe(i)&&lt(i,d,r)}),Vy=({chldPth:e,item:t,nodes:r,path:n})=>t.forEach((o,i)=>{let a=`${e}.${i}`;const s=zr(o),u=Dr(o);fr(o)?!Pe(o)&&Object.keys(u).length?lt(o,a,r):Object.keys(s).length&&!Pe(o)?It({chldPth:a,itrblObjct:s,path:n,nodes:r}):Pe(o)&&Vy({chldPth:a,item:o,nodes:r,path:n}):r.push(a)}),un=[];let Mt;function Yr(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(!Mt){const{nodes:l}=lt(e);Mt={ids:l,jsnObjct:e}}let{hideDefaultObject:u,sprtObjctKy:c}=i;try{t=Bt(t,r);const{newConfig:l,arrayObject:d}=Vr(e),f=Object.keys(a).length>0?a:l;d.length&&(e=d);const p=Dr(e),b=zr(e),{label:y,collapsed:m,parent:x}=f;if(!fr(e))r.push(Zr(Ru,t,{label:y||t,parent:x},e,s));else if(Pe(e)||Pe(e)&&t==="root"){const{config:g}=ct("array",f),w=Pe(e)?`${e.length||""}`:`{${Object.keys(e).length||""}}`,v=t==="root"?o:`${o} ${w}`;r.push(Zr(g,t,{label:y||v,parent:x},e,Pe(s)?{[o]:s}:s))}else if(!Pe(e)&&Object.keys(p).length||t==="root"){const{config:g}=ct(null,f),w=Pe(e)?`${e.length||""}`:`{${Object.keys(e).length||""}}`,v=t.split("."),_=v[v.length-1];let C=isNaN(Number(_))?null:Number(_)+1;const S=isNaN(Number(_))?_:v[v.length-2]+" "+C,T=t==="root"?o:S;let k=!1;Number.isNaN(Number(o))||(k=!0);const j=e;if(y){const{config:P}=ct("object",f);r.push(Zr(P,t,{label:y||`${y} ${w}`,parent:x},p,j))}else g.data.headerTitle=T,r.push(Zr(g,t,{label:y,parent:x},p,j))}return m||(Object.keys(b).length&&!Pe(e)?qt({flowConfig:i,chldPth:null,edges:n,isInverted:null,itrblObjct:b,nodes:r,path:t,newConfig:f}):Pe(e)&&e.forEach((g,w)=>{g=ku(g,Mt);const v=g,_=Dr(g),C=zr(g),{newConfig:S,arrayObject:T}=Vr(g);T.length&&(g=T);const{config:k}=ct(typeof g=="string"?"text":"array",S),{hideConfig:j,sourceLabel:P,label:R,isEdgeAnimated:I,parent:O}=S;u=u||j;const M=t==="root"&&i.isCntr,q=t.split(".").slice(0,2).join("."),H=un.includes(q),V=i.isCntr&&H||w%2===0&&M;let re=`${t}.${w}`;re=Bt(re,r),V&&un.push(re),fr(g)?Object.keys(_).length&&!Pe(g)?(n.push(Br(t,re,null,P,V,I)),Yr(g,re,r,n,R||w,i,S)):Object.keys(C).length&&!Pe(g)?qt({flowConfig:i,chldPth:re,isInverted:V,edges:n,itrblObjct:C,nodes:r,path:t,newConfig:S,forceIsInverted:!0}):Pe(g)?Wy({flowConfig:i,chldPth:re,edges:n,isInverted:V,item:g,nodes:r,path:t}):fr(g)&&qt({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(Zr(k,re,{label:R||String(g),parent:O},g,v)))})),{nodes:r,edges:n}}catch{return{nodes:r,edges:n}}}const qt=({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,Mt);const b=f,y=Dr(f),m=zr(f),{newConfig:x,arrayObject:g}=Vr(f);g.length&&(f=g);const{hideConfig:w,sourceLabel:v,label:_,content:C,target:S,targetLabel:T,collapsed:k,isEdgeAnimated:j,parent:P}=x;c=c||w;const R=a==="root"&&t.isCntr,I=a.split(".").slice(0,2).join("."),O=un.includes(I);u||(i=t.isCntr&&O||p%2===0&&R);let M=e?`${e}.${d}`:`${a}.${d}`;if(M=Bt(M,o),i&&un.push(M),S&&r.push(Br(M,S,null,T,i,j)),fr(f)&&!Pe(f)){r.push(Br(a,M,null,v,i,j));const q=l||Object.keys(y).length===0;if(q){const H=C?"object":"array",{config:V}=ct(H,x);V.data.headerTitle=C?_:null,o.push(Zr(V,M,{label:_||d,parent:P},f,b))}if(Object.keys(y).length&&!c){const H=Pe(f)?` ${f.length||""}`:`{${Object.keys(f).length||""}}`;let V=M;q&&(V=`${M}.${H}`,V=Bt(V,o),r.push(Br(M,V,null,v,i,j))),Yr(f,V,o,r,_||d,t,x)}else Object.keys(m).length&&!Pe(f)?qt({chldPth:M,flowConfig:t,itrblObjct:m,path:M,edges:r,nodes:o,newConfig:x,isInverted:i}):Yr(f,M,o,r,d,t,x)}else Pe(f)&&(r.push(Br(a,M,null,v,i,j)),Yr(f,M,o,r,d,t,x))})},Wy=({flowConfig:e,chldPth:t,edges:r,isInverted:n,item:o,nodes:i,path:a})=>o.forEach((s,u)=>{let c=`${t}.${u}`;c=Bt(c,i);const l=s;s=ku(s,Mt);const d=zr(s),f=Dr(s),{newConfig:p}=Vr(s),{collapsed:b,label:y,parent:m,sourceLabel:x,isEdgeAnimated:g,content:w}=p;fr(s)?!Pe(s)&&Object.keys(f).length?(r.push(Br(a,c,null,x,n,g)),Yr(s,c,i,r,u,e,p)):Object.keys(d).length&&!Pe(s)&&!b?qt({chldPth:c,flowConfig:e,itrblObjct:d,path:a,edges:r,nodes:i,isInverted:n,newConfig:p}):Pe(s)&&Wy({flowConfig:e,chldPth:c,edges:r,isInverted:n,item:s,nodes:i,path:a}):(r.push(Br(a,c,null,x,n,g)),i.push(Zr(Ru,c,{label:y||String(s),parent:m},s,l)))});function Vx(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,b;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=(b=o.get(f))==null?void 0:b.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 Gy(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 Wx(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 Dt="root",Cl=e=>e==="#"||e.startsWith("{")||/^\s\d*$/.test(e);function Ir(e){const t=e.split(".");for(t[0]===Dt&&t.shift();t.length&&Cl(t[t.length-1]);)t.pop();return t.filter(r=>!Cl(r))}function mn(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=mn(r))==null?void 0:o[n]},e)}function Gx(e){return Array.isArray(e)?[...e]:{...e}}function hr(e,t,r){const n=Ir(t),o=(i,a)=>{if(a===n.length)return r(i);const s=n[a],u=mn(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=Gx(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 hr(e,t,o=>r==="$label"&&typeof o=="string"&&typeof n=="string"&&n!==""?n:Tr(o,r,n))}const Uy=(e,t,r)=>ir(e,t,"$collapsed",r);function zt(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 hr(e,s.address,u=>Gy(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}=zt(t),a=i==="target"&&r==="$sourceLabel"?"$targetLabel":i==="target"&&r==="$edgeType"?"$targetEdgeType":i==="target"&&r==="$edgeIcon"?"$targetIcon":i==="target"&&r==="$edgeAnimationVariant"?"$targetAnimationVariant":r;return hr(e,o,s=>Tr(s,a,n))}const Hy=(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=hr(e,t,s=>{const u=mn(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:[Dt,...a,o].join(".")}}function Ky(e,t){const r=Ir(t);if(!r.length)return e;const n=r[r.length-1],o=[Dt,...r.slice(0,-1)].join(".");return hr(e,o,i=>{const a=mn(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 Zy=(e,t,r,n)=>ir(n?hr(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:hr(e,t,i=>Tr(i,"$connections",[...Array.isArray(i==null?void 0:i.$connections)?i.$connections:[],{...r,id:r.id||Eu()}]))}function Jy(e,t){if(t.connection){const i=t.connection;return bn(xe(e,i.address)).some(a=>a.key===i.key)?{json:hr(e,i.address,a=>Gy(a,i.key,()=>null)),removed:!0}:{json:e,removed:!1}}const{address:r,kind:n}=zt(t);return n==="hierarchy"?xe(e,r)===void 0?{json:e,removed:!1}:{json:hr(e,r,i=>({...i,$hideParentEdge:!0})),removed:!0}:n!=="target"?{json:e,removed:!1}:{json:hr(e,r,i=>{const{$target:a,$targetLabel:s,...u}=i||{};return u}),removed:!0}}function mu(e,t={}){var x;const r=Wx(e),{nodes:n,edges:o}=Yr(r.json,Dt,[],[],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 v=w.slice(0,-2),_=xe(e,v);!i.has(v)&&_&&typeof _=="object"&&!Array.isArray(_)&&typeof _.$label=="string"&&Object.keys(_).every(C=>C.startsWith("$")&&C!=="$")&&a.set(w,v)}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),v=xe(e,w),_={...g.data,id:w},C=v&&typeof v=="object"&&!Array.isArray(v)&&"$"in v?v.$:v;if((Array.isArray(C)?C.length>0:C&&typeof C=="object"&&Object.keys(C).some(k=>!k.startsWith("$")))&&(_.config={..._.config,collapsed:!!v.$collapsed}),u.has(w)||(_.viewProps={..._.viewProps},delete _.viewProps.borderWidth),!v||typeof v!="object"||Array.isArray(v))return{data:_};if(v.$form&&typeof v.$form=="object"&&(_.config={..._.config,form:v.$form},_.type="objectView"),Array.isArray(v.$ports)){const k=v.$ports.filter(j=>j&&typeof j.id=="string"&&["source","target"].includes(j.role)&&["top","right","bottom","left"].includes(j.side));_.config={..._.config,ports:k}}return _.parent&&(_.parent=s(_.parent)),typeof v.$label=="string"&&(_.label=v.$label,_.headerTitle=v.$label),typeof v.$subtitle=="string"&&(_.config={..._.config,subtitle:v.$subtitle}),typeof v.$outline=="boolean"&&(_.viewProps={..._.viewProps,outline:v.$outline}),["solid","dashed","dotted","double"].includes(v.$borderStyle)&&(_.viewProps={..._.viewProps,borderStyle:v.$borderStyle}),Number.isFinite(v.$borderWidth)&&v.$borderWidth>=0&&(_.viewProps={..._.viewProps,borderWidth:v.$borderWidth}),Number.isFinite(v.$borderRadius)&&v.$borderRadius>=0&&(_.viewProps={..._.viewProps,borderRadius:v.$borderRadius}),typeof v.$isNodeAnimated=="boolean"&&(_.isNodeAnimated=v.$isNodeAnimated),["traveling","pulse"].includes(v.$nodeAnimationVariant)&&(_.nodeAnimationVariant=v.$nodeAnimationVariant),typeof v.$content=="string"&&(_.config={..._.config,content:v.$content},v.$view||(_.type="objectView")),(((T=_.config)==null?void 0:T.collapsed)!==void 0||v.$collapsed!==void 0||v.$icon!==void 0)&&(_.config={..._.config||{}},(v.$collapsed!==void 0||_.config.collapsed!==void 0)&&(_.config.collapsed=!!v.$collapsed),v.$icon!==void 0&&(_.config.icon=v.$icon)),{data:_}}),l=new Map,d=o.map(g=>{const w=s(g.data.source),v=s(g.data.target),_=`${w}->${v}`,C=l.get(_)??0;l.set(_,C+1);const S={...g.data,id:C?`${_}#${C}`:_,source:w,target:v},T=zt(S),k=xe(e,T.address);if(k&&typeof k=="object"){const j=k[T.kind==="target"?"$targetEdgeType":"$edgeType"];typeof j=="string"&&(S.type=j);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===Dt);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,v=zt(w);(!f.has(w.source)||!f.has(w.target)||v.kind==="hierarchy"&&((x=xe(e,v.address))==null?void 0:x.$hideParentEdge)===!0)&&d.splice(g,1)}d.push(...r.edges.filter(g=>f.has(g.data.source)&&f.has(g.data.target)));const p=Vx(e,{nodes:c,edges:d}),b=p.nodes.filter(g=>{var w;return(w=g.data.config)==null?void 0:w.collapsed}).map(g=>Ir(g.data.id));if(!b.length)return p;const y=p.nodes.filter(g=>{const w=Ir(g.data.id);return!b.some(v=>v.length<w.length&&v.every((_,C)=>_===w[C]))}),m=new Set(y.map(g=>g.data.id));return{nodes:y,edges:p.edges.filter(g=>m.has(g.data.source)&&m.has(g.data.target))}}function Ux(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(b=>b===p||b==="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 b;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((b=y.typeParameters)!=null&&b.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,m)=>{var _;const x={},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,m)}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,m),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,j,P]=String(T[0].comment??"").trim().split(/\s+/);if(k!=="config"||!j||P||!u.has(j))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`);x[C.name.text]={kind:"config",resourceType:j,multiple:R}}return[C.name.text,{type:S,optional:!!C.questionToken}]})),...w?{additionalProperties:w}:{},...Object.keys(x).length?{ports:x}:{}}},l=(y,m)=>{var _;if(m.includes(y))throw new Error("Recursive types are not supported.");const x=u.get(y);if(!x)throw new Error(`Unknown type: ${y}`);let g;if(i.isInterfaceDeclaration(x)){if((_=x.heritageClauses)!=null&&_.length)throw new Error("Interface inheritance is not supported; declare properties explicitly.");g=c(x.members,[...m,y])}else g=d(x.type,[...m,y]);const w=n.allowJson?i.getJSDocTags(x).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 v={...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(v,T))throw new Error(`Duplicate port declaration: ${T}`);v[T]={kind:S}}return{...g,ports:v}},d=(y,m)=>{var x,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,m);if(i.isUnionTypeNode(y))return{kind:"union",types:y.types.map(v=>d(v,m))};if(i.isArrayTypeNode(y))return{kind:"array",items:d(y.elementType,m)};if(i.isTypeLiteralNode(y))return c(y.members,m);if(i.isLiteralTypeNode(y)){const v=y.literal;if(i.isStringLiteral(v))return{kind:"literal",value:v.text};if(i.isNumericLiteral(v))return{kind:"literal",value:Number(v.text)};if(v.kind===i.SyntaxKind.NullKeyword)return{kind:"null"};if(v.kind===i.SyntaxKind.TrueKeyword||v.kind===i.SyntaxKind.FalseKeyword)return{kind:"literal",value:v.kind===i.SyntaxKind.TrueKeyword}}if(i.isTypeReferenceNode(y)&&i.isIdentifier(y.typeName)){if(n.allowJson&&y.typeName.text==="Record"&&!u.has("Record")&&((x=y.typeArguments)==null?void 0:x.length)===2&&y.typeArguments[0].kind===i.SyntaxKind.StringKeyword)return{kind:"object",properties:{},additionalProperties:d(y.typeArguments[1],m)};if(y.typeName.text==="Array"&&((g=y.typeArguments)==null?void 0:g.length)===1)return{kind:"array",items:d(y.typeArguments[0],m)};if(!((w=y.typeArguments)!=null&&w.length))return l(y.typeName.text,m)}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 Yy(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 Xy(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 Yy(t,e.name);throw new Error("Choose a .ts interface or .json JSON Schema file.")}const _l=new WeakMap;function Vt(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)=>Vt(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:Vt(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 pt(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 vn(e,t){return!e||("$in"in e?e.$in.includes(xe(t,e.$address)):xe(t,e.$address)===e.$equals)}function Nt(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 hr(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 xn(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:Vt(xe(e,t.address)),data:Vt(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 Hx(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;Wt(i),r=xn(r,{address:n.address,nodeAddress:o.slice(0,-1).join("."),value:i})}return Wt(r),r}function Jt(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 Wt(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}`);Wt(r)}}function Kx(e,t,r){Wt(t.value);const n=xn(e,t,r);return Wt(n),n}function Qy(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 Jr=(e="reference")=>({kind:e,text:"",paths:[""]}),eb=e=>/^[A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*|\.\d+)+$/.test(e)&&!e.split(".").some(t=>["__proto__","constructor","prototype"].includes(t));function Zx(e,t){const r=new Set(t.map(a=>a.path)),n=a=>{if(!a.paths.length||a.paths.some(s=>!eb(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 Jx(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=Jr();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(!eb(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({...Jr("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({...Jr("text"),text:a.slice(u)}),s},o={mode:"reference",parts:[Jr()],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 jl({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,Jr()])})]})}function Yx({label:e,value:t,references:r,disabled:n,onChange:o}){const[i,a]=E.useState(),[s,u]=E.useState(""),[c,l]=E.useState(!1),d=async()=>{l(!0),u("");try{a(await Jx(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:[Jr()]}),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:b=>a({...i,fields:i.fields.map((y,m)=>m===p?{...y,key:b.target.value}:y)})})]}),h.jsx(jl,{parts:f.parts,references:r,disabled:n,onChange:b=>a({...i,fields:i.fields.map((y,m)=>m===p?{...y,parts:b}: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((b,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:[Jr()]}]})})]}):h.jsx(jl,{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(Zx(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 Xx=e=>!!e&&!e.includes(".")&&!e.startsWith("$")&&!["__proto__","constructor","prototype"].includes(e),Qx=e=>`root.__form_${encodeURIComponent(e).replace(/\./g,"%2E")}`,Et=(e,t)=>JSON.stringify([e,t]);function Gt(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 Gt(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 Rt(e){const t=Gt(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 El(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"&&!Nt(e)?e.types:[e]}function e0(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 r0(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,b=!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),m=Gt(d,y),x=m.kind!=="object"&&m.kind!=="array";o.containers.set(c,{address:l,type:m,declared:d,scalar:x});const g=`__form:${c}`,w={...(C=o.bindings[c])==null?void 0:C.fields},v={kind:"object",properties:{},ports:{...m.kind==="object"?m.ports:{},...b?{resource:{kind:"output"}}:{}}},_=m.kind==="object"?{...m.properties,...Object.fromEntries(Object.keys(y??{}).filter(k=>!Object.prototype.hasOwnProperty.call(m.properties,k)&&m.additionalProperties).map(k=>[k,{type:m.additionalProperties,optional:!0}]))}:m.kind==="array"?Object.fromEntries((Array.isArray(y)?y:[]).map((k,j)=>[String(j),{type:m.items,optional:!0}])):{value:{type:Nt(d)?d:m,optional:!1}};for(const[k,j]of Object.entries(_)){if(!Xx(k))throw new Error(`Unsupported structured property key: ${k}`);const P=x?l:`${l}.${k}`,R=xe(e,P),I=Gt(j.type,R),O=I.kind==="object"||I.kind==="array",M=(S=v.ports)==null?void 0:S[k],q=(M==null?void 0:M.kind)==="config"&&(((T=w[k])==null?void 0:T.$options)||Nt(j.type)),H=j.type.kind==="json"||j.type.kind==="union"&&!Nt(j.type);if(!O&&m.kind!=="array"&&(!H||x)||q){v.properties[k]={...j,type:j.type.kind==="json"?I:j.type};continue}const V=a.get(P)??Qx(P),re=m.kind==="array"?`Item ${Number(k)+1}`:k,ce={address:P,owner:c,field:k,type:j.type,label:re,nodeId:V,present:R!==void 0};if(o.slots.set(Et(c,k),ce),v.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 le={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(le),s(V,P,j.type,f,p+1,!0);const be=o.schema[`__form:${V}`];le.data.description=Object.fromEntries(Object.keys(be.properties).map(K=>[K,xe(e,I.kind==="array"||I.kind==="object"?`${P}.${K}`:P)]).filter(([,K])=>K!==void 0))}o.schema[g]=v,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 t0({nodeAddress:e}){const{structured:t,data:r,callbacks:n,editable:o}=E.useContext(kr),i=Ie(),[a,s]=E.useState(""),[u,c]=E.useState("0"),[l,d]=E.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,b=xe(r,f.address),y=El(f.declared),m=f.type.kind==="array"?f.type.items:f.type.kind==="object"?f.type.additionalProperties:void 0,x=m?El(m):[],g=j=>j.kind==="literal"?String(j.value):j.kind==="string"?"Text":Cr(j.kind),w=[...t.slots.values()].filter(j=>j.owner===e),v=(j,P)=>{var R;return(R=n.onFormChange)==null?void 0:R.call(n,{data:r,nodeAddress:f.address,address:j,previousValue:xe(r,j),value:P})},_=j=>{var P;i.setSelectedNodeIds([j]),(P=i.engineRef.current)==null||P.focusNode(j,90,!1)},C=(j,P)=>{if(!Array.isArray(b))return;const R=[...b];[R[j],R[j+P]]=[R[j+P],R[j]],v(f.address,R)},S=()=>{const j=x[Number(u)]??x[0];if(j)if(f.type.kind==="array")v(f.address,[...Array.isArray(b)?b:[],Rt(j)]);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(b,a)){d("Property already exists.");return}v(`${f.address}.${a}`,Rt(j)),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(j=>Gt(j,b).kind===f.type.kind),onChange:j=>v(f.address,Rt(y[Number(j.target.value)])),children:y.map((j,P)=>h.jsx("option",{value:P,children:g(j)},P))}),h.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]})]}),w.map((j,P)=>h.jsxs("div",{"data-structured-slot":j.address,style:{display:"flex",gap:6,alignItems:"center",minWidth:0},children:[j.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(j.label)}),h.jsx(ve,{"aria-label":`${j.present?"Focus":"Create"} ${Cr(j.label)}`,title:`${j.present?"Focus":"Create"} ${Cr(j.label)}`,icon:j.present?h.jsx(Z.PiMagnifyingGlass,{size:18}):h.jsx(Z.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:p&&!j.present,onClick:R=>{var I;j.present?((I=R.currentTarget.closest("dialog"))==null||I.close(),_(j.nodeId)):v(j.address,Rt(j.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)})]}),j.present&&h.jsx(ve,{"aria-label":`Remove ${Cr(j.label)}`,icon:h.jsx(Z.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:p,onClick:()=>k?v(f.address,b.filter((R,I)=>I!==P)):v(j.address,void 0)})]},j.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:j=>s(j.target.value)})]}),x.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:j=>c(j.target.value),children:x.map((j,P)=>h.jsx("option",{value:P,children:g(j)},P))}),h.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]})]}),h.jsx("span",{style:{display:"flex",alignItems:"center",flexShrink:0,...T||x.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=E.createContext({callbacks:{}}),tn=gn.default.div`
52
+ padding: 0;
53
+ font-size: 16px;
54
+ line-height: 1.4;
55
+ width: 100%;
56
+ box-sizing: border-box;
57
+ & [data-form-field] {
58
+ padding: 8px 0;
59
+ min-width: 0;
60
+ }
61
+ & label {
62
+ display: block;
63
+ margin-bottom: 6px;
64
+ font-size: 15px;
65
+ }
66
+ & input:not([type="checkbox"]),
67
+ & textarea,
68
+ & select {
69
+ width: 100%;
70
+ min-width: 0;
71
+ box-sizing: border-box;
72
+ font: inherit;
73
+ color: inherit;
74
+ padding: 10px 14px;
75
+ border: 0;
76
+ border-radius: 16px;
77
+ background: color-mix(in srgb, currentColor 7%, transparent);
78
+ outline: none;
79
+ box-shadow: none;
80
+ }
81
+ & textarea {
82
+ min-height: 98px;
83
+ resize: vertical;
84
+ }
85
+ & [data-form-select] {
86
+ position: relative;
87
+ }
88
+ & [data-form-select] select {
89
+ appearance: none;
90
+ padding-right: 40px;
91
+ }
92
+ & [data-form-select] > svg {
93
+ position: absolute;
94
+ right: 12px;
95
+ top: 50%;
96
+ transform: translateY(-50%);
97
+ pointer-events: none;
98
+ }
99
+ & [data-form-select] select:disabled + svg {
100
+ opacity: 0.55;
101
+ }
102
+ & details {
103
+ border-bottom: 1px solid color-mix(in srgb, currentColor 12%, transparent);
104
+ }
105
+ & summary {
106
+ display: flex;
107
+ align-items: center;
108
+ justify-content: space-between;
109
+ gap: 12px;
110
+ padding: 12px 0;
111
+ cursor: pointer;
112
+ font-weight: 600;
113
+ list-style: none;
114
+ }
115
+ & summary::-webkit-details-marker {
116
+ display: none;
117
+ }
118
+ & summary > span {
119
+ min-width: 0;
120
+ overflow-wrap: anywhere;
121
+ }
122
+ & summary > svg {
123
+ flex-shrink: 0;
124
+ transform: rotate(-90deg);
125
+ }
126
+ & details[open] > summary > svg {
127
+ transform: rotate(0deg);
128
+ }
129
+ & input[type="checkbox"] {
130
+ width: 20px;
131
+ height: 20px;
132
+ }
133
+ & button {
134
+ font: inherit;
135
+ cursor: pointer;
136
+ }
137
+ & button:disabled,
138
+ & input:disabled,
139
+ & select:disabled,
140
+ & textarea:disabled {
141
+ cursor: default;
142
+ opacity: 0.55;
143
+ }
144
+ & [role="alert"] {
145
+ color: #dc2626;
146
+ font-size: 14px;
147
+ margin-top: 8px;
148
+ }
149
+ `;function Rl({request:e,property:t,config:r,value:n,disabled:o}){var B,W;const{callbacks:i,structured:a,references:s}=E.useContext(kr),{themeColor:u}=Ie(),{background:c}=Ve(),l=E.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,b]=E.useState(f),[y,m]=E.useState(""),[x,g]=E.useState(0),[w,v]=E.useState(),_=((B=r.$options)==null?void 0:B.$source)==="callback",C=i.resolveFormOptions,{data:S,address:T,nodeAddress:k,nodeId:j}=e,P=E.useRef(S);P.current=S;const R=JSON.stringify([T,j,(W=r.$options)!=null&&W.$dependsOn?r.$options.$dependsOn.map(z=>xe(S,z)):xe(S,k)]);E.useEffect(()=>{b(f),m("")},[f,T,j]),E.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:j,data:Vt(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||v({key:R,options:X})}).catch(X=>{z.signal.aborted||v({key:R,options:[],error:X instanceof Error?X.message:"Options unavailable"})}),()=>z.abort()},[_,C,R,T,k,j,x]);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}]:Nt(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"),H=!t.optional||!!r.$requiredWhen&&vn(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,H),ce=Cr(r.$label??T.split(".").pop()),le=z=>{var X;if(!(o||Object.is(z,n)))try{(X=i.onFormChange)==null||X.call(i,{...e,previousValue:n,value:z}),m("")}catch(se){m(se instanceof Error?se.message:"Unable to update field")}},be=()=>{if(d){try{const Q=p===""&&t.optional?void 0:JSON.parse(p),G=Rr(t.type,Q,H);if(G){m(G);return}le(Q)}catch{m("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,H);if(z&&se&&p!==""){m(se);return}le(X)},K={id:l,disabled:o,"aria-label":ce,"aria-required":H,"aria-invalid":!!re,"aria-describedby":re?`${l}-error`:void 0},N=pe(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,H?" *":""]}),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:()=>le(void 0),children:h.jsx(Z.PiArrowCounterClockwise,{size:14})})]}),!!(s!=null&&s.length)&&!d&&h.jsx(Yx,{label:ce,value:n,references:s,disabled:o,onChange:le}),V?null:q==="select"?h.jsxs("div",{"data-form-select":"",children:[h.jsxs("select",{...K,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&&le(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:pe(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":K["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:()=>le(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",{...K,value:p,onChange:z=>b(z.target.value),onBlur:be}):h.jsx("input",{...K,type:t.type.kind==="number"||t.type.kind==="integer"?"number":"text",step:t.type.kind==="integer"?1:"any",value:p,onChange:z=>b(z.target.value),onBlur:be,onKeyDown:z=>{z.key==="Enter"&&be(),z.key==="Escape"&&b(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:()=>{v(void 0),g(x+1)},children:"Retry"})]})}function rb({nodeAddress:e}){var v,_;const{data:t,schema:r,callbacks:n,bindings:o,editable:i,renderForm:a,structured:s}=E.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(tn,{role:"alert",children:"Forms require a JSON document."});const d=o?Jt(o,e,r):void 0,f=o?d:r&&pt(t,e,r);if(!f)return h.jsx(tn,{role:"status",children:"Form schema unavailable."});const p=(d==null?void 0:d.address)??e,b=xe(t,p),y=(v=s==null?void 0:s.containers.get(e))==null?void 0:v.scalar;if(b===void 0||typeof b!="object"&&!y)return h.jsx(tn,{role:"alert",children:"Bound form state is unavailable."});const m=Object.entries(f.type.properties).filter(([C])=>{var S;return vn((S=f.fields[C])==null?void 0:S.$visibleWhen,t)}),x=m.length>8||m.some(([C])=>{var S;return(S=f.fields[C])==null?void 0:S.$section}),g=new Map;for(const C of m){const[S,T]=C,k=x?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(b==null?void 0:b.id)=="string"?b.id:void 0},property:S,config:f.fields[C]??{},value:y?b:b==null?void 0:b[C],disabled:u||c.editable===!1||!(i??!!n.onJsonChange)},`${(b==null?void 0:b.id)??e}:${C}`);return h.jsxs(tn,{"data-flow-form":e,onClick:C=>C.stopPropagation(),onDoubleClick:C=>C.stopPropagation(),children:[s&&h.jsx(t0,{nodeAddress:e}),d&&f.type.additionalProperties&&m.length===0&&h.jsx(Rl,{request:{data:t,address:p,nodeAddress:p},property:{type:f.type,optional:!1},config:{$label:"Configuration",$control:"textarea"},value:b,disabled:u||c.editable===!1||!i}),[...g].map(([C,S])=>x&&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 tb(e){const{viewData:t}=E.useContext(kr),{nodeById:r,edgeById:n,parentIds:o}=Wr();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 Ut(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:t}function ln(e,t,r,n){return{borderColor:t,borderWidth:Ut(e==null?void 0:e.borderWidth,n),borderStyle:(e==null?void 0:e.borderStyle)??"solid",...Su(t==="transparent"?"currentColor":t,r,".flow-sdk-node:hover &",!r)}}function nb({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 dn="data:image/svg+xml;base64,";function kt(e){if(e.startsWith(dn))return!0;try{const t=new URL(e);return(t.protocol==="https:"||t.protocol==="http:")&&!t.username&&!t.password}catch{return!1}}async function n0(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 dn+btoa(o)}const Mr=({name:e,svg:t=!1,...r})=>{const[n,o]=E.useState(null),[i,a]=E.useState(!0),[s,u]=E.useState(!1),c=typeof e=="string"&&kt(e);if(E.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=E.useRef(null),d=E.useId(),f=E.useRef(null),p=E.useRef(0),[b,y]=E.useState(!1),[m,x]=E.useState("icons"),[g,w]=E.useState([]),[v,_]=E.useState("loading"),[C,S]=E.useState(""),[T,k]=E.useState(0),[j,P]=E.useState(""),[R,I]=E.useState(""),[O,M]=E.useState(!1);E.useEffect(()=>()=>{p.current++},[]),E.useEffect(()=>{if(!b)return;let K=!0;return import("react-icons/pi").then(N=>{K&&(w(Object.keys(N).filter(B=>B.startsWith("Pi")).sort()),_("ready"))}).catch(()=>{K&&_("unavailable")}),()=>{K=!1}},[b]),E.useEffect(()=>{var K;o&&((K=l.current)==null||K.close())},[o]);const q=K=>{var N,B,W;o||(t?(N=n.onEdgeIconChange)==null||N.call(n,t,K):e&&((B=n.onNodeIconChange)==null||B.call(n,e,K)),(W=l.current)==null||W.close())},H=g.filter(K=>K.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase().includes(C.trim().toLowerCase())),V=36,re=Math.max(1,Math.ceil(H.length/V)),ce=Math.min(T,re-1),le=H.slice(ce*V,(ce+1)*V),be={width:"100%",padding:"8px 14px",background:"transparent",color:"inherit",border:`1px solid ${pe(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:pe(i),disabled:o,onClick:()=>{var K;I(""),x(r&&kt(r)?"custom":"icons"),P(r&&!r.startsWith(dn)&&kt(r)?r:""),y(!0),(K=l.current)==null||K.showModal()}})}),h.jsx("dialog",{ref:l,"aria-label":t?"Choose edge icon":"Choose node icon",onClose:()=>{y(!1),p.current++,M(!1)},onClick:K=>{K.stopPropagation(),K.target===K.currentTarget&&K.currentTarget.close()},onKeyDown:K=>K.stopPropagation(),style:{margin:"auto",padding:12,width:336,maxWidth:"calc(100vw - 32px)",maxHeight:"calc(100vh - 32px)",overflowY:"auto",border:`1px solid ${pe(u)}`,borderRadius:30,boxShadow:`0 0 0 8px color-mix(in srgb, ${pe(a)} 60%, transparent)`,background:pe(a),color:pe(c)},children:b&&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(ht,{"aria-label":"Close icon picker",onClick:()=>{var K;return(K=l.current)==null?void 0:K.close()}})]})]}),h.jsx("div",{role:"tablist","aria-label":"Icon source",style:{display:"flex",borderBottom:`1px solid ${pe(u)}`},children:["icons","custom"].map(K=>h.jsx("button",{id:`${d}-${K}`,type:"button",role:"tab","aria-selected":m===K,"aria-controls":`${d}-panel`,tabIndex:m===K?0:-1,onClick:()=>{x(K),I("")},onKeyDown:N=>{var W;if(!["ArrowLeft","ArrowRight","Home","End"].includes(N.key))return;N.preventDefault();const B=N.key==="Home"?"icons":N.key==="End"||K==="icons"?"custom":"icons";x(B),I(""),(W=document.getElementById(`${d}-${B}`))==null||W.focus()},style:{flex:1,padding:"8px 12px",background:"transparent",border:0,borderBottom:`2px solid ${m===K?pe(i):"transparent"}`,color:m===K?pe(i):"inherit",cursor:"pointer",fontSize:13},children:K==="icons"?"React icons":"Custom SVG"},K))}),h.jsx("input",{ref:f,type:"file",accept:".svg,image/svg+xml","aria-label":"Upload SVG icon",hidden:!0,disabled:O||o,onChange:async K=>{var W;const N=(W=K.target.files)==null?void 0:W[0];if(K.target.value="",!N)return;const B=++p.current;M(!0),I("");try{const z=await n0(N);B===p.current&&q(z)}catch(z){B===p.current&&I(z instanceof Error?z.message:"Unable to read SVG.")}finally{B===p.current&&M(!1)}}}),h.jsx("div",{id:`${d}-panel`,role:"tabpanel","aria-labelledby":`${d}-${m}`,style:{display:"grid",gap:8},children:m==="icons"?h.jsxs(h.Fragment,{children:[h.jsx("input",{"aria-label":"Search icons",placeholder:"Search icons...",value:C,onChange:K=>{S(K.target.value),k(0)},style:be}),h.jsxs("div",{style:{height:244,overflowY:"auto",display:"grid",gridTemplateColumns:"repeat(6, minmax(0, 1fr))",gridAutoRows:36,gap:4},children:[le.map(K=>h.jsx("button",{type:"button","aria-label":`Choose ${K}`,"aria-pressed":r===K,title:K,onClick:()=>q(K),style:{display:"grid",placeItems:"center",borderRadius:5,border:`${r===K?2:1}px solid ${pe(r===K?i:u)}`,background:pe(r===K?a:s),color:"inherit",cursor:"pointer"},children:h.jsx(Mr,{name:K,size:24})},K)),le.length===0&&h.jsx("span",{role:"status",style:{gridColumn:"1 / -1"},children:v==="loading"?"Loading icons...":v==="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:[H.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&&kt(r)&&h.jsx(Mr,{name:r,size:64}),h.jsxs("button",{type:"button",disabled:O||o,onClick:()=>{var K;return(K=f.current)==null?void 0:K.click()},style:{...be,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:K=>{K.preventDefault(),!(O||o)&&(!kt(j.trim())||j.trim().startsWith(dn)?I("Enter an HTTP or HTTPS image URL."):q(j.trim()))},children:[h.jsx("input",{type:"url","aria-label":"SVG URL",placeholder:"https://example.com/icon.svg",value:j,disabled:O||o,onChange:K=>P(K.target.value),style:{...be,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||!j.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"],ob=["gray.900","gray.600","gray.200","white"];function ib(){const{config:e}=Ie(),t=e.selectionToolbar||{},r=new Set(t.hide||[]);return{palette:t.palette||Nu,show:n=>!r.has(n)}}function cr(){const{border:e}=Ve();return h.jsx(F.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:e})}function Xr({value:e,placeholder:t,ariaLabel:r,width:n="140px",type:o="text",min:i,onCommit:a}){const{colorText:s}=Ve(),[u,c]=E.useState(e),l=E.useRef(!1);E.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 Ht({colors:e,value:t,label:r,onPick:n,onReset:o,includeTransparent:i=!0}){const{colorInactive:a,colorText:s}=Ve(),[u,c]=E.useState(!1),l=E.useId(),d=E.useRef(null),f=t??e[0]??"transparent";return h.jsxs(F.HStack,{gap:1,"aria-label":r,role:"group",onKeyDown:p=>{var b;p.key==="Escape"&&(c(!1),(b=d.current)==null||b.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:pe(f),...f==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:`2px solid ${pe(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 b=t===p;return h.jsx(je,{label:`${r}: ${p}`,children:h.jsx(F.Box,{as:"button","aria-label":`${r} ${p}`,"aria-pressed":b,w:4,h:4,borderRadius:"full",cursor:"pointer",style:{backgroundColor:pe(p),...p==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:b?`2px solid ${pe(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 ab({edgeId:e,onClose:t}){var p;const{callbacks:r,themeColor:n,config:o}=Ie(),{colorInactive:i}=Ve(),{edgeById:a}=Wr(),{palette:s,show:u}=ib(),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(ht,{onClick:t}),u("label")&&h.jsxs(h.Fragment,{children:[h.jsx(cr,{}),h.jsx(Xr,{ariaLabel:"Edge label",placeholder:"Edge label",value:(c==null?void 0:c.label)||"",onCommit:b=>{var y;return(y=r.onEdgeLabelChange)==null?void 0:y.call(r,e,b)}})]}),u("style")&&h.jsxs(h.Fragment,{children:[h.jsx(cr,{}),f.map(b=>h.jsx(je,{label:b.label,children:h.jsx(ve,{"aria-label":`Edge style ${b.key}`,"aria-pressed":d===b.key,icon:h.jsx(F.Icon,{as:b.icon,boxSize:5}),size:"sm",variant:"ghost",color:d===b.key?n:i,onClick:()=>{var y;return(y=r.onEdgeStyleChange)==null?void 0:y.call(r,e,b.key)}})},b.key)),d==="animated"&&h.jsx(nb,{label:"Edge animation",value:(c==null?void 0:c.edgeAnimationVariant)??"dashed",options:[{value:"dashed",label:"Dash"},{value:"traveling",label:"Trace"}],disabled:o.readOnly,onChange:b=>{var y;return(y=r.onEdgeAnimationVariantChange)==null?void 0:y.call(r,e,b)}}),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:b=>{var y;return(y=r.onEdgeTypeChange)==null?void 0:y.call(r,e,b||void 0)},children:[h.jsx("option",{value:"",children:"Default"}),l.map(b=>h.jsx("option",{value:b,children:b},b))]})]}),u("icon")&&h.jsxs(h.Fragment,{children:[h.jsx(cr,{}),h.jsx(qu,{edgeId:e,value:c==null?void 0:c.icon},e),h.jsx(Xr,{ariaLabel:"Edge icon",placeholder:"Icon name or SVG URL",value:(c==null?void 0:c.icon)??"",onCommit:b=>{var y;return(y=r.onEdgeIconChange)==null?void 0:y.call(r,e,b)}})]}),u("color")&&h.jsxs(h.Fragment,{children:[h.jsx(cr,{}),h.jsx(Ht,{label:"Edge color",colors:s,value:c==null?void 0:c.color,onPick:b=>{var y;return(y=r.onEdgeColorChange)==null?void 0:y.call(r,e,b)},onReset:()=>{var b;return(b=r.onEdgeColorChange)==null?void 0:b.call(r,e,"")}})]}),u("delete")&&h.jsxs(h.Fragment,{children:[h.jsx(cr,{}),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 b;(b=r.onEdgeDelete)==null||b.call(r,e,c),t()}})})]})]})}function sb({ids:e,showDivider:t=!0}){const{callbacks:r,config:n}=Ie(),{colorInactive:o}=Ve(),{nodeById:i}=Wr(),[a,s]=E.useState(!1),u=e.map(b=>{var y,m;return(m=(y=i.get(b))==null?void 0:y.data.viewProps)==null?void 0:m.borderRadius}),c=!u.every(b=>b===u[0]),l=c?"mixed":String(u[0]??""),d=["0","8","16","30","53","100"],f=a||!c&&l!==""&&!d.includes(l),p=b=>e.forEach(y=>{var m;return(m=r.onNodeBorderRadiusChange)==null?void 0:m.call(r,y,b)});return h.jsxs(h.Fragment,{children:[t&&h.jsx(cr,{}),h.jsx(F.Box,{position:"relative",w:"36px",h:"30px",display:"grid",placeItems:"center",children:h.jsxs(Or,{icon:h.jsx(F.Icon,{as:ev.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:b=>{s(b==="custom"),b!=="custom"&&p(b===""?void 0:Number(b))},children:[h.jsx("option",{value:"",children:"Default radius"}),c&&h.jsx("option",{value:"mixed",disabled:!0,children:"Mixed radii"}),d.map(b=>h.jsxs("option",{value:b,children:[b,"px radius"]},b)),h.jsx("option",{value:"custom",children:"Custom radius"})]})}),f&&h.jsx(Xr,{ariaLabel:"Custom border radius",placeholder:c?"Mixed":"Auto",type:"number",min:0,width:"72px",value:c?"":l,onCommit:b=>p(b===""?void 0:Number(b))})]})}function cb({ids:e,onClose:t}){var K,N,B,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}=Wr(),{palette:d,show:f}=ib(),p=e.length===1,b=p?(K=c.get(e[0]))==null?void 0:K.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)??""}),m=y.some(G=>G!==y[0]),x=m?"mixed":y[0]??"",g=e.some(G=>{var te,de;const J=(te=c.get(G))==null?void 0:te.data;return J&&(l.has(G)||((de=J.config)==null?void 0:de.parentContainer)||Object.prototype.hasOwnProperty.call(i.customViews??{},J.type))}),w=(N=b==null?void 0:b.config)==null?void 0:N.collapsed,v=tb(e[0]),_=G=>{var J,te,de;return(((te=(J=c.get(G))==null?void 0:J.data.viewProps)==null?void 0:te.outline)??(l.has(G)?(de=i.parentNodeStyle)==null?void 0:de.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),j=!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]=E.useState(!1),q=O&&f("color")&&f("borderColor"),H=G=>{var J,te,de;return(((te=(J=c.get(G))==null?void 0:J.data.viewProps)==null?void 0:te.borderStyle)??(l.has(G)?(de=i.parentNodeStyle)==null?void 0:de.borderStyle:"solid"))==="dashed"},V=e.every(H),re=!V&&e.some(H),ce=e.map(G=>{var de,fe,Ee;const J=(de=c.get(G))==null?void 0:de.data,te=l.has(G)?Ut((fe=i.parentNodeStyle)==null?void 0:fe.borderWidth,6):(J==null?void 0:J.type)==="objectView"?3:2;return Ut((Ee=J==null?void 0:J.viewProps)==null?void 0:Ee.borderWidth,te)}),le=ce.every(G=>G===ce[0])?String(ce[0]??""):"",be=G=>I(J=>{var te,de;q?(te=r.onNodeBorderColorChange)==null||te.call(r,J,G):(de=r.onNodeColorChange)==null||de.call(r,J,"bg",G)});return h.jsxs(h.Fragment,{children:[h.jsx(ht,{onClick:t}),h.jsx(cr,{}),p&&f("label")?h.jsx(Xr,{ariaLabel:"Node label",placeholder:"Node label",value:(b==null?void 0:b.label)??(b==null?void 0:b.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: ${x||"None (default)"}`,icon:h.jsx(Z.PiImage,{size:20}),style:{width:36},value:x,disabled:i.readOnly||i.editable===!1||g,onValueChange:G=>{Ft.includes(G)&&I(J=>{var te,de;(te=r.onNodeTypeViewChange)==null||te.call(r,J,G||void 0),a(J,"default"),(de=r.onNodeViewToggle)==null||de.call(r,J)})},children:[m&&h.jsx("option",{value:"mixed",disabled:!0,children:"Mixed"}),Ft.map(G=>h.jsx("option",{value:G,children:G||"None"},G))]}),f("style")&&h.jsx(sb,{ids:e},e.join("\0")),f("outline")&&h.jsxs(h.Fragment,{children:[h.jsx(cr,{}),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(cr,{}),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(Ht,{label:q?"Border color":"Background",colors:d,value:q?((B=b==null?void 0:b.viewProps)==null?void 0:B.borderColor)??(p&&l.has(e[0])?(W=i.parentNodeStyle)==null?void 0:W.borderColor:void 0):(z=b==null?void 0:b.viewProps)==null?void 0:z.bgColor,onPick:be,onReset:()=>be("")}),q&&f("style")&&h.jsxs(h.Fragment,{children:[h.jsx(cr,{}),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(Xr,{ariaLabel:"Border thickness",placeholder:p?"Auto":"Mixed",width:"64px",type:"number",min:0,value:le,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(cr,{}),h.jsx(je,{label:k?"Stop border animation":"Animate node border",children:h.jsx(ve,{"aria-label":"Toggle node animation","aria-pressed":j?"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||j)&&h.jsx(nb,{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(cr,{}),h.jsx(Ht,{label:"Text color",colors:ob,value:(X=b==null?void 0:b.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(cr,{}),h.jsx(qu,{nodeId:e[0],value:(se=b==null?void 0:b.config)==null?void 0:se.icon},e[0]),h.jsx(Xr,{ariaLabel:"Node icon",placeholder:"(e.g. PiGear)",width:"120px",value:((Q=b==null?void 0:b.config)==null?void 0:Q.icon)||"",onCommit:G=>{var J;return(J=r.onNodeIconChange)==null?void 0:J.call(r,e[0],G)}})]}),p&&v&&f("collapse")&&w!==void 0&&h.jsxs(h.Fragment,{children:[h.jsx(cr,{}),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(cr,{}),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 ub(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 lb(e,t="squeed.svg"){const r=document.createElement("a");r.href=await ub(e),r.download=t.endsWith(".svg")?t:`${t}.svg`,r.click()}function db(){const{themeColor:e}=Ie(),[t,r]=E.useState(!1),[n,o]=E.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 lb(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 fb({children:e,background:t,border:r}){const n=E.useRef(null),[o,i]=E.useState({left:!1,right:!1});E.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",borderColor:r,borderWidth:1,borderRadius:"30px",...Su(a),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 o0(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,b]of Object.entries(c))p==="$"?o(b,u):p.startsWith("$")||o(b,`${u}.${p}`)};if(o(t,"root"),!r.size)return{contract:await Xy(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=pt(t,s,i);u&&(a[s]={type:u.type,optional:!1})}return{schema:i,contract:{name:e.name,nodes:a}}}function hb({message:e,onDismiss:t}){const{background:r,colorText:n,border:o}=Ve();return!e||typeof document>"u"?null:Lt.createPortal(h.jsxs("div",{role:"alert","aria-atomic":"true",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,border:`1px solid ${pe(o)}`,background:pe(r),color:pe(n),boxShadow:"0 4px 20px #0003",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(ht,{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 pb({showDivider:e=!0,compact:t=!1}={}){const{edgeMode:r,setEdgeMode:n,workflowContract:o,setWorkflowContract:i,callbacks:a,readOnly:s,themeColor:u}=Ie(),{edgeById:c}=Wr(),{data:l,schema:d,setSchema:f,bindings:p,structured:b}=E.useContext(kr),y=(b==null?void 0:b.sourceBindings)??p,m=(b==null?void 0:b.sourceSchema)??d,{colorText:x}=Ve(),g=E.useRef(null),w=E.useRef(0),[v,_]=E.useState(!1),[C,S]=E.useState("");E.useEffect(()=>()=>{w.current++},[]),E.useEffect(()=>{w.current++,_(!1)},[s,l,y]);const T=o?[...c.values()].filter(j=>Iu(o,j.data)).length:0,k=o?`${o.name}: ${m?`${Object.keys(m).length} form types loaded; `:""}${T} invalid or unverified connections`:"";return h.jsxs(h.Fragment,{children:[h.jsx(hb,{message:C,onDismiss:()=>S("")}),e&&h.jsx(Ot,{}),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:j=>{var R;const P=j==="auto"?"auto":j==="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:pe(u),size:"sm",variant:"ghost",disabled:v||s,onClick:()=>{var j;return(j=g.current)==null?void 0:j.click()}})}),h.jsx("input",{ref:g,type:"file",hidden:!0,accept:".ts,.json","aria-label":"Workflow interface file",disabled:s||v,onChange:async j=>{var I,O;const P=(I=j.target.files)==null?void 0:I[0];if(j.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:H}=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 o0(P,l);if(R!==w.current)return;f==null||f(H),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||v)&&h.jsx("span",{role:"status",title:k,style:{color:pe(x),fontSize:12,maxWidth:180,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:v?"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||v,onClick:()=>{var j;f==null||f(void 0),i(void 0),(j=a.onWorkflowContractChange)==null||j.call(a,void 0),S("")}})})]})]})}const i0=[{value:"BT",label:"Bottom to Up",icon:Z.PiArrowUp,flowType:St.BOTTOM_UP},{value:"TB",label:"Top to Bottom",icon:Z.PiArrowDown,flowType:St.TOP_DOWN},{value:"LR",label:"Left to Right",icon:Z.PiArrowRight,flowType:St.LEFT_RIGHT},{value:"RL",label:"Right to Left",icon:Z.PiArrowLeft,flowType:St.RIGHT_LEFT}],gb=()=>{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:b,isDragMode:y,setIsDragMode:m,isEdgeHandlesEnabled:x,setIsEdgeHandlesEnabled:g,isArrayNodeMode:w,setIsArrayNodeMode:v,isPinned:_,setIsPinned:C,callbacks:S,config:T,readOnly:k}=Ie(),{nodeById:j,edgeById:P,parentIds:R}=Wr(),I=T.colorMode==="dark",{background:O,border:M,colorInactive:q,colorText:H,colorActive:V,darkBackgroundSecondary:re}=Ve(),[ce,le]=E.useState(!1),[be,K]=E.useState(!0),N=E.useCallback(me=>{const Te=e.current;if(!Te)return;const er=T.minZoom??.01,De=T.maxZoom??1.5,Ne=.02;let He=Te.zoom();switch(me){case"increase":He=Math.min(De,He+Ne),Te.zoom(He),Te.center();break;case"decrease":He=Math.max(er,He-Ne),Te.zoom(He),Te.center();break;case"reset":Te.fit(50);break}},[e,T.minZoom,T.maxZoom]),B=T.renderSelectedNodeToolbar,W=s.length>0&&!!B,z=E.useMemo(()=>W?s.map(me=>{var er;return{...((er=j.get(me))==null?void 0:er.data)??{id:me},isParent:R.has(me)}}):[],[W,s,j,R]),X=E.useCallback(()=>{var me;u([]),(me=S.onNodeDeselect)==null||me.call(S)},[u,S]),se=T.renderSelectedEdgeToolbar,Q=!!c&&!!se,G=E.useMemo(()=>{var me;return!Q||!c?null:((me=P.get(c))==null?void 0:me.data)??{id:c}},[Q,c,P]),J=E.useCallback(()=>{var me;l(null),(me=S.onEdgeDeselect)==null||me.call(S)},[l,S]),te=T.selectionToolbar!==!1&&!k,de=te&&!!c&&!se,fe=te&&!de&&s.length>0&&!B,Ee=de||fe,ge=_||ce||Ee;E.useEffect(()=>{s.length||c?o(!1):n&&!k&&(C(!0),K(!1))},[n,s.length,c,k,o,C]);const We=T.renderBottomBar;return We?h.jsxs(h.Fragment,{children:[W&&h.jsx(F.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:B({selectedNodeIds:s,selectedNodeData:z,onDeselect:X})}),Q&&G&&h.jsx(F.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:se({edgeId:c,edgeData:G,onDeselect:J})}),h.jsx(F.Box,{position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",children:We({zoomIn:()=>N("increase"),zoomOut:()=>N("decrease"),resetZoom:()=>N("reset"),direction:i,isZoomMode:d,setIsZoomMode:f,isMultiSelectMode:p,setIsMultiSelectMode:b,isDragMode:y,setIsDragMode:m,isEdgeHandlesEnabled:x,setIsEdgeHandlesEnabled:g,isArrayNodeMode:w,setIsArrayNodeMode:v,selectedNodeIds:s,selectedNodeData:z,selectedEdgeId:c,selectedEdgeData:G,onNodeDeselect:X,onEdgeDeselect:J,callbacks:S})})]}):h.jsxs(h.Fragment,{children:[W&&h.jsx(F.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:B({selectedNodeIds:s,selectedNodeData:z,onDeselect:X})}),Q&&G&&h.jsx(F.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:se({edgeId:c,edgeData:G,onDeselect:J})}),!_&&h.jsx(F.Box,{position:"absolute",bottom:5,left:0,zIndex:101,w:3,children:h.jsx(je,{label:"Show Bottom Bar",children:h.jsx(F.chakra.button,{type:"button","aria-label":"Show Bottom Bar",display:"flex",alignItems:"center",bg:O,borderColor:M,borderWidth:1,py:6,px:0,w:4,h:50,borderRadius:"15px",borderLeftRadius:0,onMouseEnter:()=>C(!0),onClick:()=>C(!0),_hover:{bg:re},children:h.jsx(F.Icon,{ml:-1,as:Z.PiLineVerticalBold,boxSize:5,color:M})})})}),h.jsx(F.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:ge?"translateY(0)":"translateY(100%)",pointerEvents:ge?"auto":"none",visibility:ge?"visible":"hidden",opacity:ge?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(fb,{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:[de?h.jsx(ab,{edgeId:c,onClose:J}):fe?h.jsx(cb,{ids:s,onClose:X}):null,h.jsxs("div",{style:{display:de||fe?"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(!_),le(!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:H,onClick:()=>N("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:H,onClick:()=>N("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:H,onClick:()=>N("reset")})}),!be&&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:()=>b(!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:()=>m(!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:x?"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:x?t:q,onClick:()=>g(!x)})})]}),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(Dy,{}),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 Te;const me=!w;v(me),(Te=S.onArrayModeChange)==null||Te.call(S,me)}})})]}),n&&!k&&h.jsxs(h.Fragment,{children:[h.jsx(F.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:M}),h.jsx(Ht,{label:"Graph theme",colors:Nu,value:t,includeTransparent:!1,onPick:me=>{var Te;r(me),(Te=S.onThemeColorChange)==null||Te.call(S,me)}})]}),h.jsx(pb,{}),h.jsx(Fy,{})]}),h.jsx(F.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:M}),h.jsx(je,{label:be?"Expand toolbar":"Collapse toolbar",children:h.jsx(ve,{"aria-label":"Toggle toolbar collapse",icon:h.jsx(F.Icon,{as:be?Z.PiCaretRight:Z.PiCaretLeft,boxSize:5}),size:"sm",variant:"ghost",color:q,onClick:()=>K(!be)})}),!be&&h.jsx(db,{})]})]})}),!Ee&&h.jsxs(F.Box,{position:"relative",ml:"auto",flexShrink:0,children:[h.jsx(F.Box,{"data-flow-direction-control":"",bg:O,borderWidth:1,borderColor:I?M:"gray.300",borderRadius:"30px",h:50,...Su(`var(--chakra-colors-${O.replace(".","-")})`),px:3,cursor:"pointer",onClick:()=>le(!ce),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})]})}),ce&&h.jsx(F.Box,{position:"absolute",bottom:"100%",right:0,pb:"24px",zIndex:200,children:h.jsxs(F.Box,{bg:O,borderWidth:1,borderColor:I?M:"gray.300",borderRadius:"30px",p:2,minW:"180px",boxShadow:`0 0 0 8px color-mix(in srgb, var(--chakra-colors-${O.replace(".","-")}) 40%, transparent), var(--chakra-shadows-lg)`,children:[i0.map(me=>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 Te;(Te=S.onDirectionChange)==null||Te.call(S,me.value),le(!1)},children:[h.jsx(F.Icon,{as:me.icon,boxSize:5,color:H}),h.jsx(F.Text,{fontSize:"sm",color:H,flex:1,whiteSpace:"nowrap",children:me.label}),i===me.value&&h.jsx(F.Icon,{as:Z.PiCheck,boxSize:4,color:V})]},me.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 me;(me=S.onDirectionChange)==null||me.call(S,"C"),le(!1)},children:[h.jsx(F.Icon,{as:Z.PiAlignCenterHorizontal,boxSize:5,color:H}),h.jsx(F.Text,{fontSize:"sm",color:H,flex:1,whiteSpace:"nowrap",children:"Center"}),i==="C"&&h.jsx(F.Icon,{as:Z.PiCheck,boxSize:4,color:V})]})]})})]})]})})]})};gb.displayName="BottomBar";const yb=E.memo(gb);function a0({checked:e,onChange:t,disabled:r,label:n="Connected nodes"}){return h.jsx(By,{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 bb(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 s0(e,t){return bb(e,t)!==void 0}function c0(e,t,r){if(e===t)return r;const n=bb(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 vu(e){return e.kind==="literal"?e.value:e.kind==="union"?vu(e.types[0]):e.kind==="array"?[]:e.kind==="object"?Object.fromEntries(Object.entries(e.properties).filter(([,t])=>!t.optional).map(([t,r])=>[t,vu(r.type)])):e.kind==="boolean"?!1:e.kind==="number"||e.kind==="integer"?0:e.kind==="null"?null:""}function mb(e,t,r){var m,x,g;const n=(m=xe(e,t))==null?void 0:m.$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=pt(e,s,r),c=(x=u==null?void 0:u.type.properties[a])==null?void 0:x.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,v]of Object.entries(d))if(!Object.prototype.hasOwnProperty.call(l.properties,w)||Rr(l.properties[w].type,v,!l.properties[w].optional))throw new Error(`Invalid creation default: ${w}`);const f={...vu(l),...structuredClone(d)};((g=l.properties.id)==null?void 0:g.type.kind)==="string"&&(f.id=Eu());let p=e;const b=xe(e,o.$address);if(b===void 0)p=hr(e,s,w=>({...w,[a]:[]}));else if(!Array.isArray(b)&&!Array.isArray(b==null?void 0:b.$))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 u0(e,t){const r=o=>e&&typeof e=="object"&&o in e;let n=1;for(;r(`${t}_${n}`);)n++;return`${t}_${n}`}function vb(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(xn(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&&!Ft.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(Uy(e,s,u),{type:"nodeCollapse",address:s,key:"$collapsed",value:u})},onNodeCreate:s=>{var p,b;const u=s.sourceNodeId&&mb(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}(b=r.onNodeCreate)==null||b.call(r,s);const c=s.sourceNodeId||"root",l=xe(e,c),d=u0(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(Ky(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):Zy(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(Hy(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=Jy(e,c);l.removed&&i(l.json,{type:"edgeDelete",edge:c,key:c.connection?"$connections":"$target"})}}}const l0=".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 d0({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 f0=".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 xb({x:e=0,y:t=0,width:r,height:n,radius:o,color:i,strokeWidth:a=8,path:s,variant:u="traveling"}){const c=E.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,b={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",...b,style:{maskType:"luminance"},children:[h.jsx("rect",{...b,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 h0=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 p0(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},b)=>{const y=c.length===1?l/2:120+(l-280)*b/(c.length-1),m=c.find(x=>Math.abs(x.cross)<Math.abs(p));i.set(d.id,{turn:y/f,labelAtTarget:s.get(d.target)===1,labelFraction:p?(p+((m==null?void 0:m.cross)??0))/(2*p):.5})})}}return i}const at=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}),g0=e=>({x:(e.x1+e.x2)/2,y:(e.y1+e.y2)/2,w:e.x2-e.x1,h:e.y2-e.y1});function Jn(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 y0=(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,ur=e=>(Math.round(e*10)/10).toString(),Ue=e=>`${ur(e.x)} ${ur(e.y)}`,b0=e=>e>0?1:e<0?-1:0,Tl=(e,t)=>e>0?Math.max(e-t,0):Math.min(e+t,0);function m0(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=b0(d),p=n*l,b=g=>Math.abs(g)<o||Math.abs(g)>=Math.abs(l),y=b(p)||b(Math.abs(l)-Math.abs(p));let m;if(y)if(c)if(Math.abs(d)<=e.h/2){const g=(e.x+t.x)/2;m=[g,e.y,g,t.y]}else if(Math.abs(i)<=t.w/2){const g=(e.y+t.y)/2;m=[e.x,g,t.x,g]}else m=[e.x,t.y];else if(Math.abs(d)<=e.w/2){const g=(e.y+t.y)/2;m=[e.x,g,t.x,g]}else if(Math.abs(a)<=t.h/2){const g=(e.x+t.x)/2;m=[g,e.y,g,t.y]}else m=[t.x,e.y];else if(c){const g=e.y+p+e.h/2*f;m=[e.x,g,t.x,g]}else{const g=e.x+p+e.w/2*f;m=[g,e.y,g,t.y]}const x=[{x:e.x,y:e.y}];for(let g=0;g<m.length;g+=2)x.push({x:m[g],y:m[g+1]});return x.push({x:t.x,y:t.y}),x}function v0(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 ft(e,t,r){var a;if(!((a=r.outline)!=null&&a.length))return v0(e,t,at(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 b=s.x-e.x,y=s.y-e.y,m=(b*f-y*d)/p,x=(b*o-y*n)/p;m>=0&&m<1&&x>=-1e-9&&x<=1+1e-9&&(i=Math.min(i,m))}),Number.isFinite(i)?{x:e.x+n*i,y:e.y+o*i}:null}function wb(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{...ft(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 ut(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 x0(e,t,r,n){const o=ut(e,r.srcDist),i=ut(t,r.tgtDist);if(n==="straight")return _b(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=ut({...o,side:e.side},u),l=ut({...i,side:t.side},u),d=r.arrowAt==="source"?Qe(o,c,r.arrowGap):o,f=r.arrowAt==="target"?Qe(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${Ue(d)} C${Ue(c)} ${Ue(l)} ${Ue(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 b=e.side==="left"||e.side==="right",y=t.side==="left"||t.side==="right";let m;if(b!==y){const g=b?{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,v=(g.x-l.x)*(l.x-i.x)+(g.y-l.y)*(l.y-i.y)>=0;m=[w&&v?g:b?{x:c.x,y:l.y}:{x:l.x,y:c.y}]}else if(s!==void 0&&s<=0)if(b){const g=(c.y+l.y)/2;m=[{x:c.x,y:g},{x:l.x,y:g}]}else{const g=(c.x+l.x)/2;m=[{x:g,y:c.y},{x:g,y:l.y}]}else if(b){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;m=[{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;m=[{x:c.x,y:g},{x:l.x,y:g}]}const x=[c,...m,l].filter((g,w,v)=>w===0||g.x!==v[w-1].x||g.y!==v[w-1].y);return wn(d,x,f,p,n==="orthogonal"?0:r.radius)}function Qe(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${Ue(e)} L${ur(e.x-u*l)} ${ur(e.y+s*l)} L${ur(d-u*l)} ${ur(f+s*l)} L${ur(d+u*l)} ${ur(f-s*l)} L${ur(e.x+u*l)} ${ur(e.y-s*l)} Z`:`M${Ue(e)} L${ur(d-u*l)} ${ur(f+s*l)} L${ur(d+u*l)} ${ur(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 w0(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 Cb(e,t,r,n){let o=-1,i=null;for(let b=0;b<e.length-1;b++){const y=ft(e[b],e[b+1],t);if(y){o=b,i=y;break}}let a=-1,s=null;for(let b=e.length-1;b>0;b--){const y=ft(e[b],e[b-1],r);if(y){a=b,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 b=Qe(i,c,n.srcDist);d=Qe(i,c,n.srcDist+n.arrowGap),p=br(b,c,n.arrowSize,n.headShape)}else d=Qe(i,c,n.srcDist);if(n.arrowAt==="target"){const b=Qe(s,l,n.tgtDist);f=Qe(s,l,n.tgtDist+n.arrowGap),p=br(b,l,n.arrowSize,n.headShape)}else f=Qe(s,l,n.tgtDist);return wn(d,u,f,p,n.radius,n.labelTargetLength,n.labelFraction)}function wn(e,t,r,n,o,i,a){var f;const s=[e,...t,r],u=[];let c=`M${Ue(e)}`;for(let p=1;p<s.length-1;p++){const b=w0(s[p-1],s[p],s[p+1],o);u.push(b),b.r===0?c+=` L${Ue(b.b)}`:c+=` L${Ue(b.p1)} Q${Ue(b.b)} ${Ue(b.p2)}`}c+=` L${Ue(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],b=t[d/2];l={x:(p.x+b.x)/2,y:(p.y+b.y)/2,angle:Lr(b.x-p.x,b.y-p.y)}}else{const p=u[(d-1)/2];if(p.r===0){const b=s[(d-1)/2+2];l={x:p.b.x,y:p.b.y,angle:Lr(b.x-p.b.x,b.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 m=u[0].p2,x=u[1].p1,g=Math.hypot(x.x-m.x,x.y-m.y),w=Math.min(.5,i/(2*g)),v=Math.max(w,Math.min(1-w,a));l={x:m.x+(x.x-m.x)*v,y:m.y+(x.y-m.y)*v,angle:Lr(x.x-m.x,x.y-m.y)}}const p=((f=u[u.length-1])==null?void 0:f.p2)??e,b=r.x-p.x,y=r.y-p.y;Math.hypot(b,y)>=i&&(l={x:(p.x+r.x)/2,y:(p.y+r.y)/2,angle:Lr(b,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 x=u.x+(c.x-u.x)*i,g=Math.max(Math.min(d,f),Math.min(Math.max(d,f),x));p=[{x:g,y:u.y},{x:g,y:c.y}]}else{const x=Math.min(e.y-e.h/2,t.y-t.h/2)-l*(1+i);p=[{x:d,y:u.y},{x:d,y:x},{x:f,y:x},{x:f,y:c.y}]}const b=a.arrowAt==="source"?Qe(u,p[0],a.arrowGap):u,y=a.arrowAt==="target"?Qe(c,p[p.length-1],a.arrowGap):c,m=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 wn(b,p,y,m,a.radius)}function Il(e,t,r,n,o){return Cb(m0(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,b=ft(f,{x:f.x+(a?0:d*p),y:f.y+(a?d*p:0)},c);return b?{x:b.x+(a?0:d*i),y:b.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 C0(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"?Qe(e,s,n.arrowGap):e,l=n.arrowAt==="target"?Qe(t,u,n.arrowGap):t;return{d:`M${Ue(c)} C${Ue(s)} ${Ue(u)} ${Ue(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 _b(e,t,r){const n=r.arrowAt==="source"?Qe(e,t,r.arrowGap):e,o=r.arrowAt==="target"?Qe(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 wn(n,[],o,i,0)}function _0(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},b={x:e.x,y:e.y},y=ft(b,f,e),m=ft(b,p,e);if(!y||!m)return null;const x={x:(f.x+p.x)/2,y:(f.y+p.y)/2};let g=Qe(y,f,r.srcDist),w=Qe(m,p,r.tgtDist),v;if(r.arrowAt==="target"){const C=w;w=Qe(m,p,r.tgtDist+r.arrowGap),v=br(C,p,r.arrowSize,r.headShape)}else if(r.arrowAt==="source"){const C=g;g=Qe(y,f,r.srcDist+r.arrowGap),v=br(C,f,r.arrowSize,r.headShape)}return{d:`M${Ue(g)} Q${Ue(f)} ${Ue(x)} Q${Ue(p)} ${Ue(w)}`,arrow:v,label:{x:x.x,y:x.y,angle:Lr(p.x-f.x,p.y-f.y)}}}const ot=e=>Math.round(e*1e3)/1e3;function Sb(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:ot((a.a*p.x+a.c*p.y+a.e-r.left)/n),y:ot((a.b*p.x+a.d*p.y+a.f-r.top)/n)}}):void 0;return{left:ot((o.left-r.left)/n),top:ot((o.top-r.top)/n),width:t instanceof HTMLElement?t.offsetWidth:ot(o.width/n),height:t instanceof HTMLElement?t.offsetHeight:ot(o.height/n),radius:parseFloat(getComputedStyle(t).borderTopLeftRadius)||0,...l?{outline:l}:{}}}function $t(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 S0(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,b]of[[d.source,d.sourceProperty,d.target],[d.target,d.targetProperty,d.source]]){const y=t.get(b);if(p===void 0||!y||b===f)continue;const m=r.get(b),x=JSON.stringify([f,p]),g=u.get(x)??[];g.push(m?$t(y,m):y),u.set(x,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 b=r.get(d),y=b?$t(p,b):p,m={x:p.w/2,y:p.h/2,w:p.w,h:p.h},x=b?$t(m,b):m,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 v=g.get(w);if(!v)return w;const _=f.filter(T=>g.get(T)===v),C=(_.indexOf(w)+1)/(_.length+1),S=wb(x,v,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 Qr='"Helvetica Neue", Helvetica, sans-serif';let _t;const nn=new Map;function Cn(e,t){const r=`${t}|${e}`,n=nn.get(r);if(n!==void 0)return n;_t===void 0&&(_t=typeof document<"u"?document.createElement("canvas").getContext("2d"):null);let o;return _t?(_t.font=t,o=_t.measureText(e).width):o=e.length*(parseFloat(t)||16)*.55,nn.size>5e3&&nn.clear(),nn.set(r,o),o}function j0(e,t,r){const n=[];for(const o of String(e).split(`
150
+ `)){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||Cn(u,t)<=r?a=u:(n.push(a),a=s)}n.push(a)}return n}const E0=e=>e.stopPropagation();function R0({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,b=r?Cn(r,`bold ${o.fontSize}px ${Qr}`):0,y=o.fontSize/5,m=r||s&&a?h.jsxs("g",{className:"flow-sdk-container-label","data-node-id":e,children:[s&&a&&h.jsx("foreignObject",{x:f+b/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:x=>{x.stopPropagation(),a(e)}})})}),r&&h.jsxs(h.Fragment,{children:[h.jsx("rect",{x:f-b/2-y,y:p-o.fontSize/2-y,width:b+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:Qr,style:{fontSize:o.fontSize,fontWeight:"bold",fontFamily:Qr},textAnchor:"middle",dominantBaseline:"central",children:r})]})]}):null;return h.jsxs("g",{className:"flow-sdk-container","data-node-id":e,onPointerDown:E0,onClick:x=>{x.stopPropagation(),i==null||i(e,{shiftKey:x.shiftKey,ctrlKey:x.ctrlKey,metaKey:x.metaKey,altKey:x.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(xb,{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&&m?Lt.createPortal(m,n):m]})}const k0=E.memo(R0),fn=45,jb=70,Kr=15,Eb=50;function Rb(e,t,r=fn){const n=`${r}px ${Qr}`,o=e?j0(e,n,200*r/fn):[],i=t?48+(o.length?12:0):0,a=i+Math.max(0,...o.map(c=>Cn(c,n))),s=Math.max(o.length*r,t?48:0),u=o.length||t?2*Kr:0;return{lines:o,iconWidth:i,contentWidth:a,contentHeight:s,width:a+u,height:s+u}}const hn=6,kb=3,$u=Math.max(Math.pow(hn*13.37,.9),29)*kb,Pb=hn*kb*2,an=80,P0=2*an+$u*.3+100,A0=36+2*Math.max(80,Pb+$u*.3);function xu(e){return e.sourceProperty!==void 0||e.targetProperty!==void 0}function wu(e,t){return t==="auto"||(t==="properties"?xu(e):!xu(e))}function st(e,t,r){return r!=="properties"||e!=="root"||t.some(n=>(n.source===e||n.target===e)&&xu(n))}function T0(e,t,r,n=!1,o){if(!n||r!=="properties"&&!o)return{nodes:e,edges:t};const i=e.filter(s=>st(s.id,t,r)&&(!o||o.has(s.id))),a=new Set(i.map(s=>s.id));return{nodes:i,edges:t.filter(s=>wu(s,r)&&a.has(s.source)&&a.has(s.target))}}const O0=500,I0="32 18",M0=e=>e.stopPropagation();function q0({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:b=!1,dir:y,turn:m,labelAtTarget:x,labelFraction:g,color:w,labelBg:v,labelLayer:_,label:C,dashed:S,animated:T,inverted:k,loopIndex:j=0,onSelect:P}){const R=t==null?void 0:t.icon,I=b?fn:jb,{lines:O,iconWidth:M,contentWidth:q,contentHeight:H}=E.useMemo(()=>Rb(C,R,I),[C,R,I]),V=E.useMemo(()=>{const X={srcDist:an,tgtDist:an,arrowGap:Pb,arrowSize:$u,headShape:b&&(k?l!==void 0||f:d!==void 0||p)?"square":"triangle",radius:o??(x?40:O0),arrowAt:k?"source":"target",labelTargetLength:x?q+2*Kr:void 0,labelFraction:x?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"},de=a.x===s.x&&a.y===s.y,fe=f||p?x0(J,te,{...X,srcDist:18,tgtDist:18},n):se?Ol(a,s,y,l,d,m,{...X,srcDist:18,tgtDist:18,radius:o??Math.min(X.radius,40)}):de?_0(a,j,{...X,srcDist:0,tgtDist:0}):Il(a,s,y,m,X);if(!fe)return null;const Ee=Ml(a,s,y,l,d,se?18:an);f&&(Ee.sourcePoint=ut(f,18)),p&&(Ee.targetPoint=ut(p,18));const ge=Object.prototype.hasOwnProperty.call(i??{},n)?i==null?void 0:i[n]:void 0;if(ge){const We={rightward:"LR",leftward:"RL",downward:"TB",upward:"BT"};return ge({edge:t??{id:e,source:"",target:""},source:{...a},target:{...s},...Ee,direction:We[y],sourceY:l,targetY:d,inverted:!!k,defaultGeometry:fe})??fe}return de||f||p?fe:n==="straight"?se?_b(Ee.sourcePoint,Ee.targetPoint,X):Cb([a,s],a,s,X):n==="bezier"?C0(Ee.sourcePoint,Ee.targetPoint,se?y==="leftward"?"leftward":"rightward":y,X):n==="orthogonal"?se?Ol(a,s,y,l,d,m,{...X,srcDist:18,tgtDist:18,radius:0}):Il(a,s,y,m,{...X,radius:0}):fe},[a,e,t,n,o,i,s,b,l,d,f,p,y,m,k,j,x,g,q]);if(!V)return null;const re=(y==="rightward"||y==="leftward")&&!Object.prototype.hasOwnProperty.call(i??{},n)&&!(b&&(l!==void 0||d!==void 0||f||p)),ce=re?`translate(${V.label.x} ${V.label.y-H/2-2*Kr})`:`translate(${V.label.x} ${V.label.y}) rotate(${V.label.angle}) translate(${x||Object.prototype.hasOwnProperty.call(i??{},n)?0:Eb} 0)`,le=r!=null&&r.startsWith("Unverified:")?"#b45309":"#dc2626",be=r?le:w,K=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:le})]}):null,N=T&&(t==null?void 0:t.edgeAnimationVariant)==="traveling",B=!N&&(S||T)?I0: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=H;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-Kr,y:-se/2-Kr,width:X+2*Kr,height:se+2*Kr,fill:w==="transparent"?"transparent":v}),h.jsx("text",{fill:w,fontSize:I,style:{fontSize:I,fontFamily:Qr},fontFamily:Qr,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:M0,onClick:X=>{X.stopPropagation(),P==null||P(e)},children:[h.jsx("path",{d:V.d,fill:"none",stroke:be,strokeWidth:hn,strokeOpacity:N?.35:void 0,strokeDasharray:B,className:W}),N&&h.jsx(d0,{path:V.d,color:be,width:hn*1.6,reversed:k}),V.arrow&&h.jsx("path",{d:V.arrow,fill:be}),_&&z?Lt.createPortal(z,_):z,_&&K?Lt.createPortal(K,_):K,h.jsx("path",{className:"flow-sdk-edge-hit",d:V.d,fill:"none",stroke:"transparent"})]})}const Nl=E.memo(q0),$l=(e,t)=>e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top;function N0(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),b=c.querySelector("rect");if(!p||!b)continue;const y=b.getBBox(),m=p.getTotalLength();if(!Number.isFinite(m)||m<=0)continue;const x=(d.left+d.right)/2,g=(d.top+d.bottom)/2,w=Math.min(256,Math.max(16,Math.ceil(m/24))),v=Array.from({length:w+1},(S,T)=>p.getPointAtLength(m*T/w)),C=Array.from({length:w+1},(S,T)=>{const k=m*T/w,j=v[T],P=l?{x:j.x,y:j.y-y.height/2-15}:j,R=p.getPointAtLength(Math.max(0,k-2)),I=p.getPointAtLength(Math.min(m,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,H=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-x,P.y-g),bounds:{left:P.x-H/2-8,right:P.x+H/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&&!v.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 on=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function $0(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 Yn,Ll;function L0(){if(Ll)return Yn;Ll=1;function e(){this.__data__=[],this.size=0}return Yn=e,Yn}var Xn,Fl;function gt(){if(Fl)return Xn;Fl=1;function e(t,r){return t===r||t!==t&&r!==r}return Xn=e,Xn}var Qn,Bl;function _n(){if(Bl)return Qn;Bl=1;var e=gt();function t(r,n){for(var o=r.length;o--;)if(e(r[o][0],n))return o;return-1}return Qn=t,Qn}var eo,Dl;function F0(){if(Dl)return eo;Dl=1;var e=_n(),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 eo=n,eo}var ro,zl;function B0(){if(zl)return ro;zl=1;var e=_n();function t(r){var n=this.__data__,o=e(n,r);return o<0?void 0:n[o][1]}return ro=t,ro}var to,Vl;function D0(){if(Vl)return to;Vl=1;var e=_n();function t(r){return e(this.__data__,r)>-1}return to=t,to}var no,Wl;function z0(){if(Wl)return no;Wl=1;var e=_n();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 no=t,no}var oo,Gl;function Sn(){if(Gl)return oo;Gl=1;var e=L0(),t=F0(),r=B0(),n=D0(),o=z0();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,Ul;function V0(){if(Ul)return io;Ul=1;var e=Sn();function t(){this.__data__=new e,this.size=0}return io=t,io}var ao,Hl;function W0(){if(Hl)return ao;Hl=1;function e(t){var r=this.__data__,n=r.delete(t);return this.size=r.size,n}return ao=e,ao}var so,Kl;function G0(){if(Kl)return so;Kl=1;function e(t){return this.__data__.get(t)}return so=e,so}var co,Zl;function U0(){if(Zl)return co;Zl=1;function e(t){return this.__data__.has(t)}return co=e,co}var uo,Jl;function Ab(){if(Jl)return uo;Jl=1;var e=typeof on=="object"&&on&&on.Object===Object&&on;return uo=e,uo}var lo,Yl;function Sr(){if(Yl)return lo;Yl=1;var e=Ab(),t=typeof self=="object"&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return lo=r,lo}var fo,Xl;function yt(){if(Xl)return fo;Xl=1;var e=Sr(),t=e.Symbol;return fo=t,fo}var ho,Ql;function H0(){if(Ql)return ho;Ql=1;var e=yt(),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 ho=i,ho}var po,ed;function K0(){if(ed)return po;ed=1;var e=Object.prototype,t=e.toString;function r(n){return t.call(n)}return po=r,po}var go,rd;function et(){if(rd)return go;rd=1;var e=yt(),t=H0(),r=K0(),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 go=a,go}var yo,td;function mr(){if(td)return yo;td=1;function e(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}return yo=e,yo}var bo,nd;function Yt(){if(nd)return bo;nd=1;var e=et(),t=mr(),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 mo,od;function Z0(){if(od)return mo;od=1;var e=Sr(),t=e["__core-js_shared__"];return mo=t,mo}var vo,id;function J0(){if(id)return vo;id=1;var e=Z0(),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 vo=r,vo}var xo,ad;function Tb(){if(ad)return xo;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 xo=r,xo}var wo,sd;function Y0(){if(sd)return wo;sd=1;var e=Yt(),t=J0(),r=mr(),n=Tb(),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 wo=d,wo}var Co,cd;function X0(){if(cd)return Co;cd=1;function e(t,r){return t==null?void 0:t[r]}return Co=e,Co}var _o,ud;function rt(){if(ud)return _o;ud=1;var e=Y0(),t=X0();function r(n,o){var i=t(n,o);return e(i)?i:void 0}return _o=r,_o}var So,ld;function Fu(){if(ld)return So;ld=1;var e=rt(),t=Sr(),r=e(t,"Map");return So=r,So}var jo,dd;function jn(){if(dd)return jo;dd=1;var e=rt(),t=e(Object,"create");return jo=t,jo}var Eo,fd;function Q0(){if(fd)return Eo;fd=1;var e=jn();function t(){this.__data__=e?e(null):{},this.size=0}return Eo=t,Eo}var Ro,hd;function ew(){if(hd)return Ro;hd=1;function e(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}return Ro=e,Ro}var ko,pd;function rw(){if(pd)return ko;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 ko=o,ko}var Po,gd;function tw(){if(gd)return Po;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 Po=n,Po}var Ao,yd;function nw(){if(yd)return Ao;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 Ao=r,Ao}var To,bd;function ow(){if(bd)return To;bd=1;var e=Q0(),t=ew(),r=rw(),n=tw(),o=nw();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,To=i,To}var Oo,md;function iw(){if(md)return Oo;md=1;var e=ow(),t=Sn(),r=Fu();function n(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}return Oo=n,Oo}var Io,vd;function aw(){if(vd)return Io;vd=1;function e(t){var r=typeof t;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?t!=="__proto__":t===null}return Io=e,Io}var Mo,xd;function En(){if(xd)return Mo;xd=1;var e=aw();function t(r,n){var o=r.__data__;return e(n)?o[typeof n=="string"?"string":"hash"]:o.map}return Mo=t,Mo}var qo,wd;function sw(){if(wd)return qo;wd=1;var e=En();function t(r){var n=e(this,r).delete(r);return this.size-=n?1:0,n}return qo=t,qo}var No,Cd;function cw(){if(Cd)return No;Cd=1;var e=En();function t(r){return e(this,r).get(r)}return No=t,No}var $o,_d;function uw(){if(_d)return $o;_d=1;var e=En();function t(r){return e(this,r).has(r)}return $o=t,$o}var Lo,Sd;function lw(){if(Sd)return Lo;Sd=1;var e=En();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 Lo=t,Lo}var Fo,jd;function Bu(){if(jd)return Fo;jd=1;var e=iw(),t=sw(),r=cw(),n=uw(),o=lw();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,Fo=i,Fo}var Bo,Ed;function dw(){if(Ed)return Bo;Ed=1;var e=Sn(),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 Bo=o,Bo}var Do,Rd;function Rn(){if(Rd)return Do;Rd=1;var e=Sn(),t=V0(),r=W0(),n=G0(),o=U0(),i=dw();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,Do=a,Do}var zo,kd;function Du(){if(kd)return zo;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 zo=e,zo}var Vo,Pd;function Ob(){if(Pd)return Vo;Pd=1;var e=rt(),t=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return Vo=t,Vo}var Wo,Ad;function kn(){if(Ad)return Wo;Ad=1;var e=Ob();function t(r,n,o){n=="__proto__"&&e?e(r,n,{configurable:!0,enumerable:!0,value:o,writable:!0}):r[n]=o}return Wo=t,Wo}var Go,Td;function Pn(){if(Td)return Go;Td=1;var e=kn(),t=gt(),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 Go=o,Go}var Uo,Od;function Xt(){if(Od)return Uo;Od=1;var e=Pn(),t=kn();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 Uo=r,Uo}var Ho,Id;function fw(){if(Id)return Ho;Id=1;function e(t,r){for(var n=-1,o=Array(t);++n<t;)o[n]=r(n);return o}return Ho=e,Ho}var Ko,Md;function Pr(){if(Md)return Ko;Md=1;function e(t){return t!=null&&typeof t=="object"}return Ko=e,Ko}var Zo,qd;function hw(){if(qd)return Zo;qd=1;var e=et(),t=Pr(),r="[object Arguments]";function n(o){return t(o)&&e(o)==r}return Zo=n,Zo}var Jo,Nd;function Qt(){if(Nd)return Jo;Nd=1;var e=hw(),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 Jo=i,Jo}var Yo,$d;function Ke(){if($d)return Yo;$d=1;var e=Array.isArray;return Yo=e,Yo}var Pt={exports:{}},Xo,Ld;function pw(){if(Ld)return Xo;Ld=1;function e(){return!1}return Xo=e,Xo}Pt.exports;var Fd;function bt(){return Fd||(Fd=1,(function(e,t){var r=Sr(),n=pw(),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})(Pt,Pt.exports)),Pt.exports}var Qo,Bd;function An(){if(Bd)return Qo;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 Qo=r,Qo}var ei,Dd;function zu(){if(Dd)return ei;Dd=1;var e=9007199254740991;function t(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return ei=t,ei}var ri,zd;function gw(){if(zd)return ri;zd=1;var e=et(),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]",b="[object String]",y="[object WeakMap]",m="[object ArrayBuffer]",x="[object DataView]",g="[object Float32Array]",w="[object Float64Array]",v="[object Int8Array]",_="[object Int16Array]",C="[object Int32Array]",S="[object Uint8Array]",T="[object Uint8ClampedArray]",k="[object Uint16Array]",j="[object Uint32Array]",P={};P[g]=P[w]=P[v]=P[_]=P[C]=P[S]=P[T]=P[k]=P[j]=!0,P[n]=P[o]=P[m]=P[i]=P[x]=P[a]=P[s]=P[u]=P[c]=P[l]=P[d]=P[f]=P[p]=P[b]=P[y]=!1;function R(I){return r(I)&&t(I.length)&&!!P[e(I)]}return ri=R,ri}var ti,Vd;function Tn(){if(Vd)return ti;Vd=1;function e(t){return function(r){return t(r)}}return ti=e,ti}var At={exports:{}};At.exports;var Wd;function Vu(){return Wd||(Wd=1,(function(e,t){var r=Ab(),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})(At,At.exports)),At.exports}var ni,Gd;function en(){if(Gd)return ni;Gd=1;var e=gw(),t=Tn(),r=Vu(),n=r&&r.isTypedArray,o=n?t(n):e;return ni=o,ni}var oi,Ud;function Ib(){if(Ud)return oi;Ud=1;var e=fw(),t=Qt(),r=Ke(),n=bt(),o=An(),i=en(),a=Object.prototype,s=a.hasOwnProperty;function u(c,l){var d=r(c),f=!d&&t(c),p=!d&&!f&&n(c),b=!d&&!f&&!p&&i(c),y=d||f||p||b,m=y?e(c.length,String):[],x=m.length;for(var g in c)(l||s.call(c,g))&&!(y&&(g=="length"||p&&(g=="offset"||g=="parent")||b&&(g=="buffer"||g=="byteLength"||g=="byteOffset")||o(g,x)))&&m.push(g);return m}return oi=u,oi}var ii,Hd;function On(){if(Hd)return ii;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 ii=t,ii}var ai,Kd;function Mb(){if(Kd)return ai;Kd=1;function e(t,r){return function(n){return t(r(n))}}return ai=e,ai}var si,Zd;function yw(){if(Zd)return si;Zd=1;var e=Mb(),t=e(Object.keys,Object);return si=t,si}var ci,Jd;function Wu(){if(Jd)return ci;Jd=1;var e=On(),t=yw(),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 ci=o,ci}var ui,Yd;function qr(){if(Yd)return ui;Yd=1;var e=Yt(),t=zu();function r(n){return n!=null&&t(n.length)&&!e(n)}return ui=r,ui}var li,Xd;function Gr(){if(Xd)return li;Xd=1;var e=Ib(),t=Wu(),r=qr();function n(o){return r(o)?e(o):t(o)}return li=n,li}var di,Qd;function bw(){if(Qd)return di;Qd=1;var e=Xt(),t=Gr();function r(n,o){return n&&e(o,t(o),n)}return di=r,di}var fi,ef;function mw(){if(ef)return fi;ef=1;function e(t){var r=[];if(t!=null)for(var n in Object(t))r.push(n);return r}return fi=e,fi}var hi,rf;function vw(){if(rf)return hi;rf=1;var e=mr(),t=On(),r=mw(),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 hi=i,hi}var pi,tf;function tt(){if(tf)return pi;tf=1;var e=Ib(),t=vw(),r=qr();function n(o){return r(o)?e(o,!0):t(o)}return pi=n,pi}var gi,nf;function xw(){if(nf)return gi;nf=1;var e=Xt(),t=tt();function r(n,o){return n&&e(o,t(o),n)}return gi=r,gi}var Tt={exports:{}};Tt.exports;var of;function qb(){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})(Tt,Tt.exports)),Tt.exports}var yi,af;function Nb(){if(af)return yi;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 yi=e,yi}var bi,sf;function $b(){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 mi,cf;function Lb(){if(cf)return mi;cf=1;function e(){return[]}return mi=e,mi}var vi,uf;function Gu(){if(uf)return vi;uf=1;var e=$b(),t=Lb(),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 vi=i,vi}var xi,lf;function ww(){if(lf)return xi;lf=1;var e=Xt(),t=Gu();function r(n,o){return e(n,t(n),o)}return xi=r,xi}var wi,df;function Uu(){if(df)return wi;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 wi=e,wi}var Ci,ff;function In(){if(ff)return Ci;ff=1;var e=Mb(),t=e(Object.getPrototypeOf,Object);return Ci=t,Ci}var _i,hf;function Fb(){if(hf)return _i;hf=1;var e=Uu(),t=In(),r=Gu(),n=Lb(),o=Object.getOwnPropertySymbols,i=o?function(a){for(var s=[];a;)e(s,r(a)),a=t(a);return s}:n;return _i=i,_i}var Si,pf;function Cw(){if(pf)return Si;pf=1;var e=Xt(),t=Fb();function r(n,o){return e(n,t(n),o)}return Si=r,Si}var ji,gf;function Bb(){if(gf)return ji;gf=1;var e=Uu(),t=Ke();function r(n,o,i){var a=o(n);return t(n)?a:e(a,i(n))}return ji=r,ji}var Ei,yf;function Db(){if(yf)return Ei;yf=1;var e=Bb(),t=Gu(),r=Gr();function n(o){return e(o,r,t)}return Ei=n,Ei}var Ri,bf;function _w(){if(bf)return Ri;bf=1;var e=Bb(),t=Fb(),r=tt();function n(o){return e(o,r,t)}return Ri=n,Ri}var ki,mf;function Sw(){if(mf)return ki;mf=1;var e=rt(),t=Sr(),r=e(t,"DataView");return ki=r,ki}var Pi,vf;function jw(){if(vf)return Pi;vf=1;var e=rt(),t=Sr(),r=e(t,"Promise");return Pi=r,Pi}var Ai,xf;function zb(){if(xf)return Ai;xf=1;var e=rt(),t=Sr(),r=e(t,"Set");return Ai=r,Ai}var Ti,wf;function Ew(){if(wf)return Ti;wf=1;var e=rt(),t=Sr(),r=e(t,"WeakMap");return Ti=r,Ti}var Oi,Cf;function mt(){if(Cf)return Oi;Cf=1;var e=Sw(),t=Fu(),r=jw(),n=zb(),o=Ew(),i=et(),a=Tb(),s="[object Map]",u="[object Object]",c="[object Promise]",l="[object Set]",d="[object WeakMap]",f="[object DataView]",p=a(e),b=a(t),y=a(r),m=a(n),x=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 v=i(w),_=v==u?w.constructor:void 0,C=_?a(_):"";if(C)switch(C){case p:return f;case b:return s;case y:return c;case m:return l;case x:return d}return v}),Oi=g,Oi}var Ii,_f;function Rw(){if(_f)return Ii;_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 Ii=r,Ii}var Mi,Sf;function Vb(){if(Sf)return Mi;Sf=1;var e=Sr(),t=e.Uint8Array;return Mi=t,Mi}var qi,jf;function Hu(){if(jf)return qi;jf=1;var e=Vb();function t(r){var n=new r.constructor(r.byteLength);return new e(n).set(new e(r)),n}return qi=t,qi}var Ni,Ef;function kw(){if(Ef)return Ni;Ef=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 Ni=t,Ni}var $i,Rf;function Pw(){if(Rf)return $i;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 $i=t,$i}var Li,kf;function Aw(){if(kf)return Li;kf=1;var e=yt(),t=e?e.prototype:void 0,r=t?t.valueOf:void 0;function n(o){return r?Object(r.call(o)):{}}return Li=n,Li}var Fi,Pf;function Wb(){if(Pf)return Fi;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 Fi=t,Fi}var Bi,Af;function Tw(){if(Af)return Bi;Af=1;var e=Hu(),t=kw(),r=Pw(),n=Aw(),o=Wb(),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]",b="[object DataView]",y="[object Float32Array]",m="[object Float64Array]",x="[object Int8Array]",g="[object Int16Array]",w="[object Int32Array]",v="[object Uint8Array]",_="[object Uint8ClampedArray]",C="[object Uint16Array]",S="[object Uint32Array]";function T(k,j,P){var R=k.constructor;switch(j){case p:return e(k);case i:case a:return new R(+k);case b:return t(k,P);case y:case m:case x:case g:case w:case v: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 Bi=T,Bi}var Di,Tf;function Gb(){if(Tf)return Di;Tf=1;var e=mr(),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 Di=r,Di}var zi,Of;function Ub(){if(Of)return zi;Of=1;var e=Gb(),t=In(),r=On();function n(o){return typeof o.constructor=="function"&&!r(o)?e(t(o)):{}}return zi=n,zi}var Vi,If;function Ow(){if(If)return Vi;If=1;var e=mt(),t=Pr(),r="[object Map]";function n(o){return t(o)&&e(o)==r}return Vi=n,Vi}var Wi,Mf;function Iw(){if(Mf)return Wi;Mf=1;var e=Ow(),t=Tn(),r=Vu(),n=r&&r.isMap,o=n?t(n):e;return Wi=o,Wi}var Gi,qf;function Mw(){if(qf)return Gi;qf=1;var e=mt(),t=Pr(),r="[object Set]";function n(o){return t(o)&&e(o)==r}return Gi=n,Gi}var Ui,Nf;function qw(){if(Nf)return Ui;Nf=1;var e=Mw(),t=Tn(),r=Vu(),n=r&&r.isSet,o=n?t(n):e;return Ui=o,Ui}var Hi,$f;function Hb(){if($f)return Hi;$f=1;var e=Rn(),t=Du(),r=Pn(),n=bw(),o=xw(),i=qb(),a=Nb(),s=ww(),u=Cw(),c=Db(),l=_w(),d=mt(),f=Rw(),p=Tw(),b=Ub(),y=Ke(),m=bt(),x=Iw(),g=mr(),w=qw(),v=Gr(),_=tt(),C=1,S=2,T=4,k="[object Arguments]",j="[object Array]",P="[object Boolean]",R="[object Date]",I="[object Error]",O="[object Function]",M="[object GeneratorFunction]",q="[object Map]",H="[object Number]",V="[object Object]",re="[object RegExp]",ce="[object Set]",le="[object String]",be="[object Symbol]",K="[object WeakMap]",N="[object ArrayBuffer]",B="[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]",de="[object Uint32Array]",fe={};fe[k]=fe[j]=fe[N]=fe[B]=fe[P]=fe[R]=fe[W]=fe[z]=fe[X]=fe[se]=fe[Q]=fe[q]=fe[H]=fe[V]=fe[re]=fe[ce]=fe[le]=fe[be]=fe[G]=fe[J]=fe[te]=fe[de]=!0,fe[I]=fe[O]=fe[K]=!1;function Ee(ge,We,me,Te,er,De){var Ne,He=We&C,rr=We&S,ze=We&T;if(me&&(Ne=er?me(ge,Te,er,De):me(ge)),Ne!==void 0)return Ne;if(!g(ge))return ge;var xr=y(ge);if(xr){if(Ne=f(ge),!He)return a(ge,Ne)}else{var Ze=d(ge),pr=Ze==O||Ze==M;if(m(ge))return i(ge,He);if(Ze==V||Ze==k||pr&&!er){if(Ne=rr||pr?{}:b(ge),!He)return rr?u(ge,o(Ne,ge)):s(ge,n(Ne,ge))}else{if(!fe[Ze])return er?ge:{};Ne=p(ge,Ze,He)}}De||(De=new e);var dr=De.get(ge);if(dr)return dr;De.set(ge,Ne),w(ge)?ge.forEach(function(or){Ne.add(Ee(or,We,me,or,ge,De))}):x(ge)&&ge.forEach(function(or,ar){Ne.set(ar,Ee(or,We,me,ar,ge,De))});var jr=ze?rr?l:c:rr?_:v,we=xr?void 0:jr(ge);return t(we||ge,function(or,ar){we&&(ar=or,or=ge[ar]),r(Ne,ar,Ee(or,We,me,ar,ge,De))}),Ne}return Hi=Ee,Hi}var Ki,Lf;function Nw(){if(Lf)return Ki;Lf=1;var e=Hb(),t=4;function r(n){return e(n,t)}return Ki=r,Ki}var Zi,Ff;function Ku(){if(Ff)return Zi;Ff=1;function e(t){return function(){return t}}return Zi=e,Zi}var Ji,Bf;function $w(){if(Bf)return Ji;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 Ji=e,Ji}var Yi,Df;function Zu(){if(Df)return Yi;Df=1;var e=$w(),t=e();return Yi=t,Yi}var Xi,zf;function Ju(){if(zf)return Xi;zf=1;var e=Zu(),t=Gr();function r(n,o){return n&&e(n,o,t)}return Xi=r,Xi}var Qi,Vf;function Lw(){if(Vf)return Qi;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 Qi=t,Qi}var ea,Wf;function Mn(){if(Wf)return ea;Wf=1;var e=Ju(),t=Lw(),r=t(e);return ea=r,ea}var ra,Gf;function nt(){if(Gf)return ra;Gf=1;function e(t){return t}return ra=e,ra}var ta,Uf;function Kb(){if(Uf)return ta;Uf=1;var e=nt();function t(r){return typeof r=="function"?r:e}return ta=t,ta}var na,Hf;function Zb(){if(Hf)return na;Hf=1;var e=Du(),t=Mn(),r=Kb(),n=Ke();function o(i,a){var s=n(i)?e:t;return s(i,r(a))}return na=o,na}var oa,Kf;function Jb(){return Kf||(Kf=1,oa=Zb()),oa}var ia,Zf;function Fw(){if(Zf)return ia;Zf=1;var e=Mn();function t(r,n){var o=[];return e(r,function(i,a,s){n(i,a,s)&&o.push(i)}),o}return ia=t,ia}var aa,Jf;function Bw(){if(Jf)return aa;Jf=1;var e="__lodash_hash_undefined__";function t(r){return this.__data__.set(r,e),this}return aa=t,aa}var sa,Yf;function Dw(){if(Yf)return sa;Yf=1;function e(t){return this.__data__.has(t)}return sa=e,sa}var ca,Xf;function Yb(){if(Xf)return ca;Xf=1;var e=Bu(),t=Bw(),r=Dw();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,ca=n,ca}var ua,Qf;function zw(){if(Qf)return ua;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 ua=e,ua}var la,eh;function Xb(){if(eh)return la;eh=1;function e(t,r){return t.has(r)}return la=e,la}var da,rh;function Qb(){if(rh)return da;rh=1;var e=Yb(),t=zw(),r=Xb(),n=1,o=2;function i(a,s,u,c,l,d){var f=u&n,p=a.length,b=s.length;if(p!=b&&!(f&&b>p))return!1;var y=d.get(a),m=d.get(s);if(y&&m)return y==s&&m==a;var x=-1,g=!0,w=u&o?new e:void 0;for(d.set(a,s),d.set(s,a);++x<p;){var v=a[x],_=s[x];if(c)var C=f?c(_,v,x,s,a,d):c(v,_,x,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)&&(v===S||l(v,S,u,c,d)))return w.push(T)})){g=!1;break}}else if(!(v===_||l(v,_,u,c,d))){g=!1;break}}return d.delete(a),d.delete(s),g}return da=i,da}var fa,th;function Vw(){if(th)return fa;th=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(o,i){n[++r]=[i,o]}),n}return fa=e,fa}var ha,nh;function Yu(){if(nh)return ha;nh=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(o){n[++r]=o}),n}return ha=e,ha}var pa,oh;function Ww(){if(oh)return pa;oh=1;var e=yt(),t=Vb(),r=gt(),n=Qb(),o=Vw(),i=Yu(),a=1,s=2,u="[object Boolean]",c="[object Date]",l="[object Error]",d="[object Map]",f="[object Number]",p="[object RegExp]",b="[object Set]",y="[object String]",m="[object Symbol]",x="[object ArrayBuffer]",g="[object DataView]",w=e?e.prototype:void 0,v=w?w.valueOf:void 0;function _(C,S,T,k,j,P,R){switch(T){case g:if(C.byteLength!=S.byteLength||C.byteOffset!=S.byteOffset)return!1;C=C.buffer,S=S.buffer;case x: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 b: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,j,P,R);return R.delete(C),q;case m:if(v)return v.call(C)==v.call(S)}return!1}return pa=_,pa}var ga,ih;function Gw(){if(ih)return ga;ih=1;var e=Db(),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,b=e(a),y=b.length;if(p!=y&&!d)return!1;for(var m=p;m--;){var x=f[m];if(!(d?x in a:n.call(a,x)))return!1}var g=l.get(i),w=l.get(a);if(g&&w)return g==a&&w==i;var v=!0;l.set(i,a),l.set(a,i);for(var _=d;++m<p;){x=f[m];var C=i[x],S=a[x];if(u)var T=d?u(S,C,x,a,i,l):u(C,S,x,i,a,l);if(!(T===void 0?C===S||c(C,S,s,u,l):T)){v=!1;break}_||(_=x=="constructor")}if(v&&!_){var k=i.constructor,j=a.constructor;k!=j&&"constructor"in i&&"constructor"in a&&!(typeof k=="function"&&k instanceof k&&typeof j=="function"&&j instanceof j)&&(v=!1)}return l.delete(i),l.delete(a),v}return ga=o,ga}var ya,ah;function Uw(){if(ah)return ya;ah=1;var e=Rn(),t=Qb(),r=Ww(),n=Gw(),o=mt(),i=Ke(),a=bt(),s=en(),u=1,c="[object Arguments]",l="[object Array]",d="[object Object]",f=Object.prototype,p=f.hasOwnProperty;function b(y,m,x,g,w,v){var _=i(y),C=i(m),S=_?l:o(y),T=C?l:o(m);S=S==c?d:S,T=T==c?d:T;var k=S==d,j=T==d,P=S==T;if(P&&a(y)){if(!a(m))return!1;_=!0,k=!1}if(P&&!k)return v||(v=new e),_||s(y)?t(y,m,x,g,w,v):r(y,m,S,x,g,w,v);if(!(x&u)){var R=k&&p.call(y,"__wrapped__"),I=j&&p.call(m,"__wrapped__");if(R||I){var O=R?y.value():y,M=I?m.value():m;return v||(v=new e),w(O,M,x,g,v)}}return P?(v||(v=new e),n(y,m,x,g,w,v)):!1}return ya=b,ya}var ba,sh;function em(){if(sh)return ba;sh=1;var e=Uw(),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 ma,ch;function Hw(){if(ch)return ma;ch=1;var e=Rn(),t=em(),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],b=i[p],y=f[1];if(d&&f[2]){if(b===void 0&&!(p in i))return!1}else{var m=new e;if(u)var x=u(b,y,p,i,a,m);if(!(x===void 0?t(y,b,r|n,u,m):x))return!1}}return!0}return ma=o,ma}var va,uh;function rm(){if(uh)return va;uh=1;var e=mr();function t(r){return r===r&&!e(r)}return va=t,va}var xa,lh;function Kw(){if(lh)return xa;lh=1;var e=rm(),t=Gr();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 xa=r,xa}var wa,dh;function tm(){if(dh)return wa;dh=1;function e(t,r){return function(n){return n==null?!1:n[t]===r&&(r!==void 0||t in Object(n))}}return wa=e,wa}var Ca,fh;function Zw(){if(fh)return Ca;fh=1;var e=Hw(),t=Kw(),r=tm();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 Ca=n,Ca}var _a,hh;function vt(){if(hh)return _a;hh=1;var e=et(),t=Pr(),r="[object Symbol]";function n(o){return typeof o=="symbol"||t(o)&&e(o)==r}return _a=n,_a}var Sa,ph;function Xu(){if(ph)return Sa;ph=1;var e=Ke(),t=vt(),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 Sa=o,Sa}var ja,gh;function Jw(){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 Ea,yh;function Yw(){if(yh)return Ea;yh=1;var e=Jw(),t=500;function r(n){var o=e(n,function(a){return i.size===t&&i.clear(),a}),i=o.cache;return o}return Ea=r,Ea}var Ra,bh;function Xw(){if(bh)return Ra;bh=1;var e=Yw(),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 Ra=n,Ra}var ka,mh;function qn(){if(mh)return ka;mh=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 ka=e,ka}var Pa,vh;function Qw(){if(vh)return Pa;vh=1;var e=yt(),t=qn(),r=Ke(),n=vt(),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 Pa=a,Pa}var Aa,xh;function nm(){if(xh)return Aa;xh=1;var e=Qw();function t(r){return r==null?"":e(r)}return Aa=t,Aa}var Ta,wh;function Nn(){if(wh)return Ta;wh=1;var e=Ke(),t=Xu(),r=Xw(),n=nm();function o(i,a){return e(i)?i:t(i,a)?[i]:r(n(i))}return Ta=o,Ta}var Oa,Ch;function rn(){if(Ch)return Oa;Ch=1;var e=vt();function t(r){if(typeof r=="string"||e(r))return r;var n=r+"";return n=="0"&&1/r==-1/0?"-0":n}return Oa=t,Oa}var Ia,_h;function $n(){if(_h)return Ia;_h=1;var e=Nn(),t=rn();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 Ia=r,Ia}var Ma,Sh;function e1(){if(Sh)return Ma;Sh=1;var e=$n();function t(r,n,o){var i=r==null?void 0:e(r,n);return i===void 0?o:i}return Ma=t,Ma}var qa,jh;function r1(){if(jh)return qa;jh=1;function e(t,r){return t!=null&&r in Object(t)}return qa=e,qa}var Na,Eh;function om(){if(Eh)return Na;Eh=1;var e=Nn(),t=Qt(),r=Ke(),n=An(),o=zu(),i=rn();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 Na=a,Na}var $a,Rh;function im(){if(Rh)return $a;Rh=1;var e=r1(),t=om();function r(n,o){return n!=null&&t(n,o,e)}return $a=r,$a}var La,kh;function t1(){if(kh)return La;kh=1;var e=em(),t=e1(),r=im(),n=Xu(),o=rm(),i=tm(),a=rn(),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 La=c,La}var Fa,Ph;function am(){if(Ph)return Fa;Ph=1;function e(t){return function(r){return r==null?void 0:r[t]}}return Fa=e,Fa}var Ba,Ah;function n1(){if(Ah)return Ba;Ah=1;var e=$n();function t(r){return function(n){return e(n,r)}}return Ba=t,Ba}var Da,Th;function o1(){if(Th)return Da;Th=1;var e=am(),t=n1(),r=Xu(),n=rn();function o(i){return r(i)?e(n(i)):t(i)}return Da=o,Da}var za,Oh;function Nr(){if(Oh)return za;Oh=1;var e=Zw(),t=t1(),r=nt(),n=Ke(),o=o1();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 za=i,za}var Va,Ih;function sm(){if(Ih)return Va;Ih=1;var e=$b(),t=Fw(),r=Nr(),n=Ke();function o(i,a){var s=n(i)?e:t;return s(i,r(a,3))}return Va=o,Va}var Wa,Mh;function i1(){if(Mh)return Wa;Mh=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n,o){return n!=null&&t.call(n,o)}return Wa=r,Wa}var Ga,qh;function cm(){if(qh)return Ga;qh=1;var e=i1(),t=om();function r(n,o){return n!=null&&t(n,o,e)}return Ga=r,Ga}var Ua,Nh;function a1(){if(Nh)return Ua;Nh=1;var e=Wu(),t=mt(),r=Qt(),n=Ke(),o=qr(),i=bt(),a=On(),s=en(),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 b=t(p);if(b==u||b==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 Ua=f,Ua}var Ha,$h;function um(){if($h)return Ha;$h=1;function e(t){return t===void 0}return Ha=e,Ha}var Ka,Lh;function lm(){if(Lh)return Ka;Lh=1;var e=Mn(),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 Ka=r,Ka}var Za,Fh;function dm(){if(Fh)return Za;Fh=1;var e=qn(),t=Nr(),r=lm(),n=Ke();function o(i,a){var s=n(i)?e:r;return s(i,t(a,3))}return Za=o,Za}var Ja,Bh;function s1(){if(Bh)return Ja;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 Ja=e,Ja}var Ya,Dh;function c1(){if(Dh)return Ya;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 Ya=e,Ya}var Xa,zh;function fm(){if(zh)return Xa;zh=1;var e=s1(),t=Mn(),r=Nr(),n=c1(),o=Ke();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 Xa=i,Xa}var Qa,Vh;function u1(){if(Vh)return Qa;Vh=1;var e=et(),t=Ke(),r=Pr(),n="[object String]";function o(i){return typeof i=="string"||!t(i)&&r(i)&&e(i)==n}return Qa=o,Qa}var es,Wh;function l1(){if(Wh)return es;Wh=1;var e=am(),t=e("length");return es=t,es}var rs,Gh;function d1(){if(Gh)return rs;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 rs=u,rs}var ts,Uh;function f1(){if(Uh)return ts;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",b=c+"?",y="["+i+"]?",m="(?:"+p+"(?:"+[l,d,f].join("|")+")"+y+b+")*",x=y+b+m,g="(?:"+[l+s+"?",s,d,f,a].join("|")+")",w=RegExp(u+"(?="+u+")|"+g+x,"g");function v(_){for(var C=w.lastIndex=0;w.test(_);)++C;return C}return ts=v,ts}var ns,Hh;function h1(){if(Hh)return ns;Hh=1;var e=l1(),t=d1(),r=f1();function n(o){return t(o)?r(o):e(o)}return ns=n,ns}var os,Kh;function p1(){if(Kh)return os;Kh=1;var e=Wu(),t=mt(),r=qr(),n=u1(),o=h1(),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 os=s,os}var is,Zh;function g1(){if(Zh)return is;Zh=1;var e=Du(),t=Gb(),r=Ju(),n=Nr(),o=In(),i=Ke(),a=bt(),s=Yt(),u=mr(),c=en();function l(d,f,p){var b=i(d),y=b||a(d)||c(d);if(f=n(f,4),p==null){var m=d&&d.constructor;y?p=b?new m:[]:u(d)?p=s(m)?t(o(d)):{}:p={}}return(y?e:r)(d,function(x,g,w){return f(p,x,g,w)}),p}return is=l,is}var as,Jh;function y1(){if(Jh)return as;Jh=1;var e=yt(),t=Qt(),r=Ke(),n=e?e.isConcatSpreadable:void 0;function o(i){return r(i)||t(i)||!!(n&&i&&i[n])}return as=o,as}var ss,Yh;function Qu(){if(Yh)return ss;Yh=1;var e=Uu(),t=y1();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 ss=r,ss}var cs,Xh;function b1(){if(Xh)return cs;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 cs=e,cs}var us,Qh;function hm(){if(Qh)return us;Qh=1;var e=b1(),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 us=r,us}var ls,ep;function m1(){if(ep)return ls;ep=1;var e=Ku(),t=Ob(),r=nt(),n=t?function(o,i){return t(o,"toString",{configurable:!0,enumerable:!1,value:e(i),writable:!0})}:r;return ls=n,ls}var ds,rp;function v1(){if(rp)return ds;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 ds=n,ds}var fs,tp;function pm(){if(tp)return fs;tp=1;var e=m1(),t=v1(),r=t(e);return fs=r,fs}var hs,np;function Ln(){if(np)return hs;np=1;var e=nt(),t=hm(),r=pm();function n(o,i){return r(t(o,i,e),o+"")}return hs=n,hs}var ps,op;function gm(){if(op)return ps;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 ps=e,ps}var gs,ip;function x1(){if(ip)return gs;ip=1;function e(t){return t!==t}return gs=e,gs}var ys,ap;function w1(){if(ap)return ys;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 ys=e,ys}var bs,sp;function C1(){if(sp)return bs;sp=1;var e=gm(),t=x1(),r=w1();function n(o,i,a){return i===i?r(o,i,a):e(o,t,a)}return bs=n,bs}var ms,cp;function _1(){if(cp)return ms;cp=1;var e=C1();function t(r,n){var o=r==null?0:r.length;return!!o&&e(r,n,0)>-1}return ms=t,ms}var vs,up;function S1(){if(up)return vs;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 vs=e,vs}var xs,lp;function j1(){if(lp)return xs;lp=1;function e(){}return xs=e,xs}var ws,dp;function E1(){if(dp)return ws;dp=1;var e=zb(),t=j1(),r=Yu(),n=1/0,o=e&&1/r(new e([,-0]))[1]==n?function(i){return new e(i)}:t;return ws=o,ws}var Cs,fp;function R1(){if(fp)return Cs;fp=1;var e=Yb(),t=_1(),r=S1(),n=Xb(),o=E1(),i=Yu(),a=200;function s(u,c,l){var d=-1,f=t,p=u.length,b=!0,y=[],m=y;if(l)b=!1,f=r;else if(p>=a){var x=c?null:o(u);if(x)return i(x);b=!1,f=n,m=new e}else m=c?[]:y;e:for(;++d<p;){var g=u[d],w=c?c(g):g;if(g=l||g!==0?g:0,b&&w===w){for(var v=m.length;v--;)if(m[v]===w)continue e;c&&m.push(w),y.push(g)}else f(m,w,l)||(m!==y&&m.push(w),y.push(g))}return y}return Cs=s,Cs}var _s,hp;function ym(){if(hp)return _s;hp=1;var e=qr(),t=Pr();function r(n){return t(n)&&e(n)}return _s=r,_s}var Ss,pp;function k1(){if(pp)return Ss;pp=1;var e=Qu(),t=Ln(),r=R1(),n=ym(),o=t(function(i){return r(e(i,1,n,!0))});return Ss=o,Ss}var js,gp;function P1(){if(gp)return js;gp=1;var e=qn();function t(r,n){return e(n,function(o){return r[o]})}return js=t,js}var Es,yp;function bm(){if(yp)return Es;yp=1;var e=P1(),t=Gr();function r(n){return n==null?[]:e(n,t(n))}return Es=r,Es}var Rs,bp;function vr(){if(bp)return Rs;bp=1;var e;if(typeof Lu=="function")try{e={clone:Nw(),constant:Ku(),each:Jb(),filter:sm(),has:cm(),isArray:Ke(),isEmpty:a1(),isFunction:Yt(),isUndefined:um(),keys:Gr(),map:dm(),reduce:fm(),size:p1(),transform:g1(),union:k1(),values:bm()}}catch{}return e||(e=window._),Rs=e,Rs}var ks,mp;function el(){if(mp)return ks;mp=1;var e=vr();ks=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(b){f.length>1?p.setNode(b,d):p.setNode(b)}),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,m){l(m)&&d.setNode(m,y)}),e.each(this._edgeObjs,function(y){d.hasNode(y.v)&&d.hasNode(y.w)&&d.setEdge(y,f.edge(y))});var p={};function b(y){var m=f.parent(y);return m===void 0||d.hasNode(m)?(p[y]=m,m):m in p?p[m]:b(m)}return this._isCompound&&e.each(d.nodes(),function(y){d.setParent(y,b(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(b,y){return p.length>1?f.setEdge(b,y,d):f.setEdge(b,y),y}),this},o.prototype.setEdge=function(){var l,d,f,p,b=!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],b=!0)):(l=y,d=arguments[1],f=arguments[3],arguments.length>2&&(p=arguments[2],b=!0)),l=""+l,d=""+d,e.isUndefined(f)||(f=""+f);var m=s(this._isDirected,l,d,f);if(e.has(this._edgeLabels,m))return b&&(this._edgeLabels[m]=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[m]=b?p:this._defaultEdgeLabelFn(l,d,f);var x=u(this._isDirected,l,d,f);return l=x.v,d=x.w,Object.freeze(x),this._edgeObjs[m]=x,i(this._preds[d],l),i(this._sucs[l],d),this._in[d][m]=x,this._out[l][m]=x,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),b=this._edgeObjs[p];return b&&(l=b.v,d=b.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(b){return b.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(b){return b.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 b=""+d,y=""+f;if(!l&&b>y){var m=b;b=y,y=m}return b+n+y+n+(e.isUndefined(p)?t:p)}function u(l,d,f,p){var b=""+d,y=""+f;if(!l&&b>y){var m=b;b=y,y=m}var x={v:b,w:y};return p&&(x.name=p),x}function c(l,d){return s(l,d.v,d.w,d.name)}return ks}var Ps,vp;function A1(){return vp||(vp=1,Ps="2.1.8"),Ps}var As,xp;function T1(){return xp||(xp=1,As={Graph:el(),version:A1()}),As}var Ts,wp;function O1(){if(wp)return Ts;wp=1;var e=vr(),t=el();Ts={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 Ts}var Os,Cp;function I1(){if(Cp)return Os;Cp=1;var e=vr();Os=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 Os}var Is,_p;function mm(){if(_p)return Is;_p=1;var e=vr();Is=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},Is}var Ms,Sp;function vm(){if(Sp)return Ms;Sp=1;var e=vr(),t=mm();Ms=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(b){var y=b.v!==d?b.v:b.w,m=c[y],x=s(b),g=f.distance+x;if(x<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+b+" Weight: "+x);g<m.distance&&(m.distance=g,m.predecessor=d,l.decrease(y,g))};for(i.nodes().forEach(function(b){var y=b===a?0:Number.POSITIVE_INFINITY;c[b]={distance:y},l.add(b,y)});l.size()>0&&(d=l.removeMin(),f=c[d],f.distance!==Number.POSITIVE_INFINITY);)u(d).forEach(p);return c}return Ms}var qs,jp;function M1(){if(jp)return qs;jp=1;var e=vm(),t=vr();qs=r;function r(n,o,i){return t.transform(n.nodes(),function(a,s){a[s]=e(n,s,o,i)},{})}return qs}var Ns,Ep;function xm(){if(Ep)return Ns;Ep=1;var e=vr();Ns=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 Ns}var $s,Rp;function q1(){if(Rp)return $s;Rp=1;var e=vr(),t=xm();$s=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 $s}var Ls,kp;function N1(){if(kp)return Ls;kp=1;var e=vr();Ls=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 b=f[c],y=l[p],m=f[p],x=b.distance+y.distance;x<m.distance&&(m.distance=x,m.predecessor=y.predecessor)})})}),s}return Ls}var Fs,Pp;function wm(){if(Pp)return Fs;Pp=1;var e=vr();Fs=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,Fs}var Bs,Ap;function $1(){if(Ap)return Bs;Ap=1;var e=wm();Bs=t;function t(r){try{e(r)}catch(n){if(n instanceof e.CycleException)return!1;throw n}return!0}return Bs}var Ds,Tp;function Cm(){if(Tp)return Ds;Tp=1;var e=vr();Ds=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 Ds}var zs,Op;function L1(){if(Op)return zs;Op=1;var e=Cm();zs=t;function t(r,n){return e(r,n,"post")}return zs}var Vs,Ip;function F1(){if(Ip)return Vs;Ip=1;var e=Cm();Vs=t;function t(r,n){return e(r,n,"pre")}return Vs}var Ws,Mp;function B1(){if(Mp)return Ws;Mp=1;var e=vr(),t=el(),r=mm();Ws=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,b=u.priority(p);if(b!==void 0){var y=i(f);y<b&&(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 Ws}var Gs,qp;function D1(){return qp||(qp=1,Gs={components:I1(),dijkstra:vm(),dijkstraAll:M1(),findCycles:q1(),floydWarshall:N1(),isAcyclic:$1(),postorder:L1(),preorder:F1(),prim:B1(),tarjan:xm(),topsort:wm()}),Gs}var Us,Np;function z1(){if(Np)return Us;Np=1;var e=T1();return Us={Graph:e.Graph,json:O1(),alg:D1(),version:e.version},Us}var Hs,$p;function _r(){if($p)return Hs;$p=1;var e;if(typeof Lu=="function")try{e=z1()}catch{}return e||(e=window.graphlib),Hs=e,Hs}var Ks,Lp;function V1(){if(Lp)return Ks;Lp=1;var e=Hb(),t=1,r=4;function n(o){return e(o,t|r)}return Ks=n,Ks}var Zs,Fp;function Fn(){if(Fp)return Zs;Fp=1;var e=gt(),t=qr(),r=An(),n=mr();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 Zs=o,Zs}var Js,Bp;function W1(){if(Bp)return Js;Bp=1;var e=Ln(),t=gt(),r=Fn(),n=tt(),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),b=-1,y=p.length;++b<y;){var m=p[b],x=s[m];(x===void 0||t(x,o[m])&&!i.call(s,m))&&(s[m]=f[m])}return s});return Js=a,Js}var Ys,Dp;function G1(){if(Dp)return Ys;Dp=1;var e=Nr(),t=qr(),r=Gr();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 Ys=n,Ys}var Xs,zp;function U1(){if(zp)return Xs;zp=1;var e=/\s/;function t(r){for(var n=r.length;n--&&e.test(r.charAt(n)););return n}return Xs=t,Xs}var Qs,Vp;function H1(){if(Vp)return Qs;Vp=1;var e=U1(),t=/^\s+/;function r(n){return n&&n.slice(0,e(n)+1).replace(t,"")}return Qs=r,Qs}var ec,Wp;function K1(){if(Wp)return ec;Wp=1;var e=H1(),t=mr(),r=vt(),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 ec=u,ec}var rc,Gp;function _m(){if(Gp)return rc;Gp=1;var e=K1(),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 rc=n,rc}var tc,Up;function Z1(){if(Up)return tc;Up=1;var e=_m();function t(r){var n=e(r),o=n%1;return n===n?o?n-o:n:0}return tc=t,tc}var nc,Hp;function J1(){if(Hp)return nc;Hp=1;var e=gm(),t=Nr(),r=Z1(),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 nc=o,nc}var oc,Kp;function Y1(){if(Kp)return oc;Kp=1;var e=G1(),t=J1(),r=e(t);return oc=r,oc}var ic,Zp;function Sm(){if(Zp)return ic;Zp=1;var e=Qu();function t(r){var n=r==null?0:r.length;return n?e(r,1):[]}return ic=t,ic}var ac,Jp;function X1(){if(Jp)return ac;Jp=1;var e=Zu(),t=Kb(),r=tt();function n(o,i){return o==null?o:e(o,t(i),r)}return ac=n,ac}var sc,Yp;function Q1(){if(Yp)return sc;Yp=1;function e(t){var r=t==null?0:t.length;return r?t[r-1]:void 0}return sc=e,sc}var cc,Xp;function eC(){if(Xp)return cc;Xp=1;var e=kn(),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 cc=n,cc}var uc,Qp;function rl(){if(Qp)return uc;Qp=1;var e=vt();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 uc=t,uc}var lc,eg;function rC(){if(eg)return lc;eg=1;function e(t,r){return t>r}return lc=e,lc}var dc,rg;function tC(){if(rg)return dc;rg=1;var e=rl(),t=rC(),r=nt();function n(o){return o&&o.length?e(o,r,t):void 0}return dc=n,dc}var fc,tg;function jm(){if(tg)return fc;tg=1;var e=kn(),t=gt();function r(n,o,i){(i!==void 0&&!t(n[o],i)||i===void 0&&!(o in n))&&e(n,o,i)}return fc=r,fc}var hc,ng;function nC(){if(ng)return hc;ng=1;var e=et(),t=In(),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 hc=c,hc}var pc,og;function Em(){if(og)return pc;og=1;function e(t,r){if(!(r==="constructor"&&typeof t[r]=="function")&&r!="__proto__")return t[r]}return pc=e,pc}var gc,ig;function oC(){if(ig)return gc;ig=1;var e=Xt(),t=tt();function r(n){return e(n,t(n))}return gc=r,gc}var yc,ag;function iC(){if(ag)return yc;ag=1;var e=jm(),t=qb(),r=Wb(),n=Nb(),o=Ub(),i=Qt(),a=Ke(),s=ym(),u=bt(),c=Yt(),l=mr(),d=nC(),f=en(),p=Em(),b=oC();function y(m,x,g,w,v,_,C){var S=p(m,g),T=p(x,g),k=C.get(T);if(k){e(m,g,k);return}var j=_?_(S,T,g+"",m,x,C):void 0,P=j===void 0;if(P){var R=a(T),I=!R&&u(T),O=!R&&!I&&f(T);j=T,R||I||O?a(S)?j=S:s(S)?j=n(S):I?(P=!1,j=t(T,!0)):O?(P=!1,j=r(T,!0)):j=[]:d(T)||i(T)?(j=S,i(S)?j=b(S):(!l(S)||c(S))&&(j=o(T))):P=!1}P&&(C.set(T,j),v(j,T,w,_,C),C.delete(T)),e(m,g,j)}return yc=y,yc}var bc,sg;function aC(){if(sg)return bc;sg=1;var e=Rn(),t=jm(),r=Zu(),n=iC(),o=mr(),i=tt(),a=Em();function s(u,c,l,d,f){u!==c&&r(c,function(p,b){if(f||(f=new e),o(p))n(u,c,b,l,s,d,f);else{var y=d?d(a(u,b),p,b+"",u,c,f):void 0;y===void 0&&(y=p),t(u,b,y)}},i)}return bc=s,bc}var mc,cg;function sC(){if(cg)return mc;cg=1;var e=Ln(),t=Fn();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 mc=r,mc}var vc,ug;function cC(){if(ug)return vc;ug=1;var e=aC(),t=sC(),r=t(function(n,o,i){e(n,o,i)});return vc=r,vc}var xc,lg;function Rm(){if(lg)return xc;lg=1;function e(t,r){return t<r}return xc=e,xc}var wc,dg;function uC(){if(dg)return wc;dg=1;var e=rl(),t=Rm(),r=nt();function n(o){return o&&o.length?e(o,r,t):void 0}return wc=n,wc}var Cc,fg;function lC(){if(fg)return Cc;fg=1;var e=rl(),t=Nr(),r=Rm();function n(o,i){return o&&o.length?e(o,t(i,2),r):void 0}return Cc=n,Cc}var _c,hg;function dC(){if(hg)return _c;hg=1;var e=Sr(),t=function(){return e.Date.now()};return _c=t,_c}var Sc,pg;function fC(){if(pg)return Sc;pg=1;var e=Pn(),t=Nn(),r=An(),n=mr(),o=rn();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 b=o(s[l]),y=u;if(b==="__proto__"||b==="constructor"||b==="prototype")return a;if(l!=f){var m=p[b];y=c?c(m,b,p):void 0,y===void 0&&(y=n(m)?m:r(s[l+1])?[]:{})}e(p,b,y),p=p[b]}return a}return Sc=i,Sc}var jc,gg;function hC(){if(gg)return jc;gg=1;var e=$n(),t=fC(),r=Nn();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 Ec,yg;function pC(){if(yg)return Ec;yg=1;var e=hC(),t=im();function r(n,o){return e(n,o,function(i,a){return t(n,a)})}return Ec=r,Ec}var Rc,bg;function gC(){if(bg)return Rc;bg=1;var e=Sm(),t=hm(),r=pm();function n(o){return r(t(o,void 0,e),o+"")}return Rc=n,Rc}var kc,mg;function yC(){if(mg)return kc;mg=1;var e=pC(),t=gC(),r=t(function(n,o){return n==null?{}:e(n,o)});return kc=r,kc}var Pc,vg;function bC(){if(vg)return Pc;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 Pc=r,Pc}var Ac,xg;function mC(){if(xg)return Ac;xg=1;var e=bC(),t=Fn(),r=_m();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 Ac=n,Ac}var Tc,wg;function vC(){if(wg)return Tc;wg=1;var e=mC(),t=e();return Tc=t,Tc}var Oc,Cg;function xC(){if(Cg)return Oc;Cg=1;function e(t,r){var n=t.length;for(t.sort(r);n--;)t[n]=t[n].value;return t}return Oc=e,Oc}var Ic,_g;function wC(){if(_g)return Ic;_g=1;var e=vt();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 Ic=t,Ic}var Mc,Sg;function CC(){if(Sg)return Mc;Sg=1;var e=wC();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 Mc=t,Mc}var qc,jg;function _C(){if(jg)return qc;jg=1;var e=qn(),t=$n(),r=Nr(),n=lm(),o=xC(),i=Tn(),a=CC(),s=nt(),u=Ke();function c(l,d,f){d.length?d=e(d,function(y){return u(y)?function(m){return t(m,y.length===1?y[0]:y)}:y}):d=[s];var p=-1;d=e(d,i(r));var b=n(l,function(y,m,x){var g=e(d,function(w){return w(y)});return{criteria:g,index:++p,value:y}});return o(b,function(y,m){return a(y,m,f)})}return qc=c,qc}var Nc,Eg;function SC(){if(Eg)return Nc;Eg=1;var e=Qu(),t=_C(),r=Ln(),n=Fn(),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 Nc=o,Nc}var $c,Rg;function jC(){if(Rg)return $c;Rg=1;var e=nm(),t=0;function r(n){var o=++t;return e(n)+o}return $c=r,$c}var Lc,kg;function EC(){if(kg)return Lc;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 Lc=e,Lc}var Fc,Pg;function RC(){if(Pg)return Fc;Pg=1;var e=Pn(),t=EC();function r(n,o){return t(n||[],o||[],e)}return Fc=r,Fc}var Bc,Ag;function Be(){if(Ag)return Bc;Ag=1;var e;if(typeof Lu=="function")try{e={cloneDeep:V1(),constant:Ku(),defaults:W1(),each:Jb(),filter:sm(),find:Y1(),flatten:Sm(),forEach:Zb(),forIn:X1(),has:cm(),isUndefined:um(),last:Q1(),map:dm(),mapValues:eC(),max:tC(),merge:cC(),min:uC(),minBy:lC(),now:dC(),pick:yC(),range:vC(),reduce:fm(),sortBy:SC(),uniqueId:jC(),values:bm(),zipObject:RC()}}catch{}return e||(e=window._),Bc=e,Bc}var Dc,Tg;function kC(){if(Tg)return Dc;Tg=1,Dc=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 Dc}var zc,Og;function PC(){if(Og)return zc;Og=1;var e=Be(),t=_r().Graph,r=kC();zc=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],b=l[0],y;c.nodeCount();){for(;y=b.dequeue();)a(c,l,d,y);for(;y=p.dequeue();)a(c,l,d,y);if(c.nodeCount()){for(var m=l.length-2;m>0;--m)if(y=l[m].dequeue(),y){f=f.concat(a(c,l,d,y,!0));break}}}return f}function a(c,l,d,f,p){var b=p?[]:void 0;return e.forEach(c.inEdges(f.v),function(y){var m=c.edge(y),x=c.node(y.v);p&&b.push({v:y.v,w:y.w}),x.out-=m,u(l,d,x)}),e.forEach(c.outEdges(f.v),function(y){var m=c.edge(y),x=y.w,g=c.node(x);g.in-=m,u(l,d,g)}),c.removeNode(f.v),b}function s(c,l){var d=new t,f=0,p=0;e.forEach(c.nodes(),function(m){d.setNode(m,{v:m,in:0,out:0})}),e.forEach(c.edges(),function(m){var x=d.edge(m.v,m.w)||0,g=l(m),w=x+g;d.setEdge(m.v,m.w,w),p=Math.max(p,d.node(m.v).out+=g),f=Math.max(f,d.node(m.w).in+=g)});var b=e.range(p+f+3).map(function(){return new r}),y=f+1;return e.forEach(d.nodes(),function(m){u(b,y,d.node(m))}),{graph:d,buckets:b,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 zc}var Vc,Ig;function AC(){if(Ig)return Vc;Ig=1;var e=Be(),t=PC();Vc={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 Vc}var Wc,Mg;function lr(){if(Mg)return Wc;Mg=1;var e=Be(),t=_r().Graph;Wc={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:b,notime:y};function r(m,x,g,w){var v;do v=e.uniqueId(w);while(m.hasNode(v));return g.dummy=x,m.setNode(v,g),v}function n(m){var x=new t().setGraph(m.graph());return e.forEach(m.nodes(),function(g){x.setNode(g,m.node(g))}),e.forEach(m.edges(),function(g){var w=x.edge(g.v,g.w)||{weight:0,minlen:1},v=m.edge(g);x.setEdge(g.v,g.w,{weight:w.weight+v.weight,minlen:Math.max(w.minlen,v.minlen)})}),x}function o(m){var x=new t({multigraph:m.isMultigraph()}).setGraph(m.graph());return e.forEach(m.nodes(),function(g){m.children(g).length||x.setNode(g,m.node(g))}),e.forEach(m.edges(),function(g){x.setEdge(g,m.edge(g))}),x}function i(m){var x=e.map(m.nodes(),function(g){var w={};return e.forEach(m.outEdges(g),function(v){w[v.w]=(w[v.w]||0)+m.edge(v).weight}),w});return e.zipObject(m.nodes(),x)}function a(m){var x=e.map(m.nodes(),function(g){var w={};return e.forEach(m.inEdges(g),function(v){w[v.v]=(w[v.v]||0)+m.edge(v).weight}),w});return e.zipObject(m.nodes(),x)}function s(m,x){var g=m.x,w=m.y,v=x.x-g,_=x.y-w,C=m.width/2,S=m.height/2;if(!v&&!_)throw new Error("Not possible to find intersection inside of the rectangle");var T,k;return Math.abs(_)*C>Math.abs(v)*S?(_<0&&(S=-S),T=S*v/_,k=S):(v<0&&(C=-C),T=C,k=C*_/v),{x:g+T,y:w+k}}function u(m){var x=e.map(e.range(f(m)+1),function(){return[]});return e.forEach(m.nodes(),function(g){var w=m.node(g),v=w.rank;e.isUndefined(v)||(x[v][w.order]=g)}),x}function c(m){var x=e.min(e.map(m.nodes(),function(g){return m.node(g).rank}));e.forEach(m.nodes(),function(g){var w=m.node(g);e.has(w,"rank")&&(w.rank-=x)})}function l(m){var x=e.min(e.map(m.nodes(),function(_){return m.node(_).rank})),g=[];e.forEach(m.nodes(),function(_){var C=m.node(_).rank-x;g[C]||(g[C]=[]),g[C].push(_)});var w=0,v=m.graph().nodeRankFactor;e.forEach(g,function(_,C){e.isUndefined(_)&&C%v!==0?--w:w&&e.forEach(_,function(S){m.node(S).rank+=w})})}function d(m,x,g,w){var v={width:0,height:0};return arguments.length>=4&&(v.rank=g,v.order=w),r(m,"border",v,x)}function f(m){return e.max(e.map(m.nodes(),function(x){var g=m.node(x).rank;if(!e.isUndefined(g))return g}))}function p(m,x){var g={lhs:[],rhs:[]};return e.forEach(m,function(w){x(w)?g.lhs.push(w):g.rhs.push(w)}),g}function b(m,x){var g=e.now();try{return x()}finally{console.log(m+" time: "+(e.now()-g)+"ms")}}function y(m,x){return x()}return Wc}var Gc,qg;function TC(){if(qg)return Gc;qg=1;var e=Be(),t=lr();Gc={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 b,y,m;for(m=0,++u;u<l;++m,++u)f.points=[],y={width:0,height:0,edgeLabel:f,edgeObj:a,rank:u},b=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,b,{weight:f.weight},d),m===0&&i.graph().dummyChains.push(b),s=b;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 Gc}var Uc,Ng;function pn(){if(Ng)return Uc;Ng=1;var e=Be();Uc={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 Uc}var Hc,$g;function km(){if($g)return Hc;$g=1;var e=Be(),t=_r().Graph,r=pn().slack;Hc=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 Hc}var Kc,Lg;function OC(){if(Lg)return Kc;Lg=1;var e=Be(),t=km(),r=pn().slack,n=pn().longestPath,o=_r().alg.preorder,i=_r().alg.postorder,a=lr().simplify;Kc=s,s.initLowLimValues=d,s.initCutValues=u,s.calcCutValue=l,s.leaveEdge=p,s.enterEdge=b,s.exchangeEdges=y;function s(w){w=a(w),n(w);var v=t(w);d(v),u(v,w);for(var _,C;_=p(v);)C=b(v,w,_),y(v,w,_,C)}function u(w,v){var _=i(w,w.nodes());_=_.slice(0,_.length-1),e.forEach(_,function(C){c(w,v,C)})}function c(w,v,_){var C=w.node(_),S=C.parent;w.edge(_,S).cutvalue=l(w,v,_)}function l(w,v,_){var C=w.node(_),S=C.parent,T=!0,k=v.edge(_,S),j=0;return k||(T=!1,k=v.edge(S,_)),j=k.weight,e.forEach(v.nodeEdges(_),function(P){var R=P.v===_,I=R?P.w:P.v;if(I!==S){var O=R===T,M=v.edge(P).weight;if(j+=O?M:-M,x(w,_,I)){var q=w.edge(_,I).cutvalue;j+=O?-q:q}}}),j}function d(w,v){arguments.length<2&&(v=w.nodes()[0]),f(w,{},1,v)}function f(w,v,_,C,S){var T=_,k=w.node(C);return v[C]=!0,e.forEach(w.neighbors(C),function(j){e.has(v,j)||(_=f(w,v,_,j,C))}),k.low=T,k.lim=_++,S?k.parent=S:delete k.parent,_}function p(w){return e.find(w.edges(),function(v){return w.edge(v).cutvalue<0})}function b(w,v,_){var C=_.v,S=_.w;v.hasEdge(C,S)||(C=_.w,S=_.v);var T=w.node(C),k=w.node(S),j=T,P=!1;T.lim>k.lim&&(j=k,P=!0);var R=e.filter(v.edges(),function(I){return P===g(w,w.node(I.v),j)&&P!==g(w,w.node(I.w),j)});return e.minBy(R,function(I){return r(v,I)})}function y(w,v,_,C){var S=_.v,T=_.w;w.removeEdge(S,T),w.setEdge(C.v,C.w,{}),d(w),u(w,v),m(w,v)}function m(w,v){var _=e.find(w.nodes(),function(S){return!v.node(S).parent}),C=o(w,_);C=C.slice(1),e.forEach(C,function(S){var T=w.node(S).parent,k=v.edge(S,T),j=!1;k||(k=v.edge(T,S),j=!0),v.node(S).rank=v.node(T).rank+(j?k.minlen:-k.minlen)})}function x(w,v,_){return w.hasEdge(v,_)}function g(w,v,_){return _.low<=v.lim&&v.lim<=_.lim}return Kc}var Zc,Fg;function IC(){if(Fg)return Zc;Fg=1;var e=pn(),t=e.longestPath,r=km(),n=OC();Zc=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 Zc}var Jc,Bg;function MC(){if(Bg)return Jc;Bg=1;var e=Be();Jc=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],b=!0;a!==u.w;){if(s=o.node(a),b){for(;(p=l[f])!==d&&o.node(p).maxRank<s.rank;)f++;p===d&&(b=!1)}if(!b){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 Jc}var Yc,Dg;function qC(){if(Dg)return Yc;Dg=1;var e=Be(),t=lr();Yc={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 b=s.children(p);if(!b.length){p!==u&&s.setEdge(u,p,{weight:0,minlen:c});return}var y=t.addBorderNode(s,"_bt"),m=t.addBorderNode(s,"_bb"),x=s.node(p);s.setParent(y,p),x.borderTop=y,s.setParent(m,p),x.borderBottom=m,e.forEach(b,function(g){n(s,u,c,l,d,f,g);var w=s.node(g),v=w.borderTop?w.borderTop:g,_=w.borderBottom?w.borderBottom:g,C=w.borderTop?l:2*l,S=v!==_?1:d-f[p]+1;s.setEdge(y,v,{weight:C,minlen:S,nestingEdge:!0}),s.setEdge(_,m,{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 Yc}var Xc,zg;function NC(){if(zg)return Xc;zg=1;var e=Be(),t=lr();Xc=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 Xc}var Qc,Vg;function $C(){if(Vg)return Qc;Vg=1;var e=Be();Qc={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 Qc}var eu,Wg;function LC(){if(Wg)return eu;Wg=1;var e=Be();eu=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 eu}var ru,Gg;function FC(){if(Gg)return ru;Gg=1;var e=Be();ru=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 b=0;p>0;)p%2&&(b+=l[p+1]),p=p-1>>1,l[p]+=f.weight;d+=f.weight*b})),d}return ru}var tu,Ug;function BC(){if(Ug)return tu;Ug=1;var e=Be();tu=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 tu}var nu,Hg;function DC(){if(Hg)return nu;Hg=1;var e=Be();nu=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 nu}var ou,Kg;function zC(){if(Kg)return ou;Kg=1;var e=Be(),t=lr();ou=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 b={vs:e.flatten(l,!0)};return f&&(b.barycenter=d/f,b.weight=f),b}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 ou}var iu,Zg;function VC(){if(Zg)return iu;Zg=1;var e=Be(),t=BC(),r=DC(),n=zC();iu=o;function o(s,u,c,l){var d=s.children(u),f=s.node(u),p=f?f.borderLeft:void 0,b=f?f.borderRight:void 0,y={};p&&(d=e.filter(d,function(_){return _!==p&&_!==b}));var m=t(s,d);e.forEach(m,function(_){if(s.children(_.v).length){var C=o(s,_.v,c,l);y[_.v]=C,e.has(C,"barycenter")&&a(_,C)}});var x=r(m,c);i(x,y);var g=n(x,l);if(p&&(g.vs=e.flatten([p,g.vs,b],!0),s.predecessors(p).length)){var w=s.node(s.predecessors(p)[0]),v=s.node(s.predecessors(b)[0]);e.has(g,"barycenter")||(g.barycenter=0,g.weight=0),g.barycenter=(g.barycenter*g.weight+w.order+v.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 iu}var au,Jg;function WC(){if(Jg)return au;Jg=1;var e=Be(),t=_r().Graph;au=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,b=u.edge(p,c),y=e.isUndefined(b)?0:b.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 au}var su,Yg;function GC(){if(Yg)return su;Yg=1;var e=Be();su=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 su}var cu,Xg;function UC(){if(Xg)return cu;Xg=1;var e=Be(),t=LC(),r=FC(),n=VC(),o=WC(),i=GC(),a=_r().Graph,s=lr();cu=u;function u(f){var p=s.maxRank(f),b=c(f,e.range(1,p+1),"inEdges"),y=c(f,e.range(p-1,-1,-1),"outEdges"),m=t(f);d(f,m);for(var x=Number.POSITIVE_INFINITY,g,w=0,v=0;v<4;++w,++v){l(w%2?b:y,w%4>=2),m=s.buildLayerMatrix(f);var _=r(f,m);_<x&&(v=0,g=e.cloneDeep(m),x=_)}d(f,g)}function c(f,p,b){return e.map(p,function(y){return o(f,y,b)})}function l(f,p){var b=new a;e.forEach(f,function(y){var m=y.graph().root,x=n(y,m,b,p);e.forEach(x.vs,function(g,w){y.node(g).order=w}),i(y,b,x.vs)})}function d(f,p){e.forEach(p,function(b){e.forEach(b,function(y,m){f.node(y).order=m})})}return cu}var uu,Qg;function HC(){if(Qg)return uu;Qg=1;var e=Be(),t=_r().Graph,r=lr();uu={positionX:b,findType1Conflicts:n,findType2Conflicts:o,addConflict:a,hasConflict:s,verticalAlignment:u,horizontalCompaction:c,alignCoordinates:f,findSmallestWidthAlignment:d,balance:p};function n(x,g){var w={};function v(_,C){var S=0,T=0,k=_.length,j=e.last(C);return e.forEach(C,function(P,R){var I=i(x,P),O=I?x.node(I).order:k;(I||P===j)&&(e.forEach(C.slice(T,R+1),function(M){e.forEach(x.predecessors(M),function(q){var H=x.node(q),V=H.order;(V<S||O<V)&&!(H.dummy&&x.node(M).dummy)&&a(w,q,M)})}),T=R+1,S=O)}),C}return e.reduce(g,v),w}function o(x,g){var w={};function v(C,S,T,k,j){var P;e.forEach(e.range(S,T),function(R){P=C[R],x.node(P).dummy&&e.forEach(x.predecessors(P),function(I){var O=x.node(I);O.dummy&&(O.order<k||O.order>j)&&a(w,I,P)})})}function _(C,S){var T=-1,k,j=0;return e.forEach(S,function(P,R){if(x.node(P).dummy==="border"){var I=x.predecessors(P);I.length&&(k=x.node(I[0]).order,v(S,j,R,T,k),j=R,T=k)}v(S,j,S.length,k,C.length)}),S}return e.reduce(g,_),w}function i(x,g){if(x.node(g).dummy)return e.find(x.predecessors(g),function(w){return x.node(w).dummy})}function a(x,g,w){if(g>w){var v=g;g=w,w=v}var _=x[g];_||(x[g]=_={}),_[w]=!0}function s(x,g,w){if(g>w){var v=g;g=w,w=v}return e.has(x[g],w)}function u(x,g,w,v){var _={},C={},S={};return e.forEach(g,function(T){e.forEach(T,function(k,j){_[k]=k,C[k]=k,S[k]=j})}),e.forEach(g,function(T){var k=-1;e.forEach(T,function(j){var P=v(j);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[j]===j&&k<S[M]&&!s(w,j,M)&&(C[M]=j,C[j]=_[j]=_[M],k=S[M])}}})}),{root:_,align:C}}function c(x,g,w,v,_){var C={},S=l(x,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 j(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=x.node(R);I!==Number.POSITIVE_INFINITY&&O.borderType!==T&&(C[R]=Math.max(C[R],I))}return k(j,S.predecessors.bind(S)),k(P,S.successors.bind(S)),e.forEach(v,function(R){C[R]=C[w[R]]}),C}function l(x,g,w,v){var _=new t,C=x.graph(),S=y(C.nodesep,C.edgesep,v);return e.forEach(g,function(T){var k;e.forEach(T,function(j){var P=w[j];if(_.setNode(P),k){var R=w[k],I=_.edge(R,P);_.setEdge(R,P,Math.max(S(x,j,k),I||0))}k=j})}),_}function d(x,g){return e.minBy(e.values(g),function(w){var v=Number.NEGATIVE_INFINITY,_=Number.POSITIVE_INFINITY;return e.forIn(w,function(C,S){var T=m(x,S)/2;v=Math.max(C+T,v),_=Math.min(C-T,_)}),v-_})}function f(x,g){var w=e.values(g),v=e.min(w),_=e.max(w);e.forEach(["u","d"],function(C){e.forEach(["l","r"],function(S){var T=C+S,k=x[T],j;if(k!==g){var P=e.values(k);j=S==="l"?v-e.min(P):_-e.max(P),j&&(x[T]=e.mapValues(k,function(R){return R+j}))}})})}function p(x,g){return e.mapValues(x.ul,function(w,v){if(g)return x[g.toLowerCase()][v];var _=e.sortBy(e.map(x,v));return(_[1]+_[2])/2})}function b(x){var g=r.buildLayerMatrix(x),w=e.merge(n(x,g),o(x,g)),v={},_;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"?x.predecessors:x.successors).bind(x),j=u(x,_,w,k),P=c(x,_,j.root,j.align,T==="r");T==="r"&&(P=e.mapValues(P,function(R){return-R})),v[S+T]=P})});var C=d(x,v);return f(v,C),p(v,x.graph().align)}function y(x,g,w){return function(v,_,C){var S=v.node(_),T=v.node(C),k=0,j;if(k+=S.width/2,e.has(S,"labelpos"))switch(S.labelpos.toLowerCase()){case"l":j=-S.width/2;break;case"r":j=S.width/2;break}if(j&&(k+=w?j:-j),j=0,k+=(S.dummy?g:x)/2,k+=(T.dummy?g:x)/2,k+=T.width/2,e.has(T,"labelpos"))switch(T.labelpos.toLowerCase()){case"l":j=T.width/2;break;case"r":j=-T.width/2;break}return j&&(k+=w?j:-j),j=0,k}}function m(x,g){return x.node(g).width}return uu}var lu,ey;function KC(){if(ey)return lu;ey=1;var e=Be(),t=lr(),r=HC().positionX;lu=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 lu}var du,ry;function ZC(){if(ry)return du;ry=1;var e=Be(),t=AC(),r=TC(),n=IC(),o=lr().normalizeRanks,i=MC(),a=lr().removeEmptyRanks,s=qC(),u=NC(),c=$C(),l=UC(),d=KC(),f=lr(),p=_r().Graph;du=b;function b(N,B){var W=B&&B.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(){m(N,z)})})}function y(N,B){B(" makeSpaceForEdgeLabels",function(){j(N)}),B(" removeSelfEdges",function(){re(N)}),B(" acyclic",function(){t.run(N)}),B(" nestingGraph.run",function(){s.run(N)}),B(" rank",function(){n(f.asNonCompoundGraph(N))}),B(" injectEdgeLabelProxies",function(){P(N)}),B(" removeEmptyRanks",function(){a(N)}),B(" nestingGraph.cleanup",function(){s.cleanup(N)}),B(" normalizeRanks",function(){o(N)}),B(" assignRankMinMax",function(){R(N)}),B(" removeEdgeLabelProxies",function(){I(N)}),B(" normalize.run",function(){r.run(N)}),B(" parentDummyChains",function(){i(N)}),B(" addBorderSegments",function(){u(N)}),B(" order",function(){l(N)}),B(" insertSelfEdges",function(){ce(N)}),B(" adjustCoordinateSystem",function(){c.adjust(N)}),B(" position",function(){d(N)}),B(" positionSelfEdges",function(){le(N)}),B(" removeBorderNodes",function(){V(N)}),B(" normalize.undo",function(){r.undo(N)}),B(" fixupEdgeLabelCoords",function(){q(N)}),B(" undoCoordinateSystem",function(){c.undo(N)}),B(" translateGraph",function(){O(N)}),B(" assignNodeIntersects",function(){M(N)}),B(" reversePoints",function(){H(N)}),B(" acyclic.undo",function(){t.undo(N)})}function m(N,B){e.forEach(N.nodes(),function(W){var z=N.node(W),X=B.node(W);z&&(z.x=X.x,z.y=X.y,B.children(W).length&&(z.width=X.width,z.height=X.height))}),e.forEach(N.edges(),function(W){var z=N.edge(W),X=B.edge(W);z.points=X.points,e.has(X,"x")&&(z.x=X.x,z.y=X.y)}),N.graph().width=B.graph().width,N.graph().height=B.graph().height}var x=["nodesep","edgesep","ranksep","marginx","marginy"],g={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},w=["acyclicer","ranker","rankdir","align"],v=["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 B=new p({multigraph:!0,compound:!0}),W=K(N.graph());return B.setGraph(e.merge({},g,be(W,x),e.pick(W,w))),e.forEach(N.nodes(),function(z){var X=K(N.node(z));B.setNode(z,e.defaults(be(X,v),_)),B.setParent(z,N.parent(z))}),e.forEach(N.edges(),function(z){var X=K(N.edge(z));B.setEdge(z,e.merge({},S,be(X,C),e.pick(X,T)))}),B}function j(N){var B=N.graph();B.ranksep/=2,e.forEach(N.edges(),function(W){var z=N.edge(W);z.minlen*=2,z.labelpos.toLowerCase()!=="c"&&(B.rankdir==="TB"||B.rankdir==="BT"?z.width+=z.labeloffset:z.height+=z.labeloffset)})}function P(N){e.forEach(N.edges(),function(B){var W=N.edge(B);if(W.width&&W.height){var z=N.node(B.v),X=N.node(B.w),se={rank:(X.rank-z.rank)/2+z.rank,e:B};f.addDummyNode(N,"edge-proxy",se,"_ep")}})}function R(N){var B=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,B=e.max(B,z.maxRank))}),N.graph().maxRank=B}function I(N){e.forEach(N.nodes(),function(B){var W=N.node(B);W.dummy==="edge-proxy"&&(N.edge(W.e).labelRank=W.rank,N.removeNode(B))})}function O(N){var B=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 de=te.x,fe=te.y,Ee=te.width,ge=te.height;B=Math.min(B,de-Ee/2),W=Math.max(W,de+Ee/2),z=Math.min(z,fe-ge/2),X=Math.max(X,fe+ge/2)}e.forEach(N.nodes(),function(te){J(N.node(te))}),e.forEach(N.edges(),function(te){var de=N.edge(te);e.has(de,"x")&&J(de)}),B-=Q,z-=G,e.forEach(N.nodes(),function(te){var de=N.node(te);de.x-=B,de.y-=z}),e.forEach(N.edges(),function(te){var de=N.edge(te);e.forEach(de.points,function(fe){fe.x-=B,fe.y-=z}),e.has(de,"x")&&(de.x-=B),e.has(de,"y")&&(de.y-=z)}),se.width=W-B+Q,se.height=X-z+G}function M(N){e.forEach(N.edges(),function(B){var W=N.edge(B),z=N.node(B.v),X=N.node(B.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(B){var W=N.edge(B);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 H(N){e.forEach(N.edges(),function(B){var W=N.edge(B);W.reversed&&W.points.reverse()})}function V(N){e.forEach(N.nodes(),function(B){if(N.children(B).length){var W=N.node(B),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(B){N.node(B).dummy==="border"&&N.removeNode(B)})}function re(N){e.forEach(N.edges(),function(B){if(B.v===B.w){var W=N.node(B.v);W.selfEdges||(W.selfEdges=[]),W.selfEdges.push({e:B,label:N.edge(B)}),N.removeEdge(B)}})}function ce(N){var B=f.buildLayerMatrix(N);e.forEach(B,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 le(N){e.forEach(N.nodes(),function(B){var W=N.node(B);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(B),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 be(N,B){return e.mapValues(e.pick(N,B),Number)}function K(N){var B={};return e.forEach(N,function(W,z){B[z.toLowerCase()]=W}),B}return du}var fu,ty;function JC(){if(ty)return fu;ty=1;var e=Be(),t=lr(),r=_r().Graph;fu={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 fu}var hu,ny;function YC(){return ny||(ny=1,hu="0.8.5"),hu}var pu,oy;function XC(){return oy||(oy=1,pu={graphlib:_r(),layout:ZC(),debug:JC(),util:{time:lr().time,notime:lr().notime},version:YC()}),pu}var QC=XC();const iy=$0(QC);function e_(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=Rb(d.label,d.icon??((l=d.data)==null?void 0:l.icon),r.edgeLabelFontSize),p=r.rankDir==="LR"||r.rankDir==="RL",b=(f.width?f.width+2*Eb:0)+(d.connectorClearance??0);i.setEdge(d.source,d.target,{minlen:1,weight:1,...b?{width:p?b:Math.max(1,f.height),height:p?Math.max(1,f.height):b,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,b=-1/0;s.forEach(x=>{d=Math.min(d,x.x),f=Math.min(f,x.y),p=Math.max(p,x.x),b=Math.max(b,x.y)});const y=(d+p)/2,m=(f+b)/2;s.forEach((x,g)=>s.set(g,{x:y+(x.x-y)*u,y:m+(x.y-m)*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",b=r.rankDir==="RL"||r.rankDir==="BT"?-1:1,y=c==="leading"?-b:b,m=new Map;for(const x of e){const g=s.get(x.id);if(!g)continue;const w=g[f];m.set(w,Math.max(m.get(w)??0,x[p]))}for(const x of e){const g=s.get(x.id);if(!g)continue;const w=g[f],v=(m.get(w)-x[p])/2;s.set(x.id,{...g,[f]:w+y*v})}}return s}function r_(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 b of i.get(l)||[]){let y=c.get(b);if(!y){const m=t.get(b);if(!m)continue;const x=r.get(b)||{w:60,h:60};y={x1:m.x-x.w/2,y1:m.y-x.h/2,x2:m.x+x.w/2,y2:m.y+x.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 b=d.x2-d.x1,y=d.y2-d.y1;if(p.w>b){const m=(p.w-b)/2;d.x1-=m,d.x2+=m}if(p.h>y){const m=(p.h-y)/2;d.y1-=m,d.y2+=m}}c.set(l,d)}return c}function t_(e){const t=e.getBoundingClientRect(),r=t.height/e.offsetHeight;if(!Number.isFinite(r)||r<=0)return[];const n=Sb(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=wb(n?$t(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 n_({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:b=8,animationVariant:y,width:m=0,height:x=0,propertyMode:g,reversePorts:w,direction:v="LR",onPropertyRows:_,onSurface:C,children:S}){const T=E.useRef(null),[k,j]=E.useState([]),P=c??k,[R,I]=E.useState();return E.useLayoutEffect(()=>{const O=T.current;if(!O)return;const M=()=>{const V=Sb(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 H=O.querySelector("[data-flow-node-surface]");return H&&q.observe(H),()=>q.disconnect()},[e,S,C]),E.useLayoutEffect(()=>(i(e,T.current),()=>{i(e,null),C==null||C(e,void 0)}),[e,i,C]),E.useLayoutEffect(()=>{const O=T.current;if(!O)return;let M="";const q=()=>{const ce=t_(O),le=g?ce:ce.filter(K=>K.anchor),be=JSON.stringify(le);be!==M&&(M=be,j(le),_==null||_(e,le))};if(q(),!g&&!O.querySelector("[data-flow-port-side]"))return;const H=new ResizeObserver(q),V=()=>{H.disconnect(),H.observe(O),O.querySelectorAll("[data-flow-property]").forEach(ce=>H.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),()=>{H.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&&b>0&&m>0&&x>0&&h.jsx("svg",{className:"flow-sdk-node-animation","aria-hidden":"true",pointerEvents:"none",children:h.jsx(xb,{variant:y,x:((R==null?void 0:R.left)??0)+b/2,y:((R==null?void 0:R.top)??0)+b/2,width:((R==null?void 0:R.width)??m)-b,height:((R==null?void 0:R.height)??x)-b,radius:((R==null?void 0:R.radius)??0)-b/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:b})}),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:H=>H.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)+(v==="RL"?-36:v==="LR"?(R==null?void 0:R.width)??m:((R==null?void 0:R.width)??m)/2),top:((R==null?void 0:R.top)??0)+(v==="BT"?-36:v==="TB"?(R==null?void 0:R.height)??x:((R==null?void 0:R.height)??x)/2),transform:v==="BT"||v==="TB"?"translateX(-50%)":"translateY(-50%)"},onClick:O=>O.stopPropagation(),children:h.jsx(Z.PiPlusBold,{size:24})})]})}const o_=E.memo(n_);class i_{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 a_={LR:"rightward",RL:"leftward",TB:"downward",BT:"upward"},gu={w:60,h:60},ay=4,s_=30,sy=300,c_=500,u_=45,l_=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 d_(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:b,lineColor:y,drawMode:m,dragMode:x,multiSelect:g,isPerformanceMode:w}=e,[v,_]=E.useState(null),C=E.useMemo(()=>v?(v.mode==="connections"?ql:Pl)(v.id,t,r):null,[v,t,r]),S=i==="auto"||i==="properties",T=E.useMemo(()=>r.filter(A=>wu(A,i)&&(!C||C.has(A.source)&&C.has(A.target))),[r,i,C]),k=E.useMemo(()=>T0(t,r,i,a,C),[t,r,i,a,C]),j=E.useRef(k);j.current=k;const P=E.useRef(e);P.current=e;const R=E.useRef(null),I=E.useRef(null),O=E.useRef(null),M=E.useRef(null),q=E.useMemo(()=>new i_(p,d,f),[]);E.useEffect(()=>{q.minZoom=d,q.maxZoom=f},[q,d,f]);const H=E.useRef(new Map),V=E.useRef(new Map),re=E.useRef(new Map),ce=E.useRef(null),[le,be]=E.useState(new Map),K=E.useCallback((A,$)=>{be(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,B]=E.useState(new Map),W=E.useRef(N),z=E.useCallback((A,$)=>{B(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]=E.useState(()=>new Map),Q=E.useRef(X);Q.current=X;const G=E.useRef(new Map),J=E.useRef(!1),[te,de]=E.useState(0),fe=E.useRef(),Ee=E.useRef(),ge=E.useRef(null),We=E.useRef(),me=E.useRef(!1),Te=E.useRef(null),er=E.useRef(c),De=a&&(i==="properties"||!!C),Ne=E.useRef(De),[He,rr]=E.useState(!0),ze=E.useRef(null);ze.current=C;const xr=E.useRef(1);xr.current=(v==null?void 0:v.mode)==="connections"?1.25:1;const Ze=E.useRef(null),pr=E.useRef(t),dr=E.useRef([]),jr=E.useRef(!1),we=()=>{ge.current!==null&&cancelAnimationFrame(ge.current),ge.current=null,clearTimeout(We.current)},or=()=>{dr.current.length&&(jr.current=!0),!J.current&&P.current.fitOnInit!==!1&&(me.current=!0),clearTimeout(Ee.current),Ee.current=setTimeout(()=>{J.current=!0,de(A=>A+1)},c_)},ar=A=>{we();const $=new Map(Q.current),L=performance.now(),U=()=>{we(),se(A),or()},oe=he=>{const Re=Math.min(1,(he-L)/sy);if(Re>=1)return U();const Ae=l_(Re),ie=new Map;A.forEach((ae,ue)=>{const ye=$.get(ue);ie.set(ue,ye?{x:ye.x+(ae.x-ye.x)*Ae,y:ye.y+(ae.y-ye.y)*Ae}:ae)}),se(ie),ge.current=requestAnimationFrame(oe)};ge.current=requestAnimationFrame(oe),We.current=setTimeout(U,sy+100)},xt=()=>{const A=P.current,$=xr.current,L=j.current,U=L.nodes.map(he=>{const Re=H.current.get(he.id)||gu;return{id:he.id,parent:he.parent,width:Re.w,height:Re.h}});let oe;try{const he=A.compactPropertyLayout&&(A.edgeMode==="properties"||!!ze.current),Re=A.edgeMode!=="nodes"&&A.edgeMode!=="workflow",Ae=L.edges.map(ie=>({...ie,connectorClearance:he?Re&&(ie.sourceProperty!==void 0||ie.targetProperty!==void 0)?A0:P0:0}));oe=e_(U,Ae,{edgeLabelFontSize:A.edgeMode==="nodes"||A.edgeMode==="workflow"?jb:fn,rankDir:A.direction,compact:he,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(he){console.warn("[flow-sdk] layout failed",he);return}for(const[he,Re]of G.current)oe.has(he)?oe.set(he,Re):A.nodes.some(Ae=>Ae.id===he)||G.current.delete(he);J.current&&!A.isPerformanceMode?ar(oe):(we(),se(oe),or())},ne=E.useCallback(()=>{clearTimeout(Ee.current),clearTimeout(fe.current),fe.current=setTimeout(xt,P.current.layoutDebounce)},[]);E.useEffect(()=>{const A=new Map(pr.current.map($=>[$.id,$]));t.some($=>{var L;return((L=A.get($.id))==null?void 0:L.collapsed)===!0&&!$.collapsed})&&(dr.current=t.filter($=>!A.has($.id)).map($=>$.id)),pr.current=t,er.current!==c&&Q.current.size>0&&(J.current=!0,me.current=!1,clearTimeout(Ee.current)),er.current=c,Ne.current!==De&&(me.current=!Te.current),Ne.current=De,ne()},[t,r,k.nodes,k.edges,De,n,o,s,u,ne,c,l]),E.useEffect(()=>()=>{clearTimeout(fe.current),clearTimeout(Ee.current),we()},[]);const Fe=E.useCallback((A,$)=>{var L,U;if(!ce.current&&typeof ResizeObserver<"u"&&(ce.current=new ResizeObserver(oe=>{let he=!1;for(const Re of oe){const Ae=re.current.get(Re.target);if(!Ae)continue;const ie=Re.target,ae=ie.offsetWidth,ue=ie.offsetHeight;if(!ae&&!ue)continue;const ye=H.current.get(Ae);ye&&ye.w===ae&&ye.h===ue||(H.current.set(Ae,{w:ae,h:ue}),he=!0)}he&&ne()})),$){V.current.set(A,$),re.current.set($,A),(L=ce.current)==null||L.observe($);const oe=$.offsetWidth,he=$.offsetHeight;(oe||he)&&H.current.set(A,{w:oe,h:he})}else{const oe=V.current.get(A);oe&&((U=ce.current)==null||U.unobserve(oe),re.current.delete(oe)),V.current.delete(A),H.current.delete(A),W.current.has(A)&&z(A,[])}ne()},[ne,z]);E.useEffect(()=>()=>{var A;return(A=ce.current)==null?void 0:A.disconnect()},[]);const Je=E.useMemo(()=>{const A=new Map;for(const $ of t)$.label&&A.set($.id,$.label);return A},[t]),$e=E.useMemo(()=>r_(k.nodes,X,H.current,A=>b(A).padding,A=>{const $=Je.get(A);if(!$)return;const L=b(A);return{w:Cn($,`bold ${L.fontSize}px ${Qr}`)+2*u_,h:0}}),[k.nodes,X,b,Je]),Xe=E.useRef($e);Xe.current=$e;const Y=E.useCallback(A=>{const $=Xe.current.get(A);if($)return g0($);const L=Q.current.get(A);if(!L)return;const U=H.current.get(A)||gu;return{x:L.x,y:L.y,w:U.w,h:U.h}},[]),D=E.useMemo(()=>{const A=new Map;for(const $ of t){const L=Y($.id);L&&A.set($.id,L)}return S0(N,A,le,r,n)},[N,t,X,$e,le,r,n,Y]);W.current=D;const ee=(A,$)=>{var oe;if(!S||$===void 0)return;const L=(oe=D.get(A))==null?void 0:oe.find(he=>he.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,he;if($===void 0)return;const L=(he=(oe=D.get(A))==null?void 0:oe.find(Re=>Re.property===$))==null?void 0:he.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},_e=(A,$)=>{const L=Y(A),U=le.get(A);return L&&U&&!$e.has(A)&&ee(A,$)===void 0?$t(L,U):L},Se=()=>{const A=[];Q.current.forEach(($,L)=>{if(Xe.current.has(L))return;const U=H.current.get(L)||gu;A.push(at({x:$.x,y:$.y,w:U.w,h:U.h}))}),Xe.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 Jn(A)},Ge=()=>{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(${$})`)};E.useEffect(()=>{Ge();let A=null,$;const L=q.onChange(()=>{Ge();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,he;A=null,(he=(oe=P.current).onViewportChange)==null||he.call(oe,q.state)}))});return()=>{L(),clearTimeout($),A!==null&&cancelAnimationFrame(A)}},[]),E.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]),E.useEffect(()=>{if(jr.current){jr.current=!1;const $=dr.current.flatMap(U=>{const oe=Y(U);return oe?[at(oe)]:[]});dr.current=[];const L=Jn($);if(L){me.current=!1,q.center(L,P.current.animateViewport);return}}if(!me.current)return;me.current=!1;const A=Se();A&&q.fit(A,50,P.current.animateViewport)},[X]);const Le=E.useMemo(()=>{const A=ie=>Pl(ie,P.current.nodes,P.current.edges),$=(ie,ae=50,ue=P.current.animateViewport)=>{const ye=Jn([...ie].flatMap(sr=>{const wt=Y(sr);return wt?[at(wt)]:[]}));ye&&(me.current=!1,q.fit(ye,Number.isFinite(ae)?Math.max(0,ae):50,ue))},L=(ie,ae,ue,ye)=>{if(!Y(ie))return;const sr=ae==="connections"?oe(ie):A(ie);Ze.current||(Ze.current={pan:{...q.pan},zoom:q.zoom}),ze.current=sr,P.current.compactPropertyLayout&&(me.current=!1,Te.current=()=>$(ze.current??sr,ue,ye)),_({id:ie,mode:ae}),P.current.compactPropertyLayout||$(sr,ue,ye)},U=ie=>{Te.current?Te.current=ie:ie()},oe=ie=>ql(ie,P.current.nodes,P.current.edges),he=(ie=>{if(ie===void 0)return q.zoom;q.set(void 0,ie)}),Re=(ie=>{if(ie===void 0)return q.pan;q.set(ie)}),Ae=(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:he,pan:Re,setEdgesVisible:rr,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&&!!ze.current;ze.current=null,_(null);const ue=Ze.current;Ze.current=null,ae?Te.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=Se();ue&&q.fit(ue,ie,ae)})},centerAndFit:(ie=0,ae=P.current.animateViewport)=>{U(()=>{const ue=Se();ue&&q.fit(ue,ie,ae)})},center:(ie=P.current.animateViewport)=>{const ae=Se();ae&&q.center(ae,ie)},clientToModel:(ie,ae)=>q.renderedToModel(Ae(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)}},[]);E.useEffect(()=>{var A,$;return($=(A=P.current).onInit)==null||$.call(A,Le),()=>q.cancelAnimation()},[Le]),E.useEffect(()=>{var A,$;if(te>0){const L=Te.current;Te.current=null,L==null||L(),($=(A=P.current).onLayoutComplete)==null||$.call(A,Le)}},[Le,te]);const ke=E.useRef(null),Me=E.useRef(new Map),gr=E.useRef(!1),[Ye,yr]=E.useState(null),[Oe,wr]=E.useState(null),$r=A=>{const $=R.current.getBoundingClientRect();return{x:A.clientX-$.left,y:A.clientY-$.top}},zn=(A,$)=>{const L=P.current.nodes;for(let U=L.length-1;U>=0;U--){const oe=L[U].id;if(!st(oe,P.current.edges,P.current.edgeMode)||ze.current&&!ze.current.has(oe)||oe===$||Xe.current.has(oe))continue;const he=Y(oe);if(he&&Al(A,at(he)))return oe}for(const[U,oe]of Xe.current)if(st(U,P.current.edges,P.current.edgeMode)&&!(ze.current&&!ze.current.has(U))&&U!==$&&Al(A,oe))return U;return null},Vn=(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 he of[...P.current.nodes].reverse()){if(!st(he.id,P.current.edges,P.current.edgeMode)||ze.current&&!ze.current.has(he.id))continue;const Re=Y(he.id),Ae=W.current.get(he.id);if(!Re||!Ae||Xe.current.has(he.id))continue;const ie=Re.x+($==="source"!==L?1:-1)*Re.w/2;for(const ae of Ae){if(ae.role&&ae.role!==$)continue;const ue=Re.y-Re.h/2+ae.top,ye=Math.hypot(A.x-(ae.anchor?Re.x-Re.w/2+ae.anchor.x:ie),A.y-ue-ae.height/2);if(!ae.anchor&&A.x>=Re.x-Re.w/2&&A.x<=Re.x+Re.w/2&&A.y>=ue&&A.y<=ue+ae.height)return{nodeId:he.id,property:ae.property};ye<=U&&(!oe||ye<oe.distance)&&(oe={nodeId:he.id,property:ae.property,distance:ye})}}return oe},Lm=A=>{var Re;if(!A.currentTarget.contains(A.target)||A.button!==0||P.current.readOnly)return;ke.current||(gr.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 Ae=cy(Me.current);if(Ae){ke.current={kind:"pinch",distance:Ae.distance,zoom:q.zoom,anchor:q.renderedToModel(Ae.center)},wr(null),yr(null),gr.current=!0;for(const ie of Me.current.keys())A.currentTarget.setPointerCapture(ie);return}}if(ke.current)return;const oe=L.drawHandles&&$.closest(".flow-sdk-handle"),he=L.drawHandles&&$.closest(".flow-sdk-property-port");if(L.drawMode||oe||he){const Ae=q.renderedToModel(U),ie=L.drawMode?Vn(Ae,"source"):null,ae=he||oe,ue=ae?(Re=ae.closest("[data-node-id]"))==null?void 0:Re.dataset.nodeId:(ie==null?void 0:ie.nodeId)??zn(Ae),ye=he?he.dataset.property:ie==null?void 0:ie.property;if(ue){ke.current={kind:"draw",pointerId:A.pointerId,source:ue,sourceProperty:ye,reverse:(he==null?void 0:he.dataset.portRole)==="target",startClient:{x:A.clientX,y:A.clientY}},gr.current=!0,wr({source:ue,sourceProperty:ye,point:Ae,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?ke.current={kind:"box",pointerId:A.pointerId,start:U,current:U}:L.dragMode?ke.current={kind:"pan",pointerId:A.pointerId,start:U,pan0:q.pan,moved:!1}:ke.current={kind:"tap",pointerId:A.pointerId,start:U,moved:!1},A.currentTarget.setPointerCapture(A.pointerId))},Fm=A=>{const $=ke.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,gr.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":{gr.current=!0,$.current=L,yr({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=Vn(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)??zn(U,$.source),targetProperty:oe==null?void 0:oe.property});break}}},ol=(A,$)=>{var oe,he,Re,Ae,ie;Me.current.delete(A.pointerId);const L=ke.current;if(!L)return;if(L.kind==="pinch"){const ae=[...Me.current][0];ke.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;ke.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(yr(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){(he=U.onBackgroundTap)==null||he.call(U);break}const sr=[];for(const wt of U.nodes){const sl=Y(wt.id);sl&&y0(at(sl),ye)&&sr.push(wt.id)}sr.length&&((Re=U.onBoxSelect)==null||Re.call(U,sr));break}case"draw":{if(wr(null),$)break;const ae=$r(A),ue=q.renderedToModel(ae),ye=Vn(ue,L.reverse?"source":"target"),sr=(ye==null?void 0:ye.nodeId)??zn(ue);if(sr===L.source&&(L.sourceProperty===void 0||(ye==null?void 0:ye.property)===void 0||ye.property===L.sourceProperty))break;sr?(Ae=U.onEdgeDraw)==null||Ae.call(U,L.reverse?sr:L.source,L.reverse?L.source:sr,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))>s_&&((ie=U.onDrawIntoSpace)==null||ie.call(U,L.source,ue,L.sourceProperty,L.reverse));break}}},Ur=E.useCallback(()=>{var L;const A=ke.current,$=[...Me.current.keys()];A&&A.kind!=="pinch"&&$.push(A.pointerId),ke.current=null,Me.current.clear(),wr(null),yr(null);for(const U of $)(L=R.current)!=null&&L.hasPointerCapture(U)&&R.current.releasePointerCapture(U)},[]);E.useEffect(()=>{const A=$=>{$.key==="Escape"&&Ur()};return window.addEventListener("keydown",A),window.addEventListener("blur",Ur),()=>{window.removeEventListener("keydown",A),window.removeEventListener("blur",Ur),ke.current=null,Me.current.clear()}},[Ur]),E.useEffect(()=>{Ur()},[m,x,g,i,n,e.drawHandles,e.readOnly,Ur]);const Bm=E.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]),Wn=a_[n],[Gn,Dm]=E.useState(null);E.useLayoutEffect(()=>{R.current&&Gn&&N0(R.current)});const Un=p0(T,_e,Wn),zm=e.onEdgeSelect,Vm=e.onContainerSelect,il=Oe?Oe.target&&_e(Oe.target,Oe.targetProperty)||{x:Oe.point.x,y:Oe.point.y,w:1,h:1}:null,al=Oe?_e(Oe.source,Oe.sourceProperty):null,Wm=["flow-sdk-canvas",m?"flow-sdk-draw":"",w?"flow-sdk-perf":""].filter(Boolean).join(" ");return h.jsxs("div",{ref:R,className:Wm,"data-edge-mode":i,onPointerDownCapture:Lm,onPointerMove:Fm,onPointerUp:A=>ol(A,!1),onPointerCancel:A=>ol(A,!0),onLostPointerCapture:A=>{const $=ke.current;$&&($.kind==="pinch"||$.pointerId===A.pointerId)&&Ur()},onClickCapture:A=>{A.currentTarget.contains(A.target)&&(gr.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])=>st(A,r,i)).filter(([A])=>!C||C.has(A)).map(([A,$])=>{var L;return h.jsx(k0,{id:A,rect:$,label:Je.get(A),labelLayer:Gn,style:b(A),onSelect:Vm,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:He&&T.map(A=>{var U,oe,he;if(C&&(!C.has(A.source)||!C.has(A.target)))return null;const $=_e(A.source,A.sourceProperty),L=_e(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:Wn,turn:((U=Un.get(A.id))==null?void 0:U.turn)??A.turn,labelAtTarget:(oe=Un.get(A.id))==null?void 0:oe.labelAtTarget,labelFraction:(he=Un.get(A.id))==null?void 0:he.labelFraction,color:A.color,labelBg:A.labelBg,label:A.label,labelLayer:Gn,dashed:A.dashed,animated:A.animated&&!w,inverted:A.inverted,loopIndex:Bm.get(A.id)??0,onSelect:zm},A.id)})}),He&&Oe&&wu(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:Wn,turn:.5,color:y,labelBg:y})})]})}),h.jsx("div",{ref:M,className:"flow-sdk-nodes",children:t.map(A=>{var he,Re;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(o_,{id:A.id,x:U,y:oe,placed:!!$||!!L,hidden:!st(A.id,r,i)||!!C&&!C.has(A.id),onMount:Fe,drawHandles:e.drawHandles&&!e.readOnly,drawMode:m,connectedPorts:new Set(T.flatMap(Ae=>[...Ae.source===A.id&&Ae.sourceProperty!==void 0?[`source:${Ae.sourceProperty}`]:[],...Ae.target===A.id&&Ae.targetProperty!==void 0?[`target:${Ae.targetProperty}`]:[]])),hasCollapseControl:A.hasCollapseControl,handleColor:y,animated:A.animated&&!L&&!w,animationColor:A.animationColor,animationWidth:A.animationWidth,animationVariant:A.animationVariant,width:(he=H.current.get(A.id))==null?void 0:he.w,height:(Re=H.current.get(A.id))==null?void 0:Re.h,propertyMode:S,resolvedRows:D.get(A.id),reversePorts:n==="RL",direction:n,onPropertyRows:z,onSurface:K,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:Dm,className:"flow-sdk-labels",style:{pointerEvents:m?"none":"visiblePainted",outline:"none"}})})})]})}const f_=E.memo(d_);function Pm({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 h_=gn.default.dialog`
151
+ &[open] {
152
+ display: flex;
153
+ flex-direction: column;
154
+ }
155
+ &,
156
+ & * {
157
+ scrollbar-width: none;
158
+ }
159
+ &::-webkit-scrollbar,
160
+ & *::-webkit-scrollbar {
161
+ display: none;
162
+ }
163
+ `,p_=gn.default.div`
164
+ min-height: 0;
165
+ overflow: auto;
166
+ padding: 32px 0;
167
+ mask-image: linear-gradient(
168
+ to bottom,
169
+ transparent,
170
+ black 32px,
171
+ black calc(100% - 32px),
172
+ transparent
173
+ );
174
+ -webkit-mask-image: linear-gradient(
175
+ to bottom,
176
+ transparent,
177
+ black 32px,
178
+ black calc(100% - 32px),
179
+ transparent
180
+ );
181
+ `;function Am({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=E.useRef(null),f=E.useId(),{data:p,schema:b,bindings:y}=E.useContext(kr),m=i!==void 0||!!(p&&b&&(y?Jt(y,e,b):pt(p,e,b)));E.useEffect(()=>{var g,w,v,_,C;!t||!m||!n?(g=d.current)==null||g.close():(w=d.current)!=null&&w.open||((v=d.current)==null||v.showModal(),(C=(_=d.current)==null?void 0:_.querySelector("[data-form-filter] input"))==null||C.focus())},[t,m,n]);const x=pe(u);return m?h.jsx(h.Fragment,{children:typeof document<"u"&&Lt.createPortal(h.jsx(h_,{ref:d,id:f,"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,border:`1px solid ${pe(c)}`,background:x,color:pe(l),boxShadow:`0 0 0 8px color-mix(in srgb, ${x} 60%, transparent)`,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(ht,{type:"submit","aria-label":"Close node configuration"})})]}),a&&h.jsx("div",{"data-form-filter":"",style:{flexShrink:0},children:a}),h.jsx(p_,{"data-form-scroll":"",style:s?{flex:1}:void 0,children:i??h.jsx(rb,{nodeAddress:e})})]})}),document.body)}):null}const Cu=({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})})})},g_=({data:e,children:t,isInverted:r,isParent:n})=>{var N,B,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:b}=Ie(),{background:y,border:m,colorText:x}=Ve(),g=E.useRef(null),w=E.useRef(null),[v,_]=E.useState(!1),[C,S]=E.useState(!1),[T,k]=E.useState(!1),j=e==null?void 0:e.id,P=tb(j),R=o.includes(j),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=E.useCallback(Q=>{var J,te,de,fe;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 Ee=o.includes(j),ge=Ee?o.filter(We=>We!==j):[...o,j];i(ge),Ee?(te=d.onNodeDeselect)==null||te.call(d):(de=d.onNodeSelect)==null||de.call(d,j,e,G)}else i([j]),(fe=d.onNodeSelect)==null||fe.call(d,j,e,G)},[j,e,o,a,u,C,i,s,d,f]),H=E.useCallback(()=>{var Q;C||f.readOnly||(Q=d.onNodeDoubleClick)==null||Q.call(d,j,e)},[j,e,C,d,f]),V=E.useCallback(()=>{w.current&&clearTimeout(w.current),w.current=setTimeout(()=>_(!0),100)},[]),re=E.useCallback(()=>{w.current&&clearTimeout(w.current),_(!1)},[]),ce=!!((N=e==null?void 0:e.config)!=null&&N.form),le={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([j]),k(!0),(G=d.onNodeDoubleClick)==null||G.call(d,j,e))},onKeyDown:Q=>{!ce||f.readOnly||Q.target!==Q.currentTarget||Q.key!=="Enter"||(Q.preventDefault(),Q.stopPropagation(),i([j]),k(!0))}},be=ce&&h.jsx(Am,{nodeAddress:j,active:R,label:e.label||e.headerTitle||"Node",open:T,onClose:()=>{var Q;k(!1),R&&((Q=g.current)==null||Q.focus({preventScroll:!0}))}}),K=Array.isArray((B=e==null?void 0:e.config)==null?void 0:B.ports)?e.config.ports.map(Q=>h.jsx(Pm,{...Q},`${Q.id}:${Q.role}`)):null;return n?h.jsxs(F.Box,{ref:g,...le,onClick:q,onDoubleClick:H,onMouseEnter:V,onMouseLeave:re,cursor:"pointer",position:"relative",children:[be,!c&&(O||I&&I.length>0)&&v&&!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:j,nodeData:e,isRoot:j==="root",isParent:!0,isHovered:v,setIsHovered:_})}):h.jsx(F.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",bg:y,p:3,borderColor:m,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:m,height:5,borderRightWidth:1}),h.jsx(Cu,{icon:Q.icon,label:Q.label,color:x,bgColor:y,borderColor:m,textColor:x,boxSize:5,onClick:J=>{var te;J.stopPropagation(),(te=d.onNodeHoverAction)==null||te.call(d,Q.id,j,e)}})]},Q.id))})})]}),t({id:j,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=b==="TB"||b==="BT",G=r||b==="RL";return h.jsx(F.IconButton,{position:"absolute",...Q?{[b==="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 de;te.stopPropagation(),(de=d.onNodeCollapse)==null||de.call(d,j,!e.config.collapsed)},bgColor:pe(((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:pe("gray.800")}):h.jsx(Z.PiMinusBold,{size:30,color:pe("gray.800")})})})()]}):h.jsxs(F.Box,{ref:g,...le,onClick:q,onDoubleClick:H,onMouseEnter:V,onMouseLeave:re,cursor:"pointer",transition:"transform 0.1s ease",position:"relative",children:[be,K,!c&&(O||I&&I.length>0)&&v&&!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:j,nodeData:e,isRoot:j==="root",isParent:!!n,isHovered:v,setIsHovered:_})}):h.jsx(F.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",bg:y,p:3,borderColor:m,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:m,height:5,borderRightWidth:1}),h.jsx(Cu,{icon:Q.icon,label:Q.label,color:x,bgColor:y,borderColor:m,textColor:x,boxSize:5,onClick:J=>{var te;J.stopPropagation(),(te=d.onNodeHoverAction)==null||te.call(d,Q.id,j,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,de,fe;const Q=b==="TB"||b==="BT",G=r||b==="RL",J=(te=e==null?void 0:e.config)!=null&&te.labelBelow?((((de=e==null?void 0:e.viewProps)==null?void 0:de.fontSize)||1)*100+100)/2:void 0;return h.jsx(F.IconButton,{position:"absolute",...Q?{[b==="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:Ee=>{var ge;Ee.stopPropagation(),(ge=d.onNodeCollapse)==null||ge.call(d,j,!e.config.collapsed)},bgColor:pe(((fe=e==null?void 0:e.viewProps)==null?void 0:fe.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:pe("gray.800")}):h.jsx(Z.PiMinusBold,{size:30,color:pe("gray.800")})})})(),t({id:j,data:e,isActive:R,isLowZoom:M,isEditing:C,onEditStart:()=>S(!0),onEditEnd:()=>S(!1)})]})]})},Bn=E.memo(g_);function tl(e=!0){const t=E.useRef(null);return E.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 Kt=({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,b]=E.useState(t),[y,m]=E.useState(),x=E.useRef(null),g=E.useRef(!1),w=tl(a);E.useEffect(()=>{a&&(g.current=!1,x.current&&(x.current.focus(),x.current.select()))},[a]);const v=()=>{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(),m({width:_.currentTarget.offsetWidth,height:_.currentTarget.offsetHeight}),b(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:x,value:p,onChange:_=>b(_.target.value),onBlur:v,onKeyDown:_=>{_.key==="Enter"&&v(),_.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"})]})},y_=({id:e,data:t,isActive:r,isEditing:n,onEditStart:o,onEditEnd:i})=>{var y,m,x,g,w,v,_,C;const{themeColor:a}=Ie(),{colorText:s}=Ve(),u=((y=t==null?void 0:t.viewProps)==null?void 0:y.bgColor)==="transparent",c=((m=t==null?void 0:t.viewProps)==null?void 0:m.outline)===!0,{bgColor:l,borderColor:d,textColor:f}=Zt(((x=t==null?void 0:t.viewProps)==null?void 0:x.bgColor)||a),p=pe(((g=t==null?void 0:t.viewProps)==null?void 0:g.textColor)||(u||c?s:f)),b=((w=t==null?void 0:t.viewProps)==null?void 0:w.borderColor)||(c?!u&&((v=t==null?void 0:t.viewProps)==null?void 0:v.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,...ln(t==null?void 0:t.viewProps,b,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(Kt,{nodeId:e,label:(t==null?void 0:t.label)||(t==null?void 0:t.text)||"",color:p,isEditing:n,onEditStart:o,onEditEnd:i})]})})};function Dn(){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 b_=({id:e,isActive:t,data:r,isEditing:n,onEditStart:o,onEditEnd:i})=>{var w,v,_,C,S,T,k,j,P,R,I,O,M,q,H;const{themeColor:a}=Ie(),{colorText:s}=Ve(),u=((w=r==null?void 0:r.viewProps)==null?void 0:w.bgColor)==="transparent",c=((v=r==null?void 0:r.viewProps)==null?void 0:v.outline)===!0,l=!u&&((_=r==null?void 0:r.viewProps)==null?void 0:_.bgColor)||a,{borderColor:d,highlightColor:f,textColor:p}=Zt(l),b=pe(((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":pe(((T=r==null?void 0:r.viewProps)==null?void 0:T.borderColor)||(c?l:d)),m=u||c?"transparent":l!=null&&l.startsWith("#")?l:pe(f),x=(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((j=r==null?void 0:r.config)!=null&&j.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:m,...ln(r==null?void 0:r.viewProps,y,t,2),children:!!x&&h.jsx(Mr,{name:x,size:V,color:b})}),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(Kt,{nodeId:e,label:g,color:pe(((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:pe(((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:m,style:{backgroundColor:m},textTransform:"capitalize",...ln(r==null?void 0:r.viewProps,y,t,2),px:50,w:"fit-content",whiteSpace:"nowrap",children:[!!x&&h.jsx(F.Flex,{align:"center",py:14,mr:g?8:0,flexShrink:0,children:h.jsx(Mr,{name:x,size:(((H=r==null?void 0:r.viewProps)==null?void 0:H.fontSize)||1)*100,color:b},b)}),(g||!x)&&h.jsx(F.Flex,{justifyContent:"start",py:14,fontSize:"5xl",lineHeight:"normal",w:"fit-content",maxW:900,minW:0,children:h.jsx(Kt,{nodeId:e,label:g,color:b,isEditing:n,onEditStart:o,onEditEnd:i})})]})};function Tm({onExpand:e,toggleLabel:t="Show properties",toggleDisabled:r=!1,renderCompact:n=b_,...o}){const{colorMode:i,callbacks:a}=Ie();return h.jsx(Bn,{...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 m_({nodeId:e,content:t,color:r}){const{callbacks:n,config:o,readOnly:i}=Ie(),a=!!o.editable&&!i,[s,u]=E.useState(!1),[c,l]=E.useState(t),[d,f]=E.useState(),p=E.useRef(null),b=E.useRef(!1),y=tl(s);E.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]),E.useEffect(()=>{var g;a?s&&(b.current=!1,(g=p.current)==null||g.focus()):u(!1)},[s,a]);const m=g=>{a&&(f({width:g.offsetWidth,height:g.offsetHeight}),l(t),u(!0))},x=()=>{var g;b.current||!a||(b.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(),m(g.currentTarget)},onKeyDown:g=>{a&&g.key==="Enter"&&g.target===g.currentTarget&&(g.preventDefault(),g.stopPropagation(),m(g.currentTarget))},children:h.jsx(tv.default,{options:{forceBlock:!0,wrapper:E.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:x,onKeyDown:g=>{g.stopPropagation(),!g.nativeEvent.isComposing&&(g.key==="Enter"&&(g.ctrlKey||g.metaKey)&&(g.preventDefault(),x()),g.key==="Escape"&&(b.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 v_=(e,t,r)=>{var f,p,b,y;const n=((f=e==null?void 0:e.viewProps)==null?void 0:f.bgColor)||t,[o]=n.split("."),i=Zt(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("#")?pe(n):pe(i.bgColor),l=pe(((b=e==null?void 0:e.viewProps)==null?void 0:b.textColor)||(s?u:i.textColor)),d=pe(((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}},x_=(e,t=350)=>`${String(e).substring(0,t)}${String(e).length>t?"...":""}`,w_=e=>e!=null&&e.includes("root")?e.replace("root","untitled"):e,Om=600,C_=3,__=e=>{const t=Math.max(...Object.keys(e||{}).map(n=>n.length),0);return Math.max(t*28+30,200)};function S_({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:b}){var g,w;const{callbacks:y}=Ie(),m=d.onShowIcon??b,x=m?"Show icon":f?"Show content":"Show properties";return h.jsx(h.Fragment,{children:(e||t||((g=r.config)==null?void 0:g.form)||s&&b)&&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(Kt,{nodeId:a,label:w_(e),color:((w=r==null?void 0:r.viewProps)==null?void 0:w.textColor)||o.propertyColor,isEditing:u,onEditStart:c,onEditEnd:l}),s&&(t||m)&&h.jsx(F.Box,{ml:"auto",pl:6,flexShrink:0,"data-flow-content-toggle":"",children:h.jsx(je,{label:x,children:h.jsx(ve,{"aria-label":x,icon:h.jsx(F.Icon,{as:Z.PiCircleFill,boxSize:4}),variant:"ghost",w:12,h:12,minW:12,color:o.hextextColor,onClick:v=>{var _;v.stopPropagation(),m?m():p(!f),(_=y.onNodeViewToggle)==null||_.call(y,a)}})})})]})})}function j_({data:e,resourcePorts:t,inspecting:r,form:n,inspectionPorts:o,extraPorts:i,colors:a,direction:s,uniformKeyWidth:u}){const{edgeById:c}=Wr(),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 b=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]),m=b??(y?`${y.kind}:${d}`:d),x=o.find(q=>q.id===m),g=b?"source":x==null?void 0:x.role,w=l.has(`source:${m}`),v=l.has(`target:${m}`),_=i.some(q=>q.id===d),C=f===""&&(_||(g?l.has(`${g}:${m}`):w||v)),S=g??(w!==v?w?"source":"target":void 0),T=(x==null?void 0:x.side)??(S?S==="source"!=(s==="RL")?"right":"left":void 0),k=C&&T==="right"?"right":"left",j=_?d.replace(/^(template|input|output|config|error):/,""):d,P=Er(a.wordBeforeDot)[typeof f],R=Er(a.wordBeforeDot).property;return h.jsxs(F.Box,{"data-flow-property":b&&(s==="TB"||s==="BT")?void 0:m,"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:j})}),!C&&h.jsx(F.Flex,{flex:1,justifyContent:"start",overflow:"hidden",p:4,background:a.hexbgColor,w:Om,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:x_(f)})})]}),p!==Object.entries(e.description||{}).length-1&&h.jsx(F.Box,{borderTopWidth:1,my:0,borderColor:a.hexborderColor})]},d)})})}function E_(e){var w,v,_;const{themeColor:t,colorMode:r,direction:n}=Ie(),o=Dn(),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}=E.useContext(kr),d=(v=u==null?void 0:u[e.data.id])==null?void 0:v.portResources,f=u?Jt(u,e.data.id,l):c&&l?pt(c,e.data.id,l):void 0,p=f&&xe(c,"address"in f?f.address:e.data.id),b=p&&typeof p=="object"&&f?Object.fromEntries(Object.keys(f.type.properties).filter(C=>{var S;return Object.prototype.hasOwnProperty.call(p,C)&&vn((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:b,m=s&&!d?((_=e.data.config)==null?void 0:_.ports)??[]:[],x=m.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(x.map(C=>[C.id,""]))};return{themeColor:t,colorMode:r,direction:n,objVisible:i,setObjVisible:a,inspecting:s,resourcePorts:d,form:f,description:g,inspectionPorts:m,extraPorts:x}}const nl=e=>{var m,x,g;const{themeColor:t,colorMode:r,direction:n,objVisible:o,setObjVisible:i,inspecting:a,resourcePorts:s,form:u,description:c,inspectionPorts:l,extraPorts:d}=E_(e),f=Dn(),p=f.getNodeViewMode(e.data.id)==="icon-label",y=!e.onShowIcon&&!((m=e.data.config)!=null&&m.parentContainer)&&typeof((x=e.data.config)==null?void 0:x.content)!="string"?()=>f.setNodeViewMode(e.data.id,"icon-label"):void 0;return!e.onShowIcon&&p?h.jsx(Tm,{...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(Bn,{...e,data:{...e.data,description:c},children:({id:w,data:v,isActive:_,isEditing:C,onEditStart:S,onEditEnd:T})=>{var V,re,ce,le,be,K;const k=v_(v,t,r),j=v.label??v.headerTitle,P=Object.entries(v.description||{}).length>0,R=__(v.description),I=(re=(V=e.data)==null?void 0:V.config)==null?void 0:re.icon,O=(le=(ce=e.data)==null?void 0:ce.config)==null?void 0:le.content,M=typeof O=="string"&&!e.onShowIcon,q=((be=v==null?void 0:v.viewProps)==null?void 0:be.borderRadius)??"53px",H=ln(v==null?void 0:v.viewProps,k.hexborderColor,_,C_);return h.jsx(F.Flex,{justifyContent:"space-between",...v==null?void 0:v.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+Om+H.borderWidth*2:void 0,...H,children:h.jsxs(F.Flex,{width:"100%",direction:"column",borderRadius:q,borderColor:k.hexborderColor,borderWidth:0,overflow:"hidden",children:[h.jsx(S_,{headerTitle:j,hasContent:M,data:v,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(m_,{nodeId:w,content:O,color:((K=v==null?void 0:v.viewProps)==null?void 0:K.textColor)||k.hextextColor})}):h.jsx(j_,{data:v,resourcePorts:s,inspecting:a,form:u,inspectionPorts:l,extraPorts:d,colors:k,direction:n,uniformKeyWidth:R})]})})}})};nl.displayName="NodeJsonObjectView";const Im=e=>{var c,l,d,f,p,b,y;const t=Dn(),r=t.getNodeViewMode(e.data.id)==="properties",n=m=>t.setNodeViewMode(e.data.id,m?"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=(b=(p=e.data)==null?void 0:p.config)==null?void 0:b.ports)==null?void 0:y.length);return!a&&u&&r?h.jsx(nl,{...e,onShowIcon:()=>n(!1)}):h.jsx(Tm,{...e,toggleLabel:s,toggleDisabled:a&&i,onExpand:u?()=>{var m;a?(m=o.onNodeCollapse)==null||m.call(o,e.data.id,!1):n(!0)}:void 0})},Mm=e=>h.jsx(Im,{...e,renderCompact:y_}),qm=e=>h.jsx(Im,{...e}),Nm=e=>h.jsx(Bn,{...e,children:()=>null});Mm.displayName="text";qm.displayName="arrayView";Nm.displayName="ParentContainerView";const R_={objectView:nl,arrayView:qm,text:Mm,parentContainer:Nm},k_=({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})]})},P_=.4,Hr={borderWidth:6,borderStyle:"solid",borderRadius:50,fontSize:70,padding:120,labelPosition:"top",labelMargin:90},A_=({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:b,callbacks:y,config:m,selectedNodeIds:x,setSelectedNodeIds:g,selectedEdgeId:w,setSelectedEdgeId:v,setIsPerformanceMode:_,isZoomMode:C,setIsZoomMode:S,isMultiSelectMode:T,setIsMultiSelectMode:k,isDragMode:j,setIsDragMode:P,isEdgeHandlesEnabled:R,isArrayNodeMode:I}=Ie(),O=E.useRef(null),[M,q]=E.useState(null),H=e.length>200;E.useEffect(()=>{_(H)},[H,_]);const{edgeSep:V,rankSep:re,spacingFactor:ce}=E.useMemo(()=>{const Y=h0(e.length),D=n<1?.3+.7*n:.5+.5*n;return{edgeSep:Y.edgeSep*D,rankSep:Y.rankSep*D,spacingFactor:1.3+(n-1)*(n<1?.4:.3)}},[e.length,n]),{bgColor:le}=Zt(r),{canvas:be,borderSecondary:K,colorText:N}=Ve(),B=i==="transparent"?"transparent":m.backgroundColor||be,W=E.useCallback(Y=>{if(Y!=null&&Y.includes("gray"))return"whitesmoke";if(!Y)return pe(r);switch(Y){case"dark":return pe(B);case"light":return pe(K);default:return pe(Y)}},[r,B,K]),z=m.colorMode==="dark",X=E.useMemo(()=>W(z?le:"light"),[z,le,W]),se=s?W(s):X,Q=E.useMemo(()=>m.initialViewport||{pan:{x:0,y:0},zoom:.01},[]),G=u==="C"?"LR":u,J=E.useCallback(Y=>{const D={...p,...Y};return{...D,bgColor:D.bgColor||r,bgOpacity:D.outline?0:D.bgOpacity??P_}},[p,r]),te=E.useMemo(()=>{var D;const Y=new Map;for(const ee of e)(D=ee.data)!=null&&D.id&&Y.set(ee.data.id,ee);return Y},[e]),de=E.useMemo(()=>{var D;const Y=new Map;for(const ee of t)(D=ee.data)!=null&&D.id&&Y.set(ee.data.id,ee);return Y},[t]),fe=E.useCallback(Y=>{var _e;const D=(_e=te.get(Y))==null?void 0:_e.data,ee=J(D==null?void 0:D.viewProps),Ce=pe(ee.bgColor);return{animated:!!(D!=null&&D.isNodeAnimated)&&!H,animationVariant:D==null?void 0:D.nodeAnimationVariant,animationColor:pe(ee.borderColor||r),bgColor:ee.outline?"transparent":Ce,bgOpacity:ee.bgOpacity,borderColor:ee.borderColor?pe(ee.borderColor):ee.outline&&ee.bgColor==="transparent"?pe(r):Ce,borderWidth:Ut(ee.borderWidth,Hr.borderWidth),borderStyle:ee.borderStyle??Hr.borderStyle,borderRadius:ee.borderRadius??Hr.borderRadius,textColor:ee.textColor?pe(ee.textColor):ee.outline||ee.bgColor==="transparent"?pe(N):Ce,fontSize:ee.fontSize??Hr.fontSize,labelPosition:ee.labelPosition??Hr.labelPosition,labelMargin:Hr.labelMargin,labelBg:cl(W("dark"),Ce,ee.bgOpacity)??W("dark"),padding:ee.padding??Hr.padding}},[J,te,N,r,H,W]),Ee=E.useMemo(()=>{var ee,Ce;const Y=new Map;for(const _e of t){const Se=(ee=_e.data)==null?void 0:ee.source,Ge=(Ce=_e.data)==null?void 0:Ce.target;if(!Se||!Ge||Se===Ge)continue;const Le=Se<Ge?`${Se}|${Ge}`:`${Ge}|${Se}`,ke=Y.get(Le);ke?ke.push({id:_e.data.id,source:Se}):Y.set(Le,[{id:_e.data.id,source:Se}])}const D=new Map;for(const[_e,Se]of Y){if(Se.length<2)continue;const Ge=_e.split("|")[0],Le=Math.min(20,70/Se.length);Se.forEach(({id:ke,source:Me},gr)=>{const Ye=50+(gr-(Se.length-1)/2)*Le;D.set(ke,(Me===Ge?Ye:100-Ye)/100)})}return D},[t]),ge=E.useMemo(()=>{const Y=W("dark");return t.filter(D=>{var ee;return((ee=D.data)==null?void 0:ee.id)&&D.data.source&&D.data.target}).map(({data:D})=>{var Se,Ge,Le,ke,Me,gr;let ee=Y;const Ce=(Ge=(Se=te.get(D.source))==null?void 0:Se.data)==null?void 0:Ge.parent,_e=(ke=(Le=te.get(D.target))==null?void 0:Le.data)==null?void 0:ke.parent;if(Ce&&Ce===_e){const Ye=J((gr=(Me=te.get(Ce))==null?void 0:Me.data)==null?void 0:gr.viewProps),yr=cl(Y,pe(Ye.bgColor),Ye.bgOpacity);yr&&(ee=yr)}return{id:D.id,data:D,type:D.type??m.edgeType??"rounded-orthogonal",source:D.source,target:D.target,sourceProperty:D.sourceProperty,targetProperty:D.targetProperty,label:D.label,validationIssue:(l==="auto"||l==="properties")&&(D.sourceProperty!==void 0||D.targetProperty!==void 0)&&f?Iu(f,D):void 0,color:D.color?pe(D.color):se,labelBg:ee,dashed:!!D.isEdgeDashed,animated:!!D.isEdgeAnimated,inverted:!!D.isInverted,turn:Ee.get(D.id)??.5}})},[t,se,Ee,m.edgeType,l,f,te,J,W]),We=E.useMemo(()=>{var D;const Y=new Set;for(const ee of e)(D=ee.data)!=null&&D.parent&&Y.add(ee.data.parent);return Y},[e]),me=E.useMemo(()=>{var D;const Y=new Map;for(const ee of t)(D=ee.data)!=null&&D.source&&!Y.has(ee.data.source)&&Y.set(ee.data.source,ee.data);return Y},[t]),Te=E.useMemo(()=>{const Y={...R_,...m.customViews};return e.filter(D=>{var ee;return(ee=D.data)==null?void 0:ee.id}).map(D=>{var Ge,Le,ke,Me;const ee=We.has(D.data.id)&&!D.data.parent,Ce=ee?D.data.label??D.data.headerTitle??"Container":void 0,_e=ee?Y.parentContainer:Y[D.data.type]||Y.text,Se=me.get(D.data.id);return{id:D.data.id,collapsed:(Ge=D.data.config)==null?void 0:Ge.collapsed,parent:D.data.parent,label:Ce,animated:!!D.data.isNodeAnimated,animationVariant:D.data.nodeAnimationVariant,hasCollapseControl:((Le=D.data.config)==null?void 0:Le.collapsed)!==void 0,animationColor:pe(((ke=D.data.viewProps)==null?void 0:ke.borderColor)||r),animationWidth:Ut((Me=D.data.viewProps)==null?void 0:Me.borderWidth,8),element:E.createElement(_e,{...D,isInverted:Se==null?void 0:Se.isInverted,isParent:ee,key:`${D.data.id}-${r}`})}})},[e,We,me,r,m.customViews]),er=E.useMemo(()=>H?300:e.length>50?150:e.length>20?100:50,[e.length,H]),De=E.useRef(m);De.current=m;const Ne=E.useRef(C);Ne.current=C;const He=E.useRef(I);He.current=I;const rr=E.useRef(x);rr.current=x;const ze=E.useRef(w);ze.current=w;const xr=E.useRef(T);xr.current=T;const Ze=E.useRef(te);Ze.current=te;const pr=E.useRef(de);pr.current=de;const dr=E.useRef(new Map);E.useEffect(()=>{var ee,Ce;const Y=new Map([...de].filter(([,_e])=>te.has(_e.data.source)&&te.has(_e.data.target))),D=dr.current;dr.current=Y;for(const[_e,Se]of D)Y.has(_e)||(ze.current===_e&&(v(null),(ee=y.onEdgeDeselect)==null||ee.call(y)),(Ce=y.onEdgeRemove)==null||Ce.call(y,_e,Se.data))},[de,te,y,v]),E.useEffect(()=>{const Y=O.current;if(!M||!Y)return;let D=null,ee=null,Ce=0,_e=0,Se=0,Ge=0,Le=0;const ke=Me=>{if(De.current.readOnly)return;Me.preventDefault(),Me.stopPropagation(),Ne.current||Me.metaKey||Me.ctrlKey?(Se+=Me.deltaY,Ge=Me.clientX,Le=Me.clientY,ee===null&&(ee=requestAnimationFrame(()=>{ee=null;const Ye=De.current,yr=M.zoom(),Oe=Se;Se=0;let wr=yr-Oe*.05/100;wr=Math.max(Ye.minZoom??.01,Math.min(Ye.maxZoom??1.5,wr));const $r=Y.getBoundingClientRect();M.zoomAt(wr,{x:Ge-$r.left,y:Le-$r.top})}))):(Ce+=Me.deltaX,_e+=Me.deltaY,D===null&&(D=requestAnimationFrame(()=>{D=null;const Ye=M.pan(),yr=M.zoom(),Oe=.35,wr=Ce,$r=_e;Ce=0,_e=0,M.pan({x:Ye.x+-wr*Oe/yr,y:Ye.y+-$r*Oe/yr})})))};return Y.addEventListener("wheel",ke,{passive:!1}),()=>{Y.removeEventListener("wheel",ke),D!==null&&cancelAnimationFrame(D),ee!==null&&cancelAnimationFrame(ee)}},[M]),E.useEffect(()=>{if(m.disableKeyboardShortcuts)return;const Y=D=>{var Ce,_e,Se,Ge;if(De.current.readOnly)return;const ee=D.target;if(!(ee.tagName==="INPUT"||ee.tagName==="TEXTAREA"||ee.isContentEditable)){if((D.key==="z"||D.key==="Z")&&S(!Ne.current),(D.key==="m"||D.key==="M")&&k(!T),(D.key==="d"||D.key==="D")&&P(!j),(D.key==="Delete"||D.key==="Backspace")&&ze.current){D.preventDefault();const Le=ze.current;(_e=y.onEdgeDelete)==null||_e.call(y,Le,((Ce=pr.current.get(Le))==null?void 0:Ce.data)??{id:Le}),v(null);return}if((D.key==="Delete"||D.key==="Backspace")&&rr.current.length>0){D.preventDefault();const Le=rr.current.filter(ke=>ke!=="root");if(Le.length===0)return;for(const ke of Le){const Me=(Se=Ze.current.get(ke))==null?void 0:Se.data;(Ge=y.onNodeDelete)==null||Ge.call(y,ke,Me||{})}g([])}}};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[T,j,S,k,P,m.disableKeyboardShortcuts,y,g,v]);const jr=E.useCallback(Y=>{var D;b.current=Y,q(Y),(D=y.onInit)==null||D.call(y,Y)},[b,y]),we=E.useCallback(Y=>{var D;return(D=y.onViewportChange)==null?void 0:D.call(y,Y)},[y]),or=E.useCallback(Y=>{var ee,Ce,_e;const D=((ee=pr.current.get(Y))==null?void 0:ee.data)??{id:Y};if(ze.current===Y&&xr.current){v(null),(Ce=y.onEdgeDeselect)==null||Ce.call(y);return}rr.current.length&&g([]),v(Y),(_e=y.onEdgeSelect)==null||_e.call(y,Y,D)},[y,v,g]),ar=E.useCallback(()=>{var Y,D,ee;a(!0),(Y=y.onBackgroundClick)==null||Y.call(y),rr.current.length&&(g([]),(D=y.onNodeDeselect)==null||D.call(y)),ze.current&&(v(null),(ee=y.onEdgeDeselect)==null||ee.call(y))},[y,g,v,a]),xt=E.useCallback(Y=>{var Ce,_e;const D=rr.current,ee=Y.filter(Se=>!D.includes(Se));if(ee.length){g([...D,...ee]);for(const Se of ee)(_e=y.onNodeSelect)==null||_e.call(y,Se,((Ce=Ze.current.get(Se))==null?void 0:Ce.data)??{id:Se})}},[y,g]),ne=E.useCallback((Y,D)=>{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},D)},[y,g]),Fe=E.useCallback((Y,D,ee)=>{var Ce;return(Ce=y.onEdgeCreate)==null?void 0:Ce.call(y,Y,D,ee)},[y]),Je=E.useCallback((Y,D,ee,Ce=!1)=>{var _e,Se;l==="properties"&&((_e=y.onNodeCreateRequest)==null?void 0:_e.call(y,{sourceNodeId:Y,position:D,sourceProperty:ee,reverse:Ce}))===!0||ee!==void 0||Ce||(Se=y.onNodeCreate)==null||Se.call(y,{type:"text",sourceNodeId:Y,position:D,isArrayMode:He.current})},[y,l]),$e=!m.readOnly&&R&&m.edgeHandles!==!1,Xe=i==="transparent"?"none":i;return h.jsx(k_,{pattern:Xe,backgroundColor:B,children:h.jsx(F.Box,{ref:O,padding:0,width:"100%",height:"100%",flex:1,position:"relative",children:h.jsx(f_,{nodes:Te,edges:ge,direction:G,nodeAlignment:c,onContainerCollapse:Y=>{var D,ee;(D=y.onNodeCollapse)==null||D.call(y,Y,!0),(ee=y.onNodeViewToggle)==null||ee.call(y,Y)},selectedNodeIds:x,edgeMode:l,compactPropertyLayout:d,edgeType:m.edgeType,edgeRadius:o,customEdgeTypes:m.customEdgeTypes,rankSep:re,edgeSep:V,spacingFactor:ce,compactSpacingScale:n,layoutDebounce:er,isPerformanceMode:H,minZoom:m.minZoom??.01,maxZoom:m.maxZoom??1.5,initialViewport:Q,fitOnInit:!m.initialViewport,readOnly:!!m.readOnly,containerStyle:fe,lineColor:se,drawMode:$e,drawHandles:!m.readOnly&&m.edgeHandles!==!1,dragMode:j,multiSelect:!!T,onInit:jr,onLayoutComplete:y.onLayoutComplete,animateViewport:m.animateViewport,onViewportChange:we,onBackgroundTap:ar,onBoxSelect:xt,onEdgeSelect:or,onContainerSelect:ne,onEdgeDraw:Fe,onDrawIntoSpace:Je})})})},$m=E.memo(A_),T_=".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 O_(){if(ly||typeof document>"u")return;const e=document.createElement("style");e.setAttribute("data-flow-sdk",""),e.textContent=T_+f0+l0+".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 I_({loading:e=!1,loader:t,...r}){var u,c;const[n,o]=E.useState(null),i=E.useMemo(()=>!!(n!=null&&n.json)&&!!r.json&&s0(n.json,r.json),[n==null?void 0:n.json,r.json]),a=n===null||n.json!==r.json&&!i,s=e||a;return E.useEffect(()=>{!e&&i&&(n==null?void 0:n.json)!==r.json&&o(r)},[e,i,n==null?void 0:n.json,r.json]),E.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(M_,{...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 M_({title:e="untitled",json:t,forms:r,nodes:n,edges:o,config:i={},callbacks:a={},className:s,style:u,showBottomBar:c=!0,children:l}){O_();const[d,f]=E.useState(),p=i.formSchema??d,b=E.useMemo(()=>t&&r?Qy(t,r.state):t,[t,r==null?void 0:r.state]),y=i.direction==="C",m=E.useMemo(()=>{let k,j;return P=>(j=k&&j?c0(k,P,j)??mu(P,{title:e,isCenter:y}):mu(P,{title:e,isCenter:y}),k=P,j)},[e,y]),x=E.useMemo(()=>b?m(b):null,[b,m]),g=E.useMemo(()=>r!=null&&r.structured&&p?r0(r.state,r.bindings,p,(x==null?void 0:x.nodes)??n??[]):void 0,[r==null?void 0:r.structured,r==null?void 0:r.state,r==null?void 0:r.bindings,p,x,n]),w=(g==null?void 0:g.schema)??p,v=(g==null?void 0:g.bindings)??(r==null?void 0:r.bindings),_=E.useMemo(()=>[...(x==null?void 0:x.nodes)??n??[],...(g==null?void 0:g.nodes)??[]].map(j=>{var H,V,re,ce;const P=t?(H=xe(t,j.data.id))==null?void 0:H.$view:(V=j.data.config)==null?void 0:V.typeView,R=P&&Ft.includes(P)?P:void 0,I=R?R==="icon-label":(re=j.data.config)==null?void 0:re.labelBelow,O=R==="object"?"objectView":R==="text"?"text":I?"arrayView":j.data.type,M=w&&(r?Jt(v,j.data.id,w):t&&pt(t,j.data.id,w)),q=(((ce=j.data.config)==null?void 0:ce.ports)??[]).map(le=>({...le}));if(g&&M){const le=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[be,K]of Object.entries(M.type.ports??{})){const N=`${K.kind}:${be}`;q.some(B=>B.id===N)||q.push({id:N,role:K.kind==="input"||K.kind==="config"?"target":"source",side:le[K.kind],...K.kind==="config"?{placement:"config"}:{}})}for(const be of q){const K=q.filter(N=>N.side===be.side);be.position=(K.indexOf(be)+1)/(K.length+1)}}return M||I||R?{...j,data:{...j.data,type:O,...r?{description:Object.fromEntries(Object.entries(j.data.description??{}).filter(([le])=>!le.startsWith("$")&&!(g!=null&&g.slots.has(Et(j.data.id,le)))))}:{},config:{...j.data.config,...g&&M?{ports:q}:{},...M?{form:!0}:{},...R?{typeView:R,labelBelow:!!I}:I?{labelBelow:!0}:{}}}}:j}),[x,n,t,w,v,g,i.direction]),C=[...(x==null?void 0:x.edges)??o??[],...(g==null?void 0:g.edges)??[]],S=E.useMemo(()=>{const k=t&&x?vb(t,x.edges,a,a.onJsonChange,p):{...a};if(g){const j=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(!j.has(I))return R==null?void 0:R(I,...O)}}}return k},[t,x,a,p,g]),T=E.useMemo(()=>{if(!r)return S;let k=r.state;const j=R=>{if(i.readOnly||i.editable===!1)return;const I=r.onStateChange??r.onChange;if(!I)return;const O=Kx(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:(j({address:M.$state,nodeAddress:R,previousValue:xe(k,M.$state),value:O,data:k}),!0)};return{...S,onFormChange:j,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(Et(R.sourceNodeId,I)));return O?(O.present||j({data:k,nodeAddress:O.address.split(".").slice(0,-1).join("."),address:O.address,value:Rt(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(le=>le.data.id===R)))return(re=S.onNodeDelete)==null?void 0:re.call(S,R,I);const O=g&&[...g.slots.values()].find(le=>le.nodeId===R);if(!O)return(ce=S.onNodeDelete)==null?void 0:ce.call(S,R,I);const M=O.address.split("."),q=M.pop(),H=M.join("."),V=xe(k,H);j(Array.isArray(V)?{data:k,nodeAddress:H,address:H,previousValue:V,value:V.filter((le,be)=>String(be)!==q)}:{data:k,nodeAddress:H,address:O.address,previousValue:xe(k,O.address),value:void 0})},onEdgeCreate:(R,I,O)=>{var H,V;const M=((H=O==null?void 0:O.targetProperty)==null?void 0:H.startsWith("config:"))&&(g==null?void 0:g.slots.get(Et(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=e0(k,q,M);re!==void 0&&j({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(le=>le.data.id===R);if(!O)return(ce=S.onEdgeDelete)==null?void 0:ce.call(S,R,I);const M=g.slots.get(Et(O.data.target,O.data.targetProperty.slice(7))),q=M.address.split("."),H=q.pop(),V=q.join("."),re=xe(k,V);j(Array.isArray(re)?{data:k,nodeAddress:V,address:V,previousValue:re,value:re.filter((le,be)=>String(be)!==H)}:{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:v,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 j;f(k),(j=a.onFormSchemaChange)==null||j.call(a,k)},callbacks:T},children:h.jsx(py,{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($m,{nodes:_,edges:C}),c&&h.jsx(yb,{}),l]})})})}function sn(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 q_(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=sn(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)},b=()=>{if(u=void 0,!(!a||s)){i=Math.min(t.length,i+c);try{f()}catch(y){p(y);return}l(),a&&(u=setTimeout(b,r))}};return{play(){s||a||(i===t.length&&(o.cancel(),o=sn(e),i=0),a=!0,l(),u=setTimeout(b,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=sn(e);try{f(!0)}catch(m){p(m);return}l(),a&&(u=setTimeout(b,r))}},dispose(){s=!0,a=!1,d(),o.cancel()}}}function N_(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 $_(e){return _u(JSON.parse(e))}function _u(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 L_(e){return{replaceJson(t){if(e.readOnly||!e.onJsonChange)throw new Error("JSON document is read-only.");const r=_u(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=_u(t);return e.onStateChange(r,{address:"root",nodeAddress:"root",previousValue:e.state,value:r,data:r}),r}}}function F_({nodeAddress:e,expanded:t=!1}){var c;const{data:r,schema:n,bindings:o}=E.useContext(kr),{colorText:i,background:a}=Ve();if((c=o==null?void 0:o[e])!=null&&c.portResources)return null;const s=o&&Jt(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:pe(i),background:pe(a),fontSize:24,lineHeight:1.4,textTransform:"none"},children:Object.keys(s.type.properties).map(l=>{const d=s.fields[l]??{};if(!vn(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=yb;exports.CompactPropertyLayoutToggle=Dy;exports.ConnectionsOnlyToggle=a0;exports.DEFAULT_PALETTE=Nu;exports.DiagramAppearanceControls=Fy;exports.DynamicIcon=Mr;exports.EdgeTools=ab;exports.EditableLabel=Kt;exports.ErrorToast=hb;exports.FlowDiagram=I_;exports.FlowDiagramProvider=py;exports.FlowPort=Pm;exports.FlowView=$m;exports.FormDocumentContext=kr;exports.NODE_TYPE_VIEWS=Ft;exports.NodeBorderRadiusControl=sb;exports.NodeConfigSummary=F_;exports.NodeForm=rb;exports.NodeFormPopover=Am;exports.NodeIconPicker=qu;exports.NodeTools=cb;exports.NodeView=Bn;exports.SvgExportButton=db;exports.Swatches=Ht;exports.TEXT_PALETTE=ob;exports.ToolbarCloseButton=ht;exports.ToolbarCommitInput=Xr;exports.ToolbarDivider=Ot;exports.ToolbarIconButton=ve;exports.ToolbarRangeInput=Ly;exports.ToolbarScrollContainer=fb;exports.ToolbarSelect=Or;exports.ToolbarTooltip=je;exports.TooltipIconButton=Cu;exports.WorkflowControls=pb;exports.addChild=Pu;exports.addConnection=Au;exports.addTargetEdge=Zy;exports.addressToPath=Ir;exports.applyCollapsed=Ux;exports.applyFormChange=xn;exports.applyStateEdits=Hx;exports.bindSqueedCallbacks=vb;exports.compileSqueed=mu;exports.connectionIssue=Iu;exports.contentObjTheme=Er;exports.createFlowDiagram=Yr;exports.createFlowDocumentActions=L_;exports.createFormNode=mb;exports.createJsonPlayback=q_;exports.createJsonStream=sn;exports.downloadSvg=lb;exports.exportSvg=ub;exports.formValueError=Rr;exports.getChakraColorHex=pe;exports.getColorVariant=gy;exports.getDarkerHexColor=cn;exports.getNode=xe;exports.parseFlowDocument=$_;exports.parseJsonContract=Tu;exports.parseTypeScriptContract=Yy;exports.parseTypeScriptForm=Ou;exports.projectJsonPlaybackPreview=N_;exports.readFormSchema=Mu;exports.readWorkflowContract=Xy;exports.removeEdge=Jy;exports.removeNode=Ky;exports.resolveEdgeOwner=zt;exports.resolveStateView=Qy;exports.setCollapsed=Uy;exports.setEdgeProp=Fr;exports.setEdgeStyle=Hy;exports.setNodeProp=ir;exports.updateNode=hr;exports.useCustomColors=Ve;exports.useFlowData=Wr;exports.useFlowDiagramContext=Ie;exports.useNodeViewActions=Dn;exports.useStopPropagation=tl;exports.useThemeContentColors=Zt;
3
182
  //# sourceMappingURL=index.cjs.map