gaesup-world 1.0.3 → 1.0.4
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/{GrassDriver-BOvF1wSA.cjs → GrassDriver-B-n-ksGE.cjs} +1 -1
- package/dist/{GrassDriver-BYgHaICM.js → GrassDriver-pCkYWAhc.js} +38 -37
- package/dist/blueprints-editor.cjs +1 -1
- package/dist/blueprints-editor.js +2 -2
- package/dist/{defaultConfig-r47lN-AC.js → defaultConfig-CJq-vbN1.js} +2 -2
- package/dist/{defaultConfig-D-a1mbtz.cjs → defaultConfig-kCt9NSk9.cjs} +1 -1
- package/dist/editor.cjs +1 -1
- package/dist/editor.js +2 -2
- package/dist/index--tenkUDe.cjs +1 -0
- package/dist/{index-BMOiJMPn.js → index-B0ESWneN.js} +1 -1
- package/dist/{index-CzYoZOU-.cjs → index-BXiDvzFS.cjs} +1 -1
- package/dist/{index-CaUZvDBz.cjs → index-C-mTcYjC.cjs} +1 -1
- package/dist/{index-D6pLUicy.cjs → index-CI6HBNFU.cjs} +1 -1
- package/dist/{index-CRmbe-O5.js → index-ClvSyuPg.js} +722 -716
- package/dist/{index-CRKFvjZ0.cjs → index-CynCF2eX.cjs} +1 -1
- package/dist/{index-Cgqkv_Dw.js → index-DUF_dJ18.js} +6 -5
- package/dist/{index-FhO0e3y-.js → index-D_WvMmii.js} +6 -5
- package/dist/{index-maKBe62H.cjs → index-DcocnzX5.cjs} +1 -1
- package/dist/{index-BEG0aFwg.js → index-N8f7DBOE.js} +1 -1
- package/dist/{index-BbzAvMs-.js → index-VpU9xAiT.js} +54 -52
- package/dist/index.cjs +1 -1
- package/dist/index.js +13 -13
- package/dist/network.cjs +1 -1
- package/dist/network.js +3 -3
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.js +5 -5
- package/package.json +1 -1
- package/dist/index-GgTn_F27.cjs +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const i=require("react/jsx-runtime"),m=require("react"),ge=require("./gaesupStore-CE-oe63F.cjs"),R=require("./index-GgTn_F27.cjs"),kc=require("zustand/traditional"),Se=require("zustand/shallow");require("react-dom");const be=require("@react-three/fiber"),ct=require("@react-three/rapier"),se=require("./sfe-RrB92jNe.cjs"),bn=require("./assetStore-BuE4mh1C.cjs"),mi=require("./index-DCa_lUwq.cjs"),Bi=require("zustand"),ls=require("zustand/react/shallow"),We=require("./templates-eL763zpL.cjs"),Jn=require("./index-D6pLUicy.cjs"),pt=require("@react-three/drei"),_p=require("three"),ua=require("three-stdlib");require("reflect-metadata");const da=require("./weatherStore-1unmwIen.cjs"),fa=require("simplex-noise"),jp=require("./authStore-CrDnYNnL.cjs");function Mp(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const k=Mp(_p);function Oe({label:e,min:t,max:n,step:o,value:s,suffix:r,onChange:a}){return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:11,color:"#fff"},children:[i.jsx("span",{style:{width:60,flexShrink:0,color:"rgba(255,255,255,0.7)"},children:e}),i.jsx("input",{type:"range",min:t,max:n,step:o,value:s,onChange:l=>a(Number(l.target.value)),style:{flex:1,accentColor:"#0078d4"}}),i.jsxs("span",{style:{width:44,textAlign:"right",fontFamily:"monospace",fontSize:11},children:[typeof o=="number"&&o<1?s.toFixed(2):s,r??""]})]})}function tr({label:e,checked:t,onChange:n}){return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:11,color:"#fff"},children:[i.jsx("input",{type:"checkbox",checked:t,onChange:o=>n(o.target.checked),style:{accentColor:"#0078d4"}}),i.jsx("span",{children:e})]})}function Di({title:e,children:t}){return i.jsxs("div",{style:{background:"rgba(0,0,0,0.2)",borderRadius:6,padding:"8px 10px",border:"1px solid rgba(255,255,255,0.08)",display:"flex",flexDirection:"column",gap:6},children:[i.jsx("div",{style:{fontSize:10,fontWeight:600,color:"rgba(255,255,255,0.5)",textTransform:"uppercase",letterSpacing:.5},children:e}),t]})}function Cp(){const e=ge.useGaesupStore(a=>a.cameraOption),t=ge.useGaesupStore(a=>a.setCameraOption),n=ge.useGaesupStore(a=>a.mode),o=m.useCallback((a,l)=>{t({[a]:l})},[t]),s=m.useCallback((a,l)=>{t({smoothing:{...e.smoothing,[a]:l}})},[t,e.smoothing]),r=a=>e[a]??0;return i.jsxs("div",{style:{padding:10,display:"flex",flexDirection:"column",gap:10},children:[i.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.5)",marginBottom:-4},children:["Mode: ",n.control??"thirdPerson"]}),i.jsxs(Di,{title:"Distance",children:[i.jsx(Oe,{label:"X",min:-50,max:50,step:1,value:r("xDistance"),onChange:a=>o("xDistance",a)}),i.jsx(Oe,{label:"Y",min:0,max:50,step:1,value:r("yDistance"),onChange:a=>o("yDistance",a)}),i.jsx(Oe,{label:"Z",min:-50,max:50,step:1,value:r("zDistance"),onChange:a=>o("zDistance",a)})]}),i.jsxs(Di,{title:"FOV / Smoothing",children:[i.jsx(Oe,{label:"FOV",min:30,max:120,step:5,value:e.fov??75,suffix:"deg",onChange:a=>o("fov",a)}),i.jsx(Oe,{label:"Pos",min:.01,max:1,step:.01,value:e.smoothing?.position??.1,onChange:a=>s("position",a)}),i.jsx(Oe,{label:"Rot",min:.01,max:1,step:.01,value:e.smoothing?.rotation??.1,onChange:a=>s("rotation",a)}),i.jsx(Oe,{label:"FOV Sm",min:.01,max:1,step:.01,value:e.smoothing?.fov??.2,onChange:a=>s("fov",a)})]}),i.jsxs(Di,{title:"Zoom",children:[i.jsx(tr,{label:"Enable Zoom",checked:e.enableZoom??!1,onChange:a=>o("enableZoom",a)}),i.jsx(Oe,{label:"Speed",min:1e-4,max:.01,step:1e-4,value:e.zoomSpeed??.001,onChange:a=>o("zoomSpeed",a)}),i.jsx(Oe,{label:"Min",min:.1,max:2,step:.1,value:e.minZoom??.5,onChange:a=>o("minZoom",a)}),i.jsx(Oe,{label:"Max",min:1,max:5,step:.1,value:e.maxZoom??2,onChange:a=>o("maxZoom",a)})]}),i.jsxs(Di,{title:"Options",children:[i.jsx(tr,{label:"Collision",checked:e.enableCollision??!1,onChange:a=>o("enableCollision",a)}),i.jsx(tr,{label:"Focus Mode",checked:e.enableFocus??!1,onChange:a=>o("enableFocus",a)}),i.jsx(Oe,{label:"Focus Dist",min:1,max:50,step:1,value:e.focusDistance??15,onChange:a=>o("focusDistance",a)}),i.jsx(Oe,{label:"Max Dist",min:5,max:100,step:1,value:e.maxDistance??50,onChange:a=>o("maxDistance",a)})]}),i.jsxs(Di,{title:"Bounds",children:[i.jsx(Oe,{label:"Min Y",min:-10,max:50,step:1,value:e.bounds?.minY??2,onChange:a=>t({bounds:{...e.bounds,minY:a}})}),i.jsx(Oe,{label:"Max Y",min:5,max:100,step:1,value:e.bounds?.maxY??50,onChange:a=>t({bounds:{...e.bounds,maxY:a}})})]})]})}const Np=[{value:"thirdPerson",label:"Third Person"},{value:"firstPerson",label:"First Person"},{value:"chase",label:"Chase"},{value:"topDown",label:"Top Down"},{value:"isometric",label:"Isometric"},{value:"sideScroll",label:"Side-Scroller"},{value:"fixed",label:"Fixed"}];function Tp(){const{mode:e,setMode:t}=ge.useGaesupStore(ls.useShallow(o=>({mode:o.mode,setMode:o.setMode}))),n=e?.control||"thirdPerson";return i.jsx("div",{className:"cc-panel",children:i.jsx("div",{className:"cc-list",children:Np.map(o=>i.jsx("button",{className:`cc-button ${n===o.value?"active":""}`,onClick:()=>t({control:o.value}),children:o.label},o.value))})})}const Ip=[{key:"mode",label:"Mode",enabled:!0,format:"text"},{key:"position",label:"Position",enabled:!0,format:"vector3",precision:2},{key:"distance",label:"Distance",enabled:!0,format:"vector3",precision:2},{key:"fov",label:"FOV",enabled:!0,format:"angle",precision:1},{key:"velocity",label:"Velocity",enabled:!1,format:"vector3",precision:2},{key:"rotation",label:"Rotation",enabled:!1,format:"vector3",precision:2},{key:"zoom",label:"Zoom",enabled:!1,format:"number",precision:2},{key:"activeController",label:"Controller",enabled:!0,format:"text"}];function nr(e){if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.x=="number"&&typeof t.y=="number"&&typeof t.z=="number"}function Bc(){const e={frameCount:0,averageFrameTime:0,lastUpdateTime:Date.now(),mode:"unknown",activeController:"unknown",distance:null,fov:0,position:null,targetPosition:null,velocity:null,rotation:null},[t,n]=m.useState(e),o=ge.useGaesupStore(d=>d.mode),s=ge.useGaesupStore(d=>d.cameraOption),{activeState:r}=R.useStateSystem(),a=m.useRef(e),l=m.useCallback((d,p)=>d===p?!1:nr(d)?nr(p)?d.x!==p.x||d.y!==p.y||d.z!==p.z:!0:typeof d!="object"||d===null?!0:JSON.stringify(d)!==JSON.stringify(p),[]),c=m.useCallback(d=>nr(d)?{x:d.x,y:d.y,z:d.z}:null,[]),u=m.useCallback(()=>{const d=s?.xDistance!==void 0&&s?.yDistance!==void 0&&s?.zDistance!==void 0?{x:s.xDistance,y:s.yDistance,z:s.zDistance}:null,p={...a.current,mode:o?.control??"unknown",activeController:s?.mode??o?.control??"unknown",distance:d,fov:s?.fov??0,position:c(r?.position),targetPosition:c(s?.target),velocity:c(r?.velocity),rotation:c(r?.euler),lastUpdateTime:Date.now(),...s?.zoom!==void 0?{zoom:s.zoom}:{}};Object.keys(p).some(v=>l(p[v],a.current[v]))&&(a.current=p,n(p))},[o,s,r,l,c]);m.useEffect(()=>{u();const d=setInterval(u,100);return()=>{clearInterval(d)}},[u]);const f=m.useCallback((d,p=2)=>d==null?"N/A":typeof d=="object"&&d.x!==void 0?`X:${d.x.toFixed(p)} Y:${d.y.toFixed(p)} Z:${d.z.toFixed(p)}`:typeof d=="number"?d.toFixed(p):d.toString(),[]);return i.jsx("div",{className:"cd-panel",children:i.jsx("div",{className:"cd-grid",children:Ip.map(d=>i.jsxs("div",{className:"cd-item",children:[i.jsx("span",{className:"cd-label",children:d.label}),i.jsx("span",{className:"cd-value",children:f(t[d.key])})]},d.key))})})}const Ep=[{id:"classic",name:"Classic",description:"A traditional third-person view.",icon:"camera",config:{mode:"thirdPerson",distance:{x:0,y:8,z:10},fov:75,smoothing:{position:.1,rotation:.1,fov:.1}}},{id:"cinematic",name:"Cinematic",description:"Smooth, movie-like camera work.",icon:"camera",config:{mode:"chase",distance:{x:2,y:7,z:8},fov:60,smoothing:{position:.05,rotation:.05,fov:.05}}},{id:"action",name:"Action",description:"Responsive camera for fast gameplay.",icon:"camera",config:{mode:"thirdPerson",distance:{x:0,y:6,z:6},fov:85,smoothing:{position:.2,rotation:.2,fov:.2}}},{id:"strategy",name:"Strategy",description:"Top-down view for an overview.",icon:"camera",config:{mode:"topDown",distance:{x:0,y:20,z:0},fov:45,smoothing:{position:.1,rotation:.1,fov:.1}}},{id:"retro",name:"Retro",description:"Classic side-scroller style.",icon:"camera",config:{mode:"sideScroll",distance:{x:15,y:0,z:0},fov:75,smoothing:{position:.15,rotation:.15,fov:.15}}}];function Ap(e,t){return!e||!t?!1:e.x===t.x&&e.y===t.y&&e.z===t.z}function kp(e){const t=e?.xDistance,n=e?.yDistance,o=e?.zDistance;if(!(t===void 0||n===void 0||o===void 0))return{x:t,y:n,z:o}}function Pc(){const[e]=m.useState(Ep),t=ge.useGaesupStore(c=>c.setMode),n=ge.useGaesupStore(c=>c.setCameraOption),o=ge.useGaesupStore(c=>c.mode),s=ge.useGaesupStore(c=>c.cameraOption),[r,a]=m.useState(null),l=m.useCallback(c=>{t({control:c.config.mode}),n({xDistance:c.config.distance.x,yDistance:c.config.distance.y,zDistance:c.config.distance.z,fov:c.config.fov,smoothing:c.config.smoothing||{position:.1,rotation:.1,fov:.1}})},[t,n,s]);return m.useEffect(()=>{const c=e.find(u=>u.config.mode===o?.control&&Ap(u.config.distance,kp(s)));a(c?c.id:null)},[o,s,e]),i.jsx("div",{className:"cp-panel",children:i.jsx("div",{className:"cp-grid",children:e.map(c=>i.jsxs("button",{className:`cp-item ${r===c.id?"active":""}`,onClick:()=>l(c),children:[i.jsx("div",{className:"cp-name",children:c.name}),i.jsx("div",{className:"cp-description",children:c.description})]},c.id))})})}function Rc({className:e="",style:t,children:n}={}){const[o,s]=m.useState("Settings"),r=()=>{switch(o){case"Settings":return i.jsx(Cp,{});case"Controller":return i.jsx(Tp,{});case"Presets":return i.jsx(Pc,{});case"Debug":return i.jsx(Bc,{});default:return null}};return i.jsxs("div",{className:`tabbed-panel ${e}`,style:t,children:[i.jsxs("div",{className:"panel-tabs",children:[i.jsx("button",{className:`panel-tab ${o==="Settings"?"active":""}`,onClick:()=>s("Settings"),children:"Settings"}),i.jsx("button",{className:`panel-tab ${o==="Controller"?"active":""}`,onClick:()=>s("Controller"),children:"Controller"}),i.jsx("button",{className:`panel-tab ${o==="Presets"?"active":""}`,onClick:()=>s("Presets"),children:"Presets"}),i.jsx("button",{className:`panel-tab ${o==="Debug"?"active":""}`,onClick:()=>s("Debug"),children:"Debug"})]}),i.jsxs("div",{className:"panel-tab-content",children:[r(),n]})]})}const Bp=[{value:"idle",label:"Idle"},{value:"walk",label:"Walk"},{value:"run",label:"Run"},{value:"jump",label:"Jump"},{value:"fall",label:"Fall"},{value:"dance",label:"Dance"},{value:"wave",label:"Wave"}];function Pp(){const{playAnimation:e,currentType:t,currentAnimation:n}=R.useAnimationBridge(),o=s=>{e(t,s)};return i.jsx("div",{className:"ac-panel",children:i.jsx("div",{className:"ac-grid",children:Bp.map(s=>i.jsx("button",{className:`ac-button ${s.value===n?"active":""}`,onClick:()=>o(s.value),title:s.label,children:s.label},s.value))})})}const Rp=[{key:"currentAnimation",label:"현재 애니메이션",format:"text",enabled:!0},{key:"animationType",label:"애니메이션 타입",format:"text",enabled:!0},{key:"isPlaying",label:"재생 상태",format:"text",enabled:!0},{key:"weight",label:"가중치",format:"number",enabled:!0},{key:"speed",label:"속도",format:"number",enabled:!0},{key:"blendDuration",label:"블렌드 시간",format:"number",enabled:!1},{key:"activeActions",label:"활성 액션",format:"number",enabled:!0},{key:"availableAnimations",label:"사용 가능 애니메이션",format:"array",enabled:!1},{key:"frameCount",label:"프레임 카운트",format:"number",enabled:!1},{key:"averageFrameTime",label:"평균 프레임 시간",format:"number",enabled:!1}];function Dc(){const{bridge:e,currentType:t}=R.useAnimationBridge(),[n,o]=m.useState({frameCount:0,averageFrameTime:0,lastUpdateTime:Date.now(),currentAnimation:"idle",animationType:"character",availableAnimations:[],isPlaying:!1,weight:1,speed:1,blendDuration:.3,activeActions:0});m.useEffect(()=>{if(!e)return;const a=()=>{const c=e.snapshot(t);if(!c)return;const u=e.getMetrics(t);o(f=>({...f,currentAnimation:c.currentAnimation,animationType:t,availableAnimations:c.availableAnimations,isPlaying:c.isPlaying,weight:c.weight,speed:c.speed,activeActions:c.metrics.activeAnimations,frameCount:u?.totalActions||0,averageFrameTime:u?.mixerTime||0,lastUpdateTime:Date.now()}))};return a(),e.subscribe((c,u)=>{u===t&&a()})},[e,t]);const s=(a,l,c=2)=>{if(a==null)return"N/A";switch(l){case"array":return Array.isArray(a)?`${a.length} animations`:String(a);case"boolean":return a?"Yes":"No";case"number":return typeof a=="number"?a.toFixed(c):String(a);default:return String(a)}},r=a=>{if(a in n)return n[a]};return i.jsx("div",{className:"ad-panel",children:i.jsx("div",{className:"ad-content",children:Rp.filter(a=>a.enabled).map(a=>i.jsxs("div",{className:"ad-item",children:[i.jsx("span",{className:"ad-label",children:a.label}),i.jsx("span",{className:"ad-value",children:s(r(a.key),a.format)})]},a.key))})})}const Dp=()=>i.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:i.jsx("path",{d:"M8 5v14l11-7z"})}),Fp=()=>i.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:i.jsx("path",{d:"M6 19h4V5H6v14zm8-14v14h4V5h-4z"})}),Lp=()=>i.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:i.jsx("path",{d:"M6 6h2v12H6zm3.5 6l8.5 6V6z"})}),zp=()=>i.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:i.jsx("path",{d:"M6 18l8.5-6L6 6v12zM16 6v12h2V6h-2z"})});function Op(){const{bridge:e,playAnimation:t,stopAnimation:n,currentType:o,currentAnimation:s}=R.useAnimationBridge(),[r,a]=m.useState(!1),[l,c]=m.useState([]),[u,f]=m.useState(30);m.useEffect(()=>{if(!e)return;const p=()=>{const v=e.snapshot(o);v&&(a(v.isPlaying),c(v.availableAnimations))};return p(),e.subscribe((v,b)=>{b===o&&p()})},[e,o]);const d=()=>{r?n(o):t(o,s)};return i.jsxs("div",{className:"ap-panel",children:[i.jsxs("div",{className:"ap-controls",children:[i.jsx("select",{className:"ap-select",value:s,onChange:p=>t(o,p.target.value),children:l.map(p=>i.jsx("option",{value:p,children:p},p))}),i.jsxs("div",{className:"ap-buttons",children:[i.jsx("button",{className:"ap-btn","aria-label":"previous animation",children:i.jsx(Lp,{})}),i.jsx("button",{className:"ap-btn-primary",onClick:d,"aria-label":r?"pause":"play",children:r?i.jsx(Fp,{}):i.jsx(Dp,{})}),i.jsx("button",{className:"ap-btn","aria-label":"next animation",children:i.jsx(zp,{})})]})]}),i.jsxs("div",{className:"ap-timeline",children:[i.jsx("span",{className:"ap-time",children:"0:00"}),i.jsx("input",{type:"range",className:"ap-slider",min:"0",max:"100",value:u,onChange:p=>f(Number(p.target.value))}),i.jsx("span",{className:"ap-time",children:"1:30"})]})]})}function Fc({className:e="",style:t,children:n}={}){const[o,s]=m.useState("Player"),r=()=>{switch(o){case"Player":return i.jsx("div",{className:"panel-content-wrapper",children:i.jsx(Op,{})});case"Controller":return i.jsx("div",{className:"panel-content-wrapper",children:i.jsx(Pp,{})});case"Debug":return i.jsx("div",{className:"panel-content-wrapper",children:i.jsx(Dc,{})});default:return null}};return i.jsxs("div",{className:`tabbed-panel ${e}`,style:t,children:[i.jsxs("div",{className:"panel-tabs",children:[i.jsx("button",{className:`panel-tab ${o==="Player"?"active":""}`,onClick:()=>s("Player"),children:"Player"}),i.jsx("button",{className:`panel-tab ${o==="Controller"?"active":""}`,onClick:()=>s("Controller"),children:"Controller"}),i.jsx("button",{className:`panel-tab ${o==="Debug"?"active":""}`,onClick:()=>s("Debug"),children:"Debug"})]}),i.jsxs("div",{className:"panel-tab-content",children:[r(),n]})]})}const Ka=[{id:"slow",name:"Slow",maxSpeed:5,acceleration:8},{id:"normal",name:"Normal",maxSpeed:10,acceleration:15},{id:"fast",name:"Fast",maxSpeed:20,acceleration:25},{id:"sprint",name:"Sprint",maxSpeed:35,acceleration:40}],qa=[{id:"eco",name:"Eco",maxSpeed:15,acceleration:10},{id:"comfort",name:"Comfort",maxSpeed:25,acceleration:20},{id:"sport",name:"Sport",maxSpeed:40,acceleration:35},{id:"turbo",name:"Turbo",maxSpeed:60,acceleration:50}];function $p(e,t){const n=e??"bottom-left",o={position:"fixed",zIndex:t??1e4};return n.includes("top")&&(o.top=12),n.includes("bottom")&&(o.bottom=12),n.includes("left")&&(o.left=12),n.includes("right")&&(o.right=12),o}function Lc(e){const t=$p(e.position,e.zIndex),n=ge.useGaesupStore(p=>p.mode),o=ge.useGaesupStore(p=>p.setMode),s=ge.useGaesupStore(p=>p.setPhysics),r=n?.type==="vehicle"?"vehicle":"character",a=r==="vehicle"?qa:Ka,[l,c]=m.useState(r==="vehicle"?"comfort":"normal"),u=m.useCallback((p,h)=>{const b=(p==="vehicle"?qa:Ka).find(S=>S.id===h);if(b){if(p==="vehicle"){s({maxSpeed:b.maxSpeed,accelRatio:b.acceleration});return}s({walkSpeed:Math.max(1,b.maxSpeed*.5),runSpeed:b.maxSpeed,accelRatio:b.acceleration})}},[s]),f=m.useCallback(p=>{c(p),u(r,p),e.onPresetChange?.(p)},[u,r,e]),d=m.useCallback(p=>{const h=p.target.value;o({type:h});const v=h==="vehicle"?"comfort":"normal";c(v),u(h,v),e.onPresetChange?.(v)},[u,o,e]);return i.jsxs("div",{className:`mc-panel ${e.compact?"compact":""}`,style:t,children:[i.jsxs("div",{className:"mc-setting-row",children:[i.jsx("label",{htmlFor:"motion-type-select",className:"mc-label",children:"Motion Type"}),i.jsxs("select",{id:"motion-type-select",className:"mc-select",value:r,onChange:d,children:[i.jsx("option",{value:"character",children:"Character"}),i.jsx("option",{value:"vehicle",children:"Vehicle"})]})]}),i.jsxs("div",{className:"mc-setting-row",children:[i.jsx("label",{className:"mc-label",children:"Presets"}),i.jsx("div",{className:"mc-presets-grid",children:a.map(p=>i.jsx("button",{className:`mc-preset-btn ${p.id===l?"active":""}`,onClick:()=>f(p.id),title:`Max Speed: ${p.maxSpeed}, Accel: ${p.acceleration}`,children:p.name},p.id))})]})]})}const Qa=[{key:"motionType",label:"Motion Type",type:"text"},{key:"position",label:"Position",type:"vector3"},{key:"velocity",label:"Velocity",type:"vector3"},{key:"speed",label:"Speed",type:"number"},{key:"direction",label:"Direction",type:"vector3"},{key:"isGrounded",label:"Grounded",type:"text"},{key:"isMoving",label:"Moving",type:"text"},{key:"acceleration",label:"Acceleration",type:"number"},{key:"jumpForce",label:"Jump Force",type:"number"},{key:"maxSpeed",label:"Max Speed",type:"number"},{key:"totalDistance",label:"Total Distance",type:"number"},{key:"gameState",label:"Game State",type:"text"}];function Gp(e,t){const n=e??"top-right",o={position:"fixed",zIndex:t??1e4};return n.includes("top")&&(o.top=12),n.includes("bottom")&&(o.bottom=12),n.includes("left")&&(o.left=12),n.includes("right")&&(o.right=12),o}function zc(e){const t=e.embedded?{}:Gp(e.position,e.zIndex),n=ge.useGaesupStore(f=>f.mode),o=ge.useGaesupStore(f=>f.physics),{activeState:s,gameStates:r}=R.useStateSystem(),a=e.precision??2,l=e.customFields?[...Qa,...e.customFields]:Qa,c=(f,d,p=2)=>{if(d==null)return"N/A";switch(f.type){case"vector3":if(Array.isArray(d)&&d.length===3){const[h,v,b]=d;return`X:${h.toFixed(p)} Y:${v.toFixed(p)} Z:${b.toFixed(p)}`}if(typeof d=="object"&&d!==null&&"x"in d&&"y"in d&&"z"in d){const h=d;return`X:${h.x.toFixed(p)} Y:${h.y.toFixed(p)} Z:${h.z.toFixed(p)}`}return String(d);case"number":return typeof d=="number"?d.toFixed(p):String(d);default:return String(d)}},u=f=>{if(f.value!==void 0)return f.value;switch(f.key){case"motionType":return n?.type??"character";case"position":return s?.position?{x:s.position.x,y:s.position.y,z:s.position.z}:{x:0,y:0,z:0};case"velocity":return s?.velocity?{x:s.velocity.x,y:s.velocity.y,z:s.velocity.z}:{x:0,y:0,z:0};case"speed":return s?.velocity?s.velocity.length():0;case"direction":return s?.direction?{x:s.direction.x,y:s.direction.y,z:s.direction.z}:{x:0,y:0,z:0};case"isGrounded":return r?.isOnTheGround?"Yes":"No";case"isMoving":return r?.isMoving?"Yes":"No";case"acceleration":return o?.accelRatio??0;case"jumpForce":return o?.jumpSpeed??0;case"maxSpeed":return n?.type==="character"?o?.runSpeed??0:o?.maxSpeed??0;case"totalDistance":return 0;case"gameState":return r?.isRiding?"riding":r?.isOnTheGround?"ground":"air";default:return null}};return i.jsx("div",{className:`md-panel ${e.compact?"compact":""} ${e.theme?`theme-${e.theme}`:""}`,style:t,children:i.jsx("div",{className:"md-content",children:l.map(f=>i.jsxs("div",{className:"md-item",children:[i.jsx("span",{className:"md-label",children:f.label}),i.jsx("span",{className:"md-value",children:c(f,u(f),a)})]},f.key))})})}function Oc({className:e="",style:t,children:n}={}){const[o,s]=m.useState("Controller"),r=()=>{switch(o){case"Controller":return i.jsx("div",{className:"panel-content-wrapper",children:i.jsx(Lc,{})});case"Debug":return i.jsx("div",{className:"panel-content-wrapper",children:i.jsx(zc,{embedded:!0})});default:return null}};return i.jsxs("div",{className:`tabbed-panel ${e}`,style:t,children:[i.jsxs("div",{className:"panel-tabs",children:[i.jsx("button",{className:`panel-tab ${o==="Controller"?"active":""}`,onClick:()=>s("Controller"),children:"Controller"}),i.jsx("button",{className:`panel-tab ${o==="Debug"?"active":""}`,onClick:()=>s("Debug"),children:"Debug"})]}),i.jsxs("div",{className:"panel-tab-content",children:[r(),n]})]})}const Io=60,Eo=({data:e,color:t,max:n,warn:o})=>{const r=e.filter(c=>isFinite(c));if(r.length<2)return null;const a=Math.max(1,n),l=r.map((c,u)=>{const f=u/(r.length-1)*100,d=40-c/a*40;return`${u===0?"M":"L"}${f.toFixed(2)},${d.toFixed(2)}`}).join(" ");return i.jsx("div",{className:"perf-chart",children:i.jsxs("svg",{width:"100%",height:40,preserveAspectRatio:"none",viewBox:"0 0 100 40",children:[o!==void 0&&i.jsx("line",{x1:"0",y1:40-o/a*40,x2:"100",y2:40-o/a*40,stroke:"#facc15",strokeWidth:"0.5",strokeDasharray:"3,3",opacity:.5}),i.jsx("path",{d:l,fill:"none",stroke:t,strokeWidth:"2",strokeLinejoin:"round",strokeLinecap:"round"})]})})},ir=({value:e,max:t,color:n,label:o})=>{const s=t>0?Math.min(100,e/t*100):0;return i.jsxs("div",{style:{marginBottom:4},children:[i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:10,marginBottom:2},children:[i.jsx("span",{className:"perf-label",children:o}),i.jsx("span",{children:e.toFixed(1)})]}),i.jsx("div",{style:{height:4,background:"#1e293b",borderRadius:2,overflow:"hidden"},children:i.jsx("div",{style:{width:`${s}%`,height:"100%",background:n,borderRadius:2,transition:"width 0.3s"}})})]})};function $c({className:e="",style:t,children:n}={}){const o=ge.useGaesupStore(ls.useShallow(P=>P.performance)),[s,r]=m.useState({current:0,min:1/0,max:0,avg:0,p1Low:0,history:Array(Io).fill(0)}),[a,l]=m.useState({used:0,limit:0,history:Array(Io).fill(0)}),[c,u]=m.useState(0),[f,d]=m.useState(Array(Io).fill(0)),[p,h]=m.useState(Array(Io).fill(0)),v=m.useRef(0),b=m.useRef(0),S=m.useRef(0),x=m.useRef([]),_=m.useRef(0),g=m.useRef(null),y=m.useRef(0),w=m.useRef(0),j=m.useRef(0),N=m.useCallback(P=>{if(P.length<5)return 0;const L=[...P].filter(U=>U>0).sort((U,V)=>U-V),M=Math.max(1,Math.floor(L.length*.01));let F=0;for(let U=0;U<M;U++)F+=L[U]??0;return F/M},[]);m.useEffect(()=>{const P=window.performance.now();v.current=P,b.current=P,_.current=P;const L=M=>{const F=M-b.current;if(b.current=M,x.current.push(F),x.current.length>300&&x.current.shift(),y.current+=F,w.current++,w.current>=10){const U=y.current/w.current;u(U),h(V=>[...V.slice(1),U]),y.current=0,w.current=0}if(S.current++,M-v.current>=500){const U=S.current*1e3/(M-v.current),V=x.current.map(q=>q>0?1e3/q:0),Y=M-_.current>3e3;r(q=>{const X=[...q.history.slice(1),U],A=Y?Math.min(q.min===1/0?U:q.min,U):1/0,C=Y?Math.max(q.max,U):0,H=Y?X.filter(ee=>ee>0):[],K=H.length>0?H.reduce((ee,ne)=>ee+ne,0)/H.length:U,Q=Y?N(V):U;return{current:U,min:A,max:C,avg:K,p1Low:Q,history:X}});const Z=window.performance.memory;Z&&l(q=>{const X=Math.round(Z.usedJSHeapSize/1048576),A=Math.round(Z.jsHeapSizeLimit/1048576);return{used:X,limit:A,history:[...q.history.slice(1),X]}}),v.current=M,S.current=0}g.current=requestAnimationFrame(L)};return g.current=requestAnimationFrame(L),()=>{g.current&&cancelAnimationFrame(g.current)}},[N]),m.useEffect(()=>{const P=o.render.calls;P!==j.current&&(j.current=P,d(L=>[...L.slice(1),P]))},[o.render.calls]);const B=P=>P>=55?"#4ade80":P>=30?"#facc15":"#f87171",z=P=>P<=16.7?"#4ade80":P<=33.3?"#facc15":"#f87171",W=P=>P<=100?"#4ade80":P<=300?"#facc15":"#f87171",D=(P,L)=>{const M=L>0?P/L*100:0;return M<60?"#4ade80":M<80?"#facc15":"#f87171"},E=o.render.triangles,G=o.render.calls,T=o.engine.geometries,O=o.engine.textures;return i.jsxs("div",{className:`perf-panel ${e}`,style:t,children:[i.jsxs("div",{className:"perf-stat-group",children:[i.jsxs("div",{className:"perf-header",children:[i.jsx("h4",{className:"perf-title",children:"Frame Rate"}),i.jsxs("span",{className:"perf-current",style:{color:B(s.current)},children:[s.current.toFixed(0)," FPS"]})]}),i.jsxs("div",{className:"perf-details-grid",children:[i.jsxs("div",{children:[i.jsx("span",{className:"perf-label",children:"Avg"}),s.avg.toFixed(1)]}),i.jsxs("div",{children:[i.jsx("span",{className:"perf-label",children:"Min"}),isFinite(s.min)?s.min.toFixed(1):"..."]}),i.jsxs("div",{children:[i.jsx("span",{className:"perf-label",children:"Max"}),s.max.toFixed(1)]}),i.jsxs("div",{children:[i.jsx("span",{className:"perf-label",children:"1% Low"}),i.jsx("span",{style:{color:B(s.p1Low)},children:s.p1Low.toFixed(1)})]})]}),i.jsx(Eo,{data:s.history,color:B(s.current),max:90,warn:60})]}),i.jsxs("div",{className:"perf-stat-group",children:[i.jsxs("div",{className:"perf-header",children:[i.jsx("h4",{className:"perf-title",children:"Frame Time"}),i.jsxs("span",{className:"perf-current",style:{color:z(c)},children:[c.toFixed(2)," ms"]})]}),i.jsx(ir,{value:c,max:33.3,color:z(c),label:"Budget (16.7ms)"}),i.jsx(Eo,{data:p,color:z(c),max:33.3,warn:16.7})]}),i.jsxs("div",{className:"perf-stat-group",children:[i.jsxs("div",{className:"perf-header",children:[i.jsx("h4",{className:"perf-title",children:"GPU Pipeline"}),i.jsxs("span",{className:"perf-current",style:{color:W(G)},children:[G," calls"]})]}),i.jsxs("div",{className:"perf-details-grid",children:[i.jsxs("div",{children:[i.jsx("span",{className:"perf-label",children:"Triangles"}),E>=1e6?(E/1e6).toFixed(2)+"M":E>=1e3?(E/1e3).toFixed(1)+"K":E]}),i.jsxs("div",{children:[i.jsx("span",{className:"perf-label",children:"Draw Calls"}),i.jsx("span",{style:{color:W(G)},children:G})]}),i.jsxs("div",{children:[i.jsx("span",{className:"perf-label",children:"Tri/Call"}),G>0?Math.round(E/G):0]}),i.jsxs("div",{children:[i.jsx("span",{className:"perf-label",children:"Points"}),o.render.points]})]}),i.jsx(Eo,{data:f,color:W(G),max:Math.max(200,...f)})]}),i.jsxs("div",{className:"perf-stat-group",children:[i.jsx("div",{className:"perf-header",children:i.jsx("h4",{className:"perf-title",children:"Resources"})}),i.jsxs("div",{className:"perf-details-grid",children:[i.jsxs("div",{children:[i.jsx("span",{className:"perf-label",children:"Geometries"}),T]}),i.jsxs("div",{children:[i.jsx("span",{className:"perf-label",children:"Textures"}),O]}),i.jsxs("div",{children:[i.jsx("span",{className:"perf-label",children:"Programs"}),o.engine.programs]}),i.jsxs("div",{children:[i.jsx("span",{className:"perf-label",children:"Lines"}),o.render.lines]})]}),i.jsx(ir,{value:T,max:200,color:T>150?"#f87171":"#4ade80",label:"Geometry Budget"}),i.jsx(ir,{value:O,max:100,color:O>80?"#f87171":"#4ade80",label:"Texture Budget"})]}),i.jsxs("div",{className:"perf-stat-group",children:[i.jsxs("div",{className:"perf-header",children:[i.jsx("h4",{className:"perf-title",children:"Memory"}),i.jsxs("span",{className:"perf-current",style:{color:D(a.used,a.limit)},children:[a.used," MB"]})]}),i.jsxs("div",{className:"perf-details-grid",children:[i.jsxs("div",{children:[i.jsx("span",{className:"perf-label",children:"Limit"}),a.limit," MB"]}),i.jsxs("div",{children:[i.jsx("span",{className:"perf-label",children:"Usage"}),a.limit>0?(a.used/a.limit*100).toFixed(0):0,"%"]})]}),i.jsx(Eo,{data:a.history,color:D(a.used,a.limit),max:a.limit||1})]}),n]})}const Gc=({className:e="",style:t,children:n})=>{const o=ge.useGaesupStore(l=>l.mode),s=ge.useGaesupStore(l=>l.setMode),r=l=>{s({type:l,controller:"keyboard",control:l==="airplane"||l==="vehicle"?"chase":"thirdPerson"})},a=[{type:"character",label:"Character",description:"Walk around as character"},{type:"vehicle",label:"Vehicle",description:"Drive a ground vehicle"},{type:"airplane",label:"Airplane",description:"Fly an airplane"}];return i.jsxs("div",{className:`vehicle-panel ${e}`,style:t,children:[i.jsx("div",{className:"vehicle-panel__modes",children:a.map(l=>i.jsxs("button",{className:`vehicle-panel__mode-button ${o.type===l.type?"vehicle-panel__mode-button--active":""}`,onClick:()=>r(l.type),children:[i.jsx("span",{className:"vehicle-panel__mode-label",children:l.label}),i.jsx("span",{className:"vehicle-panel__mode-description",children:l.description})]},l.type))}),i.jsxs("div",{className:"vehicle-panel__info",children:[i.jsxs("div",{className:"vehicle-panel__info-item",children:[i.jsx("span",{className:"vehicle-panel__info-label",children:"Current Mode:"}),i.jsx("span",{className:"vehicle-panel__info-value",children:o.type})]}),i.jsxs("div",{className:"vehicle-panel__info-item",children:[i.jsx("span",{className:"vehicle-panel__info-label",children:"Controls:"}),i.jsx("span",{className:"vehicle-panel__info-value",children:o.type==="airplane"?"WASD + Space/Shift":"WASD + Space"})]})]}),n]})},vi=[{id:"door-basic",label:"Door",category:"structure",fallbackKind:"door",defaultScale:1,defaultColor:"#8b5a2b",modelUrl:"gltf/props/door.glb"},{id:"window-basic",label:"Window",category:"structure",fallbackKind:"window",defaultScale:1,defaultColor:"#9fd3ff",modelUrl:"gltf/props/window.glb"},{id:"fence-basic",label:"Fence",category:"structure",fallbackKind:"fence",defaultScale:1,defaultColor:"#8f6a3d",modelUrl:"gltf/props/fence.glb"},{id:"lamp-basic",label:"Lamp",category:"utility",fallbackKind:"lamp",defaultScale:1,defaultColor:"#ffd166",modelUrl:"gltf/props/lamp.glb"},{id:"chair-basic",label:"Chair",category:"furniture",fallbackKind:"chair",defaultScale:1,defaultColor:"#a6784f",modelUrl:"gltf/props/chair.glb"},{id:"table-basic",label:"Table",category:"furniture",fallbackKind:"table",defaultScale:1,defaultColor:"#9b6b43",modelUrl:"gltf/props/table.glb"},{id:"bed-basic",label:"Bed",category:"furniture",fallbackKind:"bed",defaultScale:1,defaultColor:"#7aa2ff",modelUrl:"gltf/props/bed.glb"},{id:"storage-basic",label:"Storage",category:"furniture",fallbackKind:"storage",defaultScale:1,defaultColor:"#7c5c3e",modelUrl:"gltf/props/storage.glb"},{id:"mailbox-basic",label:"Mailbox",category:"utility",fallbackKind:"mailbox",defaultScale:1,defaultColor:"#d04f45",modelUrl:"gltf/props/mailbox.glb"},{id:"crafting-basic",label:"Crafting Station",category:"utility",fallbackKind:"crafting",defaultScale:1,defaultColor:"#b68553",modelUrl:"gltf/props/crafting.glb"},{id:"shop-stall-basic",label:"Shop Stall",category:"shop",fallbackKind:"shop",defaultScale:1,defaultColor:"#d88f45",modelUrl:"gltf/props/shop-stall.glb"}];function Ts(e){return vi.find(t=>t.id===e)}function ue({label:e,children:t}){return i.jsxs("div",{className:"editor-field-row",children:[i.jsx("span",{className:"editor-field-row__label",children:e}),i.jsx("div",{className:"editor-field-row__control",children:t})]})}function Lr({value:e,onChange:t}){return i.jsx("button",{type:"button",className:`editor-field-toggle ${e?"editor-field-toggle--on":""}`,onClick:()=>t(!e),children:e?"ON":"OFF"})}function no({value:e,onChange:t}){return i.jsxs("div",{className:"editor-field-color",children:[i.jsx("input",{type:"color",value:e,onChange:n=>t(n.target.value)}),i.jsx("span",{children:e})]})}function pa(e){return`${e}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}const Hp=e=>e.kind==="material"||e.kind==="wall"||e.kind==="tile",or=pa;function Ja(e,t,n){const{mapTextureUrl:o,textureUrl:s,materialParams:r,...a}=n??{};return{...a,id:e,color:t,material:"STANDARD",materialParams:{...r??{},color:t}}}function Yi(e){return`${e}-${Date.now()}`}function Ao(e){return e==="questStatus"?{id:Yi("condition-quest"),type:"condition",label:"Quest Active",condition:{type:"questStatus",questId:"welcome",status:"active"}}:e==="friendshipAtLeast"?{id:Yi("condition-friendship"),type:"condition",label:"Friendship Gate",condition:{type:"friendshipAtLeast",score:150}}:{id:Yi("condition-idle"),type:"condition",label:"Navigation Idle",condition:{type:"navigationIdle"}}}function Zi(e,t){return e==="speak"?{id:Yi("speak"),type:"action",label:"Speak",action:{type:"speak",text:"안녕?",duration:2}}:{id:Yi("wander"),type:"action",label:"Wander",action:{type:"wander",radius:t?.wanderRadius??4,speed:t?.speed??2.2}}}function Xi(e){return e.label?e.label:e.type==="start"?"Start":e.type==="condition"?`Condition: ${e.condition.type}`:`Action: ${e.action.type}`}function Wp(e){return e.type==="start"?"블루프린트 실행 시작점":e.type==="condition"?e.condition.type==="questStatus"?`quest ${e.condition.questId} is ${e.condition.status}`:e.condition.type==="friendshipAtLeast"?`friendship >= ${e.condition.score}`:e.condition.type:e.action.type==="moveToTarget"?`moveTo ${e.action.target.type}`:e.action.type==="speak"?e.action.text:e.action.type==="playAnimation"?e.action.animationId:e.action.type}function Ki(e,t){const n=e.nodes[e.nodes.length-1],o=n?{id:`${n.id}-${t.id}`,source:n.id,target:t.id,branch:"next"}:void 0;return{...e,nodes:[...e.nodes,t],edges:o?[...e.edges,o]:e.edges}}function ko(e,t,n){if(t.type!=="condition")return Ki(e,t);const o=Ki(e,t),s=Zi("wander",n),r=Zi("speak",n),a={...s,label:s.label??"True Path"},l={...r,label:r.label??"False Path"};return{...o,nodes:[...o.nodes,a,l],edges:[...o.edges,{id:`${t.id}-true-${a.id}`,source:t.id,target:a.id,branch:"true"},{id:`${t.id}-false-${l.id}`,source:t.id,target:l.id,branch:"false"}]}}function Up(e,t){const n=e.nodes.find(o=>o.id===t);return!n||n.type==="start"?e:{...e,nodes:e.nodes.filter(o=>o.id!==t),edges:e.edges.filter(o=>o.source!==t&&o.target!==t)}}function Vp(e){return{...e,nodes:[{id:"start",type:"start",label:"Start"}],edges:[]}}function Yp(e,t){return{...e,id:`npc-custom-${t}-${Date.now()}`,name:`${e.name} Custom`,description:e.description?`${e.description} Customized for ${t}.`:`Customized for ${t}.`,nodes:e.nodes.map(n=>({...n})),edges:e.edges.map(n=>({...n}))}}function Zp(e,t){const n=new Map(e.nodes.map(s=>[s.id,s])),o=e.edges.filter(s=>s.source===t);return o.length===0?"다음 없음":o.map(s=>{const r=n.get(s.target);return`${s.branch??"next"} -> ${r?Xi(r):s.target}`}).join(" · ")}function Ee(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,o;n<e.length;n++)(o=Ee(e[n]))!==""&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Xp={value:()=>{}};function Is(){for(var e=0,t=arguments.length,n={},o;e<t;++e){if(!(o=arguments[e]+"")||o in n||/[\s.]/.test(o))throw new Error("illegal type: "+o);n[o]=[]}return new es(n)}function es(e){this._=e}function Kp(e,t){return e.trim().split(/^|\s+/).map(function(n){var o="",s=n.indexOf(".");if(s>=0&&(o=n.slice(s+1),n=n.slice(0,s)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:o}})}es.prototype=Is.prototype={constructor:es,on:function(e,t){var n=this._,o=Kp(e+"",n),s,r=-1,a=o.length;if(arguments.length<2){for(;++r<a;)if((s=(e=o[r]).type)&&(s=qp(n[s],e.name)))return s;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++r<a;)if(s=(e=o[r]).type)n[s]=el(n[s],e.name,t);else if(t==null)for(s in n)n[s]=el(n[s],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new es(e)},call:function(e,t){if((s=arguments.length-2)>0)for(var n=new Array(s),o=0,s,r;o<s;++o)n[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(r=this._[e],o=0,s=r.length;o<s;++o)r[o].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],s=0,r=o.length;s<r;++s)o[s].value.apply(t,n)}};function qp(e,t){for(var n=0,o=e.length,s;n<o;++n)if((s=e[n]).name===t)return s.value}function el(e,t,n){for(var o=0,s=e.length;o<s;++o)if(e[o].name===t){e[o]=Xp,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var zr="http://www.w3.org/1999/xhtml";const tl={svg:"http://www.w3.org/2000/svg",xhtml:zr,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Es(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),tl.hasOwnProperty(t)?{space:tl[t],local:e}:e}function Qp(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===zr&&t.documentElement.namespaceURI===zr?t.createElement(e):t.createElementNS(n,e)}}function Jp(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Hc(e){var t=Es(e);return(t.local?Jp:Qp)(t)}function eh(){}function ha(e){return e==null?eh:function(){return this.querySelector(e)}}function th(e){typeof e!="function"&&(e=ha(e));for(var t=this._groups,n=t.length,o=new Array(n),s=0;s<n;++s)for(var r=t[s],a=r.length,l=o[s]=new Array(a),c,u,f=0;f<a;++f)(c=r[f])&&(u=e.call(c,c.__data__,f,r))&&("__data__"in c&&(u.__data__=c.__data__),l[f]=u);return new Ye(o,this._parents)}function nh(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function ih(){return[]}function Wc(e){return e==null?ih:function(){return this.querySelectorAll(e)}}function oh(e){return function(){return nh(e.apply(this,arguments))}}function sh(e){typeof e=="function"?e=oh(e):e=Wc(e);for(var t=this._groups,n=t.length,o=[],s=[],r=0;r<n;++r)for(var a=t[r],l=a.length,c,u=0;u<l;++u)(c=a[u])&&(o.push(e.call(c,c.__data__,u,a)),s.push(c));return new Ye(o,s)}function Uc(e){return function(){return this.matches(e)}}function Vc(e){return function(t){return t.matches(e)}}var rh=Array.prototype.find;function ah(e){return function(){return rh.call(this.children,e)}}function lh(){return this.firstElementChild}function ch(e){return this.select(e==null?lh:ah(typeof e=="function"?e:Vc(e)))}var uh=Array.prototype.filter;function dh(){return Array.from(this.children)}function fh(e){return function(){return uh.call(this.children,e)}}function ph(e){return this.selectAll(e==null?dh:fh(typeof e=="function"?e:Vc(e)))}function hh(e){typeof e!="function"&&(e=Uc(e));for(var t=this._groups,n=t.length,o=new Array(n),s=0;s<n;++s)for(var r=t[s],a=r.length,l=o[s]=[],c,u=0;u<a;++u)(c=r[u])&&e.call(c,c.__data__,u,r)&&l.push(c);return new Ye(o,this._parents)}function Yc(e){return new Array(e.length)}function mh(){return new Ye(this._enter||this._groups.map(Yc),this._parents)}function cs(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}cs.prototype={constructor:cs,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function gh(e){return function(){return e}}function bh(e,t,n,o,s,r){for(var a=0,l,c=t.length,u=r.length;a<u;++a)(l=t[a])?(l.__data__=r[a],o[a]=l):n[a]=new cs(e,r[a]);for(;a<c;++a)(l=t[a])&&(s[a]=l)}function xh(e,t,n,o,s,r,a){var l,c,u=new Map,f=t.length,d=r.length,p=new Array(f),h;for(l=0;l<f;++l)(c=t[l])&&(p[l]=h=a.call(c,c.__data__,l,t)+"",u.has(h)?s[l]=c:u.set(h,c));for(l=0;l<d;++l)h=a.call(e,r[l],l,r)+"",(c=u.get(h))?(o[l]=c,c.__data__=r[l],u.delete(h)):n[l]=new cs(e,r[l]);for(l=0;l<f;++l)(c=t[l])&&u.get(p[l])===c&&(s[l]=c)}function yh(e){return e.__data__}function vh(e,t){if(!arguments.length)return Array.from(this,yh);var n=t?xh:bh,o=this._parents,s=this._groups;typeof e!="function"&&(e=gh(e));for(var r=s.length,a=new Array(r),l=new Array(r),c=new Array(r),u=0;u<r;++u){var f=o[u],d=s[u],p=d.length,h=wh(e.call(f,f&&f.__data__,u,o)),v=h.length,b=l[u]=new Array(v),S=a[u]=new Array(v),x=c[u]=new Array(p);n(f,d,b,S,x,h,t);for(var _=0,g=0,y,w;_<v;++_)if(y=b[_]){for(_>=g&&(g=_+1);!(w=S[g])&&++g<v;);y._next=w||null}}return a=new Ye(a,o),a._enter=l,a._exit=c,a}function wh(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Sh(){return new Ye(this._exit||this._groups.map(Yc),this._parents)}function _h(e,t,n){var o=this.enter(),s=this,r=this.exit();return typeof e=="function"?(o=e(o),o&&(o=o.selection())):o=o.append(e+""),t!=null&&(s=t(s),s&&(s=s.selection())),n==null?r.remove():n(r),o&&s?o.merge(s).order():s}function jh(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,s=n.length,r=o.length,a=Math.min(s,r),l=new Array(s),c=0;c<a;++c)for(var u=n[c],f=o[c],d=u.length,p=l[c]=new Array(d),h,v=0;v<d;++v)(h=u[v]||f[v])&&(p[v]=h);for(;c<s;++c)l[c]=n[c];return new Ye(l,this._parents)}function Mh(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o=e[t],s=o.length-1,r=o[s],a;--s>=0;)(a=o[s])&&(r&&a.compareDocumentPosition(r)^4&&r.parentNode.insertBefore(a,r),r=a);return this}function Ch(e){e||(e=Nh);function t(d,p){return d&&p?e(d.__data__,p.__data__):!d-!p}for(var n=this._groups,o=n.length,s=new Array(o),r=0;r<o;++r){for(var a=n[r],l=a.length,c=s[r]=new Array(l),u,f=0;f<l;++f)(u=a[f])&&(c[f]=u);c.sort(t)}return new Ye(s,this._parents).order()}function Nh(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Th(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Ih(){return Array.from(this)}function Eh(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],s=0,r=o.length;s<r;++s){var a=o[s];if(a)return a}return null}function Ah(){let e=0;for(const t of this)++e;return e}function kh(){return!this.node()}function Bh(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var s=t[n],r=0,a=s.length,l;r<a;++r)(l=s[r])&&e.call(l,l.__data__,r,s);return this}function Ph(e){return function(){this.removeAttribute(e)}}function Rh(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Dh(e,t){return function(){this.setAttribute(e,t)}}function Fh(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Lh(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function zh(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Oh(e,t){var n=Es(e);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((t==null?n.local?Rh:Ph:typeof t=="function"?n.local?zh:Lh:n.local?Fh:Dh)(n,t))}function Zc(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function $h(e){return function(){this.style.removeProperty(e)}}function Gh(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Hh(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function Wh(e,t,n){return arguments.length>1?this.each((t==null?$h:typeof t=="function"?Hh:Gh)(e,t,n??"")):wi(this.node(),e)}function wi(e,t){return e.style.getPropertyValue(t)||Zc(e).getComputedStyle(e,null).getPropertyValue(t)}function Uh(e){return function(){delete this[e]}}function Vh(e,t){return function(){this[e]=t}}function Yh(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Zh(e,t){return arguments.length>1?this.each((t==null?Uh:typeof t=="function"?Yh:Vh)(e,t)):this.node()[e]}function Xc(e){return e.trim().split(/^|\s+/)}function ma(e){return e.classList||new Kc(e)}function Kc(e){this._node=e,this._names=Xc(e.getAttribute("class")||"")}Kc.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function qc(e,t){for(var n=ma(e),o=-1,s=t.length;++o<s;)n.add(t[o])}function Qc(e,t){for(var n=ma(e),o=-1,s=t.length;++o<s;)n.remove(t[o])}function Xh(e){return function(){qc(this,e)}}function Kh(e){return function(){Qc(this,e)}}function qh(e,t){return function(){(t.apply(this,arguments)?qc:Qc)(this,e)}}function Qh(e,t){var n=Xc(e+"");if(arguments.length<2){for(var o=ma(this.node()),s=-1,r=n.length;++s<r;)if(!o.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?qh:t?Xh:Kh)(n,t))}function Jh(){this.textContent=""}function em(e){return function(){this.textContent=e}}function tm(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function nm(e){return arguments.length?this.each(e==null?Jh:(typeof e=="function"?tm:em)(e)):this.node().textContent}function im(){this.innerHTML=""}function om(e){return function(){this.innerHTML=e}}function sm(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function rm(e){return arguments.length?this.each(e==null?im:(typeof e=="function"?sm:om)(e)):this.node().innerHTML}function am(){this.nextSibling&&this.parentNode.appendChild(this)}function lm(){return this.each(am)}function cm(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function um(){return this.each(cm)}function dm(e){var t=typeof e=="function"?e:Hc(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function fm(){return null}function pm(e,t){var n=typeof e=="function"?e:Hc(e),o=t==null?fm:typeof t=="function"?t:ha(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function hm(){var e=this.parentNode;e&&e.removeChild(this)}function mm(){return this.each(hm)}function gm(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function bm(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function xm(e){return this.select(e?bm:gm)}function ym(e){return arguments.length?this.property("__data__",e):this.node().__data__}function vm(e){return function(t){e.call(this,t,this.__data__)}}function wm(e){return e.trim().split(/^|\s+/).map(function(t){var n="",o=t.indexOf(".");return o>=0&&(n=t.slice(o+1),t=t.slice(0,o)),{type:t,name:n}})}function Sm(e){return function(){var t=this.__on;if(t){for(var n=0,o=-1,s=t.length,r;n<s;++n)r=t[n],(!e.type||r.type===e.type)&&r.name===e.name?this.removeEventListener(r.type,r.listener,r.options):t[++o]=r;++o?t.length=o:delete this.__on}}}function _m(e,t,n){return function(){var o=this.__on,s,r=vm(t);if(o){for(var a=0,l=o.length;a<l;++a)if((s=o[a]).type===e.type&&s.name===e.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=r,s.options=n),s.value=t;return}}this.addEventListener(e.type,r,n),s={type:e.type,name:e.name,value:t,listener:r,options:n},o?o.push(s):this.__on=[s]}}function jm(e,t,n){var o=wm(e+""),s,r=o.length,a;if(arguments.length<2){var l=this.node().__on;if(l){for(var c=0,u=l.length,f;c<u;++c)for(s=0,f=l[c];s<r;++s)if((a=o[s]).type===f.type&&a.name===f.name)return f.value}return}for(l=t?_m:Sm,s=0;s<r;++s)this.each(l(o[s],t,n));return this}function Jc(e,t,n){var o=Zc(e),s=o.CustomEvent;typeof s=="function"?s=new s(t,n):(s=o.document.createEvent("Event"),n?(s.initEvent(t,n.bubbles,n.cancelable),s.detail=n.detail):s.initEvent(t,!1,!1)),e.dispatchEvent(s)}function Mm(e,t){return function(){return Jc(this,e,t)}}function Cm(e,t){return function(){return Jc(this,e,t.apply(this,arguments))}}function Nm(e,t){return this.each((typeof t=="function"?Cm:Mm)(e,t))}function*Tm(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],s=0,r=o.length,a;s<r;++s)(a=o[s])&&(yield a)}var eu=[null];function Ye(e,t){this._groups=e,this._parents=t}function xo(){return new Ye([[document.documentElement]],eu)}function Im(){return this}Ye.prototype=xo.prototype={constructor:Ye,select:th,selectAll:sh,selectChild:ch,selectChildren:ph,filter:hh,data:vh,enter:mh,exit:Sh,join:_h,merge:jh,selection:Im,order:Mh,sort:Ch,call:Th,nodes:Ih,node:Eh,size:Ah,empty:kh,each:Bh,attr:Oh,style:Wh,property:Zh,classed:Qh,text:nm,html:rm,raise:lm,lower:um,append:dm,insert:pm,remove:mm,clone:xm,datum:ym,on:jm,dispatch:Nm,[Symbol.iterator]:Tm};function Ve(e){return typeof e=="string"?new Ye([[document.querySelector(e)]],[document.documentElement]):new Ye([[e]],eu)}function Em(e){let t;for(;t=e.sourceEvent;)e=t;return e}function st(e,t){if(e=Em(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,o=o.matrixTransform(t.getScreenCTM().inverse()),[o.x,o.y]}if(t.getBoundingClientRect){var s=t.getBoundingClientRect();return[e.clientX-s.left-t.clientLeft,e.clientY-s.top-t.clientTop]}}return[e.pageX,e.pageY]}const Am={passive:!1},io={capture:!0,passive:!1};function sr(e){e.stopImmediatePropagation()}function xi(e){e.preventDefault(),e.stopImmediatePropagation()}function tu(e){var t=e.document.documentElement,n=Ve(e).on("dragstart.drag",xi,io);"onselectstart"in t?n.on("selectstart.drag",xi,io):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function nu(e,t){var n=e.document.documentElement,o=Ve(e).on("dragstart.drag",null);t&&(o.on("click.drag",xi,io),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Bo=e=>()=>e;function Or(e,{sourceEvent:t,subject:n,target:o,identifier:s,active:r,x:a,y:l,dx:c,dy:u,dispatch:f}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:r,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:f}})}Or.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function km(e){return!e.ctrlKey&&!e.button}function Bm(){return this.parentNode}function Pm(e,t){return t??{x:e.x,y:e.y}}function Rm(){return navigator.maxTouchPoints||"ontouchstart"in this}function iu(){var e=km,t=Bm,n=Pm,o=Rm,s={},r=Is("start","drag","end"),a=0,l,c,u,f,d=0;function p(y){y.on("mousedown.drag",h).filter(o).on("touchstart.drag",S).on("touchmove.drag",x,Am).on("touchend.drag touchcancel.drag",_).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(y,w){if(!(f||!e.call(this,y,w))){var j=g(this,t.call(this,y,w),y,w,"mouse");j&&(Ve(y.view).on("mousemove.drag",v,io).on("mouseup.drag",b,io),tu(y.view),sr(y),u=!1,l=y.clientX,c=y.clientY,j("start",y))}}function v(y){if(xi(y),!u){var w=y.clientX-l,j=y.clientY-c;u=w*w+j*j>d}s.mouse("drag",y)}function b(y){Ve(y.view).on("mousemove.drag mouseup.drag",null),nu(y.view,u),xi(y),s.mouse("end",y)}function S(y,w){if(e.call(this,y,w)){var j=y.changedTouches,N=t.call(this,y,w),B=j.length,z,W;for(z=0;z<B;++z)(W=g(this,N,y,w,j[z].identifier,j[z]))&&(sr(y),W("start",y,j[z]))}}function x(y){var w=y.changedTouches,j=w.length,N,B;for(N=0;N<j;++N)(B=s[w[N].identifier])&&(xi(y),B("drag",y,w[N]))}function _(y){var w=y.changedTouches,j=w.length,N,B;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),N=0;N<j;++N)(B=s[w[N].identifier])&&(sr(y),B("end",y,w[N]))}function g(y,w,j,N,B,z){var W=r.copy(),D=st(z||j,w),E,G,T;if((T=n.call(y,new Or("beforestart",{sourceEvent:j,target:p,identifier:B,active:a,x:D[0],y:D[1],dx:0,dy:0,dispatch:W}),N))!=null)return E=T.x-D[0]||0,G=T.y-D[1]||0,function O(P,L,M){var F=D,U;switch(P){case"start":s[B]=O,U=a++;break;case"end":delete s[B],--a;case"drag":D=st(M||L,w),U=a;break}W.call(P,y,new Or(P,{sourceEvent:L,subject:T,target:p,identifier:B,active:U,x:D[0]+E,y:D[1]+G,dx:D[0]-F[0],dy:D[1]-F[1],dispatch:W}),N)}}return p.filter=function(y){return arguments.length?(e=typeof y=="function"?y:Bo(!!y),p):e},p.container=function(y){return arguments.length?(t=typeof y=="function"?y:Bo(y),p):t},p.subject=function(y){return arguments.length?(n=typeof y=="function"?y:Bo(y),p):n},p.touchable=function(y){return arguments.length?(o=typeof y=="function"?y:Bo(!!y),p):o},p.on=function(){var y=r.on.apply(r,arguments);return y===r?p:y},p.clickDistance=function(y){return arguments.length?(d=(y=+y)*y,p):Math.sqrt(d)},p}function ga(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function ou(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function yo(){}var oo=.7,us=1/oo,yi="\\s*([+-]?\\d+)\\s*",so="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",It="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Dm=/^#([0-9a-f]{3,8})$/,Fm=new RegExp(`^rgb\\(${yi},${yi},${yi}\\)$`),Lm=new RegExp(`^rgb\\(${It},${It},${It}\\)$`),zm=new RegExp(`^rgba\\(${yi},${yi},${yi},${so}\\)$`),Om=new RegExp(`^rgba\\(${It},${It},${It},${so}\\)$`),$m=new RegExp(`^hsl\\(${so},${It},${It}\\)$`),Gm=new RegExp(`^hsla\\(${so},${It},${It},${so}\\)$`),nl={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};ga(yo,ii,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:il,formatHex:il,formatHex8:Hm,formatHsl:Wm,formatRgb:ol,toString:ol});function il(){return this.rgb().formatHex()}function Hm(){return this.rgb().formatHex8()}function Wm(){return su(this).formatHsl()}function ol(){return this.rgb().formatRgb()}function ii(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Dm.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?sl(t):n===3?new $e(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Po(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Po(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Fm.exec(e))?new $e(t[1],t[2],t[3],1):(t=Lm.exec(e))?new $e(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=zm.exec(e))?Po(t[1],t[2],t[3],t[4]):(t=Om.exec(e))?Po(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=$m.exec(e))?ll(t[1],t[2]/100,t[3]/100,1):(t=Gm.exec(e))?ll(t[1],t[2]/100,t[3]/100,t[4]):nl.hasOwnProperty(e)?sl(nl[e]):e==="transparent"?new $e(NaN,NaN,NaN,0):null}function sl(e){return new $e(e>>16&255,e>>8&255,e&255,1)}function Po(e,t,n,o){return o<=0&&(e=t=n=NaN),new $e(e,t,n,o)}function Um(e){return e instanceof yo||(e=ii(e)),e?(e=e.rgb(),new $e(e.r,e.g,e.b,e.opacity)):new $e}function $r(e,t,n,o){return arguments.length===1?Um(e):new $e(e,t,n,o??1)}function $e(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}ga($e,$r,ou(yo,{brighter(e){return e=e==null?us:Math.pow(us,e),new $e(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?oo:Math.pow(oo,e),new $e(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new $e(ti(this.r),ti(this.g),ti(this.b),ds(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:rl,formatHex:rl,formatHex8:Vm,formatRgb:al,toString:al}));function rl(){return`#${ei(this.r)}${ei(this.g)}${ei(this.b)}`}function Vm(){return`#${ei(this.r)}${ei(this.g)}${ei(this.b)}${ei((isNaN(this.opacity)?1:this.opacity)*255)}`}function al(){const e=ds(this.opacity);return`${e===1?"rgb(":"rgba("}${ti(this.r)}, ${ti(this.g)}, ${ti(this.b)}${e===1?")":`, ${e})`}`}function ds(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ti(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ei(e){return e=ti(e),(e<16?"0":"")+e.toString(16)}function ll(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new lt(e,t,n,o)}function su(e){if(e instanceof lt)return new lt(e.h,e.s,e.l,e.opacity);if(e instanceof yo||(e=ii(e)),!e)return new lt;if(e instanceof lt)return e;e=e.rgb();var t=e.r/255,n=e.g/255,o=e.b/255,s=Math.min(t,n,o),r=Math.max(t,n,o),a=NaN,l=r-s,c=(r+s)/2;return l?(t===r?a=(n-o)/l+(n<o)*6:n===r?a=(o-t)/l+2:a=(t-n)/l+4,l/=c<.5?r+s:2-r-s,a*=60):l=c>0&&c<1?0:a,new lt(a,l,c,e.opacity)}function Ym(e,t,n,o){return arguments.length===1?su(e):new lt(e,t,n,o??1)}function lt(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}ga(lt,Ym,ou(yo,{brighter(e){return e=e==null?us:Math.pow(us,e),new lt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?oo:Math.pow(oo,e),new lt(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,o=n+(n<.5?n:1-n)*t,s=2*n-o;return new $e(rr(e>=240?e-240:e+120,s,o),rr(e,s,o),rr(e<120?e+240:e-120,s,o),this.opacity)},clamp(){return new lt(cl(this.h),Ro(this.s),Ro(this.l),ds(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=ds(this.opacity);return`${e===1?"hsl(":"hsla("}${cl(this.h)}, ${Ro(this.s)*100}%, ${Ro(this.l)*100}%${e===1?")":`, ${e})`}`}}));function cl(e){return e=(e||0)%360,e<0?e+360:e}function Ro(e){return Math.max(0,Math.min(1,e||0))}function rr(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const ba=e=>()=>e;function Zm(e,t){return function(n){return e+n*t}}function Xm(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(o){return Math.pow(e+o*t,n)}}function Km(e){return(e=+e)==1?ru:function(t,n){return n-t?Xm(t,n,e):ba(isNaN(t)?n:t)}}function ru(e,t){var n=t-e;return n?Zm(e,n):ba(isNaN(e)?t:e)}const fs=function e(t){var n=Km(t);function o(s,r){var a=n((s=$r(s)).r,(r=$r(r)).r),l=n(s.g,r.g),c=n(s.b,r.b),u=ru(s.opacity,r.opacity);return function(f){return s.r=a(f),s.g=l(f),s.b=c(f),s.opacity=u(f),s+""}}return o.gamma=e,o}(1);function qm(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,o=t.slice(),s;return function(r){for(s=0;s<n;++s)o[s]=e[s]*(1-r)+t[s]*r;return o}}function Qm(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Jm(e,t){var n=t?t.length:0,o=e?Math.min(n,e.length):0,s=new Array(o),r=new Array(n),a;for(a=0;a<o;++a)s[a]=qi(e[a],t[a]);for(;a<n;++a)r[a]=t[a];return function(l){for(a=0;a<o;++a)r[a]=s[a](l);return r}}function eg(e,t){var n=new Date;return e=+e,t=+t,function(o){return n.setTime(e*(1-o)+t*o),n}}function Tt(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function tg(e,t){var n={},o={},s;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(s in t)s in e?n[s]=qi(e[s],t[s]):o[s]=t[s];return function(r){for(s in n)o[s]=n[s](r);return o}}var Gr=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ar=new RegExp(Gr.source,"g");function ng(e){return function(){return e}}function ig(e){return function(t){return e(t)+""}}function au(e,t){var n=Gr.lastIndex=ar.lastIndex=0,o,s,r,a=-1,l=[],c=[];for(e=e+"",t=t+"";(o=Gr.exec(e))&&(s=ar.exec(t));)(r=s.index)>n&&(r=t.slice(n,r),l[a]?l[a]+=r:l[++a]=r),(o=o[0])===(s=s[0])?l[a]?l[a]+=s:l[++a]=s:(l[++a]=null,c.push({i:a,x:Tt(o,s)})),n=ar.lastIndex;return n<t.length&&(r=t.slice(n),l[a]?l[a]+=r:l[++a]=r),l.length<2?c[0]?ig(c[0].x):ng(t):(t=c.length,function(u){for(var f=0,d;f<t;++f)l[(d=c[f]).i]=d.x(u);return l.join("")})}function qi(e,t){var n=typeof t,o;return t==null||n==="boolean"?ba(t):(n==="number"?Tt:n==="string"?(o=ii(t))?(t=o,fs):au:t instanceof ii?fs:t instanceof Date?eg:Qm(t)?qm:Array.isArray(t)?Jm:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?tg:Tt)(e,t)}var ul=180/Math.PI,Hr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function lu(e,t,n,o,s,r){var a,l,c;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(c=e*n+t*o)&&(n-=e*c,o-=t*c),(l=Math.sqrt(n*n+o*o))&&(n/=l,o/=l,c/=l),e*o<t*n&&(e=-e,t=-t,c=-c,a=-a),{translateX:s,translateY:r,rotate:Math.atan2(t,e)*ul,skewX:Math.atan(c)*ul,scaleX:a,scaleY:l}}var Do;function og(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Hr:lu(t.a,t.b,t.c,t.d,t.e,t.f)}function sg(e){return e==null||(Do||(Do=document.createElementNS("http://www.w3.org/2000/svg","g")),Do.setAttribute("transform",e),!(e=Do.transform.baseVal.consolidate()))?Hr:(e=e.matrix,lu(e.a,e.b,e.c,e.d,e.e,e.f))}function cu(e,t,n,o){function s(u){return u.length?u.pop()+" ":""}function r(u,f,d,p,h,v){if(u!==d||f!==p){var b=h.push("translate(",null,t,null,n);v.push({i:b-4,x:Tt(u,d)},{i:b-2,x:Tt(f,p)})}else(d||p)&&h.push("translate("+d+t+p+n)}function a(u,f,d,p){u!==f?(u-f>180?f+=360:f-u>180&&(u+=360),p.push({i:d.push(s(d)+"rotate(",null,o)-2,x:Tt(u,f)})):f&&d.push(s(d)+"rotate("+f+o)}function l(u,f,d,p){u!==f?p.push({i:d.push(s(d)+"skewX(",null,o)-2,x:Tt(u,f)}):f&&d.push(s(d)+"skewX("+f+o)}function c(u,f,d,p,h,v){if(u!==d||f!==p){var b=h.push(s(h)+"scale(",null,",",null,")");v.push({i:b-4,x:Tt(u,d)},{i:b-2,x:Tt(f,p)})}else(d!==1||p!==1)&&h.push(s(h)+"scale("+d+","+p+")")}return function(u,f){var d=[],p=[];return u=e(u),f=e(f),r(u.translateX,u.translateY,f.translateX,f.translateY,d,p),a(u.rotate,f.rotate,d,p),l(u.skewX,f.skewX,d,p),c(u.scaleX,u.scaleY,f.scaleX,f.scaleY,d,p),u=f=null,function(h){for(var v=-1,b=p.length,S;++v<b;)d[(S=p[v]).i]=S.x(h);return d.join("")}}}var rg=cu(og,"px, ","px)","deg)"),ag=cu(sg,", ",")",")"),lg=1e-12;function dl(e){return((e=Math.exp(e))+1/e)/2}function cg(e){return((e=Math.exp(e))-1/e)/2}function ug(e){return((e=Math.exp(2*e))-1)/(e+1)}const ts=function e(t,n,o){function s(r,a){var l=r[0],c=r[1],u=r[2],f=a[0],d=a[1],p=a[2],h=f-l,v=d-c,b=h*h+v*v,S,x;if(b<lg)x=Math.log(p/u)/t,S=function(N){return[l+N*h,c+N*v,u*Math.exp(t*N*x)]};else{var _=Math.sqrt(b),g=(p*p-u*u+o*b)/(2*u*n*_),y=(p*p-u*u-o*b)/(2*p*n*_),w=Math.log(Math.sqrt(g*g+1)-g),j=Math.log(Math.sqrt(y*y+1)-y);x=(j-w)/t,S=function(N){var B=N*x,z=dl(w),W=u/(n*_)*(z*ug(t*B+w)-cg(w));return[l+W*h,c+W*v,u*z/dl(t*B+w)]}}return S.duration=x*1e3*t/Math.SQRT2,S}return s.rho=function(r){var a=Math.max(.001,+r),l=a*a,c=l*l;return e(a,l,c)},s}(Math.SQRT2,2,4);var Si=0,Wi=0,Fi=0,uu=1e3,ps,Ui,hs=0,oi=0,As=0,ro=typeof performance=="object"&&performance.now?performance:Date,du=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function xa(){return oi||(du(dg),oi=ro.now()+As)}function dg(){oi=0}function ms(){this._call=this._time=this._next=null}ms.prototype=fu.prototype={constructor:ms,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?xa():+n)+(t==null?0:+t),!this._next&&Ui!==this&&(Ui?Ui._next=this:ps=this,Ui=this),this._call=e,this._time=n,Wr()},stop:function(){this._call&&(this._call=null,this._time=1/0,Wr())}};function fu(e,t,n){var o=new ms;return o.restart(e,t,n),o}function fg(){xa(),++Si;for(var e=ps,t;e;)(t=oi-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Si}function fl(){oi=(hs=ro.now())+As,Si=Wi=0;try{fg()}finally{Si=0,hg(),oi=0}}function pg(){var e=ro.now(),t=e-hs;t>uu&&(As-=t,hs=e)}function hg(){for(var e,t=ps,n,o=1/0;t;)t._call?(o>t._time&&(o=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:ps=n);Ui=e,Wr(o)}function Wr(e){if(!Si){Wi&&(Wi=clearTimeout(Wi));var t=e-oi;t>24?(e<1/0&&(Wi=setTimeout(fl,e-ro.now()-As)),Fi&&(Fi=clearInterval(Fi))):(Fi||(hs=ro.now(),Fi=setInterval(pg,uu)),Si=1,du(fl))}}function pl(e,t,n){var o=new ms;return t=t==null?0:+t,o.restart(s=>{o.stop(),e(s+t)},t,n),o}var mg=Is("start","end","cancel","interrupt"),gg=[],pu=0,hl=1,Ur=2,ns=3,ml=4,Vr=5,is=6;function ks(e,t,n,o,s,r){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;bg(e,n,{name:t,index:o,group:s,on:mg,tween:gg,time:r.time,delay:r.delay,duration:r.duration,ease:r.ease,timer:null,state:pu})}function ya(e,t){var n=ht(e,t);if(n.state>pu)throw new Error("too late; already scheduled");return n}function At(e,t){var n=ht(e,t);if(n.state>ns)throw new Error("too late; already running");return n}function ht(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function bg(e,t,n){var o=e.__transition,s;o[t]=n,n.timer=fu(r,0,n.time);function r(u){n.state=hl,n.timer.restart(a,n.delay,n.time),n.delay<=u&&a(u-n.delay)}function a(u){var f,d,p,h;if(n.state!==hl)return c();for(f in o)if(h=o[f],h.name===n.name){if(h.state===ns)return pl(a);h.state===ml?(h.state=is,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete o[f]):+f<t&&(h.state=is,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete o[f])}if(pl(function(){n.state===ns&&(n.state=ml,n.timer.restart(l,n.delay,n.time),l(u))}),n.state=Ur,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Ur){for(n.state=ns,s=new Array(p=n.tween.length),f=0,d=-1;f<p;++f)(h=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(s[++d]=h);s.length=d+1}}function l(u){for(var f=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(c),n.state=Vr,1),d=-1,p=s.length;++d<p;)s[d].call(e,f);n.state===Vr&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=is,n.timer.stop(),delete o[t];for(var u in o)return;delete e.__transition}}function os(e,t){var n=e.__transition,o,s,r=!0,a;if(n){t=t==null?null:t+"";for(a in n){if((o=n[a]).name!==t){r=!1;continue}s=o.state>Ur&&o.state<Vr,o.state=is,o.timer.stop(),o.on.call(s?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[a]}r&&delete e.__transition}}function xg(e){return this.each(function(){os(this,e)})}function yg(e,t){var n,o;return function(){var s=At(this,e),r=s.tween;if(r!==n){o=n=r;for(var a=0,l=o.length;a<l;++a)if(o[a].name===t){o=o.slice(),o.splice(a,1);break}}s.tween=o}}function vg(e,t,n){var o,s;if(typeof n!="function")throw new Error;return function(){var r=At(this,e),a=r.tween;if(a!==o){s=(o=a).slice();for(var l={name:t,value:n},c=0,u=s.length;c<u;++c)if(s[c].name===t){s[c]=l;break}c===u&&s.push(l)}r.tween=s}}function wg(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=ht(this.node(),n).tween,s=0,r=o.length,a;s<r;++s)if((a=o[s]).name===e)return a.value;return null}return this.each((t==null?yg:vg)(n,e,t))}function va(e,t,n){var o=e._id;return e.each(function(){var s=At(this,o);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return ht(s,o).value[t]}}function hu(e,t){var n;return(typeof t=="number"?Tt:t instanceof ii?fs:(n=ii(t))?(t=n,fs):au)(e,t)}function Sg(e){return function(){this.removeAttribute(e)}}function _g(e){return function(){this.removeAttributeNS(e.space,e.local)}}function jg(e,t,n){var o,s=n+"",r;return function(){var a=this.getAttribute(e);return a===s?null:a===o?r:r=t(o=a,n)}}function Mg(e,t,n){var o,s=n+"",r;return function(){var a=this.getAttributeNS(e.space,e.local);return a===s?null:a===o?r:r=t(o=a,n)}}function Cg(e,t,n){var o,s,r;return function(){var a,l=n(this),c;return l==null?void this.removeAttribute(e):(a=this.getAttribute(e),c=l+"",a===c?null:a===o&&c===s?r:(s=c,r=t(o=a,l)))}}function Ng(e,t,n){var o,s,r;return function(){var a,l=n(this),c;return l==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),c=l+"",a===c?null:a===o&&c===s?r:(s=c,r=t(o=a,l)))}}function Tg(e,t){var n=Es(e),o=n==="transform"?ag:hu;return this.attrTween(e,typeof t=="function"?(n.local?Ng:Cg)(n,o,va(this,"attr."+e,t)):t==null?(n.local?_g:Sg)(n):(n.local?Mg:jg)(n,o,t))}function Ig(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Eg(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Ag(e,t){var n,o;function s(){var r=t.apply(this,arguments);return r!==o&&(n=(o=r)&&Eg(e,r)),n}return s._value=t,s}function kg(e,t){var n,o;function s(){var r=t.apply(this,arguments);return r!==o&&(n=(o=r)&&Ig(e,r)),n}return s._value=t,s}function Bg(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var o=Es(e);return this.tween(n,(o.local?Ag:kg)(o,t))}function Pg(e,t){return function(){ya(this,e).delay=+t.apply(this,arguments)}}function Rg(e,t){return t=+t,function(){ya(this,e).delay=t}}function Dg(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Pg:Rg)(t,e)):ht(this.node(),t).delay}function Fg(e,t){return function(){At(this,e).duration=+t.apply(this,arguments)}}function Lg(e,t){return t=+t,function(){At(this,e).duration=t}}function zg(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Fg:Lg)(t,e)):ht(this.node(),t).duration}function Og(e,t){if(typeof t!="function")throw new Error;return function(){At(this,e).ease=t}}function $g(e){var t=this._id;return arguments.length?this.each(Og(t,e)):ht(this.node(),t).ease}function Gg(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;At(this,e).ease=n}}function Hg(e){if(typeof e!="function")throw new Error;return this.each(Gg(this._id,e))}function Wg(e){typeof e!="function"&&(e=Uc(e));for(var t=this._groups,n=t.length,o=new Array(n),s=0;s<n;++s)for(var r=t[s],a=r.length,l=o[s]=[],c,u=0;u<a;++u)(c=r[u])&&e.call(c,c.__data__,u,r)&&l.push(c);return new Wt(o,this._parents,this._name,this._id)}function Ug(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,s=n.length,r=Math.min(o,s),a=new Array(o),l=0;l<r;++l)for(var c=t[l],u=n[l],f=c.length,d=a[l]=new Array(f),p,h=0;h<f;++h)(p=c[h]||u[h])&&(d[h]=p);for(;l<o;++l)a[l]=t[l];return new Wt(a,this._parents,this._name,this._id)}function Vg(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function Yg(e,t,n){var o,s,r=Vg(t)?ya:At;return function(){var a=r(this,e),l=a.on;l!==o&&(s=(o=l).copy()).on(t,n),a.on=s}}function Zg(e,t){var n=this._id;return arguments.length<2?ht(this.node(),n).on.on(e):this.each(Yg(n,e,t))}function Xg(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Kg(){return this.on("end.remove",Xg(this._id))}function qg(e){var t=this._name,n=this._id;typeof e!="function"&&(e=ha(e));for(var o=this._groups,s=o.length,r=new Array(s),a=0;a<s;++a)for(var l=o[a],c=l.length,u=r[a]=new Array(c),f,d,p=0;p<c;++p)(f=l[p])&&(d=e.call(f,f.__data__,p,l))&&("__data__"in f&&(d.__data__=f.__data__),u[p]=d,ks(u[p],t,n,p,u,ht(f,n)));return new Wt(r,this._parents,t,n)}function Qg(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Wc(e));for(var o=this._groups,s=o.length,r=[],a=[],l=0;l<s;++l)for(var c=o[l],u=c.length,f,d=0;d<u;++d)if(f=c[d]){for(var p=e.call(f,f.__data__,d,c),h,v=ht(f,n),b=0,S=p.length;b<S;++b)(h=p[b])&&ks(h,t,n,b,p,v);r.push(p),a.push(f)}return new Wt(r,a,t,n)}var Jg=xo.prototype.constructor;function e0(){return new Jg(this._groups,this._parents)}function t0(e,t){var n,o,s;return function(){var r=wi(this,e),a=(this.style.removeProperty(e),wi(this,e));return r===a?null:r===n&&a===o?s:s=t(n=r,o=a)}}function mu(e){return function(){this.style.removeProperty(e)}}function n0(e,t,n){var o,s=n+"",r;return function(){var a=wi(this,e);return a===s?null:a===o?r:r=t(o=a,n)}}function i0(e,t,n){var o,s,r;return function(){var a=wi(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),wi(this,e))),a===c?null:a===o&&c===s?r:(s=c,r=t(o=a,l))}}function o0(e,t){var n,o,s,r="style."+t,a="end."+r,l;return function(){var c=At(this,e),u=c.on,f=c.value[r]==null?l||(l=mu(t)):void 0;(u!==n||s!==f)&&(o=(n=u).copy()).on(a,s=f),c.on=o}}function s0(e,t,n){var o=(e+="")=="transform"?rg:hu;return t==null?this.styleTween(e,t0(e,o)).on("end.style."+e,mu(e)):typeof t=="function"?this.styleTween(e,i0(e,o,va(this,"style."+e,t))).each(o0(this._id,e)):this.styleTween(e,n0(e,o,t),n).on("end.style."+e,null)}function r0(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function a0(e,t,n){var o,s;function r(){var a=t.apply(this,arguments);return a!==s&&(o=(s=a)&&r0(e,a,n)),o}return r._value=t,r}function l0(e,t,n){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;return this.tween(o,a0(e,t,n??""))}function c0(e){return function(){this.textContent=e}}function u0(e){return function(){var t=e(this);this.textContent=t??""}}function d0(e){return this.tween("text",typeof e=="function"?u0(va(this,"text",e)):c0(e==null?"":e+""))}function f0(e){return function(t){this.textContent=e.call(this,t)}}function p0(e){var t,n;function o(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&f0(s)),t}return o._value=e,o}function h0(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,p0(e))}function m0(){for(var e=this._name,t=this._id,n=gu(),o=this._groups,s=o.length,r=0;r<s;++r)for(var a=o[r],l=a.length,c,u=0;u<l;++u)if(c=a[u]){var f=ht(c,t);ks(c,e,n,u,a,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new Wt(o,this._parents,e,n)}function g0(){var e,t,n=this,o=n._id,s=n.size();return new Promise(function(r,a){var l={value:a},c={value:function(){--s===0&&r()}};n.each(function(){var u=At(this,o),f=u.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(c)),u.on=t}),s===0&&r()})}var b0=0;function Wt(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function gu(){return++b0}var zt=xo.prototype;Wt.prototype={constructor:Wt,select:qg,selectAll:Qg,selectChild:zt.selectChild,selectChildren:zt.selectChildren,filter:Wg,merge:Ug,selection:e0,transition:m0,call:zt.call,nodes:zt.nodes,node:zt.node,size:zt.size,empty:zt.empty,each:zt.each,on:Zg,attr:Tg,attrTween:Bg,style:s0,styleTween:l0,text:d0,textTween:h0,remove:Kg,tween:wg,delay:Dg,duration:zg,ease:$g,easeVarying:Hg,end:g0,[Symbol.iterator]:zt[Symbol.iterator]};function x0(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var y0={time:null,delay:0,duration:250,ease:x0};function v0(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function w0(e){var t,n;e instanceof Wt?(t=e._id,e=e._name):(t=gu(),(n=y0).time=xa(),e=e==null?null:e+"");for(var o=this._groups,s=o.length,r=0;r<s;++r)for(var a=o[r],l=a.length,c,u=0;u<l;++u)(c=a[u])&&ks(c,e,t,u,a,n||v0(c,t));return new Wt(o,this._parents,e,t)}xo.prototype.interrupt=xg;xo.prototype.transition=w0;const Fo=e=>()=>e;function S0(e,{sourceEvent:t,target:n,transform:o,dispatch:s}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:s}})}function Ht(e,t,n){this.k=e,this.x=t,this.y=n}Ht.prototype={constructor:Ht,scale:function(e){return e===1?this:new Ht(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ht(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Bs=new Ht(1,0,0);bu.prototype=Ht.prototype;function bu(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Bs;return e.__zoom}function lr(e){e.stopImmediatePropagation()}function Li(e){e.preventDefault(),e.stopImmediatePropagation()}function _0(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function j0(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function gl(){return this.__zoom||Bs}function M0(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function C0(){return navigator.maxTouchPoints||"ontouchstart"in this}function N0(e,t,n){var o=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],r=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(s>o?(o+s)/2:Math.min(0,o)||Math.max(0,s),a>r?(r+a)/2:Math.min(0,r)||Math.max(0,a))}function xu(){var e=_0,t=j0,n=N0,o=M0,s=C0,r=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],l=250,c=ts,u=Is("start","zoom","end"),f,d,p,h=500,v=150,b=0,S=10;function x(T){T.property("__zoom",gl).on("wheel.zoom",B,{passive:!1}).on("mousedown.zoom",z).on("dblclick.zoom",W).filter(s).on("touchstart.zoom",D).on("touchmove.zoom",E).on("touchend.zoom touchcancel.zoom",G).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}x.transform=function(T,O,P,L){var M=T.selection?T.selection():T;M.property("__zoom",gl),T!==M?w(T,O,P,L):M.interrupt().each(function(){j(this,arguments).event(L).start().zoom(null,typeof O=="function"?O.apply(this,arguments):O).end()})},x.scaleBy=function(T,O,P,L){x.scaleTo(T,function(){var M=this.__zoom.k,F=typeof O=="function"?O.apply(this,arguments):O;return M*F},P,L)},x.scaleTo=function(T,O,P,L){x.transform(T,function(){var M=t.apply(this,arguments),F=this.__zoom,U=P==null?y(M):typeof P=="function"?P.apply(this,arguments):P,V=F.invert(U),Y=typeof O=="function"?O.apply(this,arguments):O;return n(g(_(F,Y),U,V),M,a)},P,L)},x.translateBy=function(T,O,P,L){x.transform(T,function(){return n(this.__zoom.translate(typeof O=="function"?O.apply(this,arguments):O,typeof P=="function"?P.apply(this,arguments):P),t.apply(this,arguments),a)},null,L)},x.translateTo=function(T,O,P,L,M){x.transform(T,function(){var F=t.apply(this,arguments),U=this.__zoom,V=L==null?y(F):typeof L=="function"?L.apply(this,arguments):L;return n(Bs.translate(V[0],V[1]).scale(U.k).translate(typeof O=="function"?-O.apply(this,arguments):-O,typeof P=="function"?-P.apply(this,arguments):-P),F,a)},L,M)};function _(T,O){return O=Math.max(r[0],Math.min(r[1],O)),O===T.k?T:new Ht(O,T.x,T.y)}function g(T,O,P){var L=O[0]-P[0]*T.k,M=O[1]-P[1]*T.k;return L===T.x&&M===T.y?T:new Ht(T.k,L,M)}function y(T){return[(+T[0][0]+ +T[1][0])/2,(+T[0][1]+ +T[1][1])/2]}function w(T,O,P,L){T.on("start.zoom",function(){j(this,arguments).event(L).start()}).on("interrupt.zoom end.zoom",function(){j(this,arguments).event(L).end()}).tween("zoom",function(){var M=this,F=arguments,U=j(M,F).event(L),V=t.apply(M,F),Y=P==null?y(V):typeof P=="function"?P.apply(M,F):P,Z=Math.max(V[1][0]-V[0][0],V[1][1]-V[0][1]),q=M.__zoom,X=typeof O=="function"?O.apply(M,F):O,A=c(q.invert(Y).concat(Z/q.k),X.invert(Y).concat(Z/X.k));return function(C){if(C===1)C=X;else{var H=A(C),K=Z/H[2];C=new Ht(K,Y[0]-H[0]*K,Y[1]-H[1]*K)}U.zoom(null,C)}})}function j(T,O,P){return!P&&T.__zooming||new N(T,O)}function N(T,O){this.that=T,this.args=O,this.active=0,this.sourceEvent=null,this.extent=t.apply(T,O),this.taps=0}N.prototype={event:function(T){return T&&(this.sourceEvent=T),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(T,O){return this.mouse&&T!=="mouse"&&(this.mouse[1]=O.invert(this.mouse[0])),this.touch0&&T!=="touch"&&(this.touch0[1]=O.invert(this.touch0[0])),this.touch1&&T!=="touch"&&(this.touch1[1]=O.invert(this.touch1[0])),this.that.__zoom=O,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(T){var O=Ve(this.that).datum();u.call(T,this.that,new S0(T,{sourceEvent:this.sourceEvent,target:x,transform:this.that.__zoom,dispatch:u}),O)}};function B(T,...O){if(!e.apply(this,arguments))return;var P=j(this,O).event(T),L=this.__zoom,M=Math.max(r[0],Math.min(r[1],L.k*Math.pow(2,o.apply(this,arguments)))),F=st(T);if(P.wheel)(P.mouse[0][0]!==F[0]||P.mouse[0][1]!==F[1])&&(P.mouse[1]=L.invert(P.mouse[0]=F)),clearTimeout(P.wheel);else{if(L.k===M)return;P.mouse=[F,L.invert(F)],os(this),P.start()}Li(T),P.wheel=setTimeout(U,v),P.zoom("mouse",n(g(_(L,M),P.mouse[0],P.mouse[1]),P.extent,a));function U(){P.wheel=null,P.end()}}function z(T,...O){if(p||!e.apply(this,arguments))return;var P=T.currentTarget,L=j(this,O,!0).event(T),M=Ve(T.view).on("mousemove.zoom",Y,!0).on("mouseup.zoom",Z,!0),F=st(T,P),U=T.clientX,V=T.clientY;tu(T.view),lr(T),L.mouse=[F,this.__zoom.invert(F)],os(this),L.start();function Y(q){if(Li(q),!L.moved){var X=q.clientX-U,A=q.clientY-V;L.moved=X*X+A*A>b}L.event(q).zoom("mouse",n(g(L.that.__zoom,L.mouse[0]=st(q,P),L.mouse[1]),L.extent,a))}function Z(q){M.on("mousemove.zoom mouseup.zoom",null),nu(q.view,L.moved),Li(q),L.event(q).end()}}function W(T,...O){if(e.apply(this,arguments)){var P=this.__zoom,L=st(T.changedTouches?T.changedTouches[0]:T,this),M=P.invert(L),F=P.k*(T.shiftKey?.5:2),U=n(g(_(P,F),L,M),t.apply(this,O),a);Li(T),l>0?Ve(this).transition().duration(l).call(w,U,L,T):Ve(this).call(x.transform,U,L,T)}}function D(T,...O){if(e.apply(this,arguments)){var P=T.touches,L=P.length,M=j(this,O,T.changedTouches.length===L).event(T),F,U,V,Y;for(lr(T),U=0;U<L;++U)V=P[U],Y=st(V,this),Y=[Y,this.__zoom.invert(Y),V.identifier],M.touch0?!M.touch1&&M.touch0[2]!==Y[2]&&(M.touch1=Y,M.taps=0):(M.touch0=Y,F=!0,M.taps=1+!!f);f&&(f=clearTimeout(f)),F&&(M.taps<2&&(d=Y[0],f=setTimeout(function(){f=null},h)),os(this),M.start())}}function E(T,...O){if(this.__zooming){var P=j(this,O).event(T),L=T.changedTouches,M=L.length,F,U,V,Y;for(Li(T),F=0;F<M;++F)U=L[F],V=st(U,this),P.touch0&&P.touch0[2]===U.identifier?P.touch0[0]=V:P.touch1&&P.touch1[2]===U.identifier&&(P.touch1[0]=V);if(U=P.that.__zoom,P.touch1){var Z=P.touch0[0],q=P.touch0[1],X=P.touch1[0],A=P.touch1[1],C=(C=X[0]-Z[0])*C+(C=X[1]-Z[1])*C,H=(H=A[0]-q[0])*H+(H=A[1]-q[1])*H;U=_(U,Math.sqrt(C/H)),V=[(Z[0]+X[0])/2,(Z[1]+X[1])/2],Y=[(q[0]+A[0])/2,(q[1]+A[1])/2]}else if(P.touch0)V=P.touch0[0],Y=P.touch0[1];else return;P.zoom("touch",n(g(U,V,Y),P.extent,a))}}function G(T,...O){if(this.__zooming){var P=j(this,O).event(T),L=T.changedTouches,M=L.length,F,U;for(lr(T),p&&clearTimeout(p),p=setTimeout(function(){p=null},h),F=0;F<M;++F)U=L[F],P.touch0&&P.touch0[2]===U.identifier?delete P.touch0:P.touch1&&P.touch1[2]===U.identifier&&delete P.touch1;if(P.touch1&&!P.touch0&&(P.touch0=P.touch1,delete P.touch1),P.touch0)P.touch0[1]=this.__zoom.invert(P.touch0[0]);else if(P.end(),P.taps===2&&(U=st(U,this),Math.hypot(d[0]-U[0],d[1]-U[1])<S)){var V=Ve(this).on("dblclick.zoom");V&&V.apply(this,arguments)}}}return x.wheelDelta=function(T){return arguments.length?(o=typeof T=="function"?T:Fo(+T),x):o},x.filter=function(T){return arguments.length?(e=typeof T=="function"?T:Fo(!!T),x):e},x.touchable=function(T){return arguments.length?(s=typeof T=="function"?T:Fo(!!T),x):s},x.extent=function(T){return arguments.length?(t=typeof T=="function"?T:Fo([[+T[0][0],+T[0][1]],[+T[1][0],+T[1][1]]]),x):t},x.scaleExtent=function(T){return arguments.length?(r[0]=+T[0],r[1]=+T[1],x):[r[0],r[1]]},x.translateExtent=function(T){return arguments.length?(a[0][0]=+T[0][0],a[1][0]=+T[1][0],a[0][1]=+T[0][1],a[1][1]=+T[1][1],x):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},x.constrain=function(T){return arguments.length?(n=T,x):n},x.duration=function(T){return arguments.length?(l=+T,x):l},x.interpolate=function(T){return arguments.length?(c=T,x):c},x.on=function(){var T=u.on.apply(u,arguments);return T===u?x:T},x.clickDistance=function(T){return arguments.length?(b=(T=+T)*T,x):Math.sqrt(b)},x.tapDistance=function(T){return arguments.length?(S=+T,x):S},x}const Et={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:o})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:o}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},ao=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],yu=["Enter"," ","Escape"],vu={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var _i;(function(e){e.Strict="strict",e.Loose="loose"})(_i||(_i={}));var ni;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(ni||(ni={}));var lo;(function(e){e.Partial="partial",e.Full="full"})(lo||(lo={}));const wu={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var hn;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(hn||(hn={}));var co;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(co||(co={}));var le;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(le||(le={}));const bl={[le.Left]:le.Right,[le.Right]:le.Left,[le.Top]:le.Bottom,[le.Bottom]:le.Top};function Su(e){return e===null?null:e?"valid":"invalid"}const _u=e=>"id"in e&&"source"in e&&"target"in e,T0=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),wa=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),vo=(e,t=[0,0])=>{const{width:n,height:o}=Ut(e),s=e.origin??t,r=n*s[0],a=o*s[1];return{x:e.position.x-r,y:e.position.y-a}},I0=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((o,s)=>{const r=typeof s=="string";let a=!t.nodeLookup&&!r?s:void 0;t.nodeLookup&&(a=r?t.nodeLookup.get(s):wa(s)?s:t.nodeLookup.get(s.id));const l=a?gs(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Ps(o,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Rs(n)},wo=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return e.forEach(s=>{(t.filter===void 0||t.filter(s))&&(n=Ps(n,gs(s)),o=!0)}),o?Rs(n):{x:0,y:0,width:0,height:0}},Sa=(e,t,[n,o,s]=[0,0,1],r=!1,a=!1)=>{const l={..._o(t,[n,o,s]),width:t.width/s,height:t.height/s},c=[];for(const u of e.values()){const{measured:f,selectable:d=!0,hidden:p=!1}=u;if(a&&!d||p)continue;const h=f.width??u.width??u.initialWidth??null,v=f.height??u.height??u.initialHeight??null,b=uo(l,Mi(u)),S=(h??0)*(v??0),x=r&&b>0;(!u.internals.handleBounds||x||b>=S||u.dragging)&&c.push(u)}return c},E0=(e,t)=>{const n=new Set;return e.forEach(o=>{n.add(o.id)}),t.filter(o=>n.has(o.source)||n.has(o.target))};function A0(e,t){const n=new Map,o=t?.nodes?new Set(t.nodes.map(s=>s.id)):null;return e.forEach(s=>{s.measured.width&&s.measured.height&&(t?.includeHiddenNodes||!s.hidden)&&(!o||o.has(s.id))&&n.set(s.id,s)}),n}async function k0({nodes:e,width:t,height:n,panZoom:o,minZoom:s,maxZoom:r},a){if(e.size===0)return Promise.resolve(!0);const l=A0(e,a),c=wo(l),u=_a(c,t,n,a?.minZoom??s,a?.maxZoom??r,a?.padding??.1);return await o.setViewport(u,{duration:a?.duration,ease:a?.ease,interpolate:a?.interpolate}),Promise.resolve(!0)}function ju({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:s,onError:r}){const a=n.get(e),l=a.parentId?n.get(a.parentId):void 0,{x:c,y:u}=l?l.internals.positionAbsolute:{x:0,y:0},f=a.origin??o;let d=a.extent||s;if(a.extent==="parent"&&!a.expandParent)if(!l)r?.("005",Et.error005());else{const h=l.measured.width,v=l.measured.height;h&&v&&(d=[[c,u],[c+h,u+v]])}else l&&Ci(a.extent)&&(d=[[a.extent[0][0]+c,a.extent[0][1]+u],[a.extent[1][0]+c,a.extent[1][1]+u]]);const p=Ci(d)?si(t,d,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&r?.("015",Et.error015()),{position:{x:p.x-c+(a.measured.width??0)*f[0],y:p.y-u+(a.measured.height??0)*f[1]},positionAbsolute:p}}async function B0({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:s}){const r=new Set(e.map(p=>p.id)),a=[];for(const p of n){if(p.deletable===!1)continue;const h=r.has(p.id),v=!h&&p.parentId&&a.find(b=>b.id===p.parentId);(h||v)&&a.push(p)}const l=new Set(t.map(p=>p.id)),c=o.filter(p=>p.deletable!==!1),f=E0(a,c);for(const p of c)l.has(p.id)&&!f.find(v=>v.id===p.id)&&f.push(p);if(!s)return{edges:f,nodes:a};const d=await s({nodes:a,edges:f});return typeof d=="boolean"?d?{edges:f,nodes:a}:{edges:[],nodes:[]}:d}const ji=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),si=(e={x:0,y:0},t,n)=>({x:ji(e.x,t[0][0],t[1][0]-(n?.width??0)),y:ji(e.y,t[0][1],t[1][1]-(n?.height??0))});function Mu(e,t,n){const{width:o,height:s}=Ut(n),{x:r,y:a}=n.internals.positionAbsolute;return si(e,[[r,a],[r+o,a+s]],t)}const xl=(e,t,n)=>e<t?ji(Math.abs(e-t),1,t)/t:e>n?-ji(Math.abs(e-n),1,t)/t:0,Cu=(e,t,n=15,o=40)=>{const s=xl(e.x,o,t.width-o)*n,r=xl(e.y,o,t.height-o)*n;return[s,r]},Ps=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Yr=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),Rs=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),Mi=(e,t=[0,0])=>{const{x:n,y:o}=wa(e)?e.internals.positionAbsolute:vo(e,t);return{x:n,y:o,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},gs=(e,t=[0,0])=>{const{x:n,y:o}=wa(e)?e.internals.positionAbsolute:vo(e,t);return{x:n,y:o,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:o+(e.measured?.height??e.height??e.initialHeight??0)}},Nu=(e,t)=>Rs(Ps(Yr(e),Yr(t))),uo=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),o=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*o)},yl=e=>ut(e.width)&&ut(e.height)&&ut(e.x)&&ut(e.y),ut=e=>!isNaN(e)&&isFinite(e),P0=(e,t)=>{},So=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),_o=({x:e,y:t},[n,o,s],r=!1,a=[1,1])=>{const l={x:(e-n)/s,y:(t-o)/s};return r?So(l,a):l},bs=({x:e,y:t},[n,o,s])=>({x:e*s+n,y:t*s+o});function ui(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function R0(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=ui(e,n),s=ui(e,t);return{top:o,right:s,bottom:o,left:s,x:s*2,y:o*2}}if(typeof e=="object"){const o=ui(e.top??e.y??0,n),s=ui(e.bottom??e.y??0,n),r=ui(e.left??e.x??0,t),a=ui(e.right??e.x??0,t);return{top:o,right:a,bottom:s,left:r,x:r+a,y:o+s}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function D0(e,t,n,o,s,r){const{x:a,y:l}=bs(e,[t,n,o]),{x:c,y:u}=bs({x:e.x+e.width,y:e.y+e.height},[t,n,o]),f=s-c,d=r-u;return{left:Math.floor(a),top:Math.floor(l),right:Math.floor(f),bottom:Math.floor(d)}}const _a=(e,t,n,o,s,r)=>{const a=R0(r,t,n),l=(t-a.x)/e.width,c=(n-a.y)/e.height,u=Math.min(l,c),f=ji(u,o,s),d=e.x+e.width/2,p=e.y+e.height/2,h=t/2-d*f,v=n/2-p*f,b=D0(e,h,v,f,t,n),S={left:Math.min(b.left-a.left,0),top:Math.min(b.top-a.top,0),right:Math.min(b.right-a.right,0),bottom:Math.min(b.bottom-a.bottom,0)};return{x:h-S.left+S.right,y:v-S.top+S.bottom,zoom:f}},fo=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Ci(e){return e!=null&&e!=="parent"}function Ut(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Tu(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Iu(e,t={width:0,height:0},n,o,s){const r={...e},a=o.get(n);if(a){const l=a.origin||s;r.x+=a.internals.positionAbsolute.x-(t.width??0)*l[0],r.y+=a.internals.positionAbsolute.y-(t.height??0)*l[1]}return r}function vl(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function F0(){let e,t;return{promise:new Promise((o,s)=>{e=o,t=s}),resolve:e,reject:t}}function L0(e){return{...vu,...e||{}}}function Qi(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:s}){const{x:r,y:a}=dt(e),l=_o({x:r-(s?.left??0),y:a-(s?.top??0)},o),{x:c,y:u}=n?So(l,t):l;return{xSnapped:c,ySnapped:u,...l}}const ja=e=>({width:e.offsetWidth,height:e.offsetHeight}),Eu=e=>e?.getRootNode?.()||window?.document,z0=["INPUT","SELECT","TEXTAREA"];function Au(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:z0.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const ku=e=>"clientX"in e,dt=(e,t)=>{const n=ku(e),o=n?e.clientX:e.touches?.[0].clientX,s=n?e.clientY:e.touches?.[0].clientY;return{x:o-(t?.left??0),y:s-(t?.top??0)}},wl=(e,t,n,o,s)=>{const r=t.querySelectorAll(`.${e}`);return!r||!r.length?null:Array.from(r).map(a=>{const l=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),type:e,nodeId:s,position:a.getAttribute("data-handlepos"),x:(l.left-n.left)/o,y:(l.top-n.top)/o,...ja(a)}})};function Bu({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:s,sourceControlY:r,targetControlX:a,targetControlY:l}){const c=e*.125+s*.375+a*.375+n*.125,u=t*.125+r*.375+l*.375+o*.125,f=Math.abs(c-e),d=Math.abs(u-t);return[c,u,f,d]}function Lo(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Sl({pos:e,x1:t,y1:n,x2:o,y2:s,c:r}){switch(e){case le.Left:return[t-Lo(t-o,r),n];case le.Right:return[t+Lo(o-t,r),n];case le.Top:return[t,n-Lo(n-s,r)];case le.Bottom:return[t,n+Lo(s-n,r)]}}function Pu({sourceX:e,sourceY:t,sourcePosition:n=le.Bottom,targetX:o,targetY:s,targetPosition:r=le.Top,curvature:a=.25}){const[l,c]=Sl({pos:n,x1:e,y1:t,x2:o,y2:s,c:a}),[u,f]=Sl({pos:r,x1:o,y1:s,x2:e,y2:t,c:a}),[d,p,h,v]=Bu({sourceX:e,sourceY:t,targetX:o,targetY:s,sourceControlX:l,sourceControlY:c,targetControlX:u,targetControlY:f});return[`M${e},${t} C${l},${c} ${u},${f} ${o},${s}`,d,p,h,v]}function Ru({sourceX:e,sourceY:t,targetX:n,targetY:o}){const s=Math.abs(n-e)/2,r=n<e?n+s:n-s,a=Math.abs(o-t)/2,l=o<t?o+a:o-a;return[r,l,s,a]}function O0({sourceNode:e,targetNode:t,selected:n=!1,zIndex:o=0,elevateOnSelect:s=!1,zIndexMode:r="basic"}){if(r==="manual")return o;const a=s&&n?o+1e3:o,l=Math.max(e.parentId||s&&e.selected?e.internals.z:0,t.parentId||s&&t.selected?t.internals.z:0);return a+l}function $0({sourceNode:e,targetNode:t,width:n,height:o,transform:s}){const r=Ps(gs(e),gs(t));r.x===r.x2&&(r.x2+=1),r.y===r.y2&&(r.y2+=1);const a={x:-s[0]/s[2],y:-s[1]/s[2],width:n/s[2],height:o/s[2]};return uo(a,Rs(r))>0}const G0=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,H0=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),W0=(e,t,n={})=>{if(!e.source||!e.target)return t;const o=n.getEdgeId||G0;let s;return _u(e)?s={...e}:s={...e,id:o(e)},H0(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function Du({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[s,r,a,l]=Ru({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,s,r,a,l]}const _l={[le.Left]:{x:-1,y:0},[le.Right]:{x:1,y:0},[le.Top]:{x:0,y:-1},[le.Bottom]:{x:0,y:1}},U0=({source:e,sourcePosition:t=le.Bottom,target:n})=>t===le.Left||t===le.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},jl=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function V0({source:e,sourcePosition:t=le.Bottom,target:n,targetPosition:o=le.Top,center:s,offset:r,stepPosition:a}){const l=_l[t],c=_l[o],u={x:e.x+l.x*r,y:e.y+l.y*r},f={x:n.x+c.x*r,y:n.y+c.y*r},d=U0({source:u,sourcePosition:t,target:f}),p=d.x!==0?"x":"y",h=d[p];let v=[],b,S;const x={x:0,y:0},_={x:0,y:0},[,,g,y]=Ru({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[p]*c[p]===-1){p==="x"?(b=s.x??u.x+(f.x-u.x)*a,S=s.y??(u.y+f.y)/2):(b=s.x??(u.x+f.x)/2,S=s.y??u.y+(f.y-u.y)*a);const B=[{x:b,y:u.y},{x:b,y:f.y}],z=[{x:u.x,y:S},{x:f.x,y:S}];l[p]===h?v=p==="x"?B:z:v=p==="x"?z:B}else{const B=[{x:u.x,y:f.y}],z=[{x:f.x,y:u.y}];if(p==="x"?v=l.x===h?z:B:v=l.y===h?B:z,t===o){const T=Math.abs(e[p]-n[p]);if(T<=r){const O=Math.min(r-1,r-T);l[p]===h?x[p]=(u[p]>e[p]?-1:1)*O:_[p]=(f[p]>n[p]?-1:1)*O}}if(t!==o){const T=p==="x"?"y":"x",O=l[p]===c[T],P=u[T]>f[T],L=u[T]<f[T];(l[p]===1&&(!O&&P||O&&L)||l[p]!==1&&(!O&&L||O&&P))&&(v=p==="x"?B:z)}const W={x:u.x+x.x,y:u.y+x.y},D={x:f.x+_.x,y:f.y+_.y},E=Math.max(Math.abs(W.x-v[0].x),Math.abs(D.x-v[0].x)),G=Math.max(Math.abs(W.y-v[0].y),Math.abs(D.y-v[0].y));E>=G?(b=(W.x+D.x)/2,S=v[0].y):(b=v[0].x,S=(W.y+D.y)/2)}const w={x:u.x+x.x,y:u.y+x.y},j={x:f.x+_.x,y:f.y+_.y};return[[e,...w.x!==v[0].x||w.y!==v[0].y?[w]:[],...v,...j.x!==v[v.length-1].x||j.y!==v[v.length-1].y?[j]:[],n],b,S,g,y]}function Y0(e,t,n,o){const s=Math.min(jl(e,t)/2,jl(t,n)/2,o),{x:r,y:a}=t;if(e.x===r&&r===n.x||e.y===a&&a===n.y)return`L${r} ${a}`;if(e.y===a){const u=e.x<n.x?-1:1,f=e.y<n.y?1:-1;return`L ${r+s*u},${a}Q ${r},${a} ${r},${a+s*f}`}const l=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${r},${a+s*c}Q ${r},${a} ${r+s*l},${a}`}function Zr({sourceX:e,sourceY:t,sourcePosition:n=le.Bottom,targetX:o,targetY:s,targetPosition:r=le.Top,borderRadius:a=5,centerX:l,centerY:c,offset:u=20,stepPosition:f=.5}){const[d,p,h,v,b]=V0({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:s},targetPosition:r,center:{x:l,y:c},offset:u,stepPosition:f});let S=`M${d[0].x} ${d[0].y}`;for(let x=1;x<d.length-1;x++)S+=Y0(d[x-1],d[x],d[x+1],a);return S+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[S,p,h,v,b]}function Ml(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Z0(e){const{sourceNode:t,targetNode:n}=e;if(!Ml(t)||!Ml(n))return null;const o=t.internals.handleBounds||Cl(t.handles),s=n.internals.handleBounds||Cl(n.handles),r=Nl(o?.source??[],e.sourceHandle),a=Nl(e.connectionMode===_i.Strict?s?.target??[]:(s?.target??[]).concat(s?.source??[]),e.targetHandle);if(!r||!a)return e.onError?.("008",Et.error008(r?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const l=r?.position||le.Bottom,c=a?.position||le.Top,u=ri(t,r,l),f=ri(n,a,c);return{sourceX:u.x,sourceY:u.y,targetX:f.x,targetY:f.y,sourcePosition:l,targetPosition:c}}function Cl(e){if(!e)return null;const t=[],n=[];for(const o of e)o.width=o.width??1,o.height=o.height??1,o.type==="source"?t.push(o):o.type==="target"&&n.push(o);return{source:t,target:n}}function ri(e,t,n=le.Left,o=!1){const s=(t?.x??0)+e.internals.positionAbsolute.x,r=(t?.y??0)+e.internals.positionAbsolute.y,{width:a,height:l}=t??Ut(e);if(o)return{x:s+a/2,y:r+l/2};switch(t?.position??n){case le.Top:return{x:s+a/2,y:r};case le.Right:return{x:s+a,y:r+l/2};case le.Bottom:return{x:s+a/2,y:r+l};case le.Left:return{x:s,y:r+l/2}}}function Nl(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Xr(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function X0(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:s}){const r=new Set;return e.reduce((a,l)=>([l.markerStart||o,l.markerEnd||s].forEach(c=>{if(c&&typeof c=="object"){const u=Xr(c,t);r.has(u)||(a.push({id:u,color:c.color||n,...c}),r.add(u))}}),a),[]).sort((a,l)=>a.id.localeCompare(l.id))}const Fu=1e3,K0=10,Ma={nodeOrigin:[0,0],nodeExtent:ao,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},q0={...Ma,checkEquality:!0};function Ca(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function Q0(e,t,n){const o=Ca(Ma,n);for(const s of e.values())if(s.parentId)Ta(s,e,t,o);else{const r=vo(s,o.nodeOrigin),a=Ci(s.extent)?s.extent:o.nodeExtent,l=si(r,a,Ut(s));s.internals.positionAbsolute=l}}function J0(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],o=[];for(const s of e.handles){const r={id:s.id,width:s.width??1,height:s.height??1,nodeId:e.id,x:s.x,y:s.y,position:s.position,type:s.type};s.type==="source"?n.push(r):s.type==="target"&&o.push(r)}return{source:n,target:o}}function Na(e){return e==="manual"}function Kr(e,t,n,o={}){const s=Ca(q0,o),r={i:0},a=new Map(t),l=s?.elevateNodesOnSelect&&!Na(s.zIndexMode)?Fu:0;let c=e.length>0,u=!1;t.clear(),n.clear();for(const f of e){let d=a.get(f.id);if(s.checkEquality&&f===d?.internals.userNode)t.set(f.id,d);else{const p=vo(f,s.nodeOrigin),h=Ci(f.extent)?f.extent:s.nodeExtent,v=si(p,h,Ut(f));d={...s.defaults,...f,measured:{width:f.measured?.width,height:f.measured?.height},internals:{positionAbsolute:v,handleBounds:J0(f,d),z:Lu(f,l,s.zIndexMode),userNode:f}},t.set(f.id,d)}(d.measured===void 0||d.measured.width===void 0||d.measured.height===void 0)&&!d.hidden&&(c=!1),f.parentId&&Ta(d,t,n,o,r),u||=f.selected??!1}return{nodesInitialized:c,hasSelectedNodes:u}}function eb(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Ta(e,t,n,o,s){const{elevateNodesOnSelect:r,nodeOrigin:a,nodeExtent:l,zIndexMode:c}=Ca(Ma,o),u=e.parentId,f=t.get(u);if(!f){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}eb(e,n),s&&!f.parentId&&f.internals.rootParentIndex===void 0&&c==="auto"&&(f.internals.rootParentIndex=++s.i,f.internals.z=f.internals.z+s.i*K0),s&&f.internals.rootParentIndex!==void 0&&(s.i=f.internals.rootParentIndex);const d=r&&!Na(c)?Fu:0,{x:p,y:h,z:v}=tb(e,f,a,l,d,c),{positionAbsolute:b}=e.internals,S=p!==b.x||h!==b.y;(S||v!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:S?{x:p,y:h}:b,z:v}})}function Lu(e,t,n){const o=ut(e.zIndex)?e.zIndex:0;return Na(n)?o:o+(e.selected?t:0)}function tb(e,t,n,o,s,r){const{x:a,y:l}=t.internals.positionAbsolute,c=Ut(e),u=vo(e,n),f=Ci(e.extent)?si(u,e.extent,c):u;let d=si({x:a+f.x,y:l+f.y},o,c);e.extent==="parent"&&(d=Mu(d,c,t));const p=Lu(e,s,r),h=t.internals.z??0;return{x:d.x,y:d.y,z:h>=p?h+1:p}}function Ia(e,t,n,o=[0,0]){const s=[],r=new Map;for(const a of e){const l=t.get(a.parentId);if(!l)continue;const c=r.get(a.parentId)?.expandedRect??Mi(l),u=Nu(c,a.rect);r.set(a.parentId,{expandedRect:u,parent:l})}return r.size>0&&r.forEach(({expandedRect:a,parent:l},c)=>{const u=l.internals.positionAbsolute,f=Ut(l),d=l.origin??o,p=a.x<u.x?Math.round(Math.abs(u.x-a.x)):0,h=a.y<u.y?Math.round(Math.abs(u.y-a.y)):0,v=Math.max(f.width,Math.round(a.width)),b=Math.max(f.height,Math.round(a.height)),S=(v-f.width)*d[0],x=(b-f.height)*d[1];(p>0||h>0||S||x)&&(s.push({id:c,type:"position",position:{x:l.position.x-p+S,y:l.position.y-h+x}}),n.get(c)?.forEach(_=>{e.some(g=>g.id===_.id)||s.push({id:_.id,type:"position",position:{x:_.position.x+p,y:_.position.y+h}})})),(f.width<a.width||f.height<a.height||p||h)&&s.push({id:c,type:"dimensions",setAttributes:!0,dimensions:{width:v+(p?d[0]*p-S:0),height:b+(h?d[1]*h-x:0)}})}),s}function nb(e,t,n,o,s,r,a){const l=o?.querySelector(".xyflow__viewport");let c=!1;if(!l)return{changes:[],updatedInternals:c};const u=[],f=window.getComputedStyle(l),{m22:d}=new window.DOMMatrixReadOnly(f.transform),p=[];for(const h of e.values()){const v=t.get(h.id);if(!v)continue;if(v.hidden){t.set(v.id,{...v,internals:{...v.internals,handleBounds:void 0}}),c=!0;continue}const b=ja(h.nodeElement),S=v.measured.width!==b.width||v.measured.height!==b.height;if(!!(b.width&&b.height&&(S||!v.internals.handleBounds||h.force))){const _=h.nodeElement.getBoundingClientRect(),g=Ci(v.extent)?v.extent:r;let{positionAbsolute:y}=v.internals;v.parentId&&v.extent==="parent"?y=Mu(y,b,t.get(v.parentId)):g&&(y=si(y,g,b));const w={...v,measured:b,internals:{...v.internals,positionAbsolute:y,handleBounds:{source:wl("source",h.nodeElement,_,d,v.id),target:wl("target",h.nodeElement,_,d,v.id)}}};t.set(v.id,w),v.parentId&&Ta(w,t,n,{nodeOrigin:s,zIndexMode:a}),c=!0,S&&(u.push({id:v.id,type:"dimensions",dimensions:b}),v.expandParent&&v.parentId&&p.push({id:v.id,parentId:v.parentId,rect:Mi(w,s)}))}}if(p.length>0){const h=Ia(p,t,n,s);u.push(...h)}return{changes:u,updatedInternals:c}}async function ib({delta:e,panZoom:t,transform:n,translateExtent:o,width:s,height:r}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const a=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[s,r]],o),l=!!a&&(a.x!==n[0]||a.y!==n[1]||a.k!==n[2]);return Promise.resolve(l)}function Tl(e,t,n,o,s,r){let a=s;const l=o.get(a)||new Map;o.set(a,l.set(n,t)),a=`${s}-${e}`;const c=o.get(a)||new Map;if(o.set(a,c.set(n,t)),r){a=`${s}-${e}-${r}`;const u=o.get(a)||new Map;o.set(a,u.set(n,t))}}function zu(e,t,n){e.clear(),t.clear();for(const o of n){const{source:s,target:r,sourceHandle:a=null,targetHandle:l=null}=o,c={edgeId:o.id,source:s,target:r,sourceHandle:a,targetHandle:l},u=`${s}-${a}--${r}-${l}`,f=`${r}-${l}--${s}-${a}`;Tl("source",c,f,e,s,a),Tl("target",c,u,e,r,l),t.set(o.id,o)}}function Ou(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Ou(n,t):!1}function Il(e,t,n){let o=e;do{if(o?.matches?.(t))return!0;if(o===n)return!1;o=o?.parentElement}while(o);return!1}function ob(e,t,n,o){const s=new Map;for(const[r,a]of e)if((a.selected||a.id===o)&&(!a.parentId||!Ou(a,e))&&(a.draggable||t&&typeof a.draggable>"u")){const l=e.get(r);l&&s.set(r,{id:r,position:l.position||{x:0,y:0},distance:{x:n.x-l.internals.positionAbsolute.x,y:n.y-l.internals.positionAbsolute.y},extent:l.extent,parentId:l.parentId,origin:l.origin,expandParent:l.expandParent,internals:{positionAbsolute:l.internals.positionAbsolute||{x:0,y:0}},measured:{width:l.measured.width??0,height:l.measured.height??0}})}return s}function cr({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){const s=[];for(const[a,l]of t){const c=n.get(a)?.internals.userNode;c&&s.push({...c,position:l.position,dragging:o})}if(!e)return[s[0],s];const r=n.get(e)?.internals.userNode;return[r?{...r,position:t.get(e)?.position||r.position,dragging:o}:s[0],s]}function sb({dragItems:e,snapGrid:t,x:n,y:o}){const s=e.values().next().value;if(!s)return null;const r={x:n-s.distance.x,y:o-s.distance.y},a=So(r,t);return{x:a.x-r.x,y:a.y-r.y}}function rb({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:s}){let r={x:null,y:null},a=0,l=new Map,c=!1,u={x:0,y:0},f=null,d=!1,p=null,h=!1,v=!1,b=null;function S({noDragClassName:_,handleSelector:g,domNode:y,isSelectable:w,nodeId:j,nodeClickDistance:N=0}){p=Ve(y);function B({x:E,y:G}){const{nodeLookup:T,nodeExtent:O,snapGrid:P,snapToGrid:L,nodeOrigin:M,onNodeDrag:F,onSelectionDrag:U,onError:V,updateNodePositions:Y}=t();r={x:E,y:G};let Z=!1;const q=l.size>1,X=q&&O?Yr(wo(l)):null,A=q&&L?sb({dragItems:l,snapGrid:P,x:E,y:G}):null;for(const[C,H]of l){if(!T.has(C))continue;let K={x:E-H.distance.x,y:G-H.distance.y};L&&(K=A?{x:Math.round(K.x+A.x),y:Math.round(K.y+A.y)}:So(K,P));let Q=null;if(q&&O&&!H.extent&&X){const{positionAbsolute:ie}=H.internals,re=ie.x-X.x+O[0][0],J=ie.x+H.measured.width-X.x2+O[1][0],ce=ie.y-X.y+O[0][1],de=ie.y+H.measured.height-X.y2+O[1][1];Q=[[re,ce],[J,de]]}const{position:ee,positionAbsolute:ne}=ju({nodeId:C,nextPosition:K,nodeLookup:T,nodeExtent:Q||O,nodeOrigin:M,onError:V});Z=Z||H.position.x!==ee.x||H.position.y!==ee.y,H.position=ee,H.internals.positionAbsolute=ne}if(v=v||Z,!!Z&&(Y(l,!0),b&&(o||F||!j&&U))){const[C,H]=cr({nodeId:j,dragItems:l,nodeLookup:T});o?.(b,l,C,H),F?.(b,C,H),j||U?.(b,H)}}async function z(){if(!f)return;const{transform:E,panBy:G,autoPanSpeed:T,autoPanOnNodeDrag:O}=t();if(!O){c=!1,cancelAnimationFrame(a);return}const[P,L]=Cu(u,f,T);(P!==0||L!==0)&&(r.x=(r.x??0)-P/E[2],r.y=(r.y??0)-L/E[2],await G({x:P,y:L})&&B(r)),a=requestAnimationFrame(z)}function W(E){const{nodeLookup:G,multiSelectionActive:T,nodesDraggable:O,transform:P,snapGrid:L,snapToGrid:M,selectNodesOnDrag:F,onNodeDragStart:U,onSelectionDragStart:V,unselectNodesAndEdges:Y}=t();d=!0,(!F||!w)&&!T&&j&&(G.get(j)?.selected||Y()),w&&F&&j&&e?.(j);const Z=Qi(E.sourceEvent,{transform:P,snapGrid:L,snapToGrid:M,containerBounds:f});if(r=Z,l=ob(G,O,Z,j),l.size>0&&(n||U||!j&&V)){const[q,X]=cr({nodeId:j,dragItems:l,nodeLookup:G});n?.(E.sourceEvent,l,q,X),U?.(E.sourceEvent,q,X),j||V?.(E.sourceEvent,X)}}const D=iu().clickDistance(N).on("start",E=>{const{domNode:G,nodeDragThreshold:T,transform:O,snapGrid:P,snapToGrid:L}=t();f=G?.getBoundingClientRect()||null,h=!1,v=!1,b=E.sourceEvent,T===0&&W(E),r=Qi(E.sourceEvent,{transform:O,snapGrid:P,snapToGrid:L,containerBounds:f}),u=dt(E.sourceEvent,f)}).on("drag",E=>{const{autoPanOnNodeDrag:G,transform:T,snapGrid:O,snapToGrid:P,nodeDragThreshold:L,nodeLookup:M}=t(),F=Qi(E.sourceEvent,{transform:T,snapGrid:O,snapToGrid:P,containerBounds:f});if(b=E.sourceEvent,(E.sourceEvent.type==="touchmove"&&E.sourceEvent.touches.length>1||j&&!M.has(j))&&(h=!0),!h){if(!c&&G&&d&&(c=!0,z()),!d){const U=dt(E.sourceEvent,f),V=U.x-u.x,Y=U.y-u.y;Math.sqrt(V*V+Y*Y)>L&&W(E)}(r.x!==F.xSnapped||r.y!==F.ySnapped)&&l&&d&&(u=dt(E.sourceEvent,f),B(F))}}).on("end",E=>{if(!(!d||h)&&(c=!1,d=!1,cancelAnimationFrame(a),l.size>0)){const{nodeLookup:G,updateNodePositions:T,onNodeDragStop:O,onSelectionDragStop:P}=t();if(v&&(T(l,!1),v=!1),s||O||!j&&P){const[L,M]=cr({nodeId:j,dragItems:l,nodeLookup:G,dragging:!1});s?.(E.sourceEvent,l,L,M),O?.(E.sourceEvent,L,M),j||P?.(E.sourceEvent,M)}}}).filter(E=>{const G=E.target;return!E.button&&(!_||!Il(G,`.${_}`,y))&&(!g||Il(G,g,y))});p.call(D)}function x(){p?.on(".drag",null)}return{update:S,destroy:x}}function ab(e,t,n){const o=[],s={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const r of t.values())uo(s,Mi(r))>0&&o.push(r);return o}const lb=250;function cb(e,t,n,o){let s=[],r=1/0;const a=ab(e,n,t+lb);for(const l of a){const c=[...l.internals.handleBounds?.source??[],...l.internals.handleBounds?.target??[]];for(const u of c){if(o.nodeId===u.nodeId&&o.type===u.type&&o.id===u.id)continue;const{x:f,y:d}=ri(l,u,u.position,!0),p=Math.sqrt(Math.pow(f-e.x,2)+Math.pow(d-e.y,2));p>t||(p<r?(s=[{...u,x:f,y:d}],r=p):p===r&&s.push({...u,x:f,y:d}))}}if(!s.length)return null;if(s.length>1){const l=o.type==="source"?"target":"source";return s.find(c=>c.type===l)??s[0]}return s[0]}function $u(e,t,n,o,s,r=!1){const a=o.get(e);if(!a)return null;const l=s==="strict"?a.internals.handleBounds?.[t]:[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]],c=(n?l?.find(u=>u.id===n):l?.[0])??null;return c&&r?{...c,...ri(a,c,c.position,!0)}:c}function Gu(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function ub(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Hu=()=>!0;function db(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:s,edgeUpdaterType:r,isTarget:a,domNode:l,nodeLookup:c,lib:u,autoPanOnConnect:f,flowId:d,panBy:p,cancelConnection:h,onConnectStart:v,onConnect:b,onConnectEnd:S,isValidConnection:x=Hu,onReconnectEnd:_,updateConnection:g,getTransform:y,getFromHandle:w,autoPanSpeed:j,dragThreshold:N=1,handleDomNode:B}){const z=Eu(e.target);let W=0,D;const{x:E,y:G}=dt(e),T=Gu(r,B),O=l?.getBoundingClientRect();let P=!1;if(!O||!T)return;const L=$u(s,T,o,c,t);if(!L)return;let M=dt(e,O),F=!1,U=null,V=!1,Y=null;function Z(){if(!f||!O)return;const[ee,ne]=Cu(M,O,j);p({x:ee,y:ne}),W=requestAnimationFrame(Z)}const q={...L,nodeId:s,type:T,position:L.position},X=c.get(s);let C={inProgress:!0,isValid:null,from:ri(X,q,le.Left,!0),fromHandle:q,fromPosition:q.position,fromNode:X,to:M,toHandle:null,toPosition:bl[q.position],toNode:null,pointer:M};function H(){P=!0,g(C),v?.(e,{nodeId:s,handleId:o,handleType:T})}N===0&&H();function K(ee){if(!P){const{x:de,y:me}=dt(ee),xe=de-E,je=me-G;if(!(xe*xe+je*je>N*N))return;H()}if(!w()||!q){Q(ee);return}const ne=y();M=dt(ee,O),D=cb(_o(M,ne,!1,[1,1]),n,c,q),F||(Z(),F=!0);const ie=Wu(ee,{handle:D,connectionMode:t,fromNodeId:s,fromHandleId:o,fromType:a?"target":"source",isValidConnection:x,doc:z,lib:u,flowId:d,nodeLookup:c});Y=ie.handleDomNode,U=ie.connection,V=ub(!!D,ie.isValid);const re=c.get(s),J=re?ri(re,q,le.Left,!0):C.from,ce={...C,from:J,isValid:V,to:ie.toHandle&&V?bs({x:ie.toHandle.x,y:ie.toHandle.y},ne):M,toHandle:ie.toHandle,toPosition:V&&ie.toHandle?ie.toHandle.position:bl[q.position],toNode:ie.toHandle?c.get(ie.toHandle.nodeId):null,pointer:M};g(ce),C=ce}function Q(ee){if(!("touches"in ee&&ee.touches.length>0)){if(P){(D||Y)&&U&&V&&b?.(U);const{inProgress:ne,...ie}=C,re={...ie,toPosition:C.toHandle?C.toPosition:null};S?.(ee,re),r&&_?.(ee,re)}h(),cancelAnimationFrame(W),F=!1,V=!1,U=null,Y=null,z.removeEventListener("mousemove",K),z.removeEventListener("mouseup",Q),z.removeEventListener("touchmove",K),z.removeEventListener("touchend",Q)}}z.addEventListener("mousemove",K),z.addEventListener("mouseup",Q),z.addEventListener("touchmove",K),z.addEventListener("touchend",Q)}function Wu(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:s,fromType:r,doc:a,lib:l,flowId:c,isValidConnection:u=Hu,nodeLookup:f}){const d=r==="target",p=t?a.querySelector(`.${l}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:h,y:v}=dt(e),b=a.elementFromPoint(h,v),S=b?.classList.contains(`${l}-flow__handle`)?b:p,x={handleDomNode:S,isValid:!1,connection:null,toHandle:null};if(S){const _=Gu(void 0,S),g=S.getAttribute("data-nodeid"),y=S.getAttribute("data-handleid"),w=S.classList.contains("connectable"),j=S.classList.contains("connectableend");if(!g||!_)return x;const N={source:d?g:o,sourceHandle:d?y:s,target:d?o:g,targetHandle:d?s:y};x.connection=N;const z=w&&j&&(n===_i.Strict?d&&_==="source"||!d&&_==="target":g!==o||y!==s);x.isValid=z&&u(N),x.toHandle=$u(g,_,y,f,n,!0)}return x}const qr={onPointerDown:db,isValid:Wu};function fb({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const s=Ve(e);function r({translateExtent:l,width:c,height:u,zoomStep:f=1,pannable:d=!0,zoomable:p=!0,inversePan:h=!1}){const v=g=>{if(g.sourceEvent.type!=="wheel"||!t)return;const y=n(),w=g.sourceEvent.ctrlKey&&fo()?10:1,j=-g.sourceEvent.deltaY*(g.sourceEvent.deltaMode===1?.05:g.sourceEvent.deltaMode?1:.002)*f,N=y[2]*Math.pow(2,j*w);t.scaleTo(N)};let b=[0,0];const S=g=>{(g.sourceEvent.type==="mousedown"||g.sourceEvent.type==="touchstart")&&(b=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY])},x=g=>{const y=n();if(g.sourceEvent.type!=="mousemove"&&g.sourceEvent.type!=="touchmove"||!t)return;const w=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY],j=[w[0]-b[0],w[1]-b[1]];b=w;const N=o()*Math.max(y[2],Math.log(y[2]))*(h?-1:1),B={x:y[0]-j[0]*N,y:y[1]-j[1]*N},z=[[0,0],[c,u]];t.setViewportConstrained({x:B.x,y:B.y,zoom:y[2]},z,l)},_=xu().on("start",S).on("zoom",d?x:null).on("zoom.wheel",p?v:null);s.call(_,{})}function a(){s.on("zoom",null)}return{update:r,destroy:a,pointer:st}}const Ds=e=>({x:e.x,y:e.y,zoom:e.k}),ur=({x:e,y:t,zoom:n})=>Bs.translate(e,t).scale(n),gi=(e,t)=>e.target.closest(`.${t}`),Uu=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),pb=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,dr=(e,t=0,n=pb,o=()=>{})=>{const s=typeof t=="number"&&t>0;return s||o(),s?e.transition().duration(t).ease(n).on("end",o):e},Vu=e=>{const t=e.ctrlKey&&fo()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function hb({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:s,panOnScrollSpeed:r,zoomOnPinch:a,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:u}){return f=>{if(gi(f,t))return f.ctrlKey&&f.preventDefault(),!1;f.preventDefault(),f.stopImmediatePropagation();const d=n.property("__zoom").k||1;if(f.ctrlKey&&a){const S=st(f),x=Vu(f),_=d*Math.pow(2,x);o.scaleTo(n,_,S,f);return}const p=f.deltaMode===1?20:1;let h=s===ni.Vertical?0:f.deltaX*p,v=s===ni.Horizontal?0:f.deltaY*p;!fo()&&f.shiftKey&&s!==ni.Vertical&&(h=f.deltaY*p,v=0),o.translateBy(n,-(h/d)*r,-(v/d)*r,{internal:!0});const b=Ds(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(f,b),e.panScrollTimeout=setTimeout(()=>{u?.(f,b),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l?.(f,b))}}function mb({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,s){const r=o.type==="wheel",a=!t&&r&&!o.ctrlKey,l=gi(o,e);if(o.ctrlKey&&r&&l&&o.preventDefault(),a||l)return null;o.preventDefault(),n.call(this,o,s)}}function gb({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const s=Ds(o.transform);e.mouseButton=o.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=s,o.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(o.sourceEvent,s)}}function bb({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:s}){return r=>{e.usedRightMouseButton=!!(n&&Uu(t,e.mouseButton??0)),r.sourceEvent?.sync||o([r.transform.x,r.transform.y,r.transform.k]),s&&!r.sourceEvent?.internal&&s?.(r.sourceEvent,Ds(r.transform))}}function xb({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:s,onPaneContextMenu:r}){return a=>{if(!a.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,r&&Uu(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&r(a.sourceEvent),e.usedRightMouseButton=!1,o(!1),s)){const l=Ds(a.transform);e.prevViewport=l,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s?.(a.sourceEvent,l)},n?150:0)}}}function yb({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:o,panOnScroll:s,zoomOnDoubleClick:r,userSelectionActive:a,noWheelClassName:l,noPanClassName:c,lib:u,connectionInProgress:f}){return d=>{const p=e||t,h=n&&d.ctrlKey,v=d.type==="wheel";if(d.button===1&&d.type==="mousedown"&&(gi(d,`${u}-flow__node`)||gi(d,`${u}-flow__edge`)))return!0;if(!o&&!p&&!s&&!r&&!n||a||f&&!v||gi(d,l)&&v||gi(d,c)&&(!v||s&&v&&!e)||!n&&d.ctrlKey&&v)return!1;if(!n&&d.type==="touchstart"&&d.touches?.length>1)return d.preventDefault(),!1;if(!p&&!s&&!h&&v||!o&&(d.type==="mousedown"||d.type==="touchstart")||Array.isArray(o)&&!o.includes(d.button)&&d.type==="mousedown")return!1;const b=Array.isArray(o)&&o.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||v)&&b}}function vb({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:s,onPanZoom:r,onPanZoomStart:a,onPanZoomEnd:l,onDraggingChange:c}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},f=e.getBoundingClientRect(),d=xu().scaleExtent([t,n]).translateExtent(o),p=Ve(e).call(d);_({x:s.x,y:s.y,zoom:ji(s.zoom,t,n)},[[0,0],[f.width,f.height]],o);const h=p.on("wheel.zoom"),v=p.on("dblclick.zoom");d.wheelDelta(Vu);function b(D,E){return p?new Promise(G=>{d?.interpolate(E?.interpolate==="linear"?qi:ts).transform(dr(p,E?.duration,E?.ease,()=>G(!0)),D)}):Promise.resolve(!1)}function S({noWheelClassName:D,noPanClassName:E,onPaneContextMenu:G,userSelectionActive:T,panOnScroll:O,panOnDrag:P,panOnScrollMode:L,panOnScrollSpeed:M,preventScrolling:F,zoomOnPinch:U,zoomOnScroll:V,zoomOnDoubleClick:Y,zoomActivationKeyPressed:Z,lib:q,onTransformChange:X,connectionInProgress:A,paneClickDistance:C,selectionOnDrag:H}){T&&!u.isZoomingOrPanning&&x();const K=O&&!Z&&!T;d.clickDistance(H?1/0:!ut(C)||C<0?0:C);const Q=K?hb({zoomPanValues:u,noWheelClassName:D,d3Selection:p,d3Zoom:d,panOnScrollMode:L,panOnScrollSpeed:M,zoomOnPinch:U,onPanZoomStart:a,onPanZoom:r,onPanZoomEnd:l}):mb({noWheelClassName:D,preventScrolling:F,d3ZoomHandler:h});if(p.on("wheel.zoom",Q,{passive:!1}),!T){const ne=gb({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:a});d.on("start",ne);const ie=bb({zoomPanValues:u,panOnDrag:P,onPaneContextMenu:!!G,onPanZoom:r,onTransformChange:X});d.on("zoom",ie);const re=xb({zoomPanValues:u,panOnDrag:P,panOnScroll:O,onPaneContextMenu:G,onPanZoomEnd:l,onDraggingChange:c});d.on("end",re)}const ee=yb({zoomActivationKeyPressed:Z,panOnDrag:P,zoomOnScroll:V,panOnScroll:O,zoomOnDoubleClick:Y,zoomOnPinch:U,userSelectionActive:T,noPanClassName:E,noWheelClassName:D,lib:q,connectionInProgress:A});d.filter(ee),Y?p.on("dblclick.zoom",v):p.on("dblclick.zoom",null)}function x(){d.on("zoom",null)}async function _(D,E,G){const T=ur(D),O=d?.constrain()(T,E,G);return O&&await b(O),new Promise(P=>P(O))}async function g(D,E){const G=ur(D);return await b(G,E),new Promise(T=>T(G))}function y(D){if(p){const E=ur(D),G=p.property("__zoom");(G.k!==D.zoom||G.x!==D.x||G.y!==D.y)&&d?.transform(p,E,null,{sync:!0})}}function w(){const D=p?bu(p.node()):{x:0,y:0,k:1};return{x:D.x,y:D.y,zoom:D.k}}function j(D,E){return p?new Promise(G=>{d?.interpolate(E?.interpolate==="linear"?qi:ts).scaleTo(dr(p,E?.duration,E?.ease,()=>G(!0)),D)}):Promise.resolve(!1)}function N(D,E){return p?new Promise(G=>{d?.interpolate(E?.interpolate==="linear"?qi:ts).scaleBy(dr(p,E?.duration,E?.ease,()=>G(!0)),D)}):Promise.resolve(!1)}function B(D){d?.scaleExtent(D)}function z(D){d?.translateExtent(D)}function W(D){const E=!ut(D)||D<0?0:D;d?.clickDistance(E)}return{update:S,destroy:x,setViewport:g,setViewportConstrained:_,getViewport:w,scaleTo:j,scaleBy:N,setScaleExtent:B,setTranslateExtent:z,syncViewport:y,setClickDistance:W}}var Ni;(function(e){e.Line="line",e.Handle="handle"})(Ni||(Ni={}));function wb({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:s,affectsY:r}){const a=e-t,l=n-o,c=[a>0?1:a<0?-1:0,l>0?1:l<0?-1:0];return a&&s&&(c[0]=c[0]*-1),l&&r&&(c[1]=c[1]*-1),c}function El(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),o=e.includes("left"),s=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:o,affectsY:s}}function dn(e,t){return Math.max(0,t-e)}function fn(e,t){return Math.max(0,e-t)}function zo(e,t,n){return Math.max(0,t-e,e-n)}function Al(e,t){return e?!t:t}function Sb(e,t,n,o,s,r,a,l){let{affectsX:c,affectsY:u}=t;const{isHorizontal:f,isVertical:d}=t,p=f&&d,{xSnapped:h,ySnapped:v}=n,{minWidth:b,maxWidth:S,minHeight:x,maxHeight:_}=o,{x:g,y,width:w,height:j,aspectRatio:N}=e;let B=Math.floor(f?h-e.pointerX:0),z=Math.floor(d?v-e.pointerY:0);const W=w+(c?-B:B),D=j+(u?-z:z),E=-r[0]*w,G=-r[1]*j;let T=zo(W,b,S),O=zo(D,x,_);if(a){let M=0,F=0;c&&B<0?M=dn(g+B+E,a[0][0]):!c&&B>0&&(M=fn(g+W+E,a[1][0])),u&&z<0?F=dn(y+z+G,a[0][1]):!u&&z>0&&(F=fn(y+D+G,a[1][1])),T=Math.max(T,M),O=Math.max(O,F)}if(l){let M=0,F=0;c&&B>0?M=fn(g+B,l[0][0]):!c&&B<0&&(M=dn(g+W,l[1][0])),u&&z>0?F=fn(y+z,l[0][1]):!u&&z<0&&(F=dn(y+D,l[1][1])),T=Math.max(T,M),O=Math.max(O,F)}if(s){if(f){const M=zo(W/N,x,_)*N;if(T=Math.max(T,M),a){let F=0;!c&&!u||c&&!u&&p?F=fn(y+G+W/N,a[1][1])*N:F=dn(y+G+(c?B:-B)/N,a[0][1])*N,T=Math.max(T,F)}if(l){let F=0;!c&&!u||c&&!u&&p?F=dn(y+W/N,l[1][1])*N:F=fn(y+(c?B:-B)/N,l[0][1])*N,T=Math.max(T,F)}}if(d){const M=zo(D*N,b,S)/N;if(O=Math.max(O,M),a){let F=0;!c&&!u||u&&!c&&p?F=fn(g+D*N+E,a[1][0])/N:F=dn(g+(u?z:-z)*N+E,a[0][0])/N,O=Math.max(O,F)}if(l){let F=0;!c&&!u||u&&!c&&p?F=dn(g+D*N,l[1][0])/N:F=fn(g+(u?z:-z)*N,l[0][0])/N,O=Math.max(O,F)}}}z=z+(z<0?O:-O),B=B+(B<0?T:-T),s&&(p?W>D*N?z=(Al(c,u)?-B:B)/N:B=(Al(c,u)?-z:z)*N:f?(z=B/N,u=c):(B=z*N,c=u));const P=c?g+B:g,L=u?y+z:y;return{width:w+(c?-B:B),height:j+(u?-z:z),x:r[0]*B*(c?-1:1)+P,y:r[1]*z*(u?-1:1)+L}}const Yu={width:0,height:0,x:0,y:0},_b={...Yu,pointerX:0,pointerY:0,aspectRatio:1};function jb(e){return[[0,0],[e.measured.width,e.measured.height]]}function Mb(e,t,n){const o=t.position.x+e.position.x,s=t.position.y+e.position.y,r=e.measured.width??0,a=e.measured.height??0,l=n[0]*r,c=n[1]*a;return[[o-l,s-c],[o+r-l,s+a-c]]}function Cb({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:s}){const r=Ve(e);let a={controlDirection:El("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:u,boundaries:f,keepAspectRatio:d,resizeDirection:p,onResizeStart:h,onResize:v,onResizeEnd:b,shouldResize:S}){let x={...Yu},_={..._b};a={boundaries:f,resizeDirection:p,keepAspectRatio:d,controlDirection:El(u)};let g,y=null,w=[],j,N,B,z=!1;const W=iu().on("start",D=>{const{nodeLookup:E,transform:G,snapGrid:T,snapToGrid:O,nodeOrigin:P,paneDomNode:L}=n();if(g=E.get(t),!g)return;y=L?.getBoundingClientRect()??null;const{xSnapped:M,ySnapped:F}=Qi(D.sourceEvent,{transform:G,snapGrid:T,snapToGrid:O,containerBounds:y});x={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},_={...x,pointerX:M,pointerY:F,aspectRatio:x.width/x.height},j=void 0,g.parentId&&(g.extent==="parent"||g.expandParent)&&(j=E.get(g.parentId),N=j&&g.extent==="parent"?jb(j):void 0),w=[],B=void 0;for(const[U,V]of E)if(V.parentId===t&&(w.push({id:U,position:{...V.position},extent:V.extent}),V.extent==="parent"||V.expandParent)){const Y=Mb(V,g,V.origin??P);B?B=[[Math.min(Y[0][0],B[0][0]),Math.min(Y[0][1],B[0][1])],[Math.max(Y[1][0],B[1][0]),Math.max(Y[1][1],B[1][1])]]:B=Y}h?.(D,{...x})}).on("drag",D=>{const{transform:E,snapGrid:G,snapToGrid:T,nodeOrigin:O}=n(),P=Qi(D.sourceEvent,{transform:E,snapGrid:G,snapToGrid:T,containerBounds:y}),L=[];if(!g)return;const{x:M,y:F,width:U,height:V}=x,Y={},Z=g.origin??O,{width:q,height:X,x:A,y:C}=Sb(_,a.controlDirection,P,a.boundaries,a.keepAspectRatio,Z,N,B),H=q!==U,K=X!==V,Q=A!==M&&H,ee=C!==F&&K;if(!Q&&!ee&&!H&&!K)return;if((Q||ee||Z[0]===1||Z[1]===1)&&(Y.x=Q?A:x.x,Y.y=ee?C:x.y,x.x=Y.x,x.y=Y.y,w.length>0)){const J=A-M,ce=C-F;for(const de of w)de.position={x:de.position.x-J+Z[0]*(q-U),y:de.position.y-ce+Z[1]*(X-V)},L.push(de)}if((H||K)&&(Y.width=H&&(!a.resizeDirection||a.resizeDirection==="horizontal")?q:x.width,Y.height=K&&(!a.resizeDirection||a.resizeDirection==="vertical")?X:x.height,x.width=Y.width,x.height=Y.height),j&&g.expandParent){const J=Z[0]*(Y.width??0);Y.x&&Y.x<J&&(x.x=J,_.x=_.x-(Y.x-J));const ce=Z[1]*(Y.height??0);Y.y&&Y.y<ce&&(x.y=ce,_.y=_.y-(Y.y-ce))}const ne=wb({width:x.width,prevWidth:U,height:x.height,prevHeight:V,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),ie={...x,direction:ne};S?.(D,ie)!==!1&&(z=!0,v?.(D,ie),o(Y,L))}).on("end",D=>{z&&(b?.(D,{...x}),s?.({...x}),z=!1)});r.call(W)}function c(){r.on(".drag",null)}return{update:l,destroy:c}}const Fs=m.createContext(null),Nb=Fs.Provider,Zu=Et.error001();function he(e,t){const n=m.useContext(Fs);if(n===null)throw new Error(Zu);return kc.useStoreWithEqualityFn(n,e,t)}function _e(){const e=m.useContext(Fs);if(e===null)throw new Error(Zu);return m.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const kl={display:"none"},Tb={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Xu="react-flow__node-desc",Ku="react-flow__edge-desc",Ib="react-flow__aria-live",Eb=e=>e.ariaLiveMessage,Ab=e=>e.ariaLabelConfig;function kb({rfId:e}){const t=he(Eb);return i.jsx("div",{id:`${Ib}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Tb,children:t})}function Bb({rfId:e,disableKeyboardA11y:t}){const n=he(Ab);return i.jsxs(i.Fragment,{children:[i.jsx("div",{id:`${Xu}-${e}`,style:kl,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),i.jsx("div",{id:`${Ku}-${e}`,style:kl,children:n["edge.a11yDescription.default"]}),!t&&i.jsx(kb,{rfId:e})]})}const Ls=m.forwardRef(({position:e="top-left",children:t,className:n,style:o,...s},r)=>{const a=`${e}`.split("-");return i.jsx("div",{className:Ee(["react-flow__panel",n,...a]),style:o,ref:r,...s,children:t})});Ls.displayName="Panel";function Pb({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:i.jsx(Ls,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:i.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Rb=e=>{const t=[],n=[];for(const[,o]of e.nodeLookup)o.selected&&t.push(o.internals.userNode);for(const[,o]of e.edgeLookup)o.selected&&n.push(o);return{selectedNodes:t,selectedEdges:n}},Oo=e=>e.id;function Db(e,t){return Se.shallow(e.selectedNodes.map(Oo),t.selectedNodes.map(Oo))&&Se.shallow(e.selectedEdges.map(Oo),t.selectedEdges.map(Oo))}function Fb({onSelectionChange:e}){const t=_e(),{selectedNodes:n,selectedEdges:o}=he(Rb,Db);return m.useEffect(()=>{const s={nodes:n,edges:o};e?.(s),t.getState().onSelectionChangeHandlers.forEach(r=>r(s))},[n,o,e]),null}const Lb=e=>!!e.onSelectionChangeHandlers;function zb({onSelectionChange:e}){const t=he(Lb);return e||t?i.jsx(Fb,{onSelectionChange:e}):null}const Qr=typeof window<"u"?m.useLayoutEffect:m.useEffect,qu=[0,0],Ob={x:0,y:0,zoom:1},$b=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],Bl=[...$b,"rfId"],Gb=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),Pl={translateExtent:ao,nodeOrigin:qu,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Hb(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:s,setTranslateExtent:r,setNodeExtent:a,reset:l,setDefaultNodesAndEdges:c}=he(Gb,Se.shallow),u=_e();Qr(()=>(c(e.defaultNodes,e.defaultEdges),()=>{f.current=Pl,l()}),[]);const f=m.useRef(Pl);return Qr(()=>{for(const d of Bl){const p=e[d],h=f.current[d];p!==h&&(typeof e[d]>"u"||(d==="nodes"?t(p):d==="edges"?n(p):d==="minZoom"?o(p):d==="maxZoom"?s(p):d==="translateExtent"?r(p):d==="nodeExtent"?a(p):d==="ariaLabelConfig"?u.setState({ariaLabelConfig:L0(p)}):d==="fitView"?u.setState({fitViewQueued:p}):d==="fitViewOptions"?u.setState({fitViewOptions:p}):u.setState({[d]:p})))}f.current=e},Bl.map(d=>e[d])),null}function Rl(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Wb(e){const[t,n]=m.useState(e==="system"?null:e);return m.useEffect(()=>{if(e!=="system"){n(e);return}const o=Rl(),s=()=>n(o?.matches?"dark":"light");return s(),o?.addEventListener("change",s),()=>{o?.removeEventListener("change",s)}},[e]),t!==null?t:Rl()?.matches?"dark":"light"}const Dl=typeof document<"u"?document:null;function po(e=null,t={target:Dl,actInsideInputWithModifier:!0}){const[n,o]=m.useState(!1),s=m.useRef(!1),r=m.useRef(new Set([])),[a,l]=m.useMemo(()=>{if(e!==null){const u=(Array.isArray(e)?e:[e]).filter(d=>typeof d=="string").map(d=>d.replace("+",`
|
|
1
|
+
"use strict";const i=require("react/jsx-runtime"),m=require("react"),ge=require("./gaesupStore-CE-oe63F.cjs"),R=require("./index--tenkUDe.cjs"),kc=require("zustand/traditional"),Se=require("zustand/shallow");require("react-dom");const be=require("@react-three/fiber"),ct=require("@react-three/rapier"),se=require("./sfe-RrB92jNe.cjs"),bn=require("./assetStore-BuE4mh1C.cjs"),mi=require("./index-DCa_lUwq.cjs"),Bi=require("zustand"),ls=require("zustand/react/shallow"),We=require("./templates-eL763zpL.cjs"),Jn=require("./index-CI6HBNFU.cjs"),pt=require("@react-three/drei"),_p=require("three"),ua=require("three-stdlib");require("reflect-metadata");const da=require("./weatherStore-1unmwIen.cjs"),fa=require("simplex-noise"),jp=require("./authStore-CrDnYNnL.cjs");function Mp(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const k=Mp(_p);function Oe({label:e,min:t,max:n,step:o,value:s,suffix:r,onChange:a}){return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:11,color:"#fff"},children:[i.jsx("span",{style:{width:60,flexShrink:0,color:"rgba(255,255,255,0.7)"},children:e}),i.jsx("input",{type:"range",min:t,max:n,step:o,value:s,onChange:l=>a(Number(l.target.value)),style:{flex:1,accentColor:"#0078d4"}}),i.jsxs("span",{style:{width:44,textAlign:"right",fontFamily:"monospace",fontSize:11},children:[typeof o=="number"&&o<1?s.toFixed(2):s,r??""]})]})}function tr({label:e,checked:t,onChange:n}){return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:11,color:"#fff"},children:[i.jsx("input",{type:"checkbox",checked:t,onChange:o=>n(o.target.checked),style:{accentColor:"#0078d4"}}),i.jsx("span",{children:e})]})}function Di({title:e,children:t}){return i.jsxs("div",{style:{background:"rgba(0,0,0,0.2)",borderRadius:6,padding:"8px 10px",border:"1px solid rgba(255,255,255,0.08)",display:"flex",flexDirection:"column",gap:6},children:[i.jsx("div",{style:{fontSize:10,fontWeight:600,color:"rgba(255,255,255,0.5)",textTransform:"uppercase",letterSpacing:.5},children:e}),t]})}function Cp(){const e=ge.useGaesupStore(a=>a.cameraOption),t=ge.useGaesupStore(a=>a.setCameraOption),n=ge.useGaesupStore(a=>a.mode),o=m.useCallback((a,l)=>{t({[a]:l})},[t]),s=m.useCallback((a,l)=>{t({smoothing:{...e.smoothing,[a]:l}})},[t,e.smoothing]),r=a=>e[a]??0;return i.jsxs("div",{style:{padding:10,display:"flex",flexDirection:"column",gap:10},children:[i.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.5)",marginBottom:-4},children:["Mode: ",n.control??"thirdPerson"]}),i.jsxs(Di,{title:"Distance",children:[i.jsx(Oe,{label:"X",min:-50,max:50,step:1,value:r("xDistance"),onChange:a=>o("xDistance",a)}),i.jsx(Oe,{label:"Y",min:0,max:50,step:1,value:r("yDistance"),onChange:a=>o("yDistance",a)}),i.jsx(Oe,{label:"Z",min:-50,max:50,step:1,value:r("zDistance"),onChange:a=>o("zDistance",a)})]}),i.jsxs(Di,{title:"FOV / Smoothing",children:[i.jsx(Oe,{label:"FOV",min:30,max:120,step:5,value:e.fov??75,suffix:"deg",onChange:a=>o("fov",a)}),i.jsx(Oe,{label:"Pos",min:.01,max:1,step:.01,value:e.smoothing?.position??.1,onChange:a=>s("position",a)}),i.jsx(Oe,{label:"Rot",min:.01,max:1,step:.01,value:e.smoothing?.rotation??.1,onChange:a=>s("rotation",a)}),i.jsx(Oe,{label:"FOV Sm",min:.01,max:1,step:.01,value:e.smoothing?.fov??.2,onChange:a=>s("fov",a)})]}),i.jsxs(Di,{title:"Zoom",children:[i.jsx(tr,{label:"Enable Zoom",checked:e.enableZoom??!1,onChange:a=>o("enableZoom",a)}),i.jsx(Oe,{label:"Speed",min:1e-4,max:.01,step:1e-4,value:e.zoomSpeed??.001,onChange:a=>o("zoomSpeed",a)}),i.jsx(Oe,{label:"Min",min:.1,max:2,step:.1,value:e.minZoom??.5,onChange:a=>o("minZoom",a)}),i.jsx(Oe,{label:"Max",min:1,max:5,step:.1,value:e.maxZoom??2,onChange:a=>o("maxZoom",a)})]}),i.jsxs(Di,{title:"Options",children:[i.jsx(tr,{label:"Collision",checked:e.enableCollision??!1,onChange:a=>o("enableCollision",a)}),i.jsx(tr,{label:"Focus Mode",checked:e.enableFocus??!1,onChange:a=>o("enableFocus",a)}),i.jsx(Oe,{label:"Focus Dist",min:1,max:50,step:1,value:e.focusDistance??15,onChange:a=>o("focusDistance",a)}),i.jsx(Oe,{label:"Max Dist",min:5,max:100,step:1,value:e.maxDistance??50,onChange:a=>o("maxDistance",a)})]}),i.jsxs(Di,{title:"Bounds",children:[i.jsx(Oe,{label:"Min Y",min:-10,max:50,step:1,value:e.bounds?.minY??2,onChange:a=>t({bounds:{...e.bounds,minY:a}})}),i.jsx(Oe,{label:"Max Y",min:5,max:100,step:1,value:e.bounds?.maxY??50,onChange:a=>t({bounds:{...e.bounds,maxY:a}})})]})]})}const Np=[{value:"thirdPerson",label:"Third Person"},{value:"firstPerson",label:"First Person"},{value:"chase",label:"Chase"},{value:"topDown",label:"Top Down"},{value:"isometric",label:"Isometric"},{value:"sideScroll",label:"Side-Scroller"},{value:"fixed",label:"Fixed"}];function Tp(){const{mode:e,setMode:t}=ge.useGaesupStore(ls.useShallow(o=>({mode:o.mode,setMode:o.setMode}))),n=e?.control||"thirdPerson";return i.jsx("div",{className:"cc-panel",children:i.jsx("div",{className:"cc-list",children:Np.map(o=>i.jsx("button",{className:`cc-button ${n===o.value?"active":""}`,onClick:()=>t({control:o.value}),children:o.label},o.value))})})}const Ip=[{key:"mode",label:"Mode",enabled:!0,format:"text"},{key:"position",label:"Position",enabled:!0,format:"vector3",precision:2},{key:"distance",label:"Distance",enabled:!0,format:"vector3",precision:2},{key:"fov",label:"FOV",enabled:!0,format:"angle",precision:1},{key:"velocity",label:"Velocity",enabled:!1,format:"vector3",precision:2},{key:"rotation",label:"Rotation",enabled:!1,format:"vector3",precision:2},{key:"zoom",label:"Zoom",enabled:!1,format:"number",precision:2},{key:"activeController",label:"Controller",enabled:!0,format:"text"}];function nr(e){if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.x=="number"&&typeof t.y=="number"&&typeof t.z=="number"}function Bc(){const e={frameCount:0,averageFrameTime:0,lastUpdateTime:Date.now(),mode:"unknown",activeController:"unknown",distance:null,fov:0,position:null,targetPosition:null,velocity:null,rotation:null},[t,n]=m.useState(e),o=ge.useGaesupStore(d=>d.mode),s=ge.useGaesupStore(d=>d.cameraOption),{activeState:r}=R.useStateSystem(),a=m.useRef(e),l=m.useCallback((d,p)=>d===p?!1:nr(d)?nr(p)?d.x!==p.x||d.y!==p.y||d.z!==p.z:!0:typeof d!="object"||d===null?!0:JSON.stringify(d)!==JSON.stringify(p),[]),c=m.useCallback(d=>nr(d)?{x:d.x,y:d.y,z:d.z}:null,[]),u=m.useCallback(()=>{const d=s?.xDistance!==void 0&&s?.yDistance!==void 0&&s?.zDistance!==void 0?{x:s.xDistance,y:s.yDistance,z:s.zDistance}:null,p={...a.current,mode:o?.control??"unknown",activeController:s?.mode??o?.control??"unknown",distance:d,fov:s?.fov??0,position:c(r?.position),targetPosition:c(s?.target),velocity:c(r?.velocity),rotation:c(r?.euler),lastUpdateTime:Date.now(),...s?.zoom!==void 0?{zoom:s.zoom}:{}};Object.keys(p).some(v=>l(p[v],a.current[v]))&&(a.current=p,n(p))},[o,s,r,l,c]);m.useEffect(()=>{u();const d=setInterval(u,100);return()=>{clearInterval(d)}},[u]);const f=m.useCallback((d,p=2)=>d==null?"N/A":typeof d=="object"&&d.x!==void 0?`X:${d.x.toFixed(p)} Y:${d.y.toFixed(p)} Z:${d.z.toFixed(p)}`:typeof d=="number"?d.toFixed(p):d.toString(),[]);return i.jsx("div",{className:"cd-panel",children:i.jsx("div",{className:"cd-grid",children:Ip.map(d=>i.jsxs("div",{className:"cd-item",children:[i.jsx("span",{className:"cd-label",children:d.label}),i.jsx("span",{className:"cd-value",children:f(t[d.key])})]},d.key))})})}const Ep=[{id:"classic",name:"Classic",description:"A traditional third-person view.",icon:"camera",config:{mode:"thirdPerson",distance:{x:0,y:8,z:10},fov:75,smoothing:{position:.1,rotation:.1,fov:.1}}},{id:"cinematic",name:"Cinematic",description:"Smooth, movie-like camera work.",icon:"camera",config:{mode:"chase",distance:{x:2,y:7,z:8},fov:60,smoothing:{position:.05,rotation:.05,fov:.05}}},{id:"action",name:"Action",description:"Responsive camera for fast gameplay.",icon:"camera",config:{mode:"thirdPerson",distance:{x:0,y:6,z:6},fov:85,smoothing:{position:.2,rotation:.2,fov:.2}}},{id:"strategy",name:"Strategy",description:"Top-down view for an overview.",icon:"camera",config:{mode:"topDown",distance:{x:0,y:20,z:0},fov:45,smoothing:{position:.1,rotation:.1,fov:.1}}},{id:"retro",name:"Retro",description:"Classic side-scroller style.",icon:"camera",config:{mode:"sideScroll",distance:{x:15,y:0,z:0},fov:75,smoothing:{position:.15,rotation:.15,fov:.15}}}];function Ap(e,t){return!e||!t?!1:e.x===t.x&&e.y===t.y&&e.z===t.z}function kp(e){const t=e?.xDistance,n=e?.yDistance,o=e?.zDistance;if(!(t===void 0||n===void 0||o===void 0))return{x:t,y:n,z:o}}function Pc(){const[e]=m.useState(Ep),t=ge.useGaesupStore(c=>c.setMode),n=ge.useGaesupStore(c=>c.setCameraOption),o=ge.useGaesupStore(c=>c.mode),s=ge.useGaesupStore(c=>c.cameraOption),[r,a]=m.useState(null),l=m.useCallback(c=>{t({control:c.config.mode}),n({xDistance:c.config.distance.x,yDistance:c.config.distance.y,zDistance:c.config.distance.z,fov:c.config.fov,smoothing:c.config.smoothing||{position:.1,rotation:.1,fov:.1}})},[t,n,s]);return m.useEffect(()=>{const c=e.find(u=>u.config.mode===o?.control&&Ap(u.config.distance,kp(s)));a(c?c.id:null)},[o,s,e]),i.jsx("div",{className:"cp-panel",children:i.jsx("div",{className:"cp-grid",children:e.map(c=>i.jsxs("button",{className:`cp-item ${r===c.id?"active":""}`,onClick:()=>l(c),children:[i.jsx("div",{className:"cp-name",children:c.name}),i.jsx("div",{className:"cp-description",children:c.description})]},c.id))})})}function Rc({className:e="",style:t,children:n}={}){const[o,s]=m.useState("Settings"),r=()=>{switch(o){case"Settings":return i.jsx(Cp,{});case"Controller":return i.jsx(Tp,{});case"Presets":return i.jsx(Pc,{});case"Debug":return i.jsx(Bc,{});default:return null}};return i.jsxs("div",{className:`tabbed-panel ${e}`,style:t,children:[i.jsxs("div",{className:"panel-tabs",children:[i.jsx("button",{className:`panel-tab ${o==="Settings"?"active":""}`,onClick:()=>s("Settings"),children:"Settings"}),i.jsx("button",{className:`panel-tab ${o==="Controller"?"active":""}`,onClick:()=>s("Controller"),children:"Controller"}),i.jsx("button",{className:`panel-tab ${o==="Presets"?"active":""}`,onClick:()=>s("Presets"),children:"Presets"}),i.jsx("button",{className:`panel-tab ${o==="Debug"?"active":""}`,onClick:()=>s("Debug"),children:"Debug"})]}),i.jsxs("div",{className:"panel-tab-content",children:[r(),n]})]})}const Bp=[{value:"idle",label:"Idle"},{value:"walk",label:"Walk"},{value:"run",label:"Run"},{value:"jump",label:"Jump"},{value:"fall",label:"Fall"},{value:"dance",label:"Dance"},{value:"wave",label:"Wave"}];function Pp(){const{playAnimation:e,currentType:t,currentAnimation:n}=R.useAnimationBridge(),o=s=>{e(t,s)};return i.jsx("div",{className:"ac-panel",children:i.jsx("div",{className:"ac-grid",children:Bp.map(s=>i.jsx("button",{className:`ac-button ${s.value===n?"active":""}`,onClick:()=>o(s.value),title:s.label,children:s.label},s.value))})})}const Rp=[{key:"currentAnimation",label:"현재 애니메이션",format:"text",enabled:!0},{key:"animationType",label:"애니메이션 타입",format:"text",enabled:!0},{key:"isPlaying",label:"재생 상태",format:"text",enabled:!0},{key:"weight",label:"가중치",format:"number",enabled:!0},{key:"speed",label:"속도",format:"number",enabled:!0},{key:"blendDuration",label:"블렌드 시간",format:"number",enabled:!1},{key:"activeActions",label:"활성 액션",format:"number",enabled:!0},{key:"availableAnimations",label:"사용 가능 애니메이션",format:"array",enabled:!1},{key:"frameCount",label:"프레임 카운트",format:"number",enabled:!1},{key:"averageFrameTime",label:"평균 프레임 시간",format:"number",enabled:!1}];function Dc(){const{bridge:e,currentType:t}=R.useAnimationBridge(),[n,o]=m.useState({frameCount:0,averageFrameTime:0,lastUpdateTime:Date.now(),currentAnimation:"idle",animationType:"character",availableAnimations:[],isPlaying:!1,weight:1,speed:1,blendDuration:.3,activeActions:0});m.useEffect(()=>{if(!e)return;const a=()=>{const c=e.snapshot(t);if(!c)return;const u=e.getMetrics(t);o(f=>({...f,currentAnimation:c.currentAnimation,animationType:t,availableAnimations:c.availableAnimations,isPlaying:c.isPlaying,weight:c.weight,speed:c.speed,activeActions:c.metrics.activeAnimations,frameCount:u?.totalActions||0,averageFrameTime:u?.mixerTime||0,lastUpdateTime:Date.now()}))};return a(),e.subscribe((c,u)=>{u===t&&a()})},[e,t]);const s=(a,l,c=2)=>{if(a==null)return"N/A";switch(l){case"array":return Array.isArray(a)?`${a.length} animations`:String(a);case"boolean":return a?"Yes":"No";case"number":return typeof a=="number"?a.toFixed(c):String(a);default:return String(a)}},r=a=>{if(a in n)return n[a]};return i.jsx("div",{className:"ad-panel",children:i.jsx("div",{className:"ad-content",children:Rp.filter(a=>a.enabled).map(a=>i.jsxs("div",{className:"ad-item",children:[i.jsx("span",{className:"ad-label",children:a.label}),i.jsx("span",{className:"ad-value",children:s(r(a.key),a.format)})]},a.key))})})}const Dp=()=>i.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:i.jsx("path",{d:"M8 5v14l11-7z"})}),Fp=()=>i.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:i.jsx("path",{d:"M6 19h4V5H6v14zm8-14v14h4V5h-4z"})}),Lp=()=>i.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:i.jsx("path",{d:"M6 6h2v12H6zm3.5 6l8.5 6V6z"})}),zp=()=>i.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:i.jsx("path",{d:"M6 18l8.5-6L6 6v12zM16 6v12h2V6h-2z"})});function Op(){const{bridge:e,playAnimation:t,stopAnimation:n,currentType:o,currentAnimation:s}=R.useAnimationBridge(),[r,a]=m.useState(!1),[l,c]=m.useState([]),[u,f]=m.useState(30);m.useEffect(()=>{if(!e)return;const p=()=>{const v=e.snapshot(o);v&&(a(v.isPlaying),c(v.availableAnimations))};return p(),e.subscribe((v,b)=>{b===o&&p()})},[e,o]);const d=()=>{r?n(o):t(o,s)};return i.jsxs("div",{className:"ap-panel",children:[i.jsxs("div",{className:"ap-controls",children:[i.jsx("select",{className:"ap-select",value:s,onChange:p=>t(o,p.target.value),children:l.map(p=>i.jsx("option",{value:p,children:p},p))}),i.jsxs("div",{className:"ap-buttons",children:[i.jsx("button",{className:"ap-btn","aria-label":"previous animation",children:i.jsx(Lp,{})}),i.jsx("button",{className:"ap-btn-primary",onClick:d,"aria-label":r?"pause":"play",children:r?i.jsx(Fp,{}):i.jsx(Dp,{})}),i.jsx("button",{className:"ap-btn","aria-label":"next animation",children:i.jsx(zp,{})})]})]}),i.jsxs("div",{className:"ap-timeline",children:[i.jsx("span",{className:"ap-time",children:"0:00"}),i.jsx("input",{type:"range",className:"ap-slider",min:"0",max:"100",value:u,onChange:p=>f(Number(p.target.value))}),i.jsx("span",{className:"ap-time",children:"1:30"})]})]})}function Fc({className:e="",style:t,children:n}={}){const[o,s]=m.useState("Player"),r=()=>{switch(o){case"Player":return i.jsx("div",{className:"panel-content-wrapper",children:i.jsx(Op,{})});case"Controller":return i.jsx("div",{className:"panel-content-wrapper",children:i.jsx(Pp,{})});case"Debug":return i.jsx("div",{className:"panel-content-wrapper",children:i.jsx(Dc,{})});default:return null}};return i.jsxs("div",{className:`tabbed-panel ${e}`,style:t,children:[i.jsxs("div",{className:"panel-tabs",children:[i.jsx("button",{className:`panel-tab ${o==="Player"?"active":""}`,onClick:()=>s("Player"),children:"Player"}),i.jsx("button",{className:`panel-tab ${o==="Controller"?"active":""}`,onClick:()=>s("Controller"),children:"Controller"}),i.jsx("button",{className:`panel-tab ${o==="Debug"?"active":""}`,onClick:()=>s("Debug"),children:"Debug"})]}),i.jsxs("div",{className:"panel-tab-content",children:[r(),n]})]})}const Ka=[{id:"slow",name:"Slow",maxSpeed:5,acceleration:8},{id:"normal",name:"Normal",maxSpeed:10,acceleration:15},{id:"fast",name:"Fast",maxSpeed:20,acceleration:25},{id:"sprint",name:"Sprint",maxSpeed:35,acceleration:40}],qa=[{id:"eco",name:"Eco",maxSpeed:15,acceleration:10},{id:"comfort",name:"Comfort",maxSpeed:25,acceleration:20},{id:"sport",name:"Sport",maxSpeed:40,acceleration:35},{id:"turbo",name:"Turbo",maxSpeed:60,acceleration:50}];function $p(e,t){const n=e??"bottom-left",o={position:"fixed",zIndex:t??1e4};return n.includes("top")&&(o.top=12),n.includes("bottom")&&(o.bottom=12),n.includes("left")&&(o.left=12),n.includes("right")&&(o.right=12),o}function Lc(e){const t=$p(e.position,e.zIndex),n=ge.useGaesupStore(p=>p.mode),o=ge.useGaesupStore(p=>p.setMode),s=ge.useGaesupStore(p=>p.setPhysics),r=n?.type==="vehicle"?"vehicle":"character",a=r==="vehicle"?qa:Ka,[l,c]=m.useState(r==="vehicle"?"comfort":"normal"),u=m.useCallback((p,h)=>{const b=(p==="vehicle"?qa:Ka).find(S=>S.id===h);if(b){if(p==="vehicle"){s({maxSpeed:b.maxSpeed,accelRatio:b.acceleration});return}s({walkSpeed:Math.max(1,b.maxSpeed*.5),runSpeed:b.maxSpeed,accelRatio:b.acceleration})}},[s]),f=m.useCallback(p=>{c(p),u(r,p),e.onPresetChange?.(p)},[u,r,e]),d=m.useCallback(p=>{const h=p.target.value;o({type:h});const v=h==="vehicle"?"comfort":"normal";c(v),u(h,v),e.onPresetChange?.(v)},[u,o,e]);return i.jsxs("div",{className:`mc-panel ${e.compact?"compact":""}`,style:t,children:[i.jsxs("div",{className:"mc-setting-row",children:[i.jsx("label",{htmlFor:"motion-type-select",className:"mc-label",children:"Motion Type"}),i.jsxs("select",{id:"motion-type-select",className:"mc-select",value:r,onChange:d,children:[i.jsx("option",{value:"character",children:"Character"}),i.jsx("option",{value:"vehicle",children:"Vehicle"})]})]}),i.jsxs("div",{className:"mc-setting-row",children:[i.jsx("label",{className:"mc-label",children:"Presets"}),i.jsx("div",{className:"mc-presets-grid",children:a.map(p=>i.jsx("button",{className:`mc-preset-btn ${p.id===l?"active":""}`,onClick:()=>f(p.id),title:`Max Speed: ${p.maxSpeed}, Accel: ${p.acceleration}`,children:p.name},p.id))})]})]})}const Qa=[{key:"motionType",label:"Motion Type",type:"text"},{key:"position",label:"Position",type:"vector3"},{key:"velocity",label:"Velocity",type:"vector3"},{key:"speed",label:"Speed",type:"number"},{key:"direction",label:"Direction",type:"vector3"},{key:"isGrounded",label:"Grounded",type:"text"},{key:"isMoving",label:"Moving",type:"text"},{key:"acceleration",label:"Acceleration",type:"number"},{key:"jumpForce",label:"Jump Force",type:"number"},{key:"maxSpeed",label:"Max Speed",type:"number"},{key:"totalDistance",label:"Total Distance",type:"number"},{key:"gameState",label:"Game State",type:"text"}];function Gp(e,t){const n=e??"top-right",o={position:"fixed",zIndex:t??1e4};return n.includes("top")&&(o.top=12),n.includes("bottom")&&(o.bottom=12),n.includes("left")&&(o.left=12),n.includes("right")&&(o.right=12),o}function zc(e){const t=e.embedded?{}:Gp(e.position,e.zIndex),n=ge.useGaesupStore(f=>f.mode),o=ge.useGaesupStore(f=>f.physics),{activeState:s,gameStates:r}=R.useStateSystem(),a=e.precision??2,l=e.customFields?[...Qa,...e.customFields]:Qa,c=(f,d,p=2)=>{if(d==null)return"N/A";switch(f.type){case"vector3":if(Array.isArray(d)&&d.length===3){const[h,v,b]=d;return`X:${h.toFixed(p)} Y:${v.toFixed(p)} Z:${b.toFixed(p)}`}if(typeof d=="object"&&d!==null&&"x"in d&&"y"in d&&"z"in d){const h=d;return`X:${h.x.toFixed(p)} Y:${h.y.toFixed(p)} Z:${h.z.toFixed(p)}`}return String(d);case"number":return typeof d=="number"?d.toFixed(p):String(d);default:return String(d)}},u=f=>{if(f.value!==void 0)return f.value;switch(f.key){case"motionType":return n?.type??"character";case"position":return s?.position?{x:s.position.x,y:s.position.y,z:s.position.z}:{x:0,y:0,z:0};case"velocity":return s?.velocity?{x:s.velocity.x,y:s.velocity.y,z:s.velocity.z}:{x:0,y:0,z:0};case"speed":return s?.velocity?s.velocity.length():0;case"direction":return s?.direction?{x:s.direction.x,y:s.direction.y,z:s.direction.z}:{x:0,y:0,z:0};case"isGrounded":return r?.isOnTheGround?"Yes":"No";case"isMoving":return r?.isMoving?"Yes":"No";case"acceleration":return o?.accelRatio??0;case"jumpForce":return o?.jumpSpeed??0;case"maxSpeed":return n?.type==="character"?o?.runSpeed??0:o?.maxSpeed??0;case"totalDistance":return 0;case"gameState":return r?.isRiding?"riding":r?.isOnTheGround?"ground":"air";default:return null}};return i.jsx("div",{className:`md-panel ${e.compact?"compact":""} ${e.theme?`theme-${e.theme}`:""}`,style:t,children:i.jsx("div",{className:"md-content",children:l.map(f=>i.jsxs("div",{className:"md-item",children:[i.jsx("span",{className:"md-label",children:f.label}),i.jsx("span",{className:"md-value",children:c(f,u(f),a)})]},f.key))})})}function Oc({className:e="",style:t,children:n}={}){const[o,s]=m.useState("Controller"),r=()=>{switch(o){case"Controller":return i.jsx("div",{className:"panel-content-wrapper",children:i.jsx(Lc,{})});case"Debug":return i.jsx("div",{className:"panel-content-wrapper",children:i.jsx(zc,{embedded:!0})});default:return null}};return i.jsxs("div",{className:`tabbed-panel ${e}`,style:t,children:[i.jsxs("div",{className:"panel-tabs",children:[i.jsx("button",{className:`panel-tab ${o==="Controller"?"active":""}`,onClick:()=>s("Controller"),children:"Controller"}),i.jsx("button",{className:`panel-tab ${o==="Debug"?"active":""}`,onClick:()=>s("Debug"),children:"Debug"})]}),i.jsxs("div",{className:"panel-tab-content",children:[r(),n]})]})}const Io=60,Eo=({data:e,color:t,max:n,warn:o})=>{const r=e.filter(c=>isFinite(c));if(r.length<2)return null;const a=Math.max(1,n),l=r.map((c,u)=>{const f=u/(r.length-1)*100,d=40-c/a*40;return`${u===0?"M":"L"}${f.toFixed(2)},${d.toFixed(2)}`}).join(" ");return i.jsx("div",{className:"perf-chart",children:i.jsxs("svg",{width:"100%",height:40,preserveAspectRatio:"none",viewBox:"0 0 100 40",children:[o!==void 0&&i.jsx("line",{x1:"0",y1:40-o/a*40,x2:"100",y2:40-o/a*40,stroke:"#facc15",strokeWidth:"0.5",strokeDasharray:"3,3",opacity:.5}),i.jsx("path",{d:l,fill:"none",stroke:t,strokeWidth:"2",strokeLinejoin:"round",strokeLinecap:"round"})]})})},ir=({value:e,max:t,color:n,label:o})=>{const s=t>0?Math.min(100,e/t*100):0;return i.jsxs("div",{style:{marginBottom:4},children:[i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:10,marginBottom:2},children:[i.jsx("span",{className:"perf-label",children:o}),i.jsx("span",{children:e.toFixed(1)})]}),i.jsx("div",{style:{height:4,background:"#1e293b",borderRadius:2,overflow:"hidden"},children:i.jsx("div",{style:{width:`${s}%`,height:"100%",background:n,borderRadius:2,transition:"width 0.3s"}})})]})};function $c({className:e="",style:t,children:n}={}){const o=ge.useGaesupStore(ls.useShallow(P=>P.performance)),[s,r]=m.useState({current:0,min:1/0,max:0,avg:0,p1Low:0,history:Array(Io).fill(0)}),[a,l]=m.useState({used:0,limit:0,history:Array(Io).fill(0)}),[c,u]=m.useState(0),[f,d]=m.useState(Array(Io).fill(0)),[p,h]=m.useState(Array(Io).fill(0)),v=m.useRef(0),b=m.useRef(0),S=m.useRef(0),x=m.useRef([]),_=m.useRef(0),g=m.useRef(null),y=m.useRef(0),w=m.useRef(0),j=m.useRef(0),N=m.useCallback(P=>{if(P.length<5)return 0;const L=[...P].filter(U=>U>0).sort((U,V)=>U-V),M=Math.max(1,Math.floor(L.length*.01));let F=0;for(let U=0;U<M;U++)F+=L[U]??0;return F/M},[]);m.useEffect(()=>{const P=window.performance.now();v.current=P,b.current=P,_.current=P;const L=M=>{const F=M-b.current;if(b.current=M,x.current.push(F),x.current.length>300&&x.current.shift(),y.current+=F,w.current++,w.current>=10){const U=y.current/w.current;u(U),h(V=>[...V.slice(1),U]),y.current=0,w.current=0}if(S.current++,M-v.current>=500){const U=S.current*1e3/(M-v.current),V=x.current.map(q=>q>0?1e3/q:0),Y=M-_.current>3e3;r(q=>{const X=[...q.history.slice(1),U],A=Y?Math.min(q.min===1/0?U:q.min,U):1/0,C=Y?Math.max(q.max,U):0,H=Y?X.filter(ee=>ee>0):[],K=H.length>0?H.reduce((ee,ne)=>ee+ne,0)/H.length:U,Q=Y?N(V):U;return{current:U,min:A,max:C,avg:K,p1Low:Q,history:X}});const Z=window.performance.memory;Z&&l(q=>{const X=Math.round(Z.usedJSHeapSize/1048576),A=Math.round(Z.jsHeapSizeLimit/1048576);return{used:X,limit:A,history:[...q.history.slice(1),X]}}),v.current=M,S.current=0}g.current=requestAnimationFrame(L)};return g.current=requestAnimationFrame(L),()=>{g.current&&cancelAnimationFrame(g.current)}},[N]),m.useEffect(()=>{const P=o.render.calls;P!==j.current&&(j.current=P,d(L=>[...L.slice(1),P]))},[o.render.calls]);const B=P=>P>=55?"#4ade80":P>=30?"#facc15":"#f87171",z=P=>P<=16.7?"#4ade80":P<=33.3?"#facc15":"#f87171",W=P=>P<=100?"#4ade80":P<=300?"#facc15":"#f87171",D=(P,L)=>{const M=L>0?P/L*100:0;return M<60?"#4ade80":M<80?"#facc15":"#f87171"},E=o.render.triangles,G=o.render.calls,T=o.engine.geometries,O=o.engine.textures;return i.jsxs("div",{className:`perf-panel ${e}`,style:t,children:[i.jsxs("div",{className:"perf-stat-group",children:[i.jsxs("div",{className:"perf-header",children:[i.jsx("h4",{className:"perf-title",children:"Frame Rate"}),i.jsxs("span",{className:"perf-current",style:{color:B(s.current)},children:[s.current.toFixed(0)," FPS"]})]}),i.jsxs("div",{className:"perf-details-grid",children:[i.jsxs("div",{children:[i.jsx("span",{className:"perf-label",children:"Avg"}),s.avg.toFixed(1)]}),i.jsxs("div",{children:[i.jsx("span",{className:"perf-label",children:"Min"}),isFinite(s.min)?s.min.toFixed(1):"..."]}),i.jsxs("div",{children:[i.jsx("span",{className:"perf-label",children:"Max"}),s.max.toFixed(1)]}),i.jsxs("div",{children:[i.jsx("span",{className:"perf-label",children:"1% Low"}),i.jsx("span",{style:{color:B(s.p1Low)},children:s.p1Low.toFixed(1)})]})]}),i.jsx(Eo,{data:s.history,color:B(s.current),max:90,warn:60})]}),i.jsxs("div",{className:"perf-stat-group",children:[i.jsxs("div",{className:"perf-header",children:[i.jsx("h4",{className:"perf-title",children:"Frame Time"}),i.jsxs("span",{className:"perf-current",style:{color:z(c)},children:[c.toFixed(2)," ms"]})]}),i.jsx(ir,{value:c,max:33.3,color:z(c),label:"Budget (16.7ms)"}),i.jsx(Eo,{data:p,color:z(c),max:33.3,warn:16.7})]}),i.jsxs("div",{className:"perf-stat-group",children:[i.jsxs("div",{className:"perf-header",children:[i.jsx("h4",{className:"perf-title",children:"GPU Pipeline"}),i.jsxs("span",{className:"perf-current",style:{color:W(G)},children:[G," calls"]})]}),i.jsxs("div",{className:"perf-details-grid",children:[i.jsxs("div",{children:[i.jsx("span",{className:"perf-label",children:"Triangles"}),E>=1e6?(E/1e6).toFixed(2)+"M":E>=1e3?(E/1e3).toFixed(1)+"K":E]}),i.jsxs("div",{children:[i.jsx("span",{className:"perf-label",children:"Draw Calls"}),i.jsx("span",{style:{color:W(G)},children:G})]}),i.jsxs("div",{children:[i.jsx("span",{className:"perf-label",children:"Tri/Call"}),G>0?Math.round(E/G):0]}),i.jsxs("div",{children:[i.jsx("span",{className:"perf-label",children:"Points"}),o.render.points]})]}),i.jsx(Eo,{data:f,color:W(G),max:Math.max(200,...f)})]}),i.jsxs("div",{className:"perf-stat-group",children:[i.jsx("div",{className:"perf-header",children:i.jsx("h4",{className:"perf-title",children:"Resources"})}),i.jsxs("div",{className:"perf-details-grid",children:[i.jsxs("div",{children:[i.jsx("span",{className:"perf-label",children:"Geometries"}),T]}),i.jsxs("div",{children:[i.jsx("span",{className:"perf-label",children:"Textures"}),O]}),i.jsxs("div",{children:[i.jsx("span",{className:"perf-label",children:"Programs"}),o.engine.programs]}),i.jsxs("div",{children:[i.jsx("span",{className:"perf-label",children:"Lines"}),o.render.lines]})]}),i.jsx(ir,{value:T,max:200,color:T>150?"#f87171":"#4ade80",label:"Geometry Budget"}),i.jsx(ir,{value:O,max:100,color:O>80?"#f87171":"#4ade80",label:"Texture Budget"})]}),i.jsxs("div",{className:"perf-stat-group",children:[i.jsxs("div",{className:"perf-header",children:[i.jsx("h4",{className:"perf-title",children:"Memory"}),i.jsxs("span",{className:"perf-current",style:{color:D(a.used,a.limit)},children:[a.used," MB"]})]}),i.jsxs("div",{className:"perf-details-grid",children:[i.jsxs("div",{children:[i.jsx("span",{className:"perf-label",children:"Limit"}),a.limit," MB"]}),i.jsxs("div",{children:[i.jsx("span",{className:"perf-label",children:"Usage"}),a.limit>0?(a.used/a.limit*100).toFixed(0):0,"%"]})]}),i.jsx(Eo,{data:a.history,color:D(a.used,a.limit),max:a.limit||1})]}),n]})}const Gc=({className:e="",style:t,children:n})=>{const o=ge.useGaesupStore(l=>l.mode),s=ge.useGaesupStore(l=>l.setMode),r=l=>{s({type:l,controller:"keyboard",control:l==="airplane"||l==="vehicle"?"chase":"thirdPerson"})},a=[{type:"character",label:"Character",description:"Walk around as character"},{type:"vehicle",label:"Vehicle",description:"Drive a ground vehicle"},{type:"airplane",label:"Airplane",description:"Fly an airplane"}];return i.jsxs("div",{className:`vehicle-panel ${e}`,style:t,children:[i.jsx("div",{className:"vehicle-panel__modes",children:a.map(l=>i.jsxs("button",{className:`vehicle-panel__mode-button ${o.type===l.type?"vehicle-panel__mode-button--active":""}`,onClick:()=>r(l.type),children:[i.jsx("span",{className:"vehicle-panel__mode-label",children:l.label}),i.jsx("span",{className:"vehicle-panel__mode-description",children:l.description})]},l.type))}),i.jsxs("div",{className:"vehicle-panel__info",children:[i.jsxs("div",{className:"vehicle-panel__info-item",children:[i.jsx("span",{className:"vehicle-panel__info-label",children:"Current Mode:"}),i.jsx("span",{className:"vehicle-panel__info-value",children:o.type})]}),i.jsxs("div",{className:"vehicle-panel__info-item",children:[i.jsx("span",{className:"vehicle-panel__info-label",children:"Controls:"}),i.jsx("span",{className:"vehicle-panel__info-value",children:o.type==="airplane"?"WASD + Space/Shift":"WASD + Space"})]})]}),n]})},vi=[{id:"door-basic",label:"Door",category:"structure",fallbackKind:"door",defaultScale:1,defaultColor:"#8b5a2b",modelUrl:"gltf/props/door.glb"},{id:"window-basic",label:"Window",category:"structure",fallbackKind:"window",defaultScale:1,defaultColor:"#9fd3ff",modelUrl:"gltf/props/window.glb"},{id:"fence-basic",label:"Fence",category:"structure",fallbackKind:"fence",defaultScale:1,defaultColor:"#8f6a3d",modelUrl:"gltf/props/fence.glb"},{id:"lamp-basic",label:"Lamp",category:"utility",fallbackKind:"lamp",defaultScale:1,defaultColor:"#ffd166",modelUrl:"gltf/props/lamp.glb"},{id:"chair-basic",label:"Chair",category:"furniture",fallbackKind:"chair",defaultScale:1,defaultColor:"#a6784f",modelUrl:"gltf/props/chair.glb"},{id:"table-basic",label:"Table",category:"furniture",fallbackKind:"table",defaultScale:1,defaultColor:"#9b6b43",modelUrl:"gltf/props/table.glb"},{id:"bed-basic",label:"Bed",category:"furniture",fallbackKind:"bed",defaultScale:1,defaultColor:"#7aa2ff",modelUrl:"gltf/props/bed.glb"},{id:"storage-basic",label:"Storage",category:"furniture",fallbackKind:"storage",defaultScale:1,defaultColor:"#7c5c3e",modelUrl:"gltf/props/storage.glb"},{id:"mailbox-basic",label:"Mailbox",category:"utility",fallbackKind:"mailbox",defaultScale:1,defaultColor:"#d04f45",modelUrl:"gltf/props/mailbox.glb"},{id:"crafting-basic",label:"Crafting Station",category:"utility",fallbackKind:"crafting",defaultScale:1,defaultColor:"#b68553",modelUrl:"gltf/props/crafting.glb"},{id:"shop-stall-basic",label:"Shop Stall",category:"shop",fallbackKind:"shop",defaultScale:1,defaultColor:"#d88f45",modelUrl:"gltf/props/shop-stall.glb"}];function Ts(e){return vi.find(t=>t.id===e)}function ue({label:e,children:t}){return i.jsxs("div",{className:"editor-field-row",children:[i.jsx("span",{className:"editor-field-row__label",children:e}),i.jsx("div",{className:"editor-field-row__control",children:t})]})}function Lr({value:e,onChange:t}){return i.jsx("button",{type:"button",className:`editor-field-toggle ${e?"editor-field-toggle--on":""}`,onClick:()=>t(!e),children:e?"ON":"OFF"})}function no({value:e,onChange:t}){return i.jsxs("div",{className:"editor-field-color",children:[i.jsx("input",{type:"color",value:e,onChange:n=>t(n.target.value)}),i.jsx("span",{children:e})]})}function pa(e){return`${e}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}const Hp=e=>e.kind==="material"||e.kind==="wall"||e.kind==="tile",or=pa;function Ja(e,t,n){const{mapTextureUrl:o,textureUrl:s,materialParams:r,...a}=n??{};return{...a,id:e,color:t,material:"STANDARD",materialParams:{...r??{},color:t}}}function Yi(e){return`${e}-${Date.now()}`}function Ao(e){return e==="questStatus"?{id:Yi("condition-quest"),type:"condition",label:"Quest Active",condition:{type:"questStatus",questId:"welcome",status:"active"}}:e==="friendshipAtLeast"?{id:Yi("condition-friendship"),type:"condition",label:"Friendship Gate",condition:{type:"friendshipAtLeast",score:150}}:{id:Yi("condition-idle"),type:"condition",label:"Navigation Idle",condition:{type:"navigationIdle"}}}function Zi(e,t){return e==="speak"?{id:Yi("speak"),type:"action",label:"Speak",action:{type:"speak",text:"안녕?",duration:2}}:{id:Yi("wander"),type:"action",label:"Wander",action:{type:"wander",radius:t?.wanderRadius??4,speed:t?.speed??2.2}}}function Xi(e){return e.label?e.label:e.type==="start"?"Start":e.type==="condition"?`Condition: ${e.condition.type}`:`Action: ${e.action.type}`}function Wp(e){return e.type==="start"?"블루프린트 실행 시작점":e.type==="condition"?e.condition.type==="questStatus"?`quest ${e.condition.questId} is ${e.condition.status}`:e.condition.type==="friendshipAtLeast"?`friendship >= ${e.condition.score}`:e.condition.type:e.action.type==="moveToTarget"?`moveTo ${e.action.target.type}`:e.action.type==="speak"?e.action.text:e.action.type==="playAnimation"?e.action.animationId:e.action.type}function Ki(e,t){const n=e.nodes[e.nodes.length-1],o=n?{id:`${n.id}-${t.id}`,source:n.id,target:t.id,branch:"next"}:void 0;return{...e,nodes:[...e.nodes,t],edges:o?[...e.edges,o]:e.edges}}function ko(e,t,n){if(t.type!=="condition")return Ki(e,t);const o=Ki(e,t),s=Zi("wander",n),r=Zi("speak",n),a={...s,label:s.label??"True Path"},l={...r,label:r.label??"False Path"};return{...o,nodes:[...o.nodes,a,l],edges:[...o.edges,{id:`${t.id}-true-${a.id}`,source:t.id,target:a.id,branch:"true"},{id:`${t.id}-false-${l.id}`,source:t.id,target:l.id,branch:"false"}]}}function Up(e,t){const n=e.nodes.find(o=>o.id===t);return!n||n.type==="start"?e:{...e,nodes:e.nodes.filter(o=>o.id!==t),edges:e.edges.filter(o=>o.source!==t&&o.target!==t)}}function Vp(e){return{...e,nodes:[{id:"start",type:"start",label:"Start"}],edges:[]}}function Yp(e,t){return{...e,id:`npc-custom-${t}-${Date.now()}`,name:`${e.name} Custom`,description:e.description?`${e.description} Customized for ${t}.`:`Customized for ${t}.`,nodes:e.nodes.map(n=>({...n})),edges:e.edges.map(n=>({...n}))}}function Zp(e,t){const n=new Map(e.nodes.map(s=>[s.id,s])),o=e.edges.filter(s=>s.source===t);return o.length===0?"다음 없음":o.map(s=>{const r=n.get(s.target);return`${s.branch??"next"} -> ${r?Xi(r):s.target}`}).join(" · ")}function Ee(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,o;n<e.length;n++)(o=Ee(e[n]))!==""&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Xp={value:()=>{}};function Is(){for(var e=0,t=arguments.length,n={},o;e<t;++e){if(!(o=arguments[e]+"")||o in n||/[\s.]/.test(o))throw new Error("illegal type: "+o);n[o]=[]}return new es(n)}function es(e){this._=e}function Kp(e,t){return e.trim().split(/^|\s+/).map(function(n){var o="",s=n.indexOf(".");if(s>=0&&(o=n.slice(s+1),n=n.slice(0,s)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:o}})}es.prototype=Is.prototype={constructor:es,on:function(e,t){var n=this._,o=Kp(e+"",n),s,r=-1,a=o.length;if(arguments.length<2){for(;++r<a;)if((s=(e=o[r]).type)&&(s=qp(n[s],e.name)))return s;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++r<a;)if(s=(e=o[r]).type)n[s]=el(n[s],e.name,t);else if(t==null)for(s in n)n[s]=el(n[s],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new es(e)},call:function(e,t){if((s=arguments.length-2)>0)for(var n=new Array(s),o=0,s,r;o<s;++o)n[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(r=this._[e],o=0,s=r.length;o<s;++o)r[o].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],s=0,r=o.length;s<r;++s)o[s].value.apply(t,n)}};function qp(e,t){for(var n=0,o=e.length,s;n<o;++n)if((s=e[n]).name===t)return s.value}function el(e,t,n){for(var o=0,s=e.length;o<s;++o)if(e[o].name===t){e[o]=Xp,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var zr="http://www.w3.org/1999/xhtml";const tl={svg:"http://www.w3.org/2000/svg",xhtml:zr,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Es(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),tl.hasOwnProperty(t)?{space:tl[t],local:e}:e}function Qp(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===zr&&t.documentElement.namespaceURI===zr?t.createElement(e):t.createElementNS(n,e)}}function Jp(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Hc(e){var t=Es(e);return(t.local?Jp:Qp)(t)}function eh(){}function ha(e){return e==null?eh:function(){return this.querySelector(e)}}function th(e){typeof e!="function"&&(e=ha(e));for(var t=this._groups,n=t.length,o=new Array(n),s=0;s<n;++s)for(var r=t[s],a=r.length,l=o[s]=new Array(a),c,u,f=0;f<a;++f)(c=r[f])&&(u=e.call(c,c.__data__,f,r))&&("__data__"in c&&(u.__data__=c.__data__),l[f]=u);return new Ye(o,this._parents)}function nh(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function ih(){return[]}function Wc(e){return e==null?ih:function(){return this.querySelectorAll(e)}}function oh(e){return function(){return nh(e.apply(this,arguments))}}function sh(e){typeof e=="function"?e=oh(e):e=Wc(e);for(var t=this._groups,n=t.length,o=[],s=[],r=0;r<n;++r)for(var a=t[r],l=a.length,c,u=0;u<l;++u)(c=a[u])&&(o.push(e.call(c,c.__data__,u,a)),s.push(c));return new Ye(o,s)}function Uc(e){return function(){return this.matches(e)}}function Vc(e){return function(t){return t.matches(e)}}var rh=Array.prototype.find;function ah(e){return function(){return rh.call(this.children,e)}}function lh(){return this.firstElementChild}function ch(e){return this.select(e==null?lh:ah(typeof e=="function"?e:Vc(e)))}var uh=Array.prototype.filter;function dh(){return Array.from(this.children)}function fh(e){return function(){return uh.call(this.children,e)}}function ph(e){return this.selectAll(e==null?dh:fh(typeof e=="function"?e:Vc(e)))}function hh(e){typeof e!="function"&&(e=Uc(e));for(var t=this._groups,n=t.length,o=new Array(n),s=0;s<n;++s)for(var r=t[s],a=r.length,l=o[s]=[],c,u=0;u<a;++u)(c=r[u])&&e.call(c,c.__data__,u,r)&&l.push(c);return new Ye(o,this._parents)}function Yc(e){return new Array(e.length)}function mh(){return new Ye(this._enter||this._groups.map(Yc),this._parents)}function cs(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}cs.prototype={constructor:cs,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function gh(e){return function(){return e}}function bh(e,t,n,o,s,r){for(var a=0,l,c=t.length,u=r.length;a<u;++a)(l=t[a])?(l.__data__=r[a],o[a]=l):n[a]=new cs(e,r[a]);for(;a<c;++a)(l=t[a])&&(s[a]=l)}function xh(e,t,n,o,s,r,a){var l,c,u=new Map,f=t.length,d=r.length,p=new Array(f),h;for(l=0;l<f;++l)(c=t[l])&&(p[l]=h=a.call(c,c.__data__,l,t)+"",u.has(h)?s[l]=c:u.set(h,c));for(l=0;l<d;++l)h=a.call(e,r[l],l,r)+"",(c=u.get(h))?(o[l]=c,c.__data__=r[l],u.delete(h)):n[l]=new cs(e,r[l]);for(l=0;l<f;++l)(c=t[l])&&u.get(p[l])===c&&(s[l]=c)}function yh(e){return e.__data__}function vh(e,t){if(!arguments.length)return Array.from(this,yh);var n=t?xh:bh,o=this._parents,s=this._groups;typeof e!="function"&&(e=gh(e));for(var r=s.length,a=new Array(r),l=new Array(r),c=new Array(r),u=0;u<r;++u){var f=o[u],d=s[u],p=d.length,h=wh(e.call(f,f&&f.__data__,u,o)),v=h.length,b=l[u]=new Array(v),S=a[u]=new Array(v),x=c[u]=new Array(p);n(f,d,b,S,x,h,t);for(var _=0,g=0,y,w;_<v;++_)if(y=b[_]){for(_>=g&&(g=_+1);!(w=S[g])&&++g<v;);y._next=w||null}}return a=new Ye(a,o),a._enter=l,a._exit=c,a}function wh(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Sh(){return new Ye(this._exit||this._groups.map(Yc),this._parents)}function _h(e,t,n){var o=this.enter(),s=this,r=this.exit();return typeof e=="function"?(o=e(o),o&&(o=o.selection())):o=o.append(e+""),t!=null&&(s=t(s),s&&(s=s.selection())),n==null?r.remove():n(r),o&&s?o.merge(s).order():s}function jh(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,s=n.length,r=o.length,a=Math.min(s,r),l=new Array(s),c=0;c<a;++c)for(var u=n[c],f=o[c],d=u.length,p=l[c]=new Array(d),h,v=0;v<d;++v)(h=u[v]||f[v])&&(p[v]=h);for(;c<s;++c)l[c]=n[c];return new Ye(l,this._parents)}function Mh(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o=e[t],s=o.length-1,r=o[s],a;--s>=0;)(a=o[s])&&(r&&a.compareDocumentPosition(r)^4&&r.parentNode.insertBefore(a,r),r=a);return this}function Ch(e){e||(e=Nh);function t(d,p){return d&&p?e(d.__data__,p.__data__):!d-!p}for(var n=this._groups,o=n.length,s=new Array(o),r=0;r<o;++r){for(var a=n[r],l=a.length,c=s[r]=new Array(l),u,f=0;f<l;++f)(u=a[f])&&(c[f]=u);c.sort(t)}return new Ye(s,this._parents).order()}function Nh(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Th(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Ih(){return Array.from(this)}function Eh(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],s=0,r=o.length;s<r;++s){var a=o[s];if(a)return a}return null}function Ah(){let e=0;for(const t of this)++e;return e}function kh(){return!this.node()}function Bh(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var s=t[n],r=0,a=s.length,l;r<a;++r)(l=s[r])&&e.call(l,l.__data__,r,s);return this}function Ph(e){return function(){this.removeAttribute(e)}}function Rh(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Dh(e,t){return function(){this.setAttribute(e,t)}}function Fh(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Lh(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function zh(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Oh(e,t){var n=Es(e);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((t==null?n.local?Rh:Ph:typeof t=="function"?n.local?zh:Lh:n.local?Fh:Dh)(n,t))}function Zc(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function $h(e){return function(){this.style.removeProperty(e)}}function Gh(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Hh(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function Wh(e,t,n){return arguments.length>1?this.each((t==null?$h:typeof t=="function"?Hh:Gh)(e,t,n??"")):wi(this.node(),e)}function wi(e,t){return e.style.getPropertyValue(t)||Zc(e).getComputedStyle(e,null).getPropertyValue(t)}function Uh(e){return function(){delete this[e]}}function Vh(e,t){return function(){this[e]=t}}function Yh(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Zh(e,t){return arguments.length>1?this.each((t==null?Uh:typeof t=="function"?Yh:Vh)(e,t)):this.node()[e]}function Xc(e){return e.trim().split(/^|\s+/)}function ma(e){return e.classList||new Kc(e)}function Kc(e){this._node=e,this._names=Xc(e.getAttribute("class")||"")}Kc.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function qc(e,t){for(var n=ma(e),o=-1,s=t.length;++o<s;)n.add(t[o])}function Qc(e,t){for(var n=ma(e),o=-1,s=t.length;++o<s;)n.remove(t[o])}function Xh(e){return function(){qc(this,e)}}function Kh(e){return function(){Qc(this,e)}}function qh(e,t){return function(){(t.apply(this,arguments)?qc:Qc)(this,e)}}function Qh(e,t){var n=Xc(e+"");if(arguments.length<2){for(var o=ma(this.node()),s=-1,r=n.length;++s<r;)if(!o.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?qh:t?Xh:Kh)(n,t))}function Jh(){this.textContent=""}function em(e){return function(){this.textContent=e}}function tm(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function nm(e){return arguments.length?this.each(e==null?Jh:(typeof e=="function"?tm:em)(e)):this.node().textContent}function im(){this.innerHTML=""}function om(e){return function(){this.innerHTML=e}}function sm(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function rm(e){return arguments.length?this.each(e==null?im:(typeof e=="function"?sm:om)(e)):this.node().innerHTML}function am(){this.nextSibling&&this.parentNode.appendChild(this)}function lm(){return this.each(am)}function cm(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function um(){return this.each(cm)}function dm(e){var t=typeof e=="function"?e:Hc(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function fm(){return null}function pm(e,t){var n=typeof e=="function"?e:Hc(e),o=t==null?fm:typeof t=="function"?t:ha(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function hm(){var e=this.parentNode;e&&e.removeChild(this)}function mm(){return this.each(hm)}function gm(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function bm(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function xm(e){return this.select(e?bm:gm)}function ym(e){return arguments.length?this.property("__data__",e):this.node().__data__}function vm(e){return function(t){e.call(this,t,this.__data__)}}function wm(e){return e.trim().split(/^|\s+/).map(function(t){var n="",o=t.indexOf(".");return o>=0&&(n=t.slice(o+1),t=t.slice(0,o)),{type:t,name:n}})}function Sm(e){return function(){var t=this.__on;if(t){for(var n=0,o=-1,s=t.length,r;n<s;++n)r=t[n],(!e.type||r.type===e.type)&&r.name===e.name?this.removeEventListener(r.type,r.listener,r.options):t[++o]=r;++o?t.length=o:delete this.__on}}}function _m(e,t,n){return function(){var o=this.__on,s,r=vm(t);if(o){for(var a=0,l=o.length;a<l;++a)if((s=o[a]).type===e.type&&s.name===e.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=r,s.options=n),s.value=t;return}}this.addEventListener(e.type,r,n),s={type:e.type,name:e.name,value:t,listener:r,options:n},o?o.push(s):this.__on=[s]}}function jm(e,t,n){var o=wm(e+""),s,r=o.length,a;if(arguments.length<2){var l=this.node().__on;if(l){for(var c=0,u=l.length,f;c<u;++c)for(s=0,f=l[c];s<r;++s)if((a=o[s]).type===f.type&&a.name===f.name)return f.value}return}for(l=t?_m:Sm,s=0;s<r;++s)this.each(l(o[s],t,n));return this}function Jc(e,t,n){var o=Zc(e),s=o.CustomEvent;typeof s=="function"?s=new s(t,n):(s=o.document.createEvent("Event"),n?(s.initEvent(t,n.bubbles,n.cancelable),s.detail=n.detail):s.initEvent(t,!1,!1)),e.dispatchEvent(s)}function Mm(e,t){return function(){return Jc(this,e,t)}}function Cm(e,t){return function(){return Jc(this,e,t.apply(this,arguments))}}function Nm(e,t){return this.each((typeof t=="function"?Cm:Mm)(e,t))}function*Tm(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],s=0,r=o.length,a;s<r;++s)(a=o[s])&&(yield a)}var eu=[null];function Ye(e,t){this._groups=e,this._parents=t}function xo(){return new Ye([[document.documentElement]],eu)}function Im(){return this}Ye.prototype=xo.prototype={constructor:Ye,select:th,selectAll:sh,selectChild:ch,selectChildren:ph,filter:hh,data:vh,enter:mh,exit:Sh,join:_h,merge:jh,selection:Im,order:Mh,sort:Ch,call:Th,nodes:Ih,node:Eh,size:Ah,empty:kh,each:Bh,attr:Oh,style:Wh,property:Zh,classed:Qh,text:nm,html:rm,raise:lm,lower:um,append:dm,insert:pm,remove:mm,clone:xm,datum:ym,on:jm,dispatch:Nm,[Symbol.iterator]:Tm};function Ve(e){return typeof e=="string"?new Ye([[document.querySelector(e)]],[document.documentElement]):new Ye([[e]],eu)}function Em(e){let t;for(;t=e.sourceEvent;)e=t;return e}function st(e,t){if(e=Em(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,o=o.matrixTransform(t.getScreenCTM().inverse()),[o.x,o.y]}if(t.getBoundingClientRect){var s=t.getBoundingClientRect();return[e.clientX-s.left-t.clientLeft,e.clientY-s.top-t.clientTop]}}return[e.pageX,e.pageY]}const Am={passive:!1},io={capture:!0,passive:!1};function sr(e){e.stopImmediatePropagation()}function xi(e){e.preventDefault(),e.stopImmediatePropagation()}function tu(e){var t=e.document.documentElement,n=Ve(e).on("dragstart.drag",xi,io);"onselectstart"in t?n.on("selectstart.drag",xi,io):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function nu(e,t){var n=e.document.documentElement,o=Ve(e).on("dragstart.drag",null);t&&(o.on("click.drag",xi,io),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Bo=e=>()=>e;function Or(e,{sourceEvent:t,subject:n,target:o,identifier:s,active:r,x:a,y:l,dx:c,dy:u,dispatch:f}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:r,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:f}})}Or.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function km(e){return!e.ctrlKey&&!e.button}function Bm(){return this.parentNode}function Pm(e,t){return t??{x:e.x,y:e.y}}function Rm(){return navigator.maxTouchPoints||"ontouchstart"in this}function iu(){var e=km,t=Bm,n=Pm,o=Rm,s={},r=Is("start","drag","end"),a=0,l,c,u,f,d=0;function p(y){y.on("mousedown.drag",h).filter(o).on("touchstart.drag",S).on("touchmove.drag",x,Am).on("touchend.drag touchcancel.drag",_).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(y,w){if(!(f||!e.call(this,y,w))){var j=g(this,t.call(this,y,w),y,w,"mouse");j&&(Ve(y.view).on("mousemove.drag",v,io).on("mouseup.drag",b,io),tu(y.view),sr(y),u=!1,l=y.clientX,c=y.clientY,j("start",y))}}function v(y){if(xi(y),!u){var w=y.clientX-l,j=y.clientY-c;u=w*w+j*j>d}s.mouse("drag",y)}function b(y){Ve(y.view).on("mousemove.drag mouseup.drag",null),nu(y.view,u),xi(y),s.mouse("end",y)}function S(y,w){if(e.call(this,y,w)){var j=y.changedTouches,N=t.call(this,y,w),B=j.length,z,W;for(z=0;z<B;++z)(W=g(this,N,y,w,j[z].identifier,j[z]))&&(sr(y),W("start",y,j[z]))}}function x(y){var w=y.changedTouches,j=w.length,N,B;for(N=0;N<j;++N)(B=s[w[N].identifier])&&(xi(y),B("drag",y,w[N]))}function _(y){var w=y.changedTouches,j=w.length,N,B;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),N=0;N<j;++N)(B=s[w[N].identifier])&&(sr(y),B("end",y,w[N]))}function g(y,w,j,N,B,z){var W=r.copy(),D=st(z||j,w),E,G,T;if((T=n.call(y,new Or("beforestart",{sourceEvent:j,target:p,identifier:B,active:a,x:D[0],y:D[1],dx:0,dy:0,dispatch:W}),N))!=null)return E=T.x-D[0]||0,G=T.y-D[1]||0,function O(P,L,M){var F=D,U;switch(P){case"start":s[B]=O,U=a++;break;case"end":delete s[B],--a;case"drag":D=st(M||L,w),U=a;break}W.call(P,y,new Or(P,{sourceEvent:L,subject:T,target:p,identifier:B,active:U,x:D[0]+E,y:D[1]+G,dx:D[0]-F[0],dy:D[1]-F[1],dispatch:W}),N)}}return p.filter=function(y){return arguments.length?(e=typeof y=="function"?y:Bo(!!y),p):e},p.container=function(y){return arguments.length?(t=typeof y=="function"?y:Bo(y),p):t},p.subject=function(y){return arguments.length?(n=typeof y=="function"?y:Bo(y),p):n},p.touchable=function(y){return arguments.length?(o=typeof y=="function"?y:Bo(!!y),p):o},p.on=function(){var y=r.on.apply(r,arguments);return y===r?p:y},p.clickDistance=function(y){return arguments.length?(d=(y=+y)*y,p):Math.sqrt(d)},p}function ga(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function ou(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function yo(){}var oo=.7,us=1/oo,yi="\\s*([+-]?\\d+)\\s*",so="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",It="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Dm=/^#([0-9a-f]{3,8})$/,Fm=new RegExp(`^rgb\\(${yi},${yi},${yi}\\)$`),Lm=new RegExp(`^rgb\\(${It},${It},${It}\\)$`),zm=new RegExp(`^rgba\\(${yi},${yi},${yi},${so}\\)$`),Om=new RegExp(`^rgba\\(${It},${It},${It},${so}\\)$`),$m=new RegExp(`^hsl\\(${so},${It},${It}\\)$`),Gm=new RegExp(`^hsla\\(${so},${It},${It},${so}\\)$`),nl={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};ga(yo,ii,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:il,formatHex:il,formatHex8:Hm,formatHsl:Wm,formatRgb:ol,toString:ol});function il(){return this.rgb().formatHex()}function Hm(){return this.rgb().formatHex8()}function Wm(){return su(this).formatHsl()}function ol(){return this.rgb().formatRgb()}function ii(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Dm.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?sl(t):n===3?new $e(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Po(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Po(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Fm.exec(e))?new $e(t[1],t[2],t[3],1):(t=Lm.exec(e))?new $e(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=zm.exec(e))?Po(t[1],t[2],t[3],t[4]):(t=Om.exec(e))?Po(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=$m.exec(e))?ll(t[1],t[2]/100,t[3]/100,1):(t=Gm.exec(e))?ll(t[1],t[2]/100,t[3]/100,t[4]):nl.hasOwnProperty(e)?sl(nl[e]):e==="transparent"?new $e(NaN,NaN,NaN,0):null}function sl(e){return new $e(e>>16&255,e>>8&255,e&255,1)}function Po(e,t,n,o){return o<=0&&(e=t=n=NaN),new $e(e,t,n,o)}function Um(e){return e instanceof yo||(e=ii(e)),e?(e=e.rgb(),new $e(e.r,e.g,e.b,e.opacity)):new $e}function $r(e,t,n,o){return arguments.length===1?Um(e):new $e(e,t,n,o??1)}function $e(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}ga($e,$r,ou(yo,{brighter(e){return e=e==null?us:Math.pow(us,e),new $e(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?oo:Math.pow(oo,e),new $e(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new $e(ti(this.r),ti(this.g),ti(this.b),ds(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:rl,formatHex:rl,formatHex8:Vm,formatRgb:al,toString:al}));function rl(){return`#${ei(this.r)}${ei(this.g)}${ei(this.b)}`}function Vm(){return`#${ei(this.r)}${ei(this.g)}${ei(this.b)}${ei((isNaN(this.opacity)?1:this.opacity)*255)}`}function al(){const e=ds(this.opacity);return`${e===1?"rgb(":"rgba("}${ti(this.r)}, ${ti(this.g)}, ${ti(this.b)}${e===1?")":`, ${e})`}`}function ds(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ti(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ei(e){return e=ti(e),(e<16?"0":"")+e.toString(16)}function ll(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new lt(e,t,n,o)}function su(e){if(e instanceof lt)return new lt(e.h,e.s,e.l,e.opacity);if(e instanceof yo||(e=ii(e)),!e)return new lt;if(e instanceof lt)return e;e=e.rgb();var t=e.r/255,n=e.g/255,o=e.b/255,s=Math.min(t,n,o),r=Math.max(t,n,o),a=NaN,l=r-s,c=(r+s)/2;return l?(t===r?a=(n-o)/l+(n<o)*6:n===r?a=(o-t)/l+2:a=(t-n)/l+4,l/=c<.5?r+s:2-r-s,a*=60):l=c>0&&c<1?0:a,new lt(a,l,c,e.opacity)}function Ym(e,t,n,o){return arguments.length===1?su(e):new lt(e,t,n,o??1)}function lt(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}ga(lt,Ym,ou(yo,{brighter(e){return e=e==null?us:Math.pow(us,e),new lt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?oo:Math.pow(oo,e),new lt(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,o=n+(n<.5?n:1-n)*t,s=2*n-o;return new $e(rr(e>=240?e-240:e+120,s,o),rr(e,s,o),rr(e<120?e+240:e-120,s,o),this.opacity)},clamp(){return new lt(cl(this.h),Ro(this.s),Ro(this.l),ds(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=ds(this.opacity);return`${e===1?"hsl(":"hsla("}${cl(this.h)}, ${Ro(this.s)*100}%, ${Ro(this.l)*100}%${e===1?")":`, ${e})`}`}}));function cl(e){return e=(e||0)%360,e<0?e+360:e}function Ro(e){return Math.max(0,Math.min(1,e||0))}function rr(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const ba=e=>()=>e;function Zm(e,t){return function(n){return e+n*t}}function Xm(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(o){return Math.pow(e+o*t,n)}}function Km(e){return(e=+e)==1?ru:function(t,n){return n-t?Xm(t,n,e):ba(isNaN(t)?n:t)}}function ru(e,t){var n=t-e;return n?Zm(e,n):ba(isNaN(e)?t:e)}const fs=function e(t){var n=Km(t);function o(s,r){var a=n((s=$r(s)).r,(r=$r(r)).r),l=n(s.g,r.g),c=n(s.b,r.b),u=ru(s.opacity,r.opacity);return function(f){return s.r=a(f),s.g=l(f),s.b=c(f),s.opacity=u(f),s+""}}return o.gamma=e,o}(1);function qm(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,o=t.slice(),s;return function(r){for(s=0;s<n;++s)o[s]=e[s]*(1-r)+t[s]*r;return o}}function Qm(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Jm(e,t){var n=t?t.length:0,o=e?Math.min(n,e.length):0,s=new Array(o),r=new Array(n),a;for(a=0;a<o;++a)s[a]=qi(e[a],t[a]);for(;a<n;++a)r[a]=t[a];return function(l){for(a=0;a<o;++a)r[a]=s[a](l);return r}}function eg(e,t){var n=new Date;return e=+e,t=+t,function(o){return n.setTime(e*(1-o)+t*o),n}}function Tt(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function tg(e,t){var n={},o={},s;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(s in t)s in e?n[s]=qi(e[s],t[s]):o[s]=t[s];return function(r){for(s in n)o[s]=n[s](r);return o}}var Gr=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ar=new RegExp(Gr.source,"g");function ng(e){return function(){return e}}function ig(e){return function(t){return e(t)+""}}function au(e,t){var n=Gr.lastIndex=ar.lastIndex=0,o,s,r,a=-1,l=[],c=[];for(e=e+"",t=t+"";(o=Gr.exec(e))&&(s=ar.exec(t));)(r=s.index)>n&&(r=t.slice(n,r),l[a]?l[a]+=r:l[++a]=r),(o=o[0])===(s=s[0])?l[a]?l[a]+=s:l[++a]=s:(l[++a]=null,c.push({i:a,x:Tt(o,s)})),n=ar.lastIndex;return n<t.length&&(r=t.slice(n),l[a]?l[a]+=r:l[++a]=r),l.length<2?c[0]?ig(c[0].x):ng(t):(t=c.length,function(u){for(var f=0,d;f<t;++f)l[(d=c[f]).i]=d.x(u);return l.join("")})}function qi(e,t){var n=typeof t,o;return t==null||n==="boolean"?ba(t):(n==="number"?Tt:n==="string"?(o=ii(t))?(t=o,fs):au:t instanceof ii?fs:t instanceof Date?eg:Qm(t)?qm:Array.isArray(t)?Jm:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?tg:Tt)(e,t)}var ul=180/Math.PI,Hr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function lu(e,t,n,o,s,r){var a,l,c;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(c=e*n+t*o)&&(n-=e*c,o-=t*c),(l=Math.sqrt(n*n+o*o))&&(n/=l,o/=l,c/=l),e*o<t*n&&(e=-e,t=-t,c=-c,a=-a),{translateX:s,translateY:r,rotate:Math.atan2(t,e)*ul,skewX:Math.atan(c)*ul,scaleX:a,scaleY:l}}var Do;function og(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Hr:lu(t.a,t.b,t.c,t.d,t.e,t.f)}function sg(e){return e==null||(Do||(Do=document.createElementNS("http://www.w3.org/2000/svg","g")),Do.setAttribute("transform",e),!(e=Do.transform.baseVal.consolidate()))?Hr:(e=e.matrix,lu(e.a,e.b,e.c,e.d,e.e,e.f))}function cu(e,t,n,o){function s(u){return u.length?u.pop()+" ":""}function r(u,f,d,p,h,v){if(u!==d||f!==p){var b=h.push("translate(",null,t,null,n);v.push({i:b-4,x:Tt(u,d)},{i:b-2,x:Tt(f,p)})}else(d||p)&&h.push("translate("+d+t+p+n)}function a(u,f,d,p){u!==f?(u-f>180?f+=360:f-u>180&&(u+=360),p.push({i:d.push(s(d)+"rotate(",null,o)-2,x:Tt(u,f)})):f&&d.push(s(d)+"rotate("+f+o)}function l(u,f,d,p){u!==f?p.push({i:d.push(s(d)+"skewX(",null,o)-2,x:Tt(u,f)}):f&&d.push(s(d)+"skewX("+f+o)}function c(u,f,d,p,h,v){if(u!==d||f!==p){var b=h.push(s(h)+"scale(",null,",",null,")");v.push({i:b-4,x:Tt(u,d)},{i:b-2,x:Tt(f,p)})}else(d!==1||p!==1)&&h.push(s(h)+"scale("+d+","+p+")")}return function(u,f){var d=[],p=[];return u=e(u),f=e(f),r(u.translateX,u.translateY,f.translateX,f.translateY,d,p),a(u.rotate,f.rotate,d,p),l(u.skewX,f.skewX,d,p),c(u.scaleX,u.scaleY,f.scaleX,f.scaleY,d,p),u=f=null,function(h){for(var v=-1,b=p.length,S;++v<b;)d[(S=p[v]).i]=S.x(h);return d.join("")}}}var rg=cu(og,"px, ","px)","deg)"),ag=cu(sg,", ",")",")"),lg=1e-12;function dl(e){return((e=Math.exp(e))+1/e)/2}function cg(e){return((e=Math.exp(e))-1/e)/2}function ug(e){return((e=Math.exp(2*e))-1)/(e+1)}const ts=function e(t,n,o){function s(r,a){var l=r[0],c=r[1],u=r[2],f=a[0],d=a[1],p=a[2],h=f-l,v=d-c,b=h*h+v*v,S,x;if(b<lg)x=Math.log(p/u)/t,S=function(N){return[l+N*h,c+N*v,u*Math.exp(t*N*x)]};else{var _=Math.sqrt(b),g=(p*p-u*u+o*b)/(2*u*n*_),y=(p*p-u*u-o*b)/(2*p*n*_),w=Math.log(Math.sqrt(g*g+1)-g),j=Math.log(Math.sqrt(y*y+1)-y);x=(j-w)/t,S=function(N){var B=N*x,z=dl(w),W=u/(n*_)*(z*ug(t*B+w)-cg(w));return[l+W*h,c+W*v,u*z/dl(t*B+w)]}}return S.duration=x*1e3*t/Math.SQRT2,S}return s.rho=function(r){var a=Math.max(.001,+r),l=a*a,c=l*l;return e(a,l,c)},s}(Math.SQRT2,2,4);var Si=0,Wi=0,Fi=0,uu=1e3,ps,Ui,hs=0,oi=0,As=0,ro=typeof performance=="object"&&performance.now?performance:Date,du=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function xa(){return oi||(du(dg),oi=ro.now()+As)}function dg(){oi=0}function ms(){this._call=this._time=this._next=null}ms.prototype=fu.prototype={constructor:ms,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?xa():+n)+(t==null?0:+t),!this._next&&Ui!==this&&(Ui?Ui._next=this:ps=this,Ui=this),this._call=e,this._time=n,Wr()},stop:function(){this._call&&(this._call=null,this._time=1/0,Wr())}};function fu(e,t,n){var o=new ms;return o.restart(e,t,n),o}function fg(){xa(),++Si;for(var e=ps,t;e;)(t=oi-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Si}function fl(){oi=(hs=ro.now())+As,Si=Wi=0;try{fg()}finally{Si=0,hg(),oi=0}}function pg(){var e=ro.now(),t=e-hs;t>uu&&(As-=t,hs=e)}function hg(){for(var e,t=ps,n,o=1/0;t;)t._call?(o>t._time&&(o=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:ps=n);Ui=e,Wr(o)}function Wr(e){if(!Si){Wi&&(Wi=clearTimeout(Wi));var t=e-oi;t>24?(e<1/0&&(Wi=setTimeout(fl,e-ro.now()-As)),Fi&&(Fi=clearInterval(Fi))):(Fi||(hs=ro.now(),Fi=setInterval(pg,uu)),Si=1,du(fl))}}function pl(e,t,n){var o=new ms;return t=t==null?0:+t,o.restart(s=>{o.stop(),e(s+t)},t,n),o}var mg=Is("start","end","cancel","interrupt"),gg=[],pu=0,hl=1,Ur=2,ns=3,ml=4,Vr=5,is=6;function ks(e,t,n,o,s,r){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;bg(e,n,{name:t,index:o,group:s,on:mg,tween:gg,time:r.time,delay:r.delay,duration:r.duration,ease:r.ease,timer:null,state:pu})}function ya(e,t){var n=ht(e,t);if(n.state>pu)throw new Error("too late; already scheduled");return n}function At(e,t){var n=ht(e,t);if(n.state>ns)throw new Error("too late; already running");return n}function ht(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function bg(e,t,n){var o=e.__transition,s;o[t]=n,n.timer=fu(r,0,n.time);function r(u){n.state=hl,n.timer.restart(a,n.delay,n.time),n.delay<=u&&a(u-n.delay)}function a(u){var f,d,p,h;if(n.state!==hl)return c();for(f in o)if(h=o[f],h.name===n.name){if(h.state===ns)return pl(a);h.state===ml?(h.state=is,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete o[f]):+f<t&&(h.state=is,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete o[f])}if(pl(function(){n.state===ns&&(n.state=ml,n.timer.restart(l,n.delay,n.time),l(u))}),n.state=Ur,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Ur){for(n.state=ns,s=new Array(p=n.tween.length),f=0,d=-1;f<p;++f)(h=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(s[++d]=h);s.length=d+1}}function l(u){for(var f=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(c),n.state=Vr,1),d=-1,p=s.length;++d<p;)s[d].call(e,f);n.state===Vr&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=is,n.timer.stop(),delete o[t];for(var u in o)return;delete e.__transition}}function os(e,t){var n=e.__transition,o,s,r=!0,a;if(n){t=t==null?null:t+"";for(a in n){if((o=n[a]).name!==t){r=!1;continue}s=o.state>Ur&&o.state<Vr,o.state=is,o.timer.stop(),o.on.call(s?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[a]}r&&delete e.__transition}}function xg(e){return this.each(function(){os(this,e)})}function yg(e,t){var n,o;return function(){var s=At(this,e),r=s.tween;if(r!==n){o=n=r;for(var a=0,l=o.length;a<l;++a)if(o[a].name===t){o=o.slice(),o.splice(a,1);break}}s.tween=o}}function vg(e,t,n){var o,s;if(typeof n!="function")throw new Error;return function(){var r=At(this,e),a=r.tween;if(a!==o){s=(o=a).slice();for(var l={name:t,value:n},c=0,u=s.length;c<u;++c)if(s[c].name===t){s[c]=l;break}c===u&&s.push(l)}r.tween=s}}function wg(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=ht(this.node(),n).tween,s=0,r=o.length,a;s<r;++s)if((a=o[s]).name===e)return a.value;return null}return this.each((t==null?yg:vg)(n,e,t))}function va(e,t,n){var o=e._id;return e.each(function(){var s=At(this,o);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return ht(s,o).value[t]}}function hu(e,t){var n;return(typeof t=="number"?Tt:t instanceof ii?fs:(n=ii(t))?(t=n,fs):au)(e,t)}function Sg(e){return function(){this.removeAttribute(e)}}function _g(e){return function(){this.removeAttributeNS(e.space,e.local)}}function jg(e,t,n){var o,s=n+"",r;return function(){var a=this.getAttribute(e);return a===s?null:a===o?r:r=t(o=a,n)}}function Mg(e,t,n){var o,s=n+"",r;return function(){var a=this.getAttributeNS(e.space,e.local);return a===s?null:a===o?r:r=t(o=a,n)}}function Cg(e,t,n){var o,s,r;return function(){var a,l=n(this),c;return l==null?void this.removeAttribute(e):(a=this.getAttribute(e),c=l+"",a===c?null:a===o&&c===s?r:(s=c,r=t(o=a,l)))}}function Ng(e,t,n){var o,s,r;return function(){var a,l=n(this),c;return l==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),c=l+"",a===c?null:a===o&&c===s?r:(s=c,r=t(o=a,l)))}}function Tg(e,t){var n=Es(e),o=n==="transform"?ag:hu;return this.attrTween(e,typeof t=="function"?(n.local?Ng:Cg)(n,o,va(this,"attr."+e,t)):t==null?(n.local?_g:Sg)(n):(n.local?Mg:jg)(n,o,t))}function Ig(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Eg(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Ag(e,t){var n,o;function s(){var r=t.apply(this,arguments);return r!==o&&(n=(o=r)&&Eg(e,r)),n}return s._value=t,s}function kg(e,t){var n,o;function s(){var r=t.apply(this,arguments);return r!==o&&(n=(o=r)&&Ig(e,r)),n}return s._value=t,s}function Bg(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var o=Es(e);return this.tween(n,(o.local?Ag:kg)(o,t))}function Pg(e,t){return function(){ya(this,e).delay=+t.apply(this,arguments)}}function Rg(e,t){return t=+t,function(){ya(this,e).delay=t}}function Dg(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Pg:Rg)(t,e)):ht(this.node(),t).delay}function Fg(e,t){return function(){At(this,e).duration=+t.apply(this,arguments)}}function Lg(e,t){return t=+t,function(){At(this,e).duration=t}}function zg(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Fg:Lg)(t,e)):ht(this.node(),t).duration}function Og(e,t){if(typeof t!="function")throw new Error;return function(){At(this,e).ease=t}}function $g(e){var t=this._id;return arguments.length?this.each(Og(t,e)):ht(this.node(),t).ease}function Gg(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;At(this,e).ease=n}}function Hg(e){if(typeof e!="function")throw new Error;return this.each(Gg(this._id,e))}function Wg(e){typeof e!="function"&&(e=Uc(e));for(var t=this._groups,n=t.length,o=new Array(n),s=0;s<n;++s)for(var r=t[s],a=r.length,l=o[s]=[],c,u=0;u<a;++u)(c=r[u])&&e.call(c,c.__data__,u,r)&&l.push(c);return new Wt(o,this._parents,this._name,this._id)}function Ug(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,s=n.length,r=Math.min(o,s),a=new Array(o),l=0;l<r;++l)for(var c=t[l],u=n[l],f=c.length,d=a[l]=new Array(f),p,h=0;h<f;++h)(p=c[h]||u[h])&&(d[h]=p);for(;l<o;++l)a[l]=t[l];return new Wt(a,this._parents,this._name,this._id)}function Vg(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function Yg(e,t,n){var o,s,r=Vg(t)?ya:At;return function(){var a=r(this,e),l=a.on;l!==o&&(s=(o=l).copy()).on(t,n),a.on=s}}function Zg(e,t){var n=this._id;return arguments.length<2?ht(this.node(),n).on.on(e):this.each(Yg(n,e,t))}function Xg(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Kg(){return this.on("end.remove",Xg(this._id))}function qg(e){var t=this._name,n=this._id;typeof e!="function"&&(e=ha(e));for(var o=this._groups,s=o.length,r=new Array(s),a=0;a<s;++a)for(var l=o[a],c=l.length,u=r[a]=new Array(c),f,d,p=0;p<c;++p)(f=l[p])&&(d=e.call(f,f.__data__,p,l))&&("__data__"in f&&(d.__data__=f.__data__),u[p]=d,ks(u[p],t,n,p,u,ht(f,n)));return new Wt(r,this._parents,t,n)}function Qg(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Wc(e));for(var o=this._groups,s=o.length,r=[],a=[],l=0;l<s;++l)for(var c=o[l],u=c.length,f,d=0;d<u;++d)if(f=c[d]){for(var p=e.call(f,f.__data__,d,c),h,v=ht(f,n),b=0,S=p.length;b<S;++b)(h=p[b])&&ks(h,t,n,b,p,v);r.push(p),a.push(f)}return new Wt(r,a,t,n)}var Jg=xo.prototype.constructor;function e0(){return new Jg(this._groups,this._parents)}function t0(e,t){var n,o,s;return function(){var r=wi(this,e),a=(this.style.removeProperty(e),wi(this,e));return r===a?null:r===n&&a===o?s:s=t(n=r,o=a)}}function mu(e){return function(){this.style.removeProperty(e)}}function n0(e,t,n){var o,s=n+"",r;return function(){var a=wi(this,e);return a===s?null:a===o?r:r=t(o=a,n)}}function i0(e,t,n){var o,s,r;return function(){var a=wi(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),wi(this,e))),a===c?null:a===o&&c===s?r:(s=c,r=t(o=a,l))}}function o0(e,t){var n,o,s,r="style."+t,a="end."+r,l;return function(){var c=At(this,e),u=c.on,f=c.value[r]==null?l||(l=mu(t)):void 0;(u!==n||s!==f)&&(o=(n=u).copy()).on(a,s=f),c.on=o}}function s0(e,t,n){var o=(e+="")=="transform"?rg:hu;return t==null?this.styleTween(e,t0(e,o)).on("end.style."+e,mu(e)):typeof t=="function"?this.styleTween(e,i0(e,o,va(this,"style."+e,t))).each(o0(this._id,e)):this.styleTween(e,n0(e,o,t),n).on("end.style."+e,null)}function r0(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function a0(e,t,n){var o,s;function r(){var a=t.apply(this,arguments);return a!==s&&(o=(s=a)&&r0(e,a,n)),o}return r._value=t,r}function l0(e,t,n){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;return this.tween(o,a0(e,t,n??""))}function c0(e){return function(){this.textContent=e}}function u0(e){return function(){var t=e(this);this.textContent=t??""}}function d0(e){return this.tween("text",typeof e=="function"?u0(va(this,"text",e)):c0(e==null?"":e+""))}function f0(e){return function(t){this.textContent=e.call(this,t)}}function p0(e){var t,n;function o(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&f0(s)),t}return o._value=e,o}function h0(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,p0(e))}function m0(){for(var e=this._name,t=this._id,n=gu(),o=this._groups,s=o.length,r=0;r<s;++r)for(var a=o[r],l=a.length,c,u=0;u<l;++u)if(c=a[u]){var f=ht(c,t);ks(c,e,n,u,a,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new Wt(o,this._parents,e,n)}function g0(){var e,t,n=this,o=n._id,s=n.size();return new Promise(function(r,a){var l={value:a},c={value:function(){--s===0&&r()}};n.each(function(){var u=At(this,o),f=u.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(c)),u.on=t}),s===0&&r()})}var b0=0;function Wt(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function gu(){return++b0}var zt=xo.prototype;Wt.prototype={constructor:Wt,select:qg,selectAll:Qg,selectChild:zt.selectChild,selectChildren:zt.selectChildren,filter:Wg,merge:Ug,selection:e0,transition:m0,call:zt.call,nodes:zt.nodes,node:zt.node,size:zt.size,empty:zt.empty,each:zt.each,on:Zg,attr:Tg,attrTween:Bg,style:s0,styleTween:l0,text:d0,textTween:h0,remove:Kg,tween:wg,delay:Dg,duration:zg,ease:$g,easeVarying:Hg,end:g0,[Symbol.iterator]:zt[Symbol.iterator]};function x0(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var y0={time:null,delay:0,duration:250,ease:x0};function v0(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function w0(e){var t,n;e instanceof Wt?(t=e._id,e=e._name):(t=gu(),(n=y0).time=xa(),e=e==null?null:e+"");for(var o=this._groups,s=o.length,r=0;r<s;++r)for(var a=o[r],l=a.length,c,u=0;u<l;++u)(c=a[u])&&ks(c,e,t,u,a,n||v0(c,t));return new Wt(o,this._parents,e,t)}xo.prototype.interrupt=xg;xo.prototype.transition=w0;const Fo=e=>()=>e;function S0(e,{sourceEvent:t,target:n,transform:o,dispatch:s}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:s}})}function Ht(e,t,n){this.k=e,this.x=t,this.y=n}Ht.prototype={constructor:Ht,scale:function(e){return e===1?this:new Ht(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ht(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Bs=new Ht(1,0,0);bu.prototype=Ht.prototype;function bu(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Bs;return e.__zoom}function lr(e){e.stopImmediatePropagation()}function Li(e){e.preventDefault(),e.stopImmediatePropagation()}function _0(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function j0(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function gl(){return this.__zoom||Bs}function M0(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function C0(){return navigator.maxTouchPoints||"ontouchstart"in this}function N0(e,t,n){var o=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],r=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(s>o?(o+s)/2:Math.min(0,o)||Math.max(0,s),a>r?(r+a)/2:Math.min(0,r)||Math.max(0,a))}function xu(){var e=_0,t=j0,n=N0,o=M0,s=C0,r=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],l=250,c=ts,u=Is("start","zoom","end"),f,d,p,h=500,v=150,b=0,S=10;function x(T){T.property("__zoom",gl).on("wheel.zoom",B,{passive:!1}).on("mousedown.zoom",z).on("dblclick.zoom",W).filter(s).on("touchstart.zoom",D).on("touchmove.zoom",E).on("touchend.zoom touchcancel.zoom",G).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}x.transform=function(T,O,P,L){var M=T.selection?T.selection():T;M.property("__zoom",gl),T!==M?w(T,O,P,L):M.interrupt().each(function(){j(this,arguments).event(L).start().zoom(null,typeof O=="function"?O.apply(this,arguments):O).end()})},x.scaleBy=function(T,O,P,L){x.scaleTo(T,function(){var M=this.__zoom.k,F=typeof O=="function"?O.apply(this,arguments):O;return M*F},P,L)},x.scaleTo=function(T,O,P,L){x.transform(T,function(){var M=t.apply(this,arguments),F=this.__zoom,U=P==null?y(M):typeof P=="function"?P.apply(this,arguments):P,V=F.invert(U),Y=typeof O=="function"?O.apply(this,arguments):O;return n(g(_(F,Y),U,V),M,a)},P,L)},x.translateBy=function(T,O,P,L){x.transform(T,function(){return n(this.__zoom.translate(typeof O=="function"?O.apply(this,arguments):O,typeof P=="function"?P.apply(this,arguments):P),t.apply(this,arguments),a)},null,L)},x.translateTo=function(T,O,P,L,M){x.transform(T,function(){var F=t.apply(this,arguments),U=this.__zoom,V=L==null?y(F):typeof L=="function"?L.apply(this,arguments):L;return n(Bs.translate(V[0],V[1]).scale(U.k).translate(typeof O=="function"?-O.apply(this,arguments):-O,typeof P=="function"?-P.apply(this,arguments):-P),F,a)},L,M)};function _(T,O){return O=Math.max(r[0],Math.min(r[1],O)),O===T.k?T:new Ht(O,T.x,T.y)}function g(T,O,P){var L=O[0]-P[0]*T.k,M=O[1]-P[1]*T.k;return L===T.x&&M===T.y?T:new Ht(T.k,L,M)}function y(T){return[(+T[0][0]+ +T[1][0])/2,(+T[0][1]+ +T[1][1])/2]}function w(T,O,P,L){T.on("start.zoom",function(){j(this,arguments).event(L).start()}).on("interrupt.zoom end.zoom",function(){j(this,arguments).event(L).end()}).tween("zoom",function(){var M=this,F=arguments,U=j(M,F).event(L),V=t.apply(M,F),Y=P==null?y(V):typeof P=="function"?P.apply(M,F):P,Z=Math.max(V[1][0]-V[0][0],V[1][1]-V[0][1]),q=M.__zoom,X=typeof O=="function"?O.apply(M,F):O,A=c(q.invert(Y).concat(Z/q.k),X.invert(Y).concat(Z/X.k));return function(C){if(C===1)C=X;else{var H=A(C),K=Z/H[2];C=new Ht(K,Y[0]-H[0]*K,Y[1]-H[1]*K)}U.zoom(null,C)}})}function j(T,O,P){return!P&&T.__zooming||new N(T,O)}function N(T,O){this.that=T,this.args=O,this.active=0,this.sourceEvent=null,this.extent=t.apply(T,O),this.taps=0}N.prototype={event:function(T){return T&&(this.sourceEvent=T),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(T,O){return this.mouse&&T!=="mouse"&&(this.mouse[1]=O.invert(this.mouse[0])),this.touch0&&T!=="touch"&&(this.touch0[1]=O.invert(this.touch0[0])),this.touch1&&T!=="touch"&&(this.touch1[1]=O.invert(this.touch1[0])),this.that.__zoom=O,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(T){var O=Ve(this.that).datum();u.call(T,this.that,new S0(T,{sourceEvent:this.sourceEvent,target:x,transform:this.that.__zoom,dispatch:u}),O)}};function B(T,...O){if(!e.apply(this,arguments))return;var P=j(this,O).event(T),L=this.__zoom,M=Math.max(r[0],Math.min(r[1],L.k*Math.pow(2,o.apply(this,arguments)))),F=st(T);if(P.wheel)(P.mouse[0][0]!==F[0]||P.mouse[0][1]!==F[1])&&(P.mouse[1]=L.invert(P.mouse[0]=F)),clearTimeout(P.wheel);else{if(L.k===M)return;P.mouse=[F,L.invert(F)],os(this),P.start()}Li(T),P.wheel=setTimeout(U,v),P.zoom("mouse",n(g(_(L,M),P.mouse[0],P.mouse[1]),P.extent,a));function U(){P.wheel=null,P.end()}}function z(T,...O){if(p||!e.apply(this,arguments))return;var P=T.currentTarget,L=j(this,O,!0).event(T),M=Ve(T.view).on("mousemove.zoom",Y,!0).on("mouseup.zoom",Z,!0),F=st(T,P),U=T.clientX,V=T.clientY;tu(T.view),lr(T),L.mouse=[F,this.__zoom.invert(F)],os(this),L.start();function Y(q){if(Li(q),!L.moved){var X=q.clientX-U,A=q.clientY-V;L.moved=X*X+A*A>b}L.event(q).zoom("mouse",n(g(L.that.__zoom,L.mouse[0]=st(q,P),L.mouse[1]),L.extent,a))}function Z(q){M.on("mousemove.zoom mouseup.zoom",null),nu(q.view,L.moved),Li(q),L.event(q).end()}}function W(T,...O){if(e.apply(this,arguments)){var P=this.__zoom,L=st(T.changedTouches?T.changedTouches[0]:T,this),M=P.invert(L),F=P.k*(T.shiftKey?.5:2),U=n(g(_(P,F),L,M),t.apply(this,O),a);Li(T),l>0?Ve(this).transition().duration(l).call(w,U,L,T):Ve(this).call(x.transform,U,L,T)}}function D(T,...O){if(e.apply(this,arguments)){var P=T.touches,L=P.length,M=j(this,O,T.changedTouches.length===L).event(T),F,U,V,Y;for(lr(T),U=0;U<L;++U)V=P[U],Y=st(V,this),Y=[Y,this.__zoom.invert(Y),V.identifier],M.touch0?!M.touch1&&M.touch0[2]!==Y[2]&&(M.touch1=Y,M.taps=0):(M.touch0=Y,F=!0,M.taps=1+!!f);f&&(f=clearTimeout(f)),F&&(M.taps<2&&(d=Y[0],f=setTimeout(function(){f=null},h)),os(this),M.start())}}function E(T,...O){if(this.__zooming){var P=j(this,O).event(T),L=T.changedTouches,M=L.length,F,U,V,Y;for(Li(T),F=0;F<M;++F)U=L[F],V=st(U,this),P.touch0&&P.touch0[2]===U.identifier?P.touch0[0]=V:P.touch1&&P.touch1[2]===U.identifier&&(P.touch1[0]=V);if(U=P.that.__zoom,P.touch1){var Z=P.touch0[0],q=P.touch0[1],X=P.touch1[0],A=P.touch1[1],C=(C=X[0]-Z[0])*C+(C=X[1]-Z[1])*C,H=(H=A[0]-q[0])*H+(H=A[1]-q[1])*H;U=_(U,Math.sqrt(C/H)),V=[(Z[0]+X[0])/2,(Z[1]+X[1])/2],Y=[(q[0]+A[0])/2,(q[1]+A[1])/2]}else if(P.touch0)V=P.touch0[0],Y=P.touch0[1];else return;P.zoom("touch",n(g(U,V,Y),P.extent,a))}}function G(T,...O){if(this.__zooming){var P=j(this,O).event(T),L=T.changedTouches,M=L.length,F,U;for(lr(T),p&&clearTimeout(p),p=setTimeout(function(){p=null},h),F=0;F<M;++F)U=L[F],P.touch0&&P.touch0[2]===U.identifier?delete P.touch0:P.touch1&&P.touch1[2]===U.identifier&&delete P.touch1;if(P.touch1&&!P.touch0&&(P.touch0=P.touch1,delete P.touch1),P.touch0)P.touch0[1]=this.__zoom.invert(P.touch0[0]);else if(P.end(),P.taps===2&&(U=st(U,this),Math.hypot(d[0]-U[0],d[1]-U[1])<S)){var V=Ve(this).on("dblclick.zoom");V&&V.apply(this,arguments)}}}return x.wheelDelta=function(T){return arguments.length?(o=typeof T=="function"?T:Fo(+T),x):o},x.filter=function(T){return arguments.length?(e=typeof T=="function"?T:Fo(!!T),x):e},x.touchable=function(T){return arguments.length?(s=typeof T=="function"?T:Fo(!!T),x):s},x.extent=function(T){return arguments.length?(t=typeof T=="function"?T:Fo([[+T[0][0],+T[0][1]],[+T[1][0],+T[1][1]]]),x):t},x.scaleExtent=function(T){return arguments.length?(r[0]=+T[0],r[1]=+T[1],x):[r[0],r[1]]},x.translateExtent=function(T){return arguments.length?(a[0][0]=+T[0][0],a[1][0]=+T[1][0],a[0][1]=+T[0][1],a[1][1]=+T[1][1],x):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},x.constrain=function(T){return arguments.length?(n=T,x):n},x.duration=function(T){return arguments.length?(l=+T,x):l},x.interpolate=function(T){return arguments.length?(c=T,x):c},x.on=function(){var T=u.on.apply(u,arguments);return T===u?x:T},x.clickDistance=function(T){return arguments.length?(b=(T=+T)*T,x):Math.sqrt(b)},x.tapDistance=function(T){return arguments.length?(S=+T,x):S},x}const Et={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:o})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:o}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},ao=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],yu=["Enter"," ","Escape"],vu={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var _i;(function(e){e.Strict="strict",e.Loose="loose"})(_i||(_i={}));var ni;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(ni||(ni={}));var lo;(function(e){e.Partial="partial",e.Full="full"})(lo||(lo={}));const wu={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var hn;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(hn||(hn={}));var co;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(co||(co={}));var le;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(le||(le={}));const bl={[le.Left]:le.Right,[le.Right]:le.Left,[le.Top]:le.Bottom,[le.Bottom]:le.Top};function Su(e){return e===null?null:e?"valid":"invalid"}const _u=e=>"id"in e&&"source"in e&&"target"in e,T0=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),wa=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),vo=(e,t=[0,0])=>{const{width:n,height:o}=Ut(e),s=e.origin??t,r=n*s[0],a=o*s[1];return{x:e.position.x-r,y:e.position.y-a}},I0=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((o,s)=>{const r=typeof s=="string";let a=!t.nodeLookup&&!r?s:void 0;t.nodeLookup&&(a=r?t.nodeLookup.get(s):wa(s)?s:t.nodeLookup.get(s.id));const l=a?gs(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Ps(o,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Rs(n)},wo=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return e.forEach(s=>{(t.filter===void 0||t.filter(s))&&(n=Ps(n,gs(s)),o=!0)}),o?Rs(n):{x:0,y:0,width:0,height:0}},Sa=(e,t,[n,o,s]=[0,0,1],r=!1,a=!1)=>{const l={..._o(t,[n,o,s]),width:t.width/s,height:t.height/s},c=[];for(const u of e.values()){const{measured:f,selectable:d=!0,hidden:p=!1}=u;if(a&&!d||p)continue;const h=f.width??u.width??u.initialWidth??null,v=f.height??u.height??u.initialHeight??null,b=uo(l,Mi(u)),S=(h??0)*(v??0),x=r&&b>0;(!u.internals.handleBounds||x||b>=S||u.dragging)&&c.push(u)}return c},E0=(e,t)=>{const n=new Set;return e.forEach(o=>{n.add(o.id)}),t.filter(o=>n.has(o.source)||n.has(o.target))};function A0(e,t){const n=new Map,o=t?.nodes?new Set(t.nodes.map(s=>s.id)):null;return e.forEach(s=>{s.measured.width&&s.measured.height&&(t?.includeHiddenNodes||!s.hidden)&&(!o||o.has(s.id))&&n.set(s.id,s)}),n}async function k0({nodes:e,width:t,height:n,panZoom:o,minZoom:s,maxZoom:r},a){if(e.size===0)return Promise.resolve(!0);const l=A0(e,a),c=wo(l),u=_a(c,t,n,a?.minZoom??s,a?.maxZoom??r,a?.padding??.1);return await o.setViewport(u,{duration:a?.duration,ease:a?.ease,interpolate:a?.interpolate}),Promise.resolve(!0)}function ju({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:s,onError:r}){const a=n.get(e),l=a.parentId?n.get(a.parentId):void 0,{x:c,y:u}=l?l.internals.positionAbsolute:{x:0,y:0},f=a.origin??o;let d=a.extent||s;if(a.extent==="parent"&&!a.expandParent)if(!l)r?.("005",Et.error005());else{const h=l.measured.width,v=l.measured.height;h&&v&&(d=[[c,u],[c+h,u+v]])}else l&&Ci(a.extent)&&(d=[[a.extent[0][0]+c,a.extent[0][1]+u],[a.extent[1][0]+c,a.extent[1][1]+u]]);const p=Ci(d)?si(t,d,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&r?.("015",Et.error015()),{position:{x:p.x-c+(a.measured.width??0)*f[0],y:p.y-u+(a.measured.height??0)*f[1]},positionAbsolute:p}}async function B0({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:s}){const r=new Set(e.map(p=>p.id)),a=[];for(const p of n){if(p.deletable===!1)continue;const h=r.has(p.id),v=!h&&p.parentId&&a.find(b=>b.id===p.parentId);(h||v)&&a.push(p)}const l=new Set(t.map(p=>p.id)),c=o.filter(p=>p.deletable!==!1),f=E0(a,c);for(const p of c)l.has(p.id)&&!f.find(v=>v.id===p.id)&&f.push(p);if(!s)return{edges:f,nodes:a};const d=await s({nodes:a,edges:f});return typeof d=="boolean"?d?{edges:f,nodes:a}:{edges:[],nodes:[]}:d}const ji=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),si=(e={x:0,y:0},t,n)=>({x:ji(e.x,t[0][0],t[1][0]-(n?.width??0)),y:ji(e.y,t[0][1],t[1][1]-(n?.height??0))});function Mu(e,t,n){const{width:o,height:s}=Ut(n),{x:r,y:a}=n.internals.positionAbsolute;return si(e,[[r,a],[r+o,a+s]],t)}const xl=(e,t,n)=>e<t?ji(Math.abs(e-t),1,t)/t:e>n?-ji(Math.abs(e-n),1,t)/t:0,Cu=(e,t,n=15,o=40)=>{const s=xl(e.x,o,t.width-o)*n,r=xl(e.y,o,t.height-o)*n;return[s,r]},Ps=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Yr=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),Rs=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),Mi=(e,t=[0,0])=>{const{x:n,y:o}=wa(e)?e.internals.positionAbsolute:vo(e,t);return{x:n,y:o,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},gs=(e,t=[0,0])=>{const{x:n,y:o}=wa(e)?e.internals.positionAbsolute:vo(e,t);return{x:n,y:o,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:o+(e.measured?.height??e.height??e.initialHeight??0)}},Nu=(e,t)=>Rs(Ps(Yr(e),Yr(t))),uo=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),o=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*o)},yl=e=>ut(e.width)&&ut(e.height)&&ut(e.x)&&ut(e.y),ut=e=>!isNaN(e)&&isFinite(e),P0=(e,t)=>{},So=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),_o=({x:e,y:t},[n,o,s],r=!1,a=[1,1])=>{const l={x:(e-n)/s,y:(t-o)/s};return r?So(l,a):l},bs=({x:e,y:t},[n,o,s])=>({x:e*s+n,y:t*s+o});function ui(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function R0(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=ui(e,n),s=ui(e,t);return{top:o,right:s,bottom:o,left:s,x:s*2,y:o*2}}if(typeof e=="object"){const o=ui(e.top??e.y??0,n),s=ui(e.bottom??e.y??0,n),r=ui(e.left??e.x??0,t),a=ui(e.right??e.x??0,t);return{top:o,right:a,bottom:s,left:r,x:r+a,y:o+s}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function D0(e,t,n,o,s,r){const{x:a,y:l}=bs(e,[t,n,o]),{x:c,y:u}=bs({x:e.x+e.width,y:e.y+e.height},[t,n,o]),f=s-c,d=r-u;return{left:Math.floor(a),top:Math.floor(l),right:Math.floor(f),bottom:Math.floor(d)}}const _a=(e,t,n,o,s,r)=>{const a=R0(r,t,n),l=(t-a.x)/e.width,c=(n-a.y)/e.height,u=Math.min(l,c),f=ji(u,o,s),d=e.x+e.width/2,p=e.y+e.height/2,h=t/2-d*f,v=n/2-p*f,b=D0(e,h,v,f,t,n),S={left:Math.min(b.left-a.left,0),top:Math.min(b.top-a.top,0),right:Math.min(b.right-a.right,0),bottom:Math.min(b.bottom-a.bottom,0)};return{x:h-S.left+S.right,y:v-S.top+S.bottom,zoom:f}},fo=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Ci(e){return e!=null&&e!=="parent"}function Ut(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Tu(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Iu(e,t={width:0,height:0},n,o,s){const r={...e},a=o.get(n);if(a){const l=a.origin||s;r.x+=a.internals.positionAbsolute.x-(t.width??0)*l[0],r.y+=a.internals.positionAbsolute.y-(t.height??0)*l[1]}return r}function vl(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function F0(){let e,t;return{promise:new Promise((o,s)=>{e=o,t=s}),resolve:e,reject:t}}function L0(e){return{...vu,...e||{}}}function Qi(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:s}){const{x:r,y:a}=dt(e),l=_o({x:r-(s?.left??0),y:a-(s?.top??0)},o),{x:c,y:u}=n?So(l,t):l;return{xSnapped:c,ySnapped:u,...l}}const ja=e=>({width:e.offsetWidth,height:e.offsetHeight}),Eu=e=>e?.getRootNode?.()||window?.document,z0=["INPUT","SELECT","TEXTAREA"];function Au(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:z0.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const ku=e=>"clientX"in e,dt=(e,t)=>{const n=ku(e),o=n?e.clientX:e.touches?.[0].clientX,s=n?e.clientY:e.touches?.[0].clientY;return{x:o-(t?.left??0),y:s-(t?.top??0)}},wl=(e,t,n,o,s)=>{const r=t.querySelectorAll(`.${e}`);return!r||!r.length?null:Array.from(r).map(a=>{const l=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),type:e,nodeId:s,position:a.getAttribute("data-handlepos"),x:(l.left-n.left)/o,y:(l.top-n.top)/o,...ja(a)}})};function Bu({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:s,sourceControlY:r,targetControlX:a,targetControlY:l}){const c=e*.125+s*.375+a*.375+n*.125,u=t*.125+r*.375+l*.375+o*.125,f=Math.abs(c-e),d=Math.abs(u-t);return[c,u,f,d]}function Lo(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Sl({pos:e,x1:t,y1:n,x2:o,y2:s,c:r}){switch(e){case le.Left:return[t-Lo(t-o,r),n];case le.Right:return[t+Lo(o-t,r),n];case le.Top:return[t,n-Lo(n-s,r)];case le.Bottom:return[t,n+Lo(s-n,r)]}}function Pu({sourceX:e,sourceY:t,sourcePosition:n=le.Bottom,targetX:o,targetY:s,targetPosition:r=le.Top,curvature:a=.25}){const[l,c]=Sl({pos:n,x1:e,y1:t,x2:o,y2:s,c:a}),[u,f]=Sl({pos:r,x1:o,y1:s,x2:e,y2:t,c:a}),[d,p,h,v]=Bu({sourceX:e,sourceY:t,targetX:o,targetY:s,sourceControlX:l,sourceControlY:c,targetControlX:u,targetControlY:f});return[`M${e},${t} C${l},${c} ${u},${f} ${o},${s}`,d,p,h,v]}function Ru({sourceX:e,sourceY:t,targetX:n,targetY:o}){const s=Math.abs(n-e)/2,r=n<e?n+s:n-s,a=Math.abs(o-t)/2,l=o<t?o+a:o-a;return[r,l,s,a]}function O0({sourceNode:e,targetNode:t,selected:n=!1,zIndex:o=0,elevateOnSelect:s=!1,zIndexMode:r="basic"}){if(r==="manual")return o;const a=s&&n?o+1e3:o,l=Math.max(e.parentId||s&&e.selected?e.internals.z:0,t.parentId||s&&t.selected?t.internals.z:0);return a+l}function $0({sourceNode:e,targetNode:t,width:n,height:o,transform:s}){const r=Ps(gs(e),gs(t));r.x===r.x2&&(r.x2+=1),r.y===r.y2&&(r.y2+=1);const a={x:-s[0]/s[2],y:-s[1]/s[2],width:n/s[2],height:o/s[2]};return uo(a,Rs(r))>0}const G0=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,H0=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),W0=(e,t,n={})=>{if(!e.source||!e.target)return t;const o=n.getEdgeId||G0;let s;return _u(e)?s={...e}:s={...e,id:o(e)},H0(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function Du({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[s,r,a,l]=Ru({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,s,r,a,l]}const _l={[le.Left]:{x:-1,y:0},[le.Right]:{x:1,y:0},[le.Top]:{x:0,y:-1},[le.Bottom]:{x:0,y:1}},U0=({source:e,sourcePosition:t=le.Bottom,target:n})=>t===le.Left||t===le.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},jl=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function V0({source:e,sourcePosition:t=le.Bottom,target:n,targetPosition:o=le.Top,center:s,offset:r,stepPosition:a}){const l=_l[t],c=_l[o],u={x:e.x+l.x*r,y:e.y+l.y*r},f={x:n.x+c.x*r,y:n.y+c.y*r},d=U0({source:u,sourcePosition:t,target:f}),p=d.x!==0?"x":"y",h=d[p];let v=[],b,S;const x={x:0,y:0},_={x:0,y:0},[,,g,y]=Ru({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[p]*c[p]===-1){p==="x"?(b=s.x??u.x+(f.x-u.x)*a,S=s.y??(u.y+f.y)/2):(b=s.x??(u.x+f.x)/2,S=s.y??u.y+(f.y-u.y)*a);const B=[{x:b,y:u.y},{x:b,y:f.y}],z=[{x:u.x,y:S},{x:f.x,y:S}];l[p]===h?v=p==="x"?B:z:v=p==="x"?z:B}else{const B=[{x:u.x,y:f.y}],z=[{x:f.x,y:u.y}];if(p==="x"?v=l.x===h?z:B:v=l.y===h?B:z,t===o){const T=Math.abs(e[p]-n[p]);if(T<=r){const O=Math.min(r-1,r-T);l[p]===h?x[p]=(u[p]>e[p]?-1:1)*O:_[p]=(f[p]>n[p]?-1:1)*O}}if(t!==o){const T=p==="x"?"y":"x",O=l[p]===c[T],P=u[T]>f[T],L=u[T]<f[T];(l[p]===1&&(!O&&P||O&&L)||l[p]!==1&&(!O&&L||O&&P))&&(v=p==="x"?B:z)}const W={x:u.x+x.x,y:u.y+x.y},D={x:f.x+_.x,y:f.y+_.y},E=Math.max(Math.abs(W.x-v[0].x),Math.abs(D.x-v[0].x)),G=Math.max(Math.abs(W.y-v[0].y),Math.abs(D.y-v[0].y));E>=G?(b=(W.x+D.x)/2,S=v[0].y):(b=v[0].x,S=(W.y+D.y)/2)}const w={x:u.x+x.x,y:u.y+x.y},j={x:f.x+_.x,y:f.y+_.y};return[[e,...w.x!==v[0].x||w.y!==v[0].y?[w]:[],...v,...j.x!==v[v.length-1].x||j.y!==v[v.length-1].y?[j]:[],n],b,S,g,y]}function Y0(e,t,n,o){const s=Math.min(jl(e,t)/2,jl(t,n)/2,o),{x:r,y:a}=t;if(e.x===r&&r===n.x||e.y===a&&a===n.y)return`L${r} ${a}`;if(e.y===a){const u=e.x<n.x?-1:1,f=e.y<n.y?1:-1;return`L ${r+s*u},${a}Q ${r},${a} ${r},${a+s*f}`}const l=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${r},${a+s*c}Q ${r},${a} ${r+s*l},${a}`}function Zr({sourceX:e,sourceY:t,sourcePosition:n=le.Bottom,targetX:o,targetY:s,targetPosition:r=le.Top,borderRadius:a=5,centerX:l,centerY:c,offset:u=20,stepPosition:f=.5}){const[d,p,h,v,b]=V0({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:s},targetPosition:r,center:{x:l,y:c},offset:u,stepPosition:f});let S=`M${d[0].x} ${d[0].y}`;for(let x=1;x<d.length-1;x++)S+=Y0(d[x-1],d[x],d[x+1],a);return S+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[S,p,h,v,b]}function Ml(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Z0(e){const{sourceNode:t,targetNode:n}=e;if(!Ml(t)||!Ml(n))return null;const o=t.internals.handleBounds||Cl(t.handles),s=n.internals.handleBounds||Cl(n.handles),r=Nl(o?.source??[],e.sourceHandle),a=Nl(e.connectionMode===_i.Strict?s?.target??[]:(s?.target??[]).concat(s?.source??[]),e.targetHandle);if(!r||!a)return e.onError?.("008",Et.error008(r?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const l=r?.position||le.Bottom,c=a?.position||le.Top,u=ri(t,r,l),f=ri(n,a,c);return{sourceX:u.x,sourceY:u.y,targetX:f.x,targetY:f.y,sourcePosition:l,targetPosition:c}}function Cl(e){if(!e)return null;const t=[],n=[];for(const o of e)o.width=o.width??1,o.height=o.height??1,o.type==="source"?t.push(o):o.type==="target"&&n.push(o);return{source:t,target:n}}function ri(e,t,n=le.Left,o=!1){const s=(t?.x??0)+e.internals.positionAbsolute.x,r=(t?.y??0)+e.internals.positionAbsolute.y,{width:a,height:l}=t??Ut(e);if(o)return{x:s+a/2,y:r+l/2};switch(t?.position??n){case le.Top:return{x:s+a/2,y:r};case le.Right:return{x:s+a,y:r+l/2};case le.Bottom:return{x:s+a/2,y:r+l};case le.Left:return{x:s,y:r+l/2}}}function Nl(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Xr(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function X0(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:s}){const r=new Set;return e.reduce((a,l)=>([l.markerStart||o,l.markerEnd||s].forEach(c=>{if(c&&typeof c=="object"){const u=Xr(c,t);r.has(u)||(a.push({id:u,color:c.color||n,...c}),r.add(u))}}),a),[]).sort((a,l)=>a.id.localeCompare(l.id))}const Fu=1e3,K0=10,Ma={nodeOrigin:[0,0],nodeExtent:ao,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},q0={...Ma,checkEquality:!0};function Ca(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function Q0(e,t,n){const o=Ca(Ma,n);for(const s of e.values())if(s.parentId)Ta(s,e,t,o);else{const r=vo(s,o.nodeOrigin),a=Ci(s.extent)?s.extent:o.nodeExtent,l=si(r,a,Ut(s));s.internals.positionAbsolute=l}}function J0(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],o=[];for(const s of e.handles){const r={id:s.id,width:s.width??1,height:s.height??1,nodeId:e.id,x:s.x,y:s.y,position:s.position,type:s.type};s.type==="source"?n.push(r):s.type==="target"&&o.push(r)}return{source:n,target:o}}function Na(e){return e==="manual"}function Kr(e,t,n,o={}){const s=Ca(q0,o),r={i:0},a=new Map(t),l=s?.elevateNodesOnSelect&&!Na(s.zIndexMode)?Fu:0;let c=e.length>0,u=!1;t.clear(),n.clear();for(const f of e){let d=a.get(f.id);if(s.checkEquality&&f===d?.internals.userNode)t.set(f.id,d);else{const p=vo(f,s.nodeOrigin),h=Ci(f.extent)?f.extent:s.nodeExtent,v=si(p,h,Ut(f));d={...s.defaults,...f,measured:{width:f.measured?.width,height:f.measured?.height},internals:{positionAbsolute:v,handleBounds:J0(f,d),z:Lu(f,l,s.zIndexMode),userNode:f}},t.set(f.id,d)}(d.measured===void 0||d.measured.width===void 0||d.measured.height===void 0)&&!d.hidden&&(c=!1),f.parentId&&Ta(d,t,n,o,r),u||=f.selected??!1}return{nodesInitialized:c,hasSelectedNodes:u}}function eb(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Ta(e,t,n,o,s){const{elevateNodesOnSelect:r,nodeOrigin:a,nodeExtent:l,zIndexMode:c}=Ca(Ma,o),u=e.parentId,f=t.get(u);if(!f){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}eb(e,n),s&&!f.parentId&&f.internals.rootParentIndex===void 0&&c==="auto"&&(f.internals.rootParentIndex=++s.i,f.internals.z=f.internals.z+s.i*K0),s&&f.internals.rootParentIndex!==void 0&&(s.i=f.internals.rootParentIndex);const d=r&&!Na(c)?Fu:0,{x:p,y:h,z:v}=tb(e,f,a,l,d,c),{positionAbsolute:b}=e.internals,S=p!==b.x||h!==b.y;(S||v!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:S?{x:p,y:h}:b,z:v}})}function Lu(e,t,n){const o=ut(e.zIndex)?e.zIndex:0;return Na(n)?o:o+(e.selected?t:0)}function tb(e,t,n,o,s,r){const{x:a,y:l}=t.internals.positionAbsolute,c=Ut(e),u=vo(e,n),f=Ci(e.extent)?si(u,e.extent,c):u;let d=si({x:a+f.x,y:l+f.y},o,c);e.extent==="parent"&&(d=Mu(d,c,t));const p=Lu(e,s,r),h=t.internals.z??0;return{x:d.x,y:d.y,z:h>=p?h+1:p}}function Ia(e,t,n,o=[0,0]){const s=[],r=new Map;for(const a of e){const l=t.get(a.parentId);if(!l)continue;const c=r.get(a.parentId)?.expandedRect??Mi(l),u=Nu(c,a.rect);r.set(a.parentId,{expandedRect:u,parent:l})}return r.size>0&&r.forEach(({expandedRect:a,parent:l},c)=>{const u=l.internals.positionAbsolute,f=Ut(l),d=l.origin??o,p=a.x<u.x?Math.round(Math.abs(u.x-a.x)):0,h=a.y<u.y?Math.round(Math.abs(u.y-a.y)):0,v=Math.max(f.width,Math.round(a.width)),b=Math.max(f.height,Math.round(a.height)),S=(v-f.width)*d[0],x=(b-f.height)*d[1];(p>0||h>0||S||x)&&(s.push({id:c,type:"position",position:{x:l.position.x-p+S,y:l.position.y-h+x}}),n.get(c)?.forEach(_=>{e.some(g=>g.id===_.id)||s.push({id:_.id,type:"position",position:{x:_.position.x+p,y:_.position.y+h}})})),(f.width<a.width||f.height<a.height||p||h)&&s.push({id:c,type:"dimensions",setAttributes:!0,dimensions:{width:v+(p?d[0]*p-S:0),height:b+(h?d[1]*h-x:0)}})}),s}function nb(e,t,n,o,s,r,a){const l=o?.querySelector(".xyflow__viewport");let c=!1;if(!l)return{changes:[],updatedInternals:c};const u=[],f=window.getComputedStyle(l),{m22:d}=new window.DOMMatrixReadOnly(f.transform),p=[];for(const h of e.values()){const v=t.get(h.id);if(!v)continue;if(v.hidden){t.set(v.id,{...v,internals:{...v.internals,handleBounds:void 0}}),c=!0;continue}const b=ja(h.nodeElement),S=v.measured.width!==b.width||v.measured.height!==b.height;if(!!(b.width&&b.height&&(S||!v.internals.handleBounds||h.force))){const _=h.nodeElement.getBoundingClientRect(),g=Ci(v.extent)?v.extent:r;let{positionAbsolute:y}=v.internals;v.parentId&&v.extent==="parent"?y=Mu(y,b,t.get(v.parentId)):g&&(y=si(y,g,b));const w={...v,measured:b,internals:{...v.internals,positionAbsolute:y,handleBounds:{source:wl("source",h.nodeElement,_,d,v.id),target:wl("target",h.nodeElement,_,d,v.id)}}};t.set(v.id,w),v.parentId&&Ta(w,t,n,{nodeOrigin:s,zIndexMode:a}),c=!0,S&&(u.push({id:v.id,type:"dimensions",dimensions:b}),v.expandParent&&v.parentId&&p.push({id:v.id,parentId:v.parentId,rect:Mi(w,s)}))}}if(p.length>0){const h=Ia(p,t,n,s);u.push(...h)}return{changes:u,updatedInternals:c}}async function ib({delta:e,panZoom:t,transform:n,translateExtent:o,width:s,height:r}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const a=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[s,r]],o),l=!!a&&(a.x!==n[0]||a.y!==n[1]||a.k!==n[2]);return Promise.resolve(l)}function Tl(e,t,n,o,s,r){let a=s;const l=o.get(a)||new Map;o.set(a,l.set(n,t)),a=`${s}-${e}`;const c=o.get(a)||new Map;if(o.set(a,c.set(n,t)),r){a=`${s}-${e}-${r}`;const u=o.get(a)||new Map;o.set(a,u.set(n,t))}}function zu(e,t,n){e.clear(),t.clear();for(const o of n){const{source:s,target:r,sourceHandle:a=null,targetHandle:l=null}=o,c={edgeId:o.id,source:s,target:r,sourceHandle:a,targetHandle:l},u=`${s}-${a}--${r}-${l}`,f=`${r}-${l}--${s}-${a}`;Tl("source",c,f,e,s,a),Tl("target",c,u,e,r,l),t.set(o.id,o)}}function Ou(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Ou(n,t):!1}function Il(e,t,n){let o=e;do{if(o?.matches?.(t))return!0;if(o===n)return!1;o=o?.parentElement}while(o);return!1}function ob(e,t,n,o){const s=new Map;for(const[r,a]of e)if((a.selected||a.id===o)&&(!a.parentId||!Ou(a,e))&&(a.draggable||t&&typeof a.draggable>"u")){const l=e.get(r);l&&s.set(r,{id:r,position:l.position||{x:0,y:0},distance:{x:n.x-l.internals.positionAbsolute.x,y:n.y-l.internals.positionAbsolute.y},extent:l.extent,parentId:l.parentId,origin:l.origin,expandParent:l.expandParent,internals:{positionAbsolute:l.internals.positionAbsolute||{x:0,y:0}},measured:{width:l.measured.width??0,height:l.measured.height??0}})}return s}function cr({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){const s=[];for(const[a,l]of t){const c=n.get(a)?.internals.userNode;c&&s.push({...c,position:l.position,dragging:o})}if(!e)return[s[0],s];const r=n.get(e)?.internals.userNode;return[r?{...r,position:t.get(e)?.position||r.position,dragging:o}:s[0],s]}function sb({dragItems:e,snapGrid:t,x:n,y:o}){const s=e.values().next().value;if(!s)return null;const r={x:n-s.distance.x,y:o-s.distance.y},a=So(r,t);return{x:a.x-r.x,y:a.y-r.y}}function rb({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:s}){let r={x:null,y:null},a=0,l=new Map,c=!1,u={x:0,y:0},f=null,d=!1,p=null,h=!1,v=!1,b=null;function S({noDragClassName:_,handleSelector:g,domNode:y,isSelectable:w,nodeId:j,nodeClickDistance:N=0}){p=Ve(y);function B({x:E,y:G}){const{nodeLookup:T,nodeExtent:O,snapGrid:P,snapToGrid:L,nodeOrigin:M,onNodeDrag:F,onSelectionDrag:U,onError:V,updateNodePositions:Y}=t();r={x:E,y:G};let Z=!1;const q=l.size>1,X=q&&O?Yr(wo(l)):null,A=q&&L?sb({dragItems:l,snapGrid:P,x:E,y:G}):null;for(const[C,H]of l){if(!T.has(C))continue;let K={x:E-H.distance.x,y:G-H.distance.y};L&&(K=A?{x:Math.round(K.x+A.x),y:Math.round(K.y+A.y)}:So(K,P));let Q=null;if(q&&O&&!H.extent&&X){const{positionAbsolute:ie}=H.internals,re=ie.x-X.x+O[0][0],J=ie.x+H.measured.width-X.x2+O[1][0],ce=ie.y-X.y+O[0][1],de=ie.y+H.measured.height-X.y2+O[1][1];Q=[[re,ce],[J,de]]}const{position:ee,positionAbsolute:ne}=ju({nodeId:C,nextPosition:K,nodeLookup:T,nodeExtent:Q||O,nodeOrigin:M,onError:V});Z=Z||H.position.x!==ee.x||H.position.y!==ee.y,H.position=ee,H.internals.positionAbsolute=ne}if(v=v||Z,!!Z&&(Y(l,!0),b&&(o||F||!j&&U))){const[C,H]=cr({nodeId:j,dragItems:l,nodeLookup:T});o?.(b,l,C,H),F?.(b,C,H),j||U?.(b,H)}}async function z(){if(!f)return;const{transform:E,panBy:G,autoPanSpeed:T,autoPanOnNodeDrag:O}=t();if(!O){c=!1,cancelAnimationFrame(a);return}const[P,L]=Cu(u,f,T);(P!==0||L!==0)&&(r.x=(r.x??0)-P/E[2],r.y=(r.y??0)-L/E[2],await G({x:P,y:L})&&B(r)),a=requestAnimationFrame(z)}function W(E){const{nodeLookup:G,multiSelectionActive:T,nodesDraggable:O,transform:P,snapGrid:L,snapToGrid:M,selectNodesOnDrag:F,onNodeDragStart:U,onSelectionDragStart:V,unselectNodesAndEdges:Y}=t();d=!0,(!F||!w)&&!T&&j&&(G.get(j)?.selected||Y()),w&&F&&j&&e?.(j);const Z=Qi(E.sourceEvent,{transform:P,snapGrid:L,snapToGrid:M,containerBounds:f});if(r=Z,l=ob(G,O,Z,j),l.size>0&&(n||U||!j&&V)){const[q,X]=cr({nodeId:j,dragItems:l,nodeLookup:G});n?.(E.sourceEvent,l,q,X),U?.(E.sourceEvent,q,X),j||V?.(E.sourceEvent,X)}}const D=iu().clickDistance(N).on("start",E=>{const{domNode:G,nodeDragThreshold:T,transform:O,snapGrid:P,snapToGrid:L}=t();f=G?.getBoundingClientRect()||null,h=!1,v=!1,b=E.sourceEvent,T===0&&W(E),r=Qi(E.sourceEvent,{transform:O,snapGrid:P,snapToGrid:L,containerBounds:f}),u=dt(E.sourceEvent,f)}).on("drag",E=>{const{autoPanOnNodeDrag:G,transform:T,snapGrid:O,snapToGrid:P,nodeDragThreshold:L,nodeLookup:M}=t(),F=Qi(E.sourceEvent,{transform:T,snapGrid:O,snapToGrid:P,containerBounds:f});if(b=E.sourceEvent,(E.sourceEvent.type==="touchmove"&&E.sourceEvent.touches.length>1||j&&!M.has(j))&&(h=!0),!h){if(!c&&G&&d&&(c=!0,z()),!d){const U=dt(E.sourceEvent,f),V=U.x-u.x,Y=U.y-u.y;Math.sqrt(V*V+Y*Y)>L&&W(E)}(r.x!==F.xSnapped||r.y!==F.ySnapped)&&l&&d&&(u=dt(E.sourceEvent,f),B(F))}}).on("end",E=>{if(!(!d||h)&&(c=!1,d=!1,cancelAnimationFrame(a),l.size>0)){const{nodeLookup:G,updateNodePositions:T,onNodeDragStop:O,onSelectionDragStop:P}=t();if(v&&(T(l,!1),v=!1),s||O||!j&&P){const[L,M]=cr({nodeId:j,dragItems:l,nodeLookup:G,dragging:!1});s?.(E.sourceEvent,l,L,M),O?.(E.sourceEvent,L,M),j||P?.(E.sourceEvent,M)}}}).filter(E=>{const G=E.target;return!E.button&&(!_||!Il(G,`.${_}`,y))&&(!g||Il(G,g,y))});p.call(D)}function x(){p?.on(".drag",null)}return{update:S,destroy:x}}function ab(e,t,n){const o=[],s={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const r of t.values())uo(s,Mi(r))>0&&o.push(r);return o}const lb=250;function cb(e,t,n,o){let s=[],r=1/0;const a=ab(e,n,t+lb);for(const l of a){const c=[...l.internals.handleBounds?.source??[],...l.internals.handleBounds?.target??[]];for(const u of c){if(o.nodeId===u.nodeId&&o.type===u.type&&o.id===u.id)continue;const{x:f,y:d}=ri(l,u,u.position,!0),p=Math.sqrt(Math.pow(f-e.x,2)+Math.pow(d-e.y,2));p>t||(p<r?(s=[{...u,x:f,y:d}],r=p):p===r&&s.push({...u,x:f,y:d}))}}if(!s.length)return null;if(s.length>1){const l=o.type==="source"?"target":"source";return s.find(c=>c.type===l)??s[0]}return s[0]}function $u(e,t,n,o,s,r=!1){const a=o.get(e);if(!a)return null;const l=s==="strict"?a.internals.handleBounds?.[t]:[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]],c=(n?l?.find(u=>u.id===n):l?.[0])??null;return c&&r?{...c,...ri(a,c,c.position,!0)}:c}function Gu(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function ub(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Hu=()=>!0;function db(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:s,edgeUpdaterType:r,isTarget:a,domNode:l,nodeLookup:c,lib:u,autoPanOnConnect:f,flowId:d,panBy:p,cancelConnection:h,onConnectStart:v,onConnect:b,onConnectEnd:S,isValidConnection:x=Hu,onReconnectEnd:_,updateConnection:g,getTransform:y,getFromHandle:w,autoPanSpeed:j,dragThreshold:N=1,handleDomNode:B}){const z=Eu(e.target);let W=0,D;const{x:E,y:G}=dt(e),T=Gu(r,B),O=l?.getBoundingClientRect();let P=!1;if(!O||!T)return;const L=$u(s,T,o,c,t);if(!L)return;let M=dt(e,O),F=!1,U=null,V=!1,Y=null;function Z(){if(!f||!O)return;const[ee,ne]=Cu(M,O,j);p({x:ee,y:ne}),W=requestAnimationFrame(Z)}const q={...L,nodeId:s,type:T,position:L.position},X=c.get(s);let C={inProgress:!0,isValid:null,from:ri(X,q,le.Left,!0),fromHandle:q,fromPosition:q.position,fromNode:X,to:M,toHandle:null,toPosition:bl[q.position],toNode:null,pointer:M};function H(){P=!0,g(C),v?.(e,{nodeId:s,handleId:o,handleType:T})}N===0&&H();function K(ee){if(!P){const{x:de,y:me}=dt(ee),xe=de-E,je=me-G;if(!(xe*xe+je*je>N*N))return;H()}if(!w()||!q){Q(ee);return}const ne=y();M=dt(ee,O),D=cb(_o(M,ne,!1,[1,1]),n,c,q),F||(Z(),F=!0);const ie=Wu(ee,{handle:D,connectionMode:t,fromNodeId:s,fromHandleId:o,fromType:a?"target":"source",isValidConnection:x,doc:z,lib:u,flowId:d,nodeLookup:c});Y=ie.handleDomNode,U=ie.connection,V=ub(!!D,ie.isValid);const re=c.get(s),J=re?ri(re,q,le.Left,!0):C.from,ce={...C,from:J,isValid:V,to:ie.toHandle&&V?bs({x:ie.toHandle.x,y:ie.toHandle.y},ne):M,toHandle:ie.toHandle,toPosition:V&&ie.toHandle?ie.toHandle.position:bl[q.position],toNode:ie.toHandle?c.get(ie.toHandle.nodeId):null,pointer:M};g(ce),C=ce}function Q(ee){if(!("touches"in ee&&ee.touches.length>0)){if(P){(D||Y)&&U&&V&&b?.(U);const{inProgress:ne,...ie}=C,re={...ie,toPosition:C.toHandle?C.toPosition:null};S?.(ee,re),r&&_?.(ee,re)}h(),cancelAnimationFrame(W),F=!1,V=!1,U=null,Y=null,z.removeEventListener("mousemove",K),z.removeEventListener("mouseup",Q),z.removeEventListener("touchmove",K),z.removeEventListener("touchend",Q)}}z.addEventListener("mousemove",K),z.addEventListener("mouseup",Q),z.addEventListener("touchmove",K),z.addEventListener("touchend",Q)}function Wu(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:s,fromType:r,doc:a,lib:l,flowId:c,isValidConnection:u=Hu,nodeLookup:f}){const d=r==="target",p=t?a.querySelector(`.${l}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:h,y:v}=dt(e),b=a.elementFromPoint(h,v),S=b?.classList.contains(`${l}-flow__handle`)?b:p,x={handleDomNode:S,isValid:!1,connection:null,toHandle:null};if(S){const _=Gu(void 0,S),g=S.getAttribute("data-nodeid"),y=S.getAttribute("data-handleid"),w=S.classList.contains("connectable"),j=S.classList.contains("connectableend");if(!g||!_)return x;const N={source:d?g:o,sourceHandle:d?y:s,target:d?o:g,targetHandle:d?s:y};x.connection=N;const z=w&&j&&(n===_i.Strict?d&&_==="source"||!d&&_==="target":g!==o||y!==s);x.isValid=z&&u(N),x.toHandle=$u(g,_,y,f,n,!0)}return x}const qr={onPointerDown:db,isValid:Wu};function fb({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const s=Ve(e);function r({translateExtent:l,width:c,height:u,zoomStep:f=1,pannable:d=!0,zoomable:p=!0,inversePan:h=!1}){const v=g=>{if(g.sourceEvent.type!=="wheel"||!t)return;const y=n(),w=g.sourceEvent.ctrlKey&&fo()?10:1,j=-g.sourceEvent.deltaY*(g.sourceEvent.deltaMode===1?.05:g.sourceEvent.deltaMode?1:.002)*f,N=y[2]*Math.pow(2,j*w);t.scaleTo(N)};let b=[0,0];const S=g=>{(g.sourceEvent.type==="mousedown"||g.sourceEvent.type==="touchstart")&&(b=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY])},x=g=>{const y=n();if(g.sourceEvent.type!=="mousemove"&&g.sourceEvent.type!=="touchmove"||!t)return;const w=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY],j=[w[0]-b[0],w[1]-b[1]];b=w;const N=o()*Math.max(y[2],Math.log(y[2]))*(h?-1:1),B={x:y[0]-j[0]*N,y:y[1]-j[1]*N},z=[[0,0],[c,u]];t.setViewportConstrained({x:B.x,y:B.y,zoom:y[2]},z,l)},_=xu().on("start",S).on("zoom",d?x:null).on("zoom.wheel",p?v:null);s.call(_,{})}function a(){s.on("zoom",null)}return{update:r,destroy:a,pointer:st}}const Ds=e=>({x:e.x,y:e.y,zoom:e.k}),ur=({x:e,y:t,zoom:n})=>Bs.translate(e,t).scale(n),gi=(e,t)=>e.target.closest(`.${t}`),Uu=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),pb=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,dr=(e,t=0,n=pb,o=()=>{})=>{const s=typeof t=="number"&&t>0;return s||o(),s?e.transition().duration(t).ease(n).on("end",o):e},Vu=e=>{const t=e.ctrlKey&&fo()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function hb({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:s,panOnScrollSpeed:r,zoomOnPinch:a,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:u}){return f=>{if(gi(f,t))return f.ctrlKey&&f.preventDefault(),!1;f.preventDefault(),f.stopImmediatePropagation();const d=n.property("__zoom").k||1;if(f.ctrlKey&&a){const S=st(f),x=Vu(f),_=d*Math.pow(2,x);o.scaleTo(n,_,S,f);return}const p=f.deltaMode===1?20:1;let h=s===ni.Vertical?0:f.deltaX*p,v=s===ni.Horizontal?0:f.deltaY*p;!fo()&&f.shiftKey&&s!==ni.Vertical&&(h=f.deltaY*p,v=0),o.translateBy(n,-(h/d)*r,-(v/d)*r,{internal:!0});const b=Ds(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(f,b),e.panScrollTimeout=setTimeout(()=>{u?.(f,b),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l?.(f,b))}}function mb({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,s){const r=o.type==="wheel",a=!t&&r&&!o.ctrlKey,l=gi(o,e);if(o.ctrlKey&&r&&l&&o.preventDefault(),a||l)return null;o.preventDefault(),n.call(this,o,s)}}function gb({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const s=Ds(o.transform);e.mouseButton=o.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=s,o.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(o.sourceEvent,s)}}function bb({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:s}){return r=>{e.usedRightMouseButton=!!(n&&Uu(t,e.mouseButton??0)),r.sourceEvent?.sync||o([r.transform.x,r.transform.y,r.transform.k]),s&&!r.sourceEvent?.internal&&s?.(r.sourceEvent,Ds(r.transform))}}function xb({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:s,onPaneContextMenu:r}){return a=>{if(!a.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,r&&Uu(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&r(a.sourceEvent),e.usedRightMouseButton=!1,o(!1),s)){const l=Ds(a.transform);e.prevViewport=l,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s?.(a.sourceEvent,l)},n?150:0)}}}function yb({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:o,panOnScroll:s,zoomOnDoubleClick:r,userSelectionActive:a,noWheelClassName:l,noPanClassName:c,lib:u,connectionInProgress:f}){return d=>{const p=e||t,h=n&&d.ctrlKey,v=d.type==="wheel";if(d.button===1&&d.type==="mousedown"&&(gi(d,`${u}-flow__node`)||gi(d,`${u}-flow__edge`)))return!0;if(!o&&!p&&!s&&!r&&!n||a||f&&!v||gi(d,l)&&v||gi(d,c)&&(!v||s&&v&&!e)||!n&&d.ctrlKey&&v)return!1;if(!n&&d.type==="touchstart"&&d.touches?.length>1)return d.preventDefault(),!1;if(!p&&!s&&!h&&v||!o&&(d.type==="mousedown"||d.type==="touchstart")||Array.isArray(o)&&!o.includes(d.button)&&d.type==="mousedown")return!1;const b=Array.isArray(o)&&o.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||v)&&b}}function vb({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:s,onPanZoom:r,onPanZoomStart:a,onPanZoomEnd:l,onDraggingChange:c}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},f=e.getBoundingClientRect(),d=xu().scaleExtent([t,n]).translateExtent(o),p=Ve(e).call(d);_({x:s.x,y:s.y,zoom:ji(s.zoom,t,n)},[[0,0],[f.width,f.height]],o);const h=p.on("wheel.zoom"),v=p.on("dblclick.zoom");d.wheelDelta(Vu);function b(D,E){return p?new Promise(G=>{d?.interpolate(E?.interpolate==="linear"?qi:ts).transform(dr(p,E?.duration,E?.ease,()=>G(!0)),D)}):Promise.resolve(!1)}function S({noWheelClassName:D,noPanClassName:E,onPaneContextMenu:G,userSelectionActive:T,panOnScroll:O,panOnDrag:P,panOnScrollMode:L,panOnScrollSpeed:M,preventScrolling:F,zoomOnPinch:U,zoomOnScroll:V,zoomOnDoubleClick:Y,zoomActivationKeyPressed:Z,lib:q,onTransformChange:X,connectionInProgress:A,paneClickDistance:C,selectionOnDrag:H}){T&&!u.isZoomingOrPanning&&x();const K=O&&!Z&&!T;d.clickDistance(H?1/0:!ut(C)||C<0?0:C);const Q=K?hb({zoomPanValues:u,noWheelClassName:D,d3Selection:p,d3Zoom:d,panOnScrollMode:L,panOnScrollSpeed:M,zoomOnPinch:U,onPanZoomStart:a,onPanZoom:r,onPanZoomEnd:l}):mb({noWheelClassName:D,preventScrolling:F,d3ZoomHandler:h});if(p.on("wheel.zoom",Q,{passive:!1}),!T){const ne=gb({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:a});d.on("start",ne);const ie=bb({zoomPanValues:u,panOnDrag:P,onPaneContextMenu:!!G,onPanZoom:r,onTransformChange:X});d.on("zoom",ie);const re=xb({zoomPanValues:u,panOnDrag:P,panOnScroll:O,onPaneContextMenu:G,onPanZoomEnd:l,onDraggingChange:c});d.on("end",re)}const ee=yb({zoomActivationKeyPressed:Z,panOnDrag:P,zoomOnScroll:V,panOnScroll:O,zoomOnDoubleClick:Y,zoomOnPinch:U,userSelectionActive:T,noPanClassName:E,noWheelClassName:D,lib:q,connectionInProgress:A});d.filter(ee),Y?p.on("dblclick.zoom",v):p.on("dblclick.zoom",null)}function x(){d.on("zoom",null)}async function _(D,E,G){const T=ur(D),O=d?.constrain()(T,E,G);return O&&await b(O),new Promise(P=>P(O))}async function g(D,E){const G=ur(D);return await b(G,E),new Promise(T=>T(G))}function y(D){if(p){const E=ur(D),G=p.property("__zoom");(G.k!==D.zoom||G.x!==D.x||G.y!==D.y)&&d?.transform(p,E,null,{sync:!0})}}function w(){const D=p?bu(p.node()):{x:0,y:0,k:1};return{x:D.x,y:D.y,zoom:D.k}}function j(D,E){return p?new Promise(G=>{d?.interpolate(E?.interpolate==="linear"?qi:ts).scaleTo(dr(p,E?.duration,E?.ease,()=>G(!0)),D)}):Promise.resolve(!1)}function N(D,E){return p?new Promise(G=>{d?.interpolate(E?.interpolate==="linear"?qi:ts).scaleBy(dr(p,E?.duration,E?.ease,()=>G(!0)),D)}):Promise.resolve(!1)}function B(D){d?.scaleExtent(D)}function z(D){d?.translateExtent(D)}function W(D){const E=!ut(D)||D<0?0:D;d?.clickDistance(E)}return{update:S,destroy:x,setViewport:g,setViewportConstrained:_,getViewport:w,scaleTo:j,scaleBy:N,setScaleExtent:B,setTranslateExtent:z,syncViewport:y,setClickDistance:W}}var Ni;(function(e){e.Line="line",e.Handle="handle"})(Ni||(Ni={}));function wb({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:s,affectsY:r}){const a=e-t,l=n-o,c=[a>0?1:a<0?-1:0,l>0?1:l<0?-1:0];return a&&s&&(c[0]=c[0]*-1),l&&r&&(c[1]=c[1]*-1),c}function El(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),o=e.includes("left"),s=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:o,affectsY:s}}function dn(e,t){return Math.max(0,t-e)}function fn(e,t){return Math.max(0,e-t)}function zo(e,t,n){return Math.max(0,t-e,e-n)}function Al(e,t){return e?!t:t}function Sb(e,t,n,o,s,r,a,l){let{affectsX:c,affectsY:u}=t;const{isHorizontal:f,isVertical:d}=t,p=f&&d,{xSnapped:h,ySnapped:v}=n,{minWidth:b,maxWidth:S,minHeight:x,maxHeight:_}=o,{x:g,y,width:w,height:j,aspectRatio:N}=e;let B=Math.floor(f?h-e.pointerX:0),z=Math.floor(d?v-e.pointerY:0);const W=w+(c?-B:B),D=j+(u?-z:z),E=-r[0]*w,G=-r[1]*j;let T=zo(W,b,S),O=zo(D,x,_);if(a){let M=0,F=0;c&&B<0?M=dn(g+B+E,a[0][0]):!c&&B>0&&(M=fn(g+W+E,a[1][0])),u&&z<0?F=dn(y+z+G,a[0][1]):!u&&z>0&&(F=fn(y+D+G,a[1][1])),T=Math.max(T,M),O=Math.max(O,F)}if(l){let M=0,F=0;c&&B>0?M=fn(g+B,l[0][0]):!c&&B<0&&(M=dn(g+W,l[1][0])),u&&z>0?F=fn(y+z,l[0][1]):!u&&z<0&&(F=dn(y+D,l[1][1])),T=Math.max(T,M),O=Math.max(O,F)}if(s){if(f){const M=zo(W/N,x,_)*N;if(T=Math.max(T,M),a){let F=0;!c&&!u||c&&!u&&p?F=fn(y+G+W/N,a[1][1])*N:F=dn(y+G+(c?B:-B)/N,a[0][1])*N,T=Math.max(T,F)}if(l){let F=0;!c&&!u||c&&!u&&p?F=dn(y+W/N,l[1][1])*N:F=fn(y+(c?B:-B)/N,l[0][1])*N,T=Math.max(T,F)}}if(d){const M=zo(D*N,b,S)/N;if(O=Math.max(O,M),a){let F=0;!c&&!u||u&&!c&&p?F=fn(g+D*N+E,a[1][0])/N:F=dn(g+(u?z:-z)*N+E,a[0][0])/N,O=Math.max(O,F)}if(l){let F=0;!c&&!u||u&&!c&&p?F=dn(g+D*N,l[1][0])/N:F=fn(g+(u?z:-z)*N,l[0][0])/N,O=Math.max(O,F)}}}z=z+(z<0?O:-O),B=B+(B<0?T:-T),s&&(p?W>D*N?z=(Al(c,u)?-B:B)/N:B=(Al(c,u)?-z:z)*N:f?(z=B/N,u=c):(B=z*N,c=u));const P=c?g+B:g,L=u?y+z:y;return{width:w+(c?-B:B),height:j+(u?-z:z),x:r[0]*B*(c?-1:1)+P,y:r[1]*z*(u?-1:1)+L}}const Yu={width:0,height:0,x:0,y:0},_b={...Yu,pointerX:0,pointerY:0,aspectRatio:1};function jb(e){return[[0,0],[e.measured.width,e.measured.height]]}function Mb(e,t,n){const o=t.position.x+e.position.x,s=t.position.y+e.position.y,r=e.measured.width??0,a=e.measured.height??0,l=n[0]*r,c=n[1]*a;return[[o-l,s-c],[o+r-l,s+a-c]]}function Cb({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:s}){const r=Ve(e);let a={controlDirection:El("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:u,boundaries:f,keepAspectRatio:d,resizeDirection:p,onResizeStart:h,onResize:v,onResizeEnd:b,shouldResize:S}){let x={...Yu},_={..._b};a={boundaries:f,resizeDirection:p,keepAspectRatio:d,controlDirection:El(u)};let g,y=null,w=[],j,N,B,z=!1;const W=iu().on("start",D=>{const{nodeLookup:E,transform:G,snapGrid:T,snapToGrid:O,nodeOrigin:P,paneDomNode:L}=n();if(g=E.get(t),!g)return;y=L?.getBoundingClientRect()??null;const{xSnapped:M,ySnapped:F}=Qi(D.sourceEvent,{transform:G,snapGrid:T,snapToGrid:O,containerBounds:y});x={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},_={...x,pointerX:M,pointerY:F,aspectRatio:x.width/x.height},j=void 0,g.parentId&&(g.extent==="parent"||g.expandParent)&&(j=E.get(g.parentId),N=j&&g.extent==="parent"?jb(j):void 0),w=[],B=void 0;for(const[U,V]of E)if(V.parentId===t&&(w.push({id:U,position:{...V.position},extent:V.extent}),V.extent==="parent"||V.expandParent)){const Y=Mb(V,g,V.origin??P);B?B=[[Math.min(Y[0][0],B[0][0]),Math.min(Y[0][1],B[0][1])],[Math.max(Y[1][0],B[1][0]),Math.max(Y[1][1],B[1][1])]]:B=Y}h?.(D,{...x})}).on("drag",D=>{const{transform:E,snapGrid:G,snapToGrid:T,nodeOrigin:O}=n(),P=Qi(D.sourceEvent,{transform:E,snapGrid:G,snapToGrid:T,containerBounds:y}),L=[];if(!g)return;const{x:M,y:F,width:U,height:V}=x,Y={},Z=g.origin??O,{width:q,height:X,x:A,y:C}=Sb(_,a.controlDirection,P,a.boundaries,a.keepAspectRatio,Z,N,B),H=q!==U,K=X!==V,Q=A!==M&&H,ee=C!==F&&K;if(!Q&&!ee&&!H&&!K)return;if((Q||ee||Z[0]===1||Z[1]===1)&&(Y.x=Q?A:x.x,Y.y=ee?C:x.y,x.x=Y.x,x.y=Y.y,w.length>0)){const J=A-M,ce=C-F;for(const de of w)de.position={x:de.position.x-J+Z[0]*(q-U),y:de.position.y-ce+Z[1]*(X-V)},L.push(de)}if((H||K)&&(Y.width=H&&(!a.resizeDirection||a.resizeDirection==="horizontal")?q:x.width,Y.height=K&&(!a.resizeDirection||a.resizeDirection==="vertical")?X:x.height,x.width=Y.width,x.height=Y.height),j&&g.expandParent){const J=Z[0]*(Y.width??0);Y.x&&Y.x<J&&(x.x=J,_.x=_.x-(Y.x-J));const ce=Z[1]*(Y.height??0);Y.y&&Y.y<ce&&(x.y=ce,_.y=_.y-(Y.y-ce))}const ne=wb({width:x.width,prevWidth:U,height:x.height,prevHeight:V,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),ie={...x,direction:ne};S?.(D,ie)!==!1&&(z=!0,v?.(D,ie),o(Y,L))}).on("end",D=>{z&&(b?.(D,{...x}),s?.({...x}),z=!1)});r.call(W)}function c(){r.on(".drag",null)}return{update:l,destroy:c}}const Fs=m.createContext(null),Nb=Fs.Provider,Zu=Et.error001();function he(e,t){const n=m.useContext(Fs);if(n===null)throw new Error(Zu);return kc.useStoreWithEqualityFn(n,e,t)}function _e(){const e=m.useContext(Fs);if(e===null)throw new Error(Zu);return m.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const kl={display:"none"},Tb={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Xu="react-flow__node-desc",Ku="react-flow__edge-desc",Ib="react-flow__aria-live",Eb=e=>e.ariaLiveMessage,Ab=e=>e.ariaLabelConfig;function kb({rfId:e}){const t=he(Eb);return i.jsx("div",{id:`${Ib}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Tb,children:t})}function Bb({rfId:e,disableKeyboardA11y:t}){const n=he(Ab);return i.jsxs(i.Fragment,{children:[i.jsx("div",{id:`${Xu}-${e}`,style:kl,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),i.jsx("div",{id:`${Ku}-${e}`,style:kl,children:n["edge.a11yDescription.default"]}),!t&&i.jsx(kb,{rfId:e})]})}const Ls=m.forwardRef(({position:e="top-left",children:t,className:n,style:o,...s},r)=>{const a=`${e}`.split("-");return i.jsx("div",{className:Ee(["react-flow__panel",n,...a]),style:o,ref:r,...s,children:t})});Ls.displayName="Panel";function Pb({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:i.jsx(Ls,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:i.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Rb=e=>{const t=[],n=[];for(const[,o]of e.nodeLookup)o.selected&&t.push(o.internals.userNode);for(const[,o]of e.edgeLookup)o.selected&&n.push(o);return{selectedNodes:t,selectedEdges:n}},Oo=e=>e.id;function Db(e,t){return Se.shallow(e.selectedNodes.map(Oo),t.selectedNodes.map(Oo))&&Se.shallow(e.selectedEdges.map(Oo),t.selectedEdges.map(Oo))}function Fb({onSelectionChange:e}){const t=_e(),{selectedNodes:n,selectedEdges:o}=he(Rb,Db);return m.useEffect(()=>{const s={nodes:n,edges:o};e?.(s),t.getState().onSelectionChangeHandlers.forEach(r=>r(s))},[n,o,e]),null}const Lb=e=>!!e.onSelectionChangeHandlers;function zb({onSelectionChange:e}){const t=he(Lb);return e||t?i.jsx(Fb,{onSelectionChange:e}):null}const Qr=typeof window<"u"?m.useLayoutEffect:m.useEffect,qu=[0,0],Ob={x:0,y:0,zoom:1},$b=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],Bl=[...$b,"rfId"],Gb=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),Pl={translateExtent:ao,nodeOrigin:qu,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Hb(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:s,setTranslateExtent:r,setNodeExtent:a,reset:l,setDefaultNodesAndEdges:c}=he(Gb,Se.shallow),u=_e();Qr(()=>(c(e.defaultNodes,e.defaultEdges),()=>{f.current=Pl,l()}),[]);const f=m.useRef(Pl);return Qr(()=>{for(const d of Bl){const p=e[d],h=f.current[d];p!==h&&(typeof e[d]>"u"||(d==="nodes"?t(p):d==="edges"?n(p):d==="minZoom"?o(p):d==="maxZoom"?s(p):d==="translateExtent"?r(p):d==="nodeExtent"?a(p):d==="ariaLabelConfig"?u.setState({ariaLabelConfig:L0(p)}):d==="fitView"?u.setState({fitViewQueued:p}):d==="fitViewOptions"?u.setState({fitViewOptions:p}):u.setState({[d]:p})))}f.current=e},Bl.map(d=>e[d])),null}function Rl(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Wb(e){const[t,n]=m.useState(e==="system"?null:e);return m.useEffect(()=>{if(e!=="system"){n(e);return}const o=Rl(),s=()=>n(o?.matches?"dark":"light");return s(),o?.addEventListener("change",s),()=>{o?.removeEventListener("change",s)}},[e]),t!==null?t:Rl()?.matches?"dark":"light"}const Dl=typeof document<"u"?document:null;function po(e=null,t={target:Dl,actInsideInputWithModifier:!0}){const[n,o]=m.useState(!1),s=m.useRef(!1),r=m.useRef(new Set([])),[a,l]=m.useMemo(()=>{if(e!==null){const u=(Array.isArray(e)?e:[e]).filter(d=>typeof d=="string").map(d=>d.replace("+",`
|
|
2
2
|
`).replace(`
|
|
3
3
|
|
|
4
4
|
`,`
|