diff --git a/CHANGELOG.md b/CHANGELOG.md index 2973fdd..785c85b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,90 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.8.0] - 2026-07-31 + +A full rebuild of the web canvas interface. A UI audit of all 15 frontend components found 45 +defects: 12 correctness, 11 accessibility, 6 responsive, 7 design-system, 9 content. This +release closes every one of them. No backend contract changes, so the CLI, the MCP server and +every API route behave exactly as in 1.7.0. + +### Added + +- **A design-token stylesheet and a dark theme.** `packages/web/frontend/src/styles.css` holds + every colour, space, radius, shadow and type step as a CSS custom property. `[data-theme="dark"]` + re-points the same tokens. The theme follows `prefers-color-scheme` until the user picks a side, + then keeps that choice in `localStorage`. Nothing downloads a web font, so the strict + Content-Security-Policy the server sends stays intact. +- **A responsive layout.** The frontend had zero media queries. It now has breakpoints at 1180px, + 900px and 620px. Below 900px the fixed 420px sidebar becomes a two-pane switch between Chat and + Workspace. The nine workspace tabs scroll sideways instead of clipping. The shell uses + `100dvh`, so the composer stays above the iOS URL bar. +- **The WAI-ARIA tabs pattern.** `role="tablist"`, `role="tab"`, `aria-selected`, `aria-controls`, + roving `tabindex`, and Arrow/Home/End keys. Each panel is a `role="tabpanel"` section. +- **Keyboard shortcuts and a skip link.** `Cmd/Ctrl+K` focuses the composer, `Cmd/Ctrl+1..9` picks + a tab, `Escape` closes the catalog drawer and the node panel. +- **A stop button.** An `AbortController` now cancels a running design or change. +- **Error toasts.** A polite live region surfaces the failures the old code swallowed. +- **OpenTofu, Pulumi TypeScript and Pulumi Python in the Export tab.** All three shipped in + `cloudwright.exporter.FORMATS` but had no button in the web UI. The tab now offers 13 formats in + three groups. +- **`scripts/ui_screenshots.py`.** It screenshots every tab at three widths in both themes against + the mock-LLM server, and `--readme` regenerates the exact `docs/screenshots/` filenames. +- **`packages/web/tests/test_static_bundle.py`.** Eight checks read the bundle in + `cloudwright_web/static/`. They confirm that the hashed assets match `index.html`, that the tokens + and the dark theme survive minification, that breakpoints exist, that the focus ring holds, and + that no em-dash reaches user copy. A frontend change that never reaches the wheel now fails CI. + +### Fixed + +- **A mid-stream error billed a second generation.** `streamSucceeded` only became true after the + stream loop returned, so an `error` event after the spec arrived left it false. The non-streaming + fallback then ran a second design call and its result replaced the first. The fallback now runs + only when the stream produced no spec. +- **Panel results no longer die on a tab switch.** Validation, compliance, plan and review results + lived in component state that unmounted whenever the user changed tab. Panels now mount on first + use and stay mounted. +- **The catalog drawer no longer covers the diagram on load.** It defaulted to open. +- **Silent failures now speak.** Diagram SVG/PNG export, module insertion, the standards check and + the spec download all returned on `!res.ok` with no message. +- **The YAML tab shows the server's YAML.** It rendered a hand-written client-side serialiser that + quoted nothing, so a value such as `no` or `2.0` read back as a boolean or a number. The panel now + asks the server for the authoritative YAML, and the local serialiser (still the offline fallback) + quotes anything that would change type. +- **Contrast.** 27 uses of `#94a3b8` (2.84:1 on white) and 2 of `#cbd5e1` (1.61:1) fell below the + WCAG 1.4.3 AA floor. Every token now clears 4.5:1 in both themes. +- **Focus visibility.** Four `outline: none` rules removed the focus ring with no replacement, which + fails WCAG 2.4.7. There is now one `:focus-visible` ring for the whole application. +- **The closed node panel left the tab order.** It stayed in the DOM at `translateX(100%)`, so + keyboard focus walked into inputs parked off-screen. It unmounts when closed. +- **The streaming indicator animates.** It referenced a `pulse` keyframe that no file defined. +- **An input method no longer submits mid-word.** Enter now checks `isComposing`, so confirming a + Japanese, Chinese or Korean candidate does not send the message. +- **A native `` replaces `window.confirm`.** Three destructive actions used the browser + dialog, which takes no styling and drops focus out of the page. +- **Error copy carries no em-dash.** `formatApiError` joined the message and the suggestion with + one. +- **The dead session write is gone.** The reset button wrote `cloudwright_last_session` to + `localStorage` and nothing ever read it. +- **The diagram fits its viewport.** `fitView` ran before the effect built any nodes, so the graph + rendered at default zoom in a corner. It now refits when the node set changes, and leaves a + hand-placed layout alone during a drag. +- **Diagram chrome stops overlapping.** The legend covered the React Flow zoom controls, and on a + phone the Add Resource button sat on top of the export toolbar. + +### Changed + +- **The 90-line duplicate of the send path is gone.** The `Modify` tab re-implemented streaming, + fallback, costing and error handling inline in a JSX prop. Both entry points now call one + `runTurn`. +- **Empty states name the next action.** Six panels said "Design an architecture first." and stopped. +- **The composer is a textarea.** It grows with its content, Enter sends, Shift+Enter adds a line. +- **Browser tests use stable selectors.** Two assertions matched on inline style strings + (`[style*="background: rgb(241, 245, 249)"]`), which a stylesheet removes. They now use + `data-testid`. Nine new browser tests cover the tab pattern, the theme, panel persistence and the + dialog. +- **Fresh screenshots and both web demo GIFs**, recorded against the new interface. + ## [1.7.0] - 2026-07-08 Closes the July 2026 product audit findings. The differentiating features (offline review, diff --git a/README.md b/README.md index 919c159..a6e1e63 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,25 @@ hcl = export_spec(spec, "terraform", output_dir="./infra") +## What's new in v1.8.0 + +The web canvas got a full interface rebuild. It has a dark theme, it works down to a phone, and it follows the WAI-ARIA tabs pattern. Twelve behaviour bugs went with it. One of them billed a second architecture generation after a mid-stream error. + +

+ Cloudwright web canvas: chat panel on the left, tabbed workspace with the boundary-aware diagram on the right +

+ +- **One stylesheet, one token set, and a dark theme.** Colour, spacing, radius and type come from CSS custom properties. The theme follows the operating system until you pick a side. Every text colour clears the 4.5:1 contrast floor. 29 sites did not. +- **It works on a phone.** The layout was a hard 420px sidebar and no media query anywhere. Below 900px it is now a two-pane switch. The nine tabs scroll instead of clipping. `100dvh` keeps the composer above the iOS URL bar. +- **Keyboard and screen reader.** The tab bar is a real `tablist` with arrow-key roving focus. Every control shows a focus ring. A live region announces design progress. `Cmd/Ctrl+K` focuses the composer and `Cmd/Ctrl+1..9` picks a tab. +- **A mid-stream error no longer bills twice.** The stream could fail after the spec arrived. The fallback then ran a second generation, and that architecture replaced the first. The retry now runs only when the stream gives nothing. +- **Panel results survive a tab switch.** Run a HIPAA scan, look at Cost, come back. The panel used to be empty. +- **Three more export formats.** OpenTofu, Pulumi TypeScript and Pulumi Python shipped in the exporter with no button. The Export tab now offers all thirteen, in groups. +- **Failures say so.** Diagram export, module insert, the standards check and the download failed silently. Each one now raises a toast with the server message. +- **The YAML tab shows the server YAML.** A client-side serialiser quoted nothing, so `region: no` read back as the boolean false. +- **The catalog drawer starts closed.** It opened over the diagram on every page load. +- **The composer is a textarea.** Shift+Enter adds a line. An input-method candidate no longer submits mid-word. You can stop a running generation. + ## What's new in v1.7.0 Cloudwright's design-time checks now reach every coding agent, not just its own CLI. Almost every popular AI coding harness speaks MCP, so one server puts `review`, `compliance`, and `plan` inside their agent loops. diff --git a/docs/getting-started.md b/docs/getting-started.md index f408ad7..ddd4090 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -200,7 +200,8 @@ pip install 'cloudwright-ai[web]' cloudwright chat --web ``` -Opens `http://localhost:8765`. The canvas lets you chat to design, drag and drop components, edit fields, add resources from the catalog drawer, and run Compliance and Plan checks in the UI. +Opens `http://localhost:8765`. Chat to design, then drag components, edit fields, and add +resources from the catalog drawer. Compliance, Plan, Review and Export all run in the UI. Use a different port: @@ -208,6 +209,33 @@ Use a different port: cloudwright chat --web --port 9000 ``` +### Nine workspace tabs + +`diagram`, `cost`, `validate`, `compliance`, `plan`, `review`, `export`, `spec`, `modify`. +Each tab keeps its own results. A tab switch never throws away a finished scan. + +### Keyboard + +| Keys | Action | +|---|---| +| `Cmd/Ctrl` + `K` | Focus the chat composer | +| `Cmd/Ctrl` + `1` to `9` | Open the tab at that position | +| `Enter` | Send the message | +| `Shift` + `Enter` | Add a line to the message | +| `Left` / `Right` / `Home` / `End` | Move across the tab bar, once a tab has focus | +| `Escape` | Close the catalog drawer, the node panel, or a dialog | + +### Theme + +The canvas follows your operating system light or dark setting. The moon or sun button in the +top left pins it, and the choice survives a reload. Every colour clears the WCAG AA 4.5:1 +contrast floor in both themes. + +### Small screens + +Below 900px wide the canvas splits into two panes, Chat and Workspace. A switch sits at the +bottom of each pane. The tab bar scrolls sideways. + --- ## Machine-readable output diff --git a/docs/screenshots/cloudwright-compliance-tab.png b/docs/screenshots/cloudwright-compliance-tab.png index 8403263..5ec0635 100644 Binary files a/docs/screenshots/cloudwright-compliance-tab.png and b/docs/screenshots/cloudwright-compliance-tab.png differ diff --git a/docs/screenshots/cloudwright-light-1-diagram.png b/docs/screenshots/cloudwright-light-1-diagram.png index 566e24a..dcf85b3 100644 Binary files a/docs/screenshots/cloudwright-light-1-diagram.png and b/docs/screenshots/cloudwright-light-1-diagram.png differ diff --git a/docs/screenshots/cloudwright-light-1-ecommerce.png b/docs/screenshots/cloudwright-light-1-ecommerce.png index c19ed63..dcf85b3 100644 Binary files a/docs/screenshots/cloudwright-light-1-ecommerce.png and b/docs/screenshots/cloudwright-light-1-ecommerce.png differ diff --git a/docs/screenshots/cloudwright-light-2-analytics.png b/docs/screenshots/cloudwright-light-2-analytics.png index 87eb618..88fc148 100644 Binary files a/docs/screenshots/cloudwright-light-2-analytics.png and b/docs/screenshots/cloudwright-light-2-analytics.png differ diff --git a/docs/screenshots/cloudwright-light-2-cost.png b/docs/screenshots/cloudwright-light-2-cost.png index 87eb618..88fc148 100644 Binary files a/docs/screenshots/cloudwright-light-2-cost.png and b/docs/screenshots/cloudwright-light-2-cost.png differ diff --git a/docs/screenshots/cloudwright-light-3-cost.png b/docs/screenshots/cloudwright-light-3-cost.png index 1e68502..88fc148 100644 Binary files a/docs/screenshots/cloudwright-light-3-cost.png and b/docs/screenshots/cloudwright-light-3-cost.png differ diff --git a/docs/screenshots/cloudwright-light-3-validate.png b/docs/screenshots/cloudwright-light-3-validate.png index 1e68502..da67c44 100644 Binary files a/docs/screenshots/cloudwright-light-3-validate.png and b/docs/screenshots/cloudwright-light-3-validate.png differ diff --git a/docs/screenshots/cloudwright-light-4-canvas.png b/docs/screenshots/cloudwright-light-4-canvas.png index 02030df..24fcc62 100644 Binary files a/docs/screenshots/cloudwright-light-4-canvas.png and b/docs/screenshots/cloudwright-light-4-canvas.png differ diff --git a/docs/screenshots/cloudwright-light-4-validate.png b/docs/screenshots/cloudwright-light-4-validate.png index f7d5954..da67c44 100644 Binary files a/docs/screenshots/cloudwright-light-4-validate.png and b/docs/screenshots/cloudwright-light-4-validate.png differ diff --git a/docs/screenshots/cloudwright-plan-tab.png b/docs/screenshots/cloudwright-plan-tab.png index 424d673..81c799c 100644 Binary files a/docs/screenshots/cloudwright-plan-tab.png and b/docs/screenshots/cloudwright-plan-tab.png differ diff --git a/examples/cloudwright-controls-web-demo.gif b/examples/cloudwright-controls-web-demo.gif index a6b0745..69b7d91 100644 Binary files a/examples/cloudwright-controls-web-demo.gif and b/examples/cloudwright-controls-web-demo.gif differ diff --git a/examples/cloudwright-smart-canvas-demo.gif b/examples/cloudwright-smart-canvas-demo.gif index 59ecb14..9f0d003 100644 Binary files a/examples/cloudwright-smart-canvas-demo.gif and b/examples/cloudwright-smart-canvas-demo.gif differ diff --git a/packages/cli/cloudwright_cli/__init__.py b/packages/cli/cloudwright_cli/__init__.py index 14d9d2f..29654ee 100644 --- a/packages/cli/cloudwright_cli/__init__.py +++ b/packages/cli/cloudwright_cli/__init__.py @@ -1 +1 @@ -__version__ = "1.7.0" +__version__ = "1.8.0" diff --git a/packages/core/cloudwright/__init__.py b/packages/core/cloudwright/__init__.py index 66c1376..dbd53a0 100644 --- a/packages/core/cloudwright/__init__.py +++ b/packages/core/cloudwright/__init__.py @@ -17,7 +17,7 @@ ValidationResult, ) -__version__ = "1.7.0" +__version__ = "1.8.0" __all__ = [ "Alternative", diff --git a/packages/core/pyproject.toml b/packages/core/pyproject.toml index 5d58573..bdbb106 100644 --- a/packages/core/pyproject.toml +++ b/packages/core/pyproject.toml @@ -29,10 +29,10 @@ dependencies = [ ] [project.optional-dependencies] -cli = ["cloudwright-ai-cli==1.7.0"] -web = ["cloudwright-ai-cli==1.7.0", "cloudwright-ai-web==1.7.0"] -mcp = ["cloudwright-ai-mcp==1.7.0"] -all = ["cloudwright-ai-cli==1.7.0", "cloudwright-ai-web==1.7.0", "cloudwright-ai-mcp==1.7.0", "databricks-sdk>=0.38.0"] +cli = ["cloudwright-ai-cli==1.8.0"] +web = ["cloudwright-ai-cli==1.8.0", "cloudwright-ai-web==1.8.0"] +mcp = ["cloudwright-ai-mcp==1.8.0"] +all = ["cloudwright-ai-cli==1.8.0", "cloudwright-ai-web==1.8.0", "cloudwright-ai-mcp==1.8.0", "databricks-sdk>=0.38.0"] pdf = ["weasyprint", "markdown2"] databricks = ["databricks-sdk>=0.38.0"] live-import = [ diff --git a/packages/mcp/cloudwright_mcp/__init__.py b/packages/mcp/cloudwright_mcp/__init__.py index 14d9d2f..29654ee 100644 --- a/packages/mcp/cloudwright_mcp/__init__.py +++ b/packages/mcp/cloudwright_mcp/__init__.py @@ -1 +1 @@ -__version__ = "1.7.0" +__version__ = "1.8.0" diff --git a/packages/web/cloudwright_web/__init__.py b/packages/web/cloudwright_web/__init__.py index fc068cd..ea8ac15 100644 --- a/packages/web/cloudwright_web/__init__.py +++ b/packages/web/cloudwright_web/__init__.py @@ -1,6 +1,6 @@ """Cloudwright Web — FastAPI backend for architecture intelligence.""" -__version__ = "1.7.0" +__version__ = "1.8.0" def __getattr__(name: str): diff --git a/packages/web/cloudwright_web/static/assets/index-B1XNG5bU.js b/packages/web/cloudwright_web/static/assets/index-B1XNG5bU.js deleted file mode 100644 index 61038d0..0000000 --- a/packages/web/cloudwright_web/static/assets/index-B1XNG5bU.js +++ /dev/null @@ -1,71 +0,0 @@ -(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const s of i.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function n(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(o){if(o.ep)return;o.ep=!0;const i=n(o);fetch(o.href,i)}})();function rp(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var op={exports:{}},Ns={},ip={exports:{}},te={};/** - * @license React - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Oo=Symbol.for("react.element"),py=Symbol.for("react.portal"),hy=Symbol.for("react.fragment"),gy=Symbol.for("react.strict_mode"),my=Symbol.for("react.profiler"),yy=Symbol.for("react.provider"),xy=Symbol.for("react.context"),vy=Symbol.for("react.forward_ref"),wy=Symbol.for("react.suspense"),Sy=Symbol.for("react.memo"),ky=Symbol.for("react.lazy"),zc=Symbol.iterator;function _y(e){return e===null||typeof e!="object"?null:(e=zc&&e[zc]||e["@@iterator"],typeof e=="function"?e:null)}var sp={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},lp=Object.assign,ap={};function Er(e,t,n){this.props=e,this.context=t,this.refs=ap,this.updater=n||sp}Er.prototype.isReactComponent={};Er.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};Er.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function up(){}up.prototype=Er.prototype;function au(e,t,n){this.props=e,this.context=t,this.refs=ap,this.updater=n||sp}var uu=au.prototype=new up;uu.constructor=au;lp(uu,Er.prototype);uu.isPureReactComponent=!0;var Tc=Array.isArray,cp=Object.prototype.hasOwnProperty,cu={current:null},dp={key:!0,ref:!0,__self:!0,__source:!0};function fp(e,t,n){var r,o={},i=null,s=null;if(t!=null)for(r in t.ref!==void 0&&(s=t.ref),t.key!==void 0&&(i=""+t.key),t)cp.call(t,r)&&!dp.hasOwnProperty(r)&&(o[r]=t[r]);var l=arguments.length-2;if(l===1)o.children=n;else if(1>>1,B=j[O];if(0>>1;Oo(Y,$))Xo(Q,Y)?(j[O]=Q,j[X]=$,O=X):(j[O]=Y,j[V]=$,O=V);else if(Xo(Q,$))j[O]=Q,j[X]=$,O=X;else break e}}return N}function o(j,N){var $=j.sortIndex-N.sortIndex;return $!==0?$:j.id-N.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var s=Date,l=s.now();e.unstable_now=function(){return s.now()-l}}var a=[],u=[],p=1,c=null,f=3,x=!1,y=!1,v=!1,k=typeof setTimeout=="function"?setTimeout:null,m=typeof clearTimeout=="function"?clearTimeout:null,g=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function h(j){for(var N=n(u);N!==null;){if(N.callback===null)r(u);else if(N.startTime<=j)r(u),N.sortIndex=N.expirationTime,t(a,N);else break;N=n(u)}}function w(j){if(v=!1,h(j),!y)if(n(a)!==null)y=!0,z(_);else{var N=n(u);N!==null&&R(w,N.startTime-j)}}function _(j,N){y=!1,v&&(v=!1,m(E),E=-1),x=!0;var $=f;try{for(h(N),c=n(a);c!==null&&(!(c.expirationTime>N)||j&&!P());){var O=c.callback;if(typeof O=="function"){c.callback=null,f=c.priorityLevel;var B=O(c.expirationTime<=N);N=e.unstable_now(),typeof B=="function"?c.callback=B:c===n(a)&&r(a),h(N)}else r(a);c=n(a)}if(c!==null)var W=!0;else{var V=n(u);V!==null&&R(w,V.startTime-N),W=!1}return W}finally{c=null,f=$,x=!1}}var S=!1,b=null,E=-1,A=5,D=-1;function P(){return!(e.unstable_now()-Dj||125O?(j.sortIndex=$,t(u,j),n(a)===null&&j===n(u)&&(v?(m(E),E=-1):v=!0,R(w,$-O))):(j.sortIndex=B,t(a,j),y||x||(y=!0,z(_))),j},e.unstable_shouldYield=P,e.unstable_wrapCallback=function(j){var N=f;return function(){var $=f;f=N;try{return j.apply(this,arguments)}finally{f=$}}}})(xp);yp.exports=xp;var Ry=yp.exports;/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Ly=M,Qe=Ry;function F(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ql=Object.prototype.hasOwnProperty,Ay=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,Ic={},Rc={};function $y(e){return ql.call(Rc,e)?!0:ql.call(Ic,e)?!1:Ay.test(e)?Rc[e]=!0:(Ic[e]=!0,!1)}function Dy(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Oy(e,t,n,r){if(t===null||typeof t>"u"||Dy(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Ae(e,t,n,r,o,i,s){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=o,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=s}var je={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){je[e]=new Ae(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];je[t]=new Ae(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){je[e]=new Ae(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){je[e]=new Ae(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){je[e]=new Ae(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){je[e]=new Ae(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){je[e]=new Ae(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){je[e]=new Ae(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){je[e]=new Ae(e,5,!1,e.toLowerCase(),null,!1,!1)});var fu=/[\-:]([a-z])/g;function pu(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(fu,pu);je[t]=new Ae(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(fu,pu);je[t]=new Ae(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(fu,pu);je[t]=new Ae(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){je[e]=new Ae(e,1,!1,e.toLowerCase(),null,!1,!1)});je.xlinkHref=new Ae("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){je[e]=new Ae(e,1,!1,e.toLowerCase(),null,!0,!0)});function hu(e,t,n,r){var o=je.hasOwnProperty(t)?je[t]:null;(o!==null?o.type!==0:r||!(2l||o[s]!==i[l]){var a=` -`+o[s].replace(" at new "," at ");return e.displayName&&a.includes("")&&(a=a.replace("",e.displayName)),a}while(1<=s&&0<=l);break}}}finally{al=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Qr(e):""}function By(e){switch(e.tag){case 5:return Qr(e.type);case 16:return Qr("Lazy");case 13:return Qr("Suspense");case 19:return Qr("SuspenseList");case 0:case 2:case 15:return e=ul(e.type,!1),e;case 11:return e=ul(e.type.render,!1),e;case 1:return e=ul(e.type,!0),e;default:return""}}function na(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Wn:return"Fragment";case Vn:return"Portal";case Jl:return"Profiler";case gu:return"StrictMode";case ea:return"Suspense";case ta:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Sp:return(e.displayName||"Context")+".Consumer";case wp:return(e._context.displayName||"Context")+".Provider";case mu:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case yu:return t=e.displayName||null,t!==null?t:na(e.type)||"Memo";case Xt:t=e._payload,e=e._init;try{return na(e(t))}catch{}}return null}function Fy(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return na(t);case 8:return t===gu?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function cn(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function _p(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Hy(e){var t=_p(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var o=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return o.call(this)},set:function(s){r=""+s,i.call(this,s)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(s){r=""+s},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function ei(e){e._valueTracker||(e._valueTracker=Hy(e))}function bp(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=_p(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Xi(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function ra(e,t){var n=t.checked;return me({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Ac(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=cn(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Cp(e,t){t=t.checked,t!=null&&hu(e,"checked",t,!1)}function oa(e,t){Cp(e,t);var n=cn(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?ia(e,t.type,n):t.hasOwnProperty("defaultValue")&&ia(e,t.type,cn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function $c(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function ia(e,t,n){(t!=="number"||Xi(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Gr=Array.isArray;function rr(e,t,n,r){if(e=e.options,t){t={};for(var o=0;o"+t.valueOf().toString()+"",t=ti.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function po(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var eo={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Vy=["Webkit","ms","Moz","O"];Object.keys(eo).forEach(function(e){Vy.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),eo[t]=eo[e]})});function Mp(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||eo.hasOwnProperty(e)&&eo[e]?(""+t).trim():t+"px"}function zp(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,o=Mp(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,o):e[n]=o}}var Wy=me({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function aa(e,t){if(t){if(Wy[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(F(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(F(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(F(61))}if(t.style!=null&&typeof t.style!="object")throw Error(F(62))}}function ua(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var ca=null;function xu(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var da=null,or=null,ir=null;function Bc(e){if(e=Ho(e)){if(typeof da!="function")throw Error(F(280));var t=e.stateNode;t&&(t=Is(t),da(e.stateNode,e.type,t))}}function Tp(e){or?ir?ir.push(e):ir=[e]:or=e}function Pp(){if(or){var e=or,t=ir;if(ir=or=null,Bc(e),t)for(e=0;e>>=0,e===0?32:31-(tx(e)/nx|0)|0}var ni=64,ri=4194304;function Kr(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Zi(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,o=e.suspendedLanes,i=e.pingedLanes,s=n&268435455;if(s!==0){var l=s&~o;l!==0?r=Kr(l):(i&=s,i!==0&&(r=Kr(i)))}else s=n&~o,s!==0?r=Kr(s):i!==0&&(r=Kr(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&o)&&(o=r&-r,i=t&-t,o>=i||o===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function Bo(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-ft(t),e[t]=n}function sx(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=no),Gc=" ",Kc=!1;function qp(e,t){switch(e){case"keyup":return Rx.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Jp(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Un=!1;function Ax(e,t){switch(e){case"compositionend":return Jp(t);case"keypress":return t.which!==32?null:(Kc=!0,Gc);case"textInput":return e=t.data,e===Gc&&Kc?null:e;default:return null}}function $x(e,t){if(Un)return e==="compositionend"||!Eu&&qp(e,t)?(e=Kp(),Ii=_u=qt=null,Un=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=ed(n)}}function rh(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?rh(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function oh(){for(var e=window,t=Xi();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Xi(e.document)}return t}function ju(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Yx(e){var t=oh(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&rh(n.ownerDocument.documentElement,n)){if(r!==null&&ju(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var o=n.textContent.length,i=Math.min(r.start,o);r=r.end===void 0?i:Math.min(r.end,o),!e.extend&&i>r&&(o=r,r=i,i=o),o=td(n,i);var s=td(n,r);o&&s&&(e.rangeCount!==1||e.anchorNode!==o.node||e.anchorOffset!==o.offset||e.focusNode!==s.node||e.focusOffset!==s.offset)&&(t=t.createRange(),t.setStart(o.node,o.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(s.node,s.offset)):(t.setEnd(s.node,s.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,Yn=null,ya=null,oo=null,xa=!1;function nd(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;xa||Yn==null||Yn!==Xi(r)||(r=Yn,"selectionStart"in r&&ju(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),oo&&vo(oo,r)||(oo=r,r=es(ya,"onSelect"),0Gn||(e.current=ba[Gn],ba[Gn]=null,Gn--)}function ae(e,t){Gn++,ba[Gn]=e.current,e.current=t}var dn={},Pe=pn(dn),Be=pn(!1),jn=dn;function fr(e,t){var n=e.type.contextTypes;if(!n)return dn;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var o={},i;for(i in n)o[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=o),o}function Fe(e){return e=e.childContextTypes,e!=null}function ns(){ce(Be),ce(Pe)}function ud(e,t,n){if(Pe.current!==dn)throw Error(F(168));ae(Pe,t),ae(Be,n)}function ph(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var o in r)if(!(o in t))throw Error(F(108,Fy(e)||"Unknown",o));return me({},n,r)}function rs(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||dn,jn=Pe.current,ae(Pe,e),ae(Be,Be.current),!0}function cd(e,t,n){var r=e.stateNode;if(!r)throw Error(F(169));n?(e=ph(e,t,jn),r.__reactInternalMemoizedMergedChildContext=e,ce(Be),ce(Pe),ae(Pe,e)):ce(Be),ae(Be,n)}var Tt=null,Rs=!1,_l=!1;function hh(e){Tt===null?Tt=[e]:Tt.push(e)}function o1(e){Rs=!0,hh(e)}function hn(){if(!_l&&Tt!==null){_l=!0;var e=0,t=se;try{var n=Tt;for(se=1;e>=s,o-=s,Pt=1<<32-ft(t)+o|n<E?(A=b,b=null):A=b.sibling;var D=f(m,b,h[E],w);if(D===null){b===null&&(b=A);break}e&&b&&D.alternate===null&&t(m,b),g=i(D,g,E),S===null?_=D:S.sibling=D,S=D,b=A}if(E===h.length)return n(m,b),de&&mn(m,E),_;if(b===null){for(;EE?(A=b,b=null):A=b.sibling;var P=f(m,b,D.value,w);if(P===null){b===null&&(b=A);break}e&&b&&P.alternate===null&&t(m,b),g=i(P,g,E),S===null?_=P:S.sibling=P,S=P,b=A}if(D.done)return n(m,b),de&&mn(m,E),_;if(b===null){for(;!D.done;E++,D=h.next())D=c(m,D.value,w),D!==null&&(g=i(D,g,E),S===null?_=D:S.sibling=D,S=D);return de&&mn(m,E),_}for(b=r(m,b);!D.done;E++,D=h.next())D=x(b,m,E,D.value,w),D!==null&&(e&&D.alternate!==null&&b.delete(D.key===null?E:D.key),g=i(D,g,E),S===null?_=D:S.sibling=D,S=D);return e&&b.forEach(function(I){return t(m,I)}),de&&mn(m,E),_}function k(m,g,h,w){if(typeof h=="object"&&h!==null&&h.type===Wn&&h.key===null&&(h=h.props.children),typeof h=="object"&&h!==null){switch(h.$$typeof){case Jo:e:{for(var _=h.key,S=g;S!==null;){if(S.key===_){if(_=h.type,_===Wn){if(S.tag===7){n(m,S.sibling),g=o(S,h.props.children),g.return=m,m=g;break e}}else if(S.elementType===_||typeof _=="object"&&_!==null&&_.$$typeof===Xt&&pd(_)===S.type){n(m,S.sibling),g=o(S,h.props),g.ref=Or(m,S,h),g.return=m,m=g;break e}n(m,S);break}else t(m,S);S=S.sibling}h.type===Wn?(g=bn(h.props.children,m.mode,w,h.key),g.return=m,m=g):(w=Fi(h.type,h.key,h.props,null,m.mode,w),w.ref=Or(m,g,h),w.return=m,m=w)}return s(m);case Vn:e:{for(S=h.key;g!==null;){if(g.key===S)if(g.tag===4&&g.stateNode.containerInfo===h.containerInfo&&g.stateNode.implementation===h.implementation){n(m,g.sibling),g=o(g,h.children||[]),g.return=m,m=g;break e}else{n(m,g);break}else t(m,g);g=g.sibling}g=Tl(h,m.mode,w),g.return=m,m=g}return s(m);case Xt:return S=h._init,k(m,g,S(h._payload),w)}if(Gr(h))return y(m,g,h,w);if(Rr(h))return v(m,g,h,w);ci(m,h)}return typeof h=="string"&&h!==""||typeof h=="number"?(h=""+h,g!==null&&g.tag===6?(n(m,g.sibling),g=o(g,h),g.return=m,m=g):(n(m,g),g=zl(h,m.mode,w),g.return=m,m=g),s(m)):n(m,g)}return k}var hr=xh(!0),vh=xh(!1),ss=pn(null),ls=null,qn=null,Tu=null;function Pu(){Tu=qn=ls=null}function Iu(e){var t=ss.current;ce(ss),e._currentValue=t}function ja(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function lr(e,t){ls=e,Tu=qn=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(De=!0),e.firstContext=null)}function nt(e){var t=e._currentValue;if(Tu!==e)if(e={context:e,memoizedValue:t,next:null},qn===null){if(ls===null)throw Error(F(308));qn=e,ls.dependencies={lanes:0,firstContext:e}}else qn=qn.next=e;return t}var wn=null;function Ru(e){wn===null?wn=[e]:wn.push(e)}function wh(e,t,n,r){var o=t.interleaved;return o===null?(n.next=n,Ru(t)):(n.next=o.next,o.next=n),t.interleaved=n,Dt(e,r)}function Dt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Qt=!1;function Lu(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Sh(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Lt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function on(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,oe&2){var o=r.pending;return o===null?t.next=t:(t.next=o.next,o.next=t),r.pending=t,Dt(e,n)}return o=r.interleaved,o===null?(t.next=t,Ru(r)):(t.next=o.next,o.next=t),r.interleaved=t,Dt(e,n)}function Li(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,wu(e,n)}}function hd(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var o=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var s={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?o=i=s:i=i.next=s,n=n.next}while(n!==null);i===null?o=i=t:i=i.next=t}else o=i=t;n={baseState:r.baseState,firstBaseUpdate:o,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function as(e,t,n,r){var o=e.updateQueue;Qt=!1;var i=o.firstBaseUpdate,s=o.lastBaseUpdate,l=o.shared.pending;if(l!==null){o.shared.pending=null;var a=l,u=a.next;a.next=null,s===null?i=u:s.next=u,s=a;var p=e.alternate;p!==null&&(p=p.updateQueue,l=p.lastBaseUpdate,l!==s&&(l===null?p.firstBaseUpdate=u:l.next=u,p.lastBaseUpdate=a))}if(i!==null){var c=o.baseState;s=0,p=u=a=null,l=i;do{var f=l.lane,x=l.eventTime;if((r&f)===f){p!==null&&(p=p.next={eventTime:x,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var y=e,v=l;switch(f=t,x=n,v.tag){case 1:if(y=v.payload,typeof y=="function"){c=y.call(x,c,f);break e}c=y;break e;case 3:y.flags=y.flags&-65537|128;case 0:if(y=v.payload,f=typeof y=="function"?y.call(x,c,f):y,f==null)break e;c=me({},c,f);break e;case 2:Qt=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,f=o.effects,f===null?o.effects=[l]:f.push(l))}else x={eventTime:x,lane:f,tag:l.tag,payload:l.payload,callback:l.callback,next:null},p===null?(u=p=x,a=c):p=p.next=x,s|=f;if(l=l.next,l===null){if(l=o.shared.pending,l===null)break;f=l,l=f.next,f.next=null,o.lastBaseUpdate=f,o.shared.pending=null}}while(!0);if(p===null&&(a=c),o.baseState=a,o.firstBaseUpdate=u,o.lastBaseUpdate=p,t=o.shared.interleaved,t!==null){o=t;do s|=o.lane,o=o.next;while(o!==t)}else i===null&&(o.shared.lanes=0);zn|=s,e.lanes=s,e.memoizedState=c}}function gd(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=Cl.transition;Cl.transition={};try{e(!1),t()}finally{se=n,Cl.transition=r}}function Dh(){return rt().memoizedState}function a1(e,t,n){var r=ln(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Oh(e))Bh(t,n);else if(n=wh(e,t,n,r),n!==null){var o=Re();pt(n,e,r,o),Fh(n,t,r)}}function u1(e,t,n){var r=ln(e),o={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Oh(e))Bh(t,o);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var s=t.lastRenderedState,l=i(s,n);if(o.hasEagerState=!0,o.eagerState=l,ht(l,s)){var a=t.interleaved;a===null?(o.next=o,Ru(t)):(o.next=a.next,a.next=o),t.interleaved=o;return}}catch{}finally{}n=wh(e,t,o,r),n!==null&&(o=Re(),pt(n,e,r,o),Fh(n,t,r))}}function Oh(e){var t=e.alternate;return e===ge||t!==null&&t===ge}function Bh(e,t){io=cs=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Fh(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,wu(e,n)}}var ds={readContext:nt,useCallback:Me,useContext:Me,useEffect:Me,useImperativeHandle:Me,useInsertionEffect:Me,useLayoutEffect:Me,useMemo:Me,useReducer:Me,useRef:Me,useState:Me,useDebugValue:Me,useDeferredValue:Me,useTransition:Me,useMutableSource:Me,useSyncExternalStore:Me,useId:Me,unstable_isNewReconciler:!1},c1={readContext:nt,useCallback:function(e,t){return wt().memoizedState=[e,t===void 0?null:t],e},useContext:nt,useEffect:yd,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,$i(4194308,4,Ih.bind(null,t,e),n)},useLayoutEffect:function(e,t){return $i(4194308,4,e,t)},useInsertionEffect:function(e,t){return $i(4,2,e,t)},useMemo:function(e,t){var n=wt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=wt();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=a1.bind(null,ge,e),[r.memoizedState,e]},useRef:function(e){var t=wt();return e={current:e},t.memoizedState=e},useState:md,useDebugValue:Vu,useDeferredValue:function(e){return wt().memoizedState=e},useTransition:function(){var e=md(!1),t=e[0];return e=l1.bind(null,e[1]),wt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=ge,o=wt();if(de){if(n===void 0)throw Error(F(407));n=n()}else{if(n=t(),be===null)throw Error(F(349));Mn&30||Ch(r,t,n)}o.memoizedState=n;var i={value:n,getSnapshot:t};return o.queue=i,yd(jh.bind(null,r,i,e),[e]),r.flags|=2048,jo(9,Eh.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=wt(),t=be.identifierPrefix;if(de){var n=It,r=Pt;n=(r&~(1<<32-ft(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Co++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=s.createElement(n,{is:r.is}):(e=s.createElement(n),n==="select"&&(s=e,r.multiple?s.multiple=!0:r.size&&(s.size=r.size))):e=s.createElementNS(e,n),e[kt]=t,e[ko]=r,Zh(e,t,!1,!1),t.stateNode=e;e:{switch(s=ua(n,r),n){case"dialog":ue("cancel",e),ue("close",e),o=r;break;case"iframe":case"object":case"embed":ue("load",e),o=r;break;case"video":case"audio":for(o=0;oyr&&(t.flags|=128,r=!0,Br(i,!1),t.lanes=4194304)}else{if(!r)if(e=us(s),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Br(i,!0),i.tail===null&&i.tailMode==="hidden"&&!s.alternate&&!de)return ze(t),null}else 2*xe()-i.renderingStartTime>yr&&n!==1073741824&&(t.flags|=128,r=!0,Br(i,!1),t.lanes=4194304);i.isBackwards?(s.sibling=t.child,t.child=s):(n=i.last,n!==null?n.sibling=s:t.child=s,i.last=s)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=xe(),t.sibling=null,n=he.current,ae(he,r?n&1|2:n&1),t):(ze(t),null);case 22:case 23:return Gu(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?We&1073741824&&(ze(t),t.subtreeFlags&6&&(t.flags|=8192)):ze(t),null;case 24:return null;case 25:return null}throw Error(F(156,t.tag))}function x1(e,t){switch(Mu(t),t.tag){case 1:return Fe(t.type)&&ns(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return gr(),ce(Be),ce(Pe),Du(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return $u(t),null;case 13:if(ce(he),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(F(340));pr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ce(he),null;case 4:return gr(),null;case 10:return Iu(t.type._context),null;case 22:case 23:return Gu(),null;case 24:return null;default:return null}}var fi=!1,Te=!1,v1=typeof WeakSet=="function"?WeakSet:Set,U=null;function Jn(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ye(e,t,r)}else n.current=null}function Aa(e,t,n){try{n()}catch(r){ye(e,t,r)}}var Nd=!1;function w1(e,t){if(va=qi,e=oh(),ju(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var o=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var s=0,l=-1,a=-1,u=0,p=0,c=e,f=null;t:for(;;){for(var x;c!==n||o!==0&&c.nodeType!==3||(l=s+o),c!==i||r!==0&&c.nodeType!==3||(a=s+r),c.nodeType===3&&(s+=c.nodeValue.length),(x=c.firstChild)!==null;)f=c,c=x;for(;;){if(c===e)break t;if(f===n&&++u===o&&(l=s),f===i&&++p===r&&(a=s),(x=c.nextSibling)!==null)break;c=f,f=c.parentNode}c=x}n=l===-1||a===-1?null:{start:l,end:a}}else n=null}n=n||{start:0,end:0}}else n=null;for(wa={focusedElem:e,selectionRange:n},qi=!1,U=t;U!==null;)if(t=U,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,U=e;else for(;U!==null;){t=U;try{var y=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(y!==null){var v=y.memoizedProps,k=y.memoizedState,m=t.stateNode,g=m.getSnapshotBeforeUpdate(t.elementType===t.type?v:it(t.type,v),k);m.__reactInternalSnapshotBeforeUpdate=g}break;case 3:var h=t.stateNode.containerInfo;h.nodeType===1?h.textContent="":h.nodeType===9&&h.documentElement&&h.removeChild(h.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(F(163))}}catch(w){ye(t,t.return,w)}if(e=t.sibling,e!==null){e.return=t.return,U=e;break}U=t.return}return y=Nd,Nd=!1,y}function so(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var o=r=r.next;do{if((o.tag&e)===e){var i=o.destroy;o.destroy=void 0,i!==void 0&&Aa(t,n,i)}o=o.next}while(o!==r)}}function $s(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function $a(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function eg(e){var t=e.alternate;t!==null&&(e.alternate=null,eg(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[kt],delete t[ko],delete t[_a],delete t[n1],delete t[r1])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function tg(e){return e.tag===5||e.tag===3||e.tag===4}function Md(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||tg(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Da(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=ts));else if(r!==4&&(e=e.child,e!==null))for(Da(e,t,n),e=e.sibling;e!==null;)Da(e,t,n),e=e.sibling}function Oa(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Oa(e,t,n),e=e.sibling;e!==null;)Oa(e,t,n),e=e.sibling}var Ce=null,st=!1;function Wt(e,t,n){for(n=n.child;n!==null;)ng(e,t,n),n=n.sibling}function ng(e,t,n){if(_t&&typeof _t.onCommitFiberUnmount=="function")try{_t.onCommitFiberUnmount(Ms,n)}catch{}switch(n.tag){case 5:Te||Jn(n,t);case 6:var r=Ce,o=st;Ce=null,Wt(e,t,n),Ce=r,st=o,Ce!==null&&(st?(e=Ce,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Ce.removeChild(n.stateNode));break;case 18:Ce!==null&&(st?(e=Ce,n=n.stateNode,e.nodeType===8?kl(e.parentNode,n):e.nodeType===1&&kl(e,n),yo(e)):kl(Ce,n.stateNode));break;case 4:r=Ce,o=st,Ce=n.stateNode.containerInfo,st=!0,Wt(e,t,n),Ce=r,st=o;break;case 0:case 11:case 14:case 15:if(!Te&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){o=r=r.next;do{var i=o,s=i.destroy;i=i.tag,s!==void 0&&(i&2||i&4)&&Aa(n,t,s),o=o.next}while(o!==r)}Wt(e,t,n);break;case 1:if(!Te&&(Jn(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){ye(n,t,l)}Wt(e,t,n);break;case 21:Wt(e,t,n);break;case 22:n.mode&1?(Te=(r=Te)||n.memoizedState!==null,Wt(e,t,n),Te=r):Wt(e,t,n);break;default:Wt(e,t,n)}}function zd(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new v1),t.forEach(function(r){var o=M1.bind(null,e,r);n.has(r)||(n.add(r),r.then(o,o))})}}function ot(e,t){var n=t.deletions;if(n!==null)for(var r=0;ro&&(o=s),r&=~i}if(r=o,r=xe()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*k1(r/1960))-r,10e?16:e,Jt===null)var r=!1;else{if(e=Jt,Jt=null,hs=0,oe&6)throw Error(F(331));var o=oe;for(oe|=4,U=e.current;U!==null;){var i=U,s=i.child;if(U.flags&16){var l=i.deletions;if(l!==null){for(var a=0;axe()-Xu?_n(e,0):Yu|=n),He(e,t)}function cg(e,t){t===0&&(e.mode&1?(t=ri,ri<<=1,!(ri&130023424)&&(ri=4194304)):t=1);var n=Re();e=Dt(e,t),e!==null&&(Bo(e,t,n),He(e,n))}function N1(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),cg(e,n)}function M1(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,o=e.memoizedState;o!==null&&(n=o.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(F(314))}r!==null&&r.delete(t),cg(e,n)}var dg;dg=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Be.current)De=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return De=!1,m1(e,t,n);De=!!(e.flags&131072)}else De=!1,de&&t.flags&1048576&&gh(t,is,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Di(e,t),e=t.pendingProps;var o=fr(t,Pe.current);lr(t,n),o=Bu(null,t,r,e,o,n);var i=Fu();return t.flags|=1,typeof o=="object"&&o!==null&&typeof o.render=="function"&&o.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Fe(r)?(i=!0,rs(t)):i=!1,t.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,Lu(t),o.updater=As,t.stateNode=o,o._reactInternals=t,Ma(t,r,e,n),t=Pa(null,t,r,!0,i,n)):(t.tag=0,de&&i&&Nu(t),Ie(null,t,o,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Di(e,t),e=t.pendingProps,o=r._init,r=o(r._payload),t.type=r,o=t.tag=T1(r),e=it(r,e),o){case 0:t=Ta(null,t,r,e,n);break e;case 1:t=Cd(null,t,r,e,n);break e;case 11:t=_d(null,t,r,e,n);break e;case 14:t=bd(null,t,r,it(r.type,e),n);break e}throw Error(F(306,r,""))}return t;case 0:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:it(r,o),Ta(e,t,r,o,n);case 1:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:it(r,o),Cd(e,t,r,o,n);case 3:e:{if(Qh(t),e===null)throw Error(F(387));r=t.pendingProps,i=t.memoizedState,o=i.element,Sh(e,t),as(t,r,null,n);var s=t.memoizedState;if(r=s.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){o=mr(Error(F(423)),t),t=Ed(e,t,r,n,o);break e}else if(r!==o){o=mr(Error(F(424)),t),t=Ed(e,t,r,n,o);break e}else for(Ye=rn(t.stateNode.containerInfo.firstChild),Xe=t,de=!0,at=null,n=vh(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(pr(),r===o){t=Ot(e,t,n);break e}Ie(e,t,r,n)}t=t.child}return t;case 5:return kh(t),e===null&&Ea(t),r=t.type,o=t.pendingProps,i=e!==null?e.memoizedProps:null,s=o.children,Sa(r,o)?s=null:i!==null&&Sa(r,i)&&(t.flags|=32),Xh(e,t),Ie(e,t,s,n),t.child;case 6:return e===null&&Ea(t),null;case 13:return Gh(e,t,n);case 4:return Au(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=hr(t,null,r,n):Ie(e,t,r,n),t.child;case 11:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:it(r,o),_d(e,t,r,o,n);case 7:return Ie(e,t,t.pendingProps,n),t.child;case 8:return Ie(e,t,t.pendingProps.children,n),t.child;case 12:return Ie(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,o=t.pendingProps,i=t.memoizedProps,s=o.value,ae(ss,r._currentValue),r._currentValue=s,i!==null)if(ht(i.value,s)){if(i.children===o.children&&!Be.current){t=Ot(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var l=i.dependencies;if(l!==null){s=i.child;for(var a=l.firstContext;a!==null;){if(a.context===r){if(i.tag===1){a=Lt(-1,n&-n),a.tag=2;var u=i.updateQueue;if(u!==null){u=u.shared;var p=u.pending;p===null?a.next=a:(a.next=p.next,p.next=a),u.pending=a}}i.lanes|=n,a=i.alternate,a!==null&&(a.lanes|=n),ja(i.return,n,t),l.lanes|=n;break}a=a.next}}else if(i.tag===10)s=i.type===t.type?null:i.child;else if(i.tag===18){if(s=i.return,s===null)throw Error(F(341));s.lanes|=n,l=s.alternate,l!==null&&(l.lanes|=n),ja(s,n,t),s=i.sibling}else s=i.child;if(s!==null)s.return=i;else for(s=i;s!==null;){if(s===t){s=null;break}if(i=s.sibling,i!==null){i.return=s.return,s=i;break}s=s.return}i=s}Ie(e,t,o.children,n),t=t.child}return t;case 9:return o=t.type,r=t.pendingProps.children,lr(t,n),o=nt(o),r=r(o),t.flags|=1,Ie(e,t,r,n),t.child;case 14:return r=t.type,o=it(r,t.pendingProps),o=it(r.type,o),bd(e,t,r,o,n);case 15:return Uh(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:it(r,o),Di(e,t),t.tag=1,Fe(r)?(e=!0,rs(t)):e=!1,lr(t,n),Hh(t,r,o),Ma(t,r,o,n),Pa(null,t,r,!0,e,n);case 19:return Kh(e,t,n);case 22:return Yh(e,t,n)}throw Error(F(156,t.tag))};function fg(e,t){return Op(e,t)}function z1(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function et(e,t,n,r){return new z1(e,t,n,r)}function Zu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function T1(e){if(typeof e=="function")return Zu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===mu)return 11;if(e===yu)return 14}return 2}function an(e,t){var n=e.alternate;return n===null?(n=et(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Fi(e,t,n,r,o,i){var s=2;if(r=e,typeof e=="function")Zu(e)&&(s=1);else if(typeof e=="string")s=5;else e:switch(e){case Wn:return bn(n.children,o,i,t);case gu:s=8,o|=8;break;case Jl:return e=et(12,n,t,o|2),e.elementType=Jl,e.lanes=i,e;case ea:return e=et(13,n,t,o),e.elementType=ea,e.lanes=i,e;case ta:return e=et(19,n,t,o),e.elementType=ta,e.lanes=i,e;case kp:return Os(n,o,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case wp:s=10;break e;case Sp:s=9;break e;case mu:s=11;break e;case yu:s=14;break e;case Xt:s=16,r=null;break e}throw Error(F(130,e==null?e:typeof e,""))}return t=et(s,n,t,o),t.elementType=e,t.type=r,t.lanes=i,t}function bn(e,t,n,r){return e=et(7,e,r,t),e.lanes=n,e}function Os(e,t,n,r){return e=et(22,e,r,t),e.elementType=kp,e.lanes=n,e.stateNode={isHidden:!1},e}function zl(e,t,n){return e=et(6,e,null,t),e.lanes=n,e}function Tl(e,t,n){return t=et(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function P1(e,t,n,r,o){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=dl(0),this.expirationTimes=dl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=dl(0),this.identifierPrefix=r,this.onRecoverableError=o,this.mutableSourceEagerHydrationData=null}function qu(e,t,n,r,o,i,s,l,a){return e=new P1(e,t,n,l,a),t===1?(t=1,i===!0&&(t|=8)):t=0,i=et(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Lu(i),e}function I1(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(mg)}catch(e){console.error(e)}}mg(),mp.exports=Ke;var D1=mp.exports,Dd=D1;Zl.createRoot=Dd.createRoot,Zl.hydrateRoot=Dd.hydrateRoot;function we(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n{}};function Ws(){for(var e=0,t=arguments.length,n={},r;e=0&&(r=n.slice(o+1),n=n.slice(0,o)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Hi.prototype=Ws.prototype={constructor:Hi,on:function(e,t){var n=this._,r=B1(e+"",n),o,i=-1,s=r.length;if(arguments.length<2){for(;++i0)for(var n=new Array(o),r=0,o,i;r=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Bd.hasOwnProperty(t)?{space:Bd[t],local:e}:e}function H1(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Wa&&t.documentElement.namespaceURI===Wa?t.createElement(e):t.createElementNS(n,e)}}function V1(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function yg(e){var t=Us(e);return(t.local?V1:H1)(t)}function W1(){}function nc(e){return e==null?W1:function(){return this.querySelector(e)}}function U1(e){typeof e!="function"&&(e=nc(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o=h&&(h=g+1);!(_=k[h])&&++h=0;)(s=r[o])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function mv(e){e||(e=yv);function t(c,f){return c&&f?e(c.__data__,f.__data__):!c-!f}for(var n=this._groups,r=n.length,o=new Array(r),i=0;it?1:e>=t?0:NaN}function xv(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function vv(){return Array.from(this)}function wv(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?Tv:typeof t=="function"?Iv:Pv)(e,t,n??"")):xr(this.node(),e)}function xr(e,t){return e.style.getPropertyValue(t)||kg(e).getComputedStyle(e,null).getPropertyValue(t)}function Lv(e){return function(){delete this[e]}}function Av(e,t){return function(){this[e]=t}}function $v(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Dv(e,t){return arguments.length>1?this.each((t==null?Lv:typeof t=="function"?$v:Av)(e,t)):this.node()[e]}function _g(e){return e.trim().split(/^|\s+/)}function rc(e){return e.classList||new bg(e)}function bg(e){this._node=e,this._names=_g(e.getAttribute("class")||"")}bg.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 Cg(e,t){for(var n=rc(e),r=-1,o=t.length;++r=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function fw(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,o=t.length,i;n()=>e;function Ua(e,{sourceEvent:t,subject:n,target:r,identifier:o,active:i,x:s,y:l,dx:a,dy:u,dispatch:p}){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:r,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:a,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:p}})}Ua.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function kw(e){return!e.ctrlKey&&!e.button}function _w(){return this.parentNode}function bw(e,t){return t??{x:e.x,y:e.y}}function Cw(){return navigator.maxTouchPoints||"ontouchstart"in this}function Tg(){var e=kw,t=_w,n=bw,r=Cw,o={},i=Ws("start","drag","end"),s=0,l,a,u,p,c=0;function f(w){w.on("mousedown.drag",x).filter(r).on("touchstart.drag",k).on("touchmove.drag",m,Sw).on("touchend.drag touchcancel.drag",g).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function x(w,_){if(!(p||!e.call(this,w,_))){var S=h(this,t.call(this,w,_),w,_,"mouse");S&&(Ue(w.view).on("mousemove.drag",y,Mo).on("mouseup.drag",v,Mo),Mg(w.view),Pl(w),u=!1,l=w.clientX,a=w.clientY,S("start",w))}}function y(w){if(ur(w),!u){var _=w.clientX-l,S=w.clientY-a;u=_*_+S*S>c}o.mouse("drag",w)}function v(w){Ue(w.view).on("mousemove.drag mouseup.drag",null),zg(w.view,u),ur(w),o.mouse("end",w)}function k(w,_){if(e.call(this,w,_)){var S=w.changedTouches,b=t.call(this,w,_),E=S.length,A,D;for(A=0;A>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?mi(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?mi(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=jw.exec(e))?new Oe(t[1],t[2],t[3],1):(t=Nw.exec(e))?new Oe(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Mw.exec(e))?mi(t[1],t[2],t[3],t[4]):(t=zw.exec(e))?mi(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Tw.exec(e))?Xd(t[1],t[2]/100,t[3]/100,1):(t=Pw.exec(e))?Xd(t[1],t[2]/100,t[3]/100,t[4]):Fd.hasOwnProperty(e)?Wd(Fd[e]):e==="transparent"?new Oe(NaN,NaN,NaN,0):null}function Wd(e){return new Oe(e>>16&255,e>>8&255,e&255,1)}function mi(e,t,n,r){return r<=0&&(e=t=n=NaN),new Oe(e,t,n,r)}function Lw(e){return e instanceof Uo||(e=Pn(e)),e?(e=e.rgb(),new Oe(e.r,e.g,e.b,e.opacity)):new Oe}function Ya(e,t,n,r){return arguments.length===1?Lw(e):new Oe(e,t,n,r??1)}function Oe(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}oc(Oe,Ya,Pg(Uo,{brighter(e){return e=e==null?xs:Math.pow(xs,e),new Oe(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?zo:Math.pow(zo,e),new Oe(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Oe(Cn(this.r),Cn(this.g),Cn(this.b),vs(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:Ud,formatHex:Ud,formatHex8:Aw,formatRgb:Yd,toString:Yd}));function Ud(){return`#${kn(this.r)}${kn(this.g)}${kn(this.b)}`}function Aw(){return`#${kn(this.r)}${kn(this.g)}${kn(this.b)}${kn((isNaN(this.opacity)?1:this.opacity)*255)}`}function Yd(){const e=vs(this.opacity);return`${e===1?"rgb(":"rgba("}${Cn(this.r)}, ${Cn(this.g)}, ${Cn(this.b)}${e===1?")":`, ${e})`}`}function vs(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Cn(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function kn(e){return e=Cn(e),(e<16?"0":"")+e.toString(16)}function Xd(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new ut(e,t,n,r)}function Ig(e){if(e instanceof ut)return new ut(e.h,e.s,e.l,e.opacity);if(e instanceof Uo||(e=Pn(e)),!e)return new ut;if(e instanceof ut)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,o=Math.min(t,n,r),i=Math.max(t,n,r),s=NaN,l=i-o,a=(i+o)/2;return l?(t===i?s=(n-r)/l+(n0&&a<1?0:s,new ut(s,l,a,e.opacity)}function $w(e,t,n,r){return arguments.length===1?Ig(e):new ut(e,t,n,r??1)}function ut(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}oc(ut,$w,Pg(Uo,{brighter(e){return e=e==null?xs:Math.pow(xs,e),new ut(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?zo:Math.pow(zo,e),new ut(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,r=n+(n<.5?n:1-n)*t,o=2*n-r;return new Oe(Il(e>=240?e-240:e+120,o,r),Il(e,o,r),Il(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new ut(Qd(this.h),yi(this.s),yi(this.l),vs(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=vs(this.opacity);return`${e===1?"hsl(":"hsla("}${Qd(this.h)}, ${yi(this.s)*100}%, ${yi(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Qd(e){return e=(e||0)%360,e<0?e+360:e}function yi(e){return Math.max(0,Math.min(1,e||0))}function Il(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 ic=e=>()=>e;function Dw(e,t){return function(n){return e+n*t}}function Ow(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function Bw(e){return(e=+e)==1?Rg:function(t,n){return n-t?Ow(t,n,e):ic(isNaN(t)?n:t)}}function Rg(e,t){var n=t-e;return n?Dw(e,n):ic(isNaN(e)?t:e)}const ws=function e(t){var n=Bw(t);function r(o,i){var s=n((o=Ya(o)).r,(i=Ya(i)).r),l=n(o.g,i.g),a=n(o.b,i.b),u=Rg(o.opacity,i.opacity);return function(p){return o.r=s(p),o.g=l(p),o.b=a(p),o.opacity=u(p),o+""}}return r.gamma=e,r}(1);function Fw(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),o;return function(i){for(o=0;on&&(i=t.slice(n,i),l[s]?l[s]+=i:l[++s]=i),(r=r[0])===(o=o[0])?l[s]?l[s]+=o:l[++s]=o:(l[++s]=null,a.push({i:s,x:St(r,o)})),n=Rl.lastIndex;return n180?p+=360:p-u>180&&(u+=360),f.push({i:c.push(o(c)+"rotate(",null,r)-2,x:St(u,p)})):p&&c.push(o(c)+"rotate("+p+r)}function l(u,p,c,f){u!==p?f.push({i:c.push(o(c)+"skewX(",null,r)-2,x:St(u,p)}):p&&c.push(o(c)+"skewX("+p+r)}function a(u,p,c,f,x,y){if(u!==c||p!==f){var v=x.push(o(x)+"scale(",null,",",null,")");y.push({i:v-4,x:St(u,c)},{i:v-2,x:St(p,f)})}else(c!==1||f!==1)&&x.push(o(x)+"scale("+c+","+f+")")}return function(u,p){var c=[],f=[];return u=e(u),p=e(p),i(u.translateX,u.translateY,p.translateX,p.translateY,c,f),s(u.rotate,p.rotate,c,f),l(u.skewX,p.skewX,c,f),a(u.scaleX,u.scaleY,p.scaleX,p.scaleY,c,f),u=p=null,function(x){for(var y=-1,v=f.length,k;++y=0&&e._call.call(void 0,t),e=e._next;--vr}function Zd(){In=(ks=Po.now())+Ys,vr=qr=0;try{n2()}finally{vr=0,o2(),In=0}}function r2(){var e=Po.now(),t=e-ks;t>Dg&&(Ys-=t,ks=e)}function o2(){for(var e,t=Ss,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Ss=n);Jr=e,Ga(r)}function Ga(e){if(!vr){qr&&(qr=clearTimeout(qr));var t=e-In;t>24?(e<1/0&&(qr=setTimeout(Zd,e-Po.now()-Ys)),Hr&&(Hr=clearInterval(Hr))):(Hr||(ks=Po.now(),Hr=setInterval(r2,Dg)),vr=1,Og(Zd))}}function qd(e,t,n){var r=new _s;return t=t==null?0:+t,r.restart(o=>{r.stop(),e(o+t)},t,n),r}var i2=Ws("start","end","cancel","interrupt"),s2=[],Fg=0,Jd=1,Ka=2,Wi=3,ef=4,Za=5,Ui=6;function Xs(e,t,n,r,o,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;l2(e,n,{name:t,index:r,group:o,on:i2,tween:s2,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Fg})}function lc(e,t){var n=gt(e,t);if(n.state>Fg)throw new Error("too late; already scheduled");return n}function jt(e,t){var n=gt(e,t);if(n.state>Wi)throw new Error("too late; already running");return n}function gt(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function l2(e,t,n){var r=e.__transition,o;r[t]=n,n.timer=Bg(i,0,n.time);function i(u){n.state=Jd,n.timer.restart(s,n.delay,n.time),n.delay<=u&&s(u-n.delay)}function s(u){var p,c,f,x;if(n.state!==Jd)return a();for(p in r)if(x=r[p],x.name===n.name){if(x.state===Wi)return qd(s);x.state===ef?(x.state=Ui,x.timer.stop(),x.on.call("interrupt",e,e.__data__,x.index,x.group),delete r[p]):+pKa&&r.state=0&&(t=t.slice(0,n)),!t||t==="start"})}function $2(e,t,n){var r,o,i=A2(t)?lc:jt;return function(){var s=i(this,e),l=s.on;l!==r&&(o=(r=l).copy()).on(t,n),s.on=o}}function D2(e,t){var n=this._id;return arguments.length<2?gt(this.node(),n).on.on(e):this.each($2(n,e,t))}function O2(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function B2(){return this.on("end.remove",O2(this._id))}function F2(e){var t=this._name,n=this._id;typeof e!="function"&&(e=nc(e));for(var r=this._groups,o=r.length,i=new Array(o),s=0;s()=>e;function fS(e,{sourceEvent:t,target:n,transform:r,dispatch:o}){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:r,enumerable:!0,configurable:!0},_:{value:o}})}function Rt(e,t,n){this.k=e,this.x=t,this.y=n}Rt.prototype={constructor:Rt,scale:function(e){return e===1?this:new Rt(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Rt(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 Qs=new Rt(1,0,0);Ug.prototype=Rt.prototype;function Ug(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Qs;return e.__zoom}function Ll(e){e.stopImmediatePropagation()}function Vr(e){e.preventDefault(),e.stopImmediatePropagation()}function pS(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function hS(){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 tf(){return this.__zoom||Qs}function gS(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function mS(){return navigator.maxTouchPoints||"ontouchstart"in this}function yS(e,t,n){var r=e.invertX(t[0][0])-n[0][0],o=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(o>r?(r+o)/2:Math.min(0,r)||Math.max(0,o),s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s))}function Yg(){var e=pS,t=hS,n=yS,r=gS,o=mS,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],l=250,a=Vi,u=Ws("start","zoom","end"),p,c,f,x=500,y=150,v=0,k=10;function m(C){C.property("__zoom",tf).on("wheel.zoom",E,{passive:!1}).on("mousedown.zoom",A).on("dblclick.zoom",D).filter(o).on("touchstart.zoom",P).on("touchmove.zoom",I).on("touchend.zoom touchcancel.zoom",T).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(C,L,z,R){var j=C.selection?C.selection():C;j.property("__zoom",tf),C!==j?_(C,L,z,R):j.interrupt().each(function(){S(this,arguments).event(R).start().zoom(null,typeof L=="function"?L.apply(this,arguments):L).end()})},m.scaleBy=function(C,L,z,R){m.scaleTo(C,function(){var j=this.__zoom.k,N=typeof L=="function"?L.apply(this,arguments):L;return j*N},z,R)},m.scaleTo=function(C,L,z,R){m.transform(C,function(){var j=t.apply(this,arguments),N=this.__zoom,$=z==null?w(j):typeof z=="function"?z.apply(this,arguments):z,O=N.invert($),B=typeof L=="function"?L.apply(this,arguments):L;return n(h(g(N,B),$,O),j,s)},z,R)},m.translateBy=function(C,L,z,R){m.transform(C,function(){return n(this.__zoom.translate(typeof L=="function"?L.apply(this,arguments):L,typeof z=="function"?z.apply(this,arguments):z),t.apply(this,arguments),s)},null,R)},m.translateTo=function(C,L,z,R,j){m.transform(C,function(){var N=t.apply(this,arguments),$=this.__zoom,O=R==null?w(N):typeof R=="function"?R.apply(this,arguments):R;return n(Qs.translate(O[0],O[1]).scale($.k).translate(typeof L=="function"?-L.apply(this,arguments):-L,typeof z=="function"?-z.apply(this,arguments):-z),N,s)},R,j)};function g(C,L){return L=Math.max(i[0],Math.min(i[1],L)),L===C.k?C:new Rt(L,C.x,C.y)}function h(C,L,z){var R=L[0]-z[0]*C.k,j=L[1]-z[1]*C.k;return R===C.x&&j===C.y?C:new Rt(C.k,R,j)}function w(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function _(C,L,z,R){C.on("start.zoom",function(){S(this,arguments).event(R).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event(R).end()}).tween("zoom",function(){var j=this,N=arguments,$=S(j,N).event(R),O=t.apply(j,N),B=z==null?w(O):typeof z=="function"?z.apply(j,N):z,W=Math.max(O[1][0]-O[0][0],O[1][1]-O[0][1]),V=j.__zoom,Y=typeof L=="function"?L.apply(j,N):L,X=a(V.invert(B).concat(W/V.k),Y.invert(B).concat(W/Y.k));return function(Q){if(Q===1)Q=Y;else{var H=X(Q),K=W/H[2];Q=new Rt(K,B[0]-H[0]*K,B[1]-H[1]*K)}$.zoom(null,Q)}})}function S(C,L,z){return!z&&C.__zooming||new b(C,L)}function b(C,L){this.that=C,this.args=L,this.active=0,this.sourceEvent=null,this.extent=t.apply(C,L),this.taps=0}b.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,L){return this.mouse&&C!=="mouse"&&(this.mouse[1]=L.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=L.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=L.invert(this.touch1[0])),this.that.__zoom=L,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var L=Ue(this.that).datum();u.call(C,this.that,new fS(C,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:u}),L)}};function E(C,...L){if(!e.apply(this,arguments))return;var z=S(this,L).event(C),R=this.__zoom,j=Math.max(i[0],Math.min(i[1],R.k*Math.pow(2,r.apply(this,arguments)))),N=lt(C);if(z.wheel)(z.mouse[0][0]!==N[0]||z.mouse[0][1]!==N[1])&&(z.mouse[1]=R.invert(z.mouse[0]=N)),clearTimeout(z.wheel);else{if(R.k===j)return;z.mouse=[N,R.invert(N)],Yi(this),z.start()}Vr(C),z.wheel=setTimeout($,y),z.zoom("mouse",n(h(g(R,j),z.mouse[0],z.mouse[1]),z.extent,s));function $(){z.wheel=null,z.end()}}function A(C,...L){if(f||!e.apply(this,arguments))return;var z=C.currentTarget,R=S(this,L,!0).event(C),j=Ue(C.view).on("mousemove.zoom",B,!0).on("mouseup.zoom",W,!0),N=lt(C,z),$=C.clientX,O=C.clientY;Mg(C.view),Ll(C),R.mouse=[N,this.__zoom.invert(N)],Yi(this),R.start();function B(V){if(Vr(V),!R.moved){var Y=V.clientX-$,X=V.clientY-O;R.moved=Y*Y+X*X>v}R.event(V).zoom("mouse",n(h(R.that.__zoom,R.mouse[0]=lt(V,z),R.mouse[1]),R.extent,s))}function W(V){j.on("mousemove.zoom mouseup.zoom",null),zg(V.view,R.moved),Vr(V),R.event(V).end()}}function D(C,...L){if(e.apply(this,arguments)){var z=this.__zoom,R=lt(C.changedTouches?C.changedTouches[0]:C,this),j=z.invert(R),N=z.k*(C.shiftKey?.5:2),$=n(h(g(z,N),R,j),t.apply(this,L),s);Vr(C),l>0?Ue(this).transition().duration(l).call(_,$,R,C):Ue(this).call(m.transform,$,R,C)}}function P(C,...L){if(e.apply(this,arguments)){var z=C.touches,R=z.length,j=S(this,L,C.changedTouches.length===R).event(C),N,$,O,B;for(Ll(C),$=0;$"[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:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:r}", 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."},Io=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Xg=["Enter"," ","Escape"],Qg={"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 wr;(function(e){e.Strict="strict",e.Loose="loose"})(wr||(wr={}));var En;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(En||(En={}));var Ro;(function(e){e.Partial="partial",e.Full="full"})(Ro||(Ro={}));const Gg={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Zt;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Zt||(Zt={}));var bs;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(bs||(bs={}));var q;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(q||(q={}));const nf={[q.Left]:q.Right,[q.Right]:q.Left,[q.Top]:q.Bottom,[q.Bottom]:q.Top};function Kg(e){return e===null?null:e?"valid":"invalid"}const Zg=e=>"id"in e&&"source"in e&&"target"in e,xS=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),uc=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Yo=(e,t=[0,0])=>{const{width:n,height:r}=Ht(e),o=e.origin??t,i=n*o[0],s=r*o[1];return{x:e.position.x-i,y:e.position.y-s}},vS=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,o)=>{const i=typeof o=="string";let s=!t.nodeLookup&&!i?o:void 0;t.nodeLookup&&(s=i?t.nodeLookup.get(o):uc(o)?o:t.nodeLookup.get(o.id));const l=s?Cs(s,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Gs(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Ks(n)},Xo=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(o=>{(t.filter===void 0||t.filter(o))&&(n=Gs(n,Cs(o)),r=!0)}),r?Ks(n):{x:0,y:0,width:0,height:0}},cc=(e,t,[n,r,o]=[0,0,1],i=!1,s=!1)=>{const l={...Go(t,[n,r,o]),width:t.width/o,height:t.height/o},a=[];for(const u of e.values()){const{measured:p,selectable:c=!0,hidden:f=!1}=u;if(s&&!c||f)continue;const x=p.width??u.width??u.initialWidth??null,y=p.height??u.height??u.initialHeight??null,v=Lo(l,kr(u)),k=(x??0)*(y??0),m=i&&v>0;(!u.internals.handleBounds||m||v>=k||u.dragging)&&a.push(u)}return a},wS=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function SS(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(o=>o.id)):null;return e.forEach(o=>{o.measured.width&&o.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!o.hidden)&&(!r||r.has(o.id))&&n.set(o.id,o)}),n}async function kS({nodes:e,width:t,height:n,panZoom:r,minZoom:o,maxZoom:i},s){if(e.size===0)return Promise.resolve(!0);const l=SS(e,s),a=Xo(l),u=dc(a,t,n,(s==null?void 0:s.minZoom)??o,(s==null?void 0:s.maxZoom)??i,(s==null?void 0:s.padding)??.1);return await r.setViewport(u,{duration:s==null?void 0:s.duration,ease:s==null?void 0:s.ease,interpolate:s==null?void 0:s.interpolate}),Promise.resolve(!0)}function qg({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:o,onError:i}){const s=n.get(e),l=s.parentId?n.get(s.parentId):void 0,{x:a,y:u}=l?l.internals.positionAbsolute:{x:0,y:0},p=s.origin??r;let c=s.extent||o;if(s.extent==="parent"&&!s.expandParent)if(!l)i==null||i("005",Et.error005());else{const x=l.measured.width,y=l.measured.height;x&&y&&(c=[[a,u],[a+x,u+y]])}else l&&_r(s.extent)&&(c=[[s.extent[0][0]+a,s.extent[0][1]+u],[s.extent[1][0]+a,s.extent[1][1]+u]]);const f=_r(c)?Rn(t,c,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&(i==null||i("015",Et.error015())),{position:{x:f.x-a+(s.measured.width??0)*p[0],y:f.y-u+(s.measured.height??0)*p[1]},positionAbsolute:f}}async function _S({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:o}){const i=new Set(e.map(f=>f.id)),s=[];for(const f of n){if(f.deletable===!1)continue;const x=i.has(f.id),y=!x&&f.parentId&&s.find(v=>v.id===f.parentId);(x||y)&&s.push(f)}const l=new Set(t.map(f=>f.id)),a=r.filter(f=>f.deletable!==!1),p=wS(s,a);for(const f of a)l.has(f.id)&&!p.find(y=>y.id===f.id)&&p.push(f);if(!o)return{edges:p,nodes:s};const c=await o({nodes:s,edges:p});return typeof c=="boolean"?c?{edges:p,nodes:s}:{edges:[],nodes:[]}:c}const Sr=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Rn=(e={x:0,y:0},t,n)=>({x:Sr(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Sr(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function Jg(e,t,n){const{width:r,height:o}=Ht(n),{x:i,y:s}=n.internals.positionAbsolute;return Rn(e,[[i,s],[i+r,s+o]],t)}const rf=(e,t,n)=>en?-Sr(Math.abs(e-n),1,t)/t:0,em=(e,t,n=15,r=40)=>{const o=rf(e.x,r,t.width-r)*n,i=rf(e.y,r,t.height-r)*n;return[o,i]},Gs=(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)}),qa=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Ks=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),kr=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=uc(e)?e.internals.positionAbsolute:Yo(e,t);return{x:n,y:r,width:((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},Cs=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=uc(e)?e.internals.positionAbsolute:Yo(e,t);return{x:n,y:r,x2:n+(((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0),y2:r+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},tm=(e,t)=>Ks(Gs(qa(e),qa(t))),Lo=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},of=e=>ct(e.width)&&ct(e.height)&&ct(e.x)&&ct(e.y),ct=e=>!isNaN(e)&&isFinite(e),bS=(e,t)=>{},Qo=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Go=({x:e,y:t},[n,r,o],i=!1,s=[1,1])=>{const l={x:(e-n)/o,y:(t-r)/o};return i?Qo(l,s):l},Es=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r});function Fn(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 CS(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=Fn(e,n),o=Fn(e,t);return{top:r,right:o,bottom:r,left:o,x:o*2,y:r*2}}if(typeof e=="object"){const r=Fn(e.top??e.y??0,n),o=Fn(e.bottom??e.y??0,n),i=Fn(e.left??e.x??0,t),s=Fn(e.right??e.x??0,t);return{top:r,right:s,bottom:o,left:i,x:i+s,y:r+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function ES(e,t,n,r,o,i){const{x:s,y:l}=Es(e,[t,n,r]),{x:a,y:u}=Es({x:e.x+e.width,y:e.y+e.height},[t,n,r]),p=o-a,c=i-u;return{left:Math.floor(s),top:Math.floor(l),right:Math.floor(p),bottom:Math.floor(c)}}const dc=(e,t,n,r,o,i)=>{const s=CS(i,t,n),l=(t-s.x)/e.width,a=(n-s.y)/e.height,u=Math.min(l,a),p=Sr(u,r,o),c=e.x+e.width/2,f=e.y+e.height/2,x=t/2-c*p,y=n/2-f*p,v=ES(e,x,y,p,t,n),k={left:Math.min(v.left-s.left,0),top:Math.min(v.top-s.top,0),right:Math.min(v.right-s.right,0),bottom:Math.min(v.bottom-s.bottom,0)};return{x:x-k.left+k.right,y:y-k.top+k.bottom,zoom:p}},Ao=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function _r(e){return e!=null&&e!=="parent"}function Ht(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function nm(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function rm(e,t={width:0,height:0},n,r,o){const i={...e},s=r.get(n);if(s){const l=s.origin||o;i.x+=s.internals.positionAbsolute.x-(t.width??0)*l[0],i.y+=s.internals.positionAbsolute.y-(t.height??0)*l[1]}return i}function sf(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function jS(){let e,t;return{promise:new Promise((r,o)=>{e=r,t=o}),resolve:e,reject:t}}function NS(e){return{...Qg,...e||{}}}function co(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:o}){const{x:i,y:s}=dt(e),l=Go({x:i-((o==null?void 0:o.left)??0),y:s-((o==null?void 0:o.top)??0)},r),{x:a,y:u}=n?Qo(l,t):l;return{xSnapped:a,ySnapped:u,...l}}const fc=e=>({width:e.offsetWidth,height:e.offsetHeight}),om=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},MS=["INPUT","SELECT","TEXTAREA"];function im(e){var r,o;const t=((o=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:o[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:MS.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const sm=e=>"clientX"in e,dt=(e,t)=>{var i,s;const n=sm(e),r=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,o=n?e.clientY:(s=e.touches)==null?void 0:s[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:o-((t==null?void 0:t.top)??0)}},lf=(e,t,n,r,o)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(s=>{const l=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:o,position:s.getAttribute("data-handlepos"),x:(l.left-n.left)/r,y:(l.top-n.top)/r,...fc(s)}})};function lm({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:o,sourceControlY:i,targetControlX:s,targetControlY:l}){const a=e*.125+o*.375+s*.375+n*.125,u=t*.125+i*.375+l*.375+r*.125,p=Math.abs(a-e),c=Math.abs(u-t);return[a,u,p,c]}function wi(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function af({pos:e,x1:t,y1:n,x2:r,y2:o,c:i}){switch(e){case q.Left:return[t-wi(t-r,i),n];case q.Right:return[t+wi(r-t,i),n];case q.Top:return[t,n-wi(n-o,i)];case q.Bottom:return[t,n+wi(o-n,i)]}}function am({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:r,targetY:o,targetPosition:i=q.Top,curvature:s=.25}){const[l,a]=af({pos:n,x1:e,y1:t,x2:r,y2:o,c:s}),[u,p]=af({pos:i,x1:r,y1:o,x2:e,y2:t,c:s}),[c,f,x,y]=lm({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:l,sourceControlY:a,targetControlX:u,targetControlY:p});return[`M${e},${t} C${l},${a} ${u},${p} ${r},${o}`,c,f,x,y]}function um({sourceX:e,sourceY:t,targetX:n,targetY:r}){const o=Math.abs(n-e)/2,i=n0}const PS=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,IS=(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)),RS=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||PS;let o;return Zg(e)?o={...e}:o={...e,id:r(e)},IS(o,t)?t:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,t.concat(o))};function cm({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[o,i,s,l]=um({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,i,s,l]}const uf={[q.Left]:{x:-1,y:0},[q.Right]:{x:1,y:0},[q.Top]:{x:0,y:-1},[q.Bottom]:{x:0,y:1}},LS=({source:e,sourcePosition:t=q.Bottom,target:n})=>t===q.Left||t===q.Right?e.xMath.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function AS({source:e,sourcePosition:t=q.Bottom,target:n,targetPosition:r=q.Top,center:o,offset:i,stepPosition:s}){const l=uf[t],a=uf[r],u={x:e.x+l.x*i,y:e.y+l.y*i},p={x:n.x+a.x*i,y:n.y+a.y*i},c=LS({source:u,sourcePosition:t,target:p}),f=c.x!==0?"x":"y",x=c[f];let y=[],v,k;const m={x:0,y:0},g={x:0,y:0},[,,h,w]=um({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[f]*a[f]===-1){f==="x"?(v=o.x??u.x+(p.x-u.x)*s,k=o.y??(u.y+p.y)/2):(v=o.x??(u.x+p.x)/2,k=o.y??u.y+(p.y-u.y)*s);const S=[{x:v,y:u.y},{x:v,y:p.y}],b=[{x:u.x,y:k},{x:p.x,y:k}];l[f]===x?y=f==="x"?S:b:y=f==="x"?b:S}else{const S=[{x:u.x,y:p.y}],b=[{x:p.x,y:u.y}];if(f==="x"?y=l.x===x?b:S:y=l.y===x?S:b,t===r){const I=Math.abs(e[f]-n[f]);if(I<=i){const T=Math.min(i-1,i-I);l[f]===x?m[f]=(u[f]>e[f]?-1:1)*T:g[f]=(p[f]>n[f]?-1:1)*T}}if(t!==r){const I=f==="x"?"y":"x",T=l[f]===a[I],C=u[I]>p[I],L=u[I]=P?(v=(E.x+A.x)/2,k=y[0].y):(v=y[0].x,k=(E.y+A.y)/2)}return[[e,{x:u.x+m.x,y:u.y+m.y},...y,{x:p.x+g.x,y:p.y+g.y},n],v,k,h,w]}function $S(e,t,n,r){const o=Math.min(cf(e,t)/2,cf(t,n)/2,r),{x:i,y:s}=t;if(e.x===i&&i===n.x||e.y===s&&s===n.y)return`L${i} ${s}`;if(e.y===s){const u=e.x{let w="";return h>0&&hn.id===t):e[0])||null}function eu(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function OS(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:o}){const i=new Set;return e.reduce((s,l)=>([l.markerStart||r,l.markerEnd||o].forEach(a=>{if(a&&typeof a=="object"){const u=eu(a,t);i.has(u)||(s.push({id:u,color:a.color||n,...a}),i.add(u))}}),s),[]).sort((s,l)=>s.id.localeCompare(l.id))}const dm=1e3,BS=10,pc={nodeOrigin:[0,0],nodeExtent:Io,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},FS={...pc,checkEquality:!0};function hc(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function HS(e,t,n){const r=hc(pc,n);for(const o of e.values())if(o.parentId)mc(o,e,t,r);else{const i=Yo(o,r.nodeOrigin),s=_r(o.extent)?o.extent:r.nodeExtent,l=Rn(i,s,Ht(o));o.internals.positionAbsolute=l}}function VS(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],r=[];for(const o of e.handles){const i={id:o.id,width:o.width??1,height:o.height??1,nodeId:e.id,x:o.x,y:o.y,position:o.position,type:o.type};o.type==="source"?n.push(i):o.type==="target"&&r.push(i)}return{source:n,target:r}}function gc(e){return e==="manual"}function tu(e,t,n,r={}){var u,p;const o=hc(FS,r),i={i:0},s=new Map(t),l=o!=null&&o.elevateNodesOnSelect&&!gc(o.zIndexMode)?dm:0;let a=e.length>0;t.clear(),n.clear();for(const c of e){let f=s.get(c.id);if(o.checkEquality&&c===(f==null?void 0:f.internals.userNode))t.set(c.id,f);else{const x=Yo(c,o.nodeOrigin),y=_r(c.extent)?c.extent:o.nodeExtent,v=Rn(x,y,Ht(c));f={...o.defaults,...c,measured:{width:(u=c.measured)==null?void 0:u.width,height:(p=c.measured)==null?void 0:p.height},internals:{positionAbsolute:v,handleBounds:VS(c,f),z:fm(c,l,o.zIndexMode),userNode:c}},t.set(c.id,f)}(f.measured===void 0||f.measured.width===void 0||f.measured.height===void 0)&&!f.hidden&&(a=!1),c.parentId&&mc(f,t,n,r,i)}return a}function WS(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 mc(e,t,n,r,o){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:l,zIndexMode:a}=hc(pc,r),u=e.parentId,p=t.get(u);if(!p){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}WS(e,n),o&&!p.parentId&&p.internals.rootParentIndex===void 0&&a==="auto"&&(p.internals.rootParentIndex=++o.i,p.internals.z=p.internals.z+o.i*BS),o&&p.internals.rootParentIndex!==void 0&&(o.i=p.internals.rootParentIndex);const c=i&&!gc(a)?dm:0,{x:f,y:x,z:y}=US(e,p,s,l,c,a),{positionAbsolute:v}=e.internals,k=f!==v.x||x!==v.y;(k||y!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:k?{x:f,y:x}:v,z:y}})}function fm(e,t,n){const r=ct(e.zIndex)?e.zIndex:0;return gc(n)?r:r+(e.selected?t:0)}function US(e,t,n,r,o,i){const{x:s,y:l}=t.internals.positionAbsolute,a=Ht(e),u=Yo(e,n),p=_r(e.extent)?Rn(u,e.extent,a):u;let c=Rn({x:s+p.x,y:l+p.y},r,a);e.extent==="parent"&&(c=Jg(c,a,t));const f=fm(e,o,i),x=t.internals.z??0;return{x:c.x,y:c.y,z:x>=f?x+1:f}}function yc(e,t,n,r=[0,0]){var s;const o=[],i=new Map;for(const l of e){const a=t.get(l.parentId);if(!a)continue;const u=((s=i.get(l.parentId))==null?void 0:s.expandedRect)??kr(a),p=tm(u,l.rect);i.set(l.parentId,{expandedRect:p,parent:a})}return i.size>0&&i.forEach(({expandedRect:l,parent:a},u)=>{var h;const p=a.internals.positionAbsolute,c=Ht(a),f=a.origin??r,x=l.x0||y>0||m||g)&&(o.push({id:u,type:"position",position:{x:a.position.x-x+m,y:a.position.y-y+g}}),(h=n.get(u))==null||h.forEach(w=>{e.some(_=>_.id===w.id)||o.push({id:w.id,type:"position",position:{x:w.position.x+x,y:w.position.y+y}})})),(c.width0){const x=yc(f,t,n,o);u.push(...x)}return{changes:u,updatedInternals:a}}async function XS({delta:e,panZoom:t,transform:n,translateExtent:r,width:o,height:i}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[o,i]],r),l=!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2]);return Promise.resolve(l)}function hf(e,t,n,r,o,i){let s=o;const l=r.get(s)||new Map;r.set(s,l.set(n,t)),s=`${o}-${e}`;const a=r.get(s)||new Map;if(r.set(s,a.set(n,t)),i){s=`${o}-${e}-${i}`;const u=r.get(s)||new Map;r.set(s,u.set(n,t))}}function pm(e,t,n){e.clear(),t.clear();for(const r of n){const{source:o,target:i,sourceHandle:s=null,targetHandle:l=null}=r,a={edgeId:r.id,source:o,target:i,sourceHandle:s,targetHandle:l},u=`${o}-${s}--${i}-${l}`,p=`${i}-${l}--${o}-${s}`;hf("source",a,p,e,o,s),hf("target",a,u,e,i,l),t.set(r.id,r)}}function hm(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:hm(n,t):!1}function gf(e,t,n){var o;let r=e;do{if((o=r==null?void 0:r.matches)!=null&&o.call(r,t))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function QS(e,t,n,r){const o=new Map;for(const[i,s]of e)if((s.selected||s.id===r)&&(!s.parentId||!hm(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const l=e.get(i);l&&o.set(i,{id:i,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 o}function Al({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var s,l,a;const o=[];for(const[u,p]of t){const c=(s=n.get(u))==null?void 0:s.internals.userNode;c&&o.push({...c,position:p.position,dragging:r})}if(!e)return[o[0],o];const i=(l=n.get(e))==null?void 0:l.internals.userNode;return[i?{...i,position:((a=t.get(e))==null?void 0:a.position)||i.position,dragging:r}:o[0],o]}function GS({dragItems:e,snapGrid:t,x:n,y:r}){const o=e.values().next().value;if(!o)return null;const i={x:n-o.distance.x,y:r-o.distance.y},s=Qo(i,t);return{x:s.x-i.x,y:s.y-i.y}}function KS({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:o}){let i={x:null,y:null},s=0,l=new Map,a=!1,u={x:0,y:0},p=null,c=!1,f=null,x=!1,y=!1,v=null;function k({noDragClassName:g,handleSelector:h,domNode:w,isSelectable:_,nodeId:S,nodeClickDistance:b=0}){f=Ue(w);function E({x:I,y:T}){const{nodeLookup:C,nodeExtent:L,snapGrid:z,snapToGrid:R,nodeOrigin:j,onNodeDrag:N,onSelectionDrag:$,onError:O,updateNodePositions:B}=t();i={x:I,y:T};let W=!1;const V=l.size>1,Y=V&&L?qa(Xo(l)):null,X=V&&R?GS({dragItems:l,snapGrid:z,x:I,y:T}):null;for(const[Q,H]of l){if(!C.has(Q))continue;let K={x:I-H.distance.x,y:T-H.distance.y};R&&(K=X?{x:Math.round(K.x+X.x),y:Math.round(K.y+X.y)}:Qo(K,z));let ee=null;if(V&&L&&!H.extent&&Y){const{positionAbsolute:Z}=H.internals,re=Z.x-Y.x+L[0][0],le=Z.x+H.measured.width-Y.x2+L[1][0],ie=Z.y-Y.y+L[0][1],Ne=Z.y+H.measured.height-Y.y2+L[1][1];ee=[[re,ie],[le,Ne]]}const{position:G,positionAbsolute:J}=qg({nodeId:Q,nextPosition:K,nodeLookup:C,nodeExtent:ee||L,nodeOrigin:j,onError:O});W=W||H.position.x!==G.x||H.position.y!==G.y,H.position=G,H.internals.positionAbsolute=J}if(y=y||W,!!W&&(B(l,!0),v&&(r||N||!S&&$))){const[Q,H]=Al({nodeId:S,dragItems:l,nodeLookup:C});r==null||r(v,l,Q,H),N==null||N(v,Q,H),S||$==null||$(v,H)}}async function A(){if(!p)return;const{transform:I,panBy:T,autoPanSpeed:C,autoPanOnNodeDrag:L}=t();if(!L){a=!1,cancelAnimationFrame(s);return}const[z,R]=em(u,p,C);(z!==0||R!==0)&&(i.x=(i.x??0)-z/I[2],i.y=(i.y??0)-R/I[2],await T({x:z,y:R})&&E(i)),s=requestAnimationFrame(A)}function D(I){var V;const{nodeLookup:T,multiSelectionActive:C,nodesDraggable:L,transform:z,snapGrid:R,snapToGrid:j,selectNodesOnDrag:N,onNodeDragStart:$,onSelectionDragStart:O,unselectNodesAndEdges:B}=t();c=!0,(!N||!_)&&!C&&S&&((V=T.get(S))!=null&&V.selected||B()),_&&N&&S&&(e==null||e(S));const W=co(I.sourceEvent,{transform:z,snapGrid:R,snapToGrid:j,containerBounds:p});if(i=W,l=QS(T,L,W,S),l.size>0&&(n||$||!S&&O)){const[Y,X]=Al({nodeId:S,dragItems:l,nodeLookup:T});n==null||n(I.sourceEvent,l,Y,X),$==null||$(I.sourceEvent,Y,X),S||O==null||O(I.sourceEvent,X)}}const P=Tg().clickDistance(b).on("start",I=>{const{domNode:T,nodeDragThreshold:C,transform:L,snapGrid:z,snapToGrid:R}=t();p=(T==null?void 0:T.getBoundingClientRect())||null,x=!1,y=!1,v=I.sourceEvent,C===0&&D(I),i=co(I.sourceEvent,{transform:L,snapGrid:z,snapToGrid:R,containerBounds:p}),u=dt(I.sourceEvent,p)}).on("drag",I=>{const{autoPanOnNodeDrag:T,transform:C,snapGrid:L,snapToGrid:z,nodeDragThreshold:R,nodeLookup:j}=t(),N=co(I.sourceEvent,{transform:C,snapGrid:L,snapToGrid:z,containerBounds:p});if(v=I.sourceEvent,(I.sourceEvent.type==="touchmove"&&I.sourceEvent.touches.length>1||S&&!j.has(S))&&(x=!0),!x){if(!a&&T&&c&&(a=!0,A()),!c){const $=dt(I.sourceEvent,p),O=$.x-u.x,B=$.y-u.y;Math.sqrt(O*O+B*B)>R&&D(I)}(i.x!==N.xSnapped||i.y!==N.ySnapped)&&l&&c&&(u=dt(I.sourceEvent,p),E(N))}}).on("end",I=>{if(!(!c||x)&&(a=!1,c=!1,cancelAnimationFrame(s),l.size>0)){const{nodeLookup:T,updateNodePositions:C,onNodeDragStop:L,onSelectionDragStop:z}=t();if(y&&(C(l,!1),y=!1),o||L||!S&&z){const[R,j]=Al({nodeId:S,dragItems:l,nodeLookup:T,dragging:!1});o==null||o(I.sourceEvent,l,R,j),L==null||L(I.sourceEvent,R,j),S||z==null||z(I.sourceEvent,j)}}}).filter(I=>{const T=I.target;return!I.button&&(!g||!gf(T,`.${g}`,w))&&(!h||gf(T,h,w))});f.call(P)}function m(){f==null||f.on(".drag",null)}return{update:k,destroy:m}}function ZS(e,t,n){const r=[],o={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())Lo(o,kr(i))>0&&r.push(i);return r}const qS=250;function JS(e,t,n,r){var l,a;let o=[],i=1/0;const s=ZS(e,n,t+qS);for(const u of s){const p=[...((l=u.internals.handleBounds)==null?void 0:l.source)??[],...((a=u.internals.handleBounds)==null?void 0:a.target)??[]];for(const c of p){if(r.nodeId===c.nodeId&&r.type===c.type&&r.id===c.id)continue;const{x:f,y:x}=Ln(u,c,c.position,!0),y=Math.sqrt(Math.pow(f-e.x,2)+Math.pow(x-e.y,2));y>t||(y1){const u=r.type==="source"?"target":"source";return o.find(p=>p.type===u)??o[0]}return o[0]}function gm(e,t,n,r,o,i=!1){var u,p,c;const s=r.get(e);if(!s)return null;const l=o==="strict"?(u=s.internals.handleBounds)==null?void 0:u[t]:[...((p=s.internals.handleBounds)==null?void 0:p.source)??[],...((c=s.internals.handleBounds)==null?void 0:c.target)??[]],a=(n?l==null?void 0:l.find(f=>f.id===n):l==null?void 0:l[0])??null;return a&&i?{...a,...Ln(s,a,a.position,!0)}:a}function mm(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function ek(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const ym=()=>!0;function tk(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:o,edgeUpdaterType:i,isTarget:s,domNode:l,nodeLookup:a,lib:u,autoPanOnConnect:p,flowId:c,panBy:f,cancelConnection:x,onConnectStart:y,onConnect:v,onConnectEnd:k,isValidConnection:m=ym,onReconnectEnd:g,updateConnection:h,getTransform:w,getFromHandle:_,autoPanSpeed:S,dragThreshold:b=1,handleDomNode:E}){const A=om(e.target);let D=0,P;const{x:I,y:T}=dt(e),C=mm(i,E),L=l==null?void 0:l.getBoundingClientRect();let z=!1;if(!L||!C)return;const R=gm(o,C,r,a,t);if(!R)return;let j=dt(e,L),N=!1,$=null,O=!1,B=null;function W(){if(!p||!L)return;const[G,J]=em(j,L,S);f({x:G,y:J}),D=requestAnimationFrame(W)}const V={...R,nodeId:o,type:C,position:R.position},Y=a.get(o);let Q={inProgress:!0,isValid:null,from:Ln(Y,V,q.Left,!0),fromHandle:V,fromPosition:V.position,fromNode:Y,to:j,toHandle:null,toPosition:nf[V.position],toNode:null,pointer:j};function H(){z=!0,h(Q),y==null||y(e,{nodeId:o,handleId:r,handleType:C})}b===0&&H();function K(G){if(!z){const{x:Ne,y:Vt}=dt(G),Nt=Ne-I,gn=Vt-T;if(!(Nt*Nt+gn*gn>b*b))return;H()}if(!_()||!V){ee(G);return}const J=w();j=dt(G,L),P=JS(Go(j,J,!1,[1,1]),n,a,V),N||(W(),N=!0);const Z=xm(G,{handle:P,connectionMode:t,fromNodeId:o,fromHandleId:r,fromType:s?"target":"source",isValidConnection:m,doc:A,lib:u,flowId:c,nodeLookup:a});B=Z.handleDomNode,$=Z.connection,O=ek(!!P,Z.isValid);const re=a.get(o),le=re?Ln(re,V,q.Left,!0):Q.from,ie={...Q,from:le,isValid:O,to:Z.toHandle&&O?Es({x:Z.toHandle.x,y:Z.toHandle.y},J):j,toHandle:Z.toHandle,toPosition:O&&Z.toHandle?Z.toHandle.position:nf[V.position],toNode:Z.toHandle?a.get(Z.toHandle.nodeId):null,pointer:j};h(ie),Q=ie}function ee(G){if(!("touches"in G&&G.touches.length>0)){if(z){(P||B)&&$&&O&&(v==null||v($));const{inProgress:J,...Z}=Q,re={...Z,toPosition:Q.toHandle?Q.toPosition:null};k==null||k(G,re),i&&(g==null||g(G,re))}x(),cancelAnimationFrame(D),N=!1,O=!1,$=null,B=null,A.removeEventListener("mousemove",K),A.removeEventListener("mouseup",ee),A.removeEventListener("touchmove",K),A.removeEventListener("touchend",ee)}}A.addEventListener("mousemove",K),A.addEventListener("mouseup",ee),A.addEventListener("touchmove",K),A.addEventListener("touchend",ee)}function xm(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:o,fromType:i,doc:s,lib:l,flowId:a,isValidConnection:u=ym,nodeLookup:p}){const c=i==="target",f=t?s.querySelector(`.${l}-flow__handle[data-id="${a}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x,y}=dt(e),v=s.elementFromPoint(x,y),k=v!=null&&v.classList.contains(`${l}-flow__handle`)?v:f,m={handleDomNode:k,isValid:!1,connection:null,toHandle:null};if(k){const g=mm(void 0,k),h=k.getAttribute("data-nodeid"),w=k.getAttribute("data-handleid"),_=k.classList.contains("connectable"),S=k.classList.contains("connectableend");if(!h||!g)return m;const b={source:c?h:r,sourceHandle:c?w:o,target:c?r:h,targetHandle:c?o:w};m.connection=b;const A=_&&S&&(n===wr.Strict?c&&g==="source"||!c&&g==="target":h!==r||w!==o);m.isValid=A&&u(b),m.toHandle=gm(h,g,w,p,n,!0)}return m}const nu={onPointerDown:tk,isValid:xm};function nk({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const o=Ue(e);function i({translateExtent:l,width:a,height:u,zoomStep:p=1,pannable:c=!0,zoomable:f=!0,inversePan:x=!1}){const y=h=>{if(h.sourceEvent.type!=="wheel"||!t)return;const w=n(),_=h.sourceEvent.ctrlKey&&Ao()?10:1,S=-h.sourceEvent.deltaY*(h.sourceEvent.deltaMode===1?.05:h.sourceEvent.deltaMode?1:.002)*p,b=w[2]*Math.pow(2,S*_);t.scaleTo(b)};let v=[0,0];const k=h=>{(h.sourceEvent.type==="mousedown"||h.sourceEvent.type==="touchstart")&&(v=[h.sourceEvent.clientX??h.sourceEvent.touches[0].clientX,h.sourceEvent.clientY??h.sourceEvent.touches[0].clientY])},m=h=>{const w=n();if(h.sourceEvent.type!=="mousemove"&&h.sourceEvent.type!=="touchmove"||!t)return;const _=[h.sourceEvent.clientX??h.sourceEvent.touches[0].clientX,h.sourceEvent.clientY??h.sourceEvent.touches[0].clientY],S=[_[0]-v[0],_[1]-v[1]];v=_;const b=r()*Math.max(w[2],Math.log(w[2]))*(x?-1:1),E={x:w[0]-S[0]*b,y:w[1]-S[1]*b},A=[[0,0],[a,u]];t.setViewportConstrained({x:E.x,y:E.y,zoom:w[2]},A,l)},g=Yg().on("start",k).on("zoom",c?m:null).on("zoom.wheel",f?y:null);o.call(g,{})}function s(){o.on("zoom",null)}return{update:i,destroy:s,pointer:lt}}const Zs=e=>({x:e.x,y:e.y,zoom:e.k}),$l=({x:e,y:t,zoom:n})=>Qs.translate(e,t).scale(n),tr=(e,t)=>e.target.closest(`.${t}`),vm=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),rk=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Dl=(e,t=0,n=rk,r=()=>{})=>{const o=typeof t=="number"&&t>0;return o||r(),o?e.transition().duration(t).ease(n).on("end",r):e},wm=e=>{const t=e.ctrlKey&&Ao()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function ok({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:o,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:l,onPanZoom:a,onPanZoomEnd:u}){return p=>{if(tr(p,t))return p.ctrlKey&&p.preventDefault(),!1;p.preventDefault(),p.stopImmediatePropagation();const c=n.property("__zoom").k||1;if(p.ctrlKey&&s){const k=lt(p),m=wm(p),g=c*Math.pow(2,m);r.scaleTo(n,g,k,p);return}const f=p.deltaMode===1?20:1;let x=o===En.Vertical?0:p.deltaX*f,y=o===En.Horizontal?0:p.deltaY*f;!Ao()&&p.shiftKey&&o!==En.Vertical&&(x=p.deltaY*f,y=0),r.translateBy(n,-(x/c)*i,-(y/c)*i,{internal:!0});const v=Zs(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(a==null||a(p,v),e.panScrollTimeout=setTimeout(()=>{u==null||u(p,v),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l==null||l(p,v))}}function ik({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,o){const i=r.type==="wheel",s=!t&&i&&!r.ctrlKey,l=tr(r,e);if(r.ctrlKey&&i&&l&&r.preventDefault(),s||l)return null;r.preventDefault(),n.call(this,r,o)}}function sk({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var i,s,l;if((i=r.sourceEvent)!=null&&i.internal)return;const o=Zs(r.transform);e.mouseButton=((s=r.sourceEvent)==null?void 0:s.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=o,((l=r.sourceEvent)==null?void 0:l.type)==="mousedown"&&t(!0),n&&(n==null||n(r.sourceEvent,o))}}function lk({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:o}){return i=>{var s,l;e.usedRightMouseButton=!!(n&&vm(t,e.mouseButton??0)),(s=i.sourceEvent)!=null&&s.sync||r([i.transform.x,i.transform.y,i.transform.k]),o&&!((l=i.sourceEvent)!=null&&l.internal)&&(o==null||o(i.sourceEvent,Zs(i.transform)))}}function ak({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:o,onPaneContextMenu:i}){return s=>{var l;if(!((l=s.sourceEvent)!=null&&l.internal)&&(e.isZoomingOrPanning=!1,i&&vm(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,r(!1),o)){const a=Zs(s.transform);e.prevViewport=a,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o==null||o(s.sourceEvent,a)},n?150:0)}}}function uk({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:o,zoomOnDoubleClick:i,userSelectionActive:s,noWheelClassName:l,noPanClassName:a,lib:u,connectionInProgress:p}){return c=>{var k;const f=e||t,x=n&&c.ctrlKey,y=c.type==="wheel";if(c.button===1&&c.type==="mousedown"&&(tr(c,`${u}-flow__node`)||tr(c,`${u}-flow__edge`)))return!0;if(!r&&!f&&!o&&!i&&!n||s||p&&!y||tr(c,l)&&y||tr(c,a)&&(!y||o&&y&&!e)||!n&&c.ctrlKey&&y)return!1;if(!n&&c.type==="touchstart"&&((k=c.touches)==null?void 0:k.length)>1)return c.preventDefault(),!1;if(!f&&!o&&!x&&y||!r&&(c.type==="mousedown"||c.type==="touchstart")||Array.isArray(r)&&!r.includes(c.button)&&c.type==="mousedown")return!1;const v=Array.isArray(r)&&r.includes(c.button)||!c.button||c.button<=1;return(!c.ctrlKey||y)&&v}}function ck({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:o,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:l,onDraggingChange:a}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},p=e.getBoundingClientRect(),c=Yg().scaleExtent([t,n]).translateExtent(r),f=Ue(e).call(c);g({x:o.x,y:o.y,zoom:Sr(o.zoom,t,n)},[[0,0],[p.width,p.height]],r);const x=f.on("wheel.zoom"),y=f.on("dblclick.zoom");c.wheelDelta(wm);function v(P,I){return f?new Promise(T=>{c==null||c.interpolate((I==null?void 0:I.interpolate)==="linear"?uo:Vi).transform(Dl(f,I==null?void 0:I.duration,I==null?void 0:I.ease,()=>T(!0)),P)}):Promise.resolve(!1)}function k({noWheelClassName:P,noPanClassName:I,onPaneContextMenu:T,userSelectionActive:C,panOnScroll:L,panOnDrag:z,panOnScrollMode:R,panOnScrollSpeed:j,preventScrolling:N,zoomOnPinch:$,zoomOnScroll:O,zoomOnDoubleClick:B,zoomActivationKeyPressed:W,lib:V,onTransformChange:Y,connectionInProgress:X,paneClickDistance:Q,selectionOnDrag:H}){C&&!u.isZoomingOrPanning&&m();const K=L&&!W&&!C;c.clickDistance(H?1/0:!ct(Q)||Q<0?0:Q);const ee=K?ok({zoomPanValues:u,noWheelClassName:P,d3Selection:f,d3Zoom:c,panOnScrollMode:R,panOnScrollSpeed:j,zoomOnPinch:$,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:l}):ik({noWheelClassName:P,preventScrolling:N,d3ZoomHandler:x});if(f.on("wheel.zoom",ee,{passive:!1}),!C){const J=sk({zoomPanValues:u,onDraggingChange:a,onPanZoomStart:s});c.on("start",J);const Z=lk({zoomPanValues:u,panOnDrag:z,onPaneContextMenu:!!T,onPanZoom:i,onTransformChange:Y});c.on("zoom",Z);const re=ak({zoomPanValues:u,panOnDrag:z,panOnScroll:L,onPaneContextMenu:T,onPanZoomEnd:l,onDraggingChange:a});c.on("end",re)}const G=uk({zoomActivationKeyPressed:W,panOnDrag:z,zoomOnScroll:O,panOnScroll:L,zoomOnDoubleClick:B,zoomOnPinch:$,userSelectionActive:C,noPanClassName:I,noWheelClassName:P,lib:V,connectionInProgress:X});c.filter(G),B?f.on("dblclick.zoom",y):f.on("dblclick.zoom",null)}function m(){c.on("zoom",null)}async function g(P,I,T){const C=$l(P),L=c==null?void 0:c.constrain()(C,I,T);return L&&await v(L),new Promise(z=>z(L))}async function h(P,I){const T=$l(P);return await v(T,I),new Promise(C=>C(T))}function w(P){if(f){const I=$l(P),T=f.property("__zoom");(T.k!==P.zoom||T.x!==P.x||T.y!==P.y)&&(c==null||c.transform(f,I,null,{sync:!0}))}}function _(){const P=f?Ug(f.node()):{x:0,y:0,k:1};return{x:P.x,y:P.y,zoom:P.k}}function S(P,I){return f?new Promise(T=>{c==null||c.interpolate((I==null?void 0:I.interpolate)==="linear"?uo:Vi).scaleTo(Dl(f,I==null?void 0:I.duration,I==null?void 0:I.ease,()=>T(!0)),P)}):Promise.resolve(!1)}function b(P,I){return f?new Promise(T=>{c==null||c.interpolate((I==null?void 0:I.interpolate)==="linear"?uo:Vi).scaleBy(Dl(f,I==null?void 0:I.duration,I==null?void 0:I.ease,()=>T(!0)),P)}):Promise.resolve(!1)}function E(P){c==null||c.scaleExtent(P)}function A(P){c==null||c.translateExtent(P)}function D(P){const I=!ct(P)||P<0?0:P;c==null||c.clickDistance(I)}return{update:k,destroy:m,setViewport:h,setViewportConstrained:g,getViewport:_,scaleTo:S,scaleBy:b,setScaleExtent:E,setTranslateExtent:A,syncViewport:w,setClickDistance:D}}var An;(function(e){e.Line="line",e.Handle="handle"})(An||(An={}));const dk=["top-left","top-right","bottom-left","bottom-right"],fk=["top","right","bottom","left"];function pk({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:o,affectsY:i}){const s=e-t,l=n-r,a=[s>0?1:s<0?-1:0,l>0?1:l<0?-1:0];return s&&o&&(a[0]=a[0]*-1),l&&i&&(a[1]=a[1]*-1),a}function mf(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),o=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:o}}function Ut(e,t){return Math.max(0,t-e)}function Yt(e,t){return Math.max(0,e-t)}function Si(e,t,n){return Math.max(0,t-e,e-n)}function yf(e,t){return e?!t:t}function hk(e,t,n,r,o,i,s,l){let{affectsX:a,affectsY:u}=t;const{isHorizontal:p,isVertical:c}=t,f=p&&c,{xSnapped:x,ySnapped:y}=n,{minWidth:v,maxWidth:k,minHeight:m,maxHeight:g}=r,{x:h,y:w,width:_,height:S,aspectRatio:b}=e;let E=Math.floor(p?x-e.pointerX:0),A=Math.floor(c?y-e.pointerY:0);const D=_+(a?-E:E),P=S+(u?-A:A),I=-i[0]*_,T=-i[1]*S;let C=Si(D,v,k),L=Si(P,m,g);if(s){let j=0,N=0;a&&E<0?j=Ut(h+E+I,s[0][0]):!a&&E>0&&(j=Yt(h+D+I,s[1][0])),u&&A<0?N=Ut(w+A+T,s[0][1]):!u&&A>0&&(N=Yt(w+P+T,s[1][1])),C=Math.max(C,j),L=Math.max(L,N)}if(l){let j=0,N=0;a&&E>0?j=Yt(h+E,l[0][0]):!a&&E<0&&(j=Ut(h+D,l[1][0])),u&&A>0?N=Yt(w+A,l[0][1]):!u&&A<0&&(N=Ut(w+P,l[1][1])),C=Math.max(C,j),L=Math.max(L,N)}if(o){if(p){const j=Si(D/b,m,g)*b;if(C=Math.max(C,j),s){let N=0;!a&&!u||a&&!u&&f?N=Yt(w+T+D/b,s[1][1])*b:N=Ut(w+T+(a?E:-E)/b,s[0][1])*b,C=Math.max(C,N)}if(l){let N=0;!a&&!u||a&&!u&&f?N=Ut(w+D/b,l[1][1])*b:N=Yt(w+(a?E:-E)/b,l[0][1])*b,C=Math.max(C,N)}}if(c){const j=Si(P*b,v,k)/b;if(L=Math.max(L,j),s){let N=0;!a&&!u||u&&!a&&f?N=Yt(h+P*b+I,s[1][0])/b:N=Ut(h+(u?A:-A)*b+I,s[0][0])/b,L=Math.max(L,N)}if(l){let N=0;!a&&!u||u&&!a&&f?N=Ut(h+P*b,l[1][0])/b:N=Yt(h+(u?A:-A)*b,l[0][0])/b,L=Math.max(L,N)}}}A=A+(A<0?L:-L),E=E+(E<0?C:-C),o&&(f?D>P*b?A=(yf(a,u)?-E:E)/b:E=(yf(a,u)?-A:A)*b:p?(A=E/b,u=a):(E=A*b,a=u));const z=a?h+E:h,R=u?w+A:w;return{width:_+(a?-E:E),height:S+(u?-A:A),x:i[0]*E*(a?-1:1)+z,y:i[1]*A*(u?-1:1)+R}}const Sm={width:0,height:0,x:0,y:0},gk={...Sm,pointerX:0,pointerY:0,aspectRatio:1};function mk(e){return[[0,0],[e.measured.width,e.measured.height]]}function yk(e,t,n){const r=t.position.x+e.position.x,o=t.position.y+e.position.y,i=e.measured.width??0,s=e.measured.height??0,l=n[0]*i,a=n[1]*s;return[[r-l,o-a],[r+i-l,o+s-a]]}function xk({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:o}){const i=Ue(e);let s={controlDirection:mf("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:p,keepAspectRatio:c,resizeDirection:f,onResizeStart:x,onResize:y,onResizeEnd:v,shouldResize:k}){let m={...Sm},g={...gk};s={boundaries:p,resizeDirection:f,keepAspectRatio:c,controlDirection:mf(u)};let h,w=null,_=[],S,b,E,A=!1;const D=Tg().on("start",P=>{const{nodeLookup:I,transform:T,snapGrid:C,snapToGrid:L,nodeOrigin:z,paneDomNode:R}=n();if(h=I.get(t),!h)return;w=(R==null?void 0:R.getBoundingClientRect())??null;const{xSnapped:j,ySnapped:N}=co(P.sourceEvent,{transform:T,snapGrid:C,snapToGrid:L,containerBounds:w});m={width:h.measured.width??0,height:h.measured.height??0,x:h.position.x??0,y:h.position.y??0},g={...m,pointerX:j,pointerY:N,aspectRatio:m.width/m.height},S=void 0,h.parentId&&(h.extent==="parent"||h.expandParent)&&(S=I.get(h.parentId),b=S&&h.extent==="parent"?mk(S):void 0),_=[],E=void 0;for(const[$,O]of I)if(O.parentId===t&&(_.push({id:$,position:{...O.position},extent:O.extent}),O.extent==="parent"||O.expandParent)){const B=yk(O,h,O.origin??z);E?E=[[Math.min(B[0][0],E[0][0]),Math.min(B[0][1],E[0][1])],[Math.max(B[1][0],E[1][0]),Math.max(B[1][1],E[1][1])]]:E=B}x==null||x(P,{...m})}).on("drag",P=>{const{transform:I,snapGrid:T,snapToGrid:C,nodeOrigin:L}=n(),z=co(P.sourceEvent,{transform:I,snapGrid:T,snapToGrid:C,containerBounds:w}),R=[];if(!h)return;const{x:j,y:N,width:$,height:O}=m,B={},W=h.origin??L,{width:V,height:Y,x:X,y:Q}=hk(g,s.controlDirection,z,s.boundaries,s.keepAspectRatio,W,b,E),H=V!==$,K=Y!==O,ee=X!==j&&H,G=Q!==N&&K;if(!ee&&!G&&!H&&!K)return;if((ee||G||W[0]===1||W[1]===1)&&(B.x=ee?X:m.x,B.y=G?Q:m.y,m.x=B.x,m.y=B.y,_.length>0)){const le=X-j,ie=Q-N;for(const Ne of _)Ne.position={x:Ne.position.x-le+W[0]*(V-$),y:Ne.position.y-ie+W[1]*(Y-O)},R.push(Ne)}if((H||K)&&(B.width=H&&(!s.resizeDirection||s.resizeDirection==="horizontal")?V:m.width,B.height=K&&(!s.resizeDirection||s.resizeDirection==="vertical")?Y:m.height,m.width=B.width,m.height=B.height),S&&h.expandParent){const le=W[0]*(B.width??0);B.x&&B.x{A&&(v==null||v(P,{...m}),o==null||o({...m}),A=!1)});i.call(D)}function a(){i.on(".drag",null)}return{update:l,destroy:a}}var km={exports:{}},_m={},bm={exports:{}},Cm={};/** - * @license React - * use-sync-external-store-shim.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var br=M;function vk(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var wk=typeof Object.is=="function"?Object.is:vk,Sk=br.useState,kk=br.useEffect,_k=br.useLayoutEffect,bk=br.useDebugValue;function Ck(e,t){var n=t(),r=Sk({inst:{value:n,getSnapshot:t}}),o=r[0].inst,i=r[1];return _k(function(){o.value=n,o.getSnapshot=t,Ol(o)&&i({inst:o})},[e,n,t]),kk(function(){return Ol(o)&&i({inst:o}),e(function(){Ol(o)&&i({inst:o})})},[e]),bk(n),n}function Ol(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!wk(e,n)}catch{return!0}}function Ek(e,t){return t()}var jk=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Ek:Ck;Cm.useSyncExternalStore=br.useSyncExternalStore!==void 0?br.useSyncExternalStore:jk;bm.exports=Cm;var Nk=bm.exports;/** - * @license React - * use-sync-external-store-shim/with-selector.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var qs=M,Mk=Nk;function zk(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Tk=typeof Object.is=="function"?Object.is:zk,Pk=Mk.useSyncExternalStore,Ik=qs.useRef,Rk=qs.useEffect,Lk=qs.useMemo,Ak=qs.useDebugValue;_m.useSyncExternalStoreWithSelector=function(e,t,n,r,o){var i=Ik(null);if(i.current===null){var s={hasValue:!1,value:null};i.current=s}else s=i.current;i=Lk(function(){function a(x){if(!u){if(u=!0,p=x,x=r(x),o!==void 0&&s.hasValue){var y=s.value;if(o(y,x))return c=y}return c=x}if(y=c,Tk(p,x))return y;var v=r(x);return o!==void 0&&o(y,v)?(p=x,y):(p=x,c=v)}var u=!1,p,c,f=n===void 0?null:n;return[function(){return a(t())},f===null?void 0:function(){return a(f())}]},[t,n,r,o]);var l=Pk(e,i[0],i[1]);return Rk(function(){s.hasValue=!0,s.value=l},[l]),Ak(l),l};km.exports=_m;var $k=km.exports;const Dk=rp($k),Ok={},xf=e=>{let t;const n=new Set,r=(p,c)=>{const f=typeof p=="function"?p(t):p;if(!Object.is(f,t)){const x=t;t=c??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(y=>y(t,x))}},o=()=>t,a={setState:r,getState:o,getInitialState:()=>u,subscribe:p=>(n.add(p),()=>n.delete(p)),destroy:()=>{(Ok?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},u=t=e(r,o,a);return a},Bk=e=>e?xf(e):xf,{useDebugValue:Fk}=hp,{useSyncExternalStoreWithSelector:Hk}=Dk,Vk=e=>e;function Em(e,t=Vk,n){const r=Hk(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Fk(r),r}const vf=(e,t)=>{const n=Bk(e),r=(o,i=t)=>Em(n,o,i);return Object.assign(r,n),r},Wk=(e,t)=>e?vf(e,t):vf;function fe(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,o]of e)if(!Object.is(o,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}const Js=M.createContext(null),Uk=Js.Provider,jm=Et.error001();function ne(e,t){const n=M.useContext(Js);if(n===null)throw new Error(jm);return Em(n,e,t)}function pe(){const e=M.useContext(Js);if(e===null)throw new Error(jm);return M.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const wf={display:"none"},Yk={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Nm="react-flow__node-desc",Mm="react-flow__edge-desc",Xk="react-flow__aria-live",Qk=e=>e.ariaLiveMessage,Gk=e=>e.ariaLabelConfig;function Kk({rfId:e}){const t=ne(Qk);return d.jsx("div",{id:`${Xk}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Yk,children:t})}function Zk({rfId:e,disableKeyboardA11y:t}){const n=ne(Gk);return d.jsxs(d.Fragment,{children:[d.jsx("div",{id:`${Nm}-${e}`,style:wf,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),d.jsx("div",{id:`${Mm}-${e}`,style:wf,children:n["edge.a11yDescription.default"]}),!t&&d.jsx(Kk,{rfId:e})]})}const el=M.forwardRef(({position:e="top-left",children:t,className:n,style:r,...o},i)=>{const s=`${e}`.split("-");return d.jsx("div",{className:we(["react-flow__panel",n,...s]),style:r,ref:i,...o,children:t})});el.displayName="Panel";function qk({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:d.jsx(el,{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:d.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Jk=e=>{const t=[],n=[];for(const[,r]of e.nodeLookup)r.selected&&t.push(r.internals.userNode);for(const[,r]of e.edgeLookup)r.selected&&n.push(r);return{selectedNodes:t,selectedEdges:n}},ki=e=>e.id;function e_(e,t){return fe(e.selectedNodes.map(ki),t.selectedNodes.map(ki))&&fe(e.selectedEdges.map(ki),t.selectedEdges.map(ki))}function t_({onSelectionChange:e}){const t=pe(),{selectedNodes:n,selectedEdges:r}=ne(Jk,e_);return M.useEffect(()=>{const o={nodes:n,edges:r};e==null||e(o),t.getState().onSelectionChangeHandlers.forEach(i=>i(o))},[n,r,e]),null}const n_=e=>!!e.onSelectionChangeHandlers;function r_({onSelectionChange:e}){const t=ne(n_);return e||t?d.jsx(t_,{onSelectionChange:e}):null}const zm=[0,0],o_={x:0,y:0,zoom:1},i_=["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"],Sf=[...i_,"rfId"],s_=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}),kf={translateExtent:Io,nodeOrigin:zm,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function l_(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:o,setTranslateExtent:i,setNodeExtent:s,reset:l,setDefaultNodesAndEdges:a}=ne(s_,fe),u=pe();M.useEffect(()=>(a(e.defaultNodes,e.defaultEdges),()=>{p.current=kf,l()}),[]);const p=M.useRef(kf);return M.useEffect(()=>{for(const c of Sf){const f=e[c],x=p.current[c];f!==x&&(typeof e[c]>"u"||(c==="nodes"?t(f):c==="edges"?n(f):c==="minZoom"?r(f):c==="maxZoom"?o(f):c==="translateExtent"?i(f):c==="nodeExtent"?s(f):c==="ariaLabelConfig"?u.setState({ariaLabelConfig:NS(f)}):c==="fitView"?u.setState({fitViewQueued:f}):c==="fitViewOptions"?u.setState({fitViewOptions:f}):u.setState({[c]:f})))}p.current=e},Sf.map(c=>e[c])),null}function _f(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function a_(e){var r;const[t,n]=M.useState(e==="system"?null:e);return M.useEffect(()=>{if(e!=="system"){n(e);return}const o=_f(),i=()=>n(o!=null&&o.matches?"dark":"light");return i(),o==null||o.addEventListener("change",i),()=>{o==null||o.removeEventListener("change",i)}},[e]),t!==null?t:(r=_f())!=null&&r.matches?"dark":"light"}const bf=typeof document<"u"?document:null;function $o(e=null,t={target:bf,actInsideInputWithModifier:!0}){const[n,r]=M.useState(!1),o=M.useRef(!1),i=M.useRef(new Set([])),[s,l]=M.useMemo(()=>{if(e!==null){const u=(Array.isArray(e)?e:[e]).filter(c=>typeof c=="string").map(c=>c.replace("+",` -`).replace(` - -`,` -+`).split(` -`)),p=u.reduce((c,f)=>c.concat(...f),[]);return[u,p]}return[[],[]]},[e]);return M.useEffect(()=>{const a=(t==null?void 0:t.target)??bf,u=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const p=x=>{var k,m;if(o.current=x.ctrlKey||x.metaKey||x.shiftKey||x.altKey,(!o.current||o.current&&!u)&&im(x))return!1;const v=Ef(x.code,l);if(i.current.add(x[v]),Cf(s,i.current,!1)){const g=((m=(k=x.composedPath)==null?void 0:k.call(x))==null?void 0:m[0])||x.target,h=(g==null?void 0:g.nodeName)==="BUTTON"||(g==null?void 0:g.nodeName)==="A";t.preventDefault!==!1&&(o.current||!h)&&x.preventDefault(),r(!0)}},c=x=>{const y=Ef(x.code,l);Cf(s,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(x[y]),x.key==="Meta"&&i.current.clear(),o.current=!1},f=()=>{i.current.clear(),r(!1)};return a==null||a.addEventListener("keydown",p),a==null||a.addEventListener("keyup",c),window.addEventListener("blur",f),window.addEventListener("contextmenu",f),()=>{a==null||a.removeEventListener("keydown",p),a==null||a.removeEventListener("keyup",c),window.removeEventListener("blur",f),window.removeEventListener("contextmenu",f)}}},[e,r]),n}function Cf(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(o=>t.has(o)))}function Ef(e,t){return t.includes(e)?"code":"key"}const u_=()=>{const e=pe();return M.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,{duration:n==null?void 0:n.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,o,i],panZoom:s}=e.getState();return s?(await s.setViewport({x:t.x??r,y:t.y??o,zoom:t.zoom??i},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:o,minZoom:i,maxZoom:s,panZoom:l}=e.getState(),a=dc(t,r,o,i,s,(n==null?void 0:n.padding)??.1);return l?(await l.setViewport(a,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:o,snapToGrid:i,domNode:s}=e.getState();if(!s)return t;const{x:l,y:a}=s.getBoundingClientRect(),u={x:t.x-l,y:t.y-a},p=n.snapGrid??o,c=n.snapToGrid??i;return Go(u,r,c,p)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:o,y:i}=r.getBoundingClientRect(),s=Es(t,n);return{x:s.x+o,y:s.y+i}}}),[])};function Tm(e,t){const n=[],r=new Map,o=[];for(const i of e)if(i.type==="add"){o.push(i);continue}else if(i.type==="remove"||i.type==="replace")r.set(i.id,[i]);else{const s=r.get(i.id);s?s.push(i):r.set(i.id,[i])}for(const i of t){const s=r.get(i.id);if(!s){n.push(i);continue}if(s[0].type==="remove")continue;if(s[0].type==="replace"){n.push({...s[0].item});continue}const l={...i};for(const a of s)c_(a,l);n.push(l)}return o.length&&o.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function c_(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function Pm(e,t){return Tm(e,t)}function Im(e,t){return Tm(e,t)}function xn(e,t){return{id:e,type:"select",selected:t}}function nr(e,t=new Set,n=!1){const r=[];for(const[o,i]of e){const s=t.has(o);!(i.selected===void 0&&!s)&&i.selected!==s&&(n&&(i.selected=s),r.push(xn(i.id,s)))}return r}function jf({items:e=[],lookup:t}){var o;const n=[],r=new Map(e.map(i=>[i.id,i]));for(const[i,s]of e.entries()){const l=t.get(s.id),a=((o=l==null?void 0:l.internals)==null?void 0:o.userNode)??l;a!==void 0&&a!==s&&n.push({id:s.id,item:s,type:"replace"}),a===void 0&&n.push({item:s,type:"add",index:i})}for(const[i]of t)r.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function Nf(e){return{id:e.id,type:"remove"}}const Mf=e=>xS(e),d_=e=>Zg(e);function Rm(e){return M.forwardRef(e)}const f_=typeof window<"u"?M.useLayoutEffect:M.useEffect;function zf(e){const[t,n]=M.useState(BigInt(0)),[r]=M.useState(()=>p_(()=>n(o=>o+BigInt(1))));return f_(()=>{const o=r.get();o.length&&(e(o),r.reset())},[t]),r}function p_(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const Lm=M.createContext(null);function h_({children:e}){const t=pe(),n=M.useCallback(l=>{const{nodes:a=[],setNodes:u,hasDefaultNodes:p,onNodesChange:c,nodeLookup:f,fitViewQueued:x,onNodesChangeMiddlewareMap:y}=t.getState();let v=a;for(const m of l)v=typeof m=="function"?m(v):m;let k=jf({items:v,lookup:f});for(const m of y.values())k=m(k);p&&u(v),k.length>0?c==null||c(k):x&&window.requestAnimationFrame(()=>{const{fitViewQueued:m,nodes:g,setNodes:h}=t.getState();m&&h(g)})},[]),r=zf(n),o=M.useCallback(l=>{const{edges:a=[],setEdges:u,hasDefaultEdges:p,onEdgesChange:c,edgeLookup:f}=t.getState();let x=a;for(const y of l)x=typeof y=="function"?y(x):y;p?u(x):c&&c(jf({items:x,lookup:f}))},[]),i=zf(o),s=M.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return d.jsx(Lm.Provider,{value:s,children:e})}function g_(){const e=M.useContext(Lm);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const m_=e=>!!e.panZoom;function xc(){const e=u_(),t=pe(),n=g_(),r=ne(m_),o=M.useMemo(()=>{const i=c=>t.getState().nodeLookup.get(c),s=c=>{n.nodeQueue.push(c)},l=c=>{n.edgeQueue.push(c)},a=c=>{var m,g;const{nodeLookup:f,nodeOrigin:x}=t.getState(),y=Mf(c)?c:f.get(c.id),v=y.parentId?rm(y.position,y.measured,y.parentId,f,x):y.position,k={...y,position:v,width:((m=y.measured)==null?void 0:m.width)??y.width,height:((g=y.measured)==null?void 0:g.height)??y.height};return kr(k)},u=(c,f,x={replace:!1})=>{s(y=>y.map(v=>{if(v.id===c){const k=typeof f=="function"?f(v):f;return x.replace&&Mf(k)?k:{...v,...k}}return v}))},p=(c,f,x={replace:!1})=>{l(y=>y.map(v=>{if(v.id===c){const k=typeof f=="function"?f(v):f;return x.replace&&d_(k)?k:{...v,...k}}return v}))};return{getNodes:()=>t.getState().nodes.map(c=>({...c})),getNode:c=>{var f;return(f=i(c))==null?void 0:f.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:c=[]}=t.getState();return c.map(f=>({...f}))},getEdge:c=>t.getState().edgeLookup.get(c),setNodes:s,setEdges:l,addNodes:c=>{const f=Array.isArray(c)?c:[c];n.nodeQueue.push(x=>[...x,...f])},addEdges:c=>{const f=Array.isArray(c)?c:[c];n.edgeQueue.push(x=>[...x,...f])},toObject:()=>{const{nodes:c=[],edges:f=[],transform:x}=t.getState(),[y,v,k]=x;return{nodes:c.map(m=>({...m})),edges:f.map(m=>({...m})),viewport:{x:y,y:v,zoom:k}}},deleteElements:async({nodes:c=[],edges:f=[]})=>{const{nodes:x,edges:y,onNodesDelete:v,onEdgesDelete:k,triggerNodeChanges:m,triggerEdgeChanges:g,onDelete:h,onBeforeDelete:w}=t.getState(),{nodes:_,edges:S}=await _S({nodesToRemove:c,edgesToRemove:f,nodes:x,edges:y,onBeforeDelete:w}),b=S.length>0,E=_.length>0;if(b){const A=S.map(Nf);k==null||k(S),g(A)}if(E){const A=_.map(Nf);v==null||v(_),m(A)}return(E||b)&&(h==null||h({nodes:_,edges:S})),{deletedNodes:_,deletedEdges:S}},getIntersectingNodes:(c,f=!0,x)=>{const y=of(c),v=y?c:a(c),k=x!==void 0;return v?(x||t.getState().nodes).filter(m=>{const g=t.getState().nodeLookup.get(m.id);if(g&&!y&&(m.id===c.id||!g.internals.positionAbsolute))return!1;const h=kr(k?m:g),w=Lo(h,v);return f&&w>0||w>=h.width*h.height||w>=v.width*v.height}):[]},isNodeIntersecting:(c,f,x=!0)=>{const v=of(c)?c:a(c);if(!v)return!1;const k=Lo(v,f);return x&&k>0||k>=f.width*f.height||k>=v.width*v.height},updateNode:u,updateNodeData:(c,f,x={replace:!1})=>{u(c,y=>{const v=typeof f=="function"?f(y):f;return x.replace?{...y,data:v}:{...y,data:{...y.data,...v}}},x)},updateEdge:p,updateEdgeData:(c,f,x={replace:!1})=>{p(c,y=>{const v=typeof f=="function"?f(y):f;return x.replace?{...y,data:v}:{...y,data:{...y.data,...v}}},x)},getNodesBounds:c=>{const{nodeLookup:f,nodeOrigin:x}=t.getState();return vS(c,{nodeLookup:f,nodeOrigin:x})},getHandleConnections:({type:c,id:f,nodeId:x})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${x}-${c}${f?`-${f}`:""}`))==null?void 0:y.values())??[])},getNodeConnections:({type:c,handleId:f,nodeId:x})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${x}${c?f?`-${c}-${f}`:`-${c}`:""}`))==null?void 0:y.values())??[])},fitView:async c=>{const f=t.getState().fitViewResolver??jS();return t.setState({fitViewQueued:!0,fitViewOptions:c,fitViewResolver:f}),n.nodeQueue.push(x=>[...x]),f.promise}}},[]);return M.useMemo(()=>({...o,...e,viewportInitialized:r}),[r])}const Tf=e=>e.selected,y_=typeof window<"u"?window:void 0;function x_({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=pe(),{deleteElements:r}=xc(),o=$o(e,{actInsideInputWithModifier:!1}),i=$o(t,{target:y_});M.useEffect(()=>{if(o){const{edges:s,nodes:l}=n.getState();r({nodes:l.filter(Tf),edges:s.filter(Tf)}),n.setState({nodesSelectionActive:!1})}},[o]),M.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function v_(e){const t=pe();M.useEffect(()=>{const n=()=>{var o,i,s,l;if(!e.current||!(((i=(o=e.current).checkVisibility)==null?void 0:i.call(o))??!0))return!1;const r=fc(e.current);(r.height===0||r.width===0)&&((l=(s=t.getState()).onError)==null||l.call(s,"004",Et.error004())),t.setState({width:r.width||500,height:r.height||500})};if(e.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(e.current),()=>{window.removeEventListener("resize",n),r&&e.current&&r.unobserve(e.current)}}},[])}const tl={position:"absolute",width:"100%",height:"100%",top:0,left:0},w_=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function S_({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:o=.5,panOnScrollMode:i=En.Free,zoomOnDoubleClick:s=!0,panOnDrag:l=!0,defaultViewport:a,translateExtent:u,minZoom:p,maxZoom:c,zoomActivationKeyCode:f,preventScrolling:x=!0,children:y,noWheelClassName:v,noPanClassName:k,onViewportChange:m,isControlledViewport:g,paneClickDistance:h,selectionOnDrag:w}){const _=pe(),S=M.useRef(null),{userSelectionActive:b,lib:E,connectionInProgress:A}=ne(w_,fe),D=$o(f),P=M.useRef();v_(S);const I=M.useCallback(T=>{m==null||m({x:T[0],y:T[1],zoom:T[2]}),g||_.setState({transform:T})},[m,g]);return M.useEffect(()=>{if(S.current){P.current=ck({domNode:S.current,minZoom:p,maxZoom:c,translateExtent:u,viewport:a,onDraggingChange:z=>_.setState(R=>R.paneDragging===z?R:{paneDragging:z}),onPanZoomStart:(z,R)=>{const{onViewportChangeStart:j,onMoveStart:N}=_.getState();N==null||N(z,R),j==null||j(R)},onPanZoom:(z,R)=>{const{onViewportChange:j,onMove:N}=_.getState();N==null||N(z,R),j==null||j(R)},onPanZoomEnd:(z,R)=>{const{onViewportChangeEnd:j,onMoveEnd:N}=_.getState();N==null||N(z,R),j==null||j(R)}});const{x:T,y:C,zoom:L}=P.current.getViewport();return _.setState({panZoom:P.current,transform:[T,C,L],domNode:S.current.closest(".react-flow")}),()=>{var z;(z=P.current)==null||z.destroy()}}},[]),M.useEffect(()=>{var T;(T=P.current)==null||T.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:o,panOnScrollMode:i,zoomOnDoubleClick:s,panOnDrag:l,zoomActivationKeyPressed:D,preventScrolling:x,noPanClassName:k,userSelectionActive:b,noWheelClassName:v,lib:E,onTransformChange:I,connectionInProgress:A,selectionOnDrag:w,paneClickDistance:h})},[e,t,n,r,o,i,s,l,D,x,k,b,v,E,I,A,w,h]),d.jsx("div",{className:"react-flow__renderer",ref:S,style:tl,children:y})}const k_=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function __(){const{userSelectionActive:e,userSelectionRect:t}=ne(k_,fe);return e&&t?d.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const Bl=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},b_=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function C_({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Ro.Full,panOnDrag:r,paneClickDistance:o,selectionOnDrag:i,onSelectionStart:s,onSelectionEnd:l,onPaneClick:a,onPaneContextMenu:u,onPaneScroll:p,onPaneMouseEnter:c,onPaneMouseMove:f,onPaneMouseLeave:x,children:y}){const v=pe(),{userSelectionActive:k,elementsSelectable:m,dragging:g,connectionInProgress:h}=ne(b_,fe),w=m&&(e||k),_=M.useRef(null),S=M.useRef(),b=M.useRef(new Set),E=M.useRef(new Set),A=M.useRef(!1),D=j=>{if(A.current||h){A.current=!1;return}a==null||a(j),v.getState().resetSelectedElements(),v.setState({nodesSelectionActive:!1})},P=j=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){j.preventDefault();return}u==null||u(j)},I=p?j=>p(j):void 0,T=j=>{A.current&&(j.stopPropagation(),A.current=!1)},C=j=>{var Y,X;const{domNode:N}=v.getState();if(S.current=N==null?void 0:N.getBoundingClientRect(),!S.current)return;const $=j.target===_.current;if(!$&&!!j.target.closest(".nokey")||!e||!(i&&$||t)||j.button!==0||!j.isPrimary)return;(X=(Y=j.target)==null?void 0:Y.setPointerCapture)==null||X.call(Y,j.pointerId),A.current=!1;const{x:W,y:V}=dt(j.nativeEvent,S.current);v.setState({userSelectionRect:{width:0,height:0,startX:W,startY:V,x:W,y:V}}),$||(j.stopPropagation(),j.preventDefault())},L=j=>{const{userSelectionRect:N,transform:$,nodeLookup:O,edgeLookup:B,connectionLookup:W,triggerNodeChanges:V,triggerEdgeChanges:Y,defaultEdgeOptions:X,resetSelectedElements:Q}=v.getState();if(!S.current||!N)return;const{x:H,y:K}=dt(j.nativeEvent,S.current),{startX:ee,startY:G}=N;if(!A.current){const ie=t?0:o;if(Math.hypot(H-ee,K-G)<=ie)return;Q(),s==null||s(j)}A.current=!0;const J={startX:ee,startY:G,x:Hie.id)),E.current=new Set;const le=(X==null?void 0:X.selectable)??!0;for(const ie of b.current){const Ne=W.get(ie);if(Ne)for(const{edgeId:Vt}of Ne.values()){const Nt=B.get(Vt);Nt&&(Nt.selectable??le)&&E.current.add(Vt)}}if(!sf(Z,b.current)){const ie=nr(O,b.current,!0);V(ie)}if(!sf(re,E.current)){const ie=nr(B,E.current);Y(ie)}v.setState({userSelectionRect:J,userSelectionActive:!0,nodesSelectionActive:!1})},z=j=>{var N,$;j.button===0&&(($=(N=j.target)==null?void 0:N.releasePointerCapture)==null||$.call(N,j.pointerId),!k&&j.target===_.current&&v.getState().userSelectionRect&&(D==null||D(j)),v.setState({userSelectionActive:!1,userSelectionRect:null}),A.current&&(l==null||l(j),v.setState({nodesSelectionActive:b.current.size>0})))},R=r===!0||Array.isArray(r)&&r.includes(0);return d.jsxs("div",{className:we(["react-flow__pane",{draggable:R,dragging:g,selection:e}]),onClick:w?void 0:Bl(D,_),onContextMenu:Bl(P,_),onWheel:Bl(I,_),onPointerEnter:w?void 0:c,onPointerMove:w?L:f,onPointerUp:w?z:void 0,onPointerDownCapture:w?C:void 0,onClickCapture:w?T:void 0,onPointerLeave:x,ref:_,style:tl,children:[y,d.jsx(__,{})]})}function ru({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:o,unselectNodesAndEdges:i,multiSelectionActive:s,nodeLookup:l,onError:a}=t.getState(),u=l.get(e);if(!u){a==null||a("012",Et.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&s)&&(i({nodes:[u],edges:[]}),requestAnimationFrame(()=>{var p;return(p=r==null?void 0:r.current)==null?void 0:p.blur()})):o([e])}function Am({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:o,isSelectable:i,nodeClickDistance:s}){const l=pe(),[a,u]=M.useState(!1),p=M.useRef();return M.useEffect(()=>{p.current=KS({getStoreItems:()=>l.getState(),onNodeMouseDown:c=>{ru({id:c,store:l,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}})},[]),M.useEffect(()=>{if(!(t||!e.current||!p.current))return p.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:i,nodeId:o,nodeClickDistance:s}),()=>{var c;(c=p.current)==null||c.destroy()}},[n,r,t,i,e,o,s]),a}const E_=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function $m(){const e=pe();return M.useCallback(n=>{const{nodeExtent:r,snapToGrid:o,snapGrid:i,nodesDraggable:s,onError:l,updateNodePositions:a,nodeLookup:u,nodeOrigin:p}=e.getState(),c=new Map,f=E_(s),x=o?i[0]:5,y=o?i[1]:5,v=n.direction.x*x*n.factor,k=n.direction.y*y*n.factor;for(const[,m]of u){if(!f(m))continue;let g={x:m.internals.positionAbsolute.x+v,y:m.internals.positionAbsolute.y+k};o&&(g=Qo(g,i));const{position:h,positionAbsolute:w}=qg({nodeId:m.id,nextPosition:g,nodeLookup:u,nodeExtent:r,nodeOrigin:p,onError:l});m.position=h,m.internals.positionAbsolute=w,c.set(m.id,m)}a(c)},[])}const vc=M.createContext(null),j_=vc.Provider;vc.Consumer;const Dm=()=>M.useContext(vc),N_=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),M_=(e,t,n)=>r=>{const{connectionClickStartHandle:o,connectionMode:i,connection:s}=r,{fromHandle:l,toHandle:a,isValid:u}=s,p=(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.id)===t&&(a==null?void 0:a.type)===n;return{connectingFrom:(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.id)===t&&(l==null?void 0:l.type)===n,connectingTo:p,clickConnecting:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.id)===t&&(o==null?void 0:o.type)===n,isPossibleEndHandle:i===wr.Strict?(l==null?void 0:l.type)!==n:e!==(l==null?void 0:l.nodeId)||t!==(l==null?void 0:l.id),connectionInProcess:!!l,clickConnectionInProcess:!!o,valid:p&&u}};function z_({type:e="source",position:t=q.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:o=!0,isConnectableEnd:i=!0,id:s,onConnect:l,children:a,className:u,onMouseDown:p,onTouchStart:c,...f},x){var L,z;const y=s||null,v=e==="target",k=pe(),m=Dm(),{connectOnClick:g,noPanClassName:h,rfId:w}=ne(N_,fe),{connectingFrom:_,connectingTo:S,clickConnecting:b,isPossibleEndHandle:E,connectionInProcess:A,clickConnectionInProcess:D,valid:P}=ne(M_(m,y,e),fe);m||(z=(L=k.getState()).onError)==null||z.call(L,"010",Et.error010());const I=R=>{const{defaultEdgeOptions:j,onConnect:N,hasDefaultEdges:$}=k.getState(),O={...j,...R};if($){const{edges:B,setEdges:W}=k.getState();W(RS(O,B))}N==null||N(O),l==null||l(O)},T=R=>{if(!m)return;const j=sm(R.nativeEvent);if(o&&(j&&R.button===0||!j)){const N=k.getState();nu.onPointerDown(R.nativeEvent,{handleDomNode:R.currentTarget,autoPanOnConnect:N.autoPanOnConnect,connectionMode:N.connectionMode,connectionRadius:N.connectionRadius,domNode:N.domNode,nodeLookup:N.nodeLookup,lib:N.lib,isTarget:v,handleId:y,nodeId:m,flowId:N.rfId,panBy:N.panBy,cancelConnection:N.cancelConnection,onConnectStart:N.onConnectStart,onConnectEnd:(...$)=>{var O,B;return(B=(O=k.getState()).onConnectEnd)==null?void 0:B.call(O,...$)},updateConnection:N.updateConnection,onConnect:I,isValidConnection:n||((...$)=>{var O,B;return((B=(O=k.getState()).isValidConnection)==null?void 0:B.call(O,...$))??!0}),getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,autoPanSpeed:N.autoPanSpeed,dragThreshold:N.connectionDragThreshold})}j?p==null||p(R):c==null||c(R)},C=R=>{const{onClickConnectStart:j,onClickConnectEnd:N,connectionClickStartHandle:$,connectionMode:O,isValidConnection:B,lib:W,rfId:V,nodeLookup:Y,connection:X}=k.getState();if(!m||!$&&!o)return;if(!$){j==null||j(R.nativeEvent,{nodeId:m,handleId:y,handleType:e}),k.setState({connectionClickStartHandle:{nodeId:m,type:e,id:y}});return}const Q=om(R.target),H=n||B,{connection:K,isValid:ee}=nu.isValid(R.nativeEvent,{handle:{nodeId:m,id:y,type:e},connectionMode:O,fromNodeId:$.nodeId,fromHandleId:$.id||null,fromType:$.type,isValidConnection:H,flowId:V,doc:Q,lib:W,nodeLookup:Y});ee&&K&&I(K);const G=structuredClone(X);delete G.inProgress,G.toPosition=G.toHandle?G.toHandle.position:null,N==null||N(R,G),k.setState({connectionClickStartHandle:null})};return d.jsx("div",{"data-handleid":y,"data-nodeid":m,"data-handlepos":t,"data-id":`${w}-${m}-${y}-${e}`,className:we(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",h,u,{source:!v,target:v,connectable:r,connectablestart:o,connectableend:i,clickconnecting:b,connectingfrom:_,connectingto:S,valid:P,connectionindicator:r&&(!A||E)&&(A||D?i:o)}]),onMouseDown:T,onTouchStart:T,onClick:g?C:void 0,ref:x,...f,children:a})}const Cr=M.memo(Rm(z_));function T_({data:e,isConnectable:t,sourcePosition:n=q.Bottom}){return d.jsxs(d.Fragment,{children:[e==null?void 0:e.label,d.jsx(Cr,{type:"source",position:n,isConnectable:t})]})}function P_({data:e,isConnectable:t,targetPosition:n=q.Top,sourcePosition:r=q.Bottom}){return d.jsxs(d.Fragment,{children:[d.jsx(Cr,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,d.jsx(Cr,{type:"source",position:r,isConnectable:t})]})}function I_(){return null}function R_({data:e,isConnectable:t,targetPosition:n=q.Top}){return d.jsxs(d.Fragment,{children:[d.jsx(Cr,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const js={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Pf={input:T_,default:P_,output:R_,group:I_};function L_(e){var t,n,r,o;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((r=e.style)==null?void 0:r.width),height:e.height??((o=e.style)==null?void 0:o.height)}}const A_=e=>{const{width:t,height:n,x:r,y:o}=Xo(e.nodeLookup,{filter:i=>!!i.selected});return{width:ct(t)?t:null,height:ct(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${o}px)`}};function $_({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=pe(),{width:o,height:i,transformString:s,userSelectionActive:l}=ne(A_,fe),a=$m(),u=M.useRef(null);M.useEffect(()=>{var x;n||(x=u.current)==null||x.focus({preventScroll:!0})},[n]);const p=!l&&o!==null&&i!==null;if(Am({nodeRef:u,disabled:!p}),!p)return null;const c=e?x=>{const y=r.getState().nodes.filter(v=>v.selected);e(x,y)}:void 0,f=x=>{Object.prototype.hasOwnProperty.call(js,x.key)&&(x.preventDefault(),a({direction:js[x.key],factor:x.shiftKey?4:1}))};return d.jsx("div",{className:we(["react-flow__nodesselection","react-flow__container",t]),style:{transform:s},children:d.jsx("div",{ref:u,className:"react-flow__nodesselection-rect",onContextMenu:c,tabIndex:n?void 0:-1,onKeyDown:n?void 0:f,style:{width:o,height:i}})})}const If=typeof window<"u"?window:void 0,D_=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Om({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:s,paneClickDistance:l,deleteKeyCode:a,selectionKeyCode:u,selectionOnDrag:p,selectionMode:c,onSelectionStart:f,onSelectionEnd:x,multiSelectionKeyCode:y,panActivationKeyCode:v,zoomActivationKeyCode:k,elementsSelectable:m,zoomOnScroll:g,zoomOnPinch:h,panOnScroll:w,panOnScrollSpeed:_,panOnScrollMode:S,zoomOnDoubleClick:b,panOnDrag:E,defaultViewport:A,translateExtent:D,minZoom:P,maxZoom:I,preventScrolling:T,onSelectionContextMenu:C,noWheelClassName:L,noPanClassName:z,disableKeyboardA11y:R,onViewportChange:j,isControlledViewport:N}){const{nodesSelectionActive:$,userSelectionActive:O}=ne(D_,fe),B=$o(u,{target:If}),W=$o(v,{target:If}),V=W||E,Y=W||w,X=p&&V!==!0,Q=B||O||X;return x_({deleteKeyCode:a,multiSelectionKeyCode:y}),d.jsx(S_,{onPaneContextMenu:i,elementsSelectable:m,zoomOnScroll:g,zoomOnPinch:h,panOnScroll:Y,panOnScrollSpeed:_,panOnScrollMode:S,zoomOnDoubleClick:b,panOnDrag:!B&&V,defaultViewport:A,translateExtent:D,minZoom:P,maxZoom:I,zoomActivationKeyCode:k,preventScrolling:T,noWheelClassName:L,noPanClassName:z,onViewportChange:j,isControlledViewport:N,paneClickDistance:l,selectionOnDrag:X,children:d.jsxs(C_,{onSelectionStart:f,onSelectionEnd:x,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:s,panOnDrag:V,isSelecting:!!Q,selectionMode:c,selectionKeyPressed:B,paneClickDistance:l,selectionOnDrag:X,children:[e,$&&d.jsx($_,{onSelectionContextMenu:C,noPanClassName:z,disableKeyboardA11y:R})]})})}Om.displayName="FlowRenderer";const O_=M.memo(Om),B_=e=>t=>e?cc(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function F_(e){return ne(M.useCallback(B_(e),[e]),fe)}const H_=e=>e.updateNodeInternals;function V_(){const e=ne(H_),[t]=M.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(o=>{const i=o.target.getAttribute("data-id");r.set(i,{id:i,nodeElement:o.target,force:!0})}),e(r)}));return M.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function W_({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const o=pe(),i=M.useRef(null),s=M.useRef(null),l=M.useRef(e.sourcePosition),a=M.useRef(e.targetPosition),u=M.useRef(t),p=n&&!!e.internals.handleBounds;return M.useEffect(()=>{i.current&&!e.hidden&&(!p||s.current!==i.current)&&(s.current&&(r==null||r.unobserve(s.current)),r==null||r.observe(i.current),s.current=i.current)},[p,e.hidden]),M.useEffect(()=>()=>{s.current&&(r==null||r.unobserve(s.current),s.current=null)},[]),M.useEffect(()=>{if(i.current){const c=u.current!==t,f=l.current!==e.sourcePosition,x=a.current!==e.targetPosition;(c||f||x)&&(u.current=t,l.current=e.sourcePosition,a.current=e.targetPosition,o.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function U_({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:o,onContextMenu:i,onDoubleClick:s,nodesDraggable:l,elementsSelectable:a,nodesConnectable:u,nodesFocusable:p,resizeObserver:c,noDragClassName:f,noPanClassName:x,disableKeyboardA11y:y,rfId:v,nodeTypes:k,nodeClickDistance:m,onError:g}){const{node:h,internals:w,isParent:_}=ne(H=>{const K=H.nodeLookup.get(e),ee=H.parentLookup.has(e);return{node:K,internals:K.internals,isParent:ee}},fe);let S=h.type||"default",b=(k==null?void 0:k[S])||Pf[S];b===void 0&&(g==null||g("003",Et.error003(S)),S="default",b=(k==null?void 0:k.default)||Pf.default);const E=!!(h.draggable||l&&typeof h.draggable>"u"),A=!!(h.selectable||a&&typeof h.selectable>"u"),D=!!(h.connectable||u&&typeof h.connectable>"u"),P=!!(h.focusable||p&&typeof h.focusable>"u"),I=pe(),T=nm(h),C=W_({node:h,nodeType:S,hasDimensions:T,resizeObserver:c}),L=Am({nodeRef:C,disabled:h.hidden||!E,noDragClassName:f,handleSelector:h.dragHandle,nodeId:e,isSelectable:A,nodeClickDistance:m}),z=$m();if(h.hidden)return null;const R=Ht(h),j=L_(h),N=A||E||t||n||r||o,$=n?H=>n(H,{...w.userNode}):void 0,O=r?H=>r(H,{...w.userNode}):void 0,B=o?H=>o(H,{...w.userNode}):void 0,W=i?H=>i(H,{...w.userNode}):void 0,V=s?H=>s(H,{...w.userNode}):void 0,Y=H=>{const{selectNodesOnDrag:K,nodeDragThreshold:ee}=I.getState();A&&(!K||!E||ee>0)&&ru({id:e,store:I,nodeRef:C}),t&&t(H,{...w.userNode})},X=H=>{if(!(im(H.nativeEvent)||y)){if(Xg.includes(H.key)&&A){const K=H.key==="Escape";ru({id:e,store:I,unselect:K,nodeRef:C})}else if(E&&h.selected&&Object.prototype.hasOwnProperty.call(js,H.key)){H.preventDefault();const{ariaLabelConfig:K}=I.getState();I.setState({ariaLiveMessage:K["node.a11yDescription.ariaLiveMessage"]({direction:H.key.replace("Arrow","").toLowerCase(),x:~~w.positionAbsolute.x,y:~~w.positionAbsolute.y})}),z({direction:js[H.key],factor:H.shiftKey?4:1})}}},Q=()=>{var re;if(y||!((re=C.current)!=null&&re.matches(":focus-visible")))return;const{transform:H,width:K,height:ee,autoPanOnNodeFocus:G,setCenter:J}=I.getState();if(!G)return;cc(new Map([[e,h]]),{x:0,y:0,width:K,height:ee},H,!0).length>0||J(h.position.x+R.width/2,h.position.y+R.height/2,{zoom:H[2]})};return d.jsx("div",{className:we(["react-flow__node",`react-flow__node-${S}`,{[x]:E},h.className,{selected:h.selected,selectable:A,parent:_,draggable:E,dragging:L}]),ref:C,style:{zIndex:w.z,transform:`translate(${w.positionAbsolute.x}px,${w.positionAbsolute.y}px)`,pointerEvents:N?"all":"none",visibility:T?"visible":"hidden",...h.style,...j},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:$,onMouseMove:O,onMouseLeave:B,onContextMenu:W,onClick:Y,onDoubleClick:V,onKeyDown:P?X:void 0,tabIndex:P?0:void 0,onFocus:P?Q:void 0,role:h.ariaRole??(P?"group":void 0),"aria-roledescription":"node","aria-describedby":y?void 0:`${Nm}-${v}`,"aria-label":h.ariaLabel,...h.domAttributes,children:d.jsx(j_,{value:e,children:d.jsx(b,{id:e,data:h.data,type:S,positionAbsoluteX:w.positionAbsolute.x,positionAbsoluteY:w.positionAbsolute.y,selected:h.selected??!1,selectable:A,draggable:E,deletable:h.deletable??!0,isConnectable:D,sourcePosition:h.sourcePosition,targetPosition:h.targetPosition,dragging:L,dragHandle:h.dragHandle,zIndex:w.z,parentId:h.parentId,...R})})})}var Y_=M.memo(U_);const X_=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Bm(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:o,onError:i}=ne(X_,fe),s=F_(e.onlyRenderVisibleElements),l=V_();return d.jsx("div",{className:"react-flow__nodes",style:tl,children:s.map(a=>d.jsx(Y_,{id:a,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:l,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:o,nodeClickDistance:e.nodeClickDistance,onError:i},a))})}Bm.displayName="NodeRenderer";const Q_=M.memo(Bm);function G_(e){return ne(M.useCallback(n=>{if(!e)return n.edges.map(o=>o.id);const r=[];if(n.width&&n.height)for(const o of n.edges){const i=n.nodeLookup.get(o.source),s=n.nodeLookup.get(o.target);i&&s&&TS({sourceNode:i,targetNode:s,width:n.width,height:n.height,transform:n.transform})&&r.push(o.id)}return r},[e]),fe)}const K_=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return d.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},Z_=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return d.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Rf={[bs.Arrow]:K_,[bs.ArrowClosed]:Z_};function q_(e){const t=pe();return M.useMemo(()=>{var o,i;return Object.prototype.hasOwnProperty.call(Rf,e)?Rf[e]:((i=(o=t.getState()).onError)==null||i.call(o,"009",Et.error009(e)),null)},[e])}const J_=({id:e,type:t,color:n,width:r=12.5,height:o=12.5,markerUnits:i="strokeWidth",strokeWidth:s,orient:l="auto-start-reverse"})=>{const a=q_(t);return a?d.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:l,refX:"0",refY:"0",children:d.jsx(a,{color:n,strokeWidth:s})}):null},Fm=({defaultColor:e,rfId:t})=>{const n=ne(i=>i.edges),r=ne(i=>i.defaultEdgeOptions),o=M.useMemo(()=>OS(n,{id:t,defaultColor:e,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,t,e]);return o.length?d.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:d.jsx("defs",{children:o.map(i=>d.jsx(J_,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};Fm.displayName="MarkerDefinitions";var eb=M.memo(Fm);function Hm({x:e,y:t,label:n,labelStyle:r,labelShowBg:o=!0,labelBgStyle:i,labelBgPadding:s=[2,4],labelBgBorderRadius:l=2,children:a,className:u,...p}){const[c,f]=M.useState({x:1,y:0,width:0,height:0}),x=we(["react-flow__edge-textwrapper",u]),y=M.useRef(null);return M.useEffect(()=>{if(y.current){const v=y.current.getBBox();f({x:v.x,y:v.y,width:v.width,height:v.height})}},[n]),n?d.jsxs("g",{transform:`translate(${e-c.width/2} ${t-c.height/2})`,className:x,visibility:c.width?"visible":"hidden",...p,children:[o&&d.jsx("rect",{width:c.width+2*s[0],x:-s[0],y:-s[1],height:c.height+2*s[1],className:"react-flow__edge-textbg",style:i,rx:l,ry:l}),d.jsx("text",{className:"react-flow__edge-text",y:c.height/2,dy:"0.3em",ref:y,style:r,children:n}),a]}):null}Hm.displayName="EdgeText";const tb=M.memo(Hm);function nl({path:e,labelX:t,labelY:n,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:s,labelBgPadding:l,labelBgBorderRadius:a,interactionWidth:u=20,...p}){return d.jsxs(d.Fragment,{children:[d.jsx("path",{...p,d:e,fill:"none",className:we(["react-flow__edge-path",p.className])}),u?d.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:u,className:"react-flow__edge-interaction"}):null,r&&ct(t)&&ct(n)?d.jsx(tb,{x:t,y:n,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:s,labelBgPadding:l,labelBgBorderRadius:a}):null]})}function Lf({pos:e,x1:t,y1:n,x2:r,y2:o}){return e===q.Left||e===q.Right?[.5*(t+r),n]:[t,.5*(n+o)]}function Vm({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:r,targetY:o,targetPosition:i=q.Top}){const[s,l]=Lf({pos:n,x1:e,y1:t,x2:r,y2:o}),[a,u]=Lf({pos:i,x1:r,y1:o,x2:e,y2:t}),[p,c,f,x]=lm({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:s,sourceControlY:l,targetControlX:a,targetControlY:u});return[`M${e},${t} C${s},${l} ${a},${u} ${r},${o}`,p,c,f,x]}function Wm(e){return M.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,sourcePosition:s,targetPosition:l,label:a,labelStyle:u,labelShowBg:p,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:x,style:y,markerEnd:v,markerStart:k,interactionWidth:m})=>{const[g,h,w]=Vm({sourceX:n,sourceY:r,sourcePosition:s,targetX:o,targetY:i,targetPosition:l}),_=e.isInternal?void 0:t;return d.jsx(nl,{id:_,path:g,labelX:h,labelY:w,label:a,labelStyle:u,labelShowBg:p,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:x,style:y,markerEnd:v,markerStart:k,interactionWidth:m})})}const nb=Wm({isInternal:!1}),Um=Wm({isInternal:!0});nb.displayName="SimpleBezierEdge";Um.displayName="SimpleBezierEdgeInternal";function Ym(e){return M.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,label:s,labelStyle:l,labelShowBg:a,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:c,style:f,sourcePosition:x=q.Bottom,targetPosition:y=q.Top,markerEnd:v,markerStart:k,pathOptions:m,interactionWidth:g})=>{const[h,w,_]=Ja({sourceX:n,sourceY:r,sourcePosition:x,targetX:o,targetY:i,targetPosition:y,borderRadius:m==null?void 0:m.borderRadius,offset:m==null?void 0:m.offset,stepPosition:m==null?void 0:m.stepPosition}),S=e.isInternal?void 0:t;return d.jsx(nl,{id:S,path:h,labelX:w,labelY:_,label:s,labelStyle:l,labelShowBg:a,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:c,style:f,markerEnd:v,markerStart:k,interactionWidth:g})})}const Xm=Ym({isInternal:!1}),Qm=Ym({isInternal:!0});Xm.displayName="SmoothStepEdge";Qm.displayName="SmoothStepEdgeInternal";function Gm(e){return M.memo(({id:t,...n})=>{var o;const r=e.isInternal?void 0:t;return d.jsx(Xm,{...n,id:r,pathOptions:M.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(o=n.pathOptions)==null?void 0:o.offset])})})}const rb=Gm({isInternal:!1}),Km=Gm({isInternal:!0});rb.displayName="StepEdge";Km.displayName="StepEdgeInternal";function Zm(e){return M.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,label:s,labelStyle:l,labelShowBg:a,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:c,style:f,markerEnd:x,markerStart:y,interactionWidth:v})=>{const[k,m,g]=cm({sourceX:n,sourceY:r,targetX:o,targetY:i}),h=e.isInternal?void 0:t;return d.jsx(nl,{id:h,path:k,labelX:m,labelY:g,label:s,labelStyle:l,labelShowBg:a,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:c,style:f,markerEnd:x,markerStart:y,interactionWidth:v})})}const ob=Zm({isInternal:!1}),qm=Zm({isInternal:!0});ob.displayName="StraightEdge";qm.displayName="StraightEdgeInternal";function Jm(e){return M.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,sourcePosition:s=q.Bottom,targetPosition:l=q.Top,label:a,labelStyle:u,labelShowBg:p,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:x,style:y,markerEnd:v,markerStart:k,pathOptions:m,interactionWidth:g})=>{const[h,w,_]=am({sourceX:n,sourceY:r,sourcePosition:s,targetX:o,targetY:i,targetPosition:l,curvature:m==null?void 0:m.curvature}),S=e.isInternal?void 0:t;return d.jsx(nl,{id:S,path:h,labelX:w,labelY:_,label:a,labelStyle:u,labelShowBg:p,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:x,style:y,markerEnd:v,markerStart:k,interactionWidth:g})})}const ib=Jm({isInternal:!1}),e0=Jm({isInternal:!0});ib.displayName="BezierEdge";e0.displayName="BezierEdgeInternal";const Af={default:e0,straight:qm,step:Km,smoothstep:Qm,simplebezier:Um},$f={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},sb=(e,t,n)=>n===q.Left?e-t:n===q.Right?e+t:e,lb=(e,t,n)=>n===q.Top?e-t:n===q.Bottom?e+t:e,Df="react-flow__edgeupdater";function Of({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:o,onMouseEnter:i,onMouseOut:s,type:l}){return d.jsx("circle",{onMouseDown:o,onMouseEnter:i,onMouseOut:s,className:we([Df,`${Df}-${l}`]),cx:sb(t,r,e),cy:lb(n,r,e),r,stroke:"transparent",fill:"transparent"})}function ab({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:o,targetX:i,targetY:s,sourcePosition:l,targetPosition:a,onReconnect:u,onReconnectStart:p,onReconnectEnd:c,setReconnecting:f,setUpdateHover:x}){const y=pe(),v=(w,_)=>{if(w.button!==0)return;const{autoPanOnConnect:S,domNode:b,connectionMode:E,connectionRadius:A,lib:D,onConnectStart:P,cancelConnection:I,nodeLookup:T,rfId:C,panBy:L,updateConnection:z}=y.getState(),R=_.type==="target",j=(O,B)=>{f(!1),c==null||c(O,n,_.type,B)},N=O=>u==null?void 0:u(n,O),$=(O,B)=>{f(!0),p==null||p(w,n,_.type),P==null||P(O,B)};nu.onPointerDown(w.nativeEvent,{autoPanOnConnect:S,connectionMode:E,connectionRadius:A,domNode:b,handleId:_.id,nodeId:_.nodeId,nodeLookup:T,isTarget:R,edgeUpdaterType:_.type,lib:D,flowId:C,cancelConnection:I,panBy:L,isValidConnection:(...O)=>{var B,W;return((W=(B=y.getState()).isValidConnection)==null?void 0:W.call(B,...O))??!0},onConnect:N,onConnectStart:$,onConnectEnd:(...O)=>{var B,W;return(W=(B=y.getState()).onConnectEnd)==null?void 0:W.call(B,...O)},onReconnectEnd:j,updateConnection:z,getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,dragThreshold:y.getState().connectionDragThreshold,handleDomNode:w.currentTarget})},k=w=>v(w,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),m=w=>v(w,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),g=()=>x(!0),h=()=>x(!1);return d.jsxs(d.Fragment,{children:[(e===!0||e==="source")&&d.jsx(Of,{position:l,centerX:r,centerY:o,radius:t,onMouseDown:k,onMouseEnter:g,onMouseOut:h,type:"source"}),(e===!0||e==="target")&&d.jsx(Of,{position:a,centerX:i,centerY:s,radius:t,onMouseDown:m,onMouseEnter:g,onMouseOut:h,type:"target"})]})}function ub({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:o,onDoubleClick:i,onContextMenu:s,onMouseEnter:l,onMouseMove:a,onMouseLeave:u,reconnectRadius:p,onReconnect:c,onReconnectStart:f,onReconnectEnd:x,rfId:y,edgeTypes:v,noPanClassName:k,onError:m,disableKeyboardA11y:g}){let h=ne(J=>J.edgeLookup.get(e));const w=ne(J=>J.defaultEdgeOptions);h=w?{...w,...h}:h;let _=h.type||"default",S=(v==null?void 0:v[_])||Af[_];S===void 0&&(m==null||m("011",Et.error011(_)),_="default",S=(v==null?void 0:v.default)||Af.default);const b=!!(h.focusable||t&&typeof h.focusable>"u"),E=typeof c<"u"&&(h.reconnectable||n&&typeof h.reconnectable>"u"),A=!!(h.selectable||r&&typeof h.selectable>"u"),D=M.useRef(null),[P,I]=M.useState(!1),[T,C]=M.useState(!1),L=pe(),{zIndex:z,sourceX:R,sourceY:j,targetX:N,targetY:$,sourcePosition:O,targetPosition:B}=ne(M.useCallback(J=>{const Z=J.nodeLookup.get(h.source),re=J.nodeLookup.get(h.target);if(!Z||!re)return{zIndex:h.zIndex,...$f};const le=DS({id:e,sourceNode:Z,targetNode:re,sourceHandle:h.sourceHandle||null,targetHandle:h.targetHandle||null,connectionMode:J.connectionMode,onError:m});return{zIndex:zS({selected:h.selected,zIndex:h.zIndex,sourceNode:Z,targetNode:re,elevateOnSelect:J.elevateEdgesOnSelect,zIndexMode:J.zIndexMode}),...le||$f}},[h.source,h.target,h.sourceHandle,h.targetHandle,h.selected,h.zIndex]),fe),W=M.useMemo(()=>h.markerStart?`url('#${eu(h.markerStart,y)}')`:void 0,[h.markerStart,y]),V=M.useMemo(()=>h.markerEnd?`url('#${eu(h.markerEnd,y)}')`:void 0,[h.markerEnd,y]);if(h.hidden||R===null||j===null||N===null||$===null)return null;const Y=J=>{var ie;const{addSelectedEdges:Z,unselectNodesAndEdges:re,multiSelectionActive:le}=L.getState();A&&(L.setState({nodesSelectionActive:!1}),h.selected&&le?(re({nodes:[],edges:[h]}),(ie=D.current)==null||ie.blur()):Z([e])),o&&o(J,h)},X=i?J=>{i(J,{...h})}:void 0,Q=s?J=>{s(J,{...h})}:void 0,H=l?J=>{l(J,{...h})}:void 0,K=a?J=>{a(J,{...h})}:void 0,ee=u?J=>{u(J,{...h})}:void 0,G=J=>{var Z;if(!g&&Xg.includes(J.key)&&A){const{unselectNodesAndEdges:re,addSelectedEdges:le}=L.getState();J.key==="Escape"?((Z=D.current)==null||Z.blur(),re({edges:[h]})):le([e])}};return d.jsx("svg",{style:{zIndex:z},children:d.jsxs("g",{className:we(["react-flow__edge",`react-flow__edge-${_}`,h.className,k,{selected:h.selected,animated:h.animated,inactive:!A&&!o,updating:P,selectable:A}]),onClick:Y,onDoubleClick:X,onContextMenu:Q,onMouseEnter:H,onMouseMove:K,onMouseLeave:ee,onKeyDown:b?G:void 0,tabIndex:b?0:void 0,role:h.ariaRole??(b?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":h.ariaLabel===null?void 0:h.ariaLabel||`Edge from ${h.source} to ${h.target}`,"aria-describedby":b?`${Mm}-${y}`:void 0,ref:D,...h.domAttributes,children:[!T&&d.jsx(S,{id:e,source:h.source,target:h.target,type:h.type,selected:h.selected,animated:h.animated,selectable:A,deletable:h.deletable??!0,label:h.label,labelStyle:h.labelStyle,labelShowBg:h.labelShowBg,labelBgStyle:h.labelBgStyle,labelBgPadding:h.labelBgPadding,labelBgBorderRadius:h.labelBgBorderRadius,sourceX:R,sourceY:j,targetX:N,targetY:$,sourcePosition:O,targetPosition:B,data:h.data,style:h.style,sourceHandleId:h.sourceHandle,targetHandleId:h.targetHandle,markerStart:W,markerEnd:V,pathOptions:"pathOptions"in h?h.pathOptions:void 0,interactionWidth:h.interactionWidth}),E&&d.jsx(ab,{edge:h,isReconnectable:E,reconnectRadius:p,onReconnect:c,onReconnectStart:f,onReconnectEnd:x,sourceX:R,sourceY:j,targetX:N,targetY:$,sourcePosition:O,targetPosition:B,setUpdateHover:I,setReconnecting:C})]})})}var cb=M.memo(ub);const db=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function t0({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:o,onReconnect:i,onEdgeContextMenu:s,onEdgeMouseEnter:l,onEdgeMouseMove:a,onEdgeMouseLeave:u,onEdgeClick:p,reconnectRadius:c,onEdgeDoubleClick:f,onReconnectStart:x,onReconnectEnd:y,disableKeyboardA11y:v}){const{edgesFocusable:k,edgesReconnectable:m,elementsSelectable:g,onError:h}=ne(db,fe),w=G_(t);return d.jsxs("div",{className:"react-flow__edges",children:[d.jsx(eb,{defaultColor:e,rfId:n}),w.map(_=>d.jsx(cb,{id:_,edgesFocusable:k,edgesReconnectable:m,elementsSelectable:g,noPanClassName:o,onReconnect:i,onContextMenu:s,onMouseEnter:l,onMouseMove:a,onMouseLeave:u,onClick:p,reconnectRadius:c,onDoubleClick:f,onReconnectStart:x,onReconnectEnd:y,rfId:n,onError:h,edgeTypes:r,disableKeyboardA11y:v},_))]})}t0.displayName="EdgeRenderer";const fb=M.memo(t0),pb=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function hb({children:e}){const t=ne(pb);return d.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function gb(e){const t=xc(),n=M.useRef(!1);M.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const mb=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function yb(e){const t=ne(mb),n=pe();return M.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function xb(e){return e.connection.inProgress?{...e.connection,to:Go(e.connection.to,e.transform)}:{...e.connection}}function vb(e){return xb}function wb(e){const t=vb();return ne(t,fe)}const Sb=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function kb({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:o,width:i,height:s,isValid:l,inProgress:a}=ne(Sb,fe);return!(i&&o&&a)?null:d.jsx("svg",{style:e,width:i,height:s,className:"react-flow__connectionline react-flow__container",children:d.jsx("g",{className:we(["react-flow__connection",Kg(l)]),children:d.jsx(n0,{style:t,type:n,CustomComponent:r,isValid:l})})})}const n0=({style:e,type:t=Zt.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:o,from:i,fromNode:s,fromHandle:l,fromPosition:a,to:u,toNode:p,toHandle:c,toPosition:f,pointer:x}=wb();if(!o)return;if(n)return d.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:s,fromHandle:l,fromX:i.x,fromY:i.y,toX:u.x,toY:u.y,fromPosition:a,toPosition:f,connectionStatus:Kg(r),toNode:p,toHandle:c,pointer:x});let y="";const v={sourceX:i.x,sourceY:i.y,sourcePosition:a,targetX:u.x,targetY:u.y,targetPosition:f};switch(t){case Zt.Bezier:[y]=am(v);break;case Zt.SimpleBezier:[y]=Vm(v);break;case Zt.Step:[y]=Ja({...v,borderRadius:0});break;case Zt.SmoothStep:[y]=Ja(v);break;default:[y]=cm(v)}return d.jsx("path",{d:y,fill:"none",className:"react-flow__connection-path",style:e})};n0.displayName="ConnectionLine";const _b={};function Bf(e=_b){M.useRef(e),pe(),M.useEffect(()=>{},[e])}function bb(){pe(),M.useRef(!1),M.useEffect(()=>{},[])}function r0({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:o,onNodeDoubleClick:i,onEdgeDoubleClick:s,onNodeMouseEnter:l,onNodeMouseMove:a,onNodeMouseLeave:u,onNodeContextMenu:p,onSelectionContextMenu:c,onSelectionStart:f,onSelectionEnd:x,connectionLineType:y,connectionLineStyle:v,connectionLineComponent:k,connectionLineContainerStyle:m,selectionKeyCode:g,selectionOnDrag:h,selectionMode:w,multiSelectionKeyCode:_,panActivationKeyCode:S,zoomActivationKeyCode:b,deleteKeyCode:E,onlyRenderVisibleElements:A,elementsSelectable:D,defaultViewport:P,translateExtent:I,minZoom:T,maxZoom:C,preventScrolling:L,defaultMarkerColor:z,zoomOnScroll:R,zoomOnPinch:j,panOnScroll:N,panOnScrollSpeed:$,panOnScrollMode:O,zoomOnDoubleClick:B,panOnDrag:W,onPaneClick:V,onPaneMouseEnter:Y,onPaneMouseMove:X,onPaneMouseLeave:Q,onPaneScroll:H,onPaneContextMenu:K,paneClickDistance:ee,nodeClickDistance:G,onEdgeContextMenu:J,onEdgeMouseEnter:Z,onEdgeMouseMove:re,onEdgeMouseLeave:le,reconnectRadius:ie,onReconnect:Ne,onReconnectStart:Vt,onReconnectEnd:Nt,noDragClassName:gn,noWheelClassName:zr,noPanClassName:Tr,disableKeyboardA11y:Pr,nodeExtent:rl,rfId:Ko,viewport:On,onViewportChange:Ir}){return Bf(e),Bf(t),bb(),gb(n),yb(On),d.jsx(O_,{onPaneClick:V,onPaneMouseEnter:Y,onPaneMouseMove:X,onPaneMouseLeave:Q,onPaneContextMenu:K,onPaneScroll:H,paneClickDistance:ee,deleteKeyCode:E,selectionKeyCode:g,selectionOnDrag:h,selectionMode:w,onSelectionStart:f,onSelectionEnd:x,multiSelectionKeyCode:_,panActivationKeyCode:S,zoomActivationKeyCode:b,elementsSelectable:D,zoomOnScroll:R,zoomOnPinch:j,zoomOnDoubleClick:B,panOnScroll:N,panOnScrollSpeed:$,panOnScrollMode:O,panOnDrag:W,defaultViewport:P,translateExtent:I,minZoom:T,maxZoom:C,onSelectionContextMenu:c,preventScrolling:L,noDragClassName:gn,noWheelClassName:zr,noPanClassName:Tr,disableKeyboardA11y:Pr,onViewportChange:Ir,isControlledViewport:!!On,children:d.jsxs(hb,{children:[d.jsx(fb,{edgeTypes:t,onEdgeClick:o,onEdgeDoubleClick:s,onReconnect:Ne,onReconnectStart:Vt,onReconnectEnd:Nt,onlyRenderVisibleElements:A,onEdgeContextMenu:J,onEdgeMouseEnter:Z,onEdgeMouseMove:re,onEdgeMouseLeave:le,reconnectRadius:ie,defaultMarkerColor:z,noPanClassName:Tr,disableKeyboardA11y:Pr,rfId:Ko}),d.jsx(kb,{style:v,type:y,component:k,containerStyle:m}),d.jsx("div",{className:"react-flow__edgelabel-renderer"}),d.jsx(Q_,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:l,onNodeMouseMove:a,onNodeMouseLeave:u,onNodeContextMenu:p,nodeClickDistance:G,onlyRenderVisibleElements:A,noPanClassName:Tr,noDragClassName:gn,disableKeyboardA11y:Pr,nodeExtent:rl,rfId:Ko}),d.jsx("div",{className:"react-flow__viewport-portal"})]})})}r0.displayName="GraphView";const Cb=M.memo(r0),Ff=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:s,fitViewOptions:l,minZoom:a=.5,maxZoom:u=2,nodeOrigin:p,nodeExtent:c,zIndexMode:f="basic"}={})=>{const x=new Map,y=new Map,v=new Map,k=new Map,m=r??t??[],g=n??e??[],h=p??[0,0],w=c??Io;pm(v,k,m);const _=tu(g,x,y,{nodeOrigin:h,nodeExtent:w,zIndexMode:f});let S=[0,0,1];if(s&&o&&i){const b=Xo(x,{filter:P=>!!((P.width||P.initialWidth)&&(P.height||P.initialHeight))}),{x:E,y:A,zoom:D}=dc(b,o,i,a,u,(l==null?void 0:l.padding)??.1);S=[E,A,D]}return{rfId:"1",width:o??0,height:i??0,transform:S,nodes:g,nodesInitialized:_,nodeLookup:x,parentLookup:y,edges:m,edgeLookup:k,connectionLookup:v,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:a,maxZoom:u,translateExtent:Io,nodeExtent:w,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:wr.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:h,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:s??!1,fitViewOptions:l,fitViewResolver:null,connection:{...Gg},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:bS,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Qg,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},Eb=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:s,fitViewOptions:l,minZoom:a,maxZoom:u,nodeOrigin:p,nodeExtent:c,zIndexMode:f})=>Wk((x,y)=>{async function v(){const{nodeLookup:k,panZoom:m,fitViewOptions:g,fitViewResolver:h,width:w,height:_,minZoom:S,maxZoom:b}=y();m&&(await kS({nodes:k,width:w,height:_,panZoom:m,minZoom:S,maxZoom:b},g),h==null||h.resolve(!0),x({fitViewResolver:null}))}return{...Ff({nodes:e,edges:t,width:o,height:i,fitView:s,fitViewOptions:l,minZoom:a,maxZoom:u,nodeOrigin:p,nodeExtent:c,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:k=>{const{nodeLookup:m,parentLookup:g,nodeOrigin:h,elevateNodesOnSelect:w,fitViewQueued:_,zIndexMode:S}=y(),b=tu(k,m,g,{nodeOrigin:h,nodeExtent:c,elevateNodesOnSelect:w,checkEquality:!0,zIndexMode:S});_&&b?(v(),x({nodes:k,nodesInitialized:b,fitViewQueued:!1,fitViewOptions:void 0})):x({nodes:k,nodesInitialized:b})},setEdges:k=>{const{connectionLookup:m,edgeLookup:g}=y();pm(m,g,k),x({edges:k})},setDefaultNodesAndEdges:(k,m)=>{if(k){const{setNodes:g}=y();g(k),x({hasDefaultNodes:!0})}if(m){const{setEdges:g}=y();g(m),x({hasDefaultEdges:!0})}},updateNodeInternals:k=>{const{triggerNodeChanges:m,nodeLookup:g,parentLookup:h,domNode:w,nodeOrigin:_,nodeExtent:S,debug:b,fitViewQueued:E,zIndexMode:A}=y(),{changes:D,updatedInternals:P}=YS(k,g,h,w,_,S,A);P&&(HS(g,h,{nodeOrigin:_,nodeExtent:S,zIndexMode:A}),E?(v(),x({fitViewQueued:!1,fitViewOptions:void 0})):x({}),(D==null?void 0:D.length)>0&&(b&&console.log("React Flow: trigger node changes",D),m==null||m(D)))},updateNodePositions:(k,m=!1)=>{const g=[];let h=[];const{nodeLookup:w,triggerNodeChanges:_,connection:S,updateConnection:b,onNodesChangeMiddlewareMap:E}=y();for(const[A,D]of k){const P=w.get(A),I=!!(P!=null&&P.expandParent&&(P!=null&&P.parentId)&&(D!=null&&D.position)),T={id:A,type:"position",position:I?{x:Math.max(0,D.position.x),y:Math.max(0,D.position.y)}:D.position,dragging:m};if(P&&S.inProgress&&S.fromNode.id===P.id){const C=Ln(P,S.fromHandle,q.Left,!0);b({...S,from:C})}I&&P.parentId&&g.push({id:A,parentId:P.parentId,rect:{...D.internals.positionAbsolute,width:D.measured.width??0,height:D.measured.height??0}}),h.push(T)}if(g.length>0){const{parentLookup:A,nodeOrigin:D}=y(),P=yc(g,w,A,D);h.push(...P)}for(const A of E.values())h=A(h);_(h)},triggerNodeChanges:k=>{const{onNodesChange:m,setNodes:g,nodes:h,hasDefaultNodes:w,debug:_}=y();if(k!=null&&k.length){if(w){const S=Pm(k,h);g(S)}_&&console.log("React Flow: trigger node changes",k),m==null||m(k)}},triggerEdgeChanges:k=>{const{onEdgesChange:m,setEdges:g,edges:h,hasDefaultEdges:w,debug:_}=y();if(k!=null&&k.length){if(w){const S=Im(k,h);g(S)}_&&console.log("React Flow: trigger edge changes",k),m==null||m(k)}},addSelectedNodes:k=>{const{multiSelectionActive:m,edgeLookup:g,nodeLookup:h,triggerNodeChanges:w,triggerEdgeChanges:_}=y();if(m){const S=k.map(b=>xn(b,!0));w(S);return}w(nr(h,new Set([...k]),!0)),_(nr(g))},addSelectedEdges:k=>{const{multiSelectionActive:m,edgeLookup:g,nodeLookup:h,triggerNodeChanges:w,triggerEdgeChanges:_}=y();if(m){const S=k.map(b=>xn(b,!0));_(S);return}_(nr(g,new Set([...k]))),w(nr(h,new Set,!0))},unselectNodesAndEdges:({nodes:k,edges:m}={})=>{const{edges:g,nodes:h,nodeLookup:w,triggerNodeChanges:_,triggerEdgeChanges:S}=y(),b=k||h,E=m||g,A=[];for(const P of b){if(!P.selected)continue;const I=w.get(P.id);I&&(I.selected=!1),A.push(xn(P.id,!1))}const D=[];for(const P of E)P.selected&&D.push(xn(P.id,!1));_(A),S(D)},setMinZoom:k=>{const{panZoom:m,maxZoom:g}=y();m==null||m.setScaleExtent([k,g]),x({minZoom:k})},setMaxZoom:k=>{const{panZoom:m,minZoom:g}=y();m==null||m.setScaleExtent([g,k]),x({maxZoom:k})},setTranslateExtent:k=>{var m;(m=y().panZoom)==null||m.setTranslateExtent(k),x({translateExtent:k})},resetSelectedElements:()=>{const{edges:k,nodes:m,triggerNodeChanges:g,triggerEdgeChanges:h,elementsSelectable:w}=y();if(!w)return;const _=m.reduce((b,E)=>E.selected?[...b,xn(E.id,!1)]:b,[]),S=k.reduce((b,E)=>E.selected?[...b,xn(E.id,!1)]:b,[]);g(_),h(S)},setNodeExtent:k=>{const{nodes:m,nodeLookup:g,parentLookup:h,nodeOrigin:w,elevateNodesOnSelect:_,nodeExtent:S,zIndexMode:b}=y();k[0][0]===S[0][0]&&k[0][1]===S[0][1]&&k[1][0]===S[1][0]&&k[1][1]===S[1][1]||(tu(m,g,h,{nodeOrigin:w,nodeExtent:k,elevateNodesOnSelect:_,checkEquality:!1,zIndexMode:b}),x({nodeExtent:k}))},panBy:k=>{const{transform:m,width:g,height:h,panZoom:w,translateExtent:_}=y();return XS({delta:k,panZoom:w,transform:m,translateExtent:_,width:g,height:h})},setCenter:async(k,m,g)=>{const{width:h,height:w,maxZoom:_,panZoom:S}=y();if(!S)return Promise.resolve(!1);const b=typeof(g==null?void 0:g.zoom)<"u"?g.zoom:_;return await S.setViewport({x:h/2-k*b,y:w/2-m*b,zoom:b},{duration:g==null?void 0:g.duration,ease:g==null?void 0:g.ease,interpolate:g==null?void 0:g.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{x({connection:{...Gg}})},updateConnection:k=>{x({connection:k})},reset:()=>x({...Ff()})}},Object.is);function jb({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:o,initialHeight:i,initialMinZoom:s,initialMaxZoom:l,initialFitViewOptions:a,fitView:u,nodeOrigin:p,nodeExtent:c,zIndexMode:f,children:x}){const[y]=M.useState(()=>Eb({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:u,minZoom:s,maxZoom:l,fitViewOptions:a,nodeOrigin:p,nodeExtent:c,zIndexMode:f}));return d.jsx(Uk,{value:y,children:d.jsx(h_,{children:x})})}function Nb({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:o,width:i,height:s,fitView:l,fitViewOptions:a,minZoom:u,maxZoom:p,nodeOrigin:c,nodeExtent:f,zIndexMode:x}){return M.useContext(Js)?d.jsx(d.Fragment,{children:e}):d.jsx(jb,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:o,initialWidth:i,initialHeight:s,fitView:l,initialFitViewOptions:a,initialMinZoom:u,initialMaxZoom:p,nodeOrigin:c,nodeExtent:f,zIndexMode:x,children:e})}const Mb={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function zb({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:o,nodeTypes:i,edgeTypes:s,onNodeClick:l,onEdgeClick:a,onInit:u,onMove:p,onMoveStart:c,onMoveEnd:f,onConnect:x,onConnectStart:y,onConnectEnd:v,onClickConnectStart:k,onClickConnectEnd:m,onNodeMouseEnter:g,onNodeMouseMove:h,onNodeMouseLeave:w,onNodeContextMenu:_,onNodeDoubleClick:S,onNodeDragStart:b,onNodeDrag:E,onNodeDragStop:A,onNodesDelete:D,onEdgesDelete:P,onDelete:I,onSelectionChange:T,onSelectionDragStart:C,onSelectionDrag:L,onSelectionDragStop:z,onSelectionContextMenu:R,onSelectionStart:j,onSelectionEnd:N,onBeforeDelete:$,connectionMode:O,connectionLineType:B=Zt.Bezier,connectionLineStyle:W,connectionLineComponent:V,connectionLineContainerStyle:Y,deleteKeyCode:X="Backspace",selectionKeyCode:Q="Shift",selectionOnDrag:H=!1,selectionMode:K=Ro.Full,panActivationKeyCode:ee="Space",multiSelectionKeyCode:G=Ao()?"Meta":"Control",zoomActivationKeyCode:J=Ao()?"Meta":"Control",snapToGrid:Z,snapGrid:re,onlyRenderVisibleElements:le=!1,selectNodesOnDrag:ie,nodesDraggable:Ne,autoPanOnNodeFocus:Vt,nodesConnectable:Nt,nodesFocusable:gn,nodeOrigin:zr=zm,edgesFocusable:Tr,edgesReconnectable:Pr,elementsSelectable:rl=!0,defaultViewport:Ko=o_,minZoom:On=.5,maxZoom:Ir=2,translateExtent:kc=Io,preventScrolling:c0=!0,nodeExtent:ol,defaultMarkerColor:d0="#b1b1b7",zoomOnScroll:f0=!0,zoomOnPinch:p0=!0,panOnScroll:h0=!1,panOnScrollSpeed:g0=.5,panOnScrollMode:m0=En.Free,zoomOnDoubleClick:y0=!0,panOnDrag:x0=!0,onPaneClick:v0,onPaneMouseEnter:w0,onPaneMouseMove:S0,onPaneMouseLeave:k0,onPaneScroll:_0,onPaneContextMenu:b0,paneClickDistance:C0=1,nodeClickDistance:E0=0,children:j0,onReconnect:N0,onReconnectStart:M0,onReconnectEnd:z0,onEdgeContextMenu:T0,onEdgeDoubleClick:P0,onEdgeMouseEnter:I0,onEdgeMouseMove:R0,onEdgeMouseLeave:L0,reconnectRadius:A0=10,onNodesChange:$0,onEdgesChange:D0,noDragClassName:O0="nodrag",noWheelClassName:B0="nowheel",noPanClassName:_c="nopan",fitView:bc,fitViewOptions:Cc,connectOnClick:F0,attributionPosition:H0,proOptions:V0,defaultEdgeOptions:W0,elevateNodesOnSelect:U0=!0,elevateEdgesOnSelect:Y0=!1,disableKeyboardA11y:Ec=!1,autoPanOnConnect:X0,autoPanOnNodeDrag:Q0,autoPanSpeed:G0,connectionRadius:K0,isValidConnection:Z0,onError:q0,style:J0,id:jc,nodeDragThreshold:ey,connectionDragThreshold:ty,viewport:ny,onViewportChange:ry,width:oy,height:iy,colorMode:sy="light",debug:ly,onScroll:Zo,ariaLabelConfig:ay,zIndexMode:Nc="basic",...uy},cy){const il=jc||"1",dy=a_(sy),fy=M.useCallback(Mc=>{Mc.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Zo==null||Zo(Mc)},[Zo]);return d.jsx("div",{"data-testid":"rf__wrapper",...uy,onScroll:fy,style:{...J0,...Mb},ref:cy,className:we(["react-flow",o,dy]),id:jc,role:"application",children:d.jsxs(Nb,{nodes:e,edges:t,width:oy,height:iy,fitView:bc,fitViewOptions:Cc,minZoom:On,maxZoom:Ir,nodeOrigin:zr,nodeExtent:ol,zIndexMode:Nc,children:[d.jsx(Cb,{onInit:u,onNodeClick:l,onEdgeClick:a,onNodeMouseEnter:g,onNodeMouseMove:h,onNodeMouseLeave:w,onNodeContextMenu:_,onNodeDoubleClick:S,nodeTypes:i,edgeTypes:s,connectionLineType:B,connectionLineStyle:W,connectionLineComponent:V,connectionLineContainerStyle:Y,selectionKeyCode:Q,selectionOnDrag:H,selectionMode:K,deleteKeyCode:X,multiSelectionKeyCode:G,panActivationKeyCode:ee,zoomActivationKeyCode:J,onlyRenderVisibleElements:le,defaultViewport:Ko,translateExtent:kc,minZoom:On,maxZoom:Ir,preventScrolling:c0,zoomOnScroll:f0,zoomOnPinch:p0,zoomOnDoubleClick:y0,panOnScroll:h0,panOnScrollSpeed:g0,panOnScrollMode:m0,panOnDrag:x0,onPaneClick:v0,onPaneMouseEnter:w0,onPaneMouseMove:S0,onPaneMouseLeave:k0,onPaneScroll:_0,onPaneContextMenu:b0,paneClickDistance:C0,nodeClickDistance:E0,onSelectionContextMenu:R,onSelectionStart:j,onSelectionEnd:N,onReconnect:N0,onReconnectStart:M0,onReconnectEnd:z0,onEdgeContextMenu:T0,onEdgeDoubleClick:P0,onEdgeMouseEnter:I0,onEdgeMouseMove:R0,onEdgeMouseLeave:L0,reconnectRadius:A0,defaultMarkerColor:d0,noDragClassName:O0,noWheelClassName:B0,noPanClassName:_c,rfId:il,disableKeyboardA11y:Ec,nodeExtent:ol,viewport:ny,onViewportChange:ry}),d.jsx(l_,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:x,onConnectStart:y,onConnectEnd:v,onClickConnectStart:k,onClickConnectEnd:m,nodesDraggable:Ne,autoPanOnNodeFocus:Vt,nodesConnectable:Nt,nodesFocusable:gn,edgesFocusable:Tr,edgesReconnectable:Pr,elementsSelectable:rl,elevateNodesOnSelect:U0,elevateEdgesOnSelect:Y0,minZoom:On,maxZoom:Ir,nodeExtent:ol,onNodesChange:$0,onEdgesChange:D0,snapToGrid:Z,snapGrid:re,connectionMode:O,translateExtent:kc,connectOnClick:F0,defaultEdgeOptions:W0,fitView:bc,fitViewOptions:Cc,onNodesDelete:D,onEdgesDelete:P,onDelete:I,onNodeDragStart:b,onNodeDrag:E,onNodeDragStop:A,onSelectionDrag:L,onSelectionDragStart:C,onSelectionDragStop:z,onMove:p,onMoveStart:c,onMoveEnd:f,noPanClassName:_c,nodeOrigin:zr,rfId:il,autoPanOnConnect:X0,autoPanOnNodeDrag:Q0,autoPanSpeed:G0,onError:q0,connectionRadius:K0,isValidConnection:Z0,selectNodesOnDrag:ie,nodeDragThreshold:ey,connectionDragThreshold:ty,onBeforeDelete:$,debug:ly,ariaLabelConfig:ay,zIndexMode:Nc}),d.jsx(r_,{onSelectionChange:T}),j0,d.jsx(qk,{proOptions:V0,position:H0}),d.jsx(Zk,{rfId:il,disableKeyboardA11y:Ec})]})})}var Tb=Rm(zb);function Pb(e){const[t,n]=M.useState(e),r=M.useCallback(o=>n(i=>Pm(o,i)),[]);return[t,n,r]}function Ib(e){const[t,n]=M.useState(e),r=M.useCallback(o=>n(i=>Im(o,i)),[]);return[t,n,r]}function Rb({dimensions:e,lineWidth:t,variant:n,className:r}){return d.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:we(["react-flow__background-pattern",n,r])})}function Lb({radius:e,className:t}){return d.jsx("circle",{cx:e,cy:e,r:e,className:we(["react-flow__background-pattern","dots",t])})}var un;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(un||(un={}));const Ab={[un.Dots]:1,[un.Lines]:1,[un.Cross]:6},$b=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function o0({id:e,variant:t=un.Dots,gap:n=20,size:r,lineWidth:o=1,offset:i=0,color:s,bgColor:l,style:a,className:u,patternClassName:p}){const c=M.useRef(null),{transform:f,patternId:x}=ne($b,fe),y=r||Ab[t],v=t===un.Dots,k=t===un.Cross,m=Array.isArray(n)?n:[n,n],g=[m[0]*f[2]||1,m[1]*f[2]||1],h=y*f[2],w=Array.isArray(i)?i:[i,i],_=k?[h,h]:g,S=[w[0]*f[2]||1+_[0]/2,w[1]*f[2]||1+_[1]/2],b=`${x}${e||""}`;return d.jsxs("svg",{className:we(["react-flow__background",u]),style:{...a,...tl,"--xy-background-color-props":l,"--xy-background-pattern-color-props":s},ref:c,"data-testid":"rf__background",children:[d.jsx("pattern",{id:b,x:f[0]%g[0],y:f[1]%g[1],width:g[0],height:g[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${S[0]},-${S[1]})`,children:v?d.jsx(Lb,{radius:h/2,className:p}):d.jsx(Rb,{dimensions:_,lineWidth:o,variant:t,className:p})}),d.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${b})`})]})}o0.displayName="Background";const Db=M.memo(o0);function Ob(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:d.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function Bb(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:d.jsx("path",{d:"M0 0h32v4.2H0z"})})}function Fb(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:d.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function Hb(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function Vb(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function _i({children:e,className:t,...n}){return d.jsx("button",{type:"button",className:we(["react-flow__controls-button",t]),...n,children:e})}const Wb=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function i0({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:o,onZoomIn:i,onZoomOut:s,onFitView:l,onInteractiveChange:a,className:u,children:p,position:c="bottom-left",orientation:f="vertical","aria-label":x}){const y=pe(),{isInteractive:v,minZoomReached:k,maxZoomReached:m,ariaLabelConfig:g}=ne(Wb,fe),{zoomIn:h,zoomOut:w,fitView:_}=xc(),S=()=>{h(),i==null||i()},b=()=>{w(),s==null||s()},E=()=>{_(o),l==null||l()},A=()=>{y.setState({nodesDraggable:!v,nodesConnectable:!v,elementsSelectable:!v}),a==null||a(!v)},D=f==="horizontal"?"horizontal":"vertical";return d.jsxs(el,{className:we(["react-flow__controls",D,u]),position:c,style:e,"data-testid":"rf__controls","aria-label":x??g["controls.ariaLabel"],children:[t&&d.jsxs(d.Fragment,{children:[d.jsx(_i,{onClick:S,className:"react-flow__controls-zoomin",title:g["controls.zoomIn.ariaLabel"],"aria-label":g["controls.zoomIn.ariaLabel"],disabled:m,children:d.jsx(Ob,{})}),d.jsx(_i,{onClick:b,className:"react-flow__controls-zoomout",title:g["controls.zoomOut.ariaLabel"],"aria-label":g["controls.zoomOut.ariaLabel"],disabled:k,children:d.jsx(Bb,{})})]}),n&&d.jsx(_i,{className:"react-flow__controls-fitview",onClick:E,title:g["controls.fitView.ariaLabel"],"aria-label":g["controls.fitView.ariaLabel"],children:d.jsx(Fb,{})}),r&&d.jsx(_i,{className:"react-flow__controls-interactive",onClick:A,title:g["controls.interactive.ariaLabel"],"aria-label":g["controls.interactive.ariaLabel"],children:v?d.jsx(Vb,{}):d.jsx(Hb,{})}),p]})}i0.displayName="Controls";const Ub=M.memo(i0);function Yb({id:e,x:t,y:n,width:r,height:o,style:i,color:s,strokeColor:l,strokeWidth:a,className:u,borderRadius:p,shapeRendering:c,selected:f,onClick:x}){const{background:y,backgroundColor:v}=i||{},k=s||y||v;return d.jsx("rect",{className:we(["react-flow__minimap-node",{selected:f},u]),x:t,y:n,rx:p,ry:p,width:r,height:o,style:{fill:k,stroke:l,strokeWidth:a},shapeRendering:c,onClick:x?m=>x(m,e):void 0})}const Xb=M.memo(Yb),Qb=e=>e.nodes.map(t=>t.id),Fl=e=>e instanceof Function?e:()=>e;function Gb({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:o,nodeComponent:i=Xb,onClick:s}){const l=ne(Qb,fe),a=Fl(t),u=Fl(e),p=Fl(n),c=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return d.jsx(d.Fragment,{children:l.map(f=>d.jsx(Zb,{id:f,nodeColorFunc:a,nodeStrokeColorFunc:u,nodeClassNameFunc:p,nodeBorderRadius:r,nodeStrokeWidth:o,NodeComponent:i,onClick:s,shapeRendering:c},f))})}function Kb({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:o,nodeStrokeWidth:i,shapeRendering:s,NodeComponent:l,onClick:a}){const{node:u,x:p,y:c,width:f,height:x}=ne(y=>{const v=y.nodeLookup.get(e);if(!v)return{node:void 0,x:0,y:0,width:0,height:0};const k=v.internals.userNode,{x:m,y:g}=v.internals.positionAbsolute,{width:h,height:w}=Ht(k);return{node:k,x:m,y:g,width:h,height:w}},fe);return!u||u.hidden||!nm(u)?null:d.jsx(l,{x:p,y:c,width:f,height:x,style:u.style,selected:!!u.selected,className:r(u),color:t(u),borderRadius:o,strokeColor:n(u),strokeWidth:i,shapeRendering:s,onClick:a,id:u.id})}const Zb=M.memo(Kb);var qb=M.memo(Gb);const Jb=200,eC=150,tC=e=>!e.hidden,nC=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?tm(Xo(e.nodeLookup,{filter:tC}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},rC="react-flow__minimap-desc";function s0({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:o="",nodeBorderRadius:i=5,nodeStrokeWidth:s,nodeComponent:l,bgColor:a,maskColor:u,maskStrokeColor:p,maskStrokeWidth:c,position:f="bottom-right",onClick:x,onNodeClick:y,pannable:v=!1,zoomable:k=!1,ariaLabel:m,inversePan:g,zoomStep:h=1,offsetScale:w=5}){const _=pe(),S=M.useRef(null),{boundingRect:b,viewBB:E,rfId:A,panZoom:D,translateExtent:P,flowWidth:I,flowHeight:T,ariaLabelConfig:C}=ne(nC,fe),L=(e==null?void 0:e.width)??Jb,z=(e==null?void 0:e.height)??eC,R=b.width/L,j=b.height/z,N=Math.max(R,j),$=N*L,O=N*z,B=w*N,W=b.x-($-b.width)/2-B,V=b.y-(O-b.height)/2-B,Y=$+B*2,X=O+B*2,Q=`${rC}-${A}`,H=M.useRef(0),K=M.useRef();H.current=N,M.useEffect(()=>{if(S.current&&D)return K.current=nk({domNode:S.current,panZoom:D,getTransform:()=>_.getState().transform,getViewScale:()=>H.current}),()=>{var Z;(Z=K.current)==null||Z.destroy()}},[D]),M.useEffect(()=>{var Z;(Z=K.current)==null||Z.update({translateExtent:P,width:I,height:T,inversePan:g,pannable:v,zoomStep:h,zoomable:k})},[v,k,g,h,P,I,T]);const ee=x?Z=>{var ie;const[re,le]=((ie=K.current)==null?void 0:ie.pointer(Z))||[0,0];x(Z,{x:re,y:le})}:void 0,G=y?M.useCallback((Z,re)=>{const le=_.getState().nodeLookup.get(re).internals.userNode;y(Z,le)},[]):void 0,J=m??C["minimap.ariaLabel"];return d.jsx(el,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof a=="string"?a:void 0,"--xy-minimap-mask-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-stroke-width-props":typeof c=="number"?c*N:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof s=="number"?s:void 0},className:we(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:d.jsxs("svg",{width:L,height:z,viewBox:`${W} ${V} ${Y} ${X}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":Q,ref:S,onClick:ee,children:[J&&d.jsx("title",{id:Q,children:J}),d.jsx(qb,{onClick:G,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:o,nodeStrokeWidth:s,nodeComponent:l}),d.jsx("path",{className:"react-flow__minimap-mask",d:`M${W-B},${V-B}h${Y+B*2}v${X+B*2}h${-Y-B*2}z - M${E.x},${E.y}h${E.width}v${E.height}h${-E.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}s0.displayName="MiniMap";M.memo(s0);const oC=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,iC={[An.Line]:"right",[An.Handle]:"bottom-right"};function sC({nodeId:e,position:t,variant:n=An.Handle,className:r,style:o=void 0,children:i,color:s,minWidth:l=10,minHeight:a=10,maxWidth:u=Number.MAX_VALUE,maxHeight:p=Number.MAX_VALUE,keepAspectRatio:c=!1,resizeDirection:f,autoScale:x=!0,shouldResize:y,onResizeStart:v,onResize:k,onResizeEnd:m}){const g=Dm(),h=typeof e=="string"?e:g,w=pe(),_=M.useRef(null),S=n===An.Handle,b=ne(M.useCallback(oC(S&&x),[S,x]),fe),E=M.useRef(null),A=t??iC[n];M.useEffect(()=>{if(!(!_.current||!h))return E.current||(E.current=xk({domNode:_.current,nodeId:h,getStoreItems:()=>{const{nodeLookup:P,transform:I,snapGrid:T,snapToGrid:C,nodeOrigin:L,domNode:z}=w.getState();return{nodeLookup:P,transform:I,snapGrid:T,snapToGrid:C,nodeOrigin:L,paneDomNode:z}},onChange:(P,I)=>{const{triggerNodeChanges:T,nodeLookup:C,parentLookup:L,nodeOrigin:z}=w.getState(),R=[],j={x:P.x,y:P.y},N=C.get(h);if(N&&N.expandParent&&N.parentId){const $=N.origin??z,O=P.width??N.measured.width??0,B=P.height??N.measured.height??0,W={id:N.id,parentId:N.parentId,rect:{width:O,height:B,...rm({x:P.x??N.position.x,y:P.y??N.position.y},{width:O,height:B},N.parentId,C,$)}},V=yc([W],C,L,z);R.push(...V),j.x=P.x?Math.max($[0]*O,P.x):void 0,j.y=P.y?Math.max($[1]*B,P.y):void 0}if(j.x!==void 0&&j.y!==void 0){const $={id:h,type:"position",position:{...j}};R.push($)}if(P.width!==void 0&&P.height!==void 0){const O={id:h,type:"dimensions",resizing:!0,setAttributes:f?f==="horizontal"?"width":"height":!0,dimensions:{width:P.width,height:P.height}};R.push(O)}for(const $ of I){const O={...$,type:"position"};R.push(O)}T(R)},onEnd:({width:P,height:I})=>{const T={id:h,type:"dimensions",resizing:!1,dimensions:{width:P,height:I}};w.getState().triggerNodeChanges([T])}})),E.current.update({controlPosition:A,boundaries:{minWidth:l,minHeight:a,maxWidth:u,maxHeight:p},keepAspectRatio:c,resizeDirection:f,onResizeStart:v,onResize:k,onResizeEnd:m,shouldResize:y}),()=>{var P;(P=E.current)==null||P.destroy()}},[A,l,a,u,p,c,v,k,m,y]);const D=A.split("-");return d.jsx("div",{className:we(["react-flow__resize-control","nodrag",...D,n,r]),ref:_,style:{...o,scale:b,...s&&{[S?"backgroundColor":"borderColor"]:s}},children:i})}const Hf=M.memo(sC);function lC({nodeId:e,isVisible:t=!0,handleClassName:n,handleStyle:r,lineClassName:o,lineStyle:i,color:s,minWidth:l=10,minHeight:a=10,maxWidth:u=Number.MAX_VALUE,maxHeight:p=Number.MAX_VALUE,keepAspectRatio:c=!1,autoScale:f=!0,shouldResize:x,onResizeStart:y,onResize:v,onResizeEnd:k}){return t?d.jsxs(d.Fragment,{children:[fk.map(m=>d.jsx(Hf,{className:o,style:i,nodeId:e,position:m,variant:An.Line,color:s,minWidth:l,minHeight:a,maxWidth:u,maxHeight:p,onResizeStart:y,keepAspectRatio:c,autoScale:f,shouldResize:x,onResize:v,onResizeEnd:k},m)),dk.map(m=>d.jsx(Hf,{className:n,style:r,nodeId:e,position:m,color:s,minWidth:l,minHeight:a,maxWidth:u,maxHeight:p,onResizeStart:y,keepAspectRatio:c,autoScale:f,shouldResize:x,onResize:v,onResizeEnd:k},m))]}):null}const ou={compute:"#10b981",database:"#8b5cf6",storage:"#6366f1",network:"#3b82f6",security:"#ef4444",serverless:"#f59e0b",cache:"#8b5cf6",queue:"#f97316",cdn:"#3b82f6",monitoring:"#06b6d4",ml:"#ec4899",analytics:"#a855f7",containers:"#14b8a6",streaming:"#f97316",orchestration:"#a78bfa"},aC={ec2:"compute",ecs:"compute",eks:"compute",emr:"compute",fargate:"compute",codepipeline:"compute",codecommit:"storage",codebuild:"compute",dms:"compute",migration_hub:"compute",compute_engine:"compute",gke:"containers",app_engine:"serverless",cloud_build:"compute",virtual_machines:"compute",aks:"containers",container_apps:"containers",azure_devops:"compute",azure_migrate:"compute",rds:"database",aurora:"database",dynamodb:"database",cloud_sql:"database",azure_sql:"database",cosmos_db:"database",redshift:"database",bigquery:"database",firestore:"database",spanner:"database",alloydb:"database",s3:"storage",cloud_storage:"storage",blob_storage:"storage",ebs:"storage",ecr:"storage",fsx:"storage",efs:"storage",artifact_registry:"storage",alb:"network",nlb:"network",route53:"network",cloud_load_balancing:"network",app_gateway:"network",cloud_dns:"network",direct_connect:"network",vpn:"network",azure_lb:"network",azure_dns:"network",cloud_interconnect:"network",api_management:"network",cloudfront:"cdn",cloud_cdn:"cdn",azure_cdn:"cdn",waf:"security",cognito:"security",kms:"security",cloudtrail:"security",guardduty:"security",shield:"security",security_hub:"security",config:"security",inspector:"security",cloud_armor:"security",firebase_auth:"security",azure_waf:"security",azure_ad:"security",azure_firewall:"security",azure_sentinel:"security",azure_policy:"security",lambda:"serverless",api_gateway:"serverless",cloud_functions:"serverless",cloud_run:"serverless",azure_functions:"serverless",step_functions:"serverless",glue:"serverless",app_service:"serverless",elasticache:"cache",memorystore:"cache",azure_cache:"cache",sqs:"queue",sns:"queue",pub_sub:"queue",service_bus:"queue",kinesis:"queue",eventbridge:"queue",cloudwatch:"monitoring",cloud_logging:"monitoring",azure_monitor:"monitoring",sagemaker:"ml",vertex_ai:"ml",azure_ml:"ml",athena:"analytics",dataproc:"analytics",data_factory:"analytics",synapse:"analytics",dataflow:"streaming",event_hubs:"streaming",cloud_composer:"orchestration",logic_apps:"orchestration",databricks_sql_warehouse:"analytics",databricks_cluster:"compute",databricks_job:"orchestration",databricks_pipeline:"streaming",databricks_model_serving:"ml",databricks_unity_catalog:"security",databricks_vector_search:"database",databricks_genie:"analytics",databricks_notebook:"compute",databricks_secret_scope:"security",databricks_dashboard:"analytics",databricks_volume:"storage"},Vf={compute:"M5 12H3l9-9 9 9h-2M5 12v7a2 2 0 002 2h10a2 2 0 002-2v-7",database:"M12 2C6.48 2 2 4.24 2 7v10c0 2.76 4.48 5 10 5s10-2.24 10-5V7c0-2.76-4.48-5-10-5zM2 12c0 2.76 4.48 5 10 5s10-2.24 10-5",storage:"M20 7H4a1 1 0 00-1 1v8a1 1 0 001 1h16a1 1 0 001-1V8a1 1 0 00-1-1zM4 12h16",network:"M12 2a10 10 0 100 20 10 10 0 000-20zm0 0a14.5 14.5 0 014 10 14.5 14.5 0 01-4 10 14.5 14.5 0 01-4-10A14.5 14.5 0 0112 2zM2 12h20",security:"M12 2l7 4v5c0 5.25-3.5 10.74-7 12-3.5-1.26-7-6.75-7-12V6l7-4z",serverless:"M13 2L3 14h9l-1 8 10-12h-9l1-8z",cache:"M4 4h16v4H4zM4 10h16v4H4zM4 16h16v4H4z",queue:"M4 6h16M4 12h16M4 18h16",cdn:"M12 2a10 10 0 100 20 10 10 0 000-20zm-1 17.93A8 8 0 013 12a8 8 0 018-7.93M12 2v20M2 12h20M4.22 7h15.56M4.22 17h15.56",monitoring:"M3 3v18h18M7 16l4-8 4 4 4-6",ml:"M12 2a4 4 0 014 4c0 1.95-1.4 3.57-3.24 3.9L12 14l-.76-4.1A4 4 0 018 6a4 4 0 014-4zM8 14h8M6 18h12M9 22h6",analytics:"M18 20V10M12 20V4M6 20v-6",containers:"M21 16V8a2 2 0 00-1-1.73l-7-4a2 2 0 00-2 0l-7 4A2 2 0 003 8v8a2 2 0 001 1.73l7 4a2 2 0 002 0l7-4A2 2 0 0021 16zM3.27 6.96L12 12l8.73-5.04M12 22.08V12",streaming:"M2 12c2-3 4-3 6 0s4 3 6 0 4-3 6 0 4 3 6 0",orchestration:"M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83"};function wc(e){return aC[e]||"compute"}function l0(e){return ou[e]||"#94a3b8"}function Sc(e){return Vf[e]||Vf.compute}function uC({data:e}){const t=e,n=wc(t.service),r=l0(n),o=Sc(n);return d.jsxs("div",{style:{background:"#ffffff",border:`2px solid ${r}`,borderRadius:10,padding:"8px 12px",color:"#0f172a",minWidth:160,position:"relative",boxShadow:"0 1px 3px rgba(0,0,0,0.08)"},children:[d.jsx(Cr,{type:"target",position:q.Top,style:{background:r}}),d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[d.jsx("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",style:{display:"block",width:28,height:28,padding:5,borderRadius:6,background:`${r}22`},children:d.jsx("path",{d:o})}),d.jsx("span",{style:{fontSize:9,color:"#64748b",textTransform:"uppercase",letterSpacing:1},children:n})]}),d.jsx("div",{style:{fontWeight:600,fontSize:13,marginBottom:2,color:"#0f172a"},children:t.label}),d.jsxs("div",{style:{fontSize:11,color:"#64748b"},children:[t.service,d.jsx("span",{style:{marginLeft:6,padding:"1px 4px",borderRadius:3,background:"#e2e8f0",color:"#475569",fontSize:9,textTransform:"uppercase"},children:t.provider})]}),t.monthlyCost!=null&&t.monthlyCost>0&&d.jsxs("div",{style:{fontSize:10,color:"#2563eb",marginTop:4},children:["$",t.monthlyCost.toFixed(0),"/mo"]}),d.jsx(Cr,{type:"source",position:q.Bottom,style:{background:r}})]})}const cC=M.memo(uC);function dC({data:e,selected:t}){return d.jsxs(d.Fragment,{children:[d.jsx(lC,{color:e.dotColor,isVisible:t??!1,minWidth:200,minHeight:100,lineStyle:{borderWidth:1.5},handleStyle:{width:8,height:8,borderRadius:2}}),d.jsxs("div",{style:{position:"absolute",top:6,left:8,display:"inline-flex",alignItems:"center",gap:5,padding:"3px 10px 3px 7px",borderRadius:5,background:e.labelBg,border:`1px solid ${e.dotColor}30`,boxShadow:"0 1px 2px rgba(0,0,0,0.04)",pointerEvents:"none"},children:[d.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:e.dotColor,flexShrink:0}}),d.jsx("span",{style:{color:e.labelColor,fontSize:11,fontWeight:600,letterSpacing:"0.02em",whiteSpace:"nowrap",lineHeight:1},children:e.label})]})]})}function fC({components:e}){const[t,n]=M.useState(!1),r=M.useMemo(()=>{if(!e||e.length===0)return Object.keys(ou).map(i=>({category:i,count:0}));const o={};for(const i of e){const s=wc(i.service);o[s]=(o[s]||0)+1}return Object.entries(o).sort(([,i],[,s])=>s-i).map(([i,s])=>({category:i,count:s}))},[e]);return d.jsxs("div",{style:{position:"absolute",bottom:16,left:16,zIndex:10,background:"#ffffff",border:"1px solid #e2e8f0",borderRadius:8,padding:"8px 12px",fontSize:11,color:"#64748b",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",maxHeight:t?"auto":260,overflowY:t?"visible":"auto"},children:[d.jsxs("div",{onClick:()=>n(o=>!o),style:{fontWeight:600,marginBottom:t?0:4,color:"#0f172a",cursor:"pointer",userSelect:"none",display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:["Legend",d.jsx("span",{style:{fontSize:10,color:"#94a3b8"},children:t?"+":"-"})]}),!t&&r.map(({category:o,count:i})=>{const s=ou[o]||"#94a3b8",l=Sc(o);return d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:2},children:[d.jsx("svg",{width:12,height:12,viewBox:"0 0 24 24",fill:"none",stroke:s,strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:d.jsx("path",{d:l})}),d.jsx("span",{style:{textTransform:"capitalize"},children:o}),i>0&&d.jsxs("span",{style:{color:"#94a3b8",fontSize:10},children:["(",i,")"]})]},o)})]})}function pC({onExportSvg:e,onExportPng:t,showBoundaries:n,onToggleBoundaries:r}){const o={padding:"4px 10px",borderRadius:4,border:"1px solid #e2e8f0",background:"#ffffff",color:"#475569",cursor:"pointer",fontSize:11};return d.jsxs("div",{style:{position:"absolute",top:16,right:16,zIndex:10,display:"flex",gap:4,background:"#ffffff",padding:4,border:"1px solid #e2e8f0",borderRadius:8,boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:[e&&d.jsx("button",{style:o,onClick:e,children:"Export SVG"}),t&&d.jsx("button",{style:o,onClick:t,children:"Export PNG"}),d.jsxs("button",{style:{...o,background:n?"#f1f5f9":"#ffffff"},onClick:r,children:[n?"Hide":"Show"," Boundaries"]})]})}const Wf={borderTop:"1px solid #e2e8f0",margin:"12px 0"},bi={fontSize:11,fontWeight:600,color:"#64748b",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:8},Hl={display:"block",fontSize:12,fontWeight:600,color:"#64748b",marginBottom:5},Wr={width:"100%",boxSizing:"border-box",border:"1px solid #cbd5e1",borderRadius:6,padding:"8px 10px",color:"#0f172a",fontSize:13,outline:"none",background:"#ffffff"},Vl={display:"flex",justifyContent:"space-between",alignItems:"center",gap:10,color:"#475569",fontSize:13,marginBottom:7};function a0(e){return typeof e=="boolean"?e?"true":"false":e==null?"":String(e)}function hC(e,t){return Object.entries(e??{}).filter(([n,r])=>r!=null&&n!=="tags").map(([n,r])=>`${n}=${a0(r)}`).join(` -`)}function gC(e){const t=e==null?void 0:e.tags;return!t||typeof t!="object"||Array.isArray(t)?"":Object.entries(t).map(([n,r])=>`${n}=${a0(r)}`).join(` -`)}function mC(e){const t=e.trim();return t==="true"?!0:t==="false"?!1:t!==""&&!Number.isNaN(Number(t))?Number(t):e}function Uf(e){const t={};for(const n of e.split(` -`)){const r=n.trim();if(!r)continue;const o=r.indexOf("=");if(o===-1){t[r]=!0;continue}const i=r.slice(0,o).trim();i&&(t[i]=mC(r.slice(o+1)))}return t}function yC({component:e,cost:t,onClose:n,onApply:r,onDelete:o}){var S;const i=e!==null,[s,l]=M.useState(""),[a,u]=M.useState(""),[p,c]=M.useState("2"),[f,x]=M.useState(""),[y,v]=M.useState("");M.useEffect(()=>{e&&(l(e.label),u(e.description??""),c(String(e.tier??2)),x(hC(e.config)),v(gC(e.config)))},[e]);const k=e?wc(e.service):"compute",m=l0(k),g=Sc(k),h=(t==null?void 0:t.monthly)??null,w=M.useMemo(()=>{const b=Number(p);return Number.isFinite(b)?b:2},[p]),_=()=>{if(!e)return;const b=Uf(f),E=Uf(y);Object.keys(E).length>0&&(b.tags=E),r({...e,label:s.trim()||e.label,description:a,tier:w,config:b})};return d.jsxs("div",{style:{position:"absolute",top:0,right:0,width:340,height:"100%",background:"#ffffff",borderLeft:"1px solid #e2e8f0",transform:i?"translateX(0)":"translateX(100%)",transition:"transform 0.2s ease",zIndex:20,display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"-2px 0 8px rgba(0,0,0,0.06)"},children:[d.jsxs("div",{style:{padding:"16px 16px 12px",borderBottom:"1px solid #e2e8f0"},children:[d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:[d.jsx("div",{style:{width:36,height:36,borderRadius:8,background:`${m}22`,border:`1.5px solid ${m}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:d.jsx("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:m,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",style:{display:"block"},children:d.jsx("path",{d:g})})}),d.jsx("span",{style:{fontSize:16,fontWeight:700,color:"#0f172a",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(e==null?void 0:e.label)??"Resource"}),d.jsx("button",{onClick:n,style:{background:"none",border:"none",color:"#94a3b8",cursor:"pointer",fontSize:18,lineHeight:1,padding:"2px 4px",flexShrink:0},"aria-label":"Close panel",children:"x"})]}),d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[d.jsx("span",{style:{background:"#f1f5f9",color:"#475569",borderRadius:4,fontSize:11,fontWeight:600,padding:"2px 8px",textTransform:"uppercase"},children:e==null?void 0:e.provider}),d.jsx("span",{style:{color:"#64748b",fontSize:12},children:e==null?void 0:e.service})]})]}),d.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"12px 16px"},children:[d.jsx("div",{style:bi,children:"Overview"}),d.jsx("label",{style:Hl,htmlFor:"resource-label",children:"Label"}),d.jsx("input",{id:"resource-label","aria-label":"Label",value:s,onChange:b=>l(b.target.value),style:{...Wr,marginBottom:10}}),d.jsx("label",{style:Hl,htmlFor:"resource-description",children:"Description"}),d.jsx("textarea",{id:"resource-description","aria-label":"Description",value:a,onChange:b=>u(b.target.value),rows:3,style:{...Wr,marginBottom:10,resize:"vertical",minHeight:72}}),d.jsx("label",{style:Hl,htmlFor:"resource-tier",children:"Tier"}),d.jsx("input",{id:"resource-tier","aria-label":"Tier",type:"number",value:p,onChange:b=>c(b.target.value),style:{...Wr,marginBottom:10}}),d.jsxs("div",{style:Vl,children:[d.jsx("span",{children:"Service"}),d.jsx("strong",{style:{color:"#0f172a"},children:e==null?void 0:e.service})]}),d.jsxs("div",{style:Vl,children:[d.jsx("span",{children:"Provider"}),d.jsx("strong",{style:{color:"#0f172a"},children:(S=e==null?void 0:e.provider)==null?void 0:S.toUpperCase()})]}),d.jsx("div",{style:Wf}),d.jsx("div",{style:bi,children:"Cost"}),h!==null?d.jsxs("div",{style:Vl,children:[d.jsx("span",{children:"Monthly"}),d.jsxs("strong",{style:{color:"#2563eb"},children:["$",h.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]})]}):d.jsx("p",{style:{color:"#94a3b8",fontSize:13},children:"No cost data"}),d.jsx("div",{style:Wf}),d.jsx("div",{style:bi,children:"Configuration"}),d.jsx("textarea",{"aria-label":"Configuration",value:f,onChange:b=>x(b.target.value),rows:7,style:{...Wr,resize:"vertical",minHeight:140,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace"}}),d.jsx("div",{style:{...bi,marginTop:16},children:"Tags"}),d.jsx("textarea",{"aria-label":"Tags",value:y,onChange:b=>v(b.target.value),rows:5,style:{...Wr,resize:"vertical",minHeight:110,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace"}})]}),d.jsxs("div",{style:{padding:12,borderTop:"1px solid #e2e8f0",display:"flex",gap:8},children:[d.jsx("button",{onClick:_,disabled:!e,style:{flex:1,border:"none",borderRadius:6,padding:"10px 12px",background:"#2563eb",color:"#ffffff",cursor:e?"pointer":"not-allowed",fontSize:14,fontWeight:700},children:"Apply"}),d.jsx("button",{onClick:()=>e&&o(e.id),disabled:!e,style:{border:"1px solid #fecaca",borderRadius:6,padding:"10px 12px",background:"#fef2f2",color:"#b91c1c",cursor:e?"pointer":"not-allowed",fontSize:14,fontWeight:700},children:"Delete"})]})]})}const Yf="/api",Wl={border:"1px solid #cbd5e1",background:"#ffffff",color:"#0f172a",borderRadius:6,padding:"7px 10px",cursor:"pointer",fontSize:12,fontWeight:600};function xC({provider:e,standardsResult:t,onAddResource:n,onAddModule:r,onCheckStandards:o}){const i=(e||"aws").toLowerCase(),[s,l]=M.useState(!0),[a,u]=M.useState("resources"),[p,c]=M.useState(""),[f,x]=M.useState([]),[y,v]=M.useState([]);M.useEffect(()=>{fetch(`${Yf}/catalog/services?provider=${encodeURIComponent(i)}`).then(g=>g.ok?g.json():null).then(g=>x((g==null?void 0:g.services)??[])).catch(()=>x([]))},[i]),M.useEffect(()=>{fetch(`${Yf}/modules`).then(g=>g.ok?g.json():null).then(g=>v((g==null?void 0:g.modules)??[])).catch(()=>v([]))},[]);const k=M.useMemo(()=>{const g=p.trim().toLowerCase();return g?f.filter(h=>[h.name,h.service_key,h.category,h.description??""].some(w=>w.toLowerCase().includes(g))):f},[f,p]),m=M.useMemo(()=>{const g=p.trim().toLowerCase(),h=y.filter(w=>w.provider.toLowerCase()===i);return g?h.filter(w=>[w.name,w.id,w.category,w.description??"",...w.tags??[]].some(_=>_.toLowerCase().includes(g))):h},[y,i,p]);return s?d.jsxs("div",{style:{position:"absolute",top:0,left:0,width:320,height:"100%",zIndex:14,background:"#ffffff",borderRight:"1px solid #e2e8f0",boxShadow:"2px 0 8px rgba(0,0,0,0.06)",display:"flex",flexDirection:"column"},children:[d.jsxs("div",{style:{padding:14,borderBottom:"1px solid #e2e8f0"},children:[d.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:10},children:[d.jsx("div",{style:{fontSize:15,fontWeight:700,color:"#0f172a"},children:"Catalog"}),d.jsx("button",{onClick:()=>l(!1),style:{border:"none",background:"transparent",color:"#64748b",cursor:"pointer",fontSize:18},"aria-label":"Close catalog",children:"x"})]}),d.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:4,marginBottom:10},children:["resources","modules","standards"].map(g=>d.jsx("button",{onClick:()=>u(g),style:{...Wl,padding:"6px 4px",borderColor:a===g?"#2563eb":"#cbd5e1",color:a===g?"#2563eb":"#475569",background:a===g?"#eff6ff":"#ffffff",textTransform:"capitalize"},children:g},g))}),a!=="standards"&&d.jsx("input",{value:p,onChange:g=>c(g.target.value),placeholder:"Search",style:{width:"100%",boxSizing:"border-box",border:"1px solid #cbd5e1",borderRadius:6,padding:"8px 10px",color:"#0f172a",fontSize:13,outline:"none"}})]}),d.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12},children:[a==="resources"&&k.map(g=>d.jsxs("button",{onClick:()=>n(g),style:{width:"100%",textAlign:"left",border:"1px solid #e2e8f0",background:"#ffffff",borderRadius:8,padding:10,marginBottom:8,cursor:"pointer"},children:[d.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:8},children:[d.jsx("span",{style:{color:"#0f172a",fontSize:13,fontWeight:700},children:g.name}),d.jsx("span",{style:{color:"#64748b",fontSize:10,textTransform:"uppercase"},children:g.category.replace(/_/g," ")})]}),d.jsx("div",{style:{color:"#64748b",fontSize:11,marginTop:4},children:g.service_key})]},`${g.provider}:${g.service_key}`)),a==="resources"&&k.length===0&&d.jsxs("p",{style:{color:"#64748b",fontSize:13},children:["No resources found for ",i.toUpperCase(),"."]}),a==="modules"&&m.map(g=>d.jsxs("button",{onClick:()=>r(g.id),style:{width:"100%",textAlign:"left",border:"1px solid #bfdbfe",background:"#eff6ff",borderRadius:8,padding:10,marginBottom:8,cursor:"pointer"},children:[d.jsx("div",{style:{color:"#0f172a",fontSize:13,fontWeight:700},children:g.name}),d.jsx("div",{style:{color:"#475569",fontSize:12,marginTop:4,lineHeight:1.35},children:g.description}),d.jsx("div",{style:{color:"#2563eb",fontSize:11,marginTop:6,textTransform:"uppercase"},children:g.category})]},g.id)),a==="modules"&&m.length===0&&d.jsxs("p",{style:{color:"#64748b",fontSize:13},children:["No approved modules found for ",i.toUpperCase(),"."]}),a==="standards"&&d.jsxs(d.Fragment,{children:[d.jsx("button",{onClick:o,style:{...Wl,width:"100%",marginBottom:12},children:"Check Standards"}),!t&&d.jsx("p",{style:{color:"#64748b",fontSize:13},children:"No standards check has run."}),(t==null?void 0:t.passed)&&d.jsx("div",{style:{color:"#166534",background:"#dcfce7",borderRadius:8,padding:10,fontSize:13},children:"Standards passed."}),t&&!t.passed&&d.jsx("div",{children:t.violations.map((g,h)=>d.jsxs("div",{style:{border:"1px solid #fecaca",background:"#fef2f2",borderRadius:8,padding:10,marginBottom:8},children:[d.jsx("div",{style:{color:"#991b1b",fontSize:12,fontWeight:700},children:g.code.replace(/_/g," ")}),d.jsx("div",{style:{color:"#7f1d1d",fontSize:12,marginTop:4,lineHeight:1.4},children:g.message})]},`${g.code}:${h}`))})]})]})]}):d.jsx("button",{onClick:()=>l(!0),style:{...Wl,position:"absolute",left:16,top:16,zIndex:15,boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:"Add Resource"})}const Xf=200,Ci=90,Qf=300,vC=240,yt=32,wC=36,Ur=4,Ul="/api",SC={0:"Edge / CDN",1:"Network / Ingress",2:"Application",3:"Data Layer",4:"Platform Services",5:"Platform Services"},kC={0:"edge",1:"subnet",2:"subnet",3:"subnet"},Yl={0:{border:"#60a5fa",bg:"rgba(219, 234, 254, 0.18)",labelColor:"#1d4ed8",labelBg:"rgba(219, 234, 254, 0.92)",dot:"#3b82f6"},1:{border:"#34d399",bg:"rgba(209, 250, 229, 0.18)",labelColor:"#047857",labelBg:"rgba(209, 250, 229, 0.92)",dot:"#10b981"},2:{border:"#fb923c",bg:"rgba(255, 237, 213, 0.18)",labelColor:"#9a3412",labelBg:"rgba(255, 237, 213, 0.92)",dot:"#f97316"},3:{border:"#a78bfa",bg:"rgba(237, 233, 254, 0.18)",labelColor:"#5b21b6",labelBg:"rgba(237, 233, 254, 0.92)",dot:"#8b5cf6"},4:{border:"#2dd4bf",bg:"rgba(204, 251, 241, 0.18)",labelColor:"#0f766e",labelBg:"rgba(204, 251, 241, 0.92)",dot:"#14b8a6"},5:{border:"#2dd4bf",bg:"rgba(204, 251, 241, 0.18)",labelColor:"#0f766e",labelBg:"rgba(204, 251, 241, 0.92)",dot:"#14b8a6"}},Hn={border:"#94a3b8",bg:"rgba(241, 245, 249, 0.35)",labelColor:"#475569",labelBg:"rgba(241, 245, 249, 0.92)",dot:"#94a3b8"},_C={cloudService:cC,boundaryGroup:dC};function iu(e){return JSON.parse(JSON.stringify(e))}function Ei(e){return iu(e??{})}function ji(e,t="resource"){let n=e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"_").replace(/^[_-]+|[_-]+$/g,"");return n||(n=t),/^[a-z_]/.test(n)||(n=`${t}_${n}`),n}function Xl(e,t){let n=e,r=2;for(;t.has(n);)n=`${e}-${r}`,r+=1;return t.add(n),n}function bC(e){const t=e.toLowerCase();return t.includes("cdn")||t.includes("edge")?0:t.includes("network")||t.includes("security")?1:t.includes("database")||t.includes("cache")?3:t.includes("storage")||t.includes("analytics")||t.includes("data")?4:2}function Gf(e){return{x:360+e%3*260,y:80+Math.floor(e/3)*150}}function CC(e,t){if(t==="vpc")return Hn;const n=e.match(/^tier-(\d+)$/);return n&&Yl[parseInt(n[1])]||Yl[2]}function EC(e){const t={};for(const i of e){const s=i.tier??2;t[s]||(t[s]=[]),t[s].push(i.id)}const n=Object.keys(t).map(Number).sort(),r=[];for(const i of n)r.push({id:`tier-${i}`,kind:kC[i]||"subnet",label:SC[i]||`Tier ${i}`,component_ids:t[i]});const o=r.filter(i=>i.id!=="tier-0").flatMap(i=>i.component_ids);return o.length>=2&&r.unshift({id:"vpc",kind:"vpc",label:"VPC / Virtual Network",component_ids:o}),r}function jC(e,t,n){var y,v,k,m;const r=[],o=e.boundaries||[],i=o.length>0?o:EC(e.components),s=((v=(y=e.metadata)==null?void 0:y.canvas)==null?void 0:v.nodes)??{},l={};if(t){for(const g of i)if(g.kind!=="vpc")for(const h of g.component_ids)l[h]||(l[h]=g.id)}const a={};for(const g of e.components){const h=g.tier??2;a[h]||(a[h]=[]),a[h].push(g)}const u=Object.keys(a).map(Number).sort(),p={};let c=40;const f={};for(const g of u){f[g]=c;const h=Math.ceil(a[g].length/Ur);c+=vC+(h-1)*(Ci+60)}for(const g of u){const h=a[g],w=f[g];for(let _=0;_0){const g=i.find(w=>w.kind==="vpc");let h;if(g&&g.component_ids.length>0){const w=g.component_ids.map(D=>{var P;return((P=p[D])==null?void 0:P.x)??0}),_=g.component_ids.map(D=>{var P;return((P=p[D])==null?void 0:P.y)??0}),S=Math.min(...w)-yt,b=Math.min(..._)-yt-24-wC,E=Math.max(...w)+Xf+yt,A=Math.max(..._)+Ci+yt;h=`boundary-${g.id}`,x[g.id]={x:S,y:b},r.push({id:h,type:"boundaryGroup",position:{x:S,y:b},data:{label:g.label||g.id,labelColor:Hn.labelColor,labelBg:Hn.labelBg,dotColor:Hn.dot},style:{background:Hn.bg,border:`2px dashed ${Hn.border}`,borderRadius:16,padding:yt,width:E-S,height:A-b},zIndex:-2})}for(const w of i){if(w.kind==="vpc"||w.component_ids.length===0)continue;const _=w.component_ids.map(T=>{var C;return((C=p[T])==null?void 0:C.x)??0}),S=w.component_ids.map(T=>{var C;return((C=p[T])==null?void 0:C.y)??0}),b=Math.min(..._)-yt,E=Math.min(...S)-yt-24,A=Math.max(..._)+Xf+yt,D=Math.max(...S)+Ci+yt;x[w.id]={x:b,y:E};const P=CC(w.id,w.kind),I=!!(h&&g&&w.component_ids.some(T=>g.component_ids.includes(T)));r.push({id:`boundary-${w.id}`,type:"boundaryGroup",position:I?{x:b-x[g.id].x,y:E-x[g.id].y}:{x:b,y:E},data:{label:w.label||w.id,labelColor:P.labelColor,labelBg:P.labelBg,dotColor:P.dot},style:{background:P.bg,border:`1.5px solid ${P.border}`,borderRadius:10,padding:yt,width:A-b,height:D-E},zIndex:-1,parentId:I?h:void 0})}}for(const g of u){const h=a[g];for(const w of h){const _=l[w.id],S=t&&_&&x[_];let b=((k=p[w.id])==null?void 0:k.x)??0,E=((m=p[w.id])==null?void 0:m.y)??0;S&&(b-=x[_].x,E-=x[_].y),r.push({id:w.id,type:"cloudService",position:{x:b,y:E},data:{label:w.label,service:w.service,provider:w.provider,description:w.description,tier:w.tier,config:w.config||{},monthlyCost:n[w.id]},parentId:S?`boundary-${_}`:void 0,extent:S?"parent":void 0})}}return r}function u0(e,t){return`edge:${e.source}:${e.target}:${t}`}function Kf(e){return e.connections.map((t,n)=>{let r=t.label||"";return t.protocol&&!r.includes(t.protocol)&&(r=t.protocol+(t.port?`:${t.port}`:"")),{id:u0(t,n),source:t.source,target:t.target,label:r,style:{stroke:"#94a3b8"},labelStyle:{fill:"#64748b",fontSize:11},animated:!0}})}function NC(e,t){return e&&e.map(n=>({...n,component_ids:n.component_ids.filter(r=>r!==t)}))}function MC({spec:e,onSpecChange:t}){const[n,r]=M.useState(!0),[o,i]=M.useState(null),[s,l]=M.useState(null),a=M.useCallback(T=>{l(null),t(T)},[t]),u=M.useCallback(async T=>{try{const C=await fetch(`${Ul}/export`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({spec:e,format:T})});if(!C.ok)return;const L=await C.blob(),z=URL.createObjectURL(L),R=document.createElement("a");R.href=z,R.download=`architecture.${T}`,R.click(),URL.revokeObjectURL(z)}catch{}},[e]),p=M.useMemo(()=>{var C;const T={};for(const L of((C=e.cost_estimate)==null?void 0:C.breakdown)??[])T[L.component_id]=L.monthly;return T},[e.cost_estimate]),c=M.useMemo(()=>o?e.components.find(T=>T.id===o)??null:null,[o,e.components]),f=M.useMemo(()=>{var T;return o?((T=e.cost_estimate)==null?void 0:T.breakdown.find(C=>C.component_id===o))??null:null},[o,e.cost_estimate]),[x,y,v]=Pb([]),[k,m,g]=Ib([]);M.useEffect(()=>{y(jC(e,n,p)),m(Kf(e))},[e,n,p,y,m]);const h=M.useCallback((T,C)=>{C.id.startsWith("boundary-")||i(C.id)},[]),w=M.useCallback(()=>{i(null)},[]),_=M.useCallback((T,C)=>{if(C.id.startsWith("boundary-"))return;const L=Ei(e.metadata),z=L.canvas??{},R={...z.nodes??{}},j=x.find($=>$.id===C.parentId),N=j?{x:j.position.x+C.position.x,y:j.position.y+C.position.y}:{x:C.position.x,y:C.position.y};R[C.id]=N,L.canvas={...z,nodes:R},a({...e,metadata:L})},[a,x,e]),S=M.useCallback(T=>{!T.source||!T.target||T.source===T.target||e.connections.some(L=>L.source===T.source&&L.target===T.target)||a({...e,connections:[...e.connections,{source:T.source,target:T.target,label:"HTTPS",protocol:"HTTPS",port:443}]})},[a,e]),b=M.useCallback(T=>{if(T.length===0)return;if(!window.confirm(`Delete ${T.length===1?"this connection":"these connections"}?`)){m(Kf(e));return}const C=new Set(T.map(L=>L.id));a({...e,connections:e.connections.filter((L,z)=>!C.has(u0(L,z)))})},[a,m,e]),E=M.useCallback(T=>{a({...e,components:e.components.map(C=>C.id===T.id?T:C)})},[a,e]),A=M.useCallback(T=>{var R,j;const C=e.components.find(N=>N.id===T);if(!C||!window.confirm(`Delete ${C.label||C.id} and its connections?`))return;const L=Ei(e.metadata);(R=L.canvas)!=null&&R.nodes&&delete L.canvas.nodes[T];const z=((j=L.modules)==null?void 0:j.instances)??{};for(const N of Object.values(z))N.component_ids.includes(T)&&(N.component_ids=N.component_ids.filter($=>$!==T),N.partial=!0,N.approved=!1,delete N.terraform);L.modules&&(L.modules.instances=z),a({...e,components:e.components.filter(N=>N.id!==T),connections:e.connections.filter(N=>N.source!==T&&N.target!==T),boundaries:NC(e.boundaries,T),metadata:L}),i(null)},[a,e]),D=M.useCallback(T=>{const C=new Set(e.components.map($=>$.id)),L=Xl(ji(T.service_key),C),z=Ei(e.metadata),R=z.canvas??{},j={...R.nodes??{}};j[L]=Gf(Object.keys(j).length+e.components.length),z.canvas={...R,nodes:j};const N={id:L,service:T.service_key,provider:T.provider.toLowerCase(),label:T.name,description:T.description??"",tier:bC(T.category),config:iu(T.default_config??{})};a({...e,components:[...e.components,N],metadata:z}),i(L)},[a,e]),P=M.useCallback(async T=>{var C;try{const L=await fetch(`${Ul}/modules/${encodeURIComponent(T)}`);if(!L.ok)return;const R=(await L.json()).module,j=new Set(e.components.map(G=>G.id)),N=Ei(e.metadata),$=N.modules??{},O={...$.instances??{}},B=new Set(Object.keys(O)),W=Xl(ji(R.id,"module"),B),V=ji(R.naming.component_id_prefix,W),Y={};for(const G of R.fragment.components)Y[G.id]=Xl(ji(`${V}_${G.id}`,V),j);const X=N.canvas??{},Q={...X.nodes??{}},H=Object.keys(Q).length+e.components.length,K=R.fragment.components.map((G,J)=>{const Z=iu(G.config??{}),re={...R.default_tags??{},...typeof Z.tags=="object"&&Z.tags!==null?Z.tags:{}};Z.tags=re;const le=Y[G.id];return Q[le]=Gf(H+J),{...G,id:le,provider:G.provider.toLowerCase(),config:Z}}),ee=R.fragment.connections.map(G=>({...G,source:Y[G.source],target:Y[G.target]}));O[W]={module_id:R.id,module_version:R.terraform.version,component_ids:K.map(G=>G.id),expected_component_count:K.length,required_tags:[...R.required_tags],naming_prefix:V,approved:R.approved,terraform:{...R.terraform}},N.canvas={...X,nodes:Q},N.modules={...$,instances:O},a({...e,components:[...e.components,...K],connections:[...e.connections,...ee],metadata:N}),i(((C=K[0])==null?void 0:C.id)??null)}catch{}},[a,e]),I=M.useCallback(async()=>{try{const T=await fetch(`${Ul}/canvas/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({spec:e})});if(!T.ok)return;l(await T.json())}catch{l({passed:!1,violations:[{code:"request_failed",severity:"error",message:"Standards check failed."}]})}},[e]);return d.jsxs("div",{style:{width:"100%",height:"100%",position:"relative"},children:[d.jsx(xC,{provider:e.provider||"aws",standardsResult:s,onAddResource:D,onAddModule:P,onCheckStandards:I}),d.jsxs(Tb,{nodes:x,edges:k,nodeTypes:_C,onNodesChange:v,onEdgesChange:g,onEdgesDelete:b,onConnect:S,onNodeDragStop:_,fitView:!0,proOptions:{hideAttribution:!0},style:{background:"#f8fafc"},onNodeClick:h,onPaneClick:w,children:[d.jsx(Db,{color:"#e2e8f0",gap:20}),d.jsx(Ub,{style:{background:"#ffffff",border:"1px solid #e2e8f0",borderRadius:8}})]}),d.jsx(fC,{components:e.components}),d.jsx(pC,{showBoundaries:n,onToggleBoundaries:()=>r(T=>!T),onExportSvg:()=>u("svg"),onExportPng:()=>u("png")}),d.jsx(yC,{component:c??null,cost:f,onClose:()=>i(null),onApply:T=>E({...T,description:T.description??"",config:T.config??{}}),onDelete:A})]})}function zC({estimate:e}){return d.jsxs("div",{style:{padding:32},children:[d.jsx("h2",{style:{fontSize:18,marginBottom:16,color:"#0f172a"},children:"Cost Breakdown"}),d.jsxs("table",{style:{width:"100%",maxWidth:700,borderCollapse:"collapse",fontSize:14},children:[d.jsx("thead",{children:d.jsxs("tr",{style:{borderBottom:"2px solid #e2e8f0",background:"#f8fafc"},children:[d.jsx("th",{style:{textAlign:"left",padding:"10px 12px",color:"#475569"},children:"Component"}),d.jsx("th",{style:{textAlign:"left",padding:"10px 12px",color:"#475569"},children:"Service"}),d.jsx("th",{style:{textAlign:"right",padding:"10px 12px",color:"#475569"},children:"Monthly"}),d.jsx("th",{style:{textAlign:"left",padding:"10px 12px",color:"#475569"},children:"Notes"})]})}),d.jsx("tbody",{children:e.breakdown.map(t=>d.jsxs("tr",{style:{borderBottom:"1px solid #f1f5f9"},children:[d.jsx("td",{style:{padding:"10px 12px",color:"#0f172a"},children:t.component_id}),d.jsx("td",{style:{padding:"10px 12px",color:"#475569"},children:t.service}),d.jsxs("td",{style:{padding:"10px 12px",textAlign:"right",fontFamily:"monospace",color:"#0f172a"},children:["$",t.monthly.toFixed(2)]}),d.jsx("td",{style:{padding:"10px 12px",color:"#64748b",fontSize:12},children:t.notes})]},t.component_id))}),d.jsx("tfoot",{children:d.jsxs("tr",{style:{borderTop:"2px solid #e2e8f0",background:"#f0f9ff"},children:[d.jsx("td",{style:{padding:"12px",fontWeight:700,fontSize:15,color:"#0f172a"},colSpan:2,children:"Total"}),d.jsxs("td",{style:{padding:"12px",textAlign:"right",fontWeight:700,fontSize:15,fontFamily:"monospace",color:"#2563eb"},children:["$",e.monthly_total.toFixed(2)]}),d.jsxs("td",{style:{padding:"12px",color:"#64748b",fontSize:12},children:[e.currency,"/month"]})]})})]})]})}function TC({spec:e,onDownloadTerraform:t,onDownloadYaml:n,validationSummary:r,usage:o}){var s,l;if(!e)return null;const i=[];return o!=null&&o.model&&i.push(o.model.replace("claude-","").replace("anthropic.","")),(o==null?void 0:o.input_tokens)!=null&&(o==null?void 0:o.output_tokens)!=null&&i.push(`${((o.input_tokens+o.output_tokens)/1e3).toFixed(1)}k tokens`),(o==null?void 0:o.cost_usd)!=null&&i.push(`$${o.cost_usd.toFixed(4)}`),(o==null?void 0:o.latency_ms)!=null&&i.push(`${(o.latency_ms/1e3).toFixed(1)}s`),d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"1rem",padding:"0.5rem 1rem",background:"#ffffff",borderRadius:"0.375rem",marginBottom:"0.5rem",fontSize:"0.875rem",borderBottom:"1px solid #e2e8f0"},children:[d.jsxs("span",{style:{color:"#64748b"},children:["Components: ",d.jsx("strong",{style:{color:"#334155"},children:((s=e.components)==null?void 0:s.length)||0})]}),e.cost_estimate&&d.jsxs("span",{style:{color:"#64748b"},children:["Est. ",d.jsxs("strong",{style:{color:"#2563eb"},children:["$",(l=e.cost_estimate.monthly_total)==null?void 0:l.toFixed(0),"/mo"]})]}),d.jsxs("span",{style:{color:"#64748b"},children:[(e.provider||"aws").toUpperCase()," / ",e.region||"us-east-1"]}),r&&d.jsxs("span",{style:{padding:"0.125rem 0.5rem",borderRadius:"0.25rem",fontSize:"0.75rem",fontWeight:600,background:r.passed===r.total?"#d1fae5":"#fee2e2",color:r.passed===r.total?"#065f46":"#991b1b"},children:["WA: ",r.passed,"/",r.total]}),i.length>0&&d.jsx("span",{style:{color:"#94a3b8",fontSize:"0.75rem"},children:i.join(" · ")}),d.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:"0.5rem"},children:[t&&d.jsx("button",{onClick:t,style:{padding:"0.25rem 0.75rem",background:"#2563eb",color:"white",border:"none",borderRadius:"0.25rem",cursor:"pointer",fontSize:"0.75rem"},children:"Download Terraform"}),n&&d.jsx("button",{onClick:n,style:{padding:"0.25rem 0.75rem",background:"#f8fafc",color:"#475569",border:"1px solid #e2e8f0",borderRadius:"0.25rem",cursor:"pointer",fontSize:"0.75rem"},children:"Download YAML"})]})]})}async function Mr(e){if(e.status===429){const t=e.headers.get("Retry-After"),n=t?` Retry after ${t}s.`:"";try{const r=await e.json();return`${r.message||r.detail||"Rate limited"}${n}`}catch{return`Rate limited.${n}`}}try{const t=await e.json();return su(t,e.statusText)}catch{return e.statusText||"Request failed"}}function su(e,t="Request failed"){const n=e.message||e.detail||t;return e.suggestion?`${n} — ${e.suggestion}`:n}const PC=[{key:"hipaa",label:"HIPAA"},{key:"pci-dss",label:"PCI-DSS"},{key:"soc2",label:"SOC 2"},{key:"fedramp",label:"FedRAMP"},{key:"gdpr",label:"GDPR"},{key:"well-architected",label:"Well-Architected"}],Ni={critical:0,high:1,medium:2,low:3},Do={critical:{bg:"#fef2f2",text:"#991b1b",border:"#fca5a5"},high:{bg:"#fff7ed",text:"#9a3412",border:"#fdba74"},medium:{bg:"#fffbeb",text:"#92400e",border:"#fcd34d"},low:{bg:"#f0fdf4",text:"#166534",border:"#86efac"}},IC={data_protection:"Data Protection",monitoring:"Monitoring & Logging",identity:"Identity & Access",network_security:"Network Security",reliability:"Reliability",compliance:"Compliance",operations:"Operations",security:"Security",cost:"Cost Optimization"};function RC({score:e,passed:t}){const n=Math.round(e*100),r=54,o=8,i=2*Math.PI*r,s=i*(1-e),l=t?"#16a34a":n>=70?"#f59e0b":"#dc2626";return d.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:6},children:[d.jsxs("svg",{width:136,height:136,viewBox:"0 0 136 136",children:[d.jsx("circle",{cx:68,cy:68,r,fill:"none",stroke:"#f1f5f9",strokeWidth:o}),d.jsx("circle",{cx:68,cy:68,r,fill:"none",stroke:l,strokeWidth:o,strokeDasharray:i,strokeDashoffset:s,strokeLinecap:"round",transform:"rotate(-90 68 68)",style:{transition:"stroke-dashoffset 0.6s ease"}}),d.jsxs("text",{x:68,y:62,textAnchor:"middle",fontSize:28,fontWeight:700,fill:"#0f172a",children:[n,"%"]}),d.jsx("text",{x:68,y:82,textAnchor:"middle",fontSize:11,fill:"#64748b",children:"compliance"})]}),d.jsx("span",{style:{display:"inline-block",padding:"3px 12px",borderRadius:4,fontSize:12,fontWeight:600,background:t?"#dcfce7":"#fee2e2",color:t?"#166534":"#991b1b"},children:t?"PASSED":"FAILED"})]})}function LC({severity:e}){const t=Do[e]||Do.medium;return d.jsx("span",{style:{display:"inline-block",padding:"1px 8px",borderRadius:4,fontSize:11,fontWeight:600,background:t.bg,color:t.text,border:`1px solid ${t.border}`,textTransform:"uppercase",letterSpacing:"0.02em"},children:e})}function Zf({check:e,expanded:t,onToggle:n}){const r=Do[e.severity]||Do.medium;return d.jsxs("div",{style:{borderLeft:`3px solid ${e.passed?"#86efac":r.border}`,background:"#ffffff",borderRadius:"0 6px 6px 0",marginBottom:6,cursor:"pointer",transition:"box-shadow 0.15s ease"},onClick:n,onMouseEnter:o=>{o.currentTarget.style.boxShadow="0 1px 4px rgba(0,0,0,0.06)"},onMouseLeave:o=>{o.currentTarget.style.boxShadow="none"},children:[d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 14px"},children:[d.jsx("span",{style:{fontSize:14,flexShrink:0,width:18,textAlign:"center"},children:e.passed?d.jsx("span",{style:{color:"#16a34a"},children:"✓"}):d.jsx("span",{style:{color:"#dc2626",fontWeight:700},children:"✕"})}),d.jsx("span",{style:{flex:1,fontSize:13,color:"#0f172a",fontWeight:500},children:e.name.replace(/_/g," ").replace(/\b\w/g,o=>o.toUpperCase())}),d.jsx(LC,{severity:e.severity}),d.jsx("span",{style:{fontSize:11,color:"#94a3b8",transform:t?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.15s ease",flexShrink:0},children:"▼"})]}),t&&d.jsxs("div",{style:{padding:"0 14px 12px 42px",fontSize:12,lineHeight:1.6},children:[d.jsx("div",{style:{color:"#475569",marginBottom:4},children:e.detail}),e.recommendation&&d.jsxs("div",{style:{marginTop:6,padding:"8px 12px",background:"#f8fafc",borderRadius:4,border:"1px solid #e2e8f0",color:"#334155"},children:[d.jsx("span",{style:{fontWeight:600,color:"#475569",fontSize:11},children:"Recommendation: "}),e.recommendation]})]})]})}function AC({spec:e,apiBase:t}){const[n,r]=M.useState(null),[o,i]=M.useState(null),[s,l]=M.useState(!1),[a,u]=M.useState(null),[p,c]=M.useState(new Set),[f,x]=M.useState(!1),y=M.useCallback(async _=>{i(_),l(!0),u(null),c(new Set),x(!1);try{const S=_==="well-architected",b=await fetch(`${t}/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({spec:e,compliance:S?[]:[_],well_architected:S})});if(!b.ok)throw new Error(await Mr(b));const E=await b.json();r(E.results)}catch(S){u(S instanceof Error?S.message:"Validation failed"),r(null)}finally{l(!1)}},[e,t]),v=M.useCallback(_=>{c(S=>{const b=new Set(S);return b.has(_)?b.delete(_):b.add(_),b})},[]),k=(n==null?void 0:n[0])??null,m=k?k.checks.filter(_=>!_.passed).sort((_,S)=>(Ni[_.severity]??9)-(Ni[S.severity]??9)):[],g=k?k.checks.filter(_=>_.passed).sort((_,S)=>(Ni[_.severity]??9)-(Ni[S.severity]??9)):[],h={};for(const _ of m){const S=_.category;h[S]||(h[S]=[]),h[S].push(_)}const w=k?k.checks.reduce((_,S)=>(S.passed||(_[S.severity]=(_[S.severity]||0)+1),_),{}):{};return d.jsxs("div",{style:{padding:32,maxWidth:900},children:[d.jsx("h2",{style:{fontSize:18,marginBottom:16,color:"#0f172a",fontWeight:700},children:"Validate Architecture"}),d.jsx("div",{style:{display:"flex",gap:8,marginBottom:24},children:PC.map(_=>{const S=o===_.key;return d.jsx("button",{onClick:()=>y(_.key),disabled:s,style:{padding:"8px 18px",borderRadius:6,border:S?"1.5px solid #2563eb":"1px solid #e2e8f0",background:S?"#eff6ff":"#ffffff",color:S?"#1d4ed8":"#475569",cursor:s?"wait":"pointer",fontSize:13,fontWeight:S?600:500,transition:"all 0.15s ease",opacity:s&&!S?.6:1},children:_.label},_.key)})}),s&&d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:24,color:"#64748b",fontSize:14},children:[d.jsx("span",{style:{display:"inline-block",width:16,height:16,border:"2px solid #e2e8f0",borderTopColor:"#2563eb",borderRadius:"50%",animation:"spin 0.6s linear infinite"}}),"Running ",o==null?void 0:o.toUpperCase()," validation...",d.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"})]}),a&&d.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:8,color:"#991b1b",fontSize:13},children:a}),k&&!s&&d.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:24},children:[d.jsxs("div",{style:{display:"flex",gap:24,alignItems:"flex-start",padding:20,background:"#ffffff",border:"1px solid #e2e8f0",borderRadius:10},children:[d.jsx(RC,{score:k.score,passed:k.passed}),d.jsxs("div",{style:{flex:1},children:[d.jsx("div",{style:{fontSize:16,fontWeight:700,color:"#0f172a",marginBottom:4},children:k.framework}),d.jsxs("div",{style:{fontSize:13,color:"#64748b",marginBottom:14},children:[k.checks.length," checks evaluated ·"," ",g.length," passed ·"," ",m.length," failed"]}),d.jsx("div",{style:{display:"flex",gap:10,flexWrap:"wrap"},children:["critical","high","medium","low"].map(_=>{const S=w[_]||0,b=Do[_];return d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",borderRadius:6,background:S>0?b.bg:"#f8fafc",border:`1px solid ${S>0?b.border:"#e2e8f0"}`,minWidth:100},children:[d.jsx("span",{style:{fontSize:18,fontWeight:700,color:S>0?b.text:"#cbd5e1",lineHeight:1},children:S}),d.jsx("span",{style:{fontSize:11,fontWeight:600,color:S>0?b.text:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.03em"},children:_})]},_)})})]})]}),m.length>0&&d.jsxs("div",{children:[d.jsxs("h3",{style:{fontSize:14,fontWeight:600,color:"#0f172a",marginBottom:12,display:"flex",alignItems:"center",gap:8},children:[d.jsx("span",{style:{color:"#dc2626"},children:"✕"}),"Failed Checks (",m.length,")"]}),Object.entries(h).map(([_,S])=>d.jsxs("div",{style:{marginBottom:16},children:[d.jsx("div",{style:{fontSize:11,fontWeight:600,color:"#64748b",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:6,paddingLeft:4},children:IC[_]||_.replace(/_/g," ")}),S.map(b=>{const E=`${_}-${b.name}`;return d.jsx(Zf,{check:b,expanded:p.has(E),onToggle:()=>v(E)},E)})]},_))]}),g.length>0&&d.jsxs("div",{children:[d.jsxs("button",{onClick:()=>x(_=>!_),style:{display:"flex",alignItems:"center",gap:8,background:"none",border:"none",cursor:"pointer",padding:"4px 0",fontSize:14,fontWeight:600,color:"#0f172a"},children:[d.jsx("span",{style:{color:"#16a34a"},children:"✓"}),"Passed Checks (",g.length,")",d.jsx("span",{style:{fontSize:11,color:"#94a3b8",transform:f?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.15s ease"},children:"▼"})]}),f&&d.jsx("div",{style:{marginTop:8},children:g.map(_=>{const S=`passed-${_.category}-${_.name}`;return d.jsx(Zf,{check:_,expanded:p.has(S),onToggle:()=>v(S)},S)})})]}),d.jsxs("div",{style:{fontSize:11,color:"#94a3b8",borderTop:"1px solid #f1f5f9",paddingTop:12,lineHeight:1.5},children:["Score = percentage of checks passed. A framework is marked FAILED if any critical-severity check fails, regardless of overall score. Checks are defined in the Cloudwright Validator based on ",k.framework," control requirements."]})]}),!k&&!s&&!a&&d.jsx("div",{style:{padding:40,textAlign:"center",color:"#94a3b8",fontSize:14,background:"#f8fafc",borderRadius:8,border:"1px dashed #e2e8f0"},children:"Select a compliance framework above to validate your architecture."})]})}const $C=[{key:"hipaa",label:"HIPAA"},{key:"soc2",label:"SOC 2"},{key:"pci-dss",label:"PCI-DSS"},{key:"fedramp",label:"FedRAMP"},{key:"gdpr",label:"GDPR"},{key:"iso27001",label:"ISO 27001"},{key:"nist",label:"NIST 800-53"}],qf={critical:{bg:"#fef2f2",text:"#991b1b",border:"#fca5a5"},high:{bg:"#fff7ed",text:"#9a3412",border:"#fdba74"},medium:{bg:"#fffbeb",text:"#92400e",border:"#fcd34d"},low:{bg:"#f0fdf4",text:"#166534",border:"#86efac"}};function DC({spec:e,apiBase:t}){const[n,r]=M.useState(["hipaa","soc2","fedramp"]),[o,i]=M.useState(!1),[s,l]=M.useState(null),[a,u]=M.useState(!1),[p,c]=M.useState(null),f=v=>r(k=>k.includes(v)?k.filter(m=>m!==v):[...k,v]),x=M.useCallback(async()=>{u(!0),c(null);try{const v=await fetch(`${t}/compliance`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({spec:e,frameworks:n,oscal:o})});if(!v.ok)throw new Error(await Mr(v));l(await v.json())}catch(v){c(v instanceof Error?v.message:"Compliance scan failed")}finally{u(!1)}},[e,t,n,o]),y=M.useCallback(()=>{if(!(s!=null&&s.oscal))return;const v=new Blob([JSON.stringify(s.oscal,null,2)],{type:"application/json"}),k=URL.createObjectURL(v),m=document.createElement("a");m.href=k,m.download="compliance.oscal.json",m.click(),URL.revokeObjectURL(k)},[s]);return d.jsxs("div",{style:{padding:24,maxWidth:920},children:[d.jsx("h2",{style:{fontSize:18,marginBottom:6,color:"#0f172a"},children:"Compliance Control Mapping"}),d.jsx("p",{style:{fontSize:13,color:"#64748b",marginBottom:16},children:"Every design-stage finding mapped to the framework control it violates — before any infrastructure exists. Folds in a Checkov deep scan when available."}),d.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8,marginBottom:16},children:$C.map(v=>d.jsx("button",{onClick:()=>f(v.key),style:{padding:"6px 14px",borderRadius:999,border:`1px solid ${n.includes(v.key)?"#2563eb":"#cbd5e1"}`,background:n.includes(v.key)?"#2563eb":"#ffffff",color:n.includes(v.key)?"#ffffff":"#475569",fontSize:13,cursor:"pointer"},children:v.label},v.key))}),d.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,color:"#334155",marginBottom:16},children:[d.jsx("input",{type:"checkbox",checked:o,onChange:v=>i(v.target.checked)}),"Include OSCAL 1.1.2 component-definition export"]}),d.jsxs("div",{style:{display:"flex",gap:8},children:[d.jsx("button",{onClick:x,disabled:a||n.length===0,style:{padding:"10px 22px",borderRadius:8,border:"none",background:a?"#94a3b8":"#0f172a",color:"#ffffff",fontSize:14,fontWeight:600,cursor:a?"default":"pointer"},children:a?"Scanning…":"Run compliance scan"}),(s==null?void 0:s.oscal)&&d.jsx("button",{onClick:y,style:{padding:"10px 22px",borderRadius:8,border:"1px solid #2563eb",background:"#ffffff",color:"#2563eb",fontSize:14,fontWeight:600,cursor:"pointer"},children:"Download OSCAL JSON"})]}),p&&d.jsx("div",{style:{marginTop:16,padding:12,background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:8,color:"#991b1b",fontSize:13},children:p}),s&&d.jsxs("div",{style:{marginTop:24},children:[d.jsxs("div",{style:{fontSize:12,color:"#64748b",marginBottom:8},children:["Scanner: ",d.jsx("strong",{children:s.scanner}),s.checkov_used?" (Checkov deep scan included)":""]}),d.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",marginBottom:24},children:[d.jsx("thead",{children:d.jsxs("tr",{style:{background:"#f8fafc",textAlign:"left"},children:[d.jsx("th",{style:Yr,children:"Framework"}),d.jsx("th",{style:Yr,children:"Controls satisfied"}),d.jsx("th",{style:Yr,children:"Violated"}),d.jsx("th",{style:Yr,children:"Findings"}),d.jsx("th",{style:Yr,children:"Status"})]})}),d.jsx("tbody",{children:s.frameworks.map(v=>d.jsxs("tr",{style:{borderTop:"1px solid #e2e8f0"},children:[d.jsx("td",{style:Xr,children:d.jsx("strong",{children:v.framework})}),d.jsxs("td",{style:Xr,children:[v.controls_satisfied,"/",v.controls_total]}),d.jsx("td",{style:{...Xr,color:"#991b1b"},children:v.controls_violated.length?v.controls_violated.join(", "):"—"}),d.jsx("td",{style:Xr,children:v.findings}),d.jsx("td",{style:Xr,children:d.jsx("span",{style:{padding:"2px 10px",borderRadius:999,fontSize:12,fontWeight:600,background:v.status==="pass"?"#dcfce7":"#fee2e2",color:v.status==="pass"?"#166534":"#991b1b"},children:v.status.toUpperCase()})})]},v.framework))})]}),d.jsxs("h3",{style:{fontSize:15,color:"#0f172a",marginBottom:12},children:["Findings (",s.findings.length,")"]}),s.findings.map((v,k)=>{const m=qf[v.severity]||qf.low;return d.jsxs("div",{style:{border:`1px solid ${m.border}`,background:m.bg,borderRadius:8,padding:14,marginBottom:10},children:[d.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[d.jsxs("span",{style:{fontSize:11,fontWeight:700,color:m.text,textTransform:"uppercase"},children:["[",v.severity,"]"]}),d.jsx("span",{style:{fontSize:14,color:"#0f172a"},children:v.message}),d.jsxs("span",{style:{fontSize:11,color:"#64748b"},children:["(",v.source,")"]})]}),v.controls.length>0&&d.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6,marginTop:8},children:v.controls.map((g,h)=>d.jsxs("span",{title:g.title,style:{fontSize:11,padding:"2px 8px",borderRadius:4,background:"#e0e7ff",color:"#3730a3",fontFamily:"monospace"},children:[g.framework," ",g.control_id]},h))}),d.jsx("div",{style:{fontSize:12,color:"#475569",marginTop:8},children:v.remediation})]},k)})]})]})}const Yr={padding:"10px 12px",fontSize:12,color:"#475569",fontWeight:600},Xr={padding:"10px 12px",fontSize:13,color:"#0f172a"},OC=[{key:"terraform",label:"Terraform"},{key:"pulumi-python",label:"Pulumi (Python)"},{key:"pulumi-ts",label:"Pulumi (TS)"}];function BC({spec:e,apiBase:t}){const[n,r]=M.useState("terraform"),[o,i]=M.useState(null),[s,l]=M.useState(!1),[a,u]=M.useState(null),p=M.useCallback(async()=>{l(!0),u(null),i(null);try{const c=await fetch(`${t}/plan`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({spec:e,target:n,run_plan:!0})});if(!c.ok)throw new Error(await Mr(c));i(await c.json())}catch(c){u(c instanceof Error?c.message:"Plan failed")}finally{l(!1)}},[e,t,n]);return d.jsxs("div",{style:{padding:24,maxWidth:920},children:[d.jsx("h2",{style:{fontSize:18,marginBottom:6,color:"#0f172a"},children:"Plan / Preview — prove it deploys"}),d.jsxs("p",{style:{fontSize:13,color:"#64748b",marginBottom:16},children:["Runs ",d.jsx("code",{children:"terraform validate/plan"})," or ",d.jsx("code",{children:"pulumi preview"})," against the exported artifact. Read-only — nothing is applied. Validation needs no credentials and is the offline proof of deployability."]}),d.jsx("div",{style:{display:"flex",gap:8,marginBottom:16},children:OC.map(c=>d.jsx("button",{onClick:()=>r(c.key),style:{padding:"6px 14px",borderRadius:8,border:`1px solid ${n===c.key?"#2563eb":"#cbd5e1"}`,background:n===c.key?"#2563eb":"#ffffff",color:n===c.key?"#ffffff":"#475569",fontSize:13,cursor:"pointer"},children:c.label},c.key))}),d.jsx("button",{onClick:p,disabled:s,style:{padding:"10px 22px",borderRadius:8,border:"none",background:s?"#94a3b8":"#0f172a",color:"#ffffff",fontSize:14,fontWeight:600,cursor:s?"default":"pointer"},children:s?"Running plan…":"Run plan"}),a&&d.jsx("div",{style:{marginTop:16,padding:12,background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:8,color:"#991b1b",fontSize:13},children:a}),o&&d.jsxs("div",{style:{marginTop:24},children:[d.jsxs("div",{style:{display:"inline-block",padding:"8px 18px",borderRadius:8,fontSize:15,fontWeight:700,background:o.ok?"#dcfce7":"#fee2e2",color:o.ok?"#166534":"#991b1b",marginBottom:16},children:[o.ok?"DEPLOYABLE":"NOT DEPLOYABLE",o.ok&&!o.plan_ran?" (validate only — no credentials)":""]}),o.summary&&d.jsxs("div",{style:{fontSize:14,marginBottom:16},children:["Resource diff:"," ",d.jsxs("span",{style:{color:"#166534"},children:["+",o.summary.add]})," ",d.jsxs("span",{style:{color:"#92400e"},children:["~",o.summary.change]})," ",d.jsxs("span",{style:{color:"#991b1b"},children:["-",o.summary.destroy]})]}),d.jsx("ul",{style:{fontSize:13,color:"#334155",marginBottom:16,paddingLeft:18},children:o.messages.map((c,f)=>d.jsx("li",{style:{marginBottom:4},children:c},f))}),o.output_tail&&d.jsx("pre",{style:{background:"#0f172a",color:"#e2e8f0",padding:14,borderRadius:8,fontSize:12,overflowX:"auto",maxHeight:280},children:o.output_tail})]})]})}const Jf={critical:{bg:"#fef2f2",text:"#991b1b",border:"#fca5a5"},high:{bg:"#fff7ed",text:"#9a3412",border:"#fdba74"},medium:{bg:"#fffbeb",text:"#92400e",border:"#fcd34d"},low:{bg:"#f0fdf4",text:"#166534",border:"#86efac"}};function FC({spec:e,apiBase:t}){const[n,r]=M.useState(!1),[o,i]=M.useState(null),[s,l]=M.useState(!1),[a,u]=M.useState(null),p=M.useCallback(async()=>{l(!0),u(null);try{const c=await fetch(`${t}/review`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({spec:e,well_architected:n})});if(!c.ok)throw new Error(await Mr(c));i(await c.json())}catch(c){u(c instanceof Error?c.message:"Review failed")}finally{l(!1)}},[e,t,n]);return d.jsxs("div",{style:{padding:24,maxWidth:920},children:[d.jsx("h2",{style:{fontSize:18,marginBottom:6,color:"#0f172a"},children:"Architecture Review"}),d.jsx("p",{style:{fontSize:13,color:"#64748b",marginBottom:16},children:"Deterministic critique — scorer, linter, and validator merged into one severity-ranked report. Runs offline, no LLM call."}),d.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,color:"#334155",marginBottom:16},children:[d.jsx("input",{type:"checkbox",checked:n,onChange:c=>r(c.target.checked)}),"Include Well-Architected checks"]}),d.jsx("button",{onClick:p,disabled:s,style:{padding:"10px 22px",borderRadius:8,border:"none",background:s?"#94a3b8":"#0f172a",color:"#ffffff",fontSize:14,fontWeight:600,cursor:s?"default":"pointer"},children:s?"Reviewing…":"Run review"}),a&&d.jsx("div",{style:{marginTop:16,padding:12,background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:8,color:"#991b1b",fontSize:13},children:a}),o&&d.jsxs("div",{style:{marginTop:24},children:[d.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:12,padding:"8px 18px",borderRadius:8,fontSize:15,fontWeight:700,background:o.blocking_count===0?"#dcfce7":"#fee2e2",color:o.blocking_count===0?"#166534":"#991b1b",marginBottom:16},children:[o.score.toFixed(0),"/100 (grade ",o.grade,")",d.jsx("span",{style:{fontWeight:500,fontSize:12,marginLeft:8},children:o.blocking_count===0?"no blocking findings":`${o.blocking_count} blocking finding(s)`})]}),d.jsxs("h3",{style:{fontSize:15,color:"#0f172a",marginBottom:12},children:["Findings (",o.findings.length,")"]}),o.findings.length===0?d.jsx("div",{style:{fontSize:14,color:"#166534"},children:"No findings. This architecture passes every critic."}):o.findings.map((c,f)=>{const x=Jf[c.severity]||Jf.low;return d.jsxs("div",{style:{border:`1px solid ${x.border}`,background:x.bg,borderRadius:8,padding:14,marginBottom:10},children:[d.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[d.jsxs("span",{style:{fontSize:11,fontWeight:700,color:x.text,textTransform:"uppercase"},children:["[",c.severity,"]"]}),d.jsx("span",{style:{fontSize:14,color:"#0f172a"},children:c.message}),d.jsxs("span",{style:{fontSize:11,color:"#64748b"},children:["(",c.source,")"]})]}),c.recommendation&&d.jsx("div",{style:{fontSize:12,color:"#475569",marginTop:8},children:c.recommendation})]},f)})]})]})}const Ql=[{key:"terraform",label:"Terraform",ext:"tf",lang:"hcl",desc:"HashiCorp Configuration Language"},{key:"cloudformation",label:"CloudFormation",ext:"yaml",lang:"yaml",desc:"AWS CloudFormation template"},{key:"mermaid",label:"Mermaid",ext:"mmd",lang:"mermaid",desc:"Mermaid diagram markup"},{key:"d2",label:"D2",ext:"d2",lang:"d2",desc:"D2 diagram language"},{key:"sbom",label:"SBOM",ext:"json",lang:"json",desc:"CycloneDX Software BOM"},{key:"aibom",label:"AIBOM",ext:"json",lang:"json",desc:"OWASP AI Bill of Materials"},{key:"html",label:"HTML Report",ext:"html",lang:"html",desc:"Self-contained shareable report"}];function ep({format:e}){const t={terraform:"HCL",cloudformation:"CFN",mermaid:"MMD",d2:"D2",sbom:"BOM",aibom:"AI"},n={terraform:"#7c3aed",cloudformation:"#ea580c",mermaid:"#0891b2",d2:"#4f46e5",sbom:"#059669",aibom:"#2563eb"};return d.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:32,height:20,borderRadius:4,fontSize:10,fontWeight:700,background:`${n[e]||"#64748b"}14`,color:n[e]||"#64748b",letterSpacing:"0.02em",flexShrink:0},children:t[e]||e.slice(0,3).toUpperCase()})}function HC({spec:e,apiBase:t}){const[n,r]=M.useState(null),[o,i]=M.useState(""),[s,l]=M.useState(!1),[a,u]=M.useState(null),[p,c]=M.useState(!1),f=M.useRef(null),x=M.useCallback(async g=>{r(g),l(!0),u(null),c(!1);try{const h=await fetch(`${t}/export`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({spec:e,format:g})});if(!h.ok)throw new Error(await Mr(h));const w=await h.json();i(w.content||JSON.stringify(w,null,2))}catch(h){u(h instanceof Error?h.message:"Export failed"),i("")}finally{l(!1)}},[e,t]),y=M.useCallback(async()=>{var g,h;try{await navigator.clipboard.writeText(o),c(!0),setTimeout(()=>c(!1),2e3)}catch{const w=f.current;if(w){const _=document.createRange();_.selectNodeContents(w),(g=window.getSelection())==null||g.removeAllRanges(),(h=window.getSelection())==null||h.addRange(_)}}},[o]),v=M.useCallback(()=>{if(!o||!n)return;const g=Ql.find(S=>S.key===n),h=new Blob([o],{type:"text/plain"}),w=URL.createObjectURL(h),_=document.createElement("a");_.href=w,_.download=`architecture.${(g==null?void 0:g.ext)||"txt"}`,_.click(),URL.revokeObjectURL(w)},[o,n]),k=o?o.split(` -`).length:0,m=Ql.find(g=>g.key===n);return d.jsxs("div",{style:{padding:32,maxWidth:960},children:[d.jsx("h2",{style:{fontSize:18,marginBottom:16,color:"#0f172a",fontWeight:700},children:"Export Architecture"}),d.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:10,marginBottom:24},children:Ql.map(g=>{const h=n===g.key;return d.jsxs("button",{onClick:()=>x(g.key),disabled:s,style:{display:"flex",alignItems:"center",gap:10,padding:"10px 14px",borderRadius:8,border:h?"1.5px solid #2563eb":"1px solid #e2e8f0",background:h?"#eff6ff":"#ffffff",cursor:s?"wait":"pointer",textAlign:"left",transition:"all 0.15s ease",opacity:s&&!h?.6:1},children:[d.jsx(ep,{format:g.key}),d.jsxs("div",{children:[d.jsx("div",{style:{fontSize:13,fontWeight:h?600:500,color:h?"#1d4ed8":"#0f172a"},children:g.label}),d.jsx("div",{style:{fontSize:11,color:"#94a3b8"},children:g.desc})]})]},g.key)})}),s&&d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:24,color:"#64748b",fontSize:14},children:[d.jsx("span",{style:{display:"inline-block",width:16,height:16,border:"2px solid #e2e8f0",borderTopColor:"#2563eb",borderRadius:"50%",animation:"spin 0.6s linear infinite"}}),"Generating ",(m==null?void 0:m.label)||n,"...",d.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"})]}),a&&d.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:8,color:"#991b1b",fontSize:13},children:a}),o&&!s&&d.jsxs("div",{style:{border:"1px solid #e2e8f0",borderRadius:10,overflow:"hidden"},children:[d.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",background:"#f8fafc",borderBottom:"1px solid #e2e8f0"},children:[d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[d.jsx(ep,{format:n||""}),d.jsxs("span",{style:{fontSize:12,color:"#64748b"},children:["architecture.",(m==null?void 0:m.ext)||"txt"]}),d.jsxs("span",{style:{fontSize:11,color:"#cbd5e1"},children:[k," lines"]})]}),d.jsxs("div",{style:{display:"flex",gap:6},children:[d.jsx("button",{onClick:y,style:{padding:"4px 12px",borderRadius:4,border:"1px solid #e2e8f0",background:p?"#dcfce7":"#ffffff",color:p?"#166534":"#475569",cursor:"pointer",fontSize:12,fontWeight:500,transition:"all 0.15s ease"},children:p?"Copied":"Copy"}),d.jsx("button",{onClick:v,style:{padding:"4px 12px",borderRadius:4,border:"1px solid #e2e8f0",background:"#ffffff",color:"#475569",cursor:"pointer",fontSize:12,fontWeight:500},children:"Download"})]})]}),d.jsx("div",{style:{maxHeight:560,overflow:"auto"},children:d.jsx("pre",{ref:f,style:{margin:0,padding:16,fontSize:12,lineHeight:1.7,color:"#334155",background:"#ffffff",fontFamily:"'SF Mono', 'Cascadia Code', 'Fira Code', Menlo, monospace",counterReset:"line",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:o})})]}),!o&&!s&&!a&&d.jsx("div",{style:{padding:40,textAlign:"center",color:"#94a3b8",fontSize:14,background:"#f8fafc",borderRadius:8,border:"1px dashed #e2e8f0"},children:"Select an export format above to generate infrastructure code."})]})}const VC={0:"Edge / CDN",1:"Load Balancing",2:"Compute",3:"Data",4:"Supporting"};function Gl(e){if(e===null)return"null";if(typeof e=="number"||typeof e=="boolean")return String(e);const t=String(e);return/^[A-Za-z0-9_./:@-]+$/.test(t)?t:JSON.stringify(t)}function lu(e,t=0){const n=" ".repeat(t);if(Array.isArray(e))return e.length===0?"[]":e.map(r=>{if(r&&typeof r=="object"){const o=lu(r,t+2);return`${n}- ${o.trimStart()}`}return`${n}- ${Gl(r)}`}).join(` -`);if(e&&typeof e=="object"){const r=Object.entries(e).filter(([,o])=>o!==void 0);return r.length===0?"{}":r.map(([o,i])=>{if(i&&typeof i=="object"){const s=lu(i,t+2);return`${n}${o}: -${s}`}return`${n}${o}: ${Gl(i)}`}).join(` -`)}return Gl(e)}function Mi({label:e,value:t,sub:n}){return d.jsxs("div",{style:{padding:"14px 16px",background:"#ffffff",border:"1px solid #e2e8f0",borderRadius:8,flex:1,minWidth:120},children:[d.jsx("div",{style:{fontSize:22,fontWeight:700,color:"#0f172a",lineHeight:1.2},children:t}),d.jsx("div",{style:{fontSize:12,color:"#64748b",marginTop:2},children:e}),n&&d.jsx("div",{style:{fontSize:11,color:"#94a3b8",marginTop:2},children:n})]})}function WC({spec:e,yaml:t}){var x;const[n,r]=M.useState("overview"),[o,i]=M.useState(!1),s=M.useRef(null),l=M.useMemo(()=>lu(e)||t||"",[e,t]),a=M.useMemo(()=>{const y=new Set(e.components.map(v=>v.provider));return Array.from(y)},[e.components]),u=M.useMemo(()=>{const y=new Set(e.components.map(v=>v.service));return Array.from(y)},[e.components]),p=M.useMemo(()=>{const y={};for(const v of e.components){const k=v.tier??2;y[k]||(y[k]=[]),y[k].push(v)}return y},[e.components]),c=M.useCallback(async()=>{var y,v;try{await navigator.clipboard.writeText(l),i(!0),setTimeout(()=>i(!1),2e3)}catch{const k=s.current;if(k){const m=document.createRange();m.selectNodeContents(k),(y=window.getSelection())==null||y.removeAllRanges(),(v=window.getSelection())==null||v.addRange(m)}}},[l]),f=M.useCallback(()=>{var m;const y=new Blob([l],{type:"text/yaml"}),v=URL.createObjectURL(y),k=document.createElement("a");k.href=v,k.download=`${((m=e.name)==null?void 0:m.replace(/\s+/g,"-").toLowerCase())||"architecture"}.yaml`,k.click(),URL.revokeObjectURL(v)},[l,e.name]);return d.jsxs("div",{style:{padding:32,maxWidth:960},children:[d.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:12,marginBottom:20},children:[d.jsx("h2",{style:{fontSize:18,color:"#0f172a",fontWeight:700,margin:0},children:e.name||"Architecture Spec"}),e.provider&&d.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#475569",background:"#f1f5f9",padding:"2px 8px",borderRadius:4},children:e.provider.toUpperCase()}),e.region&&d.jsx("span",{style:{fontSize:12,color:"#94a3b8"},children:e.region})]}),d.jsx("div",{style:{display:"flex",gap:0,marginBottom:20,borderBottom:"1px solid #e2e8f0"},children:["overview","yaml"].map(y=>d.jsx("button",{onClick:()=>r(y),style:{padding:"8px 18px",background:"none",border:"none",borderBottom:n===y?"2px solid #2563eb":"2px solid transparent",color:n===y?"#1d4ed8":"#64748b",fontWeight:n===y?600:500,fontSize:13,cursor:"pointer",transition:"all 0.15s ease"},children:y==="overview"?"Overview":"YAML Source"},y))}),n==="overview"&&d.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:20},children:[d.jsxs("div",{style:{display:"flex",gap:12},children:[d.jsx(Mi,{label:"Components",value:e.components.length}),d.jsx(Mi,{label:"Connections",value:e.connections.length}),d.jsx(Mi,{label:"Services",value:u.length,sub:a.join(", ")}),e.cost_estimate&&d.jsx(Mi,{label:"Monthly Cost",value:`$${e.cost_estimate.monthly_total.toLocaleString()}`,sub:e.cost_estimate.currency})]}),d.jsx("div",{style:{border:"1px solid #e2e8f0",borderRadius:10,overflow:"hidden"},children:d.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[d.jsx("thead",{children:d.jsxs("tr",{style:{background:"#f8fafc"},children:[d.jsx("th",{style:xt,children:"Component"}),d.jsx("th",{style:xt,children:"Service"}),d.jsx("th",{style:xt,children:"Provider"}),d.jsx("th",{style:xt,children:"Tier"}),d.jsx("th",{style:xt,children:"Description"})]})}),d.jsx("tbody",{children:Object.keys(p).map(Number).sort().flatMap(y=>p[y].map(v=>d.jsxs("tr",{style:{borderBottom:"1px solid #f1f5f9"},children:[d.jsxs("td",{style:vt,children:[d.jsx("span",{style:{fontWeight:600,color:"#0f172a"},children:v.label}),d.jsx("div",{style:{fontSize:11,color:"#94a3b8"},children:v.id})]}),d.jsx("td",{style:vt,children:d.jsx("code",{style:{fontSize:12,background:"#f1f5f9",padding:"1px 6px",borderRadius:3,color:"#334155"},children:v.service})}),d.jsx("td",{style:vt,children:d.jsx("span",{style:{fontSize:12,color:"#475569"},children:v.provider})}),d.jsx("td",{style:vt,children:d.jsx("span",{style:{fontSize:11,fontWeight:600,color:"#64748b",background:"#f1f5f9",padding:"2px 8px",borderRadius:4},children:VC[y]||`Tier ${y}`})}),d.jsx("td",{style:{...vt,color:"#64748b",maxWidth:240},children:v.description})]},v.id)))})]})}),e.connections.length>0&&d.jsxs("div",{style:{border:"1px solid #e2e8f0",borderRadius:10,overflow:"hidden"},children:[d.jsxs("div",{style:{padding:"10px 16px",background:"#f8fafc",borderBottom:"1px solid #e2e8f0",fontSize:13,fontWeight:600,color:"#0f172a"},children:["Connections (",e.connections.length,")"]}),d.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[d.jsx("thead",{children:d.jsxs("tr",{style:{background:"#fafafa"},children:[d.jsx("th",{style:xt,children:"Source"}),d.jsx("th",{style:xt}),d.jsx("th",{style:xt,children:"Target"}),d.jsx("th",{style:xt,children:"Protocol"}),d.jsx("th",{style:xt,children:"Label"})]})}),d.jsx("tbody",{children:e.connections.map((y,v)=>{const k=e.components.find(g=>g.id===y.source),m=e.components.find(g=>g.id===y.target);return d.jsxs("tr",{style:{borderBottom:"1px solid #f1f5f9"},children:[d.jsx("td",{style:vt,children:d.jsx("span",{style:{fontWeight:500,color:"#0f172a"},children:(k==null?void 0:k.label)||y.source})}),d.jsx("td",{style:{...vt,textAlign:"center",color:"#94a3b8",fontSize:14},children:"→"}),d.jsx("td",{style:vt,children:d.jsx("span",{style:{fontWeight:500,color:"#0f172a"},children:(m==null?void 0:m.label)||y.target})}),d.jsx("td",{style:vt,children:y.protocol&&d.jsxs("code",{style:{fontSize:11,background:"#f1f5f9",padding:"1px 6px",borderRadius:3,color:"#334155"},children:[y.protocol,y.port?`:${y.port}`:""]})}),d.jsx("td",{style:{...vt,color:"#64748b"},children:y.label})]},v)})})]})]}),e.boundaries&&e.boundaries.length>0&&d.jsxs("div",{style:{border:"1px solid #e2e8f0",borderRadius:10,overflow:"hidden"},children:[d.jsxs("div",{style:{padding:"10px 16px",background:"#f8fafc",borderBottom:"1px solid #e2e8f0",fontSize:13,fontWeight:600,color:"#0f172a"},children:["Boundaries (",e.boundaries.length,")"]}),d.jsx("div",{style:{padding:16,display:"flex",flexWrap:"wrap",gap:10},children:e.boundaries.map(y=>d.jsxs("div",{style:{padding:"8px 14px",border:"1px dashed #cbd5e1",borderRadius:8,background:"#fafafa",fontSize:13},children:[d.jsx("div",{style:{fontWeight:600,color:"#0f172a"},children:y.label||y.id}),d.jsxs("div",{style:{fontSize:11,color:"#94a3b8"},children:[y.kind," · ",y.component_ids.length," components"]})]},y.id))})]})]}),n==="yaml"&&d.jsxs("div",{style:{border:"1px solid #e2e8f0",borderRadius:10,overflow:"hidden"},children:[d.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",background:"#f8fafc",borderBottom:"1px solid #e2e8f0"},children:[d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[d.jsx("span",{style:{fontSize:10,fontWeight:700,color:"#7c3aed",background:"#7c3aed14",padding:"2px 8px",borderRadius:4},children:"YAML"}),d.jsxs("span",{style:{fontSize:12,color:"#64748b"},children:[((x=e.name)==null?void 0:x.replace(/\s+/g,"-").toLowerCase())||"architecture",".yaml"]}),d.jsxs("span",{style:{fontSize:11,color:"#cbd5e1"},children:[l.split(` -`).length," lines"]})]}),d.jsxs("div",{style:{display:"flex",gap:6},children:[d.jsx("button",{onClick:c,style:{padding:"4px 12px",borderRadius:4,border:"1px solid #e2e8f0",background:o?"#dcfce7":"#ffffff",color:o?"#166534":"#475569",cursor:"pointer",fontSize:12,fontWeight:500,transition:"all 0.15s ease"},children:o?"Copied":"Copy"}),d.jsx("button",{onClick:f,style:{padding:"4px 12px",borderRadius:4,border:"1px solid #e2e8f0",background:"#ffffff",color:"#475569",cursor:"pointer",fontSize:12,fontWeight:500},children:"Download"})]})]}),d.jsx("div",{style:{maxHeight:600,overflow:"auto"},children:d.jsx("pre",{ref:s,style:{margin:0,padding:16,fontSize:13,lineHeight:1.7,color:"#334155",background:"#ffffff",fontFamily:"'SF Mono', 'Cascadia Code', 'Fira Code', Menlo, monospace",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:l||"No YAML available"})})]})]})}const xt={padding:"10px 14px",textAlign:"left",fontSize:11,fontWeight:600,color:"#64748b",textTransform:"uppercase",letterSpacing:"0.05em"},vt={padding:"10px 14px",color:"#0f172a"},Ve="/api",UC=["Add caching layer","Reduce cost","Increase redundancy","Add monitoring","Add security"];function tp(e){var s;if((s=e.metadata)!=null&&s.suggestions&&e.metadata.suggestions.length>0)return e.metadata.suggestions.slice(0,3);const t=e.components.map(l=>l.label.toLowerCase()),n=e.components.map(l=>l.service.toLowerCase()),r=t.some(l=>l.includes("cache")||l.includes("redis")||l.includes("elasticache"))||n.some(l=>l.includes("cache")||l.includes("redis")),o=t.some(l=>l.includes("monitor")||l.includes("cloudwatch")||l.includes("grafana"))||n.some(l=>l.includes("cloudwatch")||l.includes("monitor")),i=t.some(l=>l.includes("waf")||l.includes("firewall")||l.includes("security"))||n.some(l=>l.includes("waf")||l.includes("shield"));return UC.filter(l=>!(l==="Add caching layer"&&r||l==="Add monitoring"&&o||l==="Add security"&&i)).slice(0,3)}function YC(e){return e.split(/(\*\*.*?\*\*)/g).map((t,n)=>t.startsWith("**")&&t.endsWith("**")?d.jsx("strong",{children:t.slice(2,-2)},n):d.jsx("span",{children:t},n))}async function Kl(e,t){var i;let n=e;const[r,o]=await Promise.all([fetch(`${Ve}/cost`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({spec:n})}).then(s=>s.ok?s.json():null).catch(()=>null),fetch(`${Ve}/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({spec:n,compliance:[],well_architected:!0})}).then(s=>s.ok?s.json():null).catch(()=>null)]);if(r!=null&&r.estimate&&(n={...n,cost_estimate:r.estimate}),((i=o==null?void 0:o.results)==null?void 0:i.length)>0){const s=o.results[0].checks||[],l=s.filter(a=>a.passed).length;t({passed:l,total:s.length})}return n}async function np(e,t,n){var a;const r=e?`${Ve}/modify/stream`:`${Ve}/design/stream`,o=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!o.ok){n.onError(await Mr(o));return}const i=(a=o.body)==null?void 0:a.getReader();if(!i)return;const s=new TextDecoder;let l="";for(;;){const{done:u,value:p}=await i.read();if(u)break;l+=s.decode(p,{stream:!0});const c=l.split(` -`);l=c.pop()||"";for(const f of c)if(f.startsWith("data: "))try{const x=JSON.parse(f.slice(6));switch(x.stage){case"generating":case"costing":case"validating":n.onStage(x.stage,x.message);break;case"generated":n.onSpec(x.spec,x.yaml),x.usage&&n.onUsage&&n.onUsage(x.usage);break;case"costed":n.onCost(x.cost_estimate);break;case"validated":n.onValidation(x.passed,x.total);break;case"done":n.onDone(x.spec,x.yaml),x.usage&&n.onUsage&&n.onUsage(x.usage);break;case"error":n.onError(x.message);break}}catch{}}}function XC(){var _;const[e,t]=M.useState([]),[n,r]=M.useState(""),[o,i]=M.useState("idle"),[s,l]=M.useState(null),[a,u]=M.useState("diagram"),[p,c]=M.useState(""),[f,x]=M.useState(null),[y,v]=M.useState(null),k=M.useRef(null),m=M.useRef(null);M.useEffect(()=>{var S;(S=m.current)==null||S.scrollIntoView({behavior:"smooth"})},[e]);const g=async()=>{var P;if(!n.trim()||o!=="idle")return;const S={role:"user",content:n};t(I=>[...I,S]),r("");const b=s!==null;i(b?"modifying":"generating");let E=null,A="",D=!1;try{const I=b?{spec:s,instruction:n}:{description:n};try{await np(b,I,{onStage:z=>{z==="generating"?i("generating"):(z==="costing"||z==="validating")&&i("costing")},onSpec:z=>{l(z),E=z,i("costing")},onCost:z=>{z&&E&&(E={...E,cost_estimate:z},l(E))},onValidation:(z,R)=>{z!==null&&x({passed:z,total:R})},onDone:(z,R)=>{E=z,A=R,l(z),i("done")},onUsage:z=>v(z),onError:z=>{throw new Error(z)}}),D=E!==null}catch{i(b?"modifying":"generating")}if(!D){const z=b?await fetch(`${Ve}/modify`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({spec:s,instruction:n})}):await fetch(`${Ve}/design`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:n})}),R=await z.json();if(!z.ok)throw new Error(su(R));E=R.spec,A=R.yaml,R.usage&&v(R.usage),i("costing"),E=await Kl(E,x),l(E),i("done")}const T=E,L={role:"assistant",content:`${b?"Modified":"Designed"} **${T.name}** with ${T.components.length} components on ${T.provider.toUpperCase()}.${T.cost_estimate?` Estimated cost: $${T.cost_estimate.monthly_total.toFixed(2)}/mo.`:""}`,spec:T,yaml:A,suggestions:tp(T)};t(z=>[...z,L]),u("diagram")}catch(I){const T=I instanceof Error?I.message:"Unknown error";t(C=>[...C,{role:"assistant",content:`Error: ${T}`}])}finally{i("idle"),(P=k.current)==null||P.focus()}},h=async S=>{if(s)try{const b=await fetch(`${Ve}/download`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({spec:s,format:S})});if(!b.ok)return;const E=await b.blob(),D=(b.headers.get("Content-Disposition")||"").match(/filename=([^\s;]+)/),P=D?D[1]:`architecture.${S==="terraform"?"tf":"yaml"}`,I=URL.createObjectURL(E),T=document.createElement("a");T.href=I,T.download=P,T.click(),URL.revokeObjectURL(I)}catch{}},w=async S=>{l(S),x(null);try{const b=await Kl(S,x);l(b)}catch{}};return d.jsxs("div",{style:{display:"flex",height:"100vh",background:"#ffffff"},children:[d.jsxs("div",{style:{width:420,borderRight:"1px solid #e2e8f0",display:"flex",flexDirection:"column",background:"#f8fafc"},children:[d.jsxs("div",{style:{padding:"16px 20px",borderBottom:"1px solid #e2e8f0",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[d.jsxs("div",{children:[d.jsx("h1",{style:{fontSize:20,fontWeight:700,color:"#0f172a"},children:"Cloudwright"}),d.jsx("p",{style:{fontSize:12,color:"#64748b",marginTop:4},children:"Architecture Intelligence"})]}),s&&d.jsx("button",{onClick:()=>{if(window.confirm("Discard current session and start fresh?")){try{localStorage.setItem("cloudwright_last_session",JSON.stringify(e))}catch{}l(null),t([]),x(null)}},style:{padding:"5px 12px",borderRadius:6,border:"1px solid #e2e8f0",background:"#ffffff",color:"#64748b",cursor:"pointer",fontSize:12,fontWeight:500},children:"New"})]}),d.jsxs("div",{style:{flex:1,overflowY:"auto",padding:16},children:[e.length===0&&d.jsxs("div",{style:{color:"#64748b",padding:20,textAlign:"center"},children:[d.jsx("p",{style:{fontSize:14},children:"Describe your cloud architecture"}),d.jsx("p",{style:{fontSize:12,marginTop:8,color:"#94a3b8"},children:'"3-tier web app on AWS with CloudFront, ALB, EC2, and RDS"'})]}),e.map((S,b)=>d.jsxs("div",{style:{marginBottom:12},children:[d.jsx("div",{style:{padding:"10px 14px",borderRadius:8,background:S.role==="user"?"#2563eb":"#f1f5f9",color:S.role==="user"?"#ffffff":"#1e293b",fontSize:14,lineHeight:1.5},children:YC(S.content)}),S.role==="assistant"&&S.spec&&S.suggestions&&S.suggestions.length>0&&d.jsx("div",{style:{display:"flex",gap:6,marginTop:6,flexWrap:"wrap"},children:S.suggestions.map(E=>d.jsx("button",{onClick:()=>{var A;r(E),(A=k.current)==null||A.focus()},disabled:o!=="idle",style:{padding:"4px 10px",borderRadius:12,border:"1px solid #cbd5e1",background:"#ffffff",color:"#2563eb",cursor:o!=="idle"?"not-allowed":"pointer",fontSize:12,fontWeight:500},children:E},E))})]},b)),o!=="idle"&&d.jsxs("div",{style:{padding:"10px 14px",color:"#64748b",fontSize:14},children:[o==="generating"&&"Generating architecture...",o==="modifying"&&"Modifying architecture...",o==="costing"&&"Estimating cost & validating...",o==="done"&&"Finalizing..."]}),d.jsx("div",{ref:m})]}),d.jsx("div",{style:{padding:16,borderTop:"1px solid #e2e8f0"},children:d.jsxs("div",{style:{display:"flex",gap:8},children:[d.jsx("input",{ref:k,value:n,onChange:S=>r(S.target.value),onKeyDown:S=>S.key==="Enter"&&g(),placeholder:"Describe your architecture...",style:{flex:1,padding:"10px 14px",borderRadius:8,border:"1px solid #e2e8f0",background:"#ffffff",color:"#0f172a",fontSize:14,outline:"none"}}),d.jsx("button",{onClick:g,disabled:o!=="idle"||!n.trim(),style:{padding:"10px 20px",borderRadius:8,border:"none",background:o!=="idle"?"#e2e8f0":"#2563eb",color:o!=="idle"?"#94a3b8":"#fff",cursor:o!=="idle"?"not-allowed":"pointer",fontSize:14,fontWeight:600},children:"Send"})]})})]}),d.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",background:"#ffffff"},children:[d.jsx("div",{style:{display:"flex",borderBottom:"1px solid #e2e8f0",background:"#ffffff"},children:["diagram","cost","validate","compliance","plan","review","export","spec","modify"].map(S=>d.jsx("button",{onClick:()=>u(S),style:{padding:"12px 24px",border:"none",borderBottom:a===S?"2px solid #2563eb":"2px solid transparent",background:"transparent",color:a===S?"#2563eb":"#64748b",cursor:"pointer",fontSize:14,fontWeight:500,textTransform:"capitalize"},children:S},S))}),d.jsxs("div",{style:{flex:1,overflow:"auto",display:"flex",flexDirection:"column"},children:[d.jsx("div",{style:{padding:"0.5rem 1rem"},children:d.jsx(TC,{spec:s,onDownloadTerraform:s?()=>h("terraform"):void 0,onDownloadYaml:s?()=>h("yaml"):void 0,validationSummary:f,usage:y})}),d.jsxs("div",{style:{flex:1,overflow:"auto"},children:[a==="diagram"&&(s||o!=="idle")&&d.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[s&&d.jsx(MC,{spec:s,onSpecChange:w}),o!=="idle"&&d.jsxs("div",{style:{position:"absolute",top:16,right:16,background:"rgba(37, 99, 235, 0.9)",color:"white",padding:"8px 16px",borderRadius:8,fontSize:13,fontWeight:500,display:"flex",alignItems:"center",gap:8},children:[d.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:"white",animation:"pulse 1s infinite"}}),o==="generating"?"Generating...":o==="modifying"?"Modifying...":o==="costing"?"Costing & validating...":"Finalizing..."]})]}),a==="diagram"&&!s&&o==="idle"&&d.jsx("div",{style:{padding:32,color:"#64748b"},children:"Design an architecture to see the diagram."}),a==="cost"&&(s==null?void 0:s.cost_estimate)&&d.jsx(zC,{estimate:s.cost_estimate}),a==="cost"&&(!s||!s.cost_estimate)&&d.jsx("div",{style:{padding:32,color:"#64748b"},children:"No cost estimate available."}),a==="spec"&&s&&d.jsx(WC,{spec:s,yaml:((_=e.findLast(S=>S.yaml))==null?void 0:_.yaml)||"No YAML available"}),a==="spec"&&!s&&d.jsx("div",{style:{padding:32,color:"#64748b"},children:"Design an architecture first."}),a==="validate"&&s&&d.jsx(AC,{spec:s,apiBase:Ve}),a==="validate"&&!s&&d.jsx("div",{style:{padding:32,color:"#64748b"},children:"Design an architecture first."}),a==="compliance"&&s&&d.jsx(DC,{spec:s,apiBase:Ve}),a==="compliance"&&!s&&d.jsx("div",{style:{padding:32,color:"#64748b"},children:"Design an architecture first."}),a==="plan"&&s&&d.jsx(BC,{spec:s,apiBase:Ve}),a==="plan"&&!s&&d.jsx("div",{style:{padding:32,color:"#64748b"},children:"Design an architecture first."}),a==="review"&&s&&d.jsx(FC,{spec:s,apiBase:Ve}),a==="review"&&!s&&d.jsx("div",{style:{padding:32,color:"#64748b"},children:"Design an architecture first."}),a==="export"&&s&&d.jsx(HC,{spec:s,apiBase:Ve}),a==="export"&&!s&&d.jsx("div",{style:{padding:32,color:"#64748b"},children:"Design an architecture first."}),a==="modify"&&s&&d.jsxs("div",{style:{padding:32,maxWidth:800},children:[d.jsx("h2",{style:{fontSize:18,marginBottom:16,color:"#0f172a"},children:"Modify Architecture"}),o!=="idle"&&d.jsxs("div",{style:{marginBottom:12,fontSize:13,color:"#64748b"},children:[o==="modifying"&&"Modifying architecture...",o==="costing"&&"Estimating cost & validating...",o==="done"&&"Finalizing..."]}),d.jsx("div",{style:{display:"flex",gap:8},children:d.jsx("input",{value:p,onChange:S=>c(S.target.value),onKeyDown:async S=>{if(S.key==="Enter"&&p.trim()&&o==="idle"){const b=p;c(""),i("modifying");let E=null,A="",D=!1;try{try{await np(!0,{spec:s,instruction:b},{onStage:I=>{I==="generating"?i("modifying"):(I==="costing"||I==="validating")&&i("costing")},onSpec:I=>{l(I),E=I,i("costing")},onCost:I=>{I&&E&&(E={...E,cost_estimate:I},l(E))},onValidation:(I,T)=>{I!==null&&x({passed:I,total:T})},onDone:(I,T)=>{E=I,A=T,l(I),i("done")},onUsage:I=>v(I),onError:I=>{throw new Error(I)}}),D=E!==null}catch{i("modifying")}if(!D){const I=await fetch(`${Ve}/modify`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({spec:s,instruction:b})}),T=await I.json();if(!I.ok)throw new Error(su(T,"Modification failed"));T.usage&&v(T.usage);const C=T.spec;A=T.yaml,i("costing"),E=await Kl(C,x),l(E),i("done")}const P=E;t(I=>[...I,{role:"user",content:b},{role:"assistant",content:`Modified **${P.name}** with ${P.components.length} components on ${P.provider.toUpperCase()}.${P.cost_estimate?` Estimated cost: $${P.cost_estimate.monthly_total.toFixed(2)}/mo.`:""}`,spec:P,yaml:A,suggestions:tp(P)}])}catch(P){t(I=>[...I,{role:"user",content:b},{role:"assistant",content:`Error: ${P instanceof Error?P.message:"Modification failed"}`}])}finally{i("idle")}}},placeholder:"e.g. Add a Redis cache between web and database",style:{flex:1,padding:"10px 14px",borderRadius:8,border:"1px solid #e2e8f0",background:"#ffffff",color:"#0f172a",fontSize:14,outline:"none"}})}),d.jsx("p",{style:{fontSize:12,color:"#64748b",marginTop:8},children:"Press Enter to apply modification"})]}),a==="modify"&&!s&&d.jsx("div",{style:{padding:32,color:"#64748b"},children:"Design an architecture first."})]})]})]})]})}Zl.createRoot(document.getElementById("root")).render(d.jsx(hp.StrictMode,{children:d.jsx(XC,{})})); diff --git a/packages/web/cloudwright_web/static/assets/index-BZV40eAE.css b/packages/web/cloudwright_web/static/assets/index-BZV40eAE.css deleted file mode 100644 index 093f5cd..0000000 --- a/packages/web/cloudwright_web/static/assets/index-BZV40eAE.css +++ /dev/null @@ -1 +0,0 @@ -.react-flow{direction:ltr;--xy-edge-stroke-default: #b1b1b7;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #555;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(255, 255, 255, .5);--xy-minimap-background-color-default: #fff;--xy-minimap-mask-background-color-default: rgba(240, 240, 240, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #e2e2e2;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: transparent;--xy-background-pattern-dots-color-default: #91919a;--xy-background-pattern-lines-color-default: #eee;--xy-background-pattern-cross-color-default: #e2e2e2;background-color:var(--xy-background-color, var(--xy-background-color-default));--xy-node-color-default: inherit;--xy-node-border-default: 1px solid #1a192b;--xy-node-background-color-default: #fff;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(0, 0, 0, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #1a192b;--xy-node-border-radius-default: 3px;--xy-handle-background-color-default: #1a192b;--xy-handle-border-color-default: #fff;--xy-selection-background-color-default: rgba(0, 89, 220, .08);--xy-selection-border-default: 1px dotted rgba(0, 89, 220, .8);--xy-controls-button-background-color-default: #fefefe;--xy-controls-button-background-color-hover-default: #f4f4f4;--xy-controls-button-color-default: inherit;--xy-controls-button-color-hover-default: inherit;--xy-controls-button-border-color-default: #eee;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #ffffff;--xy-edge-label-color-default: inherit;--xy-resize-background-color-default: #3367d9}.react-flow.dark{--xy-edge-stroke-default: #3e3e3e;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #727272;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(150, 150, 150, .25);--xy-minimap-background-color-default: #141414;--xy-minimap-mask-background-color-default: rgba(60, 60, 60, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #2b2b2b;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: #141414;--xy-background-pattern-dots-color-default: #777;--xy-background-pattern-lines-color-default: #777;--xy-background-pattern-cross-color-default: #777;--xy-node-color-default: #f8f8f8;--xy-node-border-default: 1px solid #3c3c3c;--xy-node-background-color-default: #1e1e1e;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(255, 255, 255, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #999;--xy-handle-background-color-default: #bebebe;--xy-handle-border-color-default: #1e1e1e;--xy-selection-background-color-default: rgba(200, 200, 220, .08);--xy-selection-border-default: 1px dotted rgba(200, 200, 220, .8);--xy-controls-button-background-color-default: #2b2b2b;--xy-controls-button-background-color-hover-default: #3e3e3e;--xy-controls-button-color-default: #f8f8f8;--xy-controls-button-color-hover-default: #fff;--xy-controls-button-border-color-default: #5b5b5b;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #141414;--xy-edge-label-color-default: #f8f8f8}.react-flow__background{background-color:var(--xy-background-color-props, var(--xy-background-color, var(--xy-background-color-default)));pointer-events:none;z-index:-1}.react-flow__container{position:absolute;width:100%;height:100%;top:0;left:0}.react-flow__pane{z-index:1}.react-flow__pane.draggable{cursor:grab}.react-flow__pane.dragging{cursor:grabbing}.react-flow__pane.selection{cursor:pointer}.react-flow__viewport{transform-origin:0 0;z-index:2;pointer-events:none}.react-flow__renderer{z-index:4}.react-flow__selection{z-index:6}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible{outline:none}.react-flow__edge-path{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default));stroke-width:var(--xy-edge-stroke-width, var(--xy-edge-stroke-width-default));fill:none}.react-flow__connection-path{stroke:var(--xy-connectionline-stroke, var(--xy-connectionline-stroke-default));stroke-width:var(--xy-connectionline-stroke-width, var(--xy-connectionline-stroke-width-default));fill:none}.react-flow .react-flow__edges{position:absolute}.react-flow .react-flow__edges svg{overflow:visible;position:absolute;pointer-events:none}.react-flow__edge{pointer-events:visibleStroke}.react-flow__edge.selectable{cursor:pointer}.react-flow__edge.animated path{stroke-dasharray:5;animation:dashdraw .5s linear infinite}.react-flow__edge.animated path.react-flow__edge-interaction{stroke-dasharray:none;animation:none}.react-flow__edge.inactive{pointer-events:none}.react-flow__edge.selected,.react-flow__edge:focus,.react-flow__edge:focus-visible{outline:none}.react-flow__edge.selected .react-flow__edge-path,.react-flow__edge.selectable:focus .react-flow__edge-path,.react-flow__edge.selectable:focus-visible .react-flow__edge-path{stroke:var(--xy-edge-stroke-selected, var(--xy-edge-stroke-selected-default))}.react-flow__edge-textwrapper{pointer-events:all}.react-flow__edge .react-flow__edge-text{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__arrowhead polyline{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__arrowhead polyline.arrowclosed{fill:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__connection{pointer-events:none}.react-flow__connection .animated{stroke-dasharray:5;animation:dashdraw .5s linear infinite}svg.react-flow__connectionline{z-index:1001;overflow:visible;position:absolute}.react-flow__nodes{pointer-events:none;transform-origin:0 0}.react-flow__node{position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:all;transform-origin:0 0;box-sizing:border-box;cursor:default}.react-flow__node.selectable{cursor:pointer}.react-flow__node.draggable{cursor:grab;pointer-events:all}.react-flow__node.draggable.dragging{cursor:grabbing}.react-flow__nodesselection{z-index:3;transform-origin:left top;pointer-events:none}.react-flow__nodesselection-rect{position:absolute;pointer-events:all;cursor:grab}.react-flow__handle{position:absolute;pointer-events:none;min-width:5px;min-height:5px;width:6px;height:6px;background-color:var(--xy-handle-background-color, var(--xy-handle-background-color-default));border:1px solid var(--xy-handle-border-color, var(--xy-handle-border-color-default));border-radius:100%}.react-flow__handle.connectingfrom{pointer-events:all}.react-flow__handle.connectionindicator{pointer-events:all;cursor:crosshair}.react-flow__handle-bottom{top:auto;left:50%;bottom:0;transform:translate(-50%,50%)}.react-flow__handle-top{top:0;left:50%;transform:translate(-50%,-50%)}.react-flow__handle-left{top:50%;left:0;transform:translate(-50%,-50%)}.react-flow__handle-right{top:50%;right:0;transform:translate(50%,-50%)}.react-flow__edgeupdater{cursor:move;pointer-events:all}.react-flow__pane.selection .react-flow__panel{pointer-events:none}.react-flow__panel{position:absolute;z-index:5;margin:15px}.react-flow__panel.top{top:0}.react-flow__panel.bottom{bottom:0}.react-flow__panel.top.center,.react-flow__panel.bottom.center{left:50%;transform:translate(-15px) translate(-50%)}.react-flow__panel.left{left:0}.react-flow__panel.right{right:0}.react-flow__panel.left.center,.react-flow__panel.right.center{top:50%;transform:translateY(-15px) translateY(-50%)}.react-flow__attribution{font-size:10px;background:var(--xy-attribution-background-color, var(--xy-attribution-background-color-default));padding:2px 3px;margin:0}.react-flow__attribution a{text-decoration:none;color:#999}@keyframes dashdraw{0%{stroke-dashoffset:10}}.react-flow__edgelabel-renderer{position:absolute;width:100%;height:100%;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;left:0;top:0}.react-flow__viewport-portal{position:absolute;width:100%;height:100%;left:0;top:0;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__minimap{background:var( --xy-minimap-background-color-props, var(--xy-minimap-background-color, var(--xy-minimap-background-color-default)) )}.react-flow__minimap-svg{display:block}.react-flow__minimap-mask{fill:var( --xy-minimap-mask-background-color-props, var(--xy-minimap-mask-background-color, var(--xy-minimap-mask-background-color-default)) );stroke:var( --xy-minimap-mask-stroke-color-props, var(--xy-minimap-mask-stroke-color, var(--xy-minimap-mask-stroke-color-default)) );stroke-width:var( --xy-minimap-mask-stroke-width-props, var(--xy-minimap-mask-stroke-width, var(--xy-minimap-mask-stroke-width-default)) )}.react-flow__minimap-node{fill:var( --xy-minimap-node-background-color-props, var(--xy-minimap-node-background-color, var(--xy-minimap-node-background-color-default)) );stroke:var( --xy-minimap-node-stroke-color-props, var(--xy-minimap-node-stroke-color, var(--xy-minimap-node-stroke-color-default)) );stroke-width:var( --xy-minimap-node-stroke-width-props, var(--xy-minimap-node-stroke-width, var(--xy-minimap-node-stroke-width-default)) )}.react-flow__background-pattern.dots{fill:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-dots-color-default)) )}.react-flow__background-pattern.lines{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-lines-color-default)) )}.react-flow__background-pattern.cross{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-cross-color-default)) )}.react-flow__controls{display:flex;flex-direction:column;box-shadow:var(--xy-controls-box-shadow, var(--xy-controls-box-shadow-default))}.react-flow__controls.horizontal{flex-direction:row}.react-flow__controls-button{display:flex;justify-content:center;align-items:center;height:26px;width:26px;padding:4px;border:none;background:var(--xy-controls-button-background-color, var(--xy-controls-button-background-color-default));border-bottom:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) );color:var( --xy-controls-button-color-props, var(--xy-controls-button-color, var(--xy-controls-button-color-default)) );cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__controls-button svg{width:100%;max-width:12px;max-height:12px;fill:currentColor}.react-flow__edge.updating .react-flow__edge-path{stroke:#777}.react-flow__edge-text{font-size:10px}.react-flow__node.selectable:focus,.react-flow__node.selectable:focus-visible{outline:none}.react-flow__node-input,.react-flow__node-default,.react-flow__node-output,.react-flow__node-group{padding:10px;border-radius:var(--xy-node-border-radius, var(--xy-node-border-radius-default));width:150px;font-size:12px;color:var(--xy-node-color, var(--xy-node-color-default));text-align:center;border:var(--xy-node-border, var(--xy-node-border-default));background-color:var(--xy-node-background-color, var(--xy-node-background-color-default))}.react-flow__node-input.selectable:hover,.react-flow__node-default.selectable:hover,.react-flow__node-output.selectable:hover,.react-flow__node-group.selectable:hover{box-shadow:var(--xy-node-boxshadow-hover, var(--xy-node-boxshadow-hover-default))}.react-flow__node-input.selectable.selected,.react-flow__node-input.selectable:focus,.react-flow__node-input.selectable:focus-visible,.react-flow__node-default.selectable.selected,.react-flow__node-default.selectable:focus,.react-flow__node-default.selectable:focus-visible,.react-flow__node-output.selectable.selected,.react-flow__node-output.selectable:focus,.react-flow__node-output.selectable:focus-visible,.react-flow__node-group.selectable.selected,.react-flow__node-group.selectable:focus,.react-flow__node-group.selectable:focus-visible{box-shadow:var(--xy-node-boxshadow-selected, var(--xy-node-boxshadow-selected-default))}.react-flow__node-group{background-color:var(--xy-node-group-background-color, var(--xy-node-group-background-color-default))}.react-flow__nodesselection-rect,.react-flow__selection{background:var(--xy-selection-background-color, var(--xy-selection-background-color-default));border:var(--xy-selection-border, var(--xy-selection-border-default))}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible,.react-flow__selection:focus,.react-flow__selection:focus-visible{outline:none}.react-flow__controls-button:hover{background:var( --xy-controls-button-background-color-hover-props, var(--xy-controls-button-background-color-hover, var(--xy-controls-button-background-color-hover-default)) );color:var( --xy-controls-button-color-hover-props, var(--xy-controls-button-color-hover, var(--xy-controls-button-color-hover-default)) )}.react-flow__controls-button:disabled{pointer-events:none}.react-flow__controls-button:disabled svg{fill-opacity:.4}.react-flow__controls-button:last-child{border-bottom:none}.react-flow__controls.horizontal .react-flow__controls-button{border-bottom:none;border-right:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) )}.react-flow__controls.horizontal .react-flow__controls-button:last-child{border-right:none}.react-flow__resize-control{position:absolute}.react-flow__resize-control.left,.react-flow__resize-control.right{cursor:ew-resize}.react-flow__resize-control.top,.react-flow__resize-control.bottom{cursor:ns-resize}.react-flow__resize-control.top.left,.react-flow__resize-control.bottom.right{cursor:nwse-resize}.react-flow__resize-control.bottom.left,.react-flow__resize-control.top.right{cursor:nesw-resize}.react-flow__resize-control.handle{width:5px;height:5px;border:1px solid #fff;border-radius:1px;background-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));translate:-50% -50%}.react-flow__resize-control.handle.left{left:0;top:50%}.react-flow__resize-control.handle.right{left:100%;top:50%}.react-flow__resize-control.handle.top{left:50%;top:0}.react-flow__resize-control.handle.bottom{left:50%;top:100%}.react-flow__resize-control.handle.top.left,.react-flow__resize-control.handle.bottom.left{left:0}.react-flow__resize-control.handle.top.right,.react-flow__resize-control.handle.bottom.right{left:100%}.react-flow__resize-control.line{border-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));border-width:0;border-style:solid}.react-flow__resize-control.line.left,.react-flow__resize-control.line.right{width:1px;transform:translate(-50%);top:0;height:100%}.react-flow__resize-control.line.left{left:0;border-left-width:1px}.react-flow__resize-control.line.right{left:100%;border-right-width:1px}.react-flow__resize-control.line.top,.react-flow__resize-control.line.bottom{height:1px;transform:translateY(-50%);left:0;width:100%}.react-flow__resize-control.line.top{top:0;border-top-width:1px}.react-flow__resize-control.line.bottom{border-bottom-width:1px;top:100%}.react-flow__edge-textbg{fill:var(--xy-edge-label-background-color, var(--xy-edge-label-background-color-default))}.react-flow__edge-text{fill:var(--xy-edge-label-color, var(--xy-edge-label-color-default))} diff --git a/packages/web/cloudwright_web/static/assets/index-BdV-mM67.css b/packages/web/cloudwright_web/static/assets/index-BdV-mM67.css new file mode 100644 index 0000000..f20df16 --- /dev/null +++ b/packages/web/cloudwright_web/static/assets/index-BdV-mM67.css @@ -0,0 +1 @@ +.react-flow{direction:ltr;--xy-edge-stroke-default: #b1b1b7;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #555;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(255, 255, 255, .5);--xy-minimap-background-color-default: #fff;--xy-minimap-mask-background-color-default: rgba(240, 240, 240, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #e2e2e2;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: transparent;--xy-background-pattern-dots-color-default: #91919a;--xy-background-pattern-lines-color-default: #eee;--xy-background-pattern-cross-color-default: #e2e2e2;background-color:var(--xy-background-color, var(--xy-background-color-default));--xy-node-color-default: inherit;--xy-node-border-default: 1px solid #1a192b;--xy-node-background-color-default: #fff;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(0, 0, 0, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #1a192b;--xy-node-border-radius-default: 3px;--xy-handle-background-color-default: #1a192b;--xy-handle-border-color-default: #fff;--xy-selection-background-color-default: rgba(0, 89, 220, .08);--xy-selection-border-default: 1px dotted rgba(0, 89, 220, .8);--xy-controls-button-background-color-default: #fefefe;--xy-controls-button-background-color-hover-default: #f4f4f4;--xy-controls-button-color-default: inherit;--xy-controls-button-color-hover-default: inherit;--xy-controls-button-border-color-default: #eee;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #ffffff;--xy-edge-label-color-default: inherit;--xy-resize-background-color-default: #3367d9}.react-flow.dark{--xy-edge-stroke-default: #3e3e3e;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #727272;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(150, 150, 150, .25);--xy-minimap-background-color-default: #141414;--xy-minimap-mask-background-color-default: rgba(60, 60, 60, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #2b2b2b;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: #141414;--xy-background-pattern-dots-color-default: #777;--xy-background-pattern-lines-color-default: #777;--xy-background-pattern-cross-color-default: #777;--xy-node-color-default: #f8f8f8;--xy-node-border-default: 1px solid #3c3c3c;--xy-node-background-color-default: #1e1e1e;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(255, 255, 255, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #999;--xy-handle-background-color-default: #bebebe;--xy-handle-border-color-default: #1e1e1e;--xy-selection-background-color-default: rgba(200, 200, 220, .08);--xy-selection-border-default: 1px dotted rgba(200, 200, 220, .8);--xy-controls-button-background-color-default: #2b2b2b;--xy-controls-button-background-color-hover-default: #3e3e3e;--xy-controls-button-color-default: #f8f8f8;--xy-controls-button-color-hover-default: #fff;--xy-controls-button-border-color-default: #5b5b5b;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #141414;--xy-edge-label-color-default: #f8f8f8}.react-flow__background{background-color:var(--xy-background-color-props, var(--xy-background-color, var(--xy-background-color-default)));pointer-events:none;z-index:-1}.react-flow__container{position:absolute;width:100%;height:100%;top:0;left:0}.react-flow__pane{z-index:1}.react-flow__pane.draggable{cursor:grab}.react-flow__pane.dragging{cursor:grabbing}.react-flow__pane.selection{cursor:pointer}.react-flow__viewport{transform-origin:0 0;z-index:2;pointer-events:none}.react-flow__renderer{z-index:4}.react-flow__selection{z-index:6}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible{outline:none}.react-flow__edge-path{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default));stroke-width:var(--xy-edge-stroke-width, var(--xy-edge-stroke-width-default));fill:none}.react-flow__connection-path{stroke:var(--xy-connectionline-stroke, var(--xy-connectionline-stroke-default));stroke-width:var(--xy-connectionline-stroke-width, var(--xy-connectionline-stroke-width-default));fill:none}.react-flow .react-flow__edges{position:absolute}.react-flow .react-flow__edges svg{overflow:visible;position:absolute;pointer-events:none}.react-flow__edge{pointer-events:visibleStroke}.react-flow__edge.selectable{cursor:pointer}.react-flow__edge.animated path{stroke-dasharray:5;animation:dashdraw .5s linear infinite}.react-flow__edge.animated path.react-flow__edge-interaction{stroke-dasharray:none;animation:none}.react-flow__edge.inactive{pointer-events:none}.react-flow__edge.selected,.react-flow__edge:focus,.react-flow__edge:focus-visible{outline:none}.react-flow__edge.selected .react-flow__edge-path,.react-flow__edge.selectable:focus .react-flow__edge-path,.react-flow__edge.selectable:focus-visible .react-flow__edge-path{stroke:var(--xy-edge-stroke-selected, var(--xy-edge-stroke-selected-default))}.react-flow__edge-textwrapper{pointer-events:all}.react-flow__edge .react-flow__edge-text{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__arrowhead polyline{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__arrowhead polyline.arrowclosed{fill:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__connection{pointer-events:none}.react-flow__connection .animated{stroke-dasharray:5;animation:dashdraw .5s linear infinite}svg.react-flow__connectionline{z-index:1001;overflow:visible;position:absolute}.react-flow__nodes{pointer-events:none;transform-origin:0 0}.react-flow__node{position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:all;transform-origin:0 0;box-sizing:border-box;cursor:default}.react-flow__node.selectable{cursor:pointer}.react-flow__node.draggable{cursor:grab;pointer-events:all}.react-flow__node.draggable.dragging{cursor:grabbing}.react-flow__nodesselection{z-index:3;transform-origin:left top;pointer-events:none}.react-flow__nodesselection-rect{position:absolute;pointer-events:all;cursor:grab}.react-flow__handle{position:absolute;pointer-events:none;min-width:5px;min-height:5px;width:6px;height:6px;background-color:var(--xy-handle-background-color, var(--xy-handle-background-color-default));border:1px solid var(--xy-handle-border-color, var(--xy-handle-border-color-default));border-radius:100%}.react-flow__handle.connectingfrom{pointer-events:all}.react-flow__handle.connectionindicator{pointer-events:all;cursor:crosshair}.react-flow__handle-bottom{top:auto;left:50%;bottom:0;transform:translate(-50%,50%)}.react-flow__handle-top{top:0;left:50%;transform:translate(-50%,-50%)}.react-flow__handle-left{top:50%;left:0;transform:translate(-50%,-50%)}.react-flow__handle-right{top:50%;right:0;transform:translate(50%,-50%)}.react-flow__edgeupdater{cursor:move;pointer-events:all}.react-flow__pane.selection .react-flow__panel{pointer-events:none}.react-flow__panel{position:absolute;z-index:5;margin:15px}.react-flow__panel.top{top:0}.react-flow__panel.bottom{bottom:0}.react-flow__panel.top.center,.react-flow__panel.bottom.center{left:50%;transform:translate(-15px) translate(-50%)}.react-flow__panel.left{left:0}.react-flow__panel.right{right:0}.react-flow__panel.left.center,.react-flow__panel.right.center{top:50%;transform:translateY(-15px) translateY(-50%)}.react-flow__attribution{font-size:10px;background:var(--xy-attribution-background-color, var(--xy-attribution-background-color-default));padding:2px 3px;margin:0}.react-flow__attribution a{text-decoration:none;color:#999}@keyframes dashdraw{0%{stroke-dashoffset:10}}.react-flow__edgelabel-renderer{position:absolute;width:100%;height:100%;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;left:0;top:0}.react-flow__viewport-portal{position:absolute;width:100%;height:100%;left:0;top:0;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__minimap{background:var( --xy-minimap-background-color-props, var(--xy-minimap-background-color, var(--xy-minimap-background-color-default)) )}.react-flow__minimap-svg{display:block}.react-flow__minimap-mask{fill:var( --xy-minimap-mask-background-color-props, var(--xy-minimap-mask-background-color, var(--xy-minimap-mask-background-color-default)) );stroke:var( --xy-minimap-mask-stroke-color-props, var(--xy-minimap-mask-stroke-color, var(--xy-minimap-mask-stroke-color-default)) );stroke-width:var( --xy-minimap-mask-stroke-width-props, var(--xy-minimap-mask-stroke-width, var(--xy-minimap-mask-stroke-width-default)) )}.react-flow__minimap-node{fill:var( --xy-minimap-node-background-color-props, var(--xy-minimap-node-background-color, var(--xy-minimap-node-background-color-default)) );stroke:var( --xy-minimap-node-stroke-color-props, var(--xy-minimap-node-stroke-color, var(--xy-minimap-node-stroke-color-default)) );stroke-width:var( --xy-minimap-node-stroke-width-props, var(--xy-minimap-node-stroke-width, var(--xy-minimap-node-stroke-width-default)) )}.react-flow__background-pattern.dots{fill:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-dots-color-default)) )}.react-flow__background-pattern.lines{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-lines-color-default)) )}.react-flow__background-pattern.cross{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-cross-color-default)) )}.react-flow__controls{display:flex;flex-direction:column;box-shadow:var(--xy-controls-box-shadow, var(--xy-controls-box-shadow-default))}.react-flow__controls.horizontal{flex-direction:row}.react-flow__controls-button{display:flex;justify-content:center;align-items:center;height:26px;width:26px;padding:4px;border:none;background:var(--xy-controls-button-background-color, var(--xy-controls-button-background-color-default));border-bottom:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) );color:var( --xy-controls-button-color-props, var(--xy-controls-button-color, var(--xy-controls-button-color-default)) );cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__controls-button svg{width:100%;max-width:12px;max-height:12px;fill:currentColor}.react-flow__edge.updating .react-flow__edge-path{stroke:#777}.react-flow__edge-text{font-size:10px}.react-flow__node.selectable:focus,.react-flow__node.selectable:focus-visible{outline:none}.react-flow__node-input,.react-flow__node-default,.react-flow__node-output,.react-flow__node-group{padding:10px;border-radius:var(--xy-node-border-radius, var(--xy-node-border-radius-default));width:150px;font-size:12px;color:var(--xy-node-color, var(--xy-node-color-default));text-align:center;border:var(--xy-node-border, var(--xy-node-border-default));background-color:var(--xy-node-background-color, var(--xy-node-background-color-default))}.react-flow__node-input.selectable:hover,.react-flow__node-default.selectable:hover,.react-flow__node-output.selectable:hover,.react-flow__node-group.selectable:hover{box-shadow:var(--xy-node-boxshadow-hover, var(--xy-node-boxshadow-hover-default))}.react-flow__node-input.selectable.selected,.react-flow__node-input.selectable:focus,.react-flow__node-input.selectable:focus-visible,.react-flow__node-default.selectable.selected,.react-flow__node-default.selectable:focus,.react-flow__node-default.selectable:focus-visible,.react-flow__node-output.selectable.selected,.react-flow__node-output.selectable:focus,.react-flow__node-output.selectable:focus-visible,.react-flow__node-group.selectable.selected,.react-flow__node-group.selectable:focus,.react-flow__node-group.selectable:focus-visible{box-shadow:var(--xy-node-boxshadow-selected, var(--xy-node-boxshadow-selected-default))}.react-flow__node-group{background-color:var(--xy-node-group-background-color, var(--xy-node-group-background-color-default))}.react-flow__nodesselection-rect,.react-flow__selection{background:var(--xy-selection-background-color, var(--xy-selection-background-color-default));border:var(--xy-selection-border, var(--xy-selection-border-default))}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible,.react-flow__selection:focus,.react-flow__selection:focus-visible{outline:none}.react-flow__controls-button:hover{background:var( --xy-controls-button-background-color-hover-props, var(--xy-controls-button-background-color-hover, var(--xy-controls-button-background-color-hover-default)) );color:var( --xy-controls-button-color-hover-props, var(--xy-controls-button-color-hover, var(--xy-controls-button-color-hover-default)) )}.react-flow__controls-button:disabled{pointer-events:none}.react-flow__controls-button:disabled svg{fill-opacity:.4}.react-flow__controls-button:last-child{border-bottom:none}.react-flow__controls.horizontal .react-flow__controls-button{border-bottom:none;border-right:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) )}.react-flow__controls.horizontal .react-flow__controls-button:last-child{border-right:none}.react-flow__resize-control{position:absolute}.react-flow__resize-control.left,.react-flow__resize-control.right{cursor:ew-resize}.react-flow__resize-control.top,.react-flow__resize-control.bottom{cursor:ns-resize}.react-flow__resize-control.top.left,.react-flow__resize-control.bottom.right{cursor:nwse-resize}.react-flow__resize-control.bottom.left,.react-flow__resize-control.top.right{cursor:nesw-resize}.react-flow__resize-control.handle{width:5px;height:5px;border:1px solid #fff;border-radius:1px;background-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));translate:-50% -50%}.react-flow__resize-control.handle.left{left:0;top:50%}.react-flow__resize-control.handle.right{left:100%;top:50%}.react-flow__resize-control.handle.top{left:50%;top:0}.react-flow__resize-control.handle.bottom{left:50%;top:100%}.react-flow__resize-control.handle.top.left,.react-flow__resize-control.handle.bottom.left{left:0}.react-flow__resize-control.handle.top.right,.react-flow__resize-control.handle.bottom.right{left:100%}.react-flow__resize-control.line{border-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));border-width:0;border-style:solid}.react-flow__resize-control.line.left,.react-flow__resize-control.line.right{width:1px;transform:translate(-50%);top:0;height:100%}.react-flow__resize-control.line.left{left:0;border-left-width:1px}.react-flow__resize-control.line.right{left:100%;border-right-width:1px}.react-flow__resize-control.line.top,.react-flow__resize-control.line.bottom{height:1px;transform:translateY(-50%);left:0;width:100%}.react-flow__resize-control.line.top{top:0;border-top-width:1px}.react-flow__resize-control.line.bottom{border-bottom-width:1px;top:100%}.react-flow__edge-textbg{fill:var(--xy-edge-label-background-color, var(--xy-edge-label-background-color-default))}.react-flow__edge-text{fill:var(--xy-edge-label-color, var(--xy-edge-label-color-default))}:root{color-scheme:light;--font-sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;--font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;--text-2xs: 10px;--text-xs: 11px;--text-sm: 12px;--text-base: 13px;--text-md: 14px;--text-lg: 16px;--text-xl: 19px;--text-2xl: 23px;--text-3xl: 28px;--space-1: 4px;--space-2: 8px;--space-3: 12px;--space-4: 16px;--space-5: 20px;--space-6: 24px;--space-8: 32px;--space-10: 40px;--radius-sm: 4px;--radius: 8px;--radius-lg: 12px;--radius-xl: 16px;--radius-pill: 999px;--shadow-sm: 0 1px 2px rgb(15 23 42 / .06);--shadow: 0 1px 3px rgb(15 23 42 / .08), 0 1px 2px rgb(15 23 42 / .04);--shadow-lg: 0 10px 24px rgb(15 23 42 / .1), 0 2px 6px rgb(15 23 42 / .06);--sidebar-width: 400px;--header-height: 56px;--ease: cubic-bezier(.2, 0, 0, 1);--duration: .16s;--bg: #ffffff;--bg-subtle: #f8fafc;--bg-inset: #f1f5f9;--surface: #ffffff;--canvas: #f8fafc;--canvas-dot: #dbe3ec;--border: #e2e8f0;--border-strong: #cbd5e1;--text: #0f172a;--text-muted: #475569;--text-subtle: #5a6b83;--accent: #2563eb;--accent-hover: #1d4ed8;--accent-active: #1e40af;--accent-text: #1d4ed8;--accent-soft: #eff6ff;--accent-contrast: #ffffff;--success: #16a34a;--success-text: #14612f;--success-soft: #dcfce7;--success-border: #86efac;--warn: #d97706;--warn-text: #92400e;--warn-soft: #fffbeb;--warn-border: #fcd34d;--danger: #dc2626;--danger-text: #991b1b;--danger-soft: #fef2f2;--danger-border: #fca5a5;--high-text: #9a3412;--high-soft: #fff7ed;--high-border: #fdba74;--focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent)}[data-theme=dark]{color-scheme:dark;--bg: #0a0f1a;--bg-subtle: #0e1524;--bg-inset: #131c2c;--surface: #111a2b;--canvas: #0c1220;--canvas-dot: #1e293b;--border: #1e293b;--border-strong: #334155;--text: #e8eefb;--text-muted: #b3c0d4;--text-subtle: #8f9fb6;--accent: #3b82f6;--accent-hover: #60a5fa;--accent-active: #93c5fd;--accent-text: #93c5fd;--accent-soft: #14243f;--accent-contrast: #ffffff;--success: #22c55e;--success-text: #86efac;--success-soft: #10281a;--success-border: #166534;--warn: #f59e0b;--warn-text: #fcd34d;--warn-soft: #2a1f08;--warn-border: #92400e;--danger: #ef4444;--danger-text: #fca5a5;--danger-soft: #2a1113;--danger-border: #991b1b;--high-text: #fdba74;--high-soft: #2a1a0c;--high-border: #9a3412;--shadow-sm: 0 1px 2px rgb(0 0 0 / .4);--shadow: 0 1px 3px rgb(0 0 0 / .5), 0 1px 2px rgb(0 0 0 / .3);--shadow-lg: 0 12px 28px rgb(0 0 0 / .55), 0 2px 8px rgb(0 0 0 / .4)}*,*:before,*:after{box-sizing:border-box;margin:0;padding:0}html,body,#root{height:100%}body{font-family:var(--font-sans);font-size:var(--text-md);line-height:1.5;background:var(--bg);color:var(--text);-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}h1,h2,h3,h4{font-weight:650;letter-spacing:-.011em;line-height:1.25;color:var(--text)}button,input,textarea,select{font:inherit;color:inherit}:focus-visible{outline:2px solid var(--accent);outline-offset:2px;border-radius:var(--radius-sm)}:focus:not(:focus-visible){outline:none}::selection{background:var(--accent);color:var(--accent-contrast)}*{scrollbar-width:thin;scrollbar-color:var(--border-strong) transparent}*::-webkit-scrollbar{width:10px;height:10px}*::-webkit-scrollbar-thumb{background:var(--border-strong);border-radius:var(--radius-pill);border:3px solid transparent;background-clip:content-box}*::-webkit-scrollbar-track{background:transparent}@keyframes cw-spin{to{transform:rotate(360deg)}}@keyframes cw-pulse{0%,to{opacity:1;transform:scale(1)}50%{opacity:.35;transform:scale(.75)}}@keyframes cw-rise{0%{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}@keyframes cw-shimmer{to{background-position:200% 0}}@media (prefers-reduced-motion: reduce){*,*:before,*:after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important;scroll-behavior:auto!important}}.app{display:grid;grid-template-columns:var(--sidebar-width) minmax(0,1fr);height:100dvh;background:var(--bg);overflow:hidden}.skip-link{position:absolute;left:var(--space-2);top:-60px;z-index:100;padding:var(--space-2) var(--space-4);background:var(--accent);color:var(--accent-contrast);border-radius:var(--radius);font-weight:600;transition:top var(--duration) var(--ease)}.skip-link:focus{top:var(--space-2)}.sidebar{display:flex;flex-direction:column;min-height:0;background:var(--bg-subtle);border-right:1px solid var(--border)}.sidebar__header{display:flex;align-items:center;gap:var(--space-3);padding:var(--space-3) var(--space-4);min-height:var(--header-height);border-bottom:1px solid var(--border);background:var(--bg-subtle)}.brand{display:flex;align-items:center;gap:var(--space-2);min-width:0;flex:1}.brand__mark{flex-shrink:0;color:var(--accent)}.brand__name{font-size:var(--text-lg);font-weight:700;letter-spacing:-.02em}.brand__tagline{font-size:var(--text-xs);color:var(--text-subtle);margin-top:1px}.workspace{display:flex;flex-direction:column;min-width:0;min-height:0;background:var(--bg)}.workspace__header{display:flex;align-items:center;gap:var(--space-3);padding-right:var(--space-3);border-bottom:1px solid var(--border);min-height:var(--header-height)}.panel-host{flex:1;min-height:0;position:relative}.panel{height:100%;overflow:auto}.panel[hidden]{display:none}.panel__body{padding:var(--space-6) var(--space-8);max-width:1000px}.panel__body--wide{max-width:1200px}.panel__title{font-size:var(--text-xl);margin-bottom:var(--space-1)}.panel__lede{font-size:var(--text-base);color:var(--text-muted);margin-bottom:var(--space-5);max-width:68ch}.btn{display:inline-flex;align-items:center;justify-content:center;gap:var(--space-2);padding:8px 14px;border-radius:var(--radius);border:1px solid var(--border-strong);background:var(--surface);color:var(--text);font-size:var(--text-base);font-weight:550;cursor:pointer;white-space:nowrap;transition:background var(--duration) var(--ease),border-color var(--duration) var(--ease),color var(--duration) var(--ease),transform var(--duration) var(--ease)}.btn:hover:not(:disabled){background:var(--bg-inset);border-color:var(--text-subtle)}.btn:active:not(:disabled){transform:translateY(1px)}.btn:disabled{opacity:.55;cursor:not-allowed}.btn--primary{background:var(--accent);border-color:var(--accent);color:var(--accent-contrast)}.btn--primary:hover:not(:disabled){background:var(--accent-hover);border-color:var(--accent-hover)}.btn--primary:disabled{opacity:1;background:var(--bg-inset);border-color:var(--border);color:var(--text-subtle)}.btn--ghost{border-color:transparent;background:transparent;color:var(--text-muted)}.btn--ghost:hover:not(:disabled){background:var(--bg-inset);border-color:transparent;color:var(--text)}.btn--danger{border-color:var(--danger-border);background:var(--danger-soft);color:var(--danger-text)}.btn--danger:hover:not(:disabled){background:var(--danger-soft);border-color:var(--danger)}.btn--sm{padding:5px 10px;font-size:var(--text-sm);border-radius:var(--radius-sm)}.btn--icon{padding:6px;width:32px;height:32px;border-radius:var(--radius)}.btn--block{width:100%}.chip{display:inline-flex;align-items:center;gap:6px;padding:5px 12px;border-radius:var(--radius-pill);border:1px solid var(--border-strong);background:var(--surface);color:var(--text-muted);font-size:var(--text-base);font-weight:550;cursor:pointer;transition:background var(--duration) var(--ease),border-color var(--duration) var(--ease),color var(--duration) var(--ease)}.chip:hover:not(:disabled){border-color:var(--accent);color:var(--accent-text)}.chip:disabled{opacity:.55;cursor:not-allowed}.chip[aria-pressed=true],.chip--on{background:var(--accent);border-color:var(--accent);color:var(--accent-contrast)}.field{width:100%;padding:8px 12px;border-radius:var(--radius);border:1px solid var(--border-strong);background:var(--surface);color:var(--text);font-size:var(--text-base);transition:border-color var(--duration) var(--ease),box-shadow var(--duration) var(--ease)}.field::placeholder{color:var(--text-subtle)}.field:hover{border-color:var(--text-subtle)}.field:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 22%,transparent)}.field--mono{font-family:var(--font-mono);font-size:var(--text-sm);resize:vertical}.field-label{display:block;font-size:var(--text-sm);font-weight:600;color:var(--text-muted);margin-bottom:5px}.checkbox{display:inline-flex;align-items:center;gap:var(--space-2);font-size:var(--text-base);color:var(--text-muted);cursor:pointer}.checkbox input{width:16px;height:16px;accent-color:var(--accent);cursor:pointer}.section-label{font-size:var(--text-xs);font-weight:650;color:var(--text-subtle);text-transform:uppercase;letter-spacing:.06em}.tabs{display:flex;align-items:stretch;gap:2px;overflow-x:auto;scrollbar-width:none;padding:0 var(--space-2);flex:1;min-width:0}.tabs::-webkit-scrollbar{display:none}.tab{position:relative;padding:0 var(--space-4);min-height:var(--header-height);border:none;background:transparent;color:var(--text-muted);font-size:var(--text-base);font-weight:550;cursor:pointer;white-space:nowrap;text-transform:capitalize;transition:color var(--duration) var(--ease)}.tab:after{content:"";position:absolute;left:var(--space-3);right:var(--space-3);bottom:0;height:2px;border-radius:2px 2px 0 0;background:transparent;transition:background var(--duration) var(--ease)}.tab:hover{color:var(--text)}.tab[aria-selected=true]{color:var(--accent-text)}.tab[aria-selected=true]:after{background:var(--accent)}.tab:disabled{opacity:.45;cursor:not-allowed}.tab:disabled:hover{color:var(--text-muted)}.chat{flex:1;min-height:0;overflow-y:auto;padding:var(--space-4);display:flex;flex-direction:column;gap:var(--space-3)}.msg{max-width:92%;padding:10px 14px;border-radius:var(--radius-lg);font-size:var(--text-md);line-height:1.55;animation:cw-rise var(--duration) var(--ease);overflow-wrap:anywhere}.msg--user{align-self:flex-end;background:var(--accent);color:var(--accent-contrast);border-bottom-right-radius:var(--radius-sm)}.msg--assistant{align-self:flex-start;background:var(--bg-inset);color:var(--text);border-bottom-left-radius:var(--radius-sm)}.msg--error{align-self:flex-start;background:var(--danger-soft);border:1px solid var(--danger-border);color:var(--danger-text);border-bottom-left-radius:var(--radius-sm)}.msg-group{display:flex;flex-direction:column;gap:var(--space-2)}.suggestions{display:flex;flex-wrap:wrap;gap:6px}.suggestions .chip{font-size:var(--text-sm);padding:4px 10px}.composer{padding:var(--space-3) var(--space-4) var(--space-4);border-top:1px solid var(--border);background:var(--bg-subtle)}.composer__box{display:flex;align-items:flex-end;gap:var(--space-2);padding:var(--space-2);border-radius:var(--radius-lg);border:1px solid var(--border-strong);background:var(--surface);transition:border-color var(--duration) var(--ease),box-shadow var(--duration) var(--ease)}.composer__box:focus-within{border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 22%,transparent)}.composer__input{flex:1;border:none;background:transparent;resize:none;max-height:168px;min-height:24px;padding:4px 6px;font-size:var(--text-md);line-height:1.5}.composer__input:focus{outline:none}.composer__hint{margin-top:6px;font-size:var(--text-xs);color:var(--text-subtle);display:flex;justify-content:space-between;gap:var(--space-2)}kbd{font-family:var(--font-mono);font-size:var(--text-2xs);padding:1px 5px;border:1px solid var(--border-strong);border-bottom-width:2px;border-radius:var(--radius-sm);background:var(--bg-inset);color:var(--text-muted)}.spinner{display:inline-block;width:15px;height:15px;flex-shrink:0;border:2px solid var(--border);border-top-color:var(--accent);border-radius:50%;animation:cw-spin .65s linear infinite}.dot-pulse{width:8px;height:8px;border-radius:50%;background:currentColor;animation:cw-pulse 1.2s var(--ease) infinite;flex-shrink:0}.status-row{display:flex;align-items:center;gap:var(--space-2);color:var(--text-muted);font-size:var(--text-base);padding:var(--space-2) var(--space-1)}.canvas-status{position:absolute;top:var(--space-4);left:50%;transform:translate(-50%);z-index:12;display:flex;align-items:center;gap:var(--space-2);padding:7px 14px;border-radius:var(--radius-pill);background:var(--accent);color:var(--accent-contrast);font-size:var(--text-base);font-weight:550;box-shadow:var(--shadow-lg)}.skeleton{border-radius:var(--radius);background:linear-gradient(90deg,var(--bg-inset) 0%,var(--border) 50%,var(--bg-inset) 100%);background-size:200% 100%;animation:cw-shimmer 1.4s linear infinite}.empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--space-3);text-align:center;padding:var(--space-10) var(--space-6);color:var(--text-muted);min-height:260px}.empty__icon{color:var(--text-subtle);opacity:.8}.empty__title{font-size:var(--text-lg);font-weight:600;color:var(--text)}.empty__hint{font-size:var(--text-base);color:var(--text-subtle);max-width:42ch}.callout{padding:var(--space-3) var(--space-4);border-radius:var(--radius);border:1px solid var(--border);background:var(--bg-subtle);font-size:var(--text-base);color:var(--text-muted)}.callout--danger{background:var(--danger-soft);border-color:var(--danger-border);color:var(--danger-text)}.callout--success{background:var(--success-soft);border-color:var(--success-border);color:var(--success-text)}.badge{display:inline-flex;align-items:center;gap:5px;padding:2px 8px;border-radius:var(--radius-sm);font-size:var(--text-xs);font-weight:650;letter-spacing:.03em;text-transform:uppercase;border:1px solid transparent}.badge--critical,.badge--danger{background:var(--danger-soft);color:var(--danger-text);border-color:var(--danger-border)}.badge--high{background:var(--high-soft);color:var(--high-text);border-color:var(--high-border)}.badge--medium,.badge--warn{background:var(--warn-soft);color:var(--warn-text);border-color:var(--warn-border)}.badge--low,.badge--success{background:var(--success-soft);color:var(--success-text);border-color:var(--success-border)}.badge--neutral{background:var(--bg-inset);color:var(--text-muted);border-color:var(--border)}.summary{display:flex;align-items:center;gap:var(--space-4);flex-wrap:wrap;padding:var(--space-2) var(--space-4);border-bottom:1px solid var(--border);background:var(--bg-subtle);font-size:var(--text-base)}.summary__stat{color:var(--text-subtle);white-space:nowrap}.summary__stat strong{color:var(--text);font-weight:650;font-variant-numeric:tabular-nums}.summary__stat--accent strong{color:var(--accent-text)}.summary__actions{margin-left:auto;display:flex;gap:var(--space-2)}.card{border:1px solid var(--border);border-radius:var(--radius-lg);background:var(--surface);overflow:hidden}.card__header{display:flex;align-items:center;justify-content:space-between;gap:var(--space-3);padding:var(--space-2) var(--space-4);background:var(--bg-subtle);border-bottom:1px solid var(--border);font-size:var(--text-base);font-weight:600}.card__body{padding:var(--space-4)}.stat-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:var(--space-3)}.stat{padding:var(--space-3) var(--space-4);border:1px solid var(--border);border-radius:var(--radius);background:var(--surface)}.stat__value{font-size:var(--text-2xl);font-weight:700;line-height:1.15;font-variant-numeric:tabular-nums;letter-spacing:-.02em}.stat__label{font-size:var(--text-sm);color:var(--text-muted);margin-top:2px}.stat__sub{font-size:var(--text-xs);color:var(--text-subtle);margin-top:2px}.table-wrap{border:1px solid var(--border);border-radius:var(--radius-lg);overflow-x:auto;background:var(--surface)}table.data{width:100%;border-collapse:collapse;font-size:var(--text-base)}table.data th{text-align:left;padding:10px 14px;font-size:var(--text-xs);font-weight:650;text-transform:uppercase;letter-spacing:.06em;color:var(--text-muted);background:var(--bg-subtle);border-bottom:1px solid var(--border);white-space:nowrap}table.data td{padding:10px 14px;border-bottom:1px solid var(--border);color:var(--text);vertical-align:top}table.data tbody tr:last-child td{border-bottom:none}table.data tbody tr:hover td{background:var(--bg-subtle)}table.data .num{text-align:right;font-family:var(--font-mono);font-variant-numeric:tabular-nums;white-space:nowrap}table.data tfoot td{padding:12px 14px;font-weight:700;background:var(--bg-inset);border-top:2px solid var(--border)}code.inline{font-family:var(--font-mono);font-size:var(--text-sm);padding:1px 6px;border-radius:var(--radius-sm);background:var(--bg-inset);color:var(--text-muted)}.code-block{margin:0;padding:var(--space-4);font-family:var(--font-mono);font-size:var(--text-sm);line-height:1.7;color:var(--text);background:var(--surface);white-space:pre-wrap;word-break:break-word;overflow-x:auto}.code-block--inverted{background:#0b1220;color:#d8e2f2;border-radius:var(--radius);max-height:300px;overflow:auto}.diagram{position:relative;width:100%;height:100%;min-height:0}.float-panel{position:absolute;z-index:10;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);box-shadow:var(--shadow);color:var(--text)}.node{background:var(--surface);border:1.5px solid var(--node-accent, var(--border-strong));border-left-width:4px;border-radius:var(--radius);padding:9px 12px;min-width:170px;box-shadow:var(--shadow-sm);transition:box-shadow var(--duration) var(--ease),transform var(--duration) var(--ease)}.node:hover{box-shadow:var(--shadow-lg)}.node__head{display:flex;align-items:center;gap:6px;margin-bottom:3px}.node__cat{font-size:var(--text-2xs);color:var(--text-subtle);text-transform:uppercase;letter-spacing:.08em;font-weight:600}.node__label{font-weight:650;font-size:var(--text-base);color:var(--text)}.node__meta{font-size:var(--text-xs);color:var(--text-subtle);display:flex;align-items:center;gap:6px;margin-top:2px}.node__cost{font-size:var(--text-xs);color:var(--accent-text);font-variant-numeric:tabular-nums;margin-top:4px;font-weight:600}.drawer{position:absolute;top:0;height:100%;z-index:16;display:flex;flex-direction:column;background:var(--surface);box-shadow:var(--shadow-lg)}.drawer--left{left:0;width:300px;border-right:1px solid var(--border)}.drawer--right{right:0;width:330px;border-left:1px solid var(--border)}.drawer__header{padding:var(--space-3) var(--space-4);border-bottom:1px solid var(--border)}.drawer__title{display:flex;align-items:center;justify-content:space-between;gap:var(--space-2);font-size:var(--text-md);font-weight:650}.drawer__body{flex:1;min-height:0;overflow-y:auto;padding:var(--space-3)}.drawer__footer{padding:var(--space-3);border-top:1px solid var(--border);display:flex;gap:var(--space-2)}.list-btn{display:block;width:100%;text-align:left;border:1px solid var(--border);background:var(--surface);color:var(--text);border-radius:var(--radius);padding:10px 12px;margin-bottom:var(--space-2);cursor:pointer;transition:border-color var(--duration) var(--ease),background var(--duration) var(--ease)}.list-btn:hover{border-color:var(--accent);background:var(--accent-soft)}.toasts{position:fixed;right:var(--space-4);bottom:var(--space-4);z-index:60;display:flex;flex-direction:column;gap:var(--space-2);max-width:min(420px,calc(100vw - 32px))}.toast{display:flex;align-items:flex-start;gap:var(--space-2);padding:10px 12px;border-radius:var(--radius);border:1px solid var(--danger-border);background:var(--danger-soft);color:var(--danger-text);font-size:var(--text-base);box-shadow:var(--shadow-lg);animation:cw-rise var(--duration) var(--ease)}.toast--success{border-color:var(--success-border);background:var(--success-soft);color:var(--success-text)}.toast__close{margin-left:auto;border:none;background:transparent;color:inherit;cursor:pointer;padding:0 2px;opacity:.7}.toast__close:hover{opacity:1}dialog.modal{border:1px solid var(--border);border-radius:var(--radius-lg);background:var(--surface);color:var(--text);padding:var(--space-5);max-width:min(420px,calc(100vw - 32px));box-shadow:var(--shadow-lg)}dialog.modal::backdrop{background:#0f172a73;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)}.modal__title{font-size:var(--text-lg);margin-bottom:var(--space-2)}.modal__text{font-size:var(--text-base);color:var(--text-muted);margin-bottom:var(--space-5)}.modal__actions{display:flex;justify-content:flex-end;gap:var(--space-2)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.react-flow__controls{border-radius:var(--radius);overflow:hidden;box-shadow:var(--shadow);border:1px solid var(--border)}.react-flow__controls-button{background:var(--surface);border-bottom:1px solid var(--border);fill:var(--text-muted)}.react-flow__controls-button:hover{background:var(--bg-inset)}.react-flow__edge-text{fill:var(--text-subtle)}.react-flow__edge-textbg{fill:var(--bg)}.react-flow__attribution{display:none}.react-flow__handle{border-color:var(--surface)}@media (max-width: 1180px){:root{--sidebar-width: 340px}.panel__body{padding:var(--space-5) var(--space-5)}}@media (max-width: 900px){.app{grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr)}.app__pane{display:none;min-height:0}.app__pane--active{display:flex;flex-direction:column}.sidebar{border-right:none}.drawer--left,.drawer--right{width:min(88vw,330px)}.panel__body{padding:var(--space-4)}.msg{max-width:100%}}.pane-switch{display:none;gap:var(--space-1);padding:var(--space-2);border-top:1px solid var(--border);background:var(--bg-subtle)}@media (max-width: 900px){.pane-switch{display:flex}}.pane-switch .btn{flex:1}.pane-switch .btn[aria-pressed=true]{background:var(--accent);border-color:var(--accent);color:var(--accent-contrast)}@media (max-width: 620px){.hide-narrow{display:none}.summary{gap:var(--space-3);font-size:var(--text-sm)}.summary__actions{margin-left:0;width:100%}.summary__actions .btn{flex:1}.tab{padding:0 var(--space-3)}.stat-grid{grid-template-columns:repeat(auto-fit,minmax(120px,1fr))}}@media print{.sidebar,.workspace__header,.float-panel,.drawer,.toasts{display:none!important}.app{display:block;height:auto}} diff --git a/packages/web/cloudwright_web/static/assets/index-Dsu-SCoz.js b/packages/web/cloudwright_web/static/assets/index-Dsu-SCoz.js new file mode 100644 index 0000000..be7476b --- /dev/null +++ b/packages/web/cloudwright_web/static/assets/index-Dsu-SCoz.js @@ -0,0 +1,72 @@ +(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const s of i.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function n(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(o){if(o.ep)return;o.ep=!0;const i=n(o);fetch(o.href,i)}})();function Gf(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Kf={exports:{}},Ns={},Qf={exports:{}},oe={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Ro=Symbol.for("react.element"),d0=Symbol.for("react.portal"),f0=Symbol.for("react.fragment"),h0=Symbol.for("react.strict_mode"),p0=Symbol.for("react.profiler"),m0=Symbol.for("react.provider"),g0=Symbol.for("react.context"),y0=Symbol.for("react.forward_ref"),v0=Symbol.for("react.suspense"),x0=Symbol.for("react.memo"),w0=Symbol.for("react.lazy"),kc=Symbol.iterator;function _0(e){return e===null||typeof e!="object"?null:(e=kc&&e[kc]||e["@@iterator"],typeof e=="function"?e:null)}var Zf={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},qf=Object.assign,Jf={};function jr(e,t,n){this.props=e,this.context=t,this.refs=Jf,this.updater=n||Zf}jr.prototype.isReactComponent={};jr.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};jr.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function eh(){}eh.prototype=jr.prototype;function nu(e,t,n){this.props=e,this.context=t,this.refs=Jf,this.updater=n||Zf}var ru=nu.prototype=new eh;ru.constructor=nu;qf(ru,jr.prototype);ru.isPureReactComponent=!0;var Nc=Array.isArray,th=Object.prototype.hasOwnProperty,ou={current:null},nh={key:!0,ref:!0,__self:!0,__source:!0};function rh(e,t,n){var r,o={},i=null,s=null;if(t!=null)for(r in t.ref!==void 0&&(s=t.ref),t.key!==void 0&&(i=""+t.key),t)th.call(t,r)&&!nh.hasOwnProperty(r)&&(o[r]=t[r]);var l=arguments.length-2;if(l===1)o.children=n;else if(1>>1,A=N[O];if(0>>1;Oo(D,P))Uo(X,D)?(N[O]=X,N[U]=P,O=U):(N[O]=D,N[W]=P,O=W);else if(Uo(X,P))N[O]=X,N[U]=P,O=U;else break e}}return b}function o(N,b){var P=N.sortIndex-b.sortIndex;return P!==0?P:N.id-b.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var s=Date,l=s.now();e.unstable_now=function(){return s.now()-l}}var a=[],c=[],f=1,d=null,p=3,v=!1,x=!1,w=!1,S=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,m=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function h(N){for(var b=n(c);b!==null;){if(b.callback===null)r(c);else if(b.startTime<=N)r(c),b.sortIndex=b.expirationTime,t(a,b);else break;b=n(c)}}function y(N){if(w=!1,h(N),!x)if(n(a)!==null)x=!0,z(_);else{var b=n(c);b!==null&&R(y,b.startTime-N)}}function _(N,b){x=!1,w&&(w=!1,g(M),M=-1),v=!0;var P=p;try{for(h(b),d=n(a);d!==null&&(!(d.expirationTime>b)||N&&!T());){var O=d.callback;if(typeof O=="function"){d.callback=null,p=d.priorityLevel;var A=O(d.expirationTime<=b);b=e.unstable_now(),typeof A=="function"?d.callback=A:d===n(a)&&r(a),h(b)}else r(a);d=n(a)}if(d!==null)var H=!0;else{var W=n(c);W!==null&&R(y,W.startTime-b),H=!1}return H}finally{d=null,p=P,v=!1}}var k=!1,E=null,M=-1,I=5,F=-1;function T(){return!(e.unstable_now()-FN||125O?(N.sortIndex=P,t(c,N),n(a)===null&&N===n(c)&&(w?(g(M),M=-1):w=!0,R(y,P-O))):(N.sortIndex=A,t(a,N),x||v||(x=!0,z(_))),N},e.unstable_shouldYield=T,e.unstable_wrapCallback=function(N){var b=p;return function(){var P=p;p=b;try{return N.apply(this,arguments)}finally{p=P}}}})(uh);ah.exports=uh;var z0=ah.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var I0=C,Ze=z0;function Y(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Yl=Object.prototype.hasOwnProperty,L0=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,Ec={},bc={};function A0(e){return Yl.call(bc,e)?!0:Yl.call(Ec,e)?!1:L0.test(e)?bc[e]=!0:(Ec[e]=!0,!1)}function $0(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function R0(e,t,n,r){if(t===null||typeof t>"u"||$0(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Fe(e,t,n,r,o,i,s){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=o,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=s}var Te={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Te[e]=new Fe(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Te[t]=new Fe(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Te[e]=new Fe(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Te[e]=new Fe(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Te[e]=new Fe(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Te[e]=new Fe(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Te[e]=new Fe(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Te[e]=new Fe(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Te[e]=new Fe(e,5,!1,e.toLowerCase(),null,!1,!1)});var su=/[\-:]([a-z])/g;function lu(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(su,lu);Te[t]=new Fe(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(su,lu);Te[t]=new Fe(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(su,lu);Te[t]=new Fe(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Te[e]=new Fe(e,1,!1,e.toLowerCase(),null,!1,!1)});Te.xlinkHref=new Fe("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Te[e]=new Fe(e,1,!1,e.toLowerCase(),null,!0,!0)});function au(e,t,n,r){var o=Te.hasOwnProperty(t)?Te[t]:null;(o!==null?o.type!==0:r||!(2l||o[s]!==i[l]){var a=` +`+o[s].replace(" at new "," at ");return e.displayName&&a.includes("")&&(a=a.replace("",e.displayName)),a}while(1<=s&&0<=l);break}}}finally{il=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Yr(e):""}function D0(e){switch(e.tag){case 5:return Yr(e.type);case 16:return Yr("Lazy");case 13:return Yr("Suspense");case 19:return Yr("SuspenseList");case 0:case 2:case 15:return e=sl(e.type,!1),e;case 11:return e=sl(e.type.render,!1),e;case 1:return e=sl(e.type,!0),e;default:return""}}function Ql(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Yn:return"Fragment";case Un:return"Portal";case Xl:return"Profiler";case uu:return"StrictMode";case Gl:return"Suspense";case Kl:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case fh:return(e.displayName||"Context")+".Consumer";case dh:return(e._context.displayName||"Context")+".Provider";case cu:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case du:return t=e.displayName||null,t!==null?t:Ql(e.type)||"Memo";case Gt:t=e._payload,e=e._init;try{return Ql(e(t))}catch{}}return null}function O0(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Ql(t);case 8:return t===uu?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function dn(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function ph(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function F0(e){var t=ph(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var o=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return o.call(this)},set:function(s){r=""+s,i.call(this,s)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(s){r=""+s},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function qo(e){e._valueTracker||(e._valueTracker=F0(e))}function mh(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=ph(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Vi(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Zl(e,t){var n=t.checked;return ye({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Mc(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=dn(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function gh(e,t){t=t.checked,t!=null&&au(e,"checked",t,!1)}function ql(e,t){gh(e,t);var n=dn(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Jl(e,t.type,n):t.hasOwnProperty("defaultValue")&&Jl(e,t.type,dn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Tc(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Jl(e,t,n){(t!=="number"||Vi(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Xr=Array.isArray;function ir(e,t,n,r){if(e=e.options,t){t={};for(var o=0;o"+t.valueOf().toString()+"",t=Jo.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function fo(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Jr={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},B0=["Webkit","ms","Moz","O"];Object.keys(Jr).forEach(function(e){B0.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Jr[t]=Jr[e]})});function wh(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Jr.hasOwnProperty(e)&&Jr[e]?(""+t).trim():t+"px"}function _h(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,o=wh(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,o):e[n]=o}}var H0=ye({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function na(e,t){if(t){if(H0[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(Y(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(Y(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(Y(61))}if(t.style!=null&&typeof t.style!="object")throw Error(Y(62))}}function ra(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var oa=null;function fu(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ia=null,sr=null,lr=null;function Ic(e){if(e=Fo(e)){if(typeof ia!="function")throw Error(Y(280));var t=e.stateNode;t&&(t=Ms(t),ia(e.stateNode,e.type,t))}}function Sh(e){sr?lr?lr.push(e):lr=[e]:sr=e}function kh(){if(sr){var e=sr,t=lr;if(lr=sr=null,Ic(e),t)for(e=0;e>>=0,e===0?32:31-(J0(e)/ev|0)|0}var ei=64,ti=4194304;function Gr(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Xi(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,o=e.suspendedLanes,i=e.pingedLanes,s=n&268435455;if(s!==0){var l=s&~o;l!==0?r=Gr(l):(i&=s,i!==0&&(r=Gr(i)))}else s=n&~o,s!==0?r=Gr(s):i!==0&&(r=Gr(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&o)&&(o=r&-r,i=t&-t,o>=i||o===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function Do(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-gt(t),e[t]=n}function ov(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=to),Hc=" ",Vc=!1;function Vh(e,t){switch(e){case"keyup":return zv.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Wh(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Xn=!1;function Lv(e,t){switch(e){case"compositionend":return Wh(t);case"keypress":return t.which!==32?null:(Vc=!0,Hc);case"textInput":return e=t.data,e===Hc&&Vc?null:e;default:return null}}function Av(e,t){if(Xn)return e==="compositionend"||!wu&&Vh(e,t)?(e=Bh(),Mi=yu=Jt=null,Xn=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Xc(n)}}function Gh(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Gh(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Kh(){for(var e=window,t=Vi();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Vi(e.document)}return t}function _u(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Wv(e){var t=Kh(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Gh(n.ownerDocument.documentElement,n)){if(r!==null&&_u(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var o=n.textContent.length,i=Math.min(r.start,o);r=r.end===void 0?i:Math.min(r.end,o),!e.extend&&i>r&&(o=r,r=i,i=o),o=Gc(n,i);var s=Gc(n,r);o&&s&&(e.rangeCount!==1||e.anchorNode!==o.node||e.anchorOffset!==o.offset||e.focusNode!==s.node||e.focusOffset!==s.offset)&&(t=t.createRange(),t.setStart(o.node,o.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(s.node,s.offset)):(t.setEnd(s.node,s.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,Gn=null,da=null,ro=null,fa=!1;function Kc(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;fa||Gn==null||Gn!==Vi(r)||(r=Gn,"selectionStart"in r&&_u(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),ro&&vo(ro,r)||(ro=r,r=Qi(da,"onSelect"),0Zn||(e.current=va[Zn],va[Zn]=null,Zn--)}function ae(e,t){Zn++,va[Zn]=e.current,e.current=t}var fn={},$e=pn(fn),We=pn(!1),bn=fn;function pr(e,t){var n=e.type.contextTypes;if(!n)return fn;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var o={},i;for(i in n)o[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=o),o}function Ue(e){return e=e.childContextTypes,e!=null}function qi(){de(We),de($e)}function nd(e,t,n){if($e.current!==fn)throw Error(Y(168));ae($e,t),ae(We,n)}function op(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var o in r)if(!(o in t))throw Error(Y(108,O0(e)||"Unknown",o));return ye({},n,r)}function Ji(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||fn,bn=$e.current,ae($e,e),ae(We,We.current),!0}function rd(e,t,n){var r=e.stateNode;if(!r)throw Error(Y(169));n?(e=op(e,t,bn),r.__reactInternalMemoizedMergedChildContext=e,de(We),de($e),ae($e,e)):de(We),ae(We,n)}var It=null,Ts=!1,wl=!1;function ip(e){It===null?It=[e]:It.push(e)}function nx(e){Ts=!0,ip(e)}function mn(){if(!wl&&It!==null){wl=!0;var e=0,t=le;try{var n=It;for(le=1;e>=s,o-=s,Lt=1<<32-gt(t)+o|n<M?(I=E,E=null):I=E.sibling;var F=p(g,E,h[M],y);if(F===null){E===null&&(E=I);break}e&&E&&F.alternate===null&&t(g,E),m=i(F,m,M),k===null?_=F:k.sibling=F,k=F,E=I}if(M===h.length)return n(g,E),fe&&gn(g,M),_;if(E===null){for(;MM?(I=E,E=null):I=E.sibling;var T=p(g,E,F.value,y);if(T===null){E===null&&(E=I);break}e&&E&&T.alternate===null&&t(g,E),m=i(T,m,M),k===null?_=T:k.sibling=T,k=T,E=I}if(F.done)return n(g,E),fe&&gn(g,M),_;if(E===null){for(;!F.done;M++,F=h.next())F=d(g,F.value,y),F!==null&&(m=i(F,m,M),k===null?_=F:k.sibling=F,k=F);return fe&&gn(g,M),_}for(E=r(g,E);!F.done;M++,F=h.next())F=v(E,g,M,F.value,y),F!==null&&(e&&F.alternate!==null&&E.delete(F.key===null?M:F.key),m=i(F,m,M),k===null?_=F:k.sibling=F,k=F);return e&&E.forEach(function(L){return t(g,L)}),fe&&gn(g,M),_}function S(g,m,h,y){if(typeof h=="object"&&h!==null&&h.type===Yn&&h.key===null&&(h=h.props.children),typeof h=="object"&&h!==null){switch(h.$$typeof){case Zo:e:{for(var _=h.key,k=m;k!==null;){if(k.key===_){if(_=h.type,_===Yn){if(k.tag===7){n(g,k.sibling),m=o(k,h.props.children),m.return=g,g=m;break e}}else if(k.elementType===_||typeof _=="object"&&_!==null&&_.$$typeof===Gt&&sd(_)===k.type){n(g,k.sibling),m=o(k,h.props),m.ref=Fr(g,k,h),m.return=g,g=m;break e}n(g,k);break}else t(g,k);k=k.sibling}h.type===Yn?(m=Nn(h.props.children,g.mode,y,h.key),m.return=g,g=m):(y=Ri(h.type,h.key,h.props,null,g.mode,y),y.ref=Fr(g,m,h),y.return=g,g=y)}return s(g);case Un:e:{for(k=h.key;m!==null;){if(m.key===k)if(m.tag===4&&m.stateNode.containerInfo===h.containerInfo&&m.stateNode.implementation===h.implementation){n(g,m.sibling),m=o(m,h.children||[]),m.return=g,g=m;break e}else{n(g,m);break}else t(g,m);m=m.sibling}m=jl(h,g.mode,y),m.return=g,g=m}return s(g);case Gt:return k=h._init,S(g,m,k(h._payload),y)}if(Xr(h))return x(g,m,h,y);if(Ar(h))return w(g,m,h,y);ai(g,h)}return typeof h=="string"&&h!==""||typeof h=="number"?(h=""+h,m!==null&&m.tag===6?(n(g,m.sibling),m=o(m,h),m.return=g,g=m):(n(g,m),m=bl(h,g.mode,y),m.return=g,g=m),s(g)):n(g,m)}return S}var gr=up(!0),cp=up(!1),ns=pn(null),rs=null,er=null,Cu=null;function Eu(){Cu=er=rs=null}function bu(e){var t=ns.current;de(ns),e._currentValue=t}function _a(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function ur(e,t){rs=e,Cu=er=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(He=!0),e.firstContext=null)}function st(e){var t=e._currentValue;if(Cu!==e)if(e={context:e,memoizedValue:t,next:null},er===null){if(rs===null)throw Error(Y(308));er=e,rs.dependencies={lanes:0,firstContext:e}}else er=er.next=e;return t}var wn=null;function ju(e){wn===null?wn=[e]:wn.push(e)}function dp(e,t,n,r){var o=t.interleaved;return o===null?(n.next=n,ju(t)):(n.next=o.next,o.next=n),t.interleaved=n,Ft(e,r)}function Ft(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Kt=!1;function Mu(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function fp(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Rt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function sn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,se&2){var o=r.pending;return o===null?t.next=t:(t.next=o.next,o.next=t),r.pending=t,Ft(e,n)}return o=r.interleaved,o===null?(t.next=t,ju(r)):(t.next=o.next,o.next=t),r.interleaved=t,Ft(e,n)}function Pi(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,pu(e,n)}}function ld(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var o=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var s={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?o=i=s:i=i.next=s,n=n.next}while(n!==null);i===null?o=i=t:i=i.next=t}else o=i=t;n={baseState:r.baseState,firstBaseUpdate:o,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function os(e,t,n,r){var o=e.updateQueue;Kt=!1;var i=o.firstBaseUpdate,s=o.lastBaseUpdate,l=o.shared.pending;if(l!==null){o.shared.pending=null;var a=l,c=a.next;a.next=null,s===null?i=c:s.next=c,s=a;var f=e.alternate;f!==null&&(f=f.updateQueue,l=f.lastBaseUpdate,l!==s&&(l===null?f.firstBaseUpdate=c:l.next=c,f.lastBaseUpdate=a))}if(i!==null){var d=o.baseState;s=0,f=c=a=null,l=i;do{var p=l.lane,v=l.eventTime;if((r&p)===p){f!==null&&(f=f.next={eventTime:v,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var x=e,w=l;switch(p=t,v=n,w.tag){case 1:if(x=w.payload,typeof x=="function"){d=x.call(v,d,p);break e}d=x;break e;case 3:x.flags=x.flags&-65537|128;case 0:if(x=w.payload,p=typeof x=="function"?x.call(v,d,p):x,p==null)break e;d=ye({},d,p);break e;case 2:Kt=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,p=o.effects,p===null?o.effects=[l]:p.push(l))}else v={eventTime:v,lane:p,tag:l.tag,payload:l.payload,callback:l.callback,next:null},f===null?(c=f=v,a=d):f=f.next=v,s|=p;if(l=l.next,l===null){if(l=o.shared.pending,l===null)break;p=l,l=p.next,p.next=null,o.lastBaseUpdate=p,o.shared.pending=null}}while(!0);if(f===null&&(a=d),o.baseState=a,o.firstBaseUpdate=c,o.lastBaseUpdate=f,t=o.shared.interleaved,t!==null){o=t;do s|=o.lane,o=o.next;while(o!==t)}else i===null&&(o.shared.lanes=0);Tn|=s,e.lanes=s,e.memoizedState=d}}function ad(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=Sl.transition;Sl.transition={};try{e(!1),t()}finally{le=n,Sl.transition=r}}function Mp(){return lt().memoizedState}function sx(e,t,n){var r=an(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Tp(e))Pp(t,n);else if(n=dp(e,t,n,r),n!==null){var o=De();yt(n,e,r,o),zp(n,t,r)}}function lx(e,t,n){var r=an(e),o={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Tp(e))Pp(t,o);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var s=t.lastRenderedState,l=i(s,n);if(o.hasEagerState=!0,o.eagerState=l,vt(l,s)){var a=t.interleaved;a===null?(o.next=o,ju(t)):(o.next=a.next,a.next=o),t.interleaved=o;return}}catch{}finally{}n=dp(e,t,o,r),n!==null&&(o=De(),yt(n,e,r,o),zp(n,t,r))}}function Tp(e){var t=e.alternate;return e===ge||t!==null&&t===ge}function Pp(e,t){oo=ss=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function zp(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,pu(e,n)}}var ls={readContext:st,useCallback:Ie,useContext:Ie,useEffect:Ie,useImperativeHandle:Ie,useInsertionEffect:Ie,useLayoutEffect:Ie,useMemo:Ie,useReducer:Ie,useRef:Ie,useState:Ie,useDebugValue:Ie,useDeferredValue:Ie,useTransition:Ie,useMutableSource:Ie,useSyncExternalStore:Ie,useId:Ie,unstable_isNewReconciler:!1},ax={readContext:st,useCallback:function(e,t){return St().memoizedState=[e,t===void 0?null:t],e},useContext:st,useEffect:cd,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Ii(4194308,4,Np.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ii(4194308,4,e,t)},useInsertionEffect:function(e,t){return Ii(4,2,e,t)},useMemo:function(e,t){var n=St();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=St();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=sx.bind(null,ge,e),[r.memoizedState,e]},useRef:function(e){var t=St();return e={current:e},t.memoizedState=e},useState:ud,useDebugValue:Ru,useDeferredValue:function(e){return St().memoizedState=e},useTransition:function(){var e=ud(!1),t=e[0];return e=ix.bind(null,e[1]),St().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=ge,o=St();if(fe){if(n===void 0)throw Error(Y(407));n=n()}else{if(n=t(),be===null)throw Error(Y(349));Mn&30||gp(r,t,n)}o.memoizedState=n;var i={value:n,getSnapshot:t};return o.queue=i,cd(vp.bind(null,r,i,e),[e]),r.flags|=2048,Eo(9,yp.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=St(),t=be.identifierPrefix;if(fe){var n=At,r=Lt;n=(r&~(1<<32-gt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=No++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=s.createElement(n,{is:r.is}):(e=s.createElement(n),n==="select"&&(s=e,r.multiple?s.multiple=!0:r.size&&(s.size=r.size))):e=s.createElementNS(e,n),e[Nt]=t,e[_o]=r,Hp(e,t,!1,!1),t.stateNode=e;e:{switch(s=ra(n,r),n){case"dialog":ce("cancel",e),ce("close",e),o=r;break;case"iframe":case"object":case"embed":ce("load",e),o=r;break;case"video":case"audio":for(o=0;oxr&&(t.flags|=128,r=!0,Br(i,!1),t.lanes=4194304)}else{if(!r)if(e=is(s),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Br(i,!0),i.tail===null&&i.tailMode==="hidden"&&!s.alternate&&!fe)return Le(t),null}else 2*we()-i.renderingStartTime>xr&&n!==1073741824&&(t.flags|=128,r=!0,Br(i,!1),t.lanes=4194304);i.isBackwards?(s.sibling=t.child,t.child=s):(n=i.last,n!==null?n.sibling=s:t.child=s,i.last=s)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=we(),t.sibling=null,n=me.current,ae(me,r?n&1|2:n&1),t):(Le(t),null);case 22:case 23:return Vu(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Xe&1073741824&&(Le(t),t.subtreeFlags&6&&(t.flags|=8192)):Le(t),null;case 24:return null;case 25:return null}throw Error(Y(156,t.tag))}function gx(e,t){switch(ku(t),t.tag){case 1:return Ue(t.type)&&qi(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return yr(),de(We),de($e),zu(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Pu(t),null;case 13:if(de(me),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(Y(340));mr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return de(me),null;case 4:return yr(),null;case 10:return bu(t.type._context),null;case 22:case 23:return Vu(),null;case 24:return null;default:return null}}var ci=!1,Ae=!1,yx=typeof WeakSet=="function"?WeakSet:Set,Q=null;function tr(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){xe(e,t,r)}else n.current=null}function Ta(e,t,n){try{n()}catch(r){xe(e,t,r)}}var _d=!1;function vx(e,t){if(ha=Gi,e=Kh(),_u(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var o=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var s=0,l=-1,a=-1,c=0,f=0,d=e,p=null;t:for(;;){for(var v;d!==n||o!==0&&d.nodeType!==3||(l=s+o),d!==i||r!==0&&d.nodeType!==3||(a=s+r),d.nodeType===3&&(s+=d.nodeValue.length),(v=d.firstChild)!==null;)p=d,d=v;for(;;){if(d===e)break t;if(p===n&&++c===o&&(l=s),p===i&&++f===r&&(a=s),(v=d.nextSibling)!==null)break;d=p,p=d.parentNode}d=v}n=l===-1||a===-1?null:{start:l,end:a}}else n=null}n=n||{start:0,end:0}}else n=null;for(pa={focusedElem:e,selectionRange:n},Gi=!1,Q=t;Q!==null;)if(t=Q,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Q=e;else for(;Q!==null;){t=Q;try{var x=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(x!==null){var w=x.memoizedProps,S=x.memoizedState,g=t.stateNode,m=g.getSnapshotBeforeUpdate(t.elementType===t.type?w:ut(t.type,w),S);g.__reactInternalSnapshotBeforeUpdate=m}break;case 3:var h=t.stateNode.containerInfo;h.nodeType===1?h.textContent="":h.nodeType===9&&h.documentElement&&h.removeChild(h.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Y(163))}}catch(y){xe(t,t.return,y)}if(e=t.sibling,e!==null){e.return=t.return,Q=e;break}Q=t.return}return x=_d,_d=!1,x}function io(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var o=r=r.next;do{if((o.tag&e)===e){var i=o.destroy;o.destroy=void 0,i!==void 0&&Ta(t,n,i)}o=o.next}while(o!==r)}}function Is(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Pa(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Up(e){var t=e.alternate;t!==null&&(e.alternate=null,Up(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Nt],delete t[_o],delete t[ya],delete t[ex],delete t[tx])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Yp(e){return e.tag===5||e.tag===3||e.tag===4}function Sd(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Yp(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function za(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Zi));else if(r!==4&&(e=e.child,e!==null))for(za(e,t,n),e=e.sibling;e!==null;)za(e,t,n),e=e.sibling}function Ia(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Ia(e,t,n),e=e.sibling;e!==null;)Ia(e,t,n),e=e.sibling}var je=null,ct=!1;function Ut(e,t,n){for(n=n.child;n!==null;)Xp(e,t,n),n=n.sibling}function Xp(e,t,n){if(Ct&&typeof Ct.onCommitFiberUnmount=="function")try{Ct.onCommitFiberUnmount(Cs,n)}catch{}switch(n.tag){case 5:Ae||tr(n,t);case 6:var r=je,o=ct;je=null,Ut(e,t,n),je=r,ct=o,je!==null&&(ct?(e=je,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):je.removeChild(n.stateNode));break;case 18:je!==null&&(ct?(e=je,n=n.stateNode,e.nodeType===8?xl(e.parentNode,n):e.nodeType===1&&xl(e,n),go(e)):xl(je,n.stateNode));break;case 4:r=je,o=ct,je=n.stateNode.containerInfo,ct=!0,Ut(e,t,n),je=r,ct=o;break;case 0:case 11:case 14:case 15:if(!Ae&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){o=r=r.next;do{var i=o,s=i.destroy;i=i.tag,s!==void 0&&(i&2||i&4)&&Ta(n,t,s),o=o.next}while(o!==r)}Ut(e,t,n);break;case 1:if(!Ae&&(tr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){xe(n,t,l)}Ut(e,t,n);break;case 21:Ut(e,t,n);break;case 22:n.mode&1?(Ae=(r=Ae)||n.memoizedState!==null,Ut(e,t,n),Ae=r):Ut(e,t,n);break;default:Ut(e,t,n)}}function kd(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new yx),t.forEach(function(r){var o=bx.bind(null,e,r);n.has(r)||(n.add(r),r.then(o,o))})}}function at(e,t){var n=t.deletions;if(n!==null)for(var r=0;ro&&(o=s),r&=~i}if(r=o,r=we()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*wx(r/1960))-r,10e?16:e,en===null)var r=!1;else{if(e=en,en=null,cs=0,se&6)throw Error(Y(331));var o=se;for(se|=4,Q=e.current;Q!==null;){var i=Q,s=i.child;if(Q.flags&16){var l=i.deletions;if(l!==null){for(var a=0;awe()-Bu?kn(e,0):Fu|=n),Ye(e,t)}function tm(e,t){t===0&&(e.mode&1?(t=ti,ti<<=1,!(ti&130023424)&&(ti=4194304)):t=1);var n=De();e=Ft(e,t),e!==null&&(Do(e,t,n),Ye(e,n))}function Ex(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),tm(e,n)}function bx(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,o=e.memoizedState;o!==null&&(n=o.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(Y(314))}r!==null&&r.delete(t),tm(e,n)}var nm;nm=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||We.current)He=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return He=!1,px(e,t,n);He=!!(e.flags&131072)}else He=!1,fe&&t.flags&1048576&&sp(t,ts,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Li(e,t),e=t.pendingProps;var o=pr(t,$e.current);ur(t,n),o=Lu(null,t,r,e,o,n);var i=Au();return t.flags|=1,typeof o=="object"&&o!==null&&typeof o.render=="function"&&o.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Ue(r)?(i=!0,Ji(t)):i=!1,t.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,Mu(t),o.updater=zs,t.stateNode=o,o._reactInternals=t,ka(t,r,e,n),t=Ea(null,t,r,!0,i,n)):(t.tag=0,fe&&i&&Su(t),Re(null,t,o,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Li(e,t),e=t.pendingProps,o=r._init,r=o(r._payload),t.type=r,o=t.tag=Mx(r),e=ut(r,e),o){case 0:t=Ca(null,t,r,e,n);break e;case 1:t=vd(null,t,r,e,n);break e;case 11:t=gd(null,t,r,e,n);break e;case 14:t=yd(null,t,r,ut(r.type,e),n);break e}throw Error(Y(306,r,""))}return t;case 0:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:ut(r,o),Ca(e,t,r,o,n);case 1:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:ut(r,o),vd(e,t,r,o,n);case 3:e:{if(Op(t),e===null)throw Error(Y(387));r=t.pendingProps,i=t.memoizedState,o=i.element,fp(e,t),os(t,r,null,n);var s=t.memoizedState;if(r=s.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){o=vr(Error(Y(423)),t),t=xd(e,t,r,n,o);break e}else if(r!==o){o=vr(Error(Y(424)),t),t=xd(e,t,r,n,o);break e}else for(Ke=on(t.stateNode.containerInfo.firstChild),Qe=t,fe=!0,ft=null,n=cp(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(mr(),r===o){t=Bt(e,t,n);break e}Re(e,t,r,n)}t=t.child}return t;case 5:return hp(t),e===null&&wa(t),r=t.type,o=t.pendingProps,i=e!==null?e.memoizedProps:null,s=o.children,ma(r,o)?s=null:i!==null&&ma(r,i)&&(t.flags|=32),Dp(e,t),Re(e,t,s,n),t.child;case 6:return e===null&&wa(t),null;case 13:return Fp(e,t,n);case 4:return Tu(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=gr(t,null,r,n):Re(e,t,r,n),t.child;case 11:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:ut(r,o),gd(e,t,r,o,n);case 7:return Re(e,t,t.pendingProps,n),t.child;case 8:return Re(e,t,t.pendingProps.children,n),t.child;case 12:return Re(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,o=t.pendingProps,i=t.memoizedProps,s=o.value,ae(ns,r._currentValue),r._currentValue=s,i!==null)if(vt(i.value,s)){if(i.children===o.children&&!We.current){t=Bt(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var l=i.dependencies;if(l!==null){s=i.child;for(var a=l.firstContext;a!==null;){if(a.context===r){if(i.tag===1){a=Rt(-1,n&-n),a.tag=2;var c=i.updateQueue;if(c!==null){c=c.shared;var f=c.pending;f===null?a.next=a:(a.next=f.next,f.next=a),c.pending=a}}i.lanes|=n,a=i.alternate,a!==null&&(a.lanes|=n),_a(i.return,n,t),l.lanes|=n;break}a=a.next}}else if(i.tag===10)s=i.type===t.type?null:i.child;else if(i.tag===18){if(s=i.return,s===null)throw Error(Y(341));s.lanes|=n,l=s.alternate,l!==null&&(l.lanes|=n),_a(s,n,t),s=i.sibling}else s=i.child;if(s!==null)s.return=i;else for(s=i;s!==null;){if(s===t){s=null;break}if(i=s.sibling,i!==null){i.return=s.return,s=i;break}s=s.return}i=s}Re(e,t,o.children,n),t=t.child}return t;case 9:return o=t.type,r=t.pendingProps.children,ur(t,n),o=st(o),r=r(o),t.flags|=1,Re(e,t,r,n),t.child;case 14:return r=t.type,o=ut(r,t.pendingProps),o=ut(r.type,o),yd(e,t,r,o,n);case 15:return $p(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:ut(r,o),Li(e,t),t.tag=1,Ue(r)?(e=!0,Ji(t)):e=!1,ur(t,n),Ip(t,r,o),ka(t,r,o,n),Ea(null,t,r,!0,e,n);case 19:return Bp(e,t,n);case 22:return Rp(e,t,n)}throw Error(Y(156,t.tag))};function rm(e,t){return Th(e,t)}function jx(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ot(e,t,n,r){return new jx(e,t,n,r)}function Uu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Mx(e){if(typeof e=="function")return Uu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===cu)return 11;if(e===du)return 14}return 2}function un(e,t){var n=e.alternate;return n===null?(n=ot(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Ri(e,t,n,r,o,i){var s=2;if(r=e,typeof e=="function")Uu(e)&&(s=1);else if(typeof e=="string")s=5;else e:switch(e){case Yn:return Nn(n.children,o,i,t);case uu:s=8,o|=8;break;case Xl:return e=ot(12,n,t,o|2),e.elementType=Xl,e.lanes=i,e;case Gl:return e=ot(13,n,t,o),e.elementType=Gl,e.lanes=i,e;case Kl:return e=ot(19,n,t,o),e.elementType=Kl,e.lanes=i,e;case hh:return As(n,o,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case dh:s=10;break e;case fh:s=9;break e;case cu:s=11;break e;case du:s=14;break e;case Gt:s=16,r=null;break e}throw Error(Y(130,e==null?e:typeof e,""))}return t=ot(s,n,t,o),t.elementType=e,t.type=r,t.lanes=i,t}function Nn(e,t,n,r){return e=ot(7,e,r,t),e.lanes=n,e}function As(e,t,n,r){return e=ot(22,e,r,t),e.elementType=hh,e.lanes=n,e.stateNode={isHidden:!1},e}function bl(e,t,n){return e=ot(6,e,null,t),e.lanes=n,e}function jl(e,t,n){return t=ot(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Tx(e,t,n,r,o){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=al(0),this.expirationTimes=al(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=al(0),this.identifierPrefix=r,this.onRecoverableError=o,this.mutableSourceEagerHydrationData=null}function Yu(e,t,n,r,o,i,s,l,a){return e=new Tx(e,t,n,l,a),t===1?(t=1,i===!0&&(t|=8)):t=0,i=ot(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Mu(i),e}function Px(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(lm)}catch(e){console.error(e)}}lm(),lh.exports=Je;var $x=lh.exports,Pd=$x;Ul.createRoot=Pd.createRoot,Ul.hydrateRoot=Pd.hydrateRoot;function Se(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n{}};function Fs(){for(var e=0,t=arguments.length,n={},r;e=0&&(r=n.slice(o+1),n=n.slice(0,o)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Di.prototype=Fs.prototype={constructor:Di,on:function(e,t){var n=this._,r=Dx(e+"",n),o,i=-1,s=r.length;if(arguments.length<2){for(;++i0)for(var n=new Array(o),r=0,o,i;r=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Id.hasOwnProperty(t)?{space:Id[t],local:e}:e}function Fx(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Da&&t.documentElement.namespaceURI===Da?t.createElement(e):t.createElementNS(n,e)}}function Bx(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function am(e){var t=Bs(e);return(t.local?Bx:Fx)(t)}function Hx(){}function Qu(e){return e==null?Hx:function(){return this.querySelector(e)}}function Vx(e){typeof e!="function"&&(e=Qu(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o=h&&(h=m+1);!(_=S[h])&&++h=0;)(s=r[o])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function pw(e){e||(e=mw);function t(d,p){return d&&p?e(d.__data__,p.__data__):!d-!p}for(var n=this._groups,r=n.length,o=new Array(r),i=0;it?1:e>=t?0:NaN}function gw(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function yw(){return Array.from(this)}function vw(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?Mw:typeof t=="function"?Pw:Tw)(e,t,n??"")):wr(this.node(),e)}function wr(e,t){return e.style.getPropertyValue(t)||hm(e).getComputedStyle(e,null).getPropertyValue(t)}function Iw(e){return function(){delete this[e]}}function Lw(e,t){return function(){this[e]=t}}function Aw(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function $w(e,t){return arguments.length>1?this.each((t==null?Iw:typeof t=="function"?Aw:Lw)(e,t)):this.node()[e]}function pm(e){return e.trim().split(/^|\s+/)}function Zu(e){return e.classList||new mm(e)}function mm(e){this._node=e,this._names=pm(e.getAttribute("class")||"")}mm.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 gm(e,t){for(var n=Zu(e),r=-1,o=t.length;++r=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function c1(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,o=t.length,i;n()=>e;function Oa(e,{sourceEvent:t,subject:n,target:r,identifier:o,active:i,x:s,y:l,dx:a,dy:c,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:r,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:a,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:f}})}Oa.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function w1(e){return!e.ctrlKey&&!e.button}function _1(){return this.parentNode}function S1(e,t){return t??{x:e.x,y:e.y}}function k1(){return navigator.maxTouchPoints||"ontouchstart"in this}function Sm(){var e=w1,t=_1,n=S1,r=k1,o={},i=Fs("start","drag","end"),s=0,l,a,c,f,d=0;function p(y){y.on("mousedown.drag",v).filter(r).on("touchstart.drag",S).on("touchmove.drag",g,x1).on("touchend.drag touchcancel.drag",m).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function v(y,_){if(!(f||!e.call(this,y,_))){var k=h(this,t.call(this,y,_),y,_,"mouse");k&&(Ge(y.view).on("mousemove.drag",x,jo).on("mouseup.drag",w,jo),wm(y.view),Ml(y),c=!1,l=y.clientX,a=y.clientY,k("start",y))}}function x(y){if(dr(y),!c){var _=y.clientX-l,k=y.clientY-a;c=_*_+k*k>d}o.mouse("drag",y)}function w(y){Ge(y.view).on("mousemove.drag mouseup.drag",null),_m(y.view,c),dr(y),o.mouse("end",y)}function S(y,_){if(e.call(this,y,_)){var k=y.changedTouches,E=t.call(this,y,_),M=k.length,I,F;for(I=0;I>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?pi(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?pi(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=C1.exec(e))?new Ve(t[1],t[2],t[3],1):(t=E1.exec(e))?new Ve(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=b1.exec(e))?pi(t[1],t[2],t[3],t[4]):(t=j1.exec(e))?pi(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=M1.exec(e))?Fd(t[1],t[2]/100,t[3]/100,1):(t=T1.exec(e))?Fd(t[1],t[2]/100,t[3]/100,t[4]):Ld.hasOwnProperty(e)?Rd(Ld[e]):e==="transparent"?new Ve(NaN,NaN,NaN,0):null}function Rd(e){return new Ve(e>>16&255,e>>8&255,e&255,1)}function pi(e,t,n,r){return r<=0&&(e=t=n=NaN),new Ve(e,t,n,r)}function I1(e){return e instanceof Vo||(e=zn(e)),e?(e=e.rgb(),new Ve(e.r,e.g,e.b,e.opacity)):new Ve}function Fa(e,t,n,r){return arguments.length===1?I1(e):new Ve(e,t,n,r??1)}function Ve(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}qu(Ve,Fa,km(Vo,{brighter(e){return e=e==null?ps:Math.pow(ps,e),new Ve(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Mo:Math.pow(Mo,e),new Ve(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ve(Cn(this.r),Cn(this.g),Cn(this.b),ms(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:Dd,formatHex:Dd,formatHex8:L1,formatRgb:Od,toString:Od}));function Dd(){return`#${Sn(this.r)}${Sn(this.g)}${Sn(this.b)}`}function L1(){return`#${Sn(this.r)}${Sn(this.g)}${Sn(this.b)}${Sn((isNaN(this.opacity)?1:this.opacity)*255)}`}function Od(){const e=ms(this.opacity);return`${e===1?"rgb(":"rgba("}${Cn(this.r)}, ${Cn(this.g)}, ${Cn(this.b)}${e===1?")":`, ${e})`}`}function ms(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Cn(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Sn(e){return e=Cn(e),(e<16?"0":"")+e.toString(16)}function Fd(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new ht(e,t,n,r)}function Nm(e){if(e instanceof ht)return new ht(e.h,e.s,e.l,e.opacity);if(e instanceof Vo||(e=zn(e)),!e)return new ht;if(e instanceof ht)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,o=Math.min(t,n,r),i=Math.max(t,n,r),s=NaN,l=i-o,a=(i+o)/2;return l?(t===i?s=(n-r)/l+(n0&&a<1?0:s,new ht(s,l,a,e.opacity)}function A1(e,t,n,r){return arguments.length===1?Nm(e):new ht(e,t,n,r??1)}function ht(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}qu(ht,A1,km(Vo,{brighter(e){return e=e==null?ps:Math.pow(ps,e),new ht(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Mo:Math.pow(Mo,e),new ht(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,r=n+(n<.5?n:1-n)*t,o=2*n-r;return new Ve(Tl(e>=240?e-240:e+120,o,r),Tl(e,o,r),Tl(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new ht(Bd(this.h),mi(this.s),mi(this.l),ms(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=ms(this.opacity);return`${e===1?"hsl(":"hsla("}${Bd(this.h)}, ${mi(this.s)*100}%, ${mi(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Bd(e){return e=(e||0)%360,e<0?e+360:e}function mi(e){return Math.max(0,Math.min(1,e||0))}function Tl(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 Ju=e=>()=>e;function $1(e,t){return function(n){return e+n*t}}function R1(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function D1(e){return(e=+e)==1?Cm:function(t,n){return n-t?R1(t,n,e):Ju(isNaN(t)?n:t)}}function Cm(e,t){var n=t-e;return n?$1(e,n):Ju(isNaN(e)?t:e)}const gs=function e(t){var n=D1(t);function r(o,i){var s=n((o=Fa(o)).r,(i=Fa(i)).r),l=n(o.g,i.g),a=n(o.b,i.b),c=Cm(o.opacity,i.opacity);return function(f){return o.r=s(f),o.g=l(f),o.b=a(f),o.opacity=c(f),o+""}}return r.gamma=e,r}(1);function O1(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),o;return function(i){for(o=0;on&&(i=t.slice(n,i),l[s]?l[s]+=i:l[++s]=i),(r=r[0])===(o=o[0])?l[s]?l[s]+=o:l[++s]=o:(l[++s]=null,a.push({i:s,x:kt(r,o)})),n=Pl.lastIndex;return n180?f+=360:f-c>180&&(c+=360),p.push({i:d.push(o(d)+"rotate(",null,r)-2,x:kt(c,f)})):f&&d.push(o(d)+"rotate("+f+r)}function l(c,f,d,p){c!==f?p.push({i:d.push(o(d)+"skewX(",null,r)-2,x:kt(c,f)}):f&&d.push(o(d)+"skewX("+f+r)}function a(c,f,d,p,v,x){if(c!==d||f!==p){var w=v.push(o(v)+"scale(",null,",",null,")");x.push({i:w-4,x:kt(c,d)},{i:w-2,x:kt(f,p)})}else(d!==1||p!==1)&&v.push(o(v)+"scale("+d+","+p+")")}return function(c,f){var d=[],p=[];return c=e(c),f=e(f),i(c.translateX,c.translateY,f.translateX,f.translateY,d,p),s(c.rotate,f.rotate,d,p),l(c.skewX,f.skewX,d,p),a(c.scaleX,c.scaleY,f.scaleX,f.scaleY,d,p),c=f=null,function(v){for(var x=-1,w=p.length,S;++x=0&&e._call.call(void 0,t),e=e._next;--_r}function Wd(){In=(vs=Po.now())+Hs,_r=Qr=0;try{e_()}finally{_r=0,n_(),In=0}}function t_(){var e=Po.now(),t=e-vs;t>Mm&&(Hs-=t,vs=e)}function n_(){for(var e,t=ys,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:ys=n);Zr=e,Va(r)}function Va(e){if(!_r){Qr&&(Qr=clearTimeout(Qr));var t=e-In;t>24?(e<1/0&&(Qr=setTimeout(Wd,e-Po.now()-Hs)),Vr&&(Vr=clearInterval(Vr))):(Vr||(vs=Po.now(),Vr=setInterval(t_,Mm)),_r=1,Tm(Wd))}}function Ud(e,t,n){var r=new xs;return t=t==null?0:+t,r.restart(o=>{r.stop(),e(o+t)},t,n),r}var r_=Fs("start","end","cancel","interrupt"),o_=[],zm=0,Yd=1,Wa=2,Fi=3,Xd=4,Ua=5,Bi=6;function Vs(e,t,n,r,o,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;i_(e,n,{name:t,index:r,group:o,on:r_,tween:o_,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:zm})}function tc(e,t){var n=xt(e,t);if(n.state>zm)throw new Error("too late; already scheduled");return n}function Tt(e,t){var n=xt(e,t);if(n.state>Fi)throw new Error("too late; already running");return n}function xt(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function i_(e,t,n){var r=e.__transition,o;r[t]=n,n.timer=Pm(i,0,n.time);function i(c){n.state=Yd,n.timer.restart(s,n.delay,n.time),n.delay<=c&&s(c-n.delay)}function s(c){var f,d,p,v;if(n.state!==Yd)return a();for(f in r)if(v=r[f],v.name===n.name){if(v.state===Fi)return Ud(s);v.state===Xd?(v.state=Bi,v.timer.stop(),v.on.call("interrupt",e,e.__data__,v.index,v.group),delete r[f]):+fWa&&r.state=0&&(t=t.slice(0,n)),!t||t==="start"})}function A_(e,t,n){var r,o,i=L_(t)?tc:Tt;return function(){var s=i(this,e),l=s.on;l!==r&&(o=(r=l).copy()).on(t,n),s.on=o}}function $_(e,t){var n=this._id;return arguments.length<2?xt(this.node(),n).on.on(e):this.each(A_(n,e,t))}function R_(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function D_(){return this.on("end.remove",R_(this._id))}function O_(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Qu(e));for(var r=this._groups,o=r.length,i=new Array(o),s=0;s()=>e;function cS(e,{sourceEvent:t,target:n,transform:r,dispatch:o}){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:r,enumerable:!0,configurable:!0},_:{value:o}})}function $t(e,t,n){this.k=e,this.x=t,this.y=n}$t.prototype={constructor:$t,scale:function(e){return e===1?this:new $t(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new $t(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 Ws=new $t(1,0,0);$m.prototype=$t.prototype;function $m(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Ws;return e.__zoom}function zl(e){e.stopImmediatePropagation()}function Wr(e){e.preventDefault(),e.stopImmediatePropagation()}function dS(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function fS(){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 Gd(){return this.__zoom||Ws}function hS(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function pS(){return navigator.maxTouchPoints||"ontouchstart"in this}function mS(e,t,n){var r=e.invertX(t[0][0])-n[0][0],o=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(o>r?(r+o)/2:Math.min(0,r)||Math.max(0,o),s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s))}function Rm(){var e=dS,t=fS,n=mS,r=hS,o=pS,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],l=250,a=Oi,c=Fs("start","zoom","end"),f,d,p,v=500,x=150,w=0,S=10;function g(j){j.property("__zoom",Gd).on("wheel.zoom",M,{passive:!1}).on("mousedown.zoom",I).on("dblclick.zoom",F).filter(o).on("touchstart.zoom",T).on("touchmove.zoom",L).on("touchend.zoom touchcancel.zoom",B).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}g.transform=function(j,$,z,R){var N=j.selection?j.selection():j;N.property("__zoom",Gd),j!==N?_(j,$,z,R):N.interrupt().each(function(){k(this,arguments).event(R).start().zoom(null,typeof $=="function"?$.apply(this,arguments):$).end()})},g.scaleBy=function(j,$,z,R){g.scaleTo(j,function(){var N=this.__zoom.k,b=typeof $=="function"?$.apply(this,arguments):$;return N*b},z,R)},g.scaleTo=function(j,$,z,R){g.transform(j,function(){var N=t.apply(this,arguments),b=this.__zoom,P=z==null?y(N):typeof z=="function"?z.apply(this,arguments):z,O=b.invert(P),A=typeof $=="function"?$.apply(this,arguments):$;return n(h(m(b,A),P,O),N,s)},z,R)},g.translateBy=function(j,$,z,R){g.transform(j,function(){return n(this.__zoom.translate(typeof $=="function"?$.apply(this,arguments):$,typeof z=="function"?z.apply(this,arguments):z),t.apply(this,arguments),s)},null,R)},g.translateTo=function(j,$,z,R,N){g.transform(j,function(){var b=t.apply(this,arguments),P=this.__zoom,O=R==null?y(b):typeof R=="function"?R.apply(this,arguments):R;return n(Ws.translate(O[0],O[1]).scale(P.k).translate(typeof $=="function"?-$.apply(this,arguments):-$,typeof z=="function"?-z.apply(this,arguments):-z),b,s)},R,N)};function m(j,$){return $=Math.max(i[0],Math.min(i[1],$)),$===j.k?j:new $t($,j.x,j.y)}function h(j,$,z){var R=$[0]-z[0]*j.k,N=$[1]-z[1]*j.k;return R===j.x&&N===j.y?j:new $t(j.k,R,N)}function y(j){return[(+j[0][0]+ +j[1][0])/2,(+j[0][1]+ +j[1][1])/2]}function _(j,$,z,R){j.on("start.zoom",function(){k(this,arguments).event(R).start()}).on("interrupt.zoom end.zoom",function(){k(this,arguments).event(R).end()}).tween("zoom",function(){var N=this,b=arguments,P=k(N,b).event(R),O=t.apply(N,b),A=z==null?y(O):typeof z=="function"?z.apply(N,b):z,H=Math.max(O[1][0]-O[0][0],O[1][1]-O[0][1]),W=N.__zoom,D=typeof $=="function"?$.apply(N,b):$,U=a(W.invert(A).concat(H/W.k),D.invert(A).concat(H/D.k));return function(X){if(X===1)X=D;else{var V=U(X),G=H/V[2];X=new $t(G,A[0]-V[0]*G,A[1]-V[1]*G)}P.zoom(null,X)}})}function k(j,$,z){return!z&&j.__zooming||new E(j,$)}function E(j,$){this.that=j,this.args=$,this.active=0,this.sourceEvent=null,this.extent=t.apply(j,$),this.taps=0}E.prototype={event:function(j){return j&&(this.sourceEvent=j),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(j,$){return this.mouse&&j!=="mouse"&&(this.mouse[1]=$.invert(this.mouse[0])),this.touch0&&j!=="touch"&&(this.touch0[1]=$.invert(this.touch0[0])),this.touch1&&j!=="touch"&&(this.touch1[1]=$.invert(this.touch1[0])),this.that.__zoom=$,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(j){var $=Ge(this.that).datum();c.call(j,this.that,new cS(j,{sourceEvent:this.sourceEvent,target:g,transform:this.that.__zoom,dispatch:c}),$)}};function M(j,...$){if(!e.apply(this,arguments))return;var z=k(this,$).event(j),R=this.__zoom,N=Math.max(i[0],Math.min(i[1],R.k*Math.pow(2,r.apply(this,arguments)))),b=dt(j);if(z.wheel)(z.mouse[0][0]!==b[0]||z.mouse[0][1]!==b[1])&&(z.mouse[1]=R.invert(z.mouse[0]=b)),clearTimeout(z.wheel);else{if(R.k===N)return;z.mouse=[b,R.invert(b)],Hi(this),z.start()}Wr(j),z.wheel=setTimeout(P,x),z.zoom("mouse",n(h(m(R,N),z.mouse[0],z.mouse[1]),z.extent,s));function P(){z.wheel=null,z.end()}}function I(j,...$){if(p||!e.apply(this,arguments))return;var z=j.currentTarget,R=k(this,$,!0).event(j),N=Ge(j.view).on("mousemove.zoom",A,!0).on("mouseup.zoom",H,!0),b=dt(j,z),P=j.clientX,O=j.clientY;wm(j.view),zl(j),R.mouse=[b,this.__zoom.invert(b)],Hi(this),R.start();function A(W){if(Wr(W),!R.moved){var D=W.clientX-P,U=W.clientY-O;R.moved=D*D+U*U>w}R.event(W).zoom("mouse",n(h(R.that.__zoom,R.mouse[0]=dt(W,z),R.mouse[1]),R.extent,s))}function H(W){N.on("mousemove.zoom mouseup.zoom",null),_m(W.view,R.moved),Wr(W),R.event(W).end()}}function F(j,...$){if(e.apply(this,arguments)){var z=this.__zoom,R=dt(j.changedTouches?j.changedTouches[0]:j,this),N=z.invert(R),b=z.k*(j.shiftKey?.5:2),P=n(h(m(z,b),R,N),t.apply(this,$),s);Wr(j),l>0?Ge(this).transition().duration(l).call(_,P,R,j):Ge(this).call(g.transform,P,R,j)}}function T(j,...$){if(e.apply(this,arguments)){var z=j.touches,R=z.length,N=k(this,$,j.changedTouches.length===R).event(j),b,P,O,A;for(zl(j),P=0;P"[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:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:r}", 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."},zo=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Dm=["Enter"," ","Escape"],Om={"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 Sr;(function(e){e.Strict="strict",e.Loose="loose"})(Sr||(Sr={}));var En;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(En||(En={}));var Io;(function(e){e.Partial="partial",e.Full="full"})(Io||(Io={}));const Fm={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var qt;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(qt||(qt={}));var ws;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(ws||(ws={}));var q;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(q||(q={}));const Kd={[q.Left]:q.Right,[q.Right]:q.Left,[q.Top]:q.Bottom,[q.Bottom]:q.Top};function Bm(e){return e===null?null:e?"valid":"invalid"}const Hm=e=>"id"in e&&"source"in e&&"target"in e,gS=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),rc=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Wo=(e,t=[0,0])=>{const{width:n,height:r}=Wt(e),o=e.origin??t,i=n*o[0],s=r*o[1];return{x:e.position.x-i,y:e.position.y-s}},yS=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,o)=>{const i=typeof o=="string";let s=!t.nodeLookup&&!i?o:void 0;t.nodeLookup&&(s=i?t.nodeLookup.get(o):rc(o)?o:t.nodeLookup.get(o.id));const l=s?_s(s,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Us(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Ys(n)},Uo=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(o=>{(t.filter===void 0||t.filter(o))&&(n=Us(n,_s(o)),r=!0)}),r?Ys(n):{x:0,y:0,width:0,height:0}},oc=(e,t,[n,r,o]=[0,0,1],i=!1,s=!1)=>{const l={...Xo(t,[n,r,o]),width:t.width/o,height:t.height/o},a=[];for(const c of e.values()){const{measured:f,selectable:d=!0,hidden:p=!1}=c;if(s&&!d||p)continue;const v=f.width??c.width??c.initialWidth??null,x=f.height??c.height??c.initialHeight??null,w=Lo(l,Nr(c)),S=(v??0)*(x??0),g=i&&w>0;(!c.internals.handleBounds||g||w>=S||c.dragging)&&a.push(c)}return a},vS=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function xS(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(o=>o.id)):null;return e.forEach(o=>{o.measured.width&&o.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!o.hidden)&&(!r||r.has(o.id))&&n.set(o.id,o)}),n}async function wS({nodes:e,width:t,height:n,panZoom:r,minZoom:o,maxZoom:i},s){if(e.size===0)return Promise.resolve(!0);const l=xS(e,s),a=Uo(l),c=ic(a,t,n,(s==null?void 0:s.minZoom)??o,(s==null?void 0:s.maxZoom)??i,(s==null?void 0:s.padding)??.1);return await r.setViewport(c,{duration:s==null?void 0:s.duration,ease:s==null?void 0:s.ease,interpolate:s==null?void 0:s.interpolate}),Promise.resolve(!0)}function Vm({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:o,onError:i}){const s=n.get(e),l=s.parentId?n.get(s.parentId):void 0,{x:a,y:c}=l?l.internals.positionAbsolute:{x:0,y:0},f=s.origin??r;let d=s.extent||o;if(s.extent==="parent"&&!s.expandParent)if(!l)i==null||i("005",Mt.error005());else{const v=l.measured.width,x=l.measured.height;v&&x&&(d=[[a,c],[a+v,c+x]])}else l&&Cr(s.extent)&&(d=[[s.extent[0][0]+a,s.extent[0][1]+c],[s.extent[1][0]+a,s.extent[1][1]+c]]);const p=Cr(d)?Ln(t,d,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&(i==null||i("015",Mt.error015())),{position:{x:p.x-a+(s.measured.width??0)*f[0],y:p.y-c+(s.measured.height??0)*f[1]},positionAbsolute:p}}async function _S({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:o}){const i=new Set(e.map(p=>p.id)),s=[];for(const p of n){if(p.deletable===!1)continue;const v=i.has(p.id),x=!v&&p.parentId&&s.find(w=>w.id===p.parentId);(v||x)&&s.push(p)}const l=new Set(t.map(p=>p.id)),a=r.filter(p=>p.deletable!==!1),f=vS(s,a);for(const p of a)l.has(p.id)&&!f.find(x=>x.id===p.id)&&f.push(p);if(!o)return{edges:f,nodes:s};const d=await o({nodes:s,edges:f});return typeof d=="boolean"?d?{edges:f,nodes:s}:{edges:[],nodes:[]}:d}const kr=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Ln=(e={x:0,y:0},t,n)=>({x:kr(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:kr(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function Wm(e,t,n){const{width:r,height:o}=Wt(n),{x:i,y:s}=n.internals.positionAbsolute;return Ln(e,[[i,s],[i+r,s+o]],t)}const Qd=(e,t,n)=>en?-kr(Math.abs(e-n),1,t)/t:0,Um=(e,t,n=15,r=40)=>{const o=Qd(e.x,r,t.width-r)*n,i=Qd(e.y,r,t.height-r)*n;return[o,i]},Us=(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)}),Ya=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Ys=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Nr=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=rc(e)?e.internals.positionAbsolute:Wo(e,t);return{x:n,y:r,width:((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},_s=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=rc(e)?e.internals.positionAbsolute:Wo(e,t);return{x:n,y:r,x2:n+(((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0),y2:r+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},Ym=(e,t)=>Ys(Us(Ya(e),Ya(t))),Lo=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},Zd=e=>pt(e.width)&&pt(e.height)&&pt(e.x)&&pt(e.y),pt=e=>!isNaN(e)&&isFinite(e),SS=(e,t)=>{},Yo=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Xo=({x:e,y:t},[n,r,o],i=!1,s=[1,1])=>{const l={x:(e-n)/o,y:(t-r)/o};return i?Yo(l,s):l},Ss=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r});function Hn(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 kS(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=Hn(e,n),o=Hn(e,t);return{top:r,right:o,bottom:r,left:o,x:o*2,y:r*2}}if(typeof e=="object"){const r=Hn(e.top??e.y??0,n),o=Hn(e.bottom??e.y??0,n),i=Hn(e.left??e.x??0,t),s=Hn(e.right??e.x??0,t);return{top:r,right:s,bottom:o,left:i,x:i+s,y:r+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function NS(e,t,n,r,o,i){const{x:s,y:l}=Ss(e,[t,n,r]),{x:a,y:c}=Ss({x:e.x+e.width,y:e.y+e.height},[t,n,r]),f=o-a,d=i-c;return{left:Math.floor(s),top:Math.floor(l),right:Math.floor(f),bottom:Math.floor(d)}}const ic=(e,t,n,r,o,i)=>{const s=kS(i,t,n),l=(t-s.x)/e.width,a=(n-s.y)/e.height,c=Math.min(l,a),f=kr(c,r,o),d=e.x+e.width/2,p=e.y+e.height/2,v=t/2-d*f,x=n/2-p*f,w=NS(e,v,x,f,t,n),S={left:Math.min(w.left-s.left,0),top:Math.min(w.top-s.top,0),right:Math.min(w.right-s.right,0),bottom:Math.min(w.bottom-s.bottom,0)};return{x:v-S.left+S.right,y:x-S.top+S.bottom,zoom:f}},Ao=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Cr(e){return e!=null&&e!=="parent"}function Wt(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function Xm(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function Gm(e,t={width:0,height:0},n,r,o){const i={...e},s=r.get(n);if(s){const l=s.origin||o;i.x+=s.internals.positionAbsolute.x-(t.width??0)*l[0],i.y+=s.internals.positionAbsolute.y-(t.height??0)*l[1]}return i}function qd(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function CS(){let e,t;return{promise:new Promise((r,o)=>{e=r,t=o}),resolve:e,reject:t}}function ES(e){return{...Om,...e||{}}}function uo(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:o}){const{x:i,y:s}=mt(e),l=Xo({x:i-((o==null?void 0:o.left)??0),y:s-((o==null?void 0:o.top)??0)},r),{x:a,y:c}=n?Yo(l,t):l;return{xSnapped:a,ySnapped:c,...l}}const sc=e=>({width:e.offsetWidth,height:e.offsetHeight}),Km=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},bS=["INPUT","SELECT","TEXTAREA"];function Qm(e){var r,o;const t=((o=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:o[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:bS.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Zm=e=>"clientX"in e,mt=(e,t)=>{var i,s;const n=Zm(e),r=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,o=n?e.clientY:(s=e.touches)==null?void 0:s[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:o-((t==null?void 0:t.top)??0)}},Jd=(e,t,n,r,o)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(s=>{const l=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:o,position:s.getAttribute("data-handlepos"),x:(l.left-n.left)/r,y:(l.top-n.top)/r,...sc(s)}})};function qm({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:o,sourceControlY:i,targetControlX:s,targetControlY:l}){const a=e*.125+o*.375+s*.375+n*.125,c=t*.125+i*.375+l*.375+r*.125,f=Math.abs(a-e),d=Math.abs(c-t);return[a,c,f,d]}function vi(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function ef({pos:e,x1:t,y1:n,x2:r,y2:o,c:i}){switch(e){case q.Left:return[t-vi(t-r,i),n];case q.Right:return[t+vi(r-t,i),n];case q.Top:return[t,n-vi(n-o,i)];case q.Bottom:return[t,n+vi(o-n,i)]}}function Jm({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:r,targetY:o,targetPosition:i=q.Top,curvature:s=.25}){const[l,a]=ef({pos:n,x1:e,y1:t,x2:r,y2:o,c:s}),[c,f]=ef({pos:i,x1:r,y1:o,x2:e,y2:t,c:s}),[d,p,v,x]=qm({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:l,sourceControlY:a,targetControlX:c,targetControlY:f});return[`M${e},${t} C${l},${a} ${c},${f} ${r},${o}`,d,p,v,x]}function eg({sourceX:e,sourceY:t,targetX:n,targetY:r}){const o=Math.abs(n-e)/2,i=n0}const TS=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,PS=(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)),zS=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||TS;let o;return Hm(e)?o={...e}:o={...e,id:r(e)},PS(o,t)?t:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,t.concat(o))};function tg({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[o,i,s,l]=eg({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,i,s,l]}const tf={[q.Left]:{x:-1,y:0},[q.Right]:{x:1,y:0},[q.Top]:{x:0,y:-1},[q.Bottom]:{x:0,y:1}},IS=({source:e,sourcePosition:t=q.Bottom,target:n})=>t===q.Left||t===q.Right?e.xMath.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function LS({source:e,sourcePosition:t=q.Bottom,target:n,targetPosition:r=q.Top,center:o,offset:i,stepPosition:s}){const l=tf[t],a=tf[r],c={x:e.x+l.x*i,y:e.y+l.y*i},f={x:n.x+a.x*i,y:n.y+a.y*i},d=IS({source:c,sourcePosition:t,target:f}),p=d.x!==0?"x":"y",v=d[p];let x=[],w,S;const g={x:0,y:0},m={x:0,y:0},[,,h,y]=eg({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[p]*a[p]===-1){p==="x"?(w=o.x??c.x+(f.x-c.x)*s,S=o.y??(c.y+f.y)/2):(w=o.x??(c.x+f.x)/2,S=o.y??c.y+(f.y-c.y)*s);const k=[{x:w,y:c.y},{x:w,y:f.y}],E=[{x:c.x,y:S},{x:f.x,y:S}];l[p]===v?x=p==="x"?k:E:x=p==="x"?E:k}else{const k=[{x:c.x,y:f.y}],E=[{x:f.x,y:c.y}];if(p==="x"?x=l.x===v?E:k:x=l.y===v?k:E,t===r){const L=Math.abs(e[p]-n[p]);if(L<=i){const B=Math.min(i-1,i-L);l[p]===v?g[p]=(c[p]>e[p]?-1:1)*B:m[p]=(f[p]>n[p]?-1:1)*B}}if(t!==r){const L=p==="x"?"y":"x",B=l[p]===a[L],j=c[L]>f[L],$=c[L]=T?(w=(M.x+I.x)/2,S=x[0].y):(w=x[0].x,S=(M.y+I.y)/2)}return[[e,{x:c.x+g.x,y:c.y+g.y},...x,{x:f.x+m.x,y:f.y+m.y},n],w,S,h,y]}function AS(e,t,n,r){const o=Math.min(nf(e,t)/2,nf(t,n)/2,r),{x:i,y:s}=t;if(e.x===i&&i===n.x||e.y===s&&s===n.y)return`L${i} ${s}`;if(e.y===s){const c=e.x{let y="";return h>0&&hn.id===t):e[0])||null}function Ga(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function RS(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:o}){const i=new Set;return e.reduce((s,l)=>([l.markerStart||r,l.markerEnd||o].forEach(a=>{if(a&&typeof a=="object"){const c=Ga(a,t);i.has(c)||(s.push({id:c,color:a.color||n,...a}),i.add(c))}}),s),[]).sort((s,l)=>s.id.localeCompare(l.id))}const ng=1e3,DS=10,lc={nodeOrigin:[0,0],nodeExtent:zo,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},OS={...lc,checkEquality:!0};function ac(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function FS(e,t,n){const r=ac(lc,n);for(const o of e.values())if(o.parentId)cc(o,e,t,r);else{const i=Wo(o,r.nodeOrigin),s=Cr(o.extent)?o.extent:r.nodeExtent,l=Ln(i,s,Wt(o));o.internals.positionAbsolute=l}}function BS(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],r=[];for(const o of e.handles){const i={id:o.id,width:o.width??1,height:o.height??1,nodeId:e.id,x:o.x,y:o.y,position:o.position,type:o.type};o.type==="source"?n.push(i):o.type==="target"&&r.push(i)}return{source:n,target:r}}function uc(e){return e==="manual"}function Ka(e,t,n,r={}){var c,f;const o=ac(OS,r),i={i:0},s=new Map(t),l=o!=null&&o.elevateNodesOnSelect&&!uc(o.zIndexMode)?ng:0;let a=e.length>0;t.clear(),n.clear();for(const d of e){let p=s.get(d.id);if(o.checkEquality&&d===(p==null?void 0:p.internals.userNode))t.set(d.id,p);else{const v=Wo(d,o.nodeOrigin),x=Cr(d.extent)?d.extent:o.nodeExtent,w=Ln(v,x,Wt(d));p={...o.defaults,...d,measured:{width:(c=d.measured)==null?void 0:c.width,height:(f=d.measured)==null?void 0:f.height},internals:{positionAbsolute:w,handleBounds:BS(d,p),z:rg(d,l,o.zIndexMode),userNode:d}},t.set(d.id,p)}(p.measured===void 0||p.measured.width===void 0||p.measured.height===void 0)&&!p.hidden&&(a=!1),d.parentId&&cc(p,t,n,r,i)}return a}function HS(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 cc(e,t,n,r,o){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:l,zIndexMode:a}=ac(lc,r),c=e.parentId,f=t.get(c);if(!f){console.warn(`Parent node ${c} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}HS(e,n),o&&!f.parentId&&f.internals.rootParentIndex===void 0&&a==="auto"&&(f.internals.rootParentIndex=++o.i,f.internals.z=f.internals.z+o.i*DS),o&&f.internals.rootParentIndex!==void 0&&(o.i=f.internals.rootParentIndex);const d=i&&!uc(a)?ng:0,{x:p,y:v,z:x}=VS(e,f,s,l,d,a),{positionAbsolute:w}=e.internals,S=p!==w.x||v!==w.y;(S||x!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:S?{x:p,y:v}:w,z:x}})}function rg(e,t,n){const r=pt(e.zIndex)?e.zIndex:0;return uc(n)?r:r+(e.selected?t:0)}function VS(e,t,n,r,o,i){const{x:s,y:l}=t.internals.positionAbsolute,a=Wt(e),c=Wo(e,n),f=Cr(e.extent)?Ln(c,e.extent,a):c;let d=Ln({x:s+f.x,y:l+f.y},r,a);e.extent==="parent"&&(d=Wm(d,a,t));const p=rg(e,o,i),v=t.internals.z??0;return{x:d.x,y:d.y,z:v>=p?v+1:p}}function dc(e,t,n,r=[0,0]){var s;const o=[],i=new Map;for(const l of e){const a=t.get(l.parentId);if(!a)continue;const c=((s=i.get(l.parentId))==null?void 0:s.expandedRect)??Nr(a),f=Ym(c,l.rect);i.set(l.parentId,{expandedRect:f,parent:a})}return i.size>0&&i.forEach(({expandedRect:l,parent:a},c)=>{var h;const f=a.internals.positionAbsolute,d=Wt(a),p=a.origin??r,v=l.x0||x>0||g||m)&&(o.push({id:c,type:"position",position:{x:a.position.x-v+g,y:a.position.y-x+m}}),(h=n.get(c))==null||h.forEach(y=>{e.some(_=>_.id===y.id)||o.push({id:y.id,type:"position",position:{x:y.position.x+v,y:y.position.y+x}})})),(d.width0){const v=dc(p,t,n,o);c.push(...v)}return{changes:c,updatedInternals:a}}async function US({delta:e,panZoom:t,transform:n,translateExtent:r,width:o,height:i}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[o,i]],r),l=!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2]);return Promise.resolve(l)}function lf(e,t,n,r,o,i){let s=o;const l=r.get(s)||new Map;r.set(s,l.set(n,t)),s=`${o}-${e}`;const a=r.get(s)||new Map;if(r.set(s,a.set(n,t)),i){s=`${o}-${e}-${i}`;const c=r.get(s)||new Map;r.set(s,c.set(n,t))}}function og(e,t,n){e.clear(),t.clear();for(const r of n){const{source:o,target:i,sourceHandle:s=null,targetHandle:l=null}=r,a={edgeId:r.id,source:o,target:i,sourceHandle:s,targetHandle:l},c=`${o}-${s}--${i}-${l}`,f=`${i}-${l}--${o}-${s}`;lf("source",a,f,e,o,s),lf("target",a,c,e,i,l),t.set(r.id,r)}}function ig(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:ig(n,t):!1}function af(e,t,n){var o;let r=e;do{if((o=r==null?void 0:r.matches)!=null&&o.call(r,t))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function YS(e,t,n,r){const o=new Map;for(const[i,s]of e)if((s.selected||s.id===r)&&(!s.parentId||!ig(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const l=e.get(i);l&&o.set(i,{id:i,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 o}function Il({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var s,l,a;const o=[];for(const[c,f]of t){const d=(s=n.get(c))==null?void 0:s.internals.userNode;d&&o.push({...d,position:f.position,dragging:r})}if(!e)return[o[0],o];const i=(l=n.get(e))==null?void 0:l.internals.userNode;return[i?{...i,position:((a=t.get(e))==null?void 0:a.position)||i.position,dragging:r}:o[0],o]}function XS({dragItems:e,snapGrid:t,x:n,y:r}){const o=e.values().next().value;if(!o)return null;const i={x:n-o.distance.x,y:r-o.distance.y},s=Yo(i,t);return{x:s.x-i.x,y:s.y-i.y}}function GS({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:o}){let i={x:null,y:null},s=0,l=new Map,a=!1,c={x:0,y:0},f=null,d=!1,p=null,v=!1,x=!1,w=null;function S({noDragClassName:m,handleSelector:h,domNode:y,isSelectable:_,nodeId:k,nodeClickDistance:E=0}){p=Ge(y);function M({x:L,y:B}){const{nodeLookup:j,nodeExtent:$,snapGrid:z,snapToGrid:R,nodeOrigin:N,onNodeDrag:b,onSelectionDrag:P,onError:O,updateNodePositions:A}=t();i={x:L,y:B};let H=!1;const W=l.size>1,D=W&&$?Ya(Uo(l)):null,U=W&&R?XS({dragItems:l,snapGrid:z,x:L,y:B}):null;for(const[X,V]of l){if(!j.has(X))continue;let G={x:L-V.distance.x,y:B-V.distance.y};R&&(G=U?{x:Math.round(G.x+U.x),y:Math.round(G.y+U.y)}:Yo(G,z));let ne=null;if(W&&$&&!V.extent&&D){const{positionAbsolute:J}=V.internals,re=J.x-D.x+$[0][0],te=J.x+V.measured.width-D.x2+$[1][0],K=J.y-D.y+$[0][1],ve=J.y+V.measured.height-D.y2+$[1][1];ne=[[re,K],[te,ve]]}const{position:ee,positionAbsolute:Z}=Vm({nodeId:X,nextPosition:G,nodeLookup:j,nodeExtent:ne||$,nodeOrigin:N,onError:O});H=H||V.position.x!==ee.x||V.position.y!==ee.y,V.position=ee,V.internals.positionAbsolute=Z}if(x=x||H,!!H&&(A(l,!0),w&&(r||b||!k&&P))){const[X,V]=Il({nodeId:k,dragItems:l,nodeLookup:j});r==null||r(w,l,X,V),b==null||b(w,X,V),k||P==null||P(w,V)}}async function I(){if(!f)return;const{transform:L,panBy:B,autoPanSpeed:j,autoPanOnNodeDrag:$}=t();if(!$){a=!1,cancelAnimationFrame(s);return}const[z,R]=Um(c,f,j);(z!==0||R!==0)&&(i.x=(i.x??0)-z/L[2],i.y=(i.y??0)-R/L[2],await B({x:z,y:R})&&M(i)),s=requestAnimationFrame(I)}function F(L){var W;const{nodeLookup:B,multiSelectionActive:j,nodesDraggable:$,transform:z,snapGrid:R,snapToGrid:N,selectNodesOnDrag:b,onNodeDragStart:P,onSelectionDragStart:O,unselectNodesAndEdges:A}=t();d=!0,(!b||!_)&&!j&&k&&((W=B.get(k))!=null&&W.selected||A()),_&&b&&k&&(e==null||e(k));const H=uo(L.sourceEvent,{transform:z,snapGrid:R,snapToGrid:N,containerBounds:f});if(i=H,l=YS(B,$,H,k),l.size>0&&(n||P||!k&&O)){const[D,U]=Il({nodeId:k,dragItems:l,nodeLookup:B});n==null||n(L.sourceEvent,l,D,U),P==null||P(L.sourceEvent,D,U),k||O==null||O(L.sourceEvent,U)}}const T=Sm().clickDistance(E).on("start",L=>{const{domNode:B,nodeDragThreshold:j,transform:$,snapGrid:z,snapToGrid:R}=t();f=(B==null?void 0:B.getBoundingClientRect())||null,v=!1,x=!1,w=L.sourceEvent,j===0&&F(L),i=uo(L.sourceEvent,{transform:$,snapGrid:z,snapToGrid:R,containerBounds:f}),c=mt(L.sourceEvent,f)}).on("drag",L=>{const{autoPanOnNodeDrag:B,transform:j,snapGrid:$,snapToGrid:z,nodeDragThreshold:R,nodeLookup:N}=t(),b=uo(L.sourceEvent,{transform:j,snapGrid:$,snapToGrid:z,containerBounds:f});if(w=L.sourceEvent,(L.sourceEvent.type==="touchmove"&&L.sourceEvent.touches.length>1||k&&!N.has(k))&&(v=!0),!v){if(!a&&B&&d&&(a=!0,I()),!d){const P=mt(L.sourceEvent,f),O=P.x-c.x,A=P.y-c.y;Math.sqrt(O*O+A*A)>R&&F(L)}(i.x!==b.xSnapped||i.y!==b.ySnapped)&&l&&d&&(c=mt(L.sourceEvent,f),M(b))}}).on("end",L=>{if(!(!d||v)&&(a=!1,d=!1,cancelAnimationFrame(s),l.size>0)){const{nodeLookup:B,updateNodePositions:j,onNodeDragStop:$,onSelectionDragStop:z}=t();if(x&&(j(l,!1),x=!1),o||$||!k&&z){const[R,N]=Il({nodeId:k,dragItems:l,nodeLookup:B,dragging:!1});o==null||o(L.sourceEvent,l,R,N),$==null||$(L.sourceEvent,R,N),k||z==null||z(L.sourceEvent,N)}}}).filter(L=>{const B=L.target;return!L.button&&(!m||!af(B,`.${m}`,y))&&(!h||af(B,h,y))});p.call(T)}function g(){p==null||p.on(".drag",null)}return{update:S,destroy:g}}function KS(e,t,n){const r=[],o={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())Lo(o,Nr(i))>0&&r.push(i);return r}const QS=250;function ZS(e,t,n,r){var l,a;let o=[],i=1/0;const s=KS(e,n,t+QS);for(const c of s){const f=[...((l=c.internals.handleBounds)==null?void 0:l.source)??[],...((a=c.internals.handleBounds)==null?void 0:a.target)??[]];for(const d of f){if(r.nodeId===d.nodeId&&r.type===d.type&&r.id===d.id)continue;const{x:p,y:v}=An(c,d,d.position,!0),x=Math.sqrt(Math.pow(p-e.x,2)+Math.pow(v-e.y,2));x>t||(x1){const c=r.type==="source"?"target":"source";return o.find(f=>f.type===c)??o[0]}return o[0]}function sg(e,t,n,r,o,i=!1){var c,f,d;const s=r.get(e);if(!s)return null;const l=o==="strict"?(c=s.internals.handleBounds)==null?void 0:c[t]:[...((f=s.internals.handleBounds)==null?void 0:f.source)??[],...((d=s.internals.handleBounds)==null?void 0:d.target)??[]],a=(n?l==null?void 0:l.find(p=>p.id===n):l==null?void 0:l[0])??null;return a&&i?{...a,...An(s,a,a.position,!0)}:a}function lg(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function qS(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const ag=()=>!0;function JS(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:o,edgeUpdaterType:i,isTarget:s,domNode:l,nodeLookup:a,lib:c,autoPanOnConnect:f,flowId:d,panBy:p,cancelConnection:v,onConnectStart:x,onConnect:w,onConnectEnd:S,isValidConnection:g=ag,onReconnectEnd:m,updateConnection:h,getTransform:y,getFromHandle:_,autoPanSpeed:k,dragThreshold:E=1,handleDomNode:M}){const I=Km(e.target);let F=0,T;const{x:L,y:B}=mt(e),j=lg(i,M),$=l==null?void 0:l.getBoundingClientRect();let z=!1;if(!$||!j)return;const R=sg(o,j,r,a,t);if(!R)return;let N=mt(e,$),b=!1,P=null,O=!1,A=null;function H(){if(!f||!$)return;const[ee,Z]=Um(N,$,k);p({x:ee,y:Z}),F=requestAnimationFrame(H)}const W={...R,nodeId:o,type:j,position:R.position},D=a.get(o);let X={inProgress:!0,isValid:null,from:An(D,W,q.Left,!0),fromHandle:W,fromPosition:W.position,fromNode:D,to:N,toHandle:null,toPosition:Kd[W.position],toNode:null,pointer:N};function V(){z=!0,h(X),x==null||x(e,{nodeId:o,handleId:r,handleType:j})}E===0&&V();function G(ee){if(!z){const{x:ve,y:Pe}=mt(ee),ke=ve-L,ze=Pe-B;if(!(ke*ke+ze*ze>E*E))return;V()}if(!_()||!W){ne(ee);return}const Z=y();N=mt(ee,$),T=ZS(Xo(N,Z,!1,[1,1]),n,a,W),b||(H(),b=!0);const J=ug(ee,{handle:T,connectionMode:t,fromNodeId:o,fromHandleId:r,fromType:s?"target":"source",isValidConnection:g,doc:I,lib:c,flowId:d,nodeLookup:a});A=J.handleDomNode,P=J.connection,O=qS(!!T,J.isValid);const re=a.get(o),te=re?An(re,W,q.Left,!0):X.from,K={...X,from:te,isValid:O,to:J.toHandle&&O?Ss({x:J.toHandle.x,y:J.toHandle.y},Z):N,toHandle:J.toHandle,toPosition:O&&J.toHandle?J.toHandle.position:Kd[W.position],toNode:J.toHandle?a.get(J.toHandle.nodeId):null,pointer:N};h(K),X=K}function ne(ee){if(!("touches"in ee&&ee.touches.length>0)){if(z){(T||A)&&P&&O&&(w==null||w(P));const{inProgress:Z,...J}=X,re={...J,toPosition:X.toHandle?X.toPosition:null};S==null||S(ee,re),i&&(m==null||m(ee,re))}v(),cancelAnimationFrame(F),b=!1,O=!1,P=null,A=null,I.removeEventListener("mousemove",G),I.removeEventListener("mouseup",ne),I.removeEventListener("touchmove",G),I.removeEventListener("touchend",ne)}}I.addEventListener("mousemove",G),I.addEventListener("mouseup",ne),I.addEventListener("touchmove",G),I.addEventListener("touchend",ne)}function ug(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:o,fromType:i,doc:s,lib:l,flowId:a,isValidConnection:c=ag,nodeLookup:f}){const d=i==="target",p=t?s.querySelector(`.${l}-flow__handle[data-id="${a}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:v,y:x}=mt(e),w=s.elementFromPoint(v,x),S=w!=null&&w.classList.contains(`${l}-flow__handle`)?w:p,g={handleDomNode:S,isValid:!1,connection:null,toHandle:null};if(S){const m=lg(void 0,S),h=S.getAttribute("data-nodeid"),y=S.getAttribute("data-handleid"),_=S.classList.contains("connectable"),k=S.classList.contains("connectableend");if(!h||!m)return g;const E={source:d?h:r,sourceHandle:d?y:o,target:d?r:h,targetHandle:d?o:y};g.connection=E;const I=_&&k&&(n===Sr.Strict?d&&m==="source"||!d&&m==="target":h!==r||y!==o);g.isValid=I&&c(E),g.toHandle=sg(h,m,y,f,n,!0)}return g}const Qa={onPointerDown:JS,isValid:ug};function ek({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const o=Ge(e);function i({translateExtent:l,width:a,height:c,zoomStep:f=1,pannable:d=!0,zoomable:p=!0,inversePan:v=!1}){const x=h=>{if(h.sourceEvent.type!=="wheel"||!t)return;const y=n(),_=h.sourceEvent.ctrlKey&&Ao()?10:1,k=-h.sourceEvent.deltaY*(h.sourceEvent.deltaMode===1?.05:h.sourceEvent.deltaMode?1:.002)*f,E=y[2]*Math.pow(2,k*_);t.scaleTo(E)};let w=[0,0];const S=h=>{(h.sourceEvent.type==="mousedown"||h.sourceEvent.type==="touchstart")&&(w=[h.sourceEvent.clientX??h.sourceEvent.touches[0].clientX,h.sourceEvent.clientY??h.sourceEvent.touches[0].clientY])},g=h=>{const y=n();if(h.sourceEvent.type!=="mousemove"&&h.sourceEvent.type!=="touchmove"||!t)return;const _=[h.sourceEvent.clientX??h.sourceEvent.touches[0].clientX,h.sourceEvent.clientY??h.sourceEvent.touches[0].clientY],k=[_[0]-w[0],_[1]-w[1]];w=_;const E=r()*Math.max(y[2],Math.log(y[2]))*(v?-1:1),M={x:y[0]-k[0]*E,y:y[1]-k[1]*E},I=[[0,0],[a,c]];t.setViewportConstrained({x:M.x,y:M.y,zoom:y[2]},I,l)},m=Rm().on("start",S).on("zoom",d?g:null).on("zoom.wheel",p?x:null);o.call(m,{})}function s(){o.on("zoom",null)}return{update:i,destroy:s,pointer:dt}}const Xs=e=>({x:e.x,y:e.y,zoom:e.k}),Ll=({x:e,y:t,zoom:n})=>Ws.translate(e,t).scale(n),rr=(e,t)=>e.target.closest(`.${t}`),cg=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),tk=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Al=(e,t=0,n=tk,r=()=>{})=>{const o=typeof t=="number"&&t>0;return o||r(),o?e.transition().duration(t).ease(n).on("end",r):e},dg=e=>{const t=e.ctrlKey&&Ao()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function nk({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:o,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:l,onPanZoom:a,onPanZoomEnd:c}){return f=>{if(rr(f,t))return f.ctrlKey&&f.preventDefault(),!1;f.preventDefault(),f.stopImmediatePropagation();const d=n.property("__zoom").k||1;if(f.ctrlKey&&s){const S=dt(f),g=dg(f),m=d*Math.pow(2,g);r.scaleTo(n,m,S,f);return}const p=f.deltaMode===1?20:1;let v=o===En.Vertical?0:f.deltaX*p,x=o===En.Horizontal?0:f.deltaY*p;!Ao()&&f.shiftKey&&o!==En.Vertical&&(v=f.deltaY*p,x=0),r.translateBy(n,-(v/d)*i,-(x/d)*i,{internal:!0});const w=Xs(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(a==null||a(f,w),e.panScrollTimeout=setTimeout(()=>{c==null||c(f,w),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l==null||l(f,w))}}function rk({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,o){const i=r.type==="wheel",s=!t&&i&&!r.ctrlKey,l=rr(r,e);if(r.ctrlKey&&i&&l&&r.preventDefault(),s||l)return null;r.preventDefault(),n.call(this,r,o)}}function ok({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var i,s,l;if((i=r.sourceEvent)!=null&&i.internal)return;const o=Xs(r.transform);e.mouseButton=((s=r.sourceEvent)==null?void 0:s.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=o,((l=r.sourceEvent)==null?void 0:l.type)==="mousedown"&&t(!0),n&&(n==null||n(r.sourceEvent,o))}}function ik({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:o}){return i=>{var s,l;e.usedRightMouseButton=!!(n&&cg(t,e.mouseButton??0)),(s=i.sourceEvent)!=null&&s.sync||r([i.transform.x,i.transform.y,i.transform.k]),o&&!((l=i.sourceEvent)!=null&&l.internal)&&(o==null||o(i.sourceEvent,Xs(i.transform)))}}function sk({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:o,onPaneContextMenu:i}){return s=>{var l;if(!((l=s.sourceEvent)!=null&&l.internal)&&(e.isZoomingOrPanning=!1,i&&cg(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,r(!1),o)){const a=Xs(s.transform);e.prevViewport=a,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o==null||o(s.sourceEvent,a)},n?150:0)}}}function lk({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:o,zoomOnDoubleClick:i,userSelectionActive:s,noWheelClassName:l,noPanClassName:a,lib:c,connectionInProgress:f}){return d=>{var S;const p=e||t,v=n&&d.ctrlKey,x=d.type==="wheel";if(d.button===1&&d.type==="mousedown"&&(rr(d,`${c}-flow__node`)||rr(d,`${c}-flow__edge`)))return!0;if(!r&&!p&&!o&&!i&&!n||s||f&&!x||rr(d,l)&&x||rr(d,a)&&(!x||o&&x&&!e)||!n&&d.ctrlKey&&x)return!1;if(!n&&d.type==="touchstart"&&((S=d.touches)==null?void 0:S.length)>1)return d.preventDefault(),!1;if(!p&&!o&&!v&&x||!r&&(d.type==="mousedown"||d.type==="touchstart")||Array.isArray(r)&&!r.includes(d.button)&&d.type==="mousedown")return!1;const w=Array.isArray(r)&&r.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||x)&&w}}function ak({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:o,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:l,onDraggingChange:a}){const c={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},f=e.getBoundingClientRect(),d=Rm().scaleExtent([t,n]).translateExtent(r),p=Ge(e).call(d);m({x:o.x,y:o.y,zoom:kr(o.zoom,t,n)},[[0,0],[f.width,f.height]],r);const v=p.on("wheel.zoom"),x=p.on("dblclick.zoom");d.wheelDelta(dg);function w(T,L){return p?new Promise(B=>{d==null||d.interpolate((L==null?void 0:L.interpolate)==="linear"?ao:Oi).transform(Al(p,L==null?void 0:L.duration,L==null?void 0:L.ease,()=>B(!0)),T)}):Promise.resolve(!1)}function S({noWheelClassName:T,noPanClassName:L,onPaneContextMenu:B,userSelectionActive:j,panOnScroll:$,panOnDrag:z,panOnScrollMode:R,panOnScrollSpeed:N,preventScrolling:b,zoomOnPinch:P,zoomOnScroll:O,zoomOnDoubleClick:A,zoomActivationKeyPressed:H,lib:W,onTransformChange:D,connectionInProgress:U,paneClickDistance:X,selectionOnDrag:V}){j&&!c.isZoomingOrPanning&&g();const G=$&&!H&&!j;d.clickDistance(V?1/0:!pt(X)||X<0?0:X);const ne=G?nk({zoomPanValues:c,noWheelClassName:T,d3Selection:p,d3Zoom:d,panOnScrollMode:R,panOnScrollSpeed:N,zoomOnPinch:P,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:l}):rk({noWheelClassName:T,preventScrolling:b,d3ZoomHandler:v});if(p.on("wheel.zoom",ne,{passive:!1}),!j){const Z=ok({zoomPanValues:c,onDraggingChange:a,onPanZoomStart:s});d.on("start",Z);const J=ik({zoomPanValues:c,panOnDrag:z,onPaneContextMenu:!!B,onPanZoom:i,onTransformChange:D});d.on("zoom",J);const re=sk({zoomPanValues:c,panOnDrag:z,panOnScroll:$,onPaneContextMenu:B,onPanZoomEnd:l,onDraggingChange:a});d.on("end",re)}const ee=lk({zoomActivationKeyPressed:H,panOnDrag:z,zoomOnScroll:O,panOnScroll:$,zoomOnDoubleClick:A,zoomOnPinch:P,userSelectionActive:j,noPanClassName:L,noWheelClassName:T,lib:W,connectionInProgress:U});d.filter(ee),A?p.on("dblclick.zoom",x):p.on("dblclick.zoom",null)}function g(){d.on("zoom",null)}async function m(T,L,B){const j=Ll(T),$=d==null?void 0:d.constrain()(j,L,B);return $&&await w($),new Promise(z=>z($))}async function h(T,L){const B=Ll(T);return await w(B,L),new Promise(j=>j(B))}function y(T){if(p){const L=Ll(T),B=p.property("__zoom");(B.k!==T.zoom||B.x!==T.x||B.y!==T.y)&&(d==null||d.transform(p,L,null,{sync:!0}))}}function _(){const T=p?$m(p.node()):{x:0,y:0,k:1};return{x:T.x,y:T.y,zoom:T.k}}function k(T,L){return p?new Promise(B=>{d==null||d.interpolate((L==null?void 0:L.interpolate)==="linear"?ao:Oi).scaleTo(Al(p,L==null?void 0:L.duration,L==null?void 0:L.ease,()=>B(!0)),T)}):Promise.resolve(!1)}function E(T,L){return p?new Promise(B=>{d==null||d.interpolate((L==null?void 0:L.interpolate)==="linear"?ao:Oi).scaleBy(Al(p,L==null?void 0:L.duration,L==null?void 0:L.ease,()=>B(!0)),T)}):Promise.resolve(!1)}function M(T){d==null||d.scaleExtent(T)}function I(T){d==null||d.translateExtent(T)}function F(T){const L=!pt(T)||T<0?0:T;d==null||d.clickDistance(L)}return{update:S,destroy:g,setViewport:h,setViewportConstrained:m,getViewport:_,scaleTo:k,scaleBy:E,setScaleExtent:M,setTranslateExtent:I,syncViewport:y,setClickDistance:F}}var $n;(function(e){e.Line="line",e.Handle="handle"})($n||($n={}));const uk=["top-left","top-right","bottom-left","bottom-right"],ck=["top","right","bottom","left"];function dk({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:o,affectsY:i}){const s=e-t,l=n-r,a=[s>0?1:s<0?-1:0,l>0?1:l<0?-1:0];return s&&o&&(a[0]=a[0]*-1),l&&i&&(a[1]=a[1]*-1),a}function uf(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),o=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:o}}function Yt(e,t){return Math.max(0,t-e)}function Xt(e,t){return Math.max(0,e-t)}function xi(e,t,n){return Math.max(0,t-e,e-n)}function cf(e,t){return e?!t:t}function fk(e,t,n,r,o,i,s,l){let{affectsX:a,affectsY:c}=t;const{isHorizontal:f,isVertical:d}=t,p=f&&d,{xSnapped:v,ySnapped:x}=n,{minWidth:w,maxWidth:S,minHeight:g,maxHeight:m}=r,{x:h,y,width:_,height:k,aspectRatio:E}=e;let M=Math.floor(f?v-e.pointerX:0),I=Math.floor(d?x-e.pointerY:0);const F=_+(a?-M:M),T=k+(c?-I:I),L=-i[0]*_,B=-i[1]*k;let j=xi(F,w,S),$=xi(T,g,m);if(s){let N=0,b=0;a&&M<0?N=Yt(h+M+L,s[0][0]):!a&&M>0&&(N=Xt(h+F+L,s[1][0])),c&&I<0?b=Yt(y+I+B,s[0][1]):!c&&I>0&&(b=Xt(y+T+B,s[1][1])),j=Math.max(j,N),$=Math.max($,b)}if(l){let N=0,b=0;a&&M>0?N=Xt(h+M,l[0][0]):!a&&M<0&&(N=Yt(h+F,l[1][0])),c&&I>0?b=Xt(y+I,l[0][1]):!c&&I<0&&(b=Yt(y+T,l[1][1])),j=Math.max(j,N),$=Math.max($,b)}if(o){if(f){const N=xi(F/E,g,m)*E;if(j=Math.max(j,N),s){let b=0;!a&&!c||a&&!c&&p?b=Xt(y+B+F/E,s[1][1])*E:b=Yt(y+B+(a?M:-M)/E,s[0][1])*E,j=Math.max(j,b)}if(l){let b=0;!a&&!c||a&&!c&&p?b=Yt(y+F/E,l[1][1])*E:b=Xt(y+(a?M:-M)/E,l[0][1])*E,j=Math.max(j,b)}}if(d){const N=xi(T*E,w,S)/E;if($=Math.max($,N),s){let b=0;!a&&!c||c&&!a&&p?b=Xt(h+T*E+L,s[1][0])/E:b=Yt(h+(c?I:-I)*E+L,s[0][0])/E,$=Math.max($,b)}if(l){let b=0;!a&&!c||c&&!a&&p?b=Yt(h+T*E,l[1][0])/E:b=Xt(h+(c?I:-I)*E,l[0][0])/E,$=Math.max($,b)}}}I=I+(I<0?$:-$),M=M+(M<0?j:-j),o&&(p?F>T*E?I=(cf(a,c)?-M:M)/E:M=(cf(a,c)?-I:I)*E:f?(I=M/E,c=a):(M=I*E,a=c));const z=a?h+M:h,R=c?y+I:y;return{width:_+(a?-M:M),height:k+(c?-I:I),x:i[0]*M*(a?-1:1)+z,y:i[1]*I*(c?-1:1)+R}}const fg={width:0,height:0,x:0,y:0},hk={...fg,pointerX:0,pointerY:0,aspectRatio:1};function pk(e){return[[0,0],[e.measured.width,e.measured.height]]}function mk(e,t,n){const r=t.position.x+e.position.x,o=t.position.y+e.position.y,i=e.measured.width??0,s=e.measured.height??0,l=n[0]*i,a=n[1]*s;return[[r-l,o-a],[r+i-l,o+s-a]]}function gk({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:o}){const i=Ge(e);let s={controlDirection:uf("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:c,boundaries:f,keepAspectRatio:d,resizeDirection:p,onResizeStart:v,onResize:x,onResizeEnd:w,shouldResize:S}){let g={...fg},m={...hk};s={boundaries:f,resizeDirection:p,keepAspectRatio:d,controlDirection:uf(c)};let h,y=null,_=[],k,E,M,I=!1;const F=Sm().on("start",T=>{const{nodeLookup:L,transform:B,snapGrid:j,snapToGrid:$,nodeOrigin:z,paneDomNode:R}=n();if(h=L.get(t),!h)return;y=(R==null?void 0:R.getBoundingClientRect())??null;const{xSnapped:N,ySnapped:b}=uo(T.sourceEvent,{transform:B,snapGrid:j,snapToGrid:$,containerBounds:y});g={width:h.measured.width??0,height:h.measured.height??0,x:h.position.x??0,y:h.position.y??0},m={...g,pointerX:N,pointerY:b,aspectRatio:g.width/g.height},k=void 0,h.parentId&&(h.extent==="parent"||h.expandParent)&&(k=L.get(h.parentId),E=k&&h.extent==="parent"?pk(k):void 0),_=[],M=void 0;for(const[P,O]of L)if(O.parentId===t&&(_.push({id:P,position:{...O.position},extent:O.extent}),O.extent==="parent"||O.expandParent)){const A=mk(O,h,O.origin??z);M?M=[[Math.min(A[0][0],M[0][0]),Math.min(A[0][1],M[0][1])],[Math.max(A[1][0],M[1][0]),Math.max(A[1][1],M[1][1])]]:M=A}v==null||v(T,{...g})}).on("drag",T=>{const{transform:L,snapGrid:B,snapToGrid:j,nodeOrigin:$}=n(),z=uo(T.sourceEvent,{transform:L,snapGrid:B,snapToGrid:j,containerBounds:y}),R=[];if(!h)return;const{x:N,y:b,width:P,height:O}=g,A={},H=h.origin??$,{width:W,height:D,x:U,y:X}=fk(m,s.controlDirection,z,s.boundaries,s.keepAspectRatio,H,E,M),V=W!==P,G=D!==O,ne=U!==N&&V,ee=X!==b&&G;if(!ne&&!ee&&!V&&!G)return;if((ne||ee||H[0]===1||H[1]===1)&&(A.x=ne?U:g.x,A.y=ee?X:g.y,g.x=A.x,g.y=A.y,_.length>0)){const te=U-N,K=X-b;for(const ve of _)ve.position={x:ve.position.x-te+H[0]*(W-P),y:ve.position.y-K+H[1]*(D-O)},R.push(ve)}if((V||G)&&(A.width=V&&(!s.resizeDirection||s.resizeDirection==="horizontal")?W:g.width,A.height=G&&(!s.resizeDirection||s.resizeDirection==="vertical")?D:g.height,g.width=A.width,g.height=A.height),k&&h.expandParent){const te=H[0]*(A.width??0);A.x&&A.x{I&&(w==null||w(T,{...g}),o==null||o({...g}),I=!1)});i.call(F)}function a(){i.on(".drag",null)}return{update:l,destroy:a}}var hg={exports:{}},pg={},mg={exports:{}},gg={};/** + * @license React + * use-sync-external-store-shim.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Er=C;function yk(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var vk=typeof Object.is=="function"?Object.is:yk,xk=Er.useState,wk=Er.useEffect,_k=Er.useLayoutEffect,Sk=Er.useDebugValue;function kk(e,t){var n=t(),r=xk({inst:{value:n,getSnapshot:t}}),o=r[0].inst,i=r[1];return _k(function(){o.value=n,o.getSnapshot=t,$l(o)&&i({inst:o})},[e,n,t]),wk(function(){return $l(o)&&i({inst:o}),e(function(){$l(o)&&i({inst:o})})},[e]),Sk(n),n}function $l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!vk(e,n)}catch{return!0}}function Nk(e,t){return t()}var Ck=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Nk:kk;gg.useSyncExternalStore=Er.useSyncExternalStore!==void 0?Er.useSyncExternalStore:Ck;mg.exports=gg;var Ek=mg.exports;/** + * @license React + * use-sync-external-store-shim/with-selector.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Gs=C,bk=Ek;function jk(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Mk=typeof Object.is=="function"?Object.is:jk,Tk=bk.useSyncExternalStore,Pk=Gs.useRef,zk=Gs.useEffect,Ik=Gs.useMemo,Lk=Gs.useDebugValue;pg.useSyncExternalStoreWithSelector=function(e,t,n,r,o){var i=Pk(null);if(i.current===null){var s={hasValue:!1,value:null};i.current=s}else s=i.current;i=Ik(function(){function a(v){if(!c){if(c=!0,f=v,v=r(v),o!==void 0&&s.hasValue){var x=s.value;if(o(x,v))return d=x}return d=v}if(x=d,Mk(f,v))return x;var w=r(v);return o!==void 0&&o(x,w)?(f=v,x):(f=v,d=w)}var c=!1,f,d,p=n===void 0?null:n;return[function(){return a(t())},p===null?void 0:function(){return a(p())}]},[t,n,r,o]);var l=Tk(e,i[0],i[1]);return zk(function(){s.hasValue=!0,s.value=l},[l]),Lk(l),l};hg.exports=pg;var Ak=hg.exports;const $k=Gf(Ak),Rk={},df=e=>{let t;const n=new Set,r=(f,d)=>{const p=typeof f=="function"?f(t):f;if(!Object.is(p,t)){const v=t;t=d??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(x=>x(t,v))}},o=()=>t,a={setState:r,getState:o,getInitialState:()=>c,subscribe:f=>(n.add(f),()=>n.delete(f)),destroy:()=>{(Rk?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},c=t=e(r,o,a);return a},Dk=e=>e?df(e):df,{useDebugValue:Ok}=ih,{useSyncExternalStoreWithSelector:Fk}=$k,Bk=e=>e;function yg(e,t=Bk,n){const r=Fk(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Ok(r),r}const ff=(e,t)=>{const n=Dk(e),r=(o,i=t)=>yg(n,o,i);return Object.assign(r,n),r},Hk=(e,t)=>e?ff(e,t):ff;function he(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,o]of e)if(!Object.is(o,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}const Ks=C.createContext(null),Vk=Ks.Provider,vg=Mt.error001();function ie(e,t){const n=C.useContext(Ks);if(n===null)throw new Error(vg);return yg(n,e,t)}function pe(){const e=C.useContext(Ks);if(e===null)throw new Error(vg);return C.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const hf={display:"none"},Wk={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},xg="react-flow__node-desc",wg="react-flow__edge-desc",Uk="react-flow__aria-live",Yk=e=>e.ariaLiveMessage,Xk=e=>e.ariaLabelConfig;function Gk({rfId:e}){const t=ie(Yk);return u.jsx("div",{id:`${Uk}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Wk,children:t})}function Kk({rfId:e,disableKeyboardA11y:t}){const n=ie(Xk);return u.jsxs(u.Fragment,{children:[u.jsx("div",{id:`${xg}-${e}`,style:hf,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),u.jsx("div",{id:`${wg}-${e}`,style:hf,children:n["edge.a11yDescription.default"]}),!t&&u.jsx(Gk,{rfId:e})]})}const Qs=C.forwardRef(({position:e="top-left",children:t,className:n,style:r,...o},i)=>{const s=`${e}`.split("-");return u.jsx("div",{className:Se(["react-flow__panel",n,...s]),style:r,ref:i,...o,children:t})});Qs.displayName="Panel";function Qk({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:u.jsx(Qs,{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:u.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Zk=e=>{const t=[],n=[];for(const[,r]of e.nodeLookup)r.selected&&t.push(r.internals.userNode);for(const[,r]of e.edgeLookup)r.selected&&n.push(r);return{selectedNodes:t,selectedEdges:n}},wi=e=>e.id;function qk(e,t){return he(e.selectedNodes.map(wi),t.selectedNodes.map(wi))&&he(e.selectedEdges.map(wi),t.selectedEdges.map(wi))}function Jk({onSelectionChange:e}){const t=pe(),{selectedNodes:n,selectedEdges:r}=ie(Zk,qk);return C.useEffect(()=>{const o={nodes:n,edges:r};e==null||e(o),t.getState().onSelectionChangeHandlers.forEach(i=>i(o))},[n,r,e]),null}const e2=e=>!!e.onSelectionChangeHandlers;function t2({onSelectionChange:e}){const t=ie(e2);return e||t?u.jsx(Jk,{onSelectionChange:e}):null}const _g=[0,0],n2={x:0,y:0,zoom:1},r2=["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"],pf=[...r2,"rfId"],o2=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}),mf={translateExtent:zo,nodeOrigin:_g,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function i2(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:o,setTranslateExtent:i,setNodeExtent:s,reset:l,setDefaultNodesAndEdges:a}=ie(o2,he),c=pe();C.useEffect(()=>(a(e.defaultNodes,e.defaultEdges),()=>{f.current=mf,l()}),[]);const f=C.useRef(mf);return C.useEffect(()=>{for(const d of pf){const p=e[d],v=f.current[d];p!==v&&(typeof e[d]>"u"||(d==="nodes"?t(p):d==="edges"?n(p):d==="minZoom"?r(p):d==="maxZoom"?o(p):d==="translateExtent"?i(p):d==="nodeExtent"?s(p):d==="ariaLabelConfig"?c.setState({ariaLabelConfig:ES(p)}):d==="fitView"?c.setState({fitViewQueued:p}):d==="fitViewOptions"?c.setState({fitViewOptions:p}):c.setState({[d]:p})))}f.current=e},pf.map(d=>e[d])),null}function gf(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function s2(e){var r;const[t,n]=C.useState(e==="system"?null:e);return C.useEffect(()=>{if(e!=="system"){n(e);return}const o=gf(),i=()=>n(o!=null&&o.matches?"dark":"light");return i(),o==null||o.addEventListener("change",i),()=>{o==null||o.removeEventListener("change",i)}},[e]),t!==null?t:(r=gf())!=null&&r.matches?"dark":"light"}const yf=typeof document<"u"?document:null;function $o(e=null,t={target:yf,actInsideInputWithModifier:!0}){const[n,r]=C.useState(!1),o=C.useRef(!1),i=C.useRef(new Set([])),[s,l]=C.useMemo(()=>{if(e!==null){const c=(Array.isArray(e)?e:[e]).filter(d=>typeof d=="string").map(d=>d.replace("+",` +`).replace(` + +`,` ++`).split(` +`)),f=c.reduce((d,p)=>d.concat(...p),[]);return[c,f]}return[[],[]]},[e]);return C.useEffect(()=>{const a=(t==null?void 0:t.target)??yf,c=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const f=v=>{var S,g;if(o.current=v.ctrlKey||v.metaKey||v.shiftKey||v.altKey,(!o.current||o.current&&!c)&&Qm(v))return!1;const w=xf(v.code,l);if(i.current.add(v[w]),vf(s,i.current,!1)){const m=((g=(S=v.composedPath)==null?void 0:S.call(v))==null?void 0:g[0])||v.target,h=(m==null?void 0:m.nodeName)==="BUTTON"||(m==null?void 0:m.nodeName)==="A";t.preventDefault!==!1&&(o.current||!h)&&v.preventDefault(),r(!0)}},d=v=>{const x=xf(v.code,l);vf(s,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(v[x]),v.key==="Meta"&&i.current.clear(),o.current=!1},p=()=>{i.current.clear(),r(!1)};return a==null||a.addEventListener("keydown",f),a==null||a.addEventListener("keyup",d),window.addEventListener("blur",p),window.addEventListener("contextmenu",p),()=>{a==null||a.removeEventListener("keydown",f),a==null||a.removeEventListener("keyup",d),window.removeEventListener("blur",p),window.removeEventListener("contextmenu",p)}}},[e,r]),n}function vf(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(o=>t.has(o)))}function xf(e,t){return t.includes(e)?"code":"key"}const l2=()=>{const e=pe();return C.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,{duration:n==null?void 0:n.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,o,i],panZoom:s}=e.getState();return s?(await s.setViewport({x:t.x??r,y:t.y??o,zoom:t.zoom??i},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:o,minZoom:i,maxZoom:s,panZoom:l}=e.getState(),a=ic(t,r,o,i,s,(n==null?void 0:n.padding)??.1);return l?(await l.setViewport(a,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:o,snapToGrid:i,domNode:s}=e.getState();if(!s)return t;const{x:l,y:a}=s.getBoundingClientRect(),c={x:t.x-l,y:t.y-a},f=n.snapGrid??o,d=n.snapToGrid??i;return Xo(c,r,d,f)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:o,y:i}=r.getBoundingClientRect(),s=Ss(t,n);return{x:s.x+o,y:s.y+i}}}),[])};function Sg(e,t){const n=[],r=new Map,o=[];for(const i of e)if(i.type==="add"){o.push(i);continue}else if(i.type==="remove"||i.type==="replace")r.set(i.id,[i]);else{const s=r.get(i.id);s?s.push(i):r.set(i.id,[i])}for(const i of t){const s=r.get(i.id);if(!s){n.push(i);continue}if(s[0].type==="remove")continue;if(s[0].type==="replace"){n.push({...s[0].item});continue}const l={...i};for(const a of s)a2(a,l);n.push(l)}return o.length&&o.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function a2(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function kg(e,t){return Sg(e,t)}function Ng(e,t){return Sg(e,t)}function vn(e,t){return{id:e,type:"select",selected:t}}function or(e,t=new Set,n=!1){const r=[];for(const[o,i]of e){const s=t.has(o);!(i.selected===void 0&&!s)&&i.selected!==s&&(n&&(i.selected=s),r.push(vn(i.id,s)))}return r}function wf({items:e=[],lookup:t}){var o;const n=[],r=new Map(e.map(i=>[i.id,i]));for(const[i,s]of e.entries()){const l=t.get(s.id),a=((o=l==null?void 0:l.internals)==null?void 0:o.userNode)??l;a!==void 0&&a!==s&&n.push({id:s.id,item:s,type:"replace"}),a===void 0&&n.push({item:s,type:"add",index:i})}for(const[i]of t)r.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function _f(e){return{id:e.id,type:"remove"}}const Sf=e=>gS(e),u2=e=>Hm(e);function Cg(e){return C.forwardRef(e)}const c2=typeof window<"u"?C.useLayoutEffect:C.useEffect;function kf(e){const[t,n]=C.useState(BigInt(0)),[r]=C.useState(()=>d2(()=>n(o=>o+BigInt(1))));return c2(()=>{const o=r.get();o.length&&(e(o),r.reset())},[t]),r}function d2(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const Eg=C.createContext(null);function f2({children:e}){const t=pe(),n=C.useCallback(l=>{const{nodes:a=[],setNodes:c,hasDefaultNodes:f,onNodesChange:d,nodeLookup:p,fitViewQueued:v,onNodesChangeMiddlewareMap:x}=t.getState();let w=a;for(const g of l)w=typeof g=="function"?g(w):g;let S=wf({items:w,lookup:p});for(const g of x.values())S=g(S);f&&c(w),S.length>0?d==null||d(S):v&&window.requestAnimationFrame(()=>{const{fitViewQueued:g,nodes:m,setNodes:h}=t.getState();g&&h(m)})},[]),r=kf(n),o=C.useCallback(l=>{const{edges:a=[],setEdges:c,hasDefaultEdges:f,onEdgesChange:d,edgeLookup:p}=t.getState();let v=a;for(const x of l)v=typeof x=="function"?x(v):x;f?c(v):d&&d(wf({items:v,lookup:p}))},[]),i=kf(o),s=C.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return u.jsx(Eg.Provider,{value:s,children:e})}function h2(){const e=C.useContext(Eg);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const p2=e=>!!e.panZoom;function Zs(){const e=l2(),t=pe(),n=h2(),r=ie(p2),o=C.useMemo(()=>{const i=d=>t.getState().nodeLookup.get(d),s=d=>{n.nodeQueue.push(d)},l=d=>{n.edgeQueue.push(d)},a=d=>{var g,m;const{nodeLookup:p,nodeOrigin:v}=t.getState(),x=Sf(d)?d:p.get(d.id),w=x.parentId?Gm(x.position,x.measured,x.parentId,p,v):x.position,S={...x,position:w,width:((g=x.measured)==null?void 0:g.width)??x.width,height:((m=x.measured)==null?void 0:m.height)??x.height};return Nr(S)},c=(d,p,v={replace:!1})=>{s(x=>x.map(w=>{if(w.id===d){const S=typeof p=="function"?p(w):p;return v.replace&&Sf(S)?S:{...w,...S}}return w}))},f=(d,p,v={replace:!1})=>{l(x=>x.map(w=>{if(w.id===d){const S=typeof p=="function"?p(w):p;return v.replace&&u2(S)?S:{...w,...S}}return w}))};return{getNodes:()=>t.getState().nodes.map(d=>({...d})),getNode:d=>{var p;return(p=i(d))==null?void 0:p.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:d=[]}=t.getState();return d.map(p=>({...p}))},getEdge:d=>t.getState().edgeLookup.get(d),setNodes:s,setEdges:l,addNodes:d=>{const p=Array.isArray(d)?d:[d];n.nodeQueue.push(v=>[...v,...p])},addEdges:d=>{const p=Array.isArray(d)?d:[d];n.edgeQueue.push(v=>[...v,...p])},toObject:()=>{const{nodes:d=[],edges:p=[],transform:v}=t.getState(),[x,w,S]=v;return{nodes:d.map(g=>({...g})),edges:p.map(g=>({...g})),viewport:{x,y:w,zoom:S}}},deleteElements:async({nodes:d=[],edges:p=[]})=>{const{nodes:v,edges:x,onNodesDelete:w,onEdgesDelete:S,triggerNodeChanges:g,triggerEdgeChanges:m,onDelete:h,onBeforeDelete:y}=t.getState(),{nodes:_,edges:k}=await _S({nodesToRemove:d,edgesToRemove:p,nodes:v,edges:x,onBeforeDelete:y}),E=k.length>0,M=_.length>0;if(E){const I=k.map(_f);S==null||S(k),m(I)}if(M){const I=_.map(_f);w==null||w(_),g(I)}return(M||E)&&(h==null||h({nodes:_,edges:k})),{deletedNodes:_,deletedEdges:k}},getIntersectingNodes:(d,p=!0,v)=>{const x=Zd(d),w=x?d:a(d),S=v!==void 0;return w?(v||t.getState().nodes).filter(g=>{const m=t.getState().nodeLookup.get(g.id);if(m&&!x&&(g.id===d.id||!m.internals.positionAbsolute))return!1;const h=Nr(S?g:m),y=Lo(h,w);return p&&y>0||y>=h.width*h.height||y>=w.width*w.height}):[]},isNodeIntersecting:(d,p,v=!0)=>{const w=Zd(d)?d:a(d);if(!w)return!1;const S=Lo(w,p);return v&&S>0||S>=p.width*p.height||S>=w.width*w.height},updateNode:c,updateNodeData:(d,p,v={replace:!1})=>{c(d,x=>{const w=typeof p=="function"?p(x):p;return v.replace?{...x,data:w}:{...x,data:{...x.data,...w}}},v)},updateEdge:f,updateEdgeData:(d,p,v={replace:!1})=>{f(d,x=>{const w=typeof p=="function"?p(x):p;return v.replace?{...x,data:w}:{...x,data:{...x.data,...w}}},v)},getNodesBounds:d=>{const{nodeLookup:p,nodeOrigin:v}=t.getState();return yS(d,{nodeLookup:p,nodeOrigin:v})},getHandleConnections:({type:d,id:p,nodeId:v})=>{var x;return Array.from(((x=t.getState().connectionLookup.get(`${v}-${d}${p?`-${p}`:""}`))==null?void 0:x.values())??[])},getNodeConnections:({type:d,handleId:p,nodeId:v})=>{var x;return Array.from(((x=t.getState().connectionLookup.get(`${v}${d?p?`-${d}-${p}`:`-${d}`:""}`))==null?void 0:x.values())??[])},fitView:async d=>{const p=t.getState().fitViewResolver??CS();return t.setState({fitViewQueued:!0,fitViewOptions:d,fitViewResolver:p}),n.nodeQueue.push(v=>[...v]),p.promise}}},[]);return C.useMemo(()=>({...o,...e,viewportInitialized:r}),[r])}const Nf=e=>e.selected,m2=typeof window<"u"?window:void 0;function g2({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=pe(),{deleteElements:r}=Zs(),o=$o(e,{actInsideInputWithModifier:!1}),i=$o(t,{target:m2});C.useEffect(()=>{if(o){const{edges:s,nodes:l}=n.getState();r({nodes:l.filter(Nf),edges:s.filter(Nf)}),n.setState({nodesSelectionActive:!1})}},[o]),C.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function y2(e){const t=pe();C.useEffect(()=>{const n=()=>{var o,i,s,l;if(!e.current||!(((i=(o=e.current).checkVisibility)==null?void 0:i.call(o))??!0))return!1;const r=sc(e.current);(r.height===0||r.width===0)&&((l=(s=t.getState()).onError)==null||l.call(s,"004",Mt.error004())),t.setState({width:r.width||500,height:r.height||500})};if(e.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(e.current),()=>{window.removeEventListener("resize",n),r&&e.current&&r.unobserve(e.current)}}},[])}const qs={position:"absolute",width:"100%",height:"100%",top:0,left:0},v2=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function x2({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:o=.5,panOnScrollMode:i=En.Free,zoomOnDoubleClick:s=!0,panOnDrag:l=!0,defaultViewport:a,translateExtent:c,minZoom:f,maxZoom:d,zoomActivationKeyCode:p,preventScrolling:v=!0,children:x,noWheelClassName:w,noPanClassName:S,onViewportChange:g,isControlledViewport:m,paneClickDistance:h,selectionOnDrag:y}){const _=pe(),k=C.useRef(null),{userSelectionActive:E,lib:M,connectionInProgress:I}=ie(v2,he),F=$o(p),T=C.useRef();y2(k);const L=C.useCallback(B=>{g==null||g({x:B[0],y:B[1],zoom:B[2]}),m||_.setState({transform:B})},[g,m]);return C.useEffect(()=>{if(k.current){T.current=ak({domNode:k.current,minZoom:f,maxZoom:d,translateExtent:c,viewport:a,onDraggingChange:z=>_.setState(R=>R.paneDragging===z?R:{paneDragging:z}),onPanZoomStart:(z,R)=>{const{onViewportChangeStart:N,onMoveStart:b}=_.getState();b==null||b(z,R),N==null||N(R)},onPanZoom:(z,R)=>{const{onViewportChange:N,onMove:b}=_.getState();b==null||b(z,R),N==null||N(R)},onPanZoomEnd:(z,R)=>{const{onViewportChangeEnd:N,onMoveEnd:b}=_.getState();b==null||b(z,R),N==null||N(R)}});const{x:B,y:j,zoom:$}=T.current.getViewport();return _.setState({panZoom:T.current,transform:[B,j,$],domNode:k.current.closest(".react-flow")}),()=>{var z;(z=T.current)==null||z.destroy()}}},[]),C.useEffect(()=>{var B;(B=T.current)==null||B.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:o,panOnScrollMode:i,zoomOnDoubleClick:s,panOnDrag:l,zoomActivationKeyPressed:F,preventScrolling:v,noPanClassName:S,userSelectionActive:E,noWheelClassName:w,lib:M,onTransformChange:L,connectionInProgress:I,selectionOnDrag:y,paneClickDistance:h})},[e,t,n,r,o,i,s,l,F,v,S,E,w,M,L,I,y,h]),u.jsx("div",{className:"react-flow__renderer",ref:k,style:qs,children:x})}const w2=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function _2(){const{userSelectionActive:e,userSelectionRect:t}=ie(w2,he);return e&&t?u.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const Rl=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},S2=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function k2({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Io.Full,panOnDrag:r,paneClickDistance:o,selectionOnDrag:i,onSelectionStart:s,onSelectionEnd:l,onPaneClick:a,onPaneContextMenu:c,onPaneScroll:f,onPaneMouseEnter:d,onPaneMouseMove:p,onPaneMouseLeave:v,children:x}){const w=pe(),{userSelectionActive:S,elementsSelectable:g,dragging:m,connectionInProgress:h}=ie(S2,he),y=g&&(e||S),_=C.useRef(null),k=C.useRef(),E=C.useRef(new Set),M=C.useRef(new Set),I=C.useRef(!1),F=N=>{if(I.current||h){I.current=!1;return}a==null||a(N),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},T=N=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){N.preventDefault();return}c==null||c(N)},L=f?N=>f(N):void 0,B=N=>{I.current&&(N.stopPropagation(),I.current=!1)},j=N=>{var D,U;const{domNode:b}=w.getState();if(k.current=b==null?void 0:b.getBoundingClientRect(),!k.current)return;const P=N.target===_.current;if(!P&&!!N.target.closest(".nokey")||!e||!(i&&P||t)||N.button!==0||!N.isPrimary)return;(U=(D=N.target)==null?void 0:D.setPointerCapture)==null||U.call(D,N.pointerId),I.current=!1;const{x:H,y:W}=mt(N.nativeEvent,k.current);w.setState({userSelectionRect:{width:0,height:0,startX:H,startY:W,x:H,y:W}}),P||(N.stopPropagation(),N.preventDefault())},$=N=>{const{userSelectionRect:b,transform:P,nodeLookup:O,edgeLookup:A,connectionLookup:H,triggerNodeChanges:W,triggerEdgeChanges:D,defaultEdgeOptions:U,resetSelectedElements:X}=w.getState();if(!k.current||!b)return;const{x:V,y:G}=mt(N.nativeEvent,k.current),{startX:ne,startY:ee}=b;if(!I.current){const K=t?0:o;if(Math.hypot(V-ne,G-ee)<=K)return;X(),s==null||s(N)}I.current=!0;const Z={startX:ne,startY:ee,x:VK.id)),M.current=new Set;const te=(U==null?void 0:U.selectable)??!0;for(const K of E.current){const ve=H.get(K);if(ve)for(const{edgeId:Pe}of ve.values()){const ke=A.get(Pe);ke&&(ke.selectable??te)&&M.current.add(Pe)}}if(!qd(J,E.current)){const K=or(O,E.current,!0);W(K)}if(!qd(re,M.current)){const K=or(A,M.current);D(K)}w.setState({userSelectionRect:Z,userSelectionActive:!0,nodesSelectionActive:!1})},z=N=>{var b,P;N.button===0&&((P=(b=N.target)==null?void 0:b.releasePointerCapture)==null||P.call(b,N.pointerId),!S&&N.target===_.current&&w.getState().userSelectionRect&&(F==null||F(N)),w.setState({userSelectionActive:!1,userSelectionRect:null}),I.current&&(l==null||l(N),w.setState({nodesSelectionActive:E.current.size>0})))},R=r===!0||Array.isArray(r)&&r.includes(0);return u.jsxs("div",{className:Se(["react-flow__pane",{draggable:R,dragging:m,selection:e}]),onClick:y?void 0:Rl(F,_),onContextMenu:Rl(T,_),onWheel:Rl(L,_),onPointerEnter:y?void 0:d,onPointerMove:y?$:p,onPointerUp:y?z:void 0,onPointerDownCapture:y?j:void 0,onClickCapture:y?B:void 0,onPointerLeave:v,ref:_,style:qs,children:[x,u.jsx(_2,{})]})}function Za({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:o,unselectNodesAndEdges:i,multiSelectionActive:s,nodeLookup:l,onError:a}=t.getState(),c=l.get(e);if(!c){a==null||a("012",Mt.error012(e));return}t.setState({nodesSelectionActive:!1}),c.selected?(n||c.selected&&s)&&(i({nodes:[c],edges:[]}),requestAnimationFrame(()=>{var f;return(f=r==null?void 0:r.current)==null?void 0:f.blur()})):o([e])}function bg({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:o,isSelectable:i,nodeClickDistance:s}){const l=pe(),[a,c]=C.useState(!1),f=C.useRef();return C.useEffect(()=>{f.current=GS({getStoreItems:()=>l.getState(),onNodeMouseDown:d=>{Za({id:d,store:l,nodeRef:e})},onDragStart:()=>{c(!0)},onDragStop:()=>{c(!1)}})},[]),C.useEffect(()=>{if(!(t||!e.current||!f.current))return f.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:i,nodeId:o,nodeClickDistance:s}),()=>{var d;(d=f.current)==null||d.destroy()}},[n,r,t,i,e,o,s]),a}const N2=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function jg(){const e=pe();return C.useCallback(n=>{const{nodeExtent:r,snapToGrid:o,snapGrid:i,nodesDraggable:s,onError:l,updateNodePositions:a,nodeLookup:c,nodeOrigin:f}=e.getState(),d=new Map,p=N2(s),v=o?i[0]:5,x=o?i[1]:5,w=n.direction.x*v*n.factor,S=n.direction.y*x*n.factor;for(const[,g]of c){if(!p(g))continue;let m={x:g.internals.positionAbsolute.x+w,y:g.internals.positionAbsolute.y+S};o&&(m=Yo(m,i));const{position:h,positionAbsolute:y}=Vm({nodeId:g.id,nextPosition:m,nodeLookup:c,nodeExtent:r,nodeOrigin:f,onError:l});g.position=h,g.internals.positionAbsolute=y,d.set(g.id,g)}a(d)},[])}const fc=C.createContext(null),C2=fc.Provider;fc.Consumer;const Mg=()=>C.useContext(fc),E2=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),b2=(e,t,n)=>r=>{const{connectionClickStartHandle:o,connectionMode:i,connection:s}=r,{fromHandle:l,toHandle:a,isValid:c}=s,f=(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.id)===t&&(a==null?void 0:a.type)===n;return{connectingFrom:(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.id)===t&&(l==null?void 0:l.type)===n,connectingTo:f,clickConnecting:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.id)===t&&(o==null?void 0:o.type)===n,isPossibleEndHandle:i===Sr.Strict?(l==null?void 0:l.type)!==n:e!==(l==null?void 0:l.nodeId)||t!==(l==null?void 0:l.id),connectionInProcess:!!l,clickConnectionInProcess:!!o,valid:f&&c}};function j2({type:e="source",position:t=q.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:o=!0,isConnectableEnd:i=!0,id:s,onConnect:l,children:a,className:c,onMouseDown:f,onTouchStart:d,...p},v){var $,z;const x=s||null,w=e==="target",S=pe(),g=Mg(),{connectOnClick:m,noPanClassName:h,rfId:y}=ie(E2,he),{connectingFrom:_,connectingTo:k,clickConnecting:E,isPossibleEndHandle:M,connectionInProcess:I,clickConnectionInProcess:F,valid:T}=ie(b2(g,x,e),he);g||(z=($=S.getState()).onError)==null||z.call($,"010",Mt.error010());const L=R=>{const{defaultEdgeOptions:N,onConnect:b,hasDefaultEdges:P}=S.getState(),O={...N,...R};if(P){const{edges:A,setEdges:H}=S.getState();H(zS(O,A))}b==null||b(O),l==null||l(O)},B=R=>{if(!g)return;const N=Zm(R.nativeEvent);if(o&&(N&&R.button===0||!N)){const b=S.getState();Qa.onPointerDown(R.nativeEvent,{handleDomNode:R.currentTarget,autoPanOnConnect:b.autoPanOnConnect,connectionMode:b.connectionMode,connectionRadius:b.connectionRadius,domNode:b.domNode,nodeLookup:b.nodeLookup,lib:b.lib,isTarget:w,handleId:x,nodeId:g,flowId:b.rfId,panBy:b.panBy,cancelConnection:b.cancelConnection,onConnectStart:b.onConnectStart,onConnectEnd:(...P)=>{var O,A;return(A=(O=S.getState()).onConnectEnd)==null?void 0:A.call(O,...P)},updateConnection:b.updateConnection,onConnect:L,isValidConnection:n||((...P)=>{var O,A;return((A=(O=S.getState()).isValidConnection)==null?void 0:A.call(O,...P))??!0}),getTransform:()=>S.getState().transform,getFromHandle:()=>S.getState().connection.fromHandle,autoPanSpeed:b.autoPanSpeed,dragThreshold:b.connectionDragThreshold})}N?f==null||f(R):d==null||d(R)},j=R=>{const{onClickConnectStart:N,onClickConnectEnd:b,connectionClickStartHandle:P,connectionMode:O,isValidConnection:A,lib:H,rfId:W,nodeLookup:D,connection:U}=S.getState();if(!g||!P&&!o)return;if(!P){N==null||N(R.nativeEvent,{nodeId:g,handleId:x,handleType:e}),S.setState({connectionClickStartHandle:{nodeId:g,type:e,id:x}});return}const X=Km(R.target),V=n||A,{connection:G,isValid:ne}=Qa.isValid(R.nativeEvent,{handle:{nodeId:g,id:x,type:e},connectionMode:O,fromNodeId:P.nodeId,fromHandleId:P.id||null,fromType:P.type,isValidConnection:V,flowId:W,doc:X,lib:H,nodeLookup:D});ne&&G&&L(G);const ee=structuredClone(U);delete ee.inProgress,ee.toPosition=ee.toHandle?ee.toHandle.position:null,b==null||b(R,ee),S.setState({connectionClickStartHandle:null})};return u.jsx("div",{"data-handleid":x,"data-nodeid":g,"data-handlepos":t,"data-id":`${y}-${g}-${x}-${e}`,className:Se(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",h,c,{source:!w,target:w,connectable:r,connectablestart:o,connectableend:i,clickconnecting:E,connectingfrom:_,connectingto:k,valid:T,connectionindicator:r&&(!I||M)&&(I||F?i:o)}]),onMouseDown:B,onTouchStart:B,onClick:m?j:void 0,ref:v,...p,children:a})}const br=C.memo(Cg(j2));function M2({data:e,isConnectable:t,sourcePosition:n=q.Bottom}){return u.jsxs(u.Fragment,{children:[e==null?void 0:e.label,u.jsx(br,{type:"source",position:n,isConnectable:t})]})}function T2({data:e,isConnectable:t,targetPosition:n=q.Top,sourcePosition:r=q.Bottom}){return u.jsxs(u.Fragment,{children:[u.jsx(br,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,u.jsx(br,{type:"source",position:r,isConnectable:t})]})}function P2(){return null}function z2({data:e,isConnectable:t,targetPosition:n=q.Top}){return u.jsxs(u.Fragment,{children:[u.jsx(br,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const ks={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Cf={input:M2,default:T2,output:z2,group:P2};function I2(e){var t,n,r,o;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((r=e.style)==null?void 0:r.width),height:e.height??((o=e.style)==null?void 0:o.height)}}const L2=e=>{const{width:t,height:n,x:r,y:o}=Uo(e.nodeLookup,{filter:i=>!!i.selected});return{width:pt(t)?t:null,height:pt(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${o}px)`}};function A2({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=pe(),{width:o,height:i,transformString:s,userSelectionActive:l}=ie(L2,he),a=jg(),c=C.useRef(null);C.useEffect(()=>{var v;n||(v=c.current)==null||v.focus({preventScroll:!0})},[n]);const f=!l&&o!==null&&i!==null;if(bg({nodeRef:c,disabled:!f}),!f)return null;const d=e?v=>{const x=r.getState().nodes.filter(w=>w.selected);e(v,x)}:void 0,p=v=>{Object.prototype.hasOwnProperty.call(ks,v.key)&&(v.preventDefault(),a({direction:ks[v.key],factor:v.shiftKey?4:1}))};return u.jsx("div",{className:Se(["react-flow__nodesselection","react-flow__container",t]),style:{transform:s},children:u.jsx("div",{ref:c,className:"react-flow__nodesselection-rect",onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:p,style:{width:o,height:i}})})}const Ef=typeof window<"u"?window:void 0,$2=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Tg({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:s,paneClickDistance:l,deleteKeyCode:a,selectionKeyCode:c,selectionOnDrag:f,selectionMode:d,onSelectionStart:p,onSelectionEnd:v,multiSelectionKeyCode:x,panActivationKeyCode:w,zoomActivationKeyCode:S,elementsSelectable:g,zoomOnScroll:m,zoomOnPinch:h,panOnScroll:y,panOnScrollSpeed:_,panOnScrollMode:k,zoomOnDoubleClick:E,panOnDrag:M,defaultViewport:I,translateExtent:F,minZoom:T,maxZoom:L,preventScrolling:B,onSelectionContextMenu:j,noWheelClassName:$,noPanClassName:z,disableKeyboardA11y:R,onViewportChange:N,isControlledViewport:b}){const{nodesSelectionActive:P,userSelectionActive:O}=ie($2,he),A=$o(c,{target:Ef}),H=$o(w,{target:Ef}),W=H||M,D=H||y,U=f&&W!==!0,X=A||O||U;return g2({deleteKeyCode:a,multiSelectionKeyCode:x}),u.jsx(x2,{onPaneContextMenu:i,elementsSelectable:g,zoomOnScroll:m,zoomOnPinch:h,panOnScroll:D,panOnScrollSpeed:_,panOnScrollMode:k,zoomOnDoubleClick:E,panOnDrag:!A&&W,defaultViewport:I,translateExtent:F,minZoom:T,maxZoom:L,zoomActivationKeyCode:S,preventScrolling:B,noWheelClassName:$,noPanClassName:z,onViewportChange:N,isControlledViewport:b,paneClickDistance:l,selectionOnDrag:U,children:u.jsxs(k2,{onSelectionStart:p,onSelectionEnd:v,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:s,panOnDrag:W,isSelecting:!!X,selectionMode:d,selectionKeyPressed:A,paneClickDistance:l,selectionOnDrag:U,children:[e,P&&u.jsx(A2,{onSelectionContextMenu:j,noPanClassName:z,disableKeyboardA11y:R})]})})}Tg.displayName="FlowRenderer";const R2=C.memo(Tg),D2=e=>t=>e?oc(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function O2(e){return ie(C.useCallback(D2(e),[e]),he)}const F2=e=>e.updateNodeInternals;function B2(){const e=ie(F2),[t]=C.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(o=>{const i=o.target.getAttribute("data-id");r.set(i,{id:i,nodeElement:o.target,force:!0})}),e(r)}));return C.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function H2({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const o=pe(),i=C.useRef(null),s=C.useRef(null),l=C.useRef(e.sourcePosition),a=C.useRef(e.targetPosition),c=C.useRef(t),f=n&&!!e.internals.handleBounds;return C.useEffect(()=>{i.current&&!e.hidden&&(!f||s.current!==i.current)&&(s.current&&(r==null||r.unobserve(s.current)),r==null||r.observe(i.current),s.current=i.current)},[f,e.hidden]),C.useEffect(()=>()=>{s.current&&(r==null||r.unobserve(s.current),s.current=null)},[]),C.useEffect(()=>{if(i.current){const d=c.current!==t,p=l.current!==e.sourcePosition,v=a.current!==e.targetPosition;(d||p||v)&&(c.current=t,l.current=e.sourcePosition,a.current=e.targetPosition,o.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function V2({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:o,onContextMenu:i,onDoubleClick:s,nodesDraggable:l,elementsSelectable:a,nodesConnectable:c,nodesFocusable:f,resizeObserver:d,noDragClassName:p,noPanClassName:v,disableKeyboardA11y:x,rfId:w,nodeTypes:S,nodeClickDistance:g,onError:m}){const{node:h,internals:y,isParent:_}=ie(V=>{const G=V.nodeLookup.get(e),ne=V.parentLookup.has(e);return{node:G,internals:G.internals,isParent:ne}},he);let k=h.type||"default",E=(S==null?void 0:S[k])||Cf[k];E===void 0&&(m==null||m("003",Mt.error003(k)),k="default",E=(S==null?void 0:S.default)||Cf.default);const M=!!(h.draggable||l&&typeof h.draggable>"u"),I=!!(h.selectable||a&&typeof h.selectable>"u"),F=!!(h.connectable||c&&typeof h.connectable>"u"),T=!!(h.focusable||f&&typeof h.focusable>"u"),L=pe(),B=Xm(h),j=H2({node:h,nodeType:k,hasDimensions:B,resizeObserver:d}),$=bg({nodeRef:j,disabled:h.hidden||!M,noDragClassName:p,handleSelector:h.dragHandle,nodeId:e,isSelectable:I,nodeClickDistance:g}),z=jg();if(h.hidden)return null;const R=Wt(h),N=I2(h),b=I||M||t||n||r||o,P=n?V=>n(V,{...y.userNode}):void 0,O=r?V=>r(V,{...y.userNode}):void 0,A=o?V=>o(V,{...y.userNode}):void 0,H=i?V=>i(V,{...y.userNode}):void 0,W=s?V=>s(V,{...y.userNode}):void 0,D=V=>{const{selectNodesOnDrag:G,nodeDragThreshold:ne}=L.getState();I&&(!G||!M||ne>0)&&Za({id:e,store:L,nodeRef:j}),t&&t(V,{...y.userNode})},U=V=>{if(!(Qm(V.nativeEvent)||x)){if(Dm.includes(V.key)&&I){const G=V.key==="Escape";Za({id:e,store:L,unselect:G,nodeRef:j})}else if(M&&h.selected&&Object.prototype.hasOwnProperty.call(ks,V.key)){V.preventDefault();const{ariaLabelConfig:G}=L.getState();L.setState({ariaLiveMessage:G["node.a11yDescription.ariaLiveMessage"]({direction:V.key.replace("Arrow","").toLowerCase(),x:~~y.positionAbsolute.x,y:~~y.positionAbsolute.y})}),z({direction:ks[V.key],factor:V.shiftKey?4:1})}}},X=()=>{var re;if(x||!((re=j.current)!=null&&re.matches(":focus-visible")))return;const{transform:V,width:G,height:ne,autoPanOnNodeFocus:ee,setCenter:Z}=L.getState();if(!ee)return;oc(new Map([[e,h]]),{x:0,y:0,width:G,height:ne},V,!0).length>0||Z(h.position.x+R.width/2,h.position.y+R.height/2,{zoom:V[2]})};return u.jsx("div",{className:Se(["react-flow__node",`react-flow__node-${k}`,{[v]:M},h.className,{selected:h.selected,selectable:I,parent:_,draggable:M,dragging:$}]),ref:j,style:{zIndex:y.z,transform:`translate(${y.positionAbsolute.x}px,${y.positionAbsolute.y}px)`,pointerEvents:b?"all":"none",visibility:B?"visible":"hidden",...h.style,...N},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:P,onMouseMove:O,onMouseLeave:A,onContextMenu:H,onClick:D,onDoubleClick:W,onKeyDown:T?U:void 0,tabIndex:T?0:void 0,onFocus:T?X:void 0,role:h.ariaRole??(T?"group":void 0),"aria-roledescription":"node","aria-describedby":x?void 0:`${xg}-${w}`,"aria-label":h.ariaLabel,...h.domAttributes,children:u.jsx(C2,{value:e,children:u.jsx(E,{id:e,data:h.data,type:k,positionAbsoluteX:y.positionAbsolute.x,positionAbsoluteY:y.positionAbsolute.y,selected:h.selected??!1,selectable:I,draggable:M,deletable:h.deletable??!0,isConnectable:F,sourcePosition:h.sourcePosition,targetPosition:h.targetPosition,dragging:$,dragHandle:h.dragHandle,zIndex:y.z,parentId:h.parentId,...R})})})}var W2=C.memo(V2);const U2=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Pg(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:o,onError:i}=ie(U2,he),s=O2(e.onlyRenderVisibleElements),l=B2();return u.jsx("div",{className:"react-flow__nodes",style:qs,children:s.map(a=>u.jsx(W2,{id:a,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:l,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:o,nodeClickDistance:e.nodeClickDistance,onError:i},a))})}Pg.displayName="NodeRenderer";const Y2=C.memo(Pg);function X2(e){return ie(C.useCallback(n=>{if(!e)return n.edges.map(o=>o.id);const r=[];if(n.width&&n.height)for(const o of n.edges){const i=n.nodeLookup.get(o.source),s=n.nodeLookup.get(o.target);i&&s&&MS({sourceNode:i,targetNode:s,width:n.width,height:n.height,transform:n.transform})&&r.push(o.id)}return r},[e]),he)}const G2=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return u.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},K2=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return u.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},bf={[ws.Arrow]:G2,[ws.ArrowClosed]:K2};function Q2(e){const t=pe();return C.useMemo(()=>{var o,i;return Object.prototype.hasOwnProperty.call(bf,e)?bf[e]:((i=(o=t.getState()).onError)==null||i.call(o,"009",Mt.error009(e)),null)},[e])}const Z2=({id:e,type:t,color:n,width:r=12.5,height:o=12.5,markerUnits:i="strokeWidth",strokeWidth:s,orient:l="auto-start-reverse"})=>{const a=Q2(t);return a?u.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:l,refX:"0",refY:"0",children:u.jsx(a,{color:n,strokeWidth:s})}):null},zg=({defaultColor:e,rfId:t})=>{const n=ie(i=>i.edges),r=ie(i=>i.defaultEdgeOptions),o=C.useMemo(()=>RS(n,{id:t,defaultColor:e,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,t,e]);return o.length?u.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:u.jsx("defs",{children:o.map(i=>u.jsx(Z2,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};zg.displayName="MarkerDefinitions";var q2=C.memo(zg);function Ig({x:e,y:t,label:n,labelStyle:r,labelShowBg:o=!0,labelBgStyle:i,labelBgPadding:s=[2,4],labelBgBorderRadius:l=2,children:a,className:c,...f}){const[d,p]=C.useState({x:1,y:0,width:0,height:0}),v=Se(["react-flow__edge-textwrapper",c]),x=C.useRef(null);return C.useEffect(()=>{if(x.current){const w=x.current.getBBox();p({x:w.x,y:w.y,width:w.width,height:w.height})}},[n]),n?u.jsxs("g",{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:v,visibility:d.width?"visible":"hidden",...f,children:[o&&u.jsx("rect",{width:d.width+2*s[0],x:-s[0],y:-s[1],height:d.height+2*s[1],className:"react-flow__edge-textbg",style:i,rx:l,ry:l}),u.jsx("text",{className:"react-flow__edge-text",y:d.height/2,dy:"0.3em",ref:x,style:r,children:n}),a]}):null}Ig.displayName="EdgeText";const J2=C.memo(Ig);function Js({path:e,labelX:t,labelY:n,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:s,labelBgPadding:l,labelBgBorderRadius:a,interactionWidth:c=20,...f}){return u.jsxs(u.Fragment,{children:[u.jsx("path",{...f,d:e,fill:"none",className:Se(["react-flow__edge-path",f.className])}),c?u.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:c,className:"react-flow__edge-interaction"}):null,r&&pt(t)&&pt(n)?u.jsx(J2,{x:t,y:n,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:s,labelBgPadding:l,labelBgBorderRadius:a}):null]})}function jf({pos:e,x1:t,y1:n,x2:r,y2:o}){return e===q.Left||e===q.Right?[.5*(t+r),n]:[t,.5*(n+o)]}function Lg({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:r,targetY:o,targetPosition:i=q.Top}){const[s,l]=jf({pos:n,x1:e,y1:t,x2:r,y2:o}),[a,c]=jf({pos:i,x1:r,y1:o,x2:e,y2:t}),[f,d,p,v]=qm({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:s,sourceControlY:l,targetControlX:a,targetControlY:c});return[`M${e},${t} C${s},${l} ${a},${c} ${r},${o}`,f,d,p,v]}function Ag(e){return C.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,sourcePosition:s,targetPosition:l,label:a,labelStyle:c,labelShowBg:f,labelBgStyle:d,labelBgPadding:p,labelBgBorderRadius:v,style:x,markerEnd:w,markerStart:S,interactionWidth:g})=>{const[m,h,y]=Lg({sourceX:n,sourceY:r,sourcePosition:s,targetX:o,targetY:i,targetPosition:l}),_=e.isInternal?void 0:t;return u.jsx(Js,{id:_,path:m,labelX:h,labelY:y,label:a,labelStyle:c,labelShowBg:f,labelBgStyle:d,labelBgPadding:p,labelBgBorderRadius:v,style:x,markerEnd:w,markerStart:S,interactionWidth:g})})}const eN=Ag({isInternal:!1}),$g=Ag({isInternal:!0});eN.displayName="SimpleBezierEdge";$g.displayName="SimpleBezierEdgeInternal";function Rg(e){return C.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,label:s,labelStyle:l,labelShowBg:a,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:d,style:p,sourcePosition:v=q.Bottom,targetPosition:x=q.Top,markerEnd:w,markerStart:S,pathOptions:g,interactionWidth:m})=>{const[h,y,_]=Xa({sourceX:n,sourceY:r,sourcePosition:v,targetX:o,targetY:i,targetPosition:x,borderRadius:g==null?void 0:g.borderRadius,offset:g==null?void 0:g.offset,stepPosition:g==null?void 0:g.stepPosition}),k=e.isInternal?void 0:t;return u.jsx(Js,{id:k,path:h,labelX:y,labelY:_,label:s,labelStyle:l,labelShowBg:a,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:d,style:p,markerEnd:w,markerStart:S,interactionWidth:m})})}const Dg=Rg({isInternal:!1}),Og=Rg({isInternal:!0});Dg.displayName="SmoothStepEdge";Og.displayName="SmoothStepEdgeInternal";function Fg(e){return C.memo(({id:t,...n})=>{var o;const r=e.isInternal?void 0:t;return u.jsx(Dg,{...n,id:r,pathOptions:C.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(o=n.pathOptions)==null?void 0:o.offset])})})}const tN=Fg({isInternal:!1}),Bg=Fg({isInternal:!0});tN.displayName="StepEdge";Bg.displayName="StepEdgeInternal";function Hg(e){return C.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,label:s,labelStyle:l,labelShowBg:a,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:d,style:p,markerEnd:v,markerStart:x,interactionWidth:w})=>{const[S,g,m]=tg({sourceX:n,sourceY:r,targetX:o,targetY:i}),h=e.isInternal?void 0:t;return u.jsx(Js,{id:h,path:S,labelX:g,labelY:m,label:s,labelStyle:l,labelShowBg:a,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:d,style:p,markerEnd:v,markerStart:x,interactionWidth:w})})}const nN=Hg({isInternal:!1}),Vg=Hg({isInternal:!0});nN.displayName="StraightEdge";Vg.displayName="StraightEdgeInternal";function Wg(e){return C.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,sourcePosition:s=q.Bottom,targetPosition:l=q.Top,label:a,labelStyle:c,labelShowBg:f,labelBgStyle:d,labelBgPadding:p,labelBgBorderRadius:v,style:x,markerEnd:w,markerStart:S,pathOptions:g,interactionWidth:m})=>{const[h,y,_]=Jm({sourceX:n,sourceY:r,sourcePosition:s,targetX:o,targetY:i,targetPosition:l,curvature:g==null?void 0:g.curvature}),k=e.isInternal?void 0:t;return u.jsx(Js,{id:k,path:h,labelX:y,labelY:_,label:a,labelStyle:c,labelShowBg:f,labelBgStyle:d,labelBgPadding:p,labelBgBorderRadius:v,style:x,markerEnd:w,markerStart:S,interactionWidth:m})})}const rN=Wg({isInternal:!1}),Ug=Wg({isInternal:!0});rN.displayName="BezierEdge";Ug.displayName="BezierEdgeInternal";const Mf={default:Ug,straight:Vg,step:Bg,smoothstep:Og,simplebezier:$g},Tf={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},oN=(e,t,n)=>n===q.Left?e-t:n===q.Right?e+t:e,iN=(e,t,n)=>n===q.Top?e-t:n===q.Bottom?e+t:e,Pf="react-flow__edgeupdater";function zf({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:o,onMouseEnter:i,onMouseOut:s,type:l}){return u.jsx("circle",{onMouseDown:o,onMouseEnter:i,onMouseOut:s,className:Se([Pf,`${Pf}-${l}`]),cx:oN(t,r,e),cy:iN(n,r,e),r,stroke:"transparent",fill:"transparent"})}function sN({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:o,targetX:i,targetY:s,sourcePosition:l,targetPosition:a,onReconnect:c,onReconnectStart:f,onReconnectEnd:d,setReconnecting:p,setUpdateHover:v}){const x=pe(),w=(y,_)=>{if(y.button!==0)return;const{autoPanOnConnect:k,domNode:E,connectionMode:M,connectionRadius:I,lib:F,onConnectStart:T,cancelConnection:L,nodeLookup:B,rfId:j,panBy:$,updateConnection:z}=x.getState(),R=_.type==="target",N=(O,A)=>{p(!1),d==null||d(O,n,_.type,A)},b=O=>c==null?void 0:c(n,O),P=(O,A)=>{p(!0),f==null||f(y,n,_.type),T==null||T(O,A)};Qa.onPointerDown(y.nativeEvent,{autoPanOnConnect:k,connectionMode:M,connectionRadius:I,domNode:E,handleId:_.id,nodeId:_.nodeId,nodeLookup:B,isTarget:R,edgeUpdaterType:_.type,lib:F,flowId:j,cancelConnection:L,panBy:$,isValidConnection:(...O)=>{var A,H;return((H=(A=x.getState()).isValidConnection)==null?void 0:H.call(A,...O))??!0},onConnect:b,onConnectStart:P,onConnectEnd:(...O)=>{var A,H;return(H=(A=x.getState()).onConnectEnd)==null?void 0:H.call(A,...O)},onReconnectEnd:N,updateConnection:z,getTransform:()=>x.getState().transform,getFromHandle:()=>x.getState().connection.fromHandle,dragThreshold:x.getState().connectionDragThreshold,handleDomNode:y.currentTarget})},S=y=>w(y,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),g=y=>w(y,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),m=()=>v(!0),h=()=>v(!1);return u.jsxs(u.Fragment,{children:[(e===!0||e==="source")&&u.jsx(zf,{position:l,centerX:r,centerY:o,radius:t,onMouseDown:S,onMouseEnter:m,onMouseOut:h,type:"source"}),(e===!0||e==="target")&&u.jsx(zf,{position:a,centerX:i,centerY:s,radius:t,onMouseDown:g,onMouseEnter:m,onMouseOut:h,type:"target"})]})}function lN({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:o,onDoubleClick:i,onContextMenu:s,onMouseEnter:l,onMouseMove:a,onMouseLeave:c,reconnectRadius:f,onReconnect:d,onReconnectStart:p,onReconnectEnd:v,rfId:x,edgeTypes:w,noPanClassName:S,onError:g,disableKeyboardA11y:m}){let h=ie(Z=>Z.edgeLookup.get(e));const y=ie(Z=>Z.defaultEdgeOptions);h=y?{...y,...h}:h;let _=h.type||"default",k=(w==null?void 0:w[_])||Mf[_];k===void 0&&(g==null||g("011",Mt.error011(_)),_="default",k=(w==null?void 0:w.default)||Mf.default);const E=!!(h.focusable||t&&typeof h.focusable>"u"),M=typeof d<"u"&&(h.reconnectable||n&&typeof h.reconnectable>"u"),I=!!(h.selectable||r&&typeof h.selectable>"u"),F=C.useRef(null),[T,L]=C.useState(!1),[B,j]=C.useState(!1),$=pe(),{zIndex:z,sourceX:R,sourceY:N,targetX:b,targetY:P,sourcePosition:O,targetPosition:A}=ie(C.useCallback(Z=>{const J=Z.nodeLookup.get(h.source),re=Z.nodeLookup.get(h.target);if(!J||!re)return{zIndex:h.zIndex,...Tf};const te=$S({id:e,sourceNode:J,targetNode:re,sourceHandle:h.sourceHandle||null,targetHandle:h.targetHandle||null,connectionMode:Z.connectionMode,onError:g});return{zIndex:jS({selected:h.selected,zIndex:h.zIndex,sourceNode:J,targetNode:re,elevateOnSelect:Z.elevateEdgesOnSelect,zIndexMode:Z.zIndexMode}),...te||Tf}},[h.source,h.target,h.sourceHandle,h.targetHandle,h.selected,h.zIndex]),he),H=C.useMemo(()=>h.markerStart?`url('#${Ga(h.markerStart,x)}')`:void 0,[h.markerStart,x]),W=C.useMemo(()=>h.markerEnd?`url('#${Ga(h.markerEnd,x)}')`:void 0,[h.markerEnd,x]);if(h.hidden||R===null||N===null||b===null||P===null)return null;const D=Z=>{var K;const{addSelectedEdges:J,unselectNodesAndEdges:re,multiSelectionActive:te}=$.getState();I&&($.setState({nodesSelectionActive:!1}),h.selected&&te?(re({nodes:[],edges:[h]}),(K=F.current)==null||K.blur()):J([e])),o&&o(Z,h)},U=i?Z=>{i(Z,{...h})}:void 0,X=s?Z=>{s(Z,{...h})}:void 0,V=l?Z=>{l(Z,{...h})}:void 0,G=a?Z=>{a(Z,{...h})}:void 0,ne=c?Z=>{c(Z,{...h})}:void 0,ee=Z=>{var J;if(!m&&Dm.includes(Z.key)&&I){const{unselectNodesAndEdges:re,addSelectedEdges:te}=$.getState();Z.key==="Escape"?((J=F.current)==null||J.blur(),re({edges:[h]})):te([e])}};return u.jsx("svg",{style:{zIndex:z},children:u.jsxs("g",{className:Se(["react-flow__edge",`react-flow__edge-${_}`,h.className,S,{selected:h.selected,animated:h.animated,inactive:!I&&!o,updating:T,selectable:I}]),onClick:D,onDoubleClick:U,onContextMenu:X,onMouseEnter:V,onMouseMove:G,onMouseLeave:ne,onKeyDown:E?ee:void 0,tabIndex:E?0:void 0,role:h.ariaRole??(E?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":h.ariaLabel===null?void 0:h.ariaLabel||`Edge from ${h.source} to ${h.target}`,"aria-describedby":E?`${wg}-${x}`:void 0,ref:F,...h.domAttributes,children:[!B&&u.jsx(k,{id:e,source:h.source,target:h.target,type:h.type,selected:h.selected,animated:h.animated,selectable:I,deletable:h.deletable??!0,label:h.label,labelStyle:h.labelStyle,labelShowBg:h.labelShowBg,labelBgStyle:h.labelBgStyle,labelBgPadding:h.labelBgPadding,labelBgBorderRadius:h.labelBgBorderRadius,sourceX:R,sourceY:N,targetX:b,targetY:P,sourcePosition:O,targetPosition:A,data:h.data,style:h.style,sourceHandleId:h.sourceHandle,targetHandleId:h.targetHandle,markerStart:H,markerEnd:W,pathOptions:"pathOptions"in h?h.pathOptions:void 0,interactionWidth:h.interactionWidth}),M&&u.jsx(sN,{edge:h,isReconnectable:M,reconnectRadius:f,onReconnect:d,onReconnectStart:p,onReconnectEnd:v,sourceX:R,sourceY:N,targetX:b,targetY:P,sourcePosition:O,targetPosition:A,setUpdateHover:L,setReconnecting:j})]})})}var aN=C.memo(lN);const uN=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Yg({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:o,onReconnect:i,onEdgeContextMenu:s,onEdgeMouseEnter:l,onEdgeMouseMove:a,onEdgeMouseLeave:c,onEdgeClick:f,reconnectRadius:d,onEdgeDoubleClick:p,onReconnectStart:v,onReconnectEnd:x,disableKeyboardA11y:w}){const{edgesFocusable:S,edgesReconnectable:g,elementsSelectable:m,onError:h}=ie(uN,he),y=X2(t);return u.jsxs("div",{className:"react-flow__edges",children:[u.jsx(q2,{defaultColor:e,rfId:n}),y.map(_=>u.jsx(aN,{id:_,edgesFocusable:S,edgesReconnectable:g,elementsSelectable:m,noPanClassName:o,onReconnect:i,onContextMenu:s,onMouseEnter:l,onMouseMove:a,onMouseLeave:c,onClick:f,reconnectRadius:d,onDoubleClick:p,onReconnectStart:v,onReconnectEnd:x,rfId:n,onError:h,edgeTypes:r,disableKeyboardA11y:w},_))]})}Yg.displayName="EdgeRenderer";const cN=C.memo(Yg),dN=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function fN({children:e}){const t=ie(dN);return u.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function hN(e){const t=Zs(),n=C.useRef(!1);C.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const pN=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function mN(e){const t=ie(pN),n=pe();return C.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function gN(e){return e.connection.inProgress?{...e.connection,to:Xo(e.connection.to,e.transform)}:{...e.connection}}function yN(e){return gN}function vN(e){const t=yN();return ie(t,he)}const xN=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function wN({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:o,width:i,height:s,isValid:l,inProgress:a}=ie(xN,he);return!(i&&o&&a)?null:u.jsx("svg",{style:e,width:i,height:s,className:"react-flow__connectionline react-flow__container",children:u.jsx("g",{className:Se(["react-flow__connection",Bm(l)]),children:u.jsx(Xg,{style:t,type:n,CustomComponent:r,isValid:l})})})}const Xg=({style:e,type:t=qt.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:o,from:i,fromNode:s,fromHandle:l,fromPosition:a,to:c,toNode:f,toHandle:d,toPosition:p,pointer:v}=vN();if(!o)return;if(n)return u.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:s,fromHandle:l,fromX:i.x,fromY:i.y,toX:c.x,toY:c.y,fromPosition:a,toPosition:p,connectionStatus:Bm(r),toNode:f,toHandle:d,pointer:v});let x="";const w={sourceX:i.x,sourceY:i.y,sourcePosition:a,targetX:c.x,targetY:c.y,targetPosition:p};switch(t){case qt.Bezier:[x]=Jm(w);break;case qt.SimpleBezier:[x]=Lg(w);break;case qt.Step:[x]=Xa({...w,borderRadius:0});break;case qt.SmoothStep:[x]=Xa(w);break;default:[x]=tg(w)}return u.jsx("path",{d:x,fill:"none",className:"react-flow__connection-path",style:e})};Xg.displayName="ConnectionLine";const _N={};function If(e=_N){C.useRef(e),pe(),C.useEffect(()=>{},[e])}function SN(){pe(),C.useRef(!1),C.useEffect(()=>{},[])}function Gg({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:o,onNodeDoubleClick:i,onEdgeDoubleClick:s,onNodeMouseEnter:l,onNodeMouseMove:a,onNodeMouseLeave:c,onNodeContextMenu:f,onSelectionContextMenu:d,onSelectionStart:p,onSelectionEnd:v,connectionLineType:x,connectionLineStyle:w,connectionLineComponent:S,connectionLineContainerStyle:g,selectionKeyCode:m,selectionOnDrag:h,selectionMode:y,multiSelectionKeyCode:_,panActivationKeyCode:k,zoomActivationKeyCode:E,deleteKeyCode:M,onlyRenderVisibleElements:I,elementsSelectable:F,defaultViewport:T,translateExtent:L,minZoom:B,maxZoom:j,preventScrolling:$,defaultMarkerColor:z,zoomOnScroll:R,zoomOnPinch:N,panOnScroll:b,panOnScrollSpeed:P,panOnScrollMode:O,zoomOnDoubleClick:A,panOnDrag:H,onPaneClick:W,onPaneMouseEnter:D,onPaneMouseMove:U,onPaneMouseLeave:X,onPaneScroll:V,onPaneContextMenu:G,paneClickDistance:ne,nodeClickDistance:ee,onEdgeContextMenu:Z,onEdgeMouseEnter:J,onEdgeMouseMove:re,onEdgeMouseLeave:te,reconnectRadius:K,onReconnect:ve,onReconnectStart:Pe,onReconnectEnd:ke,noDragClassName:ze,noWheelClassName:Pr,noPanClassName:zr,disableKeyboardA11y:Ir,nodeExtent:el,rfId:Go,viewport:Fn,onViewportChange:Lr}){return If(e),If(t),SN(),hN(n),mN(Fn),u.jsx(R2,{onPaneClick:W,onPaneMouseEnter:D,onPaneMouseMove:U,onPaneMouseLeave:X,onPaneContextMenu:G,onPaneScroll:V,paneClickDistance:ne,deleteKeyCode:M,selectionKeyCode:m,selectionOnDrag:h,selectionMode:y,onSelectionStart:p,onSelectionEnd:v,multiSelectionKeyCode:_,panActivationKeyCode:k,zoomActivationKeyCode:E,elementsSelectable:F,zoomOnScroll:R,zoomOnPinch:N,zoomOnDoubleClick:A,panOnScroll:b,panOnScrollSpeed:P,panOnScrollMode:O,panOnDrag:H,defaultViewport:T,translateExtent:L,minZoom:B,maxZoom:j,onSelectionContextMenu:d,preventScrolling:$,noDragClassName:ze,noWheelClassName:Pr,noPanClassName:zr,disableKeyboardA11y:Ir,onViewportChange:Lr,isControlledViewport:!!Fn,children:u.jsxs(fN,{children:[u.jsx(cN,{edgeTypes:t,onEdgeClick:o,onEdgeDoubleClick:s,onReconnect:ve,onReconnectStart:Pe,onReconnectEnd:ke,onlyRenderVisibleElements:I,onEdgeContextMenu:Z,onEdgeMouseEnter:J,onEdgeMouseMove:re,onEdgeMouseLeave:te,reconnectRadius:K,defaultMarkerColor:z,noPanClassName:zr,disableKeyboardA11y:Ir,rfId:Go}),u.jsx(wN,{style:w,type:x,component:S,containerStyle:g}),u.jsx("div",{className:"react-flow__edgelabel-renderer"}),u.jsx(Y2,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:l,onNodeMouseMove:a,onNodeMouseLeave:c,onNodeContextMenu:f,nodeClickDistance:ee,onlyRenderVisibleElements:I,noPanClassName:zr,noDragClassName:ze,disableKeyboardA11y:Ir,nodeExtent:el,rfId:Go}),u.jsx("div",{className:"react-flow__viewport-portal"})]})})}Gg.displayName="GraphView";const kN=C.memo(Gg),Lf=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:s,fitViewOptions:l,minZoom:a=.5,maxZoom:c=2,nodeOrigin:f,nodeExtent:d,zIndexMode:p="basic"}={})=>{const v=new Map,x=new Map,w=new Map,S=new Map,g=r??t??[],m=n??e??[],h=f??[0,0],y=d??zo;og(w,S,g);const _=Ka(m,v,x,{nodeOrigin:h,nodeExtent:y,zIndexMode:p});let k=[0,0,1];if(s&&o&&i){const E=Uo(v,{filter:T=>!!((T.width||T.initialWidth)&&(T.height||T.initialHeight))}),{x:M,y:I,zoom:F}=ic(E,o,i,a,c,(l==null?void 0:l.padding)??.1);k=[M,I,F]}return{rfId:"1",width:o??0,height:i??0,transform:k,nodes:m,nodesInitialized:_,nodeLookup:v,parentLookup:x,edges:g,edgeLookup:S,connectionLookup:w,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:a,maxZoom:c,translateExtent:zo,nodeExtent:y,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Sr.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:h,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:s??!1,fitViewOptions:l,fitViewResolver:null,connection:{...Fm},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:SS,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Om,zIndexMode:p,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},NN=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:s,fitViewOptions:l,minZoom:a,maxZoom:c,nodeOrigin:f,nodeExtent:d,zIndexMode:p})=>Hk((v,x)=>{async function w(){const{nodeLookup:S,panZoom:g,fitViewOptions:m,fitViewResolver:h,width:y,height:_,minZoom:k,maxZoom:E}=x();g&&(await wS({nodes:S,width:y,height:_,panZoom:g,minZoom:k,maxZoom:E},m),h==null||h.resolve(!0),v({fitViewResolver:null}))}return{...Lf({nodes:e,edges:t,width:o,height:i,fitView:s,fitViewOptions:l,minZoom:a,maxZoom:c,nodeOrigin:f,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:p}),setNodes:S=>{const{nodeLookup:g,parentLookup:m,nodeOrigin:h,elevateNodesOnSelect:y,fitViewQueued:_,zIndexMode:k}=x(),E=Ka(S,g,m,{nodeOrigin:h,nodeExtent:d,elevateNodesOnSelect:y,checkEquality:!0,zIndexMode:k});_&&E?(w(),v({nodes:S,nodesInitialized:E,fitViewQueued:!1,fitViewOptions:void 0})):v({nodes:S,nodesInitialized:E})},setEdges:S=>{const{connectionLookup:g,edgeLookup:m}=x();og(g,m,S),v({edges:S})},setDefaultNodesAndEdges:(S,g)=>{if(S){const{setNodes:m}=x();m(S),v({hasDefaultNodes:!0})}if(g){const{setEdges:m}=x();m(g),v({hasDefaultEdges:!0})}},updateNodeInternals:S=>{const{triggerNodeChanges:g,nodeLookup:m,parentLookup:h,domNode:y,nodeOrigin:_,nodeExtent:k,debug:E,fitViewQueued:M,zIndexMode:I}=x(),{changes:F,updatedInternals:T}=WS(S,m,h,y,_,k,I);T&&(FS(m,h,{nodeOrigin:_,nodeExtent:k,zIndexMode:I}),M?(w(),v({fitViewQueued:!1,fitViewOptions:void 0})):v({}),(F==null?void 0:F.length)>0&&(E&&console.log("React Flow: trigger node changes",F),g==null||g(F)))},updateNodePositions:(S,g=!1)=>{const m=[];let h=[];const{nodeLookup:y,triggerNodeChanges:_,connection:k,updateConnection:E,onNodesChangeMiddlewareMap:M}=x();for(const[I,F]of S){const T=y.get(I),L=!!(T!=null&&T.expandParent&&(T!=null&&T.parentId)&&(F!=null&&F.position)),B={id:I,type:"position",position:L?{x:Math.max(0,F.position.x),y:Math.max(0,F.position.y)}:F.position,dragging:g};if(T&&k.inProgress&&k.fromNode.id===T.id){const j=An(T,k.fromHandle,q.Left,!0);E({...k,from:j})}L&&T.parentId&&m.push({id:I,parentId:T.parentId,rect:{...F.internals.positionAbsolute,width:F.measured.width??0,height:F.measured.height??0}}),h.push(B)}if(m.length>0){const{parentLookup:I,nodeOrigin:F}=x(),T=dc(m,y,I,F);h.push(...T)}for(const I of M.values())h=I(h);_(h)},triggerNodeChanges:S=>{const{onNodesChange:g,setNodes:m,nodes:h,hasDefaultNodes:y,debug:_}=x();if(S!=null&&S.length){if(y){const k=kg(S,h);m(k)}_&&console.log("React Flow: trigger node changes",S),g==null||g(S)}},triggerEdgeChanges:S=>{const{onEdgesChange:g,setEdges:m,edges:h,hasDefaultEdges:y,debug:_}=x();if(S!=null&&S.length){if(y){const k=Ng(S,h);m(k)}_&&console.log("React Flow: trigger edge changes",S),g==null||g(S)}},addSelectedNodes:S=>{const{multiSelectionActive:g,edgeLookup:m,nodeLookup:h,triggerNodeChanges:y,triggerEdgeChanges:_}=x();if(g){const k=S.map(E=>vn(E,!0));y(k);return}y(or(h,new Set([...S]),!0)),_(or(m))},addSelectedEdges:S=>{const{multiSelectionActive:g,edgeLookup:m,nodeLookup:h,triggerNodeChanges:y,triggerEdgeChanges:_}=x();if(g){const k=S.map(E=>vn(E,!0));_(k);return}_(or(m,new Set([...S]))),y(or(h,new Set,!0))},unselectNodesAndEdges:({nodes:S,edges:g}={})=>{const{edges:m,nodes:h,nodeLookup:y,triggerNodeChanges:_,triggerEdgeChanges:k}=x(),E=S||h,M=g||m,I=[];for(const T of E){if(!T.selected)continue;const L=y.get(T.id);L&&(L.selected=!1),I.push(vn(T.id,!1))}const F=[];for(const T of M)T.selected&&F.push(vn(T.id,!1));_(I),k(F)},setMinZoom:S=>{const{panZoom:g,maxZoom:m}=x();g==null||g.setScaleExtent([S,m]),v({minZoom:S})},setMaxZoom:S=>{const{panZoom:g,minZoom:m}=x();g==null||g.setScaleExtent([m,S]),v({maxZoom:S})},setTranslateExtent:S=>{var g;(g=x().panZoom)==null||g.setTranslateExtent(S),v({translateExtent:S})},resetSelectedElements:()=>{const{edges:S,nodes:g,triggerNodeChanges:m,triggerEdgeChanges:h,elementsSelectable:y}=x();if(!y)return;const _=g.reduce((E,M)=>M.selected?[...E,vn(M.id,!1)]:E,[]),k=S.reduce((E,M)=>M.selected?[...E,vn(M.id,!1)]:E,[]);m(_),h(k)},setNodeExtent:S=>{const{nodes:g,nodeLookup:m,parentLookup:h,nodeOrigin:y,elevateNodesOnSelect:_,nodeExtent:k,zIndexMode:E}=x();S[0][0]===k[0][0]&&S[0][1]===k[0][1]&&S[1][0]===k[1][0]&&S[1][1]===k[1][1]||(Ka(g,m,h,{nodeOrigin:y,nodeExtent:S,elevateNodesOnSelect:_,checkEquality:!1,zIndexMode:E}),v({nodeExtent:S}))},panBy:S=>{const{transform:g,width:m,height:h,panZoom:y,translateExtent:_}=x();return US({delta:S,panZoom:y,transform:g,translateExtent:_,width:m,height:h})},setCenter:async(S,g,m)=>{const{width:h,height:y,maxZoom:_,panZoom:k}=x();if(!k)return Promise.resolve(!1);const E=typeof(m==null?void 0:m.zoom)<"u"?m.zoom:_;return await k.setViewport({x:h/2-S*E,y:y/2-g*E,zoom:E},{duration:m==null?void 0:m.duration,ease:m==null?void 0:m.ease,interpolate:m==null?void 0:m.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{v({connection:{...Fm}})},updateConnection:S=>{v({connection:S})},reset:()=>v({...Lf()})}},Object.is);function CN({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:o,initialHeight:i,initialMinZoom:s,initialMaxZoom:l,initialFitViewOptions:a,fitView:c,nodeOrigin:f,nodeExtent:d,zIndexMode:p,children:v}){const[x]=C.useState(()=>NN({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:c,minZoom:s,maxZoom:l,fitViewOptions:a,nodeOrigin:f,nodeExtent:d,zIndexMode:p}));return u.jsx(Vk,{value:x,children:u.jsx(f2,{children:v})})}function EN({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:o,width:i,height:s,fitView:l,fitViewOptions:a,minZoom:c,maxZoom:f,nodeOrigin:d,nodeExtent:p,zIndexMode:v}){return C.useContext(Ks)?u.jsx(u.Fragment,{children:e}):u.jsx(CN,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:o,initialWidth:i,initialHeight:s,fitView:l,initialFitViewOptions:a,initialMinZoom:c,initialMaxZoom:f,nodeOrigin:d,nodeExtent:p,zIndexMode:v,children:e})}const bN={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function jN({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:o,nodeTypes:i,edgeTypes:s,onNodeClick:l,onEdgeClick:a,onInit:c,onMove:f,onMoveStart:d,onMoveEnd:p,onConnect:v,onConnectStart:x,onConnectEnd:w,onClickConnectStart:S,onClickConnectEnd:g,onNodeMouseEnter:m,onNodeMouseMove:h,onNodeMouseLeave:y,onNodeContextMenu:_,onNodeDoubleClick:k,onNodeDragStart:E,onNodeDrag:M,onNodeDragStop:I,onNodesDelete:F,onEdgesDelete:T,onDelete:L,onSelectionChange:B,onSelectionDragStart:j,onSelectionDrag:$,onSelectionDragStop:z,onSelectionContextMenu:R,onSelectionStart:N,onSelectionEnd:b,onBeforeDelete:P,connectionMode:O,connectionLineType:A=qt.Bezier,connectionLineStyle:H,connectionLineComponent:W,connectionLineContainerStyle:D,deleteKeyCode:U="Backspace",selectionKeyCode:X="Shift",selectionOnDrag:V=!1,selectionMode:G=Io.Full,panActivationKeyCode:ne="Space",multiSelectionKeyCode:ee=Ao()?"Meta":"Control",zoomActivationKeyCode:Z=Ao()?"Meta":"Control",snapToGrid:J,snapGrid:re,onlyRenderVisibleElements:te=!1,selectNodesOnDrag:K,nodesDraggable:ve,autoPanOnNodeFocus:Pe,nodesConnectable:ke,nodesFocusable:ze,nodeOrigin:Pr=_g,edgesFocusable:zr,edgesReconnectable:Ir,elementsSelectable:el=!0,defaultViewport:Go=n2,minZoom:Fn=.5,maxZoom:Lr=2,translateExtent:mc=zo,preventScrolling:ay=!0,nodeExtent:tl,defaultMarkerColor:uy="#b1b1b7",zoomOnScroll:cy=!0,zoomOnPinch:dy=!0,panOnScroll:fy=!1,panOnScrollSpeed:hy=.5,panOnScrollMode:py=En.Free,zoomOnDoubleClick:my=!0,panOnDrag:gy=!0,onPaneClick:yy,onPaneMouseEnter:vy,onPaneMouseMove:xy,onPaneMouseLeave:wy,onPaneScroll:_y,onPaneContextMenu:Sy,paneClickDistance:ky=1,nodeClickDistance:Ny=0,children:Cy,onReconnect:Ey,onReconnectStart:by,onReconnectEnd:jy,onEdgeContextMenu:My,onEdgeDoubleClick:Ty,onEdgeMouseEnter:Py,onEdgeMouseMove:zy,onEdgeMouseLeave:Iy,reconnectRadius:Ly=10,onNodesChange:Ay,onEdgesChange:$y,noDragClassName:Ry="nodrag",noWheelClassName:Dy="nowheel",noPanClassName:gc="nopan",fitView:yc,fitViewOptions:vc,connectOnClick:Oy,attributionPosition:Fy,proOptions:By,defaultEdgeOptions:Hy,elevateNodesOnSelect:Vy=!0,elevateEdgesOnSelect:Wy=!1,disableKeyboardA11y:xc=!1,autoPanOnConnect:Uy,autoPanOnNodeDrag:Yy,autoPanSpeed:Xy,connectionRadius:Gy,isValidConnection:Ky,onError:Qy,style:Zy,id:wc,nodeDragThreshold:qy,connectionDragThreshold:Jy,viewport:e0,onViewportChange:t0,width:n0,height:r0,colorMode:o0="light",debug:i0,onScroll:Ko,ariaLabelConfig:s0,zIndexMode:_c="basic",...l0},a0){const nl=wc||"1",u0=s2(o0),c0=C.useCallback(Sc=>{Sc.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Ko==null||Ko(Sc)},[Ko]);return u.jsx("div",{"data-testid":"rf__wrapper",...l0,onScroll:c0,style:{...Zy,...bN},ref:a0,className:Se(["react-flow",o,u0]),id:wc,role:"application",children:u.jsxs(EN,{nodes:e,edges:t,width:n0,height:r0,fitView:yc,fitViewOptions:vc,minZoom:Fn,maxZoom:Lr,nodeOrigin:Pr,nodeExtent:tl,zIndexMode:_c,children:[u.jsx(kN,{onInit:c,onNodeClick:l,onEdgeClick:a,onNodeMouseEnter:m,onNodeMouseMove:h,onNodeMouseLeave:y,onNodeContextMenu:_,onNodeDoubleClick:k,nodeTypes:i,edgeTypes:s,connectionLineType:A,connectionLineStyle:H,connectionLineComponent:W,connectionLineContainerStyle:D,selectionKeyCode:X,selectionOnDrag:V,selectionMode:G,deleteKeyCode:U,multiSelectionKeyCode:ee,panActivationKeyCode:ne,zoomActivationKeyCode:Z,onlyRenderVisibleElements:te,defaultViewport:Go,translateExtent:mc,minZoom:Fn,maxZoom:Lr,preventScrolling:ay,zoomOnScroll:cy,zoomOnPinch:dy,zoomOnDoubleClick:my,panOnScroll:fy,panOnScrollSpeed:hy,panOnScrollMode:py,panOnDrag:gy,onPaneClick:yy,onPaneMouseEnter:vy,onPaneMouseMove:xy,onPaneMouseLeave:wy,onPaneScroll:_y,onPaneContextMenu:Sy,paneClickDistance:ky,nodeClickDistance:Ny,onSelectionContextMenu:R,onSelectionStart:N,onSelectionEnd:b,onReconnect:Ey,onReconnectStart:by,onReconnectEnd:jy,onEdgeContextMenu:My,onEdgeDoubleClick:Ty,onEdgeMouseEnter:Py,onEdgeMouseMove:zy,onEdgeMouseLeave:Iy,reconnectRadius:Ly,defaultMarkerColor:uy,noDragClassName:Ry,noWheelClassName:Dy,noPanClassName:gc,rfId:nl,disableKeyboardA11y:xc,nodeExtent:tl,viewport:e0,onViewportChange:t0}),u.jsx(i2,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:v,onConnectStart:x,onConnectEnd:w,onClickConnectStart:S,onClickConnectEnd:g,nodesDraggable:ve,autoPanOnNodeFocus:Pe,nodesConnectable:ke,nodesFocusable:ze,edgesFocusable:zr,edgesReconnectable:Ir,elementsSelectable:el,elevateNodesOnSelect:Vy,elevateEdgesOnSelect:Wy,minZoom:Fn,maxZoom:Lr,nodeExtent:tl,onNodesChange:Ay,onEdgesChange:$y,snapToGrid:J,snapGrid:re,connectionMode:O,translateExtent:mc,connectOnClick:Oy,defaultEdgeOptions:Hy,fitView:yc,fitViewOptions:vc,onNodesDelete:F,onEdgesDelete:T,onDelete:L,onNodeDragStart:E,onNodeDrag:M,onNodeDragStop:I,onSelectionDrag:$,onSelectionDragStart:j,onSelectionDragStop:z,onMove:f,onMoveStart:d,onMoveEnd:p,noPanClassName:gc,nodeOrigin:Pr,rfId:nl,autoPanOnConnect:Uy,autoPanOnNodeDrag:Yy,autoPanSpeed:Xy,onError:Qy,connectionRadius:Gy,isValidConnection:Ky,selectNodesOnDrag:K,nodeDragThreshold:qy,connectionDragThreshold:Jy,onBeforeDelete:P,debug:i0,ariaLabelConfig:s0,zIndexMode:_c}),u.jsx(t2,{onSelectionChange:B}),Cy,u.jsx(Qk,{proOptions:By,position:Fy}),u.jsx(Kk,{rfId:nl,disableKeyboardA11y:xc})]})})}var MN=Cg(jN);function TN(e){const[t,n]=C.useState(e),r=C.useCallback(o=>n(i=>kg(o,i)),[]);return[t,n,r]}function PN(e){const[t,n]=C.useState(e),r=C.useCallback(o=>n(i=>Ng(o,i)),[]);return[t,n,r]}function zN({dimensions:e,lineWidth:t,variant:n,className:r}){return u.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Se(["react-flow__background-pattern",n,r])})}function IN({radius:e,className:t}){return u.jsx("circle",{cx:e,cy:e,r:e,className:Se(["react-flow__background-pattern","dots",t])})}var cn;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(cn||(cn={}));const LN={[cn.Dots]:1,[cn.Lines]:1,[cn.Cross]:6},AN=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Kg({id:e,variant:t=cn.Dots,gap:n=20,size:r,lineWidth:o=1,offset:i=0,color:s,bgColor:l,style:a,className:c,patternClassName:f}){const d=C.useRef(null),{transform:p,patternId:v}=ie(AN,he),x=r||LN[t],w=t===cn.Dots,S=t===cn.Cross,g=Array.isArray(n)?n:[n,n],m=[g[0]*p[2]||1,g[1]*p[2]||1],h=x*p[2],y=Array.isArray(i)?i:[i,i],_=S?[h,h]:m,k=[y[0]*p[2]||1+_[0]/2,y[1]*p[2]||1+_[1]/2],E=`${v}${e||""}`;return u.jsxs("svg",{className:Se(["react-flow__background",c]),style:{...a,...qs,"--xy-background-color-props":l,"--xy-background-pattern-color-props":s},ref:d,"data-testid":"rf__background",children:[u.jsx("pattern",{id:E,x:p[0]%m[0],y:p[1]%m[1],width:m[0],height:m[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${k[0]},-${k[1]})`,children:w?u.jsx(IN,{radius:h/2,className:f}):u.jsx(zN,{dimensions:_,lineWidth:o,variant:t,className:f})}),u.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${E})`})]})}Kg.displayName="Background";const $N=C.memo(Kg);function RN(){return u.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:u.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function DN(){return u.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:u.jsx("path",{d:"M0 0h32v4.2H0z"})})}function ON(){return u.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:u.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function FN(){return u.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:u.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function BN(){return u.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:u.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function _i({children:e,className:t,...n}){return u.jsx("button",{type:"button",className:Se(["react-flow__controls-button",t]),...n,children:e})}const HN=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function Qg({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:o,onZoomIn:i,onZoomOut:s,onFitView:l,onInteractiveChange:a,className:c,children:f,position:d="bottom-left",orientation:p="vertical","aria-label":v}){const x=pe(),{isInteractive:w,minZoomReached:S,maxZoomReached:g,ariaLabelConfig:m}=ie(HN,he),{zoomIn:h,zoomOut:y,fitView:_}=Zs(),k=()=>{h(),i==null||i()},E=()=>{y(),s==null||s()},M=()=>{_(o),l==null||l()},I=()=>{x.setState({nodesDraggable:!w,nodesConnectable:!w,elementsSelectable:!w}),a==null||a(!w)},F=p==="horizontal"?"horizontal":"vertical";return u.jsxs(Qs,{className:Se(["react-flow__controls",F,c]),position:d,style:e,"data-testid":"rf__controls","aria-label":v??m["controls.ariaLabel"],children:[t&&u.jsxs(u.Fragment,{children:[u.jsx(_i,{onClick:k,className:"react-flow__controls-zoomin",title:m["controls.zoomIn.ariaLabel"],"aria-label":m["controls.zoomIn.ariaLabel"],disabled:g,children:u.jsx(RN,{})}),u.jsx(_i,{onClick:E,className:"react-flow__controls-zoomout",title:m["controls.zoomOut.ariaLabel"],"aria-label":m["controls.zoomOut.ariaLabel"],disabled:S,children:u.jsx(DN,{})})]}),n&&u.jsx(_i,{className:"react-flow__controls-fitview",onClick:M,title:m["controls.fitView.ariaLabel"],"aria-label":m["controls.fitView.ariaLabel"],children:u.jsx(ON,{})}),r&&u.jsx(_i,{className:"react-flow__controls-interactive",onClick:I,title:m["controls.interactive.ariaLabel"],"aria-label":m["controls.interactive.ariaLabel"],children:w?u.jsx(BN,{}):u.jsx(FN,{})}),f]})}Qg.displayName="Controls";const VN=C.memo(Qg);function WN({id:e,x:t,y:n,width:r,height:o,style:i,color:s,strokeColor:l,strokeWidth:a,className:c,borderRadius:f,shapeRendering:d,selected:p,onClick:v}){const{background:x,backgroundColor:w}=i||{},S=s||x||w;return u.jsx("rect",{className:Se(["react-flow__minimap-node",{selected:p},c]),x:t,y:n,rx:f,ry:f,width:r,height:o,style:{fill:S,stroke:l,strokeWidth:a},shapeRendering:d,onClick:v?g=>v(g,e):void 0})}const UN=C.memo(WN),YN=e=>e.nodes.map(t=>t.id),Dl=e=>e instanceof Function?e:()=>e;function XN({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:o,nodeComponent:i=UN,onClick:s}){const l=ie(YN,he),a=Dl(t),c=Dl(e),f=Dl(n),d=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return u.jsx(u.Fragment,{children:l.map(p=>u.jsx(KN,{id:p,nodeColorFunc:a,nodeStrokeColorFunc:c,nodeClassNameFunc:f,nodeBorderRadius:r,nodeStrokeWidth:o,NodeComponent:i,onClick:s,shapeRendering:d},p))})}function GN({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:o,nodeStrokeWidth:i,shapeRendering:s,NodeComponent:l,onClick:a}){const{node:c,x:f,y:d,width:p,height:v}=ie(x=>{const w=x.nodeLookup.get(e);if(!w)return{node:void 0,x:0,y:0,width:0,height:0};const S=w.internals.userNode,{x:g,y:m}=w.internals.positionAbsolute,{width:h,height:y}=Wt(S);return{node:S,x:g,y:m,width:h,height:y}},he);return!c||c.hidden||!Xm(c)?null:u.jsx(l,{x:f,y:d,width:p,height:v,style:c.style,selected:!!c.selected,className:r(c),color:t(c),borderRadius:o,strokeColor:n(c),strokeWidth:i,shapeRendering:s,onClick:a,id:c.id})}const KN=C.memo(GN);var QN=C.memo(XN);const ZN=200,qN=150,JN=e=>!e.hidden,eC=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?Ym(Uo(e.nodeLookup,{filter:JN}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},tC="react-flow__minimap-desc";function Zg({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:o="",nodeBorderRadius:i=5,nodeStrokeWidth:s,nodeComponent:l,bgColor:a,maskColor:c,maskStrokeColor:f,maskStrokeWidth:d,position:p="bottom-right",onClick:v,onNodeClick:x,pannable:w=!1,zoomable:S=!1,ariaLabel:g,inversePan:m,zoomStep:h=1,offsetScale:y=5}){const _=pe(),k=C.useRef(null),{boundingRect:E,viewBB:M,rfId:I,panZoom:F,translateExtent:T,flowWidth:L,flowHeight:B,ariaLabelConfig:j}=ie(eC,he),$=(e==null?void 0:e.width)??ZN,z=(e==null?void 0:e.height)??qN,R=E.width/$,N=E.height/z,b=Math.max(R,N),P=b*$,O=b*z,A=y*b,H=E.x-(P-E.width)/2-A,W=E.y-(O-E.height)/2-A,D=P+A*2,U=O+A*2,X=`${tC}-${I}`,V=C.useRef(0),G=C.useRef();V.current=b,C.useEffect(()=>{if(k.current&&F)return G.current=ek({domNode:k.current,panZoom:F,getTransform:()=>_.getState().transform,getViewScale:()=>V.current}),()=>{var J;(J=G.current)==null||J.destroy()}},[F]),C.useEffect(()=>{var J;(J=G.current)==null||J.update({translateExtent:T,width:L,height:B,inversePan:m,pannable:w,zoomStep:h,zoomable:S})},[w,S,m,h,T,L,B]);const ne=v?J=>{var K;const[re,te]=((K=G.current)==null?void 0:K.pointer(J))||[0,0];v(J,{x:re,y:te})}:void 0,ee=x?C.useCallback((J,re)=>{const te=_.getState().nodeLookup.get(re).internals.userNode;x(J,te)},[]):void 0,Z=g??j["minimap.ariaLabel"];return u.jsx(Qs,{position:p,style:{...e,"--xy-minimap-background-color-props":typeof a=="string"?a:void 0,"--xy-minimap-mask-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-stroke-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-width-props":typeof d=="number"?d*b:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof s=="number"?s:void 0},className:Se(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:u.jsxs("svg",{width:$,height:z,viewBox:`${H} ${W} ${D} ${U}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":X,ref:k,onClick:ne,children:[Z&&u.jsx("title",{id:X,children:Z}),u.jsx(QN,{onClick:ee,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:o,nodeStrokeWidth:s,nodeComponent:l}),u.jsx("path",{className:"react-flow__minimap-mask",d:`M${H-A},${W-A}h${D+A*2}v${U+A*2}h${-D-A*2}z + M${M.x},${M.y}h${M.width}v${M.height}h${-M.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Zg.displayName="MiniMap";C.memo(Zg);const nC=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,rC={[$n.Line]:"right",[$n.Handle]:"bottom-right"};function oC({nodeId:e,position:t,variant:n=$n.Handle,className:r,style:o=void 0,children:i,color:s,minWidth:l=10,minHeight:a=10,maxWidth:c=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:p,autoScale:v=!0,shouldResize:x,onResizeStart:w,onResize:S,onResizeEnd:g}){const m=Mg(),h=typeof e=="string"?e:m,y=pe(),_=C.useRef(null),k=n===$n.Handle,E=ie(C.useCallback(nC(k&&v),[k,v]),he),M=C.useRef(null),I=t??rC[n];C.useEffect(()=>{if(!(!_.current||!h))return M.current||(M.current=gk({domNode:_.current,nodeId:h,getStoreItems:()=>{const{nodeLookup:T,transform:L,snapGrid:B,snapToGrid:j,nodeOrigin:$,domNode:z}=y.getState();return{nodeLookup:T,transform:L,snapGrid:B,snapToGrid:j,nodeOrigin:$,paneDomNode:z}},onChange:(T,L)=>{const{triggerNodeChanges:B,nodeLookup:j,parentLookup:$,nodeOrigin:z}=y.getState(),R=[],N={x:T.x,y:T.y},b=j.get(h);if(b&&b.expandParent&&b.parentId){const P=b.origin??z,O=T.width??b.measured.width??0,A=T.height??b.measured.height??0,H={id:b.id,parentId:b.parentId,rect:{width:O,height:A,...Gm({x:T.x??b.position.x,y:T.y??b.position.y},{width:O,height:A},b.parentId,j,P)}},W=dc([H],j,$,z);R.push(...W),N.x=T.x?Math.max(P[0]*O,T.x):void 0,N.y=T.y?Math.max(P[1]*A,T.y):void 0}if(N.x!==void 0&&N.y!==void 0){const P={id:h,type:"position",position:{...N}};R.push(P)}if(T.width!==void 0&&T.height!==void 0){const O={id:h,type:"dimensions",resizing:!0,setAttributes:p?p==="horizontal"?"width":"height":!0,dimensions:{width:T.width,height:T.height}};R.push(O)}for(const P of L){const O={...P,type:"position"};R.push(O)}B(R)},onEnd:({width:T,height:L})=>{const B={id:h,type:"dimensions",resizing:!1,dimensions:{width:T,height:L}};y.getState().triggerNodeChanges([B])}})),M.current.update({controlPosition:I,boundaries:{minWidth:l,minHeight:a,maxWidth:c,maxHeight:f},keepAspectRatio:d,resizeDirection:p,onResizeStart:w,onResize:S,onResizeEnd:g,shouldResize:x}),()=>{var T;(T=M.current)==null||T.destroy()}},[I,l,a,c,f,d,w,S,g,x]);const F=I.split("-");return u.jsx("div",{className:Se(["react-flow__resize-control","nodrag",...F,n,r]),ref:_,style:{...o,scale:E,...s&&{[k?"backgroundColor":"borderColor"]:s}},children:i})}const Af=C.memo(oC);function iC({nodeId:e,isVisible:t=!0,handleClassName:n,handleStyle:r,lineClassName:o,lineStyle:i,color:s,minWidth:l=10,minHeight:a=10,maxWidth:c=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:d=!1,autoScale:p=!0,shouldResize:v,onResizeStart:x,onResize:w,onResizeEnd:S}){return t?u.jsxs(u.Fragment,{children:[ck.map(g=>u.jsx(Af,{className:o,style:i,nodeId:e,position:g,variant:$n.Line,color:s,minWidth:l,minHeight:a,maxWidth:c,maxHeight:f,onResizeStart:x,keepAspectRatio:d,autoScale:p,shouldResize:v,onResize:w,onResizeEnd:S},g)),uk.map(g=>u.jsx(Af,{className:n,style:r,nodeId:e,position:g,color:s,minWidth:l,minHeight:a,maxWidth:c,maxHeight:f,onResizeStart:x,keepAspectRatio:d,autoScale:p,shouldResize:v,onResize:w,onResizeEnd:S},g))]}):null}const qa={compute:"#10b981",database:"#8b5cf6",storage:"#6366f1",network:"#3b82f6",security:"#ef4444",serverless:"#f59e0b",cache:"#8b5cf6",queue:"#f97316",cdn:"#3b82f6",monitoring:"#06b6d4",ml:"#ec4899",analytics:"#a855f7",containers:"#14b8a6",streaming:"#f97316",orchestration:"#a78bfa"},sC={ec2:"compute",ecs:"compute",eks:"compute",emr:"compute",fargate:"compute",codepipeline:"compute",codecommit:"storage",codebuild:"compute",dms:"compute",migration_hub:"compute",compute_engine:"compute",gke:"containers",app_engine:"serverless",cloud_build:"compute",virtual_machines:"compute",aks:"containers",container_apps:"containers",azure_devops:"compute",azure_migrate:"compute",rds:"database",aurora:"database",dynamodb:"database",cloud_sql:"database",azure_sql:"database",cosmos_db:"database",redshift:"database",bigquery:"database",firestore:"database",spanner:"database",alloydb:"database",s3:"storage",cloud_storage:"storage",blob_storage:"storage",ebs:"storage",ecr:"storage",fsx:"storage",efs:"storage",artifact_registry:"storage",alb:"network",nlb:"network",route53:"network",cloud_load_balancing:"network",app_gateway:"network",cloud_dns:"network",direct_connect:"network",vpn:"network",azure_lb:"network",azure_dns:"network",cloud_interconnect:"network",api_management:"network",cloudfront:"cdn",cloud_cdn:"cdn",azure_cdn:"cdn",waf:"security",cognito:"security",kms:"security",cloudtrail:"security",guardduty:"security",shield:"security",security_hub:"security",config:"security",inspector:"security",cloud_armor:"security",firebase_auth:"security",azure_waf:"security",azure_ad:"security",azure_firewall:"security",azure_sentinel:"security",azure_policy:"security",lambda:"serverless",api_gateway:"serverless",cloud_functions:"serverless",cloud_run:"serverless",azure_functions:"serverless",step_functions:"serverless",glue:"serverless",app_service:"serverless",elasticache:"cache",memorystore:"cache",azure_cache:"cache",sqs:"queue",sns:"queue",pub_sub:"queue",service_bus:"queue",kinesis:"queue",eventbridge:"queue",cloudwatch:"monitoring",cloud_logging:"monitoring",azure_monitor:"monitoring",sagemaker:"ml",vertex_ai:"ml",azure_ml:"ml",athena:"analytics",dataproc:"analytics",data_factory:"analytics",synapse:"analytics",dataflow:"streaming",event_hubs:"streaming",cloud_composer:"orchestration",logic_apps:"orchestration",databricks_sql_warehouse:"analytics",databricks_cluster:"compute",databricks_job:"orchestration",databricks_pipeline:"streaming",databricks_model_serving:"ml",databricks_unity_catalog:"security",databricks_vector_search:"database",databricks_genie:"analytics",databricks_notebook:"compute",databricks_secret_scope:"security",databricks_dashboard:"analytics",databricks_volume:"storage"},$f={compute:"M5 12H3l9-9 9 9h-2M5 12v7a2 2 0 002 2h10a2 2 0 002-2v-7",database:"M12 2C6.48 2 2 4.24 2 7v10c0 2.76 4.48 5 10 5s10-2.24 10-5V7c0-2.76-4.48-5-10-5zM2 12c0 2.76 4.48 5 10 5s10-2.24 10-5",storage:"M20 7H4a1 1 0 00-1 1v8a1 1 0 001 1h16a1 1 0 001-1V8a1 1 0 00-1-1zM4 12h16",network:"M12 2a10 10 0 100 20 10 10 0 000-20zm0 0a14.5 14.5 0 014 10 14.5 14.5 0 01-4 10 14.5 14.5 0 01-4-10A14.5 14.5 0 0112 2zM2 12h20",security:"M12 2l7 4v5c0 5.25-3.5 10.74-7 12-3.5-1.26-7-6.75-7-12V6l7-4z",serverless:"M13 2L3 14h9l-1 8 10-12h-9l1-8z",cache:"M4 4h16v4H4zM4 10h16v4H4zM4 16h16v4H4z",queue:"M4 6h16M4 12h16M4 18h16",cdn:"M12 2a10 10 0 100 20 10 10 0 000-20zm-1 17.93A8 8 0 013 12a8 8 0 018-7.93M12 2v20M2 12h20M4.22 7h15.56M4.22 17h15.56",monitoring:"M3 3v18h18M7 16l4-8 4 4 4-6",ml:"M12 2a4 4 0 014 4c0 1.95-1.4 3.57-3.24 3.9L12 14l-.76-4.1A4 4 0 018 6a4 4 0 014-4zM8 14h8M6 18h12M9 22h6",analytics:"M18 20V10M12 20V4M6 20v-6",containers:"M21 16V8a2 2 0 00-1-1.73l-7-4a2 2 0 00-2 0l-7 4A2 2 0 003 8v8a2 2 0 001 1.73l7 4a2 2 0 002 0l7-4A2 2 0 0021 16zM3.27 6.96L12 12l8.73-5.04M12 22.08V12",streaming:"M2 12c2-3 4-3 6 0s4 3 6 0 4-3 6 0 4 3 6 0",orchestration:"M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83"};function hc(e){return sC[e]||"compute"}function qg(e){return qa[e]||"#64748b"}function pc(e){return $f[e]||$f.compute}function lC({data:e}){const t=e,n=hc(t.service),r=qg(n),o=pc(n);return u.jsxs("div",{className:"node",style:{"--node-accent":r},children:[u.jsx(br,{type:"target",position:q.Top,style:{background:r}}),u.jsxs("div",{className:"node__head",children:[u.jsx("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{display:"block",padding:4,borderRadius:"var(--radius-sm)",background:`${r}22`,flexShrink:0},children:u.jsx("path",{d:o})}),u.jsx("span",{className:"node__cat",children:n})]}),u.jsx("div",{className:"node__label",children:t.label}),u.jsxs("div",{className:"node__meta",children:[u.jsx("span",{children:t.service}),u.jsx("span",{className:"badge badge--neutral",children:t.provider})]}),t.monthlyCost!=null&&t.monthlyCost>0&&u.jsxs("div",{className:"node__cost",children:["$",t.monthlyCost.toFixed(0),"/mo"]}),u.jsx(br,{type:"source",position:q.Bottom,style:{background:r}})]})}const aC=C.memo(lC);function uC({data:e,selected:t}){return u.jsxs(u.Fragment,{children:[u.jsx(iC,{color:e.dotColor,isVisible:t??!1,minWidth:200,minHeight:100,lineStyle:{borderWidth:1.5},handleStyle:{width:8,height:8,borderRadius:2}}),u.jsxs("div",{style:{position:"absolute",top:6,left:8,display:"inline-flex",alignItems:"center",gap:5,padding:"3px 10px 3px 7px",borderRadius:5,background:e.labelBg,border:`1px solid ${e.dotColor}30`,boxShadow:"0 1px 2px rgba(0,0,0,0.04)",pointerEvents:"none"},children:[u.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:e.dotColor,flexShrink:0}}),u.jsx("span",{style:{color:e.labelColor,fontSize:11,fontWeight:600,letterSpacing:"0.02em",whiteSpace:"nowrap",lineHeight:1},children:e.label})]})]})}const Rf={cloud:"M17.5 19a4.5 4.5 0 00.5-8.97A6 6 0 006.08 11.5 3.5 3.5 0 006.5 19h11z",send:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z",stop:"M7 7h10v10H7z",plus:"M12 5v14M5 12h14",close:"M6 6l12 12M18 6L6 18",chevron:"M6 9l6 6 6-6",check:"M4 12.5l5 5 11-11",cross:"M6 6l12 12M18 6L6 18",sun:"M12 4V2M12 22v-2M4 12H2M22 12h-2M5.6 5.6L4.2 4.2M19.8 19.8l-1.4-1.4M18.4 5.6l1.4-1.4M4.2 19.8l1.4-1.4M16 12a4 4 0 11-8 0 4 4 0 018 0z",moon:"M20 14.5A8.5 8.5 0 019.5 4a8.5 8.5 0 1010.5 10.5z",download:"M12 3v12M7 11l5 5 5-5M4 20h16",copy:"M9 9h10v10H9zM5 15V5h10",search:"M11 19a8 8 0 100-16 8 8 0 000 16zM21 21l-4.5-4.5",layers:"M12 3l9 5-9 5-9-5 9-5zM3 13l9 5 9-5M3 17l9 5 9-5",alert:"M12 8v5M12 17h.01M10.3 3.9L2.4 17.5A2 2 0 004.1 20.5h15.8a2 2 0 001.7-3L13.7 3.9a2 2 0 00-3.4 0z",panel:"M4 4h16v16H4zM10 4v16",grid:"M4 4h7v7H4zM13 4h7v7h-7zM4 13h7v7H4zM13 13h7v7h-7z",chat:"M21 12a8 8 0 01-11.6 7.1L4 20l1-4.5A8 8 0 1121 12z",refresh:"M20 12a8 8 0 10-2.3 5.6M20 6v6h-6"};function ue({name:e,size:t=16,strokeWidth:n=1.8,className:r}){const o=Rf[e]??Rf.cloud;return u.jsx("svg",{className:r,width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",style:{display:"block",flexShrink:0},children:u.jsx("path",{d:o})})}function cC({components:e}){const[t,n]=C.useState(!0),r=C.useMemo(()=>{if(!e||e.length===0)return Object.keys(qa).map(i=>({category:i,count:0}));const o={};for(const i of e){const s=hc(i.service);o[s]=(o[s]||0)+1}return Object.entries(o).sort(([,i],[,s])=>s-i).map(([i,s])=>({category:i,count:s}))},[e]);return u.jsxs("div",{className:"float-panel",style:{bottom:"var(--space-4)",right:"var(--space-4)",padding:"var(--space-2) var(--space-3)",maxHeight:280,overflowY:"auto",fontSize:"var(--text-xs)"},children:[u.jsxs("button",{onClick:()=>n(o=>!o),"aria-expanded":t,style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"var(--space-3)",width:"100%",border:"none",background:"transparent",cursor:"pointer",padding:0,marginBottom:t?6:0,fontSize:"var(--text-sm)",fontWeight:650,color:"var(--text)"},children:["Legend",u.jsx("span",{style:{transform:t?"none":"rotate(-90deg)",transition:"transform 160ms"},children:u.jsx(ue,{name:"chevron",size:13,strokeWidth:2})})]}),t&&r.map(({category:o,count:i})=>{const s=qa[o]||"currentColor";return u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:3,color:"var(--text-muted)"},children:[u.jsx("svg",{width:12,height:12,viewBox:"0 0 24 24",fill:"none",stroke:s,strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flexShrink:0},children:u.jsx("path",{d:pc(o)})}),u.jsx("span",{style:{textTransform:"capitalize"},children:o}),i>0&&u.jsxs("span",{style:{color:"var(--text-subtle)"},children:["(",i,")"]})]},o)})]})}function dC({onExportSvg:e,onExportPng:t,showBoundaries:n,onToggleBoundaries:r}){return u.jsxs("div",{className:"float-panel",style:{top:"var(--space-4)",right:"var(--space-4)",display:"flex",gap:4,padding:4},role:"group","aria-label":"Diagram controls",children:[e&&u.jsxs("button",{className:"btn btn--ghost btn--sm",onClick:e,title:"Download the diagram as SVG",children:[u.jsx(ue,{name:"download",size:13}),"SVG"]}),t&&u.jsxs("button",{className:"btn btn--ghost btn--sm",onClick:t,title:"Download the diagram as PNG",children:[u.jsx(ue,{name:"download",size:13}),"PNG"]}),u.jsxs("button",{className:"btn btn--ghost btn--sm",onClick:r,"aria-pressed":n,title:"Show or hide the trust boundaries",children:[u.jsx(ue,{name:"panel",size:13}),u.jsx("span",{className:"hide-narrow",children:"Boundaries"})]})]})}function Jg(e){return typeof e=="boolean"?e?"true":"false":e==null?"":String(e)}function fC(e,t){return Object.entries(e??{}).filter(([n,r])=>r!=null&&n!=="tags").map(([n,r])=>`${n}=${Jg(r)}`).join(` +`)}function hC(e){const t=e==null?void 0:e.tags;return!t||typeof t!="object"||Array.isArray(t)?"":Object.entries(t).map(([n,r])=>`${n}=${Jg(r)}`).join(` +`)}function pC(e){const t=e.trim();return t==="true"?!0:t==="false"?!1:t!==""&&!Number.isNaN(Number(t))?Number(t):e}function Df(e){const t={};for(const n of e.split(` +`)){const r=n.trim();if(!r)continue;const o=r.indexOf("=");if(o===-1){t[r]=!0;continue}const i=r.slice(0,o).trim();i&&(t[i]=pC(r.slice(o+1)))}return t}function mC({component:e,cost:t,onClose:n,onApply:r,onDelete:o}){const[i,s]=C.useState(""),[l,a]=C.useState(""),[c,f]=C.useState("2"),[d,p]=C.useState(""),[v,x]=C.useState("");C.useEffect(()=>{e&&(s(e.label),a(e.description??""),f(String(e.tier??2)),p(fC(e.config)),x(hC(e.config)))},[e]),C.useEffect(()=>{if(!e)return;const y=_=>{_.key==="Escape"&&n()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[e,n]);const w=C.useMemo(()=>{const y=Number(c);return Number.isFinite(y)?y:2},[c]);if(!e)return null;const S=hc(e.service),g=qg(S),m=(t==null?void 0:t.monthly)??null,h=()=>{const y=Df(d),_=Df(v);Object.keys(_).length>0&&(y.tags=_),r({...e,label:i.trim()||e.label,description:l,tier:w,config:y})};return u.jsxs("aside",{className:"drawer drawer--right","aria-label":`Edit ${e.label}`,style:{animation:"cw-rise var(--duration) var(--ease)"},children:[u.jsxs("div",{className:"drawer__header",children:[u.jsxs("div",{className:"drawer__title",children:[u.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)",minWidth:0},children:[u.jsx("span",{style:{width:32,height:32,borderRadius:"var(--radius)",background:`${g}22`,border:`1.5px solid ${g}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:u.jsx("svg",{width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:g,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:u.jsx("path",{d:pc(S)})})}),u.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.label})]}),u.jsx("button",{className:"btn btn--ghost btn--icon",onClick:n,"aria-label":"Close panel",children:u.jsx(ue,{name:"close",size:15})})]}),u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)",marginTop:"var(--space-2)"},children:[u.jsx("span",{className:"badge badge--neutral",children:e.provider}),u.jsx("code",{className:"inline",children:e.service}),m!==null&&u.jsxs("span",{style:{marginLeft:"auto",color:"var(--accent-text)",fontWeight:650,fontSize:"var(--text-base)"},children:["$",m.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2}),"/mo"]})]})]}),u.jsxs("div",{className:"drawer__body",children:[u.jsx("p",{className:"section-label",style:{marginBottom:"var(--space-2)"},children:"Overview"}),u.jsx("label",{className:"field-label",htmlFor:"resource-label",children:"Label"}),u.jsx("input",{id:"resource-label",className:"field",value:i,onChange:y=>s(y.target.value),style:{marginBottom:"var(--space-3)"}}),u.jsx("label",{className:"field-label",htmlFor:"resource-description",children:"Description"}),u.jsx("textarea",{id:"resource-description",className:"field",value:l,onChange:y=>a(y.target.value),rows:3,style:{marginBottom:"var(--space-3)",resize:"vertical"}}),u.jsx("label",{className:"field-label",htmlFor:"resource-tier",children:"Tier"}),u.jsx("input",{id:"resource-tier",className:"field",type:"number",value:c,onChange:y=>f(y.target.value),style:{marginBottom:"var(--space-4)"}}),u.jsxs("label",{className:"field-label",htmlFor:"resource-config",children:["Configuration, one ",u.jsx("code",{className:"inline",children:"key=value"})," per line"]}),u.jsx("textarea",{id:"resource-config",className:"field field--mono",value:d,onChange:y=>p(y.target.value),rows:7,style:{marginBottom:"var(--space-4)",minHeight:130}}),u.jsx("label",{className:"field-label",htmlFor:"resource-tags",children:"Tags"}),u.jsx("textarea",{id:"resource-tags",className:"field field--mono",value:v,onChange:y=>x(y.target.value),rows:4,style:{minHeight:96}})]}),u.jsxs("div",{className:"drawer__footer",children:[u.jsx("button",{className:"btn btn--primary",style:{flex:1},onClick:h,children:"Apply"}),u.jsx("button",{className:"btn btn--danger",onClick:()=>o(e.id),children:"Delete"})]})]})}const Of="/api",gC=["resources","modules","standards"];function yC({provider:e,standardsResult:t,onAddResource:n,onAddModule:r,onCheckStandards:o}){const i=(e||"aws").toLowerCase(),[s,l]=C.useState(!1),[a,c]=C.useState("resources"),[f,d]=C.useState(""),[p,v]=C.useState([]),[x,w]=C.useState([]);C.useEffect(()=>{s&&fetch(`${Of}/catalog/services?provider=${encodeURIComponent(i)}`).then(m=>m.ok?m.json():null).then(m=>v((m==null?void 0:m.services)??[])).catch(()=>v([]))},[i,s]),C.useEffect(()=>{s&&fetch(`${Of}/modules`).then(m=>m.ok?m.json():null).then(m=>w((m==null?void 0:m.modules)??[])).catch(()=>w([]))},[s]),C.useEffect(()=>{if(!s)return;const m=h=>{h.key==="Escape"&&l(!1)};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[s]);const S=C.useMemo(()=>{const m=f.trim().toLowerCase();return m?p.filter(h=>[h.name,h.service_key,h.category,h.description??""].some(y=>y.toLowerCase().includes(m))):p},[p,f]),g=C.useMemo(()=>{const m=f.trim().toLowerCase(),h=x.filter(y=>y.provider.toLowerCase()===i);return m?h.filter(y=>[y.name,y.id,y.category,y.description??"",...y.tags??[]].some(_=>_.toLowerCase().includes(m))):h},[x,i,f]);return s?u.jsxs("aside",{className:"drawer drawer--left","aria-label":"Service catalog",children:[u.jsxs("div",{className:"drawer__header",children:[u.jsxs("div",{className:"drawer__title",children:["Catalog",u.jsx("button",{className:"btn btn--ghost btn--icon",onClick:()=>l(!1),"aria-label":"Close catalog",children:u.jsx(ue,{name:"close",size:15})})]}),u.jsx("div",{role:"tablist","aria-label":"Catalog sections",style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:4,margin:"var(--space-3) 0 var(--space-2)"},children:gC.map(m=>u.jsx("button",{role:"tab","aria-selected":a===m,tabIndex:a===m?0:-1,className:"btn btn--sm",onClick:()=>c(m),style:a===m?{background:"var(--accent-soft)",borderColor:"var(--accent)",color:"var(--accent-text)",textTransform:"capitalize"}:{textTransform:"capitalize"},children:m},m))}),a!=="standards"&&u.jsx("input",{className:"field",value:f,onChange:m=>d(m.target.value),placeholder:"Search the catalog","aria-label":"Search the catalog",type:"search"})]}),u.jsxs("div",{className:"drawer__body",children:[a==="resources"&&S.map(m=>u.jsxs("button",{className:"list-btn",onClick:()=>n(m),children:[u.jsxs("span",{style:{display:"flex",justifyContent:"space-between",gap:"var(--space-2)"},children:[u.jsx("span",{style:{fontSize:"var(--text-base)",fontWeight:650},children:m.name}),u.jsx("span",{className:"section-label",style:{fontSize:"var(--text-2xs)"},children:m.category.replace(/_/g," ")})]}),u.jsx("span",{style:{display:"block",color:"var(--text-subtle)",fontSize:"var(--text-xs)",marginTop:3},children:m.service_key})]},`${m.provider}:${m.service_key}`)),a==="resources"&&S.length===0&&u.jsxs("p",{style:{color:"var(--text-subtle)",fontSize:"var(--text-base)"},children:["No resources match that search for ",i.toUpperCase(),"."]}),a==="modules"&&g.map(m=>u.jsxs("button",{className:"list-btn",onClick:()=>r(m.id),style:{borderColor:"var(--accent)",background:"var(--accent-soft)"},children:[u.jsx("span",{style:{display:"block",fontSize:"var(--text-base)",fontWeight:650},children:m.name}),u.jsx("span",{style:{display:"block",color:"var(--text-muted)",fontSize:"var(--text-sm)",marginTop:3,lineHeight:1.4},children:m.description}),u.jsx("span",{className:"section-label",style:{display:"block",marginTop:6,color:"var(--accent-text)"},children:m.category})]},m.id)),a==="modules"&&g.length===0&&u.jsxs("p",{style:{color:"var(--text-subtle)",fontSize:"var(--text-base)"},children:["No approved modules match that search for ",i.toUpperCase(),"."]}),a==="standards"&&u.jsxs(u.Fragment,{children:[u.jsx("button",{className:"btn btn--block",onClick:o,style:{marginBottom:"var(--space-3)"},children:"Check Standards"}),!t&&u.jsx("p",{style:{color:"var(--text-subtle)",fontSize:"var(--text-base)"},children:"No standards check has run."}),(t==null?void 0:t.passed)&&u.jsx("div",{className:"callout callout--success",children:"Standards passed."}),t&&!t.passed&&t.violations.map((m,h)=>u.jsxs("div",{className:"callout callout--danger",style:{marginBottom:"var(--space-2)"},children:[u.jsx("strong",{style:{display:"block",fontSize:"var(--text-sm)",textTransform:"uppercase",letterSpacing:"0.04em"},children:m.code.replace(/_/g," ")}),u.jsx("span",{style:{display:"block",marginTop:4,lineHeight:1.45},children:m.message})]},`${m.code}:${h}`))]})]})]}):u.jsxs("button",{className:"btn",onClick:()=>l(!0),"aria-expanded":!1,style:{position:"absolute",left:"var(--space-4)",top:"var(--space-4)",zIndex:15,boxShadow:"var(--shadow)"},children:[u.jsx(ue,{name:"plus",size:14}),"Add Resource"]})}function ey({open:e,title:t,body:n,confirmLabel:r="Confirm",destructive:o=!1,onConfirm:i,onCancel:s}){const l=C.useRef(null);return C.useEffect(()=>{const a=l.current;a&&(e&&!a.open&&a.showModal(),!e&&a.open&&a.close())},[e]),u.jsxs("dialog",{ref:l,className:"modal","aria-labelledby":"confirm-title",onCancel:a=>{a.preventDefault(),s()},onClose:s,children:[u.jsx("h2",{className:"modal__title",id:"confirm-title",children:t}),u.jsx("p",{className:"modal__text",children:n}),u.jsxs("div",{className:"modal__actions",children:[u.jsx("button",{className:"btn",onClick:s,children:"Cancel"}),u.jsx("button",{className:o?"btn btn--danger":"btn btn--primary",onClick:i,autoFocus:!0,children:r})]})]})}async function jt(e){if(e.status===429){const t=e.headers.get("Retry-After"),n=t?` Retry after ${t}s.`:"";try{const r=await e.json();return`${r.message||r.detail||"Rate limited"}${n}`}catch{return`Rate limited.${n}`}}try{const t=await e.json();return ty(t,e.statusText)}catch{return e.statusText||"Request failed"}}function ty(e,t="Request failed"){const n=e.message||e.detail||t;return e.suggestion?`${n} ${e.suggestion}`:n}const ny=C.createContext({notify:()=>{}});function vC({children:e}){const[t,n]=C.useState([]),r=C.useCallback(s=>{n(l=>l.filter(a=>a.id!==s))},[]),o=C.useCallback((s,l="error")=>{const a=Date.now()+Math.random();n(c=>[...c.slice(-3),{id:a,kind:l,text:s}]),window.setTimeout(()=>r(a),l==="success"?3e3:8e3)},[r]),i=C.useMemo(()=>({notify:o}),[o]);return u.jsxs(ny.Provider,{value:i,children:[e,u.jsx("div",{className:"toasts",role:"status","aria-live":"polite",children:t.map(s=>u.jsxs("div",{className:`toast${s.kind==="success"?" toast--success":""}`,children:[u.jsx(ue,{name:s.kind==="success"?"check":"alert",size:15}),u.jsx("span",{children:s.text}),u.jsx("button",{className:"toast__close",onClick:()=>r(s.id),"aria-label":"Dismiss",children:u.jsx(ue,{name:"close",size:14})})]},s.id))})]})}function ry(){return C.useContext(ny)}const Ff=200,Si=90,Bf=300,xC=240,_t=32,wC=36,Ur=4,Ol="/api",_C={0:"Edge / CDN",1:"Network / Ingress",2:"Application",3:"Data Layer",4:"Platform Services",5:"Platform Services"},SC={0:"edge",1:"subnet",2:"subnet",3:"subnet"},Fl={0:{border:"#60a5fa",bg:"rgba(219, 234, 254, 0.18)",labelColor:"#1d4ed8",labelBg:"rgba(219, 234, 254, 0.92)",dot:"#3b82f6"},1:{border:"#34d399",bg:"rgba(209, 250, 229, 0.18)",labelColor:"#047857",labelBg:"rgba(209, 250, 229, 0.92)",dot:"#10b981"},2:{border:"#fb923c",bg:"rgba(255, 237, 213, 0.18)",labelColor:"#9a3412",labelBg:"rgba(255, 237, 213, 0.92)",dot:"#f97316"},3:{border:"#a78bfa",bg:"rgba(237, 233, 254, 0.18)",labelColor:"#5b21b6",labelBg:"rgba(237, 233, 254, 0.92)",dot:"#8b5cf6"},4:{border:"#2dd4bf",bg:"rgba(204, 251, 241, 0.18)",labelColor:"#0f766e",labelBg:"rgba(204, 251, 241, 0.92)",dot:"#14b8a6"},5:{border:"#2dd4bf",bg:"rgba(204, 251, 241, 0.18)",labelColor:"#0f766e",labelBg:"rgba(204, 251, 241, 0.92)",dot:"#14b8a6"}},Wn={border:"#64748b",bg:"rgba(241, 245, 249, 0.35)",labelColor:"#475569",labelBg:"rgba(241, 245, 249, 0.92)",dot:"#64748b"},kC={cloudService:aC,boundaryGroup:uC};function Ja(e){return JSON.parse(JSON.stringify(e))}function ki(e){return Ja(e??{})}function Ni(e,t="resource"){let n=e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"_").replace(/^[_-]+|[_-]+$/g,"");return n||(n=t),/^[a-z_]/.test(n)||(n=`${t}_${n}`),n}function Bl(e,t){let n=e,r=2;for(;t.has(n);)n=`${e}-${r}`,r+=1;return t.add(n),n}function NC(e){const t=e.toLowerCase();return t.includes("cdn")||t.includes("edge")?0:t.includes("network")||t.includes("security")?1:t.includes("database")||t.includes("cache")?3:t.includes("storage")||t.includes("analytics")||t.includes("data")?4:2}function Hf(e){return{x:360+e%3*260,y:80+Math.floor(e/3)*150}}function CC(e,t){if(t==="vpc")return Wn;const n=e.match(/^tier-(\d+)$/);return n&&Fl[parseInt(n[1])]||Fl[2]}function EC(e){const t={};for(const i of e){const s=i.tier??2;t[s]||(t[s]=[]),t[s].push(i.id)}const n=Object.keys(t).map(Number).sort(),r=[];for(const i of n)r.push({id:`tier-${i}`,kind:SC[i]||"subnet",label:_C[i]||`Tier ${i}`,component_ids:t[i]});const o=r.filter(i=>i.id!=="tier-0").flatMap(i=>i.component_ids);return o.length>=2&&r.unshift({id:"vpc",kind:"vpc",label:"VPC",component_ids:o}),r}function bC(e,t,n){var x,w,S,g;const r=[],o=e.boundaries||[],i=o.length>0?o:EC(e.components),s=((w=(x=e.metadata)==null?void 0:x.canvas)==null?void 0:w.nodes)??{},l={};if(t){for(const m of i)if(m.kind!=="vpc")for(const h of m.component_ids)l[h]||(l[h]=m.id)}const a={};for(const m of e.components){const h=m.tier??2;a[h]||(a[h]=[]),a[h].push(m)}const c=Object.keys(a).map(Number).sort(),f={};let d=40;const p={};for(const m of c){p[m]=d;const h=Math.ceil(a[m].length/Ur);d+=xC+(h-1)*(Si+60)}for(const m of c){const h=a[m],y=p[m];for(let _=0;_0){const m=i.find(y=>y.kind==="vpc");let h;if(m&&m.component_ids.length>0){const y=m.component_ids.map(F=>{var T;return((T=f[F])==null?void 0:T.x)??0}),_=m.component_ids.map(F=>{var T;return((T=f[F])==null?void 0:T.y)??0}),k=Math.min(...y)-_t,E=Math.min(..._)-_t-24-wC,M=Math.max(...y)+Ff+_t,I=Math.max(..._)+Si+_t;h=`boundary-${m.id}`,v[m.id]={x:k,y:E},r.push({id:h,type:"boundaryGroup",position:{x:k,y:E},data:{label:m.label||m.id,labelColor:Wn.labelColor,labelBg:Wn.labelBg,dotColor:Wn.dot},style:{background:Wn.bg,border:`2px dashed ${Wn.border}`,borderRadius:16,padding:_t,width:M-k,height:I-E},zIndex:-2})}for(const y of i){if(y.kind==="vpc"||y.component_ids.length===0)continue;const _=y.component_ids.map(B=>{var j;return((j=f[B])==null?void 0:j.x)??0}),k=y.component_ids.map(B=>{var j;return((j=f[B])==null?void 0:j.y)??0}),E=Math.min(..._)-_t,M=Math.min(...k)-_t-24,I=Math.max(..._)+Ff+_t,F=Math.max(...k)+Si+_t;v[y.id]={x:E,y:M};const T=CC(y.id,y.kind),L=!!(h&&m&&y.component_ids.some(B=>m.component_ids.includes(B)));r.push({id:`boundary-${y.id}`,type:"boundaryGroup",position:L?{x:E-v[m.id].x,y:M-v[m.id].y}:{x:E,y:M},data:{label:y.label||y.id,labelColor:T.labelColor,labelBg:T.labelBg,dotColor:T.dot},style:{background:T.bg,border:`1.5px solid ${T.border}`,borderRadius:10,padding:_t,width:I-E,height:F-M},zIndex:-1,parentId:L?h:void 0})}}for(const m of c){const h=a[m];for(const y of h){const _=l[y.id],k=t&&_&&v[_];let E=((S=f[y.id])==null?void 0:S.x)??0,M=((g=f[y.id])==null?void 0:g.y)??0;k&&(E-=v[_].x,M-=v[_].y),r.push({id:y.id,type:"cloudService",position:{x:E,y:M},data:{label:y.label,service:y.service,provider:y.provider,description:y.description,tier:y.tier,config:y.config||{},monthlyCost:n[y.id]},parentId:k?`boundary-${_}`:void 0,extent:k?"parent":void 0})}}return r}function oy(e,t){return`edge:${e.source}:${e.target}:${t}`}function Vf(e){return e.connections.map((t,n)=>{let r=t.label||"";return t.protocol&&!r.includes(t.protocol)&&(r=t.protocol+(t.port?`:${t.port}`:"")),{id:oy(t,n),source:t.source,target:t.target,label:r,style:{stroke:"var(--border-strong)"},labelStyle:{fill:"var(--text-muted)",fontSize:11,fontWeight:600},labelShowBg:!0,labelBgStyle:{fill:"var(--surface)",stroke:"var(--border)"},labelBgPadding:[6,3],labelBgBorderRadius:4,animated:!0}})}function jC(e,t){return e&&e.map(n=>({...n,component_ids:n.component_ids.filter(r=>r!==t)}))}function MC({signature:e}){const{fitView:t}=Zs();return C.useEffect(()=>{const n=window.setTimeout(()=>{t({padding:.16,duration:250})},60);return()=>window.clearTimeout(n)},[e,t]),null}function TC({spec:e,onSpecChange:t}){const[n,r]=C.useState(!0),[o,i]=C.useState(null),[s,l]=C.useState(null),[a,c]=C.useState(null),{notify:f}=ry(),d=C.useCallback(N=>{l(null),t(N)},[t]),p=C.useCallback(async N=>{try{const b=await fetch(`${Ol}/export`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({spec:e,format:N})});if(!b.ok){f(await jt(b));return}const P=await b.blob(),O=URL.createObjectURL(P),A=document.createElement("a");A.href=O,A.download=`architecture.${N}`,A.click(),URL.revokeObjectURL(O)}catch{f(`The ${N.toUpperCase()} export failed. Check that the server is still running.`)}},[f,e]),v=C.useMemo(()=>{var b;const N={};for(const P of((b=e.cost_estimate)==null?void 0:b.breakdown)??[])N[P.component_id]=P.monthly;return N},[e.cost_estimate]),x=C.useMemo(()=>o?e.components.find(N=>N.id===o)??null:null,[o,e.components]),w=C.useMemo(()=>{var N;return o?((N=e.cost_estimate)==null?void 0:N.breakdown.find(b=>b.component_id===o))??null:null},[o,e.cost_estimate]),[S,g,m]=TN([]),[h,y,_]=PN([]),k=C.useMemo(()=>`${n}:${e.components.map(N=>N.id).sort().join(",")}`,[n,e.components]);C.useEffect(()=>{g(bC(e,n,v)),y(Vf(e))},[e,n,v,g,y]);const E=C.useCallback((N,b)=>{b.id.startsWith("boundary-")||i(b.id)},[]),M=C.useCallback(()=>{i(null)},[]),I=C.useCallback((N,b)=>{if(b.id.startsWith("boundary-"))return;const P=ki(e.metadata),O=P.canvas??{},A={...O.nodes??{}},H=S.find(D=>D.id===b.parentId),W=H?{x:H.position.x+b.position.x,y:H.position.y+b.position.y}:{x:b.position.x,y:b.position.y};A[b.id]=W,P.canvas={...O,nodes:A},d({...e,metadata:P})},[d,S,e]),F=C.useCallback(N=>{!N.source||!N.target||N.source===N.target||e.connections.some(P=>P.source===N.source&&P.target===N.target)||d({...e,connections:[...e.connections,{source:N.source,target:N.target,label:"HTTPS",protocol:"HTTPS",port:443}]})},[d,e]),T=C.useCallback(N=>{N.length!==0&&(y(Vf(e)),c({kind:"edges",ids:N.map(b=>b.id)}))},[y,e]),L=C.useCallback(()=>{var O,A;if(!a)return;if(a.kind==="edges"){const H=new Set(a.ids);d({...e,connections:e.connections.filter((W,D)=>!H.has(oy(W,D)))}),c(null);return}const N=a.id,b=ki(e.metadata);(O=b.canvas)!=null&&O.nodes&&delete b.canvas.nodes[N];const P=((A=b.modules)==null?void 0:A.instances)??{};for(const H of Object.values(P))H.component_ids.includes(N)&&(H.component_ids=H.component_ids.filter(W=>W!==N),H.partial=!0,H.approved=!1,delete H.terraform);b.modules&&(b.modules.instances=P),d({...e,components:e.components.filter(H=>H.id!==N),connections:e.connections.filter(H=>H.source!==N&&H.target!==N),boundaries:jC(e.boundaries,N),metadata:b}),i(null),c(null)},[d,a,e]),B=C.useCallback(N=>{d({...e,components:e.components.map(b=>b.id===N.id?N:b)})},[d,e]),j=C.useCallback(N=>{const b=e.components.find(P=>P.id===N);b&&c({kind:"component",id:N,label:b.label||b.id})},[e.components]),$=C.useCallback(N=>{const b=new Set(e.components.map(D=>D.id)),P=Bl(Ni(N.service_key),b),O=ki(e.metadata),A=O.canvas??{},H={...A.nodes??{}};H[P]=Hf(Object.keys(H).length+e.components.length),O.canvas={...A,nodes:H};const W={id:P,service:N.service_key,provider:N.provider.toLowerCase(),label:N.name,description:N.description??"",tier:NC(N.category),config:Ja(N.default_config??{})};d({...e,components:[...e.components,W],metadata:O}),i(P)},[d,e]),z=C.useCallback(async N=>{var b;try{const P=await fetch(`${Ol}/modules/${encodeURIComponent(N)}`);if(!P.ok){f(await jt(P));return}const A=(await P.json()).module,H=new Set(e.components.map(K=>K.id)),W=ki(e.metadata),D=W.modules??{},U={...D.instances??{}},X=new Set(Object.keys(U)),V=Bl(Ni(A.id,"module"),X),G=Ni(A.naming.component_id_prefix,V),ne={};for(const K of A.fragment.components)ne[K.id]=Bl(Ni(`${G}_${K.id}`,G),H);const ee=W.canvas??{},Z={...ee.nodes??{}},J=Object.keys(Z).length+e.components.length,re=A.fragment.components.map((K,ve)=>{const Pe=Ja(K.config??{}),ke={...A.default_tags??{},...typeof Pe.tags=="object"&&Pe.tags!==null?Pe.tags:{}};Pe.tags=ke;const ze=ne[K.id];return Z[ze]=Hf(J+ve),{...K,id:ze,provider:K.provider.toLowerCase(),config:Pe}}),te=A.fragment.connections.map(K=>({...K,source:ne[K.source],target:ne[K.target]}));U[V]={module_id:A.id,module_version:A.terraform.version,component_ids:re.map(K=>K.id),expected_component_count:re.length,required_tags:[...A.required_tags],naming_prefix:G,approved:A.approved,terraform:{...A.terraform}},W.canvas={...ee,nodes:Z},W.modules={...D,instances:U},d({...e,components:[...e.components,...re],connections:[...e.connections,...te],metadata:W}),i(((b=re[0])==null?void 0:b.id)??null)}catch{f("That module could not be added. Check that the server is still running.")}},[d,f,e]),R=C.useCallback(async()=>{try{const N=await fetch(`${Ol}/canvas/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({spec:e})});if(!N.ok){f(await jt(N));return}l(await N.json())}catch{l({passed:!1,violations:[{code:"request_failed",severity:"error",message:"Standards check failed."}]})}},[f,e]);return u.jsxs("div",{style:{width:"100%",height:"100%",position:"relative"},children:[u.jsx(yC,{provider:e.provider||"aws",standardsResult:s,onAddResource:$,onAddModule:z,onCheckStandards:R}),u.jsxs(MN,{nodes:S,edges:h,nodeTypes:kC,onNodesChange:m,onEdgesChange:_,onEdgesDelete:T,onConnect:F,onNodeDragStop:I,fitView:!0,proOptions:{hideAttribution:!0},style:{background:"var(--canvas)"},onNodeClick:E,onPaneClick:M,children:[u.jsx($N,{color:"var(--canvas-dot)",gap:20}),u.jsx(VN,{}),u.jsx(MC,{signature:k})]}),u.jsx(cC,{components:e.components}),u.jsx(dC,{showBoundaries:n,onToggleBoundaries:()=>r(N=>!N),onExportSvg:()=>p("svg"),onExportPng:()=>p("png")}),u.jsx(mC,{component:x??null,cost:w,onClose:()=>i(null),onApply:N=>B({...N,description:N.description??"",config:N.config??{}}),onDelete:j}),u.jsx(ey,{open:a!==null,title:(a==null?void 0:a.kind)==="component"?"Delete this component?":"Delete this connection?",body:(a==null?void 0:a.kind)==="component"?`${a.label} and every connection into or out of it are removed from the spec.`:(a==null?void 0:a.kind)==="edges"?`${a.ids.length} connection${a.ids.length===1?"":"s"} removed from the spec.`:"",confirmLabel:"Delete",destructive:!0,onConfirm:L,onCancel:()=>c(null)})]})}function PC({estimate:e}){const t=e.breakdown.reduce((n,r)=>Math.max(n,r.monthly),0);return u.jsxs("div",{className:"panel__body",children:[u.jsx("h2",{className:"panel__title",children:"Cost Breakdown"}),u.jsx("p",{className:"panel__lede",children:"Per-component monthly price from the built-in catalog, at the region on the spec. The bar shows each line item against the largest one."}),u.jsx("div",{className:"table-wrap",children:u.jsxs("table",{className:"data",children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsx("th",{scope:"col",children:"Component"}),u.jsx("th",{scope:"col",children:"Service"}),u.jsx("th",{scope:"col",style:{textAlign:"right"},children:"Monthly"}),u.jsx("th",{scope:"col",children:"Share"}),u.jsx("th",{scope:"col",children:"Notes"})]})}),u.jsx("tbody",{children:e.breakdown.map(n=>u.jsxs("tr",{children:[u.jsx("td",{children:n.component_id}),u.jsx("td",{children:u.jsx("code",{className:"inline",children:n.service})}),u.jsxs("td",{className:"num",children:["$",n.monthly.toFixed(2)]}),u.jsx("td",{style:{minWidth:110},children:u.jsx("span",{"aria-hidden":"true",style:{display:"block",height:6,borderRadius:3,background:"var(--accent)",opacity:.85,width:`${t>0?Math.max(3,n.monthly/t*100):0}%`}})}),u.jsx("td",{style:{color:"var(--text-muted)",fontSize:"var(--text-sm)"},children:n.notes})]},n.component_id))}),u.jsx("tfoot",{children:u.jsxs("tr",{children:[u.jsx("td",{colSpan:2,children:"Total"}),u.jsxs("td",{className:"num",style:{color:"var(--accent-text)"},children:["$",e.monthly_total.toFixed(2)]}),u.jsxs("td",{colSpan:2,style:{color:"var(--text-muted)",fontWeight:400,fontSize:"var(--text-sm)"},children:[e.currency," per month"]})]})})]})})]})}function zC({spec:e,onDownloadTerraform:t,onDownloadYaml:n,validationSummary:r,usage:o}){var l,a;if(!e)return null;const i=[];o!=null&&o.model&&i.push(o.model.replace("claude-","").replace("anthropic.","")),(o==null?void 0:o.input_tokens)!=null&&(o==null?void 0:o.output_tokens)!=null&&i.push(`${((o.input_tokens+o.output_tokens)/1e3).toFixed(1)}k tokens`),(o==null?void 0:o.cost_usd)!=null&&i.push(`$${o.cost_usd.toFixed(4)}`),(o==null?void 0:o.latency_ms)!=null&&i.push(`${(o.latency_ms/1e3).toFixed(1)}s`);const s=r?r.passed===r.total:!1;return u.jsxs("div",{className:"summary",children:[u.jsxs("span",{className:"summary__stat",children:["Components: ",u.jsx("strong",{children:((l=e.components)==null?void 0:l.length)||0})]}),e.cost_estimate&&u.jsxs("span",{className:"summary__stat summary__stat--accent",children:["Est. ",u.jsxs("strong",{children:["$",(a=e.cost_estimate.monthly_total)==null?void 0:a.toFixed(0),"/mo"]})]}),u.jsxs("span",{className:"summary__stat",children:[u.jsx("strong",{children:(e.provider||"aws").toUpperCase()})," ",e.region||"us-east-1"]}),r&&u.jsxs("span",{className:`badge ${s?"badge--success":"badge--danger"}`,title:"Well-Architected checks passed out of total",children:["WA: ",r.passed,"/",r.total]}),i.length>0&&u.jsx("span",{className:"summary__stat",style:{fontSize:"var(--text-sm)"},children:i.join(" / ")}),u.jsxs("div",{className:"summary__actions",children:[t&&u.jsxs("button",{className:"btn btn--primary btn--sm",onClick:t,children:[u.jsx(ue,{name:"download",size:13}),"Download Terraform"]}),n&&u.jsx("button",{className:"btn btn--sm",onClick:n,children:"Download YAML"})]})]})}function Rn({icon:e="layers",title:t,hint:n,action:r}){return u.jsxs("div",{className:"empty",children:[u.jsx(ue,{className:"empty__icon",name:e,size:34,strokeWidth:1.4}),u.jsx("p",{className:"empty__title",children:t}),n&&u.jsx("p",{className:"empty__hint",children:n}),r&&u.jsx("button",{className:"btn btn--primary",onClick:r.onClick,children:r.label})]})}const IC=[{key:"hipaa",label:"HIPAA"},{key:"pci-dss",label:"PCI-DSS"},{key:"soc2",label:"SOC 2"},{key:"fedramp",label:"FedRAMP"},{key:"gdpr",label:"GDPR"},{key:"well-architected",label:"Well-Architected"}],qr={critical:0,high:1,medium:2,low:3},LC={data_protection:"Data Protection",monitoring:"Monitoring and Logging",identity:"Identity and Access",network_security:"Network Security",reliability:"Reliability",compliance:"Compliance",operations:"Operations",security:"Security",cost:"Cost Optimization"};function AC({score:e,passed:t}){const n=Math.round(e*100),r=48,o=8,i=2*Math.PI*r,s=i*(1-Math.max(0,Math.min(1,e))),l=t?"var(--success)":n>=70?"var(--warn)":"var(--danger)";return u.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"var(--space-2)"},children:[u.jsxs("svg",{width:120,height:120,viewBox:"0 0 120 120",role:"img","aria-label":`Score ${n} percent`,children:[u.jsx("circle",{cx:60,cy:60,r,fill:"none",stroke:"var(--bg-inset)",strokeWidth:o}),u.jsx("circle",{cx:60,cy:60,r,fill:"none",stroke:l,strokeWidth:o,strokeDasharray:i,strokeDashoffset:s,strokeLinecap:"round",transform:"rotate(-90 60 60)",style:{transition:"stroke-dashoffset 0.6s var(--ease)"}}),u.jsxs("text",{x:60,y:56,textAnchor:"middle",fontSize:26,fontWeight:700,fill:"var(--text)",children:[n,"%"]}),u.jsx("text",{x:60,y:75,textAnchor:"middle",fontSize:11,fill:"var(--text-subtle)",children:"checks passed"})]}),u.jsx("span",{className:`badge ${t?"badge--success":"badge--danger"}`,children:t?"Passed":"Failed"})]})}function Wf({check:e,expanded:t,onToggle:n}){const r=qr[e.severity]!==void 0?e.severity:"medium",o=e.passed?"var(--success)":r==="critical"?"var(--danger)":r==="high"?"var(--high-text)":r==="medium"?"var(--warn)":"var(--success)";return u.jsxs("div",{style:{borderLeft:`3px solid ${o}`,background:"var(--surface)",border:"1px solid var(--border)",borderLeftWidth:3,borderLeftColor:o,borderRadius:"var(--radius)",marginBottom:6,overflow:"hidden"},children:[u.jsxs("button",{onClick:n,"aria-expanded":t,style:{display:"flex",alignItems:"center",gap:"var(--space-2)",width:"100%",padding:"9px 14px",border:"none",background:"transparent",textAlign:"left",cursor:"pointer"},children:[u.jsx("span",{style:{color:e.passed?"var(--success)":"var(--danger)",display:"flex"},children:u.jsx(ue,{name:e.passed?"check":"cross",size:15,strokeWidth:2.4})}),u.jsx("span",{style:{flex:1,fontSize:"var(--text-base)",fontWeight:550,minWidth:0},children:e.name.replace(/_/g," ").replace(/\b\w/g,i=>i.toUpperCase())}),u.jsx("span",{className:`badge badge--${r}`,children:e.severity}),u.jsx("span",{style:{display:"flex",color:"var(--text-subtle)",transform:t?"rotate(180deg)":"none",transition:"transform var(--duration) var(--ease)"},children:u.jsx(ue,{name:"chevron",size:13})})]}),t&&u.jsxs("div",{style:{padding:"0 14px 12px 40px",fontSize:"var(--text-sm)",lineHeight:1.6},children:[u.jsx("p",{style:{color:"var(--text-muted)"},children:e.detail}),e.recommendation&&u.jsxs("div",{className:"callout",style:{marginTop:"var(--space-2)",fontSize:"var(--text-sm)"},children:[u.jsx("strong",{style:{color:"var(--text)"},children:"Recommendation: "}),e.recommendation]})]})]})}function $C({spec:e,apiBase:t}){const[n,r]=C.useState(null),[o,i]=C.useState(null),[s,l]=C.useState(!1),[a,c]=C.useState(null),[f,d]=C.useState(new Set),[p,v]=C.useState(!1),x=C.useCallback(async _=>{i(_),l(!0),c(null),d(new Set),v(!1);try{const k=_==="well-architected",E=await fetch(`${t}/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({spec:e,compliance:k?[]:[_],well_architected:k})});if(!E.ok)throw new Error(await jt(E));const M=await E.json();r(M.results)}catch(k){c(k instanceof Error?k.message:"Validation failed"),r(null)}finally{l(!1)}},[e,t]),w=C.useCallback(_=>{d(k=>{const E=new Set(k);return E.has(_)?E.delete(_):E.add(_),E})},[]),S=(n==null?void 0:n[0])??null,g=S?S.checks.filter(_=>!_.passed).sort((_,k)=>(qr[_.severity]??9)-(qr[k.severity]??9)):[],m=S?S.checks.filter(_=>_.passed).sort((_,k)=>(qr[_.severity]??9)-(qr[k.severity]??9)):[],h={};for(const _ of g)h[_.category]||(h[_.category]=[]),h[_.category].push(_);const y=S?S.checks.reduce((_,k)=>(k.passed||(_[k.severity]=(_[k.severity]||0)+1),_),{}):{};return u.jsxs("div",{className:"panel__body",children:[u.jsx("h2",{className:"panel__title",children:"Validate Architecture"}),u.jsx("p",{className:"panel__lede",children:"One framework at a time. A framework fails when any critical check fails, whatever the overall score says."}),u.jsx("div",{style:{display:"flex",gap:"var(--space-2)",flexWrap:"wrap",marginBottom:"var(--space-5)"},children:IC.map(_=>u.jsx("button",{className:"chip","aria-pressed":o===_.key,onClick:()=>x(_.key),disabled:s,children:_.label},_.key))}),s&&u.jsxs("div",{className:"status-row",children:[u.jsx("span",{className:"spinner"}),"Running ",o==null?void 0:o.toUpperCase()," validation..."]}),a&&u.jsx("div",{className:"callout callout--danger",children:a}),S&&!s&&u.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-6)"},children:[u.jsxs("div",{className:"card",style:{display:"flex",gap:"var(--space-6)",alignItems:"flex-start",padding:"var(--space-5)",flexWrap:"wrap"},children:[u.jsx(AC,{score:S.score,passed:S.passed}),u.jsxs("div",{style:{flex:1,minWidth:240},children:[u.jsx("h3",{style:{fontSize:"var(--text-lg)",marginBottom:4},children:S.framework}),u.jsxs("p",{style:{fontSize:"var(--text-base)",color:"var(--text-muted)",marginBottom:"var(--space-4)"},children:[S.checks.length," checks evaluated, ",m.length," passed,"," ",g.length," failed."]}),u.jsx("div",{style:{display:"flex",gap:"var(--space-2)",flexWrap:"wrap"},children:["critical","high","medium","low"].map(_=>{const k=y[_]||0;return u.jsxs("div",{className:k>0?`badge badge--${_}`:"badge badge--neutral",style:{padding:"6px 12px",gap:8},children:[u.jsx("span",{style:{fontSize:"var(--text-lg)",fontWeight:700,lineHeight:1},children:k}),_]},_)})})]})]}),g.length>0&&u.jsxs("div",{children:[u.jsxs("h3",{style:{fontSize:"var(--text-md)",marginBottom:"var(--space-3)",display:"flex",alignItems:"center",gap:8},children:[u.jsx("span",{style:{color:"var(--danger)",display:"flex"},children:u.jsx(ue,{name:"cross",size:15,strokeWidth:2.4})}),"Failed Checks (",g.length,")"]}),Object.entries(h).map(([_,k])=>u.jsxs("div",{style:{marginBottom:"var(--space-4)"},children:[u.jsx("p",{className:"section-label",style:{marginBottom:6},children:LC[_]||_.replace(/_/g," ")}),k.map(E=>{const M=`${_}-${E.name}`;return u.jsx(Wf,{check:E,expanded:f.has(M),onToggle:()=>w(M)},M)})]},_))]}),m.length>0&&u.jsxs("div",{children:[u.jsxs("button",{onClick:()=>v(_=>!_),"aria-expanded":p,style:{display:"flex",alignItems:"center",gap:8,background:"none",border:"none",cursor:"pointer",padding:"4px 0",fontSize:"var(--text-md)",fontWeight:650,color:"var(--text)"},children:[u.jsx("span",{style:{color:"var(--success)",display:"flex"},children:u.jsx(ue,{name:"check",size:15,strokeWidth:2.4})}),"Passed Checks (",m.length,")",u.jsx("span",{style:{display:"flex",color:"var(--text-subtle)",transform:p?"rotate(180deg)":"none",transition:"transform var(--duration) var(--ease)"},children:u.jsx(ue,{name:"chevron",size:13})})]}),p&&u.jsx("div",{style:{marginTop:"var(--space-2)"},children:m.map(_=>{const k=`passed-${_.category}-${_.name}`;return u.jsx(Wf,{check:_,expanded:f.has(k),onToggle:()=>w(k)},k)})})]}),u.jsxs("p",{style:{fontSize:"var(--text-xs)",color:"var(--text-subtle)",borderTop:"1px solid var(--border)",paddingTop:"var(--space-3)",lineHeight:1.6},children:["Score is the percentage of checks passed. A framework is marked failed if any critical-severity check fails, whatever the score. The Cloudwright validator defines these checks from the ",S.framework," control requirements."]})]}),!S&&!s&&!a&&u.jsx(Rn,{icon:"check",title:"No framework selected yet.",hint:"Pick a framework above. Every failed check comes back with the reason and a fix."})]})}const RC=new Set(["critical","high","medium","low"]);function iy({severity:e,title:t,source:n,detail:r,component:o,children:i}){const s=RC.has(e)?e:"low";return u.jsx("div",{className:"card",style:{marginBottom:"var(--space-2)",borderLeft:`3px solid var(--${s==="critical"?"danger":s==="high"?"high-text":s==="medium"?"warn":"success"})`},children:u.jsxs("div",{className:"card__body",style:{padding:"var(--space-3) var(--space-4)"},children:[u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)",flexWrap:"wrap"},children:[u.jsx("span",{className:`badge badge--${s}`,children:e}),u.jsx("span",{style:{fontSize:"var(--text-md)",fontWeight:550},children:t}),o&&u.jsx("code",{className:"inline",children:o}),n&&u.jsx("span",{style:{fontSize:"var(--text-xs)",color:"var(--text-subtle)",marginLeft:"auto"},children:n})]}),r&&u.jsx("p",{style:{fontSize:"var(--text-base)",color:"var(--text-muted)",marginTop:"var(--space-2)"},children:r}),i]})})}const DC=[{key:"hipaa",label:"HIPAA"},{key:"soc2",label:"SOC 2"},{key:"pci-dss",label:"PCI-DSS"},{key:"fedramp",label:"FedRAMP"},{key:"gdpr",label:"GDPR"},{key:"iso27001",label:"ISO 27001"},{key:"nist",label:"NIST 800-53"}];function OC({spec:e,apiBase:t}){const[n,r]=C.useState(["hipaa","soc2","fedramp"]),[o,i]=C.useState(!1),[s,l]=C.useState(null),[a,c]=C.useState(!1),[f,d]=C.useState(null),p=w=>r(S=>S.includes(w)?S.filter(g=>g!==w):[...S,w]),v=C.useCallback(async()=>{c(!0),d(null);try{const w=await fetch(`${t}/compliance`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({spec:e,frameworks:n,oscal:o})});if(!w.ok)throw new Error(await jt(w));l(await w.json())}catch(w){d(w instanceof Error?w.message:"Compliance scan failed")}finally{c(!1)}},[e,t,n,o]),x=C.useCallback(()=>{if(!(s!=null&&s.oscal))return;const w=new Blob([JSON.stringify(s.oscal,null,2)],{type:"application/json"}),S=URL.createObjectURL(w),g=document.createElement("a");g.href=S,g.download="compliance.oscal.json",g.click(),URL.revokeObjectURL(S)},[s]);return u.jsxs("div",{className:"panel__body",children:[u.jsx("h2",{className:"panel__title",children:"Compliance Control Mapping"}),u.jsx("p",{className:"panel__lede",children:"Every design-stage finding carries the framework control it violates, before any infrastructure exists. A Checkov deep scan folds in when Checkov is on the PATH."}),u.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"var(--space-2)",marginBottom:"var(--space-4)"},children:DC.map(w=>u.jsx("button",{className:"chip","aria-pressed":n.includes(w.key),onClick:()=>p(w.key),children:w.label},w.key))}),u.jsxs("label",{className:"checkbox",style:{marginBottom:"var(--space-4)"},children:[u.jsx("input",{type:"checkbox",checked:o,onChange:w=>i(w.target.checked)}),"Include OSCAL 1.1.2 component-definition export"]}),u.jsxs("div",{style:{display:"flex",gap:"var(--space-2)",flexWrap:"wrap"},children:[u.jsxs("button",{className:"btn btn--primary",onClick:v,disabled:a||n.length===0,children:[a&&u.jsx("span",{className:"spinner"}),a?"Scanning...":"Run compliance scan"]}),(s==null?void 0:s.oscal)&&u.jsxs("button",{className:"btn",onClick:x,children:[u.jsx(ue,{name:"download",size:14}),"Download OSCAL JSON"]})]}),f&&u.jsx("div",{className:"callout callout--danger",style:{marginTop:"var(--space-4)"},children:f}),s&&u.jsxs("div",{style:{marginTop:"var(--space-6)"},children:[u.jsxs("p",{style:{fontSize:"var(--text-sm)",color:"var(--text-subtle)",marginBottom:"var(--space-2)"},children:["Scanner: ",u.jsx("strong",{children:s.scanner}),s.checkov_used?", with the Checkov deep scan included":""]}),u.jsx("div",{className:"table-wrap",style:{marginBottom:"var(--space-6)"},children:u.jsxs("table",{className:"data",children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsx("th",{scope:"col",children:"Framework"}),u.jsx("th",{scope:"col",children:"Controls satisfied"}),u.jsx("th",{scope:"col",children:"Violated"}),u.jsx("th",{scope:"col",children:"Findings"}),u.jsx("th",{scope:"col",children:"Status"})]})}),u.jsx("tbody",{children:s.frameworks.map(w=>u.jsxs("tr",{children:[u.jsx("td",{children:u.jsx("strong",{children:w.framework})}),u.jsxs("td",{className:"num",style:{textAlign:"left"},children:[w.controls_satisfied,"/",w.controls_total]}),u.jsx("td",{style:{color:"var(--danger-text)",fontSize:"var(--text-sm)"},children:w.controls_violated.length?w.controls_violated.join(", "):"none"}),u.jsx("td",{className:"num",style:{textAlign:"left"},children:w.findings}),u.jsx("td",{children:u.jsx("span",{className:`badge ${w.status==="pass"?"badge--success":"badge--danger"}`,children:w.status})})]},w.framework))})]})}),u.jsxs("h3",{style:{fontSize:"var(--text-lg)",marginBottom:"var(--space-3)"},children:["Findings (",s.findings.length,")"]}),s.findings.length===0?u.jsx("div",{className:"callout callout--success",children:"No findings. Every selected control is satisfied by this design."}):s.findings.map((w,S)=>u.jsx(iy,{severity:w.severity,title:w.message,source:w.source,detail:w.remediation,component:w.component_id,children:w.controls.length>0&&u.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6,marginTop:"var(--space-2)"},children:w.controls.map((g,m)=>u.jsxs("span",{title:g.title,className:"badge badge--neutral",style:{fontFamily:"var(--font-mono)",textTransform:"none"},children:[g.framework," ",g.control_id]},m))})},S))]}),!s&&!a&&!f&&u.jsx(Rn,{icon:"check",title:"No scan has run yet.",hint:"Pick the frameworks that apply, then run the scan. Every finding comes back with its control ID."})]})}const FC=[{key:"terraform",label:"Terraform"},{key:"pulumi-python",label:"Pulumi (Python)"},{key:"pulumi-ts",label:"Pulumi (TS)"}];function BC({spec:e,apiBase:t}){const[n,r]=C.useState("terraform"),[o,i]=C.useState(null),[s,l]=C.useState(!1),[a,c]=C.useState(null),f=C.useCallback(async()=>{l(!0),c(null),i(null);try{const d=await fetch(`${t}/plan`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({spec:e,target:n,run_plan:!0})});if(!d.ok)throw new Error(await jt(d));i(await d.json())}catch(d){c(d instanceof Error?d.message:"Plan failed")}finally{l(!1)}},[e,t,n]);return u.jsxs("div",{className:"panel__body",children:[u.jsx("h2",{className:"panel__title",children:"Deployability Check"}),u.jsxs("p",{className:"panel__lede",children:["Runs ",u.jsx("code",{className:"inline",children:"terraform validate"})," and"," ",u.jsx("code",{className:"inline",children:"plan"}),", or ",u.jsx("code",{className:"inline",children:"pulumi preview"}),", against the exported artifact. Nothing is ever applied. Validation needs no credentials, so it works offline."]}),u.jsx("div",{style:{display:"flex",gap:"var(--space-2)",flexWrap:"wrap",marginBottom:"var(--space-4)"},children:FC.map(d=>u.jsx("button",{className:"chip","aria-pressed":n===d.key,onClick:()=>r(d.key),children:d.label},d.key))}),u.jsxs("button",{className:"btn btn--primary",onClick:f,disabled:s,children:[s&&u.jsx("span",{className:"spinner"}),s?"Running plan...":"Run plan"]}),a&&u.jsx("div",{className:"callout callout--danger",style:{marginTop:"var(--space-4)"},children:a}),o&&u.jsxs("div",{style:{marginTop:"var(--space-6)",display:"flex",flexDirection:"column",gap:"var(--space-4)"},children:[u.jsxs("div",{children:[u.jsx("span",{className:`badge ${o.ok?"badge--success":"badge--danger"}`,style:{fontSize:"var(--text-base)",padding:"6px 14px"},children:o.ok?"Deployable":"Not deployable"}),o.ok&&!o.plan_ran&&u.jsx("span",{style:{marginLeft:"var(--space-2)",fontSize:"var(--text-sm)",color:"var(--text-subtle)"},children:"validate only, no credentials found"})]}),o.summary&&u.jsxs("div",{className:"stat-grid",children:[u.jsxs("div",{className:"stat",children:[u.jsxs("div",{className:"stat__value",style:{color:"var(--success)"},children:["+",o.summary.add]}),u.jsx("div",{className:"stat__label",children:"Resources to add"})]}),u.jsxs("div",{className:"stat",children:[u.jsxs("div",{className:"stat__value",style:{color:"var(--warn)"},children:["~",o.summary.change]}),u.jsx("div",{className:"stat__label",children:"Resources to change"})]}),u.jsxs("div",{className:"stat",children:[u.jsxs("div",{className:"stat__value",style:{color:"var(--danger)"},children:["-",o.summary.destroy]}),u.jsx("div",{className:"stat__label",children:"Resources to destroy"})]})]}),o.messages.length>0&&u.jsx("ul",{style:{paddingLeft:"var(--space-5)",fontSize:"var(--text-base)",color:"var(--text-muted)"},children:o.messages.map((d,p)=>u.jsx("li",{style:{marginBottom:4},children:d},p))}),o.output_tail&&u.jsxs("div",{className:"card",children:[u.jsx("div",{className:"card__header",children:u.jsxs("span",{children:[o.tool," output"]})}),u.jsx("pre",{className:"code-block code-block--inverted",style:{borderRadius:0},children:o.output_tail})]})]}),!o&&!s&&!a&&u.jsx(Rn,{icon:"refresh",title:"No plan has run yet.",hint:"Pick a target above and run the plan. The check is read-only, so it never touches a live account."})]})}function HC({spec:e,apiBase:t}){const[n,r]=C.useState(!1),[o,i]=C.useState(null),[s,l]=C.useState(!1),[a,c]=C.useState(null),f=C.useCallback(async()=>{l(!0),c(null);try{const d=await fetch(`${t}/review`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({spec:e,well_architected:n})});if(!d.ok)throw new Error(await jt(d));i(await d.json())}catch(d){c(d instanceof Error?d.message:"Review failed")}finally{l(!1)}},[e,t,n]);return u.jsxs("div",{className:"panel__body",children:[u.jsx("h2",{className:"panel__title",children:"Architecture Review"}),u.jsx("p",{className:"panel__lede",children:"The scorer, the linter and the validator merged into one severity-ranked report. Runs offline, with no LLM call, so the result is the same every time."}),u.jsxs("label",{className:"checkbox",style:{marginBottom:"var(--space-4)"},children:[u.jsx("input",{type:"checkbox",checked:n,onChange:d=>r(d.target.checked)}),"Include Well-Architected checks"]}),u.jsx("div",{children:u.jsxs("button",{className:"btn btn--primary",onClick:f,disabled:s,children:[s&&u.jsx("span",{className:"spinner"}),s?"Reviewing...":"Run review"]})}),a&&u.jsx("div",{className:"callout callout--danger",style:{marginTop:"var(--space-4)"},children:a}),o&&u.jsxs("div",{style:{marginTop:"var(--space-6)"},children:[u.jsxs("div",{className:"stat-grid",style:{marginBottom:"var(--space-5)"},children:[u.jsxs("div",{className:"stat",children:[u.jsxs("div",{className:"stat__value",children:[o.score.toFixed(0),u.jsx("span",{style:{fontSize:"var(--text-md)",color:"var(--text-subtle)"},children:"/100"})]}),u.jsxs("div",{className:"stat__label",children:["Score, grade ",o.grade]})]}),u.jsxs("div",{className:"stat",children:[u.jsx("div",{className:"stat__value",style:{color:o.blocking_count===0?"var(--success)":"var(--danger)"},children:o.blocking_count}),u.jsx("div",{className:"stat__label",children:"Blocking findings"})]}),u.jsxs("div",{className:"stat",children:[u.jsx("div",{className:"stat__value",children:o.findings.length}),u.jsx("div",{className:"stat__label",children:"Findings in total"})]})]}),u.jsxs("h3",{style:{fontSize:"var(--text-lg)",marginBottom:"var(--space-3)"},children:["Findings (",o.findings.length,")"]}),o.findings.length===0?u.jsx("div",{className:"callout callout--success",children:"No findings. This architecture passes every critic."}):o.findings.map((d,p)=>u.jsx(iy,{severity:d.severity,title:d.message,source:d.source,detail:d.recommendation,component:d.component},p))]}),!o&&!s&&!a&&u.jsx(Rn,{icon:"alert",title:"No review has run yet.",hint:"The review reads the current spec and ranks what it finds, from critical down to low."})]})}const Uf=[{key:"terraform",label:"Terraform",ext:"tf",tag:"HCL",desc:"HashiCorp Configuration Language",group:"Infrastructure as code"},{key:"opentofu",label:"OpenTofu",ext:"tf",tag:"TOFU",desc:"Fork-safe Terraform dialect",group:"Infrastructure as code"},{key:"pulumi-ts",label:"Pulumi TypeScript",ext:"ts",tag:"TS",desc:"Pulumi program in TypeScript",group:"Infrastructure as code"},{key:"pulumi-python",label:"Pulumi Python",ext:"py",tag:"PY",desc:"Pulumi program in Python",group:"Infrastructure as code"},{key:"cloudformation",label:"CloudFormation",ext:"yaml",tag:"CFN",desc:"AWS CloudFormation template",group:"Infrastructure as code"},{key:"mermaid",label:"Mermaid",ext:"mmd",tag:"MMD",desc:"Renders in GitHub and Notion",group:"Diagram source"},{key:"d2",label:"D2",ext:"d2",tag:"D2",desc:"D2 diagram language",group:"Diagram source"},{key:"c4",label:"C4",ext:"dsl",tag:"C4",desc:"Structurizr C4 model",group:"Diagram source"},{key:"ascii",label:"ASCII",ext:"txt",tag:"TXT",desc:"Plain text for a terminal or a commit message",group:"Diagram source"},{key:"sbom",label:"SBOM",ext:"json",tag:"BOM",desc:"CycloneDX software bill of materials",group:"Inventory and report"},{key:"aibom",label:"AIBOM",ext:"json",tag:"AI",desc:"OWASP AI bill of materials",group:"Inventory and report"},{key:"compliance",label:"Compliance report",ext:"md",tag:"MD",desc:"Findings and controls in Markdown",group:"Inventory and report"},{key:"html",label:"HTML report",ext:"html",tag:"WEB",desc:"Self-contained shareable page",group:"Inventory and report"}],VC=["Infrastructure as code","Diagram source","Inventory and report"],WC={terraform:"#7c3aed",opentofu:"#facc15","pulumi-ts":"#4f46e5","pulumi-python":"#4f46e5",cloudformation:"#ea580c",mermaid:"#0891b2",d2:"#4f46e5",c4:"#0f766e",ascii:"#64748b",sbom:"#059669",aibom:"#2563eb",compliance:"#be123c",html:"#0284c7"};function Yf({format:e}){if(!e)return null;const t=WC[e.key]||"var(--text-subtle)";return u.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",minWidth:36,height:20,padding:"0 5px",borderRadius:"var(--radius-sm)",fontSize:"var(--text-2xs)",fontWeight:700,letterSpacing:"0.04em",background:`${t}1f`,color:t,flexShrink:0},children:e.tag})}function UC({spec:e,apiBase:t}){const[n,r]=C.useState(null),[o,i]=C.useState(""),[s,l]=C.useState(!1),[a,c]=C.useState(null),[f,d]=C.useState(!1),p=C.useRef(null),v=C.useCallback(async m=>{r(m),l(!0),c(null),d(!1);try{const h=await fetch(`${t}/export`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({spec:e,format:m})});if(!h.ok)throw new Error(await jt(h));const y=await h.json();i(y.content||JSON.stringify(y,null,2))}catch(h){c(h instanceof Error?h.message:"Export failed"),i("")}finally{l(!1)}},[e,t]),x=C.useCallback(async()=>{var m,h;try{await navigator.clipboard.writeText(o),d(!0),setTimeout(()=>d(!1),2e3)}catch{const y=p.current;if(y){const _=document.createRange();_.selectNodeContents(y),(m=window.getSelection())==null||m.removeAllRanges(),(h=window.getSelection())==null||h.addRange(_)}}},[o]),w=Uf.find(m=>m.key===n),S=C.useCallback(()=>{if(!o||!n)return;const m=new Blob([o],{type:"text/plain"}),h=URL.createObjectURL(m),y=document.createElement("a");y.href=h,y.download=`architecture.${(w==null?void 0:w.ext)||"txt"}`,y.click(),URL.revokeObjectURL(h)},[o,n,w]),g=o?o.split(` +`).length:0;return u.jsxs("div",{className:"panel__body panel__body--wide",children:[u.jsx("h2",{className:"panel__title",children:"Export Architecture"}),u.jsx("p",{className:"panel__lede",children:"Thirteen formats off one spec. The infrastructure formats carry the safe defaults, so encryption, versioning and public-access blocks are already in the generated code."}),VC.map(m=>u.jsxs("div",{style:{marginBottom:"var(--space-5)"},children:[u.jsx("p",{className:"section-label",style:{marginBottom:"var(--space-2)"},children:m}),u.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(230px, 1fr))",gap:"var(--space-2)"},children:Uf.filter(h=>h.group===m).map(h=>u.jsxs("button",{className:"list-btn",onClick:()=>v(h.key),disabled:s,"aria-pressed":n===h.key,style:{marginBottom:0,display:"flex",alignItems:"center",gap:"var(--space-2)",borderColor:n===h.key?"var(--accent)":void 0,background:n===h.key?"var(--accent-soft)":void 0},children:[u.jsx(Yf,{format:h}),u.jsxs("span",{style:{minWidth:0},children:[u.jsx("span",{style:{display:"block",fontSize:"var(--text-base)",fontWeight:600},children:h.label}),u.jsx("span",{style:{display:"block",fontSize:"var(--text-xs)",color:"var(--text-subtle)"},children:h.desc})]})]},h.key))})]},m)),s&&u.jsxs("div",{className:"status-row",children:[u.jsx("span",{className:"spinner"}),"Generating ",(w==null?void 0:w.label)||n,"..."]}),a&&u.jsx("div",{className:"callout callout--danger",children:a}),o&&!s&&u.jsxs("div",{className:"card",children:[u.jsxs("div",{className:"card__header",children:[u.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)",minWidth:0},children:[u.jsx(Yf,{format:w}),u.jsxs("code",{className:"inline",children:["architecture.",(w==null?void 0:w.ext)||"txt"]}),u.jsxs("span",{style:{fontSize:"var(--text-xs)",color:"var(--text-subtle)"},children:[g," lines"]})]}),u.jsxs("span",{style:{display:"flex",gap:"var(--space-2)"},children:[u.jsxs("button",{className:"btn btn--sm",onClick:x,children:[u.jsx(ue,{name:f?"check":"copy",size:13}),f?"Copied":"Copy"]}),u.jsxs("button",{className:"btn btn--sm",onClick:S,children:[u.jsx(ue,{name:"download",size:13}),"Download"]})]})]}),u.jsx("div",{style:{maxHeight:"60vh",overflow:"auto"},children:u.jsx("pre",{ref:p,className:"code-block",children:o})})]}),!o&&!s&&!a&&u.jsx(Rn,{icon:"download",title:"No format generated yet.",hint:"Pick a format above. The output appears here, ready to copy or download."})]})}const YC={0:"Edge / CDN",1:"Load Balancing",2:"Compute",3:"Data",4:"Supporting"},XC=/^[A-Za-z0-9_./:@-]+$/,GC=/^(true|false|yes|no|on|off|null|~|-?\d+(\.\d+)?([eE][+-]?\d+)?)$/i;function Hl(e){if(e==null)return"null";if(typeof e=="number"||typeof e=="boolean")return String(e);const t=String(e);return t===""?'""':t.includes(` +`)?JSON.stringify(t):XC.test(t)&&!GC.test(t)&&!t.includes(": ")?t:JSON.stringify(t)}function eu(e,t=0){const n=" ".repeat(t);if(Array.isArray(e))return e.length===0?"[]":e.map(r=>{if(r&&typeof r=="object"){const o=eu(r,t+2);return`${n}- ${o.trimStart()}`}return`${n}- ${Hl(r)}`}).join(` +`);if(e&&typeof e=="object"){const r=Object.entries(e).filter(([,o])=>o!==void 0);return r.length===0?"{}":r.map(([o,i])=>{if(i&&typeof i=="object"){const s=eu(i,t+2);return`${n}${o}: +${s}`}return`${n}${o}: ${Hl(i)}`}).join(` +`)}return Hl(e)}function Ci({label:e,value:t,sub:n}){return u.jsxs("div",{className:"stat",children:[u.jsx("div",{className:"stat__value",children:t}),u.jsx("div",{className:"stat__label",children:e}),n&&u.jsx("div",{className:"stat__sub",children:n})]})}function KC({spec:e,yaml:t,apiBase:n}){var h;const[r,o]=C.useState("overview"),[i,s]=C.useState(!1),[l,a]=C.useState(null),[c,f]=C.useState(!1),d=C.useRef(null),p=C.useMemo(()=>(t==null?void 0:t.trim())||eu(e),[e,t]),v=l??p;C.useEffect(()=>{if(r!=="yaml")return;let y=!1;return f(!0),fetch(`${n}/download`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({spec:e,format:"yaml"})}).then(_=>_.ok?_.text():null).then(_=>{!y&&_&&a(_)}).catch(()=>{}).finally(()=>{y||f(!1)}),()=>{y=!0}},[r,e,n]);const x=C.useMemo(()=>Array.from(new Set(e.components.map(y=>y.provider))),[e.components]),w=C.useMemo(()=>Array.from(new Set(e.components.map(y=>y.service))),[e.components]),S=C.useMemo(()=>{const y={};for(const _ of e.components){const k=_.tier??2;y[k]||(y[k]=[]),y[k].push(_)}return y},[e.components]),g=C.useCallback(async()=>{var y,_;try{await navigator.clipboard.writeText(v),s(!0),setTimeout(()=>s(!1),2e3)}catch{const k=d.current;if(k){const E=document.createRange();E.selectNodeContents(k),(y=window.getSelection())==null||y.removeAllRanges(),(_=window.getSelection())==null||_.addRange(E)}}},[v]),m=C.useCallback(()=>{var E;const y=new Blob([v],{type:"text/yaml"}),_=URL.createObjectURL(y),k=document.createElement("a");k.href=_,k.download=`${((E=e.name)==null?void 0:E.replace(/\s+/g,"-").toLowerCase())||"architecture"}.yaml`,k.click(),URL.revokeObjectURL(_)},[v,e.name]);return u.jsxs("div",{className:"panel__body panel__body--wide",children:[u.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"var(--space-3)",flexWrap:"wrap",marginBottom:"var(--space-4)"},children:[u.jsx("h2",{className:"panel__title",children:e.name||"Architecture Spec"}),e.provider&&u.jsx("span",{className:"badge badge--neutral",children:e.provider}),e.region&&u.jsx("code",{className:"inline",children:e.region})]}),u.jsx("div",{className:"tabs",role:"tablist","aria-label":"Spec views",style:{borderBottom:"1px solid var(--border)",marginBottom:"var(--space-5)",padding:0},children:["overview","yaml"].map(y=>u.jsx("button",{className:"tab",role:"tab","aria-selected":r===y,tabIndex:r===y?0:-1,onClick:()=>o(y),style:{minHeight:38,textTransform:"none"},children:y==="overview"?"Overview":"YAML Source"},y))}),r==="overview"&&u.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-5)"},children:[u.jsxs("div",{className:"stat-grid",children:[u.jsx(Ci,{label:"Components",value:e.components.length}),u.jsx(Ci,{label:"Connections",value:e.connections.length}),u.jsx(Ci,{label:"Distinct services",value:w.length,sub:x.join(", ")}),e.cost_estimate&&u.jsx(Ci,{label:"Monthly cost",value:`$${e.cost_estimate.monthly_total.toLocaleString()}`,sub:e.cost_estimate.currency})]}),u.jsx("div",{className:"table-wrap",children:u.jsxs("table",{className:"data",children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsx("th",{scope:"col",children:"Component"}),u.jsx("th",{scope:"col",children:"Service"}),u.jsx("th",{scope:"col",children:"Provider"}),u.jsx("th",{scope:"col",children:"Tier"}),u.jsx("th",{scope:"col",children:"Description"})]})}),u.jsx("tbody",{children:Object.keys(S).map(Number).sort().flatMap(y=>S[y].map(_=>u.jsxs("tr",{children:[u.jsxs("td",{children:[u.jsx("span",{style:{fontWeight:600},children:_.label}),u.jsx("div",{style:{fontSize:"var(--text-xs)",color:"var(--text-subtle)"},children:_.id})]}),u.jsx("td",{children:u.jsx("code",{className:"inline",children:_.service})}),u.jsx("td",{style:{color:"var(--text-muted)"},children:_.provider}),u.jsx("td",{children:u.jsx("span",{className:"badge badge--neutral",children:YC[y]||`Tier ${y}`})}),u.jsx("td",{style:{color:"var(--text-muted)",maxWidth:280},children:_.description})]},_.id)))})]})}),e.connections.length>0&&u.jsxs("div",{className:"card",children:[u.jsxs("div",{className:"card__header",children:["Connections (",e.connections.length,")"]}),u.jsxs("table",{className:"data",children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsx("th",{scope:"col",children:"Source"}),u.jsx("th",{scope:"col",children:"Target"}),u.jsx("th",{scope:"col",children:"Protocol"}),u.jsx("th",{scope:"col",children:"Label"})]})}),u.jsx("tbody",{children:e.connections.map((y,_)=>{const k=e.components.find(M=>M.id===y.source),E=e.components.find(M=>M.id===y.target);return u.jsxs("tr",{children:[u.jsx("td",{style:{fontWeight:550},children:(k==null?void 0:k.label)||y.source}),u.jsx("td",{style:{fontWeight:550},children:(E==null?void 0:E.label)||y.target}),u.jsx("td",{children:y.protocol&&u.jsxs("code",{className:"inline",children:[y.protocol,y.port?`:${y.port}`:""]})}),u.jsx("td",{style:{color:"var(--text-muted)"},children:y.label})]},_)})})]})]}),e.boundaries&&e.boundaries.length>0&&u.jsxs("div",{className:"card",children:[u.jsxs("div",{className:"card__header",children:["Boundaries (",e.boundaries.length,")"]}),u.jsx("div",{className:"card__body",style:{display:"flex",flexWrap:"wrap",gap:"var(--space-2)"},children:e.boundaries.map(y=>u.jsxs("div",{style:{padding:"8px 14px",border:"1px dashed var(--border-strong)",borderRadius:"var(--radius)",background:"var(--bg-subtle)"},children:[u.jsx("div",{style:{fontWeight:600,fontSize:"var(--text-base)"},children:y.label||y.id}),u.jsxs("div",{style:{fontSize:"var(--text-xs)",color:"var(--text-subtle)"},children:[y.kind,", ",y.component_ids.length," components"]})]},y.id))})]})]}),r==="yaml"&&u.jsxs("div",{className:"card",children:[u.jsxs("div",{className:"card__header",children:[u.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)",minWidth:0},children:[u.jsxs("code",{className:"inline",children:[((h=e.name)==null?void 0:h.replace(/\s+/g,"-").toLowerCase())||"architecture",".yaml"]}),u.jsxs("span",{style:{fontSize:"var(--text-xs)",color:"var(--text-subtle)"},children:[v.split(` +`).length," lines",c?", refreshing":l?", from the server":""]})]}),u.jsxs("span",{style:{display:"flex",gap:"var(--space-2)"},children:[u.jsxs("button",{className:"btn btn--sm",onClick:g,children:[u.jsx(ue,{name:i?"check":"copy",size:13}),i?"Copied":"Copy"]}),u.jsxs("button",{className:"btn btn--sm",onClick:m,children:[u.jsx(ue,{name:"download",size:13}),"Download"]})]})]}),u.jsx("div",{style:{maxHeight:"62vh",overflow:"auto"},children:u.jsx("pre",{ref:d,className:"code-block",children:v||"No YAML available"})})]})]})}const sy="cloudwright_theme";function ly(){return typeof window>"u"||!window.matchMedia?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function tu(){try{const e=localStorage.getItem(sy);return e==="light"||e==="dark"?e:null}catch{return null}}function QC(){const e=tu()??ly();document.documentElement.setAttribute("data-theme",e)}function ZC(){const[e,t]=C.useState(()=>tu()??ly()),[n,r]=C.useState(()=>tu()!==null);C.useEffect(()=>{document.documentElement.setAttribute("data-theme",e)},[e]),C.useEffect(()=>{if(n||!window.matchMedia)return;const i=window.matchMedia("(prefers-color-scheme: dark)"),s=l=>t(l.matches?"dark":"light");return i.addEventListener("change",s),()=>i.removeEventListener("change",s)},[n]);const o=C.useCallback(()=>{t(i=>{const s=i==="dark"?"light":"dark";try{localStorage.setItem(sy,s)}catch{}return s}),r(!0)},[]);return{theme:e,toggleTheme:o}}const tt="/api",Vn=[{key:"diagram",icon:"grid"},{key:"cost",icon:"layers"},{key:"validate",icon:"check"},{key:"compliance",icon:"check"},{key:"plan",icon:"refresh"},{key:"review",icon:"alert"},{key:"export",icon:"download"},{key:"spec",icon:"panel"},{key:"modify",icon:"chat"}],Vl={generating:"Generating architecture...",modifying:"Modifying architecture...",costing:"Estimating cost and validating...",done:"Finalizing..."},Wl="3-tier web app on AWS with CloudFront, ALB, EC2, and RDS",qC=["Add caching layer","Reduce cost","Increase redundancy","Add monitoring","Add security"];function JC(e){var s;if((s=e.metadata)!=null&&s.suggestions&&e.metadata.suggestions.length>0)return e.metadata.suggestions.slice(0,3);const t=e.components.map(l=>l.label.toLowerCase()),n=e.components.map(l=>l.service.toLowerCase()),r=t.some(l=>l.includes("cache")||l.includes("redis")||l.includes("elasticache"))||n.some(l=>l.includes("cache")||l.includes("redis")),o=t.some(l=>l.includes("monitor")||l.includes("cloudwatch")||l.includes("grafana"))||n.some(l=>l.includes("cloudwatch")||l.includes("monitor")),i=t.some(l=>l.includes("waf")||l.includes("firewall")||l.includes("security"))||n.some(l=>l.includes("waf")||l.includes("shield"));return qC.filter(l=>!(l==="Add caching layer"&&r||l==="Add monitoring"&&o||l==="Add security"&&i)).slice(0,3)}function eE(e){return e.split(/(\*\*.*?\*\*|`[^`]+`)/g).map((t,n)=>t.startsWith("**")&&t.endsWith("**")?u.jsx("strong",{children:t.slice(2,-2)},n):t.startsWith("`")&&t.endsWith("`")&&t.length>2?u.jsx("code",{className:"inline",children:t.slice(1,-1)},n):u.jsx("span",{children:t},n))}async function Xf(e,t,n){var s;let r=e;const[o,i]=await Promise.all([fetch(`${tt}/cost`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({spec:r}),signal:n}).then(l=>l.ok?l.json():null).catch(()=>null),fetch(`${tt}/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({spec:r,compliance:[],well_architected:!0}),signal:n}).then(l=>l.ok?l.json():null).catch(()=>null)]);if(o!=null&&o.estimate&&(r={...r,cost_estimate:o.estimate}),((s=i==null?void 0:i.results)==null?void 0:s.length)>0){const l=i.results[0].checks||[],a=l.filter(c=>c.passed).length;t({passed:a,total:l.length})}return r}async function tE(e,t,n,r){var c;const o=e?`${tt}/modify/stream`:`${tt}/design/stream`,i=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:r});if(!i.ok)throw new Error(await jt(i));const s=(c=i.body)==null?void 0:c.getReader();if(!s)throw new Error("Streaming is not available in this browser.");const l=new TextDecoder;let a="";for(;;){const{done:f,value:d}=await s.read();if(f)break;a+=l.decode(d,{stream:!0});const p=a.split(` +`);a=p.pop()||"";for(const v of p){if(!v.startsWith("data: "))continue;let x;try{x=JSON.parse(v.slice(6))}catch{continue}switch(x.stage){case"generating":case"costing":case"validating":n.onStage(x.stage,x.message);break;case"generated":n.onSpec(x.spec,x.yaml),x.usage&&n.onUsage&&n.onUsage(x.usage);break;case"costed":n.onCost(x.cost_estimate);break;case"validated":n.onValidation(x.passed,x.total);break;case"done":n.onDone(x.spec,x.yaml),x.usage&&n.onUsage&&n.onUsage(x.usage);break;case"error":throw new Error(x.message||"The server reported an error.")}}}}function nE(){const[e,t]=C.useState([]),[n,r]=C.useState(""),[o,i]=C.useState("idle"),[s,l]=C.useState(null),[a,c]=C.useState("diagram"),[f,d]=C.useState(()=>new Set(["diagram"])),[p,v]=C.useState("chat"),[x,w]=C.useState(!1),[S,g]=C.useState(""),[m,h]=C.useState(null),[y,_]=C.useState(null),k=C.useRef(null),E=C.useRef(null),M=C.useRef({}),I=C.useRef(null),{theme:F,toggleTheme:T}=ZC(),{notify:L}=ry(),B=o!=="idle";C.useEffect(()=>{var D;(D=E.current)==null||D.scrollIntoView({behavior:"smooth",block:"end"})},[e,o]);const j=C.useCallback(D=>{c(D),d(U=>U.has(D)?U:new Set(U).add(D)),v("workspace")},[]);C.useEffect(()=>{const D=k.current;D&&(D.style.height="auto",D.style.height=`${Math.min(D.scrollHeight,168)}px`)},[n]);const $=C.useCallback(async(D,U)=>{var re;const X=s!==null,V=new AbortController;I.current=V,i(X?"modifying":"generating");let G=null,ne="",ee=!1,Z=null;U.echoUser&&t(te=>[...te,{role:"user",content:D}]);const J={onStage:te=>{te==="generating"?i(X?"modifying":"generating"):(te==="costing"||te==="validating")&&i("costing")},onSpec:te=>{l(te),G=te,i("costing")},onCost:te=>{te&&G&&(G={...G,cost_estimate:te},l(G))},onValidation:(te,K)=>{te!==null&&h({passed:te,total:K??0})},onDone:(te,K)=>{G=te,ne=K,l(te),i("done")},onUsage:te=>_(te)};try{const te=X?{spec:s,instruction:D}:{description:D};try{await tE(X,te,J,V.signal)}catch(ke){if(V.signal.aborted)throw ke;ee=!0,Z=ke}if(ee&&G!==null)throw Z;if(ee){i(X?"modifying":"generating");const ke=await fetch(`${tt}/${X?"modify":"design"}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(te),signal:V.signal}),ze=await ke.json();if(!ke.ok)throw new Error(ty(ze));ne=ze.yaml,ze.usage&&_(ze.usage),i("costing"),G=await Xf(ze.spec,h,V.signal),l(G),i("done")}const K=G;if(!K)throw new Error("The server returned no architecture.");const ve=X?"Modified":"Designed",Pe=K.cost_estimate?` Estimated cost: $${K.cost_estimate.monthly_total.toFixed(2)}/mo.`:"";t(ke=>[...ke,{role:"assistant",content:`${ve} **${K.name}** with ${K.components.length} components on ${K.provider.toUpperCase()}.${Pe}`,spec:K,yaml:ne,suggestions:JC(K)}]),j("diagram")}catch(te){if(V.signal.aborted)t(K=>[...K,{role:"assistant",content:"Stopped.",isError:!0}]);else{const K=te instanceof Error?te.message:"Unknown error";t(ve=>[...ve,{role:"assistant",content:`Error: ${K}`,isError:!0}]),L(K)}}finally{I.current=null,i("idle"),(re=k.current)==null||re.focus()}},[s,L,j]),z=C.useCallback(()=>{const D=n.trim();!D||B||(r(""),$(D,{echoUser:!0}))},[B,n,$]),R=C.useCallback(()=>{var D;(D=I.current)==null||D.abort()},[]),N=C.useCallback(()=>{var D;w(!1),l(null),t([]),h(null),_(null),d(new Set(["diagram"])),c("diagram"),(D=k.current)==null||D.focus()},[]),b=C.useCallback(async D=>{if(s)try{const U=await fetch(`${tt}/download`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({spec:s,format:D})});if(!U.ok){L(await jt(U));return}const X=await U.blob(),G=(U.headers.get("Content-Disposition")||"").match(/filename=([^\s;]+)/),ne=G?G[1]:`architecture.${D==="terraform"?"tf":"yaml"}`,ee=URL.createObjectURL(X),Z=document.createElement("a");Z.href=ee,Z.download=ne,Z.click(),URL.revokeObjectURL(ee)}catch{L("Download failed. Check that the server is still running.")}},[s,L]),P=C.useCallback(async D=>{l(D),h(null);try{l(await Xf(D,h))}catch{}},[]),O=C.useCallback((D,U)=>{var ne;const V={ArrowRight:U+1,ArrowLeft:U-1,Home:0,End:Vn.length-1}[D.key];if(V===void 0)return;D.preventDefault();const G=Vn[(V+Vn.length)%Vn.length];j(G.key),(ne=M.current[G.key])==null||ne.focus()},[j]);C.useEffect(()=>{const D=U=>{var V;const X=U.metaKey||U.ctrlKey;if(X&&U.key.toLowerCase()==="k"){U.preventDefault(),v("chat"),(V=k.current)==null||V.focus();return}X&&/^[1-9]$/.test(U.key)&&(U.preventDefault(),j(Vn[Number(U.key)-1].key))};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[j]);const A=C.useMemo(()=>{var D;return((D=e.filter(U=>U.yaml).pop())==null?void 0:D.yaml)??""},[e]),H=s,W=D=>u.jsx(Rn,{icon:"layers",title:`No architecture yet, so ${D} has nothing to work on.`,hint:"Describe a system in the chat panel, then come back to this tab.",action:{label:"Write a description",onClick:()=>{var U;v("chat"),(U=k.current)==null||U.focus()}}});return u.jsxs("div",{className:"app",children:[u.jsx("a",{className:"skip-link",href:"#workspace",children:"Skip to workspace"}),u.jsxs("aside",{className:`sidebar app__pane${p==="chat"?" app__pane--active":""}`,children:[u.jsxs("div",{className:"sidebar__header",children:[u.jsxs("div",{className:"brand",children:[u.jsx(ue,{className:"brand__mark",name:"cloud",size:22,strokeWidth:1.7}),u.jsxs("div",{children:[u.jsx("h1",{className:"brand__name",children:"Cloudwright"}),u.jsx("p",{className:"brand__tagline",children:"Architecture Intelligence"})]})]}),u.jsx("button",{className:"btn btn--ghost btn--icon",onClick:T,"aria-label":F==="dark"?"Switch to light theme":"Switch to dark theme",title:F==="dark"?"Switch to light theme":"Switch to dark theme",children:u.jsx(ue,{name:F==="dark"?"sun":"moon",size:16})}),s&&u.jsx("button",{className:"btn btn--sm",onClick:()=>w(!0),children:"New"})]}),u.jsxs("div",{className:"chat",children:[e.length===0&&u.jsxs("div",{className:"empty",children:[u.jsx(ue,{className:"empty__icon",name:"chat",size:34,strokeWidth:1.4}),u.jsx("p",{className:"empty__title",children:"Describe your cloud architecture"}),u.jsx("p",{className:"empty__hint",children:"Plain English in, a typed spec with costs, compliance findings and Terraform out."}),u.jsx("button",{className:"chip",onClick:()=>{var D;r(Wl),(D=k.current)==null||D.focus()},children:Wl})]}),e.map((D,U)=>u.jsxs("div",{className:"msg-group",children:[u.jsx("div",{"data-testid":D.role==="user"?"msg-user":"msg-assistant",className:`msg msg--${D.isError?"error":D.role}`,children:eE(D.content)}),D.role==="assistant"&&D.spec&&D.suggestions&&D.suggestions.length>0&&u.jsx("div",{className:"suggestions",children:D.suggestions.map(X=>u.jsx("button",{className:"chip",disabled:B,onClick:()=>{var V;r(X),(V=k.current)==null||V.focus()},children:X},X))})]},U)),u.jsx("div",{className:"status-row",role:"status","aria-live":"polite",children:B&&u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"spinner"}),Vl[o]]})}),u.jsx("div",{ref:E})]}),u.jsxs("div",{className:"composer",children:[u.jsxs("div",{className:"composer__box",children:[u.jsx("textarea",{ref:k,className:"composer__input",rows:1,value:n,onChange:D=>r(D.target.value),onKeyDown:D=>{D.key==="Enter"&&!D.shiftKey&&!D.nativeEvent.isComposing&&(D.preventDefault(),z())},placeholder:"Describe your architecture...","aria-label":"Describe your architecture"}),B?u.jsxs("button",{className:"btn btn--sm",onClick:R,children:[u.jsx(ue,{name:"stop",size:13}),"Stop"]}):u.jsxs("button",{className:"btn btn--primary btn--sm",onClick:z,disabled:!n.trim(),children:[u.jsx(ue,{name:"send",size:13}),"Send"]})]}),u.jsxs("div",{className:"composer__hint",children:[u.jsxs("span",{children:[u.jsx("kbd",{children:"Enter"})," sends, ",u.jsx("kbd",{children:"Shift"}),"+",u.jsx("kbd",{children:"Enter"})," adds a line"]}),u.jsxs("span",{children:[u.jsx("kbd",{children:navigator.platform.includes("Mac")?"Cmd":"Ctrl"}),"+",u.jsx("kbd",{children:"K"})," focuses"]})]})]}),u.jsxs("div",{className:"pane-switch",children:[u.jsx("button",{className:"btn btn--sm","aria-pressed":"true",onClick:()=>v("chat"),children:"Chat"}),u.jsx("button",{className:"btn btn--sm","aria-pressed":"false",onClick:()=>v("workspace"),children:"Workspace"})]})]}),u.jsxs("main",{id:"workspace",className:`workspace app__pane${p==="workspace"?" app__pane--active":""}`,children:[u.jsx("div",{className:"workspace__header",children:u.jsx("div",{className:"tabs",role:"tablist","aria-label":"Workspace views",children:Vn.map((D,U)=>u.jsx("button",{ref:X=>{M.current[D.key]=X},className:"tab",role:"tab",id:`tab-${D.key}`,"aria-selected":a===D.key,"aria-controls":`panel-${D.key}`,tabIndex:a===D.key?0:-1,onClick:()=>j(D.key),onKeyDown:X=>O(X,U),children:D.key},D.key))})}),u.jsx(zC,{spec:s,onDownloadTerraform:s?()=>b("terraform"):void 0,onDownloadYaml:s?()=>b("yaml"):void 0,validationSummary:m,usage:y}),u.jsxs("div",{className:"panel-host",children:[f.has("diagram")&&u.jsx("section",{className:"panel",id:"panel-diagram",role:"tabpanel","aria-labelledby":"tab-diagram",hidden:a!=="diagram",style:{overflow:"hidden"},children:s?u.jsxs("div",{className:"diagram",children:[u.jsx(TC,{spec:s,onSpecChange:P}),B&&u.jsxs("div",{className:"canvas-status",children:[u.jsx("span",{className:"dot-pulse"}),Vl[o]]})]}):u.jsx(Rn,{icon:"grid",title:"Design an architecture to see the diagram.",hint:"Every component, connection and trust boundary is drawn from the spec, and stays editable.",action:{label:"Start with the example",onClick:()=>{var D;v("chat"),r(Wl),(D=k.current)==null||D.focus()}}})}),f.has("cost")&&u.jsx("section",{className:"panel",id:"panel-cost",role:"tabpanel","aria-labelledby":"tab-cost",hidden:a!=="cost",children:s!=null&&s.cost_estimate?u.jsx(PC,{estimate:s.cost_estimate}):W("the cost breakdown")}),f.has("validate")&&u.jsx("section",{className:"panel",id:"panel-validate",role:"tabpanel","aria-labelledby":"tab-validate",hidden:a!=="validate",children:s?u.jsx($C,{spec:H,apiBase:tt}):W("validation")}),f.has("compliance")&&u.jsx("section",{className:"panel",id:"panel-compliance",role:"tabpanel","aria-labelledby":"tab-compliance",hidden:a!=="compliance",children:s?u.jsx(OC,{spec:H,apiBase:tt}):W("the control mapping")}),f.has("plan")&&u.jsx("section",{className:"panel",id:"panel-plan",role:"tabpanel","aria-labelledby":"tab-plan",hidden:a!=="plan",children:s?u.jsx(BC,{spec:H,apiBase:tt}):W("the deploy check")}),f.has("review")&&u.jsx("section",{className:"panel",id:"panel-review",role:"tabpanel","aria-labelledby":"tab-review",hidden:a!=="review",children:s?u.jsx(HC,{spec:H,apiBase:tt}):W("the review")}),f.has("export")&&u.jsx("section",{className:"panel",id:"panel-export",role:"tabpanel","aria-labelledby":"tab-export",hidden:a!=="export",children:s?u.jsx(UC,{spec:H,apiBase:tt}):W("export")}),f.has("spec")&&u.jsx("section",{className:"panel",id:"panel-spec",role:"tabpanel","aria-labelledby":"tab-spec",hidden:a!=="spec",children:s?u.jsx(KC,{spec:s,yaml:A,apiBase:tt}):W("the spec view")}),f.has("modify")&&u.jsx("section",{className:"panel",id:"panel-modify",role:"tabpanel","aria-labelledby":"tab-modify",hidden:a!=="modify",children:s?u.jsxs("div",{className:"panel__body",children:[u.jsx("h2",{className:"panel__title",children:"Change this architecture in one sentence"}),u.jsx("p",{className:"panel__lede",children:"The same engine the chat panel uses. Cost and validation refresh after every change."}),u.jsxs("div",{style:{display:"flex",gap:"var(--space-2)",maxWidth:640},children:[u.jsx("input",{className:"field",value:S,"aria-label":"Modification instruction",disabled:B,onChange:D=>g(D.target.value),onKeyDown:D=>{if(D.key!=="Enter"||D.nativeEvent.isComposing)return;const U=S.trim();!U||B||(g(""),$(U,{echoUser:!0}))},placeholder:"e.g. Add a Redis cache between web and database"}),u.jsx("button",{className:"btn btn--primary",disabled:B||!S.trim(),onClick:()=>{const D=S.trim();D&&(g(""),$(D,{echoUser:!0}))},children:"Apply"})]}),u.jsx("div",{className:"status-row",role:"status","aria-live":"polite",children:B&&u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"spinner"}),Vl[o]]})})]}):W("modification")})]}),u.jsxs("div",{className:"pane-switch",children:[u.jsx("button",{className:"btn btn--sm","aria-pressed":"false",onClick:()=>v("chat"),children:"Chat"}),u.jsx("button",{className:"btn btn--sm","aria-pressed":"true",onClick:()=>v("workspace"),children:"Workspace"})]})]}),u.jsx(ey,{open:x,title:"Discard this session?",body:"The current architecture, the chat history and every panel result are cleared.",confirmLabel:"Discard and start fresh",destructive:!0,onConfirm:N,onCancel:()=>w(!1)})]})}QC();Ul.createRoot(document.getElementById("root")).render(u.jsx(ih.StrictMode,{children:u.jsx(vC,{children:u.jsx(nE,{})})})); diff --git a/packages/web/cloudwright_web/static/index.html b/packages/web/cloudwright_web/static/index.html index 1bc55bb..2e8ffee 100644 --- a/packages/web/cloudwright_web/static/index.html +++ b/packages/web/cloudwright_web/static/index.html @@ -2,14 +2,17 @@ - - Cloudwright — Architecture Intelligence - - - + + + + + + Cloudwright, Architecture Intelligence + +
diff --git a/packages/web/frontend/index.html b/packages/web/frontend/index.html index b7cf561..a7cac31 100644 --- a/packages/web/frontend/index.html +++ b/packages/web/frontend/index.html @@ -2,12 +2,15 @@ - - Cloudwright — Architecture Intelligence - + + + + + + Cloudwright, Architecture Intelligence
diff --git a/packages/web/frontend/src/App.tsx b/packages/web/frontend/src/App.tsx index 6175ca1..9074e9e 100644 --- a/packages/web/frontend/src/App.tsx +++ b/packages/web/frontend/src/App.tsx @@ -1,4 +1,4 @@ -import React, { useState, useRef, useEffect } from "react"; +import React, { useCallback, useEffect, useMemo, useRef, useState } from "react"; import ArchitectureDiagram from "./components/ArchitectureDiagram"; import CostTable from "./components/CostTable"; import SummaryBar from "./components/SummaryBar"; @@ -8,7 +8,12 @@ import PlanPanel from "./components/PlanPanel"; import ReviewPanel from "./components/ReviewPanel"; import ExportPanel from "./components/ExportPanel"; import SpecPanel from "./components/SpecPanel"; +import ConfirmDialog from "./components/ConfirmDialog"; +import EmptyState from "./components/EmptyState"; +import Icon, { type IconName } from "./components/Icon"; import { parseApiError, formatApiError } from "./lib/apiError"; +import { useTheme } from "./lib/theme"; +import { useToast } from "./lib/toast"; interface ArchSpec { name: string; @@ -68,15 +73,40 @@ interface UsageInfo { interface Message { role: "user" | "assistant"; content: string; + isError?: boolean; spec?: ArchSpec; yaml?: string; suggestions?: string[]; } type LoadingStage = "idle" | "generating" | "modifying" | "costing" | "done"; +type TabKey = + | "diagram" | "cost" | "validate" | "compliance" + | "plan" | "review" | "export" | "spec" | "modify"; const API_BASE = "/api"; +const TABS: { key: TabKey; icon: IconName }[] = [ + { key: "diagram", icon: "grid" }, + { key: "cost", icon: "layers" }, + { key: "validate", icon: "check" }, + { key: "compliance", icon: "check" }, + { key: "plan", icon: "refresh" }, + { key: "review", icon: "alert" }, + { key: "export", icon: "download" }, + { key: "spec", icon: "panel" }, + { key: "modify", icon: "chat" }, +]; + +const STAGE_TEXT: Record, string> = { + generating: "Generating architecture...", + modifying: "Modifying architecture...", + costing: "Estimating cost and validating...", + done: "Finalizing...", +}; + +const EXAMPLE_PROMPT = "3-tier web app on AWS with CloudFront, ALB, EC2, and RDS"; + const ALL_SUGGESTIONS = [ "Add caching layer", "Reduce cost", @@ -111,16 +141,19 @@ function pickSuggestions(spec: ArchSpec): string[] { } function renderMarkdown(text: string): React.ReactNode[] { - return text.split(/(\*\*.*?\*\*)/g).map((part, i) => - part.startsWith('**') && part.endsWith('**') - ? {part.slice(2, -2)} - : {part} - ); + return text.split(/(\*\*.*?\*\*|`[^`]+`)/g).map((part, i) => { + if (part.startsWith("**") && part.endsWith("**")) return {part.slice(2, -2)}; + if (part.startsWith("`") && part.endsWith("`") && part.length > 2) { + return {part.slice(1, -1)}; + } + return {part}; + }); } async function enrichSpec( rawSpec: ArchSpec, setValidationSummary: (v: { passed: number; total: number } | null) => void, + signal?: AbortSignal, ): Promise { let spec = rawSpec; const [costResult, valResult] = await Promise.all([ @@ -128,11 +161,13 @@ async function enrichSpec( method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ spec }), + signal, }).then(r => r.ok ? r.json() : null).catch(() => null), fetch(`${API_BASE}/validate`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ spec, compliance: [], well_architected: true }), + signal, }).then(r => r.ok ? r.json() : null).catch(() => null), ]); @@ -147,33 +182,35 @@ async function enrichSpec( return spec; } +interface StreamCallbacks { + onStage: (stage: string, message?: string) => void; + onSpec: (spec: ArchSpec, yaml: string) => void; + onCost: (estimate: CostEstimate | null) => void; + onValidation: (passed: number | null, total: number | null) => void; + onDone: (spec: ArchSpec, yaml: string) => void; + onUsage?: (usage: UsageInfo) => void; +} + +/** Reads the SSE stream. Throws on a transport failure or a server `error` event, + * so the caller can decide whether a retry is safe. */ async function streamDesignOrModify( isModify: boolean, payload: object, - callbacks: { - onStage: (stage: string, message?: string) => void; - onSpec: (spec: ArchSpec, yaml: string) => void; - onCost: (estimate: CostEstimate | null) => void; - onValidation: (passed: number | null, total: number | null) => void; - onDone: (spec: ArchSpec, yaml: string) => void; - onUsage?: (usage: UsageInfo) => void; - onError: (message: string) => void; - } + callbacks: StreamCallbacks, + signal?: AbortSignal, ) { const endpoint = isModify ? `${API_BASE}/modify/stream` : `${API_BASE}/design/stream`; const response = await fetch(endpoint, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(payload), + signal, }); - if (!response.ok) { - callbacks.onError(await parseApiError(response)); - return; - } + if (!response.ok) throw new Error(await parseApiError(response)); const reader = response.body?.getReader(); - if (!reader) return; + if (!reader) throw new Error("Streaming is not available in this browser."); const decoder = new TextDecoder(); let buffer = ""; @@ -188,33 +225,35 @@ async function streamDesignOrModify( for (const line of lines) { if (!line.startsWith("data: ")) continue; + let event: Record; try { - const event = JSON.parse(line.slice(6)); - switch (event.stage) { - case "generating": - case "costing": - case "validating": - callbacks.onStage(event.stage, event.message); - break; - case "generated": - callbacks.onSpec(event.spec, event.yaml); - if (event.usage && callbacks.onUsage) callbacks.onUsage(event.usage); - break; - case "costed": - callbacks.onCost(event.cost_estimate); - break; - case "validated": - callbacks.onValidation(event.passed, event.total); - break; - case "done": - callbacks.onDone(event.spec, event.yaml); - if (event.usage && callbacks.onUsage) callbacks.onUsage(event.usage); - break; - case "error": - callbacks.onError(event.message); - break; - } - } catch { /* skip malformed events */ } + event = JSON.parse(line.slice(6)); + } catch { + continue; // skip malformed events + } + switch (event.stage) { + case "generating": + case "costing": + case "validating": + callbacks.onStage(event.stage as string, event.message as string | undefined); + break; + case "generated": + callbacks.onSpec(event.spec as ArchSpec, event.yaml as string); + if (event.usage && callbacks.onUsage) callbacks.onUsage(event.usage as UsageInfo); + break; + case "costed": + callbacks.onCost(event.cost_estimate as CostEstimate | null); + break; + case "validated": + callbacks.onValidation(event.passed as number | null, event.total as number | null); + break; + case "done": + callbacks.onDone(event.spec as ArchSpec, event.yaml as string); + if (event.usage && callbacks.onUsage) callbacks.onUsage(event.usage as UsageInfo); + break; + case "error": + throw new Error((event.message as string) || "The server reported an error."); + } } } } @@ -224,236 +263,350 @@ function App() { const [input, setInput] = useState(""); const [loadingStage, setLoadingStage] = useState("idle"); const [currentSpec, setCurrentSpec] = useState(null); - const [activeTab, setActiveTab] = useState< - "diagram" | "cost" | "validate" | "compliance" | "plan" | "review" | "export" | "spec" | "modify" - >("diagram"); + const [activeTab, setActiveTab] = useState("diagram"); + const [visited, setVisited] = useState>(() => new Set(["diagram"])); + const [mobilePane, setMobilePane] = useState<"chat" | "workspace">("chat"); + const [confirmReset, setConfirmReset] = useState(false); const [modifyInput, setModifyInput] = useState(""); const [validationSummary, setValidationSummary] = useState<{ passed: number; total: number } | null>(null); const [lastUsage, setLastUsage] = useState(null); - const inputRef = useRef(null); + + const inputRef = useRef(null); const chatEndRef = useRef(null); + const tabRefs = useRef>({}); + const abortRef = useRef(null); - useEffect(() => { - chatEndRef.current?.scrollIntoView({ behavior: "smooth" }); - }, [messages]); + const { theme, toggleTheme } = useTheme(); + const { notify } = useToast(); - const sendMessage = async () => { - if (!input.trim() || loadingStage !== "idle") return; - const userMsg: Message = { role: "user", content: input }; - setMessages((prev) => [...prev, userMsg]); - setInput(""); + const busy = loadingStage !== "idle"; + + useEffect(() => { + chatEndRef.current?.scrollIntoView({ behavior: "smooth", block: "end" }); + }, [messages, loadingStage]); - const isModify = currentSpec !== null; - setLoadingStage(isModify ? "modifying" : "generating"); + const selectTab = useCallback((key: TabKey) => { + setActiveTab(key); + setVisited((seen) => (seen.has(key) ? seen : new Set(seen).add(key))); + setMobilePane("workspace"); + }, []); - // Track final spec and yaml across streaming callbacks - let finalSpec: ArchSpec | null = null; - let finalYaml = ""; - let streamSucceeded = false; + // Grow the composer with its content, up to the CSS max-height. + useEffect(() => { + const node = inputRef.current; + if (!node) return; + node.style.height = "auto"; + node.style.height = `${Math.min(node.scrollHeight, 168)}px`; + }, [input]); + + const runTurn = useCallback( + async (instruction: string, options: { echoUser: boolean }) => { + const isModify = currentSpec !== null; + const controller = new AbortController(); + abortRef.current = controller; + setLoadingStage(isModify ? "modifying" : "generating"); + + let finalSpec: ArchSpec | null = null; + let finalYaml = ""; + let streamFailed = false; + let streamError: unknown = null; + + if (options.echoUser) { + setMessages((prev) => [...prev, { role: "user", content: instruction }]); + } - try { - const payload = isModify - ? { spec: currentSpec, instruction: input } - : { description: input }; + const callbacks: StreamCallbacks = { + onStage: (stage) => { + if (stage === "generating") setLoadingStage(isModify ? "modifying" : "generating"); + else if (stage === "costing" || stage === "validating") setLoadingStage("costing"); + }, + onSpec: (spec) => { + // Early render, so the diagram appears before pricing finishes. + setCurrentSpec(spec); + finalSpec = spec; + setLoadingStage("costing"); + }, + onCost: (estimate) => { + if (estimate && finalSpec) { + finalSpec = { ...finalSpec, cost_estimate: estimate }; + setCurrentSpec(finalSpec); + } + }, + onValidation: (passed, total) => { + if (passed !== null) setValidationSummary({ passed, total: total ?? 0 }); + }, + onDone: (spec, yaml) => { + finalSpec = spec; + finalYaml = yaml; + setCurrentSpec(spec); + setLoadingStage("done"); + }, + onUsage: (usage) => setLastUsage(usage), + }; - // Try streaming endpoint first; fall back to regular on failure try { - await streamDesignOrModify(isModify, payload, { - onStage: (stage) => { - if (stage === "generating") setLoadingStage("generating"); - else if (stage === "costing" || stage === "validating") setLoadingStage("costing"); - }, - onSpec: (spec) => { - // Early render — show diagram as soon as spec is ready - setCurrentSpec(spec); - finalSpec = spec; - setLoadingStage("costing"); - }, - onCost: (estimate) => { - if (estimate && finalSpec) { - finalSpec = { ...finalSpec, cost_estimate: estimate }; - setCurrentSpec(finalSpec); - } - }, - onValidation: (passed, total) => { - if (passed !== null) setValidationSummary({ passed, total: total! }); - }, - onDone: (spec, yaml) => { - finalSpec = spec; - finalYaml = yaml; - setCurrentSpec(spec); - setLoadingStage("done"); + const payload = isModify ? { spec: currentSpec, instruction } : { description: instruction }; + + try { + await streamDesignOrModify(isModify, payload, callbacks, controller.signal); + } catch (err) { + if (controller.signal.aborted) throw err; + streamFailed = true; + streamError = err; + } + + // Retry without streaming only when the stream produced nothing. Retrying + // after a spec arrived would bill a second generation and overwrite the first. + if (streamFailed && finalSpec !== null) throw streamError; + + if (streamFailed) { + setLoadingStage(isModify ? "modifying" : "generating"); + const res = await fetch(`${API_BASE}/${isModify ? "modify" : "design"}`, { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify(payload), + signal: controller.signal, + }); + const data = await res.json(); + if (!res.ok) throw new Error(formatApiError(data)); + finalYaml = data.yaml; + if (data.usage) setLastUsage(data.usage as UsageInfo); + + setLoadingStage("costing"); + finalSpec = await enrichSpec(data.spec as ArchSpec, setValidationSummary, controller.signal); + setCurrentSpec(finalSpec); + setLoadingStage("done"); + } + + const spec = finalSpec as ArchSpec | null; + if (!spec) throw new Error("The server returned no architecture."); + + const verb = isModify ? "Modified" : "Designed"; + const cost = spec.cost_estimate + ? ` Estimated cost: $${spec.cost_estimate.monthly_total.toFixed(2)}/mo.` + : ""; + setMessages((prev) => [ + ...prev, + { + role: "assistant", + content: `${verb} **${spec.name}** with ${spec.components.length} components on ${spec.provider.toUpperCase()}.${cost}`, + spec, + yaml: finalYaml, + suggestions: pickSuggestions(spec), }, - onUsage: (usage) => setLastUsage(usage), - onError: (msg) => { throw new Error(msg); }, + ]); + selectTab("diagram"); + } catch (err) { + if (controller.signal.aborted) { + setMessages((prev) => [...prev, { role: "assistant", content: "Stopped.", isError: true }]); + } else { + const text = err instanceof Error ? err.message : "Unknown error"; + setMessages((prev) => [...prev, { role: "assistant", content: `Error: ${text}`, isError: true }]); + notify(text); + } + } finally { + abortRef.current = null; + setLoadingStage("idle"); + inputRef.current?.focus(); + } + }, + [currentSpec, notify, selectTab], + ); + + const sendMessage = useCallback(() => { + const text = input.trim(); + if (!text || busy) return; + setInput(""); + void runTurn(text, { echoUser: true }); + }, [busy, input, runTurn]); + + const stopGeneration = useCallback(() => { + abortRef.current?.abort(); + }, []); + + const resetSession = useCallback(() => { + setConfirmReset(false); + setCurrentSpec(null); + setMessages([]); + setValidationSummary(null); + setLastUsage(null); + setVisited(new Set(["diagram"])); + setActiveTab("diagram"); + inputRef.current?.focus(); + }, []); + + const handleDownload = useCallback( + async (format: string) => { + if (!currentSpec) return; + try { + const res = await fetch(`${API_BASE}/download`, { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ spec: currentSpec, format }), }); - streamSucceeded = finalSpec !== null; + if (!res.ok) { + notify(await parseApiError(res)); + return; + } + const blob = await res.blob(); + const disposition = res.headers.get("Content-Disposition") || ""; + const match = disposition.match(/filename=([^\s;]+)/); + const filename = match ? match[1] : `architecture.${format === "terraform" ? "tf" : "yaml"}`; + const url = URL.createObjectURL(blob); + const a = document.createElement("a"); + a.href = url; + a.download = filename; + a.click(); + URL.revokeObjectURL(url); } catch { - // Streaming endpoint not available or failed — fall through to non-streaming - setLoadingStage(isModify ? "modifying" : "generating"); + notify("Download failed. Check that the server is still running."); } + }, + [currentSpec, notify], + ); - if (!streamSucceeded) { - // Non-streaming fallback - const res = isModify - ? await fetch(`${API_BASE}/modify`, { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ spec: currentSpec, instruction: input }), - }) - : await fetch(`${API_BASE}/design`, { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ description: input }), - }); - const data = await res.json(); - if (!res.ok) throw new Error(formatApiError(data)); - finalSpec = data.spec as ArchSpec; - finalYaml = data.yaml; - if (data.usage) setLastUsage(data.usage as UsageInfo); - - setLoadingStage("costing"); - finalSpec = await enrichSpec(finalSpec, setValidationSummary); - setCurrentSpec(finalSpec); - setLoadingStage("done"); + const handleSpecChange = useCallback( + async (updatedSpec: ArchSpec) => { + setCurrentSpec(updatedSpec); + setValidationSummary(null); + try { + setCurrentSpec(await enrichSpec(updatedSpec, setValidationSummary)); + } catch { + // Keep the deterministic canvas edit even if cost or validation refresh fails. } + }, + [], + ); - const spec = finalSpec!; - const verb = isModify ? "Modified" : "Designed"; - const assistantMsg: Message = { - role: "assistant", - content: `${verb} **${spec.name}** with ${spec.components.length} components on ${spec.provider.toUpperCase()}.${spec.cost_estimate ? ` Estimated cost: $${spec.cost_estimate.monthly_total.toFixed(2)}/mo.` : ""}`, - spec, - yaml: finalYaml, - suggestions: pickSuggestions(spec), + // Arrow-key roving focus across the tab list, per the WAI-ARIA tabs pattern. + const onTabKeyDown = useCallback( + (event: React.KeyboardEvent, index: number) => { + const keys: Record = { + ArrowRight: index + 1, + ArrowLeft: index - 1, + Home: 0, + End: TABS.length - 1, }; - setMessages((prev) => [...prev, assistantMsg]); - setActiveTab("diagram"); - } catch (err) { - const errorMsg = err instanceof Error ? err.message : "Unknown error"; - setMessages((prev) => [ - ...prev, - { role: "assistant", content: `Error: ${errorMsg}` }, - ]); - } finally { - setLoadingStage("idle"); - inputRef.current?.focus(); - } - }; + const target = keys[event.key]; + if (target === undefined) return; + event.preventDefault(); + const next = TABS[(target + TABS.length) % TABS.length]; + selectTab(next.key); + tabRefs.current[next.key]?.focus(); + }, + [selectTab], + ); - const handleDownload = async (format: string) => { - if (!currentSpec) return; - try { - const res = await fetch(`${API_BASE}/download`, { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ spec: currentSpec, format }), - }); - if (!res.ok) return; - const blob = await res.blob(); - const disposition = res.headers.get("Content-Disposition") || ""; - const match = disposition.match(/filename=([^\s;]+)/); - const filename = match ? match[1] : `architecture.${format === "terraform" ? "tf" : "yaml"}`; - const url = URL.createObjectURL(blob); - const a = document.createElement("a"); - a.href = url; - a.download = filename; - a.click(); - URL.revokeObjectURL(url); - } catch { - // download is best-effort - } - }; + useEffect(() => { + const onKey = (event: KeyboardEvent) => { + const meta = event.metaKey || event.ctrlKey; + if (meta && event.key.toLowerCase() === "k") { + event.preventDefault(); + setMobilePane("chat"); + inputRef.current?.focus(); + return; + } + if (meta && /^[1-9]$/.test(event.key)) { + event.preventDefault(); + selectTab(TABS[Number(event.key) - 1].key); + } + }; + window.addEventListener("keydown", onKey); + return () => window.removeEventListener("keydown", onKey); + }, [selectTab]); - const handleSpecChange = async (updatedSpec: ArchSpec) => { - setCurrentSpec(updatedSpec); - setValidationSummary(null); - try { - const enriched = await enrichSpec(updatedSpec, setValidationSummary); - setCurrentSpec(enriched); - } catch { - // Keep the deterministic canvas edit even if cost or validation refresh fails. - } - }; + const lastYaml = useMemo( + () => messages.filter((m) => m.yaml).pop()?.yaml ?? "", + [messages], + ); + + const specRecord = currentSpec as unknown as Record; + + const panelPlaceholder = (label: string) => ( + { + setMobilePane("chat"); + inputRef.current?.focus(); + }, + }} + /> + ); return ( -
- {/* Sidebar - Chat */} -
-
-
-

Cloudwright

-

Architecture Intelligence

+
+ + Skip to workspace + + +